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); } }); } }
private void Start() { WebSocketListener.Instance().Subscribe(this); LobbyInfoController lobby = LobbyInfoController.Instance(); updateLobbyName(lobby.msg.id); }
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())); }
public void ReadyUp() { var lobbyInfo = LobbyInfoController.Instance(); Api.ReadyUp(lobbyInfo.msg.id, lobbyInfo.playerName, () => { Debug.Log("I'm ready!"); }); }
void Start() { WebSocketListener.Instance(); LobbyInfoController.Instance(); LobbyInfoController.ClearLobbyObject(); LobbyIDInput.onValueChanged.AddListener(UpdateInput); JoinLobbyButton.onClick.AddListener(JoinLobby); JoinLobbyButton.interactable = false; }
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>(); }
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"); }); }
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"); }); } }
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"); }); }); } }
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); } }
public void StartGame() { Api.StartGame(LobbyInfoController.Instance().msg.id, () => { Goto.Go("GameScene"); }); }