public void Juntar(ObjLixoMisturado outro) { lixoMisturado.Fundir(outro.lixoMisturado); AjeitarTexto(); Debug.Log ("Aumentar tamanho e afins"); PararBrilhoJuntar(); outro.Remover(); }
public void Juntar(ObjLixoMisturado outro) { int novoNivel = this.Nivel() + outro.Nivel(); Vector2 pos = (Vector2) transform.position; this.Remover(); outro.Remover(); ObjGerenciadorLixo.CriarLixoEstatico(novoNivel, pos); //lixoMisturado.Fundir(outro.lixoMisturado); //AjeitarTexto(); //Debug.Log ("Aumentar tamanho e afins"); //PararBrilhoJuntar(); }
public static bool Adicionar(ObjLixoMisturado lixo) { if (instancia == null) return false; lock(instancia.listaLixos) { try { if (!instancia.listaLixos.Contains(lixo)) { lixo.transform.SetParent( instancia.transform, false); instancia.listaLixos.Add(lixo); } return true; } catch (UnityException e) { Debug.Log (e.Message); } } return false; }
void PararJuncao() { if (lixoPuxando != null) lixoPuxando.PararBrilhoJuntar(); if (lixoSendoPuxado != null) lixoSendoPuxado.PararBrilhoJuntar(); lixoPuxando = null; lixoSendoPuxado = null; juntandoLixos = false; podeJuntarLixo = true; AtribuirProximoTempoJuntar(); }
void JuntarLixo() { PararJuncao(); if (listaLixos.Count > 1) { // -1: aleatorio; 0: menor; 1: maior; int tipoDeBusca = -1; if (Random.value < 0.6f) { tipoDeBusca = 0; } else if (tipoDeBusca < 0.8f) { tipoDeBusca = 1; } if (tipoDeBusca == 0) { lixoPuxando = PegarMenorLixo(); foreach(ObjLixoMisturado olm in listaLixos) { if (olm.PodeJuntar(lixoPuxando) && olm.Nivel() <= lixoPuxando.Nivel()) { lixoSendoPuxado = olm; break; } } if (lixoSendoPuxado == null) { int i = (listaLixos.IndexOf(lixoPuxando) + 1) % listaLixos.Count; lixoSendoPuxado = listaLixos[i]; } //Debug.Log("Juntar menores"); } else if (tipoDeBusca == 1) { lixoPuxando = PegarMaiorLixo(); foreach(ObjLixoMisturado olm in listaLixos) { if (olm.PodeJuntar(lixoPuxando) && olm.Nivel() >= lixoPuxando.Nivel()) { lixoSendoPuxado = olm; break; } } if (lixoSendoPuxado == null) { int i = (listaLixos.IndexOf(lixoPuxando) + 1) % listaLixos.Count; lixoSendoPuxado = listaLixos[i]; } //Debug.Log("Juntar maiores"); } else { int i = Random.Range (0, listaLixos.Count); lixoPuxando = listaLixos[i]; lixoSendoPuxado = lixoPuxando; int contador = 1000; while (lixoPuxando == lixoSendoPuxado && contador > 0) { i = Random.Range (0, listaLixos.Count); lixoSendoPuxado = listaLixos[i]; contador--; } if (contador <= 0) { i = (listaLixos.IndexOf(lixoPuxando) + 1) % listaLixos.Count; lixoSendoPuxado = listaLixos[i]; } //Debug.Log("Juntar aleatórios"); } if (lixoSendoPuxado != null) { juntandoLixos = true; podeJuntarLixo = false; lixoPuxando.BrilharJuntar(); lixoSendoPuxado.BrilharJuntar(); velocidadeJuncaoLixos = lixoPuxando.transform.position - lixoSendoPuxado.transform.position; velocidadeJuncaoLixos /= demoraPraJuntarLixos; proximoTempoFinalizarJuncao = Time.time + demoraPraJuntarLixos; } } }
public static bool Remover(ObjLixoMisturado lixo) { if (instancia == null) return false; lock(instancia.listaLixos) { try { if (instancia.listaLixos.Contains(lixo)) { if (lixo == instancia.lixoPuxando || lixo == instancia.lixoSendoPuxado) { instancia.PararJuncao(); } instancia.listaLixos.Remove(lixo); } return true; } catch (UnityException e) { Debug.Log (e.Message); } } return false; }
public static bool NoMeioDeUmaJuncao(ObjLixoMisturado lixo) { if (lixo == instancia.lixoPuxando || lixo == instancia.lixoSendoPuxado) { return true; } return false; }
public bool PodeJuntar(ObjLixoMisturado outro) { if (this == outro) return false; return lixoMisturado.PodeFundir(outro.lixoMisturado); }