public bool CanComplete(IPlayerTaskDriver driver) { if (driver != null && !driver.ActivationContext.IsClosed) { var task = driver.Task; if (driver.IsGiveTask) { if (task.ActionItems != null) { if (task.ActionItems.CollectibleCounts != null) { bool isMet = true; foreach (var cc in task.ActionItems.CollectibleCounts) { var count = Inventory.Instance.GetCount(cc.CollectibleId); if (count < cc.Count) { isMet = false; break; } } if (!isMet) { return(isMet); } } if (task.ActionItems.CurrencyCounts != null) { bool isMet = true; foreach (var cc in task.ActionItems.CurrencyCounts) { var count = Wallet.Instance.GetCount(cc.Currency); if (count < cc.Count) { isMet = false; break; } } if (!isMet) { return(isMet); } } } } // Other actions can be completed? return(true); } return(false); }
public virtual void AddNewTask(IPlayerTaskDriver driver) { if (ShouldShowNotification(driver)) { ThreadHelper.Instance.CallOnMainThread(() => { gameObject.SetActive(true); if (driver is LocationTaskDriver) { LocationTaskAnnotationHandler.Instance.SelectTaskAnnotation(driver as LocationTaskDriver); } TaskDriver = driver; var item = Table.AddItem(NotificationItem); item.Populate(driver); /* * var timer = * UnityTimer.Call(item.DisplayDuration, () => * { * Table.RemoveItem(item); * }); */ item.OnSelected.AddListener(() => { //timer.Cancel(); Select(item); }); }); } }
// TODO: everything below here is a bit of a grab-bag that needs a refactor. // Essentially, task driver delegates should handle the todo list in some way. // For now, we know what we want each one to do so we'll do it directly. void SetTodoTask(IPlayerTaskDriver driver) { // Don't preview complete/closed tasks if (driver != null && (driver.IsComplete || driver.ActivationContext.IsClosed)) { m_todoIsOverride = false; m_currTodoDriver = null; driver.SetFocus(false); return; } if (m_currTodoDriver != null && m_currTodoDriver != driver) { m_currTodoDriver.SetFocus(false); } m_currTodoDriver = driver; if (m_currTodoDriver != null) { m_currTodoDriver.SetFocus(true); } }
public void ClosePlayerTask(IPlayerTaskDriver driver) { if (driver != null) { driver.ActivationContext.Close(); } StopTask(driver, update: true); }
public virtual void Populate(IPlayerTaskDriver driver) { TaskDriver = driver; if (driver != null) { SetText(driver.Task.Title); } }
public void ClearOverrideTodoTask(IPlayerTaskDriver driver) { m_todoIsOverride = false; if (driver == m_currTodoDriver) { SetTodoTask(null); ThreadHelper.Instance.CallExclusive(RaiseEvent); } }
private void AddTask(IPlayerTaskDriver objTask, int idx) { var asnItem = new TaskAssignmentItem(m_currentDriver, objTask, idx); var item = AddSelectableItem(ItemPrefab, (_item) => { PopulateComponents(asnItem); }); item.Populate(asnItem); }
void UIModeChanged() { if (ARQuestAppUIManager.Instance.CurrentMode != ARQuestAppUIManager.Mode.AR) { // Clear complete task m_taskCompleteDriver = null; } else { SyncPanels(); } }
void StopTask(IPlayerTaskDriver driver, bool update = true) { driver.Stop(); if (update) { if (Updated != null) { Updated(this, EventArgs.Empty); } } }
void SyncPanels() { // 1. Show AssignmentComplete if required. // 2. Show guide. // 3. Show task complete. var assnDriver = TaskManager.Instance.FirstAssignment; if (ShowAssignmentComplete && AssignmentCompletePanel && assnDriver != null && assnDriver.IsComplete && ! assnDriver.ActivationContext.IsClosed) { PanelManager.Instance.Push(AssignmentCompletePanel, assnDriver, () => { SyncPanels(); }); if (TaskCompletePanel) { TaskCompletePanel.Back(); } if (GuidePanel) { GuidePanel.Back(); } // Either of these options undoes task complete m_taskCompleteDriver = null; } else if (m_guideData != null && GuidePanel) { PanelManager.Instance.Push(GuidePanel, m_guideData); if (TaskCompletePanel) { TaskCompletePanel.Back(); } m_taskCompleteDriver = null; } else if (m_taskCompleteDriver != null && ShowTaskComplete) { PanelManager.Instance.Push(TaskCompletePanel, m_taskCompleteDriver, () => { m_taskCompleteDriver = null; SyncPanels(); }); } }
public void OverrideTodoTask(IPlayerTaskDriver driver) { if (driver != null) { m_currTodoObjective = null; m_todoIsOverride = true; SetTodoTask(driver); ThreadHelper.Instance.CallExclusive(RaiseEvent); } }
public virtual void SelectTaskAnnotation(IPlayerTaskDriver taskDriver) { var annotations = m_taskAnnotations[taskDriver.ActivationContext.InstanceId]; if (annotations != null) { var ann = annotations.FirstOrDefault(); if (ann != null) { MapController.Instance.SelectAnnotation(ann); } } }
public virtual void ActivateLocationTask(ResourceActivationContext context, LocationTask task) { IPlayerTaskDriver driver = null; if (CreateLocationTaskDriver != null) { driver = CreateLocationTaskDriver(context, task); } else { driver = new LocationTaskDriver(context, task); } ActivatePlayerTaskDriver(context, driver); }
public void ActivateVisualMarkerTask(ResourceActivationContext context, VisualMarkerTask task) { IPlayerTaskDriver driver = null; if (CreateVisualMarkerTaskDriver != null) { driver = CreateVisualMarkerTaskDriver(context, task); } else { driver = new VisualMarkerTaskDriver(context, task); } ActivatePlayerTaskDriver(context, driver); }
protected virtual void ConfigureTaskItem(TaskItem item, IPlayerTaskDriver driver) { if (item.Driver.Task is LocationTask) { ConfigureLocationTaskItem(item); } else if (item.Driver.Task is CharacterTask) { ConfigureCharacterTaskItem(item); } else { ConfigureDefaultTaskItem(item); } }
public void ActivatePlayerTask(ResourceActivationContext context, PlayerTask task) { IPlayerTaskDriver driver = null; if (CreatePlayerTaskDriver != null) { driver = CreatePlayerTaskDriver(context, task); } else { driver = new PlayerTaskDriver <PlayerTask, IMinigameDriver>(context, task); } ActivatePlayerTaskDriver(context, driver); }
public void PushSuccessPanel(IPlayerTaskDriver driver) { var panel = PanelManager.Instance.GetPanel <QuizSuccessPanel>(); if (panel == null) { m_logger.Error(typeof(QuizSuccessPanel).ToString() + " not found."); return; } Action onStackClose = () => { TaskManager.Instance.Complete(driver, false); }; PanelManager.Instance.Push(k_quizStack, panel, driver, onStackClose); }
public List <Collectible> GetPlayerRewardCollectibles(IPlayerTaskDriver itemDriver) { var list = new List <Collectible>(); // TAKE TASK if (itemDriver.IsTakeTask && ((itemDriver.Task.ActionItems != null && itemDriver.Task.ActionItems.CollectibleCounts != null) || (itemDriver.Task.Reward != null && itemDriver.Task.Reward.CollectibleCounts != null))) { if (itemDriver.Task.ActionItems != null && itemDriver.Task.ActionItems.CollectibleCounts != null && itemDriver.Task.ActionItems.CollectibleCounts.Any()) { list.AddRange(itemDriver.Task.ActionItems.CollectibleCounts.Select(cc => cc.Collectible)); } if (itemDriver.Task.Reward != null && itemDriver.Task.Reward.CollectibleCounts != null && itemDriver.Task.Reward.CollectibleCounts.Any()) { list.AddRange(itemDriver.Task.Reward.CollectibleCounts.Select(cc => cc.Collectible)); } } // GIVE TASK or EXCHANGE TASK else if ((itemDriver.IsGiveTask) && itemDriver.Task.Reward != null && itemDriver.Task.Reward.CollectibleCounts != null) { if (itemDriver.Task.Reward.CollectibleCounts != null && itemDriver.Task.Reward.CollectibleCounts.Any()) { list.AddRange(itemDriver.Task.Reward.CollectibleCounts.Select(cc => cc.Collectible)); } } else { if (itemDriver.Task.Reward != null && itemDriver.Task.Reward.CollectibleCounts != null && itemDriver.Task.Reward.CollectibleCounts.Any()) { list.AddRange(itemDriver.Task.Reward.CollectibleCounts.Select(cc => cc.Collectible)); } } return(list); }
protected virtual T AddTaskItem <T>(T prefab, IPlayerTaskDriver driver) where T : TaskItem { var item = Table.AddItem <T>(prefab); item.ActionItemPrefab = ActionItemPrefab; item.OnSelected.AddListener(() => { OnItemSelected(item); }); item.OnAction.AddListener(() => { OnItemAction(item); }); item.Populate(driver); ConfigureTaskItem(item, driver); return(item); }
public override void Populate(IPlayerTaskDriver driver) { var locDriver = driver as LocationTaskDriver; if (Subtitle) { Subtitle.text = ""; if (locDriver.Task.Locations != null) { var loc = locDriver.Task.Locations.FirstOrDefault(); if (loc != null && Subtitle) { Subtitle.text = loc.Name; } } } base.Populate(driver); }
public void DeactivateTask(IPlayerTaskDriver driver) { if (m_drivers.ContainsKey(driver.ActivationContext.InstanceId)) { m_drivers.Remove(driver.ActivationContext.InstanceId); StopTask(driver, update: false); if (driver.Task.Outcomes != null) { foreach (var oc in driver.Task.Outcomes) { m_outcomeDrivers.Remove(oc.Id, driver); } } } if (Updated != null) { Updated(this, EventArgs.Empty); } }
// TODO: everything below here is a bit of a grab-bag that needs a refactor. // Essentially, task driver delegates should handle the todo list in some way. // For now, we know what we want each one to do so we'll do it directly. void SetTodoTask(IPlayerTaskDriver driver) { // Don't preview complete/closed tasks if (driver != null && (driver.IsComplete || driver.ActivationContext.IsClosed)) { m_currTodoDriver = null; driver.SetFocus(false); SetToDoPanel(null); return; } if (m_currTodoDriver != null && m_currTodoDriver != driver) { m_currTodoDriver.SetFocus(false); } m_currTodoDriver = driver; if (driver != null) { if (driver is LocationTaskDriver && LocationTaskAnnotationHandler.Instance) { var ann = LocationTaskAnnotationHandler.Instance.GetNearestAnnotation((LocationTaskDriver)driver); if (ann != null) { MapController.Instance.FocusAnnotation(ann); } else { SetToDoPanel(LocationTaskAnnotationHandler.Instance.SelectedLocationPanel, driver); } } else if (driver is ARTaskDriver && ARTaskAnnotationHandler.Instance) { var ann = ARTaskAnnotationHandler.Instance.GetNearestAnnotation((ARTaskDriver)driver); if (ann != null) { MapController.Instance.FocusAnnotation(ann); } else { SetToDoPanel(ARTaskAnnotationHandler.Instance.SelectedLocationPanel, driver); } } #if MOTIVE_VUFORIA else if (driver is VisualMarkerTaskDriver) { SetToDoPanel(VisualMarkerTaskPanel, driver); } #endif else if (driver.Task.Type == "motive.gaming.characterTask") { SetToDoPanel(CharacterTaskPanel, driver); } else { SetToDoPanel(SimpleTaskPanel, driver); } driver.SetFocus(true); } else { SetToDoPanel(null); } }
/// <summary> /// Sets the task complete panel for the given driver. /// </summary> /// <param name="taskDriver"></param> public void SetTaskComplete(IPlayerTaskDriver taskDriver) { m_taskCompleteDriver = taskDriver; ThreadHelper.Instance.CallExclusive(SyncPanels); }
protected QuizMinigameDriverBase(IPlayerTaskDriver taskDriver, T quizMinigame) { this.TaskDriver = taskDriver; this.Quiz = quizMinigame; }
public FreeResponseMinigameDriver(IPlayerTaskDriver taskDriver, FreeResponseQuiz quiz) : base(taskDriver, quiz) { }
void Update() { // Only update the preview panel if: // 1. There is no current panel, or // 2. The current driver is either inactive, complete, or closed // Otherwise we don't change anything because we want this panel to be // somewhat sticky. if (m_currTodoDriver != null && (!TaskManager.Instance.ActiveTaskDrivers.Contains(m_currTodoDriver) || m_currTodoDriver.IsComplete || m_currTodoDriver.ActivationContext.IsClosed)) { ClearTodoTask(m_currTodoDriver); } IPlayerTaskDriver driver = null; // Keep the current todo driver if it's an override and it's active. // Otherwise compute the best todo driver to show the user. if (m_currTodoDriver != null && m_todoIsOverride && TaskManager.Instance.ActiveTaskDrivers.Contains(m_currTodoDriver)) { driver = m_currTodoDriver; } else { m_todoIsOverride = false; // Todo: can we centralize the "todo" item into // one property? m_currTodoObjective = null; var adriver = TaskManager.Instance.FirstAssignment; if (adriver != null) { driver = TaskManager.Instance.GetActiveObjectiveTasks(adriver) .OrderBy(d => d.ActivationContext.ActivationTime) .FirstOrDefault(); } // Prioritize task drivers attached to the assignment, // fall back to the rest of the drivers. if (driver == null) { driver = TaskManager.Instance.ActiveTaskDrivers .OrderBy(d => d.ActivationContext.ActivationTime) .FirstOrDefault(); } } if (driver != null) { SetTodoTask(driver); } /* * Looking forward to attractions * else * { * var todo = AttractionManager.Instance.GetNextToDo(); * * if (todo != null) * { * var annotation = AttractionManager.Instance.GetAnnotation(todo.Attraction.Id); * * SetToDoPanel(AttractionManager.Instance.SelectedLocationPanel, annotation); * } * else * { * SetToDoPanel(null); * } * }*/ ThreadHelper.Instance.CallExclusive(RaiseEvent); }
/// <summary> /// Completes the task and optionally shows the reward screen for "take" items. /// </summary> /// <param name="driver"></param> /// <param name="showRewardScreenForTakeItems"></param> public virtual void Complete(IPlayerTaskDriver driver, bool showRewardScreenForTakeItems = true) { if (CanComplete(driver)) { var args = new Dictionary <string, object>() { { "Id", driver.Task.Id }, { "Title", driver.Task.Title } }; if (driver is LocationTaskDriver) { var location = ((LocationTaskDriver)driver).ActionLocation; if (location != null) { args["LocationName"] = location.Name; args["Coordinates"] = location.Coordinates.ToString(); if (location.LocationTypes != null) { args["LocationTypes"] = string.Join(",", location.LocationTypes); } if (location.StoryTags != null) { args["LocationStoryTags"] = string.Join(",", location.StoryTags); } } } AnalyticsHelper.FireEvent("CompleteTask", args); // Unless overridden, performing "action" completes this task driver.ActivationContext.FireEvent("complete"); var task = driver.Task; Action doClose = () => { if (task.Outcomes != null) { foreach (var o in task.Outcomes) { CompleteObjective(o, false); } // Update any assignments.. Save(); UpdateAssignments(); if (ObjectivesUpdated != null) { ObjectivesUpdated(this, EventArgs.Empty); } } if (!driver.Task.IsReplayable) { ClosePlayerTask(driver); } driver.DidComplete(); if (Updated != null) { Updated(this, EventArgs.Empty); } }; Action doReward = () => { if (task.Reward != null) { RewardManager.Instance.RewardValuables(task.Reward, doClose); } else { doClose(); } }; if (driver.IsGiveTask) { TransactionManager.Instance.RemoveValuables(task.ActionItems); doReward(); } else if (driver.IsTakeTask) { if (task.ActionItems != null) { // By default we show a reward screen any time a user // collects something. Set to false to add items // directly to the inventory. if (showRewardScreenForTakeItems) { RewardManager.Instance.RewardValuables(task.ActionItems, doClose); } else { TransactionManager.Instance.AddValuables(task.ActionItems); } } else { doReward(); } } else { doReward(); } } }
public virtual void ActivatePlayerTaskDriver(ResourceActivationContext context, IPlayerTaskDriver driver) { if (!context.IsClosed) { context.Open(); if (driver.Task.Outcomes != null) { foreach (var oc in driver.Task.Outcomes) { m_outcomeDrivers.Add(oc.Id, driver); } } m_drivers[context.InstanceId] = driver; // todo auto accept every task based on config option if (TaskManager.Instance.AutoAcceptTask) { driver.Accept(); // calls start } //else if (driver.IsAccepted) //{ // driver.Start(); //} if (context.IsFirstActivation) { if (TaskNotifier.Instance) { TaskNotifier.Instance.AddNewTask(driver); } } } else { // Track closed drivers, but don't do anything else with them. // This enables task views that store a "completed" task state. if (driver.Task.Outcomes != null) { foreach (var oc in driver.Task.Outcomes) { m_outcomeDrivers.Add(oc.Id, driver); } } m_drivers[context.InstanceId] = driver; } if (Updated != null) { Updated(this, EventArgs.Empty); } }
public TaskAssignmentItem(AssignmentDriver asnDriver, IPlayerTaskDriver driver, int idx = 0) : base(asnDriver, idx) { TaskDriver = driver; }
internal virtual void StopMinigame(IPlayerTaskDriver playerTaskDriver) { }