void Start() { socketIO = FindObjectOfType <SocketConnectionHandler>(); socketIO.OnGameMessage("changeBehaviour", jsonObject => { foreach (GameObject robot in GameObject.FindGameObjectsWithTag("robot")) { if (robot.name == jsonObject["username"]) { robot.GetComponent <RoombaMovement>().SetNavigationMode(jsonObject["behaviour"]); } } }); socketIO.OnGameMessage("submitrobot", jsonObject => { Debug.Log("Built"); JSONArray partsArray = jsonObject["parts"].AsArray; var username = jsonObject["username"]; var robot = GetComponent <BuildRobot>().build(partsArray.ToString(), username); var randomPosition = Random.onUnitSphere * 3f; robot.transform.position = new Vector3(randomPosition.x, 1f, randomPosition.z); }); }
void Start() { SocketIO = FindObjectOfType <SocketConnectionHandler>(); if (SocketIO == null) { throw new MissingComponentException("TitleController needs socket"); } }
void Start() { socketIO = FindObjectOfType <SocketConnectionHandler>(); // add messages to the text box socketIO.OnSocketEvent("game-message", eventData => { TextElement.text = "> " + eventData.data + "\n" + TextElement.text; }); }
public async Task HandleNodeRequest(HttpContext context, WebSocket webSocket) { var connection = new SocketConnectionHandler(container, webSocket, serializer, factory); activeConnections.Add(connection); Console.WriteLine("Connection made"); await connection.ListenForCommands(); Console.WriteLine("Connection lost"); activeConnections.Remove(connection); }
private void socketConnection() { socketIO = FindObjectOfType <SocketConnectionHandler>(); socketIO.OnGameMessage("submitrobot", jsonObject => { JSONArray partsArray = jsonObject["parts"].AsArray; var robot = GetComponent <BuildRobot>().build(partsArray.ToString(), "new-robot"); var randomPosition = Random.onUnitSphere * 3f; robot.transform.position = new Vector3(randomPosition.x, 1f, randomPosition.z); }); }
public void Awake() { if (instance != null) { Debug.LogWarning("There can only be one instance of GameStateManager. Deleting this one"); Destroy(this); } instance = this; Application.quitting += () => appIsQuitting = true; SocketIO = FindObjectOfType <SocketConnectionHandler>(); Assert.IsNotNull(SocketIO, "Game state manager needs reference to socket handler"); }
void Start() { socketIO = FindObjectOfType <SocketConnectionHandler>(); if (socketIO == null) { throw new MissingComponentException("BuildController needs socket"); } submitedRobots = new List <JSONObject>(); socketIO.OnGameMessage("submitrobot", jsonObject => { submitedRobots.Add(jsonObject); }); }
private void Start() { socketIO = FindObjectOfType <SocketConnectionHandler>(); // only show this menu when connected to the server gameObject.SetActive(false); socketIO.OnSocketEvent("connect", (_) => { gameObject.SetActive(true); }); socketIO.OnSocketEvent("disconnect", (_) => { gameObject.SetActive(false); }); }
void Start() { kills = 0; damageDealt = 0; boostsRemaining = 3; socketConnectionHandler = FindObjectOfType <SocketConnectionHandler>(); lastTouched = null; socketConnectionHandler.OnGameMessage("useBoost", jsonObject => { try{ if (jsonObject["username"] == gameObject.name) { UseBoost(); } }catch { //The robot died, so can't process no need to do the check. } }); }
void Start() { socketIO = FindObjectOfType <SocketConnectionHandler>(); if (socketIO == null) { throw new MissingComponentException("BattleController needs socket"); } socketIO.OnGameMessage("changeBehaviour", jsonObject => { foreach (GameObject robot in GameObject.FindGameObjectsWithTag("robot")) { if (robot.name == jsonObject["username"]) { robot.GetComponent <RoombaMovement>().SetNavigationMode(jsonObject["behaviour"]); } } }); FindObjectOfType <JoinGameUI>().GetComponent <CanvasGroup>().alpha = 0f; }
void Start() { textElement = GetComponent <TMPro.TMP_Text>(); Assert.IsNotNull(textElement); socketIO = FindObjectOfType <SocketConnectionHandler>(); Assert.IsNotNull(socketIO); StartCoroutine(ConnectingAnimation()); socketIO.OnSocketEvent("connect", (_) => { StopAllCoroutines(); StartCoroutine(ShowConnectionStatus(true)); }); socketIO.OnSocketEvent("disconnect", (_) => { StopAllCoroutines(); StartCoroutine(ShowConnectionStatus(false)); }); }
void Awake() { if (instance != null) { Destroy(this); } instance = this; robotList = new List <GameObject>(); StateActions = new Dictionary <GameStates, List <Action> >(); foreach (GameStates State in Enum.GetValues(typeof(GameStates))) { StateActions.Add(State, new List <Action>()); } GameState = InitialGameState; Application.quitting += () => appIsQuitting = true; SocketIO = FindObjectOfType <SocketConnectionHandler>(); Assert.IsNotNull(SocketIO, "Game state manager needs reference to socket handler"); }
void Start() { rb = gameObject.GetComponent <Rigidbody>(); socketConnectionHandler = FindObjectOfType <SocketConnectionHandler>(); }
public SocketListener createTcpSocketListener(SocketConnectionHandler socketConnectionHandler, int port) { return new DotNetTcpIpSocketListener(socketConnectionHandler, port); }
public DotNetTcpIpSocketListener(SocketConnectionHandler connectionHandler, int port) : base(connectionHandler, port) { this.port = port; }
public SocketListener createTcpSocketListener(SocketConnectionHandler socketConnectionHandler, int port) { return(new DotNetTcpIpSocketListener(socketConnectionHandler, port)); }