public void SetDoorPos(DoorOpening o) { switch (OpeningMode) { case DoorOpening.Top: transform.localPosition = TopPosition; break; case DoorOpening.Down: transform.localPosition = DownPostion; break; case DoorOpening.XLeft: transform.localPosition = XLeftPosition; break; case DoorOpening.XRight: transform.localPosition = XRightPosition; break; case DoorOpening.ZLeft: transform.localPosition = ZLeftPosition; break; case DoorOpening.ZRight: transform.localPosition = ZRightPosition; break; } }
private void OnCollisionStay2D(Collision2D collision) { if (collision.collider.tag == "Door") { door = collision.gameObject; doorScript = door.GetComponent <DoorOpening>(); } }
public void CreateDoor(TimelineObject time, bool isOp, DoorOpening opening, Material mat, float vel, bool needAll) { ItemType = time; IsOpen = isOp; OpeningMode = opening; material = mat; doorOpeningVelocity = vel; needAllButtons = needAll; }
//UPDATE FUNCTION void Update() { // Set origin of ray to 'center of screen' and direction of ray to 'cameraview'. Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0F)); RaycastHit hit; // Variable reading information about the collider hit. // Cast a ray from the center of screen towards where the player is looking. if (Physics.Raycast(ray, out hit, Reach) && hit.collider.tag == "Door") { InReach = true; if (Input.GetKey(KeyCode.E)) { // Give the object that was hit the name 'Door'. GameObject Door = hit.transform.gameObject; // Get access to the 'DoorOpening' script attached to the door that was hit. DoorOpening dooropening = Door.GetComponent <DoorOpening>(); // Check whether the door is opening/closing or not. if (dooropening.Running == false) { // Open/close the door by running the 'Open' function in the 'DoorOpening' script. StartCoroutine(hit.collider.GetComponent <DoorOpening>().Open()); } } } else { InReach = false; } //DEBUGGING //if (InReach == true) print ("The player is able to open the door (Inreach = " + InReach + ")."); //else print ("The player is not able to open the door (Inreach = " + InReach + ")."); // Draw the ray as a colored line for debugging purposes. Debug.DrawRay(ray.origin, ray.direction * Reach, DebugRayColor); }
// Start is called before the first frame update void Start() { activated_sprite = transform.GetChild(0).GetComponent <SpriteRenderer>(); if (!element_linked) { return; } if (element_linked.GetComponent <DoorOpening>() != null) { door = element_linked.GetComponent <DoorOpening>(); } else if (element_linked.GetComponent <Portal_Manager>() != null) { portal = element_linked.GetComponent <Portal_Manager>(); } if (door != null) { if (is_pressed) { activated_sprite.enabled = true; if (door.IsDoorClosed()) { door.OpenDoors(is_pressed); } } else { activated_sprite.enabled = false; if (!door.IsDoorClosed()) { door.OpenDoors(is_pressed); } } } }
private void Start() { door = GameObject.Find("Door").GetComponent <DoorOpening>(); }