/** 检查重新添加到等待接取组 */ 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); } } } }
/// <summary> /// 获取聊天频道数据 /// </summary> public ChatChannelData getChatChannelData(int channel, long key) { ChatChannelConfig config = ChatChannelConfig.get(channel); ChatChannelData re; if (config.isMulti) { LongObjectMap <ChatChannelData> dic = _multiChannels.get(channel); if (dic == null) { _multiChannels.put(channel, dic = new LongObjectMap <ChatChannelData>()); } if ((re = dic.get(key)) == null) { dic.put(key, re = new ChatChannelData()); re.initDefault(); } } else { if ((re = _singleChannels.get(channel)) == null) { _singleChannels.put(channel, re = new ChatChannelData()); re.initDefault(); } } return(re); }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { base.toReadBytesSimple(stream); int itemRecordsLen = stream.readLen(); if (this.itemRecords != null) { this.itemRecords.clear(); this.itemRecords.ensureCapacity(itemRecordsLen); } else { this.itemRecords = new IntObjectMap <AuctionItemRecordData>(itemRecordsLen); } IntObjectMap <AuctionItemRecordData> itemRecordsT = this.itemRecords; for (int itemRecordsI = itemRecordsLen - 1; itemRecordsI >= 0; --itemRecordsI) { AuctionItemRecordData itemRecordsV; itemRecordsV = (AuctionItemRecordData)stream.readDataSimpleNotNull(); itemRecordsT.put(itemRecordsV.id, itemRecordsV); } }
private void toAddBuffToDic(BuffData data) { _buffDatas.put(data.instanceID, data); if (data.config.plusType == BuffPlusType.AllExist) { _buffDatasForAllExist.computeIfAbsent(data.id, k => new IntObjectMap <BuffData>()).put(data.instanceID, data); } else { _buffDatasByID.put(data.id, data); } int[][] subNums; if ((subNums = data.config.subNums).Length > 0) { foreach (int[] v in subNums) { IntObjectMap <BuffData> dic = _buffDatasBySubNums[v[0]]; if (dic == null) { _buffDatasBySubNums[v[0]] = dic = new IntObjectMap <BuffData>(); } dic.put(data.instanceID, data); } } }
/** 场景进入场景 */ private void enterScene(SceneConfig config) { if (_currentSceneData != null) { exitScene(); } SceneEditorData sData = _sceneDic.get(config.id); if (sData == null) { sData = new SceneEditorData(); sData.config = config; sData.read(); _sceneDic.put(config.id, sData); } _currentSceneData = sData; _elementInstanceID = -1; SceneMapConfig mapConfig = SceneMapConfig.get(config.mapID); _originPos.setByIArr(mapConfig.origin); _sizePos.setByIArr(mapConfig.size); EditorSceneManager.sceneLoaded += onSceneLoaded; EditorSceneManager.LoadScene(ShineToolGlobal.assetSourceStr + "/" + mapConfig.source); }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { base.toReadBytesSimple(stream); int itemsLen = stream.readLen(); if (this.items != null) { this.items.clear(); this.items.ensureCapacity(itemsLen); } else { this.items = new IntObjectMap <ItemData>(itemsLen); } IntObjectMap <ItemData> itemsT = this.items; for (int itemsI = itemsLen - 1; itemsI >= 0; --itemsI) { int itemsK; ItemData itemsV; itemsK = stream.readInt(); itemsV = (ItemData)stream.readDataSimpleNotNull(); itemsT.put(itemsK, itemsV); } this.serverItemIndex = stream.readInt(); this.clientItemIndex = stream.readInt(); }
public void setData(IntObjectMap <CDData> cds) { _cds = cds; if (cds != null && !cds.isEmpty()) { IntObjectMap <CDData> groupMaxCDs = _groupMaxCDs; IntIntMap groupCDCount = _groupCDCount; CDData[] values = cds.getValues(); CDData data; for (int i = values.Length - 1; i >= 0; --i) { if ((data = values[i]) != null) { int lastTime = data.getLastTime(); CDConfig config = data.config = CDConfig.get(data.id); foreach (int v in config.groups) { groupCDCount.addValue(v, 1); CDData oldMax = groupMaxCDs.get(v); if (oldMax == null || oldMax.getLastTime() < lastTime) { groupMaxCDs.put(v, data); } } } } } }
/** 选择落下 */ private bool pickDown() { if (_selectData == null) { return(false); } if (!_selectData.isPicked) { return(false); } _selectData.isPicked = false; if (_selectData.isTemp) { _tempData = null; //变实体 _selectData.isTemp = false; _selectData.config.instanceID = getOneElementInstanceID(); _selectData.gameObject.name = getElementName(_selectData); //写入 _elementDic.put(_selectData.config.instanceID, _selectData); _elementDicByObj.put(_selectData.gameObject, _selectData); } // Ctrl.print("pickDown"); setPosFromGameObject(_selectData); return(true); }
private void reCountGroupCDMax() { IntObjectMap <CDData> groupMaxCDs = _groupMaxCDs; //FIXME:SMap CDData[] values = _cds.getValues(); CDData data; CDData gData; int lastTime; for (int i = values.Length - 1; i >= 0; --i) { if ((data = values[i]) != null) { lastTime = data.getLastTime(); foreach (int gv in data.config.groups) { if ((gData = groupMaxCDs.get(gv)) == null || gData.getLastTime() < lastTime) { groupMaxCDs.put(gv, data); } } } } }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.loginInfo = (ClientLoginServerInfoData)stream.readDataSimpleNotNull(); if (stream.readBoolean()) { this.version = (ClientVersionData)stream.createData(ClientVersionData.dataID); this.version.readBytesSimple(stream); } else { this.version = null; } if (stream.readBoolean()) { int areasLen = stream.readLen(); if (this.areas != null) { this.areas.clear(); this.areas.ensureCapacity(areasLen); } else { this.areas = new IntObjectMap <AreaClientData>(areasLen); } IntObjectMap <AreaClientData> areasT = this.areas; for (int areasI = areasLen - 1; areasI >= 0; --areasI) { AreaClientData areasV; if (stream.readBoolean()) { areasV = (AreaClientData)stream.readDataSimpleNotNull(); } else { areasV = null; } areasT.put(areasV.areaID, areasV); } } else { this.areas = null; } this.lastAreaID = stream.readInt(); if (stream.readBoolean()) { this.gameInfo = (ClientLoginServerInfoData)stream.readDataSimpleNotNull(); } else { this.gameInfo = null; } }
/// <summary> /// 注册ui(多实例) /// </summary> public void registMultiUI(int id, Func <GameUIBase> createFunc) { ObjectPool <GameUIBase> pool = new ObjectPool <GameUIBase>(createFunc, 8); pool.setReleaseFunc(k => k.doDispose()); pool.setEnable(CommonSetting.viewUsePool); _multiUIPoolDic.put(id, pool); }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { base.toReadBytesFull(stream); stream.startReadObj(); int itemsLen = stream.readLen(); if (this.items != null) { this.items.clear(); this.items.ensureCapacity(itemsLen); } else { this.items = new IntObjectMap <ItemData>(itemsLen); } IntObjectMap <ItemData> itemsT = this.items; for (int itemsI = itemsLen - 1; itemsI >= 0; --itemsI) { int itemsK; ItemData itemsV; itemsK = stream.readInt(); BaseData itemsVT = stream.readDataFullNotNull(); if (itemsVT != null) { if (itemsVT is ItemData) { itemsV = (ItemData)itemsVT; } else { itemsV = new ItemData(); if (!(itemsVT.GetType().IsAssignableFrom(typeof(ItemData)))) { stream.throwTypeReadError(typeof(ItemData), itemsVT.GetType()); } itemsV.shadowCopy(itemsVT); } } else { itemsV = null; } itemsT.put(itemsK, itemsV); } this.serverItemIndex = stream.readInt(); this.clientItemIndex = stream.readInt(); stream.endReadObj(); }
//方法组 /** 添加物品到指定空位置(正序)(以及空闲格子计算) */ private void addItemToPos(int index, ItemData data) { //先扩容再检测 if (ShineSetting.openCheck) { if (_dic.get(index) != null) { Ctrl.throwError("不该已有物品"); } } data.index = index; //标记index _dic.put(index, data); getItemDicByIDAbs(data.id).put(index, data); _showListDirty = true; }
/** 添加CD组 */ public void reAddCDs(IntObjectMap <CDData> dic, int dTime) { if (dic.isEmpty()) { return; } IntObjectMap <CDData> cds = _cds; if (!cds.isEmpty()) { Ctrl.throwError("这时cd组不应该有值"); } IntObjectMap <CDData> groupMaxCDs = _groupMaxCDs; IntIntMap groupCDCount = _groupCDCount; UnitFightDataLogic parent = _parent; CDData[] values = dic.getValues(); CDData v; for (int i = values.Length - 1; i >= 0; --i) { if ((v = values[i]) != null) { v.config = CDConfig.get(v.id); v.timePass += dTime; //依然有效 if (v.timePass < v.timeMax) { cds.put(v.id, v); foreach (int gv in v.config.groups) { groupCDCount.addValue(gv, 1); CDData oldMax = groupMaxCDs.get(gv); if (oldMax == null || oldMax.getLastTime() < v.getLastTime()) { groupMaxCDs.put(gv, v); } //新的 if (oldMax == null) { parent.onStartGroupCD(gv); } } } } } _parent.onCDChange(); }
/** 缓存到当前数据(见BuffKeepType) */ public void saveCache(MUnitCacheData data, int keepType) { data.cacheTime = getTimeMillis(); //当前属性 IntIntMap currentAttributes = data.currentAttributes; currentAttributes.clear(); int[] currentList = AttributeControl.attribute.currentList; for (int i = currentList.Length - 1; i >= 0; --i) { currentAttributes.put(currentList[i], attribute.getAttribute(currentList[i])); } //buff IntObjectMap <BuffData> buffs = data.buffs; buffs.clear(); BuffData[] values = buff.getBuffDatas().getValues(); BuffData v; for (int i = values.Length - 1; i >= 0; --i) { if ((v = values[i]) != null) { if (v.config.keepType == keepType) { buffs.put(v.instanceID, (BuffData)v.clone()); //clone } } } //cd IntObjectMap <CDData> cds = data.cds; cds.clear(); CDData[] cdValues = cd.getCDs().getValues(); CDData cdV; for (int i = cdValues.Length - 1; i >= 0; --i) { if ((cdV = cdValues[i]) != null) { if (CDConfig.get(cdV.id).keepType == keepType) { cds.put(cdV.id, (CDData)cdV.clone()); //clone } } } }
private void toReleaseData(BaseData data) { ObjectPool <BaseData> pool = _dataDic.get(data.getDataID()); if (pool == null) { _dataDic.put(data.getDataID(), pool = createDataPool(data.getDataID())); } pool.back(data); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { base.toCopy(data); if (!(data is AuctionToolData)) { return; } AuctionToolData mData = (AuctionToolData)data; if (mData.itemRecords != null) { if (this.itemRecords != null) { this.itemRecords.clear(); this.itemRecords.ensureCapacity(mData.itemRecords.size()); } else { this.itemRecords = new IntObjectMap <AuctionItemRecordData>(mData.itemRecords.size()); } IntObjectMap <AuctionItemRecordData> itemRecordsT = this.itemRecords; if (!mData.itemRecords.isEmpty()) { AuctionItemRecordData[] itemRecordsVValues = mData.itemRecords.getValues(); for (int itemRecordsVI = itemRecordsVValues.Length - 1; itemRecordsVI >= 0; --itemRecordsVI) { AuctionItemRecordData itemRecordsV = itemRecordsVValues[itemRecordsVI]; if (itemRecordsV != null) { AuctionItemRecordData itemRecordsU; if (itemRecordsV != null) { itemRecordsU = (AuctionItemRecordData)itemRecordsV.clone(); } else { itemRecordsU = null; nullObjError("itemRecordsU"); } itemRecordsT.put(itemRecordsU.id, itemRecordsU); } } } } else { this.itemRecords = null; nullObjError("itemRecords"); } }
/** 获取可用实例 */ protected TriggerInstance getInstance(int id) { TriggerInstance instance; if ((instance = _instanceDic.get(id)) == null) { _instanceDic.put(id, instance = doCreateInstance(id)); } return(instance); }
/** 获取部件加载器 */ private AssetPoolLoadTool getPartLoadTool(int type) { AssetPoolLoadTool tool = _partLoadToolDic.get(type); if (tool == null) { _partLoadToolDic.put(type, tool = new AssetPoolLoadTool(AssetPoolType.UnitPart)); } return(tool); }
private void toReleaseRequest(BaseData data) { ObjectPool <BaseData> pool = _requestDic.get(data.getDataID()); if (pool == null) { _requestDic.put(data.getDataID(), pool = createRequestPool(data.getDataID())); } pool.back(data); }
/** 获取物品组(id为key)(没有就创建) */ private IntObjectMap <ItemData> getItemDicByIDAbs(int id) { IntObjectMap <ItemData> tDic = _dicByID.get(id); if (tDic == null) { _dicByID.put(id, tDic = new IntObjectMap <ItemData>()); } return(tDic); }
/** 开始服务器CD组 */ public void startCDsByServer(SList <CDData> list) { IntObjectMap <CDData> cds = _cds; IntObjectMap <CDData> groupMaxCDs = _groupMaxCDs; IntIntMap groupCDCount = _groupCDCount; UnitFightDataLogic parent = _parent; CDData oldData; CDData data; CDConfig config; foreach (CDData v in list) { config = CDConfig.get(v.id); if ((oldData = cds.get(v.id)) == null) { data = v; data.config = config; cds.put(data.id, data); } else { data = oldData; data.timePass = v.timePass; data.timeMax = v.timeMax; } foreach (int gv in config.groups) { //计数加1 if (oldData == null) { groupCDCount.addValue(gv, 1); } CDData oldMax = groupMaxCDs.get(gv); if (oldMax == null || oldMax.getLastTime() < data.timeMax) { groupMaxCDs.put(gv, data); } //新的 if (oldMax == null) { parent.onStartGroupCD(gv); } } } _parent.onCDChange(); }
/** 添加元素 */ public void addElement(ScenePlaceElementConfig element) { if (BaseC.config.isIniting() && ShineSetting.openCheck) { if (elements.contains(element.instanceID)) { Ctrl.errorLog("场景元素重复:", element.instanceID); } } elements.put(element.instanceID, element); }
protected void registOne(int requestID, params int[] responses) { IntSet dd = new IntSet(); dd.addAll(responses); _requestSet.put(requestID, dd); // foreach(int id in responses) // { // _responseReDic.computeIfAbsent(id,v=>new IntList()).add(requestID); // } }
/// <summary> /// 注册目标完成回调(construct阶段用) /// </summary> public void registTaskCompleteFunc(int funcID, Action <TaskData> func) { if (ShineSetting.openCheck) { if (_taskCompleteFuncDic.contains(funcID)) { Ctrl.throwError("registTaskCompleteFunc时,重复的功能ID", funcID); } } _taskCompleteFuncDic.put(funcID, func); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is ActivityPartData)) { return; } ActivityPartData mData = (ActivityPartData)data; if (mData.datas != null) { if (this.datas != null) { this.datas.clear(); this.datas.ensureCapacity(mData.datas.size()); } else { this.datas = new IntObjectMap <ActivityData>(mData.datas.size()); } IntObjectMap <ActivityData> datasT = this.datas; if (!mData.datas.isEmpty()) { ActivityData[] datasVValues = mData.datas.getValues(); for (int datasVI = datasVValues.Length - 1; datasVI >= 0; --datasVI) { ActivityData datasV = datasVValues[datasVI]; if (datasV != null) { ActivityData datasU; if (datasV != null) { datasU = (ActivityData)datasV.clone(); } else { datasU = null; nullObjError("datasU"); } datasT.put(datasU.id, datasU); } } } } else { this.datas = null; nullObjError("datas"); } }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is PetPartData)) { return; } PetPartData mData = (PetPartData)data; if (mData.petDic != null) { if (this.petDic != null) { this.petDic.clear(); this.petDic.ensureCapacity(mData.petDic.size()); } else { this.petDic = new IntObjectMap <PetUseData>(mData.petDic.size()); } IntObjectMap <PetUseData> petDicT = this.petDic; if (!mData.petDic.isEmpty()) { PetUseData[] petDicVValues = mData.petDic.getValues(); for (int petDicVI = petDicVValues.Length - 1; petDicVI >= 0; --petDicVI) { PetUseData petDicV = petDicVValues[petDicVI]; if (petDicV != null) { PetUseData petDicU; if (petDicV != null) { petDicU = (PetUseData)petDicV.clone(); } else { petDicU = null; nullObjError("petDicU"); } petDicT.put(petDicU.mIndex, petDicU); } } } } else { this.petDic = null; nullObjError("petDic"); } }
private ItemRecordData getRecordDataAbs(int id) { ItemRecordData re; if ((re = _itemRecordDic.get(id)) == null) { re = _recordDataPool.getOne(); re.id = id; _itemRecordDic.put(id, re); } return(re); }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { base.toReadBytesSimple(stream); int equipsLen = stream.readLen(); if (this.equips != null) { this.equips.clear(); this.equips.ensureCapacity(equipsLen); } else { this.equips = new IntObjectMap <ItemData>(equipsLen); } IntObjectMap <ItemData> equipsT = this.equips; for (int equipsI = equipsLen - 1; equipsI >= 0; --equipsI) { int equipsK; ItemData equipsV; equipsK = stream.readInt(); equipsV = (ItemData)stream.readDataSimpleNotNull(); equipsT.put(equipsK, equipsV); } int openSlotsLen = stream.readLen(); if (this.openSlots != null) { this.openSlots.clear(); this.openSlots.ensureCapacity(openSlotsLen); } else { this.openSlots = new IntSet(); } IntSet openSlotsT = this.openSlots; for (int openSlotsI = openSlotsLen - 1; openSlotsI >= 0; --openSlotsI) { int openSlotsV; openSlotsV = stream.readInt(); openSlotsT.add(openSlotsV); } }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { base.toReadBytesFull(stream); stream.startReadObj(); int itemRecordsLen = stream.readLen(); if (this.itemRecords != null) { this.itemRecords.clear(); this.itemRecords.ensureCapacity(itemRecordsLen); } else { this.itemRecords = new IntObjectMap <AuctionItemRecordData>(itemRecordsLen); } IntObjectMap <AuctionItemRecordData> itemRecordsT = this.itemRecords; for (int itemRecordsI = itemRecordsLen - 1; itemRecordsI >= 0; --itemRecordsI) { AuctionItemRecordData itemRecordsV; BaseData itemRecordsVT = stream.readDataFullNotNull(); if (itemRecordsVT != null) { if (itemRecordsVT is AuctionItemRecordData) { itemRecordsV = (AuctionItemRecordData)itemRecordsVT; } else { itemRecordsV = new AuctionItemRecordData(); if (!(itemRecordsVT.GetType().IsAssignableFrom(typeof(AuctionItemRecordData)))) { stream.throwTypeReadError(typeof(AuctionItemRecordData), itemRecordsVT.GetType()); } itemRecordsV.shadowCopy(itemRecordsVT); } } else { itemRecordsV = null; } itemRecordsT.put(itemRecordsV.id, itemRecordsV); } stream.endReadObj(); }