コード例 #1
0
    /// <summary>
    /// Add a new status effect to the list of active effects.
    /// Managing for stacking properties, override properties
    /// Then tells the effect to start itself.
    /// </summary>
    /// <param name="effect">The effect obect to begin on the boat.</param>
    public void AddNewEffect(StatusEffect effect)
    {
        int currentStacksActive;

        //if the effect is not currently in the list
        //or if the effect has less than its maximum allowed amount of stacks in the list
        //or if the new effect always overrides existing effects no matter what
        //add the effect to the list
        if (!IsSameTypeEffectInList(effect, out currentStacksActive) || currentStacksActive < effect.GetMaxStacks() || effect.DoesOverrideExisting())
        {
            if (effect.DoesOverrideExisting())
            {
                Debug.Log("Overrideing existing status effects of type " + effect.GetType());
                RemoveSameTypeEffectsFromList(effect);
            }
            Debug.Log("Adding new status effect of type " + effect.GetType());
            effect.StartEffect(playerBoat);
            activeEffects.Add(effect);
        }
        else
        {
            Debug.Log("Could not add new status effect of type " + effect.GetType() + " since too many stacks already active");
        }
    }