예제 #1
0
        public new void SpawnObstacle(ObstacleData obstacleData, Vector3 moveStartPos, Vector3 moveEndPos, Vector3 jumpEndPos, float moveDuration, float jumpDuration, float rotation, float noteLinesDistance, float obstacleHeight)
        {
            ObstacleController obstacleController = _obstaclePool.Spawn();

            SetObstacleEventCallbacks(obstacleController);
            obstacleController.transform.SetPositionAndRotation(moveStartPos, Quaternion.identity);
            obstacleController.Init(obstacleData, rotation, moveStartPos, moveEndPos, jumpEndPos, moveDuration, jumpDuration, noteLinesDistance, obstacleHeight);
        }
예제 #2
0
 public void Restart()
 {
     _score = 0;
     ObstacleController.Init();
     Dino.Init();
     GameOverArea.SetActive(false);
     TouchArea.SetActive(true);
     Time.timeScale = 1;
 }
예제 #3
0
        public override void BeatmapObjectSpawnCallback(BeatmapObjectData beatmapObjectData)
        {
            if (_disableSpawning)
            {
                return;
            }
            float num  = _moveDistance / _moveSpeed;
            float num2 = _jumpDistance / _noteJumpMovementSpeed;

            if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Obstacle)
            {
                ObstacleData obstacleData = (ObstacleData)beatmapObjectData;
                Vector3      forward      = transform.forward;
                Vector3      a            = transform.position;
                a += forward * (_moveDistance + _jumpDistance * 0.5f);
                Vector3 a2         = a - forward * _moveDistance;
                Vector3 a3         = a - forward * (_moveDistance + _jumpDistance);
                Vector3 noteOffset = GetNoteOffset(beatmapObjectData.lineIndex, NoteLineLayer.Base);
                noteOffset.y = ((obstacleData.obstacleType != ObstacleType.Top) ? _verticalObstaclePosY : (_topObstaclePosY + _globalYJumpOffset));
                ObstacleController.Pool pool = (obstacleData.obstacleType != ObstacleType.Top) ? _fullHeightObstaclePool : _topObstaclePool;
                ObstacleController      obstacleController = pool.Spawn();
                SetObstacleEventCallbacks(obstacleController);
                obstacleController.transform.SetPositionAndRotation(a + noteOffset, Quaternion.identity);
                obstacleController.Init(obstacleData, a + noteOffset, a2 + noteOffset, a3 + noteOffset, num, num2, beatmapObjectData.time - _spawnAheadTime, _noteLinesDistance);
                obstacleController.SetPrivateField("_playerController", owner);
                obstacleController.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                obstacleController.finishedMovementEvent += ResetControllers;
                obstacleController.didDissolveEvent      += ResetControllers;
                _activeObstacles.Add(obstacleController);
            }
            else
            {
                NoteData noteData = (NoteData)beatmapObjectData;
                Vector3  forward2 = transform.forward;
                Vector3  a4       = transform.position;
                a4 += forward2 * (_moveDistance + _jumpDistance * 0.5f);
                Vector3 a5 = a4 - forward2 * _moveDistance;
                Vector3 a6 = a4 - forward2 * (_moveDistance + _jumpDistance);
                if (noteData.noteLineLayer == NoteLineLayer.Top)
                {
                    a6 += forward2 * _topLinesZPosOffset * 2f;
                }
                Vector3 noteOffset2 = GetNoteOffset(noteData.lineIndex, noteData.startNoteLineLayer);
                float   jumpGravity = JumpGravityForLineLayer(noteData.noteLineLayer, noteData.startNoteLineLayer);
                if (noteData.noteType == NoteType.Bomb)
                {
                    NoteController bombNoteController = _bombNotePool.Spawn();
                    SetNoteControllerEventCallbacks(bombNoteController);
                    bombNoteController.transform.SetPositionAndRotation(a4 + noteOffset2, Quaternion.identity);
                    bombNoteController.Init(noteData, a4 + noteOffset2, a5 + noteOffset2, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity);
                    var noteJump = bombNoteController.GetComponent <NoteJump>();
                    noteJump.SetPrivateField("_playerController", owner);
                    noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    bombNoteController.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    bombNoteController.noteDidFinishJumpEvent += ResetControllers;
                    bombNoteController.noteWasCutEvent        += ResetControllersNoteWasCut;
                    bombNoteController.noteDidDissolveEvent   += ResetControllers;
                    _activeNotes.Add(bombNoteController);
                }
                else if (noteData.noteType.IsBasicNote())
                {
                    NoteController.Pool pool2 = (noteData.noteType != NoteType.NoteA) ? _noteBPool : _noteAPool;
                    NoteController      basicNoteController = pool2.Spawn();
                    SetNoteControllerEventCallbacks(basicNoteController);
                    Vector3 noteOffset3 = GetNoteOffset(noteData.flipLineIndex, noteData.startNoteLineLayer);
                    basicNoteController.transform.SetPositionAndRotation(a4 + noteOffset3, Quaternion.identity);
                    GameNoteController gameNoteController = basicNoteController as GameNoteController;
                    if (gameNoteController != null)
                    {
                        gameNoteController.Init(noteData, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity, _disappearingArrows, _ghostNotes);
                    }
                    else
                    {
                        basicNoteController.Init(noteData, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity);
                    }
                    var noteJump = basicNoteController.GetComponent <NoteJump>();
                    noteJump.SetPrivateField("_playerController", owner);
                    noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    basicNoteController.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    basicNoteController.GetComponentsInChildren <BoxCollider>().First(x => x.name == "BigCuttable").size   = _defaultBigCuttableSize * 1.65f;
                    basicNoteController.GetComponentsInChildren <BoxCollider>().First(x => x.name == "SmallCuttable").size = _defaultSmallCuttableSize * 1.65f;
                    basicNoteController.noteDidFinishJumpEvent += ResetControllers;
                    basicNoteController.noteWasCutEvent        += ResetControllersNoteWasCut;
                    basicNoteController.noteDidDissolveEvent   += ResetControllers;
                    _prevSpawnedNormalNoteController            = basicNoteController;
                    _activeNotes.Add(basicNoteController);
                }
            }
        }
예제 #4
0
        public override void SpawnBeatmapObject(BeatmapObjectData beatmapObjectData)
        {
            if (_disableSpawning)
            {
                return;
            }

            float num  = _moveDistance / _moveSpeed;
            float num2 = _jumpDistance / _noteJumpMovementSpeed;

            if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Obstacle)
            {
                ObstacleData obstacleData = (ObstacleData)beatmapObjectData;
                Vector3      forward      = transform.forward;
                Vector3      a            = transform.position;
                a += forward * (_moveDistance + _jumpDistance * 0.5f);
                Vector3 a2         = a - forward * _moveDistance;
                Vector3 a3         = a - forward * (_moveDistance + _jumpDistance);
                Vector3 noteOffset = GetNoteOffset(beatmapObjectData.lineIndex, NoteLineLayer.Base);
                noteOffset.y = ((obstacleData.obstacleType == ObstacleType.Top) ? (_topObstaclePosY + _globalJumpOffsetY) : _verticalObstaclePosY);
                float height = (obstacleData.obstacleType == ObstacleType.Top) ? _topObstacleHeight : _verticalObstacleHeight;
                ObstacleController obstacleController = _obstaclePool.Spawn();
                SetObstacleEventCallbacks(obstacleController);
                obstacleController.transform.SetPositionAndRotation(a + noteOffset, Quaternion.identity);
                obstacleController.Init(obstacleData, _spawnRotationProcesser.rotation, a + noteOffset, a2 + noteOffset, a3 + noteOffset, num, num2, beatmapObjectData.time - _spawnAheadTime, _noteLinesDistance, height);
                obstacleController.SetPrivateField("_playerController", owner);
                obstacleController.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                obstacleController.finishedMovementEvent += ResetControllers;
                obstacleController.didDissolveEvent      += ResetControllers;
                _activeObstacles.Add(obstacleController);

                this.GetPrivateField <Action <BeatmapObjectSpawnController, ObstacleController> >("obstacleDiStartMovementEvent")?.Invoke(this, obstacleController);
            }
            else
            {
                NoteData noteData = (NoteData)beatmapObjectData;
                Vector3  forward2 = transform.forward;
                Vector3  a4       = transform.position;
                a4 += forward2 * (_moveDistance + _jumpDistance * 0.5f);
                Vector3 a5 = a4 - forward2 * _moveDistance;
                Vector3 a6 = a4 - forward2 * (_moveDistance + _jumpDistance);
                if (noteData.noteLineLayer == NoteLineLayer.Top)
                {
                    a6 += forward2 * _topLinesZPosOffset * 2f;
                }
                Vector3 noteOffset2 = GetNoteOffset(noteData.lineIndex, noteData.startNoteLineLayer);
                float   jumpGravity = JumpGravityForLineLayer(noteData.noteLineLayer, noteData.startNoteLineLayer);
                if (noteData.noteType == NoteType.Bomb)
                {
                    NoteController noteController = _bombNotePool.Spawn();
                    SetNoteControllerEventCallbacks(noteController);
                    noteController.transform.SetPositionAndRotation(a4 + noteOffset2, Quaternion.identity);
                    noteController.Init(noteData, _spawnRotationProcesser.rotation, a4 + noteOffset2, a5 + noteOffset2, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity);

                    var noteJump = noteController.GetComponent <NoteJump>();
                    noteJump.SetPrivateField("_playerController", owner);
                    noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    noteController.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    noteController.noteDidFinishJumpEvent += ResetControllers;
                    noteController.noteWasCutEvent        += ResetControllersNoteWasCut;
                    noteController.noteDidDissolveEvent   += ResetControllers;
                    _activeNotes.Add(noteController);
                }
                else if (noteData.noteType.IsBasicNote())
                {
                    MemoryPool <NoteController> memoryPool = (noteData.noteType == NoteType.NoteA) ? _noteAPool : _noteBPool;
                    if (_numberOfSpawnedBasicNotes == 0)
                    {
                        _firstBasicNoteTime = noteData.time;
                    }
                    bool           flag            = _firstBasicNoteTime == noteData.time;
                    NoteController noteController2 = memoryPool.Spawn();
                    SetNoteControllerEventCallbacks(noteController2);
                    Vector3 noteOffset3 = GetNoteOffset(noteData.flipLineIndex, noteData.startNoteLineLayer);
                    noteController2.transform.SetPositionAndRotation(a4 + noteOffset3, Quaternion.identity);
                    GameNoteController gameNoteController = noteController2 as GameNoteController;
                    if (gameNoteController != null)
                    {
                        gameNoteController.Init(noteData, _spawnRotationProcesser.rotation, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity, _disappearingArrows, _ghostNotes && !flag);
                    }
                    else
                    {
                        noteController2.Init(noteData, _spawnRotationProcesser.rotation, a4 + noteOffset3, a5 + noteOffset3, a6 + noteOffset2, num, num2, noteData.time - _spawnAheadTime, jumpGravity);
                    }

                    var noteJump = noteController2.GetComponent <NoteJump>();
                    noteJump.SetPrivateField("_playerController", owner);
                    noteJump.SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    noteController2.GetComponent <NoteFloorMovement>().SetPrivateField("_audioTimeSyncController", onlineSyncController);
                    noteController2.noteDidFinishJumpEvent += ResetControllers;
                    noteController2.noteWasCutEvent        += ResetControllersNoteWasCut;
                    noteController2.noteDidDissolveEvent   += ResetControllers;

                    _activeNotes.Add(noteController2);
                    _numberOfSpawnedBasicNotes++;
                    if (_prevSpawnedNormalNoteController != null)
                    {
                        float time  = _prevSpawnedNormalNoteController.noteData.time;
                        float time2 = noteController2.noteData.time;
                    }
                    _prevSpawnedNormalNoteController = noteController2;
                }
            }
            this.GetPrivateField <Action <BeatmapObjectSpawnController, BeatmapObjectData, float, float> >("beatmapObjectWasSpawnedEvent")?.Invoke(this, beatmapObjectData, num, num2);
        }
예제 #5
0
        private static bool Prefix(BeatmapObjectSpawnController __instance, BeatmapObjectData beatmapObjectData, ref bool ____disableSpawning, ref float ____moveDistance, ref float ____moveSpeed, ref float ____jumpDistance, ref float ____noteJumpMovementSpeed, ref float ____topObstaclePosY, ref float ____globalYJumpOffset, ref float ____verticalObstaclePosY, ref ObstacleController.Pool ____obstaclePool, ref float ____spawnAheadTime, ref float ____noteLinesDistance, ref Action <BeatmapObjectSpawnController, ObstacleController> ___obstacleDiStartMovementEvent, ref float ____topLinesZPosOffset, ref NoteController.Pool ____bombNotePool, ref NoteController.Pool ____noteAPool, ref NoteController.Pool ____noteBPool, ref int ____numberOfSpawnedBasicNotes, ref float ____firstBasicNoteTime, ref NoteController ____prevSpawnedNormalNoteController, ref bool ____disappearingArrows, ref bool ____ghostNotes, ref Action <BeatmapObjectSpawnController, BeatmapObjectData, float, float> ___beatmapObjectWasSpawnedEvent,
                                   ref float ____topObstacleHeight, ref float ____verticalObstacleHeight)
        {
            if (!Plugin.active)
            {
                return(true);
            }

            float      angleFloat;
            Quaternion angle = ExtraBeatmapData.beatmapObjectsAngles.TryGetValue(beatmapObjectData.id, out angleFloat) ? Quaternion.Euler(0f, angleFloat, 0f) : Quaternion.identity;

            if (____disableSpawning)
            {
                return(false);
            }

            float num2 = ____moveDistance / ____moveSpeed;
            float num3 = ____jumpDistance / ____noteJumpMovementSpeed;

            if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Obstacle)
            {
                ObstacleData obstacleData = (ObstacleData)beatmapObjectData;
                Vector3      forward      = __instance.transform.forward;
                Vector3      vector       = __instance.transform.position;
                vector += forward * (____moveDistance + ____jumpDistance * 0.5f);
                Vector3 vector2    = vector - forward * ____moveDistance;
                Vector3 vector3    = vector - forward * (____moveDistance + ____jumpDistance);
                Vector3 noteOffset = __instance.GetNoteOffset(beatmapObjectData.lineIndex, NoteLineLayer.Base);
                noteOffset.y = ((obstacleData.obstacleType == ObstacleType.Top) ? (____topObstaclePosY + ____globalYJumpOffset) : ____verticalObstaclePosY);

                float height = (obstacleData.obstacleType == ObstacleType.Top) ? ____topObstacleHeight : ____verticalObstacleHeight;
                ObstacleController obstacleController = ____obstaclePool.Spawn();
                __instance.SetObstacleEventCallbacks(obstacleController);
                obstacleController.transform.SetPositionAndRotation(angle * (vector + noteOffset), angle);
                obstacleController.Init(obstacleData, angle * (vector + noteOffset), angle * (vector2 + noteOffset), angle * (vector3 + noteOffset), num2, num3, beatmapObjectData.time - ____spawnAheadTime, ____noteLinesDistance, height);

                ___obstacleDiStartMovementEvent?.Invoke(__instance, obstacleController);
            }
            else
            {
                NoteData noteData = (NoteData)beatmapObjectData;
                Vector3  forward2 = __instance.transform.forward;
                Vector3  vector4  = __instance.transform.position;
                vector4 += forward2 * (____moveDistance + ____jumpDistance * 0.5f);
                Vector3 vector5 = vector4 - forward2 * ____moveDistance;
                Vector3 vector6 = vector4 - forward2 * (____moveDistance + ____jumpDistance);

                if (noteData.noteLineLayer == NoteLineLayer.Top)
                {
                    vector6 += forward2 * ____topLinesZPosOffset * 2f;
                }
                Vector3 noteOffset2 = __instance.GetNoteOffset(noteData.lineIndex, noteData.startNoteLineLayer);
                float   jumpGravity = __instance.JumpGravityForLineLayer(noteData.noteLineLayer, noteData.startNoteLineLayer);

                if (noteData.noteType == NoteType.Bomb)
                {
                    NoteController noteController = ____bombNotePool.Spawn();
                    __instance.SetNoteControllerEventCallbacks(noteController);
                    noteController.transform.SetPositionAndRotation(angle * (vector4 + noteOffset2), angle);
                    lastSpawnedObjectId = beatmapObjectData.id;
                    noteController.Init(noteData, angle * (vector4 + noteOffset2), angle * (vector5 + noteOffset2), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity);
                }
                else
                {
                    if (noteData.noteType.IsBasicNote())
                    {
                        MemoryPool <NoteController> memoryPool = (noteData.noteType == NoteType.NoteA) ? ____noteAPool : ____noteBPool;

                        if (____numberOfSpawnedBasicNotes == 0)
                        {
                            ____firstBasicNoteTime = noteData.time;
                        }

                        bool isFirstNote = ____firstBasicNoteTime == noteData.time;

                        NoteController noteController2 = memoryPool.Spawn();
                        __instance.SetNoteControllerEventCallbacks(noteController2);
                        Vector3 noteOffset3 = __instance.GetNoteOffset(noteData.flipLineIndex, noteData.startNoteLineLayer);
                        noteController2.transform.SetPositionAndRotation(angle * (vector4 + noteOffset3), angle);
                        GameNoteController gameNoteController = noteController2 as GameNoteController;
                        lastSpawnedObjectId = beatmapObjectData.id;

                        if (gameNoteController != null)
                        {
                            gameNoteController.Init(noteData, angle * (vector4 + noteOffset3), angle * (vector5 + noteOffset3), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity, ____disappearingArrows, ____ghostNotes && !isFirstNote);
                        }
                        else
                        {
                            noteController2.Init(noteData, angle * (vector4 + noteOffset3), angle * (vector5 + noteOffset3), angle * (vector6 + noteOffset2), num2, num3, noteData.time - ____spawnAheadTime, jumpGravity);
                        }
                        ____numberOfSpawnedBasicNotes++;

                        if (____prevSpawnedNormalNoteController != null)
                        {
                            float time  = ____prevSpawnedNormalNoteController.noteData.time;
                            float time2 = noteController2.noteData.time;
                        }
                        ____prevSpawnedNormalNoteController = noteController2;
                    }
                }
            }
            ___beatmapObjectWasSpawnedEvent?.Invoke(__instance, beatmapObjectData, num2, num3);
            return(false);
        }