Commit 0e663103 authored by Đặng Minh Chiến's avatar Đặng Minh Chiến

Genarate map

parent 5e074229
{
"ver": "1.1.3",
"uuid": "21581cdc-60e6-40cd-9478-9d0b9f7dccea",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Apple",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
360,
60,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "929a5818-51dc-417a-a7a8-6f40f300aae8"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "1a8d3OmHDpPJYMgxvE8xbi9",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.3.2",
"uuid": "69ba8df3-7c61-4497-a754-c2b025d0f54a",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "HoleEnd",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 8
}
],
"_prefab": {
"__id__": 9
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
900,
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": ""
},
{
"__type__": "cc.Node",
"_name": "HoleEnd-1",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 90,
"height": 90
},
"_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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "f97dbd12-2422-47b7-a12d-0c08b073fe04"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "c3ZWxkxe1OMYYwqT6qt19F",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "HoleEnd-2",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 90,
"height": 90
},
"_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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c9b11be8-27e8-4ef6-aea8-44ec66c59dac"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "ffJPiq2m1M57iVI2oRvytK",
"sync": false
},
{
"__type__": "641d2YoeXlBnKBleJ3Hz/Hu",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"isStart": true,
"rotateSpeed": 90,
"holeEnd2": {
"__id__": 5
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.3.2",
"uuid": "37809793-c141-4848-be7b-dc23f7baf907",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Saw",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
600,
60,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "fed1af7b-7f39-4db6-9072-661e5bca0ba2"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "f90e9xQSJJG5rpVDXFGUeq5",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"isStart": true,
"rotateSpeed": 90,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.3.2",
"uuid": "2fcd88ae-69bc-4fb8-8adb-c7ccf1302839",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Stone",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
950,
60,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "fb7b892f-1f5c-4d07-84da-1bc7897dcfb9"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "8c53719+AdPI7z0QzCsLjLm",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.3.2",
"uuid": "063b1544-8c7f-4cd2-8271-cc1fe6b0cb02",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Trap",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 8
}
],
"_prefab": {
"__id__": 9
},
"_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": [
1070,
60,
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": "thorn_back",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 50,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
6.093,
7.002,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "932bc5a6-c583-4e50-bba6-6dd4074224c0"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "6e2aiTw3tMu7hDSdnCOCrb",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "thorn_front",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 50,
"height": 35
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-4.075,
-5.254,
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.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "06d3e81c-02a9-4454-81cd-284a1e0ce413"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "fb/jj7UIFDm6F1U3MWLY8D",
"sync": false
},
{
"__type__": "4cea8dAWZNJ0qvVmx3ld837",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.3.2",
"uuid": "7dd2ad06-19a4-4f00-badd-8550dabdc87e",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
const {ccclass, property} = cc._decorator;
@ccclass
export default class Apple extends cc.Component {
}
{
"ver": "1.1.0",
"uuid": "1a8d33a6-1c3a-4f25-8320-c6f13cc5b8bd",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -2,4 +2,5 @@ export default class Brick{
x: number;
y: number;
id: number;
index?: number;
}
const {ccclass, property} = cc._decorator;
@ccclass
export default class HoleEnd extends cc.Component {
@property()
isStart: boolean = true;
@property
rotateSpeed: number = 90;
@property(cc.Node)
holeEnd2: cc.Node = null;
update(dt: number) {
if (this.isStart) {
const rotationDelta = this.rotateSpeed * dt;
const newRotation = this.node.rotation + rotationDelta;
this.node.rotation = newRotation;
}
}
}
{
"ver": "1.1.0",
"uuid": "641d2628-7979-419c-a065-789dc7cff1ee",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import UIManager from "../UI/UIManager";
import Brick from "./Brick";
import DataLevel from "./DataLevel";
import GameManager from "./GameManager";
import Saw from "./Saw";
import Trap from "./Trap";
import Wall from "./Wall";
const { ccclass, property } = cc._decorator;
......@@ -11,109 +16,160 @@ export default class MapManager extends cc.Component {
@property(cc.Node)
containerLevel: cc.Node = null;
@property(cc.SpriteFrame)
wall: cc.SpriteFrame = null;
@property([cc.SpriteFrame])
wall1: cc.SpriteFrame[] = [];
@property(cc.SpriteFrame)
store: cc.SpriteFrame = null;
@property([cc.SpriteFrame])
wall2: cc.SpriteFrame[] = [];
@property(cc.SpriteFrame)
trap: cc.SpriteFrame = null;
@property([cc.SpriteFrame])
wall3: cc.SpriteFrame[] = [];
@property(cc.SpriteFrame)
saw: cc.SpriteFrame = null;
@property([cc.SpriteFrame])
stoneSF: cc.SpriteFrame[] = [];
@property(cc.SpriteFrame)
apple: cc.SpriteFrame = null;
@property([cc.SpriteFrame])
appleSF: cc.SpriteFrame[] = [];
@property(cc.SpriteFrame)
headWorm: cc.SpriteFrame = null;
@property(cc.Prefab)
apple: cc.Prefab = null;
@property(cc.SpriteFrame)
bodyWorm: cc.SpriteFrame = null;
@property(cc.Prefab)
stone: cc.Prefab = null;
@property(cc.SpriteFrame)
tailWorm: cc.SpriteFrame = null;
@property(cc.Prefab)
trap: cc.Prefab = null;
@property(cc.SpriteFrame)
end: cc.SpriteFrame = null;
@property(cc.Prefab)
holeEnd: cc.Prefab = null;
@property(cc.Prefab)
saw: cc.Prefab = null;
map: cc.Node[][] = [];
//map: cc.Node[][] = [];
private listLevelInstance: number[] = [];
private listSpWall: cc.SpriteFrame[] = [];
private idBackground: number = 1;
private nodeParentPlatform: cc.Node = null;
private offsetMap: number = 43;
private is18: boolean = true;
private offsetMap: number = 60;
private sizeMap: number = 91
protected onLoad(): void {
MapManager.Instance = this;
}
generateMapByLevel(level) {
let dataLevel: DataLevel = GameManager.Instance.dataLevels[level];
// const width = dataLevel.width;
// const height = dataLevel.height;
const width = 21;
const height = 12;
for (let y = 0; y < height; y++) {
this.map.push([]);
for (let x = 0; x < width; x++) {
this.map[y].push(null);
}
this.idBackground = this.getID(level + 1);
UIManager.Instance.setBackground(this.idBackground);
if (this.idBackground == 1) {
this.listSpWall = this.wall1;
} else if (this.idBackground == 2) {
this.listSpWall = this.wall2;
} else {
this.listSpWall = this.wall3;
}
this.nodeParentPlatform = new cc.Node();
this.nodeParentPlatform.name = "NodePlatformLevel_" + level;
this.nodeParentPlatform.position = cc.v3(0, 0);
this.nodeParentPlatform.parent = this.containerLevel;
let count = dataLevel.bricks.length;
for (const brick of dataLevel.bricks) {
let brickNode: cc.Node = this.instanceNodeById(brick.id);
brickNode.position = cc.v3(this.offsetMap * brick.x, this.offsetMap * brick.y)
brickNode.zIndex = count--;
this.map[brick.y][brick.x] = brickNode;
if (this.listLevelInstance.includes(level)) {
const childNodeLevel = this.containerLevel.getChildByName("NodePlatformLevel_" + level);
if (childNodeLevel) {
childNodeLevel.active = true;
}
} else {
let dataLevel: DataLevel = GameManager.Instance.dataLevels[level];
const width = dataLevel.width;
const height = dataLevel.height;
if (width == 18 && height == 10) {
this.containerLevel.position = cc.v3(-535, -150);
this.sizeMap = 91;
this.offsetMap = 60;
this.is18 = true;
} else {
this.containerLevel.position = cc.v3(-530, -150);
this.sizeMap = 74;
this.offsetMap = 50;
this.is18 = false;
}
// for (let y = 0; y < height; y++) {
// this.map.push([]);
// for (let x = 0; x < width; x++) {
// this.map[y].push(null);
// }
// }
this.nodeParentPlatform = new cc.Node();
this.nodeParentPlatform.name = "NodePlatformLevel_" + level;
this.nodeParentPlatform.position = cc.v3(0, 0);
this.nodeParentPlatform.parent = this.containerLevel;
let count = dataLevel.bricks.length;
console.log(count);
for (const brick of dataLevel.bricks) {
console.log("AAAAAAA");
let brickNode: cc.Node = this.instanceNodeById(brick);
console.log(brickNode.name);
// brickNode.zIndex = count--;
//this.map[brick.y][brick.x] = brickNode;
}
this.listLevelInstance.push(level);
}
}
instanceNodeById(id: number): cc.Node {
let brick = new cc.Node();
brick.name = "brick_" + id;
brick.parent = this.nodeParentPlatform;
switch (id) {
instanceNodeById(brickData: Brick): cc.Node {
switch (brickData.id) {
case 1:
brick.addComponent(cc.Sprite).spriteFrame = this.wall;
brick.width = 64;
brick.height = 64;
break;
let brick = new cc.Node();
brick.name = "wall_" + brickData.id;
brick.parent = this.nodeParentPlatform;
brick.addComponent(cc.Sprite);
if (brickData.index) {
brick.getComponent(cc.Sprite).spriteFrame = this.listSpWall[brickData.index];
} else {
//Tạm
brick.getComponent(cc.Sprite).spriteFrame = this.listSpWall[12];
}
brick.width = this.sizeMap;
brick.height = this.sizeMap;
brick.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
console.log(brick.position.toString())
return brick;
case 2:
brick.addComponent(cc.Sprite).spriteFrame = this.store;
brick.width = 64;
brick.height = 64;
break;
let stone: cc.Node = cc.instantiate(this.stone);
stone.addComponent(cc.Sprite).spriteFrame = this.stoneSF[this.idBackground - 1];
stone.width = this.offsetMap;
stone.height = this.offsetMap;
stone.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
return stone;
case 3:
brick.addComponent(cc.Sprite).spriteFrame = this.trap;
brick.width = 64;
brick.height = 64;
break;
let trap: cc.Node = cc.instantiate(this.trap);
trap.getComponent(Trap).updateSize(this.is18);
trap.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
return trap;
case 4:
brick.addComponent(cc.Sprite).spriteFrame = this.apple;
brick.width = 64;
brick.height = 64;
break;
let apple: cc.Node = cc.instantiate(this.stone);
apple.addComponent(cc.Sprite).spriteFrame = this.appleSF[this.idBackground - 1];
apple.width = this.offsetMap;
apple.height = this.offsetMap;
apple.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
return apple;
case 7:
brick.addComponent(cc.Sprite).spriteFrame = this.saw;
brick.width = 64;
brick.height = 64;
break;
let saw: cc.Node = cc.instantiate(this.saw);
saw.width = this.offsetMap;
saw.height = this.offsetMap;
saw.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
return saw;
case 8:
brick.addComponent(cc.Sprite).spriteFrame = this.end;
brick.width = 64;
brick.height = 64;
break;
let end: cc.Node = cc.instantiate(this.holeEnd);
end.position = cc.v3(this.offsetMap * brickData.x, this.offsetMap * brickData.y);
return end;
}
}
getID(n: number): number {
if (n < 1) {
throw new Error("Số truyền vào phải lớn hơn hoặc bằng 1");
}
return brick;
return Math.floor((n - 1) / 3) + 1;
}
}
\ No newline at end of file
const {ccclass, property} = cc._decorator;
@ccclass
export default class Saw extends cc.Component {
@property()
isStart: boolean = true;
@property
rotateSpeed: number = 90;
update(dt: number) {
if (this.isStart) {
const rotationDelta = this.rotateSpeed * dt;
const newRotation = this.node.rotation + rotationDelta;
this.node.rotation = newRotation;
}
}
}
{
"ver": "1.1.0",
"uuid": "f90e9c50-4892-46e6-ba55-0d714651eab9",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const {ccclass, property} = cc._decorator;
@ccclass
export default class Stone extends cc.Component {
}
{
"ver": "1.1.0",
"uuid": "8c537d7d-f807-4f23-bcf4-4330ac2e32e6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class Trap extends cc.Component {
@property(cc.Node)
spBack: cc.Node = null;
@property(cc.Node)
spFont: cc.Node = null;
updateSize(is18){
if (is18) {
this.spBack.width = 50;
this.spBack.height = 60;
this.spFont.width = 50;
this.spFont.height = 35;
}else{
this.spBack.width = 45;
this.spBack.height = 55;
this.spFont.width = 45;
this.spFont.height = 25;
}
this.spFont.zIndex = 10000;
}
}
{
"ver": "1.1.0",
"uuid": "4cea8740-5993-49d2-abd5-9b1de577cdfb",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const {ccclass, property} = cc._decorator;
@ccclass
export default class Wall extends cc.Component {
}
{
"ver": "1.1.0",
"uuid": "29982ab7-a5fc-472d-ac0c-69d1afd2a32c",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_alone_91": {
"wall_alone": {
"ver": "1.0.6",
"uuid": "865e80ed-76cd-45ad-acc7-3b335772a51e",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_center_91": {
"wall_center_2_2": {
"ver": "1.0.6",
"uuid": "36e12fd2-dce4-47f8-81b7-39cfa70380ea",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downcenter_91": {
"wall_downcenter_3_2": {
"ver": "1.0.6",
"uuid": "dc7a4991-ef7f-4180-8bde-b5d41f8b9e30",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downleft_91": {
"wall_downleft_3_1": {
"ver": "1.0.6",
"uuid": "354e994a-97eb-4c83-997a-cb6a9b07fb35",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downright_91": {
"wall_downright_3_3": {
"ver": "1.0.6",
"uuid": "f3a4b227-850e-4581-bcf2-f22e82110391",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_transverse_91": {
"wall_full_1": {
"ver": "1.0.6",
"uuid": "bf22df6f-4200-4a04-93d5-61e3af17914d",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_left_91": {
"wall_full_2": {
"ver": "1.0.6",
"uuid": "8950a0b3-d5e9-44bf-ac29-1f427ec02fcf",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_right_91": {
"wall_full_3": {
"ver": "1.0.6",
"uuid": "0c7e5776-fd24-4848-bfc0-c87e05c1b420",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_leftcenter_91": {
"wall_leftcenter_2_1": {
"ver": "1.0.6",
"uuid": "79939907-3355-4886-abfc-1629a600c064",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_rightcenter_91": {
"wall_rightcenter_2_3": {
"ver": "1.0.6",
"uuid": "07593af5-2d69-41fb-a44f-6f1322e6d237",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_upcenter_91": {
"wall_upcenter_1_2": {
"ver": "1.0.6",
"uuid": "9c83220e-7f00-4b46-9318-755e4fcfb23b",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_upleft_91": {
"wall_upleft_1_1": {
"ver": "1.0.6",
"uuid": "2bc2c952-7e63-4979-bcdb-dc6356c5a7d6",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_upright_91": {
"wall_upright_1_3": {
"ver": "1.0.6",
"uuid": "34eb87b7-174c-4690-8aeb-a147f5adf1cc",
"importer": "sprite-frame",
......
{
"ver": "1.1.3",
"uuid": "9a565b3e-312c-4c20-8f1e-4d66d823ab8a",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.3",
"uuid": "99d2784d-a69e-442a-b6de-432ff26521fb",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_center_0": {
"wall_center_2_2": {
"ver": "1.0.6",
"uuid": "cabe52da-c4d0-408c-a033-ee89a8b38f55",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downcenter_0": {
"wall_downcenter_3_2": {
"ver": "1.0.6",
"uuid": "56db84de-3e75-4c36-9c0f-86d02eab1e56",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downleft_0": {
"wall_downleft_3_1": {
"ver": "1.0.6",
"uuid": "d000b288-87f7-474b-9fdb-8eb778d8d26e",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_downright_0": {
"wall_downright_3_3": {
"ver": "1.0.6",
"uuid": "3555eab1-795b-4a4e-aa2c-1435738e1053",
"importer": "sprite-frame",
......
......@@ -12,7 +12,7 @@
"height": 91,
"platformSettings": {},
"subMetas": {
"wall_transverse": {
"wall_full_1": {
"ver": "1.0.6",
"uuid": "8697d85e-b93c-4edc-8c22-47f506d9a217",
"importer": "sprite-frame",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment