コード例 #1
0
ファイル: ModePlay.cs プロジェクト: jimkberry/BeamBackend
        public void OnPeerJoinedGameEvt(object sender, PeerJoinedGameArgs ga)
        {
            BeamNetworkPeer p       = ga.peer;
            bool            isLocal = p.PeerId == appl.LocalPeer.PeerId;

            logger.Info($"{(ModeName())} - OnPeerJoinedGameEvt() - {(isLocal?"Local":"Remote")} Peer Joined: {p.Name}, ID: {p.PeerId}");
            if (isLocal)
            {
                if (_curState == kJoiningGame)
                {
                    // Create gameinstance and ApianInstance
                    game = new BeamAppCore(appl.frontend);
                    game.PlayerJoinedEvt += OnPlayerJoinedEvt;
                    game.NewBikeEvt      += OnNewBikeEvt;
                    BeamApian apian = new BeamApianCreatorServer(appl.gameNet, game); // TODO: make the groupMgr type run-time spec'ed
                    //BeamApian apian = new BeamApianSinglePeer(core.gameNet, game); // *** This should be commented out (or gone)
                    appl.AddAppCore(game);
                    _SetState(kCheckingForGroups, null);
                }
                else
                {
                    logger.Error($"{(ModeName())} - OnGameJoinedEvt() - Wrong state: {_curState}");
                }
            }
        }
コード例 #2
0
        public void OnPeerJoinedGameEvt(object sender, PeerJoinedGameArgs ga)
        {
            bool isLocal = ga.peer.PeerId == appl.LocalPeer.PeerId;

            if (isLocal && game == null)
            {
                logger.Info("practice game joined");
                // Create gameInstance and associated Apian
                game = new BeamAppCore(appl.frontend);
                game.PlayerJoinedEvt += OnMemberJoinedGroupEvt;
                game.NewBikeEvt      += OnNewBikeEvt;

                BeamApian apian = new BeamApianSinglePeer(appl.gameNet, game);
                appl.AddAppCore(game);
                // Dont need to check for groups in splash
                apian.CreateNewGroup(ApianGroupId, ApianGroupName);
                BeamPlayer mb = new BeamPlayer(appl.LocalPeer.PeerId, appl.LocalPeer.Name);
                apian.JoinGroup(ApianGroupId, mb.ApianSerialized());

                game.frontend?.OnStartMode(BeamModeFactory.kPractice, null);
                // waiting for OnGroupJoined()
            }
        }
コード例 #3
0
        public void OnPeerJoinedGameEvt(object sender, PeerJoinedGameArgs ga)
        {
            bool isLocal = ga.peer.PeerId == appl.LocalPeer.PeerId;

            if (isLocal && _CurrentState == ModeState.JoiningGame)
            {
                logger.Info("Splash game joined");
                // Create gameInstance and associated Apian
                game = new BeamAppCore(appl.frontend);
                game.PlayerJoinedEvt += OnPlayerJoinedEvt;
                game.NewBikeEvt      += OnNewBikeEvt;
                BeamApian apian = new BeamApianSinglePeer(appl.gameNet, game); // This is the REAL one
                // BeamApian apian = new BeamApianCreatorServer(core.gameNet, game); // Just for quick tests of CreatorServer
                appl.AddAppCore(game);
                // Dont need to check for groups in splash
                apian.CreateNewGroup(ApianGroupId, ApianGroupName);
                BeamPlayer mb = new BeamPlayer(appl.LocalPeer.PeerId, appl.LocalPeer.Name);
                game.GroupJoinedEvt += OnGroupJoinedEvt;
                apian.JoinGroup(ApianGroupId, mb.ApianSerialized());
                _CurrentState = ModeState.JoiningGroup;
                // waiting for OnPlayerJoined(localplayer)
            }
        }