Ejemplo n.º 1
0
    /// <summary>
    /// Reduce the food by X. Apply a Hungry status effect if the food equals to 0.
    /// </summary>
    /// <param name="value">Amount of food to deduct.</param>
    public void ReduceFood(float value)
    {
        Food -= value;

        if (Food <= 0)
        {
            Food = 0;
            StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 0.5f, StatusEffectManager.GetStatusEffectData(Constant.STARVING)));
        }

        OnUpdateFoodEvent?.Invoke(Food);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Increase the food bar by X. Remove any Hungry status effects.
    /// </summary>
    /// <param name="value">Amount of food to restore.</param>
    public void IncreaseFood(float value)
    {
        Food += value;

        StatusEffectScheduler.Instance(_actor.Guid).RemoveStatusEffect(Constant.STARVING);

        if (Food > Constant.ACTOR_BASE_FOOD)
        {
            Food = Constant.ACTOR_BASE_FOOD;
        }

        OnUpdateFoodEvent?.Invoke(Food);
    }