Exemple #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                m_ScoreInterval = reader.ReadEncodedInt();

                m_Duration = reader.ReadTimeSpan();

                m_Boards = reader.ReadItemList();

                m_Hills = new HillOfTheKing[reader.ReadEncodedInt()];
                for (int i = 0; i < m_Hills.Length; ++i)
                {
                    m_Hills[i] = reader.ReadItem() as HillOfTheKing;
                }

                m_TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
                for (int i = 0; i < m_TeamInfo.Length; ++i)
                {
                    m_TeamInfo[i] = new KHTeamInfo(i, reader);
                }

                break;
            }
            }
        }
Exemple #2
0
        private void ReKingify(Mobile m)
        {
            KHTeamInfo ti = null;

            if (m_Game == null || m == null)
            {
                return;
            }

            ti = m_Game.GetTeamInfo(m);
            if (ti == null)
            {
                return;
            }

            m_King = m;

            if (m_KingTimer == null)
            {
                m_KingTimer = new KingTimer(this);
            }
            m_KingTimer.Stop();
            m_KingTimer.StartHillTicker();

            if (m_King.Name != null)
            {
                PublicOverheadMessage(MessageType.Regular, 0x0481, false, String.Format("Taken by {0}!", m_King.Name));
            }
        }
Exemple #3
0
        public int GetColor(Mobile mob)
        {
            KHTeamInfo teamInfo = GetTeamInfo(mob);

            if (teamInfo != null)
            {
                return(teamInfo.Color);
            }

            return(-1);
        }
Exemple #4
0
        public override bool OnDeath(Mobile mob, Container corpse)
        {
            Mobile     killer   = mob.FindMostRecentDamager(false);
            KHTeamInfo teamInfo = null;
            KHTeamInfo victInfo = GetTeamInfo(mob);
            int        bonus    = 0;

            if (killer != null && killer.Player)
            {
                teamInfo = GetTeamInfo(killer);
            }

            for (int i = 0; i < m_Controller.Hills.Length; i++)
            {
                if (m_Controller.Hills[i] == null)
                {
                    continue;
                }

                if (m_Controller.Hills[i].King == mob)
                {
                    bonus += m_Controller.Hills[i].CapturesSoFar;
                    m_Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo);
                }

                if (m_Controller.Hills[i].King == killer)
                {
                    bonus += 2;
                }
            }

            if (teamInfo != null && teamInfo != victInfo)
            {
                KHPlayerInfo playerInfo = teamInfo[killer];

                if (playerInfo != null)
                {
                    playerInfo.Kills += 1;
                    playerInfo.Score += 1 + bonus;
                }
            }

            mob.CloseGump(typeof(KHBoardGump));
            mob.SendGump(new KHBoardGump(mob, this));

            m_Context.Requip(mob, corpse);
            DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse);

            return(false);
        }
Exemple #5
0
        public int CompareTo(object obj)
        {
            KHTeamInfo ti  = (KHTeamInfo)obj;
            int        res = ti.Score.CompareTo(this.Score);

            if (res == 0)
            {
                res = ti.Captures.CompareTo(this.Captures);

                if (res == 0)
                {
                    res = ti.Kills.CompareTo(this.Kills);
                }
            }
            return(res);
        }
Exemple #6
0
        public KHController()
        {
            Visible = false;
            Movable = false;

            Name = "King of the Hill Controller";

            m_Duration = TimeSpan.FromMinutes(30.0);
            m_Boards   = new ArrayList();
            m_Hills    = new HillOfTheKing[4];
            m_TeamInfo = new KHTeamInfo[8];

            for (int i = 0; i < m_TeamInfo.Length; ++i)
            {
                m_TeamInfo[i] = new KHTeamInfo(i);
            }
        }
Exemple #7
0
        public virtual void OnKingDied(Mobile king, KHTeamInfo kingTeam, Mobile killer, KHTeamInfo killerTeam)
        {
            if (m_Game != null && CapturesSoFar > 0 && killer != null && king != null && kingTeam != null && killerTeam != null)
            {
                string kingName = king.Name;
                if (kingName == null)
                {
                    kingName = "";
                }
                string killerName = killer.Name;
                if (killerName == null)
                {
                    killerName = "";
                }

                m_Game.Alert("{0} ({1}) was dethroned by {2} ({3})!", kingName, kingTeam.Name, killerName, killerTeam.Name);
            }

            DeKingify();
        }
Exemple #8
0
        public override void OnStart()
        {
            for (int i = 0; i < m_Controller.TeamInfo.Length; ++i)
            {
                KHTeamInfo teamInfo = m_Controller.TeamInfo[i];

                teamInfo.Game = this;
                teamInfo.Reset();
            }

            for (int i = 0; i < m_Context.Participants.Count; ++i)
            {
                ApplyHues(m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length].Color);
            }

            if (m_FinishTimer != null)
            {
                m_FinishTimer.Stop();
            }

            for (int i = 0; i < m_Controller.Hills.Length; i++)
            {
                if (m_Controller.Hills[i] != null)
                {
                    m_Controller.Hills[i].Game = this;
                }
            }

            foreach (KHBoard board in m_Controller.Boards)
            {
                if (board != null && !board.Deleted)
                {
                    board.m_Game = this;
                }
            }

            m_FinishTimer = Timer.DelayCall(m_Controller.Duration, new TimerCallback(Finish_Callback));
        }
Exemple #9
0
 public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player)
 {
     m_TeamInfo = teamInfo;
     m_Player   = player;
 }
Exemple #10
0
        public KHBoardGump(Mobile mob, KHGame game)
            : base(60, 60)
        {
            m_Game = game;

            KHTeamInfo ourTeam = game.GetTeamInfo(mob);

            ArrayList entries = new ArrayList();

            for (int i = 0; i < game.Context.Participants.Count; ++i)
            {
                KHTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length];

                if (teamInfo == null)
                {
                    continue;
                }

                entries.Add(teamInfo);
            }

            entries.Sort();

            /*
             *  delegate( IRankedCTF a, IRankedCTF b )
             * {
             *  return b.Score - a.Score;
             * } );*/

            int height = 73 + (entries.Count * 75) + 28;

            Closable = false;

            AddPage(0);

            AddBackground(1, 1, 398, height, 3600);

            AddImageTiled(16, 15, 369, height - 29, 3604);

            for (int i = 0; i < entries.Count; i += 1)
            {
                AddImageTiled(22, 58 + (i * 75), 357, 70, 0x2430);
            }

            AddAlphaRegion(16, 15, 369, height - 29);

            AddImage(215, -45, 0xEE40);
            //AddImage( 330, 141, 0x8BA );

            AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32);

            AddImageTiled(32, 50, 264, 1, 9107);
            AddImageTiled(42, 52, 264, 1, 9157);

            for (int i = 0; i < entries.Count; ++i)
            {
                KHTeamInfo teamInfo = entries[i] as KHTeamInfo;

                AddImage(30, 70 + (i * 75), 10152);
                AddImage(30, 85 + (i * 75), 10151);
                AddImage(30, 100 + (i * 75), 10151);
                AddImage(30, 106 + (i * 75), 10154);

                AddImage(24, 60 + (i * 75), teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1);

                int nameColor   = LabelColor32;
                int borderColor = BlackColor32;

                switch (teamInfo.Color)
                {
                case 0x47E:
                    nameColor = 0xFFFFFF;
                    break;

                case 0x4F2:
                    nameColor = 0x3399FF;
                    break;

                case 0x4F7:
                    nameColor = 0x33FF33;
                    break;

                case 0x4FC:
                    nameColor = 0xFF00FF;
                    break;

                case 0x021:
                    nameColor = 0xFF3333;
                    break;

                case 0x01A:
                    nameColor = 0xFF66FF;
                    break;

                case 0x455:
                    nameColor   = 0x333333;
                    borderColor = 0xFFFFFF;
                    break;
                }

                AddBorderedText(60, 65 + (i * 75), 250, 20, String.Format("{0}: {1}", LadderGump.Rank(1 + i), teamInfo.Name), nameColor, borderColor);

                AddBorderedText(50 + 10, 85 + (i * 75), 100, 20, "Score:", 0xFFC000, BlackColor32);
                AddBorderedText(50 + 15, 105 + (i * 75), 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32);

                AddBorderedText(110 + 10, 85 + (i * 75), 100, 20, "Kills:", 0xFFC000, BlackColor32);
                AddBorderedText(110 + 15, 105 + (i * 75), 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32);

                AddBorderedText(160 + 10, 85 + (i * 75), 100, 20, "Captures:", 0xFFC000, BlackColor32);
                AddBorderedText(160 + 15, 105 + (i * 75), 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, BlackColor32);

                string leader = null;
                if (teamInfo.Leader != null)
                {
                    leader = teamInfo.Leader.Name;
                }
                if (leader == null)
                {
                    leader = "(none)";
                }

                AddBorderedText(235 + 10, 85 + (i * 75), 250, 20, "Leader:", 0xFFC000, BlackColor32);
                AddBorderedText(235 + 15, 105 + (i * 75), 250, 20, leader, 0xFFC000, BlackColor32);
            }

            AddButton(314, height - 42, 247, 248, 1, GumpButtonType.Reply, 0);
        }
Exemple #11
0
            protected override void OnTick()
            {
                KHTeamInfo   ti = null;
                KHPlayerInfo pi = null;

                if (m_Hill == null || m_Hill.Deleted || m_Hill.Game == null)
                {
                    Stop();
                    return;
                }

                if (m_Hill.King == null || m_Hill.King.Deleted || !m_Hill.King.Alive)
                {
                    m_Hill.DeKingify();
                    Stop();
                    return;
                }

                ti = m_Hill.Game.GetTeamInfo(m_Hill.King);
                if (ti != null)
                {
                    pi = ti[m_Hill.King];
                }

                if (ti == null || pi == null)
                {
                    // error, bail
                    m_Hill.DeKingify();
                    Stop();
                    return;
                }

                m_Counter++;

                m_Hill.King.RevealingAction();

                if (m_Counter >= m_Hill.ScoreInterval)
                {
                    string hill = m_Hill.Name;
                    string king = m_Hill.King.Name;
                    if (king == null)
                    {
                        king = "";
                    }

                    if (hill == null || hill == "")
                    {
                        hill = "the hill";
                    }

                    m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill);

                    m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!");

                    pi.Captures++;
                    m_Total++;

                    pi.Score += m_Counter;

                    m_Counter = 0;
                }
                else
                {
                    m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, (m_Hill.ScoreInterval - m_Counter).ToString());
                }
            }
Exemple #12
0
        private void Finish_Callback()
        {
            ArrayList teams = new ArrayList();

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

                if (teamInfo == null)
                {
                    continue;
                }

                teams.Add(teamInfo);
            }

            teams.Sort();

            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)
            {
                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();

            KHTeamInfo winner = (KHTeamInfo)(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;
                }

                KHPlayerInfo leader = ((KHTeamInfo)teams[i]).Leader;

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

                    if (mob == null)
                    {
                        continue;
                    }

                    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");

                        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}", item.Name, ((KHTeamInfo)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 game.", rank.ToString().ToLower(), cash);
                    }
                    else
                    {
                        mob.SendMessage("You have been awarded a {0} trophy for your participation in this game.", rank.ToString().ToLower());
                    }
                }
            }

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

                if (p == null || p.Players == null)
                {
                    continue;
                }

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

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

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

                if (p != null && p.Players != null)
                {
                    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);
        }
Exemple #13
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    {
                        m_ScoreInterval = reader.ReadEncodedInt();

                        m_Duration = reader.ReadTimeSpan();

                        m_Boards = reader.ReadItemList();

                        m_Hills = new HillOfTheKing[reader.ReadEncodedInt()];
                        for (int i = 0; i < m_Hills.Length; ++i)
                            m_Hills[i] = reader.ReadItem() as HillOfTheKing;

                        m_TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
                        for (int i = 0; i < m_TeamInfo.Length; ++i)
                            m_TeamInfo[i] = new KHTeamInfo(i, reader);

                        break;
                    }
            }
        }
Exemple #14
0
        public KHController()
        {
            Visible = false;
            Movable = false;

            Name = "King of the Hill Controller";

            m_Duration = TimeSpan.FromMinutes(30.0);
            m_Boards = new ArrayList();
            m_Hills = new HillOfTheKing[4];
            m_TeamInfo = new KHTeamInfo[8];

            for (int i = 0; i < m_TeamInfo.Length; ++i)
                m_TeamInfo[i] = new KHTeamInfo(i);
        }
Exemple #15
0
 public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player)
 {
     m_TeamInfo = teamInfo;
     m_Player = player;
 }
Exemple #16
0
        public virtual void OnKingDied(Mobile king, KHTeamInfo kingTeam, Mobile killer, KHTeamInfo killerTeam)
        {
            if (m_Game != null && CapturesSoFar > 0 && killer != null && king != null && kingTeam != null && killerTeam != null)
            {
                string kingName = king.Name;
                if (kingName == null)
                    kingName = "";
                string killerName = killer.Name;
                if (killerName == null)
                    killerName = "";

                m_Game.Alert("{0} ({1}) was dethroned by {2} ({3})!", kingName, kingTeam.Name, killerName, killerTeam.Name);
            }

            DeKingify();
        }