void Start() { if (porta == null) { porta = GetComponent <Interagivel_MudarMapa>(); } habilidade = GameManager.instancia.GetComponent <C_Habilidade>(); habilidade.AdicionarINGanharPontos(AbrirPorta); AbrirPorta(); }
void ProcurarInteragiveis() { Ray Raio = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit Hit; if (Physics.Raycast(Raio, out Hit, 100, layerInteragivel)) { if (Hit.collider.tag == "Porta") { Cursor.SetCursor(CursorMudarMapa, Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown(1)) { source.clip = abriuPorta; source.Play(); Interagivel_MudarMapa mudarmapa = Hit.collider.gameObject.GetComponent <Interagivel_MudarMapa>(); mudarmapa.Interagir(); INInteragiu?.Invoke(Hit.point); } return; } List <Interagivel> interagiveis = Hit.collider.gameObject.GetComponents <Interagivel>().ToList(); Interagivel novoInteragivel = interagiveis.Find(x => x.GetHabilidade() == GameManager.instancia.GetHabilidadeAtual()); if (novoInteragivel == null) { return; } if (!novoInteragivel.podeInteragir()) { return; } Debug.Log("Encontrou objeto: " + novoInteragivel.gameObject.name); if (novoInteragivel != interagivelAtual) { interagivelAtual = novoInteragivel; } interagivelAtual.Ligar(); Cursor.SetCursor(GameManager.instancia.GetHabilidadeAtual().GetCursorAssociado(), hotspot, CursorMode.Auto); if (Input.GetMouseButtonDown(1)) { source.clip = interagiu; interagivelAtual.Interagir(); INInteragiu?.Invoke(Hit.point); } } else { if (interagivelAtual != null) { interagivelAtual.Desligar(); } Cursor.SetCursor(CursorPadrao, hotspot, CursorMode.Auto); } }