备份CatanBuilding瘦身独立工程
This commit is contained in:
66
Assets/Scripts/UI/Guidance/GuidanceDefineSetting.cs
Normal file
66
Assets/Scripts/UI/Guidance/GuidanceDefineSetting.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
[Serializable]
|
||||
public class GuidanceDefine
|
||||
{
|
||||
public string Description;
|
||||
public string panelName;
|
||||
public string buttonPath;
|
||||
public string popupNode;
|
||||
public string[] highlightedNode;
|
||||
public AssetReferenceT<AudioClip> assetReference;
|
||||
[Header("Mask")]
|
||||
public MaskType maskType;
|
||||
public HollowedType hollowedType;
|
||||
public float maskRadius;
|
||||
public float maskDelayed;
|
||||
[Header("TextBox")]
|
||||
public TextBoxType textBoxType;
|
||||
public Vector2 pos;
|
||||
public string anchorPath;
|
||||
public float textDelayed;
|
||||
public string textContent;
|
||||
[Header("Finger")]
|
||||
public bool isFinger = true;
|
||||
public FingerType fingerType;
|
||||
public float holdTime;
|
||||
public float fingerRotate;
|
||||
public float fingerDelayed;
|
||||
[Header("Complete")]
|
||||
public CompleteType completeType;
|
||||
public string completeTypeParameter;
|
||||
public bool isDelayedClick;
|
||||
public float clickDelayed;
|
||||
public bool isOutHide;
|
||||
public float outHideDelayed;
|
||||
|
||||
public bool isAutoNext = true;
|
||||
|
||||
public string hideRootPath;
|
||||
public bool endAutoShow = true;
|
||||
public string showRootPath;
|
||||
public bool isKey;
|
||||
public int JumpIndex;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GuidanceGroupDefine
|
||||
{
|
||||
public string Description;
|
||||
public GroupName groupName;
|
||||
public GuideTriggerConditions TriggerConditionsType;
|
||||
public string TriggerConditionsParameter;
|
||||
public GuidanceDefine[] guidanceDefines;
|
||||
}
|
||||
public class GuidanceDefineSetting : ScriptableObject
|
||||
{
|
||||
public float duration = 0.3f;
|
||||
public int MaxClickNum = 5;
|
||||
public float ShowSkipTimer = 5f;
|
||||
public List<GroupName> SkipGroupNames = new List<GroupName>();
|
||||
public int SkipLevel = 40;
|
||||
public GuidanceGroupDefine[] guidanceGroupDefines;
|
||||
}
|
||||
11
Assets/Scripts/UI/Guidance/GuidanceDefineSetting.cs.meta
Normal file
11
Assets/Scripts/UI/Guidance/GuidanceDefineSetting.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4ea912b51eab064fb7855e5277fa7ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
588
Assets/Scripts/UI/Guidance/GuidancePanel.cs
Normal file
588
Assets/Scripts/UI/Guidance/GuidancePanel.cs
Normal file
@@ -0,0 +1,588 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class IsShowGuidance
|
||||
{
|
||||
public bool isStop = false;
|
||||
public bool isShow = false;
|
||||
public string curIndexDes = "";
|
||||
public int curIndex;
|
||||
public GroupName curGroupName;
|
||||
public FingerType fingerType;
|
||||
public TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
public class GuidancePanel : MonoBehaviour
|
||||
{
|
||||
public Image mask;
|
||||
public Button maskBg;
|
||||
public Button btn_skip;
|
||||
public UIButtonDouble btn_next;
|
||||
public RectTransform Hollowed;
|
||||
public GameObject subCircleMask;
|
||||
public GameObject subRectMask;
|
||||
public Button btn_next_all;
|
||||
public Transform finger;
|
||||
Animator animator;
|
||||
public GameObject npc_chat1;
|
||||
public GameObject npc_chat2;
|
||||
public GameObject chat;
|
||||
public TMP_Text text_chat1;
|
||||
public TMP_Text text_chat2;
|
||||
public TMP_Text text_chat3;
|
||||
public RectTransform arrow_down;
|
||||
public RectTransform arrow_up;
|
||||
public RectTransform arrow_left;
|
||||
public RectTransform arrow_right;
|
||||
public Transform TargetNode;
|
||||
public GameObject hideGo;
|
||||
public float clickDelayed;
|
||||
float duration;
|
||||
int clickCount;
|
||||
float height;
|
||||
AssetReferenceAudioVoiceClip data;
|
||||
public static GuidancePanel Instance;
|
||||
IDisposable disposable;
|
||||
IDisposable disposable1;
|
||||
GuidanceDefine curDefine;
|
||||
IsShowGuidance isShowGuidance;
|
||||
bool isDown;
|
||||
float startTimer;
|
||||
float endTimer;
|
||||
bool isStop;
|
||||
Canvas TopRoot;
|
||||
GraphicRaycaster graphicRaycaster;
|
||||
List<Canvas> canvasList = new List<Canvas>();
|
||||
List<GraphicRaycaster> raycastResults = new List<GraphicRaycaster>();
|
||||
Coroutine coroutine;
|
||||
GuideDataCenter guideDataCenter;
|
||||
private void Awake()
|
||||
{
|
||||
guideDataCenter = GContext.container.Resolve<GuideDataCenter>();
|
||||
|
||||
Hollowed = transform.Find("Hollowed").GetComponent<RectTransform>();
|
||||
mask = transform.Find("mask").GetComponent<Image>();
|
||||
maskBg = transform.Find("TopRoot/maskBg").GetComponent<Button>();
|
||||
btn_skip = transform.Find("TopRoot/btn_skip").GetComponent<Button>();
|
||||
btn_next = transform.Find("TopRoot/btn_next").GetComponent<UIButtonDouble>();
|
||||
subCircleMask = Hollowed.transform.Find("Circle").gameObject;
|
||||
subRectMask = Hollowed.transform.Find("Rect").gameObject;
|
||||
|
||||
btn_next_all = transform.Find("TopRoot/btn_next_all").GetComponent<Button>();
|
||||
btn_next.ExecuteCount = 2;
|
||||
|
||||
TopRoot = transform.Find("TopRoot").GetComponent<Canvas>();
|
||||
graphicRaycaster = TopRoot.GetComponent<GraphicRaycaster>();
|
||||
finger = transform.Find("TopRoot/finger");
|
||||
animator = finger.GetComponent<Animator>();
|
||||
npc_chat1 = transform.Find("TopRoot/npc_chat1").gameObject;
|
||||
npc_chat2 = transform.Find("TopRoot/npc_chat2").gameObject;
|
||||
chat = transform.Find("TopRoot/chat").gameObject;
|
||||
text_chat1 = npc_chat1.transform.Find("bg/text_info").GetComponent<TMP_Text>();
|
||||
text_chat2 = npc_chat2.transform.Find("text_info").GetComponent<TMP_Text>();
|
||||
text_chat3 = chat.transform.Find("bg/text_info").GetComponent<TMP_Text>();
|
||||
|
||||
arrow_down = chat.transform.Find("bg/arrow_down").GetComponent<RectTransform>();
|
||||
arrow_up = chat.transform.Find("bg/arrow_up").GetComponent<RectTransform>();
|
||||
arrow_left = chat.transform.Find("bg/arrow_left").GetComponent<RectTransform>();
|
||||
arrow_right = chat.transform.Find("bg/arrow_right").GetComponent<RectTransform>();
|
||||
|
||||
Vector2 sizeDelta = UIManager.Instance.RectTrans.sizeDelta;
|
||||
height = sizeDelta.y;
|
||||
duration = guideDataCenter.guidanceDefineSetting.duration;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
btn_next.onUp.AddListener(OnUp);
|
||||
btn_next.onDown.AddListener(OnDown);
|
||||
btn_next.onClick.AddListener(Next);
|
||||
btn_next_all.onClick.AddListener(Next);
|
||||
maskBg.onClick.AddListener(AddClickCount);
|
||||
btn_skip.onClick.AddListener(SkipNext);
|
||||
}
|
||||
void OnUp()
|
||||
{
|
||||
isDown = false;
|
||||
endTimer = Time.time - startTimer;
|
||||
}
|
||||
private void OnDown()
|
||||
{
|
||||
if (curDefine.completeType == CompleteType.Down)
|
||||
{
|
||||
btn_next.OnPointerUp(btn_next.PointerEventData);
|
||||
AddIndex(false);
|
||||
return;
|
||||
}
|
||||
isDown = true;
|
||||
startTimer = Time.time;
|
||||
GuidanceDefine guidanceDefine = curDefine;
|
||||
if (coroutine != null)
|
||||
{
|
||||
StopCoroutine(coroutine);
|
||||
}
|
||||
coroutine = StartCoroutine(OnDownIng(guidanceDefine));
|
||||
}
|
||||
IEnumerator OnDownIng(GuidanceDefine guidanceDefine)
|
||||
{
|
||||
yield return new WaitForSeconds(curDefine.holdTime);
|
||||
if (isDown && curDefine.fingerType == FingerType.Hold && guidanceDefine == curDefine)
|
||||
{
|
||||
OnUp();
|
||||
AddIndex(false);
|
||||
}
|
||||
}
|
||||
void AddClickCount()
|
||||
{
|
||||
clickCount++;
|
||||
if (clickCount >= guideDataCenter.guidanceDefineSetting.MaxClickNum)
|
||||
{
|
||||
btn_skip.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void OnEnable()
|
||||
{
|
||||
guideDataCenter = GContext.container.Resolve<GuideDataCenter>();
|
||||
|
||||
curDefine = guideDataCenter.curDefine;
|
||||
transform.SetAsLastSibling();
|
||||
clickCount = 0;
|
||||
btn_skip.gameObject.SetActive(false);
|
||||
finger.gameObject.SetActive(false);
|
||||
btn_next.gameObject.SetActive(false);
|
||||
btn_next_all.gameObject.SetActive(false);
|
||||
|
||||
arrow_down.gameObject.SetActive(false);
|
||||
arrow_up.gameObject.SetActive(false);
|
||||
arrow_left.gameObject.SetActive(false);
|
||||
arrow_right.gameObject.SetActive(false);
|
||||
string CurPanelName = guideDataCenter.CurPanelName;
|
||||
if (string.IsNullOrEmpty(CurPanelName))
|
||||
{
|
||||
CurPanelName = curDefine.panelName;
|
||||
}
|
||||
Transform panel = UIManager.Instance.UICanvas.transform.Find(CurPanelName);
|
||||
if (panel == null)
|
||||
{
|
||||
panel = UIManager.Instance.UICanvas.transform.Find(CurPanelName + "(Clone)");
|
||||
}
|
||||
if (panel != null)
|
||||
{
|
||||
hideGo = null;
|
||||
string path;
|
||||
if (!string.IsNullOrEmpty(curDefine.hideRootPath))
|
||||
{
|
||||
path = curDefine.hideRootPath;
|
||||
if (path.Contains(curDefine.hideRootPath + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
hideGo = panel.transform.Find(path).gameObject;
|
||||
}
|
||||
if (hideGo != null)
|
||||
{
|
||||
hideGo.SetActive(false);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(curDefine.showRootPath))
|
||||
{
|
||||
path = curDefine.showRootPath;
|
||||
if (path.Contains(curDefine.showRootPath + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
GameObject showGo = panel.transform.Find(path).gameObject;
|
||||
if (showGo != null)
|
||||
{
|
||||
showGo.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isStop = false;
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(SetMask(curDefine, panel));
|
||||
StartCoroutine(SetTextBox(curDefine, panel));
|
||||
if (curDefine.isFinger)
|
||||
{
|
||||
StartCoroutine(ShowFinger(panel));
|
||||
}
|
||||
clickDelayed = 0.1f;
|
||||
if (curDefine.isDelayedClick)
|
||||
{
|
||||
clickDelayed = curDefine.clickDelayed;
|
||||
if (clickDelayed < curDefine.fingerDelayed)
|
||||
{
|
||||
clickDelayed = curDefine.fingerDelayed;
|
||||
}
|
||||
if (clickDelayed < curDefine.maskDelayed)
|
||||
{
|
||||
clickDelayed = curDefine.maskDelayed;
|
||||
}
|
||||
if (clickDelayed < curDefine.textDelayed)
|
||||
{
|
||||
clickDelayed = curDefine.textDelayed;
|
||||
}
|
||||
}
|
||||
StartCoroutine(ShowBtnNext(panel));
|
||||
StartCoroutine(ShowSkip());
|
||||
disposable = GContext.OnEvent<IsShowGuidance>().Subscribe(IsShowGuidance);
|
||||
disposable1 = GContext.OnEvent<GetUIAsyncEvent>().Subscribe(OnGetUIAsyncEvent);
|
||||
}
|
||||
void ShowHighlightedNode(Transform panel)
|
||||
{
|
||||
if (curDefine.highlightedNode != null && curDefine.highlightedNode.Length > 0)
|
||||
{
|
||||
string path;
|
||||
for (int i = 0; i < curDefine.highlightedNode.Length; i++)
|
||||
{
|
||||
path = curDefine.highlightedNode[i];
|
||||
if (path.Contains(curDefine.panelName + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
var node = panel.transform.Find(path);
|
||||
if (node != null)
|
||||
{
|
||||
Canvas canvas = node.gameObject.AddComponent<Canvas>();
|
||||
canvas.overrideSorting = true;
|
||||
canvas.sortingOrder = TopRoot.sortingOrder - 1;
|
||||
canvas.additionalShaderChannels = AdditionalCanvasShaderChannels.TexCoord1;
|
||||
canvasList.Add(canvas);
|
||||
GraphicRaycaster raycast = node.gameObject.AddComponent<GraphicRaycaster>();
|
||||
raycastResults.Add(raycast);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnGetUIAsyncEvent(GetUIAsyncEvent data)
|
||||
{
|
||||
if (data.show && data.uIType != UITypes.RewardPopupPanel.Name)
|
||||
{
|
||||
transform.SetAsLastSibling();
|
||||
}
|
||||
}
|
||||
void IsShowGuidance(IsShowGuidance data)
|
||||
{
|
||||
isShowGuidance = data;
|
||||
isShowGuidance.isShow = true;
|
||||
isShowGuidance.isStop = isStop;
|
||||
isShowGuidance.curIndexDes = curDefine.Description;
|
||||
isShowGuidance.curIndex = guideDataCenter.curSaveData.guideSubIndex;
|
||||
isShowGuidance.curGroupName = guideDataCenter.curGroupDefine.groupName;
|
||||
isShowGuidance.fingerType = curDefine.fingerType;
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
foreach (var item in raycastResults)
|
||||
{
|
||||
DestroyImmediate(item);
|
||||
}
|
||||
raycastResults.Clear();
|
||||
for (int i = 0; i < canvasList.Count; i++)
|
||||
{
|
||||
DestroyImmediate(canvasList[i]);
|
||||
}
|
||||
canvasList.Clear();
|
||||
if (isShowGuidance != null)
|
||||
{
|
||||
isShowGuidance.tcs.SetResult(true);
|
||||
isShowGuidance = null;
|
||||
}
|
||||
if (disposable != null)
|
||||
{
|
||||
disposable.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
if (disposable1 != null)
|
||||
{
|
||||
disposable1.Dispose();
|
||||
disposable1 = null;
|
||||
}
|
||||
}
|
||||
IEnumerator ShowSkip()
|
||||
{
|
||||
yield return new WaitForSeconds(GContext.container.Resolve<GuideDataCenter>().guidanceDefineSetting.ShowSkipTimer);
|
||||
btn_skip.gameObject.SetActive(true);
|
||||
}
|
||||
IEnumerator ShowBtnNext(Transform panel)
|
||||
{
|
||||
GuidanceDefine guidanceDefine = curDefine;
|
||||
yield return new WaitForSeconds(clickDelayed);
|
||||
isStop = true;
|
||||
if (curDefine.maskType != MaskType.None)
|
||||
{
|
||||
if (curDefine.completeType == CompleteType.ClickSpace)
|
||||
{
|
||||
btn_next_all.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 vector2 = new Vector2(curDefine.maskRadius, curDefine.maskRadius);
|
||||
if (!string.IsNullOrEmpty(curDefine.buttonPath))
|
||||
{
|
||||
string path = curDefine.buttonPath;
|
||||
if (path.Contains(curDefine.panelName + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
TargetNode = panel.transform.Find(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetNode = null;
|
||||
}
|
||||
if (TargetNode != null)
|
||||
{
|
||||
btn_next.transform.position = TargetNode.position;
|
||||
var rect = TargetNode.GetComponent<RectTransform>();
|
||||
vector2 = rect.rect.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_next.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
btn_next.GetComponent<RectTransform>().sizeDelta = vector2;
|
||||
btn_next.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_next.transform.localPosition = Vector3.zero;
|
||||
btn_next.GetComponent<RectTransform>().sizeDelta = new Vector2(height, height);
|
||||
btn_next.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (guidanceDefine.isOutHide)
|
||||
{
|
||||
yield return new WaitForSeconds(guidanceDefine.outHideDelayed);
|
||||
if (guidanceDefine == curDefine)
|
||||
{
|
||||
OnUp();
|
||||
AddIndex(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ShowFinger(Transform panel)
|
||||
{
|
||||
yield return new WaitForSeconds(curDefine.fingerDelayed);
|
||||
if (!string.IsNullOrEmpty(curDefine.buttonPath))
|
||||
{
|
||||
string path = curDefine.buttonPath;
|
||||
if (path.Contains(curDefine.panelName + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
TargetNode = panel.transform.Find(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetNode = null;
|
||||
}
|
||||
if (TargetNode != null)
|
||||
{
|
||||
finger.position = TargetNode.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
finger.localPosition = Vector3.zero;
|
||||
}
|
||||
finger.gameObject.SetActive(true);
|
||||
switch (curDefine.fingerType)
|
||||
{
|
||||
case FingerType.Hold:
|
||||
animator.Play("finger_loop2");
|
||||
break;
|
||||
case FingerType.Slid:
|
||||
animator.Play("finger_loop3");
|
||||
break;
|
||||
default:
|
||||
animator.Play("finger_loop");
|
||||
break;
|
||||
}
|
||||
finger.localEulerAngles = Vector3.forward * curDefine.fingerRotate;
|
||||
}
|
||||
IEnumerator SetMask(GuidanceDefine guide, Transform panel)
|
||||
{
|
||||
Hollowed.gameObject.SetActive(guide.maskType == MaskType.Black);
|
||||
subCircleMask.gameObject.SetActive(curDefine.hollowedType == HollowedType.Circle);
|
||||
subRectMask.gameObject.SetActive(curDefine.hollowedType == HollowedType.Rect);
|
||||
if (guide.maskType == MaskType.Black)
|
||||
{
|
||||
Vector2 vector2 = new Vector2(curDefine.maskRadius, curDefine.maskRadius);
|
||||
Hollowed.transform.localPosition = Vector3.zero;
|
||||
Hollowed.sizeDelta = new Vector2(height * 2, height * 2);
|
||||
yield return new WaitForSeconds(curDefine.maskDelayed);
|
||||
if (!string.IsNullOrEmpty(curDefine.buttonPath))
|
||||
{
|
||||
string path = curDefine.buttonPath;
|
||||
if (path.Contains(curDefine.panelName + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
TargetNode = panel.transform.Find(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetNode = null;
|
||||
}
|
||||
if (TargetNode != null)
|
||||
{
|
||||
var rect = TargetNode.GetComponent<RectTransform>().rect.size;
|
||||
if (guide.hollowedType == HollowedType.Rect)
|
||||
{
|
||||
vector2 = new Vector2(rect.x + 70, rect.y + 70) - vector2;
|
||||
if (vector2.y < 0)
|
||||
{
|
||||
vector2.y = 1;
|
||||
}
|
||||
if (vector2.x < 0)
|
||||
{
|
||||
vector2.x = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Hollowed.sizeDelta = new Vector2(height, height);
|
||||
}
|
||||
if (TargetNode != null)
|
||||
{
|
||||
Hollowed.transform.position = TargetNode.position;
|
||||
}
|
||||
Hollowed.DOSizeDelta(vector2, duration);
|
||||
isStop = true;
|
||||
}
|
||||
mask.gameObject.SetActive(guide.maskType == MaskType.Black);
|
||||
if (panel != null)
|
||||
{
|
||||
ShowHighlightedNode(panel);
|
||||
}
|
||||
}
|
||||
IEnumerator SetTextBox(GuidanceDefine guide, Transform panel)
|
||||
{
|
||||
npc_chat1.SetActive(false);
|
||||
npc_chat2.SetActive(false);
|
||||
chat.SetActive(false);
|
||||
GameObject skip = null;
|
||||
yield return new WaitForSeconds(guide.textDelayed);
|
||||
Rect rect = transform.GetComponent<RectTransform>().rect;
|
||||
float height = rect.height;
|
||||
var pos = guide.pos;
|
||||
pos.y *= height / 2340;
|
||||
Transform anchor = null;
|
||||
if (!string.IsNullOrEmpty(guide.anchorPath) && panel != null)
|
||||
{
|
||||
string path = guide.anchorPath;
|
||||
if (path.Contains(curDefine.panelName + "/"))
|
||||
{
|
||||
path = path.Substring(path.IndexOf('/') + 1);
|
||||
}
|
||||
anchor = panel.transform.Find(path);
|
||||
}
|
||||
if (guide.textBoxType == TextBoxType.Head)
|
||||
{
|
||||
text_chat1.text = LocalizationMgr.GetText(guide.textContent);
|
||||
if (anchor != null)
|
||||
{
|
||||
var position = anchor.position;
|
||||
position.x = npc_chat1.transform.position.x;
|
||||
position.z = npc_chat1.transform.position.z;
|
||||
npc_chat1.transform.position = position;
|
||||
npc_chat1.GetComponent<RectTransform>().anchoredPosition += guide.pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
npc_chat1.GetComponent<RectTransform>().anchoredPosition = pos;
|
||||
}
|
||||
npc_chat1.SetActive(true);
|
||||
skip = npc_chat1.transform.Find("bg/skip").gameObject;
|
||||
}
|
||||
else if (guide.textBoxType == TextBoxType.All)
|
||||
{
|
||||
text_chat2.text = LocalizationMgr.GetText(guide.textContent);
|
||||
npc_chat2.SetActive(true);
|
||||
skip = npc_chat2.transform.Find("skip").gameObject;
|
||||
}
|
||||
else if (guide.textBoxType == TextBoxType.NoHead || guide.textBoxType == TextBoxType.NoArrow)
|
||||
{
|
||||
text_chat3.text = LocalizationMgr.GetText(guide.textContent);
|
||||
if (anchor != null)
|
||||
{
|
||||
var position = anchor.position;
|
||||
position.x = npc_chat1.transform.position.x;
|
||||
position.z = npc_chat1.transform.position.z;
|
||||
chat.transform.position = position;
|
||||
chat.GetComponent<RectTransform>().anchoredPosition += guide.pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
chat.GetComponent<RectTransform>().anchoredPosition = pos;
|
||||
}
|
||||
chat.SetActive(true);
|
||||
skip = chat.transform.Find("skip").gameObject;
|
||||
}
|
||||
else if (guide.textBoxType == TextBoxType.Popup)
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().ShowGuidancePopupPanel(guide.popupNode);
|
||||
}
|
||||
if (guide.assetReference != null && guide.assetReference.RuntimeKeyIsValid())
|
||||
{
|
||||
data = new AssetReferenceAudioVoiceClip(guide.assetReference);
|
||||
GContext.Publish(data);
|
||||
}
|
||||
if (skip != null)
|
||||
{
|
||||
skip.SetActive(false);
|
||||
}
|
||||
}
|
||||
void SkipNext()
|
||||
{
|
||||
AddIndex(true);
|
||||
}
|
||||
void Next()
|
||||
{
|
||||
if (curDefine.fingerType == FingerType.Hold && curDefine.holdTime > endTimer - 0.001f || curDefine.fingerType == FingerType.Slid || curDefine.completeType == CompleteType.Down)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AddIndex(false);
|
||||
}
|
||||
|
||||
void AddIndex(bool is_pass)
|
||||
{
|
||||
if (hideGo != null && curDefine.endAutoShow)
|
||||
{
|
||||
hideGo.SetActive(true);
|
||||
}
|
||||
if (data != null && data.Sound != null)
|
||||
{
|
||||
GContext.Publish(new FadeOutEvent(data.Sound));
|
||||
}
|
||||
GContext.container.Resolve<GuideDataCenter>().AddIndex(is_pass);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F1))
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().GMClearGuide();
|
||||
UIManager.Instance.DestroyUI(UITypes.GuidancePanel);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
Assets/Scripts/UI/Guidance/GuidancePanel.cs.meta
Normal file
11
Assets/Scripts/UI/Guidance/GuidancePanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb24b7bb464c29418ed6e73654f5d03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Guidance/GuidancePopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Guidance/GuidancePopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a24c921922060a4a8a600a6728bf3a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
303
Assets/Scripts/UI/Guidance/GuideTriggerConditions.cs
Normal file
303
Assets/Scripts/UI/Guidance/GuideTriggerConditions.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
public enum GuideTriggerConditions
|
||||
{
|
||||
//上一组完成
|
||||
Next,
|
||||
|
||||
//商店系统打开
|
||||
OpenSystem_Shop,
|
||||
|
||||
//玩家首次登录
|
||||
First_login,
|
||||
|
||||
//玩家解锁图鉴系统时
|
||||
UnlockSystem_Album,
|
||||
|
||||
//测试用,玩家等级达到2级
|
||||
Level_2,
|
||||
|
||||
//某个group完成,参数填groupname
|
||||
Group_Finish,
|
||||
|
||||
//钓到不同鱼的数量,参数填鱼的数量
|
||||
GetDiffFishCount,
|
||||
|
||||
//玩家解锁第二张地图后首次打开map界面
|
||||
FirstClickMap_AtMap2,
|
||||
|
||||
//玩家的账号等级达到x
|
||||
AccountLevel,
|
||||
|
||||
//None
|
||||
None,
|
||||
|
||||
//熟练度积分等级
|
||||
FishMasteryLevel,
|
||||
|
||||
//解锁某个功能时
|
||||
UnlockSystem,
|
||||
|
||||
//钓到鱼的数量,和event的GetFishCount相同
|
||||
GetFishCount,
|
||||
|
||||
//玩家第一次解锁{0}为最大倍率时,参数填倍率,比如想要玩家在第一次解锁10倍率的时候引导,则填10
|
||||
MaxMultiplierCount,
|
||||
|
||||
//玩家获得第二根杆时
|
||||
GetSecondRod,
|
||||
|
||||
//第一次有杆可以强化的时候,
|
||||
RodAscendAvailable,
|
||||
|
||||
//玩家购买礼包,参数填shop表里礼包的主键
|
||||
BuyPack,
|
||||
|
||||
//玩家第一次有杆可以升级的时候,
|
||||
RodUpgradeAvailable,
|
||||
|
||||
//钓箱开启必要条件,玩家需要有紫色钓箱
|
||||
BoxOpenCondition,
|
||||
|
||||
//玩家前期张力过大触发失败的
|
||||
HighTension,
|
||||
|
||||
//玩家前期张力过小触发失败的
|
||||
LowTension,
|
||||
|
||||
//解锁某个活动时 --TriggerConditionsParameter = 4-2 Type-SubType; 4-2-101 Type-SubType-RedirectID
|
||||
UnlockEvent,
|
||||
|
||||
//第一章,当检测到钞票足够完成地图建造时
|
||||
GoBuilding,
|
||||
|
||||
//鱼的道具id
|
||||
FishItemID,
|
||||
|
||||
//根据洗车步骤进行触发
|
||||
EventWashingStep,
|
||||
|
||||
//第一章,当检测到玩家钞票足够建到12级,指能够建完领取钓箱奖励
|
||||
GoBuilding02,
|
||||
|
||||
//幸运卡牌,玩家第一次翻到倍率卡牌触发
|
||||
LuckyCardMultiply,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加序号,方便后续添加新组
|
||||
/// </summary>
|
||||
public enum GroupName
|
||||
{
|
||||
//玩家首次登录钓鱼引导1
|
||||
Fish_01 = 0,
|
||||
//第二次简单引导玩家钓鱼
|
||||
Fish_02 = 1,
|
||||
//引导玩家建造
|
||||
Build = 2,
|
||||
//引导玩家点击世界查看图鉴
|
||||
Map = 3,
|
||||
//引导玩家如何切换地图
|
||||
MapSwitch = 4,
|
||||
//建造长按弱引导
|
||||
BuildHold = 5,
|
||||
//没钞票时引导去钓鱼
|
||||
Fixguidance = 6,
|
||||
//引导装备新的紫色鱼竿
|
||||
Rod_01 = 7,
|
||||
//引导鱼竿强化
|
||||
Rod_02 = 8,
|
||||
//引导玩家钓鱼倍率
|
||||
Fish_03 = 9,
|
||||
//转盘玩法引导
|
||||
Wheel = 10,
|
||||
//轰炸玩法引导
|
||||
Bomb_01 = 11,
|
||||
//fixguidance之后的引导,为了实现让玩家首次点击时的一整套,第二次点击时只是弹窗的引导
|
||||
Fixguidance_01 = 12,
|
||||
//建造点击第六下,单独配置组
|
||||
Build_02 = 13,
|
||||
//第二次引导玩家调整倍率
|
||||
Fish_04 = 14,
|
||||
//自动钓鱼引导
|
||||
AutoFish = 15,
|
||||
|
||||
//进阶鱼竿-限定礼包引导
|
||||
Rod_03 = 16,
|
||||
|
||||
//进阶礼包-鱼竿大礼包引导
|
||||
Rod_04 = 17,
|
||||
|
||||
//引导玩家修改个人信息
|
||||
PlayerInformation = 18,
|
||||
|
||||
//公会新手引导
|
||||
Social = 19,
|
||||
|
||||
//刺鱼引导
|
||||
StabFish = 20,
|
||||
|
||||
//钓箱补给
|
||||
BoxOpen = 21,
|
||||
|
||||
//玩家购买完首充礼包后的引导,衔接首充礼包链
|
||||
BuyPack01 = 22,
|
||||
|
||||
//商店未解锁前,玩家第一次体力不足引导去建造
|
||||
Fixguidance_02 = 23,
|
||||
|
||||
//钓鱼挑战赛
|
||||
Chanllenge = 24,
|
||||
|
||||
//张力过大引导
|
||||
Tension01 = 25,
|
||||
|
||||
//张力过小引导
|
||||
Tension02 = 26,
|
||||
|
||||
//沙滩寻宝引导
|
||||
BeachTreasure = 27,
|
||||
|
||||
//第一章引导玩家去建造
|
||||
GoBuilding = 28,
|
||||
|
||||
//某个鱼放技能时触发引导
|
||||
FishSkill01 = 29,
|
||||
FishSkill02 = 30,
|
||||
|
||||
//根据洗游艇步骤进行触发
|
||||
EventWashing01 = 31,
|
||||
EventWashing02 = 32,
|
||||
EventWashing03 = 33,
|
||||
EventWashing04 = 34,
|
||||
EventWashing05 = 35,
|
||||
EventWashing06 = 36,
|
||||
EventWashing07 = 37,
|
||||
EventWashing08 = 38,
|
||||
EventWashing09 = 39,
|
||||
EventWashing10 = 40,
|
||||
EventWashing11 = 41,
|
||||
//洗卡车新手引导
|
||||
EventWashingCar01 = 42,
|
||||
EventWashingCar02 = 43,
|
||||
EventWashingCar03 = 44,
|
||||
EventWashingCar04 = 45,
|
||||
EventWashingCar05 = 46,
|
||||
EventWashingCar06 = 47,
|
||||
EventWashingCar07 = 48,
|
||||
EventWashingCar08 = 49,
|
||||
EventWashingCar09 = 50,
|
||||
EventWashingCar10 = 51,
|
||||
EventWashingCar0201 = 52,
|
||||
EventWashingCar0202 = 53,
|
||||
EventWashingCar0203 = 54,
|
||||
EventWashingCar0204 = 55,
|
||||
EventWashingCar0205 = 56,
|
||||
EventWashingCar0206 = 57,
|
||||
EventWashingCar0207 = 58,
|
||||
EventWashingCar0208 = 59,
|
||||
EventWashingCar0209 = 60,
|
||||
EventWashingCar0210 = 61,
|
||||
|
||||
//靶场射击活动引导
|
||||
Shooting = 62,
|
||||
|
||||
//魔药
|
||||
EventPotion01 = 63,
|
||||
EventPotion02 = 64,
|
||||
|
||||
//水族馆新手引导
|
||||
AquariumGuidance01 = 65,
|
||||
AquariumGuidance02 = 66,
|
||||
|
||||
//刺鱼新手引导
|
||||
Raid = 67,
|
||||
Raid02 = 68,
|
||||
|
||||
//第六条鱼的新手引导
|
||||
FishEscape = 69,
|
||||
|
||||
//玩家的钱够建到12级的时候引导玩家建造
|
||||
GoBuilding02 = 70,
|
||||
|
||||
//沼泽之王新手引导
|
||||
FishSkill03 = 71,
|
||||
|
||||
//电钻活动引导
|
||||
Drilling = 72,
|
||||
|
||||
//鱼缸建造新手引导
|
||||
Partner01 = 73,
|
||||
|
||||
//弹珠新手引导
|
||||
Pinball01 = 74,
|
||||
|
||||
//开完钓箱后的弱引导
|
||||
Build02 = 75,
|
||||
|
||||
//升级完鱼卡获得战令奖励以后引导玩家调整倍率为10
|
||||
MultiplierChange01 = 76,
|
||||
|
||||
//领取progess奖励
|
||||
ProgessRewardClaim01 = 77,
|
||||
|
||||
//幸运卡牌引导
|
||||
LuckyCard01 = 78,
|
||||
LuckyCard02 = 79,
|
||||
|
||||
//新手礼包引导
|
||||
BeginnerPack01 = 80,
|
||||
|
||||
//足球靶场射击引导
|
||||
Shooting_02,
|
||||
}
|
||||
public enum CompleteType
|
||||
{
|
||||
None,
|
||||
ClickSpace,
|
||||
ClickButton,
|
||||
PanelOpen,
|
||||
Down,
|
||||
}
|
||||
|
||||
public enum MaskType
|
||||
{
|
||||
None,
|
||||
Transparent,
|
||||
Black,
|
||||
}
|
||||
public enum HollowedType
|
||||
{
|
||||
Rect,
|
||||
Circle,
|
||||
}
|
||||
|
||||
public enum TextBoxType
|
||||
{
|
||||
None,
|
||||
All,
|
||||
Head,
|
||||
NoHead,
|
||||
NoArrow,
|
||||
Popup,
|
||||
}
|
||||
public enum FingerType
|
||||
{
|
||||
None,
|
||||
Hold,
|
||||
Slid,
|
||||
}
|
||||
|
||||
11
Assets/Scripts/UI/Guidance/GuideTriggerConditions.cs.meta
Normal file
11
Assets/Scripts/UI/Guidance/GuideTriggerConditions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d0d8b1b7a2a1b64a9a6ca068c00cb3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user