void Awake() { instance = this; mat = GetComponent <MeshRenderer>().material; gameObject.SetActive(false); enabled = false; }
void OnButton(int button) { if (!busy) { AudioControl.PlayFX("button", 3); FaderControl.FadeIn(); timer = Time.time + 3; busy = true; } }
void Start() { instance = this; time = 60; points = 0; TimerControl.Set((int)time); ScoreControl.Set(points); state = STANDBY; nextUpdate = Time.time + 3; FaderControl.FadeOut(2); }
public ControllerUIGroup(ControllerSettings _config, GameObject _faderOptionsPrefab, GameObject _optionsActivateButtonPrefab, GameObject _controlObject) { faderOptions = Instantiate(_faderOptionsPrefab).GetComponent <FaderOptions>(); faderOptions.gameObject.name = _config.name + " Options Panel"; faderOptions.controllerConfig = _config; controllerConfig = _config; faderMenuButton = Instantiate(_optionsActivateButtonPrefab).GetComponent <Button>(); faderMenuButton.gameObject.name = _config.name + " Options"; faderMenuButton.GetComponentInChildren <Text>().text = _config.name + " Options"; // change visible button title faderMenuButton.onClick.AddListener(DisplayFaderOptions); activationToggle = faderMenuButton.GetComponentInChildren <Toggle>(); activationToggle.onValueChanged.AddListener(ToggleControlVisibility); controlObject = _controlObject; controlObjectTransform = _controlObject.GetComponent <RectTransform>(); control = _controlObject.GetComponent <FaderControl>(); }
void Update() { switch (state) { case STANDBY: if (Time.time > nextUpdate) { state = PLAYING; } break; case PLAYING: time -= Time.deltaTime; if (time <= 0) { time = 0; state = TIMEOVER; TitleControl.Animate("TIME OVER", TitleControl.GAMEOVER_ANIM); FaderControl.FadeIn(2); nextUpdate = Time.time + 3; } TimerControl.Set(Mathf.CeilToInt(time)); break; case SUCCESS: if (Time.time > nextUpdate) { nextUpdate = Time.time + (0.002f * time); time -= 1; AudioControl.PlayFX("point"); if (time <= 0) { time = 0; state = GAMEOVER; FaderControl.FadeIn(2); nextUpdate = Time.time + 3; AudioControl.PlayFX("pointend"); } TimerControl.Set(Mathf.CeilToInt(time)); points++; ScoreControl.Set(points); } break; case DIE: state = GAMEOVER; TitleControl.Animate("GAME OVER", TitleControl.GAMEOVER_ANIM); FaderControl.FadeIn(2); nextUpdate = Time.time + 3; break; case TIMEOVER: case GAMEOVER: if (Time.time > nextUpdate) { if (points > PlayerPrefs.GetInt(BESTSCORE_KEY, 0)) { PlayerPrefs.SetInt(BESTSCORE_KEY, points); PlayerPrefs.Save(); } Application.LoadLevel("Menu"); } break; } }