if (m_iCompletedCircle == 0 & angle < 0) {
tempFirstCicle=true;
var rot = Quaternion.AngleAxis(0, Lever.right);
Lever.transform.localRotation = rot * Lever.transform.localRotation;
Debug.Log("Заблокировано");
} else if (m_fDelta != 0) {
var rot = Quaternion.AngleAxis(angle, Lever.right);
Lever.transform.localRotation = rot * Lever.transform.localRotation;
if (tempFirstCicle) {
m_iCompletedCircle= m_iCompletedCircle+1;
tempFirstCicle=false;
}
}
if (m_iCompletedCircle >= 1 & angle > 0) {
var currentLeverPosittion = Lever.transform.localRotation;
if (currentLeverPosittion ==saveBeginLeverRotation) {
m_iCompletedCircle= m_iCompletedCircle+1;
Debug.Log("Пройдено кругов: "+m_iCompletedCircle);
}
else if (m_iCompletedCircle >= 1 & angle < 0) {
if (currentLeverPosittion == saveBeginLeverRotation) {
m_iCompletedCircle= m_iCompletedCircle-1;
Debug.Log("Пройдено кругов: "+m_iCompletedCircle);
}
}
public class Lever : MonoBehaviour
{
private float _rotation = 0f;
private int LapsCount => (int)(_rotation / 360);
private void Rotate(float angle)
{
_rotation += angle;
transform.rotation = Quaternion.Euler(new Vector3(0, 0, _rotation));
}
private void Update()
{
if (Input.GetKey(KeyCode.A))
{
Rotate(100f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D))
{
Rotate(-100f * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log(LapsCount);
}
}
}