public static void EnemyLogic() { for (int i = 0; i < allEnemies.Count; i++) { if (allEnemies[i].type == EnemyType.Easy) { EnemyAIEasy(allEnemies[i]); } else if (allEnemies[i].type == EnemyType.Hard) { EnemyAIHard(allEnemies[i]); } else if (allEnemies[i].type == EnemyType.Kamikaze) { EnemyAIKamikaze(allEnemies[i]); } else { EnemyAIDummy(allEnemies[i]); } } if (RoundManager.bossAlive == true) { if (BossSun.boss != null) { BossSun.AI(); } } }
static void EnemyDead(BossSun boss) { boss = null; // BETTER WAY??? RoundManager.bossAlive = false; // Check if should update to new round RoundManager.RoundCompleted(); }
public BossSun() { var rnd = new Random(); int side = rnd.Next(1, 5); // 1 up, 2 down, 3 left, 4 right Vector2 pos = new Vector2(0, 0); switch (side) { case 1: pos = new Vector2(Player.ship.pos.X + rnd.Next(-Raylib.GetScreenWidth() / 2, Raylib.GetScreenWidth() / 2), Player.ship.pos.Y + Raylib.GetScreenHeight() / 2 + 200); break; case 2: pos = new Vector2(Player.ship.pos.X + rnd.Next(-Raylib.GetScreenWidth() / 2, Raylib.GetScreenWidth() / 2), Player.ship.pos.Y - Raylib.GetScreenHeight() / 2 - 200); break; case 3: pos = new Vector2(Player.ship.pos.X - Raylib.GetScreenWidth() / 2 - 200, Player.ship.pos.Y + rnd.Next(-Raylib.GetScreenHeight() / 2, Raylib.GetScreenHeight() / 2)); break; case 4: pos = new Vector2(Player.ship.pos.X + Raylib.GetScreenWidth() / 2 + 200, Player.ship.pos.Y + rnd.Next(-Raylib.GetScreenHeight() / 2, Raylib.GetScreenHeight() / 2)); break; default: break; } int maxHealth = 2000; float speed = 0.01f; int damage = 10; float fireRate = 1.5f; float sunFireRate = 0.08f; this.pos = pos; this.maxHealth = maxHealth; this.health = maxHealth; this.speed = speed; this.damage = damage; this.fireRate = fireRate; this.sunFireRate = sunFireRate; this.width = Program.allTextures["BossSun"].width; this.height = Program.allTextures["BossSun"].height; boss = (this); }
static void RenderWorld(Dictionary <String, Texture2D> Textures) // RenderWorld { // https://www.raylib.com/examples/web/textures/loader.html?name=textures_srcrec_dstrec // Raylib.DrawRectangle((int)(-Player.ship.pos.X - 50f), (int)(Player.ship.pos.Y - 50f), 100, 100, Color.GREEN); // Draw stars Star.DrawStars(); // Draw bosses if (RoundManager.bossAlive) { if (BossSun.boss != null) { BossSun.DrawBoss(); DrawHealthBar(new Vector2(BossSun.boss.pos.X - Player.ship.pos.X, -BossSun.boss.pos.Y + Player.ship.pos.Y), BossSun.boss.width, BossSun.boss.height, BossSun.boss.health, BossSun.boss.maxHealth); } } // Draw all the enemies foreach (Enemy enemy in Enemy.allEnemies) { if (enemy.type == EnemyType.Easy) { DrawObjectRotation(Textures["EnemyEasy"], enemy.pos - Player.ship.pos, enemy.rotation, 1, 255); } else if (enemy.type == EnemyType.Hard) { DrawObjectRotation(Textures["EnemyHard"], enemy.pos - Player.ship.pos, enemy.rotation, 1, 255); } else if (enemy.type == EnemyType.Kamikaze) { DrawObjectRotation(Textures["EnemyKamikaze"], enemy.pos - Player.ship.pos, enemy.rotation, 1, 255); } else if (enemy.type == EnemyType.Dummy) { DrawObjectRotation(Textures["EnemyDummy"], enemy.pos - Player.ship.pos, enemy.rotation, 1, 255); } } // Draw all the enemy healthbars foreach (Enemy enemy in Enemy.allEnemies) { DrawHealthBar(new Vector2(enemy.pos.X - Player.ship.pos.X, -enemy.pos.Y + Player.ship.pos.Y), enemy.width, enemy.height, enemy.health, enemy.maxHealth); } // Draw bullets foreach (var bullet in Bullet.allBullets) { if (bullet.isExplosive) { DrawObjectRotation(Textures["Bomb"], bullet.pos - Player.ship.pos, bullet.rotation, 1, 255); } else { DrawObjectRotation(Textures["Laser"], bullet.pos - Player.ship.pos, bullet.rotation, 1, 255); } } // Draw player DrawObjectRotation(Textures["PlayerShip"], new Vector2(0, 0), Player.ship.rotation, 1, 255); // Draw player health bar DrawHealthBar(new Vector2(0, 0), Player.ship.width, Player.ship.height, Player.ship.health, Player.ship.maxHealth); // Display round // Raylib.DrawText("Round: " + RoundManager.currentRound.round.ToString(), Raylib.GetScreenWidth() / 2, 0, 15, Color.WHITE); // Display FPS Raylib.DrawText(Raylib.GetFPS().ToString(), Raylib.GetScreenWidth() - 50, 10, 30, Color.WHITE); // Display player stats // Raylib.DrawText(Player.ship.health.ToString() + ":" + Player.ship.maxHealth.ToString(), Raylib.GetScreenWidth() - 120, 50, 30, Color.WHITE); // Display player score Raylib.DrawText("Score : " + Player.ship.score.ToString(), 20, 10, 40, Color.YELLOW); // // Display enemy amounts // Raylib.DrawText(Enemy.allEnemies.Count.ToString(), Raylib.GetScreenWidth() - 100, 10, 30, Color.WHITE); // // Display bullet amounts // Raylib.DrawText(Bullet.allBullets.Count.ToString(), Raylib.GetScreenWidth() - 100, 35, 30, Color.WHITE); // Draw effects foreach (Effect effect in EventManager.allEffects) { DrawObjectRotation(effect.texture, effect.pos - Player.ship.pos, effect.rotation, effect.size, effect.transparency); } foreach (TextBox text in EventManager.allTexts) { Raylib.DrawText(text.text, (int)text.pos.X, (int)text.pos.Y, text.fontSize, text.color); } }