示例#1
0
        public static SongSelectItem SearchSong(string query)
        {
            songSelect = GameObject.FindObjectOfType <SongSelect>();
            SongSelectItem song = null;

            if (songSelect == null)
            {
                return(song);
            }

            songs = songSelect.songSelectItems.mItems;

            for (int i = 0; i < songs.Count; i++)
            {
                SongSelectItem currentSong = songs[i];

                if (currentSong.mSongData.artist.ToLower().Contains(query.ToLower()) ||
                    currentSong.mSongData.title.ToLower().Contains(query.ToLower()) ||
                    currentSong.mSongData.songID.ToLower().Contains(query.ToLower()) ||
                    currentSong.mSongData.artist.ToLower().Replace(" ", "").Contains(query.ToLower()) ||
                    currentSong.mSongData.title.ToLower().Replace(" ", "").Contains(query.ToLower()))
                {
                    song = currentSong;
                    break;
                }
            }

            return(song);
        }
示例#2
0
 private static void Prefix(SongSelect __instance, ref SongSelect.Sort newSort)
 {
     if (FilterPanel.IsFiltering("playlists"))
     {
         newSort = SongSelect.Sort.Default;
     }
 }
示例#3
0
 private static void Postfix(SongSelect __instance)
 {
     FilterPanel.Initialize();
     ScoreHistory.LoadHistory(PlatformChooser.I.GetLeaderboardID());
     MelonCoroutines.Start(SongBrowser.UpdateLastSongCount());
     MelonLogger.Msg("Updating song count");
 }
示例#4
0
        private void label1_Click(object sender, EventArgs e)
        {
            var    s  = new SongSelect();
            string id = "";

            s.Getid += (SongSelect.IdSelector)(x =>
            {
                id = x;
            });
            s.ShowDialog();
            if (id != null)
            {
                var jsonscore = NetMidiDownload.DownloadMidi(id);
                try
                {
                    KeyplayClass keyplay = JsonConvert.DeserializeObject <KeyplayClass>(jsonscore);



                    pathTextBox.Text = keyplay.Filename;
                    Log.overlayLog($"网络文件:{Path.GetFileName(midFileDiag.FileName)}");
                    radioButton2.Checked = true;

                    var bpm = keyplay.BPM;
                    var tmp = new List <string>();

                    if (keyplay.Tracks?.Length != 0)
                    {
                        for (var i = 0; i < keyplay.Tracks.Length; i++)
                        {
                            tmp.Add($"track_{i}:{keyplay.Tracks[i].name}");
                        }
                    }


                    trackComboBox.DataSource    = tmp;
                    trackComboBox.SelectedIndex = Math.Min(tmp.Count - 1, trackLock);
                    //TODO: if source midi not imported successfully will cause error
                    //TODO: Enhancement issue#14 lock track selection
                    if (bpm >= nudBpm.Maximum)
                    {
                        nudBpm.Value = nudBpm.Maximum;
                    }
                    else if (bpm <= nudBpm.Minimum)
                    {
                        nudBpm.Value = nudBpm.Minimum;
                    }
                    else
                    {
                        nudBpm.Value = bpm;
                    }
                    mtk.netmidi = keyplay;
                    netMidiFlag = true;
                }
                catch (Exception ee)
                {
                    throw ee;
                }
            }
        }
    /*WVR_InputId[] buttonIds = new WVR_InputId[]
     * {
     *  WVR_InputId.WVR_InputId_Alias1_Menu,
     *  WVR_InputId.WVR_InputId_Alias1_Grip,
     *  WVR_InputId.WVR_InputId_Alias1_DPad_Left,
     *  WVR_InputId.WVR_InputId_Alias1_DPad_Up,
     *  WVR_InputId.WVR_InputId_Alias1_DPad_Right,
     *  WVR_InputId.WVR_InputId_Alias1_DPad_Down,
     *  WVR_InputId.WVR_InputId_Alias1_Volume_Up,
     *  WVR_InputId.WVR_InputId_Alias1_Volume_Down,
     *  WVR_InputId.WVR_InputId_Alias1_Touchpad,
     *  WVR_InputId.WVR_InputId_Alias1_Trigger,
     *  WVR_InputId.WVR_InputId_Alias1_Digital_Trigger,
     *  WVR_InputId.WVR_InputId_Alias1_System
     * };
     *
     * WVR_InputId[] axisIds = new WVR_InputId[] {
     *  WVR_InputId.WVR_InputId_Alias1_Touchpad,
     *  WVR_InputId.WVR_InputId_Alias1_Trigger
     * };*/

    private void Awake()
    {
        audio          = GetComponent <AudioSource>();
        sel            = GetComponent <SongSelect>();
        prevCount      = danceLights.Length;
        lightsCounter  = 0;
        danceSet[0]    = "isRevR";
        danceSet[1]    = "isRevL";
        danceSet[2]    = "isPointR";
        danceSet[3]    = "isPointL";
        Player         = GameObject.Find("Player").transform;
        Opponent       = GameObject.Find("Dance King").transform;
        oppTarget      = GameObject.Find("opponentPlace").transform;
        danceLights[0] = GameObject.Find("purpLight").GetComponent <Light>();
        danceLights[1] = GameObject.Find("greenLight").GetComponent <Light>();
        danceLights[2] = GameObject.Find("blueLight").GetComponent <Light>();
        animator       = GameObject.Find("Player").GetComponent <Animator>();
        dkAnim         = GameObject.Find("Dance King").GetComponent <Animator>();
        tracker        = GameObject.Find("Player").GetComponent <AudioSource>();
        pm             = GameObject.Find("Player").GetComponent <PlayerMovement>();
        gm             = GameObject.Find("Manager").GetComponent <GameManager>();
        ui             = GameObject.Find("Manager").GetComponent <UIManager2>();
        log            = gm.log;
        plot           = gm.plot;
    }
示例#6
0
 private static void Postfix(SongSelect __instance)
 {
     //FilterPanel.filteringFavorites = false;
     FilterPanel.Initialize();
     ScoreHistory.LoadHistory(PlatformChooser.I.GetLeaderboardID());
     MelonCoroutines.Start(SongBrowser.UpdateLastSongCount());
 }
示例#7
0
        private static IEnumerator IStartEndlessSession()
        {
            MenuState.I.GoToSongPage();
            ResetIndex();
            SongSelect select = null;

            while (select is null)
            {
                select = GameObject.FindObjectOfType <SongSelect>();
                yield return(new WaitForSecondsRealtime(0.2f));
            }
            if (!CanPlay(select))
            {
                PlaylistManager.state = PlaylistManager.PlaylistState.None;
                yield break;
            }

            previousNoFail = PlayerPreferences.I.NoFail.mVal;
            PlayerPreferences.I.NoFail.mVal = Config.NoFail;
            pendingReset = true;
            if (Config.Shuffle)
            {
                songs.Shuffle();
            }

            SetNextSong();
            MelonCoroutines.Start(ILaunch());
            yield return(null);
        }
示例#8
0
    void Start()
    {
        SongStarted = false;
        SS          = FindObjectOfType <SongSelect>();
        song        = SS.Selectedsong;

        hit1           = GameObject.FindGameObjectWithTag("p1");
        hit2           = GameObject.FindGameObjectWithTag("p2");
        hit3           = GameObject.FindGameObjectWithTag("p3");
        SpritePosition = GameObject.FindGameObjectWithTag("Sprite");

        rhythmtool = GetComponent <RhythmTool>();
        REP        = GetComponent <RhythmEventProvider>();

        rhythmtool.NewSong(song);
        rhythmtool.SongLoaded += OnSongLoaded;

        REP.onSubBeat.AddListener(OnSubBeat);

        combo = 0;
        score = 0;

        LHeld = false;
        MHeld = false;
        RHeld = false;

        TotalFrames = rhythmtool.totalFrames;
    }
示例#9
0
        public static void SelectRandomSong()
        {
            SongSelect select = GameObject.FindObjectOfType <SongSelect>();

            if (select == null)
            {
                return;
            }
            List <SongSelectItem> songs = select.GetSongButtons();

            if (songs.Count == 0)
            {
                return;
            }

            int songCount = songs.Count;

            System.Random rand = new System.Random();
            int           idx  = rand.Next(0, songCount);

            SongList.SongData data = songs[idx].mSongData;
            if (data != null)
            {
                SongDataHolder.I.songData = data;
                MenuState.I.GoToLaunchPage();
            }
        }
示例#10
0
 void Start()
 {
     ss = FindObjectOfType <SongSelect>();
     StartCoroutine(flashobject());
     GetComponent <AudioSource>().clip = Globals.SongList[(int)Mathf.Floor(Random.Range(0, Globals.SongList.Count - 1))];
     GetComponent <AudioSource>().Play();
     ss.gameObject.SetActive(false);
 }
示例#11
0
            private static bool Prefix(SongSelect __instance, string response)

            {
                if (MenuState.GetState() == MenuState.State.Launched)
                {
                    return(false);
                }
                return(true);
            }
示例#12
0
文件: Form1.cs 项目: n9ds/HID
 private void OpenSongsDialog(object sender, EventArgs e)
 {
     if (SongSelectDlg == null || SongSelectDlg.IsDisposed)
     {
         SongSelectDlg = new SongSelect();
         SongSelectDlg.SongSelected += new EventHandler <SongSelectedEventArgs>(Dlg_SongSelected);
     }
     SongSelectDlg.Show();
 }
示例#13
0
        private void load(SongSelect songSelect)
        {
            if (songSelect != null)
            {
                startRequested = b => songSelect.FinaliseSelection(b);
                editRequested  = songSelect.Edit;
            }

            Children = new Drawable[]
示例#14
0
    void Start()
    {
        currentSong = GetComponent <AudioSource> ();

        SongSelect songSelect = FindObjectOfType <SongSelect> ();

        currentSong.clip = songSelect.songs [0].clip;

        DontDestroyOnLoad(this.gameObject);
    }
示例#15
0
 private static void Postfix(SongSelect __instance, ref bool extras, ref Il2CppSystem.Collections.Generic.List <string> __result)
 {
     FilterPanel.ApplyFilter(__instance, ref extras, ref __result);
     if (SongBrowser.deletedSongs.Count > 0)
     {
         foreach (var deletedSong in SongBrowser.deletedSongs)
         {
             __result.Remove(deletedSong);
         }
     }
 }
示例#16
0
            private static void Postfix(SongSelect __instance, ref bool extras, ref Il2CppSystem.Collections.Generic.List <string> __result)
            {
                if (!SongRequests.hasCompatibleSongBrowser && RequestUI.requestFilterActive)
                {
                    extras = true;
                    __result.Clear();
                    __instance.songSelectHeaderItems.mItems[0].titleLabel.text = "Song Requests";

                    foreach (string songID in SongRequests.requestList)
                    {
                        __result.Add(songID);
                    }
                    __instance.scroller.SnapTo(0);
                }
            }
示例#17
0
文件: Form1.cs 项目: n9ds/HID
 private void Dlg_LibrarySelected(object sender, LibrarySelectedEventArgs e)
 {
     // TODO: Show (but not edit) an existing library
     if (SongSelectDlg == null || SongSelectDlg.IsDisposed)
     {
         SongSelectDlg = new SongSelect(e.LibraryId);
         SongSelectDlg.SongSelected += new EventHandler <SongSelectedEventArgs>(Dlg_SongSelected);
     }
     else
     {
         SongSelectDlg.LibraryId = e.LibraryId;
         SongSelectDlg.LoadSongList();
     }
     SongSelectDlg.Show();
 }
示例#18
0
            private static void Postfix(SongSelect __instance, bool extras, ref Il2CppSystem.Collections.Generic.List <string> __result)
            {
                if (AudicaMod.requestFilterActive)
                {
                    __result.Clear();
                    __instance.songSelectHeaderItems.mItems[0].titleLabel.text = "Song Requests";

                    if (extras)
                    {
                        foreach (string songID in AudicaMod.requestList)
                        {
                            __result.Add(songID);
                        }
                    }
                }
            }
示例#19
0
 internal static void ApplyFilter(SongSelect __instance, ref bool extras, ref Il2CppSystem.Collections.Generic.List <string> __result)
 {
     foreach (Filter filter in filters.Values)
     {
         if (filter.IsActive)
         {
             extras = true;
             if (filter.Apply(__result))
             {
                 __instance.songSelectHeaderItems.mItems[0].titleLabel.text = filter.SongListText;
             }
             UpdateScrollPosition(__instance.scroller);
             break; // only can have one active at a time
         }
     }
 }
示例#20
0
        protected void ReloadEditorToSameBeatmap()
        {
            AddStep("Exit", () => InputManager.Key(Key.Escape));

            AddUntilStep("Wait for main menu", () => Game.ScreenStack.CurrentScreen is MainMenu);

            SongSelect songSelect = null;

            PushAndConfirm(() => songSelect = new PlaySongSelect());
            AddUntilStep("wait for carousel load", () => songSelect.BeatmapSetsLoaded);

            AddUntilStep("Wait for beatmap selected", () => !Game.Beatmap.IsDefault);
            AddStep("Open options", () => InputManager.Key(Key.F3));
            AddStep("Enter editor", () => InputManager.Key(Key.Number5));

            AddUntilStep("Wait for editor load", () => Editor != null);
        }
示例#21
0
 private static bool CanPlay(SongSelect select)
 {
     if (select is null)
     {
         MelonLogger.Warning("SongSelect not found");
         return(false);
     }
     songs = new Il2CppSystem.Collections.Generic.List <SongSelectItem>();
     songs = select.GetSongButtons();
     songs.RemoveAt(0);
     if (songs.Count == 0)
     {
         MelonLogger.Warning("No songs in playlist");
         return(false);
     }
     return(true);
 }
        public static void Initialize()
        {
            if (songListControls == null)
            {
                songSelect       = GameObject.FindObjectOfType <SongSelect>();
                songListControls = GameObject.FindObjectOfType <SongListControls>();

                if (!SongRequests.hasCompatibleSongBrowser) // song browser integration does this automatically
                {
                    CreateSongRequestFilterButton();

                    // move that button down, since the download button doesn't exist
                    skipButtonPos   = downloadButtonPos;
                    skipButtonScale = downloadButtonScale;
                }
                CreateSongRequestSkipButton();
                CreateDownloadMissingButton();
            }
        }
示例#23
0
文件: Form1.cs 项目: n9ds/HID
        //        public event EventHandler<SongSelectedEventArgs> SongSelected;
        // TODO: Support for multiple devices?

        public Form1()
        {
            InitializeComponent();
            SongLibrary       = new SongLibrary();
            SongSelectDlg     = null;
            SetlistSelectDlg  = null;
            LibrarySelectDlg  = null;
            FootPedalMonitor  = new HIDMonitor();
            deviceConfigParms = new DeviceConfigParms();
            if (String.IsNullOrEmpty(Properties.Settings.Default.ConfigFile))
            {
                Properties.Settings.Default.ConfigFile = "DeviceConfig.xml";
            }
            if (String.IsNullOrEmpty(Properties.Settings.Default.DeviceName))
            {
                Properties.Settings.Default.DeviceName = "xxUSB NETVISTA FULL WIDTH KEYBOARD";
            }
            deviceConfigParms.ConfigFile = Properties.Settings.Default.ConfigFile;
            deviceConfigParms.DeviceName = Properties.Settings.Default.DeviceName;
            InitializeDevice(deviceConfigParms);
            FootPedalMonitor.OnHidDeviceRead += this.HidDeviceRead;
        }
示例#24
0
        public static void ReloadSongList()
        {
            needRefresh                     = false;
            SongList.sFirstTime             = true;
            SongList.OnSongListLoaded.mDone = false;
            SongList.SongSourceDirs         = new Il2CppSystem.Collections.Generic.List <SongList.SongSourceDir>();
            SongList.AddSongSearchDir(Application.dataPath, downloadsDirectory);
            SongList.I.StartAssembleSongList();
            SongSelect songSelect = GameObject.FindObjectOfType <SongSelect>();

            if (songSelect != null)
            {
                SongList.OnSongListLoaded.On(new Action(() => { songSelect.ShowSongList(); }));
            }

            if (songDataLoaderInstalled)
            {
                SongList.OnSongListLoaded.On(new Action(() => { SafeDataLoaderReload(); }));
            }

            DebugText("Reloading Songs");
        }
示例#25
0
        internal static void Initialize()
        {
            if (songListControls == null)
            {
                songSelect       = GameObject.FindObjectOfType <SongSelect>();
                songListControls = GameObject.FindObjectOfType <SongListControls>();
                GetReferences();

                foreach (string filterKey in filters.Keys)
                {
                    PrepareFilterButton(filters[filterKey]);
                }

                SetFilterUIGeometry();

                extrasButton.GetComponentInChildren <GunButton>().onHitEvent.AddListener(new Action(() =>
                {
                    DisableCustomFilters();
                    songSelect.ShowSongList();
                }));
            }
        }
示例#26
0
 private static void Postfix(SongSelect __instance, ref bool extras, ref Il2CppSystem.Collections.Generic.List <string> __result)
 {
     if (FilterPanel.filteringFavorites)
     {
         extras = true;
         if (FilterPanel.favorites != null)
         {
             __result.Clear();
             for (int i = 0; i < FilterPanel.favorites.songIDs.Count; i++)
             {
                 __result.Add(FilterPanel.favorites.songIDs[i]);
             }
         }
         __instance.scroller.SnapTo(0, true);
     }
     if (SongBrowser.deletedSongs.Count > 0)
     {
         foreach (var deletedSong in SongBrowser.deletedSongs)
         {
             __result.Remove(deletedSong);
         }
     }
 }
示例#27
0
        private void load(BeatmapManager manager, SongSelect songSelect)
        {
            Header.Height = height;

            if (songSelect != null)
            {
                startRequested = b => songSelect.FinaliseSelection(b);
                if (songSelect.AllowEditing)
                {
                    editRequested = songSelect.Edit;
                }
            }

            if (manager != null)
            {
                hideRequested = manager.Hide;
            }

            Header.Children = new Drawable[]
            {
                background = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                },
                triangles = new Triangles
                {
                    TriangleScale    = 2,
                    RelativeSizeAxes = Axes.Both,
                    ColourLight      = Color4Extensions.FromHex(@"3a7285"),
                    ColourDark       = Color4Extensions.FromHex(@"123744")
                },
                new FillFlowContainer
                {
                    Padding      = new MarginPadding(5),
                    Direction    = FillDirection.Horizontal,
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.CentreLeft,
                    Origin       = Anchor.CentreLeft,
                    Children     = new Drawable[]
                    {
                        new DifficultyIcon(beatmapInfo, shouldShowTooltip: false)
                        {
                            Scale = new Vector2(1.8f),
                        },
                        new FillFlowContainer
                        {
                            Padding = new MarginPadding {
                                Left = 5
                            },
                            Direction    = FillDirection.Vertical,
                            AutoSizeAxes = Axes.Both,
                            Children     = new Drawable[]
                            {
                                new FillFlowContainer
                                {
                                    Direction    = FillDirection.Horizontal,
                                    Spacing      = new Vector2(4, 0),
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new[]
                                    {
                                        new OsuSpriteText
                                        {
                                            Text   = beatmapInfo.Version,
                                            Font   = OsuFont.GetFont(size: 20),
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft
                                        },
                                        new OsuSpriteText
                                        {
                                            Text   = "mapped by",
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft
                                        },
                                        new OsuSpriteText
                                        {
                                            Text   = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author.Username}",
                                            Font   = OsuFont.GetFont(italics: true),
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft
                                        },
                                    }
                                },
                                new FillFlowContainer
                                {
                                    Direction    = FillDirection.Horizontal,
                                    Spacing      = new Vector2(4, 0),
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new TopLocalRank(beatmapInfo)
                                        {
                                            Scale = new Vector2(0.8f),
                                            Size  = new Vector2(40, 20)
                                        },
                                        starCounter = new StarCounter
                                        {
                                            Scale = new Vector2(0.8f),
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
        }
示例#28
0
        private void load(SongSelect songSelect, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
        {
            this.beatmapOverlay = beatmapOverlay;

            if (songSelect != null)
            {
                startRequested = b => songSelect.FinaliseSelection(b);
                editRequested  = songSelect.Edit;
            }

            if (manager != null)
            {
                hideRequested = manager.Hide;
            }

            Children = new Drawable[]
            {
                background = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                },
                triangles = new Triangles
                {
                    TriangleScale    = 2,
                    RelativeSizeAxes = Axes.Both,
                    ColourLight      = OsuColour.FromHex(@"3a7285"),
                    ColourDark       = OsuColour.FromHex(@"123744")
                },
                new FillFlowContainer
                {
                    Padding      = new MarginPadding(5),
                    Direction    = FillDirection.Horizontal,
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.CentreLeft,
                    Origin       = Anchor.CentreLeft,
                    Children     = new Drawable[]
                    {
                        new DifficultyIcon(beatmap)
                        {
                            Scale = new Vector2(1.8f),
                        },
                        new FillFlowContainer
                        {
                            Padding = new MarginPadding {
                                Left = 5
                            },
                            Direction    = FillDirection.Vertical,
                            AutoSizeAxes = Axes.Both,
                            Children     = new Drawable[]
                            {
                                new FillFlowContainer
                                {
                                    Direction    = FillDirection.Horizontal,
                                    Spacing      = new Vector2(4, 0),
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new[]
                                    {
                                        new OsuSpriteText
                                        {
                                            Font     = @"Exo2.0-Medium",
                                            Text     = beatmap.Version,
                                            TextSize = 20,
                                            Anchor   = Anchor.BottomLeft,
                                            Origin   = Anchor.BottomLeft
                                        },
                                        new OsuSpriteText
                                        {
                                            Font     = @"Exo2.0-Medium",
                                            Text     = "mapped by",
                                            TextSize = 16,
                                            Anchor   = Anchor.BottomLeft,
                                            Origin   = Anchor.BottomLeft
                                        },
                                        new OsuSpriteText
                                        {
                                            Font     = @"Exo2.0-MediumItalic",
                                            Text     = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author.Username}",
                                            TextSize = 16,
                                            Anchor   = Anchor.BottomLeft,
                                            Origin   = Anchor.BottomLeft
                                        },
                                    }
                                },
                                starCounter = new StarCounter
                                {
                                    CountStars = (float)beatmap.StarDifficulty,
                                    Scale      = new Vector2(0.8f),
                                }
                            }
                        }
                    }
                }
            };
        }
示例#29
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);
            }
        }
示例#30
0
        private static void GetRandomSong()
        {
            songSelect = GameObject.FindObjectOfType <SongSelect>();
            songs      = songSelect.songSelectItems.mItems;
            int maxLength = songs.Count - 1;

            if (!availableSongListsSetup)
            {
                availableSongListsSetup = true;

                for (int i = 0; i < mainSongCount; i++)
                {
                    availableMainSongs.Add(i);
                }

                for (int i = mainSongCount; i < maxLength; i++)
                {
                    availableExtrasSongs.Add(i);
                }

                for (int i = 0; i < maxLength; i++)
                {
                    availableSongs.Add(i);
                }
            }
            SongSelect.Filter filter = songSelect.GetListFilter();

            var rand = new System.Random();
            int index;

            if (filter == SongSelect.Filter.All)
            {
                index = availableSongs[rand.Next(0, availableSongs.Count - 1)];
            }
            else if (filter == SongSelect.Filter.Main)
            {
                index = availableMainSongs[rand.Next(0, availableMainSongs.Count - 1)];
                if (availableMainSongs.Count > 0)
                {
                    availableMainSongs.Remove(index);
                }
            }
            else
            {
                index = availableExtrasSongs[rand.Next(0, availableExtrasSongs.Count - 1)];
                if (availableExtrasSongs.Count > 0)
                {
                    availableExtrasSongs.Remove(index);
                }
            }
            songs[index].OnSelect();
            lastPickedSongs.Add(index);
            if (availableSongs.Count > 0)
            {
                availableSongs.Remove(index);
            }


            if (lastPickedSongs.Count > randomSongBagSize)
            {
                int oldestIndex = lastPickedSongs[0];
                lastPickedSongs.Remove(oldestIndex);
                availableSongs.Add(oldestIndex);
                if (oldestIndex < 33)
                {
                    availableMainSongs.Add(index);
                }
                else
                {
                    availableExtrasSongs.Add(index);
                }
            }
        }