From 92bc697150d34ef043f9c7e6aa0b0a932397d66a Mon Sep 17 00:00:00 2001
From: Ny Bruker <robinhs@stud.ntnu.no>
Date: Sun, 2 Oct 2022 16:26:18 +0200
Subject: [PATCH] Implemented new system for attacks.

---
 .../Code/Core/Abilities/BasicProjectile1.cs   | 35 +++++++++++++------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/MrBigsock/Assets/Code/Core/Abilities/BasicProjectile1.cs b/MrBigsock/Assets/Code/Core/Abilities/BasicProjectile1.cs
index b7e1e818..15aa963e 100644
--- a/MrBigsock/Assets/Code/Core/Abilities/BasicProjectile1.cs
+++ b/MrBigsock/Assets/Code/Core/Abilities/BasicProjectile1.cs
@@ -16,17 +16,19 @@ namespace BigSock {
 		//protected static readonly GameObject PROJECTILE_BASE = new AttackMovement();
 		public const string PROJECTILE_NAME = "attack";
 
-		/*
-			The attack stats of the ability.
-		*/
-		public IAttackStats AttackStats { get; set; }
-
-
+		
+		public override ulong Id => 101;
+		public override string Name => "Basic Player Projectile Attack";
+		public override string Description => "A basic projectile shooting attack the player has.";
 
 		public BasicProjectile1() {
-			Name = "Basic Player Projectile Attack";
-			Id = 101;
-			Description = "A basic projectile shooting attack the player has.";
+			AttackStats = new AttackStats{
+				Damage = 1f,
+				Knockback = 1f,
+				Range = 10f,
+				ProjectileSpeed = 10f,
+				AttackSpeed = 1f,
+			};
 		}
 
 
@@ -38,8 +40,21 @@ namespace BigSock {
 			This should be overridden in sub-classes for the actual abilities.
 		*/
 		protected override bool Activate(Character actor, Vector3? target) {
+			if(target == null) return false;
+
+			var attack = (AttackStats) AttackStats.Apply(actor.Stats);
+			attack.Actor = actor;
+
+
+			var temp = (target.Value - actor.transform.position);
+			temp.z = 0;
+
 			var bullet = PrefabService.SINGLETON.Instance(PROJECTILE_NAME, actor.transform.position);
-			bullet.GetComponent<AttackMovement>().Actor = actor;
+			var bulletScript = bullet.GetComponent<AttackMovement>();
+			//bulletScript.Actor = actor;
+			bulletScript.Stats = attack;
+			bulletScript.Direction = temp.normalized;
+
 
 			//MonoBehaviour.Instantiate(PROJECTILE_BASE, (Vector3) actor.transform.position, PROJECTILE_BASE.transform.rotation);
 			return true;
-- 
GitLab