コード例 #1
0
    public void increaseTeleRate(int reduceTime)
    {
        CollectPaper paperScript = GameObject.Find("Papers").GetComponent <CollectPaper>();

        teleportRate     = 10f - reduceTime;
        teleportDistance = 50f - reduceTime * 5;
        InvokeRepeating("TeleportEnemy", 1, teleportRate);
        if (paperScript.papers >= paperScript.papersToWin)
        {
            teleportDistance = 5f;
        }
    }
コード例 #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, interactDistance))
            {
                if (hit.collider.CompareTag("HouseScene"))
                {
                    if (SceneManager.GetActiveScene().name.Equals("Game"))
                    {
                        SaveState();
                    }
                    SceneManager.LoadScene("Inside");
                }
                else if (hit.collider.CompareTag("Door"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();


                    if (doorScript == null)
                    {
                        return;
                    }

                    if (doorScript.name == "hinge")
                    {
                        doorScript.ChangeDoorState();
                        return;
                    }

                    pauseController notDoor = GameObject.Find("PauseMenuController").GetComponent <pauseController> ();

                    if (inventory != null && inventory.keys [doorScript.index] == true)
                    {
                        doorScript.ChangeDoorState();
                    }
                    else if (doorScript.index == 3)
                    {
                        notDoor.BadDoorNot();
                    }
                    else
                    {
                        notDoor.GoodDoorNot();
                    }
                }
                else if (hit.collider.CompareTag("Key"))
                {
                    if (inventory != null)
                    {
                        if (hit.collider.gameObject.name == "Key1")
                        {
                            inventory.keys [1] = true;
                        }
                        else if (hit.collider.gameObject.name == "Key2")
                        {
                            inventory.keys [2] = true;
                        }
                        else if (hit.collider.gameObject.name == "Key3")
                        {
                            inventory.keys [3] = true;
                        }
                    }
                    AudioSource.PlayClipAtPoint(keyPickup, hit.collider.transform.position);
                    Destroy(hit.collider.gameObject);
                }
                else if (hit.collider.CompareTag("NextLeveldoor"))
                {
                    if (SceneManager.GetActiveScene().name.Equals("Inside"))
                    {
                        SaveState();
                    }
                    SceneManager.LoadScene("Game");
                }


                else if (hit.collider.CompareTag("Rock"))
                {
                    Debug.Log(hit.collider.name);
                    if (papers)
                    {
                        Debug.Log("in paper");

                        CollectPaper paperScript = papers.GetComponent <CollectPaper>();
                        if (paperScript.papers >= paperScript.papersToWin)
                        {
                            Destroy(GameObject.Find("PlayerState"));
                            SceneManager.LoadScene("Win");
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (goodDoor && badDoor)
            {
                if (maps.gameObject.activeInHierarchy == false && winScene.gameObject.activeInHierarchy == false &&
                    instruction.gameObject.activeInHierarchy == false && goodDoor.gameObject.activeInHierarchy == false &&
                    badDoor.gameObject.activeInHierarchy == false)
                {
                    Pause();
                }
                else if (maps.gameObject.activeInHierarchy == true)
                {
                    mapSetting();
                }
                else if (winScene.gameObject.activeInHierarchy == true)
                {
                    winNarrative();
                }
                else if (instruction.gameObject.activeInHierarchy == true)
                {
                    loadInstruction();
                }
                else if (goodDoor.gameObject.activeInHierarchy == true)
                {
                    GoodDoorNot();
                }
                else if (badDoor.gameObject.activeInHierarchy == true)
                {
                    BadDoorNot();
                }
            }
            else
            {
                if (maps.gameObject.activeInHierarchy == false && winScene.gameObject.activeInHierarchy == false &&
                    instruction.gameObject.activeInHierarchy == false)
                {
                    Pause();
                }
                else if (maps.gameObject.activeInHierarchy == true)
                {
                    mapSetting();
                }
                else if (winScene.gameObject.activeInHierarchy == true)
                {
                    winNarrative();
                }
                else if (instruction.gameObject.activeInHierarchy == true)
                {
                    loadInstruction();
                }
            }
        }

        GameObject   paper       = GameObject.Find("Papers");
        CollectPaper paperScript = paper.GetComponent <CollectPaper>();



        int paperNo = paperScript.papers;

        if (paperNo == 0)
        {
            map1.gameObject.GetComponent <Image>().enabled = true;
        }
        else if (paperNo == 1)
        {
            map1.gameObject.GetComponent <Image>().enabled = false;
            map2.gameObject.GetComponent <Image>().enabled = true;
            lastPaperChange = true;
        }
        else if (paperNo == 2)
        {
            map2.gameObject.GetComponent <Image>().enabled = false;
            map3.gameObject.GetComponent <Image>().enabled = true;
            lastPaperChange = true;
        }
        else if (paperNo == 3)
        {
            map3.gameObject.GetComponent <Image>().enabled = false;
            map4.gameObject.GetComponent <Image>().enabled = true;
            lastPaperChange = true;
        }
        else if (paperNo == 4)
        {
            map4.gameObject.GetComponent <Image>().enabled = false;
            map5.gameObject.GetComponent <Image>().enabled = true;
            lastPaperChange = true;
        }

        if (paperNo >= paperScript.papersToWin && playNarrative == true)
        {
            winNarrative();
            playNarrative = false;
        }
    }