Esempio n. 1
0
    /// <summary>
    /// Returns true if this LightSource can absorb the given LightSource
    /// Calculated by comparing the amount of energy in LightEnergy property of LightSources
    /// </summary>
    private bool CanAbsorb(LightSource otherLightSource)
    {
        if (!otherLightSource.CanBeAbsorbed())
        {
            return(false);
        }

        // If this light source has more energy than the other one, return true. This light source can absorb the given argument.
        if (canAbsorb && LightEnergy.CurrentEnergy > otherLightSource.LightEnergy.CurrentEnergy)
        {
            return(true);
        }

        if (canAbsorb && !otherLightSource.canAbsorb)
        {
            return(true);
        }

        // The player can always absorb a light source with LightSource.playerWillAlwaysAbsorb set to true
        if (this is Player && canAbsorb && otherLightSource.playerWillAlwaysAbsorb)
        {
            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Returns true if this LightSource can absorb the given LightSource
    /// Calculated by comparing the amount of energy in LightEnergy property of LightSources 
    /// </summary>
    private bool CanAbsorb(LightSource otherLightSource)
    {
        if (!otherLightSource.CanBeAbsorbed()) { return false; }
        
        // If this light source has more energy than the other one, return true. This light source can absorb the given argument.
        if (canAbsorb && LightEnergy.CurrentEnergy > otherLightSource.LightEnergy.CurrentEnergy) { return true; }
                       
        if (canAbsorb && !otherLightSource.canAbsorb) { return true; }        
        
        // The player can always absorb a light source with LightSource.playerWillAlwaysAbsorb set to true
        if (this is Player && canAbsorb && otherLightSource.playerWillAlwaysAbsorb) { return true; }

        return false;        
    }