Пример #1
0
        public override void Init()
        {
            base.Init();

            m_highwayControl = new HighwayControl(HighwayControlConfig.CreateDefaultKsh168());
            m_background.Init();

            m_playback = new SlidingChartPlayback(m_chart);
            m_playback.ObjectHeadCrossPrimary += (dir, obj) =>
            {
                if (dir == PlayDirection.Forward)
                {
                    m_highwayView.RenderableObjectAppear(obj);
                }
                else
                {
                    m_highwayView.RenderableObjectDisappear(obj);
                }
            };
            m_playback.ObjectTailCrossSecondary += (dir, obj) =>
            {
                if (dir == PlayDirection.Forward)
                {
                    m_highwayView.RenderableObjectDisappear(obj);
                }
                else
                {
                    m_highwayView.RenderableObjectAppear(obj);
                }
            };

            // TODO(local): Effects wont work with backwards motion, but eventually the
            //  editor (with the only backwards motion support) will pre-render audio instead.
            m_playback.ObjectHeadCrossCritical += (dir, obj) =>
            {
                if (dir != PlayDirection.Forward)
                {
                    return;
                }

                if (obj is ChartEvent evt)
                {
                    PlaybackEventTrigger(evt, dir);
                }
                else
                {
                    PlaybackObjectBegin(obj);
                }
            };
            m_playback.ObjectTailCrossCritical += (dir, obj) =>
            {
                if (dir == PlayDirection.Backward && obj is ChartEvent evt)
                {
                    PlaybackEventTrigger(evt, dir);
                }
                else
                {
                    PlaybackObjectEnd(obj);
                }
            };

            m_highwayView.ViewDuration = m_playback.LookAhead;

            ForegroundGui = new Panel()
            {
                Children = new GuiElement[]
                {
                    m_critRoot     = new CriticalLine(m_resources),
                    m_comboDisplay = new ComboDisplay(m_resources)
                    {
                        RelativePositionAxes = Axes.Both,
                        Position             = new Vector2(0.5f, 0.7f)
                    },
                }
            };

            m_judge = new MasterJudge(m_chart);
            for (int i = 0; i < 6; i++)
            {
                int stream = i;

                var judge = (ButtonJudge)m_judge[i];
                //judge.JudgementOffset = 0.032;
                judge.JudgementOffset  = Plugin.Config.GetInt(NscConfigKey.InputOffset) / 1000.0f;
                judge.AutoPlay         = AutoButtons;
                judge.OnChipPressed   += Judge_OnChipPressed;
                judge.OnTickProcessed += Judge_OnTickProcessed;
                judge.OnHoldPressed   += Judge_OnHoldPressed;
                judge.OnHoldReleased  += Judge_OnHoldReleased;
            }

            m_highwayControl = new HighwayControl(HighwayControlConfig.CreateDefaultKsh168());
            m_highwayView.Reset();

            m_audio.Volume    = 0.8f;
            m_audio.Position  = m_chart.Offset;
            m_audioController = new AudioEffectController(8, m_audio, true)
            {
                RemoveFromChannelOnFinish = true,
            };
            m_audioController.Finish += () =>
            {
                Logger.Log("track complete");
                Host.PopToParent(this);
            };

            time_t firstObjectTime = double.MaxValue;

            for (int s = 0; s < m_chart.StreamCount; s++)
            {
                firstObjectTime = MathL.Min((double)firstObjectTime, m_chart.ObjectStreams[s].FirstObject?.AbsolutePosition.Seconds ?? double.MaxValue);
            }

            m_audioController.Position = MathL.Min(0.0, (double)firstObjectTime - 2);
            m_audioController.Play();
        }
Пример #2
0
        public override void Initialize()
        {
            base.Initialize();

            m_highwayControl = new HighwayControl(HighwayControlConfig.CreateDefaultKsh168());
            //m_script.CallIfExists("init");
            m_background.Init();

            SetHiSpeed();

            m_audioPlayback.ObjectHeadCrossPrimary += (dir, entity) =>
            {
                if (dir == PlayDirection.Forward)
                {
                    if (entity is EventEntity evt)
                    {
                        switch (evt)
                        {
                        case SpinImpulseEvent _:
                        case SwingImpulseEvent _:
                        case WobbleImpulseEvent _:
                            m_queuedSlamTiedEvents.Add(evt);
                            break;
                        }
                    }
                }
            };
            m_visualPlayback.ObjectHeadCrossPrimary += (dir, entity) =>
            {
                if (dir == PlayDirection.Forward)
                {
                    m_highwayView.RenderableObjectAppear(entity);
                }
                else
                {
                    m_highwayView.RenderableObjectDisappear(entity);
                }
            };
            m_visualPlayback.ObjectTailCrossSecondary += (dir, obj) =>
            {
                if (dir == PlayDirection.Forward)
                {
                    m_highwayView.RenderableObjectDisappear(obj);
                }
                else
                {
                    m_highwayView.RenderableObjectAppear(obj);
                }
            };

            // TODO(local): Effects wont work with backwards motion, but eventually the
            //  editor (with the only backwards motion support) will pre-render audio instead.
            m_audioPlayback.ObjectHeadCrossCritical += (dir, obj) =>
            {
                if (dir != PlayDirection.Forward)
                {
                    return;
                }

                if (obj is EventEntity evt)
                {
                    PlaybackEventTrigger(evt, dir);
                }
                else
                {
                    PlaybackObjectBegin(obj);
                }
            };
            m_audioPlayback.ObjectTailCrossCritical += (dir, obj) =>
            {
                if (dir == PlayDirection.Backward && obj is EventEntity evt)
                {
                    PlaybackEventTrigger(evt, dir);
                }
                else
                {
                    PlaybackObjectEnd(obj);
                }
            };
            m_visualPlayback.ObjectHeadCrossCritical += (dir, obj) =>
            {
                if (dir != PlayDirection.Forward)
                {
                    return;
                }

                if (obj is EventEntity evt)
                {
                    PlaybackVisualEventTrigger(evt, dir);
                }
            };
            m_visualPlayback.ObjectTailCrossCritical += (dir, obj) =>
            {
                if (dir == PlayDirection.Backward && obj is EventEntity evt)
                {
                    PlaybackVisualEventTrigger(evt, dir);
                }
            };

            m_judge = new MasterJudge(m_chart, m_gaugeType);
            for (int i = 0; i < 6; i++)
            {
                var judge = (ButtonJudge)m_judge[i];
                judge.JudgementOffset  = NscConfig.InputOffset / 1000.0f;
                judge.AutoPlay         = AutoButtons;
                judge.OnChipPressed   += Judge_OnChipPressed;
                judge.OnTickProcessed += Judge_OnTickProcessed;
                judge.OnHoldPressed   += Judge_OnHoldPressed;
                judge.OnHoldReleased  += Judge_OnHoldReleased;
                judge.SpawnKeyBeam     = CreateKeyBeam;
            }
            for (int i = 0; i < 2; i++)
            {
                int iStack = i;

                var judge = (LaserJudge)m_judge[i + 6];
                judge.JudgementOffset  = NscConfig.InputOffset / 1000.0f;
                judge.AutoPlay         = AutoLasers;
                judge.OnShowCursor    += () => m_cursorsActive[iStack] = true;
                judge.OnHideCursor    += () => m_cursorsActive[iStack] = false;
                judge.OnTickProcessed += (e, when, result) => Judge_OnTickProcessed(e, when, result, false);
                judge.OnSlamHit       += (position, entity) =>
                {
                    if (position < entity.AbsolutePosition)
                    {
                        m_queuedSlamSamples.Add(entity.AbsolutePosition);
                    }
                    else
                    {
                        m_slamSample.Replay();
                    }
                };
            }

            m_highwayControl = new HighwayControl(HighwayControlConfig.CreateDefaultKsh168());
            m_highwayView.Reset();

            //m_audio.Volume = 0.8f;
            m_audio.Position  = 0.0;
            m_audioController = new AudioEffectController(8, m_audio, true)
            {
                RemoveFromChannelOnFinish = true,
            };
            m_audioController.Finish += () =>
            {
                Logger.Log("track complete");
                ExitGame();
            };

            m_audioController.Position = MathL.Min(0.0, (double)m_chart.TimeStart - 2);

            m_gameTable["Begin"] = (Action)Begin;
            //m_script.CallIfExists("Init");

            ClientAs <NscClient>().OpenCurtain();
            Begin();
        }