using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// 武将布阵: functionOrder:布阵类型 /// public class HeroPosWin : UIBase { [SerializeField] Text[] attrOnList; //上阵属性加成 [SerializeField] Image countryOnImg; //上阵阵型激活国家 [SerializeField] List OnCountImgs; //上阵数量激活 [SerializeField] List scenePosImgs; //场景布阵位置 [SerializeField] HeroScenePosCell[] sceneHero; [SerializeField] GroupButtonEx attackTeamBtn; [SerializeField] GroupButtonEx defendTeamBtn; [SerializeField] Text fightPowerText; //由客户端自己预算的战力 [SerializeField] ScrollerController heroListScroller; [SerializeField] Transform heroListEmpty; [SerializeField] Toggle showConnTipToggleBtn; [SerializeField] HeroSelectBehaviour fiterManager; //武将筛选 [SerializeField] Button oneKeyOnBtn; //一键上阵 [SerializeField] Button saveBtn; //保存阵型 [SerializeField] Button backBtn; //退出界面 [SerializeField] GroupButtonEx jjcBtn; //竞技场 [SerializeField] GroupButtonEx tttBtn; //通天塔 [SerializeField] GroupButtonEx mainFBBtn; //主线副本 //羁绊 [SerializeField] HeroConnectionCell connetionForm; protected override void InitComponent() { attackTeamBtn.AddListener(() => { if (HeroUIManager.Instance.selectTeamType == TeamType.Arena) { return; } HeroUIManager.Instance.selectTeamType = TeamType.Arena; Refresh(); }); defendTeamBtn.AddListener(() => { if (HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense) { return; } HeroUIManager.Instance.selectTeamType = TeamType.ArenaDefense; Refresh(); }); } protected override void OnPreOpen() { heroListScroller.OnRefreshCell += OnRefreshCell; CreateScroller(); Refresh(); } protected override void OnPreClose() { heroListScroller.OnRefreshCell -= OnRefreshCell; } public override void Refresh() { OnBattleTeamAttrPer(); RefreshOnTeamCountry(); RefreshOnTeamBtn(); } void OnRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell as HeroCardLineCell; _cell.Display(cell.index); } void CreateScroller() { heroListScroller.Refresh(); for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++) { if (i % 4 == 0) { heroListScroller.AddCell(ScrollerDataType.Header, i); } } heroListScroller.Restart(); } //上阵加成 void OnBattleTeamAttrPer() { var valuePer = 0; var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType); if (team != null) { for (int i = 0; i < team.serverData.Length; i++) { var hero = HeroManager.Instance.GetHero(team.serverData[i].guid); if (hero != null) { valuePer += hero.GetOnBattleAddPer(); } } } //上阵属性 for (int i = 0; i < attrOnList.Length; i++) { attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.basePerAttrs[i], valuePer)); } } //上阵武将国家光环激活 void RefreshOnTeamCountry() { Int2 result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.selectTeamType); var config = HeroLineupHaloConfig.GetConfig(result.x, result.y); if (config == null) { countryOnImg.SetSprite("heroTeamCountry" + result.x); for (int i = 0; i < OnCountImgs.Count; i++) { OnCountImgs[i].SetActive(false); } } else { countryOnImg.SetSprite("heroTeamCountry" + result.x); for (int i = 0; i < OnCountImgs.Count; i++) { if (i < result.y) { OnCountImgs[i].SetActive(true); OnCountImgs[i].SetSprite("heroTeamCountryPoint" + result.x); } else { OnCountImgs[i].SetActive(false); } } } } //管理布阵入口按钮:如竞技场是否根据功能显隐,通天塔和主线只有进攻方布阵默认不显示 void RefreshOnTeamBtn() { if (HeroUIManager.Instance.selectTeamType == TeamType.Arena || HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense) { attackTeamBtn.SetActive(true); defendTeamBtn.SetActive(true); if (HeroUIManager.Instance.selectTeamType == TeamType.Arena) { attackTeamBtn.SelectBtn(true); } else { defendTeamBtn.SelectBtn(true); } } else { attackTeamBtn.SetActive(false); defendTeamBtn.SetActive(false); } } }