private void ChargeOneTool(ChargeTool tool, UnityAction onComplete)
        {
            var resources      = elementCtrl.GetElements <ChargeResource>();
            var chargeResource = resources.Find(x => tool.CanLoad(x.type) && x.Active);
            var value          = Mathf.Min(tool.capacity, chargeResource.current);
            var type           = chargeResource.type;

            tool.PickUpAble = false;
            tool.LoadData(chargeResource.transform.position, new ChargeData(type, value), () => {
                tool.PickUpAble = true;
            });
            chargeResource.Subtruct(value, () => { onComplete.Invoke(); });
        }
        private void ChargeCurrentObj(ChargeTool tool, UnityAction onComplete)
        {
            var        data     = tool.data;
            ChargeData worpData = JudgeLeft(data);

            if (!string.IsNullOrEmpty(worpData.type))
            {
                tool.PickUpAble = false;
                tool.OnCharge(transform.position, worpData.value, () => { tool.PickUpAble = true; });
                Charge(worpData, () => {
                    onComplete();
                });
            }
        }
 /// <summary>
 /// 空间查找Resource
 /// </summary>
 /// <param name="item"></param>
 /// <param name="resourceItem"></param>
 /// <returns></returns>
 public static bool FindResource(ChargeTool item, out ChargeResource resourceItem)
 {
     Collider[] colliders = Physics.OverlapSphere(item.transform.position, item.Range, LayerMask.GetMask(Layers.chargeResourceLayer));
     if (colliders != null && colliders.Length > 0)
     {
         foreach (var collider in colliders)
         {
             ChargeResource temp = collider.GetComponentInParent <ChargeResource>();
             if (temp != null && item.CanLoad(temp.type))
             {
                 resourceItem = temp;
                 return(true);
             }
         }
     }
     resourceItem = null;
     return(false);
 }
        internal static bool FindChargeObj(ChargeTool item, out ChargeObj chargeObj)
        {
            Collider[] colliders = Physics.OverlapSphere(item.transform.position, item.Range, LayerMask.GetMask(Layers.chargeObjLayer));
            if (colliders != null && colliders.Length > 0)
            {
                foreach (var collider in colliders)
                {
                    ChargeObj temp = collider.GetComponentInParent <ChargeObj>();

                    if (temp != null && temp.Started && !temp.Completed && temp.completeDatas.FindAll(x => x.type == item.data.type).Count > 0)
                    {
                        chargeObj = temp;
                        return(true);
                    }
                }
            }
            chargeObj = null;
            return(false);
        }
 protected virtual void Awake()
 {
     target          = GetComponent <ChargeTool>();
     target.onCharge = OnCharge;
     target.onLoad   = OnLoad;
 }