Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (_target == null)
        {
            if (Goal != null && _motor.Target != Goal)
            {
                _motor.SetTarget(Goal, 1, 2);
            }

            return;
        }

        // If in range and has energy to attack
        if (Vector3.Distance(transform.position, _target.transform.position) < _weapon.WeaponType.MaxRange &&
            Vector3.Distance(transform.position, _target.transform.position) > _weapon.WeaponType.MinRange &&
            _self.HasEnergy(AttackCost))
        {
            _weapon.Attack(_target.transform);
            _self.UseEnergy(AttackCost);
        }
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     _motor = gameObject.GetComponent <ForceMotor>();
     _motor.SetTarget(TopOfScreen, 1, 2);
 }