public int waitSeconds = 3 * 60; // Interval for free gift: 3 minutes. void OnGUI() { if (textStyle == null) { SetUpStyles(); } GUILayout.BeginHorizontal(GUI.skin.label, GUILayout.Width(Screen.width)); GUILayout.Label("FreeGift:", textStyle); // Main routine: Control Free Gift. if (FreeGiftTimer.IsValid()) { if (FreeGiftTimer.CanSend()) { // Can get a free gift. if (GUILayout.Button("Get", buttonStyle)) { FreeGiftTimer.SetNextWait(waitSeconds); } } else { // Cannot get a free gift because the time has not yet come. GUILayout.Label("Next: " + FreeGiftTimer.GetRemainingTime() + " sec later", textStyle); } } else { // Cannot get a free gift because the clock is invalid. GUILayout.Label("Unavailable", textStyle); } GUILayout.EndHorizontal(); }
private TimerState GetTimerState() { if (FreeGiftTimer.IsValid()) { if (FreeGiftTimer.CanSend()) { return(TimerState.CAN_SEND); } else { return(TimerState.WAITING); } } else { return(TimerState.INVALID); } }