Esempio n. 1
0
        /// <summary>
        /// Change character facial expression/emote then reset to default face after a period of time.
        /// </summary>
        /// <param name="emotionType">target emotion.</param>
        /// <param name="duration">the duration of the emotion before resetting back to default.</param>
        public void Emote(EmotionType emotionType, float duration)
        {
            EmoteIndex i = emotes.getIndex(emotionType);

            if (isEmotingAnimationEvent)
            {
                updateAnimEmote(-1);
            }
            emote(i, duration, false);
        }
Esempio n. 2
0
        /// <summary>
        /// Reset character facial expression/emote into its default face.
        /// </summary>
        public void ResetEmote()
        {
            EmoteIndex i = defaultEmote;

            EquipPart(SlotCategory.Eyebrow, i.eyebrowPart);
            EquipPart(SlotCategory.Eyes, i.eyesPart);
            EquipPart(SlotCategory.Nose, i.nosePart);
            EquipPart(SlotCategory.Mouth, i.mouthPart);
            EquipPart(SlotCategory.Ear, i.earPart);
            isEmoting = false;
        }
Esempio n. 3
0
 private void emote(EmoteIndex i, float duration, bool isAnimation)
 {
     CancelInvoke("ResetEmote");
     isEmoting = !isAnimation;
     if (i.eyebrowPart != null)
     {
         EquipPart(SlotCategory.Eyebrow, i.eyebrowPart);
     }
     else
     {
         EquipPart(SlotCategory.Eyebrow, defaultEmote.eyebrowPart);
     }
     if (i.eyesPart != null)
     {
         EquipPart(SlotCategory.Eyes, i.eyesPart);
     }
     else
     {
         EquipPart(SlotCategory.Eyes, defaultEmote.eyesPart);
     }
     if (i.nosePart != null)
     {
         EquipPart(SlotCategory.Nose, i.nosePart);
     }
     else
     {
         EquipPart(SlotCategory.Nose, defaultEmote.nosePart);
     }
     if (i.mouthPart != null)
     {
         EquipPart(SlotCategory.Mouth, i.mouthPart);
     }
     else
     {
         EquipPart(SlotCategory.Mouth, defaultEmote.mouthPart);
     }
     if (i.earPart != null)
     {
         EquipPart(SlotCategory.Ear, i.earPart);
     }
     else
     {
         EquipPart(SlotCategory.Ear, defaultEmote.earPart);
     }
     if (duration > 0)
     {
         Invoke("ResetEmote", duration);
     }
 }
Esempio n. 4
0
        private void updateAnimEmote(float i)
        {
            int index = (int)i;

            if (index >= 0)
            {
                ResetEmote();
                isEmotingAnimationEvent = true;
                EmoteIndex e = emotes.getIndex((EmotionType)index);
                emote(e, 0f, true);
            }
            else
            {
                ResetEmote();
                isEmotingAnimationEvent = false;
            }
            _currentEmoteAnimIndex = emoteAnimIndex;
        }
Esempio n. 5
0
        /// <summary>
        /// Change character facial expression/emote then reset to default face after a period of time.
        /// </summary>
        /// <param name="emotionName">target emotion name.</param>
        /// <param name="duration">the duration of the emotion before resetting back to default.</param>
        public void Emote(string emotionName, float duration)
        {
            EmoteIndex i = null;

            foreach (EmotionType emotionType in Enum.GetValues(typeof(EmotionType)))
            {
                EmoteIndex e = emotes.getIndex(emotionType);
                if (e.name == emotionName)
                {
                    i = e;
                    break;
                }
            }
            if (i == null)
            {
                Debug.LogError("Emotion not found: " + emotionName);
                return;
            }
            if (isEmotingAnimationEvent)
            {
                updateAnimEmote(-1);
            }
            emote(i, duration, false);
        }
Esempio n. 6
0
        /// <summary>
        /// Assign and initialize this CharacterViewer according to a given CharacterData.
        /// </summary>
        /// <param name="data">CharacterData to be assigned from.</param>
        public void AssignCharacterData(CharacterData data)
        {
            //data version exception..
            if (data.dataVersion < 1)
            {
                data.slotData.Add(new PartSlotData()
                {
                    category    = SlotCategory.BodySkin,
                    partName    = data.bodyType == BodyType.Male ? "Base 00 Male" : "Base 00 Female",
                    partPackage = "Base"
                });
            }
            //..data version exception

            this.bodyType = data.bodyType;
            _skincolor    = data.skinColor;
            _tintcolor    = data.tintColor;

            Initialize();
            foreach (SlotCategory cat in Enum.GetValues(typeof(SlotCategory)))
            {
                PartSlot     slot     = this.slots.GetSlot(cat);
                PartSlotData slotdata = data.slotData.Find(x => x.category == cat);
                if (slot == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(slotdata.partName))
                {
                    EquipPart(cat, (Part)null);
                    continue;
                }

                Part part = PartList.Static.FindPart(slotdata.partName, slotdata.partPackage, cat);
                if (part == null)
                {
                    continue;
                }

                EquipPart(cat, part);
                SetPartColor(cat, ColorCode.Color1, slotdata.color1);
                SetPartColor(cat, ColorCode.Color2, slotdata.color2);
                SetPartColor(cat, ColorCode.Color3, slotdata.color3);
            }

            if (data.emoteData != null || data.emoteData.Count > 0)
            {
                foreach (EmotionType emotionType in Enum.GetValues(typeof(EmotionType)))
                {
                    EmoteIndex     e     = emotes.getIndex(emotionType);
                    EmoteIndexData edata = data.emoteData.Find(x => x.emotionType == emotionType);
                    if (e == null)
                    {
                        continue;
                    }
                    if (emotionType >= EmotionType.Blink && String.IsNullOrEmpty(edata.emotionName))
                    {
                        continue;
                    }
                    e.name = edata.emotionName;
                    if (string.IsNullOrEmpty(edata.eyebrowPartName))
                    {
                        e.eyebrowPart = null;
                    }
                    else
                    {
                        e.eyebrowPart = PartList.Static.FindPart(edata.eyebrowPartName, edata.eyebrowPackage, SlotCategory.Eyebrow);
                    }
                    if (string.IsNullOrEmpty(edata.eyesPartName))
                    {
                        e.eyesPart = null;
                    }
                    else
                    {
                        e.eyesPart = PartList.Static.FindPart(edata.eyesPartName, edata.eyesPackage, SlotCategory.Eyes);
                    }
                    if (string.IsNullOrEmpty(edata.nosePartName))
                    {
                        e.nosePart = null;
                    }
                    else
                    {
                        e.nosePart = PartList.Static.FindPart(edata.nosePartName, edata.nosePackage, SlotCategory.Nose);
                    }
                    if (string.IsNullOrEmpty(edata.mouthPartName))
                    {
                        e.mouthPart = null;
                    }
                    else
                    {
                        e.mouthPart = PartList.Static.FindPart(edata.mouthPartName, edata.mouthPackage, SlotCategory.Mouth);
                    }
                    if (string.IsNullOrEmpty(edata.earPartName))
                    {
                        e.earPart = null;
                    }
                    else
                    {
                        e.earPart = PartList.Static.FindPart(edata.earPartName, edata.earPackage, SlotCategory.Ear);
                    }
                }
            }

            //..update
            if (data.bodySegmentData == null || data.bodySegmentData.Count <= 0)
            {
                foreach (SegmentType st in Enum.GetValues(typeof(SegmentType)))
                {
                    SetBodySlider(st, new Vector2(0.5f, 0.5f));
                }
            }
            else
            {
                foreach (SegmentScaleData sd in data.bodySegmentData)
                {
                    SetBodySlider(sd.segmentType, sd.scale);
                }
            }
            //update..
        }
Esempio n. 7
0
        /// <summary>
        /// Generate CharacterData of CharacterViewer.
        /// </summary>
        /// <returns>Generated CharacterData of CharacterViewer.</returns>
        public CharacterData GenerateCharacterData()
        {
            CharacterData val = new CharacterData();

            val.dataVersion = setupData.dataVersion;
            val.bodyType    = this.bodyType;
            val.skinColor   = _skincolor;
            val.tintColor   = _tintcolor;

            val.slotData = new List <PartSlotData>();
            foreach (SlotCategory cat in Enum.GetValues(typeof(SlotCategory)))
            {
                PartSlot slot = this.slots.GetSlot(cat);
                val.slotData.Add(new PartSlotData()
                {
                    category    = cat,
                    partName    = slot.assignedPart == null ? "" : slot.assignedPart.name,
                    partPackage = slot.assignedPart == null ? "" : slot.assignedPart.packageName,
                    color1      = slot.color1,
                    color2      = slot.color2,
                    color3      = slot.color3
                });
            }

            val.emoteData = new List <EmoteIndexData>();
            foreach (EmotionType emotionType in Enum.GetValues(typeof(EmotionType)))
            {
                EmoteIndex e = emotes.getIndex(emotionType);
                if (e == null)
                {
                    continue;
                }
                if (emotionType >= EmotionType.Blink && String.IsNullOrEmpty(e.name))
                {
                    continue;
                }
                else
                {
                    val.emoteData.Add(new EmoteIndexData()
                    {
                        emotionType     = emotionType,
                        emotionName     = String.IsNullOrEmpty(e.name) ? "" : e.name,
                        eyebrowPartName = e.eyebrowPart == null ? "" : e.eyebrowPart.name,
                        eyebrowPackage  = e.eyebrowPart == null ? "" : e.eyebrowPart.packageName,
                        eyesPartName    = e.eyesPart == null ? "" : e.eyesPart.name,
                        eyesPackage     = e.eyesPart == null ? "" : e.eyesPart.packageName,
                        nosePartName    = e.nosePart == null ? "" : e.nosePart.name,
                        nosePackage     = e.nosePart == null ? "" : e.nosePart.packageName,
                        mouthPartName   = e.mouthPart == null ? "" : e.mouthPart.name,
                        mouthPackage    = e.mouthPart == null ? "" : e.mouthPart.packageName,
                        earPartName     = e.earPart == null ? "" : e.earPart.name,
                        earPackage      = e.earPart == null ? "" : e.earPart.packageName
                    });
                }
            }

            //..update
            val.bodySegmentData = new List <SegmentScaleData>();
            foreach (SegmentType stype in Enum.GetValues(typeof(SegmentType)))
            {
                Vector2 scale = GetBodySlider(stype);
                val.bodySegmentData.Add(new SegmentScaleData()
                {
                    segmentType = stype,
                    scale       = new Vector2(scale.x, scale.y)
                });
            }
            //update..

            return(val);
        }