Esempio n. 1
0
    bool OnChargingItemItemCheck(ItemObject item)
    {
        if (!CSUI_MainWndCtrl.IsWorking())
        {
            return(false);
        }

        return(true);
    }
Esempio n. 2
0
    void OnRightMouseClicked(Grid_N grid)
    {
        if (!CSUI_MainWndCtrl.IsWorking())
        {
            return;
        }

        if (!m_IsWorking)
        {
            if (OpStatusEvent != null)
            {
                OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null);
            }
            return;
        }
        if (!GameUI.Instance.mItemPackageCtrl.IsOpen())
        {
            GameUI.Instance.mItemPackageCtrl.Show();
        }

        if (grid.ItemObj == null)
        {
            return;
        }

        //lz-2016.10.26 不允许操作正在操作的东西
        if (EqualUsingItem(grid.Item, false))
        {
            return;
        }

        if (GameConfig.IsMultiMode)
        {
            if (m_storage == null)
            {
                PlayerNetwork.mainPlayer.RequestPersonalStorageFetch(grid.ItemObj.instanceId, -1);
            }
            else
            {
                m_storage._ColonyObj._Network.STO_Fetch(grid.ItemObj.instanceId, -1);
            }
        }
        else
        {
            if (PeCreature.Instance.mainPlayer.GetCmpt <PackageCmpt>().Add(grid.ItemObj))
            {
                GameUI.Instance.mItemPackageCtrl.ResetItem();
                RemoveOriginItem(grid);
            }
            else
            {
                //lz-2016.09.14 提示背包已满
                PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning);
            }
        }
    }
Esempio n. 3
0
 void CheckCantWorkTip()
 {
     //lz-2016.10.24 如果基地可以工作,说明没有超过距离,并且有核心
     if (CSUI_MainWndCtrl.IsWorking())
     {
         if (null != m_CurMenuItem)
         {
             //lz-2016.10.24 贸易站核心等级不足提示
             if (m_CurMenuItem.AssemblyLevelInsufficient)
             {
                 CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkAssemblyLevelInsufficient.GetString(), CSUtils.GetEntityName(m_CurMenuItem.m_Type)), Color.red);
             }
             //lz-2016.10.24 贸易站没电提示
             else if (m_CurMenuItem.NotHaveElectricity)
             {
                 CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_CurMenuItem.m_Type)), Color.red);
             }
         }
     }
 }
Esempio n. 4
0
    void OnPlayerPackageRightClicked(Grid_N grid)
    {
        if (!CSUI_MainWndCtrl.IsWorking(false))
        {
            return;
        }

        if (!m_IsWorking)
        {
            return;
        }

        if (GameConfig.IsMultiMode)
        {
            if (m_storage == null)
            {
                PlayerNetwork.mainPlayer.RequestPersonalStorageStore(grid.ItemObj.instanceId, -1);
            }
            else
            {
                m_storage._ColonyObj._Network.STO_Store(-1, grid.ItemObj);
            }
        }
        else
        {
            if (SetItemWithEmptyGrid(grid.ItemObj))
            {
                //			CSUI_Main.ShowStatusBar("You put the " + grid.Item.mItemData.m_Englishname + " into the storage.");
                if (OpStatusEvent != null)
                {
                    OpStatusEvent(EEventType.PutItemInto, grid.Item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage));
                }
                //			CSUI_Main.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), grid.Item.mItemData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)));
                PeCreature.Instance.mainPlayer.GetCmpt <PackageCmpt>().Remove(grid.ItemObj);
                //GetItemPackage().RemoveItem(grid.ItemObj);
                grid.SetItem(null);
            }
        }
    }
Esempio n. 5
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();
                }
            }
        }
    }
Esempio n. 6
0
    // ---------------------------------
    //  Callback
    // ---------------------------------

    void OnCompoudClick(CSUI_CompoundItem ci)
    {
        if (!GameConfig.IsMultiMode)
        {
            int index = m_CompoudItems.FindIndex(item0 => item0 == ci);
            if (index != -1)
            {
                if (!CSUI_MainWndCtrl.IsWorking())
                {
                    return;
                }

                if (m_Factory.CompoudItemsCount <= index)
                {
                    return;
                }

                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                if (pkg == null)
                {
                    Debug.LogError("CSUI_Factory.OnCompoundClick: pkg is null!");
                    return;
                }

                CompoudItem ci_data = null;
                ItemProto   item_data;
                if (!m_Factory.GetTakeAwayCompoundItem(index, out ci_data))
                {
                    if (ci_data != null)
                    {
                        item_data = ItemProto.GetItemData(ci_data.itemID);
                        CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mIsCompounding.GetString(), item_data.GetName()), Color.red);
                    }
                    return;
                }

                item_data = ItemProto.GetItemData(ci_data.itemID);

                int pacakgeEmptyCount = pkg.package.GetSlotList(ci_data.itemID).vacancyCount;
                if (!pkg.package.CanAdd(m_Factory.Data.m_CompoudItems[index].itemID, ci.Count))
                {
                    // Status bar
                    //lz-2016.07.16 背包空间不足这条提示是基地复制器和玩家复制器通用的,在基地用的时候,基地的提示只能显示一行,不能换行
                    string tip = PELocalization.GetString(8000050).Replace("\\n", " ");
                    CSUI_MainWndCtrl.ShowStatusBar(tip, Color.red);
                    if (item_data.maxStackNum > 1 || pacakgeEmptyCount == 0)
                    {
                        return;
                    }
                }

                int originalCount = ci_data.itemCnt;
                int addCount      = originalCount;
                if (item_data.maxStackNum > 1)
                {
                    pkg.Add(ci_data.itemID, ci_data.itemCnt);
                }
                else
                {
                    if (originalCount > pacakgeEmptyCount)
                    {
                        addCount = pacakgeEmptyCount;
                    }
                    pkg.Add(ci_data.itemID, addCount);
                }

                ci_data.itemCnt = originalCount - addCount;
                if (ci_data.itemCnt == 0)
                {
                    m_Factory.TakeAwayCompoudItem(index);
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayCompoundItem.GetString(), item_data.GetName()));
                }
            }
        }
        else
        {
            int index = m_CompoudItems.FindIndex(item0 => item0 == ci);
            if (index != -1)
            {
                if (m_Factory.CompoudItemsCount <= index ||
                    m_Factory.Data.m_CompoudItems[index] == null ||
                    m_Factory.Data.m_CompoudItems[index].curTime < m_Factory.Data.m_CompoudItems[index].time)
                {
                    return;
                }
                m_Factory._ColonyObj._Network.FCT_Fetch(index);
            }
        }
    }
    /// <summary>
    /// check if this grid can put item in
    /// </summary>
    /// <param name="item">target_item</param>
    /// <param name="check_type">operation_type</param>
    /// <returns></returns>
    bool OnGridCheckItem(ItemObject item, CSUI_Grid.ECheckItemType check_type)
    {
        if (!CSUI_MainWndCtrl.IsWorking())
        {
            return(false);
        }

        if (!m_Entity.IsRunning)
        {
            CSCommon com = m_Entity as CSCommon;
            if (com == null)
            {
                CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_Type)), Color.red);
            }
            else
            {
                if (com.Assembly == null)
                {
                    CSUI_MainWndCtrl.ShowStatusBar("The machine is invalid.", Color.red);
                }
                else
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_Type)), Color.red);
                }
            }

            return(false);
        }

        if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_HotKeyBar)
        {
            return(false);
        }

        if (m_Type == CSConst.etEnhance)
        {
            if ((m_Entity as CSEnhance).IsEnhancing)
            {
                if (m_enhanceItem != null)
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenEnhancingTheItem.GetString(), m_enhanceItem.protoData.GetName()), Color.red);
                }
                return(false);
            }

            if (item != null)
            {
                //if ((item.prototypeData.m_OpType & ItemOperationType.EquipmentItem) == 0
                //    && item.prototypeId < CreationData.s_ObjectStartID)
                //{
                //    return false;
                //}

                Strengthen sItem = item.GetCmpt <Strengthen>();
                if (null != sItem)
                {
                    if (sItem.strengthenTime >= 100)
                    {
                        CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.CANNOT_ENHANCE_MORE), item.protoData.GetName()), Color.red);
                        return(false);
                    }
                }
                else
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.CANNOT_ENHANCE_ITEM), item.protoData.GetName()), Color.red);
                    return(false);
                }
            }
        }
        else if (m_Type == CSConst.etRepair)
        {
            if ((m_Entity as CSRepair).IsRepairingM)
            {
                if (m_repairItem != null)
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenRepairingTheItem.GetString(), m_repairItem.protoData.GetName()), Color.red);
                }
                return(false);
            }

            if (item != null)
            {
                Repair sItem = item.GetCmpt <Repair>();
                if (sItem == null)
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mNotRequireRepair.GetString(), item.protoData.GetName()), Color.red);
                    return(false);
                }
            }
        }
        else if (m_Type == CSConst.etRecyle)
        {
            if ((m_Entity as CSRecycle).IsRecycling)
            {
                if (m_recycleItem != null)
                {
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenRecyclingTheItem.GetString(), m_recycleItem.protoData.GetName()), Color.red);
                }
                return(false);
            }

            if (item != null)
            {
                Recycle sItem = item.GetCmpt <Recycle>();
                //if (item.prototypeId > CreationData.s_ObjectStartID)
                //{
                //    //				return true;
                //}
                //else
                //{
                //    Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(item.prototypeId);
                //    //MergeSkill ms = MergeSkill.s_tblMergeSkills.Find(
                //    //    delegate(MergeSkill hh)
                //    //    {
                //    //        return hh.m_productItemId == item.mItemID;
                //    //    });

                if (sItem == null || sItem.GetRecycleItems() == null)
                {
                    if (sItem != null)
                    {
                        Debug.LogError(item.nameText + " " + item.protoId + " should not have Recycle!");
                    }
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantRecycle.GetString(), item.protoData.GetName()), Color.red);
                    return(false);
                }
                //}
            }
        }

        return(true);
    }
Esempio n. 8
0
    void OnLeftMouseClicked(Grid_N grid)
    {
        if (!CSUI_MainWndCtrl.IsWorking())
        {
            return;
        }

        if (!m_IsWorking)
        {
            if (OpStatusEvent != null)
            {
                OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null);
            }
            return;
        }

        if (grid.Item == null)
        {
            return;
        }

        //lz-2016.10.26 不允许操作正在操作的东西
        if (EqualUsingItem(grid.Item, false))
        {
            return;
        }

        switch (m_OpType)
        {
        case 0:

            SelectItem_N.Instance.SetItemGrid(grid);
            break;

        case 1:
        {
            if (grid.Item.GetCount() > 1)
            {
                int mark = -1;
                if (!GameConfig.IsMultiMode)
                {
                    mark = m_Package.GetVacancySlotIndex(0);
                }
                else
                {
                    mark = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>().package.GetVacancySlotIndex(0);
                }

                if (-1 == mark)
                {
                    MessageBox_N.ShowOkBox(PELocalization.GetString(8000102));
                }
                else if (m_OpGird == null)
                {
                    m_SplitWnd.SetActive(true);
                    m_OpGird          = grid;
                    m_SplitNumDur     = 1;
                    m_SplitNumLb.text = "1";
                }
            }
        } break;

        case 2:
        {
            if (Input.GetMouseButtonDown(0))
            {
                m_OpGird = grid;

                //wan
                //				mOpBagID = grid.ItemIndex;
                if (m_OpGird.Item.protoId / 10000000 == 9)
                {
                    MessageBox_N.ShowOkBox(PELocalization.GetString(8000054));
                }
                else
                {
                    MessageBox_N.ShowYNBox(PELocalization.GetString(8000055), OnDeleteItem);
                }
            }
        }
        break;

        default:
            break;
        }
    }
Esempio n. 9
0
    void OnDropItem(Grid_N grid)
    {
        //lz-2016.11.16 当前包裹数据为空的时候直接返回
        if (CSUI_MainWndCtrl.Instance == null || grid == null || null == m_CurPack)
        {
            return;
        }

        if (!CSUI_MainWndCtrl.IsWorking())
        {
            return;
        }


        if (!m_IsWorking)
        {
            if (OpStatusEvent != null)
            {
                OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null);
            }
            return;
        }

        if (null == SelectItem_N.Instance.ItemObj || SelectItem_N.Instance.Place == ItemPlaceType.IPT_HotKeyBar)
        {
            SelectItem_N.Instance.SetItem(null);
            return;
        }

        if (grid.ItemObj == null)
        {
            switch (SelectItem_N.Instance.Place)
            {
            default:

                if (GameConfig.IsMultiMode)
                {
                    if (SelectItem_N.Instance.GridMask != GridMask.GM_Mission)
                    {
                        if (m_storage == null)
                        {
                            if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_Bag)
                            {
                                PlayerNetwork.mainPlayer.RequestPersonalStorageStore(SelectItem_N.Instance.ItemObj.instanceId, grid.ItemIndex);
                            }
                            else if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_NPCStorage)
                            {
                                PlayerNetwork.mainPlayer.RequestPersonalStorageExchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex);
                            }
                        }
                        else
                        {
                            if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_Bag)
                            {
                                m_storage._ColonyObj._Network.STO_Store(grid.ItemIndex, SelectItem_N.Instance.ItemObj);
                            }
                            else if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_CSStorage)
                            {
                                m_storage._ColonyObj._Network.STO_Exchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex);
                            }

                            return;
                        }
                        if (OpStatusEvent != null)
                        {
                            OpStatusEvent(EEventType.PutItemInto, SelectItem_N.Instance.ItemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage));
                        }
                    }
                }
                else
                {
                    if (SelectItem_N.Instance.GridMask != GridMask.GM_Mission)
                    {
                        SelectItem_N.Instance.RemoveOriginItem();
                        grid.SetItem(SelectItem_N.Instance.ItemObj);
                        m_CurPack[grid.ItemIndex] = SelectItem_N.Instance.ItemObj;
                        if (OpStatusEvent != null)
                        {
                            OpStatusEvent(EEventType.PutItemInto, SelectItem_N.Instance.ItemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage));
                        }
                    }
                }


                SelectItem_N.Instance.SetItem(null);
                break;
            }
        }
        else
        {
            if (GameConfig.IsMultiMode)
            {
                if (m_storage == null)
                {
                    if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_NPCStorage)
                    {
                        PlayerNetwork.mainPlayer.RequestPersonalStorageExchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex);
                    }
                }
                else
                {
                    if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_CSStorage)
                    {
                        m_storage._ColonyObj._Network.STO_Exchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex);
                    }

                    return;
                }
            }
            else
            {
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();

                ItemObject dragItem = SelectItem_N.Instance.ItemObj;
                ItemObject dropItem = grid.ItemObj;

                ItemPackage.ESlotType dropType = ItemPackage.GetSlotType(dropItem.protoId);
                ItemPackage.ESlotType dragType = ItemPackage.GetSlotType(dragItem.protoId);

                //lz-2016.10.18 如果拖动的Item和放置的Item是同一类型,就直接交换ItemObj数据
                if (dropType == dragType && null != SelectItem_N.Instance.Grid)
                {
                    if (SelectItem_N.Instance.Grid.onGridsExchangeItem != null)
                    {
                        SelectItem_N.Instance.Grid.onGridsExchangeItem(SelectItem_N.Instance.Grid, dropItem);
                        grid.SetItem(dragItem);
                        m_CurPack[grid.ItemIndex] = grid.ItemObj;
                        SelectItem_N.Instance.SetItem(null);
                    }
                }
                //lz-2016.10.18 如果不是同一类型,或者没有Grid,就先添加,后移除
                else if (pkg.package.CanAdd(dropItem))
                {
                    pkg.package.AddItem(dropItem);
                    grid.SetItem(dragItem);
                    SelectItem_N.Instance.RemoveOriginItem();
                    SelectItem_N.Instance.SetItem(null);
                }
            }
        }
    }