Beispiel #1
0
        internal void ApplySamplesets(HitCircleFruits fruit, int index)
        {
            HitSoundInfo hitSoundInfo = GetHitSoundInfo(index);

            fruit.SampleSet          = hitSoundInfo.SampleSet;
            fruit.SampleSetAdditions = hitSoundInfo.SampleSetAdditions;
        }
        public bool CheckCondition(HitSoundInfo hitSoundInfo)
        {
            if (SampleSet != SampleSetType.All &&
                hitSoundInfo.SampleSet != SampleSet && SampleSet != hitSoundInfo.SampleSetAdditions)
            {
                return(false);
            }

            if (SampleSetAdditions != SampleSetType.All && hitSoundInfo.SampleSetAdditions != SampleSetAdditions)
            {
                return(false);
            }

            //storybrew可能塞了个HitSound为None的玩意
            if (hitSoundInfo.SoundType == HitObjectSoundType.None || !ContainFlagEnum(HitSound, hitSoundInfo.SoundType))
            {
                return(false);
            }

            if (CustomSampleSet != CustomSampleSetType.Default && hitSoundInfo.CustomSampleSet != CustomSampleSet)
            {
                return(false);
            }

            return(true);

            bool ContainFlagEnum <T>(T source, T compare_with) where T : Enum =>
            Enum.GetValues(typeof(T)).Cast <T>().Any(val => source.HasFlag(val) && compare_with.HasFlag(val) && Convert.ToInt32(val) != 0);
        }
Beispiel #3
0
        private void buttonClap_Click(object sender, EventArgs e)
        {
            HitSoundInfo info = GetSampleset();

            info.SoundType = HitObjectSoundType.Clap;
            AudioEngine.PlayHitSamples(info, 0, false);
        }
        /// <summary>
        /// For AutoTrigger. optimze/trim HitSounds.
        /// </summary>
        /// <param name="hit_sound"></param>
        /// <returns></returns>
        public bool CheckTrig(HitSoundInfo hit_sound)
        {
            if (hit_sound.Time == 50507)
            {
            }

            foreach (var obj in register_trigger_objects.Where(o => o.FrameStartTime <= hit_sound.Time && hit_sound.Time <= o.FrameEndTime))
            {
                foreach (var pair in obj.Triggers)
                {
                    var commands = PickVaildTriggers(pair.Key, pair.Value, (float)hit_sound.Time).ToList();

                    foreach (var cmd in commands)
                    {
                        if (cmd?.Condition is HitSoundTriggerCondition condition &&
                            condition.CheckCondition(hit_sound))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #5
0
        internal void InvokeOnHitSound(HitSoundInfo hitSoundInfo)
        {
            HitSoundDelegate sound = OnHitSound;

            if (sound != null)
            {
                sound(hitSoundInfo);
            }
        }
        public void Trig(HitSoundInfo hit_sound, float current_time)
        {
            foreach (var obj in register_trigger_objects.Where(o => o.FrameStartTime <= current_time && current_time <= o.FrameEndTime))
            {
                foreach (var pair in obj.Triggers)
                {
                    var commands = PickVaildTriggers(pair.Key, pair.Value, current_time).ToList();

                    foreach (var cmd in commands)
                    {
                        if (cmd?.Condition is HitSoundTriggerCondition condition &&
                            condition.CheckCondition(hit_sound))
                        {
                            cmd.Trig(current_time);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        internal override Slider CreateSlider(Vector2 startPosition, int startTime, bool newCombo,
                                              HitObjectSoundType soundType, CurveTypes curveType, int repeatCount, double sliderLength, List <Vector2> sliderPoints, List <HitObjectSoundType> soundTypes, int comboOffset,
                                              SampleSet sampleSet, SampleSet addSet, List <SampleSet> sampleSets, List <SampleSet> sampleSetAdditions, CustomSampleSet customSampleSet, int volume, string sampleFile)
        {
            SliderOsu s = new SliderOsu(hitObjectManager, startPosition, startTime, newCombo, soundType, curveType, repeatCount, sliderLength, sliderPoints, soundTypes, comboOffset);

            s.SampleSet          = sampleSet;
            s.SampleSetAdditions = addSet;

            s.SampleSetList         = sampleSets;
            s.SampleSetAdditionList = sampleSetAdditions;
            s.CustomSampleSet       = customSampleSet;
            s.SampleVolume          = volume;
            s.ProcessSampleFile(sampleFile);

            if (s.sliderStartCircle != null)
            {
                HitSoundInfo hitsoundInfo = s.GetHitSoundInfo(0);
                s.sliderStartCircle.SampleSet          = hitsoundInfo.SampleSet;
                s.sliderStartCircle.SampleSetAdditions = hitsoundInfo.SampleSetAdditions;
            }

            return(s);
        }
Beispiel #8
0
        internal override void OnClick(HitObject h)
        {
            HitCircleTaiko hc = h as HitCircleTaiko;
            SliderTaiko    sl = h as SliderTaiko;
            SpinnerTaiko   sp = h as SpinnerTaiko;

            if ((hc != null && hc.scoreValue > 0) || (sl != null && sl.LastHitSuccessful))
            {
                pTexture bg;
                pTexture overlay;

                if (hc != null)
                {
                    bg      = hc.SpriteHitCircle1.Texture;
                    overlay = hc.SpriteHitCircle2.Texture;
                }
                else
                {
                    bg      = sl.sliderStartCircle.SpriteHitCircle1.Texture;
                    overlay = sl.sliderStartCircle.SpriteHitCircle2.Texture;
                }

                float depth = 1 - 0.03f * SpriteManager.drawOrderBwd(h != null ? h.StartTime : 0.1f) / 0.8f;

                pSprite s =
                    new pSprite(bg, Fields.GamefieldWide, Origins.Centre,
                                Clocks.Audio, HitObjectManagerTaiko.HIT_LOCATION,
                                depth, true,
                                h != null ? h.Colour : new Color(252, 184, 6));
                s.Scale = h != null ? h.SpriteCollection[0].Scale : 0.7f;
                spriteManagerWidescreen.Add(s);
                s.InitialPosition.X = GameBase.GameField.DisplayToFieldXWide(HpBar.CurrentXPosition);

                s.TagNumeric = 169;
                flyingCircles.Add(s);

                s =
                    new pSprite(overlay, Fields.GamefieldWide, Origins.Centre,
                                Clocks.Audio, HitObjectManagerTaiko.HIT_LOCATION,
                                depth + 0.0001f, true, Color.White);
                s.Scale             = h != null ? h.SpriteCollection[0].Scale : 0.7f;
                s.InitialPosition.X = GameBase.GameField.DisplayToFieldXWide(HpBar.CurrentXPosition);
                s.TagNumeric        = 169;
                spriteManagerWidescreen.Add(s);
                flyingCircles.Add(s);

                if (Player.KiaiActive)
                {
                    s_KiaiGlow.Transformations.RemoveAll(t => t.Type == TransformationType.Scale);
                    s_KiaiGlow.Transformations.Add(new Transformation(TransformationType.Scale, 0.85f, 0.7f, GameBase.Time, GameBase.Time + 80, EasingTypes.Out));
                }
            }

            //where we store the old values,
            //we set them to false to make the compiler happy
            bool oldLeftButton1i = false;
            bool oldLeftButton2i = false;

            bool oldRightButton1i = false;
            bool oldRightButton2i = false;


            //temporarilly change the buttons to the right ones if relaxed is on.
            if (Player.Relaxing && hc != null)
            {
                oldLeftButton1i  = InputManager.leftButton1i;
                oldLeftButton2i  = InputManager.leftButton2i;
                oldRightButton1i = InputManager.rightButton1i;
                oldRightButton2i = InputManager.rightButton2i;

                InputManager.leftButton1i  = hc.CorrectButtonIsLeft && (oldRightButton1i || oldLeftButton1i);
                InputManager.leftButton2i  = hc.CorrectButtonIsLeft && (oldRightButton2i || oldLeftButton2i);
                InputManager.rightButton1i = !hc.CorrectButtonIsLeft && (oldRightButton1i || oldLeftButton1i);
                InputManager.rightButton2i = !hc.CorrectButtonIsLeft && (oldRightButton2i || oldLeftButton2i);
            }


            if (InputManager.leftButton1i || InputManager.leftButton2i)
            {
                ControlPoint p            = hitObjectManager.Beatmap.ControlPointAt(AudioEngine.Time + 2);
                HitSoundInfo hitSoundInfo = new HitSoundInfo(HitObjectSoundType.Normal, AudioEngine.CurrentSampleSet, AudioEngine.CustomSamples, p.Volume, AudioEngine.CurrentSampleSet);
                AudioEngine.PlayHitSamples(hitSoundInfo, InputManager.leftButton1i ? -0.2f : 0.2f, true);

                if (InputManager.leftButton1i)
                {
                    taikoInnerLeft.Transformations.Clear();
                    taikoInnerLeft.Transformations.Add(new Transformation(TransformationType.Fade,
                                                                          taikoInnerLeft.Alpha, 1,
                                                                          GameBase.Time,
                                                                          GameBase.Time +
                                                                          (int)
                                                                          ((1 - taikoInnerLeft.Alpha) * 80),
                                                                          EasingTypes.Out));
                    taikoInnerLeft.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0,
                                                                          GameBase.Time + 100, GameBase.Time + 150));
                }

                if (InputManager.leftButton2i)
                {
                    taikoInnerRight.Transformations.Clear();
                    taikoInnerRight.Transformations.Add(new Transformation(TransformationType.Fade,
                                                                           taikoInnerRight.Alpha, 1,
                                                                           GameBase.Time,
                                                                           GameBase.Time +
                                                                           (int)
                                                                           ((1 - taikoInnerRight.Alpha) *
                                                                            80), EasingTypes.Out));
                    taikoInnerRight.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0,
                                                                           GameBase.Time + 100, GameBase.Time + 150));
                }
            }

            if (InputManager.rightButton1i || InputManager.rightButton2i)
            {
                ControlPoint p            = hitObjectManager.Beatmap.ControlPointAt(AudioEngine.Time + 2);
                HitSoundInfo hitSoundInfo = new HitSoundInfo(HitObjectSoundType.Clap, AudioEngine.CurrentSampleSet, AudioEngine.CustomSamples, p.Volume, AudioEngine.CurrentSampleSet);
                AudioEngine.PlayHitSamples(hitSoundInfo, InputManager.rightButton1i ? -0.2f : 0.2f, true);

                if (InputManager.rightButton1i)
                {
                    taikoOuterLeft.Transformations.Clear();
                    taikoOuterLeft.Transformations.Add(new Transformation(TransformationType.Fade,
                                                                          taikoOuterLeft.Alpha, 1,
                                                                          GameBase.Time,
                                                                          GameBase.Time +
                                                                          (int)
                                                                          ((1 - taikoOuterLeft.Alpha) * 80),
                                                                          EasingTypes.Out));
                    taikoOuterLeft.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0,
                                                                          GameBase.Time + 100, GameBase.Time + 150));
                }

                if (InputManager.rightButton2i)
                {
                    taikoOuterRight.Transformations.Clear();
                    taikoOuterRight.Transformations.Add(new Transformation(TransformationType.Fade,
                                                                           taikoOuterRight.Alpha, 1,
                                                                           GameBase.Time,
                                                                           GameBase.Time +
                                                                           (int)
                                                                           ((1 - taikoOuterRight.Alpha) *
                                                                            80), EasingTypes.Out));
                    taikoOuterRight.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0,
                                                                           GameBase.Time + 100, GameBase.Time + 150));
                }
            }
            //return the input we just changed to the old values
            if (Player.Relaxing && hc != null)
            {
                InputManager.leftButton1i  = oldLeftButton1i;
                InputManager.leftButton2i  = oldLeftButton2i;
                InputManager.rightButton1i = oldRightButton1i;
                InputManager.rightButton2i = oldRightButton2i;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Applies all setup fields to beatmap
        /// </summary>
        private void applySettings(Beatmap beatmap)
        {
            beatmap.PlayMode = (PlayModes)allowedModes.SelectedIndex;

            if (newDifficulty)
            {
                beatmap.BeatmapId = 0;
            }

            //General tab

            beatmap.Title        = titleRomanised.Text;
            beatmap.TitleUnicode = title.Text;

            beatmap.Artist        = artistRomanised.Text;
            beatmap.ArtistUnicode = artist.Text;

            beatmap.Creator = creator.Text;
            beatmap.Version = version.Text;
            beatmap.Source  = source.Text;
            beatmap.Tags    = tags.Text;

            //Difficulty tab

            beatmap.DifficultyHpDrainRate  = hpDrainRate.Value / 10.0f;
            beatmap.DifficultyOverall      = overallDifficulty.Value / 10.0f;
            beatmap.DifficultyCircleSize   = allowedModes.SelectedIndex == 3 ? circleSize.Value * (coopmode.Checked ? 2 : 1) : circleSize.Value / 10.0f;
            beatmap.DifficultyApproachRate = approachRate.Value / 10.0f;

            //Account for coop mod here
            if (beatmap.PlayMode == PlayModes.OsuMania)
            {
                beatmap.DifficultyCircleSize = Math.Min(CS_MAX_MANIA * 2, Math.Max(beatmap.DifficultyCircleSize, CS_MIN_MANIA));
            }

            //Audio tab

            beatmap.SampleVolume = volume1.Value;

            if (checkSamplesMatchPlaybackRate.Enabled)
            {
                beatmap.SamplesMatchPlaybackRate = checkSamplesMatchPlaybackRate.Checked;
            }

            HitSoundInfo info = GetSampleset();

            if (AudioEngine.ControlPoints.Count > 0)
            {
                if (resetSampleSettings)
                {
                    foreach (ControlPoint p in AudioEngine.ControlPoints)
                    {
                        p.SampleSet     = info.SampleSet;
                        p.CustomSamples = info.CustomSampleSet;
                    }
                }

                if (resetVolumeSettings)
                {
                    foreach (ControlPoint p in AudioEngine.ControlPoints)
                    {
                        p.Volume = info.Volume;
                    }
                }
            }

            //Colours tab

            SkinManager.PrepareSliderRenderer(editor.hitObjectManager);

            beatmap.CustomColours = customColour.Checked;

            if (customColour.Checked)
            {
                int count = comboColourCount;

                List <System.Drawing.Color> colours = new List <System.Drawing.Color>(count);

                for (int i = 0; i < count; i++)
                {
                    colours.Add(combos[i].SwatchColor);
                }

                colours.Insert(0, colours[colours.Count - 1]);
                colours.RemoveAt(colours.Count - 1);

                for (int i = 0; i < colours.Count; i++)
                {
                    SkinManager.BeatmapColours["Combo" + (i + 1).ToString()] =
                        new Color(colours[i].R, colours[i].G, colours[i].B);
                }

                for (int i = colours.Count; i < SkinManager.MAX_COLOUR_COUNT; i++)
                {
                    SkinManager.BeatmapColours["Combo" + (i + 1).ToString()] =
                        Color.TransparentBlack;
                }
            }

            if (EventManager.Instance != null)
            {
                EventManager.Instance.ChangeColour(new Color(backgroundColour.SwatchColor.R, backgroundColour.SwatchColor.G, backgroundColour.SwatchColor.B));
            }

            //Design tab

            beatmap.SkinPreference = skinPreference.SelectedIndex > 0 ? skinPreference.Text : string.Empty;

            beatmap.LetterboxInBreaks    = checkLetterbox.Checked;
            beatmap.WidescreenStoryboard = checkWidescreen.Checked;
            beatmap.StoryFireInFront     = !checkStoryOverFire.Checked;

            if (!checkCountdown.Checked)
            {
                beatmap.Countdown = Countdown.Disabled;
            }
            else if (countdownNormal.Checked)
            {
                beatmap.Countdown = Countdown.Normal;
            }
            else if (countdownHalf.Checked)
            {
                beatmap.Countdown = Countdown.HalfSpeed;
            }
            else if (countdownDouble.Checked)
            {
                beatmap.Countdown = Countdown.DoubleSpeed;
            }

            beatmap.EpilepsyWarning = checkEpilepsy.Checked;
            beatmap.CountdownOffset = (int)udCountdownOffset.Value;

            //Advanced tab

            beatmap.StackLeniency = stackLeniency.Value / 10f;

            if (beatmap.PlayMode == PlayModes.OsuMania)
            {
                beatmap.SpecialStyle = cb_maniaSpecial.Checked;
            }
        }