Advertisement
VaporaWorker7

Untitled

Aug 17th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Photon.Pun;
  5. using Photon.Realtime;
  6. using UnityEngine.UI;
  7. using TMPro;
  8.  
  9. public class RoomScript : MonoBehaviourPunCallbacks
  10. {
  11. public static RoomScript Instance;
  12. //public MainMenuManager.GameType gmType;
  13. public TextMeshProUGUI tex;
  14. [SerializeField] GameObject playerEntityPrefab;
  15. [SerializeField] GameObject playerEntityPrefab1;
  16. //const float defaultTimeBeforeGame = 3.0f;
  17. [SerializeField] List<GameObject> listOfLudoTokens;
  18. [SerializeField] List<Vector3> listOfPlayerLabelPosition;
  19. PhotonView view;
  20. [SerializeField]int ludoTokenIndex;
  21. const int defaultLudoTokenQty = 4;
  22.  
  23. public void Start()
  24. {
  25. view = GetComponent<PhotonView>();
  26. //if (PhotonNetwork.CurrentRoom.PlayerCount == 1)
  27. //{
  28. // var player = PhotonNetwork.Instantiate(playerEntityPrefab.name, transform.position, Quaternion.identity);
  29. //}
  30. //else if (PhotonNetwork.CurrentRoom.PlayerCount == 2)
  31. //{
  32. // var player1 = PhotonNetwork.Instantiate(playerEntityPrefab1.name, transform.position, Quaternion.identity);
  33. //}
  34.  
  35.  
  36. for (int i = 0; i < defaultLudoTokenQty; i++)// spawn 4 ludo tokens per player
  37. {
  38. // 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
  39. var player = PhotonNetwork.Instantiate(listOfLudoTokens[PhotonNetwork.CurrentRoom.PlayerCount - 1].name,
  40. listOfPlayerLabelPosition[PhotonNetwork.CurrentRoom.PlayerCount - 1], Quaternion.identity);
  41.  
  42.  
  43. }
  44. //view.RPC("UpdateIndexVariable", RpcTarget.All, 1);
  45.  
  46. }
  47. public override void OnJoinedRoom()
  48. {
  49. Debug.Log("Join Room2");
  50. Debug.Log("Player Count: " + PhotonNetwork.CurrentRoom.PlayerCount);
  51. Debug.Log("Max Players: " + PhotonNetwork.CurrentRoom.MaxPlayers);
  52.  
  53. if (PhotonNetwork.CurrentRoom.PlayerCount == PhotonNetwork.CurrentRoom.MaxPlayers)
  54. {
  55. Debug.Log("Join Game");
  56.  
  57. view.RPC("TransferingToGame",RpcTarget.All);
  58.  
  59. }
  60. }
  61.  
  62. [PunRPC]
  63. public void TransferingToGame()
  64. {
  65. //if(view.IsMine)//
  66. PhotonNetwork.LoadLevel(3);
  67. }
  68. //[PunRPC]
  69. //void UpdateIndexVariable(int value)
  70. //{
  71. // ludoTokenIndex += value;
  72. //}
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement