}//end HPMPFormatting /// <summary> /// Must be called BEFORE TileForegroundColorFormatting(). Sets the text's background to a certain color based on the faction of the actor on the node, if any. /// </summary> /// <param name="map"></param> /// <param name="x"></param> /// <param name="y"></param> public static void TileBackgroundColorFormatting(Map map, int x, int y) { //TODO: JON: Go over with Sarazua. This is rather nitpicky, so we can skip it. //Right now, the coloring is based off the actor's faction //so that the player can easily see where their characters and enemies are without having //to read any text. Additional options (that maaaay be better(?) but harder to do) would be to //have the background reflect who's turn it is currently. So when it's an enemy's turn and the //game redraws the map, have their tile appear in DarkRed, then have text at the bottom //describe what he's doing while waiting for the user to press a button to continue. I don't //think we can do both effectively, since colors are very limited. We also don't want the map //to be too visually busy, since that defeats the point, so we need to be careful when we're //assigning different background and foreground colors. Perhaps making all points of interest //Yellow (or some other color), instead of using yellow for ladders, red for doors, etc. try { if (TryCatchActorFaction(map, x, y)) { ActorFaction actorFaction = map.MapNodes[x, y].ActorOnNode.Faction; switch (actorFaction) { case ActorFaction.Ally: Console.BackgroundColor = ConsoleColor.DarkBlue; break; case ActorFaction.Enemy: Console.BackgroundColor = ConsoleColor.DarkRed; break; case ActorFaction.Monster: Console.BackgroundColor = ConsoleColor.DarkMagenta; break; default: break; } } } catch (IndexOutOfRangeException) { //swallow execption; } catch (NullReferenceException) { //swallow execption; } }
public static bool TryCatchActorFaction(Map map, int x, int y) { bool actorHasFaction = false; try { //Just a way to test if the actor on the node has a faction assigned. ActorFaction actorFaction = map.MapNodes[x, y].ActorOnNode.Faction; actorHasFaction = true; } catch (IndexOutOfRangeException) { return(false); } catch (NullReferenceException) { return(false); } return(actorHasFaction); }//end TryCatchActorOnNode