protected void EvStateEnter(EnemyStateContext context)
    {
        this.context = context;

        // 次の弾幕があるなら Opening, もうなければ Defeated へ遷移します。
        var isFirst = context.CurrentBehavior == null;
        var result  = context.MoveNextBehavior();

        if (result)
        {
            if (!isFirst)
            {
                SoundManager.I.PlaySe(SeKind.EnemyDamaged);
            }
            context.CurrentBehavior.InitializeAsync(context.Api);
            context.ChangeState(Enemy.OpeningStateName);
            context.EventAccepter.OnNextRoundSubject.OnNext(Unit.Default);
        }
        else
        {
            SoundManager.I.PlaySe(SeKind.EnemyDamaged);
            context.ChangeState(Enemy.DefeatedStateName);
            context.EventAccepter.OnEnemyDefeatedSubject.OnNext(Unit.Default);
        }
    }
    protected new void EvStateEnter(EnemyStateContext context)
    {
        base.EvStateEnter(context);

        GameManager.I.GameEvents.OnEnemyEntersSafeArea
        .Subscribe(u => context.ChangeState(Enemy.NeutralStateName))
        .AddTo(Disposable);
    }
    protected void EvStateEnter(EnemyStateContext context)
    {
        this.context = context;

        disposable = GameManager.I.GameEvents.OnRoundStart
                     .Delay(TimeSpan.FromSeconds(0.4))
                     .Subscribe(u =>
        {
            context.CurrentBehavior.Start();
            context.ChangeState(Enemy.NeutralStateName);
        });
    }
    /// <summary>
    /// 敵が弾幕パターンを攻略された時に呼ばれるイベント。
    /// </summary>
    /// <param name="context">Context.</param>
    private static void OnDamaged(EnemyStateContext context)
    {
        context.Enemy.Rigidbody.velocity = Vector3.zero;
        context.BulletRenderer.Clear();

        if (context.CurrentBehavior != null)
        {
            context.CurrentBehavior.Stop();
        }

        SoundManager.I.PlaySe(SeKind.EnemyDamaged);
        context.ChangeState(Enemy.NextRoundStateName);
    }
Пример #5
0
    /// <summary>
    /// 敵キャラクターのステートを初期化し、動作を開始します。
    /// </summary>
    public void StartEnemyAction()
    {
        var api = new EnemyApi(Enemy)
        {
            BulletRenderer = bulletRenderer
        };
        var context = new EnemyStateContext
        {
            Api            = api,
            BulletRenderer = bulletRenderer,
            Enemy          = Enemy,
            InitialPos     = Enemy.InitialPosition,
            EventAccepter  = eventFacade,
            Behaviors      = EnemyStrategy.GetBehaviors(api).GetEnumerator()
        };

        context.ChangeState(Enemy.NextRoundStateName);
    }
 private static void OnPlayerDamaged(EnemyStateContext context)
 {
     context.CurrentBehavior.Stop();
     context.ChangeState(Enemy.WinStateName);
 }