public void RequestAddGood(int itemCfgID, int count) { PCMInt2 data = new PCMInt2(); data.arg = itemCfgID; data.arg2 = count; Net.Send(eCommand.SYS_ADD_GOOD, data); }
private void UseItem(int itemCfgID, int count) { PCMInt2 data = new PCMInt2(); data.arg = itemCfgID; data.arg2 = count; NetworkManager.Instance.Send(eCommand.SYS_REDUCE_GOOD, data, (byte[] buffer) => { CommonAnswer ret = Net.Deserialize <CommonAnswer>(buffer); if (ret.err_code != 0) { Log.Error("GM使用物品失败 {0}", ret.err_code); return; } Log.Info("GM使用物品成功"); if (itemCfgID == GameConfig.ITEM_CONFIG_ID_MONEY) { UserManager.Instance.Money = Mathf.Max(UserManager.Instance.Money - count, 0); } else if (itemCfgID == GameConfig.ITEM_CONFIG_ID_WOOD) { UserManager.Instance.Money = Mathf.Max(UserManager.Instance.Wood - count, 0); } else if (itemCfgID == GameConfig.ITEM_CONFIG_ID_STONE) { UserManager.Instance.Money = Mathf.Max(UserManager.Instance.Stone - count, 0); } else if (itemCfgID == GameConfig.ITEM_CONFIG_ID_GOLD) { UserManager.Instance.Money = Mathf.Max(UserManager.Instance.Gold - count, 0); } else { ItemInfo info = UserManager.Instance.GetItemByConfigID(itemCfgID); if (info != null) { info.Number = Mathf.Max(info.Number - count, 0); } } EventDispatcher.TriggerEvent(EventID.EVENT_UI_MAIN_REFRESH_VALUE); }); }