public void CmdPropagateRdy(PlyrNum _PlyrId) { var StartScreenBhvr = GameObject.Find("StartUpWindow(Clone)").GetComponent<StartUpScrBhvr>(); // Sets PlyerId as ready on server. StartScreenBhvr.RdyArray[(int)_PlyrId] = true; StartScreenBhvr.RdyCheckMark[(int)_PlyrId].gameObject.SetActive(true); // Propagates to clients RpcPropagateRdy(_PlyrId, StartScreenBhvr.RdyArray); }
public void RpcPropagateRdy(PlyrNum _PlyrId, bool[] _RdyArray) { var StartScreenBhvr = GameObject.Find("StartUpWindow(Clone)").GetComponent<StartUpScrBhvr>(); // Get Rdy state array from server. StartScreenBhvr.RdyArray = _RdyArray; int i = 0; // Propagates all Rdy states to all clients foreach (var RdyState in StartScreenBhvr.RdyArray) { if (RdyState) { StartScreenBhvr.RdyCheckMark[i].gameObject.SetActive(true); } i++; } // If all players are ready start the game. if (StartScreenBhvr.RdyArray.All(b => b)) { GameObject.Find("Me").GetComponent<StartUpScreenMngr>().GameStart(); } }
// Use this for initialization void Start() { PlayerObjRef = this.gameObject; // Disable this script for all player classes that are not "Me" and exits. if (PlayerObjRef.name != "Me") { this.enabled = false; return; } // Gets a reference for the main canvas MainCanvasRef = GameObject.Find("MainCanvas"); // Find out what class the player is playing. if (PlayerObjRef.GetComponent<GhostController>()) { // Disable movement PlayerObjRef.GetComponent<GhostController>().enabled = false; MyPlyrId = PlyrNum.Ghost; } else { // Disable movement PlayerObjRef.GetComponent<AvatarController>().enabled = false; if (PlayerObjRef.GetComponent<Sprint>()) { MyPlyrId = PlyrNum.Sprinter; } else if (PlayerObjRef.GetComponent<Heal>()) { MyPlyrId = PlyrNum.Support; } else if (PlayerObjRef.GetComponent<SetTrapPoison>()) { MyPlyrId = PlyrNum.TrapMaster; } } MyPlayerInt = (int)MyPlyrId; // Instance the Start Up window. windowObj = (GameObject)Instantiate(StrtWndwPreFab,Vector3.zero,Quaternion.identity); var windowScrpt = windowObj.GetComponent<StartUpScrBhvr>(); windowScrpt.ScrnMngrRef = this; windowScrpt.MyId = MyPlyrId; // Set window parent and center it. windowObj.transform.SetParent(MainCanvasRef.transform); windowObj.transform.localPosition = Vector3.zero; windowObj.transform.localScale= Vector3.one; if (MyPlyrId == PlyrNum.Ghost) { //windowObj.GetComponent<StartUpScrBhvr>().ClassName.text = "Ghost"; windowScrpt.BaseNetBhvr = gameObject.GetComponent<GhostNetworkBehavior>(); } else { //windowObj.GetComponent<StartUpScrBhvr>().ClassName.text = "Explorer"; windowScrpt.BaseNetBhvr = gameObject.GetComponent<AvatarNetworkBehavior>(); } }