diff --git a/Examples/Assets/InfinityWaves/Common/DestroyMe.cs b/Examples/Assets/InfinityWaves/Common/DestroyMe.cs index 8de35328..43cbc27e 100644 --- a/Examples/Assets/InfinityWaves/Common/DestroyMe.cs +++ b/Examples/Assets/InfinityWaves/Common/DestroyMe.cs @@ -2,27 +2,30 @@ using UnityEngine.Assertions; using UnityAtoms.BaseAtoms; -public class DestroyMe : MonoBehaviour +namespace UnityAtoms.Examples { - [SerializeField] - FloatReference _delay = new FloatReference(-1f); - - void Start() + public class DestroyMe : MonoBehaviour { - Assert.IsNotNull(_delay); - if (_delay.Value >= 0f) + [SerializeField] + FloatReference _delay = new FloatReference(-1f); + + void Start() { - Destroy(gameObject, _delay.Value); + Assert.IsNotNull(_delay); + if (_delay.Value >= 0f) + { + Destroy(gameObject, _delay.Value); + } } - } - public void DestroyImmediate() => Destroy(gameObject); + public void DestroyImmediate() => Destroy(gameObject); - public void DestroyIfZeroOfBelow(int value) - { - if (value <= 0) + public void DestroyIfZeroOfBelow(int value) { - DestroyImmediate(); + if (value <= 0) + { + DestroyImmediate(); + } } } } diff --git a/Examples/Assets/InfinityWaves/Common/Rigidbody2DExtensions.cs b/Examples/Assets/InfinityWaves/Common/Rigidbody2DExtensions.cs index b51602d6..9e7441ef 100644 --- a/Examples/Assets/InfinityWaves/Common/Rigidbody2DExtensions.cs +++ b/Examples/Assets/InfinityWaves/Common/Rigidbody2DExtensions.cs @@ -1,17 +1,20 @@ using UnityEngine; -public static class Rigidbody2DExtensions +namespace UnityAtoms.Examples { - public static void Move(this Rigidbody2D body, Vector2 input, float speed, float deltaTime) + public static class Rigidbody2DExtensions { - var direction = input.normalized; - var targetVelocity = direction * speed; - body.velocity = Vector2.Lerp(body.velocity, targetVelocity, 10f * deltaTime); - - if (direction.magnitude > 0f) + public static void Move(this Rigidbody2D body, Vector2 input, float speed, float deltaTime) { - float lookAtTargetAngle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; - body.transform.rotation = Quaternion.AngleAxis(lookAtTargetAngle, Vector3.forward); + var direction = input.normalized; + var targetVelocity = direction * speed; + body.velocity = Vector2.Lerp(body.velocity, targetVelocity, 10f * deltaTime); + + if (direction.magnitude > 0f) + { + float lookAtTargetAngle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; + body.transform.rotation = Quaternion.AngleAxis(lookAtTargetAngle, Vector3.forward); + } } } } diff --git a/Examples/Assets/InfinityWaves/Common/UnitHealth.cs b/Examples/Assets/InfinityWaves/Common/UnitHealth.cs index 1cdcfbf8..3a5bb203 100644 --- a/Examples/Assets/InfinityWaves/Common/UnitHealth.cs +++ b/Examples/Assets/InfinityWaves/Common/UnitHealth.cs @@ -1,11 +1,14 @@ using UnityEngine; using UnityAtoms.BaseAtoms; -public class UnitHealth : MonoBehaviour +namespace UnityAtoms.Examples { - public int Health { get => _health.Value; set => _health.Value = value; } + public class UnitHealth : MonoBehaviour + { + public int Health { get => _health.Value; set => _health.Value = value; } - [SerializeField] - private IntReference _health; -} + [SerializeField] + private IntReference _health; + } +} \ No newline at end of file diff --git a/Examples/Assets/InfinityWaves/GameState/GameStateDispatcher.cs b/Examples/Assets/InfinityWaves/GameState/GameStateDispatcher.cs index 24409b16..b954a72b 100644 --- a/Examples/Assets/InfinityWaves/GameState/GameStateDispatcher.cs +++ b/Examples/Assets/InfinityWaves/GameState/GameStateDispatcher.cs @@ -1,16 +1,19 @@ using UnityEngine; using UnityAtoms.FSM; -public class GameStateDispatcher : MonoBehaviour +namespace UnityAtoms.Examples { - [SerializeField] - private FiniteStateMachineReference _gameStateRef; - - public void DispatchGameOverIfDead(int health) + public class GameStateDispatcher : MonoBehaviour { - if (health <= 0) + [SerializeField] + private FiniteStateMachineReference _gameStateRef; + + public void DispatchGameOverIfDead(int health) { - _gameStateRef.Machine.Dispatch("SetGameOver"); + if (health <= 0) + { + _gameStateRef.Machine.Dispatch("SetGameOver"); + } } } -} +} \ No newline at end of file diff --git a/Examples/Assets/InfinityWaves/Player/PlayerShooting.cs b/Examples/Assets/InfinityWaves/Player/PlayerShooting.cs index a0179f52..412b280f 100644 --- a/Examples/Assets/InfinityWaves/Player/PlayerShooting.cs +++ b/Examples/Assets/InfinityWaves/Player/PlayerShooting.cs @@ -1,48 +1,51 @@ using UnityAtoms.BaseAtoms; using UnityEngine; -public class PlayerShooting : MonoBehaviour +namespace UnityAtoms.Examples { - [SerializeField] - private GameObject _projectile; - - [SerializeField] - private StringConstant _playerTag; - - - void Update() + public class PlayerShooting : MonoBehaviour { - var shootDirection = Vector3.zero; - var rot = Quaternion.identity; + [SerializeField] + private GameObject _projectile; - if (Input.GetKeyDown(KeyCode.UpArrow)) - { - shootDirection = Vector3.up; - rot = Quaternion.Euler(0f, 0f, 90f); - } - else if (Input.GetKeyDown(KeyCode.DownArrow)) - { - shootDirection = Vector3.down; - rot = Quaternion.Euler(0f, 0f, -90f); - - } - else if (Input.GetKeyDown(KeyCode.RightArrow)) - { - shootDirection = Vector3.right; - rot = Quaternion.Euler(0f, 0f, 0f); - } - else if (Input.GetKeyDown(KeyCode.LeftArrow)) - { - shootDirection = Vector3.left; - rot = Quaternion.Euler(0f, 0f, 180f); - } + [SerializeField] + private StringConstant _playerTag; - if (shootDirection != Vector3.zero) + void Update() { - var spawnPos = transform.position + shootDirection * 0.6f; - var projectile = Instantiate(_projectile, spawnPos, rot); - projectile.GetComponent().TagsAffected.Remove(_playerTag); // Turn off friendly fire + var shootDirection = Vector3.zero; + var rot = Quaternion.identity; + + if (Input.GetKeyDown(KeyCode.UpArrow)) + { + shootDirection = Vector3.up; + rot = Quaternion.Euler(0f, 0f, 90f); + } + else if (Input.GetKeyDown(KeyCode.DownArrow)) + { + shootDirection = Vector3.down; + rot = Quaternion.Euler(0f, 0f, -90f); + + } + else if (Input.GetKeyDown(KeyCode.RightArrow)) + { + shootDirection = Vector3.right; + rot = Quaternion.Euler(0f, 0f, 0f); + } + else if (Input.GetKeyDown(KeyCode.LeftArrow)) + { + shootDirection = Vector3.left; + rot = Quaternion.Euler(0f, 0f, 180f); + } + + + if (shootDirection != Vector3.zero) + { + var spawnPos = transform.position + shootDirection * 0.6f; + var projectile = Instantiate(_projectile, spawnPos, rot); + projectile.GetComponent().TagsAffected.Remove(_playerTag); // Turn off friendly fire + } } } -} +} \ No newline at end of file diff --git a/Examples/Assets/InfinityWaves/Projectile/DecreaseHealth.cs b/Examples/Assets/InfinityWaves/Projectile/DecreaseHealth.cs index 4fad1a3f..a413abc1 100644 --- a/Examples/Assets/InfinityWaves/Projectile/DecreaseHealth.cs +++ b/Examples/Assets/InfinityWaves/Projectile/DecreaseHealth.cs @@ -1,42 +1,43 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Assertions; using UnityAtoms.BaseAtoms; -using UnityAtoms; using UnityAtoms.Tags; -public class DecreaseHealth : MonoBehaviour +namespace UnityAtoms.Examples { - public List TagsAffected { get => _tags; } - - [SerializeField] - private IntReference _decreaseBy; - - [SerializeField] - private List _tags; - - [SerializeField] - private VoidBaseEventReference _didCollide; - - void Start() + public class DecreaseHealth : MonoBehaviour { - Assert.IsNotNull(_decreaseBy); - Assert.IsNotNull(_tags); - } + public List TagsAffected { get => _tags; } - public void Do(Collider2D collider) - { - if (collider == null) return; + [SerializeField] + private IntReference _decreaseBy; - if (collider.gameObject.HasAnyTag(_tags)) + [SerializeField] + private List _tags; + + [SerializeField] + private VoidBaseEventReference _didCollide; + + void Start() { - collider.GetComponent().Health -= _decreaseBy; + Assert.IsNotNull(_decreaseBy); + Assert.IsNotNull(_tags); } - if (_didCollide != null && _didCollide.Event != null) + public void Do(Collider2D collider) { - _didCollide.Event.Raise(); + if (collider == null) return; + + if (collider.gameObject.HasAnyTag(_tags)) + { + collider.GetComponent().Health -= _decreaseBy; + } + + if (_didCollide != null && _didCollide.Event != null) + { + _didCollide.Event.Raise(); + } } } -} +} \ No newline at end of file diff --git a/Examples/Assets/InfinityWaves/Projectile/MoveInDirection.cs b/Examples/Assets/InfinityWaves/Projectile/MoveInDirection.cs index 4d02b469..0a6075fc 100644 --- a/Examples/Assets/InfinityWaves/Projectile/MoveInDirection.cs +++ b/Examples/Assets/InfinityWaves/Projectile/MoveInDirection.cs @@ -1,26 +1,27 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; using UnityAtoms.BaseAtoms; -[RequireComponent(typeof(Rigidbody2D))] -public class MoveInDirection : MonoBehaviour +namespace UnityAtoms.Examples { - public float Speed { set => _speed.Value = value; } - - [SerializeField] - private FloatReference _speed; - - private Rigidbody2D rb; - - void Start() + [RequireComponent(typeof(Rigidbody2D))] + public class MoveInDirection : MonoBehaviour { - rb = GetComponent(); - rb.isKinematic = true; - } + public float Speed { set => _speed.Value = value; } - void Update() - { - rb.velocity = transform.right * _speed.Value; + [SerializeField] + private FloatReference _speed; + + private Rigidbody2D rb; + + void Start() + { + rb = GetComponent(); + rb.isKinematic = true; + } + + void Update() + { + rb.velocity = transform.right * _speed.Value; + } } } diff --git a/Examples/Assets/InfinityWaves/UI/TryAgainButton/RestartCurrentScene.cs b/Examples/Assets/InfinityWaves/UI/TryAgainButton/RestartCurrentScene.cs index e3c6257f..8e796357 100644 --- a/Examples/Assets/InfinityWaves/UI/TryAgainButton/RestartCurrentScene.cs +++ b/Examples/Assets/InfinityWaves/UI/TryAgainButton/RestartCurrentScene.cs @@ -1,7 +1,10 @@ using UnityEngine; using UnityEngine.SceneManagement; -public class RestartCurrentScene : MonoBehaviour +namespace UnityAtoms.Examples { - public void Do() => SceneManager.LoadScene(SceneManager.GetActiveScene().name); + public class RestartCurrentScene : MonoBehaviour + { + public void Do() => SceneManager.LoadScene(SceneManager.GetActiveScene().name); + } }