package game.locations.entrance;

import openfl.display.Bitmap;
import openfl.Assets;
import openfl.events.Event;

import game.locations.Location;

import base.GameSprite;

class Entrance extends Location {
  public function new() {
    super();

    id = 'entrance';

    addBmpLayer('bg');

    var passway = new Interactive(game.locations.celestialLockBasement.CelestialLockBasement);
    passway.initBitmap(bmpPath('passway'));
    passway.gotoFade = true;
    passway.x = 70;
    addChild(passway);

    var doorLayer = new GameSprite();

    var door = new Interactive(true, ['Тяжелая металлическая дверь с кодовым замком']);
    door.initBitmap(bmpPath('door'));
    doorLayer.addChild(door);

    var lock = new Lock();
    lock.x = 110;
    lock.y = 85;
    doorLayer.addChild(lock);

    doorLayer.x = 70;

    lock.addEventListener('opened', function(e: Event) {
      navigation = false;
      passway.actionable = false;

      timer(0.5, function() {
        Game.currentGame.playSound('sound/entrance/door.ogg');
          doorLayer.tween({ scaleX: 0.6 }, 1).then(function() {
          passway.actionable = true;
        });
      });
    });

    addChild(doorLayer);

    downLocation = game.locations.basementElevator.BasementElevator;
  }
}
