示例#1
0
        // Grows the Snake by one
        public void Grow( )
        {
            // Create Animated surface for a Tail piece
            var _tail = new SadConsole.Surfaces.Animated("default", 1, 1);

            _tail.CreateFrame();
            _tail.CurrentFrame[0].Glyph      = 9;
            _tail.CurrentFrame[0].Foreground = Color.LawnGreen;
            _tail.CurrentFrame[0].Background = Color.Transparent;
            Entity tail = new Entity(_tail);


            if (Tail.Count >= 1)
            {
                // Copy position from previous Tail piece
                tail.Position = Tail[Tail.Count - 1].Position;
            }
            else
            {
                // If its the very first Tail piece copy position from Snake object
                tail.Position = Position;
            }
            // Add to Tail list and register to Entities collection
            Tail.Add(tail);
            SnakeBoard.EntityManager.Entities.Add(tail);
        }
示例#2
0
        public SerializationTests() : base(80, 23)
        {
            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, 1)
            {
                Text     = "Save and Load",
                Position = new Point(controlsConsole.Width - 19, 1)
            };

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

            basicSurface = new SadConsole.Surfaces.Basic(34, 15);

            animatedSurface = SadConsole.Surfaces.Animated.CreateStatic(34, 15, 15, 0.3d);
            viewSurface     = new Basic(1, 1);
            viewSurface.SetViewFromSurface(new Rectangle(5, 2, 34 - 10, 15 - 4), basicSurface);
            //emptySurface = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface;

            MakeBasicSurface();
            MakeLayeredSurface();
        }