|
|
@@ -6,12 +6,13 @@ using UnityEngine.UI;
|
|
|
|
|
|
public class PKMatchView : MonoBehaviour
|
|
|
{
|
|
|
- [NonSerialized] public Action loadGameAction;
|
|
|
+ [SerializeField] Sprite[] matchHeadBGList;
|
|
|
|
|
|
void Awake()
|
|
|
{
|
|
|
InitBtnTabs();
|
|
|
InitBtnStartMatch();
|
|
|
+ InitMatchHeadBG();
|
|
|
}
|
|
|
|
|
|
void Start()
|
|
|
@@ -36,8 +37,10 @@ public class PKMatchView : MonoBehaviour
|
|
|
btnTabs[1] =this.transform.Find("LineV/BtnTab1").GetComponent<Button>();
|
|
|
for (int i = 0; i < btnTabs.Length; i++) {
|
|
|
Button btnTab = btnTabs[i];
|
|
|
+ int btnTabIndex = i;
|
|
|
btnTab.onClick.AddListener(() => {
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
+ ChangeMatchHeadBG(btnTabIndex);
|
|
|
if (!IsBtnTabSelected(btnTab)) {
|
|
|
SetBtnTabSelected(btnTab);
|
|
|
}
|
|
|
@@ -60,7 +63,7 @@ public class PKMatchView : MonoBehaviour
|
|
|
void InitBtnStartMatch() {
|
|
|
this.transform.Find("BoxRight/BtnMatch").GetComponent<Button>().onClick.AddListener(() => {
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
- loadGameAction?.Invoke();
|
|
|
+ GameObject.Instantiate(GameObject.Find("WindowViews").transform.Find("PKMatchingView").gameObject).SetActive(true);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -72,6 +75,18 @@ public class PKMatchView : MonoBehaviour
|
|
|
avatarT.Find("Sprite").GetComponent<Image>().sprite = avatar;
|
|
|
}
|
|
|
|
|
|
+ void InitMatchHeadBG() {
|
|
|
+ this.transform.Find("BoxRight/Player2/MatchHeadBG").GetComponent<Button>().onClick.AddListener(() => {
|
|
|
+ Debug.Log("选择好友");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void ChangeMatchHeadBG(int typeIndex) {
|
|
|
+ Image img = this.transform.Find("BoxRight/Player2/MatchHeadBG").GetComponent<Image>();
|
|
|
+ img.sprite = matchHeadBGList[typeIndex];
|
|
|
+ img.GetComponent<Button>().enabled = typeIndex == 1;
|
|
|
+ }
|
|
|
+
|
|
|
public void Back() {
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
Destroy(this.gameObject);
|