/** 服务器添加物品 */ public void onAddItemsByServer(IntIntMap autoUseItems, IntObjectMap <ItemData> dic, int way) { bool need = CallWayConfig.get(way).needAddItemNotice; if (need) { _tempAddItems.clear(); if (autoUseItems != null) { autoUseItems.forEach((k, v) => { _tempAddItems.add(GameC.player.bag.createItem(k, v)); }); } } if (dic != null) { foreach (var kv in dic.entrySet()) { doAddItemByServer(kv.key, kv.value, way); } } onChanged(); if (CallWayConfig.get(way).needAddItemNotice) { //TODO:合并因为到达单个物品上限的拆分问题 onAddItemNotice(_tempAddItems, way); _tempAddItems.clear(); } }
/** 服务器添加物品 */ public void onAddItemNumByServer(int index, int num, int way) { ItemData data = getItem(index); if (data == null) { Ctrl.warnLog("服务器添加物品数目时,找不到物品", _funcID, index); return; } int dNum = num - data.num; data.num = num; doAddItemPartial(index, dNum, data); onItemAdd(index, data, dNum, way); onChanged(); if (CallWayConfig.get(way).needAddItemNotice) { _tempAddItems.clear(); ItemData temp = (ItemData)data.clone(); temp.num = dNum; _tempAddItems.add(temp); onAddItemNotice(_tempAddItems, way); _tempAddItems.clear(); } }
/** 执行添加物品(来自服务器) */ private void doAddItemByServer(int index, ItemData data, int way) { data.makeConfig(); //先把来自服务器的标记取消,由客户端自己加 data.hasRedPoint = false; ItemData oldData = getItem(index); int dNum = 0; if (oldData == null) { doAddItemNew(index, dNum = data.num, data); } else { data.index = index; updateItem(index, data); doAddItemPartial(index, dNum = data.num - oldData.num, data); //TODO:oldData回收 } onItemAdd(index, data, dNum, way); if (CallWayConfig.get(way).needAddItemNotice) { ItemData temp = (ItemData)data.clone(); temp.num = dNum; _tempAddItems.add(temp); } }
/** 服务器添加物品 */ public void onAddItemByServer(int index, ItemData data, int way) { _tempAddItems.clear(); doAddItemByServer(index, data, way); onChanged(); if (CallWayConfig.get(way).needAddItemNotice) { onAddItemNotice(_tempAddItems, way); _tempAddItems.clear(); } }
/** 角色获得物品时添加到邮件 */ public void playerAddItemToMail(Player player, int itemID, int num, int way) { if (!CommonSetting.isClientDriveLogic) { return; } LogInfo info = createActionLogInfo("addItemToMail"); putPlayer(info, player); info.put("itemID", itemID); info.put("num", num); info.put("way", way); info.put("wayDescribe", CallWayConfig.get(way).describe); addActionLog(info); }
/** 角色消费货币 */ public void playerCostCurrency(Player player, int type, long value, int way) { if (!CommonSetting.isClientDriveLogic) { return; } LogInfo info = createActionLogInfo("costCurrency"); putPlayer(info, player); info.put("type", type); info.put("value", value); info.put("way", way); info.put("wayDescribe", CallWayConfig.get(way).describe); addActionLog(info); }