Skip to content

Commit

Permalink
Show up text 3 seconds before mate matching
Browse files Browse the repository at this point in the history
closes #17
  • Loading branch information
Charly Mourglia committed Oct 7, 2019
1 parent 0c7d41e commit 52fc87d
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions MutantBalls/Assets/Brawl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class Brawl : MonoBehaviour

private Blob[] blobs;

private float copulateTimer;
private bool copulateTimerStarted;

void Awake()
{
this.OnDisable();
Expand All @@ -37,6 +40,7 @@ void OnEnable()
this.Instructions.text = "brawl!";

blobs = Object.FindObjectsOfType<Blob>();
copulateTimerStarted = false;
}

void OnDisable()
Expand All @@ -53,13 +57,29 @@ void OnDisable()

void Update()
{
if (copulateTimerStarted)
{
copulateTimer -= Time.deltaTime;
if (copulateTimer <= 0.0f)
{
copulateTimer = 0.0f;
gameObject.SetActive(false);
CopulateManager.gameObject.SetActive(true);
return;
}
}

if (Input.GetKeyDown(KeyCode.Return))
{
this.CopulateManager.gameObject.SetActive(true);
this.gameObject.SetActive(false);
copulateTimerStarted = true;
copulateTimer = 3.0f;
}

if (!this.Player.IsAlive)
if (this.copulateTimerStarted)
{
this.Instructions.text = "copulate in " + ((int)copulateTimer + 1) + "...";
}
else if (!this.Player.IsAlive)
{
this.Instructions.text = "loser.";
}
Expand All @@ -76,8 +96,8 @@ void Update()

if (aliveBlobsCpt < (int)((float)blobs.Length * 0.25f))
{
gameObject.SetActive(false);
CopulateManager.gameObject.SetActive(true);
copulateTimerStarted = true;
copulateTimer = 3.0f;
}
}
}
Expand Down

0 comments on commit 52fc87d

Please sign in to comment.