Added UI selection boxes

This commit is contained in:
Logan 2020-07-20 14:59:31 -05:00
parent 603b6291d0
commit 6e2bc0c01d
7 changed files with 103 additions and 8 deletions

View file

@ -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()

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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"]

BIN
ui/box select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

34
ui/box select.png.import Normal file
View file

@ -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