Commit 0acaeb94 authored by 16서원빈's avatar 16서원빈

Working InGame

parent 4b5563af
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1839526890916058}
m_IsPrefabParent: 1
--- !u!1 &1839526890916058
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224491764761756372}
- component: {fileID: 222572614339470256}
- component: {fileID: 114048093616581902}
m_Layer: 5
m_Name: Beat Line
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114048093616581902
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.627451}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222572614339470256
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
--- !u!224 &224491764761756372
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
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: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
fileFormatVersion: 2
guid: 4efccb64927c7ca42b4e8f01d7d25773
folderAsset: yes
timeCreated: 1502962628
guid: be34e1eacae80114c90c2aedee0d6408
timeCreated: 1503573417
licenseType: Free
DefaultImporter:
NativeFormatImporter:
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -231,7 +231,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 3, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224219039990227194
RectTransform:
......
......@@ -53,6 +53,8 @@ GameObject:
serializedVersion: 5
m_Component:
- component: {fileID: 224011200304410306}
- component: {fileID: 222613705641654236}
- component: {fileID: 114973331513533902}
m_Layer: 5
m_Name: LMO
m_TagString: Untagged
......@@ -158,6 +160,33 @@ MonoBehaviour:
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114973331513533902
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1869947549572880}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222375019058029532
CanvasRenderer:
m_ObjectHideFlags: 1
......@@ -170,6 +199,12 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1422421716557948}
--- !u!222 &222613705641654236
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1869947549572880}
--- !u!222 &222950832735418152
CanvasRenderer:
m_ObjectHideFlags: 1
......@@ -195,7 +230,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 3, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224106473661142190
RectTransform:
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1839526890916058}
m_IsPrefabParent: 1
--- !u!1 &1839526890916058
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224491764761756372}
- component: {fileID: 222572614339470256}
- component: {fileID: 114048093616581902}
m_Layer: 5
m_Name: Measure Line
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114048093616581902
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.627451}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222572614339470256
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
--- !u!224 &224491764761756372
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1839526890916058}
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: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 2, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
fileFormatVersion: 2
guid: 1a97249d2381dcc4492c416a96fde813
timeCreated: 1502962628
guid: 350ca22a121fc3b40947c48a2bedea2c
timeCreated: 1503573417
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
NativeFormatImporter:
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -74,8 +74,8 @@ RectTransform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 3, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
This diff is collapsed.
......@@ -24,7 +24,8 @@ public class JudgeManager : MonoBehaviour
float latency = 225f;
float scrollMultiplier = 1.0f;
private GameObject offset, noteobj;
private GameObject offset;
private GameObject noteobj, smobj, lmobj;
private GameObject motionGuage;
private GameObject judgeText;
......@@ -53,6 +54,8 @@ public class JudgeManager : MonoBehaviour
{
offset = GameObject.Find("Offset");
noteobj = GameObject.Find("Noteobj");
smobj = GameObject.Find("SMobj");
lmobj = GameObject.Find("LMobj");
judgeText = GameObject.Find("Judge");
motionGuage = GameObject.Find("Motion Guage");
......@@ -72,66 +75,92 @@ public class JudgeManager : MonoBehaviour
offset.transform.position = new Vector3(
-timing * ScrollSpeed, 0, 0);
if (noteobj.transform.childCount <= 0)
return;
GameObject obj = noteobj.transform.GetChild(0).gameObject;
Note note = obj.GetComponent<Note.Controller>().Instance;
if (note.IsLong && note.Activated)
new Action(() =>
{
if (InputManager.Instance.IsButtonHolding)
if (noteobj.transform.childCount <= 0)
return;
GameObject obj = noteobj.transform.GetChild(0).gameObject;
Note note = obj.GetComponent<Note.Controller>().Instance;
if (note.IsLong && note.Activated)
{
if(Judge.IsNonEmptyMiss(note, timing, true))
if (InputManager.Instance.IsButtonHolding)
{
SetJudge(Judge.MISS);
if (Judge.IsNonEmptyMiss(note, timing, true))
{
SetJudge(Judge.MISS);
DeactivateNote(note);
}
return;
}
if (InputManager.Instance.IsButtonReleased)
{
SetJudge(Judge.TestJudge(note, timing, true));
DeactivateNote(note);
return;
}
return;
}
if (InputManager.Instance.IsButtonReleased)
Judge judge = Judge.TestJudge(note, timing);
if (Judge.IsNonEmptyMiss(note, timing))
{
SetJudge(Judge.TestJudge(note, timing, true));
SetJudge(judge);
DeactivateNote(note);
return;
}
}
if (note is MotionNote)
if (InputManager.Instance.IsButtonPressed)
{
SetJudge(judge);
if (judge == Judge.MISS) // Empty Miss
{
return;
}
if (note.IsLong)
note.Activated = true;
else
DeactivateNote(note);
}
})();
new Action(() =>
{
((MotionNote)note).Checkpoint();
if (smobj.transform.childCount <= 0)
return;
GameObject smo = smobj.transform.GetChild(0).gameObject;
MotionNote smnote = (MotionNote)smo.GetComponent<Note.Controller>().Instance;
if (note.Activated)
smnote.Checkpoint();
if (smnote.Activated)
{
SetJudge(Judge.TestJudge(note, timing));
DeactivateNote(note);
SetJudge(Judge.TestJudge(smnote, timing));
DeactivateNote(smnote);
}
})();
return;
}
new Action(() =>
{
if (lmobj.transform.childCount <= 0)
return;
Judge judge = Judge.TestJudge(note, timing);
GameObject lmo = lmobj.transform.GetChild(0).gameObject;
MotionNote lmnote = (MotionNote)lmo.GetComponent<Note.Controller>().Instance;
if (Judge.IsNonEmptyMiss(note, timing))
{
SetJudge(judge);
DeactivateNote(note);
}
lmnote.Checkpoint();
if (InputManager.Instance.IsButtonPressed)
{
SetJudge(judge);
if (judge == Judge.MISS) // Empty Miss
if (lmnote.Activated)
{
return;
SetJudge(Judge.TestJudge(lmnote, timing));
DeactivateNote(lmnote);
}
if (note.IsLong)
note.Activated = true;
else
DeactivateNote(note);
}
return;
})();
}
private void DeactivateNote(Note note)
......@@ -141,13 +170,13 @@ public class JudgeManager : MonoBehaviour
note.Component.Deactivate();
}
private void SetJudge(Judge judge)
private void SetJudge(Judge judge, bool isMotion = false)
{
if (!judge.IsBreak)
GameManager.Instance.Combo++;
GameManager.Instance.Score += judge.Score;
Debug.Log(judge.Name);
Debug.Log(judge.Name + (isMotion ? " Motion" : " Note"));
judgeText.SetActive(true);
judgeText.GetComponent<Text>().text = judge.Name;
......@@ -156,12 +185,20 @@ public class JudgeManager : MonoBehaviour
private void LoadNotes(List<Note> notes)
{
foreach (Note note in notes) {
foreach (Note note in notes)
{
GameObject obj = Instantiate(
Resources.Load(note.Type.ToString(), typeof(GameObject)),
noteobj.transform)
as GameObject;
if (note is MotionNote && !note.IsLong)
obj.transform.SetParent(smobj.transform);
else if (note is MotionNote && note.IsLong)
obj.transform.SetParent(lmobj.transform);
else if (note.Type == NoteType.MeasureLine || note.Type == NoteType.BeatLine)
obj.transform.SetParent(offset.transform);
if (note.IsLong)
{
float length = note.Length * ScrollSpeed;
......
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public abstract class MotionNote : Note
{
public MotionNote(float start, float end = 0f) : base(start, end) {}
public abstract Sprite Image { get; }
public MotionNote(float start, float end = 0f)
: base(start == end ? NoteType.SMO : NoteType.LMO, start, end) { }
public MotionNote(string key, float start, float end = 0f)
: this(start, end) { }
public abstract IEnumerable<bool> Checkpoint();
public static readonly Dictionary<string, Type> keymap
= new Dictionary<string, Type>
{
{ "CP", typeof(Clap) },
{ "JP", typeof(Jump) },
{ "BP", typeof(PushUp) },
{ "LP", typeof(PushUp) },
{ "RP", typeof(PushUp) },
{ "BI", typeof(Piano) },
{ "LI", typeof(Piano) },
{ "RI", typeof(Piano) },
{ "BG", typeof(Guard) },
{ "LG", typeof(Guard) },
{ "RG", typeof(Guard) },
};
protected static Sprite LoadNewSprite(string FilePath, float PixelsPerUnit = 100.0f)
{
Sprite NewSprite = new Sprite();
Texture2D SpriteTexture = LoadTexture(FilePath);
NewSprite = Sprite.Create(SpriteTexture,
new Rect(0, 0, SpriteTexture.width, SpriteTexture.height),
new Vector2(0, 0), PixelsPerUnit);
return NewSprite;
}
private static Texture2D LoadTexture(string FilePath)
{
Texture2D Tex2D;
byte[] FileData;
if (File.Exists(FilePath))
{
FileData = File.ReadAllBytes(FilePath);
Tex2D = new Texture2D(2, 2);
if (Tex2D.LoadImage(FileData))
return Tex2D;
}
return null;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
public class ClapNote : MotionNote
{
public ClapNote(float timing) : base(timing) {
}
public override IEnumerable<bool> Checkpoint()
{
var motionState = InputManager.Instance.CurrentMotionState;
var motion = motionState;
while (motion != MotionState.CLAP_PREPARE)
yield return false;
Activated = true;
yield break;
}
}
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum NoteType { SBT, LBT, SMO, LMO }
public enum NoteType { SBT, LBT, SMO, LMO, BeatLine, MeasureLine }
public class Note
{
......
......@@ -69,7 +69,10 @@ public class TrackInfo
public List<Note> ParseBPENote(FileInfo file)
{
List<Note> notes = new List<Note>();
float? tempLongStart = null;
float? tempLongBtnStart = null;
float? tempLongMtnStart = null;
int maxMeasure = 0;
using (StreamReader reader
= new StreamReader(new BufferedStream(file.OpenRead())))
......@@ -97,42 +100,74 @@ public class TrackInfo
if (Array.FindIndex(CHANNELS, x => x == channel) == -1)
continue;
if (measure > maxMeasure)
maxMeasure = measure;
int seq = value.Length / 2;
float ms = 4 * 60 * 1000f / BPM;
for (int i = 0; i < seq; i++)
{
string key = value.Substring(i * 2, 2);
string key = value.Substring(i* 2, 2);
if (key == "00")
continue;
float timing = (measure + (float)i / seq) * ms;
if (channel == "SMO")
{
notes.Add(new ClapNote(timing));
}
else if (channel[0] == 'S')
if (channel == "SBT")
{
notes.Add(new Note(key, channel, timing));
}
else if (channel[0] == 'L')
else if (channel == "LBT")
{
if (tempLongStart == null)
if (tempLongBtnStart == null)
{
tempLongStart = timing;
tempLongBtnStart = timing;
continue;
}
float start = tempLongStart.Value;
float start = tempLongBtnStart.Value;
notes.Add(new Note(key, channel, start, timing));
tempLongStart = null;
tempLongBtnStart = null;
}
Type motionType;
if (!MotionNote.keymap.TryGetValue(key, out motionType))
continue;
if (channel == "SMO")
{
notes.Add((MotionNote)Activator.CreateInstance(
motionType, key, timing));
}
else if (channel == "LMO")
{
if (tempLongMtnStart == null)
{
tempLongMtnStart = timing;
continue;
}
float start = tempLongMtnStart.Value;
notes.Add((MotionNote)Activator.CreateInstance(
motionType, key, start, timing));
tempLongMtnStart = null;
}
}
}
}
for(int i = 0; i <= maxMeasure; i++)
{
for(int j = 1; j < 4; j++)
{
notes.Add(new Note(NoteType.BeatLine, (i + (float)j / 4) * 4 * 60 * 1000f / BPM));
}
notes.Add(new Note(NoteType.BeatLine, (i + 1) * 4 * 60 * 1000f / BPM));
}
return notes;
}
}
\ 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