Пример #1
0
 public ReplayHit(int n, int o, int l, Replay.HitType hit)
 {
     this.hit = hit;
     noteOffset = n;
     offsetDifference = o;
     lane = l;
     used = false;
 }
Пример #2
0
        public ScoreScreen(Game game, string name, Replay replay, Song song, int diff, bool play)
            : base(game, name)
        {
            if (play)
            {
                retryButton = new Button(game, new Rectangle(Config.ResWidth - (int)(Config.ResWidth * 0.3), 230, 100, 50), "Retry", delegate(int data)
                {
                    game.screens["ingameScreen"].Music.stop();
                    IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                    temp.loadSong(temp.CurrentSong, temp.Difficulty, temp.Mods, null, IngameScreen.PlayType.PLAY);
                    Game.setScreen(game.screens["ingameScreen"]);
                });
                UIComponents.Add(retryButton);
            }
            if (replay != null)
            {

                this.replay = replay;
                replayButton = new Button(game, new Rectangle(Config.ResWidth - (int)(Config.ResWidth * 0.3), 330, 100, 50), "Replay", delegate(int data)
                {
                    IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                    try
                    {
                        if (temp.Music != null)
                        {
                            temp.Music.stop();
                        }
                        temp.loadSong(song, diff, temp.Mods, this.replay, IngameScreen.PlayType.REPLAY);
                        Game.setScreen(temp);
                        game.Title = "Pulse | Watch replay | " + song.Artist + " - " + song.SongName + " [" + song.Charts[diff].Name + "]";
                    }
                    catch { }
                });
                UIComponents.Add(replayButton);
            }
        }
Пример #3
0
 public static Replay reconReplay(string name)
 {
     FileStream f = null;
     try
     {
         if (File.Exists(name))
         {
             XmlDocument doc = new XmlDocument();
             f = new FileStream(name, FileMode.Open);
             doc.Load(f);
             Replay r = new Replay();
             foreach (XmlNode node in doc.DocumentElement.ChildNodes)
             {
                 switch (node.Name)
                 {
                     case "m":
                         foreach (XmlNode n in node.ChildNodes)
                         {
                             switch (n.Name)
                             {
                                 case "c":
                                     r.Mods.Scroll = Convert.ToDouble(n.InnerText);
                                     break;
                                 case "s":
                                     r.Mods.Speed = Convert.ToDouble(n.InnerText);
                                     break;
                                 case "f":
                                     r.Mods.Flags = Convert.ToUInt32(n.InnerText);
                                     break;
                             }
                         }
                         break;
                     case "h":
                         ReplayHit h = new ReplayHit(0, 0, 0, 0);
                         foreach (XmlNode n in node.ChildNodes)
                         {
                             switch (n.Name)
                             {
                                 case "t":
                                     h.Hit = (Replay.HitType)Convert.ToInt32(n.InnerText);
                                     break;
                                 case "l":
                                     h.Lane = Convert.ToInt32(n.InnerText);
                                     break;
                                 case "o":
                                     h.NoteOffset = Convert.ToInt32(n.InnerText);
                                     break;
                                 case "d":
                                     h.OffsetDifference = Convert.ToInt32(n.InnerText);
                                     break;
                             }
                         }
                         r.HitTimings.Add(h);
                         break;
                     case "p":
                         Pair<int, Pair<int, bool>> p = new Pair<int, Pair<int, bool>>(0, new Pair<int, bool>(0, false));
                         foreach (XmlNode n in node.ChildNodes)
                         {
                             switch (n.Name)
                             {
                                 case "o":
                                     p.key = Convert.ToInt32(n.InnerText);
                                     break;
                                 case "l":
                                     p.value.key = Convert.ToInt32(n.InnerText);
                                     break;
                             }
                         }
                         r.PressTimings.Add(p);
                         break;
                     case "r":
                         Pair<int, Pair<int, bool>> e = new Pair<int, Pair<int, bool>>(0, new Pair<int, bool>(0, false));
                         foreach (XmlNode n in node.ChildNodes)
                         {
                             switch (n.Name)
                             {
                                 case "o":
                                     e.key = Convert.ToInt32(n.InnerText);
                                     break;
                                 case "l":
                                     e.value.key = Convert.ToInt32(n.InnerText);
                                     break;
                             }
                         }
                         r.ReleaseTimings.Add(e);
                         break;
                 }
             }
             f.Close();
             return r;
         }
         else
         {
             return null;
         }
     }
     catch (Exception e)
     {
         if (f != null)
         {
             f.Close();
         }
         Console.WriteLine(e.Message);
         return null;
     }
 }
Пример #4
0
        public void loadSong(Song song, int difficulty, Mods m, Replay replay, PlayType t)
        {
            for (int i = 0; i < 8; i++)
            {
                holding[i] = false;
                canHit[i] = true;
            }
            first = true;
            specFailed = false;
            scoreMod = 1;
            hp = 100;
            notAdded = true;
            mods = m;
            currentReplay = null;
            playType = t;
            currentSong = song;
            this.difficulty = difficulty;
            chart = song.Charts[difficulty];
            hitWindow = 50;
            hitWindow = hitWindow + (chart.Judgement * 20);
            keygroup = chart.Keys - 5;
            switch (t)
            {
                case PlayType.PLAY:
                    recordingReplay = true;
                    this.replay = false;
                    currentReplay = new Replay();
                    this.currentReplay.Mods = m;
                    currentReplay.Mods = mods;
                    if (Config.Spectating)
                    {
                        Config.Spectating = false;
                        try
                        {
                            PacketWriter.sendSpectateCancel(Game.conn.Bw, Config.SpectatedUser);
                        }
                        catch
                        {
                        }
                    }
                    break;
                case PlayType.REPLAY:
                    recordingReplay = false;
                    currentReplay = replay;
                    this.replay = true;
                    this.mods = replay.Mods;
                    foreach (var pair in currentReplay.PressTimings)
                    {
                        pair.value.value = false;
                    }
                    foreach (var pair in currentReplay.ReleaseTimings)
                    {
                        pair.value.value = false;
                    }
                    foreach (ReplayHit h in currentReplay.HitTimings)
                    {
                        h.Used = false;
                    }
                    break;
                case PlayType.TEST:
                    recordingReplay = false;
                    this.replay = false;
                    generateAutoReplay();
                    break;
                case PlayType.AUTO:
                    this.replay = true;
                    this.recordingReplay = false;
                    generateAutoReplay();
                    break;
                case PlayType.SPECTATE:
                    this.replay = true;
                    currentReplay = new Replay();
                    break;
            }

            Game.M.Music.stop();
            try
            {
                PacketWriter.sendSongStart(Game.conn.Bw, Account.currentAccount.AccountName, Utils.calcHash(chart.Path), song.Artist + " - " + song.SongName, (short)playType, mods.Flags, Convert.ToDouble(mods.Scroll, Config.cultureEnglish), mods.Speed);
            }
            catch
            {
            }
            try
            {
                breaksound = File.ReadAllBytes(Skin.skindict["combobreak"]);
                hitsound = File.ReadAllBytes(Skin.skindict["normal-hitnormal"]);
            }
            catch
            {
                Console.WriteLine("Error loading hitsounds, probably missing file");
            }
            if (currentSong.FileVersion == 0)
            {
                music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
            }
            else
            {
                music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName); //fix in future to load per chart
            }
            Music.PositionAsMilli = 0;
            Music.Volume = Config.Volume / 100.0f;
            currentOffset = -(chart.LeadInTime * 1000);
            endOffset = 0;
            startOffset = -1;
            foreach (Note n in chart.Notes)
            {
                n.Vertical = -20;
                if (n.Hold)
                {
                    n.HoldVertical = -20;
                }
                n.Enabled = true;
                n.Visible = true;
                n.setAlpha(1.0f);
                n.setColor();
                n.Texture.Fading = false;
                n.Holdbar.Fading = false;
                n.HoldEnd.Fading = false;
                if (startOffset < 0)
                    startOffset = n.Offset;
                if (n.Hold)
                {
                    if (n.HoldOffset > endOffset)
                    {
                        endOffset = n.HoldOffset;
                    }
                }
                else if (n.Offset > endOffset)
                {
                    endOffset = n.Offset;
                }
                if (n.Offset < startOffset)
                {
                    startOffset = n.Offset;
                }
            }
            endOffset += 1500;
            Dictionary<int, int> moves = new Dictionary<int, int>();
            foreach (TimingSection s in currentSong.TimingsList)
            {
                if (s.ChangeSnap)
                {
                    double move = 60 / (s.Snap / 1000);
                    if (move > 400)
                    {
                        move = 400;
                    }
                    double perc = (move / 400) * 100;
                    move = 3000 - (27 * perc);
                    try
                    {
                        moves.Add((int)s.Offset, (int)move);
                    }
                    catch { }
                }
            }
            List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>();
            list.Sort((f, s) =>
            {
                return f.Key.CompareTo(s.Key);
            });
            invert = false;
            if ((mods.Flags & 4) == 4)
            {
                invert = true;
            }
            if ((mods.Flags & 8) == 8)
            {
                scoreMod += 0.05;
            }
            List<int> keys = new List<int>(moves.Keys);
            List<int> offs = new List<int>(moves.Values);
            foreach (Note n in chart.Notes)
            {
                if (n.Offset < keys[0])
                {
                    n.MoveTime = (int)(offs[0] / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll));
                }
            }
            foreach (Note n in chart.Notes)
            {
                foreach (var pair in moves)
                {
                    if (n.Offset >= pair.Key)
                    {
                        n.MoveTime = (int)(pair.Value / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll));
                    }
                }
                if (invert)
                {
                    n.Location = 9 - n.Location;
                }
            }
            time1 = 0;
            time2 = 0;
            time3 = 0;
            finalScore = new Score();
        }
Пример #5
0
 private void generateAutoReplay()
 {
     currentReplay = new Replay();
     currentReplay.Mods = this.mods;
     foreach (Note n in Chart.Notes)
     {
         try
         {
             currentReplay.HitTimings.Add(new ReplayHit((int)(n.Offset * (1 / mods.Speed)), 0, n.Location - 1, Replay.HitType.PERFECT));
             currentReplay.PressTimings.Add(new Pair<int, Pair<int, bool>>((int)(n.Offset * (1 / mods.Speed)) - 15, new Pair<int, bool>(n.Location - 1, false)));
             if (!n.Hold)
             {
                 currentReplay.ReleaseTimings.Add(new Pair<int, Pair<int, bool>>((int)(n.Offset * (1 / mods.Speed)) + 75, new Pair<int, bool>(n.Location - 1, false)));
             }
             else
             {
                 currentReplay.HitTimings.Add(new ReplayHit((int)(n.HoldOffset * (1 / mods.Speed)), 0, n.Location - 1, Replay.HitType.PERFECT));
                 currentReplay.ReleaseTimings.Add(new Pair<int, Pair<int, bool>>((int)(n.HoldOffset * (1 / mods.Speed)) - 15, new Pair<int, bool>(n.Location - 1, false)));
             }
         }
         catch { }
     }
 }