예제 #1
0
        // Finds all the spots for the ai given the event
        public int[] findAISpot(int x, int y, int[] range, FoundAITileEvent tileEvent)
        {
            // Variables
            int[]	spot=	new int[]	{ x, y };

            try
            {
                p_findAISpot(x, y, 0, ref x, ref y, ref range, ref tileEvent, ref spot, getTeamID(x, y));
            }catch{}

            return spot;
        }
예제 #2
0
        // Finds all the spots for the ai given the event
        private void p_findAISpot(int x, int y, int radius, ref int sx, ref int sy, ref int[] range, ref FoundAITileEvent tileEvent, ref int[] spot, int teamID)
        {
            if(aispot_canStopSearch(ref x, ref y, ref radius, ref teamID))
                return;

            if(tileEvent(range, radius, ref tiles.items[x, y], x, y, ref tiles.items[sx, sy], spot))
            {
                if((x== sx && x== sy) || !tiles.items[x, y].item.hasUnit)
                {
                    spot[0]=	x;
                    spot[1]=	y;
                    throw new Exception();
                }
            }

            p_findAISpot(x, y+1, radius+1, ref sx, ref sy, ref range, ref tileEvent, ref spot, teamID);
            p_findAISpot(x+1, y, radius+1, ref sx, ref sy, ref range, ref tileEvent, ref spot, teamID);
            p_findAISpot(x, y-1, radius+1, ref sx, ref sy, ref range, ref tileEvent, ref spot, teamID);
            p_findAISpot(x-1, y, radius+1, ref sx, ref sy, ref range, ref tileEvent, ref spot, teamID);
        }