Add buy cmd
This commit is contained in:
@@ -33,6 +33,7 @@ public struct GShopItem
|
||||
public uint giftTime; // Gift duration
|
||||
public uint logPrice; // Log price
|
||||
public uint[] ownerNpcs; // NPCs that own this item (8 max)
|
||||
public int itemIndex;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
||||
@@ -64,6 +64,7 @@ public class GShopLoader : MonoBehaviour
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
GShopItem item = ReadGShopItem(reader);
|
||||
item.itemIndex = i;
|
||||
shopData.items.Add(item);
|
||||
}
|
||||
|
||||
@@ -188,6 +189,7 @@ public class GShopLoader : MonoBehaviour
|
||||
Debug.Log($" Quantity: {item.num}");
|
||||
Debug.Log($" Icon: {item.icon}");
|
||||
Debug.Log($" Description: {item.desc}");
|
||||
Debug.Log($" Local ID: {item.localId}");
|
||||
|
||||
// Log buy options
|
||||
for (int j = 0; j < 4; j++)
|
||||
|
||||
@@ -633,6 +633,17 @@ namespace CSNetwork.C2SCommand
|
||||
public int serviceId;
|
||||
public byte[] data; // Variable length array
|
||||
}
|
||||
public struct CMD_MallShopping
|
||||
{
|
||||
public uint count;
|
||||
|
||||
public struct goods
|
||||
{
|
||||
public int goods_id;
|
||||
public int goods_index;
|
||||
public int goods_pos;
|
||||
}
|
||||
};
|
||||
|
||||
// Random mall shopping command
|
||||
public struct CMD_RandomMallShopping
|
||||
|
||||
@@ -331,6 +331,29 @@ namespace CSNetwork.C2SCommand
|
||||
};
|
||||
return SerializeCommand(CommandID.GET_IVTR_DETAIL, cmd);
|
||||
}
|
||||
public static Octets CreateGetMallShopping(uint count, CMD_MallShopping.goods[] goodsArray)
|
||||
{
|
||||
var cmd = new CMD_MallShopping()
|
||||
{
|
||||
count = count
|
||||
};
|
||||
|
||||
// Serialize the command structure first
|
||||
var octets = SerializeCommand(CommandID.MALL_SHOPPING, cmd);
|
||||
|
||||
// Append the goods array directly (matching C++ memcpy behavior)
|
||||
if (goodsArray != null && goodsArray.Length > 0)
|
||||
{
|
||||
foreach (var goods in goodsArray)
|
||||
{
|
||||
WriteBasicValue(octets, goods.goods_id);
|
||||
WriteBasicValue(octets, goods.goods_index);
|
||||
WriteBasicValue(octets, goods.goods_pos);
|
||||
}
|
||||
}
|
||||
|
||||
return octets;
|
||||
}
|
||||
public static Octets CreateOwnItemInfo
|
||||
(
|
||||
byte byPackage,
|
||||
|
||||
@@ -923,7 +923,16 @@ namespace CSNetwork.GPDataType
|
||||
{
|
||||
public info_matter Info;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct cmd_host_obtain_item
|
||||
{
|
||||
public int type;
|
||||
public int expire_date;
|
||||
public uint amount;
|
||||
public uint slot_amount;
|
||||
public byte where; //���ĸ���������0 ����2 ����1 װ��
|
||||
public byte index; //��ַ����ĸ�λ��
|
||||
};
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct cmd_pickup_item
|
||||
{
|
||||
|
||||
@@ -214,6 +214,13 @@ namespace CSNetwork
|
||||
gamedatasendRequest.Data = CSNetwork.C2SCommand.C2SCommandFactory.CreateEquipItem(iIvtrIdx, iEquipIdx);
|
||||
SendProtocol(gamedatasendRequest, callback);
|
||||
}
|
||||
|
||||
public void RequestMallShopping(uint count, CMD_MallShopping.goods[] goodsArray)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
gamedatasendRequest.Data = CSNetwork.C2SCommand.C2SCommandFactory.CreateGetMallShopping(count, goodsArray);
|
||||
SendProtocol(gamedatasendRequest);
|
||||
}
|
||||
public void RequestOwnItemInfoAsync(
|
||||
byte byPackage,
|
||||
byte bySlot,
|
||||
@@ -389,7 +396,8 @@ namespace CSNetwork
|
||||
case CommandID.MATTER_ENTER_WORLD:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERENTWORLD, (int)MANAGER_INDEX.MAN_MATTER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.PICKUP_ITEM:
|
||||
case CommandID.PICKUP_ITEM:
|
||||
case CommandID.HOST_OBTAIN_ITEM:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPITEM, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.HOST_CORRECT_POS:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BrewMonster;
|
||||
using CSNetwork;
|
||||
using CSNetwork.C2SCommand;
|
||||
using CSNetwork.Protocols;
|
||||
using CSNetwork.Protocols.RPCData;
|
||||
using CSNetwork.Security;
|
||||
@@ -160,6 +161,20 @@ namespace BrewMonster.Network
|
||||
{
|
||||
Instance._gameSession.RequestCheckSecurityPassWd(password);
|
||||
}
|
||||
|
||||
public void RequestMallShopping(uint count, int good_id, int good_index, int good_pos)
|
||||
{
|
||||
var goods = new CMD_MallShopping.goods[]
|
||||
{
|
||||
new CMD_MallShopping.goods
|
||||
{
|
||||
goods_id = good_id,
|
||||
goods_index = good_index,
|
||||
goods_pos = good_pos
|
||||
}
|
||||
};
|
||||
Instance._gameSession.RequestMallShopping(count, goods);
|
||||
}
|
||||
public static void RequestAllInventoriesAsync(Action callback = null, params byte[] packages)
|
||||
{
|
||||
if (packages == null || packages.Length == 0)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using BrewMonster.Network;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
@@ -311,8 +313,8 @@ public class ShopDetailPanel : MonoBehaviour
|
||||
void OnBuyClicked()
|
||||
{
|
||||
// TODO: Implement purchase logic
|
||||
Debug.Log($"Attempting to buy item: {currentItem.name} (ID: {currentItem.id})");
|
||||
|
||||
Debug.Log($"Attempting to buy item: ID {currentItem.id} (Index: {currentItem.itemIndex})");
|
||||
UnityGameSession.Instance.RequestMallShopping(1, Convert.ToInt32(currentItem.id), currentItem.itemIndex, 0);
|
||||
// Close panel after purchase attempt
|
||||
OnCloseClicked();
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class ShopUIManager : MonoBehaviour
|
||||
public void ShowItemDetail(GShopItem item)
|
||||
{
|
||||
selectedItem = item;
|
||||
|
||||
Debug.Log($"$ Local ID of selected item: {item.localId}");
|
||||
if (shopDetailPanel != null)
|
||||
{
|
||||
shopDetailPanel.SetActive(true);
|
||||
|
||||
@@ -402,6 +402,9 @@ public class CECHostPlayer : CECPlayer
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
switch (cmd)
|
||||
{
|
||||
case CommandID.HOST_OBTAIN_ITEM:
|
||||
Debug.Log("Host OBTAIN_ITEM");
|
||||
break;
|
||||
case CommandID.PICKUP_ITEM:
|
||||
{
|
||||
int tid = BitConverter.ToInt32(data, 0);
|
||||
|
||||
Reference in New Issue
Block a user