Esempio n. 1
0
        public virtual void Draw(float fDeltaTime)
        {
            if (m_bTransformDirty)
            {
                RebuildWorldTransform();
            }

            if (m_Model != null)
            {
                foreach (ModelMesh mesh in m_Model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.World      = m_ModelBones[mesh.ParentBone.Index] * m_WorldTransform;
                        effect.View       = GameState.Get().CameraMatrix;
                        effect.Projection = GraphicsManager.Get().Projection;
                        effect.EnableDefaultLighting();
                        effect.AmbientLightColor         = new Vector3(1.0f, 1.0f, 1.0f);
                        effect.DirectionalLight0.Enabled = true;
                        effect.DirectionalLight1.Enabled = true;
                        effect.DirectionalLight2.Enabled = false;
                        effect.PreferPerPixelLighting    = true;
                    }
                    mesh.Draw();
                }
            }
        }
Esempio n. 2
0
 public void RemoveGameObject(GameObject o, bool bRemoveFromList = true)
 {
     o.Enabled = false;
     o.Unload();
     GraphicsManager.Get().RemoveGameObject(o);
     if (bRemoveFromList)
     {
         m_GameObjects.Remove(o);
     }
 }
Esempio n. 3
0
 public Game1()
 {
     IsFixedTimeStep = false;
     GraphicsManager.Get().Start(this);
     if (DebugDefines.bShowWindowsMouseCursor)
     {
         IsMouseVisible = true;
     }
     else
     {
         IsMouseVisible = false;
     }
     Window.Title          = "Rhythm Runner";
     Content.RootDirectory = "Content";
 }
Esempio n. 4
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;
     }
 }
Esempio n. 5
0
 public void SpawnGameObject(GameObject o)
 {
     o.Load();
     m_GameObjects.AddLast(o);
     GraphicsManager.Get().AddGameObject(o);
 }
Esempio n. 6
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++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
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);
                }
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
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);
 }
Esempio n. 10
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);
        }