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);
        });
    }
    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);
        });
    }
    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);
        });
    }
    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;
    }