コード例 #1
0
 public static HitboxRepo getHitboxRepo()
 {
     if (hitboxRepo == null)
     {
         hitboxRepo = new HitboxRepo();
     }
     // throw new System.ArgumentException("Must make HitboxRepo first");
     return(hitboxRepo);
 }
コード例 #2
0
        private Enemy makeEnemy(string textureName, int health, Path path, string gunType, float delay, double scale = 1)
        {
            Texture2D texture = GraphicsLoader.getGraphicsLoader().getTexture(textureName);
            Enemy     enemy;

            try
            {
                enemy = new Enemy(texture, path, health, BulletFactoryFactory.make(gunType), delay);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error loading gun " + gunType);
                Console.WriteLine(e.Message);
                enemy = new Enemy(texture, path, health);
            }
            Gun gun = gunFactory.makeGun(gunType);

            enemy.Hitbox = HitboxRepo.getHitboxRepo().getHitbox(textureName).Copy();
            enemy.Scale(scale);
            enemy.healthbar = new HealthBar(enemy.Location, new Vector2(8, 0), enemy.Rect.Width, 10, enemy.Health);


            return(enemy);
        }