Exemple #1
0
    void Init()
    {
        int seed = (int)DateTime.UtcNow.Ticks;

        Random = new DotNetRandom(seed);

        PlayerStat     = GameObject.Find("playerStat");
        EquipmentItems = GameObject.Find("equipmentItems");
        AbilitiesItems = GameObject.Find("abilitiesItems");
        ItemItems      = GameObject.Find("itemItems");
        MonsterStat    = GameObject.Find("monsterStat");
        MonsterItem    = Resources.Load <GameObject>("Prefabs/monsterItem");

        text       = GameObject.Find("massageText").GetComponent <Text>();
        text.color = Color.white;

        MessageLog       = new MessageLog();
        SchedulingSystem = new SchedulingSystem();
        MessageLog.Add("The rogue arrives on level 1");
        MessageLog.Add(string.Format("Level created with seed '{0}'", seed));

        groundTiles = new GameObject[_width, _height];
        ItemsTiles  = new Entry[_width, _height];

        boardHolder   = new GameObject("boardHolder").transform;
        itemsHolder   = new GameObject("itemsHolder").transform;
        effectsHolder = new GameObject("effectsHolder").transform;

        CommandSystem   = new CommandSystem();
        TargetingSystem = new TargetingSystem();
    }
Exemple #2
0
        public static void Main()
        {
            string fontFileName = "terminal8x8.png";
            string consoleTitle = "RougeSharp RLNet Tutorial - Level 1";
            int    seed         = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

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

            Player           = new Player();
            SchedulingSystem = new SchedulingSystem();

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

            DungeonMap = mapGenerator.CreateMap();

            _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();
            TargetingSystem = new TargetingSystem();

            Player.Item1 = new RevealMapScroll();
            Player.Item2 = new RevealMapScroll();

            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
Exemple #3
0
        public RogueGame()
        {
            string consoleTitle = "RougeSharp SadConsole Example Game - Level 1";
            int    seed         = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

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

            Player           = new Player();
            SchedulingSystem = new SchedulingSystem();

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

            DungeonMap = mapGenerator.CreateMap();

            CommandSystem   = new CommandSystem();
            TargetingSystem = new TargetingSystem();

            Player.Item1 = new RevealMapScroll();
            Player.Item2 = new RevealMapScroll();

            _inputState = new InputState();

            _graphics         = new GraphicsDeviceManager(this);
            this.Window.Title = consoleTitle;

            Content.RootDirectory = "Content";
            var sadConsoleComponent = new SadConsole.EngineGameComponent(this, () => {
                using (var stream = System.IO.File.OpenRead("Fonts/Cheepicus12.font"))
                    SadConsole.Engine.DefaultFont = SadConsole.Serializer.Deserialize <SadConsole.Font>(stream);

                SadConsole.Engine.DefaultFont.ResizeGraphicsDeviceManager(_graphics, _screenWidth, _screenHeight, 0, 0);
                SadConsole.Engine.UseMouse    = true;
                SadConsole.Engine.UseKeyboard = true;

                _mapConsole       = new Console(_mapWidth, _mapHeight);
                _messageConsole   = new Console(_messageWidth, _messageHeight);
                _statConsole      = new Console(_statWidth, _statHeight);
                _inventoryConsole = new Console(_inventoryWidth, _inventoryHeight);

                _mapConsole.Position       = new Point(0, _inventoryHeight);
                _messageConsole.Position   = new Point(0, _screenHeight - _messageHeight);
                _statConsole.Position      = new Point(_mapWidth, 0);
                _inventoryConsole.Position = new Point(0, 0);

                SadConsole.Engine.ConsoleRenderStack.Add(_mapConsole);
                SadConsole.Engine.ConsoleRenderStack.Add(_messageConsole);
                SadConsole.Engine.ConsoleRenderStack.Add(_statConsole);
                SadConsole.Engine.ConsoleRenderStack.Add(_inventoryConsole);

                SadConsole.Engine.ActiveConsole = _mapConsole;
            });

            Components.Add(sadConsoleComponent);
        }
Exemple #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 = "Theseus";

            // 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();
            NPC        = new NPC();
            MessageLog = new MessageLog();

            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;


            // _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
            // _messageConsole.Print(1, 1, "Messages", RLColor.White);


            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldBlood);
            _statConsole.Print(1, 1, "Stats", RLColor.White);

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

            MessageLog.Add("You wake up in what remains of your ship...");
            MessageLog.Add("> Bob: \"Good morning, boss!\"");

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemple #5
0
        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);

            // 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 - Seed {seed}";

            // 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);

            CommandSystem = new CommandSystem();

            SchedulingSystem = new SchedulingSystem();

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

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

            MessageLog = new MessageLog();
            MessageLog.Add("The rogue 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;

            // Set background color and text for each console
            // so that we can verify they are in the correct positions

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

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemple #6
0
        public static void Play()
        {
            string fontFileName = "terminal16x16_gs_ro.png";

            // for testing use 1138043851
            Random = new DotNetRandom(seed);
            //TODO: Take seed out after debugging
            string consoleTitle = $"D$ DungeonZ Level {_mapLevel} - Seed {seed}";

            //setup systems
            SchedulingSystem = new SchedulingSystem();
            CommandSystem    = new CommandSystem();
            MessageLog       = new MessageLog();
            Player           = new Player();

            // Dont change map width or height
            //Attempting to make 20 rooms that are between 5 and 13 cells for room size
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 50, 5, 13, _mapLevel);

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

            // first numbers effect tile size
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 16, 16, 1.5f, consoleTitle);

            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            //these console methods have to be run before the update and render below
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "Map", Colors.TextHeading);

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

            // Remove these lines:
            _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
            _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

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

            // have to register events for RLNet for update and render
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
Exemple #7
0
        public static void Main()
        {
            //Console.WriteLine("Good luck, you will need it.");
            string fontFileName = "terminal8x8.png";
            int    seed         = (int)DateTime.UtcNow.Ticks;
            string consoleTitle = $"RoguelikeGame - Level {MapLevel}";

            Random           = new DotNetRandom(seed);
            MessageLog       = new MessageLog();
            SchedulingSystem = new SchedulingSystem();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, MapLevel);

            DungeonMap = mapGenerator.CreateForrest();
            DungeonMaps.Add(DungeonMap);

            _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();
            TargetingSystem     = new TargetingSystem();
            InputSystem         = new InputSystemPlaying();
            InventoryScreen     = new InventoryScreen(_popupWidth, _popupHeight);
            DialogScreen        = new DialogScreen(_popupWidth, _dialogHeight);
            ShopSelectionScreen = new ShopSelectionScreen(_popupWidth, _dialogHeight);
            BuyScreen           = new BuyScreen(_popupWidth, _popupHeight);
            SellScreen          = new SellScreen(_popupWidth, _popupHeight);

            if (Player.GreetMessages != null)
            {
                Random random = new Random();
                int    i      = random.Next(0, Player.GreetMessages.Length);
                MessageLog.Add($"{Player.GreetMessages[i]}", Colors.Gold);
            }
            else
            {
                MessageLog.Add("Good luck on your quest ", Colors.Gold);
            }
            // MessageLog.Add($"Level created with seed '{seed}'"); // debug

            _rootConsole.Update += OnIntroUpdate;
            _rootConsole.Render += OnIntroRender;

            Timer t = new Timer(UpdateColoredText, null, 0, 200);

            _rootConsole.Run();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);


            string consoleTitle = $"RogueSharp Test - Level 1 - Seed {seed}";

            string fontFileName = "terminal8x8.png";

            player = new Player(10, 10, 10, 10, 10, 10, 10, 10, 10,
                                10, 10, 10, 10, 10, 10, 10, 10, 10,
                                10, 10, 10, 10, 10, ClassTypes.Archer, RLColor.White,
                                new WeaponTest(), new TestArmour(), "dick");

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

            DungeonMap = mapGenerator.CreateMap();
            SaveTest save = new SaveTest(seed.ToString(), player.SavePlayer());

            DungeonMap.UpdatePlayerFieldOfView(player);

            CommandSystem = new CommandSystem();

            MessageLog = new MessageLog();
            MessageLog.Add("Message 1");

            InventoryLog = new InventoryLog();
            InventoryLog.Add("Weapon: " + player.GetInventory().GetThing(0).GetName());

            MessageLog.Add($"Level created with seed {seed}");

            //tells rlnet to use the bitmap font and that each tile is 8x8px
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            //setting up other sections
            _mapConsole     = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole = new RLConsole(_messageWidth, _messageHeight);
            _statConsole    = new RLConsole(_statWidth, _statHeight);
            _invConsole     = new RLConsole(_invWidth, _invHeight);

            //event wiring
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;

            //game loop call
            _rootConsole.Run();
        }
Exemple #9
0
        private static void LoadNextLevel()
        {
            if (_mapLevel == 4)
            {
                GameOver();
                return;
            }

            if (playWithSeed && _mapLevel <= _save.Seeds.Count)
            {
                _seed = _save.Seeds[_mapLevel - 1];
            }
            else
            {
                // Creating a new seed for the next level
                _seed = (int)DateTime.UtcNow.Ticks;
                // Saving that seed int the save
                _save.Seeds.Add(_seed);
            }

            Random = new DotNetRandom(_seed);
            MapGenerator mapGenerator = ChoseMapGenerator();

            Map           = mapGenerator.CreateMap(_seed);
            MessageLog    = new MessageLog();
            CommandSystem = new CommandSystem();

            MessageLog.Add(Story.levelBeginnigTexts[_mapLevel - 1]);
        }
Exemple #10
0
        /// <summary>
        /// Получает сообщения в фоновом режиме
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MessageListener(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            this.w.Dispatcher.Invoke(() =>
            {
                MessageRec message = new MessageRec(DateTime.Now.ToLongTimeString(), e.Message.Chat.Id, e.Message.Chat.FirstName, e.Message.Text, e.Message.Type.ToString());
                MessageLog.Add(message);

                BotContact botContact = new BotContact(e.Message.Chat.FirstName, e.Message.Chat.Id);

                if (!ContactList.Contains(botContact))
                {
                    ContactList.Add(botContact);
                }

                if (e.Message.Type.ToString() == "Text")
                {
                    string messageText = e.Message.Text.ToLower();
                    ReplyOnText(messageText, e.Message.Chat.Id);
                }
                else
                {
                    DownLoad(IdentifiedFile(e));
                }
            });
        }
Exemple #11
0
        public override CommandResult Execute(Entity entity)
        {
            if (Target == null || !entity.HasComponent <FighterComponent>() || !Target.HasComponent <FighterComponent>())
            {
                return(CommandResult.Failure);
            }

            int damage  = 0;
            int power   = entity.GetComponent <FighterComponent>().Power.Value;
            int defense = Target.GetComponent <FighterComponent>().Defense.Value;

            if (Program.Game.Random.NextDouble() < CriticalHitChance)
            {
                damage = power;
            }
            else
            {
                damage = power - defense;
            }

            if (damage > 0)
            {
                Target.GetComponent <FighterComponent>().Damage(damage, entity, ElementType.Physical);
            }
            else
            {
                MessageLog.Add($"{entity.Name} attacks {Target.Name} but it has no effect!");
            }

            return(CommandResult.Success);
        }
Exemple #12
0
        /// <summary>
        /// Загружает файл из телеграмм чата
        /// </summary>
        /// <param name="f">атрибуты полученного файла</param>
        public async void DownLoad(MyFile f)
        {
            string botReply = "Спасибо. ";

            try
            {
                if (!Directory.Exists($@"{Catalog.PathToUserFiles}\{f.FileType}"))
                {
                    Directory.CreateDirectory($@"{Catalog.PathToUserFiles}\{f.FileType}");
                }
                var file = await bot.GetFileAsync(f.FileId);

                FileStream fs = new FileStream(f.FilePath, FileMode.Create);

                await bot.DownloadFileAsync(file.FilePath, fs);

                fs.Close();

                fs.Dispose();
                f.IsDownloaded = true; // отметка о том, что файл был успешно загружен
            }
            catch (Exception ex)
            {
                botReply += "Возможно, мне неизвестен тип этого файла или произошла ошибка при загрузке.";
                Debug.WriteLine("Ошибка загрузки файла: " + ex.Message);
            }
            finally
            {
                Catalog.Add(f);
                await bot.SendTextMessageAsync(f.ChatId, botReply);

                MessageLog.Add(new MessageRec(DateTime.Now.ToLongTimeString(), 0, "Bot", botReply, "Text"));
            }
        }
        public bool PickUp(ICharacter character)
        {
            character.Gold += this.Amount;
            MessageLog.Add($"{character.Name} picked up {this.Amount} gold");

            return(true);
        }
Exemple #14
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();
        }
Exemple #15
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();
        }
Exemple #16
0
        /// <summary>
        /// Converts a bitmap to grayscale, asynchronously.
        /// </summary>
        /// <param name="b">The bitmap.</param>
        /// <returns>A Tuple containing a BackgroundWorker representing the asynchronous operation and its parameter.</returns>
        public static BackgroundWorker ApplyGrayscaleFilter(Bitmap b)
        {
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, e) => {
                MessageLog.Add("Applying grayscale filter.");

                Stopwatch st = new Stopwatch();
                st.Start();

                Bitmap     ob = new Bitmap(b);
                BitmapData bd = b.LockBits(
                    new Rectangle(new Point(0, 0), b.Size),
                    ImageLockMode.ReadOnly,
                    PixelFormat.Format24bppRgb
                    );
                BitmapData obd = ob.LockBits(
                    new Rectangle(new Point(0, 0), ob.Size),
                    ImageLockMode.WriteOnly,
                    PixelFormat.Format24bppRgb
                    );

                unsafe {
                    byte *data  = (byte *)bd.Scan0;
                    byte *odata = (byte *)obd.Scan0;
                    for (int y = 0; y < bd.Height; y++)
                    {
                        for (int x = 0; x < bd.Width; x++)
                        {
                            odata[y * bd.Stride + x * 3 + 0]         =
                                odata[y * bd.Stride + x * 3 + 1]     =
                                    odata[y * bd.Stride + x * 3 + 2] =
                                        (byte)(
                                            .0722 * data[y * bd.Stride + x * 3 + 0] +
                                            .7152 * data[y * bd.Stride + x * 3 + 1] +
                                            .2126 * data[y * bd.Stride + x * 3 + 2]
                                            );
                        }

                        if (bw.CancellationPending)
                        {
                            e.Cancel = true;
                            goto cleanup;
                        }
                        bw.ReportProgress((int)((double)y * 100 / bd.Height));
                    }
                }

cleanup:

                b.UnlockBits(bd);
                ob.UnlockBits(obd);
                e.Result = ob;

                st.Stop();
                MessageLog.Add(String.Format("Filter application took {0} msecs.", st.ElapsedMilliseconds));
            };
            return(bw);
        }
Exemple #17
0
        public bool Act(Monster monster, CommandSystem commandSystem)
        {
            Map    map    = Container.Adventure.Map;
            Player player = Container.Adventure.Player;

            FieldOfView monsterFov = new FieldOfView(map);

            if (!monster.TurnsAlerted.HasValue)
            {
                monsterFov.ComputeFov(monster.Position.X, monster.Position.Y, monster.Wisdom, true);

                if (monsterFov.IsInFov(player.Position.X, player.Position.Y))
                {
                    MessageLog.Add($"{monster.ColoredName} has spotted {player.ColoredName}!");
                    monster.TurnsAlerted = 1;
                }
            }

            if (monster.TurnsAlerted.HasValue)
            {
                map.GetTile(monster.Position).IsBlockingMove = false;
                map.GetTile(player.Position).IsBlockingMove  = false;

                PathFinder pathFinder = new PathFinder(map, 1.41);
                Path       path       = null;

                try
                {
                    path = pathFinder.ShortestPath(map.GetTile(monster.Position), map.GetTile(player.Position));
                }
                catch (PathNotFoundException)
                {
                    MessageLog.Add($"{monster.ColoredName} waits for a turn...");
                }

                map.GetTile(monster.Position).IsBlockingMove = true;
                map.GetTile(player.Position).IsBlockingMove  = true;

                if (path != null)
                {
                    try
                    {
                        commandSystem.MoveMonster(monster, path.StepForward());
                    } catch (NoMoreStepsException)
                    {
                        MessageLog.Add($"{monster.ColoredName} growls in frustration.");
                    }
                }

                monster.TurnsAlerted++;

                if (monster.TurnsAlerted > 15)
                {
                    monster.TurnsAlerted = null;
                }
            }

            return(true);
        }
Exemple #18
0
    public Game(GameManager manager, int seed)
    {
        this.Manager = manager;

        Random = new DotNetRandom(seed);

        commandSystem    = new CommandSystem(this);
        MessageLog       = new MessageLog(this);
        SchedulingSystem = new SchedulingSystem();

        MessageLog.Add("You have entered Level " + (GameData.Data.CurrentLevel + 1));

        if (GameData.Data.CurrentLevel == GameData.Data.Levels - 1)
        {
            MessageLog.Add("You sense an ominous presence.");
        }
    }
Exemple #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);

            // 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();
        }
Exemple #20
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();
        }
Exemple #21
0
        private static async Task RenderUiAndHandleInputAsync(ITcpPeerMessenger messenger, MessageLog messageLog, bool isChatbotMode)
        {
            IMessengerCommandHandler commandHandler = new MessengerCommandHandler(messenger, messageLog);
            IMessengerCommandParser  commandParser  = new MessengerCommandParser();

            int headerHeight   = 2;
            int splitterHeight = 1;
            int inputHeight    = 5;

            Header header = new Header(isChatbotMode);

            int            logViewHeight  = Console.WindowHeight - headerHeight - splitterHeight - inputHeight;
            int            logViewTop     = headerHeight;
            MessageLogView messageLogView = new MessageLogView(logViewTop, logViewHeight, messageLog, messenger.EndPoint);

            int splitterTop             = headerHeight + logViewHeight;
            HorizontalSplitter splitter = new HorizontalSplitter(splitterTop);

            int inputTop = headerHeight + splitterHeight + logViewHeight;
            MessageTextInput messageTextInput = new MessageTextInput(inputTop);

            messageTextInput.MessageEntered += async(s, input) =>
            {
                if (input != "")
                {
                    try
                    {
                        MessengerCommand command = commandParser.Parse(input);
                        await command.AcceptHandlerAsync(commandHandler);
                    }
                    catch (MessengerCommandParserException ex)
                    {
                        messageLog.Add(new SystemMessage(ex.Message));
                    }
                    catch (Exception e)
                    {
                        messenger.Stop();
                        throw e;
                    }
                }
            };

            var components = new List <ConsoleUiComponent>
            {
                header, messageLogView, splitter, messageTextInput
            };

            Console.Clear();
            while (messenger.IsStarted)
            {
                foreach (var c in components)
                {
                    c.Render();
                }
                await Task.Delay(500);
            }
        }
Exemple #22
0
        public static void PlayerDeath(Entity entity)
        {
            MessageLog.Add("You died!");

            entity.Character   = '%';
            entity.Colour      = Color.Red;
            entity.SpriteIndex = EntitySprites.TombStone;
            entity.RenderLayer = Renderer.CorpseLayer;
        }
        public bool Act(MonsterDTO monster, DungeonMapDTO map, PlayerDTO player, CommandSystem commandSystem)
        {
            var monsterFov = new FieldOfView(map);

            if (!monster.TurnsAlerted.HasValue)
            {
                monsterFov.ComputeFov(monster.X, monster.Y, monster.Awareness, true);
                if (monsterFov.IsInFov(player.X, player.Y))
                {
                    MessageLog.Add($"{monster.Name} is eager to fight {player.Name}");
                    monster.TurnsAlerted = 1;
                }
            }

            if (monster.TurnsAlerted.HasValue)
            {
                map.SetIsWalkable(monster.X, monster.Y, true);
                map.SetIsWalkable(player.X, player.Y, true);

                var  pathFinder = new PathFinder(map);
                Path path       = null;

                try
                {
                    path = pathFinder.ShortestPath(
                        map.GetCell(monster.X, monster.Y),
                        map.GetCell(player.X, player.Y));
                }
                catch (PathNotFoundException)
                {
                    MessageLog.Add($"{monster.Name} waits for a turn");
                }

                map.SetIsWalkable(monster.X, monster.Y, false);
                map.SetIsWalkable(player.X, player.Y, false);

                if (path != null)
                {
                    try
                    {
                        commandSystem.MoveMonster(monster, map, player, path.Steps.First());
                    }
                    catch (NoMoreStepsException)
                    {
                        MessageLog.Add($"{monster.Name} growls in frustration");
                    }
                }

                monster.TurnsAlerted++;

                if (monster.TurnsAlerted > 15)
                {
                    monster.TurnsAlerted = null;
                }
            }
            return(true);
        }
Exemple #24
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();
        }
Exemple #25
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

            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 consoleTitle = $"RougeSharp V3 Tutorial - Level 1 - Seed {seed}";

            // 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);
            MessageLog        = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

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

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Palette.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
            CommandSystem = new CommandSystem();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7);

            DungeonMap = mapGenerator.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;
            //_rootConsole.OnLoad += rootConsole_OnLoad;
            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Exemple #26
0
        public override CommandResult Execute(Entity entity)
        {
            if (entity == Program.Game.Player)
            {
                var healed = entity.GetComponent <FighterComponent>()?.HealPercent(RestHealPercent);
                MessageLog.Add($"You rest for a turn and regain {healed} HP.", Color.LightGreen);
            }

            return(CommandResult.Success);
        }
Exemple #27
0
        public static void Main(string[] args)
        {
            string fontFileName = "terminal8x8.png";

            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            string consoleTitle = $"RogueLike Test - Level {_mapLevel} - Seed {seed}";

            CommandSystem    = new CommandSystem();
            SchedulingSystem = new SchedulingSystem();

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

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

            _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);

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

            MessageLog = new MessageLog();
            MessageLog.Add("O Errante chega no andar 1");
            MessageLog.Add($"Level criado com a seed '{seed}'");

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


            _rootConsole.Update += OnRootConsoleUpdate;

            _rootConsole.Render += OnRootConsoleRender;

            _rootConsole.Run();
        }
Exemple #28
0
        public static void Main()
        {
            StartServer();
            LastPlayed();

            // 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 consoleTitle = $"RogueSharp - Level {_mapLevel} - Seed {seed}";;

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

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

            // 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);
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);
            // 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
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 15, 8, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();
            _rootConsole.Run();
        }
Exemple #29
0
        public Game(UI_Main console)
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random           = new DotNetRandom(seed);
            commandSystem    = new CommandSystem(this);
            MessageLog       = new MessageLog(this);
            SchedulingSystem = new SchedulingSystem();

            rootConsole             = console;
            rootConsole.UpdateView += OnUpdate;                          // Set up a handler for graphic engine Update event

            MessageLog.Add("The rogue arrives on level " + mapLevel);
            MessageLog.Add("Level created with seed '" + seed + "'");

            GenerateMap();
            rootConsole.SetPlayer(Player);
            World.UpdatePlayerFieldOfView(Player);
            Draw();
        }
    IEnumerator Start()
    {
        while (!Display.IsInitialized())
        {
            yield return(null);
        }
        GameObject.Find("Main Camera").GetComponent <Camera>().orthographicSize = 41;
        int seed = (int)DateTime.UtcNow.Ticks;

        Random     = new DotNetRandom(seed);
        text       = GameObject.Find("massageText").GetComponent <Text>();
        text.color = Color.white;

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

        Player           = new Player();
        SchedulingSystem = new SchedulingSystem();

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

        DungeonMap = mapGenerator.CreateMap();

        EquipmentItems = GameObject.Find("equipmentItems");
        AbilitiesItems = GameObject.Find("abilitiesItems");
        ItemItems      = GameObject.Find("itemItems");

        PlayerStat  = GameObject.Find("playerStat");
        MonsterStat = GameObject.Find("monsterStat");
        MonsterItem = Resources.Load <GameObject>("Prefabs/monsterItem");

        CommandSystem   = new CommandSystem();
        TargetingSystem = new TargetingSystem();

        Player.Item1 = new RevealMapScroll();
        Player.Item2 = new RevealMapScroll();

        StartCoroutine(OnRootConsoleUpdate());
        StartCoroutine(OnRootConsoleRender());
    }