Example #1
0
	public static Dictionary<string, body2_SC_CHARGE_ITEMLIST> ConvertChargeItemListToDictionary( body2_SC_CHARGE_ITEMLIST[] _chargeItems)
	{
		Dictionary<string, body2_SC_CHARGE_ITEMLIST> dicItemName = new Dictionary<string, body2_SC_CHARGE_ITEMLIST>();

		foreach( body2_SC_CHARGE_ITEMLIST product in _chargeItems)
		{
			string id = System.Text.ASCIIEncoding.Default.GetString( product.strIAPProductID);
	
			int lastIdx = id.IndexOf( '\0');
			string productId = id.Substring( 0, lastIdx);
	
			if( !dicItemName.ContainsKey( productId))
				dicItemName.Add( productId, product);
		}

		return dicItemName;
	}
Example #2
0
	public new void PacketBytesToClass( byte[] data)
	{
		Type infotype = this.GetType();
		FieldInfo headerinfo = null;

		int index = ParsePacketHeader( data);

		// eCompany
		byte[] companyType = new byte[1];
		headerinfo = infotype.GetField("eCompany", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, companyType, 0, sizeof(byte));
		headerinfo.SetValue( this, (eCHARGECOMPANYTYPE)companyType[0]);
		index += sizeof(byte);

		// nCnt
		byte[] itemCount = new byte[ sizeof( UInt16)];
		headerinfo = infotype.GetField( "nCnt", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, itemCount, 0, sizeof( UInt16));
		headerinfo.SetValue( this, BitConverter.ToUInt16( itemCount, 0));
		index += sizeof( UInt16);

		products = new body2_SC_CHARGE_ITEMLIST[nCnt];
	
		for( int i = 0; i < nCnt; i++)
		{
			products[i] = new body2_SC_CHARGE_ITEMLIST();
			byte[] tmpData = new byte[body2_SC_CHARGE_ITEMLIST.size];
			Buffer.BlockCopy( data, index, tmpData, 0, tmpData.Length);
			products[i].ByteArrayToClass( tmpData);
			index += body2_SC_CHARGE_ITEMLIST.size;
		}
	}
Example #3
0
	public void RequestProductInfoToPurchaseServer( body2_SC_CHARGE_ITEMLIST[] _chargeItems)
	{
		dicChargeItemInfo.Clear();
		
		List<string> listItemName = new System.Collections.Generic.List<string>();
		
		dicChargeItemInfo = ConvertChargeItemListToDictionary( _chargeItems);
		
		listItemName.AddRange( dicChargeItemInfo.Keys);

		if( purchaseManager != null)
		{
			purchaseManager.RequestProductInfos( listItemName.ToArray());
		}
		else
		{
			#region -test-
#if UNITY_EDITOR
			List<Store_Item_Info_Table> testList = new List<Store_Item_Info_Table>();
			int count = 0;

			foreach (body2_SC_CHARGE_ITEMLIST item in _chargeItems)
				Debug.LogWarning(item.ToString());

			foreach( string id in listItemName)
				testList.Add( new Store_Item_Info_Table( Store_Item_Type.ChargeItem, count++, id, 1));

			ProcessAfterReceiveProductInfo();

			nowState = StoreState.NOTOUCH;
#endif
			#endregion
		}
	}