Pull request #38: Fixed resource collecting bug
Merge in CGD/gather-and-defend from feature/fixRecolteBug to main * commit '5deeb528b8783c2e3c2e54753e7c369b4c910d59': Ajusted the behavior to be performance efficient Fixed yield collecting bug Ajustement de l'ordre des sprite des recoltes
This commit is contained in:
commit
76c90cacdd
@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
/// <summary>
|
||||
/// Handles what happens when the user clicks on a collider
|
||||
@ -9,13 +10,15 @@ public class ClickBehavior : MonoBehaviour
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
Vector2 clickPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
RaycastHit2D hit = Physics2D.Raycast(clickPoint, transform.up);
|
||||
if (hit.collider != null)
|
||||
List<Collider2D> listColliders = new(Physics2D.OverlapCircleAll(clickPoint, 0.05f));
|
||||
List<Collider2D> resourceColliders = listColliders.FindAll(obj => obj.CompareTag("Resource"));
|
||||
if (resourceColliders.Count > 0)
|
||||
{
|
||||
if (hit.collider.CompareTag("Resource"))
|
||||
foreach (Collider2D collider in resourceColliders)
|
||||
{
|
||||
hit.collider.GetComponent<ResourceMaker>().GenerateResource();
|
||||
collider.GetComponent<ResourceMaker>().GenerateResource();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user