/// <summary> /// 船坞item选中 /// </summary> /// <param name="groupIndex"></param> /// <param name="cellIndex"></param> /// <param name="cellData"></param> /// <param name="cellView"></param> /// <param name="selected"></param> protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { IShip ship = (IShip)cellData; Animator m_Animator = cellView.GetComponent <Animator>(); if (m_Animator) { m_Animator.SetBool("IsOn", selected); } ShipHangarItem m_ShipHangarItem = cellView.GetOrAddComponent <ShipHangarItem>(); UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Row) { m_ShipHangarItem.SetData(ship, true); } else { m_ShipHangarItem.SetData(ship, false); } if (selected) { m_Ship = ship; State.SetTipData(null); State.SetTipData(cellData); State.GetAction(UIAction.Hangar_Assemble).Enabled = true; State.GetAction(UIAction.Hangar_Appoint).Enabled = ship.GetUID() != m_ShipProxy.GetAppointWarShip().GetUID(); m_ShipHangarItem.RecordItemNew(); } }
protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); Animator animator = cellView.GetComponent <Animator>(); RectTransform content = FindComponent <RectTransform>(cellView, "Content"); if (animator) { animator.SetBool("IsOn", selected); } int page = groupIndex; int index = cellIndex; ProduceInfoVO infoVO = (ProduceInfoVO)cellData; cellView.name = infoVO.TID.ToString(); ProduceElelment m_ProduceElelmentNew = cellView.GetComponent <ProduceElelment>(); if (m_ProduceElelmentNew == null) { m_ProduceElelmentNew = cellView.gameObject.AddComponent <ProduceElelment>(); m_ProduceElelmentNew.Initialize(); } m_ProduceElelmentNew.SetData(infoVO, m_CurrentType, style); infoVO.Elelment = m_ProduceElelmentNew; }
/// <summary> /// 当前布局样式改变时 /// </summary> /// <param name="pageIndex">页索引</param> /// <param name="oldStyle">变化前的布局样式</param> /// <param name="newStyle">变化后的布局样式</param> private void OnLayoutStyleChanged(int pageIndex, UIViewListLayout oldStyle, UIViewListLayout newStyle) { if (pageIndex == State.GetPageIndex()) { LoadListTemplate(false); if (State.GetPageLayoutStyle(State.GetPageIndex()) == UIViewListLayout.Grid) { if (m_ScrollerAnimator) { m_ScrollerAnimator.SetBool("IsSimple", true); m_ScrollerAnimator.SetBool("IsCompare", State.IsCompareMode()); } State.GetAction(UIAction.Common_Grid_List).State = 1; } else { if (m_ScrollerAnimator) { m_ScrollerAnimator.SetBool("IsSimple", false); m_ScrollerAnimator.SetBool("IsCompare", State.IsCompareMode()); } State.GetAction(UIAction.Common_Grid_List).State = 0; } } }
/// <summary> /// 设置布局样式 /// </summary> /// <param name="index">页面索引</param> /// <param name="style">布局样式</param> public void SetPageLayoutStyle(int index, UIViewListLayout newValue) { UIViewListLayout oldValue = GetPage(index).ListLayoutMode; if (oldValue != newValue) { GetPage(index).ListLayoutMode = newValue; OnLayoutStyleChanged?.Invoke(index, oldValue, newValue); } }
protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); Animator animator = cellView.GetComponent <Animator>(); RectTransform content = FindComponent <RectTransform>(cellView, "Content"); if (animator) { animator.SetBool("IsOn", selected); } int page = groupIndex; int index = cellIndex; ulong infoVOId = 0; SocialElement m_SocialElement = cellView.GetComponent <SocialElement>(); if (m_SocialElement == null) { m_SocialElement = cellView.gameObject.AddComponent <SocialElement>(); m_SocialElement.Initialize(); } switch (m_SocialType) { case SocialType.Team: TeamMemberVO teamMemberVO = cellData as TeamMemberVO; m_SocialElement.SetTeamData(teamMemberVO, m_SocialType, new Vector2Int(groupIndex, cellIndex)); infoVOId = teamMemberVO.UID; break; case SocialType.Friend: FriendInfoVO friendInfoVO = cellData as FriendInfoVO; m_SocialElement.SetFriendData(friendInfoVO, m_SocialType); infoVOId = friendInfoVO.UID; break; case SocialType.Ship: FriendInfoVO Ship = cellData as FriendInfoVO; m_SocialElement.SetFriendData(Ship, m_SocialType); infoVOId = Ship.UID; break; case SocialType.Other: FriendInfoVO Other = cellData as FriendInfoVO; m_SocialElement.SetFriendData(Other, m_SocialType); infoVOId = Other.UID; break; default: break; } }
/// <summary> /// 填充数据 /// </summary> public void SetData(ProduceInfoVO infoVO, ProduceType produceType, UIViewListLayout style = UIViewListLayout.Row) { if (infoVO.TID > 0) { m_Style = style; m_TID = infoVO.TID; m_ProduceType = produceType; m_CurrentItem = m_FoundryProxy.GetItemByProduceKey(m_TID); m_CurrentProduce = m_FoundryProxy.GetProduceByKey(m_TID); m_ProduceInfoVO = infoVO; RefreshData(infoVO.Progress, infoVO.BluePrintState); SetContent(); } }
protected override string GetCellTemplate() { UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Row) { return(AssetAddressKey.PRELOADUIELEMENT_SHIPHANGARELEMENT_LIST); } else if (style == UIViewListLayout.Grid) { return(AssetAddressKey.PRELOADUIELEMENT_SHIPHANGARELEMENT_GRID); } return(null); }
protected override string GetCellTemplate() { int pageIndex = State.GetPageIndex(); UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Row) { return(AssetAddressKey.PRELOADUIELEMENT_SOCIALELEMENT); } else if (style == UIViewListLayout.Grid) { return(AssetAddressKey.PRELOADUIELEMENT_SOCIALELEMENT); } return(null); }
protected override string GetCellTemplate() { UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Row) { if (State.GetPageIndex() == 1) { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPSELLELEMENT_LIST); } else if (State.GetPageIndex() == 0) { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPBUYELEMENT_LIST); } else { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPBUYBACKELEMENT_LIST); } } else if (style == UIViewListLayout.Grid) { if (State.GetPageIndex() == 1) { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPSELLELEMENT_GRID); } else if (State.GetPageIndex() == 0) { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPBUYELEMENT_GRID); } else { return(AssetAddressKey.PRELOADUIELEMENT_NPCSHOPBUYBACKELEMENT_GRID); } } return(null); }
protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { Animator m_Animator = cellView.GetComponent <Animator>(); if (m_Animator) { m_Animator.SetBool("IsOn", selected); } UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (State.GetPageIndex() == 0) { ShopWindowVO m_ShopWindowVO = (ShopWindowVO)cellData; NpcShopElementGrid m_ShopElementGrid = cellView.GetOrAddComponent <NpcShopElementGrid>(); if (style == UIViewListLayout.Grid) { m_ShopElementGrid.SetData(m_ShopWindowVO, selected, false); } else { m_ShopElementGrid.SetData(m_ShopWindowVO, selected, true); } CountDownCompent m_CountDownCompent = cellView.GetOrAddComponent <CountDownCompent>(); m_CountDownCompent.SetTime(m_ShopWindowVO.RefreshTime); if (selected) { if (m_ShopWindowVO.IsOpen == 0 || m_ShopWindowVO.ServerLeftNum == 0 || !m_ShopElementGrid.MoneyeEnough() || m_ShopWindowVO.LimitCount == 0 || m_ShopWindowVO.LimitCount < m_ShopWindowVO.ShopItemConfig.Value.Bounds && m_ShopWindowVO.LimitCount > 0) { State.GetAction(UIAction.Shop_Buy).Enabled = false; } else { State.GetAction(UIAction.Shop_Buy).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 0; m_OpenShopParameter.Tid = m_ShopWindowVO.Tid; m_OpenShopParameter.Id = m_ShopWindowVO.Oid; m_OpenShopParameter.MoneyType = m_ShopWindowVO.ShopItemConfig.Value.MoneyType; m_OpenShopParameter.Price = m_ShopWindowVO.ShopItemConfig.Value.BuyCost * m_ShopWindowVO.ShopItemConfig.Value.DisCount; m_OpenShopParameter.LimitCount = (int)m_ShopWindowVO.LimitCount; m_OpenShopParameter.Stock = (int)m_ShopWindowVO.ServerLeftNum; m_OpenShopParameter.Bounds = m_ShopWindowVO.ShopItemConfig.Value.Bounds; m_OpenShopParameter.Category = ItemTypeUtil.GetItemType(m_ShopWindowVO.ShopItemConfig.Value.ItemGood.Value.Type).MainType; } } else if (State.GetPageIndex() == 1) { ItemBase m_PackageItem = (ItemBase)cellData; NpcShopSellElementGrid m_SellElementGrid = cellView.GetOrAddComponent <NpcShopSellElementGrid>(); if (style == UIViewListLayout.Grid) { m_SellElementGrid.SetData(m_PackageItem, selected, false); } else { m_SellElementGrid.SetData(m_PackageItem, selected, true); } if (selected) { if (m_PackageItem.Replicas != null && m_PackageItem.Replicas.Count > 0) { State.GetAction(UIAction.Shop_Sell).Enabled = false; } else if (m_PackageItem.MainType == Category.Expendable) { State.GetAction(UIAction.Shop_Sell).Enabled = false; } else { State.GetAction(UIAction.Shop_Sell).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 1; m_OpenShopParameter.Tid = m_PackageItem.TID; m_OpenShopParameter.Id = m_PackageItem.UID; if (m_PackageItem.ItemConfig.SellCurrency == 1100004) { m_OpenShopParameter.MoneyType = 1; } else { m_OpenShopParameter.MoneyType = 2; } m_OpenShopParameter.Price = (int)m_PackageItem.ItemConfig.MoneyPrice; m_OpenShopParameter.LimitCount = (int)m_PackageItem.Count; m_OpenShopParameter.Stock = (int)m_PackageItem.Count; m_OpenShopParameter.Bounds = 1; m_OpenShopParameter.Category = m_PackageItem.MainType; } } else { ShopSellBackVO m_SellBack = (ShopSellBackVO)cellData; CountDownCompent m_CountDownCompent = cellView.GetOrAddComponent <CountDownCompent>(); m_CountDownCompent.SetTime(m_SellBack.ExpireTime); NpcShopSellBackElementGrid m_SellElementGrid = cellView.GetOrAddComponent <NpcShopSellBackElementGrid>(); if (style == UIViewListLayout.Grid) { m_SellElementGrid.SetData(m_SellBack, false); } else { m_SellElementGrid.SetData(m_SellBack, true); } if (selected) { if (!m_SellElementGrid.MoneyeEnough()) { State.GetAction(UIAction.Shop_Buy).Enabled = false; } else { State.GetAction(UIAction.Shop_Buy).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 2; m_OpenShopParameter.Tid = (uint)m_SellBack.Tid; m_OpenShopParameter.Id = m_SellBack.Uid; if (m_SellBack.ItemConfig.SellCurrency == 1100004) { m_OpenShopParameter.MoneyType = 1; } else { m_OpenShopParameter.MoneyType = 2; } m_OpenShopParameter.Price = m_SellBack.ItemConfig.BuybackPrice; m_OpenShopParameter.LimitCount = (int)m_SellBack.Num; m_OpenShopParameter.Stock = (int)m_SellBack.Num; m_OpenShopParameter.Bounds = 1; m_OpenShopParameter.Category = ItemTypeUtil.GetItemType(m_SellBack.ItemConfig.Type).MainType; } } }
/// <summary> /// 普通单元格渲染时 /// </summary> /// <param name="groupIndex"></param> /// <param name="cellIndex"></param> /// <param name="cellData"></param> /// <param name="cellView"></param> /// <param name="selected"></param> protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { Animator animator = cellView.GetComponent <Animator>(); Image quality = cellView.Find("Content/Image_Quality").GetComponent <Image>(); Image icon1 = cellView.Find("Content/Image_Icon").GetComponent <Image>(); Image icon2 = cellView.Find("Content/Image_Icon2").GetComponent <Image>(); TMP_Text nameLabel = cellView.Find("Content/Mask/Label_Name").GetComponent <TMP_Text>(); TMP_Text typeLabel = cellView.Find("Content/Mask/Label_WeaponLabel").GetComponent <TMP_Text>(); Image currentUsedIcon = cellView.Find("Content/Image_Icon_E").GetComponent <Image>(); Image otherUsedIcon = cellView.Find("Content/Image_Icon_E1").GetComponent <Image>(); TMP_Text lv = cellView.Find("Content/Level/Label_Lv2").GetComponent <TMP_Text>(); ItemBase item = cellData as ItemBase; quality.color = ColorUtil.GetColorByItemQuality(item.ItemConfig.Quality); UIViewListLayout style = Parent.State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Grid) { UIUtil.SetIconImageSquare(icon1, item.ItemConfig.Icon); UIUtil.SetIconImageSquare(icon2, item.ItemConfig.Icon); } else { UIUtil.SetIconImage(icon1, item.ItemConfig.Icon); UIUtil.SetIconImage(icon2, item.ItemConfig.Icon); } sb.Clear(); nameLabel.text = TableUtil.GetItemName(item.TID); int zeroCount = 3 - item.Lv.ToString().Length; if (zeroCount > 0) { sb.Append("<color=#808080>"); do { sb.Append(0); } while (--zeroCount > 0); sb.Append("</color>"); } sb.Append(item.Lv); lv.text = sb.ToString(); switch (item) { case ItemWeaponVO val: typeLabel.text = TableUtil.GetLanguageString(val.WeaponType2); break; case ItemReformerVO val: typeLabel.text = TableUtil.GetLanguageString(val.MainType); break; case ItemEquipmentVO val: typeLabel.text = TableUtil.GetLanguageString(val.EquipmentType); break; case ItemModVO val: typeLabel.text = TableUtil.GetLanguageString(val.ModType1) + " " + TableUtil.GetLanguageString(val.ModType2); break; } currentUsedIcon.gameObject.SetActive(m_CurrentItemData?.GetReference() == item.UID); otherUsedIcon.gameObject.SetActive(false); if (!currentUsedIcon.gameObject.activeSelf) { if (item.Replicas.Count > 0) { for (int i = 0; i < item.Replicas.Count; i++) { if (Parent.Data.CurrentShip.GetItem(item.Replicas[i]) != null) { otherUsedIcon.gameObject.SetActive(true); break; } } } } animator?.SetBool("IsOn", selected); if (selected) { OnItemSelected(item); m_CurrentSelectedItemData = item; } }