private void AddStatistic(bool winner)
        {
            _rewardConsole.Fill(DefaultForeground, new Color(0, 0, 0, 0), null);
            _rewardConsole.Print(1, 0, "Statistics", Color.Gold);
            _rewardConsole.Print(1, 1, $"Monsters", Color.DarkGray);

            _rewardConsole.Print(12, 1, $"{_mogwai.Adventure.MonstersList.Count(p => p.IsDead)}/{_mogwai.Adventure.MonstersList.Count()}".PadLeft(6), Color.LimeGreen);
            _rewardConsole.Print(19, 1, $"owned", Color.Gainsboro);
            _rewardConsole.Print(1, 2, $"Exploration", Color.DarkGray);
            _rewardConsole.Print(12, 2, $"{_mogwai.Adventure.Map.GetExplorationState():0}".PadLeft(6), Color.LimeGreen);
            _rewardConsole.Print(19, 2, $"%", Color.Gainsboro);
            _rewardConsole.Print(1, 3, $"Treasures", Color.DarkGray);
            _rewardConsole.Print(12, 3, $"0/0".PadLeft(6), Color.LimeGreen);
            _rewardConsole.Print(19, 3, $"found", Color.Gainsboro);
            _rewardConsole.Print(1, 4, $"Overall", Color.DarkGray);
            _rewardConsole.Print(12, 4, $"1".PadLeft(6), Color.LimeGreen);
            _rewardConsole.Print(19, 4, $"x", Color.Gainsboro);
            _rewardConsole.Print(1, 5, $"Dungeon", Color.DarkGray);
            _rewardConsole.Print(12, 5, winner ? "CLEARED" : "FAILED".PadLeft(8), winner ? Color.LimeGreen : Color.Red);
            //_rewardConsole.Print(19, 5, $"", Color.Gainsboro);

            if (winner && _mogwai.Adventure.Reward != null)
            {
                _rewardConsole.Print(1, 7, $"REWARD", Color.Gainsboro);
                _rewardConsole.Print(12, 7, $"{_mogwai.Adventure.Reward.Gold}".PadLeft(6), Color.Gold);
                _rewardConsole.Print(19, 7, $"Gold", Color.Gold);
                _rewardConsole.Print(1, 8, $"REWARD", Color.Gainsboro);
                _rewardConsole.Print(12, 8, $"{_mogwai.Adventure.Reward.Exp}".PadLeft(6), Color.Gold);
                _rewardConsole.Print(19, 8, $"XP", Color.Gold);
            }
        }
        public CustomAdventure(MogwaiController mogwaiController, MogwaiKeys mogwaiKeys, int width, int height) : base("Adventure", "", width, height)
        {
            _controller = mogwaiController;
            _mogwaiKeys = mogwaiKeys;
            _mogwai     = _mogwaiKeys.Mogwai;

            _adventureFont = Global.LoadFont("Phoebus16.font").GetFont(Font.FontSizes.One);

            //_mapConsole = new Console(75, 75) { Position = new Point(17, 2) };
            _mapConsole = new Console(100, 100)
            {
                Position  = new Point(-24, 0),
                Font      = _adventureFont,
                IsVisible = false
            };
            Children.Add(_mapConsole);

            _entityManager = new SadConsole.Entities.EntityManager {
                Parent = _mapConsole
            };

            _statsConsole = new MogwaiConsole("stats", "", 21, 6)
            {
                Position = new Point(70, 16)
            };
            _statsConsole.Fill(DefaultForeground, new Color(10, 10, 10, 230), null);
            Children.Add(_statsConsole);
        }
Example #3
0
 public static void Log(object message, byte level)
 {
     // log in file
     File.AppendAllText("log.txt", String.Format("{0} {1} ms - {2}: {3}\r\n", DateTime.Now, DateTime.Now.Millisecond, level, message));
     // clear log
     console.Fill(new Rectangle(0, window_height - log_history.Length, window_width, log_history.Length), Color.Silver, Color.Black, 0, 0);
     for (int i = log_history.Length - 1; 0 <= i; i--)
     {
         // select next log message
         Tuple <string, byte> t = i == 0 ? new Tuple <string, byte>(message.ToString(), level) : log_history[i - 1];
         if (t != null)
         {
             LogMessage(t.Item1, t.Item2, i);
         }
         // move logs up / add message to log history
         log_history[i] = t;
     }
 }
Example #4
0
        static void Init()
        {
            var console = new Console(80, 25);

            console.FillWithRandomGarbage();
            console.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, 0);
            console.Print(4, 4, "Hello from SadConsole");

            SadConsole.Global.CurrentScreen = console;
        }
Example #5
0
        private static void Init()
        {
            // Any startup code for your game. We will use an example console for now
            Console startingConsole = new Console(Width, Height);

            startingConsole.FillWithRandomGarbage();
            startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None);
            startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            // Set our new console as the main object SadConsole processes
            SadConsole.Global.CurrentScreen = startingConsole;
        }
Example #6
0
        private static void Init()
        {
            // Any custom loading and prep. We will use a sample console for now

            SadConsole.Console startingConsole = new Console(80, 25);
            startingConsole.FillWithRandomGarbage();
            startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0);
            startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            // Set our new console as the thing to render and process
            SadConsole.Global.CurrentScreen = startingConsole;
        }
        public SelectionScreen(MogwaiController mogwaiController, int width, int height) : base(width, height)
        {
            _borderSurface = new Basic(width + 2, height + 2, Font);
            _borderSurface.DrawBox(new Rectangle(0, 0, _borderSurface.Width, _borderSurface.Height),
                                   new Cell(Color.DarkCyan, Color.Black), null, ConnectedLineThick);
            _borderSurface.Position = new Point(-1, -1);
            Children.Add(_borderSurface);

            _controlsConsole = new ControlsConsole(110, 1)
            {
                Position = new Point(0, 24)
            };
            _controlsConsole.Fill(Color.DarkCyan, Color.Black, null);
            Children.Add(_controlsConsole);

            _infoConsole = new MogwaiConsole("Info", "", 24, 38)
            {
                Position = new Point(113, -8)
            };
            Children.Add(_infoConsole);

            _debugConsole = new Console(24, 38)
            {
                Position = new Point(113, 22)
            };
            _debugConsole.Fill(Color.Beige, Color.TransparentBlack, null);
            _debugConsole.Print(1, 1, $"Debug Console [{Coloring.Gold("     ")}]:");
            _debugConsole.Print(1, 2, $"..armors: {Armors.Instance.AllBuilders().Count}");
            _debugConsole.Print(1, 3, $"..weapns: {Weapons.Instance.AllBuilders().Count}");
            _debugConsole.Print(1, 4, $"..mnstrs: {Monsters.Instance.AllBuilders().Count}");
            Children.Add(_debugConsole);


            _logConsole = new MogwaiConsole("Log", "", 110, 3)
            {
                Position = new Point(0, 27)
            };
            Children.Add(_logConsole);

            HeaderPosition  = 1;
            TrailerPosition = height - 2;

            CreateHeader();
            CreateTrailer();

            _controller    = mogwaiController;
            _transferFunds = 2;

            Init();
        }
        private MogwaiChooseButton CreateChoice(int index, int row, string name, string description, string pathIcon, AdventureType adventureType)
        {
            var choiceConsole = new Console(32, 7)
            {
                Position = new Point(13 + row * 45, 0 + index * 7)
            };

            choiceConsole.Fill(Color.TransparentBlack, Color.Black, null);
            choiceConsole.Print(0, 0, name, Color.White);
            choiceConsole.Print(0, 1, $"[c:g b:darkred:black:black:{description.Length}]" + description, Color.DarkGray);
            Children.Add(choiceConsole);

            var controls = new ControlsConsole(10, 5)
            {
                Position = new Point(-12, 1)
            };

            controls.Fill(Color.Transparent, Color.DarkGray, null);
            choiceConsole.Children.Add(controls);
            var button = new MogwaiChooseButton(10, 5)
            {
                Position = new Point(0, 0)
            };

            button.Click += (btn, args) => { DoAction(adventureType); };
            controls.Add(button);
            button.Unselect();

            // Load the logo
            System.IO.Stream imageStream = TitleContainer.OpenStream(pathIcon);
            var image = Texture2D.FromStream(Global.GraphicsDevice, imageStream);

            imageStream.Dispose();

            Font pictureFont = Global.LoadFont("Cheepicus12.font").GetFont(Font.FontSizes.Quarter);

            // Configure the logo
            SadConsole.Surfaces.Basic consoleImage = image.ToSurface(pictureFont, true);
            consoleImage.Position = new Point(85 + row * 75, 12 + 30 * index);
            //consoleImage.Tint = Color.DarkSlateBlue;
            controls.Children.Add(consoleImage);

            return(button);
        }
Example #9
0
        private static void Init()
        {
            // Load the fonts
            _kenneyFont           = Global.LoadFont("Fonts/Kenney/Kenney.font");
            _kenneyFontCharacters = Global.LoadFont("Fonts/Kenney/KenneyCharacters.font");
            _cheepicusFont        = Global.LoadFont("Fonts/DwarfFortress/Cheepicus.font");

            _console   = new Console(Width, Height, _kenneyFont.GetFont(Font.FontSizes.One));
            _uiConsole = new Console(Width, Height, _cheepicusFont.GetFont(Font.FontSizes.One));

            _uiConsole.Parent = _console;

            // Any startup code for your game. We will use an example console for now
            _uiConsole.FillWithRandomGarbage();
            _uiConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None);
            _uiConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);

            Global.CurrentScreen = _console;
        }
Example #10
0
        public SerializationTests()
        {
            controlsConsole = new ControlsConsole(80, 4);

            masterView = new Console(34, 15);
            loadedView = new Console(34, 15);

            masterView.Fill(Color.White, Color.Red, 0);
            loadedView.Fill(Color.White, Color.Blue, 0);

            UseMouse = true;

            // Add the consoles to the list.
            Children.Add(controlsConsole);
            Children.Add(masterView);
            Children.Add(loadedView);

            // Setup main view
            masterView.Position = new Point(3, 6);

            // Setup sub view
            loadedView.Position = new Point(80 - 37, 6);


            // Setup controls
            controlsConsole.Position = new Point(0, 0);

            optionButtonSurface = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface",
                Position = new Point(1, 1),
            };
            optionButtonSurface.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonSurface);

            optionButtonView = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface View",
                Position = new Point(1, 2)
            };
            optionButtonView.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonView);

            optionButtonLayered = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Layered Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 1)
            };
            optionButtonLayered.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonLayered);

            optionButtonAnimated = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Animated Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 2)
            };
            optionButtonAnimated.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonAnimated);

            var buttonSave = new SadConsole.Controls.Button(17)
            {
                Text     = "Save and Load",
                Position = new Point(controlsConsole.Width - 19, 1)
            };

            buttonSave.Click += ButtonSave_Click;
            controlsConsole.Add(buttonSave);

            basicSurface    = new SadConsole.Surfaces.BasicSurface(34, 15);
            layeredSurface  = new SadConsole.Surfaces.LayeredSurface(34, 15, 3);
            animatedSurface = SadConsole.GameHelpers.Animations.CreateStatic(34, 15, 15, 0.3d);
            viewSurface     = new SadConsole.Surfaces.SurfaceView(basicSurface, new Rectangle(5, 2, 34 - 10, 15 - 4));
            emptySurface    = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface;

            MakeBasicSurface();
            MakeLayeredSurface();
        }
Example #11
0
        static void Init()
        {
            var fontMaster = SadConsole.Global.LoadFont("Fonts/font-sample_extended.font");

            SadConsole.Global.FontDefault = fontMaster.GetFont(Font.FontSizes.One);

            var console = new Console(80, 25);

            console.Fill(Color.White, Color.Black, 0);

            Cell          cell     = new Cell(Color.White, Color.Black, 10);
            CellDecorator cellDec1 = new CellDecorator(Color.White, 256, Microsoft.Xna.Framework.Graphics.SpriteEffects.None);
            CellDecorator cellDec2 = new CellDecorator(Color.White, 257, Microsoft.Xna.Framework.Graphics.SpriteEffects.None);
            CellDecorator cellDec3 = new CellDecorator(Color.White, 258, Microsoft.Xna.Framework.Graphics.SpriteEffects.None);
            CellDecorator cellDec4 = new CellDecorator(Color.White, 259, Microsoft.Xna.Framework.Graphics.SpriteEffects.None);

            CellDecorator[] cDArray = new CellDecorator[4];
            cDArray[0] = cellDec1;
            cDArray[1] = cellDec2;
            cDArray[2] = cellDec3;
            cDArray[3] = cellDec4;
            CellState cellState = new CellState(Color.White, Color.Black, 10, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, true, cDArray);

            cell.RestoreState(ref cellState);

            console.IsFocused = true;
            console.Components.Add(new MyKeyboardComponent());

            Player.Entity          = new SadConsole.Entities.Entity(Color.White, Color.Black, 64);
            Player.Entity.Parent   = console;
            Player.Entity.Position = new Point(5, 2);
            Player.MovementHandler = new MovementHandler(new Point(5, 2), 0);

            console.Print(7, 7, "A", Color.White, Color.Black);
            console.SetDecorator(7, 7, 1, cDArray);

            Map maptest = new Map(80, 25);

            World.ActualMap = maptest;
            Random rnd = new Random();

            for (int i = 0; i < 80; i++)
            {
                for (int j = 0; j < 25; j++)
                {
                    TerrainInfo ti = new TerrainInfo();
                    ti.Height        = 0;
                    ti.PassableNorth = true;
                    ti.PassableWest  = true;
                    ti.PassableSouth = true;
                    ti.PassableEast  = true;
                    ti.Obstacle      = rnd.NextDouble() > 0.7;
                    if (j == 0 || j == 24 || i == 0 || i == 79)
                    {
                        ti.Obstacle = true;
                    }
                    maptest[i, j] = ti;
                }
            }
            maptest.Refresh();

            maptest.MapConsole.Parent   = console;
            maptest.MapConsole.Position = new Point(0, 0);

            SadConsole.Global.CurrentScreen = console;
        }
        private void Init()
        {
            splashConsole = new Console(140, 40);
            ShowIntro(splashConsole);
            splashConsole.Tint = Color.Black;

            const string textTemplate = "Pete's House of Code";
            var          text         = new System.Text.StringBuilder(Width * Height);

            for (var i = 0; i < Width * Height; i++)
            {
                text.Append(textTemplate);
            }

            Print(0, 0, text.ToString(), Color.Black, Color.Transparent);

            using (var imageStream = Microsoft.Xna.Framework.TitleContainer.OpenStream("Resources/PHOC-Splash.png"))
            {
                using (var image = Texture2D.FromStream(Global.GraphicsDevice, imageStream))
                {
                    var logo = image.ToSurface(Global.FontDefault, true);

                    consoleImage         = Console.FromSurface(logo, Global.FontDefault);
                    consoleImagePosition = new Point(Width / 2 - consoleImage.Width / 2, -1);
                    //consoleImage.Tint = Color.Black;
                    consoleImage.Fill(Color.Black, null, null);
                }
            }

            Children.Add(consoleImage);
            consoleImage.Position = consoleImagePosition;

            var animation = new InstructionSet()
                            .Wait(TimeSpan.FromSeconds(0.2d))
                            .Code(MoveGradient)
                            .Code((console, delta) =>
            {
                Children.Clear();
                console.Fill(Color.Black, Color.Transparent, 0);
                return(true);
            })
                            .Wait(TimeSpan.FromSeconds(2.5))
                            .Instruct(new FadeTextSurfaceTint(
                                          splashConsole,
                                          new ColorGradient(Color.Black, Color.Transparent),
                                          TimeSpan.FromSeconds(2)))
                            .Wait(TimeSpan.FromSeconds(3))
                            .InstructConcurrent(new FadeTextSurfaceTint(splashConsole,
                                                                        new ColorGradient(Color.Transparent, Color.Black),
                                                                        TimeSpan.FromSeconds(2)),

                                                new FadeTextSurfaceTint(this,
                                                                        new ColorGradient(Color.Transparent, Color.Black),
                                                                        TimeSpan.FromSeconds(1.0d)))

                            // Animation has completed, call the callback this console uses to indicate it's complete
                            .Code((con, delta) => { SplashDone.Invoke(); return(true); })
            ;

            animation.Finished += (s, e) => Components.Remove(animation);

            Components.Add(animation);
        }
        public SerializationTests() : base(80, 23)
        {
            //Settings.SerializationIsCompressed = true;
            _controlsConsole = new ControlsConsole(80, 4);

            masterView = new Console(34, 15);
            loadedView = new Console(34, 15);

            masterView.Fill(Color.White, Color.Red, 0);
            loadedView.Fill(Color.White, Color.Blue, 0);

            UseMouse = true;

            // Add the consoles to the list.
            Children.Add(_controlsConsole);
            Children.Add(masterView);
            Children.Add(loadedView);

            // Setup main view
            masterView.Position = new Point(3, 6);

            // Setup sub view
            loadedView.Position = new Point(80 - 37, 6);


            // Setup controls
            _controlsConsole.Position = new Point(0, 0);

            optionButtonSurface = new SadConsole.UI.Controls.RadioButton(18, 1)
            {
                Text     = "Surface",
                Position = new Point(1, 1),
            };
            optionButtonSurface.IsSelectedChanged += OptionButton_IsSelectedChanged;
            _controlsConsole.Controls.Add(optionButtonSurface);

            optionButtonView = new SadConsole.UI.Controls.RadioButton(18, 1)
            {
                Text     = "Surface View",
                Position = new Point(1, 2)
            };
            optionButtonView.IsSelectedChanged += OptionButton_IsSelectedChanged;
            _controlsConsole.Controls.Add(optionButtonView);

            optionButtonAnimated = new SadConsole.UI.Controls.RadioButton(21, 1)
            {
                Text     = "Animated Surface",
                Position = new Point(optionButtonSurface.Bounds.MaxExtentX + 1, 2)
            };
            optionButtonAnimated.IsSelectedChanged += OptionButton_IsSelectedChanged;
            _controlsConsole.Controls.Add(optionButtonAnimated);

            var buttonSave = new SadConsole.UI.Controls.Button(17, 1)
            {
                Text     = "Save and Load",
                Position = new Point(_controlsConsole.Width - 19, 1)
            };

            buttonSave.Click += ButtonSave_Click;
            _controlsConsole.Controls.Add(buttonSave);

            basicSurface = new SadConsole.Console(34, 15);

            animatedSurface = SadConsole.AnimatedScreenSurface.CreateStatic(34, 15, 15, 0.3d);
            viewSurface     = new Console(((CellSurface)basicSurface.Surface).GetSubSurface(new Rectangle(5, 2, 34 - 10, 15 - 4)));
            //emptySurface = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface;

            MakeBasicSurface();

            optionButtonSurface.IsSelected = true;
        }