예제 #1
0
        public void UnitUpgrateLevel(int unitId)
        {
            var(data, unit) = _units.GetUnit(unitId);
            var playerLevel = _player.State.Level;

            if (data.Level >= playerLevel)
            {
                throw new Exception($"Unable to level up unit. Unit id = {unitId} unit level = {data.Level} current player level = {playerLevel}");
            }
            var prices = _units.GetLevel(data.Level + 1)?.Prices;

            if (prices != null)
            {
                foreach (var price in prices)
                {
                    _scorers.Spend(price.Value, _formuls);
                }
            }
            data.Exp = 0;
            data.Level++;
            _impact.ExecuteContextImpact(unit.ImpactUpdrade, unitId);
        }