Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set a value in a hero object list. Use the value of the 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>
        public static void SetParameter(HeroKitObject heroKitObject, int actionFieldIDB, System.Object parameter)
        {
            // Get value on the target instance.
            object value = parameter.GetType();

            // Test value type.
            if (value == typeof(int))
            {
                IntegerFieldValue.SetValueB(heroKitObject, actionFieldIDB, (int)parameter);
            }
            else if (value == typeof(float))
            {
                FloatFieldValue.SetValueB(heroKitObject, actionFieldIDB, (float)parameter);
            }
            else if (value == typeof(string))
            {
                StringFieldValue.SetValueB(heroKitObject, actionFieldIDB, (string)parameter);
            }
            else if (value == typeof(bool))
            {
                BoolFieldValue.SetValueB(heroKitObject, actionFieldIDB, (bool)parameter);
            }
            else if (value == typeof(HeroKitObject))
            {
                List <HeroKitObject> hko = new List <HeroKitObject>();
                hko.Add((HeroKitObject)parameter);
                HeroObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, hko);
            }
            else if (value == typeof(GameObject))
            {
                GameObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, (GameObject)parameter);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a field from a script and set this value in a hero object list.
        /// </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 SetFieldOnHero(HeroKitObject heroKitObject, int actionFieldIDB, FieldInfo field, MonoBehaviour component)
        {
            // Get value type on the target instance.
            object valueType = field.FieldType;

            // Test value type.
            if (valueType == typeof(int))
            {
                int value = (int)field.GetValue(component);
                IntegerFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(float))
            {
                float value = (float)field.GetValue(component);;
                FloatFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(string))
            {
                string value = (string)field.GetValue(component);;
                StringFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(bool))
            {
                bool value = (bool)field.GetValue(component);;
                BoolFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(HeroKitObject))
            {
                HeroKitObject        value = (HeroKitObject)field.GetValue(component);;
                List <HeroKitObject> hko   = new List <HeroKitObject>();
                hko.Add((HeroKitObject)value);
                HeroObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, hko);
            }
            else if (valueType == typeof(GameObject))
            {
                GameObject value = (GameObject)field.GetValue(component);;
                GameObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get a property from a script and set this value in a hero object list.
        /// </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 SetPropertyOnHero(HeroKitObject heroKitObject, int actionFieldIDB, PropertyInfo property, MonoBehaviour component)
        {
            // Get value type on the target instance.
            object valueType = property.PropertyType;

            // Test value type.
            if (valueType == typeof(int))
            {
                int value = (int)property.GetValue(component, null);
                IntegerFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(float))
            {
                float value = (float)property.GetValue(component, null);;
                FloatFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(string))
            {
                string value = (string)property.GetValue(component, null);;
                StringFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(bool))
            {
                bool value = (bool)property.GetValue(component, null);;
                BoolFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
            else if (valueType == typeof(HeroKitObject))
            {
                HeroKitObject        value = (HeroKitObject)property.GetValue(component, null);;
                List <HeroKitObject> hko   = new List <HeroKitObject>();
                hko.Add((HeroKitObject)value);
                HeroObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, hko);
            }
            else if (valueType == typeof(GameObject))
            {
                GameObject value = (GameObject)property.GetValue(component, null);;
                GameObjectFieldValue.SetValueB(heroKitObject, actionFieldIDB, value);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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);
            }
        }