Beispiel #1
0
 /// <summary>
 /// 更新物品在背包中的位置
 /// </summary>
 /// <param name="loc"></param>
 public void UpdateServerLocation(uint loc)
 {
     ServerData.pos.loc = loc;
     location           = ItemDefine.TransformServerLocation2Local(loc);
     UpdateLocation();
     OnUpdateLocation(loc);
 }
    /// <summary>
    /// 仓库格子点击实现
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="data"></param>
    /// <param name="param"></param>
    public void OnWareHouseGridUIEvent(UIEventType eventType, object data, object param)
    {
        switch (eventType)
        {
        case UIEventType.Click:
        {
            if (data is UIItemGrid)
            {
                UIItemGrid grid = data as UIItemGrid;
                if (!grid.Empty)
                {
                    DataManager.Manager <KnapsackManager>().MoveItems(grid.Data.QWThisID, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN);
                }
                else if (grid.IsLock)
                {
                    KnapsackDefine.LocalUnlockInfo unlcokInfo
                        = m_kmgr.GetUnlockInfoByPackageType(m_em_activeWareHouse);
                    int unlockNum = ((int)ItemDefine.TransformServerLocation2Local(grid.Location).Position.y + 1) - unlcokInfo.UnlockNum;
                    if (unlockNum == 0)
                    {
                        Engine.Utility.Log.Warning(CLASS_NAME + "-> unlock grid failed,num = {0} data error!", unlockNum);
                        return;
                    }
                    //解锁格子
                    DoUnlocKnapsackGrid(unlockNum, m_em_activeWareHouse);
                }
            }
            else if (data is UITabGrid)
            {
                UITabGrid tabGrid = data as UITabGrid;
                KnapsackDefine.LocalUnlockInfo localInfo
                    = m_kmgr.GetUnlockInfoByPackageType((GameCmd.PACKAGETYPE)tabGrid.Data);
                if (null != localInfo && localInfo.IsUnlock)
                {
                    SetWareHousePackage((GameCmd.PACKAGETYPE)tabGrid.Data);
                }
                else
                {
                    TipsManager.Instance.ShowTips("购买皇令解锁仓库");
                }
            }
        }
        break;

        case UIEventType.LongPress:
        {
            if (data is UIItemGrid)
            {
                UIItemGrid grid = data as UIItemGrid;
                if (!grid.Empty)
                {
                    imgr.OnUIItemGridClicked(grid.Data.QWThisID);
                }
            }
        }
        break;
        }
    }
Beispiel #3
0
 private bool Equip(List <GameCmd.ItemSerialize> itemList, int pos, out GameCmd.ItemSerialize item)
 {
     item = null;
     for (int i = 0, imax = itemList.Count; i < imax; i++)
     {
         ItemDefine.ItemLocation local = ItemDefine.TransformServerLocation2Local(itemList[i].pos.loc);
         if (local != null && local.Position.y == pos)
         {
             item = itemList[i];
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
    /// <summary>
    /// 当前背包位置是否已经解锁
    /// </summary>
    /// <param name="location">服务端中背包位置</param>
    /// <returns></returns>
    public bool IsGridUnlock(uint location)
    {
        ItemDefine.ItemLocation itemLocation = ItemDefine.TransformServerLocation2Local(location);
        if (null == itemLocation ||
            !(itemLocation.PackType == PACKAGETYPE.PACKAGETYPE_MAIN ||
              IsWareHosue(itemLocation.PackType)))
        {
            //不是背包,仓库忽略
            return(false);
        }

        KnapsackDefine.LocalUnlockInfo localUnlockInfo = GetUnlockInfoByPackageType(itemLocation.PackType);
        if (null == localUnlockInfo)
        {
            Engine.Utility.Log.Error("GetUnlockInfoByPackageType null ,packtype = {0}", itemLocation.PackType);
            return(false);
        }
        int  packUnlockGrid = localUnlockInfo.UnlockNum;
        uint maxLocation    = ItemDefine.TransformLocal2ServerLocation(itemLocation.PackType, new UnityEngine.Vector2(0f, Math.Max(packUnlockGrid - 1, 0)));

        return((maxLocation >= location && packUnlockGrid != 0) ? true : false);
    }