public CharacterCustomizationData GetCustomizationData() { CharacterCustomizationData data = new CharacterCustomizationData(MaterialBody.color); Dictionary <ClothingSlot, CharacterClothing> dictionary = new Dictionary <ClothingSlot, CharacterClothing>(); List <GameObject> accessoryObjects = GetAccessoryObjects(); foreach (ClothingSlot slot in ClothingObjects.Keys) { if (IsClothingSlotUsed(slot)) { GameObject clothingObj = transform.GetChild(ClothingObjects[slot]).gameObject; CharacterClothing characterClothing = new CharacterClothing(clothingObj.GetComponent <ClothingSlotScript>().ClothingIndex, clothingObj.GetComponent <Renderer>().sharedMaterial.color); dictionary.Add(slot, characterClothing); } } foreach (GameObject accObj in accessoryObjects) { CharacterAccessory charAcc = new CharacterAccessory(accObj.GetComponent <AccessoryScript>().AccessoryIndex, accObj.GetComponent <Renderer>().sharedMaterial.color); data.CurrentAccessories.Add(charAcc); } data.SetUpLists(dictionary); //TEMP: Debug.Log("GENERATE CUSTOMIZATION DATA:"); Debug.Log("Body Color: " + data.GetBodyColor().ToString()); for (int i = 0; i < data.CurrentClothing_Keys.Count; i++) { Debug.Log("*" + data.CurrentClothing_Keys[i].ToString() + "* - Clothing ID: " + data.CurrentClothing_Values[i].ClothingID.ToString() + "; Color: " + data.CurrentClothing_Values[i].GetColor().ToString()); } for (int i = 0; i < data.CurrentAccessories.Count; i++) { Debug.Log("*" + "ACC ID: " + data.CurrentAccessories[i].AccessoryID.ToString() + "; ACC Color: " + data.CurrentAccessories[i].GetColor().ToString()); } return(data); }
/// <summary> /// Sets up the characters appearance according to the specified customization data. /// </summary> /// <param name="clothingList"></param> public void SetAppearanceByData(CharacterCustomizationData customizationData) { Dictionary <ClothingSlot, CharacterClothing> clothingDictionary = customizationData.GetDictionary(); MaterialBody.color = customizationData.GetBodyColor(); UnsetAllClothing(); UnsetAllAccessories(); foreach (ClothingSlot slot in clothingDictionary.Keys) { SetClothing(clothingDictionary[slot].ClothingID); UpdateClothingColor(slot, clothingDictionary[slot].GetColor()); } foreach (CharacterAccessory accessory in customizationData.CurrentAccessories) { SetAccessory(accessory.AccessoryID); UpdateAccessoryColor(accessory.AccessoryID, accessory.GetColor()); } }