public void MapPlacementTest() { var room1 = RoomLoader.Load(@" +d++ ds.+ ++++".ToMemoryStream()); var room2 = RoomLoader.Load(@" ++++ +..d ++++".ToMemoryStream()); var map = new Map(10, 4); // place the rooms room2.Place(map, 0, 0); room1.Place(map, 4, 0); // test the placed rooms Assert.AreEqual(TileTemplate.WallTile, map.Tiles[0, 3]); Assert.AreEqual(TileTemplate.WallTile, map.Tiles[0, 4]); Assert.AreEqual(TileTemplate.DoorTile, map.Tiles[0, 5]); Assert.AreEqual(TileTemplate.DoorTile, map.Tiles[1, 3]); Assert.AreEqual(TileTemplate.DoorTile, map.Tiles[1, 4]); Assert.AreEqual(TileTemplate.EmptyTile, map.Tiles[1, 2]); Assert.AreEqual(TileTemplate.EmptyTile, map.Tiles[1, 1]); Assert.AreEqual(TileTemplate.EmptyTile, map.Tiles[1, 6]); Assert.AreEqual(TileTemplate.StartTile, map.Tiles[1, 5]); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.ClearColor(1, 1, 1, 1); FontDrawing = new QFontDrawing(); MainFont = new QFont("Tahoma", 16, new QFontBuilderConfiguration()); // load the rooms var rooms = Directory.GetFiles(@"Content\Rooms", "*.txt", SearchOption.AllDirectories) .Select(path => RoomLoader.Load(path)) .ToList(); var items = Directory.GetFiles(@"Content\Items", "*.txt", SearchOption.AllDirectories) .SelectMany(path => ItemLoader.Load(path).Select(w => w.itemtemplate)) .ToList(); // build the map const int mapw = 75, maph = 25; Map = new Map(mapw, maph, rooms, new Random()); // and the terrain renderer TerrainRenderer = new TerrainRenderer(Map) { ViewMatrix = Matrix4.CreateTranslation(2, 2, 0) * Matrix4.CreateScale(.1f) }; }
public void RoomLoadingTest() { var roomtemplate = RoomLoader.Load(@" ++d+ +..++++ d.....+ +.....d +++++++".ToMemoryStream()); // test the loaded room Assert.AreEqual(TileTemplate.WallTile, roomtemplate.Tiles[0, 0]); Assert.AreEqual(TileTemplate.WallTile, roomtemplate.Tiles[0, 1]); Assert.AreEqual(TileTemplate.DoorTile, roomtemplate.Tiles[0, 2]); Assert.AreEqual(TileTemplate.WallTile, roomtemplate.Tiles[0, 3]); Assert.AreEqual(TileTemplate.VoidTile, roomtemplate.Tiles[0, 4]); Assert.AreEqual(TileTemplate.VoidTile, roomtemplate.Tiles[0, 5]); Assert.AreEqual(TileTemplate.EmptyTile, roomtemplate.Tiles[3, 3]); Assert.AreEqual(TileTemplate.DoorTile, roomtemplate.Tiles[3, 6]); Assert.ThrowsException <IndexOutOfRangeException>(() => roomtemplate.Tiles[0, 7]); // test the doorways Assert.IsTrue(roomtemplate.Doorways.Any(d => d.X == 2 && d.Y == 0 && d.Direction == DoorwayDirection.North)); Assert.IsTrue(roomtemplate.Doorways.Any(d => d.X == 0 && d.Y == 2 && d.Direction == DoorwayDirection.West)); Assert.IsTrue(roomtemplate.Doorways.Any(d => d.X == 6 && d.Y == 3 && d.Direction == DoorwayDirection.East)); }
public void EnterRoom(int x, int y) { enemies.Clear(); exits.Clear(); currentLocation = new Vector2Int(x, y); mapDisplay.EnterRoom(x, y); roomLoader.Load(map[x, y]); }
public void RoomPropertiesTest() { var room = RoomLoader.Load(@" ++ ++ === choose_weight = 0.1 ".ToMemoryStream()); Assert.AreEqual(0.1f, room.ChooseWeight); }
void Instantiate(string path) { RoomLayout roomLayout = Resources.Load <RoomLayout>(path); if (roomLayout != null) { Room room = new Room(0, 0); room.layout = roomLayout.entities; room.size = roomLayout.size; RoomLoader roomLoader = GameObject.Find("Room Spawn").GetComponent <RoomLoader>(); roomLoader.DestroyRoom(); roomLoader.Load(room); } }
static void Main(string[] args) { var rooms = Directory.GetFiles(@"Content\Rooms", "*.txt", SearchOption.AllDirectories) .Select(path => RoomLoader.Load(path)) .ToList(); var items = Directory.GetFiles(@"Content\Items", "*.txt", SearchOption.AllDirectories) .SelectMany(path => ItemLoader.Load(path).Select(w => w.itemtemplate)) .ToList(); const int mapw = 75, maph = 25; var map = new Map(mapw, maph, rooms, new Random()); for (var row = 0; row < maph; ++row) { Console.Write('/'); for (var col = 0; col < mapw; ++col) { var tile = map.Tiles[row, col]; if (tile == TileTemplate.DoorTile) { Console.Write('d'); } else if (tile == TileTemplate.WallTile) { Console.Write('+'); } else if (tile == TileTemplate.StartTile) { Console.Write('s'); } else if (tile == TileTemplate.EmptyTile) { Console.Write('.'); } else if (tile == TileTemplate.VoidTile) { Console.Write(' '); } else { throw new InvalidOperationException(); } } Console.WriteLine('/'); } Console.ReadKey(); }
public void LoadRoom(int roomNum) { String name = "Room" + roomNum; //test if room is already loaded if (rooms.ContainsKey(name)) { ChangeRoom(roomNum); } else { //load room if it hasn't been loaded then change room rooms.Add(name, roomLoad.Load(name + ".txt")); ChangeRoom(roomNum); } }
public void LoadRoom(int roomNum) { String name = "Room" + roomNum; if (rooms.ContainsKey(name)) { //roomKey = name; ChangeRoom(roomNum); } else { rooms.Add(name, roomLoad.Load(name + ".txt")); //roomKey = name; ChangeRoom(roomNum); } player.X = 400; player.Y = 324; }
public void MapGenerationTest() { var room1 = RoomLoader.Load(@" +d++ ds.+ ++++".ToMemoryStream()); var room2 = RoomLoader.Load(@" ++++ +..d ++++".ToMemoryStream()); var room3 = RoomLoader.Load(@" ++++ +..+ +d++".ToMemoryStream()); var room4 = RoomLoader.Load(@" +++++ +...d +++d+".ToMemoryStream()); var map = new Map(30, 30, new List <RoomTemplate> { room1, room2, room3, room4 }, new Random()); }
public GameManager(Game1 game, Dictionary <String, Texture2D> spriteSheet, SpriteFont font, SpriteFont header, Sounds sounds) { this.game = game; sprites = spriteSheet; state = GameState.PLAYING; //load room 17 first sound = sounds; roomLoad = new RoomLoader(sprites); rooms.Add("Room17", roomLoad.Load("Room17.txt")); roomKey = "Room17"; player = new Player(spriteSheet["playersheet"], new Vector2(500, 200), spriteSheet["PlayerProjectiles"], sound); hud = new HUD(spriteSheet["hudSheet"], font); itemScreen = new ItemSelectionScreen(spriteSheet["ItemSelection"]); pause = new PauseScreen(spriteSheet["MenuScreens"], font, header); gameOver = new GameOverScreen(spriteSheet["MenuScreens"], font, header); win = new WinScreen(spriteSheet["MenuScreens"]); EPCol = new EnemyProjectileCollisionHandler(this); }
public GameManager(Game1 game, Dictionary <String, Texture2D> spriteSheet, SpriteFont font, SpriteFont header, Sounds sounds) { GameplayConstants.Initialize(1);//initialize constants to normal mode, just at the start so constants are somehting this.game = game; sprites = spriteSheet; state = GameState.START; difficulty = 1; isHordeMode = false; //load room 17 first sound = sounds; roomLoad = new RoomLoader(sprites, this); rooms.Add("Room17", roomLoad.Load("Room17.txt")); roomKey = "Room17"; transitioner = new RoomTransition(); //initialize player player = new Player(spriteSheet["playersheet"], new Vector2(500, 200), spriteSheet["PlayerProjectiles"], sound); //initailize screens hud = new HUD(spriteSheet["hudSheet"], font); itemScreen = new ItemSelectionScreen(spriteSheet["ItemSelection"]); pause = new PauseScreen(spriteSheet["MenuScreens"], font, header); gameOver = new GameOverScreen(spriteSheet["MenuScreens"], font, header); win = new WinScreen(spriteSheet["MenuScreens"]); start = new StartMenuScreen(spriteSheet["StartMenu"], font, header, this); EPCol = new EnemyProjectileCollisionHandler(this); //initailize cheat code dictionary cheatCodes = new Dictionary <string, ICommand>(); //initailize cheat codes ICommand extraHealth = new ExtraHealth(player); ICommand extraRupees = new ExtraRupees(player); ICommand invinc = new Invincibility(player); ICommand bombs = new UnlimitedBombs(player); cheatCodes.Add("NBKJH", extraHealth); cheatCodes.Add("MNBVX", extraRupees); cheatCodes.Add("ZZKNL", invinc); cheatCodes.Add("GFGFG", bombs); //initailize special move code dictionary specialMoves = new Dictionary <string, ICommand>(); //initailize special moves ICommand fireSpin = new FireSpinSpecialMove(this); ICommand reapingArrow = new ReapingArrowSpecialMove(this); ICommand rupeeShied = new RupeeShieldSpecialMove(this); specialMoves.Add("TYHGT", fireSpin); specialMoves.Add("JKJKJ", reapingArrow); specialMoves.Add("KJHGF", rupeeShied); }