public elementoBenefico(Texture2D texturaElemento1, Texture2D texturaElemento2) { elementoTex1 = texturaElemento1; elementoTex2 = texturaElemento2; currentScene = ElementoScene.SCN_NORMAL; isAlive = false; isPlaying = true; }
public void Update2(GameTime gameTime) { #region EFEITOS if (currentScene != ElementoScene.SCN_NORMAL) { time += gameTime.ElapsedGameTime.TotalSeconds; if (time > 5) { currentScene = ElementoScene.SCN_NORMAL; time = 0; } } switch (currentScene) { case ElementoScene.SCN_VELOCIDADE: Meteor.BlockFallSpeed = 20; //isPlaying = true; break; case ElementoScene.SCN_NORMAL: time = 0; //isPlaying = false; Meteor.BlockFallSpeed = 5; break; case ElementoScene.SCN_LIFE: if (Game1.naveMae.vidaNave < 20) Game1.naveMae.vidaNave = 20; //isPlaying = true; currentScene = ElementoScene.SCN_NORMAL; break; } // Update each block for (int i = 0; i < elementoRandom.Count; i++) { // Animate this block falling elementoRandom[i] = new Vector2(elementoRandom[i].X + elementoSpeed, elementoRandom[i].Y); Rectangle Rect = new Rectangle((int)elementoRandom[i].X, (int)elementoRandom[i].Y, elementoTex1.Width, elementoTex1.Height); if (elementoRandom[i].X > Game1.viewportRect.Width) { elementoRandom.RemoveAt(i); i--; } for (int j = 0; j < Game1.cannonMissiles.Count; j++) { if (Game1.cannonMissiles[j].Rect.Intersects(Rect)) { try { currentScene = ElementoScene.SCN_VELOCIDADE; isAlive = false; elementoRandom.RemoveAt(i); i--; break; } catch(ArgumentOutOfRangeException) { break; } } posicaoRect = Rect.X; } for (int j = 0; j < Game1.cannonMissiles2.Count; j++) { if (Game1.cannonMissiles2[j].Rect.Intersects(Rect)) { try { currentScene = ElementoScene.SCN_VELOCIDADE; isAlive = false; elementoRandom.RemoveAt(i); i--; break; } catch (ArgumentOutOfRangeException) { break; } } posicaoRect = Rect.X; } } #endregion for (int i = 0; i < elementoBem.Count; i++) { // Animate this block falling elementoBem[i] = new Vector2(elementoBem[i].X + elementoSpeed, elementoBem[i].Y); Rectangle Rect = new Rectangle((int)elementoBem[i].X, (int)elementoBem[i].Y, elementoTex1.Width, elementoTex1.Height); if (elementoBem[i].X > Game1.viewportRect.Width) { elementoBem.RemoveAt(i); i--; } for (int j = 0; j < Game1.cannonMissiles.Count; j++) { if (Game1.cannonMissiles[j].Rect.Intersects(Rect)) { try { currentScene = ElementoScene.SCN_LIFE; isAlive = false; elementoBem.RemoveAt(i); break; } catch (ArgumentOutOfRangeException) { break; } } posicaoRect = Rect.X; } for (int j = 0; j < Game1.cannonMissiles2.Count; j++) { if (Game1.cannonMissiles2[j].Rect.Intersects(Rect)) { try { currentScene = ElementoScene.SCN_LIFE; isAlive = false; elementoBem.RemoveAt(i); i--; break; } catch (ArgumentOutOfRangeException) { break; } } posicaoRect = Rect.X; } } }