public static BaseGame StartGame(List <GamePlayer> red, List <GamePlayer> blue, int mapIndex, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType); Map map = MapMgr.CloneMap(index); if (map != null) { BaseGame game = new BaseGame(red, blue, map, roomType, teamType, gameType, timeType); lock (m_games) { m_games.Add(game); } game.Prepare(); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create game error:", e); return(null); } }
public static BaseGame StartGame(List<GamePlayer> red, List<GamePlayer> blue, int mapIndex,eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex,(byte)roomType); Map map = MapMgr.CloneMap(index); if (map != null) { BaseGame game = new BaseGame(red, blue, map,roomType,teamType,gameType,timeType); lock (m_games) { m_games.Add(game); } game.Prepare(); return game; } else { return null; } } catch (Exception e) { log.Error("Create game error:", e); return null; } }
public void Execute(BaseGame game, long tick) { if (m_tick <= tick) { switch (game.GameState) { case eGameState.Inited: game.Prepare(); break; case eGameState.Prepared: game.StartLoading(); break; case eGameState.Loading: if (game.IsAllComplete()) { game.StartGame(); } break; case eGameState.Playing: if (game.CurrentPlayer == null || game.CurrentPlayer.IsAttacking == false) { if (game.CanGameOver()) { game.GameOver(); } else { game.NextTurn(); } } break; case eGameState.GameOver: game.Stop(); break; } m_isFinished = true; } }