Beispiel #1
0
        public virtual void ActivateObjective(TaskObjective objective)
        {
            AnalyticsHelper.FireEvent("ActivateObjective", new Dictionary <string, object>()
            {
                { "Id", objective.Id },
                { "Title", objective.Title }
            });

            lock (m_activatedObjectives)
            {
                m_activatedObjectives.Add(objective.Id);
            }

            Save();

            if (ObjectivesUpdated != null)
            {
                ObjectivesUpdated(this, EventArgs.Empty);
            }

            if (Updated != null)
            {
                Updated(this, EventArgs.Empty);
            }
        }
 // ProcessTaskObjectiveCollision()
 private void ProcessTaskObjectiveCollision(TaskObjective obj)
 {
     // IF the objective has NOT been achieved...
     if (!obj.achieved)
     {
         // IF the task objective does NOT require interaction |OR| The interaction key is down...
         if (!obj.requresInteraction || Input.GetKey(interactKey))
         {
             // Trying to remove the task objective from the task queue
             int index = taskQueue.IndexOf(obj);
             if (index == 0)
             {
                 obj.achieved = true;
                 taskQueue.Remove(obj);
             }
             if (index > 0)
             {
                 Debug.Log("\tPlayer tried to complete [ " + obj.gameObject.name + " ] task before completing current task.");
             }
             else
             {
                 Debug.LogWarning("\t[ TaskObjective ] script attached to [ " + obj.gameObject.name + " ] was not found in [ taskQueue ]!");
             }
             UpdateTask();
         }
     }
 }
Beispiel #3
0
        public IPlayerTaskDriver GetTaskDriverForObjective(TaskObjective objective)
        {
            if (objective != null)
            {
                return(GetTaskDriverForObjective(objective.Id));
            }

            return(null);
        }
Beispiel #4
0
        public bool IsObjectiveComplete(TaskObjective objective)
        {
            if (objective != null)
            {
                return(IsObjectiveComplete(objective.Id));
            }

            return(false);
        }
    // OnCollisionStay()
    private void OnCollisionStay(Collision other)
    {
        TaskObjective obj = other.gameObject.GetComponent <TaskObjective>();

        if (obj != null)
        {
            ProcessTaskObjectiveCollision(obj);
        }
    }
Beispiel #6
0
        public void OverrideTodoObjective(TaskObjective objective)
        {
            if (objective != null)
            {
                SetTodoTask(null);

                m_todoIsOverride = true;

                m_currTodoObjective = objective;

                ThreadHelper.Instance.CallExclusive(RaiseEvent);
            }
        }
Beispiel #7
0
        public void OverrideTodoTask(IPlayerTaskDriver driver)
        {
            if (driver != null)
            {
                m_currTodoObjective = null;

                m_todoIsOverride = true;

                SetTodoTask(driver);

                ThreadHelper.Instance.CallExclusive(RaiseEvent);
            }
        }
Beispiel #8
0
        public virtual void CompleteObjective(TaskObjective objective, bool commit = true)
        {
            AnalyticsHelper.FireEvent("CompleteObjective", new Dictionary <string, object>()
            {
                { "Id", objective.Id },
                { "Title", objective.Title }
            });

            lock (m_completedObjectives)
            {
                CompleteObjectiveState os = null;

                if (!m_completedObjectives.TryGetValue(objective.Id, out os))
                {
                    os = new CompleteObjectiveState();

                    m_completedObjectives[objective.Id] = os;
                }

                os.Objective = objective;
                os.Count++;
            }

            if (commit)
            {
                Save();

                UpdateAssignments();

                if (ObjectivesUpdated != null)
                {
                    ObjectivesUpdated(this, EventArgs.Empty);
                }

                if (Updated != null)
                {
                    Updated(this, EventArgs.Empty);
                }
            }
        }
Beispiel #9
0
        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);
        }