make the menu screen skippable after certain time

This commit is contained in:
jparent 2016-01-31 14:27:50 -05:00
parent f092ab1aa4
commit 7ba3cdd21f

View File

@ -4,9 +4,10 @@ using System.Collections;
public class MenuInteractions : MonoBehaviour public class MenuInteractions : MonoBehaviour
{ {
public int nextLevel; public int nextLevel;
public bool isSkippable = true;
public bool hasAutoSkips = false; public bool hasAutoSkips = false;
public int timeBeforeSkip = 10; public int timeBeforeAutoSkip = 10;
public int timeBeforeSkippable = 0;
private bool isSkippable = false;
// Update is called once per frame // Update is called once per frame
void Update() void Update()
@ -18,16 +19,13 @@ public class MenuInteractions : MonoBehaviour
Application.LoadLevel(nextLevel); Application.LoadLevel(nextLevel);
} }
} }
} }
void Start() void Start()
{ {
// this won't lead anywhere... let's fix it
if(!isSkippable && !hasAutoSkips) StartCoroutine(EnableSkip());
{
isSkippable = true;
hasAutoSkips = true;
}
if (hasAutoSkips) if (hasAutoSkips)
{ {
@ -37,8 +35,15 @@ public class MenuInteractions : MonoBehaviour
IEnumerator AutoSkip() IEnumerator AutoSkip()
{ {
yield return new WaitForSeconds(timeBeforeSkip); yield return new WaitForSeconds(timeBeforeAutoSkip);
Application.LoadLevel(nextLevel); Application.LoadLevel(nextLevel);
} }
IEnumerator EnableSkip()
{
yield return new WaitForSeconds(timeBeforeSkippable);
isSkippable = true;
}
} }