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.
28 lines
800 B
GDScript
28 lines
800 B
GDScript
|
2 years ago
|
extends CharacterBody3D
|
||
|
|
class_name Character
|
||
|
|
|
||
|
|
@onready var status = (%Status as Status)
|
||
|
|
@onready var view = (%View as View)
|
||
|
|
@onready var collision = (%Collision)
|
||
|
|
|
||
|
|
func init(id:int,cfg:CharacterCfg):
|
||
|
|
status.id = id
|
||
|
|
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
|