public void UnEquipArmor(ArmorType armorType) //MUST UNEQUIP BEFORE EQUIPPING IF NOT NULL { if (EquippedArmor[(int)armorType]) { AddItem(EquippedArmor[(int)armorType], true); EquippedArmor[(int)armorType] = null; playerStats.RemoveAttributeEffect(AttributesEnum.armor, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], true); //second entry is name e.g. "Head" playerStats.RemoveAttributeEffect(AttributesEnum.plating, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], true); //second entry is name e.g. "Head" playerStats.RemoveAttributeEffect(AttributesEnum.stamina_regen, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], false); //second entry is name e.g. "Head" // UMA Component string currentSlot = armorType.ToString(); if (currentSlot == "Head") { currentSlot = "Helmet"; } playerAvatar.ClearSlot(currentSlot); if (currentSlot == "Chest") { playerAvatar.ClearSlot("Hands"); } if (currentSlot == "Legs") { playerAvatar.ClearSlot("Feet"); } playerAvatar.BuildCharacter(); } }
public void EyebrowChange() { // Get the available UMATextRecipes for this slot. List <UMATextRecipe> slotRecipes = avatar.AvailableRecipes["Eyebrows"]; /*foreach (UMATextRecipe utr in slotRecipes) * { * Debug.Log(utr.name); * }*/ if (drp.value == 0) { avatar.ClearSlot("Eyebrows"); avatar.BuildCharacter(); avatar.ForceUpdate(true, true, true); } if (drp.value == 1) { foreach (UMATextRecipe utr in slotRecipes) { if (utr.name == "MaleBrow01") { avatar.SetSlot(utr); avatar.BuildCharacter(); avatar.ForceUpdate(true, true, true); Debug.Log(utr.name); } } } if (drp.value == 2) { foreach (UMATextRecipe utr in slotRecipes) { if (utr.name == "MaleBrow02") { avatar.SetSlot(utr); avatar.BuildCharacter(); avatar.ForceUpdate(true, true, true); Debug.Log(utr.name); } } } if (drp.value == 3) { foreach (UMATextRecipe utr in slotRecipes) { if (utr.name == "MaleBrowHR") { avatar.SetSlot(utr); avatar.BuildCharacter(); avatar.ForceUpdate(true, true, true); Debug.Log(utr.name); } } } }
public void ChangeHair(bool plus) { if (avatar.activeRace.name == "HumanMaleDCS") { if (plus) { currentHairMale++; } else { currentHairMale--; } currentHairMale = Mathf.Clamp(currentHairMale, 0, CharacterManager.Instance.hairModelsMale.Count - 1); if (CharacterManager.Instance.hairModelsMale[currentHairMale] == "None") { avatar.ClearSlot("Hair"); } else { avatar.SetSlot("Hair", CharacterManager.Instance.hairModelsMale[currentHairMale]); } dataHolder.SetHairType(currentHairMale); } if (avatar.activeRace.name == "HumanFemaleDCS") { if (plus) { currentHairFemale++; } else { currentHairFemale--; } currentHairFemale = Mathf.Clamp(currentHairFemale, 0, CharacterManager.Instance.hairModelsFemale.Count - 1); if (CharacterManager.Instance.hairModelsFemale[currentHairFemale] == "None") { avatar.ClearSlot("Hair"); } else { avatar.SetSlot("Hair", CharacterManager.Instance.hairModelsFemale[currentHairFemale]); } dataHolder.SetHairType(currentHairFemale); } avatar.BuildCharacter(); }
/*************************************************************************** * Name: ChangeHair * Description: Changes the current skin color of the player. * Input: Boolean representing if the "next hair" button is pressed * Output: None ***************************************************************************/ public void ChangeHair(bool plus) { if (player.activeRace.name == "HumanMaleDCS") { //move through an list of pre-loaded hairstyles based on the index if (plus) { hairIndex++; } else { hairIndex--; } //lock the index value inside the values of the current array hairIndex = Mathf.Clamp(hairIndex, 0, maleHairOptions.Count - 1); if (maleHairOptions[hairIndex] == "None") { //empty the avatar's hair slot completely player.ClearSlot("Hair"); } else { //set the avatar's hair slot to the current index value of the list player.SetSlot("Hair", maleHairOptions[hairIndex]); } } else { if (plus) { hairIndex++; } else { hairIndex--; } hairIndex = Mathf.Clamp(hairIndex, 0, femaleHairOptions.Count - 1); if (femaleHairOptions[hairIndex] == "None") { player.ClearSlot("Hair"); } else { player.SetSlot("Hair", femaleHairOptions[hairIndex]); } } //force a player update in Unity player.BuildCharacter(); }
public void ClearClothing(DynamicCharacterAvatar avatar) { foreach (UMATextRecipe r in Recipes) { avatar.ClearSlot(r.wardrobeSlot); } }
/// <summary> /// Sets any wardrobe slot. If a negative value is passed, then the slot is cleared. /// </summary> /// <param name="slotToChange">name of the wordrobe slot to change</param> /// <param name="fSlotNumber">Id number slot to change</param> public void SetSlot(string slotToChange, float fSlotNumber) { if (slotToChange == "WardrobeCollection") { SetWardrobeCollectionSlot(slotToChange, fSlotNumber); } else { var thisRace = Avatar.activeRace.name; int slotNumber = (int)fSlotNumber; UMATextRecipe tr = null; if (slotNumber >= 0) { tr = characterSystem.Recipes[thisRace][slotToChange][slotNumber]; Debug.Log(tr.name); Avatar.SetSlot(tr); } else { Avatar.ClearSlot(slotToChange); Avatar.ReapplyWardrobeCollections(); } } Avatar.BuildCharacter(true); //Update the dropdowns to reflect any changes after the character has built SetUpWardrobeDropdowns(); }
public void OnClick() { SetColors(); // If there is no recipe, then just remove whatever is there (if any) if (Recipe == null) { Avatar.ClearSlot(Slot); Avatar.BuildCharacter(true); return; } #if UMA_ADDRESSABLES SetRecipe(); /* if (isReady) * { * SetRecipe(); * } * else * { * var op = UMAAssetIndexer.Instance.Preload(Recipe); * op.Completed += Op_Completed; * } */ #else SetRecipe(); #endif }
//public void ChangeHair(int hair) //{ // if (characterAvatar.activeRace.name == "HumanMaleDCS") // { // characterAvatar.SetSlot(MaleHair[hair]); // } // if (characterAvatar.activeRace.name == "HumanFemaleDCS") // { // characterAvatar.SetSlot(FemaleHair[hair]); // } // characterAvatar.BuildCharacter(); //} public void ChangeHair(bool plus) { if (characterAvatar.activeRace.name == "HumanMaleDCS") { if (plus) { CurrentMaleHair++; } else { CurrentMaleHair--; } CurrentMaleHair = Mathf.Clamp(CurrentMaleHair, 0, hairMaleModels.Count - 1); if (hairMaleModels[CurrentMaleHair] == "None") { characterAvatar.ClearSlot("Hair"); } else { characterAvatar.SetSlot("Hair", hairMaleModels[CurrentMaleHair]); } } if (characterAvatar.activeRace.name == "HumanFemnetaleDCS") { //Female Hair if (plus) { CurrentFemaleHair++; } else { CurrentFemaleHair--; } CurrentFemaleHair = Mathf.Clamp(CurrentFemaleHair, 0, hairFemaleModels.Count - 1); if (hairFemaleModels[CurrentFemaleHair] == "None") { characterAvatar.ClearSlot("Hair"); } else { characterAvatar.SetSlot("Hair", hairFemaleModels[CurrentFemaleHair]); } } characterAvatar.BuildCharacter(); }
public void SelectClothing(int index) { #if _UMA bool male = dca.activeRace.name == "HumanMale" ? true : false; dca.ClearSlot("Underwear"); if (male) { dca.SetSlot(maleClothing[index]); } if (!male) { dca.SetSlot(femaleClothing[index]); } dca.BuildCharacter(); #endif }
public void RPC_ChangeWardrobe(string category, string recipe) { if (recipe != "") { dca.SetSlot(category, recipe); } else { dca.ClearSlot(category); } dca.BuildCharacter(true); }
public bool RemoveItem(EquippableItem item) { for (int i = 0; i < equipmentSlots.Length; i++) { if (equipmentSlots[i].Item == item) { equipmentSlots[i].Item = null; player.ClearSlot(equipmentSlots[i].EquipmentType.ToString()); player.BuildCharacter(); return(true); } } return(false); }
private void RandomizeAvatar(DynamicCharacterAvatar Avatar) { Dictionary <string, List <UMATextRecipe> > recipes = Avatar.AvailableRecipes; // Set random wardrobe slots. foreach (string SlotName in recipes.Keys) { int cnt = recipes[SlotName].Count; if (cnt > 0) { //Get a random recipe from the slot, and apply it int min = -1; if (SlotName == "Legs") { min = 0; // Don't allow pants removal in random test } int rnd = Random.Range(min, cnt); if (rnd == -1) { Avatar.ClearSlot(SlotName); } else { Avatar.SetSlot(recipes[SlotName][rnd]); } } } // Set Random DNA Dictionary <string, DnaSetter> setters = Avatar.GetDNA(); foreach (KeyValuePair <string, DnaSetter> dna in setters) { dna.Value.Set(0.35f + (Random.value * 0.3f)); } // Set Random Colors for Skin and Hair int RandHair = Random.Range(0, HairColors.colors.Length); int RandSkin = Random.Range(0, SkinColors.colors.Length); Avatar.SetColor("Hair", HairColors.colors[RandHair]); Avatar.SetColor("Skin", SkinColors.colors[RandSkin]); Avatar.BuildCharacter(true); Avatar.ForceUpdate(true, true, true); }
void SetWardrobe(bool active) { if (wardrobeRecipe == null) { return; } if (active) { avatar.SetSlot(wardrobeRecipe); } else { avatar.ClearSlot(wardrobeRecipe.wardrobeSlot); } avatar.BuildCharacter(); }
public void OnClick() { // If there is no recipe, then just remove whatever is there (if any) if (Recipe == null) { Avatar.ClearSlot(Slot); Avatar.BuildCharacter(true); Avatar.ForceUpdate(true, true, true); return; } // We have a recipe. // The wardrobe slot is defined in the recipe itself, so setting a recipe is all // that is needed to "put on" a wardrobe item. // Any recipe that already exists at that slot will be removed - so, for example, // putting on a shirt will replace the existing shirt if one exists. Avatar.SetSlot(Recipe); // Rebuild the character so its wearing the new wardrobe item. Avatar.BuildCharacter(true); Avatar.ForceUpdate(true, true, true); }
/// <summary> /// Sets any wardrobe slot. If a negative value is passed, then the slot is cleared. /// </summary> /// <param name="slotToChange">name of the wordrobe slot to change</param> /// <param name="fSlotNumber">Id number slot to change</param> public void SetSlot(string slotToChange, float fSlotNumber) { var thisRace = Avatar.activeRace.name; int slotNumber = (int)fSlotNumber; string prioritySlot = ""; List <string> prioritySlotOver = new List <string>(); UMATextRecipe tr = null; if (slotNumber >= 0) { tr = characterSystem.Recipes[thisRace][slotToChange][slotNumber]; prioritySlotOver = tr.suppressWardrobeSlots; prioritySlot = tr.wardrobeSlot; Avatar.SetSlot(tr); } else { Avatar.ClearSlot(slotToChange); } if (prioritySlotOver.Count > 0) { foreach (Transform child in wardrobeDropdownPanel.transform) { if (child.gameObject.activeSelf) { var thisSlot = child.GetComponent <CSWardrobeSlotChangerDD>().wardrobeSlotToChange; if (prioritySlotOver.Contains(thisSlot)) { child.GetComponent <Dropdown>().value = 0; child.GetComponent <Dropdown>().CancelInvoke(); } } } } Avatar.BuildCharacter(true, prioritySlot, prioritySlotOver); //Update the dropdowns to reflect any changes SetUpWardrobeDropdowns(); }
public void ChangeHair(bool plus) { if (plus) { currentHair++; } else { currentHair--; } currentHair = Mathf.Clamp(currentHair, 0, hairModels.Count - 1); if (hairModels[currentHair] == "None") { avatar.ClearSlot("Hair"); } else { avatar.SetSlot("Hair", hairModels[currentHair]); } avatar.BuildCharacter(); }
public void ClearChest() { character.ClearSlot("Chest"); character.BuildCharacter(); }
public void ChangeHair(int hairIndex) { if (avatar.activeRace.name == "HumanMaleDCS") { currentHairMale = hairIndex; if (hairModelsMale[currentHairMale] == "None") { avatar.ClearSlot("Hair"); } else { avatar.SetSlot("Hair", hairModelsMale[currentHairMale]); } } if (avatar.activeRace.name == "HumanFemaleDCS") { currentHairFemale = hairIndex; if (hairModelsFemale[currentHairFemale] == "None") { avatar.ClearSlot("Hair"); } else { avatar.SetSlot("Hair", hairModelsFemale[currentHairFemale]); } } avatar.BuildCharacter(); }
public void UnEquipItem(DynamicCharacterAvatar avatar, ItemSlot itemSlot) { // UMAData must not be null, so wait until it is not. UMAData umaData = null; while (umaData == null) { umaData = avatar.gameObject.GetComponent <UMAData>(); } switch (itemSlot) { case ItemSlot.HEAD: avatar.ClearSlot("Helmet"); avatar.BuildCharacter(); break; case ItemSlot.CHEST: avatar.ClearSlot("Chest"); avatar.BuildCharacter(); break; case ItemSlot.LEGS: avatar.ClearSlot("Legs"); avatar.BuildCharacter(); break; case ItemSlot.HANDS: avatar.ClearSlot("Hands"); avatar.BuildCharacter(); break; case ItemSlot.FEET: avatar.ClearSlot("Feet"); avatar.BuildCharacter(); break; case ItemSlot.LEFT_HAND: // Find left hand bone. GameObject boneObjL = umaData.GetBoneGameObject("LeftHand"); // If previous item exists remove it. Transform objTransformL = boneObjL.transform.Find("LeftHandItem"); if (objTransformL != null) { Destroy(objTransformL.gameObject); } // Find right hand bone. GameObject boneObjLR = umaData.GetBoneGameObject("RightHand"); // If previous two hand item exists remove it. Transform objTransformL2 = boneObjLR.transform.Find("TwoHandItem"); if (objTransformL2 != null) { Destroy(objTransformL2.gameObject); } break; case ItemSlot.RIGHT_HAND: // Find right hand bone. GameObject boneObjR = umaData.GetBoneGameObject("RightHand"); // If previous item exists remove it. Transform objTransformR = boneObjR.transform.Find("RightHandItem"); if (objTransformR != null) { Destroy(objTransformR.gameObject); } // If previous two hand item exists remove it. Transform objTransformR2 = boneObjR.transform.Find("TwoHandItem"); if (objTransformR2 != null) { Destroy(objTransformR2.gameObject); } break; case ItemSlot.TWO_HAND: // Find left hand bone. GameObject boneObjTHL = umaData.GetBoneGameObject("LeftHand"); // If previous left hand item exists remove it. Transform objTransformTH1 = boneObjTHL.transform.Find("LeftHandItem"); if (objTransformTH1 != null) { Destroy(objTransformTH1.gameObject); } // Find right hand bone. GameObject boneObjTHR = umaData.GetBoneGameObject("RightHand"); // If previous right hand item exists remove it. Transform objTransformTH2 = boneObjTHR.transform.Find("RightHandItem"); if (objTransformTH2 != null) { Destroy(objTransformTH2.gameObject); } // If previous two hand item exists remove it. Transform objTransformTH3 = boneObjTHR.transform.Find("TwoHandItem"); if (objTransformTH3 != null) { Destroy(objTransformTH3.gameObject); } break; } }