コード例 #1
0
ファイル: TextBox.cs プロジェクト: IGarcia1121/AgarIO-Bot
        public TextBox(Font font, float x, float y, int width, int height, int maxLen)
            : base(Color.Black, x, y, false)
        {
            _font = font;
            _width = width;
            _height = height;
            _maxLen = maxLen;
            _text = "";
            _ticks = 0;

            _rect = new Rectangle(Color.Black, X, Y, width, height, true);
            _caret = new Rectangle(Color.Black, X + 2, Y + height - 4, 5, 2, false);
            _background = new Rectangle(Color.White, X, Y, width, height, false);
        }
コード例 #2
0
ファイル: ComboBox.cs プロジェクト: IGarcia1121/AgarIO-Bot
        public ComboBox(Font font, float x, float y, int width, int height)
            : base(Color.Black, x, y, false)
        {
            _font = font;
            _items = new List<TextBox>();
            _text = new TextBox(font, x, y, width, height, -1);

            int triWidth = 8;
            int triHeight = 8;
            int trix = (int)x + width - (triWidth * 2);
            int triy = (int)y + height - (triHeight * 2) + 2;
            _tri = new Triangle(Color.Black, trix, triy, trix + triWidth, triy, trix + (triWidth / 2), triy + triHeight, false);

            _seperator = new LineSegment();
            _seperator.StartPoint = new Point2D { X = trix - 5, Y = triy - 5 };
            _seperator.EndPoint = new Point2D { X = trix - 5, Y = y + height - 2 };

            _clicker = new Rectangle(Color.LightGray, _seperator.StartPoint.X, _seperator.StartPoint.Y, triWidth * 2 + 4, height - 2, false);

            _text.Text = "Select an option...";
        }
コード例 #3
0
ファイル: GameMain.cs プロジェクト: IGarcia1121/AgarIO-Bot
        public static void Main()
        {
            //Create collections to hold leaderboard, packet count and server list
            _leaderboard = new List<LeaderboardPlayer>();
            _packetCount = new Dictionary<int, int>();
            _serverList = new List<Server>();

            _showPopup = true;

            //Open the game window
            SwinGame.OpenGraphicsWindow("Petri", 1024, 800);

            //Load the Arial font
            Font _gameFont = SwinGame.LoadFont("Arial", 14);

            Rectangle background = new Rectangle(SwinGame.RGBAColor(0, 0, 0, 155), (SwinGame.ScreenWidth() / 2) - (300 / 2), 
                                                                                   (SwinGame.ScreenHeight() / 2) - (200 / 2), 300, 150, false);

            //Create a textbox to get the nick name
            TextBox nameEntry = new TextBox(_gameFont, (SwinGame.ScreenWidth() / 2) - (190 / 2), background.Y + 30, 190, 20, 16);

            //Create a combobox to select the server 
            _box = new ComboBox(_gameFont, nameEntry.X, background.Y + 70, 190, 20);
            _box.ItemSelected += box_ItemSelected;
            _box.Text = "Loading servers...";

            Rectangle connectRect = new Rectangle(Color.DarkGray, _box.X, background.Y + background.Height - 30, 190, 20, false);

            while (!SwinGame.WindowCloseRequested())
            {
                //Init the server info on load
                if (!_startup)
                {
                    _startup = true;
                    LoadData(_box);
                }

                //Check for any clicks/key presses
                SwinGame.ProcessEvents();

                //Clear the screen
                SwinGame.ClearScreen(Color.White);

                //Draw the world and contents within
                if (_agarWorld != null)
                    _agarWorld.Draw();

                //Draw menu
                if (_showPopup)
                {
                    background.Draw();
                    
                    SwinGame.DrawTextOnScreen("Name:", Color.White, nameEntry.X, nameEntry.Y - 10);
                    SwinGame.DrawTextOnScreen("Server:", Color.White, _box.X, _box.Y - 10);
                    nameEntry.Draw();

                    if (_connected)
                    {
                        connectRect.Draw();
                        SwinGame.DrawTextOnScreen("Play", Color.White, connectRect.X + (connectRect.Width / 2) - 16, connectRect.Y + 6);

                        if (SwinGame.MouseClicked(MouseButton.LeftButton) && connectRect.IsAt(SwinGame.MousePosition()) && !_box.DroppedDown)
                        {
                            Play(nameEntry.Text);
                        }
                    }

                    _box.Draw();
                }
                else
                {
                    if (SwinGame.KeyTyped(KeyCode.vk_SPACE))
                    {
                        PushMessage(17);
                    }
                    else if (SwinGame.KeyTyped(KeyCode.vk_w))
                    {
                        PushMessage(21);
                    }
                    else
                    {
                        Movement();
                    }
                }



                //Draw server info
                SwinGame.DrawTextOnScreen(string.Format("{0} FPS", SwinGame.GetFramerate()), Color.Black, 0, 0);

                if (_agarWorld != null)
                    SwinGame.DrawTextOnScreen(string.Format("{0},{1}", Math.Round(_agarWorld.CameraX), Math.Round(_agarWorld.CameraY)), Color.Black, 0, 10);

                SwinGame.DrawTextOnScreen(_packetText, Color.Black, 0, 20);
                SwinGame.DrawTextOnScreen(_ipAddress, Color.Black, 0, 30);

                //Draw Leaderboard Info
                string players = "";
                foreach (LeaderboardPlayer p in _leaderboard)
                {
                    players += string.Format("{0}. {1} ", p.Rank, p.Name);
                }
                SwinGame.DrawTextOnScreen(players, Color.Black, _leaderboardMarquee, SwinGame.ScreenHeight() - 10);
                if (players.Length * 8 > SwinGame.ScreenWidth())
                {
                    _leaderboardMarquee += 1;
                }
                else
                {
                    _leaderboardMarquee = 0;
                }
                if (_leaderboardMarquee > SwinGame.ScreenWidth())
                {
                    _leaderboardMarquee = -(players.Length * 8);
                }



                //Refresh the screen at ~60 fps
                SwinGame.RefreshScreen(60);
            }
        }