コード例 #1
0
        /// <summary>
        /// Builds a MpaCharacter from precreated objects - typically loaded from disk in advance
        /// </summary>
        /// <param name="npcRef"></param>
        /// <param name="mapCharacterAnimationState"></param>
        /// <param name="mapCharacterState"></param>
        /// <param name="nonPlayerCharacterMovement"></param>
        /// <param name="timeOfDay"></param>
        /// <param name="playerCharacterRecords"></param>
        public MapCharacter(NonPlayerCharacterReference npcRef, MapCharacterAnimationState mapCharacterAnimationState, MapCharacterState mapCharacterState,
                            NonPlayerCharacterMovement nonPlayerCharacterMovement, TimeOfDay timeOfDay, PlayerCharacterRecords playerCharacterRecords)
        {
            NPCRef         = npcRef;
            AnimationState = mapCharacterAnimationState;
            CharacterState = mapCharacterState;
            Movement       = nonPlayerCharacterMovement;
            PlayerCharacterRecord record = null;

            if (playerCharacterRecords != null)
            {
                Debug.Assert(npcRef != null);
                record = playerCharacterRecords.GetCharacterRecordByNPC(npcRef);
            }

            IsInParty = record != null && record.PartyStatus == PlayerCharacterRecord.CharacterPartyStatus.InParty;

            CurrentCharacterPosition.Floor = CharacterState?.TheCharacterPosition.Floor ?? 0;

            if (CharacterState == null)
            {
                if (npcRef != null)
                {
                    MoveNPCToDefaultScheduledPosition(timeOfDay);
                }
            }
            else
            {
                CurrentCharacterPosition.XY = new Point2D(CharacterState.TheCharacterPosition.X, CharacterState.TheCharacterPosition.Y);
            }
        }
コード例 #2
0
        /// <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,
                                                                PlayerCharacterRecords playerCharacterRecords, bool bLoadFromDisk)
        {
            List <NonPlayerCharacterReference> npcCurrentMapRefs = null;

            npcCurrentMapRefs = NPCRefs.GetNonPlayerCharactersByLocation(singleMapReference.MapLocation);
            if (bLoadFromDisk)
            {
                Debug.WriteLine("Loading character positions from disk...");
                _smallMapAnimationStates.Load(MapCharacterAnimationStates.MapCharacterAnimationStatesFiles.SAVED_GAM, bLoadFromDisk);
            }
            else
            {
                Debug.WriteLine("Loading default character positions...");
            }

            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 = 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, playerCharacterRecords));
            }
            return(npcCurrentMapRefs);
        }
コード例 #3
0
 internal static Point2D GetAdjustedPos(Point2D xy, VirtualMap.Direction direction)
 {
     return(NonPlayerCharacterMovement.GetAdjustedPos(xy, GetDirection(direction)));
 }