123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Concurrent;
- using YLTask;
- using GameFramework.Event;
- using UnityGameFramework.Runtime;
- /// <summary>
- /// 任务事件处理者 基准的
- /// </summary>
- public partial class TaskEventProcessor : Singleton<TaskEventProcessor>
- {
- delegate void TaskEventFuntion(GameEventArgs finish);
- // key:Enum_EventType + Enum_TaskCmdType
- Dictionary<string, TaskEventFuntion> _TaskEventDict;
- public void Init()
- {
- _TaskEventDict = new Dictionary<string, TaskEventFuntion>();
- EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
- eventCmpt.Subscribe(TaskCardEventAdd.EventId, ProcessorEventAdd);
- eventCmpt.Subscribe(TaskCardEventAtive.EventId, ProcessorEventStart);
- eventCmpt.Subscribe(TaskCardEventFinish.EventId, ProcessorEventFinishCard);
- eventCmpt.Subscribe(TaskEventStepProcess.EventId, ProcessorEventProcess);
- eventCmpt.Subscribe(TaskEventStepFinish.EventId, ProcessorEventFinished);
- this.InitDialog();
- this.InitKill();
- this.InitGainItem();
- this.InitModifier();
- }
- public void Clean()
- {
- EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
- if (eventCmpt.Check(TaskCardEventAdd.EventId, ProcessorEventAdd))
- eventCmpt.Unsubscribe(TaskCardEventAdd.EventId, ProcessorEventAdd);
- if (eventCmpt.Check(TaskCardEventAtive.EventId, ProcessorEventStart))
- eventCmpt.Unsubscribe(TaskCardEventAtive.EventId, ProcessorEventStart);
- if (eventCmpt.Check(TaskCardEventFinish.EventId, ProcessorEventFinishCard))
- eventCmpt.Unsubscribe(TaskCardEventFinish.EventId, ProcessorEventFinishCard);
- if (eventCmpt.Check(TaskEventStepProcess.EventId, ProcessorEventProcess))
- eventCmpt.Unsubscribe(TaskEventStepProcess.EventId, ProcessorEventProcess);
- if (eventCmpt.Check(TaskEventStepFinish.EventId, ProcessorEventFinished))
- eventCmpt.Unsubscribe(TaskEventStepFinish.EventId, ProcessorEventFinished);
- this.CleanMonifier();
- }
- /// <summary>
- /// 获得任务卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ProcessorEventAdd(object sender, GameEventArgs e)
- {
- // 粗暴处理
- // 刷新任务进度
- UI_TaskTracking.UpdateTaskInfo();
- // 任务卡获得效果队列
- TaskCardEventAdd eventADD = e as TaskCardEventAdd;
- if (eventADD.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_Chief ||
- eventADD.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_College ||
- eventADD.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_Daily)
- {
- return;
- }
- PopupEffectQueueHelper.Instance.ShowEffect(ePopupEffectType.GetTaskCardEffect, eventADD.cardVo);
- }
- /// <summary>
- /// 任务卡激活
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ProcessorEventStart(object sender, GameEventArgs e)
- {
- TaskCardEventAtive start = e as TaskCardEventAtive;
- TaskCardVo vo = start.cardVo;
- NpcManager.Instance.RefreshTaskCardVo(vo);
- vo.curSteps.ForEach(stp =>
- {
- Enum_TaskCmdType eType = (Enum_TaskCmdType)stp.mo().cmd;
- if (_TaskEventDict.ContainsKey(Enum_EventType.TaskCardActived + eType.ToString()))
- {
- start.stepVo = stp;
- // 激活卡片 StartAction
- if (start.stepVo.ShouldDoStartAction())
- {
- int gateId = stp.mo().StartAction.ParamList[0];
- int stageId = stp.mo().StartAction.ParamList[1];
- List<int> paramList = start.stepVo.mo().StartAction.ParamList;
- int npdID = paramList[0];
- int stageID = paramList[1];
- PanelHelper.Instance.ShowPanel("UI_TaskDialogWindow", panel =>
- {
- panel.GetComponent<UI_TaskDialogWindow>().Init(0, npdID, stageID, npdID + "_" + stageID + "_" + 0, 0, null);
- panel.GetComponent<UI_TaskDialogWindow>().SetTaskActionData(int.Parse(vo.uid), start.stepVo.typeId, 1);
- });
- }
- // 激活卡片 不同事件处理
- _TaskEventDict[Enum_EventType.TaskCardActived + eType.ToString()](start);
- // 刷新任务进度
- UI_TaskTracking.UpdateTaskInfo();
- }
-
- });
- }
- /// <summary>
- /// 任务卡完成
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ProcessorEventFinishCard(object sender, GameEventArgs e)
- {
- // 任务卡完成效果队列
- TaskCardEventFinish eventFinish = e as TaskCardEventFinish;
- // UI_TipsWindow.InitStaticDialog("恭喜", "完成任务:"+ eventFinish.cardVo.nMo.name);///需要从这种变成下一种,如果不满意再改动.
- UI_TipsWindow.InitFloatDialog("完成任务:" + eventFinish.cardVo.nMo.name);
- // 友盟统计: 任务卡完成
- AndroidInteractive.CallJavaFunction("onEvent", "e_task", "task_complete", eventFinish.cardVo.typeId.ToString());
- StatHelper.Instance.AddEvent("e_task","complete", eventFinish.cardVo.typeId.ToString());
- // 粗暴处理
- // 刷新任务进度
- UI_TaskTracking.UpdateTaskInfo(eventFinish.cardVo);
- // 任务卡获得效果队列
- if (eventFinish.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_Chief ||
- eventFinish.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_College ||
- eventFinish.cardVo.nMo.GetTaskCardExt().type == (int)TaskCardType.TaskCardType_Daily)
- {
- return;
- }
- PopupEffectQueueHelper.Instance.ShowEffect(ePopupEffectType.CompleteTaskCardEffect, eventFinish.cardVo);
- }
- /// <summary>
- /// 任务步骤有更新
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ProcessorEventProcess(object sender, GameEventArgs e)
- {
- TaskEventStepProcess process = e as TaskEventStepProcess;
- TaskCardVo vo = process.cardVo;
- NpcManager.Instance.RefreshTaskCardVo(vo);
- vo.curSteps.ForEach(stp =>
- {
- Enum_TaskCmdType eType = (Enum_TaskCmdType)stp.mo().cmd;
- LogHelper.Log("任务更新:" + Enum_EventType.MissionStepComplete + " " + eType.ToString());
- if (_TaskEventDict.ContainsKey(Enum_EventType.MissionStepProcess + eType.ToString()))
- {
- // 处理 startAction
- Ins_TaskStepVo svo = stp;
- //if (svo.ShouldDoStartAction())
- //{
- // int gateId = stp.mo().StartAction.ParamList[0];
- // int stageId = stp.mo().StartAction.ParamList[1];
- // List<int> paramList = svo.mo().StartAction.ParamList;
- // int npdID = paramList[0];
- // int stageID = paramList[1];
- // PanelHelper.Instance.ShowPanel("UI_TaskDialogWindow", panel =>
- // {
- // panel.GetComponent<UI_TaskDialogWindow>().Init(0, npdID, stageID, npdID + "_" + stageID + "_" + 0, 0, null);
- // panel.GetComponent<UI_TaskDialogWindow>().SetTaskActionData(gateId, stageId, 1);
- // });
- //}
- // 更新步骤
- _TaskEventDict[Enum_EventType.MissionStepProcess + eType.ToString()](process);
- // 刷新任务进度
- UI_TaskTracking.UpdateTaskInfo();
- }
-
- });
- }
- /// <summary>
- /// 任务步骤完成
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ProcessorEventFinished(object sender, GameEventArgs e)
- {
- TaskEventStepFinish finish = e as TaskEventStepFinish;
- TaskCardVo vo = finish.cardVo;
- NpcManager.Instance.RefreshTaskCardVo(vo);
- vo.curSteps.ForEach(stp =>
- {
- Enum_TaskCmdType eType = (Enum_TaskCmdType)stp.mo().cmd;
- LogHelper.Log("任务完成:" + Enum_EventType.MissionStepComplete + " " + eType.ToString());
- if (_TaskEventDict.ContainsKey(Enum_EventType.MissionStepComplete + eType.ToString()))
- {
- // 处理 步骤
- _TaskEventDict[Enum_EventType.MissionStepComplete + eType.ToString()](finish);
- // 处理 finishAction
- TaskCardVo cvo = finish.cardVo;
- Ins_TaskStepVo svo = finish.stepVo;
- if (svo.ShouldDoFinishAction())
- {
- List<int> paramList = svo.mo().FinishAction.ParamList;
- int npcID = paramList[0];
- int stageID = paramList[1];
- PanelHelper.Instance.ShowPanel("UI_TaskDialogWindow", panel =>
- {
- panel.GetComponent<UI_TaskDialogWindow>().Init(1, npcID, stageID, npcID + "_" + stageID + "_" + 0, 0, null);
- panel.GetComponent<UI_TaskDialogWindow>().SetTaskActionData(int.Parse(vo.uid), svo.typeId, 2);
- });
- }
- // 刷新任务进度
- UI_TaskTracking.UpdateTaskInfo(vo);
- }
-
- });
- }
- }
|