import State from "../data/State" ; import Transition from "../data/Transition" ; const { ccclass , property } = cc . _decorator ; export const UnitColor = { NORMAL : cc . color ( 150 , 150 , 150 ) , DEFAULT : cc . color ( 210 , 120 , 70 ) , ANY_STATE : cc . color ( 92 , 190 , 199 ) } ; /**
 * 状态节点或者状态机节点的基类
 */ @ ccclass export default class UnitBase extends cc . Component { @ property ( cc . Node ) SelectNode : cc . Node = null ; @ property ( cc . Node ) BgNode : cc . Node = null ; @ property ( cc . Label ) NameLabel : cc . Label = null ; protected _isDefault : boolean = false ; virtual public get isDefault ( ) { return this . _isDefault ; } public set isDefault ( v ) { this . _isDefault = v ; this . BgNode . color = this . _isDefault ? UnitColor . DEFAULT : UnitColor . NORMAL ; } param value public select ( value ) { this . SelectNode . active = value ; this . node . setSiblingIndex ( this . node . parent . childrenCount - 1 ) ; } virtual public addTransition ( toUnit , toState ) { } virtual param toUnit public getTransitions ( toUnit = null ) { return [ ] ; } virtual public setPos ( x , y = 0 ) { let pos = cc . v2 ( x , y ) ; pos = cc . v2 ( Math . round ( pos . x / 30 ) * 30 , Math . round ( pos . y / 30 ) * 30 ) ; this . node . position = pos ; return pos ; } }