void HighlightInteractableTiles(Pim pim, Item item) { List <GameObject> gos = GameObject.FindGameObjectsWithTag("PickupPoint").ToList <GameObject>(); List <PickupPoint> pickupPoints = new List <PickupPoint>(); foreach (var go in gos) { PickupPoint pickupPoint = go.GetComponent <PickupPoint>(); if (pickupPoint) { pickupPoints.Add(pickupPoint); } } foreach (PickupPoint pickupPoint in pickupPoints) { //if (pickupPoint.CanDropHere()) { if (pickupPoint.IsOccupied()) { GameObject recipesObj = GameObject.FindGameObjectWithTag("Recipes"); Recipes recipes = recipesObj.GetComponent <Recipes>(); GameObject itemObject = pickupPoint.GetItem(); if (itemObject != null) { Item anItem = itemObject.GetComponent <Item>(); if (anItem != null) { ItemType itemType = anItem.itemType; Item currentItemObj = currentItem.GetComponent <Item>(); if (currentItem != null) { Recipes.Recipe foundRecipe = recipes.GetRecipe(itemType, currentItemObj.itemType); if (foundRecipe.output != null) { GameObject go = Instantiate(mergableEffect, pickupPoint.gameObject.transform.position, Quaternion.identity); highlightEffectCache.Add(go); go.transform.SetParent(itemObject.transform); } } } } } else { if (pickupPoint.CanDropHere()) { GameObject go = Instantiate(highlightEffect, pickupPoint.gameObject.transform.position, Quaternion.identity); highlightEffectCache.Add(go); } } //} } }
public void Interact() { List <GameObject> pickupPoints = GameObject.FindGameObjectsWithTag("PickupPoint").ToList <GameObject>(); pickupPoints = pickupPoints.OrderBy(x => GetDistanceToObject(x)).ToList(); foreach (GameObject pickupPointObj in pickupPoints) { PickupPoint pickupPoint = pickupPointObj.GetComponent <PickupPoint>(); if (pickupPoint != null) { Collider2D pickupPointCollider = pickupPointObj.GetComponent <Collider2D>(); if (pickupPointCollider != null) { bool standingOnPickupPoint = pickupPointCollider.OverlapPoint(transform.position); if (standingOnPickupPoint) { if (pickupPoint.GetItem() != null) { if (pickupPoint.CanPickupHere()) { bool pickedUpItem = PickupItem(pickupPoint); if (pickedUpItem) { AudioManager.instance.PlaySfx("Blip_Select5"); } else if (!pickedUpItem) { if (pickupPoint.MergeItem(currentItem)) { ClearAllHighlightedTiles(this, currentItem.GetComponent <Item>()); Destroy(currentItem); currentItem = null; PickupItem(pickupPoint); if (currentItem) { Item mergedItem = currentItem.GetComponent <Item>(); if (mergedItem) { if (mergedItem.itemType.name == "Black Matter") { GameObject go = Instantiate(blackMatterMergeEffect, transform.position, Quaternion.identity); go.transform.SetParent(transform); AudioManager.instance.PlaySfx("BlackMattert"); } else { GameObject go = Instantiate(successfulMergeEffect, transform.position, Quaternion.identity); go.transform.SetParent(transform); AudioManager.instance.PlaySfx("Blip_Select10"); } } } } } } } else { if (pickupPoint.CanDropHere()) { if (DropItem(pickupPoint)) { AudioManager.instance.PlaySfx("Blip_Select7"); EZCameraShake.CameraShaker.Instance.ShakeOnce(0.2f, 5.0f, 0.2f, 0.2f); } } } } } } } }