Ejemplo n.º 1
0
        public static BattleGame StartBattleGame(List <IGamePlayer> red, ProxyRoom roomRed, List <IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId);
                Map map   = MapMgr.CloneMap(index);

                if (map != null)
                {
                    BattleGame game = new BattleGame(m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType);

                    lock (m_games)
                    {
                        m_games.Add(game.Id, game);
                    }
                    game.Prepare();
                    SendStartMessage(game);
                    return(game);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                log.Error("Create battle game error:", e);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static BattleGame StartBattleGame(List <IGamePlayer> red, ProxyRoom roomRed, List <IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            BattleGame result;

            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, GameMgr.m_serverId);
                Map map   = MapMgr.AllocateMapInstance(index);
                if (map != null)
                {
                    BattleGame game = new BattleGame(GameMgr.m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType, 0);
                    game.GameOverLog += new BaseGame.GameOverLogEventHandle(roomRed.LogFight);
                    Dictionary <int, BaseGame> games;
                    Monitor.Enter(games = GameMgr.m_games);
                    try
                    {
                        GameMgr.m_games.Add(game.Id, game);
                    }
                    finally
                    {
                        Monitor.Exit(games);
                    }
                    game.Prepare();
                    GameMgr.SendStartMessage(game);
                    GameMgr.SendBufferList(game);
                    GameMgr.UpdatePlayerGameId(game);
                    result = game;
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception e)
            {
                GameMgr.log.Error("Create battle game error:", e);
                result = null;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static BattleGame StartBattleGame(List <IGamePlayer> red, ProxyRoom roomRed, List <IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            BattleGame result;

            try
            {
                int mapIndex2 = MapMgr.GetMapIndex(mapIndex, (byte)roomType, GameMgr.m_serverId);
                Map map       = MapMgr.CloneMap(mapIndex2);
                List <PetSkillElementInfo> gameNeedPetSkill = PetMgr.GameNeedPetSkill();
                if (map != null)
                {
                    BattleGame battleGame = new BattleGame(GameMgr.m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType, gameNeedPetSkill);
                    Dictionary <int, BaseGame> games;
                    Monitor.Enter(games = GameMgr.m_games);
                    try
                    {
                        GameMgr.m_games.Add(battleGame.Id, battleGame);
                    }
                    finally
                    {
                        Monitor.Exit(games);
                    }
                    battleGame.Prepare();
                    GameMgr.SendStartMessage(battleGame);
                    result = battleGame;
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception exception)
            {
                GameMgr.log.Error("Create battle game error:", exception);
                result = null;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static BattleGame StartBattleGame(List<IGamePlayer> red, ProxyRoom roomRed, List<IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId);
                Map map = MapMgr.CloneMap(index);

                if (map != null)
                {
                    BattleGame game = new BattleGame(m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType);

                    lock (m_games)
                    {
                        m_games.Add(game.Id, game);
                    }
                    game.Prepare();
                    SendStartMessage(game);
                    return game;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                log.Error("Create battle game error:", e);
                return null;
            }
        }