Ejemplo n.º 1
0
        /// <summary>
        /// Assign/unassign part to/from desired slot of this CharacterViewer.
        /// </summary>
        /// <param name="slotCategory">Desired SlotCategory.</param>
        /// <param name="part">Desired Part. Will unassigned if 'null'.</param>
        public void EquipPart(SlotCategory slotCategory, Part part)
        {
            //..find alternative if part doesn't support this character body type
            if (part != null && !part.supportedBody.Contains(this.bodyType))
            {
                Part altpart = getAlternatePart(part);
                if (altpart == null)
                {
                    Debug.Log(String.Format("part '{0}' on slot category '{1}'  doesn't support body type {2}",
                                            part, slotCategory, this.bodyType));
                }
                else
                {
                    Debug.Log(String.Format("part '{0}' on slot category '{1}'  doesn't support body type {2}. it will be replaced with {3}",
                                            part, slotCategory, this.bodyType, altpart.name));
                }
                part = altpart;
            }

            if (slotCategory == SlotCategory.MainHand)
            {
                Weapon mainweapon = (Weapon)part;
                Weapon offweapon  = (Weapon)this.slots.GetSlot(SlotCategory.OffHand).assignedPart;
                if (mainweapon != null && mainweapon.weaponCategory == WeaponCategory.TwoHanded)
                {
                    equipWeapon(SlotCategory.OffHand, null);
                }
                else if (mainweapon != null && offweapon != null && offweapon.weaponCategory == WeaponCategory.Bow)
                {
                    equipWeapon(SlotCategory.OffHand, null);
                }
                else if (mainweapon != null && mainweapon.weaponCategory == WeaponCategory.Rifle)
                {
                    equipWeapon(SlotCategory.OffHand, null);
                }
                equipWeapon(SlotCategory.MainHand, mainweapon);
            }
            else if (slotCategory == SlotCategory.OffHand)
            {
                Weapon mainweapon = (Weapon)this.slots.GetSlot(SlotCategory.MainHand).assignedPart;
                Weapon offweapon  = (Weapon)part;
                if (offweapon != null && offweapon.weaponCategory == WeaponCategory.Bow)
                {
                    equipWeapon(SlotCategory.MainHand, null);
                }
                else if (offweapon != null && mainweapon != null && mainweapon.weaponCategory == WeaponCategory.TwoHanded)
                {
                    equipWeapon(SlotCategory.MainHand, null);
                }
                else if (offweapon != null && mainweapon != null && mainweapon.weaponCategory == WeaponCategory.Rifle)
                {
                    equipWeapon(SlotCategory.MainHand, null);
                }
                equipWeapon(SlotCategory.OffHand, offweapon);
            }
            else if (slotCategory == SlotCategory.SkinDetails)
            {
                equipSkinDetails(part);
            }
            else if (slotCategory == SlotCategory.Cape)
            {
                equipCape(part);
            }
            else if (slotCategory == SlotCategory.Skirt)
            {
                equipSkirt(part);
            }
            else if (slotCategory == SlotCategory.Eyebrow || slotCategory == SlotCategory.Eyes || slotCategory == SlotCategory.Nose || slotCategory == SlotCategory.Mouth || slotCategory == SlotCategory.Ear)
            {
                equipPart(slotCategory, part);
                if (!isEmoting && !isEmotingAnimationEvent)
                {
                    getDefaultEmote();
                }
            }
            else
            {
                equipPart(slotCategory, part);
            }
        }
Ejemplo n.º 2
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)
        {
            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..
        }