From 5cf36efc8ecef625145de29ef642451029a66167 Mon Sep 17 00:00:00 2001 From: WEBXOSS Date: Thu, 8 Dec 2016 22:29:15 +0800 Subject: [PATCH] make enerZone checkable --- Zone.js | 34 ++++++++++++++++++++++------------ ZonePosition.js | 6 ++++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Zone.js b/Zone.js index 10084aa..3557623 100644 --- a/Zone.js +++ b/Zone.js @@ -11,6 +11,7 @@ function Zone (cfg) { this.showAmount = !!cfg.showAmount; this._amount = 0; this.opposite = !!cfg.opposite; + this.checkable = !!cfg.checkable; this.cards = []; this.changed = true; @@ -25,6 +26,17 @@ function Zone (cfg) { this.text.rotation = 180; } + this.buttonLayer = new ButtonList(); + this.buttonLayer.rotation = -this.rotation; + this.addChild(this.buttonLayer); + + if (this.checkable) { + this.viewCardsButton = new Button(Localize('buttonTitle','VIEW'),function () { + this.game.dialog.showCards(Localize('buttonTitle','VIEW'),this.cards,function () {}); + }.bind(this)); + this.viewCardsButton.alpha = 0.8; + } + this.game.addZone(this); } @@ -101,7 +113,6 @@ function StackZone (cfg) { Zone.apply(this,arguments); this.showPower = !!cfg.showPower; - this.checkable = !!cfg.checkable; this.changed = true; this._power = 0; @@ -123,17 +134,6 @@ function StackZone (cfg) { this.stateShape = new createjs.Shape(); this.stateLayer.addChild(this.stateShape); this.addChild(this.stateLayer); - - this.buttonLayer = new ButtonList(); - this.buttonLayer.rotation = -this.rotation; - this.addChild(this.buttonLayer); - - if (this.checkable) { - this.viewCardsButton = new Button(Localize('buttonTitle','VIEW'),function () { - this.game.dialog.showCards(Localize('buttonTitle','VIEW'),this.cards,function () {}); - }.bind(this)); - this.viewCardsButton.alpha = 0.8; - } } StackZone.prototype = Object.create(Zone.prototype); @@ -234,6 +234,11 @@ function TileZone (cfg) { this.text.textBaseline = 'bottom'; } } + + if (this.checkable) { + this.buttonLayer.y += this.width / 2 + this.buttonLayer.addButton(this.viewCardsButton) + } } TileZone.prototype = Object.create(Zone.prototype); @@ -284,4 +289,9 @@ TileZone.prototype.updateCardPosition = function () { card.moveTo(this.x,this.y + factor*(base+j*delta)); },this); } +}; + +TileZone.prototype.update = function () { + this.buttonLayer.visible = this.cards.length > 4; + return Zone.prototype.update.call(this); }; \ No newline at end of file diff --git a/ZonePosition.js b/ZonePosition.js index 3d4e905..e4bb0b8 100644 --- a/ZonePosition.js +++ b/ZonePosition.js @@ -12,7 +12,8 @@ Game.prototype.initZones = function () { center: false, width: 259, spacing: 5, - showAmount: true + showAmount: true, + checkable: true }), signiZones: [ new StackZone({ @@ -124,7 +125,8 @@ Game.prototype.initZones = function () { center: false, width: 259, spacing: 5, - showAmount: true + showAmount: true, + checkable: true }), signiZones: [ new StackZone({