Beispiel #1
0
        internal static void PurgeFrames(ReplayAction action)
        {
            if (!HasSpectators || InputManager.ReplayMode)
            {
                return;
            }

            if (action == ReplayAction.NewSong)
            {
                lock (Spectators)
                    foreach (User u in Spectators)
                    {
                        u.CantSpectate = false;
                    }
            }

            bScoreFrame scoreFrame = Player.GetScoreFrame();

            BanchoClient.SendRequest(RequestType.Osu_SpectateFrames,
                                     new bReplayFrameBundle(waitingOutgoingFrames, action, scoreFrame));
#if DEBUG
            /*   GameBase.ShowMessage("sending " + waitingOutgoingFrames.Count + " frames to spectators", Color.LightBlue,
             *                      200);*/
#endif
            waitingOutgoingFrames = new List <bReplayFrame>();
        }
Beispiel #2
0
        internal static void MatchScoreUpdate(bScoreFrame frame)
        {
            GameBase.Scheduler.Add(delegate
            {
                if (Instance == null)
                {
                    return;
                }

                Instance.MultiRuleset.HandleFrame(frame);


                if (TeamMode)
                {
                    TeamOverlay.UpdateScores();
                }

                //quick fix for getting hpgraphs into multiplayer
                if (Instance.hitObjectManager != null &&
                    Instance.hitObjectManager.hitObjects != null &&
                    Instance.HpGraphCollection[frame.id] != null
                    )
                {
                    //get the hitobject for the incoming score.
                    HitObject ho = Instance.hitObjectManager.hitObjects.FindLast(h => frame.time < h.EndTime);
                    if (ho != null)
                    {
                        Instance.HpGraphCollection[frame.id].Add(new Vector2(frame.time,
                                                                             (float)(Math.Min(1, frame.currentHp / ho.MaxHp))));
                    }
                }
            });
        }
 public void SetScore(bScoreFrame score)
 {
     Frame            = score;
     this.score       = score.totalScore;
     spriteInfo.Text  = score.totalScore > 0 ? score.totalScore.ToString("0,0", GameBase.nfi) : "-";
     spriteInfo.Text += " (" + score.currentCombo + "x)";
     spriteBackground.FadeColour(new Color((byte)(200 - score.currentHp), 20, (byte)score.currentHp, spriteBackground.CurrentColour.A), 50);
     UpdatePending = false;
 }
Beispiel #4
0
        internal virtual void HandleFrame(bScoreFrame frame)
        {
            ScoreboardEntryExtended playerEntry = player.ScoreEntries[frame.id];

            if (playerEntry == null)
            {
                return;
            }

            playerEntry.HandleUpdate(frame);
            PlayerVs.scoreboardUpdatePending = true;
        }
Beispiel #5
0
 internal Score(bScoreFrame sf, string name)
 {
     pass        = sf.pass;
     playerName  = name;
     count300    = sf.count300;
     count100    = sf.count100;
     count50     = sf.count50;
     countGeki   = sf.countGeki;
     countKatu   = sf.countKatu;
     countMiss   = sf.countMiss;
     totalScore  = sf.totalScore;
     maxCombo    = sf.maxCombo;
     perfect     = sf.perfect;
     enabledMods = ModManager.ModStatus;
 }
        internal override void HandleFrame(bScoreFrame frame)
        {
            ScoreboardEntryExtended match = player.ScoreEntries[frame.id];

            match.HandleUpdate(frame);
            //PlayerVs.scoreboardUpdatePending = true;

            if (match.Team != player.scoreEntry.Team)
            {
                //Other team's play.
                return;
            }

            UpdateVisibleScore(match);
        }
Beispiel #7
0
        protected override void OnScoreChanged()
        {
            if (InputManager.ReplayMode)
            {
                return;
            }

            lastValidScoreFrame      = GetScoreFrame();
            lastValidScoreFrame.pass = !MultiFailed;

            lastValidScoreFrame.tagByte = PendingScoreChangeObject != null ? (int)PendingScoreChangeObject.Type : 1;
            PendingScoreChangeObject    = null;
            pendingScoreChange          = true;

            SendScoreChange();
        }
Beispiel #8
0
 internal Score(bScoreFrame sf, string name)
 {
     Pass         = sf.pass;
     PlayerName   = name;
     Count300     = sf.count300;
     Count100     = sf.count100;
     Count50      = sf.count50;
     CountGeki    = sf.countGeki;
     CountKatu    = sf.countKatu;
     CountMiss    = sf.countMiss;
     TotalScore   = sf.totalScore;
     MaxCombo     = sf.maxCombo;
     Perfect      = sf.perfect;
     CurrentHp    = sf.currentHp;
     CurrentCombo = sf.currentCombo;
     EnabledMods  = ModManager.ModStatus; //todo: wtf check this?
     Date         = DateTime.Now;
 }
Beispiel #9
0
        public static Score Create(PlayModes playMode, bScoreFrame frame, string name)
        {
            switch (playMode)
            {
            case PlayModes.CatchTheBeat:
                return(new ScoreFruits(frame, name));

            case PlayModes.Taiko:
                return(new ScoreTaiko(frame, name));

            case PlayModes.OsuMania:
                return(new ScoreMania(frame, name));

            default:
                Score s = new Score(frame, name);
                if (frame.usingScoreV2)
                {
                    s.Processor = new ScoreProcessor(s);
                }
                return(s);
            }
        }
Beispiel #10
0
        internal static void PurgeFrames(ReplayAction action, int?extra = null)
        {
            if (!HasSpectators || InputManager.ReplayMode)
            {
                return;
            }

            if (action == ReplayAction.NewSong)
            {
                lock (Spectators)
                    foreach (User u in Spectators)
                    {
                        u.CantSpectate = false;
                    }
            }

            bScoreFrame scoreFrame = Player.GetScoreFrame();

            BanchoClient.SendRequest(RequestType.Osu_SpectateFrames, new bReplayFrameBundle(waitingOutgoingFrames, action, scoreFrame, extra ?? Player.Seed));

            waitingOutgoingFrames = new List <bReplayFrame>();
        }
Beispiel #11
0
        public static void HandleFrames(bReplayFrameBundle bundle)
        {
#if DEBUG
            /*GameBase.ShowMessage(
             *  "received frames (" + bundle.Action +
             *  (bundle.ReplayFrames.Count > 0
             *       ? "," + bundle.ReplayFrames[0].time + "-" + bundle.ReplayFrames[bundle.ReplayFrames.Count - 1].time +
             *         ")"
             *       : "0)"), Color.Green, 1000);*/
#endif

            switch (bundle.Action)
            {
            case ReplayAction.Completion:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.Fail:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.NewSong:
                iDontHaveThatBeatmap = false;
                HandleSongChange(true);
                break;

            case ReplayAction.Skip:
                Player.QueueSkip();
                break;

            case ReplayAction.Standard:
                break;
            }

            if (!iDontHaveThatBeatmap && (WaitingLoad || InputManager.ReplayScore == null))
            {
                if (bundle.ReplayFrames.Count > 0)
                {
                    InputManager.ReplayStreamingStart = bundle.ReplayFrames[0].time - 50;
                }
                else
                {
                    InputManager.ReplayStreamingStart = 0;
                }

                HandleSongChange(false);

                WaitingLoad = false;

                Console.WriteLine("ReplaystreamingStart = " + InputManager.ReplayStreamingStart);
            }

            lock (LockReplayScore)
            {
                if (InputManager.ReplayScore != null && InputManager.ReplayScore.replay != null)
                {
                    foreach (bReplayFrame f in bundle.ReplayFrames)
                    {
                        InputManager.ReplayScore.replay.Add(f);
                    }
                    if ((ScoreSyncNext <= 0 || ScoreSyncNext < InputManager.ReplayFrame || InputManager.ReplayScore.replay.Count - 1 < ScoreSyncNext) && bundle.ScoreFrame.totalScore > 0)
                    {
                        ScoreSyncNext = InputManager.ReplayScore.replay.Count - 1;
                        Console.WriteLine("new syncframe " + ScoreSyncNext);
                        ScoreSyncFrame = bundle.ScoreFrame;
                    }
                }
            }
        }
Beispiel #12
0
 internal ScoreTaiko(bScoreFrame frame, string name)
     : base(frame, name)
 {
     PlayMode = PlayModes.Taiko;
 }
        internal void HandleUpdate(bScoreFrame frame)
        {
            Score newScore = ScoreFactory.Create(playMode, frame, null);

            newScore.EnabledMods = mods;
            Frame = frame;

            Score oldScore = Score;

            SetScore(newScore, frame.totalScore);

            Passing = frame.pass;

            if (oldScore != null && newScore.TotalHits != oldScore.TotalHits)
            {
                string value = @"0";
                bool   mania = playMode == PlayModes.OsuMania;

                if (mania)
                {
                    if (newScore.Count300 > oldScore.Count300)
                    {
                        value = @"300";
                    }
                    else if (newScore.Count100 > oldScore.Count100)
                    {
                        value = @"100";
                    }
                    else if (newScore.Count50 > oldScore.Count50)
                    {
                        value = @"50";
                    }
                    else if (newScore.CountGeki > oldScore.CountGeki)
                    {
                        value = @"300g";
                    }
                    else if (newScore.CountKatu > oldScore.CountKatu)
                    {
                        value = @"200";
                    }
                }
                else
                {
                    if (newScore.Count300 > oldScore.Count300)
                    {
                        value = @"300";
                    }
                    else if (newScore.Count100 > oldScore.Count100)
                    {
                        value = @"100";
                    }
                    else if (newScore.Count50 > oldScore.Count50)
                    {
                        value = @"50";
                    }
                    if (newScore.CountGeki > oldScore.CountGeki)
                    {
                        value += @"g";
                    }
                    if (newScore.CountKatu > oldScore.CountKatu)
                    {
                        value += @"k";
                    }
                }

                if (newScore.CurrentCombo == 0 && oldScore.CurrentCombo == 0)
                {
                    return; //Don't draw consecutive misses.
                }
                bool miss = value == @"0";

                if (!miss && lastHitSprite != null && lastHitSprite.Transformations.Count > 0 && lastHitSprite.Transformations[0].Time1 == GameBase.Time)
                {
                    return; //Bundled sprites don't need to be drawn unless they are a miss.
                }
                if (lastHitSprite != null && lastHitSprite.TagNumeric == 0)
                {
                    lastHitSprite.Depth -= 0.0001f;

                    lastHitSprite.FadeOut(100); //Fade out any non-miss previously being displayed.

                    scoreboard.spriteManager.Remove(lastHitSprite);
                    scoreboard.spriteManager.Add(lastHitSprite);
                }

                if (lastHitSprite != null)
                {
                    SpriteCollection.Remove(lastHitSprite);
                }

                var     texture = mania ? TextureManager.LoadAll(@"mania-hit" + value)[0] : TextureManager.Load(@"hit" + value);
                pSprite p       = new pSprite(texture, Origins.Centre, SpriteAvatar.Position, (miss ? 0.95f : 0.949f) - (rank * 0.001f), false, Color.White)
                {
                    Field      = SpriteBackground.Field,
                    TagNumeric = miss ? 1 : 0
                };

                lastHitSprite = p;

                SpriteCollection.Add(lastHitSprite);

                if (value == @"0")
                {
                    p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, GameBase.Time, GameBase.Time + HitObjectManager.HitFadeIn));
                    p.Transformations.Add(new Transformation(TransformationType.Scale, 0.6F, 0.4F, GameBase.Time, (int)(GameBase.Time + (HitObjectManager.HitFadeIn * 1.4))));
                    p.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, GameBase.Time + HitObjectManager.PostEmpt / 2, GameBase.Time + HitObjectManager.PostEmpt + HitObjectManager.HitFadeOut));
                }
                else
                {
                    p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, GameBase.Time, GameBase.Time + HitObjectManager.HitFadeIn));
                    p.Transformations.Add(new Transformation(TransformationType.Scale, 0.2F, 0.4F, GameBase.Time, (int)(GameBase.Time + (HitObjectManager.HitFadeIn * 0.8))));

                    p.Transformations.Add(new Transformation(TransformationType.Scale, 0.4F, 0.3F, GameBase.Time + HitObjectManager.HitFadeIn, (int)(GameBase.Time + (HitObjectManager.HitFadeIn * 1.2))));
                    p.Transformations.Add(new Transformation(TransformationType.Scale, 0.3F, 0.35F, GameBase.Time + HitObjectManager.HitFadeIn, (int)(GameBase.Time + (HitObjectManager.HitFadeIn * 1.4))));

                    p.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, GameBase.Time + HitObjectManager.PostEmpt, GameBase.Time + HitObjectManager.PostEmpt / 2 + HitObjectManager.HitFadeOut));
                }

                scoreboard.spriteManager.Add(p);
            }
        }
Beispiel #14
0
 internal ScoreFruits(bScoreFrame frame, string name)
     : base(frame, name)
 {
     PlayMode = PlayModes.CatchTheBeat;
 }
Beispiel #15
0
        public static void HandleFrames(bReplayFrameBundle bundle)
        {
#if DEBUG
            /*GameBase.ShowMessage(
             *  "received frames (" + bundle.Action +
             *  (bundle.ReplayFrames.Count > 0
             *       ? "," + bundle.ReplayFrames[0].time + "-" + bundle.ReplayFrames[bundle.ReplayFrames.Count - 1].time +
             *         ")"
             *       : "0)"), Color.Green, 1000);*/
#endif

            waitingOnHost = false;

            LastAction = bundle.Action;

            switch (bundle.Action)
            {
            case ReplayAction.Completion:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.Fail:
                InputManager.ReplayToEnd = true;
                break;

            case ReplayAction.WatchingOther:
                User u = BanchoClient.GetUserById(bundle.Extra);
                if (u != null && u.Id != GameBase.User.Id)
                {
                    NotificationManager.ShowMessage("Following host to new user...", Color.Green, 3000);
                    StartSpectating(u);
                }
                else
                {
                    StopSpectating();
                }
                break;

            case ReplayAction.NewSong:
                iDontHaveThatBeatmap = false;
                //ensure spectators use the same seed as players.
                Player.Seed = bundle.Extra;
                HandleSongChange(true, bundle.ScoreFrame.usingScoreV2);
                break;

            case ReplayAction.Skip:
                Player.QueueSkip();
                break;

            case ReplayAction.Standard:
                if (!iDontHaveThatBeatmap && InputManager.ReplayScore == null)
                {
                    if (bundle.ReplayFrames.Count > 0)
                    {
                        InputManager.ReplayStartTime = bundle.ReplayFrames[0].time - 50;
                    }
                    else     // set to 1 instead of 0 to make it not doubleskip if the first frame is a skip frame.
                    {
                        InputManager.ReplayStartTime = 1;
                    }
                    Player.Seed = bundle.Extra;
                    HandleSongChange(false, bundle.ScoreFrame.usingScoreV2);
                }
                break;

            case ReplayAction.Pause:
                if (!Player.Paused && Player.Instance != null)
                {
                    Player.Instance.TogglePause();
                }
                break;

            case ReplayAction.Unpause:
                if (Player.Paused && Player.Instance != null)
                {
                    Player.Instance.TogglePause();
                }
                break;
            }

            float lastY      = 0;
            int   lastOffset = 0;
            lock (LockReplayScore)
            {
                if (InputManager.ReplayScore != null && InputManager.ReplayScore.Replay != null)
                {
                    foreach (bReplayFrame f in bundle.ReplayFrames)
                    {
                        InputManager.ReplayScore.Replay.Add(f);
                    }
                    if (bundle.ReplayFrames.Count > 0)
                    {
                        int last = bundle.ReplayFrames.Count - 1;
                        lastY      = bundle.ReplayFrames[last].mouseY;
                        lastOffset = bundle.ReplayFrames[last].time;
                    }
                    if ((ScoreSyncNext <= 0 || ScoreSyncNext < InputManager.ReplayFrame || InputManager.ReplayScore.Replay.Count - 1 < ScoreSyncNext) && bundle.ScoreFrame.totalScore > 0)
                    {
                        ScoreSyncNext  = InputManager.ReplayScore.Replay.Count - 1;
                        ScoreSyncFrame = bundle.ScoreFrame;
                    }
                }
            }

            if (HasSpectators && CurrentlySpectating != null && CurrentlySpectating.Id != GameBase.User.Id && GameBase.Time - lastFollowNotification > 10000)
            {
                //tell spectators we are watching someone else.
                BanchoClient.SendRequest(RequestType.Osu_SpectateFrames, new bReplayFrameBundle(new List <bReplayFrame>(), ReplayAction.WatchingOther, new bScoreFrame(), CurrentlySpectating.Id));
                lastFollowNotification = GameBase.Time;
            }
        }
Beispiel #16
0
 private void LoadScore(string name, bScoreFrame frame)
 {
     LoadScore(new Score(frame, name));
 }
Beispiel #17
0
 internal ScoreMania(bScoreFrame frame, string name)
     : base(frame, name)
 {
     PlayMode = PlayModes.OsuMania;
 }
        private void InitializeTester()
        {
            if (!PREDEFINED_TEST)
            {
                return;
            }

            if (BeatmapManager.Beatmaps.Count > 0)
            {
                if (USE_LAST_PLAYED_BEATMAP)
                {
                    List <Beatmap> temp = new List <Beatmap>(BeatmapManager.Beatmaps);
                    temp.Sort((a, b) => { return(a.DateLastPlayed.CompareTo(b.DateLastPlayed)); });
                    BeatmapManager.Current = temp[temp.Count - 1];
                }
                else //Choose a random beatmap
                {
                    BeatmapManager.Current = BeatmapManager.Beatmaps[RNG.Next(0, BeatmapManager.Beatmaps.Count)];
                }
            }

            if (MULTIPLAYER_MATCH)
            {
                if (BeatmapManager.Current == null)
                {
                    NotificationManager.ShowMessage("Couldn't start in specified test mode because no beatmaps were available.");
                    return;
                }

                BanchoClient.Start();

                Mode = OsuModes.MatchSetup;

                const int player_count = 8;

                while (!BanchoClient.Connected || !BanchoClient.InitializationComplete)
                {
                    Scheduler.Update();
                }

                PresenceCache.QueryAll();

                while (User.Id <= 0 || BanchoClient.Users.Count < player_count)
                {
                    Scheduler.Update();
                }

                List <User> users = BanchoClient.Users.FindAll(u => u.InitialLoadComplete && u.Id != User.Id);
                users.Insert(0, User); //we are the first user.

                MatchSetup.Match = new ClientSideMatch(new bMatch(MatchTypes.Standard,
                                                                  MatchScoringTypes.Score,
                                                                  MatchTeamTypes.TeamVs,
                                                                  PlayModes.Osu,
                                                                  @"My test game",
                                                                  string.Empty,
                                                                  player_count,
                                                                  BeatmapManager.Current.SortTitle,
                                                                  BeatmapManager.Current.BeatmapChecksum,
                                                                  BeatmapManager.Current.BeatmapId,
                                                                  MODS_TO_USE,
                                                                  2,
                                                                  MultiSpecialModes.FreeMod
                                                                  ));

                for (int i = 0; i < player_count; i++)
                {
                    MatchSetup.Match.slotId[i]    = users[i].Id;
                    MatchSetup.Match.UserSlots[i] = users[i];

                    MatchSetup.Match.slotStatus[i] = SlotStatus.Playing;
                    switch (MatchSetup.Match.matchTeamType)
                    {
                    case MatchTeamTypes.TagTeamVs:
                    case MatchTeamTypes.TeamVs:
                        MatchSetup.Match.slotTeam[i] = i % 2 == 0 ? SlotTeams.Blue : SlotTeams.Red;
                        break;
                    }
                }

                bScoreFrame[] frames = new bScoreFrame[player_count];
                for (int i = 0; i < player_count; i++)
                {
                    frames[i] = new bScoreFrame {
                        id = (byte)i, pass = true, currentHp = 200
                    }
                }
                ;

                RunBackgroundThread(delegate
                {
                    Thread.Sleep(5000);

                    for (int i = 0; i < player_count; i++)
                    {
                        PlayerVs.MatchPlayerSkipped(i);
                        Thread.Sleep(100);
                    }

                    Thread.Sleep(2000);

                    Player.QueueSkip();
                    Player.Instance?.DoSkip();

                    PlayerVs.AllPlayersLoaded    = true;
                    PlayerVs.AllPlayersCompleted = true;

                    while (true)
                    {
                        byte player = (byte)RNG.Next(0, player_count);

                        switch (RNG.Next(0, 30))
                        {
                        default:
                            frames[player].count300 += 1;
                            frames[player].currentCombo++;
                            frames[player].currentHp += 3;
                            break;

                        case 1:
                        case 2:
                        case 3:
                            frames[player].count100 += 1;
                            frames[player].currentCombo++;
                            frames[player].currentHp += 2;
                            break;

                        case 4:
                        case 5:
                            frames[player].count50   += 1;
                            frames[player].currentHp += 1;
                            frames[player].currentCombo++;
                            break;

                        case 6:
                            frames[player].countMiss   += 1;
                            frames[player].currentHp   -= 50;
                            frames[player].currentCombo = 0;
                            break;
                        }

                        frames[player].currentHp = OsuMathHelper.Clamp(frames[player].currentHp, 0, 200);

                        if (frames[player].currentHp == 0)
                        {
                            frames[player].pass = false;
                        }
                        else if (frames[player].currentHp > 100)
                        {
                            frames[player].pass = true;
                        }

                        frames[player].totalScore += frames[player].currentCombo * 300;
                        frames[player].maxCombo    = Math.Max(frames[player].maxCombo, frames[player].currentCombo);


                        PlayerVs.MatchScoreUpdate(frames[player]);

                        Thread.Sleep(50);
                    }
                });
            }

            switch (INITIAL_MODE)
            {
            case OsuModes.Play:
                if (BeatmapManager.Current == null)
                {
                    NotificationManager.ShowMessage("Couldn't start in specified test mode because no beatmaps were available.");
                    return;
                }

                ModManager.ModStatus = MODS_TO_USE;

                if (AUTOMATIC_SKIP)
                {
                    GameBase.RunBackgroundThread(delegate
                    {
                        while (true)
                        {
                            if (Player.Instance != null && Player.Instance.Status != PlayerStatus.Busy)
                            {
                                Scheduler.Add(delegate { Player.Instance?.DoSkip(); });
                                if (Player.HasSkipped)
                                {
                                    break;
                                }
                            }

                            Thread.Sleep(200);
                        }
                    });
                }

                if (AUTOPLAY)
                {
                    ModManager.ModStatus |= Mods.Autoplay;
                }

                break;
            }

            QueuedMode  = INITIAL_MODE;
            Player.Mode = INITIAL_PLAY_MODE;
        }
    }