public void Update(Viking viking) { //TODO resize current health box fullHealth.Width = 2 * viking.getFullHealth(); currentHealth.Width = 2 * viking.getHealth(); fullhealth = viking.getFullHealth(); //testiColour.Width -= 62/25; //testiColour2.Width -= 62/25; cLevel = viking.getLevel(); if (health > viking.getHealth()) { health -= 1; } if (health < viking.getHealth()) { health += 1; } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); Resolution.BeginDraw(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Resolution.getTransformationMatrix()); //spriteBatch.Begin(); // TODO: Add your drawing code here if (gamestate == 0) { //draw menu screen menu.Draw(spriteBatch, fontti); } else if (gamestate == 1) { //Omaa säätöä //spriteBatch.Draw(taustaKuva, tausta1, Color.White); //spriteBatch.Draw(taustaKuva, tausta2, Color.White); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta1.X), 0, 1920, 1080), Color.Gray); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta2.X), 0, 1920, 1080), Color.Gray); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta3.X), 0, 1920, 1080), Color.Gray); /* spriteBatch.Draw(tree, new Rectangle(tausta1.X + 0, 0, 1858, 1080), Color.White); * spriteBatch.Draw(tree, new Rectangle(tausta1.X + 600, -75, 1858, 1080), Color.LightGray); * spriteBatch.Draw(tree, new Rectangle(tausta1.X + 1800, -50, 1858, 1080), Color.White); * spriteBatch.Draw(tree, new Rectangle(tausta2.X + 600, 0, 1858, 1080), Color.LightGray); * spriteBatch.Draw(tree, new Rectangle(tausta2.X + 1800, -25, 1858, 1080), Color.White); * spriteBatch.Draw(tree, new Rectangle(tausta3.X + 600, 0, 1858, 1080), Color.White);*/ this.floor(); spriteBatch.DrawString(fontti2, "" + viking.getLevel(), new Vector2(380, 155), Color.Red); spriteBatch.DrawString(fontti, "Character level: ", new Vector2(55, 170), Color.Black); int stringlengt = (int)fontti.MeasureString("kills:____").X; spriteBatch.DrawString(fontti, "kills: " + killcount, new Vector2(1920 - stringlengt - 10, 30), Color.White); //spriteBatch.Draw(house, new Rectangle(tausta1.X + talo.X, talo.Y, talo.Width, talo.Height), Color.White); goal.Draw(spriteBatch); health.Draw(spriteBatch); experience.Draw(spriteBatch); for (int i = 0; i < spawners.Count; i++) { spawners[i].Draw(spriteBatch); } for (int i = 0; i < enemies.Count; i++) { enemies[i].Draw(spriteBatch); } for (int i = 0; i < spiders.Count; i++) { spiders[i].Draw(spriteBatch); } for (int n = 0; n < powerups.Count; n++) { powerups[n].Draw(spriteBatch); } viking.Draw(gameTime, spriteBatch); } else if (gamestate == 2) { //Omaa säätöä //spriteBatch.Draw(taustaKuva, tausta1, Color.White); //spriteBatch.Draw(taustaKuva, tausta2, Color.White); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta1.X), 0, 1920, 1080), Color.White); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta2.X), 0, 1920, 1080), Color.White); spriteBatch.Draw(taustaKuva, new Rectangle((int)(tausta3.X), 0, 1920, 1080), Color.White); //spriteBatch.Draw(tree, new Rectangle(tausta1.X + 0, 220, 742, 619), Color.White); //spriteBatch.Draw(tree, new Rectangle(tausta1.X+200, 220, 742, 619), Color.LightGray); //spriteBatch.Draw(tree, new Rectangle(tausta1.X + 700, 220, 742, 619), Color.White); //spriteBatch.Draw(tree, new Rectangle(tausta1.X + 400, 220, 742, 619), Color.LightGray); //spriteBatch.Draw(tree, new Rectangle(tausta1.X + 1150, 220, 742, 619), Color.White); //spriteBatch.Draw(tree, new Rectangle(tausta1.X + 900, 220, 742, 619), Color.White); this.floor(); spriteBatch.DrawString(fontti, "Character level: " + viking.getLevel(), new Vector2(10, 30), Color.Black); int stringlengt = (int)fontti.MeasureString("kills:____").X; spriteBatch.DrawString(fontti, "kills: " + killcount, new Vector2(1920 - stringlengt - 10, 30), Color.White); //spriteBatch.Draw(house, new Rectangle(tausta1.X + talo.X, talo.Y, talo.Width, talo.Height), Color.White); health.Draw(spriteBatch); experience.Draw(spriteBatch); for (int i = 0; i < enemies.Count; i++) { enemies[i].Draw(spriteBatch); } viking.Draw(gameTime, spriteBatch); for (int x = 0; x < 1920; x += 50) { for (int y = 0; y < 1080; y += 50) { spriteBatch.Draw(filter, new Rectangle(x, y, 50, 50), Color.White); } } theend.Draw(spriteBatch, fontti); } spriteBatch.End(); base.Draw(gameTime); }