Commit 195d8379 authored by 13정준영's avatar 13정준영

노트 시스템 최종

parent 39b775a6
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: DefaultNote
m_Shader: {fileID: 4800000, guid: 19d29d358ae9fed4b8a0fd347863afc5, type: 3}
m_ShaderKeywords: _EMISSION _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DecalTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- PixelSnap: 0
- _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnableExternalAlpha: 0
- _Fresnel: 2
- _FresnelAmount: 0.31
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 1
- _Mode: 0
- _NewOutline: 0.005
- _OcclusionStrength: 1
- _Outline: 0.02
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 0
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _UseUIAlphaClip: 0
- _ZWrite: 1
- _ccccc: 0.2393162
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- _node_3119: {r: 0.5, g: 0.5, b: 0.5, a: 1}
fileFormatVersion: 2
guid: c1f601b048926674b8386fa6ef9e7f15
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -76,7 +76,7 @@ Material:
- _DstBlend: 0
- _EnableExternalAlpha: 0
- _Fresnel: 2
- _FresnelAmount: 0.2
- _FresnelAmount: 0.31
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
......
......@@ -30,6 +30,7 @@ Transform:
m_Children:
- {fileID: 6879579829741053864}
- {fileID: 6879579829926966544}
- {fileID: 2808715225732087063}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -48,10 +49,13 @@ MonoBehaviour:
endPoint: {x: 0, y: 0, z: 0}
maxRemainedTime: 5
perfectZ: 50
hitSfx: []
hitSfx:
- {fileID: 8300000, guid: a23aad6537568134a9861f2d338e83b8, type: 3}
- {fileID: 0}
cartridges:
- {fileID: 6879579829741053864}
- {fileID: 6879579829926966544}
text: {fileID: 2808715225732087063}
--- !u!1 &6879579829741053867
GameObject:
m_ObjectHideFlags: 0
......@@ -78,13 +82,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6879579829741053867}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.3, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 0.3, z: 0.1}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: 0.2, y: 0, z: 0}
m_LocalScale: {x: 0.025, y: 0.15, z: 0.05}
m_Children: []
m_Father: {fileID: 6879579829033429646}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!33 &6879579829741053871
MeshFilter:
m_ObjectHideFlags: 0
......@@ -110,7 +114,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 2100000, guid: c1f601b048926674b8386fa6ef9e7f15, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......@@ -171,8 +175,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6879579829926966572}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.3, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 0.3, z: 0.1}
m_LocalPosition: {x: -0.2, y: 0, z: 0}
m_LocalScale: {x: 0.025, y: 0.15, z: 0.05}
m_Children: []
m_Father: {fileID: 6879579829033429646}
m_RootOrder: 1
......@@ -202,7 +206,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 2100000, guid: c1f601b048926674b8386fa6ef9e7f15, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......@@ -236,3 +240,95 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &6961112589851847313
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2808715225732087063}
- component: {fileID: 7955947371106866757}
- component: {fileID: 4067875191153338803}
m_Layer: 0
m_Name: New Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2808715225732087063
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6961112589851847313}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6879579829033429646}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &7955947371106866757
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6961112589851847313}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!102 &4067875191153338803
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6961112589851847313}
m_Text: RELOAD!
m_OffsetZ: 0
m_CharacterSize: 1
m_LineSpacing: 1
m_Anchor: 7
m_Alignment: 1
m_TabSize: 4
m_FontSize: 0
m_FontStyle: 0
m_RichText: 1
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4294967295
......@@ -22,6 +22,7 @@
#00113:E1
#00114:E3
#00116:E2
#00312:37
......
File added
File added
fileFormatVersion: 2
guid: bba8ebc9e7d332b4d8c3b8ec6489bbfa
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a23aad6537568134a9861f2d338e83b8
AudioImporter:
externalObjects: {}
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:
......@@ -30,10 +30,33 @@ class Level
}
}
public void HandleMotion(PlayerMotion motion)
{
foreach(var n in notes)
{
ActionNote note = n as ActionNote;
if (note != null && note.IsActive)
{
if (Math.Abs(note.Time - motion.time) < 0.05f)
{
if (note.CheckMotion(motion) == JudgeType.Hit)
{
JudgeResult result = new JudgeResult();
result.correctHand = true;
result.type = JudgeType.Perfect;
note.HandleJudge(result);
note.Deactivate();
break;
}
}
}
}
}
private JudgeResult Judge(PlayerInput input, Note note)
{
var judge = new JudgeResult();
var hit = note.CheckHit(input.ray);
var hit = note.CheckHit(input);
judge.near = false;
judge.type = JudgeType.Ignore;
......
......@@ -64,11 +64,11 @@ abstract class Note
}
}
public virtual HitType CheckHit(Ray ray)
public virtual HitType CheckHit(PlayerInput input)
{
// add near support
if(noteObject.IsHit(ray))
if(noteObject.IsHit(input))
{
return HitType.Hit;
} else
......@@ -145,8 +145,12 @@ abstract class Note
handType = HandType.Right;
break;
// TODO : add action notes
case "16": // 1p forth lane: EDGE RIGHT HAND
note = new ReloadNote();
handType = HandType.None;
break;
default:
return null;
......@@ -249,12 +253,50 @@ class EdgeNote : Note
}
}
abstract class ActionNote : Note
{
public abstract JudgeType CheckMotion(PlayerMotion motion);
}
class ReloadNote : ActionNote
{
private int index;
public override JudgeType CheckMotion(PlayerMotion motion)
{
if (CheckHand(motion.rightHand) && CheckHand(motion.leftHand))
{
return JudgeType.Hit;
}
return JudgeType.Miss;
}
private bool CheckHand(MotionTracker hand)
{
return Vector3.Dot(hand.Velocity, Vector3.down) > 0.002;
}
protected override NoteObject CreateNoteObjectImpl()
{
var obj = MonoBehaviour.Instantiate<ReloadNoteObject>(PlayEngine.inst.ReloadNoteObject);
obj.Init();
return obj;
}
protected override void FromBmsNum(string num)
{
}
}
public enum NoteType
{
Front,
Rear,
Edge,
Action
Reload
}
public enum HandType
......
......@@ -51,8 +51,8 @@ public class EdgeNoteObject : NoteObject
transform.position = endPoint + new Vector3(0, 0, 300) * remainedTime;
}
public override bool IsHit(Ray ray)
public override bool IsHit(PlayerInput input)
{
return Mathf.Abs(Mathf.Acos(Vector3.Dot(direction.normalized, ray.direction))) < 30;
return Mathf.Abs(Mathf.Acos(Vector3.Dot(direction.normalized, input.ray.direction))) < 30;
}
}
\ No newline at end of file
......@@ -24,8 +24,6 @@ public class ForwardNoteObject : NoteObject
Ray ray = new Ray(Vector3.zero, endPoint.normalized);
endPoint = ray.GetPoint(perfectZ);
Debug.Log(endPoint);
ring = IngameUIManager.inst.AddNoteRingUI();
ring.position = endPoint;
ring.LookAt(Vector3.zero);
......@@ -103,9 +101,9 @@ public class ForwardNoteObject : NoteObject
img.color = color;
}
public override bool IsHit(Ray ray)
public override bool IsHit(PlayerInput input)
{
RaycastHit hit;
return GetComponent<Collider>().Raycast(ray, out hit, 1000);
return GetComponent<Collider>().Raycast(input.ray, out hit, 1000);
}
}
using UnityEngine;
public class MotionTracker
{
private Vector3 lastPosition;
private Vector3 currentPosition;
private bool first;
private bool active;
public bool IsActive
{
get => active;
}
public Vector3 Velocity
{
get => currentPosition - lastPosition;
}
public MotionTracker()
{
lastPosition = Vector3.zero;
currentPosition = Vector3.zero;
first = true;
active = true;
}
public void FeedPosition(Vector3 pos)
{
if (first)
{
lastPosition = currentPosition = pos;
first = false;
} else
{
lastPosition = currentPosition;
currentPosition = pos;
}
}
public void Deactivate()
{
first = true;
active = false;
}
public void Activate()
{
active = true;
}
}
fileFormatVersion: 2
guid: 72d3352ff76a52f4f88dfd64f7634f14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -88,7 +88,7 @@ public abstract class NoteObject : MonoBehaviour
transform.position = new Vector3(t * endPoint.x, t * endPoint.y, endPoint.z + z);
}
public abstract bool IsHit(Ray ray);
public abstract bool IsHit(PlayerInput ray);
private IEnumerator DissolveRoutine()
{
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
using System;
using Valve.VR.InteractionSystem;
[RequireComponent(typeof(AudioSource))]
public class PlayEngine : SingletonBehaviour<PlayEngine>
......@@ -10,6 +11,8 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public LevelScriptableObject[] levelList;
public ForwardNoteObject ForwardNoteObject;
public EdgeNoteObject[] EdgeNoteObjects = new EdgeNoteObject[4];
public ReloadNoteObject ReloadNoteObject;
private double startTime;
private Level level;
......@@ -35,6 +38,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public GameObject player;
private MotionTracker leftHandTracker = new MotionTracker();
private MotionTracker rightHandTracker = new MotionTracker();
private int combo;
private int score;
......@@ -88,6 +94,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
var leftHandObject = handObjects[0];
var rightHandObject = handObjects[1];
TrackHand(leftHandObject, leftHandTracker);
TrackHand(rightHandObject, rightHandTracker);
level.UpdateNotes(playbackTime);
if (Input.GetKeyDown(KeyCode.Alpha1))
......@@ -107,7 +116,6 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
try // when no VR device is available, SteamVR causes an error.
{
// TODO: handle vr input
if (fire.GetStateDown(leftHand))
{
input.hand = HandType.Left;
......@@ -118,7 +126,6 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
input.ray = gun.GetRay();
gun.Fire();
Debug.DrawRay(input.ray.origin, input.ray.direction, Color.magenta, 1);
level.HandleInput(input);
}
}
......@@ -131,10 +138,16 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
input.ray = gun.GetRay();
gun.Fire();
Debug.DrawRay(input.ray.origin, input.ray.direction, Color.cyan, 1);
level.HandleInput(input);
}
}
PlayerMotion motion = new PlayerMotion();
motion.leftHand = leftHandTracker;
motion.rightHand = rightHandTracker;
motion.time = playbackTime;
level.HandleMotion(motion);
}
catch (NullReferenceException e)
{
......@@ -159,6 +172,18 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
}
}
private void TrackHand(Hand handObject, MotionTracker tracker)
{
if (handObject)
{
tracker.Activate();
tracker.FeedPosition(handObject.transform.position);
} else
{
tracker.Deactivate();
}
}
// Simple implementations of Combo, Score UIs
// It needs to be changed if PlayEngine don't have any responsibilities of score & combo
public void HandleNoteJudge(JudgeType type)
......@@ -204,8 +229,14 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public class PlayerInput
{
// TODO: make'em properties
public Ray ray;
public HandType hand;
public double time;
}
public class PlayerMotion
{
public MotionTracker leftHand;
public MotionTracker rightHand;
public double time;
}
\ No newline at end of file
......@@ -6,31 +6,101 @@ public class ReloadNoteObject : NoteObject
{
[SerializeField]
private Transform[] cartridges = new Transform[2];
[SerializeField]
private Transform text;
private void Update()
{
cartridges[0].Rotate(new Vector3(0, 180 * Time.deltaTime, 0));
cartridges[1].Rotate(new Vector3(0, -180 * Time.deltaTime, 0));
cartridges[0].Rotate(new Vector3(540 * Time.deltaTime, 0, 0));
cartridges[1].Rotate(new Vector3(-540 * Time.deltaTime, 0, 0));
}
public override void NoteHit(JudgeResult judge)
{
PlayJudgeSfx(judge);
GameObject hitEffect = null;
// hit effect
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);
if (hitEffect && judge.type != JudgeType.Ignore)
{
Instantiate(hitEffect, transform.position, Quaternion.identity);
StartCoroutine(DissolveRoutine());
PlayEngine.inst.HandleNoteJudge(judge.type);
}
}
private IEnumerator DissolveRoutine()
{
Material mat = new Material(Shader.Find("Unlit/Dissolve"));
MeshRenderer[] mrs = GetComponentsInChildren<MeshRenderer>();
foreach (var mr in mrs) {
mat.SetColor("_Color", mr.material.color);
mat.SetColor("_Glow", (Color.white + mr.material.color) / 2);
mr.material = mat;
Texture2D noise = new Texture2D(100, 100);
float scale = UnityEngine.Random.Range(20, 50);
for (int i = 0; i < noise.width; ++i)
{
for (int j = 0; j < noise.height; ++j)
{
float noiseVal = Mathf.PerlinNoise(scale * i / noise.width, scale * j / noise.height);
noise.SetPixel(i, j, new Color(noiseVal, noiseVal, noiseVal, 1));
}
}
noise.Apply();
mat.SetTexture("_NoiseTex", noise);
const float time = 0.5f;
for (float t = 0; t < time; t += Time.deltaTime)
{
mat.SetFloat("_Threshold", t / time);
mat.SetColor("_Color", mat.color - new Color(0, 0, 0, 2) * Time.deltaTime);
yield return null;
}
mat.SetFloat("_Threshold", 1);
}
}
public void Init()
{
}
public override bool IsHit(Ray ray)
public override bool IsHit(PlayerInput input)
{
throw new System.NotImplementedException();
return false;
}
public override void SetPosition(float remainedTime)
{
transform.position = new Vector3(0f, -1.5f * Mathf.Pow(remainedTime, 2) + 1.5f, 0.4f);
if (Mathf.Abs(remainedTime) < 0.5f)
foreach (var cat in cartridges) {
var pos = cat.localPosition;
cat.localPosition = new Vector3(pos.x, -0.25f * Mathf.Pow((remainedTime-0.01f) * 3, 4) + 1f, 1f);
}
if (Mathf.Abs(remainedTime) < 0.1f)
{
foreach(var renderer in GetComponentsInChildren<MeshRenderer>())
foreach(var cat in cartridges)
{
renderer.material.color = Color.Lerp(Color.white, Color.red, 1 - 4 * Mathf.Pow(remainedTime, 2));
var renderer = cat.gameObject.GetComponentInChildren<MeshRenderer>();
renderer.material.color = Color.Lerp(Color.white, Color.red, 1 - 4 * Mathf.Pow(remainedTime, 3));
}
}
text.position = endPoint + new Vector3(0, 0, 300) * remainedTime;
}
}
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