This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void Start() | |
| { | |
| _cooldown = GetComponent<CooldownCounter>(); | |
| OnDistanceReached += _cooldown.TriggerCooldown; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Action OnCooldownStarted; | |
| public Action OnCooldownEnded; | |
| public void TriggerCooldown() => OnCooldownStarted?.Invoke(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void Start() | |
| { | |
| _distanceChecker = GetComponent<DistanceChecker>(); | |
| _distanceChecker.OnDistanceReached += StartCooldown; | |
| OnCooldownEnded += () => shouldCount = false; | |
| } | |
| private void Update() | |
| { | |
| if (!shouldCount) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private Action OnCooldownStarted; | |
| private Action OnCooldownEnded; | |
| private void Start() | |
| { | |
| OnCooldownStarted += () => shouldCountCooldown = true; | |
| OnCooldownEnded += () => | |
| { | |
| cooldownCounter = 0; | |
| shouldCountCooldown = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private float cooldown = 5f; | |
| private float cooldownCounter = 0; | |
| private void Update() | |
| { | |
| cooldownCounter += Time.deltaTime; | |
| if (cooldownCounter < cooldown) | |
| return; | |
| CheckRange(); |