| | |
| | | using System; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System.Collections.Generic; |
| | | |
| | | //布阵中的 武将角色 |
| | | public class HeroScenePosCell : MonoBehaviour |
| | |
| | | [SerializeField] Text lvText; |
| | | [SerializeField] UIHeroController heroModel; |
| | | [SerializeField] Image posCircleImg; |
| | | [SerializeField] UIAlphaTween suggestForm; |
| | | [SerializeField] DragItem dragObj; |
| | | [SerializeField] Transform objForfly; //点击飞入的时候的显隐控制 |
| | | |
| | | public void Display(string guid) |
| | | |
| | | public void Display(string guid, int index, bool isFly = false, bool showSuggest = false) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(guid); |
| | | this.transform.localScale = Vector3.one; |
| | | |
| | | lvText.text = Language.Get("L1094") + hero.heroLevel.ToString(); |
| | | lvText.text = Language.Get("L1099", hero.heroLevel); |
| | | var heroConfig = hero.heroConfig; |
| | | countryImg.SetSprite("herocountry" + heroConfig.Country); |
| | | countryImg.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country)); |
| | | heroModel.Create(heroConfig.SkinIDList[hero.SkinIndex], heroConfig.UIScale); |
| | | |
| | | |
| | | nameText.text = hero.breakLevel == 0 ? heroConfig.Name : Language.Get("herocardbreaklv", heroConfig.Name, hero.breakLevel); |
| | | posCircleImg.SetSprite("heroposcircle" + heroConfig.Quality); |
| | | |
| | | //不是推荐位则提示 |
| | | // if (heroConfig.Position == 1 && TeamConst.TeamPos2Array.Contains(index) || |
| | | // heroConfig.Position == 2 && TeamConst.TeamPos1Array.Contains(index)) |
| | | if (showSuggest) |
| | | { |
| | | suggestForm.SetActive(true); |
| | | jobTip.text = HeroUIManager.Instance.GetJobName(heroConfig.Class); |
| | | posTip.text = Language.Get("heroAtkDistType" + heroConfig.Position); |
| | | } |
| | | else |
| | | { |
| | | suggestForm.SetActive(false); |
| | | } |
| | | |
| | | dragObj.pos = index; |
| | | dragObj.onEndDragEvent -= SwitchPos; |
| | | dragObj.onEndDragEvent += SwitchPos; |
| | | dragObj.canvas.sortingLayerID = dragObj.parentCanvas.sortingLayerID; |
| | | dragObj.canvas.sortingOrder = dragObj.parentCanvas.sortingOrder + index + 1; |
| | | |
| | | heroBtn.AddListener(() => |
| | | { |
| | | var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType); |
| | | team.RemoveHero(index); |
| | | //通知刷新(下阵) |
| | | HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { index }, -1, Vector3.zero); |
| | | |
| | | }); |
| | | |
| | | if (isFly) |
| | | { |
| | | //点击飞入 延迟显示 |
| | | objForfly.SetActive(false); |
| | | DelayShow(); |
| | | } |
| | | else |
| | | { |
| | | objForfly.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | void SwitchPos(int pos1, int pos2) |
| | | { |
| | | Debug.Log("交换位置:" + pos1 + " " + pos2); |
| | | var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType); |
| | | if (pos2 == -1) |
| | | { |
| | | //下阵 |
| | | team.RemoveHero(pos1); |
| | | HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1 }, -2, Vector3.zero); |
| | | } |
| | | else if (pos1 == pos2) |
| | | { |
| | | HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1 }, -2, Vector3.zero); |
| | | } |
| | | else |
| | | { |
| | | //通知刷新 |
| | | team.SwapPosition(pos1, pos2); |
| | | HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1, pos2 }, -2, Vector3.zero); |
| | | } |
| | | } |
| | | |
| | | async UniTask DelayShow() |
| | | { |
| | | //延迟0.5秒显示 |
| | | await UniTask.Delay(TimeSpan.FromSeconds(HeroUIManager.clickFlyPosTime)); |
| | | objForfly.SetActive(true); |
| | | } |
| | | } |
| | | |