diff --git a/README.md b/README.md index 9e587c0..6df50d4 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ These are the available demos in this repository. | Demo | version | Documentation | | ---- | ----- | ---- | -| [GameOBECocosDemo](./cocos) | [![version](https://img.shields.io/badge/Release-13.6.1.300-yellow)](./cocos) | [Getting Started](https://github.com/AppGalleryConnect/agc-GameOBE-demos/wiki/%E5%8D%8E%E4%B8%BA%E8%81%94%E6%9C%BA%E5%AF%B9%E6%88%98%E5%BC%95%E6%93%8EJS-SDK-demo%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
[API Reference](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-js-0000001237750607) | -| [GameOBEUnityDemo](./unity)| [![version](https://img.shields.io/badge/Release-13.6.1.300-yellow)](./unity) | [Get Started](https://github.com/AppGalleryConnect/agc-GameOBE-demos/wiki/%E5%8D%8E%E4%B8%BA%E8%81%94%E6%9C%BA%E5%AF%B9%E6%88%98%E5%BC%95%E6%93%8EC%23-SDK-demo%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
[API Reference](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-csharp-0000001229744748) | -| [RealTimeServerDemo](./realtimeserver) | [![version](https://img.shields.io/badge/Release-13.6.1.300-yellow)](./realtimeserver) | [[Get Started]](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/gameobe-realtime-server-0000001289210804)
[[API Reference]](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-server-ts-0000001434539701) | +| [GameOBECocosDemo](./cocos) | [![version](https://img.shields.io/badge/Release-14.3.1.300-yellow)](./cocos) | [Getting Started](https://github.com/AppGalleryConnect/agc-GameOBE-demos/wiki/%E5%8D%8E%E4%B8%BA%E8%81%94%E6%9C%BA%E5%AF%B9%E6%88%98%E5%BC%95%E6%93%8EJS-SDK-demo%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
[API Reference](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-js-0000001237750607) | +| [GameOBEUnityDemo](./unity)| [![version](https://img.shields.io/badge/Release-14.3.1.300-yellow)](./unity) | [Get Started](https://github.com/AppGalleryConnect/agc-GameOBE-demos/wiki/%E5%8D%8E%E4%B8%BA%E8%81%94%E6%9C%BA%E5%AF%B9%E6%88%98%E5%BC%95%E6%93%8EC%23-SDK-demo%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
[API Reference](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-csharp-0000001229744748) | +| [RealTimeServerDemo](./realtimeserver) | [![version](https://img.shields.io/badge/Release-14.3.1.300-yellow)](./realtimeserver) | [[Get Started]](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/gameobe-realtime-server-0000001289210804)
[[API Reference]](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-References/gameobe-overview-server-ts-0000001434539701) | ## Precautions The agc-GameOBE-demos project contains 3 independent projects. After downloading the code, you can load different nested projects to the IDE as required. And you can run each project independently. diff --git a/cocos/README.md b/cocos/README.md index af0b767..02c46ef 100644 --- a/cocos/README.md +++ b/cocos/README.md @@ -107,8 +107,8 @@ The following is a brief description of the scene design files and corresponding * These pages are used to show and replay game historical records. When you click one item, you would enter the game scene. - \assets\Scene\recordLIst.fire - \assets\Script\scene\recordLIst.ts + \assets\Scene\recordList.fire + \assets\Script\scene\recordList.ts * After the homeowner clicks to start the game, the player enters the game. Then, the game begins. diff --git a/cocos/assets/Scene/gameend.fire b/cocos/assets/Scene/gameend.fire index 90b1bd3..9f14489 100644 --- a/cocos/assets/Scene/gameend.fire +++ b/cocos/assets/Scene/gameend.fire @@ -17,7 +17,7 @@ "__id__": 2 } ], - "_active": false, + "_active": true, "_components": [], "_prefab": null, "_opacity": 255, @@ -409,7 +409,7 @@ "_groupIndex": 0, "groupIndex": 0, "showInEditor": false, - "_id": "1bAosjspFKKqoWIfrKDCVo" + "_id": "1eYsrmmyNMYJD26Xo4e7MX" }, { "__type__": "cc.Label", @@ -442,7 +442,7 @@ "_N$fontFamily": "Arial", "_N$overflow": 0, "_N$cacheMode": 0, - "_id": "5ed+RTU0FAuJGBK93ZJIGH" + "_id": "42bd4yhTFBw7fBBWmuyytC" }, { "__type__": "cc.PrefabInfo", @@ -452,7 +452,7 @@ "asset": { "__uuid__": "4a37dd57-78cd-4cec-aad4-f11a73d12b63" }, - "fileId": "0fiTWlZKBOG7mtfF89+VpK", + "fileId": "6f7GyJgvlOe7CzyRETtbps", "sync": false }, { @@ -518,7 +518,7 @@ "_groupIndex": 0, "groupIndex": 0, "showInEditor": false, - "_id": "82uA/ncJZLcozo9+54Wv1+" + "_id": "e08oJTlxBBbLj2V6maGuv+" }, { "__type__": "cc.Label", @@ -551,7 +551,7 @@ "_N$fontFamily": "Arial", "_N$overflow": 0, "_N$cacheMode": 0, - "_id": "962YsuaHBJkI7m2BVlt5u+" + "_id": "43WtgHODdCTZQBM/JqFWRs" }, { "__type__": "cc.PrefabInfo", @@ -561,7 +561,7 @@ "asset": { "__uuid__": "4a37dd57-78cd-4cec-aad4-f11a73d12b63" }, - "fileId": "6d+p1wjVRG/J6wyUKl/w0y", + "fileId": "39KVlNqH5IBZZuK01tlLVV", "sync": false }, { @@ -1269,7 +1269,7 @@ "_id": "29zXboiXFBKoIV4PQ2liTe" }, { - "__type__": "159bfb7XZhCY5ctb5DNSAoY", + "__type__": "a78d9OmdjpFD4dQ3DH++5a2", "_name": "", "_objFlags": 0, "node": { @@ -1288,6 +1288,6 @@ "reopenGamePrefab": { "__uuid__": "5c349b53-d115-4f87-a780-c159172e3b3d" }, - "_id": "08E965pKJNG64qJMRgZ1TK" + "_id": "7a7AHU2ChO15SNc16+OqLB" } ] \ No newline at end of file diff --git a/cocos/assets/Scene/recordList.fire b/cocos/assets/Scene/recordList.fire index 66b4dd2..25a9f02 100644 --- a/cocos/assets/Scene/recordList.fire +++ b/cocos/assets/Scene/recordList.fire @@ -480,7 +480,7 @@ "_groupIndex": 0, "groupIndex": 0, "showInEditor": false, - "_id": "79347KYjpD9L+kxej9pBFE" + "_id": "83sTs1ohFGuIUKeQzYhH0h" }, { "__type__": "cc.Label", @@ -513,7 +513,7 @@ "_N$fontFamily": "Arial", "_N$overflow": 0, "_N$cacheMode": 0, - "_id": "dakn50n6RES492xKJ2LHYN" + "_id": "71v1aahXxOGqbadVRtjuBE" }, { "__type__": "cc.PrefabInfo", @@ -523,7 +523,7 @@ "asset": { "__uuid__": "4a37dd57-78cd-4cec-aad4-f11a73d12b63" }, - "fileId": "d4kmg/6uZB2KnMVpGoO4Ci", + "fileId": "29wgd8rWJNVp+3lr7YY2up", "sync": false }, { @@ -589,7 +589,7 @@ "_groupIndex": 0, "groupIndex": 0, "showInEditor": false, - "_id": "38JO4EthhEFLJc6Zyr5apA" + "_id": "69DT3FomJBaJtGSZ0nNFN2" }, { "__type__": "cc.Label", @@ -622,7 +622,7 @@ "_N$fontFamily": "Arial", "_N$overflow": 0, "_N$cacheMode": 0, - "_id": "56FaW8+eBAvJcXJZn9P3ZC" + "_id": "4338IAB8lKiZw21Fq333Fc" }, { "__type__": "cc.PrefabInfo", @@ -632,7 +632,7 @@ "asset": { "__uuid__": "4a37dd57-78cd-4cec-aad4-f11a73d12b63" }, - "fileId": "1ftuc1ritGK4a0EFJ2L712", + "fileId": "dc7AtoWBZMl7BMx/IIrlez", "sync": false }, { @@ -1136,7 +1136,7 @@ "_N$startAxis": 0, "_N$paddingLeft": 0, "_N$paddingRight": 0, - "_N$paddingTop": 0, + "_N$paddingTop": 4, "_N$paddingBottom": 0, "_N$spacingX": 0, "_N$spacingY": 70, @@ -1931,4 +1931,4 @@ }, "_id": "e4ZIfxzkJCdLo0BOqXOgk1" } -] \ No newline at end of file +] diff --git a/cocos/assets/Scene/roomlist.fire b/cocos/assets/Scene/roomlist.fire index 6355750..6971840 100644 --- a/cocos/assets/Scene/roomlist.fire +++ b/cocos/assets/Scene/roomlist.fire @@ -1387,7 +1387,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 95, + 110, 252, 0, 0, @@ -1458,7 +1458,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 14, + 0, 0, 0, 0, @@ -1523,7 +1523,7 @@ "ctor": "Float64Array", "array": [ 0, - 3, + 0, 0, 0, 0, @@ -1796,8 +1796,8 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - -119.254, - -329.799, + -110, + -330, 0, 0, 0, @@ -1867,7 +1867,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 14, + 0, 0, 0, 0, @@ -1932,7 +1932,7 @@ "ctor": "Float64Array", "array": [ 0, - 3, + 0, 0, 0, 0, @@ -2205,7 +2205,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 109.014, + 110, 209, 0, 0, @@ -2341,7 +2341,7 @@ "ctor": "Float64Array", "array": [ 0, - 1, + 0, 0, 0, 0, @@ -2676,8 +2676,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 280, - "height": 460 + "width": 310, + "height": 470 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2744,8 +2744,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 300, - "height": 460 + "width": 310, + "height": 470 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2808,8 +2808,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 280, - "height": 1440 + "width": 310, + "height": 470 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2821,7 +2821,7 @@ "ctor": "Float64Array", "array": [ 0, - 160, + 235, 0, 0, 0, @@ -2878,8 +2878,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 250, - "height": 80 + "width": 300, + "height": 70 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2957,8 +2957,8 @@ "_enabled": true, "_layoutSize": { "__type__": "cc.Size", - "width": 250, - "height": 80 + "width": 300, + "height": 70 }, "_resize": 0, "_N$layoutType": 2, @@ -2970,7 +2970,7 @@ "_N$startAxis": 0, "_N$paddingLeft": 0, "_N$paddingRight": 0, - "_N$paddingTop": 0, + "_N$paddingTop": 10, "_N$paddingBottom": 0, "_N$spacingX": 0, "_N$spacingY": 70, @@ -3622,8 +3622,8 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - -7.273, - -329.625, + 0, + -330, 0, 0, 0, @@ -3693,7 +3693,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 14, + 0, 0, 0, 0, @@ -3758,7 +3758,7 @@ "ctor": "Float64Array", "array": [ 0, - 3, + 0, 0, 0, 0, @@ -4031,8 +4031,8 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 104.36, - -329.799, + 110, + -330, 0, 0, 0, @@ -4102,7 +4102,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 14, + 0, 0, 0, 0, @@ -4167,7 +4167,7 @@ "ctor": "Float64Array", "array": [ 0, - 3, + 0, 0, 0, 0, @@ -5067,4 +5067,4 @@ "_originalHeight": 40, "_id": "13RScK9dFBpparE7kjKSwW" } -] \ No newline at end of file +] diff --git a/cocos/assets/Scene/team.fire b/cocos/assets/Scene/team.fire index 82d6396..4b83565 100644 --- a/cocos/assets/Scene/team.fire +++ b/cocos/assets/Scene/team.fire @@ -75,13 +75,13 @@ "_active": true, "_components": [ { - "__id__": 97 + "__id__": 107 }, { - "__id__": 98 + "__id__": 108 }, { - "__id__": 99 + "__id__": 109 } ], "_prefab": null, @@ -147,7 +147,7 @@ "_active": true, "_components": [ { - "__id__": 96 + "__id__": 106 } ], "_prefab": null, @@ -220,19 +220,22 @@ }, { "__id__": 83 + }, + { + "__id__": 93 } ], "_active": true, "_components": [ { - "__id__": 93 + "__id__": 103 }, { - "__id__": 94 + "__id__": 104 } ], "_prefab": { - "__id__": 95 + "__id__": 105 }, "_opacity": 255, "_color": { @@ -397,7 +400,7 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 154, + "width": 140, "height": 25.2 }, "_anchorPoint": { @@ -409,7 +412,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - -72.448, + -78, 81.207, 0, 0, @@ -449,8 +452,8 @@ ], "_srcBlendFactor": 770, "_dstBlendFactor": 771, - "_string": "快乐小黑店(可自定义)", - "_N$string": "快乐小黑店(可自定义)", + "_string": "队伍名称:快乐小黑店", + "_N$string": "队伍名称:快乐小黑店", "_fontSize": 14, "_lineHeight": 20, "_enableWrapText": true, @@ -460,7 +463,7 @@ "_batchAsBitmap": false, "_styleFlags": 0, "_underlineHeight": 0, - "_N$horizontalAlign": 1, + "_N$horizontalAlign": 0, "_N$verticalAlign": 1, "_N$fontFamily": "Arial", "_N$overflow": 0, @@ -2363,7 +2366,7 @@ }, { "__type__": "cc.Node", - "_name": "enable_btn_dismiss", + "_name": "update_btn", "_objFlags": 0, "_parent": { "__id__": 4 @@ -2392,8 +2395,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 100, - "height": 38 + "width": 75, + "height": 25 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2404,8 +2407,8 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - -60, - -300, + 108.926, + 323.925, 0, 0, 0, @@ -2427,7 +2430,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "2el/H9Hl5BkI4ZyaId7Ns8" + "_id": "f72926XzZAirRgE4xPnbYQ" }, { "__type__": "cc.Node", @@ -2456,15 +2459,15 @@ "_opacity": 255, "_color": { "__type__": "cc.Color", - "r": 236, - "g": 91, - "b": 109, + "r": 91, + "g": 97, + "b": 236, "a": 255 }, "_contentSize": { "__type__": "cc.Size", - "width": 100, - "height": 40 + "width": 75, + "height": 25 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2476,7 +2479,7 @@ "ctor": "Float64Array", "array": [ 0, - 0, + 1.621, 0, 0, 0, @@ -2498,7 +2501,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "fb+PIvW+9EEK9AgjeG7x2u" + "_id": "11ZeWVEYNMUaFCYP1RHxLN" }, { "__type__": "cc.Node", @@ -2527,8 +2530,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 100, - "height": 40 + "width": 75, + "height": 25 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2562,7 +2565,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "53J/lkaFNLb7lUSF/NQJEu" + "_id": "1dYd4peONGsqCnBbUSLzCY" }, { "__type__": "cc.Label", @@ -2579,8 +2582,8 @@ ], "_srcBlendFactor": 770, "_dstBlendFactor": 771, - "_string": "解散队伍", - "_N$string": "解散队伍", + "_string": "刷新名称", + "_N$string": "刷新名称", "_fontSize": 14, "_lineHeight": 20, "_enableWrapText": false, @@ -2595,7 +2598,7 @@ "_N$fontFamily": "PingFangSC-Regular, sans-serif", "_N$overflow": 1, "_N$cacheMode": 0, - "_id": "4et9hzxqVKvbGwaFgDN5Zu" + "_id": "37I63cshVDKZNVNpPUmDje" }, { "__type__": "cc.PrefabInfo", @@ -2636,7 +2639,7 @@ "_fillRange": 0, "_isTrimmedMode": true, "_atlas": null, - "_id": "05X/cp2kBK55XwbwmifF3G" + "_id": "f2mcQvQ09I9JbX5aS3mDAu" }, { "__type__": "cc.Layout", @@ -2648,8 +2651,8 @@ "_enabled": true, "_layoutSize": { "__type__": "cc.Size", - "width": 100, - "height": 40 + "width": 75, + "height": 25 }, "_resize": 0, "_N$layoutType": 0, @@ -2668,7 +2671,7 @@ "_N$verticalDirection": 1, "_N$horizontalDirection": 0, "_N$affectedByScale": false, - "_id": "c9ULk8I51MNLg/bjk3aoIf" + "_id": "31QRZXBllK0oukK0RuYycM" }, { "__type__": "cc.PrefabInfo", @@ -2759,7 +2762,7 @@ "_N$target": { "__id__": 63 }, - "_id": "daq03oZB1HsrZWyuE2Yqp0" + "_id": "6cfG4nX71IdKdf65USQGp5" }, { "__type__": "cc.PrefabInfo", @@ -2767,12 +2770,12 @@ "__id__": 63 }, "asset": null, - "fileId": "03EIYKM9tDFr5hz9PhYpk9", + "fileId": "2d1v4gxL9HxahjHYgtiyJ5", "sync": false }, { "__type__": "cc.Node", - "_name": "enable_btn_match", + "_name": "enable_btn_dismiss", "_objFlags": 0, "_parent": { "__id__": 4 @@ -2813,7 +2816,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - 65, + -60, -300, 0, 0, @@ -2836,7 +2839,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "08Nh9fcjlJjpm53lTlNzSf" + "_id": "2el/H9Hl5BkI4ZyaId7Ns8" }, { "__type__": "cc.Node", @@ -2907,7 +2910,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "e8G1EPf5BEiL8pjbNtCcOc" + "_id": "fb+PIvW+9EEK9AgjeG7x2u" }, { "__type__": "cc.Node", @@ -2971,7 +2974,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "84fMmj08tDjLmVTbqXVZRG" + "_id": "53J/lkaFNLb7lUSF/NQJEu" }, { "__type__": "cc.Label", @@ -2988,9 +2991,9 @@ ], "_srcBlendFactor": 770, "_dstBlendFactor": 771, - "_string": "快速匹配", - "_N$string": "快速匹配", - "_fontSize": 14.4, + "_string": "解散队伍", + "_N$string": "解散队伍", + "_fontSize": 14, "_lineHeight": 20, "_enableWrapText": false, "_N$file": null, @@ -3004,7 +3007,7 @@ "_N$fontFamily": "PingFangSC-Regular, sans-serif", "_N$overflow": 1, "_N$cacheMode": 0, - "_id": "83801LJYRMdZiWOb3nrVFe" + "_id": "4et9hzxqVKvbGwaFgDN5Zu" }, { "__type__": "cc.PrefabInfo", @@ -3045,7 +3048,7 @@ "_fillRange": 0, "_isTrimmedMode": true, "_atlas": null, - "_id": "fclNo7hyVEsoOBgmFLbZZw" + "_id": "05X/cp2kBK55XwbwmifF3G" }, { "__type__": "cc.Layout", @@ -3077,7 +3080,7 @@ "_N$verticalDirection": 1, "_N$horizontalDirection": 0, "_N$affectedByScale": false, - "_id": "d9iTPIejtPtZ90ma3PkEPN" + "_id": "c9ULk8I51MNLg/bjk3aoIf" }, { "__type__": "cc.PrefabInfo", @@ -3102,7 +3105,7 @@ "zoomScale": 1.2, "clickEvents": [], "_N$interactable": true, - "_N$enableAutoGrayEffect": true, + "_N$enableAutoGrayEffect": false, "_N$transition": 1, "transition": 1, "_N$normalColor": { @@ -3168,7 +3171,7 @@ "_N$target": { "__id__": 73 }, - "_id": "64MBZBHDFBSobihPbKl7xZ" + "_id": "daq03oZB1HsrZWyuE2Yqp0" }, { "__type__": "cc.PrefabInfo", @@ -3176,12 +3179,12 @@ "__id__": 73 }, "asset": null, - "fileId": "67hXxeXPJE4pxE7y037hK8", + "fileId": "03EIYKM9tDFr5hz9PhYpk9", "sync": false }, { "__type__": "cc.Node", - "_name": "enable_btn_leave", + "_name": "enable_btn_match", "_objFlags": 0, "_parent": { "__id__": 4 @@ -3222,7 +3225,7 @@ "__type__": "TypedArray", "ctor": "Float64Array", "array": [ - -60, + 65, -300, 0, 0, @@ -3245,7 +3248,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "e2I6OWyRxNPKM7Lq/FM2DA" + "_id": "08Nh9fcjlJjpm53lTlNzSf" }, { "__type__": "cc.Node", @@ -3316,7 +3319,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "967OhnKUhKkqmR4ONqS3wy" + "_id": "e8G1EPf5BEiL8pjbNtCcOc" }, { "__type__": "cc.Node", @@ -3380,7 +3383,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "aa25lFamZPbaJr/fs1vuXM" + "_id": "84fMmj08tDjLmVTbqXVZRG" }, { "__type__": "cc.Label", @@ -3397,6 +3400,415 @@ ], "_srcBlendFactor": 770, "_dstBlendFactor": 771, + "_string": "快速匹配", + "_N$string": "快速匹配", + "_fontSize": 14.4, + "_lineHeight": 20, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "PingFangSC-Regular, sans-serif", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "83801LJYRMdZiWOb3nrVFe" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 83 + }, + "asset": null, + "fileId": "bdQT0jYe9Ck7KI+RtM8lWr", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 84 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "fclNo7hyVEsoOBgmFLbZZw" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 84 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_resize": 0, + "_N$layoutType": 0, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 0, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "d9iTPIejtPtZ90ma3PkEPN" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 83 + }, + "asset": null, + "fileId": "6fVjTjCPJI15eZscQLi68C", + "sync": false + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 83 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": true, + "_N$transition": 1, + "transition": 1, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 60 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 60 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 60 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 83 + }, + "_id": "64MBZBHDFBSobihPbKl7xZ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 83 + }, + "asset": null, + "fileId": "67hXxeXPJE4pxE7y037hK8", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "enable_btn_leave", + "_objFlags": 0, + "_parent": { + "__id__": 4 + }, + "_children": [ + { + "__id__": 94 + } + ], + "_active": true, + "_components": [ + { + "__id__": 101 + } + ], + "_prefab": { + "__id__": 102 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 72, + "g": 162, + "b": 248, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 38 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -60, + -300, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e2I6OWyRxNPKM7Lq/FM2DA" + }, + { + "__type__": "cc.Node", + "_name": "layout", + "_objFlags": 0, + "_parent": { + "__id__": 93 + }, + "_children": [ + { + "__id__": 95 + } + ], + "_active": true, + "_components": [ + { + "__id__": 98 + }, + { + "__id__": 99 + } + ], + "_prefab": { + "__id__": 100 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 236, + "g": 91, + "b": 109, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "967OhnKUhKkqmR4ONqS3wy" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 94 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 96 + } + ], + "_prefab": { + "__id__": 97 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "aa25lFamZPbaJr/fs1vuXM" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 95 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, "_string": "退出队伍", "_N$string": "退出队伍", "_fontSize": 14, @@ -3418,7 +3830,7 @@ { "__type__": "cc.PrefabInfo", "root": { - "__id__": 83 + "__id__": 93 }, "asset": null, "fileId": "bdQT0jYe9Ck7KI+RtM8lWr", @@ -3429,7 +3841,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 84 + "__id__": 94 }, "_enabled": true, "_materials": [ @@ -3461,7 +3873,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 84 + "__id__": 94 }, "_enabled": true, "_layoutSize": { @@ -3491,7 +3903,7 @@ { "__type__": "cc.PrefabInfo", "root": { - "__id__": 83 + "__id__": 93 }, "asset": null, "fileId": "6fVjTjCPJI15eZscQLi68C", @@ -3502,7 +3914,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 83 + "__id__": 93 }, "_enabled": true, "_normalMaterial": null, @@ -3575,14 +3987,14 @@ "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" }, "_N$target": { - "__id__": 83 + "__id__": 93 }, "_id": "2e04itMQhLXq8E0NBe2AWs" }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 83 + "__id__": 93 }, "asset": null, "fileId": "77KMonbKZGbKNObYyiTLBA", @@ -3749,17 +4161,23 @@ "__id__": 2 }, "_enabled": true, + "updateBtn": { + "__id__": 71 + }, + "teamName": { + "__id__": 7 + }, "playerNum": { "__id__": 16 }, "enableDismissBtn": { - "__id__": 63 + "__id__": 73 }, "enableMatchBtn": { - "__id__": 73 + "__id__": 83 }, "enableLeaveBtn": { - "__id__": 83 + "__id__": 93 }, "reloadingPrefab": { "__uuid__": "ee4b28a3-433f-4323-815d-ad9c2c0b9195" diff --git a/cocos/assets/Script/commonValue.ts b/cocos/assets/Script/commonValue.ts index f3cf79e..36d4dcb 100644 --- a/cocos/assets/Script/commonValue.ts +++ b/cocos/assets/Script/commonValue.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ export enum RoomType { OneVOne = 1, // 1 V 1 类型房间 TwoVTwo = 2, // 2 V 2 类型房间 ThreeVOne = 3, // 3 V 1 类型房间 + OneGroup = 4 } export enum LockType { diff --git a/cocos/assets/Script/comp/Bullet.ts b/cocos/assets/Script/comp/Bullet.ts index 06cee05..013e12d 100644 --- a/cocos/assets/Script/comp/Bullet.ts +++ b/cocos/assets/Script/comp/Bullet.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/comp/Circle.ts b/cocos/assets/Script/comp/Circle.ts index b1fdec1..11f7396 100644 --- a/cocos/assets/Script/comp/Circle.ts +++ b/cocos/assets/Script/comp/Circle.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/comp/FrameSyncView.ts b/cocos/assets/Script/comp/FrameSyncView.ts index 49572f7..df9fd82 100644 --- a/cocos/assets/Script/comp/FrameSyncView.ts +++ b/cocos/assets/Script/comp/FrameSyncView.ts @@ -33,7 +33,7 @@ * 2023.06.28-Add method processServerInfo * 2023.06.28-Add method reCalcFrameState * 2023.06.28-Add method updateBullet - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ // Learn TypeScript: diff --git a/cocos/assets/Script/comp/GameCanvas.ts b/cocos/assets/Script/comp/GameCanvas.ts index 8926450..0dbaba0 100644 --- a/cocos/assets/Script/comp/GameCanvas.ts +++ b/cocos/assets/Script/comp/GameCanvas.ts @@ -30,7 +30,7 @@ * 2023.06.28-Changed method setPlayers * 2023.06.28-Changed method setBullet * 2023.06.28-Add method destroyBullet - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ // Learn TypeScript: diff --git a/cocos/assets/Script/comp/Player.ts b/cocos/assets/Script/comp/Player.ts index cf3d004..91d25d6 100644 --- a/cocos/assets/Script/comp/Player.ts +++ b/cocos/assets/Script/comp/Player.ts @@ -23,7 +23,7 @@ * 2021.12.15-Changed method initPlayer * 2023.06.28-Changed method initPlayer * 2021.12.15-Changed method onCollisionEnter - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ // Learn TypeScript: diff --git a/cocos/assets/Script/function/BulletList.ts b/cocos/assets/Script/function/BulletList.ts index 23d8467..dd04eed 100644 --- a/cocos/assets/Script/function/BulletList.ts +++ b/cocos/assets/Script/function/BulletList.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/function/CloudList.ts b/cocos/assets/Script/function/CloudList.ts index 57146d4..066fe0f 100644 --- a/cocos/assets/Script/function/CloudList.ts +++ b/cocos/assets/Script/function/CloudList.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/function/Common.ts b/cocos/assets/Script/function/Common.ts index a71066b..841a06d 100644 --- a/cocos/assets/Script/function/Common.ts +++ b/cocos/assets/Script/function/Common.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/function/FrameSync.ts b/cocos/assets/Script/function/FrameSync.ts index 3375bb1..48ab448 100644 --- a/cocos/assets/Script/function/FrameSync.ts +++ b/cocos/assets/Script/function/FrameSync.ts @@ -46,8 +46,8 @@ * 2023.06.28-Deleted method handleCollide * 2023.06.28-Deleted method calcFrame * 2023.06.28-Deleted method initPlayer - - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ import {PlayerList, PlayerData} from "./PlayerList"; diff --git a/cocos/assets/Script/function/ItemTemplate.ts b/cocos/assets/Script/function/ItemTemplate.ts index eb989b4..481d9d4 100644 --- a/cocos/assets/Script/function/ItemTemplate.ts +++ b/cocos/assets/Script/function/ItemTemplate.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,22 +21,18 @@ import {RoomInfo} from "../../GOBE/GOBE"; @ccclass export class ItemTemplate extends Component { - @property - public roomId: string = ''; @property(cc.Label) - public roomName: cc.Label | null = null; + public roomId: cc.Label | null = null; @property(cc.Label) - public roomDesc: cc.Label | null = null; + public roomName: cc.Label | null = null; @property(cc.Label) public roomStatus: cc.Label | null = null; @property(cc.Node) public backGround: cc.Node | null = null; init(data: RoomInfo) { - this.roomId = data.roomId; + this.roomId.string = data.roomId.length > 20 ? data.roomId.slice(0,20) : data.roomId; this.roomName.string = data.roomName.length > 20 ? data.roomName.slice(0,20) + "..." : data.roomName; - this.roomDesc.string = data.roomId.length > 20 ? data.roomId.slice(0,20) : data.roomId; - this.roomStatus.string = data.roomStatus==1?"游戏中":"空闲"; - + this.roomStatus.string = data.roomStatus == 1 ? "游戏中" : "空闲"; } } \ No newline at end of file diff --git a/cocos/assets/Script/function/PlayerList.ts b/cocos/assets/Script/function/PlayerList.ts index 13bc7a6..37e0c4d 100644 --- a/cocos/assets/Script/function/PlayerList.ts +++ b/cocos/assets/Script/function/PlayerList.ts @@ -23,7 +23,7 @@ * 2021.12.15-Changed interface PlayerData * 2021.06.28-Changed interface PlayerData * 2021.06.28-Changed interface PlayerList - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ export interface PlayerData { diff --git a/cocos/assets/Script/function/RecordItem.ts b/cocos/assets/Script/function/RecordItem.ts index 234bdc8..5b7e558 100644 --- a/cocos/assets/Script/function/RecordItem.ts +++ b/cocos/assets/Script/function/RecordItem.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,16 +62,17 @@ export class RecordItem extends Component { .then(async (res: ArrayBuffer) => { const pathName = remoteUrl.substring(remoteUrl.lastIndexOf('_') + 1, remoteUrl.lastIndexOf('.')); const fileName = remoteUrl.substring(remoteUrl.lastIndexOf('/') + 1, remoteUrl.lastIndexOf('.')); - let result; - if (cc.sys.isBrowser) { + let checkSumSuccess = false; + // 无crypto.subtle.digest方法,跳过sha256sum校验 + if ((typeof crypto === "object" && typeof crypto.subtle === "object" + && typeof crypto.subtle.digest === "function")) { const sha256 = await getFileHash(res); - result = sha256 == fileSha256; - console.log(`文件完整性校验成功,sha256: ${sha256}`); + checkSumSuccess = sha256 === fileSha256; + console.log(`文件完整性校验,result=${checkSumSuccess},sha256: ${sha256}`); + } else { + checkSumSuccess = true; } - else { - result = true; - } - if (result) { + if (checkSumSuccess) { let newZip = new JSZip(); newZip.loadAsync(res).then(zip => { zip.file(`${pathName}/${fileName}.data`).async('text').then(data => { diff --git a/cocos/assets/Script/scene/asymmetricroom.ts b/cocos/assets/Script/scene/asymmetricroom.ts index f768f52..4c0f274 100644 --- a/cocos/assets/Script/scene/asymmetricroom.ts +++ b/cocos/assets/Script/scene/asymmetricroom.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -353,15 +353,16 @@ export default class AsymmetricRoom extends cc.Component { async onDisconnect(playerInfo: PlayerInfo) { Util.printLog("玩家掉线"); if (playerInfo.playerId === global.playerId) { + global.isConnected = false; // 没有超过重连时间,就进行重连操作 while (!global.isConnected){ - // 1秒重连一次,防止并发过大游戏直接卡死 - await sleep(1000).then(); global.room.reconnect().then(() => { Util.printLog("reconnect success"); }).catch((error) => { Util.printLog("reconnect err"); }); + // 2秒重连一次,防止并发过大游戏直接卡死 + await sleep(2000).then(); } } } diff --git a/cocos/assets/Script/scene/game.ts b/cocos/assets/Script/scene/game.ts index cb98c7c..bd6b227 100644 --- a/cocos/assets/Script/scene/game.ts +++ b/cocos/assets/Script/scene/game.ts @@ -59,7 +59,12 @@ * 2023.06.28-Changed method reConnect * 2023.06.28-Deleted method updateBulletFly * 2023.06.28-Deleted method sendFireFrame - * Copyright(C)2023. Huawei Technologies Co., Ltd. All rights reserved + * 2024.12.16-Changed method reConnect + * 2024.12.16-Changed method syncRoomProp + * 2024.12.16-Changed method onDisconnect + * 2024.12.16-Changed method onStopFrameSync + * + * Copyright(C)2024. Huawei Technologies Co., Ltd. All rights reserved */ import global from "../../global"; @@ -273,6 +278,7 @@ export default class Game extends cc.Component { else { roomProperties = { roomType: global.roomType, + isOnlineMatch:global.isOnlineMatch, frameSyncPlayerArr: frameSyncPlayerList.players, curFrameId: global.curHandleFrameId } @@ -549,6 +555,7 @@ export default class Game extends cc.Component { onDisconnect(playerInfo: PlayerInfo) { Util.printLog("玩家掉线"); if (playerInfo.playerId === global.playerId) { + global.isConnected = false; Reloading.open("正在重连。。。", false); this.reConnect(); } @@ -670,11 +677,6 @@ export default class Game extends cc.Component { if (global.gameSceneType == GameSceneType.FOR_WATCHER){ this.watcherLeaveRoom(); }else{ - global.client.room.sendToServer(JSON.stringify({ - playerId: global.client.playerId, - type: "GameEnd", - value: Math.random() > 0.5 ? 1 : 0 - })); cc.director.loadScene("gameend"); } } else { @@ -779,13 +781,13 @@ export default class Game extends cc.Component { } else { // 没有超过重连时间,就进行重连操作 while (!global.isConnected){ - // 1秒重连一次,防止并发过大游戏直接卡死 - await sleep(1000).then(); global.room.reconnect().then(() => { Util.printLog("reconnect success"); }).catch((error) => { Util.printLog("reconnect err"); }); + // 2秒重连一次,防止并发过大游戏直接卡死 + await sleep(2000).then(); } } } diff --git a/cocos/assets/Script/scene/gameend.ts b/cocos/assets/Script/scene/gameend.ts index 5f0a293..b7b0eb9 100644 --- a/cocos/assets/Script/scene/gameend.ts +++ b/cocos/assets/Script/scene/gameend.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,16 @@ export default class GameEnd extends cc.Component { start() { this.initDialog(); this.initListener(); + this.reportGameEndInfo(); + } + + reportGameEndInfo() { + console.log('上报结算消息'); + global.client.room.sendToServer(JSON.stringify({ + playerId: global.client.playerId, + type: "GameEnd", + value: Math.random() > 0.5 ? 1 : 0 + })); } initDialog() { diff --git a/cocos/assets/Script/scene/gameend.ts.meta b/cocos/assets/Script/scene/gameend.ts.meta index 14fea15..e5a9dda 100644 --- a/cocos/assets/Script/scene/gameend.ts.meta +++ b/cocos/assets/Script/scene/gameend.ts.meta @@ -1,6 +1,6 @@ { "ver": "1.0.8", - "uuid": "159bf6fb-5d98-4263-972d-6f90cd480a18", + "uuid": "a78d93a6-763a-450f-8750-dc31fefb96b6", "isPlugin": false, "loadPluginInWeb": true, "loadPluginInNative": true, diff --git a/cocos/assets/Script/scene/hall.ts b/cocos/assets/Script/scene/hall.ts index 4c8e498..1337fad 100644 --- a/cocos/assets/Script/scene/hall.ts +++ b/cocos/assets/Script/scene/hall.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,6 +89,7 @@ export default class Hall extends cc.Component { // 绑定在线/组队匹配监听事件 global.client.onMatch.clear(); global.client.onMatch((onMatchResponse) => this.onMatch(onMatchResponse)); + global.client.onKickOff(()=>this.onKickOff()) } /** @@ -224,4 +225,8 @@ export default class Hall extends cc.Component { Util.printLog('取消匹配失败'); }) } + + private onKickOff() { + Util.printLog('多端登录,玩家离线'); + } } diff --git a/cocos/assets/Script/scene/home.ts b/cocos/assets/Script/scene/home.ts index ae17482..54e7301 100644 --- a/cocos/assets/Script/scene/home.ts +++ b/cocos/assets/Script/scene/home.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ import {LoginType, RoomType} from "../commonValue"; import * as Util from "../../util"; import global from "../../global"; import Dialog from "../comp/Dialog"; +import config from "../../config"; +import Reloading from "../comp/Reloading"; const {ccclass, property} = cc._decorator; @@ -66,12 +68,14 @@ export default class Home extends cc.Component { }; if (cc.sys.ANDROID === cc.sys.platform) { clientConfig = Object.assign(clientConfig, { - platform: window.GOBE.PlatformType.CC_ANDROID, + platform: window.GOBE.PlatformType.ANDROID, cerPath: cc.url.raw('resources/endpoint-cert.cer'), }) } + window.GOBE.Logger.level = window.GOBE.LogLevel.DEBUG; global.client = new window.GOBE.Client(clientConfig); global.client.onInitResult((resultCode) => this.onInitResult(resultCode)); + global.client.onMatch((onMatchResponse) => this.onMatch(onMatchResponse)); Util.printLog("正在初始化 SDK"); global.client.init().catch((e) => { Util.printLog('init err: ' + e); @@ -87,51 +91,84 @@ export default class Home extends cc.Component { // demo生成昵称保存到global global.playerName = Util.mockPlayerName(); Util.printLog('init success'); - if(global.client.lastRoomId){ - Util.printLog('房间Id' + global.client.lastRoomId); - global.client.joinRoom(global.client.lastRoomId, - {customPlayerStatus: 0, customPlayerProperties: ""}).then((room) => { - Util.printLog("加入房间成功"); - global.room = room; - global.player = room.player; - Util.printLog('玩家id :' + global.player.playerId + ' 房主id :' + global.room.ownerId); - // 重置帧id - let roomProp = JSON.parse(global.room.customRoomProperties); - if(roomProp.curFrameId) { - room.resetRoomFrameId(roomProp.curFrameId); - } - if (roomProp.roomType) { - global.roomType = roomProp.roomType; - if(roomProp.roomType === RoomType.OneVOne) { - cc.director.loadScene("room"); - } else if (roomProp.roomType === RoomType.TwoVTwo) { - cc.director.loadScene("teamroom"); - } else if (roomProp.roomType === RoomType.ThreeVOne) { - cc.director.loadScene("asymmetricroom"); + if (global.client.lastRoomId || global.client.lastGroupId){ + if(global.client.lastRoomId) { + Util.printLog('房间Id' + global.client.lastRoomId); + global.client.joinRoom(global.client.lastRoomId, + {customPlayerStatus: 0, customPlayerProperties: ""}).then((room) => { + Util.printLog("加入房间成功"); + global.room = room; + global.player = room.player; + Util.printLog('玩家id :' + global.player.playerId + ' 房主id :' + global.room.ownerId); + // 重置帧id + let roomProp = JSON.parse(global.room.customRoomProperties); + global.isOnlineMatch = roomProp.isOnlineMatch; + Util.printLog("isOnlineMatch:"+global.isOnlineMatch); + if (roomProp.curFrameId) { + room.resetRoomFrameId(roomProp.curFrameId); } - } - }).catch((e) => { - Util.printLog('加入房间失败,roomId: ' + global.client.lastRoomId); - Dialog.open("提示", "加入房间失败" + Util.errorMessage(e)); - global.client.leaveRoom().then(() => { - Util.printLog("leaveRoom success"); - global.roomType = RoomType.NULL; + if (roomProp.roomType) { + global.roomType = roomProp.roomType; + if(roomProp.roomType === RoomType.OneVOne) { + global.jumpType = RoomType.OneVOne; + cc.director.loadScene("room"); + } else if (roomProp.roomType === RoomType.TwoVTwo) { + global.jumpType = RoomType.TwoVTwo; + cc.director.loadScene("teamroom"); + } else if (roomProp.roomType === RoomType.ThreeVOne) { + global.jumpType = RoomType.ThreeVOne; + cc.director.loadScene("asymmetricroom"); + }else{ + global.jumpType = RoomType.OneGroup; + } + } + }).catch((e) => { + Util.printLog('加入房间失败,roomId: ' + global.client.lastRoomId); + Dialog.open("提示", "加入房间失败" + Util.errorMessage(e)); + global.client.leaveRoom().then(() => { + Util.printLog("leaveRoom success"); + global.roomType = RoomType.NULL; + }); + cc.director.loadScene("hall"); }); - cc.director.loadScene("hall"); - }); - } - else{ - global.roomType = RoomType.NULL; + } + if (global.client.lastGroupId){ + //global.roomType = RoomType.NULL; + // 检测是否要进行group重连 + console.log('lastGroupId存在:' + global.client.lastGroupId); + global.client.joinGroup(global.client.lastGroupId).then((group) => { + global.group = group; + global.player = group.player; + if (!global.client.lastRoomId || global.jumpType === RoomType.OneGroup) + cc.director.loadScene("team"); + }); + } + } else{ cc.director.loadScene("hall"); } - - window.GOBE.Logger.level = window.GOBE.LogLevel.INFO; + window.GOBE.Logger.level = window.GOBE.LogLevel.DEBUG; Util.printLog('init success'); } else { Util.printLog('init failed'); } } + onMatch(res){ + Util.printLog('触发匹配'); + Util.printLog(global.group.customGroupProperties); + if (res.rtnCode === 0) { + Util.printLog('在线匹配成功:' + res.room); + global.room = res.room; + global.player = res.room.player; + global.group = global.client.group; + cc.director.loadScene(config.asymmetric ? "asymmetricroom" : "teamroom"); + Reloading.close(); + } else { + Util.printLog("在线匹配失败" + Util.errorMessage(res)); + Reloading.close(); + } + } + onDisable() { // 关闭对话框 Dialog.close(); diff --git a/cocos/assets/Script/scene/match.ts b/cocos/assets/Script/scene/match.ts index bb9f357..c313978 100644 --- a/cocos/assets/Script/scene/match.ts +++ b/cocos/assets/Script/scene/match.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/scene/recordList.ts b/cocos/assets/Script/scene/recordList.ts index 771a687..dcb1ba0 100644 --- a/cocos/assets/Script/scene/recordList.ts +++ b/cocos/assets/Script/scene/recordList.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/scene/room.ts b/cocos/assets/Script/scene/room.ts index 81a624e..2701ba4 100644 --- a/cocos/assets/Script/scene/room.ts +++ b/cocos/assets/Script/scene/room.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,22 @@ import global from "../../global"; import * as Util from "../../util"; -import { PlayerInfo, UpdateCustomStatusResponse, UpdateCustomPropertiesResponse, RoomInfo, RecvFromServerInfo } from "../../GOBE/GOBE"; +import { + PlatformType, + PlayerInfo, + RecvFromServerInfo, + RoomInfo, + UpdateCustomPropertiesResponse, + UpdateCustomStatusResponse +} from "../../GOBE/GOBE"; import Dialog from "../comp/Dialog"; -import {RoomType} from "../commonValue"; +import {LockType, RoomType} from "../commonValue"; import {setRoomType, sleep} from "../function/Common"; import Button = cc.Button; import Label = cc.Label; import {GameSceneType} from "../function/FrameSync"; +import error = cc.error; +import {errorMessage} from "../../util"; const {ccclass, property} = cc._decorator; @@ -225,7 +234,7 @@ export default class Room extends cc.Component { onRoomPropertiesChange(roomInfo: RoomInfo) { // TODO拿到roomInfo重置本地数据,刷新页面 console.log('onRoomPropertiesChange ' + JSON.stringify(roomInfo)); - this.isLockRoom.isChecked = roomInfo.isLock == 1; + this.isLockRoom.isChecked = roomInfo.isLock == LockType.Locked; } // 准备 @@ -245,7 +254,7 @@ export default class Room extends cc.Component { // 锁定与解锁房间 lockRoom() { if (global.room && global.room.ownerId === global.room.playerId) { - global.room.updateRoomProperties({isLock: !this.isLockRoom.isChecked ? 1 : 0}); + global.room.updateRoomProperties({roomType: 'lock-type' , isLock: !this.isLockRoom.isChecked ? LockType.Locked : LockType.UnLocked}); } } @@ -310,7 +319,7 @@ export default class Room extends cc.Component { roomInfo.ownerId === global.playerId, roomInfo.players.length, readyStatus === 1, - roomInfo.isLock == 1 + roomInfo.isLock == LockType.Locked ); } @@ -545,9 +554,21 @@ export default class Room extends cc.Component { } else { // 没有超过重连时间,就进行重连操作 while (!global.isConnected){ - // 1秒重连一次,防止并发过大游戏直接卡死 - await sleep(1000).then(); - await global.room.reconnect(); + await global.room.reconnect().then(() => { + Util.printLog("玩家重连房间成功"); + }).catch((error) => { + if (!error.code || error.code === 91002) { + // 加入房间请求不通就继续重连 + Util.printLog("玩家重连房间失败,重新尝试"); + } + if (error.code && (error.code === 101117 || error.code === 101107 || error.code === 101120)) { + // 无法加入房间需要退出到大厅 + Util.printLog("玩家重连房间失败"); + cc.director.loadScene("hall"); + } + }); + // 2秒重连一次,防止并发过大游戏直接卡死 + await sleep(2000).then(); } } } else { diff --git a/cocos/assets/Script/scene/roominfo.ts b/cocos/assets/Script/scene/roominfo.ts index 9374a35..5f03b7b 100644 --- a/cocos/assets/Script/scene/roominfo.ts +++ b/cocos/assets/Script/scene/roominfo.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/assets/Script/scene/roomlist.ts b/cocos/assets/Script/scene/roomlist.ts index 63b9e87..f17ae5d 100644 --- a/cocos/assets/Script/scene/roomlist.ts +++ b/cocos/assets/Script/scene/roomlist.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,7 +162,7 @@ export default class RoomList extends cc.Component { scriptComponent.fresh(); const cls: cc.Node[] = scriptComponent.node.children; for (let i = 0; i < cls.length; ++i) { - const backGround = cls[i].getComponent("ItemTemplate").backGround + const backGround = cls[i].getComponent("ItemTemplate").backGround; backGround.on(cc.Node.EventType.TOUCH_START, () => this.freshEdit(global.roomInfos[i])); } } @@ -176,10 +176,10 @@ export default class RoomList extends cc.Component { changeList() { if (global.roomInfos) { const nums: number = global.roomInfos.length; - if (nums <= 10) { - this.listContent.height = 720 + if (nums < 7) { + this.listContent.height = 470; } else { - this.listContent.height = 720 + (nums - 10) * 47 + this.listContent.height = 70 * nums; } } } diff --git a/cocos/assets/Script/scene/team.ts b/cocos/assets/Script/scene/team.ts index 85c8c4d..aa1b7e2 100644 --- a/cocos/assets/Script/scene/team.ts +++ b/cocos/assets/Script/scene/team.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,19 @@ import {PlayerInfo} from "../../GOBE/GOBE"; import Reloading from "../comp/Reloading"; import config from "../../config"; import Dialog from "../comp/Dialog"; +import {sleep} from "../function/Common"; +import Global from "../../global"; const {ccclass, property} = cc._decorator; @ccclass export default class Team extends cc.Component { - + // 刷新队伍名称 + @property(cc.Button) + updateBtn: cc.Button = null; + // 队伍名称 + @property(cc.Label) + teamName: cc.Label = null; // 当前玩家数 @property(cc.Label) playerNum: cc.Label = null; @@ -72,6 +79,7 @@ export default class Team extends cc.Component { // 队伍code this.teamCodeEditBox.string = group.id; Util.printLog("队伍code:" + group.id); + this.teamName.string = '队伍名称:' + group.groupName; // 获取队长玩家 let ownerPlayer: PlayerInfo = null; let players = group.players; @@ -117,6 +125,7 @@ export default class Team extends cc.Component { this.enableDismissBtn.active = true; // 隐藏“退出队伍”按钮 this.enableLeaveBtn.active = false; + this.updateBtn.node.active = true; } else { // 不是队长 // 隐藏“解散队伍”、“快速匹配”按钮 this.isOwner = false; @@ -124,6 +133,7 @@ export default class Team extends cc.Component { this.enableDismissBtn.active = false; // 显示“退出队伍”按钮 this.enableLeaveBtn.active = true; + this.updateBtn.node.active = false; } // 设置加载Dialog const relaodingNode = cc.instantiate(this.reloadingPrefab) as cc.Node; @@ -137,15 +147,32 @@ export default class Team extends cc.Component { this.enableLeaveBtn.on(cc.Node.EventType.TOUCH_START, () => this.leaveGroup()); // 绑定“快速匹配”按钮 this.enableMatchBtn.on(cc.Node.EventType.TOUCH_START, () => this.teamMatch()); + // 更新队伍名称 + this.updateBtn.node.on(cc.Node.EventType.TOUCH_START, () => this.updateTeamName()); // 清除group绑定事件 this.clearListener() // 监听心跳事件(demo根据不同的事件,对数据或界面更新) global.group.onDismiss(() => this.onDismiss()); - global.group.onLeave((serverEvent) => this.onLeave(serverEvent)); - global.group.onJoin(() => this.onJoin()); - global.group.onMatchStart((serverEvent) => this.onTeamMatch(serverEvent)); + global.group.onLeave((playerInfo) => this.onLeave(playerInfo)); + global.group.onJoin((playerInfo) => this.onJoin(playerInfo)); + global.group.onMatchStart(() => this.onTeamMatch()); + global.group.onUpdate((groupInfo) => this.onUpdate(groupInfo)); + // 断线重连 + global.group.onDisconnect((playerInfo: PlayerInfo) => this.onDisconnect(playerInfo)); // 断连监听 + } + + updateTeamName() { + const name = `随机队伍${Math.floor(Math.random() * 90 + 10)}`; + global.group.updateGroup({groupName: name}).then(() => { + console.log(`更新小队名称为${name}`); + }); + } + + onUpdate(groupInfo) { + this.teamName.string = '队伍名称:' + groupInfo.groupName; + console.log('更新队伍名称成功: ' + groupInfo.groupName); } clearListener() { @@ -195,13 +222,10 @@ export default class Team extends cc.Component { /** * 监听“退出队伍” */ - onLeave(serverEvent) { - let parseEventParam: any; - if (serverEvent.eventParam) { - parseEventParam = JSON.parse(serverEvent.eventParam); - } + onLeave(playerInfo) { + console.log('触发了离开小队的消息'); // 当前操作人id(比如是谁退出了队伍) - let operator = parseEventParam.group.players[0].playerId; + let operator = playerInfo.playerId; if (operator == global.playerId) { // 是本人退出 cc.director.loadScene("hall"); } else { @@ -212,8 +236,8 @@ export default class Team extends cc.Component { /** * 监听“加入队伍” */ - onJoin() { - Util.printLog("加入队伍"); + onJoin(serverEvent) { + Util.printLog("加入队伍: " + JSON.stringify(serverEvent)); //更新队伍信息 this.updateGroup(); } @@ -254,10 +278,10 @@ export default class Team extends cc.Component { /** * 监听“组队匹配” */ - onTeamMatch(serverEvent) { + onTeamMatch() { Util.printLog('isOwner:' + this.isOwner); - Util.printLog('心跳:匹配开始通知,serverEvent =' + serverEvent); - if (!this.isOwner && serverEvent.eventType === 1) { + Util.printLog('心跳:匹配开始通知'); + if (!this.isOwner) { // 如果不是队长就弹出匹配中 Reloading.open("队员匹配中。。。", false); global.client.matchQuery(); @@ -319,4 +343,33 @@ export default class Team extends cc.Component { global.group.removeAllListeners(); } } + + async onDisconnect(playerInfo: PlayerInfo) { + Util.printLog("玩家掉线"); + if (playerInfo.playerId === global.playerId) { + Global.isGroupConnected = false; + await this.reConnectGroup(); + } + } + + async reConnectGroup() { + while (!Global.isGroupConnected){ + // 没有超过重连时间,就进行重连操作 + await global.group.reconnect().then(() => { + Global.isGroupConnected = true; + Util.printLog("玩家重连小队成功"); + }).catch((error) => { + if (!error.code || error.code === 91002) { + // 加入房间请求不通就继续重连 + Util.printLog("玩家重连小队失败,重新尝试"); + } + if (error.code && (error.code === 101205 || error.code === 101206 || error.code === 101202)) { + // 无法加入房间需要退出到大厅 + Util.printLog("玩家重连小队失败"); + cc.director.loadScene("hall"); + } + }); + await sleep(2000).then(); + } + } } diff --git a/cocos/assets/Script/scene/teamroom.ts b/cocos/assets/Script/scene/teamroom.ts index df76bc8..1106c66 100644 --- a/cocos/assets/Script/scene/teamroom.ts +++ b/cocos/assets/Script/scene/teamroom.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import {RoomType} from "../commonValue"; import global from "../../global"; import Dialog from "../comp/Dialog"; import {PlayerInfo} from "../../GOBE/GOBE"; -import {setRoomType} from "../function/Common"; +import {setRoomType, sleep} from "../function/Common"; import {GameSceneType} from "../function/FrameSync"; @@ -251,28 +251,33 @@ export default class TeamRoom extends cc.Component { global.room.onLeave((playerInfo) => this.onLeaving(playerInfo)) } - onDisconnect(playerInfo: PlayerInfo) { + async onDisconnect(playerInfo: PlayerInfo) { Util.printLog("玩家掉线"); if (playerInfo.playerId === global.playerId) { + global.isConnected = false; this.reConnectRoom(); } } - reConnectRoom() { + async reConnectRoom() { // 没有超过重连时间,就进行重连操作 - global.room.reconnect().then(() => { - Util.printLog("玩家重连成功"); - }).catch((error) => { - if (!error.code) { - // 加入房间请求不通就继续重连 - this.reConnectRoom(); - return; - } - if (error.code != 0) { - // 无法加入房间需要退出到大厅 - cc.director.loadScene("hall"); - } - }); + while (!global.isConnected){ + await global.room.reconnect().then(() => { + global.isConnected = true; + Util.printLog("玩家重连房间成功"); + }).catch((error) => { + if (!error.code || error.code === 91002) { + // 加入房间请求不通就继续重连 + Util.printLog("玩家重连房间失败,重新尝试"); + } + if (error.code && (error.code === 101117 || error.code === 101107 || error.code === 101120)) { + // 无法加入房间需要退出到大厅 + Util.printLog("玩家重连房间失败"); + cc.director.loadScene("hall"); + } + }); + await sleep(2000).then(); + } } leaveRoom() { diff --git a/cocos/assets/config.ts b/cocos/assets/config.ts index 35f9fa2..b1218b5 100644 --- a/cocos/assets/config.ts +++ b/cocos/assets/config.ts @@ -17,7 +17,8 @@ import * as Util from "./util"; export default { - openId: Util.mockOpenId(), // 区别不同用户 + openId: Util.mockOpenId(0), // 区别不同用户 + channel: 0, grantType: "client_credentials", asymmetric: false, handleFrameRate: 3, //补帧的速率(出现补帧时,每次处理3帧) @@ -27,5 +28,5 @@ export default { clientSecret: "", matchCode: "", asymmetricMatchCode:"", - + }; diff --git a/cocos/assets/global.ts b/cocos/assets/global.ts index 5e7d9f2..a499d18 100644 --- a/cocos/assets/global.ts +++ b/cocos/assets/global.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,9 @@ class GlobalData { public roomType: RoomType = RoomType.NULL; // 房间类型,区分1v1、2v2、3v1类型房间,重连时用\ public isConnected: boolean = false; // 长链是否是连接状态,默认false + public jumpType: number = 0; // 跳转方式 1-小队跳转 2-房间跳转 + + public isGroupConnected: boolean = false; // 长链是否是连接状态,默认false public planeSize: number = 15; // 飞机尺寸,圆形,半径为15像素 public planeStepPixel: number = 20; // 飞机每步移动像素 diff --git a/cocos/assets/resources/prefab/room_item.prefab b/cocos/assets/resources/prefab/room_item.prefab index 28a8ca9..8b9f982 100644 --- a/cocos/assets/resources/prefab/room_item.prefab +++ b/cocos/assets/resources/prefab/room_item.prefab @@ -19,96 +19,32 @@ "_children": [ { "__id__": 2 - } - ], - "_active": true, - "_components": [ - { - "__id__": 25 - } - ], - "_prefab": { - "__id__": 26 - }, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 0, - "height": 0 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_trs": { - "__type__": "TypedArray", - "ctor": "Float64Array", - "array": [ - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1 - ] - }, - "_eulerAngles": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_skewX": 0, - "_skewY": 0, - "_is3DNode": false, - "_groupIndex": 0, - "groupIndex": 0, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "dialog", - "_objFlags": 0, - "_parent": { - "__id__": 1 - }, - "_children": [ - { - "__id__": 3 }, { - "__id__": 6 + "__id__": 5 }, { - "__id__": 9 + "__id__": 8 }, { - "__id__": 12 + "__id__": 11 }, { - "__id__": 15 + "__id__": 14 }, { - "__id__": 18 + "__id__": 17 }, { - "__id__": 21 + "__id__": 20 } ], "_active": true, - "_components": [], + "_components": [ + { + "__id__": 23 + } + ], "_prefab": { "__id__": 24 }, @@ -164,17 +100,17 @@ "_name": "bg_color", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 4 + "__id__": 3 } ], "_prefab": { - "__id__": 5 + "__id__": 4 }, "_opacity": 255, "_color": { @@ -228,7 +164,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 3 + "__id__": 2 }, "_enabled": true, "_materials": [ @@ -263,7 +199,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "efxtJASkNMj6YHdhSn1+yg", + "fileId": "013e2OmJZJ0rKOYhR9Z+tt", "sync": false }, { @@ -271,17 +207,17 @@ "_name": "room_name_title", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 7 + "__id__": 6 } ], "_prefab": { - "__id__": 8 + "__id__": 7 }, "_opacity": 255, "_color": { @@ -335,7 +271,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 6 + "__id__": 5 }, "_enabled": true, "_materials": [ @@ -371,7 +307,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "5bidU77jJC/Lg5CtPRG2Zx", + "fileId": "1b2ZXFP3pIxIlTCLTkI1Mx", "sync": false }, { @@ -379,17 +315,17 @@ "_name": "room_name", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 10 + "__id__": 9 } ], "_prefab": { - "__id__": 11 + "__id__": 10 }, "_opacity": 255, "_color": { @@ -443,7 +379,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 9 + "__id__": 8 }, "_enabled": true, "_materials": [ @@ -479,7 +415,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "76MVCpPS9DgYE9SMBwGt/I", + "fileId": "56JBPk6ixNgraP55z6Tfma", "sync": false }, { @@ -487,17 +423,17 @@ "_name": "room_id_title", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 13 + "__id__": 12 } ], "_prefab": { - "__id__": 14 + "__id__": 13 }, "_opacity": 255, "_color": { @@ -551,7 +487,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 12 + "__id__": 11 }, "_enabled": true, "_materials": [ @@ -587,7 +523,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "3eg1uECCBLQZ1ezb8TTgYk", + "fileId": "4eZV3II09IlYdNMAPEVa7d", "sync": false }, { @@ -595,17 +531,17 @@ "_name": "room_id", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 16 + "__id__": 15 } ], "_prefab": { - "__id__": 17 + "__id__": 16 }, "_opacity": 255, "_color": { @@ -659,7 +595,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 15 + "__id__": 14 }, "_enabled": true, "_materials": [ @@ -695,7 +631,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "abUtBp+A1NWa0izVtkFOzl", + "fileId": "84W+784qRBqaj1uEesjbc4", "sync": false }, { @@ -703,17 +639,17 @@ "_name": "room_status_title", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 19 + "__id__": 18 } ], "_prefab": { - "__id__": 20 + "__id__": 19 }, "_opacity": 255, "_color": { @@ -767,7 +703,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 18 + "__id__": 17 }, "_enabled": true, "_materials": [ @@ -803,7 +739,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "f1i/UVQbhHGZ1xr/2Jwfe6", + "fileId": "d1//GywZVEbqBcyso7ozKw", "sync": false }, { @@ -811,17 +747,17 @@ "_name": "room_status", "_objFlags": 0, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 22 + "__id__": 21 } ], "_prefab": { - "__id__": 23 + "__id__": 22 }, "_opacity": 255, "_color": { @@ -875,7 +811,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 21 + "__id__": 20 }, "_enabled": true, "_materials": [ @@ -885,8 +821,8 @@ ], "_srcBlendFactor": 770, "_dstBlendFactor": 771, - "_string": "房间id", - "_N$string": "房间id", + "_string": "房间状态", + "_N$string": "房间状态", "_fontSize": 16, "_lineHeight": 20, "_enableWrapText": true, @@ -911,18 +847,7 @@ "asset": { "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" }, - "fileId": "e7suZNjnJJaq2+98OVA7Pm", - "sync": false - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__uuid__": "a3e11be4-ec09-4860-a832-5d81ba8f2972" - }, - "fileId": "bachMhdMNFi7yYvqsYnKdR", + "fileId": "09UxAvYFRMbIWkD5qtUB75", "sync": false }, { @@ -933,18 +858,17 @@ "__id__": 1 }, "_enabled": true, - "roomId": "", - "roomName": { - "__id__": 10 + "roomId": { + "__id__": 15 }, - "roomDesc": { - "__id__": 16 + "roomName": { + "__id__": 9 }, "roomStatus": { - "__id__": 22 + "__id__": 21 }, "backGround": { - "__id__": 3 + "__id__": 2 }, "_id": "" }, diff --git a/cocos/assets/util.ts b/cocos/assets/util.ts index fbff46d..795aeaa 100644 --- a/cocos/assets/util.ts +++ b/cocos/assets/util.ts @@ -1,5 +1,5 @@ /* - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cocos/package.json b/cocos/package.json index bcce5c5..92ee835 100644 --- a/cocos/package.json +++ b/cocos/package.json @@ -1,6 +1,6 @@ { "name": "gameobecocos-demo", - "version": "13.6.1", + "version": "14.3.1", "description": "Game Online Battle Engine Demo for Cocos", "dependencies": { "jszip": "^3.10.1" diff --git a/realtimeserver/GOBERTS.d.ts b/realtimeserver/GOBERTS.d.ts index a9fafab..d929b22 100644 --- a/realtimeserver/GOBERTS.d.ts +++ b/realtimeserver/GOBERTS.d.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,12 +59,26 @@ declare interface ArgsConfig { logger?: any; } +declare interface AuthResponse extends BaseResponse { + serviceToken: string; + timeStamp: number; +} + export declare const enum AutoFrame { AUTO_FRAME_OFF = 0, AUTO_FRAME_ON = 1 } +declare interface AvailableRoomsResponse extends BaseResponse { + rooms: RoomInfo_2[]; + count: number; + offset: string | number; + hasNext: 0 | 1; +} + declare interface BaseResponse { + rtnCode: number; + msg?: string; ret: { code: number; msg?: string; @@ -146,6 +160,8 @@ export declare interface GameServer { onUpdateCustomStatus?: OnUpdateCustomStatusFunc; onRealTimeServerDisconnected?: CommonFunc; onRealTimeServerConnected?: CommonFunc; + onRoomPropertiesChangeFailed?: ErrorFunc; + onInstantMessageFailed?: ErrorFunc; } declare interface GetCacheResponse extends BaseResponse { @@ -167,6 +183,7 @@ export declare interface gobeDevloperCode { */ export declare class GOBEError extends Error { code: number; + msg?: string; constructor(code: number, message?: string); } @@ -175,6 +192,39 @@ export declare const enum ImType { SPECIFILED_PLAYERS = 2 } +declare interface LocalServerChannelResponse extends BaseResponse { + epAddr: string; + roomId: string; + roomTicket: string; + setupTicket: string; + joinTicket: string; + autoFrame: number; + frameRate: number; +} + +declare interface LocalServerMethodRoute { + init: (appId: string, clientId: string, clientSecret: string) => Promise; + getRoomList: (roomType: string) => Promise; + joinRoom: (roomCode: string, roomId: string) => Promise; +} + +export declare const localServerMethodRoute: LocalServerMethodRoute; + +export declare class Logger { + static level: LogLevel; + debug(debugInfo: string): void; + info(info: string): void; + warn(info: string): void; + error(errInfo: string): void; +} + +export declare enum LogLevel { + DEBUG = 1, + INFO = 2, + ERROR = 3, + OFF = 4 +} + /** * 云侧sdk接口定义文档 */ @@ -329,14 +379,18 @@ declare namespace serverInterface { ArgsConfig, ServerAckMessage, BaseResponse, + AuthResponse, + AvailableRoomsResponse, GetRoomInfoResponse, CreateChannelResponse, + LocalServerChannelResponse, GetCacheResponse, CreateChannelResponseData, RoomInfo_2 as RoomInfo, PlayerInfo_2 as PlayerInfo, RouterInfo_2 as RouterInfo, - CacheValue_2 as CacheValue + CacheValue_2 as CacheValue, + LocalServerMethodRoute } } @@ -397,6 +451,7 @@ declare interface ServerLessMethodRequest { * @param ownerId - 房主ID * @param isPrivate - 是否私有 * @param isLock - 是否锁定房间 0:非锁定(允许加入房间),1:锁定(不允许加入房间) + * @param roomType - 房间类型 */ export declare interface UpdateRoomInfo { roomName?: string; @@ -404,6 +459,7 @@ export declare interface UpdateRoomInfo { ownerId?: string; isPrivate?: number; isLock?: number; + roomType?: string; } export { } diff --git a/realtimeserver/Game.ts b/realtimeserver/Game.ts index d33e9f6..b25de02 100644 --- a/realtimeserver/Game.ts +++ b/realtimeserver/Game.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/realtimeserver/GameInterface.ts b/realtimeserver/GameInterface.ts index 98c7a35..921815f 100644 --- a/realtimeserver/GameInterface.ts +++ b/realtimeserver/GameInterface.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/realtimeserver/GameManage.ts b/realtimeserver/GameManage.ts index 09be6f7..fb40108 100644 --- a/realtimeserver/GameManage.ts +++ b/realtimeserver/GameManage.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/realtimeserver/index.ts b/realtimeserver/index.ts index 676f0c6..092728f 100644 --- a/realtimeserver/index.ts +++ b/realtimeserver/index.ts @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ const gameServer: GOBERTS.GameServer = { onDestroyRoom(args: GOBERTS.ActionArgs): void { let game = gameManage.getGame(args.roomId); if (game === undefined) { - args.SDK.log.error('onStopFrameSync game not exist' + args.roomId); + args.SDK.log.error('onDestroyRoom game not exist' + args.roomId); return; } game.stopFrameClock(); @@ -127,7 +127,13 @@ const gameServer: GOBERTS.GameServer = { }, onRequestFrameError(error: GOBERTS.GOBEError, args: GOBERTS.ActionArgs): void { // do something - } + }, + onRoomPropertiesChangeFailed(error: GOBERTS.GOBEError, args:GOBERTS.ActionArgs): void { + // do something + }, + onInstantMessageFailed(error: GOBERTS.GOBEError, args:GOBERTS.ActionArgs): void { + // do something + }, } /** diff --git a/unity/Assets/Config.cs b/unity/Assets/Config.cs index 902f9e7..024c638 100644 --- a/unity/Assets/Config.cs +++ b/unity/Assets/Config.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,5 +19,10 @@ public class Config { public static string openId = null; public static Boolean isOpenSDKLog = true; + public static string gameId = ""; + public static string clientId = ""; + public static string clientSecret = ""; + public static string matchCode = ""; + public static string gameSecret = ""; } diff --git a/unity/Assets/Global.cs b/unity/Assets/Global.cs index 4f2009b..feb2b78 100644 --- a/unity/Assets/Global.cs +++ b/unity/Assets/Global.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Scenes/TeamView.unity b/unity/Assets/Scenes/TeamView.unity index 8abe873..7912404 100644 --- a/unity/Assets/Scenes/TeamView.unity +++ b/unity/Assets/Scenes/TeamView.unity @@ -171,8 +171,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.43137255, g: 0.54509807, b: 0.96862745, a: 1} m_RaycastTarget: 1 @@ -247,8 +247,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.19607843, g: 0.24313726, b: 0.45490196, a: 1} m_RaycastTarget: 1 @@ -323,8 +323,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -403,8 +403,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -483,8 +483,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -599,6 +599,208 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &345696457 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 345696458} + - component: {fileID: 345696460} + - component: {fileID: 345696459} + m_Layer: 0 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &345696458 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 345696457} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 388842148} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &345696459 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 345696457} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: a2def18d195f54841982ee6138ce6cd0, type: 3} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u8E22\u4EBA" +--- !u!222 &345696460 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 345696457} + m_CullTransparentMesh: 1 +--- !u!1 &388842147 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 388842148} + - component: {fileID: 388842151} + - component: {fileID: 388842150} + - component: {fileID: 388842149} + m_Layer: 0 + m_Name: EnablekickBtn + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &388842148 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 388842147} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 345696458} + m_Father: {fileID: 1134846718} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 66.364, y: -30.3} + m_SizeDelta: {x: 45.18, y: 19.34} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &388842149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 388842147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 388842150} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &388842150 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 388842147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.94117653, g: 0.38823533, b: 0.38823533, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &388842151 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 388842147} + m_CullTransparentMesh: 1 --- !u!1 &625564655 GameObject: m_ObjectHideFlags: 0 @@ -647,8 +849,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -727,8 +929,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -891,8 +1093,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -914,7 +1116,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: + m_Text: --- !u!222 &753490598 CanvasRenderer: m_ObjectHideFlags: 0 @@ -971,8 +1173,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -1093,8 +1295,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Navigation: m_Mode: 3 m_WrapAround: 0 @@ -1137,8 +1339,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -1246,14 +1448,15 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 55ae028f1ddae6c44944ba620ede0dd4, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: ownerName: {fileID: 1832576231} playerName: {fileID: 1578359122} playerNum: {fileID: 753490597} enableDismissBtn: {fileID: 990737530} enableMatchBtn: {fileID: 774414477} enableLeaveBtn: {fileID: 1627180330} + enableKickBtn: {fileID: 388842149} teamCodeEditBox: {fileID: 1823913514} Dailog: {fileID: 18332064051043527, guid: c09b42f96dde8a343a0add8866384e44, type: 3} Loading: {fileID: 7269589772353650398, guid: 944966741e158b447ab19b50daf8f2d9, type: 3} @@ -1311,8 +1514,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Navigation: m_Mode: 3 m_WrapAround: 0 @@ -1355,8 +1558,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 0.41037738, b: 0.41037738, a: 1} m_RaycastTarget: 1 @@ -1495,8 +1698,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_HorizontalAxis: Horizontal m_VerticalAxis: Vertical m_SubmitButton: Submit @@ -1514,8 +1717,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_FirstSelected: {fileID: 0} m_sendNavigationEvents: 1 m_DragThreshold: 10 @@ -1564,8 +1767,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_IgnoreReversedGraphics: 1 m_BlockingObjects: 0 m_BlockingMask: @@ -1581,8 +1784,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_UiScaleMode: 0 m_ReferencePixelsPerUnit: 100 m_ScaleFactor: 1 @@ -1633,12 +1836,13 @@ RectTransform: - {fileID: 774414476} - {fileID: 990737529} - {fileID: 1627180329} + - {fileID: 388842148} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: -0.04} + m_AnchoredPosition: {x: -0.06, y: -0} m_SizeDelta: {x: 960, y: 600} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1134846720 @@ -1651,8 +1855,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 064f380232cd6f541abc963e0f9687dc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: --- !u!1 &1191521047 GameObject: m_ObjectHideFlags: 0 @@ -1701,8 +1905,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.3160377, g: 0.85717934, b: 1, a: 1} m_RaycastTarget: 1 @@ -1777,8 +1981,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -1857,8 +2061,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -1939,8 +2143,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Navigation: m_Mode: 3 m_WrapAround: 0 @@ -1983,8 +2187,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.94117653, g: 0.38823533, b: 0.38823533, a: 1} m_RaycastTarget: 1 @@ -2059,8 +2263,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -2082,7 +2286,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: + m_Text: --- !u!222 &1823913515 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2139,8 +2343,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.19607843, g: 0.24313726, b: 0.45490196, a: 1} m_RaycastTarget: 1 @@ -2215,8 +2419,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -2379,8 +2583,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.3160377, g: 0.85717934, b: 1, a: 1} m_RaycastTarget: 1 @@ -2455,8 +2659,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.9882353, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -2535,8 +2739,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 @@ -2615,8 +2819,8 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Name: + m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 diff --git a/unity/Assets/Script/Comp/Bullet.cs b/unity/Assets/Script/Comp/Bullet.cs index 940d54b..007f69d 100644 --- a/unity/Assets/Script/Comp/Bullet.cs +++ b/unity/Assets/Script/Comp/Bullet.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ public class Bullet : MonoBehaviour public bool isDie = true; public int bullectId = 0; public string playerId = ""; - + public void initBullet(int x,int y,string PlayerId,int BullectId) { playerId = PlayerId; bullectId = BullectId; @@ -36,7 +36,7 @@ public void initBullet(int x,int y,string PlayerId,int BullectId) { } } - + /** * 碰撞检测 * @param collision @@ -54,7 +54,7 @@ public void OnTriggerEnter(Collider other) collisionFrameData.selfTag = FrameSync.BulletTag;//碰撞体标签 collisionFrameData.playerId = playerId; collisionFrameData.bulletId = bullectId; - + string frameData = CommonUtils.JsonSerializer(collisionFrameData); // 调用SDK发送帧数据 string[] frameDatas = new string[] { frameData }; diff --git a/unity/Assets/Script/Comp/Circle.cs b/unity/Assets/Script/Comp/Circle.cs index 7076dbe..83d8029 100644 --- a/unity/Assets/Script/Comp/Circle.cs +++ b/unity/Assets/Script/Comp/Circle.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ using Com.Huawei.Game.Gobes.Utils; using UnityEngine; -public class Circle : MonoBehaviour +public class Circle : MonoBehaviour { public void initCircle() { @@ -32,7 +32,7 @@ public void ChangeColor() { gameObject.GetComponent().material.color = Color.red; } - + /** * 碰撞检测 * @param collision diff --git a/unity/Assets/Script/Comp/Clouds.cs b/unity/Assets/Script/Comp/Clouds.cs index 4292277..55bf7ce 100644 --- a/unity/Assets/Script/Comp/Clouds.cs +++ b/unity/Assets/Script/Comp/Clouds.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/Dialog.cs b/unity/Assets/Script/Comp/Dialog.cs index a9714dc..254b782 100644 --- a/unity/Assets/Script/Comp/Dialog.cs +++ b/unity/Assets/Script/Comp/Dialog.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/Face.cs b/unity/Assets/Script/Comp/Face.cs index b1b71e1..83b0207 100644 --- a/unity/Assets/Script/Comp/Face.cs +++ b/unity/Assets/Script/Comp/Face.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public void RandomizeCharacter(CreatFaceParam param) { } if (param.isOwner && roleIsOwner) - { + { dismissBtn.SetActive(true); } else if (param.isOwner && !roleIsOwner) @@ -72,7 +72,7 @@ public void RandomizeCharacter(CreatFaceParam param) { slider.transform.Find("value").GetComponent().text = "进度" + param.progressValue * 100 + "%"; } } - + public void DismissRoom() { Debug.Log("解散房间"); Global.client.DismissRoom(res => diff --git a/unity/Assets/Script/Comp/FrameSyncView.cs b/unity/Assets/Script/Comp/FrameSyncView.cs index ff10202..1db8207 100644 --- a/unity/Assets/Script/Comp/FrameSyncView.cs +++ b/unity/Assets/Script/Comp/FrameSyncView.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class FrameSyncView : MonoBehaviour, ICallback public Button stopFrameButton = null; public Button fireButton = null; - + public Button watcherLeaveButton = null; // 重开一局弹框 @@ -53,7 +53,7 @@ public class FrameSyncView : MonoBehaviour, ICallback private static int[] arr4 = {90, 0, 180}; // Start is called before the first frame update - void Start() { + void Start() { InitView(); InitListener(); InitRobotSchedule(); @@ -70,7 +70,7 @@ private void RestoreRoomState() string data = Global.room.roomInfo.CustomRoomProperties; SaveToPropertiesInfo saveToPropertiesInfo = CommonUtils.JsonDeserializer(data); List.PlayerData> playerList = saveToPropertiesInfo.playerList; - + foreach (PlayerList.PlayerData player in playerList) { FrameSync.SetPlayerCMD(player.id, player.state.cmd, player.x, player.y); @@ -263,7 +263,7 @@ public void SaveGameState() }; UpdateRoomProperties(updateRoomProperties); - SDKDebugLogger.Log("saveRoomState currentRoomFrameId={0} , currentOwner={1}", + SDKDebugLogger.Log("saveRoomState currentRoomFrameId={0} , currentOwner={1}", saveToPropertiesInfo.currentRoomFrameId,Global.Room.roomInfo.OwnerId); } } @@ -518,8 +518,23 @@ void LeaveRoom() { Debug.Log("退出房间成功"); if (Global.isReconnect) { - UnityMainThread.wkr.AddJob(Route.GoHall); Global.isReconnect = false; + if (Global.isTeamMode&& !Global.isOnlineMatch) + { + UnityMainThread.wkr.AddJob(Route.GoTeam); + } + else + { + if (Global.isOnlineMatch) { + // 在线匹配 + Global.isOnlineMatch = false; + UnityMainThread.wkr.AddJob(() => + { + Util.SaveOnlineMatch(false); + }); + } + UnityMainThread.wkr.AddJob(Route.GoHall); + } return; } if (Global.isTeamMode && !Global.isOnlineMatch) { @@ -530,6 +545,11 @@ void LeaveRoom() { if (Global.isOnlineMatch) { // 在线匹配 Global.isOnlineMatch = false; + UnityMainThread.wkr.AddJob(() => + { + Util.SaveOnlineMatch(false); + }); + } UnityMainThread.wkr.AddJob(Route.GoHall); } @@ -568,7 +588,7 @@ void OnStopFrameSync() { FrameSync.frameSyncBulletList.Clear(); Debug.Log("GoGameEndView"); Route.GoGameEndView(); - }); + }); } } else { FrameSync.frameSyncPlayerList.Clear(); @@ -596,7 +616,7 @@ void OnLeave(FramePlayerInfo playerInfo) { } } } - + void WatcherLeaveRoom() { Global.client.LeaveRoom(res => { diff --git a/unity/Assets/Script/Comp/GameCanvas.cs b/unity/Assets/Script/Comp/GameCanvas.cs index def75e5..2841c7c 100644 --- a/unity/Assets/Script/Comp/GameCanvas.cs +++ b/unity/Assets/Script/Comp/GameCanvas.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,10 +39,10 @@ public class GameCanvas : MonoBehaviour { // 子弹预制件 public GameObject bullectPrefab; - + // 圆圈预制件 public GameObject circlePrefab; - + public void SetCircle(bool circleDisplay) { if (circlePrefab == null) { @@ -57,7 +57,7 @@ public void SetCircle(bool circleDisplay) Circle circle =circlesPool[0].GetComponent(); circle.initCircle(); } - + } else { @@ -71,7 +71,7 @@ public void SetCircle(bool circleDisplay) circlesPool.Clear(); } } - + public void SetPlayers(List> players) { if (playerPrefab == null) { diff --git a/unity/Assets/Script/Comp/Players.cs b/unity/Assets/Script/Comp/Players.cs index 4826c0b..21485b8 100644 --- a/unity/Assets/Script/Comp/Players.cs +++ b/unity/Assets/Script/Comp/Players.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public void InitPlayer(PlayerData player , string id) gameObject.transform.position = new Vector3(player.x, player.y, 0); } - + /** * 碰撞检测 * @param collision @@ -77,7 +77,7 @@ public void OnTriggerEnter(Collider other) collisionFrameData.otherTag = other.tag;//被碰撞体标签 collisionFrameData.selfTag = FrameSync.PlayerTag;//碰撞体标签 collisionFrameData.playerId = playerId; - + string frameData = CommonUtils.JsonSerializer(collisionFrameData); // 调用SDK发送帧数据 string[] frameDatas = new string[] { frameData }; diff --git a/unity/Assets/Script/Comp/RTMessage.cs b/unity/Assets/Script/Comp/RTMessage.cs index b3df64f..ecfdcf4 100644 --- a/unity/Assets/Script/Comp/RTMessage.cs +++ b/unity/Assets/Script/Comp/RTMessage.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/Reloading.cs b/unity/Assets/Script/Comp/Reloading.cs index 10290b8..a155af8 100644 --- a/unity/Assets/Script/Comp/Reloading.cs +++ b/unity/Assets/Script/Comp/Reloading.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/ReopenGame.cs b/unity/Assets/Script/Comp/ReopenGame.cs index 93059be..081e535 100644 --- a/unity/Assets/Script/Comp/ReopenGame.cs +++ b/unity/Assets/Script/Comp/ReopenGame.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/ReopenGameDialog.cs b/unity/Assets/Script/Comp/ReopenGameDialog.cs index cabe6ff..00fecc1 100644 --- a/unity/Assets/Script/Comp/ReopenGameDialog.cs +++ b/unity/Assets/Script/Comp/ReopenGameDialog.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Comp/RoomItem.cs b/unity/Assets/Script/Comp/RoomItem.cs index d5e083f..897fb03 100644 --- a/unity/Assets/Script/Comp/RoomItem.cs +++ b/unity/Assets/Script/Comp/RoomItem.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,13 @@ using UnityEngine; using UnityEngine.UI; using Com.Huawei.Game.Gobes; -using Com.Huawei.Game.Gobes.Store; public class RoomItem : MonoBehaviour { public Text roomId; public Text roomName; - + public Text roomStatus; public void RenderItem(RoomInfo info) diff --git a/unity/Assets/Script/Comp/SDKLog.cs b/unity/Assets/Script/Comp/SDKLog.cs index 3aa4a46..b6259ae 100644 --- a/unity/Assets/Script/Comp/SDKLog.cs +++ b/unity/Assets/Script/Comp/SDKLog.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ public static class SDKLog "${longdate}|${callsite:fileName=true}|${logger}|${level:uppercase=true}|${threadid}|${message}|${exception:format=tostring}"; private static Target runLog, sdkDebuggerLog, requestOutLog, testLog; - + private static LoggingConfiguration config = new LoggingConfiguration(); - + private static void InitConsoleTargetLog() { sdkDebuggerLog = new ConsoleTarget() @@ -39,7 +39,7 @@ private static void InitConsoleTargetLog() Layout = layout, AutoFlush = true }; - + // 通用的所有run日志 runLog = new ConsoleTarget() { @@ -47,7 +47,7 @@ private static void InitConsoleTargetLog() Layout = layout, AutoFlush = true }; - + // requestOutLog日志 requestOutLog = new ConsoleTarget() { @@ -88,7 +88,7 @@ private static void InitFileTargetLog() ConcurrentWrites = false, KeepFileOpen = false }; - + // SDKDebugger日志 sdkDebuggerLog = new FileTarget() { @@ -104,11 +104,11 @@ private static void InitFileTargetLog() KeepFileOpen = false }; } - + public static void InitSDKLog(LogLevel logLevel) { config.LoggingRules.Clear(); - + if (SDKLog.SDKLogTarget == "file") { InitFileTargetLog(); @@ -117,22 +117,22 @@ public static void InitSDKLog(LogLevel logLevel) { InitConsoleTargetLog(); } - + // 通用的所有run日志 - config.LoggingRules.Add(new LoggingRule("runLog", - logLevel, + config.LoggingRules.Add(new LoggingRule("runLog", + logLevel, new AsyncTargetWrapper(runLog, 10000, AsyncTargetWrapperOverflowAction.Block))); - + // requestOutLog日志 - config.LoggingRules.Add(new LoggingRule("requestOutLog", - logLevel, + config.LoggingRules.Add(new LoggingRule("requestOutLog", + logLevel, new AsyncTargetWrapper(requestOutLog, 10000, AsyncTargetWrapperOverflowAction.Block))); - + // sdkDebuggerLog日志 - config.LoggingRules.Add(new LoggingRule("sdkDebuggerLog", - logLevel, + config.LoggingRules.Add(new LoggingRule("sdkDebuggerLog", + logLevel, new AsyncTargetWrapper(sdkDebuggerLog, 10000, AsyncTargetWrapperOverflowAction.Block))); - + LogManager.Configuration = config; } diff --git a/unity/Assets/Script/Function/CloudList.cs b/unity/Assets/Script/Function/CloudList.cs index f2cd720..0d62872 100644 --- a/unity/Assets/Script/Function/CloudList.cs +++ b/unity/Assets/Script/Function/CloudList.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,6 @@ public class CloudData public int speed { get; set; } } - public List> Clouds = new List>(); - + public List> Clouds = new List>(); + } diff --git a/unity/Assets/Script/Function/FrameSync.cs b/unity/Assets/Script/Function/FrameSync.cs index dc93aa4..4ec2e51 100644 --- a/unity/Assets/Script/Function/FrameSync.cs +++ b/unity/Assets/Script/Function/FrameSync.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public enum ReConnectState { reConnectFail = 2, // 重连失败 reConnectIng = 3 // 重连中 }; - + // 游戏帧同步命令 [DataContract] public enum FrameSyncCmd { @@ -58,14 +58,14 @@ public enum GameTeam { red = 0, yellow = 1, }; - - + + public enum RoomType { ROOM = 0, TEAMROOM = 1, ASYCROOM = 2 } - + // 玩家 public class Player { public FrameSyncCmd cmd { get; set; } @@ -99,7 +99,7 @@ public class Bullet { [DataMember] public FrameSyncCmd cmd { get; set; } } - + //碰撞帧数据 [DataContract] public class CollisionFrameData { @@ -111,7 +111,7 @@ public class CollisionFrameData { public static List.PlayerData> frameSyncPlayerList = new PlayerList().Players; public static List.CloudData> cloudsList = new CloudList().Clouds; - + //子弹列表 public static List.BulletData> frameSyncBulletList = new BulletList().bullets; @@ -167,7 +167,7 @@ public static void CalcFrame(ServerFrameMessage frame) { Debug.Log("发生碰撞:"+data); HandleCollide(cllisionFrameData); } - else + else { PlayerList.PlayerData player = CommonUtils.JsonDeserializer.PlayerData>(data); @@ -394,7 +394,7 @@ static void HandleCollide(CollisionFrameList.Colli } } } - + // 子弹碰撞飞机(子弹发出的指令) - 子弹销毁 if (FrameSync.BulletTag.Equals(collisionFrameData.selfTag) && FrameSync.PlayerTag.Equals(collisionFrameData.otherTag)) { @@ -402,8 +402,8 @@ static void HandleCollide(CollisionFrameList.Colli && item.bulletId == collisionFrameData.bulletId)).ToList(); } } - - static void UpdateCircleColor() + + static void UpdateCircleColor() { GameObject circle = GameObject.Find("circle_special(Clone)").gameObject; circle.GetComponent().material.color = Color.red; diff --git a/unity/Assets/Script/Function/ICallback.cs b/unity/Assets/Script/Function/ICallback.cs index 6ae79ab..0808d40 100644 --- a/unity/Assets/Script/Function/ICallback.cs +++ b/unity/Assets/Script/Function/ICallback.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ public interface ICallback { - // ȡ + // 取消 void Cancel(); - // ȷ + // 确认 void Confirm(); } diff --git a/unity/Assets/Script/Function/ReopenCallback.cs b/unity/Assets/Script/Function/ReopenCallback.cs index 116add8..11c4b77 100644 --- a/unity/Assets/Script/Function/ReopenCallback.cs +++ b/unity/Assets/Script/Function/ReopenCallback.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ public interface ReopenCallback { - // ȡ + // 取消 void Reopen(); - // ȷ + // 确认 void Exit(); } diff --git a/unity/Assets/Script/Route/Route.cs b/unity/Assets/Script/Route/Route.cs index 184ec96..97a0dac 100644 --- a/unity/Assets/Script/Route/Route.cs +++ b/unity/Assets/Script/Route/Route.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ public class Route { public static void GoHome() { SceneManager.LoadScene("Home"); } - + public static void GoHall() { Global.room = null; SceneManager.LoadScene("Hall"); @@ -31,15 +31,15 @@ public static void GoHall() { public static void GoRoom() { SceneManager.LoadScene("Room"); } - + public static void GoRoomList() { SceneManager.LoadScene("RoomList"); } - + public static void GoCreateRoom() { SceneManager.LoadScene("CreateRoom"); } - + public static void GoMatch() { SceneManager.LoadScene("Match"); } @@ -47,7 +47,7 @@ public static void GoMatch() { public static void GoTeam() { SceneManager.LoadScene("TeamView"); } - + public static void GoTeamInfoView() { SceneManager.LoadScene("TeamInfoView"); } diff --git a/unity/Assets/Script/Scene/AsymmetricMatchSetting.cs b/unity/Assets/Script/Scene/AsymmetricMatchSetting.cs index b2406e6..71eb6fb 100644 --- a/unity/Assets/Script/Scene/AsymmetricMatchSetting.cs +++ b/unity/Assets/Script/Scene/AsymmetricMatchSetting.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ public class AsymmetricMatchSetting : MonoBehaviour public InputField WeaponInput; public Toggle SinglePlayerToggle; public Button ConfirmBtn; - + // Start is called before the first frame update void Start() { diff --git a/unity/Assets/Script/Scene/AsymmetricRoom.cs b/unity/Assets/Script/Scene/AsymmetricRoom.cs index 5a12c18..27b0e0b 100644 --- a/unity/Assets/Script/Scene/AsymmetricRoom.cs +++ b/unity/Assets/Script/Scene/AsymmetricRoom.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class AsymmetricRoom : MonoBehaviour public Text PlayerTwoName = null; public Text PlayerThreeName = null; - + public Text PlayerFourName = null; public Text PlayerOneStatus = null; @@ -36,7 +36,7 @@ public class AsymmetricRoom : MonoBehaviour public Text PlayerTwoStatus = null; public Text PlayerThreeStatus = null; - + public Text PlayerFourStatus = null; public Button UnReadyBtnOne = null; @@ -52,16 +52,16 @@ public class AsymmetricRoom : MonoBehaviour public Button ReadyBtnTwo = null; public Button ReadyBtnThree = null; - + public Button ReadyBtnFour = null; public Button StartBtn = null; public Dialog Dialog = null; - + public static readonly int FontSize = 14; - - // -1 断线中 0 断线重连 1 重连成功 2 重连失败 + + // -1 断线中 0 断线重连 1 重连成功 2 重连失败 private FrameSync.ReConnectState isReConnect = FrameSync.ReConnectState.reConnectionDefault; public Reloading Loading = null; @@ -69,7 +69,7 @@ public class AsymmetricRoom : MonoBehaviour // 定时 private float interval = 2f; // 每隔2秒执行一次 private float count = 0; - + // Start is called before the first frame update void Start() { @@ -167,10 +167,10 @@ private void SetRoomView() } } } - + for (int i = 0; i < playerInfos.Length; i++) { - + //房主为黄队,渲染红队 if (!ownerIsRed && playerInfos[i].TeamId != ownerTeamId) { @@ -219,7 +219,7 @@ private int DrawRedPlayer(PlayerInfo player,int allReadyCount, int playerNumber } PlayerOneName.text = customPlayerProperties.PlayerName; if (player.PlayerId == Global.playerId) - { // 当前玩家才考虑按钮的显示与隐藏 + { // 当前玩家才考虑按钮的显示与隐藏 UnReadyBtnOne.gameObject.SetActive(isPlayerStatus); // "取消准备"按钮激活 ReadyBtnOne.gameObject.SetActive(!isPlayerStatus); // "准备"按钮隐藏 } @@ -233,7 +233,7 @@ private int DrawRedPlayer(PlayerInfo player,int allReadyCount, int playerNumber if (player.IsRobot==1) { PlayerTwoName.fontSize = FontSize; - + } PlayerTwoName.text = customPlayerProperties.PlayerName; if (player.PlayerId == Global.playerId) @@ -266,7 +266,7 @@ private int DrawRedPlayer(PlayerInfo player,int allReadyCount, int playerNumber break; } - + return allReadyCount; } //渲染黄队玩家 @@ -280,7 +280,7 @@ private int DrawYellowPlayer(PlayerInfo player, int allReadyCount) { PlayerFourName.text = customPlayerProperties.PlayerName; if (player.PlayerId == Global.playerId) - { // 当前玩家才考虑按钮的显示与隐藏 + { // 当前玩家才考虑按钮的显示与隐藏 UnReadyBtnFour.gameObject.SetActive(isPlayerStatus); // "取消准备"按钮激活 ReadyBtnFour.gameObject.SetActive(!isPlayerStatus); // "准备"按钮隐藏 } @@ -331,7 +331,7 @@ public void StartTeamGame() } }); } - + // 准备 public void Ready() { @@ -380,7 +380,7 @@ private void ReConnectRoom() { Destroy(loading); isReConnect = FrameSync.ReConnectState.reConnectionDefault; }); - } + } if (response.RtnCode == ((int)ErrorCode.SDK_NOT_IN_ROOM)) { Debug.Log("玩家重连失败"); @@ -392,7 +392,7 @@ private void ReConnectRoom() { }); } catch (SDKException e){ SDKDebugLogger.Log(e.Message); - if (e.code == (int) ErrorCode.INVALID_ROOM || e.code == (int) ErrorCode.PLAYERS_EXCEEDS_ROOM_MAX + if (e.code == (int) ErrorCode.INVALID_ROOM || e.code == (int) ErrorCode.PLAYERS_EXCEEDS_ROOM_MAX || e.code == (int) ErrorCode.INVALID_ROOM_STATUS) { // 重连失败 Debug.Log("重连失败"); @@ -405,7 +405,7 @@ private void ReConnectRoom() { } } } - + //=====================广播===================== @@ -429,14 +429,14 @@ private void OnDisconnect(FramePlayerInfo playerInfo) { UnityMainThread.wkr.AddJob(() => { Reloading loading = Instantiate(Loading); - loading.Open("重连中..."); + loading.Open("房间重连中..."); isReConnect = FrameSync.ReConnectState.reConnectIng; }); } } private void OnStartFrameSync() - { + { Debug.Log("广播--开始帧同步"); Global.state = 1; Global.keyOperate = 1; diff --git a/unity/Assets/Script/Scene/Cancel.cs b/unity/Assets/Script/Scene/Cancel.cs index 7a39c5b..e7592dc 100644 --- a/unity/Assets/Script/Scene/Cancel.cs +++ b/unity/Assets/Script/Scene/Cancel.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/unity/Assets/Script/Scene/CreateRoom.cs b/unity/Assets/Script/Scene/CreateRoom.cs index b0bcf2d..1a70db7 100644 --- a/unity/Assets/Script/Scene/CreateRoom.cs +++ b/unity/Assets/Script/Scene/CreateRoom.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ public class CreateRoom : MonoBehaviour { private string roomName; - + public Dialog Dailog; // 0:公开房间,1:私有房间 @@ -52,19 +52,16 @@ public void OnCreateRoom() Global.client.CreateRoom(createRoomConfig, playerConfig, response => { if (response.RtnCode != 0) { Dialog dialog = Instantiate(Dailog); - dialog.Open("提示", "创建房间失败" + Util.ErrorMessage(response)); + dialog.Open("提示", "创建房间失败" + Util.ErrorMessage(response)); return; } - else - { - Global.Room = response.Room; - Global.player = response.Room._player; - Debug.Log(response.Room.roomInfo); - } + Global.Room = response.Room; + Global.player = response.Room._player; + Debug.Log(response.Room.roomInfo); // 跳转到房间 Route.GoRoom(); }); - + } // 点击取消创建房间按钮 diff --git a/unity/Assets/Script/Scene/GameEnd.cs b/unity/Assets/Script/Scene/GameEnd.cs index 3794556..aee5bb9 100644 --- a/unity/Assets/Script/Scene/GameEnd.cs +++ b/unity/Assets/Script/Scene/GameEnd.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,17 +28,17 @@ public class GameEnd : MonoBehaviour, ReopenCallback public Button leaveBtn; public GameObject message; - + // 重开一局预制件 public ReopenGame reopenGame = null; - + void Start() { InitListener(); } public void InitListener() { leaveBtn.onClick.AddListener(() => Leave()); - + Global.Room.OnRecvFromServer = (data) => { OnReceiveFromServer(data); @@ -112,8 +112,8 @@ void ReopenGame() { doalog.AddEventListener(this); doalog.Open("提示", "游戏已结束,还想要重开一局吗?"); } - - + + // 重开一局 public void Reopen() { Global.room.Update(response => { @@ -135,8 +135,8 @@ public void Reopen() { public void Exit() { LeaveRoom(); } - - + + // 用户是否还在房间中 Boolean IsInRoom(RoomInfo room) { PlayerInfo[] players = room.Players; @@ -149,7 +149,7 @@ Boolean IsInRoom(RoomInfo room) { } return false; } - + void LeaveRoom() { Global.client.LeaveRoom(res => { @@ -166,7 +166,7 @@ void LeaveRoom() { } }); } - + private void CreateMessage(string tip) { diff --git a/unity/Assets/Script/Scene/GameView.cs b/unity/Assets/Script/Scene/GameView.cs index a4c3e7a..eb14438 100644 --- a/unity/Assets/Script/Scene/GameView.cs +++ b/unity/Assets/Script/Scene/GameView.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,16 +33,16 @@ public class GameView : MonoBehaviour { // 云朵初始帧 private static int CloudFirstFrame = 100; - + private static volatile int RequestSize = 0; private static bool isRequestingFrame = false; - + private static int lastUsedFrameId = 0; // 出现云朵的频次 private static readonly int _frequency = 50; - + // 圆圈显隐状态 public static bool circleDisplay = true; @@ -50,11 +50,13 @@ public class GameView : MonoBehaviour { // -1 断线中 0 断线重连 1 重连成功 2 重连失败 private FrameSync.ReConnectState isReConnect = FrameSync.ReConnectState.reConnectionDefault; + private FrameSync.ReConnectState isGroupReConnect = FrameSync.ReConnectState.reConnectionDefault; + private float interval = 2f; // 每隔2秒执行一次 private float count = 0; public static List frameMessages = new List(); - + public static List replayframeMessages = new List(); // Start is called before the first frame update @@ -83,6 +85,11 @@ void Update() { { ReConnect(); } + + if (isGroupReConnect == FrameSync.ReConnectState.reConnectIng) + { + ReConnectGroup(); + } } if (isRequestingFrame && RequestSize !=0) @@ -96,6 +103,34 @@ void Update() { } + private void ReConnectGroup() + { + try { + Global.group.Reconnect(response => { + if (response.RtnCode == 0) { + // 重连成功 + Debug.Log("玩家重连小队成功"); + UnityMainThread.wkr.AddJob(() => { + isGroupReConnect = FrameSync.ReConnectState.reConnectionDefault; + }); + } + }); + } catch (SDKException e){ + SDKDebugLogger.Log(e.Message); + if (e.code == (int) ErrorCode.GROUP_NOT_EXIST || e.code == (int) ErrorCode.CURRENT_GROUP_IS_LOCKED + || e.code == (int) ErrorCode.CURRENT_GROUP_IS_FULL) { + // 重连失败 + Debug.Log("重连失败"); + UnityMainThread.wkr.AddJob(() => { + Route.GoHall(); + isGroupReConnect = FrameSync.ReConnectState.reConnectionDefault; + }); + } else { + SDKDebugLogger.Log("玩家持续重连中..."); + } + } + } + void InitView() { RoomInfo roomInfo = Global.Room != null ? Global.Room.roomInfo : null; if (roomInfo != null) { @@ -114,6 +149,22 @@ void InitListener() { Global.Room.OnDisconnect = playerInfo => OnDisconnect(playerInfo); Global.Room.OnRequestFrameError = response => OnRequestFrameError(response); } + + if (Global.group != null) + { + Global.group.OnDisconnect = playerInfo => { OnGroupDisconnect(playerInfo); }; + } + } + + private void OnGroupDisconnect(FramePlayerInfo playerInfo) + { + Debug.Log("广播--小队玩家掉线"); + if (playerInfo.PlayerId == Global.playerId) { + UnityMainThread.wkr.AddJob(() => { + Debug.Log("小队重连中"); + isGroupReConnect = FrameSync.ReConnectState.reConnectIng; + }); + } } private void OnRequestFrameError(BaseResponse response) @@ -123,14 +174,14 @@ private void OnRequestFrameError(BaseResponse response) UnityMainThread.wkr.AddJob(() => { Reloading loading = Instantiate(Loading); - loading.Open("重连中..."); + loading.Open("房间重连中..."); isReConnect = FrameSync.ReConnectState.reConnectIng; }); } if (response.RtnCode == (int)ErrorCode.SDK_AUTO_REQUEST_FRAME_FAILED) { - + UnityMainThread.wkr.AddJob(() => { if (!string.IsNullOrEmpty(Global.room.roomInfo.CustomRoomProperties) && Global.state == 1 ) @@ -139,7 +190,7 @@ private void OnRequestFrameError(BaseResponse response) string data = Global.room.roomInfo.CustomRoomProperties; SaveToPropertiesInfo saveToPropertiesInfo = CommonUtils.JsonDeserializer(data); List.PlayerData> playerList = saveToPropertiesInfo.playerList; - + foreach (PlayerList.PlayerData player in playerList) { FrameSync.SetPlayerCMD(player.id, player.state.cmd, player.x, player.y); @@ -216,12 +267,12 @@ public static void RecvFrameHandle(ServerFrameMessage frame) { { circleDisplay = false; } - + //更新子弹 if(frameId % 10 == 0){ UpdateBulletFly(); } - + float seed = frame.Ext != null ? frame.Ext.Seed : 0f; // 绘制随机云朵 GetRandomCloud(frameId, seed); @@ -345,7 +396,7 @@ void BatchRecvFrame(List frames) } } } - + void BatchRecvReplayFrame(List frames) { if (frames != null && frames.Count > 0) @@ -384,7 +435,7 @@ void OnDismiss() { Debug.Log("广播--解散房间"); if (Global.isReconnect) { - UnityMainThread.wkr.AddJob(Route.GoHall); + UnityMainThread.wkr.AddJob(Route.GoHall); } if (Global.isTeamMode && !Global.isOnlineMatch) { // 组队匹配 @@ -401,7 +452,7 @@ void OnDisconnect(FramePlayerInfo playerInfo) { if (playerInfo.PlayerId == Global.playerId) { UnityMainThread.wkr.AddJob(() => { Reloading loading = Instantiate(Loading); - loading.Open("重连中..."); + loading.Open("房间重连中..."); isReConnect = FrameSync.ReConnectState.reConnectIng; }); } @@ -447,7 +498,7 @@ void ReConnect() { } } - + void OnDestroy() { FrameSync.ClearFrames(); diff --git a/unity/Assets/Script/Scene/Hall.cs b/unity/Assets/Script/Scene/Hall.cs index 34affc9..d310c2e 100644 --- a/unity/Assets/Script/Scene/Hall.cs +++ b/unity/Assets/Script/Scene/Hall.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class Hall : MonoBehaviour public bool Flag = true; public string Msg; - + // Update is called once per frame void Update() { @@ -56,6 +56,23 @@ void Update() } } + void Start() + { + InitListener(); + } + + public void InitListener() + { + Global.client.OnKickOff = () => showTips(); + } + + public void showTips() + { + Debug.Log("玩家被踢"); + UnityMainThread.wkr.AddJob(() => { + OpenFailWindow("多端登录离线"); + }); + } //点击菜鸟区按钮 public void OnOrdinaryRoomBtn() { @@ -92,7 +109,7 @@ void MatchPlayer() { }; // 需要根据是否非对称,选择对应的matchCode - + MatchTeamInfoParam matchTeamInfoParam = new MatchTeamInfoParam() { @@ -118,6 +135,7 @@ void MatchPlayer() { { Debug.Log("MatchPlayer start"); Global.isOnlineMatch = true; + Util.SaveOnlineMatch(true); Flag = true; } else @@ -138,6 +156,7 @@ void MatchPlayer() { Global.Room = response.Room; Global.player = response.Room._player; Global.isOnlineMatch = true; + Util.SaveOnlineMatch(true); Flag = true; } else diff --git a/unity/Assets/Script/Scene/Home.cs b/unity/Assets/Script/Scene/Home.cs index 6bf1d1c..4aacfba 100644 --- a/unity/Assets/Script/Scene/Home.cs +++ b/unity/Assets/Script/Scene/Home.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public class Home : MonoBehaviour void Start() { InitSDKLog(); + InitText(); InitListener(); } @@ -103,6 +104,14 @@ void InitSDKLog() { SDKCommonConfig.GOBE_STORAGE_PATH = Application.persistentDataPath +"/gobe"; } + void InitText() + { + GameIdInput.text = Config.gameId; + ClientIdInput.text = Config.clientId; + ClientSecrectInput.text = Config.clientSecret; + MatchCodeInput.text = Config.matchCode; + } + void InitListener() { Button.onClick.AddListener(() => GoHall()); @@ -146,10 +155,10 @@ void InitSDK() ClientId = ClientIdDropDown.value == 0 ? ClientIdInput.text : ClientIdDropDown.options[ClientIdDropDown.value].text, ClientSecret = ClientSecrectDropDown.value == 0 ? ClientSecrectInput.text : ClientSecrectDropDown.options[ClientSecrectDropDown.value].text, AccessToken = AccessTokenInput.text != null ? AccessTokenInput.text : "", - + }; - Client = new Client(clientConfig); + Client = new Client(clientConfig); Debug.Log("SDK 正在初始化"); try { @@ -157,7 +166,9 @@ void InitSDK() // 监听初始化结束事件 Global.client.OnInitResult = baseResponse => InitFinish(baseResponse); Global.roomType = PlayerPrefs.GetInt("roomType"); + Global.isOnlineMatch = PlayerPrefs.GetInt("isOnlineMatch") == 1; Debug.Log("roomtype"+Global.roomType); + Debug.Log("isOnlineMatch"+Global.isOnlineMatch); Global.client.Init(); } @@ -177,7 +188,9 @@ private void InitFinish(BaseResponse baseResponse) { // 初始化成功 Debug.Log("init成功"); + SDKDebugLogger.Log("Init Success , LastRoomId:{0} , LastGroupId:{1} ",Global.client.GetLastRoomId(),Global.client.GetLastGroupId()); Global.playerId = Global.client.GetPlayerId(); + Debug.Log("当前玩家:"+Global.playerId); if (!string.IsNullOrEmpty(Global.client.GetLastRoomId())) { // 断线重连场景,直接加入房间 @@ -188,6 +201,15 @@ private void InitFinish(BaseResponse baseResponse) PlayerConfig playerInfo = new PlayerConfig(); Global.room = Global.client.JoinRoom(joinRoomReq, playerInfo, JoinRoomCallback); } + // 小队重连场景 + if (!string.IsNullOrEmpty(Global.client.GetLastGroupId())) + { + JoinGroupConfig joinGroupConfig = new JoinGroupConfig() + { + GroupId = Global.client.GetLastGroupId() + }; + Global.client.JoinGroup(joinGroupConfig, JoinGroupCallback); + } switch (Global.reconnectState) { case (int)RoomStatus.SYNCING: Debug.Log("玩家重进游戏"); @@ -196,10 +218,6 @@ private void InitFinish(BaseResponse baseResponse) Global.player = Global.room._player; UnityMainThread.wkr.AddJob(Route.GoGameView); break; - case (int)RoomStatus.RECYCLING: - Global.room = null; - UnityMainThread.wkr.AddJob(Route.GoHall); - break; case (int)RoomStatus.IDLE: Debug.Log("玩家重进房间"); Global.isReconnect = true; @@ -212,6 +230,12 @@ private void InitFinish(BaseResponse baseResponse) UnityMainThread.wkr.AddJob(Route.GoAsymmetricRoom); break; default: + Global.room = null; + if (Global.group != null) + { + UnityMainThread.wkr.AddJob(Route.GoTeam); + break; + } if (Global.isAsymmetric) { UnityMainThread.wkr.AddJob(Route.GoAsymmetricMatchSetting); @@ -234,8 +258,6 @@ private void InitFinish(BaseResponse baseResponse) } - - private void LeaveRoom() { // 调用离开房间接口 @@ -243,12 +265,33 @@ private void LeaveRoom() { if (res.RtnCode == 0) { - Debug.Log("离开房间success"); + SDKDebugLogger.Log("ReJoin Room Failed , Leave Room Success"); Route.GoHall(); } else { - Debug.Log("离开房间fail"); + SDKDebugLogger.Log("Leave Room Success , msg={0}",res.Msg); + } + }); + } + + private void LeaveGroup() + { + // 调用离开小队接口 + LeaveGroupConfig leaveGroupConfig = new LeaveGroupConfig() + { + GroupId = Global.client.GetLastGroupId() + }; + Global.client.LeaveGroup(leaveGroupConfig ,res => + { + if (res.RtnCode == 0) + { + SDKDebugLogger.Log("ReJoin Group Failed , Leave Group Success"); + Route.GoHall(); + } + else + { + SDKDebugLogger.Log("Leave Group Success , msg={0}",res.Msg); } }); } @@ -306,6 +349,21 @@ public void JoinRoomCallback(JoinRoomBaseResponse res) } } + private void JoinGroupCallback(CreateGroupBaseResponse res) + { + if (res.RtnCode == 0) + { + Global.group = res.Group; + //Global.isTeamMode = true; + Global.player = res.Group.player; + } + else + { + Debug.Log("重新加入小队失败"); + LeaveGroup(); + } + } + void GoHall() { CheckParam(); if (!isPass) return; @@ -381,7 +439,7 @@ public void OnGameIdChanged(int type) { // 下拉框选中默认值(空白) GameIdDropDown.value = 0; - // 下拉框透明 + // 下拉框透明 GameIdDropDown.GetComponent().color = new Color(1, 1, 1, 0); // 输入框不透明,使输入框文本内容置顶 GameIdInput.GetComponent().color = new Color(1, 1, 1, 1); @@ -412,7 +470,7 @@ public void OnClientIdChanged(int type) { // 下拉框选中默认值(空白) ClientIdDropDown.value = 0; - // 下拉框透明 + // 下拉框透明 ClientIdDropDown.GetComponent().color = new Color(1, 1, 1, 0); // 输入框不透明,使输入框文本内容置顶 ClientIdInput.GetComponent().color = new Color(1, 1, 1, 1); @@ -444,7 +502,7 @@ public void OnClientSecretChanged(int type) { // 下拉框选中默认值(空白) ClientSecrectDropDown.value = 0; - // 下拉框透明 + // 下拉框透明 ClientSecrectDropDown.GetComponent().color = new Color(1, 1, 1, 0); // 输入框不透明,使输入框文本内容置顶 ClientSecrectInput.GetComponent().color = new Color(1, 1, 1, 1); @@ -452,7 +510,7 @@ public void OnClientSecretChanged(int type) break; } } - + public void OnMatchCodeChanged(int type) { switch (type) @@ -476,7 +534,7 @@ public void OnMatchCodeChanged(int type) { // 下拉框选中默认值(空白) MatchCodeDropDown.value = 0; - // 下拉框透明 + // 下拉框透明 MatchCodeDropDown.GetComponent().color = new Color(1, 1, 1, 0); // 输入框不透明,使输入框文本内容置顶 MatchCodeInput.GetComponent().color = new Color(1, 1, 1, 1); diff --git a/unity/Assets/Script/Scene/Match.cs b/unity/Assets/Script/Scene/Match.cs index b83bb6d..c020f65 100644 --- a/unity/Assets/Script/Scene/Match.cs +++ b/unity/Assets/Script/Scene/Match.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class Match : MonoBehaviour public string Msg; public bool Flag = true; - + // Update is called once per frame void Update() { diff --git a/unity/Assets/Script/Scene/RentRoom.cs b/unity/Assets/Script/Scene/RentRoom.cs index 8ce3e75..3d2cb96 100644 --- a/unity/Assets/Script/Scene/RentRoom.cs +++ b/unity/Assets/Script/Scene/RentRoom.cs @@ -1,5 +1,5 @@ /** - * Copyright 2023. Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class RentRoom : MonoBehaviour public Button leaveBtn; public Button prepareOrStartBtn; - + public Toggle IsLock; public GameObject message; @@ -98,7 +98,7 @@ public void InitListener() Debug.Log("OnUpdateCustomStatus " + status); UnityMainThread.wkr.AddJob(GetRoomInfo); }; - + Global.Room.OnRoomPropertiesChange = (roomInfo) => { Debug.Log("OnRoomPropertiesChange :" + CommonUtils.JsonSerializer(roomInfo)); @@ -116,7 +116,8 @@ private void updateRoomProperties(bool isLock) UpdateRoomPropertiesConfig updateRoomProperties = new UpdateRoomPropertiesConfig { IsLock = isLockTag, - CustomRoomProperties = Global.room.roomInfo.CustomRoomProperties == null?"":Global.room.roomInfo.CustomRoomProperties + CustomRoomProperties = Global.room.roomInfo.CustomRoomProperties == null?"":Global.room.roomInfo.CustomRoomProperties, + RoomType = "1" }; Global.room.UpdateRoomProperties(updateRoomProperties, res => { @@ -131,7 +132,7 @@ private void updateRoomProperties(bool isLock) }); } } - + private void OnReceiveFromServer(RecvFromServerInfo data) { // TODO根据返回值检测所有玩家加载进度是否都达到100%,是则切换至帧同步场景 @@ -343,7 +344,7 @@ private void StartLoading() UnityMainThread.wkr.AddJob(GetRoomInfo); prepareOrStartBtn.GetComponent