Пример #1
0
        /// <summary>Removes X (<paramref name="value"/>) points from this PointSystem's Current Points (always use positive values, the calculation is made within the function).</summary>
        /// <remarks>
        /// If, after the calculation, the amount
        /// of points is greater then 0, then it triggers OnPointsDecreased and OnPointsChanged events. However if, after the calculation, the amount
        /// of points is less or equal to 0 then it triggers OnPointsDecreased, OnPointsChanged and OnPointsZero events.
        ///</remarks>
        /// <param name="value">value to be subtracted from this PointSystem 's Current Points.</param>
        public void RemovePoints(int value)
        {
            if (value > 0)
            {
                int aux = currentPoints - value;

                if (aux > 0)
                {
                    currentPoints = aux;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsDecreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                }

                else
                {
                    currentPoints = 0;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsDecreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                    OnPointsZero?.Invoke(this, EventArgsData);
                }
            }
            else
            {
                Debug.LogError("value can't be negative nor zero!");
            }
        }
Пример #2
0
        /// <summary>
        /// Set CurrentPoints variable to 0
        /// </summary>
        /// <remarks>Triggers the OnPointsChanged and OnPointsZero events</remarks>
        public void ResetPoints()
        {
            currentPoints = 0;

            OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                CurrentPointsEventArgs = currentPoints
            };

            OnPointsChanged?.Invoke(this, EventArgsData);
            OnPointsZero?.Invoke(this, EventArgsData);
        }