コード例 #1
0
    public void Save_Rhythm()
    {
        User.User_Info.Username = "******";
        User.Psswd = "1234567891011121";

        Rhythm_Data rhythm = Rhythms[0];

        string[] field_names = { "REQUEST_TYPE",
                                 "rhythm_id",
                                 "rhythm_name",
                                 "rhythm_details",
                                 "rhythm_ppm",
                                 "rhythm_date_update",
                                 "rhythm_date_creation",
                                 "rhythm_author_id",
                                 "rhythm_data" };

        string[] field_values = { "set_rhythms",
                                  rhythm.Id.ToString(),
                                  rhythm.Name,
                                  rhythm.Description,
                                  rhythm.PPM.ToString(),
                                  Utils.Get_String_SQL(rhythm.Last_Update),
                                  Utils.Get_String_SQL(rhythm.Creation),
                                  rhythm.Author_id.ToString(),
                                  rhythm.Get_Sounds_Json() };

        Http_Client.Send_Post(field_names, field_values, Handle_Save_Response);
    }
コード例 #2
0
    void Handle_Data_Response(string response, Handler_Type type)
    {
        string data = Utils.Split(response, '~')[1];

        foreach (string rhythm in Utils.Split(data, "%"))
        {
            Rhythm_Data new_rhythm  = new Rhythm_Data();
            string[]    rhythm_data = Utils.Split(rhythm, '#');

            new_rhythm.Id             = uint.Parse(rhythm_data[0]);
            new_rhythm.Name           = rhythm_data[1];
            new_rhythm.Description    = rhythm_data[2];
            new_rhythm.PPM            = uint.Parse(rhythm_data[3]);
            new_rhythm.Time_Signature = (Rhythm_Data.Time_Signature_Type)Enum.Parse(typeof(Rhythm_Data.Time_Signature_Type), rhythm_data[4]);
            new_rhythm.Creation       = Utils.Get_DateTime(rhythm_data[5]);
            new_rhythm.Last_Update    = Utils.Get_DateTime(rhythm_data[6]);
            new_rhythm.Author_id      = uint.Parse(rhythm_data[7]);

            foreach (Sound_Data.Sound_Type sound_type in (Sound_Data.Sound_Type[])Enum.GetValues(typeof(Sound_Data.Sound_Type)))
            {
                if (sound_type == Sound_Data.Sound_Type.None)
                {
                    continue;
                }

                Sound_Data new_sound = Parse_Sound(sound_type, rhythm_data[8]);
                new_rhythm.Sounds_Data.Add(new_sound);

                if (!Sound_Type_Mono.Sounds.Exists(a => a.Sound_Type == new_sound.Type))
                {
                    continue;
                }

                Sound_Type_Mono sound_mono = Sound_Type_Mono.Sounds.Find(a => a.Sound_Type == new_sound.Type);

                foreach (Sound_Data.Instance instance in new_sound.Instances)
                {
                    sound_mono.Instances[instance.Fire_Time].Set_Enabled(true);
                    sound_mono.Instances[instance.Fire_Time].Instance = instance;
                }

                foreach (Sound_Data.Loop loop in new_sound.Loops)
                {
                    int sibling_index = sound_mono.Instances[loop.Start_Time].transform.GetSiblingIndex();

                    Rhythm_Loop rhythm_loop = Instantiate(loop_prefab, sound_mono.transform).GetComponent <Rhythm_Loop>();
                    rhythm_loop.Data  = loop;
                    rhythm_loop.Sound = sound_mono;
                    rhythm_loop.Sound.Loops.Add(rhythm_loop);
                    rhythm_loop.Update_Core();
                    rhythm_loop.Update_Periphery();
                }
            }

            Rhythms.Add(new_rhythm);
        }

        rhythm_title.text = Rhythms[0].Name.ToString();
        PPM = Rhythms[0].PPM;
        rhythm_speed.text    = PPM.ToString();
        rhythm_length.text   = Song_Length.ToString();
        time_signature.value = (int)Rhythms[0].Time_Signature;
        time_signature.onValueChanged.AddListener((int value) =>
        {
            Rhythms[0].Time_Signature = (Rhythm_Data.Time_Signature_Type)value;
            Update_Separators();
        });

        Update_Numerators();
        Update_Separators();

        Reset_Events();
        Utils.Update_UI = true;
    }