From 6e2bc0c01d3ab09ba57efa4d6f4e13e4fa9deb9a Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 20 Jul 2020 14:59:31 -0500 Subject: [PATCH] Added UI selection boxes --- ai/Enemy.gd | 2 +- ai/SpinningBone.tscn | 2 +- magic/Projectiles/Projectile.gd | 1 - script/Inventory.gd | 31 ++++++++++++++++++++++++ ui/Inventory.tscn | 41 ++++++++++++++++++++++++++++---- ui/box select.png | Bin 0 -> 402 bytes ui/box select.png.import | 34 ++++++++++++++++++++++++++ 7 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 ui/box select.png create mode 100644 ui/box select.png.import diff --git a/ai/Enemy.gd b/ai/Enemy.gd index 753ef10..cc857ab 100644 --- a/ai/Enemy.gd +++ b/ai/Enemy.gd @@ -4,7 +4,7 @@ class_name Enemy var speed = 60 var gravity = 500 -var health = 5 +var health = 1 const UP = Vector2(0, -1) var velocity = Vector2() diff --git a/ai/SpinningBone.tscn b/ai/SpinningBone.tscn index c630294..7e6cff6 100644 --- a/ai/SpinningBone.tscn +++ b/ai/SpinningBone.tscn @@ -26,7 +26,7 @@ height = 2.0 [node name="Bone" type="KinematicBody2D"] collision_layer = 16 -collision_mask = 11 +collision_mask = 3 script = ExtResource( 2 ) __meta__ = { "_edit_group_": true diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index d8cbca7..8c8c6b6 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -18,6 +18,5 @@ func launch(wand, effect): func on_impact(collision): if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy": var c = collision.collider - print(c.health) c.health -= damage queue_free() diff --git a/script/Inventory.gd b/script/Inventory.gd index a1a7747..4f8f28b 100644 --- a/script/Inventory.gd +++ b/script/Inventory.gd @@ -9,6 +9,8 @@ var active_projectile = null var active_effect = null onready var Anim = $AnimationPlayer +onready var ConduitSelect = $Inventory/ConduitSelect +onready var ProjectileSelect = $Inventory/ProjectileSelect ### onready var Conduits = $Conduits @@ -17,12 +19,22 @@ onready var Conduit2 = $Inventory/Conduits/Conduit2 onready var Conduit3 = $Inventory/Conduits/Conduit3 onready var Conduit4 = $Inventory/Conduits/Conduit4 +onready var Conduit1Position = $Inventory/Conduits/Conduit1/Position2D +onready var Conduit2Position = $Inventory/Conduits/Conduit2/Position2D +onready var Conduit3Position = $Inventory/Conduits/Conduit3/Position2D +onready var Conduit4Position = $Inventory/Conduits/Conduit4/Position2D + onready var Projectiles = $Inventory/Projectiles onready var Projectile1 = $Inventory/Projectiles/Projectile1 onready var Projectile2 = $Inventory/Projectiles/Projectile2 onready var Projectile3 = $Inventory/Projectiles/Projectile3 onready var Projectile4 = $Inventory/Projectiles/Projectile4 +onready var Projectile1Position = $Inventory/Projectiles/Projectile1/Position2D +onready var Projectile2Position = $Inventory/Projectiles/Projectile2/Position2D +onready var Projectile3Position = $Inventory/Projectiles/Projectile3/Position2D +onready var Projectile4Position = $Inventory/Projectiles/Projectile4/Position2D + onready var Effects = $Inventory/Effects onready var Effect1 = $Inventory/Effects/Effect1 onready var Effect2 = $Inventory/Effects/Effect2 @@ -34,6 +46,17 @@ func _process(delta): if Input.is_action_just_pressed("inventory"): set_open(!open) + if active_conduit == null: + ConduitSelect.visible = false + else: + ConduitSelect.visible = true + + if active_projectile == null: + ProjectileSelect.visible = false + else: + ProjectileSelect.visible = true + + func _input(event): if event.is_action_pressed("ui_end"): set_open(false) @@ -79,39 +102,47 @@ func _on_Conduit1_toggled(): if Conduit1.is_visible() and active_conduit != Globals.Magic[Globals.Conduit1]: active_conduit = Globals.Magic[Globals.Conduit1] parent.WandPosition.set_current_conduit(active_conduit) + ConduitSelect.global_position = Conduit1Position.global_position func _on_Conduit2_toggled(): if Conduit2.is_visible() and active_conduit != Globals.Magic[Globals.Conduit2]: active_conduit = Globals.Magic[Globals.Conduit2] parent.WandPosition.set_current_conduit(active_conduit) + ConduitSelect.global_position = Conduit2Position.global_position func _on_Conduit3_toggled(): if Conduit3.is_visible() and active_conduit != Globals.Magic[Globals.Conduit3]: active_conduit = Globals.Magic[Globals.Conduit3] parent.WandPosition.set_current_conduit(active_conduit) + ConduitSelect.global_position = Conduit3Position.global_position func _on_Conduit4_toggled(): if Conduit4.is_visible() and active_conduit != Globals.Magic[Globals.Conduit4]: active_conduit = Globals.Magic[Globals.Conduit4] parent.WandPosition.set_current_conduit(active_conduit) + ConduitSelect.global_position = Conduit4Position.global_position func _on_Projectile1_pressed(): if Projectile1.is_visible() and active_projectile != Globals.Magic[Globals.Projectile1]: active_projectile = Globals.Magic[Globals.Projectile1] + ProjectileSelect.global_position = Projectile1Position.global_position func _on_Projectile2_pressed(): if Projectile2.is_visible() and active_projectile != Globals.Magic[Globals.Projectile2]: active_projectile = Globals.Magic[Globals.Projectile2] + ProjectileSelect.global_position = Projectile2Position.global_position func _on_Projectile3_pressed(): if Projectile3.is_visible() and active_projectile != Globals.Magic[Globals.Projectile3]: active_projectile = Globals.Magic[Globals.Projectile3] + ProjectileSelect.global_position = Projectile3Position.global_position func _on_Projectile4_pressed(): if Projectile4.is_visible() and active_projectile != Globals.Magic[Globals.Projectile4]: active_projectile = Globals.Magic[Globals.Projectile4] + ProjectileSelect.global_position = Projectile4Position.global_position diff --git a/ui/Inventory.tscn b/ui/Inventory.tscn index 185623b..91a9fd7 100644 --- a/ui/Inventory.tscn +++ b/ui/Inventory.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://ui/Inventory.png" type="Texture" id=1] [ext_resource path="res://script/Inventory.gd" type="Script" id=2] @@ -10,6 +10,7 @@ [ext_resource path="res://art/ecoprojectile.png" type="Texture" id=8] [ext_resource path="res://art/WaveProjectile.png" type="Texture" id=9] [ext_resource path="res://art/MineProjectile.png" type="Texture" id=10] +[ext_resource path="res://ui/box select.png" type="Texture" id=11] [sub_resource type="Animation" id=1] resource_name = "SlideIn" @@ -57,7 +58,6 @@ texture = ExtResource( 1 ) [node name="Conduits" type="Node2D" parent="Inventory"] [node name="Conduit1" type="TextureButton" parent="Inventory/Conduits"] -visible = false light_mask = -2147483647 margin_left = -79.0 margin_top = -30.0 @@ -72,8 +72,10 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Conduits/Conduit1"] +position = Vector2( 7, 9 ) + [node name="Conduit2" type="TextureButton" parent="Inventory/Conduits"] -visible = false light_mask = -2147483647 margin_left = -58.0 margin_top = -30.0 @@ -87,8 +89,10 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Conduits/Conduit2"] +position = Vector2( 9, 9 ) + [node name="Conduit3" type="TextureButton" parent="Inventory/Conduits"] -visible = false light_mask = -2147483647 margin_left = -81.0 margin_top = -8.0 @@ -102,8 +106,10 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Conduits/Conduit3"] +position = Vector2( 9, 10 ) + [node name="Conduit4" type="TextureButton" parent="Inventory/Conduits"] -visible = false light_mask = -2147483647 margin_left = -58.0 margin_top = -8.0 @@ -117,6 +123,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Conduits/Conduit4"] +position = Vector2( 9, 10 ) + [node name="Projectiles" type="Node2D" parent="Inventory"] [node name="Projectile1" type="TextureButton" parent="Inventory/Projectiles"] @@ -132,6 +141,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Projectiles/Projectile1"] +position = Vector2( 9, 7 ) + [node name="Projectile2" type="TextureButton" parent="Inventory/Projectiles"] margin_left = 7.0 margin_top = -30.0 @@ -145,6 +157,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Projectiles/Projectile2"] +position = Vector2( 8, 7 ) + [node name="Projectile3" type="TextureButton" parent="Inventory/Projectiles"] margin_left = -28.0 margin_top = -10.0 @@ -158,6 +173,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Projectiles/Projectile3"] +position = Vector2( 9, 7 ) + [node name="Projectile4" type="TextureButton" parent="Inventory/Projectiles"] margin_left = 7.0 margin_top = -10.0 @@ -171,6 +189,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Position2D" type="Position2D" parent="Inventory/Projectiles/Projectile4"] +position = Vector2( 8, 7 ) + [node name="Effects" type="Node2D" parent="Inventory"] visible = false @@ -182,6 +203,16 @@ margin_bottom = 55.0 __meta__ = { "_edit_use_anchors_": false } + +[node name="ConduitSelect" type="Sprite" parent="Inventory"] +visible = false +position = Vector2( -72, -22 ) +texture = ExtResource( 11 ) + +[node name="ProjectileSelect" type="Sprite" parent="Inventory"] +visible = false +position = Vector2( -20, -24 ) +texture = ExtResource( 11 ) [connection signal="pressed" from="Inventory/Conduits/Conduit1" to="." method="_on_Conduit1_toggled"] [connection signal="pressed" from="Inventory/Conduits/Conduit2" to="." method="_on_Conduit2_toggled"] [connection signal="pressed" from="Inventory/Conduits/Conduit3" to="." method="_on_Conduit3_toggled"] diff --git a/ui/box select.png b/ui/box select.png new file mode 100644 index 0000000000000000000000000000000000000000..67b7269a3484355162b5f812a632d2fd7ff1af3d GIT binary patch literal 402 zcmV;D0d4+?P)Px$Oi4sRR7i>KmN9O^Fc^hDQ_4h+ki}CMw#-$oz|^THAS1_M3@7MCP#K%4P<5!} zq4WSqM5>B}+#$7POjHGM>5?}&zwP(MmSsO7rPO#*N(sMqit4yDk7V zRo(MsWZ%Q;FZLPdKwVYdU%-Dv3~-~ICdo@CqaX_-$q&5`Vqz*H##0)nHh+wp+ENi6 w#6%&b)J4|k_4yNk`^R07)fxHT;?hz78@uPa>z9niMgRZ+07*qoM6N<$f-f|=!~g&Q literal 0 HcmV?d00001 diff --git a/ui/box select.png.import b/ui/box select.png.import new file mode 100644 index 0000000..9a52b00 --- /dev/null +++ b/ui/box select.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/box select.png-2f5302d4bcb777ec0cb9944669f120aa.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/box select.png" +dest_files=[ "res://.import/box select.png-2f5302d4bcb777ec0cb9944669f120aa.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0