private void OnGameItemSpawned(object b) { DebugMP.Log("Game item spawned. Sending update to opponent..."); List <byte> bytes = (List <byte>)b; SendMessage(GPMPEvents.Types.GPMP_GAME_ITEM_RECIEVED, bytes); }
public void OnMatchMakingCanceled(object obj) { DebugMP.Log("OnMatchMakingCanceled"); playerLeftOnPurpose = true; PlayGamesPlatform.Instance.RealTime.LeaveRoom(); LoadingController.LoadScene(LoadingController.Scenes.GPMP_LOBBY); }
void OnPlayerLeavesTheGame(object arg0) { DebugMP.Log("OnPlayerLeavesTheGame"); playerLeftOnPurpose = true; PlayGamesPlatform.Instance.RealTime.LeaveRoom(); LoadingController.LoadScene(LoadingController.Scenes.GPMP_LOBBY); }
IEnumerator TriggerGameOverScreen() { yield return(new WaitForSeconds(2)); DebugMP.Log("Game over"); LoadingController.LoadScene(LoadingController.Scenes.GPMP_GAME_OVER); }
public void OnPeersDisconnected(string[] participantIds) { DebugMP.Log("OnPeersDisconnected"); playerLeftOnPurpose = false; errorMessage = "Your opponent left the game"; PlayGamesPlatform.Instance.RealTime.LeaveRoom(); LoadingController.LoadScene(LoadingController.Scenes.GPMP_LOBBY); }
void Start() { DebugMP.Log("Player left on purpose: " + GPMPController.playerLeftOnPurpose); if (!GPMPController.playerLeftOnPurpose) { Invoke("TriggerErrorMessageWithDelay", 0.1f); } }
private void OnOpponentSkinRecieved(object data) { byte[] bytes = (byte[])data; int skinID = BitConverter.ToInt32(bytes, 5); animator.SetTrigger(skinID.ToString()); DebugMP.Log("Opponent skin recieved: " + skinID); }
private void OnPlayerDied(object arg0) { DebugMP.Log("Opponent won."); SaveLoadController.GetInstance().GetMultiplayerSession().SetOpponentWon(); StartCoroutine("TriggerGameOverScreen"); // send message to opponent saying you died SendMessage(GPMPEvents.Types.GPMP_OPPONENT_DIED, new List <byte>()); }
// GPMP private void OnGameStartReady(object matchModel) { GPMPMatchModel model = (GPMPMatchModel)matchModel; DebugMP.Log("Game start revieved by batch view. I am host: " + model.iAmTheHost); if (model.iAmTheHost) { EventManager.TriggerEvent(SpawnSystemEvents.TOGGLE_SPAWNING, true); } }
private void OnOpponentReady(object arg0) { DebugMP.Log("Opponent ready..."); // If we are also ready dispatch start game if (matchModel.playerIsReady && !matchStarted) { StopCoroutine("PollOpponentForReady"); EventManager.TriggerEvent(GPMPEvents.Types.GPMP_START_GAME.ToString(), matchModel); } }
private void OnOpponentDied(object arg0) { DebugMP.Log("You won!"); SaveLoadController slc = SaveLoadController.GetInstance(); slc.GetMultiplayerSession().SetPlayerWon(); slc.GetPlayer().AddTotalMultiplayerMatchesWon(1); AchievementChecker.CheckForMultiplayerAchievement(slc.GetPlayer().GetTotalMultiplayerMatchesWon()); GooglePlayHelper.GetInstance().PostHighscore(slc.GetPlayer().GetTotalMultiplayerMatchesWon(), GPGSConstant.leaderboard_multiplayer_mode); StartCoroutine("TriggerGameOverScreen"); GooglePlayHelper.GetInstance().SaveGame(); }
private void OnGameStarted(object arg0) { // start polling opponent to check if he is still in the game InvokeRepeating("PollOpponentForActive", 0, 1f); matchStarted = true; // Send event GooglePlayHelper.GetInstance().ReportEvent(GPGSConstant.event_multiplayer_match_started, 1); // Send player skin ID to opponent List <byte> m = new List <byte>(); m.AddRange(BitConverter.GetBytes(SaveLoadController.GetInstance().GetPlayer().GetActiveSkinID())); SendMessage(GPMPEvents.Types.GPMP_OPPONENT_SKIN_RECIEVED, m); DebugMP.Log("Sending skin ID to opponent: " + SaveLoadController.GetInstance().GetPlayer().GetActiveSkinID()); }
private void OnPlayerReady(object arg0) { DebugMP.Log("Player ready..."); // Let the other player know you are ready SendMessage(GPMPEvents.Types.GPMP_OPPONENT_READY, new List <byte>()); matchModel.playerIsReady = true; // If our opponent is also ready dispatch start game, else start polling opponent. if (matchModel.opponentIsReady) { EventManager.TriggerEvent(GPMPEvents.Types.GPMP_START_GAME.ToString(), matchModel); } else { StartCoroutine("PollOpponentForReady"); } }
public void OnRoomConnected(bool success) { DebugMP.Log("OnRoomConnected " + success); if (success) { EventManager.TriggerEvent(GPMPEvents.Types.GPMP_MATCH_MAKING_DONE.ToString()); // Reset save model SaveLoadController.GetInstance().GetMultiplayerSession().Reset(); // Start versusn screen LoadingController.LoadScene(LoadingController.Scenes.GPMP_VERSUS_SCREEN); } else { PlayGamesPlatform.Instance.RealTime.LeaveRoom(); LoadingController.LoadScene(LoadingController.Scenes.GPMP_LOBBY); } }
private void SetParticipantsInfo() { // set match model for the current session matchModel.player = PlayGamesPlatform.Instance.RealTime.GetSelf(); matchModel.iAmTheHost = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants()[0].ParticipantId == matchModel.player.ParticipantId; List <Participant> players = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants(); foreach (Participant p in players) { if (p.ParticipantId != matchModel.player.ParticipantId) { matchModel.opponent = p; } } EventManager.TriggerEvent(GPMPEvents.Types.GPMP_MATCH_INFO_READY.ToString(), matchModel); EventManager.TriggerEvent(GPMPEvents.Types.GPMP_PLAYER_READY.ToString()); // store session info in the save load controller SaveLoadController.GetInstance().GetMultiplayerSession().SetPlayers(matchModel.player, matchModel.opponent); DebugMP.Log("Match info ready"); }
IEnumerator PollOpponentForReady() { DebugMP.Log("Polling opponent for ready status..."); SendMessage(GPMPEvents.Types.GPMP_READY_ACKNOWLEDGE, new List <byte>()); yield return(new WaitForSeconds(pollOpponentForReadyInterval)); }
void PollOpponentForActive() { DebugMP.Log("Polling opponent for response timeout"); SendMessage(GPMPEvents.Types.GPMP_READY_ACKNOWLEDGE, new List <byte>()); }
public void OnPeersConnected(string[] participantIds) { DebugMP.Log("OnPeersConnected"); EventManager.TriggerEvent(GPMPEvents.Types.GPMP_OPPONENT_FOUND.ToString()); }
/* * RealTimeMultiplayerListener functions */ public void OnRoomSetupProgress(float percentage) { DebugMP.Log("OnRoomSetupProgress"); EventManager.TriggerEvent(GPMPEvents.Types.GPMP_REPORT_ROOM_SETUP_PROGRESS.ToString(), percentage); }
public void OnLeftRoom() { DebugMP.Log("OnLeftRoom"); }