备份CatanBuilding瘦身独立工程
This commit is contained in:
135
Assets/Scripts/UI/Guidance/GuidancePopupPanel.cs
Normal file
135
Assets/Scripts/UI/Guidance/GuidancePopupPanel.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class HideUI
|
||||
{
|
||||
public bool hide;
|
||||
}
|
||||
|
||||
public class GuidancePopupPanel : MonoBehaviour
|
||||
{
|
||||
Transform node;
|
||||
Button btn_mask;
|
||||
Button btn_next;
|
||||
Button btn_confirm;
|
||||
IDisposable disposable;
|
||||
public float safeTime = 2;
|
||||
bool isConfirm = false;
|
||||
bool isNext = false;
|
||||
Animation station_damage;
|
||||
TMP_Text text_tips;
|
||||
string popupPanelNode;
|
||||
HideUI hideUI;
|
||||
Animation _ani;
|
||||
private void Awake()
|
||||
{
|
||||
_ani = GetComponent<Animation>();
|
||||
station_damage = transform.Find("root/station_damage").GetComponent<Animation>();
|
||||
text_tips = transform.Find("root/station_damage/text_tips").GetComponent<TMP_Text>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_confirm = transform.Find("root/btn_confirm/btn_green").GetComponent<Button>();
|
||||
//btn_mask.onClick.AddListener(Next);
|
||||
btn_confirm.onClick.AddListener(Confirm);
|
||||
btn_confirm.gameObject.SetActive(false);
|
||||
btn_next = transform.Find("root/btn_next/btn_green").GetComponent<Button>();
|
||||
btn_next.gameObject.SetActive(false);
|
||||
btn_next.onClick.AddListener(Next);
|
||||
hideUI = new HideUI();
|
||||
hideUI.hide = true;
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
GContext.Publish(hideUI);
|
||||
popupPanelNode = GContext.container.Resolve<GuideDataCenter>().popupPanelNode;
|
||||
if (popupPanelNode != null)
|
||||
{
|
||||
node = transform.Find("root/" + popupPanelNode);
|
||||
if (node != null)
|
||||
{
|
||||
node.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
disposable = GContext.OnEvent<IsShowGuidance>().Subscribe(IsShowGuidance);
|
||||
if (popupPanelNode == "station_damage")
|
||||
{
|
||||
text_tips.text = LocalizationMgr.GetText("UI_GuidancePopupPanel_2");
|
||||
StartCoroutine(CanDamageNext());
|
||||
}
|
||||
else
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("guide_popup"))
|
||||
{
|
||||
e.AddContent("guide_popup_type", popupPanelNode)
|
||||
.AddContent("fish_count", GContext.container.Resolve<PlayerFishData>().GetAnglingCount());
|
||||
}
|
||||
#endif
|
||||
StartCoroutine(CanNext());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator CanNext()
|
||||
{
|
||||
isConfirm = false;
|
||||
yield return new WaitForSeconds(safeTime);
|
||||
isConfirm = true;
|
||||
btn_confirm.gameObject.SetActive(true);
|
||||
}
|
||||
IEnumerator CanDamageNext()
|
||||
{
|
||||
isNext = false;
|
||||
yield return new WaitForSeconds(safeTime);
|
||||
isNext = true;
|
||||
btn_next.gameObject.SetActive(true);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
hideUI.hide = false;
|
||||
GContext.Publish(hideUI);
|
||||
|
||||
if (node != null)
|
||||
{
|
||||
node.gameObject.SetActive(false);
|
||||
}
|
||||
disposable?.Dispose();
|
||||
}
|
||||
void Next()
|
||||
{
|
||||
Debug.Log("Confirm isNext:" + isNext);
|
||||
if (isNext)
|
||||
{
|
||||
btn_next.gameObject.SetActive(false);
|
||||
StartCoroutine(CanNext());
|
||||
if (popupPanelNode == "station_damage")
|
||||
{
|
||||
text_tips.text = LocalizationMgr.GetText("UI_GuidancePopupPanel_5");
|
||||
|
||||
station_damage.Play("fail_DamageIncrease");
|
||||
}
|
||||
}
|
||||
}
|
||||
async void Confirm()
|
||||
{
|
||||
Debug.Log("Confirm :" + isConfirm);
|
||||
if (isConfirm)
|
||||
{
|
||||
btn_confirm.gameObject.SetActive(false);
|
||||
_ani.Play("GuidancePopup_disappear");
|
||||
await Awaiters.Seconds(0.25f);
|
||||
GContext.container.Resolve<GuideDataCenter>().AddIndex();
|
||||
//GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide(BasePanel.PanelName);
|
||||
UIManager.Instance.DestroyUI(UITypes.GuidancePopupPanel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IsShowGuidance(IsShowGuidance data)
|
||||
{
|
||||
data.isShow = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user