示例#1
0
        void Update()
        {
            // Do nothing if not ready
            if (!ReadyCheck())
            {
                return;
            }

            // Update local world information whenever player map pixel changes
            DFPosition pos = CurrentMapPixel;

            if (pos.X != lastMapPixelX || pos.Y != lastMapPixelY)
            {
                RaiseOnMapPixelChangedEvent(pos);
                UpdateWorldInfo(pos.X, pos.Y);

                // Clear non-permanent scenes from cache, unless going to/from owned ship
                DFPosition shipCoords = DaggerfallBankManager.GetShipCoords();
                if (shipCoords == null || (!(pos.X == shipCoords.X && pos.Y == shipCoords.Y) && !(lastMapPixelX == shipCoords.X && lastMapPixelY == shipCoords.Y)))
                {
                    SaveLoadManager.ClearSceneCache(false);
                }

                lastMapPixelX          = pos.X;
                lastMapPixelY          = pos.Y;
                isPlayerInLocationRect = false;
            }

            // Raise other events
            RaiseEvents();

            // Check if player is inside actual location rect
            PlayerLocationRectCheck();
        }
示例#2
0
        void Update()
        {
            // Do nothing if not ready
            if (!ReadyCheck())
            {
                return;
            }

            // Update local world information whenever player map pixel changes
            DFPosition pos = CurrentMapPixel;

            if (pos.X != lastMapPixelX || pos.Y != lastMapPixelY)
            {
                RaiseOnMapPixelChangedEvent(pos);
                UpdateWorldInfo(pos.X, pos.Y);

                // Clear non-permanent scenes from cache, unless going to/from owned ship
                DFPosition shipCoords = DaggerfallBankManager.GetShipCoords();
                if (shipCoords == null || (!(pos.X == shipCoords.X && pos.Y == shipCoords.Y) && !(lastMapPixelX == shipCoords.X && lastMapPixelY == shipCoords.Y)))
                {
                    SaveLoadManager.ClearSceneCache(false);
                }

                lastMapPixelX = pos.X;
                lastMapPixelY = pos.Y;
            }

            // Raise other events
            RaiseEvents();

            // Check if player is inside actual location rect
            PlayerLocationRectCheck();

            // Update nearby objects
            nearbyObjectsUpdateTimer += Time.deltaTime;
            if (nearbyObjectsUpdateTimer > refreshNearbyObjectsInterval)
            {
                UpdateNearbyObjects();
                nearbyObjectsUpdateTimer = 0;
            }

            // Snap back to physical world boundary to prevent player running off edge of world
            // Setting to approx. 10000 inches (254 metres) in from edge so end of world not so visible
            if (WorldX < 10000 ||       // West
                WorldZ > 16370000 ||    // North
                WorldZ < 10000 ||       // South
                WorldX > 32750000)      // East
            {
                gameObject.transform.position = lastFramePosition;
            }

            // Record player's last frame position
            lastFramePosition = gameObject.transform.position;
        }
 // Performs cleanup before starting a new character or loading a classic save
 void NewCharacterCleanup()
 {
     DaggerfallUnity.ResetUID();
     QuestMachine.Instance.ClearState();
     DaggerfallUI.Instance.PopToHUD();
     SaveLoadManager.ClearSceneCache(true);
     GameManager.Instance.GuildManager.ClearMembershipData();
     GameManager.Instance.PlayerGPS.ClearDiscoveryData();
     RaiseOnNewGameEvent();
     ResetWeaponManager();
 }
        // Start new character to location specified in INI
        void StartNewCharacter()
        {
            DaggerfallUnity.ResetUID();
            QuestMachine.Instance.ClearState();
            RaiseOnNewGameEvent();
            DaggerfallUI.Instance.PopToHUD();
            ResetWeaponManager();
            SaveLoadManager.ClearSceneCache(true);
            GameManager.Instance.GuildManager.ClearMembershipData();

            // Must have a character document
            if (characterDocument == null)
            {
                characterDocument = new CharacterDocument();
            }

            // Assign character sheet
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.AssignCharacter(characterDocument);

            // Set game time
            DaggerfallUnity.Instance.WorldTime.Now.SetClassicGameStartTime();

            // Set time tracked in playerEntity
            playerEntity.LastGameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            // Get start parameters
            DFPosition mapPixel       = new DFPosition(DaggerfallUnity.Settings.StartCellX, DaggerfallUnity.Settings.StartCellY);
            bool       startInDungeon = DaggerfallUnity.Settings.StartInDungeon;

            // Read location if any
            DFLocation location = new DFLocation();

            ContentReader.MapSummary mapSummary;
            bool hasLocation = DaggerfallUnity.Instance.ContentReader.HasLocation(mapPixel.X, mapPixel.Y, out mapSummary);

            if (hasLocation)
            {
                if (!DaggerfallUnity.Instance.ContentReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex, out location))
                {
                    hasLocation = false;
                }
            }

            if (NoWorld)
            {
                playerEnterExit.DisableAllParents();
            }
            else
            {
                // Start at specified location
                StreamingWorld streamingWorld = FindStreamingWorld();
                if (hasLocation && startInDungeon && location.HasDungeon)
                {
                    if (streamingWorld)
                    {
                        streamingWorld.TeleportToCoordinates(mapPixel.X, mapPixel.Y);
                        streamingWorld.suppressWorld = true;
                    }
                    playerEnterExit.EnableDungeonParent();
                    playerEnterExit.StartDungeonInterior(location);
                }
                else
                {
                    playerEnterExit.EnableExteriorParent();
                    if (streamingWorld)
                    {
                        streamingWorld.SetAutoReposition(StreamingWorld.RepositionMethods.Origin, Vector3.zero);
                        streamingWorld.suppressWorld = false;
                    }
                }
            }

            // Assign starting gear to player entity
            DaggerfallUnity.Instance.ItemHelper.AssignStartingGear(playerEntity, characterDocument.classIndex, characterDocument.isCustom);

            // Assign starting spells to player entity
            SetStartingSpells(playerEntity);

            // Apply biography effects to player entity
            BiogFile.ApplyEffects(characterDocument.biographyEffects, playerEntity);

            // Setup bank accounts and houses
            Banking.DaggerfallBankManager.SetupAccounts();
            Banking.DaggerfallBankManager.SetupHouses();

            // Initialize region data
            playerEntity.InitializeRegionData();

            // Randomize weathers
            GameManager.Instance.WeatherManager.SetClimateWeathers();

            // Start game
            GameManager.Instance.PauseGame(false);
            DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();
            DaggerfallUI.PostMessage(PostStartMessage);

            lastStartMethod = StartMethods.NewCharacter;

            // Offer main quest during pre-alpha
            QuestMachine.Instance.InstantiateQuest("__MQSTAGE00");

            // Launch startup optional quest
            if (!string.IsNullOrEmpty(LaunchQuest))
            {
                QuestMachine.Instance.InstantiateQuest(LaunchQuest);
                LaunchQuest = string.Empty;
            }
            // Launch any InitAtGameStart quests
            GameManager.Instance.QuestListsManager.InitAtGameStartQuests();

            if (OnStartGame != null)
            {
                OnStartGame(this, null);
            }
        }