// Creates a bullet that follow the path of a line towards the player //boss: used for position data of boss and player public void Make_Boss_slantedshot(Boss boss) { double slope = (boss.Y + 100 - boss.p_y) / (boss.X - boss.p_x); Bullet b = new Slanted_Bullet(boss.X, boss.Y + 100, slope) { id = ID.Hostile }; if (boss.p_x > boss.X) { b.direction = 1; } else { b.direction = -1; (b as Slanted_Bullet).slope *= -1; } Image i = new Image() { Source = new BitmapImage(new Uri("images/" + "C_bullet.png", UriKind.Relative)), Width = 20, Height = 20 }; WorldCanvas.Children.Add(i); icons.Add(new Icon() { i = i, e = b }); gameCtrl.current_Enemies.Add(b); }
public void UpdatePosition_SlantedBullet_Friendly_Success() { Slanted_Bullet test = new Slanted_Bullet(20, 20, 50); test.UpdatePosition(); Assert.IsTrue(test.X > 20); Assert.IsTrue(test.Y > 20); }
public void Make_TripleShot(Entity p) { if (p is Player) { var sound = new MediaPlayer(); sound.Open(new Uri(System.Environment.CurrentDirectory.Substring(0, System.Environment.CurrentDirectory.Length - 9) + "Resources\\Shoot1.wav", UriKind.Absolute)); Application.Current.Dispatcher.BeginInvoke(new Action(() => sound.Play())); double x = p.X + 50, y = p.Y + 10; Slanted_Bullet up = new Slanted_Bullet(x, y, -1); Slanted_Bullet down = new Slanted_Bullet(x, y, 1); Bullet normal = new Bullet(x, y); up.direction = 1; down.direction = 1; normal.direction = 1; Image img_up = new Image() { Source = new BitmapImage(new Uri("images/" + "P_bullet.png", UriKind.Relative)) }; Image img_down = new Image() { Source = new BitmapImage(new Uri("images/" + "P_bullet.png", UriKind.Relative)) }; Image img_normal = new Image() { Source = new BitmapImage(new Uri("images/" + "P_bullet.png", UriKind.Relative)) }; img_up.Width = 20; img_down.Width = 20; img_normal.Width = 20; Icon i_up = new Icon() { i = img_up, e = up }; Icon i_down = new Icon() { i = img_down, e = down }; Icon i_normal = new Icon() { i = img_normal, e = normal }; gameCtrl.player_fire.Add(up); gameCtrl.player_fire.Add(down); gameCtrl.player_fire.Add(normal); icons.Add(i_up); icons.Add(i_down); icons.Add(i_normal); WorldCanvas.Children.Add(img_up); WorldCanvas.Children.Add(img_down); WorldCanvas.Children.Add(img_normal); i_up.update(); i_down.update(); i_normal.update(); } }
public void UpdatePosition_SlantedBullet_Hostile_Success() { Slanted_Bullet test = new Slanted_Bullet(20, 20, 50); test.id = ID.Hostile; test.UpdatePosition(); Assert.IsTrue(test.X > 20); Assert.IsTrue(test.Y > 20); }
public void UpdatePosition_SlantedBullet_OutofBounds_Despawn() { Slanted_Bullet test = new Slanted_Bullet(20, 20, 50); test.id = ID.Hostile; test.X = 1201; test.UpdatePosition(); Assert.IsTrue(test.alive == false); test.alive = true; test.X = -2000; test.UpdatePosition(); Assert.IsTrue(test.alive == false); }