updated to 4.4, fixed levelup

This commit is contained in:
Luca 2024-11-15 22:27:10 +01:00
parent ce5d12df95
commit cd62e12389
64 changed files with 178 additions and 60 deletions

View file

@ -0,0 +1 @@
uid://cu503s5kvphtn

View file

@ -0,0 +1 @@
uid://dssclgt0trckq

View file

@ -0,0 +1 @@
uid://x8gxk55qi2vm

View file

@ -0,0 +1 @@
uid://bk8d6dgefns5c

View file

@ -0,0 +1 @@
uid://535c636rweiv

View file

@ -0,0 +1 @@
uid://d1qj50s4fhf0f

View file

@ -0,0 +1 @@
uid://cocyc4cxaeye6

View file

@ -0,0 +1 @@
uid://swcqgichcq85

View file

@ -0,0 +1 @@
uid://bvh0rjck0ice0

View file

@ -0,0 +1 @@
uid://cjg3b55r57h8x

View file

@ -0,0 +1 @@
uid://dx2qyuyr5kh87

View file

@ -0,0 +1 @@
uid://b842l1cbmh6eq

View file

@ -0,0 +1 @@
uid://b77cgiqv8xfls

View file

@ -0,0 +1 @@
uid://c73auggirriq2

View file

@ -0,0 +1 @@
uid://0q7qc73wagwl

View file

@ -0,0 +1 @@
uid://dnk5q6wyaldnh

View file

@ -0,0 +1 @@
uid://bexpbdpoj1nh3

View file

@ -0,0 +1 @@
uid://b74q81dau8dw2

View file

@ -0,0 +1 @@
uid://h0poxvm31dch

View file

@ -0,0 +1 @@
uid://wrvu3mdm0ss0

View file

@ -0,0 +1 @@
uid://bo1070g3b1e0b

View file

@ -0,0 +1 @@
uid://d22hcg66s8hxu

View file

@ -0,0 +1 @@
uid://clkrhqgx1qviq

View file

@ -0,0 +1 @@
uid://bx1hupx44tdsd

View file

@ -0,0 +1 @@
uid://db7inrm6xdmc5

View file

@ -0,0 +1 @@
uid://b44bktvws5v3s

View file

@ -153,17 +153,22 @@ func handle_battle() -> void:
UI.battle_ui.set_message("You won!")
await get_tree().create_timer(2.0).timeout
var gained_xp: int = player_monster.data.calculate_gained_xp(enemy.data)
player_monster.data.add_xp(gained_xp)
UI.battle_ui.set_message("%s gained %s XP!" % [player_monster.data.name, str(gained_xp)])
print("You gained %s xp!" % str(gained_xp))
await get_tree().create_timer(2.0).timeout
# End the battle and reset some states
# TODO: Maybe add a cooldown of 1.5s after the battle ended
battle_state = Enums.BattleState.NOT_IN_BATTLE
enemy.queue_free()
player_monster.queue_free()
enemy.queue_free()
UI.ingame_menu.update()
UI.show_battle_ui(false)
UI.show_ingame_controls(true)
var gained_xp: int = player_monster.data.calculate_gained_xp(enemy.data)
player_monster.data.add_xp(gained_xp)
print("You gained %s xp!" % str(gained_xp))
battle_state = Enums.BattleState.NOT_IN_BATTLE
Enums.BattleState.LOSE:
SoundManager.play_sound_effect("Lost Battle")

View file

@ -0,0 +1 @@
uid://be00fdjdehq03

View file

@ -37,7 +37,8 @@ func start_new_game() -> void:
# Give the player a monster
var monster: MonsterData = MonsterData.new()
monster.set_values("debuggy", { "current_health": 12 }, 5)
monster.set_values("debuggy", {}, 5)
monster.heal(999)
SaveManager.current_save.party.push_back(monster)
# Update the UI once

1
game.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dd1wbhas5qlmi

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://cswuap81n7t3f"]
[ext_resource type="Script" path="res://game.gd" id="1_mfbtr"]
[ext_resource type="Script" uid="uid://dd1wbhas5qlmi" path="res://game.gd" id="1_mfbtr"]
[ext_resource type="PackedScene" uid="uid://cavbs8gurvpfh" path="res://worlds/terrain1/terrain1.tscn" id="2_luexm"]
[ext_resource type="Script" path="res://globals/colors.gd" id="3_0x6i2"]
[ext_resource type="Script" uid="uid://bf0efu0g7cnwh" path="res://globals/colors.gd" id="3_0x6i2"]
[node name="Game" type="Node3D"]
script = ExtResource("1_mfbtr")

1
globals/SoundFile.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://pctv6qasg6aa

1
globals/colors.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bf0efu0g7cnwh

1
globals/enums.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dj52nei2vwnuk

View file

@ -0,0 +1 @@
uid://t62dxmfb12pl

View file

@ -0,0 +1 @@
uid://b36pfmvb37tcx

View file

@ -16,3 +16,8 @@ func load_base_monster_data(p_unique_id: String) -> MonsterData:
else:
printerr("Monster.gd: No monster with the ID %s found" % p_unique_id)
return null
func heal_all() -> void:
for monster: MonsterData in SaveManager.current_save.party:
print("Healed %s" % monster.name)
monster.heal(9999)

1
globals/utils.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://x5ktjel1bpd0

View file

@ -12,7 +12,7 @@ config_version=5
config/name="monsterfangen"
run/main_scene="res://game.tscn"
config/features=PackedStringArray("4.3", "Mobile")
config/features=PackedStringArray("4.4", "Mobile")
boot_splash/image="res://assets/logo/logo.png"
config/icon="res://assets/logo/logo.png"
@ -64,22 +64,22 @@ theme/custom="res://theme/basic_theme.tres"
joystick_right_right={
"deadzone": 0.0,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-3,"axis":2,"axis_value":1.0,"script":null)
]
}
joystick_right_left={
"deadzone": 0.0,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-3,"axis":2,"axis_value":-1.0,"script":null)
]
}
joystick_right_up={
"deadzone": 0.0,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-3,"axis":3,"axis_value":-1.0,"script":null)
]
}
joystick_right_down={
"deadzone": 0.0,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-3,"axis":3,"axis_value":1.0,"script":null)
]
}

View file

@ -0,0 +1 @@
uid://b7oqmdlfu5k6h

View file

@ -68,23 +68,47 @@ func set_values(p_unique_id : String = "", current_values: Dictionary = {}, p_le
## This sets the monster to the specified level
func set_level(p_level: int) -> void:
self.level = p_level
#print("old: %s/%s" % [self.current_health, self.health])
update()
#print("new: %s/%s" % [self.current_health, self.health])
# Updates the values according to the current level of the monster
func update() -> void:
# INFO: the "current" values like the current_health should keep the percentage ratio
# of the new and increased values like max_health
var health_ratio: float = float(current_health) / float(self.health)
#print("Ratio is %s" % str(health_ratio))
var new_current_health_value: int = round( float(self.health) * health_ratio )
#print(new_current_health_value)
if new_current_health_value > self.current_health:
self.current_health = new_current_health_value
self.attack = int((((base_attack * 2.0) * level ) / 100) + (level + 5))
self.health = int((((base_health * 2.0) * level ) / 100) + (level + 5))
self.defense = int((((base_defense * 2.0) * level ) / 100) + (level + 5))
self.tempo = int((((base_tempo * 2.0) * level ) / 100) + (level + 5))
self.xp_for_levelup = int(pow(level + 1, 3))
# This is the default growth rate formula: n^3
# It calculates the total cumulative xp needed to reach level n
# To determine the XP needed for levelup, subtract the needed absolute xp
# for the current level from the next level
self.xp_for_levelup = int( (pow(level + 1, 3) - pow(level, 3)) )
func level_up() -> void:
print("monster_data.gd: %s leveled up!" % self.name)
set_level(level + 1)
# reset the gained XP
self.xp = 0
emit_signal("on_level_up")
func calculate_gained_xp(enemy_data: MonsterData) -> int:
var calculated_xp: int = 0
calculated_xp = int( (enemy_data.base_xp * enemy_data.level / 5.0) * ( float(enemy_data.level) / float(level) ) )
calculated_xp = 1 + int( (enemy_data.base_xp * enemy_data.level / 5.0) * ( float(enemy_data.level) / float(level) ) )
return calculated_xp
func add_xp(amount: int = 0) -> void:

View file

@ -0,0 +1 @@
uid://c37crtp1pdt42

View file

@ -0,0 +1 @@
uid://cxuxtevirvn7j

View file

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="MonsterData" load_steps=4 format=3 uid="uid://0xqaef8uftnv"]
[ext_resource type="Script" path="res://resources/monster_data.gd" id="1_2n3ph"]
[ext_resource type="Script" uid="uid://c37crtp1pdt42" path="res://resources/monster_data.gd" id="1_2n3ph"]
[ext_resource type="PackedScene" uid="uid://h2we7rb772hy" path="res://assets/models/round_bat/model/bat.glb" id="1_dsg0f"]
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_a4t2w"]
@ -13,17 +13,17 @@ thumbnail = ExtResource("2_a4t2w")
model = ExtResource("1_dsg0f")
primary_type = 5
secondary_type = 17
base_attack = 10
base_health = 20
base_defense = 30
base_tempo = 40
base_xp = 3
base_attack = 45
base_health = 40
base_defense = 40
base_tempo = 56
base_xp = 55
attack = 1
current_health = 1
health = 1
defense = 1
tempo = 1
level = 1
xp = 1
xp = 0
nickname = ""
xp_for_levelup = 1

View file

@ -0,0 +1 @@
uid://co1n2rldtc1d1

View file

@ -0,0 +1 @@
uid://fu02qhhn4vh8

View file

@ -0,0 +1 @@
uid://tosto05trpfl

View file

@ -0,0 +1 @@
uid://b0djbt0yqc6st

View file

@ -0,0 +1 @@
uid://cgg3sy2qd5352

View file

@ -0,0 +1 @@
uid://cp2jtkql0gaci

View file

@ -0,0 +1 @@
uid://dylk55426bidt

View file

@ -0,0 +1 @@
uid://cuik3h7xk1ung

View file

@ -5,6 +5,9 @@ class_name MonsterList
@onready var monster_list_entry: PackedScene = preload("res://ui/ingame_menu/party_list_entry.tscn")
func _ready() -> void:
# INFO: Add debug heal function for the "Party" button
%PartyButton.pressed.connect(debug_heal)
visible = false
for i: int in range(6):
var entry: Node = monster_list_entry.instantiate()
@ -14,12 +17,20 @@ func _on_close_button_pressed() -> void:
visible = false
func update() -> void:
for i: int in SaveManager.current_save.party.size():
var monster: MonsterData = SaveManager.current_save.party[i]
for i: int in range(6):
var entry: Node = monster_list_entry_container.get_child(i)
if SaveManager.current_save.party.size() >= i+1:
var monster: MonsterData = SaveManager.current_save.party[i]
entry.update(monster)
else:
entry.hide_entry()
func _update_player_info() -> void:
#%PlayerName.text =
pass
func debug_heal() -> void:
Utils.heal_all()
UI.ingame_menu.update()

View file

@ -0,0 +1 @@
uid://dlgvxqnux5b76

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://bbvbnrcjatkrb"]
[ext_resource type="Script" path="res://ui/ingame_menu/ingame_menu.gd" id="1_beinb"]
[ext_resource type="Script" uid="uid://dlgvxqnux5b76" path="res://ui/ingame_menu/ingame_menu.gd" id="1_beinb"]
[ext_resource type="Texture2D" uid="uid://bhh31i3wgww43" path="res://assets/textures/Game Icons/Vector/2x/singleplayer.png" id="2_c2ia0"]
[ext_resource type="Texture2D" uid="uid://cxry7h4q17lir" path="res://assets/textures/Game Icons/Vector/2x/star.png" id="3_oo4iu"]
@ -33,9 +33,9 @@ layout_mode = 2
[node name="PlayerInfo" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 40
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo"]
layout_mode = 2
@ -51,14 +51,14 @@ unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "PLAYER_NAME"
text = "Max"
vertical_alignment = 1
[node name="MoneyValue" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "1.000.000"
text = "23.451"
vertical_alignment = 1
[node name="CurrencyIcon" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
@ -72,15 +72,19 @@ layout_mode = 2
alignment = 1
[node name="PartyButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "Party"
[node name="Items" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
text = "Items"
[node name="Player" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
text = "Player"
[node name="MonsterInfoTitle" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
@ -115,11 +119,10 @@ theme_override_constants/margin_bottom = 32
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
size_flags_horizontal = 4
theme_type_variation = &"RedButton"
text = "Close"
icon_alignment = 1
expand_icon = true
[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer/CloseButton" to="." method="_on_close_button_pressed"]

View file

@ -1,7 +1,14 @@
extends PanelContainer
class_name PartyListEntry
func _ready() -> void:
$HBoxContainer.modulate.a = 0.0
func hide_entry() -> void:
$HBoxContainer.modulate.a = 0.0
func update(monster: MonsterData) -> void:
$HBoxContainer.modulate.a = 1.0
%MonsterID.text = str(0)
%MonsterName.text = monster.name
%MonsterLevel.text = "Lvl. %s" % monster.level
@ -9,3 +16,6 @@ func update(monster: MonsterData) -> void:
%HealthProgressBar.max_value = monster.health
%ExperienceProgressBar.value = monster.xp
%ExperienceProgressBar.max_value = monster.xp_for_levelup
%MonsterATK.text = "ATK: " + str(monster.attack)
%MonsterDEF.text = "DEF: " + str(monster.defense)
%MonsterXP.text = "XP: " + str(monster.xp) + "/" + str(monster.xp_for_levelup)

View file

@ -0,0 +1 @@
uid://dxa5lmd7juge3

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://brp2sljqnkuhe"]
[ext_resource type="Script" path="res://ui/ingame_menu/party_list_entry.gd" id="1_gdhy7"]
[ext_resource type="Script" uid="uid://dxa5lmd7juge3" path="res://ui/ingame_menu/party_list_entry.gd" id="1_gdhy7"]
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_rogma"]
[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="3_etjt6"]
@ -80,7 +80,6 @@ theme_override_constants/separation = 0
[node name="HealthProgressBar" type="ProgressBar" parent="HBoxContainer/VBoxContainer/ProgressBarContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
theme_override_styles/background = SubResource("StyleBoxFlat_s3mod")
theme_override_styles/fill = SubResource("StyleBoxFlat_nb1sm")
@ -90,6 +89,7 @@ show_percentage = false
[node name="ExperienceProgressBar" type="ProgressBar" parent="HBoxContainer/VBoxContainer/ProgressBarContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 5)
layout_mode = 2
theme_override_styles/background = SubResource("StyleBoxFlat_fkb5g")
theme_override_styles/fill = SubResource("StyleBoxFlat_b4pov")
@ -97,6 +97,24 @@ step = 1.0
rounded = true
show_percentage = false
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/VBoxContainer"]
layout_mode = 2
[node name="MonsterATK" type="Label" parent="HBoxContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "ATK: 0"
[node name="MonsterDEF" type="Label" parent="HBoxContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "DEF: 0"
[node name="MonsterXP" type="Label" parent="HBoxContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "XP: 0"
[node name="SwapPositionButton" type="Button" parent="HBoxContainer"]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 1)
@ -104,7 +122,7 @@ custom_minimum_size = Vector2(30, 30)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
theme_override_constants/icon_max_width = 32
theme_override_constants/icon_max_width = 60
icon = ExtResource("3_etjt6")
flat = true
icon_alignment = 1

View file

@ -0,0 +1 @@
uid://de6rsei7l6dv4

View file

@ -56,11 +56,11 @@ func add_license(license_path: String) -> void:
if license_path.ends_with(".remap"):
license_path = license_path.replace(".remap", "")
print(LICENSE_FOLDER + license_path)
#print(LICENSE_FOLDER + license_path)
var asset_info: AssetInfo = ResourceLoader.load(LICENSE_FOLDER + license_path)
var new_license_entry: Node = license_entry.instantiate()
license_container.add_child(new_license_entry)
print(asset_info)
#print(asset_info)
new_license_entry.populate(asset_info)

View file

@ -0,0 +1 @@
uid://bgexsev1yslus

1
ui/ui.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bhajdnao0awhr

View file

@ -4,7 +4,7 @@
[ext_resource type="Terrain3DMaterial" uid="uid://c6ppgrnektc8g" path="res://worlds/terrain1/terrain1_material.tres" id="2_2cdhe"]
[ext_resource type="Terrain3DAssets" uid="uid://bh60t03kfpvux" path="res://worlds/terrain1/terrain1_assets.tres" id="3_5hdjg"]
[ext_resource type="PackedScene" uid="uid://dawpmu4vvv3rs" path="res://entities/monster_spawnpoint/monster_spawnpoint.tscn" id="4_l81pf"]
[ext_resource type="Script" path="res://entities/monster_spawnpoint/monster_spawnpoint_probability.gd" id="5_6bskj"]
[ext_resource type="Script" uid="uid://b44bktvws5v3s" path="res://entities/monster_spawnpoint/monster_spawnpoint_probability.gd" id="5_6bskj"]
[ext_resource type="Resource" uid="uid://0xqaef8uftnv" path="res://resources/monsters/debuggy.tres" id="6_of6wf"]
[ext_resource type="PackedScene" uid="uid://bi7vo3i6wsl2y" path="res://assets/models/environment/stylized_nature_kit_quaternius/plant7diedummekuh.glb" id="7_a22cv"]
@ -46,18 +46,9 @@ collision_mask = 9
[node name="MonsterSpawnpoint" parent="." instance=ExtResource("4_l81pf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.3621, 0, -15.1762)
spawnable_monsters = Array[ExtResource("5_6bskj")]([SubResource("Resource_rgf8x")])
min_level = 2
max_level = 5
ignore_visibility = true
[node name="MonsterSpawnpoint2" parent="." instance=ExtResource("4_l81pf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14.129, 0, -9.60006)
spawnable_monsters = Array[ExtResource("5_6bskj")]([SubResource("Resource_rgf8x")])
[node name="MonsterSpawnpoint3" parent="." instance=ExtResource("4_l81pf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 37.0513, 4.65929, 13.587)
spawnable_monsters = Array[ExtResource("5_6bskj")]([SubResource("Resource_rgf8x")])
[node name="MonsterSpawnpoint4" parent="." instance=ExtResource("4_l81pf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14.8614, 1.04235, 27.0149)
spawnable_monsters = Array[ExtResource("5_6bskj")]([SubResource("Resource_rgf8x")])
[node name="plant7diedummekuh" parent="." instance=ExtResource("7_a22cv")]
[node name="DebugPlant" parent="." instance=ExtResource("7_a22cv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.02146, 0, 1.29385)

Binary file not shown.