public override void Update(GameTime gameTime) { attackDuration -= gameTime.ElapsedGameTime.TotalMilliseconds; if (attackDuration < 0) attackDuration = 0; if (frametime != 0) { frametime -= gameTime.ElapsedGameTime.TotalMilliseconds; if (frametime < 0) { frametime = 0; etat = CactusStateBoss.Attack; } } if ((IsHit) && (attacks != AttackBoss2.Grow)) { int oldWidth = this.dRect.Width; Vector2 newScale = this.Scale; newScale.X -= 0.003f; newScale.Y -= 0.003f; this.Scale = newScale; this.location.X += (oldWidth - this.dRect.Width) / 2; this.location.Y = TGPAContext.Instance.ScreenHeight - this.dRect.Height; } if (this.Scale.X < 0.35f) { attacks = AttackBoss2.Grow; attackDuration = 10000f; this.hitbox = new EmptyHitbox(this); } switch (etat) { case CactusStateBoss.Hit: sRect.Y = 512; dRect = ComputeDstRect(sRect); break; case CactusStateBoss.Attack: sRect.Y = 0; dRect = ComputeDstRect(sRect); break; } //Behavior //First thing : boss go to the middle of the screen if ((location.Y < (TGPAContext.Instance.ScreenHeight - dRect.Height)) && !go) { go = true; Background = true; speed = Vector2.Zero; Pattern = null; this.hitbox = new SquareHitbox(this, new Vector2(0.5f, 0f)); oldHitbox = (SquareHitbox)this.hitbox; } else if (!go) { Vector2 loc = panel.Location; loc.Y = this.location.Y; if (loc.Y < TGPAContext.Instance.ScreenHeight / 2) { loc.Y = TGPAContext.Instance.ScreenHeight / 2; } this.location.X = 450; loc.X += deltaX; panel.Location = loc; this.location.X += deltaX; deltaX = -deltaX; for (int i = 1; i <= 15; i++) { Vector2 smokeLoc = new Vector2(i * TGPAContext.Instance.ScreenWidth / 15, TGPAContext.Instance.ScreenHeight); TGPAContext.Instance.ParticleManager.AddParticle(new Smoke(smokeLoc, RandomMachine.GetRandomVector2(-5f, 5f, -10f, 10f), 0.70f, 0.70f, 0.70f, 1f, RandomMachine.GetRandomFloat(0.5f, 2.0f), RandomMachine.GetRandomInt(0, 4)), true); } TGPAContext.Instance.Player1.SetRumble(new Vector2(1.0f, 1.0f)); if (TGPAContext.Instance.Player2 != null) { TGPAContext.Instance.Player2.SetRumble(new Vector2(1.0f, 1.0f)); } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { attackDuration -= gameTime.ElapsedGameTime.TotalMilliseconds; if (attackDuration < 0) { attackDuration = 0; } if (frametime != 0) { frametime -= gameTime.ElapsedGameTime.TotalMilliseconds; if (frametime < 0) { frametime = 0; etat = CactusStateBoss.Attack; } } if ((IsHit) && (attacks != AttackBoss2.Grow)) { int oldWidth = this.dRect.Width; Vector2 newScale = this.Scale; newScale.X -= 0.003f; newScale.Y -= 0.003f; this.Scale = newScale; this.location.X += (oldWidth - this.dRect.Width) / 2; this.location.Y = TGPAContext.Instance.ScreenHeight - this.dRect.Height; } if (this.Scale.X < 0.35f) { attacks = AttackBoss2.Grow; attackDuration = 10000f; this.hitbox = new EmptyHitbox(this); } switch (etat) { case CactusStateBoss.Hit: sRect.Y = 512; dRect = ComputeDstRect(sRect); break; case CactusStateBoss.Attack: sRect.Y = 0; dRect = ComputeDstRect(sRect); break; } //Behavior //First thing : boss go to the middle of the screen if ((location.Y < (TGPAContext.Instance.ScreenHeight - dRect.Height)) && !go) { go = true; Background = true; speed = Vector2.Zero; Pattern = null; this.hitbox = new SquareHitbox(this, new Vector2(0.5f, 0f)); oldHitbox = (SquareHitbox)this.hitbox; } else if (!go) { Vector2 loc = panel.Location; loc.Y = this.location.Y; if (loc.Y < TGPAContext.Instance.ScreenHeight / 2) { loc.Y = TGPAContext.Instance.ScreenHeight / 2; } this.location.X = 450; loc.X += deltaX; panel.Location = loc; this.location.X += deltaX; deltaX = -deltaX; for (int i = 1; i <= 15; i++) { Vector2 smokeLoc = new Vector2(i * TGPAContext.Instance.ScreenWidth / 15, TGPAContext.Instance.ScreenHeight); TGPAContext.Instance.ParticleManager.AddParticle(new Smoke(smokeLoc, RandomMachine.GetRandomVector2(-5f, 5f, -10f, 10f), 0.70f, 0.70f, 0.70f, 1f, RandomMachine.GetRandomFloat(0.5f, 2.0f), RandomMachine.GetRandomInt(0, 4)), true); } TGPAContext.Instance.Player1.SetRumble(new Vector2(1.0f, 1.0f)); if (TGPAContext.Instance.Player2 != null) { TGPAContext.Instance.Player2.SetRumble(new Vector2(1.0f, 1.0f)); } } base.Update(gameTime); }