Server.Items.Aquarium.GiveReward C# (CSharp) Méthode

GiveReward() public méthode

public GiveReward ( Server.Mobile to ) : void
to Server.Mobile
Résultat void
        public virtual void GiveReward( Mobile to )
        {
            if ( !m_RewardAvailable )
                return;

            int max = (int) ( ( (double) m_LiveCreatures / 30 ) * m_Decorations.Length );

            int random = ( max <= 0 ) ? 0 : Utility.Random( max );

            if ( random >= m_Decorations.Length )
                random = m_Decorations.Length - 1;

            Item item;

            try
            {
                item = Activator.CreateInstance( m_Decorations[ random ] ) as Item;
            }
            catch
            {
                return;
            }

            if ( item == null )
                return;

            if ( !to.PlaceInBackpack( item ) )
            {
                item.Delete();
                to.SendLocalizedMessage( 1074361 ); // The reward could not be given.  Make sure you have room in your pack.
                return;
            }

            to.SendLocalizedMessage( 1074360, String.Format( "#{0}", item.LabelNumber ) ); // You receive a reward: ~1_REWARD~
            to.PlaySound( 0x5A3 );

            m_RewardAvailable = false;

            InvalidateProperties();
        }

Usage Example

Exemple #1
0
            public override void OnClick()
            {
                if (m_Aquarium.Deleted || !m_Aquarium.HasAccess(Owner.From))
                {
                    return;
                }

                m_Aquarium.GiveReward(Owner.From);
            }
All Usage Examples Of Server.Items.Aquarium::GiveReward