Beispiel #1
0
        // 状态处理
        public void Process(EntityParent theOwner, params Object[] args)
        {
            //         Debug.Log("process prepare state");
            if (args.Length != 1)
            {
                Debug.LogError("error spell id");
                return;
            }
            int skillID = (int)(args[0]);

            // 技能释放准备相关动作
            // 比如 旋转角色, 朝向, 自动靠近目标等
            // 目前先跳过

            if (skillID > 2)
            {
                //         ActorParent actorParent = theOwner.transform.gameObject.GetComponent<ActorParent>();
                //          actorParent.SwitchToIdle();
            }

            // 回调函数, 切换到 idle
            theOwner.AddCallbackInFrames <EntityParent, int>(
                (_theOwner, _skillID) =>
            {
                _theOwner.TriggerUniqEvent(Events.FSMMotionEvent.OnPrepareEnd, _skillID);
            },
                theOwner, skillID
                );
        }
Beispiel #2
0
        // 状态处理
        public void Process(EntityParent theOwner, params Object[] args)
        {
            Debug.Log("process roll state");

            // 播放动画
            if (theOwner.animator != null)
            {
                theOwner.animator.SetInteger("Action", 30);
                theOwner.AddCallbackInFrames((t) =>
                {
                    t.animator.SetInteger("Action", -30);
                }, theOwner);
            }
        }
Beispiel #3
0
        // 状态处理
        public void Processold(EntityParent theOwner, params Object[] args)
        {
            if (theOwner is EntityDummy)
            {
                theOwner.animator.applyRootMotion = true;
            }

            if (args.Length != 1)
            {
                Debug.LogError("error spell id");
                return;
            }
            int         actionID = (int)(args[0]);
            SkillAction action   = SkillAction.dataMap[actionID];
            SkillData   s        = SkillData.dataMap[theOwner.currSpellID];

            // 回调,基于计时器。 在duration 后切换回 idle 状态
            int duration = action.duration;

            if (duration <= 0 && action.action > 0 && s.skillAction.Count == 1)
            {
                //theOwner.AddCallbackInFrames<int, EntityParent>(
                //    (_actionID, _theOwner) =>
                //    {
                //        _theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID);
                //    },
                //    actionID,
                //    theOwner);
            }
            else if (duration <= 0 && s.skillAction.Count > 1 && theOwner.hitActionIdx >= (s.skillAction.Count - 1))
            {
                if (SkillAction.dataMap[s.skillAction[0]].duration <= 0)
                {
                    theOwner.AddCallbackInFrames <int, EntityParent>(
                        (_actionID, _theOwner) =>
                    {
                        _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID);
                    },
                        actionID,
                        theOwner);
                }
            }
            else if (duration > 0 && action.action > 0)
            {
                //theOwner.stateFlag = Mogo.Util.Utils.BitSet(theOwner.stateFlag, 13);//专为旋风斩
                //theOwner.immuneShift = true;
                TimerHeap.AddTimer <int, EntityParent>(
                    (uint)duration,
                    0,
                    (_actionID, _theOwner) =>
                {
                    _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID);
                    MogoMotor theMotor = _theOwner.motor;
                    if (_theOwner.Transform)
                    {
                        theMotor.enableStick = true;
                        theMotor.SetExrtaSpeed(0);
                        theMotor.SetMoveDirection(UnityEngine.Vector3.zero);
                    }
                    //_theOwner.stateFlag = Mogo.Util.Utils.BitReset(_theOwner.stateFlag, 13);//专为旋风斩
                    //_theOwner.immuneShift = false;
                    _theOwner.ChangeMotionState(MotionState.IDLE);
                },
                    actionID,
                    theOwner);
            }
            // 回调,基于计时器。 在removeSfxTime 后关闭持久的sfx
            if (action.duration > 0)
            {
                TimerHeap.AddTimer <int, EntityParent>(
                    (uint)action.duration,
                    0,
                    (_actionID, _theOwner) =>
                {
                    _theOwner.RemoveSfx(_actionID);
                },
                    actionID,
                    theOwner);
            }
            theOwner.OnAttacking(actionID, theOwner.Transform.localToWorldMatrix, theOwner.Transform.rotation, theOwner.Transform.forward, theOwner.Transform.position);
        }
Beispiel #4
0
        private void ProcessHit(EntityParent theOwner, int spellID, List <object> args)
        {
            int actionID = (int)args[0];

            UnityEngine.Matrix4x4  ltwm     = (UnityEngine.Matrix4x4)args[1];
            UnityEngine.Quaternion rotation = (UnityEngine.Quaternion)args[2];
            UnityEngine.Vector3    forward  = (UnityEngine.Vector3)args[3];
            UnityEngine.Vector3    position = (UnityEngine.Vector3)args[4];
            if (theOwner is EntityDummy && theOwner.animator != null)
            {
                theOwner.animator.applyRootMotion = true;
            }

            SkillAction action = SkillAction.dataMap[actionID];
            SkillData   s      = SkillData.dataMap[spellID];

            // 回调,基于计时器。 在duration 后切换回 idle 状态
            int duration = action.duration;

            if (duration <= 0 && s.skillAction.Count > 1)// && theOwner.hitActionIdx >= (s.skillAction.Count - 1))
            {
                if (SkillAction.dataMap[s.skillAction[0]].duration <= 0)
                {
                    theOwner.AddCallbackInFrames <int, EntityParent>(
                        (_actionID, _theOwner) =>
                    {
                        _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID);
                    },
                        actionID,
                        theOwner);
                }
            }
            else if (duration > 0 && action.action > 0)
            {
                TimerHeap.AddTimer <int, EntityParent>(
                    (uint)duration,
                    0,
                    (_actionID, _theOwner) =>
                {
                    _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID);
                    MogoMotor theMotor = _theOwner.motor;
                    if (_theOwner.Transform)
                    {
                        theMotor.enableStick = true;
                        theMotor.SetExrtaSpeed(0);
                        theMotor.SetMoveDirection(UnityEngine.Vector3.zero);
                    }
                    //_theOwner.stateFlag = Mogo.Util.Utils.BitReset(_theOwner.stateFlag, 13);//专为旋风斩
                    //_theOwner.immuneShift = false;
                    _theOwner.ChangeMotionState(MotionState.IDLE);
                },
                    actionID,
                    theOwner);
            }
            // 回调,基于计时器。 在removeSfxTime 后关闭持久的sfx
            if (action.duration > 0)
            {
                TimerHeap.AddTimer <int, EntityParent>(
                    (uint)action.duration,
                    0,
                    (_actionID, _theOwner) =>
                {
                    _theOwner.RemoveSfx(_actionID);
                },
                    actionID,
                    theOwner);
            }
            theOwner.OnAttacking(actionID, ltwm, rotation, forward, position);
        }
Beispiel #5
0
        private void HitRule(EntityParent theOwner, int act, int hitActionID)
        {
            int      action = act;
            HitState h      = null;

            if (!HitState.dataMap.TryGetValue(theOwner.hitStateID, out h))
            {//如果没有配置,用回原来接口
                HitActionRule(theOwner, action, hitActionID);
                return;
            }
            string actName = theOwner.CurrActStateName();

            if (theOwner.currSpellID != -1)
            {
                action = h.GetSkillAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT]))
            {
                action = h.GetHitAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.PUSH]))
            {
                action = h.GetPushAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.KNOCK_DOWN]))
            {
                action = h.GetKnockDownAct(action);
            }
            else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR]))
            {
                action = h.GetHitAirAct(action);
            }
            else if (actName.EndsWith("knockout"))
            {
                action = h.GetKnockOutAct(action);
            }
            else if (actName.EndsWith("getup"))
            {
                action = h.GetGetUpAct(action);
            }
            else if (theOwner.animator.GetInteger("Action") == ActionConstants.REVIVE)
            {
                action = h.GetReviveAct(action);
            }
            else //(theOwner.CurrentMotionState == MotionState.IDLE)
            {
                action = h.GetIdleAct(action);
            }
            if (action != 0)
            {
                theOwner.SetAction(action);
            }
            // 回调函数, 切换到 idle
            theOwner.AddCallbackInFrames <EntityParent, int>(
                (_theOwner, _hitAct) =>
            {
                _theOwner.motor.CancleLookAtTarget();
                _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnHitAnimEnd, _hitAct);
                if (_theOwner is EntityMyself)
                {
                    _theOwner.SetSpeed(0);
                    _theOwner.motor.SetSpeed(0);
                }
            },
                theOwner, hitActionID
                );
        }