Skip to content

Commit

Permalink
优化游戏结束的条件判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Sobadfish committed Oct 28, 2023
1 parent b3d7c05 commit 521e4c6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,28 @@ DLC实体类要实现接口,重写方法
```
IGameRoomDlc
```
#### 重写结束条件
如果要重写小游戏房间的结束条件 继承接口
```
IGameEndJudge
//重写
boolean judgeGameEnd(GameRoom room);
```
当实现的方法 返回值为true 则立即结束此游戏
此时就需要你在这个方法中设置好胜利的队伍与失败的队伍,总得有胜利者不是吗
你可以调用GameRoom中的方法。
```
/**
*@param teamInfo 胜利的队伍
* @param more 是否为多队伍模式
*/
public void gameEnd(TeamInfo teamInfo,boolean more);
```
不过这个方法有局限性 你可以参考GameRoom中的demoGameEnd 来开发

#### 重写计分板

实现接口中的方法可以重写玩家在游戏中的计分板信息
```
IGamePlayerScoreBoard
```
8 changes: 8 additions & 0 deletions src/main/java/org/sobadfish/gamedemo/room/GameRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,14 @@ private void onEnd() {
public void gameEnd(TeamInfo teamInfo,boolean more){
if(!more){
teamInfo.echoDefeat();
}else{
//其他队伍失败...
for(TeamInfo otherTeamInfo: teamInfos){
if(otherTeamInfo.equals(teamInfo)){
continue;
}
otherTeamInfo.echoDefeat();
}
}
teamInfo.echoVictory();
teamInfo.givePlayerAward();
Expand Down

0 comments on commit 521e4c6

Please sign in to comment.