private void InitializeGameTiles() { List<Tile> orbsToSet = new List<Tile>(); Inventory lastInventory = new Inventory(this); if (Reset == false) { lastInventory = Player.Inventory; } Terrain terrain = TerrainManager.NewTerrain(SizeX, SizeY); terrain.GetRandomTile(Tile.TileType.TileFloor).Type = Tile.TileType.TileStart; terrain.GetRandomTile(Tile.TileType.TileFloor).Type = Tile.TileType.TileEnd; int playerX = 0; int playerY = 0; foreach (Tile tempTile in terrain.Tiles) { switch (tempTile.Type) { case Tile.TileType.TileFloor: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); break; case Tile.TileType.TileTrapdoor: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityTrapdoor(this); break; case Tile.TileType.TilePit: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityPit(this); break; case Tile.TileType.TileWall: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityWall(this); break; case Tile.TileType.TileBrokenwall: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityBrokenWall(this); break; case Tile.TileType.TileShop: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityShop(this); break; case Tile.TileType.TileRoach: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityRoach(this); break; case Tile.TileType.TileRoachqueen: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); if (tempTile.Flags.Contains("spawns roach queens")) { EntityManager[tempTile.X, tempTile.Y, 0] = new EntityRoachQueen(this, ESpawnable.EsRoachQueen); } else { EntityManager[tempTile.X, tempTile.Y, 0] = new EntityRoachQueen(this); } break; case Tile.TileType.TileEvileye: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityEvilEye(this); break; case Tile.TileType.TileEvileyesentry: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityEvilEyeSentry(this); break; case Tile.TileType.TileGelbaby: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityGelBaby(this); break; case Tile.TileType.TileWraithwing: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityWraithwing(this); break; case Tile.TileType.TileZombie: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityZombie(this); break; case Tile.TileType.TileBrainYellow: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); EntityManager[tempTile.X, tempTile.Y, 0] = new EntityBrainYellow(this); break; case Tile.TileType.TileStart: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityFloor(this); playerX = tempTile.X; playerY = tempTile.Y; break; case Tile.TileType.TileEnd: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityExit(this); break; case Tile.TileType.TileClosedDoor: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityClosedDoor(this); break; case Tile.TileType.TileOrb: EntityManager[tempTile.X, tempTile.Y, 2] = new EntityPressurePlate(this); orbsToSet.Add(tempTile); break; } if (tempTile.Flags.Contains("orthosquare")) EntityManager[tempTile.X, tempTile.Y, 1] = new EntityOrthoSquare(this); } EntityManager[playerX, playerY, 0] = new EntityPlayer(this) {PreviousX = playerX, PreviousY = playerY}; for (int iY = -3; iY < 4; iY++) { for (int iX = -3; iX < 4; iX++) { if (EntityManager.IsOutOfBoundaries(playerX + iX, playerY + iY)) continue; if ((EntityManager[playerX + iX, playerY + iY, 0] is EntityPlayer) || (EntityManager[playerX + iX, playerY + iY, 0] is EntitySword)) continue; EntityManager[playerX + iX, playerY + iY, 0] = new EntityNull(this); if (((iX != -3 && iX != 3) && iY != -3) && iY != 3) continue; if (EntityManager[playerX + iX, playerY + iY, 2] is EntityFloor) { EntityManager[playerX + iX, playerY + iY, 2] = new EntityBrokenWall(this); } } } Player = (EntityPlayer) EntityManager[playerX, playerY, 0]; List<int> dir = Helper.DirectionToInt(Player.Direction); EntitySword s = new EntitySword(this, Player); EntityManager[Player.X + dir[0], Player.Y + dir[1], Player.Z] = s; Player.Sword = (EntitySword)EntityManager[Player.X + dir[0], Player.Y + dir[1], Player.Z]; Player.Name = Helper.INIParser.GetSetting("Game", "PlayerName"); for (int iY = 0; iY < EntityManager.SizeY; iY++) { for (int iX = 0; iX < EntityManager.SizeX; iX++) { if (EntityManager[iX, iY, 0] is IEiKillable && !(EntityManager[iX, iY, 0] is IEiIgnoreEnemyCount)) EnemyCountStart++; if (!(EntityManager[iX, iY, 2] is EntityExit)) continue; List<Entity> adjacents = EntityManager[iX, iY, 2].GetAdjacentEntities(2); foreach (Entity e in adjacents) { if(!(e is IEiWalkableUpon) && !(e is IEiDoor)) EntityManager[e.X, e.Y, 2] = new EntityFloor(this); } } } EnemyCount = EnemyCountStart; if (Reset) { ResetInventory(); Reset = false; } else { Player.Inventory = lastInventory; } foreach (Tile t in orbsToSet) { EntityPressurePlate pressurePlate = (EntityPressurePlate) EntityManager[t.X, t.Y, 2]; IEiDoor ecd = (IEiDoor)EntityManager[t.OrbFlagX, t.OrbFlagY, 2]; pressurePlate.DoorX = ecd.X; pressurePlate.DoorY = ecd.Y; } SFMLGame.SpawnParticles(Player.X * SFMLGame.TileSize + 7, Player.Y * SFMLGame.TileSize + 7, Resources.ParticleGel, 60); SFMLGame.SpawnParticles(Player.X * SFMLGame.TileSize + 7, Player.Y * SFMLGame.TileSize + 7, Resources.ParticleBomb, 60); }
private void InitializeClearEntities() { SFMLGame.Particles.Clear (); for (int iZ = 0; iZ < 3; iZ++) { for (int iY = 0; iY < EntityManager.SizeY; iY++) { for (int iX = 0; iX < EntityManager.SizeX; iX++) { EntityManager[iX, iY, iZ] = new EntityNull(this); } } } }