private void UpdateLockInfo(GameCmd.PACKAGETYPE ptype , table.UnlockStoreDataBase unlockdb , GameCmd.UnlockInfo serverUnlockInfo) { this.m_unlockDatabase = unlockdb; m_pType = ptype; m_ServerUnlockInfo = serverUnlockInfo; }
/// <summary> /// 创建本地仓库解锁信息 /// </summary> /// <param name="pType"></param> /// <param name="serverUnlockInfo"></param> /// <returns></returns> public static LocalUnlockInfo Create(GameCmd.PACKAGETYPE pType, GameCmd.UnlockInfo serverUnlockInfo) { table.UnlockStoreDataBase unlockDatabase = GameTableManager.Instance.GetTableItem <table.UnlockStoreDataBase>((uint)pType, 0); if (null == unlockDatabase) { Engine.Utility.Log.Error("Get Package unlock info failed ,pt={0}", pType); return(null); } LocalUnlockInfo info = new LocalUnlockInfo(); info.UpdateLockInfo(pType, unlockDatabase, serverUnlockInfo); return(info); }
/// <summary> /// 获取解锁背包格消耗钱币 /// </summary> /// <param name="pType">背包类型</param> /// <param name="needUnlockNum">当前需要解锁的数量</param> /// <returns></returns> public Dictionary <uint, uint> GetUnlockGridCost(GameCmd.PACKAGETYPE pType, int needUnlockNum) { Dictionary <uint, uint> costDic = new Dictionary <uint, uint>(); if (needUnlockNum <= 0) { return(costDic); } KnapsackDefine.LocalUnlockInfo unlockInfo = GetUnlockInfoByPackageType(pType); int initNum = GetInitGridByPackageType(pType); if (null != unlockInfo) { if (unlockInfo.UnlockNum - initNum >= 0) { int startIndex = unlockInfo.UnlockNum - initNum + 1; uint cost = 0; table.UnlockStoreDataBase storeTableData = null; for (int i = startIndex; i < startIndex + needUnlockNum; i++) { storeTableData = GetUnlockStoreDataBase((uint)pType, i); if (null != storeTableData) { if (costDic.ContainsKey(storeTableData.moneyType)) { costDic[storeTableData.moneyType] += storeTableData.moneyNum; } else { costDic.Add(storeTableData.moneyType, storeTableData.moneyNum); } } } } } return(costDic); }
/// <summary> /// 获取背包初始解锁数量 /// </summary> /// <param name="pType"></param> /// <returns></returns> public int GetInitGridByPackageType(GameCmd.PACKAGETYPE pType) { table.UnlockStoreDataBase firstData = GetUnlockStoreDataBase((uint)pType, 0); return((int)((null != firstData) ? firstData.initNum : 0)); }