Esempio n. 1
0
        private IEnumerator DelayInit(GameParams.DiffGameParams mapParams)
        {
            yield return(new WaitForSeconds(0.1f));

            GameController.mapParams = mapParams;
            new GameObject("GameSaber Controller").AddComponent <GameController>();
        }
Esempio n. 2
0
        public void Update()
        {
            if (!_init)
            {
                return;
            }
            if (_game == null)
            {
                return;
            }
            if (!_game.Started)
            {
                if (songAudio.time > lastCommentTime + 2.25f + beatTime * 2f)
                {
                    SpawnIntroText(2.25f);
                    lastCommentTime = songAudio.time;
                }
                if (!startMessageSent && songAudio.time >= gameStartTime - 3f)
                {
                    SpawnText(_game.GetStartText(), 3f);
                    startMessageSent = true;
                }
                if (!playerChoseType && songAudio.time >= phaseThreshold)
                {
                    StartGame(true);
                }
                //Debug game start
                if (Input.GetKeyDown(KeyCode.X))
                {
                    StartGame(true);
                }
                else if (Input.GetKeyDown(KeyCode.O))
                {
                    StartGame(false);
                }
            }
            else
            {
                if (songAudio.time > lastCommentTime + 2.25f + beatTime * 2f)
                {
                    SpawnGameText(2.25f);
                    lastCommentTime = songAudio.time;
                }

                if (Input.GetKeyDown(KeyCode.K) && IsPlayerTurn)
                {
                    EndPlayerTurn(_currentSpaces[UnityEngine.Random.Range(0, _currentSpaces.Count)]);
                }

                if (IsPlayerTurn && songAudio.time > phaseThreshold)
                {
                    EndPlayerTurn(_currentSpaces[UnityEngine.Random.Range(0, _currentSpaces.Count)]);
                }
                if (songAudio.time > mapParams.gameEndTime)
                {
                    //  NewGame(true);
                    _game     = null;
                    _init     = false;
                    mapParams = null;
                    CleanBeatmap();
                    SpawnText("Well Done!", 5f);
                }
            }
        }
Esempio n. 3
0
        private void BSEvents_gameSceneLoaded()
        {
            Active = false;
            GameController.worldRotation        = Quaternion.identity;
            GameController.inverseWorldRotation = Quaternion.identity;

            if (!BS_Utils.Plugin.LevelData.IsSet)
            {
                return;
            }
            if (!(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.level is CustomPreviewBeatmapLevel))
            {
                return;
            }
            if (BS_Utils.Plugin.LevelData.Mode != BS_Utils.Gameplay.Mode.Standard)
            {
                return;
            }

            var level    = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.level as CustomPreviewBeatmapLevel;
            var songData = SongCore.Collections.RetrieveDifficultyData(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap);

            if (songData == null)
            {
                return;
            }

            bool ticTacMap = songData.additionalDifficultyData._requirements.Contains("GameSaber");
            //  if (!ticTacMap) return;
            string path = Path.Combine(level.customLevelPath, "GameParams.json");

            if (!File.Exists(path) && ticTacMap)
            {
                BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Invalid GameSaber Params");
                return;
            }

            GameParams mapParams = null;

            GameParams.DiffGameParams diffParams = null;
            if (ticTacMap)
            {
                try
                {
                    mapParams  = Newtonsoft.Json.JsonConvert.DeserializeObject <GameParams>(File.ReadAllText(path));
                    diffParams = mapParams.games.FirstOrDefault(x => x.beatmapCharacteristicName == songData._beatmapCharacteristicName && x.beatmapDifficultyName == songData._difficulty.SerializedName());
                    if (diffParams == null || diffParams.gameType == GameType.None)
                    {
                        Logger.log.Error("Invalid GameParams, not initializing GameSaber");
                        Logger.log.Error($"1 {songData._beatmapCharacteristicName} | {songData._difficulty.SerializedName()}");
                        BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Invalid GameSaber Params");
                        return;
                    }
                    if (diffParams.gameType == GameType.ConnectFour && !songData.additionalDifficultyData._requirements.Contains("Mapping Extensions"))
                    {
                        Logger.log.Error("Invalid Difficulty requirements, ConnectFour requires Mapping Extensions, not initializing GameSaber");
                        Logger.log.Error($"in {songData._beatmapCharacteristicName} | {songData._difficulty.SerializedName()} Difficulty");
                        BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Invalid GameSaber Params");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Logger.log.Error("Invalid GameParams, not initializing GameSaber");
                    Logger.log.Error($"2 {ex}");
                    BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Invalid GameSaber Params");
                    return;
                }
            }

            SharedCoroutineStarter.instance.StartCoroutine(DelayInit(diffParams));
        }