Ejemplo n.º 1
0
    private void InitCropsItemGridUI(CropsTableItem item)
    {
        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (null == module)
        {
            return;
        }
        CropsItemGridUI grid = null;
        GameObject      sp   = null;

        if (!mItemGrid.ContainsKey(item.id))
        {
            sp = WindowManager.Instance.CloneGameObject(mCropsItemPrefab2);
            if (sp == null)
            {
                GameDebug.LogError("mCropsItemPrefab2 prefab not found");
                return;
            }

            sp.name = item.id.ToString();
            sp.SetActive(true);
            grid = new CropsItemGridUI(sp);
            if (null == grid)
            {
                return;
            }
            grid.SetCropsId(item.id);
            grid.SetIcon(item.cropsheadpic);
            grid.SetName(item.name);
            grid.SetSelect(false);
            grid.SetStarslv(module.GetCropsStarsLv(item.id));
            grid.SetState(module.GetCropsState(item.id));
            if (module.HasObtainCrops(item.id))
            {
                grid.SetUnlockCrops();
            }
            grid.onClick            = SetCurSelectCropsStarsUI;
            sp.transform.parent     = mRiseGrid.transform;
            sp.transform.localScale = Vector3.one;
            mRiseGrid.Reposition();
            mItemGrid.Add(item.id, grid);
            if (null == mOldSelectedofStarsUI || item.id < mOldSelectedofStarsUI.GetCropsId())
            {
                mOldSelectedofStarsUI = grid;
            }
        }
        else
        {
            grid = mItemGrid[item.id];
            if (module.HasObtainCrops(item.id))
            {
                grid.SetUnlockCrops();
            }
            grid.SetStarslv(module.GetCropsStarsLv(item.id));
            grid.SetState(module.GetCropsState(item.id));
        }
    }
Ejemplo n.º 2
0
    private void SetCurSelectCropsStarsUI(CropsItemGridUI target)
    {
        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (null == module)
        {
            return;
        }
        if (null == target)
        {
            return;
        }
        if (null != mOldSelectedofStarsUI)
        {
            mOldSelectedofStarsUI.SetSelect(false);
        }

        mOldSelectedofStarsUI = target;
        mOldSelectedofStarsUI.SetSelect(true);


        CropsTableItem item = DataManager.CropsTable[target.GetCropsId()] as CropsTableItem;

        if (null == item)
        {
            return;
        }
        foreach (Transform trans in mItemObj.transform)
        {
            trans.gameObject.SetActive(false);
            GameObject.Destroy(trans.gameObject);
        }
        int starslv = module.GetCropsStarsLv(target.GetCropsId());

        starslv = starslv == -1 ? 1 : starslv;
        if (starslv != STARSMAX)
        {
            if (mStage2.activeSelf)
            {
                mStage2.SetActive(false);
            }
            CommonItemUI ui = new CommonItemUI(item.itemid);
            ui.gameObject.transform.parent        = mItemObj.transform;
            ui.gameObject.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
            ui.gameObject.transform.localScale    = Vector3.one;

            mItemNameAndNum.text = ItemManager.Instance.getItemName(item.itemid) + "X" + item[starslv + 1];
            mHasItemNum.text     = "已有:" + module.GetItemNumByID(item.itemid);
            mPerItem.SetActive(true);

            SetNowStarsLvProperty(target.GetCropsId(), starslv);
            SetNextStarsLvProperty(target.GetCropsId(), starslv + 1);

            InitSkillPanel(target.GetCropsId(), starslv);
        }
        else
        {
            //升星到最高等级,中间显示卡片属性
            SetMaxStarsLvProperty(target.GetCropsId(), starslv);
            mBtnRiseStars.gameObject.SetActive(false);
            mStage0.SetActive(false);
            mStage1.SetActive(false);
            mSkillPanel.SetActive(false);
            mArrowPanel.SetActive(false);
            mPerItem.SetActive(false);
        }
        if (!module.HasObtainCrops(target.GetCropsId()))
        {
            mBtnRiseStars.gameObject.SetActive(false);
        }
    }