public void TriangleAttack() { var projectileSprite = ((SpriteRenderer)phaseOneProjectile.GetComponent <SpriteRenderer>()).Sprite; var projectileDirection = -VectorMath.Angle2Vector(transform.Rotation); for (int i = 0; i < bossOutline.Length - 1; i++) { var j = (i == bossOutline.Length - 1) ? 0 : i + 1; var direction = bossOutline[j] - bossOutline[i]; if (direction.X != 0 || direction.Y != 0) { direction.Normalize(); } var offset = Vector2.Distance(bossOutline[j], bossOutline[i]) / 16; var currentPoint = bossOutline[i]; var projectileInstance = GameManager.Instantiate(phaseOneProjectile, currentPoint + transform.Position - projectileSprite.GetCenter()); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; var instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); instanceVelocity.Direction = projectileDirection; while (Vector2.Distance(currentPoint, bossOutline[j]) >= offset) { currentPoint += offset * direction; projectileInstance = GameManager.Instantiate(phaseOneProjectile, currentPoint + transform.Position - projectileSprite.GetCenter()); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); instanceVelocity.Direction = projectileDirection; } } }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (gameTime.TotalGameTime.TotalMilliseconds >= cooldown + lastAttackTime) { cooldown = 300; var numProjectiles = projectileWave + 2; var offset = VectorMath.Degrees2Radians((range.Y - range.X) / (numProjectiles + 1)); var currentAngle = VectorMath.Degrees2Radians(range.X); for (int i = 0; i < numProjectiles; i++) { currentAngle += offset; var projectileInstance = GameManager.Instantiate(projectile, transform.Position + renderer.Sprite.GetCenter() - projectileRenderer.Sprite.GetCenter()); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; var velocity = (Velocity)projectileInstance.GetComponent <Velocity>(); velocity.Direction = VectorMath.Angle2Vector(currentAngle); } projectileWave++; if (projectileWave > 3) { projectileWave = 0; cooldown = 2000; } lastAttackTime = gameTime.TotalGameTime.TotalMilliseconds; } }
public void BulletRain(float offset) { for (var currentX = offset; currentX <= 710; currentX += bulletRainSpacing) { var projectileInstance = GameManager.Instantiate(bulletRainProjectile, new Vector2(currentX, transform.Y + ((isFlipped) ? renderer.Sprite.GetDimensions().Y + 10 : -10))); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; var projectileVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); projectileVelocity.Direction = -VectorMath.Angle2Vector(transform.Rotation); } }
private void FireProjectile() { var projectileInstance = GameManager.Instantiate(PlayerProjectile, sprite.GetCenter() + transform.Position - projectileSprite.GetCenter()); projectileInstance.Tag = "Player" + PlayerProjectile.Tag; var instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); instanceVelocity.Direction = VectorMath.Angle2Vector(transform.Rotation); var instanceProjectile = (Projectile)projectileInstance.GetComponent <Projectile>(); }
private void BulletFan(Vector2 origin) { for (var currentAngle = 0f; currentAngle < Math.PI * 2; currentAngle += bulletFanOffset) { var projectileInstance = GameManager.Instantiate(bulletFanProjectile, origin); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; var instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); instanceVelocity.Direction = VectorMath.Angle2Vector(currentAngle); ((Transform)projectileInstance.GetComponent <Transform>()).Rotation = currentAngle; } }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (gameTime.TotalGameTime.TotalMilliseconds > lastAttackTime + cooldown) { var projectileOrigin = renderer.Sprite.GetCenter() + transform.Position - projectileRenderer.Sprite.GetCenter(); for (currentAngle = 0; currentAngle < Math.PI * 2; currentAngle += offset) { var projectileInstance = GameManager.Instantiate(projectile, projectileOrigin); projectileInstance.Tag = "Enemy" + projectileInstance.Tag; var instanceVelocity = (Velocity)projectileInstance.GetComponent <Velocity>(); instanceVelocity.Direction = VectorMath.Angle2Vector(currentAngle); ((Transform)projectileInstance.GetComponent <Transform>()).Rotation = currentAngle; } lastAttackTime = gameTime.TotalGameTime.TotalMilliseconds; } }