From 64eacb5744a6f4303d0e2c4be5e912dbc8493d1e Mon Sep 17 00:00:00 2001 From: IwamotoKakeru Date: Fri, 17 May 2024 02:12:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=82=AF=E3=83=AA=E3=82=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E4=BA=8B=E3=81=AB=E3=82=AF=E3=83=AA=E3=82=A2=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=A2=97=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Plugins/CookieManager.jslib | 11 +++++++++-- Assets/Scenes/Title.unity | 4 ++-- Assets/Scripts/ClearTimesText.cs | 3 +-- Assets/Scripts/Endroll.cs | 21 ++++++++++++++------- Assets/Scripts/Utility.cs | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Assets/Plugins/CookieManager.jslib b/Assets/Plugins/CookieManager.jslib index 19d0dc4..9a9e16f 100644 --- a/Assets/Plugins/CookieManager.jslib +++ b/Assets/Plugins/CookieManager.jslib @@ -1,10 +1,17 @@ function SetClearTimes(clearTimes) { - document.cookie = "clear_times=" + score; + document.cookie = "clear_times=" + clearTimes; + console.log("Set clearTimes = %d ", clearTimes); } // TODO: 現在の実装だとclearTimes以外の保存したいデータに対応できないので修正 function GetClearTimes() { - return parseInt(document.cookie.split("=")[1]); + var clearTimes; + try { + clearTimes = parseInt(document.cookie.split("=")[1]); + console.log("clearTimes = %d ", clearTimes); + } catch { + console.log("Unable Get clearTimes", clearTimes); + } } const cookiePlugins = {}; diff --git a/Assets/Scenes/Title.unity b/Assets/Scenes/Title.unity index 7b38095..3f9b7f1 100644 --- a/Assets/Scenes/Title.unity +++ b/Assets/Scenes/Title.unity @@ -194,7 +194,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: "\u30AF\u30EA\u30A2\u56DE\u6570: -1" + m_Text: "\u30AF\u30EA\u30A2\u56DE\u6570: --" --- !u!222 &166402758 CanvasRenderer: m_ObjectHideFlags: 0 @@ -3343,7 +3343,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 'Device: PC' + m_Text: 'Device: --' --- !u!114 &1867554086 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ClearTimesText.cs b/Assets/Scripts/ClearTimesText.cs index 56ca2a8..7203346 100644 --- a/Assets/Scripts/ClearTimesText.cs +++ b/Assets/Scripts/ClearTimesText.cs @@ -24,14 +24,13 @@ void Awake() { // cookieにクリア回数がない場合 WebGL.SetClearTimes(0); - throw; } #endif + text.text = "クリア回数: " + clearTimes.ToString(); } void Start() { - text.text = "クリア回数: " + clearTimes.ToString(); } } diff --git a/Assets/Scripts/Endroll.cs b/Assets/Scripts/Endroll.cs index 8f8f6a4..7919c83 100644 --- a/Assets/Scripts/Endroll.cs +++ b/Assets/Scripts/Endroll.cs @@ -29,26 +29,33 @@ public class Endroll : MonoBehaviour }; private string company = "九州工業大学\nプログラミング研究会"; private string clearTimeText; + private int clearTimes = -1; private Vector3 logoPos = new Vector3(0.0f, 1.6f, 0.0f); - void Start() + void Awake() { tex = GetComponent(); - stopWatch = GameObject.Find("StopWatch").GetComponent().stopWatch; - float totalSec = (float)(stopWatch.Elapsed.TotalMilliseconds / 1000); +#if UNITY_WEBGL && !UNITY_EDITOR + clearTimes = WebGL.GetClearTimes(); +#endif + } + + void Start() + { + float totalSec = (float)(stopWatch.Elapsed.TotalMilliseconds / 1000); clearTimeText = "クリアタイム\n" + stopWatch.Elapsed.ToString(@"mm\:ss\.ff") + "\nCongratulation!!!\n"; clearTimeText += totalSec.ToString() + "秒としてランキングに掲載しました"; -#if UNITY_EDITOR - // 何もしない - // エディター上で実行した際のタイムを登録しないようにするため -#else +#if UNITY_WEBGL && !UNITY_EDITOR // unityroomのランキングへ登録 UnityroomApiClient.Instance.SendScore(1, totalSec, ScoreboardWriteMode.HighScoreDesc); + + WebGL.SetClearTimes(clearTimes+1); #endif + Debug.Log(clearTimes); StartCoroutine(RunEndroll()); } diff --git a/Assets/Scripts/Utility.cs b/Assets/Scripts/Utility.cs index 4736d5f..fcdcd17 100644 --- a/Assets/Scripts/Utility.cs +++ b/Assets/Scripts/Utility.cs @@ -23,7 +23,7 @@ public static class Tags /// /// ホバーのために用いる /// - [ObsoleteAttribute("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover"; + [Obsolete("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover"; /// /// キャラクタが歩く地面や壁等に用いる