Beispiel #1
0
        public void Broadcast(int hue, string text)
        {
            PlayerStateCollection members = Members;

            for (int i = 0; i < members.Count; ++i)
            {
                members[i].Mobile.SendMessage(hue, text);
            }
        }
Beispiel #2
0
        public void Broadcast(int number)
        {
            PlayerStateCollection members = Members;

            for (int i = 0; i < members.Count; ++i)
            {
                members[i].Mobile.SendLocalizedMessage(number);
            }
        }
Beispiel #3
0
 public FactionState(Faction faction)
 {
     m_Faction      = faction;
     m_Tithe        = 50;
     m_Members      = new PlayerStateCollection();
     m_Election     = new Election(faction);
     m_FactionItems = new FactionItemCollection();
     m_FactionTraps = new FactionTrapCollection();
 }
 public FactionState( Faction faction )
 {
     m_Faction = faction;
     m_Tithe = 50;
     m_Members = new PlayerStateCollection();
     m_Election = new Election( faction );
     m_FactionItems = new FactionItemCollection();
     m_FactionTraps = new FactionTrapCollection();
 }
Beispiel #5
0
        public PlayerState(Mobile mob, Faction faction, PlayerStateCollection owner)
        {
            m_Mobile  = mob;
            m_Faction = faction;
            m_Owner   = owner;

            m_Rank = faction.Definition.Ranks[faction.Definition.Ranks.Length - 1];

            Attach();
            Invalidate();
        }
Beispiel #6
0
        public PlayerState( Mobile mob, Faction faction, PlayerStateCollection owner )
        {
            m_Mobile = mob;
            m_Faction = faction;
            m_Owner = owner;

            m_Rank = faction.Definition.Ranks[faction.Definition.Ranks.Length - 1];

            Attach();
            Invalidate();
        }
Beispiel #7
0
        public void UpdateRanks()
        {
            PlayerStateCollection members = Members;

            ArrayList list = new ArrayList(members);

            list.Sort();

            RankDefinition[] ranks = m_Definition.Ranks;

            for (int i = 0; i < list.Count; ++i)
            {
                PlayerState pl = (PlayerState)list[i];

                int percent;

                if (list.Count == 1)
                {
                    percent = 1000;
                }
                else
                {
                    percent = (i * 1000) / (list.Count - 1);
                }

                RankDefinition rank = null;

                for (int j = 0; j < ranks.Length; ++j)
                {
                    RankDefinition check = ranks[j];

                    if (percent >= check.Required)
                    {
                        rank = check;
                        break;
                    }
                }

                if (pl.Rank != rank)
                {
                    pl.Rank = rank;
                    OnRankUpdate(pl);
                }
            }
        }
Beispiel #8
0
        public PlayerState(GenericReader reader, Faction faction, PlayerStateCollection owner)
        {
            m_Faction = faction;
            m_Owner   = owner;

            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 0:
            {
                m_Mobile = reader.ReadMobile();

                m_KillPoints    = reader.ReadEncodedInt();
                m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();

                m_Leaving = reader.ReadDateTime();

                break;
            }
            }

            Attach();
        }
Beispiel #9
0
        public PlayerState( GenericReader reader, Faction faction, PlayerStateCollection owner )
        {
            m_Faction = faction;
            m_Owner = owner;

            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 0:
                    {
                        m_Mobile = reader.ReadMobile();

                        m_KillPoints = reader.ReadEncodedInt();
                        m_MerchantTitle = (MerchantTitle) reader.ReadEncodedInt();

                        m_Leaving = reader.ReadDateTime();

                        break;
                    }
            }

            Attach();
        }
 /// <summary>
 /// Default constructor for enumerator.
 /// </summary>
 /// <param name="collection">Instance of the collection to enumerate.</param>
 internal PlayerStateCollectionEnumerator(PlayerStateCollection collection)
 {
     _index = -1;
     _collection = collection;
 }
Beispiel #11
0
 /// <summary>
 /// Default constructor for enumerator.
 /// </summary>
 /// <param name="collection">Instance of the collection to enumerate.</param>
 internal PlayerStateCollectionEnumerator(PlayerStateCollection collection)
 {
     _index      = -1;
     _collection = collection;
 }
        public FactionState( GenericReader reader )
        {
            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 4:
                {
                    int count = reader.ReadEncodedInt();

                    for ( int i = 0; i < count; ++i )
                    {
                        DateTime time = reader.ReadDateTime();

                        if ( i < m_LastBroadcasts.Length )
                            m_LastBroadcasts[i] = time;
                    }

                    goto case 3;
                }
                case 3:
                case 2:
                case 1:
                {
                    m_Election = new Election( reader );

                    goto case 0;
                }
                case 0:
                {
                    m_Faction = Faction.ReadReference( reader );

                    m_Commander = reader.ReadMobile();

                    if ( version < 4 )
                    {
                        DateTime time = reader.ReadDateTime();

                        if ( m_LastBroadcasts.Length > 0 )
                            m_LastBroadcasts[0] = time;
                    }

                    m_Tithe = reader.ReadEncodedInt();
                    m_Silver = reader.ReadEncodedInt();

                    int memberCount = reader.ReadEncodedInt();

                    m_Members = new PlayerStateCollection();

                    for ( int i = 0; i < memberCount; ++i )
                    {
                        PlayerState pl = new PlayerState( reader, m_Faction, m_Members );

                        if ( pl.Mobile != null )
                            m_Members.Add( pl );
                    }

                    m_Faction.State = this;
                    m_Faction.UpdateRanks();

                    m_FactionItems = new FactionItemCollection();

                    if ( version >= 2 )
                    {
                        int factionItemCount = reader.ReadEncodedInt();

                        for ( int i = 0; i < factionItemCount; ++i )
                        {
                            FactionItem factionItem = new FactionItem( reader, m_Faction );

                            if ( !factionItem.HasExpired )
                                factionItem.Attach();
                            else
                                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( factionItem.Detach ) ); // sandbox detachment
                        }
                    }

                    m_FactionTraps = new FactionTrapCollection();

                    if ( version >= 3 )
                    {
                        int factionTrapCount = reader.ReadEncodedInt();

                        for ( int i = 0; i < factionTrapCount; ++i )
                        {
                            BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                            if ( trap != null && !trap.CheckDecay() )
                                m_FactionTraps.Add( trap );
                        }
                    }

                    break;
                }
            }

            if ( version < 1 )
                m_Election = new Election( m_Faction );
        }
Beispiel #13
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new PlayerStateCollection();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;
                m_Faction.UpdateRanks();

                m_FactionItems = new FactionItemCollection();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        if (!factionItem.HasExpired)
                        {
                            factionItem.Attach();
                        }
                        else
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.Detach));                                         // sandbox detachment
                        }
                    }
                }

                m_FactionTraps = new FactionTrapCollection();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }