//------------------------------------------------------------------------- public override void onInit() { TbDataTaskKillMonster = EbDataMgr.Instance.getData <TbDataTaskKillMonster>(TaskData.task_id); ListMonsterData = new List <OneMonsterData>(); if (TaskData.task_state == TaskState.Init) { if (TbDataTask.AcceptNpcId == 0) { TaskData.task_state = TaskState.Doing; } else { TaskData.task_state = TaskState.CanDo; } } _loadTaskData(); if (TaskData.task_state == TaskState.Doing && _isDone()) { TaskData.task_state = TaskState.Done; } if (TaskData.task_state == TaskState.Done && TbDataTask.FinishNpcId == 0) { TaskData.task_state = TaskState.Release; TaskMgr._serverAddDirtyTask(this); } }
//------------------------------------------------------------------------- public override void c2sTaskFinish() { if (TaskData.task_state == TaskState.Doing) { TaskData.task_state = TaskState.Done; TaskMgr._serverAddDirtyTask(this); if (TbDataTask.FinishNpcId == 0) { TaskData.task_state = TaskState.Release; TaskMgr._serverAddDirtyTask(this); } } }
//------------------------------------------------------------------------- public override void onInit() { CoPlayer = Entity.getComponent <CellPlayer <DefPlayer> >(); TbDataTaskCollectItem = EbDataMgr.Instance.getData <TbDataTaskCollectItem>(TaskData.task_id); ListItemData = new List <OneItemData>(); if (TaskData.task_state == TaskState.Init) { if (TbDataTask.AcceptNpcId == 0) { TaskData.task_state = TaskState.Doing; } else { TaskData.task_state = TaskState.CanDo; } } // 主动查询一次背包中是否有所需任务物品 foreach (var i in TbDataTaskCollectItem.ListCollectItem) { OneItemData one_item_data = new OneItemData(); one_item_data.item_id = i.item_id; one_item_data.num_total = i.count; int num_cur = CoPlayer.CoBag.getItemNumByItemId(i.item_id); if (num_cur > i.count) { num_cur = i.count; } one_item_data.num_cur = num_cur; ListItemData.Add(one_item_data); } if (TaskData.task_state == TaskState.Doing && _isDone()) { TaskData.task_state = TaskState.Done; } _saveTaskData(); if (TaskData.task_state == TaskState.Done && TbDataTask.FinishNpcId == 0) { TaskData.task_state = TaskState.Release; TaskMgr._serverAddDirtyTask(this); } }
//------------------------------------------------------------------------- public override void handleEvent(object sender, EntityEvent e) { if (e is EvCellBagAddItem) { // CellBag,添加道具消息 var ev = (EvCellBagAddItem)e; // 主动查询一次背包中是否有所需任务物品 foreach (var i in TbDataTaskCollectItem.ListCollectItem) { int num_cur = CoPlayer.CoBag.getItemNumByItemId(i.item_id); if (num_cur > i.count) { num_cur = i.count; } foreach (var j in ListItemData) { if (j.item_id == i.item_id) { if (j.num_cur != num_cur) { j.num_cur = num_cur; _saveTaskData(); TaskMgr._serverAddDirtyTask(this); } break; } } } if (TaskData.task_state == TaskState.Doing && _isDone()) { TaskData.task_state = TaskState.Done; TaskMgr._serverAddDirtyTask(this); } if (TaskData.task_state == TaskState.Done && TbDataTask.FinishNpcId == 0) { TaskData.task_state = TaskState.Release; TaskMgr._serverAddDirtyTask(this); } } }