123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import { _decorator, Component, Node } from "cc";
- import BaseUI from "../base/BaseUI";
- import { ModuleDef } from "../../scripts/ModuleDef";
- import { GameUILayers } from "../../scripts/GameUILayers";
- import { SceneUtil } from "../../core_tgx/base/SceneUtils";
- import { SceneDef } from "../../scripts/SceneDef";
- import { UIGameResultPlayerItem } from "./UIGameResultPlayerItem";
- import { tween } from "cc";
- import { Vec3 } from "cc";
- import UIUtils from "../base/UIUtils";
- import { isValid } from "cc";
- const { ccclass, property } = _decorator;
- @ccclass("UIGameResult")
- export class UIGameResult extends BaseUI {
- static show() {
- tgx.UIMgr.inst.show(
- ModuleDef.BALL,
- "ui_game/ui_game_result",
- GameUILayers.POPUP
- );
- }
- protected onLoad(): void {
- super.onLoad();
- this.initResult();
- }
- private _rankMap = {};
- async initResult() {
- let list = [];
- list.push({
- name: "player_1",
- score: 9.9,
- rank: 1,
- isSelf: false,
- kill: 87,
- });
- list.push({
- name: "player_2",
- score: 8.2,
- rank: 2,
- isSelf: true,
- kill: 66,
- });
- list.push({
- name: "player_3",
- score: 6.7,
- rank: 3,
- isSelf: false,
- kill: 55,
- });
- list.push({
- name: "player_4",
- score: 4.1,
- rank: 4,
- isSelf: false,
- kill: 34,
- });
- for (let index = 5; index <= 9; index++) {
- list.push({
- name: "player_" + index,
- score: 2 - index / 10,
- rank: index,
- isSelf: false,
- kill: 9 - index,
- });
- }
- for (let i in list) {
- this._rankMap[list[i].rank] = list[i];
- }
- for (let index = 1; index <= 9; index++) {
- this.FindNode("no" + index).active = false;
- }
- for (let index = 0; index < list.length; index++) {
- const element = list[index];
- let node = this.FindNode("no" + element.rank);
- if (node) {
- if (node.getComponent(UIGameResultPlayerItem) == null) {
- node.addComponent(UIGameResultPlayerItem);
- }
- node.getComponent(UIGameResultPlayerItem).init(element);
- }
- }
- for (let index = 1; index <= 9; index++) {
- if (this._rankMap[index] == null) {
- break;
- }
- if (index <= 3) {
- this.playTopAnim(index);
- } else if (index <= 6) {
- this.playLeftAnim(index);
- } else {
- this.playRightAnim(index);
- }
- }
- let aaa = this.FindNode("circle_anim");
- aaa.setScale(3, 3, 3);
- UIUtils.AnimBezierMoveAndScale(aaa, new Vec3(0, 0, 0), 1, 1, () => {});
- }
- playTopAnim(index: number) {
- let self = this;
- setTimeout(() => {
- if (!isValid(self.node)) {
- return;
- }
- let animNode = self.FindNode("no" + index);
- let moveDis = 200;
- animNode.setPosition(animNode.position.x, animNode.position.y - moveDis);
- animNode.active = true;
- UIUtils.AnimBezierMoveAndScale(
- animNode,
- new Vec3(animNode.position.x, animNode.position.y + moveDis, 0),
- 1,
- 0.3
- );
- }, index * 200);
- }
- playLeftAnim(index: number) {
- let self = this;
- setTimeout(() => {
- if (!isValid(self.node)) {
- return;
- }
- self.FindNode("no" + index).active = true;
- let animNode = self.FindNode("no" + index);
- let moveDis = 200;
- animNode.setPosition(animNode.position.x - moveDis, animNode.position.y);
- animNode.active = true;
- tween(animNode)
- .to(0.5, {
- position: new Vec3(
- animNode.position.x + moveDis,
- animNode.position.y
- ),
- })
- .start();
- }, 700 + index * 100);
- }
- playRightAnim(index: number) {
- let self = this;
- setTimeout(() => {
- if (!isValid(self.node)) {
- return;
- }
- let animNode = self.FindNode("no" + index);
- let moveDis = 200;
- animNode.setPosition(animNode.position.x + moveDis, animNode.position.y);
- animNode.active = true;
- tween(animNode)
- .to(0.5, {
- position: new Vec3(
- animNode.position.x - moveDis,
- animNode.position.y
- ),
- })
- .start();
- }, 800 + index * 100);
- }
- protected simpleOnBtnClick(name: string): void {
- if (name == "btn_back") {
- this.closePage();
- tgx.UIMgr.inst.closeAll();
- SceneUtil.loadScene(SceneDef.LOBBY);
- }
- }
- }
|