void Update()
        {
            // If the bot is not available.
            if (_bot == null || _died)
            {
                return;
            }

            // If the robot is confused.
            if (_bot.Move == PossibleMoves.ScriptError)
            {
                RunAnimationOnce(Animations.Defend);
                if (_errorGameObject == null)
                {
                    _errorGameObject = Instantiate(ErrorPrefab);
                    _errorGameObject.transform.SetParent(Head);
                    _errorGameObject.transform.localPosition = new Vector3(0, 0, 0);
                    _errorGameObject.transform.position      = new Vector3(_errorGameObject.transform.position.x, 2.5f, _errorGameObject.transform.position.z);
                }
                return;
            }

            if (_errorGameObject != null)
            {
                Destroy(_errorGameObject);
                _errorGameObject = null;
            }

            float   step = Math.Abs(_bot.X - _bot.FromX) > 1 || Math.Abs(_bot.Y - _bot.FromY) > 1 ? 100 : MovementSpeed * Time.deltaTime;
            Vector3 targetWorldPosition = _arenaController.ArenaToWorldPosition(_bot.X, _bot.Y);
            Vector3 newPos = Vector3.MoveTowards(transform.position, targetWorldPosition, step);

            if ((newPos - transform.position).magnitude > 0.01)
            {
                RunAnimation(Animations.Walk);
                transform.position = newPos;
                return;
            }

            Vector3 targetOrientation = OrientationVector.CreateFrom(_bot.Orientation);
            float   rotationStep      = RotationSpeed * Time.deltaTime;
            Vector3 newDir            = Vector3.RotateTowards(transform.forward, targetOrientation, rotationStep, 0.0F);

            if (targetOrientation != newDir)
            {
                transform.rotation = Quaternion.LookRotation(newDir);
            }

            if ((targetOrientation - newDir).magnitude > 0.01)
            {
                RunAnimation(Animations.Turn);
                return;
            }

            // If the robot has died.
            if (_bot.CurrentHealth <= 0 && _bot.Move != PossibleMoves.SelfDestruct)
            {
                _died = true;
                RunAnimationOnce(Animations.Death);
                _nameTagController.Destroy();
                _healthTagController.Destroy();
                _staminaTagController.Destroy();
                return;
            }

            // If the robot performs a melee attack.
            if (_bot.Move == PossibleMoves.MeleeAttack)
            {
                RunAnimationOnce(Animations.MeleeAttack);
                return;
            }

            // If the robot performs a ranged attack.
            if (_bot.Move == PossibleMoves.RangedAttack)
            {
                if (!_rangeAttackExecuted)
                {
                    _rangeAttackExecuted    = true;
                    _rangedAttackGameObject = Instantiate(RangedAttackPrefab);
                    _rangedAttackGameObject.transform.SetParent(transform);
                    var     rangedAttackController = _rangedAttackGameObject.GetComponent <RangedAttackController>();
                    Vector3 startPos  = _arenaController.ArenaToWorldPosition(_bot.X, _bot.Y);
                    Vector3 targetPos = _arenaController.ArenaToWorldPosition(_bot.LastAttackX, _bot.LastAttackY);
                    rangedAttackController.Fire(startPos, targetPos);
                    RunAnimation(Animations.RangedAttack);
                }
                return;
            }

            // If the robot is self destructing.
            if (_bot.Move == PossibleMoves.SelfDestruct)
            {
                GetComponent <ExplosionController>().Explode();
                RunAnimationOnce(Animations.Death);
                return;
            }

            RunAnimation(Animations.Idle);
        }
        void Update()
        {
            if (BotIsNotAvailable())
            {
                return;
            }

            if (RobotIsConfused())
            {
                RunAnimationOnce(Animations.Defend);
                if (_errorGameObject == null)
                {
                    _errorGameObject = Instantiate(ErrorPrefab);
                    _errorGameObject.transform.SetParent(Head);
                    _errorGameObject.transform.localPosition = new Vector3(0, 0, 0);
                    _errorGameObject.transform.position      = new Vector3(_errorGameObject.transform.position.x, 2.5f, _errorGameObject.transform.position.z);
                }
                return;
            }

            if (_errorGameObject != null)
            {
                Destroy(_errorGameObject);
                _errorGameObject = null;
            }

            Single  step = Math.Abs(_bot.X - _bot.FromX) > 1 || Math.Abs(_bot.Y - _bot.FromY) > 1 ? 100 : Speed * Time.deltaTime;
            Vector3 targetWorldPosition = _arenaController.ArenaToWorldPosition(_bot.X, _bot.Y);
            Vector3 newPos = Vector3.MoveTowards(transform.position, targetWorldPosition, step);

            if ((newPos - transform.position).magnitude > 0.01)
            {
                RunAnimation(Animations.Walk);
                transform.position = newPos;
                return;
            }

            Vector3 targetOrientation = OrientationVector.CreateFrom(_bot.Orientation);
            Single  rotationStep      = RotationSpeed * Time.deltaTime;
            Vector3 newDir            = Vector3.RotateTowards(transform.forward, targetOrientation, rotationStep, 0.0F);

            if (targetOrientation != newDir)
            {
                transform.rotation = Quaternion.LookRotation(newDir);
            }

            if ((targetOrientation - newDir).magnitude > 0.01)
            {
                RunAnimation(Animations.TurnRight);
                return;
            }

            if (RobotHasDied())
            {
                _died = true;
                RunAnimationOnce(Animations.Death);
                _nameTagController.Destroy();
                _healthTagController.Destroy();
                _staminaTagController.Destroy();
                return;
            }

            if (RobotIsAttackingUsingMelee())
            {
                RunAnimationOnce(Animations.MeleeAttack);
                return;
            }

            if (RobotIsAttackingUsingRanged())
            {
                if (!_rangeAttackExecuted)
                {
                    _rangeAttackExecuted    = true;
                    _rangedAttackGameObject = Instantiate(RangedAttackPrefab);
                    _rangedAttackGameObject.transform.SetParent(transform);
                    var     rangedAttackController = _rangedAttackGameObject.GetComponent <RangedAttackController>();
                    Vector3 startPos  = _arenaController.ArenaToWorldPosition(_bot.X, _bot.Y);
                    Vector3 targetPos = _arenaController.ArenaToWorldPosition(_bot.LastAttackX, _bot.LastAttackY);
                    rangedAttackController.Fire(startPos, targetPos);
                    RunAnimation(Animations.RangedAttack);
                }
                return;
            }

            if (RobotIsSelfDestructing())
            {
                GetComponent <ExplosionController>().Explode();
                RunAnimationOnce(Animations.Death);
                return;
            }

            RunAnimation(Animations.Idle);
        }