Exemplo n.º 1
0
        public virtual bool CastDetection()
        {
            PlayerGhost _ghost = null;

            for (int i = 0; i < fieldOfView.Length; i++)
            {
                int _amount = Physics2D.RaycastNonAlloc(transform.position, transform.rotation * fieldOfView[i], detectionCast, range, detectionMask.value);

                for (int _j = 0; _j < _amount; _j++)
                {
                    if (detectionCast[_j].collider.TryGetComponent(out PlayerController _player))
                    {
                        if (target == null)
                        {
                            PlayDetectionSound();
                        }
                        target          = _player;
                        TargetTransform = detectionCast[_j].collider.transform;
                        return(true);
                    }
                    else if (detectionCast[_j].collider.TryGetComponent(out PlayerGhost _testGhost))
                    {
                        // IS OK
                        _ghost = _testGhost;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (_ghost && target == null)
            {
                target          = _ghost;
                TargetTransform = _ghost.transform;
                PlayDetectionSound();
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public void UpdateState(PlayerGhost _ghost) => _ghost.Move(movement * GameManager.DeltaTime);
Exemplo n.º 3
0
 public void UpdateState(PlayerGhost _ghost) => _ghost.Stop(position);
Exemplo n.º 4
0
 public void UpdateState(PlayerGhost _ghost) => _ghost.Interact();