예제 #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);
        }
예제 #2
0
        /// <summary>
        /// Get a scene object from the scene object field.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldIDA">ID assigned to action field A.</param>
        /// <param name="actionFieldIDB">ID assigned to action field B.</param>
        /// <param name="includeInactive">Include inactive scene objects?</param>
        /// <returns>The scene object.</returns>
        public static SceneObjectValueData GetValue(HeroKitObject heroKitObject, int actionFieldIDA, int actionFieldIDB, bool includeInactive)
        {
            SceneObjectValueData objectData = new SceneObjectValueData();
            int dataType = DropDownListValue.GetValue(heroKitObject, actionFieldIDA);

            // object is hero object
            if (dataType == 1)
            {
                objectData.heroKitObject = HeroObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB);
            }

            // object is game object
            else if (dataType == 2)
            {
                GameObject gameObject = GameObjectFieldValue.GetValueA(heroKitObject, actionFieldIDB, includeInactive);
                objectData.gameObject = new GameObject[] { gameObject };
            }

            return(objectData);
        }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }