예제 #1
0
 protected void ReallyDoAction(GOAction action)
 {
     if (_curAction != null)
     {
         _curAction.ActionOut();
     }
     _curAction = action;
     _curAction.ActionIn();
 }
예제 #2
0
 public virtual void ChangeNetObj(bool isNetObj)
 {
     if (this.isNetObj != isNetObj)
     {
         this.isNetObj = isNetObj;
         InitAction();
         //从网络对象切换到当前对象的话,做默认动作
         GOAction defaultAction = GetAction(_gameObjectActionData.defaultId);
         ReallyDoAction(defaultAction);
     }
 }
예제 #3
0
        //初始化当前对象的action
        public void InitAction()
        {
            _actionMap = new Dictionary <int, GOAction>();
            List <ActionData> list = _gameObjectActionData.GetListActionData();

            for (int i = 0; i < list.Count; i++)
            {
                GOAction action = new GOAction(_gameObjectController, list[i], isNetObj);
                _actionMap.Add(action.actionData.id, action);
            }
        }
예제 #4
0
        public virtual bool DoAction(int actionId, ActionParam param = null)
        {
            GOAction action = GetAction(actionId);

            if (!action.CanDoAction())
            {
                return(false);
            }
            if (!_curAction.CanCancelAction())
            {
                return(false);
            }
            _curAnimatorController.DoAction(action.actionData.animName);
            return(true);
        }
예제 #5
0
        public void BindAnimatorController(AnimatorController animatorController)
        {
            if (_curAnimatorController != null)
            {
                _curAnimatorController.On_ActionStateEnter -= HandleOn_ActionStateEnter;
                _curAnimatorController.On_AnimatorEvent    -= HandleOn_AnimatorEvent;
                _curAnimatorController.Dispose();
            }
            _curAnimatorController = animatorController;
            UpdateNameHashActionMap();
            _curAnimatorController.On_ActionStateEnter += HandleOn_ActionStateEnter;
            _curAnimatorController.On_AnimatorEvent    += HandleOn_AnimatorEvent;
            //强制做默认动作
            ActionData actionData = _gameObjectActionData.GetActionData(_gameObjectActionData.defaultId);

            _curAnimatorController.animator.Play(actionData.animName, actionData.animLayer);
            GOAction defaultAction = GetAction(_gameObjectActionData.defaultId);

            ReallyDoAction(defaultAction);
        }
예제 #6
0
        //监听动画事件,如果动画发生改变,那么当前行为改变
        protected void HandleOn_ActionStateEnter(StateInfo info)
        {
            GOAction action = GetActionByAnimNameHash(info.fullNameHash);

            ReallyDoAction(action);
        }