Exemplo n.º 1
0
        public void Process(EntityParent theOwner, params object[] args)
        {
            GameMotor theMotor = theOwner.motor;

            if (theOwner is EntityBeast || (theOwner is EntityPlayer && !(theOwner is EntityMyself)))
            {
                theOwner.ApplyRootMotion(false);
                theOwner.SetSpeed(1);
                theMotor.SetSpeed(0.4f);
                if (theOwner.Speed == 0)
                {
                    theMotor.SetExtraSpeed(6);
                }
                else
                {
                    theMotor.SetExtraSpeed(theOwner.Speed);
                }
                return;
            }
            else
            {
                theOwner.ApplyRootMotion(true);
                theMotor.SetSpeed(0.4f);
                theMotor.SetExtraSpeed(0.4f);
            }
            theMotor.isMovable = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 释放技能的时候移动
        /// </summary>
        /// <param name="action"></param>
        private void AttackingMove(SkillAction action)
        {
            GameMotor motor = theOwner.motor;

            if (motor == null)
            {
                return;
            }
            float extraSpeed = action.extraSpeed;

            if (extraSpeed != 0)
            {
                motor.SetExtraSpeed(extraSpeed);
                motor.SetMoveDirection(theOwner.Transform.forward);
                //延迟extraSt时间后,设置速度为0
                TimerHeap.AddTimer <GameMotor>((uint)action.extraSt, 0, (m) => { m.SetExtraSpeed(0); }, motor);
            }
            else
            {
                motor.SetExtraSpeed(0);
            }
            //如果该技能是带传送的,直接传送
            if (action.teleportDistance > 0 && extraSpeed <= 0)
            {
                Vector3 dst = Vector3.zero;
                dst = theOwner.Transform.position + theOwner.Transform.forward * action.teleportDistance;
                motor.TeleportTo(dst);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 清除技能,到Idle状态
        /// </summary>
        /// <param name="remove"></param>
        /// <param name="naturalEnd"></param>
        public virtual void ClearSkill(bool remove = false, bool naturalEnd = false)
        {
            TimerHeap.DelTimer(hitTimerID);
            TimerHeap.DelTimer(delayAttackTimerID);
            if (currSpellID != -1)
            {
                if (SkillAction.dataMap.ContainsKey(currHitAction) && remove)
                {
                    RemoveSfx(currHitAction);
                }
                SkillData data;
                if (SkillData.dataMap.TryGetValue(currSpellID, out data) && remove)
                {
                    foreach (var action in data.skillAction)
                    {
                        RemoveSfx(action);
                    }
                }
                currHitAction = -1;
            }
            hitTimer.Clear();
            GameMotor theMotor = motor;

            if (Transform)
            {
                theMotor.enableStick    = true;
                theMotor.enableRotation = true;
                theMotor.SetExtraSpeed(0);
                theMotor.SetMoveDirection(Vector3.zero);
            }
            ChangeMotionState(MotionState.IDLE);
            currSpellID = -1;
        }
Exemplo n.º 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   skill    = SkillData.dataMap[spellId];
            int         duration = action.duration;

            if (duration <= 0 && skill.skillAction.Count > 1)
            {
                if (SkillAction.dataMap[skill.skillAction[0]].duration <= 0)
                {
                    //攻击结束,进入idle状态
                    theOwner.AddCallbackInFrames <int, EntityParent>((_actionId, _theOwner) =>
                    {
                    }, actionId, theOwner);
                }
            }
            else if (duration > 0 && action.action > 0)
            {
                TimerHeap.AddTimer <int, EntityParent>((uint)duration, 0, (_actionID, _theOwner) =>
                {
                    GameMotor theMotor = _theOwner.motor;
                    if (_theOwner.Transform)
                    {
                        theMotor.enableStick = true;
                        theMotor.SetExtraSpeed(0);                 //额外速度为0
                        theMotor.SetMoveDirection(Vector3.zero);   //移动方向为(0,0,0)
                    }
                    _theOwner.ChangeMotionState(MotionState.IDLE); //改变状态为idle
                }, actionId, theOwner);
            }
            //移除技能特效
            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);
        }
Exemplo n.º 5
0
        // 状态处理
        public void Process(EntityParent theOwner, params object[] args)
        {
            Debug.Log("Idle");
            // 播放 idle 动画
            if (theOwner == null)
            {
                return;
            }
            if (theOwner.CanMove() && theOwner.motor != null)
            {
                theOwner.motor.enableStick = true;
            }
            GameMotor theMotor = theOwner.motor;

            if (theOwner is EntityBeast)
            {
                theOwner.ApplyRootMotion(false);
            }
            // 设置速度
            if (theMotor != null)
            {
                theMotor.SetSpeed(0.0f);
                theMotor.SetExtraSpeed(0f);
            }
            if (theOwner.charging)
            {
                return;
            }
            if (theOwner is EntityPlayer && GameWorld.isInTown)
            {
                theOwner.SetAction(-1);
            }
            else
            {
                theOwner.SetAction(0);
            }
            theOwner.SetActionByStateFlagInIdleState();
        }