IEnumerator Fail(SelectScript2_FIL Script1, SelectScript2_FIL Script2) {//si fallas tarda un tiempo en volver a ocultarse yield return(new WaitForSeconds(1f)); timer -= 5; Script1.DesSelect(); Script2.DesSelect(); Select1 = null; Select2 = null; }
void Comprobar() {//comprueba si ambas cartas seleccionadas son iguales(teniendo en cuenta el nivel tienen comportamiento distinto al fallar if (level == 1) { SelectScript_FIL Script1 = Select1.GetComponent <SelectScript_FIL>(); SelectScript_FIL Script2 = Select2.GetComponent <SelectScript_FIL>(); if (Script1.type == Script2.type) { Script1.Correct(); Script2.Correct(); Select1 = null; Select2 = null; timer += 15; aciertos++; if (aciertos == 10) { Win(); } } else { timer -= 5; Script1.DesSelect(); Script2.DesSelect(); Select1 = null; Select2 = null; } } else if (level == 2) { SelectScript2_FIL Script1 = Select1.GetComponent <SelectScript2_FIL>(); SelectScript2_FIL Script2 = Select2.GetComponent <SelectScript2_FIL>(); if (Script1.type == Script2.type) { Script1.Correct(); Script2.Correct(); Select1 = null; Select2 = null; timer += 15; aciertos++; if (aciertos == 10) { Win(); } } else { StartCoroutine(Fail(Script1, Script2)); } } }