Ejemplo n.º 1
0
 public override 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /// <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);
 }
 protected virtual void Awake()
 {
     target          = GetComponent <ChargeResource>();
     target.onChange = OnCharge;
 }