public void SetQuest(ActiveQuestBase currentQuest) { RemoveListeners(previous); if (currentQuest is ActiveWalkingQuest) { ActiveWalkingQuest awq = currentQuest as ActiveWalkingQuest; awq.AmountSoFar.OnChange.AddListener(OnChange); } else if (currentQuest is ActiveQuest <int, IntVariable, UnityEventInt> ) { ActiveQuest <int, IntVariable, UnityEventInt> awq = currentQuest as ActiveQuest <int, IntVariable, UnityEventInt>; awq.AmountSoFar.OnChange.AddListener(OnChange); } else if (currentQuest is ReachValueQuest) { var awq = currentQuest as ReachValueQuest; awq.TotalAmount.OnChange.AddListener(OnChange); } var prog = currentQuest.GetProgress(); ProgressText.text = $"{prog.current} / {prog.max}"; ProgressFill.rectTransform.anchorMax = ProgressFill.rectTransform.anchorMax.SetX(Mathf.Clamp01((float)(prog.current / prog.max))); QuestTitle.text = currentQuest.DisplayName; previous = currentQuest; }
public void SetQuest(ActiveQuestBase quest) { AreaManager.Instance.SetArea(quest.Area); QuestingStatWatcher.Instance.SetQuest(quest); MiningPoints.Instance.QuestChanged(quest); TutorialManager.Instance.QuestUpdated(quest); }
// Must do this due to Unity events... Is there a better way to do this? public void SetAreaFromQuest(ActiveQuestBase quest) { if (quest.Area != Area) { SetArea(quest.Area); } }
public void SetCurrentQuest(ActiveQuestBase quest) { quest.CleanUp(); if (quest.Area != currentArea) { AreaChangeAndFadeObject.SetActive(true); AreaChangeInterpolater.StartLerping(() => { DataManager.Instance.Followers.Clear(); DeadEnemyController.Instance.ClearEnemies(); CurrentQuest.Value = quest; SetQuest(quest); quest.StartQuest(FinishQuest); AreaChangeInterpolater.StartReverseLerp(() => { AreaChangeAndFadeObject.SetActive(false); QuestDialogUI.SetConversation(quest.StartConversation, () => { // Check that the quest isn't finished (for reach quests) if (quest.IsFinished()) { FinishQuest(quest); } if (quest is BossQuest) { InteractionController.Instance.StartBossFight(); } }); }); }); } else { CurrentQuest.Value = quest; SetQuest(quest); quest.StartQuest(FinishQuest); QuestDialogUI.SetConversation(quest.StartConversation, () => { if (quest.IsFinished()) { FinishQuest(quest); } if (quest is BossQuest) { InteractionController.Instance.StartBossFight(); } }); } currentArea = quest.Area; }
private void FinishQuest(ActiveQuestBase quest) { quest.CleanUp(); StatTracker.Instance.CompleteQuest(quest); if (quest.NextQuest != null) { CurrentQuest.Value = quest.NextQuest; } QuestDialogUI.SetConversation(quest.EndConversation, () => DropRewardAndAdvanceConversation(quest)); }
public void QuestUpdated(ActiveQuestBase Quest) { if (Quest == BlockingAndParryingTutorialStart) { ShowParryAndBlockColor.Value = true; } if (Quest == BlockingAndParryingTutorialEnd) { ShowParryAndBlockColor.Value = false; } }
public void QuestChanged(ActiveQuestBase a) { if (currentArea != a.Area) { currentArea = a.Area; Pool.Reset(); } areaPoints = a.MiningPoints; nextSpawnDistance.Clear(); foreach (var point in areaPoints) { nextSpawnDistance.Add(Random.Range(point.MinDistanceBetween, point.MaxDistanceBetween)); } }
private void AdvanceQuestAfterConversation(ActiveQuestBase q) { q.CleanUp(); if (q.NextQuest == null) { PopUp.SetPopUp( "You finished the quest! You may either continue in this area or switch quests using the quest book on your screen.", new[] { "ok" }, new Action[] { () => { } }); return; } SetCurrentQuest(q.NextQuest); }
void RemoveListeners(ActiveQuestBase previousQuest) { if (previousQuest == null) { return; } if (previousQuest is ActiveWalkingQuest) { ActiveWalkingQuest awq = previousQuest as ActiveWalkingQuest; awq.AmountSoFar.OnChange.RemoveListener(OnChange); } else if (previousQuest is ActiveEnemySlayerQuest) { ActiveEnemySlayerQuest awq = previousQuest as ActiveEnemySlayerQuest; awq.AmountSoFar.OnChange.RemoveListener(OnChange); } else if (previousQuest is ActiveItemCollectQuest) { ActiveItemCollectQuest awq = previousQuest as ActiveItemCollectQuest; awq.AmountSoFar.OnChange.RemoveListener(OnChange); } if (previousQuest is ActiveWalkingQuest) { ActiveWalkingQuest awq = previousQuest as ActiveWalkingQuest; awq.AmountSoFar.OnChange.RemoveListener(OnChange); } else if (previousQuest is ActiveQuest <int, IntVariable, UnityEventInt> ) { ActiveQuest <int, IntVariable, UnityEventInt> awq = previousQuest as ActiveQuest <int, IntVariable, UnityEventInt>; awq.AmountSoFar.OnChange.RemoveListener(OnChange); } else if (previousQuest is ReachValueQuest) { var q = previousQuest as ReachValueQuest; q.TotalAmount.OnChange.RemoveListener(OnChange); } }
void QuestChanged(ActiveQuestBase quest) { currentTime = 0; currentTimeToReach = Random.Range(quest.MinEnemyDropTime, quest.MaxEnemyDropTime); }
public void OnQuestChanged(ActiveQuestBase quest) { QuestChanged?.Invoke(quest); }
private void DropRewardAndAdvanceConversation(ActiveQuestBase q) { List <Item> todrops = new List <Item>(); foreach (var reward in q.QuestRewards) { Item it = reward.it; if (it.ShouldCreateNewInstanceWhenPlayerObtained()) { if (it is Weapon) { Weapon w = ScriptableObject.Instantiate(it) as Weapon; w.OnAfterObtained(); w.Level = reward.Level; if (reward.RandomRoll != -1) { w.Random = reward.RandomRoll; w.SetValuesBasedOnRandom(); } it = w; } else if (it is Armor) { Armor a = ScriptableObject.Instantiate(it) as Armor; a.OnAfterObtained(); a.Level = reward.Level; if (reward.RandomRoll != -1) { a.Random = reward.RandomRoll; a.SetValuesBasedOnRandom(); } it = a; } else if (it is Headgear) { Headgear a = ScriptableObject.Instantiate(it) as Headgear; a.OnAfterObtained(); a.Level = reward.Level; if (reward.RandomRoll != -1) { a.RandomRoll = reward.RandomRoll; a.SetValuesBasedOnRandom(); } it = a; } } todrops.Add(it); } if (todrops.Count == 0) { AdvanceQuestAfterConversation(q); } else { DraggableWorld.Disable2(); ScrollArrow.SetActive(false); ItemDropManager.AddItems(todrops, null, () => { ScrollArrow.SetActive(true); DraggableWorld.Enable2(); AdvanceQuestAfterConversation(q); Inventory.AddItems(todrops); }); } }
public void CompleteQuest(ActiveQuestBase quest) { CompletedQuests.Add(quest); }