Beispiel #1
0
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            base.LoadContent();

            _defaultSong          = new SongDataPlus();
            _defaultSong.type     = SongDataPlus.NoteType.GBA;
            _defaultSong.dirPath  = "";// TITLE_LOCATION;
            _defaultSong.songData = new SongData();
            _defaultSong.songData.info.filename = "Default";

            String aviPath = Path.Combine(/*TITLE_LOCATION,*/ "Intro.avi");

            try
            {                      /*
                                    * introVideo = new Microsoft.Xna.Framework.Media.VideoPlayer(aviPath, GraphicsDevice);
                                    * introVideo.OnVideoComplete += new EventHandler(MovieFinished);
                                    * introVideo.Play();
                                    * ChangeState(GameStateType.IntroMovie);*/
                introVideo = null; // 4.0change
            }
            catch (Exception)
            {
                introVideo = null;
            }
        }
Beispiel #2
0
        public static SongDataPlus GetMidiSongDataPlus(DirectoryInfo dir, FileInfo fl, bool isFromGuitarHero)
        {
            SongDataPlus dataPlus = new SongDataPlus();

            // TODO: Add midi specific information here.
            dataPlus.songData               = new SongData();
            dataPlus.songData.info.name     = fl.Name.Split('.')[0];
            dataPlus.songData.info.artist   = "Unknown";
            dataPlus.songData.info.filename = dataPlus.songData.info.name;
            dataPlus.fullPath               = fl.FullName;
            dataPlus.type    = isFromGuitarHero ? SongDataPlus.NoteType.MID : SongDataPlus.NoteType.GenMID;
            dataPlus.dirPath = dir.ToString();

            return(dataPlus);
        }
Beispiel #3
0
        /// <summary>
        /// Searches all known song formats and determines if the music
        /// exists in any of the following formats.
        /// </summary>
        public bool QueueSong(SongDataPlus songToQueue)
        {
            if (musicPlayer != null)
            {
                musicPlayer.StopAll();
            }
            _songPlaying = false;

            if (songToQueue.type == SongDataPlus.NoteType.None)
            {
                return(false);
            }

            bool foundValidPlayer = false;

            for (int i = 0; i < availablePlayers.Count; i++)
            {
                musicPlayer = availablePlayers[i];

                foundValidPlayer = musicPlayer.LoadSong(songToQueue.dirPath, songToQueue.songData.info.filename);
                if (foundValidPlayer)
                {
                    break;
                }
            }

            if (!foundValidPlayer)
            {
                return(false);
            }

            // Can possibly have 5 extra tracks playing...?
            // For now they must use the same player they used for the main song.
            for (int t = 1; t <= 5; t++)
            {
                musicPlayer.LoadTrack(songToQueue.dirPath, songToQueue.songData.info.filename + "_tr" + t);
            }

            return(true);
        }
Beispiel #4
0
        public static Setlist SearchDirectory(DirectoryInfo dir)
        {
            List <SongDataPlus> list = new List <SongDataPlus>();

            foreach (FileInfo fl in dir.GetFiles("*.gba"))
            {
                SongDataPlus dataPlus = new SongDataPlus();
                dataPlus.fullPath = fl.FullName;
                dataPlus.songData = SongDataIO.SongLoader.LoadSong(dataPlus.fullPath);
                dataPlus.dirPath  = dir.ToString();
                dataPlus.type     = SongDataPlus.NoteType.GBA;
                list.Add(dataPlus);
            }
            foreach (FileInfo fl in dir.GetFiles("*.mid"))
            {
                // .mid files are considered to be Notes.mid files from commercial games, not general Midis
                //if(fl.Name.Contains("if"))

                list.Add(GetMidiSongDataPlus(dir, fl, true));
            }

            foreach (FileInfo fl in dir.GetFiles("*.fff"))
            {
                foreach (FileInfo fl2 in dir.GetFiles("*.ffm"))
                {
                    // Only add .fff files if there is a corresponding .ffm file
                    if (fl2.FullName.Substring(0, fl2.FullName.Length - 4).CompareTo(fl.FullName.Substring(0, fl.FullName.Length - 4)) == 0)
                    {
                        list.Add(GetMidiSongDataPlus(dir, fl, false));
                        break;
                    }
                }
            }

            Setlist s = new Setlist(list, dir.Name);

            return(s);
        }
Beispiel #5
0
        public static SongDataPlus PickRandomSong()
        {
            IAsyncResult result;

            result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);

            // wait in result...
            StorageDevice device = StorageDevice.EndShowSelector(result);

            StorageContainer container = Setlist.OpenContainer(device, "Fortissimo");
            String           directory = Path.Combine(/*TITLE_LOCATION,*/ "Songs");


            List <SongDataPlus> list = new List <SongDataPlus>();
            DirectoryInfo       dr   = new DirectoryInfo(directory);

            if (dr.Exists)
            {
                list.AddRange(SearchDirectory(dr).Songs);
                //list.Add(SearchDirectory(dr));
                foreach (DirectoryInfo dir in dr.GetDirectories())
                {
                    list.AddRange(SearchDirectory(dir).Songs);
                }
            }
            if (list.Count != 0)
            {
                Random r   = new Random();
                int    idx = r.Next(list.Count);
                return(list[idx]);
            }
            else
            {
                SongDataPlus nullSong = new SongDataPlus();
                nullSong.type = SongDataPlus.NoteType.None;
                return(nullSong);
            }
        }
Beispiel #6
0
        public virtual void StartSong(RhythmGame game, GameTime gameTime, SongDataPlus dataPlus, int instrument, float difficulty)
        {
            // Get the input skin for the given instrument
            InputSkin inputSkin = new GuitarASDFG(game.ActiveInput, game);

            game.ActiveInput.UpdateOrder = 0;
            DrawOrder = 3;
            game.Components.Add(inputSkin);
            inputSkin.ReplaceBackground(Path.Combine(dataPlus.dirPath, "Default.png"));

            // Get the notes for the given song.
            NoteManager notes = null;

            switch (dataPlus.type)
            {
            case SongDataPlus.NoteType.MID:
                notes = new GuitarHeroManager(game, this, instrument, difficulty < 0.25 ? 0 : difficulty < 0.5 ? 1 : difficulty < 0.75 ? 2 : difficulty < 0.95 ? 3 : 4, dataPlus);
                break;

            case SongDataPlus.NoteType.GBA:
                notes = new UnsignedManager(game, this, (byte)(difficulty < 0.25 ? 0 : difficulty < 0.5 ? 1 : difficulty < 0.75 ? 2 : 3), dataPlus.songData);
                break;

            case SongDataPlus.NoteType.GenMID:
                notes = new MidiManager(game, this, instrument, difficulty, dataPlus.fullPath);
                break;

            default:
                throw new NotSupportedException();
            }
            notes.UpdateOrder = 1;
            game.Components.Add(notes);
            Notes = notes;
            notes.StartSong(gameTime);
            Input = game.ActiveInput;

            game.Components.Add(this);
        }
Beispiel #7
0
        /// <summary>
        /// All state changes go through this function.
        /// </summary>
        public void ChangeState(GameStateType state)
        {
            // Transition to a NoneState?!  No way!
            if (state == GameStateType.None)
            {
                return;
            }

            // Store off old state.
            if (IsStorableState(State, state))
            {
                StoreState();
            }

            lastState = State;
            State     = state;

            if (lastState != state)
            {
                stateChanged = true;
            }

            if (!stateChanged)
            {
                return;
            }

            if (!IsBackgroundMusicState(state) && IsBackgroundMusicState(lastState))
            {
                StopAllSongs();
            }

            // Pause is a unique state.
            if (state == GameStateType.Paused && lastState != GameStateType.Paused)
            {
                PauseGame(true);
                return;
            }

            if (lastState == GameStateType.Paused)
            {
                CancelMenu();
                if (state == GameStateType.Running)
                {
                    PauseGame(false);
                    return;
                }
            }

            if (state == GameStateType.SongRestart)
            {
                musicPlayer.StopAll();
                QueueSong(_currentSong);
                List <Player> members = CurrentBand.BandMembers;
                foreach (Player p in members)
                {
                    p.Notes.Reset();
                }
                ChangeState(GameStateType.Running);
                return;
            }

            // Clear out residue from last state.
            ResetComponents();


            // Temporarily skip band members
            if (State == GameStateType.MembersSelect)
            {
                state = State = GameStateType.CareerSelect;
            }

            if (ShouldSaveBand(state))
            {
                if (state == GameStateType.SongSuccess)
                {
                    Band tmp = CurrentBand;
                    _currentBand.ScoreSong(_currentSong.songData.info.name, _currentBand.CurrentScore, _currentBand.Stars);
                }
                Band.SaveBandToFile(_currentBand);
            }

            bool changeToMenu = false;
            Menu newMenu      = null;

            // Initialize our next state.
            switch (state)
            {
            case GameStateType.TitleScreen:
                newMenu      = new TitleScreen(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.CareerSelect:
                newMenu      = new CareerSelect(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.MembersSelect:
                changeToMenu = true;
                break;

            case GameStateType.BandSelect:
                newMenu      = new BandSelect(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.SongSelect:
                // Stupid hack to get a player readied for rpg stuffs
                if (CurrentBand.BandMembers.Count == 0)
                {
                    PlayerFactory.TestPlayer(null, this);
                }

                newMenu      = new SongSelect(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.BuySong:
                newMenu      = new BuySongWarning(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.Credits:
                newMenu      = new CreditsScreen(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.DifficultySelect:
                newMenu      = new DifficultySelect(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.Running:
                menu = null;
                float realDifficulty = (Difficulty == 0 ? 0.2f : Difficulty == 1 ? 0.4f : Difficulty == 2 ? 0.6f : Difficulty == 3 ? 0.8f : 0.96f);

                foreach (Player p in CurrentBand.BandMembers)
                {
                    p.Reset();
                    p.StartSong(this, gameTime, _currentSong, Player.GUITAR, realDifficulty);
                    p.ChangeState += new Action <RhythmGame.GameStateType>(ChangeState);

                    if (musicPlayer != null)
                    {
                        p.NoteWasMissed += new Action <SongData.NoteSet>(musicPlayer.MissedNote);
                        p.NoteWasHit    += new Action <SongData.NoteSet>(musicPlayer.HitNote);
                    }
                }
                break;

            case GameStateType.LoadSong:
                _currentSong = songQueue.Dequeue();

                if (QueueSong(_currentSong))
                {
                    ChangeState(GameStateType.DifficultySelect);
                }
                else
                {
                    ChangeState(GameStateType.BuySong);
                }
                break;

            case GameStateType.SongFail:
                newMenu      = new SongFail(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.SongSuccess:
                newMenu      = new SongSuccess(this, menu);
                changeToMenu = true;
                break;

            case GameStateType.SongCancel:
                StopAllSongs();
                CancelMenu();
                break;
            }

            if (changeToMenu)
            {
                // Give the plugin a chance to override the menu.
                newMenu = ActivePlugin.GetPluginMenu(this, menu, newMenu);

                menu           = newMenu;
                menu.DrawOrder = 1;
                menu.Enabled   = true;
                menu.Visible   = true;
                Components.Add(menu);
            }
        }
Beispiel #8
0
 public void EnqueueSong(SongDataPlus song)
 {
     // 4.0change
     songQueue.Enqueue(song);
 }
Beispiel #9
0
        protected override void Update(GameTime gameTime)
        {
            this.gameTime = gameTime;

            switch (State)
            {
            case GameStateType.Paused:
                if (stateChanged)
                {
                    pausedTime = gameTime.TotalGameTime;
                }
                break;

            case GameStateType.Running:
                if (stateChanged && lastState == GameStateType.Paused)
                {
                    TimeSpan totalPausedTime = gameTime.TotalGameTime - pausedTime;

                    foreach (GameComponent component in Components)
                    {
                        if (component is Player)
                        {
                            ((Player)component).Notes.SyncStartTime(totalPausedTime);
                        }
                    }
                }
                break;
            }
            stateChanged = false;

            if (State == GameStateType.Running)
            {
                TimeSpan      playPosition = musicPlayer.PlayPosition() + AUDIO_VIDEO_OFFSET;
                List <Player> members      = CurrentBand.BandMembers;
                foreach (Player p in members)
                {
                    p.Notes.VerifySongTime(playPosition);
                }
            }

            if (IsBackgroundMusicState(State))
            {
                // Give the song a minute, then fade out and start a new one.
                if (_backgroundTimer < TimeSpan.FromSeconds(10))
                {
                    if (musicPlayer != null)
                    {
                        musicPlayer.FadeVolume(-(gameTime.ElapsedGameTime.Milliseconds / 10000.0));
                    }
                }

                if (_backgroundTimer < TimeSpan.Zero)
                {
                    _backgroundSong = SongSearcher.PickRandomSong();
                    StopAllSongs();
                    if (QueueSong(_backgroundSong))
                    {
                        PlayQueuedSong();
                    }
                    else
                    {
                        // Try default song.
                        if (QueueSong(_defaultSong))
                        {
                            PlayQueuedSong();
                        }
                    }
                    _backgroundTimer = TimeSpan.FromMinutes(1);
                }
                _backgroundTimer -= gameTime.ElapsedGameTime;
            }
            else
            {
                // Start it up as soon as we get to a valid state.
                _backgroundTimer = TimeSpan.Zero;
            }

            base.Update(gameTime);

            // Update after the game update to prevent the user from skipping the title screen.
            if (State == GameStateType.IntroMovie)
            {
                // Funky work around for video player.
                GraphicsDevice.Textures[0] = null;
                //introVideo.Update(); // 4.0change

                for (int i = 0; i < InputDevices.Length; i++)
                {
                    if (InputDevices[i].OtherKeyPressed(OtherKeyType.Select) ||
                        InputDevices[i].OtherKeyPressed(OtherKeyType.Cancel) ||
                        InputDevices[i].OtherKeyPressed(OtherKeyType.Select))
                    {
                        //introVideo.Stop(); // 4.0change
                        MovieFinished(null, null);
                    }
                }
            }
        }
Beispiel #10
0
        public GuitarHeroManager(Game game, Player player, int instrument, int difficulty, SongDataPlus dataPlus)
            : base(game)
        {
            this.player = player;

            int trackID = instrument == Player.GUITAR ? 0 : instrument == Player.RHYTHM ? 1 : instrument == Player.DRUMS ? 2 : instrument == Player.VOCALS ? 3 : 99;

            if (trackID == 99)
            {
                throw new System.NotSupportedException();
            }

            curMusicFile = new GuitarHeroMusicFile();
            if (!curMusicFile.GenerateNotesFromFile(dataPlus.fullPath))
            {
                throw new System.NotSupportedException();
            }

            // Check for tap-on/hammer-off notes... <200 ms since start of last note && this is the only note at this time slot
            if (curMusicFile.AllNotes[trackID][difficulty].Count > 1)
            {
                NoteX last = curMusicFile.AllNotes[trackID][difficulty][0];
                for (int i = 1; i < curMusicFile.AllNotes[trackID][difficulty].Count; i++)
                {
                    NoteX curr = curMusicFile.AllNotes[trackID][difficulty][i];
                    if (curr.type != last.type && curr.time != last.time)
                    {
                        // Make sure last note is different than this one
                        if (i > 0 && (curMusicFile.AllNotes[trackID][difficulty][i - 1].type & 0x1F) != curr.type)
                        {
                            // Check threshold
                            if (curr.time - last.time < HOPO_Threshold)
                            {
                                // Check that it's a single chord
                                if (curr.type == 1 || curr.type == 2 || curr.type == 4 || curr.type == 8 || curr.type == 16)
                                {
                                    curr.type |= (1 << 5);
                                }
                            }
                        }
                    }
                    last = curr;
                }
            }
            foreach (NoteX note in curMusicFile.AllNotes[trackID][difficulty])
            {
                note.burning = 0;
                note.endtype = 0;
                if (note.length < 150)
                {
                    note.length = 0;
                }
            }

            allBeats = curMusicFile.markers;
            _noteSet = curMusicFile.AllNotes[trackID][difficulty].ToArray();
            NoteX.InitializeSet(NoteSet, player);
        }