예제 #1
0
    // Update is called once per frame
    void Update()
    {
        waitTime -= Time.deltaTime;
        if (waitTime <= 0)
        {
            gameObject.tag = "Murder";
            puppet.SetActive(true);
            if (!playedSnd)
            {
                particles.GetComponent <ParticleSystem>().Stop();
                PlaySound.NoLoopRandomPitch(snd, 0.5f, 1.5f);
                playedSnd = true;
            }
        }
        else
        {
            gameObject.tag = "Untagged";
            puppet.SetActive(false);
        }

        if (waitTime <= -0.25f)
        {
            Destroy(gameObject);
        }
    }
예제 #2
0
 void OnMouseEnter()
 {
     if (unlocked && !Game.usingController)
     {
         PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f);
     }
 }
예제 #3
0
 void Update()
 {
     gameObject.GetComponent <LookAtScript>().enabled = (!got);
     gameObject.GetComponent <MoveForward>().enabled  = (!got);
     if (!got && Game.playerObj != null)
     {
         Vector3 playerPos = Game.playerObj.transform.position;
         float   distance  = Vector2.Distance(new Vector2(playerPos.x, playerPos.y), new Vector2(gameObject.transform.position.x, gameObject.transform.position.y));
         if (distance <= 1f)
         {
             Game.coins++;
             Game.currentCoinsCollectedInLevel++;
             Instantiate(gotEffect, transform.position, Quaternion.identity);
             PlaySound.NoLoopRandomPitch(snd, 0.5f, 1.5f);
             got = true;
         }
     }
     else
     {
         Destroy(gameObject, 1f);
     }
 }
예제 #4
0
 void OnMouseEnter()
 {
     PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f);
 }
 public void  Clink()
 {
     PlaySound.NoLoopRandomPitch(snd, 0.75f, 1.25f);
 }
예제 #6
0
    void Update()
    {
        //Debug for unlocking everything for steam test.
        if (Game.debug)
        {
            bool s = Input.GetKey(KeyCode.S);
            bool t = Input.GetKey(KeyCode.T);
            bool e = Input.GetKey(KeyCode.E);
            bool a = Input.GetKey(KeyCode.A);
            bool m = Input.GetKey(KeyCode.M);
            if (s && t && e && a && m)
            {
                Game.UnlockAll();
                SceneManager.LoadScene(0);
            }
        }

        //Check for controller usage.
        Game.ControllerCheck();
        //Debug.Log("Using Controller: " + Game.usingController);

        //When to show the cursor.
        Cursor.visible = !Game.usingController;

        //Setting the scale of the selector.
        if (atRightSettingsMenu)
        {
            selector.transform.localScale = new Vector3(-10f, 0.5f, 1f);
        }
        else
        {
            selector.transform.localScale = new Vector3(5f, 0.5f, 1f);
        }

        //When the gamepad selector is visible.
        gamePadSelector.SetActive(Game.usingController);

        //when menu is fully open.
        if (startTime >= 0)
        {
            startTime -= Time.deltaTime;
        }

        //Light bloom active if light effects are on.
        bloom.enabled = Game.lightEffects;

        //The adventure gamepad selector should have a velocity of 0 if not at the adventure menu, or ot using a controller.
        if (currentMenu != Menu.Adventure || !Game.usingController)
        {
            adventurePadSelector.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
        }

        //Setting the camera positions.
        Vector3[] cPos =
        {
            new Vector3(0,    0, -30),         //0
            new Vector3(0,  -20, -30),         //1
            new Vector3(20,   0, -30),         //2
            new Vector3(20, -20, -30),         //3
            new Vector3(60,   0, -30),         //4
        };
        //If we are the adventure cam, scroll up to the map, else, behave normally.
        if (adventureCam && backFromAdventureTweenCounter <= 0)
        {
            Camera.main.gameObject.transform.position = Vector3.Lerp(Camera.main.gameObject.transform.position, new Vector3(0, 20, -10), 3f * Time.deltaTime);
        }
        else if (!adventureCam && backFromAdventureTweenCounter <= 0)
        {
            Camera.main.gameObject.transform.position = cPos[camState];
        }
        if (backFromAdventureTweenCounter > 0f)
        {
            backFromAdventureTweenCounter -= Time.deltaTime;
        }

        //You have been to the shop... when you go there lel.
        if (currentMenu == Menu.Shop)
        {
            Game.beenToShop = true;
        }
        else
        {
            shopIndex = 0;
        }

        //Set what shop texts to set active if you have coins.
        vektorDead = (Game.beatWhite && !Game.savedVektor);

        if (vektorDead)
        {
            shopMusic.GetComponent <AudioSource>().pitch  = 1f;
            shopMusic.GetComponent <AudioSource>().volume = 0;
            for (int p = 0; p < shopTexts.Length; p++)
            {
                shopTexts[p].SetActive(false);
            }
        }
        else
        {
            if (Game.coins >= 0)
            {
                shopMusic.GetComponent <AudioSource>().pitch = 1f;
                for (int o = 0; o < shopTexts.Length; o++)
                {
                    if (o == shopIndex)
                    {
                        shopTexts[o].SetActive(true);
                    }
                    else
                    {
                        shopTexts[o].SetActive(false);
                    }
                }
            }
            else             //When you have no money, only display debt text.
            {
                shopMusic.GetComponent <AudioSource>().pitch = 0.5f;
                for (int j = 0; j < shopTexts.Length; j++)
                {
                    if (j == 9)
                    {
                        shopTexts[j].SetActive(true);
                    }
                    else
                    {
                        shopTexts[j].SetActive(false);
                    }
                }
            }
        }

        //When to set shop music active.
        shopMusic.SetActive(camState == 3);
        if (!vektorDead)
        {
            shopMusic.GetComponent <AudioSource>().volume = Game.musicVolume;
        }

        //When to set menu music active.
        menuMusic.SetActive(camState != 3);
        if (!startedSwipe)
        {
            menuMusic.GetComponent <AudioSource>().volume = Game.musicVolume;
        }
        else
        {
            if (menuMusic.GetComponent <AudioSource>().volume > 0)
            {
                menuMusic.GetComponent <AudioSource>().volume -= Time.deltaTime * 1.5f;
            }
        }
        //Pitch down the menu music if you are at adventure mode with the final boss visible.
        float pitchSpeed = 1f;

        musicPitch = menuMusic.GetComponent <AudioSource>().pitch;
        if (Game.beatWhite && currentMenu == Menu.Adventure)
        {
            //Debug.Log("going!");
            musicPitch = Mathf.Lerp(musicPitch, 0.5f, pitchSpeed * Time.deltaTime);
        }
        else
        {
            musicPitch = Mathf.Lerp(musicPitch, 1f, pitchSpeed * Time.deltaTime);
        }
        menuMusic.GetComponent <AudioSource>().pitch = musicPitch; //Apply the pitch.

        //Resetting the settings that need resetting of the settings.
        if (Input.GetButton("Reset Controls") && !reset)
        {
            resetTime -= Time.deltaTime;
            if (resetTime <= 0)
            {
                Game.ResetSettings();
                //Debug.Log("Reset");
                reset = true;
            }
        }
        else
        {
            resetTime = 2f;
            reset     = false;
        }

        //The delay before you can select a level in adventure mode is controlled here.
        if (currentMenu == Menu.Adventure)
        {
            if (adventureDelayCounter > -1)
            {
                adventureDelayCounter -= Time.deltaTime;
            }
        }
        else
        {
            adventureDelayCounter = adventureDelayTime;
        }

        //Debug reset level.
        if (Input.GetKeyDown(KeyCode.O) && Game.debug)
        {
            SceneManager.LoadScene(1);
        }

        //How the menu is interacted with by keyboard and mouse.
        if (!Game.usingController)
        {
            //Setting the selector positions.
            Vector3[] sPos =
            {
                new Vector3(-6.5f,      2f, 0),            //1
                new Vector3(-6.5f,    1.5f, 0),            //2
                new Vector3(-6.5f,      1f, 0),            //3
                new Vector3(-6.5f,    0.5f, 0),            //4
                new Vector3(-6.5f,     -1f, 0),            //5
                new Vector3(-6.5f,   -2.5f, 0),            //6
                new Vector3(-6.5f,     -3f, 0),            //7
                new Vector3(-6.5f,   -3.5f, 0),            //8
                new Vector3(-6.5f,     -4f, 0),            //9
                new Vector3(-6.5f,   -4.5f, 0),            //10
                new Vector3(-6.5f,  -24.6f, 0),            //11
                new Vector3(13.5f,   -3.6f, 0),            //12
                new Vector3(13.5f, -22.45f, 0),            //13
                new Vector3(53.6f,   -4.6f, 0),            //14
                new Vector3(24f,     1.95f, 0),            //15
                new Vector3(24f,     1.18f, 0),            //16
            };
            selector.transform.position = sPos[selectorMouseIndex];

            //When you are at the right settings menu.
            atRightSettingsMenu = (currentMenu == Menu.Settings);

            //Selector is visible when on a thing.
            selector.SetActive(onThing && !startedSwipe && startTime < 0);

            //what pics to set active.
            for (int i = 0; i < pics.Count; i++)
            {
                if (i == selectorMouseIndex && onThing && startTime < 0)
                {
                    pics[i].SetActive(true);
                }
                else
                {
                    pics[i].SetActive(false);
                }
            }

            //Clicking.
            if (Input.GetMouseButtonDown(0) && onThing && startTime < 0)
            {
                MenuAction(selectorMouseIndex);
            }
        }
        else             //How the menu is controlled using a controller.
                         //Selector is always active when using a gamepad.
        {
            selector.SetActive(true);

            //Get the controller inputs.
            float x          = Input.GetAxisRaw("Horizontal [Gamepad]");
            float y          = Input.GetAxisRaw("Vertical [Gamepad]");
            float threshHold = 0.5f;

            if (counter > 0)
            {
                counter -= Time.deltaTime;
            }

            switch (currentMenu)
            {
            case Menu.Main:
                Vector3[] sPos =
                {
                    new Vector3(-6.5f,      2f, 0),                        //1
                    new Vector3(-6.5f,    1.5f, 0),                        //2
                    new Vector3(-6.5f,      1f, 0),                        //3
                    new Vector3(-6.5f,    0.5f, 0),                        //4
                    new Vector3(-6.5f,     -1f, 0),                        //5
                    new Vector3(-6.5f,   -2.5f, 0),                        //6
                    new Vector3(-6.5f,     -3f, 0),                        //7
                    new Vector3(-6.5f,   -3.5f, 0),                        //8
                    new Vector3(-6.5f,     -4f, 0),                        //9
                    new Vector3(-6.5f,   -4.5f, 0),                        //10
                    new Vector3(-6.5f,  -24.6f, 0),                        //11
                    new Vector3(13.5f,   -3.6f, 0),                        //12
                    new Vector3(13.5f, -22.45f, 0),                        //13
                };
                selector.transform.position = sPos[gamePadMainIndex];

                //What pics to set active.
                for (int i = 0; i < pics.Count; i++)
                {
                    padLocked = lockedMains.Contains(i);
                    if (i == gamePadMainIndex && startTime < 0 && !padLocked)
                    {
                        pics[i].SetActive(true);
                    }
                    else
                    {
                        pics[i].SetActive(false);
                    }
                }

                if (y < -threshHold && gamePadMainIndex > 0 && counter <= 0)
                {
                    gamePadMainIndex--; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (y > threshHold && gamePadMainIndex < 9 && counter <= 0)
                {
                    gamePadMainIndex++; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (Input.GetButtonDown("Submit") && !lockedMains.Contains(gamePadMainIndex))
                {
                    MenuAction(gamePadMainIndex);
                }
                break;

            case Menu.Settings:

                if (Game.boughtSupporterPack)
                {
                    settingMax = 10;
                }
                else
                {
                    settingMax = 7;
                }

                Vector3[] settingSelectorPos =
                {
                    new Vector3(13.5f,  2.24f, 0),                          //0 sfx
                    new Vector3(13.5f,  1.68f, 0),                          //1 music
                    new Vector3(13.5f,  0.17f, 0),                          //2 light effects
                    new Vector3(13.5f, -0.45f, 0),                          //3 vsync
                    new Vector3(13.5f, -2.03f, 0),                          //4 fullscreen
                    new Vector3(13.5f, -2.61f, 0),                          //5 resolution
                    new Vector3(24f,    1.95f, 0),                          //6 delete adventure mode progress.
                    new Vector3(24f,    1.18f, 0),                          //7 delete all progress.
                    new Vector3(24f,   -1.55f, 0),                          //8 supporter benefits smiley mode.
                    new Vector3(24f,   -2.16f, 0),                          //9 supporter benefits party mode.
                    new Vector3(24f,   -2.79f, 0),                          //10 supporter benefits toot mode.
                };
                selector.transform.position = settingSelectorPos[gamePadSettingsIndex];
                //How the menu works when you are at the left side.
                if (!atRightSettingsMenu)
                {
                    //Clamping index.
                    if (gamePadSettingsIndex < 0)
                    {
                        gamePadSettingsIndex = 0;
                    }
                    if (gamePadSettingsIndex > 5)
                    {
                        gamePadSettingsIndex = 5;
                    }
                    //Movement.
                    if (y < -threshHold && gamePadSettingsIndex > 0 && counter <= 0)
                    {
                        gamePadSettingsIndex--; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                    }
                    if (y > threshHold && gamePadSettingsIndex < 5 && counter <= 0)
                    {
                        gamePadSettingsIndex++; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                    }
                    if (Input.GetButtonDown("Right Bumper"))
                    {
                        PlaySound.NoLoop(overSnd); gamePadSettingsIndex = 6; atRightSettingsMenu = true;
                    }
                }
                else                             //How the menu works when you are at the right side.
                                                 //Clamping index.
                {
                    if (gamePadSettingsIndex < 6)
                    {
                        gamePadSettingsIndex = 6;
                    }
                    if (gamePadSettingsIndex > settingMax)
                    {
                        gamePadSettingsIndex = settingMax;
                    }
                    //Movement.
                    if (y < -threshHold && gamePadSettingsIndex > 6 && counter <= 0)
                    {
                        gamePadSettingsIndex--; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                    }
                    if (y > threshHold && gamePadSettingsIndex < settingMax && counter <= 0)
                    {
                        gamePadSettingsIndex++; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                    }
                    if (Input.GetButtonDown("Left Bumper"))
                    {
                        PlaySound.NoLoop(overSnd); gamePadSettingsIndex = 0; atRightSettingsMenu = false;
                    }
                }
                //For tick box settings.
                if (Input.GetButtonDown("Submit"))
                {
                    PlaySound.NoLoop(snd);
                    switch (gamePadSettingsIndex)
                    {
                    case 2:                                     //Light effects.
                        SettingAction(4);
                        break;

                    case 3:                                     //VSync.
                        SettingAction(5);
                        break;

                    case 4:                                     //Fullscreen.
                        SettingAction(6);
                        break;

                    case 6:
                        MenuAction(14);
                        break;

                    case 7:
                        MenuAction(15);
                        break;

                    case 8:
                        SettingAction(9);
                        break;

                    case 9:
                        SettingAction(10);
                        break;

                    case 10:
                        SettingAction(11);
                        break;
                    }
                }

                //For settings requiring horizontal movement.
                if (x > threshHold && counter <= 0)                          //Increasing value of music, sfx, and resolution.
                {
                    switch (gamePadSettingsIndex)
                    {
                    case 0:                                     //Sfx up.
                        SettingAction(1);
                        PlaySound.NoLoop(snd);
                        break;

                    case 1:                                     //Music up.
                        SettingAction(3);
                        PlaySound.NoLoop(snd);
                        break;

                    case 5:                                     //Resolution up.
                        SettingAction(8);
                        PlaySound.NoLoop(snd);
                        break;
                    }
                    counter = iTime;
                }
                if (x < -threshHold && counter <= 0)                         //Decreasing value of musicm sfx, and resolution.
                {
                    switch (gamePadSettingsIndex)
                    {
                    case 0:                                     //Sfx down.
                        SettingAction(0);
                        PlaySound.NoLoop(snd);
                        break;

                    case 1:                                     //Music down.
                        SettingAction(2);
                        PlaySound.NoLoop(snd);
                        break;

                    case 5:                                     //Resolution down.
                        SettingAction(7);
                        PlaySound.NoLoop(snd);
                        break;
                    }
                    counter = iTime;
                }

                //Backing out of the menu.
                if (Input.GetButtonDown("Cancel"))
                {
                    MenuAction(11);
                }
                break;

            case Menu.Stats:
                if (Input.GetButtonDown("Cancel"))
                {
                    MenuAction(10);
                }
                break;

            case Menu.Adventure:
                Vector2 v0          = adventurePadSelector.GetComponent <Rigidbody2D>().velocity;
                Vector3 p0          = adventurePadSelector.transform.position;
                float   smooth      = 17.5f;
                float   selectSpeed = 5f;
                v0 = Vector2.Lerp(v0, new Vector2(x, -y) * selectSpeed, smooth * Time.deltaTime);
                float maxX = 8.5f;
                float maxY = 25.4f;
                float minX = -9.2f;
                float minY = 15.5f;
                if (p0.x < minX)
                {
                    p0.x = minX;
                }
                if (p0.x > maxX)
                {
                    p0.x = maxX;
                }
                if (p0.y > maxY)
                {
                    p0.y = maxY;
                }
                if (p0.y < minY)
                {
                    p0.y = minY;
                }
                p0.z = -7.5f;
                adventurePadSelector.transform.position = p0;
                adventurePadSelector.GetComponent <Rigidbody2D>().velocity = v0;

                //When the swipe starts, hide the cursor.
                adventurePadSelector.SetActive(!startedSwipe);


                if (Input.GetButtonDown("Cancel"))
                {
                    MenuAction(16);
                }
                break;

            case Menu.Shop:

                //The postions of the shop box.
                Vector3[] shopBoxPos =
                {
                    new Vector3(13,    -18, 0),  //0 - Health.
                    new Vector3(20,    -18, 0),  //1 - Fire Rate.
                    new Vector3(27,    -18, 0),  //2 - Floppy Disk.
                    new Vector3(16.5f, -21, 0),  //3 - Speed
                    new Vector3(23.5f, -21, 0),  //4 - Shot Splits.
                };
                gamePadSelector.transform.position = shopBoxPos[gamePadShopIndex];

                //Moving the stick around in the shop menu. (Up and Down).
                if (y > threshHold && gamePadShopIndex == 0 && counter <= 0)
                {
                    gamePadShopIndex = 3; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (y > threshHold && gamePadShopIndex == 1 && counter <= 0)
                {
                    gamePadShopIndex = 4; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (y > threshHold && gamePadShopIndex == 2 && counter <= 0)
                {
                    gamePadShopIndex = 4; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (y < -threshHold && gamePadShopIndex == 3 && counter <= 0)
                {
                    gamePadShopIndex = 0; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (y < -threshHold && gamePadShopIndex == 4 && counter <= 0)
                {
                    gamePadShopIndex = 1; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                //Moving the stick around in the shop menu. (Horizontal).
                if (x < -threshHold && gamePadShopIndex > 0 && counter <= 0)
                {
                    gamePadShopIndex--; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }
                if (x > threshHold && gamePadShopIndex < 4 && counter <= 0)
                {
                    gamePadShopIndex++; PlaySound.NoLoopRandomPitch(overSnd, 1f, 1.5f); counter = iTime;
                }

                //This sets the shop text.
                switch (gamePadShopIndex)
                {
                case 0:
                    shopIndex = 2;
                    break;

                case 1:
                    shopIndex = 4;
                    break;

                case 2:
                    shopIndex = 7;
                    break;

                case 3:
                    shopIndex = 5;
                    break;

                case 4:
                    shopIndex = 6;
                    break;
                }

                //Pressing that A button.
                if (Input.GetButtonDown("Submit") && Game.coins >= 0)
                {
                    switch (gamePadShopIndex)
                    {
                    case 0:         //Buying heart.
                        if (Game.healthRank < maxRank)
                        {
                            ShopAction(Game.healthRank, "Health");
                        }
                        break;

                    case 1:
                        if (Game.shotSpeedRank < maxRank)
                        {
                            ShopAction(Game.shotSpeedRank, "Shot Speed");
                        }
                        break;

                    case 2:
                        if (!Game.ownsFloppyDisk)
                        {
                            ShopAction(4, "Floppy");
                        }
                        break;

                    case 3:
                        if (Game.speedRank < maxRank)
                        {
                            ShopAction(Game.speedRank, "Speed");
                        }
                        break;

                    case 4:
                        if (Game.shotSplitRank < (maxRank - 1))
                        {
                            ShopAction(Game.shotSplitRank, "Shot Split");
                        }
                        break;
                    }
                    //ShopAction(0, "temp");
                }

                //Refund!
                bool refundable = RefundCheck();
                if (Input.GetButtonDown("Delete Save") && refundable)
                {
                    Refund();
                }

                if (Input.GetButtonDown("Cancel"))
                {
                    MenuAction(12);
                }
                break;

            case Menu.DeleteSave:
                if (Input.GetButtonDown("Cancel"))
                {
                    MenuAction(13);
                }
                break;
            }
        }

        //Swiping out to a level.
        if (startedSwipe)
        {
            loadTime -= Time.deltaTime;
            if (loadTime <= 0)
            {
                if (lvl == 420)
                {
                    Application.Quit();
                }
                else
                {
                    SceneManager.LoadScene(lvl);
                }
            }
        }
    }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        //Set when the smile face is active.
        smile.SetActive(Game.smileyMode);

        //Set position and parents of the object.
        gameObject.transform.parent = Game.enemyHolder.transform;

        //Manage health bar.
        float divider = 0.013333f;

        Game.manager.GetComponent <GameManager>().BossHealthBar(health, divider);
        if (health < 0)
        {
            health = 0;
        }                               //You can't go negative health!

        //Lerp that color when hurt!
        //Flash me when I'm hit.
        if (hitCounter > 0f)
        {
            hitCounter -= Time.deltaTime;
            targetColor = Game.bulletColor;
        }
        else
        {
            targetColor = Game.frontColor;
        }
        float smoothness = 5f;

        for (int i = 0; i < puppets.Length; i++)
        {
            puppets[i].GetComponent <MeshRenderer>().material.color = Color.Lerp(puppets[i].GetComponent <MeshRenderer>().material.color, targetColor, smoothness * Time.deltaTime);
        }


        //Hold boss until not in Splash Screen.
        if (Game.manager.GetComponent <GameManager>().splashCounter <= 0 && !dead)
        {
            //Setup velocity.
            vel = GetComponent <Rigidbody2D>().velocity;

            //Coming in phase.
            if (p == Phase.ComingIn)
            {
                //Keep the bullet shot indicators hidden.
                for (int i = 0; i < shootIndicators.Count; i++)
                {
                    shootIndicators[i].transform.localScale = Vector3.zero;
                    shootIndicators[i].GetComponent <MeshRenderer>().material.color = Color.clear;
                }

                transform.position = Vector3.MoveTowards(transform.position, Vector3.zero, speed * Time.deltaTime);
                if (transform.position == Vector3.zero)
                {
                    //Enable lasers and go to phase1.
                    p = Phase.PhaseOne;
                }
                //PHASE 1
            }
            else if (p == Phase.PhaseOne)
            {
                //Play laser sound.
                if (!playedLaserSnd)
                {
                    PlaySound.NoLoop(laserSnd);
                    playedLaserSnd = true;
                }

                //Keep lasers active, if not dead.
                for (int i = 0; i < 4; i++)
                {
                    if (laserGroup[i] != null)
                    {
                        laserGroup[i].SetActive(true);
                    }
                }

                //Move around to 9 designated points.
                float     xa        = 24f;
                float     ya        = 8.5f;
                Vector3[] targetPos =
                {
                    Vector3.zero,   new Vector3(xa,  0,              0), new Vector3(-xa,  0,             0), new Vector3(0, ya,              0), new Vector3(0, -ya, 0),
                    new Vector3(xa, ya,             0), new Vector3(-xa, ya,              0), new Vector3(xa,           -ya, 0), new Vector3(-xa,           -ya,  0),
                };
                if (transform.position == targetPos[targetPosIndex])
                {
                    targetPosIndex = Random.Range(0, 8);
                }
                transform.position = Vector3.MoveTowards(transform.position, targetPos[targetPosIndex], speed * Time.deltaTime);

                //Shooting cheese bullets.
                phase1BulletCounter -= Time.deltaTime;//HERE
                if (phase1BulletCounter <= 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        Instantiate(bullet, new Vector3(points[i].transform.position.x, points[i].transform.position.y, 75), points[i].transform.rotation * Quaternion.Euler(0, 0, -90));
                    }
                    PlaySound.NoLoop(fireShoot);
                    phase1BulletCounter = phase1BulletTime;
                }

                //Scale the cheese bullet shoot indicators.
                float f = (phase1BulletCounter / 5f);
                Color c = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, 1 - f);
                if (f > 1f)
                {
                    f = 1f;
                }
                if (f < 0f)
                {
                    f = 0f;
                }
                for (int i = 0; i < shootIndicators.Count; i++)
                {
                    if (i < 4)
                    {
                        shootIndicators[i].transform.localScale = new Vector3(5f, f, 1f);
                        shootIndicators[i].GetComponent <MeshRenderer>().material.color = c;
                    }
                    else
                    {
                        shootIndicators[i].transform.localScale = Vector3.zero;
                        shootIndicators[i].GetComponent <MeshRenderer>().material.color = Color.clear;
                    }
                }

                //Checking if all lasers are dead.
                for (int i = 0; i < lasers.Count; i++)
                {
                    if (lasers[i] == null)
                    {
                        lasers.Remove(lasers[i]);
                    }
                }
                //Debug.Log(lasers.Count.ToString());
                if (lasers.Count < 1)
                {
                    p = Phase.Transition;
                }
                //Transition to phase 2!!
            }
            else if (p == Phase.Transition)
            {
                //Keep the bullet shot indicators hidden.
                for (int i = 0; i < shootIndicators.Count; i++)
                {
                    shootIndicators[i].transform.localScale = Vector3.zero;
                    shootIndicators[i].GetComponent <MeshRenderer>().material.color = Color.clear;
                }

                //Move to the middle.
                transform.position = Vector3.MoveTowards(transform.position, Vector3.zero, speed * Time.deltaTime);

                //When he gets to the center...
                if (transform.position == Vector3.zero)
                {
                    //Scale out the new guns!
                    if (!playedGunTween)
                    {
                        iTween.ScaleTo(gunsToScale, iTween.Hash("x", 1f, "y", 1f, "z", 1f, "time", 2f, "easetype", iTween.EaseType.easeInOutSine, "looptype", iTween.LoopType.none));
                        secondGuns.GetComponent <RotateScript>().enabled = true;
                        playedGunTween = true;
                    }

                    //Subtract counter.
                    shieldBreakWaitTime -= Time.deltaTime;

                    if (shieldBreakWaitTime <= 1f && !playedBreakSound)
                    {
                        Destroy(fBlocker);
                        Instantiate(glassBreakPoof, new Vector3(0, 0, 40), Quaternion.identity);
                        PlaySound.NoLoop(shieldBreak);
                        playedBreakSound = true;
                    }

                    if (shieldBreakWaitTime <= 0)
                    {
                        p = Phase.PhaseTwo;
                    }
                } //Phase 2!!!!
            }
            else if (p == Phase.PhaseTwo)
            {
                //Enable that collider.
                GetComponent <Collider2D>().enabled = true;

                phase2BulletCounter -= Time.deltaTime;
                if (phase2BulletCounter <= 0)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        GameObject o = (GameObject)Instantiate(bullet, new Vector3(points[i].transform.position.x, points[i].transform.position.y, 75), points[i].transform.rotation * Quaternion.Euler(0, 0, -90));
                        o.GetComponent <CheeseBulletScript>().turnTime = -1f;
                    }
                    PlaySound.NoLoopRandomPitch(fireShoot, 0.5f, 1.5f);
                    phase2BulletCounter = phase2BulletTime;
                }

                //Scaling the shot indicators for phase 2.
                float f = phase2BulletCounter;
                Color c = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, 1 - f);
                if (f > 1f)
                {
                    f = 1f;
                }
                if (f < 0f)
                {
                    f = 0f;
                }
                for (int i = 0; i < shootIndicators.Count; i++)
                {
                    shootIndicators[i].transform.localScale = new Vector3(5f, f, 1f);
                    shootIndicators[i].GetComponent <MeshRenderer>().material.color = c;
                }
            }

            //Reapply velocity.
            GetComponent <Rigidbody2D>().velocity = vel;
        }
        else if (dead)
        {
            GetComponent <Collider2D>().enabled = false;
            if (deathCounter > 0)
            {
                deathCounter -= Time.deltaTime;
            }

            if (deathCounter <= 0 && !playedSecondTween)
            {
                iTween.MoveTo(gameObject, iTween.Hash(
                                  "x", 0f, "y", -33f, "z", 0f,
                                  "time", 1f,
                                  "easetype", iTween.EaseType.linear,
                                  "looptype", iTween.LoopType.none
                                  ));
                iTween.ScaleTo(boom, iTween.Hash(
                                   "x", 50f, "y", 50f, "z", 1f,
                                   "time", 1f,
                                   "delay", 1f,
                                   "easetype", iTween.EaseType.linear,
                                   "looptype", iTween.LoopType.none
                                   ));
                iTween.ColorTo(boom, iTween.Hash(
                                   "a", 0f,
                                   "time", 0.75f,
                                   "delay", 1.25f,
                                   "easetype", iTween.EaseType.linear,
                                   "looptype", iTween.LoopType.none
                                   ));
                Game.manager.GetComponent <GameManager>().victory = true;
                PlaySound.NoLoop(boomSnd);
                playedSecondTween = true;
            }
        }
    }