public uint Execute(PacketDistributed ipacket) { GC_RESTAURANT_UPDATE packet = (GC_RESTAURANT_UPDATE)ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } RestaurantData.UpdatePlayerData(packet); return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
public static void UpdatePlayerData(GC_RESTAURANT_UPDATE data) { if (data.HasFriendGuid) { UpdateRestaurantInfo(m_FriendRestaurantInfo, data); if (null != delUpdateFriendData) { delUpdateFriendData(); } } else { UpdateRestaurantInfo(m_PlayerRestaurantInfo, data); if (null != delUpdatePlayerData) { delUpdatePlayerData(); } } }
// 更新酒楼信息 public static void UpdateRestaurantInfo(RestaurantInfo curRestaurant, GC_RESTAURANT_UPDATE data) { curRestaurant.m_RestaurantExp = data.RestaurantExp; curRestaurant.m_RestaurantLevel = data.RestaurantLevel; curRestaurant.m_MasterName = data.Name; if (data.HasFriendGuid) { curRestaurant.m_FrinedGuid = data.FriendGuid; } // 先重置 foreach (DeskInfo curDesk in curRestaurant.m_Desks) { curDesk.Rest(); } int nRestaurantTipCount = 0; for (int i = 0; i < data.activeDeskIndexsCount; i++) { if (data.activeDeskIndexsList[i] >= DeskCountMax) { LogModule.ErrorLog("desk index is more than 10", i.ToString()); break; } if (data.actionFinishTimersCount <= i) { LogModule.ErrorLog("food timer list length is less than desk count ", data.actionFinishTimersCount.ToString()); break; } if (data.deskGuestIDsCount <= i * GuestCountMax) { LogModule.ErrorLog("guest id count is less than desk count ", data.deskGuestIDsCount.ToString()); break; } DeskInfo curDesk = curRestaurant.m_Desks[data.activeDeskIndexsList[i]]; curDesk.m_IsActive = true; curDesk.m_DeskFinishTime = data.actionFinishTimersList[i] + (int)Time.realtimeSinceStartup; for (int guestIndex = 0; guestIndex < GuestCountMax; guestIndex++) { int nDestGuestIDsListIndex = 4 * i + guestIndex; if (guestIndex >= curDesk.m_GuestIDs.Length || nDestGuestIDsListIndex >= data.deskGuestIDsList.Count) { LogModule.ErrorLog("guestIndex or nDestGuestIDsListIndex error"); break; } curDesk.m_GuestIDs[guestIndex] = data.deskGuestIDsList[nDestGuestIDsListIndex]; } curDesk.m_DestState = (DeskState)data.deskStatesList[i]; curDesk.m_FoodID = data.GetDeskFoodIDs(i); if (RestaurantData.DeskState.WaitBilling == curDesk.m_DestState) { nRestaurantTipCount++; } } if (!data.HasFriendGuid) { //PlayerPreferenceData.RestaurantTipCount = nRestaurantTipCount; m_restaurantTipsCount = nRestaurantTipCount; if (MenuBarLogic.Instance() != null) { MenuBarLogic.Instance().UpdateRestaurantTips(); } if (PlayerFrameLogic.Instance() != null) { PlayerFrameLogic.Instance().UpdateRemainNum(); } } }