From 58f6f314467a1eb0bec97992123c3ff20837add8 Mon Sep 17 00:00:00 2001 From: Yadciel Date: Thu, 24 Nov 2022 22:34:56 +0100 Subject: [PATCH] fix --- Entity.tscn | 10 ++++++++-- Game.gd | 12 ++++++++++++ Game.tscn | 10 ++++++---- Overlay.tscn | 22 ++++++++++------------ Spawner.gd | 6 +++++- project.godot | 1 + 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Entity.tscn b/Entity.tscn index 66ee514..6e8a8c3 100644 --- a/Entity.tscn +++ b/Entity.tscn @@ -8,14 +8,17 @@ script/source = "extends KinematicBody2D var velocity = Vector2(0,1) var speed = 50 +var life = 2 + signal on_Death # Called when the node enters the scene tree for the first time. func _ready(): - var text = randi() % 4 + var text = randi() % life as int $Label.text = (text+1) as String var Progressbars = get_tree().get_nodes_in_group(\"XP\") for Progressbar in Progressbars: + self.connect(\"on_Death\",Progressbar, \"on_Death_listed\") Progressbar.connect(\"full_bar\", self, \"set_speed\") pass # Replace with function body. @@ -37,7 +40,10 @@ func _on_Area2D_area_entered(area): pass # Replace with function body. func set_speed(value): - speed += value + var Spawner = get_tree().get_nodes_in_group(\"Spawner\") + for Spawn in Spawner: + Spawn.e_speed += value + Spawn.e_life *= 1.2 " [sub_resource type="RectangleShape2D" id=2] diff --git a/Game.gd b/Game.gd index 5175828..2366928 100644 --- a/Game.gd +++ b/Game.gd @@ -5,12 +5,16 @@ const SlotClass = preload("res://Slot.gd") var Panzer_Temp = preload("res://Panzer.tscn") onready var game_slots = $VBoxContainer/PanzerSlots var holding_item = null +var buy_panzer_left = 0 signal speed_shoot func _ready(): for gam_slot in game_slots.get_children(): gam_slot.connect("gui_input", self, "slot_gui_input", [gam_slot]) + var pBars = get_tree().get_nodes_in_group("XP") + for pBar in pBars: + pBar.connect("full_bar", self, "_enable_Panzer") func slot_gui_input(event: InputEvent, slot: SlotClass): @@ -38,6 +42,9 @@ func _input(event): func _on_Panzer_pressed(): + buy_panzer_left -= 1 + if buy_panzer_left == 0: + $VBoxContainer/ButtonGrid/Panzer.disabled = true if holding_item == null: var Panzer = null Panzer = Panzer_Temp.instance() @@ -50,4 +57,9 @@ func _on_Panzer_pressed(): func _on_Speed_pressed(): var value = 0.5 emit_signal("speed_shoot", value) + $VBoxContainer/ButtonGrid/Speed.disabled = true pass # Replace with function body. + +func _enable_Panzer(value): + buy_panzer_left += 1 + $VBoxContainer/ButtonGrid/Panzer.disabled = false diff --git a/Game.tscn b/Game.tscn index 6998937..339ba13 100644 --- a/Game.tscn +++ b/Game.tscn @@ -56,14 +56,14 @@ margin_right = 575.0 custom_constants/hseparation = 21 columns = 4 -[node name="Spawner 1" type="Panel" parent="Spawner"] +[node name="Spawner 1" type="Panel" parent="Spawner" groups=["Spawner"]] margin_right = 128.0 margin_bottom = 128.0 rect_min_size = Vector2( 128, 128 ) custom_styles/panel = SubResource( 3 ) script = ExtResource( 4 ) -[node name="Spawner 2" type="Panel" parent="Spawner"] +[node name="Spawner 2" type="Panel" parent="Spawner" groups=["Spawner"]] margin_left = 149.0 margin_right = 277.0 margin_bottom = 128.0 @@ -71,7 +71,7 @@ rect_min_size = Vector2( 128, 128 ) custom_styles/panel = SubResource( 3 ) script = ExtResource( 4 ) -[node name="Spawner 3" type="Panel" parent="Spawner"] +[node name="Spawner 3" type="Panel" parent="Spawner" groups=["Spawner"]] margin_left = 298.0 margin_right = 426.0 margin_bottom = 128.0 @@ -79,7 +79,7 @@ rect_min_size = Vector2( 128, 128 ) custom_styles/panel = SubResource( 3 ) script = ExtResource( 4 ) -[node name="Spawner 4" type="Panel" parent="Spawner"] +[node name="Spawner 4" type="Panel" parent="Spawner" groups=["Spawner"]] margin_left = 447.0 margin_right = 575.0 margin_bottom = 128.0 @@ -184,6 +184,7 @@ margin_right = 128.0 margin_bottom = 128.0 rect_min_size = Vector2( 128, 128 ) custom_fonts/font = SubResource( 5 ) +disabled = true text = "Speed" [node name="Panzer" type="Button" parent="VBoxContainer/ButtonGrid"] @@ -192,6 +193,7 @@ margin_right = 260.0 margin_bottom = 128.0 rect_min_size = Vector2( 128, 128 ) custom_fonts/font = SubResource( 5 ) +disabled = true text = "Panzer" [node name="Control" parent="." instance=ExtResource( 7 )] diff --git a/Overlay.tscn b/Overlay.tscn index 33c8460..8ffac09 100644 --- a/Overlay.tscn +++ b/Overlay.tscn @@ -1,13 +1,10 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=1] [sub_resource type="GDScript" id=1] script/source = "extends Control - -# Declare member variables here. Examples: -# var a = 2 -# var b = \"text\" - onready var pBar = $CanvasLayer/ProgressBar signal full_bar @@ -15,25 +12,25 @@ signal full_bar # Called when the node enters the scene tree for the first time. func _ready(): - var Enemies = get_tree().get_nodes_in_group(\"Enemy\") - for Enemy in Enemies: - Enemy.connect(\"on_Death\", self, \"on_Death_listed\") pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if pBar.value == pBar.max_value: - var value = 50 + var value = 5 emit_signal(\"full_bar\", value) pBar.value = 0 - pBar.max_value += 10 + pBar.max_value *= 1.2 pass func on_Death_listed(value): pBar.value += value " +[sub_resource type="DynamicFont" id=2] +font_data = ExtResource( 1 ) + [node name="Control" type="Control" groups=["XP"]] anchor_right = 1.0 anchor_bottom = 1.0 @@ -52,7 +49,8 @@ margin_top = 48.0 margin_right = 48.0 margin_bottom = 62.0 rect_scale = Vector2( 1.5, 1.5 ) -max_value = 10.0 +custom_fonts/font = SubResource( 2 ) +max_value = 5.0 [node name="Label" type="Label" parent="."] margin_right = 184.0 diff --git a/Spawner.gd b/Spawner.gd index 4ed84f0..5cb744b 100644 --- a/Spawner.gd +++ b/Spawner.gd @@ -2,6 +2,8 @@ extends Panel var enemy_pre = preload("res://Entity.tscn") var enemy = null +var e_speed = 50 +var e_life = 2 var Time = 0 # Called when the node enters the scene tree for the first time. @@ -13,8 +15,10 @@ func _ready(): func _process(delta): Time += delta - if Time > 5: + if Time > 3.5: if randi() % 2 == 0: enemy = enemy_pre.instance() + enemy.speed = e_speed + enemy.life = e_life add_child(enemy) Time = 0 diff --git a/project.godot b/project.godot index d34ff27..6b010da 100644 --- a/project.godot +++ b/project.godot @@ -83,6 +83,7 @@ window/size/width=576 window/size/height=1200 window/handheld/orientation="portrait" window/stretch/mode="2d" +window/stretch/aspect="keep_width" [editor_plugins]