-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
大改事件系统 BGM支持 Assets Version: v0.0.3 Script Version: v0.0.4
- Loading branch information
Showing
18 changed files
with
520 additions
and
94 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!241 &24100000 | ||
AudioMixerController: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: NewAudioMixer | ||
m_OutputGroup: {fileID: 0} | ||
m_MasterGroup: {fileID: 24300002} | ||
m_Snapshots: | ||
- {fileID: 24500006} | ||
m_StartSnapshot: {fileID: 24500006} | ||
m_SuspendThreshold: -80 | ||
m_EnableSuspend: 1 | ||
m_UpdateMode: 0 | ||
m_ExposedParameters: [] | ||
m_AudioMixerGroupViews: | ||
- guids: | ||
- 2e56caa10b03d2b48aab4d11c12021f7 | ||
- 322533cf3b9bba54584be71d6bc4c36f | ||
- 63b5d0aadf6defc4781ccf27dcd3212e | ||
name: View | ||
m_CurrentViewIndex: 0 | ||
m_TargetSnapshot: {fileID: 24500006} | ||
--- !u!243 &24300002 | ||
AudioMixerGroupController: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: Master | ||
m_AudioMixer: {fileID: 24100000} | ||
m_GroupID: 2e56caa10b03d2b48aab4d11c12021f7 | ||
m_Children: | ||
- {fileID: 243159630443108008} | ||
- {fileID: 243736800746631566} | ||
m_Volume: 85383db9e6fd2ad4ba49edc92f6a7a9f | ||
m_Pitch: f99a7c2f1d68ef64eb65af7db3f17ed1 | ||
m_Effects: | ||
- {fileID: 24400004} | ||
m_UserColorIndex: 0 | ||
m_Mute: 0 | ||
m_Solo: 0 | ||
m_BypassEffects: 0 | ||
--- !u!244 &24400004 | ||
AudioMixerEffectController: | ||
m_ObjectHideFlags: 3 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: | ||
m_EffectID: 86d94f750707f2d4f9cb7c6464b9d5a1 | ||
m_EffectName: Attenuation | ||
m_MixLevel: 7e9ab68080b4c9e46b36a29d476d393c | ||
m_Parameters: [] | ||
m_SendTarget: {fileID: 0} | ||
m_EnableWetMix: 0 | ||
m_Bypass: 0 | ||
--- !u!245 &24500006 | ||
AudioMixerSnapshotController: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: Snapshot | ||
m_AudioMixer: {fileID: 24100000} | ||
m_SnapshotID: cc1460d2ebb162843827ceb9fc034609 | ||
m_FloatValues: {} | ||
m_TransitionOverrides: {} | ||
--- !u!243 &243159630443108008 | ||
AudioMixerGroupController: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: BackGroundMusic | ||
m_AudioMixer: {fileID: 24100000} | ||
m_GroupID: 322533cf3b9bba54584be71d6bc4c36f | ||
m_Children: [] | ||
m_Volume: 787fd58580bbb35458e71c261e11cc44 | ||
m_Pitch: 26725e43732261647832ccb90cc7079a | ||
m_Effects: | ||
- {fileID: 244373443531088772} | ||
m_UserColorIndex: 0 | ||
m_Mute: 0 | ||
m_Solo: 0 | ||
m_BypassEffects: 0 | ||
--- !u!243 &243736800746631566 | ||
AudioMixerGroupController: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: Effect | ||
m_AudioMixer: {fileID: 24100000} | ||
m_GroupID: 63b5d0aadf6defc4781ccf27dcd3212e | ||
m_Children: [] | ||
m_Volume: 6de58d687e55c0a4fa82619c024845d7 | ||
m_Pitch: 18cc243afd30f214bb836ca7698be735 | ||
m_Effects: | ||
- {fileID: 244419882805022256} | ||
m_UserColorIndex: 0 | ||
m_Mute: 0 | ||
m_Solo: 0 | ||
m_BypassEffects: 0 | ||
--- !u!244 &244373443531088772 | ||
AudioMixerEffectController: | ||
m_ObjectHideFlags: 3 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: | ||
m_EffectID: ecb49877185562e44936148d9fd39962 | ||
m_EffectName: Attenuation | ||
m_MixLevel: b92ea95f9be369b43a29ec95d0c682e2 | ||
m_Parameters: [] | ||
m_SendTarget: {fileID: 0} | ||
m_EnableWetMix: 0 | ||
m_Bypass: 0 | ||
--- !u!244 &244419882805022256 | ||
AudioMixerEffectController: | ||
m_ObjectHideFlags: 3 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_Name: | ||
m_EffectID: 5e443c88f838b1144872ebb4c03e53cc | ||
m_EffectName: Attenuation | ||
m_MixLevel: 8ec2a7a74e8ab3444b52ddc990af0003 | ||
m_Parameters: [] | ||
m_SendTarget: {fileID: 0} | ||
m_EnableWetMix: 0 | ||
m_Bypass: 0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Event; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Level | ||
{ | ||
public class BGMController : MonoBehaviour | ||
{ | ||
[SerializeField] private AudioSource source; | ||
|
||
private void Awake() | ||
{ | ||
if (source == null) { source = GetComponent<AudioSource>(); } | ||
EventManager.onStateChange.AddListener(OnStateChange, Priority.Lowest); | ||
} | ||
|
||
private StateChangeEventArgs OnStateChange(StateChangeEventArgs e) | ||
{ | ||
if (!e.canceled) | ||
{ | ||
if (e.newState == GameState.Playing) { source.Play(); } | ||
if (e.newState == GameState.WaitingRespawn) { source.Pause(); } | ||
} | ||
return e; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,38 +1,86 @@ | ||
using System; | ||
using Level; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
|
||
namespace Level.Event | ||
namespace Event | ||
{ | ||
public static class EventManager | ||
public enum Priority | ||
{ | ||
Highest, | ||
High, | ||
Normal, | ||
Low, | ||
Lowest | ||
} | ||
|
||
public class HandlerAttributes<T> | ||
{ | ||
public delegate void StateChange(ref StateChangeEvent arg); | ||
public delegate void GameOver(ref GameOverEvent arg); | ||
public static UnityEvent onStart = new UnityEvent(); | ||
public static UnityEvent onBGButtonClick = new UnityEvent(); | ||
public static StateChange OnStateChange; | ||
public static GameOver onGameOver; | ||
|
||
public static void RunStateChangeEvent(GameState oldState, GameState newState, UnityAction<StateChangeEvent> callback) | ||
public Func<T, T> action; | ||
public Priority priority; | ||
|
||
public HandlerAttributes(Func<T, T> action, Priority priority) | ||
{ | ||
StateChangeEvent arg = new StateChangeEvent(oldState, newState); | ||
try { | ||
IAsyncResult iar = OnStateChange.BeginInvoke(ref arg, ar => { callback.Invoke(arg); }, null); | ||
OnStateChange.EndInvoke(ref arg, iar); | ||
this.action = action; | ||
this.priority = priority; | ||
} | ||
} | ||
|
||
public class EventBase<T> | ||
{ | ||
private static LinkedList<HandlerAttributes<T>> handlers = new LinkedList<HandlerAttributes<T>>(); | ||
|
||
public void AddListener(Func<T, T> action, Priority priority) | ||
{ | ||
if (priority == Priority.Lowest) | ||
{ | ||
handlers.AddLast(new HandlerAttributes<T>(action, priority)); | ||
return; | ||
} | ||
foreach (HandlerAttributes<T> handler in handlers) | ||
{ | ||
if ((int)handler.priority < (int)priority) | ||
{ | ||
handlers.AddBefore(handlers.Find(handler), new HandlerAttributes<T>(action, priority)); | ||
break; | ||
} | ||
} | ||
catch (NullReferenceException) { callback.Invoke(arg); } | ||
} | ||
|
||
public static void RunGameOverEvent(DeathCause deathCause, UnityAction<GameOverEvent> callback) | ||
public void RemoveListener(Func<T, T> action) | ||
{ | ||
GameOverEvent arg = new GameOverEvent(deathCause); | ||
try { | ||
IAsyncResult iar = onGameOver.BeginInvoke(ref arg, ar => { callback.Invoke(arg); }, null); | ||
onGameOver.EndInvoke(ref arg, iar); | ||
foreach (HandlerAttributes<T> handler in handlers) | ||
{ | ||
if (action == handler.action) | ||
{ | ||
handlers.Remove(handlers.Find(handler)); | ||
break; | ||
} | ||
} | ||
catch (NullReferenceException) { callback.Invoke(arg); } | ||
} | ||
|
||
public void Invoke(T arg) | ||
{ | ||
foreach (HandlerAttributes<T> handler in handlers) | ||
{ | ||
arg = handler.action.Invoke(arg); | ||
} | ||
} | ||
} | ||
|
||
public static class EventManager | ||
{ | ||
public class StateChangeEvent: EventBase<StateChangeEventArgs> | ||
{ | ||
public void Invoke(GameState oldState, GameState newState) | ||
{ | ||
Invoke(new StateChangeEventArgs(oldState, newState)); | ||
} | ||
} | ||
|
||
|
||
public static StateChangeEvent onStateChange = new StateChangeEvent(); | ||
} | ||
} |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Level; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Event | ||
{ | ||
public class LineDieEventArgs | ||
{ | ||
public readonly Line line; | ||
public readonly DeathCause cause; | ||
public bool canceled = false; | ||
|
||
public LineDieEventArgs (Line line, DeathCause cause) | ||
{ | ||
this.line = line; | ||
this.cause = cause; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Level; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Event | ||
{ | ||
public class LineTurnEventArgs | ||
{ | ||
public readonly Line line; | ||
public readonly Vector3 lastway; | ||
public Vector3 newway; | ||
public bool foucs; | ||
public bool canceled = false; | ||
|
||
public LineTurnEventArgs(Line line, Vector3 lastway, Vector3 newway, bool foucs) | ||
{ | ||
this.line = line; | ||
this.lastway = lastway; | ||
this.newway = newway; | ||
this.foucs = foucs; | ||
} | ||
} | ||
} |
Oops, something went wrong.