private void enemyBossStart() { try { int col = 115; int row = 45; String source = "./boss_enemy.png"; row = 40; col = 40; boss = new enemyObject(game, source, col, row, 200, 200); bossLifeBar.Width = 150; bossLifeBar.Height = 25; bossLifeBar.Stroke = new SolidColorBrush(Colors.Red); bossLifeBar.Fill = new SolidColorBrush(Colors.Red); Canvas.SetLeft(bossLifeBar, 275); Canvas.SetTop(bossLifeBar, 12); game.Children.Add(bossLifeBar); bossLabel.Content = "BOSS"; bossLabel.Visibility = Visibility.Visible; } catch (Exception) { } }
void enemyOStartLvl2() { String source = "./enemy3.gif"; int y = 130; int x = 500; try { for (int i = 0; i < enemyArrayEX2.Length; i++) { if (i < 3) { enemyArrayEX2[i] = new enemyObject(game, source, x, y, 60, 60); y += 60; } else if (i == 3) { y = 130; x = 100; enemyArrayEX2[i] = new enemyObject(game, source, x, y, 60, 60); y += 60; } else if (i <= 6) { enemyArrayEX2[i] = new enemyObject(game, source, x, y, 60, 60); y += 60; } } } catch (Exception) { } }
public static bool BossdetectCollsion(Canvas game, enemyObject enemy, Rectangle bullet) { try { //BULLET double leftB = Convert.ToDouble(bullet.GetValue(Canvas.LeftProperty)); double topB = Convert.ToDouble(bullet.GetValue(Canvas.TopProperty)); Rect bulletPosition = new Rect(leftB, topB, 30, 10); //Rect bulletPosition = new Rect(bulletPoint, bulletPoint2); //ENEMY double leftE = Canvas.GetLeft(enemy.getImage()); double topE = Canvas.GetTop(enemy.getImage()); Rect enemyPosition = new Rect(leftE + 18, topE + 20, 160, 160); //HITBOX Rectangle rec1 = new Rectangle(); rec1.Width = 160; rec1.Height = 160; rec1.Stroke = new SolidColorBrush(Colors.Red); //rec1.Fill = new SolidColorBrush(Colors.Red); Canvas.SetLeft(rec1, leftE + 18); Canvas.SetTop(rec1, topE + 20); //game.Children.Add(rec1); if (game.Children.Contains(enemy.getImage())) { enemyPosition.Intersect(bulletPosition); if (!(enemyPosition.IsEmpty)) { return(true); } } } catch (Exception) { } return(false); }
private void enemyOStart() { try { int col = 115; int row = 45; String source = ""; for (int i = 0; i < enemyArrayEX.Length; i++) { if (i % 10 == 0 && i != 0) { row += 40; col = 40; } if (i == 10) { col = 115; } else if (i == 20) { col = 115; } if (i % 2 == 0) { source = "./enemy1.png"; } else { source = "./enemy2.png"; } enemyArrayEX[i] = new enemyObject(game, source, col, row, 30, 30); col += 40; } } catch (Exception) { } }