-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfighelper.java
129 lines (121 loc) · 3.62 KB
/
confighelper.java
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
import android.text.Layout;
import android.view.View;
/**
* Created by a on 2017/4/15.
*/
//配置当前游戏内玩家类型
public class ConfigHelper {
//参与玩家数
private int LocalHumanNum,OnlineHumanNum,AINum;
private int GameType;//
private int PlayerType[]=new int[4];
private boolean Host;
//private int redType,yellowType,blueType,greenType;
public ConfigHelper(int GAMETYPE){
GameType=GAMETYPE;
if(GAMETYPE==Value.Online){
LocalHumanNum=1;
OnlineHumanNum=3;
AINum=0;
}
else if(GAMETYPE==Value.Local){
LocalHumanNum=4;
OnlineHumanNum=0;
AINum=0;
}
Host=true;//默认为主机
PlayerType[Value.red]=Value.LocalHuman;
PlayerType[Value.yellow]=Value.LocalHuman;
PlayerType[Value.blue]=Value.LocalHuman;
PlayerType[Value.green]=Value.LocalHuman;
}
//托管模式下,切换棋子模式
public void cgPlayerType(int FACTION,int TYPE){
if(TYPE==Value.LocalHuman) LocalHumanNum++;
else if(TYPE==Value.OnlineHuman) OnlineHumanNum++;
else if(TYPE==Value.AI) AINum++;
int t=0;
if(FACTION==Value.red){
t=PlayerType[Value.red];//获取该棋子原本的类型
setRedType(TYPE);
}
else if(FACTION==Value.yellow){
t=PlayerType[Value.yellow];
setYellowType(TYPE);
}
else if(FACTION==Value.blue){
t=PlayerType[Value.blue];
setBlueType(TYPE);
}
else if(FACTION==Value.green){
t=PlayerType[Value.green];
setGreenType(TYPE);
}
//根据该棋子原本的类型,减少对应的玩家类型数
switch(t){
case Value.LocalHuman:
LocalHumanNum--;
break;
case Value.OnlineHuman:
OnlineHumanNum--;
break;
case Value.AI:
AINum--;
break;
}
}
//重置所有棋子的模式
public void resetStatusALL(){
if(GameType==Value.Online){
LocalHumanNum=1;
OnlineHumanNum=3;
AINum=0;
}
else if(GameType==Value.Local){
LocalHumanNum=4;
OnlineHumanNum=0;
AINum=0;
}
PlayerType[Value.red]=Value.LocalHuman;
PlayerType[Value.yellow]=Value.LocalHuman;
PlayerType[Value.blue]=Value.LocalHuman;
PlayerType[Value.green]=Value.LocalHuman;
}
//设置各个阵营棋子的游戏模式
public void setRedType(int TYPE){
PlayerType[Value.red]=TYPE;
}
public void setYellowType(int TYPE){
PlayerType[Value.yellow]=TYPE;
}
public void setBlueType(int TYPE){
PlayerType[Value.blue]=TYPE;
}
public void setGreenType(int TYPE){
PlayerType[Value.green]=TYPE;
}
public void setHost(boolean host) {
Host = host;
}
public int getGameType(){
return GameType;
}
public boolean isHost() {
return Host;
}
public int getPlayerType(int FACTION) {
return PlayerType[FACTION];
}
public int getRedType(){
return PlayerType[Value.red];
}
public int getYellowType(){
return PlayerType[Value.yellow];
}
public int getBlueType(){
return PlayerType[Value.blue];
}
public int getGreenType(){
return PlayerType[Value.green];
}
}