public void drawMain(float a_elapsedTime, GraphicsDevice a_graphics, Model.Levels a_level, Camera a_camera, Vector2 a_playerPosition, Model.StateHandler.LevelState a_LevelState, Model.StateHandler.CharStates a_charState, Model.StateHandler.CharFaceState a_charFaceState, List<Vector2> a_drawEnemy, List<Vector2> a_drawBoltEnemy) { //SÄTTER ALLT SOM RITAS UT TILL RENDERTARGET MAINSCENE SÅ ATT DET PÅVERKAS RÄTT UTAV FICKLAMPAN a_graphics.SetRenderTarget(mainScene); a_graphics.Clear(Color.Black); torchPositions = new List<Vector2>(); var mouse = Mouse.GetState(); mousePosition = new Vector2(mouse.X, mouse.Y); float scale = a_camera.GetScale(); Vector2 viewportSize = new Vector2(a_graphics.Viewport.Width, a_graphics.Viewport.Height); Vector2 playerViewPos = a_camera.GetViewPosition(a_playerPosition.X, a_playerPosition.Y, viewportSize); Vector2 displacement = new Vector2(a_graphics.Viewport.Width, a_graphics.Viewport.Height); m_time += a_elapsedTime / 10.0f; //TILLDELAR TILES OCH PARTIKEL SYSTEM SOM SKALLF FINNAS PÅ BANA 1 if(m_level ==1) { SetBackground(m_level); DrawBackGround(GetBackground(), a_graphics); for (int x = 0; x < Model.Levels.g_levelWidth; x++) { for (int y = 0; y < Model.Levels.g_levelHeight; y++) { Vector2 viewPos = a_camera.GetViewPosition(x, y, viewportSize); DrawTile(viewPos.X, viewPos.Y, scale, a_level.m_tiles[x, y]); } } a_rainSystem.DrawRainDrops(m_spriteBatch, m_rainTexture, a_elapsedTime); } //TILLDELAR RÄTT TILES FÖR BANA 2 if (m_level == 2) { SetBackground(m_level); DrawBackGround(GetBackground(), a_graphics); for (int x = 0; x < Model.Levels.g_levelWidth; x++) { for (int y = 0; y < Model.Levels.g_levelHeight; y++) { Vector2 viewPos = a_camera.GetViewPosition(x, y, viewportSize); //DrawTile(viewPos.X, viewPos.Y, scale, a_level.m_tiles[x, y]); DrawTileLevel2(viewPos.X, viewPos.Y, scale, a_level.m_tiles2[x, y]); } } } //BANA 3, TILLDELAR RÄTT TILE VÄRDEN OCH VILKEN PARTICEL EFFEKT SOM SKALL RITAS UT if (m_level == 3) { SetBackground(m_level); DrawBackGround(GetBackground(), a_graphics); for (int x = 0; x < Model.Levels.g_levelWidth; x++) { for (int y = 0; y < Model.Levels.g_levelHeight; y++) { Vector2 viewPos = a_camera.GetViewPosition(x, y, viewportSize); DrawTileLevel3(viewPos.X, viewPos.Y, scale, a_level.m_tiles3[x, y]); } } a_ashSystem.DrawAshes(m_spriteBatch, m_ashes, a_elapsedTime); } //RITAR UT RESTERANDE OBEROENDE VILKEN BANA. DrawEnemy(a_drawEnemy, viewportSize, a_camera, scale); DrawBoltEnemy(a_drawBoltEnemy, viewportSize, a_camera, scale); DrawPlayerAt(playerViewPos, scale, a_elapsedTime, a_charState, a_charFaceState); a_graphics.SetRenderTarget(null); }
public void DrawLevel(GraphicsDevice a_graphicsDevice, Model.Levels a_level, Camera a_camera, Vector2 a_playerPosition, float a_elapsedTime, Model.StateHandler.LevelState a_LevelState, GraphicsDeviceManager a_manager, Model.StateHandler.CharStates a_charState, Model.StateHandler.CharFaceState a_charFaceState, List<Vector2> a_drawEnemy, List<Vector2> a_drawBoltEnemy, int m_playerHp, bool a_isInAir) { m_isInAir = a_isInAir; float scale = a_camera.GetScale(); Vector2 viewPortSize = new Vector2(a_graphicsDevice.Viewport.Width, a_graphicsDevice.Viewport.Height); Vector2 playerViewPos = a_camera.GetViewPosition(a_playerPosition.X, a_playerPosition.Y, viewPortSize); Vector2 displacement = new Vector2(a_graphicsDevice.Viewport.Width, a_graphicsDevice.Viewport.Height); m_time += a_elapsedTime / 10.0f; torchPositions = new List<Vector2>(); var mouse = Mouse.GetState(); mousePosition = new Vector2(mouse.X, mouse.Y); // m_spriteBatch.Begin(); a_graphicsDevice.Clear(Color.Transparent); //m_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,null, null, null, lightningEffect); Draw(scale, a_elapsedTime, a_graphicsDevice, a_level, a_camera, a_playerPosition, a_LevelState, a_charState,a_charFaceState, a_drawEnemy, a_drawBoltEnemy); m_spriteBatch.End(); m_spriteBatch.Begin(); m_spriteBatch.DrawString(m_hpFont, "Hope " + m_playerHp.ToString(), m_hpPos, Color.Red); //DrawUI(m_playerHp); m_spriteBatch.End(); a_graphicsDevice.SetRenderTarget(null); }
//SÄTTER BOLTENEMYTEXTUREN public void DrawBoltEnemy(List<Vector2>a_boltposition, Vector2 viewportSize, Camera a_camera, float a_scale) { // Model.EnemyBolt a_boltEnemy = new Model.EnemyBolt(); Rectangle enemySource = new Rectangle(0, 0, (int)(m_boltEnemy.Width), (int)(m_boltEnemy.Height)); a_scale = 64; for (int i = 0; i < a_boltposition.Count(); i++) { Vector2 EnemyViewPos = a_camera.GetViewPosition(a_boltposition[i].X, a_boltposition[i].Y, viewportSize); Rectangle enemyRect = new Rectangle((int)(EnemyViewPos.X - a_scale / 4), (int)(EnemyViewPos.Y - a_scale/4), (int)a_scale, (int)a_scale); m_spriteBatch.Draw(m_boltEnemy, enemyRect, enemySource, Color.White); } }
//SÄTTER FIENDE TEXTUREN, public void DrawEnemy(List<Vector2> a_position, Vector2 viewportSize, Camera a_camera, float a_scale) { Rectangle enemySource = new Rectangle(0, 0, (int)(m_enemyTexture.Width), (int)(m_enemyTexture.Height)); a_scale = 128; for (int i = 0; i < a_position.Count(); i++) { Vector2 EnemyViewPos = a_camera.GetViewPosition(a_position[i].X, a_position[i].Y, viewportSize); Rectangle enemyRect = new Rectangle((int)(EnemyViewPos.X - a_scale / 2), (int)(EnemyViewPos.Y - a_scale), (int)a_scale, (int)a_scale); m_spriteBatch.Draw(m_enemyTexture, enemyRect, enemySource, Color.White); } }
//public void Draw(float a_elapsedTime, GraphicsDevice a_graphics, Camera a_camera, Vector2 a_playerPosition) //DRAW METODEN ANROPAR SENDA DRAWMAIN OCH DRAWLIGHTMASK. ÄVEN EFFEKTEN FINNS HÄR I. public void Draw(float a_scale, float a_elapsedTime, GraphicsDevice a_graphics, Model.Levels a_level, Camera a_camera, Vector2 a_playerPosition, Model.StateHandler.LevelState a_LevelState, Model.StateHandler.CharStates a_charState, Model.StateHandler.CharFaceState a_charFaceState, List<Vector2> a_drawEnemy, List<Vector2> a_drawboltEnemy) { Vector2 viewportSize = new Vector2(a_graphics.Viewport.Width, a_graphics.Viewport.Height); Vector2 playerViewPos = a_camera.GetViewPosition(a_playerPosition.X, a_playerPosition.Y, viewportSize); m_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.DepthRead, RasterizerState.CullNone); drawMain(a_elapsedTime, a_graphics, a_level, a_camera, a_playerPosition, a_LevelState, a_charState, a_charFaceState, a_drawEnemy, a_drawboltEnemy); drawLightMask(a_elapsedTime, a_graphics, playerViewPos); a_graphics.Clear(Color.Black); lightningEffect.Parameters["lightMask"].SetValue(lightMask); lightningEffect.CurrentTechnique.Passes[0].Apply(); m_spriteBatch.Draw(mainScene, new Vector2(0, 0), Color.Black); }