Exemplo n.º 1
0
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            ownerAI.ChaseTarget   = GameSystem.Instance.ActorManager.GetRandomPlayer();
            this.currentDirection = this.GetTargetDirection(owner, ownerAI);

            this.GetObserver(owner)
            .SubscribeWithState3(this, owner, ownerAI, (_, _this, _owner, _ownerAI) =>
            {
                _owner.StatusController.SetMoveSpeedRate(_this.moveSpeedRate);
                _owner.Broker.Publish(RequestMove.Get(_this.currentDirection.ToVector2()));

                if (_this.IsReverse(_owner, _ownerAI))
                {
                    _this.changeDirectionDuration += Time.deltaTime;
                }
                else
                {
                    _this.changeDirectionDuration = 0.0f;
                }

                if (_this.changeDirectionDuration > _this.changeDirectionDelay)
                {
                    _this.changeDirectionDuration = 0.0f;
                    _this.currentDirection        = _this.GetTargetDirection(_owner, _ownerAI);
                }
            })
            .AddTo(this.events);
        }
Exemplo n.º 2
0
        void IActorReactionOnTriggerEnter2D.Do(Actor actor)
        {
            if (!this.includeTags.Contains(actor.tag))
            {
                return;
            }

            Broker.Global.Receive <EndFadeIn>()
            .Take(1)
            .SubscribeWithState2(this, actor, (_, _this, _actor) =>
            {
                Broker.Global.Publish(RequestChangeStage.Get(_this.prefab));
                _actor.Movement.Warp(_this.actorPosition);
                Broker.Global.Publish(RequestFadeOut.Get(_this.direction.ToReverse().ToFadeType(), _this.fadeTimeSeconds));
                Broker.Global.Publish(EndChangeStage.Get());
            });

            Broker.Global.Publish(BeginChangeStage.Get());
            Broker.Global.Publish(RequestFadeIn.Get(this.direction.ToFadeType(), this.fadeTimeSeconds));

            actor.UpdateAsObservable()
            .TakeUntil(Broker.Global.Receive <EndChangeStage>())
            .SubscribeWithState2(this, actor, (_, _this, _actor) =>
            {
                _actor.Broker.Publish(RequestMove.Get(_this.direction.ToVector2()));
            })
            .AddTo(actor);
        }
Exemplo n.º 3
0
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            this.velocity = this.velocities[Random.Range(0, this.velocities.Count)];

            this.GetObserver(owner)
            .SubscribeWithState3(this, owner, ownerAI, (_, _this, _owner, _ownerAI) =>
            {
                _owner.StatusController.SetMoveSpeedRate(_this.moveSpeedRate);
                _owner.Broker.Publish(RequestMove.Get(_this.velocity));
            })
            .AddTo(this.events);
        }
Exemplo n.º 4
0
        void IControllableUserInput.UpdateInput()
        {
            if (this.actor == null)
            {
                return;
            }

            var velocity = new Vector2(Input.GetAxis("Horizontal"), 0.0f);

            if (velocity.sqrMagnitude > 0.0f)
            {
                this.actor.Broker.Publish(RequestMove.Get(velocity));
            }

            var vertical = Input.GetAxis("Vertical");

            if (vertical < 0.0f)
            {
                this.actor.Broker.Publish(RequestFallOneWayPlatforms.Get());
            }

            if (Input.GetButtonDown("InvokeGameEvent"))
            {
                this.actor.Broker.Publish(RequestInvokeGameEvent.Get());
            }

            if (Input.GetButtonDown("Jump"))
            {
                this.actor.Broker.Publish(RequestJump.Get());
            }

            this.PublishRequestFire(InputName.Fire1, 0);
            this.PublishRequestFire(InputName.Fire2, 1);
            this.PublishRequestFire(InputName.Fire3, 2);

            this.PublishRequestTerminationFire(InputName.Fire1, 0);
            this.PublishRequestTerminationFire(InputName.Fire2, 1);
            this.PublishRequestTerminationFire(InputName.Fire3, 2);
        }