Compare commits

..

4 Commits

Author SHA1 Message Date
Joey Pollack 566c563446 Battle Menu UI tweeked 2 years ago
Joey Pollack c333930b4e Refactoring action system 2 years ago
Joey Pollack 7e599a5f97 Adds action queuing and ATB charging 2 years ago
Joey Pollack d421821fbe Battle menu actions added
ATB Progress bar added
2 years ago

@ -7,6 +7,8 @@ class_name Action
var ActionIndex = 0
signal action_finished
func _ready():
if ActionName == "NONE":
push_warning("Actions has NONE name")

@ -0,0 +1,19 @@
extends Action
class_name Attack
func _ready():
ActionName = "Attack"
var timer
func execute():
timer = Timer.new()
timer.timeout.connect(done)
timer.wait_time = 1
add_child(timer)
timer.start()
print("Executing Attack!")
func done():
timer.queue_free()
action_finished.emit()

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bbbyup8pp6uam"]
[ext_resource type="Script" path="res://Test Scenes/Test Player Actions/Scripts/attack.gd" id="1_nmi0m"]
[ext_resource type="Script" path="res://Systems/Combat/Actions/Standard Actions/attack.gd" id="1_nmi0m"]
[node name="attack" type="Node"]
script = ExtResource("1_nmi0m")

@ -4,26 +4,29 @@ class_name Combatant
# @export var Behavior:
@export var Stats: CombatStats
@export var Actions: Array[Action] = []
@export var ATBSpeedCoeffecient = 25
var is_init = false
var ATBCurrent = 0
func _ready():
pass
# var idx = 0
# for node in get_children():
# if node.name == "Actions":
# for action in node.get_children():
# action.ActionIndex = idx
# Menu.add_action(action)
# Actions.append(action)
# idx += 1
# for action in Actions:
# Menu.add_action(action)
func next_turn():
ATBCurrent = 0
# TODO: Tick status effects
func tick_atb(delta):
if ATBCurrent >= 100:
ATBCurrent = 100
return
ATBCurrent += Stats.Speed * delta * ATBSpeedCoeffecient
func execute_action(index: int):
Actions[index].execute()
#func _process(delta):
# if not is_init:

@ -1,25 +1,26 @@
extends Control
class_name BattleMenu
var items: Array[MenuItem] = []
var top_margin = 100
var item_padding = 10
var next_y_pos = 0
func _ready():
next_y_pos = top_margin
enum ACTION { ATTACK, DEFEND, ITEM }
func add_action(action: Action):
var item = preload("res://Systems/UI/Menu System/menu_item.tscn").instantiate()
items.push_back(item)
item.label = action.ActionName
item.action = action
var button = item.get_node("Button")
button.position.y = next_y_pos
next_y_pos += button.size.y + item_padding
var panel = $Panel
# var button = item.get_node("Button")
panel.add_child(item)
signal action_selected(action)
func _on_attack_pressed():
action_selected.emit("attack")
func _on_defend_pressed():
action_selected.emit("defend")
func _on_item_pressed():
pass # GO TO SUBMENU HERE
func _on_tech_pressed():
pass # GO TO SUBMENU HERE

@ -20,8 +20,8 @@ anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -86.0
offset_right = 108.0
offset_bottom = 184.0
offset_right = 70.0
offset_bottom = 145.0
grow_horizontal = 2
grow_vertical = 2
@ -37,3 +37,81 @@ offset_bottom = 45.0
grow_horizontal = 2
text = "Battle Menu"
horizontal_alignment = 1
[node name="Panel" type="Panel" parent="Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -72.0
offset_top = 45.0
offset_right = 75.0
offset_bottom = 228.0
grow_horizontal = 2
[node name="Attack" type="Button" parent="Panel/Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -35.0
offset_top = 6.0
offset_right = 35.0
offset_bottom = 37.0
grow_horizontal = 2
text = "Attack
"
[node name="Tech" type="Button" parent="Panel/Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -35.0
offset_top = 41.0
offset_right = 35.0
offset_bottom = 72.0
grow_horizontal = 2
text = "Tech"
[node name="Defend" type="Button" parent="Panel/Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -35.0
offset_top = 76.0
offset_right = 35.0
offset_bottom = 107.0
grow_horizontal = 2
text = "Defend"
[node name="Item" type="Button" parent="Panel/Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -35.5
offset_top = 111.0
offset_right = 34.5
offset_bottom = 142.0
grow_horizontal = 2
text = "Item"
[node name="Rest" type="Button" parent="Panel/Panel"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -35.5
offset_top = 146.0
offset_right = 34.5
offset_bottom = 177.0
grow_horizontal = 2
text = "Rest"
[connection signal="pressed" from="Panel/Panel/Attack" to="." method="_on_attack_pressed"]
[connection signal="pressed" from="Panel/Panel/Tech" to="." method="_on_tech_pressed"]
[connection signal="pressed" from="Panel/Panel/Defend" to="." method="_on_defend_pressed"]
[connection signal="pressed" from="Panel/Panel/Item" to="." method="_on_item_pressed"]
[connection signal="pressed" from="Panel/Panel/Rest" to="." method="_on_item_pressed"]

@ -1,7 +1,40 @@
extends Sprite2D
@export var SpecialActions: Array[Action] = []
@onready var ATB = $battle_menu/ATB
@onready var ActionState = $battle_menu/ActionPanel/ActionState
@onready var Actions = $Combatant/Actions
var NextAction
var ActionReady = false
func _ready():
var menu = $battle_menu
menu.add_action($Combatant/Actions/attack)
menu.add_action($Combatant/Actions/spin_attack)
func _process(delta):
var combatant = $Combatant
if ActionReady and ATB.value == 100:
NextAction.execute()
ActionState.text = "Action Executing: %s" % NextAction.ActionName
combatant.ATBCurrent = 0
ATB.value = 0
ActionReady = false
return
combatant.tick_atb(delta)
ATB.value = combatant.ATBCurrent
func do_action(a):
var action = Actions.get_node(a)
if !action:
push_error("Unknown battle action: %s" % a)
return
ActionState.text = "Action Queued: %s" % action.ActionName
NextAction = action
ActionReady = true
func action_done():
ActionState.text = ""

@ -1,6 +0,0 @@
extends Action
func execute():
print("Test Player Attacking!")

@ -1,4 +1,14 @@
extends Action
var timer
func execute():
print("Test Player uses Spin Attack!")
timer = Timer.new()
timer.timeout.connect(done)
timer.wait_time = 1
add_child(timer)
timer.start()
print("Executing Spin Attack!")
func done():
timer.queue_free()
action_finished.emit()

@ -0,0 +1,87 @@
[gd_scene load_steps=10 format=3 uid="uid://b2iq5inxeoe82"]
[ext_resource type="Texture2D" uid="uid://dedauf4ntkthu" path="res://icon.svg" id="1_d15px"]
[ext_resource type="Script" path="res://Test Scenes/Player.gd" id="2_8b3bs"]
[ext_resource type="PackedScene" uid="uid://cl5d768roh8ir" path="res://Systems/UI/Menu System/battle_menu.tscn" id="3_ubnwv"]
[ext_resource type="Texture2D" uid="uid://dqf1p1mfki3vc" path="res://assets/art/ui/bar_under.png" id="4_afpwe"]
[ext_resource type="PackedScene" uid="uid://ch1sc85jxy1r7" path="res://Systems/Combat/Combatant.tscn" id="4_w3vb5"]
[ext_resource type="Texture2D" uid="uid://bnp5t7o26kb0c" path="res://assets/art/ui/bar_over.png" id="5_5mhew"]
[ext_resource type="PackedScene" uid="uid://bbbyup8pp6uam" path="res://Systems/Combat/Actions/Standard Actions/attack.tscn" id="5_17k7n"]
[ext_resource type="Script" path="res://Systems/Combat/Scripts/combat_stats.gd" id="7_ynhjd"]
[sub_resource type="Resource" id="Resource_28c5l"]
script = ExtResource("7_ynhjd")
MaxHP = 10
MaxPhysicalStamina = 10
MaxMentalStamina = 10
Strength = 1
Wisdom = 1
Constitution = 1
Willpower = 1
Speed = 1
Focus = 1
Accuracy = 1
Agility = 1
[node name="Player" type="Sprite2D"]
position = Vector2(553, 219)
texture = ExtResource("1_d15px")
script = ExtResource("2_8b3bs")
[node name="battle_menu" parent="." instance=ExtResource("3_ubnwv")]
offset_left = -49.0
offset_top = 126.0
offset_right = -49.0
offset_bottom = 103.0
[node name="ATB" type="TextureProgressBar" parent="battle_menu"]
layout_mode = 0
offset_left = -36.0
offset_top = -57.575
offset_right = 234.0
offset_bottom = -7.575
scale = Vector2(0.63, 0.403)
value = 50.0
texture_under = ExtResource("4_afpwe")
texture_progress = ExtResource("5_5mhew")
texture_progress_offset = Vector2(16, 8)
[node name="ActionPanel" type="Panel" parent="battle_menu"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -36.0
offset_top = 93.0
offset_right = 6.0
offset_bottom = 119.0
grow_horizontal = 2
grow_vertical = 0
[node name="ActionState" type="Label" parent="battle_menu/ActionPanel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -85.0
offset_top = -13.0
offset_right = 85.0
offset_bottom = 13.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 10
horizontal_alignment = 1
vertical_alignment = 1
[node name="Combatant" parent="." instance=ExtResource("4_w3vb5")]
Stats = SubResource("Resource_28c5l")
[node name="Actions" type="Node" parent="Combatant"]
[node name="attack" parent="Combatant/Actions" instance=ExtResource("5_17k7n")]
[connection signal="action_selected" from="battle_menu" to="." method="do_action"]
[connection signal="action_finished" from="Combatant/Actions/attack" to="." method="action_done"]

File diff suppressed because one or more lines are too long

BIN
assets/art/ui/bar_over.png (Stored with Git LFS)

Binary file not shown.

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bnp5t7o26kb0c"
path="res://.godot/imported/bar_over.png-55a6bae0151fad781ffcae0da3dc8d8b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/ui/bar_over.png"
dest_files=["res://.godot/imported/bar_over.png-55a6bae0151fad781ffcae0da3dc8d8b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/art/ui/bar_under.png (Stored with Git LFS)

Binary file not shown.

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dqf1p1mfki3vc"
path="res://.godot/imported/bar_under.png-f50ef5b32422e97a71938bac527202bf.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/ui/bar_under.png"
dest_files=["res://.godot/imported/bar_under.png-f50ef5b32422e97a71938bac527202bf.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/art/ui/bars.png (Stored with Git LFS)

Binary file not shown.

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dusv2g2bfou5l"
path="res://.godot/imported/bars.png-44ddffd67a1ebda120adc0b0e3911832.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/ui/bars.png"
dest_files=["res://.godot/imported/bars.png-44ddffd67a1ebda120adc0b0e3911832.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading…
Cancel
Save