using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using LitJson;
|
using System.Text.RegularExpressions;
|
using System.Text;
|
using vnxbqy.UI;
|
//任务信息的存储
|
|
/** 任务结构 */
|
public class MissionDetailDates
|
{
|
public DateTime Time;//记录时间
|
public int ID;//任务ID
|
public string Name;//任务名称
|
public int Type;//任务类型
|
public int NPC_ID;//起始NPCID
|
public int LV;//可接等级
|
public int ColorLV;//任务难度
|
public string Desclist;//任务详情
|
public string RewardList;//奖励信息
|
public List<TsakLight> LightList;//任务灯信息
|
public string InforList;//任务完成条件
|
public int MissionState;//任务状态0未接,1进行中,2可提交,3已完成,6特殊卡级
|
public int descIndex;//任务描述索引
|
}
|
|
|
public class MissionDict//任务字典信息
|
{
|
public int MissionId;//任务ID
|
|
public int DictKeyLen;//任务字典中的某个Key
|
|
public string DictKey;//key的长度
|
|
public int DictValue;//该key对应的值
|
|
|
}
|
public class RunTaskAwardRecord
|
{
|
public int Num;
|
public int AwardState;
|
}
|
|
public struct TsakLight
|
{
|
public int NpcId;
|
public int StateLight;
|
}
|
|
|
public class TaskModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
|
/** 任务总清单 */
|
public static bool _globalbool = false;
|
public Dictionary<int, MissionDetailDates> allMissionDict = new Dictionary<int, MissionDetailDates>();//任务初始化接收字典
|
public Dictionary<int, MissionDetailDates> MainTaskDic = new Dictionary<int, MissionDetailDates>();//主线任务字典
|
public Dictionary<int, MissionDetailDates> SideQuestsDic = new Dictionary<int, MissionDetailDates>();//支线任务字典
|
public Dictionary<int, MissionDetailDates> BountyDic = new Dictionary<int, MissionDetailDates>();//赏金任务
|
public Dictionary<int, MissionDetailDates> FairyAuDic = new Dictionary<int, MissionDetailDates>();//仙盟任务
|
public int FairyAuTaskCount_Day { get; private set; }
|
public int FairyAuTaskCount_Round { get; private set; }
|
public Dictionary<int, MissionDetailDates> SpecialTask = new Dictionary<int, MissionDetailDates>();//特殊任务类型
|
public Dictionary<int, Dictionary<string, string>> _DicTaskInformation = new Dictionary<int, Dictionary<string, string>>();//任务字典的信息
|
public Dictionary<int, Dictionary<string, int>> ReplaceDic = new Dictionary<int, Dictionary<string, int>>();//key值替换字典
|
public Dictionary<int, RunTaskAwardRecord> AwardRecordDic = new Dictionary<int, RunTaskAwardRecord>();//跑环奖励记录
|
public Dictionary<int, int> NPCShowDic = new Dictionary<int, int>();//关于NPC的显隐问题
|
|
Dictionary<int, int> m_ShowNpcCache = new Dictionary<int, int>();
|
|
public delegate void OnTaskToAdd(int MissionID, int MissionState, int DiscriptionIndex);
|
public static event OnTaskToAdd Event_TaskToAdd;//任务添加
|
public delegate void OnTaskRefreshes(int _taskId);
|
public static event OnTaskRefreshes Event_TaskRefreshes;//任务的刷新
|
public delegate void OnBounty();//赏金任务的添加
|
public static event OnBounty Event_nBounty;
|
public delegate void OnFairyAuTask();//仙盟任务的添加和刷新
|
public static event OnFairyAuTask Event_FairyAuTask;
|
|
public delegate void OnTaskInformation(int _id, Dictionary<int, Dictionary<string, string>> _Dic);
|
public static event OnTaskInformation Event_TaskInformation;//任务字典信息
|
|
public delegate void OnTaskToDelete(int _taskID);
|
public static event OnTaskToDelete Event_TaskToDelete;//任务的删除
|
|
public delegate void OnBountyRewards(int Number, int AwardState);//获取赏金奖励
|
public static event OnBountyRewards Event_BountyRewards;
|
public int BountyRewardsNumber = 0;//获取赏金内容的奖励值
|
|
public delegate void OnFairyAuReward(int Number, int AwardState);//仙盟奖励
|
public static event OnFairyAuReward Event_FairyAuReward;
|
public int OnFairyAuNumber = 0;//获取仙盟的奖励值
|
|
public string _conversation = null;//对话内容、
|
public int _TaskNow = 0;//获取当前任务ID
|
public string _DefaultDialogContent = null;//默认对话内容
|
|
public delegate void OnMainlineTask(int MissionID, int MissionState);//主线任务任务状态变更和刷新
|
public static event OnMainlineTask Event_MainlineTask;
|
|
public delegate void OnTaskResponse(int _nowNPCid, int _nPCLamp, Dictionary<int, int> _dic = null);//NPCNPC灯状态,可接取任务(NPCID,任务灯状态)
|
public static event OnTaskResponse Event_TaskResponse;
|
|
public static event Action tryGetTaskAwardEvent;//这个是客户端只要尝试去领奖就会触发,不管最后的领奖结果。
|
|
public static event Action<int> CardLevelChange;//关于任务卡机状态的转变
|
|
public static event Action<int> SideQuestChangeEvent;//支线任务状态改变
|
|
public static event Action<int> MainCardLevelChange;//主线任务卡级状态改变
|
|
public static event Action<int> CompletionOfTaskEvent;//任务完成回调
|
|
public event Action<int> talkNpcIdUpdate;
|
|
public event Action<int> taskDescriptionRefresh;
|
|
public static event Action TaskCoinTaskEvent;//赏金任务信息字典变更
|
public static event Action FairyTaskEvent;//仙盟任务信息字典变更
|
|
public int NPCid = 0;//获取NPCID(打开任务面板时)、
|
|
public bool BountyMotionBool = false;//控制赏金任务是否自动移动
|
public bool FairyAuBool = false;//控制仙盟任务是否自动移动
|
public int currentMission { get; private set; }
|
public int currentMissionState { get; private set; }
|
|
public int GetNowTaskID { get; set; }//获取当前选中条的任务ID
|
|
private bool isServerPrepare = false;//控制是否自动进行自动任务
|
private int retainTaskID = 0;
|
private float BossDelayTimeint = 0;
|
public Vector3 UIeffectFabaoVec = new Vector3();//法宝NPC消失时获取的坐标
|
//----关于前期无操作自动执行主线
|
public int TaskAutoLv = 0;
|
public int TaskAutoTime = 0;
|
|
public bool TaskOverBool = false;
|
private int Times = 0;
|
private int NeedWaitTime = 4;
|
|
public int clientGuardDugeonTask { get; private set; }
|
|
List<int[]> priorityTaskChains = new List<int[]>();
|
|
List<int> allowAutoTaskMapIds = new List<int>();
|
|
private float mainTaskAutoWaitTime = 0f;
|
public readonly TaskWait taskWait = new TaskWait();
|
|
PackModel _playerPack;
|
PackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
|
public override void Init()
|
{
|
StageLoad.Instance.onStageLoadFinish += onStageLoadFinish;
|
NPCInteractProcessor.s_NpcInteractEvent += NpcInterac;
|
|
string BossDelayTime = FuncConfigConfig.Get("BossDelayTime").Numerical1;
|
BossDelayTimeint = float.Parse(BossDelayTime);
|
var Task_Auto = FuncConfigConfig.Get("TaskAuto");
|
TaskAutoLv = int.Parse(Task_Auto.Numerical1);
|
TaskAutoTime = int.Parse(Task_Auto.Numerical2);
|
mainTaskAutoWaitTime = int.Parse(Task_Auto.Numerical3) / 1000f;
|
var mapIds = ConfigParse.GetMultipleStr<int>(Task_Auto.Numerical4);
|
if (mapIds != null && mapIds.Length > 0)
|
{
|
allowAutoTaskMapIds.AddRange(mapIds);
|
}
|
|
FairyAuTaskCount_Day = int.Parse(FuncConfigConfig.Get("RunTaskCnt").Numerical1.Split('|')[1].Split('_')[1]);
|
FairyAuTaskCount_Round = int.Parse(FuncConfigConfig.Get("RunTaskCnt").Numerical2.Split('|')[1].Split('_')[1]);
|
|
var cliengGuardConfig = FuncConfigConfig.Get("ClientGuardDungeon");
|
clientGuardDugeonTask = int.Parse(cliengGuardConfig.Numerical5);
|
|
var funcConfig = FuncConfigConfig.Get("AutoSelectTaskChain");
|
var taskChainArray = LitJson.JsonMapper.ToObject<int[][]>(funcConfig.Numerical1);
|
if (taskChainArray != null)
|
{
|
for (int i = 0; i < taskChainArray.Length; i++)
|
{
|
priorityTaskChains.Add(taskChainArray[i]);
|
}
|
}
|
}
|
|
public override void UnInit()
|
{
|
StageLoad.Instance.onStageLoadFinish -= onStageLoadFinish;
|
NPCInteractProcessor.s_NpcInteractEvent -= NpcInterac;
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
allMissionDict.Clear();
|
MainTaskDic.Clear();
|
SideQuestsDic.Clear();
|
BountyDic.Clear();
|
FairyAuDic.Clear();
|
SpecialTask.Clear();
|
_DicTaskInformation.Clear();
|
ReplaceDic.Clear();
|
AwardRecordDic.Clear();
|
NPCShowDic.Clear();
|
m_ShowNpcCache.Clear();
|
_conversation = null;
|
_DefaultDialogContent = null;
|
_TaskNow = 0;
|
BountyRewardsNumber = 0;
|
NPCid = 0;
|
retainTaskID = 0;
|
currentMission = 0;
|
_globalbool = false;
|
BountyMotionBool = false;
|
FairyAuBool = false;
|
isServerPrepare = false;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= secondEvent;
|
GlobalTimeEvent.Instance.secondEvent += secondEvent;
|
TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow;
|
isServerPrepare = true;
|
TaskOverBool = false;
|
}
|
|
private void onStageLoadFinish()//地图切换时调用
|
{
|
var inDungeon = IsDungeon();
|
if (!inDungeon && retainTaskID != 0)
|
{
|
if (ReplaceDic.ContainsKey(retainTaskID))
|
{
|
AutomaticTripToTask(retainTaskID);
|
//int missionState = SideQuestState(retainTaskID);
|
//TaskTerminationToHangUp(retainTaskID, missionState);
|
retainTaskID = 0;
|
}
|
}
|
}
|
List<int> ListMissionID = new List<int>();
|
public void RefreshMissionState(int MissionID, int MissionState, int DiscriptionIndex)//1.任务ID,2任务状态,3,任务描述Index(接收任务)
|
{
|
try
|
{
|
if (isServerPrepare && MissionState != 3 && MissionID != 2000 && MissionID != 3000)
|
{
|
TaskupToDate = MissionID;
|
}
|
var pytaskM = PyTaskConfig.Get(MissionID);
|
if (pytaskM == null)
|
{
|
return;
|
}
|
if ((pytaskM.type == (int)TaskTypenum.MainlineTaskType || pytaskM.type == (int)TaskTypenum.MainlineTaskTyp2) && MissionState != 0 && MissionState != 3)
|
{
|
currentMission = MissionID;
|
currentMissionState = MissionState;
|
}
|
//仙盟任务完成
|
if ((pytaskM.type == 12 || pytaskM.type == 14) && TaskAllocation.Instance.FairyAuAllNumber() >= FairyAuTaskCount_Day)
|
{
|
Event_FairyAuTask();
|
return;
|
}
|
|
|
if (allMissionDict.ContainsKey(MissionID))
|
{
|
int missionState = allMissionDict[MissionID].MissionState;
|
var lastDescriptionIndex = allMissionDict[MissionID].descIndex;
|
|
if (allMissionDict[MissionID].MissionState != MissionState && MissionState == 3 && isServerPrepare)
|
{
|
TaskOverBool = true;
|
taskWait.Push(TaskWaitType.TaskComplete);
|
if (CompletionOfTaskEvent != null)
|
{
|
CompletionOfTaskEvent(MissionID);
|
}
|
}
|
TaskChanges(MissionID, MissionState, DiscriptionIndex);//任务的状态修改
|
|
if (missionState == 0 && (MissionState == 1 || MissionState == 2))
|
{
|
if (Event_TaskToAdd != null)//任务添加(用于存储于身上的未接取任务的特殊处理)
|
{
|
Event_TaskToAdd(MissionID, MissionState, DiscriptionIndex);
|
}
|
}
|
else
|
{
|
if (Event_TaskRefreshes != null)//刷新任务
|
{
|
Event_TaskRefreshes(MissionID);
|
}
|
}
|
|
if (lastDescriptionIndex != DiscriptionIndex)
|
{
|
if (taskDescriptionRefresh != null)
|
{
|
taskDescriptionRefresh(MissionID);
|
}
|
}
|
|
}
|
else
|
{
|
AddMission(MissionID, MissionState, DiscriptionIndex);//任务的添加
|
if (taskDescriptionRefresh != null)
|
{
|
taskDescriptionRefresh(MissionID);
|
}
|
if (Event_TaskToAdd != null)
|
{
|
Event_TaskToAdd(MissionID, MissionState, DiscriptionIndex);
|
}
|
}
|
TaskClassification(MissionID, MissionState);//任务分类
|
IsShowNpC(1);//是否显示NPC
|
IsShowNpC(MissionID);//是否显示NPC
|
if (isServerPrepare)
|
{
|
AutotaskingPrecedence(isServerPrepare, MissionID);//是否执行自动任务
|
}
|
TaskTerminationToHangUp(MissionID, MissionState);//结束赏金和仙盟任务前往挂机
|
if (Event_TaskResponse != null)//发送任务灯信息
|
{
|
if (allMissionDict[MissionID].LightList.Equals(default(TsakLight)))
|
{
|
return;
|
}
|
for (int i = 0; i < allMissionDict[MissionID].LightList.Count; i++)
|
{
|
Event_TaskResponse(allMissionDict[MissionID].LightList[i].NpcId, allMissionDict[MissionID].LightList[i].StateLight);
|
}
|
|
}
|
}
|
catch (Exception ex)
|
{
|
DebugEx.Log(ex.StackTrace);
|
}
|
|
}
|
|
void NpcInterac(E_NpcType equip, int NPcID, uint instanceId)//服务器发包(NPCID,人物位置)
|
{
|
float Posx = PlayerDatas.Instance.hero.Pos.x * 2;
|
float PosY = PlayerDatas.Instance.hero.Pos.z * 2;
|
if (BossInfoConfig.GetBossInfoByStoneId(NPcID) != null)
|
{
|
return;
|
}
|
|
if (CrossServerUtility.IsCrossServer())
|
{
|
var sendInfo = new CC106_tagCMCrossNPCTalk();
|
sendInfo.ObjID = instanceId;
|
sendInfo.NPCID = (uint)NPcID;
|
sendInfo.PosX = (ushort)Posx;
|
sendInfo.PosY = (ushort)PosY;
|
GameNetSystem.Instance.SendInfo(sendInfo);
|
}
|
else
|
{
|
C0801_tagCNPCTalk _C0801 = new C0801_tagCNPCTalk();
|
_C0801.NPCID = instanceId;
|
_C0801.PosX = (ushort)Posx;
|
_C0801.PosY = (ushort)PosY;
|
GameNetSystem.Instance.SendInfo(_C0801);
|
}
|
}
|
|
public ImpactRankModel.RankAwardItem GetRunTaskRward()//添加任务奖励
|
{
|
var runTaskAward = FuncConfigConfig.Get("RunTaskAward");
|
ImpactRankModel.RankAwardItem _award = new ImpactRankModel.RankAwardItem();
|
var _jsonData = LitJson.JsonMapper.ToObject(runTaskAward.Numerical3);
|
var jsonData2 = LitJson.JsonMapper.ToObject(runTaskAward.Numerical4);
|
foreach (string key in _jsonData.Keys)
|
{
|
var _job = int.Parse(key);
|
var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(_jsonData[key].ToJson());
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_award.Add(_job, new Item(_itemArray[j][0], _itemArray[j][1]));
|
}
|
}
|
foreach (string key in jsonData2.Keys)
|
{
|
var _job = int.Parse(key);
|
_award.Add(_job, new Item(2301, 0));
|
|
}
|
|
return _award;
|
}
|
|
public int GetLatestMainTaskId()
|
{
|
var taskId = 0;
|
foreach (var id in MainTaskDic.Keys)
|
{
|
if (id > taskId)
|
{
|
taskId = id;
|
}
|
}
|
return taskId;
|
}
|
|
public bool TryGetTaskData(int _taskId, out MissionDetailDates taskData)
|
{
|
return allMissionDict.TryGetValue(_taskId, out taskData);
|
}
|
|
void DefaultDialogue()//关于打开默认对话界面
|
{
|
if (NewBieCenter.Instance.inGuiding || ModelCenter.Instance.GetModel<TreasureModel>().newGotShowing)
|
{
|
return;
|
}
|
bool IsOpenMain = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
|
if (!WindowCenter.Instance.IsOpen<DefaultDialogueBoxWin>() && IsOpenMain)
|
{
|
WindowCenter.Instance.Open<DefaultDialogueBoxWin>();
|
WindowCenter.Instance.Close<MainInterfaceWin>();
|
}
|
else
|
{
|
if (talkNpcIdUpdate != null)
|
{
|
talkNpcIdUpdate(NPCid);
|
}
|
}
|
}
|
private void OnEventTalkEvent(int taskID)//NPC对话后的弹框
|
{
|
//if (WindowCenter.Instance.ExitAnyFullScreenOrMaskWin())
|
//{
|
// return;
|
//}
|
if (NewBieCenter.Instance.inGuiding || ModelCenter.Instance.GetModel<TreasureModel>().newGotShowing
|
|| WindowCenter.Instance.IsOpen<TreasureChapterWin>())
|
{
|
return;
|
}
|
|
bool IsOpenMain = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
|
|
var state = 0;
|
if (TryGetCustomTaskState(taskID, out state))
|
{
|
var config = StoryMissionsConfig.GetConfig(taskID, state);
|
if (config != null && NPCid == config.NpcID)
|
{
|
if (!WindowCenter.Instance.IsOpen<DialogueDuidanceWin>() && IsOpenMain
|
&& !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
|
{
|
WindowCenter.Instance.Close<MainInterfaceWin>();
|
DialogueDuidanceWin.storyMissionId = config.id;
|
DialogueDuidanceWin.taskId = taskID;
|
WindowCenter.Instance.Open<DialogueDuidanceWin>();
|
}
|
return;
|
}
|
}
|
if (!WindowCenter.Instance.IsOpen<TaskBoxBGMWin>() && IsOpenMain)
|
{
|
WindowCenter.Instance.Close<MainInterfaceWin>();
|
WindowCenter.Instance.Open<TaskBoxBGMWin>();
|
return;
|
}
|
if (BountyDic.ContainsKey(_TaskNow) || FairyAuDic.ContainsKey(_TaskNow))
|
{
|
if (!ModelCenter.Instance.GetModel<TeamModel>().teamPrepare.isPreparing)
|
{
|
RequestGetTaskAward("OK", _TaskNow);
|
}
|
}
|
}
|
|
|
private void BountySelfMotion()
|
{
|
int blank = playerPack.GetEmptyGridCount(PackType.Item);
|
if (blank < 1)//"请先清理背包再领取奖励
|
{
|
return;
|
}
|
|
}
|
|
public bool TryGetCustomTaskState(int taskId, out int state)
|
{
|
state = 0;
|
if (ReplaceDic.ContainsKey(taskId))
|
{
|
var keyValue = ReplaceDic[taskId];
|
if (keyValue.ContainsKey("state"))
|
{
|
state = keyValue["state"];
|
return true;
|
}
|
}
|
return false;
|
}
|
|
void AddMission(int MissionID, int MissionState, int DiscriptionIndex)//添加任务
|
{
|
var config = PyTaskConfig.Get(MissionID);
|
if (config == null)
|
{
|
DebugEx.LogError(MissionID + "表格中不存在此任务ID");
|
return;
|
}
|
|
if (allMissionDict == null)
|
allMissionDict = new Dictionary<int, MissionDetailDates>();
|
MissionDetailDates vDetailData = new MissionDetailDates();
|
vDetailData.Time = DateTime.Now;
|
vDetailData.ID = int.Parse(config.id);
|
vDetailData.Name = config.name;
|
vDetailData.Type = config.type;
|
vDetailData.NPC_ID = config.npcId;
|
vDetailData.LV = config.lv;
|
vDetailData.ColorLV = config.colorLV;
|
|
vDetailData.RewardList = RewardInformation(config.rewardList, DiscriptionIndex);//奖励信息
|
if (ReplaceDic.ContainsKey(MissionID))
|
{
|
Dictionary<string, int> _dic = ReplaceDic[MissionID];
|
if (_dic.ContainsKey("visit_npc_id") || _dic.ContainsKey("kill_npc_id"))
|
{
|
vDetailData.LightList = CharactersReplace(config.lightList, DiscriptionIndex, int.Parse(config.id));
|
}
|
else
|
{
|
vDetailData.LightList = StrSegmentation(config.lightList, DiscriptionIndex);//任务信息灯
|
}
|
if (MissionState == 3)
|
{
|
for (int i = 0; i < vDetailData.LightList.Count; i++)
|
{
|
TsakLight TsakLight = new TsakLight();
|
TsakLight.NpcId = vDetailData.LightList[i].NpcId;
|
TsakLight.StateLight = -1;
|
vDetailData.LightList[i] = TsakLight;
|
}
|
}
|
}
|
else
|
{
|
vDetailData.LightList = StrSegmentation(config.lightList, DiscriptionIndex);//任务信息灯
|
if (MissionState == 3)
|
{
|
for (int i = 0; i < vDetailData.LightList.Count; i++)
|
{
|
TsakLight TsakLight = new TsakLight();
|
TsakLight.NpcId = vDetailData.LightList[i].NpcId;
|
TsakLight.StateLight = -1;
|
vDetailData.LightList[i] = TsakLight;
|
}
|
}
|
}
|
vDetailData.Desclist = TaskDetails(config.descList, DiscriptionIndex);//任务详情
|
vDetailData.InforList = StrInforList(config.infoList, DiscriptionIndex);//任务完成条件
|
|
|
vDetailData.MissionState = MissionState;
|
vDetailData.descIndex = DiscriptionIndex;
|
|
var canSwitchSelectTask = true;
|
if (GetNowTaskID != 0 && !IsMainTaskType(vDetailData.Type))
|
{
|
MissionDetailDates taskData;
|
if (TryGetTaskData(GetNowTaskID, out taskData)
|
&& IsMainTaskType(taskData.Type)
|
&& taskData.MissionState != 3)
|
{
|
canSwitchSelectTask = false;
|
}
|
}
|
|
if (isServerPrepare && PriorityTaskChainContains(MissionID))
|
{
|
canSwitchSelectTask = true;
|
}
|
|
if (canSwitchSelectTask)
|
{
|
GetNowTaskID = MissionID;
|
}
|
|
allMissionDict.Add(MissionID, vDetailData);//添加任务
|
}
|
|
public bool PriorityTaskChainContains(int taskId)
|
{
|
for (int i = 0; i < priorityTaskChains.Count; i++)
|
{
|
if (taskId >= priorityTaskChains[i][0]
|
&& taskId <= priorityTaskChains[i][1])
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public bool IsMainTaskType(int type)
|
{
|
return type == (int)TaskTypenum.MainlineTaskType || type == (int)TaskTypenum.MainlineTaskTyp2;
|
}
|
|
public enum TaskTypenum//任务类型分类
|
{
|
MainlineTaskType = 0,//主线
|
MainlineTaskTyp2 = 1,
|
SideQuestsType2 = 2,//支线
|
SideQuestsType3 = 3,//支线任务(本源法宝支线)
|
SideQuestsType4 = 4,
|
SideQuestsType5 = 5,
|
BountyMissionsType6 = 6,//赏金任务
|
BountyMissionsType7 = 7,
|
BountyMissionsType8 = 8,
|
FairyAuMissionType11 = 11,//仙盟任务
|
FairyAuMissionType12 = 12,
|
SpecialTaskType13 = 13,//特殊任务类型(用于赏金)
|
SpecialTaskType14 = 14,//特殊任务类型(用于仙盟)
|
AchievementTask = 15,//成就任务(暂未开出专属字典)
|
SpecialTaskType16 = 16,//特殊任务类型(用于法宝)
|
SideQuestsType17 = 17,//支线17-21新增
|
SideQuestsType18 = 18,
|
SideQuestsType19 = 19,
|
SideQuestsType20 = 20,//(后端特殊处理,暂定不让使用)
|
SideQuestsType21 = 21,
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
|
void TaskClassification(int _taskID, int MissionState)//任务分类(主线任务,支线任务)
|
{
|
if (!allMissionDict.ContainsKey(_taskID))
|
{
|
return;
|
}
|
TaskTypenum type = (TaskTypenum)allMissionDict[_taskID].Type;
|
switch (type)
|
{
|
case TaskTypenum.MainlineTaskType:
|
case TaskTypenum.MainlineTaskTyp2:
|
{
|
if (_taskID != 1)//主线任务(添加与更新)
|
{
|
if (MainTaskDic.ContainsKey(_taskID))
|
{
|
MainTaskDic[_taskID] = allMissionDict[_taskID];
|
}
|
else
|
{
|
MainTaskDic.Add(_taskID, allMissionDict[_taskID]);
|
}
|
if (Event_MainlineTask != null)
|
{
|
Event_MainlineTask(_taskID, MissionState);
|
}
|
}
|
|
}
|
break;
|
case TaskTypenum.SideQuestsType2:
|
case TaskTypenum.SideQuestsType3:
|
case TaskTypenum.SideQuestsType4:
|
case TaskTypenum.SideQuestsType5:
|
case TaskTypenum.SideQuestsType17:
|
case TaskTypenum.SideQuestsType18:
|
case TaskTypenum.SideQuestsType19:
|
case TaskTypenum.SideQuestsType20:
|
case TaskTypenum.SideQuestsType21:
|
{
|
if (SideQuestsDic.ContainsKey(_taskID))
|
{
|
SideQuestsDic[_taskID] = allMissionDict[_taskID];
|
}
|
else
|
{
|
SideQuestsDic.Add(_taskID, allMissionDict[_taskID]);
|
}
|
if (SideQuestChangeEvent != null)
|
{
|
SideQuestChangeEvent(_taskID);
|
}
|
}
|
break;
|
case TaskTypenum.BountyMissionsType6:
|
case TaskTypenum.BountyMissionsType7:
|
case TaskTypenum.BountyMissionsType8:
|
{
|
|
if (BountyDic.ContainsKey(_taskID))
|
BountyDic[_taskID] = allMissionDict[_taskID];
|
else
|
BountyDic.Add(_taskID, allMissionDict[_taskID]);
|
if (Event_nBounty != null)
|
Event_nBounty();
|
}
|
|
break;
|
case TaskTypenum.FairyAuMissionType11:
|
case TaskTypenum.FairyAuMissionType12:
|
{
|
if (FairyAuDic.ContainsKey(_taskID))
|
FairyAuDic[_taskID] = allMissionDict[_taskID];
|
else
|
FairyAuDic.Add(_taskID, allMissionDict[_taskID]);
|
if (Event_FairyAuTask != null && MissionState != 3)
|
Event_FairyAuTask();
|
}
|
break;
|
case TaskTypenum.SpecialTaskType13:
|
case TaskTypenum.SpecialTaskType14:
|
case TaskTypenum.SpecialTaskType16:
|
|
{
|
if (SpecialTask.ContainsKey(_taskID))
|
SpecialTask[_taskID] = allMissionDict[_taskID];
|
else
|
SpecialTask.Add(_taskID, allMissionDict[_taskID]);
|
}
|
break;
|
default:
|
break;
|
}
|
|
|
}
|
|
void TaskTypeDeletion(int _taskID)//任务类型的删除
|
{
|
|
if (MainTaskDic.ContainsKey(_taskID))//主线
|
{
|
MainTaskDic.Remove(_taskID);
|
}
|
else if (SideQuestsDic.ContainsKey(_taskID))//支线
|
{
|
SideQuestsDic.Remove(_taskID);
|
}
|
else if (BountyDic.ContainsKey(_taskID))//赏金
|
{
|
BountyDic.Remove(_taskID);
|
if (Event_nBounty != null)
|
Event_nBounty();
|
|
}
|
else if (SpecialTask.ContainsKey(_taskID))//特殊任务
|
{
|
SpecialTask.Remove(_taskID);
|
}
|
else if (FairyAuDic.ContainsKey(_taskID))
|
{
|
FairyAuDic.Remove(_taskID);
|
if (Event_FairyAuTask != null)
|
Event_FairyAuTask();
|
}
|
|
|
}
|
string TaskDetails(string _string, int _index)////Json解析
|
{
|
JsonData _Json = JsonMapper.ToObject(_string);
|
if (_Json.Count == 1)
|
{
|
string _TaskDetails = _Json["0"].ToString().Replace("\"", "");
|
return _TaskDetails;
|
}
|
else
|
{
|
string _TaskDetails = _Json[_index.ToString()].ToString().Replace("\"", "");
|
return _TaskDetails;
|
}
|
|
}
|
|
|
List<TsakLight> CharactersReplace(string _string, int _index, int Id)
|
{
|
|
JsonData _Json = JsonMapper.ToObject(_string);
|
List<TsakLight> TsakLightList = new List<TsakLight>();
|
TsakLightList.Clear();
|
TsakLight taskLight = new TsakLight();
|
foreach (var key in _Json.Keys)
|
{
|
if (int.Parse(key) == _index)
|
{
|
JsonData _Json1 = _Json[key];
|
if (_Json1.Count != 0)
|
{
|
foreach (var _key in _Json1.Keys)
|
{
|
string Str = _key.ToString();
|
Match match = Regex.Match(Str, pattern);
|
if (ReplaceDic.ContainsKey(Id))
|
{
|
Dictionary<string, int> _dic = ReplaceDic[Id];
|
if (_dic.ContainsKey(match.Groups[1].Value))
|
{
|
taskLight.NpcId = _dic[match.Groups[1].Value];
|
taskLight.StateLight = int.Parse(_Json1[_key].ToString());
|
TsakLightList.Add(taskLight);
|
}
|
}
|
}
|
}
|
return TsakLightList;
|
|
}
|
}
|
|
return TsakLightList;
|
}
|
|
string StrInforList(string _string, int _index)
|
{
|
JsonData _Json = JsonMapper.ToObject(_string);
|
foreach (var key in _Json.Keys)
|
{
|
if (int.Parse(key) == _index)
|
{
|
JsonData _Json1 = _Json[key];
|
if (_Json1.Count != 0)
|
{
|
foreach (var _key in _Json1.Keys)
|
{
|
return _Json1[_key].ToString();
|
}
|
}
|
}
|
}
|
|
return string.Empty;
|
}
|
|
List<TsakLight> StrSegmentation(string _string, int _index)
|
{
|
int val;
|
JsonData _Json = JsonMapper.ToObject(_string);
|
List<TsakLight> TsakLightList = new List<TsakLight>();
|
TsakLightList.Clear();
|
|
foreach (var key in _Json.Keys)
|
{
|
if (int.Parse(key) == _index)
|
{
|
JsonData _Json1 = _Json[key];
|
if (_Json1.Count != 0)
|
{
|
foreach (var _key in _Json1.Keys)
|
{
|
if (int.TryParse(_key, out val))
|
{
|
TsakLight taskLight = new TsakLight();
|
taskLight.NpcId = int.Parse(_key);
|
taskLight.StateLight = int.Parse(_Json1[_key].ToString());
|
TsakLightList.Add(taskLight);
|
}
|
}
|
}
|
return TsakLightList;
|
}
|
}
|
|
return TsakLightList;
|
}
|
|
string RewardInformation(string _string, int _index)//奖励信息
|
{
|
|
string _occupation = ("J" + PlayerDatas.Instance.baseData.Job).ToString();
|
JsonData _Json = JsonMapper.ToObject(_string);
|
foreach (var key in _Json.Keys)
|
{
|
if (int.Parse(key) == _index)
|
{
|
JsonData _Json1 = _Json[key];
|
if (_Json1.Count != 0)
|
{
|
foreach (var _key in _Json1.Keys)
|
{
|
if (_key == _occupation)
|
return _Json1[_key].ToString();
|
else if (_key == "-")
|
return _Json1[_key].ToString();
|
}
|
}
|
else
|
{
|
return null;
|
}
|
}
|
}
|
return null;
|
}
|
|
|
void TaskChanges(int MissionID, int MissionState, int DiscriptionIndex)//存在的任务的修改
|
{
|
var pytaskM = PyTaskConfig.Get(MissionID);
|
if (pytaskM == null)
|
return;
|
allMissionDict[MissionID].Time = DateTime.Now;
|
allMissionDict[MissionID].MissionState = MissionState;
|
allMissionDict[MissionID].descIndex = DiscriptionIndex;
|
allMissionDict[MissionID].RewardList = RewardInformation(pytaskM.rewardList, DiscriptionIndex);//奖励信息
|
allMissionDict[MissionID].Desclist = TaskDetails(pytaskM.descList, DiscriptionIndex);//任务详情
|
allMissionDict[MissionID].InforList = StrInforList(pytaskM.infoList, DiscriptionIndex);//任务完成条件
|
|
|
if (MissionState == 3)
|
{
|
if (allMissionDict[MissionID].LightList.Equals(default(TsakLight)))
|
{
|
return;
|
}
|
for (int i = 0; i < allMissionDict[MissionID].LightList.Count; i++)
|
{
|
TsakLight TsakLight = new TsakLight();
|
TsakLight.NpcId = allMissionDict[MissionID].LightList[i].NpcId;
|
TsakLight.StateLight = -1;
|
allMissionDict[MissionID].LightList[i] = TsakLight;
|
}
|
return;
|
}
|
else
|
{
|
if (ReplaceDic.ContainsKey(MissionID))
|
{
|
Dictionary<string, int> _dic = ReplaceDic[MissionID];
|
if (_dic.ContainsKey("visit_npc_id") || _dic.ContainsKey("kill_npc_id"))
|
{
|
allMissionDict[MissionID].LightList = CharactersReplace(pytaskM.lightList, DiscriptionIndex, allMissionDict[MissionID].ID);
|
}
|
else
|
{
|
allMissionDict[MissionID].LightList = StrSegmentation(pytaskM.lightList, DiscriptionIndex);//任务信息灯
|
}
|
}
|
else
|
{
|
allMissionDict[MissionID].LightList = StrSegmentation(pytaskM.lightList, DiscriptionIndex);//任务信息灯
|
}
|
}
|
}
|
|
public void Task0820(H0820_tagMissionDict info)//0820信息字典
|
{
|
Dictionary<string, int> dic = null;
|
ReplaceDic.TryGetValue((int)info.MissionID, out dic);
|
if (dic == null)
|
{
|
dic = new Dictionary<string, int>();
|
StorageNPCDic(info.MissionID, info.DictKey, (int)info.DictValue);
|
dic.Add(info.DictKey, (int)info.DictValue);
|
ReplaceDic.Add((int)info.MissionID, dic);
|
}
|
else
|
{
|
if (dic.ContainsKey(info.DictKey))
|
{
|
StorageNPCDic(info.MissionID, info.DictKey, (int)info.DictValue);
|
dic[info.DictKey] = (int)info.DictValue;
|
if (info.DictKey == "around_allcount")
|
{
|
if (TaskCoinTaskEvent != null)
|
{
|
TaskCoinTaskEvent();
|
}
|
}
|
if (info.DictKey == "around_count_family")
|
{
|
if (FairyTaskEvent != null)
|
{
|
FairyTaskEvent();
|
}
|
}
|
}
|
else
|
{
|
StorageNPCDic(info.MissionID, info.DictKey, (int)info.DictValue);
|
dic.Add(info.DictKey, (int)info.DictValue);
|
}
|
}
|
|
}
|
|
public void RequestGetTaskAward(string _answer, int taskId = 0)
|
{
|
if (taskId == clientGuardDugeonTask)
|
{
|
ClientGuardDungeon.RequestEnter();
|
return;
|
}
|
|
var sendInfo = new C0802_tagCNPCAnswer();
|
sendInfo.Answer = _answer;
|
sendInfo.AnswerLen = (byte)_answer.Length;
|
GameNetSystem.Instance.SendInfo(sendInfo);
|
|
if (tryGetTaskAwardEvent != null)
|
{
|
tryGetTaskAwardEvent();
|
}
|
}
|
|
public void TaskRefreshes(int _MissionId, int _DictKeyLen, string _DictKey, int _DictValue)//任务数据的刷新(任务字典信息)
|
{
|
|
if (!_DicTaskInformation.ContainsKey(_MissionId))
|
{
|
Dictionary<string, string> _dic = new Dictionary<string, string>();
|
if (_dic.ContainsKey(_DictKey))
|
{
|
_dic[_DictKey] = _DictValue.ToString();
|
}
|
else
|
{
|
_dic.Add(_DictKey, _DictValue.ToString());
|
}
|
_DicTaskInformation.Add(_MissionId, _dic);
|
string kaji = "kaji";
|
if (_DicTaskInformation.ContainsKey(_MissionId) && _DicTaskInformation[_MissionId].ContainsKey(kaji))
|
{
|
if (MainTaskDic.ContainsKey(_MissionId) && MainCardLevelChange != null && _DictValue == 0)
|
{
|
|
if (IsGetOnBool)
|
{
|
GetNowTaskID = _MissionId;
|
}
|
MainCardLevelChange(_MissionId);
|
|
}
|
}
|
}
|
else
|
{
|
if (_DicTaskInformation[_MissionId].ContainsKey(_DictKey))
|
{
|
_DicTaskInformation[_MissionId][_DictKey] = _DictValue.ToString();
|
if (_DictKey == "kaji" && (_DictValue == 0 || _DictValue == 1))//kaji:0为主线卡级变更,kaji:1为魔族卡级变更
|
{
|
if (CardLevelChange != null)
|
{
|
CardLevelChange(_MissionId);
|
}
|
if (MainTaskDic.ContainsKey(_MissionId))
|
{
|
if (IsGetOnBool)
|
{
|
GetNowTaskID = _MissionId;
|
}
|
if (MainCardLevelChange != null)
|
{
|
MainCardLevelChange(_MissionId);
|
}
|
}
|
}
|
}
|
else
|
{
|
_DicTaskInformation[_MissionId].Add(_DictKey, _DictValue.ToString());
|
}
|
}
|
|
|
if (Event_TaskInformation != null)
|
Event_TaskInformation(_MissionId, _DicTaskInformation);
|
}
|
public void DelMission(int _taskID)//真实任务删除
|
{
|
if (allMissionDict.ContainsKey(_taskID))
|
{
|
allMissionDict.Remove(_taskID);
|
if (_DicTaskInformation.ContainsKey(_taskID))
|
{
|
_DicTaskInformation.Remove(_taskID);
|
}
|
}
|
TaskTypeDeletion(_taskID);
|
if (Event_TaskToDelete != null)
|
{
|
Event_TaskToDelete(_taskID);
|
}
|
}
|
bool _bool = false;
|
string _conversationA = null;
|
public void EventTalk(H0801_tagEventTalk info)//访问任务是否可提交
|
{
|
NPCid = (int)info.NPCID;
|
if (info.Msg == null || info.Msg[0].MsgLen == 0)
|
{
|
_conversation = _conversationA;
|
}
|
else
|
{
|
if (_conversationA != info.Msg[0].Msg)
|
{
|
_conversation = info.Msg[0].Msg;
|
_conversationA = _conversation;
|
}
|
}
|
|
if (_bool)
|
{
|
if ((int)info.MissionID != 0)
|
{
|
_TaskNow = (int)info.MissionID;
|
OnEventTalkEvent((int)info.MissionID);
|
_bool = false;
|
return;
|
}
|
}
|
|
for (int i = 0; i < info.Answer.Length; i++)
|
{
|
string[] str = info.Answer[i].Msg.Split('_');
|
int var;
|
if (str.Length > 1)
|
{
|
for (int j = 0; j < info.Answer.Length; j++)
|
{
|
string[] stX = info.Answer[j].Msg.Split('_');
|
if (stX.Length > 1)
|
{
|
string strXX = stX[stX.Length - 1];
|
if (int.TryParse(strXX, out var))
|
{
|
if (int.Parse(strXX) == GetNowTaskID)
|
{
|
RequestGetTaskAward(strXX);
|
_bool = true;
|
return;
|
}
|
}
|
}
|
}
|
string str1 = str[str.Length - 1];
|
RequestGetTaskAward(str1);
|
_bool = true;
|
return;
|
}
|
else
|
{
|
_bool = false;
|
if ((int)info.NPCID != 32504001)
|
{
|
DefaultDialogue();
|
}
|
return;
|
}
|
}
|
}
|
|
public string pattern = @"\{(.+)\}";
|
|
public int StatusLightQuery(int _NpcID)//状态灯查询
|
{
|
int Light = -1;
|
foreach (int key in allMissionDict.Keys)
|
{
|
if (allMissionDict[key].LightList.Equals(default(TsakLight)))
|
{
|
continue;
|
}
|
for (int i = 0; i < allMissionDict[key].LightList.Count; i++)
|
{
|
if (_NpcID == allMissionDict[key].LightList[i].NpcId)
|
{
|
if (allMissionDict[key].LightList[i].StateLight > Light)
|
{
|
Light = allMissionDict[key].LightList[i].StateLight;
|
}
|
}
|
}
|
}
|
|
return Light;
|
}
|
|
public void DailyFairyTaskMove()//日常仙盟任务
|
{
|
if (SpecialTask.Count != 0)
|
{
|
foreach (int key in SpecialTask.Keys)
|
{
|
if (SpecialTask[key].Type == 14 && SpecialTask[key].MissionState != 3)//未接任务
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(key));
|
return;
|
}
|
}
|
}
|
if (FairyAuDic.Count != 0)
|
{
|
foreach (int key in FairyAuDic.Keys)
|
{
|
if (FairyAuDic[key].MissionState != 0 && FairyAuDic[key].MissionState != 3)
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(key));
|
return;
|
}
|
}
|
}
|
}
|
public void DailyBountyMove()//日常赏金任务
|
{
|
if (SpecialTask.Count != 0)
|
{
|
foreach (int key in SpecialTask.Keys)
|
{
|
if (SpecialTask[key].Type == 13 && SpecialTask[key].MissionState != 3)//未接任务
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(key));
|
return;
|
}
|
}
|
}
|
if (BountyDic.Count != 0)
|
{
|
foreach (int key in BountyDic.Keys)
|
{
|
if (BountyDic[key].MissionState != 0 && BountyDic[key].MissionState != 3)
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(key));
|
return;
|
}
|
}
|
}
|
}
|
|
|
private void AutotaskingPrecedence(bool automaticityBool, int missionID)//关于是否执行自动任务和自动任务的优先级
|
{
|
if (automaticityBool)
|
{
|
var inDungeon = IsDungeon();
|
|
if (inDungeon)//判断是否再副本中对任务ID进行储存
|
{
|
retainTaskID = Autotasking(missionID);
|
}
|
else
|
{
|
retainTaskID = 0;
|
if (Autotasking(missionID) != 0)
|
{
|
AutomaticTripToTask(Autotasking(missionID));
|
}
|
}
|
}
|
}
|
|
private int Autotasking(int taskID)
|
{
|
foreach (var value in MainTaskDic.Values)
|
{
|
if (value.MissionState != 0 && value.MissionState != 3)
|
{
|
if (allMissionDict.ContainsKey(taskID) && (allMissionDict[taskID].Time - value.Time).TotalSeconds <= 1)
|
{
|
if (ReplaceDic.ContainsKey(value.ID))
|
{
|
Dictionary<string, int> _dic = ReplaceDic[value.ID];
|
if (_dic.ContainsKey("continue") && _dic["continue"] == 1)
|
{
|
return value.ID;
|
}
|
}
|
}
|
}
|
}
|
if (ReplaceDic.ContainsKey(taskID))
|
{
|
Dictionary<string, int> _dic = ReplaceDic[taskID];
|
if (_dic.ContainsKey("continue") && _dic["continue"] == 1)
|
{
|
return taskID;
|
}
|
}
|
return 0;
|
}
|
|
|
public void AutomaticTripToTask(int _taskID)//任务自动前往(任务添加)
|
{
|
try
|
{
|
if (!allowAutoTaskMapIds.Contains(PlayerDatas.Instance.baseData.MapID))
|
{
|
return;
|
}
|
|
var _hero = PlayerDatas.Instance.hero;
|
if (_hero != null)
|
{
|
if (MapArea.IsInMapArea(_hero.CurMapArea, MapArea.E_Type.Boss))
|
{
|
return;
|
}
|
}
|
|
if (MainTaskDic.ContainsKey(_taskID))//主线任务
|
{
|
if (MainTaskDic[_taskID].MissionState == 0 || MainTaskDic[_taskID].MissionState == 3)
|
return;
|
if (MainTaskDic.ContainsKey(_taskID))
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
if (PlayerDatas.Instance.baseData.LV != 1)
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(_taskID));
|
return;
|
}
|
}
|
if (BountyDic.ContainsKey(_taskID))//赏金任务
|
{
|
if (BountyDic[_taskID].MissionState == 3 || BountyMotionBool)
|
{
|
return;
|
}
|
else
|
{
|
if (BountyDic.ContainsKey(_taskID))
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(_taskID));
|
return;
|
}
|
}
|
}
|
else if (FairyAuDic.ContainsKey(_taskID))//仙盟任务
|
{
|
if (FairyAuDic[_taskID].MissionState == 3 || FairyAuBool)
|
{
|
return;
|
}
|
if (FairyAuDic.ContainsKey(_taskID))
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(_taskID));
|
return;
|
}
|
}
|
else if (SideQuestsDic.ContainsKey(_taskID))
|
{
|
if (SideQuestsDic[_taskID].MissionState == 0 || SideQuestsDic[_taskID].MissionState == 3)
|
{
|
return;
|
}
|
else
|
{
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI();
|
SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(_taskID));
|
return;
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
DebugEx.Log(ex);
|
}
|
}
|
|
public void RunTaskAwarInfo(HA708_tagMCRunTaskAwardInfo info)//通知跑环奖励记录
|
{
|
for (int i = 0; i < info.Cnt; i++)
|
{
|
if (!AwardRecordDic.ContainsKey(info.InfoList[i].Type))
|
{
|
RunTaskAwardRecord _RunTaskAwardRecord = new RunTaskAwardRecord();
|
_RunTaskAwardRecord.Num = (int)info.InfoList[i].Num;
|
_RunTaskAwardRecord.AwardState = info.InfoList[i].AwardState;
|
AwardRecordDic.Add(info.InfoList[i].Type, _RunTaskAwardRecord);
|
}
|
else
|
{
|
AwardRecordDic[info.InfoList[i].Type].Num = (int)info.InfoList[i].Num;
|
AwardRecordDic[info.InfoList[i].Type].AwardState = info.InfoList[i].AwardState;
|
}
|
if (info.InfoList[i].Type == (int)TaskTypenum.BountyMissionsType7)
|
{
|
BountyRewardsNumber = (int)info.InfoList[i].Num;
|
if (Event_BountyRewards != null)
|
Event_BountyRewards((int)info.InfoList[i].Num, info.InfoList[i].AwardState);
|
}
|
else if (info.InfoList[i].Type == (int)TaskTypenum.FairyAuMissionType12)
|
{
|
OnFairyAuNumber = (int)info.InfoList[i].Num;
|
if (Event_FairyAuReward != null)
|
Event_FairyAuReward((int)info.InfoList[i].Num, info.InfoList[i].AwardState);
|
}
|
}
|
}
|
|
private PackModel packModel
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<PackModel>();
|
}
|
}
|
|
private IEnumerator WaitForSkillFinished(int _taskID)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
|
if (_hero == null)
|
{
|
yield break;
|
}
|
while (_hero != null && _hero.SkillMgr.CurCastSkill != null &&
|
_hero.SkillMgr.CurCastSkill.SkillCompelete == false)
|
{
|
yield return null;
|
}
|
|
yield return WaitingForSecondConst.WaitMS500;
|
|
// 如果有守护, 则不拾取
|
var equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard));
|
var _itemModel = packModel.GetItemByIndex(PackType.Equip, equipIndex);
|
if (_itemModel == null || !GeneralDefine.GuardianPickUpID.Contains(_itemModel.itemId))
|
{
|
float _chkDistanceSqrt;
|
DropItemManager.DropObject _obj = null;
|
while (DropItemManager.HandupTryGetHeroItem(out _obj))
|
{
|
if (DropItemManager.StopMissionPickup)
|
{
|
break;
|
}
|
if (MapTransferUtility.Instance.MapTransferDoType != MapTransferUtility.E_MapTransferDoType.None)
|
{
|
break;
|
}
|
Vector3 _targetPosition = _obj.dropItem.transform.position;
|
_chkDistanceSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _targetPosition);
|
if (_chkDistanceSqrt > 0.5f)
|
{
|
if (_hero.State != E_ActorState.AutoRun)
|
{
|
_hero.MoveToPosition(_targetPosition);
|
}
|
}
|
|
yield return null;
|
}
|
}
|
|
if (AdventureStage.Instance.IsInAdventureStage)
|
{
|
yield break;
|
}
|
|
if (NewBieCenter.Instance.inGuiding || ModelCenter.Instance.GetModel<TreasureModel>().newGotShowing
|
|| WindowCenter.Instance.IsOpen<TreasureChapterWin>())
|
{
|
yield break;
|
}
|
|
if (WindowCenter.Instance.IsOpen<TreasureBaseWin>())
|
{
|
yield break;
|
}
|
|
if (WindowCenter.Instance.IsOpen<MysteriousMissionWin>())
|
{
|
yield break;
|
}
|
|
if (CrossServerUtility.IsCrossServer())
|
{
|
yield break;
|
}
|
|
if (BossShowModel.Instance.BossShowing)
|
{
|
yield break;
|
}
|
|
if (BountyDic.ContainsKey(_taskID) || FairyAuDic.ContainsKey(_taskID))
|
{
|
yield return WaitingForSecondConst.WaitMS800;//缓冲一秒再进行
|
}
|
|
if (MainTaskDic.ContainsKey(_taskID))//主线等待表现
|
{
|
if (taskWait.wait)
|
{
|
yield return WaitingForSecondConst.GetWaitForSeconds(mainTaskAutoWaitTime);
|
}
|
}
|
|
while(ClientSceneManager.Instance.isWaitPickup)
|
{
|
yield return null;
|
}
|
|
if (GA_Hero.s_MapSwitching)
|
{
|
yield break;
|
}
|
try
|
{
|
TaskMove(_taskID);
|
}
|
catch (Exception ex)
|
{
|
DebugEx.Log(ex);
|
}
|
|
}
|
|
private int GetNPCID(Dictionary<string, int> _Dic)
|
{
|
foreach (string key in _Dic.Keys)
|
{
|
if (key.Equals("Show_{visit_npc_id}"))
|
{
|
continue;
|
}
|
string[] str = key.Split('_');
|
if (str[0] == "Show")
|
{
|
return int.Parse(str[1]);
|
}
|
}
|
return 0;
|
}
|
|
private int CacheNpcID = 0;
|
|
private void StorageNPCDic(uint taskId, string key, int Value)//关于NPC的显隐
|
{
|
if (key.Equals("Show_{visit_npc_id}"))
|
{
|
m_ShowNpcCache[(int)taskId] = Value;
|
if (CacheNpcID != 0)
|
{
|
Task0820(new H0820_tagMissionDict()
|
{
|
MissionID = taskId,
|
DictKey = "Show_" + CacheNpcID,
|
DictValue = (uint)m_ShowNpcCache[(int)taskId],
|
});
|
m_ShowNpcCache.Remove(CacheNpcID);
|
CacheNpcID = 0;
|
}
|
return;
|
}
|
|
if (key.Equals("visit_npc_id"))
|
{
|
CacheNpcID = Value;
|
if (m_ShowNpcCache.ContainsKey((int)taskId))
|
{
|
Task0820(new H0820_tagMissionDict()
|
{
|
MissionID = taskId,
|
DictKey = "Show_" + CacheNpcID,
|
DictValue = (uint)m_ShowNpcCache[(int)taskId],
|
});
|
m_ShowNpcCache.Remove((int)taskId);
|
CacheNpcID = 0;
|
}
|
return;
|
}
|
|
string[] str = key.Split('_');
|
if (str[0] == "Show")
|
{
|
int NPCid = int.Parse(str[1]);
|
if (NPCShowDic.ContainsKey(NPCid))
|
{
|
NPCShowDic[NPCid] = Value;
|
}
|
else
|
{
|
NPCShowDic.Add(NPCid, Value);
|
}
|
|
ShowNpc((int)taskId, NPCid);
|
}
|
}
|
|
private void ShowNpc(int taskID, int Npcid = -1)
|
{
|
if (ReplaceDic.ContainsKey(taskID))
|
{
|
if (Npcid > 0)
|
{
|
if (Npcid != 0 && NPCShowDic.ContainsKey(Npcid))
|
{
|
if (NPCShowDic[Npcid] == 0)
|
{
|
GA_NpcFunc.SetNpcFuncVisible(Npcid, false);
|
}
|
else if (NPCShowDic[Npcid] == 1)
|
{
|
GA_NpcFunc.SetNpcFuncVisible(Npcid, true);
|
}
|
}
|
}
|
}
|
}
|
|
private void IsShowNpC(int _taskID)//关于NPC的显隐
|
{
|
if (ReplaceDic.ContainsKey(_taskID))
|
{
|
Dictionary<string, int> showNpcDic = ReplaceDic[_taskID];
|
int Npcid = GetNPCID(showNpcDic);
|
if (Npcid != 0 && NPCShowDic.ContainsKey(Npcid))
|
{
|
if (NPCShowDic[Npcid] == 0)
|
{
|
GA_NpcFunc.SetNpcFuncVisible(Npcid, false);
|
}
|
else if (NPCShowDic[Npcid] == 1)
|
{
|
GA_NpcFunc.SetNpcFuncVisible(Npcid, true);
|
}
|
}
|
}
|
}
|
|
public enum TaskStatus//任务状态
|
{
|
None = -5,//没有
|
Normal = 0,//正常任务(绿)
|
TreasureCardLevel = 1,//法宝卡级(红)
|
CardLevel = 2,//等级卡级(红)
|
Completed = 3,//立即完成任务
|
}
|
public TaskStatus GetTaskStatus(int taskID)
|
{
|
if (_DicTaskInformation.ContainsKey(taskID) && _DicTaskInformation[taskID].ContainsKey("kaji"))
|
{
|
var kaji = _DicTaskInformation[taskID]["kaji"];
|
|
switch (int.Parse(kaji))
|
{
|
case 0:
|
return TaskStatus.Normal;
|
case 1:
|
return TaskStatus.TreasureCardLevel;
|
case 2:
|
return TaskStatus.CardLevel;
|
case 3:
|
return TaskStatus.Completed;
|
default:
|
return TaskStatus.None;
|
}
|
}
|
else
|
{
|
return TaskStatus.None;
|
}
|
|
}
|
private bool IsDungeon()//判断是否在副本中
|
{
|
if (ClientDungeonStageUtility.isClientDungeon)
|
return true;
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
return mapConfig != null && mapConfig.MapFBType != 0;
|
}
|
public bool IsGather(int npdId)//是否能采集NPC
|
{
|
var taskListConfig = TaskListConfig.Get(currentMission);
|
if (taskListConfig != null)
|
{
|
int[] collectNPCList = taskListConfig.CollectNPC;
|
var isTaskNPC = false;
|
for (int i = 0; i < collectNPCList.Length; i++)
|
{
|
if (collectNPCList[i] == npdId)
|
{
|
isTaskNPC = true;
|
break;
|
}
|
}
|
if (isTaskNPC)
|
{
|
if ((collectNPCList.Length == 1 && collectNPCList[0] == 0) || GetTaskStatus(currentMission) != 0)
|
{
|
return false;
|
|
}
|
}
|
|
}
|
return true;
|
}
|
|
public static bool IsOPenAutoResolve()//任务面板不开启自动挂机状态
|
{
|
bool _bool = true;
|
if (WindowCenter.Instance.IsOpen<TaskBoxBGMWin>())
|
{
|
_bool = false;
|
}
|
else if (WindowCenter.Instance.IsOpen<DefaultDialogueBoxWin>())
|
{
|
_bool = false;
|
}
|
else if (WindowCenter.Instance.IsOpen<DialogueDuidanceWin>())
|
{
|
_bool = false;
|
}
|
return _bool;
|
}
|
|
private int BOUNTYTASK = 2009;//赏金任务
|
private int FAIRYAUTASK = 3009;//仙盟任务
|
private void TaskTerminationToHangUp(int taskID, int MissionState)//(完成任务后前往挂机地点)任务ID,任务状态
|
{
|
if (!isServerPrepare)
|
{
|
return;
|
}
|
if ((taskID == BOUNTYTASK && MissionState == 1 && !BountyMotionBool && TaskAllocation.Instance.ForRingAllNumber() != 10)
|
|| (taskID == FAIRYAUTASK && MissionState == 1 && !FairyAuBool && TaskAllocation.Instance.FairyAuAllNumber() == 70))
|
{
|
var mapModel = ModelCenter.Instance.GetModel<MapModel>();
|
var point = mapModel.GetRecommendHangPoint();
|
var config = MapEventPointConfig.Get(point);
|
MapTransferUtility.Instance.MoveToNPC(config.NPCID);
|
|
}
|
}
|
public void CompletionOfTask(int TaskID)//任务完成
|
{
|
CA206_tagCMQuickFinishMission _CA206 = new CA206_tagCMQuickFinishMission();
|
_CA206.MissionID = (uint)TaskID;
|
_CA206.DoType = 0;
|
GameNetSystem.Instance.SendInfo(_CA206);
|
}
|
|
public int SideQuestState(int TaskID)//关于查询任务的状态(-1没有此任务,0未接,1正在进行中,2可提交)
|
{
|
if (allMissionDict.ContainsKey(TaskID))
|
{
|
return allMissionDict[TaskID].MissionState;
|
}
|
else
|
{
|
return -1;
|
}
|
}
|
|
public int GetQuestState(int _taskId)
|
{
|
if (allMissionDict.ContainsKey(_taskId))
|
{
|
return allMissionDict[_taskId].MissionState;
|
}
|
else
|
{
|
return -1;
|
}
|
}
|
//--------主要用于记录任务列表选中条的智能性 (-_-||)
|
public int TaskupToDate = 0;//获取最新任务ID
|
public int GetOnTaskId = 0;
|
public bool IsGetOnBool = false;
|
private int NeedTime = 10;
|
private DateTime dateTimeA;
|
public void GetTaskGetOnNow(int TaskID, string DictKey)//记录下信息字典的ID
|
{
|
string key1Str = "on_kill_" + TaskID;
|
string key2Str = "get_byid_" + TaskID;
|
if (TaskID > 1 && (key1Str == DictKey || key2Str == DictKey))
|
{
|
GetOnTaskId = TaskID;
|
dateTimeA = DateTime.Now;
|
}
|
|
}
|
private void secondEvent()
|
{
|
TimeSpan timeS = DateTime.Now - dateTimeA;
|
int timeSend = timeS.Seconds;
|
if (timeSend >= NeedTime)
|
{
|
IsGetOnBool = true;
|
GetOnTaskId = GetNowTaskID;//获取当前选中的ID
|
}
|
else
|
{
|
IsGetOnBool = false;
|
}
|
|
if (TaskOverBool)
|
{
|
Times += 1;
|
if (Times >= NeedTime)
|
{
|
TaskOverBool = false;
|
}
|
}
|
else
|
{
|
if (Times != 0)
|
{
|
Times = 0;
|
}
|
}
|
}
|
|
|
public bool IsTaskMove()
|
{
|
bool IsBool = false;
|
if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
|
{
|
return IsBool;
|
}
|
if (PlayerDatas.Instance.baseData.LV > TaskAutoLv)
|
{
|
return IsBool;
|
}
|
if (GetTaskStatus(currentMission) == TaskStatus.Normal)
|
{
|
IsBool = true;
|
}
|
return IsBool;
|
}
|
public void TaskMove(int _taskID)
|
{
|
if (allMissionDict.ContainsKey(_taskID) && !NewBieCenter.Instance.inGuiding)
|
{
|
string _strTest = allMissionDict[_taskID].InforList;
|
string strTask = TaskAllocation.Instance.GetTaskInfo(TASKINFOConfig.Get(_strTest).show_writing, _taskID);
|
HrefAnalysis.Inst.ExcuteHrefEvent(strTask, 0, true);
|
DropItemManager.StopMissionPickup = false;
|
TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow;
|
}
|
}
|
|
public class TaskWait
|
{
|
public bool wait
|
{
|
get
|
{
|
foreach (var key in taskWaits.Keys)
|
{
|
if ((Time.realtimeSinceStartup - taskWaits[key]) < 1f)
|
{
|
#if UNITY_EDITOR
|
DebugEx.LogFormat("<color=#00ffff>由于{0}开始任务等待</color>", GetTaskWaitTypeLabel(key));
|
#endif
|
return true;
|
}
|
}
|
return false;
|
}
|
}
|
|
Dictionary<TaskWaitType, float> taskWaits = new Dictionary<TaskWaitType, float>();
|
|
public void Push(TaskWaitType type)
|
{
|
taskWaits[type] = Time.realtimeSinceStartup;
|
}
|
|
#if UNITY_EDITOR
|
static string GetTaskWaitTypeLabel(TaskWaitType waitType)
|
{
|
switch (waitType)
|
{
|
case TaskWaitType.TaskComplete:
|
return "主界面任务完成表现";
|
case TaskWaitType.LevelUp:
|
return "玩家升级表现";
|
case TaskWaitType.TreasureProgress:
|
return "法宝进度更新";
|
case TaskWaitType.BetterEquip:
|
return "获得更好装备";
|
default:
|
return waitType.ToString();
|
}
|
}
|
#endif
|
}
|
|
public enum TaskWaitType
|
{
|
TaskComplete,
|
LevelUp,
|
TreasureProgress,
|
BetterEquip,
|
}
|
}
|