示例#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
文件: TextBox.cs 项目: jkapi/Kakoi
        /// <summary>
        /// Handles all mouse interaction
        /// </summary>
        private void HandleMouse()
        {
            bool wasHovered = Hover;

            Hover = new Rectangle((int)(bounds.X * View.Scale.X), (int)(bounds.Y * View.Scale.Y), (int)(bounds.Width * View.Scale.X), (int)(bounds.Height * View.Scale.Y)).Contains(Mouse.Position);

            if (Hover)
            {
                Mouse.Cursor = MouseCursor.IBeam;
            }
            else
            {
                if (wasHovered)
                {
                    Mouse.Cursor = Mouse.DefaultCursor;
                }
            }

            if (Mouse.CheckPressed(MouseButtons.Left))
            {
                if (Hover)
                {
                    Focussed        = true;
                    Keyboard.String = "";

                    MoveCursorToCharacterByPosition(Mouse.Position.ToPoint());
                    mouseStartPosition = Mouse.Position;
                }
                else
                {
                    // If clicked outside textbox, stop focussing
                    Focussed = false;
                }
            }

            if (Mouse.Check(MouseButtons.Left))
            {
                mousePosition = Mouse.Position;
                SelectStart   = GetCharacterByPosition(mouseStartPosition.ToPoint());
                SelectEnd     = GetCharacterByPosition(mousePosition.ToPoint());
            }
        }
示例#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
文件: LoginMenu.cs 项目: jkapi/Kakoi
        public override void Update()
        {
            View.Scale = new Vector2(Graphics.PreferredBackBufferHeight / 1080f);
            if (new Rectangle((int)(960 * View.Scale.X), (int)(570 * View.Scale.Y), (int)(190 * View.Scale.X), (int)(60 * View.Scale.Y)).Contains(Mouse.Position) && Mouse.Check(MouseButtons.Left))
            {
                registerpage = true;
            }
            else if (new Rectangle((int)(770 * View.Scale.X), (int)(570 * View.Scale.Y), (int)(190 * View.Scale.X), (int)(60 * View.Scale.Y)).Contains(Mouse.Position) && Mouse.CheckPressed(MouseButtons.Left))
            {
                registerpage = false;
            }

            if (Keyboard.CheckTriggered(Keys.Tab))
            {
                if (UserBox.Focussed)
                {
                    UserBox.Focussed = false;
                    PassBox.Focussed = true;
                }
                else if (PassBox.Focussed == true)
                {
                    UserBox.Focussed = true;
                    PassBox.Focussed = false;
                }
            }
            if (Keyboard.CheckPressed(Keys.Enter))
            {
                LoginButton.Clicked = true;
            }
        }
示例#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");
                        }
                    }
                }
            }
        }