public override void Draw() { timer.Update(); if (timer.IsTime) { timer.Initialize(); } graphicsDevice.RasterizerState = RasterizerState.CullClockwise; effect.Parameters["WorldViewProjection"].SetValue(Camera2D.GetView() * Camera2D.GetProjection()); effect.Parameters["Rate"].SetValue(timer.Rate()); float radian = MathHelper.ToRadians(entity.transform.Angle); Vector2 direction = new Vector2((float)Math.Cos(radian), (float)Math.Sin(radian)); Vector2 drawPosition = entity.transform.Position + Camera2D.GetOffsetPosition() + offsetPosition; Vector3 drawP3 = new Vector3(drawPosition, 0); VertexUpdate(drawP3); graphicsDevice.SetVertexBuffer(vertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserPrimitives <VertexPositionTexture>( PrimitiveType.TriangleStrip, vertexPositions, 0, 2 ); } }
public C_DrawSeasonUI(C_SeasonState seasonState, float depth = 100, float alpha = 1) { this.seasonState = seasonState; this.alpha = alpha; this.depth = depth; graphicsDevice = Renderer_2D.GetGraphicsDevice(); effect = ResouceManager.GetEffect("CircleBar").Clone(); effect.Parameters["WorldViewProjection"].SetValue(Camera2D.GetView() * Camera2D.GetProjection()); effect.CurrentTechnique = effect.Techniques["Technique1"]; vertexPositions = new VertexPositionTexture[4]; }
public void SetShaderOn(float liveTime, string baseImg, string maskImg) { isShaderOn = true; baseImgSize = ResouceManager.GetTextureSize(baseImg); shadeTimer.SetTimer(liveTime); effect = ResouceManager.GetEffect("MaskShader").Clone(); effect.Parameters["theTexture"].SetValue(ResouceManager.GetTexture(baseImg)); effect.Parameters["theMask"].SetValue(ResouceManager.GetTexture(maskImg)); effect.CurrentTechnique = effect.Techniques["Technique1"]; effect.Parameters["WorldViewProjection"].SetValue(Camera2D.GetView() * Camera2D.GetProjection()); effect.Parameters["Color"].SetValue(new float[4] { 0.5f, 0, 0, 0.5f }); }
public void Draw() { effect.Parameters["WorldViewProjection"].SetValue(Camera2D.GetView() * Camera2D.GetProjection()); Vector3 drawPosition = targetPosition + Camera2D.GetOffsetPosition3(); drawPosition.Y -= broadSize.Y / 2; drawPosition.X -= broadSize.X / 2; VertexUpdate(drawPosition); graphicsDevice.SetVertexBuffer(vertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserPrimitives <VertexPositionTexture>( PrimitiveType.TriangleStrip, vertexPositions, 0, 2 ); } }
public ImageEffect(string name, Vector2 position, float aliveSecond) { this.name = name; this.position = position; alpha = 0; aliveTimer = new Timer(aliveSecond); isDisappear = false; imageSize = ResouceManager.GetTextureSize(name); rect = new Rectangle(0, 0, (int)imageSize.X, (int)imageSize.Y); size = Vector2.One; graphicsDevice = Renderer_2D.GetGraphicsDevice(); effect = ResouceManager.GetEffect("MaskShader").Clone(); effect.Parameters["theTexture"].SetValue(ResouceManager.GetTexture(name)); effect.Parameters["theMask"].SetValue(ResouceManager.GetTexture("ShadeMask_LR")); effect.CurrentTechnique = effect.Techniques["Technique1"]; effect.Parameters["Color"].SetValue(new float[4] { 0.5f, 0, 0, 0.5f }); effect.Parameters["WorldViewProjection"].SetValue(Camera2D.GetView() * Camera2D.GetProjection()); vertexPositions = new VertexPositionTexture[4]; }
public override void Show(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: matrix * camera.GetProjection()); // Draw tiles int minX = (int)Math.Max(0, (camera.Left) / Tile.size); int maxX = (int)Math.Min((camera.Right) / Tile.size, (width * Tile.size) / Tile.size - 1); int minY = (int)Math.Max(0, (camera.Top) / Tile.size); int maxY = (int)Math.Min((camera.Bottom) / Tile.size, (height * Tile.size) / Tile.size - 1); for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { int cX = x / Chunk.size; int cY = y / Chunk.size; if (chunks[cX, cY] != null) { GetTile(x, y).Draw(spriteBatch, x, y); } else { Chunk.RequestChunk(cX, cY); } } } // Draw all entities foreach (NPC npc in NPCs) { if (npc.transform.InCameraBounds(camera)) { npc.Show(gameTime, spriteBatch); } } //NPCs.ForEach(x => x.Show(gameTime, spriteBatch)); spriteBatch.End(); }