make enerZone checkable

This commit is contained in:
WEBXOSS 2016-12-08 22:29:15 +08:00
parent 5e8b3a228f
commit 5cf36efc8e
2 changed files with 26 additions and 14 deletions

34
Zone.js
View file

@ -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);
};

View file

@ -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({