-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFightObjList.go
114 lines (104 loc) · 2.7 KB
/
FightObjList.go
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
package GameFight
type FightObjList struct {
mOwnerGuid X_GUID
mObjectList [MaxMatrixCellCount]*FightObject
}
func (list *FightObjList) CleanUp() {
list.mOwnerGuid = InvalidId
for i := 0; i < MaxMatrixCellCount; i++ {
list.mObjectList[i].CleanUp()
}
}
func (list *FightObjList) SetOwnerGuid(guid X_GUID) {
list.mOwnerGuid = guid
}
func (list *FightObjList) GetOwnerGuid() X_GUID {
return list.mOwnerGuid
}
func (list *FightObjList) GetActiveCount() int {
nCount := 0
for i := 0; i < MaxMatrixCellCount; i++ {
if list.mObjectList[i].IsActive() {
nCount += 1
}
}
return nCount
}
func (list *FightObjList) GetInactiveCount() int {
nCount := 0
for i := 0; i < MaxMatrixCellCount; i++ {
if list.mObjectList[i].IsValid() && !list.mObjectList[i].IsActive() {
nCount += 1
}
}
return nCount
}
func (list *FightObjList) GetFightObject(index int) *FightObject {
if index >= 0 && index < MaxMatrixCellCount {
return list.mObjectList[index]
}
return nil
}
func (list *FightObjList) FillObject(index int, object *FightObject) bool {
if !object.IsValid() {
return false
}
if index < 0 || index >= MaxMatrixCellCount {
return false
}
if list.mObjectList[index] != nil && list.mObjectList[index].IsValid() {
return false
}
object.SetMatrixID(index)
list.mObjectList[index] = object
return true
}
func (list *FightObjList) Init(fightDB *FightDB) bool {
if !fightDB.IsValid() {
return false
}
list.SetOwnerGuid(fightDB.HumanGuid)
for i := 0; i < fightDB.FightCount; i++ {
fightDBData := fightDB.FightDBData[i]
if fightDBData.IsValid() {
fightObj := new(FightObject)
fightObj.InitFightDBData(fightDBData)
index := fightObj.GetMatrixID()
list.mObjectList[index] = fightObj
}
}
return true
}
func (list *FightObjList) ImpactHeartBeat(uTime int) {
for i := 0; i < MaxMatrixCellCount; i++ {
if list.mObjectList[i].IsActive() {
//清空英雄的impact
list.mObjectList[i].ClearImpactEffect()
//impact攻击逻辑
list.mObjectList[i].ImpactHeartBeat(uTime)
}
}
}
//攻击
func (list *FightObjList) HeartBeat(uTime int) {
for i := 0; i < MaxMatrixCellCount; i++ {
if list.mObjectList[i].IsActive() {
//fmt.Printf("第%+v回合, 英雄id %+v \n",uTime, list.mObjectList[i].GetGuid())
list.mObjectList[i].HeartBeat(uTime)
pAttackInfo := list.mObjectList[i].GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pFightCell := list.mObjectList[i].GetFightCell()
pRoundInfo := pFightCell.GetRoundInfo()
pRoundInfo.AddAttackInfo(*pAttackInfo)
}
}
}
}
//清除所有buff
func (list *FightObjList) ClearImpactEffect() {
for i := 0; i < MaxMatrixCellCount; i++ {
if list.mObjectList[i].IsActive() {
list.mObjectList[i].ClearImpactEffect()
}
}
}