/// <summary> /// Resets the current map to a default state - typically no monsters and NPCs in there default positions /// </summary> private List <NonPlayerCharacterReference> LoadSmallMap(SmallMapReferences.SingleMapReference singleMapReference, TimeOfDay timeOfDay, bool bLoadFromDisk) { List <NonPlayerCharacterReference> npcCurrentMapRefs = null; npcCurrentMapRefs = npcRefs.GetNonPlayerCharactersByLocation(singleMapReference.MapLocation); if (bLoadFromDisk) { smallMapAnimationStates.Load(MapCharacterAnimationStates.MapCharacterAnimationStatesFiles.SAVED_GAM, bLoadFromDisk); } else { } for (int i = 0; i < MAX_MAP_CHARACTERS; i++) { if (i == 0) { Characters.Add(new MapCharacter()); continue; } NonPlayerCharacterReference npcRef = npcCurrentMapRefs[i]; MapCharacterState mapCharState; MapCharacterAnimationState charAnimState = null; NonPlayerCharacterMovement charMovement; charMovement = movements.GetMovement(i); if (!bLoadFromDisk) { // we keep the object because we may be required to save this to disk - but since we are leaving the map there is no need to save their movements charMovement.ClearMovements(); mapCharState = new MapCharacterState(tileRefs, npcRef, i, timeOfDay); } else { // character states are only loaded when forced from disk and only on small maps mapCharState = charStates.GetCharacterState(i); if (CurrentAnimationState.HasAnyAnimationStates()) { charAnimState = CurrentAnimationState.GetCharacterState(mapCharState.CharacterAnimationStateIndex); } } Characters.Add(new MapCharacter(npcRef, charAnimState, mapCharState, charMovement, timeOfDay)); } return(npcCurrentMapRefs); }
public MapCharacter(NonPlayerCharacterReference npcRef, MapCharacterAnimationState mapCharacterAnimationState, MapCharacterState mapCharacterState, NonPlayerCharacterMovement nonPlayerCharacterMovement, TimeOfDay timeOfDay) { NPCRef = npcRef; AnimationState = mapCharacterAnimationState; CharacterState = mapCharacterState; Movement = nonPlayerCharacterMovement; CurrentCharacterPosition.Floor = CharacterState == null? 0: CharacterState.TheCharacterPosition.Floor; if (CharacterState == null) { if (npcRef != null) { MoveNPCToDefaultScheduledPosition(timeOfDay); } } else { CurrentCharacterPosition.XY = new Point2D(CharacterState.TheCharacterPosition.X, CharacterState.TheCharacterPosition.Y); } }