示例#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);
            }
        }
示例#2
0
        public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, 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)
                {
                    PVPGame game = new PVPGame(m_gameId++, roomId, red, blue, map, roomType, gameType, timeType);
                    game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    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);
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
 private static void StartMatchGame(ProxyRoom red, ProxyRoom blue)
 {
     try
     {
         int       mapId    = MapMgr.GetMapIndex((red.AvgLevel + blue.AvgLevel) / 2, ProxyRoomMgr.m_serverId);
         eGameType gameType = eGameType.Free;
         if (red.GameType == blue.GameType)
         {
             gameType = red.GameType;
         }
         else
         {
             if ((red.GameType == eGameType.ALL && blue.GameType == eGameType.Guild) || (blue.GameType == eGameType.ALL && red.GameType == eGameType.Guild))
             {
                 gameType = eGameType.Guild;
             }
         }
         BaseGame game = GameMgr.StartBattleGame(red.GetPlayers(), red, blue.GetPlayers(), blue, mapId, eRoomType.Match, gameType, 3);
         if (game != null)
         {
             blue.StartGame(game);
             red.StartGame(game);
         }
     }
     catch (Exception e)
     {
         ProxyRoomMgr.log.Error("Start  Match Game Error:", e);
     }
 }
示例#5
0
        public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            BaseGame result;

            try
            {
                int totalLevel = 0;
                foreach (IGamePlayer player in red)
                {
                    totalLevel += player.PlayerCharacter.Grade;
                }
                foreach (IGamePlayer player in blue)
                {
                    totalLevel += player.PlayerCharacter.Grade;
                }
                int averageLevel = totalLevel / (red.Count + blue.Count);
                int mapId        = MapMgr.GetMapIndex(averageLevel, GameMgr.m_serverId);
                if (mapIndex == 0)
                {
                    mapIndex = mapId;
                }
                Map map = MapMgr.AllocateMapInstance(mapIndex);
                if (map != null)
                {
                    PVPGame game = new PVPGame(GameMgr.m_gameId++, roomId, red, blue, map, roomType, gameType, timeType, 0);
                    //game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    List <BaseGame> games;
                    Monitor.Enter(games = GameMgr.m_games);
                    try
                    {
                        GameMgr.m_games.Add(game);
                    }
                    finally
                    {
                        Monitor.Exit(games);
                    }
                    game.Prepare();
                    result = game;
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception e)
            {
                GameMgr.log.Error("Create game error:", e);
                result = null;
            }
            return(result);
        }
示例#6
0
        private static void StartMatchGame(ProxyRoom red, ProxyRoom blue)
        {
            int       mapIndex = MapMgr.GetMapIndex(0, 0, ProxyRoomMgr.m_serverId);
            eGameType gameType = eGameType.Free;

            if (red.GameType == blue.GameType)
            {
                gameType = red.GameType;
            }
            BaseGame baseGame = GameMgr.StartBattleGame(red.GetPlayers(), red, blue.GetPlayers(), blue, mapIndex, eRoomType.Match, gameType, 2);

            if (baseGame != null)
            {
                blue.StartGame(baseGame);
                red.StartGame(baseGame);
            }
            if (baseGame.GameType == eGameType.Guild)
            {
                red.Client.SendConsortiaAlly(red.GetPlayers()[0].PlayerCharacter.ConsortiaID, blue.GetPlayers()[0].PlayerCharacter.ConsortiaID, baseGame.Id);
            }
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
0
        public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType)
        {
            BaseGame result;

            try
            {
                int mapIndex2 = MapMgr.GetMapIndex(mapIndex, (byte)roomType, GameMgr.m_serverId);
                Map map       = MapMgr.CloneMap(mapIndex2);
                List <PetSkillElementInfo> gameNeedPetSkillInfoList = PetMgr.GameNeedPetSkill();
                if (map != null)
                {
                    PVPGame pVPGame = new PVPGame(GameMgr.m_gameId++, roomId, red, blue, map, roomType, gameType, timeType, gameNeedPetSkillInfoList);
                    pVPGame.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    List <BaseGame> games;
                    Monitor.Enter(games = GameMgr.m_games);
                    try
                    {
                        GameMgr.m_games.Add(pVPGame);
                    }
                    finally
                    {
                        Monitor.Exit(games);
                    }
                    pVPGame.Prepare();
                    result = pVPGame;
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception exception)
            {
                GameMgr.log.Error("Create game error:", exception);
                result = null;
            }
            return(result);
        }