Esempio n. 1
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, 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);
        }
Esempio n. 2
0
        public void SetCurrentMapType(SmallMapReferences.SingleMapReference singleMapReference, LargeMap.Maps largeMap, TimeOfDay timeOfDay, bool bLoadFromDisk)
        {
            List <NonPlayerCharacterReference> npcCurrentMapRefs = null;

            currentMapType = largeMap;

            // I may need make an additional save of state before wiping these mapcharacters out
            Characters.Clear();

            switch (largeMap)
            {
            case LargeMap.Maps.Small:
                LoadSmallMap(singleMapReference, timeOfDay, bLoadFromDisk);
                return;

            case LargeMap.Maps.Overworld:
                // we don't reload them because the over and underworld are only loaded at boot time
                break;

            case LargeMap.Maps.Underworld:
                break;
            }
            bool bIsLargeMap = largeMap != LargeMap.Maps.Small;

            if (bIsLargeMap)
            {
                for (int i = 0; i < MAX_MAP_CHARACTERS; i++)
                {
                    // the animations are out of order - so we use this reference to track it down
                    NonPlayerCharacterReference npcRef = bIsLargeMap ? null : npcCurrentMapRefs[i];
                    MapCharacterState           mapCharState;

                    MapCharacterAnimationState charAnimState = null;

                    NonPlayerCharacterMovement charMovement;

                    mapCharState  = null;
                    charMovement  = null;
                    charAnimState = CurrentAnimationState.GetCharacterState(i);

                    Characters.Add(new MapCharacter(npcRef, charAnimState, mapCharState, charMovement, timeOfDay));
                }
                //Debug.Assert(charAnimState.X == mapCharState.X);
                //Debug.Assert(charAnimState.Y == mapCharState.Y);
                //Debug.Assert(charAnimState.Floor == mapCharState.Floor);
            }
        }
Esempio n. 3
0
        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);
            }
        }