Commit 390a0c5b authored by lokanchung's avatar lokanchung

기본 판정 시스템 구현

parent f79dc081
......@@ -121,7 +121,7 @@ Transform:
m_GameObject: {fileID: 8354046899824507571}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 3, y: 3, z: 3}
m_LocalScale: {x: 5, y: 5, z: 5}
m_Children:
- {fileID: 2824711142497691445}
m_Father: {fileID: 0}
......@@ -184,7 +184,7 @@ SphereCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Radius: 0.75
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &8354046899824507576
MonoBehaviour:
......@@ -198,54 +198,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5ede6b16436a58b4bb3118a59fd1a9ba, type: 3}
m_Name:
m_EditorClassIdentifier:
curveX:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 1
outSlope: 1
tangentMode: 34
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 1
inSlope: 1
outSlope: 1
tangentMode: 34
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
curveY:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 1
outSlope: 1
tangentMode: 34
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 1
inSlope: 1
outSlope: 1
tangentMode: 34
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
endPoint: {x: 0, y: 0, z: 0}
maxRemainedTime: 1
perfectZ: 10
......
......@@ -20,10 +20,9 @@ class Level
var judge = new JudgeResult();
var hit = note.CheckHit(input.ray);
Debug.Log(input.ray);
judge.near = false;
judge.type = JudgeType.Ignore;
judge.correctHand = note.HandType == HandType.None || note.HandType == input.hand;
switch (hit)
{
......
......@@ -33,14 +33,14 @@ abstract class Note
var timing = Math.Abs(delta);
var early = delta < 0;
if (timing < 0.5)
if (timing < 0.1)
{
return JudgeType.Perfect;
}
else if (timing < 1.0)
else if (timing < 0.5)
{
return JudgeType.Hit;
} else if (timing < 1.5 && early)
} else if (timing < 1.0 && early)
{
return JudgeType.Miss;
}
......@@ -67,7 +67,11 @@ abstract class Note
{
if (judge.type != JudgeType.Ignore)
{
Debug.Log(System.Enum.GetName(typeof(JudgeType), judge.type));
Debug.Log(string.Format("Note #{0}: {1}, Correct Hand: {2}",
0,
System.Enum.GetName(typeof(JudgeType), judge.type),
judge.correctHand
));
noteObject.NoteHit(judge);
}
}
......
......@@ -28,9 +28,28 @@ public abstract class NoteObject : MonoBehaviour
public virtual void NoteHit(JudgeResult judge)
{
GameObject hitEffect = null;
if (judge.type == JudgeType.Perfect)
hitEffect = PlayEngine.inst.hitEffectPrefabs[0];
if (judge.type == JudgeType.Hit)
hitEffect = PlayEngine.inst.hitEffectPrefabs[1];
if (judge.type == JudgeType.Miss)
hitEffect = PlayEngine.inst.hitEffectPrefabs[2];
OnNoteHit?.Invoke(judge);
Instantiate(PlayEngine.inst.hitEffectPrefabs[(int)(judge.type)], transform.position, Quaternion.identity);
//Destroy(gameObject);
if (hitEffect && judge.type != JudgeType.Ignore)
{
// show explosion effect
Instantiate(hitEffect, transform.position, Quaternion.identity);
// TODO: temporary implementation
// make note invisible
var meshRenderer = gameObject.GetComponent<MeshRenderer>();
var trailRenderer = gameObject.GetComponent<TrailRenderer>();
if (meshRenderer) meshRenderer.enabled = false;
if (trailRenderer) trailRenderer.enabled = false;
}
}
public virtual void SetPosition(float remainedTime)
......
......@@ -75,23 +75,29 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
PlayerInput input = new PlayerInput();
input.time = playbackTime;
// FIXME: fire.GetStateDown causes error
if (Input.GetKeyDown(KeyCode.Alpha1))
{
input.ray = Camera.main.ScreenPointToRay(Input.mousePosition);
input.hand = HandType.Left;
level.HandleInput(input);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
input.ray = Camera.main.ScreenPointToRay(Input.mousePosition);
input.hand = HandType.Left;
level.HandleInput(input);
}
try // when no VR device is available, SteamVR causes an error.
{
if (Input.GetMouseButtonDown(0) || fire.GetStateDown(leftHand))
// TODO: handle vr input
if (fire.GetStateDown(leftHand))
{
AudioSource.PlayClipAtPoint(gunSfx, Vector3.zero);
input.ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay(input.ray.origin, input.ray.direction * 10, Color.yellow);
input.hand = HandType.Left;
level.HandleInput(input);
}
if (Input.GetMouseButtonDown(1) || fire.GetStateDown(rightHand))
if (fire.GetStateDown(rightHand))
{
AudioSource.PlayClipAtPoint(gunSfx, Vector3.zero);
input.ray = Camera.main.ScreenPointToRay(Input.mousePosition);
input.hand = HandType.Right;
level.HandleInput(input);
}
}
catch (NullReferenceException e)
......
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