Example #1
0
    private void Start()
    {
        readyUpText          = GameObject.Find("ReadyUpText")?.GetComponent <RichText>();
        teamSelectionLineTwo = GameObject.Find("TeamSelectionLineTwo")?.GetComponent <Text>();
        readyUpCount         = GameObject.Find("ReadyUpCount")?.GetComponent <Text>();
        skipText             = GameObject.Find("SkipText")?.GetComponent <RichText>();
        skipCount            = GameObject.Find("SkipCount")?.GetComponent <Text>();
        inTeamSelection      = (tutorialType == TutorialType.TeamSelection &&
                                GameObject.Find("TeamSelection") != null);

        GameManager.instance.notificationManager.CallOnMessage(
            Message.PlayerPressedLeftBumper, () => { if (!inTeamSelection)
                                                     {
                                                         skipReadyUpCheat = true;
                                                     }
            });

        skipTutorialCheckin = PlayerCheckin.TextCountCheckin(
            () => GetPlayers(), Message.PlayerPressedY, skipCount,
            checkoutEvent: Message.PlayerReleasedY);

        if (inTeamSelection)
        {
            StartCoroutine(TeamSelection());
        }
        else if (tutorialType == TutorialType.Sandbox)
        {
            StartCoroutine(Sandbox());
        }
    }
Example #2
0
    public static PlayerCheckin TextCountCheckin(
        CheckinLister lister, Message checkinEvent,
        Text textBox, Predicate allCheckedInPredicate = null,
        EventPredicate checkinPredicate = null,
        Callback onCheckin    = null,
        Callback onReset      = null,
        Message?checkoutEvent = null)
    {
        PlayerCheckin result = new PlayerCheckin(
            lister, checkinEvent, allCheckedInPredicate,
            checkinPredicate, checkoutEvent: checkoutEvent);

        Callback modifyText = () =>
        {
            textBox.text = string.Format("{0}/{1}", result.NumberCheckedIn(), lister().Count);
        };

        onCheckin  = onCheckin ?? delegate { };
        onCheckin += modifyText;

        onReset  = onReset ?? delegate { };
        onReset += modifyText;

        result.onCheckin = onCheckin;
        result.onReset   = onReset;
        return(result);
    }
    public override IMessage OnHotelCheckin(ByteString msg)
    {
        PlayerCheckin checkin = new PlayerCheckin();

        ByteUtils.ByteStringToObject(checkin, msg);
        Logger.Info("PlayerCheckin, gameID:{0} roomID:{1} userID:{2}", checkin.GameID, checkin.RoomID, checkin.UserID);
        return(new PlayerCheckinAck()
        {
            Status = (UInt32)ErrorCode.Ok
        });
    }
 private void Start()
 {
     tutorialCanvas = GameObject.Find("TutorialCanvas").GetComponent <Canvas>();
     if (tutorialCanvas != null)
     {
         ySkip = new PlayerCheckin(() => GetPlayers(), Message.PlayerPressedY,
                                   checkoutEvent: Message.PlayerReleasedY);
         infoText  = tutorialCanvas.FindComponent <RichText>("Info");
         readyText = tutorialCanvas.FindComponent <RichText>("ReadyText");
         StartCoroutine(Clips());
     }
 }
    public override async Task Stream(IAsyncStreamReader <Package.Types.Frame> requestStream, IServerStreamWriter <Package.Types.Frame> responseStream, ServerCallContext context)
    {
        if (GetMetadata(context, out uint userID, out string token) == false)
        {
            Logger.Error("Invalid connection");
            return;
        }
        baseServer.Connect(userID, token);

        try
        {
            while (await requestStream.MoveNext(CancellationToken.None))
            {
                Package.Types.Frame p = (Package.Types.Frame)requestStream.Current;
                var responseTask      = Task.Run(async() =>
                {
                    Package.Types.Frame rep = null;
                    if (p.CmdId == Gvalue.CmdHeartbeat)
                    {
                        rep = p;
                    }
                    else
                    {
                        if (p.CmdId == (UInt32)HotelGsCmdID.HotelCreateConnect ||
                            p.CmdId == (UInt32)HotelGsCmdID.HotelBroadcastCmdid ||
                            p.CmdId == (UInt32)HotelGsCmdID.HotelPlayerCheckin)
                        {
                            if (p.CmdId == (UInt32)HotelGsCmdID.HotelCreateConnect)
                            {
                                Connect connectInfo          = Connect.Parser.ParseFrom(p.Message);
                                hotelMap[connectInfo.RoomID] = responseStream;
                            }
                            else if (p.CmdId == (UInt32)HotelGsCmdID.HotelBroadcastCmdid)
                            {
                                HotelBroadcast broadcast   = HotelBroadcast.Parser.ParseFrom(p.Message);
                                hotelMap[broadcast.RoomID] = responseStream;
                            }
                            else if (p.CmdId == (UInt32)HotelGsCmdID.HotelPlayerCheckin)
                            {
                                PlayerCheckin checkin    = PlayerCheckin.Parser.ParseFrom(p.Message);
                                hotelMap[checkin.RoomID] = responseStream;
                            }
                        }
                        else
                        {
                            if (this.responseStream == null)    //MVS消息只用一个channel返回
                            {
                                this.responseStream = responseStream;
                            }
                        }
                        rep = baseServer.DealMsg(p);
                    }

                    if (rep != null)
                    {
                        await responseStream.WriteAsync(rep);
                    }
                });

                await responseTask;
            }
            Logger.Info("Rcv package over!");
        }
        catch (RpcException e)
        {
            Logger.Info("catch exception: {0}", e);
        }

        Logger.Info("requestTask over!");
        baseServer.Disconnect(userID, token);
    }