コード例 #1
0
        public void SetLevelData(LevelDataModel dat)
        {
            currentLevelData = dat;
            ticksPerTile     = dat.songData.tickPerTile;
            denominator      = dat.denominator;
            //tickPerWholeNote = dat.tickPerQuarterNote * 4;
            speedModifier = dat.songData.speedModifier;

            minTickPerTile = Mathf.FloorToInt(ticksPerTile * (1 - tickTolerance));
            maxTickPerTile = Mathf.CeilToInt(ticksPerTile * (1 + tickTolerance));
        }
コード例 #2
0
 //public void GetLevelData(SongDataModel songData) {
 //        DownLoadAndCacheSongData(songData);
 //}
 public void DownLoadAndCacheSongData(SongDataModel songData)
 {
     m_levelData          = new LevelDataModel();
     m_levelData.songData = songData;
     AssetDownloader.Instance.DownloadAndCacheAsset(m_levelData.songData.songURL,
                                                    m_levelData.songData.version,
                                                    OnProgressChanged,
                                                    OnError,
                                                    OnLevelDownloadCompleted
                                                    );
 }
コード例 #3
0
        /// <summary>
        /// Prepare data and fire up the main game's UI
        /// </summary>
        private void LoadLevel()
        {
            levelData = GameManager.Instance.SessionData.currentLevel;

            //only try to load game if the level to load is different from cached, or there is no level being loaded
            if (gamelogic.CachedLevelData == null || !gamelogic.CachedLevelData.songData.name.Equals(levelData.songData.name))
            {
                Timing.RunCoroutine(C_StartGame());
            }
            else
            {
                StartNewGame();
            }
        }
コード例 #4
0
        //SONG PARSED NOTE AND SORTING
        private void OnSongParsed(bool isSucceed, LevelDataModel levelData)
        {
            if (isSucceed)
            {
                this.levelData.playbackData = levelData.playbackData;
                //sort playback data by time appear
                this.levelData.playbackData.Sort((x, y) => (x.timeAppear.CompareTo(y.timeAppear)));

                this.levelData.noteData = levelData.noteData;
                //sort note data by time appear
                this.levelData.noteData.Sort((x, y) => (x.timeAppear.CompareTo(y.timeAppear)));

                this.levelData.BPM = levelData.BPM;
                this.levelData.tickPerQuarterNote = levelData.tickPerQuarterNote;

                this.levelData.denominator = levelData.denominator;

                //cache level
                GameManager.Instance.SessionData.currentLevel = this.levelData;
                gamelogic.Initialize();
                gamelogic.SetLevelData(this.levelData);
                ChangeState(UIState.ParsingLevelData);

                gamelogic.PrepareTileData(
                    //on progressing
                    (progress) => {
                    progressbar.value = progress;
                },

                    //on complete
                    () => {
                    progressbar.value = 1;
                    StartNewGame();
                },

                    //on Error
                    (errorMessage) => {
                    Debug.LogError("Error trying to parse song data: " + errorMessage);
                    lbMessage.text = Localization.Get("er_parse_song_failed");
                    ChangeState(UIState.ParseError);
                }
                    );
            }
        }
コード例 #5
0
 public void ReplayLastSong()
 {
     //print("Calling replay");
     if (GameManager.Instance.SessionData.lastLevel != null)
     {
         GameManager.Instance.SessionData.currentLevel = GameManager.Instance.SessionData.lastLevel;
         AnalyticsHelper.Instance.LogClickItem("Replay last song");
         SceneManager.Instance.OpenScene(ProjectConstants.Scenes.MainGame);
     }
     else
     {
         if (itemLastPlay.Model != null)
         {
             LevelDataModel level = new LevelDataModel();
             level.songData = itemLastPlay.Model;
             GameManager.Instance.SessionData.currentLevel = level;
             SceneManager.Instance.OpenScene(ProjectConstants.Scenes.MainGame);
         }
     }
 }
コード例 #6
0
 private void OnSongItemClicked(SongDataModel songitem)
 {
     if (LivesManager.Instance.CanPlaySong())
     {
         //this.Print("Clicked on song item: " + obj.name + " should process song item clicked = " + ShouldProcessSongItemClick);
         if (ShouldProcessSongItemClick)
         {
             ShouldProcessSongItemClick = false;
             LevelDataModel level = new LevelDataModel();
             level.songData = songitem;
             GameManager.Instance.SessionData.currentLevel = level;
             AnalyticsHelper.Instance.LogClickItem("Play song in HOME");
             SceneManager.Instance.OpenScene(ProjectConstants.Scenes.MainGame);
         }
     }
     else
     {
         LivesManager.Instance.SuggestRechargeLives();
     }
 }
コード例 #7
0
ファイル: SongListView.cs プロジェクト: LuanNg/PianoTiles
        private void OnSongItemClicked(SongDataModel obj)
        {
            Debug.Log("<color=red>OnSongItemClicked " + obj.name + "</color>");

            //check if user has enough lives to continue?
            if (LivesManager.Instance.CanPlaySong())
            {
                //this.Print("Clicked on song item: " + obj.name + " should process song item clicked = " + ShouldProcessSongItemClick);
                if (ShouldProcessSongItemClick)
                {
                    ShouldProcessSongItemClick = false;
                    LevelDataModel level = new LevelDataModel();
                    level.songData = obj;
                    GameManager.Instance.SessionData.currentLevel = level;
                    SceneManager.Instance.OpenScene(ProjectConstants.Scenes.MainGame);
                }
            }
            else
            {
                LivesManager.Instance.SuggestRechargeLives();
            }
        }