Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Add snooze function
Browse files Browse the repository at this point in the history
  • Loading branch information
forno committed Dec 10, 2019
1 parent 927f3c7 commit f4baaff
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 21 deletions.
25 changes: 24 additions & 1 deletion Assets/Scripts/AlarmManagerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class AlarmManagerScript : MonoBehaviour
[SerializeField]
private Text AlarmMinutesAlarmWindow;
[SerializeField]
private GameObject SetAlarmWindow;
[SerializeField]
private GameObject SnoozeAlarmWindow;
[SerializeField]
private GameObject AlarmWindowsObject;

[SerializeField]
Expand Down Expand Up @@ -63,13 +67,14 @@ public class AlarmManagerScript : MonoBehaviour

//-----------------------------

const int jsonVerMaster = 1; //設定ファイルバージョン
const int jsonVerMaster = 2; //設定ファイルバージョン
const string jsonPath = "config\\Alarm.json";
AlarmConfig config = null; //読み込まれた設定

[Serializable]
class AlarmConfig
{
public int SnoozeMinute = 5;
public int Hour = 0;
public int Minutes = 0;
public bool Enable = false;
Expand Down Expand Up @@ -226,6 +231,8 @@ public void ApplyAlarmWindowFromConfig() {
//アラーム停止
public void AlarmDisable()
{
SnoozeAlarmWindow.SetActive(false);
SetAlarmWindow.SetActive(true);
AlarmRinging = false; //アラーム鳴動状態:停止
config.Enable = false; //アラーム設定:無効
saveJSON();//時刻と無効を反映
Expand All @@ -247,6 +254,8 @@ public void AlarmDisable()
}
public void AlarmEnable() {
ApplyAlarmSettingToConfig(); //設定画面からアラーム設定に反映
SnoozeAlarmWindow.SetActive(false);
SetAlarmWindow.SetActive(true);
AlarmRinging = false; //アラーム鳴動状態:停止
config.Enable = true; //アラーム設定:有効
saveJSON(); //時刻と有効を反映
Expand All @@ -258,10 +267,24 @@ public void AlarmEnable() {
AlarmWindowImage.color = AlarmWindowImageColor; //色をもとに戻す
}

public void AlarmSnooze()
{
AlarmDisable();
// var AlarmDateTime = new DateTime(1, 1, 2, config.Hour, config.Minutes, 0).AddMinutes(config.SnoozeMinute); // value from user alarm
var AlarmDateTime = DateTime.Now.AddMinutes(config.SnoozeMinute); // value from on time
HourHigh = AlarmDateTime.Hour / 10;
HourLow = AlarmDateTime.Hour % 10;
MinutesHigh = AlarmDateTime.Minute / 10;
MinutesLow = AlarmDateTime.Minute % 10;
AlarmEnable();
}

public void OnTime() {
AlarmAudioSrc.PlayDelayed(1f);
AudioMan.ApplyVolume();
menu.ShowDialogOK(LanguageManager.config.showdialog.ONTIME, LanguageManager.config.showdialog.ALARMSTOP, 0f, () => { });
SetAlarmWindow.SetActive(false);
SnoozeAlarmWindow.SetActive(true);
AlarmRinging = true; //アラーム鳴動状態:鳴動
}

Expand Down
7 changes: 0 additions & 7 deletions Assets/Scripts/EasyOpenVRUtil.csv0.041.meta

This file was deleted.

4 changes: 4 additions & 0 deletions Assets/Scripts/GlobalOnClickManagerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,10 @@ public void GlobalOnClick(string objectid) {
AudioMan.PlayApplySound();
AlarmMan.AlarmEnable();
break;
case "MiscClockAlarm/AlarmSnoozeButton":
AudioMan.PlayApplySound();
AlarmMan.AlarmSnooze();
break;
case "MiscClockAlarm/AlarmReleaseButton":
AudioMan.PlayApplySound();
AlarmMan.AlarmDisable();
Expand Down
Loading

0 comments on commit f4baaff

Please sign in to comment.