private void Start() { moveCamera = GetComponent <moveSmoothly>(); }
public void edgeReached(CustomEnums.directions direction) { GameObject nextRoom = room.getNextRoom(direction); if (nextRoom != null && !changingRoom) { //PREPARATION FOR THE ANIMATION float xOffset = 0; float yOffset = 0; float animationMovementX = 0; float animationMovementY = 0; if (direction == CustomEnums.directions.right) { xOffset = 36.25f; animationMovementX = -player.transform.localPosition.x * 2 + 0.25f; } else if (direction == CustomEnums.directions.left) { xOffset = -36.25f; animationMovementX = -player.transform.localPosition.x * 2 - 0.25f; } else if (direction == CustomEnums.directions.up) { yOffset = 20.25f; animationMovementY = -player.transform.localPosition.y * 2 + 1f; } else { yOffset = -20.25f; animationMovementY = -player.transform.localPosition.y * 2 - 2f; } //CREO HABITACION changingRoom = true; GameObject nextRoomInstance = Instantiate(nextRoom); nextRoomInstance.transform.position = new Vector3(transform.position.x + xOffset, transform.position.y + yOffset, transform.position.z); //ACTUALIZO LOS NOTIFIERS updateNotifiableState(false); //desactivo los notifiers antiguos getNotifiables(); OrderNotifiables(); initializeNotifiers(currentColor == SceneColor.red); //ANIMACION DEL JUGADOR player.modifyCollisions(false); moveSmoothly moveSmoothlyPlayer = player.GetComponent <moveSmoothly>(); moveSmoothlyPlayer.moveObjectiveX = animationMovementX; moveSmoothlyPlayer.moveObjectiveY = animationMovementY; moveSmoothlyPlayer.animationSeconds = 1; moveSmoothlyPlayer.UpdatePath(); moveSmoothlyPlayer.move(); //ANIMACION CAMARA cameraController.move(xOffset, yOffset, 1); StartCoroutine(givePlayerControl(roomGO)); roomGO = nextRoomInstance; room = roomGO.GetComponent <roomController>(); } }