Skip to content

Commit cc885ce

Browse files
authored
Merge pull request #149 from AirConsole/marc-automatic-formatting
a: Apply reformat and syntax styling
2 parents 2a32878 + a34f82c commit cc885ce

52 files changed

Lines changed: 326 additions & 213 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "AirConsole.Examples",
3-
"rootNamespace": "NDream.AirConsole.Examples",
4-
"references": [
5-
"AirConsole.Runtime"
6-
],
7-
"includePlatforms": [
8-
"Android",
9-
"Editor",
10-
"WebGL"
11-
],
12-
"excludePlatforms": [],
13-
"allowUnsafeCode": false,
14-
"overrideReferences": true,
15-
"precompiledReferences": [
16-
"Newtonsoft.Json.dll"
17-
],
18-
"autoReferenced": true,
19-
"defineConstraints": [
20-
"UNITY_2022_3_OR_NEWER"
21-
],
22-
"versionDefines": [],
23-
"noEngineReferences": false
2+
"name": "AirConsole.Examples",
3+
"rootNamespace": "NDream.AirConsole.Examples",
4+
"references": [
5+
"AirConsole.Runtime"
6+
],
7+
"includePlatforms": [
8+
"Android",
9+
"Editor",
10+
"WebGL"
11+
],
12+
"excludePlatforms": [],
13+
"allowUnsafeCode": false,
14+
"overrideReferences": true,
15+
"precompiledReferences": [
16+
"Newtonsoft.Json.dll"
17+
],
18+
"autoReferenced": true,
19+
"defineConstraints": [
20+
"UNITY_2022_3_OR_NEWER"
21+
],
22+
"versionDefines": [],
23+
"noEngineReferences": false
2424
}

Assets/AirConsole/examples/basic/ExampleBasicLogic.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ private void Awake() {
3939

4040
private void OnReady(string code) {
4141
AirConsoleLogger.Log(() => "OnReady: " + code);
42+
4243
//Log to on-screen Console
4344
logWindow.text = "ExampleBasic: AirConsole is ready! \n \n";
4445

4546
Time.timeScale = 1.0f;
46-
47+
4748
//Mark Buttons as Interactable as soon as AirConsole is ready
4849
Button[] allButtons = (Button[])FindObjectsOfType(typeof(Button));
4950
foreach (Button button in allButtons) {
@@ -53,7 +54,8 @@ private void OnReady(string code) {
5354

5455
private void OnMessage(int from, JToken data) {
5556
//Log to on-screen Console
56-
logWindow.text = logWindow.text.Insert(0, "Incoming message from device: " + from + ": " + data.ToString() + " \n \n");
57+
logWindow.text = logWindow.text.Insert(0,
58+
"Incoming message from device: " + from + ": " + data.ToString() + " \n \n");
5759

5860
// Rotate the AirConsole Logo to the right
5961
if ((string)data == "left") {
@@ -92,7 +94,8 @@ private void OnDisconnect(int device_id) {
9294

9395
private void OnDeviceStateChange(int device_id, JToken data) {
9496
//Log to on-screen Console
95-
logWindow.text = logWindow.text.Insert(0, "Device State Change on device: " + device_id + ", data: " + data + "\n \n");
97+
logWindow.text = logWindow.text.Insert(0,
98+
"Device State Change on device: " + device_id + ", data: " + data + "\n \n");
9699
}
97100

98101
private void OnCustomDeviceStateChange(int device_id, JToken custom_data) {
@@ -124,6 +127,7 @@ private void OnGameEnd() {
124127
private void OnHighScores(JToken highscores) {
125128
//Log to on-screen Console
126129
logWindow.text = logWindow.text.Insert(0, "On High Scores " + highscores + " \n \n");
130+
127131
//logWindow.text = logWindow.text.Insert (0, "Converted Highscores: " + HighScoreHelper.ConvertHighScoresToTables(highscores).ToString() + " \n \n");
128132
}
129133

@@ -197,7 +201,8 @@ public void DisplayNicknameOfFirstController() {
197201
string nicknameOfFirstController = AirConsole.instance.GetNickname(idOfFirstController);
198202

199203
//Log to on-screen Console
200-
logWindow.text = logWindow.text.Insert(0, "The first controller's nickname is: " + nicknameOfFirstController + "\n \n");
204+
logWindow.text = logWindow.text.Insert(0,
205+
"The first controller's nickname is: " + nicknameOfFirstController + "\n \n");
201206
}
202207

203208
private IEnumerator DisplayUrlPicture(string uri) {
@@ -227,7 +232,8 @@ public void DisplayProfilePictureOfFirstController() {
227232
string urlOfProfilePic = AirConsole.instance.GetProfilePicture(idOfFirstController, 512);
228233

229234
//Log url to on-screen Console
230-
logWindow.text = logWindow.text.Insert(0, "URL of Profile Picture of first Controller: " + urlOfProfilePic + "\n \n");
235+
logWindow.text = logWindow.text.Insert(0,
236+
"URL of Profile Picture of first Controller: " + urlOfProfilePic + "\n \n");
231237
StartCoroutine(DisplayUrlPicture(urlOfProfilePic));
232238
}
233239

@@ -246,7 +252,11 @@ public void DisplayAllCustomDataOfFirstController() {
246252
// go through all properties
247253
foreach (JProperty prop in ((JObject)data).Properties()) {
248254
logWindow.text = logWindow.text.Insert(0,
249-
"Custom Data on first Controller - Key: " + prop.Name + " / Value:" + prop.Value + "\n \n");
255+
"Custom Data on first Controller - Key: "
256+
+ prop.Name
257+
+ " / Value:"
258+
+ prop.Value
259+
+ "\n \n");
250260
}
251261
} else {
252262
//If there's only one property, log it to on-screen Console
@@ -310,7 +320,8 @@ public void DisplayNumberOfConnectedControllers() {
310320
//This does not count devices that have been connected and then left,
311321
//only devices that are still active
312322
int numberOfActiveControllers = AirConsole.instance.GetControllerDeviceIds().Count;
313-
logWindow.text = logWindow.text.Insert(0, "Number of Active Controllers: " + numberOfActiveControllers + "\n \n");
323+
logWindow.text
324+
= logWindow.text.Insert(0, "Number of Active Controllers: " + numberOfActiveControllers + "\n \n");
314325
}
315326

316327
public void SetActivePlayers() {
@@ -333,7 +344,8 @@ public void DisplayDeviceIDOfPlayerOne() {
333344
if (device_id != -1) {
334345
logWindow.text = logWindow.text.Insert(0, "Player #1 has device ID: " + device_id + " \n \n");
335346
} else {
336-
logWindow.text = logWindow.text.Insert(0, "There is no active player # 1 - Set Active Players first!\n \n");
347+
logWindow.text
348+
= logWindow.text.Insert(0, "There is no active player # 1 - Set Active Players first!\n \n");
337349
}
338350
}
339351

@@ -371,6 +383,7 @@ public void NavigateToPong() {
371383
public void ShowAd() {
372384
//Display an Advertisement
373385
AirConsole.instance.ShowAd();
386+
374387
//Log to on-screen Console
375388
logWindow.text = logWindow.text.Insert(0, "Called ShowAd" + "\n \n");
376389
}
@@ -470,4 +483,4 @@ private void OnDestroy() {
470483
}
471484
#endif
472485
}
473-
}
486+
}

Assets/AirConsole/examples/game-states/GameStatesExampleLogic.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ private static class ControllerEvents {
2828
public const string ResumeGame = "resume-game";
2929
}
3030

31-
private readonly string[] colorNames = new string[] { "red", "blue", "green", "yellow", "orange", "purple", "pink" };
31+
private readonly string[] colorNames = new string[]
32+
{ "red", "blue", "green", "yellow", "orange", "purple", "pink" };
33+
3234
private int colorIndex;
3335

3436
// This field should overwrite any game state
@@ -158,6 +160,7 @@ public void AssignPlayerColors() {
158160
// updates get delayed because of rate limiting the more devices are connected, the more this becomes a problem
159161
AirConsole.instance.SetCustomDeviceStateProperty("playerColors",
160162
UpdatePlayerColorData(AirConsole.instance.GetCustomDeviceState(0), i, colorNames[colorIndex]));
163+
161164
// The controller listens for the onCustomDeviceStateChanged event.
162165
// See the controller-game-states.html file for how this is handled there.
163166

@@ -171,6 +174,7 @@ public void AssignPlayerColors() {
171174

172175
private void SetGameState(string state) {
173176
gameStateText.text = state;
177+
174178
// Set a custom device state property to inform all connected devices
175179
// of the current game state
176180
AirConsole.instance.SetCustomDeviceStateProperty("state", state);
@@ -199,10 +203,13 @@ private static JToken UpdatePlayerColorData(JToken oldGameState, int deviceId, s
199203
}
200204

201205
// Logging and returning the updated playerColorData
202-
Debug.Log("AssignPlayerColor for device " + deviceId + " returning new playerColorData: " + playerColorData);
206+
Debug.Log("AssignPlayerColor for device "
207+
+ deviceId
208+
+ " returning new playerColorData: "
209+
+ playerColorData);
203210

204211
return playerColorData;
205212
}
206213
#endif
207214
}
208-
}
215+
}

Assets/AirConsole/examples/platformer/PlatformerExampleLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ private void OnDestroy() {
5757
}
5858
#endif
5959
}
60-
}
60+
}

Assets/AirConsole/examples/platformer/Player_Platformer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ private void OnTriggerExit(Collider trigger) {
6868
}
6969
#endif
7070
}
71-
}
71+
}

Assets/AirConsole/examples/pong/ExamplePongLogic.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private void OnConnect(int device_id) {
4848
private void OnDisconnect(int device_id) {
4949
int player = AirConsole.instance.ConvertDeviceIdToPlayerNumber(device_id);
5050
if (player >= 0)
51+
5152
// Player that was in the game left the game.
5253
// Setting active players to length 0
5354
{
@@ -82,6 +83,7 @@ private void OnMessage(int device_id, JToken data) {
8283

8384
private void OnPause() {
8485
Time.timeScale = 0;
86+
8587
// If we were playing any sounds we must mute them when the game gets paused
8688
AudioListener.pause = true;
8789
}
@@ -96,6 +98,7 @@ private void OnResume() {
9698
/// </summary>
9799
private void OnAdShow() {
98100
Time.timeScale = 0;
101+
99102
// If we were playing any sounds we must mute them when an ad is shown
100103
AudioListener.pause = true;
101104
}
@@ -137,7 +140,8 @@ private void CheckTwoPlayers() {
137140
/// </summary>
138141
/// <param name="player"></param>
139142
private void Vibrate(int player) {
140-
AirConsole.instance.Message(AirConsole.instance.ConvertPlayerNumberToDeviceId(player), new { vibrate = 1000 });
143+
AirConsole.instance.Message(AirConsole.instance.ConvertPlayerNumberToDeviceId(player),
144+
new { vibrate = 1000 });
141145
}
142146

143147
/// <summary>
@@ -224,4 +228,4 @@ private void OnDestroy() {
224228
}
225229
#endif
226230
}
227-
}
231+
}

Assets/AirConsole/examples/pong/Racket.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
namespace NDream.AirConsole.Examples {
44
public class Racket : MonoBehaviour {
5-
65
public ExamplePongLogic logic;
76

87
// Use this for initialization
9-
void Start() { }
10-
11-
void OnCollisionEnter2D(Collision2D col) {
8+
private void Start() { }
129

10+
private void OnCollisionEnter2D(Collision2D col) {
1311
if (col.gameObject.GetComponent<Rigidbody2D>() != null) {
14-
15-
float hitPos = (col.transform.position.y - transform.position.y) / (GetComponent<Collider2D>().bounds.size.y / 2);
12+
float hitPos = (col.transform.position.y - transform.position.y)
13+
/ (GetComponent<Collider2D>().bounds.size.y / 2);
1614
float hitDir = 1f;
1715

1816
if (col.relativeVelocity.x > 0) {
@@ -21,7 +19,6 @@ void OnCollisionEnter2D(Collision2D col) {
2119

2220
Vector2 dir = new Vector2(hitDir, hitPos).normalized;
2321
col.gameObject.GetComponent<Rigidbody2D>().velocity = dir * logic.ballSpeed;
24-
2522
}
2623
}
2724
}

Assets/AirConsole/examples/safe-area/FullscreenSafeAreaHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace NDream.AirConsole.Examples {
88
/// </summary>
99
[RequireComponent(typeof(Camera))]
1010
public class FullscreenSafeAreaHandler : MonoBehaviour {
11-
[Tooltip("Reference to the camera that should be adjusted to the safe area. Will use the attached camera if not assigned.")]
11+
[Tooltip(
12+
"Reference to the camera that should be adjusted to the safe area. Will use the attached camera if not assigned.")]
1213
[SerializeField]
1314
private Camera targetCamera;
1415

@@ -61,4 +62,4 @@ private void OnDisable() {
6162
}
6263
#endif
6364
}
64-
}
65+
}

Assets/AirConsole/examples/safe-area/SplitScreenSafeAreaHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ private void HandleSafeAreaChanged(Rect newSafeArea) {
7575
}
7676

7777
#region Split Screen Configuration Methods
78-
7978
/// <summary>
8079
/// Sets up two player cameras in a horizontal split (side by side)
8180
/// </summary>
@@ -234,7 +233,6 @@ private void SetupFourPlayers(Rect safeArea) {
234233
);
235234
playerCameras[3].pixelRect = bottomRightRect;
236235
}
237-
238236
#endregion
239237

240238
private void OnEnable() {
@@ -251,4 +249,4 @@ private void OnDisable() {
251249
}
252250
#endif
253251
}
254-
}
252+
}

Assets/AirConsole/examples/safe-area/UISafeAreaHandler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ private void AdjustCanvasScaler(Rect safeArea) {
108108

109109
if (Mathf.Approximately(canvasScaler.matchWidthOrHeight, 1)) {
110110
newReferenceResolution.x = originalReferenceResolution.y * safeAreaAspect;
111-
} else if (canvasScaler.matchWidthOrHeight == 0)
112-
{
111+
} else if (canvasScaler.matchWidthOrHeight == 0) {
113112
newReferenceResolution.y = originalReferenceResolution.x / safeAreaAspect;
114113
} else {
115114
float matchValue = canvasScaler.matchWidthOrHeight;
@@ -145,4 +144,4 @@ private void OnDisable() {
145144
}
146145
#endif
147146
}
148-
}
147+
}

0 commit comments

Comments
 (0)