Пример #1
0
        public FadingChild() : base(80, 23)
        {
            Surface.FillWithRandomGarbage(Font);

            _child = new ScreenSurface(30, 13);
            _child.Surface.DefaultForeground = Color.White;
            _child.Surface.DefaultBackground = Color.Black;
            _child.Surface.Clear();
            _child.Surface.DrawBox(_child.Surface.View, new ColoredGlyph(Color.MediumPurple, Color.Black), connectedLineStyle: ICellSurface.ConnectedLineThick);
            _child.Surface.Print(2, 2, "Transparent console");
            _child.Position = (40, 4);

            Children.Add(_child);

            _childTint = new ScreenSurface(30, 13);
            _childTint.Surface.DefaultForeground = Color.White;
            _childTint.Surface.DefaultBackground = Color.Black;
            _childTint.Surface.Clear();
            _childTint.Surface.DrawBox(_child.Surface.View, new ColoredGlyph(Color.MediumPurple, Color.Black), connectedLineStyle: ICellSurface.ConnectedLineThick);
            _childTint.Surface.Print(2, 2, "Tinted console");
            _childTint.Position = (4, 4);

            Children.Add(_childTint);

            _set = new SadConsole.Instructions.InstructionSet()

                   .Instruct(new SadConsole.Instructions.AnimatedValue(TimeSpan.FromSeconds(1.5), 255, 0, new SadConsole.EasingFunctions.Linear()))
                   .Instruct(new SadConsole.Instructions.AnimatedValue(TimeSpan.FromSeconds(1.5), 0, 255, new SadConsole.EasingFunctions.Linear()))
            ;

            _set.RepeatCount = -1;

            SadComponents.Add(_set);
            //_child.Tint = new Color(0, 127, 0, 127);
        }
Пример #2
0
        public ViewsAndSubViews()
        {
            mainView = new ScreenSurface(60, 23);
            subView  = new ScreenSurface(mainView.Surface.GetSubSurface(new Rectangle(0, 0, 20, 23)));

            IsVisible = false;
            UseMouse  = true;

            mainView.Surface.DrawLine(new Point(59, 0), new Point(59, 22), SadConsole.ICellSurface.ConnectedLineThin[(int)SadConsole.ICellSurface.ConnectedLineIndex.Left], Color.White);

            // Setup main view
            mainView.Position   = new Point(0, 0);
            mainView.MouseMove += (s, e) => { if (e.Mouse.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Blue; mainView.IsDirty = true;
                                              }
            };
            mainView.Surface.IsDirtyChanged += (s, e) => subView.IsDirty = true;

            // Setup sub view
            subView.Position = new Point(60, 0);
            //subView.SetViewFromSurface(new Rectangle(0, 0, 20, 23), mainView);
            subView.MouseMove += (s, e) => { if (e.Mouse.LeftButtonDown)
                                             {
                                                 e.Cell.Background = Color.Red; subView.IsDirty = true;
                                             }
            };
            subView.Surface.IsDirtyChanged += (s, e) => mainView.IsDirty = true;

            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);
        }
Пример #3
0
        public ShapesConsole()
            : base(80, 23)
        {
            UseKeyboard = false;

            Surface.DrawLine(new Point(2, 2), new Point(Surface.ViewWidth - 4, 2), (int)'=', Color.Yellow);
            Surface.DrawBox(new Rectangle(2, 4, 6, 6), new ColoredGlyph(Color.Yellow, Color.Black, '='));
            Surface.DrawBox(new Rectangle(9, 4, 6, 6), new ColoredGlyph(Color.Yellow, Color.Black, '='), connectedLineStyle: ICellSurface.ConnectedLineThin);
            Surface.DrawBox(new Rectangle(16, 4, 6, 6), new ColoredGlyph(Color.Yellow, Color.Black, '='), connectedLineStyle: ICellSurface.ConnectedLineThick);
            Surface.DrawBox(new Rectangle(23, 4, 6, 6), new ColoredGlyph(Color.Black, Color.Yellow, '='), new ColoredGlyph(Color.Black, Color.Yellow, 0), connectedLineStyle: ICellSurface.ConnectedLineThick);

            Surface.DrawCircle(new Rectangle(2, 12, 16, 10), new ColoredGlyph(Color.White, Color.Black, 176));
            Surface.DrawCircle(new Rectangle(19, 12, 16, 10), new ColoredGlyph(Color.White, Color.Black, 176), new ColoredGlyph(Color.Green, Color.Black, 178));

            IsDirty   = true;
            IsVisible = false;

            _mouseCursor = new SadConsole.ScreenSurface(1, 1);
            _mouseCursor.Surface.SetGlyph(0, 0, 178);
            _mouseCursor.UseMouse = false;

            UseMouse = true;

            Children.Add(_mouseCursor);
        }
Пример #4
0
        public ScreenSurface CreateRender(Point?viewSize = null)
        {
            var(viewWidth, viewHeight) = viewSize ?? (Width, Height);
            var cellSurface = new CellSurface(viewWidth, viewHeight, 100, 100);

            _renderer       = new ScreenSurface(cellSurface);
            _entityRenderer = new Renderer();
            _renderer.SadComponents.Add(_entityRenderer);
            _renderer.SadComponents.Add(new MapRendererMouseProcessor(this));

            // add any entity associated with the map the to entity renderer
            _entityRenderer.AddRange(Entities.Items.Cast <Entity>());
            return(_renderer);
        }
        /// <inheritdoc/>
        public override void Update(TimeSpan delta)
        {
            base.Update(delta);

            if (_activeScreen.IsVisible == false)
            {
                Children.Remove(_activeScreen);

                if (GameHost.Instance._splashScreens.Count != 0)
                {
                    _activeScreen = GameHost.Instance._splashScreens.Dequeue();
                    Children.Add(_activeScreen);
                    GameHost.Instance.FocusedScreenObjects.Set(_activeScreen);
                }
                else
                {
                    GameHost.Instance.RestoreGlobalState();
                }
            }
        }
Пример #6
0
        private void GenerateMap(Generator mapGen)
        {
            _mapRenderer          = Map.CreateRender(Game.MapRenderSize);
            _mapRenderer.Position = (Game.PlayerStatSize.X, 0);
            Children.Add(_mapRenderer);

            Map.ApplyTerrainOverlay(mapGen.Context.GetFirst <IGridView <bool> >("WallFloor"), GetTerrain);

            var randomPosition = Map.WalkabilityView.RandomPosition(true);

            Game.Player        = new Player(Map, randomPosition);
            Game.Player.Moved += OnPlayerMoved;

            for (var i = 0; i < 10; i++)
            {
                var randomPos = Map.WalkabilityView.RandomPosition(true);
                var zombie    = Zombie.Create(Map, randomPos, 1);
            }

            Map.PlayerFOV.Calculate(Game.Player.Position, 10);
            _mapRenderer.Surface.View = _mapRenderer.Surface.View.WithCenter(Game.Player.Position);
        }