Наследование: InstructionBase
Пример #1
0
        private bool ProcessTrap()
        {
            if(ItemManager.FindItemInInventory("Necklace") != null)
            {
                return false;
            }

            GameResult = GameResult.Failed;

            // Draw Walls
            foreach(Point wallPoint in currentRoom.Trap.WallPoints)
            {
                this.CellData.SetCharacter(wallPoint.X, wallPoint.Y, 178, Color.White);
            }

            waterXStart = currentRoom.Trap.WaterFlowXStart;
            waterXEnd = currentRoom.Trap.WaterFlowXEnd - 1;
            waterYStart = currentRoom.Trap.WaterFlowYStart;
            waterYEnd = currentRoom.Trap.WaterFlowYEnd;

            // Animate the water
            animation = new InstructionSet();
            animation.Instructions.AddLast(new Wait() { Duration = 0.2f });

            var waterFillInstruction = new CodeInstruction();
            waterFillInstruction.CodeCallback = (inst) =>
            {
                waterXStart += 1;

                if (waterXStart > waterXEnd)
                {
                    inst.IsFinished = true;
                    gameOver = true;
                }
                this.CellData.SetCharacter(waterXStart, waterYStart, 176, Color.White);
                this.CellData.SetCharacter(waterXStart, waterYEnd, 176, Color.White);
            };
            animation.Instructions.AddLast(waterFillInstruction);

            UserMessage userMessage = new UserMessage();
            userMessage.AddLine("You have");
            userMessage.AddLine("sprung a Trap!");
            userMessage.AddLine("The room has");
            userMessage.AddLine("filled with");
            userMessage.AddLine("water and you");
            userMessage.AddLine("drowned!");

            // Kill Character
            this.player.Kill();
            PrintUserMessage(userMessage);
            EndGame();

            return true;
        }
Пример #2
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();
                }
            });
        }
Пример #3
0
        public SnakeConsole()
            : base(50, 60)
        {
            gameSpeed = new TimeSpan(0, 0, 0, 0, gameSpeedMs);
            lastUpdate = DateTime.Now;

            random = new Random();
            this.IsVisible = false;
            gameState = GameState.MenuScreen;

            // Draw outline of phone
            SetGlyph(11, 55, 200, Color.White);
            SetGlyph(39, 55, 188, Color.White);
            for(int i = 12; i < 39; i++)
            {
                SetGlyph(i, 55, 205, Color.White);
            }
            for (int i = 30; i < 55; i++)
            {
                SetGlyph(11, i, 186, Color.White);
                SetGlyph(39, i, 186, Color.White);
            }
            SetGlyph(11, 29, 187, Color.White);
            SetGlyph(39, 29, 201, Color.White);
            SetGlyph(10, 29, 200, Color.White);
            SetGlyph(40, 29, 188, Color.White);
            for (int i = 5; i < 29; i++)
            {
                SetGlyph(10, i, 186, Color.White);
                SetGlyph(40, i, 186, Color.White);
            }
            SetGlyph(10, 4, 201, Color.White);
            SetGlyph(40, 4, 187, Color.White);
            for (int i = 11; i < 40; i++)
            {
                SetGlyph(i, 4, 205, Color.White);
            }

            // Draw Phone Buttons
            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow1, "1");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow1, "2");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow1, "3");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow2, "4");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow2, "5");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow2, "6");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow3, "7");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow3, "8");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow3, "9");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow4, "*");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow4, "0");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow4, "#");

            // Create Animations  AstrickKeyAnimationCb
            astrickKeyAnimation = new InstructionSet();
            CodeInstruction astrickCallback = new CodeInstruction();
            astrickCallback.CodeCallback = AstrickKeyAnimationCb;
            astrickKeyAnimation.Instructions.AddLast(astrickCallback);

            upKeyAnimation = new InstructionSet();
            CodeInstruction upCallback = new CodeInstruction();
            upCallback.CodeCallback = UpKeyAnimationCb;
            upKeyAnimation.Instructions.AddLast(upCallback);

            downKeyAnimation = new InstructionSet();
            CodeInstruction downCallback = new CodeInstruction();
            downCallback.CodeCallback = DownKeyAnimationCb;
            downKeyAnimation.Instructions.AddLast(downCallback);

            leftKeyAnimation = new InstructionSet();
            CodeInstruction leftCallback = new CodeInstruction();
            leftCallback.CodeCallback = LeftKeyAnimationCb;
            leftKeyAnimation.Instructions.AddLast(leftCallback);

            rightKeyAnimation = new InstructionSet();
            CodeInstruction rightCallback = new CodeInstruction();
            rightCallback.CodeCallback = RightKeyAnimationCb;
            rightKeyAnimation.Instructions.AddLast(rightCallback);

            // Draw Microphone
            for (int i = 24; i < 27; i++)
            {
                SetGlyph(i, 53, 240, Color.DarkGray);
            }

            // Draw Plate
            for (int x = 12; x < 39; x++)
            {
                for (int y = 6; y < 28; y++)
                {
                    SetGlyph(x, y, 178, Color.Silver);
                }
            }
            for (int x = 13; x < 38; x++)
            {
                for (int y = 28; y < 30; y++)
                {
                    SetGlyph(x, y, 178, Color.Silver);
                }
            }

            // Draw End and CAll Button
            for (int x = phoneButtonColumn1; x < phoneButtonColumn1 + 7; x++)
            {
                for (int y = 26; y < 29; y++)
                {
                    SetGlyph(x, y, 219, Color.Gray);
                }
            }
            Print(phoneButtonColumn1 + 2, 27, "End", Color.Red, Color.Gray);

            for (int x = phoneButtonColumn3 - 2; x < phoneButtonColumn3 - 2 + 7; x++)
            {
                for (int y = 26; y < 29; y++)
                {
                    SetGlyph(x, y, 219, Color.Gray);
                }
            }
            Print(phoneButtonColumn3 - 1, 27, "Call", Color.Green, Color.Gray);

            // Draw Speaker
            for (int i = 22; i < 29; i++)
            {
                SetGlyph(i, 7, 240, Color.Black, Color.Silver);
            }

            // Draw Brand
            Print(23, 10, "NOKIA", Color.White, Color.Silver);

            // Draw Screen
            ClearScreen();

            // Draw Game Name
            CreateStartMessage();

            player = null;
        }
Пример #4
0
 private void UpKeyAnimationCb(CodeInstruction codeInstruction)
 {
     SadConsole.Effects.Fade fadeEffect = CreateFadeAnimation();
     List<Cell> cells = new List<Cell>();
     for (int x = phoneButtonColumn2; x < phoneButtonColumn2 + 5; x++)
     {
         for (int y = phoneButtonRow1; y < phoneButtonRow1 + 3; y++)
         {
             cells.Add(textSurface[x, y]);
         }
     }
     SetEffect(cells, fadeEffect);
 }
Пример #5
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(_cellData[x, y]);
         }
     }
     _cellData.SetEffect(cells, fadeEffect);
 }