Ejemplo n.º 1
0
 public Room(Tile[,] t, int xOffset, int yOffset)
 {
     xPos = xOffset;
     yPos = yOffset;
     tiles = new Tile[TILEW, TILEH];
     for (int x = 0; x < TILEW; x++)
     {
         for (int y = 0; y < TILEH; y++)
         {
             TileType f = t[x, y].Type;
             tiles[x, y] = new Tile((xOffset * 800) + x * 53, (yOffset * 480) + y * 53, t[x, y].Type);
         }
     }
 }
Ejemplo n.º 2
0
        public void AddDoor(string dir)
        {
            //top, bottom, left, right
            int x = 0, y = 0;
            switch (dir)
            {
                case "top":
                    x = TILEW / 2;
                    y = 0;
                    break;
                case "bottom":
                    x = TILEW / 2;
                    y = TILEH - 1;
                    break;
                case "left":
                    x = 0;
                    y = TILEH / 2;
                    break;
                case "right":
                    x = TILEW - 1;
                    y = TILEH / 2;
                    break;
            }

            tiles[x, y] = new Tile(tiles[x, y].Rect.X, tiles[x, y].Rect.Y, TileType.door);
        }
Ejemplo n.º 3
0
        public void LoadTiles()
        {
            for (int i = 0; i <= LAYOUTS; i++)
            {
                List<Enemy> enemies = new List<Enemy>();
                StreamReader sr = new StreamReader(TitleContainer.OpenStream("Content\\Tilesets\\1\\"+ i +".txt"));
                Tile[,] tempTiles = new Tile[TILEW, TILEH];
                string line = "";
                int heightIndex = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    for (int x = 0; x < line.Length; x++)
                    {
                        Tile tile = null;
                        if (line[x] == '|' || line[x] == '?')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.solid);
                        }
                        else if (line[x] == '-')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                        }
                        else if (line[x] == '#' || line[x] == '@')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.rock);
                        }
                        else if (line[x] == 'a')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new Fly(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'b')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new AggressiveFly(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'c')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new DoubleFly(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'd')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new ShootingFly(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'e')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new FireFly(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'f')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new Horf(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'g')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            //manager.ActorManager.Add(new FireFly(new Vector2((x * 53) + (TILEW / 2), (heightIndex * 53) + (TILEW / 2)),
                            //   manager));
                        }
                        else if (line[x] == 'h')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new HeadlessZombie(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'i')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new Jumper(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'j')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            //manager.ActorManager.Add(new FireFly(new Vector2((x * 53) + (TILEW / 2), (heightIndex * 53) + (TILEW / 2)),
                            //    manager));
                        }
                        else if (line[x] == 'k')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new Clotty(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT)),
                                manager));
                        }
                        else if (line[x] == 'l')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            enemies.Add(new Gish(new Vector2((x * Tile.WIDTH) + (Tile.WIDTH / 2), ((heightIndex + 1) * Tile.HEIGHT) ),
                                manager));
                        }
                        else if (line[x] == 'm')
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                            //enemies.Add(new FireFly(new Vector2((x * 53) + (TILEW / 2), (heightIndex * 53) + (TILEW / 2)),
                            //    manager));
                        }
                        else
                        {
                            tile = new Tile(x * Tile.WIDTH, heightIndex * Tile.HEIGHT, TileType.background);
                        }

                        tempTiles[x, heightIndex] = tile;
                    }
                    heightIndex++;
                }

                enemyConfigs.Add(enemies);
                tilesets.Add(tempTiles);
            }
        }