Пример #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, umaContext);
        }
Пример #2
0
        public void RandomizeAll()
        {
            if (generateUMA || generateLotsUMA)
            {
                Debug.LogWarning("Can't randomize while spawning.");
                return;
            }

            int childCount = gameObject.transform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                Transform        child            = gameObject.transform.GetChild(i);
                UMADynamicAvatar umaDynamicAvatar = child.gameObject.GetComponent <UMADynamicAvatar>();
                if (umaDynamicAvatar == null)
                {
                    Debug.Log("Couldn't find dynamic avatar on child: " + child.gameObject.name);
                    continue;
                }
                umaData = umaDynamicAvatar.umaData;
                var umaRecipe = umaDynamicAvatar.umaData.umaRecipe;
                UMACrowdRandomSet.CrowdRaceData race = null;

                if (randomPool != null && randomPool.Length > 0)
                {
                    int randomResult = Random.Range(0, randomPool.Length);
                    race = randomPool[randomResult].data;
                    umaRecipe.SetRace(umaContext.GetRace(race.raceID));
                }
                else
                {
                    if (Random.value < 0.5f)
                    {
                        umaRecipe.SetRace(umaContext.GetRace("HumanMaleDCS"));
                    }
                    else
                    {
                        umaRecipe.SetRace(umaContext.GetRace("HumanFemaleDCS"));
                    }
                }

                //			SetUMAData();

                if (race != null && race.slotElements.Length > 0)
                {
                    DefineSlots(race);
                }
                else
                {
                    DefineSlots();
                }

                AddAdditionalSlots();

                GenerateUMAShapes();

                if (animationController != null)
                {
                    umaDynamicAvatar.animationController = animationController;
                }
                umaDynamicAvatar.Show();
            }
        }
Пример #3
0
        public GameObject GenerateUMA(int sex, Vector3 position)
        {
            GameObject newGO = new GameObject("Generated Character");

            newGO.transform.parent   = transform;
            newGO.transform.position = position;
            newGO.transform.rotation = zeroPoint != null ? zeroPoint.rotation : transform.rotation;

            UMADynamicAvatar umaDynamicAvatar = newGO.AddComponent <UMADynamicAvatar>();

            umaDynamicAvatar.Initialize();
            umaData = umaDynamicAvatar.umaData;
            umaData.CharacterCreated      = new UMADataEvent(CharacterCreated);
            umaData.CharacterDestroyed    = new UMADataEvent(CharacterDestroyed);
            umaData.CharacterUpdated      = new UMADataEvent(CharacterUpdated);
            umaDynamicAvatar.umaGenerator = generator;
            umaData.umaGenerator          = generator;
            var umaRecipe = umaDynamicAvatar.umaData.umaRecipe;

            UMACrowdRandomSet.CrowdRaceData race = null;

            if (randomPool != null && randomPool.Length > 0)
            {
                int randomResult = Random.Range(0, randomPool.Length);
                race = randomPool[randomResult].data;
                umaRecipe.SetRace(umaContext.GetRace(race.raceID));
            }
            else
            {
                if (sex == 0)
                {
                    umaRecipe.SetRace(umaContext.GetRace("HumanMaleDCS"));
                }
                else
                {
                    umaRecipe.SetRace(umaContext.GetRace("HumanFemaleDCS"));
                }
            }

            SetUMAData();

            if (race != null && race.slotElements.Length > 0)
            {
                DefineSlots(race);
            }
            else
            {
                DefineSlots();
            }

            AddAdditionalSlots();

            GenerateUMAShapes();

            if (animationController != null)
            {
                umaDynamicAvatar.animationController = animationController;
            }
            umaDynamicAvatar.Show();

            return(newGO);
        }