public void TriggerTaskByTargetType(TaskTargetType type, int count) { //Dictionary<int, DBTask>.Enumerator em = ZTConfig.Instance.DictTask.GetEnumerator(); //int pRoleLevel = DataManager.Instance.GetCurRole().Level; //while (em.MoveNext()) //{ // DBTask db = em.Current.Value; // int taskID = em.Current.Key; // if (db.TargetType != type) // { // continue; // } // if (db.MinRquireLevel > pRoleLevel) // { // continue; // } // if (db.MaxRquireLevel > 0 && pRoleLevel > db.MaxRquireLevel) // { // continue; // } // switch (em.Current.Value.Type) // { // case TaskType.DAILY: // { // XDailyTask data = DataManager.Instance.GetDailyTaskDataById(taskID); // if (data == null) // { // data = new XDailyTask(); // data.Id = taskID; // data.State = (int)TaskState.QUEST_DOING; // } // data.Count += count; // if (data.Count >= db.Condition) // { // data.Count = count; // data.State = (int)TaskState.QUEST_CANSUBMIT; // } // DataManager.Instance.DataDailyTask.Update(taskID, data); // } // break; // } //} //em.Dispose(); }
private void DealByType(TaskData taskData, bool checkItems) { A3_TaskOpt.Instance.ResetStat(); A3_TaskOpt.Instance.Reset(alsoHideGameObject: true, resetCase: 0); TaskTargetType taskTargetType = taskData.targetType; TaskType taskType = taskData.taskT; if (A3_TaskOpt.Instance == null) { //Debug.LogError("请将A3_TaskOpt预制件默认设为Active"); return;// not init } if (!A3_TaskOpt.Instance.taskOptElement.ContainsKey(taskData.taskId)) { A3_TaskOpt.Instance.taskOptElement[taskData.taskId] = new TaskOptElement(taskData.taskId); } A3_TaskOpt.Instance.curTaskId = taskData.taskId; if (taskTargetType == TaskTargetType.WAIT_POINT_GIVEN /* || TaskTargetType.MESSAGE_GIVEN_POS == taskTargetType*/) { Vector3 waitPosition = Vector3.zero; var pointInfo = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId); //A3_TaskOpt.Instance.IsOnTaskWait = true; A3_TaskOpt.Instance.LockStat = false; if (A3_TaskOpt.Instance.isWaiting) { A3_TaskOpt.Instance.StopCD(); } A3_TaskOpt.Instance.BtnWait.interactable = true; A3_TaskOpt.Instance.waitPosition = new Vector3(pointInfo.getFloat("target_coordinate_x"), 0, pointInfo.getFloat("target_coordinate_y")); waitPosition = A3_TaskOpt.Instance.waitPosition; A3_TaskOpt.Instance.actionImage.sprite = GAMEAPI.ABUI_LoadSprite("icon_task_action_" + pointInfo.getInt("act_icon")); A3_TaskOpt.Instance.transform.FindChild("wait/action_text").GetComponent <Text>().text = pointInfo.getString("act_name"); #region PlayerModel.getInstance().task_monsterIdOnAttack[taskData.taskId] = pointInfo.getInt("target_param2"); //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData //{ // mapId = pointInfo.getInt("tasking_map_id"), // check_beforeShow = true, // handle_customized_afterTransmit = () => SelfRole.WalkToMap(pointInfo.getInt("tasking_map_id"), // waitPosition), // targetPosition = waitPosition //}); int mapId = pointInfo.getInt("tasking_map_id"); if (MapModel.getInstance().dicMappoint.ContainsKey(mapId)) { int mapPoint = MapModel.getInstance().dicMappoint[mapId]; if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint) { SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, waitPosition, taskmove: true), taskTrans: true); } else { SelfRole.WalkToMap(mapId, waitPosition, taskmove: true); } } } // endif wait given point else if (taskTargetType == TaskTargetType.KILL_MONSTER_GIVEN) { A3_TaskOpt.Instance.IsOnKillMon = true; Vector3 waitPosition = Vector3.zero; SXML monInfo = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId); if (monInfo != null) { //A3_TaskOpt.Instance.IsOnKillMon = true; A3_TaskOpt.Instance.LockStat = false; PlayerModel.getInstance().task_monsterIdOnAttack.Add(taskData.taskId, monInfo.getInt("target_param2")); A3_TaskOpt.Instance.killPosition = new Vector3(monInfo.getFloat("target_coordinate_x"), 0, monInfo.getFloat("target_coordinate_y")); waitPosition = A3_TaskOpt.Instance.killPosition; } //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData //{ // mapId = monInfo.getInt("tasking_map_id"), // check_beforeShow = true, // handle_customized_afterTransmit = () => SelfRole.WalkToMap(monInfo.getInt("tasking_map_id"), // waitPosition), // targetPosition = waitPosition //}); int mapId = monInfo.getInt("tasking_map_id"); if (MapModel.getInstance().dicMappoint.ContainsKey(mapId)) { int mapPoint = MapModel.getInstance().dicMappoint[mapId]; if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint) { SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, waitPosition, taskmove: true), taskTrans: true); } else { SelfRole.WalkToMap(mapId, waitPosition, taskmove: true); } } } // endif kill given monster else if (taskTargetType == TaskTargetType.GET_ITEM_GIVEN) { int holdNum = 0, needNum = 0; //A3_TaskOpt.Instance.IsOnTaskWait = true; Action uiHandle = null; NpcShopData npcShopData = null; SXML taskinfoGetItem = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId); A3_TaskOpt.Instance.taskItemId = taskinfoGetItem.getUint("target_param2"); needNum = taskData.completion - taskData.taskRate;//taskinfoGetItem.getInt("target_param1"); holdNum = a3_BagModel.getInstance().getItemNumByTpid(A3_TaskOpt.Instance.taskItemId); uiHandle = () => A3_TaskOpt.Instance?.ShowSubmitItem(); npcShopData = A3_NPCShopModel.getInstance().GetDataByItemId(A3_TaskOpt.Instance.taskItemId); if (holdNum >= needNum) { int npcId = taskinfoGetItem.getInt("complete_npc_id"); int mapId = taskinfoGetItem.getInt("tasking_map_id"); SXML npcInfo = XMLMgr.instance.GetSXML("npcs").GetNode("npc", "id==" + npcId); float mapY = npcInfo.getFloat("location_height"); if (mapY < 0) { mapY = 0; } Vector3 npcPos = new Vector3(npcInfo.getFloat("location_x") / GameConstant.GEZI_TRANS_UNITYPOS, mapY / GameConstant.GEZI_TRANS_UNITYPOS, npcInfo.getFloat("location_y") / GameConstant.GEZI_TRANS_UNITYPOS); //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData //{ // mapId = mapId, // check_beforeShow = true, // handle_customized_afterTransmit = () => // { // SelfRole.WalkToMap(mapId, npcPos, handle: () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, stopDis: 2f); // } //}); if (MapModel.getInstance().dicMappoint.ContainsKey(mapId)) { int mapPoint = MapModel.getInstance().dicMappoint[mapId]; if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint) { SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, npcPos, () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, 2f, taskmove: true), taskTrans: true); } else { SelfRole.WalkToMap(mapId, npcPos, () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, 2f, taskmove: true); } } } else if (npcShopData != null) { //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData //{ // mapId = npcShopData.mapId, // check_beforeShow = true, // handle_customized_afterTransmit = () => SelfRole.moveToNPc(npcShopData.mapId, npcShopData.npc_id) //}); int mapId = npcShopData.mapId; if (!PlayerModel.getInstance().inFb&& mapId != GRMap.instance.m_nCurMapID && MapModel.getInstance().dicMappoint.ContainsKey(mapId) && MapModel.getInstance().dicMappoint[mapId] != GRMap.instance.m_nCurMapID) { SelfRole.Transmit(toid: MapModel.getInstance().dicMappoint[mapId], after: () => SelfRole.moveToNPc(mapId, npcShopData.npc_id, taskmove: true), taskTrans: true); } else { SelfRole.moveToNPc(mapId, npcShopData.npc_id, taskmove: true); } } else { if (checkItems) { ArrayList data = new ArrayList(); data.Add(a3_BagModel.getInstance().getItemDataById(A3_TaskOpt.Instance.taskItemId)); //data.Add(null); InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_ITEMLACK, data); } } } // endif get given item #endregion }
private void OnCheck(GameEvent e) { Variant data = e.data; if (data == null) { return; } if (data.ContainsKey("change_task") && data["change_task"].Length > 0) { Variant task = data["change_task"][0]; if (task.ContainsKey("id")) { int taskId = task["id"]._int; TaskData taskData = A3_TaskModel.getInstance().GetTaskDataById(taskId); if (taskOptElement.ContainsKey(taskId) && task.ContainsKey("cnt") && task["cnt"]._int >= taskData.completion) { taskOptElement[taskId].Set( isKeepingKillMon: false, isTaskMonsterAlive: false, timeKillTerminal: -1 ); if (taskOptElement.ContainsKey(taskId)) { taskOptElement[taskId].Set(isTaskMonsterAlive: false); taskOptElement[taskId].liteMinimapTaskTimer.gameObject?.SetActive(false); taskOptElement.Remove(taskId); } //taskOptElement[taskId].liteMinimapTaskTimer.gameObject.SetActive(false); } else if (taskData.targetType == TaskTargetType.KILL_MONSTER_GIVEN) { uint lose_tm = task.ContainsKey("lose_tm") ? task["lose_tm"]._uint : 0; taskOptElement[taskId].Set( isKeepingKillMon: true, isTaskMonsterAlive: taskData.release_tm > lose_tm - muNetCleint.instance.CurServerTimeStamp, timeKillTerminal: lose_tm ); } } } else { int taskId = 0; Variant misData = new Variant(); TaskTargetType taskTargetType = default(TaskTargetType); if (data.ContainsKey("mlmis")) { taskTargetType = A3_TaskModel.getInstance().GetTaskDataById((taskId = (misData = data["mlmis"])["id"]._int)).targetType; } if (data.ContainsKey("bmis")) { misData = data["bmis"]; if (misData != null) { taskId = misData["id"]._int; if (taskId > 0) { TaskData tData = A3_TaskModel.getInstance().GetTaskDataById(taskId); if (tData != null) { taskTargetType = tData.targetType; } } } } if (data.ContainsKey("dmis")) { taskTargetType = A3_TaskModel.getInstance().GetTaskDataById((taskId = (misData = data["dmis"])["id"]._int)).targetType; } if (data.ContainsKey("emis")) { taskTargetType = A3_TaskModel.getInstance().GetTaskDataById((taskId = (misData = data["emis"])["id"]._int)).targetType; } if (data.ContainsKey("cmis")) { taskTargetType = A3_TaskModel.getInstance().GetTaskDataById((taskId = (misData = data["cmis"])["id"]._int)).targetType; } if (taskTargetType == TaskTargetType.KILL_MONSTER_GIVEN) { if (misData != null) { long timeKillTerminal; if (misData.ContainsKey("cnt") && misData["cnt"] < A3_TaskModel.getInstance().GetTaskDataById(taskId).completion&& misData.ContainsKey("lose_tm")) { timeKillTerminal = misData["lose_tm"]._int64; } else { timeKillTerminal = 0; } if (taskOptElement.ContainsKey(taskId)) { taskOptElement[taskId].Set(isKeepingKillMon: true, isTaskMonsterAlive: false, timeKillTerminal: timeKillTerminal); } } } else if (taskTargetType == TaskTargetType.GET_ITEM_GIVEN) { taskItemId = (uint)A3_TaskModel.getInstance().GetTaskDataById(taskId).completionAim;//GetTaskXML().GetNode("task", "id==" + taskId).getUint("target_param2"); } } if (!IsInvoking("RunTimer")) { InvokeRepeating("RunTimer", 0f, 1.0f); } }