Commit d94eeb54 authored by Chae Ho Shin's avatar Chae Ho Shin

WIP

parent 6e0695fb
......@@ -20,14 +20,27 @@ public class Clap : MotionNote
{
}
public override IEnumerator Checkpoint()
private bool isChecked = false;
public override bool IsChecked
{
get
{
return isChecked;
}
}
public override IEnumerator Checkpoint(MotionNote obj)
{
IsCoroutineExecuted = true;
var motion = InputManager.Instance.CurrentMotionState;
while ((motion & MotionState.CLAP_PREPARE) == 0)
{
yield return null;
}
IsChecked = true;
isChecked = true;
yield break;
}
......@@ -36,7 +49,7 @@ public class Clap : MotionNote
{
var motion = InputManager.Instance.CurrentMotionState;
if ((motion & MotionState.CLAP_DONE) != 0)
if (isChecked && (motion & MotionState.CLAP_DONE) != 0)
return true;
return false;
......
......@@ -7,15 +7,40 @@ public class Guard : MotionNote
enum Hand { Both, Left, Right }
Hand hand;
private static Sprite image = LoadNewSprite("");
private static Sprite imageB = LoadNewSprite("");
private static Sprite imageL = LoadNewSprite("");
private static Sprite imageR = LoadNewSprite("");
public override Sprite Image
{
get
{
return image;
switch (hand)
{
default:
case Hand.Both:
return imageB;
case Hand.Left:
return imageL;
case Hand.Right:
return imageR;
}
}
}
private bool isChecked = false;
public override bool IsChecked
{
get
{
return isChecked;
}
}
public Guard(string key, float timing) : this(key, timing, 0f)
{
}
public Guard(string key, float timing, float end = 0f) : this(timing, end)
{
switch (key)
......@@ -35,7 +60,7 @@ public class Guard : MotionNote
{
}
public override IEnumerator Checkpoint()
public override IEnumerator Checkpoint(MotionNote obj)
{
var motionState = InputManager.Instance.CurrentMotionState;
var motion = motionState;
......@@ -50,6 +75,6 @@ public class Guard : MotionNote
public override bool FinalJudgeAction()
{
throw new NotImplementedException();
return false;
}
}
......@@ -4,7 +4,7 @@ using UnityEngine;
public class Jump : MotionNote
{
private static Sprite image = new Sprite();
private static Sprite image = LoadNewSprite("Assets/MotionNotes/JP.png");
public override Sprite Image
{
get
......@@ -21,16 +21,25 @@ public class Jump : MotionNote
downCount = 0;
}
private float spineHeight;
private bool isChecked = false;
public override bool IsChecked
{
get
{
return isChecked;
}
}
private float spineHeight = 0f;
private int downCount;
public override IEnumerator Checkpoint()
public override IEnumerator Checkpoint(MotionNote obj)
{
float currentSpineHeight
= InputManager.Instance
.Joints[Windows.Kinect.JointType.SpineBase].Position.Y;
while (downCount < 10 && currentSpineHeight <= spineHeight - 0.1f)
while (spineHeight == 0f || downCount < 10 && currentSpineHeight <= spineHeight - 0.1f)
{
spineHeight = currentSpineHeight;
currentSpineHeight
......
using System;
using System.Collections;
using UnityEngine;
public class Piano : MotionNote
{
enum Hand { Both, Left, Right }
Hand hand;
private static Sprite image = LoadNewSprite("");
public override Sprite Image
{
get
{
return image;
}
}
public Piano(string key, float timing) : this(timing)
{
switch (key)
{
case "BI":
hand = Hand.Both;
break;
case "LI":
hand = Hand.Left;
break;
case "RI":
hand = Hand.Right;
break;
}
}
public Piano(float timing) : base(timing)
{
}
public override IEnumerator Checkpoint()
{
var motionState = InputManager.Instance.CurrentMotionState;
var motion = motionState;
while (motion != MotionState.CLAP_PREPARE)
yield return false;
Activated = true;
yield break;
}
public override bool FinalJudgeAction()
{
throw new NotImplementedException();
}
}
......@@ -35,7 +35,16 @@ public class PushUp : MotionNote
{
}
public override IEnumerator Checkpoint()
private bool isChecked = false;
public override bool IsChecked
{
get
{
return isChecked;
}
}
public override IEnumerator Checkpoint(MotionNote obj)
{
var motionState = InputManager.Instance.CurrentMotionState;
var motion = motionState;
......
......@@ -90,7 +90,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 0.627451}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
......@@ -117,7 +117,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
......@@ -144,7 +144,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
......
......@@ -66,7 +66,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1870857072681458}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 5.5, z: -1.6}
m_LocalPosition: {x: 0, y: 6.5, z: -3}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_Children:
- {fileID: 4514239179313720}
......
......@@ -1924,8 +1924,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 80}
m_SizeDelta: {x: 120, y: 120}
m_AnchoredPosition: {x: 0, y: 200}
m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1173591430
MonoBehaviour:
......
......@@ -1174,24 +1174,25 @@ MonoBehaviour:
m_GameObject: {fileID: 1243499222}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0.712}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1243499228
CanvasRenderer:
m_ObjectHideFlags: 0
......
......@@ -56,8 +56,9 @@ public class GameManager : MonoBehaviour {
{
}
public void SceneTransition(string sceneName)
public void SceneTransition(string sceneName, bool additive = false)
{
SceneManager.LoadScene("Scene/" + sceneName);
SceneManager.LoadScene("Scene/" + sceneName,
additive ? LoadSceneMode.Additive : LoadSceneMode.Single);
}
}
......@@ -17,7 +17,7 @@ public class Judge
private Judge()
{
ButtonTimingRange = 0f;
MotionTimingRange = ButtonTimingRange;
ButtonTimingRange = 0f;
Score = 0;
IsBreak = false;
Color = Color.black;
......@@ -28,20 +28,22 @@ public class Judge
public string Name { get; private set; }
public float ButtonTimingRange { get; private set; }
public float MotionTimingRange { get; private set; }
public int Score { get; private set; }
public bool IsBreak { get; private set; }
public Color Color { get; private set; }
public static readonly Judge MISS = JudgeList.Last();
private static readonly
public static readonly
float MaxButtonTimingRange = JudgeList[2].ButtonTimingRange;
public static Judge TestJudge(Note note, float elapsedTime, bool end = false)
public static Judge TestJudge(Note note, float elapsedTime, bool end = false, bool test = false)
{
float timing = end ? note.EndTiming : note.StartTiming;
float difference = Mathf.Abs(elapsedTime - timing);
if (test)
Debug.Log(elapsedTime - timing);
foreach (Judge judge in JudgeList)
{
if (difference < judge.ButtonTimingRange)
......
......@@ -54,6 +54,32 @@ public class JudgeManager : MonoBehaviour
}
}
private float elapsedMotion;
private float motionTimeout;
private void MotionGuageReset(float timeout = 0f)
{
if (timeout <= 0f)
{
elapsedMotion = 0f;
motionGuage.transform.parent.gameObject.SetActive(false);
return;
}
motionTimeout = timeout;
motionGuage.transform.parent.gameObject.SetActive(true);
motionGuage.SetActive(true);
}
private void MotionGuageUpdate()
{
if (motionGuage.transform.parent.gameObject.activeInHierarchy)
elapsedMotion += Time.deltaTime * 1000f;
if (elapsedMotion >= motionTimeout)
MotionGuageReset();
else
motionGuage.GetComponent<Image>().fillAmount = elapsedMotion / motionTimeout;
}
// Use this for initialization
void Start()
{
......@@ -68,22 +94,29 @@ public class JudgeManager : MonoBehaviour
initialPos = offset.transform.position;
judgeText.SetActive(false);
motionGuage.transform.parent.gameObject.SetActive(false);
MotionGuageReset();
activatedNotes = new List<MotionNote>();
LoadNotes(GameManager.Instance.CurrentTrack.Notes);
Instantiate(GameManager.Instance.CurrentTrack.BGM);
// Instantiate(GameManager.Instance.CurrentTrack.BGM);
}
// Update is called once per frame
void Update()
{
elapsedTime += Time.deltaTime * 1000;
float timing = elapsedTime + latency;
float timing = elapsedTime;
offset.transform.position = new Vector3(-timing * ScrollSpeed, 0, 0);
MotionGuageUpdate();
if (noteobj.transform.childCount <= 0
&& smobj.transform.childCount <= 0
&& lmobj.transform.childCount <= 0)
Invoke("ShowResult", 2f);
new Action(() =>
{
if (noteobj.transform.childCount <= 0)
......@@ -143,23 +176,39 @@ public class JudgeManager : MonoBehaviour
GameObject smo = smobj.transform.GetChild(0).gameObject;
MotionNote smnote = (MotionNote)smo.GetComponent<Note.Controller>().Instance;
if (!smnote.Activated && elapsedTime >= (smnote.StartTiming - MsPerBeat))
if (!smnote.IsCoroutineExecuted)
{
StartCoroutine(smnote.Checkpoint(smnote));
}
if (!smnote.Activated && timing >= (smnote.StartTiming - MsPerBeat))
{
GameObject motionSample = Instantiate(motionSampleDisplayPrefab);
MotionSampleDisplay msd = motionSample.GetComponent<MotionSampleDisplay>();
msd.sprite = smnote.Image;
msd.timeout = MsPerBeat*2;
msd.timeout = MsPerBeat;
smnote.Activated = true;
smnote.MotionSampleDisplay = msd;
activatedNotes.Add(smnote);
smnote.Component.transform.SetParent(offset.transform);
}
for(int i=activatedNotes.Count-1;i>=0;i--)
{
if((InputManager.Instance.CurrentMotionState & MotionState.CLAP_DONE) != 0)
{
foreach (MotionNote anote in activatedNotes)
{
Debug.Log(anote.IsChecked);
}
}
MotionNote note = activatedNotes[i];
if (note.FinalJudgeAction() || elapsedTime > note.EndTiming + Judge.MISS.MotionTimingRange)
if (note.FinalJudgeAction() || (timing > (note.EndTiming + Judge.MaxButtonTimingRange)))
{
SetJudge(Judge.TestJudge(note, timing, true));
Debug.Log(note.IsChecked);
SetJudge(Judge.TestJudge(note, timing, false, true), true);
activatedNotes.RemoveAt(i);
DeactivateNote(note);
}
......@@ -174,15 +223,33 @@ public class JudgeManager : MonoBehaviour
GameObject lmo = lmobj.transform.GetChild(0).gameObject;
MotionNote lmnote = (MotionNote)lmo.GetComponent<Note.Controller>().Instance;
lmnote.Checkpoint();
StartCoroutine(lmnote.Checkpoint(lmnote));
if (lmnote.Activated)
if (!lmnote.Activated && elapsedTime >= (lmnote.StartTiming - MsPerBeat))
{
SetJudge(Judge.TestJudge(lmnote, timing));
DeactivateNote(lmnote);
GameObject motionSample = Instantiate(motionSampleDisplayPrefab);
MotionSampleDisplay msd = motionSample.GetComponent<MotionSampleDisplay>();
msd.sprite = lmnote.Image;
msd.timeout = MsPerBeat;
lmnote.Activated = true;
lmnote.MotionSampleDisplay = msd;
activatedNotes.Add(lmnote);
}
return;
for (int i = activatedNotes.Count - 1; i >= 0; i--)
{
MotionNote note = activatedNotes[i];
if (elapsedTime > note.StartTiming)
MotionGuageReset(note.Length);
if (note.FinalJudgeAction() || elapsedTime > note.EndTiming + Judge.MaxButtonTimingRange)
{
SetJudge(Judge.TestJudge(note, timing, true));
activatedNotes.RemoveAt(i);
DeactivateNote(note);
MotionGuageReset();
}
}
})();
}
......@@ -202,9 +269,7 @@ public class JudgeManager : MonoBehaviour
GameManager.Instance.Score += judge.Score;
GameManager.Instance.JudgeCount[judge]++;
Debug.Log(judge.Name + (isMotion ? " Motion" : " Note"));
Debug.Log(GameManager.Instance.Combo);
Debug.Log(GameManager.Instance.LongestCombo);
Debug.Log(judge.Name + (isMotion ? " Motion" : " Note") + " Combo: " + GameManager.Instance.Combo);
judgeText.SetActive(true);
judgeText.GetComponent<Text>().text = judge.Name;
......@@ -248,4 +313,15 @@ public class JudgeManager : MonoBehaviour
obj.AddComponent<Note.Controller>().Instance = note;
}
}
private bool onResult = false;
private void ShowResult()
{
if (!onResult)
{
GameManager.Instance.SceneTransition("Result", true);
onResult = true;
}
}
}
......@@ -13,10 +13,12 @@ public abstract class MotionNote : Note
public MotionNote(string key, float start, float end = 0f)
: this(start, end) { }
public abstract IEnumerator Checkpoint();
public abstract IEnumerator Checkpoint(MotionNote obj);
public abstract bool FinalJudgeAction();
public bool IsChecked { get; protected set; }
public abstract bool IsChecked { get; }
public bool IsCoroutineExecuted { get; protected set; }
public MotionSampleDisplay MotionSampleDisplay { get; set; }
......@@ -35,9 +37,9 @@ public abstract class MotionNote : Note
{ "LK", typeof(PushUp) },
{ "RK", typeof(PushUp) },
{ "BI", typeof(Piano) },
{ "LI", typeof(Piano) },
{ "RI", typeof(Piano) },
{ "BI", typeof(Guard) },
{ "LI", typeof(Guard) },
{ "RI", typeof(Guard) },
{ "BG", typeof(Guard) },
{ "LG", typeof(Guard) },
......
......@@ -15,7 +15,7 @@ public class MotionSampleDisplay : MonoBehaviour
private float velocity;
private float acceleration;
private float distance = 3f;
private float distance = 1.5f;
// Use this for initialization
void Start()
......
......@@ -62,6 +62,9 @@ public class TrackManager : MonoBehaviour {
// Update is called once per frame
void Update()
{
if (trackList.transform.childCount < 0)
return;
if (Input.GetKeyDown(KeyCode.DownArrow))
{
trackList.transform.GetChild(0).SetAsLastSibling();
......
#TITLE Jump Jump Revolution
#ARTIST 128
#GENRE None
#BPM 128
#PLAYLEVEL 0
#TRACKLIST Something - Someone
#TRACKLIST Probably - Amumal
#TRACKLIST PARANOiA - Revolution
#002SMO JPJPJPJP
#003SMO JPJPJPJP
fileFormatVersion: 2
guid: e943dcff2ea00af40acbfc09b7345f25
timeCreated: 1503548782
guid: a0ed6224ca6bb234085d194a31e2a3c1
timeCreated: 1503617877
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 16201f7e6e6532143b745bb09761c13b
timeCreated: 1503611397
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment