diff --git a/MrBigsock/Assets/Code/attack/AttackMovement.cs b/MrBigsock/Assets/Code/attack/AttackMovement.cs index 37b53fa9705d5bfb24c47e4824e351bdf21de880..aa7795a3385fed211ac5008c6d464885cd9634fa 100644 --- a/MrBigsock/Assets/Code/attack/AttackMovement.cs +++ b/MrBigsock/Assets/Code/attack/AttackMovement.cs @@ -4,29 +4,44 @@ using UnityEngine; using UnityEngine.InputSystem; using static UnityEngine.GraphicsBuffer; +using BigSock.Service; + + namespace BigSock { public class AttackMovement : MonoBehaviour { public float speed = 10.0f; bool moved = false; - Vector3 direction; + //Vector3 direction; + Vector3 startingPos; /* Damage of the character. */ - public float Damage => baseDamage; - public float baseDamage = 1; + //public float Damage => baseDamage; + //public float baseDamage = 1; - public float KnockbackForce => knockbackForce; - public float knockbackForce = 1; + //public float KnockbackForce => knockbackForce; + //public float knockbackForce = 1; /* The character that activated the attack. */ - public Character Actor { get; set; } + //public Character Actor { get; set; } + + /* + The attack stats of the attack. + */ + public AttackStats Stats { get; set; } + + /* + The direction of the attack. + */ + public Vector3 Direction { get; set; } + - // Start is called before the first frame update + // Start is called before the first frame update void Start() { } @@ -36,18 +51,26 @@ namespace BigSock { { if (!moved) { - var mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition); - var pos = transform.position; - var temp = (mouse - pos); - temp.z = 0; - direction = temp.normalized; + //var mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition); + //var pos = transform.position; + //var temp = (mouse - pos); + //temp.z = 0; + //direction = temp.normalized; //print($"[AttackMovement.Update()] {mouse} - {pos} = {direction}"); + startingPos = transform.position; moved = true; } //transform.Translate(new Vector3(1 * horizontalInput, 1 * verticalInput, 0) * speed * Time.deltaTime); - transform.Translate(direction * speed * Time.deltaTime); - + transform.Translate(Direction * Stats.ProjectileSpeed * Time.deltaTime); + + var traveled = Vector2.Distance(transform.position, startingPos); + + // If we traveled passed our range: destroy this obj. + if(traveled > Stats.Range) { + PrefabService.SINGLETON.Destroy(gameObject); + } + } @@ -58,23 +81,24 @@ namespace BigSock { if(target != null) { - var attack = new AttackStats{ - Damage = Damage, - Knockback = KnockbackForce, - //Range = 0, - //AttackSpeed = AttackSpeed, - Source = transform.position, - Actor = Actor, - }; + //var attack = new AttackStats{ + // Damage = Damage, + // Knockback = KnockbackForce, + // //Range = 0, + // //AttackSpeed = AttackSpeed, + // Source = transform.position, + // Actor = Actor, + //}; + Stats.Source = transform.position; // If we have an actor: Apply their stat mods & trigger their OnHit. - if(Actor != null) { - attack.Damage *= Actor.Damage; - attack.Knockback *= Actor.KnockbackForce; - //Actor.TargetHit(target, attack); - } + //if(Actor != null) { + // attack.Damage *= Actor.Damage; + // attack.Knockback *= Actor.KnockbackForce; + // //Actor.TargetHit(target, attack); + //} - if(target.TakeDamage(attack)) { + if(target.TakeDamage(Stats)) { } }