void Initialize(ICharacterPosition playerPosition) { playerPosition.Position .Subscribe(x => _enemyCore.UpdateDirection((x - transform.position + Vector3.forward).normalized.XZ())) .AddTo(this); playerPosition.Position .Where(x => (transform.position - x).sqrMagnitude < _nudgeThreshold) .First() .Subscribe(_ => _enemyCore.OnNudge()); }
private void Initialize(ICharacterPosition characterPosition) { var y = transform.position.y; characterPosition.Position.First() .Select(x => transform.position - x) .CombineLatest(characterPosition.Position, (offset, target) => target + offset) .Select(x => { x.y = y; return(x); }) .Subscribe(x => transform.position = x) .AddTo(this); }
void Initialize(ICharacterPosition playerPosition) { var goalPosition = _goal.position; playerPosition.Position.First() .Select(x => (goalPosition - x).sqrMagnitude) .CombineLatest(playerPosition.Position.Select(x => (goalPosition - x).sqrMagnitude), (max, current) => Mathf.Pow(1 - current / max, 3)) .Subscribe(x => { var color = _bg.color; color.a = x; _bg.color = color; }) .AddTo(this); }