示例#1
0
    public void Set_Repeated(Sound_Instance_Mono new_repeating_from)
    {
        if (subscribed)
        {
            Repeating_From.Toggling -= Copying_Toggle;
            subscribed = false;
        }

        if (new_repeating_from != null)
        {
            Repeated      = true;
            Default_Color = Repeated__Color;

            Set_Enabled(new_repeating_from.Enabled);
            Volume = new_repeating_from.Volume;
            new_repeating_from.Copies.Add(this);
            new_repeating_from.Toggling += Copying_Toggle;
            subscribed = true;
        }
        else
        {
            Repeated      = false;
            Default_Color = Not_Repeated__Color;

            if (Repeating_From != null && Repeating_From.Copies.Exists(a => a == this))
            {
                Repeating_From.Copies.Remove(this);
            }
        }

        Repeating_From   = new_repeating_from;
        Background.color = Default_Color;
    }
    public void Update_Core()
    {
        Sound_Instance_Mono[] already_cores = new Sound_Instance_Mono[Sound_Instances_Core.Count];
        Sound_Instances_Core.CopyTo(already_cores);
        Sound_Instances_Core = new List <Sound_Instance_Mono>();

        for (float y = Data.Start_Time; y <= Data.End_Time; y += 0.125f)
        {
            Sound_Instances_Core.Add(Sound.Instances[y]);
        }

        foreach (Sound_Instance_Mono instance in Sound_Instances_Core)
        {
            if (!already_cores.ToList().Exists(a => a == instance))
            {
                instance.Set_Repeated(null);
            }
        }

        foreach (Rhythm_Loop_Border border in Borders)
        {
            border.Update_UI();
        }

        transform.SetAsLastSibling();
    }
    public void Update_Periphery()
    {
        List <Sound_Instance_Mono> new_Peripheric = new List <Sound_Instance_Mono>();

        for (float x = 1; x <= Data.Repetitions; x++)
        {
            for (float y = 0; y < Data.Length_Steps; y++)
            {
                float key = y * 0.125f + Data.Start_Time + x * (Data.Length + 0.125f);
                Sound_Instance_Mono core      = Sound.Instances[Data.Start_Time + y * 0.125f];
                Sound_Instance_Mono periphery = Sound.Instances[key];

                periphery.Set_Repeated(core);
                new_Peripheric.Add(periphery);
            }
        }

        foreach (Sound_Instance_Mono instance in Sound_Instances_Peripheric)
        {
            if (!new_Peripheric.Exists(a => a == instance))
            {
                instance.Set_Repeated(null);
            }
        }

        Sound_Instances_Peripheric = new_Peripheric;
    }
示例#4
0
    void Initialize()
    {
        total_cells_count = (int)Math.Round(Song_Length / Step, 0);
        event_handlers    = new EventHandler[total_cells_count];
        cells_per_step    = 1 / Step;
        Cell_Width        = sound_instance_prefab.GetComponent <RectTransform>().sizeDelta.x;
        Load_Rhythm();

        foreach (Sound_Type_Mono sound in FindObjectsOfType <Sound_Type_Mono>())
        {
            List <Image> sep = new List <Image>();

            for (float x = 0; x < total_cells_count; x++)
            {
                Sound_Instance_Mono instance = Instantiate(sound_instance_prefab, sound.transform).GetComponent <Sound_Instance_Mono>();
                instance.Fire_Time = x * Step;
                instance.sound     = sound;

                sep.Add(Instantiate(separator_prefab, sound.transform).GetComponent <Image>());
            }

            separators.Add(sep);
        }

        Utils.Update_UI = true;
    }
示例#5
0
    public void Change_Song_Length(string value_s)
    {
        float value = float.Parse(value_s);

        float diff = value - Song_Length;

        Song_Length = value;


        if (diff > 0)
        {
            int y = 0;
            foreach (Sound_Type_Mono sound in FindObjectsOfType <Sound_Type_Mono>())
            {
                for (int x = total_cells_count; x < total_cells_count + diff * cells_per_step; x++)
                {
                    Sound_Instance_Mono instance = Instantiate(sound_instance_prefab, sound.transform).GetComponent <Sound_Instance_Mono>();
                    instance.Fire_Time = x * Step;
                    instance.sound     = sound;

                    separators[y].Add(Instantiate(separator_prefab, sound.transform).GetComponent <Image>());
                }

                y++;
            }
        }
        else if (diff < 0)
        {
            foreach (Sound_Type_Mono sound in FindObjectsOfType <Sound_Type_Mono>())
            {
                for (int x = total_cells_count - 1; x > total_cells_count - 1 + diff * cells_per_step; x--)
                {
                    Destroy(sound.Instances[x * Step].gameObject);
                }
            }

            foreach (List <Image> sep_row in separators)
            {
                for (int x = 0; x < Math.Abs(diff) * cells_per_step; x++)
                {
                    Image image = sep_row[sep_row.Count - 1];
                    sep_row.Remove(image);
                    Destroy(image.gameObject);
                }
            }
        }

        total_cells_count = (int)Math.Round(Song_Length / Step, 0);
        Update_Numerators();

        Utils.InvokeNextFrame(() =>
        {
            Reset_Events();
            rhythm_length.text = Song_Length.ToString();
            Utils.Update_UI    = true;
            Utils.Reactivate(FindObjectOfType <Canvas>().gameObject);
        });
    }
示例#6
0
    void Set_Height(Sound_Instance_Mono instance, float height)
    {
        RectTransform rect_transform = instance.sound.title.transform.parent.GetComponent <RectTransform>();

        rect_transform.sizeDelta = new Vector2(rect_transform.sizeDelta.x, height);

        rect_transform           = GetComponent <RectTransform>();
        rect_transform.sizeDelta = new Vector2(rect_transform.sizeDelta.x, height);
    }
    public void Change_Repetitions_Amount(uint repetitions_target)
    {
        List <Sound_Instance_Mono> cores       = Sound_Instances_Core;
        List <Sound_Instance_Mono> peripheries = Sound_Instances_Peripheric;
        uint repetitions_current = Data.Repetitions;

        int loop_steps = Data.Length_Steps;

        if (repetitions_target < repetitions_current)
        {
            for (uint x = repetitions_current; x > repetitions_target; x--)
            {
                for (int y = loop_steps - 1; y >= 0; y--)
                {
                    Sound_Instance_Mono periphery = peripheries[(int)(x - 1) * loop_steps + y];
                    periphery.Set_Repeated(null);
                    peripheries.Remove(periphery);
                }
            }
        }
        else
        {
            for (uint x = repetitions_current + 1; x <= repetitions_target; x++)
            {
                for (int y = 0; y < loop_steps; y++)
                {
                    Sound_Instance_Mono periphery = Sound.Instances[((int)x * loop_steps + y) * Rhythm_Player.Singleton.Step];
                    Sound_Instance_Mono core      = cores[y];

                    if (!periphery.Repeated)
                    {
                        periphery.Set_Repeated(core);
                        peripheries.Add(periphery);
                    }
                    else
                    {
                        Data.Repetitions = x;
                        Message.ShowMessage("Error, superposición entre bucles");
                        return;
                    }
                }
            }
        }

        Data.Repetitions = repetitions_target;
    }