add game mode

This commit is contained in:
Vick Scarlet
2022-01-25 18:15:22 +08:00
parent 0e3c885ad3
commit 286828abe7
84 changed files with 6244 additions and 135 deletions

View File

@@ -0,0 +1,89 @@
export default class Celebrity extends ui.view.DefaultTheme.CelebrityUI {
constructor() {
super();
this.btnRetry.on(Laya.Event.CLICK, this, this.random);
this.btnNext.on(Laya.Event.CLICK, this, this.next);
this.panelCharacter.vScrollBar.elasticDistance = 150;
}
#characters;
#selected;
static #createComponent = Laya.plugin.extractComponents(Celebrity.uiView, ['boxCharacter','boxTalent']);
#createCharacterItem(dataSource, click) {
const {name, property, talent} = dataSource;
const style = $ui.common.characterItem;
const item = Celebrity.#createComponent('boxCharacter');
const vboxStates = item.getChildByName('vboxStates');
const boxName = item.getChildByName('boxName');
boxName.label = name;
vboxStates.label = $_.format($lang.F_PropertyStr, property);
$_.deepMapSet(boxName, style.name);
$_.deepMapSet(vboxStates, style.state);
for(const t of talent) {
const i = Celebrity.#createComponent('boxTalent');
i.label = $_.format($lang.F_TalentSelection, t);
i.y = vboxStates.height+vboxStates.space;
$_.deepMapSet(i, $ui.common.card[t.grade].normal);
vboxStates.addChild(i);
}
const box = new Laya.Box();
box.height = vboxStates.space;
box.y = vboxStates.height;
vboxStates.addChild(box);
vboxStates.scaleY = 0;
item.dataSource = dataSource;
item.switch = showDetails => vboxStates.scaleY = !!showDetails?1:0;
item.click = (cb, caller) => {
boxName.offAll(Laya.Event.CLICK);
boxName.on(Laya.Event.CLICK, caller || this, cb);
}
if(click) item.click(click);
return item;
}
init() {
this.random();
}
close() {
this.#selected = null;
this.vboxCharacter.destroyChildren(true);
}
random() {
this.#selected = null;
this.vboxCharacter.destroyChildren(true);
this.#characters = core.characterRandom();
this.#characters.forEach(character => {
const item = this.#createCharacterItem(character);
this.vboxCharacter.addChild(item);
item.click(()=>{
if(this.#selected) this.#selected.switch(false);
this.#selected = item;
item.switch(true);
item.event(Laya.Event.RESIZE);
});
});
}
next() {
if(!this.#selected) {
$$event('message', ['M_PleaseSelectOne']);
return;
}
const {property: propertyAllocate, talent: talents} = this.#selected.dataSource;
const replace = core.remake(talents.map(talent => talent.id));
if(replace.length > 0) {
$$event('message', [replace.map(v => ['F_TalentReplace', v])]);
}
$ui.switchView(
UI.pages.TRAJECTORY,
{
propertyAllocate, talents,
enableExtend: false,
}
);
}
}

View File

@@ -1,7 +1,7 @@
export default class Main extends ui.view.DefaultTheme.MainUI {
constructor() {
super();
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MODE));
this.btnAchievement.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.ACHIEVEMENT));
this.btnThanks.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.THANKS));
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);

View File

@@ -0,0 +1,7 @@
export default class Mode extends ui.view.DefaultTheme.ModeUI {
constructor() {
super();
this.btnCustom.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
this.btnCelebrity.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.CELEBRITY));
}
}

View File

@@ -67,6 +67,7 @@ export default class Property extends ui.view.DefaultTheme.PropertyUI {
{
propertyAllocate: this.#propertyAllocate,
talents: this.listSelectedTalents.array,
enableExtend: true,
}
);
}

View File

@@ -7,6 +7,7 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
}
#selectedTalent;
#enableExtend;
onAgain() {
core.talentExtend(this.#selectedTalent);
@@ -14,8 +15,9 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
$ui.switchView(UI.pages.MAIN);
}
init({talents}) {
init({talents, enableExtend}) {
const {summary, lastExtendTalent} = core;
this.#enableExtend = enableExtend;
this.listSummary.array = [
[core.PropertyTypes.HCHR, $lang.UI_Property_Charm],
@@ -38,7 +40,11 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
if(b == lastExtendTalent) return 1;
return bg - ag;
});
this.#selectedTalent = talents[0].id;
if(this.#enableExtend) {
this.#selectedTalent = talents[0].id;
} else {
this.#selectedTalent = lastExtendTalent;
}
this.listSelectedTalents.array = talents;
}
renderSummary(box) {
@@ -57,6 +63,9 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
}
onSelectTalent(talentId) {
if(!this.#enableExtend) {
return $$event('message', ['M_DisableExtendTalent']);
}
if(talentId == this.#selectedTalent) {
this.#selectedTalent = null;
} else {

View File

@@ -8,7 +8,6 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
}
#selected = new Set();
init() {
this.pageDrawCard.visible = true;
this.pageResult.visible = false;
@@ -30,7 +29,7 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
}
const talents = [...this.#selected].map(index => this.listTalents.array[index]);
$ui.switchView(UI.pages.PROPERTY, { talents });
$ui.switchView(UI.pages.PROPERTY, { talents, enableExtend: true });
}
renderTalent(box, index) {
@@ -55,7 +54,7 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
if(this.#selected.size >= core.talentSelectLimit) {
return $$event('message', ['F_TalentSelectLimit', core.talentSelectLimit]);
}
const exclusive = core.exclusive(
const exclusive = core.exclude(
[...this.#selected].map(index => this.listTalents.array[index].id),
this.listTalents.array[index].id
);

View File

@@ -88,16 +88,17 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
if(isEnd) {
this.boxSpeed.visible = false;
this.btnSummary.visible = true;
Laya.timer.frameOnce(1,this,()=>{
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
});
}
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
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();
}
@@ -117,7 +118,7 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
item.grade(content[content.length - 1].grade);
this.vboxTrajectory.addChild(item);
this.#trajectoryItems.push(item);
this.#trajectoryItems.forEach((item, index) => item.y = index);
item.y = this.vboxTrajectory.height;
}
onSummary() {