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

        updateLobbyName(lobby.msg.id);
    }
Ejemplo 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()));
 }
Ejemplo n.º 4
0
        public void ReadyUp()
        {
            var lobbyInfo = LobbyInfoController.Instance();

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

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

        return(instance);
    }
Ejemplo 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");
            });
        }
Ejemplo 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");
         });
     }
 }
Ejemplo 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");
             });
         });
     }
 }
Ejemplo 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);
     }
 }
Ejemplo n.º 13
0
 public void StartGame()
 {
     Api.StartGame(LobbyInfoController.Instance().msg.id, () => {
         Goto.Go("GameScene");
     });
 }