Example #1
0
        public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits)
        {
            BaseGame result;

            try
            {
                List <PetSkillElementInfo> gameNeedPetSkillInfoList = PetMgr.GameNeedPetSkill();
                PveInfo pveInfo;
                if (copyId == 0 || copyId == 100000)
                {
                    pveInfo = PveInfoMgr.GetPveInfoByType(roomType, levelLimits);
                }
                else
                {
                    pveInfo = PveInfoMgr.GetPveInfoById(copyId);
                }
                if (pveInfo != null)
                {
                    PVEGame pVEGame = new PVEGame(GameMgr.m_gameId++, roomId, pveInfo, players, null, roomType, gameType, timeType, hardLevel, gameNeedPetSkillInfoList);
                    pVEGame.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd);
                    List <BaseGame> games;
                    Monitor.Enter(games = GameMgr.m_games);
                    try
                    {
                        GameMgr.m_games.Add(pVEGame);
                    }
                    finally
                    {
                        Monitor.Exit(games);
                    }
                    pVEGame.Prepare();
                    result = pVEGame;
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception exception)
            {
                GameMgr.log.Error("Create game error:", exception);
                result = null;
            }
            return(result);
        }
Example #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 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);
        }
Example #3
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);
        }