예제 #1
0
        public CharacterPicker(Color foreground, Color fill, Color selectedCharacterColor)
            : base(16, 16)
        {
            effectsManager = new SadConsole.Effects.EffectsManager(textSurface);
            textSurface.DefaultForeground = _charForeground = foreground;
            textSurface.DefaultBackground = _fill = fill;
            Clear();

            this.CanUseMouse = true;

            _selectedCharColor = selectedCharacterColor;

            //_characterSurface = new SadConsole.Controls.DrawingSurface(16, 16);
            //_characterSurface.DefaultBackground = fill;
            //_characterSurface.DefaultForeground = foreground;
            //_characterSurface.Clear();

            _selectedCharEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground = true,
                UseCellBackground = false,
                DestinationBackground = new ColorGradient(_fill, _selectedCharColor * 0.8f),
                FadeDuration = 2d,
                CloneOnApply = false,
                AutoReverse = true,
                Repeat = true,
            };

            SelectedCharacter = 1;
        }
예제 #2
0
        public BoxTool()
        {
            animSinglePoint = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            var _frameSinglePoint = animSinglePoint.CreateFrame();
            _frameSinglePoint[0].GlyphIndex = 42;

            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            _settingsPanel = new BoxToolPanel();

            ControlPanels = new CustomPanel[] { _settingsPanel };

            //
            Brush = new SadConsole.Game.GameObject();
            Brush.Font = Settings.Config.ScreenFont;
            AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            Brush.Animations.Add(animation.Name, animation);
            Brush.Animation = animation;
        }
예제 #3
0
        public BoxTool()
        {
            animSinglePoint = new AnimatedSurface("single", 1, 1, SadConsoleEditor.Settings.Config.ScreenFont);
            var _frameSinglePoint = animSinglePoint.CreateFrame();

            _frameSinglePoint[0].Glyph = 42;


            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground    = true,
                FadeDuration      = 1f,
                AutoReverse       = true
            };

            _settingsPanel = new BoxToolPanel();

            ControlPanels = new CustomPanel[] { _settingsPanel };

            //
            Brush = new SadConsole.GameHelpers.GameObject(1, 1, SadConsoleEditor.Settings.Config.ScreenFont);
            AnimatedSurface animation = new AnimatedSurface("single", 1, 1, SadConsoleEditor.Settings.Config.ScreenFont);

            animation.CreateFrame()[0].Glyph = 42;
            Brush.Animations.Add(animation.Name, animation);
            Brush.Animation = animation;
        }
예제 #4
0
        public CharacterPicker(Color foreground, Color fill, Color selectedCharacterColor) : base(16, 16)
        {
            effectsManager = new SadConsole.Effects.EffectsManager(textSurface);
            textSurface.DefaultForeground = _charForeground = foreground;
            textSurface.DefaultBackground = _fill = fill;
            Clear();


            this.UseMouse = true;

            _selectedCharColor = selectedCharacterColor;

            //_characterSurface = new SadConsole.Controls.DrawingSurface(16, 16);
            //_characterSurface.DefaultBackground = fill;
            //_characterSurface.DefaultForeground = foreground;
            //_characterSurface.Clear();

            _selectedCharEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                UseCellBackground     = false,
                DestinationBackground = new ColorGradient(_fill, _selectedCharColor * 0.8f),
                FadeDuration          = 2d,
                CloneOnApply          = false,
                AutoReverse           = true,
                Repeat = true,
            };

            SelectedCharacter = 1;
        }
예제 #5
0
 private SadConsole.Effects.Fade CreateFadeAnimation()
 {
     SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
     fadeEffect.AutoReverse           = true;
     fadeEffect.DestinationForeground = Color.Turquoise;
     fadeEffect.FadeForeground        = true;
     fadeEffect.Repeat       = false;
     fadeEffect.FadeDuration = 0.1f;
     return(fadeEffect);
 }
예제 #6
0
        private void RightKeyAnimationCb(CodeInstruction codeInstruction)
        {
            SadConsole.Effects.Fade fadeEffect = CreateFadeAnimation();
            List <Cell>             cells      = new List <Cell>();

            for (int x = phoneButtonColumn3; x < phoneButtonColumn3 + 5; x++)
            {
                for (int y = phoneButtonRow2; y < phoneButtonRow2 + 3; y++)
                {
                    cells.Add(this[x, y]);
                }
            }
            SetEffect(cells, fadeEffect);
        }
예제 #7
0
        private void DownKeyAnimationCb(CodeInstruction codeInstruction)
        {
            SadConsole.Effects.Fade fadeEffect = CreateFadeAnimation();
            List <Cell>             cells      = new List <Cell>();

            for (int x = phoneButtonColumn2; x < phoneButtonColumn2 + 5; x++)
            {
                for (int y = phoneButtonRow3; y < phoneButtonRow3 + 3; y++)
                {
                    cells.Add(textSurface[x, y]);
                }
            }
            SetEffect(cells, fadeEffect);
        }
예제 #8
0

        
예제 #9
0
        public SelectionTool()
        {
            Brush = new LayeredGameObject();

            var animation = new AnimatedSurface(AnimationSingle, 1, 1, SadConsoleEditor.Settings.Config.ScreenFont);

            animation.CreateFrame()[0].Glyph  = 42;
            animation.Frames[0][0].Background = Color.Black;
            Brush.Animations.Add(animation.Name, animation);

            animation = new AnimatedSurface(AnimationSelection, 1, 1, SadConsoleEditor.Settings.Config.ScreenFont);
            Brush.Animations.Add(animation.Name, animation);

            _frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground    = true,
                FadeDuration      = 1f,
                AutoReverse       = true
            };


            _panel = new SelectionToolPanel(LoadBrush, SaveBrush);
            _panel.StateChangedHandler = PanelStateChanged;
            _panel.State = SelectionToolPanel.CloneState.SelectingPoint1;

            _altPanel = new SelectionToolAltPanel();

            ControlPanels = new CustomPanel[] { _panel, _altPanel };

            _pulseAnimation = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                UseCellBackground     = false,
                DestinationBackground = Color.Transparent,
                FadeDuration          = 2d,
                CloneOnApply          = false,
                AutoReverse           = true,
                Repeat = true,
            };
        }
예제 #10
0
        public CircleTool()
        {
            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            // Configure the animations
            Brush = new SadConsole.Game.GameObject();
            Brush.Font = Settings.Config.ScreenFont;
            AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            Brush.Animations.Add(animation.Name, animation);

            settingsPanel = new CircleToolPanel();
            ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance };
            ResetCircle();
        }
예제 #11
0
        public CircleTool()
        {
            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground    = true,
                FadeDuration      = 1f,
                AutoReverse       = true
            };

            // Configure the animations
            Brush = new SadConsole.GameHelpers.GameObject(1, 1, SadConsoleEditor.Settings.Config.ScreenFont);
            AnimatedSurface animation = new AnimatedSurface("single", 1, 1, SadConsoleEditor.Settings.Config.ScreenFont);

            animation.CreateFrame()[0].Glyph = 42;
            Brush.Animations.Add(animation.Name, animation);

            settingsPanel = new CircleToolPanel();
            ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance };
            ResetCircle();
        }
예제 #12
0
        public SplashScreen()
            : base(80, 25)
        {
            IsVisible = false;

            // Setup the console text background
            string textTemplate = "sole SadCon";
            System.Text.StringBuilder text = new System.Text.StringBuilder(2200);

            for (int i = 0; i < CellData.Width * CellData.Height; i++)
            {
                text.Append(textTemplate);
            }
            this.CellData.Print(0, 0, text.ToString(), Color.Black, Color.Transparent);

            // Load the logo
            System.IO.Stream imageStream = System.IO.File.OpenRead("sad.png");
            var image = Texture2D.FromStream(Engine.Device, imageStream);
            imageStream.Dispose();

            // Configure the logo
            _consoleImage = new CellsRenderer(new CellSurface(image.Width, image.Height), this.Batch);
            _consoleImage.Position = new Point(CellData.Width / 2 - image.Width / 2, -1);
            image.DrawImageToSurface(_consoleImage.CellData, new Point(0,0), true);
            _consoleImage.Tint = Color.Black;

            // Configure the animations
            _animation = new InstructionSet();
            _animation.Instructions.AddLast(new Wait() { Duration = 0.3f });

            // Animation to move the angled gradient spotlight effect.
            var moveGradientInstruction = new CodeInstruction();
            moveGradientInstruction.CodeCallback = (inst) =>
                {
                    _x += 1;

                    if (_x > _cellData.Width + 50)
                    {
                        inst.IsFinished = true;
                    }

                    Color[] colors = new Color[] { Color.Black, Color.DarkBlue, Color.White, Color.DarkBlue, Color.Black };
                    float[] colorStops = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f };

                    Algorithms.GradientFill(CellSize, new Point(_x, 12), 10, 45, new Rectangle(0, 0, CellData.Width, CellData.Height), new ColorGradient(colors, colorStops), _cellData.SetForeground);
                };
            _animation.Instructions.AddLast(moveGradientInstruction);

            // Animation to clear the SadConsole text.
            _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { _cellData.Fill(Color.Black, Color.Transparent, 0, null); i.IsFinished = true; } });

            // Animation for the logo text.
            var logoText = new ColorGradient(new Color[] { Color.Purple, Color.Yellow }, new float[] { 0.0f, 1f }).ToColoredString("[| Powered by SadConsole |]");
            logoText.SetEffect(new SadConsole.Effects.Fade() { DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, Permanent = true, CloneOnApply = true });
            _animation.Instructions.AddLast(new DrawString(this) { Position = new Point(26, this.CellData.Height - 1), Text = logoText, TotalTimeToPrint = 1f, UseConsolesCursorToPrint = false });

            // Animation for fading in the logo picture.
            _animation.Instructions.AddLast(new FadeCellRenderer(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), new TimeSpan(0, 0, 0, 0, 2000)));

            // Animation to blink SadConsole in the logo text
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                    {
                        SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
                        fadeEffect.AutoReverse = true;
                        fadeEffect.DestinationForeground = new ColorGradient(Color.Blue, Color.Yellow);
                        fadeEffect.FadeForeground = true;
                        fadeEffect.Repeat = true;
                        fadeEffect.FadeDuration = 0.7f;

                        List<Cell> cells = new List<Cell>();
                        for (int index = 0; index < 10; index++)
                        {
                            var point = new Point(26, this.CellData.Height - 1).ToIndex(this.CellData.Width) + 14 + index;
                            cells.Add(_cellData[point]);
                        }

                        _cellData.SetEffect(cells, fadeEffect);
                        i.IsFinished = true;
                    }
            });
            
            // Animation to delay, keeping the logo and all on there for 2 seconds, then destroy itself.
            _animation.Instructions.AddLast(new Wait() { Duration = 2.5f });
            _animation.Instructions.AddLast(new FadeCellRenderer(this, new ColorGradient(Color.Transparent, Color.Black), new TimeSpan(0, 0, 0, 0, 2000)));
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    if (this.Parent != null)
                        this.Parent.Remove(this);

                    if (SplashCompleted != null)
                        SplashCompleted();
                }
            });
        }
예제 #13
0
        public SelectionTool()
        {
            Brush = new LayeredGameObject();
            Brush.Font = Settings.Config.ScreenFont;

            var animation = new AnimatedTextSurface(AnimationSingle, 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            animation.Frames[0][0].Background = Color.Black;
            Brush.Animations.Add(animation.Name, animation);

            animation = new AnimatedTextSurface(AnimationSelection, 1, 1, Settings.Config.ScreenFont);
            Brush.Animations.Add(animation.Name, animation);

            _frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            _panel = new SelectionToolPanel(LoadBrush, SaveBrush);
            _panel.StateChangedHandler = PanelStateChanged;
            _panel.State = SelectionToolPanel.CloneState.SelectingPoint1;

            _altPanel = new SelectionToolAltPanel();

            ControlPanels = new CustomPanel[] { _panel, _altPanel };

            _pulseAnimation = new SadConsole.Effects.Fade()
            {
                FadeBackground = true,
                UseCellBackground = false,
                DestinationBackground = Color.Transparent,
                FadeDuration = 2d,
                CloneOnApply = false,
                AutoReverse = true,
                Repeat = true,
            };
        }
예제 #14
0
 private SadConsole.Effects.Fade CreateFadeAnimation()
 {
     SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
     fadeEffect.AutoReverse = true;
     fadeEffect.DestinationForeground = Color.Turquoise;
     fadeEffect.FadeForeground = true;
     fadeEffect.Repeat = false;
     fadeEffect.FadeDuration = 0.1f;
     return fadeEffect;
 }
예제 #15
0
        public EntityLiteConsole()
            : base(80, 23, 160, 46)
        {
            var fadeEffect = new SadConsole.Effects.Fade
            {
                AutoReverse           = true,
                DestinationForeground = new ColorGradient(Color.Blue, Color.Yellow),
                FadeForeground        = true,
                UseCellForeground     = false,
                Repeat           = true,
                FadeDuration     = 0.7f,
                RemoveOnFinished = true,
                CloneOnAdd       = true
            };

            player = new Entity(Color.Yellow, Color.Black, 1, 100)
            {
                //Position = new Point(Surface.BufferWidth / 2, Surface.BufferHeight / 2)
                Position            = new Point(0, 0),
                UsePixelPositioning = usePixelPositioning,
            };

            // If we're allowing smooth movements, add the component
            if (useSmoothMovements)
            {
                player.SadComponents.Add(new SadConsole.Components.SmoothMove(FontSize, new TimeSpan(0, 0, 0, 0, 300)));
            }

            Surface.DefaultBackground = Color.DarkGray;
            Surface.Clear();

            playerPreviousPosition = player.Position;
            SadComponents.Add(new SadConsole.Components.SurfaceComponentFollowTarget()
            {
                Target = player
            });

            entityManager = new Renderer();
            //SadComponents.Add(new SadConsole.Components.SurfaceComponentEntityOffsets());
            SadComponents.Add(entityManager);
            //player.Components.Add(new SadConsole.Components.EntityViewSync());
            entityManager.Add(player);

            //Children.Add(player);
            others = new List <Entity>();
            for (int i = 0; i < 1000; i++)
            {
                var item = new Entity(Color.Red.GetRandomColor(SadConsole.Game.Instance.Random), Color.Black, Game.Instance.Random.Next(0, 60), 0)
                {
                    Position            = GetRandomPosition(),
                    UsePixelPositioning = usePixelPositioning,
                };

                if (useSmoothMovements)
                {
                    item.SadComponents.Add(new SadConsole.Components.SmoothMove(FontSize, new TimeSpan(0, 0, 0, 0, 300)));
                }

                if (Game.Instance.Random.Next(0, 500) < 50)
                {
                    item.Effect = fadeEffect;
                }

                entityManager.Add(item);
                others.Add(item);
            }

            // Setup this console to accept keyboard input.
            UseKeyboard = true;
            IsVisible   = false;
        }
예제 #16
0
        public SplashScreen()
            : base(80, 25)
        {
            IsVisible = false;

            // Setup the console text background
            string textTemplate = "sole SadCon";

            System.Text.StringBuilder text = new System.Text.StringBuilder(2200);

            for (int i = 0; i < CellData.Width * CellData.Height; i++)
            {
                text.Append(textTemplate);
            }
            this.CellData.Print(0, 0, text.ToString(), Color.Black, Color.Transparent);

            // Load the logo
            System.IO.Stream imageStream = System.IO.File.OpenRead("sad.png");
            var image = Texture2D.FromStream(Engine.Device, imageStream);

            imageStream.Dispose();

            // Configure the logo
            _consoleImage          = new CellsRenderer(new CellSurface(image.Width, image.Height), this.Batch);
            _consoleImage.Position = new Point(CellData.Width / 2 - image.Width / 2, -1);
            image.DrawImageToSurface(_consoleImage.CellData, new Point(0, 0), true);
            _consoleImage.Tint = Color.Black;

            // Configure the animations
            _animation = new InstructionSet();
            _animation.Instructions.AddLast(new Wait()
            {
                Duration = 0.3f
            });

            // Animation to move the angled gradient spotlight effect.
            var moveGradientInstruction = new CodeInstruction();

            moveGradientInstruction.CodeCallback = (inst) =>
            {
                _x += 1;

                if (_x > _cellData.Width + 50)
                {
                    inst.IsFinished = true;
                }

                Color[] colors     = new Color[] { Color.Black, Color.DarkBlue, Color.White, Color.DarkBlue, Color.Black };
                float[] colorStops = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f };

                Algorithms.GradientFill(CellSize, new Point(_x, 12), 10, 45, new Rectangle(0, 0, CellData.Width, CellData.Height), new ColorGradient(colors, colorStops), _cellData.SetForeground);
            };
            _animation.Instructions.AddLast(moveGradientInstruction);

            // Animation to clear the SadConsole text.
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) => { _cellData.Fill(Color.Black, Color.Transparent, 0, null); i.IsFinished = true; }
            });

            // Animation for the logo text.
            var logoText = new ColorGradient(new Color[] { Color.Purple, Color.Yellow }, new float[] { 0.0f, 1f }).ToColoredString("[| Powered by SadConsole |]");

            logoText.SetEffect(new SadConsole.Effects.Fade()
            {
                DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, Permanent = true, CloneOnApply = true
            });
            _animation.Instructions.AddLast(new DrawString(this)
            {
                Position = new Point(26, this.CellData.Height - 1), Text = logoText, TotalTimeToPrint = 1f, UseConsolesCursorToPrint = false
            });

            // Animation for fading in the logo picture.
            _animation.Instructions.AddLast(new FadeCellRenderer(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), new TimeSpan(0, 0, 0, 0, 2000)));

            // Animation to blink SadConsole in the logo text
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
                    fadeEffect.AutoReverse             = true;
                    fadeEffect.DestinationForeground   = new ColorGradient(Color.Blue, Color.Yellow);
                    fadeEffect.FadeForeground          = true;
                    fadeEffect.Repeat       = true;
                    fadeEffect.FadeDuration = 0.7f;

                    List <Cell> cells = new List <Cell>();
                    for (int index = 0; index < 10; index++)
                    {
                        var point = new Point(26, this.CellData.Height - 1).ToIndex(this.CellData.Width) + 14 + index;
                        cells.Add(_cellData[point]);
                    }

                    _cellData.SetEffect(cells, fadeEffect);
                    i.IsFinished = true;
                }
            });

            // Animation to delay, keeping the logo and all on there for 2 seconds, then destroy itself.
            _animation.Instructions.AddLast(new Wait()
            {
                Duration = 2.5f
            });
            _animation.Instructions.AddLast(new FadeCellRenderer(this, new ColorGradient(Color.Transparent, Color.Black), new TimeSpan(0, 0, 0, 0, 2000)));
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    if (this.Parent != null)
                    {
                        this.Parent.Remove(this);
                    }

                    if (SplashCompleted != null)
                    {
                        SplashCompleted();
                    }
                }
            });
        }