/** 写回 */ public void write() { Ctrl.print("保存场景", config.id); if (_stream == null) { _stream = new BytesWriteStream(); } else { _stream.clear(); } _stream.writeLen(elements.size()); foreach (int k in elements.getSortedKeyList()) { ScenePlaceElementConfig scenePlaceElementConfig = elements.get(k).config; scenePlaceElementConfig.writeBytesSimple(_stream); } string path = SceneEditorWindow.getScenePlaceFilePath(config.id); FileUtils.writeFileForBytesWriteStream(path, _stream); }
protected virtual void doAttackMoment(int moment, Unit from, Unit attacker, Unit target, AttackData lastData, DamageOneData damageOneData) { int[][] intArr; if ((intArr = lastData.levelConfig.momentActionsT[moment]) != null) { foreach (int[] args in intArr) { if (args[0] == moment) { if (attacker.fight.randomProb(args[1])) { doOneAttackAction(args, 2, from, attacker, target, lastData); } } } } IntObjectMap <int[]> momentDic = attacker.fight.getBuffLogic().getAttackProbActionDic(moment); if (momentDic != null && momentDic.size() > 0) { int[][] momentValues = momentDic.getValues(); int[] momentV; for (int j = momentValues.Length - 1; j >= 0; --j) { if ((momentV = momentValues[j]) != null) { if (momentV[2] <= 0 || lastData.config.hasGroup(momentV[2])) { if (attacker.fight.randomProb(momentV[3])) { doOneAttackAction(momentV, 4, from, attacker, target, lastData); } } } } } }
/** 执行移除一个物品(倒序)(核心) */ protected override bool doRemoveItemC(int id, int num) { int totalNum = _itemNums.get(id); if (totalNum < num) { return(false); } IntObjectMap <ItemData> iDic = _dicByID.get(id); if (iDic == null) { Ctrl.errorLog("此处不该为空"); return(false); } //只有一个 if (iDic.size() == 1) { ItemData data = iDic.getEver(); if ((num = doRemoveItemOneC(data, num)) == 0) { return(true); } } else { _tempRemoveItemList.clear(); ItemData[] values; ItemData v; for (int i = (values = iDic.getValues()).Length - 1; i >= 0; --i) { if ((v = values[i]) != null) { _tempRemoveItemList.add(v); } } //排序 _tempRemoveItemList.sort(compareItemForRemove); ItemData[] values1 = _tempRemoveItemList.getValues(); ItemData v1; for (int i1 = 0, len1 = _tempRemoveItemList.size(); i1 < len1; ++i1) { v1 = values1[i1]; num = doRemoveItemOneC(v1, num); if (num == 0) { _tempRemoveItemList.clear(); return(true); } } _tempRemoveItemList.clear(); } Ctrl.errorLog("物品不该没移除完"); return(false); }
public override int getGridUseNum() { return(_dic.size()); }
/** 写合并项 */ private void writeMapCombine() { if (_sceneList == null) { return; } Ctrl.print("writeCombine"); BytesWriteStream stream = new BytesWriteStream(); IntObjectMap <SceneMapConfig> dic = SceneMapConfig.getDic(); stream.writeLen(dic.size()); foreach (int k in dic.getSortedKeyList()) { SceneMapConfig config = dic.get(k); stream.writeInt(config.id); if (CommonSetting.serverMapNeedGrid || CommonSetting.clientMapNeedGrid) { string path = getMapGridFilePath(config.id); byte[] bytes = FileUtils.readFileForBytes(path); if (bytes != null) { stream.writeLen(bytes.Length); stream.writeByteArr(bytes); } else { stream.writeLen(0); } if (CommonSetting.clientMapNeedGrid) { BytesWriteStream clientStream = new BytesWriteStream(); BaseC.config.writeConfigVersion(clientStream); clientStream.writeInt(config.id); if (bytes != null) { clientStream.writeLen(bytes.Length); clientStream.writeByteArr(bytes); } else { clientStream.writeLen(0); } byte[] buf = clientStream.getBuf(); int len = clientStream.length(); if (CommonSetting.configNeedCompress) { clientStream.compress(); } BytesReadStream rs = new BytesReadStream(clientStream.getBuf(), 0, clientStream.length()); rs.unCompress(); byte[] rBuf = rs.getBuf(); int rLen = rs.length(); if (len == rLen) { bool isSame = true; for (int i = 0; i < len; i++) { if (buf[i] != rBuf[i]) { isSame = false; break; } } } FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.sourceCommonConfigDirPath + "/mapInfo/" + config.id + ".bin", clientStream); } } if (CommonSetting.serverMapNeedRecast) { string path = getMapNavFilePath(config.id); byte[] bytes = FileUtils.readFileForBytes(path); if (bytes != null) { stream.writeLen(bytes.Length); stream.writeByteArr(bytes); } else { stream.writeLen(0); } } } //写出服务器端配置 FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.serverSavePath + "/config/mapInfo.bin", stream); //调用configExport ToolFileUtils.executeServerTool("configExport"); }
private BuffData addOneBuff(int id, int level, int adderInstanceID, BuffData eData) { BuffConfig config = BuffConfig.get(id); //先看忽略 foreach (int v in config.groups) { if (_ignoreBuffGroupDic.get(v) > 0) { return(null); } } BuffData re; BuffData oldData; BuffData data; switch (config.plusType) { case BuffPlusType.Normal: { if ((oldData = _buffDatasByID.get(id)) != null) { //新的等级更高 if (level > oldData.level) { toRemoveBuff(oldData); toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } else { toRefreshBuff(re = oldData); } } else { toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } } break; case BuffPlusType.Replace: { if ((oldData = _buffDatasByID.get(id)) != null) { toRemoveBuff(oldData); } toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } break; case BuffPlusType.AllExist: { IntObjectMap <BuffData> dic = _buffDatasForAllExist.get(id); if (dic == null) { toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } else { if (config.plusMax > 0 && dic.size() >= config.plusMax) { BuffData temp = null; BuffData[] values = dic.getValues(); for (int i = values.Length - 1; i >= 0; --i) { if ((data = values[i]) != null) { if (temp == null) { temp = data; } else if (data.instanceID < temp.instanceID) //更小 { temp = data; } } } //删了最早的 if (temp != null) { toRemoveBuff(temp); } } toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } } break; case BuffPlusType.AddFloor: { if ((oldData = _buffDatasByID.get(id)) != null) { //新的等级更高 if (level > oldData.level) { toRemoveBuff(oldData); re = toCreateBuff(id, level, adderInstanceID, eData); //继承层数 re.lastNum = oldData.lastNum; toAddBuff(re); } else { //没满级 if (oldData.lastNum < config.plusMax) { //加 oldData.lastNum++; refreshOneBuffAttributeVar(oldData); //刷新buff时间 toRefreshBuff(re = oldData); //到达上限 if (oldData.lastNum == config.plusMax) { doPlusMaxActions(oldData); } } else { re = oldData; if (oldData.levelConfig.lastTime > 0) { //刷新buff时间 toRefreshBuff(oldData); } } } } else { toAddBuff(re = toCreateBuff(id, level, adderInstanceID, eData)); } } break; default: { re = null; Ctrl.throwError("不支持的buff plusType", config.plusType); } break; } return(re); }
/// <summary> /// 转文本输出 /// </summary> protected override void toWriteDataString(DataWriter writer) { writer.writeTabs(); writer.sb.Append("funcTools"); writer.sb.Append(':'); writer.sb.Append("Map<int,IntObjectMap<FuncToolData>>"); if (this.funcTools != null) { writer.sb.Append('('); writer.sb.Append(this.funcTools.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; writer.writeTabs(); writer.sb.Append(funcToolsK); writer.sb.Append(':'); writer.sb.Append("Map<int,FuncToolData>"); if (funcToolsV != null) { writer.sb.Append('('); writer.sb.Append(funcToolsV.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; writer.writeTabs(); writer.sb.Append(funcToolsVK); writer.sb.Append(':'); if (funcToolsVV != null) { funcToolsVV.writeDataString(writer); } else { writer.sb.Append("FuncToolData=null"); } writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); writer.writeTabs(); writer.sb.Append("funcOpenSet"); writer.sb.Append(':'); writer.sb.Append("Set<int>"); if (this.funcOpenSet != null) { writer.sb.Append('('); writer.sb.Append(this.funcOpenSet.size()); writer.sb.Append(')'); writer.writeEnter(); writer.writeLeftBrace(); if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { writer.writeTabs(); writer.sb.Append(funcOpenSetV); writer.writeEnter(); } } } writer.writeRightBrace(); } else { writer.sb.Append("=null"); } writer.writeEnter(); }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { FuncPartData mData = (FuncPartData)data; if (mData.funcTools != null) { if (this.funcTools == null) { return(false); } if (this.funcTools.size() != mData.funcTools.size()) { return(false); } IntObjectMap <IntObjectMap <FuncToolData> > funcToolsR = mData.funcTools; if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; IntObjectMap <FuncToolData> funcToolsU = funcToolsR.get(funcToolsK); if (funcToolsU != null) { if (funcToolsV == null) { return(false); } if (funcToolsV.size() != funcToolsU.size()) { return(false); } IntObjectMap <FuncToolData> funcToolsVR = funcToolsU; if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; FuncToolData funcToolsVU = funcToolsVR.get(funcToolsVK); if (funcToolsVU != null) { if (funcToolsVV == null) { return(false); } if (!funcToolsVV.dataEquals(funcToolsVU)) { return(false); } } else { if (funcToolsVV != null) { return(false); } } } } } } else { if (funcToolsV != null) { return(false); } } } } } } else { if (this.funcTools != null) { return(false); } } if (mData.funcOpenSet != null) { if (this.funcOpenSet == null) { return(false); } if (this.funcOpenSet.size() != mData.funcOpenSet.size()) { return(false); } IntSet funcOpenSetR = mData.funcOpenSet; if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { if (!funcOpenSetR.contains(funcOpenSetV)) { return(false); } } } } } else { if (this.funcOpenSet != null) { return(false); } } return(true); }
/// <summary> /// 写入字节流(完整版) /// </summary> protected override void toWriteBytesFull(BytesWriteStream stream) { stream.startWriteObj(); if (this.funcTools != null) { stream.writeBoolean(true); stream.writeLen(this.funcTools.size()); if (!this.funcTools.isEmpty()) { int funcToolsKFreeValue = this.funcTools.getFreeValue(); int[] funcToolsKKeys = this.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = this.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; stream.writeInt(funcToolsK); if (funcToolsV != null) { stream.writeBoolean(true); stream.writeLen(funcToolsV.size()); if (!funcToolsV.isEmpty()) { int funcToolsVKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsVKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsVVValues = funcToolsV.getValues(); for (int funcToolsVKI = funcToolsVKKeys.Length - 1; funcToolsVKI >= 0; --funcToolsVKI) { int funcToolsVK = funcToolsVKKeys[funcToolsVKI]; if (funcToolsVK != funcToolsVKFreeValue) { FuncToolData funcToolsVV = funcToolsVVValues[funcToolsVKI]; stream.writeInt(funcToolsVK); if (funcToolsVV != null) { stream.writeBoolean(true); stream.writeDataFullNotNull(funcToolsVV); } else { stream.writeBoolean(false); } } } } } else { stream.writeBoolean(false); } } } } } else { stream.writeBoolean(false); } if (this.funcOpenSet != null) { stream.writeLen(this.funcOpenSet.size()); if (!this.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = this.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = this.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { stream.writeInt(funcOpenSetV); } } } } else { nullObjError("funcOpenSet"); } stream.endWriteObj(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is FuncPartData)) { return; } FuncPartData mData = (FuncPartData)data; if (mData.funcTools != null) { if (this.funcTools != null) { this.funcTools.clear(); this.funcTools.ensureCapacity(mData.funcTools.size()); } else { this.funcTools = new IntObjectMap <IntObjectMap <FuncToolData> >(mData.funcTools.size()); } IntObjectMap <IntObjectMap <FuncToolData> > funcToolsT = this.funcTools; if (!mData.funcTools.isEmpty()) { int funcToolsKFreeValue = mData.funcTools.getFreeValue(); int[] funcToolsKKeys = mData.funcTools.getKeys(); IntObjectMap <FuncToolData>[] funcToolsVValues = mData.funcTools.getValues(); for (int funcToolsKI = funcToolsKKeys.Length - 1; funcToolsKI >= 0; --funcToolsKI) { int funcToolsK = funcToolsKKeys[funcToolsKI]; if (funcToolsK != funcToolsKFreeValue) { IntObjectMap <FuncToolData> funcToolsV = funcToolsVValues[funcToolsKI]; int funcToolsW; IntObjectMap <FuncToolData> funcToolsU; funcToolsW = funcToolsK; if (funcToolsV != null) { funcToolsU = new IntObjectMap <FuncToolData>(funcToolsV.size()); IntObjectMap <FuncToolData> funcToolsUT = funcToolsU; if (!funcToolsV.isEmpty()) { int funcToolsUKFreeValue = funcToolsV.getFreeValue(); int[] funcToolsUKKeys = funcToolsV.getKeys(); FuncToolData[] funcToolsUVValues = funcToolsV.getValues(); for (int funcToolsUKI = funcToolsUKKeys.Length - 1; funcToolsUKI >= 0; --funcToolsUKI) { int funcToolsUK = funcToolsUKKeys[funcToolsUKI]; if (funcToolsUK != funcToolsUKFreeValue) { FuncToolData funcToolsUV = funcToolsUVValues[funcToolsUKI]; int funcToolsUW; FuncToolData funcToolsUU; funcToolsUW = funcToolsUK; if (funcToolsUV != null) { funcToolsUU = (FuncToolData)funcToolsUV.clone(); } else { funcToolsUU = null; } funcToolsUT.put(funcToolsUW, funcToolsUU); } } } } else { funcToolsU = null; } funcToolsT.put(funcToolsW, funcToolsU); } } } } else { this.funcTools = null; } if (mData.funcOpenSet != null) { if (this.funcOpenSet != null) { this.funcOpenSet.clear(); this.funcOpenSet.ensureCapacity(mData.funcOpenSet.size()); } else { this.funcOpenSet = new IntSet(); } IntSet funcOpenSetT = this.funcOpenSet; if (!mData.funcOpenSet.isEmpty()) { int funcOpenSetVFreeValue = mData.funcOpenSet.getFreeValue(); int[] funcOpenSetVKeys = mData.funcOpenSet.getKeys(); for (int funcOpenSetVI = funcOpenSetVKeys.Length - 1; funcOpenSetVI >= 0; --funcOpenSetVI) { int funcOpenSetV = funcOpenSetVKeys[funcOpenSetVI]; if (funcOpenSetV != funcOpenSetVFreeValue) { int funcOpenSetU; funcOpenSetU = funcOpenSetV; funcOpenSetT.add(funcOpenSetU); } } } } else { this.funcOpenSet = null; nullObjError("funcOpenSet"); } }