//return true if tile has boxcollider if wall controller is not present or value specified by wallcontroller public bool HasCollider(Coords2 coords) { GameObject tile = GetWallTile(coords); if (tile == null) { return(false); } WallTileController controller = tile.GetComponent <WallTileController>(); if (controller == null) { return(tile.GetComponent <BoxCollider2D>() != null); } return(controller.HasCollider()); }
private void UpdateBulletsPhysics(BulletController bullet) { Vector2 position = bullet.GetPosition(); Vector2 velocity = bullet.GetVelocity(); Vector2 newPosition = position + velocity * Time.fixedDeltaTime; bullet.SetPosition(newPosition); Rect collider = bullet.GetCollider(); int minX = Mathf.FloorToInt(collider.xMin + 0.5f); int minY = Mathf.FloorToInt(collider.yMin + 0.5f); int maxX = Mathf.FloorToInt(collider.xMax + 0.5f); int maxY = Mathf.FloorToInt(collider.yMax + 0.5f); for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { Coords2 coords = new Coords2(x, y); GameObject wall = map.GetWallTile(coords); if (wall == null) { continue; } WallTileController controller = wall.GetComponent <WallTileController>(); if (controller == null) { continue; } if (controller.HasCollider()) { bullet.OnHitWall(controller); return; } } } }
public override bool HasCollider() { return(ownerController.HasCollider()); }