OpenDoor() private method

private OpenDoor ( ) : IEnumerator
return IEnumerator
Ejemplo n.º 1
0
    protected override void OnMouseUp()
    {
        playerPosition = GameObject.Find("Player").transform;

        // Academy
        if (sceneName == "Academy")
        {
            if (Mathf.Abs(transform.position.x - targetBlock[0].position.x) <= 0.5f &&
                Mathf.Abs(transform.position.y - targetBlock[0].position.y) <= 0.5f)
            {
                transform.position = new Vector2(targetBlock[0].position.x, targetBlock[0].position.y);
                SceneManager.LoadScene("Outside Academy");
            }
            else if (Mathf.Abs(transform.position.x - targetBlock[1].position.x) <= 0.5f &&
                     Mathf.Abs(transform.position.y - targetBlock[1].position.y) <= 0.5f)
            {
                transform.position = new Vector2(targetBlock[1].position.x, targetBlock[1].position.y);
                DoorOpen.OpenDoor();
                transform.position = new Vector2(playerPosition.position.x + initialPosition.x, playerPosition.position.y + initialPosition.y);
            }
            else
            {
                for (int i = 0; i < targetBlocks.Length; i++)
                {
                    if (Mathf.Abs(transform.position.x - targetBlocks[i].transform.position.x) <= 0.5f &&
                        Mathf.Abs(transform.position.y - targetBlocks[i].transform.position.y) <= 0.5f)
                    {
                        Progress.emotion++;
                    }
                }

                transform.position = new Vector2(playerPosition.position.x + 4.382f, playerPosition.position.y + 3.119f);
            }
        }
        // Outside Academy
        if (sceneName == "Outside Academy")
        {
            if (Mathf.Abs(transform.position.x - targetBlockSingle.position.x) <= 0.5f &&
                Mathf.Abs(transform.position.y - targetBlockSingle.position.y) <= 0.5f)
            {
                transform.position = new Vector2(targetBlockSingle.position.x, targetBlockSingle.position.y);
                SceneManager.LoadScene("Academy");
                Progress.previousScene = "Outside Academy";
                Progress.exp++;
            }
            else
            {
                for (int i = 0; i < targetBlocks.Length; i++)
                {
                    if (Mathf.Abs(transform.position.x - targetBlocks[i].transform.position.x) <= 0.5f &&
                        Mathf.Abs(transform.position.y - targetBlocks[i].transform.position.y) <= 0.5f)
                    {
                        Progress.emotion++;
                    }
                }

                transform.position = new Vector2(playerPosition.position.x + 4.382f, playerPosition.position.y + 3.119f);
            }
        }
    }
Ejemplo n.º 2
0
    public void enemyKilled()
    {
        enemiesKilled++;
        if (enemiesKilled == enemiesInLevel)
        {
            exitDoor.OpenDoor();
        }

        PlayerStats.currentRespawnPoint = playerController.transform.position;
    }
Ejemplo n.º 3
0
    //void OnCollisionEnter(Collision col)
    //{
    //if (col.gameObject.name == "Player" || col.gameObject.CompareTag("RollingRock"))
    //{
    //if (Door.IsClosed)
    //{
    //	Door.OpenDoor();
    //	anim.SetBool("EnableSwitch", true);
    //}
    //}
    //}

    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.CompareTag("Lazerbeam") || col.gameObject.name == "Player" || col.gameObject.CompareTag("RollingRock"))
        {
            if (Door.IsClosed && CanPlay)
            {
                Door.OpenDoor();
                anim.SetBool("EnableSwitch", true);
                StartCoroutine(PlaySound());
                CanPlay = false;
            }
        }
    }
Ejemplo n.º 4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Ball")
     {
         currentWeightOnPlatform += other.GetComponent <Rigidbody>().mass;
     }
     if (other.tag == "Chair")
     {
         currentWeightOnPlatform += other.GetComponent <Rigidbody>().mass;
     }
     if (other.tag == "Player")
     {
         currentWeightOnPlatform += other.GetComponent <Rigidbody>().mass;
     }
     if (currentWeightOnPlatform >= doorOpenThreshold)
     {
         door.OpenDoor();
     }
 }
    void FixedUpdate()
    {
        if (HP < 0)
        {
            deadCamera.gameObject.SetActive(true);
            deadCamera.gameObject.transform.position = this.transform.position;
            this.gameObject.SetActive(false);
        }
        RaycastHit hit;
        Ray        ray = playerCamera.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            GameObject objectHit = hit.collider.gameObject;
            float      dist      = Vector3.Distance(objectHit.transform.position, this.transform.position);



            if (objectHit.CompareTag("door"))
            {
                if (dist < 5)
                {
                    if (objectHit.gameObject.GetComponent("DoorOpen") != null)
                    {
                        at = objectHit.gameObject.GetComponent <DoorOpen> ();
                        _consoleLD41.mainConsole.tipsDoor.gameObject.SetActive(true);
                        isOkayToOpenDoor = true;
                    }
                }
                else
                {
                    _consoleLD41.mainConsole.tipsDoor.gameObject.SetActive(false);
                    isOkayToOpenDoor = false;
                }
            }
            else
            {
                _consoleLD41.mainConsole.tipsDoor.gameObject.SetActive(false);
                isOkayToOpenDoor = false;
            }

            if (objectHit.CompareTag("food"))
            {
                if (dist < 2)
                {
                    if (objectHit.gameObject.GetComponent("FoodObject") != null)
                    {
                        fo = objectHit.gameObject.GetComponent <FoodObject> ();
                        isOkayToTakeItem = true;
                        _consoleLD41.mainConsole.tipsFood.gameObject.SetActive(true);
                    }
                }
                else
                {
                    isOkayToTakeItem = false;
                    _consoleLD41.mainConsole.tipsFood.gameObject.SetActive(false);
                }
            }
            else
            {
                isOkayToTakeItem = false;
                _consoleLD41.mainConsole.tipsFood.gameObject.SetActive(false);
            }


            if (objectHit.CompareTag("cook"))
            {
                if (dist < 4)
                {
                    _consoleLD41.mainConsole.tipsCooking.gameObject.SetActive(true);
                    isOkayToCook = true;
                }
                else
                {
                    _consoleLD41.mainConsole.tipsCooking.gameObject.SetActive(false);
                    isOkayToCook = false;
                }
            }
            else
            {
                _consoleLD41.mainConsole.tipsCooking.gameObject.SetActive(false);
                isOkayToCook = false;
            }



            if (objectHit.CompareTag("craftingTable"))
            {
                if (dist < 4)
                {
                    _consoleLD41.mainConsole.tipsCrafting.gameObject.SetActive(true);
                    isOkayToCraft = true;
                }
                else
                {
                    _consoleLD41.mainConsole.tipsCrafting.gameObject.SetActive(false);
                    isOkayToCraft = false;
                }
            }
            else
            {
                _consoleLD41.mainConsole.tipsCrafting.gameObject.SetActive(false);
                isOkayToCraft = false;
            }

            if (objectHit.CompareTag("wash"))
            {
                if (dist < 4)
                {
                    _consoleLD41.mainConsole.tipsWashing.gameObject.SetActive(true);
                    isOkayToGetWaterFromSinkWash = true;
                }
                else
                {
                    _consoleLD41.mainConsole.tipsWashing.gameObject.SetActive(false);
                    isOkayToGetWaterFromSinkWash = false;
                }
            }
            else
            {
                _consoleLD41.mainConsole.tipsWashing.gameObject.SetActive(false);
                isOkayToGetWaterFromSinkWash = false;
            }
        }



        if (isOkayToOpenDoor)
        {
            if (Input.GetKeyUp(KeyCode.E))
            {
                if (at.isOpen)
                {
                    at.CloseDoor();
                }
                else
                {
                    at.OpenDoor();
                }
            }
        }

        if (isOkayToTakeItem)
        {
            if (Input.GetButtonUp("Fire1"))
            {
                if (_consoleLD41.mainConsole.FindingAllPossibleEmptySlot() != null)
                {
                    BackpackSlot BS = _consoleLD41.mainConsole.FindingAllPossibleEmptySlot();
                    _consoleLD41.mainConsole.RegisterItem(BS, fo.itemID, fo.gameObject);
                    fo.gameObject.transform.position = placeholderPhysicalObject.transform.position;
                    fo.gameObject.transform.parent   = placeholderPhysicalObject.transform;
                    fo.gameObject.SetActive(false);
                    fo = null;
                }
            }
        }

        if (isOkayToCook)
        {
            if (Input.GetKeyUp(KeyCode.E))
            {
                _consoleLD41.mainConsole.CookingMode();
            }
        }

        if (isOkayToCraft)
        {
            if (Input.GetKeyUp(KeyCode.E))
            {
                _consoleLD41.mainConsole.CraftingResult();
            }
        }

        if (isOkayToGetWaterFromSinkWash)
        {
            if (Input.GetKeyUp(KeyCode.E))
            {
                _consoleLD41.mainConsole.FillWaterInsideContainer();
            }
        }

        if (currentWeaponID != 0)
        {
            if (Input.GetButtonUp("Fire1"))
            {
                if (currentWeaponID != 1)
                {
                    Instantiate(whatProjectiles [currentWeaponID], projectileOut.position, projectileOut.rotation);
                    _consoleLD41.mainConsole.EverySinglePeoplePanic();
                }
                else if (currentWeaponID == 1 && !isOkayToTakeItem)
                {
                    //BANANAS SECTION

                    int ifThereisBananas = 0;

                    for (int x = 0; x < _consoleLD41.mainConsole.backpackSlots.Count; x++)
                    {
                        if (_consoleLD41.mainConsole.backpackSlots [x].itemID == 2)
                        {
                            ifThereisBananas++;
                        }
                    }

                    if (ifThereisBananas > 0)
                    {
                        Instantiate(whatProjectiles [currentWeaponID], projectileOut.position, projectileOut.rotation);
                        _consoleLD41.mainConsole.EverySinglePeoplePanic();

                        RequireCertainAmmunition(2);
                    }

                    //END SECTION
                }
                if (currentWeaponID == 2)
                {
                    RemoveWeapon();
                }
                if (currentWeaponID == 3)
                {
                    RemoveWeapon();
                }
                if (currentWeaponID == 4)
                {
                    RemoveWeapon();
                }
            }
        }
    }