/// <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();
        }
Esempio n. 2
0
        private void spawnItem(BodyType bodyType, Part bodySkin, Transform itemParent)
        {
            Part assignedpart = CreatorUI.character.GetAssignedPart(SlotCategory.BodySkin);

            if (bodySkin == null) //spawn NULL
            {
                BodyTypeItem partitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemParent);
                partitem.Initialize(bodyType, null);
                if (CreatorUI.character.bodyType == bodyType && assignedpart == null)
                {
                    selectedItem = partitem;
                    if (this.gameObject.activeInHierarchy)
                    {
                        StopCoroutine("ie_initselected");
                        StartCoroutine("ie_initselected", selectedItem);
                    }
                }
            }
            else
            {
                BodyTypeItem partitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemParent);
                partitem.Initialize(bodyType, bodySkin);
                if (CreatorUI.character.bodyType == bodyType && assignedpart == bodySkin)
                {
                    selectedItem = partitem;
                    if (this.gameObject.activeInHierarchy)
                    {
                        StopCoroutine("ie_initselected");
                        StartCoroutine("ie_initselected", selectedItem);
                    }
                }
            }
        }
        /// <summary>
        /// Updates selectedItem to a given value and updates UICreator's character body type.
        /// </summary>
        /// <param name="item">BodyTypeItem to be selected.</param>
        public void SelectItem(BodyTypeItem item)
        {
            selectedItem          = item;
            selectionObj.position = item.transform.position;

            if (CreatorUI.character.bodyType != item.bodyType)
            {
                CreatorUI.character.SetBodyType(item.bodyType);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Updates selectedItem to a given value and updates UICreator's character body type.
        /// </summary>
        /// <param name="item">BodyTypeItem to be selected.</param>
        public void SelectItem(BodyTypeItem item)
        {
            selectedItem = item;
            selectionObj.gameObject.SetActive(true);
            selectionObj.position = item.transform.position;

            if (CreatorUI.character.bodyType != item.bodyType)
            {
                CreatorUI.character.SetBodyType(item.bodyType);
            }

            Part skin = CreatorUI.character.GetAssignedPart(SlotCategory.BodySkin);

            if (skin != item.bodySkin)
            {
                CreatorUI.character.EquipPart(SlotCategory.BodySkin, item.bodySkin);
            }
        }
        IEnumerator ie_initselected(BodyTypeItem item)
        {
            yield return(null);

            SelectItem(item);
        }