コード例 #1
0
    // Use this for initialization
    public void Start()
    {
        timer = 0.0f;

        int i = Random.Range(0, stringsInBubble.Length);

        emotionText.rosetta = rosetta.rosetta;

        int k;

        int match = 0;

        for (k = 0; k < emotionText.nItems(); ++k)
        {
            if (emotionText.getString(k).Equals(stringsInBubble [i]))
            {
                match = k;
                break;
            }
        }

        if (k < emotionText.nItems())
        {
            icon.texture = emotionTexture [match];
            text.text    = emotionText.getString(match);
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
コード例 #2
0
    // Use this for initialization
    new void Start()
    {
        mcRef       = GameObject.Find("MasterController").GetComponent <MasterControllerScript> ();
        rosetta     = GameObject.Find("Rosetta").GetComponent <Rosetta> ();
        ds          = mcRef.getStorage();
        visitNumber = ds.retrieveIntValue("TopFloorVisitNumber");

        bank         = stringBankCol.getBank(visitNumber);
        bank.rosetta = rosetta;
        bank.reset();

        int nFloaters;

        nFloaters = bank.nItems();
        floater   = new HeavyLevitatingFollower[nFloaters];

        for (int i = 0; i < nFloaters; ++i)
        {
            Vector3 newPos = player.transform.position;
            newPos.x -= 5 * i;
            GameObject newFloater = (GameObject)Instantiate(floaterPrefab, newPos, Quaternion.Euler(0, 0, 0));
            floater [i]            = newFloater.GetComponent <HeavyLevitatingFollower> ();
            floater [i].player     = player;
            floater [i].nearRadius = 2.0f + i * 1.0f;
            floater [i].initialize();
        }

        questionNumber = 0;
    }
コード例 #3
0
    public void _wm_pushSentenceBitsToMasterController()
    {
        mcRef.resetSentencePiecesList();
        StringBank sb = bank.getNextBank();

        for (int i = 0; i < sb.nItems(); ++i)
        {
            //mcRef.addSentencePiece (rosetta.retrieveString(phrase.getStringId(i)));
            mcRef.addSentencePiece(rosetta.retrieveString(sb.getStringId(i)));
        }
    }
コード例 #4
0
    // Use this for initialization
    public void Start()
    {
        state = 1;
        timer = 0.0f;
        textAndImage.Start();

        int    i       = Random.Range(0, stringsInBubble.Length);
        string laQueNo = stringsInBubble [i];

        emotionText.rosetta = rosetta;

        int k;

        int match = 0;

        for (k = 0; k < emotionText.nItems(); ++k)
        {
            string emotionTextk = emotionText.getString(k);
            if (emotionTextk.Equals(stringsInBubble [i]))
            {
                match = k;
                break;
            }
        }

        if (k < emotionText.nItems())
        {
            icon.texture = emotionTexture [match];
            text.text    = emotionText.getString(match);
        }
        else
        {
            Destroy(this.gameObject);
            Debug.Log("Emotion not found: " + laQueNo);
            icon.enabled = false;
            text.enabled = false;
        }
    }
コード例 #5
0
    new void Start()
    {
        if (level == null)
        {
            level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> ();
        }

        dropletAlive = new List <bool> ();
        visitNumber  = level.retrieveIntValue(variableName);

        visitNumber = (visitNumber % stringBanks.bank.Length);

        currentStringBank = stringBanks.bank [visitNumber];

        actualNumberOfDroplets = currentStringBank.nItems();

        for (int i = 0; i < actualNumberOfDroplets; ++i)
        {
            dropletAlive.Add(true);
        }
        for (int i = actualNumberOfDroplets; i < waterDroplets.Length; ++i)
        {
            dropletAlive.Add(false);
        }

        for (int i = actualNumberOfDroplets; i < waterDroplets.Length; ++i)
        {
            //Destroy (waterDroplets [i]); // get rid of unused droplets
            waterDroplets[i].SetActive(false);
        }

        currentStringBank.rosetta = level.rosetta;
        currentStringBank.reset();

        for (int i = 0; i < waterDroplets.Length; ++i)
        {
            bool b = level.retrieveBoolValue("PickedUpDroplet" + (i + 1));
            if (b)
            {
                dropletAlive [i] = false;
            }
        }

        int nFloaters;

        nFloaters = currentStringBank.nItems();
        floater   = new HeavyLevitatingFollower[nFloaters];

        int pickedUpDroplets = level.retrieveIntValue("Droplets");

        for (int i = 0; i < nFloaters; ++i)
        {
            Vector3 newPos = level.player.transform.position - Vector3.right * 100;
            newPos.x -= 5 * i;
            GameObject newFloater = (GameObject)Instantiate(floaterPrefab, newPos, Quaternion.Euler(0, 0, 0));
            floater [i]            = newFloater.GetComponent <HeavyLevitatingFollower> ();
            floater [i].player     = level.player;
            floater [i].nearRadius = 2.0f + i * 2.0f;
            floater [i].initialize();
            floater [i].yOffset = followerYOffset;
            if (i < pickedUpDroplets)
            {
                floater [i].immediateBreak();
            }
        }
        usedQuestions = pickedUpDroplets;
    }
コード例 #6
0
    new void Update()
    {
        bool change = Utils.updateSoftVariable(ref sparkScale, sparkTargetScale, 30.0f);

        if (change)
        {
            spark1.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark2.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark3.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
        }

        if (state == QAControllerState.idle)
        {
            elapsedTime += Time.deltaTime;


            if (elapsedTime > initialDelay)
            {
                letterOutputSpeed = slowletterOutputSpeed;
                state             = QAControllerState.idle2;
            }
        }

        if (state == QAControllerState.idle2)
        {
            /* extract question and answers */

            ab            = qa.getNextBank();
            correctAnswer = qb.correntAnswer [currentQuestion];
            ab.rosetta    = rosetta;
            qb.rosetta    = rosetta;

            ab.reset();

            burn [currentQuestion].lightUp();

            question = qb.getNextString();

            state = QAControllerState.printingQuestion;

            questionLetterOutput = 0.0f;
        }

        if (state == QAControllerState.printingQuestion)
        {
            int letters = (int)questionLetterOutput;

            if (Input.GetMouseButtonDown(0))
            {
                letterOutputSpeed = fastletterOutputSpeed;
            }

            if ((letters > 2) && (letters < question.Length - 2))
            {
                questionText.text = "<color=" + color1 + ">" + question.Substring(0, letters) + "</color>" +
                                    "<color=" + color2 + ">" + question.Substring(letters, 1) + "</color>" +
                                    "<color=" + color3 + ">" + question.Substring(letters + 1, 1) + "</color>" +
                                    "<color=" + color4 + ">" + question.Substring(letters + 2, question.Length - 1 - letters - 2) +
                                    "</color>";
            }
            if (letters == question.Length)
            {
                questionText.text = question;
            }
            questionLetterOutput += letterOutputSpeed * Time.deltaTime;

            if (letters > question.Length - 1)
            {
                letters           = question.Length - 1;
                questionText.text = "" + question;
                state             = QAControllerState.waitingForAnswer;

                for (int i = 0; i < maxAnswers; ++i)
                {
                    answerGO [i] = null;
                }

                float yPos = YAdjust - (question.Length / QuestionLettersPerLine) * QuestionLineHeight;
                for (int i = 0; i < ab.nItems(); ++i)
                {
                    GameObject newAnswer;
                    newAnswer = Instantiate(QAnswerPrefab);
                    newAnswer.transform.SetParent(answerPanel.transform);
                    newAnswer.transform.localScale = Vector3.one;
                    newAnswer.GetComponent <RectTransform>().sizeDelta        = new Vector2(800, 45);
                    newAnswer.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
                    newAnswer.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
                    newAnswer.GetComponent <QAAnswer> ().initialize(yPos);
                    newAnswer.GetComponent <QAAnswer> ().answerNumber = i + 1;
                    int nLines;
                    newAnswer.GetComponent <QAAnswer> ().setText(StringUtils.chopLines(ab.getNextString(), 85, out nLines));
                    newAnswer.GetComponent <QAAnswer> ().setDelay(i * 0.3f);
                    yPos        -= (InterAnswerDistance + AnswerLineHeight * (nLines - 1));
                    answerGO [i] = newAnswer;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer)
        {
            bool waiting = true;
            for (int i = 0; i < ab.nItems(); i++)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().state != QAAnswerState.idle)
                {
                    waiting = false;
                }
                else
                {
                    waiting = true;
                }
            }

            if (waiting)
            {
                for (int i = 0; i < ab.nItems(); i++)
                {
                    answerGO [i].GetComponent <QAAnswer> ().state = QAAnswerState.ready;
                    state = QAControllerState.waitingForAnswer2;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer2)
        {
        }

        if (state == QAControllerState.answered)
        {
            letterOutputSpeed = slowletterOutputSpeed;
            for (int i = 0; i < ab.nItems(); ++i)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().answerNumber != selectedAnswer)
                {
                    answerGO [i].GetComponent <QAAnswer> ().dispose();
                }
                else
                {
                    answerGO [i].GetComponent <QAAnswer> ().blink(selectedAnswer == correctAnswer);
                    if (selectedAnswer == correctAnswer)
                    {
                        levelRef.playSound(hitSound);
                    }
                    else
                    {
                        levelRef.playSound(missSound);
                    }
                }
            }

            elapsedTime = 0.0f;
            state       = QAControllerState.preparingNextQuestion;
        }

        if (state == QAControllerState.preparingNextQuestion)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                elapsedTime = 0.0f;
                state       = QAControllerState.preparingNextQuestion2;
                if (selectedAnswer == correctAnswer)
                {
                    burn [currentQuestion].burstInFlames();
                }
                else
                {
                    ++nMisses;
                    if (nMisses > 1)
                    {
                        fader._wa_fadeOut(this);
                        keyChannel = -1;
                        // mark this flame for resurrection, please
                        string lvl           = ds.retrieveStringValue("CurrentLevelFlame");
                        int    FlameIndex    = ds.retrieveIntValue("CurrentFlameIndex");
                        string FlameName     = ds.retrieveStringValue("FlameResurrectionName" + lvl + FlameIndex);
                        string FlameLocation = ds.retrieveStringValue("FlameResurrectionLocation" + lvl + FlameIndex);
                        ds.storeIntValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, 3);
                        ds.storeStringValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, FlameName);
                        this.isWaitingForActionToComplete = true;
                        state = QAControllerState.exitting3;
                    }
                }
                if (currentQuestion == numQuestions - 1)
                {
                    //fader._wa_fadeOut (this);
                    //this.isWaitingForActionToComplete = true;
                    /* do the flower thing */
                    flowerRenderQuad.GetComponent <GameObjectFader> ().fadeIn();
                    flowerAnim.SetBool("open", true);
                    spark1Anim.SetBool("open", true);
                    spark2Anim.SetBool("open", true);
                    spark3Anim.SetBool("open", true);
                    levelRef.dipMusic(4);
                    levelRef.playSound(sparksSound);
                    sparkTargetScale = 60.0f;
                    elapsedTime      = 0.0f;
                    state            = QAControllerState.exitting1;
                }
            }
        }

        if (state == QAControllerState.preparingNextQuestion2)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                questionText.text = "";
                ++currentQuestion;
                state = QAControllerState.idle;
            }
        }

        if (state == QAControllerState.exitting1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 5.6f)
            {
                fader.setFadeColor(1, 1, 1);
                fader._wa_fadeOut(this);
                keyImageFader.fadeIn();
                youGotAKeyTextFader.fadeIn();
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting2;
            }
        }

        if (state == QAControllerState.exitting2)
        {
            if (!isWaitingForActionToComplete)
            {
                levelRef.playSound(winSound);
                elapsedTime = 0.0f;
                state       = QAControllerState.exitting3;
            }
        }

        if (state == QAControllerState.exitting3)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 2.0f)
            {
                secondFader.setFadeValue(1.0f);
                secondFader.setFadeColor(0, 0, 0);
                secondFader._wa_fadeOut(this);
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting4;
            }
        }

        if (state == QAControllerState.exitting4)
        {
            string rLoc = mcRef.getStorage().retrieveStringValue("ReturnLocation");
            string lvl  = rLoc.Substring(0, 6);

            if (isWaitingForActionToComplete)
            {
            }
            else
            {
                switch (keyChannel)
                {
                case 0:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "RedKey", true);
                    break;

                case 1:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "OrangeKey", true);
                    break;

                case 2:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BlueKey", true);
                    break;

                case 3:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "GreenKey", true);
                    break;

                case 4:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "YellowKey", true);
                    break;

                case 5:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "PurpleKey", true);
                    break;

                case 6:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BrownKey", true);
                    break;
                }
                mcRef.getStorage().storeBoolValue("IsHUDCracked", false);                   // return HUD crack to non-crcked

                // increment number of keys
                string curLev = mcRef.getStorage().retrieveStringValue("CurrentLevel");
                int    n      = mcRef.getStorage().retrieveIntValue(curLev + "NumberOfKeys");
                ++n;
                mcRef.getStorage().storeIntValue(curLev + "NumberOfKeys", n);
                SceneManager.LoadScene(rLoc);
            }
        }
    }