public static void DoPveBuy(ShopInfo shopInfo, Units unit, string targetItemID, List <ItemInfo> possessItemsP, int realPrice) { List <ItemInfo> list = new List <ItemInfo>(possessItemsP); List <string> composition = BattleEquipTools_Travers.GetComposition(targetItemID, list); if (composition != null || composition.Count > 0) { for (int i = 0; i < composition.Count; i++) { ItemInfo target; int index; if (BattleEquipTools_Travers.GetItem_last_least(list, composition[i], out target, out index)) { BattleEquipTools_op.RemoveItem(list, target, index); } } } BattleEquipTools_op.AddItem(list, targetItemID); BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, -realPrice); BattleEquipTools_op.SetHeroItems(unit, list); byte[] msgParam = SerializeHelper.Serialize <P2CBuyItem>(new P2CBuyItem { itemoid = 0, retaCode = 0 }); MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_BuyItem, msgParam, 0f, null); MobaMessageManager.DispatchMsg(message); }
public static void DoPveRollback(ShopInfo shopInfo, Units unit) { RollbackInfo rollbackInfo = shopInfo.RollbackStack.Peek(); if (rollbackInfo != null) { BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, -rollbackInfo._deltaMoney); BattleEquipTools_op.SetHeroItems(unit, rollbackInfo._items); } byte[] msgParam = SerializeHelper.Serialize <RetaMsg>(new RetaMsg { retaCode = 0 }); MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_RevertShop, msgParam, 0f, null); MobaMessageManager.DispatchMsg(message); }
public static void DoPveSell(ShopInfo shopInfo, Units unit, ItemInfo targetItem, List <ItemInfo> possessItemsP) { List <ItemInfo> items = new List <ItemInfo>(possessItemsP); int itemPrice = BattleEquipTools_config.GetItemPrice(targetItem.ID); int delta = (int)((float)itemPrice * 0.8f); BattleEquipTools_op.RemoveItem(items, targetItem); BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, delta); BattleEquipTools_op.SetHeroItems(unit, items); byte[] msgParam = SerializeHelper.Serialize <P2CSellItem>(new P2CSellItem { itemoid = 0, retaCode = 0 }); MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_SellItem, msgParam, 0f, null); MobaMessageManager.DispatchMsg(message); }