mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
Add docs to example scripts
This commit is contained in:
parent
25bd51fec2
commit
48ca635af7
@ -6,6 +6,9 @@ using UnityAtoms.Tags;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Script to decrease a Unit's health.
|
||||
/// </summary>
|
||||
public class DecreaseHealth : MonoBehaviour
|
||||
{
|
||||
public List<StringConstant> TagsAffected { get => _tags; }
|
||||
|
@ -2,6 +2,9 @@ using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple move script for the Player.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Unity Atoms/Examples/PlayerMove")]
|
||||
public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
|
@ -3,6 +3,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// A component that contains the Player's health.
|
||||
/// </summary>
|
||||
public class UnitHealth : MonoBehaviour
|
||||
{
|
||||
public int Health { get => _health.Value; set => _health.Value = value; }
|
||||
|
@ -4,6 +4,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Script intending to destroy the GameObject it's attached to.
|
||||
/// </summary>
|
||||
public class DestroyMe : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -4,6 +4,13 @@ namespace UnityAtoms.Examples
|
||||
{
|
||||
public static class Rigidbody2DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple extension to move a Rigidbody2D using input.
|
||||
/// </summary>
|
||||
/// <param name="body">The Rigidbody2D.</param>
|
||||
/// <param name="input">Move input.</param>
|
||||
/// <param name="speed">The speed multiplier.</param>
|
||||
/// <param name="deltaTime">Time since last Update tick.</param>
|
||||
public static void Move(this Rigidbody2D body, Vector2 input, float speed, float deltaTime)
|
||||
{
|
||||
var direction = input.normalized;
|
||||
|
@ -3,6 +3,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Script to sync the Vector3 Variable with this GameObject's current position.
|
||||
/// </summary>
|
||||
public class SyncPositionWithVariable : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -5,6 +5,9 @@ using UnityAtoms.FSM;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Moves the Enemy based on the state of the enemy.
|
||||
/// </summary>
|
||||
public class EnemyMovement : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -5,6 +5,9 @@ using UnityAtoms.Tags;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Scipt that listens to the state of the enemy and shoots towards the Player if it's in the correct state.
|
||||
/// </summary>
|
||||
public class EnemyShooting : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -5,6 +5,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Manager responsible of spawning enmeies and keep track of which enemy wave we are currently facing.
|
||||
/// </summary>
|
||||
public class EnemyWaveManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -3,6 +3,9 @@ using UnityAtoms.FSM;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Dispatches commands to the FSM.
|
||||
/// </summary>
|
||||
public class GameStateDispatcher : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -3,6 +3,9 @@ using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple shooting scipt for the player using the arrow keys.
|
||||
/// </summary>
|
||||
public class PlayerShooting : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -3,6 +3,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets a constant velocity on the attached Rigidbody 2D.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class MoveInDirection : MonoBehaviour
|
||||
{
|
||||
|
@ -6,6 +6,9 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Listens to spawned and dead enemies and create and manage healthbars accordingly.
|
||||
/// </summary>
|
||||
public class EnemyHealthBarManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
@ -3,6 +3,9 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Restart the current scene.
|
||||
/// </summary>
|
||||
public class RestartCurrentScene : MonoBehaviour
|
||||
{
|
||||
public void Do() => SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
|
@ -3,6 +3,9 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the text for the Wave count UI.
|
||||
/// </summary>
|
||||
public class WaveCountText : MonoBehaviour
|
||||
{
|
||||
public void AdjustText(int waveCount) => GetComponent<Text>().text = $"Wave count: {waveCount}";
|
||||
|
@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using Marvelous;
|
||||
using UniRx;
|
||||
using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple Player move script using UniRx.
|
||||
/// </summary>
|
||||
public class PlayerMoveUniRx : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
@ -18,20 +20,24 @@ namespace UnityAtoms.Examples
|
||||
float _horizontal = 0f, _vertical = 0f;
|
||||
string HORIZONTAL = "Horizontal", VERTICAL = "Vertical";
|
||||
|
||||
Observable.EveryUpdate().Fuse<long, string>(
|
||||
_uiState.ObserveChange(),
|
||||
initialValue2: _uiState.Value
|
||||
).Subscribe(t =>
|
||||
{
|
||||
var (_, state) = t;
|
||||
_horizontal = state == _uiStatePlaying.Value ? Input.GetAxis(HORIZONTAL) : 0f;
|
||||
_vertical = state == _uiStatePlaying.Value ? Input.GetAxis(VERTICAL) : 0f;
|
||||
});
|
||||
Observable
|
||||
.EveryUpdate()
|
||||
.Fuse<long, string>(
|
||||
_uiState.ObserveChange(),
|
||||
initialValue2: _uiState.Value
|
||||
).Subscribe(t =>
|
||||
{
|
||||
var (_, state) = t;
|
||||
_horizontal = state == _uiStatePlaying.Value ? Input.GetAxis(HORIZONTAL) : 0f;
|
||||
_vertical = state == _uiStatePlaying.Value ? Input.GetAxis(VERTICAL) : 0f;
|
||||
});
|
||||
|
||||
Observable.EveryFixedUpdate().Subscribe(t =>
|
||||
{
|
||||
GetComponent<Rigidbody2D>().velocity = new Vector2(_horizontal, _vertical) * 5f;
|
||||
});
|
||||
Observable
|
||||
.EveryFixedUpdate()
|
||||
.Subscribe(t =>
|
||||
{
|
||||
GetComponent<Rigidbody2D>().velocity = new Vector2(_horizontal, _vertical) * 5f;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ using UnityAtoms.BaseAtoms;
|
||||
|
||||
namespace UnityAtoms.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple healthbar script using UniRx.
|
||||
/// </summary>
|
||||
public class HealthBarUniRx : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
Loading…
Reference in New Issue
Block a user