Ejemplo n.º 1
0
 public RoomSettings(ActiveRoomState activeRoomState) : this()
 {
     BetChoice      = activeRoomState.BetChoice;
     CapacityChoice = activeRoomState.CapacityChoice;
     UserInfos      = activeRoomState.UserInfos;
     MyTurn         = activeRoomState.MyTurnId;
 }
Ejemplo n.º 2
0
 private void LoadAppropriateModules(ActiveRoomState activeRoomState)
 {
     if (activeRoomState == null)
     {
         new LobbyController();
         Debug.Log("attempt to create and forget Lobby");
     }
     else
     {
         new RoomSettings(activeRoomState);
         RoomController.Create(activeRoomState).Forget();
     }
 }
Ejemplo n.º 3
0
    public void InitGame(PersonalFullUserInfo myFullUserInfo, ActiveRoomState activeRoomState,
                         int messageIndex)
    {
        Debug.Log("InitGame is being called");

        Repository.I.PersonalFullInfo = myFullUserInfo;

        Repository.I.PersonalFullInfo.DecreaseMoneyAimTimeLeft().Forget();

        this.messageIndex = messageIndex;

        LoadAppropriateModules(activeRoomState);
    }
Ejemplo n.º 4
0
        private async Task InitClientGame(ActiveRoomState activeRoomState)
        {
            var user = await _masterRepo.GetUserByIdAsyc(Context.UserIdentifier);

            var clientPersonalInfo = Mapper.ConvertUserDataToClient(user);

            //you travel to db 2 more times
            clientPersonalInfo.Followers =
                await _masterRepo.GetFollowersAsync(Context.UserIdentifier);

            clientPersonalInfo.Followings =
                await _masterRepo.GetFollowingsAsync(Context.UserIdentifier);

            await Clients.Caller.SendAsync("InitGame", ++ActiveUser.MessageIndex, clientPersonalInfo, activeRoomState, ActiveUser.MessageIndex);
        }
Ejemplo n.º 5
0
    //A. this is registering the services
    //meaning all I is resolved

    //Q. can we pass params to services?

    //B.
    //the initialization issue, this should be after injection, means after awake
    private async UniTask Initialize(ActiveRoomState activeRoomState)
    {
        // Controller.I.OnAppPause += DestroyModuleGroup;

        var containerRoot = new GameObject("Room").transform;

        new RoomReferences();
        RoomReferences.I.Canvas = (await Addressables.InstantiateAsync("canvas", containerRoot))
                                  .GetComponent <Transform>();
        RoomReferences.I.Root = containerRoot;

        PrizeView.Create();

        await ChatSystem.Create();

        await Ground.Create();

        new CoreGameplay();

        new RoomUserView.Manager();

        //dependent on RoomSettings
        //this will make registering requires order, so no circular dependencies possible

        RoomUserView.Manager.I.Init();

        await CoreGameplay.I.CreatePlayers();

        Repository.I.PersonalFullInfo.Money -= RoomSettings.I.BetMoneyToPay();

        Background.I.SetForRoom(RoomSettings.I.UserInfos);

        // AssignRpcs();

        if (activeRoomState == null)
        {
            Controller.I.SendAsync("Ready").Forget(e => throw e);
        }
        else
        {
            //todo why this
            // await UniTask.DelayFrame(1);

            CoreGameplay.I.ResumeGame(activeRoomState.MyHand, activeRoomState.Ground,
                                      activeRoomState.HandCounts,
                                      activeRoomState.CurrentTurn);
        }
    }
Ejemplo n.º 6
0
        public override async Task OnConnectedAsync()
        {
            _logger.LogInformation($"connection established: {Context.UserIdentifier}");

            ActiveRoomState activeRoomState = null;

            if (_sessionRepo.IsUserActive(Context.UserIdentifier))
            {
                activeRoomState = await _roomManager.GetFullRoomState(RoomUser);

                ActiveUser.IsDisconnected = false;
            }
            else
            {
                CreateActiveUser();
            }

            await InitClientGame(activeRoomState);

            await base.OnConnectedAsync();
        }
Ejemplo n.º 7
0
    // public RoomController(ActiveRoomState activeRoomState) : this()
    // {
    //     new RoomSettings(activeRoomState.BetChoice, activeRoomState.CapacityChoice, activeRoomState.UserInfos,
    //         activeRoomState.MyTurnId);
    //
    //     Initialize(activeRoomState).Forget();
    // }
    // public RoomController(int betChoice, int capacityChoice, List<FullUserInfo> userInfos, int myTurn) : this()
    // {
    //     new RoomSettings(betChoice, capacityChoice, userInfos, myTurn);
    //
    //     Initialize(null).Forget();
    // }

    public static async UniTaskVoid Create(ActiveRoomState activeRoomState)
    {
        var roomController = new RoomController();
        await roomController.Initialize(activeRoomState);
    }