Commit 28ad94b1 by Tim Reiter

added option to fast load levels with key 0 to 9.

parent dfb43f00
......@@ -15,14 +15,15 @@ public class GameMaster : MonoBehaviour {
levelLoader = new DeserializedLevelsLoader();
}
public void loadLevel(int numberOfPlayers)
public void loadLevel(int numberOfPlayers, int level = -1)
{
levelLoader.loadLevel();
levelLoader.loadLevel(level);
deleteAllPlayers();
spawnPlayers(numberOfPlayers);
}
private void deleteAllPlayers()
{
foreach (GameObject player in GameObject.FindGameObjectsWithTag("Player"))
......
......@@ -35,14 +35,14 @@ public class Menu : MonoBehaviour
}
//returns true if game was started;
private bool startGameIfPossible()
private bool startGameIfPossible(int levelNumber = -1)
{
if (numberOfRegisteredPlayers > 1 || (numberOfRegisteredPlayers > 0 && Debug.isDebugBuild))
{
gameUI.SetActive(true);
gameStateTracker.setNumberOfPlayers(numberOfRegisteredPlayers);
gameStateTracker.reset();
gameMaster.loadLevel(numberOfRegisteredPlayers);
gameMaster.loadLevel(numberOfRegisteredPlayers, levelNumber);
gameObject.SetActive(false);
return true;
}
......@@ -51,6 +51,17 @@ public class Menu : MonoBehaviour
void Update()
{
if (Debug.isDebugBuild)
{
for (int i = 0; i < 10; i++)
{
if (Input.GetKeyDown(i.ToString()))
{
startGameIfPossible(i);
}
}
}
if (Input.GetKeyDown(KeyCode.Space))
{
if (WASDAdded)
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment