| | |
| | | Image backgroundImg;//用来接受空白点击事件的图片 |
| | | |
| | | RectTransform dragHandImg;//拖动标识手指 |
| | | |
| | | Button skillBtn;// |
| | | Vector2 skillBtnPos = new Vector2(459, 280); |
| | | |
| | | /// <summary> |
| | | /// 关闭所有UI |
| | | /// </summary> |
| | |
| | | |
| | | backgroundImg = transform.Find("Button").GetComponent<Image>(); |
| | | |
| | | skillBtn = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBtn").GetComponent<Button>(); |
| | | skillBtn.interactable = false; |
| | | towerBuyBtn = GameObject.Find("UICamera/BottomCanvas/Panel/TowerBuyBtn"); |
| | | RectTransform tmpTs = towerBuyBtn.GetComponent<RectTransform>(); |
| | | |
| | | RectTransform canvasUI = transform.parent.parent.GetComponent<RectTransform>(); |
| | | float tmpOffect = tmpTs.anchoredPosition.y - (canvasUI.sizeDelta.y * 0.5f); |
| | | towerBuyBtnPos = new Vector2(215, tmpOffect); |
| | | towerBuyBtnPos = new Vector2(tmpTs.anchoredPosition.x, tmpOffect); |
| | | |
| | | tipsUI = transform.Find("Tips").gameObject; |
| | | tipsUI.transform.SetAsLastSibling();//把tips放在最下面 |
| | |
| | | dragHandImg.gameObject.SetActive(false); |
| | | } |
| | | |
| | | |
| | | private Vector2 tmpOffect; |
| | | |
| | | /// <summary> |
| | | /// Start is called on the frame when a script is enabled just before |
| | | /// any of the Update methods is called the first time. |
| | | /// </summary> |
| | | void Start() |
| | | { |
| | | tmpOffect = GetComponent<RectTransform>().offsetMin; |
| | | tmpOffect = new Vector2(tmpOffect.x, tmpOffect.y * 0.5f); |
| | | |
| | | image_SkillRim.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | fire1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | fire2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | towerPos.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | towerPos2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | water1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | skill.GetComponent<RectTransform>().anchoredPosition -= tmpOffect; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 设置引导框 |
| | | /// </summary> |
| | |
| | | /// <param name="currentIndex">当前第几步</param> |
| | | public void Step1(string str, int currentIndex, Action ac) |
| | | { |
| | | |
| | | if (currentIndex == 0) |
| | | { |
| | | backgroundImg.raycastTarget = false; |
| | | SetRimActive(true); |
| | | AddButtonListener(towerBuyBtn, ac); |
| | | Image btnImg = towerBuyBtn.GetComponent<Image>(); |
| | | InitRectGuidance(btnImg, 159, 73.5f); |
| | | InitRectGuidance(btnImg, 159, 73.5f, Vector2.one); |
| | | SetRimPos(towerBuyBtn); |
| | | //maskObj.ShowImmediately(); |
| | | |
| | |
| | | } |
| | | text_Tip.text = str;//动态改变长度 |
| | | StartCoroutine(ShowRimTip(str)); |
| | | |
| | | } |
| | | |
| | | public void Step1_1() |
| | |
| | | SetRimActive(true); |
| | | Image btnImg = transform.Find("Image_TowerPos").GetComponent<Image>(); |
| | | towerPos.enabled = true; |
| | | InitRectGuidance(btnImg, 75, 80); |
| | | InitRectGuidance(btnImg, 75, 80, tmpOffect); |
| | | SetRimPos(btnImg.gameObject); |
| | | //maskObj.ShowImmediately(); |
| | | ShowDragPath(fire1.GetStartP, btnImg.rectTransform); |
| | |
| | | |
| | | Image btnImg = go.GetComponent<Image>(); |
| | | btnImg.raycastTarget = false; |
| | | InitRectGuidance(btnImg, 75, 80); |
| | | InitRectGuidance(btnImg, 75, 80, tmpOffect); |
| | | SetRimPos(go); |
| | | //maskObj.ShowImmediately(); |
| | | StartCoroutine(ShowRimTip(str)); |
| | |
| | | { |
| | | if (currentIndex == 0) |
| | | { |
| | | |
| | | SetRimActive(true); |
| | | |
| | | image_Tip_Rect.gameObject.SetActive(false); |
| | | //设置位置 |
| | | AddButtonListener(towerBuyBtn, ac); |
| | | |
| | | Image btnImg = towerBuyBtn.GetComponent<Image>(); |
| | | InitRectGuidance(btnImg, 159, 73.5f); |
| | | InitRectGuidance(btnImg, 159, 73.5f, Vector2.one); |
| | | SetRimPos(towerBuyBtn); |
| | | //maskObj.ShowImmediately(); |
| | | } |
| | | else if (currentIndex == 1) |
| | | { |
| | | GameObject go = transform.Find("Image_TowerPos2").gameObject; |
| | | Image btnImg = go.GetComponent<Image>(); |
| | | btnImg.raycastTarget = true; |
| | | InitRectGuidance(btnImg, 75, 80); |
| | | InitRectGuidance(btnImg, 75, 80, tmpOffect); |
| | | SetRimPos(go); |
| | | //maskObj.ShowImmediately(); |
| | | ShowDragPath(water1.GetStartP, btnImg.rectTransform); |
| | | } |
| | | |
| | | //StartCoroutine(ShowRimTip(str)); |
| | | } |
| | | |
| | | public void Step9_1() |
| | |
| | | |
| | | ShowDragPath(skill.GetStartP, image_SkillRim.rectTransform); |
| | | |
| | | InitRectGuidance(image_SkillRim, 79, 265); |
| | | InitRectGuidance(image_SkillRim, 79, 265, tmpOffect); |
| | | |
| | | } |
| | | else if (currentIndex == 1) |
| | |
| | | SetRimActive(false); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 第12步,引导释放技能 |
| | | /// </summary> |
| | | public void Step11Drag(int currentIndex) |
| | | { |
| | | if (currentIndex == 0) |
| | | { |
| | | GameConfig.CanDragTower = true; |
| | | //标记水塔 引导拖动 |
| | | towerPos.GetComponent<Image>().raycastTarget = false; |
| | | towerPos2.GetComponent<Image>().raycastTarget = false; |
| | | backgroundImg.raycastTarget = false; |
| | | SetRimActive(true); |
| | | SetGuideUI(false); |
| | | Image btnImg = towerPos2.GetComponent<Image>(); |
| | | btnImg.raycastTarget = false; |
| | | |
| | | InitRectGuidance(btnImg, 75, 80, tmpOffect); |
| | | SetRimPos(towerPos2.gameObject); |
| | | StartCoroutine(ShowRimTip("拖动")); |
| | | ShowDragPath(towerPos2.GetComponent<RectTransform>().anchoredPosition, towerPos.GetComponent<RectTransform>()); |
| | | |
| | | } |
| | | else if (currentIndex == 1) |
| | | { |
| | | Image btnImg = towerPos.GetComponent<Image>(); |
| | | btnImg.raycastTarget = false; |
| | | |
| | | InitRectGuidance(btnImg, 75, 80, tmpOffect); |
| | | SetRimPos(towerPos.gameObject); |
| | | StartCoroutine(ShowRimTip("拖动")); |
| | | |
| | | } |
| | | else if (currentIndex == 2) |
| | | { |
| | | SetRimActive(false); |
| | | StopShowDragPath(true); |
| | | CloseMask(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void Step12() |
| | | { |
| | | |
| | | |
| | | SetGuideUI(true); |
| | | backgroundImg.raycastTarget = true; |
| | | } |
| | | |
| | | public void Step13(string str, Action ac) |
| | | { |
| | | skillBtn.interactable = true; |
| | | |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.GuideEnergyUp, 100); |
| | | |
| | | SetGuideUI(false); |
| | | |
| | | backgroundImg.raycastTarget = false; |
| | | SetRimActive(true); |
| | | AddButtonListener(skillBtn.gameObject, ac); |
| | | Image btnImg = skillBtn.GetComponent<Image>(); |
| | | InitRectGuidance(btnImg, 79, 79f, Vector2.one); |
| | | SetRimPos(skillBtn.gameObject); |
| | | text_Tip.text = str;//动态改变长度 |
| | | StartCoroutine(ShowRimTip(str)); |
| | | } |
| | | |
| | | public void Step14() |
| | | { |
| | | SetGuideUI(true); |
| | | backgroundImg.raycastTarget = true; |
| | | } |
| | | |
| | | |
| | | #region 按钮以及提示 |
| | | |
| | |
| | | { |
| | | SetRimActive(true); |
| | | RectTransform rt = target.GetComponent<RectTransform>(); |
| | | image_Rim_Rect.anchoredPosition = rt.anchoredPosition; |
| | | if (target.gameObject.name == "TowerBuyBtn") |
| | | { |
| | | image_Rim_Rect.anchoredPosition = towerBuyBtnPos; |
| | | image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect; |
| | | } |
| | | else if (target.gameObject.name == "FireSkillBtn") |
| | | { |
| | | image_Rim_Rect.anchoredPosition = skillBtnPos; |
| | | } |
| | | else |
| | | { |
| | | image_Rim_Rect.anchoredPosition = rt.anchoredPosition; |
| | | } |
| | | image_Rim_Rect.sizeDelta = (rt.sizeDelta * rt.localScale) + rimOffset; |
| | | if (image_Rim_Rect.sizeDelta.x > 200) |
| | |
| | | } |
| | | |
| | | 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); |
| | | //image_Tip_Rect.anchoredPosition -= tmpOffect; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | /// 抠出来一个区域 |
| | | /// </summary> |
| | | /// <param name="target"></param> |
| | | void InitRectGuidance(Image target, float x, float y) |
| | | void InitRectGuidance(Image target, float x, float y, Vector2 offect) |
| | | { |
| | | if (!maskObj.gameObject.activeSelf) |
| | | { |
| | |
| | | { |
| | | maskObj.InitForCamera(target, towerBuyBtnPos, x, y); |
| | | } |
| | | else if (target.gameObject.name == "FireSkillBtn") |
| | | { |
| | | maskObj.InitForCamera(target, skillBtnPos, x, y); |
| | | } |
| | | else |
| | | { |
| | | maskObj.InitForCamera(target, x, y); |
| | | maskObj.InitForCamera(target, x, y, offect); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |