public override void Update(GameTime gameTime) { bool attack = true; //Decrease cooldowns if (this.faceCooldown > 0f) { this.faceCooldown -= gameTime.ElapsedGameTime.TotalMilliseconds; } if (this.attackCooldown > 0f) { this.attackCooldown -= gameTime.ElapsedGameTime.TotalMilliseconds; attack = false; } //Boss is hit : change face if (IsHit) { this.faceState = CrazyDocFaceState.Hit; this.faceCooldown = 500f; } //Change state is necessary else if (this.faceCooldown < 0f) { this.faceState = CrazyDocFaceState.Normal; } //Random Pattern if (this.Pattern.Points.Count < 3) { for (int i = 0; i < 5; i++) { this.movePattern.AddPoint(new Point( RandomMachine.GetRandomInt(this.DstRect.Width, TGPAContext.Instance.ScreenWidth), RandomMachine.GetRandomInt(this.DstRect.Height, TGPAContext.Instance.ScreenHeight))); } } //*************************************************************************** //Find a new attack if (attack) { //(Re)Initialisation this.faceState = CrazyDocFaceState.Attack; this.faceCooldown = 2000f; int rand = RandomMachine.GetRandomInt(0, 6); this.speed = new Vector2(150f, 140.0f); // Circular attack //**************************************************** if ((rand < 3) && (this.attackType != CrazyDocAttacks.Circular)) { this.attackType = CrazyDocAttacks.Circular; this.wpn = new CrazyDocCircularWeapon(); this.speed = Vector2.Zero; this.attackCooldown = 2500f; } // Wave attack //**************************************************** else if ((rand <= 5) && (this.attackType != CrazyDocAttacks.Wave)) { this.attackType = CrazyDocAttacks.Wave; this.wpn = new CrazyDocWaveWeapon(); this.speed.X/=2; this.attackCooldown = 3500f; } // Random shots attack //**************************************************** else { this.attackType = CrazyDocAttacks.Random; this.wpn = new CrazyDocRandomWeapon(); this.attackCooldown = 2000f; } } //Sprite updates //************************************************ //Facial animation switch (this.faceState) { case CrazyDocFaceState.Normal: this.sRect.Y = 0; break; case CrazyDocFaceState.Hit: this.sRect.Y = 256; break; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { bool attack = true; //Decrease cooldowns if (this.faceCooldown > 0f) { this.faceCooldown -= gameTime.ElapsedGameTime.TotalMilliseconds; } if (this.attackCooldown > 0f) { this.attackCooldown -= gameTime.ElapsedGameTime.TotalMilliseconds; attack = false; } //Boss is hit : change face if (IsHit) { this.faceState = CrazyDocFaceState.Hit; this.faceCooldown = 500f; } //Change state is necessary else if (this.faceCooldown < 0f) { this.faceState = CrazyDocFaceState.Normal; } //Random Pattern if (this.Pattern.Points.Count < 3) { for (int i = 0; i < 5; i++) { this.movePattern.AddPoint(new Point( RandomMachine.GetRandomInt(this.DstRect.Width, TGPAContext.Instance.ScreenWidth), RandomMachine.GetRandomInt(this.DstRect.Height, TGPAContext.Instance.ScreenHeight))); } } //*************************************************************************** //Find a new attack if (attack) { //(Re)Initialisation this.faceState = CrazyDocFaceState.Attack; this.faceCooldown = 2000f; int rand = RandomMachine.GetRandomInt(0, 6); this.speed = new Vector2(150f, 140.0f); // Circular attack //**************************************************** if ((rand < 3) && (this.attackType != CrazyDocAttacks.Circular)) { this.attackType = CrazyDocAttacks.Circular; this.wpn = new CrazyDocCircularWeapon(); this.speed = Vector2.Zero; this.attackCooldown = 2500f; } // Wave attack //**************************************************** else if ((rand <= 5) && (this.attackType != CrazyDocAttacks.Wave)) { this.attackType = CrazyDocAttacks.Wave; this.wpn = new CrazyDocWaveWeapon(); this.speed.X /= 2; this.attackCooldown = 3500f; } // Random shots attack //**************************************************** else { this.attackType = CrazyDocAttacks.Random; this.wpn = new CrazyDocRandomWeapon(); this.attackCooldown = 2000f; } } //Sprite updates //************************************************ //Facial animation switch (this.faceState) { case CrazyDocFaceState.Normal: this.sRect.Y = 0; break; case CrazyDocFaceState.Hit: this.sRect.Y = 256; break; } base.Update(gameTime); }