Ejemplo n.º 1
0
        public void Draw(PrimitiveRenderer pr, SpriteBatch sb)
        {
            leftRender.Draw(pr, sb);
            rightRender.Draw(pr, sb);

            if (font != null) {
                sb.Begin();
                debug.Clear();
                debug.AppendFormat("Active Player: {0}\n", host.ActivePlayer);
                debug.AppendFormat("Time: {0:F2}\n", host.Time);
                debug.AppendFormat("Track time: {0:F2}\n", host.Song.PlayPosition);
                debug.AppendFormat("Active Section: {0}\n", host.ActiveSectionNo[(int)host.ActivePlayer]);
                sb.DrawString(font, debug, debugTextPos, Color.White);
                sb.End();
            }
        }
Ejemplo n.º 2
0
        public void Draw(PrimitiveRenderer pr, SpriteBatch sb)
        {
            leftRender.Draw(pr, sb);
            rightRender.Draw(pr, sb);

            if (font != null)
            {
                sb.Begin();
                debug.Clear();
                debug.AppendFormat("Active Player: {0}\n", host.ActivePlayer);
                debug.AppendFormat("Time: {0:F2}\n", host.Time);
                debug.AppendFormat("Track time: {0:F2}\n", host.Song.PlayPosition);
                debug.AppendFormat("Active Section: {0}\n", host.ActiveSectionNo[(int)host.ActivePlayer]);
                sb.DrawString(font, debug, debugTextPos, Color.White);
                sb.End();
            }
        }
Ejemplo n.º 3
0
        public override void Draw(SpriteBatch Sb, PrimitiveRenderer Pr)
        {
            StringBuilder str = new StringBuilder();
            // Draw track list
            str.AppendLine("Track List:");
            foreach (Track track in Tracks)
                str.AppendLine(track.Name);

            Sb.Begin();
            Sb.DrawString(Font, str, trackSelectListPosition, Color.White);

            // BEGIN ==================================
            for (int i = 0; i < noPlayers; ++i) {
                str.Clear();
                str.AppendLine(Tracks[TrackSelected[i]].Name);
                // Draw diff list
                foreach (TrackData diff in Tracks[TrackSelected[i]].Diffs)
                    str.AppendLine(diff.Name);
                Sb.DrawString(Font, str, diffSelectListPosition[i], Color.Pink);

                // Draw selected list
                str.Clear();
                str.AppendLine("Selected:");
                foreach (TrackSelection selection in SelectionList[i])
                    str.AppendFormat("{0} ({1})\n", selection.Track.Name, selection.Diff.Name);
                Sb.DrawString(Font, str, selectionListPosition[i], Color.Pink);

                // Draw track selected box
                Rectangle selectedRect = new Rectangle((int)trackSelectListPosition.X - 15 * (noPlayers - i), (int)trackSelectListPosition.Y + (1 + TrackSelected[i]) * Font.LineSpacing, 10, Font.LineSpacing);
                Pr.DrawRectFilled(selectedRect, 1, Color.Red, Color.Pink);

                // Draw diff selected box
                selectedRect = new Rectangle((int)diffSelectListPosition[i].X - 15, (int)diffSelectListPosition[i].Y + (1 + DiffSelected[i]) * Font.LineSpacing, 10, Font.LineSpacing);
                Pr.DrawRectFilled(selectedRect, 1, Color.Red, Color.Pink);
            }
            // END ==================================

            Sb.End();
        }
Ejemplo n.º 4
0
 public abstract void Draw(SpriteBatch Sb, PrimitiveRenderer Pr);
Ejemplo n.º 5
0
        public void Draw(PrimitiveRenderer pr, SpriteBatch sb)
        {
            if (Host.Track != null) {
                int noteHeight = 10;
                // Draw track
                Color healthColor = Color.Lerp(Color.Red, Color.Green, Host.ScoreValue.Health);
                pr.Begin();
                pr.DrawRectFilled(Dimensions, 2, Color.White, healthColor * 0.5f);
                pr.End();

                pr.Begin(Matrix.CreateTranslation(Dimensions.X, Dimensions.Y, 0));
                // Draw notes
                for (int key = 0; key < Host.ActiveDiff.Keys; ++key) {
                    LinkedList<Note> visibleNotes = Host.ActiveDiff.GetNotesInRange(Host.ActiveSectionNo, key, (int)Host.Time, (int)(Host.Time + VisibleRange));
                    int noteWidth = Dimensions.Width / Host.ActiveDiff.Keys;
                    Rectangle drawPos = new Rectangle(noteWidth * key, 0, noteWidth, noteHeight);
                    double delta;
                    drawPos.Y = 0;
                    foreach (Note note in visibleNotes) {
                        delta = note.Time - Host.Time;
                        drawPos.Y = (delta <= 0) ? 0 :
                                        (int)(delta / VisibleRange * Dimensions.Height);
                        switch (note.State) {
                            default:
                            case KeyState.Tap:
                                drawPos.Height = noteHeight;
                                pr.DrawRectFilled(drawPos, 1, Color.White, Color.Red);
                                break;
                            case KeyState.Hold:
                                // If note passed already, fix it to the top of the track.
                                // Otherwise, leave default
                                if (delta < 0) {
                                    drawPos.Y = 0;
                                }
                                // figure out where to put end
                                double endDelta = delta + note.Length;
                                if (delta > 0 && endDelta < VisibleRange) {
                                    // In range
                                    drawPos.Height = (int)(note.Length / VisibleRange * Dimensions.Height);
                                } else if (delta < 0 && endDelta > VisibleRange) {
                                    // Extended range
                                    drawPos.Height = Dimensions.Height;
                                } else if (delta > 0) {
                                    // Entering
                                    drawPos.Height = (int)((1 - delta / VisibleRange) * Dimensions.Height);
                                } else {
                                    // Leaving
                                    drawPos.Height = (int)((note.Length + delta) / VisibleRange * Dimensions.Height);
                                }
                                pr.DrawRectFilled(drawPos, 1, Color.White, Color.Blue);
                                break;
                        }
                    }
                }
                pr.End();

                // Draw track overlay
                Rectangle currentTimeRect = new Rectangle(0, 0, Dimensions.Width, noteHeight);
                pr.Begin(Matrix.CreateTranslation(Dimensions.X, Dimensions.Y, 0));
                pr.DrawRectFilled(currentTimeRect, 1, Color.White, Color.LightGray * 0.8f);
                pr.End();
            }

            // Debug overlay
            StringBuilder debug = new StringBuilder();
            debug.AppendFormat("Status: {0}\n", Host.State);
            debug.AppendFormat("Active Section: {0}\n", Host.ActiveSectionNo);
            if (Host.Time == TrackPlayer.InvalidTime)
                debug.AppendLine("Track time: -");
            else
                debug.AppendFormat("Track time: {0:F2} ms\n", Host.Time);
            debug.AppendFormat("Begin/End: {0:F2} ms, {1:F2} ms\n", Host.ActiveDiff.Sections[Host.ActiveSectionNo].Begin, Host.ActiveDiff.Sections[Host.ActiveSectionNo].End);
            debug.AppendFormat("Health/Score: {0:P2}/{1}\n", Host.ScoreValue.Health, Host.ScoreValue.Score);

            // Movement keys
            for (int i = 0; i < 6; ++i) {
                debug.AppendFormat("{0}", Host.Controller.States[i]);
            }
            debug.AppendLine();
            // Rhythm keys
            for (int i = 6; i < Host.Controller.States.Length; ++i) {
                debug.AppendFormat("{0}", Host.Controller.States[i]);
            }

            sb.Begin();
            sb.DrawString(font, debug, textPosition, textColor);
            sb.End();
        }
Ejemplo n.º 6
0
        protected override void LoadContent()
        {
            // ==============================
            // -- Prepare graphic systems
            // ==============================
            spriteBatch = new SpriteBatch(GraphicsDevice);
            particleSystem = new ParticleSystem();
            primitiveRenderer = new PrimitiveRenderer(spriteBatch);

            // ==============================
            // -- Object pre-initialization
            // ==============================
            particle = new Particle(particle1SpriteSheet);
            beam = new Particle(beam1SpriteSheet);

            // ==============================
            // -- Load fonts
            // ==============================
            sysFont = Content.Load<SpriteFont>(@"Fonts\System");
            // ==============================
            // -- Load graphics
            // ==============================
            fighterSpriteSheet.Texture = Content.Load<Texture2D>(@"Sprites\Fighter1");
            particle1SpriteSheet.Texture = Content.Load<Texture2D>(@"Particles\Particle1");
            beam1SpriteSheet.Texture = Content.Load<Texture2D>(@"Particles\Beam1");
            bulletSpriteSheet.Texture = Content.Load<Texture2D>(@"Sprites\bullet");
            // ==============================
            // -- Object post-initialization
            // =============================
            LoadTracks();

            State = new TitleState(this, sysFont);
        }
Ejemplo n.º 7
0
        public override void Draw(SpriteBatch Sb, PrimitiveRenderer Pr)
        {
            Ps.Draw(Sb);

            Sb.Begin();
            // Draw enemy projectiles
            // Draw player projectiles
            foreach (Bullet bullet in BulletList) {
                if (bullet.isAlive)
                    bullet.Sprite.Draw(Sb, bullet.position, bullet.Angle, bullet.Scale, Color.White);
            }
            // Draw enemy slaves
            // Draw player slaves

            // Draw fighters
            foreach (Fighter fighter in Fighters) {
                if (fighter.CurrentState == Fighter.State.Defend)
                    Pr.DrawCircle(fighter.Position, 50, 1.0f, Color.White * fighter.ShieldStrength);
                fighter.Sprite.Draw(Sb, fighter.Position, fighter.Angle, fighter.Scale, Color.White);
            }
            Sb.End();
            Rr.Draw(Pr, Sb);
        }
Ejemplo n.º 8
0
        public void Draw(PrimitiveRenderer pr, SpriteBatch sb)
        {
            if (Host.Track != null)
            {
                int noteHeight = 10;
                // Draw track
                Color healthColor = Color.Lerp(Color.Red, Color.Green, Host.ScoreValue.Health);
                pr.Begin();
                pr.DrawRectFilled(Dimensions, 2, Color.White, healthColor * 0.5f);
                pr.End();

                pr.Begin(Matrix.CreateTranslation(Dimensions.X, Dimensions.Y, 0));
                // Draw notes
                for (int key = 0; key < Host.ActiveDiff.Keys; ++key)
                {
                    LinkedList <Note> visibleNotes = Host.ActiveDiff.GetNotesInRange(Host.ActiveSectionNo, key, (int)Host.Time, (int)(Host.Time + VisibleRange));
                    int       noteWidth            = Dimensions.Width / Host.ActiveDiff.Keys;
                    Rectangle drawPos = new Rectangle(noteWidth * key, 0, noteWidth, noteHeight);
                    double    delta;
                    drawPos.Y = 0;
                    foreach (Note note in visibleNotes)
                    {
                        delta     = note.Time - Host.Time;
                        drawPos.Y = (delta <= 0) ? 0 :
                                    (int)(delta / VisibleRange * Dimensions.Height);
                        switch (note.State)
                        {
                        default:
                        case KeyState.Tap:
                            drawPos.Height = noteHeight;
                            pr.DrawRectFilled(drawPos, 1, Color.White, Color.Red);
                            break;

                        case KeyState.Hold:
                            // If note passed already, fix it to the top of the track.
                            // Otherwise, leave default
                            if (delta < 0)
                            {
                                drawPos.Y = 0;
                            }
                            // figure out where to put end
                            double endDelta = delta + note.Length;
                            if (delta > 0 && endDelta < VisibleRange)
                            {
                                // In range
                                drawPos.Height = (int)(note.Length / VisibleRange * Dimensions.Height);
                            }
                            else if (delta < 0 && endDelta > VisibleRange)
                            {
                                // Extended range
                                drawPos.Height = Dimensions.Height;
                            }
                            else if (delta > 0)
                            {
                                // Entering
                                drawPos.Height = (int)((1 - delta / VisibleRange) * Dimensions.Height);
                            }
                            else
                            {
                                // Leaving
                                drawPos.Height = (int)((note.Length + delta) / VisibleRange * Dimensions.Height);
                            }
                            pr.DrawRectFilled(drawPos, 1, Color.White, Color.Blue);
                            break;
                        }
                    }
                }
                pr.End();

                // Draw track overlay
                Rectangle currentTimeRect = new Rectangle(0, 0, Dimensions.Width, noteHeight);
                pr.Begin(Matrix.CreateTranslation(Dimensions.X, Dimensions.Y, 0));
                pr.DrawRectFilled(currentTimeRect, 1, Color.White, Color.LightGray * 0.8f);
                pr.End();
            }

            // Debug overlay
            StringBuilder debug = new StringBuilder();

            debug.AppendFormat("Status: {0}\n", Host.State);
            debug.AppendFormat("Active Section: {0}\n", Host.ActiveSectionNo);
            if (Host.Time == TrackPlayer.InvalidTime)
            {
                debug.AppendLine("Track time: -");
            }
            else
            {
                debug.AppendFormat("Track time: {0:F2} ms\n", Host.Time);
            }
            debug.AppendFormat("Begin/End: {0:F2} ms, {1:F2} ms\n", Host.ActiveDiff.Sections[Host.ActiveSectionNo].Begin, Host.ActiveDiff.Sections[Host.ActiveSectionNo].End);
            debug.AppendFormat("Health/Score: {0:P2}/{1}\n", Host.ScoreValue.Health, Host.ScoreValue.Score);

            // Movement keys
            for (int i = 0; i < 6; ++i)
            {
                debug.AppendFormat("{0}", Host.Controller.States[i]);
            }
            debug.AppendLine();
            // Rhythm keys
            for (int i = 6; i < Host.Controller.States.Length; ++i)
            {
                debug.AppendFormat("{0}", Host.Controller.States[i]);
            }

            sb.Begin();
            sb.DrawString(font, debug, textPosition, textColor);
            sb.End();
        }