Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniol0012 committed Sep 11, 2024
1 parent 214ab6b commit 6a25bcb
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 88 deletions.
9 changes: 3 additions & 6 deletions Assets/Scripts/Gameplay/PlayerJumped.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using Platformer.Core;
using Platformer.Mechanics;

namespace Platformer.Gameplay
{
namespace Platformer.Gameplay {
/// <summary>
/// Fired when the player performs a Jump.
/// </summary>
/// <typeparam name="PlayerJumped"></typeparam>
public class PlayerJumped : Simulation.Event<PlayerJumped>
{
public class PlayerJumped : Simulation.Event<PlayerJumped> {
public PlayerController player;

public override void Execute()
{
public override void Execute() {
if (player.audioSource && player.jumpAudio)
player.audioSource.PlayOneShot(player.jumpAudio);
}
Expand Down
9 changes: 3 additions & 6 deletions Assets/Scripts/Gameplay/PlayerLanded.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using Platformer.Core;
using Platformer.Mechanics;

namespace Platformer.Gameplay
{
namespace Platformer.Gameplay {
/// <summary>
/// Fired when the player character lands after being airborne.
/// </summary>
/// <typeparam name="PlayerLanded"></typeparam>
public class PlayerLanded : Simulation.Event<PlayerLanded>
{
public class PlayerLanded : Simulation.Event<PlayerLanded> {
public PlayerController player;

public override void Execute()
{
public override void Execute() {
}
}
}
9 changes: 3 additions & 6 deletions Assets/Scripts/Gameplay/PlayerStopJump.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using Platformer.Core;
using Platformer.Mechanics;

namespace Platformer.Gameplay
{
namespace Platformer.Gameplay {
/// <summary>
/// Fired when the Jump Input is deactivated by the user, cancelling the upward velocity of the jump.
/// </summary>
/// <typeparam name="PlayerStopJump"></typeparam>
public class PlayerStopJump : Simulation.Event<PlayerStopJump>
{
public class PlayerStopJump : Simulation.Event<PlayerStopJump> {
public PlayerController player;

public override void Execute()
{
public override void Execute() {
}
}
}
9 changes: 3 additions & 6 deletions Assets/Scripts/Gameplay/PlayerTokenCollision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
using Platformer.Model;
using UnityEngine;

namespace Platformer.Gameplay
{
namespace Platformer.Gameplay {
/// <summary>
/// Fired when a player collides with a token.
/// </summary>
/// <typeparam name="PlayerCollision"></typeparam>
public class PlayerTokenCollision : Simulation.Event<PlayerTokenCollision>
{
public class PlayerTokenCollision : Simulation.Event<PlayerTokenCollision> {
public PlayerController player;
public TokenInstance token;

PlatformerModel model = Simulation.GetModel<PlatformerModel>();

public override void Execute()
{
public override void Execute() {
AudioSource.PlayClipAtPoint(token.tokenCollectAudio, token.transform.position);
}
}
Expand Down
6 changes: 2 additions & 4 deletions Assets/Scripts/Model/PlatformerModel.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using Platformer.Mechanics;
using UnityEngine;

namespace Platformer.Model
{
namespace Platformer.Model {
/// <summary>
/// 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.
/// </summary>
[System.Serializable]
public class PlatformerModel
{
public class PlatformerModel {
/// <summary>
/// The virtual camera in the scene.
/// </summary>
Expand Down
15 changes: 5 additions & 10 deletions Assets/Scripts/UI/MainUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@
using System.Collections.Generic;
using UnityEngine;

namespace Platformer.UI
{
namespace Platformer.UI {
/// <summary>
/// A simple controller for switching between UI panels.
/// </summary>
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);
}
}
Expand Down
30 changes: 10 additions & 20 deletions Assets/Scripts/UI/MetaGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
using Platformer.UI;
using UnityEngine;

namespace Platformer.UI
{
namespace Platformer.UI {
/// <summary>
/// The MetaGameController is responsible for switching control between the high level
/// contexts of the application, eg the Main Menu and Gameplay systems.
/// </summary>
public class MetaGameController : MonoBehaviour
{
public class MetaGameController : MonoBehaviour {
/// <summary>
/// The main UI object which used for the menu.
/// </summary>
Expand All @@ -27,33 +25,27 @@ public class MetaGameController : MonoBehaviour

bool showMainCanvas = false;

void OnEnable()
{
void OnEnable() {
_ToggleMainMenu(showMainCanvas);
}

/// <summary>
/// Turn the main menu on or off.
/// </summary>
/// <param name="show"></param>
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);
Expand All @@ -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);
}
}
Expand Down
33 changes: 11 additions & 22 deletions Assets/Scripts/View/AnimatedTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Sprite>(ref tile.m_AnimatedSprites, count);
}

Expand All @@ -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);
}
Expand Down
12 changes: 4 additions & 8 deletions Assets/Scripts/View/ParallaxLayer.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
using UnityEngine;

namespace Platformer.View
{
namespace Platformer.View {
/// <summary>
/// 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.
/// </summary>
public class ParallaxLayer : MonoBehaviour
{
public class ParallaxLayer : MonoBehaviour {
/// <summary>
/// Movement of the layer is scaled by this value.
/// </summary>
public Vector3 movementScale = Vector3.one;

Transform _camera;

void Awake()
{
void Awake() {
_camera = Camera.main.transform;
}

void LateUpdate()
{
void LateUpdate() {
transform.position = Vector3.Scale(_camera.position, movementScale);
}
}
Expand Down

0 comments on commit 6a25bcb

Please sign in to comment.