Example #1
0
    private void Update()
    {
        Target = null;
        if (_findTarget.Targets != null && _findTarget.Targets.Any())
        {
            Target = _findTarget.Targets?.First();
        }

        if (Target != null)
        {
            _lookAt.SetTarget(Target.transform.position);
            _agent.destination = Target.transform.position;
        }
        else if (_patrolPoints.Length > 0)
        {
            var currentPatrolPointTarget = _patrolPoints[_currentPatrolPointIndex];
            _agent.destination = currentPatrolPointTarget.transform.position;
            _lookAt.SetTarget(_agent.steeringTarget);

            if (Vector2.Distance(transform.position, _agent.destination) < _targetDistanceOffset)
            {
                _currentPatrolPointIndex++;
                if (_currentPatrolPointIndex >= _patrolPoints.Length)
                {
                    _currentPatrolPointIndex = 0;
                }
            }
        }
    }
Example #2
0
    void FocusCubie(Vector3 pos)
    {
        LookAt camera = Camera.main.GetComponent <LookAt>();

        if (camera != null)
        {
            camera.SetTarget(pos);
        }
    }
Example #3
0
    void FocusCubie(CubeInfo.Cubie cubie)
    {
        Debug.Log("FIX CUBIE: " + cubie.id);
        LookAt camera = Camera.main.GetComponent <LookAt>();

        if (camera != null)
        {
            camera.SetTarget(cubie.transform);
        }
    }
Example #4
0
    void Start()
    {
        bulletPool = GameObject.FindGameObjectWithTag("BulletPool").transform;
        InvokeRepeating("Shoot", 0, 1 / bulletsPerSecond);
        LookAt aim = GetComponent <LookAt>();

        if (aim)
        {
            aim.SetTarget(GameManager.instance.GetPlayer().transform);
        }
    }
    protected void UpdateArrow()
    {
        var target = Pawn.All.Where(e => e.Disease != this).Select(e => e.transform).ClosestTo(transform.position);

        if (!target)
        {
            _targetPointer.gameObject.SetActive(false);
            return;
        }
        _targetPointer.gameObject.SetActive(true);
        _targetPointer.SetTarget(target);
    }
Example #6
0
 public void SetTarget(GameObject newTarget)
 {
     if (newTarget != null)
     {
         tower.enabled  = true;
         cannon.enabled = true;
         tower.SetTarget(newTarget);
         cannon.SetTarget(newTarget);
     }
     else
     {
         tower.enabled  = false;
         cannon.enabled = false;
     }
 }