diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 0b6564d..29c3962 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -675,6 +675,10 @@ PrefabInstance: propertyPath: gameFlowManager value: objectReference: {fileID: 1359990806} + - target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} + propertyPath: arena + value: + objectReference: {fileID: 397851252} - target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} propertyPath: healthBar value: diff --git a/Assets/Scripts/AIEntity.cs b/Assets/Scripts/AIEntity.cs index 382ad86..0c4080a 100644 --- a/Assets/Scripts/AIEntity.cs +++ b/Assets/Scripts/AIEntity.cs @@ -153,17 +153,20 @@ public class AIEntity : Entity if(!entity.IsAlive()){ return new DeadState(entity); } - if(entity.IsInAttackRange()){ - if(entity.attackTimer >= entity.attackCooldown){ - entity.attackTimer = 0; - return Attack(); - }else{ - entity.attackTimer += Time.deltaTime; - } + + if (entity.gameFlowManager.CanDoAction) { + if(entity.IsInAttackRange()){ + if(entity.attackTimer >= entity.attackCooldown){ + entity.attackTimer = 0; + return Attack(); + }else{ + entity.attackTimer += Time.deltaTime; + } - }else{ - return new SeekState(entity); + }else + return new SeekState(entity); } + return null; } diff --git a/Assets/Scripts/GameFlowManager.cs b/Assets/Scripts/GameFlowManager.cs index 22d2339..6acfff4 100644 --- a/Assets/Scripts/GameFlowManager.cs +++ b/Assets/Scripts/GameFlowManager.cs @@ -102,14 +102,14 @@ public class GameFlowManager : MonoBehaviour { public override void EnterState() { base.EnterState(); - gameFlowManager.gameTimer.StartTimer(); + gameFlowManager.gameTimer.stopped = false; gameFlowManager.SetPauseLevel(PauseLevel.NotPaused); } public override void LeaveState() { base.LeaveState(); - gameFlowManager.gameTimer.PauseTimer(); + gameFlowManager.gameTimer.stopped = true; } } diff --git a/Assets/Scripts/GameTimer.cs b/Assets/Scripts/GameTimer.cs index d901c0d..5034abd 100644 --- a/Assets/Scripts/GameTimer.cs +++ b/Assets/Scripts/GameTimer.cs @@ -5,20 +5,14 @@ using UnityEngine; public class GameTimer : MonoBehaviour { TMP_Text label; float timer; - bool stopped; + public bool stopped; void Awake() { label = GetComponent(); + timer = 0f; stopped = true; } - public void StartTimer() { - timer = Time.time; - stopped = false; - } - - public void PauseTimer() => stopped = true; - void Update() { if (stopped) return; diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs index 199d6e1..cce0b3e 100644 --- a/Assets/Scripts/MinionThrower.cs +++ b/Assets/Scripts/MinionThrower.cs @@ -55,6 +55,9 @@ public class MinionThrower : MonoBehaviour { } public void AimThrow(InputAction.CallbackContext context) { + if (!gameFlowManager.CanDoAction) + return; + throwDirection = context.ReadValue().normalized; if (vampireEntity.playerMovement.facingRight) { aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.right, throwDirection); diff --git a/Assets/Scripts/VampireEntity.cs b/Assets/Scripts/VampireEntity.cs index 8da0a11..8ef4bff 100644 --- a/Assets/Scripts/VampireEntity.cs +++ b/Assets/Scripts/VampireEntity.cs @@ -9,6 +9,11 @@ public class VampireEntity : Entity { // HealthBar healthBar; [HideInInspector] public PlayerMovement playerMovement; + protected override void Awake() { + base.Awake(); + transform.SetParent(arena.minionParent); + } + protected override void Start() { base.Start(); base.entityType = EntityFlag.Vampire;