Exemple #1
0
        public void UpdateShortCut(ItemObject itemObj)
        {
            if (null == mPkg)
            {
                return;
            }
            bool updateCount = itemObj.protoData.maxStackNum > 1;            //grenade == 60

            if (!updateCount)
            {
                return;
            }
            for (int i = 0; i < mShortCutItems.Length; i++)
            {
                ShortCutItem item = mShortCutItems[i];
                if (null == item)
                {
                    continue;
                }
                if (item.protoId == itemObj.protoId)
                {
                    if (60 == item.protoId)
                    {
                        item.SetStackCount(itemObj.GetCount());
                    }
                    else
                    {
                        item.SetStackCount(mPkg.GetCount(item.protoId));
                    }
                    return;
                }
            }
        }
Exemple #2
0
    public void RemoveRepurchase(ItemObject itemObj, int count)
    {
        if (itemObj.GetCount() < count)
        {
            Debug.LogError("Remove num is big than item you have.");
            return;
        }

        if (itemObj.GetCount() > count)
        {
            itemObj.DecreaseStackCount(count);
        }
        else
        {
            mRepurchaseList.Remove(itemObj);
        }
    }
Exemple #3
0
 public void RemoveBuyItem(ItemObject itemObj, int count)
 {
     if (itemObj.stackCount < count)
     {
         Debug.LogError("Remove num is big than item you have.");
     }
     else if (itemObj.GetCount() > count)
     {
         itemObj.DecreaseStackCount(count);
     }
     else
     {
         mBuyItemList.Remove(itemObj);
     }
 }
Exemple #4
0
        public void UpdateShortCut()
        {
            if (null == mPkg)
            {
                return;
            }

            for (int i = 0; i < mShortCutItems.Length; i++)
            {
                ShortCutItem item = mShortCutItems[i];

                if (null == item || null == item.protoData)
                {
                    continue;
                }

                bool useProtoID = item.protoData.maxStackNum > 1 && 60 != item.protoId;                 //grenade == 60

                if (useProtoID)
                {
                    int itemCount = mPkg.GetCount(item.protoId);
                    if (itemCount == 0)
                    {
                        PutItem(null, i, false);
                    }
                    else
                    {
                        item.SetStackCount(itemCount);
                    }
                }
                else
                {
                    ItemObject itemObj = ItemMgr.Instance.Get(item.itemInstanceId);
                    if (null == itemObj)
                    {
                        PutItem(null, i, false);
                        continue;
                    }
                    if (itemObj.protoData.maxStackNum > 1)
                    {
                        item.SetStackCount(itemObj.GetCount());
                    }

                    CheckEquipInPackage(item, i);
                }
            }
            SendUpdateMsg();
        }
            public static bool DestroyItem(this ItemPackage package, ItemObject item, int count)
            {
                if (count <= 0)
                {
                    return(false);
                }

                if (item.GetCount() < count)
                {
                    return(false);
                }

                SlotList accessor = package.GetSlotList(ItemPackage.GetSlotType(item.protoId));

                return(accessor.DestroyItem(item.instanceId, count));
            }
Exemple #6
0
    private FarmPlantLogic _plant(ItemObject io, Vector3 pos, int index)
    {
        //PlantInfo info = PlantInfo.GetPlantInfoByItemId(io.protoId);
//		Vector3 new_pos = new Vector3(pos.x, pos.y, pos.z)
        DragArticleAgent dragItem = DragArticleAgent.PutItemByProroId(io.protoId, pos, Quaternion.identity);

        //FarmManager.Instance.CreatePlant(dragItem.itemInstanceId, info.mTypeID, pos);
        io.DecreaseStackCount(1);
        if (io.GetCount() <= 0)
        {
            ItemMgr.Instance.DestroyItem(io.instanceId);

            SetPlantSeed(index, null);
        }

        // Event
        ExcuteEvent(CSConst.eetFarm_OnPlant, index);
        return(dragItem.itemLogic as FarmPlantLogic);
    }
Exemple #7
0
    private void OnRightMouseCliked(Grid_N grid)
    {
        if (grid.ItemObj == null)
        {
            return;
        }

        if (mSellOpLayer.gameObject.activeSelf)
        {
            return;
        }

        if (grid.ItemObj.GetCount() == 0)
        {
            new PeTipMsg(PELocalization.GetString(82209007), PeTipMsg.EMsgLevel.Warning);
            return;
        }

        SelectItem_N.Instance.SetItem(null);

        m_CurOpItem = grid.ItemObj;

        //lz-2016.10.27 购买所有的时候提示加上购买所有的价格
        int count = m_CurOpItem.GetCount();
        int price = 0;

        if (m_CurPackTab == 0)
        {
            price = Mathf.RoundToInt(m_CurOpItem.GetBuyPrice() * (1 + ColonyConst.TRADE_POST_CHARGE_RATE));
        }
        else
        {
            price = m_CurOpItem.GetSellPrice(); //赎回的价格等于卖出的价格
        }
        string name   = m_CurOpItem.protoData.GetName();
        string msgStr = string.Format("{0} {1}\n{2} {3}", PELocalization.GetString(8000077), name + " X " + count, PELocalization.GetString(8000253), (count * price));

        MessageBox_N.ShowYNBox(msgStr, BuyAll, ResetOpInfo);
    }
Exemple #8
0
    public void SellItem(int instanceId, int count)
    {
        ItemObject itemObj = ItemAsset.ItemMgr.Instance.Get(instanceId);

        if (itemObj == null)
        {
            Debug.LogError("Sell item is null");
            return;
        }

        if (count > itemObj.GetCount())
        {
            Debug.LogError("not enough count");
            return;
        }

        PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

        if (null == pkg)
        {
            return;
        }

        int protoId = itemObj.protoId;
        int cost    = itemObj.GetSellPrice() * count;

        if (colonyMoney < cost)
        {
            //lz-2016.10.31 The TradePost has no money to pay for you!
            new PeTipMsg(PELocalization.GetString(8000858), PeTipMsg.EMsgLevel.Error);
            return;
        }


        if (PeGameMgr.IsMulti)
        {
            _ColonyObj._Network.RPCServer(EPacketType.PT_CL_TRD_SellItem, instanceId, count);
            return;
        }
        else
        {
            colonyMoney -= cost;
            ItemObject SellItemObj;
            if (count == itemObj.stackCount)
            {
                SellItemObj = itemObj;
                pkg.Remove(itemObj);
            }
            else
            {
                SellItemObj = ItemMgr.Instance.CreateItem(protoId);
                SellItemObj.SetStackCount(count);
                pkg.DestroyItem(instanceId, count);
            }

            AddRepurchase(SellItemObj);
            pkg.money.current += cost;            //Add money to player
        }

        //--to do: updateUI
        UpdateRepurchaseDataToUI();
    }
Exemple #9
0
    public bool Buy(ItemObject itemObj, int count, ShopData data, bool isRepurchase)
    {
        int price;

        if (!isRepurchase)
        {
            price = Mathf.RoundToInt(data.m_Price * (1 + ColonyConst.TRADE_POST_CHARGE_RATE));
        }
        else
        {
            price = itemObj.GetSellPrice();
        }
        int cost = price * count;

        if (PlayerMoney.current < cost)
        {
            PeTipMsg.Register(PELocalization.GetString(Money.Digital? 8000092:8000073), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        ItemObject        addItem = null;
        PlayerPackageCmpt pkg     = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

        if (null == pkg)
        {
            PeTipMsg.Register(PELocalization.GetString(8000496), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        if (!pkg.package.CanAdd(itemObj.protoId, count))
        {
            PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        if (itemObj.protoData.maxStackNum == 1)
        {
            int NUM = count;
            for (int i = 0; i < NUM; i++)
            {
                count = 1;
                if (count < itemObj.GetCount())
                {
                    addItem = ItemMgr.Instance.CreateItem(itemObj.protoId);                     // single
                    addItem.SetStackCount(count);
                }
                else
                {
                    addItem = itemObj;
                    if (!isRepurchase)
                    {
                        mShopList[data.m_ID].ItemObjID = -1;
                    }
                }
                pkg.package.AddItem(addItem, !isRepurchase);
            }
            PlayerMoney.current -= cost;

            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }
        else
        {
            if (count == itemObj.GetCount())
            {
                if (!isRepurchase)
                {
                    mShopList[data.m_ID].ItemObjID = -1;
                }
            }
            pkg.package.Add(itemObj.protoId, count, !isRepurchase);
            PlayerMoney.current -= cost;
            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }

        return(true);
    }
Exemple #10
0
    void Update()
    {
        if (null != m_CurMenuItem)
        {
            //lz-2016.10.24 增加没在范围内不可以操作
            m_NewUseState = !(m_CurMenuItem.AssemblyLevelInsufficient || m_CurMenuItem.NotHaveAssembly || m_CurMenuItem.NotHaveElectricity || !CSUI_MainWndCtrl.IsWorking(false));
            if (m_NewUseState != m_CanUseThis)
            {
                m_CanUseThis = m_NewUseState;
                ShowMeshGo(!m_CanUseThis);
            }
        }

        if (null != m_CurOpItem)
        {
            if (mAddBtnPress)
            {
                float dT = Time.time - m_OpStarTime;
                if (dT < 0.2f)
                {
                    m_OpDurNum = 1;
                }
                else if (dT < 1f)
                {
                    m_OpDurNum += 2 * Time.deltaTime;
                }
                else if (dT < 2f)
                {
                    m_OpDurNum += 4 * Time.deltaTime;
                }
                else if (dT < 3f)
                {
                    m_OpDurNum += 7 * Time.deltaTime;
                }
                else if (dT < 4f)
                {
                    m_OpDurNum += 11 * Time.deltaTime;
                }
                else if (dT < 5f)
                {
                    m_OpDurNum += 16 * Time.deltaTime;
                }
                else
                {
                    m_OpDurNum += 20 * Time.deltaTime;
                }

                m_OpDurNum        = Mathf.Clamp(m_OpDurNum + m_CurrentNum, 1, m_CurOpItem.GetCount()) - m_CurrentNum;
                m_InputOpNum.text = ((int)(m_OpDurNum + m_CurrentNum)).ToString();
                m_LbTotal.text    = (m_CurPrice * (int)(m_OpDurNum + m_CurrentNum)).ToString();
            }
            else if (mSubBtnPress)
            {
                float dT = Time.time - m_OpStarTime;
                if (dT < 0.5f)
                {
                    m_OpDurNum = -1;
                }
                else if (dT < 1f)
                {
                    m_OpDurNum -= 2 * Time.deltaTime;
                }
                else if (dT < 2f)
                {
                    m_OpDurNum -= 4 * Time.deltaTime;
                }
                else if (dT < 3f)
                {
                    m_OpDurNum -= 7 * Time.deltaTime;
                }
                else if (dT < 4f)
                {
                    m_OpDurNum -= 11 * Time.deltaTime;
                }
                else if (dT < 5f)
                {
                    m_OpDurNum -= 16 * Time.deltaTime;
                }
                else
                {
                    m_OpDurNum -= 20 * Time.deltaTime;
                }

                m_OpDurNum        = Mathf.Clamp(m_OpDurNum + m_CurrentNum, 1, m_CurOpItem.GetCount()) - m_CurrentNum;
                m_InputOpNum.text = ((int)(m_OpDurNum + m_CurrentNum)).ToString();
                m_LbTotal.text    = (m_CurPrice * (int)(m_OpDurNum + m_CurrentNum)).ToString();
            }
            else
            {
                if ("" == m_InputOpNum.text)
                {
                    m_CurrentNum = 1;
                }
                else
                {
                    m_CurrentNum = Mathf.Clamp(System.Convert.ToInt32(m_InputOpNum.text), 1, m_CurOpItem.GetCount());
                }
                if (!UICamera.inputHasFocus)
                {
                    m_InputOpNum.text = m_CurrentNum.ToString();
                    m_LbTotal.text    = (m_CurPrice * (int)m_CurrentNum).ToString();
                }
            }
        }
    }