public void StartAIGame(Scene arg0, Scene arg1) { AIBattleController aiController = GameObject.FindObjectOfType <AIBattleController>(); aiController.SetAI(AITeam, aiDifficultySlider.AILevel); aiController.SetAI(AITeam.Enemy(), 0); // 0 is None, meaning the player can play that team aiController.StartGame(); SceneManager.activeSceneChanged -= StartAIGame; }
public void StartAIGame(Scene arg0, Scene arg1) { AIBattleController aiController = GameObject.FindObjectOfType <AIBattleController>(); // 0 is None, meaning the player can play that team if (AITeam == Team.White) { aiController.SetAI(aiDifficultySlider.AILevel, 0); } else if (AITeam == Team.Black) { aiController.SetAI(0, aiDifficultySlider.AILevel); } else // If AITeam somehow comes in as Team.None, there is nothing to do here. { return; } aiController.StartGame(); SceneManager.activeSceneChanged -= StartAIGame; }
private void Awake() { button.onClick.AddListener(() => { board = GameObject.FindObjectOfType <Board>(); AIBattleController aiBattleController = board?.GetComponent <AIBattleController>(); int blackAI = aiBattleController != null ? aiBattleController.selectedBlackAI : 0; int whiteAI = aiBattleController != null ? aiBattleController.selectedWhiteAI : 0; SceneManager.activeSceneChanged += ResetAI; board?.Reset(); void ResetAI(Scene arg0, Scene arg1) { Board b = GameObject.FindObjectOfType <Board>(); AIBattleController aiController = b?.GetComponent <AIBattleController>(); aiController?.SetAI(whiteAI, blackAI); aiController?.StartGame(); SceneManager.activeSceneChanged -= ResetAI; } }); }