コード例 #1
0
    private void ResetGame()
    {
        if (currentBomb != null)
        {
            Debug.LogError("Game should not have ended, error cannot compute, fix it");
        }

        GameObject theBomb = Instantiate(bombPrefab, bombRespawnPos);

        theBomb.transform.position = bombRespawnPos.position;
        theBomb.name      = "TheBomb";
        currentBomb       = theBomb;
        currentBombScript = currentBomb.GetComponent <BombStatusScript>();


        if (currentPlayer1 == null && currentPlayer2 == null)
        {
            SpawnPlayer1();
            SpawnPlayer2();
        }
        else if (currentPlayer1 == null)
        {
            SpawnPlayer1();
        }
        else if (currentPlayer2 == null)
        {
            SpawnPlayer2();
        }

        timerTextBox.text      = null;
        restartTextBox.enabled = false;
        gameOver = false;
        //canResetGame = false;
    }
コード例 #2
0
    void Start()
    {
        restartTextBox.enabled = false;

        bombTimer         = bombTimerStart;
        timerTextBox.text = null;
        ResetGame();
        currentBomb       = GameObject.FindGameObjectWithTag("Bomb");
        currentPlayer1    = GameObject.FindGameObjectWithTag("Player 1");
        currentPlayer2    = GameObject.FindGameObjectWithTag("Player 2");
        currentBombScript = currentBomb.GetComponent <BombStatusScript>();

        if (currentPlayer1 == null || currentPlayer2 == null || currentBomb == null)
        {
            Debug.LogError("Something wasnt found");
        }
    }