public void Update()
 {
     if (chargeTool != null)
     {
         if (chargeTool.charged)
         {
             if (ChargeUtil.FindChargeObj(chargeTool, out chargeObj))
             {
                 if (chargeObj != lastMatchChargeObj)
                 {
                     if (lastMatchChargeObj != null)
                     {
                         highter.UnHighLightTarget(lastMatchChargeObj.gameObject);
                     }
                     highter.HighLightTarget(chargeObj.gameObject, Color.green);
                     lastMatchChargeObj = chargeObj;
                 }
             }
             else
             {
                 if (lastMatchChargeObj != null)
                 {
                     highter.UnHighLightTarget(lastMatchChargeObj.gameObject);
                     lastMatchChargeObj = null;
                 }
             }
         }
         else
         {
             if (ChargeUtil.FindResource(chargeTool, out chargeResource))
             {
                 if (chargeResource != lastMatchChargeResource)
                 {
                     if (lastMatchChargeResource != null)
                     {
                         highter.UnHighLightTarget(lastMatchChargeResource.gameObject);
                     }
                     highter.HighLightTarget(chargeResource.gameObject, Color.green);
                     lastMatchChargeResource = chargeResource;
                 }
             }
             else
             {
                 if (lastMatchChargeResource != null)
                 {
                     highter.UnHighLightTarget(lastMatchChargeResource.gameObject);
                     lastMatchChargeResource = null;
                 }
             }
         }
     }
 }
        /// <summary>
        /// 空间查找Resource
        /// </summary>
        /// <param name="item"></param>
        /// <param name="resourceItem"></param>
        public static bool FindResource(ChargeTool item, out ChargeResource resourceItem)
        {
            var resourceItems = SelectItems <ChargeResource>(ChargeResource.layer, CameraController.Instence.currentCamera.transform.position, item.transform.position, item.Range);

            if (resourceItems == null || resourceItems.Length == 0)
            {
                resourceItem = null;
                return(false);
            }
            else
            {
                for (int i = 0; i < resourceItems.Length; i++)
                {
                    ChargeResource tempItem = resourceItems[i];
                    if (tempItem != null && tempItem.Actived && item.CanLoad(tempItem.type) && tempItem.current > 0)
                    {
                        resourceItem = tempItem;
                        return(true);
                    }
                }
                resourceItem = null;
                return(false);
            }
        }
        private void OnPickStay(PickUpAbleComponent item)
        {
            var chargeTool = item.GetComponentInParent <ChargeTool>();

            if (chargeTool)
            {
                var currTool = chargeTool;
                if (chargeResource != null)
                {
                    var value = Mathf.Min(currTool.capacity, chargeResource.current);
                    var type  = chargeResource.type;
                    currTool.RetriveFeature <PickUpAbleFeature>().PickUpAble = false;
                    currTool.LoadData(chargeResource.transform.position, new ChargeData(type, value), () =>
                    {
                        currTool.RetriveFeature <PickUpAbleFeature>().PickUpAble = true;
                    });
                    chargeResource.Subtruct(value, () => { });

                    highter.UnHighLightTarget(chargeResource.gameObject);
                    lastMatchChargeResource = chargeResource = null;
                }
                else if (chargeObj != null)
                {
                    var        data     = currTool.data;
                    ChargeData worpData = chargeObj.JudgeLeft(data);
                    if (!string.IsNullOrEmpty(worpData.type))
                    {
                        currTool.RetriveFeature <PickUpAbleFeature>().PickUpAble = false;
                        currTool.OnCharge(chargeObj.transform.position, worpData.value, () => { currTool.RetriveFeature <PickUpAbleFeature>().PickUpAble = true; });
                        chargeObj.Charge(worpData, () => { chargeObj.JudgeComplete(); });
                    }
                    highter.UnHighLightTarget(chargeObj.gameObject);
                    lastMatchChargeObj = null;
                }
            }
        }
 protected virtual void Awake()
 {
     target          = GetComponent <ChargeResource>();
     target.onChange = OnCharge;
 }