//-----------------------------------Button Function Set---------------------------------- private void setNextButton(State.BattleState state) { State.BattleState nextState = state; Button tmp = nextButton.GetComponent <Button>(); tmp.onClick.RemoveAllListeners(); switch (state) { case State.BattleState.SelectBattleSkill: nextState = State.BattleState.PlayerRollBattleDice; tmp.GetComponent <Button>().onClick.AddListener(() => setBattleSkill()); break; case State.BattleState.PlayerRollBattleDice: nextState = State.BattleState.SelectGambleSkill; //tmp.GetComponent<Button>().onClick.AddListener(() => processBattleSkillMP()); break; case State.BattleState.EnemyRollBattleDice: nextState = State.BattleState.EnemyAttack; break; case State.BattleState.SelectGambleSkill: nextState = State.BattleState.PlayerRollBattleDice2; tmp.GetComponent <Button>().onClick.AddListener(() => setGambleSkill()); break; case State.BattleState.PlayerRollBattleDice2: nextState = State.BattleState.PlayerAttack; tmp.GetComponent <Button>().onClick.AddListener(() => processGambleSkillTimes()); break; case State.BattleState.EnemyAttack: nextState = State.BattleState.SelectBattleSkill; break; case State.BattleState.PlayerAttack: nextState = State.BattleState.SelectBattleSkill; break; default: Debug.Log("setNextButton - ErrorState"); break; } tmp.GetComponent <Button>().onClick.AddListener(() => stateManager.setState(nextState)); }
// 設定階段: 目前State Manager自己、UI Magnager都會call這個來設定目前的階段 public void setState(State.BattleState state) { currentState = state; uiManager.currentState = currentState; // 通知UI Manager目前是什麼階段,方便設定UI switch (currentState) { // 選擇技能階段 case State.BattleState.SelectBattleSkill: // 如果現在可行動的戰鬥單位是怪物,則跳過選擇技能階段 if (string.Equals(battleUnits [currentUnitIndex].type, "Monster")) { //執行turn end來解除腳色骰子的封印狀態 currentCharacter.turnEnd(); setState(State.BattleState.EnemyRollBattleDice); } else { // 如果角色死亡,則Game Over if (currentCharacter.Hp <= 0) { setState(State.BattleState.BattleEnd); } else { //執行turn end來解除骰子的封印狀態 Debug.Log(monster.name); monster.turnEnd(); // 回合數 + 1 turn += 1; uiManager.showBattleSkillPanel(); // UI: 顯示技能選擇的操作面板 } } break; case State.BattleState.PlayerRollBattleDice: bcManager.setCurrentCharacter(currentCharacter); bcManager.setForPlayerToRoll(1); // 1表示第一次擲骰子 uiManager.showDiceRollingPanel(); break; case State.BattleState.EnemyRollBattleDice: bcManager.monsterRoll(); uiManager.showEnemyRollingPanel(); break; case State.BattleState.SelectGambleSkill: uiManager.showGambleSkillPanel(); break; case State.BattleState.PlayerRollBattleDice2: bcManager.setForPlayerToRoll(2); // 2表示第二次擲骰子 uiManager.showDiceRolling2Panel(); break; case State.BattleState.EnemyAttack: StartCoroutine(MonsterAttackRoutine()); break; case State.BattleState.PlayerAttack: StartCoroutine(PlayerAttackRoutine()); break; case State.BattleState.BattleEnd: currentCharacter.transform.SetParent(dataManager.transform, false); currentCharacter.transform.localPosition = new Vector3(0f, 10f, 0f); currentCharacter.resetDiceState(); if (currentCharacter.Hp > 0) { screenEffectManager.fadeOutToLoot(); } else { screenEffectManager.fadeOutToGameOver(); } break; default: Debug.Log("setState - ErrorState"); break; } }