public void ShowCurrentDialog() { LeanTween.cancel(gameObject); if (_currentDialogData == null) { FinishDialog(); return; } if (_currentDialogData.dialogNPCSide == Logic.Enums.DialogNPCSide.Left) { leftNPCRawImage.texture = ResMgr.instance.Load <Texture>(ResPath.GetNPCTexturePath(_currentDialogData.headIcon)); // leftNPCRawImage.SetNativeSize(); string leftNPCName = string.Empty; if (_currentDialogData.heroName == "hero_name_my") { leftNPCName = Logic.Game.Model.GameProxy.instance.AccountName; } else { leftNPCName = Localization.Get(_currentDialogData.heroName); } leftNPCNameText.text = leftNPCName; // leftNPCRawImage.gameObject.SetActive(true); // rightNPCRawImage.gameObject.SetActive(false); leftNPCRoot.SetActive(true); rightNPCRoot.SetActive(false); leftNPCNameFrameGameObject.gameObject.SetActive(true); rightNPCNameFrameGameObject.gameObject.SetActive(false); enterImage.rectTransform.localScale = new Vector3(1, 1, 1); enterImage.rectTransform.anchoredPosition = new Vector2(442, 72); } else { rightNPCRawImage.texture = ResMgr.instance.Load <Texture>(ResPath.GetNPCTexturePath(_currentDialogData.headIcon)); // rightNPCRawImage.SetNativeSize(); string rightNPCName = string.Empty; if (_currentDialogData.heroName == "hero_name_my") { rightNPCName = Logic.Game.Model.GameProxy.instance.AccountName; } else { rightNPCName = Localization.Get(_currentDialogData.heroName); } rightNPCNameText.text = rightNPCName; // leftNPCRawImage.gameObject.SetActive(false); // rightNPCRawImage.gameObject.SetActive(true); leftNPCRoot.SetActive(false); rightNPCRoot.SetActive(true); leftNPCNameFrameGameObject.gameObject.SetActive(false); rightNPCNameFrameGameObject.gameObject.SetActive(true); enterImage.rectTransform.localScale = new Vector3(-1, 1, 1); enterImage.rectTransform.anchoredPosition = new Vector2(-442, 72); } _realCharIndexList = RichTextFormatUtil.GetRTFStringRealCharIndexList(Localization.Get(_currentDialogData.message)); isPrinting = true; dialogText.text = string.Empty; enterImage.gameObject.SetActive(false); StartCoroutine("WaitAndPrint"); }
public void SetData(TutorialChapterData tutorialChapterData, TutorialStepData tutorialStepData) { _tutorialChapterData = tutorialChapterData; _tutorialStepData = tutorialStepData; _waitMSGIDList = new List <string>(_tutorialStepData.waitMSGIDList); for (int index = 0, count = _waitMSGIDList.Count; index < count; index++) { Observers.Facade.Instance.RegisterObserver(_waitMSGIDList[index].ToString(), OnReceiveWaitMSG); } if (_tutorialStepData.forceCompleteMSGIDList.Count > 0) { _forceCompleteMSGIDList = new List <string>(_tutorialStepData.forceCompleteMSGIDList); for (int index = 0, count = _forceCompleteMSGIDList.Count; index < count; index++) { Observers.Facade.Instance.RegisterObserver(_forceCompleteMSGIDList[index].ToString(), OnReceiveForceCompleteMSG); } } else { _forceCompleteMSGIDList = null; } _handRootOffset = tutorialStepData.handIndicatorOffset; _arrowRootOffset = tutorialStepData.arrowIndicatorOffset; maskImage.gameObject.SetActive(_tutorialStepData.enableMask); maskImage.GetComponent <UnityEngine.UI.Mask>().showMaskGraphic = _tutorialStepData.showMask; nextStepButton.gameObject.SetActive(_tutorialStepData.enableNextStepButton); if (_tutorialStepData.showDialog) { AnchorType dialogAnchorType = (AnchorType)Enum.Parse(typeof(AnchorType), _tutorialStepData.dialogAnchor); dialogRootRectTransform.anchorMin = GetAnchoredVector2(dialogAnchorType); dialogRootRectTransform.anchorMax = GetAnchoredVector2(dialogAnchorType); dialogRootRectTransform.pivot = GetAnchoredVector2(dialogAnchorType); dialogRootRectTransform.anchoredPosition = _tutorialStepData.dialogOffset; dialogText.text = Localization.Get(_tutorialStepData.dialogContentID); } if (_tutorialStepData.showNPC) { NPCShowData npcShowData = NPCShowData.GetNPCShowData(_tutorialStepData.npcShowID); string npcBodyPath = ResPath.GetNPCTexturePath(npcShowData.npc_name); string npcFacePath = ResPath.GetNPCTexturePath(npcShowData.faceDic[_tutorialStepData.npcFace]); npcBodyRawImage.texture = ResMgr.instance.Load <Texture>(npcBodyPath); npcBodyRawImage.SetNativeSize(); npcBodyRawImage.transform.localScale = new Vector3(_tutorialStepData.npcFlip ? -1 : 1, 1, 1); npcFaceRawImage.texture = ResMgr.instance.Load <Texture>(npcFacePath); npcFaceRawImage.SetNativeSize(); npcFaceRawImage.rectTransform.anchorMin = Vector2.zero; npcFaceRawImage.rectTransform.anchorMax = Vector2.zero; npcFaceRawImage.rectTransform.pivot = Vector2.zero; npcFaceRawImage.rectTransform.anchoredPosition = npcShowData.facePosition; AnchorType npcAnchorType = (AnchorType)Enum.Parse(typeof(AnchorType), _tutorialStepData.npcAnchor); npcBodyRawImage.rectTransform.anchorMin = GetAnchoredVector2(npcAnchorType); npcBodyRawImage.rectTransform.anchorMax = GetAnchoredVector2(npcAnchorType); npcBodyRawImage.rectTransform.pivot = GetAnchoredVector2(npcAnchorType); npcBodyRawImage.rectTransform.anchoredPosition = _tutorialStepData.npcOffset; } if (_tutorialStepData.showIllustrateImage) { illustrateRawImage.texture = ResMgr.instance.Load <Texture>(ResPath.GetTutorialIllustrateImagePath(_tutorialStepData.illustrateImageName)); illustrateRawImage.SetNativeSize(); illustrateRawImage.rectTransform.anchoredPosition = _tutorialStepData.illustrateImageAnchoredPosition; } illustrateRawImage.gameObject.SetActive(_tutorialStepData.showIllustrateImage); dialogRootRectTransform.gameObject.SetActive(_tutorialStepData.showDialog); npcBodyRawImage.gameObject.SetActive(_tutorialStepData.showNPC); // Add for masked ui path Transform maskedTarget = null; Transform maskedTransform = null; for (int index = 0, count = _tutorialStepData.maskedUIPathList.Count; index < count; index++) { maskedTarget = UIMgr.instance.GetParticularUITransform(_tutorialStepData.maskedUIPathList[index][0], _tutorialStepData.maskedUIPathList[index][1]); _maskedTargetTransformList.Add(maskedTarget); maskedTransform = Instantiate(maskedTarget); DestroyImmediate(maskedTransform.GetComponent <Button>()); DestroyImmediate(maskedTransform.GetComponent <Toggle>()); Image[] images = maskedTransform.GetComponentsInChildren <Image>(); for (int i = 0, imagesCount = images.Length; i < imagesCount; i++) { images[i].color = new Color(0, 0, 0, 0); } RawImage[] rawImages = maskedTransform.GetComponentsInChildren <RawImage>(); for (int i = 0, rawImagesCount = rawImages.Length; i < rawImagesCount; i++) { rawImages[i].color = new Color(0, 0, 0, 0); } maskedTransform.SetParent(maskedGameObjectsRoot, false); maskedTransform.position = new Vector3(maskedTarget.position.x, maskedTarget.position.y, 0); maskedTransform.SetAsFirstSibling(); _maskedTransformList.Add(maskedTransform); } // Add for masked ui path skipButton.gameObject.SetActive(_tutorialChapterData.isSkippable); SetTargetTransform(); }