コード例 #1
0
ファイル: ChasePlayer.cs プロジェクト: gif-hara/Bright2
        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);
        }
コード例 #2
0
ファイル: RequestFire.cs プロジェクト: gif-hara/Bright2
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            this.GetObserver(owner)
            .SubscribeWithState2(this, owner, (_, _this, _owner) =>
            {
                _owner.Broker.Publish(Messages.RequestFire.Get(_this.equipmentIndex));
            })
            .AddTo(this.events);
        }
コード例 #3
0
ファイル: ChangeAI.cs プロジェクト: gif-hara/Bright2
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            this.GetObserver(owner)
            .SubscribeWithState2(this, owner, (_, _this, _owner) =>
            {
                ownerAI.ChangeAI(this.nextAIName);
            })
            .AddTo(this.events);
        }
コード例 #4
0
ファイル: ChasePlayer.cs プロジェクト: gif-hara/Bright2
        private Constants.Direction GetTargetDirection(Actor owner, ActorAIController ownerAI)
        {
            var result = new Vector2(ownerAI.ChaseTarget.CachedTransform.position.x - owner.CachedTransform.position.x, 0.0f).GetHorizontalDirection();

            if (!this.isChase)
            {
                result = result.ToReverse();
            }

            return(result);
        }
コード例 #5
0
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            this.GetObserver(owner)
            .SubscribeWithState2(this, owner, (_, _this, _owner) =>
            {
                _owner.Broker.Publish(RequestJump.Get());
            })
            .AddTo(this.events);
        }
コード例 #6
0
 public virtual void Enter(Actor owner, ActorAIController ownerAI)
 {
     if (this.instanceConditions == null)
     {
         this.instanceConditions = new List <IObservable <Unit> >(this.conditions.Count);
         foreach (var condition in this.conditions)
         {
             var instance = UnityEngine.Object.Instantiate(condition);
             this.instanceConditions.Add(instance.Satisfy(owner, ownerAI));
         }
     }
 }
コード例 #7
0
ファイル: AddItemModifier.cs プロジェクト: gif-hara/Bright2
 public override void Exit(Actor owner, ActorAIController ownerAI)
 {
     base.Exit(owner, ownerAI);
     if (this.removeOnExit)
     {
         for (var i = 0; i < this.addCount; i++)
         {
             foreach (var o in this.itemModifiers)
             {
                 owner.StatusController.RemoveOtherItemModifier(o);
             }
         }
     }
 }
コード例 #8
0
ファイル: RandomMove.cs プロジェクト: gif-hara/Bright2
        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);
        }
コード例 #9
0
ファイル: AddItemModifier.cs プロジェクト: gif-hara/Bright2
        public override void Enter(Actor owner, ActorAIController ownerAI)
        {
            base.Enter(owner, ownerAI);

            this.addCount = 0;

            this.GetObserver(owner)
            .SubscribeWithState2(this, owner, (_, _this, _owner) =>
            {
                foreach (var i in _this.itemModifiers)
                {
                    owner.StatusController.AddOtherItemModifier(i);
                }

                _this.addCount++;
            })
            .AddTo(this.events);
        }
コード例 #10
0
ファイル: ChasePlayer.cs プロジェクト: gif-hara/Bright2
        private bool IsReverse(Actor owner, ActorAIController ownerAI)
        {
            var direction = owner.StatusController.Direction;

            if (!this.isChase)
            {
                direction = direction.ToReverse();
            }

            var diff = ownerAI.ChaseTarget.CachedTransform.position.x - owner.CachedTransform.position.x;

            if ((direction == Constants.Direction.Left && diff > 0.0f) || (direction == Constants.Direction.Right && diff < 0.0f))
            {
                return(true);
            }

            return(false);
        }
コード例 #11
0
        private bool SatisfyFromDistance(Actor owner, ActorAIController ownerAI)
        {
            var diff = (ownerAI.ChaseTarget.CachedTransform.position - owner.CachedTransform.position).sqrMagnitude;
            var d    = this.distance * this.distance;

            switch (this.type)
            {
            case CompareType.Greater:
                return(d < diff);

            case CompareType.Less:
                return(d > diff);

            default:
                Assert.IsTrue(false, $"{this.type}は未対応です");
                return(false);
            }
        }
コード例 #12
0
 public override IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI)
 {
     return(owner.UpdateAsObservable().Where(_ => this.SatisfyFromDistance(owner, ownerAI)));
 }
コード例 #13
0
ファイル: TakeDamage.cs プロジェクト: gif-hara/Bright2
 public override IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI)
 {
     return(owner.Broker.Receive <TakedDamage>().AsUnitObservable());
 }
コード例 #14
0
ファイル: Interval.cs プロジェクト: gif-hara/Bright2
 public override IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI)
 {
     return(Observable.Interval(TimeSpan.FromSeconds(this.seconds)).AsUnitObservable());
 }
コード例 #15
0
 public virtual void Exit(Actor owner, ActorAIController ownerAI)
 {
     this.events.Clear();
 }
コード例 #16
0
 public abstract IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI);
コード例 #17
0
ファイル: Landed.cs プロジェクト: gif-hara/Bright2
 public override IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI)
 {
     return(owner.Broker.Receive <Messages.Landed>().AsUnitObservable());
 }
コード例 #18
0
ファイル: ChasePlayer.cs プロジェクト: gif-hara/Bright2
 public override void Exit(Actor owner, ActorAIController ownerAI)
 {
     base.Exit(owner, ownerAI);
     ownerAI.ChaseTarget = null;
 }
コード例 #19
0
ファイル: Once.cs プロジェクト: gif-hara/Bright2
 public override IObservable <Unit> Satisfy(Actor owner, ActorAIController ownerAI)
 {
     return(owner.UpdateAsObservable().Take(1));
 }