From ee61049de024ddb8b73c51044d564b2040f7f2b8 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sun, 21 Apr 2024 14:04:42 +0200 Subject: [PATCH] variable enemy damage --- Assets/Scripts/Classes/EnemyCollection.cs | 1 + Assets/Scripts/Manager/EnemySpawnManager.cs | 2 +- Assets/Scripts/Manager/WaypointPath.cs | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Classes/EnemyCollection.cs b/Assets/Scripts/Classes/EnemyCollection.cs index 2d792f9..3feb9cb 100644 --- a/Assets/Scripts/Classes/EnemyCollection.cs +++ b/Assets/Scripts/Classes/EnemyCollection.cs @@ -10,6 +10,7 @@ public class EnemyCollection : ScriptableObject public struct EnemyInfo { public string name; + public int damage; public float moveSpeed; public bool FlyPath; public float feetOffset; diff --git a/Assets/Scripts/Manager/EnemySpawnManager.cs b/Assets/Scripts/Manager/EnemySpawnManager.cs index 79b8cea..50ecbfb 100644 --- a/Assets/Scripts/Manager/EnemySpawnManager.cs +++ b/Assets/Scripts/Manager/EnemySpawnManager.cs @@ -99,7 +99,7 @@ public class EnemySpawnManager : MonoBehaviour EnemyInfo enemyInfo = enemyCollection.Enemies[group.enemyIndex]; GameObject spawned = Instantiate(enemyInfo.prefab); - WaypointEntityData data = new WaypointEntityData(spawned.transform, enemyInfo.moveSpeed, enemyInfo.feetOffset); + WaypointEntityData data = new WaypointEntityData(spawned.transform, enemyInfo.moveSpeed, enemyInfo.feetOffset, enemyInfo.damage); if (enemyInfo.FlyPath) { diff --git a/Assets/Scripts/Manager/WaypointPath.cs b/Assets/Scripts/Manager/WaypointPath.cs index 3ad27fc..1497461 100644 --- a/Assets/Scripts/Manager/WaypointPath.cs +++ b/Assets/Scripts/Manager/WaypointPath.cs @@ -37,7 +37,7 @@ public class WaypointPath : MonoBehaviour if (index + 1 >= Waypoints.Count) { Destroy(data.Entity.gameObject); // Destroy object when finish waypoints - GameManager.Instance.health--; + GameManager.Instance.health -= data.Damage; } else { @@ -69,13 +69,15 @@ public class WaypointEntityData public Transform NextTargetPosition; public float MoveSpeed; public float FeetOffset; + public int Damage; - public WaypointEntityData(Transform entity, float moveSpeed, float feet) + public WaypointEntityData(Transform entity, float moveSpeed, float feet, int damage) { Entity = entity; MoveSpeed = moveSpeed; // feet :P FeetOffset = feet; + Damage = damage; } }