public static void ModifyLittleZooMap(int littleZooID, Dictionary <int, LittleZoo> littleZooMap) { LittleZoo littleZoo = null; var buildinPos = LittleZooBuildinPosManager.GetInstance().GetLittleZooBuildinPos(littleZooID); var littleZooModuleDatas = GlobalDataManager.GetInstance().playerData.playerZoo.littleZooModuleDatasMSS; int idx = GlobalDataManager.GetInstance().playerData.GetLittleZooIDIndexOfDataIdx(littleZooID); //获取动物栏ID 下标 var cell = Config.buildupConfig.getInstace().getCell(littleZooID); //int visitNum = OpenVisitPosNUmber(littleZooModuleDatas[idx].littleZooVisitorSeatLevel); int visitNum = OpenVisitPosNumber((int)littleZooModuleDatas[idx].littleZooID, (int)littleZooModuleDatas[idx].littleZooVisitorSeatLevel); int visitDuartion = (int)GetComeVisitorSpeedCD(littleZooID, littleZooModuleDatas[idx].littleZooEnterVisitorSpawnLevel); //LogWarp.LogErrorFormat("测试: 当前动物栏{0}的观光点数{1}",littleZooID,visitNum); if (!littleZooMap.TryGetValue(littleZooID, out littleZoo)) { littleZoo = new LittleZoo(littleZooID, buildinPos, visitDuartion, visitNum, visitNum); littleZooMap.Add(littleZooID, littleZoo); return; } littleZoo.visitCDValue = visitDuartion; if (visitNum > littleZoo.maxLenthOfVisitQueue) { int extendLen = visitNum - littleZoo.maxLenthOfVisitQueue; for (int i = 0; i < extendLen; i++) { littleZoo.visitQueue.Add(Const.Invalid_Int); littleZoo.waitQueue.Add(Const.Invalid_Int); } littleZoo.maxLenthOfVisitQueue = visitNum; littleZoo.maxLenthOfWaitQueue = visitNum; } }
protected void OnVisitorGetVisitSeatApply(Message msg) { var _msg = msg as VisitorGetVisitSeatApply; LittleZoo littleZoo = null; int littleZooID = _msg.littleZooID; int entityID = _msg.entityID; if (!littleZooMap.TryGetValue(littleZooID, out littleZoo)) { #if UNITY_EDITOR string e = string.Format("VisitorGetVisitSeatApply 异常 {0}, {1}", entityID, littleZooID); throw new System.Exception(e); #endif return; } int indexInQueue = Const.Invalid_Int; bool retCode = littleZoo.IsFreeVisitQueue(ref indexInQueue); if (!retCode) { //没有空位 失败 VisitorGetVisitSeatReply.Send(entityID, false, Const.Invalid_Int, Const.Invalid_Int); return; } littleZoo.AddVisitorToVisitQueue(_msg.entityID, indexInQueue); VisitorGetVisitSeatReply.Send(entityID, true, littleZooID, indexInQueue); }
protected void OnLittleZooData(Message msg) { var _msg = msg as LittleZooData; LittleZoo littleZoo = null; if (!littleZooMap.TryGetValue(_msg.littleZooID, out littleZoo)) { string e = string.Format("没找到动物栏信息 {0}", _msg.littleZooID); throw new System.Exception(e); } LittleZooDataReply.Send(_msg.entityID, littleZoo); }
/// <summary> /// 从开启的动物栏中选择有空位的动物栏(等待位有空位) /// </summary> /// <param name="openedLittleZooIDs"></param> /// <param name="littleZooMap"></param> /// <param name="freeLittleZooIDs"></param> /// <returns></returns> public static bool GetFreeLittleZooIDs(List <int> openedLittleZooIDs, Dictionary <int, LittleZoo> littleZooMap, List <int> freeLittleZooIDs) { freeLittleZooIDs.Clear(); LittleZoo littleZoo = null; int littleZooID = Const.Invalid_Int; for (int i = 0; i < openedLittleZooIDs.Count; i++) { littleZooID = openedLittleZooIDs[i]; littleZooMap.TryGetValue(littleZooID, out littleZoo); if (littleZoo.IsFreeWaitQueue()) { freeLittleZooIDs.Add(littleZooID); } } return(freeLittleZooIDs.Count > 0); }
/// <summary> /// 游客的观光时间到了,要把这个观光位腾出来,给对应的等待位上的游客 /// </summary> /// <param name="msg"></param> protected void OnVisitorVisitCDFinshed(Message msg) { var _msg = msg as VisitorVisitCDFinshed; LittleZoo littleZoo = null; if (!littleZooMap.TryGetValue(_msg.littleZooID, out littleZoo)) { string e = string.Format("查不到LittleZoo {0}", _msg.littleZooID); throw new System.Exception(e); } //游客退出观光位,查找游客在观光位的位置 DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "LittleZooModule 收到{0}, 把{1}移除观光位", _msg, _msg.entityID); int indexInVisitQueue = littleZoo.RemoveVisitorFromVisitQueue(_msg.entityID); var toMsgCDTo = VisitorVisitCDFinshedReply.Send(_msg.entityID, _msg.indexInVisitQueue, _msg.littleZooID); DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "LittleZooModule 收到{0}, 把{1}移除观光位{2}, 发送{3}", _msg, _msg.entityID, indexInVisitQueue, toMsgCDTo); //PlayEffect(_msg); }