wangguan
2020-12-11 74cc09511f7ffcbec25d9ce276f4be974875c05b
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using KTGMGemClient;
using UnityEngine;
using UnityEngine.UI;
 
public class GuidePanelNew : MonoBehaviour
{
    GameObject tipsUI;//显示文字的UI
    CharForeach charForeach;//动态显示文字
    Action callBack;//每一步操作后的回调
    private GuideBox boxPanel;//宝箱面板
 
    /// <summary>
    /// 抠图脚本
    /// </summary>
    private RectGuidance guidance;
    private RectTransform image_Rim_Rect;//边框
    private GameObject particle_1, particle_2;//使用粒子特效
    private RectTransform image_Tip_Rect;//可以移动的提示框
    private Text text_Tip;//可以移动的提示框文字
 
    Vector2 rimOffset = new Vector2(30, 30);//边框要比按钮大一些
 
    Vector2 towerBuyBtnPos;//动态生成按钮抠图位置
    Vector2 skillBtnPos = new Vector2(459, 121f);
 
    private Image warningImg;//大波敌人来袭提示
 
    private Vector2 tmpOffect;
    GameObject towerBuyBtn;//购买宝石按钮
 
    private string[] strArray;//按钮提示文字
    GameObject offectBackground;//适配需要的黑色背景
    ImageTowerPos towerPos;//塔位标识
    ImageTowerPos towerPos2;//塔位标识
    ImageTowerPos towerPos3;//塔位标识
 
    Image tmpMask;//自身的阻挡射线Panel
    ParticleSystem finishPS;
    void Awake()
    {
        tmpMask = transform.GetComponent<Image>();
        tipsUI = transform.Find("Tips").gameObject;
        tipsUI.transform.SetAsLastSibling();//把tips放在最下面
        charForeach = tipsUI.GetComponent<CharForeach>();
 
        boxPanel = transform.Find("BoxPanel").GetComponent<GuideBox>();
 
        //生成抠图面板
        GameObject go = Instantiate(Resources.Load<GameObject>("GuideFile/RectGuidance_Panel"), this.transform);
        if (go != null)
        {
            go.transform.SetSiblingIndex(1);
            guidance = go.GetComponent<RectGuidance>();
            guidance.gameObject.SetActive(false);
        }
        else
        {
            Debug.LogError("遮罩生成失败了");
        }
 
        //购买按钮
        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);//计算偏移量
 
        //得到用来标记的粒子特效
        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;
 
        //为了防止各种适配出现白边,多做了黑色遮罩
        offectBackground = transform.Find("OffectImage").gameObject;
        offectBackground.SetActive(false);
 
        image_Tip_Rect = transform.Find("Image_Tip").GetComponent<RectTransform>();
        text_Tip = image_Tip_Rect.transform.Find("Text").GetComponent<Text>();
 
        SetRimActive(false);
 
        float a = 0.06666667f;
        float b = canvasUI.localScale.x;
        float tmpScale = a / b;
 
        wood1 = transform.Find("Image_Wood1").GetComponent<ImageWood>();
        wood1.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        wood1PS1 = wood1.transform.Find("Mu/Particle System").GetComponent<ParticleSystem>();
        wood1PS2 = wood1.transform.Find("Mu_02/Particle System").GetComponent<ParticleSystem>();
 
        wood2 = transform.Find("Image_Wood2").GetComponent<ImageWood2>();
        wood2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        wood2PS1 = wood2.transform.Find("Mu/Particle System").GetComponent<ParticleSystem>();
        wood2PS2 = wood2.transform.Find("Mu_02/Particle System").GetComponent<ParticleSystem>();
 
        wood1.gameObject.SetActive(false);
        wood2.gameObject.SetActive(false);
 
        fire = transform.Find("Image_Fire").GetComponent<ImageFire1>();
        fire.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        firePS1 = fire.transform.Find("Huo/Particle System").GetComponent<ParticleSystem>();
        firePS2 = fire.transform.Find("Huo_02/Particle System").GetComponent<ParticleSystem>();
        fire.gameObject.SetActive(false);
 
        water = transform.Find("Image_Water").GetComponent<ImageWater>();
        water.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        waterPS1 = water.transform.Find("Shui/Particle System").GetComponent<ParticleSystem>();
        waterPS2 = water.transform.Find("Shui_02/Particle System").GetComponent<ParticleSystem>();
        water.gameObject.SetActive(false);
 
        towerPos = transform.Find("Image_TowerPos").GetComponent<ImageTowerPos>();
        towerPos.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        towerPos.Init(wood1);
        towerPos.enabled = false;
 
        towerPos2 = transform.Find("Image_TowerPos2").GetComponent<ImageTowerPos>();
        towerPos2.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        towerPos2.Init(fire);
        towerPos2.enabled = false;
 
        towerPos3 = transform.Find("Image_TowerPos3").GetComponent<ImageTowerPos>();
        towerPos3.GetComponent<RectTransform>().anchoredPosition *= tmpScale;
        towerPos3.Init(water);
        towerPos3.enabled = false;
 
        dragHandImg = transform.Find("ImageHand").GetComponent<RectTransform>();
        dragHandImg.gameObject.SetActive(false);
 
        warningImg = transform.Find("Image_Warning").GetComponent<Image>();
        warningImg.gameObject.SetActive(false);
 
        boxPanel = transform.Find("BoxPanel").GetComponent<GuideBox>();
 
        skillBtn = GameObject.Find("UICamera/BottomCanvas/Panel/Energy/FireSkillBg/SkillBtn").GetComponent<Button>();
        skillBtn.interactable = false;
 
        finishPS = transform.Find("Effect_UI_YinDaoJieShu/Particle System (3)").GetComponent<ParticleSystem>();
        towerBuyBtn.gameObject.SetActive(false);
    }
 
 
    /// <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);
 
        //fire1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        //fire2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        towerPos.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        towerPos2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        towerPos3.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        wood1.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        wood2.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        fire.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        water.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
        //fire.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
 
        //skill.GetComponent<RectTransform>().anchoredPosition -= tmpOffect;
 
    }
 
    /// <summary>
    ///  步骤1 :对话---开箱---玉米
    /// </summary>
    /// <param name="str"></param>
    /// <param name="cb"></param>
    public void Step1(string[] str, Action cb)
    {
        callBack = cb;
        SetGuideUI(true);
        StartShowWord(str, OpenBoxPanel);
    }
 
    /// <summary>
    /// 开箱
    /// </summary>
    public void OpenBoxPanel()
    {
        //关闭对话框
        SetGuideUI(false);
        towerBuyBtn.gameObject.SetActive(true);
 
        //开箱
        boxPanel.ChangeType(GuideBoxType.Wood, Step1Finish);
    }
 
    /// <summary>
    /// 步骤1结束
    /// </summary>
    private void Step1Finish()
    {
        if (callBack != null) callBack();
    }
 
 
    ImageWood wood1;
    ParticleSystem wood1PS1, wood1PS2;//出现的特效
    ImageWood2 wood2;//两个用来合成的mu元素
    ParticleSystem wood2PS1, wood2PS2;
 
    ImageFire1 fire;//火元素
    ParticleSystem firePS1, firePS2;
 
    ImageWater water;//水元素
    ParticleSystem waterPS1, waterPS2;
 
    /// <summary>
    /// 步骤2:购买---购买---合成---上阵  事件广播结束,不走回调
    /// </summary>
    public void Step2(string[] str)
    {
        strArray = str;
        tmpMask.enabled = false;
 
        AddButtonListener(towerBuyBtn, Step2_1);
        Image btnImg = towerBuyBtn.GetComponent<Image>();
        InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
        SetRimPos(towerBuyBtn);
        StartCoroutine(ShowRimTip(strArray[0]));
    }
 
    /// <summary>
    /// 首次购买
    /// </summary>
    private void Step2_1()
    {
        Wood1Appear();
    }
 
    private void Wood1Appear()
    {
        if (!wood1.gameObject.activeSelf)
        {
            wood1.gameObject.SetActive(true);
            wood1.transform.Find("Image_2").gameObject.SetActive(false);
            wood1.enabled = false;
            wood1PS1.Play();
            wood1PS2.Play();
            RemoveButtonListener(towerBuyBtn);
            AddButtonListener(towerBuyBtn, Step2_2);
            StartCoroutine(ShowRimTip(strArray[1]));
        }
    }
 
    /// <summary>
    /// 再次购买后,引导合成
    /// </summary>
    private void Step2_2()
    {
        Wood2Appear();
 
 
 
        //StartCoroutine(ShowRimTip(strArray[2]));
    }
 
    private void Wood2Appear()
    {
        if (!wood2.gameObject.activeSelf)
        {
            wood2.gameObject.SetActive(true);
            wood2PS1.Play();
            wood2PS2.Play();
            //fire2.enabled = false;
            DestoryButtonListener(towerBuyBtn);
            towerBuyBtn.gameObject.SetActive(false);
 
            SetRimActive(false);
            CloseGuidance();
            tmpMask.enabled = true;
            offectBackground.SetActive(true);
            wood1.enabled = true;
            wood2.enabled = true;
            ShowDragPath(wood2.GetStartP, wood1.GetRect);
            RimWood2();
            image_Tip_Rect.gameObject.SetActive(false);
        }
    }
 
 
    /// <summary>
    /// 开始拖拽,提示玩家进行合成
    /// </summary>
    public void RimWood1()
    {
        SetRimPos(wood1.gameObject);
    }
 
    /// <summary>
    /// 结束拖拽,未完成
    /// </summary>
    public void RimWood2()
    {
        SetRimPos(wood2.gameObject);
    }
 
    public void AddCard()
    {
        //合成了2级木
        Step2_3();
    }
 
 
    /// <summary>
    /// 合成了2级木 准备引导上阵
    /// </summary>
    private void Step2_3()
    {
 
        offectBackground.SetActive(false);
        SetRimActive(true);
        Image btnImg = transform.Find("Image_TowerPos").GetComponent<Image>();
        towerPos.enabled = true;
        InitRectGuidance(btnImg, 75, 80, tmpOffect);
        SetRimPos(btnImg.gameObject);
        StopShowDragPath(true);
        ShowDragPath(wood1.GetStartP, btnImg.rectTransform);
        //StartCoroutine(ShowRimTip(strArray[3]));
    }
 
    /// <summary>
    /// 上阵成功
    /// </summary>
    public void OnWoodAttackPos()
    {
        towerPos.enabled = false;
        SetRimActive(false);
        CloseGuidance();
        StopShowDragPath(true);
    }
 
 
 
    /// <summary>
    ///  步骤3 :对话---出兵后杀光---对话---展示火鸡
    /// </summary>
    /// <param name="str"></param>
    /// <param name="cb"></param>
    public void Step3(string[] str, Action cb)
    {
        SetGuideUI(true);
        StartShowWord(str, cb);
    }
 
    public void Step3AfterTalk()
    {
        SetGuideUI(false);
    }
 
 
    public void Step3_3(Action cb)
    {
        //关闭对话框
        SetGuideUI(false);
        towerBuyBtn.gameObject.SetActive(true);
 
        //开箱
        boxPanel.ChangeType(GuideBoxType.Fire, cb);
    }
 
    /// <summary>
    ///  步骤4 :点击购买---上阵
    /// </summary>
    /// <param name="str"></param>
    /// <param name="cb"></param>
    public void Step4(string[] str)
    {
        strArray = str;
        tmpMask.enabled = false;
 
        AddButtonListener(towerBuyBtn, Step4_1);
        Image btnImg = towerBuyBtn.GetComponent<Image>();
        InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
        SetRimPos(towerBuyBtn);
        StartCoroutine(ShowRimTip(strArray[0]));
    }
 
    /// <summary>
    /// 购买火鸡
    /// </summary>
    private void Step4_1()
    {
        FireAppear();
    }
 
    private void FireAppear()
    {
        if (!fire.gameObject.activeSelf)
        {
            fire.gameObject.SetActive(true);
            //fire.transform.Find("Image_2").gameObject.SetActive(false);
            fire.enabled = true;
            firePS1.Play();
            firePS1.Play();
            RemoveButtonListener(towerBuyBtn);
            towerBuyBtn.gameObject.SetActive(false);
 
            Step4_2();
        }
    }
 
    /// <summary>
    /// 引导上阵
    /// </summary>
    private void Step4_2()
    {
        tmpMask.enabled = true;
 
        offectBackground.SetActive(false);
        SetRimActive(true);
        Image btnImg = transform.Find("Image_TowerPos2").GetComponent<Image>();
        towerPos2.enabled = true;
        InitRectGuidance(btnImg, 75, 80, tmpOffect);
        SetRimPos(btnImg.gameObject);
        ShowDragPath(fire.GetStartP, btnImg.rectTransform);
        image_Tip_Rect.gameObject.SetActive(false);
    }
 
    public void OnFireAttackPos()
    {
        SetRimActive(false);
        CloseGuidance();
        StopShowDragPath(true);
    }
 
    /// <summary>
    ///  步骤5:第二关出兵---三波后---对话框---置换
    /// </summary>
    /// <param name="str"></param>
    /// <param name="cb"></param>
    public void Step5(string[] str)
    {
        SetGuideUI(true);
        StartShowWord(str, ChangeStep);
    }
 
    private void ChangeStep()
    {
        //开始引导
        Step5Drag(0);
    }
 
    /// <summary>
    /// 第12步,交换水火塔 
    /// </summary>
    public void Step5Drag(int currentIndex)
    {
        if (currentIndex == 0)
        {
            GameConfig.CanDragTower = true;
            //标记水塔 引导拖动
            towerPos.GetComponent<Image>().raycastTarget = false;
            towerPos2.GetComponent<Image>().raycastTarget = false;
            //backgroundImg.raycastTarget = false;
            tmpMask.enabled = 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)
        {
            tmpMask.enabled = true;
 
            SetRimActive(false);
            StopShowDragPath(true);
            CloseGuidance();
        }
    }
 
    /// <summary>
    /// 对话完毕后展示水
    /// </summary>
    /// <param name="str"></param>
    /// <param name="ac"></param>
    public void Step5Talk(string[] str, Action ac)
    {
        SetGuideUI(true);
        StartShowWord(str, ac);
    }
 
    public void Step5_7(Action cb)
    {
        //关闭对话框
        SetGuideUI(false);
        towerBuyBtn.gameObject.SetActive(true);
 
        //开箱
        boxPanel.ChangeType(GuideBoxType.Water, cb);
    }
 
 
    /// <summary>
    ///  步骤6:购买---上阵---第三关---杀光---结束引导
    /// </summary>
    /// <param name="str"></param>
    public void Step6(string[] str)
    {
        strArray = str;
        tmpMask.enabled = false;
 
        AddButtonListener(towerBuyBtn, Step6_1);
        Image btnImg = towerBuyBtn.GetComponent<Image>();
        InitRectGuidance(btnImg, 159, 73.5f, Vector2.one);
        SetRimPos(towerBuyBtn);
        StartCoroutine(ShowRimTip(strArray[0]));
    }
 
    /// <summary>
    /// 购买水
    /// </summary>
    private void Step6_1()
    {
        WaterAppear();
    }
 
    private void WaterAppear()
    {
        if (!water.gameObject.activeSelf)
        {
            water.gameObject.SetActive(true);
            //fire.transform.Find("Image_2").gameObject.SetActive(false);
            water.enabled = true;
            waterPS1.Play();
            waterPS2.Play();
            RemoveButtonListener(towerBuyBtn);
            towerBuyBtn.gameObject.SetActive(false);
 
            Step6_2();
        }
    }
    /// <summary>
    /// 引导上阵
    /// </summary>
    private void Step6_2()
    {
        tmpMask.enabled = true;
        offectBackground.SetActive(false);
        SetRimActive(true);
        Image btnImg = transform.Find("Image_TowerPos3").GetComponent<Image>();
        towerPos3.enabled = true;
        InitRectGuidance(btnImg, 75, 80, tmpOffect);
        SetRimPos(btnImg.gameObject);
        ShowDragPath(water.GetStartP, btnImg.rectTransform);
        image_Tip_Rect.gameObject.SetActive(false);
    }
    public void OnWaterAttackPos()
    {
        SetRimActive(false);
        CloseGuidance();
        StopShowDragPath(true);
    }
 
    /// <summary>
    /// 步骤7:一大波敌人---引导释放技能
    /// </summary>
    public void Step7()
    {
        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 < 6)
        {
            colorCount++;
            warningImg.DOFade(colorCount % 2, 1.0f).OnComplete(SetWarningColor);
            CommonDebugHelper.Debug($"执行了{colorCount}次");
        }
        else
        {
            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateFourthWave);//开始第三关
            warningImg.gameObject.SetActive(false);
        }
    }
 
 
    public void Step7Talk(string[] str, Action ac)
    {
        callBack = ac;
        SetGuideUI(true);
        StartShowWord(str, GuideEnergyUp);
    }
 
    Button skillBtn;//
 
    /// <summary>
    /// 引导释放技能
    /// </summary>
    public void GuideEnergyUp()
    {
        GameObject.Find("UICamera/MainUI/BloodUI").SetActive(false);
        EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.GuideEnergyUp, 100);
 
        tmpMask.enabled = false;
        skillBtn.interactable = true;
        SetGuideUI(false);
 
        SetRimActive(true);
        AddButtonListener(skillBtn.gameObject, callBack);
        Image btnImg = skillBtn.GetComponent<Image>();
        InitRectGuidance(btnImg, 79, 79f, Vector2.one);
        SetRimPos(skillBtn.gameObject, new Vector2(-15, -241));
        StartCoroutine(ShowRimTip("释放技能"));
    }
 
    public void SkillRelease(string[] str, Action ac)
    {
        GameObject.Find("UICamera/MainUI/BloodUI").SetActive(true);
 
        RemoveButtonListener(skillBtn.gameObject);
        SetRimActive(false);
        CloseGuidance();
 
        SetGuideUI(true);
        //StartShowWord(str, ac);
 
        charForeach.StartFinalShowWord(str, ac, () =>
        {
            finishPS.Play();
        });
 
    }
 
 
    public void FinishGuide()
    {
        towerBuyBtn.gameObject.SetActive(true);
    }
 
 
    #region 设置对话框
 
    /// <summary>
    /// 设置引导框
    /// </summary>
    /// <param name="active"></param>
    private void SetGuideUI(bool active)
    {
        if (tipsUI.activeSelf != active)
            tipsUI.SetActive(active);
    }
 
    //开始打印文字
    private void StartShowWord(string[] str, Action cb)
    {
        charForeach.StartShowWord(str, cb);
    }
 
    /// <summary>
    /// 立刻完成打印
    /// </summary>
    private void ShowWordImmediately()
    {
        charForeach.ShowWordImmediately();
    }
 
    #endregion
 
    #region 按钮以及提示
 
    private 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);
        }
 
    }
 
    /// <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 (!guidance.gameObject.activeSelf)
        {
            guidance.gameObject.SetActive(true);
        }
 
        if (target.gameObject.name == "TowerBuyBtn")
        {
            guidance.InitForCamera(target, towerBuyBtnPos, x, y);
        }
        else if (target.gameObject.name == "SkillBtn")
        {
            guidance.InitForCamera(target, skillBtnPos, x, y);
        }
        else
        {
            guidance.InitForCamera(target, x, y, offect);
        }
    }
 
    /// <summary>
    /// 关闭抠图
    /// </summary>
    public void CloseGuidance()
    {
        guidance.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 拖动效果
    RectTransform dragHandImg;//拖动标识手指
 
    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
 
}