예제 #1
0
        /// <summary>
        /// Get a child game object.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionFieldA">Action field parameters.</param>
        /// <param name="actionFieldB">Action field parameters.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, bool titleToLeft = false, int rightOffset = 0)
        {
            bool useChild = GetBoolValue.BuildField(title, actionParams, actionFieldA, true);

            if (useChild)
            {
                GetStringField.BuildFieldA("Name of the child object:", actionParams, actionFieldB, titleToLeft, false, rightOffset);
            }
        }
예제 #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="field">The field to set.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionFieldB">Action field.</param>
        private static void SetFieldOnScript(FieldInfo field, HeroActionParams actionParams, HeroActionField actionFieldB)
        {
            // Get value on the target instance.
            object value = field.FieldType;

            // Test value type.
            if (value == typeof(int))
            {
                GetIntegerField.BuildFieldA(field.Name + " (Int): ", actionParams, actionFieldB);
            }
            else if (value == typeof(float))
            {
                GetFloatField.BuildFieldA(field.Name + " (Float): ", actionParams, actionFieldB);
            }
            else if (value == typeof(string))
            {
                GetStringField.BuildFieldA(field.Name + " (String): ", actionParams, actionFieldB);
            }
            else if (value == typeof(bool))
            {
                GetBoolField.BuildFieldA(field.Name + " (Bool): ", actionParams, actionFieldB);
            }
            else if (value == typeof(HeroKitObject))
            {
                GetHeroObjectField.BuildFieldA(field.Name + " (HeroObject): ", actionParams, actionFieldB);
            }
            else if (value == typeof(GameObject))
            {
                GetGameObjectField.BuildFieldA(field.Name + " (GameObject): ", actionParams, actionFieldB);
            }
            else
            {
                string valueType = value.ToString();
                int    index     = valueType.LastIndexOf('.');
                if (valueType.Length >= 2)
                {
                    valueType = valueType.Substring(index + 1, valueType.Length - index - 1);
                }

                SimpleLayout.Label(valueType + " " + field.Name + ": [Value can't be stored by HeroKit]");
            }
        }
예제 #3
0
        /// <summary>
        /// Create a field in the hero kit editor for a parameter.
        /// </summary>
        /// <param name="param">The parameter.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionFieldB">Action field.</param>
        /// <param name="setHeroValue">True=user can set a value on a hero object. False=user can set a value in a script.</param>
        private static void GetParameter(ParameterInfo param, HeroActionParams actionParams, HeroActionField actionFieldB, bool setHeroValue)
        {
            // Get value on the target instance.
            object value = param.ParameterType;

            // Test value type.
            if (value == typeof(int))
            {
                if (!setHeroValue)
                {
                    GetIntegerField.BuildFieldA(param.Name + " (Int): ", actionParams, actionFieldB);
                }
                else
                {
                    GetIntegerField.BuildFieldB(param.Name + " (Int): ", actionParams, actionFieldB);
                }
            }
            else if (value == typeof(float))
            {
                if (!setHeroValue)
                {
                    GetFloatField.BuildFieldA(param.Name + " (Float): ", actionParams, actionFieldB);
                }
                else
                {
                    GetFloatField.BuildFieldB(param.Name + " (Float): ", actionParams, actionFieldB);
                }
            }
            else if (value == typeof(string))
            {
                if (!setHeroValue)
                {
                    GetStringField.BuildFieldA(param.Name + " (String): ", actionParams, actionFieldB, false, false, -10);
                }
                else
                {
                    GetStringField.BuildFieldB(param.Name + " (String): ", actionParams, actionFieldB);
                }
            }
            else if (value == typeof(bool))
            {
                if (!setHeroValue)
                {
                    GetBoolField.BuildFieldA(param.Name + " (Bool): ", actionParams, actionFieldB);
                }
                else
                {
                    GetBoolField.BuildFieldB(param.Name + " (Bool): ", actionParams, actionFieldB);
                }
            }
            else if (value == typeof(HeroKitObject))
            {
                if (!setHeroValue)
                {
                    GetHeroObjectField.BuildFieldA(param.Name + " (HeroObject): ", actionParams, actionFieldB);
                }
                else
                {
                    GetHeroObjectField.BuildFieldB(param.Name + " (HeroObject): ", actionParams, actionFieldB);
                }
            }
            else if (value == typeof(GameObject))
            {
                if (!setHeroValue)
                {
                    GetGameObjectField.BuildFieldA(param.Name + " (GameObject): ", actionParams, actionFieldB);
                }
                else
                {
                    GetGameObjectField.BuildFieldB(param.Name + " (GameObject): ", actionParams, actionFieldB);
                }
            }
            else
            {
                string valueType = value.ToString();
                int    index     = valueType.LastIndexOf('.');
                if (valueType.Length >= 2)
                {
                    valueType = valueType.Substring(index + 1, valueType.Length - index - 1);
                }

                SimpleLayout.Label(valueType + " " + param.Name + ": [Value can't be stored by HeroKit]");
            }
        }