예제 #1
0
 private void OnEnable()
 {
     GameRegistry.Spawn(this);
     _prevPos     = transform.position;
     IsDead       = false;
     IsPastPlayer = false;
 }
예제 #2
0
        private void Update()
        {
            var pos       = transform.position;
            var direction = pos - _prevPos;

            if (direction.sqrMagnitude > 0.001f)
            {
                transform.LookAt(transform.position + direction, Vector3.up);
                _prevPos = pos;
            }

            if (transform.position.z < 0.5f && !IsPastPlayer)
            {
                var directionSign = Path == EnemyPath.Left ? -1f : 1f;
                if (!(_player.LeanState > 0f != directionSign > 0f && Mathf.Abs(_player.LeanState) > 0.5f))
                {
                    MessageManager.SendEvent(new PlayerDamagedEvent {
                        Damage = Damage, Source = this
                    });
                }
                IsPastPlayer = true;
                GameRegistry.Remove(this);
            }
        }
예제 #3
0
 private void OnDisable()
 {
     GameRegistry.Remove(this);
 }