public IList <Elemento> generarCompas(Compas compas, string tonalidad, int grado) { IList <Elemento> result = new List <Elemento>(); // generar el ritmo double longitudCompas = compas.getLongitud(); IList <BloqueRitmico> bloques = new List <BloqueRitmico>(); double longitud = 0; longitud = generarBloquesRitmicos(bloques, longitud, longitudCompas); if (longitud < longitudCompas) { throw new Exception("Con los bloques rítmicos disponibles no se puede rellenar el compás. With the rythm blocks available it is not possible to fill the measure"); } // generar la melodía IList <Nota> notasCandidatas = MusicUtils.obtenerNotas(tonalidad, grado, notasDisponibles); foreach (BloqueRitmico bloque in bloques) { string[] duraciones = bloque.getDuraciones(); foreach (string duracion in duraciones) { Nota notaCandidata = notasCandidatas[MusicUtils.rnd.Next(notasCandidatas.Count)]; Nota nota = new Nota(notaCandidata.getNombre(), notaCandidata.getOctava(), duracion); result.Add(nota); } } return(result); }
public void TurnTo(Compas c) { int dirDiff = Mod(c - compas, 4); if (dirDiff == 1) { dir = Turning.RIGHT; } else if (dirDiff == 3) { dir = Turning.LEFT; } }
public override void PreGameStep() { ms = MoveScore.MOVE; switch (dir) { case Turning.FORWARD: break; case Turning.LEFT: compas = (Compas)Mod((int)compas - 1, 4); turns++; break; case Turning.RIGHT: compas = (Compas)Mod((int)compas + 1, 4); turns++; break; } dir = Turning.FORWARD; }
private void Awake() { compas = gameObject.GetComponent <Compas>(); var tAsset = Resources.Load("data") as TextAsset; xDoc = XElement.Parse(tAsset.text); xElement = xDoc.Elements("pin"); Input.location.Start(); #region old_Ver //cts = new CancellationTokenSource(); //locationChecker = new Thread(() => // { // xElement = xDoc.Elements("pin"); // try // { // while (true) // { // cts.Token.ThrowIfCancellationRequested(); // var selected = xElement.Where(xe => // { // float[] pos = { float.Parse(xe.Element("latitude").Value), float.Parse(xe.Element("longitude").Value) }; // var dis = DistanceCalc(compas.myPosition, pos); // var type = xe.Element("type").Value; // if (type == "group") // { // return dis <= groupDistance; // } // else // { // return dis <= locationDistance; // } // }).FirstOrDefault(); // if (selected != null) // { // var type = selected.Element("type").Value; // if (type == "group") // { // xElement = selected.Elements("childs"); // isInGroup = true; // } // else if (type == "location") // { // isInLocation = true; // } // contents = selected.Element("contents").Value; // } // else // { // xElement = xDoc.Elements("pin"); // isInGroup = false; // isInLocation = false; // contents = "none"; // } // } // } // catch // { // Debug.Log("stop!!"); // } // }); //locationChecker.Name = "LocationChecker"; //locationChecker.Start(); #endregion }
protected void cargarConfiguracion() { cfg.compas = ddlCompas.SelectedValue; cfg.tonalidad = rblTonalidad.SelectedValue; cfg.compases = tbCompases.Text; cfg.pentagrama_rango_g = ddlRangoG1A.SelectedValue + ddlRangoG1B.SelectedValue + "," + ddlRangoG2A.SelectedValue + ddlRangoG2B.SelectedValue; cfg.pentagrama_rango_f = ddlRangoF1A.SelectedValue + ddlRangoF1B.SelectedValue + "," + ddlRangoF2A.SelectedValue + ddlRangoF2B.SelectedValue; StringBuilder aux = new StringBuilder(); foreach (ListItem item in cblBloquesRitmicosG.Items) { if (item.Selected) { if (aux.Length > 0) { aux.Append(","); } aux.Append(item.Value); } } cfg.bloques_ritmicos_g = aux.ToString(); if (cfg.bloques_ritmicos_g.Length == 0) { throw new Exception("You must select one or more rythm blocks for the treble cleff."); } aux = new StringBuilder(); foreach (ListItem item in cblBloquesRitmicosF.Items) { if (item.Selected) { if (aux.Length > 0) { aux.Append(","); } aux.Append(item.Value); } } cfg.bloques_ritmicos_f = aux.ToString(); if (cfg.bloques_ritmicos_f.Length == 0) { throw new Exception("You must select one or more rythm blocks for the bass cleff."); } string[] sListaPentagramas = cfg.pentagramas.Split(','); pentagramas = new Pentagrama[sListaPentagramas.Length]; for (int i = 0; i < sListaPentagramas.Length; i++) { pentagramas[i] = new Pentagrama(cfg.tonalidad, sListaPentagramas[i]); } compas = new Compas(cfg.compas); compases = int.Parse(cfg.compases); progresiones = new Dictionary <int, IList <int> >(); progresionesInversas = new Dictionary <int, IList <int> >(); string[] sListaProgresiones = cfg.progresiones_acordes.Split(','); for (int i = 0; i < sListaProgresiones.Length; i++) { string[] sValores = sListaProgresiones[i].Split(':'); string sOrigen = sValores[0]; string[] sDestinos = sValores[1].Split('-'); int key = int.Parse(sOrigen); IList <int> value = new List <int>(); for (int j = 0; j < sDestinos.Length; j++) { int val = int.Parse(sDestinos[j]); value.Add(val); IList <int> inversa = null; if (progresionesInversas.ContainsKey(val)) { inversa = progresionesInversas[val]; } if (inversa == null) { inversa = new List <int>(); inversa.Add(key); progresionesInversas.Add(val, inversa); } else if (inversa.IndexOf(key) < 0) { inversa.Add(key); } } progresiones.Add(key, value); } }