Compare commits

...

4 Commits

Author SHA1 Message Date
Sveske Juice 77a3b7f3fc Merge remote-tracking branch 'refs/remotes/origin/main' 2024-04-21 14:17:52 +02:00
Sveske Juice 504c967f45 reset managers on death/home go 2024-04-21 14:17:50 +02:00
Sveske Juice 4baa667b4e Merge remote-tracking branch 'refs/remotes/origin/main' 2024-04-21 14:04:50 +02:00
Sveske Juice ee61049de0 variable enemy damage 2024-04-21 14:04:42 +02:00
6 changed files with 18 additions and 3 deletions

View File

@ -10,6 +10,7 @@ public class EnemyCollection : ScriptableObject
public struct EnemyInfo public struct EnemyInfo
{ {
public string name; public string name;
public int damage;
public float moveSpeed; public float moveSpeed;
public bool FlyPath; public bool FlyPath;
public float feetOffset; public float feetOffset;

View File

@ -98,7 +98,7 @@ public class EnemySpawnManager : MonoBehaviour
EnemyInfo enemyInfo = enemyCollection.Enemies[group.enemyIndex]; EnemyInfo enemyInfo = enemyCollection.Enemies[group.enemyIndex];
GameObject spawned = Instantiate(enemyInfo.prefab); 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) if (enemyInfo.FlyPath)
{ {

View File

@ -43,6 +43,16 @@ public class GameManager : MonoBehaviour
health = startHealth; health = startHealth;
} }
public void Reset()
{
foreach (var go in GameObject.FindObjectsByType<GameObject>(FindObjectsSortMode.None))
{
if (go != null && go != this.gameObject)
Destroy(go);
}
Destroy(this.gameObject);
}
private void OnEnable() private void OnEnable()
{ {
MoneyManager.OnShopSelected += m_OnTowerShopSelected; MoneyManager.OnShopSelected += m_OnTowerShopSelected;

View File

@ -37,7 +37,7 @@ public class WaypointPath : MonoBehaviour
if (index + 1 >= Waypoints.Count) if (index + 1 >= Waypoints.Count)
{ {
Destroy(data.Entity.gameObject); // Destroy object when finish waypoints Destroy(data.Entity.gameObject); // Destroy object when finish waypoints
GameManager.Instance.health--; GameManager.Instance.health -= data.Damage;
} }
else else
{ {
@ -69,13 +69,15 @@ public class WaypointEntityData
public Transform NextTargetPosition; public Transform NextTargetPosition;
public float MoveSpeed; public float MoveSpeed;
public float FeetOffset; 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; Entity = entity;
MoveSpeed = moveSpeed; MoveSpeed = moveSpeed;
// feet :P // feet :P
FeetOffset = feet; FeetOffset = feet;
Damage = damage;
} }
} }

View File

@ -24,6 +24,7 @@ public class PlayerHealth : MonoBehaviour
{ {
gameOver.SetActive(true); gameOver.SetActive(true);
yield return new WaitForSecondsRealtime(5f); yield return new WaitForSecondsRealtime(5f);
GameManager.Instance.Reset();
SceneManager.LoadScene(0); SceneManager.LoadScene(0);
} }

View File

@ -7,6 +7,7 @@ public class SwitchScene : MonoBehaviour
{ {
public void SwitchToScene(string scene) public void SwitchToScene(string scene)
{ {
GameManager.Instance.Reset();
SceneManager.LoadScene(scene); SceneManager.LoadScene(scene);
} }