示例#1
0
    void NewDayUpdate()
    {
        string curStr     = "";
        int    numEntries = 0;
        int    numBlanks  = 0;

        todaysTemplate    = new List <List <string> >();
        blanksPerSentence = new List <int>();
        blankMarkers      = new List <int[]>();
        fxState           = new bool[3] {
            false, false, false
        };                                                // fish, chrome, glass
        todaysBlanks       = 0;
        dayStart           = 0.0f;
        currentIndex       = 0;
        currentSent        = 0;
        templateComplete   = false;
        needsEntry         = false;
        canLeaveInter      = false;
        textState          = -1;
        currentBlankInSent = 0;
        MainCamera.GetComponent <Camera>().orthographicSize = 4.5f;
        FaceGroup.transform.localPosition = new Vector3(faceResetX, FaceGroup.transform.localPosition.y, FaceGroup.transform.localPosition.z);
        FaceGroup.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);
        MainCamera.transform.localPosition = new Vector3(camResetX, MainCamera.transform.localPosition.y, MainCamera.transform.localPosition.z);
        UI_storyL.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, 0f);
        UI_storyR.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, 0f);
        UI_main.SetActive(false);
        UI_words.SetActive(false);
        for (int i = 0; i < allDays[(currentDay - 1)].dayTemplates.Count; i++)     // count the number of phrases in template
        {
            numEntries = 0;
            numBlanks  = 0;
            todaysTemplate.Add(new List <string>());
            for (int j = 0; j < allDays[(currentDay - 1)].dayTemplates[i].Length; j++)
            {
                if (allDays[(currentDay - 1)].dayTemplates[i][j] == '_')
                {
                    todaysTemplate[i].Add(curStr);
                    if (curStr != "")
                    {
                        numEntries++;
                    }
                    todaysTemplate[i].Add("___");
                    todaysBlanks++;
                    curStr = "";
                    numEntries++;
                    numBlanks++;
                    blankMarkers.Add(new int[2] {
                        i, numEntries - 1
                    });
                }
                else
                {
                    curStr += allDays[(currentDay - 1)].dayTemplates[i][j];
                }
                if (j == allDays[(currentDay - 1)].dayTemplates[i].Length - 1)
                {
                    todaysTemplate[i].Add(curStr);
                    curStr = "";
                }
            }
            blanksPerSentence.Add(numBlanks);
        }

        /*for (int i=0;i<blankMarkers.Count;i++) {
         *      print(blankMarkers[i][0]+","+blankMarkers[i][1]);
         * }*/

        // Change alpha of tankQuad
        Color color = TankMat.color;

        color.a       = 1.0f - (0.07f * currentDay);
        TankMat.color = color;

        // Change alpha of face
        FaceGroup.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, (float)0.2 + (0.06f * currentDay));


        // if we're > day 5, swap position of two
        // face starts at -3.5, tank at -1.5
        if (currentDay < 6)
        {
            FaceGroup.transform.localPosition = new Vector3(FaceGroup.transform.localPosition.x, FaceGroup.transform.localPosition.y, (float)-3.5);
            TankQuad.transform.localPosition  = new Vector3(TankQuad.transform.localPosition.x, TankQuad.transform.localPosition.y, (float)-1.5);
        }
        else
        {
            FaceGroup.transform.localPosition = new Vector3(FaceGroup.transform.localPosition.x, FaceGroup.transform.localPosition.y, (float)-1.5);
            TankQuad.transform.localPosition  = new Vector3(TankQuad.transform.localPosition.x, TankQuad.transform.localPosition.y, (float)-3.5);
        }

        // disable all ALLDAYS children
        foreach (Transform child in AllDays.transform)
        {
            child.gameObject.SetActive(false);
        }

        // enable the correct day
        dayObjs[(currentDay - 1)].SetActive(true);
        UpdateStrings();
    }
示例#2
0
    void Update()
    {
        if (gameState == "startDay")
        {
            if (FadeSquare.GetComponent <SpriteRenderer>().color.a > 0)
            {
                FadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, FadeSquare.GetComponent <SpriteRenderer>().color.a - fadeInTime);
            }
            else
            {
                gameState = "active";
            }
        }

        // z-axis camera movement
        if (zMove == 1)           // stepping toward the glass

        {
            if (MainCamera.GetComponent <Camera>().orthographicSize > 3)
            {
                MainCamera.GetComponent <Camera>().orthographicSize = MainCamera.GetComponent <Camera>().orthographicSize - (float)0.05;
            }

            else
            {
                zMove = 2;
            }
        }
        else if (zMove == -1)           // stepping back from the glass


        {
            if (MainCamera.GetComponent <Camera>().orthographicSize < 4.5)
            {
                MainCamera.GetComponent <Camera>().orthographicSize = MainCamera.GetComponent <Camera>().orthographicSize + (float)0.05;
            }
            else
            {
                zMove        = 0;
                closeToGlass = false;
                UI_main.SetActive(true);
                UI_words.SetActive(true);
            }
        }
        else if (zMove == 3)           // fading scene out to interstitial

        {
            if (FaceGroup.transform.localPosition.x < 12)               // face walking
            {
                FaceGroup.transform.localPosition = new Vector3(FaceGroup.transform.localPosition.x + (float)0.02, FaceGroup.transform.localPosition.y, FaceGroup.transform.localPosition.z);
                FaceGroup.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, FaceGroup.GetComponent <SpriteRenderer>().color.a - (float)0.002);
            }

            if (MainCamera.transform.localPosition.x < 12)
            {
                MainCamera.transform.localPosition = new Vector3(MainCamera.transform.localPosition.x + (float)0.02, MainCamera.transform.localPosition.y, MainCamera.transform.localPosition.z);
            }

            if (FadeSquare.GetComponent <SpriteRenderer>().color.a < 1)
            {
                FadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, FadeSquare.GetComponent <SpriteRenderer>().color.a + fadeOutTime);
            }
            else
            {
                if (Time.time - holdTime >= waitTankToInter)
                {
                    if (!transOnce)
                    {
                        transOnce = true;
                        transform.GetComponent <audioManager>().playCig();
                        transform.GetComponent <audioManager>().playSmokeAmbient();
                        MainCamera.SetActive(false);
                        InterCamera.SetActive(true);
                        UI_storyL.SetActive(true);
                        UI_storyR.SetActive(true);
                        transform.GetComponent <imageEffects>().FishEyeOn(false);
                        transform.GetComponent <imageEffects>().ChromAbOn(false);
                        transform.GetComponent <imageEffects>().glassColorOn(false);
                    }

                    if (UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a < 1)
                    {
                        UI_storyL.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a + 0.05f);
                    }

                    if (UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a < 1)
                    {
                        UI_storyR.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a + 0.05f);
                    }


                    if (InterFadeSquare.GetComponent <SpriteRenderer>().color.a > 0)
                    {
                        InterFadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, InterFadeSquare.GetComponent <SpriteRenderer>().color.a - fadeInTime);
                    }
                    else                       // done
                    {
                        templateComplete = false;
                        zMove            = 0;
                        gameState        = "inter";
                        transOnce        = false;
                        holdTime         = 0.0f;
                        canLeaveInter    = true;
                    }
                }
            }
        }
        else if (zMove == 4)           // fading out from intersitial to next day
        {
            if (UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a > 0)
            {
                UI_storyL.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a - 0.05f);
            }

            if (UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a > 0)
            {
                UI_storyR.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a - 0.05f);
            }

            if (InterFadeSquare.GetComponent <SpriteRenderer>().color.a < 1)
            {
                InterFadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, InterFadeSquare.GetComponent <SpriteRenderer>().color.a + fadeOutTime);
            }
            else
            {
                if (Time.time - holdTime >= waitInterToTank)
                {
                    if (!transOnce)
                    {
                        InterCamera.SetActive(false);
                        MainCamera.SetActive(true);
                        NewDayUpdate();
                        transOnce = true;
                        transform.GetComponent <audioManager>().playTankBubbles();
                        transform.GetComponent <audioManager>().playTankAmbient();
                    }


                    if (FadeSquare.GetComponent <SpriteRenderer>().color.a > 0)
                    {
                        FadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, FadeSquare.GetComponent <SpriteRenderer>().color.a - (float)0.02);
                    }
                    else                       // done
                    {
                        gameState = "startDay";
                        zMove     = 0;
                        transOnce = false;
                        UI_storyL.SetActive(false);
                        UI_storyR.SetActive(false);
                    }
                }
            }
        }
        else if (zMove == 5)           // face is walking away
        {
            if (FaceGroup.transform.localPosition.x < 10)
            {
                FaceGroup.transform.localPosition = new Vector3(FaceGroup.transform.localPosition.x + (float)0.02, FaceGroup.transform.localPosition.y, FaceGroup.transform.localPosition.z);
                FaceGroup.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, FaceGroup.GetComponent <SpriteRenderer>().color.a - (float)0.005);
            }
            else               // end-game triggers
            {
                if (!transOnce)
                {
                    lastDayUIDelay = Time.time;
                    UpdateStrings();
                    UI_storyL.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, 0f);
                    UI_storyR.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, 0f);
                    UI_storyL.SetActive(true);
                    UI_storyR.SetActive(true);
                    UI_main.SetActive(false);
                    transOnce = true;
                    GameObject fb = GameObject.Find("/FarBackInsideAquarium");
                    fb.transform.GetComponent <BackgroundFadeIn>().GameEndScreenSetUp();
                }
            }
        }
        else if (zMove == 6)           // fade from title to intro
        {
            if (InterFadeSquare.GetComponent <SpriteRenderer>().color.a < 1)
            {
                InterFadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, InterFadeSquare.GetComponent <SpriteRenderer>().color.a + fadeInTime);
            }
            else
            {
                if (!transOnce)
                {
                    InterCamera.SetActive(false);
                    MainCamera.SetActive(true);
                    transOnce = true;
                    UI_intro.SetActive(true);
                }

                gameState = "intro";
                zMove     = 0;
                transOnce = false;
            }
        }
        else if (zMove == 7)           // fade out from last day to restart
        {
            if (FadeSquare.GetComponent <SpriteRenderer>().color.a < 1)
            {
                FadeSquare.GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f, FadeSquare.GetComponent <SpriteRenderer>().color.a + fadeOutTime);
            }
            else
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }

        if (lastDayUIDelay != 0.0 && Time.time - lastDayUIDelay >= 8 && UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a < 1)
        {
            if (UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a < 1)
            {
                UI_storyL.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyL.GetComponent <UnityEngine.UI.Text>().color.a + 0.05f);
            }

            if (UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a < 1)
            {
                UI_storyR.GetComponent <UnityEngine.UI.Text>().color = new Color(1f, 1f, 1f, UI_storyR.GetComponent <UnityEngine.UI.Text>().color.a + 0.05f);
            }
        }

        // UI Prompts
        string promptText = "";

        if (gameState == "title" && zMove == 0)
        {
            promptText = "( ENTER ) to START";
        }
        else if (gameState == "intro")
        {
            // built-in to intro text
        }
        else if (gameState == "outro" && lastDayUIDelay != 0.0 && Time.time - lastDayUIDelay >= 8)
        {
            promptText = "( ESCAPE ) TO QUIT\n\r( ENTER ) TO RESTART";
        }
        else if (gameState == "active" && !closeToGlass)
        {
            if (textState > -1)
            {
                if (templateComplete && currentSent >= todaysTemplate.Count)
                {
                    promptText = "( ENTER ) TO DEPART";
                }
                else
                {
                    if (needsEntry && textState == 1)
                    {
                        promptText = "( ENTER ) TO CONFIRM\n\r( SPACE ) TO STARE";
                    }
                    else if (needsEntry)
                    {
                        promptText = "( ENTER ) TO WRITE\n\r( SPACE ) TO STARE";
                    }
                    else
                    {
                        promptText = "( ENTER ) TO PROCEED";
                    }
                }
            }

            else if (textState == -1)
            {
                promptText = "( ENTER ) TO BEGIN";
            }
        }
        else if (gameState == "inter" && zMove != 4)
        {
            promptText = " ( ENTER ) FOR NEXT DAY";
        }
        if (!confirmExit)
        {
            UI_prompts.GetComponent <UnityEngine.UI.Text>().text = promptText;
        }



        // Check for time-based triggers

        // word additions
        if (Time.time - lastTickCheck >= 1 && gameState == "active")           // so we're not looping through the list array every frame, just every second
        {
            for (int i = 0; i < allDays[(currentDay - 1)].dayPhrases.Count; i++)
            {
                if (dayStart != 0.0 && allDays[(currentDay - 1)].dayPhrases[i].triggerType == "time" && float.Parse(allDays[(currentDay - 1)].dayPhrases[i].triggerVal) <= (Time.time - dayStart))
                {
                    allDays[(currentDay - 1)].dayPhrasesActive.Add(allDays[(currentDay - 1)].dayPhrases[i]);
                    allDays[(currentDay - 1)].dayPhrases.RemoveAt(i);
                    i--;
                    UpdateStrings();
                    if (!templateComplete)
                    {
                        transform.GetComponent <audioManager>().playChime();                        // sound chime for new word
                    }
                }
                else if (stareTime != 0.0 && allDays[(currentDay - 1)].dayPhrases[i].triggerType == "close" && float.Parse(allDays[(currentDay - 1)].dayPhrases[i].triggerVal) <= (Time.time - stareTime))
                {
                    allDays[(currentDay - 1)].dayPhrasesActive.Add(allDays[(currentDay - 1)].dayPhrases[i]);
                    allDays[(currentDay - 1)].dayPhrases.RemoveAt(i);
                    i--;
                    UpdateStrings();
                    if (!templateComplete)
                    {
                        transform.GetComponent <audioManager>().playChime();                        // sound chime for new word
                    }
                }
            }

            // imageEffects triggers
            if (dayStart != 0 && Time.time - dayStart >= 8 && !fxState[0])               // fish (extra time accounting for fade-in)
            {
                transform.GetComponent <imageEffects>().FishEyeOn(true);
                fxState[0] = true;
            }

            if (dayStart != 0 && Time.time - dayStart >= 28 && !fxState[1])               // chrome
            {
                transform.GetComponent <imageEffects>().ChromAbOn(true);
                fxState[1] = true;
            }
            if (dayStart != 0 && Time.time - dayStart >= 18 && !fxState[2])              // glass
            {
                transform.GetComponent <imageEffects>().glassColorOn(true);
                fxState[2] = true;
            }

            lastTickCheck = Time.time;
        }

        // Keystrokes

        if (Input.GetKeyUp("escape"))
        {
            if (!confirmExit)
            {
                lastPrompt = UI_prompts.GetComponent <UnityEngine.UI.Text>().text;
                UI_prompts.GetComponent <UnityEngine.UI.Text>().text = "<color=#FF0000>( ENTER ) TO EXIT</color>\r\n( ESC ) TO RESUME";
                confirmExit = true;
            }
            else if (confirmExit)
            {
                UI_prompts.GetComponent <UnityEngine.UI.Text>().text = lastPrompt;
                confirmExit = false;
            }
        }

        if (Input.GetKeyUp("return"))
        {
            //print("gameState: "+gameState+" textState: "+textState + " needsEntry: "+needsEntry+" closeToGlass:"+closeToGlass+" templateComplete: "+templateComplete);
            if (confirmExit)
            {
                Application.Quit();
            }
            if (gameState == "active")
            {
                if (textState == -1 && !closeToGlass)                   // start the day
                {
                    transform.GetComponent <MouseParallax>().mouseParallaxControl = true;
                    textState = 0;
                    UI_main.SetActive(true);
                    UI_words.SetActive(true);
                    UpdateStrings();
                    if (dayStart == 0)
                    {
                        dayStart = Time.time;
                    }
                }
                else if (textState == 0 && !templateComplete && needsEntry && !closeToGlass)
                {
                    // entering typing mode
                    textState = 1;
                    todaysTemplate[blankMarkers[currentIndex][0]][blankMarkers[currentIndex][1]] = "";
                    UpdateStrings();
                }
                else if (textState == 0 && !needsEntry && !closeToGlass && currentSent < todaysTemplate.Count)                   // advance to next sentence
                {
                    completedText.Add(CleanString(currentTemplate));
                    currentSent++;
                    UpdateStrings();
                }
                else if (textState != 1 && !closeToGlass && templateComplete && currentSent >= todaysTemplate.Count)
                {
                    UI_main.SetActive(false);
                    UI_main.SetActive(false);
                    if (!needsEntry)
                    {
                        completedText.Add(CleanString(currentTemplate));
                        UpdateStrings();
                    }

                    if (currentDay < maxDays)               // exiting day -> interstitial
                    {
                        transform.GetComponent <audioManager>().stopTankBubbles();
                        transform.GetComponent <audioManager>().stopTankAmbient();
                        transform.GetComponent <audioManager>().playWalking();
                        zMove      = 3;
                        holdTime   = Time.time;
                        currentDay = currentDay + 1;
                        gameState  = "endDay";
                        transform.GetComponent <MouseParallax>().mouseParallaxControl = false;
                    }
                    else if (currentDay == maxDays)               // end of game
                    {
                        transform.GetComponent <MouseParallax>().mouseParallaxControl = false;
                        transform.GetComponent <audioManager>().stopTankAmbient();
                        zMove     = 5;
                        gameState = "outro";
                        completedText.Add(outroText);
                    }

                    completedText.Add("\n");
                    if (currentDay == 6)
                    {
                        dayBreak = completedText.Count;
                    }
                }
            }
            else if (gameState == "intro")
            {
                transform.GetComponent <audioManager>().playTankBubbles();
                transform.GetComponent <audioManager>().playTankAmbient();
                gameState = "startDay";
                UI_intro.SetActive(false);
            }

            else if (gameState == "inter" && canLeaveInter)
            {
                zMove    = 4;
                holdTime = Time.time;
                transform.GetComponent <audioManager>().stopCig();
                transform.GetComponent <audioManager>().stopSmokeAmbient();
                canLeaveInter = false;
            }
            else if (gameState == "title")
            {
                UI_title.SetActive(false);
                zMove = 6;
            }
            else if (gameState == "outro" && lastDayUIDelay != 0.0 && Time.time - lastDayUIDelay >= 8)       // restart
            {
                transform.GetComponent <audioManager>().stopTankBubbles();
                UI_prompts.SetActive(false);
                UI_storyL.SetActive(false);
                UI_storyR.SetActive(false);
                zMove = 7;
            }
        }
        if (Input.GetKey("space"))
        {
            if (gameState == "active" && (textState == 0 || textState == 1))
            {
                if (zMove == 0 && !closeToGlass)
                {
                    SendAction("stepFoward");
                    zMove        = 1;
                    closeToGlass = true;
                    UI_main.SetActive(false);
                    UI_words.SetActive(false);
                    stareTime = Time.time;
                    transform.GetComponent <audioManager>().closeToTank();
                }
                if (zMove == 2 && closeToGlass)
                {
                    SendAction("stepBack");
                    zMove = -1;
                    transform.GetComponent <audioManager>().awayFromTank();
                    stareTime = 0.0f;
                }
            }
        }

        if (releaseTyping)
        {
            textState     = 0;
            releaseTyping = false;
        }
    }
示例#3
0
    void UpdateStrings()
    {
        currentPhrases  = "";
        currentTemplate = "";


        if (!templateComplete)
        {
            for (int i = 0; i < allDays[(currentDay - 1)].dayPhrasesActive.Count; i++)
            {
                currentPhrases += allDays[(currentDay - 1)].dayPhrasesActive[i].text + "\r\n";
            }
        }
        int checkent = 0;

        for (int i = 0; i < todaysTemplate.Count; i++)
        {
            if (currentSent == i)
            {
                for (int j = 0; j < todaysTemplate[i].Count; j++)
                {
                    if (blankMarkers[currentIndex][0] == i && blankMarkers[currentIndex][1] == j)
                    {
                        checkent++;
                    }
                    if (IsBlank(i, j))
                    {
                        if (blankMarkers[currentIndex][0] == i && blankMarkers[currentIndex][1] == j && textState == 1 && !releaseTyping) // this is what we're editing
                        {
                            if (phraseMismatch)                                                                                           // trying to lock something in that's not an available phrase
                            {
                                currentTemplate += "[<color=#FF0000>" + todaysTemplate[i][j] + "</color>]";
                            }
                            else
                            {
                                currentTemplate += "[<color=#FFFF00>" + todaysTemplate[i][j] + "</color>]";
                            }
                        }
                        else if (todaysTemplate[i][j] != "___")
                        {
                            currentTemplate += "<color=#87B7C7>" + todaysTemplate[i][j] + "</color>";
                        }
                        else
                        {
                            currentTemplate += "<color=#ABABAB>" + todaysTemplate[i][j] + "</color>";
                        }
                    }
                    else
                    {
                        currentTemplate += todaysTemplate[i][j];
                    }
                }
                currentTemplate += "\n";
            }
        }
        if (checkent > 0)
        {
            needsEntry = true;
        }
        else
        {
            needsEntry = false;
        }
        UI_main.GetComponent <UnityEngine.UI.Text>().text  = currentTemplate;
        UI_words.GetComponent <UnityEngine.UI.Text>().text = currentPhrases;

        UI_storyL.GetComponent <UnityEngine.UI.Text>().text = "";
        UI_storyR.GetComponent <UnityEngine.UI.Text>().text = "";
        for (int i = 0; i < completedText.Count; i++)
        {
            if (dayBreak != 0 && i >= dayBreak)
            {
                UI_storyR.GetComponent <UnityEngine.UI.Text>().text += completedText[i];
            }
            else
            {
                UI_storyL.GetComponent <UnityEngine.UI.Text>().text += completedText[i];
            }
        }
    }