Пример #1
0
        /// <summary>
        /// Fields for the hero property (floats).
        /// </summary>
        private static void DrawFloats()
        {
            List <FloatField> items = propertyBlock.itemProperties.floats.items;

            // exit early if there are no values
            if (items == null || items.Count == 0)
            {
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.Label(items[i].name + ":");
                items[i].value = SimpleLayout.FloatField(items[i].value, HeroKitCommon.GetWidthForField(60, 150));
            }
            SimpleLayout.EndVertical();
        }
Пример #2
0
        // --------------------------------------------------------------
        // Action Fields
        // --------------------------------------------------------------

        /// <summary>
        /// Get a value from a float field.
        /// This is for a field that contains Value, Variable, Property, Global.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        public static void BuildFieldA(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false, SliderData sliderData = new SliderData())
        {
            // create the fields
            FloatFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }

            //-----------------------------------------
            // Get the type of field you want to work with.
            //-----------------------------------------
            data.fieldType = new HeroField.ValueTypeField().SetValues(data.fieldType, 0);

            //-----------------------------------------
            // Get the type of game object we are working with
            // Option 1: This game object (game object that this hero object is attached to)
            // Option 2: Another game object (another game object in the scene that has a hero object attached to it)
            //-----------------------------------------
            if (data.fieldType == 2 || data.fieldType == 3)
            {
                data = ActionCommon.GetTargetHeroObject(data);
            }

            //-----------------------------------------
            // Get the float list you want to work with.
            // The float list is in hero object editor > Variables
            //-----------------------------------------

            // if this is a field, draw field (1=number)
            if (data.fieldType == 1)
            {
                data.fieldValue = SimpleLayout.FloatField(data.fieldValue, 149);
            }

            // if this is a list, draw floats (2=floats, 3=properties)
            if (data.fieldType != 1)
            {
                data = SetPropertyID(data, -1);
                List <FloatField> items = GetItemsFromList(data, -1);
                data = BuildItemFieldList(data, items);
            }


            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.ints[0]        = data.objectType;
            actionField.ints[1]        = data.objectID;
            actionField.ints[2]        = data.fieldID;
            actionField.ints[3]        = data.fieldType;
            actionField.ints[4]        = data.heroGUID;
            actionField.ints[7]        = data.propertyID;
            actionField.heroObjects[0] = data.targetHeroObject;
            actionField.strings[0]     = data.objectName;
            actionField.floats[0]      = data.fieldValue;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();
        }