Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4b72d1b

Browse files
separating tests into individual classes
1 parent ec6044c commit 4b72d1b

File tree

4 files changed

+82
-67
lines changed

4 files changed

+82
-67
lines changed

‎Data/DataController.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,6 @@ public int Score {
3737
}
3838
#endregion
3939

40-
#region Unity Functions
41-
#if UNITY_EDITOR
42-
private void Update() {
43-
if (Input.GetKeyUp(KeyCode.R)) {
44-
TestAddScore(1);
45-
Log("[Test] Score = "+this.Score+" | Highscore = "+this.Highscore);
46-
}
47-
48-
if (Input.GetKeyUp(KeyCode.T)) {
49-
TestAddScore(-1);
50-
Log("[Test] Score = "+this.Score+" | Highscore = "+this.Highscore);
51-
}
52-
53-
if (Input.GetKeyUp(KeyCode.Space)) {
54-
TestResetHighscore();
55-
TestResetScore();
56-
Log("[Test] Score = "+this.Score+" | Highscore = "+this.Highscore);
57-
}
58-
}
59-
#endif
60-
#endregion
61-
6240
#region Private Functions
6341
private void SaveInt(string _data, int _value) {
6442
PlayerPrefs.SetInt(_data, _value);
@@ -67,30 +45,6 @@ private void SaveInt(string _data, int _value) {
6745
private int GetInt(string _data) {
6846
return PlayerPrefs.GetInt(_data, DEFAULT_INT);
6947
}
70-
71-
private void Log(string _msg) {
72-
if (!debug) return;
73-
Debug.Log("[DataController]: "+_msg);
74-
}
75-
76-
private void LogWarning(string _msg) {
77-
if (!debug) return;
78-
Debug.LogWarning("[DataController]: "+_msg);
79-
}
80-
#endregion
81-
82-
#region Tests
83-
private void TestAddScore(int _delta) {
84-
this.Score += _delta;
85-
}
86-
87-
private void TestResetScore() {
88-
this.Score = 0;
89-
}
90-
91-
private void TestResetHighscore() {
92-
this.Highscore = 0;
93-
}
9448
#endregion
9549
}
9650
}

‎Data/TestData.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace UnityCore {
6+
7+
namespace Data {
8+
9+
public class TestData : MonoBehaviour
10+
{
11+
public DataController data;
12+
13+
#region Unity Functions
14+
#if UNITY_EDITOR
15+
private void Update() {
16+
if (Input.GetKeyUp(KeyCode.R)) {
17+
TestAddScore(1);
18+
Debug.Log("[Test] Score = "+data.Score+" | Highscore = "+data.Highscore);
19+
}
20+
21+
if (Input.GetKeyUp(KeyCode.T)) {
22+
TestAddScore(-1);
23+
Debug.Log("[Test] Score = "+data.Score+" | Highscore = "+data.Highscore);
24+
}
25+
26+
if (Input.GetKeyUp(KeyCode.Space)) {
27+
TestResetScore();
28+
Debug.Log("[Test] Score = "+data.Score+" | Highscore = "+data.Highscore);
29+
}
30+
}
31+
#endif
32+
#endregion
33+
34+
private void TestAddScore(int _delta) {
35+
data.Score += _delta;
36+
}
37+
38+
private void TestResetScore() {
39+
data.Score = 0;
40+
}
41+
}
42+
}
43+
}

‎Menu/PageController.cs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,12 @@ private void Awake() {
3232
}
3333
}
3434
}
35-
36-
#if UNITY_EDITOR
37-
private void Update() {
38-
if (Input.GetKeyUp(KeyCode.F)) {
39-
TurnPageOn(PageType.Loading);
40-
}
41-
if (Input.GetKeyUp(KeyCode.G)) {
42-
TurnPageOff(PageType.Loading);
43-
}
44-
if (Input.GetKeyUp(KeyCode.H)) {
45-
TurnPageOff(PageType.Loading, PageType.Menu);
46-
}
47-
if (Input.GetKeyUp(KeyCode.J)) {
48-
TurnPageOff(PageType.Loading, PageType.Menu, true);
49-
}
50-
}
51-
#endif
5235
#endregion
5336

5437
#region Public Functions
38+
/// <summary>
39+
/// Turn on page with type '_type'
40+
/// </summary>
5541
public void TurnPageOn(PageType _type) {
5642
if (_type == PageType.None) return;
5743
if (!PageExists(_type)) {
@@ -64,6 +50,11 @@ public void TurnPageOn(PageType _type) {
6450
_page.Animate(true);
6551
}
6652

53+
/// <summary>
54+
/// Turn off page with type '_off'
55+
/// Optionally turn page with type '_on' on
56+
/// Optionally wait for page to exit before turning on optional page
57+
/// </summary>
6758
public void TurnPageOff(PageType _off, PageType _on=PageType.None, bool _waitForExit=false) {
6859
if (_off == PageType.None) return;
6960
if (!PageExists(_off)) {
@@ -133,10 +124,6 @@ private void LogWarning(string _msg) {
133124
if (!debug) return;
134125
Debug.LogWarning("[Page Controller]: "+_msg);
135126
}
136-
#endregion
137-
138-
#region Tests
139-
140127
#endregion
141128
}
142129
}

‎Menu/TestMenu.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace UnityCore {
6+
7+
namespace Menu {
8+
9+
public class TestMenu : MonoBehaviour
10+
{
11+
public PageController pageController;
12+
13+
#if UNITY_EDITOR
14+
private void Update() {
15+
if (Input.GetKeyUp(KeyCode.F)) {
16+
pageController.TurnPageOn(PageType.Loading);
17+
}
18+
if (Input.GetKeyUp(KeyCode.G)) {
19+
pageController.TurnPageOff(PageType.Loading);
20+
}
21+
if (Input.GetKeyUp(KeyCode.H)) {
22+
pageController.TurnPageOff(PageType.Loading, PageType.Menu);
23+
}
24+
if (Input.GetKeyUp(KeyCode.J)) {
25+
pageController.TurnPageOff(PageType.Loading, PageType.Menu, true);
26+
}
27+
}
28+
#endif
29+
}
30+
}
31+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /