private void OnTriggerEnter2D(Collider2D collision) { KeyVar myKeys = GameController.g.MyKeys; if (collision.tag == "Player") { if (myKeys.VerificaCont(KeyCont.losangulosPegos) >= InicioDeAcao && myKeys.VerificaCont(KeyCont.losangulosConfirmados) < FinalDeAcao && myKeys.VerificaCont(KeyCont.losangulosPegos) > myKeys.VerificaCont(KeyCont.losangulosConfirmados)) { if (UnicidadeDoPlayer.Verifique(collision)) { EventAgregator.Publish(new StandardSendGameEvent(gameObject, EventKey.cofreRequisitado)); if (myKeys.VerificaCont(KeyCont.losangulosPegos) >= FinalDeAcao) { new MyInvokeMethod().InvokeNoTempoDeJogo(() => { premio.SetActive(true); GetComponent <SpriteRenderer>().sprite = spriteAberto; Destroy(Instantiate(LosanguloManager.l.ParticulaPoeira, transform.position, Quaternion.identity), 5); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.rockFalseAttack)); TrophiesManager.VerifyTrophy(TrophyId.abraUmCofre); }, 1); } } } } }
void VerifiqueConfirmacao(GameObject qual) { CofreDosLosangulos c = null; for (int i = 0; i < cofres.Length; i++) { if (qual == cofres[i].gameObject) { Debug.Log("indice do cofre é: " + i); c = cofres[i]; } } KeyVar myKeys = GameController.g.MyKeys; int sum = 0; for (int i = myKeys.VerificaCont(KeyCont.losangulosConfirmados); i < myKeys.VerificaCont(KeyCont.losangulosPegos); i++) { if (i >= c.InicioDeAcao - 1 && i < c.FinalDeAcao) { SouUmLosanguloGerenciavel s = transform.GetChild(i).GetComponent <SouUmLosanguloGerenciavel>(); s.MySprite.sprite = spriteAmarelo; Debug.Log("filho " + i + " :" + s.name); GameObject G = Instantiate(particulaDaConfirmacao, s.transform.position, Quaternion.identity); G.SetActive(true); Destroy(G, 5); SpawnMoedas.Spawn(s.transform.position, Mathf.Max(5, i)); sum++; } } if (sum > 0) { EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.somParaGetLosangulo)); new MyInvokeMethod().InvokeNoTempoDeJogo(() => { EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.VariasMoedas)); }, .35f); } myKeys.SomaCont(KeyCont.losangulosConfirmados, sum); Debug.Log(myKeys.VerificaCont(KeyCont.losangulosConfirmados) + " confirmados"); }