public List <float> BeatsCenterWithOffset(int beatPos, enum_BeatType type, float f_beatEach) { List <float> beatMids = new List <float>(); switch (type) { case enum_BeatType.Single: { beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach); } break; case enum_BeatType.Double: { beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach); beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach + f_beatEach * .5f); } break; case enum_BeatType.Triple: { beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach); beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach + f_beatEach / 3); beatMids.Add(F_BeatStartOffset + beatPos * f_beatEach + f_beatEach * 2 / 3); } break; } return(beatMids); }
private void Awake() { I_RectHeight = 700; I_BeatCheckLine = 50; I_SliderWidth = 80; I_BeatsInView = 16; I_ViewBtnScale = 25; I_SliderBeatScale = 2; e_CurNodeType = enum_BeatType.Single; Event.current = new Event(); }
public void AdjustNode(int beatPos, enum_BeatType type) { tempNode = GetNodeByPos(beatPos); if (tempNode != null) { int index = l_Nodes.IndexOf(tempNode); Node n = new Node(beatPos, tempNode.b_IsLeft, type); l_Nodes[index] = n; } else { Debug.LogError("Can't Adjust A Unexisted Node!Pos:" + beatPos); } }
Color GetNodeColor(bool editable, enum_BeatType type = enum_BeatType.Invalid) { if (!editable) { return(Color.grey); } switch (type) { default: return(Color.white); case enum_BeatType.Single: return(Color.red); case enum_BeatType.Double: return(new Color(1, .5f, 0, 1f)); case enum_BeatType.Triple: return(Color.magenta); } }
public void SetNode(int beatPos, bool isLeft, enum_BeatType type) { tempNode = GetNodeByPos(beatPos); if (tempNode != null) { int index = l_Nodes.IndexOf(tempNode); Node n = new Node(beatPos, isLeft, type); l_Nodes[index] = n; } else { for (int i = 0; i < l_Nodes.Count; i++) { if (l_Nodes[i].i_BeatPos > beatPos) { l_Nodes.Insert(i, new Node(beatPos, isLeft, type)); return; } } l_Nodes.Add(new Node(beatPos, isLeft, type)); } }
public Node(int beatPos, bool isLeft, enum_BeatType type) { i_BeatPos = beatPos; b_IsLeft = isLeft; e_Type = type; }
void DrawViewExtra(Rect totalRect, Vector2 v2_mousePos) { //Draw Node Counter GUI.color = Color.white; tempRect = new Rect(totalRect.xMin + 5, totalRect.yMin + 5, 120, 20); GUI.Box(tempRect, "Beats Set:" + beats.GetNodes().Count.ToString() + "/" + i_totalBeats.ToString()); //Draw Total Time GUI.color = Color.white; tempRect = new Rect(totalRect.xMin + 5, totalRect.yMin + 30, 120, 20); GUI.Box(tempRect, "Clip Length:" + string.Format("{0:000.0}", beats.AC_ClipToPlay.length)); //Draw Node Select if (i_curSelectPos != -1) { Node tempNode = beats.GetNodeByPos(i_curSelectPos); if (tempNode == null) { return; } List <float> beatsCenter = beats.BeatsCenterWithOffset(tempNode.i_BeatPos, tempNode.e_Type, f_beatEach); GUI.color = Color.white; tempRect = new Rect(totalRect.xMin + 5, totalRect.yMin + 55, 120, 40 + beatsCenter.Count * 20); GUI.Box(tempRect, ""); tempRect = new Rect(totalRect.xMin + 10, totalRect.yMin + 60, 110, 20); GUI.Label(tempRect, "Ind:" + beats.GetNodeIndex(i_curSelectPos).ToString() + "/Pos:" + i_curSelectPos.ToString()); tempRect = new Rect(totalRect.xMin + 10, totalRect.yMin + 80, 110, 20); GUI.Label(tempRect, "Type:" + beats.GetNodeByPos(i_curSelectPos).e_Type.ToString()); for (int i = 0; i < beatsCenter.Count; i++) { tempRect = new Rect(totalRect.xMin + 10, totalRect.yMin + 80 + (i + 1) * 20, 110, 20); GUI.Label(tempRect, "Beat " + (i + 1).ToString() + ":" + beatsCenter[i].ToString()); } } //Draw Node Type Select foreach (int i in System.Enum.GetValues(typeof(enum_BeatType))) { if (i == -1) { continue; } enum_BeatType type = (enum_BeatType)i; //HighLight if (type == e_CurNodeType) { GUI.color = Color.grey; tempRect = new Rect(totalRect.xMin + 5 - .1f * I_ViewBtnScale, totalRect.yMax - I_BeatCheckLine - 5 - (i * 1.1f + 1 + .1f) * I_ViewBtnScale, I_ViewBtnScale * 1.2f, I_ViewBtnScale * 1.2f); GUI.DrawTexture(tempRect, t2_BeatBtn); } //Draw Tips GUI.color = Color.white; tempRect = new Rect(totalRect.xMin + 5 + I_ViewBtnScale + 10f, totalRect.yMax - I_BeatCheckLine - 5 - (i * 1.1f + 1) * I_ViewBtnScale, 80, I_ViewBtnScale); GUI.Box(tempRect, type.ToString()); //Draw Btn GUI.color = GetNodeColor(true, type); tempRect = new Rect(totalRect.xMin + 5, totalRect.yMax - I_BeatCheckLine - 5 - (i * 1.1f + 1) * I_ViewBtnScale, I_ViewBtnScale, I_ViewBtnScale); GUI.DrawTexture(tempRect, t2_BeatBtn); //Btn Click if (tempRect.Contains(v2_mousePos)) { if (e_CurNodeType == type && i_curSelectPos != -1) { beats.AdjustNode(i_curSelectPos, e_CurNodeType); } e_CurNodeType = type; } } if (f_curTime - beats.F_BeatStartOffset > f_beatCheck) //Check Beats { f_beatCheck += f_beatEach; f_beatToScale = 1f; } f_beatToScale = Mathf.Lerp(f_beatToScale, 0f, .02f); //Draw Beat Check Box GUI.color = Color.white; tempRect = new Rect(totalRect.xMax - 5 - 20, totalRect.yMax - 120 * f_beatToScale - 5, 20, 120 * f_beatToScale); GUI.Box(tempRect, "B"); }