/// <summary> /// Get a list of hero object fields. /// </summary> /// <param name="data">Current data for this action field.</param> /// <param name="indexShift">Make sure we are using the correct field type.</param> /// <returns>A list of hero object fields.</returns> private static List <HeroObjectField> GetItemsFromList(HeroObjectFieldData data, int indexShift = 0) { List <HeroObjectField> items = new List <HeroObjectField>(); int fieldType = data.fieldType + indexShift; // Local Variable if (fieldType == 1 && data.targetHeroObject != null) { items = data.targetHeroObject.lists.heroObjects.items; } // Property else if (fieldType == 2 && data.targetHeroObject != null) { List <HeroProperties> heroProperties = data.targetHeroObject.propertiesList.properties; if (heroProperties != null && heroProperties.Count > 0) { items = heroProperties[data.propertyID - 1].itemProperties.heroObjects.items; } } // Global Variable else if (fieldType == 3) { items = HeroKitCommon.GetGlobals().globals.heroObjects.items; } return(items); }
/// <summary> /// Create a drop-down list of hero object fields in the action field. /// </summary> /// <param name="data">Current data for this action field.</param> /// <param name="items">A list of hero object fields.</param> /// <returns>The data for this action field.</returns> private static HeroObjectFieldData BuildItemFieldList(HeroObjectFieldData data, List <HeroObjectField> items) { bool drawValues = ActionCommon.InitItemFieldList(ref data, items, "Hero Objects"); if (drawValues) { data.fieldID = HeroField.HeroObjectListField.SetValues(items, data.fieldID, 0); } return(data); }
// -------------------------------------------------------------- // Helpers // -------------------------------------------------------------- /// <summary> /// If we are working with a hero property list, get the ID of the property we are using. /// </summary> /// <param name="data">Current data for this action field.</param> /// <param name="indexShift">Make sure we are using the correct field type.</param> /// <returns>Current data for this action field.</returns> private static HeroObjectFieldData SetPropertyID(HeroObjectFieldData data, int indexShift = 0) { int fieldType = data.fieldType + indexShift; // Property if (fieldType == 2 && data.targetHeroObject != null) { data.propertyID = HeroField.HeroPropertyListField.SetValues(data.targetHeroObject.propertiesList.properties.ToArray(), data.propertyID, 0); } return(data); }
/// <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); }
// -------------------------------------------------------------- // 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 HeroObjectFieldData CreateFieldData(string title, HeroActionField actionField, HeroObject heroObject) { HeroObjectFieldData data = new HeroObjectFieldData(); 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.fieldType = actionField.ints[3]; data.heroGUID = actionField.ints[4]; data.propertyID = actionField.ints[5]; data.objectName = actionField.strings[0]; data.gameObject = actionField.gameObjects[0]; return(data); }
/// <summary> /// Get a value from a hero object field. /// 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="titleToLeft">Show the title on the left?</param> public static HeroObject BuildFieldB(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); } //----------------------------------------- // Get the type of field you want to work with. //----------------------------------------- data.fieldType = new HeroField.ValueTypeFieldB().SetValues(data.fieldType, 0); //----------------------------------------- // 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) //----------------------------------------- if (data.fieldType == 1 || data.fieldType == 2) { data = ActionCommon.GetTargetHeroObject(data); } //----------------------------------------- // Get the hero list you want to work with. // The list is in hero object editor > Variables //----------------------------------------- // if this is a field, draw field (1=value) data = SetPropertyID(data); List <HeroObjectField> items = GetItemsFromList(data); data = BuildItemFieldList(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.fieldType; actionField.ints[4] = data.heroGUID; actionField.ints[5] = data.propertyID; actionField.strings[0] = data.objectName; //----------------------------------------- // Visual stuff //----------------------------------------- SimpleLayout.Space(); SimpleLayout.EndHorizontal(); return(GetTargetHeroObject(data.targetHeroObject, data.fieldType + 1, data.fieldID, data.propertyID)); }
// -------------------------------------------------------------- // Action Fields // -------------------------------------------------------------- /// <summary> /// Get a value from a hero object field. /// This is for a field that contains Value, 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="titleToLeft">Show the title on the left?</param> public static HeroObject BuildFieldA(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); } //----------------------------------------- // Get the type of field you want to work with. //----------------------------------------- data.fieldType = new HeroField.ValueTypeField().SetValues(data.fieldType, 0); //----------------------------------------- // Get the type of object we are working with. (if it isn't a global) //----------------------------------------- data = ActionCommon.GetTargetHeroObject(data); //----------------------------------------- // Get the list you want to work with. //----------------------------------------- // if this is a list, draw ints (2=variables, 3=properties) if (data.fieldType != 1) { data = SetPropertyID(data, -1); List <HeroObjectField> items = GetItemsFromList(data, -1); data = BuildItemFieldList(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.fieldType; actionField.ints[4] = data.heroGUID; actionField.ints[5] = data.propertyID; actionField.strings[0] = data.objectName; //----------------------------------------- // Visual stuff //----------------------------------------- SimpleLayout.Space(); SimpleLayout.EndHorizontal(); //----------------------------------------- // Return value //----------------------------------------- return(GetTargetHeroObject(data.targetHeroObject, data.fieldType, data.fieldID, data.propertyID)); }