Skip to content

Commit

Permalink
[code] First scripts for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
u-m-i committed Aug 25, 2023
1 parent 9ce6e79 commit 258ec51
Show file tree
Hide file tree
Showing 21 changed files with 191 additions and 281 deletions.
58 changes: 22 additions & 36 deletions Assets/Scenes/Abduction/Abduction.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4803,7 +4803,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 144531526}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -2.68, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
Expand Down Expand Up @@ -6607,7 +6607,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &187296716
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -16845,7 +16845,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 348527799}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 31.13538, y: -17.453907, z: -22.280586}
m_LocalPosition: {x: 33.037956, y: -19.758352, z: -20.92453}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
Expand Down Expand Up @@ -59124,21 +59124,17 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
stages:
- clip: {fileID: 8300000, guid: c5faceb05b0aa5148a3996af25ed32d1, type: 3}
transition:
serializedVersion: 2
- {clip: {fileID: 8300000, guid: c5faceb05b0aa5148a3996af25ed32d1, type: 3}, transition:
m_Curve:
- serializedVersion: 3
time: 0
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
- time: 1
value: 1
inSlope: 2
outSlope: 2
Expand All @@ -59149,21 +59145,18 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
- clip: {fileID: 8300000, guid: 0f76dfafe6ccd6947a5ed211ed29f40c, type: 3}
transition:
serializedVersion: 2
}
- {clip: {fileID: 8300000, guid: 0f76dfafe6ccd6947a5ed211ed29f40c, type: 3}, transition:
m_Curve:
- serializedVersion: 3
time: 0
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
- time: 1
value: 1
inSlope: 2
outSlope: 2
Expand All @@ -59174,21 +59167,18 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
- clip: {fileID: 8300000, guid: ddeeff2a24811924b96d0f93c0da4c58, type: 3}
transition:
serializedVersion: 2
}
- {clip: {fileID: 8300000, guid: ddeeff2a24811924b96d0f93c0da4c58, type: 3}, transition:
m_Curve:
- serializedVersion: 3
time: 0
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
- time: 1
value: 1
inSlope: 2
outSlope: 2
Expand All @@ -59199,21 +59189,18 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
- clip: {fileID: 8300000, guid: 671674c736bf0c74495c612200ba8826, type: 3}
transition:
serializedVersion: 2
}
- {clip: {fileID: 8300000, guid: 671674c736bf0c74495c612200ba8826, type: 3}, transition:
m_Curve:
- serializedVersion: 3
time: 0
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
- time: 1
value: 1
inSlope: 2
outSlope: 2
Expand All @@ -59224,14 +59211,13 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
currentStage:
clip: {fileID: 0}
transition:
serializedVersion: 2
}
currentStage: {clip: {fileID: 0}, transition:
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
}
--- !u!4 &1712739896
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -59936,7 +59922,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 29763bfeba1c80d4ea3c8745c46a9b23, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 1600006925}
stages: []
--- !u!4 &1734884801
Transform:
m_ObjectHideFlags: 0
Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions Assets/Scripts/Runtime/Audio/Fader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using UnityEngine;
using System.Collections;



using System;

namespace Abduction.Audio
{

///<summary>
/// Plays the music with transitions
///</summary>
public class Fader : MonoBehaviour
{

[Serializable]
public struct Stage
{
public AudioClip clip;

public AnimationCurve transitionIn;

public AnimationCurve transisionOut;
}

[SerializeField]
private Stage[] stages;



private AnimationCurve @in;

private AnimationCurve @out;



public void FadeBetween()
{
@in = stages[0].transitionIn;
@out = stages[1].transisionOut;
}


public void AnalizeLerp()
{

}

}
}
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Assets/Scripts/Runtime/StateMachine/MusicState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using UnityEngine;
using Abduction.Audio;

namespace Abduction.StateBehaviour
{

/// <summary>
/// Dictates the state for the music
/// </summary>
public class MusicState : State
{
[SerializeField]
private Fader fader;


public override void OnRun()
{
// Check alterations
}


public override void OnSwap()
{
Transition();
}


private void Transition()
{
// Use the fader to transition between stages
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Assets/Scripts/Runtime/StateMachine/State.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;


namespace Abduction.StateBehaviour
{
public abstract class State : MonoBehaviour
{
public abstract void OnRun();

public abstract void OnSwap();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Assets/Scripts/Runtime/StateMachine/StateMachine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using UnityEngine;


namespace Abduction.StateBehaviour
{

/// <summary>
/// Runs the state on a loop
/// </summary>
public class StateMachine : MonoBehaviour
{

private State _state;


private void Run()
{
_state.OnRun();

}


private void Swap()
{
_state.OnSwap();
}

public void SetChange(in State @state)
{
_state.OnSwap();

// Start running

_state = @state;

}


#if PHYSICS

private void FixedUpdate()
{
Run();
}

#endif

private void Update()
{
Run();
}

}




}
11 changes: 11 additions & 0 deletions Assets/Scripts/Runtime/StateMachine/StateMachine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Assets/Scripts/Runtime/Test/Abduction.meta

This file was deleted.

Loading

0 comments on commit 258ec51

Please sign in to comment.