private void ButtonsAddListener() { _drillRocketButton.onClick.AddListener(() => { if (GameManager.DrillRocketUnused == 0) { return; } State = StateEnum.AllDisable; var r = Factory.CreatDrillRocket(); r.SetByMouse(); GameManager.DrillRocketUnused--; }); _returnRocketButton.onClick.AddListener(() => { if (GameManager.ReturnRocketUnused == 0) { return; } State = StateEnum.AllDisable; var r = Factory.CreatReturnRocket(); r.SetByMouse(); GameManager.ReturnRocketUnused--; }); _startButton.onClick.AddListener(() => {//在不同的游戏阶段,这个按钮有不同的作用 switch (GameManager.StateMachine.State) { case GameManager.StateEnum.SettingRocket: State = StateEnum.OnGaming; GameManager.GameStart(); _instructionText.text = "游戏开始!敌人正在赶到战场"; break; default: GameEditor.SceneUtils.ChangeScene("LevelPlayerScene"); break; } }); _speedUpButton.onClick.AddListener(() => { CustomTimeScale *= 1.3f; if (CustomTimeScale > 20) { CustomTimeScale = 20; } string timeStr = CustomTimeScale.ToString("F1"); _speedText.text = timeStr + "倍速"; }); _speedDownButton.onClick.AddListener(() => { CustomTimeScale /= 1.3f; string timeStr = CustomTimeScale.ToString("F1"); _speedText.text = timeStr + "倍速"; }); _exitButton.onClick.AddListener(() => { GameEditor.SceneUtils.ChangeScene("LevelSelectScene"); }); }
void Start() { ButtonsAddListener(); string timeStr = CustomTimeScale.ToString("F1"); _speedText.text = timeStr + "倍速"; }