wangguan
2020-11-25 9969ed162f8aa4bd0b977a3c1eba45358eb01f72
Assets/Scripts/Guide/GuidePanel.cs
@@ -45,6 +45,11 @@
    Image backgroundImg;//用来接受空白点击事件的图片
    RectTransform dragHandImg;//拖动标识手指
    Button skillBtn;//
    Vector2 skillBtnPos = new Vector2(459, 280);
    private Image warningImg;//大波敌人来袭提示
    /// <summary>
    /// 关闭所有UI
    /// </summary>
@@ -66,6 +71,8 @@
        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>();
@@ -137,6 +144,9 @@
        dragHandImg = transform.Find("ImageHand").GetComponent<RectTransform>();
        dragHandImg.gameObject.SetActive(false);
        warningImg = transform.Find("Image_Warning").GetComponent<Image>();
        warningImg.gameObject.SetActive(false);
    }
@@ -193,7 +203,6 @@
    /// <param name="currentIndex">当前第几步</param>
    public void Step1(string str, int currentIndex, Action ac)
    {
        if (currentIndex == 0)
        {
            backgroundImg.raycastTarget = false;
@@ -212,7 +221,6 @@
        }
        text_Tip.text = str;//动态改变长度
        StartCoroutine(ShowRimTip(str));
    }
    public void Step1_1()
@@ -342,7 +350,7 @@
    /// <summary>
    /// 第九步,
    /// 第九步,购买水元素,第二步上阵
    /// </summary>
    /// <param name="str"></param>
    /// <param name="currentIndex">当前第几步</param>
@@ -350,17 +358,13 @@
    {
        if (currentIndex == 0)
        {
            SetRimActive(true);
            image_Tip_Rect.gameObject.SetActive(false);
            //设置位置
            AddButtonListener(towerBuyBtn, ac);
            Image btnImg = towerBuyBtn.GetComponent<Image>();
            InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
            SetRimPos(towerBuyBtn);
            //maskObj.ShowImmediately();
        }
        else if (currentIndex == 1)
        {
@@ -369,11 +373,8 @@
            btnImg.raycastTarget = true;
            InitRectGuidance(btnImg, 75, 80, tmpOffect);
            SetRimPos(go);
            //maskObj.ShowImmediately();
            ShowDragPath(water1.GetStartP, btnImg.rectTransform);
        }
        //StartCoroutine(ShowRimTip(str));
    }
    public void Step9_1()
@@ -395,7 +396,7 @@
    }
    /// <summary>
    /// 第12步,引导释放技能
    /// 第12步,弃用
    /// </summary>
    public void Step11(int currentIndex, string str)
    {
@@ -431,12 +432,112 @@
        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);
            SetRimPos(towerPos2.gameObject, new Vector2(0, 30));
            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);
            SetRimPos(towerPos.gameObject, new Vector2(0, 10));
            StartCoroutine(ShowRimTip("交换"));
        }
        else if (currentIndex == 2)
        {
            SetRimActive(false);
            StopShowDragPath(true);
            CloseMask();
        }
    }
    /// <summary>
    /// 一大波敌人
    /// </summary>
    public void Step11_End()
    {
        warningImg.color = new Color(1.0f, 1.0f, 1.0f, 0);
        warningImg.gameObject.SetActive(true);
        colorCount = 0;
        SetWarningColor();
    }
    int colorCount = 0;
    private void SetWarningColor()
    {
        if (colorCount < 4)
        {
            colorCount++;
            warningImg.DOFade(colorCount % 2, 1.0f).OnComplete(SetWarningColor);
            CommonDebugHelper.Debug($"执行了{colorCount}次");
        }
        else
        {
            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateThirdWave);
            warningImg.gameObject.SetActive(false);
        }
    }
    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);
        SetRimPos(skillBtn.gameObject, new Vector2(-15, 10));
        text_Tip.text = str;//动态改变长度
        StartCoroutine(ShowRimTip(str));
    }
    public void Step14()
    {
        SetGuideUI(true);
        backgroundImg.raycastTarget = true;
        RemoveButtonListener(skillBtn.gameObject);
    }
    #region 按钮以及提示
@@ -461,6 +562,10 @@
        {
            image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect;
        }
        else if (target.gameObject.name == "FireSkillBtn")
        {
            image_Rim_Rect.anchoredPosition = skillBtnPos - tmpOffect;
        }
        else
        {
            image_Rim_Rect.anchoredPosition = rt.anchoredPosition;
@@ -483,6 +588,41 @@
            //image_Tip_Rect.anchoredPosition -= tmpOffect;
        }
    }
    /// <summary>
    /// 设置边框的大小和位置
    /// </summary>
    /// <param name="target"></param>
    private void SetRimPos(GameObject target, Vector2 offect)
    {
        SetRimActive(true);
        RectTransform rt = target.GetComponent<RectTransform>();
        if (target.gameObject.name == "TowerBuyBtn")
        {
            image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect;
        }
        else if (target.gameObject.name == "FireSkillBtn")
        {
            image_Rim_Rect.anchoredPosition = skillBtnPos - tmpOffect;
        }
        else
        {
            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);
        }
        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 += offect;
    }
    IEnumerator ShowRimTip(string str)
@@ -523,11 +663,14 @@
        {
            maskObj.InitForCamera(target, towerBuyBtnPos, x, y);
        }
        else if (target.gameObject.name == "FireSkillBtn")
        {
            maskObj.InitForCamera(target, skillBtnPos, x, y);
        }
        else
        {
            maskObj.InitForCamera(target, x, y, offect);
        }
    }
    /// <summary>