Ejemplo n.º 1
0
        private void PopulateMap()
        {
            int                   minp = 10, maxp = 20;
            Factory <INPC>        enfac = SuperFactory.GetFactory <INPC>();
            Factory <Collectible> clfac = SuperFactory.GetFactory <Collectible>();
            var                   coord = NPCCoordinator.GetInstance();

            coord.Reset();
            for (int i = 0; i < noenemies; i++)
            {
                var e = enfac.CreateNew((byte)ran.Next(0, enfac.AvailableTypes), Vector3.Zero, coord.GenerateRandomPath(ran.Next(minp, maxp)));
                coord.Register(e);
                world.Add(e);
            }
            float offset = -Map.Celld / 4;

            byte[,] used = new byte[cellspr, cellspr];
            for (int i = 0; i < nocol; i++)
            {
                int   x    = ran.Next(0, cellspr);
                int   z    = ran.Next(0, cellspr);
                int   yoff = used[x, z];
                float fx   = x * Map.Celld + offset;
                float fz   = z * Map.Celld + offset;
                var   c    = clfac.CreateNew((byte)ran.Next(0, clfac.AvailableTypes), new Vector3(fx, yoff, fz));
                used[x, z] += (byte)(c.HighAnchor.Y - c.LowAnchor.Y);
                world.Add(c);
                // Place mine
                x    = ran.Next(0, cellspr);
                z    = ran.Next(0, cellspr);
                yoff = used[x, z];
                if (yoff == 0)
                {
                    fx = x * Map.Celld + offset;
                    fz = z * Map.Celld + offset;
                    world.Add(new LandMine(new Vector3(fx, 0, fz)));
                }
            }
        }
Ejemplo n.º 2
0
        public void BuildMaze()
        {
            World       world       = World.GetInstance();
            int         cellspr     = walls.GetLength(1) - 1;
            int         cellspc     = walls.GetLength(2) - 1;
            WallFactory wallfactory = (WallFactory)SuperFactory.GetFactory <Wall>();

            for (short x = 0; x < Walls.GetLength(1); x++)
            {
                for (short z = 0; z < walls.GetLength(2); z++)
                {
                    if (x < cellspr && walls[0, x, z] < 0xFF)
                    {
                        world.Add(wallfactory.CreateNew(walls[0, x, z], new Vector3(x * Celld - Wall.WallLowAnchor.Z, 0, z * Celld - Wall.WallLowAnchor.X), 1));
                    }
                    if (z < cellspc && walls[1, x, z] < 0xFF)
                    {
                        world.Add(wallfactory.CreateNew(walls[1, x, z], new Vector3(x * Celld - Wall.WallLowAnchor.X, 0, z * Celld - Wall.WallLowAnchor.Z), 0));
                    }
                }
            }
        }