상속: CellEffectBase
예제 #1
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = HorizontalAlignment.Left;
            //SetTitle(" Characters ", HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnEscKey       = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar = new ScrollBar(Orientation.Vertical, 16)
            {
                Position = new Point(17, 1),
                Name     = "ScrollBar",
                Maximum  = Font.Rows - 16,
                Value    = 0
            };
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = Font.Rows > 16;

            // Add all controls
            Add(_charScrollBar);

            _closeButton = new Button(6, 1)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect = new Recolor
            {
                Foreground = Color.Blue,
                Background = Color.DarkGray
            };

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            Theme = SadConsole.Themes.Library.Default.WindowTheme.Clone();
            Theme.BorderLineStyle = CellSurface.ConnectedLineThick;

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            //Invalidate();
        }
예제 #2
0
파일: Map.cs 프로젝트: Thraka/SadConsole
        public MapConsole(int width, int height)
            : base(width, height)
        {
            // Create the map
            IMapCreationStrategy<Map> mapCreationStrategy = new RandomRoomsMapCreationStrategy<Map>(width, height, 100, 15, 4);
            map = Map.Create(mapCreationStrategy);

            mapData = new SadConsole.CellAppearance[width, height];

            foreach (var cell in map.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    // Our local information about each map square
                    mapData[cell.X, cell.Y] = new MapObjects.Floor();
                    // Copy the appearance we've defined for Floor or Wall or whatever, to the actual console data that is rendered
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
                else
                {
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
            }

            // Create map effects
            explored = new SadConsole.Effects.Recolor();
            explored.Background = Color.White * 0.3f;
            explored.Foreground = Color.White * 0.3f;
            explored.Update(10d); // Trickery to force the fade to complete to the destination color.

            // Entities
            entities = new List<SadConsole.Game.GameObject>();

            // Create the player
            player = new Entities.Player();
            var tempCell = GetRandomEmptyCell();
            player.Position = new Microsoft.Xna.Framework.Point(tempCell.X, tempCell.Y);
            player.RenderOffset = this.Position;
            entities.Add(player);

            // Create a hound
            GenerateHound();
            GenerateHound();
            GenerateHound();

            // Initial view
            UpdatePlayerView();

            // Keyboard setup
            SadConsole.Engine.Keyboard.RepeatDelay = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f;
        }
예제 #3
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = System.Windows.HorizontalAlignment.Left;
            //SetTitle(" Characters ", System.Windows.HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnESC          = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar               = ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, 16);
            _charScrollBar.Position      = new Point(17, 1);
            _charScrollBar.Name          = "ScrollBar";
            _charScrollBar.Maximum       = textSurface.Font.Rows - 16;
            _charScrollBar.Value         = 0;
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = textSurface.Font.Rows > 16;

            // Add all controls
            this.Add(_charScrollBar);

            _closeButton = new Button(6)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect            = new Recolor();
            highlightedEffect.Foreground = Color.Blue;
            highlightedEffect.Background = Color.DarkGray;

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            Redraw();
        }
예제 #4
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = HorizontalAlignment.Left;
            //SetTitle(" Characters ", HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnEscKey       = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar = new ScrollBar(Orientation.Vertical, 16)
            {
                Position = new Point(17, 1),
                Name     = "ScrollBar",
                Maximum  = Font.Rows - 16,
                Value    = 0
            };
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = Font.Rows > 16;

            // Add all controls
            Add(_charScrollBar);

            _closeButton = new Button(6, 1)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect = new Recolor
            {
                Foreground = Color.Blue,
                Background = Color.DarkGray
            };

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            Theme = SadConsole.Themes.Library.Default.WindowTheme.Clone();
            Theme.BorderLineStyle = CellSurface.ConnectedLineThick;

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            //Invalidate();


            // Get the existing colors object
            var colors = SadConsole.Themes.Colors.CreateAnsi();

            // Use a common background color
            var backgroundColor = Color.Black;

            // Assign the background color to both the hosts (console) and controls
            colors.ControlHostBack = backgroundColor;
            colors.ControlBack     = backgroundColor;

            // Build other colors used by themes based on the background color
            colors.ControlBackLight = (backgroundColor * 1.3f).FillAlpha();
            colors.ControlBackDark  = (backgroundColor * 0.7f).FillAlpha();

            // When a control is selected, a color indicates it. this is either some other color or a lighter color
            // the colors object also defines a palette of colors, we'll use this.
            colors.ControlBackSelected = colors.GrayDark;

            // Build the colors into theme objects for control appearance states
            colors.RebuildAppearances();

            _characterSurface          = new DrawingSurface(16, 16);
            _characterSurface.Position = new Point(1, 1);
            _characterSurface.OnDraw   = (ds) =>
            {
                ds.Surface.Effects.UpdateEffects(Global.GameTimeElapsedUpdate);

                if (hasDrawn)
                {
                    return;
                }

                ds.Surface.Fill(Foreground, Background, 0);

                int charIndex = fontRowOffset * 16;
                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        ds.Surface.SetGlyph(x, y, charIndex);
                        charIndex++;
                    }
                }
                hasDrawn = true;
            };
            _characterSurface.MouseMove          += _characterSurface_MouseMove;
            _characterSurface.MouseButtonClicked += _characterSurface_MouseButtonClicked;
            _characterSurface.MouseExit          += _characterSurface_MouseExit;
            Add(_characterSurface);

            ThemeColors = colors;
            IsDirty     = true;
        }