示例#1
0
    private void Update()
    {
        switch (_currentState)
        {
        case LungeState.Preparing:
        {
            _timer.Update(Time.deltaTime);
        }
        break;

        case LungeState.Attacking:
        {
            if (!_wallCollision)
            {
                // Move our position a step closer to the target.
                float step = _speed * Time.deltaTime;      // calculate distance to move
                transform.position = Vector3.MoveTowards(transform.position, _positionToAttack, step);
            }

            // Check if the position of the cube and sphere are approximately equal.
            if (_wallCollision || Vector3.Distance(transform.position, _positionToAttack) < 0.001f)
            {
                _currentAttack++;

                if (_wallCollision)
                {
                    _wallCollision = false;
                }


                if (_currentAttack >= _attacksAmount)
                {
                    FinishAttack();
                }
                else
                {
                    _currentState = LungeState.Preparing;
                    _timer.Reset();
                }
            }
        }
        break;
        }
    }
示例#2
0
 private void Attack()
 {
     _currentState     = LungeState.Attacking;
     _positionToAttack = _target.position;
     _audioSource.Play();
 }
示例#3
0
 private void OnEnable()
 {
     _currentState  = LungeState.Preparing;
     _currentAttack = 0;
     _timer.StartCountDown(_preparingTime, Attack);
 }
示例#4
0
    protected virtual void BuildFSM() //To Finish
    {
        phase2 = false;

        //Phase 1 Stuff
        BossIdleState bossIdle = new BossIdleState();

        bossIdle.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        bossIdle.AddTransitionState(FSMStateID.Phase2Setup, FSMTransitions.HealthLessThanThreshold);
        //---------------------------------
        bossIdle.AddTransitionState(FSMStateID.LashReady, FSMTransitions.InMeleeRange);
        bossIdle.AddTransitionState(FSMStateID.Projectile, FSMTransitions.GreaterThanRad2);
        bossIdle.AddTransitionState(FSMStateID.Roar, FSMTransitions.PlayerInRangeTooLong);

        LashReadyState lashReady = new LashReadyState(shootChance);

        lashReady.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        lashReady.AddTransitionState(FSMStateID.Lash, FSMTransitions.InRad1);
        lashReady.AddTransitionState(FSMStateID.Projectile, FSMTransitions.OORad1AndChance);
        lashReady.AddTransitionState(FSMStateID.Lunge, FSMTransitions.InRad2);

        LashState lash = new LashState();

        lash.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        lash.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.BehaviorComplete);

        LungeState lunge = new LungeState();

        lunge.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        lunge.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.BehaviorComplete);

        ProjectileAttackState projectile = new ProjectileAttackState("BossBulletPhase1");

        projectile.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        projectile.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.BehaviorComplete);

        RoarState roar = new RoarState();

        roar.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        roar.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.BehaviorComplete);

        SetupPhase2State phase2Setup = new SetupPhase2State();

        phase2Setup.AddTransitionState(FSMStateID.BossDead, FSMTransitions.OutOfHealth);
        phase2Setup.AddTransitionState(FSMStateID.BossIdlePhase2, FSMTransitions.BehaviorComplete);

        BossDeadState dead = new BossDeadState();

        AddFSMState(bossIdle);
        AddFSMState(projectile);
        AddFSMState(roar);
        AddFSMState(lashReady);
        AddFSMState(lash);
        AddFSMState(lunge);
        AddFSMState(phase2Setup);
        AddFSMState(dead);

        #region Depricated Code

        /* GrappleLashState grappleLash = new GrappleLashState();
         * grappleLash.AddTransitionState(FSMStateID.Lunge, FSMTransitions.PlayerOutOfRange);
         * //---------------------------------
         * grappleLash.AddTransitionState(FSMStateID.WallSpawn, FSMTransitions.WallTime);
         * grappleLash.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * grappleLash.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         * LashState lashState = new LashState();
         * lashState.AddTransitionState(FSMStateID.Lunge, FSMTransitions.PlayerOutOfRange);
         * lashState.AddTransitionState(FSMStateID.GrappleLash, FSMTransitions.Phase2LashRange);
         * //---------------------------------
         * lashState.AddTransitionState(FSMStateID.WallSpawn, FSMTransitions.WallTime);
         * lashState.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * lashState.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         *
         * LungeState lungeState = new LungeState();
         * lungeState.AddTransitionState(FSMStateID.Lash, FSMTransitions.PlayerTooClose);
         * lungeState.AddTransitionState(FSMStateID.Projectile, FSMTransitions.PlayerOutOfRange);
         * //-----------------------------------
         * lungeState.AddTransitionState(FSMStateID.WallSpawn, FSMTransitions.WallTime);
         * lungeState.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * lungeState.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         * ProjectileAttackState projectileAttack = new ProjectileAttackState();
         * projectileAttack.AddTransitionState(FSMStateID.Lunge, FSMTransitions.PlayerTooClose);
         * projectileAttack.AddTransitionState(FSMStateID.Tracking, FSMTransitions.Phase2ProjectileRange);
         * //----------------------------------
         * projectileAttack.AddTransitionState(FSMStateID.WallSpawn, FSMTransitions.WallTime);
         * projectileAttack.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * projectileAttack.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         * TrackRoundState trackRoundState = new TrackRoundState();
         * trackRoundState.AddTransitionState(FSMStateID.Lunge, FSMTransitions.PlayerTooClose);
         * //-------------------------------------
         * trackRoundState.AddTransitionState(FSMStateID.WallSpawn, FSMTransitions.WallTime);
         * trackRoundState.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * trackRoundState.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         * WallSpawnState wallSpawnState = new WallSpawnState();
         * wallSpawnState.AddTransitionState(FSMStateID.BossIdle, FSMTransitions.none);
         * wallSpawnState.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);
         *
         * DeadState dead = new DeadState();
         *
         *
         * AddFSMState(projectileAttack);
         * AddFSMState(bossIdle);
         * AddFSMState(lashState);
         * AddFSMState(lungeState);
         * AddFSMState(grappleLash);
         * AddFSMState(trackRoundState);
         * AddFSMState(wallSpawnState);
         * AddFSMState(dead); */
        #endregion
    }