Exemplo n.º 1
0
        public void StartGame(Msg_G2C_GameStartInfo gameStartInfo, int localPlayerId)
        {
            if (_hasStart)
            {
                return;
            }
            _hasStart = true;
            var    playerInfos   = gameStartInfo.UserInfos;
            var    playerCount   = playerInfos.Length;
            string _traceLogPath = "";

#if UNITY_STANDALONE_OSX
            _traceLogPath = $"/tmp/LPDemo/Dump_{localPlayerId}.txt";
#else
            _traceLogPath = $"c:/tmp/LPDemo/Dump_{Instance.localPlayerId}.txt";
#endif
            Debug.TraceSavePath = _traceLogPath;

            Debug.Trace("CreatePlayer " + playerCount);
            //create Players
            for (int i = 0; i < playerCount; i++)
            {
                var PrefabId = 0;             //TODO
                var initPos  = LVector2.zero; //TODO
                var player   = _gameStateService.CreateEntity <Player>(PrefabId, initPos);
                player.localId = i;
            }

            var allPlayers = _gameStateService.GetPlayers();

            MyPlayer = allPlayers[localPlayerId];
        }
Exemplo n.º 2
0
        public void _DoStart()
        {
            //Debug.Trace("Before StartGame _IdCounter" + BaseEntity.IdCounter);
            //if (!IsReplay && !IsClientMode) {
            //    netClient = new NetClient();
            //    netClient.Start();
            //    netClient.Send(new Msg_JoinRoom() {name = Application.dataPath});
            //}
            //else {
            //    StartGame(0, playerServerInfos, localPlayerId);
            //}


            if (IsVideoMode)
            {
                EventHelper.Trigger(EEvent.BorderVideoFrame, FramesInfo);
                EventHelper.Trigger(EEvent.OnGameCreate, GameStartInfo);
            }
            else if (IsClientMode)
            {
                GameStartInfo = _serviceContainer.GetService <IGameConfigService>().ClientModeInfo;
                EventHelper.Trigger(EEvent.OnGameCreate, GameStartInfo);
                EventHelper.Trigger(EEvent.LevelLoadDone, GameStartInfo);
            }
        }
Exemplo n.º 3
0
 public void OnGameCreateGameStartInfo(Msg_G2C_GameStartInfo msg)
 {
     this._gameStartInfo = msg;
     this._globalStateService.GameStartInfo = this._gameStartInfo;
     Debug.Log("Msg_G2C_GameStartInfo ", Array.Empty <object>());
     this.SimulationAwake(60, this.LocalActorId, msg.UserCount, true);
 }
Exemplo n.º 4
0
        protected void G2C_GameStartInfo(IIncommingMessage reader)
        {
            var msg = reader.Parse <Msg_G2C_GameStartInfo>();

            Log("G2C_GameStartInfo " + msg);
            HasRecvGameDta = true;
            GameStartInfo  = msg;
            _handler.OnGameStartInfo(msg);
        }
Exemplo n.º 5
0
        public void OpenRecordFile(string path)
        {
            var bytes  = File.ReadAllBytes(path);
            var reader = new Deserializer(Compressor.Decompress(bytes));

            GameStartInfo = reader.Parse <Msg_G2C_GameStartInfo>();
            FramesInfo    = reader.Parse <Msg_RepMissFrame>();
            MaxRunTick    = FramesInfo.frames.Length + 1;
            IsVideoMode   = true;
        }
Exemplo n.º 6
0
        protected void G2C_GameStartInfo(object reader)
        {
            Msg_G2C_GameStartInfo msg_G2C_GameStartInfo = reader as Msg_G2C_GameStartInfo;

            HasRecvGameDta = true;
            GameStartInfo  = msg_G2C_GameStartInfo;
            _handler.OnGameStartInfo(msg_G2C_GameStartInfo);
            HasConnGameTcp   = true;
            HasConnGameUdp   = true;
            CurGameState     = EGameState.Loading;
            _curLoadProgress = 1f;
            EventHelper.Trigger(EEvent.OnGameCreate, msg_G2C_GameStartInfo);
            Debug.Log("G2C_GameStartInfo", Array.Empty <object>());
        }
Exemplo n.º 7
0
 public void _DoStart()
 {
     if (IsVideoMode)
     {
         EventHelper.Trigger(EEvent.BorderVideoFrame, FramesInfo);
         EventHelper.Trigger(EEvent.OnGameCreate, GameStartInfo);
     }
     else if (IsClientMode)
     {
         GameStartInfo = _serviceContainer.GetService <IGameConfigService>().ClientModeInfo;
         EventHelper.Trigger(EEvent.OnGameCreate, GameStartInfo);
         EventHelper.Trigger(EEvent.LevelLoadDone, GameStartInfo);
     }
 }
Exemplo n.º 8
0
        public void SimulationStart(Msg_G2C_GameStartInfo gameStartInfo, int localPlayerId)
        {
            bool hasStart = this._hasStart;

            if (!hasStart)
            {
                this._hasStart = true;
                GameData[] userInfos     = gameStartInfo.UserInfos;
                int        num           = userInfos.Length;
                string     traceSavePath = string.Format("/tmp/LPDemo/Dump_{0}.txt", localPlayerId);
                Debug.TraceSavePath = traceSavePath;
                this._debugService.Trace("CreatePlayer " + num, false, false);
                this.DoSimulateStart();
            }
        }
Exemplo n.º 9
0
        protected void G2C_GameStartInfo(object reader)
        {
            var msg = reader as Msg_G2C_GameStartInfo;

            HasRecvGameDta = true;
            GameStartInfo  = msg;
            _handler.OnGameStartInfo(msg);
            //TODO temp code
            HasConnGameTcp   = true;
            HasConnGameUdp   = true;
            CurGameState     = EGameState.Loading;
            _curLoadProgress = 1;
            EventHelper.Trigger(EEvent.OnGameCreate, msg);
            Debug.Log("G2C_GameStartInfo");
        }
        void OnEvent_OnGameCreate(object param)
        {
            if (param is Msg_G2C_Hello msg)
            {
                OnGameCreate(60, msg.LocalId, msg.UserCount);
            }

            if (param is Msg_G2C_GameStartInfo smsg)
            {
                _gameStartInfo = smsg;
                OnGameCreate(60, 0, smsg.UserCount);
            }

            EventHelper.Trigger(EEvent.SimulationInit, null);
        }
Exemplo n.º 11
0
 public virtual void OnGameStartInfo(Msg_G2C_GameStartInfo data)
 {
 }
Exemplo n.º 12
0
 public void SetStartInfo(Msg_G2C_GameStartInfo info)
 {
     GameStartInfo = info;
     BorderTcp(EMsgSC.G2C_GameStartInfo, GameStartInfo);
 }
Exemplo n.º 13
0
 public override void OnGameStartInfo(Msg_G2C_GameStartInfo data)
 {
 }
Exemplo n.º 14
0
 public void OnGameStartInfo(Msg_G2C_GameStartInfo data)
 {
     Log("Msg_G2C_GameStartInfo ");
     EventHelper.Trigger(EEvent.OnGameStartInfo, data);
 }
Exemplo n.º 15
0
 public void SetStartInfo(Msg_G2C_GameStartInfo info)
 {
     Debug.Log("SetStartInfo");
     GameStartInfo = info;
     BorderTcp(EMsgSC.G2C_GameStartInfo, GameStartInfo);
 }