This commit is contained in:
2024-04-16 23:03:54 +08:00
commit 54580cc1b2
723 changed files with 103745 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "37ac4184-546f-4fa8-9030-da49dbe4219c",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,44 @@
import { _decorator } from 'cc'
import { FishInfo } from './FishInfo'
export class FishConfig {
public static readonly config: ReadonlyArray<FishInfo> = [
new FishInfo(1, '蝴蝶鱼', 2, 2),
new FishInfo(2, '鲶鱼', 2, 1),
new FishInfo(3, '狮子鱼', 2, 2),
new FishInfo(4, '条纹鱼', 2, 2),
new FishInfo(5, '沙丁鱼', 2, 2),
new FishInfo(6, '石斑鱼', 2, 2),
new FishInfo(7, '河豚', 3, 1.2),
new FishInfo(8, '海螺', 3, 2),
new FishInfo(9, '接吻鱼', 3, 1.2),
new FishInfo(10, '海姆', 4, 1),
new FishInfo(11, '绿鳍鱼', 4, 1.2),
new FishInfo(12, '鲎', 4, 1.2),
new FishInfo(13, '魔鬼鱼', 5, 0.6),
new FishInfo(14, '小海龟', 5, 2),
new FishInfo(15, '锤头鲨', 6, 0.5),
new FishInfo(16, '金枪鱼', 6, 0.5),
new FishInfo(17, '大三元', 6, 0.5),
new FishInfo(18, '黄金鲎', 6, 1.2),
new FishInfo(19, '大四喜', 7, 0.5),
new FishInfo(20, '黄金锤头鲨', 7, 0.5),
new FishInfo(21, '金海姆', 7, 0.6),
new FishInfo(22, '五福临门', 8, 0.4),
new FishInfo(23, '金海龟', 8, 0.7),
new FishInfo(24, '金鲨', 8, 0.5),
new FishInfo(25, '蓝鲨', 8, 0.5),
new FishInfo(26, '美人鱼', 14, 0.4),
new FishInfo(27, '金龙', 14, 0.3),
new FishInfo(28, '章鱼', 10, 0.5),
new FishInfo(29, '电鳗鱼', 3, 0.8),
]
public static getFishInfoByType(fishType: number) {
for (let i = 0; i < this.config.length; i++) {
let fishInfo: FishInfo = this.config[i]
if (fishInfo.fishType == fishType) {
return fishInfo
}
}
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c7516237-7eb2-4767-8cc7-7ce0b2d5484e",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,18 @@
import { _decorator } from 'cc'
export class FishInfo {
public fishType: number
public name: string
public blood: number
public wikiScale: number
constructor(
fishType: number,
name: string,
blood: number,
wikiScale: number
) {
this.fishType = fishType
this.name = name
this.blood = blood
this.wikiScale = wikiScale
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "03f14923-6d67-4d91-97ad-a81bf4f1551f",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,11 @@
import { _decorator } from 'cc'
import { FishMapInfo } from './FishMapInfo'
export class FishMap {
public mapId: number
public fishMapInfoList: Array<FishMapInfo>
constructor(mapId: number, list: Array<FishMapInfo>) {
this.mapId = mapId
this.fishMapInfoList = list
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f84ce3e3-8c47-43ff-a6f4-7cda4c320fcf",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,21 @@
import { _decorator } from 'cc'
export class FishMapInfo {
public fishType: number
public scale: number
public side: number //1: -1:
public x: number
public y: number
constructor(
fishType: number,
scale: number,
side: number,
x: number,
y: number
) {
this.fishType = fishType
this.scale = scale
this.side = side
this.x = x
this.y = y
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "5f3df30a-4677-4f9c-97a9-e80fcb5b8295",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,998 @@
import { Vec2, _decorator } from 'cc'
import { FishPathInfo } from './FishPathInfo'
import RandomUtil from '../../engine/utils/RandomUtil'
import { FishMapInfo } from './FishMapInfo'
import { FishMap } from './FishMap'
import { Logger } from '../../engine/utils/Logger'
export class FishPathConfig {
private static mapConfig: Array<Array<Array<number>>> = [
[
[1, 1, 1, -425, 387],
[1, 1, 1, -487, 352],
[1, 1, 1, -541, 307],
[1, 1, 1, -589, 263],
[1, 1, 1, -623, 232],
[1, 1, 1, -654, 172],
[1, 1, 1, -671, 134],
[1, 1, 1, -693, 92],
[1, 1, 1, -697, 35],
[1, 1, 1, -706, -19],
[1, 1, 1, -707, -92],
[1, 1, 1, -701, -136],
[1, 1, 1, -702, -177],
[1, 1, 1, -686, -230],
[1, 1, 1, -637, -257],
[1, 1, 1, -559, -272],
[1, 1, 1, -471, -278],
[1, 1, 1, -408, -259],
[1, 1, 1, -337, -226],
[1, 1, 1, -325, -170],
[1, 1, 1, -322, -99],
[1, 1, 1, -336, -39],
[1, 1, 1, -370, 7],
[1, 1, 1, -412, 59],
[1, 1, 1, -532, 69],
[1, 1, 1, -613, 82],
[1, 1, 1, -470, 63],
[1, 1, 1, 241, 402],
[1, 1, 1, 184, 357],
[1, 1, 1, 143, 335],
[1, 1, 1, 81, 285],
[1, 1, 1, 27, 229],
[1, 1, 1, -9, 167],
[1, 1, 1, -39, 126],
[1, 1, 1, -47, 57],
[1, 1, 1, -74, -10],
[1, 1, 1, -62, -66],
[1, 1, 1, -74, -118],
[1, 1, 1, -85, -201],
[1, 1, 1, -30, -240],
[1, 1, 1, 10, -271],
[1, 1, 1, 135, -273],
[1, 1, 1, 79, -280],
[1, 1, 1, 202, -280],
[1, 1, 1, 266, -276],
[1, 1, 1, 276, -274],
[1, 1, 1, 307, -259],
[1, 1, 1, 316, -244],
[1, 1, 1, 327, -226],
[1, 1, 1, 335, -195],
[1, 1, 1, 337, -142],
[1, 1, 1, 321, -53],
[1, 1, 1, 271, -13],
[1, 1, 1, 188, 27],
[1, 1, 1, 123, 46],
[1, 1, 1, 59, 57],
[1, 1, 1, 17, 60],
[1, 1, 1, 323, -101],
[1, 1, 1, 732, 329],
[1, 1, 1, 669, 283],
[1, 1, 1, 613, 218],
[1, 1, 1, 567, 185],
[1, 1, 1, 558, 163],
[1, 1, 1, 507, 95],
[1, 1, 1, 468, 35],
[1, 1, 1, 456, -18],
[1, 1, 1, 451, -80],
[1, 1, 1, 447, -164],
[1, 1, 1, 458, -234],
[1, 1, 1, 505, -267],
[1, 1, 1, 578, -281],
[1, 1, 1, 657, -291],
[1, 1, 1, 708, -291],
[1, 1, 1, 769, -291],
[1, 1, 1, 812, -290],
[1, 1, 1, 847, -275],
[1, 1, 1, 860, -236],
[1, 1, 1, 853, -160],
[1, 1, 1, 826, -95],
[1, 1, 1, 794, -46],
[1, 1, 1, 754, -7],
[1, 1, 1, 671, 26],
[1, 1, 1, 630, 59],
[1, 1, 1, 584, 80],
],
[
[2, 1, 1, -784, 353],
[2, 1, 1, -693, 356],
[2, 1, 1, -614, 354],
[2, 1, 1, -510, 354],
[2, 1, 1, -422, 354],
[2, 1, 1, -456, 287],
[2, 1, 1, -510, 199],
[2, 1, 1, -562, 139],
[2, 1, 1, -600, 82],
[2, 1, 1, -636, 38],
[2, 1, 1, -688, -17],
[2, 1, 1, -745, -92],
[2, 1, 1, -764, -152],
[2, 1, 1, -815, -216],
[2, 1, 1, -166, 341],
[2, 1, 1, -17, 343],
[2, 1, 1, 89, 343],
[2, 1, 1, 246, 331],
[2, 1, 1, 326, 348],
[2, 1, 1, -180, 310],
[2, 1, 1, -144, 209],
[2, 1, 1, -112, 151],
[2, 1, 1, -74, 55],
[2, 1, 1, -48, 0],
[2, 1, 1, 4, -91],
[2, 1, 1, 40, -153],
[2, 1, 1, 85, -201],
[2, 1, 1, 102, -247],
[3, 1, 1, 595, 319],
[3, 1, 1, 664, 322],
[3, 1, 1, 799, 318],
[3, 1, 1, 968, 319],
[3, 1, 1, 963, 107],
[3, 1, 1, 955, -21],
[3, 1, 1, 948, -157],
[3, 1, 1, 940, -231],
[3, 1, 1, 795, -245],
[3, 1, 1, 685, -248],
[3, 1, 1, 610, -252],
[3, 1, 1, 523, -253],
[3, 1, 1, 172, 128],
[3, 1, 1, -357, 30],
[3, 1, 1, 582, 23],
],
[
[5, 1, 1, -888, 405],
[5, 1, 1, -806, 410],
[5, 1, 1, -718, 404],
[5, 1, 1, -658, 406],
[5, 1, 1, -661, 286],
[5, 1, 1, -661, 224],
[5, 1, 1, -664, 142],
[5, 1, 1, -688, -2],
[5, 1, 1, -687, -69],
[5, 1, 1, -697, -120],
[5, 1, 1, -981, 410],
[5, 1, 1, -503, 150],
[5, 1, 1, -432, 146],
[5, 1, 1, -362, 149],
[5, 1, 1, -259, 148],
[5, 1, 1, -192, 149],
[5, 1, 1, -341, 359],
[5, 1, 1, -353, 256],
[5, 1, 1, -354, 203],
[5, 1, 1, -361, 72],
[5, 1, 1, -371, -23],
[5, 1, 1, -387, -79],
[5, 1, 1, 18, 277],
[5, 1, 1, 7, 159],
[5, 1, 1, -7, 94],
[5, 1, 1, -19, -3],
[5, 1, 1, -27, -80],
[5, 1, 1, 177, 164],
[5, 1, 1, 248, 172],
[5, 1, 1, 355, 170],
[5, 1, 1, 153, 29],
[5, 1, 1, 230, 30],
[5, 1, 1, 327, 32],
[6, 1, 1, 548, 371],
[6, 1, 1, 682, 374],
[6, 1, 1, 833, 373],
[6, 1, 1, 942, 374],
[6, 1, 1, 935, 289],
[6, 1, 1, 924, 143],
[6, 1, 1, 903, 65],
[6, 1, 1, 887, -44],
[6, 1, 1, 857, -157],
[6, 1, 1, 526, 109],
[6, 1, 1, 612, 108],
[6, 1, 1, 761, 94],
[6, 1, 1, 710, 260],
[6, 1, 1, 673, 177],
[6, 1, 1, 661, 10],
[6, 1, 1, 634, -61],
[6, 1, 1, 617, -138],
[7, 1, 1, 340, -259],
[7, 1, 1, 485, -254],
[7, 1, 1, 622, -254],
[7, 1, 1, 816, -251],
],
[
[9, 1, 1, -513, 150],
[9, 1, 1, -636, 237],
[9, 1, 1, -811, 250],
[9, 1, 1, -860, 145],
[9, 1, 1, -850, -54],
[9, 1, 1, -801, -154],
[9, 1, 1, -673, -268],
[9, 1, 1, -498, -294],
[9, 1, 1, -358, -223],
[9, 1, 1, -207, -127],
[9, 1, 1, -72, 15],
[9, 1, 1, -88, 196],
[9, 1, 1, -240, 285],
[9, 1, 1, -334, 185],
[9, 1, 1, 466, 151],
[9, 1, 1, 310, 202],
[9, 1, 1, 213, 246],
[9, 1, 1, 106, 83],
[9, 1, 1, 141, -54],
[9, 1, 1, 241, -252],
[9, 1, 1, 388, -285],
[9, 1, 1, 605, -295],
[9, 1, 1, 771, -226],
[9, 1, 1, 846, -125],
[9, 1, 1, 893, 51],
[9, 1, 1, 865, 195],
[9, 1, 1, 665, 207],
[17, 1, 1, -461, 2],
[17, 1, 1, 515, -49],
],
[
[19, 1, 1, -785, 31],
[19, 1, 1, 905, 16],
[20, 1, 1, -242, 34],
[20, 1, 1, 228, 12],
[20, 1, 1, -30, 303],
[20, 1, 1, -109, -292],
[20, 1, 1, 425, -301],
[20, 1, 1, 537, 265],
[20, 1, 1, -604, 317],
[20, 1, 1, -634, -285],
],
[
[21, 1, 1, -757, 94],
[21, 1, 1, 646, 55],
[21, 1, 1, -41, 376],
[21, 1, 1, -102, -315],
[21, 1, 1, -76, 83],
[21, 1, 1, -437, 300],
[21, 1, 1, -434, -155],
[21, 1, 1, 314, -154],
[21, 1, 1, 435, 249],
],
[
[22, 1, 1, -548, 65],
[22, 1, 1, 747, 61],
[22, 1, 1, 95, 63],
],
[
[23, 1, 1, -431, 384],
[23, 1, 1, -766, 89],
[23, 1, 1, -415, -232],
[23, 1, 1, -72, 135],
[23, 1, 1, 721, 414],
[23, 1, 1, 328, 77],
[23, 1, 1, 1025, 60],
[23, 1, 1, 677, -247],
[23, 1, 1, 104, 390],
[23, 1, 1, 84, -265],
],
[
[24, 1, 1, -429, 353],
[24, 1, 1, 241, 323],
[24, 1, 1, -472, 46],
[24, 1, 1, -27, 35],
[24, 1, 1, 563, 39],
[24, 1, 1, -268, -245],
[24, 1, 1, 172, -260],
],
[
[25, 1, 1, -595, 276],
[25, 1, 1, 115, 291],
[25, 1, 1, -192, -64],
[25, 1, 1, 464, -46],
[25, 1, 1, 191, -280],
[25, 1, 1, 884, -319],
],
[
[26, 1, 1, -681, 441],
[26, 1, 1, 685, 426],
[26, 1, 1, -46, 140],
[26, 1, 1, -494, -207],
[26, 1, 1, 497, -238],
],
[
[27, 1, 1, -431, 345],
[27, 1, 1, 569, 311],
[27, 1, 1, 112, -12],
[27, 1, 1, -298, -271],
[27, 1, 1, 678, -244],
],
[
[28, 1, 1, -454, 8],
[28, 1, 1, 597, 1],
[28, 1, 1, 46, 431],
[28, 1, 1, 44, -227],
],
[
[2, 1, 1, -557, 409],
[2, 1, 1, -648, 382],
[2, 1, 1, -732, 338],
[2, 1, 1, -809, 236],
[2, 1, 1, -861, 157],
[2, 1, 1, -865, 18],
[2, 1, 1, -835, -37],
[2, 1, 1, -787, -86],
[2, 1, 1, -746, -115],
[2, 1, 1, -683, -181],
[2, 1, 1, -575, -206],
[2, 1, 1, -494, -204],
[2, 1, 1, -442, -157],
[2, 1, 1, -403, -111],
[2, 1, 1, -387, 11],
[2, 1, 1, -356, 94],
[2, 1, 1, -472, 330],
[2, 1, 1, -407, 260],
[2, 1, 1, -395, 195],
[2, 1, 1, -214, 51],
[2, 1, 1, -139, 52],
[2, 1, 1, -77, 51],
[2, 1, 1, -21, 51],
[2, 1, 1, 67, 50],
[2, 1, 1, 107, 50],
[2, 1, 1, -40, 332],
[2, 1, 1, -43, 207],
[2, 1, 1, -60, 154],
[2, 1, 1, -60, 5],
[2, 1, 1, -82, -71],
[2, 1, 1, -77, -195],
[5, 1, 1, 427, 311],
[5, 1, 1, 578, 314],
[5, 1, 1, 779, 315],
[5, 1, 1, 862, 315],
[5, 1, 1, 884, 123],
[5, 1, 1, 879, -108],
[5, 1, 1, 778, -183],
[5, 1, 1, 672, -181],
[5, 1, 1, 564, -179],
[5, 1, 1, 407, -178],
[5, 1, 1, 297, 8],
[5, 1, 1, 625, 48],
[5, 1, 1, 379, 92],
],
]
private static formatMapConfig: Array<FishMap> = []
private static config: Array<Array<Array<number>>> = [
// 左边开始
[
[-1309, 528],
[-1144, 438],
[-1081, 411],
[-947, 327],
[-801, 241],
[-683, 154],
[-539, 69],
[-394, -23],
[-230, -115],
[-115, -207],
[45, -280],
[247, -364],
[497, -457],
[627, -511],
[762, -578],
[885, -667],
[1068, -773],
],
[
[-1295, 534],
[-1144, 438],
[-1081, 411],
[-906, 326],
[-696, 274],
[-462, 223],
[-213, 198],
[-1, 172],
[156, 178],
[396, 194],
[576, 216],
[753, 233],
[936, 279],
[1182, 350],
[1314, 418],
],
[
[-1295, 534],
[-1144, 438],
[-1081, 411],
[-906, 326],
[-696, 274],
[-462, 223],
[-213, 198],
[-1, 172],
[199, 150],
[417, 111],
[635, 10],
[827, -42],
[1020, -131],
[1189, -170],
[1309, -198],
],
[
[-1295, 534],
[-1111, 514],
[-1015, 454],
[-864, 403],
[-671, 387],
[-450, 354],
[-219, 311],
[11, 274],
[213, 270],
[471, 212],
[642, 172],
[835, 88],
[1013, -2],
[1212, -99],
[1309, -198],
],
[
[-1275, -118],
[-1129, -19],
[-1024, 42],
[-858, 129],
[-677, 225],
[-448, 277],
[-219, 311],
[11, 274],
[213, 270],
[510, 320],
[596, 350],
[772, 391],
[887, 426],
[1066, 513],
[1164, 710],
],
[
[-1299, -618],
[-1143, -521],
[-1033, -496],
[-726, -425],
[-489, -360],
[-245, -293],
[-8, -210],
[212, -134],
[385, -65],
[552, 7],
[705, 96],
[904, 176],
[1090, 273],
[1208, 355],
[1308, 435],
],
[
[-1275, -118],
[-1060, -69],
[-938, -85],
[-729, -59],
[-551, -48],
[-397, -2],
[-203, -1],
[46, 61],
[228, 105],
[506, 159],
[630, 208],
[784, 266],
[935, 228],
[1157, 174],
[1329, 163],
],
[
[-1288, -220],
[-1113, -194],
[-945, -195],
[-709, -162],
[-502, -200],
[-313, -211],
[-144, -186],
[128, -135],
[314, 14],
[571, 56],
[727, 132],
[851, 203],
[1050, 141],
[1255, 58],
[1326, 20],
],
[
[-1288, -220],
[-1113, -194],
[-945, -195],
[-709, -162],
[-502, -200],
[-313, -211],
[-144, -186],
[132, -144],
[406, -196],
[644, -272],
[884, -272],
[993, -283],
[1090, -319],
[1242, -341],
[1329, -396],
],
[
[-1288, -220],
[-1113, -194],
[-916, -213],
[-710, -238],
[-501, -273],
[-297, -289],
[-101, -312],
[173, -324],
[419, -339],
[653, -362],
[889, -390],
[1011, -407],
[1095, -418],
[1238, -539],
[1317, -663],
],
[
[-1314, -508],
[-1123, -480],
[-917, -443],
[-708, -379],
[-514, -361],
[-300, -319],
[-101, -307],
[155, -256],
[398, -248],
[645, -219],
[787, -178],
[980, -165],
[1086, -103],
[1093, 280],
[1026, 371],
[868, 631],
[648, 787],
],
[
[-1314, -508],
[-1130, -281],
[-898, -160],
[-693, -141],
[-561, -91],
[-384, -43],
[-187, 48],
[119, 32],
[298, -95],
[519, -135],
[744, -156],
[868, -97],
[1033, 55],
[1093, 280],
[1026, 371],
[868, 631],
[648, 787],
],
[
[-1314, -508],
[-1130, -281],
[-898, -160],
[-693, -141],
[-561, -91],
[-384, -43],
[-187, 48],
[119, 32],
[298, -95],
[519, -135],
[744, -156],
[872, -200],
[1060, -391],
[1150, -492],
[1301, -461],
],
//右边开始
[
[1286, -293],
[1149, -184],
[952, -147],
[795, -130],
[536, -45],
[476, 57],
[467, 300],
[408, 500],
[405, 701],
],
[
[1345, 34],
[1189, -69],
[978, -94],
[820, -115],
[443, -66],
[267, -29],
[66, -79],
[-219, -287],
[-271, -693],
],
[
[1345, 34],
[1189, -69],
[978, -94],
[820, -115],
[443, -66],
[267, -29],
[66, -79],
[-215, -156],
[-444, -100],
[-725, -92],
[-963, -68],
[-1169, -46],
[-1325, -40],
],
[
[1345, 34],
[1189, -69],
[978, -94],
[820, -115],
[443, -66],
[267, -29],
[66, -79],
[-215, -156],
[-454, -156],
[-719, -199],
[-981, -264],
[-1180, -291],
[-1320, -367],
],
[
[1345, 34],
[1189, -69],
[978, -94],
[820, -115],
[413, -128],
[258, -147],
[60, -161],
[-254, -250],
[-493, -278],
[-707, -320],
[-961, -408],
[-1160, -449],
[-1309, -524],
],
[
[1345, 34],
[1189, -69],
[978, -94],
[820, -115],
[439, -173],
[267, -185],
[109, -251],
[-211, -307],
[-428, -408],
[-596, -448],
[-847, -604],
[-1019, -589],
[-1241, -695],
],
[
[1345, 34],
[1189, -69],
[951, -68],
[512, -86],
[159, -142],
[-56, -144],
[-362, -160],
[-569, -143],
[-772, -35],
[-898, 66],
[-1070, 219],
[-1181, 292],
[-1289, 558],
],
[
[1345, 34],
[1189, -69],
[951, -68],
[512, -86],
[159, -142],
[-56, -144],
[-310, -118],
[-530, -84],
[-654, -2],
[-806, 84],
[-905, 246],
[-1008, 375],
[-1021, 750],
],
[
[1297, 542],
[1181, 330],
[1041, 250],
[676, 110],
[429, -12],
[5, -105],
[-310, -118],
[-530, -84],
[-654, -2],
[-806, 84],
[-905, 246],
[-1008, 375],
[-1021, 750],
],
[
[1297, 542],
[1181, 330],
[1041, 250],
[676, 110],
[429, -12],
[7, -105],
[-310, -118],
[-530, -84],
[-655, -18],
[-806, 84],
[-927, 189],
[-1073, 291],
[-1318, 474],
],
[
[1297, 542],
[1181, 330],
[1041, 250],
[676, 110],
[429, -12],
[7, -105],
[-310, -118],
[-530, -84],
[-631, -85],
[-775, -77],
[-923, -28],
[-1133, -46],
[-1294, -10],
],
[
[1297, 542],
[1181, 330],
[1041, 250],
[676, 110],
[429, -12],
[243, -126],
[-141, -203],
[-340, -201],
[-500, -218],
[-616, -254],
[-854, -240],
[-1115, -272],
[-1312, -336],
],
[
[1297, 542],
[1181, 330],
[1041, 250],
[676, 110],
[429, -12],
[243, -126],
[-141, -203],
[-307, -229],
[-398, -281],
[-562, -321],
[-647, -446],
[-930, -540],
[-1073, -726],
],
[
[1293, -558],
[1192, -467],
[1069, -395],
[948, -305],
[733, -245],
[243, -126],
[-141, -203],
[-307, -229],
[-398, -281],
[-562, -321],
[-647, -446],
[-930, -540],
[-1073, -726],
],
[
[1293, -558],
[1192, -467],
[1069, -395],
[948, -305],
[733, -245],
[243, -126],
[-141, -203],
[-307, -229],
[-398, -281],
[-568, -262],
[-857, -301],
[-1055, -406],
[-1353, -380],
],
[
[1293, -558],
[1192, -467],
[1069, -395],
[948, -305],
[733, -245],
[243, -126],
[-141, -203],
[-307, -229],
[-426, -197],
[-590, -195],
[-905, -120],
[-1100, -72],
[-1300, 225],
],
[
[1293, -558],
[1192, -467],
[1069, -395],
[948, -305],
[733, -245],
[243, -126],
[-141, -203],
[-307, -229],
[-497, -179],
[-633, -130],
[-917, 33],
[-1079, 184],
[-1220, 412],
],
[
[1293, -558],
[1192, -467],
[1069, -395],
[948, -305],
[733, -245],
[243, -126],
[-141, -203],
[-307, -229],
[-461, -55],
[-602, -25],
[-857, 181],
[-921, 416],
[-909, 805],
],
//下往上
[
[-279, -786],
[-92, -667],
[45, -582],
[618, -388],
[436, -239],
[176, -173],
[-141, -203],
[-307, -229],
[-461, -55],
[-602, -25],
[-857, 181],
[-921, 416],
[-909, 805],
],
[
[-279, -786],
[-92, -667],
[45, -582],
[618, -388],
[436, -239],
[176, -173],
[126, -95],
[-26, -92],
[-157, 40],
[-362, 152],
[-543, 358],
[-721, 502],
[-401, 770],
],
[
[-279, -786],
[-78, -718],
[133, -652],
[618, -388],
[436, -239],
[392, -130],
[254, -77],
[194, -49],
[79, 44],
[60, 214],
[-85, 418],
[-140, 630],
[-401, 770],
],
[
[-279, -786],
[-78, -718],
[133, -652],
[618, -388],
[459, -232],
[392, -130],
[304, -80],
[267, -2],
[222, 130],
[253, 319],
[330, 465],
[544, 684],
[858, 803],
],
[
[841, -837],
[683, -745],
[672, -600],
[618, -388],
[459, -232],
[392, -130],
[304, -80],
[267, -2],
[222, 130],
[253, 319],
[330, 465],
[544, 684],
[858, 803],
],
]
private static formatConfig: Array<FishPathInfo> = []
public static init() {
this.initNormalConfig()
this.initMapConfig()
}
private static initMapConfig() {
this.formatMapConfig = []
for (let i = 0; i < this.mapConfig.length; i++) {
let arr: Array<Array<number>> = this.mapConfig[i]
let fishMapInfoList: Array<FishMapInfo> = []
for (let j = 0; j < arr.length; j++) {
let temp: Array<number> = arr[j]
let fishMapInfo: FishMapInfo = new FishMapInfo(
temp[0],
temp[1],
temp[2],
temp[3],
temp[4]
)
fishMapInfoList.push(fishMapInfo)
}
let fishMap: FishMap = new FishMap(i, fishMapInfoList)
this.formatMapConfig.push(fishMap)
}
}
public static randomFishMap() {
let randomIndex: number = RandomUtil.nextInt(
0,
this.formatMapConfig.length - 1
)
let map: FishMap = this.formatMapConfig[randomIndex]
return map
}
private static initNormalConfig() {
this.formatConfig = []
let pathId: number = 1
for (let i = 0; i < this.config.length; i++) {
let path: Array<Vec2> = []
let flipXPath: Array<Vec2> = []
let flipYPath: Array<Vec2> = []
for (let j = 0; j < this.config[i].length; j++) {
let p: Vec2 = new Vec2(this.config[i][j][0], this.config[i][j][1])
path.push(p)
let flipXP: Vec2 = new Vec2(-p.x, p.y)
let flipYP: Vec2 = new Vec2(p.x, -p.y)
flipXPath.push(flipXP)
flipYPath.push(flipYP)
}
this.formatConfig.push(new FishPathInfo(pathId++, path))
this.formatConfig.push(new FishPathInfo(pathId++, flipXPath))
this.formatConfig.push(new FishPathInfo(pathId++, flipYPath))
}
}
public static getPathInfo(pathId: number) {
for (let i = 0; i < this.formatConfig.length; i++) {
let pathInfo: FishPathInfo = this.formatConfig[i]
if (pathInfo.pathId == pathId) {
return pathInfo
}
}
}
public static randomPathInfo() {
let randomIndex: number = RandomUtil.nextInt(
0,
this.formatConfig.length - 1
)
// let randomIndex: number = 0
let pathInfo: FishPathInfo = this.formatConfig[randomIndex]
return pathInfo
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "704e17b3-0f7b-478a-8ad1-1cb2f5d89a8f",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,9 @@
import { _decorator, Vec2 } from 'cc'
export class FishPathInfo {
public pathId: number
public path: Array<Vec2> = []
constructor(pathId: number, path: Array<Vec2>) {
this.pathId = pathId
this.path = path
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "01cc78a7-9862-45b4-ad09-ebb92c01de58",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,4 @@
import { _decorator } from 'cc'
export class GameConfig {
public static GameName: string = 'FishSingle'
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "8b274344-0b4c-4ac5-a289-2f8cd7a5596b",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,2 @@
import { _decorator } from 'cc'
export default class GameEvent {}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "71a46444-1a80-435f-b02e-0fe6acf71155",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "1e8eeb35-adbc-485b-879b-bf95de554cfd",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,160 @@
import {
_decorator,
Component,
Prefab,
NodePool,
Event,
Node,
Vec3,
Vec2,
EventTouch,
UITransform,
instantiate,
sys,
error,
} from 'cc'
const { ccclass, property } = _decorator
import { Logger } from '../../engine/utils/Logger'
import FishBulletBase from '../../../fish/script/FishBulletBase'
import MathUtils from '../../engine/utils/MathUtils'
import CannonManager from './CannonManager'
import { MoveHelper } from '../../engine/utils/MoveHelper'
import FishNetManager from './FishNetManager'
import GameMusicHelper from '../utils/GameMusicHelper'
import FishUI from '../../../fish/script/FishUI'
import CommonTips from '../../engine/uicomponent/CommonTips'
@ccclass('BulletManager')
export default class BulletManager extends Component {
public static instance: BulletManager = null
@property({ type: [Prefab] })
private bulletPrefabList: Prefab[] = []
private bulletPool: Array<NodePool> = []
private bulletList: Array<FishBulletBase> = []
private bulletMoveSpeed: number = 30
private _vec3Cache
private _vec2Cache
private _fireTime: number = 0
private _fireTimeNew: number
onLoad() {
this._vec3Cache = new Vec3()
this._vec2Cache = new Vec2()
BulletManager.instance = this
this.node.on(Node.EventType.TOUCH_START, this.onShootBullet, this)
// this.node.on(Node.EventType.TOUCH_MOVE, this.onShootBullet, this)
}
start() {}
update() {
this.checkMoveBullet()
}
private checkMoveBullet() {
for (let i = this.bulletList.length - 1; i >= 0; i--) {
let bullet: FishBulletBase = this.bulletList[i]
let isMoving: boolean = MoveHelper.moveNode(
bullet.node,
this.bulletMoveSpeed,
bullet.targetP.x,
bullet.targetP.y
)
if (!isMoving) {
bullet.node.getPosition(this._vec3Cache)
this._vec2Cache.x = this._vec3Cache.x
this._vec2Cache.y = this._vec3Cache.y
FishNetManager.instance.addFishNet(bullet.bulletType, this._vec2Cache)
this.bulletList.splice(i, 1)
this.destroyBullet(bullet)
}
}
}
private onShootBullet(event: EventTouch) {
//TOUCH_START 在Editor上连续触发2次导致发2次炮弹bug
if (sys.platform == 'EDITOR_PAGE') {
this._fireTimeNew = new Date().getTime()
if (this._fireTimeNew - this._fireTime < 100) {
return
}
this._fireTime = this._fireTimeNew
}
let tran = this.node.getComponent(UITransform)
let location = event.getUILocation()
this._vec3Cache.x = location.x
this._vec3Cache.y = location.y
this._vec3Cache.z = 0
tran.convertToNodeSpaceAR(this._vec3Cache, this._vec3Cache)
let localP: Vec2 = new Vec2(this._vec3Cache.x, this._vec3Cache.y)
FishUI.instance.playClickEffect(localP)
// 子弹发射
if (FishUI.instance.dz_score >= CannonManager.instance.cannonType) {
FishUI.instance.dz_score -= CannonManager.instance.cannonType
FishUI.instance.refreshScore()
this._vec3Cache = CannonManager.instance.getCannonPosition()
let rad: number = MathUtils.p2pRad(
new Vec2(this._vec3Cache.x, this._vec3Cache.y),
localP
)
let rot: number = MathUtils.radiansToDegrees(rad)
let bullet: FishBulletBase = this.createBullet(
CannonManager.instance.cannonType - 1
)
bullet.targetP = localP
this.node.addChild(bullet.node)
bullet.node.setPosition(CannonManager.instance.getCannonPosition())
this._vec3Cache.x = 1
this._vec3Cache.y = 1
this._vec3Cache.y = 1
Vec3.multiplyScalar(this._vec3Cache, this._vec3Cache, 2)
bullet.node.setScale(this._vec3Cache)
bullet.node.angle = rot
this.bulletList.push(bullet)
GameMusicHelper.playFire()
//旋转炮台
CannonManager.instance.rotateCannon(location)
} else {
CommonTips.showMsg('豆子不足!')
}
}
private createBullet(bulletType: number) {
let bulletNode: Node
if (this.bulletPool[bulletType] && this.bulletPool[bulletType].size() > 0) {
bulletNode = this.bulletPool[bulletType].get()
} else {
bulletNode = instantiate(this.bulletPrefabList[bulletType])
}
bulletNode.getComponent(FishBulletBase).bulletType = bulletType
return bulletNode.getComponent(FishBulletBase)
}
public killBullet(bullet: FishBulletBase) {
let index: number = this.bulletList.indexOf(bullet)
if (index >= 0) {
this.bulletList.splice(index, 1)
this.destroyBullet(bullet)
}
}
private destroyBullet(bullet: FishBulletBase) {
//临时代码,因为回收在内存卡顿。后面在优化 2023-2-10
if (sys.platform == 'EDITOR_PAGE') {
bullet.node.destroy()
return
}
if (!this.bulletPool[bullet.bulletType]) {
this.bulletPool[bullet.bulletType] = new NodePool()
}
this.bulletPool[bullet.bulletType].put(bullet.node)
}
onDestroy() {
BulletManager.instance = null
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bd065d0b-0b60-4981-aea0-75d2f209b7ea",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,66 @@
import {
_decorator,
Component,
Node,
SpriteFrame,
Event,
EventMouse,
Sprite,
Vec2,
UITransform,
Vec3,
} from 'cc'
const { ccclass, property } = _decorator
import MathUtils from '../../engine/utils/MathUtils'
@ccclass('CannonManager')
export default class CannonManager extends Component {
public static instance: CannonManager = null
@property({ type: Node })
private view: Node | null = null
@property({ type: [SpriteFrame] })
private cannonSpriteFrame: Array<SpriteFrame> = []
// 炮塔倍数
public cannonType: number = 1
private _vec3Cache
onLoad() {
this._vec3Cache = new Vec3()
CannonManager.instance = this
this.node.parent.on(Node.EventType.MOUSE_MOVE, this.onMeMove.bind(this))
this.refreshCannon()
}
private onMeMove(event: EventMouse) {
this.rotateCannon(event.getUILocation())
}
public rotateCannon(uilocation: Vec2) {
let location = uilocation
this._vec3Cache.x = location.x
this._vec3Cache.y = location.y
this._vec3Cache.z = 0
let tran = this.node.getComponent(UITransform)
tran.convertToNodeSpaceAR(this._vec3Cache, this._vec3Cache)
let localTouch: Vec2 = new Vec2(this._vec3Cache.x, this._vec3Cache.y)
this.view.getPosition(this._vec3Cache)
let rad: number = MathUtils.p2pRad(
new Vec2(this._vec3Cache.x, this._vec3Cache.y),
localTouch
)
let rot: number = MathUtils.radiansToDegrees(rad)
this.view.angle = rot - 90
}
public refreshCannon() {
this.view.getComponent(Sprite).spriteFrame =
this.cannonSpriteFrame[this.cannonType - 1]
}
public getCannonPosition() {
return this.view.getPosition()
}
onDestroy() {
CannonManager.instance = null
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d03d3fa0-9f23-4106-be05-9d106bd8f8c8",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,222 @@
import {
_decorator,
Component,
Node,
Prefab,
NodePool,
game,
Vec3,
sys,
instantiate,
Animation,
Vec2,
} from 'cc'
const { ccclass, property } = _decorator
import RandomUtil from '../../engine/utils/RandomUtil'
import FishBase from '../../../fish/script/FishBase'
import { FishPathInfo } from '../config/FishPathInfo'
import { FishPathConfig } from '../config/FishPathConfig'
import FishMover from '../../../fish/script/FishMover'
import { Logger } from '../../engine/utils/Logger'
import { FishInfo } from '../config/FishInfo'
import { FishConfig } from '../config/FishConfig'
import GameMusicHelper from '../utils/GameMusicHelper'
import ScoreManager from './ScoreManager'
import { FishMap } from '../config/FishMap'
import { FishMapInfo } from '../config/FishMapInfo'
import FishUI from '../../../fish/script/FishUI'
import TimeHelper from '../utils/TimeHelper'
@ccclass('FishManager')
export default class FishManager extends Component {
public static instance: FishManager = null
@property({ type: Node })
private fishContainer: Node | null = null
@property({ type: [Prefab] })
public fishPrefabList: Array<Prefab> = []
private fishPool: Array<NodePool> = []
private fishList: Array<FishBase> = []
private nextRandomFishTime: number = 0
private minRandomTime: number = 2 * (game.frameRate as number)
private maxRandomTime: number = 5 * (game.frameRate as number)
private isFishMap: boolean = false
private mapCount: number = 0
private minMapCount: number = 30 * (game.frameRate as number)
private maxMapCount: number = 60 * (game.frameRate as number)
// // private minMapCount: number = 2 * cc.game.getFrameRate();
// // private maxMapCount: number = 5 * cc.game.getFrameRate();
private _fishPosCache
onLoad() {
FishManager.instance = this
this._fishPosCache = new Vec3()
Logger.log(
'maxRandomTime=',
this.minRandomTime,
this.maxRandomTime,
game.frameRate
)
}
start() {
this.randomFish()
}
update() {
this.checkRandomFish()
this.checkFishMoveEnd()
this.checkFishMap()
}
private checkFishMap() {
if (!this.isFishMap) {
if (this.mapCount > 0) {
this.mapCount--
if (this.mapCount <= 0) {
FishUI.instance.playWaveEffect()
}
}
}
}
private checkRandomFish() {
if (!this.isFishMap) {
if (this.nextRandomFishTime > 0) {
this.nextRandomFishTime--
if (this.nextRandomFishTime == 0) {
this.randomFish()
}
}
}
}
private checkFishMoveEnd() {
for (let i = this.fishList.length - 1; i >= 0; i--) {
let fish: FishBase = this.fishList[i]
if (this.isFishMap) {
if (!fish.isDead) {
fish.node.getPosition(this._fishPosCache)
this._fishPosCache.x -= 2
fish.node.setPosition(this._fishPosCache)
if (this._fishPosCache.x <= -screen.width / 2) {
//winSize.width
this.destroyFish(fish)
this.fishList.splice(i, 1)
this.checkEndFishMap()
}
}
} else if (!fish.getComponent(FishMover).isMoving) {
this.destroyFish(fish)
this.fishList.splice(i, 1)
}
}
}
private checkEndFishMap() {
Logger.log('checkEndFishMap==', this.isFishMap, this.fishList)
if (this.isFishMap && this.fishList.length <= 0) {
this.isFishMap = false
this.randomFish()
}
}
private randomFish() {
if (this.isFishMap) return
let randomNum: number = RandomUtil.nextInt(1, 10)
// let randomNum: number = RandomUtil.nextInt(1, 1);
for (let i = 0; i < randomNum; i++) {
let fishType: number = RandomUtil.nextInt(1, 29)
// let fishType: number = RandomUtil.nextInt(1, 1);
let fish: FishBase = this.createFishByType(fishType)
fish.fishPathInfo = FishPathConfig.randomPathInfo()
this._fishPosCache.z = 0
this._fishPosCache.x = fish.fishPathInfo.path[0].x
this._fishPosCache.y = fish.fishPathInfo.path[0].y
fish.node.setPosition(this._fishPosCache)
fish.getComponent(FishMover).bezierPList = fish.fishPathInfo.path
fish.getComponent(FishMover).startMove()
this.fishList.push(fish)
this.fishContainer.addChild(fish.node)
}
Logger.log('checkFishMoveEnd=randomFish=', this.fishList)
this.nextRandomFishTime = RandomUtil.nextInt(
this.minRandomTime,
this.maxRandomTime
)
if (this.mapCount <= 0) {
this.mapCount = RandomUtil.nextInt(this.minMapCount, this.maxMapCount)
}
}
public createFishByType(fishType: number): FishBase {
let fishNode: Node
if (this.fishPool[fishType - 1] && this.fishPool[fishType - 1].size() > 0) {
fishNode = this.fishPool[fishType - 1].get()
} else {
fishNode = instantiate(this.fishPrefabList[fishType - 1])
}
//fishNode.getComponent(Animation).play() //v3 当前帧 不能播放
TimeHelper.exeNextFrame(fishNode, () =>
fishNode.getComponent(Animation).play()
)
let fishInfo: FishInfo = FishConfig.getFishInfoByType(fishType)
fishNode.getComponent(FishBase).fishInfo = fishInfo
fishNode.getComponent(FishBase).fishType = fishType
fishNode.getComponent(FishBase).blood = fishInfo.blood
fishNode.getComponent(FishBase).isDead = false
return fishNode.getComponent(FishBase)
}
public killFish(fish: FishBase) {
let index: number = this.fishList.indexOf(fish)
if (index >= 0) {
// console.log("鱼挂了")
GameMusicHelper.playFishDead(fish.fishType)
fish.node.getPosition(this._fishPosCache)
let vec2 = new Vec2(this._fishPosCache.x, this._fishPosCache.y)
ScoreManager.instance.addScore(fish.fishInfo.blood, vec2)
this.fishList.splice(index, 1)
this.destroyFish(fish)
this.checkEndFishMap()
}
}
private destroyFish(fish: FishBase) {
if (!this.fishPool[fish.fishType - 1]) {
this.fishPool[fish.fishType - 1] = new NodePool()
}
this.fishPool[fish.fishType - 1].put(fish.node)
}
public playFishMap() {
this.isFishMap = true
for (let i = this.fishList.length - 1; i >= 0; i--) {
let fish: FishBase = this.fishList[i]
this.destroyFish(fish)
this.fishList.splice(i, 1)
}
}
public startFishMap() {
// this.playFishMap();
// this.fishList = [];
let map: FishMap = FishPathConfig.randomFishMap()
let fishMapInfoList: Array<FishMapInfo> = map.fishMapInfoList
Logger.log('startFishMap==', this.isFishMap, this.fishList, map)
for (let i = 0; i < fishMapInfoList.length; i++) {
let fishMapInfo: FishMapInfo = fishMapInfoList[i]
let fish: FishBase = this.createFishByType(fishMapInfo.fishType)
fish.node.angle = 0
// fish.node.setScale(fishMapInfo.scale);
this.fishContainer.addChild(fish.node)
fish.node.setPosition(fishMapInfo.x + screen.width, fishMapInfo.y)
this.fishList.push(fish)
}
}
onDestroy() {
FishManager.instance = null
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b20609a9-5a1b-4119-9fb1-399b45155aab",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,53 @@
import {
_decorator,
Component,
Prefab,
NodePool,
Vec2,
instantiate,
Vec3,
Node,
} from 'cc'
const { ccclass, property } = _decorator
import FishNetBase from '../../../fish/script/FishNetBase'
@ccclass('FishNetManager')
export default class FishNetManager extends Component {
public static instance: FishNetManager = null
@property({ type: [Prefab] })
private netPrefabList: Prefab[] = []
private fishNetPool: Array<NodePool> = []
onLoad() {
FishNetManager.instance = this
}
public addFishNet(netType: number, p: Vec2) {
let fishNet: FishNetBase = this.createFishNet(netType)
this.node.addChild(fishNet.node)
fishNet.node.setPosition(new Vec3(p.x, p.y, 0))
fishNet.playMv()
}
private createFishNet(netType: number) {
let fishNetNode: Node
if (this.fishNetPool[netType] && this.fishNetPool[netType].size() > 0) {
fishNetNode = this.fishNetPool[netType].get()
} else {
fishNetNode = instantiate(this.netPrefabList[netType])
}
fishNetNode.getComponent(FishNetBase).netType = netType
return fishNetNode.getComponent(FishNetBase)
}
public destroyFishNet(fishNet: FishNetBase) {
if (!this.fishNetPool[fishNet.netType]) {
this.fishNetPool[fishNet.netType] = new NodePool()
}
this.fishNetPool[fishNet.netType].put(fishNet.node)
}
onDestroy() {
FishNetManager.instance = null
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "fec491b0-4f6f-4a17-928d-a4ee3c2bb567",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,57 @@
import {
_decorator,
Component,
Prefab,
NodePool,
Vec2,
instantiate,
Node,
Vec3,
} from 'cc'
const { ccclass, property } = _decorator
import ScorePrefab from '../prefab/ScorePrefab'
import FishUI from '../../../fish/script/FishUI'
@ccclass('ScoreManager')
export default class ScoreManager extends Component {
public static instance: ScoreManager = null
@property({ type: Prefab })
private scrorePrefab: Prefab | null = null
private scorePool: NodePool
onLoad() {
ScoreManager.instance = this
this.scorePool = new NodePool()
}
public addScore(score: number, p: Vec2) {
let scorePrefab: ScorePrefab = this.createScore(score)
this.node.addChild(scorePrefab.node)
scorePrefab.node.setPosition(new Vec3(p.x, p.y, 0))
scorePrefab.init(score)
scorePrefab.playMoveEffect(new Vec2(-472.398, -547.481), () => {
this.destroyScore(scorePrefab)
FishUI.instance.jf_score += score
FishUI.instance.refreshScore()
})
}
private createScore(score: number): ScorePrefab {
let scoreNode: Node
if (this.scorePool && this.scorePool.size() > 0) {
scoreNode = this.scorePool.get()
} else {
scoreNode = instantiate(this.scrorePrefab)
}
return scoreNode.getComponent(ScorePrefab)
}
private destroyScore(scorePrefab: ScorePrefab) {
this.scorePool.put(scorePrefab.node)
}
onDisable() {}
onDestroy() {
ScoreManager.instance = null
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "ff2defbe-9c85-4632-b16a-021567da1bdd",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "a52a8a98-fc73-4bb3-9081-157a181af0a9",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,34 @@
import { _decorator, Component, Prefab, Node, instantiate } from 'cc'
const { ccclass, property } = _decorator
import PrefabLoader from '../../engine/utils/PrefabLoader'
import { GameConfig } from '../config/GameConfig'
@ccclass('ResourcePrefab')
export default class ResourcePrefab extends Component {
private static prefab: Prefab | null = null
public static instance: Node
@property({ type: Prefab })
private scorePrefab: Prefab | null = null
public static preLoad(): Promise<void> {
return new Promise((resolve, reject) => {
PrefabLoader.loadPrefab(
GameConfig.GameName + '/' + 'game/prefab/ResourcePrefab',
(loadedResource: Prefab) => {
ResourcePrefab.prefab = loadedResource
ResourcePrefab.instance = instantiate(loadedResource)
resolve()
}
)
})
}
public static clear() {
ResourcePrefab.instance = null
ResourcePrefab.prefab = null
}
public static getScorePrefab() {
return ResourcePrefab.instance.getComponent(ResourcePrefab).scorePrefab
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e0c999fe-5635-4caa-8c3b-d16793848320",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,30 @@
import { _decorator, Component, Label, Vec2, tween, Vec3, Tween } from 'cc'
const { ccclass, property } = _decorator
@ccclass('ScorePrefab')
export default class ScorePrefab extends Component {
@property({ type: Label })
private txtScore: Label | null = null
public init(score: number) {
if (score <= 0) {
this.txtScore.string = 'Miss'
} else {
this.txtScore.string = score + ''
}
}
public playMoveEffect(p: Vec2, callback: Function = null) {
tween(this.node)
.to(0.5, { scale: new Vec3(3, 3, 3), position: new Vec3(p.x, p.y, 0) })
.call(() => {
if (callback) {
callback()
}
})
.start()
}
onDisable() {
Tween.stopAllByTarget(this.node)
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "465f63cc-b6fe-4ea9-9a10-79254fbe67cc",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,41 @@
import { _decorator, Component, Node, Material, instantiate, Prefab } from 'cc'
const { ccclass, property } = _decorator
import PrefabLoader from '../../engine/utils/PrefabLoader'
import { GameConfig } from '../config/GameConfig'
@ccclass('ShaderMaterialPrefab')
export default class ShaderMaterialPrefab extends Component {
public static instance: Node
@property({ type: Material })
public default: Material | null = null
@property({ type: Material })
public grayMaterial: Material | null = null
@property({ type: Material })
public oldPhoto: Material | null = null
@property({ type: Material })
public glowInner: Material | null = null
@property({ type: Material })
public mosaic: Material | null = null
@property({ type: Material })
public roundCornerCrop: Material | null = null
@property({ type: Material })
public flashLight: Material | null = null
@property({ type: Material })
public flag: Material | null = null
@property({ type: Material })
public gaussian: Material | null = null
public static preLoad(): Promise<void> {
return new Promise((resolve, reject) => {
PrefabLoader.loadPrefab(
GameConfig.GameName + '/' + 'game/prefab/ShaderMaterialPrefab',
(loadedResource: Prefab) => {
ShaderMaterialPrefab.instance = instantiate(loadedResource)
resolve()
}
)
})
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "7c56c670-6b06-4cf1-a606-7af6226a3cb6",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "8041396e-ebea-4101-a42b-e0eee5b71be2",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,72 @@
import { _decorator, Sprite, Prefab, Node, instantiate, Vec3, Tween } from 'cc'
const { ccclass, property } = _decorator
import SceneBase from './SceneBase'
import TextureMgr from '../../engine/uicomponent/TextureMgr'
import RandomUtil from '../../engine/utils/RandomUtil'
import FishMover from '../../../fish/script/FishMover'
import { FishPathInfo } from '../config/FishPathInfo'
import { FishPathConfig } from '../config/FishPathConfig'
import { Logger } from '../../engine/utils/Logger'
import FishWiki from '../../../fish/script/FishWiki'
import GameMusicHelper from '../utils/GameMusicHelper'
@ccclass('FishGameScene')
export default class FishGameScene extends SceneBase {
@property(Sprite)
private bg: Sprite | null = null
@property({ type: [Prefab] })
private fishPrefabList: Array<Prefab> = []
private showNode: Node | null = null
onLoadMe() {
GameMusicHelper.playBg()
FishPathConfig.init()
this.initBg()
// this.testPathPlay()
}
private initBg() {
let textureMgr: TextureMgr = this.bg.getComponent(TextureMgr)
this.bg.spriteFrame =
textureMgr.Spriteset[
RandomUtil.nextInt(0, textureMgr.Spriteset.length - 1)
]
}
private initShowNode() {
if (this.showNode) {
this.showNode.destroy()
this.showNode = null
}
let fishType: number = 29
if (fishType < 1 || fishType > 29) {
return
}
this.showNode = instantiate(this.fishPrefabList[fishType - 1])
this.showNode.getComponent(FishMover).speed = 2
this.showNode.getComponent(FishMover).node.setScale(new Vec3(2, 2, 1))
this.node.addChild(this.showNode)
}
private testPathPlay() {
this.initShowNode()
let pathInfo: FishPathInfo = FishPathConfig.getPathInfo(3)
Logger.log('testPathPlay=pathInfo=', pathInfo)
let params = pathInfo.path
let param0 = params[0]
Logger.log('testPathPlay=11=', param0)
this.showNode.setPosition(new Vec3(param0.x, param0.y, 0))
this.showNode.getComponent(FishMover).bezierPList = params
this.showNode.getComponent(FishMover).startMove()
}
private onClickWiki() {
FishWiki.show()
}
onDestroyMe() {
this.unscheduleAllCallbacks()
//this.node.stopAllActions();
Tween.stopAllByTarget(this.node)
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "ebb8d437-f642-4a91-9a2c-6d9b8743d7d7",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,156 @@
import {
_decorator,
Node,
sys,
profiler,
DynamicAtlasManager,
PhysicsSystem2D,
} from 'cc'
const { ccclass, property } = _decorator
import MusicConfig from '../../engine/config/MusicConfig'
import CommonTips from '../../engine/uicomponent/CommonTips'
import Progress from '../../engine/uicomponent/Progress'
import EventManager, { HaoEvent } from '../../engine/utils/EventManager'
import HotUpdate from '../../engine/utils/HotUpdate'
import { Logger } from '../../engine/utils/Logger'
import VersionManager from '../../engine/utils/VersionManager'
import ResourcePreload from '../utils/ResourcePreload'
import SceneBase from './SceneBase'
import SceneManager from './SceneManager'
@ccclass('LoadingScene')
export default class LoadingScene extends SceneBase {
public static scriptName: string = 'LoadingScene'
@property({ type: Node })
private progressNode: Node | null = null
onLoadMe() {
this.baseInit()
EventManager.instance.addListener(
HotUpdate.Event_On_NeedUpdate,
this.onNeedUpdate,
this
)
EventManager.instance.addListener(
HotUpdate.Event_On_Progress,
this.onUpdateProgress,
this
)
EventManager.instance.addListener(
HotUpdate.Event_On_Fail_Update,
this.onUpdateFail,
this
)
EventManager.instance.addListener(
HotUpdate.Event_Finish_Update,
this.onUpdateFinish,
this
)
EventManager.instance.addListener(
HotUpdate.Event_On_ALREADY_UP_TO_DATE,
this.onUpdateFinish,
this
)
if (sys.isNative && VersionManager.instance.isOpenHotUpdate) {
this.checkUpdate()
} else {
this.preLoadRes()
}
}
private baseInit() {
profiler.hideStats() //showStats
//let collisionManager:cc.CollisionManager = director.getCollisionManager();
PhysicsSystem2D.instance.enable = true
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb |
// EPhysics2DDrawFlags.Pair |
// EPhysics2DDrawFlags.CenterOfMass |
// EPhysics2DDrawFlags.Joint |
// EPhysics2DDrawFlags.Shape;
//if(collisionManager){
//collisionManager.enabled = true;
// collisionManager.enabledDebugDraw = true;
// collisionManager.enabledDrawBoundingBox = true;
//}
if (DynamicAtlasManager.instance) {
DynamicAtlasManager.instance.enabled = false
}
MusicConfig.init()
// cc.director.getCollisionManager().enabled=true;//这是一个全局属性,开启后就代表碰撞检测组件可以进行检测了
// cc.director.getCollisionManager().enabledDebugDraw = true; //绘制碰撞区域
}
private checkUpdate() {
Logger.log(this, 'checkUpdate====')
VersionManager.instance.checkUpdate(0)
}
private onNeedUpdate(event: HaoEvent, key: string) {
Logger.log(this, 'onNeedUpdate=====', key, VersionManager.Config_Key)
if (key == VersionManager.Config_Key[0]) {
VersionManager.instance.startUpdate(0)
}
}
private onUpdateProgress(event, loadedFiles, totalFiles, key) {
if (key == VersionManager.Config_Key[0]) {
let msg: string =
Math.min(100, (loadedFiles / totalFiles) * 100).toFixed(2) + '%'
this.progressNode
.getComponent(Progress)
.updateProgress(loadedFiles, totalFiles, msg)
}
}
private onUpdateFail(event, key: string) {
if (key == VersionManager.Config_Key[0]) {
Logger.warn(this, '热更新失败========')
CommonTips.showMsg('热更新失败')
ResourcePreload.instance.restartGame()
}
}
private onUpdateFinish(event, key: string, needRestart: boolean) {
Logger.log(this, 'onUpdateFinish========')
if (key == VersionManager.Config_Key[0] && !needRestart) {
this.preLoadRes()
}
}
private async preLoadRes() {
ResourcePreload.instance.preLoad(() => {
this.startGame()
}, this.progressNode.getComponent(Progress))
}
private startGame() {
Logger.info(this, 'startGame')
SceneManager.instance.sceneSwitch('FishGameScene', true)
}
onDestroyMe() {
EventManager.instance.removeListener(
HotUpdate.Event_On_NeedUpdate,
this.onNeedUpdate
)
EventManager.instance.removeListener(
HotUpdate.Event_On_Progress,
this.onUpdateProgress
)
EventManager.instance.removeListener(
HotUpdate.Event_On_Fail_Update,
this.onUpdateFail
)
EventManager.instance.removeListener(
HotUpdate.Event_Finish_Update,
this.onUpdateFinish
)
EventManager.instance.removeListener(
HotUpdate.Event_On_ALREADY_UP_TO_DATE,
this.onUpdateFinish
)
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "ba786f67-34b5-4fa6-abc5-69a3ef70bfd3",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,25 @@
import { _decorator, Component } from 'cc'
const { ccclass, property } = _decorator
import AdapterHelper from '../../engine/utils/AdapterHelper'
import PrefabLoader from '../../engine/utils/PrefabLoader'
import { Logger } from '../../engine/utils/Logger'
import ResourcePrefab from '../prefab/ResourcePrefab'
@ccclass('SceneBase')
export default class SceneBase extends Component {
public static scriptName: string = 'SceneBase'
onLoad() {
AdapterHelper.fixApdater()
this.onLoadMe()
}
onLoadMe() {}
start() {
this.onStartMe()
}
onStartMe() {}
onDestroy() {
this.onDestroyMe()
}
onDestroyMe() {}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "544253ea-8aa0-4349-9d6c-efb97841d976",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,72 @@
import { director, SceneAsset, sys, _decorator } from 'cc'
import { Logger } from '../../engine/utils/Logger'
import LoadingScenePrefab from '../../engine/uicomponent/LoadingScenePrefab'
import CommonTips from '../../engine/uicomponent/CommonTips'
import EventManager from '../../engine/utils/EventManager'
import CommonEvent from '../../engine/config/CommonEvent'
export default class SceneManager {
public static instance: SceneManager = new SceneManager()
private loadingSceneName: string
public currentSceneName: string
public initFullScreenPrefab(isShow: boolean = false) {
if (sys.isBrowser && !sys.isMobile) {
if (isShow) {
// FullscreenPrefab.show();
} else {
// FullscreenPrefab.close();
}
}
}
public sceneSwitch(name: string, showProgress: boolean = false) {
if (this.loadingSceneName == name) return
Logger.log(this, 'sceneSwitch==', name)
if (sys.isBrowser) {
// showProgress = true;
}
this.initFullScreenPrefab(false)
this.loadingSceneName = name
if (showProgress) {
LoadingScenePrefab.show()
director.preloadScene(
name,
(completedCount: number, totalCount: number, item: any) => {
LoadingScenePrefab.updateLoading(completedCount, totalCount)
},
(error: Error, asset: SceneAsset) => {
if (error) {
Logger.warn(this, 'preloadScene=error', error.message)
CommonTips.showMsg('加载场景失败')
} else {
//director.getScene().destroy();//director.getScene().cleanup();
director.loadScene(name, this.loadSceneOK.bind(this))
}
}
)
} else {
//director.getScene().destroy();//director.getScene().cleanup();
director.loadScene(name, this.loadSceneOK.bind(this))
}
}
private loadSceneOK() {
LoadingScenePrefab.close()
this.initFullScreenPrefab(true)
this.currentSceneName = this.loadingSceneName
this.loadingSceneName = ''
Logger.log(this, 'scene load ok=', this.currentSceneName)
EventManager.instance.dispatchEvent(CommonEvent.Event_Scene_Switch)
}
public preloadScene(
sceneName: string,
onProgressCallback: any = null,
onLoadedCallback: any = null
) {
director.preloadScene(sceneName, onProgressCallback, onLoadedCallback)
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b636d5b8-723e-4576-861b-5cfc3151e46a",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,15 @@
import { _decorator } from 'cc'
const { ccclass, property } = _decorator
import EventManager, { HaoEvent } from '../../engine/utils/EventManager'
import SceneBase from './SceneBase'
import SceneManager from './SceneManager'
@ccclass('StartScene')
export default class StartScene extends SceneBase {
public static scriptName: string = 'StartScene'
onLoadMe() {}
update() {}
onDestroyMe() {}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "65ad3e01-f8b1-4160-a391-c55d6c8f366f",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "2a75ef29-1cd1-446e-95df-61bd54c8c217",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,196 @@
import { _decorator, Component, Vec2 } from 'cc'
const { ccclass, property } = _decorator
import { Logger } from '../../engine/utils/Logger'
export enum AstarGridType {
Hider = 0, //不能走
Normal = 1, //能走
End = 2, //终点
}
@ccclass('Astar')
export class AstarGrid {
public x: number = 0
public y: number = 0
public f: number = 0
public g: number = 0
public h: number = 0
public type: number = 0
public parent: AstarGrid = null
}
export class Astar extends Component {
public mapW: number = 24 // 横向格子数量
public mapH: number = 13 // 纵向格子数量
public is8dir: boolean = false // 是否8方向寻路 //4方向:代表只能走上下左右 8方向:代表可以走上下左右,左上,右上,左下,右下
private openList: Array<AstarGrid> = []
private closeList: Array<AstarGrid> = []
private path: Array<AstarGrid> = []
private gridsList: Array<Array<AstarGrid>> = []
onLoad() {}
/**
* @param mapW 宽格子数
* @param mapH 高格子数
* @param is8dir 是8方向(上,下,左,右,左上,右上,左下,右下)寻路还是4方向(上,下,左,右)
*/
public init(mapW: number, mapH: number, is8dir: boolean = false) {
this.mapW = mapW
this.mapH = mapH
this.is8dir = is8dir
this.initMap()
}
/**
* 初始化map的格子
*/
private initMap() {
this.openList = []
this.closeList = []
this.path = []
// 初始化格子二维数组
this.gridsList = new Array(this.mapW + 1)
for (let col = 0; col < this.gridsList.length; col++) {
this.gridsList[col] = new Array(this.mapH + 1)
}
for (let col = 0; col <= this.mapW; col++) {
for (let row = 0; row <= this.mapH; row++) {
this.addGrid(col, row, AstarGridType.Normal)
}
}
}
/**
* 创建一个格子到地图
* @param x
* @param y
* @param type
*/
private addGrid(x: number, y: number, type: number = AstarGridType.Hider) {
let grid = new AstarGrid()
grid.x = x
grid.y = y
grid.type = type
this.gridsList[x][y] = grid
}
/**
* 设置格子类型
* @param x
* @param y
* @param type
*/
public setGridType(x: number, y: number, type: number) {
let curGrid: AstarGrid = this.gridsList[x][y]
curGrid.type = type
}
/**
* 开始搜索路径
* @param startPos
* @param endPos
*/
public findPath(startPos: Vec2, endPos: Vec2, callback: Function = null) {
let startGrid = this.gridsList[startPos.x][startPos.y]
this.openList.push(startGrid)
let curGrid: AstarGrid = this.openList[0]
while (this.openList.length > 0 && curGrid.type != AstarGridType.End) {
// 每次都取出f值最小的节点进行查找
curGrid = this.openList[0]
if (curGrid.type == AstarGridType.End) {
// Logger.log(this,"find path success.");
this.generatePath(curGrid)
if (callback) {
callback(this.path)
}
return
}
for (let i: number = -1; i <= 1; i++) {
for (let j: number = -1; j <= 1; j++) {
if (i != 0 || j != 0) {
let col = curGrid.x + i
let row = curGrid.y + j
if (
col >= 0 &&
row >= 0 &&
col <= this.mapW &&
row <= this.mapH &&
this.gridsList[col][row].type != AstarGridType.Hider &&
this.closeList.indexOf(this.gridsList[col][row]) < 0
) {
if (this.is8dir) {
// 8方向 斜向走动时要考虑相邻的是不是障碍物
if (
this.gridsList[col - i][row].type == AstarGridType.Hider ||
this.gridsList[col][row - j].type == AstarGridType.Hider
) {
continue
}
} else {
// 四方形行走
if (Math.abs(i) == Math.abs(j)) {
continue
}
}
// 计算g值
let g =
curGrid.g +
Math.floor(Math.sqrt(Math.pow(i * 10, 2)) + Math.pow(j * 10, 2))
if (
this.gridsList[col][row].g == 0 ||
this.gridsList[col][row].g > g
) {
this.gridsList[col][row].g = g
// 更新父节点
this.gridsList[col][row].parent = curGrid
}
// 计算h值 manhattan估算法
this.gridsList[col][row].h =
Math.abs(endPos.x - col) + Math.abs(endPos.y - row)
// 更新f值
this.gridsList[col][row].f =
this.gridsList[col][row].g + this.gridsList[col][row].h
// 如果不在开放列表里则添加到开放列表里
if (this.openList.indexOf(this.gridsList[col][row]) < 0) {
this.openList.push(this.gridsList[col][row])
}
// // 重新按照f值排序升序排列)
}
}
}
}
// 遍历完四周节点后把当前节点加入关闭列表
this.closeList.push(curGrid)
// 从开放列表把当前节点移除
this.openList.splice(this.openList.indexOf(curGrid), 1)
if (this.openList.length <= 0) {
// Logger.log(this,"find path failed.");
this.path = []
if (callback) {
callback(this.path)
}
break
}
// 重新按照f值排序升序排列)
this.openList.sort((x, y) => {
return x.f - y.f
})
}
}
/**
* 生成路径
* @param grid
*/
private generatePath(grid: AstarGrid) {
this.path.push(grid)
while (grid.parent) {
grid = grid.parent
this.path.push(grid)
}
return this.path
}
onDestroy() {}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2e03a7ea-58a9-4bbb-9dcc-660b093ea918",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "67ea5a4d-4210-4fdb-af71-bba5c66b368b",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,19 @@
import { _decorator } from 'cc'
import SoundPrefab from '../../engine/uicomponent/SoundPrefab'
import MusicPrefab from '../../engine/uicomponent/MusicPrefab'
import RandomUtil from '../../engine/utils/RandomUtil'
export default class GameMusicHelper {
public static playBg() {
let randomIndex: number = RandomUtil.nextInt(1, 3)
MusicPrefab.play('background_' + randomIndex)
}
public static playFishDead(fishType: number) {
SoundPrefab.play('deadfish_' + fishType)
}
public static playFire() {
SoundPrefab.play('fire')
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "5515ff19-e57f-4594-99b0-2e5439136f41",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,64 @@
import { error, game, _decorator } from 'cc'
import DarkLayer from '../../engine/uicomponent/DarkLayer'
import LoadingPrefab from '../../engine/uicomponent/LoadingPrefab'
import LoadingScenePrefab from '../../engine/uicomponent/LoadingScenePrefab'
import MusicPrefab from '../../engine/uicomponent/MusicPrefab'
import Progress from '../../engine/uicomponent/Progress'
import SoundPrefab from '../../engine/uicomponent/SoundPrefab'
import { Logger } from '../../engine/utils/Logger'
import ResourcePrefab from '../prefab/ResourcePrefab'
import ShaderMaterialPrefab from '../prefab/ShaderMaterialPrefab'
export default class ResourcePreload {
public static instance: ResourcePreload = new ResourcePreload()
private isPreloaded: boolean = false
private totalNum: number = 6
private nowIndex: number = 0
private progress: Progress
public async preLoad(callback: Function, progress: Progress) {
if (this.isPreloaded) {
callback()
return
}
this.isPreloaded = true
this.progress = progress
if (this.progress) {
progress.updateProgress(this.nowIndex, this.totalNum)
}
await LoadingPrefab.preLoad() //1
this.finishOneItemLoad()
await DarkLayer.preLoad() //2
this.finishOneItemLoad()
await MusicPrefab.preLoad() //3
this.finishOneItemLoad()
await SoundPrefab.preLoad() //4
this.finishOneItemLoad()
await ResourcePrefab.preLoad() //5
this.finishOneItemLoad()
await ShaderMaterialPrefab.preLoad() //6
this.finishOneItemLoad() //
callback()
}
private finishOneItemLoad() {
this.nowIndex++
if (this.progress) {
this.progress.updateProgress(this.nowIndex, this.totalNum)
}
}
public restartGame() {
this.isPreloaded = false
// GameSocket.getInstance().closeSocket(false);
LoadingScenePrefab.clear()
LoadingPrefab.clear()
error('需要获取游戏里所有的AudioSource停止音乐')
//audioEngine.stopAll();
// VersionManager.instance.releaseAll();
MusicPrefab.destory()
SoundPrefab.destory()
ResourcePrefab.clear()
game.restart()
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c49b722e-acd3-4d0f-9685-b773d596a5b3",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,7 @@
import { tween, Node } from 'cc'
export default class TimeHelper {
public static exeNextFrame(node: Node, callback: Function) {
tween(node).delay(0.02).call(callback).start()
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "11277eab-4376-4199-9255-4d5c9d2b9e7e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { _decorator, Component, Node } from 'cc'
const { ccclass, property } = _decorator
@ccclass('UIRoot')
export class UIRoot extends Component {
public static Instance
onLoad() {
UIRoot.Instance = this
}
onDestroy() {
UIRoot.Instance = null
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e0962cbd-f5bd-4c15-b6d8-c403d02a854f",
"files": [],
"subMetas": {},
"userData": {}
}