chenxin
2020-11-27 2a1575f0dd35ad089de454588b19b8504d13acb4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using KTGMGemClient;
using DG.Tweening;
/// <summary>
/// 新手引导UI脚本
/// </summary>
public class GuidePanel : MonoBehaviour
{
    GameObject tipsUI;//显示文字的UI
    CharForeach charForeach;//动态显示文字
 
    GuideCtrl m_Ctrl;//控制类
 
    /// <summary>
    /// 遮罩对象
    /// </summary>
    private RectGuidance maskObj;
 
    private RectTransform image_Rim_Rect;//边框
    private GameObject particle_1, particle_2;//使用粒子特效
    private RectTransform image_Tip_Rect;//可以移动的提示框
    private Text text_Tip;//可以移动的提示框文字
 
    private Image image_SkillRim;//技能释放区域
    Vector2 rimOffset = new Vector2(30, 30);//边框要比按钮大一些
 
    Image tmpMask;//自身的遮罩
    GameObject offectBackground;//适配需要的黑色背景
    ImageFire1 fire1;
    ParticleSystem fire1PS1, fire1PS2;//出现的特效
 
    ImageFire2 fire2;//两个用来合成的火元素
    ParticleSystem fire2PS1, fire2PS2;
 
    ImageWater wood1;
 
    ParticleSystem woodPS1, woodPS2;
 
    ImageSkill skill;
 
    ImageTowerPos towerPos;//塔位标识
    ImageTowerPos2 towerPos2;//塔位标识
 
    GameObject towerBuyBtn;//购买宝石按钮
    Vector2 towerBuyBtnPos;
    Image backgroundImg;//用来接受空白点击事件的图片
 
    RectTransform dragHandImg;//拖动标识手指
 
    Button skillBtn;//
    Vector2 skillBtnPos = new Vector2(455, -150);
 
    private Image warningImg;//大波敌人来袭提示
    /// <summary>
    /// 关闭所有UI
    /// </summary>
    public void CleanMask()
    {
        CloseMask();
        SetRimActive(false);
        image_SkillRim.gameObject.SetActive(false);
 
    }
 
    // Start is called before the first frame update
    void Awake()
    {
        tmpMask = GetComponent<Image>();
        tmpMask.enabled = false;
        offectBackground = transform.Find("OffectImage").gameObject;
        offectBackground.SetActive(false);
 
        backgroundImg = transform.Find("Button").GetComponent<Image>();
 
        skillBtn = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBg/SkillBtn").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(tmpTs.anchoredPosition.x, tmpOffect);
 
        tipsUI = transform.Find("Tips").gameObject;
        tipsUI.transform.SetAsLastSibling();//把tips放在最下面
 
        charForeach = tipsUI.GetComponent<CharForeach>();
        m_Ctrl = transform.GetComponent<GuideCtrl>();
        transform.Find("Button").GetComponent<Button>().onClick.AddListener(m_Ctrl.OnFinishOneStep);
        GameObject go = Instantiate(Resources.Load<GameObject>("GuideFile/RectGuidance_Panel"), this.transform);
        if (go != null)
        {
            go.transform.SetSiblingIndex(1);
            maskObj = go.GetComponent<RectGuidance>();
            maskObj.gameObject.SetActive(false);
        }
        else
        {
            Debug.LogError("遮罩生成失败了");
        }
 
        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;
 
        float a = 0.06666667f;
        float b = canvasUI.localScale.x;
        float tmpScale = a / b;
        //Debug.Log($"记录的比值:{a}   当前Canvas的Scale:{b}  计算得到的比值:{tmpScale}");
 
        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>();
        image_SkillRim.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
 
        SetRimActive(false);
        image_SkillRim.gameObject.SetActive(false);
 
        fire1 = transform.Find("Image_Fire1").GetComponent<ImageFire1>();
        fire1.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        fire1PS1 = fire1.transform.Find("Huo/Particle System").GetComponent<ParticleSystem>();
        fire1PS2 = fire1.transform.Find("Huo_02/Particle System").GetComponent<ParticleSystem>();
 
        fire2 = transform.Find("Image_Fire2").GetComponent<ImageFire2>();
        fire2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        fire2PS1 = fire2.transform.Find("Huo/Particle System").GetComponent<ParticleSystem>();
        fire2PS2 = fire2.transform.Find("Huo_02/Particle System").GetComponent<ParticleSystem>();
 
        fire1.gameObject.SetActive(false);
        fire2.gameObject.SetActive(false);
 
        towerPos = transform.Find("Image_TowerPos").GetComponent<ImageTowerPos>();
        towerPos.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
 
        towerPos.enabled = false;
 
        towerPos2 = transform.Find("Image_TowerPos2").GetComponent<ImageTowerPos2>();
        towerPos2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
 
        towerPos2.enabled = false;
 
        wood1 = transform.Find("Image_Wood").GetComponent<ImageWater>();
        wood1.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        woodPS1 = wood1.transform.Find("Mu/Particle System").GetComponent<ParticleSystem>();
        woodPS2 = wood1.transform.Find("Mu_02/Particle System").GetComponent<ParticleSystem>();
 
        wood1.gameObject.SetActive(false);
 
        skill = transform.Find("Image_Skill").GetComponent<ImageSkill>();
        skill.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
 
        skill.gameObject.SetActive(false);
 
        dragHandImg = transform.Find("ImageHand").GetComponent<RectTransform>();
        dragHandImg.gameObject.SetActive(false);
 
        warningImg = transform.Find("Image_Warning").GetComponent<Image>();
        warningImg.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;
        wood1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        skill.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
 
    }
    /// <summary>
    /// 设置引导框
    /// </summary>
    /// <param name="active"></param>
    public void SetGuideUI(bool active)
    {
        if (backgroundImg.enabled != active)
            backgroundImg.enabled = active;
        if (tipsUI.activeSelf != active)
            tipsUI.SetActive(active);
    }
 
    //开始打印文字
    public void StartShowWord(string str, Action cb)
    {
        charForeach.StartShowWord(str, cb);
    }
 
    /// <summary>
    /// 立刻完成打印
    /// </summary>
    public void ShowWordImmediately()
    {
        charForeach.ShowWordImmediately();
    }
 
    /// <summary>
    /// 第二步,购买宝石
    /// </summary>
    /// <param name="str"></param>
    /// <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, Vector2.one);
            SetRimPos(towerBuyBtn);
            //maskObj.ShowImmediately();
 
        }
        else if (currentIndex == 1)
        {
            RemoveButtonListener(towerBuyBtn);
            AddButtonListener(towerBuyBtn, ac);
        }
        text_Tip.text = str;//动态改变长度
        StartCoroutine(ShowRimTip(str));
    }
 
    public void Step1_1()
    {
        if (!fire1.gameObject.activeSelf)
        {
            fire1.gameObject.SetActive(true);
            fire1.transform.Find("Image_2").gameObject.SetActive(false);
            fire1.enabled = false;
            fire1PS1.Play();
            fire1PS2.Play();
 
            //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.PlayAppearEffect, fire1.transform.position);
        }
    }
    public void Step1_2()
    {
        fire2.gameObject.SetActive(true);
        fire2PS1.Play();
        fire2PS2.Play();
        fire2.enabled = false;
        DestoryButtonListener(towerBuyBtn);
        SetRimActive(false);
        CloseMask();
        //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.PlayAppearEffect, fire2.transform.position);
 
        //RemoveButtonListener(towerBuyBtn);
    }
 
    /// <summary>
    /// 第三步,关闭其余遮罩,打开大Tips
    /// </summary>
    /// <param name="currentIndex"></param>
    public void Step2(int currentIndex)
    {
        backgroundImg.raycastTarget = true;
        //RemoveButtonListener(towerBuyBtn);
    }
 
    /// <summary>
    /// 第四步,合成宝石
    /// </summary>
    public void Step3(int currentIndex, string str)
    {
        if (currentIndex == 0)
        {
 
            tmpMask.enabled = true;
            offectBackground.SetActive(true);
 
            SetGuideUI(false);
 
            SetRimPos(fire2.gameObject);
            fire1.enabled = true;
            fire2.enabled = true;
            image_Tip_Rect.gameObject.SetActive(false);
            ShowDragPath(fire2.GetStartP, fire1.GetRect);
            StartCoroutine(ShowRimTip(str));
        }
    }
 
    //移动方框,提示玩家进行合成
    public void Step3_2(string str)
    {
        SetRimPos(fire1.gameObject);
        //StartCoroutine(ShowRimTip(str));
    }
 
    /// <summary>
    /// 第五步,拖动造塔
    /// </summary>
    public void Step4(int currentIndex, string str)
    {
        if (currentIndex == 0)
        {
            tmpMask.enabled = false;
            offectBackground.SetActive(false);
 
            SetRimActive(true);
            Image btnImg = transform.Find("Image_TowerPos").GetComponent<Image>();
            towerPos.enabled = true;
            InitRectGuidance(btnImg, 75, 80, tmpOffect);
            SetRimPos(btnImg.gameObject);
            //maskObj.ShowImmediately();
            ShowDragPath(fire1.GetStartP, btnImg.rectTransform);
            StartCoroutine(ShowRimTip(str));
 
        }
    }
 
    /// <summary>
    /// 第六步
    /// </summary>
    public void Step5(int currentIndex, string str)
    {
        if (currentIndex == -1)
        {
            CloseMask();
            SetRimActive(false);
 
        }
    }
 
    /// <summary>
    /// 第七步,解锁新塔位
    /// </summary>
    public void Step7(int currentIndex, string str)
    {
        if (currentIndex == 0)
        {
            SetRimActive(true);
            //设置位置
            GameObject go = transform.Find("Image_TowerPos2").gameObject;
 
            Image btnImg = go.GetComponent<Image>();
            btnImg.raycastTarget = false;
            InitRectGuidance(btnImg, 75, 80, tmpOffect);
            SetRimPos(go);
            //maskObj.ShowImmediately();
            StartCoroutine(ShowRimTip(str));
        }
    }
 
    //介绍水元素
    public void Step8()
    {
        SetGuideUI(true);
        SetRimActive(false);
        CloseMask();
    }
 
 
    /// <summary>
    /// 第九步,购买水元素,第二步上阵
    /// </summary>
    /// <param name="str"></param>
    /// <param name="currentIndex">当前第几步</param>
    public void Step9(string str, int currentIndex, Action ac)
    {
        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);
        }
        else if (currentIndex == 1)
        {
            GameObject go = transform.Find("Image_TowerPos2").gameObject;
            Image btnImg = go.GetComponent<Image>();
            btnImg.raycastTarget = true;
            InitRectGuidance(btnImg, 75, 80, tmpOffect);
            SetRimPos(go);
            ShowDragPath(wood1.GetStartP, btnImg.rectTransform);
        }
    }
 
    public void Step9_1()
    {
        wood1.gameObject.SetActive(true);
        woodPS1.Play();
        woodPS2.Play();
        towerPos2.enabled = true;
        DestoryButtonListener(towerBuyBtn);
    }
 
 
    //生成一个技能宝石
    public void Step10()
    {
        //SetGuideUI(false);
 
        image_SkillRim.gameObject.SetActive(true);
 
        skill.gameObject.SetActive(true);
    }
 
    /// <summary>
    /// 第12步,弃用
    /// </summary>
    public void Step11(int currentIndex, string str)
    {
        if (currentIndex == 0)
        {
            tmpMask.enabled = true;
            tmpMask.color = new Color(1.0f, 1.0f, 1.0f, 0);
            SetGuideUI(false);
            SetRimActive(true);
            SetRimPos(skill.gameObject);
            image_Tip_Rect.gameObject.SetActive(false);
            //StartCoroutine(ShowRimTip(str));
 
            ShowDragPath(skill.GetStartP, image_SkillRim.rectTransform);
 
            InitRectGuidance(image_SkillRim, 79, 265, tmpOffect);
 
        }
        else if (currentIndex == 1)
        {
            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);
    }
 
 
    /// <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, -241));
 
        text_Tip.text = str;//动态改变长度
        StartCoroutine(ShowRimTip(str));
    }
 
    public void Step14()
    {
        SetGuideUI(true);
        backgroundImg.raycastTarget = true;
        RemoveButtonListener(skillBtn.gameObject);
    }
 
 
    #region 按钮以及提示
 
 
    public void SetRimActive(bool isOn)
    {
        if (image_Rim_Rect.gameObject.activeSelf != isOn)
        {
            image_Rim_Rect.gameObject.SetActive(isOn);
            image_Tip_Rect.gameObject.SetActive(isOn);
        }
    }
    /// <summary>
    /// 设置边框的大小和位置
    /// </summary>
    /// <param name="target"></param>
    private void SetRimPos(GameObject target, bool changeTipPos = true)
    {
        SetRimActive(true);
        RectTransform rt = target.GetComponent<RectTransform>();
        if (target.gameObject.name == "TowerBuyBtn")
        {
            image_Rim_Rect.anchoredPosition = towerBuyBtnPos - tmpOffect;
        }
        else if (target.gameObject.name == "SkillBtn")
        {
            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);
        }
 
        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>
    /// 设置边框的大小和位置
    /// </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 == "SkillBtn")
        {
            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)
    {
        text_Tip.text = str;//动态改变长度
        yield return 10;
        SetTipRect(str);//动态修改text长度需要等待计算完成
    }
    /// <summary>
    /// 设置显示文字的长度
    /// </summary>
    /// <param name="str"></param>
    private void SetTipRect(string str)
    {
        RectTransform textRect = text_Tip.GetComponent<RectTransform>();
        image_Tip_Rect.sizeDelta = new Vector2(textRect.sizeDelta.x + 64, image_Tip_Rect.sizeDelta.y);
    }
 
    #endregion
 
    #region 遮罩,以及按钮添加删除事件
 
 
 
    /// <summary>
    /// 抠出来一个区域
    /// </summary>
    /// <param name="target"></param>
    void InitRectGuidance(Image target, float x, float y, Vector2 offect)
    {
        if (!maskObj.gameObject.activeSelf)
        {
            maskObj.gameObject.SetActive(true);
        }
        //maskObj.Init(target);
        //maskObj.ShowImmediately();
        if (target.gameObject.name == "TowerBuyBtn")
        {
            maskObj.InitForCamera(target, towerBuyBtnPos, x, y);
        }
        else if (target.gameObject.name == "SkillBtn")
        {
            maskObj.InitForCamera(target, skillBtnPos, x, y);
        }
        else
        {
            maskObj.InitForCamera(target, x, y, offect);
        }
    }
 
    /// <summary>
    /// 关闭遮罩
    /// </summary>
    public void CloseMask()
    {
        maskObj.gameObject.SetActive(false);
    }
 
    /// <summary>
    /// 给按钮添加事件
    /// </summary>
    private void AddButtonListener(GameObject go, Action ac)
    {
        EventTriggerListener.GetListener(go).onClick += (go1) =>
    {
        ac();
    };
 
    }
 
    /// <summary>
    /// 移除事件
    /// </summary>
    /// <param name="go"></param>
    private void RemoveButtonListener(GameObject go)
    {
        EventTriggerListener eventTriggerListener = EventTriggerListener.GetListener(go);
 
        eventTriggerListener.RemoveListener(go);
    }
 
    private void DestoryButtonListener(GameObject go)
    {
        EventTriggerListener eventTriggerListener = EventTriggerListener.GetListener(go);
 
        if (eventTriggerListener != null)
            Destroy(eventTriggerListener);
    }
 
    #endregion
 
    #region 拖动效果
    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
 
}