//unity private void Start() { //set init values difficulty = 1; #if UNITY_WEBGL && !UNITY_EDITOR float sensitivity = 0.55f; #else float sensitivity = 0.5f; #endif bool sound = false; //setup control #if UNITY_ANDROID && !UNITY_EDITOR control = gameObject.AddComponent <GyroControl>(); uiManager = new UIWithTaps(UIManagerFactory.getInstance().CreateBig()); #else control = gameObject.AddComponent <SliderControl>(); // uiManager = new UIWithKeyHandler(UIManagerFactory.getInstance().Create()); uiManager = new UIWithTaps(UIManagerFactory.getInstance().CreateBig()); #endif control.SetSensitivity(sensitivity); //setup physics physics = new GamePhysics(); physics.SetDifficulty(difficulty); //setup score score = new GameScore(); score.SetDifficulty(difficulty); uiManager.onMenuCommand += OnMenuCommand; uiManager.Initialize(difficulty, sound, sensitivity); //uiManager.MakeFlexible(true); soundManager.Play(sound); PauseGame(true); }
private void ExecuteMenuCommand(string command, params string[] args) { Debug.Log("Menu: " + command); switch (command) { case "NewGame": RestartGame(); soundManager.SetTrack("Normal"); break; case "Resume": if (!uiManager.isFirstStart) { PauseGame(!isPaused); } break; case "Respawn": if (!uiManager.isFirstStart /*&& !isFinish*/) { RespawnPlayer(); Cursor.lockState = CursorLockMode.Locked; } break; case "Options": PauseGame(true); uiManager.ShowOptions(); Cursor.lockState = CursorLockMode.None; break; case "Help": PauseGame(true); uiManager.ShowHelp(); Cursor.lockState = CursorLockMode.None; break; case "OptsBack": if (isFinish) { uiManager.ShowFinish(totalScore); } else { uiManager.ShowMainMenu(); } break; case "HelpBack": if (isFinish) { uiManager.ShowFinish(totalScore); } else { uiManager.ShowMainMenu(); } break; case "ToBar": cameraManager.PlaySnow(true); PauseGame(false); player.SetActive(false); soundManager.SetTrack("Bar"); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; break; case "Quit": Cursor.visible = true; Cursor.lockState = CursorLockMode.None; Application.Quit(); break; case "Sound": soundManager.Play(bool.Parse(args[0])); break; case "Difficulty": physics.SetDifficulty(int.Parse(args[0])); score.SetDifficulty(int.Parse(args[0])); difficulty = int.Parse(args[0]); uiManager.isFirstStart = true; break; case "Sensitivity": control.SetSensitivity(float.Parse(args[0])); break; } }