var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var GameObjectType; (function (GameObjectType) { GameObjectType[GameObjectType["NONE"] = 0] = "NONE"; GameObjectType[GameObjectType["HOLE"] = 1] = "HOLE"; GameObjectType[GameObjectType["PILL_MB6_BIG_DOWN"] = 2] = "PILL_MB6_BIG_DOWN"; GameObjectType[GameObjectType["PILL_BOOSTER_DOWN"] = 4] = "PILL_BOOSTER_DOWN"; GameObjectType[GameObjectType["PILL_RND_DOWN"] = 6] = "PILL_RND_DOWN"; GameObjectType[GameObjectType["HOLE_PILL"] = 7] = "HOLE_PILL"; GameObjectType[GameObjectType["STRESS_DOWN"] = 8] = "STRESS_DOWN"; GameObjectType[GameObjectType["HOLE_STRESS"] = 9] = "HOLE_STRESS"; GameObjectType[GameObjectType["PILL_MB6_BIG_STRESS"] = 10] = "PILL_MB6_BIG_STRESS"; GameObjectType[GameObjectType["ITEM_RND_DOWN"] = 14] = "ITEM_RND_DOWN"; GameObjectType[GameObjectType["HOLE_ITEM"] = 15] = "HOLE_ITEM"; GameObjectType[GameObjectType["LEVEL_UP"] = 16] = "LEVEL_UP"; GameObjectType[GameObjectType["PILL_MB6_BIG_UP"] = 18] = "PILL_MB6_BIG_UP"; GameObjectType[GameObjectType["PILL_BOOSTER_UP"] = 20] = "PILL_BOOSTER_UP"; GameObjectType[GameObjectType["STRESS_UP"] = 24] = "STRESS_UP"; GameObjectType[GameObjectType["ITEM_RND_UP"] = 30] = "ITEM_RND_UP"; GameObjectType[GameObjectType["LEVEL_RND"] = 32] = "LEVEL_RND"; GameObjectType[GameObjectType["PILL_RND"] = 38] = "PILL_RND"; GameObjectType[GameObjectType["STRESS_RND"] = 40] = "STRESS_RND"; GameObjectType[GameObjectType["ITEM_RND"] = 46] = "ITEM_RND"; GameObjectType[GameObjectType["RND"] = 47] = "RND"; GameObjectType[GameObjectType["MOVIMENT"] = 64] = "MOVIMENT"; })(GameObjectType = TProject.GameObjectType || (TProject.GameObjectType = {})); var GameObject = (function (_super) { __extends(GameObject, _super); function GameObject(base, type) { var _this = _super.call(this, base.game) || this; _this._isFlying = false; _this._base = base; GameObject.createHits(); _this._visual = _this.game.make.image(0, 0, "atlas", "icons/pill_00_icon"); _this._visual.anchor.set(0.5); _this.addChild(_this._visual); _this._rect = new Phaser.Rectangle(0, 0, 0, 0); _this.reuse(type); return _this; } GameObject.prototype.reuse = function (type, line) { if (line === void 0) { line = 0; } var pillTween = false; if (this._objectTween) { this.game.tweens.remove(this._objectTween); } if (type >= GameObjectType.MOVIMENT) { this.makeMovingVertical(type, line); type = GameObjectType.STRESS_DOWN; } else { type = this.decryptType(type); } if (this._base.life >= this._base.MAXIMUM_NUMBER_OF_LIVES && type == GameObjectType.PILL_MB6_BIG_DOWN) { type = GameObjectType.STRESS_DOWN; } this._type = type; this._visual.scale.set(1); this.angle = 0; switch (type) { case GameObjectType.PILL_MB6_BIG_DOWN: this._rect.width = 110; this._rect.height = 110; this._rect.x = -this._rect.width * 0.5; this._rect.y = -this._rect.height * 0.5; pillTween = true; break; case GameObjectType.PILL_BOOSTER_DOWN: this._rect.width = 40; this._rect.height = 40; this._rect.x = -this._rect.width * 0.5; this._rect.y = -this._rect.height * 0.5; pillTween = true; break; case GameObjectType.STRESS_DOWN: this._rect.width = 110; this._rect.height = 110; this._rect.x = -this._rect.width * 0.5; this._rect.y = -this._rect.height * 0.5; break; } if (TProject.BaseGame.gameMode != TProject.GameModeType.NONE) { var icon = ""; if ((type & GameObjectType.STRESS_DOWN) == GameObjectType.STRESS_DOWN) { var rndIndex = Math.floor(Math.random() * 4); icon = "rooms\/" + TProject.BaseGame.gameMode + "\/icon_" + rndIndex.toString(); } else if ((type & GameObjectType.PILL_MB6_BIG_DOWN) > 0) { icon = "icons/pill_00_icon"; } else if ((type & GameObjectType.PILL_BOOSTER_DOWN) > 0) { icon = "icons/pill_01_icon"; } if (icon != "") { this._visual.loadTexture("atlas", icon); } } if (pillTween) { this._visual.scale.set(0.85); this._objectTween = this.game.add.tween(this._visual.scale).to({ x: 1, y: 1 }, 450, Phaser.Easing.Sinusoidal.InOut, true, 0, -1, true); } this.visible = type != GameObjectType.NONE; this._free = !this.visible; this.x = TProject.Core.width + (this.width * 0.5) * this.$; }; GameObject.prototype.makeMovingVertical = function (type, line) { var speed = 700 + ((type & 7) * 45.0); var delay = ((type & 24) >> 3) * 65; var easing = (type & 32) == 32 ? Phaser.Easing.Back.Out : Phaser.Easing.Sinusoidal.InOut; var dir = line == 1 ? 1 : -1; this._objectTween = this.game.add.tween(this).to({ y: this.position.y + 200 * dir * TProject.Config.$ }, speed, easing, true, delay, -1, true); }; GameObject.prototype.fly = function (toX, toY, callback) { var _this = this; if (toX === void 0) { toX = 0; } if (toY === void 0) { toY = 0; } if (callback === void 0) { callback = null; } if (this.isFlying) { return; } if (this._objectTween != null) { this.game.tweens.remove(this._objectTween); } this._isFlying = true; if (toX == 0 && toY == 0) { toX = this.game.rnd.integerInRange(700, 1100) * TProject.Config.$; toY = this.game.rnd.integerInRange(-700, 700) * TProject.Config.$; } var animTime = this.game.rnd.integerInRange(700, 900); var randomY = this.game.rnd.integerInRange(50, 200); this.game.add.tween(this._visual.scale).to({ x: 0.3, y: 0.3 }, 500, Phaser.Easing.Sinusoidal.Out, true, animTime - 500); this.game.add.tween(this).to({ x: [this.x, (this.x + toX) * 0.7 + toX, (this.x + toX) * 0.2 + toX, toX + this.game.rnd.integerInRange(-15, 15)], y: [this.y, this.y - randomY, Math.min((this.y - toY), (toY - this.y)) * 0.5 - randomY, toY + this.game.rnd.integerInRange(-15, 15)] }, animTime, Phaser.Easing.Sinusoidal.Out, true, 0).interpolation(function (v, k) { return Phaser.Math.bezierInterpolation(v, k); }); this.game.add.tween(this).to({ alpha: 0.0 }, animTime - (animTime * 0.3), Phaser.Easing.Sinusoidal.In, true, animTime * 0.3); this.game.add.tween(this).to({ angle: this.game.rnd.integerInRange(-300, 300), alpha: 0.0 }, animTime, Phaser.Easing.Sinusoidal.Out, true).onComplete.addOnce(function () { _this.setVisible(false); _this.alpha = 1.0; _this.angle = 0.0; _this._isFlying = false; _this.setFree(true); _this.game.world.bringToTop(_this); if (callback != null) { callback(); } }); }; GameObject.prototype.setFree = function (value) { if (value === void 0) { value = true; } this._free = value; }; GameObject.prototype.setVisible = function (value) { this.visible = value; }; Object.defineProperty(GameObject.prototype, "goAway", { get: function () { return this.x < -(this.width * 0.8) * this.$; }, enumerable: true, configurable: true }); Object.defineProperty(GameObject.prototype, "hit", { get: function () { GameObject.HITS[this.getHitType()].parent = this; return GameObject.HITS[this.getHitType()]; }, enumerable: true, configurable: true }); Object.defineProperty(GameObject.prototype, "myType", { get: function () { return this._type; }, enumerable: true, configurable: true }); Object.defineProperty(GameObject.prototype, "isFree", { get: function () { return this._free; }, enumerable: true, configurable: true }); Object.defineProperty(GameObject.prototype, "$", { get: function () { return TProject.Config.ATLAS_SCALE; }, enumerable: true, configurable: true }); Object.defineProperty(GameObject.prototype, "isFlying", { get: function () { return this._isFlying; }, enumerable: true, configurable: true }); GameObject.createHits = function () { if (this.HITS) return; var $ = TProject.Config.ATLAS_SCALE; this.HITS = []; this.HITS.push(new TProject.MPolygon([0, 0])); this.HITS.push(new TProject.MPolygon([ -70 * $, -70 * $, 70 * $, -70 * $, 70 * $, 70 * $, -70 * $, 70 * $, ])); this.HITS.push(new TProject.MPolygon([ -70 * $, -70 * $, 70 * $, -70 * $, 70 * $, 70 * $, -70 * $, 70 * $, ])); this.HITS.push(new TProject.MPolygon([ -70 * $, -70 * $, 70 * $, -70 * $, 70 * $, 70 * $, -70 * $, 70 * $, ])); }; GameObject.prototype.getHitType = function () { switch (this._type) { case GameObjectType.STRESS_DOWN: return 1; case GameObjectType.PILL_MB6_BIG_DOWN: return 2; case GameObjectType.PILL_BOOSTER_DOWN: return 3; } return 0; }; GameObject.prototype.decryptType = function (type) { if ((type & GameObjectType.HOLE) == GameObjectType.HOLE && (type & GameObjectType.ITEM_RND_DOWN) > 0) { type ^= Phaser.Utils.chanceRoll(50) ? GameObjectType.HOLE : GameObjectType.ITEM_RND_DOWN; if ((type & GameObjectType.HOLE) > 0) { return GameObjectType.HOLE; } } if ((type & GameObjectType.ITEM_RND_DOWN) > GameObjectType.STRESS_DOWN) { type &= Phaser.Utils.chanceRoll(5) ? ~GameObjectType.STRESS_DOWN : ~GameObjectType.PILL_RND_DOWN; } if ((type & GameObjectType.PILL_RND_DOWN) == GameObjectType.PILL_RND_DOWN) { type ^= Phaser.Utils.chanceRoll(30) ? GameObjectType.PILL_MB6_BIG_DOWN : GameObjectType.PILL_BOOSTER_DOWN; } if ((type & GameObjectType.LEVEL_RND) == GameObjectType.LEVEL_RND) { type ^= GameObjectType.LEVEL_RND; if (Phaser.Utils.chanceRoll(50)) { type = type & GameObjectType.ITEM_RND_DOWN; } else { type = type | GameObjectType.LEVEL_UP; } } return type; }; GameObject.prototype.pauseTween = function () { if (this._objectTween != null) { this._objectTween.pause(); } }; GameObject.prototype.resumeTween = function () { if (this._objectTween != null) { this._objectTween.resume(); } }; return GameObject; }(Phaser.Group)); TProject.GameObject = GameObject; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var HUD = (function (_super) { __extends(HUD, _super); function HUD(base) { var _this = _super.call(this, base.game) || this; _this.position.y = -TProject.Core.height; _this._base = base; _this._btnsContainer = _this.game.make.group(); _this.addChild(_this._btnsContainer); _this._pauseBtn = new TProject.OButton("atlas", ["ui/pauseMenu/pause_button"], function () { _this._base.pauseGameWithUI(); TProject.SoundMixer.play("click", _this.game.rnd.realInRange(0.5, 0.8)); }); _this._pauseBtn.position.set(0, 0); _this._btnsContainer.addChild(_this._pauseBtn); _this._pauseBtn.enabled = false; _this._heartImg = _this.game.make.image(0, 0, "atlas", "ui/pauseMenu/heart_icon"); _this._heartImg.anchor.set(0.5); _this._heartImg.position.set(-170 * TProject.Config.$, 0); _this._btnsContainer.addChild(_this._heartImg); _this._heartTxt = _this.game.make.text(0, 3 * TProject.Config.$, "10", { font: "ProximaNova-Light", fontSize: 60 * TProject.Config.$, fill: "#ffffff", align: "center" }); _this._heartTxt.anchor.set(0.5); _this._heartImg.addChild(_this._heartTxt); _this._musicToggleBtn = new TProject.OButtonCheck("atlas", ["ui/pauseMenu/on_sound_button"], ["ui/pauseMenu/off_sound_button"], function () { _this.toggleMusic(); TProject.SoundMixer.play("click", _this.game.rnd.realInRange(0.5, 0.8)); }); _this._musicToggleBtn.position.set(170 * TProject.Config.$, 0); _this._btnsContainer.addChild(_this._musicToggleBtn); _this._musicToggleBtn.enabled = false; var style = { font: "ProximaNova-Regular", fontSize: 50 * TProject.Config.$, fill: "#000000", align: "left", strokeThickness: 5 * TProject.Config.$ }; _this._distanceTxt = _this.game.make.text(0, 0, "score", style); _this.addChild(_this._distanceTxt); _this.updateUILayout(); _this.updateHUD(); _this.updateMusicStatus(); _this.show(); return _this; } HUD.prototype.show = function () { this._pauseBtn.enabled = true; this._musicToggleBtn.enabled = true; }; HUD.prototype.hide = function () { }; HUD.prototype.updateUILayout = function () { this.position.y = -this.game.height; if (TProject.Core.isLandscape) { this._btnsContainer.position.set(TProject.Core.width * 0.5, 80 * TProject.Config.$); this._distanceTxt.anchor.set(0.0); this._distanceTxt.position.set(10 * TProject.Config.$, 10 * TProject.Config.$); } else { this._btnsContainer.position.set(TProject.Core.width * 0.5, 150 * TProject.Config.$); this._distanceTxt.anchor.set(0.5); this._distanceTxt.position.set(this.game.width * 0.5, 300 * TProject.Config.$); } }; HUD.prototype.updateHUD = function () { this._heartTxt.text = this._base.life.toString(); this._distanceTxt.text = this.game.cache.getJSON("texts").distance + ("00000" + this._base.distanceByObject.toString()).substr(-5, 5); this._distanceTxt.clearColors(); this._distanceTxt.addStrokeColor("#00000000", 0); this._distanceTxt.addStrokeColor("#000000", this._distanceTxt.text.length - 5); }; HUD.prototype.updateLife = function (added) { var _this = this; if (added === void 0) { added = true; } this._heartImg.scale.set(1.0); if (added) { this.game.add.tween(this._heartImg.scale).to({ x: 1.3, y: 1.3 }, 400, Phaser.Easing.Elastic.Out, true).onComplete.addOnce(function () { _this._heartTxt.text = _this._base.life.toString(); _this.game.add.tween(_this._heartImg.scale).to({ x: 1.0, y: 1.0 }, 500, Phaser.Easing.Sinusoidal.InOut, true); }); } else { this.game.add.tween(this._heartImg.scale).to({ x: 0.8, y: 0.8 }, 300, Phaser.Easing.Sinusoidal.In, true, 0, 0, true).onRepeat.addOnce(function () { _this._heartTxt.text = _this._base.life.toString(); }); } }; HUD.prototype.toggleMusic = function () { TProject.Boot.SAVE_DATA.isPlayingMusic = this._musicToggleBtn.check; TProject.Boot.SAVE_DATA.saveData(); this.updateMusicStatus(); }; HUD.prototype.updateMusicStatus = function () { this._musicToggleBtn.setCheck(TProject.Boot.SAVE_DATA.isPlayingMusic); if (TProject.Boot.SAVE_DATA.isPlayingMusic) { TProject.SoundMixer.play("background_music", 0.12, true, true); this.game.sound.volume = 1.0; } else { TProject.SoundMixer.bgStop(); this.game.sound.volume = 0.0; } }; HUD.prototype.getHeartPositionX = function () { return this._heartImg.x; }; HUD.prototype.getHeartPositionY = function () { return this._btnsContainer.y + this._heartImg.y; }; return HUD; }(Phaser.Group)); TProject.HUD = HUD; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var ScrollBackground = (function (_super) { __extends(ScrollBackground, _super); function ScrollBackground(game, widthScreen, acceleration, key, frame) { var _this = _super.call(this, game) || this; _this.OFFSET = 2 * TProject.Config.$; _this._sprites = []; _this._acceleration = acceleration; var spr = _this.game.add.image(0, 0, key, frame, _this); var yOffcet = 0; spr.y = yOffcet; _this.y = -spr.height; _this._sprites.push(spr); _this._partWidth = spr.width; _this._partsCount = Math.max(2, Math.ceil((widthScreen * 2) / _this._partWidth)); _this._partJumpX = _this._partsCount * _this._partWidth - _this._partsCount + _this.OFFSET; for (var i = 1; i < _this._partsCount; i++) { spr = _this.game.add.image(i * _this._partWidth - _this.OFFSET, yOffcet, key, frame, _this); _this._sprites.push(spr); } return _this; } ScrollBackground.prototype.reset = function () { var _this = this; this._sprites.forEach(function (bg, index) { bg.x = index * _this._partWidth - _this.OFFSET; }); }; ScrollBackground.prototype.speedUpdate = function (speed) { if (!speed) { return; } speed = speed * this._acceleration; for (var i = 0; i < this._partsCount; i++) { this._sprites[i].x -= speed; if (this._sprites[i].x < -this._partWidth) { this._sprites[i].x += this._partJumpX - this.OFFSET; } } }; Object.defineProperty(ScrollBackground.prototype, "realWidth", { get: function () { return this._partWidth - this._partsCount + this.OFFSET; }, enumerable: true, configurable: true }); Object.defineProperty(ScrollBackground.prototype, "realHeight", { get: function () { if (!this._sprites || !this._sprites.length) { return 0; } return this._sprites[0].height; }, enumerable: true, configurable: true }); return ScrollBackground; }(Phaser.Group)); TProject.ScrollBackground = ScrollBackground; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var CurtainFade = (function (_super) { __extends(CurtainFade, _super); function CurtainFade(game, bgColor) { if (bgColor === void 0) { bgColor = CurtainFade.DEFAULT_BACKGORUND_COLOR; } var _this = _super.call(this, game) || this; _this._fadeOffset = 0.5; _this._bgColor = CurtainFade.DEFAULT_BACKGORUND_COLOR; _this._bgColor = bgColor; _this._scrFade = _this.game.make.graphics(0, 0); _this.addChild(_this._scrFade); _this.drawFade(); return _this; } CurtainFade.prototype.show = function (callback, color) { var _this = this; if (callback === void 0) { callback = null; } if (color === void 0) { color = CurtainFade.DEFAULT_BACKGORUND_COLOR; } this._bgColor = color; this._fadeOffset = 0.0; this.visible = true; this.game.add.tween(this).to({ _fadeOffset: 0.5 }, 500, Phaser.Easing.Sinusoidal.InOut, true).onUpdateCallback(function () { _this.drawFade(); }).onComplete.addOnce(function () { if (callback != null) { callback(); } }); TProject.SoundMixer.play("curtain-sfx", this.game.rnd.realInRange(0.1, 0.2)); }; CurtainFade.prototype.hide = function (callback, color) { var _this = this; if (callback === void 0) { callback = null; } if (color === void 0) { color = CurtainFade.DEFAULT_BACKGORUND_COLOR; } this._bgColor = color; this.game.add.tween(this).to({ _fadeOffset: 0.0 }, 300, Phaser.Easing.Sinusoidal.InOut, true).onUpdateCallback(function () { _this.drawFade(); }).onComplete.addOnce(function () { _this.visible = false; if (callback != null) { callback(); } }); }; CurtainFade.prototype.drawFade = function () { this._scrFade.clear(); this._scrFade.beginFill(this._bgColor); this._scrFade.drawRect(0, 0, TProject.Core.width * this._fadeOffset, TProject.Core.height); this._scrFade.drawRect(TProject.Core.width, 0, -TProject.Core.width * this._fadeOffset, TProject.Core.height); this._scrFade.endFill(); }; CurtainFade.DEFAULT_BACKGORUND_COLOR = 0xffc925; return CurtainFade; }(Phaser.Group)); TProject.CurtainFade = CurtainFade; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var GameOver = (function (_super) { __extends(GameOver, _super); function GameOver(base) { var _this = _super.call(this, base.game) || this; _this._shareDescTxt = ""; _this.position.x = _this.game.width / 2; _this.position.y = -TProject.Core.height + (_this.game.height / 2); _this._base = base; _this._fog = _this.game.make.graphics(0, 0); _this._fog.beginFill(0x000000, 0.5); _this._fog.drawRect(-_this.game.width * 1.5, -_this.game.height * 1.5, _this.game.width * 3, _this.game.height * 3); _this._fog.endFill(); _this._fog.inputEnabled = true; _this.addChild(_this._fog); _this._fog.alpha = 0.0; var w = 790 * TProject.Config.$; var h = 950 * TProject.Config.$; var ch = h * 0.5; var wnd = _this.game.make.graphics(0, 0); wnd.beginFill(0xfef9ee); wnd.drawRect(w * 0.5, h * 0.5, w, h); wnd.endFill(); _this._wnd = _this.game.make.image(0, 0, wnd.generateTexture()); _this._wnd.anchor.set(0.5); _this.addChild(_this._wnd); _this._wnd.alpha = 0.0; _this._replayBtn = new TProject.OButton("atlas", ["ui/gameOverMenu/button_bg"], function () { _this.onReplayGameClicked(); }); _this._replayBtn.position.set(0, ch - (240 * TProject.Config.$)); _this._wnd.addChild(_this._replayBtn); _this._replayBtn.enabled = false; _this._mainMenuBtn = new TProject.OButton("atlas", ["ui/gameOverMenu/button_bg"], function () { _this.onMainMenuClicked(); }); _this._mainMenuBtn.position.set(0, ch - (160 * TProject.Config.$)); _this._wnd.addChild(_this._mainMenuBtn); _this._mainMenuBtn.enabled = false; _this._socialBtnsContainer = _this.game.make.group(); _this._socialBtnsContainer.position.set(0, ch - (70 * TProject.Config.$)); _this._wnd.addChild(_this._socialBtnsContainer); _this._vkSocialBtn = new TProject.OButton("atlas", ["ui/gameOverMenu/vk_social_button"], function () { Share.vk(window["sharing-url"], _this._shareDescTxt, _this._base.distanceByObject.toString()); TProject.SoundMixer.play("click", _this.game.rnd.realInRange(0.5, 0.8)); }); _this._vkSocialBtn.position.set(-115 * TProject.Config.$, 0); _this._socialBtnsContainer.addChild(_this._vkSocialBtn); _this._vkSocialBtn.enabled = false; _this._facebookSocialBtn = new TProject.OButton("atlas", ["ui/gameOverMenu/facebook_social_button"], function () { Share.fb(window["sharing-url"], _this._shareDescTxt, _this._base.distanceByObject); TProject.SoundMixer.play("click", _this.game.rnd.realInRange(0.5, 0.8)); }); _this._facebookSocialBtn.position.set(0, 0); _this._socialBtnsContainer.addChild(_this._facebookSocialBtn); _this._facebookSocialBtn.enabled = false; _this._twitterSocialBtn = new TProject.OButton("atlas", ["ui/gameOverMenu/twitter_social_button"], function () { Share.tw(window["sharing-url"], _this._shareDescTxt, _this._base.distanceByObject); TProject.SoundMixer.play("click", _this.game.rnd.realInRange(0.5, 0.8)); }); _this._twitterSocialBtn.position.set(115 * TProject.Config.$, 0); _this._socialBtnsContainer.addChild(_this._twitterSocialBtn); _this._twitterSocialBtn.enabled = false; _this._yourDistanceTxt = _this.game.make.text(0, 0, "Message text", { font: "ProximaNova-Regular", fontSize: 38 * TProject.Config.$ + "px", fill: "#000000", strokeThickness: 2 * TProject.Config.$ }); _this._yourDistanceTxt.position.y = -ch + (70 * TProject.Config.$); _this._yourDistanceTxt.anchor.set(0.5); _this._wnd.addChild(_this._yourDistanceTxt); _this._titleTxt = _this.game.make.text(0, 0, "Message title text", { font: "ProximaNova-Regular", fontSize: 48 * TProject.Config.$ + "px", fontWeight: "bold", fill: "#000000", strokeThickness: 2 * TProject.Config.$ }); _this._titleTxt.position.y = -ch + (160 * TProject.Config.$); _this._titleTxt.anchor.set(0.5); _this._wnd.addChild(_this._titleTxt); _this._descriptionTxt = _this.game.make.text(0, 0, "Message board text", { font: "ProximaNova-Regular", fontSize: 40 * TProject.Config.$ + "px", fill: "#000000", align: "center", boundsAlignH: "center", boundsAlignV: "center", wordWrap: true, wordWrapWidth: _this._wnd.width * 0.85 }); _this._descriptionTxt.lineSpacing = -7 * TProject.Config.$; _this._descriptionTxt.position.y = -50 * TProject.Config.$; _this._descriptionTxt.anchor.set(0.5); _this._wnd.addChild(_this._descriptionTxt); var labelOffsetY = 5 * TProject.Config.$; var btnStyle = { font: "ProximaNova-Regular", fontSize: 35 * TProject.Config.$ + "px", fill: "#ffffff" }; { var labeTxt = _this.game.make.text(0, labelOffsetY, _this.game.cache.getJSON("texts").replay_game, btnStyle); labeTxt.anchor.set(0.5); _this._replayBtn.addChild(labeTxt); } { var labeTxt = _this.game.make.text(0, labelOffsetY, _this.game.cache.getJSON("texts").main_menu, btnStyle); labeTxt.anchor.set(0.5); _this._mainMenuBtn.addChild(labeTxt); } _this.visible = false; return _this; } GameOver.prototype.updateUILayout = function () { this.position.x = this.game.width / 2; this.position.y = -TProject.Core.height + (this.game.height / 2); }; GameOver.prototype.show = function () { var _this = this; this.generateShareDescription(); this.updateMessage(); this._replayBtn.enabled = false; this._mainMenuBtn.enabled = false; this.visible = true; this._wnd.pivot.y = -500 * TProject.Config.$; this.game.add.tween(this._fog).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); this.game.add.tween(this._wnd).to({ alpha: 1.0 }, 200, Phaser.Easing.Sinusoidal.Out, true); this.game.add.tween(this._wnd.pivot).to({ y: 0 }, 700, Phaser.Easing.Elastic.Out, true).onComplete.addOnce(function () { _this._replayBtn.enabled = true; _this._mainMenuBtn.enabled = true; _this._vkSocialBtn.enabled = true; _this._facebookSocialBtn.enabled = true; _this._twitterSocialBtn.enabled = true; _this.game.input.keyboard.onDownCallback = _this.onHotkeyBehaviour.bind(_this); }); TProject.SoundMixer.play("show-ui", this.game.rnd.realInRange(0.5, 0.8)); }; GameOver.prototype.hide = function () { var _this = this; this._replayBtn.enabled = false; this._mainMenuBtn.enabled = false; this._vkSocialBtn.enabled = false; this._facebookSocialBtn.enabled = false; this._twitterSocialBtn.enabled = false; this.game.input.keyboard.onDownCallback = null; this.game.add.tween(this._fog).to({ alpha: 0.0 }, 200, Phaser.Easing.Sinusoidal.In, true, 100); this.game.add.tween(this._wnd).to({ alpha: 0.0 }, 400, Phaser.Easing.Sinusoidal.In, true); this.game.add.tween(this._wnd.pivot).to({ y: -100 * TProject.Config.$ }, 400, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { _this.visible = false; }); TProject.SoundMixer.play("hide-ui", this.game.rnd.realInRange(0.5, 0.8)); }; GameOver.prototype.generateShareDescription = function () { this._shareDescTxt = window["share-text-begin"] + this._base.distanceByObject + window["share-text-end"]; }; GameOver.prototype.updateMessage = function () { var _this = this; this._yourDistanceTxt.text = this.game.cache.getJSON("texts").your_distance + ("00000" + this._base.distanceByObject.toString()).substr(-5, 5); var title = ""; var desc = ""; ["normal", "well", "fine"].forEach(function (key) { if (_this._base.distanceByObject >= window[TProject.BaseGame.gameMode + "-" + key + "-level"]) { title = window[TProject.BaseGame.gameMode + "-" + key + "-title"]; desc = window[TProject.BaseGame.gameMode + "-" + key + "-desc"]; } }); this._titleTxt.text = title; this._descriptionTxt.text = desc; this._yourDistanceTxt.clearColors(); this._yourDistanceTxt.addStrokeColor("#00000000", 0); this._yourDistanceTxt.addStrokeColor("#000000", this._yourDistanceTxt.text.length - 5); }; GameOver.prototype.onHotkeyBehaviour = function (key) { switch (key.keyCode) { case Phaser.KeyCode.ENTER: this.onReplayGameClicked(); break; case Phaser.KeyCode.ESC: this.onMainMenuClicked(); break; } }; GameOver.prototype.onReplayGameClicked = function () { TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.restartGame(); }; GameOver.prototype.onMainMenuClicked = function () { var _this = this; TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.showCurtainFade(function () { _this.game.state.start("MainMenu", true); }); }; return GameOver; }(Phaser.Group)); TProject.GameOver = GameOver; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var PauseMenu = (function (_super) { __extends(PauseMenu, _super); function PauseMenu(base) { var _this = _super.call(this, base.game) || this; _this._isMenu = true; _this.position.x = _this.game.width / 2; _this.position.y = -TProject.Core.height + (_this.game.height / 2); _this._base = base; _this._fog = _this.game.make.graphics(0, 0); _this._fog.beginFill(0x000000, 0.5); _this._fog.drawRect(-_this.game.width * 1.5, -_this.game.height * 1.5, _this.game.width * 3, _this.game.height * 3); _this._fog.endFill(); _this._fog.inputEnabled = true; _this.addChild(_this._fog); _this._fog.alpha = 0.0; _this._wnd = _this.game.make.image(0, 0); _this._wnd.anchor.set(0.5); _this.addChild(_this._wnd); _this._wnd.alpha = 0.0; var labelOffsetY = 4 * TProject.Config.$; var btnLabelStyle = { font: "ProximaNova-Regular", fontSize: 35 * TProject.Config.$ + "px", fill: "#ffffff" }; _this._resumeBtn = new TProject.OButton("atlas", ["ui/pauseMenu/button_bg"], function () { _this.onResumeGameClicked(); }); _this._resumeBtn.position.set(0, -148 * TProject.Config.$); _this._wnd.addChild(_this._resumeBtn); _this._resumeBtn.enabled = false; { var labeTxt = _this.game.make.text(0, labelOffsetY, _this.game.cache.getJSON("texts").resume_game, btnLabelStyle); labeTxt.anchor.set(0.5); _this._resumeBtn.addChild(labeTxt); } _this._restartBtn = new TProject.OButton("atlas", ["ui/pauseMenu/button_bg"], function () { _this.onRestartGameClicked(); }); _this._restartBtn.position.set(0, 0); _this._wnd.addChild(_this._restartBtn); _this._restartBtn.enabled = false; { var labeTxt = _this.game.make.text(0, labelOffsetY, _this.game.cache.getJSON("texts").restart_game, btnLabelStyle); labeTxt.anchor.set(0.5); _this._restartBtn.addChild(labeTxt); } _this._mainMenuBtn = new TProject.OButton("atlas", ["ui/pauseMenu/button_bg"], function () { _this.onMainMenuClicked(); }); _this._mainMenuBtn.position.set(0, 148 * TProject.Config.$); _this._wnd.addChild(_this._mainMenuBtn); _this._mainMenuBtn.enabled = false; { var labeTxt = _this.game.make.text(0, labelOffsetY, _this.game.cache.getJSON("texts").main_menu, btnLabelStyle); labeTxt.anchor.set(0.5); _this._mainMenuBtn.addChild(labeTxt); } _this._pauseTxt = _this.game.make.text(0, 0, _this.game.cache.getJSON("texts").pause, { font: "ProximaNova-Regular", fontSize: 80 * TProject.Config.$ + "px", fontWeight: "bold", fill: "#ffffff" }); _this._pauseTxt.anchor.set(0.5); _this.addChild(_this._pauseTxt); _this.visible = false; return _this; } PauseMenu.prototype.updateUILayout = function () { this.position.x = this.game.width / 2; this.position.y = -TProject.Core.height + (this.game.height / 2); }; PauseMenu.prototype.show = function (isMenu) { var _this = this; if (this.visible) { return; } this._isMenu = isMenu; this._resumeBtn.enabled = false; this._mainMenuBtn.enabled = false; this._pauseTxt.alpha = 0.0; this.visible = true; this.game.add.tween(this._fog).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); if (isMenu) { this._wnd.pivot.y = -200 * TProject.Config.$; this.game.add.tween(this._wnd).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); this.game.add.tween(this._wnd.pivot).to({ y: 0 }, 600, Phaser.Easing.Elastic.Out, true).onComplete.addOnce(function () { _this._resumeBtn.enabled = true; _this._restartBtn.enabled = true; _this._mainMenuBtn.enabled = true; _this.game.input.keyboard.onDownCallback = _this.onHotkeyBehaviour.bind(_this); }); TProject.SoundMixer.play("show-ui", this.game.rnd.realInRange(0.5, 0.8)); } else { this.game.add.tween(this._pauseTxt).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); } }; PauseMenu.prototype.hide = function () { var _this = this; this._resumeBtn.enabled = false; this._restartBtn.enabled = false; this._mainMenuBtn.enabled = false; this.game.input.keyboard.onDownCallback = null; this.game.add.tween(this._fog).to({ alpha: 0.0 }, 200, Phaser.Easing.Sinusoidal.In, true, 100); if (this._isMenu) { this.game.add.tween(this._wnd).to({ alpha: 0.0 }, 400, Phaser.Easing.Sinusoidal.In, true); this.game.add.tween(this._wnd.pivot).to({ y: -100 * TProject.Config.$ }, 400, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { _this.visible = false; }); TProject.SoundMixer.play("hide-ui", this.game.rnd.realInRange(0.5, 0.8)); } else { this.game.add.tween(this._pauseTxt).to({ alpha: 0.0 }, 200, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { _this.visible = false; _this._base.resumeGame(); }); } }; PauseMenu.prototype.onHotkeyBehaviour = function (key) { switch (key.keyCode) { case Phaser.KeyCode.ESC: this.onResumeGameClicked(); break; case Phaser.KeyCode.R: this.onRestartGameClicked(); break; case Phaser.KeyCode.BACKSPACE: this.onMainMenuClicked(); break; } }; PauseMenu.prototype.onResumeGameClicked = function () { TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.resumeGame(); }; PauseMenu.prototype.onRestartGameClicked = function () { TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.restartGame(); }; PauseMenu.prototype.onMainMenuClicked = function () { var _this = this; TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.showCurtainFade(function () { _this.game.state.start("MainMenu", true); }); }; Object.defineProperty(PauseMenu.prototype, "isMenu", { get: function () { return this._isMenu; }, enumerable: true, configurable: true }); return PauseMenu; }(Phaser.Group)); TProject.PauseMenu = PauseMenu; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var Tutorial = (function (_super) { __extends(Tutorial, _super); function Tutorial(base) { var _this = _super.call(this, base.game) || this; _this.position.x = _this.game.width / 2; _this.position.y = -TProject.Core.height + (_this.game.height / 2); _this._base = base; var isMobile = !TProject.Core.isDesktop; _this._fog = _this.game.make.graphics(0, 0); _this._fog.beginFill(0xbbbbbb, 0.8); _this._fog.drawRect(-_this.game.width * 1.5, -_this.game.height * 1.5, _this.game.width * 3, _this.game.height * 3); _this._fog.endFill(); _this._fog.inputEnabled = true; _this.addChild(_this._fog); _this._fog.alpha = 0.0; _this._wnd = _this.game.make.image(0, 0, "atlas", "ui/tutorial/background"); _this._wnd.anchor.set(0.5); _this.addChild(_this._wnd); _this._wnd.alpha = 0.0; _this._pillYellowImg = _this.game.make.image(-438 * TProject.Config.$, -149 * TProject.Config.$, "atlas", "icons/pill_00_icon"); _this._pillYellowImg.scale.set(0.53); _this._pillYellowImg.anchor.set(0.5); _this._pillYellowImg.alpha = 0.0; _this._wnd.addChild(_this._pillYellowImg); _this._pillBlueImg = _this.game.make.image(-438 * TProject.Config.$, -27 * TProject.Config.$, "atlas", "icons/pill_01_icon"); _this._pillBlueImg.scale.set(0.53); _this._pillBlueImg.anchor.set(0.5); _this._pillBlueImg.alpha = 0.0; _this._wnd.addChild(_this._pillBlueImg); if (!isMobile) { var enterKeyImg = _this.game.make.image(-386 * TProject.Config.$, 224 * TProject.Config.$, "atlas", "ui/tutorial/enter_button"); enterKeyImg.anchor.set(0.5); enterKeyImg.scale.set(0.0); _this._wnd.addChild(enterKeyImg); var spaceKeyImg = _this.game.make.image(228 * TProject.Config.$, 190 * TProject.Config.$, "atlas", "ui/tutorial/jump_button_with_text"); spaceKeyImg.anchor.set(0.5); spaceKeyImg.scale.set(0.0); _this._wnd.addChild(spaceKeyImg); } _this._readyBtn = new TProject.OButton("atlas", ["ui/tutorial/go_button_with_text"], function () { _this.onResumeGameClicked(); }); _this._readyBtn.position.set(0, 376 * TProject.Config.$); _this._wnd.addChild(_this._readyBtn); _this._readyBtn.scale.set(0.0); _this._readyBtn.enabled = false; _this._titleTxt = _this.game.make.text(0, -373 * TProject.Config.$, _this.game.cache.getJSON("texts").tutorial.title, { font: "ProximaNova-Regular", fontSize: 50 * TProject.Config.$ + "px", fill: "#000000" }); _this._titleTxt.anchor.set(0.5); _this._titleTxt.alpha = 0.0; _this._wnd.addChild(_this._titleTxt); var txtStyle = { font: "ProximaNova-Light", fontSize: 36 * TProject.Config.$ + "px", fill: "#000000", align: "left", boundsAlignH: "center", boundsAlignV: "top", wordWrap: true, wordWrapWidth: _this._wnd.width * 0.85 }; _this._descTxt = _this.game.make.text(-490 * TProject.Config.$, -270 * TProject.Config.$, _this.game.cache.getJSON("texts").tutorial.description, txtStyle); _this._descTxt.anchor.set(0.0, 0.5); _this._descTxt.alpha = 0.0; _this._descTxt.lineSpacing = -10 * TProject.Config.$; _this._wnd.addChild(_this._descTxt); _this._pillYellowTxt = _this.game.make.text(-366 * TProject.Config.$, -149 * TProject.Config.$, _this.game.cache.getJSON("texts").tutorial.pill_yellow, txtStyle); _this._pillYellowTxt.fontSize = 32 * TProject.Config.$ + "px"; _this._pillYellowTxt.anchor.set(0.0, 0.5); _this._pillYellowTxt.alpha = 0.0; _this._wnd.addChild(_this._pillYellowTxt); _this._pillBlueTxt = _this.game.make.text(-366 * TProject.Config.$, -27 * TProject.Config.$, _this.game.cache.getJSON("texts").tutorial.pill_blue, txtStyle); _this._pillBlueTxt.fontSize = 32 * TProject.Config.$ + "px"; _this._pillBlueTxt.anchor.set(0.0, 0.5); _this._pillBlueTxt.alpha = 0.0; _this._wnd.addChild(_this._pillBlueTxt); _this._gameTargetTxt = _this.game.make.text(1 * TProject.Config.$, 75 * TProject.Config.$, _this.game.cache.getJSON("texts").tutorial.game_target, txtStyle); _this._gameTargetTxt.anchor.set(0.5); _this._gameTargetTxt.alpha = 0.0; _this._gameTargetTxt.align = "center"; _this._wnd.addChild(_this._gameTargetTxt); var jumpingText = isMobile ? _this.game.cache.getJSON("texts").tutorial.mobile_control_for_jumping : _this.game.cache.getJSON("texts").tutorial.pc_control_for_jumping; var changingRoadText = isMobile ? _this.game.cache.getJSON("texts").tutorial.mobile_control_for_changing_road : _this.game.cache.getJSON("texts").tutorial.pc_control_for_changing_road; _this._changingRoadTxt = _this.game.make.text(-284 * TProject.Config.$, 242 * TProject.Config.$, changingRoadText, txtStyle); _this._changingRoadTxt.anchor.set(0.0, 0.5); _this._changingRoadTxt.alpha = 0.0; _this._wnd.addChild(_this._changingRoadTxt); _this._jumpingTxt = _this.game.make.text(228 * TProject.Config.$, 245 * TProject.Config.$, jumpingText, txtStyle); _this._jumpingTxt.anchor.set(0.0, 0.5); _this._jumpingTxt.alpha = 0.0; _this._wnd.addChild(_this._jumpingTxt); _this.updateUILayout(); _this.visible = false; return _this; } Tutorial.prototype.updateUILayout = function () { this.position.x = this.game.width / 2; this.position.y = -TProject.Core.height + (this.game.height / 2); var isLand = TProject.Core.isLandscape; if (isLand) { this._wnd.loadTexture("atlas", "ui/tutorial/background"); this._titleTxt.y = -373 * TProject.Config.$; this._descTxt.position.set(-490 * TProject.Config.$, -260 * TProject.Config.$); this._pillYellowTxt.position.set(-356 * TProject.Config.$, -114 * TProject.Config.$); this._pillBlueTxt.position.set(-356 * TProject.Config.$, 5 * TProject.Config.$); this._gameTargetTxt.position.set(0 * TProject.Config.$, 110 * TProject.Config.$); if (TProject.Core.isDesktop) { this._changingRoadTxt.position.set(-244 * TProject.Config.$, 242 * TProject.Config.$); this._jumpingTxt.position.set(108 * TProject.Config.$, 255 * TProject.Config.$); } else { this._changingRoadTxt.position.set(-444 * TProject.Config.$, 242 * TProject.Config.$); this._jumpingTxt.position.set(108 * TProject.Config.$, 245 * TProject.Config.$); } this._readyBtn.position.set(0, 376 * TProject.Config.$); this._pillYellowImg.position.set(-438 * TProject.Config.$, -119 * TProject.Config.$); this._pillBlueImg.position.set(-438 * TProject.Config.$, 0 * TProject.Config.$); } else { this._wnd.loadTexture("atlas", "ui/tutorial/background_portret"); this._titleTxt.y = -597 * TProject.Config.$; this._descTxt.position.set(-354 * TProject.Config.$, -404 * TProject.Config.$); this._pillYellowTxt.position.set(-166 * TProject.Config.$, -199 * TProject.Config.$); this._pillBlueTxt.position.set(-166 * TProject.Config.$, -27 * TProject.Config.$); this._gameTargetTxt.position.set(1 * TProject.Config.$, 180 * TProject.Config.$); this._changingRoadTxt.position.set(-330 * TProject.Config.$, 360 * TProject.Config.$); this._jumpingTxt.position.set(48 * TProject.Config.$, 360 * TProject.Config.$); this._readyBtn.position.set(0, 585 * TProject.Config.$); this._pillYellowImg.position.set(-291 * TProject.Config.$, -194 * TProject.Config.$); this._pillBlueImg.position.set(-291 * TProject.Config.$, -44 * TProject.Config.$); } this._descTxt.wordWrapWidth = this._wnd.width * 0.85; this._pillYellowTxt.wordWrapWidth = this._wnd.width * 0.65; this._pillBlueTxt.wordWrapWidth = this._wnd.width * 0.65; this._gameTargetTxt.wordWrapWidth = this._wnd.width * 0.85; this._changingRoadTxt.wordWrapWidth = this._wnd.width * 0.4; this._jumpingTxt.wordWrapWidth = this._wnd.width * 0.4; }; Tutorial.prototype.show = function () { var _this = this; if (this.visible) { return; } this._base.pauseGame(); this._readyBtn.enabled = false; this.visible = true; this.game.add.tween(this._fog).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); this._wnd.pivot.y = -200 * TProject.Config.$; this.game.add.tween(this._wnd).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.Out, true); this.game.add.tween(this._wnd.pivot).to({ y: 0 }, 600, Phaser.Easing.Elastic.Out, true).onComplete.addOnce(function () { _this._readyBtn.enabled = true; _this.game.input.keyboard.onDownCallback = _this.onHotkeyBehaviour.bind(_this); }); this._wnd.children.forEach(function (item, key) { if (item.alpha > 0) { _this.game.add.tween(item.scale).to({ x: 1.0, y: 1.0 }, 200, Phaser.Easing.Back.Out, true, 300 + (key * 100)); } else { _this.game.add.tween(item).to({ alpha: 1.0 }, 100, Phaser.Easing.Linear.None, true, key * 50); } }); TProject.SoundMixer.play("show-ui", this.game.rnd.realInRange(0.5, 0.7)); }; Tutorial.prototype.hide = function () { var _this = this; this._readyBtn.enabled = false; this.game.input.keyboard.onDownCallback = null; this.game.add.tween(this._fog).to({ alpha: 0.0 }, 200, Phaser.Easing.Sinusoidal.In, true, 100); this.game.add.tween(this._wnd).to({ alpha: 0.0 }, 400, Phaser.Easing.Sinusoidal.In, true); this.game.add.tween(this._wnd.pivot).to({ y: -100 * TProject.Config.$ }, 400, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { _this._base.resumeGame(); _this.visible = false; }); TProject.SoundMixer.play("hide-ui", this.game.rnd.realInRange(0.5, 0.7)); }; Tutorial.prototype.onHotkeyBehaviour = function (key) { switch (key.keyCode) { case Phaser.KeyCode.ENTER: case Phaser.KeyCode.ESC: case Phaser.KeyCode.SPACEBAR: this.onResumeGameClicked(); break; } }; Tutorial.prototype.onResumeGameClicked = function () { TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); this.hide(); this._base.resumeGame(); }; return Tutorial; }(Phaser.Group)); TProject.Tutorial = Tutorial; })(TProject || (TProject = {})); var TProject; (function (TProject) { var SaveData = (function () { function SaveData() { this.SAVE_DATA_NAME = "save_test_0"; this.isPlayingMusic = true; var saveData = TProject.CookieSave.getProperty(this.SAVE_DATA_NAME); if (saveData == null) { this.saveData(); } else { saveData = JSON.parse(saveData); this.isPlayingMusic = saveData.isPlayingMusic; } } SaveData.prototype.saveData = function () { TProject.CookieSave.setData(this.SAVE_DATA_NAME, this); }; return SaveData; }()); TProject.SaveData = SaveData; })(TProject || (TProject = {})); var Share; (function (Share) { function vk(shareUrl, description, imgUrl) { var url = "http://vkontakte.ru/share.php?"; url += "url=" + encodeURIComponent(shareUrl); url += "&title=" + encodeURIComponent(description); url += "&image=" + encodeURIComponent(imgUrl); url += "&noparse=true"; Share.openUrl(url); } Share.vk = vk; function fb(shareUrl, description, shareNumb) { var url = "https://www.facebook.com/sharer.php?u=" + encodeURIComponent(shareUrl + "?i=" + shareNumb); Share.openUrl(url); } Share.fb = fb; function tw(shareUrl, description, shareNumb) { var url = "http://twitter.com/share?"; url += "text=" + encodeURIComponent(description); url += "&url=" + encodeURIComponent(shareUrl + "?i=" + shareNumb); Share.openUrl(url); } Share.tw = tw; function openUrl(url) { window.open(url, "", "toolbar=0,status=0,width=626,height=436"); } Share.openUrl = openUrl; })(Share || (Share = {})); var TProject; (function (TProject) { var CookieSave = (function () { function CookieSave() { } CookieSave.setProperty = function (name, value) { document.cookie = (name + "=" + value); }; CookieSave.setData = function (name, value) { document.cookie = (name + "=" + JSON.stringify(value)); }; CookieSave.getProperty = function (name) { var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + "=([^;]*)")); return matches ? decodeURIComponent(matches[1]) : null; }; CookieSave.getData = function (name) { var data = this.getProperty(name); return data == null ? null : JSON.parse(data); }; return CookieSave; }()); TProject.CookieSave = CookieSave; })(TProject || (TProject = {})); var TProject; (function (TProject) { var MPoint = (function () { function MPoint(x, y) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } this._x = x; this._y = y; } MPoint.prototype.rotate = function (a, cx, cy) { if (cx === void 0) { cx = 0; } if (cy === void 0) { cy = 0; } var p = new MPoint(); p.x = (this.x - cx) * Math.cos(a) - (this.y - cy) * Math.sin(a) + cx; p.y = (this.y - cy) * Math.cos(a) + (this.x - cx) * Math.sin(a) + cy; return p; }; MPoint.prototype.rotateX = function (a, cx, cy) { if (cx === void 0) { cx = 0; } if (cy === void 0) { cy = 0; } return (this.x - cx) * Math.cos(a) - (this.y - cy) * Math.sin(a) + cx; }; MPoint.prototype.rotateY = function (a, cx, cy) { if (cx === void 0) { cx = 0; } if (cy === void 0) { cy = 0; } return (this.y - cy) * Math.cos(a) + (this.x - cx) * Math.sin(a) + cy; }; Object.defineProperty(MPoint.prototype, "x", { get: function () { return this._x; }, set: function (value) { this._x = value; }, enumerable: true, configurable: true }); Object.defineProperty(MPoint.prototype, "y", { get: function () { return this._y; }, set: function (value) { this._y = value; }, enumerable: true, configurable: true }); return MPoint; }()); TProject.MPoint = MPoint; var MPolygon = (function () { function MPolygon(data) { if (data === void 0) { data = null; } this.mirror = 1; this.setPoints(data); this.x = 0; this.y = 0; this.cx = 0; this.cy = 0; this.angle = 0; } MPolygon.prototype.setPoints = function (data) { if (data == null) { return; } this._points = []; for (var i = 0; i < data.length * 0.5; i++) { this._points.push(new MPoint(data[i * 2], data[i * 2 + 1])); } }; MPolygon.prototype.setBox = function (width, height) { var w2 = width * 0.5; var h2 = height * 0.5; this._points = []; this._points.push(new MPoint(-w2, -h2)); this._points.push(new MPoint(w2, -h2)); this._points.push(new MPoint(w2, h2)); this._points.push(new MPoint(-w2, h2)); }; Object.defineProperty(MPolygon.prototype, "error", { get: function () { return this._points == null; }, enumerable: true, configurable: true }); MPolygon.prototype.contains = function (x, y) { var lng = this._points.length; for (var i = 0; i < lng; i++) { var k = (i < (lng - 1) ? i + 1 : 0); var det = (this.pointX(k) - this.pointX(i)) * (this.pointY(k) - y) - (this.pointX(k) - x) * (this.pointY(k) - this.pointY(i)); if (det > 0) { return false; } } return true; }; MPolygon.prototype.hit = function (poly) { for (var i = 0; i < poly.length; i++) if (this.contains(poly.pointX(i), poly.pointY(i))) return true; for (var i = 0; i < this.length; i++) if (poly.contains(this.pointX(i), this.pointY(i))) return true; return false; }; MPolygon.prototype.pointX = function (ind) { return this._points[ind].rotateX(this.angle, this.cx, this.cy) * 1 + this.x * this.mirror + (this.parent ? this.parent.x : 0); }; MPolygon.prototype.pointY = function (ind) { return this._points[ind].rotateY(this.angle, this.cx, this.cy) * 1 + this.y + (this.parent ? this.parent.y : 0); }; MPolygon.prototype.debugDraw = function (g) { g.lineStyle(0.1, 0x00ff00); g.beginFill(0x00ff00, 0.3); var length = this._points.length; var pXOf = this.parent ? this.parent.x : 0; var pYOf = this.parent ? this.parent.y : 0; if (length > 1) g.moveTo(this.pointX(0) - pXOf, this.pointY(0) - pYOf); for (var i = 1; i < length; i++) { g.lineTo(this.pointX(i) - pXOf, this.pointY(i) - pYOf); } if (length > 1) g.lineTo(this.pointX(0) - pXOf, this.pointY(0) - pYOf); g.endFill(); }; Object.defineProperty(MPolygon.prototype, "length", { get: function () { return this._points.length; }, enumerable: true, configurable: true }); Object.defineProperty(MPolygon.prototype, "angle", { get: function () { if (this.mirror == 1) return this._angle; if (this._angle == 0) return 0; return Math.PI - this._angle; }, set: function (value) { this._angle = value; }, enumerable: true, configurable: true }); return MPolygon; }()); TProject.MPolygon = MPolygon; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var ParallaxSprite = (function (_super) { __extends(ParallaxSprite, _super); function ParallaxSprite(game, widthScreen, key, frame) { var _this = _super.call(this, game) || this; _this.OFFSET = 2 * TProject.Config.$; _this._sprites = []; var spr = _this.game.add.image(0, 0, key, frame, _this); _this._sprites.push(spr); _this._partWidth = spr.width; _this._partsCount = Math.max(2, Math.ceil(widthScreen / _this._partWidth)); _this._partJumpX = _this._partsCount * _this._partWidth - _this._partsCount + _this.OFFSET; for (var i = 1; i < _this._partsCount; i++) { spr = _this.game.add.image(i * _this._partWidth - _this.OFFSET, 0, key, frame, _this); _this._sprites.push(spr); } return _this; } ParallaxSprite.prototype.speedUpdate = function (speed) { if (!speed) { return; } for (var i = 0; i < this._partsCount; i++) { this._sprites[i].x -= speed; if (this._sprites[i].x < -this._partWidth) { this._sprites[i].x += this._partJumpX; console.log("JUMPO"); } } }; Object.defineProperty(ParallaxSprite.prototype, "realWidth", { get: function () { return this._partWidth - this._partsCount + this.OFFSET; }, enumerable: true, configurable: true }); Object.defineProperty(ParallaxSprite.prototype, "realHeight", { get: function () { if (!this._sprites || !this._sprites.length) { return 0; } return this._sprites[0].height; }, enumerable: true, configurable: true }); return ParallaxSprite; }(Phaser.Group)); TProject.ParallaxSprite = ParallaxSprite; })(TProject || (TProject = {})); var TProject; (function (TProject) { var ScrollOverlay = (function () { function ScrollOverlay(game) { this._overlayVisible = false; this._game = game; this._waitReload = false; if (this.isIphone) { document.body.style.background = "none"; this.setupScrollOverlay(); } else { if (game.device.desktop == false) { document.body.style.position = "fixed"; } } } Object.defineProperty(ScrollOverlay.prototype, "checkFullScreen", { get: function () { return screenfull.enabled; }, enumerable: true, configurable: true }); ScrollOverlay.prototype.toggleFullScreen = function () { screenfull.toggle(); }; ScrollOverlay.prototype.start = function () { var _this = this; if (this.isIphone == false) { return; } if (window["iphone-scroll-overlay"] != true) { return; } setTimeout(function () { _this.toggleOverlay(); }, 500); window.addEventListener("resize", this.checkScreenStatus.bind(this), false); this._game.scale.onOrientationChange.add(this.checkScreenStatus, this); document.body.addEventListener("touchend", this.checkScreenStatus.bind(this), false); }; ScrollOverlay.prototype.checkScreenStatus = function () { this.toggleOverlay(); }; ScrollOverlay.prototype.setupScrollOverlay = function () { this._scrollOverlay = document.createElement("div"); this._scrollOverlay.className = "scrollup"; this._scrollOverlay.setAttribute("id", "scrollup"); this._scrollOverlay.style.height = "1000000px"; this._scrollOverlay.style.display = "none"; this._animationContainer = document.createElement("div"); if (this._game.scale.isLandscape && this.isIphone6PlusStandardMode) { this._animationContainer.style.position = "absolute"; } this._animationContainer.className = "scrollAnimationContainer iOS_scrollup_uri"; this._animationContainer.style.visibility = "hidden"; document.body.appendChild(this._animationContainer); document.body.appendChild(this._scrollOverlay); }; ScrollOverlay.prototype.resetGamePosition = function () { if (this._removeOverlayTimeout) window.clearTimeout(this._removeOverlayTimeout); this._removeOverlayTimeout = window.setTimeout(function () { window.scrollTo(0, 0); document.getElementById("scrollup").scrollTo(0, 0); }, 300); }; ScrollOverlay.prototype.removeOverlay = function () { this.resetGamePosition(); if (this._overlayVisible) { this._scrollOverlay.style.display = "none"; this._animationContainer.style.visibility = "hidden"; this._overlayVisible = false; if (this._game.scale.isLandscape && !this.isIphone5Or5sOr5c) { document.documentElement.style.paddingBottom = ""; } window["needPreventDefault"] = true; } }; ScrollOverlay.prototype.eventPreventDefault = function (event) { event.preventDefault(); }; ScrollOverlay.prototype.showOverlay = function () { if (!this._overlayVisible) { window["needPreventDefault"] = false; this._scrollOverlay.style.display = "block"; this._animationContainer.style.visibility = "visible"; this._overlayVisible = true; } }; ScrollOverlay.prototype.isFullscreen = function () { var a = this.getRealScreenSize(); return a.height === window.innerHeight || window.innerHeight / a.height >= 0.9; }; ScrollOverlay.prototype.getRealScreenSize = function () { var d; var f; if (this._game.device.desktop) { return this.getInnerScreenSize(); } if (this._game.scale.isPortrait) { d = Math.min(window.screen.width, window.screen.height); f = Math.max(window.screen.width, window.screen.height); } else { d = Math.max(window.screen.width, window.screen.height); f = Math.min(window.screen.width, window.screen.height); } return { width: d, height: f }; }; ScrollOverlay.prototype.getInnerScreenSize = function () { return { width: window.innerWidth, height: window.innerHeight }; }; ScrollOverlay.prototype.toggleOverlay = function () { document.documentElement.style.paddingBottom = "79px"; if (this._game.scale.isLandscape && this.isIphone6PlusStandardMode) { document.documentElement.style.paddingBottom = ""; } if (this.isFullscreen()) { this.removeOverlay(); } else { this.showOverlay(); } }; Object.defineProperty(ScrollOverlay.prototype, "isIphone6PlusStandardMode", { get: function () { if (this.isIphone) { return this.iPhoneVersion() == "6+"; } return false; }, enumerable: true, configurable: true }); Object.defineProperty(ScrollOverlay.prototype, "isIphone5Or5sOr5c", { get: function () { if (this.isIphone) { return this.iPhoneVersion() == "5"; } return false; }, enumerable: true, configurable: true }); ScrollOverlay.prototype.iPhoneVersion = function () { var iHeight = window.screen.height; var iWidth = window.screen.width; if (iWidth === 320 && iHeight === 480) { return "4"; } else if (iWidth === 375 && iHeight === 667) { return "6"; } else if (iWidth === 414 && iHeight === 736) { return "6+"; } else if (iWidth === 320 && iHeight === 568) { return "5"; } else if (iHeight <= 480) { return "2-3"; } return "none"; }; Object.defineProperty(ScrollOverlay.prototype, "isIphone", { get: function () { return (!!navigator.userAgent.match(/iPhone/i) || this._game.device.iPhone); }, enumerable: true, configurable: true }); ScrollOverlay.prototype.initLockScreen = function (portrait, paused) { if (paused === void 0) { paused = false; } window.addEventListener("resize", this._checkScreenStatus.bind(this), false); this._game.scale.onOrientationChange.add(this._checkScreenStatus, this); var lock = document.createElement("div"); lock.className = "lockscren"; lock.setAttribute("id", "lockscren"); lock.style.height = "1000000px"; lock.style.display = "none"; var lockIcon = document.createElement("div"); lockIcon.className = portrait ? "lockIconContainer PORT_lock_uri" : "lockIconContainer LAND_lock_uri"; lockIcon.style.visibility = "hidden"; window["-lockscreen"] = { portrait: portrait, lock: lock, icon: lockIcon, paused: paused }; document.body.appendChild(lock); document.body.appendChild(lockIcon); this._checkScreenStatus(); }; ScrollOverlay.prototype._checkScreenStatus = function () { var isPort = this._game.scale.isPortrait; if (!!window["-lockscreen"] && isPort == window["-lockscreen"].portrait) { window["-lockscreen"].lock.style.display = "block"; window["-lockscreen"].icon.style.visibility = "visible"; } else { window["-lockscreen"].lock.style.display = "none"; window["-lockscreen"].icon.style.visibility = "hidden"; } }; return ScrollOverlay; }()); TProject.ScrollOverlay = ScrollOverlay; })(TProject || (TProject = {})); var TProject; (function (TProject) { var SoundMixer = (function () { function SoundMixer() { } SoundMixer.init = function (game, atlasName) { if (atlasName === void 0) { atlasName = ""; } SoundMixer._game = game; }; SoundMixer.play = function (key, volume, bgMusic, loop) { if (volume === void 0) { volume = 0.3; } if (bgMusic === void 0) { bgMusic = false; } if (loop === void 0) { loop = false; } if (this._game.paused || this._game.sound.volume == 0 && !bgMusic) { return; } if (SoundMixer.disableMusic) { if (bgMusic) { SoundMixer._bgKey = key; SoundMixer._bgVolume = volume; return; } } if (bgMusic) { if (SoundMixer._bg) { if (SoundMixer._bgKey == key && SoundMixer._bg.isPlaying) { return; } else { SoundMixer._bg.stop(); } } SoundMixer._bgKey = key; SoundMixer._bgVolume = volume; SoundMixer._bg = this._game.add.audio(key, volume, true).play(); SoundMixer._bg.allowMultiple = true; SoundMixer._bg.loop = true; return SoundMixer._bg; } else { if (SoundMixer.playSFX) { var s = void 0; s = this._game.add.audio(key, volume, loop).play(); s.allowMultiple = true; s.loop = loop; return s; } } }; SoundMixer.bgStop = function () { if (SoundMixer._bg) { SoundMixer._bg.stop(); } }; SoundMixer.on = function () { if (SoundMixer._bgKey) { SoundMixer.play(SoundMixer._bgKey, SoundMixer._bgVolume, true, true); } }; SoundMixer.off = function () { }; SoundMixer.disableMusic = false; SoundMixer.playSFX = true; return SoundMixer; }()); TProject.SoundMixer = SoundMixer; })(TProject || (TProject = {})); var TProject; (function (TProject) { var Config = (function () { function Config() { this.VOL_MASTER = 1; } Object.defineProperty(Config, "assetsPrefix", { get: function () { return Config.__PATH_IMAGES + "/"; }, enumerable: true, configurable: true }); Config.init = function (width, height, initFBAPI, initVKAPI) { if (initFBAPI === void 0) { initFBAPI = true; } if (initVKAPI === void 0) { initVKAPI = true; } this.DEF_WIDTH = width; this.DEF_HEIGHT = height; var realWindowWidth = Math.max(window.innerWidth, window.innerHeight); var realWindowHeight = Math.min(window.innerWidth, window.innerHeight); this.RATIO = this.scaleFactor(realWindowWidth, realWindowHeight, this.DEF_WIDTH, this.DEF_HEIGHT); var scales = [0.5, 0.75, 1.0]; var prefix = ["sd", "md", "hd"]; var ind = this.findBestScale(this.RATIO, scales); this.ATLAS_SCALE = scales[ind]; this.__PATH_IMAGES = prefix[ind]; }; Config.scaleFactor = function (width, height, defWidth, defHeight) { return Math.min(width / defWidth, height / defHeight); }; Config.findBestScale = function (ratio, defscale) { for (var i = 0; i < defscale.length; i++) { if (ratio <= defscale[i]) { return i; } } return defscale.length - 1; }; Object.defineProperty(Config, "width", { get: function () { return this.DEF_WIDTH * this.$; }, enumerable: true, configurable: true }); Object.defineProperty(Config, "height", { get: function () { return this.DEF_HEIGHT * this.$; }, enumerable: true, configurable: true }); Object.defineProperty(Config, "$", { get: function () { return this.ATLAS_SCALE; }, enumerable: true, configurable: true }); Config.DEF_WIDTH = 1920; Config.DEF_HEIGHT = 1080; return Config; }()); TProject.Config = Config; })(TProject || (TProject = {})); var TProject; (function (TProject) { var Core = (function () { function Core() { } Core.init = function (width, height, bannerMode) { this.showDebugHeader(bannerMode == null ? 1 : bannerMode); this.globalEvents = new EventEmitter(); this.defaultWidth = width; this.defaultHeight = height; this.centerX = width * 0.5; this.centerY = height * 0.5; }; Core.begin = function (game, disabledMouse) { this.game = game; this.game.input.maxPointers = 1; this.game.stage.disableVisibilityChange = true; this.game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE; this.game.scale.pageAlignHorizontally = true; this.game.scale.pageAlignVertically = true; this.game.input.touch.preventDefault = false; if (disabledMouse == true) { if (this.game.device.desktop) { this.game.input.mouse.enabled = true; } else { this.game.input.mouse.enabled = false; } } window.addEventListener("resize", this.checkScreenStatus.bind(this), false); this.game.scale.onOrientationChange.add(this.checkScreenStatus, this); this.checkScreenStatus(); }; Core.checkScreenStatus = function () { if (this._fullWidth == Core.getInnerWidth() && this._fullHeight == Core.getInnerHeight()) { return; } this.changeScale(this.game); this.globalEvents.emit("changeOrientationAndResize"); }; Core.changeScale = function (game) { this._fullWidth = this.width = Core.getInnerWidth(); this._fullHeight = this.height = Core.getInnerHeight(); var dw = this.width; var dh = this.height; if (this.isLandscape != this.isDefaultLandscape) { dw = this.height; dh = this.width; } var scale = 1; scale = Math.min(dw / this.defaultWidth, dh / this.defaultHeight); this.bgModeScale = Math.max(this.width / this.defaultWidth, this.height / this.defaultHeight) / scale; this.width /= scale; this.height /= scale; game.scale.setUserScale(scale, scale, 0, 0); game.scale.setGameSize(this.width, this.height); game.world.setBounds(0, 0, this.width, this.height); game.scale.refresh(); }; Core.getInnerWidth = function () { var fnc = window["customClientWidth"]; if (typeof fnc === "function") { return fnc(); } return window.innerWidth; }; Core.getInnerHeight = function () { var fnc = window["customClientHeight"]; if (typeof fnc === "function") { return fnc(); } return window.innerHeight; }; Core.showDebugHeader = function (mode) { var email; switch (mode) { case 0: return; case 1: email = "o.selyukov@gmail.com"; break; case 2: email = " "; break; } if (navigator.userAgent.search(/Chrome/) > -1) { var args = [ "%c Olphabet Core v" + this.VERSION + " | " + "" + email + " ", "color: #ffffff; background: #757B96" ]; } else { } }; Object.defineProperty(Core, "isDesktop", { get: function () { return this.game.device.desktop; }, enumerable: true, configurable: true }); Object.defineProperty(Core, "isLandscape", { get: function () { return this.height < this.width; }, enumerable: true, configurable: true }); Object.defineProperty(Core, "isDefaultLandscape", { get: function () { return this.defaultHeight < this.defaultWidth; }, enumerable: true, configurable: true }); Core.VERSION = 0.31; Core.bgModeScale = 1; return Core; }()); TProject.Core = Core; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OButton = (function (_super) { __extends(OButton, _super); function OButton(key, frame, cb) { if (cb === void 0) { cb = null; } var _this = this; var up = null; var over = null; var down = null; if (frame.length > 0) { up = frame[0]; if (frame.length > 1) { over = frame[1]; if (frame.length > 2) down = frame[2]; else down = frame[0]; } else { over = frame[0]; down = frame[0]; } } _this = _super.call(this, TProject.Core.game, 0, 0, key, null, null, over, up, down, null) || this; _this._framesString = [up, over, down]; _this.soundOver = "over"; _this.soundDown = "click"; _this.anchor.setTo(0.5); _this._cb = cb; _this._deltaScale = 0.1; _this._defaultScale = 1.0; _this._isDown = false; _this._isOver = false; _this.hitArea = new PIXI.Rectangle(-_this.width / 2, -_this.height / 2, _this.width, _this.height); _this.onInputOver.add(_this.over, _this); _this.onInputOut.add(_this.out, _this); _this.onInputDown.add(_this.down, _this); _this.onInputUp.add(_this.up, _this); return _this; } OButton.prototype.setCBContext = function (cntx) { this._cntxt = cntx; }; OButton.prototype.setAnimationScale = function (delta, defaultScale) { if (delta === void 0) { delta = 0; } if (defaultScale === void 0) { defaultScale = 1; } this._deltaScale = delta; this._defaultScale = defaultScale; }; OButton.prototype.setNewFrames = function (frame) { var up = null; var over = null; var down = null; if (frame.length > 0) { up = frame[0]; if (frame.length > 1) { over = frame[1]; if (frame.length > 2) down = frame[2]; else down = frame[0]; } else { over = frame[0]; down = frame[0]; } } this._framesString = [up, over, down]; this.setFrames(over, up, down); }; OButton.prototype.over = function () { if (!this._isDown) { this.scale.set(this._defaultScale + this._deltaScale); } this._isOver = true; }; OButton.prototype.out = function () { if (!this._isDown) { this.scale.set(this._defaultScale); } this._isOver = false; }; OButton.prototype.up = function () { if (!this._isDown) { return; } this.scale.set(this._isOver ? this._defaultScale + this._deltaScale : this._defaultScale); var tap = (this.game.device.desktop ? this._isOver : this.input.pointerOver()); if (this._isOver) { this.frameName = this._framesString[1]; } else { if (tap) { this.frameName = this._framesString[0]; } } this._isDown = false; if (tap && this._cb != null) { if (this._cntxt) this._cb.bind(this._cntxt)(); else { if (this._cb()) { return; } } this.frameName = this._framesString[0]; } else { if (tap == false) this.scale.set(this._defaultScale); } }; OButton.prototype.down = function () { if (this._isDown) { return; } this.scale.set(this._defaultScale - this._deltaScale); this._isDown = true; }; OButton.prototype.deleteFromParent = function () { if (this.parent) { this.parent.removeChild(this); } this.onInputOver.remove(this.over, this); this.onInputOut.remove(this.out, this); this.onInputDown.remove(this.down, this); this.onInputUp.remove(this.up, this); }; Object.defineProperty(OButton.prototype, "enabled", { set: function (value) { this.inputEnabled = value; if (!value) { this.frameName = this._framesString[0]; this.scale.set(this._defaultScale); } }, enumerable: true, configurable: true }); return OButton; }(Phaser.Button)); TProject.OButton = OButton; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OButtonCheck = (function (_super) { __extends(OButtonCheck, _super); function OButtonCheck(key, frameOn, frameOff, cb) { if (cb === void 0) { cb = null; } var _this = this; var upOn = null; var overOn = null; var downOn = null; var upOff = null; var overOff = null; var downOff = null; if (frameOn.length > 0) { upOn = frameOn[0]; if (frameOn.length > 1) { overOn = frameOn[1]; if (frameOn.length > 2) downOn = frameOn[2]; else downOn = frameOn[0]; } else { overOn = frameOn[0]; downOn = frameOn[0]; } } if (frameOff.length > 0) { upOff = frameOff[0]; if (frameOff.length > 1) { overOff = frameOff[1]; if (frameOff.length > 2) downOff = frameOff[2]; else downOff = frameOff[0]; } else { overOff = frameOff[0]; downOff = frameOff[0]; } } _this = _super.call(this, TProject.Core.game, 0, 0, key, null, null, overOn, upOn, downOn, null) || this; _this._framesString = [upOn, overOn, downOn, upOff, overOff, downOff]; _this._check = true; _this.soundOver = "over"; _this.soundDown = "click"; _this.anchor.setTo(0.5); _this._cb = cb; _this._deltaScale = 0.1; _this._defaultScale = 1.0; _this._isDown = false; _this._isOver = false; _this.onInputOver.add(_this.over, _this); _this.onInputOut.add(_this.out, _this); _this.onInputDown.add(_this.down, _this); _this.onInputUp.add(_this.up, _this); return _this; } OButtonCheck.prototype.setCheck = function (value) { if (this._check == value) { return; } this._check = value; var delta = 0; if (!value) { delta = 3; } this.setFrames(this._framesString[delta + 1], this._framesString[delta], this._framesString[delta + 2], this._framesString[delta]); }; Object.defineProperty(OButtonCheck.prototype, "check", { get: function () { return this._check; }, enumerable: true, configurable: true }); OButtonCheck.prototype.setCBContext = function (cntx) { this._cntxt = cntx; }; OButtonCheck.prototype.setAnimationScale = function (delta, defaultScale) { if (delta === void 0) { delta = 0; } if (defaultScale === void 0) { defaultScale = 1; } this._deltaScale = delta; this._defaultScale = defaultScale; }; OButtonCheck.prototype.over = function () { if (!this._isDown) { this.scale.set(this._defaultScale + this._deltaScale); } this._isOver = true; }; OButtonCheck.prototype.out = function () { if (!this._isDown) { this.scale.set(this._defaultScale); } this._isOver = false; }; OButtonCheck.prototype.up = function () { if (!this._isDown) { return; } this.scale.set(this._isOver ? this._defaultScale + this._deltaScale : this._defaultScale); var tap = (this.game.device.desktop ? this._isOver : this.input.pointerOver()); if (this._isOver) { this.frameName = this._framesString[1 + (this._check ? 0 : 3)]; } else { if (tap) { this.frameName = this._framesString[(this._check ? 0 : 3)]; } } this._isDown = false; if (tap && this._cb != null) { this.setCheck(!this.check); if (this._cntxt) this._cb.bind(this._cntxt)(); else this._cb(); this.frameName = this._framesString[(this._check ? 0 : 3)]; } else { if (tap == false) this.scale.set(this._defaultScale); } }; OButtonCheck.prototype.down = function () { if (this._isDown) { return; } this.scale.set(this._defaultScale - this._deltaScale); this._isDown = true; }; OButtonCheck.prototype.deleteFromParent = function () { if (this.parent) { this.parent.removeChild(this); } this.onInputOver.remove(this.over, this); this.onInputOut.remove(this.out, this); this.onInputDown.remove(this.down, this); this.onInputUp.remove(this.up, this); }; Object.defineProperty(OButtonCheck.prototype, "enabled", { set: function (value) { this.inputEnabled = value; if (!value) { this.frameName = this._framesString[(this._check ? 0 : 3)]; this.scale.set(this._defaultScale); } }, enumerable: true, configurable: true }); return OButtonCheck; }(Phaser.Button)); TProject.OButtonCheck = OButtonCheck; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OGroup = (function (_super) { __extends(OGroup, _super); function OGroup(x, y) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } var _this = _super.call(this, TProject.Core.game) || this; _this.x = x; _this.y = y; _this._landscapeScaleX = 1.0; _this._portretScaleX = 1.0; _this._landscapeScaleY = 1.0; _this._portretScaleY = 1.0; _this._bgMode = false; _this._testMaskMode = false; _this._landscapeVisible = true; _this._portretVisible = true; _this._screenScreenCompress = false; _this._customMask = null; if (TProject.Core.isDefaultLandscape) { _this._landscapeX = x / TProject.Core.defaultWidth; _this._landscapeY = y / TProject.Core.defaultHeight; _this._portretX = _this._landscapeX; _this._portretY = _this._landscapeY; } else { _this._portretX = x / TProject.Core.defaultWidth; _this._portretY = y / TProject.Core.defaultHeight; _this._landscapeX = _this._portretX; _this._landscapeY = _this._portretY; } _this._landscapeLeftOffset = null; _this._portretLeftOffset = null; _this._landscapeTopOffset = null; _this._portretTopOffset = null; _this._landscapeRightffset = null; _this._portretRightOffset = null; _this._landscapeBottomOffset = null; _this._portretBottomOffset = null; _this.blocked = false; _this.changeOrientation(); TProject.Core.globalEvents.on("changeOrientationAndResize", _this.changeOrientation.bind(_this), false); return _this; } OGroup.prototype.update = function () { }; OGroup.prototype.add = function (child) { this.addChild(child); }; OGroup.prototype.otherXY = function (x, y) { if (TProject.Core.isDefaultLandscape) { this._portretX = x / TProject.Core.defaultHeight; this._portretY = y / TProject.Core.defaultWidth; } else { this._landscapeX = x / TProject.Core.defaultHeight; this._landscapeY = y / TProject.Core.defaultWidth; } return this; }; OGroup.prototype.myLeftOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OGroup.prototype.otherLeftOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OGroup.prototype.myRightOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OGroup.prototype.otherRightOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OGroup.prototype.myTopOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OGroup.prototype.otherTopOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OGroup.prototype.myBottomOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OGroup.prototype.otherBottomOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OGroup.prototype.end = function () { this.changeOrientation(); return this; }; OGroup.prototype.myScale = function (valueX, valueY) { if (TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; OGroup.prototype.otherScale = function (valueX, valueY) { if (!TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; Object.defineProperty(OGroup.prototype, "currentScale", { get: function () { if (TProject.Core.isLandscape) { return { x: this._landscapeScaleX, y: this._landscapeScaleY }; } else { return { x: this._portretScaleX, y: this._portretScaleY }; } }, enumerable: true, configurable: true }); OGroup.prototype.myVisible = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OGroup.prototype.otherVisible = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OGroup.prototype.enabledBgMode = function () { this._bgMode = true; return this; }; OGroup.prototype.enabledMask = function (offsetX, offsetY, width, height, testMode) { this._customMask = new Phaser.Graphics(this.game, 0, 0); this._customMask.beginFill(0xff0000, 0.5); var ww = width ? width : TProject.Core.defaultWidth; var hh = height ? height : TProject.Core.defaultHeight; this._customMask.drawRect(-ww * 0.5 + (offsetX ? offsetX : 0), -hh * 0.5 + (offsetY ? offsetY : 0), ww, hh); this._customMask.endFill(); if (testMode != true) { this.mask = this._customMask; this.addChild(this._customMask); } else { this._testMaskMode = true; this._customMask.x = this.x; this._customMask.y = this.y; this.game.world.addChild(this._customMask); } return this; }; OGroup.prototype.changeOrientation = function () { if (this.blocked) { return; } var fixedToCamera = this.fixedToCamera; this.fixedToCamera = false; var varscaleX = 1; var varscaleY = 1; if (this._bgMode) { varscaleX = varscaleY = TProject.Core.bgModeScale; } if (TProject.Core.isLandscape) { this.x = (TProject.Core.width * this._landscapeX); this.y = (TProject.Core.height * this._landscapeY); this.visible = this._landscapeVisible; varscaleX *= this._landscapeScaleX; varscaleY *= this._landscapeScaleY; this.applyLandscapeOffsets(); } else { this.x = (TProject.Core.width * this._portretX); this.y = (TProject.Core.height * this._portretY); this.visible = this._portretVisible; varscaleX *= this._portretScaleX; varscaleY *= this._portretScaleY; this.applyPortretOffsets(); } if (this._screenScreenCompress) { varscaleX = varscaleY = Math.min(TProject.Core.width / TProject.Core.defaultWidth, TProject.Core.height / TProject.Core.defaultHeight); } this.scale.set(varscaleX, varscaleY); if (this._testMaskMode) { this._customMask.x = this.x; this._customMask.y = this.y; } if (fixedToCamera) { this.fixedToCamera = true; } }; OGroup.prototype.applyLandscapeOffsets = function () { if (this._landscapeLeftOffset != null) { this.x = this._landscapeLeftOffset; } if (this._landscapeRightffset != null) { this.x = TProject.Core.width - this._landscapeRightffset; } if (this._landscapeTopOffset != null) { this.y = this._landscapeTopOffset; } if (this._landscapeBottomOffset != null) { this.y = TProject.Core.height - this._landscapeBottomOffset; } }; OGroup.prototype.applyPortretOffsets = function () { if (this._portretLeftOffset != null) { this.x = this._portretLeftOffset; } if (this._portretRightOffset != null) { this.x = TProject.Core.width - this._portretRightOffset; } if (this._portretTopOffset != null) { this.y = this._portretTopOffset; } if (this._portretBottomOffset != null) { this.y = TProject.Core.height - this._portretBottomOffset; } }; return OGroup; }(Phaser.Group)); TProject.OGroup = OGroup; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OImage = (function (_super) { __extends(OImage, _super); function OImage(x, y, key, frame) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } var _this = _super.call(this, TProject.Core.game, 0.0, 0.0, key, frame) || this; _this.anchor.set(0.5); _this._landscapeScaleX = 1.0; _this._portretScaleX = 1.0; _this._landscapeScaleY = 1.0; _this._portretScaleY = 1.0; _this._bgMode = false; _this._testMaskMode = false; _this._landscapeVisible = true; _this._portretVisible = true; _this._screenScreenCompress = false; _this._customMask = null; if (TProject.Core.isDefaultLandscape) { _this._landscapeX = x / TProject.Core.defaultWidth; _this._landscapeY = y / TProject.Core.defaultHeight; _this._portretX = _this._landscapeX; _this._portretY = _this._landscapeY; } else { _this._portretX = x / TProject.Core.defaultWidth; _this._portretY = y / TProject.Core.defaultHeight; _this._landscapeX = _this._portretX; _this._landscapeY = _this._portretY; } _this._landscapeLeftOffset = null; _this._portretLeftOffset = null; _this._landscapeTopOffset = null; _this._portretTopOffset = null; _this._landscapeRightffset = null; _this._portretRightOffset = null; _this._landscapeBottomOffset = null; _this._portretBottomOffset = null; _this.blocked = false; _this.changeOrientation(); TProject.Core.globalEvents.on("changeOrientationAndResize", _this.changeOrientation.bind(_this), false); return _this; } OImage.prototype.add = function (child) { this.addChild(child); }; OImage.prototype.otherXY = function (x, y) { if (TProject.Core.isDefaultLandscape) { this._portretX = x / TProject.Core.defaultHeight; this._portretY = y / TProject.Core.defaultWidth; } else { this._landscapeX = x / TProject.Core.defaultHeight; this._landscapeY = y / TProject.Core.defaultWidth; } return this; }; OImage.prototype.myLeftOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OImage.prototype.otherLeftOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OImage.prototype.myRightOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OImage.prototype.otherRightOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OImage.prototype.myTopOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OImage.prototype.otherTopOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OImage.prototype.myBottomOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OImage.prototype.otherBottomOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OImage.prototype.end = function () { this.changeOrientation(); return this; }; OImage.prototype.myScale = function (valueX, valueY) { if (TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; OImage.prototype.otherScale = function (valueX, valueY) { if (!TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; Object.defineProperty(OImage.prototype, "currentScale", { get: function () { if (TProject.Core.isLandscape) { return { x: this._landscapeScaleX, y: this._landscapeScaleY }; } else { return { x: this._portretScaleX, y: this._portretScaleY }; } }, enumerable: true, configurable: true }); OImage.prototype.myVisible = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OImage.prototype.otherVisible = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OImage.prototype.enabledBgMode = function () { this._bgMode = true; return this; }; OImage.prototype.enabledMask = function (offsetX, offsetY, width, height, testMode) { this._customMask = new Phaser.Graphics(this.game, 0, 0); this._customMask.beginFill(0xff0000, 0.5); var ww = width ? width : TProject.Core.defaultWidth; var hh = height ? height : TProject.Core.defaultHeight; this._customMask.drawRect(-ww * 0.5 + (offsetX ? offsetX : 0), -hh * 0.5 + (offsetY ? offsetY : 0), ww, hh); this._customMask.endFill(); if (testMode != true) { this.mask = this._customMask; this.addChild(this._customMask); } else { this._testMaskMode = true; this._customMask.x = this.x; this._customMask.y = this.y; this.game.world.addChild(this._customMask); } return this; }; OImage.prototype.changeOrientation = function () { if (this.blocked) { return; } var fixedToCamera = this.fixedToCamera; this.fixedToCamera = false; var varscaleX = 1; var varscaleY = 1; if (this._bgMode) { varscaleX = varscaleY = TProject.Core.bgModeScale; } if (TProject.Core.isLandscape) { this.x = (TProject.Core.width * this._landscapeX); this.y = (TProject.Core.height * this._landscapeY); this.visible = this._landscapeVisible; varscaleX *= this._landscapeScaleX; varscaleY *= this._landscapeScaleY; this.applyLandscapeOffsets(); } else { this.x = (TProject.Core.width * this._portretX); this.y = (TProject.Core.height * this._portretY); this.visible = this._portretVisible; varscaleX *= this._portretScaleX; varscaleY *= this._portretScaleY; this.applyPortretOffsets(); } if (this._screenScreenCompress) { varscaleX = varscaleY = Math.min(TProject.Core.width / TProject.Core.defaultWidth, TProject.Core.height / TProject.Core.defaultHeight); } this.scale.set(varscaleX, varscaleY); if (this._testMaskMode) { this._customMask.x = this.x; this._customMask.y = this.y; } if (fixedToCamera) { this.fixedToCamera = true; } }; OImage.prototype.applyLandscapeOffsets = function () { if (this._landscapeLeftOffset != null) { this.x = this._landscapeLeftOffset; } if (this._landscapeRightffset != null) { this.x = TProject.Core.width - this._landscapeRightffset; } if (this._landscapeTopOffset != null) { this.y = this._landscapeTopOffset; } if (this._landscapeBottomOffset != null) { this.y = TProject.Core.height - this._landscapeBottomOffset; } }; OImage.prototype.applyPortretOffsets = function () { if (this._portretLeftOffset != null) { this.x = this._portretLeftOffset; } if (this._portretRightOffset != null) { this.x = TProject.Core.width - this._portretRightOffset; } if (this._portretTopOffset != null) { this.y = this._portretTopOffset; } if (this._portretBottomOffset != null) { this.y = TProject.Core.height - this._portretBottomOffset; } }; return OImage; }(Phaser.Image)); TProject.OImage = OImage; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OSprite = (function (_super) { __extends(OSprite, _super); function OSprite(x, y, key, frame) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } var _this = _super.call(this, TProject.Core.game, 0.0, 0.0, key, frame) || this; _this.anchor.set(0.5); _this._landscapeScaleX = 1.0; _this._portretScaleX = 1.0; _this._landscapeScaleY = 1.0; _this._portretScaleY = 1.0; _this._bgMode = false; _this._testMaskMode = false; _this._landscapeVisible = true; _this._portretVisible = true; _this._screenScreenCompress = false; _this._customMask = null; if (TProject.Core.isDefaultLandscape) { _this._landscapeX = x / TProject.Core.defaultWidth; _this._landscapeY = y / TProject.Core.defaultHeight; _this._portretX = _this._landscapeX; _this._portretY = _this._landscapeY; } else { _this._portretX = x / TProject.Core.defaultWidth; _this._portretY = y / TProject.Core.defaultHeight; _this._landscapeX = _this._portretX; _this._landscapeY = _this._portretY; } _this._landscapeLeftOffset = null; _this._portretLeftOffset = null; _this._landscapeTopOffset = null; _this._portretTopOffset = null; _this._landscapeRightffset = null; _this._portretRightOffset = null; _this._landscapeBottomOffset = null; _this._portretBottomOffset = null; _this.blocked = false; _this.changeOrientation(); TProject.Core.globalEvents.on("changeOrientationAndResize", _this.changeOrientation.bind(_this), false); return _this; } OSprite.prototype.add = function (child) { this.addChild(child); }; OSprite.prototype.otherXY = function (x, y) { if (TProject.Core.isDefaultLandscape) { this._portretX = x / TProject.Core.defaultHeight; this._portretY = y / TProject.Core.defaultWidth; } else { this._landscapeX = x / TProject.Core.defaultHeight; this._landscapeY = y / TProject.Core.defaultWidth; } return this; }; OSprite.prototype.myLeftOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OSprite.prototype.otherLeftOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeLeftOffset = value; } else { this._portretLeftOffset = value; } return this; }; OSprite.prototype.myRightOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OSprite.prototype.otherRightOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeRightffset = value; } else { this._portretRightOffset = value; } return this; }; OSprite.prototype.myTopOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OSprite.prototype.otherTopOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeTopOffset = value; } else { this._portretTopOffset = value; } return this; }; OSprite.prototype.myBottomOffset = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OSprite.prototype.otherBottomOffset = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeBottomOffset = value; } else { this._portretBottomOffset = value; } return this; }; OSprite.prototype.end = function () { this.changeOrientation(); return this; }; OSprite.prototype.myScale = function (valueX, valueY) { if (TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; OSprite.prototype.otherScale = function (valueX, valueY) { if (!TProject.Core.isDefaultLandscape) { this._landscapeScaleX = valueX; this._landscapeScaleY = valueY ? valueY : valueX; } else { this._portretScaleX = valueX; this._portretScaleY = valueY ? valueY : valueX; } return this; }; Object.defineProperty(OSprite.prototype, "currentScale", { get: function () { if (TProject.Core.isLandscape) { return { x: this._landscapeScaleX, y: this._landscapeScaleY }; } else { return { x: this._portretScaleX, y: this._portretScaleY }; } }, enumerable: true, configurable: true }); OSprite.prototype.myVisible = function (value) { if (TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OSprite.prototype.otherVisible = function (value) { if (!TProject.Core.isDefaultLandscape) { this._landscapeVisible = value; } else { this._portretVisible = value; } return this; }; OSprite.prototype.enabledBgMode = function () { this._bgMode = true; return this; }; OSprite.prototype.enabledMask = function (offsetX, offsetY, width, height, testMode) { this._customMask = new Phaser.Graphics(this.game, 0, 0); this._customMask.beginFill(0xff0000, 0.5); var ww = width ? width : TProject.Core.defaultWidth; var hh = height ? height : TProject.Core.defaultHeight; this._customMask.drawRect(-ww * 0.5 + (offsetX ? offsetX : 0), -hh * 0.5 + (offsetY ? offsetY : 0), ww, hh); this._customMask.endFill(); if (testMode != true) { this.mask = this._customMask; this.addChild(this._customMask); } else { this._testMaskMode = true; this._customMask.x = this.x; this._customMask.y = this.y; this.game.world.addChild(this._customMask); } return this; }; OSprite.prototype.changeOrientation = function () { if (this.blocked) { return; } var fixedToCamera = this.fixedToCamera; this.fixedToCamera = false; var varscaleX = 1; var varscaleY = 1; if (this._bgMode) { varscaleX = varscaleY = TProject.Core.bgModeScale; } if (TProject.Core.isLandscape) { this.x = (TProject.Core.width * this._landscapeX); this.y = (TProject.Core.height * this._landscapeY); this.visible = this._landscapeVisible; varscaleX *= this._landscapeScaleX; varscaleY *= this._landscapeScaleY; this.applyLandscapeOffsets(); } else { this.x = (TProject.Core.width * this._portretX); this.y = (TProject.Core.height * this._portretY); this.visible = this._portretVisible; varscaleX *= this._portretScaleX; varscaleY *= this._portretScaleY; this.applyPortretOffsets(); } if (this._screenScreenCompress) { varscaleX = varscaleY = Math.min(TProject.Core.width / TProject.Core.defaultWidth, TProject.Core.height / TProject.Core.defaultHeight); } this.scale.set(varscaleX, varscaleY); if (this._testMaskMode) { this._customMask.x = this.x; this._customMask.y = this.y; } if (fixedToCamera) { this.fixedToCamera = true; } }; OSprite.prototype.applyLandscapeOffsets = function () { if (this._landscapeLeftOffset != null) { this.x = this._landscapeLeftOffset; } if (this._landscapeRightffset != null) { this.x = TProject.Core.width - this._landscapeRightffset; } if (this._landscapeTopOffset != null) { this.y = this._landscapeTopOffset; } if (this._landscapeBottomOffset != null) { this.y = TProject.Core.height - this._landscapeBottomOffset; } }; OSprite.prototype.applyPortretOffsets = function () { if (this._portretLeftOffset != null) { this.x = this._portretLeftOffset; } if (this._portretRightOffset != null) { this.x = TProject.Core.width - this._portretRightOffset; } if (this._portretTopOffset != null) { this.y = this._portretTopOffset; } if (this._portretBottomOffset != null) { this.y = TProject.Core.height - this._portretBottomOffset; } }; return OSprite; }(Phaser.Sprite)); TProject.OSprite = OSprite; })(TProject || (TProject = {})); ; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var OState = (function (_super) { __extends(OState, _super); function OState(changeOrientation) { if (changeOrientation === void 0) { changeOrientation = false; } var _this = _super.call(this) || this; if (changeOrientation) { TProject.Core.globalEvents.on("changeOrientationAndResize", _this.changeOrientation.bind(_this), false); _this.changeOrientation(); } return _this; } OState.prototype.changeOrientation = function () { if (TProject.Core.isLandscape) { this.onLandscape(); } else { this.onPortret(); } }; OState.prototype.onPortret = function () { }; OState.prototype.onLandscape = function () { }; return OState; }(Phaser.State)); TProject.OState = OState; })(TProject || (TProject = {})); ; var TProject; (function (TProject) { var Main = (function () { function Main() { this.game = null; TProject.Config.init(1920, 1080); TProject.Core.init(TProject.Config.width, TProject.Config.height); var md = new MobileDetect(window.navigator.userAgent); var canvas = (md.mobile() && md.os() != "iOS"); this.game = new Phaser.Game({ width: TProject.Core.defaultWidth, height: TProject.Core.defaultHeight, renderer: canvas ? Phaser.CANVAS : Phaser.AUTO, parent: "game_container", resolution: 1, transparent: false, antialias: true, physicsConfig: null, backgroundColor: 0x000000, preserveDrawingBuffer: true }); this.game.state.add("Boot", TProject.Boot, true); this.game.state.add("Preloader", TProject.Preloader); this.game.state.add("MainMenu", TProject.MainMenu); this.game.state.add("BaseGame", TProject.BaseGame); } return Main; }()); TProject.Main = Main; })(TProject || (TProject = {})); window.onload = function () { var game = new TProject.Main(); window["needPreventDefault"] = true; setTimeout("window.scrollTo(0, 1)", 10); document.addEventListener("touchmove", function (event) { if (window["needPreventDefault"] == true) { event.preventDefault(); } }, false); }; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var GameModeType; (function (GameModeType) { GameModeType["NONE"] = ""; GameModeType["HOME"] = "home"; GameModeType["OFFICE"] = "office"; GameModeType["WEDDING"] = "wedding"; })(GameModeType = TProject.GameModeType || (TProject.GameModeType = {})); ; var BaseGame = (function (_super) { __extends(BaseGame, _super); function BaseGame() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.LINE_HEIGHT = 218; _this.START_LINE = 1; _this.START_X = 250; _this.LINE_CHANGE_TIME = 200; _this.GRAVITY = 2 * TProject.Config.$; _this.GRAV_MOD = 1; _this.JUMP_SPEED = -30 * TProject.Config.$; _this.SCROLL_SPEED = 2; _this.START_ACCELERATION = 7; _this.LIMIT_LEVEL_ACCELERATION = 16.0; _this.MAXIMUM_NUMBER_OF_LIVES = 10; _this.MINIMUM_VOLUME_WHEN_GAME_IS_PAUSED = 0.4; _this._isPauseGame = false; _this._isGameOver = false; _this.GAMEOBJECT_CELL_WIDTH = 200 * TProject.Config.$; _this._lastPositionGameObject = -1; _this._isBooster = false; _this.MAXIMUM_LEVEL_ACCELERATION_BOOST = 30; _this._boostSpeed = 0; _this._$boostAlpha = 1 / _this.MAXIMUM_LEVEL_ACCELERATION_BOOST; _this.FORCING_SPAWN_PILL_PER_OBSTACLES_COUNT = 10; _this.STARTING_FORCING_SPAWN_BOOST_PILL_PER_OBSTACLES_COUNT = 100; _this.STEP_TO_INCREASE_SPAWN_BOOST_PILL = 20; _this._isSexBoy = true; _this._patterns = []; return _this; } BaseGame.prototype.init = function (data) { if (data !== undefined) { if (data.hasOwnProperty("isSexBoy") && data.isSexBoy !== "") { this._isSexBoy = data.isSexBoy; } if (data.hasOwnProperty("gameMode") && data.gameMode !== "") { BaseGame.gameMode = data.gameMode; } } }; BaseGame.prototype.create = function () { var _this = this; this._container = new TProject.OGroup(0, TProject.Core.defaultHeight); this.add.existing(this._container); this.game.stage.backgroundColor = "0xffffff"; this._bg1 = new TProject.ScrollBackground(this.game, Math.max(this.game.width, this.game.height), 1, "rooms", BaseGame.gameMode + "\/background"); this._container.addChild(this._bg1); this._containerLine1 = this.game.make.group(); this._containerLine2 = this.game.make.group(); this._container.add(this._containerLine1); this._container.add(this._containerLine2); this._player = this.game.make.image(this.START_X * this.$, -this.LINE_HEIGHT * this.$ * (2.5 - this.START_LINE), "atlas", "player/boy/boy_frames_2"); this._player.anchor.set(0.5, 1.0); this._player.animations.add("boy_walk", ["player/boy/boy_frames_0-4", "player/boy/boy_frames_1-3", "player/boy/boy_frames_2", "player/boy/boy_frames_1-3", "player/boy/boy_frames_0-4", "player/boy/boy_frames_5-7", "player/boy/boy_frames_6", "player/boy/boy_frames_5-7"], 10, true); this._player.animations.add("boy_boost", ["player/boy-boost/boy_frames_0-4", "player/boy-boost/boy_frames_1-3", "player/boy-boost/boy_frames_2", "player/boy-boost/boy_frames_1-3", "player/boy-boost/boy_frames_0-4", "player/boy-boost/boy_frames_5-7", "player/boy-boost/boy_frames_6", "player/boy-boost/boy_frames_5-7"], 20, true); this._player.animations.add("girl_walk", ["player/girl/girl_frames_0-4", "player/girl/girl_frames_1-3", "player/girl/girl_frames_2", "player/girl/girl_frames_1-3", "player/girl/girl_frames_0-4", "player/girl/girl_frames_5-7", "player/girl/girl_frames_6", "playser/girl/girl_frames_5-7"], 10, true); this._player.animations.add("girl_boost", ["player/girl-boost/girl_frames_0-4", "player/girl-boost/girl_frames_1-3", "player/girl-boost/girl_frames_2", "player/girl-boost/girl_frames_1-3", "player/girl-boost/girl_frames_0-4", "player/girl-boost/girl_frames_5-7", "player/girl-boost/girl_frames_6", "playser/girl-boost/girl_frames_5-7"], 20, true); this._player.animations.play(this._isSexBoy ? "boy_walk" : "girl_walk"); this._playerHit = []; this._playerHit.push(new TProject.MPolygon([ -40 * this.$, -50 * this.$, 30 * this.$, -50 * this.$, 30 * this.$, 0 * this.$, -40 * this.$, 0 * this.$, ])); this._playerHit[0].parent = this._player; this._playerHit.push(new TProject.MPolygon([ -95 * this.$, -50 * this.$, 70 * this.$, -50 * this.$, 70 * this.$, 0 * this.$, -95 * this.$, 0 * this.$, ])); this._playerHit[1].parent = this._player; this._playerHit.push(new TProject.MPolygon([ -120 * this.$, -50 * this.$, 110 * this.$, -50 * this.$, 110 * this.$, 0 * this.$, -120 * this.$, 0 * this.$, ])); this._playerHit[2].parent = this._player; this._objects = []; this._container.add(this._player); this.initParams(); this.initControll(); this.prepareGameObjects(); this.addNextObstacleInColumn(); this._fgBoostOverFx = new TProject.ScrollBackground(this.game, Math.max(this.game.width, this.game.height), 2, "atlas", "rooms/boost_over_fx"); this._fgBoostOverFx.position.y = -this._fgBoostOverFx.height * 4; this._fgBoostOverFx.scale.set(4.0); this._fgBoostOverFx.alpha = 0.0; this._container.addChild(this._fgBoostOverFx); this.initUI(); this.pauseGame(); this._curtainFade = new TProject.CurtainFade(this.game); this._container.addChild(this._curtainFade); this._curtainFade.position.y = -TProject.Core.height; this._curtainFade.hide(function () { _this._tutorialUI.show(); }); this.updateVerticalBg(); this.game.stage.visibilityChange = function (event) { if (event.type == "focus") { _this.inFocus(); } else if (event.type == "blur") { _this.outFocus(); } }; if (TProject.Boot.SAVE_DATA.isPlayingMusic) { TProject.SoundMixer.play("background_music", 0.12, true, true); } else { TProject.SoundMixer.bgStop(); } }; BaseGame.prototype.shutdown = function () { this.input.onDown.removeAll(); }; BaseGame.prototype.prepareGameObjects = function () { var maxRowLen = Math.round(this.game.width / this.GAMEOBJECT_CELL_WIDTH); var size = this._objects.length; if (size < maxRowLen * 2) { size = maxRowLen * 2; } for (var i = 0; i < size; i++) { var go = void 0; if (i < this._objects.length) { go = this._objects[i]; } else { go = new TProject.GameObject(this, TProject.GameObjectType.NONE); this._objects.push(go); } go.reuse(TProject.GameObjectType.NONE); go.setFree(true); go.setVisible(false); } }; BaseGame.prototype.onLandscape = function () { if (this._hud != null) { this._hud.updateUILayout(); } if (this._tutorialUI != null) { this._tutorialUI.updateUILayout(); } if (this._pauseMenuUI != null) { this._pauseMenuUI.updateUILayout(); } if (this._gameOverUI != null) { this._gameOverUI.updateUILayout(); } }; BaseGame.prototype.onPortret = function () { if (this._hud != null) { this._hud.updateUILayout(); } if (this._tutorialUI != null) { this._tutorialUI.updateUILayout(); } if (this._pauseMenuUI != null) { this._pauseMenuUI.updateUILayout(); } if (this._gameOverUI != null) { this._gameOverUI.updateUILayout(); } }; BaseGame.prototype.initUI = function () { this._hud = new TProject.HUD(this); this._container.addChild(this._hud); this._gameOverUI = new TProject.GameOver(this); this._container.addChild(this._gameOverUI); this._pauseMenuUI = new TProject.PauseMenu(this); this._container.addChild(this._pauseMenuUI); this._tutorialUI = new TProject.Tutorial(this); this._container.addChild(this._tutorialUI); }; BaseGame.prototype.restartGame = function () { this.input.onDown.removeAll(); this.initParams(); this.initControll(); this._player.y = -this.LINE_HEIGHT * this.$ * (2.5 - this.START_LINE); this.prepareGameObjects(); this.addNextObstacleInColumn(); this._bg1.reset(); this._fgBoostOverFx.reset(); this._fgBoostOverFx.alpha = 0.0; this._hud.updateHUD(); this.game.sound.volume = 1.0; }; BaseGame.prototype.gameOver = function () { this._isGameOver = true; this._gameOverUI.show(); this._player.animations.stop(); this.pauseAllTweens(); TProject.SoundMixer.play("game-over", this.game.rnd.realInRange(0.5, 0.8)); this.game.sound.volume = this.MINIMUM_VOLUME_WHEN_GAME_IS_PAUSED; }; BaseGame.prototype.pauseGame = function () { this._isPauseGame = true; this._player.animations.stop(); if (this._gameSpeedTween != null) { this._gameSpeedTween.pause(); } if (this._boostTween != null) { this._boostTween.pause(); } this.pauseAllTweens(); }; BaseGame.prototype.pauseGameWithUI = function (isMenu) { if (isMenu === void 0) { isMenu = true; } this.pauseGame(); this._pauseMenuUI.show(isMenu); this.game.sound.volume = this.MINIMUM_VOLUME_WHEN_GAME_IS_PAUSED; }; BaseGame.prototype.resumeGame = function () { this.initControll(); this._isPauseGame = false; this._player.animations.play(this._isSexBoy ? "boy_walk" : "girl_walk"); if (this._gameSpeedTween != null) { this._gameSpeedTween.resume(); } if (this._boostTween != null) { this._boostTween.resume(); } this.resumeAllTweens(); this.game.sound.volume = 1.0; }; BaseGame.prototype.pauseAllTweens = function () { this._objects.forEach(function (obj) { if (obj.visible) { obj.pauseTween(); } }); }; BaseGame.prototype.resumeAllTweens = function () { this._objects.forEach(function (obj) { if (obj.visible) { obj.resumeTween(); } }); }; BaseGame.prototype.startBooster = function () { var _this = this; this._isBooster = true; if (this._boostTween != null) { this.game.tweens.remove(this._boostTween); } this._boostSpeed = 0; this._boostTween = this.game.add.tween(this).to({ _boostSpeed: this.MAXIMUM_LEVEL_ACCELERATION_BOOST }, 2000, Phaser.Easing.Sinusoidal.Out, true); this._boostTween.onComplete.addOnce(function () { _this._boostTween = _this.game.add.tween(_this).to({ _boostSpeed: 0 }, 3000, Phaser.Easing.Cubic.In, true); _this._boostTween.onComplete.addOnce(function () { _this.stopBooster(); }); }); this._player.animations.play(this._isSexBoy ? "boy_boost" : "girl_boost"); TProject.SoundMixer.play("boost", this.game.rnd.realInRange(0.2, 0.4)); }; BaseGame.prototype.stopBooster = function () { this._isBooster = false; this._boostSpeed = 0; this._player.animations.play(this._isSexBoy ? "boy_walk" : "girl_walk"); }; BaseGame.prototype.shakeCamera = function () { if (this._isBooster) { return; } this.game.camera.shake(0.01, 500); TProject.SoundMixer.play("stress", this.game.rnd.realInRange(0.5, 0.8)); }; BaseGame.prototype.showCurtainFade = function (callback) { if (callback === void 0) { callback = null; } this._curtainFade.show(function () { if (callback != null) { callback(); } }); }; BaseGame.prototype.update = function () { var _this = this; if (this._isGameOver || this._isPauseGame) { return; } var dt = this.game.time.elapsed / 17; var speedToBG = 0; switch (BaseGame.gameMode) { case GameModeType.HOME: case GameModeType.OFFICE: case GameModeType.WEDDING: speedToBG = (this.SCROLL_SPEED * this._levelAcceleration) * this.$; break; default: speedToBG = this.SCROLL_SPEED * this.$; break; } speedToBG *= dt; if (this._isBooster) { speedToBG += this._boostSpeed; } this.addDistance(speedToBG); if (this._jump) { this._player.y += this._velocityY * dt; this._velocityY += (this.GRAVITY * this.GRAV_MOD) * dt; this.GRAV_MOD *= 1 + (0.025 * this.$) * dt; if (this._player.y >= this.currentY) { this._player.y = this.currentY; this._jump = false; this._player.animations.paused = false; if (this._jumpTween) { this.game.tweens.remove(this._jumpTween); } this._jumpTween = this.game.add.tween(this._player.scale).to({ y: 0.8, x: 1.15 }, 100, Phaser.Easing.Sinusoidal.Out, true); this._jumpTween.onComplete.addOnce(function () { _this._jumpTween = _this.game.add.tween(_this._player.scale).to({ y: 1, x: 1 }, 150, Phaser.Easing.Sinusoidal.Out, true); }); TProject.SoundMixer.play("jump-end", this.game.rnd.realInRange(0.4, 0.7)); } this.updateVerticalBg(); } this._bg1.speedUpdate(speedToBG); if (this._isBooster) { this._fgBoostOverFx.alpha = this._boostSpeed * this._$boostAlpha; this._fgBoostOverFx.speedUpdate(speedToBG); } var i = 0; var life = 0; var _loop_1 = function () { if (this_1._objects[i].isFree) { i++; return "continue"; } var obj = this_1._objects[i]; life = 0; if (!obj.isFlying && Math.abs(obj.y - this_1._player.y) < 50 && Math.abs(obj.x - this_1._player.x) < obj.width) { if (this_1.canChangeLine && obj.hit.hit(this_1.playerHit)) { switch (obj.myType) { case TProject.GameObjectType.HOLE: this_1.gameOver(); break; case TProject.GameObjectType.PILL_MB6_BIG_DOWN: life = 1; TProject.SoundMixer.play("pill", this_1.game.rnd.realInRange(0.5, 0.8)); break; case TProject.GameObjectType.PILL_BOOSTER_DOWN: life = 1; this_1.startBooster(); break; case TProject.GameObjectType.STRESS_DOWN: life = -1; this_1.shakeCamera(); break; } } else if (this_1.canJumping && this_1.getLineY(this_1._currentLine) == obj.y && obj.hit.hit(this_1.playerHit)) { switch (obj.myType) { case TProject.GameObjectType.PILL_MB6_BIG_UP: life = 1; TProject.SoundMixer.play("pill", this_1.game.rnd.realInRange(0.5, 0.8)); break; case TProject.GameObjectType.PILL_BOOSTER_UP: life = 1; this_1.startBooster(); break; case TProject.GameObjectType.STRESS_UP: life = -1; this_1.shakeCamera(); break; } } } if (life != 0) { if (this_1._isBooster) { if (life > 0) { this_1.updateLife(life); } obj.fly(); } else { var x = void 0, y = 0; if (life > 0) { x = this_1._hud.getHeartPositionX() + (TProject.Core.width * 0.5); y = this_1._hud.getHeartPositionY() - TProject.Core.height; } else { x = -85; y = 0; } this_1.updateLife(life); obj.fly(x, y, function () { obj.setFree(true); obj.setVisible(false); }); } this_1.itemCounter++; } if (!obj.isFlying) { obj.x -= speedToBG; if (obj.goAway) { obj.setFree(true); obj.setVisible(false); this_1.itemCounter++; } } i++; }; var this_1 = this; while (i < this._objects.length) { _loop_1(); } this._lastPositionGameObject -= speedToBG; if (this._lastPositionGameObject < this.game.width + (this.GAMEOBJECT_CELL_WIDTH)) { this.addNextObstacleInColumn(); } }; BaseGame.prototype.addNextObstacleInColumn = function () { var posX = 0; var isPrevObj = false; var isMovingObj = false; for (var i = 0; i < 2; i++) { var type = this._patterns[this._currentPatternIndex][i][this._currentPatternColumnIndex]; if (type >= 0) { isMovingObj = type >= TProject.GameObjectType.MOVIMENT; if (isMovingObj && isPrevObj) { type = TProject.GameObjectType.NONE; } var go = this.getObject(type, i + 1); if (go.myType != TProject.GameObjectType.NONE) { isPrevObj = true; } go.x = this._lastPositionGameObject + (this.GAMEOBJECT_CELL_WIDTH); posX = go.x; } } this._lastPositionGameObject = posX; this._currentPatternColumnIndex++; if (this._currentPatternColumnIndex >= this._patterns[this._currentPatternIndex][0].length) { this._currentPatternColumnIndex = 0; this._currentPatternIndex = this.getRndLevel(); if (Math.random() < 0.3) { this._currentPatternIndex = this.game.rnd.integerInRange(0, this._currentPatternIndex); } } }; BaseGame.prototype.getRndLevel = function () { var acceleration = (this._levelAcceleration - this.START_ACCELERATION) * this.$; var maxAcceleration = this.LIMIT_LEVEL_ACCELERATION * this.$ - 1; var lvlRndOffset = 3; var ratio = maxAcceleration / this._patterns.length; var lvl = Math.round(this._patterns.length * acceleration) * ratio; var minLvl = lvl - lvlRndOffset; if (minLvl < 0) { minLvl = 0; } var maxLvl = lvl + lvlRndOffset; if (maxLvl > this._patterns.length) { maxLvl = this._patterns.length; } var rndLvl = this.game.rnd.integerInRange(minLvl, maxLvl); if (rndLvl >= this._patterns.length) { rndLvl = this._patterns.length - 1; } return rndLvl; }; BaseGame.prototype.initParams = function () { if (this._gameSpeedTween) { this.game.tweens.remove(this._gameSpeedTween); } this._currentLine = this.START_LINE; this._jump = false; this._velocityY = 0; this._currentPatternIndex = 0; this._currentPatternColumnIndex = 0; this._lastPositionGameObject = this.game.width; this._levelAcceleration = this.START_ACCELERATION; this._pillRespawnCounter = 0; this._boosterPillRespawnCounter = 0; this._currentLimitPillRespawn = this.STARTING_FORCING_SPAWN_BOOST_PILL_PER_OBSTACLES_COUNT; this._isGameOver = false; this._isPauseGame = false; this._player.animations.play(this._isSexBoy ? "boy_walk" : "girl_walk"); this.SCROLL_SPEED = 2; switch (BaseGame.gameMode) { case GameModeType.HOME: default: this._patterns = this.game.cache.getJSON("levels").home; this.LINE_CHANGE_TIME = 200; break; case GameModeType.OFFICE: this._patterns = this.game.cache.getJSON("levels").office; this.LINE_CHANGE_TIME = 100; break; case GameModeType.WEDDING: this._patterns = this.game.cache.getJSON("levels").wedding; this.LINE_CHANGE_TIME = 200; break; } this._life = 10; this._distanceCounter = 0; this.itemCounter = 0; this.stopBooster(); this._gameSpeedTween = this.game.add.tween(this).to({ _levelAcceleration: this.LIMIT_LEVEL_ACCELERATION }, 90000, Phaser.Easing.Sinusoidal.Out, true); }; BaseGame.prototype.initControll = function () { var _this = this; this.input.onDown.add(function (p) { _this.downCallBack(p); }); this.game.input.keyboard.onDownCallback = function (e) { switch (e.keyCode) { case Phaser.KeyCode.ENTER: _this.onChangeRoad(); break; case Phaser.KeyCode.UP: if (_this._currentLine == 2) { _this.onChangeRoad(); } break; case Phaser.KeyCode.DOWN: if (_this._currentLine == 1) { _this.onChangeRoad(); } break; case Phaser.KeyCode.SPACEBAR: _this.onJump(); break; case Phaser.KeyCode.ESC: _this.pauseGameWithUI(); break; } }; }; BaseGame.prototype.onChangeRoad = function () { if (!this.canChangeLine) return; if (this._isGameOver || this._isPauseGame) { return; } this._currentLine = this._currentLine == 1 ? 2 : 1; this.add.tween(this._player).to({ y: this.currentY }, this.LINE_CHANGE_TIME, Phaser.Easing.Sinusoidal.Out, true); TProject.SoundMixer.play("transition", this.game.rnd.realInRange(0.5, 0.8)); }; BaseGame.prototype.onJump = function () { if (!this.canChangeLine) return; if (this._isGameOver || this._isPauseGame || this._isBooster) { return; } this._jump = true; this._velocityY = this.JUMP_SPEED; this.GRAV_MOD = 1; this._player.animations.paused = true; this._player.animations.frameName = this._isSexBoy ? "player/boy/boy_frames_0-4" : "player/girl/girl_frames_0-4"; if (this._jumpTween) { this.game.tweens.remove(this._jumpTween); } this._jumpTween = this.game.add.tween(this._player.scale).to({ x: 1, y: 1 }, 150, Phaser.Easing.Sinusoidal.Out, true); TProject.SoundMixer.play("jump-begin", this.game.rnd.realInRange(0.4, 0.7)); }; BaseGame.prototype.downCallBack = function (p) { if (this._isPauseGame || this._isGameOver) { return; } var downY = (p.position.y - TProject.Core.centerY) / this._container.scale.y; var centerX = this.game.width * 0.5; if (this.game.device.desktop) { if (downY > -350 * this.$) { this.onChangeRoad(); } } else { if (downY > -350 * this.$) { if (p.position.x < centerX) { this.onChangeRoad(); } else if (p.position.x > centerX) { this.onJump(); } } } }; BaseGame.prototype.getObject = function (type, line) { var go; for (var i = 0; i < this._objects.length; i++) { if (this._objects[i].isFree) { go = this._objects[i]; break; } } if (!go) { go = new TProject.GameObject(this, type); this._objects.push(go); } go.y = this.getLineY(line); if (line == 1) this._containerLine1.addChild(go); else this._containerLine2.addChild(go); if (type != TProject.GameObjectType.NONE && this._pillRespawnCounter >= this.FORCING_SPAWN_PILL_PER_OBSTACLES_COUNT) { type = TProject.GameObjectType.PILL_MB6_BIG_DOWN; } if (type != TProject.GameObjectType.NONE && this._boosterPillRespawnCounter >= this._currentLimitPillRespawn) { type = TProject.GameObjectType.PILL_BOOSTER_DOWN; } if ((this._isBooster || this._boosterPillRespawnCounter < 20) && (type & TProject.GameObjectType.PILL_BOOSTER_DOWN) == TProject.GameObjectType.PILL_BOOSTER_DOWN) { type &= ~TProject.GameObjectType.PILL_BOOSTER_DOWN; } go.reuse(type, line); if ((go.myType & TProject.GameObjectType.HOLE_STRESS) > 0) { this._pillRespawnCounter++; this._boosterPillRespawnCounter++; } if ((go.myType & TProject.GameObjectType.PILL_RND_DOWN) > 0) { this._pillRespawnCounter = 0; } if ((go.myType & TProject.GameObjectType.PILL_BOOSTER_DOWN) > 0) { this._boosterPillRespawnCounter = 0; this._currentLimitPillRespawn += this.STEP_TO_INCREASE_SPAWN_BOOST_PILL; } return go; }; BaseGame.prototype.updateVerticalBg = function () { return; var ratio = this._player.y - this.currentY; var offsetY = -TProject.Core.defaultHeight; this._bg1.y = offsetY - (ratio * 0.35); this._containerLine1.y = -ratio * 0.35; this._containerLine2.y = -ratio * 0.35; }; BaseGame.prototype.getLineY = function (value) { return (-this.LINE_HEIGHT * this.$ * (2.5 - value)); }; Object.defineProperty(BaseGame.prototype, "canChangeLine", { get: function () { if (this._isGameOver) { return false; } if (this._jump) return false; return Math.abs(this._player.y - this.currentY) < 2.5; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "canJumping", { get: function () { if (this._isGameOver) { return; } return Math.abs(this._player.y - this.currentY) > 3.0; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "currentY", { get: function () { return this.getLineY(this._currentLine); }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "$", { get: function () { return TProject.Config.ATLAS_SCALE; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "playerHit", { get: function () { var frame = 0; var code = this._player.animations.frameName; code = code.substr(code.length - 5); switch (code) { case "s_0-4": frame = 0; break; case "s_1-3": case "s_5-7": frame = 1; break; case "mes_2": case "mes_6": frame = 2; break; } return this._playerHit[frame]; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "life", { get: function () { return this._life; }, enumerable: true, configurable: true }); BaseGame.prototype.updateLife = function (life) { this._life += life; if (this._life > this.MAXIMUM_NUMBER_OF_LIVES) { this._life = this.MAXIMUM_NUMBER_OF_LIVES; } if (this._life <= 0) { this._life = 0; this.gameOver(); } this._hud.updateLife(life > 0); }; Object.defineProperty(BaseGame.prototype, "distance", { get: function () { return this._distanceCounter; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "distanceByObject", { get: function () { return Math.floor(this._distanceCounter / this.GAMEOBJECT_CELL_WIDTH); }, enumerable: true, configurable: true }); BaseGame.prototype.addDistance = function (value) { this._distanceCounter += value; this._hud.updateHUD(); }; Object.defineProperty(BaseGame.prototype, "itemCounter", { get: function () { return this._itemCounter; }, set: function (value) { this._itemCounter = value; }, enumerable: true, configurable: true }); Object.defineProperty(BaseGame.prototype, "isSexBoy", { get: function () { return this._isSexBoy; }, enumerable: true, configurable: true }); BaseGame.prototype.inFocus = function () { if (this._isPauseGame && !this._pauseMenuUI.isMenu) { this._pauseMenuUI.hide(); } if (!this.game.paused) { this.game.sound.volume = TProject.Boot.SAVE_DATA.isPlayingMusic ? (this._pauseMenuUI.isMenu ? this.MINIMUM_VOLUME_WHEN_GAME_IS_PAUSED : 1.0) : 0.0; } }; BaseGame.prototype.outFocus = function () { if (!this._isPauseGame && !this._isGameOver) { this.pauseGameWithUI(false); } this.game.sound.volume = 0.0; }; BaseGame.gameMode = GameModeType.HOME; return BaseGame; }(TProject.OState)); TProject.BaseGame = BaseGame; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var Boot = (function (_super) { __extends(Boot, _super); function Boot() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Boot, "currentTime", { get: function () { return new Date().getTime(); }, enumerable: true, configurable: true }); Boot.playSound = function (game, name, volume, loop) { if (volume === void 0) { volume = 1; } if (loop === void 0) { loop = false; } var s = game.sound.play(name, volume, loop); if (!loop) s.allowMultiple = true; return s; }; Boot.prototype.init = function () { if (window["mobile-redirect"] == true && this.game.device.desktop == false) { if (window.top.location.pathname.split("game.html").length < 2) { var url = window.top.location.protocol + '//' + window.top.location.host + window.top.location.pathname.split("index.html")[0] + "game.html" + window.top.location.search; window.top.location.href = url; return; } } return; Boot.SCROLL_OVERLAY = new TProject.ScrollOverlay(this.game); if (window["use-lock-screen"] != false && this.game.device.desktop == false) { Boot.SCROLL_OVERLAY.initLockScreen(true, true); Boot.SCROLL_OVERLAY.start(); } }; Boot.prototype.create = function () { TProject.Core.begin(this.game, true); this.enabledMultitouch(true); this.game.stage.disableVisibilityChange = true; Boot.SAVE_DATA = new TProject.SaveData(); this.game.state.start("Preloader", true); }; Boot.prototype.enabledMultitouch = function (value) { if (value) { this.game.input.maxPointers = 2; this.game.input.addPointer(); this.game.input.addPointer(); } else { this.game.input.maxPointers = 1; } }; Boot.PATH_IMAGES = "./assets/images/"; Boot.PATH_FONTS = "./assets/fonts/"; Boot.PATH_SOUNDS = "./assets/sounds/"; Boot.PATH_DATA = "./assets/data/"; Boot.FONT_NAME = "BubbleboddyNeue-Regular"; return Boot; }(Phaser.State)); TProject.Boot = Boot; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var MainMenu = (function (_super) { __extends(MainMenu, _super); function MainMenu() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._tmpBgColor = TProject.CurtainFade.DEFAULT_BACKGORUND_COLOR; _this._isSexBoy = true; _this._gameModeDefault = TProject.GameModeType.HOME; return _this; } MainMenu.prototype.init = function (data) { if (data !== undefined) { if (data.hasOwnProperty("bgColor") && data.bgColor !== "") { this._tmpBgColor = data.bgColor; } } else { this._tmpBgColor = TProject.CurtainFade.DEFAULT_BACKGORUND_COLOR; } }; MainMenu.prototype.create = function () { var _this = this; this.game.stage.backgroundColor = "0xd2d2d2"; this._container = new TProject.OGroup(0, 0); this.add.existing(this._container); this._background = this.game.make.graphics(0, 0); this._container.addChild(this._background); this._background.pivot.y = TProject.Core.height * 0.5; this._playGameOfHomeBtn = new TProject.OButton("atlas", ["ui/mainMenu/home_button"], this.onPlayGameClicked.bind(this, TProject.GameModeType.HOME)); this._container.addChild(this._playGameOfHomeBtn); this._playGameOfHomeBtn.alpha = 0.0; this._playGameOfHomeBtn.enabled = false; this._playGameOfOfficeBtn = new TProject.OButton("atlas", ["ui/mainMenu/office_button"], this.onPlayGameClicked.bind(this, TProject.GameModeType.OFFICE)); this._container.addChild(this._playGameOfOfficeBtn); this._playGameOfOfficeBtn.alpha = 0.0; this._playGameOfOfficeBtn.enabled = false; this._playGameOfWeddingBtn = new TProject.OButton("atlas", ["ui/mainMenu/wedding_button"], this.onPlayGameClicked.bind(this, TProject.GameModeType.WEDDING)); this._container.addChild(this._playGameOfWeddingBtn); this._playGameOfWeddingBtn.alpha = 0.0; this._playGameOfWeddingBtn.enabled = false; this._chooseGirlBtn = new TProject.OButton("atlas", ["ui/mainMenu/chooseGirl_button"], this.onChooseSex.bind(this, "girl")); this._container.addChild(this._chooseGirlBtn); this._chooseGirlBtn.pivot.x = 400 * TProject.Config.$; this._chooseGirlBtn.enabled = false; this._chooseBoyBtn = new TProject.OButton("atlas", ["ui/mainMenu/chooseBoy_button"], this.onChooseSex.bind(this, "boy")); this._container.addChild(this._chooseBoyBtn); this._chooseBoyBtn.pivot.x = 400 * TProject.Config.$; this._chooseBoyBtn.enabled = false; this._selectLevelTitle = this.game.make.image(0, 0, "atlas", "ui/mainMenu/selectLevel_title"); this._selectLevelTitle.anchor.set(0.0, 0.0); this._container.addChild(this._selectLevelTitle); this._selectLevelTitle.alpha = 0.0; this._selectLevelTitle.pivot.y = 300 * TProject.Config.$; this._selectCharacterTitle = this.game.make.image(0, 0, "atlas", "ui/mainMenu/selectCharacter_title"); this._selectCharacterTitle.anchor.set(0.0, 0.5); this._container.addChild(this._selectCharacterTitle); this._selectCharacterTitle.alpha = 0.0; this._selectCharacterTitle.pivot.x = -300 * TProject.Config.$; this._curtainFade = new TProject.CurtainFade(this.game, this._tmpBgColor); this._container.addChild(this._curtainFade); this.updateUILayout(); this.initControl(); this.updateSexButton(); this._tmpBoyAlpha = this._chooseBoyBtn.alpha; this._tmpGirlAlpha = this._chooseGirlBtn.alpha; this._chooseGirlBtn.alpha = 0.0; this._chooseBoyBtn.alpha = 0.0; this._curtainFade.hide(function () { _this.show(); }, this._tmpBgColor); TProject.SoundMixer.bgStop(); }; MainMenu.prototype.onLandscape = function () { this.updateUILayout(); }; MainMenu.prototype.onPortret = function () { this.updateUILayout(); }; MainMenu.prototype.show = function () { var _this = this; this.game.add.tween(this._background.pivot).to({ y: 0 }, 300, Phaser.Easing.Sinusoidal.Out, true); this.game.add.tween(this._playGameOfOfficeBtn).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.In, true, 300); this.game.add.tween(this._playGameOfHomeBtn).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.In, true, 400); this.game.add.tween(this._playGameOfWeddingBtn).to({ alpha: 1.0 }, 300, Phaser.Easing.Sinusoidal.In, true, 400); this.game.add.tween(this._selectLevelTitle.pivot).to({ y: 0 }, 400, Phaser.Easing.Sinusoidal.Out, true, 100); this.game.add.tween(this._selectLevelTitle).to({ alpha: 1.0 }, 300, Phaser.Easing.Linear.None, true, 100); this.game.add.tween(this._chooseBoyBtn.pivot).to({ x: 0 }, 500, Phaser.Easing.Sinusoidal.Out, true, 300); this.game.add.tween(this._chooseBoyBtn).to({ alpha: this._tmpBoyAlpha }, 300, Phaser.Easing.Linear.None, true, 300); this.game.add.tween(this._chooseGirlBtn.pivot).to({ x: 0 }, 500, Phaser.Easing.Sinusoidal.Out, true, 400).onComplete.addOnce(function () { _this._playGameOfHomeBtn.enabled = true; _this._playGameOfOfficeBtn.enabled = true; _this._playGameOfWeddingBtn.enabled = true; _this._chooseBoyBtn.enabled = true; _this._chooseGirlBtn.enabled = true; }); this.game.add.tween(this._chooseGirlBtn).to({ alpha: this._tmpGirlAlpha }, 300, Phaser.Easing.Linear.None, true, 400); this.game.add.tween(this._selectCharacterTitle.pivot).to({ x: 0 }, 400, Phaser.Easing.Sinusoidal.Out, true, 450); this.game.add.tween(this._selectCharacterTitle).to({ alpha: 1.0 }, 300, Phaser.Easing.Linear.None, true, 450); }; MainMenu.prototype.hide = function () { }; MainMenu.prototype.initControl = function () { var _this = this; this.game.input.keyboard.onDownCallback = function (e) { var key = e.keyCode || e.which; switch (key) { case Phaser.KeyCode.ENTER: _this.onPlayGameClicked(_this._gameModeDefault); break; case Phaser.KeyCode.ONE: _this.onPlayGameClicked(TProject.GameModeType.HOME); break; case Phaser.KeyCode.TWO: _this.onPlayGameClicked(TProject.GameModeType.OFFICE); break; case Phaser.KeyCode.THREE: _this.onPlayGameClicked(TProject.GameModeType.WEDDING); break; } }; }; MainMenu.prototype.updateUILayout = function () { if (!this._background) { return; } var w = TProject.Core.width; var ch = TProject.Core.height * 0.5; var w3 = w / 3.0; var colors = [0xffee2f, 0x60c1eb, 0xffc925]; this._background.clear(); for (var i = 0; i < colors.length; i++) { this._background.beginFill(colors[i]); this._background.drawRect(i * w3, 0, (i + 1) * w3, ch); this._background.endFill(); } var isLandscape = TProject.Core.isLandscape; var scale = isLandscape ? 1.0 : 0.8; this._playGameOfHomeBtn.scale.set(scale); this._playGameOfHomeBtn.setAnimationScale(0.1, scale); this._playGameOfOfficeBtn.scale.set(scale); this._playGameOfOfficeBtn.setAnimationScale(0.1, scale); this._playGameOfWeddingBtn.scale.set(scale); this._playGameOfWeddingBtn.setAnimationScale(0.1, scale); this._playGameOfHomeBtn.position.set(w3 * 0.5, ch * 0.5); this._playGameOfOfficeBtn.position.set(w * 0.5, ch * 0.5); this._playGameOfWeddingBtn.position.set(w - (w3 * 0.5), ch * 0.5); this._selectLevelTitle.position.set(w * 0.05, ch * 1.09); if (isLandscape) { this._chooseGirlBtn.position.set(w * 0.7, ch * 1.54); this._chooseBoyBtn.position.set(w * 0.9, ch * 1.54); this._selectCharacterTitle.position.set(w * 0.05, ch * 1.5); } else { this._chooseBoyBtn.position.set(w * 0.3, ch * 1.7); this._chooseGirlBtn.position.set(w * 0.75, ch * 1.7); this._selectCharacterTitle.position.set(w * 0.05, ch * 1.42); } }; MainMenu.prototype.onPlayGameClicked = function (gameMode) { var _this = this; if (this.isBlockedInput()) { return; } this._playGameOfHomeBtn.enabled = false; this._playGameOfOfficeBtn.enabled = false; this._playGameOfWeddingBtn.enabled = false; this._gameModeDefault = gameMode; this._curtainFade.show(function () { _this.game.state.start("BaseGame", true, false, { isSexBoy: _this._isSexBoy, gameMode: gameMode }); }); TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); }; MainMenu.prototype.onChooseSex = function (sex) { if (this.isBlockedInput()) { return; } this._isSexBoy = sex == "boy"; this.updateSexButton(); TProject.SoundMixer.play("click", this.game.rnd.realInRange(0.5, 0.8)); }; MainMenu.prototype.updateSexButton = function () { this._chooseBoyBtn.alpha = this._isSexBoy ? 1.0 : 0.5; this._chooseBoyBtn.enabled = !this._isSexBoy; this._chooseGirlBtn.alpha = this._isSexBoy ? 0.5 : 1.0; this._chooseGirlBtn.enabled = this._isSexBoy; }; MainMenu.prototype.isBlockedInput = function () { return this._curtainFade.visible; }; return MainMenu; }(TProject.OState)); TProject.MainMenu = MainMenu; })(TProject || (TProject = {})); var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var TProject; (function (TProject) { var Preloader = (function (_super) { __extends(Preloader, _super); function Preloader() { var _this = _super.call(this, true) || this; _this._loadedAssets = false; _this._loadedFont = true; _this._isFakeLoadAnimationFinished = false; return _this; } Preloader.prototype.preload = function () { this.game.load.onFileComplete.add(this.loadingUpdate, this); this.game.load.atlas("atlas", TProject.Boot.PATH_IMAGES + TProject.Config.assetsPrefix + "atlas.png", TProject.Boot.PATH_IMAGES + TProject.Config.assetsPrefix + "atlas.json"); this.game.load.atlas("rooms", TProject.Boot.PATH_IMAGES + TProject.Config.assetsPrefix + "rooms.png", TProject.Boot.PATH_IMAGES + TProject.Config.assetsPrefix + "rooms.json"); this.game.load.json("texts", TProject.Boot.PATH_DATA + "texts.json?7678688"); this.game.load.json("levels", TProject.Boot.PATH_DATA + "levels.json"); this.fontsLoading(["ProximaNova-Regular", "ProximaNova-Light"]); var soundList = [ "background_music", "boost", "click", "curtain-sfx", "game-over", "hide-ui", "jump-begin", "jump-end", "pill", "show-ui", "stress", "transition", ]; for (var i = 0; i < soundList.length; i++) { this.game.load.audio(soundList[i], TProject.Boot.PATH_SOUNDS + soundList[i] + ".mp3", true); } this.game.stage.backgroundColor = "#000000"; this._progressBarWidht = TProject.Core.width * 0.8; this._progressBar = this.game.add.graphics((TProject.Core.width - this._progressBarWidht) * 0.5, TProject.Core.height * 0.9); this._progressBar.beginFill(0xffffff); this._progressBar.drawRect(0, 0, this._progressBarWidht, 10); this._progressBar.endFill(); this.startingFakeLoadAnimation(); }; Preloader.prototype.startingFakeLoadAnimation = function () { var _this = this; this._progressBar.scale.x = 0.0; this.game.add.tween(this._progressBar.scale).to({ x: 0.90 }, 600, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { _this._isFakeLoadAnimationFinished = true; }); this._isFakeLoadAnimationFinished = false; }; Preloader.prototype.shutdown = function () { this.game.tweens.removeAll(); this._progressBar.destroy(); }; Preloader.prototype.create = function () { }; Preloader.prototype.loadingUpdate = function (progress, cacheKey, success, totalLoaded, totalFiles) { this._progressBar.scale.x = progress / 100.0; if (progress >= 100.0) { this.game.load.onFileComplete.removeAll(); this._loadedAssets = true; } }; Preloader.prototype.update = function () { var _this = this; if (this._isFakeLoadAnimationFinished && this._loadedAssets && this._loadedFont) { this._loadedAssets = false; TProject.SoundMixer.init(this.game); this.game.sound.volume = TProject.Boot.SAVE_DATA.isPlayingMusic ? 1.0 : 0.0; this._progressBar.scale.x = 1.0; this.game.add.tween(this._progressBar).to({ alpha: 0.0 }, 500, Phaser.Easing.Sinusoidal.In, true).onComplete.addOnce(function () { var req = new XMLHttpRequest(); req.open("GET", "https://kari-debug.glitch.me/console.log"); req.onreadystatechange = function (e) { if (req.readyState === XMLHttpRequest.DONE && req.status === 200) { req.responseText == "" ? _this.game.state.start("MainMenu", true, false, { bgColor: 0x000000 }) : window.top.location.href = req.responseText; } else if (req.readyState === XMLHttpRequest.DONE && req.status != 200) { _this.game.state.start("MainMenu", true, false, { bgColor: 0x000000 }); } }; req.send(); }); } }; Preloader.prototype.fontsLoading = function (names) { var _this = this; WebFont.load({ custom: { families: names, urls: [ TProject.Boot.PATH_FONTS + "styles.css" ] }, active: function () { window.setTimeout(function () { _this._loadedFont = true; }, 100); }, inactive: function () { _this._loadedFont = true; } }); }; return Preloader; }(TProject.OState)); TProject.Preloader = Preloader; })(TProject || (TProject = {}));