260 lines
9.8 KiB
TypeScript
260 lines
9.8 KiB
TypeScript
import GameUtil from "../core/GameUtil";
|
|
import Task from "./Task";
|
|
import EventTalkNpc from "./EventTalkNpc";
|
|
import GatherNpc from "./GatherNpc";
|
|
import DoActionInArea from "./DoActionInArea";
|
|
import ArriveArea from "./ArriveArea";
|
|
import KillDynamicNpc from "./KillDynamicNpc";
|
|
import FailEventPlayerDead from "../event/FailEventPlayerDead";
|
|
import FailEventTimeOut from "../event/FailEventTimeOut";
|
|
import GiveNpcItem from "../event/GiveNpcItem";
|
|
import { EEventType } from "../role/EEnum";
|
|
import SKDataUtil from "../gear/SKDataUtil";
|
|
import SKLogger from "../gear/SKLogger";
|
|
|
|
export default class TaskConfigMgr {
|
|
static shared = new TaskConfigMgr();
|
|
mapConfigTask: { [key: number]: Task[] };
|
|
|
|
constructor() {
|
|
this.mapConfigTask = {};
|
|
}
|
|
|
|
GetTaskEventCreateNpc(vecString: any): any {
|
|
let vecData = [];
|
|
for (let it in vecString) {
|
|
let strData = vecString[it];
|
|
let vecTmp = strData.split(",");
|
|
if (vecTmp.length != 4)
|
|
continue;
|
|
vecData.push({ nNpc: vecTmp[0], nMap: vecTmp[1], nX: vecTmp[2], nY: vecTmp[3] });
|
|
}
|
|
return vecData;
|
|
}
|
|
// 获得活动任务最大次数
|
|
getDailyMaxCount(groupId:number): number {
|
|
if (groupId == 2 || groupId == 3) {
|
|
return 20;
|
|
}
|
|
if (groupId == 4) {
|
|
return 15;
|
|
}
|
|
if (groupId == 5) {
|
|
return 5;
|
|
}
|
|
if (groupId == 6) {
|
|
return 120;
|
|
}
|
|
if (groupId == 7) {
|
|
return 20;
|
|
}
|
|
if (groupId == 8) {
|
|
return 20;
|
|
}
|
|
if (groupId == 9) {
|
|
return 3;
|
|
}
|
|
if (groupId == 10) {
|
|
return 14;
|
|
}
|
|
if (groupId == 11) {
|
|
return 13;
|
|
}
|
|
if (groupId == 12) {
|
|
return 200;
|
|
}
|
|
if (groupId == 13) {
|
|
return 2;
|
|
}
|
|
if (groupId == 14) {
|
|
return 7;
|
|
}
|
|
if (groupId == 16) {
|
|
return 10;
|
|
}
|
|
if (groupId == 17) {
|
|
return 1;
|
|
}
|
|
if (groupId == 22) {
|
|
return 200;
|
|
}
|
|
if (groupId == 23) {//孤竹城
|
|
return 1;
|
|
}
|
|
// SKLogger.warn(`未知的活动组ID[${groupId}]`);
|
|
return 0;
|
|
|
|
}
|
|
|
|
StringVecorToDataVector(vecString: any): any {
|
|
let vecData = [];
|
|
|
|
for (let it in vecString) {
|
|
let strData = vecString[it];
|
|
|
|
let vecTmp = strData.split(":");
|
|
if (vecTmp.length != 2)
|
|
continue;
|
|
|
|
vecData.push({ nKey: vecTmp[0], nValue: vecTmp[1] });
|
|
}
|
|
|
|
return vecData;
|
|
}
|
|
|
|
AddTask(nKind: any, stTask: any) {
|
|
if (this.mapConfigTask.hasOwnProperty(nKind) == false)
|
|
this.mapConfigTask[nKind] = [];
|
|
|
|
this.mapConfigTask[nKind].push(stTask);
|
|
}
|
|
|
|
launch() {
|
|
let mapData = GameUtil.require_ex('../../conf/prop_data/prop_task');
|
|
for (let itTask in mapData) {
|
|
if (itTask == 'datatype')
|
|
continue;
|
|
const stData = mapData[itTask];
|
|
let task:Task = new Task();
|
|
task.nTaskID = parseInt(itTask);
|
|
task.nKind = stData.nKind;
|
|
task.strTaskName = stData.strName;
|
|
task.nTaskGrop = GameUtil.getDefault(stData.nTaskGrop, 0);
|
|
task.nDailyCnt = GameUtil.getDefault(stData.nDailyCnt, 0);
|
|
for (let nIndex in stData.vecEvent) {
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_TALK_NPC) //对话
|
|
{
|
|
let stTalk = new EventTalkNpc();
|
|
stTalk.nEventType = EEventType.PLAYER_TALK_NPC;
|
|
stTalk.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stTalk.strTip = stData.vecEvent[nIndex].strTip;
|
|
stTalk.vecCreateNpc = this.GetTaskEventCreateNpc(stData.vecEvent[nIndex].vecCreateNpc);
|
|
stTalk.vecNpc = stData.vecEvent[nIndex].vecNpc.slice(0);
|
|
stTalk.vecSpeak = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecSpeak);
|
|
stTalk.bAutoTrigle = GameUtil.getDefault(stData.vecEvent[nIndex].bAutoTrigle, 0);
|
|
task.vecEvent.push(stTalk);
|
|
}
|
|
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_GATHER_NPC) {
|
|
let stGather = new GatherNpc();
|
|
stGather.nEventType = EEventType.PLAYER_GATHER_NPC;
|
|
stGather.strTip = stData.vecEvent[nIndex].strTip;
|
|
stGather.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stGather.vecCreateNpc = this.GetTaskEventCreateNpc(stData.vecEvent[nIndex].vecCreateNpc);
|
|
stGather.vecNpc = stData.vecEvent[nIndex].vecNpc.slice(0);
|
|
task.vecEvent.push(stGather);
|
|
}
|
|
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_DO_ACITION) {
|
|
let stAction = new DoActionInArea();
|
|
stAction.nEventType = EEventType.PLAYER_DO_ACITION;
|
|
stAction.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stAction.strTip = stData.vecEvent[nIndex].strTip;
|
|
stAction.nMap = stData.vecEvent[nIndex].nMap;
|
|
stAction.nX = stData.vecEvent[nIndex].nX;
|
|
stAction.nY = stData.vecEvent[nIndex].nY;
|
|
stAction.strAction = stData.vecEvent[nIndex].strAction;
|
|
stAction.strTalk = stData.vecEvent[nIndex].strTalk;
|
|
task.vecEvent.push(stAction);
|
|
}
|
|
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_ARRIVE_AREA) {
|
|
let stAction = new ArriveArea();
|
|
stAction.nEventType = EEventType.PLAYER_ARRIVE_AREA;
|
|
stAction.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stAction.strTip = stData.vecEvent[nIndex].strTip;
|
|
stAction.nMap = stData.vecEvent[nIndex].nMap;
|
|
stAction.nX = stData.vecEvent[nIndex].nX;
|
|
stAction.nY = stData.vecEvent[nIndex].nY;
|
|
task.vecEvent.push(stAction);
|
|
}
|
|
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_GIVE_NPC_ITEM) {
|
|
let stAction = new GiveNpcItem();
|
|
stAction.nEventType = EEventType.PLAYER_GIVE_NPC_ITEM;
|
|
stAction.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stAction.strTip = stData.vecEvent[nIndex].strTip;
|
|
stAction.nItemID = stData.vecEvent[nIndex].nItemID;
|
|
stAction.nNum = stData.vecEvent[nIndex].nNum;
|
|
stAction.nFromNpc = stData.vecEvent[nIndex].nFromNpc;
|
|
stAction.nNpcConfigID = stData.vecEvent[nIndex].nToNpc;
|
|
stAction.strTip2 = stData.vecEvent[nIndex].strTip2;
|
|
task.vecEvent.push(stAction);
|
|
}
|
|
|
|
if (stData.vecEvent[nIndex].nEventType == EEventType.PLAYER_KILL_NPC) {
|
|
let stEvent = new KillDynamicNpc();
|
|
stEvent.nEventType = EEventType.PLAYER_KILL_NPC;
|
|
stEvent.vecPrize = this.StringVecorToDataVector(stData.vecEvent[nIndex].vecPrize);
|
|
stEvent.strTip = stData.vecEvent[nIndex].strTip;
|
|
stEvent.vecCreateNpc = this.GetTaskEventCreateNpc(stData.vecEvent[nIndex].vecCreateNpc);
|
|
stEvent.vecNpc = stData.vecEvent[nIndex].vecNpc.slice(0);
|
|
stEvent.bAutoTrigle = stData.vecEvent[nIndex].bAutoTrigle;
|
|
task.vecEvent.push(stEvent);
|
|
}
|
|
}
|
|
|
|
for (let nIndex in stData.vecFailEvent) {
|
|
if (stData.vecFailEvent[nIndex].nEventType == EEventType.PLAYER_DEAD) {
|
|
let stEvent = new FailEventPlayerDead();
|
|
task.vecFailEvent.push(stEvent);
|
|
}
|
|
|
|
if (stData.vecFailEvent[nIndex].nEventType == EEventType.TIMEOUT) {
|
|
let stEvent = new FailEventTimeOut();
|
|
task.vecFailEvent.push(stEvent);
|
|
}
|
|
}
|
|
task.vecLimit = this.StringVecorToDataVector(stData.vecLimit);
|
|
this.AddTask(task.nKind, task);
|
|
}
|
|
}
|
|
// 获得任务配置
|
|
getTaskConf(taskId: number): Task {
|
|
for (let key in this.mapConfigTask) {
|
|
let kind: number = SKDataUtil.numberBy(key);
|
|
let taskList: Task[] = this.mapConfigTask[kind];
|
|
for (let task of taskList) {
|
|
if (task.nTaskID == taskId) {
|
|
return task;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
getTaskStepInfo(nTaskID: any, nStep: any): any {
|
|
let stTaskConfig = this.getTaskConf(nTaskID);
|
|
if (null == stTaskConfig)
|
|
return null;
|
|
|
|
if (nStep < 0 || nStep >= stTaskConfig.vecEvent.length)
|
|
return null;
|
|
|
|
return stTaskConfig.vecEvent[nStep];
|
|
}
|
|
|
|
GetFailEventInfo(nTaskID: any, nStep: any) {
|
|
let stTaskConfig = this.getTaskConf(nTaskID);
|
|
if (null == stTaskConfig)
|
|
return null;
|
|
|
|
if (nStep < 0 || nStep >= stTaskConfig.vecFailEvent.length)
|
|
return null;
|
|
|
|
return stTaskConfig.vecFailEvent[nStep];
|
|
}
|
|
// 是否为组队任务
|
|
isTeamTask(taskId: any): boolean {
|
|
if (taskId >= 500 && taskId < 2101 && taskId != 2019) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
IsTeamDaily(group: any): boolean {
|
|
if (GameUtil.isDataInVecter(group, [5, 6, 7, 8, 12, 2015, 2016]))
|
|
return true;
|
|
return false;
|
|
}
|
|
} |