public void UpdateScale(float value) { if (_uicreator == null) { _uicreator = this.GetComponentInParent <UICreator>(); } switch (sliderType) { case BodySliderType.X: _uicreator.character.SetBodySlider(segmentType, new Vector2(value, _uicreator.character.GetBodySlider(segmentType).y)); break; case BodySliderType.Y: _uicreator.character.SetBodySlider(segmentType, new Vector2(_uicreator.character.GetBodySlider(segmentType).x, value)); break; case BodySliderType.Symmetrical: _uicreator.character.SetBodySlider(segmentType, new Vector2(value, value)); break; default: break; } }
public void ResetScale() { if (_uicreator == null) { _uicreator = this.GetComponentInParent <UICreator>(); } switch (sliderType) { case BodySliderType.X: _uicreator.character.SetBodySlider(segmentType, new Vector2(0.5f, _uicreator.character.GetBodySlider(segmentType).y)); break; case BodySliderType.Y: _uicreator.character.SetBodySlider(segmentType, new Vector2(_uicreator.character.GetBodySlider(segmentType).x, 0.5f)); break; case BodySliderType.Symmetrical: _uicreator.character.SetBodySlider(segmentType, new Vector2(0.5f, 0.5f)); break; default: break; } }
/// <summary> /// Initialize BodyTypeGroup and populate the items. /// </summary> public void Initialize() { this.CreatorUI = this.transform.GetComponentInParent <UICreator>(); if (this.CreatorUI == null) { return; } Transform itemparent = getItemParent(); Dictionary <string, List <BodyType> > bodytypes = getAvailableBodyTypes(); clearItems(); foreach (string packagename in bodytypes.Keys) { PackageItem packitem = Instantiate <PackageItem>(tPackage, itemparent); packitem.Initialize(packagename); foreach (BodyType bodytype in bodytypes[packagename]) { BodyTypeItem bodyitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemparent); bodyitem.Initialize(bodytype); if (bodytype == CreatorUI.character.bodyType) { selectedItem = bodyitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } } _bodycolors = getBodyColors(); }
/// <summary> /// Initialize BodyTypeGroup and populate the items. /// </summary> public void Initialize() { this.CreatorUI = this.transform.GetComponentInParent <UICreator>(); if (this.CreatorUI == null) { return; } Transform itemparent = getItemParent(); Dictionary <string, List <Part> > bodyskins = getAvailableBodySkins(); clearItems(); selectionObj.gameObject.SetActive(false); //..add null spawnItem(BodyType.Female, null, itemparent); spawnItem(BodyType.Male, null, itemparent); //add null.. foreach (string packagename in bodyskins.Keys) { PackageItem packitem = Instantiate <PackageItem>(tPackage, itemparent); packitem.Initialize(packagename); foreach (Part bodyskin in bodyskins[packagename]) { foreach (BodyType bodytype in bodyskin.supportedBody) { spawnItem(bodytype, bodyskin, itemparent); } } } _bodycolors = getBodyColors(); }
/// <summary> /// Initialize PartGroup and populate the items. /// </summary> public void Initialize() { this.CreatorUI = this.transform.GetComponentInParent <UICreator>(); if (this.CreatorUI == null) { return; } Transform itemparent = getItemParent(); Dictionary <string, List <Part> > parts = getAvailableParts(); Part assignedpart = this.CreatorUI.character.GetAssignedPart(slotCategory); clearItems(); selectionObj.gameObject.SetActive(false); //..add null PartItem partitem = Instantiate <PartItem>(tPartItem, itemparent); partitem.Initialize(null); if (assignedpart == null) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } //add null.. foreach (string packagename in parts.Keys) { PackageItem packitem = Instantiate <PackageItem>(tPackage, itemparent); packitem.Initialize(packagename); foreach (Part part in parts[packagename]) { partitem = Instantiate <PartItem>(tPartItem, itemparent); partitem.Initialize(part); if (part == assignedpart) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } } _partcolors = getPartColors(); }
void Start() { uicreator = GetComponentInParent <UICreator>(); mainbutton = GetComponent <Button>(); mainbutton.onClick.AddListener(OpenMenu); Button[] buttons = GetComponentsInChildren <Button>(); foreach (Button b in buttons) { if (b.name == "Randomize") { b.onClick.AddListener(Randomize); } if (b.name == "Clear") { b.onClick.AddListener(Clear); } } }
/// <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; } }
public void RandomizeScale() { if (_uicreator == null) { _uicreator = this.GetComponentInParent <UICreator>(); } float extremeDice = Random.Range(0f, 1f); float value = 0.5f; if (extremeDice > 0.85f) { value = Random.Range(0.0f, 1.0f); } else if (extremeDice > 0.5f) { value = Random.Range(0.3f, 0.7f); } else if (extremeDice > 0.15f) { value = Random.Range(0.4f, 0.6f); } switch (sliderType) { case BodySliderType.X: _uicreator.character.SetBodySlider(segmentType, new Vector2(value, _uicreator.character.GetBodySlider(segmentType).y)); break; case BodySliderType.Y: _uicreator.character.SetBodySlider(segmentType, new Vector2(_uicreator.character.GetBodySlider(segmentType).x, value)); break; case BodySliderType.Symmetrical: _uicreator.character.SetBodySlider(segmentType, new Vector2(value, value)); break; default: break; } }
public void Randomize() { List <SlotCategory> excludedparts = new List <SlotCategory>(); List <SlotCategory> excludedcolors = new List <SlotCategory>(); if (_uicreator == null) { _uicreator = this.GetComponentInParent <UICreator>(); } //randomize parts if (!bodyPartToggle.isOn) { excludedparts.AddRange(new List <SlotCategory>() { SlotCategory.SkinDetails, SlotCategory.BodySkin }); } else { _uicreator.RandomizeBody(); } if (!facePartToggle.isOn) { excludedparts.AddRange(_facecats); } if (!outfitPartToggle.isOn) { excludedparts.AddRange(_outfitcats); } if (!weaponPartToggle.isOn) { excludedparts.AddRange(_weaponcats); } if (bodySliderToggle.isOn) { _uicreator.RandomizeBodySliders(); } //randomize colors if (!bodyColorToggle.isOn) { excludedcolors.AddRange(new List <SlotCategory>() { SlotCategory.SkinDetails }); } else { _uicreator.RandomizeSkinColor(); } if (!faceColorToggle.isOn) { excludedcolors.AddRange(_facecats); } if (!outfitColorToggle.isOn) { excludedcolors.AddRange(_outfitcats); } if (!weaponColorToggle.isOn) { excludedcolors.AddRange(_weaponcats); } _uicreator.RandomizePart(excludedparts, packGroup.GetExcludedPacks()); _uicreator.RandomizeColor(excludedcolors.ToArray()); }
private void Awake() { _uicreator = this.GetComponentInParent <UICreator>(); }
void Awake() { _uicreator = this.transform.GetComponentInParent <UICreator>(); }
void Awake() { _uicreator = this.GetComponentInParent <UICreator>(); input = GetComponent <InputFieldSlider>(); input.onValueChanged.AddListener(UpdateScale); }