Exemple #1
0
        public override void Draw()
        {
            var players = SocketHandler.GetPlayers();

            MovingBackground.Draw(this);
            View.DrawRectangle(new Rectangle(600, 32, 640, 640), false, new Color(240, 240, 240));

            View.DrawSprite(Chips, 0, new Vector2(32, 32) + _vector64, null, Rotations[0], _vector64);
            View.DrawSprite(Chips, 1, new Vector2(32, 192) + _vector64, null, Rotations[1], _vector64);
            View.DrawSprite(Chips, 2, new Vector2(32, 352) + _vector64, null, Rotations[2], _vector64);
            View.DrawSprite(Chips, 3, new Vector2(32, 512) + _vector64, null, Rotations[3], _vector64);

            View.DrawSpriteStretched(Heads, 3, new Vector2(76, 76), new Vector2(40));
            View.DrawSpriteStretched(Heads, 0, new Vector2(76, 76 + 160), new Vector2(40));
            View.DrawSpriteStretched(Heads, 1, new Vector2(76, 76 + 320), new Vector2(40));
            View.DrawSpriteStretched(Heads, 2, new Vector2(76, 76 + 480), new Vector2(40));

            try
            {
                DrawTextOutlined(Arial24, players[0].Name, new Vector2(180, 96), Color.White, Color.Black);
                if (players.Count > 1)
                {
                    DrawTextOutlined(Arial24, players[1].Name, new Vector2(180, 256), Color.White, Color.Black);
                }
                if (players.Count > 2)
                {
                    DrawTextOutlined(Arial24, players[2].Name, new Vector2(180, 416), Color.White, Color.Black);
                }
                if (players.Count > 3)
                {
                    DrawTextOutlined(Arial24, players[3].Name, new Vector2(180, 576), Color.White, Color.Black);
                }
            }
            catch
            {
                // This isn't really something to worry about, can be caused because of a breakpoint in the tick function of the server
            }
            Vector2 MouseMovement = Mouse.AverageMovement();

            if (Math.Abs(Mouse.LastMovement.X + Mouse.LastMovement.Y) > 0.1)
            {
                if (Math.Abs(MouseMovement.X + MouseMovement.Y) > 0)
                {
                    MouseAngle = (float)Math.Atan2(MouseMovement.Y, MouseMovement.X);
                }
            }
            View.RotationMode = View.RotationType.Radians;
            View.DrawRectangle(Mouse.Position, new Vector2(20), rotation: MouseAngle + (float)Math.PI);
            View.RotationMode = View.RotationType.Degrees;
        }
Exemple #2
0
        public override void Update()
        {
            if (tick % sendNewLocationDelay == 0)
            {
                SocketHandler.SendMessage(PacketTypes.MOUSE, Mouse.Position.X, Mouse.Position.Y, Mouse.AverageMovement().X, Mouse.AverageMovement().Y);
            }
            var data = SocketHandler.GetData();

            if (data != null)
            {
                if (data.BaseStream.Length > 1)
                {
                    data.BaseStream.Position = 0;
                    positions.Clear();
                    Timer = data.ReadInt32();
                    int numflies = data.ReadInt32();
                    for (int i = 0; i < numflies; i++)
                    {
                        try
                        {
                            positions.Add(data.ReadInt32(), new Vector2(data.ReadSingle() * Graphics.PreferredBackBufferWidth / 1920, data.ReadSingle() * Graphics.PreferredBackBufferHeight / 1080));
                        }
                        catch
                        { }
                    }
                }
            }

            if (Mouse.CheckPressed(MouseButtons.Left))
            {
                Rectangle bounds = new Rectangle(Mouse.Position.ToPoint() - new Point(10, 8), new Point(30, 38));
                foreach (var fly in positions)
                {
                    if (bounds.Contains(fly.Value))
                    {
                        SocketHandler.SendMessage(PacketTypes.SWAT, fly.Key);
                    }
                }
            }

            tick++;
        }
Exemple #3
0
 public override void Update()
 {
     if (!started)
     {
         try
         {
             var data = SocketHandler.GetData();
             if (data.BaseStream.Length == 8)
             {
                 gamelist = new GameList(Vector2.Zero, 5, true, 0, data.ReadSingle(), data.ReadSingle());
                 Objects.Add(gamelist);
                 started = true;
             }
             SocketHandler.SendMessage(PacketTypes.MOUSE, Mouse.Position.X, Mouse.Position.Y, Mouse.AverageMovement().X, Mouse.AverageMovement().Y);
         }
         catch
         {
         }
     }
     else
     {
         if (gamelist.speed == 0)
         {
             SocketHandler.SendMessage(PacketTypes.MOUSE, Mouse.Position.X + 0.5f, Mouse.Position.Y + 0.1f + (gamelist.bottompanel / 10f), Mouse.AverageMovement().X, Mouse.AverageMovement().Y);
         }
         else
         {
             SocketHandler.SendMessage(PacketTypes.MOUSE, Mouse.Position.X, Mouse.Position.Y, Mouse.AverageMovement().X, Mouse.AverageMovement().Y);
         }
     }
 }