コード例 #1
0
    /// <summary>
    /// Función que reinicia la partida tras un Game Over.
    /// </summary>
    public void RestartGame()
    {
        panelGameOver.SetActive(false);

        score          = 0;
        scoreText.text = "SCORE: 0";

        remainingLifes = 4; // El número de vidas inicial será de 4.

        for (int i = 0; i < lifes.Length; i++)
        {
            lifes[i].SetActive(true);
        }

        dotsInScreen = 325; // El número de puntos en la pantalla será de 325 al inicio de la partida.

        for (int i = 0; i < dots.Length; i++)
        {
            dots[i].SetActive(true);
        }

        for (int i = 0; i < bigDots.Length; i++)
        {
            bigDots[i].SetActive(true);
        }

        if (ResetPositions != null)
        {
            ResetPositions();
        }

        StopAllCoroutines();

        GameObject[] activeFruit = GameObject.FindGameObjectsWithTag("Game4/Fruit");

        if (activeFruit != null)
        {
            for (int i = 0; i < activeFruit.Length; i++)
            {
                Destroy(activeFruit[i]);
            }
        }

        GenerateFruit();

        player.transform.position = new Vector2(14, 11);
        player.SetActive(true);
        pacmanMovement.ResetPosition();
    }
コード例 #2
0
    /// <summary>
    /// Function called to replay after Game Over.
    /// </summary>
    public void RestartGame()
    {
        panelGameOver.SetActive(false);

        score          = 0;
        scoreText.text = "SCORE: 0";

        remainingLifes = 4;

        for (int i = 0; i < lifes.Length; i++)
        {
            lifes[i].SetActive(true);
        }

        dotsInScreen = 325;

        for (int i = 0; i < dots.Length; i++)
        {
            dots[i].SetActive(true);
        }

        for (int i = 0; i < bigDots.Length; i++)
        {
            bigDots[i].SetActive(true);
        }

        if (ResetPositions != null)
        {
            ResetPositions();
        }

        StopAllCoroutines();

        GameObject[] activeFruit = GameObject.FindGameObjectsWithTag("Game4/Fruit");

        if (activeFruit != null)
        {
            for (int i = 0; i < activeFruit.Length; i++)
            {
                Destroy(activeFruit[i]);
            }
        }

        GenerateFruit();

        player.transform.position = pacmanMovement.startPosition;
        player.SetActive(true);
        pacmanMovement.ResetPosition();
    }
コード例 #3
0
        public IEnumerator PacmansPositionResets()
        {
            Vector3 startingPosition = pacman.transform.position;

            yield return(new WaitForSeconds(WAIT_TIME));

            pacmanMovement.ResetPosition();
            Assert.AreEqual(startingPosition, pacman.transform.position);
        }
コード例 #4
0
        /// <summary>
        /// Resets Pacman and Ghost positions.
        /// </summary>
        public void ResetEntityPositions()
        {
            debugger.Info("resetting positions");

            foreach (Ghost ghost in ghosts)
            {
                ghost.ResetPosition();
            }

            // We reset the current node here to stop the Ghosts immediately looking at the first node when pacman dies
            foreach (GhostPath path in FindObjectsOfType <GhostPath>())
            {
                path.ResetCurrentWaypointIndex();
            }

            // Reset pacmans position
            pacmanMovement.ResetPosition();
        }