You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.2 KiB
77 lines
2.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SceneSlectedWnd : WindowBase
|
|
{
|
|
public int currentSlectedIndex = 0;
|
|
|
|
[Header("场景图片")]
|
|
public Transform sceneImgParent;
|
|
private Image[] sceneImages;
|
|
private Image[] scneMiaoBianImgs;
|
|
[Header("按钮")]
|
|
public Button EnterBtn;
|
|
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
sceneImages = new Image[sceneImgParent.childCount];
|
|
scneMiaoBianImgs = new Image[sceneImgParent.childCount];
|
|
for (int i = 0; i < sceneImgParent.childCount; i++)
|
|
{
|
|
sceneImages[i]=sceneImgParent.GetChild(i).Find("Image").GetComponent<Image>();
|
|
scneMiaoBianImgs[i]= sceneImgParent.GetChild(i).Find("miaobian").GetComponent<Image>();
|
|
UIEventListener listener = sceneImages[i].gameObject.AddComponent<UIEventListener>();
|
|
listener.ID = i;
|
|
listener.onPointDown = () => {
|
|
SetSceneIndex(listener.ID);
|
|
};
|
|
}
|
|
|
|
EnterBtn.onClick.AddListener(() => {
|
|
|
|
switch (currentSlectedIndex)
|
|
{
|
|
case 0:
|
|
GameRoot.Instance.SetGameState(GameSateType.塌方巡检);
|
|
this.gameObject.SetActive(false);
|
|
break;
|
|
case 1:
|
|
GameRoot.Instance.AddTipQueue("此场景开发中");
|
|
break;
|
|
case 2:
|
|
GameRoot.Instance.AddTipQueue("此场景开发中");
|
|
break;
|
|
case 3:
|
|
GameRoot.Instance.AddTipQueue("此场景开发中");
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
}
|
|
|
|
public void SetSceneIndex(int index)
|
|
{
|
|
currentSlectedIndex = index;
|
|
for (int i = 0; i < scneMiaoBianImgs.Length; i++)
|
|
{
|
|
if (i == index)
|
|
{
|
|
scneMiaoBianImgs[i].gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
scneMiaoBianImgs[i].gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|