/// <summary>Adds X (<paramref name="value"/>) points to this PointSystem's Current Points.</summary> /// <remarks> /// If, after the calculation, the amount /// of points is less then MaxPoints, then it triggers OnPointsIncreased and OnPointsChanged events. However if, after the calculation, the amount /// of points is greater or equal to MaxPoints, then it triggers OnPointsIncreased, OnPointsChanged and OnPointsMax events. ///</remarks> /// <param name="value">value to be summed to this PointSystem's Current Points.</param> public void AddPoints(int value) { if (value > 0) { int aux = currentPoints + value;// Propriedade auxiliar para não precisar repetir função if (aux >= maxPoints) { currentPoints = maxPoints; OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs { CurrentPointsEventArgs = currentPoints }; OnPointsMax?.Invoke(this, EventArgsData); OnPointsIncreased?.Invoke(this, EventArgsData); OnPointsChanged?.Invoke(this, EventArgsData); } else { currentPoints = aux; OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs { CurrentPointsEventArgs = currentPoints }; OnPointsIncreased?.Invoke(this, EventArgsData); OnPointsChanged?.Invoke(this, EventArgsData); } } else { Debug.LogError("value can't be negative nor zero!"); } }
/// <summary> /// Set currentPoints in the PointsSystem instance /// </summary> public void SetCurrentPoints(int currentpoints) { if (currentpoints > 0 && currentpoints <= maxPoints) { OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs { CurrentPointsEventArgs = currentPoints }; if (currentpoints == maxPoints) { OnPointsMax?.Invoke(this, EventArgsData); } currentPoints = currentpoints; OnPointsChanged?.Invoke(this, EventArgsData); } else { Debug.LogError("value can't be negative, zero nor greater then MaxPoints!"); } }