Exemplo n.º 1
0
    //this code is starting to look disgusting :( i should split these scripts up
    void Update()
    {
        updateAllBullets();

        if (bossGreenHP.transform.localScale.x < 0)
        {
            bossGreenHP.transform.localScale = new Vector3(0, bossGreenHP.transform.localScale.y, bossGreenHP.transform.localScale.z);
        }

        if (currentMode == GameMode.Dialog)
        {
            if (currentScriptIndex == -1)
            {
                SetObjectsToFade(charPanelCanvasGroup, textBoxCanvasGroup);
                FadeIn = true;
                currentScriptIndex++;
            }
            else if (currentScriptIndex >= 0)
            {
                if (!spellingOutDialog && !waitingForSpaceBar)
                {
                    CharacterSpeak(script[currentScriptIndex].Key, script[currentScriptIndex].Value);
                }
            }
            if (currentScriptIndex == 11)
            {
                bossGreenHP.transform.localScale = new Vector3(1, bossGreenHP.transform.localScale.y, bossGreenHP.transform.localScale.z);
            }
            if (spellingOutDialog)
            {
                SpellOutDialog();
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    textToSpellOutTo.text = DialogToSpellOut;
                    spellingOutDialog     = false;
                    currentCharIndex      = 0;
                    waitingForSpaceBar    = true;
                }
            }

            else if (waitingForSpaceBar && Input.GetKeyDown(KeyCode.Space))
            {
                waitingForSpaceBar = false;
                currentScriptIndex++;
                if (currentScriptIndex == 7)
                {
                    bossHealthCG.alpha = 1;
                }
                else if (currentScriptIndex == 9)
                {
                    textBoxCanvasGroup.alpha = 0;
                    currentMode = GameMode.Battle;
                    musicScript.PlayBossMusic();
                    bradBullet.SetActive(true);
                    JeffShoot();
                }
                else if (currentScriptIndex == 11)
                {
                    musicScript.PlayFullUnlimitedAnime();
                    TimePerChar = .1f;
                }
                else if (currentScriptIndex == 12)
                {
                    TimePerChar = 0;
                }
                else if (currentScriptIndex == 14)
                {
                    currentMode = GameMode.Battle;
                }
                else if (currentScriptIndex == 15)
                {
                    musicScript.PlayDramaMusic();
                }
                else if (currentScriptIndex == 24)
                {
                    Drew.GetComponent <SpriteRenderer>().sprite = Kojima;
                }
                else if (currentScriptIndex == 33)
                {
                    musicScript.PlayFinalBossMusic();
                }
                else if (currentScriptIndex == 34)
                {
                    currentMode = GameMode.Battle;
                    bradBullet.SetActive(true);
                    bradBullet.GetComponent <SpriteRenderer>().sprite = MGS1;
                    bossHealthCG.alpha = 1;
                    bossGreenHP.transform.localScale = Vector3.one;
                }
                else if (currentScriptIndex == 35)
                {
                    currentMode = GameMode.Battle;
                    bradBullet.GetComponent <SpriteRenderer>().sprite = MGS2;
                    bossGreenHP.transform.localScale = Vector3.one;
                }
                else if (currentScriptIndex == 36)
                {
                    currentMode = GameMode.Battle;
                    bradBullet.GetComponent <SpriteRenderer>().sprite = MGS3;
                    bossGreenHP.transform.localScale = Vector3.one;
                }
                else if (currentScriptIndex == 37)
                {
                    currentMode = GameMode.Battle;
                    bradBullet.GetComponent <SpriteRenderer>().sprite = MGS4;
                    bossGreenHP.transform.localScale = Vector3.one;
                }
                else if (currentScriptIndex == 38)
                {
                    currentMode = GameMode.Battle;
                    bradBullet.GetComponent <SpriteRenderer>().sprite = MGSV;
                    bossGreenHP.transform.localScale = Vector3.one;
                }
                else if (currentScriptIndex == 42)
                {
                    currentMode = GameMode.Credits;
                    FadeOut     = true;
                    SetObjectsToFade(bossHealthCG, charPanelCanvasGroup);
                    TimePerChar = 0;
                }
                else if (currentScriptIndex == 49)
                {
                    Drew.GetComponent <SpriteRenderer>().sprite = Obama;
                }
                else if (currentScriptIndex == 50)
                {
                    musicScript.PlayDramaticSting();
                }
                else if (currentScriptIndex == 51)
                {
                    FadeSpeed = .02f;

                    secretEnding = false;
                    FadeOut      = true;
                    SetObjectsToFade(bossHealthCG, charPanelCanvasGroup);

                    currentMode = GameMode.GameOver;
                }
            }
        }
        else if (currentMode == GameMode.Intro)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                FadeOut = true;
                SetObjectsToFade(fadingTitleText);
            }
        }
        else if (currentMode == GameMode.Battle)
        {
            if (currentScriptIndex == 9)
            {
                if (bossGreenHP.transform.localScale.x <= 0)
                {
                    currentMode = GameMode.Dialog;
                    musicScript.StopMusic();
                    textBoxCanvasGroup.alpha = 1;
                    bradBullet.SetActive(false);
                }
            }
            //unlimited anime
            if (currentScriptIndex == 14)
            {
                Anime.transform.Translate(-.01f, 0, 0);
            }

            if (bossGreenHP.transform.localScale.x <= 0)
            {
                currentMode = GameMode.Dialog;
                if (currentScriptIndex == 9)
                {
                    musicScript.StopMusic();
                    textBoxCanvasGroup.alpha = 1;
                    bradBullet.SetActive(false);
                }
                if (currentScriptIndex == 14)
                {
                    Anime.SetActive(false);
                    musicScript.StopMusic();
                }
                if (currentScriptIndex == 38)
                {
                    musicScript.PlayCreditsMusic();
                    bradBullet.SetActive(false);
                    TimePerChar = .1f;
                }
            }

            timeSinceLastShot += Time.deltaTime;

            if (Input.GetKeyDown(KeyCode.Space) && timeSinceLastShot >= timePerShot)
            {
                DrewShoot();
                timeSinceLastShot = 0;
            }
        }
        else if (currentMode == GameMode.Credits)
        {
            if (!secretEnding && !source.isPlaying)
            {
                fadeImageImage.CrossFadeAlpha(1, 3, true);
            }

            if (secretEnding && fadeImageImage.color.a > 0)
            {
                fadeImageImage.CrossFadeAlpha(0, 3, true);
            }
            else if (fadeImageImage.color.a >= 1)
            {
                if (Input.GetKey(KeyCode.Space))
                {
                    creditsSpeed = .04f;
                }
                else
                {
                    creditsSpeed = .01f;
                }
                CreditsText.transform.Translate(0, creditsSpeed, 0);
                //Debug.Log(CreditsText.transform.position.y);
                if (CreditsText.transform.position.y >= 27)
                {
                    source.Stop();
                    secretEnding = true;
                    FadeIn       = true;
                    currentMode  = GameMode.Dialog;
                    SetObjectsToFade(charPanelCanvasGroup, bossHealthCG);
                }
            }
        }
        else if (currentMode == GameMode.GameOver)
        {
            thanksCG.alpha += .01f;
        }

        if (FadeOut)
        {
            FadeObjectsOut();
        }
        else if (FadeIn)
        {
            FadeObjectsIn();
        }
    }