adapted monster structure and save game
This commit is contained in:
parent
04873e3880
commit
aa4afc4c4b
22 changed files with 358 additions and 183 deletions
|
|
@ -11,9 +11,11 @@ func _ready() -> void:
|
|||
setup_new_inventory()
|
||||
|
||||
func setup_new_inventory() -> void:
|
||||
var stats = MonsterStats.new()
|
||||
stats.manual_init("Bat", 2)
|
||||
monsters.append(stats)
|
||||
var data = MonsterData.new()
|
||||
data.set_data("debuggy", {}, 5)
|
||||
print("After setting it in inventory: ", data.display_name)
|
||||
|
||||
monsters.append(data)
|
||||
# debug timeout to wait for the debug UI
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
inventory_changed.emit()
|
||||
|
|
|
|||
73
globals/save_game.gd
Normal file
73
globals/save_game.gd
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
extends Node
|
||||
# save_game.gd - Responsible for saving and loading the game using a SaveData resource
|
||||
|
||||
const SAVE_GAME_PATH := "user://savegame.save"
|
||||
const VERSION: int = 1
|
||||
|
||||
# List all the nodes and resouces to save
|
||||
var save_data: Resource = SaveData.new()
|
||||
|
||||
func save() -> void:
|
||||
var save_file = FileAccess.open(SAVE_GAME_PATH, FileAccess.WRITE)
|
||||
|
||||
# Save the meta data like save game version and timestamps
|
||||
var meta_data = {
|
||||
"meta": {
|
||||
"version" : VERSION,
|
||||
"timestamp" : Time.get_datetime_string_from_system()
|
||||
}
|
||||
}
|
||||
var meta_json_string = JSON.stringify(meta_data)
|
||||
save_file.store_line(meta_json_string)
|
||||
|
||||
# for now, only save the savedata resource from above
|
||||
if !save_data.has_method("save"):
|
||||
print("Resource '%s' is missing a save() function, skipped" %save_data.resource_name)
|
||||
return
|
||||
|
||||
# Call the node's / resource's save function
|
||||
var node_data = save_data.call("save")
|
||||
|
||||
# Serialize the JSON string
|
||||
var json_string = JSON.stringify(node_data)
|
||||
|
||||
# Store the save dictionary as a new line in the save file
|
||||
save_file.store_line(json_string)
|
||||
|
||||
func load() -> void:
|
||||
if not FileAccess.file_exists(SAVE_GAME_PATH):
|
||||
print("No save file exists.")
|
||||
return
|
||||
|
||||
# Load the save file line by line and process the dictionary to restore
|
||||
# the object it represents
|
||||
var save_file = FileAccess.open(SAVE_GAME_PATH, FileAccess.READ)
|
||||
while save_file.get_position() < save_file.get_length():
|
||||
var json_string = save_file.get_line()
|
||||
|
||||
# Creates the helper class to interact with JSON
|
||||
var json = JSON.new()
|
||||
|
||||
# Check if there is any error while parsing the JSON string, skip in case of failure
|
||||
var parse_result = json.parse(json_string)
|
||||
if not parse_result == OK:
|
||||
print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line", json.get_error_line())
|
||||
continue
|
||||
|
||||
# Get the data from the JSON object
|
||||
var node_data = json.get_data()
|
||||
|
||||
# handle the player data (name, money, etc.)
|
||||
if node_data.has("player_data"):
|
||||
print("save_game.gd: ", node_data)
|
||||
|
||||
# Firstly, we need to create the object and add it to the tree and set its position.
|
||||
#var new_object = load(node_data["filename"]).instantiate()
|
||||
#get_node(node_data["parent"]).add_child(new_object)
|
||||
#new_object.position = Vector2(node_data["pos_x"], node_data["pos_y"])
|
||||
|
||||
# Now we set the remaining variables.
|
||||
#for i in node_data.keys():
|
||||
# if i == "filename" or i == "parent" or i == "pos_x" or i == "pos_y":
|
||||
# continue
|
||||
# new_object.set(i, node_data[i])
|
||||
|
|
@ -19,6 +19,7 @@ config/icon="res://assets/logo/logo.png"
|
|||
[autoload]
|
||||
|
||||
Inventory="*res://globals/inventory.gd"
|
||||
SaveGame="*res://globals/save_game.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
|||
66
resources/monster_data.gd
Normal file
66
resources/monster_data.gd
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
class_name MonsterData
|
||||
extends Resource
|
||||
|
||||
@export var unique_id : String = ""
|
||||
|
||||
@export var display_name : String = ""
|
||||
@export var nickname: String = ""
|
||||
@export var description: String = ""
|
||||
@export var thumbnail: CompressedTexture2D = preload("res://assets/logo/logo.png")
|
||||
@export var model: PackedScene
|
||||
@export var primary_type: MonsterType.Type = MonsterType.Type.NORMAL
|
||||
@export var secondary_type: MonsterType.Type = MonsterType.Type.NONE
|
||||
|
||||
# Base Values
|
||||
@export var base_attack: int = 1
|
||||
@export var base_health: int = 1
|
||||
@export var base_defense: int = 1
|
||||
@export var base_tempo: int = 1
|
||||
@export var base_xp_for_next_level: int = 1
|
||||
|
||||
# Current Values
|
||||
var attack: int = 1
|
||||
var current_health: int = 1
|
||||
var health: int = 1
|
||||
var defense: int = 1
|
||||
var tempo: int = 1
|
||||
var level: int = 1
|
||||
var xp: int = 1
|
||||
|
||||
|
||||
# the ID is the filename of the monster from res://resources/monsters/<filename>.tres
|
||||
func set_data(p_unique_id = "", current_values: Dictionary = {}, p_level: int = 1) -> void:
|
||||
if p_unique_id.is_empty():
|
||||
printerr("Monster.gd: No ID given")
|
||||
return
|
||||
|
||||
# Get an instance of the base monster data form the MonsterDatabase
|
||||
var base_monster = load_base_monster_data(p_unique_id)
|
||||
|
||||
# set all the values here
|
||||
self.display_name = base_monster.display_name
|
||||
self.description = base_monster.description
|
||||
self.thumbnail = base_monster.thumbnail
|
||||
self.model = base_monster.model
|
||||
self.primary_type = base_monster.primary_type
|
||||
self.secondary_type = base_monster.secondary_type
|
||||
self.base_attack = base_monster.base_attack
|
||||
self.base_health = base_monster.base_health
|
||||
self.base_defense = base_monster.base_defense
|
||||
self.base_tempo = base_monster.base_tempo
|
||||
self.base_xp_for_next_level = base_monster.base_xp_for_next_level
|
||||
|
||||
# process custom and current values
|
||||
if current_values.is_empty():
|
||||
return
|
||||
|
||||
if current_values.has("nickname"):
|
||||
self.nickname = current_values.nickname
|
||||
|
||||
func load_base_monster_data(p_unique_id):
|
||||
var path = "res://resources/monsters/" + p_unique_id + ".tres"
|
||||
if FileAccess.file_exists(path):
|
||||
var base_monster = load(path)
|
||||
return base_monster
|
||||
|
||||
printerr("Monster.gd: No monster with the ID %s found" % p_unique_id)
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
class_name MonsterStats
|
||||
extends Resource
|
||||
|
||||
@export var thumbnail: CompressedTexture2D = preload("res://assets/logo/logo.png")
|
||||
@export var name: String = "MISSINGNO"
|
||||
var spitzname: String = ""
|
||||
@export var level: int = 1
|
||||
@export var base_health: int = 100
|
||||
@export var base_attack: int = 10
|
||||
@export var base_defense: int = 10
|
||||
@export var base_speed: int = 10
|
||||
@export var base_experience_for_next_level: int = 50
|
||||
@export var model: PackedScene
|
||||
|
||||
var health: int
|
||||
var max_health: int
|
||||
var attack: int
|
||||
var defense: int
|
||||
var speed: int
|
||||
var experience: int
|
||||
var experience_for_next_level: int
|
||||
|
||||
func _init() -> void:
|
||||
max_health = roundi(base_health + 1.05 * level)
|
||||
health = max_health
|
||||
attack = base_attack
|
||||
defense = base_defense
|
||||
speed = base_speed
|
||||
experience = 0
|
||||
experience_for_next_level = roundi(base_experience_for_next_level + 1.10 * level)
|
||||
|
||||
func manual_init(p_name: String, p_level: int) -> void:
|
||||
print("TODO: Manual init")
|
||||
name = p_name
|
||||
level = p_level
|
||||
24
resources/monster_type.gd
Normal file
24
resources/monster_type.gd
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class_name MonsterType
|
||||
extends Resource
|
||||
|
||||
enum Type {
|
||||
NONE,
|
||||
NORMAL,
|
||||
FIRE,
|
||||
WATER,
|
||||
GRASS,
|
||||
FLYING,
|
||||
FIGHTING,
|
||||
POISON,
|
||||
ELECTRIC,
|
||||
GROUND,
|
||||
ROCK,
|
||||
PSYCHIC,
|
||||
ICE,
|
||||
BUG,
|
||||
GHOST,
|
||||
STEEL,
|
||||
DRAGON,
|
||||
DARK,
|
||||
FAIRY
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="MonsterStats" load_steps=4 format=3 uid="uid://ym438vedcdyl"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://h2we7rb772hy" path="res://assets/models/round_bat/model/bat.glb" id="1_ajl37"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_8r754"]
|
||||
[ext_resource type="Script" path="res://resources/monster_stats.gd" id="2_ec3n5"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_ec3n5")
|
||||
thumbnail = ExtResource("2_8r754")
|
||||
name = "Debug Monster 1"
|
||||
health = 110
|
||||
attack_value = 12
|
||||
defense_value = 15
|
||||
speed_value = 8
|
||||
model = ExtResource("1_ajl37")
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="MonsterStats" load_steps=3 format=3 uid="uid://br8opay3hdptg"]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/monster_stats.gd" id="1_saexp"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_3x4e0"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_saexp")
|
||||
health = 100
|
||||
thumbnail = ExtResource("2_3x4e0")
|
||||
name = "Debug Monster 2"
|
||||
attack_value = 10
|
||||
defense_value = 10
|
||||
speed_value = 10
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="MonsterStats" load_steps=3 format=3 uid="uid://y250cwuiq5y"]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/monster_stats.gd" id="1_eka2r"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_b7c7s"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_eka2r")
|
||||
thumbnail = ExtResource("2_b7c7s")
|
||||
name = "Debug Monster 3"
|
||||
health = 120
|
||||
attack_value = 13
|
||||
defense_value = 18
|
||||
speed_value = 30
|
||||
21
resources/monsters/debuggy.tres
Normal file
21
resources/monsters/debuggy.tres
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[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="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"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_2n3ph")
|
||||
unique_id = "debuggy"
|
||||
display_name = "Debuggy"
|
||||
nickname = "Debuggy"
|
||||
description = "A debug monster"
|
||||
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_for_next_level = 50
|
||||
24
resources/save_data.gd
Normal file
24
resources/save_data.gd
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class_name SaveData
|
||||
extends Resource
|
||||
|
||||
# Player data
|
||||
var player_name: String = "Player"
|
||||
var money: int = 0
|
||||
|
||||
# Inventory data
|
||||
|
||||
func _init() -> void:
|
||||
set_name("SaveData")
|
||||
|
||||
func save():
|
||||
var player_data = {
|
||||
"player_name": player_name,
|
||||
"money": money
|
||||
}
|
||||
|
||||
# Collect all data to save in one dictionary
|
||||
var save_dict = {
|
||||
"player_data": player_data
|
||||
}
|
||||
|
||||
return save_dict
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
extends Node3D
|
||||
# Game.gd - Main Entrypoint for the game
|
||||
|
||||
@onready var ui: UI = $UI
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
SaveGame.load()
|
||||
# Update the UI when the Inventory (global) changes
|
||||
Inventory.inventory_changed.connect(ui._update_ui)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
class_name Monster
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var stats: MonsterStats
|
||||
signal level_up
|
||||
|
||||
@export var stats: MonsterData = MonsterData.new()
|
||||
|
||||
var spawn_point: Vector3 = Vector3(0, 0, 0)
|
||||
|
||||
|
|
@ -9,7 +11,6 @@ var spawn_point: Vector3 = Vector3(0, 0, 0)
|
|||
@onready var time: float = 16.0
|
||||
@onready var frequency: float = 1.0
|
||||
@onready var amplitude: float = 0.5
|
||||
|
||||
var in_battle: bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ extends Node3D
|
|||
# monsters are only spawned, if the player is not looking
|
||||
|
||||
# list that holds all spawnable monsters
|
||||
@export var spawnable_monsters: Array[MonsterStats]
|
||||
@export var spawnable_monsters: Array[MonsterData]
|
||||
|
||||
# ignore spawning only if visible
|
||||
@export var ignore_visibility: bool = false
|
||||
|
|
@ -71,7 +71,7 @@ func spawn() -> void:
|
|||
|
||||
var debug_level_node = get_parent_node_3d()
|
||||
debug_level_node.add_child(monster_to_spawn)
|
||||
print("Spawning Mob \"%s\"" % monster_to_spawn.stats.name)
|
||||
print("Spawning Mob \"%s\"" % monster_to_spawn.stats.display_name)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ func _process(delta) -> void:
|
|||
if save_timer >= time_to_save:
|
||||
save_timer_reached.emit()
|
||||
save_timer = 0.0
|
||||
|
||||
# Save the game
|
||||
SaveGame.save()
|
||||
|
||||
save_button_held_down = false
|
||||
else:
|
||||
save_timer_incremented.emit(ceili((save_timer / time_to_save) * 100))
|
||||
|
|
|
|||
|
|
@ -21,3 +21,7 @@ func _update_monster_list() -> void:
|
|||
|
||||
# add it to the list
|
||||
monster_list_entry_container.add_child(entry)
|
||||
|
||||
func _update_player_info() -> void:
|
||||
#%PlayerName.text =
|
||||
pass
|
||||
113
scenes/ui/ingame_menu.tscn
Normal file
113
scenes/ui/ingame_menu.tscn
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://bbvbnrcjatkrb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/ui/ingame_menu.gd" id="1_beinb"]
|
||||
[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_1e4kf"]
|
||||
[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://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="3_kgfth"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxry7h4q17lir" path="res://assets/textures/Game Icons/Vector/2x/star.png" id="3_oo4iu"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_co4a0"]
|
||||
bg_color = Color(0.9, 0.9, 0.9, 1)
|
||||
corner_radius_top_left = 64
|
||||
corner_radius_top_right = 64
|
||||
corner_radius_bottom_right = 64
|
||||
corner_radius_bottom_left = 64
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_flvbu"]
|
||||
|
||||
[node name="IngameMenu" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_beinb")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 50
|
||||
theme_override_constants/margin_top = 50
|
||||
theme_override_constants/margin_right = 50
|
||||
theme_override_constants/margin_bottom = 50
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_co4a0")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
|
||||
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
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PlayerThumbnail" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_c2ia0")
|
||||
expand_mode = 3
|
||||
|
||||
[node name="PlayerName" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
|
||||
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"
|
||||
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"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="CurrencyIcon" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
|
||||
self_modulate = Color(0.941789, 0.802506, 0.327877, 1)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_oo4iu")
|
||||
expand_mode = 3
|
||||
|
||||
[node name="MonsterInfoTitle" 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
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/MonsterInfoTitle"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_fonts/font = ExtResource("2_1e4kf")
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Your Monsters"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="MonsterListEntryContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
|
||||
[node name="CloseButtonContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_flvbu")
|
||||
icon = ExtResource("3_kgfth")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bbvbnrcjatkrb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/monster_list.gd" id="1_jk76e"]
|
||||
[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_hunv3"]
|
||||
[ext_resource type="Texture2D" uid="uid://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="3_08jy5"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_co4a0"]
|
||||
bg_color = Color(0.9, 0.9, 0.9, 1)
|
||||
corner_radius_top_left = 64
|
||||
corner_radius_top_right = 64
|
||||
corner_radius_bottom_right = 64
|
||||
corner_radius_bottom_left = 64
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_flvbu"]
|
||||
|
||||
[node name="MonsterList" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_jk76e")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 50
|
||||
theme_override_constants/margin_top = 50
|
||||
theme_override_constants/margin_right = 50
|
||||
theme_override_constants/margin_bottom = 50
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_co4a0")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" 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
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_fonts/font = ExtResource("2_hunv3")
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Your Monsters"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="MonsterListEntryContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer2"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_flvbu")
|
||||
icon = ExtResource("3_08jy5")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/MarginContainer2/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
|
|
@ -12,17 +12,10 @@ func _process(delta: float) -> void:
|
|||
pass
|
||||
|
||||
func populate(monster) -> void:
|
||||
# thumbnail
|
||||
# id
|
||||
# name
|
||||
# level
|
||||
# health
|
||||
# healthprogress
|
||||
# experience
|
||||
%MonsterID.text = str(0)
|
||||
%MonsterName.text = monster.name
|
||||
%MonsterName.text = monster.display_name
|
||||
%MonsterLevel.text = "Lvl. %s" % monster.level
|
||||
%HealthProgressBar.value = monster.health
|
||||
%HealthProgressBar.max_value = monster.max_health
|
||||
%ExperienceProgressBar.value = monster.experience
|
||||
%ExperienceProgressBar.max_value = monster.experience_for_next_level
|
||||
%HealthProgressBar.max_value = monster.health
|
||||
%ExperienceProgressBar.value = monster.xp
|
||||
%ExperienceProgressBar.max_value = monster.base_xp_for_next_level
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends CanvasLayer
|
||||
class_name UI
|
||||
|
||||
@onready var monster_list: MarginContainer = %MonsterList
|
||||
@onready var ingame_menu: MarginContainer = %IngameMenu
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -12,12 +12,15 @@ func _process(delta: float) -> void:
|
|||
pass
|
||||
|
||||
func _on_ingame_controls_menu_button_clicked() -> void:
|
||||
monster_list.visible = true
|
||||
ingame_menu.visible = true
|
||||
|
||||
# Updates the whole UI
|
||||
func _update_ui() -> void:
|
||||
# Updating the player info
|
||||
ingame_menu._update_player_info()
|
||||
|
||||
# Updating the monster list
|
||||
monster_list._update_monster_list()
|
||||
ingame_menu._update_monster_list()
|
||||
|
||||
print("UI updated")
|
||||
|
||||
|
|
@ -34,9 +37,8 @@ func _on_ingame_controls_save_timer_incremented(value) -> void:
|
|||
|
||||
func _on_ingame_controls_save_timer_reached() -> void:
|
||||
%SavePercentage.text = "Saved!"
|
||||
print("Saved Game")
|
||||
%IngameControls.disable_save_button()
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
%IngameControls.enable_save_button()
|
||||
$SaveUI.visible = false
|
||||
%SavePercentage.text = "0 % ..."
|
||||
%SavePercentage.text = "0%"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
[ext_resource type="Script" path="res://scripts/camera_controls.gd" id="1_x56x6"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt00rjsodtady" path="res://scenes/ui/main_menu.tscn" id="3_tcmm8"]
|
||||
[ext_resource type="PackedScene" uid="uid://1anjhvi173g3" path="res://scenes/ui/ingame_controls.tscn" id="4_likk0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbvbnrcjatkrb" path="res://scenes/ui/monster_list.tscn" id="5_qjqu1"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbvbnrcjatkrb" path="res://scenes/ui/ingame_menu.tscn" id="5_qjqu1"]
|
||||
|
||||
[node name="UI" type="CanvasLayer"]
|
||||
script = ExtResource("1_vyi3s")
|
||||
|
|
@ -56,7 +56,7 @@ vertical_alignment = 1
|
|||
[node name="IngameControls" parent="." instance=ExtResource("4_likk0")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="MonsterList" parent="." instance=ExtResource("5_qjqu1")]
|
||||
[node name="IngameMenu" parent="." instance=ExtResource("5_qjqu1")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://be5bc5gjbo875" path="res://scenes/player/player.tscn" id="1_ra6oo"]
|
||||
[ext_resource type="PackedScene" uid="uid://dawpmu4vvv3rs" path="res://scenes/monster_spawnpoint/monster_spawnpoint.tscn" id="3_esgto"]
|
||||
[ext_resource type="Script" path="res://resources/monster_stats.gd" id="3_iktqp"]
|
||||
[ext_resource type="Resource" uid="uid://ym438vedcdyl" path="res://resources/monsters/DebugMonster1.tres" id="4_3y7gi"]
|
||||
[ext_resource type="Script" path="res://resources/monster_data.gd" id="3_iktqp"]
|
||||
[ext_resource type="Resource" uid="uid://0xqaef8uftnv" path="res://resources/monsters/debuggy.tres" id="4_noslo"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_wak6a"]
|
||||
size = Vector2(1000, 1000)
|
||||
|
|
@ -52,6 +52,6 @@ environment = SubResource("Environment_rwve8")
|
|||
|
||||
[node name="MonsterSpawnpoint" parent="." instance=ExtResource("3_esgto")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.6673, 0, -8.88992)
|
||||
spawnable_monsters = Array[ExtResource("3_iktqp")]([ExtResource("4_3y7gi")])
|
||||
spawnable_monsters = Array[ExtResource("3_iktqp")]([ExtResource("4_noslo")])
|
||||
ignore_visibility = true
|
||||
max_monsters = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue