Beispiel #1
0
        private void DrawDirection(
            Graphics gc,
            PointDrawingHelper drawingHelper,
            LazerEntity lazer)
        {
            var rectangle = drawingHelper.GetPointRectangle();
            var point1    = drawingHelper.GetCentrePoint();
            var point2    = drawingHelper.GetLazerDirectionPoint(lazer.GlowDirection);

            gc.DrawLine(this._redPen, point1, point2);
        }
Beispiel #2
0
        private void DrawMainBlueCircle(
            Graphics gc,
            PointDrawingHelper drawingHelper,
            LazerEntity lazer)
        {
            var rectangle = drawingHelper.GetPointRectangle();

            gc.FillEllipse(
                this.GetMainBrush(lazer.State),
                rectangle);
        }
        private void Process(LazerEntity lazer)
        {
            var walls           = this._map.ListEntitiesOf(EntityType.Wall);
            var mirrors         = this._map.ListEntitiesOf(EntityType.Mirror).As <MirrorEntity>();
            var stopLazerPoints = this._map.ListEntitiesWith(EntityProperty.StopLazerRay)
                                  .Where(entity => entity.Type != EntityType.Mirror);

            var incomingRay = lazer.CreateProducedRay();

            while (incomingRay != null)
            {
                if (walls.IntersectWithPositionOf(incomingRay))
                {
                    incomingRay = null;
                    continue;
                }

                _map.AddEntity(incomingRay);
                _map.LazerPoint(incomingRay.X, incomingRay.Y);
                var stopLazerPoint = stopLazerPoints.GetIntersectWithPositionOf(incomingRay);
                if (stopLazerPoint != null)
                {
                    incomingRay = null;
                    continue;
                }

                var mirror      = mirrors.GetIntersectWithPositionOf(incomingRay);
                var outgoingRay =
                    mirror != null
                    ? mirror.GetReflectedRay(incomingRay)
                    : incomingRay.CreateProducedRay();

                _map.AddEntity(outgoingRay);
                incomingRay = outgoingRay.CreateProducedRay();
            }
        }