123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7", "__unresolved_8", "__unresolved_9", "__unresolved_10", "__unresolved_11"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Node, Quat, math, Camera, sys, Vec3, Label, geometry, ProgressBar, tween, easing, Tween, UIOpacity, Game, BaseExp, autoBind, Constants, uiMgr, userIns, MsgHints, List, Utils, TaskEnemyItem, BulletMagazine, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _crd, ccclass, property, clamp, toRadian, GunfightShootUI;
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
- function _reportPossibleCrUseOfGame(extras) {
- _reporterNs.report("Game", "../game/Game", _context.meta, extras);
- }
- function _reportPossibleCrUseOfBaseExp(extras) {
- _reporterNs.report("BaseExp", "../core/base/BaseExp", _context.meta, extras);
- }
- function _reportPossibleCrUseOfautoBind(extras) {
- _reporterNs.report("autoBind", "../extend/AutoBind", _context.meta, extras);
- }
- function _reportPossibleCrUseOfConstants(extras) {
- _reporterNs.report("Constants", "../data/Constants", _context.meta, extras);
- }
- function _reportPossibleCrUseOfuiMgr(extras) {
- _reporterNs.report("uiMgr", "../core/manager/UIManager", _context.meta, extras);
- }
- function _reportPossibleCrUseOfuserIns(extras) {
- _reporterNs.report("userIns", "../data/UserData", _context.meta, extras);
- }
- function _reportPossibleCrUseOfMsgHints(extras) {
- _reporterNs.report("MsgHints", "../utils/MsgHints", _context.meta, extras);
- }
- function _reportPossibleCrUseOfList(extras) {
- _reporterNs.report("List", "../third/List", _context.meta, extras);
- }
- function _reportPossibleCrUseOfUtils(extras) {
- _reporterNs.report("Utils", "../utils/Utils", _context.meta, extras);
- }
- function _reportPossibleCrUseOfTaskEnemyItem(extras) {
- _reporterNs.report("TaskEnemyItem", "../items/item/TaskEnemyItem", _context.meta, extras);
- }
- function _reportPossibleCrUseOfBulletMagazine(extras) {
- _reporterNs.report("BulletMagazine", "../game/BulletMagazine", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Node = _cc.Node;
- Quat = _cc.Quat;
- math = _cc.math;
- Camera = _cc.Camera;
- sys = _cc.sys;
- Vec3 = _cc.Vec3;
- Label = _cc.Label;
- geometry = _cc.geometry;
- ProgressBar = _cc.ProgressBar;
- tween = _cc.tween;
- easing = _cc.easing;
- Tween = _cc.Tween;
- UIOpacity = _cc.UIOpacity;
- }, function (_unresolved_2) {
- Game = _unresolved_2.Game;
- }, function (_unresolved_3) {
- BaseExp = _unresolved_3.BaseExp;
- }, function (_unresolved_4) {
- autoBind = _unresolved_4.autoBind;
- }, function (_unresolved_5) {
- Constants = _unresolved_5.Constants;
- }, function (_unresolved_6) {
- uiMgr = _unresolved_6.uiMgr;
- }, function (_unresolved_7) {
- userIns = _unresolved_7.userIns;
- }, function (_unresolved_8) {
- MsgHints = _unresolved_8.default;
- }, function (_unresolved_9) {
- List = _unresolved_9.default;
- }, function (_unresolved_10) {
- Utils = _unresolved_10.Utils;
- }, function (_unresolved_11) {
- TaskEnemyItem = _unresolved_11.TaskEnemyItem;
- }, function (_unresolved_12) {
- BulletMagazine = _unresolved_12.BulletMagazine;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "c368esIoplOL4AhvWUUyNzo", "GunfightShootUI", undefined);
- __checkObsolete__(['_decorator', 'EventTouch', 'Node', 'Quat', 'math', 'Camera', 'sys', 'Vec3', 'Label', 'geometry', 'ProgressBar', 'tween', 'easing', 'Tween', 'UIOpacity', 'game', 'PhysicsSystem', 'PhysicsRayResult']);
- ({
- ccclass,
- property
- } = _decorator);
- ({
- clamp,
- toRadian
- } = math);
- _export("GunfightShootUI", GunfightShootUI = (_dec = ccclass('GunfightShootUI'), _dec2 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "轮盘节点"
- }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "标准贴图"
- }), _dec4 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "准心"
- }), _dec5 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: ProgressBar,
- tooltip: "步枪子弹进度条"
- }), _dec6 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Label,
- tooltip: "步枪子弹数文本"
- }), _dec7 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: _crd && BulletMagazine === void 0 ? (_reportPossibleCrUseOfBulletMagazine({
- error: Error()
- }), BulletMagazine) : BulletMagazine,
- tooltip: "步枪子弹列表"
- }), _dec8 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: _crd && BulletMagazine === void 0 ? (_reportPossibleCrUseOfBulletMagazine({
- error: Error()
- }), BulletMagazine) : BulletMagazine,
- tooltip: "狙击枪子弹列表"
- }), _dec9 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "步枪显示子弹的总的节点"
- }), _dec10 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: _crd && List === void 0 ? (_reportPossibleCrUseOfList({
- error: Error()
- }), List) : List,
- tooltip: "敌人任务列表"
- }), _dec11 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: ProgressBar,
- tooltip: "玩家生命进度条"
- }), _dec12 = property({
- type: [Node],
- tooltip: "要隐藏的所有按钮"
- }), _dec13 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: ProgressBar,
- tooltip: "换弹夹时间进度条"
- }), _dec14 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "玩家受到伤害呼吸闪烁"
- }), _dec15 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Label,
- tooltip: "玩家枪的名字"
- }), _dec(_class = (_class2 = class GunfightShootUI extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
- error: Error()
- }), BaseExp) : BaseExp) {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "wheel", _descriptor, this);
- _initializerDefineProperty(this, "scopeOverlay", _descriptor2, this);
- _initializerDefineProperty(this, "crossHair", _descriptor3, this);
- _initializerDefineProperty(this, "rifle_bullet_progressBar", _descriptor4, this);
- _initializerDefineProperty(this, "rifle_bullet_num_label", _descriptor5, this);
- _initializerDefineProperty(this, "rifle_bullets_scrollView", _descriptor6, this);
- _initializerDefineProperty(this, "snipe_bullets_scrollView", _descriptor7, this);
- _initializerDefineProperty(this, "rifle_bullets_bg", _descriptor8, this);
- _initializerDefineProperty(this, "task_scrollView", _descriptor9, this);
- _initializerDefineProperty(this, "hpProgressBar", _descriptor10, this);
- _initializerDefineProperty(this, "hiddeNodes", _descriptor11, this);
- _initializerDefineProperty(this, "reloadProgressBar", _descriptor12, this);
- _initializerDefineProperty(this, "injury_blood", _descriptor13, this);
- _initializerDefineProperty(this, "gun_name_label", _descriptor14, this);
- /** 子弹飞行距离 */
- this.bulletDistance = 800;
- /** 当前相机绕 X 轴的旋转角度 */
- this.currentXRotation = 0;
- /** 当前相机绕 Y 轴的旋转角度 */
- this.currentYRotation = 0;
- /** 左右旋转角度的最大限制值 */
- this.maxHorizontalAngle = 40;
- /** 上下旋转角度的最大限制值 */
- this.maxVerticalAngle = 40;
- /** 相机的原始视野值 */
- this.originalFov = void 0;
- /** 玩家节点的初始旋转四元数 */
- this.initialPlayerRotation = new Quat();
- /** 相机节点的初始旋转四元数 */
- this.initialCameraRotation = new Quat();
- /**相机旋转的灵敏度 值越大移动越快 灵敏度越高*/
- this.sensitivity = 0.5;
- /** 相机放大后的目标视野值 */
- this.targetFov = void 0;
- /** 标记相机是否正在进行放大操作 */
- this.isZoomingIn = false;
- /** 标记相机是否正在进行缩小操作 */
- this.isZoomingOut = false;
- /** 相机视野放大的速度 */
- this.zoomSpeed = 0;
- /** 期望的缩放时间,单位为秒 */
- this.zoomDuration = 0.2;
- /** 记录镜头开始放大的时间 */
- this.zoomStartTime = 0;
- /** 标记是否在2秒内完成放大 */
- this.zoomValid = false;
- /** 标记是否开镜 */
- this._isScopeOpen = false;
- /**镜头的位置*/
- this.wheelPos = Vec3.ZERO;
- //任务数据
- this.taskDatas = [];
- //是否正在被击中
- this.isHurtRun = false;
- }
- get isScopeOpen() {
- return this._isScopeOpen;
- }
- set isScopeOpen(value) {
- this.gunDataUI();
- if (this._isScopeOpen !== value) {
- this._isScopeOpen = value;
- if (value) {
- this.openScope();
- } else {
- this.closeScope();
- }
- }
- }
- start() {
- this.hasAnim = false;
- this.closeOnBlank = false;
- this.injury_blood.active = false;
- this.reloadProgressBar.node.active = false;
- if (!(_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
- error: Error()
- }), Constants) : Constants).isDebug) {
- this.hiddeNodes.forEach(e => e.active = false);
- }
- this.wheelPos = this.wheel.position.clone(); //记录摄像机原始视野
- this.originalFov = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.getComponent(Camera).fov; //录初始旋转角度
- this.initialPlayerRotation = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.node.rotation.clone();
- this.initialCameraRotation = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.node.rotation.clone(); //监听当前节点触摸事件
- this.node.on(Node.EventType.TOUCH_START, this.onNodeTouchMove, this);
- this.node.on(Node.EventType.TOUCH_MOVE, this.onNodeTouchMove, this);
- this.node.on(Node.EventType.TOUCH_END, this.onCustomNodeTouchEnd, this);
- this.node.on(Node.EventType.TOUCH_CANCEL, this.onCustomNodeTouchEnd, this); //监听轮盘点击事件 监听轮盘的触摸开始事件,当触摸开始时调用 onWheelClick 方法
- this.wheel.on(Node.EventType.TOUCH_START, this.onWheelClick, this);
- this.wheel.on(Node.EventType.TOUCH_END, this.onWheelRelease, this);
- this.wheel.on(Node.EventType.TOUCH_CANCEL, this.onWheelRelease, this);
- }
- show() {
- this.loadTaskData();
- }
- /**
- * 加载数据
- */
- loadTaskData() {
- var data = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).getCurLevelData();
- if (!data) return;
- this.taskDatas = []; //拆分并处理每个敌人配置
- data.dispose.split('|').forEach(item => {
- var [enemyId, count] = item.split('_').map(Number);
- var enemyData = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
- error: Error()
- }), Utils) : Utils).clone((_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).enemyTable).find(e => e.id === enemyId);
- enemyData.count = count;
- enemyData.killCount = 0;
- this.taskDatas.push(enemyData);
- });
- if (this.taskDatas.length <= 0) return;
- this.task_scrollView.numItems = this.taskDatas.length; //加载子弹的数据
- this.gunDataUI();
- }
- /**
- * 设置枪的数据
- */
- gunDataUI() {
- var gData = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.pData;
- if (!gData) return;
- this.crossHair.active = true; //准心
- if (gData.type == 2) {
- //步枪
- this.scopeOverlay.active = false; //标准贴图
- } else {
- this.scopeOverlay.active = true; //标准贴图
- }
- this.gun_name_label.string = gData.name_lang;
- var isSnipeGun = gData.type == 1; //换弹夹进度条
- var isMagazine = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.isReloadMagazine;
- if (isMagazine) {
- this.rifle_bullets_bg.active = false;
- this.snipe_bullets_scrollView.node.active = false;
- } else {
- //步枪子弹视图
- this.rifle_bullets_bg.active = !isSnipeGun; //狙击子弹视图列表
- this.snipe_bullets_scrollView.node.active = isSnipeGun;
- if (isSnipeGun) {
- this.snipe_bullets_scrollView.magazineNum = gData.magazine;
- } else {
- this.rifle_bullets_scrollView.magazineNum = gData.magazine; //子弹进度条
- var s_bullet = gData.magazine - (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.gun.shotBullets;
- this.rifle_bullet_progressBar.progress = s_bullet / gData.magazine;
- this.rifle_bullet_num_label.string = s_bullet + "/" + gData.magazine;
- }
- }
- }
- /**
- * 更换弹夹动画
- * @param time 换弹时间 单位秒
- * @param complete 完成回调
- */
- reloadMagazineing(time, complete) {
- if (time <= 0) {
- complete == null || complete();
- } else {
- this.reloadProgressBar.node.active = true;
- this.reloadProgressBar.progress = 1;
- this.rifle_bullets_bg.active = false;
- this.snipe_bullets_scrollView.node.active = false; //创建定时器动画
- tween(this.reloadProgressBar).to(time, {
- progress: 0
- }, {
- easing: easing.linear,
- onStart: () => {
- tween(this.reloadProgressBar).stop();
- },
- onComplete: () => {
- this.reloadProgressBar.node.active = false;
- complete == null || complete();
- }
- }).start();
- }
- }
- /**
- * 任务数据
- * @param item item节点
- * @param idx 数据下标
- */
- setTaskItemData(item, idx) {
- item.getComponent(_crd && TaskEnemyItem === void 0 ? (_reportPossibleCrUseOfTaskEnemyItem({
- error: Error()
- }), TaskEnemyItem) : TaskEnemyItem).init(this.taskDatas[idx]);
- }
- /**
- * 根据切换枪的stability设置镜头的稳定性
- */
- crossHairStability() {
- var gData = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.pData;
- if (!gData) return;
- this.gunDataUI();
- this.wheel.position = this.wheelPos; //参数映射优化(假设stability范围0-1) 振幅稳定性越低振幅越大 频率稳定性越低抖动越快
- var amplitude = 20 * (1 - gData.stability / 1000);
- var elapsed = 0; //基础抖动持续时间
- var duration = 0.4;
- var updateShake = deltaTime => {
- elapsed += deltaTime; //双轴随机偏移
- var offsetX = amplitude * (Math.random() - 0.5) * Math.max(1 - elapsed / duration, 0);
- var offsetY = amplitude * (Math.random() - 0.5) * Math.max(1 - elapsed / duration, 0);
- this.wheel.position = new Vec3(this.wheelPos.x + offsetX, this.wheelPos.y + offsetY, this.wheelPos.z); //自动结束
- if (elapsed >= duration) {
- this.wheel.position = this.wheelPos;
- this.unschedule(updateShake);
- }
- };
- this.unschedule(updateShake); // 使用游戏时间而非系统时间
- this.schedule(updateShake, 0.02); // 每0.02秒更新(约50FPS)
- }
- /**
- * 屏幕触摸事件
- * 触摸移动时,根据触摸的位置计算旋转角度,并应用到节点上
- * @param event
- */
- onNodeTouchMove(event) {
- var delta = event.getDelta(); //计算旋转角度
- this.currentYRotation -= delta.x * this.sensitivity;
- this.currentXRotation -= delta.y * this.sensitivity; //分别限制左右和上下旋转角度
- this.currentYRotation = clamp(this.currentYRotation, -this.maxHorizontalAngle, this.maxHorizontalAngle);
- this.currentXRotation = clamp(this.currentXRotation, -this.maxVerticalAngle, this.maxVerticalAngle); //计算水平和垂直旋转的四元数
- var yQuat = new Quat();
- Quat.fromEuler(yQuat, 0, this.currentYRotation, 0);
- var xQuat = new Quat();
- Quat.fromEuler(xQuat, +this.currentXRotation, 0, 0); //合并旋转
- var finalQuat = new Quat();
- Quat.multiply(finalQuat, yQuat, xQuat); //将最终旋转与初始摄像机旋转合并
- Quat.multiply(finalQuat, this.initialPlayerRotation, finalQuat); //应用旋转到摄像机
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.node.rotation = finalQuat;
- }
- /**
- * 触摸结束
- * 触摸结束时 触摸结束处理方法
- */
- onCustomNodeTouchEnd() {//触摸结束,可添加其他逻辑
- }
- /**
- * 开始慢慢放大视野
- */
- onWheelClick() {
- this.isScopeOpen = true;
- }
- /**
- * 恢复原始视野
- */
- onWheelRelease() {
- if (!this.zoomValid) {
- this.isScopeOpen = false;
- return;
- }
- this.scheduleOnce(() => {
- //检查是否在秒内完成放大 已经在update里开镜完成时调用 Game.I.player.shoot();
- this.isScopeOpen = false;
- }, 0.2);
- }
- /**
- * 开始开镜
- */
- openScope() {
- //从枪械数据获取参数
- var gData = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.pData;
- if (!gData) return;
- var isRifle = this.isRifleGun(); //是步枪直接连续开火
- if (isRifle) {
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.shoot();
- }
- this.isZoomingIn = true; //将 zoomingSpeed 转换为持续时间(450对应1.2秒)
- this.zoomDuration = 72 / gData.zoomingSpeed; //使用枪械类型决定视口倍数
- var zoomMultiplier = isRifle ? 1 / gData.rifleZoom : // 步枪使用 rifleZoom
- 1 / gData.scopeZoom; // 狙击枪使用 scopeZoom
- this.targetFov = this.originalFov * zoomMultiplier; //保持原有速度计算逻辑
- var fovDifference = this.originalFov - this.targetFov;
- this.zoomSpeed = fovDifference / this.zoomDuration;
- this.zoomStartTime = sys.now();
- } // 在 closeScope 方法中保持相同持续时间
- closeScope() {
- this.isZoomingIn = false;
- this.isZoomingOut = true;
- var fovDifference = this.originalFov - this.targetFov; //使用相同 zoomDuration 保证缩镜速度一致
- this.zoomSpeed = fovDifference / this.zoomDuration;
- }
- /**
- * 是否是步枪
- */
- isRifleGun() {
- var gData = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.pData;
- if (!gData) return false;
- return gData.id == '100014' || gData.id == '100015';
- }
- /**
- * 计算从枪口出发,沿准心射线方向的点
- * @param isBulletEndPos 是否获得子弹的终点
- */
- getCrossHairPos() {
- //获取屏幕准心位置(世界坐标)
- var worldPos = this.crossHair.worldPosition.clone();
- var camera2D = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.canvas.getChildByName('Camera2D').getComponent(Camera);
- var screenPos = camera2D.worldToScreen(worldPos); //校准补偿准心的偏移量
- screenPos.x -= 0;
- screenPos.y += 20; //从摄像机发射通过准心的射线
- var ray = new geometry.Ray();
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.screenPointToRay(screenPos.x, screenPos.y, ray); //获取枪口位置
- var muzzlePos = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.gun.muzzleNode.worldPosition;
- return new Vec3(muzzlePos.x + ray.d.x * this.bulletDistance, muzzlePos.y + ray.d.y * this.bulletDistance, muzzlePos.z + ray.d.z * this.bulletDistance);
- }
- /**
- * 玩家血量低于30%一直闪烁、打一枪的时候闪一下
- * @param progress 血量进度
- * @returns
- */
- playerHurtTwinkle(progress) {
- this.hpProgressBar.progress = progress;
- var isRepeat = progress <= 0.3;
- if (this.isHurtRun) return;
- this.isHurtRun = true;
- this.injury_blood.active = true; //audioMgr.play(Constants.audios.pop_up_sound);
- Tween.stopAllByTarget(this.injury_blood);
- var op = this.injury_blood.getComponent(UIOpacity);
- op.opacity = 255;
- tween(op).to(0.2, {
- opacity: 0
- }).call(() => {
- this.isHurtRun = false;
- this.injury_blood.active = false;
- }).repeat(isRepeat ? 100000 : 1).start();
- }
- /**
- * 点击事件
- * @param event 事件
- * @param customEventData 数据
- */
- onBtnClicked(event, customEventData) {
- super.onBtnClicked(event, customEventData);
- var btnName = event.target.name;
- if (btnName === 'pause_btn') {
- // 暂停页面
- (_crd && uiMgr === void 0 ? (_reportPossibleCrUseOfuiMgr({
- error: Error()
- }), uiMgr) : uiMgr).show((_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
- error: Error()
- }), Constants) : Constants).popUIs.pauseUI);
- } else if (btnName === 'shot_btn') {
- //射击
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.shoot();
- } else if (btnName === 'cut_gun_btn') {
- //切枪
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.randomCutGun();
- } else if (btnName === 'clean_btn') {
- //重新加载数据
- (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).removeData();
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.pData = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).getCurUseGun();
- (_crd && MsgHints === void 0 ? (_reportPossibleCrUseOfMsgHints({
- error: Error()
- }), MsgHints) : MsgHints).show('重新加载数据完成');
- } else if (btnName === 'adds_btn') {
- //解锁全部枪数据
- (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).unlockAllGuns();
- (_crd && MsgHints === void 0 ? (_reportPossibleCrUseOfMsgHints({
- error: Error()
- }), MsgHints) : MsgHints).show('已经解锁全部枪数据');
- }
- }
- /**
- * 每帧更新,处理视野渐变和检查 2 秒时间限制
- * @param deltaTime - 上一帧到当前帧的时间间隔
- */
- update(deltaTime) {
- if (this.isZoomingIn) {
- var currentFov = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.fov;
- if (currentFov > this.targetFov) {
- var newFov = currentFov - this.zoomSpeed * deltaTime;
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.fov = Math.max(newFov, this.targetFov);
- } else {
- //检查是否在2秒内完成放大
- var elapsedTime = (sys.now() - this.zoomStartTime) / 1000;
- if (elapsedTime <= 1.5) {
- this.zoomValid = true;
- }
- this.isZoomingIn = false;
- }
- } else if (this.isZoomingOut) {
- var _currentFov = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.fov;
- if (_currentFov < this.originalFov) {
- var _newFov = _currentFov + this.zoomSpeed * deltaTime;
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.camera.fov = Math.min(_newFov, this.originalFov);
- } else {
- this.isZoomingOut = false;
- this.zoomValid = false; //非步枪开镜结束开火
- if (!this.isRifleGun()) {
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.shoot();
- }
- }
- }
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "wheel", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "scopeOverlay", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "crossHair", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "rifle_bullet_progressBar", [_dec5], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "rifle_bullet_num_label", [_dec6], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "rifle_bullets_scrollView", [_dec7], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "snipe_bullets_scrollView", [_dec8], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "rifle_bullets_bg", [_dec9], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "task_scrollView", [_dec10], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "hpProgressBar", [_dec11], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "hiddeNodes", [_dec12], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return [];
- }
- }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "reloadProgressBar", [_dec13], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "injury_blood", [_dec14], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "gun_name_label", [_dec15], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: null
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=4939d0aafb7a933a612fcaa12691e0b0a210a5ff.js.map
|