Пример #1
0
        /// <summary>
        /// Update is called once per frame.
        /// </summary>
        void Update()
        {
            if (_healthHelper == null)
            {
                _healthHelper = GameObject.FindObjectOfType <HealthHelper>();
            }
            else
            {
                transform.position = Vector2.MoveTowards(transform.position,
                                                         _healthHelper.transform.position,
                                                         Time.deltaTime * 10f);

                if (Vector2.Distance(transform.position, _healthHelper.transform.position) < 0.1f)
                {
                    _healthHelper.GetHit(Damage);
                    Destroy(gameObject);
                }
            }
        }
Пример #2
0
 private void GetHitbyHero()
 {
     _healthHelper.GetHit(Damage);
 }