public GameObject SpawnIfPossible(GameObject touristPrefab) { touristSize tourist = touristPrefab.GetComponent <touristSize>(); int rotation = TileMatching(TileGenerator.GetFreeTile(), tourist.takenSize, 0); if (rotation == -1) { return(null); } FillTouristTileComponent(tourist); Sprite sprite = gameObject.GetComponent <SpriteRenderer>().sprite; Vector2 SpriteSize = sprite.bounds.size; Vector3 position = this.transform.position + new Vector3(SpriteSize.x * touristPrefab.GetComponent <touristSize>().GetTileOffset().x, SpriteSize.y * touristPrefab.GetComponent <touristSize>().GetTileOffset().y, 0); if (m_rotation == 1) { position = this.transform.position + new Vector3(SpriteSize.y * touristPrefab.GetComponent <touristSize>().GetTileOffset().y, SpriteSize.x * touristPrefab.GetComponent <touristSize>().GetTileOffset().x, 0); } GameObject touristSpawnGO = (GameObject)Instantiate(touristPrefab, position, Quaternion.identity); touristSpawnGO.transform.localEulerAngles = new Vector3(0, 0, (m_rotation == 1) ? 90 : 0); Debug.Log("SpawnPlayer in tile : " + (int)m_tileIndex.x + " " + (int)m_tileIndex.y); touristSpawnGO.GetComponent <touristSize>().SetOrderInLayer((int)m_tileIndex.x, (int)m_tileIndex.y); return(touristSpawnGO); }