IEnumerator PostCompleteGlyphSequence() { var priest = GameObject.FindGameObjectWithTag("Priest"); priest.GetComponent <Animator> ().SetBool("Gospelling", true); AudioSource audioSource = GetComponent <AudioSource> (); audioSource.PlayOneShot(dialogs [currentGlyphIdSequence [0]], 1f); yield return(new WaitForSeconds(2f)); Debug.Log("Transitioning traits"); priest.GetComponent <Animator> ().SetBool("Gospelling", false); traitController.TransitionTraits(currSequence); currentGlyphIdSequence = new List <int> (); currSequence = new GlyphSequence(); currGlyphInSeq = 0; principalSymbolSet.setEmptySymbols(); currentTry += 1; yield return(new WaitForSeconds(2f)); waitingForGlyphs = true; CheckFinishConditions(); }
public void TransitionTraits(GlyphSequence g) { // Harcoded to hats and ponchos, // modify the signature if the logic changes Trait hat = getTrait("hat"); Trait poncho = getTrait("poncho"); if (hat.name == null) { Debug.LogError("hat trait not defined"); } if (poncho.name == null) { Debug.LogError("poncho trait not defined"); } List <int> notPonchoBlancoIds = Enumerable.Range(0, poncho.variations.Length) .ToList().Except(new[] { poncho.blancoId }).ToList(); foreach (var po in GameObject.FindGameObjectsWithTag("Person")) { Person p = po.GetComponent <Person>(); if (p.amIDisposable) { continue; } int currHatId = p.GetTraitVariation("hat"); int currPonchoId = p.GetTraitVariation("poncho"); if (currHatId != g.hat) { continue; } if (poncho.blancoId < 0) { Debug.LogError("Falta que implementar la lógica" + " cuando no hay poncho blanco"); } if (poncho.blancoId >= poncho.variations.Length) { Debug.LogError("Invalid poncho blanco id"); } //Poncho blanco if (currPonchoId == poncho.blancoId) { if (g.action == ActionGlyph.Up) { GivePersonTrait(poncho, g.poncho, p); } else if (g.action == ActionGlyph.Down) { int rnd = Random.Range(0, notPonchoBlancoIds.Count); GivePersonTrait(poncho, notPonchoBlancoIds[rnd], p); } } //Matchea else if (currPonchoId == g.poncho) { if (g.action == ActionGlyph.Down) { GivePersonTrait(poncho, poncho.blancoId, p); } } // No matchea else { if (g.action == ActionGlyph.Up) { GivePersonTrait(poncho, poncho.blancoId, p); } } } ; }