Commit 6cfca48c authored by 16이상민's avatar 16이상민

Refactoring about motion notes

parent b6e8f197
......@@ -15,6 +15,7 @@ public class Clap : MotionNote
public Clap(string key, float start, float end = 0f) : this(start, end)
{
MotionName = "Clap";
}
public Clap(float start, float end = 0f) : base(start, end)
{
......
......@@ -29,6 +29,7 @@ public class Guard : MotionNote
| MotionState.HAND_MOVE_DOWN_LEFT | MotionState.HAND_MOVE_DOWN_RIGHT;
done = MotionState.GUARD_BASE_LEFT | MotionState.GUARD_BASE_RIGHT
| MotionState.HAND_MOVE_UP_LEFT | MotionState.HAND_MOVE_UP_RIGHT;
MotionName = "GuardBoth";
break;
case "LG":
hand = Hand.Left;
......@@ -37,6 +38,7 @@ public class Guard : MotionNote
| MotionState.HAND_MOVE_DOWN_LEFT;
done = MotionState.GUARD_BASE_LEFT
| MotionState.HAND_MOVE_UP_LEFT;
MotionName = "GuardLeft";
break;
case "RG":
hand = Hand.Right;
......@@ -45,6 +47,7 @@ public class Guard : MotionNote
| MotionState.HAND_MOVE_DOWN_RIGHT;
done = MotionState.GUARD_BASE_RIGHT
| MotionState.HAND_MOVE_UP_RIGHT;
MotionName = "GuardRight";
break;
}
}
......
......@@ -26,16 +26,19 @@ public class HandDown : MotionNote
hand = Hand.Both;
image = LoadNewSprite("Assets/MotionNotes/BD.png");
done = MotionState.HAND_DOWN_LEFT | MotionState.HAND_DOWN_RIGHT;
MotionName = "HandDownBoth";
break;
case "LD":
hand = Hand.Left;
image = LoadNewSprite("Assets/MotionNotes/LD.png");
done = MotionState.HAND_DOWN_LEFT;
MotionName = "HandDownLeft";
break;
case "RD":
hand = Hand.Right;
image = LoadNewSprite("Assets/MotionNotes/RD.png");
done = MotionState.HAND_DOWN_RIGHT;
MotionName = "HandDownRight";
break;
}
}
......
......@@ -26,16 +26,19 @@ public class HandUp : MotionNote
hand = Hand.Both;
image = LoadNewSprite("Assets/MotionNotes/BU.png");
done = MotionState.HAND_UP_LEFT | MotionState.HAND_UP_RIGHT;
MotionName = "HandUpBoth";
break;
case "LU":
hand = Hand.Left;
image = LoadNewSprite("Assets/MotionNotes/LU.png");
done = MotionState.HAND_UP_LEFT;
MotionName = "HandUpLeft";
break;
case "RU":
hand = Hand.Right;
image = LoadNewSprite("Assets/MotionNotes/RU.png");
done = MotionState.HAND_UP_RIGHT;
MotionName = "HandUpRight";
break;
}
}
......
......@@ -26,16 +26,19 @@ public class Headphone : MotionNote
hand = Hand.Both;
image = LoadNewSprite("Assets/MotionNotes/BH.png");
done = MotionState.HEADPHONE_LEFT | MotionState.HEADPHONE_RIGHT;
MotionName = "HeadphoneBoth";
break;
case "LH":
hand = Hand.Left;
image = LoadNewSprite("Assets/MotionNotes/LH.png");
done = MotionState.HEADPHONE_LEFT;
MotionName = "HeadphoneLeft";
break;
case "RH":
hand = Hand.Right;
image = LoadNewSprite("Assets/MotionNotes/RH.png");
done = MotionState.HEADPHONE_RIGHT;
MotionName = "HeadphoneRight";
break;
}
}
......
......@@ -15,6 +15,7 @@ public class Jesus : MotionNote
public Jesus(string key, float start, float end = 0f) : this(start, end)
{
MotionName = "Jesus";
}
public Jesus(float start, float end = 0f) : base(start, end)
{
......
......@@ -15,6 +15,7 @@ public class Jump : MotionNote
public Jump(string key, float start, float end = 0f) : this(start, end)
{
MotionName = "Jump";
}
public Jump(float start, float end = 0f) : base(start, end)
{
......
......@@ -15,6 +15,7 @@ public class OnTheTable : MotionNote
public OnTheTable(string key, float start, float end = 0f) : this(start, end)
{
MotionName = "OnTheTable";
}
public OnTheTable(float start, float end = 0f) : base(start, end)
{
......
......@@ -27,36 +27,42 @@ public class PushUp : MotionNote
image = LoadNewSprite("Assets/MotionNotes/BP.png");
prepare = MotionState.HAND_MOVE_UP_LEFT | MotionState.HAND_MOVE_UP_RIGHT;
done = MotionState.HAND_MOVE_DOWN_LEFT | MotionState.HAND_MOVE_DOWN_RIGHT;
MotionName = "PushUpBoth";
break;
case "LP":
hand = Hand.Left;
image = LoadNewSprite("Assets/MotionNotes/LP.png");
prepare = MotionState.HAND_MOVE_UP_LEFT;
done = MotionState.HAND_MOVE_DOWN_LEFT;
MotionName = "PushUpLeft";
break;
case "RP":
hand = Hand.Right;
image = LoadNewSprite("Assets/MotionNotes/RP.png");
prepare = MotionState.HAND_MOVE_UP_RIGHT;
done = MotionState.HAND_MOVE_DOWN_RIGHT;
MotionName = "PushUpRight";
break;
case "BK":
hand = Hand.Both;
image = LoadNewSprite("Assets/MotionNotes/BK.png");
prepare = MotionState.HAND_MOVE_UP_LEFT | MotionState.HAND_MOVE_UP_RIGHT | MotionState.JUMP_PREPARE;
done = MotionState.HAND_MOVE_DOWN_LEFT | MotionState.HAND_MOVE_DOWN_RIGHT | MotionState.JUMP_DONE;
MotionName = "JumpPushUpBoth";
break;
case "LK":
hand = Hand.Left;
image = LoadNewSprite("Assets/MotionNotes/LK.png");
prepare = MotionState.HAND_MOVE_UP_LEFT | MotionState.JUMP_PREPARE;
done = MotionState.HAND_MOVE_DOWN_LEFT | MotionState.JUMP_DONE;
MotionName = "JumpPushUpLeft";
break;
case "RK":
hand = Hand.Right;
image = LoadNewSprite("Assets/MotionNotes/RK.png");
prepare = MotionState.HAND_MOVE_UP_RIGHT | MotionState.JUMP_PREPARE;
done = MotionState.HAND_MOVE_DOWN_RIGHT | MotionState.JUMP_DONE;
MotionName = "JumpPushUpRight";
break;
}
}
......
......@@ -71,14 +71,17 @@ public class InputManager : MonoBehaviour {
{
get
{
if (ClapStat == InputStatus.Entered ||
JumpStat == InputStatus.Entered ||
PushUpLeftStat == InputStatus.Entered ||
PushUpRightStat == InputStatus.Entered ||
PushUpBothStat == InputStatus.Entered ||
GuardLeftStat == InputStatus.Entered ||
GuardRightStat == InputStatus.Entered ||
GuardBothStat == InputStatus.Entered)
if (ShortMotionToInput("Clap") == InputStatus.Entered ||
ShortMotionToInput("Jump") == InputStatus.Entered ||
ShortMotionToInput("PushUpLeft") == InputStatus.Entered ||
ShortMotionToInput("PushUpRight") == InputStatus.Entered ||
ShortMotionToInput("PushUpBoth") == InputStatus.Entered ||
ShortMotionToInput("JumpPushUpLeft") == InputStatus.Entered ||
ShortMotionToInput("JumpPushUpRight") == InputStatus.Entered ||
ShortMotionToInput("JumpPushUpBoth") == InputStatus.Entered ||
ShortMotionToInput("GuardLeft") == InputStatus.Entered ||
ShortMotionToInput("GuardRight") == InputStatus.Entered ||
ShortMotionToInput("GuardBoth") == InputStatus.Entered)
return InputStatus.Entered;
return InputStatus.None;
}
......@@ -88,108 +91,33 @@ public class InputManager : MonoBehaviour {
{
get
{
if (HandUpLeftStat == InputStatus.Entered ||
HandUpLeftStat == InputStatus.Continuing ||
HandUpRightStat == InputStatus.Entered ||
HandUpRightStat == InputStatus.Continuing ||
HandUpBothStat == InputStatus.Entered ||
HandUpBothStat == InputStatus.Continuing ||
HandDownLeftStat == InputStatus.Entered ||
HandDownLeftStat == InputStatus.Continuing ||
HandDownRightStat == InputStatus.Entered ||
HandDownRightStat == InputStatus.Continuing ||
HandDownBothStat == InputStatus.Entered ||
HandDownBothStat == InputStatus.Continuing ||
JesusStat == InputStatus.Entered ||
JesusStat == InputStatus.Continuing ||
HeadphoneLeftStat == InputStatus.Entered ||
HeadphoneLeftStat == InputStatus.Continuing ||
HeadphoneRightStat == InputStatus.Entered ||
HeadphoneRightStat == InputStatus.Continuing ||
HeadphoneBothStat == InputStatus.Entered ||
HeadphoneBothStat == InputStatus.Continuing ||
OnTheTableStat == InputStatus.Entered ||
OnTheTableStat == InputStatus.Continuing)
if (LongMotionToInput("HandUpLeft") == InputStatus.Entered ||
LongMotionToInput("HandUpLeft") == InputStatus.Continuing ||
LongMotionToInput("HandUpRight") == InputStatus.Entered ||
LongMotionToInput("HandUpRight") == InputStatus.Continuing ||
LongMotionToInput("HandUpBoth") == InputStatus.Entered ||
LongMotionToInput("HandUpBoth") == InputStatus.Continuing ||
LongMotionToInput("HandDownLeft") == InputStatus.Entered ||
LongMotionToInput("HandDownLeft") == InputStatus.Continuing ||
LongMotionToInput("HandDownRight") == InputStatus.Entered ||
LongMotionToInput("HandDownRight") == InputStatus.Continuing ||
LongMotionToInput("HandDownBoth") == InputStatus.Entered ||
LongMotionToInput("HandDownBoth") == InputStatus.Continuing ||
LongMotionToInput("Jesus") == InputStatus.Entered ||
LongMotionToInput("Jesus") == InputStatus.Continuing ||
LongMotionToInput("HeadphoneLeft") == InputStatus.Entered ||
LongMotionToInput("HeadphoneLeft") == InputStatus.Continuing ||
LongMotionToInput("HeadphoneRight") == InputStatus.Entered ||
LongMotionToInput("HeadphoneRight") == InputStatus.Continuing ||
LongMotionToInput("HeadphoneBoth") == InputStatus.Entered ||
LongMotionToInput("HeadphoneBoth") == InputStatus.Continuing ||
LongMotionToInput("OnTheTable") == InputStatus.Entered ||
LongMotionToInput("OnTheTable") == InputStatus.Continuing)
return InputStatus.Entered;
return InputStatus.None;
}
}
public InputStatus ClapStat
{ get { return ShortMotionToInput("Clap"); } }
public InputStatus JumpStat
{ get { return ShortMotionToInput("Jump"); } }
public InputStatus PushUpLeftStat
{ get { return ShortMotionToInput("PushUpLeft"); } }
public InputStatus PushUpRightStat
{ get { return ShortMotionToInput("PushUpRight"); } }
public InputStatus PushUpBothStat
{
get
{
var left = PushUpLeftStat;
var right = PushUpRightStat;
return left == right ? left : InputStatus.None;
}
}
public InputStatus GuardLeftStat
{ get { return ShortMotionToInput("GuardLeft"); } }
public InputStatus GuardRightStat
{ get { return ShortMotionToInput("GuardRight"); } }
public InputStatus GuardBothStat
{
get
{
var left = GuardLeftStat;
var right = GuardRightStat;
return left == right ? left : InputStatus.None;
}
}
public InputStatus HandUpLeftStat
{ get { return LongMotionToInput("HandUpLeft"); } }
public InputStatus HandUpRightStat
{ get { return LongMotionToInput("HandUpRight"); } }
public InputStatus HandUpBothStat
{
get
{
var left = HandUpLeftStat;
var right = HandUpRightStat;
return left == right ? left : InputStatus.None;
}
}
public InputStatus HandDownLeftStat
{ get { return LongMotionToInput("HandDownLeft"); } }
public InputStatus HandDownRightStat
{ get { return LongMotionToInput("HandDownRight"); } }
public InputStatus HandDownBothStat
{
get
{
var left = HandDownLeftStat;
var right = HandDownRightStat;
return left == right ? left : InputStatus.None;
}
}
public InputStatus JesusStat
{ get { return LongMotionToInput("Jesus"); } }
public InputStatus HeadphoneLeftStat
{ get { return LongMotionToInput("HeadphoneLeft"); } }
public InputStatus HeadphoneRightStat
{ get { return LongMotionToInput("HeadphoneRight"); } }
public InputStatus HeadphoneBothStat
{
get
{
var left = HeadphoneLeftStat;
var right = HeadphoneRightStat;
return left == right ? left : InputStatus.None;
}
}
public InputStatus OnTheTableStat
{ get { return LongMotionToInput("OnTheTable"); } }
// Update is called once per frame
void Update()
{
......@@ -197,8 +125,18 @@ public class InputManager : MonoBehaviour {
PrevMotionState = CurrentMotionState;
}
private InputStatus LongMotionToInput(string name)
public InputStatus LongMotionToInput(string name)
{
if (name.Contains("Both"))
{
var tmpname = name.Substring(name.IndexOf("Both"));
var left = LongMotionToInput(tmpname + "Left");
var right = LongMotionToInput(tmpname + "Right");
return left == right ? left : InputStatus.None;
}
Func<MotionState, MotionStatus> extractor = MotionStatusExtractor.GetExtractor(name);
if (extractor == null)
return InputStatus.None;
......@@ -219,8 +157,18 @@ public class InputManager : MonoBehaviour {
return InputStatus.None;
}
private InputStatus ShortMotionToInput(string name)
public InputStatus ShortMotionToInput(string name)
{
if (name.Contains("Both"))
{
var tmpname = name.Substring(name.IndexOf("Both"));
var left = ShortMotionToInput(tmpname + "Left");
var right = ShortMotionToInput(tmpname + "Right");
return left == right ? left : InputStatus.None;
}
Func<MotionState, MotionStatus> extractor = MotionStatusExtractor.GetExtractor(name);
if (extractor == null)
return InputStatus.None;
......@@ -249,7 +197,7 @@ public class InputManager : MonoBehaviour {
if (IsContain(state, MotionState.CLAP_PREPARE))
return MotionStatus.Prepared;
if (IsContain(state, MotionState.CLAP_DONE))
return MotionStatus.Prepared;
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -258,7 +206,7 @@ public class InputManager : MonoBehaviour {
if (IsContain(state, MotionState.JUMP_PREPARE))
return MotionStatus.Prepared;
if (IsContain(state, MotionState.JUMP_DONE))
return MotionStatus.Prepared;
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -269,7 +217,7 @@ public class InputManager : MonoBehaviour {
return MotionStatus.Prepared;
if (IsContain(state, MotionState.HURRAY) &&
IsContain(state, MotionState.HAND_MOVE_DOWN_LEFT))
return MotionStatus.Prepared;
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -280,7 +228,29 @@ public class InputManager : MonoBehaviour {
return MotionStatus.Prepared;
if (IsContain(state, MotionState.HURRAY) &&
IsContain(state, MotionState.HAND_MOVE_DOWN_RIGHT))
return MotionStatus.Done;
return MotionStatus.None;
}
private static MotionStatus ExtractJumpPushUpLeft(MotionState state)
{
if (ExtractJump (state) == MotionStatus.Prepared &&
ExtractPushUpLeft(state) == MotionStatus.Prepared)
return MotionStatus.Prepared;
if (ExtractJump (state) == MotionStatus.Done &&
ExtractPushUpLeft(state) == MotionStatus.Done)
return MotionStatus.Done;
return MotionStatus.None;
}
private static MotionStatus ExtractJumpPushUpRight(MotionState state)
{
if (ExtractJump (state) == MotionStatus.Prepared &&
ExtractPushUpRight(state) == MotionStatus.Prepared)
return MotionStatus.Prepared;
if (ExtractJump (state) == MotionStatus.Done &&
ExtractPushUpRight(state) == MotionStatus.Done)
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -291,7 +261,7 @@ public class InputManager : MonoBehaviour {
return MotionStatus.Prepared;
if (IsContain(state, MotionState.GUARD_BASE_LEFT) &&
IsContain(state, MotionState.HAND_MOVE_DOWN_LEFT))
return MotionStatus.Prepared;
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -302,7 +272,7 @@ public class InputManager : MonoBehaviour {
return MotionStatus.Prepared;
if (IsContain(state, MotionState.GUARD_BASE_RIGHT) &&
IsContain(state, MotionState.HAND_MOVE_DOWN_RIGHT))
return MotionStatus.Prepared;
return MotionStatus.Done;
return MotionStatus.None;
}
......@@ -382,6 +352,10 @@ public class InputManager : MonoBehaviour {
return ExtractPushUpLeft;
if (name.Equals("PushUpRight"))
return ExtractPushUpRight;
if (name.Equals("JumpPushUpLeft"))
return ExtractJumpPushUpLeft;
if (name.Equals("JumpPushUpRight"))
return ExtractJumpPushUpRight;
if (name.Equals("GuardLeft"))
return ExtractGuardLeft;
if (name.Equals("GuardRight"))
......
......@@ -266,7 +266,7 @@ public class JudgeManager : MonoBehaviour
private class NoteCondition
{
public static Dictionary<string, InputStatus> JudgeInput(Note note)
public static Dictionary<string, InputStatus> WrongInput(Note note)
{
if (note is MotionNote)
return new Dictionary<string, InputStatus>
......@@ -281,6 +281,21 @@ public class JudgeManager : MonoBehaviour
};
}
public static 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) }
};
return new Dictionary<string, InputStatus>
{
{ "short", InputManager.Instance.ShortButtonStat },
{ "long", InputManager.Instance.LongButtonStat }
};
}
public static bool IsShortNoteEntered(Note note)
{
return JudgeInput(note)["short"] == InputStatus.Entered;
......@@ -321,7 +336,7 @@ public class JudgeManager : MonoBehaviour
public static bool IsWrongInput(Note note)
{
var stat = JudgeInput(note);
var stat = WrongInput(note);
return stat["short"] == InputStatus.Entered ||
stat["long"] == InputStatus.Entered ||
stat["long"] == InputStatus.Continuing;
......
......@@ -20,6 +20,8 @@ public abstract class MotionNote : Note
public MotionSampleDisplay MotionSampleDisplay { get; set; }
public string MotionName { get; protected set; }
public static readonly Dictionary<string, Type> keymap
= new Dictionary<string, Type>
{
......
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