Exemple #1
0
        /// <summary>
        /// Get a value from a hero object list that will be assigned to a parameter in a script.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldIDB">ID assigned to action field B.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns>The value from the hero object list.</returns>
        public static System.Object GetParameter(HeroKitObject heroKitObject, int actionFieldIDB, ParameterInfo parameter)
        {
            // Get value on the target instance.
            object value = parameter.ParameterType;

            System.Object item = null;

            // Test value type.
            if (value == typeof(int))
            {
                item = IntegerFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }
            else if (value == typeof(float))
            {
                item = FloatFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }
            else if (value == typeof(string))
            {
                item = StringFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }
            else if (value == typeof(bool))
            {
                item = BoolFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }
            else if (value == typeof(HeroKitObject))
            {
                item = HeroObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB)[0];
            }
            else if (value == typeof(GameObject))
            {
                item = GameObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }

            return(item);
        }
Exemple #2
0
        // --------------------------------------------------------------
        // Helpers
        // --------------------------------------------------------------

        /// <summary>
        /// Get a value from a hero object list and set this value for a field in a script.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldIDB">ID assigned to action field B.</param>
        /// <param name="field">The field in the script.</param>
        /// <param name="component">The script component on the hero kit object.</param>
        private static void SetFieldOnScript(HeroKitObject heroKitObject, int actionFieldIDB, FieldInfo field, MonoBehaviour component)
        {
            // Get value on the target instance.
            object value = field.FieldType;

            // Test value type.
            if (value == typeof(int))
            {
                int newValue = IntegerFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                field.SetValue(component, newValue);
            }
            else if (value == typeof(float))
            {
                float newValue = FloatFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                field.SetValue(component, newValue);
            }
            else if (value == typeof(string))
            {
                string newValue = StringFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                field.SetValue(component, newValue);
            }
            else if (value == typeof(bool))
            {
                bool newValue = BoolFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                field.SetValue(component, newValue);
            }
            else if (value == typeof(HeroKitObject))
            {
                HeroKitObject newValue = HeroObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB)[0];
                field.SetValue(component, newValue);
            }
            else if (value == typeof(GameObject))
            {
                GameObject newValue = GameObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                field.SetValue(component, newValue);
            }
        }
Exemple #3
0
        /// <summary>
        /// Get a value from a hero object list and set this value for a property in a script.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldIDB">ID assigned to action field B.</param>
        /// <param name="property">The property in the script.</param>
        /// <param name="component">The script component on the hero kit object.</param>
        public static void SetPropertyOnScript(HeroKitObject heroKitObject, int actionFieldIDB, PropertyInfo property, MonoBehaviour component)
        {
            // Get value on the target instance.
            object value = property.PropertyType;

            // Test value type.
            if (value == typeof(int))
            {
                int newValue = IntegerFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                property.SetValue(component, newValue, null);
            }
            else if (value == typeof(float))
            {
                float newValue = FloatFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                property.SetValue(component, newValue, null);
            }
            else if (value == typeof(string))
            {
                string newValue = StringFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                property.SetValue(component, newValue, null);
            }
            else if (value == typeof(bool))
            {
                bool newValue = BoolFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                property.SetValue(component, newValue, null);
            }
            else if (value == typeof(HeroKitObject))
            {
                HeroKitObject newValue = HeroObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB)[0];
                property.SetValue(component, newValue, null);
            }
            else if (value == typeof(GameObject))
            {
                GameObject newValue = GameObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB);
                property.SetValue(component, newValue, null);
            }
        }