public void Rotate(ERotateAxis axis) { if (_IsPlayingAnim) { return; } StartCoroutine(RotateRoutine(axis, (int)(ConstValue._RoomRotateSpeed))); }
IEnumerator RotateRoutine(ERotateAxis axis, int delta) { _IsPlayingAnim = true; // player.Floating(); int value = 0; while (value < 90 && value > -90) { yield return(null); if (axis == ERotateAxis.X) { rotateTarget.transform.RotateAround(transform.position, transform.right, delta); player.transform.RotateAround(transform.position, transform.right, -delta); value += delta; } else if (axis == ERotateAxis.Y) { rotateTarget.transform.RotateAround(transform.position, transform.up, delta); value += delta; } else if (axis == ERotateAxis.Z) { rotateTarget.transform.RotateAround(transform.position, transform.forward, delta); player.transform.RotateAround(transform.position, transform.forward, -delta); value += delta; } else if (axis == ERotateAxis.AX) { rotateTarget.transform.RotateAround(transform.position, transform.right, -delta); player.transform.RotateAround(transform.position, transform.right, delta); value -= delta; } else if (axis == ERotateAxis.AY) { rotateTarget.transform.RotateAround(transform.position, transform.up, -delta); value -= delta; } else if (axis == ERotateAxis.AZ) { rotateTarget.transform.RotateAround(transform.position, transform.forward, -delta); player.transform.RotateAround(transform.position, transform.forward, delta); value -= delta; } } if (value != 90 || value != -90) { if (axis == ERotateAxis.X) { rotateTarget.transform.RotateAround(transform.position, transform.right, 90 - value); player.transform.RotateAround(transform.position, transform.right, 90 - value); } else if (axis == ERotateAxis.Y) { rotateTarget.transform.RotateAround(transform.position, transform.up, 90 - value); } else if (axis == ERotateAxis.Z) { rotateTarget.transform.RotateAround(transform.position, transform.forward, 90 - value); player.transform.RotateAround(transform.position, transform.forward, 90 - value); } else if (axis == ERotateAxis.AX) { rotateTarget.transform.RotateAround(transform.position, transform.right, -90 - value); player.transform.RotateAround(transform.position, transform.right, -90 - value); } else if (axis == ERotateAxis.AY) { rotateTarget.transform.RotateAround(transform.position, transform.up, -90 - value); } else if (axis == ERotateAxis.AZ) { rotateTarget.transform.RotateAround(transform.position, transform.forward, -90 - value); player.transform.RotateAround(transform.position, transform.forward, -90 - value); } } HideWall(); // player.UnFloating(); manager.CheckDoorState(roomNo); _IsPlayingAnim = false; }