void Start()
    {
        Api = FindObjectOfType <RestApi>();

        WebSocketListener.Instance().Subscribe(this);

        CardTray = FindObjectOfType <CardTrayBehaviour>();
        CardTray.OnSelected.AddListener(OnCardSelections);

        Board = FindObjectOfType <GameBoardBehaviour>();

        AnimationEngine = FindObjectOfType <AnimationEngineBehaviour>();
        AnimationEngine.OnComplete.AddListener(onAnimationsComplete);

        lobbyInfo = LobbyInfoController.Instance();
        if (lobbyInfo != null && lobbyInfo.msg != null)
        {
            WebSocketListener.Instance().StartListening(lobbyInfo.msg.id, lobbyInfo.playerName, () => {
                Debug.Log("I'm listening...");
                if (lobbyInfo.gameStartMessage != null)
                {
                    handleDownStreamMessage(MsgTypes.GAME_START, lobbyInfo.gameStartMessage);
                }
            });
        }
    }
Esempio n. 2
0
 public void JoinLobby()
 {
     if (PlayerNameInputField.text.Length > 0)
     {
         if (GameCodeInputField.text.Length <= 0)
         {
             GameCodeInputField.text = "GAME";
         }
         addToActivityStream("Attempt to join lobby " + GameCodeInputField.text);
         Api.JoinLobby(GameCodeInputField.text, PlayerNameInputField.text, (resp) => {
             addToActivityStream("Joined lobby " + GameCodeInputField.text);
             WebSocketListener.Instance().StartListening(GameCodeInputField.text, PlayerNameInputField.text,
                                                         () => { addToActivityStream("Made websocket connection"); });
             GameCodeInputField.interactable   = false;
             PlayerNameInputField.interactable = false;
             CreateButton.interactable         = false;
             JoinButton.interactable           = false;
             ReadyButton.interactable          = true;
         });
     }
     else
     {
         addToActivityStream("Failed to join lobby, must have a player name");
     }
 }
    private void Start()
    {
        WebSocketListener.Instance().Subscribe(this);
        LobbyInfoController lobby = LobbyInfoController.Instance();

        updateLobbyName(lobby.msg.id);
    }
Esempio n. 4
0
 void Start()
 {
     WebSocketListener.Instance();
     LobbyInfoController.Instance();
     LobbyInfoController.ClearLobbyObject();
     LobbyIDInput.onValueChanged.AddListener(UpdateInput);
     JoinLobbyButton.onClick.AddListener(JoinLobby);
     JoinLobbyButton.interactable = false;
 }
Esempio n. 5
0
    private void Start()
    {
        WebSocketListener.Instance().Subscribe(this);
        LobbyInfoController lobbyInfo = LobbyInfoController.Instance();

        updatePlayers(lobbyInfo.msg.players.ToArray(), lobbyInfo.msg.readyStatus);
        WebSocketListener.Instance().StartListening(lobbyInfo.msg.id, lobbyInfo.playerName, () => {});
        Goto = FindObjectOfType <GoToScene>();
    }
Esempio n. 6
0
    void Start()
    {
        WebSocketListener.Instance();
        LobbyInfoController.Instance();

        LobbyInfoController.ClearLobbyObject();
        PlayerNameInputField.onValueChanged.AddListener(UpdateInput);
        CreateLobbyButton.onClick.AddListener(CreateLobby);
        CreateLobbyButton.interactable = false;
    }
        public void Leave()
        {
            WebSocketListener.Instance().StopListening();
            var lobbyInfo = LobbyInfoController.Instance();

            Api.LeaveLobby(lobbyInfo.msg.id, lobbyInfo.playerName, () => {
                Debug.Log("I left the lobby");
                Goto.Go("MainMenuScene");
            });
        }
Esempio n. 8
0
        private void Start()
        {
            WebSocketListener.Instance().Subscribe(this);

            cards.AddRange(CardGroup.GetComponentsInChildren <Text>());
            cardButtons.AddRange(CardGroup.GetComponentsInChildren <Button>());

            CreateButton.onClick.AddListener(CreateLobby);
            JoinButton.onClick.AddListener(JoinLobby);
            ReadyButton.onClick.AddListener(ReadyUp);
            StartButton.onClick.AddListener(StartGame);

            ReadyButton.interactable = false;
            StartButton.interactable = false;
            cardButtons.ForEach(b => b.interactable = false);

            PlayerNameInputField.Select();

            debugPrintGameState();
        }
Esempio n. 9
0
 void Start()
 {
     DontDestroyOnLoad(gameObject);
     WebSocketListener.Instance().Subscribe(this);
 }
Esempio n. 10
0
 private void OnDestroy()
 {
     WebSocketListener.Instance().Unsubscribe(this);
 }
Esempio n. 11
0
 private void OnDestroy()
 {
     WebSocketListener.Instance().CancelSubscription(this);
 }
Esempio n. 12
0
 public void Send()
 {
     WebSocketListener.Instance().Send(MessageInputField.text);
 }
Esempio n. 13
0
 public void Disconnect()
 {
     WebSocketListener.Instance().StopListening();
 }
Esempio n. 14
0
 public void Connect()
 {
     WebSocketListener.Instance().StartListening(GAME_ID, PLAYER_NAME, () => { UnityEngine.Debug.Log("Websocket connection successful"); });
 }
Esempio n. 15
0
 private void OnDestroy()
 {
     WebSocketListener.Instance().StopListening();
 }
Esempio n. 16
0
 private void Start()
 {
     WebSocketListener.Instance().Subscribe(this);
 }