Example #1
0
        public void SpawnImpact(WeaponData.WeaponType weaponType, Vector3 position)
        {
            PooledObject pooledObject = ObjectPoolManager.Instance.GetPooledObject(WeaponData.GetImpactPool(weaponType), AmmoContainer.transform);
            Impact       impact       = pooledObject?.GetComponent <Impact>();

            if (null == impact)
            {
                return;
            }

            impact.transform.position = position;

            StartCoroutine(ImpactCoroutine(pooledObject));
        }
Example #2
0
        public virtual void Initialize(Fighter fighter, int slotId, WeaponData.WeaponType weaponType, int damage)
        {
            Fighter = fighter;

            gameObject.layer = fighter.gameObject.layer;

            WeaponType = weaponType;
            Damage     = damage;

            Transform spawn = fighter.GetWeaponAmmoSpawnTransform(slotId);

            transform.position = spawn.position;
            transform.rotation = spawn.rotation;
        }
Example #3
0
        public void Damage(int amount, WeaponData.WeaponType type)
        {
            if (!GameStageManager.Instance.IsGameStarted)
            {
                return;
            }

            float reducedAmount = amount - (amount * _armor.GetDamageReduction(type));

            if (reducedAmount < MinimumDamage)
            {
                reducedAmount = MinimumDamage;
            }
            CurrentHealth -= reducedAmount;
        }
Example #4
0
        public void IncreaseStrength(WeaponData.WeaponType type, int strength, int damageReductionPercent, int maxReductionPercent)
        {
            if (!_damageReductionPercents.ContainsKey(type))
            {
                return;
            }

            // TODO: can this be done with math rather than a for-loop?
            int reduction = _damageReductionPercents[type];

            for (int i = 0; i < strength; ++i)
            {
                reduction = (int)Mathf.Clamp(reduction + (100 - reduction) * (damageReductionPercent / 100.0f), 0, maxReductionPercent);
            }
            _damageReductionPercents[type] = reduction;
        }
Example #5
0
 public float GetDamageReduction(WeaponData.WeaponType type)
 {
     return(_damageReductionPercents.GetOrDefault(type) / 100.0f);
 }
Example #6
0
        public override void Initialize(Fighter fighter, int slotId, WeaponData.WeaponType weaponType, int damage)
        {
            base.Initialize(fighter, slotId, weaponType, damage);

            _rigidBody.velocity = Fighter.Forward * _velocity;
        }