void Update()
    {
        var xDirection = Input.GetAxis("Horizontal");
        var yDirection = Input.GetAxis("Vertical");

        var angle = Mathf.Atan2(xDirection, yDirection) * Mathf.Rad2Deg;

        if (xDirection != 0 || yDirection != 0)
        {
            this.transform.rotation = Quaternion.AngleAxis(angle, Vector3.back);
        }

        this.rigidbody2D.velocity = new Vector2(xDirection * speed, yDirection * speed);
        var message = string.Format("{0}|{1}|p|{2}|{3}|{4}|{5}", heroId, heroName, this.transform.position.x, this.transform.position.y, xDirection, yDirection);

        if (message != _oldmessage || timePassedToLive > 10)
        {
            realtimeManager.RealtimeSendMessage(message);
            _oldmessage      = message;
            timePassedToLive = 0;
        }

        timePassedToLive  += Time.deltaTime;
        timePassedToShoot += Time.deltaTime;

        if (timePassedToShoot > 2)
        {
            if (gameManager.enemies.Count > 0)
            {
                GameObject nearestEnemy    = null;
                float      nearestDistance = -1f;

                foreach (var enemy in gameManager.enemies)
                {
                    var newDistance = Vector3.Distance(enemy.Value.transform.position, this.transform.position);
                    if (nearestDistance < 0 || newDistance < nearestDistance)
                    {
                        nearestDistance = newDistance;
                        nearestEnemy    = enemy.Value;
                    }
                }

                var directionVector = nearestEnemy.transform.position - this.transform.position;
                directionVector.Normalize();
                var bullet = (GameObject)GameObject.Instantiate(gameManager.bulletPrefab, this.transform.position, this.transform.rotation);
                bullet.rigidbody2D.velocity = directionVector;
                bullet.GetComponent <BulletScript>().parent     = this.gameObject;
                bullet.GetComponent <BulletScript>().parentName = heroName;
                bullet.GetComponentInChildren <Light>().color   = Color.red;

                realtimeManager.RealtimeSendMessage(string.Format("{0}|{1}|s|{2}|{3}|{4}|{5}", heroId, heroName, this.transform.position.x, this.transform.position.y, directionVector.x, directionVector.y));
                timePassedToShoot = 0;
            }
        }
    }