Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void CheckAndGoToCoin()
- {
- float minDistance = Mathf.Infinity;
- Vector3 closestPosition = Vector3.zero;
- IWork _stray = null;
- Coin _coin = null;
- bool waitWhileCoinsDisable = false;
- bool inMove = false;
- foreach (var stray in StrayList)
- {
- Coin coin = _pool.GetClosestEngagedElementsSecondTouch(stray.getTransform().position);
- if (coin == null)
- {
- break;
- }
- float distance = Distance.Manhattan(stray.getTransform().position, coin.GetTransform().position);
- if (stray.GetAiComponent().GeNavMeshAgent().remainingDistance > 0)
- {
- inMove = true;
- }
- if (distance < minDistance)
- {
- _coin = coin;
- minDistance = distance;
- closestPosition = stray.getTransform().position;
- _stray = stray;
- }
- }
- if (_stray != null && Distance.Manhattan(_stray.getTransform().position, _coin.GetTransform().position) < _minDistance)
- {
- inMove = true;
- _stray.Move(_coin.transform.position, () => { _coin.Hide(); CheckAndGoToCoin(); });
- _stray = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement