Exemple #1
0
        /// <summary>
        /// Get a value from a property in a script and save this value on a hero kit object.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionFieldA">Action field.</param>
        /// <param name="actionFieldB">Action field.</param>
        /// <param name="script">The script.</param>
        public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, MonoScript script)
        {
            // create the fields
            PropertyFieldData data = CreateFieldData(title, actionFieldA, actionParams.heroObject);

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

            //-----------------------------------------
            // Get the list you want to work with.
            //-----------------------------------------
            PropertyInfo[] properties = GetPropertiesFromScript(script);
            data = BuildItemFieldList(data, properties);

            if (properties != null && properties.Length != 0 && data.fieldID > 0)
            {
                PropertyInfo property = properties[data.fieldID - 1];
                SetPropertyOnScript(property, actionParams, actionFieldB);
            }

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionFieldA.ints[0] = data.fieldID;
        }
Exemple #2
0
        // --------------------------------------------------------------
        // Initialize Action Field
        // --------------------------------------------------------------

        /// <summary>
        /// Create the subfields that we need for this action field.
        /// </summary>
        /// <param name="title">The title of the action.</param>
        /// <param name="actionField">The action field.</param>
        /// <param name="heroObject">The hero object that contains this action field.</param>
        /// <returns>The data for this action field.</returns>
        public static PropertyFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject)
        {
            PropertyFieldData data = new PropertyFieldData();

            data.Init(ref actionField);
            data.title   = title;
            data.fieldID = actionField.ints[0];
            data.startID = actionField.ints[1];
            data.endID   = actionField.ints[2];
            return(data);
        }
Exemple #3
0
        /// <summary>
        /// Create a drop-down list of script properties in the action field.
        /// </summary>
        /// <param name="data">Current data for this action field.</param>
        /// <param name="items">A list of properties in a script.</param>
        /// <returns>The data for this action field.</returns>
        private static PropertyFieldData BuildItemFieldList(PropertyFieldData data, PropertyInfo[] items)
        {
            // hero object does not exist on game object or int list is empty
            if (items.Length == 0)
            {
                data.fieldID = 0;
            }
            // everything looks okay. draw int list.
            else
            {
                // if we are referencing a field that no longer exists in int list, reset condition int field
                if (items.Length < data.fieldID)
                {
                    data.fieldID = 0;
                }

                // draw the list
                data.fieldID = HeroField.PropertyListField.SetValues(items, data.fieldID, 0);
            }

            return(data);
        }
Exemple #4
0
        /// <summary>
        /// Set a property in a script.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="propertyFieldStart">Action field (range start).</param>
        /// <param name="propertyFieldEnd">Action field (range stop).</param>
        /// <param name="script">The script.</param>
        /// <param name="heroAction">The hero action.</param>
        public static void BuildFieldA(string title, HeroActionParams actionParams, HeroActionField actionField, int propertyFieldStart, int propertyFieldEnd, MonoScript script, HeroAction heroAction)
        {
            // create the fields
            PropertyFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

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

            //-----------------------------------------
            // Get the list you want to work with.
            //-----------------------------------------
            PropertyInfo[] properties             = GetProperties(script);
            int            availablePropertySlots = propertyFieldEnd - propertyFieldStart;

            if (properties != null && properties.Length != 0)
            {
                SimpleLayout.BeginVertical(Box.StyleB);
                for (int i = 0; i < properties.Length && i < availablePropertySlots; i++)
                {
                    PropertyInfo property = properties[i];
                    SetPropertyOnScript(property, actionParams, heroAction.actionFields[propertyFieldStart + i]);
                }
                SimpleLayout.EndVertical();
            }

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.ints[1] = propertyFieldStart;
            actionField.ints[2] = propertyFieldEnd;
        }