public void Draw(Screen screen) { foreach (PhysicalObject2D p in _children) { p.Draw(screen); } }
public void Draw(Screen screen) { /*screen.SpriteBatch.Draw( texture: TextureManager.GetTexture("blood"), destinationRectangle: new Rectangle(0,0,(int)screen.ExactWidth, (int)screen.ExactHeight), scale: null, color: BackgroundColor, layerDepth: LayerDepth );*/ //_graphics.GraphicsDevice.Clear(BackgroundColor); for (int i = 0; i < _layerList.Count; i++) { Layer layer = _layerList[i]; float scale = screen.Size.Y / (float)layer.Texture.Height; float position = -((screen.ScreenOrigin.X * (i + 1) / 3) % (layer.Texture.Width * scale)); screen.SpriteBatch.Draw( texture: layer.Texture, position: new Vector2(position, 0), scale: new Vector2(scale), color: layer.Color, layerDepth: LayerDepth + i / 100f ); screen.SpriteBatch.Draw( texture: layer.Texture, position: new Vector2(position + layer.Texture.Width * scale, 0), scale: new Vector2(scale), color: layer.Color, layerDepth: LayerDepth + i / 100f ); } }
public override void Draw(Screen screen) { screen.Draw( Texture, this, TextureScale ); }
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 ); }
public bool IsPointingAt(PhysicalObject2D target, Screen screen) { //TODO fix VectorRectangle bounds = target.Bounds; return ( bounds.Left < Position.X && bounds.Right > Position.X && bounds.Top < Position.Y && bounds.Bottom > Position.Y ); }
public override void Draw(Screen screen) { if (_paused) { Position = screen.Size / 2 - _background.Size / 2; Vector2 tmpPosition = Position + new Vector2(75, 120); Vector2 tmpIncrement = new Vector2(0, 50); _background.Position = screen.ToWorldPosition(Position); _background.Draw(screen); for (int i = 1; i < MenuElements.Count; i++) { MenuElements[i].Position = tmpPosition; MenuElements[i].Draw(screen); tmpPosition += tmpIncrement; } } }
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 ); }
public override void Draw(Screen screen) { screen.SpriteBatch.Draw( texture: Texture, position: Position + RotationOrigin, scale: TextureScale, color: Color * (_mouseOver ? 1f : 0.6f), layerDepth: LayerDepth ); if (_drawText) { Vector2 tmpPosition = NumberFactory.VectorInt(Position + Size / 2 - TextureManager.Font.MeasureString(_caption,12) / 2); TextureManager.Font.DrawText( spriteBatch: screen.SpriteBatch, text: _caption, fontSize: 12, position: tmpPosition, color: Color, layerDepth: LayerDepth - 0.01f, drawLine: true ); } }
public override void Draw(Screen screen) { base.Draw(screen); }
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)"); } }
public override void Draw(Screen screen) { Texture2D texture = Texture; Vector2 textureScale = TextureScale; for (float x=0; x< BlockAmountX; x++) { for (float y=0; y<BlockAmountY; y++) { Vector2 position = Position + new Vector2(x * Size.X / BlockAmountX, y * Size.Y / BlockAmountY); screen.Draw( texture: texture, position: position, layerDepth: LayerDepth, color: _colorBehaviour.Value, objectScale: textureScale, rotationAngle: RotationAngle, rotationOrigin: RotationOrigin ); //screen.SpriteBatch.Draw( // texture, // position: screen.ToExactPosition(position + RotationOrigin * textureScale), // scale: screen.Scale * textureScale, // color:_colorBehaviour.Value, // rotation: RotationAngle, // origin: RotationOrigin, // layerDepth: LayerDepth // ); } } }
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)); }
public override void Draw(Screen screen) { foreach (PhysicalObject2D sprite in Children) { sprite.Draw(screen); } }
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; } } }
public override void Draw(Screen screen) { DrawMedal(screen); DrawTime(screen); DrawBestMedalText(screen); }
public void DrawBestMedalText(Screen screen) { Vector2 textPosition = new Vector2(screen.ExactWidth - 120, screen.ExactHeight - screen.ExactHeight + 60); { TextureManager.Font.DrawText( spriteBatch: screen.SpriteBatch, text: "Best Medal: " + _bestMedal.ToString(), fontSize: 6, position: textPosition, color: Color.White, layerDepth: LayerDepth, drawLine: true ); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); _mainScreen = new Screen(spriteBatch, size: new Vector2(1000, 600)); InputManager.GameScreen = _mainScreen; InputManager.Window = Window; _levelBuilder.Screen = _mainScreen; UpdateBackBufferSize(); CenterWindow(); _levelBuilder.LoadContent(); Window.AllowUserResizing = true; Window.ClientSizeChanged += Window_Resize; }
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++; } } }
public override void Draw(Screen screen) { if(state != State.Reappearing) base.Draw(screen); }
public override void Draw(Screen screen) { if (Background != null) { float screenRatio = screen.ExactWidth / screen.ExactHeight; Rectangle backgroundBounds = Background.Texture.Bounds; float backgroundRatio = (float)backgroundBounds.Width / backgroundBounds.Height; if (screenRatio < backgroundRatio) { Rectangle newPosition = new Rectangle(0, 0, (int)(screen.ExactWidth / screenRatio * backgroundRatio), (int)(screen.ExactHeight)); newPosition.X = (int)(screen.ExactWidth / 2 - newPosition.Width / 2); newPosition.Y = (int)(screen.ExactHeight / 2 - newPosition.Height / 2); screen.SpriteBatch.Draw( texture: Background.Texture, destinationRectangle: newPosition, layerDepth: LayerDepth, color: Color.White ); } else { Rectangle newPosition = new Rectangle(0, 0, (int)(screen.ExactWidth), (int)(screen.ExactHeight / backgroundRatio * screenRatio)); newPosition.X = (int)(screen.ExactWidth / 2 - newPosition.Width / 2); newPosition.Y = (int)(screen.ExactHeight / 2 - newPosition.Height / 2); screen.SpriteBatch.Draw( texture: Background.Texture, destinationRectangle: newPosition, layerDepth: LayerDepth, color: Color.White ); } } if (Text != null) { float screenRatio = screen.ExactWidth / screen.ExactHeight; Rectangle textBounds = Text.Texture.Bounds; float textRatio = (float)textBounds.Width / textBounds.Height; if (screenRatio > textRatio) { Rectangle newPosition = new Rectangle(0, 0, (int)(screen.ExactWidth / screenRatio * textRatio), (int)(screen.ExactHeight)); newPosition.X = (int)(screen.ExactWidth / 2 - newPosition.Width / 2); newPosition.Y = (int)(screen.ExactHeight / 2 - newPosition.Height / 2); screen.SpriteBatch.Draw( texture: Text.Texture, destinationRectangle: newPosition, layerDepth: LayerDepth - 0.01f, color: Color.White ); } else { Rectangle newPosition = new Rectangle(0, 0, (int)(screen.ExactWidth), (int)(screen.ExactHeight / textRatio * screenRatio)); newPosition.X = (int)(screen.ExactWidth / 2 - newPosition.Width / 2); newPosition.Y = (int)(screen.ExactHeight / 2 - newPosition.Height / 2); screen.SpriteBatch.Draw( texture: Text.Texture, destinationRectangle: newPosition, layerDepth: LayerDepth - 0.01f, color: Color.White ); } } foreach(Sprite s in MenuElements) { s.Draw(screen); } crosshair.Draw(screen); }
public void DrawTime(Screen screen) { Vector2 timePosition = new Vector2(screen.ExactWidth - 120, screen.ExactHeight - screen.ExactHeight + 22); TextureManager.Font.DrawText( spriteBatch: screen.SpriteBatch, text: _elapsedTime, fontSize: 12, position: timePosition, color: Color.White, layerDepth: LayerDepth, drawLine: true ); }
public void DrawMedal(Screen screen) { Size = TextureManager.GetTexture("gold").Bounds.Size.ToVector2(); Vector2 medalPosition = new Vector2(screen.ExactWidth - Size.X - 24, screen.ExactHeight - screen.ExactHeight); Position = screen.ToWorldPosition(medalPosition); if (CurrentMedal != Medal.None) { screen.SpriteBatch.Draw( texture: TextureManager.GetTexture(CurrentMedal.ToString().ToLower()), position: medalPosition, color: Color.White, layerDepth: LayerDepth ); } }
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 ); } }
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); }