private void tictoc() { int thisBeatIndex = myAudioPlayer.getNextBeat(); float thisFreq = myAudioPlayer.playSoundBass(thisBeatIndex); int thisNote = myAudioPlayer.lookupNote(thisFreq); // myAudioPlayer.playSoundTone(thisBeatIndex); // float thisTone = myAudioPlayer.playSoundTone(thisBeatIndex); float thisTone = 0; if (ticVal % 16 == 0) { playerCtrl.updateCapBuffer(1); } if (ticVal % 8 == 0) { imgHitCount = 0; } if (ticVal % (64 * Mathf.Pow(2, decCount)) == 0) { if (ticVal > 0) { decEnemySpawnTime(); } decCount += 1; // Debug.Log(ticVal); // Debug.Log(enemySpawnTime); } if (capQueue.Count != 0) { barDisplay.gameObject.SetActive(true); explainText.gameObject.SetActive(false); barDisplay.text = myAudioPlayer.getBarDisplay(thisBeatIndex); // if (ticVal % 8 == 0) // { // barDisplay.text = myAudioPlayer.getBarDisplay(thisBeatIndex); // } // barDisplay.text += "> "; //barDisplayStrs[ticVal%8] barDisplay.text += "\nBuffer: " + playerCtrl.getCapBufferVal(); } else { barDisplay.gameObject.SetActive(false); explainText.gameObject.SetActive(true); playerCtrl.ResetPlayer(); } ticVal += 1; if (thisNote > 0) { SpawnRandomEnemy(thisNote); } if (capQueue.Count != 0) { int qLen = capQueue.Count; bool killAny = false; if (myAudioPlayer.playSoundBeat(thisBeatIndex) > 0) { for (int i = 0; i < qLen; i++) { GameObject currentCap = (GameObject)capQueue.Dequeue(); CapController TheCapControllerInstance = currentCap.GetComponent("CapController") as CapController; if (TheCapControllerInstance.checkLifeTime() < 8) { TheCapControllerInstance.incLifeTime(8); // will be 0 or 8; 1,2 } Renderer rendTemp = currentCap.GetComponent <Renderer>(); if (TheCapControllerInstance.checkLifeTime() > 7) //2,0 { rendTemp.material.color = Color.cyan; } else { rendTemp.material.color = Color.Lerp(Color.yellow, Color.cyan, TheCapControllerInstance.checkLifeTime() / 8.0f); // getting power sound? } capQueue.Enqueue(currentCap); } } // myAudioPlayer.playSoundTone(thisBeatIndex); bool skipRest = false; for (int i = 0; i < qLen; i++) { GameObject currentCap = (GameObject)capQueue.Dequeue(); CapController TheCapControllerInstance; if (skipRest == true) { capQueue.Enqueue(currentCap); continue; } else { TheCapControllerInstance = currentCap.GetComponent("CapController") as CapController; } if (TheCapControllerInstance.checkLifeTime() > 3 - 3) { // Destroy(currentCap); if (TheCapControllerInstance.checkHit(imgZ, imgX)) { // crash cap sound Destroy(currentCap); } else if ((TheCapControllerInstance.tryClean(thisNote) > 0)) // || (thisNote == 0)) { // TheCapControllerInstance.resetLifeTime(); if (thisNote > 0) { killAny = true; } // float thisTone = myAudioPlayer.playSoundTone(thisBeatIndex); // barDisplay.text += myAudioPlayer.lookupNote(thisTone); // if ( thisTone > 0) if (true) { // to calculate hitsum from this note? if (TheCapControllerInstance.checkLifeTime() > 7) { imgHitCount += 1; // 2 } else { imgHitCount += 1; } if (imgHitCount > 3 || checkGroundCut(imgX)) //15 { imgX = 20; imgZ = 5; imgHitCount = 0; } // hit sound as a function of hitCount // Destroy(currentCap); playerCtrl.updateCapBuffer(1); // move to above? } else { // playSoundHigh? } if ((thisNote > 0) || (thisTone > 0)) { TheCapControllerInstance.incLifeTime(-8); } if (TheCapControllerInstance.checkLifeTime() < 0) { //?TheSpawnManagerInstance.updateGroundInfo(z, x, null); //?auto to null? Destroy(currentCap); } else { if (TheCapControllerInstance.checkLifeTime() == 0) { Renderer rendTemp = currentCap.GetComponent <Renderer>(); rendTemp.material.color = Color.yellow; } capQueue.Enqueue(currentCap); } skipRest = true; // don't check the rest of capQueue if anykill // can't use break here to ensure the sequence of queue } else // did nothing for this cap { capQueue.Enqueue(currentCap); } } else // capLifeTime <= 0 { capQueue.Enqueue(currentCap); } } barDisplay.text += "\nCombo: " + imgHitCount.ToString() + "/4"; if (killAny) { myAudioPlayer.playSoundHigh(thisBeatIndex); // Debug.Log("HERE"); } } else { // TO DO } }