public void Reveal() { if (m_TargetOpacity == 1) { return; } m_TargetOpacity = 1; // TODO: Optimize this Collider[] colliders = Physics.OverlapSphere(transform.position, m_TerrainRevealRadius); foreach (Collider c in colliders) { RevealableTerrain target = c.GetComponent <RevealableTerrain>(); if (target == null) { continue; } target.PaintAtPosition(transform.position, m_TerrainRevealRadius); } PlayAudioFx(); }
IEnumerator UpdateVisibilityFlags() { while (true) { Collider[] colliders = Physics.OverlapSphere(transform.position, m_RevealRadius, m_TerrainLayerMask); float startTime = Time.time; bool shouldReveal = false; foreach (Collider c in colliders) { RevealableTerrain target = c.GetComponent <RevealableTerrain>(); if (target == null) { continue; } Vector3[] positions = target.GetVertexPositions(); Color32[] colors = target.GetVertexColors(); if (positions == null) { continue; } if (colors == null) { continue; } for (int i = 0; i < positions.Length; ++i) { if (Vector3.Distance(transform.position, positions[i]) <= m_RevealRadius) { if (colors[i].r > 0) { shouldReveal = true; } } if (Time.time - startTime > 0.5f) { yield return(null); } } } m_IsVisible = shouldReveal; yield return(null); } }
private void PaintVertex() { float modulatedRadius = m_Radius / 2; Collider[] colliders = Physics.OverlapSphere(transform.position, modulatedRadius, m_VertexPaintMask); foreach (Collider c in colliders) { RevealableTerrain target = c.GetComponent <RevealableTerrain>(); if (target == null) { continue; } target.PaintAtPosition(transform.position, modulatedRadius, m_VertexPaintCurve); } }