/// <summary> /// Returns PartSlot of a given SlotCategory. /// </summary> /// <param name="slotCategory">Given SlotCategory.</param> /// <returns>PartSlot according to slotCategory.</returns> public PartSlot GetSlot(SlotCategory slotCategory) { switch (slotCategory) { case SlotCategory.Armor: return(this.armor); case SlotCategory.Boots: return(this.boots); case SlotCategory.Ear: return(this.ear); case SlotCategory.Eyebrow: return(this.eyebrow); case SlotCategory.Eyes: return(this.eyes); case SlotCategory.FacialHair: return(this.facialHair); case SlotCategory.Gloves: return(this.gloves); case SlotCategory.Hair: return(this.hair); case SlotCategory.Helmet: return(this.helmet); case SlotCategory.Mouth: return(this.mouth); case SlotCategory.Nose: return(this.nose); case SlotCategory.Pants: return(this.pants); case SlotCategory.SkinDetails: return(this.skinDetails); case SlotCategory.MainHand: return(this.mainHand); case SlotCategory.OffHand: return(this.offHand); case SlotCategory.Cape: return(this.cape); case SlotCategory.Skirt: return(this.skirts); default: return(null); } }
/// <summary> /// Randomize character's part. /// </summary> public void RandomizePart(SlotCategory slotCategory) { if (_availparts == null || _availparts.Count <= 0) { _availparts = getAvailableParts(new List <string>()); } character.EquipPart(slotCategory, _availparts[slotCategory][Random.Range(0, _availparts[slotCategory].Count)]); }
/// <summary> /// Returns the assigned part of a given SlotCategory. Returns 'null' if there is no part assigned. /// </summary> /// <param name="category">Given SlotCategory.</param> /// <returns>Assigned part of the given SlotCategory if there is any, otherwise returns 'null'.</returns> public Part GetAssignedPart(SlotCategory category) { PartSlot slot = this.slots.GetSlot(category); if (slot == null) { return(null); } return(slot.assignedPart); }
public void OpenPartMenu(string title, SlotCategory slotCategory) { OpenMenu(title); if (uipartcolor == null) { uipartcolor = findMenu("Parts Color").GetComponent <UIPartColor>(); } uipartcolor.Initialize(slotCategory); uipartcolor.gameObject.SetActive(true); }
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); } }
/// <summary> /// Find a Part from this PartList's partPacks. /// </summary> /// <param name="partName"></param> /// <param name="partPackage"></param> /// <param name="slotCategory"></param> /// <returns>May returns 'null' if there is no Part found.</returns> public Part FindPart(string partName, string partPackage, SlotCategory slotCategory) { if (slotCategory == SlotCategory.MainHand || slotCategory == SlotCategory.OffHand) { return(FindPart(partName, partPackage, PartCategory.Weapon)); } else { return(FindPart(partName, partPackage, (PartCategory)slotCategory)); } }
/// <summary> /// Randomize color of character's part /// </summary> public void RandomizeColor(SlotCategory slotCategory) { List <SlotCategory> excludedCategory = new List <SlotCategory>(); foreach (SlotCategory c in System.Enum.GetValues(typeof(SlotCategory))) { if (c != slotCategory) { excludedCategory.Add(c); } } RandomizeColor(excludedCategory.ToArray()); }
private List <Part> findWeapons(SlotCategory slotCategory) { if (slotCategory < SlotCategory.MainHand) { return(new List <Part>()); } List <Part> val = new List <Part>(); foreach (PartPack pack in this.partPacks) { if (pack.category != PartCategory.Weapon) { continue; } foreach (Part part in pack.parts) { Weapon weapon = (Weapon)part; if (weapon == null) { continue; } if (slotCategory == SlotCategory.MainHand) { if (weapon.weaponCategory == WeaponCategory.OneHanded || weapon.weaponCategory == WeaponCategory.TwoHanded || weapon.weaponCategory == WeaponCategory.Gun || weapon.weaponCategory == WeaponCategory.Rifle) { val.Add(weapon); } } else if (slotCategory == SlotCategory.OffHand) { if (weapon.weaponCategory == WeaponCategory.OneHanded || weapon.weaponCategory == WeaponCategory.Shield || weapon.weaponCategory == WeaponCategory.Bow || weapon.weaponCategory == WeaponCategory.Gun) { val.Add(weapon); } } } break; } return(val); }
public void setPart(SlotCategory slot, Part part) { switch (slot) { case (SlotCategory.Eyebrow): this.eyebrowPart = part == null ? null : part; break; case (SlotCategory.Eyes): this.eyesPart = part == null ? null : part; break; case (SlotCategory.Nose): this.nosePart = part == null ? null : part; break; case (SlotCategory.Mouth): this.mouthPart = part == null ? null : part; break; case (SlotCategory.Ear): this.earPart = part == null ? null : part; break; } }
/// <summary> /// Find Parts from PartList's partPacks. /// </summary> /// <param name="slotCategory">Desired SlotCategory</param> /// <returns>Returns all Parts supported on a PartSlot of a given SlotCategory.</returns> public List <Part> FindParts(SlotCategory slotCategory) { if (slotCategory == SlotCategory.MainHand) { return(findWeapons(SlotCategory.MainHand)); } else if (slotCategory == SlotCategory.OffHand) { return(findWeapons(SlotCategory.OffHand)); } else { return(FindParts((PartCategory)slotCategory)); } }
/// <summary> /// Modifies Part's Color. /// </summary> /// <param name="slotCategory">Desired SlotCategory.</param> /// <param name="colorCode">Represent the desired color order of the part. Use 'CharacterCreator2D.ColorCode'.</param> /// <param name="color">Desired value of the color.</param> public void SetPartColor(SlotCategory slotCategory, string colorCode, Color color) { if (slotCategory == SlotCategory.MainHand || slotCategory == SlotCategory.OffHand) { setWeaponColor(slotCategory, colorCode, color); } else if (slotCategory == SlotCategory.SkinDetails) { setSkinDetailsColor(color); } else { setPartColor(slotCategory, colorCode, color); } }
private void setWeaponColor(SlotCategory slotCategory, string colorCode, Color color) { if (colorCode == ColorCode.Color1) { if (slotCategory == SlotCategory.MainHand) { this.transform.Find(SetupData.weaponFXLinks[SlotCategory.MainHand]).GetComponent <SpriteRenderer>().color = color; } else if (slotCategory == SlotCategory.OffHand) { this.transform.Find(SetupData.weaponFXLinks[SlotCategory.OffHand]).GetComponent <SpriteRenderer>().color = color; } } setPartColor(slotCategory, colorCode, color); }
public Part getPart(SlotCategory slot) { switch (slot) { case (SlotCategory.Eyebrow): return(this.eyebrowPart); case (SlotCategory.Eyes): return(this.eyesPart); case (SlotCategory.Nose): return(this.nosePart); case (SlotCategory.Mouth): return(this.mouthPart); case (SlotCategory.Ear): return(this.earPart); default: return(null); } }
/// <summary> /// Assign/unassign part to/from desired slot of this CharacterViewer. /// </summary> /// <param name="slotCategory">Desired SlotCategory.</param> /// <param name="partName">The name of the part. Will unassign if 'null' or 'empty'.</param> /// <param name="partPackage">The package name of the part. Will assign the first part found if 'null' or 'empty'</param> public void EquipPart(SlotCategory slotCategory, string partName, string partPackage) { if (string.IsNullOrEmpty(partName)) { EquipPart(slotCategory, (Part)null); return; } Part part = PartList.Static.FindPart(partName, partPackage, slotCategory); if (part == null) { Debug.Log("can't find part: " + partName); return; } EquipPart(slotCategory, part); }
/// <summary> /// Initialize UIPartColor according to SlotCategory value. /// </summary> /// <param name="slotCategory">SlotCategory value.</param> public void Initialize(SlotCategory slotCategory) { if (_uicreator == null) { _uicreator = this.transform.GetComponentInParent <UICreator>(); } this.slotCategory = slotCategory; if (_uicreator.character.slots.GetSlot(slotCategory).material == null) { this.mode = UIPartColorMode.Uncolorable; } else if (SetupData.colorableSpriteLinks.ContainsKey(slotCategory) || slotCategory == SlotCategory.SkinDetails) { this.mode = UIPartColorMode.OneColor; } else { this.mode = UIPartColorMode.ThreeColor; } }
/// <summary> /// Randomize character's weapon. /// </summary> public void RandomizeWeapon(SlotCategory slotCategory, WeaponCategory weaponCategory) { if (_availparts == null || _availparts.Count <= 0) { _availparts = getAvailableParts(new List <string>()); } List <Part> weaponlist = new List <Part>(); foreach (Part p in _availparts[slotCategory]) { if (p is Weapon) { Weapon w = (Weapon)p; if (w.weaponCategory == weaponCategory) { weaponlist.Add(w); } } } character.EquipPart(slotCategory, weaponlist[Random.Range(0, weaponlist.Count)]); }
private void setPartColor(SlotCategory slotCategory, string colorCode, Color color) { PartSlot slot = this.slots.GetSlot(slotCategory); if (SetupData.colorableSpriteLinks.ContainsKey(slotCategory)) { List <string> links = SetupData.colorableSpriteLinks[slotCategory]; foreach (string l in links) { this.transform.Find(l).GetComponent <SpriteRenderer>().color = color; } slot.color1 = slot.color2 = slot.color3 = color; return; } if (slot == null || slot.material == null) { return; } slot.material.SetColor(colorCode, color); switch (colorCode) { case ColorCode.Color1: slot.color1 = color; break; case ColorCode.Color2: slot.color2 = color; break; case ColorCode.Color3: slot.color3 = color; break; default: break; } }
/// <summary> /// Returns Part's Color from desired PartSlot. /// </summary> /// <param name="slotCategory">Desired SlotCategory</param> /// <param name="colorCode">Represent the desired color order of the part. Use 'CharacterCreator2D.ColorCode'.</param> /// <returns>Part's Color. Returns 'Color.clear' if colorCode doesn't match with any value in 'CharacterCreator2D.ColorCode'.</returns> public Color GetPartColor(SlotCategory slotCategory, string colorCode) { PartSlot slot = slots.GetSlot(slotCategory); if (slot != null) { switch (colorCode) { case ColorCode.Color1: return(slot.color1); case ColorCode.Color2: return(slot.color2); case ColorCode.Color3: return(slot.color3); default: return(Color.clear); } } return(Color.clear); }
public EquippableItem() { // This constructor is only useful when loading from a manifest. Category = SlotCategory.Skill; EquippedBehaviorAssetName = String.Empty; }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { base.Initialize(contentLoader, manifest); Category = (SlotCategory)(manifest.Properties[ManifestKeys.EQUIP_SLOT_CATEGORY]); EquippedBehaviorAssetName = (string)(manifest.Properties[ManifestKeys.EQUIPPED_BEHAVIOR_NAME]); }
/// <summary> /// Modifies Part's Color. /// </summary> /// <param name="slotCategory">Desired SlotCategory.</param> /// <param name="colorCode">Represent the desired color order of the part. Use 'CharacterCreator2D.ColorCode'.</param> /// <param name="color1">color for the 1st color slot of the equipment</param> /// <param name="color2">color for the 2nd color slot of the equipment</param> /// <param name="color3">color for the 3rd color slot of the equipment</param> public void SetPartColor(SlotCategory slotCategory, Color color1, Color color2, Color color3) { SetPartColor(slotCategory, ColorCode.Color1, color1); SetPartColor(slotCategory, ColorCode.Color2, color2); SetPartColor(slotCategory, ColorCode.Color3, color3); }
/// <summary> /// Initialize UIPartColor according to SlotCategoy value. /// </summary> /// <param name="slotCatInt">An integer value of SlotCategory.</param> public void Initialize(int slotCatInt) { SlotCategory slotcat = (SlotCategory)slotCatInt; Initialize(slotcat); }
public EquippableItem(string equippedBehaviorAssetName, SlotCategory slotCategory, string name) : base(name) { EquippedBehaviorAssetName = equippedBehaviorAssetName; Category = slotCategory; }
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; }
/// <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); } }
public EquippableItem(string equippedBehaviorAssetName, SlotCategory slotCategory, string name) : base(name) { EquippedBehaviorAssetName = equippedBehaviorAssetName; Category = slotCategory; }
/// <summary> /// Assign/unassign part to/from desired slot of this CharacterViewer. /// </summary> /// <param name="slotCategory">Desired SlotCategory.</param> /// <param name="partName">The name of the part. It will assign the first part found if there are more than one part with the same name in different packages. Will unassign if 'null' or 'empty'.</param> public void EquipPart(SlotCategory slotCategory, string partName) { EquipPart(slotCategory, partName, ""); }