feat: ernergy bar on menu
This commit is contained in:
parent
58f7a7c48e
commit
f1ab7db046
7 changed files with 45 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ extends Node
|
||||||
signal tower_selected(tower : PackedScene)
|
signal tower_selected(tower : PackedScene)
|
||||||
|
|
||||||
|
|
||||||
#Emitter :
|
#Emitter :
|
||||||
#Subscriber :
|
#Subscriber :
|
||||||
signal tower_builded(tower : Tower)
|
signal tower_builded(tower : Tower)
|
||||||
|
|
||||||
|
|
@ -69,3 +69,7 @@ signal open_shop()
|
||||||
#Emitter : PlayerManager.gd
|
#Emitter : PlayerManager.gd
|
||||||
#Subscriber : game_menu.gd
|
#Subscriber : game_menu.gd
|
||||||
signal close_shop()
|
signal close_shop()
|
||||||
|
|
||||||
|
#Emitter : tower.gd
|
||||||
|
#Subscriber : tower button.gd
|
||||||
|
signal energy_has_changed(tower : Tower)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func _process(delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("rest"):
|
if Input.is_action_just_pressed("rest"):
|
||||||
if _state == STATE.PLACING:
|
if _state == STATE.PLACING:
|
||||||
quit_placing()
|
quit_placing()
|
||||||
|
|
||||||
EventBus.close_shop.emit()
|
EventBus.close_shop.emit()
|
||||||
if target_tower:
|
if target_tower:
|
||||||
send_to_rest()
|
send_to_rest()
|
||||||
|
|
@ -80,7 +80,7 @@ func handle_player_controls() -> void:
|
||||||
selected_collider = collider
|
selected_collider = collider
|
||||||
|
|
||||||
visible = true
|
visible = true
|
||||||
$"selection-a".visible = true
|
$"selection-a".visible = true
|
||||||
global_position = collider.global_position
|
global_position = collider.global_position
|
||||||
global_position += Vector3(0.0,0.2,0.0)
|
global_position += Vector3(0.0,0.2,0.0)
|
||||||
|
|
||||||
|
|
@ -88,10 +88,10 @@ func handle_player_controls() -> void:
|
||||||
target_tower = collider
|
target_tower = collider
|
||||||
else:
|
else:
|
||||||
target_tower = null
|
target_tower = null
|
||||||
|
|
||||||
if _state == STATE.PLACING:
|
if _state == STATE.PLACING:
|
||||||
tower_to_place.sprite.modulate = "ff4545c8" #If the tower can't be placed he is red
|
tower_to_place.sprite.modulate = "ff4545c8" #If the tower can't be placed he is red
|
||||||
$"selection-a".visible = false
|
$"selection-a".visible = false
|
||||||
if selected_collider is BuildTile: #if we are placing a tower, hide the selector model
|
if selected_collider is BuildTile: #if we are placing a tower, hide the selector model
|
||||||
tower_to_place.sprite.modulate = "61ff45c8" #If the tower can be placed he is green
|
tower_to_place.sprite.modulate = "61ff45c8" #If the tower can be placed he is green
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ func quit_placing() -> void:
|
||||||
func build_tower() -> void:
|
func build_tower() -> void:
|
||||||
if tower_blueprint == null:
|
if tower_blueprint == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
if !visible:
|
if !visible:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ func build_tower() -> void:
|
||||||
else :
|
else :
|
||||||
#Can build
|
#Can build
|
||||||
quit_placing() #Destroy the tower placeholder
|
quit_placing() #Destroy the tower placeholder
|
||||||
|
|
||||||
EventBus.money_spent.emit(temp_tower.price)
|
EventBus.money_spent.emit(temp_tower.price)
|
||||||
tower_count += 1
|
tower_count += 1
|
||||||
$"../Towers".add_child(temp_tower)
|
$"../Towers".add_child(temp_tower)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ var energy : float = max_energy:
|
||||||
is_exhausted = true
|
is_exhausted = true
|
||||||
else:
|
else:
|
||||||
is_exhausted = false
|
is_exhausted = false
|
||||||
|
EventBus.energy_has_changed.emit(self)
|
||||||
|
|
||||||
var current_targets : Array = []
|
var current_targets : Array = []
|
||||||
var current : CharacterBody3D
|
var current : CharacterBody3D
|
||||||
|
|
@ -74,6 +75,10 @@ func apply_upgrade(upgrade : TowerUpgrade):
|
||||||
else:
|
else:
|
||||||
printerr("Upgrade already bought")
|
printerr("Upgrade already bought")
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
EventBus.energy_has_changed.emit(self)
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
EventBus.tower_upgraded.connect(_on_EventBus_tower_upgraded)
|
EventBus.tower_upgraded.connect(_on_EventBus_tower_upgraded)
|
||||||
energy_bar.set_up(energy, max_energy)
|
energy_bar.set_up(energy, max_energy)
|
||||||
|
|
|
||||||
9
UI/PierreEnergyMenuProgressBar.gd
Normal file
9
UI/PierreEnergyMenuProgressBar.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends ProgressBar
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
#font_outline_color = Color.YELLOW
|
||||||
|
EventBus.energy_has_changed.connect(changeEnergy)
|
||||||
|
|
||||||
|
func changeEnergy(tower : Tower) -> void:
|
||||||
|
if tower is Pierre:
|
||||||
|
value = tower.energy
|
||||||
1
UI/PierreEnergyMenuProgressBar.gd.uid
Normal file
1
UI/PierreEnergyMenuProgressBar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://igvr34eaqta
|
||||||
|
|
@ -23,7 +23,7 @@ func _on_button_pierre_pressed() -> void:
|
||||||
if tower is Pierre:
|
if tower is Pierre:
|
||||||
can_build = false
|
can_build = false
|
||||||
player_manager.selected_tower = tower #If can't build, tower is selected
|
player_manager.selected_tower = tower #If can't build, tower is selected
|
||||||
|
|
||||||
if can_build: #If Pierre is not builded then build it !
|
if can_build: #If Pierre is not builded then build it !
|
||||||
print("can build !")
|
print("can build !")
|
||||||
EventBus.tower_to_build.emit(load("res://Towers/pierre.tscn"))
|
EventBus.tower_to_build.emit(load("res://Towers/pierre.tscn"))
|
||||||
|
|
|
||||||
21
UI/gui.tscn
21
UI/gui.tscn
|
|
@ -1,10 +1,10 @@
|
||||||
[gd_scene load_steps=21 format=3 uid="uid://p6a6rb7sgeqd"]
|
[gd_scene load_steps=23 format=3 uid="uid://p6a6rb7sgeqd"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d2x8oy4os7ysn" path="res://UI/label_money.gd" id="1_cwd3r"]
|
[ext_resource type="Script" uid="uid://d2x8oy4os7ysn" path="res://UI/label_money.gd" id="1_cwd3r"]
|
||||||
[ext_resource type="Script" uid="uid://c350dletl5pde" path="res://UI/label_tower_in_cube.gd" id="2_6ujs1"]
|
[ext_resource type="Script" path="res://UI/label_tower_in_cube.gd" id="2_6ujs1"]
|
||||||
[ext_resource type="Script" uid="uid://bhylcok1l6eke" path="res://UI/gui.gd" id="2_sac4j"]
|
[ext_resource type="Script" uid="uid://bhylcok1l6eke" path="res://UI/gui.gd" id="2_sac4j"]
|
||||||
[ext_resource type="Script" uid="uid://dmcgoepvytnn" path="res://UI/cube_integrity.gd" id="2_sj6ny"]
|
[ext_resource type="Script" uid="uid://dmcgoepvytnn" path="res://UI/cube_integrity.gd" id="2_sj6ny"]
|
||||||
[ext_resource type="Script" uid="uid://kngsgirej7lx" path="res://UI/label_tower_on_terrain.gd" id="3_wg577"]
|
[ext_resource type="Script" path="res://UI/label_tower_on_terrain.gd" id="3_wg577"]
|
||||||
[ext_resource type="Theme" uid="uid://bbp4qcbwkeg7x" path="res://default_theme.tres" id="5_wpcnu"]
|
[ext_resource type="Theme" uid="uid://bbp4qcbwkeg7x" path="res://default_theme.tres" id="5_wpcnu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://csl43eb7qjhe4" path="res://Assets/Icones/dog-house.svg" id="7_fffne"]
|
[ext_resource type="Texture2D" uid="uid://csl43eb7qjhe4" path="res://Assets/Icones/dog-house.svg" id="7_fffne"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dfnf26suc8yb6" path="res://Assets/Icones/sideswipe.svg" id="8_ay13l"]
|
[ext_resource type="Texture2D" uid="uid://dfnf26suc8yb6" path="res://Assets/Icones/sideswipe.svg" id="8_ay13l"]
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://b4m5ejfdrm8s0" path="res://Assets/Icones/power-button.svg" id="9_reygo"]
|
[ext_resource type="Texture2D" uid="uid://b4m5ejfdrm8s0" path="res://Assets/Icones/power-button.svg" id="9_reygo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="10_reygo"]
|
[ext_resource type="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="10_reygo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="11_76b7g"]
|
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="11_76b7g"]
|
||||||
|
[ext_resource type="Script" uid="uid://igvr34eaqta" path="res://UI/PierreEnergyMenuProgressBar.gd" id="12_decjp"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="12_ih1k6"]
|
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="12_ih1k6"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="13_ryolu"]
|
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="13_ryolu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c4ir6y45pchpl" path="res://Assets/Icones/seahorse.svg" id="14_hndjt"]
|
[ext_resource type="Texture2D" uid="uid://c4ir6y45pchpl" path="res://Assets/Icones/seahorse.svg" id="14_hndjt"]
|
||||||
|
|
@ -30,6 +31,9 @@ bg_color = Color(0.727498, 0.222072, 0.249347, 1)
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3lugd"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3lugd"]
|
||||||
bg_color = Color(0.933333, 0.933333, 0.933333, 1)
|
bg_color = Color(0.933333, 0.933333, 0.933333, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_decjp"]
|
||||||
|
bg_color = Color(1, 0.878431, 0, 1)
|
||||||
|
|
||||||
[node name="GUI" type="Control"]
|
[node name="GUI" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -221,6 +225,17 @@ grow_vertical = 2
|
||||||
texture = ExtResource("9_decjp")
|
texture = ExtResource("9_decjp")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 1.0
|
||||||
|
offset_top = 71.0
|
||||||
|
offset_right = 79.0
|
||||||
|
offset_bottom = 78.0
|
||||||
|
mouse_filter = 1
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_decjp")
|
||||||
|
show_percentage = false
|
||||||
|
script = ExtResource("12_decjp")
|
||||||
|
|
||||||
[node name="ButtonAline" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonAline" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
custom_minimum_size = Vector2(80, 80)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue