少年修仙传客户端代码仓库
client_Hale
2019-03-04 03a7dc0924450a37c9c1972edbdbd0154945836c
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
using UnityEngine;
using H2Engine;
 
public class EventRefreshNPCHandler : IEventHandler
{
    private Evt_RefreshMonster m_Evt = null;
 
    private int m_DeadCount = 0;
    private float m_Duration = 0;
    private int m_RefreshCount = -1;
    private float m_RefreshInterval = 0;
 
    public int GetEventID()
    {
        if (m_Evt != null)
        {
            return m_Evt.id;
        }
        return -1;
    }
 
    public Evt.E_EventType GetEventType()
    {
        return Evt.E_EventType.Enemy;
    }
 
    public void Init(Evt evt)
    {
        m_Evt = evt as Evt_RefreshMonster;
        m_DeadCount = 0;
        m_Duration = 0;
        m_RefreshCount = -1;
        m_RefreshInterval = 0;
    }
 
    public void Update()
    {
        if (IsCompelete() && m_Duration > 0)
        {
            return;
        }
 
        m_Duration += Time.deltaTime;
 
        // 此模式下刷出第一只怪
        if (m_Evt.refreshType == Evt_RefreshMonster.E_RefreshType.OneByOnePrevDie)
        {
            if (m_RefreshCount == -1)
            {
                RefreshNpc();
            }
        }
        else if (m_Evt.refreshType == Evt_RefreshMonster.E_RefreshType.All)
        {
            RefreshAll();
        }
        else if (m_Evt.refreshType == Evt_RefreshMonster.E_RefreshType.OneByOneTime)
        {
            m_RefreshInterval += Time.deltaTime;
            if (m_RefreshInterval > m_Evt.refreshParam)
            {
                m_RefreshInterval = 0;
                RefreshNpc();
            }
        }
    }
 
    public void NpcDead(int npcID)
    {
        m_DeadCount += 1;
        Debug.LogFormat("通知死亡: {0}, 当前计数: {1}", npcID, m_DeadCount);
        if (m_Evt.refreshType == Evt_RefreshMonster.E_RefreshType.OneByOnePrevDie)
        {
            RefreshNpc();
        }
 
        CA225_tagCMClientTaskCount _a225 = new CA225_tagCMClientTaskCount
        {
            CountID = (uint)npcID
        };
        GameNetSystem.Instance.SendInfo(_a225);
    }
 
    private void RefreshNpc()
    {
        m_RefreshCount += 1;
        if (m_RefreshCount >= 0 && m_RefreshCount < m_Evt.monsters.Length)
        {
            var _data = m_Evt.monsters[m_RefreshCount];
            var _npc = GAMgr.Instance.ReqClntFightNpc<GA_NpcClientFightNorm>((uint)_data.npcID, E_ActorGroup.Enemy);
            _npc.Pos = _data.position;
            _npc.belongEventID = m_Evt.id;
        }
    }
 
    private void RefreshAll()
    {
        if (m_RefreshCount < m_Evt.monsters.Length)
        {
            foreach (var _data in m_Evt.monsters)
            {
                var _npc = GAMgr.Instance.ReqClntFightNpc<GA_NpcClientFightNorm>((uint)_data.npcID, E_ActorGroup.Enemy);
                _npc.Pos = _data.position;
                _npc.belongEventID = m_Evt.id;
            }
            m_RefreshCount = m_Evt.monsters.Length;
        }
    }
 
    public void UnInit()
    {
        Debug.LogFormat("事件: {0} => UnInit()", m_Evt.id);
    }
 
    public bool IsCompelete()
    {
        if (m_Evt == null)
        {
            return true;
        }
 
        if (m_Evt.overCondition == Evt_RefreshMonster.E_OverCondition.DeadCount)
        {
            if (m_Evt.conditionParam <= 0)
            {
                return m_DeadCount >= m_Evt.monsters.Length;
            }
 
            return m_DeadCount >= m_Evt.conditionParam;
        }
        else if (m_Evt.overCondition == Evt_RefreshMonster.E_OverCondition.Time)
        {
            return m_Duration >= m_Evt.conditionParam && m_DeadCount >= m_Evt.monsters.Length;
        }
        return false;
    }
}