public void Remove(DuelPlayer player)
        {
            if (player == null)
            {
                return;
            }

            int index = Array.IndexOf(m_Players, player);

            if (index == -1)
            {
                return;
            }

            DuelPlayer[] old = m_Players;
            m_Players = new DuelPlayer[old.Length - 1];

            for (int i = 0; i < index; ++i)
            {
                m_Players[i] = old[i];
            }

            for (int i = index + 1; i < old.Length; ++i)
            {
                m_Players[i - 1] = old[i];
            }
        }
Beispiel #2
0
        private void DelayBounce_Callback(object state)
        {
            object[]  states = (object[])state;
            Mobile    mob    = (Mobile)states[0];
            Container corpse = (Container)states[1];

            DuelPlayer dp = null;

            if (mob is PlayerMobile)
            {
                dp = (mob as PlayerMobile).DuelPlayer;
            }

            m_Context.RemoveAggressions(mob);

            if (dp != null && !dp.Eliminated)
            {
                mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet);
            }
            else
            {
                m_Context.SendOutside(mob);
            }

            m_Context.Refresh(mob, corpse);
            DuelContext.Debuff(mob);
            DuelContext.CancelSpell(mob);
            mob.Frozen = false;
        }
Beispiel #3
0
        public void MoveInside(DuelPlayer[] players, int index)
        {
            if (index < 0)
            {
                index = 0;
            }
            else
            {
                index %= m_Points.Points.Length;
            }

            Point3D start = GetBaseStartPoint(index);

            int offset = 0;

            Point2D[] offsets = (index < 4) ? m_EdgeOffsets : m_CornerOffsets;
            int[,] matrix = m_Rotate[index];

            for (int i = 0; i < players.Length; ++i)
            {
                DuelPlayer pl = players[i];

                if (pl == null)
                {
                    continue;
                }

                Mobile mob = pl.Mobile;

                Point2D p;

                if (offset < offsets.Length)
                {
                    p = offsets[offset++];
                }
                else
                {
                    p = offsets[offsets.Length - 1];
                }

                p.X = (p.X * matrix[0, 0]) + (p.Y * matrix[0, 1]);
                p.Y = (p.X * matrix[1, 0]) + (p.Y * matrix[1, 1]);

                mob.MoveToWorld(new Point3D(start.X + p.X, start.Y + p.Y, start.Z), m_Facet);
                mob.Direction = mob.GetDirectionTo(m_Wall);

                m_Players.Add(mob);
            }
        }
        public void Nullify(DuelPlayer player)
        {
            if (player == null)
            {
                return;
            }

            int index = Array.IndexOf(m_Players, player);

            if (index == -1)
            {
                return;
            }

            m_Players[index] = null;
        }
Beispiel #5
0
        public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50)
        {
            m_From        = from;
            m_Context     = context;
            m_Participant = p;

            from.CloseGump(typeof(RulesetGump));
            from.CloseGump(typeof(DuelContextGump));
            from.CloseGump(typeof(ParticipantGump));

            int count = p.Players.Length;

            if (count < 4)
            {
                count = 4;
            }

            AddPage(0);

            int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + (count * 22) + 2 + 30;

            AddBackground(0, 0, 300, height, 9250);
            AddBackground(10, 10, 280, height - 20, 0xDAC);

            AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0);

            //AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 );

            AddHtml(35, 25, 230, 20, Center("Participant Setup"), false, false);

            int x = 35;
            int y = 47;

            AddHtml(x, y, 200, 20, String.Format("Team Size: {0}", p.Players.Length), false, false); y += 22;

            AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); y += 22;
            AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); y += 30;

            AddHtml(35, y, 230, 20, Center("Players"), false, false); y += 22;

            for (int i = 0; i < p.Players.Length; ++i)
            {
                DuelPlayer pl = p.Players[i];

                AddGoldenButtonLabeled(x, y, 5 + i, String.Format("{0}: {1}", 1 + i, pl == null ? "Empty" : pl.Mobile.Name)); y += 22;
            }
        }
        public void Add(Mobile player)
        {
            if (Contains(player))
            {
                return;
            }

            for (int i = 0; i < m_Players.Length; ++i)
            {
                if (m_Players[i] == null)
                {
                    m_Players[i] = new DuelPlayer(player, this);
                    return;
                }
            }

            Resize(m_Players.Length + 1);
            m_Players[m_Players.Length - 1] = new DuelPlayer(player, this);
        }
Beispiel #7
0
        public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50)
        {
            m_From    = from;
            m_Context = context;

            Closable = false;
            AddPage(0);

            if (context.Rematch)
            {
                int height = 25 + 20 + 10 + 22 + 25;

                AddBackground(0, 0, 210, height, 9250);
                AddBackground(10, 10, 190, height - 20, 0xDAC);

                AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false);

                AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0);
                AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                #region Participants
                AddPage(1);

                ArrayList parts = context.Participants;

                int height = 25 + 20;

                for (int i = 0; i < parts.Count; ++i)
                {
                    Participant p = (Participant)parts[i];

                    height += 4;

                    if (p.Players.Length > 1)
                    {
                        height += 22;
                    }

                    height += (p.Players.Length * 22);
                }

                height += 10 + 22 + 25;

                AddBackground(0, 0, 260, height, 9250);
                AddBackground(10, 10, 240, height - 20, 0xDAC);

                AddHtml(35, 25, 190, 20, Center("Participants"), false, false);

                int y = 20 + 25;

                for (int i = 0; i < parts.Count; ++i)
                {
                    Participant p = (Participant)parts[i];

                    y += 4;

                    int offset = 0;

                    if (p.Players.Length > 1)
                    {
                        AddHtml(35, y, 176, 20, String.Format("Team #{0}", i + 1), false, false);
                        y     += 22;
                        offset = 10;
                    }

                    for (int j = 0; j < p.Players.Length; ++j)
                    {
                        DuelPlayer pl = p.Players[j];

                        string name = (pl == null ? "(Empty)" : pl.Mobile.Name);

                        AddHtml(35 + offset, y, 166, 20, name, false, false);

                        y += 22;
                    }
                }

                y += 8;

                AddHtml(35, y, 176, 20, "Continue?", false, false);

                y -= 2;

                AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2);
                AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0);
                #endregion

                #region Rules
                AddPage(2);

                Ruleset ruleset = context.Ruleset;
                Ruleset basedef = ruleset.Base;

                height = 25 + 20 + 5 + 20 + 20 + 4;

                int changes = 0;

                BitArray defs;

                if (ruleset.Flavors.Count > 0)
                {
                    defs = new BitArray(basedef.Options);

                    for (int i = 0; i < ruleset.Flavors.Count; ++i)
                    {
                        defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
                    }

                    height += ruleset.Flavors.Count * 18;
                }
                else
                {
                    defs = basedef.Options;
                }

                BitArray opts = ruleset.Options;

                for (int i = 0; i < opts.Length; ++i)
                {
                    if (defs[i] != opts[i])
                    {
                        ++changes;
                    }
                }

                height += (changes * 22);

                height += 10 + 22 + 25;

                AddBackground(0, 0, 260, height, 9250);
                AddBackground(10, 10, 240, height - 20, 0xDAC);

                AddHtml(35, 25, 190, 20, Center("Rules"), false, false);

                AddHtml(35, 50, 190, 20, String.Format("Set: {0}", basedef.Title), false, false);

                y = 70;

                for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
                {
                    AddHtml(35, y, 190, 20, String.Format(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title), false, false);
                }

                y += 4;

                if (changes > 0)
                {
                    AddHtml(35, y, 190, 20, "Modifications:", false, false);
                    y += 20;

                    for (int i = 0; i < opts.Length; ++i)
                    {
                        if (defs[i] != opts[i])
                        {
                            string name = ruleset.Layout.FindByIndex(i);

                            if (name != null) // sanity
                            {
                                AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                                AddHtml(60, y, 165, 22, name, false, false);
                            }

                            y += 22;
                        }
                    }
                }
                else
                {
                    AddHtml(35, y, 190, 20, "Modifications: None", false, false);
                    y += 20;
                }

                y += 8;

                AddHtml(35, y, 176, 20, "Continue?", false, false);

                y -= 2;

                AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0);
                AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0);
                #endregion
            }
        }
Beispiel #8
0
        private void Finish_Callback()
        {
            List <DDTeamInfo> teams = new List <DDTeamInfo>();

            for (int i = 0; i < m_Context.Participants.Count; ++i)
            {
                DDTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];

                if (teamInfo != null)
                {
                    teams.Add(teamInfo);
                }
            }

            teams.Sort(delegate(DDTeamInfo a, DDTeamInfo b)
            {
                return(b.Score - a.Score);
            });

            Tournament tourny = m_Context.m_Tournament;

            StringBuilder sb = new StringBuilder();

            if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
            {
                sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
                sb.Append("-man FFA");
            }
            else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
            {
                sb.Append(tourny.ParticipantsPerMatch);
                sb.Append("-team");
            }
            else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
            {
                sb.Append("Red v Blue");
            }
            else if (tourny != null && tourny.TournyType == TournyType.Faction)
            {
                sb.Append(tourny.ParticipantsPerMatch);
                sb.Append("-team Faction");
            }
            else if (tourny != null)
            {
                for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append('v');
                    }

                    sb.Append(tourny.PlayersPerParticipant);
                }
            }

            if (m_Controller != null)
            {
                sb.Append(' ').Append(m_Controller.Title);
            }

            string title = sb.ToString();

            DDTeamInfo winner = (DDTeamInfo)(teams.Count > 0 ? teams[0] : null);

            for (int i = 0; i < teams.Count; ++i)
            {
                TrophyRank rank = TrophyRank.Bronze;

                if (i == 0)
                {
                    rank = TrophyRank.Gold;
                }
                else if (i == 1)
                {
                    rank = TrophyRank.Silver;
                }

                DDPlayerInfo leader = ((DDTeamInfo)teams[i]).Leader;

                foreach (DDPlayerInfo pl in ((DDTeamInfo)teams[i]).Players.Values)
                {
                    Mobile mob = pl.Player;

                    if (mob == null)
                    {
                        continue;
                    }

                    //"Red v Blue DD Champion"

                    sb = new StringBuilder();

                    sb.Append(title);

                    if (pl == leader)
                    {
                        sb.Append(" Leader");
                    }

                    if (pl.Score > 0)
                    {
                        sb.Append(": ");

                        sb.Append(pl.Score.ToString("N0"));
                        sb.Append(pl.Score == 1 ? " point" : " points");

                        if (pl.Kills > 0)
                        {
                            sb.Append(", ");
                            sb.Append(pl.Kills.ToString("N0"));
                            sb.Append(pl.Kills == 1 ? " kill" : " kills");
                        }

                        if (pl.Captures > 0)
                        {
                            sb.Append(", ");
                            sb.Append(pl.Captures.ToString("N0"));
                            sb.Append(pl.Captures == 1 ? " capture" : " captures");
                        }
                    }

                    Item item = new Trophy(sb.ToString(), rank);

                    if (pl == leader)
                    {
                        item.ItemID = 4810;
                    }

                    item.Name = String.Format("{0}, {1} team", item.Name, ((DDTeamInfo)teams[i]).Name.ToLower());

                    if (!mob.PlaceInBackpack(item))
                    {
                        mob.BankBox.DropItem(item);
                    }

                    int cash = pl.Score * 250;

                    if (cash > 0)
                    {
                        item = new BankCheck(cash);

                        if (!mob.PlaceInBackpack(item))
                        {
                            mob.BankBox.DropItem(item);
                        }

                        mob.SendMessage("You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", rank.ToString().ToLower(), cash);
                    }
                    else
                    {
                        mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", rank.ToString().ToLower());
                    }
                }
            }

            for (int i = 0; i < m_Context.Participants.Count; ++i)
            {
                Participant p = m_Context.Participants[i] as Participant;

                for (int j = 0; j < p.Players.Length; ++j)
                {
                    DuelPlayer dp = p.Players[j];

                    if (dp != null && dp.Mobile != null)
                    {
                        dp.Mobile.CloseGump(typeof(DDBoardGump));
                        dp.Mobile.SendGump(new DDBoardGump(dp.Mobile, this));
                    }
                }

                if (i == winner.TeamID)
                {
                    continue;
                }

                for (int j = 0; j < p.Players.Length; ++j)
                {
                    if (p.Players[j] != null)
                    {
                        p.Players[j].Eliminated = true;
                    }
                }
            }

            m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
        }
Beispiel #9
0
        public ReadyGump(Mobile from, DuelContext context, int count) : base(50, 50)
        {
            m_From    = from;
            m_Context = context;
            m_Count   = count;

            ArrayList parts = context.Participants;

            int height = 25 + 20;

            for (int i = 0; i < parts.Count; ++i)
            {
                Participant p = (Participant)parts[i];

                height += 4;

                if (p.Players.Length > 1)
                {
                    height += 22;
                }

                height += (p.Players.Length * 22);
            }

            height += 25;

            Closable = false;
            Dragable = false;

            AddPage(0);

            AddBackground(0, 0, 260, height, 9250);
            AddBackground(10, 10, 240, height - 20, 0xDAC);

            if (count == -1)
            {
                AddHtml(35, 25, 190, 20, Center("Ready"), false, false);
            }
            else
            {
                AddHtml(35, 25, 190, 20, Center("Starting"), false, false);
                AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count.ToString(), false, false);
            }

            int y = 25 + 20;

            for (int i = 0; i < parts.Count; ++i)
            {
                Participant p = (Participant)parts[i];

                y += 4;

                bool isAllReady = true;
                int  yStore     = y;
                int  offset     = 0;

                if (p.Players.Length > 1)
                {
                    AddHtml(35 + 14, y, 176, 20, String.Format("Participant #{0}", i + 1), false, false);
                    y     += 22;
                    offset = 10;
                }

                for (int j = 0; j < p.Players.Length; ++j)
                {
                    DuelPlayer pl = p.Players[j];

                    if (pl != null && pl.Ready)
                    {
                        AddImage(35 + offset, y + 4, 0x939);
                    }
                    else
                    {
                        AddImage(35 + offset, y + 4, 0x938);
                        isAllReady = false;
                    }

                    string name = (pl == null ? "(Empty)" : pl.Mobile.Name);

                    AddHtml(35 + offset + 14, y, 166, 20, name, false, false);

                    y += 22;
                }

                if (p.Players.Length > 1)
                {
                    AddImage(35, yStore + 4, isAllReady ? 0x939 : 0x938);
                }
            }
        }