2018-04-21 12:22:17 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class GameController : MonoBehaviour {
|
2018-04-21 13:10:01 +02:00
|
|
|
|
|
|
|
|
|
public enum GameState { UNSET, INIT, STARTING, RUNNING, ENDED };
|
|
|
|
|
|
|
|
|
|
private GameState state = GameState.UNSET;
|
2018-04-21 12:22:17 +02:00
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
void Start () {
|
2018-04-21 13:10:01 +02:00
|
|
|
|
ChangeState(GameState.INIT);
|
2018-04-21 12:22:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update () {
|
|
|
|
|
|
|
|
|
|
}
|
2018-04-21 13:10:01 +02:00
|
|
|
|
|
|
|
|
|
void ChangeState(GameState nextState) {
|
|
|
|
|
if(nextState != state) {
|
|
|
|
|
state = nextState;
|
|
|
|
|
StateLogic(nextState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StateLogic(GameState nstate) {
|
|
|
|
|
switch (nstate)
|
|
|
|
|
{
|
|
|
|
|
case GameState.INIT:
|
|
|
|
|
Init();
|
|
|
|
|
break;
|
|
|
|
|
case GameState.STARTING:
|
|
|
|
|
Starting();
|
|
|
|
|
break;
|
|
|
|
|
case GameState.RUNNING:
|
|
|
|
|
Running();
|
|
|
|
|
break;
|
|
|
|
|
case GameState.ENDED:
|
|
|
|
|
Ended();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
print("Wrong GameState for StateLogic() call!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
ChangeState(GameState.STARTING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Starting()
|
|
|
|
|
{
|
|
|
|
|
ChangeState(GameState.RUNNING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Running()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Ended()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-21 12:22:17 +02:00
|
|
|
|
}
|