Esempio n. 1
0
 public bool Click(out TargetObject target)
 {
     target = null;
     for (int i = 0; i < targetObjectManager.targets.Count; i++)
     {
         float pos = targetObjectManager.targets[i].GetPos();
         if (pos >= areaLowerLimit)
         {
             if (pos < areaUpperLimit)
             {
                 target = targetObjectManager.targets[i];
                 if (target.id == id && target.GetIsClicked() != true)
                 {
                     target.SetIsClicked(true);
                     ClickEffect obj = objectPool.GetItem(clickEffect, null).GetComponent <ClickEffect>();
                     obj.transform.localPosition = Vector3.zero;
                     obj.Play(target.transform);
                     return(true);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
    private void TargetPathEndReached(object sender)
    {
        TargetObject obj = (TargetObject)sender;

        if (!obj.GetIsClicked())
        {
            FailedToClickInTime.Invoke(this);
        }
        obj.EndReached -= TargetPathEndReached;
        objectPool.ReturnItem(obj.gameObject);
        targets.RemoveAt(0); // Removes at 0 as it is expected that oldest object is first to arrive to end
    }