void Raycast() { if (pointer != null) { RaycastHit hit; Physics.Raycast(pointer.pointer.transform.position, pointer.pointer.transform.forward, out hit); if (hit.collider != null) { if (hit.collider.tag == "TeleportZone") { TeleportObject teleport = hit.collider.GetComponentInChildren <TeleportObject>(); if (buttons.triggerPressed) { try { if (GameObject.Find("IntroWave").activeSelf || GameObject.Find("IntroWave") != null) { GameObject.Find("IntroWave").GetComponent <introWave>().ExternalInput("Teleported"); } } catch (Exception e) { Debug.Log(e); } StartCoroutine(Teleport(hit, teleport)); } } } } }
private void Awake() { CurrentTeleportPos = StartingPosition.transform.parent.gameObject; TeleportObject teleport = CurrentTeleportPos.GetComponentInChildren <TeleportObject>(); teleport.Teleport(cameraRig.transform, null); }
private void TeleportBind(TeleportObject tpObj, GameObject obj_to_move, Transform start_pos, Transform end_pos) { tpObj.ThingToMove.exposedName = UnityEditor.GUID.Generate().ToString(); tpObj.StartTransform.exposedName = UnityEditor.GUID.Generate().ToString(); tpObj.EndTransform.exposedName = UnityEditor.GUID.Generate().ToString(); director.SetReferenceValue(tpObj.ThingToMove.exposedName, obj_to_move); director.SetReferenceValue(tpObj.StartTransform.exposedName, start_pos); director.SetReferenceValue(tpObj.EndTransform.exposedName, end_pos); }
IEnumerator Teleport(RaycastHit hit, TeleportObject teleport) { GameObject prev = CurrentTeleportPos; CurrentTeleportPos = hit.collider.gameObject; animationCanvas.GetComponentInChildren <Animator>().SetBool("Teleport", true); yield return(new WaitForSeconds(0.3f)); teleport.Teleport(cameraRig.transform, prev); animationCanvas.GetComponentInChildren <Animator>().SetBool("Teleport", false); }
private void OnTriggerStay(Collider other) { if (enter_door) { //Debug.Log("In door"); if (stayCount > timetoTele) { TeleportObject teleport = other.GetComponent <TeleportObject>(); teleport.passObject(gameObject); } else { stayCount += Time.deltaTime; } } }
void GetDoorExit(GameObject exitRoom, string doorName, TeleportObject me) { if (exitRoom != null) { Transform[] PossibleExits = exitRoom.GetComponentsInChildren <Transform>(); foreach (Transform exit in PossibleExits) { if (exit.name == doorName) { me.setExit(exit.gameObject); } } } else { me.setExit(null); } }
void OnTriggerEnter2D(Collider2D other) { TeleportObject otherTeleport = other.GetComponent <TeleportObject>(); if (otherTeleport != null) { if (otherTeleport.CanTeleport) { if (Behaviour == PortalBehaviour.Random) { ToPortal = PortalManager.instance.GetRandomPortal; while (ToPortal == this) { ToPortal = PortalManager.instance.GetRandomPortal; } } otherTeleport.SpawnEffect(ToPortal.transform.position); otherTeleport.CanTeleport = false; } } }
//Assign each tile its neighboors void AssignNeighbors() { // x axis for (int x = 0; x < columns; x++) { // y axis, rows for (int y = 0; y < rows; y++) { GameObject current_tile = floorTiles[x][y]; if (current_tile != null) { //Debug.Log("The name of this tile is:" + current_tile.name); Transform[] current_door_transforms = current_tile.GetComponentsInChildren <Transform>(); foreach (Transform child in current_door_transforms) { if (child.name.Contains("Door")) { //Debug.Log("We got this door:" + child.name + " That belongs to: " + current_tile.name); GameObject nieghboor; TeleportObject telport_script = child.GetComponent <TeleportObject>(); //Switch on the first char of the door, ex N door switch (child.name[0]) { case 'N': //Assign the room that the north door would teleport to //check if in range of grid if (y + 1 < rows) { nieghboor = floorTiles[x][y + 1]; GetDoorExit(nieghboor, "S Door", telport_script); telport_script.assignDir(TeleportObject.Direction.NORTH); //telport_script.AssignRoom(nieghboor); //Debug.Log("Assigned a room to a door"); } else { telport_script.setExit(null); } break; case 'E': //Assign the room that the north door would teleport to //check if in range of grid if (x + 1 < rows) { nieghboor = floorTiles[x + 1][y]; GetDoorExit(nieghboor, "W Door", telport_script); //telport_script.AssignRoom(nieghboor); telport_script.assignDir(TeleportObject.Direction.EAST); Debug.Log("Assigned a room to a door"); } else { telport_script.setExit(null); } break; case 'S': //Assign the room that the north door would teleport to if (y - 1 >= 0) { nieghboor = floorTiles[x][y - 1]; GetDoorExit(nieghboor, "N Door", telport_script); //telport_script.AssignRoom(nieghboor); telport_script.assignDir(TeleportObject.Direction.SOUTH); //Debug.Log("Assigned a room to a door"); } else { telport_script.setExit(null); } break; case 'W': //Assign the room that the north door would teleport to if (x - 1 >= 0) { nieghboor = floorTiles[x - 1][y]; GetDoorExit(nieghboor, "E Door", telport_script); //telport_script.AssignRoom(nieghboor); telport_script.assignDir(TeleportObject.Direction.WEST); //Debug.Log("Assigned a room to a door"); } else { telport_script.setExit(null); } break; default: break; } } } } } } }