/// <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> /// Get the target hero object. /// </summary> /// <param name="targetObject"></param> /// <param name="fieldType"></param> /// <param name="fieldID"></param> /// <returns></returns> private static HeroObject GetTargetHeroObject(HeroObject targetObject, int fieldType, int fieldID, int propertyID) { HeroObject heroObject = null; // value if (fieldType == 1) { heroObject = targetObject; } if (targetObject != null && fieldID > 0) { // variable if (fieldType == 2 && targetObject.lists.heroObjects.items.Count >= fieldID) { heroObject = targetObject.lists.heroObjects.items[fieldID - 1].value; } // property else if (fieldType == 3 && targetObject.propertiesList.properties[propertyID].itemProperties.heroObjects.items.Count >= fieldID) { heroObject = targetObject.propertiesList.properties[propertyID].itemProperties.heroObjects.items[fieldID - 1].value; } // global else if (fieldType == 4 && HeroKitCommon.GetGlobals().globals.heroObjects.items.Count >= fieldID) { heroObject = HeroKitCommon.GetGlobals().globals.heroObjects.items[fieldID - 1].value; } } return(heroObject); }
/// <summary> /// Hero Object = A hero object attached to another game object in global list. /// </summary> /// <typeparam name="T">The type of data for the action field.</typeparam> /// <param name="data">The data for the action field.</param> /// <returns>The data for the action field.</returns> public static T GetHeroObjectInGlobalsB <T>(T data) where T : ITargetHeroObject { // get the hero object assigned to the game object field if field has been selected if (data.fieldID > 0) { data.targetHeroObject = HeroKitCommon.GetGlobals().globals.heroObjects.items[data.fieldID - 1].value; } else { data.targetHeroObject = null; } return(data); }
/// <summary> /// Block to display on the canvas. Get list from hero kit object. /// </summary> /// <param name="heroKitObject">Hero object info to display in the block.</param> /// <param name="globals">Display gobal variables instead of local variables?</param> public static void Block(HeroObject heroKitObject, bool globals = false) { // exit early if object is null if (heroKitObject == null) { return; } // assign hero object to this class heroObject = heroKitObject; items = (globals) ? HeroKitCommon.GetGlobals().globals.bools.items : heroObject.lists.bools.items; // draw components DrawHeader(); DrawBlock(); }
/// <summary> /// Hero Object = A hero object attached to another game object in global list. /// </summary> /// <typeparam name="T">The type of data for the action field.</typeparam> /// <param name="data">The data for the action field.</param> /// <returns>The data for the action field.</returns> public static T GetHeroObjectInGlobals <T>(T data) where T : ITargetHeroObject { // display list of game object fields in this hero object data.objectID = HeroField.HeroObjectListField.SetValues(HeroKitCommon.GetGlobals().globals.heroObjects.items, data.objectID, 0); // get the hero object assigned to the game object field if field has been selected if (data.objectID > 0) { data.targetHeroObject = HeroKitCommon.GetGlobals().globals.heroObjects.items[data.objectID - 1].value; } else { data.targetHeroObject = null; } return(data); }