From 6a25bcb480c877fb92b708c62b60ee6a2b8e3657 Mon Sep 17 00:00:00 2001 From: Aniol0012 Date: Wed, 11 Sep 2024 12:46:05 +0200 Subject: [PATCH] style: lint --- Assets/Scripts/Gameplay/PlayerJumped.cs | 9 ++--- Assets/Scripts/Gameplay/PlayerLanded.cs | 9 ++--- Assets/Scripts/Gameplay/PlayerStopJump.cs | 9 ++--- .../Scripts/Gameplay/PlayerTokenCollision.cs | 9 ++--- Assets/Scripts/Model/PlatformerModel.cs | 6 ++-- Assets/Scripts/UI/MainUIController.cs | 15 +++------ Assets/Scripts/UI/MetaGameController.cs | 30 ++++++----------- Assets/Scripts/View/AnimatedTile.cs | 33 +++++++------------ Assets/Scripts/View/ParallaxLayer.cs | 12 +++---- 9 files changed, 44 insertions(+), 88 deletions(-) diff --git a/Assets/Scripts/Gameplay/PlayerJumped.cs b/Assets/Scripts/Gameplay/PlayerJumped.cs index 208a892..8ad7361 100644 --- a/Assets/Scripts/Gameplay/PlayerJumped.cs +++ b/Assets/Scripts/Gameplay/PlayerJumped.cs @@ -1,18 +1,15 @@ using Platformer.Core; using Platformer.Mechanics; -namespace Platformer.Gameplay -{ +namespace Platformer.Gameplay { /// /// Fired when the player performs a Jump. /// /// - public class PlayerJumped : Simulation.Event - { + public class PlayerJumped : Simulation.Event { public PlayerController player; - public override void Execute() - { + public override void Execute() { if (player.audioSource && player.jumpAudio) player.audioSource.PlayOneShot(player.jumpAudio); } diff --git a/Assets/Scripts/Gameplay/PlayerLanded.cs b/Assets/Scripts/Gameplay/PlayerLanded.cs index 7823c8c..eafdaab 100644 --- a/Assets/Scripts/Gameplay/PlayerLanded.cs +++ b/Assets/Scripts/Gameplay/PlayerLanded.cs @@ -1,18 +1,15 @@ using Platformer.Core; using Platformer.Mechanics; -namespace Platformer.Gameplay -{ +namespace Platformer.Gameplay { /// /// Fired when the player character lands after being airborne. /// /// - public class PlayerLanded : Simulation.Event - { + public class PlayerLanded : Simulation.Event { public PlayerController player; - public override void Execute() - { + public override void Execute() { } } } \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/PlayerStopJump.cs b/Assets/Scripts/Gameplay/PlayerStopJump.cs index 927dddb..c2cde89 100644 --- a/Assets/Scripts/Gameplay/PlayerStopJump.cs +++ b/Assets/Scripts/Gameplay/PlayerStopJump.cs @@ -1,18 +1,15 @@ using Platformer.Core; using Platformer.Mechanics; -namespace Platformer.Gameplay -{ +namespace Platformer.Gameplay { /// /// Fired when the Jump Input is deactivated by the user, cancelling the upward velocity of the jump. /// /// - public class PlayerStopJump : Simulation.Event - { + public class PlayerStopJump : Simulation.Event { public PlayerController player; - public override void Execute() - { + public override void Execute() { } } } \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/PlayerTokenCollision.cs b/Assets/Scripts/Gameplay/PlayerTokenCollision.cs index 81ff54a..428ead6 100644 --- a/Assets/Scripts/Gameplay/PlayerTokenCollision.cs +++ b/Assets/Scripts/Gameplay/PlayerTokenCollision.cs @@ -3,21 +3,18 @@ using Platformer.Model; using UnityEngine; -namespace Platformer.Gameplay -{ +namespace Platformer.Gameplay { /// /// Fired when a player collides with a token. /// /// - public class PlayerTokenCollision : Simulation.Event - { + public class PlayerTokenCollision : Simulation.Event { public PlayerController player; public TokenInstance token; PlatformerModel model = Simulation.GetModel(); - public override void Execute() - { + public override void Execute() { AudioSource.PlayClipAtPoint(token.tokenCollectAudio, token.transform.position); } } diff --git a/Assets/Scripts/Model/PlatformerModel.cs b/Assets/Scripts/Model/PlatformerModel.cs index 040dd45..10aaecc 100644 --- a/Assets/Scripts/Model/PlatformerModel.cs +++ b/Assets/Scripts/Model/PlatformerModel.cs @@ -1,16 +1,14 @@ using Platformer.Mechanics; using UnityEngine; -namespace Platformer.Model -{ +namespace Platformer.Model { /// /// The main model containing needed data to implement a platformer style /// game. This class should only contain data, and methods that operate /// on the data. It is initialised with data in the GameController class. /// [System.Serializable] - public class PlatformerModel - { + public class PlatformerModel { /// /// The virtual camera in the scene. /// diff --git a/Assets/Scripts/UI/MainUIController.cs b/Assets/Scripts/UI/MainUIController.cs index 76e13e8..a77be92 100644 --- a/Assets/Scripts/UI/MainUIController.cs +++ b/Assets/Scripts/UI/MainUIController.cs @@ -2,27 +2,22 @@ using System.Collections.Generic; using UnityEngine; -namespace Platformer.UI -{ +namespace Platformer.UI { /// /// A simple controller for switching between UI panels. /// - public class MainUIController : MonoBehaviour - { + public class MainUIController : MonoBehaviour { public GameObject[] panels; - public void SetActivePanel(int index) - { - for (var i = 0; i < panels.Length; i++) - { + public void SetActivePanel(int index) { + for (var i = 0; i < panels.Length; i++) { var active = i == index; var g = panels[i]; if (g.activeSelf != active) g.SetActive(active); } } - void OnEnable() - { + void OnEnable() { SetActivePanel(0); } } diff --git a/Assets/Scripts/UI/MetaGameController.cs b/Assets/Scripts/UI/MetaGameController.cs index 2e3ff50..c669e1b 100644 --- a/Assets/Scripts/UI/MetaGameController.cs +++ b/Assets/Scripts/UI/MetaGameController.cs @@ -2,14 +2,12 @@ using Platformer.UI; using UnityEngine; -namespace Platformer.UI -{ +namespace Platformer.UI { /// /// The MetaGameController is responsible for switching control between the high level /// contexts of the application, eg the Main Menu and Gameplay systems. /// - public class MetaGameController : MonoBehaviour - { + public class MetaGameController : MonoBehaviour { /// /// The main UI object which used for the menu. /// @@ -27,8 +25,7 @@ public class MetaGameController : MonoBehaviour bool showMainCanvas = false; - void OnEnable() - { + void OnEnable() { _ToggleMainMenu(showMainCanvas); } @@ -36,24 +33,19 @@ void OnEnable() /// Turn the main menu on or off. /// /// - public void ToggleMainMenu(bool show) - { - if (this.showMainCanvas != show) - { + public void ToggleMainMenu(bool show) { + if (this.showMainCanvas != show) { _ToggleMainMenu(show); } } - void _ToggleMainMenu(bool show) - { - if (show) - { + void _ToggleMainMenu(bool show) { + if (show) { Time.timeScale = 0; mainMenu.gameObject.SetActive(true); foreach (var i in gamePlayCanvasii) i.gameObject.SetActive(false); } - else - { + else { Time.timeScale = 1; mainMenu.gameObject.SetActive(false); foreach (var i in gamePlayCanvasii) i.gameObject.SetActive(true); @@ -62,10 +54,8 @@ void _ToggleMainMenu(bool show) this.showMainCanvas = show; } - void Update() - { - if (Input.GetButtonDown("Menu")) - { + void Update() { + if (Input.GetButtonDown("Menu")) { ToggleMainMenu(show: !showMainCanvas); } } diff --git a/Assets/Scripts/View/AnimatedTile.cs b/Assets/Scripts/View/AnimatedTile.cs index e0bd22a..86839c5 100644 --- a/Assets/Scripts/View/AnimatedTile.cs +++ b/Assets/Scripts/View/AnimatedTile.cs @@ -8,34 +8,28 @@ using UnityEngine; using UnityEngine.Tilemaps; -namespace Platformer.View -{ +namespace Platformer.View { [System.Serializable] [CreateAssetMenu(fileName = "New Animated Tile", menuName = "Tiles/Animated Tile")] - public class AnimatedTile : TileBase - { + public class AnimatedTile : TileBase { public Sprite[] m_AnimatedSprites; public float m_MinSpeed = 1f; public float m_MaxSpeed = 1f; public float m_AnimationStartTime; public Tile.ColliderType m_TileColliderType; - public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData) - { + public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData) { tileData.transform = Matrix4x4.identity; tileData.color = Color.white; - if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0) - { + if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0) { tileData.sprite = m_AnimatedSprites[m_AnimatedSprites.Length - 1]; tileData.colliderType = m_TileColliderType; } } public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, - ref TileAnimationData tileAnimationData) - { - if (m_AnimatedSprites.Length > 0) - { + ref TileAnimationData tileAnimationData) { + if (m_AnimatedSprites.Length > 0) { tileAnimationData.animatedSprites = m_AnimatedSprites; tileAnimationData.animationSpeed = Random.Range(m_MinSpeed, m_MaxSpeed); tileAnimationData.animationStartTime = m_AnimationStartTime; @@ -48,23 +42,19 @@ public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, #if UNITY_EDITOR [CustomEditor(typeof(AnimatedTile))] - public class AnimatedTileEditor : Editor - { - private AnimatedTile tile - { + public class AnimatedTileEditor : Editor { + private AnimatedTile tile { get { return (target as AnimatedTile); } } - public override void OnInspectorGUI() - { + public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); int count = EditorGUILayout.DelayedIntField("Number of Animated Sprites", tile.m_AnimatedSprites != null ? tile.m_AnimatedSprites.Length : 0); if (count < 0) count = 0; - if (tile.m_AnimatedSprites == null || tile.m_AnimatedSprites.Length != count) - { + if (tile.m_AnimatedSprites == null || tile.m_AnimatedSprites.Length != count) { System.Array.Resize(ref tile.m_AnimatedSprites, count); } @@ -74,8 +64,7 @@ public override void OnInspectorGUI() EditorGUILayout.LabelField("Place sprites shown based on the order of animation."); EditorGUILayout.Space(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { tile.m_AnimatedSprites[i] = (Sprite)EditorGUILayout.ObjectField("Sprite " + (i + 1), tile.m_AnimatedSprites[i], typeof(Sprite), false, null); } diff --git a/Assets/Scripts/View/ParallaxLayer.cs b/Assets/Scripts/View/ParallaxLayer.cs index 4d9af60..743ca3e 100644 --- a/Assets/Scripts/View/ParallaxLayer.cs +++ b/Assets/Scripts/View/ParallaxLayer.cs @@ -1,13 +1,11 @@ using UnityEngine; -namespace Platformer.View -{ +namespace Platformer.View { /// /// Used to move a transform relative to the main camera position with a scale factor applied. /// This is used to implement parallax scrolling effects on different branches of gameobjects. /// - public class ParallaxLayer : MonoBehaviour - { + public class ParallaxLayer : MonoBehaviour { /// /// Movement of the layer is scaled by this value. /// @@ -15,13 +13,11 @@ public class ParallaxLayer : MonoBehaviour Transform _camera; - void Awake() - { + void Awake() { _camera = Camera.main.transform; } - void LateUpdate() - { + void LateUpdate() { transform.position = Vector3.Scale(_camera.position, movementScale); } }