Exemplo n.º 1
0
 public override void Draw(Screen screen)
 {
     //base.Draw(screen);
     screen.SpriteBatch.Draw(
         texture: Texture,
         position: screen.ToExactPosition(Position),
         scale: TextureScale * screen.Scale,
         color: Color,
         layerDepth: LayerDepth
         );
 }
Exemplo n.º 2
0
        public override void Draw(Screen screen)
        {
            Position = screen.ToWorldPosition(InputManager.GetMousePosition());
            screen.Draw(
                texture: Texture,
                position: screen.ToExactPosition(Position),
                layerDepth: LayerDepth,
                rotationAngle: RotationAngle,
                rotationOrigin: RotationOrigin,
                exactPosition: true
                );

            if (Debug) // TODO move to screen
                TextureManager.Font.DrawText(
                    screen.SpriteBatch,
                    "X: " + Position.X + "; Y: " + Position.Y + ";",
                    12,
                    screen.ToExactPosition(Position + new Vector2(0, 20)),
                    Color.Red,
                    LayerDepth + 0.01f,
                    false
                );
        }
Exemplo n.º 3
0
        public override void Draw(Screen screen)
        {
            if(_visible && _currentRow < Text.Count && _background != null) {
                string stringToDraw = Text[_currentRow].Substring(0, _currentChar);

                Vector2 tmpPosition = screen.ToExactPosition(Position);
                tmpPosition = NumberFactory.VectorInt(tmpPosition);

                _background.Position = tmpPosition - new Vector2(10, 10);

                screen.SpriteBatch.Draw(
                    texture: _background.Texture,
                    destinationRectangle: _background.Bounds.ToRectangle(),
                    color: _background.Color,
                    layerDepth: LayerDepth
                );

                Color color = Color.White;
                if (TalkingObject is IColored) {
                    color = ((IColored)TalkingObject).Color;
                }

                TextureManager.Font.DrawText(
                    spriteBatch: screen.SpriteBatch,
                    text: stringToDraw,
                    fontSize: 18,
                    position: tmpPosition,
                    color: color,
                    layerDepth: LayerDepth - 0.02f,
                    drawLine: true
                );

            }
        }
Exemplo n.º 4
0
 public void DrawRectangle(Screen screen)
 {
     try
     {
         screen.SpriteBatch.Draw(
             texture: _rectTexture,
             position: screen.ToExactPosition(Position),
             scale: screen.Scale,
             layerDepth: 0.9f
             );
     } catch (Exception)
     {
         throw new Exception("This model doesn't have a texture. (try making one with BuildTextureFromBounds)");
     }
 }
Exemplo n.º 5
0
        public void Draw(Screen screen)
        {
            foreach (PhysicalObject2D obj in Children)
            {
                obj.Draw(screen);
            }

            if (FirstCheckpoint != null)
                TextureManager.Font.DrawText(
                    spriteBatch: screen.SpriteBatch,
                    text: "F",
                    fontSize: 12,
                    position: screen.ToExactPosition(new Vector2(FirstCheckpoint.Left, FirstCheckpoint.Top - 25)),
                    color: Color.Green,
                    layerDepth: .05f - 0.01f,
                    drawLine: true
                );

            foreach (PlayerCheckpoint checkpoint in Checkpoints.ToArray())
            {
                int extraX = 25;
                foreach (Color color in checkpoint.StartingColors.ToArray())
                {
                    string colorString = "";

                    if (color == Color.Red)
                        colorString = "R";
                    if (color == Color.Blue)
                        colorString = "B";
                    if (color == Color.Green)
                        colorString = "G";
                    if (color == Color.Yellow)
                        colorString = "Y";
                    if (color == Color.White)
                        colorString = "W";

                    TextureManager.Font.DrawText(
                        spriteBatch: screen.SpriteBatch,
                        text: colorString,
                        fontSize: 12,
                        position: screen.ToExactPosition(new Vector2(checkpoint.Left + extraX, checkpoint.Top - 25)),
                        color: Color.Green,
                        layerDepth: 0.05f - 0.01f,
                        drawLine: true
                    );
                    extraX += 25;
                }
            }
        }
Exemplo n.º 6
0
        public void ScreenScaleTest()
        {
            Screen s = new Screen(
                spriteBatch: null,
                position: new Vector2(2),
                screenOrigin: new Vector2(20),
                size: new Vector2(300)
                );

            Vector2 worldPosition = new Vector2(50);
            Vector2 expectedDrawPosition = new Vector2(50 + 2 - 20);

            Assert.AreEqual(expectedDrawPosition, s.ToExactPosition(worldPosition));

            s.Scale = new Vector2(0.5f);

            expectedDrawPosition = new Vector2(25 + 2 - 10);

            Assert.AreEqual(expectedDrawPosition, s.ToExactPosition(worldPosition));
        }
Exemplo n.º 7
0
        public void DrawTeleporterLinks(Screen screen)
        {
            List<Teleporter> tp = new List<Teleporter>();
            int i = 0;

            foreach (PhysicalObject2D p in CurrentLevel.Children) {

                if (p is Teleporter && !tp.Contains((Teleporter)p)) {
                    Teleporter p2 = ((Teleporter)p).LinkedTeleporter;
                    Vector2 position1 = p.Center;
                    Vector2 position2 = p2.Center;

                    TextureManager.Font.DrawText(
                        spriteBatch: screen.SpriteBatch,
                        text: i.ToString(),
                        fontSize: 12,
                        position: screen.ToExactPosition(position1 - TextureManager.Font.MeasureString(i.ToString(), 12) / 2),
                        color: ((Teleporter)p).Color,
                        layerDepth: 0.05f - 0.01f,
                        drawLine: true
                    );

                    TextureManager.Font.DrawText(
                        spriteBatch: screen.SpriteBatch,
                        text: i.ToString(),
                        fontSize: 12,
                        position: screen.ToExactPosition(position2 - TextureManager.Font.MeasureString(i.ToString(), 12) / 2),
                        color: p2.Color,
                        layerDepth: 0.05f - 0.01f,
                        drawLine: true
                    );

                    tp.Add((Teleporter)p);
                    tp.Add(((Teleporter)p).LinkedTeleporter);

                    i++;
                }
            }
        }
Exemplo n.º 8
0
        public void Draw(Screen screen)
        {
            if (_selectedObject != null) {
                Rectangle tmpRectangle = _selectedObject.Bounds.ToRectangle();
                tmpRectangle.Location = screen.ToExactPosition(tmpRectangle.Location.ToVector2()).ToPoint();
                screen.SpriteBatch.Draw(
                        TextureManager.GetTexture("blood"),
                        new Rectangle(
                            tmpRectangle.X,
                            tmpRectangle.Y,
                            (int)Math.Round(tmpRectangle.Width * (_selectedObject is TextBalloon ? 1f : screen.Scale.X)),
                            (int)Math.Round(tmpRectangle.Height * (_selectedObject is TextBalloon ? 1f : screen.Scale.Y))
                        ),
                        Color.Black * 0.3f
                    );
            }

            CurrentLevel.Draw(screen);
            DrawTeleporterLinks(screen);
        }