示例#1
0
 public Edge(CrystalBombDetonator parent, Vector2 a, Vector2 b)
 {
     Parent        = parent;
     A             = a;
     B             = b;
     Min           = new Vector2(Math.Min(A.X, B.X), Math.Min(A.Y, B.Y));
     Max           = new Vector2(Math.Max(A.X, B.X), Math.Max(A.Y, B.Y));
     Normal        = (B - A).SafeNormalize();
     Perpendicular = -Normal.Perpendicular();
     Length        = (A - B).Length();
 }
示例#2
0
        // Add a field to the tracker
        public void Track(CrystalBombDetonator block)
        {
            trackedFields.Add(block);
            if (tiles == null)
            {
                levelTileBounds = (Scene as Level).TileBounds;
                tiles           = new VirtualMap <bool>(levelTileBounds.Width, levelTileBounds.Height, false);
            }

            for (int xTile = (int)block.X / 8; xTile < (block.Right / 8f); xTile++)
            {
                for (int yTile = (int)block.Y / 8; yTile < (block.Bottom / 8f); yTile++)
                {
                    tiles[xTile - levelTileBounds.X, yTile - levelTileBounds.Y] = true;
                }
            }

            dirty = true;
        }
示例#3
0
        public void Untrack(CrystalBombDetonator block)
        {
            trackedFields.Remove(block);
            if (trackedFields.Count <= 0)
            {
                tiles = null;
            }
            else
            {
                for (int xTile = (int)block.X / 8; xTile < (block.Right / 8f); xTile++)
                {
                    for (int yTile = (int)block.Y / 8; yTile < (block.Bottom / 8f); yTile++)
                    {
                        tiles[xTile - levelTileBounds.X, yTile - levelTileBounds.Y] = false;
                    }
                }
            }

            dirty = true;
        }