コード例 #1
0
    public Dictionary <int, int> GetRecycleItems()
    {
        if (m_Item == null)
        {
            return(null);
        }

        Dictionary <int, int> recycleItems = new Dictionary <int, int>();

        //lz-2016.06.16 直接foreach可能会返回null的数据会报空对象
        MaterialItem[] materialItemArray = m_Item.GetRecycleItems();
        if (materialItemArray != null && materialItemArray.Length > 0)
        {
            for (int i = 0; i < materialItemArray.Length; i++)
            {
                recycleItems[materialItemArray[i].protoId] = materialItemArray[i].count * m_Item.itemObj.stackCount;
            }
        }
        //float factor = m_Item.GetPriceFactor();

        //// Creation System
        //if (m_Item.prototypeId >= CreationData.s_ObjectStartID)
        //{
        //    foreach (KeyValuePair<int, int> kvp in m_Item.GetRecycleItems();)
        //        recycleItems[kvp.Key] = Mathf.CeilToInt( kvp.Value * factor );
        //}
        //else
        //{
        //    Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_Item.prototypeId);
        //    //MergeSkill ms = MergeSkill.s_tblMergeSkills.Find( item0 => item0.m_productItemId == m_Item.mItemID);
        //    List<Pathea.Replicator.Formula.Material> m_maxNumberList = ms.materials;
        //    foreach (Pathea.Replicator.Formula.Material msmi in m_maxNumberList)
        //        recycleItems[msmi.itemId] =  Mathf.CeilToInt (msmi.itemCount * factor);
        //}

        return(recycleItems);
    }
コード例 #2
0
    /// <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);
    }