Ejemplo n.º 1
0
        public PVEGame(int id, int roomId, PveInfo info, List<IGamePlayer> players, Map map, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel)
            : base(id, roomId, map, roomType, gameType, timeType)
        {
            foreach (IGamePlayer player in players)
            {
                Player fp = new Player(player, PhysicalId++, this, 1);
                //fp.Reset();
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                AddPlayer(player, fp);
            }

            m_info = info;
            BeginPlayersCount = players.Count;
            TotalKillCount = 0;
            TotalNpcGrade = 0;
            TotalNpcExperience = 0;
            TotalHurt = 0;

            m_IsBossType = "";

            WantTryAgain = 0;
            SessionId = 0;
            m_gameOverResources = new List<string>();
            Misssions = new Dictionary<int, MissionInfo>();
            m_mapHistoryIds = new List<int>();
            m_hardLevel = hardLevel;

            string script = GetScript(info, hardLevel);

            m_gameAI = ScriptMgr.CreateInstance(script) as APVEGameControl;
            if (m_gameAI == null)
            {
                log.ErrorFormat("Can't create game ai :{0}", script);
                m_gameAI = SimplePVEGameControl.Simple;
            }
            m_gameAI.Game = this;
            m_gameAI.OnCreated();

            m_missionAI = SimpleMissionControl.Simple;
            beginTime = DateTime.Now;
            m_bossCardCount = 0;
        }
Ejemplo n.º 2
0
        public void PrepareNewSession()
        {
            if (GameState == eGameState.Prepared || GameState == eGameState.GameOver || GameState == eGameState.ALLSessionStopped)
            {
                m_gameState = eGameState.SessionPrepared;
                SessionId++;
                ClearLoadingFiles();
                ClearMissionData();
                m_gameOverResources.Clear();
                WantTryAgain = 0;

                m_missionInfo = Misssions[SessionId];
                m_pveGameDelay = m_missionInfo.Delay;
                TotalCount = m_missionInfo.TotalCount;
                TotalTurn = m_missionInfo.TotalTurn;
                Param1 = m_missionInfo.Param1;
                Param2 = m_missionInfo.Param2;
                Param3 = -1;
                Param4 = -1;

                m_missionAI = ScriptMgr.CreateInstance(m_missionInfo.Script) as AMissionControl;

                if (m_missionAI == null)
                {
                    log.ErrorFormat("Can't create game mission ai :{0}", m_missionInfo.Script);
                    m_missionAI = SimpleMissionControl.Simple;
                }
                IsBossWar = "";
                m_missionAI.Game = this;

                try
                {
                    m_missionAI.OnPrepareNewSession();
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("game ai script {0} error:{1}", GameState, ex);
                }
            }
        }