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);
                }
            });
        }
    }
Exemplo n.º 2
0
    private void Start()
    {
        WebSocketListener.Instance().Subscribe(this);
        LobbyInfoController lobby = LobbyInfoController.Instance();

        updateLobbyName(lobby.msg.id);
    }
Exemplo n.º 3
0
 public void Initialize()
 {
     gameCode        = LobbyInfoController.Instance().msg.id;
     playerName      = string.Format("DumbAI_{0}", Ais.Count);
     gameObject.name = playerName;
     Ais.Add(this);
     StartCoroutine(WaitThenDo(1, () => JoinLobby()));
 }
Exemplo n.º 4
0
        public void ReadyUp()
        {
            var lobbyInfo = LobbyInfoController.Instance();

            Api.ReadyUp(lobbyInfo.msg.id, lobbyInfo.playerName, () => {
                Debug.Log("I'm ready!");
            });
        }
Exemplo n.º 5
0
 void Start()
 {
     WebSocketListener.Instance();
     LobbyInfoController.Instance();
     LobbyInfoController.ClearLobbyObject();
     LobbyIDInput.onValueChanged.AddListener(UpdateInput);
     JoinLobbyButton.onClick.AddListener(JoinLobby);
     JoinLobbyButton.interactable = false;
 }
Exemplo n.º 6
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>();
    }
Exemplo n.º 7
0
    void Start()
    {
        WebSocketListener.Instance();
        LobbyInfoController.Instance();

        LobbyInfoController.ClearLobbyObject();
        PlayerNameInputField.onValueChanged.AddListener(UpdateInput);
        CreateLobbyButton.onClick.AddListener(CreateLobby);
        CreateLobbyButton.interactable = false;
    }
Exemplo n.º 8
0
    public static LobbyInfoController Instance()
    {
        if (!instance)
        {
            var go = new GameObject(objectName);
            instance = go.AddComponent <LobbyInfoController>();
        }

        return(instance);
    }
Exemplo n.º 9
0
        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");
            });
        }
Exemplo n.º 10
0
 private void JoinLobby()
 {
     if (!string.IsNullOrEmpty(LobbyIDInput.text) && !string.IsNullOrEmpty(PlayerNameInput.text))
     {
         Api.JoinLobby(LobbyIDInput.text, PlayerNameInput.text, (body) => {
             var lobby        = LobbyInfoController.Instance();
             lobby.name       = LobbyInfoController.objectName;
             var lobbyMessage = JsonUtility.FromJson <LobbyMessage>(body);
             lobby.msg        = lobbyMessage;
             lobby.playerName = PlayerNameInput.text;
             sceneChanger.Go("LobbyScene");
         });
     }
 }
Exemplo n.º 11
0
 public void CreateLobby()
 {
     if (!string.IsNullOrEmpty(PlayerNameInputField.text))
     {
         Api.CreateLobby((createRespBody) => {
             Api.JoinLobby(createRespBody, PlayerNameInputField.text, (body) => {
                 var lobbyInfo        = LobbyInfoController.Instance();
                 lobbyInfo.msg        = JsonUtility.FromJson <LobbyMessage>(body);
                 lobbyInfo.playerName = PlayerNameInputField.text;
                 sceneChanger.Go("LobbyScene");
             });
         });
     }
 }
Exemplo n.º 12
0
 public void handleDownStreamMessage(string messageType, string message)
 {
     Debug.Log("Got downstream message: \n" + message);
     if (messageType == MsgTypes.LOBBY)
     {
         var lobbyMsg = JsonUtility.FromJson <LobbyMessage>(message);
         lobbyMsg.readyStatus = parserReadyStatus(message);
         updatePlayers(lobbyMsg.players.ToArray(), lobbyMsg.readyStatus);
     }
     else if (messageType == MsgTypes.GAME_START)
     {
         LobbyInfoController.Instance().gameStartMessage = message;
         Goto.Go("GameScene");
     }
     else
     {
         Debug.Log("Got unhandled message: " + messageType);
     }
 }
Exemplo n.º 13
0
 public void StartGame()
 {
     Api.StartGame(LobbyInfoController.Instance().msg.id, () => {
         Goto.Go("GameScene");
     });
 }