示例#1
0
        public virtual void HandleNoteWasCutEvent(BeatmapObjectSpawnController noteSpawnController, NoteController noteController, NoteCutInfo noteCutInfo)
        {
            try
            {
                Vector3 notePos = noteController.noteTransform.position;

                Vector3 leftPos = _playerController.leftSaber.transform.position;
                leftPos += _playerController.leftSaber.transform.forward * 0.5f;
                Vector3 rightPos = _playerController.rightSaber.transform.position;
                rightPos += _playerController.rightSaber.transform.forward * 0.5f;

                float leftDist  = Vector3.Distance(leftPos, notePos);
                float rightDist = Vector3.Distance(rightPos, notePos);

                _mainSettingsModel.controllersRumbleEnabled = true;
                Saber.SaberType targetType = (leftDist > rightDist) ? Saber.SaberType.SaberB : Saber.SaberType.SaberA;
                _noteCutHapticEffect.RumbleController(targetType);
                _mainSettingsModel.controllersRumbleEnabled = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#2
0
        private void SpawnController_ScaleRemoveCut(BeatmapObjectSpawnController arg1, NoteController controller, NoteCutInfo arg3)
        {
            NoteData  note          = controller.noteData;
            Transform noteTransform = controller.GetField <Transform>("_noteTransform");

            //      Log("DESPAWN" + noteTransform.localScale.ToString());
            if (noteTransform.localScale.x != 1)
            {
                noteTransform.localScale = new Vector3(1f, 1f, 1f);
            }
            //          Log("DESPAWN" + noteTransform.localScale.ToString());



            //     if (modifiedNotes[note.id] != null)
            //          note = modifiedNotes[note.id];

            FloatBehavior behavior = noteTransform.gameObject.GetComponent <FloatBehavior>();

            if (behavior != null)
            {
                noteTransform.localPosition = new Vector3(behavior.originalX, behavior.originalY, noteTransform.localPosition.z);
                GameObject.Destroy(behavior);
            }


            if (GMPUI.oneColor)
            {
                if (!defaultRumble)
                {
                    return;
                }
                _noteCutEffectSpawner = UnityEngine.Object.FindObjectOfType <NoteCutEffectSpawner>();
                if (_noteCutEffectSpawner != null)
                {
                    _noteCutHapticEffect = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect");
                }
                if (_noteCutHapticEffect != null)
                {
                    _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController");
                }
                if (_hapticFeedbackController != null)
                {
                    _mainSettingsModelOneC = ReflectionUtil.GetPrivateField <MainSettingsModel>(_hapticFeedbackController, "_mainSettingsModel");
                }

                if (_mainSettingsModelOneC == null)
                {
                    return;
                }
                Vector3 notePos = controller.noteTransform.position;

                Vector3 leftPos = player.leftSaber.transform.position;
                leftPos += player.leftSaber.transform.forward * 0.5f;
                Vector3 rightPos = player.rightSaber.transform.position;
                rightPos += player.rightSaber.transform.forward * 0.5f;

                float leftDist  = Vector3.Distance(leftPos, notePos);
                float rightDist = Vector3.Distance(rightPos, notePos);
                // Log(leftDist.ToString() + "   " + rightDist.ToString());
                _mainSettingsModelOneC.controllersRumbleEnabled = true;
                Saber.SaberType targetType = (leftDist > rightDist) ? Saber.SaberType.SaberB : Saber.SaberType.SaberA;
                if (!(Mathf.Abs(leftDist - rightDist) <= 0.2f))
                {
                    _noteCutHapticEffect.RumbleController(targetType);
                }
                else
                {
                    _noteCutHapticEffect.RumbleController(Saber.SaberType.SaberA);
                    _noteCutHapticEffect.RumbleController(Saber.SaberType.SaberB);
                }
                _mainSettingsModel.controllersRumbleEnabled = false;
            }
        }