private void OnTriggerEnter2D(Collider2D other) { if (other.tag != "Player") { return; } var pos = Vector3.zero; var playerPos = transform.position; BigSmallRoom dir = null; switch (doorDirection) { case DoorDirection.Up: if (bigSmallRoom.Up == null) { return; } dir = bigSmallRoom.Up; pos = bigSmallRoom.Up.transform.position; playerPos.y += 3f; break; case DoorDirection.Down: if (bigSmallRoom.Down == null) { return; } dir = bigSmallRoom.Down; pos = bigSmallRoom.Down.transform.position; playerPos.y -= 3f; break; case DoorDirection.Left: if (bigSmallRoom.Left == null) { return; } dir = bigSmallRoom.Left; pos = bigSmallRoom.Left.transform.position; playerPos.x -= 3f; break; case DoorDirection.Right: if (bigSmallRoom.Right == null) { return; } dir = bigSmallRoom.Right; pos = bigSmallRoom.Right.transform.position; playerPos.x += 3f; break; } var cam = Camera.main.GetComponent <CameraUtility>(); cam.MoveCamera(pos, bigSmallRoom, dir); BigSmallRoom.PlayerTransform.position = playerPos; }
private IEnumerator MoveCameraRoutine(Vector3 pos, BigSmallRoom current, BigSmallRoom next) { next.gameObject.SetActive(true); next.OpenDoors(); var currentPos = transform.position; pos.z = currentPos.z; var direction = (pos - currentPos).normalized; var distance = Vector3.Distance(currentPos, pos); while (distance > 0.5f) { yield return(null); transform.Translate(direction * 40f * Time.deltaTime); distance = Vector3.Distance(transform.position, pos); } transform.position = new Vector3(pos.x, pos.y, transform.position.z); current.gameObject.SetActive(false); yield return(null); if (!next.Opened) { next.CloseDoors(); } var handler = CameraStopped; if (handler != null) { handler(this, null); } }
private void ConnectIndividuals(Vector2Int roomGridPos, BigSmallRoom currentRoom, int direction) { if (roomGridPos.x >= 0 && roomGridPos.x < numberOfColumns && roomGridPos.y >= 0 && roomGridPos.y < numberOfRows) { switch (direction) { case 0: currentRoom.Up = roomsGrid[roomGridPos.x, roomGridPos.y]; break; case 1: currentRoom.Down = roomsGrid[roomGridPos.x, roomGridPos.y]; break; case 2: currentRoom.Left = roomsGrid[roomGridPos.x, roomGridPos.y]; break; case 3: currentRoom.Right = roomsGrid[roomGridPos.x, roomGridPos.y]; break; default: break; } } }
public void MoveCamera(Vector3 pos, BigSmallRoom current, BigSmallRoom next) { var handler = CameraMoved; if (handler != null) { handler(this, null); } StartCoroutine(MoveCameraRoutine(pos, current, next)); }
private void Awake() { bigSmallRoom = transform.parent.parent.GetComponent <BigSmallRoom>(); }