Exemple #1
0
        private float GetLeftDistance(Vector4 boundingBox)
        {
            float result = boundingBox.X;

            if (result < 0)
            {
                result = 0;
            }
            List <KeyValuePair <float, List <MapTile> > > list = this.mapTiles.VSortedTiles;
            int index = MapTiles.FindIndexSortedTiles(boundingBox.X, list);

            if (index == list.Count)
            {
                return(result);
            }
            if (list[index].Key == boundingBox.X)
            {
                foreach (MapTile tile in list[index].Value)
                {
                    if (IsVerticalValid(boundingBox, tile) == true)
                    {
                        return(0);
                    }
                }
            }
            for (index = index - 1; index > -1; --index)
            {
                foreach (MapTile tile in list[index].Value)
                {
                    if (IsVerticalValid(boundingBox, tile) == true)
                    {
                        return(Math.Abs(list[index].Key - boundingBox.X));
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        public bool isFront(Vector4 boundingBox)
        {
            List <KeyValuePair <float, List <MapTile> > > list = this.mapTiles.HSortedTiles;
            int index = MapTiles.FindIndexSortedTiles(boundingBox.W, list);

            for (int i = index; i < list.Count; ++i)
            {
                foreach (MapTile tile in list[i].Value)
                {
                    if (IsHorizontalValid(boundingBox, tile) == true)
                    {
                        if (tile.Sprite2D.Depth == 0.3f)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }