Exemplo n.º 1
0
        private void equipWeapon(SlotCategory slotCategory, Weapon weapon)
        {
            PartSlot slot = this.slots.GetSlot(slotCategory);

            if (slot == null)
            {
                return;
            }

            resetWeaponRenderer(slot);
            if (weapon == null)
            {
                slot.assignedPart = null;
                return;
            }

            Dictionary <string, string> links = new Dictionary <string, string>();

            switch (slotCategory)
            {
            case SlotCategory.MainHand:
                if (weapon.weaponCategory == WeaponCategory.OneHanded ||
                    weapon.weaponCategory == WeaponCategory.TwoHanded ||
                    weapon.weaponCategory == WeaponCategory.Gun ||
                    weapon.weaponCategory == WeaponCategory.Rifle)
                {
                    links = SetupData.rWeaponLink;
                }
                break;

            case SlotCategory.OffHand:
                if (weapon.weaponCategory == WeaponCategory.Bow)
                {
                    links = SetupData.bowLink;
                }
                else if (weapon.weaponCategory == WeaponCategory.Shield)
                {
                    links = SetupData.shieldLink;
                }
                else if (weapon.weaponCategory == WeaponCategory.OneHanded ||
                         weapon.weaponCategory == WeaponCategory.Gun)
                {
                    links = SetupData.lWeaponLink;
                }
                break;

            default:
                break;
            }

            slot.assignedPart = weapon;
            if (slot.material != null)
            {
                slot.material.SetTexture("_ColorMask", weapon.colorMask);
            }
            foreach (Sprite s in weapon.sprites)
            {
                this.transform.Find(links[s.name]).GetComponent <SpriteRenderer>().sprite = s;
            }
            if (SetupData.colorableSpriteLinks.ContainsKey(slotCategory))
            {
                SetPartColor(slotCategory, ColorCode.Color1, slot.color1);
            }
            Transform muzzlefx = null;

            if (slotCategory == SlotCategory.MainHand)
            {
                muzzlefx = this.transform.Find(SetupData.muzzleFXLinks[SlotCategory.MainHand]);
            }
            if (slotCategory == SlotCategory.OffHand)
            {
                muzzlefx = this.transform.Find(SetupData.muzzleFXLinks[SlotCategory.OffHand]);
            }
            muzzlefx.localPosition = weapon.muzzlePosition;
        }
Exemplo n.º 2
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.Eyebrow || slotCategory == SlotCategory.Eyes || slotCategory == SlotCategory.Nose || slotCategory == SlotCategory.Mouth || slotCategory == SlotCategory.Ear)
            {
                equipPart(slotCategory, part);
                if (!isEmoting && !isEmotingAnimationEvent)
                {
                    getDefaultEmote();
                }
            }
            else
            {
                equipPart(slotCategory, part);
            }
        }