// Handler functions for when characters move from zone to zone. private void HandleCharacterEnterAreaEvent(object sender, ICharacter character) { // DebuggingHelpers.PrintCurrentMethodName(); AreaNodeVisualisation area = (AreaNodeVisualisation)sender; // Whatever the state of the area the Character was PREVIOUSLY in should become the state of the new area, unless the entered area already has a state which supersedes it. AreaNodeVisualisationStates state = characterStateMap[character]; if (state.Priority() >= area.CurrentState.Priority()) { area.CurrentState = state; } // ok! we better make sure we keep everything up to date. characterAreaMap[character] = area; }
private void UpdateAreaStateBasedOnCharactersWithinIt(AreaNodeVisualisation area) { if (area == null) { return; } AreaNodeVisualisationStates state = AreaNodeVisualisationStates.UNCONTROLLED; foreach (ICharacter c in area.AgentsInZone) { if (characterStateMap[c].Priority() >= state.Priority()) { state = characterStateMap[c]; } } area.CurrentState = state; }