291 lines
		
	
	
		
			7.0 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			291 lines
		
	
	
		
			7.0 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using DG.Tweening; | |||
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using TMPro; | |||
|  | using Unity.VisualScripting; | |||
|  | using UnityEngine; | |||
|  | using UnityEngine.Events; | |||
|  | using UnityEngine.UI; | |||
|  | 
 | |||
|  | /// <summary> | |||
|  | /// <20><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | |||
|  | /// </summary> | |||
|  | public enum E_HandAniKindType  | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     Tap, | |||
|  |     /// <summary> | |||
|  |     /// <20><> | |||
|  |     /// </summary> | |||
|  |     Slide, | |||
|  |     /// <summary> | |||
|  |     /// ˫<><CBAB> | |||
|  |     /// </summary> | |||
|  |     DoubleClick, | |||
|  | } | |||
|  | /// <summary> | |||
|  | /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD> | |||
|  | /// </summary> | |||
|  | public enum E_FocusType | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     Square, | |||
|  |     /// <summary> | |||
|  |     /// Բ<><D4B2> | |||
|  |     /// </summary> | |||
|  |     Round, | |||
|  | } | |||
|  | 
 | |||
|  | /// <summary> | |||
|  | /// <20><><EFBFBD><EFBFBD>UI | |||
|  | /// </summary> | |||
|  | public class TeachUI : UIBaseClass | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״ | |||
|  |     /// </summary> | |||
|  |     public Image focus; | |||
|  |      | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public Image tapEvent; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>۽<EFBFBD><DBBD><EFBFBD>ͼ | |||
|  |     /// </summary> | |||
|  |     public Image focusBM; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public TextMeshProUGUI talkText; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD>㰴ť | |||
|  |     /// </summary> | |||
|  |     public Button withDotsBtn; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>۽<EFBFBD>RectTransform | |||
|  |     /// </summary> | |||
|  |     public RectTransform lookRect; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>۽<EFBFBD><DBBD><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public GameObject lookNode; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public GameObject handNode; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public Animator handAni; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public GameObject talkObj; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>ϵ<EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public Transform upPoint; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public CanvasGroup maskBGCG; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ | |||
|  |     /// </summary> | |||
|  |     public CanvasGroup dialogueCG; | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><>ָ | |||
|  |     /// </summary> | |||
|  |     public CanvasGroup guidelinesCG; | |||
|  | 
 | |||
|  |     public override void OnShow() | |||
|  |     { | |||
|  |         base.OnShow(); | |||
|  |         HideAll(); | |||
|  |         SetTapEvent(false); | |||
|  |         dialogueCG.alpha = 0; | |||
|  |         guidelinesCG.alpha = 0; | |||
|  |         maskBGCG.alpha = 0; | |||
|  |     } | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD>þ۽<C3BE> | |||
|  |     /// </summary> | |||
|  |     /// <param name="pos">λ<><CEBB></param> | |||
|  |     /// <param name="size"><3E><>С</param> | |||
|  |     /// <param name="unityAction"><3E><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD></param> | |||
|  |     public void SetLookState(Vector3 pos, bool isUI,Vector2 size) | |||
|  |     { | |||
|  |         SetMaskBGCG(true); | |||
|  |         lookNode.gameObject.SetActive(true); | |||
|  |         if (isUI) | |||
|  |         { | |||
|  |             lookRect.position = pos; | |||
|  |         } | |||
|  |         else | |||
|  |         { | |||
|  |             bool isRect = RectTransformUtility.ScreenPointToLocalPointInRectangle(GetComponent<Canvas>().transform as RectTransform, pos, UIManager.Instance.uICamera, out Vector2 localPoint); | |||
|  |             if (isRect) | |||
|  |             { | |||
|  |                 lookRect.anchoredPosition = localPoint; | |||
|  |             } | |||
|  |         } | |||
|  |         lookRect.sizeDelta = new Vector2(1000, 1000); | |||
|  |         lookRect.DOKill(); | |||
|  |         lookRect.DOSizeDelta(size, 0.5f).SetUpdate(true); | |||
|  |     } | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD>ô<EFBFBD><C3B4>㰴ť | |||
|  |     /// </summary> | |||
|  |     /// <param name="pos">λ<><CEBB></param> | |||
|  |     /// <param name="size"><3E><>С</param> | |||
|  |     /// <param name="unityAction"><3E><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD></param> | |||
|  |     public void SetBtnState(Vector3 pos, Vector2 size, UnityAction unityAction) | |||
|  |     { | |||
|  |         withDotsBtn.gameObject.SetActive(true); | |||
|  |         withDotsBtn.transform.position = pos; | |||
|  |         (withDotsBtn.transform as RectTransform).sizeDelta = size; | |||
|  |         withDotsBtn.onClick.RemoveAllListeners(); | |||
|  |         withDotsBtn.onClick.AddListener(() => | |||
|  |         { | |||
|  |             unityAction?.Invoke(); | |||
|  |         }); | |||
|  |     } | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD>öԻ<C3B6> | |||
|  |     /// </summary> | |||
|  |     /// <param name="str"></param> | |||
|  |     public void SetTalkText(string str) | |||
|  |     { | |||
|  |         SetDialogueCGCG(true); | |||
|  |         talkObj.gameObject.SetActive(true); | |||
|  |         talkObj.transform.position = upPoint.transform.position; | |||
|  |         talkText.text=str; | |||
|  |         talkText.transform.DOKill(); | |||
|  |         talkText.transform.localScale = Vector3.one; | |||
|  |         talkText.transform.DOScale(Vector3.one * 1.1f, 0.5f).SetLoops(-1, LoopType.Yoyo).SetUpdate(true); | |||
|  |     } | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     /// <param name="pos">λ<><CEBB></param> | |||
|  |     /// <param name="kind"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param> | |||
|  |     public void SetHandState(Vector3 pos, E_HandAniKindType e_HandAniKind_Type) | |||
|  |     { | |||
|  |         SetGuidelinesCG(true); | |||
|  |         handNode.gameObject.SetActive(true); | |||
|  |         handNode.transform.position = pos; | |||
|  | 
 | |||
|  |         switch (e_HandAniKind_Type) | |||
|  |         { | |||
|  |             case E_HandAniKindType.Tap: | |||
|  |                 handAni.Play("Tap"); | |||
|  |                 break; | |||
|  |             case E_HandAniKindType.Slide: | |||
|  |                 handAni.Play("Slide"); | |||
|  |                 break; | |||
|  |             case E_HandAniKindType.DoubleClick: | |||
|  |                 handAni.Play("DoubleClick"); | |||
|  |                 break; | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public void SetMaskBGRay(bool isShow) | |||
|  |     { | |||
|  |         maskBGCG.blocksRaycasts = isShow; | |||
|  |     } | |||
|  | 
 | |||
|  |     public void SetFocus(E_FocusType e_FocusType) | |||
|  |     { | |||
|  |         switch (e_FocusType) | |||
|  |         { | |||
|  |             case E_FocusType.Square: | |||
|  |                 focus.sprite = null; | |||
|  |                 focusBM.sprite= YooAssetManager.Instance.LoadAssetSync<Sprite>(PackagesName.GameData, "Square"); | |||
|  |                 break; | |||
|  |             case E_FocusType.Round: | |||
|  |                 focus.sprite = YooAssetManager.Instance.LoadAssetSync<Sprite>(PackagesName.GameData, "NumberButton_Fill@2x"); | |||
|  |                 focusBM.sprite = YooAssetManager.Instance.LoadAssetSync<Sprite>(PackagesName.GameData, "Handle_Outline"); | |||
|  |                 break; | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     public void SetGuidelinesCG(bool isShow) | |||
|  |     { | |||
|  |         if (isShow) | |||
|  |         { | |||
|  |             guidelinesCG.DOFade(1, 0.5f).SetUpdate(true).SetUpdate(true); | |||
|  |         } | |||
|  |         else | |||
|  |         { | |||
|  |             guidelinesCG.DOFade(0, 0.5f).SetUpdate(true).SetUpdate(true); | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     public void SetDialogueCGCG(bool isShow) | |||
|  |     { | |||
|  |         if (isShow) | |||
|  |         { | |||
|  |             dialogueCG.DOFade(1, 0.5f).SetUpdate(true).SetUpdate(true); | |||
|  |         } | |||
|  |         else | |||
|  |         { | |||
|  |             dialogueCG.DOFade(0, 0.5f).SetUpdate(true).SetUpdate(true); | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     public void SetTapEvent(bool isShow) | |||
|  |     { | |||
|  |         tapEvent.gameObject.SetActive(isShow); | |||
|  |     } | |||
|  | 
 | |||
|  |     public void SetMaskBGCG(bool isShow) | |||
|  |     { | |||
|  |         maskBGCG.DOKill(); | |||
|  |         if(isShow) | |||
|  |         { | |||
|  |             maskBGCG.DOFade(1, 0.5f).SetUpdate(true); | |||
|  |         } | |||
|  |         else | |||
|  |         { | |||
|  |             maskBGCG.DOFade(0, 0.5f).SetUpdate(true); | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  | 
 | |||
|  |     /// <summary> | |||
|  |     /// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD> | |||
|  |     /// </summary> | |||
|  |     public void HideAll() | |||
|  |     { | |||
|  |         handNode.gameObject.SetActive(false); | |||
|  |         withDotsBtn.gameObject.SetActive(false); | |||
|  |         lookNode.gameObject.SetActive(false); | |||
|  |         talkObj.gameObject.SetActive(false); | |||
|  |         maskBGCG.alpha = 0; | |||
|  |     } | |||
|  | } |