public LaserbeamManager(ContentManager Content) { textures = new LaserbeamTextures(Content); /*Laserbeam test = new Laserbeam(textures); test.SetStartDirection(Direction4D.Right); test.Add(new Vector2(3, 10)); test.Add(new Vector2(4, 10)); test.Add(new Vector2(5, 10)); test.Add(new Vector2(5, 11)); test.Add(new Vector2(5, 12)); test.Add(new Vector2(6, 12)); test.Add(new Vector2(7, 12)); beams.Add(test);*/ }
public void DrawPulse(LaserbeamTextures textures, float position, SpriteBatch spriteBatch, Vector2 cameraPos) { float offsetPosition = position - 0.5f; Direction4D relevantDirection = offsetPosition < 0 ? startDirection: endDirection; switch (relevantDirection) { case Direction4D.Down: spriteBatch.Draw(textures.pulseV, pos + new Vector2(0, offsetPosition * 32.0f) - cameraPos, Color.White); break; case Direction4D.Up: spriteBatch.Draw(textures.pulseV, pos + new Vector2(0, -offsetPosition * 32.0f) - cameraPos, Color.White); break; case Direction4D.Left: spriteBatch.Draw(textures.pulseH, pos + new Vector2(-offsetPosition * 32.0f, 0.0f) - cameraPos, Color.White); break; case Direction4D.Right: spriteBatch.Draw(textures.pulseH, pos + new Vector2(offsetPosition * 32.0f, 0.0f) - cameraPos, Color.White); break; } }
public void DrawPartial(Direction4D direction, LaserbeamTextures textures, SpriteBatch spriteBatch, Vector2 cameraPos) { switch (direction) { case Direction4D.Up: spriteBatch.Draw(textures.beamV, pos - cameraPos, new Rectangle(0, 0, 32, 16), Color.White); break; case Direction4D.Down: spriteBatch.Draw(textures.beamV, pos + new Vector2(0, 16.0f) - cameraPos, new Rectangle(0, 16, 32, 16), Color.White); break; case Direction4D.Left: spriteBatch.Draw(textures.beamH, pos - cameraPos, new Rectangle(0, 0, 16, 32), Color.White); break; case Direction4D.Right: spriteBatch.Draw(textures.beamH, pos + new Vector2(16.0f, 0.0f) - cameraPos, new Rectangle(16, 0, 16, 32), Color.White); break; } }
public void Draw(LaserbeamTextures textures, SpriteBatch spriteBatch, Vector2 cameraPos) { if( startDirection != endDirection ) { DrawPartial(startDirection.Reverse(), textures, spriteBatch, cameraPos); DrawPartial(endDirection, textures, spriteBatch, cameraPos); } else if (startDirection == Direction4D.Up || startDirection == Direction4D.Down) { spriteBatch.Draw(textures.beamV, pos - cameraPos, Color.White); } else // left/right { spriteBatch.Draw(textures.beamH, pos - cameraPos, Color.White); } }
public Laserbeam(LaserbeamTextures aTextures) { startDirection = Direction4D.Right; textures = aTextures; }