12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { _decorator, Component, ERaycast2DType, find, Label, Node, NodeEventType, PhysicsSystem2D, Tween, tween, v2, v3, Vec2, Vec3 } from 'cc';
- import { GameEvent } from './Script/Enum/GameEvent';
- import { LevelManager } from './Script/Manager/LevelMgr';
- import { GameUtil } from './Script/GameUtil';
- import { LevelAction } from './Script/LevelAction';
- import { GlobalConfig } from '../start/Config/GlobalConfig';
- import { AdvertMgr } from '../core_tgx/base/ad/AdvertMgr';
- import { AliensAudioMgr } from './Script/Manager/CarUnscrewAudioMgr';
- import { AliensGlobalInstance } from './Script/CarColorsGlobalInstance';
- import { UI_Setting } from '../scripts/UIDef';
- import { tgxUIMgr } from '../core_tgx/tgx';
- import { EventDispatcher } from '../core_tgx/easy_ui_framework/EventDispatcher';
- const { ccclass, property } = _decorator;
- const duration = 0.3;
- @ccclass('RoosterAliens')
- export class RoosterAliens extends Component {
- onLoad() {
- AliensAudioMgr.initilize();
- // AliensAudioMgr.play(AliensAudioMgr.getMusicIdName(2), 1.0);
- LevelManager.instance.initilizeModel();
- AliensGlobalInstance.instance.initUI(); //初始化u
- this.registerListener();
- }
- protected start(): void {
- this.startGame();
- }
- async startGame() {
- await LevelManager.instance.gameStart();
- }
- registerListener() {
- //UI监听
- const btnRefresh = find('Canvas/GameUI/TopLeft/BtnRefresh')!;
- const btnSet = find('Canvas/GameUI/TopLeft/BtnSet')!;
- const btnPoint = find('Canvas/GameUI/Aim/BtPoint')!;
- const btnPointFrame = find('Canvas/GameUI/AimTarget/Mask/frame')!;
- btnSet.on(NodeEventType.TOUCH_END, () => this.onClickSet(), this);
- btnPoint.on(NodeEventType.TOUCH_END, () => this.onClickAim(), this);
- btnPointFrame.on(NodeEventType.TOUCH_END, () => this.onClickResetAim(), this);
- }
- private onClickSet(): void {
- AliensAudioMgr.playOneShot(AliensAudioMgr.getMusicIdName(2), 1.0);
- const show = tgxUIMgr.inst.isShowing(UI_Setting);
- if (!show) {
- tgxUIMgr.inst.showUI(UI_Setting);
- }
- }
- private onClickAim(): void {
- const aimTarget = AliensGlobalInstance.instance.aimTarget;
- aimTarget.active = true;
- EventDispatcher.instance.emit(GameEvent.EVENT_CAMERA_AIM);
- }
- private onClickResetAim(): void {
- const aimTarget = AliensGlobalInstance.instance.aimTarget;
- aimTarget.active = false;
- EventDispatcher.instance.emit(GameEvent.EVENT_CAMERA_RESET_AIM);
- }
- }
|