예제 #1
0
 private void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
     DontDestroyOnLoad(gameObject);
 }
예제 #2
0
    void StartGame()
    {
        SoundsManager.getInstance().PlayIngameMusic();

        PhysicalGameManager.getInstance().gameObject.transform.GetChild(0).gameObject.SetActive(false);

        if (NetworkManager.getInstance().IsServer())
        {
            ObstaclesManager.getInstance().StartObstaclesManager();
            PowerUpsManager.getInstance().StartPowerUpsManager();
        }

        for (int i = 0; i < 4; i++)
        {
            if (i == SelectedPlayer)
            {
                transform.GetChild(3).GetChild(i).GetComponent <BaseController>().SelectPlayer(true);
            }
            else
            {
                if (!InPractice)
                {
                    transform.GetChild(3).GetChild(i).GetComponent <NPCController>().enabled = true;
                    transform.GetChild(3).GetChild(i).GetComponent <NPCController>().StartSynchronize();
                }
                transform.GetChild(3).GetChild(i).GetComponent <CapsuleCollider>().enabled = false;
                Destroy(transform.GetChild(3).GetChild(i).GetComponent <Rigidbody>());
            }
        }

        var Platforms = gameObject.GetComponentsInChildren <FixedPlatform>();

        // Enable rigidbodies:
        foreach (var component in Platforms)
        {
            component.Initiate();
        }

        UIPlayerFollow.getInstance().SetPlayer(SelectedPlayer);

        Timer.getInstance().StartTimer();

        GameCanvas.getInstance().gameObject.transform.GetChild(0).GetChild(0).GetChild(0).GetChild(SelectedPlayer).gameObject.SetActive(true);
        GameCanvas.getInstance().gameObject.transform.GetChild(0).GetChild(1).GetChild(SelectedPlayer).gameObject.SetActive(true);
        GameCanvas.getInstance().gameObject.transform.GetChild(0).GetChild(0).GetChild(1).gameObject.SetActive(true);

        InGame = true;
    }