Legal and Moral obligations? More to it...
If an armed BG wants to put me in a position where I feel the need to defend myself, I don't feel any moral obligation to shield him from his own actions. None at all.
That said, I would feel a moral obligation to protect innocent bystanders, assuming there were any. This could include people who were with me, and anybody else in the vicinity. Situationally, that protection could range from proper sight alignment and trigger control to de-escalation by any reasonable means. Any number of variables would impact this calculus, including but not limited to apparent intent of the BG, number and positions of BGs, number and positions of bystanders, etc.
Additionally, assuming force were required, I would feel a moral obligation to use no more force than necessary to resolve the situation. IE once threat is stopped, no more shots taken, punches or kicks thrown, etc. Engage to stop the threat, quickly and efficiently as possible, but no further than stopping the threat.
But morally, I'd feel no obligation to put the protection of the BG, per se, anywhere near the level of conscious thought.
Legal obligations may vary. After avoiding the graveyard or ER, and preventing harm to innocents, avoiding prison time runs a close third - or maybe second, as the first two are kind of tied for first place.
That's all well and good for Legal and Moral. However, a third and no less important consideration is Practical/Tactical.
If a safe avenue of escape is available, then it doesn't make sense to engage. I'd define "safe" as safe not only for me, but for anybody I might care about in the vicinity. IE, if I drive away, or if I go around the building, do I just leave a bunch of people in harm's way? So, if I can in good conscience resolve the problem by exiting, that's the way to go. I'm a good shot, and I'm not bad with my hands, or knives or clubs for that matter, but a wounded attacker can still inflict damage; an armed and wounded attacker can potentially still inflict fatal damage. Engaging just for the sake of not backing down opens up a very big can of risk. So, from a Practical/Tactical or self-preservation perspective, I'd avoid the problem if a morally acceptable retreat were available.
Note that while retreating, I'd keep whatever weapon I had in hand, as surreptitiously as possible; I'd also want to maximize use of cover and concealment. As soon as relative safety were reached, it would then be time for a 911 call.