示例#1
0
文件: RoomMenu.cs 项目: jkapi/Kakoi
        public void DrawRoom(Vector2 position, string name, int players, string owner, bool locked, int id)
        {
            Rectangle bounds = new Rectangle(position.ToPoint() + new Point(0, 140), new Point(1400, 100));

            Color oldColor = View.DrawColor;

            View.DrawColor = bounds.Contains(Mouse.Position) && Mouse.Position.Y > 140 ? Color.White : Color.LightGray;
            float opacity = bounds.Contains(Mouse.Position) && Mouse.Position.Y > 140 ? 0.25f : 0.2f;

            opacity = bounds.Contains(Mouse.Position) && Mouse.Check(MouseButtons.Left) && Mouse.Position.Y > 140 ? 0.3f: opacity;

            View.DrawRectangle(position, new Vector2(1400, 100), false, new Color(Color.Black, opacity));

            View.DrawText(Arial24, name, position + new Vector2(20, 20));
            View.DrawText(Arial16, "By " + owner, position + new Vector2(20, 60));

            float numWidth = Arial24.MeasureString(players + "/4").X;

            View.DrawText(Arial24, players + "/4", position + new Vector2(1380 - numWidth, 20), Color.LightGray);
            if (locked)
            {
                View.DrawTexture(LockSmall, position + new Vector2(1359, 60));
            }
            View.DrawColor = oldColor;

            if (Mouse.CheckReleased(MouseButtons.Left) && bounds.Contains(Mouse.Position) && Mouse.Position.Y > 140)
            {
                SocketHandler.SendMessage(PacketTypes.JOINROOM, id);
            }
        }
示例#2
0
 public override void Update()
 {
     if (new Rectangle((Position * View.Scale).ToPoint(), (new Vector2(20) * View.Scale).ToPoint()).Contains(Mouse.Position))
     {
         if (Mouse.CheckReleased(MouseButtons.Left))
         {
             Checked = !Checked;
         }
         Mouse.Cursor = MouseCursor.Hand;
         Hovered      = true;
     }
     else
     {
         if (new Rectangle(Position.ToPoint(), new Point(20)).Contains(Mouse.LastPosition))
         {
             Mouse.Cursor = Mouse.DefaultCursor;
         }
         Hovered = false;
     }
     font = Room.Content.Load <SpriteFont>("opensans13");
 }
示例#3
0
文件: Button.cs 项目: jkapi/Kakoi
        public override void Update()
        {
            if (Clicked)
            {
                if (OnClick != null)
                {
                    OnClick.Invoke(this, new EventArgs());
                }
                Clicked = false;
            }

            if (Mouse.Check(MouseButtons.Left) && Bounds.Contains(Mouse.Position))
            {
                clicking = true;
            }
            else
            {
                clicking = false;
            }
            if (Bounds.Contains(Mouse.Position))
            {
                Hover = true;
                if (Mouse.CheckReleased(MouseButtons.Left))
                {
                    Clicked = true;
                }
                Mouse.Cursor = MouseCursor.Hand;
            }
            else
            {
                if (Hover == true)
                {
                    Mouse.Cursor = Mouse.DefaultCursor;
                }
                Hover = false;
            }
        }
示例#4
0
文件: MainMenu.cs 项目: jkapi/Kakoi
        public override void Update()
        {
            Graphics.ApplyChanges();
            multiHovered    = IsVector2InPolygon4(ScaledPolygon(boundsMulti), Mouse.Position - offsetMain * View.Scale.X) && multiEnabled && menuEnabled;
            soloHovered     = IsVector2InPolygon4(ScaledPolygon(boundsSolo), Mouse.Position - offsetMain * View.Scale.X) && menuEnabled;
            settingsHovered = IsVector2InPolygon4(ScaledPolygon(boundsSettings), Mouse.Position - offsetMain * View.Scale.X) && menuEnabled;
            quitHovered     = IsVector2InPolygon4(ScaledPolygon(boundsQuit), Mouse.Position - offsetMain * View.Scale.X) && menuEnabled;

            targetOffsetMulti    = multiHovered ? targetOffset : 0;
            targetOffsetSolo     = soloHovered ? targetOffset : 0;
            targetOffsetSettings = settingsHovered ? targetOffset : 0;
            targetOffsetQuit     = quitHovered ? targetOffset : 0;

            if (offsetMulti != targetOffsetMulti)
            {
                offsetMulti += animationSpeed * (targetOffsetMulti - offsetMulti);
            }
            if (offsetSolo != targetOffsetSolo)
            {
                offsetSolo += animationSpeed * (targetOffsetSolo - offsetSolo);
            }
            if (offsetSettings != targetOffsetSettings)
            {
                offsetSettings += animationSpeed * (targetOffsetSettings - offsetSettings);
            }
            if (offsetQuit != targetOffsetQuit)
            {
                offsetQuit += animationSpeed * (targetOffsetQuit - offsetQuit);
            }
            if (offsetMain != targetOffsetMain)
            {
                offsetMain         += animationSpeed * (targetOffsetMain - offsetMain);
                offsetMenuSettings += animationSpeed * (targetOffsetMenuSettings - offsetMenuSettings);
            }
            if (Mouse.CheckReleased(MouseButtons.Left))
            {
                if (multiHovered)
                {
                    showMulti = true; showSettings = false;
                }
                if (soloHovered)
                {
                    showSolo = true; showSettings = false;
                }
                if (settingsHovered)
                {
                    showSettings = !showSettings;
                }
                if (quitHovered)
                {
                    Game1.stopping = true;
                }
            }

            if (Keyboard.CheckReleased(Keys.Escape))
            {
                if (showSettings)
                {
                    showSettings = false;
                }
                else if (showMulti)
                {
                    showMulti = false;
                }
                else if (showSolo)
                {
                    showSolo = false;
                }
                else
                {
                    Game1.stopping = true;
                }
            }

            if (multiHovered | soloHovered | settingsHovered | quitHovered)
            {
                Mouse.Cursor = MouseCursor.Hand;
            }
            else
            {
                Mouse.Cursor = Mouse.DefaultCursor;
            }

            MultiplayerAnimationHandler();

            if (startopacity > 0)
            {
                startopacity -= 20;
            }
        }
示例#5
0
        public override void Update()
        {
            float offset = (float)(Math.PI * 2) / totalCovers;
            Dictionary <int, Vector2> positions = new Dictionary <int, Vector2>();

            for (int i = 0; i < totalCovers; i++)
            {
                positions.Add(i, new Vector2(500 + (float)Math.Sin(tt + offset * i) * 450, 250 + (float)Math.Cos(tt + offset * i) * 200));
            }

            sortedpositions = from entry in positions orderby entry.Value.Y ascending select entry;
            bottompanel     = sortedpositions.Last().Key;

            if (!automove && Position.X < 10)
            {
                if (Mouse.CheckPressed(MouseButtons.Left))
                {
                    mousestartpos = Mouse.Position;
                    starttt       = tt;
                }
                if (Mouse.Check(MouseButtons.Left))
                {
                    tt = starttt + (Mouse.Position.X - mousestartpos.X) / 500;
                }
                if (Mouse.CheckReleased(MouseButtons.Left))
                {
                    Dictionary <int, float> distances = new Dictionary <int, float>();
                    if (Math.Abs(Mouse.Position.X - mousestartpos.X) < 5)
                    {
                        foreach (var position in sortedpositions)
                        {
                            if (position.Value.Y > 40)
                            {
                                if (new Rectangle((position.Value + new Vector2(460, 200) + Position - Covers.Center).ToPoint(), Covers.Size.ToPoint()).Contains(Mouse.Position))
                                {
                                    distances.Add(position.Key, Vector2.Distance(position.Value + new Vector2(460, 200) + Position, Mouse.Position));
                                }
                            }
                        }
                    }
                    if (distances.Count > 0)
                    {
                        var clickeditem = distances.OrderBy(kvp => kvp.Value).First();
                        switch (clickeditem.Key)
                        {
                        case 0: Room.GotoRoom(typeof(Minigames.ClimbTheMountain.ClimbTheMountain)); break;

                        case 1: Room.GotoRoom(typeof(Minigames.FlySwat.FlySwat)); break;

                        case 2: Room.GotoRoom(typeof(Minigames.DontTapWhite.Donttapwhite)); break;

                        case 3: Room.GotoRoom(typeof(Minigames.Quiz.Quiz)); break;

                        case 4: Room.GotoRoom(typeof(Minigames.DinoCollectStuff.DinoCollectStuff)); break;

                        case 5: Room.GotoRoom(typeof(Rooms.Room1)); break;

                        default: throw new IndexOutOfRangeException("Tried to open a room that does not exist");
                        }
                    }
                }
            }
        }