void OnTriggerEnter(Collider other) { switch (Principal.tag) { case "Player": if (!Principal.GetComponent <ControleDeAnimacao>().Atacando&& GetComponent <NivelArma>().arma != Dados.Armas.Arco && GetComponent <NivelArma>().arma != Dados.Armas.Cajado) { return; } if (other.CompareTag("Enemy")) { ControleDeArmas ctrArma = Principal.GetComponent <ControleDeArmas>(); DanoArma danoArma = GetComponent <DanoArma>(); Atributos atb = other.GetComponent <Atributos>(); DisparadordeSons.PlayOneShot(SomDano); int danoCalculado = (int)(danoArma.Dano * ctrArma.multi); if (atb.Especialidade == ctrArma.arma) { danoCalculado = (int)(danoArma.Dano * atb.multiEspecialidade); } float variacao = Random.Range(.9f, 1.1f); atb.CausarDano((int)(danoCalculado * variacao)); } break; case "Enemy": if (!Principal.GetComponent <ControledeAnimacaoInimigo>().Atacando) { return; } if (other.CompareTag("Player")) { danoArma = GetComponent <DanoArma>(); atb = other.GetComponent <Atributos>(); DisparadordeSons.PlayOneShot(SomDano); int danoCalculado = (int)(danoArma.Dano); float variacao = Random.Range(.9f, 1.1f); atb.CausarDano((int)(danoCalculado * variacao)); } break; } }
public void MudarPersonagem(int i) { selecao.SFX.PlayOneShot(selecao.SomClick); if (i > Personagens.Length - 1) { i = 0; } if (i < 0) { i = Personagens.Length - 1; } for (int x = 0; x < Personagens.Length; x++) { Personagens[x].SetActive(x == i ? true : false); Person = Personagens[x].GetComponent <Atributos>().Personagem; ControleDeArmas ctrArmas = Personagens[x].GetComponent <ControleDeArmas>(); ctrArmas.AtivarArma(ctrArmas.arma, ctrArmas.nivel); } indice = i; }
void Update() { timer += Time.deltaTime; if (Personagens.Length == 0) { return; } if (Input.GetButtonDown(playerIndice.ToString() + "B") && !Selecao) { SceneManager.LoadScene("Menu"); } if (Selecao) { if (Input.GetAxisRaw(playerIndice.ToString() + "Right/Left") != 0 && timer > 1f) { timer = 0; switch ((int)Input.GetAxisRaw(playerIndice.ToString() + "Right/Left")) { case 1: indice += 1; MudarPersonagem(indice); break; case -1: indice -= 1; MudarPersonagem(indice); break; } } if (Input.GetButtonDown(playerIndice.ToString() + "A")) { print("A"); if (FindObjectOfType <Selecao>().PodeSelecionar(Person)) { print("A"); selecao.SFX.PlayOneShot(selecao.SomClick); Confirmado = true; Personagens[indice].GetComponent <ControleDeAnimacao>().Selecionar(); GetComponent <Image>().color = Color.yellow; PersonagemSelecionado.personagem = Person; PersonagemSelecionado.playerIndice = playerIndice; } } if (Input.GetButtonDown(playerIndice.ToString() + "B")) { if (Confirmado) { print("B"); selecao.SFX.PlayOneShot(selecao.SomClick); Confirmado = false; Personagens[indice].GetComponent <ControleDeAnimacao>().DesSelecionar(); GetComponent <Image>().color = Color.white; PersonagemSelecionado.personagem = Dados.Personagens.Nenhum; PersonagemSelecionado.playerIndice = Dados.PlayerIndice.Vazio; } else { selecao.SFX.PlayOneShot(selecao.SomClick); Selecao = false; for (int x = 0; x < Personagens.Length; x++) { Personagens[x].SetActive(false); } Person = Dados.Personagens.Nenhum; indice = 0; txtBotaoPlayer.enabled = true; } } } if (Input.GetButtonDown(playerIndice.ToString() + "Start") && !Selecao) { Selecao = true; selecao.SFX.PlayOneShot(selecao.SomClick); Debug.Log(Personagens.Length, gameObject); Personagens[0].SetActive(true); Personagens[0].GetComponent <ControleDeAnimacao>().Idle(1); Person = Personagens[0].GetComponent <Atributos>().Personagem; ControleDeArmas ctrArmas = Personagens[0].GetComponent <ControleDeArmas>(); ctrArmas.AtivarArma(ctrArmas.arma, ctrArmas.nivel); txtBotaoPlayer.enabled = false; } }