Example #1
0
 private void ClampMouse()
 {
     if (m_MousePos.X < 0)
     {
         m_MousePos.X = 0;
     }
     if (m_MousePos.Y < 0)
     {
         m_MousePos.Y = 0;
     }
     if (m_MousePos.X > GraphicsManager.Get().Width)
     {
         m_MousePos.X = GraphicsManager.Get().Width - GlobalDefines.iMouseCursorSize / 4;
     }
     if (m_MousePos.Y > GraphicsManager.Get().Height)
     {
         m_MousePos.Y = GraphicsManager.Get().Height - GlobalDefines.iMouseCursorSize / 4;
     }
 }
 public void SpawnGameObject(GameObject o)
 {
     o.Load();
     m_GameObjects.AddLast(o);
     GraphicsManager.Get().AddGameObject(o);
 }
        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++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        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);
                }
            }
        }
        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);
            }
        }
Example #6
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     GraphicsManager.Get().LoadContent();
     SoundManager.Get().LoadContent(Content);
 }
Example #7
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsManager.Get().Draw((float)gameTime.ElapsedGameTime.TotalSeconds);

            base.Draw(gameTime);
        }