private void Start() { MinimapInstance = miniMap; SetCurrentState(EditorState.INIT); // Set static objects from unity editor // BarPrefab = barPrefab; NotePrefab = notePrefab; controlsDiagram = GameObject.FindGameObjectWithTag("ControlsWindow"). GetComponent <ControlsDiagram>(); controlsDiagram.UpdateMe(EditorState.INIT); BeatMap.currentDebugText = debugText; BeatMap.staticMats = materials; isVrPlayer = isVrPlayerOverride; spawnPositions = new Vector3[4, 3]; spawnPositions[0, 0] = spawnBlocks[1].position; spawnPositions[0, 1] = spawnBlocks[5].position; spawnPositions[0, 2] = spawnBlocks[9].position; spawnPositions[1, 0] = spawnBlocks[0].position; spawnPositions[1, 1] = spawnBlocks[4].position; spawnPositions[1, 2] = spawnBlocks[8].position; spawnPositions[2, 0] = spawnBlocks[2].position; spawnPositions[2, 1] = spawnBlocks[6].position; spawnPositions[2, 2] = spawnBlocks[10].position; spawnPositions[3, 0] = spawnBlocks[3].position; spawnPositions[3, 1] = spawnBlocks[7].position; spawnPositions[3, 2] = spawnBlocks[11].position; BeatMap.Log("Spawn position0 - " + spawnPositions[0, 0]); mainCamera = Camera.main; NoteContainer = new GameObject("NoteContainer"); Log("Main camera - " + mainCamera.name); audioSource = GetComponent <AudioSource>(); leftSaber.Initialize(isVrPlayer); rightSaber.Initialize(isVrPlayer); }
public void Refresh() { if (!initialized) { return; } BeatMap.EditorState currentState = BeatMap.GetCurrentState(); if (currentState == BeatMap.EditorState.Editing) { currentMaterial = ViveWandEditMode; } else if (currentState == BeatMap.EditorState.Recording) { currentMaterial = ViveWandRecordMode; } else if (currentState == BeatMap.EditorState.Playback) { currentMaterial = ViveWandPlaybackMode; } else if (currentState == BeatMap.EditorState.PlaybackPaused) { currentMaterial = ViveWandPlaybackPausedMode; } else { currentMaterial = ViveWand; } }
public static NoteDetails[] GenerateNotesForNewMap(BeatMap.NoteMode modeToGenerate, int totalBeats) { Debug.Log("Generating notes for new map, #Beats-" + totalBeats + " Mode-" + modeToGenerate); int numberOfNotesToGenerate = (12 * totalBeats); numberOfNotesToGenerate = (int)(numberOfNotesToGenerate * Note.GetFactor(modeToGenerate)); NoteDetails[] notes = new NoteDetails[numberOfNotesToGenerate]; for (int count = 0; count < numberOfNotesToGenerate; count++) { notes[count] = new NoteDetails(); int offSet = count % 12; int y = offSet / 4; int x = offSet % 4; Vector2 gridPosition = new Vector2(x, y); notes[count].gridPosition = gridPosition; notes[count].color = Note.NoteColor.NONE; notes[count].slashDirection = Note.SlashDirection.NONE; float spawnTime = (int)(count / 12f) / Note.GetFactor(modeToGenerate); float factor = Note.GetFactor(modeToGenerate); spawnTime = BeatMap.RoundToRelativeBeat(spawnTime, modeToGenerate); notes[count].timeToSpawn = spawnTime; } return(notes); }
// Update is called once per frame void Update() { if (currentCooldown > 0) { currentCooldown += Time.deltaTime; if (currentCooldown > cooldown) { currentCooldown = 0; } } timeAlive += Time.deltaTime; if (!BeatMap.IsRunning()) { return; } if (gameObject.activeSelf) { if (!BeatMap.IsRewinding) { transform.position += (transform.forward * noteSpeed) * Time.deltaTime; } else { transform.position -= (transform.forward * noteSpeed) * Time.deltaTime; } } }
public void StartNewMap() { if (!flatMenu.IsReadyForNew()) { BeatMap.Log("Start new called, but not ready"); return; } currentNoteMode = flatMenu.selectedMode; StartNewMap(0, flatMenu.selectedBPM, flatMenu.selectedAudioPath, flatMenu.selectedSongArtist, flatMenu.selectedMapArtist, flatMenu.selectedNewSongName, flatMenu.selectedDifficulty, flatMenu.selecedNewSongFileName); }
public void Attach(GameObject gameObject) { BeatMap.Log("Attach called on saber selector, current attachmetn - " + attachedObject); if (attachedObject != null) { BeatMap.Log("Saber Selector called to attach when already attached"); return; } attachedObject = gameObject; transform.position = gameObject.transform.position; transform.SetParent(gameObject.transform, true); meshRenderer.enabled = true; }
public void UnGrab() { resizing = false; if (joint != null) { Destroy(joint); } float relativeBeat = (MAX_Z + transform.position.z) * zPerBeat; Debug.LogWarning("Relative - " + relativeBeat); relativeBeat = BeatMap.RoundToRelativeBeat(relativeBeat, BeatMap.currentNoteMode); BeatMap.SkipToBeat(relativeBeat); }
public void InvertNotes() { if (BeatMap.state == EditorState.Playback) { return; } BeatMap.Log("Inverting map from " + BeatMap.Inverted + " Waiting note size " + waitingNotes.Count); BeatMap.Inverted = !BeatMap.Inverted; InvertArray(waitingNotes); InvertArray(activeNotes); InvertArray(completedNotes); }
private void OnTriggerEnter(Collider other) { if (IsOnCooldown() || BeatMap.Inverted != noteDetails.inverted) { Debug.LogWarning("Note is on cooldown"); return; } saberTouched = other.GetComponent <Saber>(); if (saberTouched != null) { bool refresh = false; currentCooldown += Time.deltaTime; BeatMap.EditorState currentState = BeatMap.GetCurrentState(); // During playback, remove notes as they are hit // if (noteDetails.IsVisible() && (currentState == BeatMap.EditorState.Playback || currentState == BeatMap.EditorState.Recording)) { Debug.LogWarning("INversion map-note - " + BeatMap.Inverted + "-" + noteDetails.inverted); Debug.LogWarning("Current beat - " + BeatMap.GetCurrentBeat()); Debug.LogWarning("Note beat - " + noteDetails.timeToSpawn); Debug.LogWarning("Difference - " + (BeatMap.GetCurrentBeat() - noteDetails.timeToSpawn)); saberTouched.addVibration(.5f, .05f, false); meshRenderer.enabled = false; noteDetails.inverted = !noteDetails.inverted; Debug.LogWarning("Note changed to " + noteDetails.inverted); refresh = true; } // During editing, highlight if the Note color has already been set // else if (currentState == BeatMap.EditorState.Editing && !noteDetails.inverted) { saberTouched.Attach(gameObject); } // During editing if set to neutral, record saber direction and color // if ((currentState == BeatMap.EditorState.Editing || currentState == BeatMap.EditorState.Recording) && noteDetails.color == NoteColor.NONE) { SlashDirection direction = saberTouched.GetSlashDirection(this); NoteColor color = saberTouched.GetSaberColor(); noteDetails.color = color; noteDetails.slashDirection = direction; refresh = true; } if (refresh) { Refresh(); Debug.LogWarning("Notiying mini map of change inverted?- " + noteDetails.inverted); MiniMap.AddNoteChange(noteDetails); } } }
private void Update() { if (!initialized) { return; } if (IsGrabbed()) { if (transform.position.z > MAX_Z) { Vector3 newPosition = transform.position; newPosition.z = MAX_Z; transform.position = newPosition; } else if (transform.position.z < MIN_Z) { Vector3 newPosition = transform.position; newPosition.z = MIN_Z; transform.position = newPosition; } float relativeBeat = totalBeats - (transform.position.z / zPerBeat) - 45; relativeBeat = BeatMap.RoundToRelativeBeat(relativeBeat, BeatMap.currentNoteMode); currentTimeBar.GetComponentInChildren <Text>().text = (relativeBeat * totalBeats).ToString(); } else { currentTimeBar.GetComponentInChildren <Text>().text = BeatMap.GetMostRecentBeat.ToString(); } if (BeatMap.IsRunning()) { //Debug.Log("Current Beat - " + BeatMap.GetCurrentBeat() + " current Z - " //+ transform.position.z + " ZDiff - " + (MAX_Z-transform.position.z)); Vector3 newPosition = transform.position; newPosition.z = MAX_Z - (zPerBeat * BeatMap.GetCurrentBeat()); transform.position = newPosition; } if (changes.Count > 0) { //Debug.LogWarning("Changes detected - " + changes.Count); foreach (NoteDetails change in changes) { littleNoteMap[change].GetComponent <MeshRenderer>().enabled = !littleNoteMap[change].GetComponent <MeshRenderer>().enabled; Debug.LogWarning("Meshrendered inverted on game object " + littleNoteMap[change].name); } changes = new List <NoteDetails>(); } }
public void Grab(IGrabber grabber) { Rigidbody thisRigidBody = GetComponent <Rigidbody>(); BeatMap.Log("grab called on " + gameObject.name + " already grabbed? - " + IsGrabbed()); if (IsGrabbed()) { return; } resizing = true; joint = gameObject.AddComponent <FixedJoint>(); BeatMap.Log("Adding joint to " + gameObject.name); joint.connectedBody = grabber.GetRigidBody(); joint.anchor = Vector3.zero; joint.connectedAnchor = grabber.GetJointAnchorPoint(); }
private void Start() { currentCooldown = 0; meshRenderer = GetComponent <MeshRenderer>(); if (thisControl == Controls.PAUSE) { if (BeatMap.IsRunning()) { meshRenderer.enabled = true; } else { meshRenderer.enabled = false; } } }
private void Update() { if (!gameObject.activeInHierarchy) { return; } if (isNoteDisplay) { Note note = GetComponentInParent <Note>(); if (note.noteDetails.inverted != BeatMap.Inverted) { gameObject.SetActive(false); } else { if (!gameObject.activeSelf) { gameObject.SetActive(true); } SetText(note.noteDetails.timeToSpawn.ToString()); } return; } else if (isBeatDisplay) { SetText(GetComponentInParent <BeatBar>().GetBeatNumber().ToString()); } else if (BeatMap.currentFrame % 15 == 0 && !isSaberdisplay) { string text = "Mode - " + BeatMap.GetCurrentState() + "\nCurrent Beat - " + BeatMap.GetCurrentBeat() + "\nRecord Mode - "; if (BeatMap.currentNoteMode == BeatMap.NoteMode.HalfNote) { text += "Half Notes"; } else if (BeatMap.currentNoteMode == BeatMap.NoteMode.QuarterNote) { text += "Quarter Notes"; } else if (BeatMap.currentNoteMode == BeatMap.NoteMode.WholeNote) { text += "Whole Notes"; } SetText(text); } }
public static BeatSaberJSONClass ConvertUnityDataToBSData(BeatMapData data) { BeatSaberJSONClass bsaberJSON = new BeatSaberJSONClass(); bsaberJSON.info = new InfoJSON(); bsaberJSON.info.beatsPerMinute = (int)data.beatsPerMinute; bsaberJSON.info.authorName = data.mapArtist; bsaberJSON.info.songSubName = data.songArtist; bsaberJSON.info.songName = data.songName; // TODO merge with existing info if any // bsaberJSON.info.difficultyLevels = new DifficultyLevel[1]; bsaberJSON.info.difficultyLevels[0] = DifficultyLevel.Generate(data.difficulty, data.songFileName, (int)data.songOffset); List <BSNote> notes = new List <BSNote>(); for (int count = 0; count < data.notes.Length; count++) { if (!data.notes[count].inverted) { BSNote bSNote = new BSNote(); if (data.notes[count].color == Note.NoteColor.LEFT) { bSNote._type = 0; } else { bSNote._type = 1; } bSNote._cutDirection = BSNote.GetBSaberCutDirection(data.notes[count].slashDirection); bSNote._lineIndex = (int)data.notes[count].gridPosition.x; bSNote._lineLayer = (int)data.notes[count].gridPosition.y; bSNote._time = data.notes[count].timeToSpawn; notes.Add(bSNote); } } BeatMap.Log("Notes exported with count " + notes.Count); LevelJSON level = new LevelJSON(); level._beatsPerMinute = (int)data.beatsPerMinute; level._version = "1.0"; level._beatsPerBar = 16; level._noteJumpSpeed = 10; level._shufflePeriod = .5f; level._notes = notes.ToArray(); bsaberJSON.level = level; return(bsaberJSON); }
private bool UnGrab() { IGrabbable grabbable = selector.GetAttachedObject().GetComponent <IGrabbable>(); if (grabbable == null) { grabbable = selector.GetAttachedObject().GetComponentInParent <IGrabbable>(); } if (grabbable != null) { grabbable.UnGrab(); } else { BeatMap.Log("Ungrab called on an object that doesn't have a grabbable " + selector.GetAttachedObject().name); } grabbing = false; return(true); }
public void SaveCurrentMapToDisk() { BeatMapData dataToSave = new BeatMapData(); if (beatMapData == null) { BeatMap.Log("Current map data not available to save"); return; } if (state != EditorState.Editing && state != EditorState.Recording && state != EditorState.PlaybackPaused) { BeatMap.Log("Call to save when not in proper state - " + state); return; } else { Debug.LogWarning("data song file name - " + beatMapData.songFileName); dataToSave = BeatMapData.CopyBMDNotNotes(dataToSave, beatMapData); float throwAwayFirstBeats = (dataToSave.beatsPerMinute / 16.5f); NoteDetails[] notes = GetAllNotes(true); List <NoteDetails> filtered = new List <NoteDetails>(); for (int count = 0; count < notes.Length; count++) { if (notes[count].timeToSpawn < throwAwayFirstBeats) { } else { Debug.LogWarning("Accepting note " + notes[count].timeToSpawn + "-" + notes[count].inverted); filtered.Add(notes[count]); } } Debug.LogWarning("Notes - " + notes.Length + " filtered - " + filtered.Count); dataToSave.notes = filtered.ToArray(); } Log("Call to save with # of notes " + dataToSave.notes.Length); Utilities.SaveToDisk(dataToSave); }
private void Update() { if (currentCooldown > 0) { currentCooldown += Time.deltaTime; } if (currentCooldown > cooldown) { currentCooldown = 0; } if (thisControl == Controls.PAUSE) { if (BeatMap.IsRunning() && !meshRenderer.enabled) { meshRenderer.enabled = true; } else if (!BeatMap.IsRunning() && meshRenderer.enabled) { meshRenderer.enabled = false; } } }
// Update is called once per frame void Update() { if (!textInitalized) { Initialize(); } if (!BeatMap.IsRunning()) { return; } if (gameObject.activeSelf) { if (!BeatMap.IsRewinding) { transform.position += (transform.forward * Note.noteSpeed) * Time.deltaTime; } else { transform.position -= (transform.forward * Note.noteSpeed) * Time.deltaTime; } } }
private bool Grab(GameObject gameObject) { BeatMap.Log("Saber called grab on " + gameObject.name); IGrabbable grabbable = gameObject.GetComponent <IGrabbable>(); if (grabbable == null) { grabbable = gameObject.GetComponentInParent <IGrabbable>(); } if (grabbable == null) { Debug.LogWarning("Object not grabbable - " + gameObject.name); return(false); } if (grabbable.IsGrabbed()) { Debug.LogWarning("Object already grabbed - " + gameObject.name); return(false); } grabbable.Grab(this); grabbing = true; addVibration(.5f, .5f, true); return(true); }
public void ResumeSong() { Debug.LogWarning("Resume called running, state " + running + "-" + BeatMap.state); if (!running) { if (beatManager.rewinding) { //Debug.Log("Current beat - " + currentBeat + " BPS - " + (beatMapData.beatsPerMinute / 60)); //Debug.Log("Setting to " + currentBeat * (beatMapData.beatsPerMinute / 60)); beatManager.SetRewinding(false); float skipToTime = beatManager.currentBeat / (beatMapData.beatsPerMinute / 60); if (skipToTime < 0) { skipToTime = 0; } audioSource.time = skipToTime; } SetRunning(true); if (state == EditorState.Editing) { SetCurrentState(EditorState.Recording); leftSaber.DetachSelector(); rightSaber.DetachSelector(); } else if (state == EditorState.PlaybackPaused) { SetCurrentState(EditorState.Playback); } // If we have a negative beat, don't start the song, let the update method handle it // if (!(BeatMap.GetCurrentBeat() < 0)) { audioSource.time = GetCurrentBeat() / beatManager.beatsPerSecond; audioSource.UnPause(); } } }
private void Update() { if (!initialized) { // Initialization // if (audioIsLoading) { AudioIsInitialized(); } } // INITIALIZED // else { // Start Update // currentFrame++; if (running) { beatManager.Update(); // Song may be completed // if ((state == EditorState.Playback || state == EditorState.Recording) && !audioSource.isPlaying) { PauseSong(); } if (mainCamera.transform.position.z >= showGuardAtZ && !guard.activeSelf) { guard.SetActive(true); BeatMap.Log("Guard activated"); PauseSong(); } } // Check if player is back in a good position and resume song // else if (guard.activeSelf && mainCamera.transform.position.z < showGuardAtZ) { guard.SetActive(false); BeatMap.Log("Guard deactivated"); ResumeSong(); } // If we're not running, we are done // else { return; } // Check if the next beat has started // if (beatManager.NextBeatStarted(true, mostRecentBeat)) { mostRecentBeat = beatManager.GetCurrentRelativeBeat(); // Check if any active notes are complete // foreach (Note note in activeNotes) { if ((note.transform.position.z < destroyNoteAtZ && !beatManager.rewinding) || (note.transform.position.z > spawnPositions[0, 0].z) && beatManager.rewinding) { note.gameObject.SetActive(false); if (!beatManager.rewinding) { completedNotes.Add(note.noteDetails); } else { waitingNotes.Add(note.noteDetails); } } } // Wait list is determined by rewinding // List <NoteDetails> waitList; if (!beatManager.rewinding) { waitList = waitingNotes; } else { waitList = completedNotes; } // Temp list for removing notes from waiting list // List <NoteDetails> notesDoneWaiting = new List <NoteDetails>(); for (int count = 0; count < waitList.Count; count++) { NoteDetails noteDetails = waitList[count]; float playerRelativeTimeToSpawn = beatManager.currentBeat + beatsToReachPlayer; if ((playerRelativeTimeToSpawn >= noteDetails.timeToSpawn && !beatManager.rewinding) || (beatManager.currentBeat <= noteDetails.timeToSpawn && beatManager.rewinding)) { Note note = noteDetails.note; if (note == null) { note = Instantiate(notePrefab).GetComponent <Note>(); } note.Initialize(noteDetails, materials, GetSpawnPosition(noteDetails.gridPosition, beatManager.rewinding)); note.transform.SetParent(NoteContainer.transform); notesDoneWaiting.Add(noteDetails); activeNotes.Add(note); note.Refresh(); } } foreach (NoteDetails note in notesDoneWaiting) { if (!beatManager.rewinding) { waitingNotes.Remove(note); } else { completedNotes.Remove(note); } } } } }
// Use this for initialization public void Initialize(int totalBeats, float beatsThatFit) { zPerBeat = (MAX_Z - MIN_Z) / totalBeats; changes = new List <NoteDetails>(); littleNoteMap = new Dictionary <NoteDetails, GameObject>(); currentWidthOfMinimap = 1; Debug.LogWarning("Minimap width - " + currentWidthOfMinimap); this.totalBeats = totalBeats; notes = BeatMap.GetAllNotes(true); GameObject container = new GameObject("NoteContainer"); container.transform.SetParent(transform); container.transform.localPosition = Vector3.zero; foreach (NoteDetails note in notes) { GameObject smallNote; if (note.color == Note.NoteColor.LEFT) { smallNote = Instantiate(noteRed); } else { smallNote = Instantiate(noteBlue); } smallNote.transform.SetParent(container.transform); smallNote.transform.localPosition = Vector3.zero; Vector3 newPosition = new Vector3( note.gridPosition.x / NoteSpacingXY, note.gridPosition.y / NoteSpacingXY, MIN_Z + note.timeToSpawn * zPerBeat); smallNote.transform.localPosition = newPosition; if (!showNotes) { smallNote.GetComponent <MeshRenderer>().enabled = false; } littleNoteMap.Add(note, smallNote); } GameObject barContainer = new GameObject("BarContainer"); barContainer.transform.SetParent(transform); barContainer.transform.position = transform.position; float startAtZ = barContainer.transform.position.z; currentTimeBar = Instantiate(miniBarPrefab).GetComponent <BeatBar>(); currentTimeBar.name = "TimeBar"; currentTimeBar.transform.SetParent(null); currentTimeBar.transform.position = new Vector3(1.306f, 1.47f, MAX_Z + .0447f); currentTimeBar.SetBeatNumber(0); BeatBar spawnPointBar = Instantiate(miniBarNoDisplayPrefab, currentTimeBar.transform) .GetComponent <BeatBar>(); float totalZ = beatsThatFit * zPerBeat; spawnPointBar.transform.localScale = Vector3.one; spawnPointBar.transform.localPosition = Vector3.zero; Vector3 newSpawnBarPosition = spawnPointBar.transform.position; newSpawnBarPosition.z += totalZ; spawnPointBar.transform.position = newSpawnBarPosition; SetZBasedOnBeat(BeatMap.GetCurrentBeat()); GameObject miniMapContainer = new GameObject("Minimap Container"); transform.SetParent(miniMapContainer.transform); initialized = true; }
private void ProcessControls(bool vrControls) { bool triggerCooldown = false; BeatMap.EditorState currentState = BeatMap.GetCurrentState(); if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger) || Input.GetKeyDown(KeyCode.Space) && !vrControls) { triggerDown = true; if (!BeatMap.Inverted) { map.InvertNotes(); } } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger) || Input.GetKeyUp(KeyCode.Space) && !vrControls) { triggerDown = false; if (BeatMap.Inverted) { map.InvertNotes(); } } else if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_ApplicationMenu) || Input.GetKeyDown(KeyCode.A) && !vrControls) { menuButtonDown = true; bool bothControllersPressing = otherSaber.menuButtonDown; if (bothControllersPressing) { if (currentState == BeatMap.EditorState.Editing || currentState == BeatMap.EditorState.PlaybackPaused) { map.ResumeSong(); triggerCooldown = true; return; } else if (currentState == BeatMap.EditorState.Playback || currentState == BeatMap.EditorState.Recording) { map.PauseSong(); triggerCooldown = true; return; } } else { if (currentState == BeatMap.EditorState.Editing) { if (selector.GetAttachedObject() != null) { Note note = selector.GetAttachedObject().GetComponent <Note>(); if (note != null) { if (!note.noteDetails.inverted) { note.MakeNeutral(); if (isLeft) { note.Invert(true); } DetachSelector(); triggerCooldown = true; } } } } } } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_ApplicationMenu) || Input.GetKeyUp(KeyCode.A) && !vrControls) { menuButtonDown = false; } if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyDown(KeyCode.Y) && !vrControls) { } if (vrControls && steamVRController.GetTouchDown(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyDown(KeyCode.T) && !vrControls) { if (currentState == BeatMap.EditorState.Recording) { BeatMap.currentNoteMode = BeatMap.NoteMode.HalfNote; } } else if (vrControls && steamVRController.GetTouchUp(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyUp(KeyCode.T) && !vrControls) { if (currentState == BeatMap.EditorState.Recording) { BeatMap.currentNoteMode = BeatMap.NoteMode.WholeNote; } } if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_Grip) || Input.GetKeyDown(KeyCode.G) && !vrControls) { if (gripHeldFor == 0) // Fresh push { if (selector.HasTarget()) { BeatMap.Log("Calling Grab on object " + selector.GetAttachedObject().name); Grab(selector.GetAttachedObject()); if (selector.GetAttachedObject().GetComponent <MiniMap>() != null) { map.PauseSong(); } triggerCooldown = true; } } gripHeldFor += Time.deltaTime; } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_Grip) || Input.GetKeyUp(KeyCode.G) && !vrControls) { BeatMap.Log("Grip let go, grabbing? " + grabbing); gripHeldFor = 0; if (grabbing) { UnGrab(); triggerCooldown = true; } } // KEYBOARD ONLY // if (!vrControls) { if (Input.GetKeyDown(KeyCode.W)) { transform.position += transform.forward; } else if (Input.GetKeyDown(KeyCode.A)) { transform.position += -transform.right; } else if (Input.GetKeyDown(KeyCode.S)) { transform.position += -transform.forward; } else if (Input.GetKeyDown(KeyCode.D)) { transform.position += transform.right; } else if (Input.GetKeyDown(KeyCode.Q)) { transform.position += transform.up; } else if (Input.GetKeyDown(KeyCode.E)) { transform.position += -transform.up; } else if (Input.GetKeyDown(KeyCode.RightArrow)) { BeatMap.SkipToBeat(BeatMap.GetCurrentBeat() + 10); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { BeatMap.SkipToBeat(BeatMap.GetCurrentBeat() - 10); } else if (Input.GetKeyDown(KeyCode.P) && !IsOnCoolDown() && isLeft) { triggerCooldown = true; if (BeatMap.GetCurrentState() == BeatMap.EditorState.Editing) { map.ResumeSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.PlaybackPaused) { map.ResumeSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.Playback) { map.PauseSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.Recording) { map.PauseSong(); } } } if (triggerCooldown) { currentCooldown += Time.deltaTime; } }
public static void SkipToBeat(float beat) { if (!(state == EditorState.PlaybackPaused || state == EditorState.Editing)) { Debug.LogWarning("SkipToBeat called when not in proper state -" + state); return; } BeatMap.Log("Skipping to beat " + beat); // Disable all active notes and bars on screen // foreach (Note note in activeNotes) { note.gameObject.SetActive(false); } // Reinitialize lists // waitingNotes = new List <NoteDetails>(); activeNotes = new List <Note>(); completedNotes = new List <NoteDetails>(); // Get the beat manager up to date // float noteSpeedInBeats = beatManager.GetNoteSpeedInBeats(); beatManager.SkipToBeat(beat, noteSpeedInBeats); float lastBeatToPlace = beatManager.GetClosestBeatToPlayer(); // List of notes that will be spawned as active // List <NoteDetails> notesToSpawn = new List <NoteDetails>(); // Check each note in our map data for notes that fall within the skipped time // for (int count = 0; count < beatMapData.notes.Length; count++) { if (beatMapData.notes[count].timeToSpawn <= beat && beatMapData.notes[count].timeToSpawn >= lastBeatToPlace) { notesToSpawn.Add(beatMapData.notes[count]); } else { if (beatMapData.notes[count].timeToSpawn < beat) { completedNotes.Add(beatMapData.notes[count]); } else { waitingNotes.Add(beatMapData.notes[count]); } } } // Place Notes // for (int count = 0; count < notesToSpawn.Count; count++) { Note note = notesToSpawn[count].note; if (note == null) { note = Instantiate(NotePrefab).GetComponent <Note>(); note.noteDetails = notesToSpawn[count]; } float spaceBetween = noteSpeedInBeats; Vector3 position = GetSpawnPosition(note.noteDetails.gridPosition); float adjustedSpawnTime = beat - note.noteDetails.timeToSpawn; position.z -= (adjustedSpawnTime * spaceBetween); position.z = RoundToRelativeBeat(position.z, currentNoteMode); note.Initialize(notesToSpawn[count], staticMats, position); activeNotes.Add(note); } SetRunning(false); MinimapInstance.SetZBasedOnBeat(beat); initialized = true; }
private void AddCollision(Hit collision) { BeatMap.Log("Hit - " + collision.point + " By - " + collision.saberColor.ToString()); collisions.Add(collision); }