Ejemplo n.º 1
0
        void Update()
        {
            ITargetable target = targetBehavior.getTarget();

            if (target == null || target.Equals(null))
            {
                return;
            }

            aimBehavior.aimAt(target);
            shootBehavior.shoot();
        }
Ejemplo n.º 2
0
    private void UpdateHealthBar()
    {
        if (_user == null || _user.Equals(null))
        {
            OnDestroyed();
            return;
        }

        //Convert the position of the entity to a viewpoint
        Vector2 viewport = Camera.main.WorldToViewportPoint(_user.GetTransform().position);

        //Calculate the position of the health bar to be above the entity.
        Vector2 position = new Vector2(
            ((viewport.x * _canvas.sizeDelta.x) - (_canvas.sizeDelta.x * 0.5f)),
            ((viewport.y * _canvas.sizeDelta.y) - (_canvas.sizeDelta.y * 0.5f)) + _offset);


        HealthBarRect.anchoredPosition = position;
    }