protected override void OnDraw(ref DrawParams p) { if (timeParam != null) { timeParam.SetValue(SimTime); } if (positionParam != null) { positionParam.SetValue(Motion.Position); } Color col = DrawInfo.DrawColor; if (EffectEnabled) { // this is a conversion from 'halotime' to the time format that can be given to the pixel shader // via the 'draw color' parameter int t = (int)(haloTime * 256); int c3 = t % 256; int c2 = ((t - c3) / 256) % 256; int c1 = ((t - c2 - c3) / 65536) % 256; col = new Color(c1, c2, c3, col.A); } MySpriteBatch.Draw(Texture, DrawInfo.DrawPosition, null, col, Motion.RotateAbs, DrawInfo.DrawCenter, DrawInfo.DrawScale, SpriteEffects.None, DrawInfo.LayerDepth); }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { if (_mainMenuUi != null) { _mainMenuUi.Draw(gameTime, spritebatch); } }
public void Draw(MySpriteBatch spritebatch) { if (!_textureUpdating) { spritebatch.Draw(_renderTarget, Vector2.Zero, Color.White); } }
protected override void OnDraw(ref DrawParams p) { base.OnDraw(ref p); Vector2 origin = Vector2.Zero; // new Vector2(2f * txt.Length, 0f); Vector2 pos = Motion.PositionAbsZoomedPixels; // draw shadow Color shadowDrawColor = Color.Black; shadowDrawColor.A = DrawInfo.DrawColor.A; // scaling with resolutions // descriptionBox.Motion.Scale = ((float)Screen.WidthPixels) / 1440f; // 768f / ((float)Screen.HeightPixels); // +(((float)Screen.WidthPixels) - 1440f) / 1440f; float sc = Motion.ScaleAbs; // *((float)Screen.WidthPixels) / 1440f; // HACK float scRatio = (float)(Screen.AspectRatio / 1.6f); Vector2 vScale = new Vector2(sc * scRatio, sc); try { MySpriteBatch.DrawString(font, txt, pos + new Vector2(1f, 1f), shadowDrawColor, Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth + 0.00001f); // TODO the const MySpriteBatch.DrawString(font, txt, pos, DrawInfo.DrawColor, Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth); } catch (Exception) { ; // e.g. if character to draw not available. // TODO } }
public override void Draw(double elapsedTime, MySpriteBatch spriteBatch) { var entities = _world.EntityManager.GetEntities(); var entitiesFounded = entities.Where(x => x.HasComponents(_componentTypes)).ToList(); foreach (var e in entitiesFounded) { var spriteComponent = e.GetComponent <SpriteComponent>(); var transformComponent = e.GetComponent <TransformComponent>(); var region = MyGame.Instance.TextureManager.GetRegionByIndex(spriteComponent.SpriteIndex); spriteBatch.Draw(MyGame.Instance.TextureManager.GetTexture(), new Rectangle( (int)(transformComponent.X) * MyGame.Instance.SpriteWidth + _offsetX, (int)(transformComponent.Y) * MyGame.Instance.SpriteHeight + _offsetY, (int)(region.Width * spriteComponent.ScaleX), (int)(region.Height * spriteComponent.ScaleY) ), new Rectangle( region.X, region.Y, region.Width, region.Height ), spriteComponent.Color, transformComponent.Rotation, new Vector2( region.Width * spriteComponent.OriginX, region.Height * spriteComponent.OriginY), spriteComponent.Effect, 0); } }
public override void Draw(double elapsedTime, MySpriteBatch spriteBatch) { var offsetX = (int)((MyGame.Instance.ScreenWidth - (MyGame.MapWidth * MyGame.Instance.SpriteWidth)) * 0.5f); var offsetY = (int)((MyGame.Instance.ScreenHeight - (MyGame.MapHeight * MyGame.Instance.SpriteHeight)) * 0.5f); for (int i = 0; i < MyGame.MapWidth * MyGame.MapHeight; i++) { var region = MyGame.Instance.TextureManager.GetRegionByIndex(33); spriteBatch.Draw(MyGame.Instance.TextureManager.GetTexture(), new Rectangle( (int)(i % MyGame.MapWidth) * MyGame.Instance.SpriteWidth + offsetX, (int)(i / MyGame.MapHeight) * MyGame.Instance.SpriteHeight + offsetY, (int)(region.Width), (int)(region.Height) ), new Rectangle( region.X, region.Y, region.Width, region.Height ), Color.White, 0, new Vector2( MyGame.Instance.SpriteWidth * 0.5f, MyGame.Instance.SpriteHeight * 0.5f), SpriteEffects.None, 0); } }
protected override void OnDraw(ref DrawParams p) { if (timeParam != null) { timeParam.SetValue(SimTime); } if (positionParam != null) { positionParam.SetValue(Motion.Position); } if (Texture != null) { Color col = DrawInfo.DrawColor; if (EffectEnabled) { // this is a conversion from 'halotime' to the time format that can be given to the pixel shader // via the 'draw color' parameter double warpedTime = 20 * (1 + Math.Sin(1.5f * MathHelper.Pi + MathHelper.TwoPi * 0.05 * (double)haloTime)); int t = (int)(warpedTime * 16); int c3 = t % 256; int c2 = ((t - c3) / 256) % 256; //int c1 = ((t - c2 - c3)/65536) % 256; col = new Color(col.R, c2, c3, col.A); // (intensity, timeMSB, timeLSB, alpha) passed to shader } MySpriteBatch.Draw(Texture, DrawInfo.DrawPosition, null, col, Motion.RotateAbs, DrawInfo.DrawCenter, DrawInfo.DrawScale, SpriteEffects.None, DrawInfo.LayerDepth); } }
protected override void OnDraw(ref DrawParams p) { Vector2 pos = DrawInfo.DrawPosition; double progressValuePercent = 100 * progressValue; float drawSc = DrawInfo.DrawScale; int width = 1 + (int)Math.Round(ToPixels(DrawInfo.WidthAbs) * progressValue * barWidth); int height = (int)Math.Round(ToPixels(DrawInfo.HeightAbs)); if (width > Texture.Width) { width = Texture.Width; } Rectangle srcRect = new Rectangle(0, 0, width, Texture.Height - 2); MySpriteBatch.Draw(Texture, pos, srcRect, DrawInfo.DrawColor, Motion.RotateAbs, new Vector2(0f, height / 4), drawSc, SpriteEffects.None, DrawInfo.LayerDepth); // plot text percentage Color textColor = DrawInfo.DrawColor; Vector2 tpos = pos + new Vector2(width * drawSc, height / 4); //Texture.Height / 2.0f - 10.0f) ; Vector2 origin = new Vector2(10f, 6f); MySpriteBatch.DrawString(spriteFont, String.Format(" {0,3}%", Math.Round(progressValuePercent)), tpos, textColor, Motion.RotateAbs, origin, textScale * drawSc * 0.72f, SpriteEffects.None, DrawInfo.LayerDepth); }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { if (m_gameState.HasValue) { m_gameStates[m_gameState.Value].Draw(gameTime, spritebatch); } }
public void Draw(MySpriteBatch spritebatch) { if (m_gameState.HasValue) { m_gameStates[m_gameState.Value].Draw(spritebatch); } }
public void Draw(MySpriteBatch spritebatch) { //Calcul zones visibles int xMin = (int)(-Settings.ScreenWidth * 1 / Settings.Zoom); int yMin = (int)(-Settings.ScreenHeight * 1 / Settings.Zoom); int xMax = (int)(Settings.ScreenWidth + Settings.ScreenWidth * 1 / Settings.Zoom); int yMax = (int)(Settings.ScreenHeight + Settings.ScreenHeight * 1 / Settings.Zoom); for (var i = _zoneViews.Count - 1; i >= 0; i--) { var zoneView = _zoneViews.ElementAt(i); var position = zoneView.Value.GetPosition(); if ( xMin <= position.X && position.X < xMax && yMin <= position.Y && position.Y < yMax ) { zoneView.Value.Draw(spritebatch); } } var font = FontManager.Instance.GetFont("Arial-16"); spritebatch.DrawString(font, $"Zones : {xMin},{yMin} {xMax},{yMax}", new Vector2(10, 110), Color.Yellow); }
public MapManager() { _renderTarget = new RenderTarget2D(GraphicManager.Instance.GraphicsDevice, Settings.ScreenWidth, Settings.ScreenHeight); _spritebatch = new MySpriteBatch(GraphicManager.Instance.GraphicsDevice); _random = new Random(); }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { if (_scoreUi != null) { _scoreUi.Draw(gameTime, spritebatch); } SpriteFont font = FontManager.Instance.GetFont("Arial-16"); var measuring = font.MeasureString("Rank"); spritebatch.DrawString(font, "Rank", new Vector2(Settings.ScreenWidth * 0.5f - measuring.X * 0.5f, Settings.ScreenHeight * 0.5f), Color.Yellow); var scores = new List <double>() { _score.Red, _score.Blue, _score.Green, _score.Yellow }; bool redDrawed = false; bool blueDrawed = false; bool greenDrawed = false; bool yellowDrawed = false; var orderScores = scores.OrderByDescending(x => x); for (int i = 0; i < orderScores.Count(); i++) { var score = orderScores.ElementAt(i); if (score == _score.Red && !redDrawed) { spritebatch.DrawString(font, (i + 1) + " : Red : " + _score.Red.ToString("0") + "%", new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow); redDrawed = true; } else if (score == _score.Blue && !blueDrawed) { spritebatch.DrawString(font, (i + 1) + " : Blue : " + _score.Blue.ToString("0") + "%", new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow); blueDrawed = true; } else if (score == _score.Green && !greenDrawed) { spritebatch.DrawString(font, (i + 1) + " : Green : " + _score.Green.ToString("0") + "%", new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow); greenDrawed = true; } else if (score == _score.Yellow && !yellowDrawed) { spritebatch.DrawString(font, (i + 1) + " : Yellow : " + _score.Yellow.ToString("0") + "%", new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow); yellowDrawed = true; } } }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { StateManager.Instance.Draw(gameTime, spritebatch); //if (Input.GetKeyDown(KeyCode.Escape)) //{ // Application.Quit(); //} }
public void Draw(MySpriteBatch spritebatch) { _mapView.Draw(spritebatch); SpriteFont font = FontManager.Instance.GetFont("Arial-16"); spritebatch.DrawString(font, "Pinch : " + _pinchDistance, new Vector2(10, 90), Color.Yellow); spritebatch.DrawString(font, "Zoom : " + Settings.Zoom, new Vector2(10, 130), Color.Yellow); }
public void Draw(MySpriteBatch spritebatch) { if (!_textureUpdating) { var center = _position - new Vector2(_texture.Width * Settings.Zoom * 0.5f, _texture.Height * Settings.Zoom * 0.5f); spritebatch.Draw(_texture, new Rectangle((int)center.X, (int)center.Y, (int)(_texture.Width * Settings.Zoom), (int)(_texture.Height * Settings.Zoom)), Color.White); } }
public void Draw(double elapsedTime, MySpriteBatch spriteBatch) { if (_isRunning) { var systems = SystemManager.GetDrawSystems(); foreach (var s in systems) { s.Draw(elapsedTime, spriteBatch); } } }
/// <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 MySpriteBatch(GraphicsDevice); GraphicManager.Instance.SetGraphicsDevice(GraphicsDevice); FontManager.Instance.AddFont("Arial-10", Content.Load <SpriteFont>("Fonts /Arial-10")); FontManager.Instance.AddFont("Arial-16", Content.Load <SpriteFont>("Fonts /Arial-16")); FontManager.Instance.AddFont("Arial-24", Content.Load <SpriteFont>("Fonts /Arial-24")); FontManager.Instance.AddFont("Arial-36", Content.Load <SpriteFont>("Fonts /Arial-36")); TextureManager.Instance.SetContentManager(Content); _gameManager = new GameManager(); _gameManager.Start(this); }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { _mapManager.Draw(spritebatch); //Player Positions var texturePlayerPositionWidth = TextureManager.Instance.GetTexture("Textures/PlayerPosition_Width"); var texturePlayerPositionHeight = TextureManager.Instance.GetTexture("Textures/PlayerPosition_Height"); spritebatch.Draw(texturePlayerPositionWidth, _rectRed, Color.White); spritebatch.Draw(texturePlayerPositionHeight, _rectBlue, Color.White); spritebatch.Draw(texturePlayerPositionWidth, _rectGreen, Color.White); spritebatch.Draw(texturePlayerPositionHeight, _rectYellow, Color.White); //Draw balls var textureBall = TextureManager.Instance.GetTexture("Textures/Paint"); foreach (var ball in _paintBalls) { if (!ball.IsDrawed) { var position = ball.Position - new Vector2(16, 16); spritebatch.Draw(textureBall, new Rectangle((int)position.X, (int)position.Y, 32, 32), ball.Color); } } SpriteFont font = FontManager.Instance.GetFont("Arial-10"); spritebatch.DrawString(font, "Pinch : " + _pinchDistance, new Vector2(10, 90), Color.Yellow); if (_lastScore != null) { spritebatch.DrawString(font, "Time : " + TimeSpan.FromSeconds(_timeGame - _timeCurrent), new Vector2(Settings.ScreenWidth - 200, 10), Color.Yellow); spritebatch.DrawString(font, "Red : " + _lastScore.Red.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 30), Color.Yellow); spritebatch.DrawString(font, "Blue : " + _lastScore.Blue.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 50), Color.Yellow); spritebatch.DrawString(font, "Green : " + _lastScore.Green.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 70), Color.Yellow); spritebatch.DrawString(font, "Yellow : " + _lastScore.Yellow.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 90), Color.Yellow); } }
protected override void OnDraw(ref DrawParams p) { Vector2 pos = DrawInfo.DrawPosition; String curText = ""; if (text.Length > 0 && text[0].Length > 0) { float t = 0f; for (int i = 0; i < text.Length; i++) { if (t <= SimTime) { if (doReplace) { curText = text[i]; } else { if (curText.Length > 0) { curText += "\n"; } curText += text[i]; } } t += timings[i]; } } if (curText.Length > 0) { float sc = Motion.ScaleAbs; Vector2 origin = totalTextSize / 2f; // Vector2.Zero; // new Vector2(((float)curText.Length) / 40f, 0f); if (Shadow) { MySpriteBatch.DrawString(SubtitleFont, curText, pos + ShadowVector, Color.Black, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth + 0.0001f); MySpriteBatch.DrawString(SubtitleFont, curText, pos - ShadowVector, Color.DarkGray, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth + 0.0002f); } MySpriteBatch.DrawString(SubtitleFont, curText, pos, DrawInfo.DrawColor, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth); } }
public virtual void Draw(double elapsedTime, MySpriteBatch spriteBatch) { }
public void Draw(GameTime gameTime, MySpriteBatch spritebatch) { }
public void Draw(MySpriteBatch spritebatch) { }
public void UpdateTexture() { _textureUpdating = true; MySpriteBatch spritebatch = new MySpriteBatch(GraphicManager.Instance.GraphicsDevice); Width = Settings.SubZoneWidth * (int)Settings.Tile_Size; Height = Settings.SubZoneHeight * (int)Settings.Tile_Size; var renderTarget = new RenderTarget2D(GraphicManager.Instance.GraphicsDevice, Width, Height); GraphicManager.Instance.GraphicsDevice.SetRenderTarget(renderTarget); GraphicManager.Instance.GraphicsDevice.Clear(Color.Transparent); Sprite spriteGrass = SpriteManager.Instance.GetSprite("Grass"); Sprite spriteRock = SpriteManager.Instance.GetSprite("Rock"); Sprite spriteDirt = SpriteManager.Instance.GetSprite("Dirt"); Sprite spriteWater1 = SpriteManager.Instance.GetSprite("Water1"); Sprite spriteWater2 = SpriteManager.Instance.GetSprite("Water2"); Sprite spriteWater3 = SpriteManager.Instance.GetSprite("Water3"); spritebatch.Begin(); for (var line = _zone.Height - 1; line >= 0; line--) { for (var col = _zone.Width - 1; col >= 0; col--) { var tile = _zone.LayerFloor.Tiles[line, col]; var position = Convert2DToIso(new Vector3(col, line, tile.Altitude)); position.X += renderTarget.Width * 0.5f - Settings.Tile_Size * 0.5f; position.Y += renderTarget.Height * 0.5f - Settings.Tile_Size * 0.5f; if (tile.Terrain.Type == TypeTerrain.Rock) { spritebatch.Draw(spriteRock.Texture, new Rectangle((int)position.X, (int)position.Y, (int)Settings.Tile_Size, (int)Settings.Tile_Size), spriteRock.RectangleSource, spriteRock.Color); } else if (tile.Terrain.Type == TypeTerrain.Grass) { spritebatch.Draw(spriteGrass.Texture, new Rectangle((int)position.X, (int)position.Y, (int)Settings.Tile_Size, (int)Settings.Tile_Size), spriteGrass.RectangleSource, spriteGrass.Color); } else if (tile.Terrain.Type == TypeTerrain.Dirt) { spritebatch.Draw(spriteDirt.Texture, new Rectangle((int)position.X, (int)position.Y, (int)Settings.Tile_Size, (int)Settings.Tile_Size), spriteDirt.RectangleSource, spriteDirt.Color); } } } spritebatch.End(); GraphicManager.Instance.GraphicsDevice.SetRenderTarget(null); _texture = (Texture2D)renderTarget; _textureUpdating = false; }
/// <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 MySpriteBatch(GraphicsDevice); Utils.FontManager.Instance.LoadFonts(this); EmptyKeys.UserInterface.FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16)); Viewport viewport = GraphicsDevice.Viewport; _basicUI = new EmptyKeys.UserInterface.Generated.BasicUI(); _viewModel = new BasicUIViewModel(); _basicUI.DataContext = _viewModel; EmptyKeys.UserInterface.FontManager.Instance.LoadFonts(Content, "Fonts/"); ImageManager.Instance.LoadImages(Content); SoundManager.Instance.LoadSounds(Content); var spriteSheet = Content.Load <Texture2D>("Textures/spritesheet"); TextureManager = new TextureManager(spriteSheet, 32, 32); Lua = new LuaInterpreter(); _threadLua = new Thread( new ThreadStart(ConsoleThread)); _threadLua.Start(); World = new World(); var drawSystem = new DrawEntitySystem( 1, new List <Type>() { typeof(SpriteComponent), typeof(TransformComponent) }, World ); var random = new Random(); var player = World.CreateGameObject(); FactoryEntity.CreatePlayer(World, player); var bomb = World.CreateGameObject(); FactoryEntity.CreateBomb(World, bomb, 6, 1); var map = new int[MapWidth * MapHeight] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 0, 2, 0, 2, 0, 1, 0, 0, 1, 2, 0, 2, 0, 2, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (var i = 0; i < map.Length; i++) { var e = World.CreateGameObject(); var value = map[i]; switch (value) { case 0: FactoryEntity.CreateHardWall(World, e, i % MapWidth, i / MapHeight); break; case 2: FactoryEntity.CreateSoftWall(World, e, i % MapWidth, i / MapHeight); break; } } World.SystemManager.AddSystem(new UpdateSpriteSystem(0, new List <Type>() { typeof(SpriteComponent), typeof(SpriteAnimationComponent) }, World)); World.SystemManager.AddSystem(new UpdateInputSystem(0, new List <Type>() { typeof(TypeEntityComponent), typeof(TransformComponent), typeof(InputComponent) }, World)); World.SystemManager.AddSystem(new DrawFloorSystem(0, null, World)); World.SystemManager.AddSystem(drawSystem); _stopwatch = new Stopwatch(); _stopwatch.Start(); }