Game Won, Game Over and Tower fixes
This commit is contained in:
@ -31,6 +31,8 @@ func _on_timer_timeout() -> void:
|
|||||||
if not get_node("Path2D").get_children():
|
if not get_node("Path2D").get_children():
|
||||||
endwave = false
|
endwave = false
|
||||||
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
|
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
|
||||||
|
if currentwave >= 5:
|
||||||
|
get_node("CanvasLayer/SidePanel").GameWon()
|
||||||
else:
|
else:
|
||||||
spawnMonster()
|
spawnMonster()
|
||||||
|
|
||||||
@ -40,6 +42,8 @@ func spawnMonster():
|
|||||||
if w[0] > 0:
|
if w[0] > 0:
|
||||||
if randf() < w[1]: #chance of generating any kind of enemy
|
if randf() < w[1]: #chance of generating any kind of enemy
|
||||||
w[0] -= 1
|
w[0] -= 1
|
||||||
|
if w[0] <= 0:
|
||||||
|
endwave = true
|
||||||
var chosen = randf()
|
var chosen = randf()
|
||||||
var sum = 0.0
|
var sum = 0.0
|
||||||
for i in range(2,5):
|
for i in range(2,5):
|
||||||
@ -53,7 +57,7 @@ func spawnMonster():
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
currentwave += 1
|
currentwave += 1
|
||||||
endwave = true
|
|
||||||
|
|
||||||
func decrease_life(damage) -> void:
|
func decrease_life(damage) -> void:
|
||||||
get_node("CanvasLayer/SidePanel").Update_Lifes(-damage)
|
get_node("CanvasLayer/SidePanel").Update_Lifes(-damage)
|
||||||
|
@ -1549,7 +1549,7 @@ texture = ExtResource("65_ef8wx")
|
|||||||
curve = SubResource("Curve2D_6abe5")
|
curve = SubResource("Curve2D_6abe5")
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
wait_time = 0.5
|
wait_time = 0.2
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="TrapArea" type="Area2D" parent="."]
|
[node name="TrapArea" type="Area2D" parent="."]
|
||||||
|
@ -20,6 +20,7 @@ var lifteramount = 0
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
follower = true
|
follower = true
|
||||||
get_node("CharacterBody2D/Area2D").body_entered.connect(choose_target)
|
get_node("CharacterBody2D/Area2D").body_entered.connect(choose_target)
|
||||||
|
get_node("CharacterBody2D/Area2D").body_exited.connect(choose_target)
|
||||||
get_node("Timer").timeout.connect(shoot)
|
get_node("Timer").timeout.connect(shoot)
|
||||||
set_process_input(true)
|
set_process_input(true)
|
||||||
set_properties()
|
set_properties()
|
||||||
@ -70,10 +71,12 @@ func set_properties() -> void:
|
|||||||
get_node("Timer").wait_time = 0.5
|
get_node("Timer").wait_time = 0.5
|
||||||
bulletSpeed = 600
|
bulletSpeed = 600
|
||||||
hitpoint = 25
|
hitpoint = 25
|
||||||
|
get_node("CharacterBody2D/Area2D/CollisionShape2D").shape.radius = 150
|
||||||
if self.name.contains("WizardTower"):
|
if self.name.contains("WizardTower"):
|
||||||
get_node("Timer").wait_time = 1.0
|
get_node("Timer").wait_time = 1.0
|
||||||
bulletSpeed = 450
|
bulletSpeed = 450
|
||||||
hitpoint = 15
|
hitpoint = 15
|
||||||
|
get_node("CharacterBody2D/Area2D/CollisionShape2D").shape.radius = 150
|
||||||
if self.name.contains("MortarTower"): #??? not sure if necessary yet
|
if self.name.contains("MortarTower"): #??? not sure if necessary yet
|
||||||
get_node("Timer").wait_time = 2
|
get_node("Timer").wait_time = 2
|
||||||
hitpoint = 80
|
hitpoint = 80
|
||||||
@ -90,6 +93,8 @@ func _input(event):
|
|||||||
func choose_target(body : Node2D) -> void:
|
func choose_target(body : Node2D) -> void:
|
||||||
if not follower:
|
if not follower:
|
||||||
var surroinding_enemies = get_node("CharacterBody2D/Area2D").get_overlapping_bodies()
|
var surroinding_enemies = get_node("CharacterBody2D/Area2D").get_overlapping_bodies()
|
||||||
|
target = null
|
||||||
|
if surroinding_enemies.size() > 0:
|
||||||
target = surroinding_enemies[0]
|
target = surroinding_enemies[0]
|
||||||
if self.name.contains("ArcherTower") or self.name.contains("MortarTower"):
|
if self.name.contains("ArcherTower") or self.name.contains("MortarTower"):
|
||||||
for i in surroinding_enemies:
|
for i in surroinding_enemies:
|
||||||
@ -99,7 +104,6 @@ func choose_target(body : Node2D) -> void:
|
|||||||
for i in surroinding_enemies:
|
for i in surroinding_enemies:
|
||||||
if i.get_parent().get_progress() < target.get_parent().get_progress():
|
if i.get_parent().get_progress() < target.get_parent().get_progress():
|
||||||
target = i
|
target = i
|
||||||
pass
|
|
||||||
|
|
||||||
func shoot() -> void:
|
func shoot() -> void:
|
||||||
if target != null:
|
if target != null:
|
||||||
|
@ -31,8 +31,14 @@ var coins = 0
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_node("pausemenu").hide()
|
get_node("pausemenu").hide()
|
||||||
get_node("pausemenu").z_index = 5
|
get_node("pausemenu").z_index = 5
|
||||||
|
get_node("GameOver").hide()
|
||||||
|
get_node("GameOver").z_index = 5
|
||||||
|
get_node("GameWon").hide()
|
||||||
|
get_node("GameWon").z_index = 5
|
||||||
get_node("Panel").show()
|
get_node("Panel").show()
|
||||||
get_node("Panel").z_index = 5
|
get_node("Panel").z_index = 5
|
||||||
|
get_node("WaveCounter").show()
|
||||||
|
get_node("WaveCounter").z_index = 5
|
||||||
|
|
||||||
stickspawner.connect("button_up", Spawn_Stick)
|
stickspawner.connect("button_up", Spawn_Stick)
|
||||||
stickspawner.tooltip_text = "Cost: 10\nReturn: 5"
|
stickspawner.tooltip_text = "Cost: 10\nReturn: 5"
|
||||||
@ -57,6 +63,8 @@ func _ready() -> void:
|
|||||||
func _process(delta : float)-> void:
|
func _process(delta : float)-> void:
|
||||||
coinlabel.text = "Coins: " + str(coins)
|
coinlabel.text = "Coins: " + str(coins)
|
||||||
livelabel.text = "Lives: " + str(lives)
|
livelabel.text = "Lives: " + str(lives)
|
||||||
|
if lives <= 0:
|
||||||
|
GameOver()
|
||||||
|
|
||||||
func set_Lifes(amount) -> void:
|
func set_Lifes(amount) -> void:
|
||||||
lives = amount
|
lives = amount
|
||||||
@ -139,6 +147,22 @@ func _unhandled_input(event):
|
|||||||
get_parent().get_parent().get_node("Timer").stop()
|
get_parent().get_parent().get_node("Timer").stop()
|
||||||
|
|
||||||
|
|
||||||
|
func GameOver() -> void:
|
||||||
|
get_node("Panel").hide()
|
||||||
|
get_node("GameOver").show()
|
||||||
|
for i in get_node("../../Path2D").get_children():
|
||||||
|
i.get_children()[0].set_process(false)
|
||||||
|
|
||||||
|
for i in get_parent().get_children():
|
||||||
|
if i.name != "sidepanel":
|
||||||
|
i.set_process(false)
|
||||||
|
var timer_node = i.get_node("Timer") if i.has_node("Timer") else null
|
||||||
|
if timer_node:
|
||||||
|
timer_node.stop()
|
||||||
|
|
||||||
|
func GameWon() -> void:
|
||||||
|
get_node("Panel").hide()
|
||||||
|
get_node("GameWon").show()
|
||||||
|
|
||||||
func _on_button_3_pressed() -> void:
|
func _on_button_3_pressed() -> void:
|
||||||
get_node("pausemenu").hide()
|
get_node("pausemenu").hide()
|
||||||
|
@ -350,7 +350,118 @@ alignment = 1
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Current wave: 1"
|
text = "Current wave: 1"
|
||||||
|
|
||||||
|
[node name="GameOver" type="PanelContainer" parent="."]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
offset_left = 409.0
|
||||||
|
offset_top = 188.5
|
||||||
|
offset_right = 742.0
|
||||||
|
offset_bottom = 459.5
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_s7jra")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GameOver"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 30
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="GameOver/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0, 0, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("2_4l4p2")
|
||||||
|
theme_override_font_sizes/font_size = 64
|
||||||
|
text = "Game Over"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="Button2" type="Button" parent="GameOver/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxEmpty_4l4p2")
|
||||||
|
theme_override_styles/hover = SubResource("StyleBoxFlat_f5es8")
|
||||||
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_dgw1d")
|
||||||
|
theme_override_styles/normal = SubResource("StyleBoxFlat_nctfw")
|
||||||
|
text = "Restart"
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="GameOver/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxEmpty_4l4p2")
|
||||||
|
theme_override_styles/hover = SubResource("StyleBoxFlat_f5es8")
|
||||||
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_dgw1d")
|
||||||
|
theme_override_styles/normal = SubResource("StyleBoxFlat_nctfw")
|
||||||
|
text = "Exit"
|
||||||
|
|
||||||
|
[node name="GameWon" type="PanelContainer" parent="."]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
offset_left = 438.0
|
||||||
|
offset_top = 224.5
|
||||||
|
offset_right = 712.0
|
||||||
|
offset_bottom = 423.5
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_s7jra")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GameWon"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 30
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="GameWon/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 1, 0, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("2_4l4p2")
|
||||||
|
theme_override_font_sizes/font_size = 64
|
||||||
|
text = "Congratulations!"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="Label3" type="Label" parent="GameWon/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("2_4l4p2")
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
text = "You've protected the citadell!"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="Button2" type="Button" parent="GameWon/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxEmpty_4l4p2")
|
||||||
|
theme_override_styles/hover = SubResource("StyleBoxFlat_f5es8")
|
||||||
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_dgw1d")
|
||||||
|
theme_override_styles/normal = SubResource("StyleBoxFlat_nctfw")
|
||||||
|
text = "Restart"
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="GameWon/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxEmpty_4l4p2")
|
||||||
|
theme_override_styles/hover = SubResource("StyleBoxFlat_f5es8")
|
||||||
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_dgw1d")
|
||||||
|
theme_override_styles/normal = SubResource("StyleBoxFlat_nctfw")
|
||||||
|
text = "Continue"
|
||||||
|
|
||||||
[connection signal="pressed" from="Panel/HBoxContainer4/HBoxContainer4/Button3" to="." method="_on_button_3_pressed"]
|
[connection signal="pressed" from="Panel/HBoxContainer4/HBoxContainer4/Button3" to="." method="_on_button_3_pressed"]
|
||||||
[connection signal="pressed" from="pausemenu/VBoxContainer/Button3" to="." method="_on_button_3_pressed"]
|
[connection signal="pressed" from="pausemenu/VBoxContainer/Button3" to="." method="_on_button_3_pressed"]
|
||||||
[connection signal="pressed" from="pausemenu/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]
|
[connection signal="pressed" from="pausemenu/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]
|
||||||
[connection signal="pressed" from="pausemenu/VBoxContainer/Button" to="." method="_on_button_pressed"]
|
[connection signal="pressed" from="pausemenu/VBoxContainer/Button" to="." method="_on_button_pressed"]
|
||||||
|
[connection signal="pressed" from="GameOver/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]
|
||||||
|
[connection signal="pressed" from="GameOver/VBoxContainer/Button" to="." method="_on_button_pressed"]
|
||||||
|
[connection signal="pressed" from="GameWon/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]
|
||||||
|
[connection signal="pressed" from="GameWon/VBoxContainer/Button" to="." method="_on_button_pressed"]
|
||||||
|
Reference in New Issue
Block a user