コード例 #1
0
 public bReplayFrameBundle(List <bReplayFrame> frames, ReplayAction action, bScoreFrame scoreFrame, int extra)
 {
     ReplayFrames = frames;
     Action       = action;
     ScoreFrame   = scoreFrame;
     Extra        = extra;
 }
コード例 #2
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>();
        }
コード例 #3
0
 public BanchoReplayFrameBundle(ReplayAction action, BanchoScoreFrame scoreFrame,
                                IEnumerable <BanchoReplayFrame> replayFrames, int extra = 0)
 {
     Action            = action;
     CurrentScoreState = scoreFrame;
     ReplayFrames      = replayFrames.ToList();
     ExtraData         = extra;
 }
コード例 #4
0
        /// <summary>
        /// Adds the given <see cref="ReplayAction" /> to the current frame.
        /// </summary>
        /// <param name="action"></param>
        public void RecordAction(ReplayAction action)
        {
            if (!IsRecording)
            {
                throw new InvalidOperationException("Could not record action: recording not started.");
            }

            _frame.Actions.Add(action);
        }
コード例 #5
0
    ReplayAction getNext()
    {
        int total = actionRecords.Count;

        if (current >= total)
        {
            return(null);
        }

        ReplayAction ret = new ReplayAction(actionRecords[current], actionRecords[current + 1], actionRecords[current + 2]);

        current += 3;

        return(ret);
    }
コード例 #6
0
    public void Setup(RoomHistory room, GameBaseInfo baseInfo, List <int> records)
    {
        actionRecords = records;
        mRoom         = room;
        mBaseInfo     = baseInfo;

        current    = 0;
        lastAction = null;

        mCount = baseInfo.mahjongs.Count;
        foreach (GameSeatInfo seat in baseInfo.game_seats)
        {
            mCount -= seat.holds.Count + seat.flowers.Count;
        }
    }
コード例 #7
0
        public static void PushNewFrame(bReplayFrame f)
        {
            if (!HasSpectators && waitingOutgoingFrames.Count > 0)
            {
                waitingOutgoingFrames.Clear();
                return;
            }

            waitingOutgoingFrames.Add(f);

            if (waitingOutgoingFrames.Count >= 30)
            {
                PurgeFrames(queuedAction);
                queuedAction = ReplayAction.Standard;
            }
        }
コード例 #8
0
        public void ReadFromStream(SerializationReader r)
        {
            ExtraData = r.ReadInt32();

            ReplayFrames = new List <BanchoReplayFrame>();
            int length = r.ReadUInt16();

            for (int i = 0; i < length; i++)
            {
                var f = new BanchoReplayFrame();
                f.ReadFromStream(r);
                ReplayFrames.Add(f);
            }

            Action = (ReplayAction)r.ReadByte();

            (CurrentScoreState = new BanchoScoreFrame()).ReadFromStream(r);
        }
コード例 #9
0
    public void gotoAction(int id)
    {
        current    = 0;
        lastAction = null;

        int total = actionRecords.Count / 3;

        if (id >= total)
        {
            Debug.Log("replaymgr id > total");
            return;
        }

        int cnt = 0;

        while (cnt < id)
        {
            takeAction(true);
            cnt++;
        }
    }
コード例 #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>();
        }
コード例 #11
0
        public bReplayFrameBundle(Stream s)
        {
            ReplayFrames = new List <bReplayFrame>();

            SerializationReader sr = new SerializationReader(s);


            int frameCount = sr.ReadUInt16();

            for (int i = 0; i < frameCount; i++)
            {
                ReplayFrames.Add(new bReplayFrame(s));
            }

            Action = (ReplayAction)sr.ReadByte();

            try
            {
                ScoreFrame = new bScoreFrame(s);
            }
            catch (Exception)
            { }
        }
コード例 #12
0
        public bReplayFrameBundle(SerializationReader sr)
        {
            if (OsuCommon.ProtocolVersion >= 18)
            {
                Extra = sr.ReadInt32();
            }
            ReplayFrames = new List <bReplayFrame>();

            int frameCount = sr.ReadUInt16();

            for (int i = 0; i < frameCount; i++)
            {
                ReplayFrames.Add(new bReplayFrame(sr));
            }

            Action = (ReplayAction)sr.ReadByte();

            try
            {
                ScoreFrame = new bScoreFrame(sr);
            }
            catch (Exception)
            { }
        }
コード例 #13
0
 public ReplayActionCommand(Invoker _invoker)
 {
     m_Invoker = _invoker;
     SetAction = new ReplayAction();
 }
コード例 #14
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;
            }
        }
コード例 #15
0
    public float takeAction(bool background)
    {
        NetMgr       net = NetMgr.GetInstance();
        RoomMgr      rm  = RoomMgr.GetInstance();
        PomeloClient pc  = net.pc;

        ReplayAction action = getNext();

        if (lastAction != null && lastAction.type == ACTION_TYPE.CHUPAI)
        {
            if (action != null &&
                action.type != ACTION_TYPE.PENG &&
                action.type != ACTION_TYPE.GANG &&
                action.type != ACTION_TYPE.CHI &&
                action.type != ACTION_TYPE.HU)
            {
                int        _uid = rm.getUIDBySeatIndex(lastAction.si);
                JsonObject guo  = new JsonObject();
                guo.Add("userId", _uid);
                guo.Add("seatindex", lastAction.si);
                guo.Add("pai", lastAction.pai);
                if (background)
                {
                    guo.Add("bg", true);
                }

                pc.pseudo("guo_notify_push", guo);
            }
        }

        lastAction = action;

        if (action == null)
        {
            return(0);
        }

        JsonObject turn = new JsonObject();

        turn.Add("turn", action.si);
        if (background)
        {
            turn.Add("bg", true);
        }

        float delay = 1.0f;

        int uid = rm.getUIDBySeatIndex(action.si);

        JsonObject data = new JsonObject();

        data.Add("userId", uid);
        data.Add("userid", uid);
        data.Add("pai", action.pai);
        data.Add("seatindex", action.si);
        if (background)
        {
            data.Add("bg", true);
        }

        switch (action.type)
        {
        case ACTION_TYPE.CHUPAI:
            pc.pseudo("game_chupai_notify_push", data);
            return(1.0f);

        case ACTION_TYPE.MOPAI:
            bool flower = false;
            if (action.pai >= 45)
            {
                pc.pseudo("game_af_push", data);
                flower = true;
            }
            else
            {
                pc.pseudo("game_mopai_push", data);
                pc.pseudo("game_chupai_push", turn);
            }

            mCount--;

            JsonObject count = new JsonObject();
            count.Add("numofmj", mCount);
            if (background)
            {
                count.Add("bg", true);
            }

            pc.pseudo("mj_count_push", count);

            return(flower ? 2.0f : 1.0f);

        case ACTION_TYPE.PENG:
            pc.pseudo("peng_notify_push", data);
            pc.pseudo("game_chupai_push", turn);
            return(1.0f);

        case ACTION_TYPE.GANG:
            if (!background)
            {
                pc.pseudo("hangang_notify_push", data);
            }

            pc.pseudo("gang_notify_push", data);
            pc.pseudo("game_chupai_push", turn);
            return(1.0f);

        case ACTION_TYPE.CHI:
            pc.pseudo("chi_notify_push", data);
            pc.pseudo("game_chupai_push", turn);
            return(1.0f);

        case ACTION_TYPE.HU:
            data.Add("hupai", action.pai);
            data.Add("iszimo", false);
            data.Add("target", -1);
            pc.pseudo("hu_push", data);
            return(1.5f);

        case ACTION_TYPE.ZIMO:
            data.Add("hupai", action.pai);
            data.Add("iszimo", true);
            pc.pseudo("hu_push", data);
            return(1.5f);

        case ACTION_TYPE.TING:
            pc.pseudo("ting_notify_push", data);
            return(1.0f);

        default:
            break;
        }

        return(delay);
    }
コード例 #16
0
 public void clear()
 {
     lastAction = null;
     current    = 0;
     actionRecords.Clear();
 }
コード例 #17
0
 public bReplayFrameBundle(List <bReplayFrame> frames, ReplayAction action, bScoreFrame scoreFrame)
 {
     ReplayFrames = frames;
     Action       = action;
     ScoreFrame   = scoreFrame;
 }