示例#1
0
        static void placeActors()
        {
            int plx, ply;

            plx = player.CoordX;
            ply = player.CoordY;
            int x, y;

            for (int i = 0; i < 7; i++)
            {
                do
                {
                    x = MyRandom.getRandomInt(mapWidth);
                    y = MyRandom.getRandomInt(mapHeight);
                    if (map[x, y].IsPassable && !WorldLOS.VisibleLineExist(x, y, plx, ply))
                    {
                        AllActors.Add(UnitCreator.createActor("Guard", x, y));
                    }
                } while (!map[x, y].IsPassable);
            }
            for (int i = 0; i < 3; i++)
            {
                do
                {
                    x = MyRandom.getRandomInt(mapWidth);
                    y = MyRandom.getRandomInt(mapHeight);
                    if (map[x, y].IsPassable && !WorldLOS.VisibleLineExist(x, y, plx, ply))
                    {
                        AllActors.Add(UnitCreator.createActor("Officer", x, y));
                    }
                } while (!map[x, y].IsPassable);
            }
        }
示例#2
0
 public World()
 {
     makeMap();
     _DEBUG.AddDebugMessage("Map generation... ok");
     //find an entrance and place player
     for (int i = 0; i < mapWidth; i++)
     {
         for (int j = 0; j < mapHeight; j++)
         {
             if (map[i, j].IsUpstair)
             {
                 player = UnitCreator.createPlayer(i, j);
             }
         }
     }
     //place enemies
     placeActors();
     _DEBUG.AddDebugMessage("Actors placement... ok");
     _DEBUG.AddDebugMessage("All systems nominal... for now");
     _DEBUG.AddDebugMessage("Seed for this world is " + MyRandom.Seed.ToString());
     Log.AddLine("Press F1 for list of game commands");
 }