Esempio n. 1
0
 public void remakeLists(Chart c)
 {
     timingsList.Clear();
     foreach (var pair in timings)
     {
         timingsList.Add(pair.Value);
     }
     foreach (TimingSection s in c.Sections)
     {
         timingsList.Add(s);
     }
     timingsList.Sort(delegate(TimingSection a, TimingSection b)
     {
         return a.Offset.CompareTo(b.Offset);
     });
 }
Esempio n. 2
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();
        }