Пример #1
0
    public Nota Add_Nota(Holder hold, Znak target = null, int input_delka = -1, float adapt = 0)
    {
        if (hold == null)
        {
            hold = hands[0];
        }
        bool middle = true;

        if (target == null)
        {
            target = hold.Posledni;
            middle = false;
        }
        GameObject GO = Instantiate(proto_nota, paper.transform, false);

        GO.name = "nota " + hold.not + " " + hold.id;
        GO.SetActive(true);
        hold.not++;
        Nota made = GO.AddComponent <Nota>();

        made.Do_data();
        made.master  = hold;
        made.Hand_id = hands.GetLength(0) - 1 + hold.id;
        if (adapt == 0)
        {
            if (input_delka == -1)
            {
                int tmp_delka = 1;
                for (int i = 4; i > -1; i--)
                {
                    if (Math.Pow(2, i) <= takt)
                    {
                        tmp_delka = i;
                        i         = -1;
                    }
                }
                made.Delka = tmp_delka;
            }
            else
            {
                made.Delka = input_delka;
            }
        }
        else
        {
            made.Adapt(adapt, false);
        }
        if (target != null)
        {
            if (middle && target.Next != null)
            {
                made.Next = target.Next;
            }
            else
            {
                hold.Posledni = made;
            }
            target.Next = made;
            made.Prev   = target;
            made.Bump_pos();
        }
        else
        {
            hold.Prvni    = made;
            hold.Posledni = made;
            made.Linka    = hold.first;
            made.Calc_Pos();
        }
        made.Update_delka();
        Do_Takty(hold);
        hold.vybrany = made;
        if (hold.nakonec != null)
        {
            hold.nakonec.add(made);
        }
        Select_hand(hold);
        Select_HUD.Adjust_HUD(made);
        return(made);
    }