public void SelectTarget(Point target)
        {
            DungeonMap map     = RogueGame.DungeonMap;
            Player     player  = RogueGame.Player;
            Monster    monster = map.GetMonsterAt(target.X, target.Y);

            if (monster != null)
            {
                RogueGame.MessageLog.Add($"{player.Name} casts a {Name} at {monster.Name}");
                Actor magicMissleActor = new Actor
                {
                    Attack = _attack, AttackChance = _attackChance, Name = Name
                };
                RogueGame.CommandSystem.Attack(magicMissleActor, monster);
            }
        }
Exemplo n.º 2
0
 public Player(DungeonMap map, Point location) : base(map, location)
 {
     try
     {
         StepCounter = Game.Player.StepCounter;
     }
     catch
     {
         StepCounter = 0;
     }
     Location = map.CurrentPlayerLocation;
     if (HasMultiKey)
     {
         this.MultiKey = Game.Player.MultiKey;
     }
 }
Exemplo n.º 3
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            RLConsole.Blit(_mapConsole, 0, 0, _mapWidth, _mapHeight, _rootConsole, 0, _inventoryHeight);
            RLConsole.Blit(_statConsole, 0, 0, _statWidth, _statHeight, _rootConsole, _mapWidth, 0);
            RLConsole.Blit(_inventoryConsole, 0, 0, _inventoryWidth, _inventoryHeight, _rootConsole, 0, 0);
            Player.Draw(_mapConsole, DungeonMap);

            _rootConsole.Draw();

            if (_renderRequired)
            {
                DungeonMap.Draw(_mapConsole, _statConsole);
                Player.Draw(_mapConsole, DungeonMap);
                Player.DrawStats(_statConsole);
            }
        }
Exemplo n.º 4
0
        public static void Main()
        {
            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";
            // The title will appear at the top of the console window
            string consoleTitle = "Hunter v0.0";


            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
                                             8, 8, 1f, consoleTitle);

            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole     = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole = new RLConsole(_messageWidth, _messageHeight);
            _statConsole    = new RLConsole(_statWidth, _statHeight);

            Player           = new Player();
            CommandSystem    = new CommandSystem();
            QuestMenu        = new QuestMenu(_menuWidth, _menuHeight);
            DeathScreen      = new DeathScreen(_menuWidth, _menuHeight);
            WinMenu          = new WinMenu(_menuWidth, _menuHeight);
            Menu             = new Menu(_menuWidth, _menuHeight);
            SchedulingSystem = new SchedulingSystem();

            // Create a new MessageLog and print the random seed used to generate the level
            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add("Prepare to fight for your life");

            //Generate the map
            TownMap mapCreation = new TownMap(_mapWidth, _mapHeight);

            //SimpleBsp mapCreation = new SimpleBsp(_mapWidth, _mapHeight);
            //FullRoomBsp mapCreation = new FullRoomBsp(_mapWidth, _mapHeight);

            DungeonMap = mapCreation.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();


            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;
            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;
            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemplo n.º 5
0
        public static void Main()
        {
            //Establish the seed for the random number generator from the current time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);
            // The title will appear at the top of the console window
            // also include the seed used to generate the level
            string fontFileName = "terminal8x8.png";
            string consoleTitle = $"RogueSharp V3 Tutorial - 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);

            CommandSystem = new CommandSystem();


            _rootConsole.Update += OnRootConsoleUpdate;

            _rootConsole.Render += OnRootConsoleRender;

            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Color.FloorBackground);
            _mapConsole.Print(1, 1, "", Color.TextHeading);

            //Create a new MessageLog and print the seed used to create the level
            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Pallette.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Color.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Pallette.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Color.TextHeading);

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7);

            DungeonMap = mapGenerator.CreateMap();

            DungeonMap.UpdatePlayerFieldOfView();

            _rootConsole.Run();
        }
Exemplo n.º 6
0
        protected override bool PerformAbility()
        {
            DungeonMap map    = Game.DungeonMap;
            Player     player = Game.Player;

            if (player.Mana < _manaCost)
            {
                Game.MessageLog.Add($"You don't have enough mana to use this skill", Swatch.DbBlood);

                return(false);
            }
            else
            {
                player.Mana -= _manaCost;
                Game.MessageLog.Add($"You perform a whirlwind attack against all enemies {_range} tile(s) away");
                List <Point> monsterLocations = new List <Point>();

                foreach (ICell cell in map.GetCellsInSquare(player.X, player.Y, _range))
                {
                    foreach (Point monsterLocation in map.GetMonsterLocations())
                    {
                        if (cell.X == monsterLocation.X && cell.Y == monsterLocation.Y)
                        {
                            monsterLocations.Add(monsterLocation);
                        }
                    }
                }

                foreach (Point monsterLocation in monsterLocations)
                {
                    Monster monster = map.GetMonsterAt(monsterLocation.X, monsterLocation.Y);
                    if (monster != null)
                    {
                        Game.CommandSystem.Attack(player, monster);
                        if (Dice.Roll("1D100") < _poisonChance)
                        {
                            if (monster.IsPoisonedImmune == false && _poisonDamage != 0)
                            {
                                monster.State = new MonsterAbnormalState(monster, _poisonLength, "Poisoned", -2, -2, _poisonDamage);
                            }
                        }
                    }
                }

                return(true);
            }
        }
Exemplo n.º 7
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            if (_renderRequired)
            {
                DungeonMap.Draw(_mapConsole);
                Player.Draw(_mapConsole, DungeonMap);
                RLConsole.Blit(_mapConsole, 0, 0, _mapWidth, _mapHeight,
                               _rootConsole, 0, _headerHeight);
                RLConsole.Blit(_headerConsole, 0, 0, _headerWidth, _headerHeight,
                               _rootConsole, 0, 0);
                Player.Draw(_mapConsole, DungeonMap);
                DungeonMap.Draw(_mapConsole);
                _rootConsole.Draw();

                _renderRequired = false;
            }
        }
        protected override bool UseItem()
        {
            DungeonMap map       = Game.DungeonMap;
            Player     player    = Game.Player;
            Point      edgePoint = GetRandomEdgePoint(map);

            Game.MessageLog.Add($"You use a {Name} and chaotically unleashes a void beam");
            Actor voidAttackActor = new Actor
            {
                Attack       = 12,
                AttackChance = 90,
                Name         = "The Void"
            };

            ICell previousCell = null;

            foreach (ICell cell in map.GetCellsAlongLine(player.X, player.Y, edgePoint.X, edgePoint.Y))
            {
                if (cell.X == player.X && cell.Y == player.Y)
                {
                    continue;
                }

                Monster monster = map.GetMonsterAt(cell.X, cell.Y);
                if (monster != null)
                {
                    Game.CommandSystem.Attack(voidAttackActor, monster);
                }
                else
                {
                    map.SetCellProperties(cell.X, cell.Y, true, true, true);
                    if (previousCell != null)
                    {
                        if (cell.X != previousCell.X || cell.Y != previousCell.Y)
                        {
                            map.SetCellProperties(cell.X + 1, cell.Y, true, true, true);
                        }
                    }
                    previousCell = cell;
                }
            }

            RemainingUses--;

            return(true);
        }
Exemplo n.º 9
0
 public static void LoadPoIsEditorFiles()
 {
     try
     {
         DbcStores.InitFiles();
         AreaPoi.LoadData();
         AreaTable.LoadData();
         DungeonMap.LoadData();
         Map.LoadData();
         WorldMapArea.LoadData();
         WorldMapOverlay.LoadData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 10
0
    private void LateUpdate()
    {
        if (_renderRequired)
        {
            for (int i = 0; i < MonsterStat.transform.childCount; i++)
            {
                var go = MonsterStat.transform.GetChild(i).gameObject;
                Destroy(go);
            }

            DungeonMap.Draw();
            MessageLog.Draw();
            TargetingSystem.Draw();

            _renderRequired = false;
        }
    }
Exemplo n.º 11
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            if (_renderRequired)
            {
                DungeonMap.Draw(_mapConsole);
                Player.Draw(_mapConsole, DungeonMap);
                RLConsole.Blit(_mapConsole, 0, 0, _mapWidth, _mapHeight, _rootConsole, _messageWidth, 0);
                RLConsole.Blit(_messageConsole, 0, 0, _messageWidth, _messageHeight, _rootConsole, 0, 0);
                RLConsole.Blit(_statsConsole, 0, 0, _statsWidth, _statsHeight, _rootConsole, _mapWidth + _messageWidth, 0);
                RLConsole.Blit(_invConsole, 0, 0, _invWidth, _invHeight, _rootConsole, _mapWidth + _messageWidth, _statsHeight);
                // RLNET draw setted console
                _rootConsole.Draw();

                _renderRequired = false;
            }
            // throw new NotImplementedException();
        }
Exemplo n.º 12
0
        public static Zombie Create(DungeonMap map, Point pos, int level)
        {
            var health = Dice.Roll("2d5");

            return(new Zombie(map, pos, Colours.ZombieColour, Color.Black, 'Z', (int)MapLayers.MONSTERS)
            {
                Attack = Dice.Roll("2d5") + level / 3,
                AttackChance = Dice.Roll("25d3"),
                Awareness = 10,
                Defense = Dice.Roll("1d3") + level / 3,
                DefenseChance = Dice.Roll("10d4"),
                Gold = Dice.Roll("5d5"),
                Health = health,
                MaxHealth = health,
                Name = "Zombur"
            });
        }
Exemplo n.º 13
0
        public static void Main()
        {
            //establish the seed for the random number generator from the current time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            // the title will appear on top of the console window and include the seed used to generate the level
            string consoleTitle = $"RogueSharp V4 - Level {_mapLevel} - Seed {seed}";
            //must be the exact name of the bitmap file or we will get an error
            string fontFileName = "terminal8x8.png";

            //tell RLNet to use the bitmap font we specified, and that each tile is 8x8 pixels.
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            //initialize the sub-consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            SchedulingSystem = new SchedulingSystem();

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            CommandSystem = new CommandSystem();

            //set up a handler for RLNET's update event
            _rootConsole.Update += OnRootConsoleUpdate;
            //set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;

            //Create a new MessageLog and print the  random seed used to generate the level
            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on Level 1.");
            MessageLog.Add($"Level was created with seed '{seed}'");

            //Commented out below is just how to set the background color for the inventory console (can also be used for the messagelog or stats console, as well)
            //_inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, RLColor.Cyan)

            //begin RLNET's game loop
            _rootConsole.Run();
        }
Exemplo n.º 14
0
        public void PlaceBoss(DungeonMap map, List <Rectangle> rooms)
        {
            int roomIndex = GenerateRandomInt(0, rooms.Count);

            Console.WriteLine(roomIndex);
            Rectangle room = rooms[roomIndex];
            Point     randomRoomLocation = map.GetRandomWalkableLocationInRoom(room);

            if (randomRoomLocation != null)
            {
                // Temporarily hard code this monster to be created at level 1
                var boss = Outlaw.Create(1);
                boss.X = randomRoomLocation.X;
                boss.Y = randomRoomLocation.Y;
                map.AddMonster(map, boss);
            }
        }
Exemplo n.º 15
0
    public IEnumerator Execute(DungeonMap map)
    {
        Clear(map);
        Config config    = map.mainCells;
        int    max       = map.generateCells.maxArea;
        int    min       = map.generateCells.minArea;
        int    threshold = (int)(min * (1f - config.areaThreshold) + max * config.areaThreshold);

        foreach (Cell c in map.cells)
        {
            if (c.width * c.length >= threshold)
            {
                c.GetComponent <Renderer>().material.color = Color.red;
            }
        }
        yield break;
    }
Exemplo n.º 16
0
        protected override bool UseItem()
        {
            DungeonMap map = Game.DungeonMap;

            Game.MessageLog.Add($"You read the {Name} and gains knowledge of the surrounding area");

            foreach (ICell cell in map.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true);
                }
            }

            RemainingUses--;
            return(true);
        }
        public bool Act(Monster monster, CommandSystem commandSystem)
        {
            bool didReveal = false;

            DungeonMap dungeonMap = Game.DungeonMap;
            Player     player     = Game.Player;
            MessageLog messageLog = Game.MessageLog;

            foreach (ICell cell in dungeonMap.GetCellsInSquare(monster.X, monster.Y, 1))
            {
                if (dungeonMap.CheckForPlayer(cell.X, cell.Y) && didReveal == false)
                {
                    monster.Name            = "Mimic";
                    monster.Symbol          = 'M';
                    monster.IsMimicInHiding = false;
                    messageLog.Add("That's no armor, that a Mimic", Swatch.DbBlood);
                    messageLog.Add("The mimic spat poison at you", Swatch.DbBlood); // hp debug

                    if (Dice.Roll("1D10") < 7)
                    {
                        if (player.IsPoisonedImmune == false)
                        {
                            messageLog.Add("You were hit! The poison starts to enter your system", Swatch.DbBlood);
                            player.State = new AbnormalState(4, "Poisoned", "The Poison has stated to take its full effect", -2, -2, -3, 2, 3);
                        }
                        else if (player.Status == "Hardened")
                        {
                            messageLog.Add("You were hit! However, the poison has no effect on you in your hardened state");
                        }
                        else
                        {
                            messageLog.Add("You were hit! However, you are completely immune to the poison", Swatch.DbBlood);
                        }
                    }
                    else
                    {
                        messageLog.Add("You swifty dodge the poison");
                    }

                    didReveal = true;
                }
            }

            return(didReveal);
        }
        private void GenerateMap()
        {
            // Create the map
            //RogueSharp.MapCreation.IMapCreationStrategy<RogueSharp.Map> mapCreationStrategy
            //    = new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy<RogueSharp.Map>(Width, Height, 100, 20, 7);
            //rogueMap = RogueSharp.Map.Create(mapCreationStrategy);
            MapGenerator mapGenerator = new MapGenerator(Width, Height, 50, 12, 6);

            // TODO: I don't think I should have two maps
            detailedMap = mapGenerator.CreateMap();
            rogueMap    = detailedMap;

            rogueFOV = new RogueSharp.FieldOfView(rogueMap);
            mapData  = new MapObjects.MapObjectBase[Width, Height];

            // Loop through the map information generated by RogueSharp and create our cached visuals of that data
            foreach (var cell in rogueMap.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    if (detailedMap.GetDoor(cell.X, cell.Y) == null)
                    {
                        mapData[cell.X, cell.Y] = new Floor();
                    }
                    else
                    {
                        mapData[cell.X, cell.Y] = new Door('+');
                    }
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);
                }
                else
                {
                    //rogueMap.SetCellProperties(cell.X, cell.Y, false, false);
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);

                    // We're a wall, so we block LOS
                    rogueMap.SetCellProperties(cell.X, cell.Y, false, cell.IsWalkable);
                }
            }


            Monsters = detailedMap.getMonsters(Position - textSurface.RenderArea.Location);
            PositionPlayer();
        }
Exemplo n.º 19
0
        public static void Main()
        {
            //Establish the seed for the random number generator from the current time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            //Title will appear at the top of the console window and will include the seed for the level
            string consoleTitle = $"RPG_Game - Level {_mapLevel} - Seed {seed}";

            SchedulingSystem = new SchedulingSystem();
            CommandSystem    = new CommandSystem();
            string fontFileName = "terminal8x8.png";

            //Tells RLNet to use the bitmap font and that each tile is 8x8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;

            //Set background color and text color for each console

            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

            _rootConsole.Run();
        }
Exemplo n.º 20
0
    public void SelectTarget(Point target)
    {
        DungeonMap map     = Game.DungeonMap;
        Player     player  = Game.Player;
        Monster    monster = map.GetMonsterAt(target.X, target.Y);

        if (monster != null)
        {
            Game.MessageLog.Add(string.Format("{0} casts a {1} at {2}", player.Name, Name, monster.Name));
            Actor magicMissleActor = new Actor
            {
                Attack       = _attack,
                AttackChance = _attackChance,
                Name         = Name
            };
            Game.CommandSystem.Attack(magicMissleActor, monster);
        }
    }
Exemplo n.º 21
0
    public void SetDungeon(DungeonMap dungeon)
    {
        Clear();

        //Reset dungeon container to default position befor initializing
        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        this.dungeon = dungeon;

        this.dungeon.SetDungeonListener(this);

        AddTiles();

        AddEntities();

        UpdateVisibility();
    }
Exemplo n.º 22
0
    private IEnumerator Start()
    {
        yield return(new WaitUntil(() => RootConsole.s_Singleton.Initialized == true));

        active = true;
        Map.SetBackgroundColor(Palette.FloorBackground);
        Message.SetBackgroundColor(Swatch.DbDeepWater);
        Inventory.SetBackgroundColor(Swatch.DbWood);
        Stat.SetBackgroundColor(Swatch.DbOldStone);

        player     = new Player();
        commandSys = new CommandSystem();

        MapGenerator mapGen = new MapGenerator(Map.GetWidth(), Map.GetHeight());

        dunegonMap = mapGen.CreateMap();
        dunegonMap.Draw(Map);
    }
Exemplo n.º 23
0
        public bool SelectMonster(ITargetable targetable)
        {
            Initialize();
            _selectionType = SelectionType.Target;
            DungeonMap map = Game.DungeonMap;

            _selectableTargets = map.GetMonsterLocationsInFieldOfView().ToList();
            _targetable        = targetable;
            _cursorPosition    = _selectableTargets.FirstOrDefault();
            if (_cursorPosition == null)
            {
                StopTargeting();
                return(false);
            }

            IsPlayerTargeting = true;
            return(true);
        }
Exemplo n.º 24
0
        public void ShutDown()
        {
            if (nextScene == SceneType.Pause)       //次のシーンがPauseだったら以下のものShutdownしない
            {
                return;
            }

            map.Clear();                            //マップ解放
            map = null;
            gameManager.ReleaseMap();

            mapItemManager.Initialize();            //Item解放
            mapItemManager = null;

            gameManager.EnemySetting.Clear();       //SpawnSettingを削除

            ui = null;
        }
Exemplo n.º 25
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            if (_renderRequired)
            {
                DungeonMap.draw(_mapConsole);
                Player.Draw(_mapConsole, DungeonMap);

                // Blits other consoles to root console
                RLConsole.Blit(_mapConsole, 0, 0, _mapWidth, _mapHeight, _rootConsole, 0, _inventoryHeight);
                RLConsole.Blit(_statConsole, 0, 0, _statWidth, _statHeight, _rootConsole, _mapWidth, 0);
                RLConsole.Blit(_messageConsole, 0, 0, _messageWidth, _messageHeight, _rootConsole, 0, _screenHeight - _messageHeight);
                RLConsole.Blit(_inventoryConsole, 0, 0, _inventoryWidth, _inventoryHeight, _rootConsole, 0, 0);

                _rootConsole.Draw();

                _renderRequired = false;
            }
        }
Exemplo n.º 26
0
    protected override bool UseItem()
    {
        DungeonMap map = Game.DungeonMap;

        Game.MessageLog.Add(string.Format("{0} reads a {1} and gains knowledge of the surrounding area", Game.Player.Name, Name));

        foreach (RogueSharp.Cell cell in map.GetAllCells())
        {
            if (cell.IsWalkable)
            {
                map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true);
            }
        }

        RemainingUses--;

        return(true);
    }
Exemplo n.º 27
0
        public static void Main(string[] args)
        {
            //establish seed from random number generator from current time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";

            //include title at top of console window
            string consoleTitle = $"Rougelike - Level {_mapLevel} - Seed {seed}";

            SchedulingSystem = new SchedulingSystem();

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
                                             8, 8, 1f, consoleTitle);

            //initialize all the sub consoles that blit onto the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            CommandSystem = new CommandSystem();

            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            //create new MessageLog and print the random seed used to generate level
            MessageLog = new MessageLog();
            MessageLog.Add("The player arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;
            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;
            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemplo n.º 28
0
Arquivo: Game.cs Projeto: Auri3l/Hobby
        public static void Main()
        {
            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";

            // The title will appear at the top of the console window
            string consoleTitle = "RougeSharp V3 Tutorial - Level 1";

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            Player = new Player();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            CommandSystem = new CommandSystem();

            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;

            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;

            // Set background color and text for each console so that we can verify they are in the correct positions
            _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
            _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemplo n.º 29
0
        public static void Main()
        {
            //font file we're using, this is in my file
            string fontFileName = "terminal8x8.png";
            string consoleTitle = "RogueSharp V3 Tutorial - Level 1";

            //Initialize the sub consoles that will attach to root
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            Player = new Player();
            //Use map generator to generate dungeon
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();

            //Instantiate CommandSystem();
            CommandSystem = new CommandSystem();

            _rootConsole         = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            //Set background color and text for each console
            //Used to verify correct positions
            //Map console color for text and background
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "Map", Colors.TextHeading);

            //Message console color for text and background
            _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
            _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

            //Stat console color for text and background
            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            //Inventory console color for text and background
            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
            _rootConsole.Run();
        }
Exemplo n.º 30
0
 public void PlaceMonsters(DungeonMap map, Rectangle room)
 {
     // Each room has a 60% chance of having monsters
     //if (Dice.Roll("1D10") < 7)
     //{
     //    // Generate between 1 and 4 monsters
     //    var numberOfMonsters = Dice.Roll("1D4");
     //    for (int i = 0; i < numberOfMonsters; i++)
     //    {
     //        // Find a random walkable location in the room to place the monster
     //        Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room);
     //        // It's possible that the room doesn't have space to place a monster
     //        // In that case skip creating the monster
     //        if (randomRoomLocation != null)
     //        {
     //            // Temporarily hard code this monster to be created at level 1
     //            var monster = Kobold.Create(1);
     //            monster.X = randomRoomLocation.X;
     //            monster.Y = randomRoomLocation.Y;
     //            _map.AddMonster(_map, monster);
     //        }
     //    }
     //}
     if (test == true)
     {
         // Generate between 1 and 4 monsters
         var numberOfMonsters = 1;
         for (int i = 0; i < numberOfMonsters; i++)
         {
             // Find a random walkable location in the room to place the monster
             Point randomRoomLocation = map.GetRandomWalkableLocationInRoom(room);
             // It's possible that the room doesn't have space to place a monster
             // In that case skip creating the monster
             if (randomRoomLocation != null)
             {
                 // Temporarily hard code this monster to be created at level 1
                 var monster = Goon.Create(1);
                 monster.X = randomRoomLocation.X;
                 monster.Y = randomRoomLocation.Y;
                 map.AddMonster(map, monster);
             }
         }
     }
 }
Exemplo n.º 31
0
    public void GenerateMap()
    {
        Map = new DungeonMap();
        int roomCount = Random.Range(Constants.FT_RoomCountMax, Constants.FT_RoomCountMin);
        bool isRestExists = false;
        bool isTrainingExists = false;
        bool isShopExists = false;
        for (int i=0; i < roomCount; i++)
        {
            RoomClass room = new RoomClass();
            if (Map.Compartments.Count == 0)
            {
                room.Type = FloodedTempleRoomTypes.Start;
                room.Background = StartRoomSprite;
                room.Furniture = SetRoomFurniture(room);
                Map.Compartments.Add(room);
            }
            else if (Map.Compartments.Count == (roomCount - 1) * 2)
            {
                room.Type = FloodedTempleRoomTypes.Final;
                room.Background = FinalRoomSprite;
                room.Furniture = SetRoomFurniture(room);
                room.ActiveItems.Add(FT_AltarCollection.TheRivenMaskAltar);
                room.Enemy = FT_EnemyCollection.DDTheRock;
                Map.Compartments.Add(room);
            }
            else
            {
                do
                {
                    room.Type = MinorRoomTypes[Random.Range(0, MinorRoomTypes.Length)];
                } while (!(room.Type == FloodedTempleRoomTypes.Training && !isTrainingExists || room.Type == FloodedTempleRoomTypes.Shop && !isShopExists
                || room.Type == FloodedTempleRoomTypes.Rest && !isRestExists || isTrainingExists && isShopExists && isRestExists));
                if (room.Type == FloodedTempleRoomTypes.Training)
                {
                    isTrainingExists = true;
                }
                else if(room.Type == FloodedTempleRoomTypes.Shop)
                {
                    isShopExists = true;
                }
                else if (room.Type == FloodedTempleRoomTypes.Rest)
                {
                    isRestExists = true;
                }
                room.Background = MinorRoomSprites[(int)room.Type-1];
                room.Furniture = SetRoomFurniture(room);
                if (room.Type == FloodedTempleRoomTypes.Shop)
                {
                    for (int j = 0; j < Random.Range(1, Constants.FT_ItemsPerShop); j++)
                    {
                        room.ActiveItems.Add(ItemCollection.GetRandomItem());
                    }
                }
                else if (room.Type == FloodedTempleRoomTypes.Rest)
                {
                    room.ActiveItems.Add(FT_AltarCollection.RestRoomAltar);
                }
                else if (room.Type == FloodedTempleRoomTypes.Training)
                {
                    room.Enemy = FT_EnemyCollection.GetRandomMinorBoss();
                }
                Map.Compartments.Add(room);
            }
            if (i < roomCount - 1)
            {
                PassageClass passage = new PassageClass();
                passage.Tiles = new PassageTile[Random.Range(Constants.FT_PassageMinTileLength, Constants.FT_PassageMaxTileLength+1)];
                AbActiveItem[] activeItems = new AbActiveItem[passage.Tiles.Length * 4];

                for (int j = 3; j < activeItems.Length-2; j++)
                {
                    if ((j%Constants.FT_EventSlotsPerPassageTile==2 || j % Constants.FT_EventSlotsPerPassageTile == 3) && Random.Range(1, 100) <= Constants.FT_AltarChance)
                    {
                        activeItems[j] = FT_AltarCollection.GetRandomAltar();
                        j += Constants.FT_SameEventsMinDistance - 1;
                    }
                }
                AbEnemy[] enemies = new AbEnemy[passage.Tiles.Length * 4];

                if (i == 0)
                {
                    enemies[2] = FT_EnemyCollection.TutorialTurtle;
                }
                for (int j = 2; j < enemies.Length; j++)
                {
                    if (i == 0)
                    {
                        j += Constants.FT_SameEventsMinDistance - 1;
                    }
                    else
                    {
                        if (j % Constants.FT_EventSlotsPerPassageTile != 0 && Random.Range(1, 100) <= Constants.FT_EnemyChance)
                        {
                            if (activeItems[j] != null)
                            {
                                enemies[j - 1] = FT_EnemyCollection.GetRandomTrashEnemy();
                            }
                            else
                            {
                                enemies[j] = FT_EnemyCollection.GetRandomTrashEnemy();
                            }
                            j += Constants.FT_SameEventsMinDistance - 1;
                        }
                    }
                }
                for (int j = 0; j < passage.Tiles.Length; j++)
                {
                    PassageTile passageTile = new PassageTile();
                    passageTile.Background = PassageSprites[Random.Range(0, PassageSprites.Length)];

                    for(int k = 0; k < Constants.FT_EventSlotsPerPassageTile; k++)
                    {
                        passageTile.ActiveItems[k] = activeItems[j * 4 + k];
                    }
                    for (int k = 0; k < Constants.FT_EventSlotsPerPassageTile; k++)
                    {
                        passageTile.Enemies[k] = enemies[j * 4 + k];
                    }

                    passage.Tiles[j] = passageTile;
                }

                Map.Compartments.Add(passage);
            }
        }
    }
Exemplo n.º 32
0
    public void GenerateMap()
    {
        Map = new DungeonMap();
        int roomCount = Random.Range(Constants.FT_RoomCountMax, Constants.FT_RoomCountMin);
        for(int i=0; i < roomCount; i++)
        {
            RoomClass room = new RoomClass();
            room.Background = RoomSprites[Random.Range(0, RoomSprites.Length - 1)];
            room.Type = RoomTypes[Random.Range(0, RoomTypes.Length - 1)];
            room.Furniture = SetRoomFurniture(room);
            if (room.Type == FloodedTempleRoomType.Shop)
            {
                for(int j=0; j < Constants.FT_ItemsPerShop; j++)
                {
                    room.ActiveItems.Add(ItemCollection.GetRandomItem());
                }
            }
            else if (room.Type == FloodedTempleRoomType.Rest)
            {
                room.ActiveItems.Add(new FakeAltar());
            }
            else if (room.Type == FloodedTempleRoomType.Training)
            {
                room.Enemy = FT_EnemyCollection.GetRandomEnemy();
            }
            Map.Compartments.Add(room);

            if (i < roomCount - 1)
            {
                PassageClass passage = new PassageClass();
                passage.Tiles = new PassageTile[Random.Range(Constants.FT_PassageTileLengthMin, Constants.FT_PassageTileLengthMax)];
                AbActiveItem[] activeItems = new AbActiveItem[passage.Tiles.Length * 4];

                //#todo generate doors
                activeItems[1] = new FakeAltar();
                //activeItems[1].Action = previous;
                activeItems[activeItems.Length-2] = new FakeAltar();
                //activeItems[activeItems.Length-2].Action = next;

                for (int j = 3; j < activeItems.Length-2; j++)
                {
                    if (Random.Range(1, 100) <= Constants.FT_AltarChance)
                    {
                        activeItems[j] = FT_AltarCollection.GetRandomAltar();
                        j += Constants.FT_SameEventsMinDistance - 1;
                    }
                }
                AbEnemy[] enemies = new AbEnemy[passage.Tiles.Length * 4];
                for (int j = 2; j < enemies.Length; j++)
                {
                    if (Random.Range(1, 100) <= Constants.FT_AltarChance)
                    {
                        if (activeItems[j]!=null)
                        {
                            enemies[j-1] = FT_EnemyCollection.GetRandomEnemy();
                        }
                        else
                        {
                            enemies[j] = FT_EnemyCollection.GetRandomEnemy();
                        }
                        j += Constants.FT_SameEventsMinDistance - 1;
                    }
                }
                for (int j = 0; j < passage.Tiles.Length; j++)
                {
                    PassageTile passageTile = new PassageTile();
                    passageTile.Background = PassageSprites[Random.Range(0, PassageSprites.Length - 1)];

                    for(int k = 0; k < Constants.FT_EventSlotsPerPassageTile; k++)
                    {
                        passageTile.ActiveItems[k] = activeItems[j * 4 + k];
                    }
                    for (int k = 0; k < Constants.FT_EventSlotsPerPassageTile; k++)
                    {
                        passageTile.Enemies[k] = enemies[j * 4 + k];
                    }

                    passage.Tiles[j] = passageTile;
                }

                Map.Compartments.Add(passage);
            }
        }
    }
Exemplo n.º 33
0
 public void SetMap(DungeonMap dungeonMap)
 {
     _dungeonMap = dungeonMap;
 }