Example #1
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     if (singleton == null)
     {
         singleton = this;
     }
 }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        player1 = GameObject.Find("Player1");
        player2 = GameObject.Find("Player2");

        player1_script = player1.GetComponent <Player_collision>();
        player2_script = player2.GetComponent <Player_collision>();

        spawnPoints = GameObject.FindGameObjectsWithTag("Respawn");

        player1_lives      = NumLives;
        player2_lives      = NumLives;
        p1LivesString      = GameObject.Find("Player1Lives").GetComponent <Text>();
        p2LivesString      = GameObject.Find("Player2Lives").GetComponent <Text>();
        p1LivesString.text = "P1 Lives: " + (NumLives - 1);
        p2LivesString.text = "P2 Lives: " + (NumLives - 1);
        renderCanvas       = GameObject.Find("Canvas");

        winsUI = GameObject.Find("Wins");


        Debug.Log("about to call wwise bank...");
        WWiseBankManager.MainMusic(gameObject);
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (winsUI)
        {
            winsUI.GetComponent <Text>().text = player1wins + ":" + player2wins;
        }
        if (player1_script.dead == true)
        {
            player1_lives -= 1;
            WWiseBankManager.PlayerDeath(gameObject);

            if (player1_lives <= 0)
            {
                p1LivesString.text = "P1 Lives: 0";
            }
            else
            {
                p1LivesString.text = "P1 Lives: " + (player1_lives - 1);
            }
            if (player1_lives <= 0)
            {
                //Player 2 wins round, move to next scene
                player2wins = Mathf.Clamp(player2wins + 1, 0, maxWins);
                winsUI.GetComponent <Text>().text = player1wins + ":" + player2wins;
                CheckWins();
                //SceneManager.LoadScene(sceneName: next_level);
            }
            else
            {
                //Respawn player
                int        respawnSelect = Random.Range(1, spawnPoints.Length);
                GameObject rider2        = GameObject.FindGameObjectWithTag("Rider2");
                if (rider2 != null && Vector3.Distance(spawnPoints[respawnSelect].transform.position, GameObject.FindGameObjectWithTag("Rider2").transform.position) < 5)
                {
                    respawnSelect = Random.Range(1, spawnPoints.Length);
                }
                player1_script.dead = false;
                player1.SetActive(true);
                player1.transform.position = spawnPoints[respawnSelect].transform.position;

                //WWiseBankManager.MainMusic(gameObject);
            }
        }

        if (player2_script.dead == true)
        {
            player2_lives -= 1;
            WWiseBankManager.PlayerDeath(gameObject);
            if (player2_lives <= 0)
            {
                p2LivesString.text = "P2 Lives: 0";
            }
            else
            {
                p2LivesString.text = "P2 Lives: " + (player2_lives - 1);
            }
            if (player2_lives <= 0)
            {
                //Player 1 wins round, move to next scene
                player1wins = Mathf.Clamp(player1wins + 1, 0, maxWins);
                winsUI.GetComponent <Text>().text = player1wins + ":" + player2wins;
                CheckWins();
                //SceneManager.LoadScene(sceneName: next_level);
            }
            else
            {
                //Respawn player
                int        respawnSelect = Random.Range(1, spawnPoints.Length);
                GameObject rider1        = GameObject.FindGameObjectWithTag("Rider1");
                if (rider1 != null && Vector3.Distance(spawnPoints[respawnSelect].transform.position, rider1.transform.position) < 5)
                {
                    respawnSelect = Random.Range(1, spawnPoints.Length);
                }
                player2_script.dead = false;
                player2.SetActive(true);

                player2.transform.position = spawnPoints[respawnSelect].transform.position;
                //WWiseBankManager.MainMusic(gameObject);
            }
        }
    }