Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Photon.Pun;
- using Photon.Realtime;
- using UnityEngine.UI;
- using TMPro;
- public class RoomScript : MonoBehaviourPunCallbacks
- {
- public static RoomScript Instance;
- //public MainMenuManager.GameType gmType;
- public TextMeshProUGUI tex;
- [SerializeField] GameObject playerEntityPrefab;
- [SerializeField] GameObject playerEntityPrefab1;
- //const float defaultTimeBeforeGame = 3.0f;
- [SerializeField] List<GameObject> listOfLudoTokens;
- [SerializeField] List<Vector3> listOfPlayerLabelPosition;
- PhotonView view;
- [SerializeField]int ludoTokenIndex;
- const int defaultLudoTokenQty = 4;
- public void Start()
- {
- view = GetComponent<PhotonView>();
- //if (PhotonNetwork.CurrentRoom.PlayerCount == 1)
- //{
- // var player = PhotonNetwork.Instantiate(playerEntityPrefab.name, transform.position, Quaternion.identity);
- //}
- //else if (PhotonNetwork.CurrentRoom.PlayerCount == 2)
- //{
- // var player1 = PhotonNetwork.Instantiate(playerEntityPrefab1.name, transform.position, Quaternion.identity);
- //}
- for (int i = 0; i < defaultLudoTokenQty; i++)// spawn 4 ludo tokens per player
- {
- // the -1 is used to instantiate a prefab at element[0], it has to be set to that number because by the time this line of code runs there would have been an increment
- var player = PhotonNetwork.Instantiate(listOfLudoTokens[PhotonNetwork.CurrentRoom.PlayerCount - 1].name,
- listOfPlayerLabelPosition[PhotonNetwork.CurrentRoom.PlayerCount - 1], Quaternion.identity);
- }
- //view.RPC("UpdateIndexVariable", RpcTarget.All, 1);
- }
- public override void OnJoinedRoom()
- {
- Debug.Log("Join Room2");
- Debug.Log("Player Count: " + PhotonNetwork.CurrentRoom.PlayerCount);
- Debug.Log("Max Players: " + PhotonNetwork.CurrentRoom.MaxPlayers);
- if (PhotonNetwork.CurrentRoom.PlayerCount == PhotonNetwork.CurrentRoom.MaxPlayers)
- {
- Debug.Log("Join Game");
- view.RPC("TransferingToGame",RpcTarget.All);
- }
- }
- [PunRPC]
- public void TransferingToGame()
- {
- //if(view.IsMine)//
- PhotonNetwork.LoadLevel(3);
- }
- //[PunRPC]
- //void UpdateIndexVariable(int value)
- //{
- // ludoTokenIndex += value;
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement