private CharacterGear CreateGear(string id, string name, string path, string category) { CharacterGear newGear = new CharacterGear(); newGear.id = id; newGear.name = name; newGear.path = path; newGear.categoryName = category; switch (category) { case "Hat": newGear.category = GearCategory.Hat; break; case "Shirt": newGear.category = GearCategory.Shirt; break; case "Hoodie": newGear.category = GearCategory.Hoodie; break; case "Pants": newGear.category = GearCategory.Pants; break; case "Shoes": newGear.category = GearCategory.Shoes; break; } return(newGear); }
/// <summary> /// Create a new instance of CharacterRightSide. /// </summary> /// <param name="offhand">The offhand equipment equipped by the character.</param> /// <param name="earrings">The earring equipment equipped by the character.</param> /// <param name="necklace">The necklace equipment equipped by the character.</param> /// <param name="bracelet">The bracelet equipment equipped by the character.</param> /// <param name="ring1">The first ring equipment equipped by the character.</param> /// <param name="ring2">The second ring equipment equipped by the character.</param> public CharacterRightSide(CharacterGear offhand, CharacterGear earrings, CharacterGear necklace, CharacterGear bracelet, CharacterGear ring1, CharacterGear ring2) { Offhand = offhand; Earrings = earrings; Necklace = necklace; Bracelet = bracelet; Ring1 = ring1; Ring2 = ring2; }
private CharacterGear CreateGear(GearCategory category, string categoryName, string id) { CharacterGear newGear = new CharacterGear(); newGear.category = category; newGear.categoryName = categoryName; newGear.id = id; newGear.path = "CharacterCustomization/" + categoryName + "/" + id; return(newGear); }
/// <summary> /// Create a new instance of CharacterLeftSide. /// </summary> /// <param name="weapon">The weapon equipped by the character.</param> /// <param name="head">The head equipment equipped by the character.</param> /// <param name="chest">The chest equipment equipped by the character.</param> /// <param name="arms">The arm equipment equipped by the character.</param> /// <param name="waist">The waist equipment equipped by the character.</param> /// <param name="legs">The leg equipment equipped by the character.</param> /// <param name="feet">The foot equipment equipped by the character.</param> public CharacterLeftSide(CharacterWeapon weapon, CharacterGear head, CharacterGear chest, CharacterGear arms, CharacterGear waist, CharacterGear legs, CharacterGear feet) { Weapon = weapon; Head = head; Chest = chest; Arms = arms; Waist = waist; Legs = legs; Feet = feet; }
/// <summary> /// Create a new instance of CharacterInventory. /// </summary> /// <param name="weapon">The weapon equipped by the character.</param> /// <param name="head">The head equipment equipped by the character.</param> /// <param name="chest">The chest equipment equipped by the character.</param> /// <param name="arms">The arm equipment equipped by the character.</param> /// <param name="waist">The waist equipment equipped by the character.</param> /// <param name="legs">The leg equipment equipped by the character.</param> /// <param name="feet">The foot equipment equipped by the character.</param> /// <param name="offhand">The offhand equipment equipped by the character.</param> /// <param name="earrings">The earring equipment equipped by the character.</param> /// <param name="necklace">The necklace equipment equipped by the character.</param> /// <param name="bracelet">The bracelet equipment equipped by the character.</param> /// <param name="ring1">The first ring equipment equipped by the character.</param> /// <param name="ring2">The second ring equipment equipped by the character.</param> public CharacterInventory(CharacterWeapon weapon, CharacterGear head, CharacterGear chest, CharacterGear arms, CharacterGear waist, CharacterGear legs, CharacterGear feet, CharacterGear offhand, CharacterGear earrings, CharacterGear necklace, CharacterGear bracelet, CharacterGear ring1, CharacterGear ring2) { Weapon = weapon; Head = head; Chest = chest; Arms = arms; Waist = waist; Legs = legs; Feet = feet; Offhand = offhand; Earrings = earrings; Necklace = necklace; Bracelet = bracelet; Ring1 = ring1; Ring2 = ring2; }
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); }
public void SetPlayerTexture(Texture tex, MPTextureType texType, bool useFull) { switch (texType) { case MPTextureType.Pants: foreach (Tuple <CharacterGear, GameObject> gearItem in gearList) { if (gearItem.Item1.categoryName.Equals("Pants")) { gearItem.Item2.GetComponent <Renderer>().material.SetTexture(MainTextureName, tex); break; } } break; case MPTextureType.Shirt: foreach (Tuple <CharacterGear, GameObject> gearItem in gearList) { if (gearItem.Item1.categoryName.Equals("Hoodie") || gearItem.Item1.categoryName.Equals("Shirt")) { CharacterGear newGear = new CharacterGear(); newGear.id = "PAX_1"; newGear.name = "Black"; newGear.category = useFull ? GearCategory.Hoodie : GearCategory.Shirt; newGear.categoryName = useFull ? "Hoodie" : "Shirt"; newGear.path = useFull ? "CharacterCustomization/Hoodie/PAX_1" : "CharacterCustomization/Shirt/PAX_1"; characterCustomizer.LoadGear(newGear); break; } } if (tex != null) { foreach (Tuple <CharacterGear, GameObject> gearItem in gearList) { if (gearItem.Item1.categoryName.Equals("Hoodie") || gearItem.Item1.categoryName.Equals("Shirt")) { gearItem.Item2.GetComponent <Renderer>().material.SetTexture(MainTextureName, tex); } } } break; case MPTextureType.Shoes: foreach (Tuple <CharacterGear, GameObject> gearItem in gearList) { if (gearItem.Item1.categoryName.Equals("Shoes")) { GameObject Shoe_L = gearItem.Item2.transform.Find("Shoe_L").gameObject; GameObject Shoe_R = gearItem.Item2.transform.Find("Shoe_R").gameObject; Shoe_L.GetComponent <Renderer>().material.SetTexture(MainTextureName, tex); Shoe_R.GetComponent <Renderer>().material.SetTexture(MainTextureName, tex); break; } } break; case MPTextureType.Hat: foreach (Tuple <CharacterGear, GameObject> gearItem in gearList) { if (gearItem.Item1.categoryName.Equals("Hat")) { gearItem.Item2.GetComponent <Renderer>().material.SetTexture(MainTextureName, tex); break; } } break; case MPTextureType.Board: foreach (Transform t in board.GetComponentsInChildren <Transform>()) { if (SkateboardMaterials.Contains(t.name)) { Renderer r = t.GetComponent <Renderer>(); if (r != null) { r.material.SetTexture(MainDeckTextureName, tex); } } } break; } }
private void AddGear(CharacterGear newGear, GameObject newObject) { Tuple <CharacterGear, GameObject> newTuple = Tuple.Create <CharacterGear, GameObject>(newGear, newObject); gearList.Add(newTuple); }
private void updateTexture(string GearItem, Texture2D texture, Texture2D normal, Texture2D rgmtao) { if (!GearItem.Equals("Skateboard")) { if (!GearItem.Equals("Shirt") && !GearItem.Equals("Hoodie")) { foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals(GearItem)) { if (GearItem == "Shoes") { RemoveTupleFromGear(t); CharacterGear newGear = CreateGear("PAX_1", "Black White Sole", "CharacterCustomization/shoes/PAX_1", GearItem); GameObject newObject = CustomLoadPrefab(Resources.Load <GameObject>(newGear.path), skaterMeshesObject.transform); AddGear(newGear, newObject); GameObject Shoe_L = newObject.transform.Find("Shoe_L").gameObject; GameObject Shoe_R = newObject.transform.Find("Shoe_R").gameObject; if (normal == null) { normal = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shoe_Normal.png"); } if (rgmtao == null) { rgmtao = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shoe_RgMtAo.png"); } SetNewTextures(Shoe_L, texture, normal, rgmtao); SetNewTextures(Shoe_R, texture, normal, rgmtao); break; } else { RemoveTupleFromGear(t); string name = ""; string path = ""; CharacterGear newGear = null; switch (GearItem) { case "Hat": name = "Black"; path = "CharacterCustomization/Hat/PAX_1"; newGear = CreateGear("PAX_1", name, path, GearItem); break; case "Pants": name = "Black"; path = "CharacterCustomization/pants/PAX_1"; newGear = CreateGear("PAX_1", name, path, GearItem); break; } GameObject prefab = Resources.Load <GameObject>(newGear.path); GameObject newObject = CustomLoadPrefab(prefab, skaterMeshesObject.transform); Tuple <Mesh, Texture2D[]> hat = null; if (selectedWindow == SkinEditorWindowShow.Hat) { if (currentCap != CapType.defaultCap) { currentCap = CapType.defaultCap; } hat = GetHatMesh(); } else if (selectedWindow == SkinEditorWindowShow.Beanie) { currentCap = CapType.beanie; hat = GetHatMesh(); } else if (selectedWindow == SkinEditorWindowShow.Snapback) { if (currentCap != CapType.backwardSnapback || currentCap != CapType.forwardSnapback) { currentCap = CapType.forwardSnapback; } hat = GetHatMesh(); } if (hat != null) { newObject.GetComponent <SkinnedMeshRenderer>().sharedMesh = hat.Item1; if (normal == null) { normal = hat.Item2[0]; } if (rgmtao == null) { rgmtao = hat.Item2[1]; } UpdateReplayhat(); } else { if (normal == null) { normal = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Pants_Normal.png"); } if (rgmtao == null) { rgmtao = assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Pants_RgMtAo.png"); } } AddGear(newGear, newObject); SetNewTextures(newObject, texture, normal, rgmtao); break; } } } } else { foreach (Tuple <CharacterGear, GameObject> t in gearList) { if (t.Item1.categoryName.Equals("Hoodie") || t.Item1.categoryName.Equals("Shirt")) { RemoveTupleFromGear(t); string name = GearItem.Equals("Hoodie") ? "Black" : "Black"; string path = GearItem.Equals("Hoodie") ? "CharacterCustomization/Hoodie/PAX_1" : "CharacterCustomization/Shirt/PAX_1"; normal = normal != null ? normal : GearItem.Equals("Hoodie") ? assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Hoodie_Normal.png") : assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shirt_Normal.png"); rgmtao = rgmtao != null ? rgmtao : GearItem.Equals("Hoodie") ? assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Hoodie_RgMtAo.png") : assetsBundle.LoadAsset <Texture2D>("Assets/DefaultTextures/Shirt_RgMtAo.png"); CharacterGear newGear = CreateGear("PAX_1", name, path, GearItem); GameObject newObject = CustomLoadPrefab(Resources.Load <GameObject>(newGear.path), skaterMeshesObject.transform); AddGear(newGear, newObject); SetNewTextures(newObject, texture, normal, rgmtao); Traverse.Create(characterCustomizer).Method("UpdateBodyMesh").GetValue(); break; } } } } else { foreach (Transform t in board.GetComponentsInChildren <Transform>()) { if (SkateboardMaterials.Contains(t.name)) { Renderer r = t.GetComponent <Renderer>(); if (r != null) { if (t.name.Equals(SkateboardMaterials[0])) { UnityEngine.Object.Destroy(r.sharedMaterial.GetTexture(MainDeckTextureName)); } r.sharedMaterial.SetTexture(MainDeckTextureName, texture); if (normal != null) { r.sharedMaterial.SetTexture(NormalDeckTextureName, normal); } if (rgmtao != null) { r.sharedMaterial.SetTexture(rgmtaoDeckTextureName, rgmtao); } } } } } }
protected Character(string name, double life, double mana, double lifeRegenerationMultiplier, double manaRegenerationMultiplier, CharacterGear gear, double damage) { this.Name = name; this.BaseLife = life; this.Life = life; this.BaseMana = mana; this.Mana = mana; this.LifeRegenerationMultiplier = lifeRegenerationMultiplier; this.ManaRegenerationMultiplier = manaRegenerationMultiplier; this.CharacterGear = gear; this.Damage = damage; }