| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { _decorator, Component, Node, Prefab, ScrollView, Vec3, instantiate } from 'cc';
- import { DataSystem } from '../../core/data/DataSystem';
- import { Window } from '../../core/ui/window/Window';
- import { WindowSystem } from '../../core/ui/window/WindowSystem';
- import { ConfigData } from '../../data/ConfigData';
- import { MarshalSkillSystem } from '../../marshal/MarshalSkillSystem';
- import { RecruitData } from '../RecruitData';
- import { RecruitResultItem } from './RecruitResultItem';
- const { ccclass, property } = _decorator;
- /**
- * 招募奖品展示页
- * @author 郑聂华
- */
- @ccclass('RecruitResultUI')
- export class RecruitResultUI extends Component {
- @property({ type: ScrollView, displayName: '窗口滑动组件', tooltip: "窗口滑动组件" }) scrollView: ScrollView = null;
- @property({ type: Node, displayName: 'Content', tooltip: "Content" }) content: Node = null;
- @property({ type: Prefab, displayName: '奖励Item', tooltip: "奖励Item" }) resultResultItemPrefab: Prefab = null;
- start() {
- let data = DataSystem.getData(RecruitData).recruitResults;
- data.sort(function (a, b) {
- let heroA = DataSystem.getData(ConfigData).get("general")[a.id];
- let heroB = DataSystem.getData(ConfigData).get("general")[b.id];
- if (heroA.color == heroB.color) {
- if (heroA.initStar == heroB.star) {
- if (heroA.camp == heroB.camp) {
- return heroB.id - heroA.id;
- } else {
- return heroA.camp - heroB.camp;//阵营 魏蜀吴群 1-4
- }
- } else {
- return heroB.initStar - heroA.initStar;
- }
- } else {
- return heroB.color - heroA.color;
- }
- });
- if (data != null && data.length > 0) {
- if (data.length <= 3) {
- this.scrollView.enabled = false;
- this.content.setPosition(Vec3.ZERO);
- } else {
- let posx = (data.length * 110 + (data.length - 1) * 30) / 2 - 253;
- this.content.setPosition(new Vec3(posx, 0, 0));
- }
- for (let i = 0; i < data.length; i++) {
- let scr = instantiate(this.resultResultItemPrefab).getComponent(RecruitResultItem);
- let hero = DataSystem.getData(ConfigData).get("general")[data[i].id];
- scr.Init(hero, data[i]);
- scr.node.active = true;
- this.content.addChild(scr.node);
- }
- } else {
- this.getComponent(Window).close();
- }
- }
- onDestroy() {
- DataSystem.getData(RecruitData).recruitResults = null;
- MarshalSkillSystem.openMarshalSkillNotice();
- }
- }
|