예제 #1
0
        public void Execute(BaseGame game, long tick)
        {
            if (this.m_tick <= tick)
            {
                PVPGame pvp = game as PVPGame;
                if (pvp != null)
                {
                    switch (game.GameState)
                    {
                    case eGameState.Inited:
                        pvp.Prepare();
                        break;

                    case eGameState.Prepared:
                        pvp.StartLoading();
                        break;

                    case eGameState.Loading:
                        if (pvp.IsAllComplete())
                        {
                            pvp.StartGame();
                        }
                        break;

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

                    case eGameState.GameOver:
                        if (pvp.CurrentActionCount == 1)
                        {
                            pvp.Stop();
                        }
                        break;
                    }
                }
                this.m_isFinished = true;
            }
        }
예제 #2
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);
        }