예제 #1
0
        /// <summary>
        /// 创建技能动作实体
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static SkillActionEntity CreateSkillActionEntity(SkillAction action)
        {
            SkillActionEntity entity = new SkillActionEntity();

            entity.action = action;
            return(entity);
        }
예제 #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);
            }
        }
예제 #3
0
        /// <summary>
        /// 发出攻击
        /// </summary>
        /// <param name="hitActionId"></param>
        /// <param name="itwm"></param>
        /// <param name="rotation"></param>
        /// <param name="forward"></param>
        /// <param name="position"></param>
        public void OnAttacking(int hitActionId, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position)
        {
            SkillAction action = SkillAction.dataMap[hitActionId];

            if (action.removeCollider == 1)
            {
            }
            //动画动作
            int act = action.action;

            if (act > 0)
            {
                if (PlayerActionNames.animatorNames.ContainsKey(act))
                {
                    theOwner.skillActName = PlayerActionNames.animatorNames[act];
                }
                else
                {
                    Debug.LogWarning("找不到动作id");
                    theOwner.skillActName = "";
                }
                theOwner.SetAction(act);
            }
            AttackingFx(action);
            AttackingMove(action);
            AttackBuff(action);

            List <object> args = new List <object>();

            args.Add(ltwm);
            args.Add(rotation);
            args.Add(forward);
            args.Add(position);
            theOwner.delayAttackTimerID = TimerHeap.AddTimer((uint)(action.actionBeginDuration / theOwner.aiRate), 0, DelayAttack, hitActionId, args);
        }
예제 #4
0
        /// <summary>
        /// 对指定技能添加动作实体
        /// </summary>
        /// <param name="id"></param>
        /// <param name="action"></param>
        public void AddSkillAction(int id, SkillAction action)
        {
            SkillEntity entity = GetSkill(id);

            if (entity != null)
            {
                entity.AddAction(action);
            }
        }
예제 #5
0
        public static List <int> CacuDamage(int hitActionID, uint attackerID, uint victimID)
        {
            List <int>   result       = new List <int>();
            EntityParent attacker     = null; //攻击者
            EntityParent victimer     = null; //受击者
            double       levelCorrect = 1.00f;

            if (attackerID == GameWorld.thePlayer.ID && GameWorld.Entities.ContainsKey(victimID))
            {
                //如果攻击者刚好是主角,受击者刚好在场景中
                attacker = GameWorld.thePlayer;
                victimer = GameWorld.Entities[victimID] as EntityDummy;
                double levelGap = victimer.Level - attacker.Level;
                if (levelGap >= 20)
                {
                    levelCorrect = 0.1f;
                }
                else if (levelGap > 10 && levelGap < 20)
                {
                    levelCorrect = 1 - levelGap * 0.05f;
                }
            }
            else if (victimID == GameWorld.thePlayer.ID && GameWorld.Entities.ContainsKey(attackerID))
            {
                //如果攻击者是客户端怪物,受击者是主角
                attacker = GameWorld.Entities[attackerID];
                victimer = GameWorld.thePlayer;
            }

            bool   critFlag        = false;                           //是否发生暴击
            var    atk             = GetProperty(attacker, "Attack"); //角色的攻击力
            double extraCritDamage = 0.00f;                           //暴击伤害

            if (RandomHelper.GetRandomFloat() <= GetCritRate(attacker))
            {
                critFlag        = true;
                extraCritDamage = GetProperty(attacker, "critExtraAttack");
            }
            //1miss 2暴击 3普通攻击
            int retFlag;

            if (critFlag)
            {
                retFlag = 2;
            }
            else
            {
                retFlag = 3;
            }
            SkillAction skillData   = SkillAction.dataMap[hitActionID];
            int         skillDamage = skillData.damage;
            int         addDamage   = (int)CacuAddDamage(skillData, attacker, victimer);

            result.Add(retFlag);
            result.Add(skillDamage + addDamage);
            return(result);
        }
예제 #6
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);
        }
예제 #7
0
 /// <summary>
 /// 显示攻击特效
 /// </summary>
 /// <param name="action"></param>
 private void AttackingFx(SkillAction action)
 {
     if (!GameWorld.isShowSkillFx)
     {
         return;
     }
     theOwner.PlaySfx(action.id);
     if (action.cameraTweenId > 0)
     {
         //如果有震屏,调用摄像机脚本的震屏API接口
     }
     if (string.IsNullOrEmpty(action.sound))
     {
         //技能释放音效
     }
 }
예제 #8
0
 /// <summary>
 /// 技能增加buff
 /// </summary>
 /// <param name="action"></param>
 private void AttackBuff(SkillAction action)
 {
     if (action.casterAddBuff != null)
     {
         foreach (var id in action.casterAddBuff)
         {
             theOwner.ClientAddBuff(id);
         }
     }
     if (action.casterDelBuff != null)
     {
         foreach (var id in action.casterDelBuff)
         {
             theOwner.ClientDelBuff(id);
         }
     }
 }
예제 #9
0
        public void AttackEffect(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position)
        {
            SkillAction s = SkillAction.dataMap[hitActionID];

            if (s.damageFlag == 0)//等于1才有伤害
            {
                return;
            }
            List <List <uint> > list = GetHitEntities(hitActionID, ltwm, rotation, forward, position);

            if (list.Count != 4)
            {
                return;
            }
            if (theOwner is EntityMyself && list[0].Count > 0)
            {
            }
        }
예제 #10
0
 /// <summary>
 /// 返回技能加成伤害
 /// </summary>
 /// <param name="skillData"></param>
 /// <param name="attacker"></param>
 /// <param name="victimer"></param>
 /// <returns></returns>
 public static double CacuAddDamage(SkillAction skillData, EntityParent attacker, EntityParent victimer)
 {
     if (skillData.damageAddType == (byte)damageAddType.AD)
     {
         var atk = GetProperty(attacker, "Attack");
         return(skillData.damageAdd * atk);
     }
     else if (skillData.damageAddType == (byte)damageAddType.AP)
     {
         var ap = GetProperty(attacker, "AbilityPower");
         return(skillData.damageAdd * ap);
     }
     else if (skillData.damageAddType == (byte)damageAddType.AR)
     {
         var ar = GetProperty(attacker, "Armor");
         return(skillData.damageAdd * ar);
     }
     else if (skillData.damageAddType == (byte)damageAddType.MyselfHP)
     {
         var hp = GetProperty(attacker, "HP");
         return(skillData.damageAdd * hp);
     }
     else if (skillData.damageAddType == (byte)damageAddType.OhterHP)
     {
         if (null == victimer)
         {
             var hp = GetProperty(attacker, "HP");
             return(skillData.damageAdd * hp);
         }
         else
         {
             var hp = GetProperty(victimer, "HP");
             return(skillData.damageAdd * hp);
         }
     }
     return(0);
 }
예제 #11
0
 /// <summary>
 /// 添加动作
 /// </summary>
 /// <param name="action"></param>
 public void AddAction(SkillAction action)
 {
     actions.Add(action);
 }
예제 #12
0
        public void Process(EntityParent theOwner, params object[] args)
        {
            if (args.Length != 1)
            {
                Debug.LogError("没有攻击技能");
                return;
            }
            int       spellId = (int)args[0];
            SkillData s       = SkillData.dataMap[spellId];

            theOwner.motor.speed       = 0;
            theOwner.motor.targetSpeed = 0;
            int baseTime = 0;

            for (int i = 0; i < s.skillAction.Count; i++)
            {
                SkillAction   action = SkillAction.dataMap[s.skillAction[0]];
                List <object> args1  = new List <object>();
                args1.Add(s.skillAction[0]);
                args1.Add(theOwner.Transform.localToWorldMatrix);
                args1.Add(theOwner.Transform.rotation);
                args1.Add(theOwner.Transform.forward);
                args1.Add(theOwner.Transform.position);
                //播放技能的第一个动作
                if (i == 0)
                {
                    ProcessHit(theOwner, spellId, args1);
                    if (theOwner is EntityMyself)
                    {
                        theOwner.motor.enableStick = action.enableStick > 0;
                    }
                }
                //如果没有后续动作了就跳出循环
                if (i + 1 == s.skillAction.Count)
                {
                    break;
                }
                //记录加到定时器里面的hit动作
                uint          tid   = 0;
                List <object> args2 = new List <object>();
                args2.Add(s.skillAction[i + 1]);
                args2.Add(theOwner.Transform.localToWorldMatrix);
                args2.Add(theOwner.Transform.rotation);
                args2.Add(theOwner.Transform.forward);
                args2.Add(theOwner.Transform.position);
                if (action.actionTime > 0)
                {
                    tid       = TimerHeap.AddTimer((uint)((baseTime + action.actionTime) / theOwner.aiRate), 0, ProcessHit, theOwner, spellId, args2);
                    baseTime += action.actionTime;
                }
                if (action.nextHitTime > 0)
                {
                    tid       = TimerHeap.AddTimer((uint)((baseTime + action.nextHitTime) / theOwner.aiRate), 0, ProcessHit, theOwner, spellId, args2);
                    baseTime += action.nextHitTime;
                }
                theOwner.hitTimer.Add(tid);
            }

            /*int actionID = (int)args[0];
             * SkillActionData action = SkillActionData.dataMap[actionID];
             * SkillData skill = SkillData.dataMap[theOwner.currSpellID];
             * int duration = action.duration;
             * if (duration <= 0 && skill.skillAction.Count > 1 && theOwner.hitActionIdx >= (skill.skillAction.Count - 1))
             * {
             *  if (SkillActionData.dataMap[skill.skillAction[0]].duration <= 0)
             *  {
             *       //攻击结束,进入idle状态
             *      theOwner.AddCallbackInFrames<EntityParent>((_theOwner) =>
             *      {
             *
             *      },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) =>
             *  {
             *
             *  },actionID,theOwner);
             * }*/
        }