예제 #1
0
        int tileSize; /**< Size of single tile */

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="WS">Reference to World Screen</param>
        /// <param name="tileSize">Size of single tile</param>
        /// <param name="size">Size of map</param>
        public Map(WorldScreen WS, int tileSize, int size)
        {
            this.tileSize = tileSize;
            this.size = size;

            this.Entities = new List<Entity>();

            PhysicalWorld = new World(new Vector2(0, 0));

            Player = new Player(new Rectangle(6 * 64, 6 * 64, 64, 64), this);
            AddEntity(Player);

            chunk = new Chunk(new Rectangle(0, 0, size * tileSize, size * tileSize), this, tileSize);
            Parent = WS;

            pfinder = new PathFinderFast(GetChunk().GetCostArray());

            for (int i = 0; i < 25; i++)
            {
                Rectangle r = new Rectangle((int)Helper.GetRandomTo(size * tileSize), (int)Helper.GetRandomTo(size * tileSize), 64, 64);
                Rectangle t = new Rectangle(r.X / tileSize, r.Y / tileSize, tileSize, tileSize);

                while (chunk.tiles[t.X,t.Y].isSolid)
                {
                    r = new Rectangle((int)Helper.GetRandomTo(size * tileSize), (int)Helper.GetRandomTo(size * tileSize), 64, 64);
                    t = new Rectangle(r.X / tileSize, r.Y / tileSize, tileSize, tileSize);
                }
                new ZombieBig(r, this);
            }

            new Barrel(new Rectangle(Player.Position.X + 64, Player.Position.Y + 64, 32, 32), this);
            new FloorFan(new Rectangle(Player.Position.X + 64, Player.Position.Y + 64, 128, 128), this);
            //chunk.Save("Content/Chunks/00.xml");
        }
예제 #2
0
        /// <summary>
        /// Overrided method to Generate empty Map
        /// </summary>
        /// <param name="Chunk">Chunk to generate in</param>
        public override void Generate(Chunk Chunk)
        {
            for (int y = 0; y < Chunk.position.Height / Chunk.tileSize; y++)
            {
                for (int x = 0; x < Chunk.position.Width / Chunk.tileSize; x++)
                {
                    Chunk.SetTile(x, y, new Tile(new Rectangle(Chunk.position.X + x * Chunk.tileSize, Chunk.position.Y + y * Chunk.tileSize, Chunk.tileSize, Chunk.tileSize), "dungFloor", 30));
                }
            }

            for (int x = 2; x <= 10; x++)
            {
                Chunk.SetTile(x, 2, new Tile(new Rectangle(Chunk.position.X + x * Chunk.tileSize, Chunk.position.Y + 2 * Chunk.tileSize, Chunk.tileSize, Chunk.tileSize), "dungWall", 0));
                Chunk.SetTile(x, 10, new Tile(new Rectangle(Chunk.position.X + x * Chunk.tileSize, Chunk.position.Y + 10 * Chunk.tileSize, Chunk.tileSize, Chunk.tileSize), "dungWall", 0));
            }

            for (int y = 2; y <= 10; y++)
            {
                Chunk.SetTile(2, y, new Tile(new Rectangle(Chunk.position.X + 2 * Chunk.tileSize, Chunk.position.Y + y * Chunk.tileSize, Chunk.tileSize, Chunk.tileSize), "dungWall", 0));
                Chunk.SetTile(10, y, new Tile(new Rectangle(Chunk.position.X + 10 * Chunk.tileSize, Chunk.position.Y + y * Chunk.tileSize, Chunk.tileSize, Chunk.tileSize), "dungWall", 0));
            }
        }
예제 #3
0
        void ConvertDungeon(Chunk C)
        {
            for (int y = 0; y < ymax; y++)
               {
               for (int x = 0; x < xmax; x++)
               {
                   switch (GetCellType(x, y))
                   {
                       case Tile.Corridor:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungFloor", 30));
                           break;
                       case Tile.DirtFloor:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungFloor", 30));
                           break;
                       case Tile.DirtWall:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungWall", 0));
                           break;
                       case Tile.StoneWall:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungWall", 0));
                           break;
                       case Tile.Unused:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungWall", 0));
                           break;
                       case Tile.Upstairs:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungFloor", 30));
                           C.map.Player.Position = new Rectangle(x * C.tileSize, y * C.tileSize,C.tileSize,C.tileSize);
                           break;
                       default:
                           C.SetTile(x, y, new MapManager.Tile(new Rectangle(C.position.X + x * C.tileSize, C.position.Y + y * C.tileSize, C.tileSize, C.tileSize), "dungFloor", 30));
                           break;

                   }
               }
               }
        }
예제 #4
0
        public override void Generate(Chunk Chunk)
        {
            this.Chunk = Chunk;
               xmax = (int)Chunk.Size.X;
               ymax = (int)Chunk.Size.Y;

               LightList = new List<Vector2>();
               AlarmLights = new List<KeyValuePair<Vector2, Direction>>();

               CreateDungeon((int)Chunk.Size.X, (int)Chunk.Size.Y, 100);
               ConvertDungeon(Chunk);

               LightingEngine LE = (LightingEngine)Renderer.GetRenderEffect("LightingEngine");
               foreach (Vector2 V in LightList)
               {
               PointLight L = new PointLight()
               {
                   IsEnabled = true,
                   Color = new Vector4(0.9f, .2f, .2f, 1f),
                   Power = .85f,
                   LightDecay = 300,
                   Position = new Vector3(V.X * Chunk.tileSize, V.Y * Chunk.tileSize, 1),
               };

               LE.AddLight(L);
               }

               foreach (KeyValuePair<Vector2, Direction> Alarm in AlarmLights)
               {
               switch (Alarm.Value)
               {
                   case Direction.North:
                       for (int i = -2; i <= 2; i++)
                       {
                           if (!(GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.Corridor) ||
                               (GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y - 1) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y - 1) == Tile.Corridor))
                           {
                               break;
                           }
                       }

                       new RedAlarmLamp(new Rectangle((int)Alarm.Key.X * 64 + 32, (int)Alarm.Key.Y * 64 + 4, 16,8), Chunk.map);

                       break;
                   case Direction.South:

                       for (int i = -2; i <= 2; i++)
                       {
                           if (!(GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y + 1) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y + 1) == Tile.Corridor) ||
                               (GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y ) == Tile.Corridor))
                           {
                               break;
                           }
                       }

                       RedAlarmLamp tmp = new RedAlarmLamp(new Rectangle((int)Alarm.Key.X * 64 + 32, (int)Alarm.Key.Y * 64 + 60, 16,8), Chunk.map);
                       tmp.Fixture.Body.Rotation = (float)Math.PI;

                       break;
                   case Direction.East:

                       break;
                   case Direction.West:

                       break;
               }
               }
        }
예제 #5
0
 /// <summary>
 /// Abstract class for Generating
 /// </summary>
 /// <param name="Chunk">Chunk to generate in</param>
 public abstract void Generate(Chunk Chunk);