public void SimulationExitButtonPressed() { isPause = false; StopCoroutine(scoreUpdateCoroutine); if (currentSimulation != null) { currentSimulation.Visualizer.Clear(); if (currentSimulation.ObservedPlayer is IHumanPlayer humanPlayer) { humanPlayer.DirectionSelected -= DirectionSelectedHandler; } currentSimulation.Visualizer = null; currentSimulation.ObservedPlayer = null; currentSimulation.ObservingCamera = null; currentSimulation = null; } TurnOffAllMenues(); menuCanvas?.SetActive(true); startMenu?.SetActive(true); }
private void AddBots(SimulatorAdapter simulator) { for (int i = 0; i < numberOfBots; i++) { var nwBot = new PlayerMechanism.SimpleBot(); simulator.AddPlayer(nwBot); } }
private void SimulationInitializedHandler(SimulatorAdapter simulation) { InitializeSimulation(simulation); TurnOffAllMenues(); menuCanvas?.SetActive(true); standartGameInterfase?.SetActive(true); arenaGameInterfase?.SetActive(true); currentSimulation = simulation; scoreUpdateCoroutine = StartCoroutine(ScoreUpdateCoroutine()); countdownCoroutine = StartCoroutine(CountdownCoroutine()); }
private void InitializeSimulation(SimulatorAdapter simulation) { PlayerPrefs.Save(); simulation.Visualizer = visualizer; var observingCamera = gameCamera.GetComponent <Visualization.IVisualizerObserver>(); Debug.Assert(observingCamera != null, "GameCamera must have IVisualizerObserver based component."); observingCamera.Restart(); simulation.ObservingCamera = observingCamera; var validPlayer = SelectValidPlayer(); var curInfo = validPlayer.GetSnakeInfo(); if (snakeLookupManager != null) { curInfo.maxLength = snakeLookupManager.SnakeLength; curInfo.scuamaPatern = snakeLookupManager.ScuamaPatern; } if (validPlayer is IHumanPlayer humanPlayer) { humanPlayer.DirectionSelected += DirectionSelectedHandler; } simulation.ObservedPlayer = validPlayer; AddBots(simulation); simulation.ObservedPlayerDied -= ObservedPlayerDiedHandler; simulation.ObservedPlayerDied += ObservedPlayerDiedHandler; simulation.NonObservedPlayerDied -= NonObservedPlayerDiedHandler; simulation.NonObservedPlayerDied += NonObservedPlayerDiedHandler; simulation.MakeStep(); }