static int getTargetType(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        Games.Module.Wars.SkillWarConf obj = (Games.Module.Wars.SkillWarConf)LuaScriptMgr.GetNetObjectSelf(L, 1, "Games.Module.Wars.SkillWarConf");
        int o = obj.getTargetType();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Exemple #2
0
        bool AIUse_SelectUnit(SkillOperateData skillData)
        {
            skillData.receiveList.Clear();

            List <UnitCtl> buildList = War.scene.buildList;
            //ai目标
            SkillWarConf skillWarConf = War.model.GetSkillWarConf(skillData.skillId);

            if (skillWarConf.getTargetType() == (int)eSkillWarTargetType.eEffectTargetBuildBeHitMinHp)//正在被攻击&人口最少,没有被攻击则选人口最少的
            {
                int unitType = 0;
                unitType = unitType.UBuild(true);
                int relation = 0;
                relation = relation.ROwn(true);
                List <UnitCtl> listTmp = War.scene.SearchUnit(unitType, legionData.legionId, relation);
                foreach (UnitCtl unit in listTmp)
                {
                    if (unit.unitData.behit == true)
                    {
                        skillData.receiveList.Add(unit);
                        return(true);
                    }
                }
                //没有正在被攻击的城池,选择人口钌俚锰
                UnitCtl unitMin = null;
                float   hpTmp   = 10000.0f;
                foreach (UnitCtl unit in listTmp)
                {
                    if (unit.hp <= hpTmp)
                    {
                        hpTmp   = unit.hp;
                        unitMin = unit;
                    }
                }
                if (unitMin != null)
                {
                    if (skillData.EnableUse(unitMin))
                    {
                        skillData.receiveList.Add(unitMin);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            List <UnitCtl> candidatesList = new List <UnitCtl> ();

            foreach (UnitCtl entity in buildList)
            {
                if (skillData.EnableUse(entity))
                {
                    candidatesList.Add(entity);
                }
            }

            UnitCtl select = null;

            foreach (UnitCtl entity in candidatesList)
            {
                select = entity;
                if (select.legionData.type != LegionType.Neutral)
                {
                    break;
                }
            }

            if (select != null)
            {
                skillData.receiveList.Add(select);
                return(true);
            }

            return(false);
        }