public static void LoadData() { SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("randombox"); while (reader.Read()) { RandomItemBoxInfo boxInfo = new RandomItemBoxInfo(); boxInfo.boxNo = Convert.ToInt32(reader.GetString(reader.GetOrdinal("boxno"))); boxInfo.boxId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("boxid"))); boxInfo.boxName = reader.GetString(reader.GetOrdinal("boxname")); boxInfo.boxAmount = Convert.ToInt32(reader.GetString(reader.GetOrdinal("boxamount"))); boxInfo.boxDepth = Convert.ToSingle(reader.GetString(reader.GetOrdinal("boxdepth"))); boxInfo.boxRange = Convert.ToInt32(reader.GetString(reader.GetOrdinal("boxrange"))); string[] boxMapTypeStr = reader.GetString(reader.GetOrdinal("boxmaptype")).Split(','); boxInfo.boxMapType = new List <int> (); foreach (string str in boxMapTypeStr) { boxInfo.boxMapType.Add(Convert.ToInt32(str)); } string[] itemAmountStr = reader.GetString(reader.GetOrdinal("boxitemamount")).Split(','); boxInfo.boxItemAmountMin = Convert.ToInt32(itemAmountStr[0]); boxInfo.boxItemAmountMax = boxInfo.boxItemAmountMin; if (itemAmountStr.Count() > 1) { boxInfo.boxItemAmountMax = Convert.ToInt32(itemAmountStr[1]); } boxInfo.rulesId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("rulesid"))); boxInfo.boxModelPath = reader.GetString(reader.GetOrdinal("boxmodelpath")); mDataDic.Add(boxInfo.boxId, boxInfo); } }
void RPC_S2C_GenRandomItem(uLink.BitStream stream, uLink.NetworkMessageInfo info) { Vector3 pos = stream.Read <Vector3>(); Quaternion rot = stream.Read <Quaternion>(); int templateId = stream.Read <int>(); int[] itemIdCount = stream.Read <int[]>(); RandomItem.RandomItemBoxInfo boxInfo = RandomItem.RandomItemBoxInfo.GetBoxInfoById(templateId); if (boxInfo != null) { RandomItemMgr.Instance.AddItmeResult(pos, rot, templateId, itemIdCount, boxInfo.boxModelPath); } }
void RPC_S2C_RandomItemRareAry(uLink.BitStream stream, uLink.NetworkMessageInfo info) { List <Vector3> posList = stream.Read <Vector3[]>().ToList(); List <Quaternion> rotList = stream.Read <Quaternion[]>().ToList(); List <int> idList = stream.Read <int[]>().ToList(); List <int> itemLength = stream.Read <int[]>().ToList(); List <int> allItems = stream.Read <int[]>().ToList(); for (int i = 0; i < posList.Count; i++) { Vector3 pos = posList[i]; Quaternion rot = rotList[i]; int boxId = idList[i]; int iCount = itemLength[i]; int[] itemIdCount = new int[iCount]; Array.Copy(allItems.ToArray(), itemIdCount, iCount); allItems.RemoveRange(0, iCount); RandomItem.RandomItemBoxInfo boxInfo = RandomItem.RandomItemBoxInfo.GetBoxInfoById(boxId); if (boxInfo != null) { RandomItemMgr.Instance.AddRareItmeResult(pos, rot, boxId, itemIdCount, boxInfo.boxModelPath); } } }