Пример #1
0
 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;
     }
 }
Пример #2
0
 public void UpdateMe(BeatMap.EditorState currentState)
 {
     if (currentState != lastKnownState)
     {
         lastKnownState = currentState;
         Refresh();
     }
 }
Пример #3
0
        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);
                }
            }
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
 public void Initialize(BeatMap.EditorState currentState)
 {
     lastKnownState = currentState;
     initialized    = true;
 }