Support for units with multiple health
This commit is contained in:
parent
5ccbc5ca9e
commit
b87a26cc33
7
TODO.md
7
TODO.md
|
@ -1,16 +1,17 @@
|
|||
1. Power ups
|
||||
* a chance of having power ups spawn on an random unoccupied square when a unit dies
|
||||
* +health, +attack, +speed, +jump, (pawn only) remove "attack_only", spawn a new (random?) piece, change movement type
|
||||
* then the enemy respawns units, their new units are stronger
|
||||
* support for pieces with multiple hit points
|
||||
2. Visual polish
|
||||
* multiple square tiles to add variation
|
||||
* make the help text indicate (flash, etc.)
|
||||
* visual indications when damage is done but a unit isn't killed
|
||||
* visual indication when a unit is stronger (eg. a little skull or star or something)
|
||||
3. Sound effects
|
||||
* on hit
|
||||
* on hit, especially when the unit isn't killed
|
||||
* if possible, a small bit of background music
|
||||
4. New units
|
||||
5. Further visual polish
|
||||
* animate the piece making the attack, and returning to it's spot
|
||||
|
||||
Bugs of note:
|
||||
|
||||
|
|
81
src/Game.gd
81
src/Game.gd
|
@ -35,6 +35,7 @@ var ai_piece = null
|
|||
var reinforcements = null
|
||||
var reinforcements_size = 0
|
||||
var reinforcements_coords = []
|
||||
var reinforcement_buff = null
|
||||
|
||||
const on_ai_lose_piece = {
|
||||
50: "/root/Game/Huh",
|
||||
|
@ -259,8 +260,14 @@ func _ready():
|
|||
get_node("/root/Game/EndMenu/VBoxContainer/Quit").connect("pressed", self, "_on_quit_game_pressed")
|
||||
get_node("/root/Game/EndMenu/VBoxContainer/Fail Game").connect("pressed", self, "_on_fail_game")
|
||||
get_node("/root/Game/EndMenu/VBoxContainer/Win Game").connect("pressed", self, "_on_win_game")
|
||||
get_node("/root/Game/PanelRight/VBox/PieceInfo").connect("stat_change_requested", self, "_on_piece_stat_change_requested")
|
||||
reset_game_state()
|
||||
|
||||
func _on_piece_stat_change_requested(piece, attribute, value):
|
||||
if piece.get(attribute) != null:
|
||||
piece.set(attribute, value)
|
||||
get_node("/root/Game/PanelRight/VBox/PieceInfo").set_piece_info(piece)
|
||||
|
||||
func _input(ev):
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
print(ev)
|
||||
|
@ -409,6 +416,13 @@ func _on_new_turn():
|
|||
var square = self.board_squares[coord]
|
||||
if square['piece'] == null:
|
||||
new_piece(square['reinforcement'], "opponent", coord)
|
||||
square = self.board_squares[coord]
|
||||
if self.reinforcement_buff != null:
|
||||
square['piece'].speed += self.reinforcement_buff
|
||||
square['piece'].damage += self.reinforcement_buff
|
||||
square['piece'].health += self.reinforcement_buff
|
||||
if self.reinforcement_buff >= 5:
|
||||
square['piece'].health = true
|
||||
else:
|
||||
print("Reinforcement arrival at ", coord, " blocked by piece!")
|
||||
get_node("BottomBar/Help").set_text("Reinforcement at " + str(coord) + " telefragged.")
|
||||
|
@ -429,6 +443,10 @@ func _on_new_turn():
|
|||
get_node("BottomBar/Help").set_text("Multiple opponent reinforcements detected inbound")
|
||||
get_node("/root/Game/ThinkYouCan").play()
|
||||
self.flash_help = 3
|
||||
if self.reinforcement_buff != null:
|
||||
self.reinforcement_buff += 1
|
||||
if self.reinforcement_buff == null:
|
||||
self.reinforcement_buff = 0
|
||||
if self.reinforcements == null and not just_spawned:
|
||||
var chance = lerp(0, 50, 1 - float(opponent_pieces.size())/16.0)
|
||||
var i = self.rng.randi() % 100
|
||||
|
@ -495,19 +513,26 @@ func _process(delta):
|
|||
# End movement
|
||||
var square = square_of_piece(self.ai_piece)
|
||||
if target_square['piece'] != null:
|
||||
# @TODO If the target doesn't die, we need to bounce back
|
||||
target_square['piece'].queue_free()
|
||||
square['piece'].kills += 1
|
||||
get_node("PanelRight/VBox/PieceInfo").set_piece_info(square['piece'])
|
||||
var c = self.rng.randi() % 100
|
||||
var index_to_play = null
|
||||
for idx in self.on_player_lose_piece.keys():
|
||||
if c < idx:
|
||||
break
|
||||
index_to_play = idx
|
||||
if index_to_play != null:
|
||||
print("ai loss Chance to play: ", c, " got index ", index_to_play)
|
||||
get_node(self.on_player_lose_piece[index_to_play]).play()
|
||||
if square['piece'].damage >= target_square['piece'].health:
|
||||
target_square['piece'].queue_free()
|
||||
square['piece'].kills += 1
|
||||
get_node("PanelRight/VBox/PieceInfo").set_piece_info(square['piece'])
|
||||
var c = self.rng.randi() % 100
|
||||
var index_to_play = null
|
||||
for idx in self.on_player_lose_piece.keys():
|
||||
if c < idx:
|
||||
break
|
||||
index_to_play = idx
|
||||
if index_to_play != null:
|
||||
print("ai loss Chance to play: ", c, " got index ", index_to_play)
|
||||
get_node(self.on_player_lose_piece[index_to_play]).play()
|
||||
else:
|
||||
# Deal damage
|
||||
target_square['piece'].health -= square['piece'].damage
|
||||
# @TODO Sound effect
|
||||
# @TODO Visual indication of damage dealt
|
||||
# Bounce piece back
|
||||
target_square = square
|
||||
square['piece'] = null
|
||||
target_square['piece'] = self.ai_piece
|
||||
self.ai_piece.set_position(Vector2(target_square['x']*128, target_square['y']*128))
|
||||
|
@ -579,18 +604,24 @@ func _physics_process(delta):
|
|||
var dest_square = self.board_squares[dest]
|
||||
if dest_square['piece'] != null:
|
||||
# @TODO If the target doesn't die, we need to bounce back
|
||||
dest_square['piece'].queue_free()
|
||||
square['piece'].kills += 1
|
||||
get_node("PanelRight/VBox/PieceInfo").set_piece_info(square['piece'])
|
||||
var c = self.rng.randi() % 100
|
||||
var index_to_play = null
|
||||
for idx in self.on_ai_lose_piece.keys():
|
||||
if c < idx:
|
||||
break
|
||||
index_to_play = idx;
|
||||
if index_to_play != null:
|
||||
print("ai loss Chance to play: ", c, " got index ", index_to_play)
|
||||
get_node(self.on_ai_lose_piece[index_to_play]).play()
|
||||
if square['piece'].damage >= dest_square['piece'].health:
|
||||
dest_square['piece'].queue_free()
|
||||
square['piece'].kills += 1
|
||||
get_node("PanelRight/VBox/PieceInfo").set_piece_info(square['piece'])
|
||||
var c = self.rng.randi() % 100
|
||||
var index_to_play = null
|
||||
for idx in self.on_ai_lose_piece.keys():
|
||||
if c < idx:
|
||||
break
|
||||
index_to_play = idx;
|
||||
if index_to_play != null:
|
||||
print("ai loss Chance to play: ", c, " got index ", index_to_play)
|
||||
get_node(self.on_ai_lose_piece[index_to_play]).play()
|
||||
else:
|
||||
# @TODO Play a sound effect
|
||||
# @TODO Visual indication of damage dealt
|
||||
dest_square['piece'].health -= square['piece'].damage
|
||||
dest_square = square
|
||||
square['piece'] = null
|
||||
dest_square['piece'] = piece
|
||||
piece.set_position(Vector2(dest_square['x']*128, dest_square['y']*128))
|
||||
|
|
|
@ -5,16 +5,41 @@ extends Control
|
|||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
signal stat_change_requested
|
||||
|
||||
var last_piece = null
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func set_piece_info(piece):
|
||||
self.last_piece = piece
|
||||
get_node("Vbox/Damage/Label").set_text(str(piece.damage))
|
||||
get_node("Vbox/Movement/Label").set_text(str(piece.speed))
|
||||
get_node("Vbox/Health/Label").set_text(str(piece.health))
|
||||
get_node("Vbox/Kills/Label").set_text(str(piece.kills))
|
||||
if piece.jump:
|
||||
get_node("Vbox/Jump").set_text("Can jump")
|
||||
get_node("Vbox/CheckButton").set_pressed(true)
|
||||
else:
|
||||
get_node("Vbox/Jump").set_text("Cannot jump")
|
||||
get_node("Vbox/CheckButton").set_pressed(false)
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
func _on_UpMovement_pressed():
|
||||
emit_signal("stat_change_requested", self.last_piece, "speed", self.last_piece.speed + 1)
|
||||
|
||||
|
||||
func _on_UpHealth_pressed():
|
||||
emit_signal("stat_change_requested", self.last_piece, "health", self.last_piece.health + 1)
|
||||
|
||||
|
||||
func _on_UpDamage_pressed():
|
||||
emit_signal("stat_change_requested", self.last_piece, "damage", self.last_piece.damage + 1)
|
||||
|
||||
|
||||
func _on_CheckButton_toggled(button_pressed):
|
||||
emit_signal("stat_change_requested", self.last_piece, "jump", button_pressed)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://src/font_32.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://assets/export/health.png" type="Texture" id=2]
|
||||
|
@ -7,6 +7,11 @@
|
|||
[ext_resource path="res://assets/export/attack.png" type="Texture" id=5]
|
||||
[ext_resource path="res://assets/export/kills.png" type="Texture" id=6]
|
||||
[ext_resource path="res://src/PieceDetails.gd" type="Script" id=7]
|
||||
[ext_resource path="res://assets/source/Bitstream Vera Sans Mono Bold Nerd Font Complete.ttf" type="DynamicFontData" id=8]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 20
|
||||
font_data = ExtResource( 8 )
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
|
@ -19,6 +24,9 @@ __meta__ = {
|
|||
[node name="Vbox" type="VBoxContainer" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="Vbox"]
|
||||
margin_right = 190.0
|
||||
|
@ -50,10 +58,16 @@ __meta__ = {
|
|||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="Health" type="HBoxContainer" parent="Vbox"]
|
||||
[node name="UpMovement" type="Button" parent="Vbox"]
|
||||
margin_top = 151.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 215.0
|
||||
margin_bottom = 171.0
|
||||
text = "Increase Movement"
|
||||
|
||||
[node name="Health" type="HBoxContainer" parent="Vbox"]
|
||||
margin_top = 175.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 239.0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Vbox/Health"]
|
||||
material = ExtResource( 3 )
|
||||
|
@ -69,10 +83,16 @@ margin_bottom = 51.0
|
|||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "1 "
|
||||
|
||||
[node name="Damage" type="HBoxContainer" parent="Vbox"]
|
||||
margin_top = 219.0
|
||||
[node name="UpHealth" type="Button" parent="Vbox"]
|
||||
margin_top = 243.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 283.0
|
||||
margin_bottom = 263.0
|
||||
text = "Increase health"
|
||||
|
||||
[node name="Damage" type="HBoxContainer" parent="Vbox"]
|
||||
margin_top = 267.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 331.0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Vbox/Damage"]
|
||||
material = ExtResource( 3 )
|
||||
|
@ -88,10 +108,16 @@ margin_bottom = 51.0
|
|||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "1"
|
||||
|
||||
[node name="Kills" type="HBoxContainer" parent="Vbox"]
|
||||
margin_top = 287.0
|
||||
[node name="UpDamage" type="Button" parent="Vbox"]
|
||||
margin_top = 335.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 351.0
|
||||
margin_bottom = 355.0
|
||||
text = "Increase damage"
|
||||
|
||||
[node name="Kills" type="HBoxContainer" parent="Vbox"]
|
||||
margin_top = 359.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 423.0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Vbox/Kills"]
|
||||
material = ExtResource( 3 )
|
||||
|
@ -106,3 +132,20 @@ margin_right = 87.0
|
|||
margin_bottom = 51.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "1"
|
||||
|
||||
[node name="Jump" type="Label" parent="Vbox"]
|
||||
margin_top = 427.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 451.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Cannot jump"
|
||||
|
||||
[node name="CheckButton" type="CheckButton" parent="Vbox"]
|
||||
margin_top = 455.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 495.0
|
||||
text = "Jump"
|
||||
[connection signal="pressed" from="Vbox/UpMovement" to="." method="_on_UpMovement_pressed"]
|
||||
[connection signal="pressed" from="Vbox/UpHealth" to="." method="_on_UpHealth_pressed"]
|
||||
[connection signal="pressed" from="Vbox/UpDamage" to="." method="_on_UpDamage_pressed"]
|
||||
[connection signal="toggled" from="Vbox/CheckButton" to="." method="_on_CheckButton_toggled"]
|
||||
|
|
Loading…
Reference in New Issue