// Update is called once per frame void Update() { if (_inv.InventoryPanelStat()) { return; } InLineOfSight(); var pos = transform.position; pos.z += 0.01f; if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) { _popupAction.SetActive(false); var touchLocation = Camera.main.ScreenToWorldPoint(Input.mousePosition); float distance = Vector2.Distance(touchLocation, pos); //AttackTarget Also check AttackInside foreach (var monster in _terrainManager.GetMonster(touchLocation, 0.4f)) { _popupAction.GetComponent <ActionHandler>().SetActiveMonster(monster, transform, "Terrain"); CreateFloatingAction(touchLocation, "Monster"); return; } //Consume Element var currentElement = _terrainManager.GetElement(touchLocation); if (currentElement != null) { if (distance < 1) { _popupAction.GetComponent <ActionHandler>().SetActiveElement(currentElement); CreateFloatingAction(touchLocation, "Element"); return; } } //Pick Up Item var currentItem = _terrainManager.GetDropItem(touchLocation); if (currentItem != null) { print("currentItem happening :" + distance + " _item:" + currentItem.ItemTypeInUse.Name); if (distance < 1) { _popupAction.GetComponent <ActionHandler>().SetActiveItem(currentItem, "Terrain"); _popupAction.GetComponent <ActionHandler>().GrabItem(); //Performance: Less click approach //CreateFloatingAction(touchLocation, "Item"); } else { _GUIManager.PrintMessage("Too Far from this Target!", Color.yellow); } return; } //Digging if (distance < 1) { TerrainIns currentTerrain = _terrainManager.SelectTerrain(touchLocation); //print("TerrainIns distance < 1" +currentTerrain.MyInfo()); if (currentTerrain.Digable) { touchLocation.z = pos.z; _popupAction.GetComponent <ActionHandler>().SetActiveTerrain(currentTerrain); CreateFloatingAction(touchLocation, "Dig"); return; } } CreateFloatingAction(touchLocation, "Map"); } }