示例#1
0
        /// <summary>
        /// Get a value from a hero object field in a hero object template.
        /// This is for a field that contains Variable, Property, Global.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="heroObject">Hero object that is the target of this action.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        public static HeroObject BuildFieldC(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false)
        {
            HeroObjectFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            else
            {
                SimpleLayout.Space(8);
            }

            //-----------------------------------------
            // Get the type of object we are working with
            // Option 1: This object (object that this hero object is attached to)
            // Option 2: Another object (another object in the scene that has a hero object attached to it)
            //-----------------------------------------
            SimpleLayout.Space(-8);
            data = ActionCommon.GetTargetHeroTemplate(data);

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.heroObjects[0] = data.targetHeroObject;
            actionField.ints[0]        = data.objectType;
            actionField.ints[1]        = data.objectID;
            actionField.ints[2]        = data.fieldID;
            actionField.ints[3]        = data.fieldType;
            actionField.ints[4]        = data.heroGUID;
            actionField.ints[5]        = data.propertyID;
            actionField.strings[0]     = data.objectName;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            return(data.targetHeroObject);
        }
        /// <summary>
        /// Set an animation controller.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="animatorController">The animation controller.</param>
        /// <param name="paramType">Animation controller parameter type.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        /// <returns>The animation controller.</returns>
        public static RuntimeAnimatorController BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionField, RuntimeAnimatorController animatorController, AnimatorControllerParameterType paramType, bool titleToLeft = false)
        {
            // create the fields
            AnimationParameterFieldData data = CreateFieldData(title, actionField);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }

            //-----------------------------------------
            // Get the animation controller we are working with
            //-----------------------------------------
            if (animatorController == null)
            {
                SimpleLayout.Space();
                SimpleLayout.EndHorizontal();
                return(null);
            }

            //-----------------------------------------
            // Get the triggers we want to work with
            //-----------------------------------------
            List <string> items = GetItemsFromList(animatorController, paramType);

            data = BuildItemFieldList(data, items);

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.ints[0]    = data.fieldID;
            actionField.strings[0] = data.fieldName;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            return(animatorController);
        }
示例#3
0
        /// <summary>
        /// Draw the body of the block.
        /// </summary>
        private static void DrawBody()
        {
            SimpleLayout.BeginVertical(Box.StyleCanvasBox);

            SimpleLayout.BeginVertical(Box.StyleB);

            SimpleLayout.Label("Action (this is used during gameplay):");
            heroAction.action = SimpleLayout.ObjectField(heroAction.action, 400);

            SimpleLayout.Label("Action (this is used to create editor fields for action):");
            heroAction.actionFields = SimpleLayout.ObjectField(heroAction.actionFields, 400);

            SimpleLayout.EndVertical();

            // -------------

            SimpleLayout.BeginVertical(Box.StyleB);

            SimpleLayout.Label("Prefix (adds text in front of the action in the menu):");
            heroAction.title = SimpleLayout.TextField(heroAction.title);

            SimpleLayout.Label("Description (this appears below editor fields for action):");
            heroAction.description = SimpleLayout.TextArea(heroAction.description);

            SimpleLayout.EndVertical();

            // --------------

            SimpleLayout.BeginVertical(Box.StyleB);

            SimpleLayout.Label("Indent This Action (indents this action in menu. 0=no indent):");
            heroAction.indentThis = SimpleLayout.IntField(heroAction.indentThis);

            SimpleLayout.Label("Indent Next Action (indents the next action in menu. 0=no indent):");
            heroAction.indentNext = SimpleLayout.IntField(heroAction.indentNext);

            SimpleLayout.Label("Color (The color of this action in the menu):");
            heroAction.titleColor = SimpleLayout.ColorField(heroAction.titleColor, 400);

            SimpleLayout.EndVertical();

            // --------------

            SimpleLayout.Label("Version (version of this action + developer notes):");
            heroAction.version = SimpleLayout.TextArea(heroAction.version);

            SimpleLayout.EndVertical();
        }
示例#4
0
        /// <summary>
        /// If visuals type was prefab, draw the prefab preview.
        /// </summary>
        /// <param name="is2D">If we are working with 2D visuals, set this to true.</param>
        private static void DrawPrefabForState(bool is2D = false)
        {
            SimpleLayout.BeginVertical(Box.StyleB);

            stateBlock.heroVisuals.hasMesh            = false;
            stateBlock.heroVisuals.imageMesh          = null;
            stateBlock.heroVisuals.hasAnimator        = false;
            stateBlock.heroVisuals.animator           = null;
            stateBlock.heroVisuals.animatorController = null;
            stateBlock.heroVisuals.avatar             = null;

            // display the prefab
            SimpleLayout.Label("Prefab:");
            stateBlock.heroVisuals.prefab = SimpleLayout.ObjectField(stateBlock.heroVisuals.prefab);
            if (stateBlock.heroVisuals.prefab != null && PrefabUtility.GetPrefabType(stateBlock.heroVisuals.prefab) != PrefabType.Prefab)
            {
                stateBlock.heroVisuals.prefab = null;
            }
            if (stateBlock.heroVisuals.prefab != null)
            {
                // attach mesh to hero kit object if it exists
                MeshFilter meshFilter = stateBlock.heroVisuals.prefab.GetComponent <MeshFilter>();
                if (meshFilter != null)
                {
                    stateBlock.heroVisuals.hasMesh   = true;
                    stateBlock.heroVisuals.imageMesh = meshFilter.sharedMesh;
                }

                // attach animator to hero kit object if it exists
                Animator animator = stateBlock.heroVisuals.prefab.GetComponent <Animator>();
                if (animator != null)
                {
                    stateBlock.heroVisuals.hasAnimator        = true;
                    stateBlock.heroVisuals.animator           = animator;
                    stateBlock.heroVisuals.animatorController = animator.runtimeAnimatorController;
                    stateBlock.heroVisuals.avatar             = animator.avatar;
                }
            }
            SimpleLayout.EndVertical();

            // attach rigidbody
            DrawRigidbodyForState(is2D);

            // display preview
            DrawVisualPreview(stateBlock.heroVisuals.prefab);
        }
示例#5
0
        /// <summary>
        /// Fields for the hero property (game objects).
        /// </summary>
        private static void DrawGameObjects()
        {
            List <GameObjectField> items = propertyBlock.itemProperties.gameObjects.items;

            // exit early if there are no values
            if (items == null || items.Count == 0)
            {
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.Label(items[i].name + " (read only)");
            }
            SimpleLayout.EndVertical();
        }
示例#6
0
        /// <summary>
        /// Draw item type
        /// </summary>
        private static void DrawSuccess()
        {
            // item type field
            string[]       items = { "100%", "95%", "90%", "85%", "80%", "75%", "70%", "65%", "60%", "55%", "50%",
                                     "45%",        "40%", "35%", "30%", "25%", "20%", "15%", "15%", "5%" };
            DropDownValues itemList = new DropDownValues();

            itemList.setValues("", items);

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            SimpleLayout.BeginHorizontal();
            intFields[5].value = SimpleLayout.DropDownList(intFields[5].value, itemList, 0, HeroKit.Editor.HeroKitCommon.GetWidthForField(60, 200));
            SimpleLayout.Label("Chance of success");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();
            SimpleLayout.EndVertical();
        }
示例#7
0
        /// <summary>
        /// Fields for the hero property (unity objects).
        /// </summary>
        private static void DrawUnityObjects()
        {
            List <UnityObjectField> items = propertyBlock.itemProperties.unityObjects.items;

            // exit early if there are no values
            if (items == null || items.Count == 0)
            {
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.Label(items[i].name + ":");

                switch (items[i].objectType)
                {
                case 1:     // audio
                    items[i].value = SimpleLayout.ObjectField(items[i].value as AudioClip, HeroKitCommon.GetWidthForField(60, 150));
                    break;

                case 2:     // sprite
                    items[i].value = SimpleLayout.ObjectField(items[i].value as Sprite, HeroKitCommon.GetWidthForField(60, 150));
                    break;

                case 3:     // scene
                    items[i].value = SimpleLayout.ObjectField(items[i].value as SceneAsset, HeroKitCommon.GetWidthForField(60, 150));
                    if (items[i].value != null)
                    {
                        // add the scene to the editor build settings if it doesn't already exist there.
                        HeroKitCommon.AddSceneToBuildSettings(items[i].value as SceneAsset);
                    }
                    break;

                case 4:     // particle system
                    items[i].value = SimpleLayout.ObjectField(items[i].value as ParticleSystem, HeroKitCommon.GetWidthForField(60, 150));
                    break;

                case 5:     // script
                    items[i].value = SimpleLayout.ObjectField(items[i].value as MonoScript, HeroKitCommon.GetWidthForField(60, 150));
                    break;
                }
            }
            SimpleLayout.EndVertical();
        }
示例#8
0
        public static void BuildField(HeroActionParams actionParams)
        {
            HeroAction heroAction = actionParams.heroAction;

            //-----------------------------------------
            // create the action fields if they don't exist
            //-----------------------------------------
            ActionCommon.CreateActionFieldsOnHeroObject(heroAction, 22);

            //-----------------------------------------
            // create the fields for this action
            //-----------------------------------------

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            GetHeroObjectField.BuildFieldE("Use the method on a different object?", actionParams, heroAction.actionFields[0], heroAction.actionFields[1]);
            SimpleLayout.EndVertical();

            // add class
            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            MonoScript script = GetUnityObjectField.BuildFieldA <MonoScript>("The script on the hero object:", actionParams, heroAction.actionFields[2]);

            SimpleLayout.EndVertical();

            // add method
            if (script != null)
            {
                SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                SimpleLayout.Label("The method to call in the script:");
                MethodInfo method = GetMethodField.BuildFieldA(script, "", actionParams, heroAction.actionFields[3]);
                SimpleLayout.EndVertical();

                if (method != null)
                {
                    SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                    // add parameters (up to 15)
                    GetParameterField.BuildFieldA("Parameters to pass into the method:", actionParams, heroAction.actionFields[4], 5, 19, method, heroAction);
                    SimpleLayout.EndVertical();

                    SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                    // add return value (1)
                    GetParameterField.BuildFieldB("Return value to save on the hero object:", actionParams, heroAction.actionFields[20], heroAction.actionFields[21], method);
                    SimpleLayout.EndVertical();
                }
            }
        }
示例#9
0
        /// <summary>
        /// Draw item type
        /// </summary>
        private static void DrawTarget()
        {
            // item type field
            string[]       items    = { "Enemies", "Friends", "Caster", "Enemies and Friends", "All" };
            DropDownValues itemList = new DropDownValues();

            itemList.setValues("", items);

            // item type field
            string[]       scope     = { "All", "Some", "One" };
            DropDownValues scopeList = new DropDownValues();

            scopeList.setValues("", scope);

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);

            SimpleLayout.BeginHorizontal();
            intFields[1].value = SimpleLayout.DropDownList(intFields[1].value, itemList, 0, HeroKit.Editor.HeroKitCommon.GetWidthForField(60, 250));
            SimpleLayout.Label("Target");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            SimpleLayout.BeginHorizontal();
            intFields[7].value = SimpleLayout.DropDownList(intFields[7].value, scopeList, 0, HeroKit.Editor.HeroKitCommon.GetWidthForField(60, 250));
            SimpleLayout.Label("Scope");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            if (intFields[7].value == 2)
            {
                SimpleLayout.BeginHorizontal();
                intFields[8].value = SimpleLayout.IntField(intFields[8].value);
                SimpleLayout.Label("Max number of targets");
                SimpleLayout.Space();
                SimpleLayout.EndHorizontal();

                SimpleLayout.BeginHorizontal();
                boolFields[4].value = SimpleLayout.BoolField(boolFields[4].value);
                SimpleLayout.Label("Random");
                SimpleLayout.Space();
                SimpleLayout.EndHorizontal();
            }

            SimpleLayout.EndVertical();
        }
示例#10
0
        /// <summary>
        /// Fields for the hero property (bools).
        /// </summary>
        private static void DrawBools()
        {
            List <BoolField> items = propertyBlock.itemProperties.bools.items;

            // exit early if there are no values
            if (items == null || items.Count == 0)
            {
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.Label(items[i].name + ":");
                items[i].value = SimpleLayout.BoolField(items[i].value);
            }
            SimpleLayout.EndVertical();
        }
示例#11
0
        public static void BuildField(HeroActionParams actionParams)
        {
            HeroAction heroAction = actionParams.heroAction;

            //-----------------------------------------
            // create the action fields if they don't exist
            //-----------------------------------------
            ActionCommon.CreateActionFieldsOnHeroObject(heroAction, 1);

            //-----------------------------------------
            // create the fields for this action
            //-----------------------------------------

            // Field: Skip (hidden, only for else if)
            GetConditionalField.BuildField(actionParams, heroAction.actionFields[0]);

            SimpleLayout.Label("There are no fields for this action.");
        }
示例#12
0
        public static void BuildField(HeroActionParams actionParams)
        {
            HeroAction heroAction = actionParams.heroAction;

            //-----------------------------------------
            // create the action fields if they don't exist
            //-----------------------------------------
            ActionCommon.CreateActionFieldsOnHeroObject(heroAction, 1);

            //-----------------------------------------
            // create the fields for this action
            //-----------------------------------------

            // holds the id of the action that is the head of the loop
            ActionCommon.CreateLoopFieldData(heroAction.actionFields[0]);

            SimpleLayout.Label("There are no fields for this action.");
        }
示例#13
0
        /// <summary>
        /// Draw item type
        /// </summary>
        private static void DrawAttackSpeed()
        {
            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);

            SimpleLayout.BeginHorizontal();
            intFields[6].value = SimpleLayout.IntField(intFields[6].value);
            SimpleLayout.Label("Wait time before cast");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            SimpleLayout.BeginHorizontal();
            intFields[13].value = SimpleLayout.IntField(intFields[13].value);
            SimpleLayout.Label("Wait time after cast");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            SimpleLayout.EndVertical();
        }
示例#14
0
        /// <summary>
        /// Fields for the hero property (hero objects).
        /// </summary>
        private static void DrawHeroObjects()
        {
            List <HeroObjectField> items = propertyBlock.itemProperties.heroObjects.items;

            // exit early if there are no values
            if (items == null || items.Count == 0)
            {
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.Label(items[i].name + ":");
                items[i].value = SimpleLayout.ObjectField(items[i].value, HeroKitCommon.GetWidthForField(60, 150));
            }
            SimpleLayout.EndVertical();
        }
示例#15
0
    /// <summary>
    /// Display a custom inspector for the hero kit object.
    /// </summary>
    public override void OnInspectorGUI()
    {
        HeroObject oldHeroObject = heroKitObject.heroObject;

        heroKitObject.heroObject = SimpleLayout.ObjectField("Hero Object", 100, heroKitObject.heroObject, 200, false);
        HeroObject newHeroObject = heroKitObject.heroObject;

        // has hero object changed? if yes, refresh graphics
        if (newHeroObject != oldHeroObject)
        {
            HeroKit.Scene.HeroKitCommonRuntime.RefreshVisuals(heroKitObject);
        }

        if (heroKitObject.heroObject == null)
        {
            SimpleLayout.BeginVertical(EditorStyles.helpBox);
            SimpleLayout.Label("Drag the hero object you want to use from the Project Tab into the field above. Or you can choose an existing hero object by selecting the icon to the right of the field above.\n\nIf you want to create a new hero object and assign it to this field, click the button below.", true);
            SimpleLayout.EndVertical();
            if (GUILayout.Button("Create & Assign Hero Object"))
            {
                heroKitObject.heroObject = HeroKitCommon.AddHeroObjectToFolder(false);
                Selection.activeObject   = heroKitObject.transform;
            }
        }

        else if (heroKitObject.heroObject != null)
        {
            if (GUILayout.Button("Edit Hero Object"))
            {
                HeroKitEditor.ButtonClickHeroObjectAsset(heroKitObject.heroObject);
            }

            if (GUILayout.Button("Show Details"))
            {
                ToggleDetails();
            }

            // show existing inspector
            if (showDetails)
            {
                base.OnInspectorGUI();
            }
        }
    }
示例#16
0
        /// <summary>
        /// Get a hero kit object or game object.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionFieldA">Action field.</param>
        /// <param name="actionFieldB">Action field.</param>
        public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB)
        {
            SimpleLayout.Label("The type of object that contains the " + title + ":");

            string[] items  = { "Hero Object", "Game Object" };
            int      result = GetDropDownField.BuildField("", actionParams, actionFieldA, new GenericListField(items));

            if (result == 1)
            {
                SimpleLayout.Label("The hero object that contains the " + title + ":");
                GetHeroObjectField.BuildFieldA("", actionParams, actionFieldB);
            }

            else if (result == 2)
            {
                SimpleLayout.Label("The game object that contains the " + title + ":");
                GetGameObjectField.BuildFieldA("", actionParams, actionFieldB);
            }
        }
示例#17
0
        public static void BuildField(HeroActionParams actionParams)
        {
            HeroAction heroAction = actionParams.heroAction;

            //-----------------------------------------
            // create the action fields if they don't exist
            //-----------------------------------------
            ActionCommon.CreateActionFieldsOnHeroObject(heroAction, 3);

            //-----------------------------------------
            // create the fields for this action
            //-----------------------------------------

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            GetStringField.BuildFieldA("Name of the setting:", actionParams, heroAction.actionFields[2]);
            SimpleLayout.EndVertical();

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            int valueType = GetDropDownField.BuildField("Type of value to load:", actionParams, heroAction.actionFields[0], new PlayerPrefTypeField());

            if (valueType != 0)
            {
                SimpleLayout.Label("Save the value here:");
            }

            if (valueType == 1)
            {
                GetIntegerField.BuildFieldB("", actionParams, heroAction.actionFields[1]);
            }
            else if (valueType == 2)
            {
                GetFloatField.BuildFieldB("", actionParams, heroAction.actionFields[1]);
            }
            else if (valueType == 3)
            {
                GetBoolField.BuildFieldB("", actionParams, heroAction.actionFields[1]);
            }
            else if (valueType == 4)
            {
                GetStringField.BuildFieldB("", actionParams, heroAction.actionFields[1]);
            }
            SimpleLayout.EndVertical();
        }
示例#18
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]");
            }
        }
示例#19
0
 /// <summary>
 /// Draw a note about how to use the fields in this block.
 /// </summary>
 private static void DrawDescription()
 {
     SimpleLayout.Line();
     SimpleLayout.Label("You can insert integers, bools, and strings" + "\n" +
                        "into this string with codes." + "\n" +
                        "\n" +
                        "Codes:" + "\n" +
                        "[V-I-0] = Variables, Integers (slot 0)" + "\n" +
                        "[V-B-0] = Variables, Bools (slot 0)" + "\n" +
                        "[V-S-0] = Variables, Strings (slot 0)" + "\n" +
                        "\n" +
                        "[P-0-I-0] = Properties (slot 0), Integers (slot 0)" + "\n" +
                        "[P-0-B-0] = Properties (slot 0), Bools (slot 0)" + "\n" +
                        "[P-0-S-0] = Properties (slot 0), Strings (slot 0)" + "\n" +
                        "\n" +
                        "[G-I-0] = Globals, Integers (slot 0)" + "\n" +
                        "[G-B-0] = Globals, Bools (slot 0)" + "\n" +
                        "[G-S-0] = Globals, Strings (slot 0)"
                        );
 }
示例#20
0
        public static void Block(string name, int heroType)
        {
            GUIContent icon = Content.HeroObjectIcon;

            SimpleLayout.BeginHorizontal();

            //SimpleLayout.BeginVertical();
            //SimpleLayout.Space(8);
            //SimpleLayout.Label(icon);
            //SimpleLayout.Space(7);
            //SimpleLayout.EndVertical();

            SimpleLayout.BeginVertical();
            SimpleLayout.Space(9);
            SimpleLayout.Label(" " + name, HeroKit.Editor.HeroKitCommon.GetWidthForTitleField(88, 450), Label.StyleHeroTitle);
            SimpleLayout.Space(7);
            SimpleLayout.EndVertical();

            SimpleLayout.EndHorizontal();
        }
示例#21
0
        // --------------------------------------------------------------
        // Action Fields
        // --------------------------------------------------------------

        /// <summary>
        /// Get an object.
        /// </summary>
        /// <typeparam name="T">The type of object.</typeparam>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="titleToLeft">Show the title on the left?</param>
        /// <returns>The object.</returns>
        public static Rigidbody BuildField(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false)
        {
            // create the fields
            GetRigidbodyValueData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (data.title != "" && !titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }
            SimpleLayout.BeginHorizontal();
            if (data.title != "" && titleToLeft)
            {
                SimpleLayout.Label(data.title);
            }

            //-----------------------------------------
            // Get the object you want to work with
            //-----------------------------------------
            string[] rigidbodyOptions = { "Default Rigidbody", "Custom Rigidbody", "No Rigidbody", "Heavy Rigidbody" };
            data.rigidbodyType = new GenericListField(rigidbodyOptions).SetValues(data.rigidbodyType, 0);
            data.fieldValue    = GetRigidbody(data.rigidbodyType);

            //data.fieldValue = SimpleLayout.ObjectField(data.fieldValue as Rigidbody, HeroKitCommon.GetWidthForField(60));

            //-----------------------------------------
            // assign values back to hero object fields
            //-----------------------------------------
            actionField.component = data.fieldValue;
            actionField.ints[0]   = data.rigidbodyType;

            //-----------------------------------------
            // Visual stuff
            //-----------------------------------------
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            return(actionField.component as Rigidbody);
        }
示例#22
0
        /// <summary>
        /// Draw the body of the block.
        /// </summary>
        private static void DrawBody()
        {
            SimpleLayout.BeginVertical(Box.StyleCanvasBox);

            // draw name of the block
            action.name = HeroKitCommon.DrawBlockName(action.name);

            SimpleLayout.Line();

            // get current action template on hero object
            HeroKitAction oldTemplate = action.actionTemplate;

            // draw action field for block
            SimpleLayout.Space(5);
            SimpleLayout.BeginHorizontal();
            SimpleLayout.Label("Action:");
            action.actionTemplate = SimpleLayout.ObjectField(action.actionTemplate, HeroKitCommon.GetWidthForField(85));

            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            // SHOW FIELDS FOR SPECIFIC ACTION
            if (action.actionTemplate != null)
            {
                SimpleLayout.Space(5);
                SimpleLayout.Line();
                SimpleLayout.Space(5);

                // build fields
                ActionBlockBuilder.BuildFields(heroObject, action, action.actionTemplate, oldTemplate);

                // build description for action
                SimpleLayout.Space(5);
                SimpleLayout.Line();
                SimpleLayout.Label("Description:");
                SimpleLayout.Label(action.actionTemplate.description, true);
            }


            SimpleLayout.EndVertical();
        }
示例#23
0
        /// <summary>
        /// Get a return value from a method and assign the value to a hero object variable.
        /// </summary>
        /// <param name="title">Title for action field.</param>
        /// <param name="actionParams">Action field parameters.</param>
        /// <param name="actionField">Action field.</param>
        /// <param name="actionFieldB">Action field.</param>
        /// <param name="method">The method that contains the parameters.</param>
        public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionField, HeroActionField actionFieldB, MethodInfo method)
        {
            // create the fields
            ParameterFieldData data = CreateFieldData(title, actionField, actionParams.heroObject);

            //-----------------------------------------
            // Get the list you want to work with.
            //-----------------------------------------
            ParameterInfo returnValue = method.ReturnParameter;

            if (returnValue != null)
            {
                if (data.title != "")
                {
                    SimpleLayout.Label(data.title);
                }

                SimpleLayout.Line();
                GetParameter(returnValue, actionParams, actionFieldB, true);
            }
        }
示例#24
0
        /// <summary>
        /// Draw chain attack
        /// </summary>
        private static void DrawChainAttack()
        {
            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);

            SimpleLayout.BeginHorizontal();
            boolFields[5].value = SimpleLayout.BoolField(boolFields[5].value);
            SimpleLayout.Label("Chain attack (pass attack to others in range of target that is hit)");
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            if (boolFields[5].value)
            {
                SimpleLayout.BeginHorizontal();
                intFields[9].value = SimpleLayout.IntField(intFields[9].value);
                SimpleLayout.Label("Radius around target");
                SimpleLayout.Space();
                SimpleLayout.EndHorizontal();
            }

            SimpleLayout.EndVertical();
        }
示例#25
0
        // --------------------------------------------------------------
        // Methods (Fields)
        // --------------------------------------------------------------

        /// <summary>
        /// A field for a hero property file.
        /// </summary>
        private static void DrawItemType()
        {
            SimpleLayout.BeginHorizontal();
            SimpleLayout.Label("Item Type:");
            SimpleLayout.Space(13);
            propertyBlock.propertyTemplate = SimpleLayout.ObjectField(propertyBlock.propertyTemplate, HeroKitCommon.GetWidthForField(120));
            SimpleLayout.Space();
            SimpleLayout.EndHorizontal();

            // SHOW FIELDS FOR SPECIFIC HERO PROPERTY
            // if hero property has been removed, sanitize properties list
            if (propertyBlock.propertyTemplate != null)
            {
                SimpleLayout.Space(5);
                SimpleLayout.Line();
            }
            else
            {
                propertyBlock.itemProperties = new HeroList();
            }
        }
示例#26
0
        /// <summary>
        /// Draw the body of the block.
        /// </summary>
        private static void DrawItems()
        {
            // exit early if there are no items
            if (items == null || items.Count == 0)
            {
                HeroKitCommon.DrawNoItemsInList(blockName);
                return;
            }

            SimpleLayout.BeginVertical(Box.StyleCanvasBox);

            // display items (move up, move down, int field,
            for (int i = 0; i < items.Count; i++)
            {
                SimpleLayout.BeginHorizontal();
                HeroKitCommon.DrawListArrows(moveItemUp, moveItemDown, i);

                SimpleLayout.BeginVertical();
                SimpleLayout.BeginHorizontal();
                items[i].name = SimpleLayout.StringListField(items[i].name, HeroKitCommon.GetWidthForField(270, 150));
                SimpleLayout.EndHorizontal();
                SimpleLayout.BeginHorizontal();
                SimpleLayout.Label("Type:");
                items[i].value = SimpleLayout.ObjectListField(items[i].value, i, HeroKitCommon.GetWidthForField(315));
                SimpleLayout.EndHorizontal();
                SimpleLayout.EndVertical();

                HeroKitCommon.DrawListButtons(addItem, copyItem, pasteItem, deleteItem, i);
                SimpleLayout.EndHorizontal();

                if (i != items.Count - 1)
                {
                    SimpleLayout.Line();
                }
            }

            SimpleLayout.EndVertical();

            SimpleLayout.Space(20);
        }
示例#27
0
        /// <summary>
        /// Draw the visual preview pane for a prefab.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        private static void DrawVisualPreview(GameObject prefab)
        {
            bool showPreview = true;

            // Unity 2017 will not display the preview window with OnPreviewGUI. A ticket has been submitted to them.
            //#if UNITY_2017
            //showPreview = false;
            //#endif

            // exit early if preview should not be visible
            if (!showPreview || prefab == null)
            {
                return;
            }

            SimpleLayout.BeginVertical(Box.StyleB);
            SimpleLayout.Label("Preview:");
            gameObjectEditor = UnityEditor.Editor.CreateEditor(prefab);
            gameObjectEditor.OnPreviewGUI(GUILayoutUtility.GetRect(200, 200), Box.StyleImagePreview);
            SimpleLayout.EndVertical();
            Object.DestroyImmediate(gameObjectEditor);
        }
示例#28
0
        /// <summary>
        /// Get the camera to use.
        /// </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>
        public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB)
        {
            //-----------------------------------------
            // Display this title above the field
            //-----------------------------------------
            if (title != "")
            {
                SimpleLayout.Label(title);
            }

            //-----------------------------------------
            // Display the fields
            //-----------------------------------------
            bool customCamera = GetBoolValue.BuildField("Use a specific camera that is not the main camera?", actionParams, actionFieldA, true);

            if (customCamera)
            {
                SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                GetHeroObjectField.BuildFieldA("The camera is on this hero object:", actionParams, actionFieldB);
                SimpleLayout.EndVertical();
            }
        }
示例#29
0
        // --------------------------------------------------------------
        // Methods (Visual Fields)
        // --------------------------------------------------------------

        /// <summary>
        /// Choose the type of visuals to use for this state.
        /// </summary>
        private static void DrawVisualsTypeForState()
        {
            // Visual Type
            SimpleLayout.Label("Visuals type:");
            stateBlock.heroVisuals.visualType = new VisualTypeField().SetValues(stateBlock.heroVisuals.visualType, 0);

            SimpleLayout.Space(5);
            SimpleLayout.Line();
            SimpleLayout.Space(5);

            switch (stateBlock.heroVisuals.visualType)
            {
            case 0:     // not set
            case 1:     // 3D
                Draw3DForState();
                break;

            case 2:     // 2D
                Draw2DForState();
                break;
            }
        }
示例#30
0
        /// <summary>
        /// Draw the body of the block.
        /// </summary>
        private static void DrawBody()
        {
            SimpleLayout.BeginVertical(Box.StyleCanvasBox);
            SimpleLayout.Button("Refresh Hero Objects", RefreshHeroObjects, Button.StyleA);
            SimpleLayout.Label("Use this to make sure that your hero objects structure is up-to-date. \n" +
                               "For example, if you change a Hero Property that is assigned to several \n" +
                               "Hero Objects, press this button to make sure all of the hero objects have \n" +
                               "the new, updated properties.");

            SimpleLayout.Line();
            SimpleLayout.EndVertical();

            SimpleLayout.BeginVertical(Box.StyleCanvasBox);
            SimpleLayout.Button("Delete Save Files", DeleteSaveFiles, Button.StyleA);
            SimpleLayout.Label("Quickly delete save files.");

            SimpleLayout.Line();
            SimpleLayout.EndVertical();

            SimpleLayout.BeginVertical(Box.StyleCanvasBox);
            SimpleLayout.Button("Migrate HeroKit data to Beta 1.02", UpdateHeroKit1_2, Button.StyleA);
            SimpleLayout.Label("This move your properties on hero objects into the new Property \n" +
                               "structure on hero objects. Once you've done this, you need to update your \n" +
                               "actions to point to the updated properties.");

            SimpleLayout.Line();
            SimpleLayout.EndVertical();

            SimpleLayout.BeginVertical(Box.StyleCanvasBox);
            SimpleLayout.Button("Show/Hide Menu Templates", ShowMenuSkins, Button.StyleA);
            SimpleLayout.Label("You can use the default templates we provide for your menus \n" +
                               "or you can use your own. The default templates are stored here: \n" +
                               "HeroKit/Hero Engine/Assets/Resources/Hero Templates/Menus");
            MenuSkins();

            SimpleLayout.Line();
            SimpleLayout.EndVertical();
        }