Esempio n. 1
0
    private void DefineSlots(UMACrowdRandomSet.CrowdRaceData race)
    {
        Color skinColor;
        Color HairColor;
        Color Shine = Color.black;

        if (SkinColors != null)
        {
            OverlayColorData ocd = SkinColors.colors[Random.Range(0, SkinColors.colors.Length)];

            skinColor = ocd.color;
            Shine     = ocd.channelAdditiveMask[2];
        }
        else
        {
            float skinTone = Random.Range(0.1f, 0.6f);
            skinColor = new Color(skinTone + Random.Range(0.35f, 0.4f), skinTone + Random.Range(0.25f, 0.4f), skinTone + Random.Range(0.35f, 0.4f), 1);
        }
        if (HairColors != null)
        {
            HairColor = HairColors.colors[Random.Range(0, HairColors.colors.Length)].color;
        }
        else
        {
            HairColor = new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1.0f);
        }

        var keywordsLookup = new HashSet <string>(keywords);

        UMACrowdRandomSet.Apply(umaData, race, skinColor, HairColor, Shine, keywordsLookup, GetSlotLibrary(), GetOverlayLibrary());
    }
Esempio n. 2
0
	private void DefineSlots(UMACrowdRandomSet.CrowdRaceData race)
	{
		float skinTone = Random.Range(0.1f, 0.6f);
		Color skinColor = new Color(skinTone + Random.Range(0.35f, 0.4f), skinTone + Random.Range(0.25f, 0.4f), skinTone + Random.Range(0.35f, 0.4f), 1);
		Color HairColor = new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.5f));
		var keywordsLookup = new HashSet<string>(keywords);
		UMACrowdRandomSet.Apply(umaData, race, skinColor, HairColor, keywordsLookup, GetSlotLibrary(), GetOverlayLibrary());
	}
Esempio n. 3
0
 private void DefineSlots(UMACrowdRandomSet.CrowdRaceData race)
 {
     float skinTone = Random.Range(0.1f, 0.6f);
     Color skinColor = new Color(skinTone + Random.Range(0.35f, 0.4f), skinTone + Random.Range(0.25f, 0.4f), skinTone + Random.Range(0.35f, 0.4f), 1);
     Color HairColor = new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1);
     var slotParts = new HashSet<string>();
     umaData.umaRecipe.slotDataList = new SlotData[race.slotElements.Length];
     for (int i = 0; i < race.slotElements.Length; i++)
     {
         var currentElement = race.slotElements[i];
         if (!string.IsNullOrEmpty(currentElement.requirement) && !slotParts.Contains(currentElement.requirement)) continue;
         if (currentElement.possibleSlots.Length == 0) continue;
         int randomResult = Random.Range(0, currentElement.possibleSlots.Length);
         var slot = currentElement.possibleSlots[randomResult];
         if (string.IsNullOrEmpty(slot.slotID)) continue;
         slotParts.Add(slot.slotID);
         SlotData slotData;
         if (slot.useSharedOverlayList && slot.overlayListSource >= 0 && slot.overlayListSource < i)
         {
             slotData = slotLibrary.InstantiateSlot(slot.slotID, umaData.umaRecipe.slotDataList[slot.overlayListSource].GetOverlayList());
         }
         else
         {
             if (slot.useSharedOverlayList)
             {
                 Debug.LogError("UMA Crowd: Invalid overlayListSource for " + slot.slotID);
             }
             slotData = slotLibrary.InstantiateSlot(slot.slotID);
         }
         umaData.umaRecipe.slotDataList[i] = slotData;
         for (int overlayIdx = 0; overlayIdx < slot.overlayElements.Length; overlayIdx++)
         {
             var currentOverlayElement = slot.overlayElements[overlayIdx];
             randomResult = Random.Range(0, currentOverlayElement.possibleOverlays.Length);
             var overlay = currentOverlayElement.possibleOverlays[randomResult];
             if (string.IsNullOrEmpty(overlay.overlayID)) continue;
             slotParts.Add(overlay.overlayID);
             Color overlayColor;
             if (overlay.useSkinColor)
             {
                 overlayColor = skinColor + new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1);
             }
             else if (overlay.useHairColor)
             {
                 overlayColor = HairColor * overlay.hairColorMultiplier;
             }
             else
             {
                 overlayColor = new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1);
             }
             slotData.AddOverlay(overlayLibrary.InstantiateOverlay(overlay.overlayID, overlayColor));
         }
         if (umaData.umaRecipe.slotDataList[i].GetOverlayList().Count == 0)
         {
             Debug.LogError("Slot without overlay: " + umaData.umaRecipe.slotDataList[i].slotName+" at index "+i+" of race: "+race.raceID);
         }
     }
 }
Esempio n. 4
0
    private void DefineSlots(UMACrowdRandomSet.CrowdRaceData race)
    {
        float skinTone       = Random.Range(0.1f, 0.6f);
        Color skinColor      = new Color(skinTone + Random.Range(0.35f, 0.4f), skinTone + Random.Range(0.25f, 0.4f), skinTone + Random.Range(0.35f, 0.4f), 1);
        Color HairColor      = new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.5f));
        var   keywordsLookup = new HashSet <string>(keywords);

        UMACrowdRandomSet.Apply(umaData, race, skinColor, HairColor, keywordsLookup, slotLibrary, overlayLibrary);
    }
Esempio n. 5
0
		public virtual void AddToLibraries(OverlayLibraryBase overlayLibrary, SlotLibraryBase slotLibrary, RaceLibraryBase raceLibrary, UMACrowd crowd)
		{
			if (overlayLibrary != null && overlayData.Length > 0)
			{
#if UNITY_EDITOR
				UnityEditor.Undo.RecordObject(overlayLibrary, "Added Asset Collection");
#endif
				for (int i = 0; i < overlayData.Length; i++)
				{
					overlayLibrary.AddOverlay(overlayData[i]);
				}
			}
			if (slotLibrary != null && slotData.Length > 0)
			{
#if UNITY_EDITOR
				UnityEditor.Undo.RecordObject(slotLibrary, "Added Asset Collection");
#endif
				for (int i = 0; i < slotData.Length; i++)
				{
					slotLibrary.AddSlot(slotData[i]);
				}

			}
			if (raceLibrary != null && raceData.Length > 0) 
			{
#if UNITY_EDITOR
				UnityEditor.Undo.RecordObject(raceLibrary, "Added Asset Collection");
#endif
				for (int i = 0; i < raceData.Length; i++)
				{
					raceLibrary.AddRace(raceData[i]);
				}
			}

			if (crowd != null && randomSets.Length > 0)
			{
#if UNITY_EDITOR
				UnityEditor.Undo.RecordObject(crowd, "Added Asset Collection");
#endif
				var newPool = new UMACrowdRandomSet[crowd.randomPool.Length + randomSets.Length];
				Array.Copy(crowd.randomPool, newPool, crowd.randomPool.Length);
				for (int i = 0; i < randomSets.Length; i++)
				{
					newPool[crowd.randomPool.Length + i] = randomSets[i];
				}
			}
		}
Esempio n. 6
0
        public virtual void AddToLibraries(OverlayLibraryBase overlayLibrary, SlotLibraryBase slotLibrary, RaceLibraryBase raceLibrary, UMACrowd crowd)
        {
            if (overlayLibrary != null && overlayData.Length > 0)
            {
#if UNITY_EDITOR
                UnityEditor.Undo.RecordObject(overlayLibrary, "Added Asset Collection");
#endif
                for (int i = 0; i < overlayData.Length; i++)
                {
                    overlayLibrary.AddOverlay(overlayData[i]);
                }
            }
            if (slotLibrary != null && slotData.Length > 0)
            {
#if UNITY_EDITOR
                UnityEditor.Undo.RecordObject(slotLibrary, "Added Asset Collection");
#endif
                for (int i = 0; i < slotData.Length; i++)
                {
                    slotLibrary.AddSlot(slotData[i]);
                }
            }
            if (raceLibrary != null && raceData.Length > 0)
            {
#if UNITY_EDITOR
                UnityEditor.Undo.RecordObject(raceLibrary, "Added Asset Collection");
#endif
                for (int i = 0; i < raceData.Length; i++)
                {
                    raceLibrary.AddRace(raceData[i]);
                }
            }

            if (crowd != null && randomSets.Length > 0)
            {
#if UNITY_EDITOR
                UnityEditor.Undo.RecordObject(crowd, "Added Asset Collection");
#endif
                var newPool = new UMACrowdRandomSet[crowd.randomPool.Length + randomSets.Length];
                Array.Copy(crowd.randomPool, newPool, crowd.randomPool.Length);
                for (int i = 0; i < randomSets.Length; i++)
                {
                    newPool[crowd.randomPool.Length + i] = randomSets[i];
                }
            }
        }
    private UMACrowdRandomSet.CrowdSlotData SlotDataFromSet(UMACrowdRandomSet set, string slotid)
    {
        foreach(UMACrowdRandomSet.CrowdSlotElement crowdElement in set.data.slotElements)
        {
            if (crowdElement != null)
            {
                foreach(UMACrowdRandomSet.CrowdSlotData slotData in crowdElement.possibleSlots)
                {
                    if (slotData != null && slotData.slotID == slotid)
                        return slotData;
                }
            }
        }

        return null;
    }
    private UMACrowdRandomSet.CrowdOverlayData OverlayDataFromSlot(UMACrowdRandomSet.CrowdSlotData slot, string overlayid)
    {
        foreach(UMACrowdRandomSet.CrowdOverlayElement overlayElement in slot.overlayElements)
        {
            if (overlayElement != null)
            {
                foreach(UMACrowdRandomSet.CrowdOverlayData overlayData in overlayElement.possibleOverlays)
                {
                    if (overlayData != null && overlayData.overlayID == overlayid)
                        return overlayData;
                }
            }
        }

        return null;
    }