/** 检查重新添加到等待接取组 */ private void checkReAddWaitAccept(QuestConfig config) { //可接 if (checkQuestCanAcceptFirst(config)) { _waitAcceptQuests.put(config.id, config); if (checkSeeConditions(config)) { _canSeeQuests.put(config.id, config); me.dispatch(GameEventType.RefreshCanSeeQuests); } if (checkAcceptConditions(config, false)) { _canAcceptQuests.put(config.id, config); me.dispatch(GameEventType.RefreshCanAcceptQuests); // 自动接 if (config.acceptType == QuestAcceptType.Auto) { acceptQuest(config.id); } } } }
/** 完成任务以及前置(gm) */ private void toCompleteQuestByGm(int id) { if (isQuestComplete(id)) { return; } QuestConfig config = QuestConfig.get(id); //前置任务 foreach (int v in config.preQuests) { toCompleteQuestByGm(v); } //完成当前 QuestData qData = _d.accepts.get(id); if (qData == null) { doAcceptQuest(config); qData = _d.accepts.get(id); //已自动完成 if (qData == null) { return; } } toCommitQuest(qData, true); }
public void makeConfig() { if (config == null) { config = QuestConfig.get(id); } }
/// <summary> /// 接取任务(执行数据) /// </summary> public void acceptQuest(int id) { if (_d.accepts.contains(id)) { me.warnLog("接任务时,任务已接", id); return; } if (isQuestComplete(id)) { me.warnLog("接任务时,任务已完成", id); return; } QuestConfig config = QuestConfig.get(id); //任务失败了 QuestCompleteData cData; if ((cData = _d.completeQuestsDic.get(id)) != null && !cData.isSuccess) { //不可接取失败 if (!config.cantAcceptFailed) { me.warnLog("接任务时,不可接取已失败的任务", id); return; } } foreach (int v in config.preQuests) { if (!isQuestComplete(v)) { me.warnLog("接任务时,前置任务未完成", id, v); return; } } if (!checkAcceptConditions(config, true)) { me.warnLog("接任务时,条件不满足", id); return; } //接任务给任务道具 DIntData[] questItem = config.questItem; if (questItem.Length > 0) { //检测是否有足够的格子放置任务道具 if (!me.bag.hasItemPlace(questItem)) { me.warnLog("背包没有足够的位置放任务道具", id); return; } } preDoAcceptQuest(config); }
/** 检查某任务的前置是否都完成 */ private bool checkQuestPreAllComplete(QuestConfig config) { foreach (int v in config.preQuests) { if (!isQuestComplete(v)) { return(false); } } return(true); }
/// <summary> /// 检查可视任务条件(只看条件部分) /// </summary> public bool checkSeeConditions(QuestConfig config) { foreach (int[] v2 in config.acceptConditions) { if (!checkOneSeeCondition(v2)) { return(false); } } return(true); }
/// <summary> /// 检查任务是否可接 /// </summary> public bool checkQuestCanAccept(QuestConfig config, bool needNotice) { if (!checkQuestCanAcceptFirst(config)) { return(false); } if (!checkAcceptConditions(config, needNotice)) { return(false); } return(true); }
/** 提交任务 */ private void doCommitQuest(QuestData data) { QuestConfig config = data.config; removeAcceptQuest(data); addCompleteRecord(data.config, true); //回收 releaseQuest(data); checkReAddWaitAccept(config); me.dispatch(GameEventType.CommitQuest, config.id); }
/** 添加完成记录 */ private void addCompleteRecord(QuestConfig config, bool isSuccess) { switch (config.repeatType) { case QuestRepeatType.Once: { //胜利记录 if (isSuccess) { DIntData questLine; if (!(questLine = config.questLine).isEmpty()) { //更高 if (questLine.value > _d.completeLines.getOrDefault(questLine.key, -1)) { _d.completeLines.put(questLine.key, questLine.value); } } else { _d.completeIDs.add(config.id); } checkWaitAcceptQuestByComplete(config); } } break; case QuestRepeatType.Cycle: { QuestCompleteData cData = _d.completeQuestsDic.get(config.id); if (cData == null) { cData = new QuestCompleteData(); cData.id = config.id; _d.completeQuestsDic.put(config.id, cData); } //下个时间 cData.reTime = config.cycleTimeT.getNextTime(); cData.isSuccess = isSuccess; } break; } }
private void doGiveUpQuest(QuestData data) { QuestConfig config = data.config; //没失败 if (!data.isFailed) { data.isFailed = true; addCompleteRecord(config, false); } removeAcceptQuest(data); releaseQuest(data); checkReAddWaitAccept(config); me.dispatch(GameEventType.GiveUpQuest, config.id); }
/** 检查等待接取组受到完成任务的影响 */ private void checkWaitAcceptQuestByComplete(QuestConfig config) { bool hasSee = false; bool hasAccept = false; int[] values = config.afterQuests.getValues(); QuestConfig qConfig; for (int i = 0, len = config.afterQuests.size(); i < len; ++i) { //可接 if (checkQuestCanAcceptFirst(qConfig = QuestConfig.get(values[i]))) { _waitAcceptQuests.put(qConfig.id, qConfig); if (checkSeeConditions(qConfig)) { _canSeeQuests.put(qConfig.id, qConfig); hasSee = true; } if (checkAcceptConditions(qConfig, false)) { _canAcceptQuests.put(qConfig.id, qConfig); hasAccept = true; } } } if (hasSee) { me.dispatch(GameEventType.RefreshCanSeeQuests); } if (hasAccept) { me.dispatch(GameEventType.RefreshCanAcceptQuests); } checkAutoAccept(); }
private void selectPanel_DrawCell(Graphics g, int info, int xOff, int yOff) { QuestConfig questConfig = ConfigData.GetQuestConfig(info); // g.DrawImage(SceneQuestBook.GetEquipImage(info), 5 + xOff, 5 + yOff, 40, 40); Font font = new Font("微软雅黑", 11.25F * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); int offX = 40 + xOff; if (selectPanel.SelectIndex >= 0 && questIds[selectPanel.SelectIndex] == info) offX += 15; if (UserProfile.InfoQuest.IsQuestFinish(questConfig.Id)) { g.DrawString(questConfig.Name, font, Brushes.White, offX, 5 + yOff); } else { g.DrawString("???", font, Brushes.DarkGray, offX, 5 + yOff); } font.Dispose(); }
public static void Test() { const string jsonPath = "..\\..\\..\\..\\quan.java\\config\\json"; const string namespacePrefix = "Test.Config"; var assemblyName = Assembly.GetExecutingAssembly().FullName; var configLoader = new ConfigLoader { JsonPath = jsonPath, NamespacePrefix = namespacePrefix, ConfigAssemblies = { assemblyName } }; configLoader.Load(); foreach (var config in ItemConfig.GetIdConfigs().Values) { Console.WriteLine(config); } EquipConfig.GetByPosition(1); QuestConfig.GetById(1); }
/// <summary> /// 接任务(gm指令)(并完成所有前置) /// </summary> public void acceptQuestByGM(int id, bool needPre) { if (_d.accepts.contains(id)) { me.warnLog("gm接任务时,任务已接", id); return; } if (isQuestComplete(id)) { me.warnLog("gm接任务时,任务已完成", id); return; } if (needPre) { toCompleteQuestByGm(id); } doAcceptQuest(QuestConfig.get(id)); }
/** 执行接取任务 */ private void doAcceptQuest(QuestConfig config) { if (CommonSetting.isClientDriveLogic) { QuestData qData = GameC.factory.createQuestData(); qData.id = config.id; qData.makeConfig(); int[] list = config.tasks; TaskData[] tasks = qData.tasks = new TaskData[list.Length]; for (int i = 0; i < list.Length; i++) { tasks[i] = createTaskByID(list[i], FunctionType.Quest, config.id); } if (config.failTimeT != null) { qData.enableTime = config.failTimeT.getNextTime(); } else { qData.enableTime = 0L; } //成功接取任务后 把任务道具给玩家 DIntData[] questItem = config.questItem; if (questItem.Length > 0) { me.bag.addItems(questItem, 1, CallWayType.AcceptQuest); } doAcceptQuest(qData); } else { me.send(AcceptQuestRequest.create(config.id)); } }
/** 执行完成任务 */ private void toCommitQuest(QuestData data, bool isAbs) { if (CommonSetting.isClientDriveLogic) { QuestConfig config = data.config; //删除任务道具 DIntData[] questItemArr = config.questItem; if (questItemArr.Length > 0) { //如果需要删除任务道具 me.bag.removeItems(questItemArr, 1, CallWayType.CommitQuest); } //执行任务完成动作组 me.role.doRoleActions(config.completeActions, 1, CallWayType.CommitQuest); //有奖励 if (data.config.rewardID > 0) { //奖励 if (isAbs) { me.bag.addRewardAbs(data.config.rewardID, CallWayType.CommitQuest); } else { me.bag.addReward(data.config.rewardID, CallWayType.CommitQuest); } } doCommitQuest(data); } else { me.send(CommitQuestRequest.create(data.id)); } }
public override void onNewCreate() { _d.clientTaskInstanceIDIndex = ShineSetting.indexMaxHalf; //接取首次任务 IntList list = QuestConfig.initQuests; if (!list.isEmpty()) { int[] values = list.getValues(); QuestConfig config; for (int i = 0, len = list.size(); i < len; ++i) { config = QuestConfig.get(values[i]); if (me.role.checkRoleConditions(config.acceptConditions, false)) { doAcceptQuest(config); } } } }
/// <summary> /// 移除配置记录 /// </summary> public void removeCompleteRecord(QuestConfig config) { switch (config.repeatType) { case QuestRepeatType.Once: { if (!config.questLine.isEmpty()) { Ctrl.throwError("不可删除链式任务结构数据"); } else { _d.completeIDs.remove(config.id); } } break; case QuestRepeatType.Cycle: { _d.completeQuestsDic.remove(config.id); } break; } }
/** 获取某任务是否完成 */ private bool isQuestComplete(QuestConfig config) { if (_d.completeIDs.contains(config.id)) { return(true); } DIntData line; //有值 if (!(line = config.questLine).isEmpty()) { return(line.value <= _d.completeLines.getOrDefault(line.key, -1)); } QuestCompleteData cData; if ((cData = _d.completeQuestsDic.get(config.id)) != null) { return(cData.isSuccess); } return(false); }
/** 检查任务可接基础条件 */ private bool checkQuestCanAcceptFirst(QuestConfig config) { //已接 if (_d.accepts.contains(config.id)) { return(false); } //完成 if (_d.completeIDs.contains(config.id)) { return(false); } //周期完成 if (_d.completeQuestsDic.contains(config.id)) { return(false); } DIntData line; //链完成 if (!(line = config.questLine).isEmpty() && line.value <= _d.completeLines.getOrDefault(line.key, -1)) { return(false); } //前置未完成 if (!checkQuestPreAllComplete(config)) { return(false); } return(true); }
private static int sortQuestLine(QuestConfig config0, QuestConfig config1) { return(MathUtils.intCompare(config0.questLine.value, config1.questLine.value)); }
public void InitQuest(QuestConfig config) { Type = config.Type; _type.text = config.Title; }
/// <summary> /// 预接任务 /// </summary> protected void preDoAcceptQuest(QuestConfig config) { //TODO:找NPC doAcceptQuest(config); }
/** 统计所有可接任务列表 */ private void countWaitAcceptQuests() { IntObjectMap <QuestConfig> dic = QuestConfig.getDic(); if (dic == null) { return; } IntObjectMap <QuestConfig> waitAcceptQuests = _waitAcceptQuests; waitAcceptQuests.clear(); IntObjectMap <QuestData> accepts = _d.accepts; IntSet completeIDs = _d.completeIDs; IntObjectMap <QuestCompleteData> completeQuestsDic = _d.completeQuestsDic; IntIntMap completeLines = _d.completeLines; QuestConfig[] values; QuestConfig v; int questID; DIntData line; for (int i = (values = dic.getValues()).Length - 1; i >= 0; --i) { if ((v = values[i]) != null) { //可主动接 if (v.acceptType != QuestAcceptType.Passive) { questID = v.id; //已接 if (accepts.contains(questID)) { continue; } //完成 if (completeIDs.contains(questID)) { continue; } //周期完成 if (completeQuestsDic.contains(questID)) { continue; } //链完成 if (!(line = v.questLine).isEmpty() && line.value <= completeLines.getOrDefault(line.key, -1)) { continue; } //前置未完成 if (!checkQuestPreAllComplete(v)) { continue; } waitAcceptQuests.put(v.id, v); } } } }
/// <summary> /// 检查单个角色条件 /// </summary> public virtual bool checkOneRoleCondition(int[] args, bool needNotice) { switch (args[0]) { case RoleConditionType.Level: { if (me.role.getLevel() < args[1]) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_needLevel); } return(false); } } break; case RoleConditionType.FunctionOpen: { if (!me.func.isFunctionOpen(args[1])) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_functionNotOpen, FunctionConfig.get(args[1]).showName); } return(false); } } break; case RoleConditionType.NeedUnion: { if (!me.union.hasUnion()) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_needUnion); } return(false); } } break; case RoleConditionType.QuestComplete: { if (!me.quest.isQuestComplete(args[1])) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_needCompleteQuest, QuestConfig.get(args[1]).name); } return(false); } } break; case RoleConditionType.OnStatus: { if (!me.character.getCurrentCharacterUseLogic().getFightLogic().status.getStatus(args[1])) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_needOnStatus, StatusConfig.getShowName(args[1])); } return(false); } } break; case RoleConditionType.OffStatus: { if (me.character.getCurrentCharacterUseLogic().getFightLogic().status.getStatus(args[1])) { if (needNotice) { me.showInfoCode(InfoCodeType.Condition_needOffStatus, StatusConfig.getShowName(args[1])); } return(false); } } break; } return(true); }
public override void clear() { config = null; enableTime = 0L; }
/// <summary> /// 获取某任务是否完成 /// </summary> public bool isQuestComplete(int id) { return(isQuestComplete(QuestConfig.get(id))); }
/// <summary> /// 检查接受任务条件(只看条件部分) /// </summary> public bool checkAcceptConditions(QuestConfig config, bool needNotice) { return(me.role.checkRoleConditions(config.acceptConditions, needNotice)); }