| 123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using RPG_Fight_Test.Assets.Scripts.Weapons;
- using UnityEngine;
- public class AttackAction : IAction {
- private Creature Target;
- private Creature Attacker;
- bool hilightEnbled = true;
- public bool HilightEnabled { get => hilightEnbled; set => hilightEnbled = value; }
- public AttackAction(Creature attacker, Creature target) {
- Target = target;
- Attacker = attacker;
- }
- private bool actionPerformed;
- public bool ActionPerformed { get => actionPerformed; set => actionPerformed = value; }
- public IEnumerator PerformAction() {
- int chanseToHit = Attacker.PrimaryWeapon.AttackProficiency - Target.Evade;
- int attackRoll = Random.Range(1, 100);
- string message = Attacker.name + " attacked " + Target.name + " with a chanse to hit " + chanseToHit + " and attack roll " + attackRoll;
- if (attackRoll < chanseToHit) {
- // hit the attack roll damage;
- int damage = Attacker.PrimaryWeapon.RollDamage();
- message += " and hit for " + damage + " damage";
- Target.TakeDamage(damage);
- }
- GameManagerScript.GetInstance().LogRow(message);
- actionPerformed = true;
- yield return new WaitForSeconds(3);
- }
- }
|