You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
extends CharacterBody3D
|
|
|
|
|
class_name Character
|
|
|
|
|
|
|
|
|
|
@onready var status = (%Status as Status)
|
|
|
|
|
@onready var view = (%View as View)
|
|
|
|
|
@onready var collision = (%Collision)
|
|
|
|
|
|
|
|
|
|
var character_manager : CharacterManager
|
|
|
|
|
|
|
|
|
|
func init(mgr:CharacterManager,id:int,cfg:CharacterCfg,team:Enum.ETeam):
|
|
|
|
|
character_manager = mgr
|
|
|
|
|
status.id = id
|
|
|
|
|
status.team = team
|
|
|
|
|
status.cfg = cfg
|
|
|
|
|
build_view(cfg)
|
|
|
|
|
build_battle(cfg)
|
|
|
|
|
|
|
|
|
|
func build_view(cfg:CharacterCfg):
|
|
|
|
|
var half_height = Setting.pixel_size * Setting.sprite_scale * cfg.sprite_harf_height
|
|
|
|
|
var width = Setting.pixel_size * Setting.sprite_scale * cfg.sprite_width
|
|
|
|
|
|
|
|
|
|
collision.position = Vector3(0,half_height,0)
|
|
|
|
|
collision.scale = Vector3(width,half_height*2,width)
|
|
|
|
|
view.position = Vector3(0,half_height,0)
|
|
|
|
|
view.init(cfg.sprite_frames)
|
|
|
|
|
|
|
|
|
|
func build_battle(cfg:CharacterCfg):
|
|
|
|
|
status.hp = cfg.hp_max
|
|
|
|
|
status.hp_max = cfg.hp_max
|
|
|
|
|
status.shield = cfg.shield_max
|
|
|
|
|
status.shield_max = cfg.shield_max
|
|
|
|
|
|
|
|
|
|
#==getter==
|
|
|
|
|
func manager()->CharacterManager:return character_manager
|
|
|
|
|
func id()->int:return status.id
|
|
|
|
|
func team()->Enum.ETeam:return status.team
|
|
|
|
|
func pos()->Vector2:return Vector2(position.x,position.z)
|