コード例 #1
0
ファイル: Profession.cs プロジェクト: pgonzbecer/Conquest
        // Gets the target
        public virtual void ai_getTarget(Unit unit, BattleMap map, bool isUncontrollable, out int[] target, out int[] spotToMoveTo, out AttackInfo info)
        {
            info=	new AttackInfo();
            info.range=	new int[] {1, 1};

            map.aiSearch(unit.mapPos[0], unit.mapPos[1], unit.move, info.range[1], isUncontrollable, map.getTeamID(unit.mapPos), info);

            spotToMoveTo=	map.findAISpot(unit.mapPos[0], unit.mapPos[1], info.range, map.aggressiveAI);
            target=	map.tiles.items[spotToMoveTo[0], spotToMoveTo[1]].t;
            info=	AttackInfo.createBasicAttack(map.getFullUnitID(unit.mapPos), target, ref map);
        }
コード例 #2
0
ファイル: Profession.cs プロジェクト: pgonzbecer/Conquest
        // Updates the ai normally
        public virtual void updateAINormal(Unit unit, BattleMap map)
        {
            // Variables
            int[]	spot;
            int[]	target=	map.getClosestEnemy(unit.mapPos[0], unit.mapPos[1], map.getTeamID(unit.mapPos));
            AttackInfo	info=	AttackInfo.createBasicAttack(map.getFullUnitID(unit.mapPos), target, ref map);
            int	heuristic;

            // Get Target
            info.range=	new int[] {1, 1};

            map.aiSearch(unit.mapPos[0], unit.mapPos[1], unit.move, info.range[1], false, map.getTeamID(unit.mapPos), info, target);

            spot=	map.findAISpot(unit.mapPos[0], unit.mapPos[1], info.range, map.aggressiveAI);

            if(!unit.isWalkingDone)
            {
                ai_moveUnit(unit, map, spot, false);

                map.destroyPaths();
                map.endUnitWalking(map.getFullUnitID(unit.mapPos));

                if(unit.isTurnEnded)
                    return;
            }

            heuristic=	map.getHeuristic(unit.mapPos, map.getUnitXY(target));

            if(!unit.isAttackingDone && heuristic>= info.range[0] && heuristic<= info.range[1])
            {
                ai_attackUnit(unit, map, info, false);

                map.destroyPaths();
                map.endUnitAttacking(map.getFullUnitID(unit.mapPos));

                if(unit.isTurnEnded)
                    return;
            }
        }