Exemplo n.º 1
0
    //Create two tanks at random x values from -15 0 and 0 to 19
    void ResetGame()
    {
        GameOver   = false;
        PlayerTurn = true;
        foreach (GameObject p in GameObject.FindGameObjectsWithTag("Player"))
        {
            Destroy(p);
        }
        Destroy(GameObject.FindGameObjectWithTag("Background"));
        Destroy(GameObject.FindGameObjectWithTag("Water"));
        Instantiate(Water);
        Instantiate(Background);

        Vector3 position = transform.position;

        position.x = Random.Range(-15, 0);
        Player1    = (GameObject)Instantiate(Tank, position, Quaternion.identity);
        position.x = Random.Range(0, 19);
        Player2    = (GameObject)Instantiate(Tank, position, Quaternion.identity);


        Player1.GetComponent <Tank>().PlayerTurn      = true;
        Player1.GetComponent <Tank>().ControlsEnabled = true;
        Player2.GetComponent <Tank>().PlayerTurn      = false;
        Camera.target = Player1.transform;
        Camera.GetComponent <Camera2DFollow>().Enabled        = true;
        GameObject.Find("WonText").GetComponent <Text>().text = "";
        GuiText.GetComponent <Text>().text = "Player 1";
    }