public static void DeserializeCharacterData_UMA(IPlayerCharacterData characterData, NetDataReader reader)
        {
            UmaAvatarData umaAvatarData = new UmaAvatarData();

            umaAvatarData.Deserialize(reader);
            characterData.UmaAvatarData = umaAvatarData;
        }
コード例 #2
0
        protected void OnUmaAvatarDataChange(bool isInit, UmaAvatarData avatarData)
        {
            CharacterModelUMA characterModelUma = CharacterModel as CharacterModelUMA;

            if (characterModelUma == null)
            {
                return;
            }
            characterModelUma.ApplyUmaAvatar(avatarData);
        }
コード例 #3
0
        public UmaAvatarData GetAvatarData()
        {
            UmaAvatarData result = new UmaAvatarData();

            result.raceIndex   = SelectedRaceIndex;
            result.genderIndex = SelectedGenderIndex;
            result.slots       = SelectedSlots;
            result.colors      = SelectedColors;
            result.dnas        = SelectedDnas;
            return(result);
        }
コード例 #4
0
        public void SetObjectData_UMA(object obj,
                                      SerializationInfo info,
                                      StreamingContext context,
                                      ISurrogateSelector selector)
        {
            PlayerCharacterData data          = (PlayerCharacterData)obj;
            UmaAvatarData       umaAvatarData = new UmaAvatarData();

            umaAvatarData.SetBytes(info.GetListValue <byte>("UmaAvatarData"));
            data.UmaAvatarData = umaAvatarData;
        }
コード例 #5
0
 protected void OnUmaAvatarDataChange(bool isInit, UmaAvatarData avatarData)
 {
     if (CharacterModel is AnimatorCharacterModelUMA)
     {
         AnimatorCharacterModelUMA animatorCharacterModelUma = CharacterModel as AnimatorCharacterModelUMA;
         if (animatorCharacterModelUma == null)
         {
             return;
         }
         animatorCharacterModelUma.ApplyUmaAvatar(avatarData);
     }
 }
コード例 #6
0
 public void ApplyUmaAvatar(UmaAvatarData avatarData)
 {
     if (CacheUmaAvatar == null)
     {
         Debug.LogWarning("[CharacterModelUMA] Uma avatar or applier is empty, cannot change avatar appearances");
         return;
     }
     InitializeUMA();
     if (!IsUmaCharacterCreated)
     {
         applyingAvatarData = avatarData;
         return;
     }
     if (applyCoroutine != null)
     {
         StopCoroutine(applyCoroutine);
     }
     applyCoroutine = StartCoroutine(ApplyUmaAvatarRoutine(avatarData));
 }
コード例 #7
0
        IEnumerator ApplyUmaAvatarRoutine(UmaAvatarData avatarData)
        {
            int           i;
            UmaRace       race   = CurrentGameInstance.UmaRaces[avatarData.raceIndex];
            UmaRaceGender gender = race.genders[avatarData.genderIndex];

            CacheUmaAvatar.ChangeRace(gender.raceData.raceName);
            yield return(null);

            // Set character hair, beard, eyebrows (or other things up to your settings)
            if (avatarData.slots != null)
            {
                Dictionary <string, List <UMATextRecipe> > recipes = CacheUmaAvatar.AvailableRecipes;
                string slotName;
                for (i = 0; i < gender.customizableSlots.Length; ++i)
                {
                    if (i >= avatarData.slots.Length)
                    {
                        break;
                    }
                    slotName = gender.customizableSlots[i].name;
                    CacheUmaAvatar.SetSlot(recipes[slotName][avatarData.slots[i]]);
                }
            }
            // Set skin color, eyes color, hair color (or other things up to your settings)
            if (avatarData.colors != null)
            {
                SharedColorTable colorTable;
                for (i = 0; i < race.colorTables.Length; ++i)
                {
                    if (i >= avatarData.colors.Length)
                    {
                        break;
                    }
                    colorTable = race.colorTables[i];
                    CacheUmaAvatar.SetColor(colorTable.sharedColorName, colorTable.colors[avatarData.colors[i]]);
                }
            }
            // Set equip items if it is already set
            if (tempEquipWeapons != null)
            {
                SetEquipWeapons(tempEquipWeapons);
            }
            if (tempEquipItems != null)
            {
                SetEquipItems(tempEquipItems);
            }

            // Update avatar
            CacheUmaAvatar.BuildCharacter(true);
            CacheUmaAvatar.ForceUpdate(true, true, true);
            yield return(null);

            // Set character dna
            if (avatarData.dnas != null)
            {
                Dictionary <string, DnaSetter> dnas = null;
                while (dnas == null || dnas.Count == 0)
                {
                    dnas = CacheUmaAvatar.GetDNA();
                    yield return(null);
                }
                List <string> dnaNames = new List <string>(dnas.Keys);
                dnaNames.Sort();
                string dnaName;
                for (i = 0; i < dnaNames.Count; ++i)
                {
                    if (i >= avatarData.dnas.Length)
                    {
                        break;
                    }
                    dnaName = dnaNames[i];
                    dnas[dnaName].Set(avatarData.dnas[i] * 0.01f);
                }
            }
            // Update avatar after set dna
            CacheUmaAvatar.ForceUpdate(true, false, false);
        }