Thomas ICHÉ
6 年前
当前提交
9177bf4d
共有 75 个文件被更改,包括 1482 次插入 和 0 次删除
-
8net.peeweek.gameplay-ingredients/Runtime.meta
-
8net.peeweek.gameplay-ingredients/Runtime/Actions.meta
-
9net.peeweek.gameplay-ingredients/Runtime/Actions/ActionBase.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/ActionBase.cs.meta
-
13net.peeweek.gameplay-ingredients/Runtime/Actions/ApplicationExitAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/ApplicationExitAction.cs.meta
-
57net.peeweek.gameplay-ingredients/Runtime/Actions/AudioMixParameterAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/AudioMixParameterAction.cs.meta
-
44net.peeweek.gameplay-ingredients/Runtime/Actions/AudioMixParameterCurveAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/AudioMixParameterCurveAction.cs.meta
-
17net.peeweek.gameplay-ingredients/Runtime/Actions/CursorAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/CursorAction.cs.meta
-
85net.peeweek.gameplay-ingredients/Runtime/Actions/CycleResolutionsAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/CycleResolutionsAction.cs.meta
-
33net.peeweek.gameplay-ingredients/Runtime/Actions/CycleWindowModeAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/CycleWindowModeAction.cs.meta
-
31net.peeweek.gameplay-ingredients/Runtime/Actions/EditorOnlyAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/EditorOnlyAction.cs.meta
-
15net.peeweek.gameplay-ingredients/Runtime/Actions/FocusUIAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/FocusUIAction.cs.meta
-
14net.peeweek.gameplay-ingredients/Runtime/Actions/SendMessageAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/SendMessageAction.cs.meta
-
20net.peeweek.gameplay-ingredients/Runtime/Actions/SetTimeScaleAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/SetTimeScaleAction.cs.meta
-
14net.peeweek.gameplay-ingredients/Runtime/Actions/SimpleAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/SimpleAction.cs.meta
-
22net.peeweek.gameplay-ingredients/Runtime/Actions/StreamingLevelAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/StreamingLevelAction.cs.meta
-
36net.peeweek.gameplay-ingredients/Runtime/Actions/SwitcherAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/SwitcherAction.cs.meta
-
18net.peeweek.gameplay-ingredients/Runtime/Actions/TakeScreenshotAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/TakeScreenshotAction.cs.meta
-
48net.peeweek.gameplay-ingredients/Runtime/Actions/ToggleGameObjectAction.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Actions/ToggleGameObjectAction.cs.meta
-
8net.peeweek.gameplay-ingredients/Runtime/GameplayIngredients.asmdef
-
7net.peeweek.gameplay-ingredients/Runtime/GameplayIngredients.asmdef.meta
-
8net.peeweek.gameplay-ingredients/Runtime/Hooks.meta
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/HookBase.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/HookBase.cs.meta
-
17net.peeweek.gameplay-ingredients/Runtime/Hooks/OnAwakeHook.cs
-
13net.peeweek.gameplay-ingredients/Runtime/Hooks/OnAwakeHook.cs.meta
-
21net.peeweek.gameplay-ingredients/Runtime/Hooks/OnEnableDisableHook.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/OnEnableDisableHook.cs.meta
-
30net.peeweek.gameplay-ingredients/Runtime/Hooks/OnKeyDownHook.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/OnKeyDownHook.cs.meta
-
28net.peeweek.gameplay-ingredients/Runtime/Hooks/OnMessageHook.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/OnMessageHook.cs.meta
-
17net.peeweek.gameplay-ingredients/Runtime/Hooks/OnStartHook.cs
-
13net.peeweek.gameplay-ingredients/Runtime/Hooks/OnStartHook.cs.meta
-
60net.peeweek.gameplay-ingredients/Runtime/Hooks/OnTriggerHook.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Hooks/OnTriggerHook.cs.meta
-
8net.peeweek.gameplay-ingredients/Runtime/LevelStreaming.meta
-
248net.peeweek.gameplay-ingredients/Runtime/LevelStreaming/LevelStreamingManager.cs
-
11net.peeweek.gameplay-ingredients/Runtime/LevelStreaming/LevelStreamingManager.cs.meta
-
8net.peeweek.gameplay-ingredients/Runtime/Logic.meta
-
48net.peeweek.gameplay-ingredients/Runtime/Logic/ConditionalLogic.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Logic/ConditionalLogic.cs.meta
-
41net.peeweek.gameplay-ingredients/Runtime/Logic/DelayedLogic.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Logic/DelayedLogic.cs.meta
-
11net.peeweek.gameplay-ingredients/Runtime/Logic/LogicBase.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Logic/LogicBase.cs.meta
-
26net.peeweek.gameplay-ingredients/Runtime/Logic/NextFrameLogic.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Logic/NextFrameLogic.cs.meta
-
8net.peeweek.gameplay-ingredients/Runtime/Messager.meta
-
48net.peeweek.gameplay-ingredients/Runtime/Messager/Messager.cs
-
11net.peeweek.gameplay-ingredients/Runtime/Messager/Messager.cs.meta
-
7net.peeweek.gameplay-ingredients/package.json
-
7net.peeweek.gameplay-ingredients/package.json.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 2bc4397234bb33b4bb4e5977bd9f81b0 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: dd5d6228a31581e42ae1cd1a3b12a79f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public abstract class ActionBase : MonoBehaviour |
|||
{ |
|||
public abstract void Execute(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 446b3e7e2cf55584fa1555b54658d4ab |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class ApplicationExitAction : ActionBase |
|||
{ |
|||
public override void Execute() |
|||
{ |
|||
Application.Quit(); |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: ec5c4aa8c38a45743b935b39eceb9b44 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.Audio; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class AudioMixParameterAction : ActionBase |
|||
{ |
|||
public AudioMixer AudioMixer; |
|||
|
|||
public string Parameter; |
|||
public float Value; |
|||
public float InterpDuration = 0; |
|||
|
|||
public UnityEvent OnInterpComplete; |
|||
|
|||
Coroutine m_Coroutine; |
|||
public override void Execute() |
|||
{ |
|||
if (InterpDuration <= 0.0f) |
|||
{ |
|||
AudioMixer.SetFloat(Parameter, Value); |
|||
} |
|||
else |
|||
{ |
|||
if (m_Coroutine != null) |
|||
StopCoroutine(m_Coroutine); |
|||
|
|||
m_Coroutine = StartCoroutine(InterpParameterCoroutine(AudioMixer, InterpDuration, Parameter, Value, OnInterpComplete)); |
|||
} |
|||
} |
|||
|
|||
IEnumerator InterpParameterCoroutine(AudioMixer mixer, float duration, string parameter, float targetvalue, UnityEvent onInterpComplete) |
|||
{ |
|||
float initial = 0.0f; |
|||
if (mixer.GetFloat(parameter, out initial)) |
|||
{ |
|||
float t = 0.0f; |
|||
t += Time.deltaTime / duration; |
|||
while (t < 1.0f) |
|||
{ |
|||
mixer.SetFloat(parameter, Mathf.Lerp(initial, targetvalue, t)); |
|||
yield return new WaitForEndOfFrame(); |
|||
} |
|||
mixer.SetFloat(parameter, targetvalue); |
|||
yield return new WaitForEndOfFrame(); |
|||
onInterpComplete.Invoke(); |
|||
} |
|||
else |
|||
{ |
|||
throw new InvalidOperationException("Parameter " + parameter + " does not exist on target AudioMixer : " + mixer.name); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3e93b674f69eb054c8514bd7c501f0e3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Audio; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class AudioMixParameterCurveAction : ActionBase |
|||
{ |
|||
public AudioMixer AudioMixer; |
|||
|
|||
public string Parameter; |
|||
public AnimationCurve Curve; |
|||
public float InterpDuration = 2.0f; |
|||
|
|||
public UnityEvent OnInterpComplete; |
|||
|
|||
Coroutine m_Coroutine; |
|||
public override void Execute() |
|||
{ |
|||
|
|||
if (m_Coroutine != null) |
|||
StopCoroutine(m_Coroutine); |
|||
m_Coroutine = StartCoroutine(InterpParameterCoroutine(AudioMixer, InterpDuration, Parameter, Curve, OnInterpComplete)); |
|||
} |
|||
|
|||
IEnumerator InterpParameterCoroutine(AudioMixer mixer, float duration, string parameter, AnimationCurve curve, UnityEvent onInterpComplete) |
|||
{ |
|||
float t = 0.0f; |
|||
|
|||
while (t < 1.0f) |
|||
{ |
|||
mixer.SetFloat(parameter, curve.Evaluate(t)); |
|||
yield return new WaitForEndOfFrame(); |
|||
t += Time.deltaTime / duration; |
|||
} |
|||
mixer.SetFloat(parameter, curve.Evaluate(1.0f)); |
|||
yield return new WaitForEndOfFrame(); |
|||
onInterpComplete.Invoke(); |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 483b9101733f40747b8c858a4e30c737 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class CursorAction : ActionBase |
|||
{ |
|||
public CursorLockMode LockState = CursorLockMode.None; |
|||
public bool CursorVisible = true; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
Cursor.lockState = LockState; |
|||
Cursor.visible = CursorVisible; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: a441d07e5dca4794e8f2896c98a158a0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class CycleResolutionsAction : ActionBase |
|||
{ |
|||
public Text ButtonLabel; |
|||
|
|||
private int resolution = 3; |
|||
|
|||
class ResolutionComparer : IEqualityComparer<Resolution> |
|||
{ |
|||
public bool Equals(Resolution r1, Resolution r2) |
|||
{ |
|||
return r1.width == r2.width && r1.height == r2.height; |
|||
} |
|||
|
|||
public int GetHashCode(Resolution obj) { return obj.width.GetHashCode() ^ obj.height.GetHashCode(); } |
|||
} |
|||
|
|||
string getText(Resolution currentResolution) |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
return "No resolution switch in the editor"; |
|||
#endif
|
|||
|
|||
if (currentResolution.width == 0 || currentResolution.height == 0) |
|||
{ |
|||
Debug.LogError("The selected resolution is not available in the resolution list"); |
|||
return "No resolution avaliable"; |
|||
} |
|||
|
|||
return string.Format("Resolution: {0}X{1}", currentResolution.width, currentResolution.height); |
|||
} |
|||
|
|||
Resolution[] availableResolutions; |
|||
|
|||
bool IsAllowedAspectRatio(float ratio) |
|||
{ |
|||
float[] allowedAspectRatios = new[]{ |
|||
16f / 9f, |
|||
16f / 10f, |
|||
}; |
|||
|
|||
foreach (var allowedRatio in allowedAspectRatios) |
|||
if (Mathf.Abs(ratio - allowedRatio) < 0.01f) // We allow 1% of error for in ratio difference due to floating precisions
|
|||
return true; |
|||
return false; |
|||
} |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
availableResolutions = Screen.resolutions |
|||
.Where(r => r.refreshRate == 60 || r.refreshRate == 59) // 60 or 59 fps only
|
|||
.Where(r => IsAllowedAspectRatio((float)r.width / (float)r.height)) |
|||
.Distinct(new ResolutionComparer()) // remove duplicates
|
|||
.ToArray(); |
|||
|
|||
// Note: If the player was launched with a resolution which is not in the list, we can't display it
|
|||
// If you have this issue while running a player, ensure that you're running the player with an allowed aspect ratio
|
|||
var selectedResolution = availableResolutions.FirstOrDefault(f => f.width == Screen.width && f.height == Screen.height); |
|||
|
|||
if (ButtonLabel != null) |
|||
ButtonLabel.text = getText(selectedResolution); |
|||
} |
|||
|
|||
public override void Execute() |
|||
{ |
|||
// When we are in the editor we don't have any available resolutions
|
|||
if (availableResolutions.Length == 0) |
|||
return ; |
|||
|
|||
resolution = (resolution + 1) % availableResolutions.Length; |
|||
|
|||
var selectedResolution = availableResolutions[resolution]; |
|||
Screen.SetResolution(selectedResolution.width, selectedResolution.height, Screen.fullScreen); |
|||
|
|||
if (ButtonLabel != null) |
|||
ButtonLabel.text = getText(selectedResolution); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cc067b05f79701f48b975e89dc514c85 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class CycleWindowModeAction : ActionBase |
|||
{ |
|||
public Text ButtonLabel; |
|||
|
|||
string getText(bool mode) |
|||
{ |
|||
return string.Format("Window Mode: {0}", mode ? "Full Screen" : "Windowed"); |
|||
} |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
if (ButtonLabel != null) |
|||
ButtonLabel.text = getText(Screen.fullScreen); |
|||
} |
|||
|
|||
private void Update() |
|||
{ |
|||
// We update this label each frame because setting Screen.fullScreen only update the fullScreen value at the next frame
|
|||
if (ButtonLabel != null) |
|||
ButtonLabel.text = getText(Screen.fullScreen); |
|||
} |
|||
|
|||
public override void Execute() |
|||
{ |
|||
Screen.fullScreen = !Screen.fullScreen; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 221a42401321ccc48854ecd5cfd14a28 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class EditorOnlyAction : ActionBase |
|||
{ |
|||
public enum Mode |
|||
{ |
|||
EditorOnly, |
|||
PlayerOnly |
|||
} |
|||
|
|||
public Mode ExecutionPath; |
|||
|
|||
public UnityEvent OnExecute; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
switch(ExecutionPath) |
|||
{ |
|||
case Mode.EditorOnly: |
|||
if (Application.isEditor) OnExecute.Invoke(); |
|||
break; |
|||
case Mode.PlayerOnly: |
|||
if (!Application.isEditor) OnExecute.Invoke(); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e5b32278809154e47b5d8375352f6f8f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.UI; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class FocusUIAction : ActionBase |
|||
{ |
|||
public Selectable UIObjectToFocus; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
if (UIObjectToFocus != null) |
|||
UIObjectToFocus.Select(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1e96e23fc0058b9438af30550fbe4943 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class SendMessageAction : ActionBase |
|||
{ |
|||
public string MessageToSend = "Message"; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
Messager.Send(MessageToSend); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: c68adda9532fd8043b281736d2a5fbcf |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class SetTimeScaleAction : ActionBase |
|||
{ |
|||
public float TimeScale = 1.0f; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
Time.timeScale = TimeScale; |
|||
} |
|||
|
|||
public void SetTimeScale(float value) |
|||
{ |
|||
TimeScale = value; |
|||
Execute(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8d77cc038e4aacf45b80000ee76c24b1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class SimpleAction : ActionBase |
|||
{ |
|||
public UnityEvent OnExecute; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
OnExecute.Invoke(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d0e98867b2173494983582dfb1a01d0b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Events; |
|||
using GameplayIngredients.LevelStreaming; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class StreamingLevelAction : ActionBase |
|||
{ |
|||
public string[] Scenes; |
|||
public string SceneToActivate; |
|||
public LevelStreamingManager.StreamingAction Action = LevelStreamingManager.StreamingAction.Load; |
|||
|
|||
public bool ShowUI = false; |
|||
|
|||
public UnityEvent OnLoadComplete; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
LevelStreamingManager.instance.LoadScenes(Action, Scenes, SceneToActivate, ShowUI, OnLoadComplete); |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 39abcbaec080eaa4cb915feb031bb7e8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class SwitcherAction : MonoBehaviour |
|||
{ |
|||
public GameObject[] Objects; |
|||
public GameObject Default; |
|||
|
|||
private void Start() |
|||
{ |
|||
if (Default != null) |
|||
SwitchTo(Default); |
|||
} |
|||
|
|||
public void SwitchTo(GameObject obj) |
|||
{ |
|||
foreach (GameObject o in Objects) |
|||
{ |
|||
if (o == null) continue; |
|||
if (o == obj) |
|||
{ |
|||
if (!o.activeSelf) |
|||
o.SetActive(true); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
if (o.activeSelf) |
|||
o.SetActive(false); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 966f6fe13c497cb41bcb63ce7fc45d1c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class TakeScreenshotAction : ActionBase |
|||
{ |
|||
public int supersampleRate = 1; |
|||
public string fileName = "screenshot"; |
|||
public int figureCount = 2; |
|||
private int screenshotNumber = 0; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
ScreenCapture.CaptureScreenshot(name + screenshotNumber.ToString().PadLeft(figureCount, '0') + ".png", supersampleRate); |
|||
screenshotNumber += 1; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 243cd724bfb1cdd45986699812abcbe1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Actions |
|||
{ |
|||
public class ToggleGameObjectAction : ActionBase |
|||
{ |
|||
public GameObjectToggle[] Targets; |
|||
public override void Execute() |
|||
{ |
|||
foreach(var target in Targets) |
|||
{ |
|||
if (target.GameObject == null) |
|||
{ |
|||
Debug.Log("Target is null, ignoring"); |
|||
} |
|||
else |
|||
{ |
|||
switch(target.State) |
|||
{ |
|||
case GameObjectToggle.GameObjectToggleState.Disable: |
|||
target.GameObject.SetActive(false); |
|||
break; |
|||
case GameObjectToggle.GameObjectToggleState.Enable: |
|||
target.GameObject.SetActive(true); |
|||
break; |
|||
case GameObjectToggle.GameObjectToggleState.Toggle: |
|||
target.GameObject.SetActive(!target.GameObject.activeSelf); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public struct GameObjectToggle |
|||
{ |
|||
[System.Serializable] |
|||
public enum GameObjectToggleState |
|||
{ |
|||
Disable = 0, |
|||
Enable = 1, |
|||
Toggle = 2 |
|||
} |
|||
|
|||
public GameObject GameObject; |
|||
public GameObjectToggleState State; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 846d5f33f7af4014ea15adf7a92dc953 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"name": "GameplayIngredients", |
|||
"references": [], |
|||
"optionalUnityReferences": [], |
|||
"includePlatforms": [], |
|||
"excludePlatforms": [], |
|||
"allowUnsafeCode": false |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 35b77b6af1f4f29438b572ce0b250b85 |
|||
AssemblyDefinitionImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3c92fcec6c30f474484161ae0c8f31d2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public abstract class HookBase : MonoBehaviour |
|||
{ |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 1fc1a91895a65e945aa1a76962232170 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnAwakeHook : MonoBehaviour |
|||
{ |
|||
public UnityEvent onAwake; |
|||
|
|||
private void Awake() |
|||
{ |
|||
onAwake.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 3bfe7209b5cff4f49b13217ed25f16dd |
|||
timeCreated: 1504691534 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnEnableDisableHook : HookBase |
|||
{ |
|||
public UnityEvent OnEnableEvent; |
|||
public UnityEvent OnDisableEvent; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
OnEnableEvent.Invoke(); |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
OnDisableEvent.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 19e53b416fec4b341a147adedee96946 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnKeyDownAction : HookBase |
|||
{ |
|||
public enum ActionType |
|||
{ |
|||
KeyDown, |
|||
KeyUp |
|||
} |
|||
|
|||
public KeyCode Key = KeyCode.F5; |
|||
|
|||
public UnityEvent OnKeyDownEvent; |
|||
public UnityEvent OnKeyUpEvent; |
|||
|
|||
void Update() |
|||
{ |
|||
if (Input.GetKeyDown(Key)) |
|||
OnKeyDownEvent.Invoke(); |
|||
|
|||
if (Input.GetKeyUp(Key)) |
|||
OnKeyUpEvent.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 067ff0798d64f3f4cab5a7ddf7057db3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnMessageHook : HookBase |
|||
{ |
|||
public string MessageName = "Message"; |
|||
|
|||
public UnityEvent Event; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
Messager.RegisterEvent(MessageName, Execute); |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
Messager.UnregisterEvent(MessageName, Execute); |
|||
} |
|||
|
|||
void Execute() |
|||
{ |
|||
Event.Invoke(); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4a42a87995c7dd1418e01c581ec175f1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnStartHook : HookBase |
|||
{ |
|||
public UnityEvent OnStart; |
|||
|
|||
private void Start() |
|||
{ |
|||
OnStart.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 718c1945292acbd4497cd28bcaa94f8d |
|||
timeCreated: 1504691534 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Hooks |
|||
{ |
|||
public class OnTriggerHook : HookBase |
|||
{ |
|||
public int EnterMaxCount = 0; |
|||
public int ExitMaxCount = 0; |
|||
|
|||
private int m_RemainingEnterCount; |
|||
private int m_RemainingExitCount; |
|||
|
|||
public UnityEvent onTriggerEnter; |
|||
public UnityEvent onTriggerExit; |
|||
|
|||
public bool OnlyInteractWithTag = true; |
|||
public string Tag = "Player"; |
|||
|
|||
void Start() |
|||
{ |
|||
m_RemainingEnterCount = EnterMaxCount; |
|||
m_RemainingExitCount = ExitMaxCount; |
|||
} |
|||
|
|||
private void OnTriggerEnter(Collider other) |
|||
{ |
|||
if (EnterMaxCount > 0) |
|||
{ |
|||
if (m_RemainingEnterCount == 0) return; |
|||
m_RemainingEnterCount--; |
|||
} |
|||
if (OnlyInteractWithTag && other.tag == Tag ) |
|||
{ |
|||
onTriggerEnter.Invoke(); |
|||
} |
|||
if (!OnlyInteractWithTag) |
|||
{ |
|||
onTriggerEnter.Invoke(); |
|||
} |
|||
} |
|||
|
|||
private void OnTriggerExit(Collider other) |
|||
{ |
|||
if (ExitMaxCount > 0) |
|||
{ |
|||
if (m_RemainingExitCount == 0) return; |
|||
m_RemainingExitCount--; |
|||
} |
|||
if (OnlyInteractWithTag && other.tag == Tag ) |
|||
{ |
|||
onTriggerExit.Invoke(); |
|||
} |
|||
if (!OnlyInteractWithTag) |
|||
{ |
|||
onTriggerExit.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 75510bef0e49d8e4ea339b95845f15de |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {fileID: 2800000, guid: 72c736bbabc19884988f7d3f5376ee26, type: 3} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4187919837946ea479e9dd7d67ba328c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.SceneManagement; |
|||
using System.Linq; |
|||
|
|||
namespace GameplayIngredients.LevelStreaming |
|||
{ |
|||
public class LevelStreamingManager : MonoBehaviour |
|||
{ |
|||
public static LevelStreamingManager instance { get { return s_Instance; } } |
|||
private static LevelStreamingManager s_Instance; |
|||
|
|||
public enum StreamingAction |
|||
{ |
|||
Load, |
|||
Unload |
|||
} |
|||
|
|||
[Header("UI Configuration")] |
|||
public GameObject LoadingRoot; |
|||
public GameObject ProgressBar; |
|||
public GameObject ProgressBarContainer; |
|||
public Text LoadingText; |
|||
public Text PercentageText; |
|||
|
|||
[Header("Debug")] |
|||
public Text DebugText; |
|||
public bool EnableDebug = false; |
|||
|
|||
private float[] percentages; |
|||
private AsyncOperation[] asyncOperations; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
//if(!Console.HasCommand("STREAMING")) Console.AddCommand(new LevelStreamingCommand());
|
|||
|
|||
if (s_Instance != null) |
|||
throw new InvalidOperationException("LevelStreamingManager Already Exists"); |
|||
else |
|||
s_Instance = this; |
|||
|
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
if (s_Instance == this) |
|||
s_Instance = null; |
|||
} |
|||
|
|||
public void LoadScenes(StreamingAction action, string[] scenes, string sceneToActivate, bool showUI, UnityEvent onLoadComplete) |
|||
{ |
|||
if (EnableDebug) |
|||
DebugText.gameObject.SetActive(true); |
|||
|
|||
List<string> requiredScenes = new List<string>(); |
|||
|
|||
foreach (string scene in scenes) |
|||
{ |
|||
if ( |
|||
(SceneManager.GetSceneByName(scene).isLoaded && action == StreamingAction.Unload) |
|||
|| (!SceneManager.GetSceneByName(scene).isLoaded && action == StreamingAction.Load) |
|||
) |
|||
{ |
|||
requiredScenes.Add(scene); |
|||
} |
|||
} |
|||
|
|||
int count = requiredScenes.Count; |
|||
percentages = new float[count]; |
|||
asyncOperations = new AsyncOperation[count]; |
|||
|
|||
if (showUI) |
|||
LoadingRoot.SetActive(true); |
|||
|
|||
if (count > 0) |
|||
StartCoroutine(LoadScenesCoroutine(action, requiredScenes, sceneToActivate, showUI, onLoadComplete)); |
|||
else |
|||
{ |
|||
Debug.LogWarning("Did not find any candidates to load or unload..."); |
|||
|
|||
if (onLoadComplete != null) onLoadComplete.Invoke(); |
|||
|
|||
if (showUI) |
|||
LoadingRoot.SetActive(false); |
|||
|
|||
if (EnableDebug) |
|||
DebugText.gameObject.SetActive(false); |
|||
} |
|||
} |
|||
|
|||
IEnumerator LoadScenesCoroutine(StreamingAction action, List<string> scenes, string sceneToActivate, bool showUI, UnityEvent onLoadComplete) |
|||
{ |
|||
LogDebugInformation("START LOAD/UNLOAD FOR LEVELS..."); |
|||
SetProgressBar(0.0f, true); |
|||
|
|||
switch (action) |
|||
{ |
|||
case StreamingAction.Load: |
|||
LogDebugInformation("[*] ASYNC LOAD FOR: " + scenes); |
|||
StartCoroutine(LoadLevelCoroutine(scenes)); |
|||
break; |
|||
case StreamingAction.Unload: |
|||
LogDebugInformation("[*] ASYNC UNLOAD FOR: " + scenes); |
|||
StartCoroutine(UnloadLevelCoroutine(scenes)); |
|||
break; |
|||
default: throw new NotImplementedException("LoadScenesCoroutine does not handle mode " + action.ToString()); |
|||
} |
|||
|
|||
// Wait for all scenes to be loaded
|
|||
while (asyncOperations.Any(a => !a.isDone)) |
|||
yield return new WaitForEndOfFrame(); |
|||
|
|||
// Then change active scene
|
|||
if (sceneToActivate != "") |
|||
{ |
|||
var newActive = SceneManager.GetSceneByName(sceneToActivate); |
|||
SceneManager.SetActiveScene(newActive); |
|||
yield return new WaitForEndOfFrame(); |
|||
} |
|||
|
|||
if (onLoadComplete != null) |
|||
onLoadComplete.Invoke(); |
|||
|
|||
if (showUI) |
|||
LoadingRoot.SetActive(false); |
|||
|
|||
if (EnableDebug) |
|||
DebugText.gameObject.SetActive(false); |
|||
} |
|||
|
|||
void UpdatePercentage() |
|||
{ |
|||
for (int i = 0; i < asyncOperations.Length; i++) |
|||
percentages[i] = asyncOperations[i].progress; |
|||
float percentage = percentages.Sum() / percentages.Length; |
|||
SetProgressBar(percentage); |
|||
} |
|||
|
|||
private IEnumerator LoadLevelCoroutine(List<string> sceneNames) |
|||
{ |
|||
for (int i = 0; i < sceneNames.Count; i++) |
|||
{ |
|||
asyncOperations[i] = SceneManager.LoadSceneAsync(sceneNames[i], LoadSceneMode.Additive); |
|||
asyncOperations[i].allowSceneActivation = false; |
|||
} |
|||
|
|||
LoadingText.text = "Loading..."; |
|||
|
|||
while (asyncOperations.Any(a => a.progress < 0.9f)) |
|||
{ |
|||
UpdatePercentage(); |
|||
yield return new WaitForEndOfFrame(); |
|||
} |
|||
|
|||
// Activate scenes
|
|||
foreach (var a in asyncOperations) |
|||
a.allowSceneActivation = true; |
|||
LoadingText.text = "Starting..."; |
|||
LogDebugInformation("All scenes loaded"); |
|||
|
|||
while (asyncOperations.Any(a => !a.isDone)) |
|||
{ |
|||
foreach (var a in asyncOperations) |
|||
Debug.Log("allowSceneActivation: " + a.allowSceneActivation); |
|||
UpdatePercentage(); |
|||
yield return new WaitForEndOfFrame(); |
|||
} |
|||
|
|||
LogDebugInformation("All scenes activated"); |
|||
} |
|||
|
|||
private IEnumerator UnloadLevelCoroutine(List<string> sceneNames) |
|||
{ |
|||
for (int i = 0; i < sceneNames.Count; i++) |
|||
{ |
|||
if (!SceneManager.GetSceneByName(sceneNames[i]).isLoaded) |
|||
{ |
|||
LogDebugInformation("SKIP UNLOAD: " + sceneNames + " (NOT LOADED)"); |
|||
continue; |
|||
} |
|||
asyncOperations[i] = SceneManager.UnloadSceneAsync(sceneNames[i]); |
|||
asyncOperations[i].allowSceneActivation = false; |
|||
} |
|||
|
|||
// Remove nulls
|
|||
asyncOperations = asyncOperations.Where(a => a != null).ToArray(); |
|||
|
|||
LoadingText.text = "Unloading..."; |
|||
|
|||
while (asyncOperations.Any(a => a.progress < 1.0f)) |
|||
{ |
|||
UpdatePercentage(); |
|||
yield return new WaitForEndOfFrame(); |
|||
} |
|||
|
|||
LogDebugInformation("Unloaded all scenes"); |
|||
} |
|||
|
|||
private float m_CurrentPercentage = 0.0f; |
|||
private float m_TargetPercentage = 0.0f; |
|||
|
|||
private void SetProgressBar(float percentage, bool direct = false) |
|||
{ |
|||
m_TargetPercentage = percentage; |
|||
if (direct) |
|||
m_CurrentPercentage = m_TargetPercentage; |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
// Smoothen bar
|
|||
m_CurrentPercentage = Mathf.Lerp(m_CurrentPercentage, m_TargetPercentage, 10 * Time.deltaTime); |
|||
|
|||
// Update UI
|
|||
PercentageText.text = ((int)(m_CurrentPercentage * 100)) + "%"; |
|||
Vector2 size = ProgressBar.GetComponent<RectTransform>().sizeDelta; |
|||
size.x = m_CurrentPercentage * ProgressBarContainer.GetComponent<RectTransform>().sizeDelta.x; |
|||
ProgressBar.GetComponent<RectTransform>().sizeDelta = size; |
|||
|
|||
//Debug
|
|||
if (EnableDebug) |
|||
{ |
|||
var sb = new System.Text.StringBuilder(); |
|||
int count = SceneManager.sceneCount; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
var s = SceneManager.GetSceneAt(i); |
|||
sb.AppendLine(string.Format("{0} : {1}", s.name, s.isLoaded ? "loaded" : "unloaded")); |
|||
} |
|||
|
|||
DebugText.text = sb.ToString(); |
|||
} |
|||
|
|||
} |
|||
|
|||
private void LogDebugInformation(string text) |
|||
{ |
|||
if(EnableDebug) |
|||
Debug.Log(text); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d9f78c0b7259f604da294b52e1208e0f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5ebe86219914e5142b233ec087aa6c4b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Logic |
|||
{ |
|||
public abstract class ConditionalLogic : LogicBase |
|||
{ |
|||
public UnityEvent OnConditionValid; |
|||
public UnityEvent OnConditionInvalid; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
if (GetCondition()) |
|||
OnConditionValid.Invoke(); |
|||
else |
|||
OnConditionInvalid.Invoke(); |
|||
} |
|||
|
|||
public abstract bool GetCondition(); |
|||
|
|||
protected static bool Compare<T>(T A, T B, Comparison c) where T : IComparable |
|||
{ |
|||
int comp = A.CompareTo(B); |
|||
switch (c) |
|||
{ |
|||
case Comparison.Equal: return comp == 0; |
|||
case Comparison.NotEqual: return comp != 0; |
|||
case Comparison.Greater: return comp > 0; |
|||
case Comparison.GreaterOrEqual: return comp >= 0; |
|||
case Comparison.Less: return comp < 0; |
|||
case Comparison.LessOrEqual: return comp <= 0; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public enum Comparison |
|||
{ |
|||
Equal, |
|||
NotEqual, |
|||
Greater, |
|||
GreaterOrEqual, |
|||
Less, |
|||
LessOrEqual |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 284bd2246811b5140981d1b726bcc42d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Logic |
|||
{ |
|||
public class DelayedLogic : LogicBase |
|||
{ |
|||
public float Delay = 1.0f; |
|||
public UnityEvent OnDelayComplete; |
|||
public UnityEvent OnCanceled; |
|||
|
|||
IEnumerator m_Coroutine; |
|||
|
|||
public void Cancel() |
|||
{ |
|||
if(m_Coroutine != null) |
|||
{ |
|||
StopCoroutine(m_Coroutine); |
|||
OnCanceled.Invoke(); |
|||
m_Coroutine = null; |
|||
} |
|||
} |
|||
|
|||
public override void Execute() |
|||
{ |
|||
if (m_Coroutine != null) Cancel(); |
|||
|
|||
m_Coroutine = RunDelay(Delay); |
|||
StartCoroutine(m_Coroutine); |
|||
} |
|||
|
|||
IEnumerator RunDelay(float Seconds) |
|||
{ |
|||
yield return new WaitForSeconds(Seconds); |
|||
OnDelayComplete.Invoke(); |
|||
m_Coroutine = null; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 0ce142628ca19c2489cf2183fc2d934f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Logic |
|||
{ |
|||
public abstract class LogicBase : MonoBehaviour |
|||
{ |
|||
public abstract void Execute(); |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 25794934d66638d499d7845c74835d10 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace GameplayIngredients.Logic |
|||
{ |
|||
public class NextFrameLogic : LogicBase |
|||
{ |
|||
public UnityEvent OnComplete; |
|||
IEnumerator m_Coroutine; |
|||
|
|||
public override void Execute() |
|||
{ |
|||
m_Coroutine = RunDelay(); |
|||
StartCoroutine(m_Coroutine); |
|||
} |
|||
|
|||
IEnumerator RunDelay() |
|||
{ |
|||
yield return new WaitForEndOfFrame(); |
|||
OnComplete.Invoke(); |
|||
m_Coroutine = null; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 67b9c6de4d14ca04297d8e1b9884a16e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 028d58b9ffaca47498724dd4e40eb5f0 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients |
|||
{ |
|||
public static class Messager |
|||
{ |
|||
private static Dictionary<string, Action> m_RegisteredEvents; |
|||
|
|||
static Messager() |
|||
{ |
|||
m_RegisteredEvents = new Dictionary<string, Action>(); |
|||
} |
|||
|
|||
|
|||
public static void RegisterEvent(string eventName, Action action) |
|||
{ |
|||
if (!m_RegisteredEvents.ContainsKey(eventName)) |
|||
m_RegisteredEvents.Add(eventName, action); |
|||
else |
|||
m_RegisteredEvents[eventName] += action; |
|||
} |
|||
|
|||
public static void UnregisterEvent(string eventName, Action action) |
|||
{ |
|||
var currentEvent = m_RegisteredEvents[eventName]; |
|||
currentEvent -= action; |
|||
if (currentEvent == null) |
|||
m_RegisteredEvents.Remove(eventName); |
|||
} |
|||
|
|||
public static void Send(string eventName) |
|||
{ |
|||
Debug.Log(string.Format("[MessageManager] Broadcast: {0}", eventName)); |
|||
|
|||
if (m_RegisteredEvents.ContainsKey(eventName)) |
|||
{ |
|||
m_RegisteredEvents[eventName](); |
|||
} |
|||
else |
|||
{ |
|||
Debug.Log("[MessageManager] could not find any listeners for event : " + eventName); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 98f6d9dadeeb5c247a48dfbe4de41585 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: -200 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"name": "net.peeweek.gameplay-ingredients", |
|||
"displayName": "Gameplay Ingredients", |
|||
"version": "0.0.1", |
|||
"unity": "2018.3", |
|||
"description": "Gameplay ingredients base package" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9ce404d2f5284c247a1fcf5849abf173 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue