// -------------------------------------------------------------- // Action Fields // -------------------------------------------------------------- /// <summary> /// Get a hero property. /// </summary> /// <param name="title">Title for action field.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionField">Action field.</param> public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionField) { // create the fields HeroPropertyFieldData data = CreateFieldData(title, actionField, actionParams.heroObject); //----------------------------------------- // Display this title above the field //----------------------------------------- if (data.title != "") { SimpleLayout.Label(data.title); } SimpleLayout.BeginHorizontal(); //----------------------------------------- // Get the integer list you want to work with. // The integer list is in hero object editor > Variables //----------------------------------------- data.fieldValue = SimpleLayout.ObjectField(data.fieldValue, 200); //----------------------------------------- // assign values back to hero object fields //----------------------------------------- actionField.heroProperties[0] = data.fieldValue; //----------------------------------------- // Visual stuff //----------------------------------------- SimpleLayout.Space(); SimpleLayout.EndHorizontal(); }
public void Init(ref HeroActionField actionField) { ActionCommon.CreateActionField(ref actionField.ints, 7, 0); ActionCommon.CreateActionField(ref actionField.heroObjects, 1, null); ActionCommon.CreateActionField(ref actionField.strings, 1, ""); ActionCommon.CreateActionField(ref actionField.bools, 1, false); }
/// <summary> /// Get X, Y, Z coordinates. /// </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="actionFieldC">Action field parameters.</param> /// <param name="actionFieldD">Action field parameters.</param> /// <param name="actionFieldE">Action field parameters.</param> /// <param name="actionFieldF">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, HeroActionField actionFieldC, HeroActionField actionFieldD, HeroActionField actionFieldE, HeroActionField actionFieldF, bool titleToLeft = false) { if (title != "") { SimpleLayout.Label(title); } bool changeX = GetBoolValue.BuildField("X:", actionParams, actionFieldA, true); if (changeX) { GetFloatField.BuildFieldA("", actionParams, actionFieldB); } bool changeY = GetBoolValue.BuildField("Y:", actionParams, actionFieldC, true); if (changeY) { GetFloatField.BuildFieldA("", actionParams, actionFieldD); } bool changeZ = GetBoolValue.BuildField("Z:", actionParams, actionFieldE, true); if (changeZ) { GetFloatField.BuildFieldA("", actionParams, actionFieldF); } }
/// <summary> /// Get a value from a property in a script and save this value on a hero kit 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> /// <param name="script">The script.</param> public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, MonoScript script) { // create the fields PropertyFieldData data = CreateFieldData(title, actionFieldA, actionParams.heroObject); //----------------------------------------- // Display this title above the field //----------------------------------------- if (data.title != "") { SimpleLayout.Label(data.title); } //----------------------------------------- // Get the list you want to work with. //----------------------------------------- PropertyInfo[] properties = GetPropertiesFromScript(script); data = BuildItemFieldList(data, properties); if (properties != null && properties.Length != 0 && data.fieldID > 0) { PropertyInfo property = properties[data.fieldID - 1]; SetPropertyOnScript(property, actionParams, actionFieldB); } //----------------------------------------- // assign values back to hero object fields //----------------------------------------- actionFieldA.ints[0] = data.fieldID; }
// -------------------------------------------------------------- // Action Fields // -------------------------------------------------------------- /// <summary> /// Get a layer mask. /// </summary> /// <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> public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionField, bool titleToLeft = false) { // create the fields LayerMaskValueData 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 bool list you want to work with. // The bool list is in hero object editor > Variables //----------------------------------------- data.fieldValue = SimpleLayout.LayerMaskField(data.fieldValue, 200); //----------------------------------------- // assign values back to hero object fields //----------------------------------------- actionField.ints[0] = data.fieldValue; //----------------------------------------- // Visual stuff //----------------------------------------- SimpleLayout.Space(); SimpleLayout.EndHorizontal(); }
/// <summary> /// Get a value from a field in a script and save this value on a hero kit 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> /// <param name="script">The script.</param> public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, MonoScript script) { // create the fields FieldInfoFieldData data = CreateFieldData(title, actionFieldA, actionParams.heroObject); //----------------------------------------- // Display this title above the field //----------------------------------------- if (data.title != "") { SimpleLayout.Label(data.title); } //----------------------------------------- // Get the list you want to work with. //----------------------------------------- FieldInfo[] fields = GetFields(script); data = BuildItemFieldList(data, fields); if (fields != null && fields.Length != 0 && data.fieldID > 0) { FieldInfo field = fields[data.fieldID - 1]; SetFieldOnHero(field, actionParams, actionFieldB); } //----------------------------------------- // assign values back to hero object fields //----------------------------------------- actionFieldA.ints[0] = data.fieldID; }
public void Init(ref HeroActionField actionField) { ActionCommon.CreateActionField(ref actionField.ints, 6, 0); ActionCommon.CreateActionField(ref actionField.heroObjects, 1, null); ActionCommon.CreateActionField(ref actionField.strings, 1, ""); ActionCommon.CreateActionField(ref actionField.gameObjects, 1, null); }
// -------------------------------------------------------------- // Actin Fields // -------------------------------------------------------------- /// <summary> /// Create a flag that tracks the result of a condition. /// </summary> /// <remarks>This field is hidden in the editor.</remarks> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionField">Action field.</param> public static void BuildField(HeroActionParams actionParams, HeroActionField actionField) { ConditionalFieldData data = CreateFieldData(actionField); data.skip = false; actionField.bools[0] = data.skip; }
/// <summary> /// Get a value from a bool 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 void BuildFieldC(string title, HeroActionParams actionParams, HeroActionField actionField, HeroObject heroObject, bool titleToLeft = false) { // create the fields BoolFieldData 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 type of field you want to work with. //----------------------------------------- data.fieldType = new HeroField.ValueTypeFieldB().SetValues(data.fieldType, 0); //----------------------------------------- // Get the type of game object we are working with // Option 1: This game object // Option 2: Another game object in the Game Object list attached to this game object // Option 3: Another game object in the scene //----------------------------------------- data.targetHeroObject = heroObject; //----------------------------------------- // Get the bool list you want to work with. // The bool list is in hero object editor > Variables //----------------------------------------- data = SetPropertyID(data); List <BoolField> items = GetItemsFromList(data); data = BuildItemFieldList(data, items); //----------------------------------------- // assign values back to hero object fields //----------------------------------------- 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.heroObjects[0] = data.targetHeroObject; actionField.strings[0] = data.objectName; actionField.bools[0] = data.fieldValue; //----------------------------------------- // Visual stuff //----------------------------------------- SimpleLayout.Space(); SimpleLayout.EndHorizontal(); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static ConditionalFieldData CreateFieldData(HeroActionField actionField) { ConditionalFieldData data = new ConditionalFieldData(); data.Init(ref actionField); data.skip = actionField.bools[0]; return(data); }
// -------------------------------------------------------------- // Action Fields // -------------------------------------------------------------- /// <summary> /// Get an event. /// </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> public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionField, HeroObject heroObject) { EventFieldData data = CreateFieldData(title, actionField, actionParams.heroObject); //----------------------------------------- // Display this title above the field //----------------------------------------- if (data.title != "") { SimpleLayout.Label(data.title); } // save target object data.targetHeroObject = heroObject; // draw states if (data.targetHeroObject != null) { SimpleLayout.Label("State:"); List <HeroState> states = new List <HeroState>(); if (data.targetHeroObject != null) { states = data.targetHeroObject.states.states; } data = GetTargetStateEvent(data, states); // draw events for state if (data.stateID > 0) { SimpleLayout.Label("Event:"); List <HeroEvent> items = new List <HeroEvent>(); if (data.targetHeroObject != null && data.stateID > 0) { items = data.targetHeroObject.states.states[data.stateID - 1].heroEvent; } data = BuildEventFieldList(data, items); } } //----------------------------------------- // 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.stateID; actionField.ints[4] = data.heroGUID; actionField.ints[5] = data.fieldType; actionField.strings[0] = data.objectName; //----------------------------------------- // Visual stuff //----------------------------------------- //SimpleLayout.Space(); //SimpleLayout.EndHorizontal(); }
/// <summary> /// Get an animation to play. This requires the use of action fields 0-3. /// </summary> /// <param name="title">Title of the action field.</param> /// <param name="actionParams">Action parameters.</param> /// <param name="actionFieldA">Action field.</param> /// <param name="actionFieldB">Action field.</param> /// <param name="actionFieldC">Action field.</param> /// <param name="paramType">Animation controller parameter type.</param> /// <param name="targetHeroObject">The target hero object.</param> public static void GetAnimation(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, HeroActionField actionFieldC, AnimatorControllerParameterType paramType, HeroObject targetHeroObject) { if (title != "") { SimpleLayout.Label(title); } SimpleLayout.BeginVertical(Box.StyleB); if (targetHeroObject == null) { SimpleLayout.Label("Select a hero object to see its animation parameters."); SimpleLayout.EndVertical(); return; } if (targetHeroObject.states.states == null || targetHeroObject.states.states.Count == 0) { SimpleLayout.Label("This hero object has no states."); SimpleLayout.EndVertical(); return; } SimpleLayout.Label("The state that contains the animation controller:"); int stateID = GetDropDownBField.BuildField("", actionParams, actionFieldA, new HeroField.StateListField(), targetHeroObject.states.states) - 1; if (stateID >= 0) { string paramTypeName = paramType.ToString(); SimpleLayout.Label(paramTypeName + " assigned to the animation controller:"); RuntimeAnimatorController animatorController = GetAnimationParameterField.BuildFieldA("", actionParams, actionFieldB, targetHeroObject, stateID, paramType); if (animatorController == null) { SimpleLayout.BeginVertical(Box.StyleA); SimpleLayout.Label("This state has no animation controller.\nIf you are 100% certain a specific animation controller\nwill be available at runtime, drag the prefab \nthat contains the controller here:"); GameObject prefab = GetPrefabValue.BuildField("", actionParams, actionFieldC); if (prefab != null) { Animator animator = prefab.GetComponent <Animator>(); if (animator != null) { animatorController = animator.runtimeAnimatorController; if (animatorController != null) { GetAnimationParameterField.BuildFieldB("", actionParams, actionFieldB, animatorController, paramType); } } } SimpleLayout.EndVertical(); } } SimpleLayout.EndVertical(); }
/// <summary> /// A slider (integer values). /// </summary> /// <param name="title">Title for action field.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionField">Action field.</param> /// <param name="min">Smallest value for the slider.</param> /// <param name="max">Largest value for the slider.</param> /// <param name="titleToLeft">Show the title on the left?</param> public static void BuildFieldB(string title, HeroActionParams actionParams, HeroActionField actionField, int min = 0, int max = 100, bool titleToLeft = false) { SliderData slider = new SliderData(); slider.useSlider = true; slider.min = min; slider.max = max; GetIntegerField.BuildFieldA(title, actionParams, actionField, titleToLeft, slider); }
/// <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); } }
// -------------------------------------------------------------- // General // -------------------------------------------------------------- /// <summary> /// Save the ID of the action that is the head of the loop. /// </summary> /// <param name="actionField">The action field.</param> /// <returns>Data needed to use loops inside an event.</returns> public static LoopFieldData CreateLoopFieldData(HeroActionField actionField) { LoopFieldData data = new LoopFieldData(); CreateActionField(ref actionField.ints, data.intSlots, 0); CreateActionField(ref actionField.bools, data.boolSlots, false); data.startLoopID = actionField.ints[0]; data.success = actionField.bools[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> private static ParameterFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { ParameterFieldData data = new ParameterFieldData(); data.Init(ref actionField); data.title = title; data.startID = actionField.ints[1]; data.endID = actionField.ints[2]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> public static LayerMaskValueData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { LayerMaskValueData data = new LayerMaskValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.ints[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static ColorValueData CreateFieldData(string title, HeroActionField actionField) { ColorValueData data = new ColorValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.colors[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static PrefabValueData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { PrefabValueData data = new PrefabValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.gameObjects[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static AnimationParameterFieldData CreateFieldData(string title, HeroActionField actionField) { AnimationParameterFieldData data = new AnimationParameterFieldData(); data.Init(ref actionField); data.title = title; data.fieldID = actionField.ints[0]; data.fieldName = actionField.strings[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static GetObjectValueData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { GetObjectValueData data = new GetObjectValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.component; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> private static HeroPropertyFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { HeroPropertyFieldData data = new HeroPropertyFieldData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.heroProperties[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static BoolValueData CreateFieldData(string title, HeroActionField actionField) { BoolValueData data = new BoolValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.bools[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> public static TagFieldData CreateFieldData(string title, HeroActionField actionField) { TagFieldData data = new TagFieldData(); data.Init(ref actionField); data.title = title; data.fieldID = actionField.ints[0]; data.fieldName = actionField.strings[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static DropDownFieldData CreateFieldData(string title, HeroActionField actionField) { DropDownFieldData data = new DropDownFieldData(); data.Init(ref actionField); data.title = title; data.fieldID = actionField.ints[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> public static HeroTypeFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { HeroTypeFieldData data = new HeroTypeFieldData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.heroObjects[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> private static MethodFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { MethodFieldData data = new MethodFieldData(); data.Init(ref actionField); data.title = title; data.fieldID = actionField.ints[0]; data.fieldNameString = actionField.strings[0]; data.fieldName = null; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> public static PropertyFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { PropertyFieldData data = new PropertyFieldData(); data.Init(ref actionField); data.title = title; data.fieldID = actionField.ints[0]; data.startID = actionField.ints[1]; data.endID = actionField.ints[2]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <returns>The data for this action field.</returns> private static GetRigidbodyValueData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { GetRigidbodyValueData data = new GetRigidbodyValueData(); data.Init(ref actionField); data.title = title; data.fieldValue = actionField.component as Rigidbody; data.rigidbodyType = actionField.ints[0]; return(data); }
// -------------------------------------------------------------- // Initialize Action Field // -------------------------------------------------------------- /// <summary> /// Create the subfields that we need for this action field. /// </summary> /// <param name="title">The title of the action.</param> /// <param name="actionField">The action field.</param> /// <param name="heroObject">The hero object that contains this action field.</param> /// <returns>The data for this action field.</returns> private static EventFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { EventFieldData data = new EventFieldData(); data.Init(ref actionField); data.title = title; data.heroObject = heroObject; data.targetHeroObject = actionField.heroObjects[0]; data.objectType = actionField.ints[0]; data.objectID = actionField.ints[1]; data.fieldID = actionField.ints[2]; data.stateID = actionField.ints[3]; data.heroGUID = actionField.ints[4]; data.fieldType = actionField.ints[5]; data.objectName = actionField.strings[0]; return(data); }