147 lines
6.3 KiB
C#
147 lines
6.3 KiB
C#
using CG.Framework;
|
|
using CG.UTility;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using UnityEngine.UI;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class ModelSelectPanel : UIBase
|
|
{
|
|
private GameObject _teachModelGeo = null;
|
|
private GameObject _trainModelGeo = null;
|
|
private GameObject _examModelGeo = null;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
_teachModelGeo = GetWedage("TeachModleBtn_N");
|
|
HoverImageCtrl teachHoverBtn = _teachModelGeo.AddComponent<HoverImageCtrl>();
|
|
teachHoverBtn._EnterEvent = () => {
|
|
TeachBtnState(true);
|
|
};
|
|
teachHoverBtn._ExitEvent = () => {
|
|
TeachBtnState(false);
|
|
};
|
|
AddEventListener("TeachVideoBtn_N", UIEventType.OnButtonClick, () =>
|
|
{
|
|
GameManager.Instance._StateContext.SetState(new TeachState(GameManager.Instance._StateContext, "TeachVideoPanel"));
|
|
TeachBtnState(false);
|
|
});
|
|
AddEventListener("DataShowBtn_N", UIEventType.OnButtonClick, () =>
|
|
{
|
|
GameManager.Instance._StateContext.SetState(new TeachState(GameManager.Instance._StateContext, "DataShowPanel"));
|
|
TeachBtnState(false);
|
|
});
|
|
|
|
_trainModelGeo = GetWedage("TrainModleBtn_N");
|
|
HoverImageCtrl trainHoverBtn = _trainModelGeo.AddComponent<HoverImageCtrl>();
|
|
trainHoverBtn._EnterEvent = () =>
|
|
{
|
|
TrainBtnState(true);
|
|
};
|
|
trainHoverBtn._ExitEvent = () =>
|
|
{
|
|
TrainBtnState(false);
|
|
};
|
|
_trainModelGeo.GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
GameManager.Instance._StateContext.SetState(new TrainState(GameManager.Instance._StateContext));
|
|
TrainBtnState(false);
|
|
});
|
|
|
|
_examModelGeo = GetWedage("ExamModleBtn_N");
|
|
HoverImageCtrl examHoverBtn = _examModelGeo.AddComponent<HoverImageCtrl>();
|
|
examHoverBtn._EnterEvent = () =>
|
|
{
|
|
ExamBtnState(true);
|
|
};
|
|
examHoverBtn._ExitEvent = () =>
|
|
{
|
|
ExamBtnState(false);
|
|
};
|
|
_examModelGeo.GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
GameManager.Instance._StateContext.SetState(new ExamState(GameManager.Instance._StateContext));
|
|
ExamBtnState(false);
|
|
});
|
|
}
|
|
|
|
private void TeachBtnState(bool enter)
|
|
{
|
|
if (enter)
|
|
{
|
|
_teachModelGeo.GetComponent<RectTransform>().DOAnchorPosY(80.0f, 0.1f).SetId("Teach");
|
|
_teachModelGeo.transform.Find("Mask").gameObject.SetActive(true);
|
|
GetWedage("TeachVideoBtn_N").gameObject.SetActive(true);
|
|
GetWedage("DataShowBtn_N").gameObject.SetActive(true);
|
|
|
|
GameObject teachVideoGeo = _teachModelGeo.transform.Find("TeachVideoBtn_N").gameObject;
|
|
|
|
HoverImageCtrl teachVideoHoverBtn;
|
|
if(!teachVideoGeo.TryGetComponent(out teachVideoHoverBtn))
|
|
{
|
|
teachVideoHoverBtn = teachVideoGeo.AddComponent<HoverImageCtrl>();
|
|
}
|
|
teachVideoHoverBtn._EnterEvent = () => { teachVideoGeo.transform.Find("bg").gameObject.SetActive(true); };
|
|
teachVideoHoverBtn._ExitEvent = () => { teachVideoGeo.transform.Find("bg").gameObject.SetActive(false); };
|
|
|
|
GameObject dataShowGeo = _teachModelGeo.transform.Find("DataShowBtn_N").gameObject;
|
|
HoverImageCtrl dataShowHoverBtn;
|
|
if (!dataShowGeo.TryGetComponent(out dataShowHoverBtn))
|
|
{
|
|
dataShowHoverBtn = dataShowGeo.AddComponent<HoverImageCtrl>();
|
|
}
|
|
dataShowHoverBtn._EnterEvent = () => { dataShowGeo.transform.Find("bg").gameObject.SetActive(true); };
|
|
dataShowHoverBtn._ExitEvent = () => { dataShowGeo.transform.Find("bg").gameObject.SetActive(false); };
|
|
}
|
|
else
|
|
{
|
|
DOTween.Kill("Teach");
|
|
Vector2 curPos = _teachModelGeo.GetComponent<RectTransform>().anchoredPosition;
|
|
_teachModelGeo.GetComponent<RectTransform>().anchoredPosition = new Vector2(curPos.x, 50.0f);
|
|
_teachModelGeo.transform.Find("Mask").gameObject.SetActive(false);
|
|
GetWedage("TeachVideoBtn_N").gameObject.SetActive(false);
|
|
GetWedage("DataShowBtn_N").gameObject.SetActive(false);
|
|
|
|
_teachModelGeo.transform.Find("TeachVideoBtn_N/bg").gameObject.SetActive(false);
|
|
_teachModelGeo.transform.Find("DataShowBtn_N/bg").gameObject.SetActive(false);
|
|
}
|
|
}
|
|
private void TrainBtnState(bool enter)
|
|
{
|
|
if (enter)
|
|
{
|
|
_trainModelGeo.GetComponent<RectTransform>().DOAnchorPosY(80.0f, 0.1f).SetId("Train");
|
|
_trainModelGeo.transform.Find("Mask").gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
DOTween.Kill("Train");
|
|
Vector2 curPos = _trainModelGeo.GetComponent<RectTransform>().anchoredPosition;
|
|
_trainModelGeo.GetComponent<RectTransform>().anchoredPosition = new Vector2(curPos.x, 50.0f);
|
|
_trainModelGeo.transform.Find("Mask").gameObject.SetActive(false);
|
|
}
|
|
}
|
|
private void ExamBtnState(bool enter)
|
|
{
|
|
if (enter)
|
|
{
|
|
_examModelGeo.GetComponent<RectTransform>().DOAnchorPosY(80.0f, 0.1f).SetId("Exam");
|
|
_examModelGeo.transform.Find("Mask").gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
DOTween.Kill("Exam");
|
|
Vector2 curPos = _examModelGeo.GetComponent<RectTransform>().anchoredPosition;
|
|
_examModelGeo.GetComponent<RectTransform>().anchoredPosition = new Vector2(curPos.x, 50.0f);
|
|
_examModelGeo.transform.Find("Mask").gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
} |