public void Darp() { VurusTipi vurustipi = usuller[usulIndex].vuruslar[vurusIndex]; Vurus vurus = sablon.vurusListesi[vurustipi]; switch (vurus.ses) { case VurusSesi.Dum: dum.Play(); break; case VurusSesi.Tek: tek.Play(); break; case VurusSesi.Hek: dum.Play(); tek.Play(); break; } //Debug.Log(Time.time); sablon._vurusObjeleri[vurusIndex].GetComponent <Image>().color = Color.green; int oncekiVurus = vurusIndex == 0 ? usuller[usulIndex].vuruslar.Length - 1 : vurusIndex - 1; sablon._vurusObjeleri[oncekiVurus].GetComponent <Image>().color = Color.white; Debug.Log(Time.time - lastVurus); lastVurus = Time.time; if (vurusIndex == usuller[usulIndex].vuruslar.Length - 1) { if (tekrar) { float bekleme = yonetmen.ritim * ((usuller[usulIndex].birim * 1f) / (vurus.zaman * 1f)); Invoke("Darp", bekleme); } else { Invoke("Sondur", yonetmen.ritim); yonetmen.MetronomDurdur(); } } else { float bekleme = yonetmen.ritim * ((usuller[usulIndex].birim * 1f) / (vurus.zaman * 1f)); Invoke("Darp", bekleme); } vurusIndex = vurusIndex == usuller[usulIndex].vuruslar.Length - 1 ? 0 : vurusIndex + 1; }
public void Olustur() { ListeyiOlustur(); foreach (GameObject v in _vurusObjeleri) { DestroyImmediate(v); } _vurusObjeleri.Clear(); int aralik = (bitis - baslangic) / (vuruslar.Length + 1); int pozisyon = baslangic + aralik; VurusTipi onceki = vuruslar[0]; foreach (VurusTipi v in vuruslar) { GameObject vrs = GameObject.Instantiate(vurusSablon.gameObject); if (v.ToString().StartsWith("Dum") || v.ToString().StartsWith("Hek")) { vrs.transform.SetParent(ustCizgi); if (onceki.ToString().StartsWith("Tek")) { pozisyon += aralik / 2; } } else { vrs.transform.SetParent(altCizgi); } vrs.name = v.ToString(); vrs.GetComponent <Image>().sprite = vurusListesi[v].sprite; vrs.transform.localScale = Vector3.one; vrs.GetComponent <RectTransform>().anchorMin = Vector2.zero; vrs.GetComponent <RectTransform>().anchorMax = Vector2.zero; if (v.ToString().StartsWith("Hek")) { pozisyon += aralik / 2; vrs.GetComponent <RectTransform>().pivot = new Vector2(vurusListesi[v].sprite.pivot.x / 128, vurusListesi[v].sprite.pivot.y / 256); vrs.GetComponent <RectTransform>().anchoredPosition = new Vector2(pozisyon, 0); vrs.GetComponent <RectTransform>().sizeDelta = new Vector2(64, 128); } else { vrs.GetComponent <RectTransform>().pivot = vurusListesi[v].sprite.pivot / 128; vrs.GetComponent <RectTransform>().anchoredPosition = new Vector2(pozisyon, 0); vrs.GetComponent <RectTransform>().sizeDelta = new Vector2(64, 90); } //pozisyon += v.ToString().StartsWith("Dum") ? aralik / 2 : (aralik * 1) / 1; if (v.ToString().StartsWith("Dum")) { pozisyon += aralik / 2; } else { pozisyon += aralik; } // pozisyon += aralik;// / 2; _vurusObjeleri.Add(vrs); onceki = v; } birimText.text = birim.ToString(); zamanText.text = zaman.ToString(); usulText.text = UsulAdı; }