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 ResetClick() { avatar.ClearSlots(); SwitchGender(false); SwitchGender(true); avatar.BuildCharacter(); }
// Character colors and wardrobes initialization. public void Initialize() { avatar.ClearSlots(); avatar.LoadDefaultWardrobe(); avatar.BuildCharacter(true); avatar.characterColors = defaultColors; avatar.BuildCharacter(true); }
public void ChangeHeight() { if (dna == null) { dna = character.GetDNA(); } height = levelManager.height; dna["height"].Set(height); character.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 LoadRecipeForEdit() { myRecipe = File.ReadAllText(Application.persistentDataPath + "/characterSaves/" + SelectedCharacterName + ".txt"); nameField.text = SelectedCharacterName; avatar.LoadFromRecipeString(myRecipe); avatar.BuildCharacter(); }
void ChangeGender(bool male) { if (male && avatar.activeRace.name != "HumanMaleDCS") { avatar.ChangeRace("HumanMaleDCS"); ChangeHairStyle(currentStyle); } if (!male && avatar.activeRace.name != "HumanFemaleDCS") { avatar.ChangeRace("HumanFemaleDCS"); ChangeHairStyle(currentStyle); } avatar.BuildCharacter(); }
private void UpdateWardrobe() { if (Head) { enemyAvatar.SetSlot(Head.GetComponent <Armor>().GetWardrobePiece().Item1); } if (Chest) { enemyAvatar.SetSlot(Chest.GetComponent <Armor>().GetWardrobePiece().Item1); if (Chest.GetComponent <Armor>().GetWardrobePiece().Item2) { enemyAvatar.SetSlot(Chest.GetComponent <Armor>().GetWardrobePiece().Item2); } } if (Legs) { enemyAvatar.SetSlot(Legs.GetComponent <Armor>().GetWardrobePiece().Item1); if (Legs.GetComponent <Armor>().GetWardrobePiece().Item2) { enemyAvatar.SetSlot(Legs.GetComponent <Armor>().GetWardrobePiece().Item2); } } if (enemyAvatar) { enemyAvatar.BuildCharacter(); } }
/// <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 DynamicCharacterAvatar CreateCharacter(CharacterDataHolder characterData, float posX, float posY, float posZ, float heading) { // Setting race on Instantiate, because even we set it at CustomizeCharacterAppearance, we could not mount items for female characters. Vector3 newPosition = new Vector3(posX, posY, posZ); DynamicCharacterAvatar avatarTemplate = characterData.GetRace() == 0 ? _avatarMale : _avatarFemale; DynamicCharacterAvatar newAvatar = Instantiate(avatarTemplate, newPosition, Quaternion.identity) as DynamicCharacterAvatar; // Set heading early, to avoid inconsistencies with template heading that are // sometimes visible before CustomizeCharacterAppearance starts on character selection scene. SetAvatarHeading(newAvatar, heading); // Prevent UMA bone error. newAvatar.BuildCharacter(false); // Add a new Capsule Collider to prevent falling. CapsuleCollider capsuleCollider = newAvatar.gameObject.AddComponent <CapsuleCollider>(); capsuleCollider.radius = 0.15f; capsuleCollider.height = 1.71f; capsuleCollider.center = new Vector3(0, 0.82f, 0); // Add AudioSource. newAvatar.gameObject.AddComponent <AudioSource>(); // Customize character. StartCoroutine(CustomizeCharacterAppearance(characterData, newAvatar)); StartCoroutine(InitializeLocation(newAvatar, newPosition, heading)); // Return GameObject. return(newAvatar); }
public DynamicCharacterAvatar CreateCharacter(CharacterDataHolder characterData, float posX, float posY, float posZ) { // Setting race on Instantiate, because even we set it at CustomizeCharacterAppearance, we could not mount items for female characters. DynamicCharacterAvatar newAvatar = Instantiate(characterData.GetRace() == 0 ? avatarMale : avatarFemale, new Vector3(posX, posY, posZ), Quaternion.identity) as DynamicCharacterAvatar; newAvatar.BuildCharacter(); // Prevent UMA bone error. // Add a new Capsule Collider to prevent falling. CapsuleCollider capsuleCollider = newAvatar.gameObject.AddComponent <CapsuleCollider>(); capsuleCollider.radius = 0.15f; capsuleCollider.height = 1.71f; capsuleCollider.center = new Vector3(0, 0.82f, 0); // Customize character. StartCoroutine(CustomizeCharacterAppearance(characterData, newAvatar)); // Add AudioSource. newAvatar.gameObject.AddComponent <AudioSource>(); // Disable avatar until race customization ends. newAvatar.gameObject.SetActive(false); // Return GameObject. return(newAvatar); }
private void CharacterEquipment_OnInventoryChanged(ItemsContainer obj) { if (avatar) { avatar.ClearSlots(); avatar.BuildCharacter(); } foreach (var item in obj.items) { ItemData itemData = ItemsManager.Instance.GetItemData(item.Value.id); if (itemData != null) { EquipItemVisual(itemData); } } }
public override void Use() { DynamicCharacterAvatar avatar = EventSystem.Objects.Player.GetComponentInChildren <ModularClothingProxy>().CharacterAvatar; ApplyClothing(avatar); avatar.BuildCharacter(); Debug.Log("Clothing Applied."); }
public void UpdateCharacterEquip(EquipmentSlot slot, EquippableItem item) { for (int i = 0; i < equipmentSlots.Length; i++) { if (item.recipe == null) { Debug.Log("No Wardrobe Recipe: " + item.ItemName); return; } else { player.SetSlot(equipmentSlots[i].EquipmentType.ToString(), item.recipe.name); //_player.SetSlot(equipmentSlots[i].EquipmentType.ToString(), item.femaleRecipe.name); player.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 IEnumerator CustomizeCharacterAppearance(CharacterDataHolder characterData, DynamicCharacterAvatar newAvatar) { // Hide avatar until delay ends. newAvatar.gameObject.SetActive(false); // Unfortunately UMA needs a small delay to initialize. yield return(new WaitForSeconds(0.25f)); // Delay ended. Show avatar. newAvatar.gameObject.SetActive(true); // Customize character. int hairType = characterData.GetHairType(); if (characterData.GetRace() == 0) { newAvatar.ChangeRace("HumanMaleDCS"); if (hairType != 0) { newAvatar.SetSlot("Hair", _hairModelsMale[characterData.GetHairType()]); } } if (characterData.GetRace() == 1) { newAvatar.ChangeRace("HumanFemaleDCS"); if (hairType != 0) { newAvatar.SetSlot("Hair", _hairModelsFemale[characterData.GetHairType()]); } } // Set colors. newAvatar.SetColor("Hair", Util.IntToColor(characterData.GetHairColor())); newAvatar.SetColor("Skin", Util.IntToColor(characterData.GetSkinColor())); newAvatar.SetColor("Eyes", Util.IntToColor(characterData.GetEyeColor())); newAvatar.UpdateColors(true); Dictionary <string, DnaSetter> dna = newAvatar.GetDNA(); dna["height"].Set(characterData.GetHeight()); dna["belly"].Set(characterData.GetBelly()); newAvatar.BuildCharacter(false); // Set visible equipable armor items. EquipItem(newAvatar, characterData.GetHeadItem()); EquipItem(newAvatar, characterData.GetChestItem()); EquipItem(newAvatar, characterData.GetLegsItem()); EquipItem(newAvatar, characterData.GetHandsItem()); EquipItem(newAvatar, characterData.GetFeetItem()); // Without this delay, sometimes, we cannot not see mounted weapons. yield return(new WaitForSeconds(0.25f)); // Set visible equipable left and right hand items. EquipItem(newAvatar, characterData.GetLeftHandItem()); EquipItem(newAvatar, characterData.GetRightHandItem()); }
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); }
private void Update() { if (RenderersEnabled != lastState) { if (avatar.hide) { return; } lastState = RenderersEnabled; avatar.BuildCharacter(); } }
void Start() { ClientManager.CharacterSelection(); var Characters = ClientManager.CharacterSelection().Characters; foreach (var chars in Characters) { // CharButton.text = chars.CharName; var charname = chars.CharName; var umdata = chars.UmaData; GameObject button = (GameObject)Instantiate(buttonPrefab); button.transform.SetParent(panelToAttachButtonsTo.transform);//Setting button parent button.GetComponent <Button>().onClick.AddListener(() => { // // characterAvatar.LoadDNAFromRecipeString(chars.UmaData); // // characterAvatar.LoadFromRecipeString(chars.UmaData.ToString()); // characterAvatar.LoadColorsFromRecipeString(umdata); // // characterAvatar.ImportSettings(UMATextRecipe.PackedLoadDCS(characterAvatar.context, umdata)); characterAvatar.LoadFromRecipeString(umdata, DynamicCharacterAvatar.LoadOptions.useDefaults); characterAvatar.BuildCharacter(); }); //Setting what button does when clicked //Next line assumes button has child with text as first gameobject like button created from GameObject->UI->Button button.transform.GetChild(0).GetComponent <Text>().text = charname; //Changing text } characterAvatar.CharacterUpdated.AddListener(OnCharacterUpdated); characterAvatar.CharacterCreated.AddListener(OnCharacterCreated); // ToDO CharButtons per Script anlegen.. // ToDO UMA Dynamic CharacterAvatar Laden // TODO WorldServer Button // var canvas = GameObject.FindObjectsOfType(typeof(ScrollView)).Cast<Canvas>().FirstOrDefault((c) => c.name == "CharacterList"); //foreach (string str in CharacterList) //{ // //GameObject go = Instantiate(Button_Template) as GameObject; // //go.SetActive(true); // //Tutorial_Button TB = go.GetComponent<Tutorial_Button>(); // //TB.SetName(str); // //go.transform.SetParent(Button_Template.transform.parent); //} ////GameObject canvas = GameObject.Find("CharacterSelection"); //charbtn.text = packgeData1.CharName; //var characterButton = GameObject.Find("CharacterButton"); //characterButton.SetActive(true); //characterButton.GetComponent<Text>().text = packgeData1.CharName; // var characterButton = GameObject.Find("CharacterButton"); // GameObject ScrollView = GameObject.FindObjectOfType<ScrollView>() }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { bool dcaUpdated = false; DynamicCharacterAvatar avatar = playerData as DynamicCharacterAvatar; if (avatar == null) { return; } if (!isAdded) { isAdded = true; dcaUpdated = true; if (wardrobeOption == UmaWardrobeBehaviour.WardrobeOptions.AddRecipes) { if (recipesToAdd != null) { foreach (UMAWardrobeRecipe recipe in recipesToAdd) { avatar.SetSlot(recipe); dcaUpdated = true; } } else { if (Debug.isDebugBuild) { Debug.LogWarning("Wardrobe recipes not set!"); } } } if (wardrobeOption == UmaWardrobeBehaviour.WardrobeOptions.ClearSlots) { avatar.ClearSlots(slotsToClear); dcaUpdated = true; } if (wardrobeOption == UmaWardrobeBehaviour.WardrobeOptions.ClearAllSlots) { avatar.ClearSlots(); dcaUpdated = true; } } if (dcaUpdated && rebuildImmediately) { avatar.BuildCharacter(true, !avatar.BundleCheck); } }
void Awake() { if (PhotonNetwork.connected) { imageTarget = GameObject.FindWithTag("ImageTarget").transform; transform.parent = imageTarget; DynamicCharacterAvatar loadedAvatar = GetComponent <DynamicCharacterAvatar>(); string myRecipe = (string)photonView.instantiationData[0]; loadedAvatar.LoadFromRecipeString(myRecipe); loadedAvatar.BuildCharacter(); } }
//EquipedConsumable////////////////////////////////// //EquipedArmor/////////////////////////////////////// public void EquipArmor(GameObject item, ArmorType armorType) //MUST UNEQUIP BEFORE EQUIPPING IF NOT NULL { ItemMaster tempMaster = item.GetComponent <ItemMaster>(); int itemSubArray = (int)tempMaster.ReturnItemType(); Armor armorScript = item.GetComponent <Armor>(); UnEquipArmor(armorType); EquippedArmor[(int)armorType] = item; InventoryStorage[itemSubArray][tempMaster.ReturnItemName()].Remove(item); playerStats.AddAttributeEffect(AttributesEnum.armor, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], true, armorScript.returnArmor()); //second entry is name e.g. "Head" playerStats.AddAttributeEffect(AttributesEnum.plating, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], true, armorScript.returnPlating()); //second entry is name e.g. "Head" playerStats.AddAttributeEffect(AttributesEnum.stamina_regen, STARTUP_DECLARATIONS.ArmorTypeEnumReverse[(int)armorType], false, armorScript.returnEEnergyRegenModifier()); // UMA Component playerAvatar.SetSlot(armorScript.GetWardrobePiece().Item1); if (armorScript.GetWardrobePiece().Item2) { playerAvatar.SetSlot(armorScript.GetWardrobePiece().Item2); } playerAvatar.BuildCharacter(); }
public void GenerateRandomCharacter(Vector3 Pos, Quaternion Rot, string Name) { if (prefab) { GameObject go = GameObject.Instantiate(prefab, Pos, Rot); if (ParentObject != null) { go.transform.parent = ParentObject.transform; } RandomAvatar = go.GetComponent <DynamicCharacterAvatar>(); go.name = Name; } Randomize(RandomAvatar); RandomAvatar.BuildCharacter(); }
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 LoadCharacterForPlay() { if (SelectedCharacterName != "") { myRecipe = File.ReadAllText(Application.persistentDataPath + "/characterSaves/" + SelectedCharacterName + ".txt"); if (PhotonNetwork.connected) { loadedCharacter = PhotonNetwork.Instantiate("New Character Prefab", loadedCharacterPrefab.transform.position, loadedCharacterPrefab.transform.rotation, 0, new object[] { myRecipe }); Debug.Log(loadedCharacter); } else { loadedCharacter = Instantiate(loadedCharacterPrefab); loadedCharacter.name = SelectedCharacterName; DynamicCharacterAvatar loadedAvatar = loadedCharacter.GetComponent <DynamicCharacterAvatar>(); loadedAvatar.LoadFromRecipeString(myRecipe); loadedAvatar.BuildCharacter(); foreach (GameObject t in UDTEH.targets) { if (t.name == UDTEH.SelectedTarget) { TargetToSetAsParent = t; } } loadedCharacter.transform.parent = TargetToSetAsParent.transform; if (loadedCharacter.transform.parent == null) { Debug.Log(imageTarget.name); //open up the placer menu and let them set the character to load onto a image target //change the accessor for place button to work after adding fx here } float xyz = (loadedCharacter.transform.localScale.x * imageTarget.localScale.x) / 10; loadedCharacter.transform.localScale = new Vector3(xyz, xyz, xyz); } charactersDictionary.Add(loadedCharacter, myRecipe); characters.Add(loadedCharacter); } }
public void GenerateRandomCharacter(Vector3 Pos, Quaternion Rot, string Name) { if (prefab) { GameObject go = GameObject.Instantiate(prefab, Pos, Rot); if (ParentObject != null) { go.transform.parent = ParentObject.transform; } RandomAvatar = go.GetComponent <DynamicCharacterAvatar>(); go.name = Name; // Event for possible networking here if (RandomAvatarGenerated != null) { RandomAvatarGenerated.Invoke(gameObject, go); } } Randomize(RandomAvatar); RandomAvatar.BuildCharacter(!RandomAvatar.BundleCheck); }
/// <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 PreloadDNA() { Avatar.predefinedDNA = new UMAPredefinedDNA(); Avatar.predefinedDNA.AddDNA("feetSize", 1.0f); Avatar.BuildCharacter(false); }
public void ClearChest() { character.ClearSlot("Chest"); character.BuildCharacter(); }