Commit 928ffea4 authored by 15박보승's avatar 15박보승

NoteHit시 노트가 Dissolve 되도록 구현, Combo & Score UI 간단히 구현, Miss 이펙트 추가

parent 48cee20a
......@@ -9568,7 +9568,7 @@ ParticleSystem:
serializedVersion: 6
lengthInSec: 0.2
simulationSpeed: 1
stopAction: 0
stopAction: 2
cullingMode: 1
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
......
This diff is collapsed.
fileFormatVersion: 2
guid: b8ffb5b84b254524abff419289c5adfd
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -43,7 +43,7 @@ ParticleSystem:
serializedVersion: 6
lengthInSec: 0.1
simulationSpeed: 1
stopAction: 0
stopAction: 2
cullingMode: 3
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
......
This diff is collapsed.
This diff is collapsed.
......@@ -9,6 +9,7 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
public Text scoreText;
public Text comboText;
private Vector3 comboTextPosition;
private void Start()
{
......@@ -33,6 +34,17 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
if (combo < 1)
comboText.text = "";
else
{
comboText.text = combo.ToString() + " Combo!";
StartCoroutine(ComboRoutine());
}
}
private IEnumerator ComboRoutine()
{
for (float t = 0; t < 0.2f; t += Time.deltaTime) {
comboText.transform.localPosition = Vector3.Lerp(new Vector3(0, 10), Vector3.zero, t * 5);
yield return new WaitForEndOfFrame();
}
comboText.transform.localPosition = Vector3.zero;
}
}
......@@ -14,7 +14,7 @@ public abstract class NoteObject : MonoBehaviour
public Vector3 endPoint;
public float maxRemainedTime = 5;
public float perfectZ = 10;
public float perfectZ = 50;
public AudioClip[] hitSfx;
......@@ -60,10 +60,17 @@ public abstract class NoteObject : MonoBehaviour
// TODO: temporary implementation
// make note invisible
StartCoroutine(DissolveRoutine());
/*
var meshRenderer = gameObject.GetComponent<MeshRenderer>();
var trailRenderer = gameObject.GetComponent<TrailRenderer>();
if (meshRenderer) meshRenderer.enabled = false;
if (trailRenderer) trailRenderer.enabled = false;
*/
PlayEngine.inst.HandleNoteJudge(judge.type);
}
}
......@@ -75,4 +82,38 @@ public abstract class NoteObject : MonoBehaviour
}
public abstract bool IsHit(Ray ray);
private IEnumerator DissolveRoutine()
{
Material mat = new Material(Shader.Find("Unlit/Dissolve"));
MeshRenderer mr = GetComponent<MeshRenderer>();
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)
{
//print(t / time);
mat.SetFloat("_Threshold", t / time);
yield return null;
}
mat.SetFloat("_Threshold", 1);
}
}
......@@ -32,6 +32,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public SteamVR_Input_Sources leftHand;
public SteamVR_Input_Sources rightHand;
private int combo;
private int score;
public void Start()
{
audioSource = GetComponent<AudioSource>();
......@@ -121,6 +124,20 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
startDspTime -= 1.0f;
}
}
// 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)
{
if (type == JudgeType.Ignore)
return;
combo = type != JudgeType.Miss ? combo + 1 : 0;
score += (int)type;
IngameUIManager.inst.UpdateComboUI(combo);
IngameUIManager.inst.UpdateScoreUI(score);
}
//
}
public class PlayerInput
......
fileFormatVersion: 2
guid: c914f324cf453f049a32e43b44daeee1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Shader "Unlit/Dissolve"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Color("Color", Color) = (1, 1, 1, 1)
_NoiseTex("Noise_Texture", 2D) = "white" {}
_Threshold("Threshold" , range(0,1)) = 0
_Glow("Glow", Color) = (1, 0.5, 0.5, 1)
_EmissionAmount("Emission amount", float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 _Color;
sampler2D _NoiseTex;
float _Threshold;
fixed4 _Glow;
float _EmissionAmount;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
if (col.a < 0.01f)
discard;
if (tex2D(_NoiseTex, i.uv).r < _Threshold)
discard;
else if (tex2D(_NoiseTex, i.uv).r < _Threshold + 0.05f)
col = lerp(_Glow, col, (tex2D(_NoiseTex, i.uv).r - _Threshold) * 20);
//else
// o.Emission = _Glow * _EmissionAmount * pow(1 - (tex2D(_NoiseTex, IN.uv_MainTex).r - _Threshold), 10);
return col;
}
ENDCG
}
}
}
fileFormatVersion: 2
guid: 457a7835d317dbd40a3c3467b0006e70
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
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