123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import { Prop } from "../data/Define";
- import UIBase from "../fgui/core/UIBase";
- import ui_UIFlyEft from "../fgui/res/game/ui_UIFlyEft";
- import { xGame } from "../xGame";
- export default class UIFlyEft extends UIBase {
- public ui: ui_UIFlyEft;
- iconPos: Array<any>;
- max: number = 8;
- delay: number = 0;
- public constructor() {
- super();
- }
- protected onConstructor(): void {
- this.ui = ui_UIFlyEft.createInstance();
- this.contentPane = this.ui;
- this.isEject = false;
- this.isMuti = true;
- this.ui.x += xGame.common.sysOffestNum;
- }
- getArrPos() {
- if (this.iconPos && this.iconPos.length > 0) return;
- this.iconPos = [];
- let temp;
- for (let index = 0; index < this.max; index++) {
- temp = this.ui["n" + index];
- this.iconPos.push([temp.x, temp.y]);
- }
- }
- show(stPos, edPos, num, type, callback) {
- super.show();
- //
- this.parent.setChildIndex(this, this.parent.numChildren - 1);
- //
- this.getArrPos();
- //初始化img
- this.updateUI(type);
- //初始化位置
- this.updatePos();
- //飞行特效
- this.runFly(edPos, callback);
- //文字特效
- this.runWorlds(stPos, num);
- }
- updateUI(type) {
- let temp;
- let str;
- for (let index = 0; index < this.max; index++) {
- temp = this.ui["n" + index];
- str = this.getIconStr(type);
- temp.url = xGame.common.getGameIconUrl(str);
- }
- }
- getIconStr(type) {
- switch (type) {
- case Prop.diamond:
- return "ty_zs";
- case Prop.coin:
- return "ty_jb";
- default:
- break;
- }
- }
- updatePos() {
- let temp;
- for (let index = 0; index < this.max; index++) {
- temp = this.ui["n" + index];
- temp.x = this.iconPos[index][0];
- temp.y = this.iconPos[index][1];
- }
- }
- runFly(endPos, callback) {
- let all = 0;
- let temp;
- for (let index = 0; index < this.max; index++) {
- temp = this.ui["n" + index];
- temp.visible = true;
- Laya.Tween.to(temp, { x: endPos.x, y: endPos.y }, 600, Laya.Ease.cubicInOut, Laya.Handler.create(this, () => {
- temp.visible = false;
- all++;
- if (all >= this.max) {
- callback && callback();
- }
- }), 20 * index);
- }
- }
- runWorlds(stPos, num) {
- let str = "+" + num;
- this.ui.txt.text = str;
- //
- let starX = stPos.x;
- let starY = stPos.y + 50;
- this.ui.txt.x = starX
- this.ui.txt.y = starY
- this.ui.txt.visible = true;
- this.ui.txt.alpha = 1;
- Laya.Tween.to(this.ui.txt, { x: starX, y: starY - 30 }, 500, null, Laya.Handler.create(this, () => {
- Laya.Tween.to(this.ui.txt, { alpha: 0 }, 500, null, Laya.Handler.create(this, () => {
- this.ui.txt.visible = false;
- this.hide();
- }))
- }))
- }
- }
- UIFlyEft.uiName = "UIFlyEft"
|