Răsfoiți Sursa

瞄准镜头UI

woso_javan 1 lună în urmă
părinte
comite
51f492ee81

+ 24 - 12
assets/module_aliens/RoosterAliens.ts

@@ -7,6 +7,9 @@ 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;
@@ -33,24 +36,33 @@ export class RoosterAliens extends Component {
         //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')!;
 
-    private onClickHandler(bt: Node): void {
-        AliensAudioMgr.playOneShot(AliensAudioMgr.getMusicIdName(3), 1.0);
-        const setBtEmpty = () => {
-            bt.name = 'empty';
-        }
+        btnSet.on(NodeEventType.TOUCH_END, () => this.onClickSet(), this);
+        btnPoint.on(NodeEventType.TOUCH_END, () => this.onClickAim(), this);
+        btnPointFrame.on(NodeEventType.TOUCH_END, () => this.onClickResetAim(), this);
+    }
 
-        if (!GlobalConfig.isDebug) {
-            AdvertMgr.instance.showReawardVideo(() => {
-                setBtEmpty();
-            })
-        } else {
-            setBtEmpty();
+    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);
+    }
 }
 
 

+ 4 - 4
assets/module_aliens/Script/Components/ButtonComponent.ts

@@ -29,18 +29,18 @@ export class ButtonComponent extends Component {
         if (type == TYPE_ITEM.REFRESH) {
             if (!GlobalConfig.isDebug) {
                 AdvertMgr.instance.showReawardVideo(() => {
-                    EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_COLOR);
+                    // EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_COLOR);
                 })
             } else {
-                EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_COLOR);
+                // EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_COLOR);
             }
         } else if (type == TYPE_ITEM.MAGNET) {
             if (!GlobalConfig.isDebug) {
                 AdvertMgr.instance.showReawardVideo(() => {
-                    EventDispatcher.instance.emit(GameEvent.EVENT_MAGNET);
+                    // EventDispatcher.instance.emit(GameEvent.EVENT_MAGNET);
                 })
             } else {
-                EventDispatcher.instance.emit(GameEvent.EVENT_MAGNET);
+                // EventDispatcher.instance.emit(GameEvent.EVENT_MAGNET);
             }
         }
     }

+ 6 - 25
assets/module_aliens/Script/Enum/GameEvent.ts

@@ -3,33 +3,14 @@ export class GameEvent {
     static readonly EVENT_UI_INITILIZE = 'EVENT_UI_INITILIZE';
     /** 游戏开始*/
     static readonly EVENT_GAME_START = 'EVENT_GAME_START';
+    /** 游戏暂停*/
+    static readonly EVENT_GAME_PAUSE = 'EVENT_GAME_PAUSE';
 
-    /** 点击汽车*/
-    static readonly EVENT_CLICK_CAR = 'EVENT_CLICK_CAR';
+    /** 瞄准镜头*/
+    static readonly EVENT_CAMERA_AIM = 'EVENT_CAMERA_AIM';
 
-    /** 更新Layer*/
-    static readonly EVENT_UPDATE_LAYER = 'EVENT_UPDATE_LAYER';
-
-    /** 检查Layer子节点*/
-    static readonly EVENT_CHECK_LAYER_CHILD = 'EVENT_CHECK_LAYER_CHILD';
-
-    /** 刷新剩余钉子数量*/
-    static readonly EVENT_UPDATE_LEFT_NAIL = 'EVENT_UPDATE_LEFT_NAIL';
-
-    /** 检测是否有钉子可上车*/
-    static readonly EVENT_CHECK_MOVE_TO_CAR = 'EVENT_CHECK_MOVE_TO_CAR';
-
-    /** 检测element子节点长度*/
-    static readonly EVENT_CHECK_ELEMENT_CHILDREN = 'EVENT_CHECK_ELEMENT_CHILDREN';
-
-    /** 磁力事件*/
-    static readonly EVENT_MAGNET = 'EVENT_MAGNET';
-
-    /** 刷新钉子颜色事件*/
-    static readonly EVENT_REFRESH_PIN_COLORS = 'EVENT_REFRESH_PIN_COLORS';
-
-    /** 按钮功能 颜色刷新事件*/
-    static readonly EVENT_REFRESH_COLOR = 'EVENT_REFRESH_COLOR';
+    /** 取消瞄准*/
+    static readonly EVENT_CAMERA_RESET_AIM = 'EVENT_CAMERA_RESET_AIM';
 
     /** 检测游戏是否结束*/
     static readonly EVENT_CHECK_GAME_OVER = 'EVENT_CHECK_GAME_OVER';

+ 32 - 2
assets/module_aliens/Script/LevelAction.ts

@@ -1,4 +1,6 @@
 import { _decorator, BoxCollider2D, Button, Camera, CircleCollider2D, Collider2D, Component, EventTouch, find, Input, input, Node, NodeEventType, RenderTexture, v3, Vec3 } from 'cc';
+import { EventDispatcher } from '../../core_tgx/easy_ui_framework/EventDispatcher';
+import { GameEvent } from './Enum/GameEvent';
 
 const { ccclass, property } = _decorator;
 
@@ -28,16 +30,43 @@ export class LevelAction extends Component {
     onLoad(): void {
         this._cameraOriginalPos = this.camera.node.position.clone();
         this._originalRotation = this.camera.node.eulerAngles.clone();
-        
+        this.registerEvent();
+    }
+
+    start() {
+
+    }
+
+    private registerEvent(){
         // 触摸事件监听
         input.on(Input.EventType.TOUCH_START, this._onTouchStart, this);
         input.on(Input.EventType.TOUCH_MOVE, this._onTouchMove, this);
         input.on(Input.EventType.TOUCH_END, this._onTouchEnd, this);
         input.on(Input.EventType.TOUCH_CANCEL, this._onTouchEnd, this);
+
+        //事件监听
+        EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
+        EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
     }
 
-    start() {
+    private unRegisterEvent(){
+        // 触摸事件监听
+        input.off(Input.EventType.TOUCH_START, this._onTouchStart, this);
+        input.off(Input.EventType.TOUCH_MOVE, this._onTouchMove, this); 
+        input.off(Input.EventType.TOUCH_END, this._onTouchEnd, this);
+        input.off(Input.EventType.TOUCH_CANCEL, this._onTouchEnd, this);
+
+        //事件监听
+        EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
+        EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
+    }
+
+    private onAimTarget(){
+        console.log(`拉近相机镜头!`);
+    }
 
+    private onResetAimTarget(){
+        console.log(`重置相机镜头!`); 
     }
 
     /***************************触摸事件**********************************/
@@ -75,6 +104,7 @@ export class LevelAction extends Component {
  /***************************触摸事件end**********************************/
 
     onDestroy () {
+        this.unRegisterEvent();
         if (this._renderTex) {
             this._renderTex.destroy();
             this._renderTex = null;

+ 167 - 29
assets/module_aliens/rooster_aliens.scene

@@ -23,7 +23,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 88
+      "__id__": 91
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -54,7 +54,7 @@
     },
     "autoReleaseAssets": false,
     "_globals": {
-      "__id__": 89
+      "__id__": 92
     },
     "_id": "be14c61f-22d8-4bb9-b444-ad9f29740469"
   },
@@ -77,22 +77,22 @@
         "__id__": 9
       },
       {
-        "__id__": 82
+        "__id__": 85
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 84
+        "__id__": 87
       },
       {
-        "__id__": 85
+        "__id__": 88
       },
       {
-        "__id__": 86
+        "__id__": 89
       },
       {
-        "__id__": 87
+        "__id__": 90
       }
     ],
     "_prefab": null,
@@ -379,16 +379,16 @@
         "__id__": 67
       },
       {
-        "__id__": 77
+        "__id__": 80
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 80
+        "__id__": 83
       },
       {
-        "__id__": 81
+        "__id__": 84
       }
     ],
     "_prefab": null,
@@ -2706,15 +2706,18 @@
     "_children": [
       {
         "__id__": 68
+      },
+      {
+        "__id__": 75
       }
     ],
     "_active": false,
     "_components": [
       {
-        "__id__": 75
+        "__id__": 78
       },
       {
-        "__id__": 76
+        "__id__": 79
       }
     ],
     "_prefab": null,
@@ -2862,8 +2865,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 760,
-      "height": 1600
+      "width": 2000,
+      "height": 2000
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -2943,7 +2946,7 @@
     },
     "_enabled": true,
     "__prefab": null,
-    "_type": 0,
+    "_type": 1,
     "_inverted": true,
     "_segments": 64,
     "_alphaThreshold": 0.1,
@@ -2989,6 +2992,141 @@
     "_miterLimit": 10,
     "_id": "99sLyx0VZLa5/ek8CxFb9Q"
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "Label",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 67
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 76
+      },
+      {
+        "__id__": 77
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": -701.893,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": "69TK4hre1Nwae20ZUQ50Rr"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 75
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 320,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": "fd0Jg3oOtM+pOFCwOZbo+B"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 75
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "点击任意位置取消",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 40,
+    "_fontSize": 40,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 0,
+    "_enableWrapText": false,
+    "_font": {
+      "__uuid__": "23a47957-4ba6-41f7-999f-a5fbf8a48aed",
+      "__expectedType__": "cc.TTFFont"
+    },
+    "_isSystemFontUsed": false,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": false,
+    "_outlineColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_outlineWidth": 2,
+    "_enableShadow": false,
+    "_shadowColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_shadowOffset": {
+      "__type__": "cc.Vec2",
+      "x": 2,
+      "y": 2
+    },
+    "_shadowBlur": 2,
+    "_id": "59uRArR0ZE5KosXjUNVY6c"
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -3053,10 +3191,10 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 78
+        "__id__": 81
       },
       {
-        "__id__": 79
+        "__id__": 82
       }
     ],
     "_prefab": null,
@@ -3095,7 +3233,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 77
+      "__id__": 80
     },
     "_enabled": true,
     "__prefab": null,
@@ -3117,7 +3255,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 77
+      "__id__": 80
     },
     "_enabled": true,
     "__prefab": null,
@@ -3214,7 +3352,7 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 83
+        "__id__": 86
       }
     ],
     "_prefab": null,
@@ -3253,7 +3391,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 82
+      "__id__": 85
     },
     "_enabled": true,
     "__prefab": null,
@@ -3355,28 +3493,28 @@
   {
     "__type__": "cc.SceneGlobals",
     "ambient": {
-      "__id__": 90
+      "__id__": 93
     },
     "shadows": {
-      "__id__": 91
+      "__id__": 94
     },
     "_skybox": {
-      "__id__": 92
+      "__id__": 95
     },
     "fog": {
-      "__id__": 93
+      "__id__": 96
     },
     "octree": {
-      "__id__": 94
+      "__id__": 97
     },
     "skin": {
-      "__id__": 95
+      "__id__": 98
     },
     "lightProbeInfo": {
-      "__id__": 96
+      "__id__": 99
     },
     "postSettings": {
-      "__id__": 97
+      "__id__": 100
     },
     "bakedWithStationaryMainLight": false,
     "bakedWithHighpLightmap": false

+ 1 - 1
profiles/v2/packages/preview.json

@@ -5,7 +5,7 @@
   },
   "preview": {
     "current": {
-      "platform": "gameView"
+      "platform": "browser"
     }
   }
 }

+ 15 - 15
profiles/v2/packages/scene.json

@@ -5,7 +5,7 @@
     "__version__": "1.3.7"
   },
   "gizmos-infos": {
-    "is2D": false,
+    "is2D": true,
     "is3DIcon": false,
     "iconSize": 2,
     "gridVisible": true,
@@ -1194,10 +1194,10 @@
         "z": 95.77869779910438
       },
       "rotation": {
-        "x": -0.10769293488388819,
-        "y": 0.2103944222216951,
-        "z": 0.023325340367052215,
-        "w": 0.9713868165259226
+        "x": -0.10769293488123756,
+        "y": 0.21039442221684093,
+        "z": 0.02332534036642414,
+        "w": 0.9713868165532707
       },
       "viewCenter": {
         "x": 374.2603490174048,
@@ -1214,9 +1214,9 @@
     },
     "19323c5d-5d36-438a-86ee-8288c690e5b0": {
       "position": {
-        "x": 34.026274117233626,
-        "y": 34.02627411723362,
-        "z": 34.02627411723362
+        "x": 30.12230852470416,
+        "y": 30.122308524704156,
+        "z": 30.122308524704152
       },
       "rotation": {
         "x": -0.27984814233312133,
@@ -1239,15 +1239,15 @@
     },
     "9e293cde-e27b-4902-808b-e884f3e9da32": {
       "position": {
-        "x": 21.179516230594665,
-        "y": 21.179516230594658,
-        "z": 21.179516230594654
+        "x": 21.30151515536121,
+        "y": 21.3015151553612,
+        "z": 21.3015151553612
       },
       "rotation": {
-        "x": -0.021920235822641253,
-        "y": 0.02856700750272881,
-        "z": 0.009079658968154563,
-        "w": 0.9993102566955073
+        "x": -0.0465633653025151,
+        "y": 0.06068255910711151,
+        "z": 0.01928717741803454,
+        "w": 0.9968838873304964
       },
       "viewCenter": {
         "x": 0,