public GameObject SpawnFromTile(ETile tile_, ChunkInfo info_, int x_, int y_) { EItem toSpawn = EItem.None; if (tile_ == ETile.Mountain) { toSpawn = EItem.Stone; } else if (tile_ == ETile.Tree) { toSpawn = EItem.Wood; } if (toSpawn == EItem.None) { return(null); } ItemInstance ii = SpawnItem(toSpawn); if (!ii) { return(null); } Vector2 worldPos = WorldMap.Chunk2World(info_, x_, y_); ii.gameObject.transform.position = new Vector3(worldPos.x, worldPos.y, -0.06f); return(ii.gameObject); }
public bool HasCollision(ChunkInfo ci, int x, int y) { Vector2 worldPos = WorldMap.Chunk2World(ci, x, y); Box2D worldBox = new Box2D(worldPos, 0.5f, 0.5f); // Check against any player Box2D playerBox = GameManager.Instance.MainPlayer.Box; return(CollisionCode.TestBox2DBox2D(worldBox, playerBox)); }