Пример #1
0
    bool HandleNewGoods(Tab_YuanBaoShop tabYuanBaoShop, int nPageItemIndex, int nPriorityIndex, bool bNextPage)
    {
        if (nPageItemIndex >= ItemCount_PerPage || nPageItemIndex < 0)
        {
            return(false);
        }

        m_GoodsArray[nPageItemIndex].Init(tabYuanBaoShop);
        if (bNextPage)
        {
            if (nPageItemIndex == 0)
            {
                m_TabPageInfo.PageStartID = nPriorityIndex;
            }
            m_TabPageInfo.PageEndID = nPriorityIndex;
        }
        else
        {
            if (nPageItemIndex == ItemCount_PerPage - 1)
            {
                m_TabPageInfo.PageEndID = nPriorityIndex;
            }
            m_TabPageInfo.PageStartID = nPriorityIndex;
        }

        return(true);
    }
Пример #2
0
    bool IsTabNewGoods(Tab_YuanBaoShop tabYuanBaoShop)
    {
        if (tabYuanBaoShop.TabIndex != (int)m_CurTabIndex)
        {
            return(false);
        }

        if (false == IsGoodsOnSell(tabYuanBaoShop))
        {
            return(false);
        }

        if (m_CurTabIndex == TAB_INDEX.TAB_VIP)
        {
            if (tabYuanBaoShop.ItemType != (int)YuanBaoShopItemLogic.ITEM_TYPE.TYPE_ITEM)
            {
                return(false);
            }

            Tab_VIPShop tabVIPShop = TableManager.GetVIPShopByID(tabYuanBaoShop.ItemID, 0);
            if (tabVIPShop == null)
            {
                return(false);
            }

            int nPlayerVIPLevel = VipData.GetVipLv();

            if (nPlayerVIPLevel < tabVIPShop.ShowLevelReq)
            {
                return(false);
            }
        }

        return(true);
    }
Пример #3
0
    bool IsGoodsOnSell(Tab_YuanBaoShop tabYuanBaoShop)
    {
        if (tabYuanBaoShop.SellTimeStart == GlobeVar.INVALID_ID ||
            tabYuanBaoShop.SellTimeEnd == GlobeVar.INVALID_ID)
        {
            return(true);
        }

        DateTime DateTimeSellStart = new DateTime(
            tabYuanBaoShop.SellTimeStart / 100000000 % 100 + 2000,
            tabYuanBaoShop.SellTimeStart / 1000000 % 100,
            tabYuanBaoShop.SellTimeStart / 10000 % 100,
            tabYuanBaoShop.SellTimeStart / 100 % 100,
            tabYuanBaoShop.SellTimeStart / 1 % 100,
            0);
        DateTime DateTimeSellEnd = new DateTime(
            tabYuanBaoShop.SellTimeEnd / 100000000 % 100 + 2000,
            tabYuanBaoShop.SellTimeEnd / 1000000 % 100,
            tabYuanBaoShop.SellTimeEnd / 10000 % 100,
            tabYuanBaoShop.SellTimeEnd / 100 % 100,
            tabYuanBaoShop.SellTimeEnd / 1 % 100,
            0);

        DateTime DateTimeNow = Utils.GetServerDateTime();

        return(DateTimeSellStart <= DateTimeNow && DateTimeNow < DateTimeSellEnd);
    }
Пример #4
0
    public void Init(int goodsid, int count, PresentRootLogic.TAB_INDEX tab, int index = GlobeVar.INVALID_ID)
    {
        m_GoodsID    = goodsid;
        m_GoodsCount = count;
        m_Type       = tab;
        m_GoodsIndex = index;

        Tab_YuanBaoShop tabGood = TableManager.GetYuanBaoShopByID(goodsid, 0);

        if (tabGood != null && tabGood.ItemType == (int)YuanBaoShopItemLogic.ITEM_TYPE.TYPE_ITEM)
        {
            int            itemid  = tabGood.ItemID;
            Tab_CommonItem tabItem = TableManager.GetCommonItemByID(itemid, 0);
            if (tabItem != null)
            {
                m_ItemSlot.InitInfo_Item(tabItem.Id, GoodsOnClick, tabGood.Num.ToString(), true);
                m_CountLabel.text = count.ToString();
                m_DeleteButton.SetActive(true);
                m_NameLabel.text = tabItem.Name;
            }
        }

        if (tab == PresentRootLogic.TAB_INDEX.TAB_SHOPPINGCART)
        {
            m_DeleteButton.SetActive(true);
        }
        else
        {
            m_DeleteButton.SetActive(false);
        }
    }
Пример #5
0
    public void Init(Tab_YuanBaoShop tabYuanBaoShop)
    {
        m_GoodsId      = tabYuanBaoShop.Id;
        m_eItemType    = (ITEM_TYPE)tabYuanBaoShop.ItemType;
        m_ItemID       = tabYuanBaoShop.ItemID;
        m_Num          = tabYuanBaoShop.Num;
        m_PriceWeek    = tabYuanBaoShop.PriceWeek;
        m_SaleWeek     = tabYuanBaoShop.SaleWeek;
        m_PriceMonth   = tabYuanBaoShop.PriceMonth;
        m_SaleMonth    = tabYuanBaoShop.SaleMonth;
        m_PriceForever = tabYuanBaoShop.PriceForever;
        m_SaleForever  = tabYuanBaoShop.SaleForever;

        m_ItemSlot.InitInfo(ConvertGoodsTypeToSlotType(m_eItemType), m_ItemID, GoodsOnClick);
        m_NumContent.text = m_Num.ToString();
        SetNameLabel();
        SetPriceLabel();
    }
Пример #6
0
    void LoadAllGoodsDicPriority()
    {
        if (m_ListPriority.Count > 0)
        {
            return;
        }

        for (int i = 0; i < TableManager.GetYuanBaoShop().Count; i++)
        {
            Tab_YuanBaoShop tabYuanBaoShop = TableManager.GetYuanBaoShopByID(i, 0);
            if (tabYuanBaoShop == null)
            {
                continue;
            }

            m_ListPriority.Add(new PriorityInfo((short)i, (short)tabYuanBaoShop.ShowPriority));
        }

        m_ListPriority.Sort(new PriorityInfoCompare());
    }
        public int GetCostYuanBao()
        {
            int cost = 0;

            for (int i = 0; i < m_GoodsID.Length && i < m_GoodsCount.Length; i++)
            {
                if (m_GoodsID[i] == GlobeVar.INVALID_ID || m_GoodsCount[i] == GlobeVar.INVALID_ID)
                {
                    break;
                }

                Tab_YuanBaoShop tabGood = TableManager.GetYuanBaoShopByID(m_GoodsID[i], 0);
                if (tabGood == null)
                {
                    break;
                }

                cost += tabGood.PriceForever * tabGood.Num * m_GoodsCount[i];
            }
            return(cost);
        }
Пример #8
0
    void ShowPrePage()
    {
        if (m_TabPageInfo.CurPage <= 1)
        {
            return;
        }

        int start = m_TabPageInfo.PageStartID;

        m_TabPageInfo.PageStartID = GlobeVar.INVALID_ID;
        m_TabPageInfo.PageEndID   = GlobeVar.INVALID_ID;

        int nPageItemIndex = ItemCount_PerPage - 1;

        for (int i = start - 1; i >= 0; i--)
        {
            Tab_YuanBaoShop tabYuanBaoShop = TableManager.GetYuanBaoShopByID(m_ListPriority[i].GoodsId, 0);
            if (tabYuanBaoShop == null)
            {
                continue;
            }

            if (IsTabNewGoods(tabYuanBaoShop))
            {
                if (HandleNewGoods(tabYuanBaoShop, nPageItemIndex, i, false))
                {
                    nPageItemIndex -= 1;
                }
                if (nPageItemIndex < 0)
                {
                    break;
                }
            }
        }

        // 上一页必然所有item都显示
        UpdateGoodsActive(ItemCount_PerPage);
        m_TabPageInfo.CurPage -= 1;
        m_PageLabel.text       = m_TabPageInfo.CurPage.ToString() + "/" + m_TabPageInfo.PageCount.ToString();
    }
Пример #9
0
    void ShowNextPage()
    {
        if (m_TabPageInfo.CurPage >= m_TabPageInfo.PageCount)
        {
            return;
        }

        int end = m_TabPageInfo.PageEndID;

        m_TabPageInfo.PageStartID = GlobeVar.INVALID_ID;
        m_TabPageInfo.PageEndID   = GlobeVar.INVALID_ID;

        int nPageItemIndex = 0;

        for (int i = end + 1; i < m_ListPriority.Count; i++)
        {
            Tab_YuanBaoShop tabYuanBaoShop = TableManager.GetYuanBaoShopByID(m_ListPriority[i].GoodsId, 0);
            if (tabYuanBaoShop == null)
            {
                continue;
            }

            if (IsTabNewGoods(tabYuanBaoShop))
            {
                if (HandleNewGoods(tabYuanBaoShop, nPageItemIndex, i, true))
                {
                    nPageItemIndex += 1;
                }
                if (nPageItemIndex >= ItemCount_PerPage)
                {
                    break;
                }
            }
        }

        UpdateGoodsActive(nPageItemIndex);

        m_TabPageInfo.CurPage += 1;
        m_PageLabel.text       = m_TabPageInfo.CurPage.ToString() + "/" + m_TabPageInfo.PageCount.ToString();
    }
Пример #10
0
        public int GetCostYuanBao()
        {
            int cost = 0;

            for (int i = 0; i < m_GoodsInfo.Count; i++)
            {
                if (m_GoodsInfo[i].GoodsId == GlobeVar.INVALID_ID || m_GoodsInfo[i].GoodsCount == GlobeVar.INVALID_ID)
                {
                    break;
                }

                Tab_YuanBaoShop tabGood = TableManager.GetYuanBaoShopByID(m_GoodsInfo[i].GoodsId, 0);
                if (tabGood == null)
                {
                    break;
                }

                cost += tabGood.PriceForever * m_GoodsInfo[i].GoodsCount;
            }

            return(cost);
        }
Пример #11
0
    void UpdatePresentButton(int nGoodsId)
    {
        Tab_YuanBaoShop tabGood = TableManager.GetYuanBaoShopByID(nGoodsId, 0);

        if (tabGood != null)
        {
            if (tabGood.IsCanPresent == 1 && GameManager.gameManager.PlayerDataPool.IsServerFlagOpen(SERVER_FLAGS_ENUM.FLAG_PRESENT))
            {
                m_PresentButton.SetActive(true);
                m_ButtonGrid.transform.localPosition           = new Vector3(-135, -100, 0);
                m_ButtonGrid.GetComponent <UIGrid>().cellWidth = 160;
                m_ButtonGrid.GetComponent <UIGrid>().Reposition();
            }
            else
            {
                m_PresentButton.SetActive(false);
                m_ButtonGrid.transform.localPosition           = new Vector3(-75, -100, 0);
                m_ButtonGrid.GetComponent <UIGrid>().cellWidth = 200;
                m_ButtonGrid.GetComponent <UIGrid>().Reposition();
            }
        }
    }
Пример #12
0
        public bool IsCanAdd(int goodsid, int count)
        {
            Tab_YuanBaoShop tabGoods = TableManager.GetYuanBaoShopByID(goodsid, 0);

            if (tabGoods == null || tabGoods.ItemType != (int)YuanBaoShopItemLogic.ITEM_TYPE.TYPE_ITEM)
            {
                return(false);
            }

            if (tabGoods.Num < 0)
            {
                return(false);
            }

            Tab_CommonItem tabItem = TableManager.GetCommonItemByID(tabGoods.ItemID, 0);

            if (tabItem == null)
            {
                return(false);
            }

            if (count * tabGoods.Num > tabItem.MaxStorageCount)
            {
                return(false);
            }

            int nNeedSlot = GlobeVar.INVALID_ID;

            bool bAdd         = false;
            int  nRemainCount = count;

            for (int i = 0; i < m_GoodsInfo.Count; i++)
            {
                if (nRemainCount == 0)
                {
                    break;
                }

                if (m_GoodsInfo[i].GoodsId == goodsid)
                {
                    if (tabGoods.Num * (m_GoodsInfo[i].GoodsCount + count) <= tabItem.MaxStackSize)
                    {
                        nRemainCount -= count;
                        nNeedSlot     = 0;
                    }
                    else
                    {
                        int preAdd = tabItem.MaxStackSize / tabGoods.Num - m_GoodsInfo[i].GoodsCount;
                        nRemainCount -= preAdd;
                    }
                    bAdd = true;
                }
            }

            if (false == bAdd || nRemainCount > 0)
            {
                nNeedSlot = (int)Math.Ceiling((float)nRemainCount / (float)(tabItem.MaxStackSize / tabGoods.Num));
            }
            nRemainCount = 0;

            return(nNeedSlot != GlobeVar.INVALID_ID &&
                   nNeedSlot <= GlobeVar.SHOPPINGLIST_GOODSMAX - m_GoodsInfo.Count);
        }
Пример #13
0
        public void AddGoods(int goodsid, int count)
        {
            if (goodsid == GlobeVar.INVALID_ID)
            {
                return;
            }

            if (false == IsCanAdd(goodsid, count))
            {
                return;
            }

            Tab_YuanBaoShop tabGoods = TableManager.GetYuanBaoShopByID(goodsid, 0);

            if (tabGoods == null || tabGoods.ItemType != (int)YuanBaoShopItemLogic.ITEM_TYPE.TYPE_ITEM)
            {
                return;
            }

            if (tabGoods.Num < 0)
            {
                return;
            }

            Tab_CommonItem tabItem = TableManager.GetCommonItemByID(tabGoods.ItemID, 0);

            if (tabItem == null)
            {
                return;
            }

            if (false == IsInCountDown())
            {
                m_CreateTime = GlobalData.ServerAnsiTime;
            }

            bool bAdd         = false;
            int  nRemainCount = count;

            for (int i = 0; i < m_GoodsInfo.Count; i++)
            {
                if (nRemainCount == 0)
                {
                    break;
                }

                if (m_GoodsInfo[i].GoodsId == goodsid)
                {
                    if (tabGoods.Num * (m_GoodsInfo[i].GoodsCount + count) <= tabItem.MaxStackSize)
                    {
                        int precount = m_GoodsInfo[i].GoodsCount;
                        m_GoodsInfo[i].Init(goodsid, precount + count);
                        nRemainCount -= count;
                    }
                    else
                    {
                        int precount = m_GoodsInfo[i].GoodsCount;
                        int preAdd   = tabItem.MaxStackSize / tabGoods.Num - precount;
                        m_GoodsInfo[i].Init(goodsid, precount + preAdd);
                        nRemainCount -= preAdd;
                    }
                    bAdd = true;
                }
            }

            if (false == bAdd || nRemainCount > 0)
            {
                for (int i = 0; i < GlobeVar.SHOPPINGLIST_GOODSMAX; i++)
                {
                    if (nRemainCount > tabItem.MaxStackSize / tabGoods.Num)
                    {
                        m_GoodsInfo.Add(new ShoppingCartItem(goodsid, tabItem.MaxStackSize / tabGoods.Num));
                        nRemainCount -= tabItem.MaxStackSize / tabGoods.Num;
                    }
                    else
                    {
                        m_GoodsInfo.Add(new ShoppingCartItem(goodsid, nRemainCount));
                        break;
                    }
                }
            }
            nRemainCount = 0;

            WriteShoppingCartInfo();
        }
Пример #14
0
    void UpdateGoodsInfo(TAB_INDEX eTabIndex)
    {
        m_TabPageInfo.Clear();
        m_CurTabIndex = eTabIndex;

        if (eTabIndex == TAB_INDEX.TAB_VIP)
        {
            if (Singleton <ObjManager> .Instance.MainPlayer != null)
            {
                int nPlayerVIPLevel = VipData.GetVipLv();
                if (nPlayerVIPLevel < 9)
                {
                    m_GoodsGrid.SetActive(false);
                    m_Pages.SetActive(false);
                    m_VIPLabel.SetActive(true);
                    return;
                }
                else
                {
                    m_GoodsGrid.SetActive(true);
                    m_Pages.SetActive(true);
                    m_VIPLabel.SetActive(false);
                }
            }
        }
        else
        {
            m_GoodsGrid.SetActive(true);
            m_Pages.SetActive(true);
            m_VIPLabel.SetActive(false);
        }

        int nTabItemCount  = 0;
        int nPageItemIndex = 0;

        for (int i = 0; i < m_ListPriority.Count; i++)
        {
            Tab_YuanBaoShop tabYuanBaoShop = TableManager.GetYuanBaoShopByID(m_ListPriority[i].GoodsId, 0);
            if (tabYuanBaoShop == null)
            {
                continue;
            }

            if (IsTabNewGoods(tabYuanBaoShop))
            {
                nTabItemCount += 1;
                if (HandleNewGoods(tabYuanBaoShop, nPageItemIndex, i, true))
                {
                    nPageItemIndex += 1;
                }
            }
        }

        UpdateGoodsActive(nPageItemIndex);

        m_TabPageInfo.PageCount = Mathf.CeilToInt((float)nTabItemCount / (float)ItemCount_PerPage);
        if (m_TabPageInfo.PageCount <= 0)
        {
            m_TabPageInfo.CurPage = 0;
        }
        else
        {
            m_TabPageInfo.CurPage = 1;
        }
        m_PageLabel.text = m_TabPageInfo.CurPage.ToString() + "/" + m_TabPageInfo.PageCount.ToString();
    }