Exemplo n.º 1
0
    /// <summary>
    /// 仓库数据
    /// </summary>
    /// <param name="grid"></param>
    /// <param name="index"></param>
    public void OnWareHouseGridDataUpdate(UIGridBase grid, int index)
    {
        KnapsackManager knapMgr  = DataManager.Manager <KnapsackManager>();
        uint            location = ItemDefine.TransformLocal2ServerLocation(m_em_activeWareHouse, new Vector2(0, index));
        BaseItem        itemData = (wareHouseItems.Count > index) ? imgr.GetBaseItemByQwThisId(wareHouseItems[index]) : null;
        UIItemGrid      itemGrid = grid as UIItemGrid;

        itemGrid.EnableCheckBox(false);
        if (null == itemData)
        {
            itemGrid.SetLocation(location);
            //清空
        }
        itemGrid.SetLock(!knapMgr.IsGridUnlock(location));
        itemGrid.SetGridData(UIItemInfoGridBase.InfoGridType.None, itemData);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 获取背包中空列表
    /// </summary>
    /// <param name="pType"></param>
    /// <returns></returns>
    public List <uint> GetEmptyGridInPackage(GameCmd.PACKAGETYPE pType)
    {
        List <uint> emptyGridPosList = new List <uint>();
        int         max            = GetUnlockGridByPackageType(pType);
        List <uint> itemsInPackage = DataManager.Manager <ItemManager>().GetItemDataByPackageType(pType);
        BaseItem    data           = null;
        uint        tempLocation   = 0;

        for (int i = 0; i < max; i++)
        {
            data         = null;
            tempLocation = ItemDefine.TransformLocal2ServerLocation(pType, new UnityEngine.Vector2(0f, i));

            if (null != itemsInPackage && itemsInPackage.Count > 0)
            {
                uint matchId = 0;
                for (int j = 0; j < itemsInPackage.Count; j++)
                {
                    matchId = 0;
                    data    = DataManager.Manager <ItemManager>().GetBaseItemByQwThisId(itemsInPackage[j]);
                    if (null != data && data.ServerLocaltion == tempLocation)
                    {
                        matchId = data.QWThisID;
                        break;
                    }
                }
                if (matchId != 0)
                {
                    itemsInPackage.Remove(matchId);
                    continue;
                }
            }
            emptyGridPosList.Add(tempLocation);
        }
        return(emptyGridPosList);
    }
Exemplo n.º 4
0
    public static ViewPlayerData BuildViewData(uint uid, string name, uint job, int level, uint sex = 0)
    {
        retData          = new ViewPlayerData();
        retData.job      = job;
        retData.sex      = sex;
        retData.userid   = uid;
        retData.username = name;
        table.RobotDataBase data = GameTableManager.Instance.GetTableItem <table.RobotDataBase>(job, level);
        if (data != null)
        {
            retData.power = data.power;

            retData.user_level = data.dwLevel;

            retData.viewRoleData       = new GameCmd.ViewRoleData();
            retData.viewRoleData.maxhp = (uint)(data.hp * 1.15f);
            retData.viewRoleData.maxsp = (uint)(data.mp * 1.15f);

            retData.viewRoleData.pdam_min = (uint)(data.pdam * 0.8f);
            retData.viewRoleData.pdam_max = (uint)(data.pdam * 1.15f);

            retData.viewRoleData.mdam_min = (uint)(data.mdam * 0.8f);
            retData.viewRoleData.mdam_max = (uint)(data.mdam * 1.15f);

            retData.viewRoleData.pdef_min = (uint)(data.mdef * 0.8f);
            retData.viewRoleData.pdef_max = (uint)(data.mdef * 1.15f);

            retData.viewRoleData.liliang      = data.liliang;
            retData.viewRoleData.minjie       = data.minjie;
            retData.viewRoleData.zhili        = data.zhili;
            retData.viewRoleData.tizhi        = data.tizhi;
            retData.viewRoleData.jingshen     = data.jingshen;
            retData.viewRoleData.esdam        = data.esdam;
            retData.viewRoleData.ssdam        = data.ssdam;
            retData.viewRoleData.lsdam        = data.lsdam;
            retData.viewRoleData.vsdam        = data.vsdam;
            retData.viewRoleData.lucky        = data.lucky;
            retData.viewRoleData.mlucky       = data.mlucky;
            retData.viewRoleData.criti_ratio  = data.criti_ratio;
            retData.viewRoleData.cure         = data.cure;
            retData.viewRoleData.phit         = data.phit;
            retData.viewRoleData.hide_per     = data.hide_per;
            retData.viewRoleData.pabs         = data.pabs;
            retData.viewRoleData.mabs         = data.mabs;
            retData.viewRoleData.harm_add_per = data.harm_add_per;
            retData.viewRoleData.harm_sub_per = data.harm_sub_per;

            List <uint> equipList = new List <uint>();

            /*1;    //  头盔
            *  2;    //  护肩
            *  3;    //  上衣
            *  4;    //  护腿
            *  5;    //  戒指
            *  7;    //  盾牌
            *  8;    //  武器
            *  9;    //  鞋子
            *  10;   //  护腕
            *  11;   //  腰带
            *  12;   //  披风
            *  13;   //  项链*/
            equipList.Add(data.Hat);
            equipList.Add(data.Shoulder);
            equipList.Add(data.Coat);
            equipList.Add(data.Leg);
            equipList.Add(data.Adornl_1);
            equipList.Add(data.Adornl_2);
            equipList.Add(data.Shield);
            equipList.Add(data.Equip);
            equipList.Add(data.Shoes);
            equipList.Add(data.Cuff);
            equipList.Add(data.Belf);
            equipList.Add(data.Necklace);

            GameCmd.ItemSerialize item = null;
            for (int i = 0; i < equipList.Count; i++)
            {
                if (equipList[i] == 0)
                {
                    continue;
                }
                table.ItemDataBase itemdb = GameTableManager.Instance.GetTableItem <table.ItemDataBase>(equipList[i]);
                if (itemdb == null)
                {
                    continue;
                }
                //GameCmd.eItemAttribute
                item            = new GameCmd.ItemSerialize();
                item.dwObjectID = equipList[i];

                GameCmd.EquipPos[] pos = EquipDefine.GetEquipPosByEquipType((GameCmd.EquipType)itemdb.subType);
                if (pos.Length == 2)
                {
                    uint loc = 0;
                    if (i == 4)
                    {
                        loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                        {
                            x = 0, y = (int)pos[0]
                        });
                    }
                    else if (i == 5)
                    {
                        loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                        {
                            x = 0, y = (int)pos[1]
                        });
                    }

                    item.pos = new GameCmd.tItemLocation()
                    {
                        loc = loc
                    };
                }
                else if (pos.Length == 1)
                {
                    uint loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                    {
                        x = 0, y = (int)pos[0]
                    });
                    item.pos = new GameCmd.tItemLocation()
                    {
                        loc = loc
                    };
                }
                item.dwNum = 1;
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Bind, value = itemdb.bindMask
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Grade, value = itemdb.grade
                });

                table.EquipDataBase equipdb = GameTableManager.Instance.GetTableItem <table.EquipDataBase>(itemdb.itemID);
                if (equipdb == null)
                {
                    continue;
                }
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Dur, value = equipdb.maxDurable
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_HoleNum, value = 0
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_FightPower, value = equipdb.fightPower
                });

                retData.itemList.Add(item);

                if (equipdb.act_show != 0)
                {
                    table.SuitDataBase suitDb = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(equipdb.act_show, 1);
                    if (suitDb != null)
                    {
                        retData.suit_data.Add(new GameCmd.SuitData()
                        {
                            baseid = suitDb.base_id, suit_type = (GameCmd.EquipSuitType)suitDb.type
                        });
                    }
                }
            }
        }

        return(retData);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 刷新仓库
    /// </summary>
    private void CreateWareHouse()
    {
        if (!(IsInitMode(KnapsackStatus.WareHouse) || IsInitMode(KnapsackStatus.WareHouseNPC)) ||
            null == m_ctor_WareHouseItemGridScrollView)
        {
            return;
        }
        wareHouseItems.Clear();
        List <uint>             wareHouseItemDatas = imgr.GetItemDataByPackageType(m_em_activeWareHouse);
        Dictionary <uint, uint> gridDataDic        = new Dictionary <uint, uint>();
        BaseItem data = null;

        if (null != wareHouseItemDatas && wareHouseItemDatas.Count > 0)
        {
            for (int i = 0; i < wareHouseItemDatas.Count; i++)
            {
                data = imgr.GetBaseItemByQwThisId(wareHouseItemDatas[i]);
                if (null == data || data.Num == 0)
                {
                    continue;
                }
                if (gridDataDic.ContainsKey(data.ServerLocaltion))
                {
                    Engine.Utility.Log.Warning(CLASS_NAME + "->CreateItemDataUI add to temp Dic Faield,Have same key = {0}", data.QWThisID);
                    continue;
                }
                else
                {
                    gridDataDic.Add(data.ServerLocaltion, data.QWThisID);
                }
            }
        }
        //重新构建格子列表
        KnapsackDefine.LocalUnlockInfo wareHouseUnlockInfo
            = m_kmgr.GetUnlockInfoByPackageType(m_em_activeWareHouse);
        if (null == wareHouseUnlockInfo)
        {
            Engine.Utility.Log.Error("CreateWareHouse failed,wareHouseUnlockInfo null");
            m_ctor_WareHouseItemGridScrollView.CreateGrids(0);
            return;
        }
        int mainPackMaxGridHave = m_kmgr.GetMaxGridHaveByPackageType(m_em_activeWareHouse);
        int max     = wareHouseUnlockInfo.UnlockNum;
        int mod     = max % KnapsackManager.KNAPSACK_GRID_COLUMN_MAX;
        int lockNum = ((mod != 0) ? (KnapsackManager.KNAPSACK_GRID_COLUMN_MAX * 2 - mod) : KnapsackManager.KNAPSACK_GRID_COLUMN_MAX);

        lockNum = Math.Min(lockNum, mainPackMaxGridHave - max);
        uint combineLocation = 0;
        int  needNum         = max + lockNum;

        if (needNum < 25)
        {
            needNum = 25;
        }
        for (int i = 0; i < needNum; i++)
        {
            combineLocation = ItemDefine.TransformLocal2ServerLocation(m_em_activeWareHouse, new Vector2(0, i));
            wareHouseItems.Add((gridDataDic.ContainsKey(combineLocation)) ? gridDataDic[combineLocation] : 0);
        }
        //创建格子数据
        m_ctor_WareHouseItemGridScrollView.CreateGrids(wareHouseItems.Count);
        UpdateWareHouseStatus();
        if (m_dic_cacheOldUnlock.ContainsKey(m_em_activeWareHouse))
        {
            m_dic_cacheOldUnlock[m_em_activeWareHouse] = wareHouseUnlockInfo.UnlockNum;
        }
        else
        {
            m_dic_cacheOldUnlock.Add(m_em_activeWareHouse, wareHouseUnlockInfo.UnlockNum);
        }
    }