public void Actualize() { if (Input.GetMouseButtonDown(0)) { Vector2 wpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Hidder h = FindHidder(wpos); if (h != null) { h.Bump(); } } }
Hidder FindHidder(Vector2 wpos) { float bestDist = float.MaxValue; Hidder best = null; for (int i = 0; i < _hidders.Count; i++) { Rect rect = _hidders[i].GetCollider(true); if (rect.Contains(wpos)) { float dist = Vector2.Distance(rect.center, wpos); if (dist < bestDist) { best = _hidders[i]; bestDist = dist; } } } return(best); }
public void Unregister(Hidder hidder) { _hidders.Remove(hidder); }
public void Register(Hidder hidder) { _hidders.Add(hidder); }