| | | 1 | | using UnityEngine; |
| | | 2 | | using System.Collections; |
| | | 3 | | |
| | | 4 | | //[ExecuteInEditMode] |
| | | 5 | | public class DigitalClockValue : MonoBehaviour { |
| | | 6 | | public int currentValue; |
| | | 7 | | private int lastValue; |
| | | 8 | | public int maximumValue; |
| | | 9 | | public DigitalClockValue NextValue; |
| | | 10 | | public DisplaySelectedObject tens; |
| | | 11 | | public DisplaySelectedObject units; |
| | 6 | 12 | | public int tensValue=10; |
| | 6 | 13 | | public bool reverse=false; |
| | | 14 | | |
| | 2 | 15 | | public void ChangeToTargetTime(int value){ |
| | 2 | 16 | | if (!reverse) |
| | 2 | 17 | | currentValue = value-1; |
| | | 18 | | else |
| | 0 | 19 | | currentValue = value+1; |
| | 2 | 20 | | if (value > maximumValue) |
| | 0 | 21 | | value = maximumValue - 1; |
| | 2 | 22 | | if (value < 0) |
| | 0 | 23 | | value = 0; |
| | 2 | 24 | | ChangeTimeValue (); |
| | 2 | 25 | | } |
| | | 26 | | |
| | 225 | 27 | | public void ChangeTimeValue(){ |
| | 225 | 28 | | if (!reverse) |
| | 225 | 29 | | currentValue += 1; |
| | | 30 | | else |
| | 0 | 31 | | currentValue -= 1; |
| | 284 | 32 | | if (currentValue > maximumValue - 1) { |
| | 59 | 33 | | currentValue = 0; |
| | 59 | 34 | | if (NextValue != null) |
| | 1 | 35 | | NextValue.ChangeTimeValue (); |
| | 59 | 36 | | } |
| | 225 | 37 | | if (currentValue < 0) { |
| | 0 | 38 | | currentValue = maximumValue - 1; |
| | 0 | 39 | | if (NextValue != null) |
| | 0 | 40 | | NextValue.ChangeTimeValue (); |
| | 0 | 41 | | } |
| | | 42 | | |
| | 337 | 43 | | if (tens!=null)tens.TurnSelectedWithButton (currentValue/tensValue); |
| | 225 | 44 | | units.TurnSelectedWithButton (currentValue % tensValue); |
| | 225 | 45 | | } |
| | | 46 | | } |