Skip to content

Commit

Permalink
后台控制比赛逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
TastSong committed May 16, 2022
1 parent 8aab808 commit 95e22ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 0 additions & 8 deletions CrazyCar/Assets/Scripts/System/MatchRoomSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,8 @@ public void MatchRoomStart() {
w.Write(this.GetModel<IMatchModel>().RoomId);
w.WritePropertyName("uid");
w.Write(this.GetModel<IUserModel>().Uid);
w.WritePropertyName("map_id");
w.Write(info.mapId);
w.WritePropertyName("cid");
w.Write(info.cid);
w.WritePropertyName("limit_time");
w.Write(info.limitTime);
w.WritePropertyName("times");
w.Write(info.times);
w.WritePropertyName("start_time");
w.Write(Util.GetTime() / 1000 + this.GetModel<IGameModel>().MatchStartGameTime);
w.WriteObjectEnd();
Debug.Log("MatchRoomStart : " + sb.ToString());
this.GetSystem<IWebSocketSystem>().SendMsgToServer(sb.ToString());
Expand Down
2 changes: 1 addition & 1 deletion CrazyCar/Assets/Scripts/UI/Match/MatchRoomStatusUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MatchRoomStatusUI : MonoBehaviour, IController {
public Button mapBtn;
public MatchRoomMapUI mapUI;

private int maxNum = 2;
private int maxNum = 1;

private void Awake() {
this.RegisterEvent<MatchRoomUpdateStatusEvent>(OnMatchRoomUpdateStatus).UnRegisterWhenGameObjectDestroyed(gameObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MatchRoomPlayerInfo{
private int maxNum = 2;
private int curUid;
private String roomId = "";
private Integer startOffsetTime = 16;

// id = uid + "," + room_id
@OnOpen
Expand Down Expand Up @@ -165,10 +166,11 @@ private void onStatusRoom(JSONObject message) {

private void onStartRoom(JSONObject message) {
String roomId = message.getString("room_id");
Integer mapId = message.getInteger("map_id");
Integer limitTime = message.getInteger("limit_time");
Integer times = message.getInteger("times");
long startTime = message.getLong("start_time");
Integer mapCid = message.getInteger("cid");
Integer mapId = getIntData(mapCid, "map_id");
Integer limitTime = getIntData(mapCid, "limit_time");
Integer times = getIntData(mapCid, "times");
long startTime = System.currentTimeMillis()/1000 + startOffsetTime;
long enrollTime = System.currentTimeMillis()/1000;
String mapName = "TastSong";
Integer star = 2;
Expand All @@ -191,7 +193,7 @@ private void onStartRoom(JSONObject message) {
data.put("enroll_time", enrollTime);
data.put("code", 200);
}
System.out.println("OnStatusRoom : " + data.toString());
System.out.println("onStartRoom : " + data.toString());
sendToUser(data.toString(), roomId);
}

Expand All @@ -201,6 +203,12 @@ private int getCid(String roomId, long startTime) {
return Util.JDBC.executeSelectInt(sql, "cid");
}

private int getIntData(int cid, String key) {
String sql = "select " + key + " from match_map where cid = "
+ cid + ";";
return Util.JDBC.executeSelectInt(sql, key);
}

public void sendToUser(String message, String roomId) {
//String now = getNowTime();
for (String key : webSocketSet.keySet()) {
Expand Down

0 comments on commit 95e22ed

Please sign in to comment.