1 var BakingOvenObjectClass = function(ownerStage, args){
2 BakingOvenObjectClass.base.apply(this, arguments);
4 this.imgs = new Array();
5 for(var i = 0; i < 3; i++){
6 this.imgs[i] = document.createElement('img');
8 this.imgs[0].src = "images/furnace.png";
9 this.imgs[1].src = "images/furnaceof1.png";
10 this.imgs[2].src = "images/furnaceof2.png";
13 this.img_puff[0] = document.createElement('img');
14 this.img_puff[0].src = "images/puff.png";
15 this.img_puff[1] = document.createElement('img');
16 this.img_puff[1].src = "images/puff2.png";
18 this.cookSound = createAudio("baking.mp3");
19 this.image = this.imgs[0];
22 this.isPhantom = true;
23 this.isSelecting = false;
25 this.bakingTickCount = 0;
27 this.bakingStartTime = -1; //調理開始時に時刻を代入
28 this.isBaking = false;
32 }.extend(BlockClass, {
35 this.checkTouchingDirection();
36 if((this.touchingDirection & CollideBody) == CollideBody){
37 if(this.ownerStage.manager.UIManager.keyState.select && !this.isSelecting){
39 var thatManager = that.ownerStage.manager;
42 if(thatManager.userManager.ingredientList.length <= 0){
43 thatManager.addWidget(new MessageWidgetClass(thatManager, ["手持ちの材料がありません!\n"]));
44 that.isSelecting = false;
46 this.isSelecting = true;
47 thatManager.addWidget(
48 new SelectWidgetClass(thatManager, [thatManager.userManager.ingredientList, function(retv){
51 that.basePoint = that.calculateBreadBasePoint(retv);
52 if(that.basePoint < 0){
53 thatManager.addWidget(new MessageWidgetClass(thatManager, ["見るからにまずそう…焼くのはやめておこう。\n"]));
55 var text = new TextWidgetClass(thatManager, ["焼き始めました!\nもう一度窯を選択すると取り出します。 ", true, true]);
56 thatManager.addWidget(text);
57 that.bakingTickCount = 0;
59 that.bakingStartTime = +new Date(); //時間のミリ秒を代入
61 for(var i = 0, m = retv.length; i < m; i++){
62 removeAnObjectFromArray(thatManager.userManager.ingredientList, retv[i]);
64 that.cookSound.load();
65 that.cookSound.play();
68 thatManager.addWidget(new MessageWidgetClass(thatManager, ["一つも材料が選択されていないので、パンを焼くことができません!\n"]));
71 that.isSelecting = false;
75 } else if(this.bakingCount > 10){
77 this.isSelecting = true;
80 var t = ((+new Date()) - this.bakingStartTime) * (100/16000); //16秒が基準(下の判定の100)
81 var c = this.bakingCount;
110 s = "もはや灰しか残らなかった…。";
113 that.basePoint = Math.floor(p * that.basePoint);
114 thatManager.userManager.breadList.push(that.basePoint);
115 thatManager.addWidget(new MessageWidgetClass(thatManager, [s + that.basePoint + "ポイントのパンをゲットした。\n"]));
116 that.isSelecting = false;
117 that.isBaking = false;
118 this.bakingCount = 0;
119 this.image = this.imgs[0];
120 that.cookSound.pause();
126 this.bakingTickCount++;
127 if(this.bakingTickCount >= 6){
128 this.bakingTickCount = 0;
130 this.image = this.imgs[(this.bakingCount & 1) + 1];
134 calculateBreadBasePoint: function(ingr){
136 for(var i = 0, m = ingr.length; i < m; i++){
137 p += IngredientAttributeList[ingr[i].index][1];
141 draw : function(x, y)
143 BakingOvenObjectClass.base.prototype.draw.apply(this, [x, y]);
145 if(this.bakingCount > 80)
147 var puff = ((+new Date()) - this.bakingStartTime) * (100/16000) - 80;
148 if(puff > 40)puff = 40;
149 var opacity = 0.5 * (puff / 40) + (this.ownerStage.manager.tickCount % 10) / 20;
150 this.ownerStage.mainContext.save();
151 this.ownerStage.mainContext.globalAlpha = opacity;
152 this.ownerStage.mainContext.drawImage(this.img_puff[this.ownerStage.manager.tickCount % 20 < 10 ? 0 : 1], x - 32 , y - 400, 320, 480);
153 this.ownerStage.mainContext.restore();