From 22d482183aa44aa2ffd837d8939a7b0bd15d28b9 Mon Sep 17 00:00:00 2001 From: liuzhiwei <liuzhiwei@qq.com> Date: Thu, 29 Oct 2020 10:45:21 +0800 Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master --- Assets/Scripts/Guide/GuidePanel.cs | 102 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 82 insertions(+), 20 deletions(-) diff --git a/Assets/Scripts/Guide/GuidePanel.cs b/Assets/Scripts/Guide/GuidePanel.cs index a2427cf..551a121 100644 --- a/Assets/Scripts/Guide/GuidePanel.cs +++ b/Assets/Scripts/Guide/GuidePanel.cs @@ -3,7 +3,7 @@ using UnityEngine; using UnityEngine.UI; using System; - +using DG.Tweening; /// <summary> /// 新手引导UI脚本 /// </summary> @@ -20,6 +20,7 @@ private RectGuidance maskObj; private RectTransform image_Rim_Rect;//边框 + private GameObject particle_1, particle_2;//使用粒子特效 private RectTransform image_Tip_Rect;//可以移动的提示框 private Text text_Tip;//可以移动的提示框文字 @@ -42,6 +43,7 @@ Image backgroundImg;//用来接受空白点击事件的图片 + RectTransform dragHandImg;//拖动标识手指 /// <summary> /// 关闭所有UI /// </summary> @@ -80,6 +82,9 @@ } image_Rim_Rect = transform.Find("Image_Rim").GetComponent<RectTransform>(); + particle_1 = image_Rim_Rect.transform.Find("Particle System Small").gameObject; + particle_2 = image_Rim_Rect.transform.Find("Particle System Big").gameObject; + image_Tip_Rect = transform.Find("Image_Tip").GetComponent<RectTransform>(); text_Tip = image_Tip_Rect.transform.Find("Text").GetComponent<Text>(); image_SkillRim = transform.Find("Image_SkillRim").GetComponent<Image>(); @@ -104,6 +109,9 @@ skill = transform.Find("Image_Skill").GetComponent<ImageSkill>(); skill.gameObject.SetActive(false); + + dragHandImg = transform.Find("ImageHand").GetComponent<RectTransform>(); + dragHandImg.gameObject.SetActive(false); } /// <summary> @@ -148,7 +156,7 @@ Image btnImg = towerBuyBtn.GetComponent<Image>(); InitRectGuidance(btnImg, 189, 73.5f); SetRimPos(towerBuyBtn); - maskObj.ShowImmediately(); + //maskObj.ShowImmediately(); } else if (currentIndex == 1) @@ -175,6 +183,8 @@ fire2.gameObject.SetActive(true); fire2.enabled = false; DestoryButtonListener(towerBuyBtn); + SetRimActive(false); + CloseMask(); //RemoveButtonListener(towerBuyBtn); } @@ -186,8 +196,6 @@ { backgroundImg.raycastTarget = true; //RemoveButtonListener(towerBuyBtn); - SetRimActive(false); - CloseMask(); } /// <summary> @@ -197,6 +205,7 @@ { if (currentIndex == 0) { + tmpMask.enabled = true; SetGuideUI(false); @@ -204,6 +213,8 @@ SetRimPos(fire2.gameObject); fire1.enabled = true; fire2.enabled = true; + image_Tip_Rect.gameObject.SetActive(false); + ShowDragPath(fire2.GetStartP, fire1.GetRect); StartCoroutine(ShowRimTip(str)); } } @@ -212,7 +223,7 @@ public void Step3_2(string str) { SetRimPos(fire1.gameObject); - StartCoroutine(ShowRimTip(str)); + //StartCoroutine(ShowRimTip(str)); } /// <summary> @@ -229,13 +240,15 @@ towerPos.enabled = true; InitRectGuidance(btnImg, 75, 80); SetRimPos(btnImg.gameObject); - maskObj.ShowImmediately(); + //maskObj.ShowImmediately(); + ShowDragPath(fire1.GetStartP, btnImg.rectTransform); StartCoroutine(ShowRimTip(str)); + } } /// <summary> - /// 第六步,拖动造塔 + /// 第六步 /// </summary> public void Step5(int currentIndex, string str) { @@ -259,10 +272,10 @@ GameObject go = transform.Find("Image_TowerPos2").gameObject; Image btnImg = go.GetComponent<Image>(); - btnImg.raycastTarget=false; + btnImg.raycastTarget = false; InitRectGuidance(btnImg, 75, 80); SetRimPos(go); - maskObj.ShowImmediately(); + //maskObj.ShowImmediately(); StartCoroutine(ShowRimTip(str)); } } @@ -287,25 +300,28 @@ { SetRimActive(true); + + image_Tip_Rect.gameObject.SetActive(false); //设置位置 AddButtonListener(towerBuyBtn, ac); Image btnImg = towerBuyBtn.GetComponent<Image>(); InitRectGuidance(btnImg, 189, 73.5f); SetRimPos(towerBuyBtn); - maskObj.ShowImmediately(); + //maskObj.ShowImmediately(); } else if (currentIndex == 1) { GameObject go = transform.Find("Image_TowerPos2").gameObject; Image btnImg = go.GetComponent<Image>(); - btnImg.raycastTarget=true; + btnImg.raycastTarget = true; InitRectGuidance(btnImg, 75, 80); SetRimPos(go); - maskObj.ShowImmediately(); + //maskObj.ShowImmediately(); + ShowDragPath(water1.GetStartP, btnImg.rectTransform); } - StartCoroutine(ShowRimTip(str)); + //StartCoroutine(ShowRimTip(str)); } public void Step9_1() @@ -334,27 +350,40 @@ if (currentIndex == 0) { tmpMask.enabled = true; - + tmpMask.color = new Color(1.0f, 1.0f, 1.0f, 0); SetGuideUI(false); SetRimActive(true); SetRimPos(skill.gameObject); - StartCoroutine(ShowRimTip(str)); + image_Tip_Rect.gameObject.SetActive(false); + //StartCoroutine(ShowRimTip(str)); + + ShowDragPath(skill.GetStartP, image_SkillRim.rectTransform); + + InitRectGuidance(image_SkillRim, 79, 265); + } else if (currentIndex == 1) { - SetRimPos(image_SkillRim.gameObject); - StartCoroutine(ShowRimTip(str)); + SetRimActive(false); + //SetRimPos(image_SkillRim.gameObject); + //StartCoroutine(ShowRimTip(str)); } } + public void SkillRelease() + { + StopShowDragPath(true); + CloseMask(); + image_SkillRim.gameObject.SetActive(false); + tmpMask.enabled = false; + SetRimActive(false); + } public void Step12() { - image_SkillRim.gameObject.SetActive(false); - tmpMask.enabled = false; + SetGuideUI(true); - SetRimActive(false); } #region 按钮以及提示 @@ -378,6 +407,17 @@ RectTransform rt = target.GetComponent<RectTransform>(); image_Rim_Rect.anchoredPosition = rt.anchoredPosition; image_Rim_Rect.sizeDelta = (rt.sizeDelta * rt.localScale) + rimOffset; + if (image_Rim_Rect.sizeDelta.x > 200) + { + particle_1.SetActive(false); + particle_2.SetActive(true); + } + else + { + particle_1.SetActive(true); + particle_2.SetActive(false); + } + if (changeTipPos) image_Tip_Rect.anchoredPosition = new Vector2(image_Rim_Rect.anchoredPosition.x, image_Rim_Rect.anchoredPosition.y + 74 / 2 + image_Rim_Rect.sizeDelta.y / 2); @@ -416,6 +456,7 @@ maskObj.gameObject.SetActive(true); } //maskObj.Init(target); + //maskObj.ShowImmediately(); maskObj.InitForCamera(target, x, y); } @@ -461,5 +502,26 @@ #endregion + #region 拖动效果 + private float dragTimer = 1f; + private void ShowDragPath(Vector2 startP, RectTransform endP) + { + if (!dragHandImg.gameObject.activeSelf) + { + dragHandImg.gameObject.SetActive(true); + dragHandImg.anchoredPosition = startP; + dragHandImg.DOMove(endP.position, 1).SetEase(Ease.InCubic).SetLoops(-1); + } + } + + public void StopShowDragPath(bool isClose) + { + dragHandImg.DOKill(); + if (isClose) + dragHandImg.gameObject.SetActive(false); + } + + + #endregion } -- Gitblit v1.9.1