public void ModifyDragArea(UIDragScrollView ds) { UIWidget uw = ds.GetComponent <UIWidget>(); if (!uw) { uw = ds.gameObject.AddComponent <UIWidget>(); } uw.depth = -100; uw.width = 2; uw.height = 2; BoxCollider bx = ds.GetComponent <BoxCollider>(); if (!bx) { bx = ds.gameObject.AddComponent <BoxCollider>(); } if (!m_panel) { InitPosAndScroll(); } Vector3 size = bx.size; size.x = m_panel.width; size.y = m_panel.height; bx.size = size; m_scrollViewDrag = ds; FixBoxPostion(); }
private void FixBoxPostion() { BoxCollider bx = m_scrollViewDrag.GetComponent <BoxCollider>(); if (!bx) { return; } Vector3 center = m_panel.baseClipRegion; center.z = 0; Vector3 offset = m_panel.clipOffset; center = center + offset; m_scrollViewDrag.transform.localPosition = center; }
private void FixBoxPostion() { BoxCollider bx = m_drag.GetComponent <BoxCollider>(); if (!bx) { return; } Vector3 center = m_panel.baseClipRegion; center.z = 0; Vector3 offset = m_panel.clipOffset; center = center + offset; center.x = center.x - m_halfPanelWidth + cellWidth * 0.5f; center.y = center.y + m_halfPanelHeight - cellHeight * 0.5f; m_drag.transform.localPosition = center; }
//更新购买魔法石界面 void UpDateMagicStoneShopUI() { int index = 1; foreach (MagicStoneInfo item in ShopProp.Singleton.m_magicStoneList) { string numText = string.Format(Localization.Get("BuyMagicStone"), item.m_magicStoneNum); string priceText = string.Format(Localization.Get("MagciStonePrice"), item.m_magicStonePrice); if (m_gridList.ContainsKey(index)) { UIDragScrollView scrollView = m_gridList[index]; scrollView.GetComponent <Parma>().m_id = item.m_magicStoneId; scrollView.transform.Find("Text").GetComponent <UILabel>().text = numText; scrollView.transform.Find("Price").GetComponent <UILabel>().text = priceText; scrollView.transform.parent = FindChildComponent <UIGrid>("StoneGridList").transform; scrollView.gameObject.SetActive(true); } else { UIDragScrollView copy = GameObject.Instantiate(m_item) as UIDragScrollView; copy.GetComponent <Parma>().m_id = item.m_magicStoneId; copy.transform.Find("Text").GetComponent <UILabel>().text = numText; copy.transform.Find("Price").GetComponent <UILabel>().text = priceText; copy.transform.parent = FindChildComponent <UIGrid>("StoneGridList").transform; // 设置大小 copy.transform.localScale = m_item.transform.localScale; copy.gameObject.SetActive(true); m_gridList.Add(index, copy); string buttonName = copy.transform.Find("StoneButton").name + index; copy.transform.Find("StoneButton").name = buttonName; AddChildMouseClickEvent(buttonName, OnBuyStoneButton); } index++; } for (; index < m_gridList.Count; index++) { m_gridList[index].gameObject.SetActive(false); m_gridList[index].GetComponent <Parma>().m_id = 0; } m_stoneGridList.Reposition(); }
//更新荣誉戒指商店界面 void UpDateRingOfHonorShopUI() { int ring = User.Singleton.UserProps.GetProperty_Int32(UserProperty.ring); int index = 1; foreach (RingOfHonorInfo item in ShopProp.Singleton.m_ringOfHonorList) { UIDragScrollView copy = GameObject.Instantiate(m_ringItem) as UIDragScrollView; copy.GetComponent <Parma>().m_id = item.m_infoId; copy.GetComponent <Parma>().m_type = item.m_cardId; copy.transform.Find("Exchange").GetComponent <UIButton>().transform.Find("RingNum").GetComponent <UILabel>().text = item.m_price.ToString(); //如果戒指数量不足 按钮为灰色 if (ring < item.m_price) { copy.transform.Find("Exchange").GetComponent <UIButton>().enabled = false; } //设置卡牌显示 兑换时间 RingExchangeTableInfo info = GameTable.RingExchangeTableAsset.Lookup(item.m_infoId); UISlider timeSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("ExchangeTime").GetComponent <UISlider>(); timeSlider.transform.Find("StartTime").GetComponent <UILabel>().text = info.startDate + "~"; timeSlider.transform.Find("EndTime").GetComponent <UILabel>().text = info.endDate; //获得卡牌信息 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(item.m_cardId); //设置卡牌名字 copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("Name").GetComponent <UILabel>().text = heroInfo.StrName; copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("Name").GetComponent <UILabel>().text = heroInfo.StrName; //设置种族职业 UISlider typeSlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("TypePanel").GetComponent <UISlider>(); typeSlider.transform.Find("Type").GetComponent <UILabel>().text = GameTable.RaceInfoTableAsset.LookUp(heroInfo.Type).m_name; UISlider occupationSlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("OccupationPanel").GetComponent <UISlider>(); occupationSlider.transform.Find("Occupation").GetComponent <UILabel>().text = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation).m_name; UITexture occupationSprite = occupationSlider.transform.Find("Texture").GetComponent <UITexture>(); //设置职业图标 OccupationInfo occInfo = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation); IconInfomation occicon = GameTable.IconInfoTableAsset.Lookup(occInfo.m_iconId); occupationSprite.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(occicon.dirName); //设置星级 UISlider raritySlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("RarityPanel").GetComponent <UISlider>(); RarityRelativeInfo rarityInfo = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(rarityInfo.m_iconId); raritySlider.transform.Find("Rarity").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); icon = GameTable.IconInfoTableAsset.Lookup(heroInfo.ImageId); //设置卡牌图片 copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("Card").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); //设置魔法攻击力 UISlider magicSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxMagAttackPanel").GetComponent <UISlider>(); // RarityRelativeInfo rarityRelative = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); magicSlider.transform.Find("MagAttackNum").GetComponent <UILabel>().text = BattleFormula.GetMagAttack(item.m_cardId, 1) + ""; UISlider phySlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxPhyAttackPanel").GetComponent <UISlider>(); phySlider.transform.Find("PhyAttackNum").GetComponent <UILabel>().text = BattleFormula.GetPhyAttack(item.m_cardId, 1) + ""; //设置生命值 UISlider hpSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxHpPanel").GetComponent <UISlider>(); hpSlider.transform.Find("MaxHpNum").GetComponent <UILabel>().text = BattleFormula.GetHp(item.m_cardId, 1) + ""; //设置卡牌编号 UILabel cardNum = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("CardNumText").GetComponent <UILabel>(); cardNum.text = string.Format(Localization.Get("MercenaryNum"), heroInfo.CardId); copy.transform.parent = FindChildComponent <UIGrid>("CardGridList").transform; // 设置大小 copy.transform.localScale = m_ringItem.transform.localScale; copy.gameObject.SetActive(true); //设置主动技能 IconInfomation iconInfo = null; SkillInfo skillInfo = null; int skillIndex = 1; List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (0 == skillInfo.SkillType) { UITexture copySkillItem = GameObject.Instantiate(m_skillItem) as UITexture; copySkillItem.GetComponent <Parma>().m_id = skillId; copySkillItem.transform.localScale = m_skillItem.transform.lossyScale; copySkillItem.gameObject.SetActive(true); iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); copySkillItem.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); copySkillItem.name = copySkillItem.name + skillIndex; copySkillItem.transform.parent = copy.transform.Find("CardDetail").transform.Find("Skill").transform; EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onPress, OnShowTips); EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onClick, OnHideTips); //AddChildMouseClickEvent(copySkillItem.name, OnHideTips); } skillIndex++; } m_skillGirdList.Reposition(); //设置被动技能 int passiveIndex = 1; foreach (int skillId in heroInfo.PassiveSkillIDList) { skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (0 == skillInfo.SkillType) { UISprite copySkillItem = m_skillItem.gameObject.AddComponent <UISprite>(); copySkillItem.GetComponent <Parma>().m_id = skillId; copySkillItem.transform.localScale = m_skillItem.transform.lossyScale; copySkillItem.gameObject.SetActive(true); iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); copySkillItem.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); copySkillItem.name = copySkillItem.name + skillIndex; copySkillItem.transform.parent = copy.transform.Find("CardDetail").transform.Find("PassiveSkill").transform; EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onPress, OnShowTips); EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onClick, OnHideTips); //AddChildMouseClickEvent(copySkillItem.name, OnHideTips); } passiveIndex++; } m_ringHonorGridList.Add(index, copy); AddMouseClickEvent(copy.transform.Find("Exchange").gameObject, OnBuyRingCardButton); index++; } for (; index < m_ringHonorGridList.Count; index++) { m_ringHonorGridList[index].gameObject.SetActive(false); m_ringHonorGridList[index].GetComponent <Parma>().m_id = 0; m_ringHonorGridList[index].GetComponent <Parma>().m_type = 0; } m_cardGridList.Reposition(); }
//更新图鉴面板 void UpdateIllustratedPanel() { return; int index = 1; foreach (IllustratedInfo item in Illustrate.Singleton.m_cardList) { if (m_gridList.ContainsKey(index)) { UIDragScrollView scrollView = m_gridList[index]; scrollView.GetComponent <Parma>().m_id = item.m_id; scrollView.GetComponent <Parma>().m_type = item.m_gainLv; scrollView.transform.Find("ImageNum").GetComponent <UILabel>().text = "" + item.m_cardId; int iconId = GameTable.HeroInfoTableAsset.Lookup(item.m_id).headImageId; IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(iconId); scrollView.transform.Find("ImageSprite").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); scrollView.transform.parent = FindChildComponent <UIGrid>("ImageGridList").transform; if (0 == m_selectOccList.Count && 0 == m_selectRaceList.Count) { scrollView.gameObject.SetActive(true); } else { if (m_selectOccList.IndexOf(item.m_occupation) == -1 && m_selectRaceList.IndexOf(item.m_type) == -1) { scrollView.gameObject.SetActive(false); } else { scrollView.gameObject.SetActive(true); } } switch (item.m_gainLv) { case ((int)ENGainLevel.enNone): scrollView.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(false); scrollView.transform.Find("ImageSprite").GetComponent <UITexture>().mainTexture = m_unopen; break; case ((int)ENGainLevel.enSee): scrollView.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(true); break; case ((int)ENGainLevel.enHave): scrollView.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(false); break; } } else { int iconId = GameTable.HeroInfoTableAsset.Lookup(item.m_id).headImageId; IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(iconId); if (null != icon) { UIDragScrollView copy = GameObject.Instantiate(m_item) as UIDragScrollView; copy.GetComponent <Parma>().m_id = item.m_id; copy.GetComponent <Parma>().m_type = item.m_gainLv; copy.transform.Find("ImageNum").GetComponent <UILabel>().text = "" + item.m_cardId; copy.transform.Find("ImageSprite").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); copy.transform.parent = FindChildComponent <UIGrid>("ImageGridList").transform; // 设置大小 copy.transform.localScale = m_item.transform.localScale; if (0 == m_selectOccList.Count && 0 == m_selectRaceList.Count) { copy.gameObject.SetActive(true); } else { if (m_selectOccList.IndexOf(item.m_occupation) == -1 && m_selectRaceList.IndexOf(item.m_type) == -1) { copy.gameObject.SetActive(false); } else { copy.gameObject.SetActive(true); } } m_gridList.Add(index, copy); AddMouseClickEvent(copy.gameObject, OnClickCardImage); switch (item.m_gainLv) { case ((int)ENGainLevel.enNone): copy.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(false); copy.transform.Find("ImageSprite").GetComponent <UITexture>().mainTexture = m_unopen; break; case ((int)ENGainLevel.enSee): copy.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(false); break; case ((int)ENGainLevel.enHave): copy.transform.Find("ImageSprite").Find("LockSprite").gameObject.SetActive(false); break; } } } index++; } m_girdPanel.Reposition(); }