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 { ...@@ -15,14 +15,15 @@ public class GameMaster : MonoBehaviour {
levelLoader = new DeserializedLevelsLoader(); levelLoader = new DeserializedLevelsLoader();
} }
public void loadLevel(int numberOfPlayers) public void loadLevel(int numberOfPlayers, int level = -1)
{ {
levelLoader.loadLevel(); levelLoader.loadLevel(level);
deleteAllPlayers(); deleteAllPlayers();
spawnPlayers(numberOfPlayers); spawnPlayers(numberOfPlayers);
} }
private void deleteAllPlayers() private void deleteAllPlayers()
{ {
foreach (GameObject player in GameObject.FindGameObjectsWithTag("Player")) foreach (GameObject player in GameObject.FindGameObjectsWithTag("Player"))
......
...@@ -35,14 +35,14 @@ public class Menu : MonoBehaviour ...@@ -35,14 +35,14 @@ public class Menu : MonoBehaviour
} }
//returns true if game was started; //returns true if game was started;
private bool startGameIfPossible() private bool startGameIfPossible(int levelNumber = -1)
{ {
if (numberOfRegisteredPlayers > 1 || (numberOfRegisteredPlayers > 0 && Debug.isDebugBuild)) if (numberOfRegisteredPlayers > 1 || (numberOfRegisteredPlayers > 0 && Debug.isDebugBuild))
{ {
gameUI.SetActive(true); gameUI.SetActive(true);
gameStateTracker.setNumberOfPlayers(numberOfRegisteredPlayers); gameStateTracker.setNumberOfPlayers(numberOfRegisteredPlayers);
gameStateTracker.reset(); gameStateTracker.reset();
gameMaster.loadLevel(numberOfRegisteredPlayers); gameMaster.loadLevel(numberOfRegisteredPlayers, levelNumber);
gameObject.SetActive(false); gameObject.SetActive(false);
return true; return true;
} }
...@@ -51,6 +51,17 @@ public class Menu : MonoBehaviour ...@@ -51,6 +51,17 @@ public class Menu : MonoBehaviour
void Update() 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 (Input.GetKeyDown(KeyCode.Space))
{ {
if (WASDAdded) 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