protected override void Load() { EveryUpdate .Subscribe(_ => transform.LookAt(Vector3.zero)) .AddTo(_disposables); _collision.OnTriggerEnterAsObservable() .Where(it => it.CompareTag("CircleOfFire")) .Do(_ => canMove = false) .Subscribe() .AddTo(_disposables); _collision.OnTriggerExitAsObservable() .Where(it => it.CompareTag("CircleOfFire")) .Do(_ => canMove = true) .Subscribe() .AddTo(_disposables); EveryUpdate .Where(_ => canMove) .Subscribe(_ => transform.Translate(Vector3.forward * Time.deltaTime)) .AddTo(_disposables); Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) .Do(_ => Jump(true)) .Wait(0.5f) .Do(_ => Jump(false)) .Subscribe() .AddTo(_disposables); }
protected override void Load() { _allHumedals = FindObjectsOfType <Humedal>().ToList(); EveryUpdate .Where(_ => _allHumedals.All(it => it.IsBurnt())) .First() .Subscribe(_ => EventStream.Send(Events.Defeat())); }
private void GoTowardsNearestHumedalSubscription() { EveryUpdate .Where(_ => _beingKnockedBackTimer <= 0) .Select(_ => FindClosestAliveHumedal()) .Where(HumedalIsNotNull) .Subscribe(MoveTowardsTarget) .AddTo(_disposables); EveryUpdate .Where(_ => _beingKnockedBackTimer > 0) .Do(_ => _beingKnockedBackTimer -= Time.deltaTime) .Subscribe() .AddTo(_disposables); }
protected override void Load() { _humedales = FindObjectsOfType <Humedal>().ToList(); _actualHumedal = FindClosestAliveHumedal(); transform.position = _actualHumedal.transform.position; GenerateRandomPosition(); EveryUpdate .Where(_ => !_actualHumedal.IsBurnt()) .Where(_ => canMove) .Subscribe(_ => JumpAroundHumedal()) .AddTo(_disposables); EveryUpdate .Where(_ => _actualHumedal.IsBurnt()) .Subscribe(_ => GoToOtherHumedal()) .AddTo(_disposables); }