Created
May 20, 2017 19:35
-
-
Save atakotestudios/b736161f1ea5463fbe6ffaefbdb74b97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.SceneManagement; | |
[RequireComponent(typeof(SteamVR_LoadLevel))] | |
public class GameManager : MonoBehaviour { | |
public int score; | |
public int projectilesThrown; | |
public bool countNumberOfProjsThrown = true; | |
public int projectilesPerLevel = 5; | |
public bool loadLevelScreenFade = false; | |
private static int levelNum; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
if (countNumberOfProjsThrown) | |
{ | |
if(projectilesThrown >= projectilesPerLevel) | |
{ | |
projectilesPerLevel = 0; //prevents this code from firing multiple times | |
levelNum++; | |
if (loadLevelScreenFade) | |
{ | |
//will only work if naming convenction is Scene0, Scene1, etc (can be customized to own convention) | |
SteamVR_LoadLevel.Begin("Scene" + levelNum); | |
} | |
else | |
{ | |
//instant scene load with no fade | |
SceneManager.LoadScene(levelNum); | |
} | |
} | |
} | |
} | |
public void CountProjectiles() | |
{ | |
projectilesThrown++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment