Esempio n. 1
0
        public CTFTeamInfo(int teamID, GenericReader ip)
        {
            m_TeamID  = teamID;
            m_Players = new Dictionary <Mobile, CTFPlayerInfo>();

            int version = ip.ReadEncodedInt();

            switch (version)
            {
            case 2:
            {
                m_Board = ip.ReadItem() as CTFBoard;

                goto case 1;
            }

            case 1:
            {
                m_Name = ip.ReadString();

                goto case 0;
            }

            case 0:
            {
                m_Color = ip.ReadEncodedInt();

                m_Flag   = ip.ReadItem() as CTFFlag;
                m_Origin = ip.ReadPoint3D();
                break;
            }
            }
        }
Esempio n. 2
0
        private void Flag_OnTarget(Mobile from, object obj)
        {
            if (m_TeamInfo == null)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                return;
            }

            CTFTeamInfo ourTeam = m_TeamInfo;
            CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo(from);

            if (obj is CTFFlag)
            {
                if (obj == useTeam.Flag)
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You captured the cookies!");
                    m_TeamInfo.Game.Alert("{0} captured the {1} cookies!", from.Name, ourTeam.Name);

                    SendHome();

                    CTFPlayerInfo playerInfo = useTeam[from];

                    if (playerInfo != null)
                    {
                        playerInfo.Captures += 1;
                        playerInfo.Score    += 50; // capture

                        CTFFlag teamFlag = useTeam.Flag;

                        if (teamFlag.m_Fragger != null && DateTime.UtcNow < (teamFlag.m_FragTime + TimeSpan.FromSeconds(5.0)) && m_TeamInfo.Game.GetTeamInfo(teamFlag.m_Fragger) == useTeam)
                        {
                            CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Fragger];

                            if (assistInfo != null)
                            {
                                assistInfo.Score += 6; // frag assist
                            }
                        }

                        if (teamFlag.m_Returner != null && DateTime.UtcNow < (teamFlag.m_ReturnTime + TimeSpan.FromSeconds(5.0)))
                        {
                            CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Returner];

                            if (assistInfo != null)
                            {
                                assistInfo.Score += 4; // return assist
                            }
                        }
                    }
                }
                else
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "Those are not my cookies.");
                }
            }
            else if (obj is Mobile)
            {
                Mobile passTo = obj as Mobile;

                CTFTeamInfo passTeam = m_TeamInfo.Game.GetTeamInfo(passTo);

                if (passTo == from)
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them.");
                }
                else if (passTeam == useTeam && passTo.PlaceInBackpack(this))
                {
                    passTo.LocalOverheadMessage(MessageType.Regular, 0x59, false, String.Format("{0} has passed you the cookies!", from.Name));
                }
                else
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them.");
                }
            }
        }