public void CleanManItemOnPointerUp(BaseEventData baseEventData) { if (cleanManObj == null) { return; } PointerEventData eventData = (PointerEventData)baseEventData; Vector2 worldPos = Camera.main.ScreenToWorldPoint(eventData.position); worldPos.y += 100; Tile tile = null; float distance = 100; for (int x = 0; x < TileController.x_max_value; x++) { for (int y = 0; y < TileController.y_max_value; y++) { Vector2 tilePos = tileController.tiles[x, y].transform.position; float tempDistance = Vector2.Distance(worldPos, tilePos); if (distance > tempDistance) { distance = tempDistance; tile = tileController.tiles[x, y]; } } } if (tile == null) { Destroy(cleanManObj.gameObject); cleanManObj = null; } else { if (tile.pos == new Vector2(7, 11)) { cleanManObj.transform.position = tile.transform.position; cleanManObj.Init(tile); nextOn = true; } else { Destroy(cleanManObj.gameObject); cleanManObj = null; WarningManager.Instance.WarningSet("빨강 타일에 소환해 주십시오."); } } }
public void CleanManItemDrag(BaseEventData baseEventData) { PointerEventData eventData = (PointerEventData)baseEventData; if (cleanManObj == null) { cleanManObj = Instantiate(Resources.Load <CleanMan>("InGame/Item/CleanMan"), transform); } Vector2 worldPos = Camera.main.ScreenToWorldPoint(eventData.position); cleanManObj.transform.position = new Vector3(worldPos.x, worldPos.y + 100); }
public void OnPointerDown(PointerEventData eventData) { SoundManager.Instance.PlaySe(SeEnum.Touch); if (!CheckCost(false)) { return; } cleanManObj = Instantiate(Resources.Load <CleanMan>("InGame/Item/CleanMan"), transform); Vector2 worldPos = Camera.main.ScreenToWorldPoint(eventData.position); cleanManObj.transform.position = new Vector3(worldPos.x, worldPos.y + 70); }
public void OnPointerUp(PointerEventData eventData) { if (!CheckCost() || cleanManObj == null) { return; } Vector2 worldPos = Camera.main.ScreenToWorldPoint(eventData.position); worldPos.y += 100; Tile tile = null; float distance = 100; for (int x = 0; x < TileController.x_max_value; x++) { for (int y = 0; y < TileController.y_max_value; y++) { Vector2 tilePos = tileController.tiles[x, y].transform.position; float tempDistance = Vector2.Distance(worldPos, tilePos); if (distance > tempDistance) { distance = tempDistance; tile = tileController.tiles[x, y]; } } } if (tile != null) { cleanManObj.transform.position = tile.transform.position; cleanManObj.Init(tile); AddCost(); } else { Destroy(cleanManObj.gameObject); } cleanManObj = null; }