예제 #1
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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }