public static SetupGameMenu GetReference()
 {
     if (reference == null)
     {
         reference = GameObject.Find("Canvas").transform.Find("Setup Game").GetComponent <SetupGameMenu>();
     }
     return(reference);
 }
Example #2
0
    public void OnPhotonInstantiate(PhotonMessageInfo info)
    {
        manager = GameManager.GetReference();
        terrain = Terrain.GetReference();

        int actorNum = info.Sender.ActorNumber;

        MyPlayer     = info.Sender;
        OnlineNumber = actorNum;
        float seed = (float)PhotonNetwork.CurrentRoom.CustomProperties["TerrainSeed"];

        terrain.Init(SetupGameMenu.GetReference().TerrainType.value, seed);
        if (actorNum == PhotonNetwork.LocalPlayer.ActorNumber)
        {
            return;
        }

        SetupGameMenu setup       = SetupGameMenu.GetReference();
        int           playerCount = setup.GetPlayerCount();
        float         offset      = terrain.MapWidth / (playerCount + 1);
        int           counter     = 0;

        for (int i = 0; i < setup.PlayerDataList.Count; i++)
        {
            PlayerSetup playerData = setup.PlayerDataList[i];
            if (playerData.Active.activeInHierarchy)
            {
                if (playerData.OnlineNumber == OnlineNumber)
                {
                    transform.position = new Vector3((counter + 1) * offset, 0f, 0f);
                    transform.parent   = setup.TankParent;
                    Init(playerData.GetName(), counter, playerData.GetColor(), ControlType.NetworkPlayer);
                    manager.PlayerTanks.Add(this);
                }
                counter++;
            }
        }

        setup.NumLoadedTanks++;
    }