public CharacterStatus(CharacterStatusInfo info) { Info = info; Strength = new IntReactiveProperty(0); Agility = new IntReactiveProperty(0); MaxHealth = new ReactiveProperty <float>(Info.MaxHealth); MoveSpeed = new ReactiveProperty <float>(Info.MoveSpeed); ModifierCalculator = new ModifierCalculator(); ModifierCalculator.Changed += OnModifiersChange; }
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); } }
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); } }
public virtual void SetCharacter(Character character) { Character = character; Inventory = character.Inventory; ModifierCalculator = character.Status.ModifierCalculator; }