Exemple #1
0
    // 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);
    }
Exemple #2
0
    /////////////////////////////////


    // 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);
    }
Exemple #3
0
 public void addTag(TileTags tagsToAdd)
 {
     tags |= tagsToAdd;
 }
Exemple #4
0
 public void removeTag(TileTags tagsToRemove)
 {
     tags = tags & ~(tagsToRemove);
 }
Exemple #5
0
 protected void removeTag(TileTags tagsToRemove)
 {
     tags = tags & ~(tagsToRemove);
 }
Exemple #6
0
 protected void addTag(TileTags tagsToAdd)
 {
     tags |= tagsToAdd;
 }