mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-09 09:15:43 +08:00
commitb421082374Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Dec 31 20:26:20 2021 +0800 update specialthanks commit765a69294bAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 19:10:03 2021 +0800 fix ios goto commit8eb8c3ca72Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 19:03:37 2021 +0800 add event grade commitab705dd46cAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:48:42 2021 +0800 build version commita1e4232369Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:47:05 2021 +0800 change talent replace before property allocate commitf4d7b3ae3cAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:06:18 2021 +0800 add event grade commit0567e40ddcAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 21:28:10 2021 +0800 add particle commitf17003925eAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 20:14:26 2021 +0800 change ui commitf8beda1d8fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 19:08:30 2021 +0800 change popup message ui commit915a2aa17dAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 18:34:29 2021 +0800 new build commitb5edabc104Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 18:18:46 2021 +0800 add hint message commita143feadafAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 17:57:31 2021 +0800 fix copy bug commiteab1975791Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 17:56:28 2021 +0800 add save/load commitacf9b92134Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 14:35:33 2021 +0800 add theme switch commit488a6054abAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Dec 1 18:30:36 2021 +0800 fix uiManager bug commitf0317eaf14Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Dec 1 16:07:03 2021 +0800 add message popup commiteb02d1ee6fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 21:22:54 2021 +0800 change relocation commit60503eae47Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:27:16 2021 +0800 change ScaleButton -> Laya.runtime.ScaleButton commit52ef5909c1Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:26:31 2021 +0800 change ScaleButton -> Laya.runtime.ScaleButton commit0284f6aa71Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:05:24 2021 +0800 config webpack commit0e272ffd99Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 13:17:41 2021 +0800 add thanks commite1e2ab4701Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 11:40:21 2021 +0800 add light theme commit4f55c00f86Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 27 22:27:39 2021 +0800 fix bug commit1d07bdfc46Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 27 21:48:47 2021 +0800 daily update commit52d6a0ca8fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Nov 24 23:10:04 2021 +0800 daily update commitf8dd720d4dAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Nov 24 19:08:13 2021 +0800 daily update commitd088c1a862Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 21 21:41:46 2021 +0800 remove useless commita711fcf3edAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Nov 16 00:53:05 2021 +0800 add achievement popup add page adaptive add talent extends commit05e02de3dbAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 13 01:24:04 2021 +0800 add github and discord commitbff0109cc5Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 13 00:30:01 2021 +0800 add trajectory auto mode commit54c04f65c2Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Nov 12 19:54:31 2021 +0800 fix property judge negative number bug commit660739530bAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Nov 12 19:48:58 2021 +0800 update achievement commitc94e9e7433Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Nov 11 21:37:45 2021 +0800 update daily commitc06cd9ea62Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Nov 9 00:08:05 2021 +0800 update daily commit2666983f89Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 7 23:00:22 2021 +0800 add uiManager auto scan and load skin resource commit22fa5d755aAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 7 22:17:04 2021 +0800 update framework commitf40698d63eAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Oct 31 00:13:22 2021 +0800 add laya
143 lines
4.5 KiB
JavaScript
143 lines
4.5 KiB
JavaScript
export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
|
|
constructor() {
|
|
super();
|
|
let pos1 = [0, 0];
|
|
this.panelTrajectory.on(Laya.Event.MOUSE_DOWN, this, e => pos1 = [e.stageX, e.stageY]);
|
|
this.panelTrajectory.on(Laya.Event.MOUSE_UP, this, e => {
|
|
const distanceX = e.stageX - pos1[0];
|
|
const distanceY = e.stageY - pos1[1];
|
|
if(Math.sqrt(Math.abs(distanceX) + Math.abs(distanceY)) > 10) {
|
|
return;
|
|
}
|
|
this.onNext();
|
|
});
|
|
this.btnSummary.on(Laya.Event.CLICK, this, this.onSummary);
|
|
|
|
this.panelTrajectory.vScrollBar.elasticDistance = 150;
|
|
this.scbSpeed.on(Laya.Event.CHANGE, this, () => this.speed = this.scbSpeed.value);
|
|
this.scbSpeed.on(Laya.Event.MOUSE_UP, this, () => this.onNext());
|
|
}
|
|
|
|
#speed;
|
|
#auto;
|
|
|
|
static load() {
|
|
return [
|
|
"images/atlas/images/progress.atlas",
|
|
'images/atlas/images/slider.atlas',
|
|
];
|
|
}
|
|
|
|
static #createComponent = Laya.plugin.extractComponents(Trajectory.uiView, ['boxTrajectoryItem']);
|
|
#createTrajectoryItem() {
|
|
const item = Trajectory.#createComponent('boxTrajectoryItem');
|
|
item.labContent = item.getChildByName('labContent');
|
|
item.labAge = item.getChildByName('hboxAge').getChildByName('labAge');
|
|
const config = $ui.common.trajectoryItem;
|
|
$_.deepMapSet(item, config.box);
|
|
item.grade = grade => {
|
|
$_.deepMapSet(item, config.grade[grade || 0]);
|
|
}
|
|
item.getChildByName('hboxAge')._childs.forEach(child => child.color = config.ageColor);
|
|
item.labContent.color = config.contentColor;
|
|
return item;
|
|
}
|
|
#isEnd;
|
|
#trajectoryItems;
|
|
#talents;
|
|
|
|
init({propertyAllocate, talents}) {
|
|
this.boxParticle.visible = false;
|
|
this.boxSpeed.visible = true;
|
|
this.btnSummary.visible = false;
|
|
this.#trajectoryItems = [];
|
|
this.#isEnd = false;
|
|
this.#talents = talents;
|
|
core.start(propertyAllocate);
|
|
this.updateProperty();
|
|
this.onNext();
|
|
}
|
|
|
|
close() {
|
|
this.scbSpeed.value = 0;
|
|
this.speed = 0;
|
|
this.#trajectoryItems.forEach(item => {
|
|
item.removeSelf();
|
|
item.destroy();
|
|
});
|
|
this.#trajectoryItems = null;
|
|
}
|
|
|
|
updateProperty() {
|
|
const types = core.PropertyTypes;
|
|
const propertys = core.propertys;
|
|
|
|
this.labCharm.text = propertys[types.CHR];
|
|
this.labIntelligence.text = propertys[types.INT];
|
|
this.labStrength.text = propertys[types.STR];
|
|
this.labMoney.text = propertys[types.MNY];
|
|
this.labSpirit.text = propertys[types.SPR];
|
|
}
|
|
|
|
onNext() {
|
|
if(this.#isEnd) return;
|
|
|
|
const { age, content, isEnd } = core.next();
|
|
this.#isEnd = isEnd;
|
|
|
|
if(isEnd) {
|
|
this.boxSpeed.visible = false;
|
|
this.btnSummary.visible = true;
|
|
}
|
|
|
|
this.renderTrajectory(age, content);
|
|
|
|
if(age >= 100) {
|
|
this.boxParticle.visible = true;
|
|
}
|
|
Laya.timer.frameOnce(1, this, () => {
|
|
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
|
});
|
|
this.updateProperty();
|
|
}
|
|
|
|
renderTrajectory(age, content) {
|
|
const item = this.#createTrajectoryItem();
|
|
item.labAge.text = ''+age;
|
|
item.labContent.text = content.map(
|
|
({type, description, grade, name, postEvent}) => {
|
|
switch(type) {
|
|
case 'TLT':
|
|
return `天赋【${name}】发动:${description}`;
|
|
case 'EVT':
|
|
return description + (postEvent?`\n${postEvent}`:'');
|
|
}
|
|
}
|
|
).join('\n');
|
|
item.grade(content[content.length - 1].grade);
|
|
this.vboxTrajectory.addChild(item);
|
|
this.#trajectoryItems.push(item);
|
|
this.#trajectoryItems.forEach((item, index) => item.y = index);
|
|
}
|
|
|
|
onSummary() {
|
|
const talents = this.#talents;
|
|
$ui.switchView(UI.pages.SUMMARY, {talents});
|
|
}
|
|
|
|
get speed() {
|
|
return this.#speed;
|
|
}
|
|
|
|
set speed(speed) {
|
|
this.#speed = speed;
|
|
this.prgSpeed.value = speed / this.scbSpeed.max;
|
|
clearInterval(this.#auto);
|
|
this.#auto = null;
|
|
if(!speed) return;
|
|
this.#auto = setInterval(
|
|
() => this.onNext(),
|
|
3000 * (1 - this.prgSpeed.value) + 300
|
|
);
|
|
}
|
|
} |