Beispiel #1
0
 /// What to do when an extra player has joined the room
 public virtual void OnPeersConnected(string[] participantIds)
 {
     foreach (string participantID in participantIds)
     {
         UILogger.Log("Player " + participantID + " has joined.");
     }
 }
Beispiel #2
0
        /// What to do when a player declines an invitiation to join a room
        public virtual void OnParticipantLeft(Participant participant)
        {
            startedMatching = false;
            UILogger.Log("Player " + participant.DisplayName + " has not connected.");

            // we should also exit the room

            LeaveGame();
        }
Beispiel #3
0
        // STARTING A GAME

        /// Look for a suitable partner to play the game with
        public virtual void StartMatchMaking(string level, IRoomListener room = null)
        {
            uint gameVariation = (uint)Maps.GetIndex(level);

            UILogger.Log("index: " + gameVariation);

            this.roomListener = room;

            startedMatching = true;
            ShowMPStatus("Connecting...");
            PlayGamesPlatform.Instance.RealTime.CreateQuickGame(minimumPartners, maximumPartners, gameVariation, this);
        }
Beispiel #4
0
        // STARTING A GAME

        /// Look for a suitable partner to play the game with
        public override void StartMatchMaking(string level, IRoomListener room = null)
        {
            uint gameVariation = (uint)Maps.GetIndex(level);

            UILogger.Log("index: " + gameVariation);

            this.roomListener = room;

            startedMatching = true;
            ShowMPStatus("Connecting...");

            // start a matchmaking game right here
            OnRoomConnected(true);
        }
Beispiel #5
0
        /// What to do when any players leave the room
        public virtual void OnPeersDisconnected(string[] participantIds)
        {
            foreach (string participantID in participantIds)
            {
                UILogger.Log("Player " + participantID + " has left.");
            }

            // we should also exit the room

            LeaveGame();

            // and we should bring up the disconnection dialog if we are in a game
            InGameGUIController gui = GameObject.FindObjectOfType <InGameGUIController>();

            if (gui != null)
            {
                // we are in a level
                gui.DisconnectionHandler();
                return;
            }

            // if that didn't work, maybe we are in the postgame menu! in which case,
            // we should let the menu controller know about the disconnection
            PostSubmissionMenuController menu = GameObject.FindObjectOfType <PostSubmissionMenuController> ();

            if (menu != null)
            {
                menu.OnDisconnect();
                return;
            }

            // hmm, if we're here, we much not be in a level yet,
            // which is unlikely. But, if that's the case, we have
            // to handle the transition ourselves
            SceneManager.LoadMainMenu();
        }
Beispiel #6
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Report that the test had an error
        /// </summary>
        /// -------------------------------------------------------------------
        public static void LogError(Exception exception)
        {
            // Our test framework calls using Invoke, and throw is returned
            if (exception is TargetInvocationException)
            {
                exception = exception.InnerException;
            }

            // If a test catches the exception, and then rethrows the excpeption later, it uses "RETHROW"
            // to allow this global exception handler to peel this rethrow and analyze the actual exception.
            if (exception.Message == "RETHROW")
            {
                exception = exception.InnerException;
            }

            if (exception.GetType() == typeof(InternalHelper.Tests.IncorrectElementConfigurationForTestException))
            {
                _incorrectConfigurations++;
                _currentLogger.Log(new CommentInfo(exception.Message));
                LogPass();
            }
            else if (exception.GetType() == typeof(InternalHelper.Tests.TestErrorException))
            {
                _currentLogger.Log(new ExceptionInfo(exception));
                _currentLogger.Log(new TestResultInfo(TestResultInfo.TestResults.Failed));
            }
            else
            {
                LogUnexpectedError(exception);
            }
        }
Beispiel #7
0
        // ROOM EVENTS DURING GAMEPLAY

        /// What to do if the player leaves the room.
        public virtual void OnLeftRoom()
        {
            UILogger.Log("I have left the game");
        }
Beispiel #8
0
 /// What to do when a player declines an invitiation to join a room
 public override void OnParticipantLeft(Participant participant)
 {
     startedMatching = false;
     UILogger.Log("Player " + participant.DisplayName + " has left.");
 }
        /// welcome to the start of our multiplayer connection!
        /// today we will be setting up a level with all of
        /// its child objects and their components, so that they
        /// can send and receive updates over the network!
        public static void MultiplayerAwake(GameObject level)
        {
            // decide which player is the host by participant ID

            string             myID         = MultiPlayerController.Instance.GetMyParticipantId();
            List <Participant> participants = MultiPlayerController.Instance.GetAllPlayers();

            // the host is the participant with the first ID in the list

            bool host = (participants [0].ParticipantId.Equals(myID));

            MultiPlayerController.Instance.host = host;

            UILogger.Log("I am the " + (host ? "host" : "client"));


            // Get localPlayer and remotePlayer gameObjects sorted

            LocalPlayerController[] players = level.GetComponentsInChildren <LocalPlayerController>();
            GameObject localPlayer;
            GameObject remotePlayer;

            if (host)
            {
                localPlayer  = players [0].gameObject;
                remotePlayer = players [1].gameObject;
            }
            else
            {
                localPlayer  = players [1].gameObject;
                remotePlayer = players [0].gameObject;
            }

            // Enter update manager, stage left!

            UpdateManager updateManager = MultiPlayerController.Instance.updateManager;


            // Link the update manager to componenets it needs to know about

            LinkUpdateManager(updateManager);


            // Link the camera to follow the local player

            LinkCamera(localPlayer);


            // set up objects and their components!

            InitializePlayers(localPlayer, remotePlayer, updateManager);


            if (host)
            {
                InitializeObstaclesHost(level, updateManager);
            }
            else
            {
                InitializeObstaclesClient(level, updateManager);
            }

            // assign serialisers unique IDs

            SetObjectIDs(level);


            // set up the start lines, finish lines and finalizer

            InitializeFinalization(level, updateManager);



            // Dont forget to let our peer know our gamertag!

            updateManager.SendGamerTag();
        }