コード例 #1
0
    public List <Life> GetBuildSkillTarget(Life target)
    {
        List <Life> RoleList    = new List <Life>();
        List <Life> newRoleList = new List <Life>();

        CM.SearchLifeMList(ref RoleList, null, LifeMType.SOLDIER | LifeMType.SUMMONPET, LifeMCamp.ATTACK, m_Parent, (m_skill as BuildSkillInfo).m_dSearchInfo);

        if (RoleList.Count > 0)
        {
            CM.SearchAttackLifeMList(ref RoleList, target);
            int nRoleCnt      = 0;
            int nRoleMaxCount = m_skill.m_multiple;
            if (nRoleMaxCount == 0)
            {
                nRoleMaxCount = RoleList.Count;
            }
            for (int i = 0; i < RoleList.Count; i++)
            {
                if (RoleList[i] is  Role && !CheckCanAttack((RoleList[i]  as Role).CurrentAction))
                {
                }
                else
                {
                    newRoleList.Add(RoleList[i]);
                    nRoleCnt++;
                }
                if (nRoleCnt >= nRoleMaxCount)
                {
                    break;
                }
            }
        }
        CheckMultiple(ref newRoleList, m_skill);
        return(newRoleList);
    }
コード例 #2
0
ファイル: SkillAI.cs プロジェクト: 741645596/batgame
    private Life GetBestAttackTarget()
    {
        if (m_AttackList == null || m_AttackList.Count == 0)
        {
            return(null);
        }

        if (m_AttackList.Count == 1)
        {
            return(m_AttackList [0]);
        }


        Life        m = null;
        List <Life> l = new List <Life>();

        CM.SearchAttackLifeMList(ref m_AttackList, m_Parent);
        if (m_AttackList.Count > 0)
        {
            l = GetSkillTarget(m_AttackList, m_SkillInfo);
            if (l.Count == 1)
            {
                m = l[0];
            }
            if (m != null)
            {
                return(m);
            }
            if (l.Count > 1)
            {
                m_AttackList = l;
            }
            //目标一致优先

            /*m = GetAttack2Target();
            *  if(m != null) return m;
            *
            *  //目标一致优先
            *  m = GetAttackTargetLock();
            *  if(m != null) return m;*/
            //距离最近
            m = GetShortAttackTarget();
            if (m != null)
            {
                return(m);
            }
        }

        return(null);
    }
コード例 #3
0
ファイル: SkillAI.cs プロジェクト: 741645596/batgame
    private bool GetAttackList()
    {
        m_AttackList.Clear();
        int       distant = m_SkillInfo.m_distance / MapGrid.m_Pixel;
        LifeMCamp camp    = m_Parent.m_Core.m_Camp == LifeMCamp.ATTACK ? LifeMCamp.DEFENSE : LifeMCamp.ATTACK;

        if (m_SkillInfo.m_target == 4)
        {
            camp = m_Parent.m_Core.m_Camp;
        }
        if (m_SkillInfo.m_condition != (int)SkillCondition.HaveDoor)
        {
            if (m_SkillInfo.m_distance > 0)
            {
                if (m_Parent.Target != null && !m_Parent.Target.isDead)
                {
                    if (CheckAttackTarget(m_Parent.Target, m_SkillInfo.m_sort, distant))
                    {
                        m_AttackList.Add(m_Parent.Target);
                    }

                    /*else
                     * {
                     *  if (!m_Parent.run.CheckHaveIdleAttackPosInPath(m_Parent.SceneID))
                     *  {
                     *          //m_Parent.run.Pass = false;
                     *          int ldistant = m_SkillInfo.m_ldistance/MapGrid.m_Pixel;
                     *          if (CheckAttackTarget(m_Parent.Target,m_SkillInfo.m_sort,ldistant))
                     *                  m_AttackList.Add(m_Parent.Target);
                     *  }
                     *  else
                     *  {
                     *          //m_Parent.run.Pass = true;
                     *  }
                     * }*/
                }
            }
            else
            {
                List <Life> l = new List <Life>();
                ///需要排除隐形 。。。。。。。。。。。。。。。。。。
                CM.SearchLifeMListInBoat(ref l, LifeMType.SOLDIER, camp);
                foreach (Role r in l)
                {
                    if (m_Parent.m_Attr.IsHide && !m_IsBigSkill)
                    {
                        if (m_Parent.Target != null && !m_Parent.Target.isDead && CheckAttackTarget(m_Parent.Target, m_SkillInfo.m_sort, distant))
                        {
                            m_AttackList.Add(m_Parent.Target);
                        }
                    }
                    else if (!r.m_Attr.IsHide && CheckCanAttack(r.CurrentAction) && CheckAttackTarget(r, m_SkillInfo.m_sort, distant))
                    {
                        m_AttackList.Add(r);
                    }
                }

                /*List<Life> lp = new List<Life>();
                 * CM.SearchLifeMListInBoat(ref lp,LifeMType.PET, camp);
                 * foreach(Life p in lp)
                 * {
                 *
                 *      if (m_Parent.m_Attr.IsHide && !m_IsBigSkill)
                 *      {
                 *              if (m_Parent.Target != null && !m_Parent.Target.isDead && CheckAttackTarget(m_Parent.Target,m_SkillInfo.m_sort,distant))
                 *                      m_AttackList.Add(m_Parent.Target);
                 *      }
                 *      else if (CheckAttackTarget(p,1,distant) )
                 *              m_AttackList.Add(p);
                 * }*/
                //if (m_parent.m_Core.m_Camp == LifeMCamp.ATTACK)
                //{
                List <Life> lb = new List <Life>();
                CM.SearchLifeMListInBoat(ref lb, LifeMType.BUILD, camp);
                foreach (Building b in lb)
                {
                    if (m_Parent.m_Attr.IsHide && !m_IsBigSkill)
                    {
                        if (m_Parent.Target != null && !m_Parent.Target.isDead && CheckAttackTarget(m_Parent.Target, m_SkillInfo.m_sort, distant))
                        {
                            m_AttackList.Add(m_Parent.Target);
                        }
                    }
                    else if (b.m_Attr.IsDamage && CheckAttackTarget(b, 1, distant))
                    {
                        m_AttackList.Add(b);
                    }
                }
            }
        }
        List <Life> lw = new List <Life>();

        CM.SearchLifeMListInBoat(ref lw, LifeMType.WALL, camp);
        foreach (IggWall w in lw)
        {
            if (CheckAttackTarget(w, 1, distant) && !w.m_Attr.DoorState)
            {
                m_AttackList.Add(w);
            }
        }
        //}
        CM.SearchAttackLifeMList(ref m_AttackList, m_Parent);

        return(true);
    }