chenxin
2020-12-25 6baa5a654138a2e0a9871adaef311a74e132dd6e
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
using TowerDefense.Towers;
using Core.Utilities;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using MoreMountains.NiceVibrations;
using TowerDefense.Level;
using KTGMGemClient;
using TowerDefense.UI.HUD;
using System.Collections;
 
/// <summary>
/// 无尽模式用自己的EndlessUIStart
/// </summary>
public class EndlessUIStart : Singleton<EndlessUIStart>
{
    //public TextMeshProUGUI countDownTextNew = null;
 
    public TextMeshProUGUI timeTextNew = null;
 
    //public TextMeshProUGUI timeStatic = null;
 
    /// <summary>
    /// 结算界面
    /// </summary>
    public GameObject SettlementUI;
 
    /// <summary>
    /// 倒计时整体的背景图片Mask
    /// </summary>
    public Image uiStartMssk = null;
 
    public AudioSource bgMusic;
 
    public static bool bFirstLoaded = false;
 
    public static bool bGameStart = false;
 
    protected float secToDo = 3f;
 
    protected float startTime = 0.0f;
 
    protected bool bossCreate = false;
 
    protected bool[] bVibrate;
 
    private bool isPause;
 
    public bool beginDragStep = false;
    public bool guideFourthWaveStep = false;
 
    public GameObject darkGroundImg;
 
    private CanvasGroup canvasGroup;
 
    public GameObject GMBtn;
 
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    protected override void Awake()
    {
        base.Awake();
 
        if (Application.platform == RuntimePlatform.WindowsEditor ||
         Application.platform == RuntimePlatform.WindowsPlayer)
        {
            GameConfig.useSDK = false;
            GameConfig.OpenDebug = true;
            GMBtn.SetActive(true);
        }
        else
        {
            GMBtn.SetActive(false);
        }
        //这里为了方便直接使用Endless2D
        GameObject root = GameObject.Find("ManagerRoot");
 
        if (root == null)
        {
 
            root = new GameObject("ManagerRoot");
 
            root.AddComponent<DoNotDestory>();
            root.AddComponent<MasterSocket>();
            root.AddComponent<TDAA_SDKManager>();
            root.AddComponent<AudioSourceManager>();
            root.AddComponent<JsonDataReader>();
            root.AddComponent<JsonDataInit>();
        }
        firstStart = true;
        //EventCenter.Ins.Add((int)KTGMGemClient.EventType.JsonDataReadDone, JsonDataReadDone);
    }
 
    Vector2 tmpOffect;//计算适配的偏移量
    bool firstStart = true;
    // Start is called before the first frame update
    void Start()
    {
        InitSDK();
        bGameStart = false;
        bFirstLoaded = false;
        GameConfig.IsUpgradeTowerLevel = false;
        GameConfig.CreateRandomTower = true;
 
        bVibrate = new bool[4];
        bVibrate[0] = bVibrate[1] = bVibrate[2] = bVibrate[3] = false;
 
        EndlessBuffSelect.instance.HideBuffUI();
        EndlessSettlement settlement = SettlementUI.transform.Find("BgMask").GetComponent<EndlessSettlement>();
        settlement.Init();
        SettlementUI.SetActive(false);
        EndlessMaskUI.instance.Hide();
        EndlessBossHPManager.instance.HideHP();
        EndlessScoreManager.instance.HideScore();
 
 
        float ratio = 0.06666667f;
        RectTransform ts = GetComponent<RectTransform>();
        float tmpScale = ratio / ts.localScale.x - 1.0f;
        float offect = tmpScale * (ts.sizeDelta.y * 0.5f);
        //Debug.Log($"tmpScale:{tmpScale}  offect:{offect}");
        tmpOffect = new Vector2(0, offect);
        transform.Find("Panel/Bottom").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
        transform.Find("Panel/TowerBuyBtn").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
        transform.Find("Panel/SwitchSpeed").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
        transform.Find("Panel/BuffPreviewButton").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
 
        transform.Find("Panel/BossHPBar").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
        transform.Find("Panel/Score").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
        transform.Find("Panel/TimeInfo").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
        //transform.Find("Panel/Boss").GetComponent<RectTransform>().anchoredPosition -= tmpOffect*0.5f;
 
 
        //darkGroundImg = transform.Find("Image_DarkGround").gameObject;
        darkGroundImg.GetComponent<RectTransform>().offsetMin += tmpOffect;
        darkGroundImg.GetComponent<RectTransform>().offsetMax -= tmpOffect * 0.5f;
 
        darkGroundImg.SetActive(false);
 
        //查询是否已经做过了新手引导
        //CheckIsNewbie();
 
        GameConfig.EndlessOpenAttackTowerCount = 0;
        GameConfig.EndlessBuyTowerCount = 0;
        GameConfig.EndlessPortUseSkillTowerCount = 0;
 
        AudioSourceManager.Ins.Play(AudioEnum.BGM2);
 
        fireSkillBgImg = transform.Find("Panel/Energy/FireSkillBg").GetComponent<Image>();
        transform.Find("Panel/Energy/FireSkillBg/SkillBtn").GetComponent<Button>().onClick.AddListener(OnClickFireSkillBtn);
        fireSkillLevelText = transform.Find("Panel/Energy/FireSkillBg/Level/Text").GetComponent<Text>();
        skillSliderValueRect = transform.Find("Panel/Energy/FireSkillBg/SliderValue").GetComponent<RectTransform>();
        skillSliderVStartP = skillSliderValueRect.anchoredPosition;
        skillSliderVStartHeight = skillSliderValueRect.sizeDelta;
 
        skillPS1 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao/03").gameObject;
        skillPS2 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao_02/03").gameObject;
        skillPS3 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao_03/03 (8)").gameObject;
 
        skillPS1.SetActive(false);
        skillPS2.SetActive(false);
        skillPS3.SetActive(false);
 
        transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(false);
        transform.Find("Panel/SwitchSpeed").gameObject.SetActive(false);
 
 
        GameConfig.EnergyCount = 0;
        GameConfig.SkillLevel = 1;
 
        //CalculateSkillSliderValue();
        transform.Find("Panel/Energy").gameObject.SetActive(false);
 
        canvasGroup = transform.Find("Panel").GetComponent<CanvasGroup>();
 
        EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EnergyUp, EnergyUp);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillLevelUpBuff, SkillLevelUpBuff);
 
 
    }
 
    private void CheckIsNewbie()
    {
        int guide = PlayerPrefs.GetInt("GemBattleGuide");
        GameConfig.IsNewbie = guide == 0;
 
        //GameConfig.IsNewbie = true;
 
        GameConfig.IsNewbieStart = GameConfig.IsNewbie;
 
        if (GameConfig.IsNewbie)
        {
            EndlessRandomTower.instance.SetCountDown(false);
 
            Debug.Log("开始新手引导");
            GameConfig.CanDragTower = false;
            Pause();
            HideUIMask();
            //countDownTextNew.text = "";
            //countDownTextNew.gameObject.SetActive(false);
            GameObject prefab = Resources.Load<GameObject>("UI/Guide/GuidePanel");
            GameObject guideObj = Instantiate(prefab, transform.Find("Panel"));
            guideObj.GetComponent<RectTransform>().offsetMin += tmpOffect;
            AddGuideEvent();
 
        }
        else
        {
            //开始倒计时
            StartCoroutine(StartCountDown());
        }
    }
    public GameObject countDownPS;
 
    IEnumerator StartCountDown()
    {
        countDownPS.SetActive(true);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        HideUIMask();
        //countDownTextNew.text = "";
        countDownPS.SetActive(false);
        bGameStart = true;
        // 开始关卡
        EndlessLevelManager.instance.StartLevel();
        timeTextNew.gameObject.SetActive(true);
 
        JsonDataReadDone();
        // 开始播放背景音乐.
        if (bgMusic != null)
            bgMusic.Play();
    }
 
    public void GameOver()
    {
        canvasGroup.alpha = 0;
        canvasGroup.interactable = false;
        GuideEnergyUp(0);
    }
 
    /// <summary>
    /// 所有数据读取完毕
    /// </summary>
    private void JsonDataReadDone()
    {
        Debug.Log("设置激活");
        transform.Find("Panel/Energy").gameObject.SetActive(true);
 
        if (!GameConfig.IsNewbie)
        {
            transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(true);
            transform.Find("Panel/SwitchSpeed").gameObject.SetActive(true);
            // cx test
            // GMBtn.SetActive(true);
        }
 
        fireSkillCost = JsonDataCenter.GetSkillLevelInfo(fireSkillID, GameConfig.SkillLevel).cost;
        bombSkillCost = JsonDataCenter.GetSkillLevelInfo(bombSkillID, GameConfig.SkillLevel).cost;
 
        energyMax = JsonDataCenter.GetById<battle>(22).value;
 
        //transform.Find("Panel/Energy/FireSkillBtn/Image/EnergyText").GetComponent<TextMeshProUGUI>().text = fireSkillCost.ToString();
        //transform.Find("Panel/Energy/BombSkillBtn/Image/EnergyText").GetComponent<TextMeshProUGUI>().text = bombSkillCost.ToString();
 
        EnergyUp(0);
    }
 
    /// <summary>
    /// 拖拽时候黑色背景
    /// </summary>
    /// <param name="isOn"></param>
    public void SetDarkGround(bool isOn)
    {
        if (darkGroundImg.activeSelf != isOn)
            darkGroundImg.SetActive(isOn);
    }
    private void InitSDK()
    {
        if (TDAA_SDKManager.Ins == null)
            gameObject.AddComponent<TDAA_SDKManager>();
        TDAA_SDKManager.Ins.ArriveBattle();//埋点
        TDAA_SDKManager.Ins.Statistics(4);//埋点
 
        if (AudioSourceManager.Ins == null)
            gameObject.AddComponent<AudioSourceManager>();
    }
 
    public void ShowUIMask()
    {
        uiStartMssk.gameObject.SetActive(true);
    }
 
    public void HideUIMask()
    {
        uiStartMssk.gameObject.SetActive(false);
    }
 
    /// <summary>
    /// 添加新手引导事件
    /// </summary>
    private void AddGuideEvent()
    {
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWoodLv2, CreateWoodLv2);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFirstWave, CreateFirstWave);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.RestartWave, RestartWave);
        EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.AddGold, AddGold);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFireLv1, CreateFireLv1);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1);
 
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateSecondWave, CreateSecondWave);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateThirdWave, CreateThirdWave);
 
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFourthWave, CreateFourthWave);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFourthWaveDone, CreateFourthWaveDone);
        EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.GuideEnergyUp, GuideEnergyUp);
 
 
        //EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillRelease, SkillRelease);
        EventCenter.Ins.Add((int)KTGMGemClient.EventType.GuideFinish, NewbieGuideEnd);
 
        //EventCenter.Ins.Add<Vector3>((int)KTGMGemClient.EventType.PlayAppearEffect, GuidePlayAppearEffect);
        EventCenter.Ins.Add<Vector3>((int)KTGMGemClient.EventType.GuidePlayUpgradeEffect, GuidePlayUpgradeEffect);
    }
 
    /// <summary>
    /// 在(2,3)位置放置一个火元素的塔
    /// </summary>
    private void CreateWoodLv2()
    {
        //GrowUpTower 火
        //BlinkTower 木
        //CopyCatTower 水
 
        Tower aTower = EndlessRandomTower.instance.getTowerByName("BlinkTower");
        EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(2, 3), 2);
    }
 
    /// <summary>
    /// 开始第一关的第一个波次
    /// </summary>
    private void CreateFirstWave()
    {
        Restart();
        //EventCenter.Ins.Add((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd);
    }
 
    /// <summary>
    /// 火塔充能释放完成
    /// </summary>
    private void OnFireTowerChargeEnd()
    {
        Pause();
        EndlessLevelManager.instance.PauseWave();
        //EventCenter.Ins.Remove((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd);
        //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.ChargingEnd);
    }
 
    /// <summary>
    /// 恢复波次
    /// </summary>
    private void RestartWave()
    {
        Restart();
        EndlessLevelManager.instance.RestartWave();
    }
 
    /// <summary>
    /// 获得金币
    /// </summary>
    /// <param name="gold"></param>
    private void AddGold(int gold)
    {
        EndlessLevelManager.instance.Currency.AddCurrency(gold);
    }
 
    /// <summary>
    /// 新手引导生成特效
    /// </summary>
    private void GuidePlayAppearEffect(Vector3 worldPos)
    {
        EndlessGameUI.instance.PlayAppearEffectGuide(worldPos);
    }
 
    /// <summary>
    /// 新手引导合成特效
    /// </summary>
    private void GuidePlayUpgradeEffect(Vector3 worldPos)
    {
        EndlessGameUI.instance.GuidePlayUpgradeEffect(worldPos);
    }
 
    /// <summary>
    /// 在攻击位置上创建一个1级的木塔
    /// </summary>
    private void CreateFireLv1()
    {
        Tower aTower = EndlessRandomTower.instance.getTowerByName("GrowUpTower");
        EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(1, 3), 1);
    }
 
    /// <summary>
    /// 在攻击位置上创建一个1级的木塔
    /// </summary>
    private void CreateWaterLv1()
    {
        Tower aTower = EndlessRandomTower.instance.getTowerByName("CopyCatTower");
        EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(3, 3), 1);
    }
 
    /// <summary>
    /// 开始第二关
    /// </summary>
    private void CreateSecondWave()
    {
        EndlessLevelManager.instance.NewbieUpdateLevel();
        beginDragStep = true;
    }
 
    /// <summary>
    /// 开始第三关
    /// </summary>
    private void CreateThirdWave()
    {
        CommonDebugHelper.Debug($"开始下一关");
 
        EndlessLevelManager.instance.NewbieUpdateLevel();
        beginDragStep = false;
    }
 
    /// <summary>
    /// 第三关出兵完毕,暂停出兵
    /// </summary>
    private void CreateFourthWaveDone()
    {
        EndlessLevelManager.instance.PauseWave();
    }
 
    /// <summary>
    /// 开始第四关
    /// </summary>
    private void CreateFourthWave()
    {
        CommonDebugHelper.Debug($"开始下一关");
 
        EndlessLevelManager.instance.NewbieUpdateLevel();
        guideFourthWaveStep = true;
    }
 
 
    /// <summary>
    /// 在第三条兵线释放技能宝石
    /// </summary>
    private void SkillRelease()
    {
        int attributeId = 99902;
        int level = 1;
        int waveLineIndex = 1;
 
        // 播放特效,并处理伤害.
        EndlessWaveLineManager.instance.PlayWaveLineEffect(waveLineIndex);
        AgentInsManager.instance.ExecWavelineAttack(waveLineIndex, attributeId, level, false);
        ++GameConfig.EndlessPortUseSkillTowerCount;
        StartCoroutine(Delay1());
    }
 
    private IEnumerator Delay1()
    {
        yield return new WaitForSeconds(1f);
        EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillReleaseDone);
    }
 
    /// <summary>
    /// 新手引导结束
    /// </summary>
    private void NewbieGuideEnd()
    {
        EndlessLevelManager.instance.RestartWave();
        GameConfig.IsNewbie = false;
        transform.Find("Panel/SwitchSpeed").gameObject.SetActive(true);
        transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(true);
    }
 
    /// <summary>
    /// 当前游戏局的开始时间.
    /// </summary>
    public float GameStartTime
    {
        get { return startTime; }
    }
 
    protected string ConvertSec(float sec)
    {
        if (sec < 10)
            return "0" + Math.Floor(sec).ToString();
        else
            return Math.Floor(sec).ToString();
    }
 
    /// <summary>
    /// 把当前的秒数变成字符串.
    /// </summary>
    /// <param name="sec"></param>
    /// <returns></returns>
    protected string ConvertTime(float sec)
    {
        if (sec < 60)
        {
            return "00:" + ConvertSec(sec);
        }
        else
        {
            float min = sec / 60;
            if (min < 10)
            {
                return "0" + Math.Floor(min).ToString() + ":" + ConvertSec(sec % 60);
            }
            else
            {
                return Math.Floor(min).ToString() + ":" + ConvertSec(sec % 60);
            }
        }
    }
 
    #region 点击右侧技能按钮释放技能
 
    private int fireSkillCost, bombSkillCost;//两个技能花费
    private int fireSkillID = 99902;
    private int bombSkillID = 99901;
    private int energyMax = 0;//能量最大值,目前写死
    private Color normalColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
    private Color disColor = new Color(1.0f, 1.0f, 1.0f, 0);
    private Text fireSkillLevelText;
    private Image fireSkillBgImg;
    private GameObject skillPS1, skillPS2, skillPS3;
 
    /// <summary>
    /// 点击火技能
    /// </summary>
    private void OnClickFireSkillBtn()
    {
        if (GameConfig.InfiniteSkill)
        {
            GuideEnergyUp(200);
            EndlessWaveLineManager.instance.PlayAllWaveLineEffect();
            AgentInsManager.instance.ExecAllWavelineAttack(fireSkillID, GameConfig.SkillLevel, false);
            return;
        }
 
        //Debug.Log("释放了火技能:" + GameConfig.EnergyCount + "  fireSkillCost:" + fireSkillCost);
        if (GameConfig.EnergyCount >= fireSkillCost)
        {
            EnergyUp(-fireSkillCost);
            Debug.Log("释放了火技能" + GameConfig.SkillLevel);
            // 播放特效,并处理伤害.
            EndlessWaveLineManager.instance.PlayAllWaveLineEffect();
            AgentInsManager.instance.ExecAllWavelineAttack(fireSkillID, GameConfig.SkillLevel, false);
            ++GameConfig.EndlessPortUseSkillTowerCount;
        }
        else
        {
            AudioSourceManager.Ins.Play(AudioEnum.UIDisable);
        }
    }
 
    public void GuideEnergyUp(int count)
    {
        GameConfig.EnergyCount = count;
        EnergyUp(0);
    }
 
    /// <summary>
    /// 击杀小怪能量(释放技能使用)
    /// </summary>
    private void EnergyUp(int upCount)
    {
        GameConfig.EnergyCount += upCount;
        if (GameConfig.EnergyCount > energyMax)
        {
            GameConfig.EnergyCount = energyMax;
        }
        CalculateSkillSliderValue();
 
        if (GameConfig.EnergyCount >= fireSkillCost)
        {
            if (GameConfig.EnergyCount == energyMax)
            {
                //Debug.Log("能量已满");
                if (fireSkillBgImg.color != disColor)
                {
                    fireSkillBgImg.color = disColor;
                }
                if (!skillPS1.activeSelf) skillPS1.SetActive(true);
                if (!skillPS2.activeSelf) skillPS2.SetActive(true);
                if (skillPS3.activeSelf) skillPS3.SetActive(false);
                //skillPS1.Play();
                //skillPS2.Play();
            }
            else
            {
                //Debug.Log("能量达到一次使用");
                if (fireSkillBgImg.color != normalColor)
                {
                    fireSkillBgImg.color = normalColor;
                }
                if (skillPS1.activeSelf) skillPS1.SetActive(false);
                if (!skillPS2.activeSelf) skillPS2.SetActive(true);
                if (!skillPS3.activeSelf) skillPS3.SetActive(true);
 
                //if (skillPS1.isPlaying) skillPS1.Stop();
                //if (!skillPS2.isPlaying) skillPS2.Play();
            }
        }
        else
        {
            //Debug.Log("能量不够");
            if (fireSkillBgImg.color != normalColor)
            {
                fireSkillBgImg.color = normalColor;
            }
            if (skillPS1.activeSelf) skillPS1.SetActive(false);
            if (skillPS2.activeSelf) skillPS2.SetActive(false);
            if (skillPS3.activeSelf) skillPS3.SetActive(false);
            // if (skillPS1.isPlaying) skillPS1.Stop();
            // if (skillPS2.isPlaying) skillPS2.Stop();
 
        }
    }
 
    RectTransform skillSliderValueRect;
    Vector2 skillSliderVStartP;
    Vector2 skillSliderVStartHeight;
 
    private void CalculateSkillSliderValue()
    {
        float value = (float)GameConfig.EnergyCount / 200.0f;
        float height = skillSliderVStartHeight.y * value;
        float y = skillSliderVStartP.y - (skillSliderVStartHeight.y - height) * 0.5f;
        skillSliderValueRect.sizeDelta = new Vector2(skillSliderVStartHeight.x, height);
        skillSliderValueRect.anchoredPosition = new Vector2(skillSliderVStartP.x, y);
 
    }
 
 
    /// <summary>
    /// 增加技能等级的事件监听
    /// </summary>
    private void SkillLevelUpBuff()
    {
        if (GameConfig.SkillLevel <= 5)
        {
            GameConfig.SkillLevel++;
            fireSkillCost = JsonDataCenter.GetSkillLevelInfo(fireSkillID, GameConfig.SkillLevel).cost;
            bombSkillCost = JsonDataCenter.GetSkillLevelInfo(bombSkillID, GameConfig.SkillLevel).cost;
            //Debug.Log($"技能最高5级,当前技能等级:{GameConfig.SkillLevel}  fireSkillCost:{fireSkillCost}  ");
            fireSkillLevelText.text = GameConfig.SkillLevel + "级";
        }
    }
 
 
 
 
    #endregion
 
    public void Pause()
    {
        isPause = true;
    }
 
    public void Restart()
    {
        isPause = false;
    }
 
    public bool IsGameRunning { get { return !isPause; } }
 
    private bool isUpgradeTowerLevel;
 
    // Update is called once per frame
    void Update()
    {
        if (firstStart)
        {
            if (!GameConfig.JsonReadDone)
                return;
            else
            {
                firstStart = false;
                CheckIsNewbie();
            }
        }
        if (isPause) return;
 
        if (bGameStart)
        {
            startTime += Time.deltaTime;
 
            // if (!isUpgradeTowerLevel && startTime >= JsonDataCenter.DOUBLE_GEM_TIME)
            // {
            //     EndlessRandomTower.instance.UpdateDescDisplay();
            //     isUpgradeTowerLevel = true;
            // }
 
            timeTextNew.text = ConvertTime((float)Math.Ceiling(startTime));
        }
 
        if (GameConfig.IsNewbie)
        {
            // 新手走的流程
            if (!bFirstLoaded && !bGameStart)
                bFirstLoaded = true;
 
            if (bFirstLoaded && !bGameStart)
            {
                bGameStart = true;
                EndlessLevelManager.instance.StartLevel();
                timeTextNew.gameObject.SetActive(true);
 
                JsonDataReadDone();
 
                if (bgMusic != null)
                    bgMusic.Play();
            }
        }
 
    }
}