From 0d9d433a6496882b8e10361a6ebf75305a2d59fe Mon Sep 17 00:00:00 2001 From: Natalie Bunduwongse Date: Tue, 28 May 2024 15:22:43 +1200 Subject: [PATCH] style: dotnet format --- .../Scripts/EventSystem/AppPauseDetector.cs | 6 ++-- .../Scripts/StateMachine/AbstractState.cs | 4 +-- .../Core/Scripts/StateMachine/DelayState.cs | 2 +- Assets/Core/Scripts/StateMachine/EventLink.cs | 8 ++--- Assets/Core/Scripts/StateMachine/ILink.cs | 8 ++--- Assets/Core/Scripts/StateMachine/Link.cs | 2 +- .../Scripts/StateMachine/LoadSceneState.cs | 6 ++-- .../Core/Scripts/StateMachine/PauseState.cs | 6 ++-- Assets/Core/Scripts/StateMachine/State.cs | 2 +- .../Core/Scripts/StateMachine/StateMachine.cs | 28 ++++++++-------- .../StateMachine/UnloadLastSceneState.cs | 2 +- Assets/Core/Scripts/UI/UIManager.cs | 4 +-- Assets/Core/Scripts/UI/View.cs | 2 +- Assets/Core/Scripts/Utils/CoroutineUtils.cs | 6 ++-- Assets/Core/Scripts/Utils/SceneController.cs | 12 +++---- Assets/Editor/CustomEditors/SceneRefEditor.cs | 4 +-- Assets/Runner/Scripts/CameraManager.cs | 2 +- Assets/Runner/Scripts/Collectable.cs | 4 +-- .../Scripts/Editor/RunnerLevelEditorWindow.cs | 8 ++--- Assets/Runner/Scripts/FinishLine.cs | 2 +- Assets/Runner/Scripts/GameManager.cs | 4 +-- Assets/Runner/Scripts/Gate.cs | 4 +-- Assets/Runner/Scripts/InputManager.cs | 2 +- Assets/Runner/Scripts/LevelManager.cs | 2 +- Assets/Runner/Scripts/LoadLevelFromDef.cs | 2 +- Assets/Runner/Scripts/Obstacle.cs | 2 +- Assets/Runner/Scripts/Spawnable.cs | 8 ++--- Assets/Runner/Scripts/TerrainGenerator.cs | 6 ++-- Assets/Shared/Scripts/AudioManager.cs | 12 +++---- Assets/Shared/Scripts/BootLoader.cs | 2 +- .../Scripts/GenericGameEventListener.cs | 4 +-- Assets/Shared/Scripts/HyperCasualButton.cs | 6 ++-- Assets/Shared/Scripts/ItemPickedEvent.cs | 2 +- Assets/Shared/Scripts/ItemPickupTrigger.cs | 10 +++--- Assets/Shared/Scripts/SequenceManager.cs | 32 +++++++++---------- Assets/Shared/Scripts/Service/ApiService.cs | 3 +- Assets/Shared/Scripts/UI/Hud.cs | 4 +-- Assets/Shared/Scripts/UI/LevelSelectButton.cs | 2 +- .../Shared/Scripts/UI/LevelSelectionScreen.cs | 8 ++--- Assets/Shared/Scripts/UI/MainMenu.cs | 4 +-- Assets/Shared/Scripts/UI/SettingsMenu.cs | 8 ++--- Assets/Shared/Scripts/UI/SetupWalletScreen.cs | 2 +- 42 files changed, 124 insertions(+), 123 deletions(-) diff --git a/Assets/Core/Scripts/EventSystem/AppPauseDetector.cs b/Assets/Core/Scripts/EventSystem/AppPauseDetector.cs index ef31fc45..87f5388b 100644 --- a/Assets/Core/Scripts/EventSystem/AppPauseDetector.cs +++ b/Assets/Core/Scripts/EventSystem/AppPauseDetector.cs @@ -12,12 +12,12 @@ public class AppPauseDetector : MonoBehaviour { [SerializeField] AbstractGameEvent m_PauseEvent; - + /// /// Returns the current pause state of the application /// public bool IsPaused { get; private set; } - + void OnApplicationFocus(bool hasFocus) { IsPaused = !hasFocus; @@ -29,7 +29,7 @@ void OnApplicationFocus(bool hasFocus) void OnApplicationPause(bool pauseStatus) { IsPaused = pauseStatus; - + if (IsPaused) m_PauseEvent.Raise(); } diff --git a/Assets/Core/Scripts/StateMachine/AbstractState.cs b/Assets/Core/Scripts/StateMachine/AbstractState.cs index e0e8590e..cbf619ee 100644 --- a/Assets/Core/Scripts/StateMachine/AbstractState.cs +++ b/Assets/Core/Scripts/StateMachine/AbstractState.cs @@ -15,7 +15,7 @@ public abstract class AbstractState : IState /// public virtual string Name { get; set; } - readonly List m_Links = new (); + readonly List m_Links = new(); public virtual void Enter() { @@ -74,7 +74,7 @@ public void EnableLinks() link.Enable(); } } - + public void DisableLinks() { foreach (var link in m_Links) diff --git a/Assets/Core/Scripts/StateMachine/DelayState.cs b/Assets/Core/Scripts/StateMachine/DelayState.cs index 10bebeba..ce48989b 100644 --- a/Assets/Core/Scripts/StateMachine/DelayState.cs +++ b/Assets/Core/Scripts/StateMachine/DelayState.cs @@ -12,7 +12,7 @@ public class DelayState : AbstractState public override string Name => nameof(DelayState); readonly float m_DelayInSeconds; - + /// delay in seconds public DelayState(float delayInSeconds) { diff --git a/Assets/Core/Scripts/StateMachine/EventLink.cs b/Assets/Core/Scripts/StateMachine/EventLink.cs index 67b1905a..789e3839 100644 --- a/Assets/Core/Scripts/StateMachine/EventLink.cs +++ b/Assets/Core/Scripts/StateMachine/EventLink.cs @@ -12,7 +12,7 @@ public class EventLink : ILink, IGameEventListener IState m_NextState; AbstractGameEvent m_GameEvent; bool m_EventRaised; - + /// the event this link listens to /// the next state public EventLink(AbstractGameEvent gameEvent, IState nextState) @@ -25,13 +25,13 @@ public bool Validate(out IState nextState) { nextState = null; bool result = false; - + if (m_EventRaised) { nextState = m_NextState; result = true; } - + return result; } @@ -45,7 +45,7 @@ public void Enable() m_GameEvent.AddListener(this); m_EventRaised = false; } - + public void Disable() { m_GameEvent.RemoveListener(this); diff --git a/Assets/Core/Scripts/StateMachine/ILink.cs b/Assets/Core/Scripts/StateMachine/ILink.cs index b9ce8603..5f209751 100644 --- a/Assets/Core/Scripts/StateMachine/ILink.cs +++ b/Assets/Core/Scripts/StateMachine/ILink.cs @@ -16,15 +16,15 @@ public interface ILink /// The next state that this link points to /// true: the link is open for transition bool Validate(out IState nextState); - + /// /// Activates the link /// - void Enable(){} - + void Enable() { } + /// /// Deactivates the link /// - void Disable(){} + void Disable() { } } } \ No newline at end of file diff --git a/Assets/Core/Scripts/StateMachine/Link.cs b/Assets/Core/Scripts/StateMachine/Link.cs index c9dbd9a4..cb2e8319 100644 --- a/Assets/Core/Scripts/StateMachine/Link.cs +++ b/Assets/Core/Scripts/StateMachine/Link.cs @@ -8,7 +8,7 @@ namespace HyperCasual.Core public class Link : ILink { readonly IState m_NextState; - + /// the next state public Link(IState nextState) { diff --git a/Assets/Core/Scripts/StateMachine/LoadSceneState.cs b/Assets/Core/Scripts/StateMachine/LoadSceneState.cs index 5f864b79..37ab977f 100644 --- a/Assets/Core/Scripts/StateMachine/LoadSceneState.cs +++ b/Assets/Core/Scripts/StateMachine/LoadSceneState.cs @@ -13,9 +13,9 @@ public class LoadSceneState : AbstractState readonly string m_Scene; readonly SceneController m_SceneController; readonly Action m_OnLoadCompleted; - + public override string Name => $"{nameof(LoadSceneState)}: {m_Scene}"; - + /// The SceneController for the current loading operation /// The path to the scene /// An action that is invoked when scene loading is finished @@ -25,7 +25,7 @@ public LoadSceneState(SceneController sceneController, string scene, Action onLo m_SceneController = sceneController; m_OnLoadCompleted = onLoadCompleted; } - + public override IEnumerator Execute() { yield return m_SceneController.LoadScene(m_Scene); diff --git a/Assets/Core/Scripts/StateMachine/PauseState.cs b/Assets/Core/Scripts/StateMachine/PauseState.cs index 833fa40a..956a2d93 100644 --- a/Assets/Core/Scripts/StateMachine/PauseState.cs +++ b/Assets/Core/Scripts/StateMachine/PauseState.cs @@ -11,9 +11,9 @@ namespace HyperCasual.Core public class PauseState : AbstractState { readonly Action m_OnPause; - + public override string Name => $"{nameof(PauseState)}"; - + /// The action that is invoked when the game loop paused public PauseState(Action onPause) { @@ -30,7 +30,7 @@ public override IEnumerator Execute() { yield return null; } - + public override void Exit() { Time.timeScale = 1f; diff --git a/Assets/Core/Scripts/StateMachine/State.cs b/Assets/Core/Scripts/StateMachine/State.cs index 04577dc9..6d51c56c 100644 --- a/Assets/Core/Scripts/StateMachine/State.cs +++ b/Assets/Core/Scripts/StateMachine/State.cs @@ -10,7 +10,7 @@ namespace HyperCasual.Core public class State : AbstractState { readonly Action m_OnExecute; - + /// An event that is invoked when the state is executed public State(Action onExecute) { diff --git a/Assets/Core/Scripts/StateMachine/StateMachine.cs b/Assets/Core/Scripts/StateMachine/StateMachine.cs index 619b6671..3aaa7eda 100644 --- a/Assets/Core/Scripts/StateMachine/StateMachine.cs +++ b/Assets/Core/Scripts/StateMachine/StateMachine.cs @@ -11,7 +11,7 @@ namespace HyperCasual.Core public class StateMachine { public IState CurrentState { get; private set; } - + /// /// Finalizes the previous state and then runs the new state /// @@ -22,12 +22,12 @@ public virtual void SetCurrentState(IState state) if (state == null) throw new ArgumentNullException(nameof(state)); - if (CurrentState != null && m_CurrentPlayCoroutine != null) + if (CurrentState != null && m_CurrentPlayCoroutine != null) { //interrupt currently executing state Skip(); } - + CurrentState = state; Coroutines.StartCoroutine(Play()); } @@ -43,14 +43,14 @@ IEnumerator Play() if (!m_PlayLock) { m_PlayLock = true; - + CurrentState.Enter(); //keep a ref to execute coroutine of the current state //to support stopping it later. m_CurrentPlayCoroutine = Coroutines.StartCoroutine(CurrentState.Execute()); yield return m_CurrentPlayCoroutine; - + m_CurrentPlayCoroutine = null; } } @@ -63,7 +63,7 @@ void Skip() { if (CurrentState == null) throw new Exception($"{nameof(CurrentState)} is null!"); - + if (m_CurrentPlayCoroutine != null) { Coroutines.StopCoroutine(ref m_CurrentPlayCoroutine); @@ -73,24 +73,24 @@ void Skip() m_PlayLock = false; } } - + public virtual void Run(IState state) { SetCurrentState(state); Run(); } - + Coroutine m_LoopCoroutine; /// /// Turns on the main loop of the StateMachine. /// This method does not resume previous state if called after Stop() /// and the client needs to set the state manually. /// - public virtual void Run() + public virtual void Run() { if (m_LoopCoroutine != null) //already running return; - + m_LoopCoroutine = Coroutines.StartCoroutine(Loop()); } @@ -101,13 +101,13 @@ public void Stop() { if (m_LoopCoroutine == null) //already stopped return; - - if (CurrentState != null && m_CurrentPlayCoroutine != null) + + if (CurrentState != null && m_CurrentPlayCoroutine != null) { //interrupt currently executing state Skip(); } - + Coroutines.StopCoroutine(ref m_LoopCoroutine); CurrentState = null; } @@ -133,7 +133,7 @@ protected virtual IEnumerator Loop() } CurrentState.DisableLinks(); SetCurrentState(nextState); - CurrentState.EnableLinks(); + CurrentState.EnableLinks(); } } diff --git a/Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs b/Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs index 89525ffc..28f9c800 100644 --- a/Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs +++ b/Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs @@ -16,7 +16,7 @@ public UnloadLastSceneState(SceneController sceneController) { m_SceneController = sceneController; } - + public override IEnumerator Execute() { yield return m_SceneController.UnloadLastScene(); diff --git a/Assets/Core/Scripts/UI/UIManager.cs b/Assets/Core/Scripts/UI/UIManager.cs index 73030523..7e32f025 100644 --- a/Assets/Core/Scripts/UI/UIManager.cs +++ b/Assets/Core/Scripts/UI/UIManager.cs @@ -24,13 +24,13 @@ public class UIManager : AbstractSingleton View m_CurrentView; - readonly Stack m_History = new (); + readonly Stack m_History = new(); void Start() { m_Views = m_Root.GetComponentsInChildren(true).ToList(); Init(); - + // m_ViewLayer.ResizeToSafeArea(m_Canvas); } diff --git a/Assets/Core/Scripts/UI/View.cs b/Assets/Core/Scripts/UI/View.cs index fbdb28ca..54f33370 100644 --- a/Assets/Core/Scripts/UI/View.cs +++ b/Assets/Core/Scripts/UI/View.cs @@ -13,7 +13,7 @@ public abstract class View : MonoBehaviour public virtual void Initialize() { } - + /// /// Makes the View visible /// diff --git a/Assets/Core/Scripts/Utils/CoroutineUtils.cs b/Assets/Core/Scripts/Utils/CoroutineUtils.cs index 738ec668..e252c5ff 100644 --- a/Assets/Core/Scripts/Utils/CoroutineUtils.cs +++ b/Assets/Core/Scripts/Utils/CoroutineUtils.cs @@ -11,10 +11,10 @@ namespace HyperCasual.Core /// It instantiates a hidden GameObject and adds an empty MonoBehaviour component /// to it that is used for starting/stopping coroutines. /// - public static class Coroutines + public static class Coroutines { public class CoroutineHelper : MonoBehaviour { } - + static MonoBehaviour s_Instance; static MonoBehaviour Instance @@ -32,7 +32,7 @@ static MonoBehaviour Instance return s_Instance; } } - + /// /// Starts a coroutine /// diff --git a/Assets/Core/Scripts/Utils/SceneController.cs b/Assets/Core/Scripts/Utils/SceneController.cs index d78c42c7..9e4dabb7 100644 --- a/Assets/Core/Scripts/Utils/SceneController.cs +++ b/Assets/Core/Scripts/Utils/SceneController.cs @@ -14,7 +14,7 @@ public class SceneController { Scene m_LastScene; readonly Scene m_NeverUnloadScene; - + /// The scene we instantiate all level-independent managers in it and never unloads. public SceneController(Scene neverUnloadScene) { @@ -36,7 +36,7 @@ public IEnumerator LoadScene(string scene) yield return LoadSceneAdditive(scene); } - + /// /// Creates and Loads a new empty scene of the given name and unloads others. /// @@ -51,12 +51,12 @@ public IEnumerator LoadNewScene(string scene) LoadNewSceneAdditive(scene); } - + IEnumerator UnloadScene(Scene scene) { - if (!m_LastScene.IsValid()) + if (!m_LastScene.IsValid()) yield break; - + var asyncUnload = SceneManager.UnloadSceneAsync(scene); while (!asyncUnload.isDone) { @@ -76,7 +76,7 @@ IEnumerator LoadSceneAdditive(string scenePath) m_LastScene = SceneManager.GetSceneByPath(scenePath); SceneManager.SetActiveScene(m_LastScene); } - + void LoadNewSceneAdditive(string sceneName) { var scene = SceneManager.CreateScene(sceneName); diff --git a/Assets/Editor/CustomEditors/SceneRefEditor.cs b/Assets/Editor/CustomEditors/SceneRefEditor.cs index bb0f3f95..9b3afec8 100644 --- a/Assets/Editor/CustomEditors/SceneRefEditor.cs +++ b/Assets/Editor/CustomEditors/SceneRefEditor.cs @@ -13,14 +13,14 @@ namespace HyperCasual.CustomEditors public class ScenePickerEditor : Editor { const string k_PropertyName = "m_ScenePath"; - + public override void OnInspectorGUI() { var sceneRef = target as SceneRef; if (sceneRef == null) return; - + var oldScene = AssetDatabase.LoadAssetAtPath(sceneRef.m_ScenePath); serializedObject.Update(); diff --git a/Assets/Runner/Scripts/CameraManager.cs b/Assets/Runner/Scripts/CameraManager.cs index 4974bb84..d68cd099 100644 --- a/Assets/Runner/Scripts/CameraManager.cs +++ b/Assets/Runner/Scripts/CameraManager.cs @@ -130,7 +130,7 @@ bool GetCameraLockStatus() Vector3 GetPlayerPosition() { Vector3 playerPosition = Vector3.up; - if (PlayerController.Instance != null) + if (PlayerController.Instance != null) { playerPosition = PlayerController.Instance.GetPlayerTop(); } diff --git a/Assets/Runner/Scripts/Collectable.cs b/Assets/Runner/Scripts/Collectable.cs index 24250c92..287b9236 100644 --- a/Assets/Runner/Scripts/Collectable.cs +++ b/Assets/Runner/Scripts/Collectable.cs @@ -15,7 +15,7 @@ public class Collectable : Spawnable { [SerializeField] SoundID m_Sound = SoundID.None; - + const string k_PlayerTag = "Player"; public ItemPickedEvent m_Event; @@ -31,7 +31,7 @@ public class Collectable : Spawnable public override void ResetSpawnable() { m_Collected = false; - + for (int i = 0; i < m_Renderers.Length; i++) { m_Renderers[i].enabled = true; diff --git a/Assets/Runner/Scripts/Editor/RunnerLevelEditorWindow.cs b/Assets/Runner/Scripts/Editor/RunnerLevelEditorWindow.cs index 47cbb1f2..f893120f 100644 --- a/Assets/Runner/Scripts/Editor/RunnerLevelEditorWindow.cs +++ b/Assets/Runner/Scripts/Editor/RunnerLevelEditorWindow.cs @@ -66,7 +66,7 @@ static void Init() window.LoadAutoSaveSettings(); } - void OnFocus() + void OnFocus() { SceneView.duringSceneGui -= OnSceneGUI; SceneView.duringSceneGui += OnSceneGUI; @@ -183,7 +183,7 @@ void OnSceneGUI(SceneView sceneView) Debug.LogError($"Could not load level with path {levelPath}. Specify a valid level to continue."); m_AttemptedToLoadPreviousLevel = true; } - + return; } @@ -487,7 +487,7 @@ void SaveLevel(LevelDefinition levelDefinition) { Debug.LogWarning("No instance of PlayerController found in the scene. No changes saved!"); } - else + else { Debug.LogWarning("More than two instances of PlayerController found in the scene. No changes saved!"); } @@ -515,7 +515,7 @@ void SaveLevel(LevelDefinition levelDefinition) { Debug.LogWarning("No instance of CameraManager found in the scene. No changes saved!"); } - else + else { Debug.LogWarning("More than two instances of CameraManager found in the scene. No changes saved!"); } diff --git a/Assets/Runner/Scripts/FinishLine.cs b/Assets/Runner/Scripts/FinishLine.cs index d4cc9bd4..91d66939 100644 --- a/Assets/Runner/Scripts/FinishLine.cs +++ b/Assets/Runner/Scripts/FinishLine.cs @@ -13,7 +13,7 @@ namespace HyperCasual.Runner public class FinishLine : Spawnable { const string k_PlayerTag = "Player"; - + void OnTriggerEnter(Collider col) { if (col.CompareTag(k_PlayerTag)) diff --git a/Assets/Runner/Scripts/GameManager.cs b/Assets/Runner/Scripts/GameManager.cs index d982e3ae..afb3da4b 100644 --- a/Assets/Runner/Scripts/GameManager.cs +++ b/Assets/Runner/Scripts/GameManager.cs @@ -155,7 +155,7 @@ public static void LoadLevel(LevelDefinition levelDefinition, ref GameObject lev Vector3 scale = spawnableObject.Scale; GameObject go = null; - + if (Application.isPlaying) { go = GameObject.Instantiate(spawnableObject.SpawnablePrefab, position, Quaternion.Euler(eulerAngles)); @@ -286,7 +286,7 @@ private void SetSkyBox() Material nightSkyBox = Resources.Load("Skybox1", typeof(Material)) as Material; RenderSettings.skybox = nightSkyBox; } - + public void Win() { m_WinEvent.Raise(); diff --git a/Assets/Runner/Scripts/Gate.cs b/Assets/Runner/Scripts/Gate.cs index 3a1466a9..41e032d8 100644 --- a/Assets/Runner/Scripts/Gate.cs +++ b/Assets/Runner/Scripts/Gate.cs @@ -84,11 +84,11 @@ void ActivateGate() { case GateType.ChangeSpeed: PlayerController.Instance.AdjustSpeed(m_Value); - break; + break; case GateType.ChangeSize: PlayerController.Instance.AdjustScale(m_Value); - break; + break; } m_Applied = true; diff --git a/Assets/Runner/Scripts/InputManager.cs b/Assets/Runner/Scripts/InputManager.cs index 2a4684b9..1e959c6d 100644 --- a/Assets/Runner/Scripts/InputManager.cs +++ b/Assets/Runner/Scripts/InputManager.cs @@ -77,7 +77,7 @@ void Update() { m_PreviousInputPosition = m_InputPosition; } - + m_HasInput = true; } else diff --git a/Assets/Runner/Scripts/LevelManager.cs b/Assets/Runner/Scripts/LevelManager.cs index c41e4222..1667d33d 100644 --- a/Assets/Runner/Scripts/LevelManager.cs +++ b/Assets/Runner/Scripts/LevelManager.cs @@ -23,7 +23,7 @@ public class LevelManager : MonoBehaviour public LevelDefinition LevelDefinition { get => m_LevelDefinition; - set + set { m_LevelDefinition = value; diff --git a/Assets/Runner/Scripts/LoadLevelFromDef.cs b/Assets/Runner/Scripts/LoadLevelFromDef.cs index 7677e187..00c3d3e8 100644 --- a/Assets/Runner/Scripts/LoadLevelFromDef.cs +++ b/Assets/Runner/Scripts/LoadLevelFromDef.cs @@ -21,7 +21,7 @@ public LoadLevelFromDef(SceneController sceneController, AbstractLevelData level m_ManagerPrefabs = managerPrefabs; m_SceneController = sceneController; } - + public override IEnumerator Execute() { if (m_LevelDefinition == null) diff --git a/Assets/Runner/Scripts/Obstacle.cs b/Assets/Runner/Scripts/Obstacle.cs index 995ac875..9f192981 100644 --- a/Assets/Runner/Scripts/Obstacle.cs +++ b/Assets/Runner/Scripts/Obstacle.cs @@ -13,7 +13,7 @@ namespace HyperCasual.Runner public class Obstacle : Spawnable { const string k_PlayerTag = "Player"; - + void OnTriggerEnter(Collider col) { if (col.CompareTag(k_PlayerTag)) diff --git a/Assets/Runner/Scripts/Spawnable.cs b/Assets/Runner/Scripts/Spawnable.cs index fe6f7472..6ec073d6 100644 --- a/Assets/Runner/Scripts/Spawnable.cs +++ b/Assets/Runner/Scripts/Spawnable.cs @@ -104,7 +104,7 @@ public virtual void SetBaseColor(Color baseColor) /// public virtual void SetScale(Vector3 scale) { - m_Transform.localScale = scale; + m_Transform.localScale = scale; } /// @@ -128,7 +128,7 @@ public void SetLevelDefinition(LevelDefinition levelDefinition) /// This method can be overriden in classes that extend Spawnable /// to hold any logic needed to reset that object to its default state. /// - public virtual void ResetSpawnable() {} + public virtual void ResetSpawnable() { } protected virtual void OnEnable() { @@ -182,8 +182,8 @@ protected virtual void SnapToGrid() Vector3 position = m_Position; - position.x = m_LevelDefinition.GridSize * Mathf.Round(position.x/m_LevelDefinition.GridSize); - position.z = m_LevelDefinition.GridSize * Mathf.Round(position.z/m_LevelDefinition.GridSize); + position.x = m_LevelDefinition.GridSize * Mathf.Round(position.x / m_LevelDefinition.GridSize); + position.z = m_LevelDefinition.GridSize * Mathf.Round(position.z / m_LevelDefinition.GridSize); m_Transform.position = position; diff --git a/Assets/Runner/Scripts/TerrainGenerator.cs b/Assets/Runner/Scripts/TerrainGenerator.cs index 9d25da75..e5b1b46d 100644 --- a/Assets/Runner/Scripts/TerrainGenerator.cs +++ b/Assets/Runner/Scripts/TerrainGenerator.cs @@ -20,17 +20,17 @@ public struct TerrainDimensions /// Width of the terrain to generate. /// public float Width; - + /// /// Length of the terrain to generate. /// public float Length; - + /// /// Length of terrain to add before the start of the level. /// public float StartBuffer; - + /// /// Length of terrain to add after the end of the level. /// diff --git a/Assets/Shared/Scripts/AudioManager.cs b/Assets/Shared/Scripts/AudioManager.cs index 4f8ce6dc..8f1f24fc 100644 --- a/Assets/Shared/Scripts/AudioManager.cs +++ b/Assets/Shared/Scripts/AudioManager.cs @@ -10,7 +10,7 @@ namespace HyperCasual.Runner /// /// Handles playing sounds and music based on their sound ID /// - public class AudioManager : AbstractSingleton + public class AudioManager : AbstractSingleton { [Serializable] class SoundIDClipPair @@ -45,7 +45,7 @@ public bool EnableMusic m_MusicSource.mute = !value; } } - + /// /// Unmute/mute all sound effects /// @@ -98,7 +98,7 @@ void OnEnable() EnableSfx = audioSettings.EnableSfx; MasterVolume = audioSettings.MasterVolume; } - + void OnDisable() { if (SaveManager.Instance == null) @@ -113,12 +113,12 @@ void PlayMusic(AudioClip audioClip, bool looping = true) { if (m_MusicSource.isPlaying) return; - + m_MusicSource.clip = audioClip; m_MusicSource.loop = looping; m_MusicSource.Play(); } - + /// /// Play a music based on its sound ID /// @@ -154,7 +154,7 @@ public void PlayEffect(SoundID soundID) { if (soundID == SoundID.None) return; - + PlayEffect(m_Clips[soundID]); } } diff --git a/Assets/Shared/Scripts/BootLoader.cs b/Assets/Shared/Scripts/BootLoader.cs index 45ff1768..d6127295 100644 --- a/Assets/Shared/Scripts/BootLoader.cs +++ b/Assets/Shared/Scripts/BootLoader.cs @@ -13,7 +13,7 @@ public class BootLoader : MonoBehaviour { [SerializeField] SequenceManager m_SequenceManagerPrefab; - + void Start() { Instantiate(m_SequenceManagerPrefab); diff --git a/Assets/Shared/Scripts/GenericGameEventListener.cs b/Assets/Shared/Scripts/GenericGameEventListener.cs index de5c4112..e4d6bca4 100644 --- a/Assets/Shared/Scripts/GenericGameEventListener.cs +++ b/Assets/Shared/Scripts/GenericGameEventListener.cs @@ -12,7 +12,7 @@ public class GenericGameEventListener : IGameEventListener /// The event this class is observing /// public AbstractGameEvent m_Event; - + /// /// The event handler invoked once the event is triggered /// @@ -33,7 +33,7 @@ public void Unsubscribe() { m_Event.RemoveListener(this); } - + /// /// The event handler that is called when the subscribed event is triggered /// diff --git a/Assets/Shared/Scripts/HyperCasualButton.cs b/Assets/Shared/Scripts/HyperCasualButton.cs index ed0d4024..846deec1 100644 --- a/Assets/Shared/Scripts/HyperCasualButton.cs +++ b/Assets/Shared/Scripts/HyperCasualButton.cs @@ -30,7 +30,7 @@ protected virtual void OnDisable() { m_Button.onClick.RemoveListener(OnClick); } - + /// /// Adds a listener the button event. /// @@ -39,7 +39,7 @@ public void AddListener(Action handler) { m_Action += handler; } - + /// /// Removes a listener from the button event. /// @@ -53,7 +53,7 @@ public void RemoveListener() { m_Button.onClick.RemoveListener(OnClick); } - + protected virtual void OnClick() { m_Action?.Invoke(); diff --git a/Assets/Shared/Scripts/ItemPickedEvent.cs b/Assets/Shared/Scripts/ItemPickedEvent.cs index 59a68cdd..b9aa7d66 100644 --- a/Assets/Shared/Scripts/ItemPickedEvent.cs +++ b/Assets/Shared/Scripts/ItemPickedEvent.cs @@ -14,7 +14,7 @@ public class ItemPickedEvent : AbstractGameEvent { [HideInInspector] public int Count = -1; - + public override void Reset() { Count = -1; diff --git a/Assets/Shared/Scripts/ItemPickupTrigger.cs b/Assets/Shared/Scripts/ItemPickupTrigger.cs index 342fdd72..a20cc308 100644 --- a/Assets/Shared/Scripts/ItemPickupTrigger.cs +++ b/Assets/Shared/Scripts/ItemPickupTrigger.cs @@ -15,22 +15,22 @@ public class ItemPickupTrigger : Spawnable /// Player tag /// public string m_PlayerTag = "Player"; - + /// /// The event to raise on trigger /// public ItemPickedEvent m_Event; - + /// /// Defines how many items(for example coins) are stored in this object. /// public int m_Count; - + void OnTriggerEnter(Collider col) { - if (!col.CompareTag(m_PlayerTag)) + if (!col.CompareTag(m_PlayerTag)) return; - + m_Event.Count = m_Count; m_Event.Raise(); gameObject.SetActive(false); diff --git a/Assets/Shared/Scripts/SequenceManager.cs b/Assets/Shared/Scripts/SequenceManager.cs index f9d81607..c6a72161 100644 --- a/Assets/Shared/Scripts/SequenceManager.cs +++ b/Assets/Shared/Scripts/SequenceManager.cs @@ -47,7 +47,7 @@ public class SequenceManager : AbstractSingleton [SerializeField] float m_SplashDelay = 2f; - readonly StateMachine m_StateMachine = new (); + readonly StateMachine m_StateMachine = new(); IState m_SplashScreenState; IState m_MainMenuState; IState m_LevelSelectState; @@ -55,19 +55,19 @@ public class SequenceManager : AbstractSingleton public IState m_CurrentLevel; SceneController m_SceneController; - + /// /// Initializes the SequenceManager /// public void Initialize() { m_SceneController = new SceneController(SceneManager.GetActiveScene()); - + InstantiatePreloadedAssets(); m_SplashScreenState = new State(ShowUI); m_StateMachine.Run(m_SplashScreenState); - + CreateMenuNavigationSequence(); CreateLevelSequences(); SetStartingLevel(0); @@ -87,7 +87,7 @@ void CreateMenuNavigationSequence() var splashDelay = new DelayState(m_SplashDelay); m_MainMenuState = new State(OnMainMenuDisplayed); m_LevelSelectState = new State(OnLevelSelectionDisplayed); - + //Connect the states m_SplashScreenState.AddLink(new Link(splashDelay)); splashDelay.AddLink(new Link(m_MainMenuState)); @@ -98,7 +98,7 @@ void CreateMenuNavigationSequence() void CreateLevelSequences() { m_LevelStates.Clear(); - + //Create and connect all level states IState lastState = null; foreach (var level in m_Levels) @@ -144,7 +144,7 @@ IState CreateLevelState(string scenePath) { return new LoadSceneState(m_SceneController, scenePath); } - + /// /// Creates a level state from a level data /// @@ -154,7 +154,7 @@ IState CreateLevelState(AbstractLevelData levelData) { return new LoadLevelFromDef(m_SceneController, levelData, m_LevelManagers); } - + IState AddLevelPeripheralStates(IState loadLevelState, IState quitState, IState lastState) { //Create states @@ -180,7 +180,7 @@ IState AddLevelPeripheralStates(IState loadLevelState, IState quitState, IState gameplayState.AddLink(new EventLink(m_WinEvent, winState)); gameplayState.AddLink(new EventLink(m_LoseEvent, loseState)); gameplayState.AddLink(new EventLink(m_PauseEvent, pauseState)); - + loseState.AddLink(new EventLink(m_ContinueEvent, loadLevelState)); loseState.AddLink(new EventLink(m_BackEvent, unloadLose)); unloadLose.AddLink(new Link(quitState)); @@ -195,7 +195,7 @@ IState AddLevelPeripheralStates(IState loadLevelState, IState quitState, IState unlockedSkinState.AddLink(new EventLink(m_ContinueEvent, loadLevelState)); unlockedSkinState.AddLink(new EventLink(m_CollectEvent, collectedSkinState)); collectedSkinState.AddLink(new EventLink(m_ContinueEvent, loadLevelState)); - + return winState; } @@ -206,8 +206,8 @@ IState AddLevelPeripheralStates(IState loadLevelState, IState quitState, IState public void SetStartingLevel(int index) { m_LevelSelectState.RemoveAllLinks(); - m_LevelSelectState.AddLink( new EventLink(m_ContinueEvent, m_LevelStates[index])); - m_LevelSelectState.AddLink(new EventLink(m_BackEvent, m_MainMenuState)); + m_LevelSelectState.AddLink(new EventLink(m_ContinueEvent, m_LevelStates[index])); + m_LevelSelectState.AddLink(new EventLink(m_BackEvent, m_MainMenuState)); m_LevelSelectState.EnableLinks(); } @@ -215,7 +215,7 @@ void ShowUI() where T : View { UIManager.Instance.Show(); } - + void OnMainMenuDisplayed() { ShowUI(); @@ -226,10 +226,10 @@ void OnWinScreenDisplayed(IState currentLevel) { UIManager.Instance.Show(); var currentLevelIndex = m_LevelStates.IndexOf(currentLevel); - + if (currentLevelIndex == -1) throw new Exception($"{nameof(currentLevel)} is invalid!"); - + var levelProgress = SaveManager.Instance.LevelProgress; if (currentLevelIndex == levelProgress && currentLevelIndex < m_LevelStates.Count - 1) SaveManager.Instance.LevelProgress = levelProgress + 1; @@ -240,7 +240,7 @@ void OnLevelSelectionDisplayed() ShowUI(); AudioManager.Instance.PlayMusic(SoundID.MenuMusic); } - + void OnGamePlayStarted(IState current) { m_CurrentLevel = current; diff --git a/Assets/Shared/Scripts/Service/ApiService.cs b/Assets/Shared/Scripts/Service/ApiService.cs index c0cd3db7..032bc360 100644 --- a/Assets/Shared/Scripts/Service/ApiService.cs +++ b/Assets/Shared/Scripts/Service/ApiService.cs @@ -8,6 +8,7 @@ namespace HyperCasual.Core { - public class ApiService { + public class ApiService + { } } \ No newline at end of file diff --git a/Assets/Shared/Scripts/UI/Hud.cs b/Assets/Shared/Scripts/UI/Hud.cs index 4a1a5693..99636622 100644 --- a/Assets/Shared/Scripts/UI/Hud.cs +++ b/Assets/Shared/Scripts/UI/Hud.cs @@ -29,7 +29,7 @@ public class Hud : View public Slider XpSlider => m_XpSlider; int m_FoodValue; - + /// /// The amount of gold to display on the hud. /// The setter method also sets the hud text. @@ -48,7 +48,7 @@ public int FoodValue } float m_XpValue; - + /// /// The amount of XP to display on the hud. /// The setter method also sets the hud slider value. diff --git a/Assets/Shared/Scripts/UI/LevelSelectButton.cs b/Assets/Shared/Scripts/UI/LevelSelectButton.cs index 783b21e1..eab6d19f 100644 --- a/Assets/Shared/Scripts/UI/LevelSelectButton.cs +++ b/Assets/Shared/Scripts/UI/LevelSelectButton.cs @@ -18,7 +18,7 @@ public class LevelSelectButton : HyperCasualButton int m_Index = -1; Action m_OnClick; bool m_IsUnlocked; - + /// The index of the associated level /// Is the associated level locked? /// callback method for this button diff --git a/Assets/Shared/Scripts/UI/LevelSelectionScreen.cs b/Assets/Shared/Scripts/UI/LevelSelectionScreen.cs index edf1f3c0..44ea6978 100644 --- a/Assets/Shared/Scripts/UI/LevelSelectionScreen.cs +++ b/Assets/Shared/Scripts/UI/LevelSelectionScreen.cs @@ -47,7 +47,7 @@ void Start() void OnEnable() { ResetButtonData(); - + m_QuickPlayButton.AddListener(OnQuickPlayButtonClicked); m_BackButton.AddListener(OnBackButtonClicked); } @@ -71,7 +71,7 @@ void ResetButtonData() button.SetData(i, unlocked, OnClick); } } - + void OnClick(int startingIndex) { if (startingIndex < 0) @@ -80,12 +80,12 @@ void OnClick(int startingIndex) SequenceManager.Instance.SetStartingLevel(startingIndex); m_NextLevelEvent.Raise(); } - + void OnQuickPlayButtonClicked() { OnClick(SaveManager.Instance.LevelProgress); } - + void OnBackButtonClicked() { m_BackEvent.Raise(); diff --git a/Assets/Shared/Scripts/UI/MainMenu.cs b/Assets/Shared/Scripts/UI/MainMenu.cs index 356f0274..39c0643c 100644 --- a/Assets/Shared/Scripts/UI/MainMenu.cs +++ b/Assets/Shared/Scripts/UI/MainMenu.cs @@ -33,11 +33,11 @@ void OnEnable() // Set listener to 'Logout' button m_LogoutButton.RemoveListener(OnLogoutButtonClick); m_LogoutButton.AddListener(OnLogoutButtonClick); - + ShowLoading(false); ShowStartButton(true); } - + void OnDisable() { m_StartButton.RemoveListener(OnStartButtonClick); diff --git a/Assets/Shared/Scripts/UI/SettingsMenu.cs b/Assets/Shared/Scripts/UI/SettingsMenu.cs index d23c3950..95ad3eed 100644 --- a/Assets/Shared/Scripts/UI/SettingsMenu.cs +++ b/Assets/Shared/Scripts/UI/SettingsMenu.cs @@ -21,21 +21,21 @@ public class SettingsMenu : View Slider m_AudioVolumeSlider; [SerializeField] Slider m_QualitySlider; - + void OnEnable() { m_EnableMusicToggle.isOn = AudioManager.Instance.EnableMusic; m_EnableSfxToggle.isOn = AudioManager.Instance.EnableSfx; m_AudioVolumeSlider.value = AudioManager.Instance.MasterVolume; m_QualitySlider.value = QualityManager.Instance.QualityLevel; - + m_Button.AddListener(OnBackButtonClick); m_EnableMusicToggle.onValueChanged.AddListener(MusicToggleChanged); m_EnableSfxToggle.onValueChanged.AddListener(SfxToggleChanged); m_AudioVolumeSlider.onValueChanged.AddListener(VolumeSliderChanged); m_QualitySlider.onValueChanged.AddListener(QualitySliderChanged); } - + void OnDisable() { m_Button.RemoveListener(OnBackButtonClick); @@ -59,7 +59,7 @@ void VolumeSliderChanged(float value) { AudioManager.Instance.MasterVolume = value; } - + void QualitySliderChanged(float value) { QualityManager.Instance.QualityLevel = (int)value; diff --git a/Assets/Shared/Scripts/UI/SetupWalletScreen.cs b/Assets/Shared/Scripts/UI/SetupWalletScreen.cs index 021f9897..f8cf64f9 100644 --- a/Assets/Shared/Scripts/UI/SetupWalletScreen.cs +++ b/Assets/Shared/Scripts/UI/SetupWalletScreen.cs @@ -13,7 +13,7 @@ namespace HyperCasual.Runner /// public class SetupWalletScreen : View { - + [SerializeField] TextMeshProUGUI m_Title; [SerializeField]