123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { Sprite, Vec3, _decorator } from 'cc';
- import { AudioID } from '../../../framework/config/AudioConf';
- import { ViewID } from '../../../framework/config/LayerConf';
- import { Framework } from '../../../framework/Framework';
- import { BaseView } from '../../../framework/layer/BaseView';
- import { UserData } from '../../data/UserData';
- import { LoginMgr } from '../../common/LoginManager';
- const { ccclass, property } = _decorator;
- @ccclass('MainUI')
- export class MainUI extends BaseView {
- private GameUI = {}
- private openGameUI = 'Unpacking';
- private _timer_uuid = 0;
- onLoad() {
- super.onLoad();
- }
-
- EventAll() {
- }
- onDestroy() {
- Framework.event.removeEvent(this);
- super.onDestroy();
- }
- onOpen() {
-
- Framework.layer.open(ViewID.TowerUI, null, (the) => {
-
- this.GameUI[this.openGameUI] = the
- });
- }
- onMiningRedDotChanged(redNum: number) {
- this.Node.Mining_red.active = redNum > 0;
- }
- onArena() {
- Framework.audio.playEffect(AudioID.Click);
- LoginMgr.sendPost('arena', 'get', (data) => {
- if (data) {
-
- }
- })
- }
- onOpenWin(event: Event, openUI) {
- Framework.audio.playEffect(AudioID.Click);
- let target: any = event.target;
- if (openUI) {
- if (openUI == 'Legion') {
- if (UserData['legion'].id != 0) {
-
- } else {
-
- }
- } else {
- let open_url = Number(ViewID[openUI])
- Framework.layer.open(open_url);
- }
- }
- }
- onClose() {
- }
- onShow() {
- this._ui_opacity.opacity = 255;
- this.node.setPosition(0, 0);
- }
- onHide() {
- this._ui_opacity.opacity = 0;
- this.node.setPosition(0, -5000);
- }
- private onTouchButton(event: Event, openUI) {
- Framework.audio.playEffect(AudioID.Click);
- let target: any = event.target;
-
- if (openUI) {
- let open_url = Number(ViewID[openUI])
- Framework.layer.open(open_url, () => {
- if (openUI == 'Territory') {
- if (!UserData['RoomId']) {
- UserData['RoomId'] = UserData['_id']
- }
- }
- });
- }
- }
- private BottonBtn(e, str) {
- Framework.audio.playEffect(AudioID.Click);
- let target = e.target
-
- if (this.openGameUI != target.name) {
- if (str == 'Mining') {
-
-
-
-
-
- }
- let openGameUI = this.openGameUI
- let onBgFrame = target.parent.getComponent(Sprite).spriteFrame
- let unBgFrame = this.Node[this.openGameUI].parent.getComponent(Sprite).spriteFrame
- this.Node[this.openGameUI].children[0].scale = new Vec3(0.75, 0.75)
- target.parent.getComponent(Sprite).spriteFrame = unBgFrame
- this.Node[this.openGameUI].parent.getComponent(Sprite).spriteFrame = onBgFrame
- target.children[0].scale = new Vec3(1, 1)
- if (this.GameUI[this.openGameUI]) {
- this.GameUI[this.openGameUI].onHide()
- }
- this.openGameUI = str;
- if (!this.GameUI[str]) {
- Framework.layer.open(Number(ViewID[str]), () => {
- console.log(str);
-
-
-
-
-
-
-
-
-
-
-
- }, (the) => {
-
-
- });
- } else {
- this.GameUI[str].onShow()
- }
- }
- }
- private _startTimer() {
- (this._timer_uuid != 0) && this._unschedule(this._timer_uuid);
-
-
-
- }
- }
|