Commit ed3a1d8e authored by 16이상민's avatar 16이상민

Fix malfunctions

parent 2e76df20
......@@ -37,4 +37,4 @@ Material:
m_Floats:
- _Cutoff: 0
m_Colors:
- _Color: {r: 0, g: 1, b: 0, a: 0}
- _Color: {r: 0, g: 1, b: 0, a: 1}
This diff is collapsed.
......@@ -77,15 +77,18 @@ LightmapSettings:
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
......@@ -107,6 +110,8 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &135533173
GameObject:
......@@ -484,7 +489,6 @@ GameObject:
m_Component:
- component: {fileID: 609057691}
- component: {fileID: 609057690}
- component: {fileID: 609057692}
- component: {fileID: 609057689}
m_Layer: 0
m_Name: Managers
......@@ -526,6 +530,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a9d22e7eb4921ca47b18c68e43c0eb6e, type: 3}
m_Name:
m_EditorClassIdentifier:
defaultSound: {fileID: 0}
--- !u!4 &609057691
Transform:
m_ObjectHideFlags: 0
......@@ -539,17 +544,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &609057692
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 609057688}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6e697643158480b4ba850d906eac1bc2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &634338382
GameObject:
m_ObjectHideFlags: 0
......@@ -598,20 +592,6 @@ Light:
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_FalloffTable:
m_Table[0]: 0
m_Table[1]: 0
m_Table[2]: 0
m_Table[3]: 0
m_Table[4]: 0
m_Table[5]: 0
m_Table[6]: 0
m_Table[7]: 0
m_Table[8]: 0
m_Table[9]: 0
m_Table[10]: 0
m_Table[11]: 0
m_Table[12]: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
......@@ -830,11 +810,11 @@ Camera:
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &1050043563
Transform:
m_ObjectHideFlags: 0
......
This diff is collapsed.
fileFormatVersion: 2
guid: bd1125abc59508941a9858dc3f08c1b7
timeCreated: 1516864014
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -131,14 +131,14 @@ namespace KinectModule
public class SourceBuffer
{
private byte[] _ColorBuffer = new byte[KinectConstants.ColorWidth *
KinectConstants.ColorHeight *
KinectConstants.ColorCount],
_BodyIndexBuffer = new byte[KinectConstants.DepthWidth *
KinectConstants.DepthHeight];
private ushort[] _DepthBuffer = new ushort[KinectConstants.DepthWidth *
KinectConstants.DepthHeight];
private IBody[] _BodyBuffer = new IBody[KinectConstants.BodyCount];
private byte[] _ColorBuffer = new byte [KinectConstants.ColorWidth *
KinectConstants.ColorHeight *
KinectConstants.ColorCount],
_BodyIndexBuffer = new byte [KinectConstants.DepthWidth *
KinectConstants.DepthHeight];
private ushort[] _DepthBuffer = new ushort[KinectConstants.DepthWidth *
KinectConstants.DepthHeight];
private IBody[] _BodyBuffer = new IBody [KinectConstants.BodyCount];
public byte[] ColorBuffer
{ get { return _ColorBuffer; } }
......
......@@ -4,6 +4,8 @@ using Windows.Kinect;
public class CoordinateMapperView : MonoBehaviour
{
private GameObject manager;
private ComputeBuffer DepthBuffer,
BodyIndexBuffer;
......@@ -12,13 +14,12 @@ public class CoordinateMapperView : MonoBehaviour
void Start ()
{
var CoordinateMapperManager = GameObject.Find("Managers").GetComponent<CoordinateMapperManager>();
CoordinateMapperManager.enabled = true;
var CoordinateMapperManager = GameObject.Find("InGameManagers").GetComponent<CoordinateMapperManager>();
var material = GetComponent<Renderer>().material;
material.SetTexture("_MainTex", CoordinateMapperManager.ColorTexture);
DepthBuffer = GenerateBuffer("depthCoordinates", sizeof(float) * 2,
(DepthPoints = CoordinateMapperManager.DepthCoordinates), material);
BodyIndexBuffer = GenerateBuffer("BodyIndexBuffer", sizeof(float),
......@@ -34,6 +35,8 @@ public class CoordinateMapperView : MonoBehaviour
void Update()
{
//TODO: fix perf on this call.
DepthBuffer.SetData(DepthPoints);
......
......@@ -25,7 +25,7 @@ public class GameManager : MonoBehaviour {
}
[SerializeField]
public AudioSource defaultSound;
public string defaultSound;
public TrackInfo CurrentTrack { get; set; }
......
using System;
using UnityEngine;
public class InputManager : MonoBehaviour {
private static InputManager instance;
public static InputManager Instance
{
get
{
if (instance == null)
{
instance = FindObjectOfType(typeof(InputManager))
as InputManager;
}
return instance;
}
}
public class InputManager : MonoBehaviour
{
private bool IsButtonDownPrev { get; set; }
private bool IsButtonDown
{
get { return Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.Joystick1Button0); }
}
{ get { return Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.Joystick1Button0); } }
private MotionState PrevMotionState { get; set; }
public MotionState CurrentMotionState { get; set; }
public ButtonStatus ButtonStat
{
get
{
if (!IsButtonDown)
return ButtonStatus.Released;
if (IsButtonDownPrev)
return ButtonStatus.Holding;
return ButtonStatus.Pressed;
}
}
public InputStatus ShortButtonStat
{
get
......@@ -118,8 +89,7 @@ public class InputManager : MonoBehaviour {
}
}
// Update is called once per frame
void Update()
private void Update()
{
IsButtonDownPrev = IsButtonDown;
PrevMotionState = CurrentMotionState;
......@@ -129,7 +99,7 @@ public class InputManager : MonoBehaviour {
{
if (name.Contains("Both"))
{
var tmpname = name.Substring(name.IndexOf("Both"));
var tmpname = name.Substring(0, name.IndexOf("Both"));
var left = LongMotionToInput(tmpname + "Left");
var right = LongMotionToInput(tmpname + "Right");
......@@ -161,7 +131,7 @@ public class InputManager : MonoBehaviour {
{
if (name.Contains("Both"))
{
var tmpname = name.Substring(name.IndexOf("Both"));
var tmpname = name.Substring(0, name.IndexOf("Both"));
var left = ShortMotionToInput(tmpname + "Left");
var right = ShortMotionToInput(tmpname + "Right");
......@@ -402,4 +372,14 @@ public enum InputStatus
Continuing,
Stopped,
None
}
\ No newline at end of file
}
internal interface IButtonDownGetter
{
bool IsButtonDown
{ get; }
}
internal class ButtonDownGetter
{
}
......@@ -7,29 +7,16 @@ using UnityEngine.UI;
public class JudgeManager : MonoBehaviour
{
private static JudgeManager instance;
public static JudgeManager Instance
{
get
{
if (instance == null)
{
instance = FindObjectOfType(typeof(JudgeManager))
as JudgeManager;
}
return instance;
}
}
float latency = 225f;
float scrollMultiplier = 1.0f;
float startOffset = -5f;
float baseTime;
bool IsInitTime;
bool IsGameEnd;
private GameObject offset;
private GameObject noteobj, smobj, lmobj;
private GameObject noteobj;
private MotionGageManager motionGageManager;
private GameObject judgeText;
......@@ -53,13 +40,16 @@ public class JudgeManager : MonoBehaviour
}
}
private InputManager input;
private NoteCondition condition;
void SetObjectRef()
{
offset = GameObject.Find("Offset");
noteobj = GameObject.Find("Noteobj");
smobj = GameObject.Find("SMobj");
lmobj = GameObject.Find("LMobj");
judgeText = GameObject.Find("Judge");
input = GameObject.Find("InGameManagers").GetComponent<InputManager>();
condition = new NoteCondition(input);
motionGageManager = new MotionGageManager
{ motionGuage = GameObject.Find("Motion Guage") };
}
......@@ -70,13 +60,23 @@ public class JudgeManager : MonoBehaviour
judgeText.SetActive(false);
motionGageManager.ResetGuage();
IsGameEnd = false;
baseTime = 0f;
IsInitTime = false;
}
void LoadGameObjects()
{
motionSampleDisplayPrefab = Resources.Load("Motion Sample Display") as GameObject;
GameManager.Instance.CurrentTrack.Notes.ForEach(LoadNote);
Instantiate(GameManager.Instance.defaultSound);
//if (GameManager.Instance.defaultSound != null)
// Instantiate(GameManager.Instance.defaultSound);
var sounds = GameObject.Find("Sounds");
sounds.transform.Cast<Transform>()
.ToList()
.ForEach(x => x.gameObject.SetActive(false));
if (GameManager.Instance.CurrentTrack.BGM != null)
sounds.transform.Find(GameManager.Instance.CurrentTrack.BGM)
.gameObject.SetActive(true);
}
// Use this for initialization
......@@ -90,9 +90,16 @@ public class JudgeManager : MonoBehaviour
// Update is called once per frame
void Update()
{
float timing = motionGageManager.UpdateTime(); ;
float current = motionGageManager.UpdateTime();
if (!IsInitTime)
{
baseTime = current;
IsInitTime = true;
}
float timing = current - baseTime;
offset.transform.position = Vector3.left * timing * ScrollSpeed;
offset.transform.position = Vector3.left * current * ScrollSpeed;
motionGageManager.UpdateGuage();
......@@ -132,23 +139,23 @@ public class JudgeManager : MonoBehaviour
void JudgeShortNote(Note note, float timing)
{
if (NoteCondition.IsWrongInput(note))
if (condition.IsWrongInput(note))
WrongNoteProc(note);
else if (NoteCondition.IsShortNoteEntered(note))
else if (condition.IsShortNoteEntered(note))
EnteredNoteProc(note, timing);
}
void JudgeLongNote(Note note, float timing)
{
if (NoteCondition.IsWrongInput(note))
if (condition.IsWrongInput(note))
WrongNoteProc(note);
else if (NoteCondition.IsLongNoteStartCorrectly(note))
else if (condition.IsLongNoteStartCorrectly(note))
EnteredNoteProc(note, timing);
else if (NoteCondition.IsLongNoteHoldCorrectly(note))
else if (condition.IsLongNoteHoldCorrectly(note))
ContinuingNoteProc(note, timing);
else if (NoteCondition.IsLongNoteFinishCorrectly(note, timing))
else if (condition.IsLongNoteFinishCorrectly(note, timing))
CorrectlyStoppedNoteProc(note, timing);
else if (NoteCondition.IsLongNoteFinishIncorrectly(note, timing))
else if (condition.IsLongNoteFinishIncorrectly(note, timing))
IncorrectlyStoppedNoteProc(note, timing);
}
......@@ -179,7 +186,7 @@ public class JudgeManager : MonoBehaviour
SetJudge(judge);
if (isNoteEnd ||
NoteCondition.IsNoteBroken(note, timing, judge))
condition.IsNoteBroken(note, timing, judge))
DeactivateNote(note);
}
......@@ -259,55 +266,66 @@ public class JudgeManager : MonoBehaviour
{
if (!onResult)
{
GameManager.Instance.SceneTransition("Result", true);
Destroy(GetComponent<InputManager>());
Destroy(GetComponent<MotionView>());
Destroy(GetComponent<CoordinateMapperManager>());
Destroy(this);
GameManager.Instance.SceneTransition("Result");
onResult = true;
}
}
private class NoteCondition
{
public static Dictionary<string, InputStatus> WrongInput(Note note)
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", InputManager.Instance.ShortMotionStat },
{ "long", InputManager.Instance.LongMotionStat }
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
return new Dictionary<string, InputStatus>
{
{ "short", InputManager.Instance.ShortButtonStat },
{ "long", InputManager.Instance.LongButtonStat }
{ "short", manager.ShortMotionStat },
{ "long", manager.LongMotionStat }
};
}
public static Dictionary<string, InputStatus> JudgeInput(Note note)
public Dictionary<string, InputStatus> JudgeInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
{
{ "short", InputManager.Instance.ShortMotionToInput((note as MotionNote).MotionName) },
{ "long", InputManager.Instance.LongMotionToInput((note as MotionNote).MotionName) }
{ "short", manager.ShortMotionToInput((note as MotionNote).MotionName) },
{ "long", manager.LongMotionToInput((note as MotionNote).MotionName) }
};
return new Dictionary<string, InputStatus>
{
{ "short", InputManager.Instance.ShortButtonStat },
{ "long", InputManager.Instance.LongButtonStat }
{ "short", manager.ShortButtonStat },
{ "long", manager.LongButtonStat }
};
}
public static bool IsShortNoteEntered(Note note)
public bool IsShortNoteEntered(Note note)
{
return JudgeInput(note)["short"] == InputStatus.Entered;
}
public static bool IsLongNoteStartCorrectly(Note note)
public bool IsLongNoteStartCorrectly(Note note)
{
return JudgeInput(note)["long"] == InputStatus.Entered &&
!note.Activated;
}
public static bool IsLongNoteHoldCorrectly(Note note)
public bool IsLongNoteHoldCorrectly(Note note)
{
var stat = JudgeInput(note);
return (
......@@ -317,14 +335,14 @@ public class JudgeManager : MonoBehaviour
note.Activated;
}
public static bool IsLongNoteFinishCorrectly(Note note, float timing)
public bool IsLongNoteFinishCorrectly(Note note, float timing)
{
return JudgeInput(note)["long"] == InputStatus.Stopped &&
note.Activated &&
Judge.IsNoteEnd(note, timing);
}
public static bool IsLongNoteFinishIncorrectly(Note note, float timing)
public bool IsLongNoteFinishIncorrectly(Note note, float timing)
{
var stat = JudgeInput(note);
return stat["long"] == InputStatus.Stopped &&
......@@ -334,7 +352,7 @@ public class JudgeManager : MonoBehaviour
);
}
public static bool IsWrongInput(Note note)
public bool IsWrongInput(Note note)
{
var stat = WrongInput(note);
return stat["short"] == InputStatus.Entered ||
......@@ -342,7 +360,7 @@ public class JudgeManager : MonoBehaviour
stat["long"] == InputStatus.Continuing;
}
public static bool IsNoteBroken(Note note, float timing, Judge judge)
public bool IsNoteBroken(Note note, float timing, Judge judge)
{
return note.IsLong &&
!Judge.IsNoteEnd(note, timing) &&
......@@ -384,7 +402,7 @@ class MotionGageManager
public float UpdateTime()
{
elapsedTime += Time.deltaTime * 1000;
elapsedTime += (Time.deltaTime * 1000);
return elapsedTime;
}
......
......@@ -6,22 +6,40 @@ using System.Linq;
public class MotionView : MonoBehaviour
{
CoordinateMapperManager manager;
InputManager input;
IEnumerable<KinectModule.IBody> body;
MotionDiscriminator discriminator = new MotionDiscriminator();
bool IsInit;
// Use this for initialization
void Start ()
{
body = GameObject.Find("Managers").GetComponent<CoordinateMapperManager>().BodyBuffer;
IsInit = false;
discriminator.Preset(body.ToList()[0]);
var ingameManager = GameObject.Find("InGameManagers");
manager = ingameManager.GetComponent<CoordinateMapperManager>();
input = ingameManager.GetComponent<InputManager>();
}
// Update is called once per frame
void Update ()
{
InputManager.Instance.CurrentMotionState = DetermineState();
}
if (IsInit)
{
input.CurrentMotionState = DetermineState();
return;
}
body = manager.BodyBuffer;
var tmp = body.ToList()[0];
if (tmp != null)
{
discriminator.Preset(body.ToList()[0]);
IsInit = true;
}
}
MotionState DetermineState()
{
......
......@@ -9,33 +9,6 @@ using System;
// TODO: Change IMGUI to uGUI
public class CoordinateMapperManagerTests
{
// A UnityTest behaves like a coroutine in PlayMode
// and allows you to yield null to skip a frame in EditMode
[UnityTest]
public IEnumerator EmptyTest() {
// Use the Assert class to test conditions.
// yield to skip a frame
yield return null;
}
[UnityTest]
public IEnumerator NullFrame_GUI_Show_When_Kinect_Disconnected()
{
yield return null;
}
[UnityTest]
public IEnumerator FPS_GUI_Show_When_Kinect_Disconnected()
{
yield return null;
}
[UnityTest]
public IEnumerator FPS_GUI_Show_When_Kinect_Connected()
{
yield return null;
}
[UnityTest]
public IEnumerator ColorTexture_Not_Equal_Null_When_Kinect_Disconnected()
{
......
......@@ -41,7 +41,7 @@ class CoordinateMapperViewTests
CoordinateMapperManager CreateManager()
{
var manager = new GameObject("Managers");
var manager = new GameObject("InGameManagers");
return manager.AddComponent<CoordinateMapperManager>();
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
// keyboard event => next frame => ButtonStat
class InputManagerTests
{
// A UnityTest behaves like a coroutine in PlayMode
// and allows you to yield null to skip a frame in EditMode
[UnityTest]
public IEnumerator EmptyTest()
{
// Use the Assert class to test conditions.
// yield to skip a frame
yield return null;
yield return null;
yield return null;
}
[UnityTest]
public IEnumerator ShortButtonStat_Equal_None_When_After_One_Keyboard_Event()
{
var obj = new GameObject();
yield return null;
}
}
fileFormatVersion: 2
guid: 6e827d1ccd3c1ee44931742328a640b3
timeCreated: 1516873575
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -16,7 +16,7 @@ public class TrackInfo
public float BeatInterval
{ get { return 4 * 60 * 1000f / BPM; } }
public AudioSource BGM { get; private set; }
public string BGM { get; private set; }
public List<string> TrackList { get; private set; }
......@@ -151,7 +151,7 @@ internal class TrackHeader
public string Genre { get; private set; }
public float BPM { get; private set; }
public int Level { get; private set; }
public AudioSource BGM { get; private set; }
public string BGM { get; private set; }
public List<string> TrackList { get; private set; }
public
......@@ -159,27 +159,25 @@ internal class TrackHeader
ExtractHeader(
MultiDictionary<string, string> parseResult)
{
Title = ExtractMetaString(
parseResult,
"#TITLE");
Artist = ExtractMetaString(
parseResult,
"#ARTIST");
Genre = ExtractMetaString(
parseResult,
"#GENRE");
BPM = ExtractBPM(
parseResult);
Level = ExtractLevel(
parseResult);
TrackList = ExtractMetaList(
parseResult,
"#TRACKLIST");
BGM = Resources.Load(
ExtractMetaString(
parseResult,
"#WAV"))
as AudioSource;
Title = ExtractMetaString(
parseResult,
"#TITLE");
Artist = ExtractMetaString(
parseResult,
"#ARTIST");
Genre = ExtractMetaString(
parseResult,
"#GENRE");
BPM = ExtractBPM(
parseResult);
Level = ExtractLevel(
parseResult);
TrackList = ExtractMetaList(
parseResult,
"#TRACKLIST");
BGM = ExtractMetaString(
parseResult,
"#WAV");
}
private
......
......@@ -41,7 +41,7 @@ public class TrackManager : MonoBehaviour {
}
bool IsPressedStart
{ get { return InputManager.Instance.ButtonStat == ButtonStatus.Pressed; } }
{ get { return Input.GetKey(KeyCode.Space); } }
// Use this for initialization
void Start()
......@@ -135,8 +135,7 @@ public class TrackManager : MonoBehaviour {
// TODO: disable start button if nothing selected
GameManager.Instance.CurrentTrack = selected.GetComponent<TrackInfoHolder>().trackInfo;
Destroy(GetComponent<InputManager>());
Destroy(this);
GameManager.Instance.SceneTransition("InGame");
......
......@@ -4,6 +4,8 @@
#BPM 128
#PLAYLEVEL 0
#WAV Bigroom1
#000SBT AA00
#004SBT AAAAAAAA
#005SBT AAAAAAAA
......
......@@ -8,5 +8,7 @@
#TRACKLIST Probably - Amumal
#TRACKLIST PARANOiA - Revolution
#WAV REC001
#002SMO JPJPJPJP
#003SMO JPJPJPJP
#TITLE test
#ARTIST asdf
#GENRE asdf
#BPM 120
#PLAYLEVEL 0
#000SBT 00AA00AA
#001SBT 00AA00AA
#002SBT 00AA00AA
#003SBT 00AA00AA
#004SBT 00AA00AA
#015SBT 00AA00AA
#025SBT 00AA00AA
#035SBT 00AA00AA
#045SBT 00AA00AA
#055SBT 00AA00AA
#065SBT 00AA00AA
#075SBT 00AA00AA
#085SBT 00AA00AA
#095SBT 00AA00AA
#105SBT 00AA00AA
#115SBT 00AA00AA
#125SBT 00AA00AA
#135SBT 00AA00AA
#145SBT 00AA00AA
#155SBT 00AA00AA
\ No newline at end of file
fileFormatVersion: 2
guid: 28b00014f89894a4b9eff7574541cf9c
timeCreated: 1516862638
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -20,3 +20,6 @@ EditorBuildSettings:
- enabled: 1
path: Assets/Scene/Result.unity
guid: 610cc3a14d437e44bb9e6ba385e05136
- enabled: 1
path: Assets/Scene/tmp.unity
guid: bd1125abc59508941a9858dc3f08c1b7
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