private void AssignQuestsFromSystemToPlayer(Quest[] quests)
        {
            _allQuests = new Quest[quests.Length];
            for (int i = 0; i < quests.Length; i++)
            {
                _allQuests[quests[i].ID] = quests[i];
            }
            for (int i = 0; i < _allQuests.Length; i++)
            {
                if (_allQuests[i].IsActiveNow)
                {
                    if (_allQuests[i] is EliminationQuest)
                    {
                        EliminationQuest eq = ScriptableObject.CreateInstance <EliminationQuest>();
                        eq.AssignValuesFromCode(_allQuests[i]);
                        _actualQuestPlayer.Add(eq);
                    }
                    else if (_allQuests[i] is CompletitionQuest)
                    {
                        CompletitionQuest cq = ScriptableObject.CreateInstance <CompletitionQuest>();
                        cq.AssignValuesFromCode(_allQuests[i]);
                        _actualQuestPlayer.Add(cq);
                    }
                }

                if (_allQuests[i].CompletedByUser)
                {
                    _questsCompleted++;
                }
            }
            _questUpdater = _questUpdatePanel.GetComponent <QuestUpdater>();
            _questPanel.SetAllQuest(_allQuests);
        }
 public void SetAvailableQuestAsActive(int ID)
 {
     foreach (Quest q in _allQuests)
     {
         if (q.ID == ID)
         {
             if (_allQuests[ID] is EliminationQuest)
             {
                 EliminationQuest eq = ScriptableObject.CreateInstance <EliminationQuest>();
                 eq.AssignValuesFromCode(_allQuests[ID]);
                 _actualQuestPlayer.Add(eq);
                 eq.IsActiveNow    = true;
                 eq.IsAvailableNow = false;
                 _questPanel.UpdateStatusQuest(eq);
             }
             else if (_allQuests[ID] is CompletitionQuest)
             {
                 CompletitionQuest cq = ScriptableObject.CreateInstance <CompletitionQuest>();
                 cq.AssignValuesFromCode(_allQuests[ID]);
                 _actualQuestPlayer.Add(cq);
                 cq.IsActiveNow    = true;
                 cq.IsAvailableNow = false;
                 _questPanel.UpdateStatusQuest(cq);
             }
         }
     }
 }
 private void UpdateActualMissions(Quest q)
 {
     _endedActualQuestPlayer.Add(q);
     _actualQuestPlayer.Remove(q);
     if (q.NextMissionId >= 0)
     {
         Quest nextQuest = _allQuests[q.NextMissionId];
         Debug.Log("Siguiente: " + nextQuest.name);
         if (nextQuest is CompletitionQuest)
         {
             CompletitionQuest toAdd = ScriptableObject.CreateInstance <CompletitionQuest>();
             toAdd.AssignValuesFromCode(nextQuest);
             toAdd.IsAvailableNow = true;
             _actualQuestPlayer.Add(toAdd);
             _questPanel.UpdateStatusQuest(toAdd);
         }
         else if (nextQuest is EliminationQuest)
         {
             EliminationQuest toAdd = ScriptableObject.CreateInstance <EliminationQuest>();
             toAdd.AssignValuesFromCode(nextQuest);
             toAdd.IsAvailableNow = true;
             _actualQuestPlayer.Add(toAdd);
             _questPanel.UpdateStatusQuest(toAdd);
         }
     }
 }
 private void DisplayCompletedObjective(Quest q, int subID)
 {
     if (q is EliminationQuest)
     {
         EliminationQuest eQ = q as EliminationQuest;
         UIManager.Instance.ShowUISecondaryPanel(UISecondaryPanel.UpdateMission);
         _questUpdater.DisplayMissionUpdate(eQ.Name, eQ.EliminationQuestDescription(subID));
     }
     else if (q is CompletitionQuest)
     {
         CompletitionQuest cQ = q as CompletitionQuest;
         UIManager.Instance.ShowUISecondaryPanel(UISecondaryPanel.UpdateMission);
         _questUpdater.DisplayMissionUpdate(cQ.Name, cQ.Objectives[subID].NameObjective);
     }
 }
        /// <summary>
        /// Method to create copies passed without the reference so we can modified them
        /// in runtime without touching the original scriptableObject
        /// </summary
        public override void AssignValuesFromCode(Quest toCopy)
        {
            if (!(toCopy is CompletitionQuest))
            {
                return;
            }
            base.AssignValuesFromCode(toCopy);
            CompletitionQuest toCopyCompletition = toCopy as CompletitionQuest;
            int auxObjectivesCompleted           = toCopyCompletition.ObjectivesCompleted;
            List <Objective> auxObjectives       = new List <Objective>();

            for (int i = 0; i < toCopyCompletition.Objectives.Count; i++)
            {
                auxObjectives.Add(toCopyCompletition.Objectives[i]);
            }
            Objectives          = auxObjectives;
            ObjectivesCompleted = auxObjectivesCompleted;
        }
        public bool IsQuestNotCompleted(int idQuest, int idObjective)
        {
            bool cond = false;

            if (_actualQuestPlayer.Count == 0)
            {
                return(false);
            }
            for (int i = 0; i < _actualQuestPlayer.Count; i++)
            {
                if (_actualQuestPlayer[i].ID == idQuest)
                {
                    CompletitionQuest cq = _actualQuestPlayer[i] as CompletitionQuest;
                    cq.Objectives[idObjective].IsCompleted = true;
                    cond = true;
                }
            }
            return(cond);
        }
 public void UpdateQuestPlayerData(List <int> missionsFromPlayer)
 {
     foreach (int i in missionsFromPlayer)
     {
         if (_allQuests[i].IsActiveNow)
         {
             if (_allQuests[i] is EliminationQuest)
             {
                 EliminationQuest eq = ScriptableObject.CreateInstance <EliminationQuest>();
                 eq.AssignValuesFromCode(_allQuests[i]);
                 _actualQuestPlayer.Add(eq);
             }
             else if (_allQuests[i] is CompletitionQuest)
             {
                 CompletitionQuest cq = ScriptableObject.CreateInstance <CompletitionQuest>();
                 cq.AssignValuesFromCode(_allQuests[i]);
                 _actualQuestPlayer.Add(cq);
             }
         }
     }
 }