コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // Items Dialog
        if (teddy.getColliderStateEnter() == true)
        {
            tState = true;
        }
        if (tState && Input.GetKeyDown(KeyCode.F))
        {
            dialogManager.setDialog("teddy.txt");
        }
        if (teddy.getColliderStateExit() == true)
        {
            tState = false;
        }

        if (wife.getColliderStateEnter() == true)
        {
            wState = true;
        }
        //Debug.Log ("This is wState: " + wState);
        if (wState && Input.GetKeyDown(KeyCode.F))
        {
            dialogManager.setDialog("wife.txt");
            //Debug.Log ("DialogManager finish");
        }
        if (wife.getColliderStateExit() == true)
        {
            wState = false;
        }

        if (basketball.getColliderStateEnter() == true)
        {
            bState = true;
        }
        if (bState && Input.GetKeyDown(KeyCode.F))
        {
            dialogManager.setDialog("basketball.txt");
        }
        if (basketball.getColliderStateExit() == true)
        {
            bState = false;
        }

        if (armchair.getColliderStateEnter() == true)
        {
            aState = true;
        }
        if (aState && Input.GetKeyDown(KeyCode.F))
        {
            dialogManager.setDialog("armchair.txt");
        }
        if (armchair.getColliderStateExit() == true)
        {
            aState = false;
        }

        if (isActive)
        {
            dialogManager.setRoom("room_A");
            player.setRoom("room_A");


            switch (eventCounter)
            {
            case 0:

                player.freeze();
                dialogManager.setDialog("thebeginning.txt");
                eventCounter++;
                break;

            case 1:
                if (dialogManager.getDialogOutput() == "falling")
                {
                    playerCamera.enabled = false;
                    if (victimCamera != null)
                    {
                        victimCamera.enabled = true;
                    }
                    float tempLocX  = victim.transform.position.x;
                    float tempLocY  = victim.transform.position.y;
                    float tempSizeX = victim.transform.localScale.x;
                    float tempSizeY = victim.transform.localScale.y;

                    fallingState = true;

                    if (fallingState)
                    {
                        if (victim.transform.position.y > -10.8f)
                        {
                            speed    += 9.82f * Time.deltaTime;
                            tempLocY  = victim.transform.position.y - 0.1f * Time.deltaTime * speed;
                            tempSizeX = victim.transform.localScale.x - 0.2f * Time.deltaTime;
                            tempSizeY = victim.transform.localScale.y - 0.24f * Time.deltaTime;
                        }

                        victim.transform.position   = new Vector3(tempLocX, tempLocY, 0f);
                        victim.transform.localScale = new Vector3(tempSizeX, tempSizeY, 1f);
                        if (victim.transform.position.y <= -10.8f)
                        {
                            victimSprite.enabled = false;
                        }
                    }
                }
                if (dialogManager.getDialogOutput() == "fallingEnd")
                {
                    if (victimCamera != null)
                    {
                        victimCamera.enabled = false;
                    }
                    playerCamera.enabled = true;
                    fallingState         = false;
                    Destroy(victim);
                }
                if (dialogManager.getDialogOutput() == "endingDialogue")
                {
                    audio.GetComponent <AudioSource> ().Play();
                    player.unfreeze();
                    roomSolved = true;
                    eventCounter++;
                }
                break;

            case 2:
                break;
            }

            if (roomSolved)
            {
                if (exitDoor.isLocked())
                {
                    File.Delete("dialog/room_A/ItemHolder.txt");

                    aDark          = GameObject.Find("anfangsraumD").GetComponent <SpriteRenderer>();
                    aDark.enabled  = true;
                    r1Dark         = GameObject.Find("raum1D").GetComponent <SpriteRenderer>();
                    r1Dark.enabled = false;
                    endAndProceed();
                }
            }
        }
    }
コード例 #2
0
    //Executing commands found in txt files:
    //===================================================
    private void executeMetaCommand(string metaCommand)
    {
        bool   isValue = false;
        string command = "";
        string value   = "";

        for (int i = 0; i < metaCommand.Length; i++)
        {
            if (metaCommand [i] == ':')
            {
                isValue = true;
            }
            else
            {
                if (isValue == false)
                {
                    command += metaCommand [i];
                }
                if (isValue == true)
                {
                    value += metaCommand [i];
                }
            }
        }
        Debug.Log("Command: " + command);
        Debug.Log("Value: " + value);

        //if - if else routing: Executing according to command! (If recognizable)
        //===================================================
        if (command == "timeout")
        {
            float time = 0;
            if (float.TryParse(value, out time))
            {
                //dialogAusgabe.text = currentLine;
                Debug.Log("Timout initiated by dialog script!");
                StartCoroutine(timeoutFor(time));
            }
            else
            {
                Debug.Log("Dialog command 'timeout' failed!");
            }
            dialogAusgabe.text = currentLine;
        }
        //===================================================
        else if (command == "playsound")
        {
            Debug.Log("Playsound command executing! ->filename: " + value);
            loadAndPlaySoundFile(value, unterverzeichnis);
        }
        //===================================================
        else if (command == "unlockExit")
        {
            if (currentExitDoor != null)
            {
                currentExitDoor.setIsLocked();
                Debug.Log("Exit unlocked through dialog script!");
            }
        }
        //===================================================
        else if (command == "choice")
        {
            Debug.Log("...executing choice command now...");
            string content = "Choose: \n";
            //dialogAusgabe.text = content;
            string currentChoice = "";
            bool   isChoice      = false;
            int    choiceCounter = 0;

            for (int i = 0; i < value.Length; i++)
            {
                if (isChoice == true)
                {
                    if (value [i] == '"')
                    {
                        isChoice = false;
                        globalChoiceCount++;                        // How many choices are there?
                        choiceCounter++;
                        Debug.Log("Choice: " + currentChoice);
                        content      += choiceCounter + ": " + currentChoice + "\n";
                        currentChoice = "";
                    }
                    else
                    {
                        currentChoice += value [i];
                    }
                }
                else
                {
                    if (value [i] == '"')
                    {
                        isChoice = true;
                    }
                }
            }
            currentLine += content;
        }        //===================================================
        else if (command == "waitForAnswer")
        {
            dialogAusgabe.text = currentLine;
            currentLine        = "";
            waitingForAnswer   = true;
        }        //===================================================
        else if (command == "jumpTo")
        {
            Debug.Log("JumpTo command active!");
            for (int i = 0; i < value.Length; i++)
            {
                if (value [i] == '#')
                {
                    jumpToString += AnswerID;
                }
                else
                {
                    jumpToString += value [i];
                }
            }
            Debug.Log("JumptToString has been set to: " + jumpToString);
        }        //===================================================
        else if (command == "freezeFor")
        {
            int time = 0;
            if (int.TryParse(value, out time))
            {
                player.setFreezeFor(time);
                Debug.Log("Player frozen through dialog script!");
            }
            else
            {
                Debug.Log("Dialog command 'freezeFor' failed!");
            }
        }        //===================================================
        else if (command == "freeze")
        {
            player.freeze();
        }        //===================================================
        else if (command == "unfreeze")
        {
            player.unfreeze();
        }        //===================================================
        else if (command == "waitForEnter")
        {
            dialogAusgabe.text = currentLine;
            currentLine        = "";
            waitingForEnter    = true;
        }        //===================================================
        else if (command == "movePlayerTo")
        {
            bool   check            = false;
            float  x                = 0;
            float  y                = 0;
            string currentValuePart = "";

            for (int i = 0; i < value.Length; i++)
            {
                if (check == false)
                {
                    if (value [i] != ',')
                    {
                        currentValuePart += value [i];
                    }
                    else
                    {
                        Debug.Log("Current valuePart x: " + currentValuePart);
                        if (float.TryParse(currentValuePart, out x))
                        {
                            //dialogAusgabe.text = currentLine;
                            Debug.Log("x initiated by dialog script!");
                        }
                        else
                        {
                            Debug.Log("Dialog command 'movePlayerTo' failed!");
                        }
                        currentValuePart = "";
                        check            = true;
                    }
                }
                else
                {
                    if (value [i] <= '9')
                    {
                        currentValuePart += value [i];
                    }
                }
            }

            Debug.Log("Current valuePart y: " + currentValuePart);
            if (float.TryParse(currentValuePart, out y))
            {
                //dialogAusgabe.text = currentLine;
                Debug.Log("y initiated by dialog script!");
            }
            else
            {
                Debug.Log("Dialog command 'movePlayerTo' failed!");
            }

            player.moveTo(x, y);
            currentValuePart = "";
            check            = true;
        }        //===================================================
        else if (command == "movePlayerRelative")
        {
            bool   check            = false;
            float  x                = 0;
            float  y                = 0;
            string currentValuePart = "";

            for (int i = 0; i < value.Length; i++)
            {
                if (check == false)
                {
                    if (value [i] != ',')
                    {
                        currentValuePart += value [i];
                    }
                    else
                    {
                        Debug.Log("Current valuePart x: " + currentValuePart);
                        if (float.TryParse(currentValuePart, out x))
                        {
                            //dialogAusgabe.text = currentLine;
                            Debug.Log("x initiated by dialog script!");
                        }
                        else
                        {
                            Debug.Log("Dialog command 'movePlayerTo' failed!");
                        }
                        currentValuePart = "";
                        check            = true;
                    }
                }
                else
                {
                    if (value [i] <= '9')
                    {
                        currentValuePart += value [i];
                    }
                }
            }

            Debug.Log("Current valuePart y: " + currentValuePart);
            if (float.TryParse(currentValuePart, out y))
            {
                //dialogAusgabe.text = currentLine;
                Debug.Log("y initiated by dialog script!");
            }
            else
            {
                Debug.Log("Dialog command 'movePlayerRelative' failed!");
            }
            Debug.Log("Player is being moved by vector: " + x + ", " + y + ";");
            player.moveRelative(x, y);
        }        //===================================================
        else if (command == "returnMessage")
        {
            dialogOutput = value;
        }        //===================================================
        else if (command == "enableDisplay")
        {
            display.enabled = true;
        }        //===================================================
        else if (command == "disableDisplay")
        {
            display.enabled = false;
        }
        else if (command == "exitDialog")
        {
            Debug.Log("Dialog has been ended by meta command! dialog index: " + dialogIndex);
            rawDialog          = "";   //Interpretation is done! rawDialog empty now!
            display.enabled    = false;
            dialogAusgabe.text = "";
            currentLine        = "";
            dialogIndex        = 0;
            dialogtxt          = "";
        }
        else if (command == jumpToString)
        {
            jumpToString = "";
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)
        {
            dialogManager.setRoom("room_5");
            player.setRoom("room_5");

            switch (eventCounter)
            {
            case 0:
                if (event1.getColliderStateEnter() == true)
                {
                    audio.GetComponent <AudioSource> ().Play();

                    player.freeze();
                    dialogManager.setDialog("beforeTheEnd.txt");
                }
                if (dialogManager.getDialogOutput() == "endingDialogue")
                {
                    player.unfreeze();
                    eventCounter++;
                }

                break;

            case 1:
                if (event2.getColliderStateEnter() == true)
                {
                    player.freeze();
                    dialogManager.setDialog("scaryScene.txt");
                }
                if (dialogManager.getDialogOutput() == "endingDialogue2")
                {
                    player.unfreeze();
                    eventCounter++;
                }

                break;


            case 2:
                eventCounter++;

                break;

            case 3:
                roomSolved = true;
                eventCounter++;
                break;

            case 4:
                break;
            }



            if (roomSolved)
            {
                if (exitDoor.checkDark())
                {
                    File.Delete("dialog/room_5/ItemHolder.txt");
                    endAndProceed();
                }
            }
        }
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)
        {
            dialogManager.setRoom("room_3");
            player.setRoom("room_3");

            switch (eventCounter)
            {
            case 0:
                if (event1.getColliderStateEnter())
                {
                    player.freeze();

                    if (player.getFirstItem() != null)
                    {
                        //Debug.Log ("FirstIsntHere");
                        dialogManager.setDialog("someitems.txt");
                        firstTime = false;
                    }
                    else if (firstTime)
                    {
                        dialogManager.setDialog("noitems.txt");
                    }
                    else
                    {
                        dialogManager.setDialog("lostitems.txt");
                        eventCounter++;
                    }
                }
                if (dialogManager.getDialogOutput() == "falling")
                {
                    collider.enabled = false;
                    if (timeCounter < 2f)
                    {
                        tempPlanken = planken.transform.position.y + Time.deltaTime * 2f;

                        planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z);
                    }

                    if (timeCounter > .5f && (spieler.transform.position.y > 14))
                    {
                        tempPlanken = spieler.transform.position.y - Time.deltaTime * 1f;

                        spieler.transform.position = new Vector3(spieler.transform.position.x, tempPlanken, spieler.transform.position.z);

                        tempPlanken = spieler.transform.localScale.y - 0.05f * Time.deltaTime;

                        spieler.transform.localScale = new Vector3(tempPlanken, tempPlanken, 1f);
                    }

                    if (timeCounter > 1.5f && timeCounter < 3.5f)
                    {
                        tempPlanken = planken.transform.position.y - Time.deltaTime * 2f;

                        planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z);
                    }
                    else if (timeCounter > 3.5f)
                    {
                        spieler.transform.localScale = new Vector3(0.025f, 0.025f, 1f);
                        timeCounter = 0f;
                        player.setSpeed(1f);
                        collider.enabled = true;
                        //player.unfreeze ();
                        dialogManager.setDialogOutputTo("");
                    }

                    timeCounter += Time.deltaTime;
                }
                if (dialogManager.getDialogOutput() == "delete")
                {
                    player.deleteIventory();
                }
                if (dialogManager.getDialogOutput() == "endDialog")
                {
                    //Debug.Log ("endDialog = true");
                    endDialog = true;
                }

                if (dialogManager.getDialogOutput() == "unfreeze")
                {
                    player.unfreeze();
                    dialogManager.setDialogOutputTo("");
                }
                if (dialogManager.isActive() == false && endDialog)
                {
                    eventCounter++;
                }



                break;

            case 1:
                player.unfreeze();
                eventCounter++;

                break;


            case 2:
                eventCounter++;

                break;

            case 3:

                exitDoor.setIsLocked();                 //exitDoor locked=false!! (unlock)
                roomSolved = true;
                eventCounter++;
                break;

            case 4:
                break;
            }



            if (roomSolved)
            {
                if (exitDoor.isLocked())
                {
                    File.Delete("dialog/room_3/ItemHolder.txt");
                    r4Dark         = GameObject.Find("raum4D").GetComponent <SpriteRenderer>();
                    r4Dark.enabled = false;
                    r3Dark         = GameObject.Find("raum3D").GetComponent <SpriteRenderer>();
                    r3Dark.enabled = true;
                    //audio.GetComponent<AudioSource> ().Stop ();
                    endAndProceed();
                }
            }
        }
    }