コード例 #1
0
 public void AddItem(ItemBase item)
 {
     Items.Add(item);
     AllEffects.UnionWith(item.Effects);
     item.UpdateTower(this);
     UpdateStats();
     OnItemAdded?.Invoke(this, item);
 }
コード例 #2
0
        public bool OnAttacked(float damage, TowerBase tower, List <EffectBase> effects)
        {
            AllEffects.UnionWith(effects);
            var healthDelta = damage * DamageReduction * DamageTypeReduction(tower.DamageType);

            tower.EnemyAttacked(Math.Min(healthDelta, Health));
            return(UpdateHealth(-healthDelta));
        }
コード例 #3
0
        private void Start()
        {
            _animator         = GetComponentInChildren <Animator>();
            _healthBar        = transform.Find("Status").Find("Health").Find("Fill");
            _statusIndicators = transform.Find("Status").Find("Indicators").GetComponentsInChildren <SpriteRenderer>();
            UpdateHealth(0f);

            Effects.AddRange(GetComponents <EffectBase>());
            foreach (var effect in Effects)
            {
                effect.Source      = this;
                effect.IncludeGain = false;
                effect.UpdateLevel(_level + 1);
                effect.IsLoading = true;
            }
            AllEffects.UnionWith(Effects);
        }
コード例 #4
0
        private void Start()
        {
            _collider = GetComponent <CircleCollider2D>();

            if (!_isLoading)
            {
                SellCost.Base = Cost / 2f;
                SellCost.Gain = SellCost.Base / 10f;
            }
            SellCost.Value = SellCost.Base;

            Effects.AddRange(GetComponents <EffectBase>());
            Effects.ForEach(effect =>
            {
                effect.Source = this;
                effect.UpdateLevel(Level);
                effect.IsLoading = _isLoading;
            });
            AllEffects.UnionWith(Effects);

            Upgrades = GetComponents <UpgradeBase>();
            for (var i = 0; i < Upgrades.Length; i++)
            {
                Upgrades[i].Tower = this;
                if (_isLoading && _upgradeLevels.Any())
                {
                    Upgrades[i].Level     = _upgradeLevels[i];
                    Upgrades[i].IsLoading = true;
                }
            }

            if (_isLoading)
            {
                Items.ForEach(item =>
                {
                    AllEffects.UnionWith(item.Effects);
                    item.UpdateTower(this);
                });
            }

            UpdateStats();
        }