예제 #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);
        }
예제 #2
0
        /// <summary>
        /// Creates a resource category header for critters.
        /// </summary>
        /// <param name="type">The critter type to create.</param>
        /// <returns>The heading for that critter type.</returns>
        private CritterResourceRowGroup Create(CritterType type)
        {
            var spawn = Util.KInstantiateUI(allResources.categoryLinePrefab, allResources.
                                            rootListContainer, true);

            // Create a heading for Critter (Type)
            PUtil.LogDebug("Creating Critter ({0}) category".F(type.GetProperName()));
            var refs = spawn.GetComponent <HierarchyReferences>();
            // Set up chart
            var graphBase = refs.GetReference <SparkLayer>("Chart").GetComponent <GraphBase>();

            graphBase.axis_x.min_value       = 0f;
            graphBase.axis_x.max_value       = 600f;
            graphBase.axis_x.guide_frequency = 120f;
            graphBase.RefreshGuides();
            // Component which actually handles updating
            var rg = spawn.AddComponent <CritterResourceRowGroup>();

            rg.CritterType = type;
            refs.GetReference <LocText>("NameLabel").SetText(rg.Title);
            return(rg);
        }
 /// <summary>
 /// Gets the proper, localized heading for a critter resource entry.
 /// </summary>
 /// <param name="species">The critter species.</param>
 /// <param name="type">The critter domestication type.</param>
 /// <returns>The title for that entry.</returns>
 internal static string GetTitle(Tag species, CritterType type)
 {
     return(string.Format("{0} ({1})", species.ProperNameStripLink(), type.
                          GetProperName()));
 }