public System.Collections.IEnumerator EncodeTextures() { if (!startedEncoding) { startedEncoding = true; Main.statusMenu.isLoading = true; Main.statusMenu.loadingStatus = 0; yield return(new WaitForEndOfFrame()); shirtMP = new MultiplayerTexture(ConvertTexture(tShirtTexture, MPTextureType.Shirt), new Vector2(tShirtTexture.width, tShirtTexture.height), MPTextureType.Shirt, debugWriter); Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); pantsMP = new MultiplayerTexture(ConvertTexture(pantsTexture, MPTextureType.Pants), new Vector2(pantsTexture.width, pantsTexture.height), MPTextureType.Pants, debugWriter); Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); shoesMP = new MultiplayerTexture(ConvertTexture(shoesTexture, MPTextureType.Shoes), new Vector2(shoesTexture.width, shoesTexture.height), MPTextureType.Shoes, debugWriter); Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); hatMP = new MultiplayerTexture(ConvertTexture(hatTexture, MPTextureType.Hat), new Vector2(hatTexture.width, hatTexture.height), MPTextureType.Hat, debugWriter); Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); boardMP = new MultiplayerTexture(ConvertTexture(skateboardTexture, MPTextureType.Board), new Vector2(skateboardTexture.width, skateboardTexture.height), MPTextureType.Board, debugWriter); copiedTextures = true; Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); Main.statusMenu.loadingStatus++; yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); Main.menu.multiplayerManager.SendTextures(); yield return(new WaitForEndOfFrame()); Main.menu.multiplayerManager.InvokeRepeating("SendUpdate", 0.5f, 1.0f / (float)MultiplayerController.tickRate); yield return(new WaitForEndOfFrame()); Main.statusMenu.isLoading = false; } yield break; }
public void ConstructFromPlayer(MultiplayerPlayerController source) { //Create a new root object for the player this.player = GameObject.Instantiate <GameObject>(ReplayEditor.ReplayEditorController.Instance.playbackController.gameObject); UnityEngine.Object.DontDestroyOnLoad(this.player); this.player.name = "New Player"; this.player.transform.SetParent(null); this.player.transform.position = PlayerController.Instance.transform.position; this.player.transform.rotation = PlayerController.Instance.transform.rotation; debugWriter.WriteLine("Created New Player"); this.replayController = this.player.GetComponentInChildren <ReplayPlaybackController>(); this.bones = replayController.playbackTransforms.ToArray(); //UnityEngine.Object.DestroyImmediate(this.player.GetComponentInChildren<ReplayEditor.ReplayPlaybackController>()); foreach (MonoBehaviour m in this.player.GetComponentsInChildren <MonoBehaviour>()) { if (m.GetType() == typeof(ReplayEditor.ReplayAudioEventPlayer)) { UnityEngine.Object.Destroy(m); } } this.player.SetActive(true); this.board = this.player.transform.Find("Skateboard").gameObject; this.board.transform.position = new Vector3(1111111, 111111111, 11111111); this.board.name = "New Player Board"; this.skater = this.player.transform.Find("NewSkater").gameObject; this.skater.transform.position = new Vector3(1111111, 111111111, 11111111); this.skater.name = "New Player Skater"; this.hips = this.skater.transform.Find("Skater_Joints").Find("Skater_root"); this.skaterMeshesObject = this.skater.transform.Find("Skater").gameObject; debugWriter.WriteLine("created everything"); characterCustomizer.enabled = true; characterCustomizer.RemoveAllGear(); foreach (Transform t in skaterMeshesObject.GetComponentsInChildren <Transform>()) { if (t.gameObject != null) { GameObject.Destroy(t.gameObject); } } debugWriter.WriteLine("Removed gear"); debugWriter.WriteLine(characterCustomizer.ClothingParent.name); debugWriter.WriteLine(characterCustomizer.RootBone.name); characterCustomizer.ClothingParent = this.hips.Find("Skater_pelvis"); characterCustomizer.RootBone = this.hips; Traverse.Create(characterCustomizer).Field("_bonesDict").SetValue(this.hips.GetComponentsInChildren <Transform>().ToDictionary((Transform t) => t.name)); characterCustomizer.LoadCustomizations(PlayerController.Instance.characterCustomizer.CurrentCustomizations); debugWriter.WriteLine("Added gear back"); bool foundHat = false, foundShirt = false, foundPants = false, foundShoes = false; foreach (Tuple <CharacterGear, GameObject> GearItem in gearList) { switch (GearItem.Item1.categoryName) { case "Hat": hatObject = GearItem.Item2; foundHat = true; break; case "Hoodie": shirtObject = GearItem.Item2; foundShirt = true; break; case "Shirt": shirtObject = GearItem.Item2; foundShirt = true; break; case "Pants": pantsObject = GearItem.Item2; foundPants = true; break; case "Shoes": shoesObject = GearItem.Item2; foundShoes = true; break; } } if (!foundHat) { CharacterGear newHat = CreateGear(GearCategory.Hat, "Hat", "PAX_1"); characterCustomizer.LoadGear(newHat); } if (!foundPants) { CharacterGear newPants = CreateGear(GearCategory.Pants, "Pants", "PAX_1"); characterCustomizer.LoadGear(newPants); } if (!foundShirt) { CharacterGear newShirt = CreateGear(GearCategory.Shirt, "Shirt", "PAX_1"); characterCustomizer.LoadGear(newShirt); } if (!foundShoes) { CharacterGear newShoes = CreateGear(GearCategory.Shoes, "Shoes", "PAX_1"); characterCustomizer.LoadGear(newShoes); } this.usernameObject = new GameObject("Username Object"); this.usernameObject.transform.SetParent(this.player.transform, false); this.usernameObject.transform.localScale = new Vector3(-0.01f, 0.01f, 1f); this.usernameObject.AddComponent <MeshRenderer>(); this.usernameObject.GetComponent <MeshRenderer>().material = Resources.FindObjectsOfTypeAll <Font>()[0].material; this.usernameText = this.usernameObject.AddComponent <TextMesh>(); this.usernameText.text = username; this.usernameText.fontSize = 256; this.usernameText.font = Resources.FindObjectsOfTypeAll <Font>()[0]; this.usernameText.color = Color.black; this.usernameText.alignment = TextAlignment.Center; this.shirtMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Shirt); this.pantsMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Pants); this.hatMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Hat); this.shoesMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Shoes); this.boardMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Board); }