Antura.UI.MinigamesUILives.SetCurrLives C# (CSharp) Method

SetCurrLives() public method

Sets the current lives to the given value and returns the value (representing the lives with a full heart).
public SetCurrLives ( int _to, bool _canExceedMax = false ) : int
_to int Lives to set as active (with full heart)
_canExceedMax bool If TRUE and the new value is higher than , /// new life objects are created and is modified accordingly.
return int
        public int SetCurrLives(int _to, bool _canExceedMax = false)
        {
            if (!Validate("MinigamesUILives")) { return 0; }

            if (!_canExceedMax && _to > MaxLives) {
                _to = MaxLives;
            }
            if (CurrLives == _to) {
                return CurrLives;
            }

            if (_to < 0) {
                _to = 0;
            }
            CurrLives = _to;
            for (int i = 0; i < lives.Count; i++) {
                MinigamesUISingleLife life = lives[i];
                if (i < _to) {
                    life.Gain();
                } else {
                    life.Lose();
                }
            }
            _to -= lives.Count;
            while (_to > 0) {
                _to--;
                MinigamesUISingleLife life = (MinigamesUISingleLife)Instantiate(LifePrefab, LifePrefab.transform.parent, false);
                life.gameObject.SetActive(true);
                lives.Add(life);
            }
            int actualMaxLives = lives.Count;
            if (MaxLives < actualMaxLives) {
                MaxLives = actualMaxLives;
            }
            return _to;
        }