Fixed dying twice

This commit is contained in:
Jason Durand 01 2022-04-02 23:37:40 -04:00
parent 9b9a4a7380
commit 7d66b97f5d
6 changed files with 28 additions and 19 deletions

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -5,20 +5,14 @@ using UnityEngine;
public class GameTimer : MonoBehaviour {
TMP_Text label;
float timer;
bool stopped;
public bool stopped;
void Awake() {
label = GetComponent<TMP_Text>();
timer = 0f;
stopped = true;
}
public void StartTimer() {
timer = Time.time;
stopped = false;
}
public void PauseTimer() => stopped = true;
void Update() {
if (stopped)
return;

View File

@ -55,6 +55,9 @@ public class MinionThrower : MonoBehaviour {
}
public void AimThrow(InputAction.CallbackContext context) {
if (!gameFlowManager.CanDoAction)
return;
throwDirection = context.ReadValue<Vector2>().normalized;
if (vampireEntity.playerMovement.facingRight) {
aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.right, throwDirection);

View File

@ -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;