Engine.Objects.Person.CheckObstructions C# (CSharp) Method

CheckObstructions() public method

public CheckObstructions ( Vector2f &position, Line line ) : bool
position Vector2f
line Line
return bool
        public bool CheckObstructions(ref Vector2f position, Line line)
        {
            Line[] baselines = _innerSS.GetLineBase();
            Vector2f pos = position - new Vector2f(_base.Left, _base.Top);
            foreach (Line b in baselines)
            {
                var baseline = b.Offset(pos);
                if (Line.Intersects(baseline, line))
                    return true;
            }
            return false;
        }

Same methods

Person::CheckObstructions ( Vector2f &pos, Person other ) : bool
Person::CheckObstructions ( Vector2f &pos, Vector2f &tileOffset, Tile tile ) : bool

Usage Example

Exemplo n.º 1
0
 public static bool CheckTileObstruction(ref Vector2f position, Person person)
 {
     int tw = _map.Tileset.TileWidth, th = _map.Tileset.TileHeight;
     int sx = (int)position.X / tw + 2;
     int sy = (int)position.Y / th + 2;
     Vector2f pos = new Vector2f();
     for (var y = sy - 2; y < sy; ++y)
     {
         pos.Y = y * th;
         for (var x = sx - 2; x < sx; ++x)
         {
             pos.X = x * tw;
             int t = _map.Layers[person.Layer].GetTile(x, y);
             if (t >= 0 && person.CheckObstructions(ref position, ref pos, _map.Tileset.Tiles[t]))
                 return true;
         }
     }
     return false;
 }
All Usage Examples Of Engine.Objects.Person::CheckObstructions