adapted monster structure and save game
This commit is contained in:
parent
04873e3880
commit
aa4afc4c4b
22 changed files with 358 additions and 183 deletions
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue