Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        FenceHealth health = other.gameObject.GetComponent <FenceHealth>();

        if (health != null)
        {
            targetsHealth = health;
            onCollidedWithFence?.Invoke();
        }
    }
Example #2
0
    private void Start()
    {
        _healthBarSlider = _healthBarGameObject.GetComponent <Slider>();
        _health          = gameObject.GetComponent <FenceHealth>();

        if (_health == null)
        {
            Debug.LogError("Attach Health script");
        }

        _repairPopUpGameObject.SetActive(false);
        _healthBarGameObject.SetActive(false);

        _health.SetHealthSlider(_healthBarSlider);
        _healthBarPosition = _healthBarGameObject.transform.position;

        status = FenceStatus.Fixed;

        _health.OnFenceDestroyed += FenceIsDestroyed;
        _health.OnFenceDamaged   += FenceDamaged;

        CameraFollow.CameraFollowInstance.OnCameraMoved  += DisableFenceUI;
        CameraFollow.CameraFollowInstance.OnCameraOnCamp += EnableFenceUI;
    }
Example #3
0
 private void OnTriggerExit(Collider other)
 {
     targetsHealth = null;
 }