public void AcceptInvitation(string invitationId) { _instance = new MultiplayerController(); if (PlayGamesPlatform.Instance.localUser.authenticated) { PlayGamesPlatform.Instance.RealTime.AcceptInvitation (invitationId, _instance); } }
// Update is called once per frame void Update() { if (controller == null) { controller = FindObjectOfType <MultiplayerController>(); } }
public void GameFromInbox() { _instance = new MultiplayerController(); if (PlayGamesPlatform.Instance.localUser.authenticated) { PlayGamesPlatform.Instance.RealTime.AcceptFromInbox (_instance); } }
public static void CreateWithInvitationScreen() { gameVariation = (uint)GameData.Instance.appModeType; _instance = new MultiplayerController(); PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen(minimumOpponents, maximumOpponents, gameVariation, _instance); }
private void StartMatchMaking(Invitation invitation) { _instance = new MultiplayerController(); Debug.Log("StartMatchMaking invitation " + invitation); // PlayGamesPlatform.Instance.RealTime.CreateQuickGame (minimumOpponents, maximumOpponents, gameVariation, this); PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitation.InvitationId, _instance); }
public static void CreateQuickGame() { gameVariation = (uint)GameData.Instance.appModeType; _instance = new MultiplayerController(); PlayGamesPlatform.Instance.RealTime.CreateQuickGame(QuickGameOpponents, QuickGameOpponents, gameVariation, _instance); }
void Start() { mc = this.GetComponent <MultiplayerController>(); connectingToRoom = false; var config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build(); PlayGamesPlatform.InitializeInstance(config); if (PlayGamesPlatform.Instance.localUser.authenticated) { UpdateLeaderboards(); UpdateAchievements(); loginInfo.text = "Signed In: " + PlayGamesPlatform.Instance.localUser.userName; signInButton.SetActive(false); signOutButton.SetActive(true); leaderboardButton.interactable = true; archievementButton.interactable = true; multiplayerButton.interactable = true; } else { loginInfo.text = "Not Signed In"; signInButton.SetActive(true); signOutButton.SetActive(false); leaderboardButton.interactable = false; archievementButton.interactable = false; multiplayerButton.interactable = false; //Do not try to sign in when entering the menu. Player must click the sign in button to login. //SignIn(); } }
private void StartMatchMaking() { _instance = new MultiplayerController(); gameVariation = (uint)GameData.Instance.appModeType; // PlayGamesPlatform.Instance.RealTime.CreateQuickGame (minimumOpponents, maximumOpponents, gameVariation, this); PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen(minimumOpponents, maximumOpponents, gameVariation, _instance); }
private UIController uiController = null; //!< The local reference to the UIController #endregion #region Unity methods /// @name Unity methods /** * Called when the script is loaded, before the game starts */ void Awake () { S = this; // Get the controllers gameController = GameController.S; playerController = PlayerController.S; tvUIController = TVUIController.S; }
/// <summary> /// Must be called before usage. /// </summary> public void Initialize(ControllerManager controllerManager, int blockWidth, int blockHeight) { base.Initialize(controllerManager); this.blockWidth = blockWidth; this.blockHeight = blockHeight; multiplayerController = MultiplayerController.GetInstance(); multiplayerController.OnMessageReceived += ProcessNetworkData; }
void Start() { // Authenticate localUser for multi network ready = 0; connect = false; multiplayerController = new MultiplayerController(); MultiplayerController.Instance.MultiplayerConfigAndInit(); }
/** * Runs at load time */ void Start () { gameController = GameController.S; lobbyController = LobbyController.S; multiplayerController = MultiplayerController.S; networkController = NetworkController.S; uiController = UIController.S; // Setup the UI's buttons construct (); }
public Multiplayer(MainWindow mainWindow) { this.mainWindow = mainWindow; InitializeComponent(); MessageBox.Show("Plug in secondary keyboard!"); MessageBox.Show("Get Ready!"); MultiplayerController = new MultiplayerController(this); keyHandle = new WindowInteropHelper(this.mainWindow).Handle; //KeyEvent handler rawInput = new RawInput(keyHandle, true); //RawInput reader rawInput.KeyPressed += OnKeyPressed; //Void OnKeyPress when KeyPress Focus(); }
void Awake() { if (instance != null && instance != this) { Destroy(this); } else { Players = new List <PlayerOnline>(); instance = this; DontDestroyOnLoad(gameObject); } }
internal void Construct(IConnectedPlayer connectedPlayer, MultiplayerController multiplayerController, IScoreSyncStateManager scoreProvider, MultiplayerLeadPlayerProvider leadPlayerProvider, MultiplayerGameplayAnimator gameplayAnimator, ExtendedPlayerManager extendedPlayerManager) { _connectedPlayer = connectedPlayer; _multiplayerController = multiplayerController; _scoreProvider = scoreProvider; _leadPlayerProvider = leadPlayerProvider; _gameplayAnimator = gameplayAnimator; _extendedPlayerManager = extendedPlayerManager; _allLights = gameplayAnimator.GetField <LightsAnimator[], MultiplayerGameplayAnimator>("_allLightsAnimators"); _gameplayLights = gameplayAnimator.GetField <LightsAnimator[], MultiplayerGameplayAnimator>("_gameplayLightsAnimators"); _activeLightsColor = gameplayAnimator.GetField <ColorSO, MultiplayerGameplayAnimator>("_activeLightsColor"); _leadingLightsColor = gameplayAnimator.GetField <ColorSO, MultiplayerGameplayAnimator>("_leadingLightsColor"); _failedLightsColor = gameplayAnimator.GetField <ColorSO, MultiplayerGameplayAnimator>("_failedLightsColor"); _leadPlayerProvider.newLeaderWasSelectedEvent += this.HandleNewLeaderWasSelected; }
public override void RespawnBall() { if (!PhotonNetwork.IsMasterClient) { return; } if (_currentCountLooseBools == CountLooseBoolsMax) { MultiplayerController.Disconnect(); return; } _ball.Transform.position = Vector3.zero; _ball.RandomBallSettings(); _currentCountLooseBools++; base.RespawnBall(); }
private void GameSceneLoadedCallback(ScenesTransitionSetupDataSO transitionSetupData, DiContainer diContainer) { // Prevent firing this event when returning to menu var gameScenesManager = Resources.FindObjectsOfTypeAll <GameScenesManager>().FirstOrDefault(); gameScenesManager.transitionDidFinishEvent -= GameSceneLoadedCallback; if (Plugin.LevelData.Mode == Gameplay.Mode.Multiplayer) { MultiplayerController sync = Resources.FindObjectsOfTypeAll <MultiplayerController>().LastOrDefault(x => x.isActiveAndEnabled); if (sync != null) { sync.stateChangedEvent += (state) => { MultiControllerStateChanged(state, transitionSetupData, diContainer, sync); }; } } else { GameSceneSceneWasLoaded(transitionSetupData, diContainer); } }
private void CleanUpMultiplayer() { if (multiplayerSessionManager != null) { multiplayerSessionManager.disconnectedEvent -= OnMultiplayerDisconnected; multiplayerSessionManager = null; } if (multiplayerController != null) { multiplayerController.stateChangedEvent -= OnMultiplayerStateChanged; multiplayerController = null; } if (multiplayerLocalActivePlayerFacade != null) { multiplayerLocalActivePlayerFacade.playerDidFinishEvent -= OnMultiplayerLevelFinished; multiplayerLocalActivePlayerFacade = null; } }
private async void Timer_Elapsed(object sender, ElapsedEventArgs e) { await MultiplayerController.RunTasks(); }
public override void OnConnectedToMaster() { MultiplayerController.JoinOrCreateRoom(); }
public override void OnMasterClientSwitched(Player newMasterClient) { MultiplayerController.Disconnect(); }
public override void OnPlayerLeftRoom(Player otherPlayer) { MultiplayerController.Disconnect(); }
private void EndGameClient() { MultiplayerController.Disconnect(); }
public override void Open() { MultiplayerController.Connect(); }
public static void AcceptInvitation(string invitationId) { _instance = new MultiplayerController(); PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitationId, _instance); }
public async void HandleSongStart() { GameStatus gameStatus = statusManager.gameStatus; // Check for multiplayer early to abort if needed: gameplay controllers don't exist in multiplayer until later multiplayerSessionManager = FindFirstOrDefaultOptional <MultiplayerSessionManager>(); multiplayerController = FindFirstOrDefaultOptional <MultiplayerController>(); if (multiplayerSessionManager && multiplayerController) { Plugin.log.Debug("Multiplayer Level loaded"); // public event Action<DisconnectedReason> MultiplayerSessionManager#disconnectedEvent; multiplayerSessionManager.disconnectedEvent += OnMultiplayerDisconnected; // public event Action<State> MultiplayerController#stateChangedEvent; multiplayerController.stateChangedEvent += OnMultiplayerStateChanged; // Do nothing until the next state change to Gameplay. if (multiplayerController.state != MultiplayerController.State.Gameplay) { return; } multiplayerLocalActivePlayerFacade = FindFirstOrDefaultOptional <MultiplayerLocalActivePlayerFacade>(); if (multiplayerLocalActivePlayerFacade != null) { multiplayerLocalActivePlayerFacade.playerDidFinishEvent += OnMultiplayerLevelFinished; } } else if (!doDelayedSongStart) { doDelayedSongStart = true; return; } // `wants_to_play_next_level` is set for players who don't want to play the song aka want to spectate aka are not "active". `isSpectating` is apparently not spectating. gameStatus.scene = multiplayerSessionManager.isSpectating || !multiplayerSessionManager.LocalPlayerHasState(NetworkConstants.wantsToPlayNextLevel) ? "Spectator" : "Song"; gameStatus.multiplayer = multiplayerSessionManager.isConnectingOrConnected; pauseController = FindFirstOrDefaultOptional <PauseController>(); scoreController = FindFirstOrDefault <ScoreController>(); gameplayManager = FindFirstOrDefaultOptional <StandardLevelGameplayManager>() as MonoBehaviour ?? FindFirstOrDefaultOptional <MissionLevelGameplayManager>(); beatmapObjectCallbackController = FindFirstOrDefault <BeatmapObjectCallbackController>(); gameplayModifiersSO = FindFirstOrDefault <GameplayModifiersModelSO>(); audioTimeSyncController = FindFirstOrDefault <AudioTimeSyncController>(); playerHeadAndObstacleInteraction = (PlayerHeadAndObstacleInteraction)scoreControllerHeadAndObstacleInteractionField.GetValue(scoreController); gameSongController = FindFirstOrDefault <GameSongController>(); gameEnergyCounter = FindFirstOrDefault <GameEnergyCounter>(); if (multiplayerController) { // NOOP } else if (gameplayManager is StandardLevelGameplayManager) { Plugin.log.Debug("Standard Level loaded"); } else if (gameplayManager is MissionLevelGameplayManager) { Plugin.log.Debug("Mission Level loaded"); } gameplayCoreSceneSetupData = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData; // Register event listeners // PauseController doesn't exist in multiplayer if (pauseController != null) { // public event Action PauseController#didPauseEvent; pauseController.didPauseEvent += OnGamePause; // public event Action PauseController#didResumeEvent; pauseController.didResumeEvent += OnGameResume; } // public ScoreController#noteWasCutEvent<NoteData, NoteCutInfo, int multiplier> // called after AfterCutScoreBuffer is created scoreController.noteWasCutEvent += OnNoteWasCut; // public ScoreController#noteWasMissedEvent<NoteData, int multiplier> scoreController.noteWasMissedEvent += OnNoteWasMissed; // public ScoreController#scoreDidChangeEvent<int, int> // score scoreController.scoreDidChangeEvent += OnScoreDidChange; // public ScoreController#comboDidChangeEvent<int> // combo scoreController.comboDidChangeEvent += OnComboDidChange; // public ScoreController#multiplierDidChangeEvent<int, float> // multiplier, progress [0..1] scoreController.multiplierDidChangeEvent += OnMultiplierDidChange; // public event Action<BeatmapEventData> BeatmapObjectCallbackController#beatmapEventDidTriggerEvent beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTrigger; // public event Action GameSongController#songDidFinishEvent; gameSongController.songDidFinishEvent += OnLevelFinished; // public event Action GameEnergyCounter#gameEnergyDidReach0Event; gameEnergyCounter.gameEnergyDidReach0Event += OnEnergyDidReach0Event; if (gameplayManager is ILevelEndActions levelEndActions) { // event Action levelFailedEvent; levelEndActions.levelFailedEvent += OnLevelFailed; } IDifficultyBeatmap diff = gameplayCoreSceneSetupData.difficultyBeatmap; IBeatmapLevel level = diff.level; gameStatus.partyMode = Gamemode.IsPartyActive; gameStatus.mode = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName; gameplayModifiers = gameplayCoreSceneSetupData.gameplayModifiers; PlayerSpecificSettings playerSettings = gameplayCoreSceneSetupData.playerSpecificSettings; PracticeSettings practiceSettings = gameplayCoreSceneSetupData.practiceSettings; float songSpeedMul = gameplayModifiers.songSpeedMul; if (practiceSettings != null) { songSpeedMul = practiceSettings.songSpeedMul; } // Generate NoteData to id mappings for backwards compatiblity with <1.12.1 noteToIdMapping = new NoteData[diff.beatmapData.cuttableNotesType + diff.beatmapData.bombsCount]; lastNoteId = 0; int beatmapObjectId = 0; var beatmapObjectsData = diff.beatmapData.beatmapObjectsData; foreach (BeatmapObjectData beatmapObjectData in beatmapObjectsData) { if (beatmapObjectData is NoteData noteData) { noteToIdMapping[beatmapObjectId++] = noteData; } } gameStatus.songName = level.songName; gameStatus.songSubName = level.songSubName; gameStatus.songAuthorName = level.songAuthorName; gameStatus.levelAuthorName = level.levelAuthorName; gameStatus.songBPM = level.beatsPerMinute; gameStatus.noteJumpSpeed = diff.noteJumpMovementSpeed; // 13 is "custom_level_" and 40 is the magic number for the length of the SHA-1 hash gameStatus.songHash = level.levelID.StartsWith("custom_level_") && !level.levelID.EndsWith(" WIP") ? level.levelID.Substring(13, 40) : null; gameStatus.levelId = level.levelID; gameStatus.songTimeOffset = (long)(level.songTimeOffset * 1000f / songSpeedMul); gameStatus.length = (long)(level.beatmapLevelData.audioClip.length * 1000f / songSpeedMul); gameStatus.start = GetCurrentTime() - (long)(audioTimeSyncController.songTime * 1000f / songSpeedMul); if (practiceSettings != null) { gameStatus.start -= (long)(practiceSettings.startSongTime * 1000f / songSpeedMul); } gameStatus.paused = 0; gameStatus.difficulty = diff.difficulty.Name(); gameStatus.notesCount = diff.beatmapData.cuttableNotesType; gameStatus.bombsCount = diff.beatmapData.bombsCount; gameStatus.obstaclesCount = diff.beatmapData.obstaclesCount; gameStatus.environmentName = level.environmentInfo.sceneInfo.sceneName; try { // From https://support.unity3d.com/hc/en-us/articles/206486626-How-can-I-get-pixels-from-unreadable-textures- var texture = (await level.GetCoverImageAsync(CancellationToken.None)).texture; var active = RenderTexture.active; var temporary = RenderTexture.GetTemporary( texture.width, texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear ); Graphics.Blit(texture, temporary); RenderTexture.active = temporary; var cover = new Texture2D(texture.width, texture.height); cover.ReadPixels(new Rect(0, 0, temporary.width, temporary.height), 0, 0); cover.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); gameStatus.songCover = System.Convert.ToBase64String( ImageConversion.EncodeToPNG(cover) ); } catch { gameStatus.songCover = null; } gameStatus.ResetPerformance(); UpdateModMultiplier(); gameStatus.songSpeedMultiplier = songSpeedMul; gameStatus.batteryLives = gameEnergyCounter.batteryLives; gameStatus.modObstacles = gameplayModifiers.enabledObstacleType.ToString(); gameStatus.modInstaFail = gameplayModifiers.instaFail; gameStatus.modNoFail = gameplayModifiers.noFailOn0Energy; gameStatus.modBatteryEnergy = gameplayModifiers.energyType == GameplayModifiers.EnergyType.Battery; gameStatus.modDisappearingArrows = gameplayModifiers.disappearingArrows; gameStatus.modNoBombs = gameplayModifiers.noBombs; gameStatus.modSongSpeed = gameplayModifiers.songSpeed.ToString(); gameStatus.modNoArrows = gameplayModifiers.noArrows; gameStatus.modGhostNotes = gameplayModifiers.ghostNotes; gameStatus.modFailOnSaberClash = gameplayModifiers.failOnSaberClash; gameStatus.modStrictAngles = gameplayModifiers.strictAngles; gameStatus.modFastNotes = gameplayModifiers.fastNotes; gameStatus.staticLights = playerSettings.staticLights; gameStatus.leftHanded = playerSettings.leftHanded; gameStatus.playerHeight = playerSettings.playerHeight; gameStatus.sfxVolume = playerSettings.sfxVolume; gameStatus.reduceDebris = playerSettings.reduceDebris; gameStatus.noHUD = playerSettings.noTextsAndHuds; gameStatus.advancedHUD = playerSettings.advancedHud; gameStatus.autoRestart = playerSettings.autoRestart; statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "songStart"); }
void Awake() { instance = this; }
void Start() { mc = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MultiplayerController>(); mm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MenuManager>(); }
public void MatchWithFriends() { _instance = new MultiplayerController(); if (PlayGamesPlatform.Instance.localUser.authenticated) { PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen (MinOpponents, MaxOpponents, Variant, _instance); } }
private static void Prefix(MultiplayerController __instance, MultiplayerPlayersManager ____playersManager) { _playersManager = ____playersManager; Events.SetSelectedLevel(null); }
private static void Prefix(MultiplayerController __instance) { Events.SetSelectedLevel(null); }
public async void HandleSongStart() { // Check if level data is actually available in BS_Utils before proceeding further. It isn't available in the tutorial if (!BS_Utils.Plugin.LevelData.IsSet) { Plugin.log.Debug("BS_Utils level data is not present. Probably due to the tutorial being active."); return; } GameStatus gameStatus = statusManager.gameStatus; // Check for multiplayer early to abort if needed: gameplay controllers don't exist in multiplayer until later multiplayerSessionManager = FindFirstOrDefaultOptional <MultiplayerSessionManager>(); multiplayerController = FindFirstOrDefaultOptional <MultiplayerController>(); if (multiplayerSessionManager && multiplayerController) { Plugin.log.Debug("Multiplayer Level loaded"); // public event Action<DisconnectedReason> MultiplayerSessionManager#disconnectedEvent; multiplayerSessionManager.disconnectedEvent += OnMultiplayerDisconnected; // public event Action<State> MultiplayerController#stateChangedEvent; multiplayerController.stateChangedEvent += OnMultiplayerStateChanged; // Do nothing until the next state change to Gameplay. if (multiplayerController.state != MultiplayerController.State.Gameplay) { return; } multiplayerLocalActivePlayerFacade = FindFirstOrDefaultOptional <MultiplayerLocalActivePlayerFacade>(); if (multiplayerLocalActivePlayerFacade != null) { multiplayerLocalActivePlayerFacade.playerDidFinishEvent += OnMultiplayerLevelFinished; } } else if (!doDelayedSongStart) { doDelayedSongStart = true; return; } // `wants_to_play_next_level` is set for players who don't want to play the song aka want to spectate aka are not "active". `isSpectating` is apparently not spectating. gameStatus.scene = multiplayerSessionManager.isSpectating || !multiplayerSessionManager.LocalPlayerHasState(NetworkConstants.wantsToPlayNextLevel) ? "Spectator" : "Song"; gameStatus.multiplayer = multiplayerSessionManager.isConnectingOrConnected; pauseController = FindFirstOrDefaultOptional <PauseController>(); scoreController = FindWithMultiplayerFix <ScoreController>(); beatmapObjectManager = (BeatmapObjectManager)scoreControllerBeatmapObjectManagerField.GetValue(scoreController); gameplayManager = FindFirstOrDefaultOptional <StandardLevelGameplayManager>() as MonoBehaviour ?? FindFirstOrDefaultOptional <MissionLevelGameplayManager>(); beatmapObjectCallbackController = FindWithMultiplayerFix <BeatmapObjectCallbackController>(); gameplayModifiersSO = FindFirstOrDefault <GameplayModifiersModelSO>(); audioTimeSyncController = FindWithMultiplayerFix <AudioTimeSyncController>(); playerHeadAndObstacleInteraction = (PlayerHeadAndObstacleInteraction)scoreControllerHeadAndObstacleInteractionField.GetValue(scoreController); gameSongController = FindWithMultiplayerFix <GameSongController>(); gameEnergyCounter = FindWithMultiplayerFix <GameEnergyCounter>(); if (multiplayerController) { // NOOP } else if (gameplayManager is StandardLevelGameplayManager) { Plugin.log.Debug("Standard Level loaded"); } else if (gameplayManager is MissionLevelGameplayManager) { Plugin.log.Debug("Mission Level loaded"); } gameplayCoreSceneSetupData = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData; // Register event listeners // PauseController doesn't exist in multiplayer if (pauseController != null) { // public event Action PauseController#didPauseEvent; pauseController.didPauseEvent += OnGamePause; // public event Action PauseController#didResumeEvent; pauseController.didResumeEvent += OnGameResume; } // public ScoreController#noteWasCutEvent<NoteData, NoteCutInfo, int multiplier> // called after CutScoreBuffer is created scoreController.noteWasCutEvent += OnNoteWasCut; // public ScoreController#noteWasMissedEvent<NoteData, int multiplier> scoreController.noteWasMissedEvent += OnNoteWasMissed; // public ScoreController#scoreDidChangeEvent<int, int> // score scoreController.scoreDidChangeEvent += OnScoreDidChange; // public ScoreController#comboDidChangeEvent<int> // combo scoreController.comboDidChangeEvent += OnComboDidChange; // public ScoreController#multiplierDidChangeEvent<int, float> // multiplier, progress [0..1] scoreController.multiplierDidChangeEvent += OnMultiplierDidChange; beatmapObjectManager.noteWasSpawnedEvent += OnNoteWasSpawned; // public event Action<BeatmapEventData> BeatmapObjectCallbackController#beatmapEventDidTriggerEvent beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTrigger; // public event Action GameSongController#songDidFinishEvent; gameSongController.songDidFinishEvent += OnLevelFinished; // public event Action GameEnergyCounter#gameEnergyDidReach0Event; gameEnergyCounter.gameEnergyDidReach0Event += OnEnergyDidReach0Event; if (gameplayManager is ILevelEndActions levelEndActions) { // event Action levelFailedEvent; levelEndActions.levelFailedEvent += OnLevelFailed; } IDifficultyBeatmap diff = gameplayCoreSceneSetupData.difficultyBeatmap; IBeatmapLevel level = diff.level; gameStatus.partyMode = Gamemode.IsPartyActive; gameplayModifiers = gameplayCoreSceneSetupData.gameplayModifiers; gameplayModiferParamsList = gameplayModifiersSO.CreateModifierParamsList(gameplayModifiers); PlayerSpecificSettings playerSettings = gameplayCoreSceneSetupData.playerSpecificSettings; PracticeSettings practiceSettings = gameplayCoreSceneSetupData.practiceSettings; float songSpeedMul = gameplayModifiers.songSpeedMul; if (practiceSettings != null) { songSpeedMul = practiceSettings.songSpeedMul; } int beatmapObjectId = 0; var beatmapObjectsData = diff.beatmapData.beatmapObjectsData; // Generate NoteData to id mappings for backwards compatiblity with <1.12.1 noteToIdMapping = new NoteData[beatmapObjectsData.Count(obj => obj is NoteData)]; lastNoteId = 0; foreach (BeatmapObjectData beatmapObjectData in beatmapObjectsData) { if (beatmapObjectData is NoteData noteData) { noteToIdMapping[beatmapObjectId++] = noteData; } } gameStatus.songName = level.songName; gameStatus.songSubName = level.songSubName; gameStatus.songAuthorName = level.songAuthorName; gameStatus.levelAuthorName = level.levelAuthorName; gameStatus.songBPM = level.beatsPerMinute; gameStatus.noteJumpSpeed = diff.noteJumpMovementSpeed; gameStatus.noteJumpStartBeatOffset = diff.noteJumpStartBeatOffset; // 13 is "custom_level_" and 40 is the magic number for the length of the SHA-1 hash gameStatus.songHash = Regex.IsMatch(level.levelID, "^custom_level_[0-9A-F]{40}", RegexOptions.IgnoreCase) && !level.levelID.EndsWith(" WIP") ? level.levelID.Substring(13, 40) : null; gameStatus.levelId = level.levelID; gameStatus.songTimeOffset = (long)(level.songTimeOffset * 1000f / songSpeedMul); gameStatus.length = (long)(level.beatmapLevelData.audioClip.length * 1000f / songSpeedMul); gameStatus.start = GetCurrentTime() - (long)(audioTimeSyncController.songTime * 1000f / songSpeedMul); if (practiceSettings != null) { gameStatus.start -= (long)(practiceSettings.startSongTime * 1000f / songSpeedMul); } gameStatus.paused = 0; gameStatus.difficulty = diff.difficulty.Name(); gameStatus.difficultyEnum = Enum.GetName(typeof(BeatmapDifficulty), diff.difficulty); gameStatus.characteristic = diff.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName; gameStatus.notesCount = diff.beatmapData.cuttableNotesCount; gameStatus.bombsCount = diff.beatmapData.bombsCount; gameStatus.obstaclesCount = diff.beatmapData.obstaclesCount; gameStatus.environmentName = level.environmentInfo.sceneInfo.sceneName; ColorScheme colorScheme = gameplayCoreSceneSetupData.colorScheme ?? new ColorScheme(gameplayCoreSceneSetupData.environmentInfo.colorScheme); gameStatus.colorSaberA = colorScheme.saberAColor; gameStatus.colorSaberB = colorScheme.saberBColor; gameStatus.colorEnvironment0 = colorScheme.environmentColor0; gameStatus.colorEnvironment1 = colorScheme.environmentColor1; if (colorScheme.supportsEnvironmentColorBoost) { gameStatus.colorEnvironmentBoost0 = colorScheme.environmentColor0Boost; gameStatus.colorEnvironmentBoost1 = colorScheme.environmentColor1Boost; } gameStatus.colorObstacle = colorScheme.obstaclesColor; try { // From https://support.unity3d.com/hc/en-us/articles/206486626-How-can-I-get-pixels-from-unreadable-textures- // Modified to correctly handle texture atlases. Fixes #82. var active = RenderTexture.active; var sprite = await level.GetCoverImageAsync(CancellationToken.None); var texture = sprite.texture; var temporary = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear); Graphics.Blit(texture, temporary); RenderTexture.active = temporary; var spriteRect = sprite.rect; var uv = sprite.uv[0]; var cover = new Texture2D((int)spriteRect.width, (int)spriteRect.height); // Unity sucks. The coordinates of the sprite on its texture atlas are only accessible through the Sprite.uv property since rect always returns `x=0,y=0`, so we need to convert them back into texture space. cover.ReadPixels(new Rect( uv.x * texture.width, texture.height - uv.y * texture.height, spriteRect.width, spriteRect.height ), 0, 0); cover.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); gameStatus.songCover = System.Convert.ToBase64String(ImageConversion.EncodeToPNG(cover)); } catch { gameStatus.songCover = null; } gameStatus.ResetPerformance(); UpdateModMultiplier(); gameStatus.songSpeedMultiplier = songSpeedMul; gameStatus.batteryLives = gameEnergyCounter.batteryLives; gameStatus.modObstacles = gameplayModifiers.enabledObstacleType.ToString(); gameStatus.modInstaFail = gameplayModifiers.instaFail; gameStatus.modNoFail = gameplayModifiers.noFailOn0Energy; gameStatus.modBatteryEnergy = gameplayModifiers.energyType == GameplayModifiers.EnergyType.Battery; gameStatus.modDisappearingArrows = gameplayModifiers.disappearingArrows; gameStatus.modNoBombs = gameplayModifiers.noBombs; gameStatus.modSongSpeed = gameplayModifiers.songSpeed.ToString(); gameStatus.modNoArrows = gameplayModifiers.noArrows; gameStatus.modGhostNotes = gameplayModifiers.ghostNotes; gameStatus.modFailOnSaberClash = gameplayModifiers.failOnSaberClash; gameStatus.modStrictAngles = gameplayModifiers.strictAngles; gameStatus.modFastNotes = gameplayModifiers.fastNotes; gameStatus.modSmallNotes = gameplayModifiers.smallCubes; gameStatus.modProMode = gameplayModifiers.proMode; gameStatus.modZenMode = gameplayModifiers.zenMode; var environmentEffectsFilterPreset = diff.difficulty == BeatmapDifficulty.ExpertPlus ? playerSettings.environmentEffectsFilterExpertPlusPreset : playerSettings.environmentEffectsFilterDefaultPreset; // Backwards compatibility for <1.13.4 gameStatus.staticLights = environmentEffectsFilterPreset != EnvironmentEffectsFilterPreset.AllEffects; gameStatus.leftHanded = playerSettings.leftHanded; gameStatus.playerHeight = playerSettings.playerHeight; gameStatus.sfxVolume = playerSettings.sfxVolume; gameStatus.reduceDebris = playerSettings.reduceDebris; gameStatus.noHUD = playerSettings.noTextsAndHuds; gameStatus.advancedHUD = playerSettings.advancedHud; gameStatus.autoRestart = playerSettings.autoRestart; gameStatus.saberTrailIntensity = playerSettings.saberTrailIntensity; gameStatus.environmentEffects = environmentEffectsFilterPreset.ToString(); gameStatus.hideNoteSpawningEffect = playerSettings.hideNoteSpawnEffect; statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "songStart"); }
public static void AcceptFromInbox() { _instance = new MultiplayerController(); PlayGamesPlatform.Instance.RealTime.AcceptFromInbox(_instance); }
/** * Coroutine method that waits for the multiplayer controller to be instantiated */ private IEnumerator findMultiplayerController () { // Wait 100ms for the networkManager to be instantiated yield return new WaitForSeconds (0.1f); // Get all of the available controllers GameObject[] controllers = GameObject.FindGameObjectsWithTag ("Multiplayer Controller"); // Decrement the number of attempts attempts--; // Loop through the controllers foreach (GameObject controller in controllers) { // Get the script MultiplayerController script = controller.GetComponent<MultiplayerController> (); // Check if the script belongs to the player if (script.isLocalPlayer) { // Set the controller multiplayerController = script; // Break out of the loop break; } } // Ensure that the controller is not null if (multiplayerController != null) { // Rename the server's copy of the controller multiplayerController.gameObject.name = string.Format ("Local Multiplayer Controller"); // Move the controller to the collections holder multiplayerController.gameObject.transform.SetParent (GameObject.Find ("Multiplayer Controllers").transform); // Give the controller references to the local phone objects multiplayerController.setVars (gameController, uiController, this); // Create the player and join the lobby multiplayerController.doCreatePlayer (); } else { // Ensure that it stops at some point if (attempts >= 0) { // Wait again StartCoroutine (findMultiplayerController ()); } } }
private void MultiControllerStateChanged(MultiplayerController.State newState, ScenesTransitionSetupDataSO transitionSetupData, DiContainer diContainer, MultiplayerController sync = null) { if (newState == MultiplayerController.State.Gameplay) { sync.stateChangedEvent -= (state) => { MultiControllerStateChanged(state, transitionSetupData, diContainer, sync); }; GameSceneSceneWasLoaded(transitionSetupData, diContainer, sync); } }
private void GameSceneSceneWasLoaded(ScenesTransitionSetupDataSO transitionSetupData, DiContainer diContainer, MultiplayerController sync = null) { var pauseManager = diContainer.TryResolve <PauseController>(); if (pauseManager != null) { pauseManager.didResumeEvent += delegate { InvokeAll(songUnpaused); }; pauseManager.didPauseEvent += delegate { InvokeAll(songPaused); }; } var beatmapObjectManager = diContainer.TryResolve <BeatmapObjectManager>(); if (beatmapObjectManager != null) { beatmapObjectManager.noteWasCutEvent += (NoteController controller, in NoteCutInfo noteCutInfo) => InvokeAll(noteWasCut, controller, noteCutInfo); beatmapObjectManager.noteWasMissedEvent += controller => InvokeAll(noteWasMissed, controller); } var comboController = diContainer.TryResolve <ComboController>(); if (comboController != null) { comboController.comboDidChangeEvent += delegate(int combo) { InvokeAll(comboDidChange, combo); }; comboController.comboBreakingEventHappenedEvent += delegate { InvokeAll(comboDidBreak); }; } var scoreController = diContainer.TryResolve <ScoreController>(); if (scoreController != null) { scoreController.multiplierDidChangeEvent += delegate(int multiplier, float progress) { InvokeAll(multiplierDidChange, multiplier, progress); if (multiplier > 1 && progress < 0.1f) { InvokeAll(multiplierDidIncrease, multiplier); } }; scoreController.scoreDidChangeEvent += delegate { InvokeAll(scoreDidChange); }; } var saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().LastOrDefault(x => x.isActiveAndEnabled); if (saberCollisionManager != null) { saberCollisionManager.sparkleEffectDidStartEvent += delegate(SaberType saber) { InvokeAll(sabersStartCollide, saber); }; saberCollisionManager.sparkleEffectDidEndEvent += delegate(SaberType saber) { InvokeAll(sabersEndCollide, saber); }; } var gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().LastOrDefault(x => x.isActiveAndEnabled); if (gameEnergyCounter != null) { gameEnergyCounter.gameEnergyDidReach0Event += delegate { InvokeAll(energyReachedZero); }; gameEnergyCounter.gameEnergyDidChangeEvent += delegate(float energy) { InvokeAll(energyDidChange, energy); }; } var beatmapCallbacksController = diContainer.TryResolve <BeatmapCallbacksController>(); beatmapCallbacksController?.AddBeatmapCallback(new BeatmapDataCallback <BeatmapEventData>(songEvent => InvokeAll(beatmapEvent, songEvent))); var transitionSetup = Resources.FindObjectsOfTypeAll <StandardLevelScenesTransitionSetupDataSO>().FirstOrDefault(); if (transitionSetup) { transitionSetup.didFinishEvent -= OnTransitionSetupOnDidFinishEvent; transitionSetup.didFinishEvent += OnTransitionSetupOnDidFinishEvent; } InvokeAll(gameSceneLoaded); }
//Quick Game public void StartMatchMaking() { _instance = new MultiplayerController(); if (PlayGamesPlatform.Instance.localUser.authenticated) { PlayGamesPlatform.Instance.RealTime.CreateQuickGame (MinOpponents, MaxOpponents, Variant, _instance); } }