public void relink(PortalDoor[] doors) { linkedDoor = null; // If this door isn't receiving any power now, there's no need to hook it up if (color == Vector3.zero) return; // Go through every door. If this door finds another with its same color, it links to it, // but if it finds another one of the same color later, it unhooks itself again. foreach (PortalDoor p in doors) { if (p != this && p.color == color) { if (linkedDoor == null) linkedDoor = p; else { linkedDoor = null; return; } } } // If this door is now linked, give the surface its new data if (linkedDoor != null) { surface.setSurfaceType(GetInstanceID() < linkedDoor.GetInstanceID()); surface.setLinkedSurface(linkedDoor.surface); } }
public void Close() { open = false; active = false; animator.SetTrigger("Close"); if (destination != null) { destination.destination = null; renderer.gameObject.SetActive(false); camera.gameObject.SetActive(false); destination.open = false; destination.animator.SetTrigger("Close"); destination.renderer.gameObject.SetActive(false); destination.camera.gameObject.SetActive(false); } destination = null; }
public void Open() { open = true; animator.SetBool("Clockwise", false); animator.SetTrigger("Open"); if (linkedDoor != null) { destination = linkedDoor; destination.destination = this; active = true; renderer.gameObject.SetActive(true); renderer.material = linkedDoor.material; camera.gameObject.SetActive(true); destination.open = true; destination.animator.SetBool("Clockwise", false); destination.animator.SetTrigger("Open"); destination.renderer.gameObject.SetActive(true); destination.renderer.material = material; destination.camera.gameObject.SetActive(true); } }
private void Start() { portal = GetComponentInParent <PortalDoor>(); }