示例#1
0
 /// <summary>
 /// 完成任务
 /// </summary>
 public bool CompleteTask(Task task)
 {
     if (!task)
     {
         return(false);
     }
     task = ResMgr.Instance.Load <Task>(task.TaskID);
     if (OnGoingTask != null && task.IsComplete)
     {
         cmpleteTask    = task;
         task.IsOngoing = false;
         OnGoingTask    = null;
         DoneTaskList.Add(task);
         GameDataMgr.Instance.CompleteTask(task);
         //如果该任务在中转站中,需要消除
         if (TaskGiverMgr.Instance.GiverTransferStation.ContainsKey(task.CmpltNpcID))
         {
             TaskGiverMgr.Instance.GiverTransferStation.Remove(task.CmpltNpcID);
         }
         foreach (Objective o in task.Objectives)
         {
             o.OnFinishThisEvent -= UpdateCollectObjectives;
             if (o is CollectObjective)
             {
                 CollectObjective co = o as CollectObjective;
                 GameDataMgr.Instance.RemoveTaskCoItem(co.ItemID, co.Amount);
                 GameDataMgr.Instance.playerInfo.OnGetItemEvent -= co.UpdateCollectAmountUp;
             }
             if (o is KillObjective)
             {
                 KillObjective ko = o as KillObjective;
                 LevelManager.Instance.OnDeathEvent -= ko.UpdateKillAmount;
             }
             if (o is TalkObjective)
             {
                 TalkObjective to = o as TalkObjective;
                 if (TaskGiverMgr.Instance.CmpDbTransferStation.ContainsKey(to.TalkerID))
                 {
                     TaskGiverMgr.Instance.CmpDbTransferStation.Remove(to.TalkerID);
                 }
                 TaskGiverMgr.Instance.OnTalkFinishEvent -= to.UpdateTalkStatus;
             }
         }
         //奖励
         if (task.OnCmpltDialog != null)
         {
             DialogMgr.Instance.rewardEvent += Reward;
         }
         else
         {
             Reward();
         }
         return(true);
     }
     return(false);
 }
示例#2
0
 public void TraceQuest(Quest quest)
 {
     if (!quest || !quest.IsValid)
     {
         return;
     }
     if (quest.IsComplete)
     {
         //在目标建筑显示提醒
     }
     else if (quest.ObjectiveInstances.Count > 0)
     {
         using (var objectiveEnum = quest.ObjectiveInstances.GetEnumerator())
         {
             Objective        currentObj    = null;
             List <Objective> concurrentObj = new List <Objective>();
             while (objectiveEnum.MoveNext())
             {
                 currentObj = objectiveEnum.Current;
                 if (!currentObj.IsComplete)
                 {
                     if (currentObj.Concurrent && currentObj.AllPrevObjCmplt)
                     {
                         if (!(currentObj is CollectObjective))
                         {
                             concurrentObj.Add(currentObj);
                         }
                     }
                     else
                     {
                         break;
                     }
                 }
             }
             if (concurrentObj.Count > 0)
             {
                 int index = Random.Range(0, concurrentObj.Count);
                 //如果目标并发则UI则选一个
                 currentObj = concurrentObj[index];
             }
             if (currentObj is TalkObjective)
             {
                 TalkObjective to = currentObj as TalkObjective;
             }
             else if (currentObj is KillObjective)
             {
                 KillObjective ko = currentObj as KillObjective;
                 if (ko.Enemy != null)
                 {
                 }
             }
         }
     }
 }
示例#3
0
 public void StartObjectiveDialogue(TalkObjective talkObj)
 {
     if (talkObj == null)
     {
         return;
     }
     currentTalkObj = talkObj;
     CurrentType    = DialogueType.Objective;
     ShowButtons(false, false, false);
     StartDialogue(talkObj.Dialogue);
 }
示例#4
0
 public override void CloseWindow()
 {
     base.CloseWindow();
     if (IsUIOpen)
     {
         return;
     }
     CurrentType      = DialogueType.Normal;
     CurrentTalker    = null;
     CurrentQuest     = null;
     currentDialog    = null;
     currentOption    = null;
     currentTalkObj   = null;
     currentSubmitObj = null;
     wordsOptionInstances.Clear();
     ClearOptions();
     HideQuestDescription();
     if (!BuildingManager.Instance.IsPreviewing)
     {
         WindowsManager.Instance.PauseAll(false);
     }
     if (WarehouseManager.Instance.IsPausing)
     {
         WarehouseManager.Instance.PauseDisplay(false);
     }
     if (WarehouseManager.Instance.IsUIOpen)
     {
         WarehouseManager.Instance.CloseWindow();
     }
     if (ShopManager.Instance.IsPausing)
     {
         ShopManager.Instance.PauseDisplay(false);
     }
     if (ShopManager.Instance.IsUIOpen)
     {
         ShopManager.Instance.CloseWindow();
     }
     IsTalking = false;
     UIManager.Instance.EnableJoyStick(true);
     PlayerManager.Instance.PlayerController.controlAble = true;
 }
    public static void Main(string[] args)
    {
        List <BaseObjective> currentObjectives = new List <BaseObjective>();
        TalkObjective        obj1 = new TalkObjective()
        {
            Title = "Talk to Bob", Description = "Bob has some useful information for you", TargetCharacter = new Character()
            {
                GameCharId = 87
            }
        };
        LocationObjective obj2 = new LocationObjective()
        {
            Title = "Find the thing", Description = "Bob informed you of a thing, go and find it", TargetLocation = new Location()
            {
                X = 33, Y = 172
            }
        };


        currentObjectives.Add(obj1);
        currentObjectives.Add(obj2);
    }
示例#6
0
 public void Init(string text, TalkObjective objective)
 {
     titleText.text = text;
     OptionType     = OptionType.Objective;
     TalkObjective  = objective;
 }
示例#7
0
 /// <summary>
 /// 接受任务
 /// </summary>
 public bool AcceptTask(Task task)
 {
     if (!task)
     {
         return(false);
     }
     if (OnGoingTask != null)
     {
         return(false);
     }
     foreach (Objective o in task.Objectives)
     {
         if (o is CollectObjective)
         {
             CollectObjective co = o as CollectObjective;
             co.CurrentAmount = 0;
             GameDataMgr.Instance.playerInfo.OnGetItemEvent += co.UpdateCollectAmountUp;
             //获取时是否检查一遍背包以检测任务是否已可完成
             if (co.CheckBagAtAccept)
             {
                 int currentNum = GameDataMgr.Instance.playerInfo.hideList.Any(x => x.id == co.ItemID) ? GameDataMgr.Instance.playerInfo.hideList.Find(x => x.id == co.ItemID).num : 0;
                 co.UpdateCollectAmountUp(co.ItemID, currentNum);
             }
         }
         else if (o is KillObjective)
         {
             KillObjective ko = o as KillObjective;
             ko.CurrentAmount = 0;
             //检验是否为目的enermy的任务交给关卡管理器(它管理怪物生成和记录死亡的)
             LevelManager.Instance.OnDeathEvent += ko.UpdateKillAmount;
         }
         else if (o is TalkObjective)
         {
             TalkObjective to = o as TalkObjective;
             to.CurrentAmount = 0;
             if (TaskGiverMgr.Instance.AllTaskGiverInCurrentScene.ContainsKey(to.TalkerID))
             {
                 TaskGiverMgr.Instance.AllTaskGiverInCurrentScene[to.TalkerID].GetComponent <DialogListenTrigger>().SetDialogSp(to.TalkDb, true);
             }
             else if (!TaskGiverMgr.Instance.CmpDbTransferStation.ContainsKey(to.TalkerID))
             {
                 TaskGiverMgr.Instance.CmpDbTransferStation.Add(to.TalkerID, to.TalkDb);
             }
             //检验是否为目的NPC的任务交给NPC管理器(它管理NPC的读取)
             TaskGiverMgr.Instance.OnTalkFinishEvent += to.UpdateTalkStatus;
         }
         o.OnFinishThisEvent += UpdateCollectObjectives;
     }
     task.IsOngoing = true;
     OnGoingTask    = task;
     GameDataMgr.Instance.AcceptTask(task);
     //如果这个任务不是在原NPC处交任务的话
     if (!task.CmpltOnOriginalNpc)
     {
         //储存到中转站
         if (!TaskGiverMgr.Instance.GiverTransferStation.ContainsKey(task.CmpltNpcID))
         {
             TaskGiverMgr.Instance.GiverTransferStation.Add(task.CmpltNpcID, task);
         }
         //如果现在场景中就有这个NPC,把这个人物转交给那个NPC
         if (TaskGiverMgr.Instance.AllTaskGiverInCurrentScene.ContainsKey(task.CmpltNpcID))
         {
             TaskGiverMgr.Instance.AllTaskGiverInCurrentScene[task.CmpltNpcID].TransferTaskToThis(task);
         }
     }
     return(true);
 }
示例#8
0
 /// <summary>
 /// 处理最后一句对话型目标的对话
 /// </summary>
 private void HandlingLastObjectiveWords()
 {
     if (currentSubmitObj)
     {
         //双重确认,以防出错
         Quest qParent    = currentSubmitObj.runtimeParent;
         var   amount     = BackpackManager.Instance.GetItemAmount(currentSubmitObj.ItemToSubmit);
         bool  submitAble = true;
         if (qParent.CmpltObjctvInOrder)
         {
             foreach (var o in qParent.ObjectiveInstances)
             {
                 if (o is CollectObjective && (o as CollectObjective).LoseItemAtSbmt && o.InOrder && o.IsComplete)
                 {
                     if (amount - currentSubmitObj.Amount < o.Amount)
                     {
                         submitAble = false;
                         MessageManager.Instance.New($"该物品为目标[{o.DisplayName}]所需");
                         break;
                     }
                 }
             }
         }
         submitAble &= BackpackManager.Instance.TryLoseItem_Boolean(currentSubmitObj.ItemToSubmit, currentSubmitObj.Amount);
         if (submitAble)
         {
             BackpackManager.Instance.LoseItem(currentSubmitObj.ItemToSubmit, currentSubmitObj.Amount);
             currentSubmitObj.UpdateSubmitState(currentSubmitObj.Amount);
         }
         if (currentSubmitObj.IsComplete)
         {
             OptionAgent oa = optionAgents.Find(x => x.TalkObjective == currentSubmitObj);
             if (oa && oa.gameObject)
             {
                 //去掉该对话目标自身的提交型目标选项
                 optionAgents.Remove(oa);
                 oa.Recycle();
             }
             //若该目标是任务的最后一个目标,则可以直接提交任务
             if (qParent.currentQuestHolder == CurrentTalker.Data && qParent.IsComplete && qParent.ObjectiveInstances.IndexOf(currentSubmitObj) == qParent.ObjectiveInstances.Count - 1)
             {
                 oa = ObjectPool.Get(UI.optionPrefab, UI.optionsParent).GetComponent <OptionAgent>();
                 oa.Init("继续", qParent);
                 optionAgents.Add(oa);
             }
         }
         currentSubmitObj = null;//重置管理器的提交目标以防出错
     }
     else if (currentTalkObj)
     {
         if (!AllOptionComplete())
         {
             return;
         }
         currentTalkObj.UpdateTalkState();
         if (currentTalkObj.IsComplete)
         {
             OptionAgent oa = optionAgents.Find(x => x.TalkObjective == currentTalkObj);
             if (oa && oa.gameObject)
             {
                 //去掉该对话目标自身的对话型目标选项
                 optionAgents.Remove(oa);
                 oa.Recycle();
             }
             //该目标是任务的最后一个目标,则可以直接提交任务
             Quest qParent = currentTalkObj.runtimeParent;
             if (qParent.currentQuestHolder == CurrentTalker.Data && qParent.IsComplete && qParent.ObjectiveInstances.IndexOf(currentTalkObj) == qParent.ObjectiveInstances.Count - 1)
             {
                 oa = ObjectPool.Get(UI.optionPrefab, UI.optionsParent).GetComponent <OptionAgent>();
                 oa.Init("继续", qParent);
                 optionAgents.Add(oa);
             }
         }
         currentTalkObj = null;//重置管理器的对话目标以防出错
     }
     QuestManager.Instance.UpdateUI();
 }