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)); } }
private void InitCropsShopGridUI(CropsTableItem item) { PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>(); if (null == module) { return; } CropsShopGridUI grid = null; GameObject sp = null; if (!mShopCrid.ContainsKey(item.id)) { sp = WindowManager.Instance.CloneGameObject(mCropsItemPrefab1); if (sp == null) { GameDebug.LogError("mCropsItemPrefab1 prefab not found"); return; } sp.SetActive(true); sp.name = item.id.ToString(); grid = new CropsShopGridUI(sp); if (null == grid) { return; } grid.SetCropsId(item.id); grid.SetIcon(item.picname, item.picname2); 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(); } else { grid.SetProgress((int)module.GetItemNumByID(item.itemid), item.itemnum); } grid.onClick = SetCurSelectCrops; sp.transform.parent = mCampGrid.transform; sp.transform.localScale = Vector3.one; mCampGrid.Reposition(); mShopCrid.Add(item.id, grid); if (null == mOldSelected || item.id < mOldSelected.GetCropsId()) { mOldSelected = grid; } } else { grid = mShopCrid[item.id]; grid.SetStarslv(module.GetCropsStarsLv(item.id)); grid.SetState(module.GetCropsState(item.id)); if (!module.HasObtainCrops(item.id)) { grid.SetProgress((int)module.GetItemNumByID(item.itemid), item.itemnum); } else { grid.SetUnlockCrops(); } } }