public int GetDamage() { NoteBehavior closestNote = null; int distanceTo50 = 1000000; foreach (GameObject note in noteList) { NoteBehavior noteBehavior = note.GetComponent <NoteBehavior>(); if (null == closestNote) { closestNote = noteBehavior; distanceTo50 = Mathf.Abs(noteBehavior.GetDelta()); } else { if (Mathf.Abs(noteBehavior.GetDelta()) < distanceTo50) { closestNote = noteBehavior; distanceTo50 = Mathf.Abs(noteBehavior.GetDelta()); } } } if (null == closestNote) { return(1); } int dmgFactor = closestNote.GetDamageFactor(); HandleComboMeter(dmgFactor); return(dmgFactor); }
void HoldChk() { for (int i = 0; i < 4; i++) { float[] TimeChk = { PerfectTime, GoodTime }; if (ChkCount[i] < NoteChker[i].Count) { NoteBehavior Data = NoteChker[i][ChkCount[i]]; if (holding[i]) { if (Input.GetKeyUp(Click[i])) { holding[i] = false; Destroy(Data.gameObject); ChkCount[i]++; if (StageTime - Data.EndTime < -GoodTime) { HoldMiss++; Combo = 0; } } } if (StageTime - Data.EndTime > GoodTime && Data.isHold) { holding[i] = false; Destroy(Data.gameObject); ChkCount[i]++; } } } }
//Creation function to spawn a new note, allowing easy modification of attributes in NoteManager. //Defaults could be managed in the prefab, but this I find easier public static void Create(float speed, GameObject template, int position, float topBound, float bottomBound, float windowBound, int pointValue) { //Create a new note from the template GameObject newNote = (GameObject)Instantiate(template); NoteBehavior newNoteBehavior = newNote.GetComponent <NoteBehavior> (); //Initialize speed and position newNoteBehavior._moveSpeed = speed; newNoteBehavior.SetInitialPosition(position); //Set bounds newNoteBehavior._targetTopBound = topBound; newNoteBehavior._targetBottomBound = bottomBound; newNoteBehavior._windowTopBound = windowBound; newNoteBehavior._pointValue = pointValue; //Pass a reference to ScoreController so that points can be updated GameObject scoreControllerObject = GameObject.FindWithTag("GameController"); if (scoreControllerObject != null) { newNoteBehavior._scoreController = scoreControllerObject.GetComponent <ScoreController>(); } newNoteBehavior._listener = KeyManager.GetKeyListenerByPosition(position); }
//Add a new note at the specified position void addNote(int position) { float windowTop = (renderer.bounds.size.y / 2) + transform.position.y; float targetTopBounds = _noteCollider.GetTop(); float targetBottomBounds = _noteCollider.GetBottom(); NoteBehavior.Create(_noteSpeed, _noteTemplate, position, targetTopBounds, targetBottomBounds, windowTop, _noteValue); }
public void CreateNote(int isHold) { GameObject Ob = Instantiate(NoteOrigin[isHold], NoteFile[isHold]); Hold NoteData = new Hold(); NoteData.line = LineSlect; NoteData.Time = (MusicPlayer.StageTime - Stage.offset) / (RealTime); if (isHold == 1) { NoteData.EndTime = NoteData.Time + 0.25f; } Ob.transform.localPosition = new Vector2(Line1Mid + LineAndLine * LineSlect, Ob.transform.localPosition.y); EditNoitBeh DataID = Ob.GetComponent <EditNoitBeh>(); DataID.NoteIDonLine = NoteChker[LineSlect].Count; if (isHold == 1) { DataID.NoteData = NoteData; DataID.NoteIDinStageData = Stage.H.Count; Stage.H.Add(NoteData); HoldInd = true; } else { DataID.NoteData = NoteData; DataID.NoteIDinStageData = Stage.N.Count; Stage.N.Add(NoteData); HoldInd = false; } EditingNoteIDonLine = DataID.NoteIDonLine; EditingData = NoteData; EditingNoteIDinStage = DataID.NoteIDinStageData; DataChange = true; Slected = true; NoteBehavior Data = Ob.GetComponent <NoteBehavior>(); Data.arrivetime = NoteData.Time * RealTime + Stage.offset; if (isHold == 1) { Data.isHold = true; Ob.transform.localScale = new Vector3(1, (Speed * (NoteData.EndTime - NoteData.Time)) / 100, 1); Data.EndTime = NoteData.EndTime * RealTime + Stage.offset; } NoteChker[LineSlect].Add(Data); }
private GameObject PlaceNote(string text, Vector3 position, Quaternion rotation, float scale) { GameObject newNote = Instantiate(notePrefab, position, rotation) as GameObject; newNote.transform.localScale *= scale; // set text of created note NoteBehavior newNoteScript = newNote.GetComponent <NoteBehavior>(); newNoteScript.changeNoteText(text); return(newNote); }
private void OnTriggerStay(Collider other) { // destroy the note that is in the drum as the player hits it if (other.tag == "note" && currentlyHit) { NoteBehavior nb = other.GetComponent <NoteBehavior>(); if (nb.laneID == this.laneID) { Instantiate(particleDestroy, transform.position, transform.rotation); nb.OnDestroy(); } } }
void ClickChk() { for (int i = 0; i < 4; i++) { if (ChkCount[i] < NoteChker[i].Count) { NoteBehavior Data = NoteChker[i][ChkCount[i]]; if (!Data.isHold && StageTime - Data.arrivetime > GoodTime) { Data.click = true; Destroy(Data.gameObject); ChkCount[i]++; Miss++; Combo = 0; continue; } if (Input.GetKeyDown(Click[i])) { int[] Playing = { Perfect, Good }; float[] TimeChk = { PerfectTime, GoodTime }; for (int k = 0; k < 2; k++) { if (Mathf.Abs(StageTime - Data.arrivetime) < TimeChk[k]) { Combo++; Playing[k]++; if (Data.isHold) { Data.click = true; holding[i] = true; } else { Data.click = true; Destroy(Data.gameObject); ChkCount[i]++; } break; } } Debug.Log("Hit" + "Line: " + i); Perfect = Playing[0]; Good = Playing[1]; } } } }
void spawnNote() { int index = Random.Range(0, notePrefabs.Length); GameObject temp = Instantiate(notePrefabs[index]); NoteBehavior note = temp.GetComponent <NoteBehavior>(); note.init(speed, hoverHeight, hoverVariance, hoverSpeed, rotationSpeed, boyMoveScript.getT(), startDistance, endDistance, boyMoveScript.getCurrentBezierSpline(), boyMoveScript.transform); note.setSwingSpeed(swingSpeed); note.setSwingVariance(swingVariance); temp.transform.SetParent(noteList); }
public void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag == "Note") { NoteBehavior note = collision.gameObject.GetComponent <NoteBehavior>(); if (side == SatelliteType.blue) { if (note.planetType == PlanetType.blue || note.planetType == PlanetType.white) { Destroy(collision.gameObject); } } else { if (note.planetType == PlanetType.red || note.planetType == PlanetType.white) { Destroy(collision.gameObject); } } } }
void AdvanceLecture() { cursor++; int cursor50 = cursor + 50; if (musicNotes[cursor]) { particleSystemFeedback.Play(); } for (int i = 0; i < noteList.Count; i++) { GameObject note = noteList[i]; NoteBehavior noteBehavior = note.GetComponent <NoteBehavior>(); float notePositionValue = (float)noteBehavior.GetPositionAndUpdate(); if (notePositionValue <= 50) { note.transform.position = Vector3.Lerp(noteStart.position, noteRight.position, notePositionValue * 0.02f); } else if (notePositionValue <= 70) { note.transform.position = Vector3.Lerp(noteRight.position, noteEnd.position, (notePositionValue - 50f) * 0.05f); } else { note.SetActive(false); noteList.RemoveAt(i); } } if (musicNotes[cursor50]) { GameObject newNote = Instantiate(notePrefab); newNote.transform.parent = trackParent; newNote.transform.position = noteStart.position; noteList.Add(newNote); } }
public void NoteCreate() { GameObject Ob; int[] NoteLine = { 0, 0 }; float[] NoteTime = { 0, 0 }; for (int i = 0; i < 2; i++) { if (count[i] < maxchk[i]) { if (i == 0) { NoteLine[i] = Stage.N[count[i]].line; NoteTime[i] = Stage.N[count[i]].Time; } else { NoteLine[i] = Stage.H[count[i]].line; NoteTime[i] = Stage.H[count[i]].Time; } } } //Debug.Log("NextGenerate: Note: Line " + NoteLine[0] + " Time " + NoteTime[0] + " Hold: Line " + NoteLine[1] + " Time " + NoteTime[1]); for (int k = 0; k <= 1; k++) { float NoteReady = (NoteTime[k] * (RealTime) + Stage.offset) - ((NoteTop - NoteBottom) / MoveSpeed); if (NoteReady <= StageTime) { if (count[k] < maxchk[k]) { Ob = Instantiate(NoteOrigin[k], NoteFile[k]); Ob.transform.localPosition = new Vector2(Line1Mid + LineAndLine * NoteLine[k], Ob.transform.localPosition.y); if (Editor) { EditNoitBeh DataID = Ob.GetComponent <EditNoitBeh>(); DataID.NoteIDonLine = NoteChker[NoteLine[k]].Count; if (k == 1) { DataID.NoteData = Stage.H[count[k]]; } else { DataID.NoteData = Stage.N[count[k]]; } DataID.NoteIDinStageData = count[k]; } NoteBehavior Data = Ob.GetComponent <NoteBehavior>(); Data.arrivetime = NoteTime[k] * (RealTime) + Stage.offset; if (k == 1) { Data.isHold = true; Data.EndTime = (Stage.H[count[k]].EndTime) * (RealTime) + Stage.offset; Ob.transform.localScale = new Vector3(Ob.transform.localScale.x, (Speed * ((Stage.H[count[k]].EndTime - NoteTime[k])) * (RealTime)) / HoldSize, 1); } NoteChker[NoteLine[k]].Add(Data); count[k] += 1; } } } }