Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void AddBots(SimulatorAdapter simulator)
 {
     for (int i = 0; i < numberOfBots; i++)
     {
         var nwBot = new PlayerMechanism.SimpleBot();
         simulator.AddPlayer(nwBot);
     }
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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();
        }