-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
290 changed files
with
24,284 additions
and
8,776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Unity.Hypercasual.Tutorials.Editor")] | ||
[assembly: InternalsVisibleTo("Unity.Hypercasual.Tutorials.Editor")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace HyperCasual.Core | ||
{ | ||
/// <summary> | ||
/// A scriptable object that encapsulates a reference to a scene | ||
/// A scriptable object that encapsulates a reference to a scene | ||
/// </summary> | ||
[CreateAssetMenu(fileName = nameof(SceneRef), | ||
menuName = "Runner/" + nameof(SceneRef))] | ||
public class SceneRef : AbstractLevelData | ||
{ | ||
[SerializeField] | ||
public string m_ScenePath; | ||
[SerializeField] public string m_ScenePath; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,50 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace HyperCasual.Core | ||
{ | ||
/// <summary> | ||
/// A base class which provides basic event functionalities. | ||
/// Events facilitate the communication between different scopes of the game. | ||
/// Each event is a scriptable object instance that has a list of listeners that are notified when the event is triggered. | ||
/// A base class which provides basic event functionalities. | ||
/// Events facilitate the communication between different scopes of the game. | ||
/// Each event is a scriptable object instance that has a list of listeners that are notified when the event is | ||
/// triggered. | ||
/// </summary> | ||
public abstract class AbstractGameEvent : ScriptableObject | ||
{ | ||
readonly List<IGameEventListener> m_EventListeners = new(); | ||
private readonly List<IGameEventListener> m_EventListeners = new(); | ||
|
||
/// <summary> | ||
/// Triggers the current event instance and notifies the subscribers | ||
/// Each event resets immediately after it's triggered. | ||
/// This method contains the reset logic for the derived classes. | ||
/// </summary> | ||
public abstract void Reset(); | ||
|
||
/// <summary> | ||
/// Triggers the current event instance and notifies the subscribers | ||
/// </summary> | ||
public void Raise() | ||
{ | ||
for (int i = m_EventListeners.Count - 1; i >= 0; i--) | ||
for (var i = m_EventListeners.Count - 1; i >= 0; i--) | ||
m_EventListeners[i].OnEventRaised(); | ||
Reset(); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a class to the list of observers for this event | ||
/// Adds a class to the list of observers for this event | ||
/// </summary> | ||
/// <param name="listener">The class that wants to observe this event</param> | ||
public void AddListener(IGameEventListener listener) | ||
{ | ||
if (!m_EventListeners.Contains(listener)) | ||
{ | ||
m_EventListeners.Add(listener); | ||
} | ||
if (!m_EventListeners.Contains(listener)) m_EventListeners.Add(listener); | ||
} | ||
|
||
/// <summary> | ||
/// Removes a class from the list of observers for this event | ||
/// Removes a class from the list of observers for this event | ||
/// </summary> | ||
/// <param name="listener">The class that doesn't want to observe this event anymore</param> | ||
public void RemoveListener(IGameEventListener listener) | ||
{ | ||
if (m_EventListeners.Contains(listener)) | ||
{ | ||
m_EventListeners.Remove(listener); | ||
} | ||
if (m_EventListeners.Contains(listener)) m_EventListeners.Remove(listener); | ||
} | ||
|
||
/// <summary> | ||
/// Each event resets immediately after it's triggered. | ||
/// This method contains the reset logic for the derived classes. | ||
/// </summary> | ||
public abstract void Reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using HyperCasual.Core; | ||
using UnityEngine; | ||
using HyperCasual.Runner; | ||
|
||
namespace HyperCasual.Core | ||
{ | ||
/// <summary> | ||
/// Generic game event | ||
/// Generic game event | ||
/// </summary> | ||
public class GameEvent<T> : AbstractGameEvent | ||
{ | ||
public T m_Data { get; private set; } | ||
|
||
public void Raise(T data) | ||
public override void Reset() | ||
{ | ||
m_Data = data; | ||
base.Raise(); | ||
} | ||
|
||
public override void Reset() | ||
public void Raise(T data) | ||
{ | ||
m_Data = data; | ||
base.Raise(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace HyperCasual.Core | ||
{ | ||
/// <summary> | ||
/// Raises an event on trigger collision | ||
/// Raises an event on trigger collision | ||
/// </summary> | ||
[RequireComponent(typeof(Collider))] | ||
public class TriggerEvent : MonoBehaviour | ||
{ | ||
const string k_PlayerTag = "Player"; | ||
private const string k_PlayerTag = "Player"; | ||
|
||
[SerializeField] | ||
AbstractGameEvent m_Event; | ||
[SerializeField] private AbstractGameEvent m_Event; | ||
|
||
void OnTriggerEnter(Collider col) | ||
private void OnTriggerEnter(Collider col) | ||
{ | ||
if (col.CompareTag(k_PlayerTag)) | ||
{ | ||
if (m_Event != null) | ||
{ | ||
m_Event.Raise(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.