예제 #1
0
 private void ChangePhaseAOnBullet(int _maxShootQuantity, _bossStateA[] phaseAAlgorithm)
 {
     if (currentShootQuantity >= _maxShootQuantity)
     {
         currentShootQuantity = 0;
         shooterIndex         = 0;
         if (phaseIndex >= phaseAAlgorithm.Length)
         {
             phaseIndex = 0;
         }
         bossSubstateA = phaseAAlgorithm[phaseIndex];
         phaseIndex++;
         nextShoot1    = Time.time;
         nextShoot2    = Time.time;
         nextPhaseTime = Time.time;
     }
 }
예제 #2
0
        void FixedUpdate()
        {
            //find player in case player is dead
            try
            {
                if (player == null)
                {
                    player = GameObject.Find("Player").gameObject;
                }
                //test
                player = GameObject.Find("Player").gameObject;

                playerPosition = new Vector2(player.transform.position.x, player.transform.position.y);
            }
            catch
            {
                //player is dead, do nothing
            }

            //add camera movement to boss
            //transform.position += new Vector3(Camera.main.GetComponent<CameraMovement>().moveSpeed.x, Camera.main.GetComponent<CameraMovement>().moveSpeed.y, 0);

            //check cores for phase change
            if (bossSuperstate == _bossState.SPAWNING || bossSuperstate == _bossState.DEAD)
            {
                //do nothing
            }
            else if (bossSuperstate != _bossState.DEAD && outerCores[0].gameObject == null && outerCores[1].gameObject == null && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore == null)
            {
                bossSuperstate = _bossState.DEAD;
                StartCoroutine(BossDie());
                StartCoroutine(RandomExplosions());
            }
            else if (!hasBeenA && bossSuperstate != _bossState.PHASE_A && outerCores[0].gameObject != null && outerCores[1].gameObject != null && innerCores[0].gameObject != null && innerCores[1].gameObject != null && centerCore != null)
            {
                hasBeenA       = true;
                bossSuperstate = _bossState.PHASE_A;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 1;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }
            else if (!hasBeenF && bossSuperstate != _bossState.PHASE_F && outerCores[0].gameObject == null && outerCores[1].gameObject == null && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore != null)
            {
                hasBeenF       = true;
                hasBeenC       = true;
                bossSuperstate = _bossState.PHASE_F;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 0;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }
            else if (!hasBeenD && bossSuperstate != _bossState.PHASE_D && outerCores[0].gameObject == null && outerCores[1].gameObject == null && centerCore == null)
            {
                hasBeenD       = true;
                hasBeenB       = true;
                hasBeenC       = true;
                bossSuperstate = _bossState.PHASE_D;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 1;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }
            else if (!hasBeenE && bossSuperstate != _bossState.PHASE_E && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore == null)
            {
                hasBeenE       = true;
                hasBeenB       = true;
                bossSuperstate = _bossState.PHASE_E;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 1;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }
            else if (!hasBeenB && bossSuperstate != _bossState.PHASE_B && centerCore == null)
            {
                hasBeenB       = true;
                bossSuperstate = _bossState.PHASE_B;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 1;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }
            else if (!hasBeenC && bossSuperstate != _bossState.PHASE_C && outerCores[0].gameObject == null && outerCores[1].gameObject == null)
            {
                hasBeenC       = true;
                bossSuperstate = _bossState.PHASE_C;
                StartCoroutine(InvulBoss());
                //reset all variables
                currentShootQuantity = 0;
                shooterIndex         = 0;
                phaseIndex           = 1;
                nextShoot1           = Time.time + phaseChangeInvulDuration;
                nextShoot2           = Time.time + phaseChangeInvulDuration;
                nextPhaseTime        = Time.time + phaseChangeInvulDuration;
            }

            switch (bossSuperstate)
            {
            case (_bossState.SPAWNING):
                //change phase
                if (Time.time > nextPhaseTime + spawnTime)
                {
                    nextPhaseTime = Time.time;

                    bossSuperstate = _bossState.PHASE_A;

                    bossSubstateA = phaseAAlgorithm[phaseIndex];
                    ++phaseIndex;
                }
                break;

            case (_bossState.PHASE_A):
                switch (bossSubstateA)
                {
                case (_bossStateA.PHASE_1):
                    //laser shooter
                    if (!hasShotA1 && Time.time >= nextPhaseTime + firstShootA1)
                    {
                        hasShotA1 = true;
                        GameObject _shooter = Instantiate(laserShooter, centerCore.transform.position, transform.rotation);
                        _shooter.transform.parent = gameObject.transform;

                        audioManager.PlaySound(laserShooterSoundName);

                        ShieldBoss();
                    }

                    //change phase
                    if (Time.time >= nextPhaseTime + invulTimeA1 + firstShootA1)
                    {
                        UnshieldBoss();

                        hasShotA1 = false;

                        currentShootQuantity = 0;
                        shooterIndex         = 0;
                        if (phaseIndex >= phaseAAlgorithm.Length)
                        {
                            phaseIndex = 0;
                        }
                        bossSubstateA = phaseAAlgorithm[phaseIndex];
                        phaseIndex++;
                        nextShoot1    = Time.time;
                        nextShoot2    = Time.time;
                        nextPhaseTime = Time.time;
                    }
                    break;

                case (_bossStateA.PHASE_2):
                    //spread shoot
                    if (Time.time >= shootIntervalA2 + nextShoot1 + firstShootA2)
                    {
                        nextShoot1 = Time.time - firstShootA2;

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }

                        if (innerCores[shooterIndex].gameObject != null)
                        {
                            Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position;
                            ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityA2, deviationA2, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedA2);
                        }

                        audioManager.PlaySound(bigBulletSoundName);

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }
                        else if (shooterIndex == 0)
                        {
                            ++shooterIndex;
                        }
                        else
                        {
                            shooterIndex = 0;
                        }

                        ++currentShootQuantity;
                    }

                    ChangePhaseAOnBullet(maxShootQuantityA2, phaseAAlgorithm);
                    break;

                case (_bossStateA.PHASE_3):
                    //missile
                    if (Time.time >= shootIntervalA3 + nextShoot1 + firstShootA3)
                    {
                        nextShoot1 = Time.time - firstShootA3;

                        for (int i = 0; i < 2; i++)
                        {
                            if (outerCores[i].gameObject != null)
                            {
                                Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position;
                                Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f));
                            }
                        }

                        audioManager.PlaySound(homingMissileSoundName);

                        ++currentShootQuantity;
                    }

                    ChangePhaseAOnBullet(maxShootQuantityA3, phaseAAlgorithm);
                    break;
                }
                break;

            case (_bossState.PHASE_B):
                switch (bossSubstateB)
                {
                case (_bossStateB.PHASE_1):
                    //spread shoot
                    if (Time.time >= shootIntervalB1 + nextShoot1 + firstShootB1)
                    {
                        nextShoot1 = Time.time - firstShootB1;

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }

                        if (innerCores[shooterIndex].gameObject != null)
                        {
                            Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position;
                            ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityA2, deviationA2, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedA2);
                        }

                        audioManager.PlaySound(bigBulletSoundName);

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }
                        else if (shooterIndex == 0)
                        {
                            ++shooterIndex;
                        }
                        else
                        {
                            shooterIndex = 0;
                        }

                        ++currentShootQuantity;
                    }

                    ChangePhaseBOnBullet(maxShootQuantityB1, phaseBAlgorithm);
                    break;

                case (_bossStateB.PHASE_2):
                    //missile
                    if (Time.time >= shootIntervalB2 + nextShoot1 + firstShootB2)
                    {
                        nextShoot1 = Time.time - firstShootB2;

                        for (int i = 0; i < 2; i++)
                        {
                            if (outerCores[i].gameObject != null)
                            {
                                Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position;
                                Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f));
                            }
                        }

                        audioManager.PlaySound(homingMissileSoundName);

                        ++currentShootQuantity;
                    }

                    ChangePhaseBOnBullet(maxShootQuantityB2, phaseBAlgorithm);
                    break;

                case (_bossStateB.PHASE_3):
                    //bomb
                    if (!hasShotB3 && Time.time >= nextPhaseTime + firstShootB3)
                    {
                        hasShotB3 = true;
                        for (int i = 0; i < 2; i++)
                        {
                            if (outerCores[i].gameObject != null)
                            {
                                GameObject _bomb = Instantiate(bomb, outerCores[i].transform.position, transform.rotation);
                                //_bomb.transform.parent = gameObject.transform;
                            }
                        }

                        audioManager.PlaySound(bombSoundName);

                        ShieldBoss();
                    }

                    //change phase
                    if (Time.time >= nextPhaseTime + invulTimeB3 + firstShootB3)
                    {
                        UnshieldBoss();

                        hasShotB3 = false;

                        currentShootQuantity = 0;
                        shooterIndex         = 0;
                        if (phaseIndex >= phaseBAlgorithm.Length)
                        {
                            phaseIndex = 0;
                        }
                        bossSubstateB = phaseBAlgorithm[phaseIndex];
                        phaseIndex++;
                        nextShoot1    = Time.time;
                        nextShoot2    = Time.time;
                        nextPhaseTime = Time.time;
                    }

                    break;
                }
                break;

            case (_bossState.PHASE_C):
                switch (bossSubstateC)
                {
                case (_bossStateC.PHASE_1):
                    //spread shoot
                    if (Time.time >= shootIntervalC1 + nextShoot1 + firstShootC1)
                    {
                        nextShoot1 = Time.time - firstShootC1;

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }

                        if (innerCores[shooterIndex].gameObject != null)
                        {
                            Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position;
                            ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityC1, deviationC1, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedC1);
                        }

                        audioManager.PlaySound(bigBulletSoundName);

                        //change bullet spawn position
                        if (innerCores[0].gameObject == null)
                        {
                            shooterIndex = 1;
                        }
                        else if (innerCores[1].gameObject == null)
                        {
                            shooterIndex = 0;
                        }
                        else if (shooterIndex == 0)
                        {
                            ++shooterIndex;
                        }
                        else
                        {
                            shooterIndex = 0;
                        }

                        ++currentShootQuantity;
                    }

                    ChangePhaseCOnBullet(maxShootQuantityC1, phaseCAlgorithm);
                    break;

                case (_bossStateC.PHASE_2):

                    //laser shooter
                    if (!hasShotC2 && Time.time >= nextPhaseTime + firstShootC2)
                    {
                        hasShotC2 = true;
                        GameObject _shooter = Instantiate(laserShooter, centerCore.transform.position, transform.rotation);
                        _shooter.transform.parent = gameObject.transform;

                        audioManager.PlaySound(laserShooterSoundName);

                        ShieldBoss();
                    }

                    //change phase
                    if (Time.time >= nextPhaseTime + invulTimeC2 + firstShootC2)
                    {
                        UnshieldBoss();

                        hasShotC2 = false;

                        currentShootQuantity = 0;
                        shooterIndex         = 0;
                        if (phaseIndex >= phaseCAlgorithm.Length)
                        {
                            phaseIndex = 0;
                        }
                        bossSubstateC = phaseCAlgorithm[phaseIndex];
                        phaseIndex++;
                        nextShoot1    = Time.time;
                        nextShoot2    = Time.time;
                        nextPhaseTime = Time.time;
                    }
                    break;
                }
                break;

            case (_bossState.PHASE_D):
                //spread shoot
                if (Time.time >= shootIntervalD + nextShoot1 + firstShootD)
                {
                    nextShoot1 = Time.time - firstShootD;

                    //change bullet spawn position
                    if (innerCores[0].gameObject == null)
                    {
                        shooterIndex = 1;
                    }
                    else if (innerCores[1].gameObject == null)
                    {
                        shooterIndex = 0;
                    }

                    if (innerCores[shooterIndex].gameObject != null)
                    {
                        Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position;
                        ShootInDirection.Shoot(bigBullet, shotQuantityD, deviationD, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedD, true);
                    }

                    audioManager.PlaySound(bigBulletSoundName);

                    //change bullet spawn position
                    if (innerCores[0].gameObject == null)
                    {
                        shooterIndex = 1;
                    }
                    else if (innerCores[1].gameObject == null)
                    {
                        shooterIndex = 0;
                    }
                    else if (shooterIndex == 0)
                    {
                        ++shooterIndex;
                    }
                    else
                    {
                        shooterIndex = 0;
                    }

                    ++currentShootQuantity;
                }
                break;

            case (_bossState.PHASE_E):
                switch (bossSubstateE)
                {
                case (_bossStateE.PHASE_1):
                    //missile
                    if (Time.time >= shootIntervalE1 + nextShoot1 + firstShootE1)
                    {
                        nextShoot1 = Time.time - firstShootE1;

                        for (int i = 0; i < 2; i++)
                        {
                            if (outerCores[i].gameObject != null)
                            {
                                Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position;
                                Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f));
                            }
                        }

                        audioManager.PlaySound(homingMissileSoundName);

                        ++currentShootQuantity;
                    }

                    ChangePhaseEOnBullet(maxShootQuantityE1, phaseEAlgorithm);
                    break;

                case (_bossStateE.PHASE_2):
                    //bomb
                    if (!hasShotE2 && Time.time >= nextPhaseTime + firstShootE2)
                    {
                        hasShotE2 = true;
                        for (int i = 0; i < 2; i++)
                        {
                            if (outerCores[i].gameObject != null)
                            {
                                GameObject _bomb = Instantiate(bomb, outerCores[i].transform.position, transform.rotation);
                                //_bomb.transform.parent = gameObject.transform;
                            }
                        }

                        audioManager.PlaySound(bombSoundName);

                        ShieldBoss();
                    }

                    //change phase
                    if (Time.time >= nextPhaseTime + invulTimeE2 + firstShootE2)
                    {
                        UnshieldBoss();

                        hasShotE2 = false;

                        currentShootQuantity = 0;
                        shooterIndex         = 0;
                        if (phaseIndex >= phaseEAlgorithm.Length)
                        {
                            phaseIndex = 0;
                        }
                        bossSubstateE = phaseEAlgorithm[phaseIndex];
                        phaseIndex++;
                        nextShoot1    = Time.time;
                        nextShoot2    = Time.time;
                        nextPhaseTime = Time.time;
                    }
                    break;
                }
                break;

            case (_bossState.PHASE_F):
                //rotating laser shooter
                if (Time.time >= shootIntervalF + nextShoot1 + firstShootF)
                {
                    nextShoot1 = Time.time - firstShootF;
                    GameObject _shooter = Instantiate(rotatingLaserShooter, centerCore.transform.position, transform.rotation);
                    _shooter.transform.parent = gameObject.transform;

                    audioManager.PlaySound(laserShooterSoundName);
                }
                break;

            case (_bossState.DEAD):
                //do nothing for now
                break;
            }
        }