382 lines
10 KiB
C#
382 lines
10 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public class BtnController : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public static BtnController Instance;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
Instance = this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Animator anim;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// չ<><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public GameObject pnlEx;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// С<><D0A1>ͼ
|
|||
|
|
/// </summary>
|
|||
|
|
public GameObject objMinimap;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ťͼ<C5A5><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public Image imgBGSetting;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public Sprite spMusicOn;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public Sprite spMusicOff;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// չ<><D5B9>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ
|
|||
|
|
/// </summary>
|
|||
|
|
public bool isPanelExShow;
|
|||
|
|
|
|||
|
|
private void Start()
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>
|
|||
|
|
//Button[] btns = transform.GetComponentsInChildren<Button>(true);
|
|||
|
|
//foreach (Button btn in btns)
|
|||
|
|
//{
|
|||
|
|
// btn.gameObject.AddComponent<BtnPreHandler>();
|
|||
|
|
//}
|
|||
|
|
//InputField[] inputs = transform.GetComponentsInChildren<InputField>(true);
|
|||
|
|
//foreach (InputField input in inputs)
|
|||
|
|
//{
|
|||
|
|
// input.gameObject.AddComponent<BtnPreHandler>();
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
rectMini.localScale = Vector3.one * 2;
|
|||
|
|
|
|||
|
|
// <20><>λ<EFBFBD><CEBB>Բ<EFBFBD><D4B2>RawImage<67><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>Pivot<6F><74>
|
|||
|
|
rectMini.localPosition = new Vector3(
|
|||
|
|
rectMini.localPosition.x - rectMini.rect.width / 2,
|
|||
|
|
rectMini.localPosition.y - rectMini.rect.height / 2);
|
|||
|
|
rectMiniBG.localScale = Vector3.one * 2;
|
|||
|
|
rectMiniBG.localPosition = new Vector3(
|
|||
|
|
rectMiniBG.localPosition.x - rectMiniBG.rect.width / 2,
|
|||
|
|
rectMiniBG.localPosition.y - rectMiniBG.rect.height / 2);
|
|||
|
|
|
|||
|
|
anim = GetComponent<Animator>();
|
|||
|
|
|
|||
|
|
objImgHelp.GetComponentInChildren<Button>().onClick.AddListener(OnBtnHelpCloseClick);
|
|||
|
|
objImgHelp.GetComponentInChildren<Button>().onClick.AddListener(OnBtnHelpClick);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnBtnHelpCloseClick()
|
|||
|
|
{
|
|||
|
|
if(!H5Receiver.IsEnterGame)
|
|||
|
|
{
|
|||
|
|
BaseController.IsAnimatorOnControl = true;
|
|||
|
|
FindObjectOfType<H5Receiver>().EnterGame();
|
|||
|
|
objImgHelp.GetComponentInChildren<Button>().onClick.RemoveListener(OnBtnHelpCloseClick);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnBtnBGMusicClick()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
AudioManager.Instance.SetBackgroundMute();
|
|||
|
|
|
|||
|
|
// <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
imgBGSetting.sprite =
|
|||
|
|
AudioManager.Instance.IsBgMute ? spMusicOff : spMusicOn;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public Color defaultColor = Color.gray;
|
|||
|
|
|
|||
|
|
public Color selectedColor = Color.cyan;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// չ<><D5B9><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnBtnExLoaderClick()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
isPanelExShow = !isPanelExShow;
|
|||
|
|
if (isPanelExShow)
|
|||
|
|
{
|
|||
|
|
// Tween myTween = pnlEx.transform.DOLocalMoveY(302f, 1f);
|
|||
|
|
// myTween.SetEase(Ease.OutQuint);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>õ<EFBFBD>ǰչ<C7B0><D5B9>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ɫ
|
|||
|
|
for (int i = 0; i < 7; i++)
|
|||
|
|
{
|
|||
|
|
GameObject objBtn = GameObject.Find("BtnExLoader" + i);
|
|||
|
|
if (objBtn != null)
|
|||
|
|
{
|
|||
|
|
if (i == SceneLoader.currentIndex)
|
|||
|
|
{
|
|||
|
|
objBtn.GetComponent<Image>().color = selectedColor;
|
|||
|
|
objBtn.GetComponentInChildren<Text>().color = selectedColor;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
objBtn.GetComponent<Image>().color = defaultColor;
|
|||
|
|
objBtn.GetComponentInChildren<Text>().color = defaultColor;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// Tween myTween = pnlEx.transform.DOLocalRotate(Vector3.forward * 180, 1);
|
|||
|
|
// Tween myTween = pnlEx.transform.DOLocalMoveY(-400f, 1f);
|
|||
|
|
// myTween.SetEase(Ease.OutQuint);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public float move = 200f;
|
|||
|
|
|
|||
|
|
public void OnBtnLoadExClick(int index)
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl && index == SceneLoader.currentIndex)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
LoadScene(index);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Text txtBtnName;
|
|||
|
|
|
|||
|
|
public void OnBtnLoadExEnter(string btnName)
|
|||
|
|
{
|
|||
|
|
//txtBtnName.text = btnName;
|
|||
|
|
//txtBtnName.transform.parent.position =
|
|||
|
|
// new Vector3(Input.mousePosition.x, Input.mousePosition.y + 50f, Input.mousePosition.z);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="index">չ<><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
|
void LoadScene(int index)
|
|||
|
|
{
|
|||
|
|
StartCoroutine(SceneLoader.Instance.LoadScene(index));
|
|||
|
|
|
|||
|
|
OnBtnExLoaderClick();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnBtnShowPointClick()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
ShowPointEx.Instance.ShowPanel(SceneLoader.currentIndex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// С<><D0A1>ͼͼ<CDBC><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public RectTransform rectMini;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// С<><D0A1>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public RectTransform rectMiniBG;
|
|||
|
|
|
|||
|
|
public GameObject imgMapZT;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// С<><D0A1>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnMinimapClick()
|
|||
|
|
{
|
|||
|
|
//if (!BaseController.CanControl)
|
|||
|
|
// return;
|
|||
|
|
|
|||
|
|
imgMapZT.SetActive(true);
|
|||
|
|
objMinimap.SetActive(false);
|
|||
|
|
BaseController.CanControl = false;
|
|||
|
|
// ZX9Controller.Instance.ShowPanel(SceneLoader.currentIndex);
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//if (rectMini.localScale == Vector3.one)
|
|||
|
|
//{
|
|||
|
|
// rectMini.localScale = Vector3.one * 4;
|
|||
|
|
|
|||
|
|
// // <20><>λ<EFBFBD><CEBB>Բ<EFBFBD><D4B2>RawImage<67><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>Pivot<6F><74>
|
|||
|
|
// rectMini.localPosition = new Vector3(
|
|||
|
|
// rectMini.localPosition.x - rectMini.rect.width / 2,
|
|||
|
|
// rectMini.localPosition.y - rectMini.rect.height / 2);
|
|||
|
|
// rectMiniBG.localScale = Vector3.one * 4;
|
|||
|
|
// rectMiniBG.localPosition = new Vector3(
|
|||
|
|
// rectMiniBG.localPosition.x - rectMiniBG.rect.width / 2,
|
|||
|
|
// rectMiniBG.localPosition.y - rectMiniBG.rect.height / 2);
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// rectMini.localScale = Vector3.one;
|
|||
|
|
// rectMiniBG.localScale = Vector3.one;
|
|||
|
|
// rectMini.localPosition = new Vector3(
|
|||
|
|
// rectMini.localPosition.x + rectMini.rect.width / 2,
|
|||
|
|
// rectMini.localPosition.y + rectMini.rect.height / 2);
|
|||
|
|
// rectMiniBG.localPosition = new Vector3(
|
|||
|
|
// rectMiniBG.localPosition.x + rectMiniBG.rect.width / 2,
|
|||
|
|
// rectMiniBG.localPosition.y + rectMiniBG.rect.height / 2);
|
|||
|
|
//}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnMinimapEnter()
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = false;
|
|||
|
|
}
|
|||
|
|
public void OnMinimapExit()
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnMapZTClick()
|
|||
|
|
{
|
|||
|
|
imgMapZT.SetActive(false);
|
|||
|
|
objMinimap.SetActive(true);
|
|||
|
|
BaseController.CanControl = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ͼ<EFBFBD><CDBC>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnBtnMinimapClick()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
objMinimap.SetActive(!objMinimap.activeSelf);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
|||
|
|
/// <summary>
|
|||
|
|
/// ȫ<><C8AB><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>Click<63><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ٵ<EFBFBD><D9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnBtnFullScreenPointerDown()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl || H5Controller.IsMobileBroswer())
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
Screen.fullScreen = !Screen.fullScreen;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public GameObject objImgHelp;
|
|||
|
|
public Image imgHelp;
|
|||
|
|
public GameObject objTxtHelp;
|
|||
|
|
public GameObject objBtnSkipAnim;
|
|||
|
|
public void OnBtnHelpClick()
|
|||
|
|
{
|
|||
|
|
if (objImgHelp.activeSelf)
|
|||
|
|
{
|
|||
|
|
objTxtHelp.SetActive(false);
|
|||
|
|
objImgHelp.SetActive(false);
|
|||
|
|
|
|||
|
|
if (!BaseController.IsAnimatorOnControl)
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
objBtnSkipAnim.SetActive(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (anim != null && anim.enabled)
|
|||
|
|
{
|
|||
|
|
anim.SetBool("IsHelp", false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// StartCoroutine(ImageLoader<Image>.LoadImage(CommonData.UIImageFullPath + "Help.png", imgHelp));
|
|||
|
|
objTxtHelp.SetActive(true);
|
|||
|
|
objImgHelp.SetActive(true);
|
|||
|
|
BaseController.CanControl = false;
|
|||
|
|
|
|||
|
|
if (anim != null && anim.enabled)
|
|||
|
|
{
|
|||
|
|
anim.SetBool("IsHelp", true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SetCanControlDelay()
|
|||
|
|
{
|
|||
|
|
Invoke("SetControl", 0.2f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void SetControl()
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public Sprite spAutoOn;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
|
/// </summary>
|
|||
|
|
public Sprite spAutoOff;
|
|||
|
|
|
|||
|
|
public Image imgAutoNavigate;
|
|||
|
|
|
|||
|
|
public GameObject objGuider;
|
|||
|
|
|
|||
|
|
public void OnBtnAutoClick()
|
|||
|
|
{
|
|||
|
|
if (!BaseController.CanControl && !BaseController.IsAutoNavigating)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
BaseController.IsAutoNavigating = !BaseController.IsAutoNavigating;
|
|||
|
|
imgAutoNavigate.sprite = BaseController.IsAutoNavigating ? spAutoOff : spAutoOn;
|
|||
|
|
|
|||
|
|
if (BaseController.IsAutoNavigating)
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = false;
|
|||
|
|
GameObject obj = GameObject.Find("AutoGuiderEx");
|
|||
|
|
if (obj != null)
|
|||
|
|
{
|
|||
|
|
objGuider.SetActive(false);
|
|||
|
|
|
|||
|
|
obj.GetComponent<AutoGuiderEx>().Navigate();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BaseController.CanControl = true;
|
|||
|
|
GameObject obj = GameObject.Find("AutoGuiderEx");
|
|||
|
|
if (obj != null)
|
|||
|
|
{
|
|||
|
|
objGuider.SetActive(true);
|
|||
|
|
|
|||
|
|
obj.GetComponent<AutoGuiderEx>().StopNavigate();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|