Esempio n. 1
0
        public static BaseGame StartPVEGame(List <IGamePlayer> player, int mapIndex, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType)
        {
            try
            {
                int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId);
                index = 1072;
                Map map = MapMgr.CloneMap(index);

                if (map != null)
                {
                    PVEGame game = new PVEGame(m_gameId++, player, 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);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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
            {
                PveInfo info;
                if (copyId == 0 || copyId == 10000)
                {
                    info = PveInfoMgr.GetPveInfoByType(roomType, levelLimits);
                }
                else
                {
                    info = PveInfoMgr.GetPveInfoById(copyId);
                }
                if (info != null)
                {
                    PVEGame         game = new PVEGame(GameMgr.m_gameId++, roomId, info, players, null, roomType, gameType, timeType, hardLevel);
                    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);
        }
Esempio n. 4
0
        public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits)
        {
            try
            {
                PveInfo info = null;

                if (copyId == 0 || copyId == 100000)
                {
                    info = PveInfoMgr.GetPveInfoByType(roomType, levelLimits);
                }
                else
                {
                    info = PveInfoMgr.GetPveInfoById(copyId);
                }
                if (info != null)
                {
                    PVEGame game = new PVEGame(m_gameId++, roomId, info, players, null, roomType, gameType, timeType, hardLevel);
                    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);
            }
        }
        public void Execute(BaseGame game, long tick)
        {
            if (this.m_time <= tick && game.GetWaitTimer() < tick)
            {
                PVEGame pVEGame = game as PVEGame;
                if (pVEGame != null)
                {
                    switch (pVEGame.GameState)
                    {
                    case eGameState.Inited:
                        pVEGame.Prepare();
                        break;

                    case eGameState.Prepared:
                        pVEGame.PrepareNewSession();
                        break;

                    case eGameState.Loading:
                        if (!pVEGame.IsAllComplete())
                        {
                            game.WaitTime(1000);
                        }
                        else
                        {
                            pVEGame.StartGame();
                        }
                        break;

                    case eGameState.GameStartMovie:
                        if (game.CurrentActionCount > 1)
                        {
                            pVEGame.StartGameMovie();
                        }
                        else
                        {
                            pVEGame.StartGame();
                        }
                        break;

                    case eGameState.GameStart:
                        pVEGame.PrepareNewGame();
                        break;

                    case eGameState.Playing:
                        if ((pVEGame.CurrentLiving == null || !pVEGame.CurrentLiving.IsAttacking) && game.CurrentActionCount <= 1)
                        {
                            if (pVEGame.CanGameOver())
                            {
                                pVEGame.GameOver();
                            }
                            else
                            {
                                pVEGame.NextTurn();
                            }
                        }
                        break;

                    case eGameState.GameOver:
                        if (!pVEGame.HasNextSession())
                        {
                            pVEGame.GameOverAllSession();
                        }
                        else
                        {
                            pVEGame.PrepareNewSession();
                        }
                        break;

                    case eGameState.SessionPrepared:
                        if (!pVEGame.CanStartNewSession())
                        {
                            game.WaitTime(1000);
                        }
                        else
                        {
                            pVEGame.StartLoading();
                        }
                        break;

                    case eGameState.ALLSessionStopped:
                        if (pVEGame.PlayerCount == 0 || pVEGame.WantTryAgain == 0)
                        {
                            pVEGame.Stop();
                        }
                        else
                        {
                            if (pVEGame.WantTryAgain == 1)
                            {
                                pVEGame.SessionId--;
                                pVEGame.PrepareNewSession();
                            }
                            else
                            {
                                game.WaitTime(1000);
                            }
                        }
                        break;
                    }
                }
                this.m_isFinished = true;
            }
        }
Esempio n. 6
0
        public void Execute(BaseGame game, long tick)
        {
            if (m_time <= tick && game.GetWaitTimer() < tick)
            {
                PVEGame pve = game as PVEGame;
                if (pve != null)
                {
                    switch (pve.GameState)
                    {
                    case eGameState.Inited:
                        pve.Prepare();
                        break;

                    case eGameState.Prepared:
                        pve.PrepareNewSession();
                        break;

                    case eGameState.SessionPrepared:
                        if (pve.CanStartNewSession())
                        {
                            pve.StartLoading();
                            break;
                        }
                        else
                        {
                            game.WaitTime(1000);
                        }
                        break;

                    case eGameState.Loading:
                        if (pve.IsAllComplete())
                        {
                            pve.StartGame();
                            break;
                        }
                        else
                        {
                            game.WaitTime(1000);
                        }
                        break;

                    //TODO
                    case eGameState.GameStartMovie:
                        if (game.CurrentActionCount <= 1)
                        {
                            pve.StartGame();
                            break;
                        }
                        else
                        {
                            pve.StartGameMovie();
                        }
                        break;

                    case eGameState.GameStart:
                        pve.PrepareNewGame();
                        break;

                    case eGameState.Playing:

                        if ((pve.CurrentLiving == null || pve.CurrentLiving.IsAttacking == false) && game.CurrentActionCount <= 1)
                        {
                            if (pve.CanGameOver())
                            {
                                //log.Error(string.Format("stage : {0}", -1));
                                pve.GameOver();
                                break;
                            }
                            else
                            {
                                //log.Error(string.Format("stage : {0}", 0));
                                pve.NextTurn();
                            }
                        }
                        break;

                    case eGameState.GameOver:
                        if (pve.HasNextSession())
                        {
                            //log.Error(string.Format("stage : {0}", 1));
                            pve.PrepareNewSession();
                            break;
                        }
                        else
                        {
                            //log.Error(string.Format("stage : {0}", 2));
                            pve.GameOverAllSession();
                        }
                        break;

                    case eGameState.ALLSessionStopped:

                        if ((pve.PlayerCount != 0) && (pve.WantTryAgain != 0))
                        {
                            if (pve.WantTryAgain == 1)
                            {
                                pve.SessionId--;
                                pve.PrepareNewSession();
                                //log.Error(string.Format("stage : {0}", 3));
                            }
                            else
                            {
                                game.WaitTime(1000);
                                //log.Error(string.Format("stage : {0}", 4));
                            }
                            break;
                        }
                        pve.Stop();
                        break;
                    }
                }
                m_isFinished = true;
            }
        }