private void LoadKeyboardObjects() { for (int t = 0; t < 41; t++) { GameObject _sfObj = Instantiate(Resources.Load("Prefabs/KeyBoardObj", typeof(GameObject))) as GameObject; if (_sfObj != null) { if (KeyboardObjectContainer != null) { _sfObj.transform.parent = KeyboardObjectContainer.transform; } _sfObj.name = "keyBoardObj" + t.ToString(); //default storage location _sfObj.transform.position = new Vector2(StoragePosition.transform.position.x, StoragePosition.transform.position.y); _sfObj.transform.localScale = new Vector2(targetScale, targetScale); KeyBoardObj objectScript = _sfObj.GetComponent <KeyBoardObj> (); objectScript.ID = t; KeyboardObjectList.Add(_sfObj); } else { Debug.Log("Couldn't load keyboard object prefab"); } } }
void QuerySetKeyboardObjectsLoaded() { foreach (GameObject tObj in KeyboardObjectList) { KeyBoardObj objectScript = tObj.GetComponent <KeyBoardObj> (); objectScript._State = KeyBoardObj.eState.Loaded; } }
void QuerySetKeyboardlObjectsPosition() { float yOffset = 0f; int keyIndex = 0; int[] keySeqArray = new int[41] { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 }; int lastKey = 1; foreach (GameObject tObj in KeyboardObjectList) { KeyBoardObj objectScript = tObj.GetComponent <KeyBoardObj> (); int k = keySeqArray [keyIndex]; if (k == 0) { objectScript.SetWhiteBlack(0); if (lastKey == 0) { yOffset += FretGridDY * targetScale; } else { yOffset += (FretGridDY / 2) * targetScale; } } else if (k == 1) { objectScript.SetWhiteBlack(1); yOffset += (FretGridDY / 2) * targetScale; } float x = fretStartX; float y = fretStartY + yOffset; objectScript.SetGridPosition(new Vector3(x, y, 1f)); lastKey = k; keyIndex++; } }
void QuerySetMarkerObjectsPosition() { float xOffset = 0.42f * targetScale; float yOffset = 0f; int colCount = 0; int rowCount = 0; int noteIndex = 0; int[] notes = new int[Globals.MaxStrings + 1] { (int)Globals._notes.NOTE_E, (int)Globals._notes.NOTE_A, (int)Globals._notes.NOTE_D, (int)Globals._notes.NOTE_G, (int)Globals._notes.NOTE_B, (int)Globals._notes.NOTE_E, 0 }; int[] keySeqArray = new int[41] { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 }; if (_drawMode == DrawMode.Guitar) { noteIndex = notes[colCount]; foreach (GameObject tObj in MarkerObjectList) { MarkerObj objectScript = tObj.GetComponent <MarkerObj> (); float x = gridStartX + xOffset; float y = gridStartY + yOffset; objectScript.SetGridPosition(new Vector3(x, y, -0.5f)); objectScript.NoteName = noteIndex; yOffset += FretGridDY * targetScale; rowCount++; if (rowCount >= FretGridHeight) { rowCount = 0; yOffset = 0f; xOffset += FretGridDX * targetScale; colCount++; noteIndex = notes [colCount]; } else { noteIndex++; if (noteIndex >= 12) { noteIndex = 0; } } if (colCount >= FretGridWidth) { break; } } } else if (_drawMode == DrawMode.Piano) { int lastKey = 1; int keyIndex = 0; int count = KeyboardObjectList.Count; count--; noteIndex = (int)Globals._notes.NOTE_C; foreach (GameObject tObj in MarkerObjectList) { if (keyIndex < 41) { MarkerObj objectScript = tObj.GetComponent <MarkerObj> (); float x = gridStartX + xOffset + 4f; float y = gridStartY + yOffset; GameObject key = KeyboardObjectList[count]; KeyBoardObj keyObjectScript = key.GetComponent <KeyBoardObj> (); Vector3 vpos = keyObjectScript.GetGridPosition(); if (keyObjectScript.isBlack == true) { vpos.x = vpos.x - 1f; } else { vpos.x = vpos.x + 1f; } objectScript.SetGridPosition(new Vector3(vpos.x, vpos.y, -0.5f)); objectScript.NoteName = noteIndex; int k = keySeqArray [keyIndex]; if (k == 0) { if (lastKey == 0) { yOffset += FretGridDY * targetScale; } else { yOffset += (FretGridDY / 2) * targetScale; } } else if (k == 1) { yOffset += (FretGridDY / 2) * targetScale; } noteIndex++; if (noteIndex >= 12) { noteIndex = 0; } count--; if (count < 0) { count = 0; } lastKey = k; keyIndex++; } else { break; } } } }