Beispiel #1
0
 // this function will recieve game object
 public void CategorySwitch(CategoryButton btn)
 {                 // All Players
     btn.Switch(); //
     activeButton.Switch();
     activeButton          = btn;
     achvScrollbar.content = btn.achievementMenu.GetComponent <RectTransform>();
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        activeButton = GameObject.Find("CurrentPLayerButton").GetComponent <CategoryButton>();
        activeButton.Switch();
        PlayerScore = 0;
        isPaused    = false;
        // Players
        txtCollectedCoins.text = PlayerPrefs.GetInt("CollectedCoins").ToString();
        txtPlayer1Coins.text   = player1RequiredCoins.ToString();
        txtPlayer2Coins.text   = player2RequiredCoins.ToString();
        int player1 = PlayerPrefs.GetInt("player1");

        int curPlayerID = PlayerPrefs.GetInt("Player", 1);

        Player2Button.GetComponent <CharacterUnlock>().Activate();

        if (curPlayerID == 1)
        {
            characterPlayer1.SetActive(true);
            characterPlayer2.SetActive(false);

            player = characterPlayer1;
        }
        else if (curPlayerID == 2)
        {
            characterPlayer1.SetActive(false);
            characterPlayer2.SetActive(true);

            player = characterPlayer2;
        }

        BuildingController[] bCs = (BuildingController[])GameObject.FindObjectsOfType(typeof(BuildingController));
        foreach (BuildingController bC in bCs)
        {
            bC.player = player.transform;
        }
        CarController[] cCs = (CarController[])GameObject.FindObjectsOfType(typeof(CarController));
        foreach (CarController cC in cCs)
        {
            cC.player = player.transform;
        }

        CameraController[] cameraCs = (CameraController[])GameObject.FindObjectsOfType(typeof(CameraController));
        foreach (CameraController cC in cameraCs)
        {
            cC.player = player.transform;
        }

        /*if (player1 == 1) // 0 -> locked  1 -> unlocked  2 -> active
         * {
         *  player1Button.GetComponent<CharacterUnlock>().Unlock();
         *  coinsPlayer1.SetActive(false);
         *  coinsPlayer2.SetActive(false);
         *  characterPlayer1.SetActive(false);
         * }
         * else if (player1 == 2)
         * {
         *  player1Button.GetComponent<CharacterUnlock>().Activate();
         *  Player2Button.GetComponent<CharacterUnlock>().Unlock();
         *  coinsPlayer1.SetActive(false);
         *  coinsPlayer2.SetActive(false);
         *  characterPlayer2.SetActive(false);
         * }
         * else
         * {
         *  if (PlayerPrefs.GetInt("CollectedCoins") >= player1RequiredCoins)
         *  {
         *      player1Button.GetComponent<CharacterUnlock>().Unlock();
         *      coinsPlayer1.SetActive(false);
         *      coinsPlayer2.SetActive(false);
         *      characterPlayer1.SetActive(false);
         *      PlayerPrefs.SetInt("player1", 1);
         *      PlayerPrefs.SetInt("CollectedCoins", PlayerPrefs.GetInt("CollectedCoins") - player1RequiredCoins);
         *
         *  }
         *  else
         *  {
         *      coinsPlayer2.SetActive(false);
         *      characterPlayer1.SetActive(false);
         *  }
         * }*/
    }