using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using Unity.VisualScripting; using UnityEngine; using UnityEngine.U2D; using UnityEngine.UI; /// /// 关卡信息,关卡状态 /// public class LevItem2 : MonoBehaviour { //按钮本身 public Button btnSelf; //名字 public Text txtName; //关卡id private int levId; //按钮锁 public Image imgLock; //本关是否通关 private bool isLock=false; void Start() { btnSelf.onClick.AddListener(() => { if (isLock) { GameDataMgr.Instance.levRankMsg.openId = GameDataMgr.Instance.player.openId; GameDataMgr.Instance.levRankMsg.id = levId; StartCoroutine(NetMgr.Instance.LevPetInfoPost(GameDataMgr.Instance.levRankMsg)); //更新游戏界面数据 UIManager.Instance.GetPanel().UpdatePanel(levId); } }); } /// /// 初始化方法 用于 更新按钮显示相关 /// /// 关卡状态信息 public void InitInfo(AllLevData lev) { //记录当前关卡id levId = lev.levId; if (levId==1) { isLock=true; } else { if (levId<=GameDataMgr.Instance.player.customLev+1) { isLock = true; } else { isLock = false; } } //更新按钮上的信息 txtName.text = levId.ToString(); //加载图集 SpriteAtlas sa = Resources.Load("Atlas/AllLevPanel"); if (!isLock) { btnSelf.image.sprite = sa.GetSprite("icn_taxoff"); imgLock.gameObject.SetActive(true); } else { btnSelf.image.sprite = sa.GetSprite("icn_taxon"); imgLock.gameObject.SetActive(false); } } }