示例#1
0
        /// <summary>
        /// Creates a resource category header for critters.
        /// </summary>
        /// <param name="resList">The parent category screen for this header.</param>
        /// <param name="prefab">The prefab to use for creating the headers.</param>
        /// <param name="type">The critter type to create.</param>
        internal void Create(ResourceCategoryScreen resList, GameObject prefab,
                             CritterType type)
        {
            var tag = GameTags.BagableCreature;

            // Create a heading for Critter (Type)
            PUtil.LogDebug("Creating Critter ({0}) category".F(type.GetProperName()));
            var gameObject = Util.KInstantiateUI(prefab, resList.CategoryContainer.gameObject,
                                                 false);

            gameObject.name = "CategoryHeader_{0}_{1}".F(tag.Name, type.ToString());
            var header = gameObject.GetComponent <ResourceCategoryHeader>();

            header.SetTag(tag, GameUtil.MeasureUnit.quantity);
            // Tag it with a wild/tame tag
            header.gameObject.AddComponent <CritterResourceHeader>().CritterType = type;
            header.elements.LabelText.SetText(CritterInventoryUtils.GetTitle(tag, type));
            headers.Add(header);
        }
        /// <summary>
        /// Creates a resource category header for critters.
        /// </summary>
        /// <param name="resList">The parent category screen for this header.</param>
        /// <param name="prefab">The prefab to use for creating the headers.</param>
        /// <param name="type">The critter type to create.</param>
        /// <returns>The heading for that critter type.</returns>
        public static ResourceCategoryHeader Create(ResourceCategoryScreen resList,
                                                    GameObject prefab, CritterType type)
        {
            var    tag     = GameTags.BagableCreature;
            string typeStr = type.GetDescription();

            // Create a heading for Critter (Type)
            PUtil.LogDebug("Creating Critter ({0}) category".F(typeStr));
            var gameObject = Util.KInstantiateUI(prefab, resList.CategoryContainer.gameObject,
                                                 false);

            gameObject.name = "CategoryHeader_{0}_{1}".F(tag.Name, type.ToString());
            var header = gameObject.GetComponent <ResourceCategoryHeader>();

            header.SetTag(tag, GameUtil.MeasureUnit.quantity);
            // Tag it with a wild/tame tag
            header.gameObject.AddComponent <CritterResourceInfo>().CritterType = type;
            header.elements.LabelText.SetText("{0} ({1})".F(tag.ProperName(), typeStr));
            return(header);
        }