Ejemplo n.º 1
0
        public void RemoveBeatPlane(Objects.BeatPlane planeToDelete)
        {
            foreach (Objects.Note n in planeToDelete.ContainedNotes)
            {
                if (!n.Hit && !n.Bad)
                {
                    //Miss a good note
                    Health -= 1;
                    if (Health <= 0)
                    {
                        //FAILURE
                        MediaPlayer.Stop();
                        SetState(eGameState.MainMenu);
                    }
                    Combo  = 0;
                    n.Miss = true;
                    MissCount++;
                    if (MissCount == 3)
                    {
                        Multiplier = MultMult;
                    }
                    TotalNotes++;
                }
            }

            while (planeToDelete.ContainedNotes.Count > 0)
            {
                RemoveGameObject(planeToDelete.ContainedNotes[0]);
                planeToDelete.ContainedNotes.RemoveAt(0);
            }
            m_BeatPlanes.Remove(planeToDelete);
            RemoveGameObject(planeToDelete);
        }
Ejemplo n.º 2
0
        void createTestBeatPlanes()
        {
            m_BeatPlanes.Clear();
            m_Notes.Clear();
            m_CurrentBeat = 0f;

            // Go through each beat in the song
            foreach (DictionaryEntry entry in m_CurrentSong.Notes)
            {
                // New beatplane
                Objects.BeatPlane newBeatPlane = new Objects.BeatPlane(m_Game, m_CurrentSong);
                // Populate the beatplane with notes
                newBeatPlane.addNotesFromSong(m_CurrentSong, (float)entry.Key);
                // Add the beatplane to the list of beatplanes for update
                m_BeatPlanes.Add(entry.Key, newBeatPlane);
                // Spawn the beatplane
                SpawnGameObject(newBeatPlane);
            }
        }
Ejemplo n.º 3
0
        void UpdateGameplay(float fDeltaTime)
        {
            if (!IsPaused)
            {
                m_Camera.Update(fDeltaTime);

                if (MediaPlayer.PlayPosition.TotalSeconds + m_CurrentSong.AppearanceTime >= m_CurrentSong.LeadIn + m_CurrentBeat * 60 / m_CurrentSong.BPM)
                {
                    m_CurrentBeat += 0.25f;


                    if (((int)(m_CurrentBeat * 4)) % 32 == 0)
                    {
                        Array  tunnelDirectionValues = Enum.GetValues(typeof(Objects.BeatPlane.TunnelDirection));
                        Random rng = new Random();
                        Objects.BeatPlane.TunnelDirection newTunnelDirection =
                            (Objects.BeatPlane.TunnelDirection)tunnelDirectionValues.GetValue(rng.Next(0, tunnelDirectionValues.Length));
                        while (newTunnelDirection == m_TunnelDirection)
                        {
                            newTunnelDirection = (Objects.BeatPlane.TunnelDirection)tunnelDirectionValues.GetValue(rng.Next(0, tunnelDirectionValues.Length));
                        }
                        m_TunnelDirection = newTunnelDirection;
                    }
                    Objects.BeatPlane beatplaneAtCurrentBeat = (Objects.BeatPlane)m_BeatPlanes[m_CurrentBeat];
                    if (beatplaneAtCurrentBeat != null && !beatplaneAtCurrentBeat.Enabled)
                    {
                        // Set it active
                        beatplaneAtCurrentBeat.SetActive(m_CurrentSong, m_TunnelDirection);
                    }
                }


                if (m_NextState == eGameState.Gameplay && MediaPlayer.State == MediaState.Stopped)
                {
                    if (CheckNewHighScore())
                    {
                        IsPaused = true;
                        ShowNewScoreMenu();
                    }
                    else
                    {
                        SetState(eGameState.MainMenu);
                    }
                }


                // Update objects in the world
                // We have to make a temp copy in case the objects list changes
                LinkedList <GameObject> temp = new LinkedList <GameObject>(m_GameObjects);
                foreach (GameObject o in temp)
                {
                    if (o.Enabled)
                    {
                        o.Update(fDeltaTime);
                    }
                }
                m_Timer.Update(fDeltaTime);

                if (MediaPlayer.State == MediaState.Playing)
                {
                    MediaPlayer.GetVisualizationData(m_VisualData);
                    GraphicsManager.Get().VisualData = m_VisualData;
                }

                if (!DanceMode)
                {
                    foreach (DictionaryEntry entry in m_BeatPlanes)
                    {
                        Objects.BeatPlane plane = (Objects.BeatPlane)entry.Value;
                        if (plane.Enabled && (plane.Position.Z < m_Player.Position.Z + m_fTolerance) && (plane.Position.Z > m_Player.Position.Z - m_fTolerance))
                        {
                            foreach (Objects.Note n in plane.ContainedNotes)
                            {
                                if (!n.Hit && !n.Miss && n.Location == m_Player.CurrentLocation)
                                {
                                    if (n.Bad)
                                    {
                                        if ((plane.Position.Z < m_Player.Position.Z + m_fTolerance / 3.0f) && (plane.Position.Z > m_Player.Position.Z))
                                        {
                                            if (Shield > 0)
                                            {
                                                Shield--;
                                            }
                                            else
                                            {
                                                Score     -= n.Value;
                                                Combo      = 0;
                                                Multiplier = MultMult;
                                                Health    -= 1;
                                                if (Health <= 0)
                                                {
                                                    //FAILURE
                                                    MediaPlayer.Stop();
                                                    SetState(eGameState.MainMenu);
                                                }
                                            }
                                            n.Hit = true;
                                        }
                                    }
                                    else
                                    {
                                        if (Health != m_iHealthMax)
                                        {
                                            Health += 1;
                                            if (Health > 50)
                                            {
                                                Health = 50;
                                            }
                                        }
                                        Score  += n.Value * Multiplier;
                                        n.Value = n.Value * Multiplier;
                                        Combo++;
                                        if (n.NotePowerup == Objects.Note.Powerup.DoubleMult)
                                        {
                                            MultMult    = 2;
                                            Multiplier *= MultMult;
                                            m_Timer.AddTimer("DoubleMult Expire", 32.0f * 60.0f / m_CurrentSong.BPM, DoubleMultExpire, false);
                                        }
                                        if (n.NotePowerup == Objects.Note.Powerup.Shield)
                                        {
                                            Shield = 3;
                                        }
                                        if ((Combo % m_iComboReq == 0) && (Multiplier < m_iMultMax * MultMult))
                                        {
                                            Multiplier += MultMult;
                                        }
                                        n.Hit     = true;
                                        MissCount = 0;
                                        HitNotes++;
                                        TotalNotes++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void HitNote(int x, int y)
        {
            GraphicsManager.Get().DrawHitRect(new Point(x, y));

            bool noteExists = false;

            foreach (DictionaryEntry entry in m_BeatPlanes)
            {
                Objects.BeatPlane plane = (Objects.BeatPlane)entry.Value;
                if (plane.Enabled && (plane.Position.Z < m_fTolerance) && (plane.Position.Z > -1.0f * m_fTolerance))
                {
                    foreach (Objects.Note n in plane.ContainedNotes)
                    {
                        if (!n.Hit && !n.Miss && n.Location.X == x && n.Location.Y == y)
                        {
                            noteExists = true;
                            if (n.Bad)
                            {
                                if ((plane.Position.Z < m_fTolerance / 3.0f) && (plane.Position.Z > -1.0f * m_fTolerance / 8.0f))
                                {
                                    if (Shield > 0)
                                    {
                                        Shield--;
                                    }
                                    else
                                    {
                                        Score     -= n.Value;
                                        Combo      = 0;
                                        Multiplier = MultMult;
                                        Health    -= 1;
                                        if (Health <= 0)
                                        {
                                            //FAILURE
                                            MediaPlayer.Stop();
                                            SetState(eGameState.MainMenu);
                                        }
                                    }
                                    n.Hit = true;
                                }
                            }
                            else
                            {
                                if (Health != m_iHealthMax)
                                {
                                    Health += 1;
                                    if (Health > 50)
                                    {
                                        Health = 50;
                                    }
                                }
                                Score  += n.Value * Multiplier;
                                n.Value = n.Value * Multiplier;
                                Combo++;
                                if (n.NotePowerup == Objects.Note.Powerup.DoubleMult)
                                {
                                    MultMult    = 2;
                                    Multiplier *= MultMult;
                                    m_Timer.AddTimer("DoubleMult Expire", 32.0f * 60.0f / m_CurrentSong.BPM, DoubleMultExpire, false);
                                }
                                if (n.NotePowerup == Objects.Note.Powerup.Shield)
                                {
                                    Shield = 3;
                                }
                                if ((Combo % m_iComboReq == 0) && (Multiplier < m_iMultMax * MultMult))
                                {
                                    Multiplier += MultMult;
                                }
                                n.Hit     = true;
                                MissCount = 0;
                                HitNotes++;
                                TotalNotes++;
                            }
                        }
                    }
                }
            }

            if (!noteExists)
            {
                Combo      = 0;
                Multiplier = MultMult;
                Health    -= 1;
                if (Health <= 0)
                {
                    //FAILURE
                    MediaPlayer.Stop();
                    SetState(eGameState.MainMenu);
                }
            }
        }
Ejemplo n.º 5
0
        public void SetupGameplay()
        {
            ClearGameObjects();
            m_UIStack.Clear();
            m_UIGameplay = new UI.UIGameplay(m_Game.Content);
            m_UIStack.Push(m_UIGameplay);

            m_bPaused = false;
            GraphicsManager.Get().ResetProjection();

            m_Timer.RemoveAll();

            //Reset all gameplay variables
            Multiplier = 1;
            Combo      = 0;
            Score      = 0;
            HitNotes   = 0;
            MultMult   = 1;
            Shield     = 0;



            // Set grid dimensions and player movement limit
            GraphicsManager.Get().SetGridDimensions(m_GridWidth, m_GridHeight);

            if (!DanceMode)
            {
                m_Player = new Objects.Player(m_Game);
                SpawnGameObject(m_Player);
                m_Camera.FollowObject = m_Player;
                m_Player.setPlayerMovementLimitations(m_GridWidth / 3.0f, m_GridHeight / 3.0f);
            }

            ParseFile(m_SongFile);


            foreach (Objects.BeatPlane b in m_BeatPlanes.Values)
            {
                RemoveBeatPlane(b);
            }
            m_BeatPlanes.Clear();
            m_CurrentSong = m_Songs[0];

            Health     = m_iHealthMax / 2;
            TotalNotes = 0;

            SetState(eGameState.Gameplay);
            createTestBeatPlanes();

            MediaPlayer.Stop();
            MediaPlayer.IsVisualizationEnabled = true;
            m_CurrentSongAudio = m_Game.Content.Load <Song>(m_SongFile.Replace(".txt", ""));

            m_VisualData = new VisualizationData();
            MediaPlayer.Play(m_CurrentSongAudio);

            m_CurrentBeat = 0.0f;

            // Get the beatplane at the beat
            Objects.BeatPlane beatplaneAtCurrentBeat = (Objects.BeatPlane)m_BeatPlanes[m_CurrentBeat];
            if (beatplaneAtCurrentBeat != null)
            {
                // Set it active
                beatplaneAtCurrentBeat.SetActive(m_CurrentSong, Objects.BeatPlane.TunnelDirection.straight);
            }
        }