// I'd recommend using string parameters for your buttons instead // of enum parameters, but you can do it either way public void ModifyUnitButtonHandler(ArmyTypes army, UnitTypes unit, AttributeTypes attribute, int value) { // I'm not sure if the ? operator exists in Unity's default .NET version. // If not, you can use a few if/then statements to make sure that nothing // returns null GetArmy(army.ToString())? .GetUnit(unit.ToString())? .GetAttribute(attribute.ToString())? .Add(value); }
/// <summary> /// Creates a default attribute type instance of the passed in type. /// </summary> public static IAttributeType CreateAttributeType(AttributeTypes type) { switch (type) { case AttributeTypes.AssetName: return(new AssetNameAttributeType()); case AttributeTypes.Integer: return(new IntegerAttributeType()); case AttributeTypes.StringAttribute: return(new StringAttributeType()); default: throw new NotImplementedException(type.ToString() + " has not been implemented yet."); } }