/// <summary> /// 刷新上阵小队信息 /// </summary> /// <param name="item"></param> void UpdateHeroGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } item.onPress = SeeHeroArcaneInfo; HeroInfo info = item.oData as HeroInfo; UILabel heroName = item.mScripts[0] as UILabel; UILabel cardName = item.mScripts[1] as UILabel; UITexture isEmpty = item.mScripts[4] as UITexture; CreateSpineAni player = item.mScripts[2] as CreateSpineAni; item.name = "hero" + item.miCurIndex.ToString(); if (player != null) { MonoBehaviour.Destroy(player.gameObject); } heroName.gameObject.SetActive(info.heroUUId > 0); cardName.gameObject.SetActive(info.heroUUId > 0); isEmpty.gameObject.SetActive(info.heroUUId <= 0); if (info.heroUUId > 0) { TD_Hero heroInfo = HeroConfig.GetItem(info.configId); heroName.text = heroInfo.name; cardName.text = info.cardTeamName; ResourceManager.Instance.LoadPrefab(heroInfo.res, LoadComplete, LoadFail, item); } }
public void OnLoad_TweenRes() { mAtkCfg = HeroConfig.GetItem(1001); TD_Skill skillItem = SkillConfig.GetItem(10011001); if (Define.VSTest) { skillItem.hero_out = "test_outtween"; skillItem.hero_back = "test_outtween"; } ResourceManager.Instance.LoadPrefab(skillItem.hero_out.ToLower(), (abname, obj) => { TweenOutAtk.IsMirror = IsMirror; mAtkOutTransform = obj.transform; TweenOutAtk.Target = obj.transform; TweenOutAtk.InitParams(skillItem.animation); TweenOutAtk.AdaptMapObjectPosition(TweenOutOrgObjectAtk.position); TweenOutAtk_ResLoaded = true; }, OnLoader_Error); if (!TweenOut_IsSng) { mAtkedCfg = HeroConfig.GetItem(1001); ResourceManager.Instance.LoadPrefab(mAtkedCfg.hero_atked.ToLower(), (abname, obj) => { TweenOutAtked.FaceX = -1; TweenOutAtked.IsMirror = IsMirror; mAtkedOutTransform = obj.transform; TweenOutAtked.Target = obj.transform; TweenOutAtked.InitParams(skillItem.animation); TweenOutAtked.AdaptMapObjectPosition(TweenOutOrgObjectAtked.position); TweenOutAtked_ResLoaded = true; mAtkedBackTransform = obj.transform; }, OnLoader_Error); } if (!skillItem.animation.IsNullOrEmpty()) { ResourceManager.Instance.LoadPrefab(skillItem.animation.ToLower(), OnLoader_FightCompleteTest, OnLoader_Error); } ResourceManager.Instance.LoadPrefab(skillItem.hero_back.ToLower(), (abname, obj) => { obj.SetActive(false); obj.name = "atk_tweenOut"; mAtkBackTransform = obj.transform; }, OnLoader_Error); }
/// <summary> /// 刷新奥义信息 /// </summary> /// <param name="hero"></param> void UpdateArcaneInfo(TD_Hero hero) { panel.changeCardName.label.text = cardInfoList.cardName; for (int i = 0; i < hero.arcane_list.Split(';').Length; ++i) { if (hero.arcane_list.Split(';')[i] == cardInfoList.arcaneId.ToString()) { panel.dropScrollView.startCenterIndex = i; } UIEventListener.Get(panel.dropScrollView.listEnhanceItems[i].gameObject).onClick = OnClickItem; panel.dropScrollView.listEnhanceItems[i].name = hero.arcane_list.Split(';')[i]; } panel.dropScrollView.callBack = ChooseArcane; }
/// <summary>获取项</summary> /// <returns>TD_Hero</returns> public static TD_Hero GetItem(int id) { TD_Hero itm = null; int cnt = m_data.Count; for (int i = 0; i < cnt; i++) { if (m_data[i].id.CompareTo(id) == 0) { return(m_data[i]); } } return(itm); }
/// <summary> /// 界面显示调用 /// </summary> protected override void OnShow(INotification notification) { TD_Hero hero = HeroConfig.GetItem(cardInfoList.heroConfigId); UpdateArcaneInfo(hero); cardInfoList = notification.Body as CardInfoListMsg; cardInfoList.cardList.Sort((x, y) => y.isFight.CompareTo(x.isFight)); int fightCount = 0; for (int i = 0; i < cardInfoList.cardList.Count; ++i) { if (cardInfoList.cardList[i].isFight == 1) { fightCount++; } } panel.cardCount.text = string.Format("{0}/{1}", fightCount, cardInfoList.cardList.Count); }
/// <summary> /// 刷新英雄信息 /// </summary> /// <param name="item"></param> void UpdateHeroGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } item.onClick = SetHeroItem; HeroInfoMsg info = item.oData as HeroInfoMsg; UITexture head = item.mScripts[0] as UITexture; UILabel name = item.mScripts[1] as UILabel; UILabel level = item.mScripts[2] as UILabel; TD_Hero hero = HeroConfig.GetItem(info.configId); if (hero == null) { return; } LoadSprite.LoaderHead(head, hero.headRes); name.text = hero.name; level.text = string.Format("Lv{0}", info.level); }
/// <summary> /// 刷新备用小队信息 /// </summary> /// <param name="item"></param> void UpdateDownHeroGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } HeroInfo info = item.oData as HeroInfo; UITexture head = item.mScripts[0] as UITexture; UILabel cardName = item.mScripts[1] as UILabel; UISprite addHeroBtn = item.mScripts[2] as UISprite; UISprite isFight = item.mScripts[3] as UISprite; UISprite dropItemSpri = item.mScripts[4] as UISprite; UILabel isMove = item.mScripts[5] as UILabel; UISprite isReady = item.mScripts[6] as UISprite; dropItemSpri.gameObject.SetActive(false); isMove.gameObject.SetActive(true); UIEventListener.Get(addHeroBtn.gameObject).onClick = CreateCardTeam; item.onPress = ChooseItem; item.onClick = SetHeroItem; isFight.gameObject.SetActive(info.pos >= 1); addHeroBtn.gameObject.SetActive(info.heroUUId == 0); isReady.gameObject.SetActive(false); if (info.heroUUId > 0) { TD_Hero hero = HeroConfig.GetItem(info.configId); isReady.gameObject.SetActive(info.arcaneId == 0 || info.skillID.Count < hero.deck_build); if (isReady.gameObject.activeSelf) { isReady.Additive = true; } LoadSprite.LoaderHead(head, hero.headRes); cardName.text = info.cardTeamName; } else { head.mainTexture = null; cardName.text = TextManager.GetUIString("UI1005"); } }
/// <summary> /// 刷新小队信息 /// </summary> /// <param name="item"></param> void UpdateTeamGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } item.onClick = ChooseItem; SelectTeamMsg info = item.oData as SelectTeamMsg; UILabel name = item.mScripts[0] as UILabel; UILabel id = item.mScripts[1] as UILabel; UISprite addBtn = item.mScripts[2] as UISprite; UILabel haveTeam = item.mScripts[3] as UILabel; haveTeam.gameObject.SetActive(info.teamId > 0); addBtn.gameObject.SetActive(info.teamId < 0); item.GetComponent <BoxCollider>().enabled = info.teamId > 0; UIEventListener.Get(addBtn.gameObject).onClick = CeateTeam; if (info.teamId < 0) { return; } name.text = info.teamName; id.text = info.teamId.ToString(); TD_Hero hero = null; for (int i = 0; i < 4; ++i) { if (info.configIdList.Count > i) { hero = HeroConfig.GetItem(info.configIdList[i]); LoadSprite.LoaderHead(haveTeam.transform.FindChild(i.ToString()).GetComponent <UITexture>(), hero.headRes); } else { haveTeam.transform.FindChild(i.ToString()).GetComponent <UITexture>().material = null; } } }
/// <summary> /// 刷新卡组信息 /// </summary> /// <param name="hero"></param> void UpdateCardTeamInfo(TD_Hero hero) { for (int i = 0; i < cardInfoList.cardList.Count; ++i) { TD_Card card = CardConfig.GetItem(cardInfoList.cardList[i].configId); card.isFight = cardInfoList.cardList[i].isFight; card.isHave = 1; cardList.Add(card); } CardDataMsg info = null; for (int i = 0; i < hero.card_list.Split(';').Length; ++i) { int id = hero.card_list.Split(';')[i].ToInt(); info = CheckCardIsHave(id); if (info != null) { continue; } TD_Card card = CardConfig.GetItem(id); card.isFight = 0; card.isHave = 0; cardList.Add(card); } listObj = new List <object>(); for (int i = 0; i < cardList.Count; ++i) { listObj.Add(cardList[i]); } panel.cardGrid.AddCustomDataList(listObj); List <object> list = new List <object>(); for (int i = 0; i < cardInfoList.cardList.Count; ++i) { if (cardInfoList.cardList[i].isFight == 1) { list.Add(cardInfoList.cardList[i]); } } if (list.Count < 4) { for (int i = 0; i < 4; ++i) { if (i >= list.Count) { CardDataMsg data = new CardDataMsg { configId = i, }; list.Add((object)data); } } } panel.fightGrid.AddCustomDataList(list); list.Clear(); if (panel.cardGrid.mDataSource.Count % 6 == 0) { dragIndex = panel.cardGrid.mDataSource.Count / 6; dragIndex--; } else { dragIndex = Mathf.FloorToInt(panel.cardGrid.mDataSource.Count * 1.0f / 6); } }
/// <summary> /// 上阵英雄 /// </summary> public void SetHeroFight(int fightIndex, int index) { HeroInfo info = panel.heroGrid.GetCustomDataItem(index) as HeroInfo; HeroInfo downInfo = panel.cardGrid.GetCustomDataItem(fightIndex) as HeroInfo; int replaceId = 0; replaceId = info.heroUUId; bool haveFight = false; for (int i = 0; i < panel.heroGrid.mDataSource.Count; ++i) { if ((panel.heroGrid.GetCustomDataItem(i) as HeroInfo).configId == downInfo.configId) { if (index == i) { continue; } haveFight = true; break; } } if (haveFight || downInfo.pos > 0) { Debug.LogError("已经存在"); panel.cardGrid.UpdateCustomData(downInfo); return; } TD_Hero hero = HeroConfig.GetItem(downInfo.configId); if (downInfo.skillID.Count < hero.deck_build || downInfo.arcaneId == 0) { Debug.LogError("技能没有全或者奥义没有选奥义"); panel.cardGrid.UpdateCustomData(downInfo); return; } if (info.heroUUId != 0) { HeroInfo infos = null; for (int i = 0; i < panel.cardGrid.mDataSource.Count; ++i) { infos = panel.cardGrid.GetCustomDataItem(i) as HeroInfo; if (infos.heroUUId == info.heroUUId) { infos.pos = 0; panel.cardGrid.UpdateCustomData(infos); break; } } } info.heroUUId = downInfo.heroUUId; info.configId = downInfo.configId; info.cardTeamName = downInfo.cardTeamName; panel.heroGrid.UpdateCustomData(info); downInfo.pos = index + 1; panel.cardGrid.UpdateCustomData(downInfo); HeroOnFightMsg msg = new HeroOnFightMsg { teamId = heroListMsg.id, heroId = downInfo.heroUUId, replaceId = replaceId, pos = downInfo.pos, }; NSocket.GetInstance().SendData(Request.HeroOnFight, msg); }
public override void onloaded(AssetBundles.NormalRes data) { byte[] asset = (data as AssetBundles.BytesRes).m_bytes; if (asset == null) { return; } m_data = new List <TD_Hero>(); TbXmlNode docNode = TbXml.Load(asset).docNode; if (docNode == null) { return; } List <TbXmlNode> xmlNodeList = docNode.GetNodes("Object/Property"); int xmlNodeListLength = xmlNodeList.Count; if (xmlNodeListLength < 1) { return; } TD_Hero item; for (int i = 0; i < xmlNodeListLength; ++i) { TbXmlNode node = xmlNodeList[i] as TbXmlNode; item = new TD_Hero(); item.id = node.GetIntValue("hero_id"); item.res = node.GetStringValue("hero_res"); item.name = node.GetStringValue("hero_name"); item.type = (E_HeroType)node.GetIntValue("hero_type"); item.skinRes = node.GetStringValue("skin_res"); item.hero_dis = node.GetStringValue("hero_dis"); item.hp = node.GetIntValue("hp"); item.shield = node.GetIntValue("shield"); item.headRes = node.GetStringValue("hero_head"); item.arcane_list = node.GetStringValue("arcane_list"); item.arcaneInitalSkill = node.GetIntValue("arcane_initial_list"); item.card_list = node.GetStringValue("card_list"); item.card_initial_list = node.GetStringValue("card_initial_list"); item.awake = node.GetStringValue("awake"); item.hero_occupy = node.GetIntValue("hero_occupy"); item.hero_atked = node.GetStringValue("hero_atked"); item.hero_voice1 = node.GetStringValue("hero_voice1"); item.hero_voice2 = node.GetStringValue("hero_voice2"); item.hero_voice3 = node.GetStringValue("hero_voice3"); item.hero_voice4 = node.GetStringValue("hero_voice4"); item.hero_voice5 = node.GetStringValue("hero_voice5"); item.deck_build = node.GetIntValue("deck_build"); m_data.Add(item); } asset = null; if (null != m_callBack) { m_callBack(); m_callBack = null; } base.onloaded(data); }