Ejemplo n.º 1
0
        private void Restart()
        {
            canvas = new Canvas(colorCanvasToRestart, graphics.ClientWidth, graphics.ClientHeight);
            canvas.Render(graphics);
            graphics.DrawString("Игра окончена", "Arial", colorTextToRestart1, graphics.ClientWidth - graphics.ClientWidth, graphics.ClientHeight - graphics.ClientHeight, 25);
            graphics.DrawString($"Ваш счёт : {currentScore}", "Arial", colorTextToRestart2, graphics.ClientWidth - graphics.ClientWidth, graphics.ClientHeight - graphics.ClientHeight + 40, 25);
            graphics.DrawString($"Ваш лучший счёт : {maxScore}", "Arial", colorTextToRestart2, graphics.ClientWidth - graphics.ClientWidth, graphics.ClientHeight - graphics.ClientHeight + 80, 25);
            graphics.DrawString("Нажмите Y для рестарта или N для выхода", "Arial", colorTextToRestart2, graphics.ClientWidth - graphics.ClientWidth, graphics.ClientHeight - graphics.ClientHeight + 120, 20);
            graphics.FlipPages();
            bool temp = true;

            do
            {
                if (Input.IsKeyDown(Keys.KEY_Y))
                {
                    ClearGameObject();
                    NewSnake();
                    Start();
                    temp = false;
                }
                else if (Input.IsKeyDown(Keys.KEY_N))
                {
                    temp = false;
                }
            }while (temp);
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            while (true)
            {
                ConsoleGraphics graphics = new ConsoleGraphics();
                GameEngine      engine   = new ArkanoidGameEngine(graphics);
                engine.Start();

                graphics.DrawString("FOR NEW GAME PRESS SPASE\n  FOR EXIT GAME PRESS ESC", "Arial", 0xFF000080, 460, 450, 20);
                graphics.DrawString("(FOR RESET BEST SCORS  PRESS (R)", "Arial", 0xFF000080, 530, 550, 10);
                graphics.FlipPages();

                while (Console.KeyAvailable)
                {
                    Console.ReadKey();
                }
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                ConsoleKey     key     = keyInfo.Key;

                if (key == ConsoleKey.Escape)
                {
                    break;
                }

                if (key == ConsoleKey.R)
                {
                    Scors.WriteInFileBestScors(0);
                    Scors.SetBestScors(0);
                }
            }
        }
Ejemplo n.º 3
0
 private static void Restart(ConsoleGraphics graphics, GameScore score)
 {
     graphics.FillRectangle(0xFFFFFFFF, 0, 0, graphics.ClientWidth, graphics.ClientHeight);
     graphics.DrawString("Game is over", "Arial", 0xFF000000, 150, 150);
     graphics.DrawString($"Your score: {score.Score.ToString()}", "Arial", 0xFF00FF00, 150, 170);
     graphics.DrawString("If you want to restart, press Space", "Arial", 0xFF000000, 150, 190);
 }
Ejemplo n.º 4
0
        public override void OnPaint(PaintEventArgs e)
        {
            ConsoleGraphics g     = e.Graphics;
            var             items = _items;

            g.FillRectangle(ColorResources.ListViewBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height);
            int lastIndex = _visibleItemsFirstIndex + _visibleItemsCount > items.Count ?
                            items.Count : _visibleItemsFirstIndex + _visibleItemsCount;

            for (int i = _visibleItemsFirstIndex; i < lastIndex; i++)
            {
                items[i].Draw(g,
                              new Point(_itemsStartPosition.X + NumericConstants.MarginUpLeft,
                                        _itemsStartPosition.Y + (i - _visibleItemsFirstIndex) *
                                        NumericConstants.ListViewItemHeight + NumericConstants.MarginUpLeft),
                              new Size(NumericConstants.ListViewItemHeight, Size.Width - NumericConstants.MarginRightDown));
            }
            g.DrawLine(ColorResources.AppBackground, Position.X, Position.Y + NumericConstants.ListViewItemHeight,
                       Position.X + Size.Width, Position.Y + NumericConstants.ListViewItemHeight,
                       NumericConstants.WindowBorderThikness);
            g.DrawLine(ColorResources.AppBackground, Position.X, Size.Height - NumericConstants.ListViewItemHeight,
                       Position.X + Size.Width, Size.Height - NumericConstants.ListViewItemHeight,
                       NumericConstants.WindowBorderThikness);

            g.DrawString(_drawingPath, StringResources.FontName, ColorResources.ListItemTextColor,
                         Position.X, Position.Y, NumericConstants.FontSize);
            g.DrawString($"{SelectedIndex + 1}/{this._items.Count}", StringResources.FontName, ColorResources.ListItemTextColor,
                         Position.X + 22, Size.Height - NumericConstants.ListViewItemHeight + 3, NumericConstants.FontSize);
        }
Ejemplo n.º 5
0
 public override void Render(ConsoleGraphics graphics)
 {
     for (int i = 0; i < _bestScores.Length; i++)
     {
         graphics.DrawString(ResourcesManager.StringResources.BuildBestScoreItemText(i + 1, _bestScores[i]), ResourcesManager.StringResources.FontName, ResourcesManager.ColorResources.TextColor, 50, i * 50);
     }
     graphics.DrawString(ResourcesManager.StringResources.BestScoreSceneHelpText, ResourcesManager.StringResources.FontName, ResourcesManager.ColorResources.TextColor, 30, graphics.ClientHeight - 30, 8);
 }
Ejemplo n.º 6
0
 public void Render(ConsoleGraphics graphics)
 {
     if (IsSelected)
     {
         graphics.DrawString(_text, ResourcesManager.StringResources.FontName, 0xff000000, Position.X, Position.Y, 18);
     }
     else
     {
         graphics.DrawString(_text, ResourcesManager.StringResources.FontName, 0xffaaaaaa, Position.X, Position.Y);
     }
 }
Ejemplo n.º 7
0
        public void Start()
        {
            while (true)// Game Loop
            {
                foreach (var obj in objects)
                {
                    obj.Update(this);
                }

                foreach (var obj in delObjects)
                {
                    objects.Remove(obj);
                }

                objects.AddRange(tempObjects);

                tempObjects.Clear();
                delObjects.Clear();

                result = IsGameOver();
                if (result != 0)
                {
                    break;
                }

                Thread.Sleep(10);

                // clearing screen before painting new frame
                graphics.FillRectangle(0xFF00FF00, 0, 0, graphics.ClientWidth, graphics.ClientHeight);

                //painting new frame
                foreach (var obj in objects)
                {
                    obj.Render(graphics);
                }

                // double buffering technique is used
                graphics.FlipPages();
            }

            if (result == 1)
            {
                graphics.DrawString("G A M E  O V E R", "Arial", 0xFF000080, 500, 400, 30);
            }

            if (result == 2)
            {
                graphics.DrawString("W I N", "Arial", 0xFF000080, 600, 400, 30);
            }
            // double buffering technique is used
            graphics.FlipPages();
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        private void DrawDatails(string diskName)
        {
            _graphic.FillRectangle(0xff000000, Indent + 1, 0, (_graphic.ClientWidth / 2), _graphic.ClientHeight);

            _graphic.DrawString($"{diskName}", "Arial", 0xffffffff, Indent, 0, 12);
            _graphic.DrawString("F1-copy  :  F2-cut  :  F3-paste  :  F4-list of disks  :  F5-properties  :  F6-rename  :  F7-criate folder",
                                "Arial", 0xffffffff, 0, _graphic.ClientHeight - _actions.LineHeight, 10);

            _graphic.DrawLine(0xffffffff, _graphic.ClientWidth / 2, 0, _graphic.ClientWidth / 2, _graphic.ClientHeight - _actions.LineHeight);
            _graphic.DrawLine(0xffffffff, 0, _graphic.ClientHeight - _actions.LineHeight, _graphic.ClientWidth, _graphic.ClientHeight - _actions.LineHeight);
            _graphic.DrawLine(0xffffffff, 0, _actions.LineHeight - 1, _graphic.ClientWidth, _actions.LineHeight - 1);
        }
Ejemplo n.º 9
0
        public void ShowMessage(string str, int indent)
        {
            while (!Input.IsKeyDown(Keys.ESCAPE))
            {
                _graphics.FillRectangle(0xff000000, indent, _lineHeight, _graphics.ClientWidth / 2, _graphics.ClientHeight - _lineHeight * 2);
                _graphics.DrawString($"{str}", "Arial", 0xffffffff, indent, _lineHeight, 12);
                _graphics.DrawString("Press Escape to Exit...", "Arial", 0xffffffff, indent, _graphics.ClientHeight / 2, 10);

                _graphics.FlipPages();
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 10
0
        public override void OnPaint(PaintEventArgs e)
        {
            ConsoleGraphics g = e.Graphics;

            g.FillRectangle(ColorResources.WindowBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height);
            g.DrawRectangle(ColorResources.WindowBorderColor, Position.X + NumericConstants.MarginUpLeft,
                            Position.Y + NumericConstants.MarginUpLeft, Size.Width - NumericConstants.MarginRightDown,
                            Size.Height - NumericConstants.MarginRightDown, NumericConstants.WindowBorderThikness);
            g.DrawString(_labels, StringResources.FontName, ColorResources.WindowTextColor, Position.X + 10, Position.Y + 20, 10);
            g.DrawString(_infoText, StringResources.FontName, ColorResources.WindowTextColor,
                         Position.X + 150, Position.Y + 20, 10);
            _okButton.Draw(g);
        }
Ejemplo n.º 11
0
 public override void Render(ConsoleGraphics graphics)
 {
     foreach (var item in _items)
     {
         item.Render(graphics);
     }
     graphics.DrawString(_helpText, ResourcesManager.StringResources.FontName, ResourcesManager.ColorResources.TextColor, 30, _height - 30, 8);
 }
Ejemplo n.º 12
0
 public override void Draw(ConsoleGraphics g)
 {
     g.DrawRectangle(ColorResources.TextBoxBorderColor, _position.X, _position.Y, _size.Width, _size.Height,
                     NumericConstants.WindowBorderThikness);
     g.FillRectangle(ColorResources.TextBoxBackgroundColor, _position.X, _position.Y, _size.Width, _size.Height);
     g.DrawString(Text, StringResources.FontName, ColorResources.ListItemSelectedTextColor, _position.X,
                  _position.Y, NumericConstants.TextBoxFontSize);
 }
Ejemplo n.º 13
0
 private void ResumeGame(ConsoleGraphics graphics)
 {
     graphics.DrawString(message, "Arial", 0xFFFF0000, 100, 300);
     buttonRestart.Render(graphics);
     buttonHighScore.Render(graphics);
     buttonRestart.MouseLeftDown   += MouseRestart;
     buttonHighScore.MouseLeftDown += HighScore;
     UpdatePoints(Score);
 }
Ejemplo n.º 14
0
            public void ShowCards()                                                         // Вывод имеющихся карт
            {
                int i = 0;

                ConsoleGraphics.DrawString(Name, font10, Brushes.White, 20, Position * 90);
                foreach (Karta Card in Cards.ToArray().Reverse())
                {
                    ConsoleGraphics.DrawImage(Card.karta, i++ *13, 15 + Position * 90, WidthCard, HeightCard);
                }
            }
Ejemplo n.º 15
0
        private void DisplayDrives(uint color, Tab tab)
        {
            int textCoordinateY = tab.CoordinateY;
            var listDrives      = tab.GetListDrives();

            for (int i = 0; i < listDrives.Count; i++)
            {
                if (i == tab.Position)
                {
                    _graphics.FillRectangle(color, tab.CoordinateX, textCoordinateY + 5, Settings.TabWidth, Settings.FontSize);
                    _graphics.DrawString($"{listDrives[i].Name}", Settings.FontName, Settings.BlackColor, tab.CoordinateX, textCoordinateY, Settings.FontSize);
                }
                else
                {
                    _graphics.DrawString($"{listDrives[i].Name}", Settings.FontName, color, tab.CoordinateX, textCoordinateY, Settings.FontSize);
                }

                textCoordinateY += Settings.FontSize + 1;
            }
        }
Ejemplo n.º 16
0
 private void MenuPage(ConsoleGraphics graphics)
 {
     graphics.DrawString(message, "Arial", 0xFFFF0000, 100, 100);
     this.btRestart    = new Button(20, 20, 100, 30, "Start");
     this.btHightScore = new Button(370, 20, 150, 30, "Hight Score");
     btRestart.Render(graphics);
     btHightScore.Render(graphics);
     btRestart.MouseDown    += MouseRestart;
     btHightScore.MouseDown += HightSore;
     UpdatePoints(points);
 }
Ejemplo n.º 17
0
        public void Draw(ConsoleGraphics graphics, Point position, Size size)
        {
            uint textColor = ColorResources.ListItemTextColor;

            if (_parent.Enabled && Selected)
            {
                graphics.FillRectangle(ColorResources.ListItemBackgroundColor, position.X, position.Y, size.Width, size.Height);
                textColor = ColorResources.ListItemSelectedTextColor;
            }
            graphics.DrawString(Text, StringResources.FontName, textColor, position.X, position.Y, NumericConstants.FontSize);
        }
Ejemplo n.º 18
0
        public void ShowWindow(string titleText, string inputText, bool isDialogWindow, bool waitForClosing)
        {
            _graphics.FillRectangle(Settings.ActiveColor, Settings.MessageWindowCoordinateX, Settings.MessageWindowCoordinateY, Settings.MessageWindowWidth, Settings.MessageWindowHeiht);

            if (isDialogWindow)
            {
                _graphics.FillRectangle(0xFF0055de, Settings.MessageWindowCoordinateX + 10, Settings.MessageWindowCoordinateY + 40, Settings.MessageWindowWidth - 20, 30);
            }

            _graphics.DrawString(titleText, Settings.FontName, Settings.BlackColor, Settings.MessageWindowCoordinateX + 10, Settings.MessageWindowCoordinateY);
            _graphics.DrawString(inputText, Settings.FontName, Settings.BlackColor, Settings.MessageWindowCoordinateX + 10, Settings.MessageWindowCoordinateY + 40);
            _graphics.FlipPages();

            while (waitForClosing)
            {
                if (Console.ReadKey(true).Key == ConsoleKey.Enter)
                {
                    return;
                }
            }
        }
Ejemplo n.º 19
0
        public static bool ContinueGame(ConsoleGraphics graphics, GameEngine engine)
        {
            var scoreCounter = engine.GetFirstObjectByType <ScoreCounter>();

            graphics.DrawImagePart(graphics.LoadImage("Images/snake-gameover.jpg"), 0, 0, graphics.ClientWidth, graphics.ClientHeight, 0, 0);
            graphics.DrawString($"Current score:{scoreCounter.Score}", Settings.FontName, Settings.WhiteColor, 320, 450, 36);
            graphics.DrawString($"Best score:{scoreCounter.BestScore}", Settings.FontName, Settings.WhiteColor, 350, 520, 36);
            graphics.FlipPages();

            while (true)
            {
                if (Input.IsKeyDown(Keys.SPACE))
                {
                    return(true);
                }

                if (Input.IsKeyDown(Keys.ESCAPE))
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 20
0
        public bool Restart()
        {
            while (true)
            {
                _canvas.Render(_graphics);

                _graphics.DrawString("GAME OVER", "Arial", 0xFFbd1a1a, 100, 200, 30);
                _graphics.DrawString($"You have: {points} points", "Arial", 0xFFbd1a1a, 100, 250, 16);
                _graphics.DrawString($"Do you wont play again?\nPress Y(Yes)/N(No)", "Arial", 0xFFbd1a1a, 100, 270, 16);

                if (Input.IsKeyDown(Keys.KEY_N))
                {
                    return(false);
                }
                else if (Input.IsKeyDown(Keys.KEY_Y))
                {
                    return(true);
                }
                _graphics.FlipPages();

                Thread.Sleep(30);
            }
        }
Ejemplo n.º 21
0
        public override void Draw(ConsoleGraphics g)
        {
            uint color;

            if (Selected)
            {
                color = ColorResources.SelectedButtonColor;
            }
            else
            {
                color = ColorResources.UnselectedButtonColor;
            }
            g.FillRectangle(color, _position.X, _position.Y, _size.Width, _size.Height);
            g.DrawString(_text, StringResources.FontName, ColorResources.ButtonTextColor,
                         _position.X + _textAlign, _position.Y - 2, NumericConstants.ButtonFontSize);
        }
Ejemplo n.º 22
0
 void DrawStatArea(ConsoleGraphics graphics)
 {
     graphics.FillRectangle((uint)BorderColor, X, Y, TotalWidth, TotalHeight);          //Draw border
     graphics.FillRectangle((uint)Color.White, X + 4, Y + 4, StatWidth, StatHeight);    //Draw background
     graphics.DrawString("Score:", "", (uint)Color.Black, X + 5, Y + 10);
     graphics.DrawString($"{PlayingArea.Score}", "DS-Digital", (uint)Color.Black, X + 3, Y + 30, 30);
     graphics.DrawString("Last score:", "", (uint)Color.Black, X + 5, Y + 90);
     graphics.DrawString($"{PlayingArea.LastScore}", "DS-Digital", (uint)Color.Black, X + 3, Y + 110, 30);
     graphics.DrawString("HiScore:", "", (uint)Color.Red, X + 5, Y + 170);
     graphics.DrawString($"{PlayingArea.HiScore}", "DS-Digital", (uint)Color.Red, X + 3, Y + 190, 30);
 }
Ejemplo n.º 23
0
 public void Render(ConsoleGraphics graphics)
 {
     graphics.DrawString("Score:", "Consolas", (uint)Color.Black, X + 8, Y, 18);                             //current score
     graphics.DrawString(PlayingArea.Score.ToString(), "Consolas", (uint)Color.Black, X + 8, Y + 25, 22);
     graphics.DrawString("Top Ten", "Consolas", (uint)Color.Black, X + 8, Y + 200, 22);                      //top ten score
     for (int i = 0; i < PlayingArea.TopTen.Count; i++)
     {
         string temp = "#" + (i + 1).ToString().PadLeft(2) + ": " + PlayingArea.TopTen[i].ToString();
         graphics.DrawString(temp, "Consolas", (uint)Color.Black, X + 8, Y + 226 + i * 26, 22);
     }
     graphics.DrawString("\"Space\" - play", "Consolas", (uint)Color.Black, X + 8, 625, 14);                 //playing help
     graphics.DrawString("\"Esc\" - pause", "Consolas", (uint)Color.Black, X + 8, 650, 14);
 }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            ConsoleGraphics graphics = new ConsoleGraphics();

            Field field = new Field();
            Cross cross = new Cross();

            while (true)
            {
                graphics.FillRectangle(0xFFFFFFFF, 0, 0, graphics.ClientWidth, graphics.ClientHeight);
                graphics.DrawString("0", "Arial", 0xFF00FFFF, 200, 500, 50);
                field.Render(graphics);
                if (Input.IsMouseLeftButtonDown)
                {
                    cross.Render(graphics);
                }

                graphics.FlipPages();
                //Thread.Sleep(50);
            }
        }
Ejemplo n.º 25
0
        public override void OnPaint(PaintEventArgs e)
        {
            ConsoleGraphics g = e.Graphics;

            g.FillRectangle(ColorResources.WindowBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height);
            g.DrawRectangle(ColorResources.WindowBorderColor, Position.X + NumericConstants.MarginUpLeft,
                            Position.Y + NumericConstants.MarginUpLeft, Size.Width - NumericConstants.MarginRightDown,
                            Size.Height - NumericConstants.MarginRightDown, NumericConstants.WindowBorderThikness);
            _progressBar.Draw(g);
            string name = Path.GetFileName(_sourcePath);

            name = name.Length > 40 ? name.Substring(0, 36).Insert(36, StringResources.LongFileNameEnd) : name;
            string text = string.Empty;

            switch (_type)
            {
            case OperationType.CopyFile:
                text = $"Copy file:\n{name}";
                break;

            case OperationType.MoveFile:
                text = $"Move file:\n{name}";
                break;

            case OperationType.CopyDirectory:
                text = $"Copy directory:\n{name}";
                break;

            case OperationType.MoveDirectory:
                text = $"Move directory:\n{name}";
                break;
            }
            g.DrawString(text, StringResources.FontName, ColorResources.WindowTextColor,
                         Position.X + 10, Position.Y + 20, NumericConstants.FontSize);
            _okButton.Draw(g);
            _cancelButton.Draw(g);
        }
Ejemplo n.º 26
0
 public override void Render(ConsoleGraphics graphics)
 {
     graphics.DrawString(ResourcesManager.StringResources.BuildGUIScoreText(Scores), ResourcesManager.StringResources.FontName, ResourcesManager.ColorResources.TextColor, Position.X + 20, Position.Y + 5);
     graphics.DrawString(ResourcesManager.StringResources.GUIHelpText, ResourcesManager.StringResources.FontName, ResourcesManager.ColorResources.TextColor, Position.X + 250, Position.Y + 10, 8);
 }
Ejemplo n.º 27
0
 public void Show(ConsoleGraphics graphics, int index, int indent, int lineHeight)
 {
     graphics.DrawString($"{Name}\t\t{IsReady}", "Arial", 0xffffffff, indent, lineHeight + lineHeight * index, 10);
 }
Ejemplo n.º 28
0
 public void Draw(ConsoleGraphics cg)
 {
     cg.DrawString(text, "Consolas", textColor, x, y, h);
 }
Ejemplo n.º 29
0
 public void Render(ConsoleGraphics graphics)
 {
     graphics.DrawString($"Score:{Score}", Settings.FontName, Settings.BlackColor, Settings.FieldWightInPixel + 10, 0);
     graphics.DrawString($"Best Score:{BestScore}", Settings.FontName, Settings.BlackColor, Settings.FieldWightInPixel + 10, 20);
 }
Ejemplo n.º 30
0
 public void Render(ConsoleGraphics graphics)
 {
     graphics.FillRectangle(0xFF00F000, x, y, width, height);
     graphics.DrawString(text, "Arial", 0xFFF0FF00, x, y);
 }