Commit 86c15430 authored by rockyl's avatar rockyl

加快钩子速度

parent 262eaeb5
...@@ -10,10 +10,15 @@ export default class TakeFailed extends DialogContent { ...@@ -10,10 +10,15 @@ export default class TakeFailed extends DialogContent {
unit: dynamic unit: dynamic
setup(data) {
super.setup(data);
this.setLabel();
}
setLabel() { setLabel() {
this.label.getComponent(TextRenderer).text = `${this.unit}扣除失败 this.label.getComponent(TextRenderer).text = `${this.unit}扣除失败
别慌张,可以再试一次哟~` 别慌张,可以再试一次哟~`
this.controller.getComponent(Popup).showDialog('TakeFailed')
// this.entity.getChildrenByName('Button')[0].getComponent(BuriedPoint).callSetConfig() // this.entity.getChildrenByName('Button')[0].getComponent(BuriedPoint).callSetConfig()
} }
......
...@@ -25,7 +25,7 @@ enum ElementType { ...@@ -25,7 +25,7 @@ enum ElementType {
Stone = 'Stone' Stone = 'Stone'
} }
const commonSpeedBefore = 280 const commonSpeedBefore = 580
const commonSpeedAfter = 420 const commonSpeedAfter = 420
const slowSpeed = 350 const slowSpeed = 350
...@@ -77,6 +77,7 @@ export default class Game extends InteractComponent { ...@@ -77,6 +77,7 @@ export default class Game extends InteractComponent {
private playable: boolean = true private playable: boolean = true
private clickable: boolean = false private clickable: boolean = false
private blockTextures: any = {};
homeInfo: dynamic homeInfo: dynamic
configInterface: dynamic configInterface: dynamic
...@@ -99,9 +100,22 @@ export default class Game extends InteractComponent { ...@@ -99,9 +100,22 @@ export default class Game extends InteractComponent {
} }
init() { async loadTextures(){
let urls = {
treasure: this.configInterface.indexBoxImg,
stone: this.configInterface.indexBlockImg
};
for(let key in urls){
this.blockTextures[key] = await engine.assetsManager.loadTexture(urls[key]);
}
}
async init() {
this.startRotate() this.startRotate()
await this.loadTextures();
this.copyEntity.getComponent(TextureRenderer).texture = this.blockTextures.treasure;
this.initBox() this.initBox()
const {x, y} = this.Detail.getComponent(Transform).position const {x, y} = this.Detail.getComponent(Transform).position
...@@ -204,7 +218,7 @@ export default class Game extends InteractComponent { ...@@ -204,7 +218,7 @@ export default class Game extends InteractComponent {
// if (box === 6) stoneNum-- // if (box === 6) stoneNum--
const generateEle = (create, box, img, num, left, top, width, height) => { const generateEle = (create, box, img, num, left, top, width, height) => {
const entity = create(box, this.config.getTexture(img), num) const entity = create(box, this.blockTextures[img], num)
const element = this.initElement(entity, left - containerWidth / 2, top - containerHeight / 2, width, height) const element = this.initElement(entity, left - containerWidth / 2, top - containerHeight / 2, width, height)
this.elementList.push(element) this.elementList.push(element)
} }
...@@ -232,24 +246,24 @@ export default class Game extends InteractComponent { ...@@ -232,24 +246,24 @@ export default class Game extends InteractComponent {
} }
if (rowNum === 3 && i === 1) { if (rowNum === 3 && i === 1) {
height = 0 height = 0
generateEle(createStone, this.BoxContainer, 'stone.png', box, left, top, width, height) generateEle(createStone, this.BoxContainer, 'stone', box, left, top, width, height)
continue continue
} }
} }
if (treasureNum > 0 && stoneNum > 0) { if (treasureNum > 0 && stoneNum > 0) {
if (createRandomTreasure()) { if (createRandomTreasure()) {
treasureNum-- treasureNum--
generateEle(createTreasure, this.BoxContainer, 'treasure.png', box, left, top, width, height) generateEle(createTreasure, this.BoxContainer, 'treasure', box, left, top, width, height)
} else { } else {
stoneNum-- stoneNum--
generateEle(createStone, this.BoxContainer, 'stone.png', box, left, top, width, height) generateEle(createStone, this.BoxContainer, 'stone', box, left, top, width, height)
} }
} else if (stoneNum > 0) { } else if (stoneNum > 0) {
stoneNum-- stoneNum--
generateEle(createStone, this.BoxContainer, 'stone.png', box, left, top, width, height) generateEle(createStone, this.BoxContainer, 'stone', box, left, top, width, height)
} else if (treasureNum > 0) { } else if (treasureNum > 0) {
treasureNum-- treasureNum--
generateEle(createTreasure, this.BoxContainer, 'treasure.png', box, left, top, width, height) generateEle(createTreasure, this.BoxContainer, 'treasure', box, left, top, width, height)
} }
} }
}) })
...@@ -379,6 +393,7 @@ export default class Game extends InteractComponent { ...@@ -379,6 +393,7 @@ export default class Game extends InteractComponent {
break break
case 3: case 3:
this.TakeFailed.getComponent(TakeFailed).setLabel() this.TakeFailed.getComponent(TakeFailed).setLabel()
this.popup.showDialog('TakeFailed')
break break
default: default:
this.popup.showDialog('Network') this.popup.showDialog('Network')
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
engine, engine,
resource, resource,
instantiate, instantiate,
dataCenter, Texture,
color, color,
ScillaEvent, ScillaEvent,
LocalStorage LocalStorage
...@@ -96,7 +96,6 @@ export default class start extends ScillaComponent { ...@@ -96,7 +96,6 @@ export default class start extends ScillaComponent {
} }
initEnv() initEnv()
} }
init() { init() {
...@@ -212,7 +211,7 @@ export default class start extends ScillaComponent { ...@@ -212,7 +211,7 @@ export default class start extends ScillaComponent {
} }
private initFirstJoin() { private initFirstJoin() {
const instance = new LocalStorage('miner-tool') const instance = new LocalStorage('miner-tool' + '_' + this.homeInfo.id);
const isFirst = instance.getItem('first') const isFirst = instance.getItem('first')
console.log(isFirst) console.log(isFirst)
if (isFirst === '1') { if (isFirst === '1') {
......
import * as tslib_1 from "tslib";
import TextRenderer from 'components/renderer/TextRenderer';
import Wave from 'components/animation/Wave';
import ScillaComponent from 'components/base/ScillaComponent';
var HelloScilla = (function (_super) {
tslib_1.__extends(HelloScilla, _super);
function HelloScilla() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.name = 'scilla';
return _this;
}
HelloScilla.prototype.onCreate = function () {
_super.prototype.onCreate.call(this);
this.labelRenderer = this.label.getComponent(TextRenderer);
this.logoAnimation = this.logo.getComponent(Wave);
};
HelloScilla.prototype.tapMe = function () {
this.labelRenderer.text = 'Hello ' + this.name;
this.logoAnimation.play();
};
return HelloScilla;
}(ScillaComponent));
export default HelloScilla;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import ScillaComponent from "components/base/ScillaComponent";
import { fade, flew, none, zoom } from "components/other/Popup";
import { decorators } from "scilla";
var dirtyFieldTrigger = decorators.dirtyFieldTrigger;
var DialogContent = (function (_super) {
tslib_1.__extends(DialogContent, _super);
function DialogContent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.effect = PopupEffect.none;
_this.effectImpl = none;
_this.show = function (data, callback) {
console.log('show');
_this.bubbling('showDialog', _this.entity.name, data, callback);
};
_this.hide = function (action) {
_this.bubbling('hideDialog', _this.entity.name, action || 'close');
};
return _this;
}
DialogContent.prototype.onModify = function (value, key, oldValue) {
_super.prototype.onModify.call(this, value, key, oldValue);
if (key === 'effect') {
this.effectImpl = effects[value];
}
};
DialogContent.prototype.onAwake = function () {
_super.prototype.onAwake.call(this);
};
DialogContent.prototype.onTapCloseButton = function () {
this.hide();
};
DialogContent.prototype.setup = function (data) {
};
tslib_1.__decorate([
dirtyFieldTrigger
], DialogContent.prototype, "effect", void 0);
return DialogContent;
}(ScillaComponent));
export default DialogContent;
var effects = {
none: none,
fade: fade,
flew: flew,
zoom: zoom,
};
export var PopupEffect;
(function (PopupEffect) {
PopupEffect["none"] = "none";
PopupEffect["fade"] = "fade";
PopupEffect["flew"] = "flew";
PopupEffect["zoom"] = "zoom";
})(PopupEffect || (PopupEffect = {}));
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import { DialogContent } from 'components/other/Popup';
var Network = (function (_super) {
tslib_1.__extends(Network, _super);
function Network() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Network;
}(DialogContent));
export default Network;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import { DialogContent } from 'components/other/Popup';
var Normal = (function (_super) {
tslib_1.__extends(Normal, _super);
function Normal() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Normal;
}(DialogContent));
export default Normal;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import { DialogContent } from 'components/other/Popup';
import { engine, createTexture } from 'scilla';
import TextRenderer from 'components/renderer/TextRenderer';
import TextureRenderer from 'components/renderer/TextureRenderer';
import Popup from 'components/other/Popup';
var TakeRewards = (function (_super) {
tslib_1.__extends(TakeRewards, _super);
function TakeRewards() {
return _super !== null && _super.apply(this, arguments) || this;
}
TakeRewards.prototype.init = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, _b, popup;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
this.name.getComponent(TextRenderer).text = this.nameText;
_a = this.img.getComponent(TextureRenderer);
_b = createTexture;
return [4, engine.assetsManager.loadImage(this.imgUrl)];
case 1:
_a.texture = _b.apply(void 0, [_c.sent()]);
popup = this.controller.getComponent(Popup);
popup.showDialog('TakeRewards');
return [2];
}
});
});
};
TakeRewards.prototype.onclick = function () {
location.href = this.link;
};
return TakeRewards;
}(DialogContent));
export default TakeRewards;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import { DialogContent } from 'components/other/Popup';
import TextRenderer from 'components/renderer/TextRenderer';
var Tips = (function (_super) {
tslib_1.__extends(Tips, _super);
function Tips() {
return _super !== null && _super.apply(this, arguments) || this;
}
Tips.prototype.setLabel = function (num) {
this.label.getComponent(TextRenderer).text = "\u6BCF\u5C40\u6316\u51FA" + num + "\u4E2A\u5B9D\u7BB1\n\u5373\u6709\u673A\u4F1A\u83B7\u5F97\u5956\u54C1";
};
return Tips;
}(DialogContent));
export default Tips;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import InteractComponent from 'components/base/InteractComponent';
import { countDown, } from '../utils/index';
import { engine, createTween, ease, killTweens } from 'scilla';
import TextRenderer from 'components/renderer/TextRenderer';
import ToolAnimateRotate from './ToolAnimate';
import Transform from 'components/base/Transform';
import { createTreasure } from './Treasure';
import RelativeLayout from 'components/other/RelativeLayout';
import { createStone } from './Stone';
import Treasure from './Treasure';
import TextureRenderer from 'components/renderer/TextureRenderer';
import start, { setTexture, setButton } from '../scenes/start';
import SampleApi from 'components/net/SampleApi';
import { md5 } from 'components/utils/Crypto';
import Popup from 'components/other/Popup';
import SamplePollingApi from 'components/net/SamplePollingApi';
import TakeRewards from '../dialog/TakeRewards';
import Currency from '../dialog/Currency';
import TakeFailed from '../dialog/TakeFailed';
import BuriedPoint from '../utils/BuriedPoint';
var ElementType;
(function (ElementType) {
ElementType["Treasure"] = "Treasure";
ElementType["Stone"] = "Stone";
})(ElementType || (ElementType = {}));
var commonSpeedBefore = 280;
var commonSpeedAfter = 420;
var slowSpeed = 350;
var needToastErr = ['0100017', '0100003', '0100007', '0100015'];
var startPoint = {
dpm: 'app_id.248.2.1',
dcm: '252.oaid.0.0',
};
var waPoint = {
dpm: 'app_id.248.5.1',
dcm: '252.oaid.0.0',
};
var Game = (function (_super) {
tslib_1.__extends(Game, _super);
function Game() {
var _this = _super.call(this) || this;
_this.toolTrAnchorY = 0.88;
_this.ticks = [];
_this.elementList = [];
_this.gameInfo = [];
_this.score = 0;
_this.playable = true;
_this.clickable = false;
_this.doJoinStatus = false;
_this.doJoinRunning = false;
return _this;
}
Game.prototype.onAwake = function () {
_super.prototype.onAwake.call(this);
};
Game.prototype.init = function () {
this.toolTs = this.Tool.getComponent(Transform);
this.toolTr = this.Tool.getComponent(TextureRenderer);
this.toolTrAnchorY = this.toolTr.anchor.y;
this.popup = this.DialogContainer.getComponent(Popup);
this.rotateTick = new ToolAnimateRotate(this.toolTs);
this.startRotate();
this.initBox();
var _a = this.Detail.getComponent(Transform).position, x = _a.x, y = _a.y;
this.ox = x;
this.oy = y;
this.setBtnActionBg(false);
};
Game.prototype.onUpdate = function (t) {
_super.prototype.onUpdate.call(this, t);
this.ticks.forEach(function (tick) { return tick.onTick(t); });
};
Game.prototype.countDown = function (from, to, cb) {
var _this = this;
if (to === void 0) { to = 0; }
this.clearCountDown = countDown(from, to, function (target) {
_this.CountDown.getComponent(TextRenderer).text = target + 's';
}, cb);
};
Game.prototype.setDetail = function (child, isActive, cb, parent) {
if (isActive === void 0) { isActive = false; }
if (this._parent)
parent = this._parent;
else
this._parent = parent;
this.Detail.getComponent(TextRenderer).text = "\u76EE\u6807\uFF1A" + child + "/" + parent + " \u4E2A\u7BB1\u5B50";
if (child >= parent)
cb && cb();
if (isActive) {
createTween(this, this.Target.getComponent(Transform), true)
.to({ scale: { x: 1.2, y: 1.2 } }, 100)
.to({ scale: { x: 1, y: 1 } }, 100);
}
};
Game.prototype.setTitle = function (visible, isDecrease, per, unit, freeTimes) {
if (isDecrease === void 0) { isDecrease = false; }
if (!visible)
return this.Title.enabled = false;
if (!this._per)
this._per = per;
if (!this._unit)
this._unit = unit;
if (!this._freeTimes)
this._freeTimes = freeTimes;
if (isDecrease)
this._freeTimes--;
this.Title.enabled = true;
var title = this.Title.getComponent(TextRenderer);
title.text = this._freeTimes > 0 ? "\u4ECA\u65E5\u514D\u8D39\uFF1A" + this._freeTimes + "\u6B21" : "" + this._per + this._unit + "/\u6B21";
};
Game.prototype.initList = function (box) {
switch (box) {
case 5:
return [3, 3, { ele: 2, iterater: 3 }];
case 6:
return [3, 3, 2, { ele: 2, iterater: 3 }];
case 7:
return [3, 3, 4, { ele: 2, iterater: 3 }];
case 8:
return [3, 4, 4, { ele: 2, iterater: 3 }];
case 9:
return [4, 5, 4, { ele: 2, iterater: 3 }];
case 10:
return [5, 4, 5, { ele: 2, iterater: 3 }];
default:
break;
}
};
Game.prototype.initBox = function () {
var _this = this;
this.elementList = [];
this.BoxContainer.removeChildren();
var box = this.homeInfo.box;
var randomIsTreasure = box / (box + Math.floor(box * 0.6));
var createRandomTreasure = function () {
var len = _this.elementList.length;
if (len >= 2) {
var lastOneType = _this.elementList[len - 1].type;
var lastTwoType = _this.elementList[len - 2].type;
if (lastOneType === lastTwoType)
return lastOneType !== ElementType.Treasure;
}
return randomIsTreasure - Math.random() > 0;
};
var _a = this.BoxContainer.getComponent(Transform), width = _a.width, height = _a.height;
width -= 20;
var list = this.initList(box);
var itemHeight = height / list.length;
var treasureNum = box;
var stoneNum = Math.ceil(box * 0.6);
var generateEle = function (create, box, img, num, left, top, width, height) {
var entity = create(box, _this.config.getTexture(img), num);
var element = _this.initElement(entity, left, top, width, height);
_this.elementList.push(element);
};
list.forEach(function (row, index) {
var rowNum = (typeof row === 'number' ? row : row.iterater);
var itemWidth = Math.floor(width / rowNum);
for (var i = 0; i < rowNum; i++) {
var left = i * itemWidth;
var top = index * itemHeight;
var width_1 = itemWidth;
var height_1 = itemHeight;
if (index === 1) {
if (i === 0) {
left += 20;
}
else if (i === rowNum - 1) {
width_1 -= 20;
}
}
if (i === rowNum - 1)
width_1 -= 20;
if (typeof row === 'object') {
if (row.ele === 2 && i === 1) {
continue;
}
if (rowNum === 3 && i === 1) {
height_1 = 0;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width_1, height_1);
continue;
}
}
if (treasureNum > 0 && stoneNum > 0) {
if (createRandomTreasure()) {
treasureNum--;
generateEle(createTreasure, _this.BoxContainer, 'treasure.png', box, left, top, width_1, height_1);
}
else {
stoneNum--;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width_1, height_1);
}
}
else if (stoneNum > 0) {
stoneNum--;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width_1, height_1);
}
else if (treasureNum > 0) {
treasureNum--;
generateEle(createTreasure, _this.BoxContainer, 'treasure.png', box, left, top, width_1, height_1);
}
}
});
};
Game.prototype.stopRotate = function () {
var _this = this;
var index = this.ticks.findIndex(function (item) { return item === _this.rotateTick; });
this.ticks[index].removeOnTick();
if (index > -1) {
this.ticks.splice(index, 1);
}
};
Game.prototype.startRotate = function () {
this.ticks.push(this.rotateTick);
};
Game.prototype.doJoin = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var sampleApi;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.doJoinRunning = true;
sampleApi = this.Button.getComponent(SampleApi);
return [4, sampleApi.execute()];
case 1:
_a.sent();
return [2];
}
});
});
};
Game.prototype.onError = function (e) {
if (e.name == 'CALL_FAILED') {
var c = this.entity.getComponent(start);
this.popup = this.DialogContainer.getComponent(Popup);
var s = this.entity.getComponent(start);
switch (e.code) {
case '0100000':
c.initLoginProcess(true);
break;
case '0901010':
this.popup.showDialog('NoChance');
break;
case '0901011':
this.CurrencyNotEnough.getComponent(Currency).setLabel();
break;
case '0901012':
case '0901013':
this.popup.showDialog('TakeFailed');
break;
case '0100014':
s.toast('活动已结束\n无法参与');
break;
case '0100016':
s.toast('活动未开始\n暂时无法参与');
break;
case '9999999':
this.popup.showDialog('Network');
break;
case '0100003':
s.toast('无权访问\n该活动');
break;
case '0100007':
s.toast('参数\n不能为空');
break;
case '0100015':
s.toast('活动不存在');
break;
case '0100017':
s.toast('活动已关闭');
break;
default:
this.popup.showDialog('Network');
}
}
else {
this.popup.showDialog('Network');
}
this.doJoinRunning = false;
};
Game.prototype.onGetOrderStatusResponse = function () {
this.doJoinRunning = false;
switch (this.doCredits) {
case 2:
case 4:
this.doJoinStatus = true;
this.onClickStartBtn();
break;
case 3:
this.TakeFailed.getComponent(TakeFailed).setLabel();
break;
default:
this.popup.showDialog('Network');
}
};
Game.prototype.onClickStartBtn = function () {
var _this = this;
this.entity.getComponent(start).endGuide();
if (this.doJoinRunning)
return;
if (!this.doJoinStatus) {
return this.doJoin();
}
if (this.clickable) {
this.onClickActionBtn();
return;
}
if (!this.playable)
return;
this.playable = false;
this.clickable = true;
this.setBtnActionBg(true);
this.setTitle(false);
this.countDown(this.homeInfo.continueTime, 0, function () {
_this.entity.getComponent(start).toast('时间到!');
console.log('game over');
if (_this.toolTr.anchor.y !== _this.toolTrAnchorY) {
killTweens(_this.toolTr);
createTween(_this, _this.toolTr, true)
.to({
anchor: { y: _this.toolTrAnchorY }
}, 500)
.call(function () {
_this.copyEntity.enabled = false;
killTweens(_this.copyEntity.getComponent(Transform));
_this.startRotate();
_this.submit();
});
}
else {
_this.submit();
}
});
};
Game.prototype.reset = function () {
this.playable = true;
this.clickable = false;
this.doJoinStatus = false;
this.setBtnActionBg(false);
this.setTitle(true, true);
this.countDown(this.homeInfo.continueTime, this.homeInfo.continueTime, function () { });
this.initBox();
this.score = 0;
this.setDetail(this.score, false, this.submit.bind(this));
};
Game.prototype.setBtnActionBg = function (bool) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var imgUrl, point;
return tslib_1.__generator(this, function (_a) {
imgUrl = bool ? this.configInterface.indexStartBtnImg : this.configInterface.indexInitBtnImg;
setTexture(this.Button, imgUrl);
setButton(this.Button, imgUrl);
point = bool ? waPoint : startPoint;
this.Button.getComponent(BuriedPoint).setConfig(point.dpm, point.dcm, true);
return [2];
});
});
};
Game.prototype.onClickActionBtn = function () {
var _this = this;
this.clickable = false;
this.stopRotate();
var renderer = this.toolTr;
var result = this.makeLineInGameCenter(this.Tool);
var ts = this.toolTs;
var boxTs = this.BoxContainer.getComponent(Transform);
if (Array.isArray(result)) {
var x = result[0] + boxTs.globalPosition.x;
var y = result[1] + boxTs.globalPosition.y;
var local = ts.globalPositionToLocal({ x: x, y: y });
var distance = generatePointsDistance(ts.position.x, ts.position.y, local.x, local.y);
var per = this.distance2Anchor(distance);
createTween(this, renderer, true)
.to({
anchor: {
y: this.toolTrAnchorY - per
}
}, distance / commonSpeedBefore * 1000)
.to({
anchor: {
y: this.toolTrAnchorY
}
}, distance / 420 * 1000)
.call(function () {
_this.startRotate();
_this.clickable = true;
});
}
else {
var x = result.targetX, y = result.targetY;
x += boxTs.globalPosition.x;
y += boxTs.globalPosition.y;
var local = ts.globalPositionToLocal({ x: x, y: y });
var distance_1 = generatePointsDistance(ts.position.x, ts.position.y, local.x, local.y);
var per = this.distance2Anchor(distance_1);
var index = this.elementList.findIndex(function (item) { return item === result; });
this.elementList.splice(index, 1);
createTween(this, renderer, true)
.to({
anchor: {
y: this.toolTrAnchorY - per
}
}, distance_1 / commonSpeedBefore * 1000)
.call(function () {
if (_this.playable && !_this.clickable)
return;
if (result.type === ElementType.Treasure) {
_this.hitTreasure({ entity: result.entity });
}
else {
_this.hitStone({ entity: result.entity, toolDistance: distance_1 });
}
})
.to({
anchor: {
y: this.toolTrAnchorY
}
}, distance_1 / (result.type === ElementType.Treasure ? commonSpeedAfter : slowSpeed) * 1000, ease.cubicInOut)
.call(function () {
_this.startRotate();
_this.clickable = true;
});
}
};
Game.prototype.distance2Anchor = function (distance) {
return (distance - 100) / this.toolTs.height;
};
Game.prototype.makeLineInGameCenter = function (tool) {
var _this = this;
var ts = tool.getComponent(Transform);
var global = ts.globalPosition;
var boxTs = this.BoxContainer.getComponent(Transform);
var local = boxTs.globalPositionToLocal(global);
var rotation = ts.rotation;
var a;
var PI = Math.PI;
if (rotation < 0) {
a = Math.tan(PI / 2 + rotation / 180 * PI);
}
else {
a = -Math.tan(PI / 2 - rotation / 180 * PI);
}
this._startPoint = [(boxTs.height / (-2) - local.y) / a, boxTs.height / (-2)];
drawTestCircle(this.BoxContainer, this._startPoint[0], this._startPoint[1], '#1153d8');
try {
this.elementList.forEach(function (element) {
var _a = element.entity.getComponent(Transform).position, tsX = _a.x, tsY = _a.y;
var x1 = tsX - element.width / 2;
var y1 = tsY - element.height / 2;
var x2 = x1 + element.width;
var y2 = y1 + element.height;
if (rotation > 0) {
drawTestCircle(_this.BoxContainer, x1, y1, '#000');
drawTestCircle(_this.BoxContainer, x2, y2, '#000');
var x = lineLeft(x1, y1, x2, y2, a, local.y);
drawTestCircle(_this.BoxContainer, x, x * a + local.y, '#fff');
if ((x - x1) * (x - x2) < 0) {
element.targetX = x;
element.targetY = x * a + local.y;
throw element;
}
}
else if (rotation < 0) {
drawTestCircle(_this.BoxContainer, x1, y2, '#000');
drawTestCircle(_this.BoxContainer, x2, y1, '#000');
var x = lineRight(x1, y1, x2, y2, a, local.y);
drawTestCircle(_this.BoxContainer, x, x * a + local.y, '#fff');
if ((x - x1) * (x - x2) < 0) {
element.targetX = x;
element.targetY = x * a + local.y;
throw element;
}
}
else {
if (x1 * x2 < 0) {
element.targetX = 0;
element.targetY = y1;
throw element;
}
}
});
}
catch (ele) {
return ele;
}
return this.hitEdge(function (x) { return a * x + local.y; }, function (y) { return (y - local.y) / a; });
};
Game.prototype.initElement = function (entity, left, top, width, height) {
var tl = entity.getComponent(RelativeLayout);
var ts = entity.getComponent(Transform);
var thisWidth = Math.floor(ts.width * ts.scale.x);
var thisHeight = Math.floor(ts.height * ts.scale.y);
var padding = 30;
var thisLeft = generateRandomDistance(left, width - thisWidth - padding);
var thisTop = generateRandomDistance(top, height - thisHeight - padding);
if (height <= 0) {
ts.scale.x = entity.min;
ts.scale.y = entity.min;
thisTop = top;
thisWidth = Math.floor(ts.width * entity.min);
thisHeight = Math.floor(ts.height * entity.min);
}
if (width <= 0) {
thisLeft = left;
}
tl.left = thisLeft;
tl.top = thisTop;
return {
left: thisLeft,
top: thisTop,
width: thisWidth,
height: thisHeight,
sx: ts.scale.x,
sy: ts.scale.y,
entity: entity,
type: !!entity.getComponent(Treasure) ? ElementType.Treasure : ElementType.Stone,
index: this.elementList.length
};
};
Game.prototype.hitTreasure = function (_a) {
var _this = this;
var entity = _a.entity;
var _ts = entity.getComponent(Transform);
var locationTs = this.Detail.getComponent(Transform);
_ts.alpha = 0;
var global = _ts.globalPosition;
var ts = this.copyEntity.getComponent(Transform);
var _b = ts.scale, ox = _b.x, oy = _b.y;
ts.scale.setXY(_ts.scale.x, _ts.scale.y);
ts.alpha = 1;
this.copyEntity.enabled = true;
var local = locationTs.globalPositionToLocal(global);
ts.position.setXY(local.x, local.y);
var distance = generatePointDistanceToZeroZero(local.x, local.y);
var speed = 400;
var time = Number((distance / speed).toFixed(4)) * 1000;
var _c = ts.scale, sx = _c.x, sy = _c.y;
createTween(this, ts, true, { initFields: ['x', 'alpha'] })
.to({
position: { x: local.x > 50 ? 50 : local.x < -50 ? -50 : 0 },
scale: {
x: sx * 0.7,
y: sy * 0.7
}
}, time - 200)
.to({
position: { x: this.ox, y: this.oy },
scale: { x: sx * 0.5, y: sy * 0.5 },
alpha: 0
}, 200)
.call(function () {
if (_this.playable && !_this.clickable)
return;
_this.setDetail(++_this.score, true, _this.submit.bind(_this));
});
createTween(this, ts, false, { initFields: ['y'] })
.to({
position: { y: this.oy - 50 }
}, time - 200, ease.cubicInOut)
.call(function () { return ts.scale.setXY(ox, oy); });
};
Game.prototype.hitStone = function (_a) {
var entity = _a.entity, toolDistance = _a.toolDistance;
var needLocaltion = this._startPoint;
drawTestCircle(this.BoxContainer, needLocaltion[0], needLocaltion[1], '#1153d8');
var curTs = entity.getComponent(Transform);
var currLocation = curTs.position;
var distance = generatePointsDistance(currLocation.x, currLocation.y, needLocaltion[0], needLocaltion[1]);
createTween(this, curTs, true, { initFields: ['x', 'y'] })
.to({
position: {
x: needLocaltion[0],
y: needLocaltion[1],
}
}, toolDistance / slowSpeed * 1000, ease.cubicInOut)
.to({
alpha: 0,
position: {
x: needLocaltion[0],
y: needLocaltion[1],
}
}, 330);
};
Game.prototype.hitEdge = function (funcFromX, funcFromY) {
var _a = this.BoxContainer.getComponent(Transform), width = _a.width, height = _a.height;
var left = -width / 2;
var right = -1 * left;
var bottom = height / 2;
var top = -1 * bottom;
var YOfLeftFromX = funcFromX(left);
var YOfRightFromX = funcFromX(right);
if (YOfLeftFromX < bottom && YOfLeftFromX > top)
return [left, YOfLeftFromX];
else if (YOfRightFromX < bottom && YOfRightFromX > top)
return [right, YOfRightFromX];
else {
var x = funcFromY(bottom);
return [x, bottom];
}
};
Game.prototype.submit = function () {
this.clearCountDown();
engine.dataCenter.set('custom', 'score', this.score);
engine.dataCenter.set('custom', 'sign', md5("" + engine.dataCenter.get('API', 'doJoin') + this.score));
var submit = this.Target.getComponent(SampleApi);
submit.execute();
};
Game.prototype.onSubmitResponse = function () {
var _this = this;
if (this.submitData) {
var getOrder = this.Target.getComponent(SamplePollingApi);
getOrder.execute();
}
else {
setTimeout(function () {
_this.popup.showDialog('ScoreNotEnough');
}, 300);
}
};
Game.prototype.onGetOrderResponse = function () {
if (this.result.winPrized === 2 || this.result.winPrized === 4) {
this.takeRewards.getComponent(TakeRewards).init();
}
else {
this.popup.showDialog('TakeAgain');
}
};
return Game;
}(InteractComponent));
export default Game;
function generateRandomDistance(min, distance) {
if (distance <= 0)
return min;
return min + Math.floor(Math.random() * distance);
}
function generatePointDistanceToZeroZero(x, y) {
return generatePointsDistance(x, y, 0, 0);
}
function generatePointsDistance(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
}
function drawTestCircle(entity, left, top, color) {
}
function lineLeft(x1, y1, x2, y2, a, b) {
return ((x1 * y2 - x2 * y1) / (x1 - x2) - b) / ((a - ((y2 - y1) / (x2 - x1))));
}
function lineRight(x1, y1, x2, y2, a, b) {
return (b - ((x2 * y2 - x1 * y1) / (x2 - x1))) / ((y2 - y1) / (x1 - x2) - a);
}
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import ScillaComponent from 'components/base/ScillaComponent';
import { Entity } from 'scilla';
import TextureRenderer from 'components/renderer/TextureRenderer';
import RelativeLayout from 'components/other/RelativeLayout';
import Transform from 'components/base/Transform';
var scale;
(function (scale) {
scale[scale["min"] = 0.5] = "min";
scale[scale["max"] = 0.7] = "max";
})(scale || (scale = {}));
function generateRandomScale() {
return Number((Math.random() * 0.2 + scale.min).toFixed(2));
}
var Stone = (function (_super) {
tslib_1.__extends(Stone, _super);
function Stone(entity, texture) {
var _this = _super.call(this) || this;
_this.entity = entity;
_this.ts = new Transform();
_this.tx = new TextureRenderer();
_this.rl = new RelativeLayout();
_this.entity.addComponent(_this.ts);
_this.entity.addComponent(_this.tx);
_this.entity.addComponent(_this.rl);
var scale = generateRandomScale();
_this.ts.scale.setXY(scale, scale);
_this.rl.once = false;
_this.tx.texture = texture;
return _this;
}
Stone.prototype.onAwake = function () {
};
Stone.prototype.destory = function () {
this.enabled = false;
};
return Stone;
}(ScillaComponent));
export default Stone;
export function createStone(parent, texture) {
var entity = new Entity();
parent.addChild(entity);
entity.addComponent(new Stone(entity, texture));
return entity;
}
//# sourceMappingURL=module.js.map
\ No newline at end of file
var constant;
(function (constant) {
constant[constant["rotate"] = 60] = "rotate";
constant[constant["absMaxValue"] = 70] = "absMaxValue";
})(constant || (constant = {}));
var ToolAnimateRotate = (function () {
function ToolAnimateRotate(ts) {
this.forwards = 1;
this.ts = ts;
}
ToolAnimateRotate.prototype.onTick = function (t) {
if (this.lastT === undefined) {
return this.lastT = t;
}
var v = this.forwards * Math.floor(t - this.lastT) / 1000 * constant.rotate + this.ts.rotation;
if (Math.abs(v) >= constant.absMaxValue) {
v = this.forwards * constant.absMaxValue;
this.forwards *= -1;
}
this.ts.rotation = v;
this.lastT = t;
};
return ToolAnimateRotate;
}());
export default ToolAnimateRotate;
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import ScillaComponent from 'components/base/ScillaComponent';
import { Entity } from 'scilla';
import TextureRenderer from 'components/renderer/TextureRenderer';
import RelativeLayout from 'components/other/RelativeLayout';
import Transform from 'components/base/Transform';
var scale;
(function (scale) {
scale[scale["min"] = 0.5] = "min";
scale[scale["max"] = 0.7] = "max";
})(scale || (scale = {}));
function generateRandomScale() {
return Number((Math.random() * 0.2 + scale.min).toFixed(2));
}
var Treasure = (function (_super) {
tslib_1.__extends(Treasure, _super);
function Treasure(entity, texture) {
var _this = _super.call(this) || this;
_this.entity = entity;
_this.ts = new Transform();
_this.tx = new TextureRenderer();
_this.rl = new RelativeLayout();
_this.entity.addComponent(_this.ts);
_this.entity.addComponent(_this.tx);
_this.entity.addComponent(_this.rl);
var scale = generateRandomScale();
_this.ts.scale.setXY(scale, scale);
_this.rl.once = false;
_this.tx.texture = texture;
return _this;
}
Treasure.prototype.onAwake = function () {
};
Treasure.prototype.destory = function () {
this.enabled = false;
};
return Treasure;
}(ScillaComponent));
export default Treasure;
export function createTreasure(parent, texture) {
var entity = new Entity();
parent.addChild(entity);
entity.addComponent(new Treasure(entity, texture));
entity.enabled = true;
return entity;
}
//# sourceMappingURL=module.js.map
\ No newline at end of file
import * as tslib_1 from "tslib";
import ScillaComponent from 'components/base/ScillaComponent';
import { createTween, killTweens, engine, instantiate, ScillaEvent, LocalStorage } from 'scilla';
import Toast from 'components/other/Toast';
import Game from '../game/Game';
import Transform from 'components/base/Transform';
import RelativeLayout from 'components/other/RelativeLayout';
import RectRenderer from 'components/renderer/RectRenderer';
import TextureRenderer from 'components/renderer/TextureRenderer';
import Button from 'components/ui/Button';
import TextRenderer from 'components/renderer/TextRenderer';
import HtmlRenderer from 'components/renderer/HtmlRenderer';
import Popup from 'components/other/Popup';
import Tips from '../dialog/Tips';
import BuriedPoint, { initEnv } from '../utils/BuriedPoint';
engine.dataCenter.register('CFG');
engine.dataCenter.setBatch('CFG', window['CFG']);
var ActStatus;
(function (ActStatus) {
ActStatus[ActStatus["before"] = 0] = "before";
ActStatus[ActStatus["running"] = 1] = "running";
ActStatus[ActStatus["after"] = 2] = "after";
})(ActStatus || (ActStatus = {}));
var start = (function (_super) {
tslib_1.__extends(start, _super);
function start() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.playable = false;
_this.configError = false;
_this.loginStatus = false;
return _this;
}
start.prototype.onCreate = function () {
_super.prototype.onCreate.call(this);
this.popup = this.DialogContainer.getComponent(Popup);
if (navigator.userAgent.match(/iphone|ipad/gi)) {
this.Apple.enabled = true;
}
initEnv();
};
start.prototype.init = function () {
try {
engine.dataCenter.set('CFG', 'appId', this.homeInfo.appId);
engine.dataCenter.set('CFG', 'oaId', engine.dataCenter.get('CFG', 'opId'));
var config = JSON.parse(this.homeInfo.interfaceConfig);
console.log(config);
engine.dataCenter.register('custom');
engine.dataCenter.set('custom', 'config', config);
this.initUI(config, this.homeInfo.prizeList);
}
catch (err) {
console.log('interfaceConfig json parse error.');
return this.toastConfigError();
}
this.initBuriedPoint();
if (!this.setTitle(this.homeInfo.title))
return;
if (!this.homeInfo.rule ||
!this.homeInfo.prizeUrl ||
isUndefinedOrNull(this.homeInfo.box) ||
isUndefinedOrNull(this.homeInfo.continueTime) ||
isUndefinedOrNull(this.homeInfo.credits) ||
isUndefinedOrNull(this.homeInfo.unit) ||
isUndefinedOrNull(this.homeInfo.remainedFreeTimes)) {
this.toastConfigError();
console.log('rule || prizeUrl || box || continueTime || credits || remainedFreeTimes || unit has not config.');
return;
}
this.game.setDetail(0, false, function () {
}, this.homeInfo.box);
this.game.countDown(this.homeInfo.continueTime, this.homeInfo.continueTime, function () {
});
this.game.setTitle(true, false, this.homeInfo.credits, this.homeInfo.unit, this.homeInfo.remainedLimitTimes === null ? this.homeInfo.remainedFreeTimes : Math.min(this.homeInfo.remainedFreeTimes, this.homeInfo.remainedLimitTimes));
this.game.init();
if (!this.initActStatus())
return;
if (!this.initLoginProcess())
return;
if (!this.initFirstJoin())
return;
};
start.prototype.initLoginProcess = function (force) {
var _this = this;
if (force === void 0) { force = false; }
this.loginStatus = this.homeInfo && this.homeInfo.login;
if (!(this.homeInfo && this.homeInfo.login) || force) {
var btn = this.UnLogin.getChildrenByName('Button')[0];
if (typeof window['requireLogin'] !== 'function' && !this.homeInfo.loginUrl) {
btn.children[0].getComponent(TextRenderer).text = '知道啦';
}
else {
var btnc = btn.getComponent(Button);
var click = new ScillaEvent();
click.addListener(function () {
if (typeof window['requireLogin'] === 'function') {
window['requireLogin']();
}
else {
location.href = _this.homeInfo.loginUrl;
}
});
btnc.onClick = click;
}
this.callOnNextTick(function () { return _this.popup.showDialog('UnLogin'); });
return false;
}
return true;
};
start.prototype.initBuriedPoint = function () {
var ruleBuried = this.rulesBg.getComponent(BuriedPoint);
ruleBuried.enabled = true;
ruleBuried.callSetConfig();
var rewardsBtnBgBuried = this.rewardsBtnBg.getComponent(BuriedPoint);
rewardsBtnBgBuried.enabled = true;
rewardsBtnBgBuried.callSetConfig();
};
start.prototype.initActStatus = function () {
if (!(this.homeInfo.startTime && this.homeInfo.endTime)) {
console.log('startTime || endTime has not config.');
this.toastConfigError();
return false;
}
if (+new Date() < this.homeInfo.startTime) {
this.actStatus = ActStatus.before;
}
else if (+new Date() < this.homeInfo.endTime) {
this.actStatus = ActStatus.running;
}
else {
this.actStatus = ActStatus.after;
}
return true;
};
start.prototype.initFirstJoin = function () {
var instance = new LocalStorage('miner-tool');
var isFirst = instance.getItem('first');
console.log(isFirst);
if (isFirst === '1') {
return false;
}
else {
this.NewTips.getComponent(Tips).setLabel(this.homeInfo.box);
instance.setItem('first', '1');
return true;
}
};
start.prototype.initUI = function (config, rewards) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
setTexture.call(this, this.background, config.indexBackBgImg);
setTexture.call(this, this.banner, config.indexBannerImg);
setTexture.call(this, this.targetBg, config.indexGoalBgImg);
setTexture.call(this, this.frontBg, config.indexFrontBgImg);
setTexture.call(this, this.rewardsBg, config.indexPrizeBgImg);
setTexture.call(this, this.btnBg, config.indexInitBtnImg);
setButton.call(this, this.btnBg, config.indexInitBtnImg);
setTexture.call(this, this.rewardsBtnBg, config.indexPrizeImg);
setButton.call(this, this.rewardsBtnBg, config.indexPrizeImg);
setTexture.call(this, this.rulesBg, config.indexRuleImg);
setButton.call(this, this.rulesBg, config.indexRuleImg);
setPopUi.call(this, [this.NoChance, this.Rule, this.TakeRewards, this.TakeFailed, this.NewTips, this.CurrencyNotEnough, this.TakeAgain, this.ScoreNotEnough, this.Network, this.UnLogin], config.popBgColor, config.popTitleColor, config.popBtnImg, config.popPrizeTextColor, config.popBtnTextColor);
this.initRewardsList(rewards);
return [2];
});
});
};
start.prototype.onGotResponse = function () {
};
start.prototype.onReset = function () {
};
start.prototype.onAwake = function () {
this.game = this.entity.getComponent(Game);
this.circleOneTs = this.circleOne.getComponent(Transform);
this.circleTwoTs = this.circleTwo.getComponent(Transform);
this.handleTs = this.handle.getComponent(Transform);
this.startGuide();
};
start.prototype.toast = function (str) {
var toast = this.toastContainer.getComponent(Toast);
toast.show({ content: str });
};
start.prototype.toastConfigError = function () {
this.popup.showDialog('Network');
this.configError = true;
};
start.prototype.startGuide = function () {
this.circleOne.enabled = true;
this.circleTwo.enabled = true;
this.handle.enabled = true;
createTween(this, this.handleTs, true, { loop: -1 })
.set({ opacity: 0, scale: { x: 1, y: 1 } })
.to({ opacity: 1 }, 100)
.to({ scale: { x: 0.8, y: 0.8 } }, 100)
.to({ scale: { x: 1, y: 1 } }, 100)
.wait(330);
createTween(this, this.circleOneTs, true, { loop: -1 })
.set({ alpha: 0, scale: { x: 0.5, y: 0.5 } })
.wait(200)
.set({ alpha: 1 })
.to({ scale: { x: 1.1, y: 1.1 } }, 133)
.to({ scale: { x: 1.5, y: 1.5 }, alpha: 0 }, 67)
.wait(230);
createTween(this, this.circleTwoTs, true, { loop: -1 })
.set({ alpha: 0, scale: { x: 0.5, y: 0.5 } })
.wait(300)
.set({ alpha: 1 })
.to({ scale: { x: 1.1, y: 1.1 } }, 133)
.to({ scale: { x: 1.5, y: 1.5 }, alpha: 0 }, 67)
.wait(130);
};
start.prototype.endGuide = function () {
this.circleOne.enabled = false;
this.circleTwo.enabled = false;
this.handle.enabled = false;
killTweens(this.circleOneTs);
killTweens(this.circleTwoTs);
killTweens(this.handleTs);
};
start.prototype.isRunning = function () {
if (this.actStatus === ActStatus.running) {
return true;
}
else {
this.toast(this.actStatus === ActStatus.before ? '活动未开始\n暂时无法参与' : '活动已结束\n无法参与');
return false;
}
};
start.prototype.setTitle = function (title) {
if (!title) {
console.log('title has not config');
this.toastConfigError();
return false;
}
document.title = title;
return true;
};
start.prototype.linkToRecordUrl = function () {
if (!this.loginStatus) {
this.popup.showDialog('UnLogin');
return;
}
if (this.configError)
return;
if (this.isRunning())
location.href = this.homeInfo.prizeUrl;
};
start.prototype.showRule = function () {
var _this = this;
if (this.configError)
return;
if (this.isRunning()) {
var entity = this.Rule.getChildrenByName('Entity')[0];
var htmlRenderer = entity.getComponent(HtmlRenderer);
htmlRenderer.htmlText = this.homeInfo.rule;
this.callOnNextTick(function () { return _this.popup.showDialog('Rule'); });
}
};
start.prototype.initRewardsList = function (rewardsList) {
var _this = this;
this.rewardsContainer.getComponent(RectRenderer).width = 150 * rewardsList.length;
this.rewardsContainer.removeChildren();
rewardsList.forEach(function (item, index) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var entity, _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
entity = instantiate(this.rewardsItem);
entity.enabled = true;
entity.getComponent(RelativeLayout).left = index * 150;
this.rewardsContainer.addChild(entity);
_a = entity.children[0].getComponent(TextureRenderer);
return [4, engine.assetsManager.loadTexture(item.img)];
case 1:
_a.texture = _b.sent();
entity.children[1].getComponent(TextRenderer).text = item.title;
return [2];
}
});
}); });
};
return start;
}(ScillaComponent));
export default start;
export function setTexture(entity, imgUrl) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var texture;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, engine.assetsManager.loadTexture(imgUrl)];
case 1:
texture = _a.sent();
entity.getComponent(TextureRenderer).texture = texture;
return [2];
}
});
});
}
export function setButton(entity, imgUrl) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var texture;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, engine.assetsManager.loadTexture(imgUrl)];
case 1:
texture = _a.sent();
entity.getComponent(Button).upRes = texture;
return [2];
}
});
});
}
function setPopUi(list, bgColor, fontColor, btnBg, titleColor, btnFontColor) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
this.Rule.getChildrenByName('Entity')[0].getComponent(HtmlRenderer).color = fontColor;
list.forEach(function (entity) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var btn, btnC, texture, text;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
entity.getComponent(RectRenderer).fillColor = bgColor;
btn = entity.getChildrenByName('Button')[0];
if (!btn) return [3, 2];
btnC = btn.getComponent(Button);
return [4, engine.assetsManager.loadTexture(btnBg)];
case 1:
texture = _a.sent();
btnC.upRes = texture;
btn.getComponent(TextureRenderer).texture = texture;
btn.getChildrenByName('label')[0].getComponent(TextRenderer).fillColor = btnFontColor;
_a.label = 2;
case 2:
entity.getChildrenByName('Label').forEach(function (label) {
label.getComponent(TextRenderer).fillColor = fontColor;
});
text = entity.getChildrenByName('Text')[0];
if (text) {
text.getComponent(TextRenderer).fillColor = titleColor;
}
return [2];
}
});
}); });
return [2];
});
});
}
function isUndefinedOrNull(target) {
return target === undefined || target === null;
}
//# sourceMappingURL=module.js.map
\ No newline at end of file
export function countDown(from, to, onChange, onComplete) {
var current = from;
onChange(current);
var timer = setInterval(function () {
if (current <= to) {
clearInterval(timer);
onComplete(to);
}
else {
onChange(--current);
}
}, 1000);
}
//# sourceMappingURL=module.js.map
\ No newline at end of file
...@@ -9736,7 +9736,7 @@ ...@@ -9736,7 +9736,7 @@
return true; return true;
}; };
start.prototype.initFirstJoin = function () { start.prototype.initFirstJoin = function () {
var instance = new LocalStorage('miner-tool'); var instance = new LocalStorage('miner-tool' + '_' + this.homeInfo.id);
var isFirst = instance.getItem('first'); var isFirst = instance.getItem('first');
console.log(isFirst); console.log(isFirst);
if (isFirst === '1') { if (isFirst === '1') {
...@@ -10202,9 +10202,12 @@ ...@@ -10202,9 +10202,12 @@
function TakeFailed() { function TakeFailed() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
TakeFailed.prototype.setup = function (data) {
_super.prototype.setup.call(this, data);
this.setLabel();
};
TakeFailed.prototype.setLabel = function () { TakeFailed.prototype.setLabel = function () {
this.label.getComponent(TextRenderer).text = this.unit + "\u6263\u9664\u5931\u8D25\n \u522B\u614C\u5F20\uFF0C\u53EF\u4EE5\u518D\u8BD5\u4E00\u6B21\u54DF~"; this.label.getComponent(TextRenderer).text = this.unit + "\u6263\u9664\u5931\u8D25\n \u522B\u614C\u5F20\uFF0C\u53EF\u4EE5\u518D\u8BD5\u4E00\u6B21\u54DF~";
this.controller.getComponent(Popup).showDialog('TakeFailed');
}; };
return TakeFailed; return TakeFailed;
}(DialogContent)); }(DialogContent));
...@@ -10214,7 +10217,7 @@ ...@@ -10214,7 +10217,7 @@
ElementType["Treasure"] = "Treasure"; ElementType["Treasure"] = "Treasure";
ElementType["Stone"] = "Stone"; ElementType["Stone"] = "Stone";
})(ElementType || (ElementType = {})); })(ElementType || (ElementType = {}));
var commonSpeedBefore = 280; var commonSpeedBefore = 580;
var commonSpeedAfter = 420; var commonSpeedAfter = 420;
var slowSpeed = 350; var slowSpeed = 350;
var startPoint = { var startPoint = {
...@@ -10236,6 +10239,7 @@ ...@@ -10236,6 +10239,7 @@
_this.score = 0; _this.score = 0;
_this.playable = true; _this.playable = true;
_this.clickable = false; _this.clickable = false;
_this.blockTextures = {};
_this.doJoinStatus = false; _this.doJoinStatus = false;
_this.doJoinRunning = false; _this.doJoinRunning = false;
return _this; return _this;
...@@ -10248,13 +10252,58 @@ ...@@ -10248,13 +10252,58 @@
this.popup = this.DialogContainer.getComponent(Popup); this.popup = this.DialogContainer.getComponent(Popup);
this.rotateTick = new ToolAnimateRotate(this.toolTs); this.rotateTick = new ToolAnimateRotate(this.toolTs);
}; };
Game.prototype.loadTextures = function () {
return __awaiter(this, void 0, void 0, function () {
var urls, _a, _b, _i, key, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
urls = {
treasure: this.configInterface.indexBoxImg,
stone: this.configInterface.indexBlockImg
};
_a = [];
for (_b in urls)
_a.push(_b);
_i = 0;
_e.label = 1;
case 1:
if (!(_i < _a.length)) return [3, 4];
key = _a[_i];
_c = this.blockTextures;
_d = key;
return [4, engine.assetsManager.loadTexture(urls[key])];
case 2:
_c[_d] = _e.sent();
_e.label = 3;
case 3:
_i++;
return [3, 1];
case 4: return [2];
}
});
});
};
Game.prototype.init = function () { Game.prototype.init = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, x, y;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this.startRotate(); this.startRotate();
return [4, this.loadTextures()];
case 1:
_b.sent();
this.copyEntity.getComponent(TextureRenderer).texture = this.blockTextures.treasure;
this.initBox(); this.initBox();
var _a = this.Detail.getComponent(Transform).position, x = _a.x, y = _a.y; _a = this.Detail.getComponent(Transform).position, x = _a.x, y = _a.y;
this.ox = x; this.ox = x;
this.oy = y; this.oy = y;
this.setBtnActionBg(false); this.setBtnActionBg(false);
return [2];
}
});
});
}; };
Game.prototype.onUpdate = function (t) { Game.prototype.onUpdate = function (t) {
_super.prototype.onUpdate.call(this, t); _super.prototype.onUpdate.call(this, t);
...@@ -10338,7 +10387,7 @@ ...@@ -10338,7 +10387,7 @@
var treasureNum = box; var treasureNum = box;
var stoneNum = Math.ceil(box * 0.6); var stoneNum = Math.ceil(box * 0.6);
var generateEle = function (create, box, img, num, left, top, width, height) { var generateEle = function (create, box, img, num, left, top, width, height) {
var entity = create(box, _this.config.getTexture(img), num); var entity = create(box, _this.blockTextures[img], num);
var element = _this.initElement(entity, left - containerWidth / 2, top - containerHeight / 2, width, height); var element = _this.initElement(entity, left - containerWidth / 2, top - containerHeight / 2, width, height);
_this.elementList.push(element); _this.elementList.push(element);
}; };
...@@ -10366,27 +10415,27 @@ ...@@ -10366,27 +10415,27 @@
} }
if (rowNum === 3 && i === 1) { if (rowNum === 3 && i === 1) {
height = 0; height = 0;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width, height); generateEle(createStone, _this.BoxContainer, 'stone', box, left, top, width, height);
continue; continue;
} }
} }
if (treasureNum > 0 && stoneNum > 0) { if (treasureNum > 0 && stoneNum > 0) {
if (createRandomTreasure()) { if (createRandomTreasure()) {
treasureNum--; treasureNum--;
generateEle(createTreasure, _this.BoxContainer, 'treasure.png', box, left, top, width, height); generateEle(createTreasure, _this.BoxContainer, 'treasure', box, left, top, width, height);
} }
else { else {
stoneNum--; stoneNum--;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width, height); generateEle(createStone, _this.BoxContainer, 'stone', box, left, top, width, height);
} }
} }
else if (stoneNum > 0) { else if (stoneNum > 0) {
stoneNum--; stoneNum--;
generateEle(createStone, _this.BoxContainer, 'stone.png', box, left, top, width, height); generateEle(createStone, _this.BoxContainer, 'stone', box, left, top, width, height);
} }
else if (treasureNum > 0) { else if (treasureNum > 0) {
treasureNum--; treasureNum--;
generateEle(createTreasure, _this.BoxContainer, 'treasure.png', box, left, top, width, height); generateEle(createTreasure, _this.BoxContainer, 'treasure', box, left, top, width, height);
} }
} }
}); });
...@@ -10512,6 +10561,7 @@ ...@@ -10512,6 +10561,7 @@
break; break;
case 3: case 3:
this.TakeFailed.getComponent(TakeFailed).setLabel(); this.TakeFailed.getComponent(TakeFailed).setLabel();
this.popup.showDialog('TakeFailed');
break; break;
default: default:
this.popup.showDialog('Network'); this.popup.showDialog('Network');
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
}, },
"entryScene": "main" "entryScene": "main"
}, },
"webServiceUrl": "" "webServiceUrl": "http://localhost:3000"
}, },
"dataCenterConfig": { "dataCenterConfig": {
"dataCenterRoot": [ "dataCenterRoot": [
......
{"/Users/firefly/duiba/demoList/minner-tool/assets/scripts/HelloScilla.ts":1561020169937.0137,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/HelloScilla.ts":1561020169937.0137,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/DialogContent.ts":1561600311985.8552,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Network.ts":1561600425062.0408,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Normal.ts":1562566682279.367,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Tips.ts":1563342864232.2847,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/TakeRewards.ts":1561604368987.917,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/scenes/start.ts":1563414744765.5208,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Game.ts":1563517294108.954,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/utils/index.ts":1561701943800.5488,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/ToolAnimate.ts":1562061481431.2627,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Treasure.ts":1562036486693.9104,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Stone.ts":1562036497419.1833,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Currency.ts":1562576376017.156,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/TakeFailed.ts":1562567908671.4026,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/utils/BuriedPoint.ts":1562566605218.4138,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Currency.ts":1563759198037.1516,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Normal.ts":1563759198037.4158,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/TakeFailed.ts":1563759198037.7097,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/TakeRewards.ts":1563759198037.9731,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Tips.ts":1563759198038.2512,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Game.ts":1563878060701.6638,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Stone.ts":1563877946954.2656,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/ToolAnimate.ts":1563759198039.2769,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Treasure.ts":1563877946951.9539,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/scenes/start.ts":1563870901625.6755,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/utils/BuriedPoint.ts":1563759198040.374,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/utils/index.ts":1563759198040.6511} {"/Users/firefly/duiba/demoList/minner-tool/assets/scripts/HelloScilla.ts":1561020169937.0137,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/HelloScilla.ts":1561020169937.0137,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/DialogContent.ts":1561600311985.8552,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Network.ts":1561600425062.0408,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Normal.ts":1562566682279.367,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Tips.ts":1563342864232.2847,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/TakeRewards.ts":1561604368987.917,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/scenes/start.ts":1563414744765.5208,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Game.ts":1563517294108.954,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/utils/index.ts":1561701943800.5488,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/ToolAnimate.ts":1562061481431.2627,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Treasure.ts":1562036486693.9104,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/game/Stone.ts":1562036497419.1833,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/Currency.ts":1562576376017.156,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/dialog/TakeFailed.ts":1562567908671.4026,"/Users/firefly/duiba/demoList/miner-tool/assets/scripts/utils/BuriedPoint.ts":1562566605218.4138,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Currency.ts":1563759198037.1516,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Normal.ts":1563759198037.4158,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/TakeFailed.ts":1563942766706.9917,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/TakeRewards.ts":1563759198037.9731,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/dialog/Tips.ts":1563759198038.2512,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Game.ts":1563967580359.461,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Stone.ts":1563877946954.2656,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/ToolAnimate.ts":1563759198039.2769,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/game/Treasure.ts":1563877946951.9539,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/scenes/start.ts":1563958374197.611,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/utils/BuriedPoint.ts":1563759198040.374,"/Users/rockyl/WorkSpaces/scilla-projects/minner-tool/assets/scripts/utils/index.ts":1563759198040.6511}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment