Пример #1
0
    private void OnGUI()
    {
        if (GUILayout.Button("Log"))
        {
            _eventHub.Dispatch(EventId.DebugLog, SimpleEventArgs.Empty);
        }

        if (GUILayout.Button("Error"))
        {
            _eventHub.Dispatch(EventId.DebugLogError, SimpleEventArgs.Empty);
        }

        if (GUILayout.Button("Warning"))
        {
            _eventHub.Dispatch(EventId.DebugLogWarning, new CommonCEventArgs <string>("Warning Warning"));
        }
    }
Пример #2
0
        public async Task Handle(SendRoomState command)
        {
            var room = await _fetcher.Fetch(RoomId.Parse(command.RoomId));

            if (room != null)
            {
                await _eventHub.Dispatch(new RoomStateGenerated()
                {
                    MyPlayerId = command.PlayerId,
                    RoomCode   = room.RoomCode.ToString(),
                    Status     = room.Status.ToString(),
                    Guest      = Convert(room.Guest),
                    Host       = Convert(room.Host)
                });
            }
        }
Пример #3
0
        public async Task Handle(JoinRoom command)
        {
            if (RoomCode.TryParse(command.RoomCode, out RoomCode code, out string error))
            {
                var room = await _fetcher.Fetch(code);

                if (room == null)
                {
                    await _eventHub.Dispatch(new JoinRoomFailed()
                    {
                        PlayerId = command.PlayerId,
                        RoomCode = command.RoomCode,
                        UserName = command.UserName,
                        Reason   = "Room not found"
                    });
                }
                else
                {
                    room.AddGuest(new PlayerId(command.PlayerId), command.UserName, CharacterKey.Parse(command.SelectedCharacter));
                    await _persister.TryStore(room);

                    await _eventHub.DispatchAll(room);
                }
            }