Ejemplo n.º 1
0
    private void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        //Debug.Log(GetType() + "/SkillAction()/ ");

        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        // 判断是怪物还是玩家攻击,避免怪物打怪物
        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer player = caster.battleMgr.entityPlayer;
            if (player == null)
            {
                return;
            }
            // 判断距离和角度
            if (InRange(caster.GetPos(), player.GetPos(), skillActionCfg.radius) == true &&
                InAngle(caster.GetTrans(), player.GetPos(), skillActionCfg.angle) == true
                )
            {
                // 计算伤害
                CalcDamage(caster, player, skillCfg, damage);
            }
            Debug.Log(GetType() + "/SkillAction()/ ...");
        }
        else if (caster.entityType == EntityType.Player)
        {
            // 获取场景中所有的怪物尸体,遍历运算伤害
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster monster = monsterLst[i];

                // 判断距离和角度
                if (InRange(caster.GetPos(), monster.GetPos(), skillActionCfg.radius) == true &&
                    InAngle(caster.GetTrans(), monster.GetPos(), skillActionCfg.angle) == true
                    )
                {
                    // 计算伤害
                    CalcDamage(caster, monster, skillCfg, damage);
                }
                Debug.Log(GetType() + "/SkillAction()/ ...");
            }
        }


        //Debug.Log(GetType() + "/SkillAction()/ End");
    }
Ejemplo n.º 2
0
    private bool InAtkRange()
    {
        EntityPlayer entityPlayer = battleMgr.entitySelfPlayer;

        if (entityPlayer == null || entityPlayer.currentAniState == AniState.Die)
        {
            runAI = false;
            return(false);
        }
        else
        {
            Vector3 target = entityPlayer.GetPos();
            Vector3 self   = GetPos();
            target.y = 0;
            self.y   = 0;
            float dis = Vector3.Distance(target, self);
            if (dis <= md.mCfg.atkDis)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Ejemplo n.º 3
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionData = resSvc.GetSkillActionCfg(skillCfg.skillActionList[index]);
        int            damage          = skillCfg.skillDamageList[index];

        if (caster.entityType == EntityType.Player)
        {
            //获取场景中所有怪物实体
            List <EntityMonster> monsterList = caster.battleMgr.GetEntityMonster();

            for (int i = 0; i < monsterList.Count; i++)
            {
                EntityMonster target = monsterList[i];
                //判断距离和角度,对满足条件的怪物进行伤害运算
                if (InRange(caster.GetPos(), target.GetPos(), skillActionData.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionData.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
        else if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer entityPlayer = caster.battleMgr.GetEntityPlayer();
            if (entityPlayer == null)
            {
                return;
            }
            if (InRange(caster.GetPos(), entityPlayer.GetPos(), skillActionData.radius) && InAngle(caster.GetTrans(), entityPlayer.GetPos(), skillActionData.angle))
            {
                CalcDamage(caster, entityPlayer, skillCfg, damage);
            }
        }
    }
Ejemplo n.º 4
0
    private bool InAtkRange()
    {
        EntityPlayer entityPlayer = battleMgr.GetEntityPlayer();

        if (entityPlayer == null || entityPlayer.currentAniState == AniState.Die)
        {
            runAI = false;
            return(false);
        }
        Vector3 targetPos = entityPlayer.GetPos();
        Vector3 selfPos   = GetPos();

        targetPos.y = 0;
        selfPos.y   = 0;
        float dis    = Vector3.Distance(targetPos, selfPos);
        float atkDis = monsterData.monsterCfg.atkDis;

        if (dis <= atkDis)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 5
0
    //是否在攻击范围内
    public bool InAttackRange()
    {
        EntityPlayer enitityPlayer = battleMgr.GetEnitityPlayer();
        Vector3      playerPos     = enitityPlayer.GetPos();
        Vector3      selfPos       = GetPos();
        float        dis           = Vector2.Distance(new Vector2(playerPos.x, playerPos.z), new Vector2(selfPos.x, selfPos.z));

        return(dis < msd.mCfg.atkDis);
    }
Ejemplo n.º 6
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer targetEntity = caster.battleMgr.entitySelfPlayer;
            if (targetEntity == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), targetEntity.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), targetEntity.GetPos(), skillActionCfg.angle))
            {
                //计算伤害TODO
                CalcDamage(caster, targetEntity, skillCfg, damage);
            }
        }
        else if (caster.entityType == EntityType.Player)
        {
            //获取场景里怪物实体,遍历运算
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonster();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster targetEntity = monsterLst[i];
                //判断距离,判断角度
                if (InRange(caster.GetPos(), targetEntity.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), targetEntity.GetPos(), skillActionCfg.angle))
                {
                    //计算伤害TODO
                    CalcDamage(caster, targetEntity, skillCfg, damage);
                }
            }
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 技能伤害计算
    /// </summary>
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);
        int            damage         = skillCfg.skillDamageLst[index];

        // 怪物攻击,目标是玩家
        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer target = caster.battleMgr.entitySelfPlayer;
            if (target == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
            {
                CalcDamage(caster, target, skillCfg, damage);
            }
        }
        // 玩家攻击,目标是怪物
        else if (caster.entityType == EntityType.Player)
        {
            // 获取场景里所有的怪物实体,遍历运算,怪物很多的游戏 如 MMO 就不能这样运算
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster target = monsterLst[i];
                // 判断距离,判断角度
                if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    // 计算伤害
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 瞬时技能
    /// </summary>
    /// <param name="caster"></param>
    /// <param name="skillCfg"></param>
    /// <param name="index"></param>
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = GameEntry.Res.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer target = caster.BattleMgr.EntitySelfPlayer;
            if (target == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
            {
                CalcDamage(caster, target, skillCfg, damage);
            }
        }
        else if (caster.entityType == EntityType.Player)
        {
            //获取场景里所有的怪物实体,遍历运算
            List <EntityMonster> monsterLst = caster.BattleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster em = monsterLst[i];
                //判断距离,判断角度
                if (InRange(caster.GetPos(), em.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), em.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, em, skillCfg, damage);
                }
            }
        }
    }
Ejemplo n.º 9
0
    public override Vector2 CalcTargetDir()
    {
        EntityPlayer entityPlayer = battleMgr.GetEntityPlayer();

        if (entityPlayer == null || entityPlayer.currentAniState == AniState.Die)
        {
            runAI = false;
            return(Vector2.zero);
        }
        Vector3 targetPos = entityPlayer.GetPos();
        Vector3 selfPos   = GetPos();
        Vector2 dir       = new Vector2(targetPos.x - selfPos.x, targetPos.z - selfPos.z);

        return(dir.normalized);
    }
Ejemplo n.º 10
0
    public override Vector2 CalcTargetDir()
    {
        EntityPlayer entityPlayer = battleMgr.entitySelfPlayer;

        if (entityPlayer == null || entityPlayer.currentAniState == AniState.Die)
        {
            runAI = false;
            return(Vector2.zero);
        }
        else
        {
            Vector3 target = entityPlayer.GetPos();
            Vector3 self   = GetPos();
            return(new Vector2(target.x - self.x, target.z - self.z).normalized);
        }
    }
Ejemplo n.º 11
0
 public override Vector2 CalculateTargetDir()
 {
     EntityPlayer entityPlayer = battleMg.entitySelfPlayer;
     //玩家死亡就停止AI驱动
     if (entityPlayer==null||entityPlayer.currentState==AniState.Die)
     {
         runAI = false;
         return Vector2.zero;
     }
     else
     {
         Vector3 target = entityPlayer.GetPos();
         Vector3 self = GetPos();
         Vector2 dir = new Vector2(target.x - self.x, target.z - self.z);
         dir = dir.normalized;
         return dir;
     }
 }
Ejemplo n.º 12
0
 private bool InAtkRange(bool isBoss)
 {
     EntityPlayer entityPlayer = battleMg.entitySelfPlayer;
     //玩家死亡就停止AI驱动
     if (entityPlayer == null || entityPlayer.currentState == AniState.Die)
     {
         runAI = false;
         return false;
     }
     else
     {
         Vector3 target = entityPlayer.GetPos();
         Vector3 self = GetPos();
         target.y = 0;
         self.y = 0;
         float dis = Vector3.Distance(target,self);
         if (isBoss)
         {
             currentSkillCfg = ResSvc.instance.GetSkillCfgData(currentBossSkill);
             if (dis <= currentSkillCfg.skillAtkDistance)
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
         else
         {
             if (dis <= md.mCfg.atkDis)
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
     }
 }
Ejemplo n.º 13
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index, Vector3 blackAirPos)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionData(skillCfg.skillActionList[index]);

        int damage = skillCfg.skillDamageList[index];

        if (caster.entityType == EntityType.Player)
        {
            //拿到场景中的怪物实体,遍历运算
            List <EntityMonster> monsterList = caster.battleMg.GetEntityMonsters();

            for (int i = 0; i < monsterList.Count; i++)
            {
                EntityMonster target = monsterList[i];
                if (target == null)
                {
                    return;
                }
                //判断距离,角度
                //如果是范围技能,施法者位置变更为鼠标指定区域位置,角度固定为360度
                if (skillCfg.dmgType == DamageType.AreaSkill)
                {
                    if (InRange(BattleSys.Instance.playerCtrlWnd.pos, target.GetPos(), skillActionCfg.radius))
                    {
                        CalcDamage(caster, target, skillCfg, damage);
                    }
                }
                else
                {
                    if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                    {
                        //计算伤害
                        CalcDamage(caster, target, skillCfg, damage);
                    }
                    else if (!InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius))
                    {
                        GameRoot.instance.AddTips("超出攻击范围");
                    }
                }
            }
        }
        else if (caster.entityType == EntityType.Monster)//如果是怪物只能攻击玩家
        {
            EntityPlayer target = caster.battleMg.entitySelfPlayer;

            //判断距离角度
            //范围技能(黑气)则施法者位置变更为玩家当前所处位置,提前取得
            if (skillCfg.dmgType == DamageType.AreaSkill)
            {
                if (blackAirPos == null || target == null)
                {
                    return;
                }
                if (InRange(blackAirPos, target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
            else
            {
                if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
    }