Esempio n. 1
0
    public string GetText(string paramName)
    {
        string val = "";

        if (ShopSignList != null)
        {
            //val += ShopSignList.ForeachToString(",", tar => { return tar.ShopName; });
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < ShopSignList.Count; i++)
            {
                ShopSignVO ssv = ShopSignList[i];
                if (string.IsNullOrEmpty(ssv.m_strShopShowName))
                {
                    ssv.m_strShopShowName = m_sm.GetShopTypeByCode(ssv.ShopCode);
                }
                if (ssv.m_txtShop == null)
                {
                    m_sm.GetShopTexByCode(ssv.ShopCode, ssv.CellNum, (tx) =>
                    {
                        ssv.m_txtShop = tx;
                    });
                }
                sb.Append(ssv.m_strShopShowName);
                sb.Append(",");
            }
            val = sb.ToString();
        }
        return(val);
    }
Esempio n. 2
0
    /// <summary>创建商铺模型, 并加载招牌/铺面贴图</summary>
    public void CreateShops(bool isForceCreate = true)
    {
        if (!isForceCreate)
        {
            if (_isShopCreated)
            {
                return;
            }
        }
        //Debug.Log("CreateShops");
        DestroyShops();
        Model2ShopSignDic.Clear();
        //Resources.UnloadUnusedAssets();

        if (ShopSignList == null)
        {
            ShopSignList = new List <ShopSignVO>();
        }

        float curCellWidth = 0;

        if (ShopSignList.Count != 0)
        {
            for (int iSS = 0, lenSS = ShopSignList.Count; iSS < lenSS; iSS++)
            {
                ShopSignVO ss = ShopSignList[iSS];

                GameObject shop = m_sm.CreateShopModel(ss.CellNum, ss.PrefabType);

                Model2ShopSignDic.AddRep(shop, ss);

                shop.transform.parent           = transform;
                shop.transform.localEulerAngles = new Vector3(-90, 0, 0);
                shop.transform.localPosition    = new Vector3(-curCellWidth, 0, 0);
                shop.transform.localScale       = new Vector3(1, 1, shopHeight / 3.35f);

                Utils.ForAllChildren(shop, child =>
                {
                    if (child.GetComponent <MeshFilter>() != null)
                    {
                        child.AddComponent <MeshCollider>();
                    }
                });


                curCellWidth += CellWidth * ss.CellNum;
                Material[] matArr  = shop.GetComponentInChildren <Renderer>().materials;
                Material   matShop = matArr.FindItem(mat => { return(mat.name.Contains("mat_context")); });
                Material   matSign = matArr.FindItem(mat => { return(mat.name.Contains("mat_zp")); });

                m_sm.GetSignTexByCode(ss.SignCode, ss.RouteID, tex =>
                {
                    if (this != null && tex != null && matSign != null)
                    {
                        matSign.mainTexture = tex;
                    }
                });
                m_sm.GetShopTexByCode(ss.ShopCode, ss.CellNum, tex =>
                {
                    if (this != null && tex != null && matShop != null)
                    {
                        matShop.mainTexture = tex;
                    }
                });
            }
        }
        else
        {
            //没有商铺的也要创建一间空白的作为占位显示
            ShopSignVO ss = new ShopSignVO(1);
            ss.PrefabType = ShopSignVO.PrefabTypeShopSign;
            GameObject shop = m_sm.CreateShopModel(ss.CellNum, ss.PrefabType);
            Model2ShopSignDic.AddRep(shop, ss);
            shop.transform.parent           = transform;
            shop.transform.localEulerAngles = new Vector3(-90, 0, 0);
            shop.transform.localPosition    = new Vector3(-curCellWidth, 0, 0);
            shop.transform.localScale       = new Vector3(1, 1, shopHeight / 3.35f);

            Utils.ForAllChildren(shop, child =>
            {
                if (child.GetComponent <MeshFilter>() != null)
                {
                    child.AddComponent <MeshCollider>();
                }
            });
            curCellWidth += CellWidth * ss.CellNum;
            Material[] matArr  = shop.GetComponentInChildren <Renderer>().materials;
            Material   matShop = matArr.FindItem(mat => { return(mat.name.Contains("mat_context")); });
            Material   matSign = matArr.FindItem(mat => { return(mat.name.Contains("mat_zp")); });
            matSign.mainTexture = Texture2D.whiteTexture;
            matShop.mainTexture = Texture2D.whiteTexture;
        }

        transform.localScale  = new Vector3(curCellWidth == 0 ? 1 : shopTotalWidth / curCellWidth, 1, 1);
        transform.eulerAngles = Vector3.up.GetScaledVector(Utils.GetRotateY(worldNormal));
        transform.position    = PointList[0] + worldNormal.normalized.GetScaledVector(0.1f);
        transform.parent      = m_sm.ShopModelFolder.transform;
        _isShopCreated        = true;
    }
Esempio n. 3
0
    /// <summary>
    /// 创建招牌列表
    /// </summary>
    /// <param name="_pSss"></param>
    /// <param name="_objPrefab"></param>
    /// <param name="_tfGrid"></param>
    /// <param name="m_nGridHeight"></param>
    /// <returns></returns>
    private IEnumerator RefreshBoardItemList(List <ShopSignVO> _pSss, RefreshType _rType)
    {
        int       nGridHeight = _rType == RefreshType.BoardList ? m_nBoardGrid : m_nSampleBoard;
        Transform tfGrid      = _rType == RefreshType.BoardList ? boardGrid : sampleBoardGrid;

        int nLenth = nGridHeight * _pSss.Count;

        UIPoolManager.Instance.DeSpawnAll(tfGrid);
        //Utils.RemoveChildren(tfGrid);

        if (_rType == RefreshType.SampleBoardList)
        {
            Utils.ResetRectTransform(tfGrid, -1, nLenth);
        }
        else
        {
            Utils.ResetRectTransform(tfGrid, nLenth, -1);
        }
        ToggleGroup tgg = tfGrid.GetComponent <ToggleGroup>();

        Utils.ResetScrollSensitivity(tfGrid.parent, nLenth);

        for (int i = 0; i < _pSss.Count; i++)
        {
            ShopSignVO ssv = _pSss[i];
            //Transform tf = GameObject.Instantiate(m_objSampleBoard).transform;
            Transform tf = UIPoolManager.Instance.OnGetItem(m_strSampleBoardItem);

            Image img_top    = tf.Find("img_top").GetComponent <Image>();
            Image img_center = tf.Find("img_center").GetComponent <Image>();

            Text txt_index      = tf.Find("txt_index").GetComponent <Text>();
            Text txt_shopCode   = tf.Find("txt_shopCode").GetComponent <Text>();
            Text txt_prefabType = tf.Find("txt_prefabType").GetComponent <Text>();
            Text txt_shopId     = tf.Find("txt_shopId").GetComponent <Text>();
            Text txt_cellNum    = tf.Find("txt_cellNum").GetComponent <Text>();

            InputField ipt_shopName = tf.Find("ipt_shopName").GetComponent <InputField>();
            Toggle     tg           = tf.GetComponent <Toggle>();
            tg.group = tgg;
            tg.isOn  = false;
            Button btn_close = tf.Find("btn_close").GetComponent <Button>();
            btn_close.gameObject.SetActive(false);
            if (_rType == RefreshType.BoardList)
            {
                btn_close.gameObject.SetActive(true);
                btn_close.onClick.RemoveAllListeners();
                btn_close.onClick.AddListener(() =>
                {
                    Message msg = new Message(MsgType.ShopView_DeleteBoard, this);
                    msg["data"] = ssv;
                    msg.Send();

                    Debug.LogWarning(string.Format("Delete Board:{0}", ssv.m_strShopShowName));
                });
            }

            ssv.GetTexture("Sign", (tx) => {
                img_top.sprite = Utils.GetSprite(tx);
            });

            ssv.GetTexture("Shop", (tx) =>
            {
                img_center.sprite = Utils.GetSprite(tx);
            });

            ipt_shopName.text = ssv.ShopName;
            if (_rType == RefreshType.SampleBoardList)
            {
                ipt_shopName.enabled      = false;
                ipt_shopName.interactable = false;
                tg.onValueChanged.RemoveAllListeners();
                tg.onValueChanged.AddListener(bGo =>
                {
                    if (bGo)
                    {
                        Message msg = new Message(MsgType.ShopView_SampleBoardClicked, this);
                        msg["data"] = ssv;
                        msg.Send();
                        Debug.Log("Click SampleBoard:" + ssv.GetText("ShopCode"));
                    }
                });
            }
            txt_index.text      = i.ToString();
            txt_shopCode.text   = ssv.GetText("ShopCode");
            txt_prefabType.text = GetPrefabType(ssv.PrefabType);
            txt_shopId.text     = ssv.ShopID;
            txt_cellNum.text    = ssv.CellNum.ToString() + "间";
            tf.SetParent(tfGrid);

            yield return(new WaitForEndOfFrame());
        }
    }