"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PlayButton = void 0;
class PlayButton extends Phaser.GameObjects.Container {
  constructor(scene) {
    super(scene, scene.scale.width / 2, scene.scale.height / 4);
    this.scene = scene;
    this.playButton = this.scene.add.image(0, 0, "play").setInteractive();
    this.shadow = this.scene.add.image(0, 0, "play").setTint(0x000000).setAlpha(0.5);
    this.init();
    this.scene.add.existing(this);
  }
  init() {
    var _this$scene$mountain;
    const scaleFactor = ((_this$scene$mountain = this.scene.mountain) === null || _this$scene$mountain === void 0 ? void 0 : _this$scene$mountain.scaleFactors.height) || 1;
    const width = 185;
    const height = 185;
    this.playButton.setPosition(0, 0);
    this.playButton.setVisible(false);
    this.playButton.setDisplaySize(width * scaleFactor, height * scaleFactor);
    this.shadow.setPosition(this.playButton.x + 5, this.playButton.y + 5);
    this.shadow.setVisible(false);
    this.shadow.setDisplaySize(width * scaleFactor, height * scaleFactor);
    this.add([this.shadow, this.playButton]).setAlpha(1).setDepth(3);

    // Handle resizing
    this.scene.scale.once('resize', this.scaleToFit, this);
    this.scene.scale.once('resize', this.positionOnMountain, this);
    this.scene.tweens.add({
      targets: this,
      scaleX: 1.2,
      scaleY: 1.2,
      duration: 1300,
      yoyo: true,
      ease: 'Power1',
      repeat: -1
    });
  }
  positionOnMountain() {
    this.setY(this.scene.scale.height / 2);
    this.setX(this.scene.scale.width / 2);
    this.playButton.setVisible(true);
    this.shadow.setVisible(true);
  }
  scaleToFit() {
    var _this$scene$mountain2;
    // Use the scale factor from the Sky class to maintain consistency
    const scaleFactor = ((_this$scene$mountain2 = this.scene.mountain) === null || _this$scene$mountain2 === void 0 ? void 0 : _this$scene$mountain2.scaleFactors.height) || 1;
    const height = this.height * scaleFactor;
    // // Apply the scale factor to the player
    this.setDisplaySize(this.width, height);
  }
}
exports.PlayButton = PlayButton;