chenxin
2020-10-28 56f231f1f6523d7920cf32f033f9bb6f0015550f
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
using Core.Utilities;
using DG.Tweening;
using System.Collections.Generic;
using TowerDefense.Level;
using UnityEngine;
 
public class EndlessWaveLineManager : Singleton<EndlessWaveLineManager>
{
    /// <summary>
    /// 兵线对应的选中效果
    /// </summary>
    public List<GameObject> waveLineList;
 
    /// <summary>
    /// 标注战场区域的Object.
    /// </summary>
    public GameObject battleAreaObject;
 
    /// <summary>
    /// 火攻击效果
    /// </summary>
    public GameObject skillFirePrefab;
 
    /// <summary>
    /// 炸弹攻击效果
    /// </summary>
    public GameObject skillBombPrefab;
 
    /// <summary>
    /// 停止移动的Buff特效.
    /// </summary>
    public GameObject bufStopMovePrefab;
 
    protected bool zeroState = true;
 
    // Start is called before the first frame update
    void Start()
    {
        for (int ti = 0; ti < waveLineList.Count; ti++)
        {
            if (waveLineList[ti])
            {
                Material tmat = waveLineList[ti].GetComponent<MeshRenderer>().material;
                tmat.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
            }
        }
    }
 
    /// <summary>
    /// 在某一兵线上播放技能特效
    /// </summary>
    public void PlayWaveLineEffect(int id)
    {
        if (id >= waveLineList.Count || waveLineList[id] == null) return;
 
        GameObject obj = Instantiate(skillFirePrefab);
        ParticleSystem ps = obj.GetComponent<ParticleSystem>();
 
        if (ps == null)
            ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
        ps.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(id);
        ps.Play();
        Destroy(obj, ps.main.duration);
    }
 
    /// <summary>
    /// 在战场内某一个位置播放特效
    /// </summary>
    /// <param name="pos"></param>
    public void PlayBattleAreaBombEffect(Vector3 pos)
    {
        if (skillBombPrefab == null) return;
 
        GameObject obj = Instantiate(skillBombPrefab);
        ParticleSystem ps = obj.GetComponent<ParticleSystem>();
 
        if (ps == null)
            ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
        ps.transform.position = pos;
        ps.Play();
        Destroy(obj, ps.main.duration);
    }
 
    /// <summary>
    /// 对应兵线发亮.
    /// </summary>
    /// <param name="id"></param>
    public void WaveLineFlash(int id)
    {
        if (id >= waveLineList.Count || waveLineList[id] == null) return;
 
        //设置一个DOTween队列
        Sequence flashSeq = DOTween.Sequence();
        Material tmat = waveLineList[id].GetComponent<MeshRenderer>().material;
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.1f));
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.2f), 0.08f));
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.08f));
        flashSeq.AppendInterval(0.05f);
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.2f), 0.08f));
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.08f));
        flashSeq.AppendInterval(0.05f);
        flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.25f));
    }
 
    /// <summary>
    /// 对某一条兵线显示选中效果
    /// </summary>
    /// <param name="id"></param>
    public void FadeWaveline(int id, bool fadeOut, float ftime = 0.3f)
    {
        if (id >= waveLineList.Count || waveLineList[id] == null) return;
        Material tmat = waveLineList[id].GetComponent<MeshRenderer>().material;
        if (fadeOut)
            tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), ftime);
        else
            tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), ftime);
    }
 
    /// <summary>
    /// 某一个位置攻击塔位放下。
    /// </summary>
    /// <param name="pos"></param>
    public void AttackTowerFixed(int pos)
    {
        if (pos >= waveLineList.Count || waveLineList[pos] == null) return;
 
        // 无尽模式改为只有一条兵线
        WaveLineFlash(pos);
    }
}