예제 #1
0
        /// <summary>
        /// Get a field from a script and set this value in a hero object list.
        /// </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 SetFieldOnHero(FieldInfo field, HeroActionParams actionParams, HeroActionField actionFieldB)
        {
            // Get value on the target instance.
            object value = field.FieldType;

            // Test value type.
            if (value == typeof(int))
            {
                GetIntegerField.BuildFieldB(field.Name + " (Int): ", actionParams, actionFieldB);
            }
            else if (value == typeof(float))
            {
                GetFloatField.BuildFieldB(field.Name + " (Float): ", actionParams, actionFieldB);
            }
            else if (value == typeof(string))
            {
                GetStringField.BuildFieldB(field.Name + " (String): ", actionParams, actionFieldB);
            }
            else if (value == typeof(bool))
            {
                GetBoolField.BuildFieldB(field.Name + " (Bool): ", actionParams, actionFieldB);
            }
            else if (value == typeof(HeroKitObject))
            {
                GetHeroObjectField.BuildFieldB(field.Name + " (HeroObject): ", actionParams, actionFieldB);
            }
            else if (value == typeof(GameObject))
            {
                GetGameObjectField.BuildFieldB(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]");
            }
        }
예제 #2
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]");
            }
        }