// This function will look for a tile type at a specific point and return the first version it finds // Returns null if it can't find one public static Tile tileAtPoint(Vector2 point, TileTags testTags) { int numObjects = Physics2D.OverlapPointNonAlloc(point, _maybeColliderResults); for (int i = 0; i < numObjects && i < _maybeColliderResults.Length; i++) { Tile maybeTile = _maybeColliderResults[i].GetComponent <Tile>(); if (maybeTile != null && maybeTile.hasTag(testTags)) { return(maybeTile); } } return(null); }
///////////////////////////////// // These are convenient functions for adding/removing/checking for tags // Since they involve bitwise operations, probably best to use these functions instead of altering the tags property directly from code public bool hasTag(TileTags tag) { return((tags & tag) != 0); }
public void addTag(TileTags tagsToAdd) { tags |= tagsToAdd; }
public void removeTag(TileTags tagsToRemove) { tags = tags & ~(tagsToRemove); }
protected void removeTag(TileTags tagsToRemove) { tags = tags & ~(tagsToRemove); }
protected void addTag(TileTags tagsToAdd) { tags |= tagsToAdd; }