Pull request #9: Fixed dying twice

Merge in CEGJ/ludumdare50 from jason to dev

* commit '5545e42e5aff22b859a3f55bcb8a896e8195a25f':
  Fixed dying twice
This commit is contained in:
Jason Durand 01 2022-04-03 03:40:59 +00:00
commit 1d8d4c572e
6 changed files with 28 additions and 19 deletions

View File

@ -675,6 +675,10 @@ PrefabInstance:
propertyPath: gameFlowManager propertyPath: gameFlowManager
value: value:
objectReference: {fileID: 1359990806} objectReference: {fileID: 1359990806}
- target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
propertyPath: arena
value:
objectReference: {fileID: 397851252}
- target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} - target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
propertyPath: healthBar propertyPath: healthBar
value: value:

View File

@ -153,17 +153,20 @@ public class AIEntity : Entity
if(!entity.IsAlive()){ if(!entity.IsAlive()){
return new DeadState(entity); return new DeadState(entity);
} }
if(entity.IsInAttackRange()){
if(entity.attackTimer >= entity.attackCooldown){ if (entity.gameFlowManager.CanDoAction) {
entity.attackTimer = 0; if(entity.IsInAttackRange()){
return Attack(); if(entity.attackTimer >= entity.attackCooldown){
}else{ entity.attackTimer = 0;
entity.attackTimer += Time.deltaTime; return Attack();
} }else{
entity.attackTimer += Time.deltaTime;
}
}else{ }else
return new SeekState(entity); return new SeekState(entity);
} }
return null; return null;
} }

View File

@ -102,14 +102,14 @@ public class GameFlowManager : MonoBehaviour {
public override void EnterState() { public override void EnterState() {
base.EnterState(); base.EnterState();
gameFlowManager.gameTimer.StartTimer(); gameFlowManager.gameTimer.stopped = false;
gameFlowManager.SetPauseLevel(PauseLevel.NotPaused); gameFlowManager.SetPauseLevel(PauseLevel.NotPaused);
} }
public override void LeaveState() { public override void LeaveState() {
base.LeaveState(); base.LeaveState();
gameFlowManager.gameTimer.PauseTimer(); gameFlowManager.gameTimer.stopped = true;
} }
} }

View File

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

View File

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

View File

@ -9,6 +9,11 @@ public class VampireEntity : Entity {
// HealthBar healthBar; // HealthBar healthBar;
[HideInInspector] public PlayerMovement playerMovement; [HideInInspector] public PlayerMovement playerMovement;
protected override void Awake() {
base.Awake();
transform.SetParent(arena.minionParent);
}
protected override void Start() { protected override void Start() {
base.Start(); base.Start();
base.entityType = EntityFlag.Vampire; base.entityType = EntityFlag.Vampire;