示例#1
0
        public void CopyFrom(StatusEffect copySource)
        {
            m_description = copySource.m_description;
            m_icon        = copySource.m_icon;
            m_duration    = copySource.m_duration;
            m_originalId  = copySource.m_originalId;
            if (m_originalId == -1)
            {
                m_originalId = copySource.GetInstanceID();
            }
            name = copySource.name;

            m_effects = new Effect[copySource.m_effects.Length];
            for (int i = 0; i < copySource.m_effects.Length; ++i)
            {
                m_effects[i] = copySource.m_effects[i].DeepCopy() as Effect;
                Debug.Assert(m_effects[i] != null, "Unexpected data type");
            }
        }
示例#2
0
        /// <summary>
        /// Apply a status effect to the handler
        /// </summary>
        /// <param name="statusEffect"> The status effect to be applied </param>
        public void Apply(StatusEffect statusEffect)
        {
            int originalId = statusEffect.GetInstanceID();

            //If the player has that status effect already, refresh the duration
            if (m_statusEffects.ContainsKey(originalId))
            {
                //Refresh the duration of the status effect currently applied on the player
                m_statusEffects[originalId].RefreshDuration();
            }
            else
            {
                //Create a copy of the status effect
                StatusEffect newStatusEffect = ScriptableObject.CreateInstance <StatusEffect>();
                newStatusEffect.CopyFrom(statusEffect);

                //Apply the status effect copy to the player
                m_statusEffects[originalId] = newStatusEffect;
                newStatusEffect.OnApplied(this);
            }
        }