Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Godot project #1

Merged
merged 14 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Fauna-RPG/#Scenes/TestingScene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ position = Vector2(595, 284)

[node name="CanvasLayer" type="CanvasLayer" parent="."]

[node name="Control" type="Control" parent="CanvasLayer"]
[node name="UIControl" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
mouse_filter = 2

[node name="EndTurnButton" type="Button" parent="CanvasLayer/Control"]
[node name="EndTurnButton" type="Button" parent="CanvasLayer/UIControl"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
Expand All @@ -56,4 +56,4 @@ grow_vertical = 0
text = "end turn"
script = ExtResource("11_6xwul")

[connection signal="pressed" from="CanvasLayer/Control/EndTurnButton" to="CanvasLayer/Control/EndTurnButton" method="_on_pressed"]
[connection signal="pressed" from="CanvasLayer/UIControl/EndTurnButton" to="CanvasLayer/UIControl/EndTurnButton" method="_on_pressed"]
35 changes: 19 additions & 16 deletions Fauna-RPG/Cards/Card.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://caxbd2ppk3ans"]
[gd_scene load_steps=8 format=3 uid="uid://caxbd2ppk3ans"]

[ext_resource type="Script" path="res://Cards/CardWorld.gd" id="1_4el5m"]
[ext_resource type="Texture2D" uid="uid://nheutko3fha3" path="res://Cards/card.png" id="2_k6rq5"]
Expand All @@ -7,24 +7,12 @@
[ext_resource type="Script" path="res://UI/CardUISetter.gd" id="5_hkyxd"]
[ext_resource type="Texture2D" uid="uid://bdc5r0w6lyh34" path="res://Cards/card_image.png" id="6_p357x"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_2wyyb"]
size = Vector2(200, 279)

[sub_resource type="LabelSettings" id="LabelSettings_ooxvf"]
font_color = Color(0, 0, 0, 1)

[node name="Card" type="Node2D"]
script = ExtResource("1_4el5m")

[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_k6rq5")

[node name="Area2D" type="Area2D" parent="."]

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_2wyyb")

[node name="ClickHandler" type="Node2D" parent="."]
script = ExtResource("3_du4nn")

Expand All @@ -51,6 +39,19 @@ title_label = NodePath("VerticalLayout/Title")
description_label = NodePath("VerticalLayout/Description")
key_art = NodePath("VerticalLayout/KeyArt")

[node name="SelectionButton" type="TextureButton" parent="CardUI"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture_normal = ExtResource("2_k6rq5")
texture_pressed = ExtResource("2_k6rq5")
texture_hover = ExtResource("2_k6rq5")
texture_disabled = ExtResource("2_k6rq5")
texture_focused = ExtResource("2_k6rq5")

[node name="VerticalLayout" type="VBoxContainer" parent="CardUI"]
layout_mode = 1
anchors_preset = 15
Expand All @@ -61,6 +62,7 @@ grow_vertical = 2
mouse_filter = 2

[node name="Title" type="Label" parent="CardUI/VerticalLayout"]
custom_minimum_size = Vector2(188, 23)
layout_mode = 2
text = "Card Title"
label_settings = SubResource("LabelSettings_ooxvf")
Expand All @@ -75,13 +77,14 @@ texture = ExtResource("6_p357x")
stretch_mode = 3

[node name="Description" type="Label" parent="CardUI/VerticalLayout"]
custom_minimum_size = Vector2(188, 127)
layout_mode = 2
text = "This is a test description for a card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam"
label_settings = SubResource("LabelSettings_ooxvf")
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2

[connection signal="input_event" from="Area2D" to="ClickHandler" method="_on_area_2d_input_event"]
[connection signal="mouse_entered" from="Area2D" to="ClickHandler" method="_on_area_2d_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="ClickHandler" method="_on_area_2d_mouse_exited"]
[connection signal="gui_input" from="CardUI/SelectionButton" to="ClickHandler" method="_on_gui_input_event"]
[connection signal="mouse_entered" from="CardUI/SelectionButton" to="ClickHandler" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="CardUI/SelectionButton" to="ClickHandler" method="_on_mouse_exited"]
10 changes: 5 additions & 5 deletions Fauna-RPG/Cards/CardBase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ func _damage_entity(victim: Entity, attacker: Entity, damage_amount: float, dama
var party: Array[Entity] = victim.get_party_component().party
assert(party.size() > 0, "Entity has an empty party. Make sure you added party members.")

for party_member in party:
for party_member: Entity in party:
party_member.get_health_component().deal_damage(victim_damage_data)
else:
victim.get_health_component().deal_damage(victim_damage_data)


func _apply_buffs(attacker: Entity, victim: Entity) -> void:
for buff in buffs_to_apply_to_attacker:
for buff: BuffBase in buffs_to_apply_to_attacker:
if affect_all_attackers:
for party_member in attacker.get_party_component().party:
for party_member: Entity in attacker.get_party_component().party:
party_member.get_buff_component().add_buff(buff, attacker)
else:
attacker.get_buff_component().add_buff(buff, attacker)

for buff in buffs_to_apply_to_victim:
for buff: BuffBase in buffs_to_apply_to_victim:
if affect_all_victims:
for party_member in victim.get_party_component().party:
for party_member: Entity in victim.get_party_component().party:
party_member.get_buff_component().add_buff(buff, attacker)
else:
victim.get_buff_component().add_buff(buff, attacker)
7 changes: 4 additions & 3 deletions Fauna-RPG/Cards/CardContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ func _process(_delta: float) -> void:

func deal_cards() -> void:
discard_all_cards()
for card_index in default_hand.size():
for card_index: int in default_hand.size():
# create card and add to list
var card_instance: CardWorld = card_scene.instantiate()
add_child(card_instance)
cards.append(card_instance)
card_instance.init_card(default_hand[card_index])

# bind mouse events
var card_click_handler: ClickHandler = card_instance.get_click_handler()
card_click_handler.on_click.connect(_on_card_clicked.bind(card_instance))
Expand All @@ -43,7 +44,7 @@ func deal_cards() -> void:


func discard_all_cards() -> void:
for card in cards:
for card: CardWorld in cards:
card.queue_free()
cards.clear()

Expand Down Expand Up @@ -104,7 +105,7 @@ func _update_card_positions() -> void:
var per_card_width: float = 0
if cards.size() > 1:
per_card_width = total_hand_width / (cards.size() - 1)
for card_index in cards.size():
for card_index: int in cards.size():
var card: CardWorld = cards[card_index]
var card_x: float = per_card_width * card_index

Expand Down
8 changes: 4 additions & 4 deletions Fauna-RPG/Core/Battler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func _ready() -> void:


func _summon_enemies() -> void:
for enemy_index in enemies_to_summon.size():
for enemy_index: int in enemies_to_summon.size():
cheesefrycook marked this conversation as resolved.
Show resolved Hide resolved
var enemy_instance: Node = enemies_to_summon[enemy_index].instantiate()
add_child(enemy_instance)
_enemy_list.append(enemy_instance)
enemy_instance.get_click_handler().on_click.connect(_on_enemy_clicked.bind(enemy_instance))
enemy_instance.position.x += enemy_spacing * enemy_index

# setup party
for enemy in _enemy_list:
for enemy: Entity in _enemy_list:
enemy.get_party_component().set_party(_enemy_list)


Expand All @@ -60,11 +60,11 @@ func _on_player_start_turn() -> void:
# party with a buff during their attack
func _on_enemy_start_turn() -> void:
# apply buffs
for enemy in _enemy_list:
for enemy: Entity in _enemy_list:
enemy.get_buff_component().apply_turn_start_buffs()

# enemy attack
for enemy in _enemy_list:
for enemy: Entity in _enemy_list:
var success: bool = _on_attack(enemy.get_behavior_component().attack, enemy, PlayerManager.player)
assert(success == true, "Enemy failed to attack.")

Expand Down
2 changes: 1 addition & 1 deletion Fauna-RPG/Entity/Components/BehaviorComponent.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node2D
extends EntityComponent
class_name BehaviorComponent
## Enemy's behavior.
##
Expand Down
2 changes: 1 addition & 1 deletion Fauna-RPG/Entity/Components/BuffComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func remove_buff(new_buff: BuffBase) -> void:


func apply_turn_start_buffs() -> void:
for buff in current_buffs:
for buff: BuffBase in current_buffs:
buff.on_turn_start()

# remove buff if turn duration is deplete
Expand Down
4 changes: 2 additions & 2 deletions Fauna-RPG/Entity/Components/HealthComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func deal_damage(damage_data: DealDamageData) -> void:

# apply buffs
if attacker != null and !damage_data.ignore_attacker_buffs:
for buff in attacker.get_buff_component().current_buffs:
for buff: BuffBase in attacker.get_buff_component().current_buffs:
buff.get_modified_stats(modified_attacker_stats)
Turtyo marked this conversation as resolved.
Show resolved Hide resolved
if !damage_data.ignore_victim_buffs:
for buff in victim.get_buff_component().current_buffs:
for buff: BuffBase in victim.get_buff_component().current_buffs:
buff.get_modified_stats(modified_victim_stats)

var damage_taken_increase: float = 0.0
Expand Down
16 changes: 9 additions & 7 deletions Fauna-RPG/Entity/Enemy/Enemy.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ font_size = 26
[node name="Enemy" type="Node2D"]
script = ExtResource("1_ya6nf")

[node name="StatComponent" type="Node2D" parent="."]
[node name="StatComponent" type="Node" parent="."]
script = ExtResource("2_twygh")

[node name="BuffComponent" type="Node2D" parent="."]
[node name="BuffComponent" type="Node" parent="."]
script = ExtResource("3_7qc0d")

[node name="HealthComponent" type="Node2D" parent="."]
[node name="HealthComponent" type="Node" parent="."]
script = ExtResource("4_t7jp6")

[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(6, 6)
texture = ExtResource("5_dxya8")

[node name="ClickHandler" type="Node2D" parent="."]
[node name="ClickHandler" type="Node" parent="."]
script = ExtResource("6_m32ri")

[node name="Area2D" type="Area2D" parent="."]
Expand All @@ -52,11 +52,13 @@ label_settings = SubResource("LabelSettings_urr12")
script = ExtResource("7_tofxs")
health_component = NodePath("../HealthComponent")

[node name="PartyComponent" type="Node2D" parent="."]
[node name="PartyComponent" type="Node" parent="."]
script = ExtResource("8_yr066")

[node name="BehaviorComponent" type="Node2D" parent="."]
[node name="BehaviorComponent" type="Node" parent="."]
script = ExtResource("9_kvor6")
attack = ExtResource("10_l5325")

[connection signal="input_event" from="Area2D" to="ClickHandler" method="_on_area_2d_input_event"]
[connection signal="input_event" from="Area2D" to="ClickHandler" method="_on_input_event"]
[connection signal="mouse_entered" from="Area2D" to="ClickHandler" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="ClickHandler" method="_on_mouse_exited"]
2 changes: 1 addition & 1 deletion Fauna-RPG/Entity/EntityComponent.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node2D
extends Node
class_name EntityComponent
## Base component that an entity can use.
##
Expand Down
14 changes: 8 additions & 6 deletions Fauna-RPG/Entity/Player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ font_size = 26
[node name="Player" type="Node2D"]
script = ExtResource("1_4qbo7")

[node name="StatComponent" type="Node2D" parent="."]
[node name="StatComponent" type="Node" parent="."]
script = ExtResource("2_cf8lx")

[node name="BuffComponent" type="Node2D" parent="."]
[node name="BuffComponent" type="Node" parent="."]
script = ExtResource("3_l5gfj")

[node name="HealthComponent" type="Node2D" parent="."]
[node name="HealthComponent" type="Node" parent="."]
script = ExtResource("4_8ip81")

[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(6, 6)
texture = ExtResource("5_ygjep")

[node name="ClickHandler" type="Node2D" parent="."]
[node name="ClickHandler" type="Node" parent="."]
script = ExtResource("6_kgqto")

[node name="Area2D" type="Area2D" parent="."]
Expand All @@ -50,8 +50,10 @@ label_settings = SubResource("LabelSettings_urr12")
script = ExtResource("7_1hqya")
health_component = NodePath("../HealthComponent")

[node name="PartyComponent" type="Node2D" parent="."]
[node name="PartyComponent" type="Node" parent="."]
script = ExtResource("8_mmgs7")
team = 1

[connection signal="input_event" from="Area2D" to="ClickHandler" method="_on_area_2d_input_event"]
[connection signal="input_event" from="Area2D" to="ClickHandler" method="_on_input_event"]
[connection signal="mouse_entered" from="Area2D" to="ClickHandler" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="ClickHandler" method="_on_mouse_exited"]
2 changes: 1 addition & 1 deletion Fauna-RPG/Helpers/StaticHelpers.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class_name Helpers


static func get_child_node_of_type(node: Node, type: Variant) -> Variant:
for child in node.get_children():
for child: Variant in node.get_children():
if is_instance_of(child, type):
return child
return null
12 changes: 8 additions & 4 deletions Fauna-RPG/Input/ClickHandler.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node2D
extends Node
class_name ClickHandler


Expand All @@ -20,7 +20,11 @@ func set_interactable(interactable: bool) -> void:
on_unhover.emit()


func _on_area_2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
_on_gui_input_event(event)


func _on_gui_input_event(event: InputEvent) -> void:
if not _is_interactable:
return

Expand All @@ -30,14 +34,14 @@ func _on_area_2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int
on_mouse_hovering.emit()


func _on_area_2d_mouse_entered() -> void:
func _on_mouse_entered() -> void:
if not _is_interactable:
return

on_hover.emit()


func _on_area_2d_mouse_exited() -> void:
func _on_mouse_exited() -> void:
if not _is_interactable:
return

Expand Down