Exemple #1
0
    protected override void OnStart()
    {
        base.OnStart();
        WareHouseManager.AddWareHouseObjectList(this);
        if (_itemPak == null && PeGameMgr.IsSingleStory)
        {
            _itemPak = DescToItemPack(WareHouseManager.GetWareHouseData(_id).m_itemsDesc);
        }
        else if (_itemPak == null && PeGameMgr.playerType == PeGameMgr.EPlayerType.Tutorial)//这个位置在教程做完之后可能需要改
        {
            _itemPak = DescToItemPack(WareHouseManager.GetWareHouseData(_id).m_itemsDesc);
        }
        else if (/*_itemPak == null && */ PeGameMgr.IsMulti)
        {
            GlobalBehaviour.RegisterEvent(RequestCreate);
        }

        if (null == _itemPak && PeGameMgr.IsSingle)
        {
            _itemPak = new ItemPackage(PakCapacity);
        }
        operateDistance = MaxOperateDistance;
        _entity         = gameObject.GetComponentInParent <PeEntity>();
        if (_entity != null)
        {
            MapObjNetwork net = MapObjNetwork.GetNet(_entity.Id);
            if (net != null)
            {
                net.wareHouseObj = this;
                _id = net.AssetId;
                InitForNet(net);
            }
        }
    }
Exemple #2
0
    /*
     * public static string ItemPackToByteArray(ItemAsset.ItemPackage pak)
     * {
     *  for (int i = 0; i < pak.Length; i++)
     *  {
     *      string[] itemlist = items[i].Split(',');
     *      if (itemlist.Length == 2)
     *      {
     *          int id = Convert.ToInt32(itemlist[0]);
     *          int cnt = Convert.ToInt32(itemlist[1]);
     *          pak.Add(id, cnt);
     *      }
     *  }
     *  return;
     * }
     */


    public void InitForNet(MapObjNetwork net)
    {
        if (_itemPak == null)
        {
            _itemPak = new ItemAsset.ItemPackage(PakCapacity);
        }
        _objNet = net;
    }
Exemple #3
0
 public void ImportData(byte[] data)
 {
     if (PeGameMgr.IsMulti)
     {
         return;
     }
     _itemPak = new ItemAsset.ItemPackage(PakCapacity);
     if (data != null)
     {
         _itemPak.Import(data);
     }
 }
Exemple #4
0
 public static ItemAsset.ItemPackage DescToItemPack(string desc)
 {
     ItemAsset.ItemPackage pak = new ItemAsset.ItemPackage(PakCapacity);
     if (desc != "0")
     {
         string[] items = desc.Split(';');
         for (int i = 0; i < items.Length; i++)
         {
             string[] itemlist = items[i].Split(',');
             if (itemlist.Length == 2)
             {
                 int id  = Convert.ToInt32(itemlist[0]);
                 int cnt = Convert.ToInt32(itemlist[1]);
                 pak.Add(id, cnt);
             }
         }
     }
     return(pak);
 }