예제 #1
0
 protected virtual void OnAwake()
 {
     StateMachine = new RoleStateMachine(this.gameObject, true);
     RoleStateAbstract[] states = GetComponents <RoleStateAbstract>();
     for (int i = 0; i < states.Length; i++)
     {
         StateMachine.AddState(states[i]);
     }
 }
예제 #2
0
 /// <summary>
 /// 角色控制器初始化
 /// </summary>
 /// <param name="roleType"></param>
 /// <param name="roleInfo"></param>
 /// <param name="ai"></param>
 public void Init(RoleType roleType, RoleInfoBase roleInfo, IRoleAI ai)
 {
     CurRoleType  = roleType;
     CurRoleInfo  = roleInfo;
     CurRoleAI    = ai;
     m_IsInit     = true;
     StateMachine = new RoleStateMachine(this.gameObject, true);
     RoleStateAbstract[] states = GetComponents <RoleStateAbstract>();
     for (int i = 0; i < states.Length; i++)
     {
         StateMachine.AddState(states[i]);
     }
     Attack        = new RoleAttack(this);
     m_Hurt        = new RoleHurt(StateMachine, this);
     m_Hurt.OnHurt = OnHurt;
     ToIdle();
     m_RoleOperationsStatus = new StateMachine <RoleOperationsStatus>(this.gameObject, true, CurRoleInfo.RoleId + ":" + "RoleOperationsStatus");
     StateMachineDispatcher.Instance.AddEventListen(CurRoleInfo.RoleId + ":" + "RoleOperationsStatus", OnRoleOperationsStatusCallBack);
     m_RoleOperationsStatus.ChangeState(RoleOperationsStatus.NoOperations);
     //初始化血条
     InitRoleHeadBar();
 }
예제 #3
0
 public RoleHurt(RoleStateMachine fsm, RoleCtrl role)
 {
     m_StateMachine = fsm;
     m_Role         = role;
 }