Skip to content

Commit

Permalink
feat: クリアする事にクリア回数を増やす
Browse files Browse the repository at this point in the history
  • Loading branch information
IwamotoKakeru committed May 17, 2024
1 parent 0bb3f65 commit 64eacb5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
11 changes: 9 additions & 2 deletions Assets/Plugins/CookieManager.jslib
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scenes/Title.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/ClearTimesText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ void Awake()
{
// cookieにクリア回数がない場合
WebGL.SetClearTimes(0);
throw;
}
#endif
text.text = "クリア回数: " + clearTimes.ToString();
}

void Start()
{
text.text = "クリア回数: " + clearTimes.ToString();
}

}
21 changes: 14 additions & 7 deletions Assets/Scripts/Endroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Text>();

stopWatch = GameObject.Find("StopWatch").GetComponent<StopWatch>().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());
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class Tags
/// <summary>
/// ホバーのために用いる
/// </summary>
[ObsoleteAttribute("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover";
[Obsolete("現在ホバーはEventTrigger経由で使用されるため非推奨")] public const string Hover = "Hover";

/// <summary>
/// キャラクタが歩く地面や壁等に用いる
Expand Down

0 comments on commit 64eacb5

Please sign in to comment.