Ejemplo n.º 1
0
        public void OnContainerIconDrop(ContainerIcon icon)
        {
            containers.ForEach((x) => x.GetComponent <ContainerController>().TurnLight(false));
            List <Container> intersectedContainers = containers.FindAll((x) => x.Intersects(icon));

            Container container = null;

            if (intersectedContainers.Count > 0)
            {
                container = intersectedContainers.Aggregate <Container>(
                    (x, y) => x.GetComponent <SpriteRenderer>().sortingOrder > y.GetComponent <SpriteRenderer>().sortingOrder ? x : y
                    );
            }

            if (container != null && container.gameObject != icon.transform.parent.gameObject)
            {
                ExecuteEvents.Execute <IContainerHandler>(container.gameObject, null, (x, y) => x.OnContainerDrop(icon.transform.parent.GetComponent <Container>()));
            }
        }
Ejemplo n.º 2
0
 public bool Intersects(ContainerIcon icon)
 {
     return(icon.GetComponent <SpriteRenderer>().bounds.Intersects(containerCollider.bounds));
 }
Ejemplo n.º 3
0
 void Awake()
 {
     icon = GetComponentInChildren <ContainerIcon>();
     containerCollider = GetComponent <Collider2D>();
 }