Example #1
0
        public void Collect([NotNull] UnitViewModel unit)
        {
            Assert.IsNotNull(unit, nameof(unit));

            var income = unit.Income.TakeAll();

            Resources.Add(income);
        }
Example #2
0
        public void UpgradeUnit([NotNull] UnitViewModel unit)
        {
            Assert.IsNotNull(unit, nameof(unit));

            var config = GetUnitConfig(unit.Type);

            if (config == null)
            {
                return;
            }
            if (unit.Level.Value >= (config.Levels.Count - 1))
            {
                return;
            }
            var upgradePrice = unit.UpgradePrice.Value.Model;

            if (Resources.TryTake(upgradePrice))
            {
                unit.Upgrade();
            }
        }