public void Awake() { #region btnRestart.SetActive(false); btnLeaveGame.SetActive(false); txtWaitingForOtherPlayers.SetActive(true); btnScore.SetActive(false); btnAccessNewTrack.SetActive(false); gManager = GameObject.Find("Game_Manager").GetComponent <Game_Manager>(); GameObject tmpObj = GameObject.Find("GM_Photon"); if (tmpObj) { PhotonManager = tmpObj.GetComponent <MCR.GameManager_MCR_Photon>(); } tmpObj = GameObject.Find("EventSystem"); if (tmpObj) { eventSystem = tmpObj.GetComponent <EventSystem>(); } #endregion }
public void Awake() { Instance = this; playerListEntries = new Dictionary <int, string>(); foreach (Player p in PhotonNetwork.PlayerList) { playerListEntries.Add(p.ActorNumber, p.NickName); } b_IsMasterClient = PhotonNetwork.IsMasterClient; b_IsMine = GetComponent <PhotonView>().IsMine; if (PlayerPrefs.GetString("Which_GameMode") != "OnlineMultiPlayer") { Destroy(this.gameObject); } // Init gameobject needed for the Track Selection Panel GameObject tmpObj = GameObject.Find("ResultMultiObjRef"); if (tmpObj) { currentTrack_Image = tmpObj.GetComponent <ResultPageOnlineMulti_MCR>().ImTrackSelection; } if (tmpObj) { currentTrack_Name = tmpObj.GetComponent <ResultPageOnlineMulti_MCR>().txtTrackSelection; } }
// --> Initilization void Start() { if (PlayerPrefs.GetString("Which_GameMode") != "OnlineMultiPlayer") { StartCoroutine(I_Init()); } else { #if PHOTON_UNITY_NETWORKING b_Multiplayer = true; gManagerPhoton = GameObject.Find("GM_Photon").GetComponent <MCR.GameManager_MCR_Photon>(); #endif } }
public void OnClickButtonLoadNewTrack() { #region if (!gameManager_MCR_Photon) { GameObject obj = GameObject.Find("GM_Photon"); if (obj) { gameManager_MCR_Photon = obj.GetComponent <MCR.GameManager_MCR_Photon>(); gameManager_MCR_Photon.NewRaceButtonClicked(); } } else { gameManager_MCR_Photon.NewRaceButtonClicked(); } #endregion }
public void OnClickButtonTotalScorOnline() { #region btnScore.SetActive(false); btnAccessNewTrack.SetActive(true); btnRestart.SetActive(false); btnLeaveGame.SetActive(true); txtWaitingForOtherPlayers.SetActive(false); if (objStamp_02) { objStamp_02.gameObject.SetActive(true); objStamp_02.AP_LogoAnimation(); } if (!gameManager_MCR_Photon) { GameObject obj = GameObject.Find("GM_Photon"); if (obj) { gameManager_MCR_Photon = obj.GetComponent <MCR.GameManager_MCR_Photon>(); gameManager_MCR_Photon.displayOnlineTotalScore(); } } else { gameManager_MCR_Photon.displayOnlineTotalScore(); } // Display Stamp Global result and display leave game button for all clients except the master client if (PhotonManager) { PhotonManager.totalScoreAllClient(); } if (eventSystem) { eventSystem.SetSelectedGameObject(btnAccessNewTrack); } #endregion }
void OnTriggerEnter(Collider other) { CarPathFollow carPathFollow = other.GetComponent <CarPathFollow> (); if (other.tag == "Car" && carPathFollow.iLapCounter < lapNumber + 1) // A car finish a lap { if (b_ActivateLapCounter) { if (b_Multiplayer) { #if PHOTON_UNITY_NETWORKING for (var j = 0; j < gManagerPhoton.tmpCarList.Count; j++) { if (gManagerPhoton.tmpCarList[j] && gManagerPhoton.tmpCarList[j].gameObject == other.gameObject) { if (gManagerPhoton.tmpPhotonManagerList[j].GetComponent <PhotonView>().IsMine) { if (carPathFollow.iLapCounter <= lapNumber + 1) { Debug.Log("Lap"); Txt_P1_Lap.text = "Lap " + (gManagerPhoton.tmpCarList[j].GetComponent <CarPathFollow>().iLapCounter).ToString() + "/" + lapNumber.ToString(); } } } } #endif } else { if (carPathFollow.iLapCounter <= lapNumber + 1) { if (car[0] != null && car[0].gameObject == other.gameObject && Txt_P1_Lap) { Txt_P1_Lap.text = "Lap " + (car[0].iLapCounter).ToString() + "/" + lapNumber.ToString(); } if (car[1] != null && car[1].name == other.name && Txt_P2_Lap) { Txt_P2_Lap.text = "Lap " + (car[1].iLapCounter).ToString() + "/" + lapNumber.ToString(); } } } } } if (b_ActivateLapCounter) { if (other.tag == "Car" && carPathFollow.iLapCounter >= lapNumber + 1) // A car finish the race //Debug.Log (other.name + " finished the race"); { for (var i = 0; i < car.Count; i++) { if (car[i] != null && car[i].gameObject == other.gameObject && raceFinished[i]) { carController [i].raceIsFinished = true; } if (car [i] != null && car [i].gameObject == other.gameObject && !raceFinished [i]) { raceFinished [i] = true; carTime [i] = Timer; carController [i].raceIsFinished = true; //GM_Photon.DisplayScoreMultiOnline(carController[i].gameObject); if (PlayerPrefs.GetString("Which_GameMode") == "OnlineMultiPlayer") { #if PHOTON_UNITY_NETWORKING PlayerPrefs.SetInt("CurrentScore", Mathf.RoundToInt(carTime[i] * 1000)); MCR.GameManager_MCR_Photon GM_Photon = GameObject.Find("GM_Photon").GetComponent <MCR.GameManager_MCR_Photon>(); if (GM_Photon != null) { Debug.Log(" GM_Photon "); } else { Debug.Log(" GM_Photon nuii"); } Debug.Log(" carTime[ " + i + " ] " + carTime[i]); StartCoroutine( GM_Photon.WinProcessOnlineMultiplayer( carController[i].gameObject, Mathf.RoundToInt(carTime[i] * 1000))); #endif } else if (i == 0 && player2IsManageByCPU) { PlayerPrefs.SetInt("CurrentScore", Mathf.RoundToInt(carTime [i] * 1000)); gameManager.RaceIsFinished(); CheckIfNextTrackMustBeUnlocked(); } else if ((i == 0 || i == 1) && !player2IsManageByCPU && carController [0] != null && carController [0].raceIsFinished && carController [1] != null && carController [1].raceIsFinished) { gameManager.RaceIsFinished(); CheckIfNextTrackMustBeUnlocked(); } } } } } }
private void Update() { #region if (!gameManager_MCR_Photon) { GameObject obj = GameObject.Find("GM_Photon"); if (obj) { gameManager_MCR_Photon = obj.GetComponent <MCR.GameManager_MCR_Photon>(); } } if (gameManager_MCR_Photon && btnRestart && !btnRestart.activeSelf && gameManager_MCR_Photon.b_IsMasterClient && gManager.b_initDone) { bool b_AllThePlayerEndedTheTrack = true;; for (var i = 0; i < gameManager_MCR_Photon.tmpCarRaceEndedList.Count; i++) { if (gameManager_MCR_Photon.tmpCarRaceEndedList[i] == false) { b_AllThePlayerEndedTheTrack = false; break; } } if (b_AllThePlayerEndedTheTrack && !btnAccessNewTrack.activeSelf && !btnScore.activeInHierarchy) { if (PhotonManager) { PhotonManager.initTrackImageInGame(); } btnScore.SetActive(true); txtWaitingForOtherPlayers.SetActive(false); if (eventSystem) { eventSystem.SetSelectedGameObject(btnScore); eventSystem.GetComponent <StandaloneInputModule>().submitButton = "Submit"; } } else if (btnScore.activeSelf && btnAccessNewTrack.activeSelf) { btnScore.SetActive(false); } } /*if (gameManager_MCR_Photon && !gameManager_MCR_Photon.b_IsMasterClient && gManager.b_initDone) * { * Debug.Log("Here 0"); * * if (!btnAccessNewTrack.activeSelf && !btnLeaveGame.activeInHierarchy && objStamp_01 && !objStamp_01.gameObject.activeInHierarchy) * { * Debug.Log("Here 1"); * if (PhotonManager) PhotonManager.initTrackImageInGame(); * if (objStamp_01) * { * Debug.Log("Here 3"); * objStamp_01.gameObject.SetActive(true); * objStamp_01.AP_LogoAnimation(); * } * btnLeaveGame.SetActive(true); * } * * }*/ #endregion }