public GameService(int mapSizeX, int mapSizeY, string playerName)//char[,] initialMap) { this.playerName = playerName; Random r = RandomNumberGenerator.GlobalRandom; Generator = new MapGenerator(mapSizeX, mapSizeY); Creatures = new List<Creature>(); Player = new Creature(40) { CreatureType = "Hero", MeleeWeapon = new MeleeWeapon(){Damage=3, BrokeChance=0.001}, RangedWeapon = new RangedWeapon(){Damage=2, Range=3, Chance=0.5, Ammo=15}, GrenadeWeapon = new GrenadeWeapon{Damage=5, Range=5, Spread=2, Ammo=2} }; Player.MianownikName = "Gracz"; Player.BiernikName = "gracza"; Map = Generator.GenerateMap(Player);// new Map(initialMap); CreatureVisitor.map = Map; Creatures.AddRange(Generator.GeneratedCreatures); bool playerPlaced = false; while (playerPlaced == false) { playerPlaced = Map[r.Next(Map.MapWidth), r.Next(Map.MapHeight)].putCreature(Player); } }
public void MapGeneratedTest() { // arrange int mapSizeX = 30; int mapSizeY = 40; MapGenerator Generator = new MapGenerator(mapSizeX, mapSizeY); // act map = Generator.GenerateMap(player); // assert Assert.AreEqual(mapSizeX, map.MapWidth); Assert.AreEqual(mapSizeY, map.MapHeight); }
static void Main(string[] args) { int seed = (int)DateTime.UtcNow.Ticks; Random = new DotNetRandom(seed); string fontFileName = "terminal8x8.png"; string consoleTitle = $"RogueSharp - Level 1 - Seed: {seed}"; _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle); _mapConsole = new RLConsole(_mapWidth, _mapHeight); _messageConsole = new RLConsole(_messageWidth, _messageHeight); _statConsole = new RLConsole(_statWidth, _statHeight); _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight); SchedulingSystem = new SchedulingSystem(); //Player = new Player(); MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7); DungeonMap = mapGenerator.CreateMap(); DungeonMap.UpdatePlayerFieldOfView(); CommandSystem = new CommandSystem(); MessageLog = new MessageLog(); MessageLog.Add("The rogue arrives at level 1"); MessageLog.Add($"Dungeon generated with seed: {seed}"); // Only Run This Block Once... For now _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood); _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading); // Resume regular operation _rootConsole.Update += OnRootConsoleUpdate; _rootConsole.Render += OnRootConsoleRender; _rootConsole.Run(); }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (CommandSystem.IsPlayerTurn) { if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Direction.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Direction.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Direction.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Direction.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } else if (keyPress.Key == RLKey.Period) { if (DungeonMap.CanMoveDownToNextLevel()) { MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, ++_mapLevel); DungeonMap = mapGenerator.CreateMap(); MessageLog = new MessageLog(); CommandSystem = new CommandSystem(); _rootConsole.Title = $"RougeSharp RLNet Tutorial - Level {_mapLevel}"; didPlayerAct = true; } } } if (didPlayerAct) { _renderRequired = true; CommandSystem.EndPlayerTurn(); } } else { CommandSystem.ActivateMonsters(); _renderRequired = true; } //Set background color andd text for our consoles //this is temporary, btw _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground); _mapConsole.Print(1, 1, "Map", Colors.TextHeading); _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood); _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading); }