Exemplo n.º 1
0
        public override void Attack(Vector3 direction)
        {
            if (!IsAttackAvailable)
            {
                return;
            }

            if (AttackAction != null)
            {
                AttackAction();
            }

            var shotsFired = 0;

            for (var i = 0; i < _typedInfo._projectilesPerShot; ++i)
            {
                var projectile          = GetProjectileInstance();
                var projectileDirection = GetOffsetDirection(direction, i);
                var finalDamage         = ModifierCalculator.CalculateFinalValue(ModifierType.BaseDamage, _typedInfo.BaseDamage);

                projectile.Launch(Character, projectileDirection,
                                  _typedInfo._projectileSpeed, finalDamage, _typedInfo.CanFriendlyFire,
                                  _typedInfo._splashDamageRadius);

                AttackDirection = direction;
                EventSystem.RaiseEvent(new Fire {
                    Character = Character, Weapon = this
                });

                if (_behaviour.TryShoot())
                {
                    AmmoInClip -= ClipSize;
                }

                if (_behaviour.IsReloading)
                {
                    break;
                }
            }

            var sound = _typedInfo._sounds.RandomElement();

            if (sound != null)
            {
                AudioSource.PlayClipAtPoint(sound, Character.Pawn.position, 0.5f);
            }
        }
Exemplo n.º 2
0
        public override void Attack(Character target, EnemyCharacterStatusInfo statusInfo)
        {
            if (target == null || !IsAttackAvailable)
            {
                return;
            }

            if (AttackAction != null)
            {
                AttackAction();
            }

            for (var i = 0; i < _typedInfo._projectilesPerShot; ++i)
            {
                var projectile      = GetProjectileInstance();
                var targetDirection = (target.Pawn.position - Character.Pawn.position).Set(y: 0).normalized;

                AttackDirection = targetDirection;

                var projectileDirection = GetOffsetDirection(targetDirection, i);

                var finalDamage = ModifierCalculator.CalculateFinalValue(ModifierType.BaseDamage,
                                                                         _typedInfo.BaseDamage);
                projectile.Launch(Character, projectileDirection, _typedInfo._projectileSpeed, finalDamage, _typedInfo.CanFriendlyFire, _typedInfo._splashDamageRadius);
                if (_behaviour.TryShoot())
                {
                    AmmoInClip -= ClipSize;
                }

                if (_behaviour.IsReloading)
                {
                    break;
                }
            }

            var sound = _typedInfo._sounds.RandomElement();

            if (sound != null)
            {
                AudioSource.PlayClipAtPoint(sound, Character.Pawn.position, 0.5f);
            }
        }
Exemplo n.º 3
0
 private void OnModifiersChange()
 {
     MoveSpeed.Value = ModifierCalculator.CalculateFinalValue(ModifierType.BaseMoveSpeed, Info.MoveSpeed);
     //MaxHealth = ModifierCalculator.CalculateFinalValue( Base )
 }