Example #1
0
 public void OpenDatabase()
 {
     if (database == null)
     {
         database = new Database(SongInfoLoader.GetAbsolutePath("../" + sqlitePath));
     }
 }
Example #2
0
    public void StartGame()
    {
        HideOptions();
        if (string.IsNullOrEmpty(Loader.songPath))
        {
            SongInfoLoader.OnRecursiveLoaded += StartListen;
            SongInfoLoader.RecursiveLoadDirectory();
            return;
        }
        switch (Loader.gameMode)
        {
        case 0: SceneManager.LoadScene("GameScene"); break;

        case 1: SceneManager.LoadScene("ClassicGameScene"); break;
        }
    }
Example #3
0
    IEnumerator LoadBMSCoroutine(string songPath)
    {
        bmsManager.IsStarted = false;
        FileInfo fileInfo   = new FileInfo(songPath);
        string   bmsContent = SongInfoLoader.LoadFile(fileInfo);

        bmsManager.NoteLimit             = noteLimit > 0 ? Mathf.FloorToInt(Mathf.Pow(2, 3 + noteLimit)) : 0;
        bmsManager.DetuneEnabled         = enableDetune;
        bmsManager.BGAEnabled            = enableBGA;
        bmsManager.DynamicPreEventOffset = dynamicSpeed;
        bmsManager.PreEventOffset        = TimeSpan.FromSeconds((2 - speed) * 2);
        bmsManager.LoadBMS(bmsContent, fileInfo.Directory.FullName, fileInfo.Extension);
        while (!bmsManager.BMSLoaded)
        {
            yield return(null);
        }

        bmsManager.ReloadBMS(BMSReloadOperation.Body | BMSReloadOperation.ResourceHeader);
        while (!bmsManager.BMSLoaded)
        {
            yield return(null);
        }
        bmsManager.ReloadBMS(BMSReloadOperation.Resources);
        while (bmsManager.IsLoadingResources)
        {
            yield return(null);
        }
        bmsManager.InitializeNoteScore();

        if (noteDetector != null)
        {
            noteDetector.autoMode = autoMode;
        }
        if (noteSpaawners != null)
        {
            foreach (var spawner in noteSpaawners)
            {
                spawner.coloringMode = colorMode;
            }
        }
        bmsManager.TightMode = judgeMode == 1;
        if (!enableBGA)
        {
            bmsManager.placeHolderTexture = Texture2D.whiteTexture;
        }
        bmsManager.IsStarted = true;
    }
Example #4
0
    /// <summary>
    /// 游戏开始的逻辑
    /// </summary>
    /// <param name="_bDevelopment"></param>
    void Play(bool _bDevelopment)
    {
        DeactiveateAllGUI();
        ActivateGUI("OnPlayGUI");
        if (_bDevelopment)
        {
            ActivateGUI("DevelopmentModeGUI");
        }

        //从csv读取歌曲数据
        TextReader textReader = new StringReader(
            System.Text.Encoding.UTF8.GetString((Resources.Load(SongName + "songInfoCSV") as TextAsset).bytes));
        SongInfo       songInfo = new SongInfo();
        SongInfoLoader loader   = new SongInfoLoader();

        loader.songInfo = songInfo;
        loader.ReadCSV(SongName, textReader);
        m_musicManager.currentSongInfo = songInfo;

        //-三波观众开始动起来
        foreach (GameObject audience in GameObject.FindGameObjectsWithTag("Audience"))
        {
            audience.GetComponent <SimpleActionMotor>().isWaveBegin = true;
        }

        //-各种效果动画(舞台演出等)开始
        GameObject.Find("EventManager").GetComponent <EventManager>().BeginEventSequence();

        //-得分评价开始
        m_scoringManager.BeginScoringSequence();

        //-节奏序列绘制开始
        OnPlayGUI onPlayGUI = GameObject.Find("OnPlayGUI").GetComponent <OnPlayGUI>();

        onPlayGUI.BeginVisualization();
        onPlayGUI.isDevelopmentMode = _bDevelopment;

        //-绘制开发版的特殊界面
        if (_bDevelopment)
        {
            GameObject.Find("DevelopmentModeGUI").GetComponent <DevelopmentModeGUI>().BeginVisualization();
        }

        //开始播放音乐
        m_musicManager.PlayMusicFromStart();
    }
Example #5
0
 public void Save()
 {
     using (var stream = File.Open(SongInfoLoader.GetAbsolutePath(path), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) {
         var writer = new BinaryWriter(stream);
         writer.Write(presets.Count);
         foreach (var kv in presets)
         {
             writer.Write(kv.Key);
             if (kv.Value == null)
             {
                 writer.Write(-1);
                 continue;
             }
             writer.Write(kv.Value.Length);
             writer.Write(kv.Value);
         }
         writer.Write(oldIndex);
     }
 }
Example #6
0
    void Awake()
    {
        if (!bmsManager)
        {
            bmsManager = GetComponent <BMSManager>();
        }
        if (!bmsManager)
        {
            bmsManager = gameObject.AddComponent <BMSManager>();
        }
        SongInfoLoader.SetBMSManager(bmsManager);

        gameMode.value = Loader.gameMode;
        gameMode.onValueChanged.AddListener(GameModeChange);
        colorMode.value = (int)Loader.colorMode;
        colorMode.onValueChanged.AddListener(ColorModeChange);
        autoModeToggle.isOn = Loader.autoMode;
        autoModeToggle.onValueChanged.AddListener(ToggleAuto);
        detuneToggle.isOn = Loader.enableDetune;
        detuneToggle.onValueChanged.AddListener(ToggleDetune);
        bgaToggle.isOn = Loader.enableBGA;
        bgaToggle.onValueChanged.AddListener(ToggleBGA);
        dynamicSpeedToggle.isOn = Loader.dynamicSpeed;
        dynamicSpeedToggle.onValueChanged.AddListener(ToggleDynamicSpeed);
        judgeModeDropDown.value = Loader.judgeMode;
        judgeModeDropDown.onValueChanged.AddListener(JudgeModeChange);
        speedSlider.value = Loader.speed;
        speedSlider.onValueChanged.AddListener(ChangeSpeed);
        notesLimitSlider.value = Loader.noteLimit;
        notesLimitSlider.onValueChanged.AddListener(ChangeNoteLimit);
        sortMode.value = savedSortMode;
        sortMode.onValueChanged.AddListener(ChangeSortMode);
        startGameButton.onClick.AddListener(StartGame);
        optionsButton.onClick.AddListener(ShowOptions);
        optionsBackButton.onClick.AddListener(HideOptions);

        currentInfo = SongInfoLoader.SelectedSong;
        SongInfoLoader.OnStartLoading     += OnLoadingChanged;
        SongInfoLoader.OnListUpdated      += OnLoadingChanged;
        SongInfoLoader.OnSelectionChanged += SelectionChanged;
        LanguageLoader.OnLanguageChange   += LangChange;
        OnLoadingChanged();
    }
Example #7
0
    void Start()
    {
        var file = new FileInfo(SongInfoLoader.GetAbsolutePath(path));

        if (file.Exists)
        {
            using (var stream = file.OpenRead()) {
                var reader       = new BinaryReader(stream);
                int presetsCount = reader.ReadInt32();
                for (int i = 0; i < presetsCount; i++)
                {
                    var presetName = reader.ReadString();
                    int dataLength = reader.ReadInt32();
                    presets[presetName] = dataLength == -1 ? null : reader.ReadBytes(dataLength);
                    presetsDisplay.options.Add(new Dropdown.OptionData(presetName));
                }
                oldIndex = reader.ReadInt32();
            }
        }
        if (presets.Count == 0)
        {
            oldIndex = 0;
            presets.Add("Default", null);
            presetsDisplay.options.Add(new Dropdown.OptionData("Default"));
            if (OnReset != null)
            {
                OnReset.Invoke();
            }
        }
        if (oldIndex >= 0)
        {
            presetsDisplay.value = oldIndex;
            SelectionChanged();
        }
        initialized = true;
    }
    public void SetPhase(string nextPhase)
    {
        switch (nextPhase)
        {
        // 开始菜单
        case "Startup":
        {
            DeactiveateAllGUI();
            this.startupMenuGUI.gameObject.SetActive(true);
        }
        break;

        // 说明
        case "OnBeginInstruction":
        {
            DeactiveateAllGUI();
            this.instructionGUI.gameObject.SetActive(true);
            this.onPlayGUI.gameObject.SetActive(true);
        }
        break;

        //主体游戏
        case "Play":
        {
            DeactiveateAllGUI();
            this.onPlayGUI.gameObject.SetActive(true);

            //从csv读取音乐数据
            TextReader textReader
                = new StringReader(
                      System.Text.Encoding.UTF8.GetString((Resources.Load("SongInfo/songInfoCSV") as TextAsset).bytes)
                      );
            SongInfo       songInfo = new SongInfo();
            SongInfoLoader loader   = new SongInfoLoader();
            loader.songInfo = songInfo;
            loader.ReadCSV(textReader);
            m_musicManager.currentSongInfo = songInfo;

            foreach (GameObject audience in GameObject.FindGameObjectsWithTag("Audience"))
            {
                audience.GetComponent <SimpleActionMotor>().isWaveBegin = true;
            }
            //事件(舞台演出等)开始
            GameObject.Find("EventManager").GetComponent <EventManager>().BeginEventSequence();
            //开始评价得分
            m_scoringManager.BeginScoringSequence();

            //开始绘制旋律的时间序列
            this.onPlayGUI.BeginVisualization();
            this.onPlayGUI.isDevelopmentMode = false;
            //开始演奏
            m_musicManager.PlayMusicFromStart();
        }
        break;

        case "DevelopmentMode":
        {
            DeactiveateAllGUI();
            this.developmentGUI.gameObject.SetActive(true);
            this.onPlayGUI.gameObject.SetActive(true);

            //从csv读取音乐数据
            TextReader textReader
                = new StringReader(
                      System.Text.Encoding.UTF8.GetString((Resources.Load("SongInfo/songInfoCSV") as TextAsset).bytes)
                      );
            SongInfo       songInfo = new SongInfo();
            SongInfoLoader loader   = new SongInfoLoader();
            loader.songInfo = songInfo;
            loader.ReadCSV(textReader);
            m_musicManager.currentSongInfo = songInfo;

            foreach (GameObject audience in GameObject.FindGameObjectsWithTag("Audience"))
            {
                audience.GetComponent <SimpleActionMotor>().isWaveBegin = true;
            }
            //事件(舞台演出等)开始
            GameObject.Find("EventManager").GetComponent <EventManager>().BeginEventSequence();
            //开始评价得分
            m_scoringManager.BeginScoringSequence();

            //开始绘制旋律时序图
            this.onPlayGUI.BeginVisualization();
            this.onPlayGUI.isDevelopmentMode = true;

            //开始绘制develop模式下的专用GUI时序图
            GameObject.Find("DevelopmentModeGUI").GetComponent <DevelopmentModeGUI>().BeginVisualization();
            //开始演奏
            m_musicManager.PlayMusicFromStart();
        }
        break;

        case "GameOver":
        {
            DeactiveateAllGUI();
            this.showResultGUI.gameObject.SetActive(true);

            //显示保存得分的信息
            //Debug.Log( m_scoringManager.scoreRate );
            //Debug.Log(ScoringManager.failureScoreRate);

            ShowResultGUI.RESULT result = ShowResultGUI.RESULT.GOOD;

            if (m_scoringManager.scoreRate <= ScoringManager.failureScoreRate)
            {
                result = ShowResultGUI.RESULT.BAD;
                GameObject.Find("Vocalist").GetComponent <BandMember>().BadFeedback();
            }
            else if (m_scoringManager.scoreRate >= ScoringManager.excellentScoreRate)
            {
                result = ShowResultGUI.RESULT.EXCELLENT;
                GameObject.Find("Vocalist").GetComponent <BandMember>().GoodFeedback();
                GameObject.Find("AudienceVoice").GetComponent <AudioSource>().Play();
            }
            else
            {
                result = ShowResultGUI.RESULT.GOOD;
                GameObject.Find("Vocalist").GetComponent <BandMember>().GoodFeedback();
            }

            this.showResultGUI.BeginVisualization(result);
        }
        break;

        case "Restart":
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
        }
        break;

        default:
        {
            Debug.LogError("unknown phase: " + nextPhase);
        }
        break;
        }         // end of switch

        m_currentPhase = nextPhase;
    }
Example #9
0
    public void SetPhase(string nextPhase)
    {
        switch (nextPhase)
        {
        // スタートメニュー.
        case "Startup":
        {
            DeactiveateAllGUI();
            this.startupMenuGUI.gameObject.SetActive(true);
        }
        break;

        // 説明.
        case "OnBeginInstruction":
        {
            DeactiveateAllGUI();
            this.instructionGUI.gameObject.SetActive(true);
            this.onPlayGUI.gameObject.SetActive(true);
        }
        break;

        //メインゲーム.
        case "Play":
        {
            DeactiveateAllGUI();
            this.onPlayGUI.gameObject.SetActive(true);

            //csvから曲データ読み込み.
            TextReader textReader
                = new StringReader(
                      System.Text.Encoding.UTF8.GetString((Resources.Load("SongInfo/songInfoCSV") as TextAsset).bytes)
                      );
            SongInfo       songInfo = new SongInfo();
            SongInfoLoader loader   = new SongInfoLoader();
            loader.songInfo = songInfo;
            loader.ReadCSV(textReader);
            m_musicManager.currentSongInfo = songInfo;

            foreach (GameObject audience in GameObject.FindGameObjectsWithTag("Audience"))
            {
                audience.GetComponent <SimpleActionMotor>().isWaveBegin = true;
            }
            //イベント(ステージ演出等)開始.
            GameObject.Find("EventManager").GetComponent <EventManager>().BeginEventSequence();
            //スコア評価開始
            m_scoringManager.BeginScoringSequence();

            //リズムシーケンス描画開始.
            this.onPlayGUI.BeginVisualization();
            this.onPlayGUI.isDevelopmentMode = false;
            //演奏開始.
            m_musicManager.PlayMusicFromStart();
        }
        break;

        case "DevelopmentMode":
        {
            DeactiveateAllGUI();
            this.developmentGUI.gameObject.SetActive(true);
            this.onPlayGUI.gameObject.SetActive(true);

            //csvから曲データ読み込み.
            TextReader textReader
                = new StringReader(
                      System.Text.Encoding.UTF8.GetString((Resources.Load("SongInfo/songInfoCSV") as TextAsset).bytes)
                      );
            SongInfo       songInfo = new SongInfo();
            SongInfoLoader loader   = new SongInfoLoader();
            loader.songInfo = songInfo;
            loader.ReadCSV(textReader);
            m_musicManager.currentSongInfo = songInfo;

            foreach (GameObject audience in GameObject.FindGameObjectsWithTag("Audience"))
            {
                audience.GetComponent <SimpleActionMotor>().isWaveBegin = true;
            }
            //イベント(ステージ演出等)開始.
            GameObject.Find("EventManager").GetComponent <EventManager>().BeginEventSequence();
            //スコア評価開始.
            m_scoringManager.BeginScoringSequence();

            //リズムシーケンス描画開始.
            this.onPlayGUI.BeginVisualization();
            this.onPlayGUI.isDevelopmentMode = true;

            //developモード専用GUIシーケンス描画開始.
            GameObject.Find("DevelopmentModeGUI").GetComponent <DevelopmentModeGUI>().BeginVisualization();
            //演奏開始
            m_musicManager.PlayMusicFromStart();
        }
        break;

        case "GameOver":
        {
            DeactiveateAllGUI();
            this.showResultGUI.gameObject.SetActive(true);

            //スコア依存のメッセージを表示.
            //Debug.Log( m_scoringManager.scoreRate );
            //Debug.Log(ScoringManager.failureScoreRate);

            ShowResultGUI.RESULT result = ShowResultGUI.RESULT.GOOD;

            if (m_scoringManager.scoreRate <= ScoringManager.failureScoreRate)
            {
                result = ShowResultGUI.RESULT.BAD;
                GameObject.Find("Vocalist").GetComponent <BandMember>().BadFeedback();
            }
            else if (m_scoringManager.scoreRate >= ScoringManager.excellentScoreRate)
            {
                result = ShowResultGUI.RESULT.EXCELLENT;
                GameObject.Find("Vocalist").GetComponent <BandMember>().GoodFeedback();
                GameObject.Find("AudienceVoice").GetComponent <AudioSource>().Play();
            }
            else
            {
                result = ShowResultGUI.RESULT.GOOD;
                GameObject.Find("Vocalist").GetComponent <BandMember>().GoodFeedback();
            }

            this.showResultGUI.BeginVisualization(result);
        }
        break;

        case "Restart":
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
        }
        break;

        default:
        {
            Debug.LogError("unknown phase: " + nextPhase);
        }
        break;
        }         // end of switch

        m_currentPhase = nextPhase;
    }
Example #10
0
 void Start()
 {
     SongInfoLoader.CurrentCodePage = 932; // Hardcoded to Shift-JIS as most of BMS are encoded by this.
     SongInfoLoader.ReloadDirectory();
     InternalHideOptions();
 }