Beispiel #1
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            if (GDOwner.Selection == this)
            {
                sbatch.FillShape(GetArea().AsInflated(GDConstants.TILE_WIDTH / 2, GDConstants.TILE_WIDTH / 2), Color.Black * 0.333f);
            }

            if (_ppCacheKey != EquatableTuple.Create(Length, Normal, Position))
            {
                _ppCacheKey   = EquatableTuple.Create(Length, Normal, Position);
                _ppCacheRects = CommonObstacleRenderer.CreatePortalRenderRects(Position, Vector2.UnitX.Rotate(Normal), Vector2.UnitX.Rotate(Normal).RotateWithLength(FloatMath.RAD_POS_090, Length / 2f), Length);
            }

            CommonObstacleRenderer.DrawPortal(sbatch, _ppCacheRects, Portal.COLORS[Group], Normal);
        }
Beispiel #2
0
        public Portal(GDGameScreen scrn, PortalBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_PORTAL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            Normal       = FloatMath.DegreesToRadians * blueprint.Normal;
            VecNormal    = Vector2.UnitX.Rotate(Normal);
            Length       = blueprint.Length;
            VecDirection = VecNormal.RotateWithLength(FloatMath.RAD_POS_090, blueprint.Length / 2f);
            Color        = COLORS[blueprint.Group];
            _group       = blueprint.Group;
            _side        = blueprint.Side;

            Position = pos;

            DrawingBoundingBox = new Vector2(Length, 0).Rotate(Normal + FloatMath.RAD_POS_090).ToAbsFSize().AtLeast(WIDTH, WIDTH);

            this.GDOwner().GDBackground.RegisterBlockedLine(pos - Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f), pos + Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f));

            _renderRects = CommonObstacleRenderer.CreatePortalRenderRects(pos, VecNormal, VecDirection, Length);
        }