Esempio n. 1
0
        bool IsOccupiedCore(Vector2 tilePosition)
        {
            var underlayTile = _logicalMap.GetUnderlay((int)tilePosition.X, (int)tilePosition.Y);
            var overlayTile  = _logicalMap.GetOverlay((int)tilePosition.X, (int)tilePosition.Y);

            bool underlayBlocked = underlayTile != null && underlayTile.Collision != Passability.Passable;
            bool overlayBlocked  = overlayTile != null && overlayTile.Collision != Passability.Passable;

            return(underlayBlocked || overlayBlocked);
        }
Esempio n. 2
0
        bool IsOccupiedCore(Vector2 tilePosition)
        {
            if ((int)tilePosition.X < 0)
            {
                return(true);
            }
            if ((int)tilePosition.Y < 0)
            {
                return(true);
            }
            if ((int)tilePosition.X >= _logicalMap.Width)
            {
                return(true);
            }
            if ((int)tilePosition.Y >= _logicalMap.Height)
            {
                return(true);
            }

            var underlayTile = _logicalMap.GetUnderlay((int)tilePosition.X, (int)tilePosition.Y);
            var overlayTile  = _logicalMap.GetOverlay((int)tilePosition.X, (int)tilePosition.Y);

            bool underlayBlocked = underlayTile != null && underlayTile.Collision != Passability.Passable;
            bool overlayBlocked  = overlayTile != null && overlayTile.Collision != Passability.Passable;

            return(underlayBlocked || overlayBlocked);
        }
Esempio n. 3
0
        bool OnSelect(WorldCoordinateSelectEvent e, Action <Selection> continuation)
        {
            float denominator = Vector3.Dot(Normal, e.Direction);

            if (Math.Abs(denominator) < 0.00001f)
            {
                return(false);
            }

            float t = Vector3.Dot(-e.Origin, Normal) / denominator;

            if (t < 0)
            {
                return(false);
            }

            Vector3 intersectionPoint = e.Origin + t * e.Direction;
            int     x = (int)(intersectionPoint.X / _renderable.TileSize.X);
            int     y = (int)(intersectionPoint.Y / _renderable.TileSize.Y);

            int highlightIndex = y * _map.Width + x;
            var underlayTile   = _map.GetUnderlay(x, y);
            var overlayTile    = _map.GetOverlay(x, y);

            continuation(new Selection(e.Origin, e.Direction, t, new MapTileHit(
                                           new Vector2(x, y),
                                           intersectionPoint,
                                           _renderable.GetWeakUnderlayReference(x, y),
                                           _renderable.GetWeakOverlayReference(x, y))));

            if (underlayTile != null)
            {
                continuation(new Selection(e.Origin, e.Direction, t, underlayTile));
            }
            if (overlayTile != null)
            {
                continuation(new Selection(e.Origin, e.Direction, t, overlayTile));
            }
            continuation(new Selection(e.Origin, e.Direction, t, this));

            var zone = _map.GetZone(x, y);

            if (zone != null)
            {
                continuation(new Selection(e.Origin, e.Direction, t, zone));
            }

            var chain = zone?.Chain;

            if (chain != null)
            {
                foreach (var zoneEvent in chain.Events)
                {
                    continuation(new Selection(e.Origin, e.Direction, t, zoneEvent));
                }
            }

            if (_lastHighlightIndex != highlightIndex)
            {
                HighlightIndexChanged?.Invoke(this, highlightIndex);
                _lastHighlightIndex = highlightIndex;
            }

            return(true);
        }