Beispiel #1
0
        public void RestoreSaveData(QuestSaveData_v1 data)
        {
            // Restore base state
            uid                = data.uid;
            questComplete      = data.questComplete;
            questSuccess       = data.questSuccess;
            questName          = data.questName;
            displayName        = data.displayName;
            questStartTime     = data.questStartTime;
            questTombstoned    = data.questTombstoned;
            questTombstoneTime = data.questTombstoneTime;

            // Restore active log messages
            activeLogMessages.Clear();
            foreach (LogEntry logEntry in data.activeLogMessages)
            {
                activeLogMessages.Add(logEntry.stepID, logEntry);
            }

            // Restore messages
            messages.Clear();
            foreach (Message.MessageSaveData_v1 messageData in data.messages)
            {
                Message message = new Message(this);
                message.RestoreSaveData(messageData);
                messages.Add(message.ID, message);
            }

            // Restore resources
            resources.Clear();
            foreach (QuestResource.ResourceSaveData_v1 resourceData in data.resources)
            {
                // Construct deserialized QuestResource based on type
                System.Reflection.ConstructorInfo ctor = resourceData.type.GetConstructor(new Type[] { typeof(Quest) });
                QuestResource resource = (QuestResource)ctor.Invoke(new object[] { this });

                // Restore state
                resource.RestoreResourceSaveData(resourceData);
                resources.Add(resource.Symbol.Name, resource);
            }

            // Restore questors
            questors.Clear();
            if (data.questors != null)
            {
                questors = data.questors;
            }

            // Restore tasks
            tasks.Clear();
            foreach (Task.TaskSaveData_v1 taskData in data.tasks)
            {
                Task task = new Task(this);
                task.RestoreSaveData(taskData);
                tasks.Add(task.Symbol.Name, task);
            }
        }
        /// <summary>
        /// Raise skills if conditions are met.
        /// </summary>
        public void RaiseSkills()
        {
            const int youAreNowAMasterOfTextID = 4020;

            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            if ((now.ToClassicDaggerfallTime() - timeOfLastSkillIncreaseCheck) <= 360)
            {
                return;
            }

            timeOfLastSkillIncreaseCheck = now.ToClassicDaggerfallTime();

            for (short i = 0; i < skillUses.Length; i++)
            {
                int   skillAdvancementMultiplier  = DaggerfallSkills.GetAdvancementMultiplier((DFCareer.Skills)i);
                float careerAdvancementMultiplier = Career.AdvancementMultiplier;
                int   usesNeededForAdvancement    = FormulaHelper.CalculateSkillUsesForAdvancement(skills.GetPermanentSkillValue(i), skillAdvancementMultiplier, careerAdvancementMultiplier, level);
                if (skillUses[i] >= usesNeededForAdvancement)
                {
                    skillUses[i] = 0;

                    if (skills.GetPermanentSkillValue(i) < 100 && (skills.GetPermanentSkillValue(i) < 95 || !AlreadyMasteredASkill()))
                    {
                        skills.SetPermanentSkillValue(i, (short)(skills.GetPermanentSkillValue(i) + 1));
                        SetCurrentLevelUpSkillSum();
                        DaggerfallUI.Instance.PopupMessage(HardStrings.skillImprove.Replace("%s", DaggerfallUnity.Instance.TextProvider.GetSkillName((DFCareer.Skills)i)));
                        if (skills.GetPermanentSkillValue(i) == 100)
                        {
                            List <DFCareer.Skills> primarySkills = GetPrimarySkills();
                            if (primarySkills.Contains((DFCareer.Skills)i))
                            {
                                ITextProvider    textProvider = DaggerfallUnity.Instance.TextProvider;
                                TextFile.Token[] tokens;
                                tokens = textProvider.GetRSCTokens(youAreNowAMasterOfTextID);
                                if (tokens != null && tokens.Length > 0)
                                {
                                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                                    messageBox.SetTextTokens(tokens);
                                    messageBox.ClickAnywhereToClose        = true;
                                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                                    messageBox.Show();
                                }
                                DaggerfallUI.Instance.PlayOneShot(SoundClips.ArenaFanfareLevelUp);
                            }
                        }
                    }
                }
            }

            if (CheckForLevelUp())
            {
                DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenCharacterSheetWindow);
            }
        }
Beispiel #3
0
    /**
     * Starts the timer if it's not already running AND if the timer isn't already complete
     * @returns true if the timer was started, false otherwise
     **/
    public bool start()
    {
        if (complete)
        {
            return(false);
        }

        startedAt = new DaggerfallDateTime();
        startedAt.FromSeconds(worldTime.Now.ToSeconds());

        running = true;
        return(true);
    }
        protected void TrainSkill(DFCareer.Skills skillToTrain)
        {
            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime();
            now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3);
            playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180);
            int   skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain);
            short tallyAmount = (short)(UnityEngine.Random.Range(10, 20 + 1) * skillAdvancementMultiplier);

            playerEntity.TallySkill(skillToTrain, tallyAmount);
            DaggerfallUI.MessageBox(TrainSkillId);
        }
        void UpdateSelectedSaveInfo()
        {
            // Clear info if no save selected
            if (saveNameTextBox.Text.Length == 0 || savesList.SelectedIndex < 0)
            {
                screenshotPanel.BackgroundTexture = null;
                saveVersionLabel.Text             = string.Empty;
                saveFolderLabel.Text             = string.Empty;
                saveTimeLabel.Text               = string.Empty;
                gameTimeLabel.Text               = string.Empty;
                renameSaveButton.BackgroundColor = namePanelBackgroundColor;
                deleteSaveButton.BackgroundColor = namePanelBackgroundColor;
                return;
            }

            // Get save key
            int key = GameManager.Instance.SaveLoadManager.FindSaveFolderByNames(currentPlayerName, saveNameTextBox.Text);

            if (key == -1)
            {
                return;
            }

            // Destroy old background texture
            if (screenshotPanel.BackgroundTexture)
            {
                UnityEngine.Object.Destroy(screenshotPanel.BackgroundTexture);
                screenshotPanel.BackgroundTexture = null;
            }

            // Get save info and texture
            string      path        = GameManager.Instance.SaveLoadManager.GetSaveFolder(key);
            SaveInfo_v1 saveInfo    = GameManager.Instance.SaveLoadManager.GetSaveInfo(key);
            Texture2D   saveTexture = GameManager.Instance.SaveLoadManager.GetSaveScreenshot(key);

            if (saveTexture != null)
            {
                screenshotPanel.BackgroundTexture = saveTexture;
            }

            // Show save info
            DaggerfallDateTime dfDateTime = new DaggerfallDateTime();

            dfDateTime.FromSeconds(saveInfo.dateAndTime.gameTime);
            saveVersionLabel.Text            = string.Format("V{0}", saveInfo.saveVersion);
            saveFolderLabel.Text             = Path.GetFileName(path);
            saveTimeLabel.Text               = DateTime.FromBinary(saveInfo.dateAndTime.realTime).ToLongDateString();
            gameTimeLabel.Text               = dfDateTime.MidDateTimeString();
            renameSaveButton.BackgroundColor = saveButtonBackgroundColor;
            deleteSaveButton.BackgroundColor = cancelButtonBackgroundColor;
        }
        private void QuestCompleteMessage_OnClose()
        {
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            // Train the skill, for free
            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime();
            now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3);
            playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180);
            int   skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skill);
            short tallyAmount = (short)(UnityEngine.Random.Range(10, 20 + 1) * skillAdvancementMultiplier);

            playerEntity.TallySkill(skill, tallyAmount);
        }
Beispiel #7
0
        public static string GetLoanDueDateString(int regionIndex)
        {
            if (BankAccounts[regionIndex].loanDueDate <= 0)
            {
                return("");
            }
            if (dateTime == null)
            {
                dateTime = new DaggerfallDateTime();
            }
            dateTime.FromClassicDaggerfallTime(BankAccounts[regionIndex].loanDueDate);
            string timeString = dateTime.DateString();

            return(timeString);
        }
Beispiel #8
0
        public override bool CheckTrigger(Task caller)
        {
            // Get live world time
            DaggerfallDateTime worldTime = DaggerfallUnity.Instance.WorldTime.Now;
            int currentDailySeconds      = ToDailySeconds(worldTime.Hour, worldTime.Minute);

            // Check if inside range
            if (currentDailySeconds >= minDailySeconds && currentDailySeconds <= maxDailySeconds)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Marks quest as tombstoned and schedules for eventual deletion.
        /// </summary>
        public void TombstoneQuest()
        {
            questTombstoned    = true;
            questComplete      = true;
            questTombstoneTime = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);

            Message messageRumors;
            Message messageQuestor;

            // add RumorsPostSuccess, RumorsPostFailure, QuestorPostSuccess or QuestorPostFailure rumor to rumor mill
            if (questSuccess)
            {
                messageRumors  = GetMessage((int)QuestMachine.QuestMessages.RumorsPostSuccess);
                messageQuestor = GetMessage((int)QuestMachine.QuestMessages.QuestorPostSuccess);
            }
            else
            {
                messageRumors  = GetMessage((int)QuestMachine.QuestMessages.RumorsPostFailure);
                messageQuestor = GetMessage((int)QuestMachine.QuestMessages.QuestorPostFailure);
            }
            if (messageRumors != null)
            {
                GameManager.Instance.TalkManager.AddOrReplaceQuestProgressRumor(this.UID, messageRumors);
            }
            if (messageQuestor != null)
            {
                GameManager.Instance.TalkManager.AddQuestorPostQuestMessage(this.UID, messageQuestor);
            }

            // remove quest rumors (rumor mill command) for this quest from talk manager
            GameManager.Instance.TalkManager.RemoveQuestRumorsFromRumorMill(this.UID);

            // remove all quest topics for this quest from talk manager
            GameManager.Instance.TalkManager.RemoveQuestInfoTopicsForSpecificQuest(this.UID);

            // undiscover all quest residences used by this quest
            QuestResource[] allQuestResources = this.GetAllResources(typeof(Place)); // Get list of place quest resources
            for (int i = 0; i < allQuestResources.Length; i++)
            {
                Place place = (Place)allQuestResources[i];
                GameManager.Instance.PlayerGPS.UndiscoverBuilding(place.SiteDetails.buildingKey, true, place.SiteDetails.buildingName);
            }

            // Remove all questors for this quest
            DropAllQuestors();
        }
        protected void TrainSkillIntense(DFCareer.Skills skillToTrain)
        {
            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            now.RaiseTime(DaggerfallDateTime.SecondsPerDay * 4);
            playerEntity.Skills.SetPermanentSkillValue(skillToTrain, (short)(playerEntity.Skills.GetPermanentSkillValue(skillToTrain) + 4));

            TrainSkill(skillToTrain);

            TextFile.Token[] intenseTokens =
            {
                TextFile.CreateTextToken("You have spent the last 4 days intensively training your "),  newLine,
                TextFile.CreateTextToken(skillToTrain + " skill, and have improved it significantly."), newLine,newLine,
                TextFile.CreateTextToken("Now it's time to begin your fifth and final session...")
            };
            DaggerfallUI.MessageBox(intenseTokens);
        }
Beispiel #11
0
        public override void RestoreSaveData(object dataIn)
        {
            if (dataIn == null)
            {
                return;
            }

            SaveData_v1 data = (SaveData_v1)dataIn;

            lastWorldTimeSample    = data.lastWorldTimeSample;
            startingTimeInSeconds  = data.startingTimeInSeconds;
            remainingTimeInSeconds = data.remainingTimeInSeconds;
            flag          = data.flag;
            minRange      = data.minRange;
            maxRange      = data.maxRange;
            clockEnabled  = data.clockEnabled;
            clockFinished = data.clockFinished;
        }
        public void TrainingSkill_OnItemPicked(int index, string skillName)
        {
            CloseWindow();
            List <DFCareer.Skills> trainingSkills;

            if (guildTrainingSkills.TryGetValue(service, out trainingSkills))
            {
                DFCareer.Skills skillToTrain = trainingSkills[index];
                int             maxTraining  = 50;
                if (DaggerfallSkills.IsLanguageSkill(skillToTrain))     // BCHG: Language skill training is capped by char intelligence instead of 50%
                {
                    maxTraining = playerEntity.Stats.PermanentIntelligence;
                }

                if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > maxTraining)
                {
                    // Inform player they're too skilled to train
                    TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId);
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                    messageBox.SetTextTokens(tokens, this);
                    messageBox.ClickAnywhereToClose = true;
                    uiManager.PushWindow(messageBox);
                }
                else
                {   // Train the skill
                    DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;
                    playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime();
                    now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3);
                    playerEntity.DeductGoldAmount(GetServicePrice());
                    playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180);
                    int   skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain);
                    short tallyAmount = (short)(UnityEngine.Random.Range(10, 21) * skillAdvancementMultiplier);
                    playerEntity.TallySkill(skillToTrain, tallyAmount);
                    DaggerfallUI.MessageBox(TrainSkillId);
                }
            }
            else
            {
                Debug.LogError("Invalid skill selected for training.");
            }
        }
Beispiel #13
0
        /// <summary>
        /// Marks quest as tombstoned and schedules for eventual deletion.
        /// </summary>
        public void TombstoneQuest()
        {
            questTombstoned    = true;
            questComplete      = true;
            questTombstoneTime = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);

            Message messageRumors;
            Message messageQuestor;

            // add RumorsPostSuccess, RumorsPostFailure, QuestorPostSuccess or QuestorPostFailure rumor to rumor mill
            if (questSuccess)
            {
                messageRumors  = GetMessage((int)QuestMachine.QuestMessages.RumorsPostSuccess);
                messageQuestor = GetMessage((int)QuestMachine.QuestMessages.QuestorPostSuccess);
            }
            else
            {
                messageRumors  = GetMessage((int)QuestMachine.QuestMessages.RumorsPostFailure);
                messageQuestor = GetMessage((int)QuestMachine.QuestMessages.QuestorPostFailure);
            }
            if (messageRumors != null)
            {
                GameManager.Instance.TalkManager.AddOrReplaceQuestProgressRumor(this.UID, messageRumors);
            }
            if (messageQuestor != null)
            {
                GameManager.Instance.TalkManager.AddQuestorPostQuestMessage(this.UID, messageQuestor);
            }

            // remove quest rumors (rumor mill command) for this quest from talk manager
            GameManager.Instance.TalkManager.RemoveQuestRumorsFromRumorMill(this.UID);

            // remove all quest topics for this quest from talk manager
            GameManager.Instance.TalkManager.RemoveQuestInfoTopicsForSpecificQuest(this.UID);

            // Remove all questors for this quest
            DropAllQuestors();
        }
        protected virtual void TrainingService()
        {
            // Check enough time has passed since last trained
            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            if ((now.ToClassicDaggerfallTime() - playerEntity.TimeOfLastSkillTraining) < 720)
            {
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingToSoonId);
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                messageBox.SetTextTokens(tokens);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
            else
            {   // Offer training price
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId);
                messageBox.SetTextTokens(tokens, Guild);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTraining_OnButtonClick;
                messageBox.Show();
            }
        }
Beispiel #15
0
        public void RestoreSaveData(QuestSaveData_v1 data)
        {
            // Restore base state
            uid                = data.uid;
            questComplete      = data.questComplete;
            questSuccess       = data.questSuccess;
            questName          = data.questName;
            displayName        = data.displayName;
            factionId          = data.factionId;
            questStartTime     = data.questStartTime;
            questTombstoned    = data.questTombstoned;
            questTombstoneTime = data.questTombstoneTime;

            // Restore active log messages
            activeLogMessages.Clear();
            foreach (LogEntry logEntry in data.activeLogMessages)
            {
                activeLogMessages.Add(logEntry.stepID, logEntry);
            }

            // Restore messages
            messages.Clear();
            foreach (Message.MessageSaveData_v1 messageData in data.messages)
            {
                Message message = new Message(this);
                message.RestoreSaveData(messageData);
                messages.Add(message.ID, message);
            }

            // Restore resources
            resources.Clear();
            foreach (QuestResource.ResourceSaveData_v1 resourceData in data.resources)
            {
                // Construct deserialized QuestResource based on type
                System.Reflection.ConstructorInfo ctor = resourceData.type.GetConstructor(new Type[] { typeof(Quest) });
                QuestResource resource = (QuestResource)ctor.Invoke(new object[] { this });

                // Restore state
                resource.RestoreResourceSaveData(resourceData);
                resources.Add(resource.Symbol.Name, resource);
            }

            // Restore questors
            questors.Clear();
            if (data.questors != null)
            {
                questors = data.questors;
            }

            // Restore tasks
            tasks.Clear();
            foreach (Task.TaskSaveData_v1 taskData in data.tasks)
            {
                Task task = new Task(this);
                task.RestoreSaveData(taskData);
                tasks.Add(task.Symbol.Name, task);
            }

            // May need to remap old marker system at end of load for each Place resource
            QuestResource[] foundPlaces = GetAllResources(typeof(Place));
            if (foundPlaces != null && foundPlaces.Length > 0)
            {
                foreach (QuestResource place in foundPlaces)
                {
                    (place as Place).ReassignSiteDetailsLegacyMarkers();
                }
            }
        }
Beispiel #16
0
 /// <summary>
 /// Marks quest as tombstoned and schedules for eventual deletion.
 /// </summary>
 public void TombstoneQuest()
 {
     questTombstoned    = true;
     questComplete      = true;
     questTombstoneTime = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);
 }
        void DisplaySaveStatsGUI()
        {
            if (currentSaveTree == null)
            {
                return;
            }

            SaveTreeBaseRecord positionRecord = currentSaveTree.FindRecord(RecordTypes.CharacterPositionRecord);

            EditorGUILayout.Space();
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Version"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(currentSaveTree.Header.Version.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                string positionText = string.Format("X={0}, Y={1}, Z={2}",
                                                    positionRecord.RecordRoot.Position.WorldX,
                                                    positionRecord.RecordRoot.Position.WorldY,
                                                    positionRecord.RecordRoot.Position.WorldZ);

                EditorGUILayout.LabelField(new GUIContent("Player Position", "Position of player in the world."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(positionText, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                DFPosition mapPixel = MapsFile.WorldCoordToMapPixel(positionRecord.RecordRoot.Position.WorldX, positionRecord.RecordRoot.Position.WorldZ);
                string mapPixelText = string.Format("X={0}, Y={1}", mapPixel.X, mapPixel.Y);

                EditorGUILayout.LabelField(new GUIContent("Player Map Pixel", "Position of player on small map."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(mapPixelText, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                DaggerfallDateTime time = new DaggerfallDateTime();
                time.FromClassicDaggerfallTime(currentSaveVars.GameTime);

                EditorGUILayout.LabelField(new GUIContent("Player Time", "World time of this save."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(time.LongDateTimeString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Player Environment"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(((Environments)currentSaveTree.Header.Environment).ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("RecordElement records"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(currentSaveTree.RecordDictionary.Count.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            //GUILayoutHelper.Horizontal(() =>
            //{
            //    EditorGUILayout.LabelField(new GUIContent("Header.Unknown"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
            //    EditorGUILayout.SelectableLabel(currentSaveTree.Header.Unknown.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            //});
            //GUILayoutHelper.Horizontal(() =>
            //{
            //    EditorGUILayout.LabelField(new GUIContent("CharacterPosition.Unknown"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
            //    EditorGUILayout.SelectableLabel(currentSaveTree.Header.CharacterPosition.Unknown.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            //});
        }
Beispiel #18
0
 /// <summary>
 /// Start the quest.
 /// </summary>
 public void Start()
 {
     questStartTime = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);
 }
Beispiel #19
0
 /// <summary>
 /// Start the quest.
 /// </summary>
 public void Start()
 {
     questStartTime       = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);
     smallerDungeonsState = (DaggerfallUnity.Settings.SmallerDungeons) ? QuestSmallerDungeonsState.Enabled : QuestSmallerDungeonsState.Disabled;
 }
Beispiel #20
0
 public static int CreateStockedDate(DaggerfallDateTime date)
 {
     return((date.Year * 1000) + date.DayOfYear);
 }
Beispiel #21
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Quest()
 {
     uid            = DaggerfallUnity.NextUID;
     questStartTime = new DaggerfallDateTime(DaggerfallUnity.Instance.WorldTime.Now);
 }
Beispiel #22
0
        public override void Update(Task caller)
        {
            const int minHour  = 7;
            const int maxHour  = 18;
            const int minDelay = 40;
            const int maxDelay = 500;

            base.Update(caller);

            // "give pc anItem notify 1234" and "give pc anItem silently" require player
            // to be within a town, outdoors, and during set hours for action to fire
            if ((textId != 0 || silently) && !offerImmediately)
            {
                // Fail if conditions not met, but take note we are waiting
                DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;
                if (!GameManager.Instance.PlayerGPS.IsPlayerInTown(true, true) || now.Hour < minHour || now.Hour > maxHour)
                {
                    waitingForTown = true;
                    ticksUntilFire = 0;
                    return;
                }

                // If we were waiting then add a small random delay so messages don't all arrive at once
                if (waitingForTown)
                {
                    ticksUntilFire = UnityEngine.Random.Range(minDelay, maxDelay + 1);
                    waitingForTown = false;
                    RaiseOnOfferPendingEvent(this);
                }
            }

            // Reduce random delay until nothing is left
            // This is in questmachine ticks which is currently 10 ticks per second while game is running
            // Does not tick while game paused or resting - player must be actively in town walking around
            if (ticksUntilFire > 0)
            {
                ticksUntilFire--;
                return;
            }

            // Handle giving player nothing
            // This also shows QuestComplete message but does not give player loot
            if (isNothing)
            {
                OfferToPlayerWithQuestComplete(null);
                SetComplete();
                return;
            }

            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                Debug.LogErrorFormat("Could not find Item resource symbol {0}", itemSymbol);
                return;
            }

            // Give quest item to player based on command format
            if (textId != 0)
            {
                DirectToPlayerWithNotify(item);
            }
            else
            {
                if (silently)
                {
                    DirectToPlayerWithoutNotify(item);
                }
                else
                {
                    OfferToPlayerWithQuestComplete(item);
                }
            }

            offerImmediately = false;
            SetComplete();
        }
Beispiel #23
0
        static void PassTime(int timeRaised)
        {
            DaggerfallDateTime timeNow = DaggerfallUnity.Instance.WorldTime.Now;

            timeNow.RaiseTime(timeRaised);
        }
Beispiel #24
0
 private static int CalculateDaySinceZero(DaggerfallDateTime date)
 {
     return((date.Year * DaggerfallDateTime.DaysPerYear) + date.DayOfYear);
 }