Ejemplo n.º 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile       from = sender.Mobile;
            PlayerMobile pm   = from as PlayerMobile;

            if (from == null || pm == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            {
                // Closed from right click
                break;
            }

            case 996:     //next page (if applicable)
            {
                int nitems = 0;

                if (matches != null)
                {
                    nitems = matches.Count;
                }

                int page = CurrentPage + 1;

                if (page > nitems / MaxPerPage)
                {
                    page = nitems / MaxPerPage;
                }

                from.SendGump(new MatchmakingGump(from, page));
                break;
            }

            case 997:     //previous page (if applicable)
            {
                int page = CurrentPage - 1;

                if (page < 0)
                {
                    page = 0;
                }

                from.SendGump(new MatchmakingGump(from, page));
                break;
            }

            case 998:      // Leave Matchmaking
            {
                Matchmaking.CancelWaitForParty(from);
                break;
            }

            case 999:      // Open Gump To Join Matchmaking, with new options.
            {
                if (pm.HasGump(typeof(MatchmakingCreateGump)))
                {
                    pm.CloseGump(typeof(MatchmakingCreateGump));
                }

                if (pm.HasGump(typeof(MatchmakingGump)))
                {
                    pm.CloseGump(typeof(MatchmakingGump));
                }

                pm.SendGump(new MatchmakingCreateGump(pm));

                break;
            }

            default:                             // Join Party
            {
                int partyid = info.ButtonID - 1; // Math, so the 0 button isn't taken, we need it for right click closing.

                if (Matchmaking.WaitingForParty.Count > partyid)
                {
                    Matchmaking match = Matchmaking.WaitingForParty[partyid];

                    if (match == null)
                    {
                        from.SendMessage("The party was removed from Matchmaking before you could join it.");
                        return;
                    }

                    Matchmaking.AddToParty(match, from);
                }
                else
                {
                    from.SendMessage("The party was removed from Matchmaking before you could join it.");
                }

                break;
            }
            }
        }