Example #1
0
        private void equipSkinDetails(Part part)
        {
            if (part != null && part.category != PartCategory.SkinDetails)
            {
                return;
            }

            PartSlot slot = this.slots.GetSlot(SlotCategory.SkinDetails);

            if (slot == null)
            {
                return;
            }

            slot.assignedPart = part;
            if (slot.material != null)
            {
                if (part == null)
                {
                    slot.material.SetTexture("_Details", null);
                }
                else
                {
                    slot.material.SetTexture("_Details", part.texture);
                    ResourcesManager.ReleaseZeroReference();
                }
            }
        }
Example #2
0
        private void equipPart(SlotCategory slotCategory, Part part)
        {
            if (!SetupData.partLinks.ContainsKey(slotCategory))
            {
                return;
            }

            Dictionary <string, string> links = SetupData.partLinks[slotCategory];
            PartSlot slot = this.slots.GetSlot(slotCategory);

            if (links == null || slot == null)
            {
                return;
            }

            if (part != null && (int)slotCategory != (int)part.category)
            {
                Debug.Log("can't equip " + part.name + ". part doesn't match with slot category");
                return;
            }

            //..reset part
            foreach (string k in links.Keys)
            {
                this.transform.Find(links[k]).GetComponent <SpriteRenderer>().sprite = null;
            }

            if (part == null)
            {
                slot.assignedPart = null;
                if (SetupData.colorableSpriteLinks.ContainsKey(slotCategory))
                {
                    SetPartColor(slotCategory, ColorCode.Color1, slot.color1);
                }
                return;
            }

            slot.assignedPart = part;
            if (slot.material != null)
            {
                slot.material.SetTexture("_ColorMask", part.colorMask);
            }
            {
                foreach (Sprite s in part.sprites)
                {
                    this.transform.Find(links[s.name]).GetComponent <SpriteRenderer>().sprite = s;
                }
                ResourcesManager.ReleaseZeroReference();
            }
            if (SetupData.colorableSpriteLinks.ContainsKey(slotCategory))
            {
                SetPartColor(slotCategory, ColorCode.Color1, slot.color1);
            }
        }
Example #3
0
        private void equipSkirt(Part part)
        {
            if (part != null && part.category != PartCategory.Skirt)
            {
                return;
            }

            PartSlot slot = this.slots.GetSlot(SlotCategory.Skirt);

            if (slot == null)
            {
                return;
            }

            Transform capetransform = this.transform.Find("Root/Pos_Hip/Bone_Hip/Skirt");

            slot.assignedPart = part;
            if (part == null)
            {
                if (slot.material != null)
                {
                    slot.material.SetTexture("_MainTex", null);
                    slot.material.SetTexture("_ColorMask", null);
                }
                if (capetransform != null)
                {
                    capetransform.gameObject.SetActive(false);
                }
            }
            else
            {
                if (slot.material != null)
                {
                    slot.material.SetTexture("_MainTex", part.texture);
                    slot.material.SetTexture("_ColorMask", part.colorMask);
                    ResourcesManager.ReleaseZeroReference();
                }
                if (capetransform != null)
                {
                    capetransform.gameObject.SetActive(true);
                }
            }
        }
Example #4
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;
                }
                ResourcesManager.ReleaseZeroReference();
            }
            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;
        }