protected virtual void Awake()
        {
            _detectionAreas = GetComponent <LazyBot.Area.Detection.DetectionAreaContainer>();
            _navigationPath = GetComponent <LazyBot.Navigation.NavigationContainer>();
            _targets        = new LazyBot.Target.Data.TargetInfo();

            _audioContainer = GetComponent <LazyBot.Audio.AudioContainer>();
            _behaviour      = GetComponent <EntityBehaviour>();

            _transform = gameObject.transform;
        }
Exemple #2
0
        private IEnumerator FindTargetsWithDelay(float delay)
        {
            while (true)
            {
                yield return(new WaitForSeconds(delay));

                _onTargetClear.Invoke(this);

                for (int i = 0; i < _data.EnemyTags.Count; i++)
                {
                    GameObject[] targets = GameObject.FindGameObjectsWithTag(_data.EnemyTags[i]);

                    for (int j = 0; j < targets.Length; j++)
                    {
                        int k;
                        // Getting all detectionArea from current target
                        LazyBot.Area.Detection.DetectionAreaContainer dAreas = targets[j].
                                                                               GetComponent <LazyBot.Entity.EntityController>()?.DetectionAreas;

                        foreach (var dArea in dAreas)
                        {
                            for (k = 0; k < _onTargetDetection.Length; k++)
                            {
                                if (!_onTargetDetection[k].Validate(this, dArea))
                                {
                                    break;
                                }
                            }

                            // If one of the targets areas was detected, then there is no sense
                            // to check other because we will grab the same data from them

                            // Could be upgraded with detection mask(on each dArea)
                            // then break will be removed, because we'll get different data from each dArea
                            if ((k == _onTargetDetection.Length) && (_targetType != null))
                            {
                                _onTargetUpdate.Invoke(this, dArea);
                                break;
                            }
                        }
                    }
                }
            }
        }