using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public enum GuideBoxType
|
{
|
None,
|
//Box,
|
Fire,
|
Wood,
|
Water
|
}
|
public class GuideBox : MonoBehaviour
|
{
|
Button bgBtn;//背景按钮
|
private GuideBoxType myType;
|
|
GameObject srImage;
|
GameObject infoImage;
|
|
GameObject firePS;
|
GameObject woodPS;
|
GameObject waterPS;
|
|
GameObject firePanel;
|
GameObject woodPanel;
|
GameObject waterPanel;
|
|
|
GameObject tmpPS = null;
|
GameObject tmpObj = null;
|
|
Text infoTxt;
|
|
Action callBack;
|
|
// Start is called before the first frame update
|
void Awake()
|
{
|
bgBtn = transform.Find("BackGround").GetComponent<Button>();
|
bgBtn.onClick.AddListener(OnClickBtn);
|
|
srImage = transform.Find("SRImage").gameObject;
|
|
firePS = transform.Find("Effect_UI_ChouKa_Huo").gameObject;
|
woodPS = transform.Find("Effect_UI_ChouKa_Mu").gameObject;
|
waterPS = transform.Find("Effect_UI_ChouKa_Shui").gameObject;
|
|
firePanel = transform.Find("Fire").gameObject;
|
woodPanel = transform.Find("Wood").gameObject;
|
waterPanel = transform.Find("Water").gameObject;
|
|
|
infoImage = transform.Find("InfoTxt").gameObject;
|
infoTxt = transform.Find("InfoTxt/Text").GetComponent<Text>();
|
|
myType = GuideBoxType.None;
|
|
gameObject.SetActive(false);
|
}
|
|
public void ChangeType(GuideBoxType type, Action ac)
|
{
|
if (!gameObject.activeSelf)
|
{
|
gameObject.SetActive(true);
|
}
|
|
callBack = ac;
|
srImage.SetActive(false);
|
infoImage.SetActive(false);
|
if (type != myType)
|
{
|
myType = type;
|
|
bgBtn.interactable = false;
|
if (myType == GuideBoxType.Fire)
|
{
|
Fire();
|
}
|
else if (myType == GuideBoxType.Wood)
|
{
|
Wood();
|
}
|
else if (myType == GuideBoxType.Water)
|
{
|
Water();
|
}
|
}
|
}
|
|
private void Fire()
|
{
|
tmpPS = firePS;
|
tmpPS.SetActive(true);
|
//tmpPS.Play();
|
tmpObj = firePanel;
|
StartCoroutine(AfterPSPlay("群体攻击,充能爆发"));
|
}
|
|
IEnumerator AfterPSPlay(string info)
|
{
|
yield return new WaitForSeconds(1.2f);
|
bgBtn.interactable = true;
|
srImage.SetActive(true);
|
infoImage.SetActive(true);
|
infoTxt.text = info;
|
tmpObj.SetActive(true);
|
}
|
private void Wood()
|
{
|
tmpPS = woodPS;
|
|
tmpPS.SetActive(true);
|
|
tmpObj = woodPanel;
|
|
StartCoroutine(AfterPSPlay("单体攻击,狙击秒杀"));
|
|
}
|
private void Water()
|
{
|
tmpPS = waterPS;
|
|
tmpPS.SetActive(true);
|
|
tmpObj = waterPanel;
|
StartCoroutine(AfterPSPlay("群体减速,减速增伤"));
|
|
}
|
|
|
private void OnClickBtn()
|
{
|
if (callBack != null)
|
{
|
if (tmpPS != null) tmpPS.SetActive(false);
|
if (tmpObj != null) tmpObj.SetActive(false);
|
gameObject.SetActive(false);
|
callBack();
|
}
|
}
|
}
|