Commit 79d8170b authored by 16이상민's avatar 16이상민

Working..

parent 7473ef61
fileFormatVersion: 2
guid: b8f0efef942ecaa4caff7cc221a81b9a
folderAsset: yes
timeCreated: 1518174436
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.UI;
namespace JudgeModule
{
class MotionGageManager
{
public GameObject motionGuage;
private float elapsedMotion;
private float motionTimeout;
private float elapsedTime = 0;
public void ResetGuage(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);
}
public void UpdateGuage()
{
if (motionGuage.transform.parent.gameObject.activeInHierarchy)
UpdateTime();
if (elapsedMotion >= motionTimeout)
ResetGuage();
else
motionGuage.GetComponent<Image>().fillAmount = elapsedMotion / motionTimeout;
}
public float UpdateTime()
{
elapsedTime += (Time.deltaTime * 1000);
return elapsedTime;
}
}
}
fileFormatVersion: 2
guid: e8c5bce833e52b54c87644b6993c484c
timeCreated: 1518174436
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using StatusConvert;
using System.Collections.Generic;
namespace JudgeModule
{
public class NoteCondition
{
private InputManager manager;
public NoteCondition(InputManager inputManager)
{
manager = inputManager;
}
public Dictionary<string, InputStatus> WrongInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortMotionStat },
{ "long", manager.LongMotionStat }
};
}
public Dictionary<string, InputStatus> JudgeInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
{
{ "short", manager.MotionToInput((note as MotionNote).MotionName, "short") },
{ "long", manager.MotionToInput((note as MotionNote).MotionName, "long") }
};
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
}
public bool IsShortNoteEntered(Note note)
{
return JudgeInput(note)["short"] == InputStatus.Entered;
}
public bool IsLongNoteStartCorrectly(Note note)
{
return JudgeInput(note)["long"] == InputStatus.Entered &&
!note.Activated;
}
public bool IsLongNoteHoldCorrectly(Note note)
{
var stat = JudgeInput(note);
return (
stat["long"] == InputStatus.Entered ||
stat["long"] == InputStatus.Continuing
) &&
note.Activated;
}
public bool IsLongNoteFinishCorrectly(Note note, float timing)
{
return JudgeInput(note)["long"] == InputStatus.Stopped &&
note.Activated &&
Judge.IsNoteEnd(note, timing);
}
public bool IsLongNoteFinishIncorrectly(Note note, float timing)
{
var stat = JudgeInput(note);
return stat["long"] == InputStatus.Stopped &&
(
!note.Activated ||
!Judge.IsNoteEnd(note, timing)
);
}
public bool IsWrongInput(Note note)
{
var stat = WrongInput(note);
return stat["short"] == InputStatus.Entered ||
stat["long"] == InputStatus.Entered ||
stat["long"] == InputStatus.Continuing;
}
public bool IsNoteBroken(Note note, float timing, Judge judge)
{
return note.IsLong &&
!Judge.IsNoteEnd(note, timing) &&
(judge == Judge.BAD || judge == Judge.MISS);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 7a1cd9d6ab06da646b5a4d1ad104a036
timeCreated: 1518174436
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using UnityEngine; using UnityEngine;
public class Clap : MotionNote public class Clap : MotionNote
......
using System;
using System.Collections;
using UnityEngine; using UnityEngine;
public class Guard : MotionNote public class Guard : MotionNote
......
using System; using UnityEngine;
using System.Collections;
using UnityEngine;
public class HandDown : MotionNote public class HandDown : MotionNote
{ {
......
using System; using UnityEngine;
using System.Collections;
using UnityEngine;
public class HandUp : MotionNote public class HandUp : MotionNote
{ {
......
using System; using UnityEngine;
using System.Collections;
using UnityEngine;
public class Headphone : MotionNote public class Headphone : MotionNote
{ {
......
using System; using UnityEngine;
using System.Collections;
using UnityEngine;
public class Jesus : MotionNote public class Jesus : MotionNote
{ {
......
using System;
using System.Collections;
using UnityEngine; using UnityEngine;
public class Jump : MotionNote public class Jump : MotionNote
......
using System; using UnityEngine;
using System.Collections;
using UnityEngine;
public class OnTheTable : MotionNote public class OnTheTable : MotionNote
{ {
......
using System;
using System.Collections;
using UnityEngine; using UnityEngine;
public class PushUp : MotionNote public class PushUp : MotionNote
......
...@@ -57,6 +57,12 @@ public class Judge ...@@ -57,6 +57,12 @@ public class Judge
return elapsedTime - timing > BadTime; return elapsedTime - timing > BadTime;
} }
public static bool IsNoteStart(Note note, float elapsedTime)
{
return note is MotionNote &&
!note.Activated;
}
public static bool IsNoteEnd(Note note, float elapsedTime) public static bool IsNoteEnd(Note note, float elapsedTime)
{ {
return elapsedTime - note.EndTiming <= BadTime; return elapsedTime - note.EndTiming <= BadTime;
......
using StatusConvert; using JudgeModule;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
...@@ -41,6 +41,7 @@ public class JudgeManager : MonoBehaviour ...@@ -41,6 +41,7 @@ public class JudgeManager : MonoBehaviour
private InputManager input; private InputManager input;
private NoteCondition condition; private NoteCondition condition;
private List<Note> notes;
void SetObjectRef() void SetObjectRef()
{ {
...@@ -66,9 +67,9 @@ public class JudgeManager : MonoBehaviour ...@@ -66,9 +67,9 @@ public class JudgeManager : MonoBehaviour
void LoadGameObjects() void LoadGameObjects()
{ {
motionSampleDisplayPrefab = Resources.Load("Motion Sample Display") as GameObject; motionSampleDisplayPrefab = Resources.Load("Motion Sample Display") as GameObject;
GameManager.Instance.CurrentTrack.Notes.ForEach(LoadNote); notes = GameManager.Instance.CurrentTrack.Notes.ToList();
//if (GameManager.Instance.defaultSound != null) notes.ForEach(LoadNote);
// Instantiate(GameManager.Instance.defaultSound);
var sounds = GameObject.Find("Sounds"); var sounds = GameObject.Find("Sounds");
sounds.transform.Cast<Transform>() sounds.transform.Cast<Transform>()
.ToList() .ToList()
...@@ -115,6 +116,15 @@ public class JudgeManager : MonoBehaviour ...@@ -115,6 +116,15 @@ public class JudgeManager : MonoBehaviour
if (note == null) if (note == null)
return; return;
if (condition.IsWrongInput(note))
{
WrongNoteProc(note);
return;
}
if (Judge.IsNoteStart(note, timing))
PlaySampleMotion(note as MotionNote);
if (note.IsLong) if (note.IsLong)
JudgeLongNote(note, timing); JudgeLongNote(note, timing);
else else
...@@ -136,25 +146,31 @@ public class JudgeManager : MonoBehaviour ...@@ -136,25 +146,31 @@ public class JudgeManager : MonoBehaviour
return null; return null;
} }
void PlaySampleMotion(MotionNote note)
{
GameObject motionSample = Instantiate(motionSampleDisplayPrefab);
MotionSampleDisplay msd = motionSample.GetComponent<MotionSampleDisplay>();
msd.sprite = note.Image;
msd.timeout = MsPerBeat;
note.Activated = true;
note.MotionSampleDisplay = msd;
}
void JudgeShortNote(Note note, float timing) void JudgeShortNote(Note note, float timing)
{ {
if (condition.IsWrongInput(note)) if (condition.IsShortNoteEntered(note))
WrongNoteProc(note);
else if (condition.IsShortNoteEntered(note))
EnteredNoteProc(note, timing); EnteredNoteProc(note, timing);
} }
void JudgeLongNote(Note note, float timing) void JudgeLongNote(Note note, float timing)
{ {
if (condition.IsWrongInput(note)) if (condition.IsLongNoteStartCorrectly(note))
WrongNoteProc(note);
else if (condition.IsLongNoteStartCorrectly(note))
EnteredNoteProc(note, timing); EnteredNoteProc(note, timing);
else if (condition.IsLongNoteHoldCorrectly(note)) if (condition.IsLongNoteHoldCorrectly(note))
ContinuingNoteProc(note, timing); ContinuingNoteProc(note, timing);
else if (condition.IsLongNoteFinishCorrectly(note, timing)) if (condition.IsLongNoteFinishCorrectly(note, timing))
CorrectlyStoppedNoteProc(note, timing); CorrectlyStoppedNoteProc(note, timing);
else if (condition.IsLongNoteFinishIncorrectly(note, timing)) if (condition.IsLongNoteFinishIncorrectly(note, timing))
IncorrectlyStoppedNoteProc(note, timing); IncorrectlyStoppedNoteProc(note, timing);
} }
...@@ -174,7 +190,9 @@ public class JudgeManager : MonoBehaviour ...@@ -174,7 +190,9 @@ public class JudgeManager : MonoBehaviour
{ {
SetJudge(Judge.TestJudge(note, timing)); SetJudge(Judge.TestJudge(note, timing));
if (!note.IsLong) if (note.IsLong)
note.Activated = true;
else
DeactivateNote(note); DeactivateNote(note);
} }
...@@ -274,135 +292,4 @@ public class JudgeManager : MonoBehaviour ...@@ -274,135 +292,4 @@ public class JudgeManager : MonoBehaviour
onResult = true; onResult = true;
} }
} }
private class NoteCondition
{
private InputManager manager;
public NoteCondition(InputManager inputManager)
{
manager = inputManager;
}
public Dictionary<string, InputStatus> WrongInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortMotionStat },
{ "long", manager.LongMotionStat }
};
}
public Dictionary<string, InputStatus> JudgeInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
{
{ "short", manager.MotionToInput((note as MotionNote).MotionName, "short") },
{ "long", manager.MotionToInput((note as MotionNote).MotionName, "long") }
};
return new Dictionary<string, InputStatus>
{
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
}
public bool IsShortNoteEntered(Note note)
{
return JudgeInput(note)["short"] == InputStatus.Entered;
}
public bool IsLongNoteStartCorrectly(Note note)
{
return JudgeInput(note)["long"] == InputStatus.Entered &&
!note.Activated;
}
public bool IsLongNoteHoldCorrectly(Note note)
{
var stat = JudgeInput(note);
return (
stat["long"] == InputStatus.Entered ||
stat["long"] == InputStatus.Continuing
) &&
note.Activated;
}
public bool IsLongNoteFinishCorrectly(Note note, float timing)
{
return JudgeInput(note)["long"] == InputStatus.Stopped &&
note.Activated &&
Judge.IsNoteEnd(note, timing);
}
public bool IsLongNoteFinishIncorrectly(Note note, float timing)
{
var stat = JudgeInput(note);
return stat["long"] == InputStatus.Stopped &&
(
!note.Activated ||
!Judge.IsNoteEnd(note, timing)
);
}
public bool IsWrongInput(Note note)
{
var stat = WrongInput(note);
return stat["short"] == InputStatus.Entered ||
stat["long"] == InputStatus.Entered ||
stat["long"] == InputStatus.Continuing;
}
public bool IsNoteBroken(Note note, float timing, Judge judge)
{
return note.IsLong &&
!Judge.IsNoteEnd(note, timing) &&
(judge == Judge.BAD || judge == Judge.MISS);
}
}
} }
class MotionGageManager
{
public GameObject motionGuage;
private float elapsedMotion;
private float motionTimeout;
private float elapsedTime = 0;
public void ResetGuage(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);
}
public void UpdateGuage()
{
if (motionGuage.transform.parent.gameObject.activeInHierarchy)
UpdateTime();
if (elapsedMotion >= motionTimeout)
ResetGuage();
else
motionGuage.GetComponent<Image>().fillAmount = elapsedMotion / motionTimeout;
}
public float UpdateTime()
{
elapsedTime += (Time.deltaTime * 1000);
return elapsedTime;
}
}
\ No newline at end of file
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
override protected override protected
bool bool
NotValidType( NotValidType(
string type) string type,
string code)
{ {
return type.Substring(1) != "BT"; return type.Substring(1) != "BT";
} }
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
string type, string type,
float timing) float timing)
{ {
return new Note(code, type, timing); return new Note(code, type, timing, 0);
} }
override protected override protected
......
...@@ -7,11 +7,11 @@ namespace TrackAnalysis ...@@ -7,11 +7,11 @@ namespace TrackAnalysis
override protected override protected
bool bool
NotValidType( NotValidType(
string type) string type,
string code)
{ {
Type motionType;
return type.Substring(1) != "MO" || return type.Substring(1) != "MO" ||
!MotionNote.keymap.TryGetValue(type, out motionType); !MotionNote.keymap.ContainsKey(code);
} }
override protected override protected
...@@ -22,7 +22,7 @@ namespace TrackAnalysis ...@@ -22,7 +22,7 @@ namespace TrackAnalysis
float timing) float timing)
{ {
return (MotionNote)Activator.CreateInstance return (MotionNote)Activator.CreateInstance
(MotionNote.keymap[type], code, timing); (MotionNote.keymap[code], code, timing, 0);
} }
override protected override protected
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
string type, string type,
float timing) float timing)
{ {
if (NotValidType(type)) if (NotValidType(type, code))
return null; return null;
if (IsShort(type)) if (IsShort(type))
return MakeShort(code, type, timing); return MakeShort(code, type, timing);
...@@ -50,7 +50,8 @@ ...@@ -50,7 +50,8 @@
abstract protected abstract protected
bool bool
NotValidType( NotValidType(
string type); string type,
string code);
abstract protected abstract protected
Note Note
MakeShort( MakeShort(
......
...@@ -59,9 +59,16 @@ namespace TrackAnalysis ...@@ -59,9 +59,16 @@ namespace TrackAnalysis
Func<int, float> calcTiming, Func<int, float> calcTiming,
Func<string, float, Note> concreteNote) Func<string, float, Note> concreteNote)
{ {
return DiscreteRange(range, x => currentCode(x)) var disrange = DiscreteRange(range, x => currentCode(x));
var disRange = disrange.ToList();
var notes = disrange
.Select(x => concreteNote(currentCode(x), calcTiming(x)));
var Notes = notes.ToList();
return notes.Where(x => x != null);
/*return disrange
.Select(x => concreteNote(currentCode(x), calcTiming(x))) .Select(x => concreteNote(currentCode(x), calcTiming(x)))
.Where(x => x != null); .Where(x => x != null);*/
} }
private static private static
...@@ -70,7 +77,7 @@ namespace TrackAnalysis ...@@ -70,7 +77,7 @@ namespace TrackAnalysis
IEnumerable<int> range, IEnumerable<int> range,
Func<int, string> currentCode) Func<int, string> currentCode)
{ {
return range.Where(x => currentCode(x).Equals("00")); return range.Where(x => !currentCode(x).Equals("00"));
} }
} }
} }
\ No newline at end of file
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