public class Cash1
{
private float _value;
public Cash1(float value)
{
_value = value;
}
public override string ToString() => $"${_value}";
}
public class Cash2
{
private float _value;
public Cash2(float startValue)
{
_value = startValue;
}
public void SetValue(float value)
{
_value = value;
}
public override string ToString() => $"${_value}";
}
public class Cash3
{
private float _value = 0;
public void SetValue(float value)
{
_value = value;
}
public float GetValue() => _value;
public override string ToString() => $"${_value}";
}
using UnityEngine;
public class Rotation : MonoBehaviour
{
[SerializeField] private float _minAngle = 0;
[SerializeField] private float _maxAngle = 90f;
[SerializeField] private float _speed = 10f;
private float _angle = 0;
private void FixedUpdate()
{
Rotate();
}
private void Rotate()
{
var nextAngle = _angle + _speed * Time.deltaTime;
_angle = Mathf.Clamp(nextAngle, _minAngle, _maxAngle);
transform.rotation = Quaternion.Euler(0, 0, _angle);
if (_angle == _minAngle || _angle == _maxAngle) SwitchDirection();
}
private void SwitchDirection() => _speed *= -1;
}