コード例 #1
0
    void Awake()
    {
        // Create Worked material Grids
        for (int i = 0; i < 1; i++)
        {
            CSUI_MaterialGrid mg = Instantiate(m_Work.m_MatGridPrefab) as CSUI_MaterialGrid;
            mg.transform.parent        = m_Work.m_Root.transform;
            mg.transform.localPosition = Vector3.zero;
            mg.transform.localRotation = Quaternion.identity;
            mg.transform.localScale    = Vector3.one;

            mg.ItemID = 0;
            m_MatGrids.Add(mg);
        }

        for (int i = 0; i < 8; i++)
        {
            CSUI_CommonIcon ci = Instantiate(m_CommonIcoPrefab) as CSUI_CommonIcon;
            ci.transform.parent        = mIcoGrid.transform;
            ci.transform.localPosition = Vector3.zero;
            ci.transform.localRotation = Quaternion.identity;
            ci.transform.localScale    = Vector3.one;
            ci.e_OnClickIco           += OnClickIcoItem;
            ci.gameObject.SetActive(true);

            mUIPPCoalIcoList.Add(ci);
        }
        mIcoGrid.repositionNow = true;
    }
コード例 #2
0
    // Storage Menu
    void UpdateStorageMenu()
    {
        if (m_StorageMenuObjs == null)
        {
            return;
        }

        for (int i = 0; i < 8; i++)
        {
            CSUI_CommonIcon commonIcon = m_StorageMenuObjs[i].GetComponent <CSUI_CommonIcon>();
            if (i < m_Storages.Count)
            {
                m_StorageMenuObjs[i].SetActive(true);
                UIEventListener listener = UIEventListener.Get(m_StorageMenuObjs[i]);
                listener.onClick = OnStorageMenuSelect;
                bool ischecked = m_StorageMenuObjs[i].GetComponent <UICheckbox>().isChecked;
                if (ischecked)
                {
                    OnStorageMenuSelect(m_StorageMenuObjs[i]);
                }
                commonIcon.Common = m_Storages[i] as CSCommon;
            }
            else
            {
                m_StorageMenuObjs[i].SetActive(false);
                commonIcon.Common = null;
            }
        }

        m_StorageMenu.m_Root.repositionNow = true;
    }
コード例 #3
0
    public void SetEntityList(List <CSEntity> entityList, CSEntity selectEntity)
    {
        //lz-2016.10.13 错误 #4045 空对象
        if (null == entityList || null == mUIPPCoalIcoList)
        {
            return;
        }

        for (int i = 0; i < mUIPPCoalIcoList.Count; i++)
        {
            if (i < entityList.Count)
            {
                mUIPPCoalIcoList[i].gameObject.SetActive(true);
                mUIPPCoalIcoList[i].Common = entityList[i] as CSCommon;
            }
            else
            {
                mUIPPCoalIcoList[i].gameObject.SetActive(false);
                mUIPPCoalIcoList[i].Common = null;
            }
        }

        CSEntity curSelectEntity = null;

        //lz-2016.09.13 需要选中的
        if (null != selectEntity)
        {
            curSelectEntity = selectEntity;
        }
        //lz-2016.09.13 上次选中的
        else if (null != m_Entity)
        {
            curSelectEntity = m_Entity;
        }

        //lz - 2016.09.13 上面两个不满足就选第一个
        if (null == curSelectEntity || !entityList.Contains(curSelectEntity))
        {
            curSelectEntity = entityList[0];
        }

        CSUI_CommonIcon icon = mUIPPCoalIcoList.Find(a => a.Common == selectEntity);

        if (null != icon)
        {
            SetEntity(curSelectEntity);
            icon.mCheckBox.isChecked = true;
        }

        mIcoGrid.repositionNow = true;
    }
コード例 #4
0
    public void Replace(List <CSEntity> commons, CSEntity selectEntity)
    {
        List <CSCommon> commons_list = new List <CSCommon>();

        if (m_Enhance != null)
        {
            commons_list.Add(m_Enhance);
        }
        if (m_Repair != null)
        {
            commons_list.Add(m_Repair);
        }
        if (m_Recycle != null)
        {
            commons_list.Add(m_Recycle);
        }

        bool replace = false;

        if (commons.Count != commons_list.Count)
        {
            replace = true;
        }
        else
        {
            for (int i = 0; i < commons.Count; i++)
            {
                if (!commons_list.Contains(commons[i] as CSCommon))
                {
                    replace = true;
                    break;
                }
            }
        }

        if (replace)
        {
            if (m_Enhance != null)
            {
                m_MenuPart.m_EnhanceCB.gameObject.SetActive(false);
                m_Enhance.onEnhancedTimeUp = null;
                m_Enhance = null;
            }

            if (m_Repair != null)
            {
                m_MenuPart.m_RepairCB.gameObject.SetActive(false);
                m_Repair.onRepairedTimeUp = null;
                m_Repair = null;
            }

            if (m_Recycle != null)
            {
                m_MenuPart.m_RecyleCB.gameObject.SetActive(false);
                m_Recycle = null;
            }

            foreach (CSCommon csc in commons)
            {
                AddMachine(csc);
            }

            CSUI_CommonIcon Icon = m_MenuPart.m_EnhanceCB.gameObject.GetComponent <CSUI_CommonIcon>();
            Icon.Common = m_Enhance as CSCommon;

            Icon        = m_MenuPart.m_RepairCB.gameObject.GetComponent <CSUI_CommonIcon>();
            Icon.Common = m_Repair as CSCommon;

            Icon        = m_MenuPart.m_RecyleCB.gameObject.GetComponent <CSUI_CommonIcon>();
            Icon.Common = m_Recycle as CSCommon;
        }

        if (null == selectEntity)
        {
            if (m_Enhance != null)
            {
                m_CurType = CSConst.etEnhance;
            }
            else if (m_Recycle != null)
            {
                m_CurType = CSConst.etRecyle;
            }
            else if (m_Repair != null)
            {
                m_CurType = CSConst.etRepair;
            }
        }
        else
        {
            //lz-2016.10.17 从那个Entity打开就选中哪个
            if (m_Enhance != null && selectEntity == m_Enhance)
            {
                m_CurType = CSConst.etEnhance;
            }
            else if (m_Recycle != null && selectEntity == m_Recycle)
            {
                m_CurType = CSConst.etRecyle;
            }
            else if (m_Repair != null && selectEntity == m_Repair)
            {
                m_CurType = CSConst.etRepair;
            }
        }
        SelectByType();
    }