private void OnTriggerEnter2D(Collider2D target)
    {
        if (ignoreTrigger)
        {
            return;
        }

        if (target.gameObject.tag == "Player")
        {
            door.OpenDoor();
        }
    }
 private void HandleDoorInputs()
 {
     if (Input.GetKeyDown(KeyCode.E) && m_IsInArea) // enable input when the player is in the trigger zone
     {
         if (m_Player.GetKeyCount() == m_Door.GetDoorID())
         {
             m_Door.OpenDoor();
             Destroy(gameObject);
             KeyText.text = "";
         }
     }
 }
Esempio n. 3
0
    // GrabObj grabs the given object and opens the corresponding door.
    private void GrabObj(GameObject obj)
    {
        holdingSomething = true;
        Vector3 target = this.transform.position;

        // We want them to target a point near the middle of the act, so adjust accordingly.
        target.y = target.y + 0.35f;
        obj.GetComponent <Grabbed>().targetPoint = target;
        obj.GetComponent <Grabbed>().enabled     = true;

        // Open the corresponding door.
        Door.OpenDoor();
    }
Esempio n. 4
0
    private void HandleDoors()
    {
        if (areAllEnemiesDead)
        {
            //Debug.Log("all enemies dead");
            //open the exit scene doors
            if (Door1_Exit != null)
            {
                Door1_Exit.OpenDoor();
            }
            if (Door2_Exit != null)
            {
                Door2_Exit.OpenDoor();
            }
            if (Door3_Exit != null)
            {
                Door3_Exit.OpenDoor();
            }
        }
        else if (startNewLevel)
        {
            Debug.Log("start new level");

            //close all doors
            if (Door1_Exit != null)
            {
                Door1_Exit.CloseDoor();
            }
            if (Door2_Exit != null)
            {
                Door2_Exit.CloseDoor();
            }
            if (Door3_Exit != null)
            {
                Door3_Exit.CloseDoor();
            }

            if (Door1_Entry != null)
            {
                Door1_Entry.CloseDoor();
            }
            if (Door2_Entry != null)
            {
                Door2_Entry.CloseDoor();
            }
            if (Door3_Entry != null)
            {
                Door3_Entry.CloseDoor();
            }
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (NumberOfKeysLeft <= 0)
        {
            LevelDoors.OpenDoor();
        }

        if (Input.GetButtonDown("Cancel"))
        {
            Time.timeScale = Time.timeScale == 0 ? 1 : 0;
            PausePanel.SetActive(!PausePanel.activeInHierarchy);
        }

        if (oldVolume != VolumeControl.value)
        {
            AudioListener.volume = VolumeControl.value;
            oldVolume            = VolumeControl.value;
        }
    }
Esempio n. 6
0
 public void InteractWithDoor(Transform door)
 {
     for (int i = 0; i < doorList.Count; i++)
     {
         if (door == doorList[i])
         {
             DoorScript temp = doorList[i].GetComponent <DoorScript>();
             if (!temp.Open)
             {
                 temp.OpenDoor();
             }
             else
             {
                 temp.CloseDoor();
             }
             break;
         }
     }
 }
Esempio n. 7
0
 void Update()
 {
     if (suihku == true && ruoka == true)
     {
         time += 1 * Time.deltaTime;
         if (time > 2)
         {
             shower.Hide();
             food.Hide();
             sausage.ShowItem();
             salad.ShowItem();
             beer.ShowItem();
             door.OpenDoor();
             suihku = false;
             time   = 0;
         }
     }
     if (satisfaction >= 3)
     {
         SetFood();
     }
     if (shopping >= 3)
     {
         time += 1 * Time.deltaTime;
         Debug.Log(time);
         if (time > 1)
         {
             sausage.Hide();
             salad.Hide();
             beer.Hide();
             goHome.ShowItem();
             crash.CrashReady();
             anime.Animate();
             shopping = 0;
         }
     }
 }
Esempio n. 8
0
 private void OpenDoor(DoorScript door)
 {
     door.OpenDoor();
 }
Esempio n. 9
0
    // Функция* Показ панель предмета
    void DetectItem()
    {
        RaycastHit pickHit;
        Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));

        if (Physics.Raycast(ray, out pickHit, 3, LayerMask.GetMask("Door")))
        {
            CrossHair.color = Color.blue;
            if (Input.GetMouseButtonDown(0))
            {
                if (pickHit.transform.tag == "brakebale")
                {
                    if (GetComponent <SubjectUse> ().MyModel.GetComponent <Item> ().item.id == 201)
                    {
                        if (pickHit.transform.GetComponent <DoorScript> ())
                        {
                            DoorScript _script = pickHit.transform.GetComponent <DoorScript> ();
                            _script.hp -= 20;
                            if (_script.hp <= 0)
                            {
                                _script.Locked = false;
                                _script.OpenDoor();
                            }
                            Player.GetComponent <Animator> ().SetBool("punch", true);
                            HitHair.gameObject.SetActive(true);
                            ChangeTimer(true, 3, 0.2f);
                            return;
                        }
                    }
                }
            }
        }
        else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Door")))
        {
            CrossHair.color = Color.green;
            if (Input.GetKeyDown(KeyCode.E))
            {
                if (pickHit.transform.GetComponent <MechanicDoorScript> ())
                {
                    MechanicDoorScript _script = pickHit.transform.GetComponent <MechanicDoorScript> ();
                    if (_script.Locked)
                    {
                        _script.OpenLockedDoor();
                    }
                    else
                    {
                        _script.OpenDoor();
                    }
                }
                else if (pickHit.transform.GetComponent <DoorScript> ())
                {
                    DoorScript _script = pickHit.transform.GetComponent <DoorScript> ();
                    if (!_script.Locked)
                    {
                        _script.OpenDoor();
                    }
                }
            }
            if (GetComponent <SubjectUse> ().MyModel)
            {
                Subject MyModel = GetComponent <SubjectUse> ().MyModel.GetComponent <Item> ().item;
                if (MyModel.id == 2 && Input.GetKeyDown(KeyCode.E))
                {
                    if (Player.GetComponent <FirstPersonController> ().m_PreviouslyGrounded)
                    {
                        if (pickHit.transform.GetComponent <DoorScript> ())
                        {
                            if (pickHit.transform.GetComponent <DoorScript> ())
                            {
                                DoorScript script = pickHit.transform.GetComponent <DoorScript> ();
                                if (script.Locked)
                                {
                                    script.OpenLockedDoor(MyModel.value);
                                }
                                else
                                {
                                    script.OpenDoor();
                                }
                            }
                        }
                    }
                }
            }
        }
        else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Static")))
        {
        }
        else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Interactible")))
        {
            CrossHair.color = Color.green;
            if (Input.GetKeyDown(KeyCode.E))
            {
                if (GetComponent <SubjectUse> ().MyModel)
                {
                    if (GetComponent <SubjectUse> ().MyModel.GetComponent <Item> ().item.id == 103)
                    {
                        ChangeTimer(true, 2, 1.5f);
                        pickHit.transform.gameObject.layer = LayerMask.GetMask("Default");
                        pickHit.transform.parent.GetChild(1).gameObject.layer = LayerMask.GetMask("Default");
                    }
                }
                if (pickHit.transform.tag == "box")
                {
                    pickHit.transform.tag = "Untagged";
                    NotificationIns(pickHit.transform.GetChild(0).GetComponent <Item>(), false);
                    AddItem(pickHit.transform.GetChild(0).GetComponent <Item>().gameObject);
                }
                if (pickHit.transform.tag == "button")
                {
                    GameInstaller.item.name = "Что-то прозвучало около поезда, нужно проверить";
                    NotificationIns(GameInstaller, true);
                    GameInstaller.GetComponent <GameInstaller> ().OpentwoDoor();
                }
            }
        }
        else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Pickable")))
        {
            if (pickHit.transform.GetComponent <Item>() != null)
            {
                CrossHair.color = Color.green;
                Item itemEq = pickHit.transform.GetComponent <Item>();
                if (!Input.GetKeyDown(KeyCode.E))
                {
                    Detected.text = itemEq.item.name;
                }
                else
                {
                    NotificationIns(itemEq, false);
                    AddItem(itemEq.gameObject);
                }
            }
        }
        else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Item")))
        {
            Item itemEq = pickHit.transform.GetComponent <Item>();
            if (itemEq != null)
            {
                CrossHair.color = Color.green;
                if (!Input.GetKeyDown(KeyCode.E))
                {
                    Detected.text = itemEq.item.name;
                }
                else
                {
                    NotificationIns(itemEq, false);
                    AddItem(itemEq.gameObject);
                }
            }
            else
            {
                itemEq = pickHit.transform.parent.GetComponent <Item>();
                if (itemEq)
                {
                    CrossHair.color = Color.green;
                    if (!Input.GetKeyDown(KeyCode.E))
                    {
                        Detected.text = itemEq.item.name;
                    }
                    else
                    {
                        NotificationIns(itemEq, false);
                        AddItem(itemEq.gameObject);
                    }
                }
            }
            return;
        }
        else
        {
            CrossHair.color = Color.red;
            if (Detected.text != "")
            {
                Detected.text = "";
                return;
            }
        }
    }
Esempio n. 10
0
 void FixedUpdate()
 {
     if (GrabingObject)
     {
         Grabing();
     }
     if (newPlace != null)
     {
         Animate(newPlace);
     }
     else
     {
         if (UsingModel)
         {
             if (MyModel)
             {
                 if (Input.GetMouseButtonDown(0))
                 {
                     if (!DontPickable)
                     {
                         if (UsingOriginPosition)
                         {
                             Animate(PickOffset);
                         }
                         else
                         {
                             UsingModel = false;
                             MyModel.GetComponent <Rigidbody> ().velocity = transform.forward * throwPower;
                             //MyModel.gameObject.tag = "Untagged";
                             SetComponent(null, true);
                             throwPower = 10;
                             grabPower  = 10;
                             MyModel    = null;
                             if (GrabingObject)
                             {
                                 GrabingObject = false;
                             }
                         }
                     }
                     else
                     {
                         if (MyModel.GetComponent <Item>().item.id == 102)
                         {
                             transform.GetComponent <PlayerInventory>().ChangeTimer(true, 1, 1.5f);
                         }
                     }
                 }
                 else if (Input.GetMouseButtonDown(1) && !GrabingObject)
                 {
                     if (UsingOriginPosition)
                     {
                         transform.GetComponent <PlayerInventory> ().AddItem(MyModel.gameObject);
                         transform.GetComponent <PlayerInventory> ().NotificationIns(MyModel.GetComponent <Item>(), false);
                         Destroy(MyModel);
                         MyModel    = null;
                         UsingModel = false;
                     }
                     else
                     {
                         Animate(OriginOffset);
                     }
                 }
                 else
                 {
                     if (!GrabingObject)
                     {
                         RaycastHit pickHit;
                         Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
                         if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Door")))
                         {
                             if (MyModel.GetComponent <Item>().item.active&& Input.GetKeyDown(KeyCode.E))
                             {
                                 if (transform.GetComponent <FirstPersonController>().m_PreviouslyGrounded)
                                 {
                                     if (pickHit.transform.GetComponent <DoorScript>())
                                     {
                                         if (pickHit.transform.GetComponent <DoorScript>())
                                         {
                                             DoorScript script = pickHit.transform.GetComponent <DoorScript>();
                                             if (script.Locked)
                                             {
                                                 script.OpenLockedDoor(MyModel.GetComponent <Item>().item.value);
                                             }
                                             else
                                             {
                                                 script.OpenDoor();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         else
         {
             RaycastHit pickHit;
             Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
             if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Pickable")))
             {
                 if (Input.GetMouseButtonDown(1))
                 {
                     newPlace            = null;
                     UsingModel          = true;
                     MyModel             = pickHit.transform;
                     DontPickable        = false;
                     UsingOriginPosition = false;
                     GrabingObject       = true;
                     if (MyModel.gameObject.tag == "Hanger")
                     {
                         throwPower = 0;
                         grabPower  = 3;
                     }
                     Grabing();
                 }
             }
             else if (Physics.Raycast(ray, out pickHit, EquipDistance, LayerMask.GetMask("Door")))
             {
                 if (Input.GetKeyDown(KeyCode.E))
                 {
                     if (pickHit.transform.GetComponent <MechanicDoorScript>())
                     {
                         MechanicDoorScript _script = pickHit.transform.GetComponent <MechanicDoorScript>();
                         if (_script.Locked)
                         {
                             _script.OpenLockedDoor();
                         }
                         else
                         {
                             _script.OpenDoor();
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 11
0
    private void Update()
    {
        IsGrounded = Physics2D.Linecast(transform.position, transform.position + new Vector3(0, GroundedRaycastLength, 0), 1 << LayerMask.NameToLayer("Land"));

        Debug.DrawLine(transform.position, transform.position + new Vector3(0, GroundedRaycastLength, 0), Color.blue);

        // Doors
        if (Input.GetButtonDown("Vertical"))
        {
            if (CurrentDoor)
            {
                if (CurrentDoor.IsOpen)
                {
                    CurrentDoor.CloseDoor();
                }
                else
                {
                    CurrentDoor.OpenDoor();
                }
            }
            else if (CurrentNavigator)
            {
                Floor = CurrentNavigator.ThisLeadsTo.gameObject.GetComponent <NavigatorScript>().Floor;


                transform.position = CurrentNavigator.ThisLeadsTo.transform.position;
            }
        }

        // Jumping
        if (Input.GetButtonDown("Jump"))
        {
            if (IsGrounded && MyRigid.velocity.y >= 0)
            {
                MyRigid.gravityScale = 1;
                MyRigid.velocity     = new Vector2(0, 0);
                MyRigid.AddForce(new Vector2(0, JumpStrength));
                CanHoldForMore = true;
                CurHoldJump    = 0;
            }
        }
        if (Input.GetButton("Jump") && CanHoldForMore)
        {
            CurHoldJump += Time.deltaTime;
            if (CurHoldJump > HoldJumpCD)
            {
                CanHoldForMore = false;
                CurHoldJump    = 0;
                return;
            }

            if (MyRigid.velocity.y > 0)
            {
                MyRigid.AddRelativeForce(new Vector2(0, JumpStrength * JumpHoldMultiplier * Time.deltaTime));
                MyRigid.gravityScale += Time.deltaTime;
            }
        }

        // Shooting Projectiles
        if (Input.GetButtonDown("Fire1"))
        {
            if (IsGrounded && MyRigid.velocity.y >= 0)
            {
                if (IceBall)
                {
                    if (IceBall.activeInHierarchy)
                    {
                        StopAllMovement = false;
                        return;
                    }
                }

                IceBall = Instantiate(IceBallProjectile, ShootingOrigin.position, Quaternion.identity);
                IceBall.GetComponent <Rigidbody2D>().velocity = new Vector2(ProjectileSpeed * (IsFacingRight ? 1 : -1), 0);
                IceBall.GetComponent <IceBallScript>().Floor  = Floor;
            }
        }


        // Flipping
        if (ShouldFlip())
        {
            Flip();
        }
    }