Browse Source

Add icons to show abilities and their charge cost

master
Luna 7 years ago
parent
commit
5ef3aa9543
7 changed files with 250 additions and 14 deletions
  1. +146
    -0
      scenes/ability_icon.tscn
  2. +17
    -4
      scenes/heroes/0.tscn
  3. +16
    -3
      scenes/heroes/4.tscn
  4. +29
    -2
      scenes/heroes/5.tscn
  5. +28
    -0
      scripts/ability_icon.gd
  6. +12
    -5
      scripts/heroes/4.gd
  7. +2
    -0
      scripts/heroes/5.gd

+ 146
- 0
scenes/ability_icon.tscn View File

@ -0,0 +1,146 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scripts/ability_icon.gd" type="Script" id=1]
[sub_resource type="StyleBoxFlat" id=2]
content_margin_left = -1.0
content_margin_right = -1.0
content_margin_top = -1.0
content_margin_bottom = -1.0
bg_color = Color( 0.0297089, 0.230469, 0.206942, 1 )
draw_center = true
border_width_left = 0
border_width_top = 0
border_width_right = 0
border_width_bottom = 0
border_color = Color( 0.8, 0.8, 0.8, 1 )
border_blend = false
corner_radius_top_left = 0
corner_radius_top_right = 0
corner_radius_bottom_right = 0
corner_radius_bottom_left = 0
corner_detail = 8
expand_margin_left = 0.0
expand_margin_right = 0.0
expand_margin_top = 0.0
expand_margin_bottom = 0.0
shadow_color = Color( 0, 0, 0, 0.6 )
shadow_size = 0
anti_aliasing = true
anti_aliasing_size = 1
[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = -1.0
content_margin_right = -1.0
content_margin_top = -1.0
content_margin_bottom = -1.0
bg_color = Color( 0.73822, 0.921875, 0.814265, 0.403333 )
draw_center = true
border_width_left = 0
border_width_top = 0
border_width_right = 0
border_width_bottom = 0
border_color = Color( 0.8, 0.8, 0.8, 1 )
border_blend = false
corner_radius_top_left = 0
corner_radius_top_right = 0
corner_radius_bottom_right = 0
corner_radius_bottom_left = 0
corner_detail = 8
expand_margin_left = 0.0
expand_margin_right = 0.0
expand_margin_top = 0.0
expand_margin_bottom = 0.0
shadow_color = Color( 0, 0, 0, 0.6 )
shadow_size = 0
anti_aliasing = true
anti_aliasing_size = 1
[node name="Ability" type="Control"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -6.0
margin_top = -4.0
margin_right = 5.0
margin_bottom = 5.0
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 0
script = ExtResource( 1 )
cost = 1
ability_name = "Ability"
display_progress = true
[node name="Bar" type="ProgressBar" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -20.0
margin_top = -21.0
margin_right = 30.0
margin_bottom = 28.0
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 0
custom_styles/fg = SubResource( 2 )
custom_styles/bg = SubResource( 1 )
min_value = 0.0
max_value = 100.0
step = 1.0
page = 0.0
value = 0.0
exp_edit = false
rounded = false
percent_visible = false
[node name="Available" type="ColorRect" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -25.0
margin_top = -26.0
margin_right = 25.0
margin_bottom = 23.0
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 0
color = Color( 0.347443, 0.898438, 0.549761, 1 )
[node name="Name" type="Label" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -65.0
margin_top = 36.0
margin_right = 77.0
margin_bottom = 50.0
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0.00357056, 0.0703125, 0.04372, 1 )
text = "<Name>"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

+ 17
- 4
scenes/heroes/0.tscn View File

@ -1,11 +1,12 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/heroes/0.gd" type="Script" id=2] [ext_resource path="res://scripts/heroes/0.gd" type="Script" id=2]
[ext_resource path="res://assets/heroes/0_head.obj" type="ArrayMesh" id=3] [ext_resource path="res://assets/heroes/0_head.obj" type="ArrayMesh" id=3]
[ext_resource path="res://assets/heroes/0.obj" type="ArrayMesh" id=4] [ext_resource path="res://assets/heroes/0.obj" type="ArrayMesh" id=4]
[ext_resource path="res://scenes/ability_icon.tscn" type="PackedScene" id=5]
[node name="RigidBody" index="0" instance=ExtResource( 1 )]
[node name="RigidBody" instance=ExtResource( 1 )]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -13,16 +14,28 @@ script = ExtResource( 2 )
transform = Transform( 0.376731, 0, 6.23012e-08, -6.13772e-08, 1.03258e-14, 0.382402, 0, -0.389018, 1.01502e-14, 0, 0.104562, -0.0173855 ) transform = Transform( 0.376731, 0, 6.23012e-08, -6.13772e-08, 1.03258e-14, 0.382402, 0, -0.389018, 1.01502e-14, 0, 0.104562, -0.0173855 )
mesh = ExtResource( 3 ) mesh = ExtResource( 3 )
material/0 = null
[node name="MainMesh" parent="Yaw" index="1"] [node name="MainMesh" parent="Yaw" index="1"]
transform = Transform( 0.409321, 0, 0, 0, -7.39614e-08, -0.453971, 0, 0.389055, -6.33852e-08, 0.0432051, 0.588691, 0.0666541 ) transform = Transform( 0.409321, 0, 0, 0, -7.39614e-08, -0.453971, 0, 0.389055, -6.33852e-08, 0.0432051, 0.588691, 0.0666541 )
mesh = ExtResource( 4 ) mesh = ExtResource( 4 )
material/0 = null
[node name="Crosshair" parent="MasterOnly" index="0"] [node name="Crosshair" parent="MasterOnly" index="0"]
text = "" text = ""
[node name="ProgressBar" parent="MasterOnly" index="1" instance=ExtResource( 5 )]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -91.0
margin_top = -118.0
margin_right = -80.0
margin_bottom = -109.0
cost = 2
ability_name = "Speed Boost"
display_progress = false

+ 16
- 3
scenes/heroes/4.tscn View File

@ -1,12 +1,13 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/heroes/4.gd" type="Script" id=2] [ext_resource path="res://scripts/heroes/4.gd" type="Script" id=2]
[ext_resource path="res://assets/heroes/4_head.obj" type="ArrayMesh" id=3] [ext_resource path="res://assets/heroes/4_head.obj" type="ArrayMesh" id=3]
[ext_resource path="res://assets/heroes/4_beam.obj" type="ArrayMesh" id=4] [ext_resource path="res://assets/heroes/4_beam.obj" type="ArrayMesh" id=4]
[ext_resource path="res://assets/heroes/4.obj" type="ArrayMesh" id=5] [ext_resource path="res://assets/heroes/4.obj" type="ArrayMesh" id=5]
[ext_resource path="res://scenes/ability_icon.tscn" type="PackedScene" id=6]
[node name="RigidBody" index="0" instance=ExtResource( 1 )]
[node name="RigidBody" instance=ExtResource( 1 )]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -29,10 +30,22 @@ lod_max_hysteresis = 0.0
mesh = ExtResource( 4 ) mesh = ExtResource( 4 )
skeleton = NodePath("..") skeleton = NodePath("..")
material/0 = null material/0 = null
_sections_unfolded = [ "Transform" ]
[node name="MainMesh" parent="Yaw" index="1"] [node name="MainMesh" parent="Yaw" index="1"]
mesh = ExtResource( 5 ) mesh = ExtResource( 5 )
[node name="Destroy" parent="MasterOnly" index="2" instance=ExtResource( 6 )]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -109.0
margin_top = -100.0
margin_right = -98.0
margin_bottom = -91.0
cost = 0
ability_name = "Destroy"

+ 29
- 2
scenes/heroes/5.tscn View File

@ -1,11 +1,12 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/heroes/5.gd" type="Script" id=2] [ext_resource path="res://scripts/heroes/5.gd" type="Script" id=2]
[ext_resource path="res://assets/heroes/5_head.obj" type="ArrayMesh" id=3] [ext_resource path="res://assets/heroes/5_head.obj" type="ArrayMesh" id=3]
[ext_resource path="res://assets/heroes/5.obj" type="ArrayMesh" id=4] [ext_resource path="res://assets/heroes/5.obj" type="ArrayMesh" id=4]
[ext_resource path="res://scenes/ability_icon.tscn" type="PackedScene" id=5]
[node name="RigidBody" index="0" instance=ExtResource( 1 )]
[node name="RigidBody" instance=ExtResource( 1 )]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -19,4 +20,30 @@ mesh = ExtResource( 3 )
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.556542, 0 ) transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.556542, 0 )
mesh = ExtResource( 4 ) mesh = ExtResource( 4 )
[node name="Portal" parent="MasterOnly" index="2" instance=ExtResource( 5 )]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -160.0
margin_top = -112.0
margin_right = -149.0
margin_bottom = -103.0
cost = 20
ability_name = "Build Portal"
[node name="Teleport" parent="MasterOnly" index="3" instance=ExtResource( 5 )]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -70.0
margin_top = -112.0
margin_right = -59.0
margin_bottom = -103.0
cost = 5
ability_name = "Teleport"

+ 28
- 0
scripts/ability_icon.gd View File

@ -0,0 +1,28 @@
extends Control
onready var hero = get_node("../..")
onready var bar = get_node("Bar")
onready var available = get_node("Available")
export var cost = 1
export var ability_name = "Ability"
export var display_progress = true
# This is intended to be public
var disabled = false
func _ready():
get_node("Name").text = ability_name
func _process(delta):
if disabled:
available.hide()
bar.value = 0
else:
if display_progress:
if cost == 0:
bar.value = 100 if hero.switch_charge > 0 else 0
else:
bar.value = 100 * hero.switch_charge / cost
if hero.switch_charge > cost:
available.show()
else:
available.hide()

+ 12
- 5
scripts/heroes/4.gd View File

@ -2,6 +2,8 @@
extends "res://scripts/player.gd" extends "res://scripts/player.gd"
onready var destroy_ability = get_node("MasterOnly/Destroy")
var stun_charge = 1 var stun_charge = 1
var velocity_charge = 10 # This one is instantaneous, so it gets quita weight var velocity_charge = 10 # This one is instantaneous, so it gets quita weight
@ -28,11 +30,16 @@ func _process(delta):
get_node("TPCamera").cam_view_sensitivity *= sens_factor get_node("TPCamera").cam_view_sensitivity *= sens_factor
get_node("TPCamera").cam_smooth_movement = true get_node("TPCamera").cam_smooth_movement = true
if Input.is_action_just_pressed("primary_ability"):
var looking_at = pick()
if looking_at.has_method("destroy"):
if switch_charge > looking_at.destroy_cost:
switch_charge -= looking_at.destroy()
var looking_at = pick()
if looking_at and looking_at.has_method("destroy"):
destroy_ability.cost = looking_at.destroy_cost
destroy_ability.disabled = false
if Input.is_action_just_pressed("primary_ability"):
if switch_charge > looking_at.destroy_cost:
switch_charge -= looking_at.destroy_cost
looking_at.rpc("destroy")
else:
destroy_ability.disabled = true
if stun: if stun:
var players = get_node("/root/Level/Players").get_children() var players = get_node("/root/Level/Players").get_children()


+ 2
- 0
scripts/heroes/5.gd View File

@ -1,6 +1,7 @@
extends "res://scripts/player.gd" extends "res://scripts/player.gd"
onready var placement = preload("res://scripts/placement.gd").new(self, "res://scenes/heroes/5_portal.tscn") onready var placement = preload("res://scripts/placement.gd").new(self, "res://scenes/heroes/5_portal.tscn")
onready var teleport_ability = get_node("MasterOnly/Teleport")
var radius = 15 var radius = 15
# The spaces make the bracket centered, rather than on of the dots # The spaces make the bracket centered, rather than on of the dots
@ -47,6 +48,7 @@ func _process(delta):
rpc("flick", flicking.get_name(), towards) rpc("flick", flicking.get_name(), towards)
flicking = null flicking = null
switch_charge += flick_charge switch_charge += flick_charge
teleport_ability.disabled = placement.placed.size() <= 1
func _exit_tree(): func _exit_tree():
._exit_tree() ._exit_tree()


Loading…
Cancel
Save