Beispiel #1
0
    public void Actualize()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2 wpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Hidder  h    = FindHidder(wpos);

            if (h != null)
            {
                h.Bump();
            }
        }
    }
Beispiel #2
0
    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);
    }
Beispiel #3
0
 public void Unregister(Hidder hidder)
 {
     _hidders.Remove(hidder);
 }
Beispiel #4
0
 public void Register(Hidder hidder)
 {
     _hidders.Add(hidder);
 }