Example #1
0
        public void Play(Harp harp, MetronomeMark metronomeMark, ChordOffset[] melody)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var strumIndex = 0; strumIndex < melody.Length;)
            {
                var strum = melody[strumIndex];

                if (stopwatch.ElapsedMilliseconds > metronomeMark.WholeNoteLength.Multiply(strum.Offest).TotalMilliseconds)
                {
                    var chord = strum.Chord;

                    foreach (var note in chord.Notes)
                    {
                        harp.GoToOctave(note);
                        harp.PlayNote(note);
                    }

                    strumIndex++;
                }
                else
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(1));
                }
            }

            stopwatch.Stop();
        }
Example #2
0
 public InternalSellInfo()
 {
     Add(typeof(Lute), Lute.GetSBSellValue());
     Add(typeof(Drums), Drums.GetSBSellValue());
     Add(typeof(Harp), Harp.GetSBSellValue());
     Add(typeof(Tambourine), Tambourine.GetSBSellValue());
 }
Example #3
0
        public void Play(Harp harp, MetronomeMark metronomeMark, ChordOffset[] melody)
        {
            PrepareChordsOctave(harp, melody[0].Chord);

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var strumIndex = 0; strumIndex < melody.Length;)
            {
                var strum = melody[strumIndex];

                if (stopwatch.ElapsedMilliseconds > metronomeMark.WholeNoteLength.Multiply(strum.Offest).TotalMilliseconds)
                {
                    var chord = strum.Chord;

                    PlayChord(harp, chord);

                    if (strumIndex < melody.Length - 1)
                    {
                        PrepareChordsOctave(harp, melody[strumIndex + 1].Chord);
                    }

                    strumIndex++;
                }
                else
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(1));
                }
            }

            stopwatch.Stop();
        }
Example #4
0
 public InternalBuyInfo()
 {
     Add(new GenericBuyInfo("Lute", typeof(Lute), Lute.GetSBPurchaseValue(), 50, 0x0EB3, 0));
     Add(new GenericBuyInfo("Drums", typeof(Drums), Drums.GetSBPurchaseValue(), 50, 0x0E9C, 0));
     Add(new GenericBuyInfo("Harp", typeof(Harp), Harp.GetSBPurchaseValue(), 50, 0x0EB1, 0));
     Add(new GenericBuyInfo("Tambourine", typeof(Tambourine), Tambourine.GetSBPurchaseValue(), 50, 0x0E9E, 0));
 }
        public bool CheckInstrument()
        {
            BaseInstrument inst = BaseInstrument.GetInstrument(this.m_Mobile);

            if (inst != null)
            {
                return(true);
            }

            if (this.m_Mobile.Debug)
            {
                this.m_Mobile.Say(1162, "I need an instrument, fixing my problem.");
            }

            if (this.m_Mobile.Backpack == null)
            {
                return(false);
            }

            inst = (BaseInstrument)this.m_Mobile.Backpack.FindItemByType(typeof(BaseInstrument));

            if (inst == null)
            {
                inst = new Harp();
                inst.SuccessSound = 0x58B;
                inst.FailureSound = 0x58C;
                // Got Better Music?
                // inst.DiscordSound = inst.PeaceSound = 0x58B;
                // inst.ProvocationSound = 0x58A;
            }

            BaseInstrument.SetInstrument(this.m_Mobile, inst);
            return(true);
        }
            public InternalBuyInfo()
            {
                Add(new GenericBuyInfo("Hatchet", typeof(Hatchet), Hatchet.GetSBPurchaseValue(), 50, 0xF43, 0));
                Add(new GenericBuyInfo("Saw", typeof(Saw), Saw.GetSBPurchaseValue(), 50, 0x1034, 0));

                Add(new GenericBuyInfo("Club", typeof(Club), Club.GetSBPurchaseValue(), 25, 0x13B4, 0));
                Add(new GenericBuyInfo("Shepherd's Crook", typeof(ShepherdsCrook), ShepherdsCrook.GetSBPurchaseValue(), 25, 0xE81, 0));
                Add(new GenericBuyInfo("Quarter Staff", typeof(QuarterStaff), QuarterStaff.GetSBPurchaseValue(), 25, 0xE89, 0));
                Add(new GenericBuyInfo("Gnarled Staff", typeof(GnarledStaff), GnarledStaff.GetSBPurchaseValue(), 25, 0x13F8, 0));
                Add(new GenericBuyInfo("Black Staff", typeof(BlackStaff), BlackStaff.GetSBPurchaseValue(), 25, 0xDF0, 0));

                Add(new GenericBuyInfo("Wooden Shield", typeof(WoodenShield), WoodenShield.GetSBPurchaseValue(), 25, 7034, 0));
                Add(new GenericBuyInfo("Wooden Kite Shield", typeof(WoodenKiteShield), WoodenKiteShield.GetSBPurchaseValue(), 25, 7033, 0));

                Add(new GenericBuyInfo("Lute", typeof(Lute), Lute.GetSBPurchaseValue(), 50, 0x0EB3, 0));
                Add(new GenericBuyInfo("Drums", typeof(Drums), Drums.GetSBPurchaseValue(), 50, 0x0E9C, 0));
                Add(new GenericBuyInfo("Harp", typeof(Harp), Harp.GetSBPurchaseValue(), 50, 0x0EB1, 0));
                Add(new GenericBuyInfo("Tambourine", typeof(Tambourine), Tambourine.GetSBPurchaseValue(), 50, 0x0E9E, 0));

                Add(new GenericBuyInfo("Scorp", typeof(Scorp), Scorp.GetSBPurchaseValue(), 50, 0x10E7, 0));
                Add(new GenericBuyInfo("Smoothing Plane", typeof(SmoothingPlane), SmoothingPlane.GetSBPurchaseValue(), 50, 0x1032, 0));
                Add(new GenericBuyInfo("Drawing Knife", typeof(DrawKnife), DrawKnife.GetSBPurchaseValue(), 50, 0x10E4, 0));
                Add(new GenericBuyInfo("Froe", typeof(Froe), Froe.GetSBPurchaseValue(), 50, 0x10E5, 0));
                Add(new GenericBuyInfo("Hammer", typeof(Hammer), Hammer.GetSBPurchaseValue(), 50, 0x102A, 0));
                Add(new GenericBuyInfo("Inshave", typeof(Inshave), Inshave.GetSBPurchaseValue(), 50, 0x10E6, 0));
                Add(new GenericBuyInfo("Jointing Plane", typeof(JointingPlane), JointingPlane.GetSBPurchaseValue(), 50, 0x1030, 0));
                Add(new GenericBuyInfo("Wooden Plane", typeof(WoodenPlane), WoodenPlane.GetSBPurchaseValue(), 50, 0x102C, 0));
                Add(new GenericBuyInfo("Dovetail Saw", typeof(DovetailSaw), DovetailSaw.GetSBPurchaseValue(), 50, 0x1028, 0));
            }
Example #7
0
    protected override void Start()
    {
        if (ins)
        {
            Destroy(gameObject);
        }
        else
        {
            ins = this;
        }
        base.Start();
        var pos = rt.anchoredPosition;

        pos.y = GetBottom();
        rt.anchoredPosition = pos;

        float x = rt.anchoredPosition.x - BlockSize.x / 2f;
        float y = rt.anchoredPosition.y + BlockSize.y / 2f;
        float w = exits[exit + width - 1].y_bot - exits[exit].y_top;
        float h = harpImageEndHeight;

        touchField = new Rect(x, y, w, h);
        center_x   = x + w / 2;
        score_x    = center_x;

        harpImage2.enabled = harpImage.enabled = true;
        harpImage2.rectTransform.sizeDelta        = harpImage.rectTransform.sizeDelta = new Vector2(touchField.width, harpImageStartHeight);
        harpImage2.rectTransform.anchoredPosition = harpImage.rectTransform.anchoredPosition = new Vector2(touchField.width / 2 - BlockSize.x / 2, BlockSize.y / 2f);
        harpImageIn = true;
        startTime   = Time.time;

        if (rouxian)
        {
            float hintAnim_x1 = 0;
            float hintAnim_x2 = w;
            if (roufa == 0) // 深揉
            {
                hintAnim_x1 = 0;
                hintAnim_x2 = w - BlockSize.x;
            }
            else if (roufa == 1) // 浅揉
            {
                hintAnim_x1 = -BlockSize.x / 2 + 0.3f * w;
                hintAnim_x2 = -BlockSize.x / 2 + 0.7f * w;
            }
            if (rousu == 0) // 快揉
            {
                hintAnimTotalTime = 1.5f * limitTime;
            }
            else if (rousu == 1) // 慢揉
            {
                hintAnimTotalTime = 2.25f * limitTime;
            }
            hintAnimStart = new Vector2(hintAnim_x1, -rt.anchoredPosition.y);
            hintAnimEnd   = new Vector2(hintAnim_x2, -rt.anchoredPosition.y);
        }
    }
Example #8
0
    public static Beat CreateBeat(int exit, PanelType panel, Color?c = null, int perfectScore = 20, int goodScore = 10, int badScore = 0)
    {
        var ret = Instantiate(Resources.Load <GameObject>("Beat"), ins.parentNode).GetComponent <Beat>().Initialize(exit, panel, c == null ? Color.white : c.GetValueOrDefault(), perfectScore, goodScore, badScore);

        ret.fallingTime      = 1f;
        ((Beat)ret).lifetime = 1f;
        var pos = (ret.transform as RectTransform).anchoredPosition;

        pos.y = Harp.GetHeight();
        (ret.transform as RectTransform).anchoredPosition = pos;
        return((Beat)ret);
    }
            public InternalSellInfo()
            {
                Add(typeof(Hatchet), Hatchet.GetSBSellValue());
                Add(typeof(Saw), Saw.GetSBSellValue());

                Add(typeof(Scorp), Scorp.GetSBSellValue());
                Add(typeof(SmoothingPlane), SmoothingPlane.GetSBSellValue());
                Add(typeof(DrawKnife), DrawKnife.GetSBSellValue());
                Add(typeof(Froe), Froe.GetSBSellValue());
                Add(typeof(Hammer), Hammer.GetSBSellValue());
                Add(typeof(Inshave), Inshave.GetSBSellValue());
                Add(typeof(JointingPlane), JointingPlane.GetSBSellValue());
                Add(typeof(WoodenPlane), WoodenPlane.GetSBSellValue());
                Add(typeof(DovetailSaw), DovetailSaw.GetSBSellValue());

                Add(typeof(Lute), Lute.GetSBSellValue());
                Add(typeof(Drums), Drums.GetSBSellValue());
                Add(typeof(Harp), Harp.GetSBSellValue());
                Add(typeof(Tambourine), Tambourine.GetSBSellValue());

                Add(typeof(Club), Club.GetSBSellValue());
                Add(typeof(ShepherdsCrook), ShepherdsCrook.GetSBSellValue());
                Add(typeof(QuarterStaff), QuarterStaff.GetSBSellValue());
                Add(typeof(GnarledStaff), GnarledStaff.GetSBSellValue());
                Add(typeof(BlackStaff), BlackStaff.GetSBSellValue());

                Add(typeof(WoodenShield), WoodenShield.GetSBSellValue());
                Add(typeof(WoodenKiteShield), WoodenKiteShield.GetSBSellValue());

                /*
                 *              Add( typeof( WoodenBox ), 7 );
                 *              Add( typeof( SmallCrate ), 5 );
                 *              Add( typeof( MediumCrate ), 6 );
                 *              Add( typeof( LargeCrate ), 7 );
                 *              Add( typeof( WoodenChest ), 15 );
                 *
                 *              Add( typeof( LargeTable ), 10 );
                 *              Add( typeof( Nightstand ), 7 );
                 *              Add( typeof( YewWoodTable ), 10 );
                 *              Add( typeof( WritingTable ), 9 );
                 *
                 *              Add( typeof( Throne ), 24 );
                 *              Add( typeof( WoodenThrone ), 6 );
                 *              Add( typeof( Stool ), 6 );
                 *              Add( typeof( FootStool ), 6 );
                 *
                 *              Add( typeof( FancyWoodenChairCushion ), 12 );
                 *              Add( typeof( CushionedWoodenChair ), 10 );
                 *              Add( typeof( WoodenChair ), 8 );
                 *              Add( typeof( BambooChair ), 6 );
                 *              Add( typeof( WoodenBench ), 6 );
                 */
            }
Example #10
0
        public static void PlayHarpMinor_OnCommand(CommandEventArgs e)
        {
            Harp inst1 = new Harp();
            Harp inst2 = new Harp();
            Harp inst3 = new Harp();

            if (PlayChord(e.Mobile, e.Arguments, true, inst1, inst2, inst3))
            {
                inst1.Delete();
                inst2.Delete();
                inst3.Delete();
            }
        }
Example #11
0
        public static void MultiPlay_OnCommand(CommandEventArgs e)
        {
            Harp    inst1 = new Harp();
            Lute    inst2 = new Lute();
            LapHarp inst3 = new LapHarp();

            if (PlayChord(e.Mobile, e.Arguments, false, inst1, inst2, inst3))
            {
                inst1.Delete();
                inst2.Delete();
                inst3.Delete();
            }
        }
Example #12
0
        private static void PlayChord(Harp harp, Chord chord)
        {
            var notes = chord.Notes.ToArray();

            for (var noteIndex = 0; noteIndex < notes.Length; noteIndex++)
            {
                harp.PlayNote(notes[noteIndex]);

                if (noteIndex < notes.Length - 1)
                {
                    PrepareNoteOctave(harp, notes[noteIndex + 1]);
                }
            }
        }
Example #13
0
        // Warning: Untested
        public static bool CheckBarding(BaseCreature from)
        {
            BaseInstrument inst = BaseInstrument.GetInstrument(from);

            if (inst == null)
            {
                if (from.Backpack == null)
                {
                    return(false);
                }

                inst = (BaseInstrument)from.Backpack.FindItemByType(typeof(BaseInstrument));

                if (inst == null)
                {
                    inst = new Harp();
                    inst.SuccessSound = 0x58B;
                    // inst.DiscordSound = inst.PeaceSound = 0x58B;
                    // inst.ProvocationSound = 0x58A;
                    inst.FailureSound = 0x58C;
                }
            }

            BaseInstrument.SetInstrument(from, inst);

            if (from.Skills[SkillName.Discordance].Base == 0)
            {
                from.Skills[SkillName.Discordance].Base = 100.0;
            }

            if (from.Skills[SkillName.Peacemaking].Base == 0)
            {
                from.Skills[SkillName.Peacemaking].Base = 100.0;
            }

            if (from.Skills[SkillName.Provocation].Base == 0)
            {
                from.Skills[SkillName.Provocation].Base = 100.0;
            }

            return(true);
        }
Example #14
0
 private static void PrepareNoteOctave(Harp harp, Note note)
 {
     harp.GoToOctave(note);
 }
Example #15
0
        private void Process(Mobile from)
        {
            Item rewardItem;

            switch (m_Skill.SkillID)
            {
            case 0:                     // alchemy
                rewardItem = new MortarPestle();
                break;

            case 7:                     // Blacksmithy
                rewardItem = new GMSmithHammer();
                break;

            case 8:                     // Bowcraft/fletching
                rewardItem = new Bow();
                break;

            case 11:                     // Carpentry
                switch (m_Itemid)
                {
                case 4138:
                    rewardItem = new Hammer();
                    break;

                case 4148:
                    rewardItem = new Saw();
                    break;

                case 4146:
                    rewardItem = new SmoothingPlane();
                    break;

                case 4325:
                    rewardItem = new Froe();
                    break;

                case 4326:
                    rewardItem = new Inshave();
                    break;

                case 4324:
                    rewardItem = new DrawKnife();
                    break;

                default:
                    return;
                }
                break;

            case 23:                     // Inscription
                rewardItem = new ScribesPen();
                break;

            case 25:                     // Magery
                rewardItem = new Spellbook();
                (rewardItem as Spellbook).Content  = ulong.MaxValue;
                (rewardItem as Spellbook).LootType = LootType.Blessed;
                break;

            case 34:                     // Tailoring
                rewardItem = new RewardDyeTub();
                break;

            case 35:                     // Animal Taming
                rewardItem = new ShepherdsCrook();
                break;

            case 44:     //Lumberjacking
                rewardItem = new Hatchet();
                break;

            case 45:     // Mining
                rewardItem = new Pickaxe();
                break;

            //Bardic skills
            case 9:
            case 15:
            case 22:
            case 29:
                switch (m_Itemid)
                {
                case 3740:
                    rewardItem = new Drums();
                    break;

                case 3761:
                    rewardItem = new Harp();
                    break;

                case 3762:
                    rewardItem = new LapHarp();
                    break;

                case 3763:
                    rewardItem = new Lute();
                    break;

                case 3741:
                    rewardItem = new Tambourine();
                    break;

                case 3742:
                    rewardItem = new TambourineTassel();
                    break;

                default:
                    return;
                }
                break;

            //"Thieving" skills
            case 21:
            case 28:
            case 33:
            case 47:
                rewardItem = new Cloak();
                break;

            default:
                return;
            }

            rewardItem.Hue      = m_CurrentHue;
            rewardItem.LootType = LootType.Blessed;

            if (m_Name != "")
            {
                rewardItem.Name = m_Name;
            }

            if (rewardItem is RewardDyeTub)
            {
                var tub = (RewardDyeTub)rewardItem;
                tub.DyedHue  = rewardItem.Hue;
                tub.Redyable = false;
                tub.LootType = LootType.Blessed;
                tub.Owner    = from;
            }
            else if (rewardItem is GMSmithHammer)
            {
                var hammer = (GMSmithHammer)rewardItem;
                hammer.Owner = from;
            }

            from.AddToBackpack(rewardItem);

            // Log
            RewardLogging.WriteLine(from, m_Skill, m_Name, m_CurrentHue);
        }
Example #16
0
 private static void PrepareChordsOctave(Harp harp, Chord chord)
 {
     harp.GoToOctave(chord.Notes.First());
 }
Example #17
0
    IEnumerator StartFalling(KeyData kd)
    {
        yield return(new WaitForSeconds(kd.startTime - GeneralSettings.musicStartTime + GeneralSettings.delay - GeneralSettings.fallingTime));

        //print(kd.prop["Type"] + " is falling from Exit " + kd.prop["Exit"] + " in " + kd.prop["FallingTime"]);
        int       exit = 0;
        PanelType panel = PanelType.Left;
        string    str; string[] seg;

        if (kd.prop.TryGetValue("Exit", out str))
        {
            exit = int.Parse(str);
        }
        if (kd.prop.TryGetValue("Panel", out str))
        {
            if (str == "Right")
            {
                panel = PanelType.Right;
            }
        }

        string blockType = "None";

        if (kd.prop.TryGetValue("Type", out str))
        {
            blockType = str;
        }
        if (GeneralSettings.specialMode == 1)
        {
            blockType = "FallingBlock";
        }

        // General Properties
        // if game layout needs to change
        bool generateNewExit = false;

        if (kd.prop.TryGetValue("NewExitCount", out str))
        {
            int newExitCount = int.Parse(str);
            if (newExitCount != GeneralSettings.exitCount)
            {
                GeneralSettings.exitCount = newExitCount;
                print("Change number of Exits to " + GeneralSettings.exitCount);
                generateNewExit = true;
            }
        }
        if (kd.prop.TryGetValue("NewGameMode", out str))
        {
            int newMode = int.Parse(str);
            if (newMode != GeneralSettings.mode)
            {
                GeneralSettings.mode = newMode;
                print("New game mode: " + GeneralSettings.mode);
                generateNewExit = true;
            }
        }
        if (generateNewExit)
        {
            RhythmGameManager.GenerateExits();
        }

        if (kd.prop.TryGetValue("HideBottom", out str))
        {
            if (str == "true")
            {
                RhythmGameManager.HideBottomBar();
            }
            else if (str == "false")
            {
                RhythmGameManager.HideBottomBar(false);
            }
        }
        if (kd.prop.TryGetValue("HideExits", out str))
        {
            if (str == "true")
            {
                RhythmGameManager.HideExit();
            }
            else if (str == "false")
            {
                RhythmGameManager.HideExit(false);
            }
            else
            {
                seg = str.Split(',');
                HashSet <int> set = new HashSet <int>();
                foreach (var s in seg)
                {
                    set.Add(int.Parse(s));
                }
                RhythmGameManager.HideExit(set);
            }
        }
        if (kd.prop.TryGetValue("SpecialMode", out str))
        {
            GeneralSettings.specialMode = int.Parse(str);
        }
        if (kd.prop.TryGetValue("Enable3D", out str))
        {
            if (str == "yes")
            {
                Road.ins.EnableDisplay(true);
            }
            else if (str == "no")
            {
                Road.ins.EnableDisplay(false);
            }
        }
        if (kd.prop.TryGetValue("SetParam", out str))
        {
            seg = str.Split(',');
            vEventIns.setParameterByName(seg[0], float.Parse(seg[1]));
        }
        if (kd.prop.TryGetValue("SFX", out str))
        {
            FMODUnity.RuntimeManager.PlayOneShot("event:/" + str);
        }
        if (kd.prop.TryGetValue("Image", out str))
        {
            Instantiate(Resources.Load <GameObject>(str), RhythmGameManager.ins.imageNode);
        }
        if (kd.prop.TryGetValue("VideoVolumeFadeOut", out str))
        {
            ins.StartCoroutine(FadeVideoVolume(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("MusicFadeIn", out str))
        {
            ins.StartCoroutine(MusicFadeIn(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("MusicFadeOut", out str))
        {
            ins.StartCoroutine(MusicFadeOut(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("PreloadVideoClip", out str))
        {
            int    clipNum = int.Parse(str);
            int    mode    = kd.prop["Ratio"] == "16:9" ? 1 : 0;
            double time    = 0;
            if (kd.prop.TryGetValue("VideoStartTime", out str))
            {
                time = double.Parse(str);
            }
            PreloadVideo(clipNum, mode, time);
        }
        if (kd.prop.TryGetValue("ShowPreloadVideo", out str))
        {
            StartCoroutine(SetPreloadVideoActive());
        }
        if (kd.prop.TryGetValue("PlayVideoClip", out str))
        {
            int    clipNum = int.Parse(str);
            int    mode    = kd.prop["Ratio"] == "16:9" ? 1 : 0;
            double time    = 0;
            if (kd.prop.TryGetValue("VideoStartTime", out str))
            {
                time = double.Parse(str);
            }
            PlayVideo(clipNum, mode, time);
        }
        if (kd.prop.TryGetValue("PanelAlpha", out str))
        {
            Panel.alpha = float.Parse(str);
            foreach (var e in RhythmGameManager.exits)
            {
                foreach (Graphic g in e.obj.GetComponentsInChildren <Graphic>())
                {
                    Color c = g.color;
                    c.a     = Panel.alpha;
                    g.color = c;
                }
                foreach (Graphic g in e.idctor.GetComponentsInChildren <Graphic>())
                {
                    Color c = g.color;
                    c.a     = Panel.alpha;
                    g.color = c;
                }
            }
        }

        if (blockType == "GameOver")
        {
            RhythmGameManager.HideContent();
            // DebugMode.DestroyAllDebugObjects();
            Instantiate(Resources.Load <GameObject>("结算画面"), GameObject.Find("Canvas").transform);
        }
        else if (blockType == "ShowLeftPanel")
        {
            Panel.ShowLeft();
        }
        else if (blockType == "HideLeftPanel")
        {
            Panel.HideLeft();
        }
        else if (blockType == "ShowRightPanel")
        {
            Panel.ShowRight();
        }
        else if (blockType == "HideRightPanel")
        {
            Panel.HideRight();
        }
        else if (blockType == "HideBothPanels")
        {
            Panel.HideBoth();
        }

        // Generates block
        else if (blockType != "None" && (GeneralSettings.specialMode != 2 || IgnoresSpecialMode2(blockType)))
        {
            if (Harp.Contains(kd))
            {
                if (Harp.ins.rouxian)
                {
                    if (blockType == "Lyrics")
                    {
                        Harp.CreateLyrics(kd.prop["Lyrics"], float.Parse(kd.prop["TimeLast"]));
                    }
                }
            }
            else
            {
                Color c = Utils.GetRandomColor();
                if (kd.prop.TryGetValue("Color", out str))
                {
                    seg = str.Split(',');
                    c   = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255);
                }
                var block = RhythmGameManager.CreateBlock(exit, panel, blockType, c);
                block.fallingTime = GeneralSettings.fallingTime;

                if (kd.prop.TryGetValue("Note", out str))
                {
                    seg         = str.Split(',');
                    block.sound = new SoundStruct[seg.Length];
                    for (int i = 0; i < seg.Length; ++i)
                    {
                        block.sound[i].id = "MidiNotes/" + seg[i];
                    }
                }
                if (kd.prop.TryGetValue("Delays", out str))
                {
                    seg = str.Split(',');
                    if (seg.Length > 1 && seg.Length == block.sound.Length - 1)
                    {
                        float val = 0;
                        for (int i = 0; i < seg.Length; ++i)
                        {
                            float cur = float.Parse(seg[i]);
                            val += cur;
                            block.sound[i + 1].delay = val;
                        }
                    }
                    else
                    {
                        float val = float.Parse(seg[0]);
                        for (int i = 1; i < block.sound.Length; ++i)
                        {
                            block.sound[i].delay = val * i;
                        }
                    }
                }

                switch (blockType)
                {
                case "FallingBlock":
                    break;

                case "Beat":
                    Beat beat = (Beat)block;
                    if (kd.prop.TryGetValue("Position", out str))
                    {
                        seg = str.Split(',');
                        beat.rt.anchoredPosition = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    }
                    else
                    {
                        var pos = beat.rt.anchoredPosition;
                        pos.y = 0;
                        beat.rt.anchoredPosition = pos;
                    }
                    if (kd.prop.TryGetValue("Lifetime", out str))
                    {
                        beat.lifetime = int.Parse(str);
                    }
                    else
                    {
                        beat.lifetime = 2;
                    }
                    break;

                case "LongFallingBlock":
                    LongFallingBlock lfb = (LongFallingBlock)block;
                    lfb.length = int.Parse(kd.prop["Length"]);
                    break;

                case "HorizontalMove":
                    HorizontalMove hrm = (HorizontalMove)block;
                    hrm.width     = int.Parse(kd.prop["Width"]);
                    hrm.direction = kd.prop["Direction"] == "Up" ? Direction.Up : Direction.Down;
                    break;

                case "Harp":
                    Harp h = (Harp)block;
                    h.width    = int.Parse(kd.prop["Width"]);
                    h.timeLast = float.Parse(kd.prop["TimeLast"]);
                    if (kd.prop.TryGetValue("Rouxian", out str))
                    {
                        h.rouxian = str == "yes";
                    }
                    if (h.rouxian)
                    {
                        str = kd.prop["Roufa"];
                        if (str == "deep")
                        {
                            h.roufa = 0;
                        }
                        else if (str == "shallow")
                        {
                            h.roufa = 1;
                        }
                        str = kd.prop["Rousu"];
                        if (str == "quick")
                        {
                            h.rousu = 0;
                        }
                        else if (str == "slow")
                        {
                            h.rousu = 1;
                        }
                        if (kd.prop.TryGetValue("LimitTime", out str))
                        {
                            h.limitTime = float.Parse(str);
                        }
                        else
                        {
                            h.limitTime = 0.5f;
                        }
                        if (kd.prop.TryGetValue("Cooldown", out str))
                        {
                            h.cooldown = float.Parse(str);
                        }
                        else
                        {
                            h.cooldown = 0.6f;
                        }
                    }
                    break;

                case "VocalText":
                    VocalText vt = (VocalText)block;
                    if (kd.prop.TryGetValue("Text", out str))
                    {
                        vt.text = str;
                    }
                    seg             = kd.prop["StartPosition"].Split(',');
                    vt.startPos     = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    seg             = kd.prop["EndPosition"].Split(',');
                    vt.endPos       = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    vt.rotation     = int.Parse(kd.prop["Rotation"]);
                    vt.beatInterval = float.Parse(kd.prop["BeatInterval"]);
                    vt.voEvent      = kd.prop["Voice"];
                    vt.length       = int.Parse(kd.prop["Length"]);
                    vt.num          = int.Parse(kd.prop["Num"]);
                    if (kd.prop.TryGetValue("AnimColor", out str))
                    {
                        seg          = str.Split(',');
                        vt.animColor = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255);
                    }
                    if (kd.prop.TryGetValue("MaxMiss", out str))
                    {
                        vt.maxMiss = int.Parse(str);
                    }
                    else
                    {
                        vt.maxMiss = 1;
                    }
                    if (kd.prop.TryGetValue("BeatLifetime", out str))
                    {
                        vt.beatLifetime = int.Parse(str);
                    }
                    else
                    {
                        vt.beatLifetime = 2;
                    }
                    if (kd.prop.TryGetValue("NoAnim", out str))
                    {
                        if (str == "yes")
                        {
                            vt.noAnim = true;
                        }
                    }
                    break;

                default:
                    break;
                }
                OnBlockCreated?.Invoke(block);
            }
        }
    }
Example #18
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            from.CloseGump(typeof(SynthGump));

            InstrumentType inst = InstrumentType.Harp;

            if (info.IsSwitched((int)Buttons.RB2_LapHarp))
            {
                inst = InstrumentType.LapHarp;
            }
            if (info.IsSwitched((int)Buttons.RB3_Lute))
            {
                inst = InstrumentType.Lute;
            }
            if (info.IsSwitched((int)Buttons.RB4_Drums))
            {
                inst = InstrumentType.Drums;
            }

            try { m_Name = info.TextEntries[0].Text.Trim(); }
            catch { m_Name = "Untitled"; }

            if (info.ButtonID > 100)
            {
                m_Page = info.ButtonID - 100;
                from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
            }
            else if (info.ButtonID >= (int)Buttons.Track1 && info.ButtonID <= (int)Buttons.Track8)
            {
                EditTrack(from);
                from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
            }
            else if (info.ButtonID >= (int)Buttons.PlayTrack1 && info.ButtonID <= (int)Buttons.PlayTrack8)
            {
                int track = info.ButtonID - (int)Buttons.PlayTrack1 + 1;
                m_Mixer[track] = !m_Mixer[track];
                from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
            }
            else if (info.ButtonID == (int)Buttons.PlayTracks)
            {
                Container             pack        = m_From.Backpack;
                List <BaseInstrument> instruments = new List <BaseInstrument>();
                List <XmlMusic>       mxm         = new List <XmlMusic>();
                if (pack == null || pack.Deleted || pack.Items.Count == 0)
                {
                    from.SendMessage("Your pack is missing or empty!");
                }
                else
                {
                    foreach (Item i in pack.Items)
                    {
                        if (i is BaseInstrument)
                        {
                            instruments.Add(i as BaseInstrument);
                        }
                    }
                    if (instruments.Count > 0)
                    {
                        XmlMusic findxm = null;
                        for (int x = 0; x < instruments.Count; x++)
                        {
                            if (!m_Mixer[x + 1])
                            {
                                from.SendMessage("Skipping Track {0}", (int)(x + 1));
                                continue;
                            }
                            findxm = (XmlMusic)XmlAttach.FindAttachment(instruments[x], typeof(XmlMusic));
                            if (findxm != null)
                            {
                                try
                                {
                                    mxm.Add(findxm);
                                }
                                catch { }
                            }
                            else
                            {
                                from.SendMessage("XmlMusic was null on the {0}", instruments[x].GetType().Name);
                            }
                        }
                    }
                    if (mxm.Count > 0)
                    {
                        Mix.PlayTracks(from, mxm);
                    }
                    else
                    {
                        from.SendMessage("xmx.Count was 0.");
                    }
                }
            }
            else
            {
                switch (info.ButtonID)
                {
                case (int)Buttons.Quit:
                    break;

                case (int)Buttons.ShowKeys:
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, !m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;

                case (int)Buttons.ShowMusic:
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, !m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;

                case (int)Buttons.ShowChords:
                {
                    m_Chords = !m_Chords;
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.ShowMixer:
                {
                    m_Mixer[0] = !m_Mixer[0];
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.StartRecording:
                {
                    if (m_Recording)
                    {
                        from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    }
                    else
                    {
                        m_Song = new List <string>();
                        m_Song.Add("norm");
                        from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, true, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    }
                    break;
                }

                case (int)Buttons.StopRecording:
                {
                    if (!m_Recording)
                    {
                        from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    }
                    else
                    {
                        List <string> tempSong = new List <string>(m_Song);
                        string        speed    = tempSong[0];
                        tempSong.RemoveAt(0);
                        string[] newSong = tempSong.ToArray();
                        Play.Play_OnCommand(new CommandEventArgs(from, "Play", speed, newSong));
                        from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, !m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    }
                    break;
                }

                case (int)Buttons.FileOptions: from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, !m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks)); break;

                case (int)Buttons.Play:
                {
                    List <string> tempSong = new List <string>(m_Song);
                    string        speed    = tempSong[0];
                    tempSong.RemoveAt(0);
                    string[] newSong = tempSong.ToArray();
                    Play.Play_OnCommand(new CommandEventArgs(from, "Play", speed, newSong));
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.Save:
                {
                    SaveSong(from, m_Name, m_Song);
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.Load:
                {
                    m_Song = LoadSong(from, m_Name);
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.Fast:
                {
                    if (m_Song.Count == 0)
                    {
                        m_Song.Add("fast");
                    }
                    else if (m_Song[0] == "fast")
                    {
                        m_Song[0] = "veryfast";
                    }
                    else if (m_Song[0] == "norm")
                    {
                        m_Song[0] = "fast";
                    }
                    else if (m_Song[0] == "slow")
                    {
                        m_Song[0] = "norm";
                    }
                    else if (m_Song[0] == "veryslow")
                    {
                        m_Song[0] = "slow";
                    }
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                case (int)Buttons.Slow:
                {
                    if (m_Song.Count == 0)
                    {
                        m_Song.Add("slow");
                    }
                    else if (m_Song[0] == "slow")
                    {
                        m_Song[0] = "veryslow";
                    }
                    else if (m_Song[0] == "norm")
                    {
                        m_Song[0] = "slow";
                    }
                    else if (m_Song[0] == "fast")
                    {
                        m_Song[0] = "norm";
                    }
                    else if (m_Song[0] == "veryfast")
                    {
                        m_Song[0] = "fast";
                    }
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }

                default:
                {
                    try
                    {
                        if (m_Song.Count == 0)
                        {
                            m_Song.Add("norm");
                        }
                        if (m_Chords && info.ButtonID < (int)Buttons.n13_c)
                        {
                            switch ((InstrumentType)inst)
                            {
                            case InstrumentType.Harp:
                            {
                                Harp inst1 = new Harp();
                                Harp inst2 = new Harp();
                                Harp inst3 = new Harp();
                                if (Play.PlayChord(from, new string[] { GetNoteString((NoteValue)(info.ButtonID - 1)) }, true, inst1, inst2, inst3))
                                {
                                    inst1.Delete();
                                    inst2.Delete();
                                    inst3.Delete();
                                }
                                break;
                            }

                            case InstrumentType.Lute:
                            {
                                Lute inst1 = new Lute();
                                Lute inst2 = new Lute();
                                Lute inst3 = new Lute();
                                if (Play.PlayChord(from, new string[] { GetNoteString((NoteValue)(info.ButtonID - 1)) }, true, inst1, inst2, inst3))
                                {
                                    inst1.Delete();
                                    inst2.Delete();
                                    inst3.Delete();
                                }
                                break;
                            }

                            case InstrumentType.LapHarp:
                            {
                                LapHarp inst1 = new LapHarp();
                                LapHarp inst2 = new LapHarp();
                                LapHarp inst3 = new LapHarp();
                                if (Play.PlayChord(from, new string[] { GetNoteString((NoteValue)(info.ButtonID - 1)) }, true, inst1, inst2, inst3))
                                {
                                    inst1.Delete();
                                    inst2.Delete();
                                    inst3.Delete();
                                }
                                break;
                            }

                            case InstrumentType.Drums: break;
                            }
                        }
                        else
                        {
                            NoteValue nv = (NoteValue)(info.ButtonID - 1);

                            Music.PlayNote(from, (int)nv, inst);
                            if (m_Recording)
                            {
                                m_Song.Add(GetNoteString(nv));
                                //from.SendMessage("Note added to song: #: {0}, string: {1}", nv, GetNoteString(nv));
                            }
                        }
                    }
                    catch { }
                    from.SendGump(new SynthGump(m_From, m_Page, (int)inst, m_Music, m_Keys, m_Recording, m_FileOptions, m_Chords, m_Mixer, m_Song, m_Name, m_MusicTracks));
                    break;
                }
                }
            }
        }
 public MusicPlayer(MusicSheet musicSheet, Harp harp, IPlayAlgorithm algorithm)
 {
     _musicSheet = musicSheet;
     _harp       = harp;
     _algorithm  = algorithm;
 }