Commit 0b7ce095 authored by Nguyễn Quang Sáng's avatar Nguyễn Quang Sáng

update 27/7

parent 2ce43f74
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "New Particle",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_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": [
3.754,
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.ParticleSystem",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 775,
"_dstBlendFactor": 772,
"_custom": true,
"_file": {
"__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5"
},
"_spriteFrame": {
"__uuid__": "8d2a9861-057e-44ec-a6b1-16c6d47f8dd2"
},
"_texture": null,
"_stopped": true,
"playOnLoad": true,
"autoRemoveOnFinish": true,
"totalParticles": 650,
"duration": 2.5,
"emissionRate": 550,
"life": 3,
"lifeVar": 0.5,
"_startColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_startColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 0
},
"_endColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 0
},
"_endColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 0
},
"angle": 0,
"angleVar": 360,
"startSize": 200,
"startSizeVar": 50,
"endSize": 200,
"endSizeVar": 0,
"startSpin": 0,
"startSpinVar": 360,
"endSpin": 0,
"endSpinVar": 0,
"sourcePos": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"posVar": {
"__type__": "cc.Vec2",
"x": 240,
"y": 240
},
"_positionType": 1,
"positionType": 1,
"emitterMode": 0,
"gravity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"speed": 50,
"speedVar": 0,
"tangentialAccel": 0,
"tangentialAccelVar": 360,
"radialAccel": 350,
"radialAccelVar": 200,
"rotationIsDir": true,
"startRadius": 0,
"startRadiusVar": 0,
"endRadius": 0,
"endRadiusVar": 0,
"rotatePerS": 0,
"rotatePerSVar": 0,
"_N$preview": 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": "3baee33d-6796-4280-8864-4a5ae4291f32",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -42,7 +42,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 162,
"width": 160,
"height": 82
},
"_anchorPoint": {
......@@ -55,7 +55,7 @@
"ctor": "Float64Array",
"array": [
200.517,
282.219,
282.21900000000005,
0,
0,
0,
......@@ -98,7 +98,7 @@
"__uuid__": "4c985699-20b6-4953-9b67-f5901c523cc2"
},
"_type": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
......
......@@ -98,7 +98,7 @@
"__uuid__": "5e0960c8-7576-43ff-9cb5-ed46d0378ead"
},
"_type": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
......
......@@ -98,7 +98,7 @@
"__uuid__": "b7503491-55cf-49fc-8501-7ca7cc3ae1a9"
},
"_type": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
......
......@@ -42,7 +42,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 242,
"width": 240,
"height": 82
},
"_anchorPoint": {
......@@ -98,7 +98,7 @@
"__uuid__": "ff89843c-3301-41f3-afcc-901b3c9df86c"
},
"_type": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
......
This diff is collapsed.
This diff is collapsed.
......@@ -75,22 +75,19 @@
"__id__": 5
},
{
"__id__": 7
"__id__": 8
},
{
"__id__": 10
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 13
},
{
"__id__": 14
"__id__": 15
},
{
"__id__": 15
"__id__": 16
}
],
"_prefab": null,
......@@ -251,6 +248,9 @@
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": null,
......@@ -333,6 +333,19 @@
"_atlas": null,
"_id": "a8n4d+a8FOE7Ybhwd7byeC"
},
{
"__type__": "a6db5wfXWRGH4RmRsOfJHj1",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"introSound": {
"__uuid__": "fa86100b-1011-4065-ba50-1914d84fcbac"
},
"_id": "3f/ULYa1lFvYRIpNeNvkYJ"
},
{
"__type__": "cc.Node",
"_name": "Title",
......@@ -344,10 +357,10 @@
"_active": true,
"_components": [
{
"__id__": 8
"__id__": 9
},
{
"__id__": 9
"__id__": 10
}
],
"_prefab": null,
......@@ -403,7 +416,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 8
},
"_enabled": true,
"_materials": [
......@@ -435,7 +448,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 8
},
"_enabled": true,
"_defaultClip": {
......@@ -460,7 +473,10 @@
"_active": true,
"_components": [
{
"__id__": 11
"__id__": 12
},
{
"__id__": 14
}
],
"_prefab": null,
......@@ -516,7 +532,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
"__id__": 11
},
"_enabled": true,
"_normalMaterial": null,
......@@ -525,7 +541,7 @@
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 12
"__id__": 13
}
],
"_N$interactable": true,
......@@ -598,13 +614,25 @@
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 2
"__id__": 11
},
"component": "",
"_componentId": "0630eLWyFxBW47AT1b77FBE",
"handler": "LoadScene",
"_componentId": "4bc11amZLhJF7l5YKzcrMTW",
"handler": "LoadScene0",
"customEventData": ""
},
{
"__type__": "4bc11amZLhJF7l5YKzcrMTW",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"volumeOnSprite": null,
"volumeOffSprite": null,
"_id": "74+UhfoGhAqI0uYMFlviH3"
},
{
"__type__": "cc.Canvas",
"_name": "",
......@@ -648,15 +676,5 @@
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "336r9sBylMMIN9QPWVS9fO"
},
{
"__type__": "0630eLWyFxBW47AT1b77FBE",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "47EM7ryghJM7bCKUvHjJ6n"
}
]
\ No newline at end of file
import GamePlay from "./GamePlay";
import Levels from "./Levels";
const { ccclass, property } = cc._decorator;
......@@ -13,40 +12,66 @@ export default class Block extends cc.Component {
lockUp = false;
lockDown = false;
lockLeftX = null;
lockRightX = null;
lockUpY = null;
lockDownY = null;
onCollisionEnter(other, self) {
if (GamePlay.instance.currentHoldingBlock != this.node) return;
if (other.tag == 1) {
console.log("next level!");
GamePlay.instance.onMouseLeave();
GamePlay.instance.onMouseUp();
Levels.instance.currentLevel += 1;
Levels.instance.LoadScene(null, Levels.instance.currentLevel.toString());
GamePlay.instance.onCompleteLevel();
} else {
GamePlay.instance.isOnBlockCollision = true;
GamePlay.instance.touchLocOnBlockCollision =
GamePlay.instance.currentTouchLoc;
this.isColliding = true;
if (GamePlay.instance.touchDelta.y > 0) {
this.lockUp = true;
this.lockDown = false;
}
if (GamePlay.instance.touchDelta.y < 0) {
this.lockDown = true;
this.lockUp = false;
}
if (GamePlay.instance.touchDelta.x > 0) {
this.lockRight = true;
this.lockLeft = false;
}
if (GamePlay.instance.touchDelta.x < 0) {
this.lockRight = false;
this.lockLeft = true;
let nodeA = this.node;
let nodeB: cc.Node = other.node;
if (this.typeMove == 2) {
if (nodeA.position.x - nodeB.position.x < 0) {
let pos = nodeA.position;
pos.x =
nodeB.x -
nodeB.getContentSize().width / 2 -
nodeA.getContentSize().width / 2;
nodeA.position = pos;
this.lockRight = true;
this.lockRightX = GamePlay.instance.currentTouchLoc.x;
} else {
let pos = nodeA.position;
pos.x =
nodeB.x +
nodeB.getContentSize().width / 2 +
nodeA.getContentSize().width / 2;
nodeA.position = pos;
this.lockLeft = true;
this.lockLeftX = GamePlay.instance.currentTouchLoc.x;
}
} else {
if (nodeA.position.y - nodeB.position.y < 0) {
let pos = nodeA.position;
pos.y =
nodeB.y -
nodeB.getContentSize().height / 2 -
nodeA.getContentSize().height / 2;
nodeA.position = pos;
this.lockUp = true;
this.lockUpY = GamePlay.instance.currentTouchLoc.y;
} else {
let pos = nodeA.position;
pos.y =
nodeB.y +
nodeB.getContentSize().height / 2 +
nodeA.getContentSize().height / 2;
nodeA.position = pos;
this.lockDown = true;
this.lockDownY = GamePlay.instance.currentTouchLoc.y;
}
}
}
}
onCollisionExit() {
this.isColliding = false;
this.lockLeft = false;
this.lockRight = false;
this.lockUp = false;
this.lockDown = false;
}
}
import GamePlay from "./GamePlay";
const { ccclass, property } = cc._decorator;
@ccclass
export default class VolumeButton extends cc.Component {
export default class Button extends cc.Component {
@property(cc.SpriteFrame)
volumeOnSprite: cc.SpriteFrame = null;
......@@ -10,6 +12,7 @@ export default class VolumeButton extends cc.Component {
sprite: cc.Sprite = null;
currentSprite: cc.SpriteFrame;
pressed: boolean = false;
onLoad() {
this.currentSprite = this.volumeOnSprite;
......@@ -18,8 +21,12 @@ export default class VolumeButton extends cc.Component {
onClickButton() {
if (this.currentSprite === this.volumeOnSprite) {
this.currentSprite = this.volumeOffSprite;
cc.audioEngine.setMusicVolume(0);
cc.audioEngine.setEffectsVolume(0);
} else {
this.currentSprite = this.volumeOnSprite;
cc.audioEngine.setMusicVolume(1);
cc.audioEngine.setEffectsVolume(1);
}
this.updateButtonSprite();
}
......@@ -29,4 +36,15 @@ export default class VolumeButton extends cc.Component {
const sprite = button.node.getComponent(cc.Sprite);
sprite.spriteFrame = this.currentSprite;
}
LoadCurrentScene() {
if (!this.pressed) {
this.pressed = true;
GamePlay.instance.restartLevel();
}
}
LoadScene0() {
cc.director.loadScene("levels");
}
}
{
"ver": "1.1.0",
"uuid": "ff77d565-e394-4084-8f35-1f46fb11df82",
"uuid": "4bc116a6-64b8-4917-b979-60acdcacc4d6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
......
This diff is collapsed.
This diff is collapsed.
const { ccclass, property } = cc._decorator;
@ccclass
export default class LocalStorage extends cc.Component {
public static setCurrentLevel(value: number) {
cc.sys.localStorage.setItem("FreeTheKey" + " - " + "CurrentLevel", value);
}
public static getCurrentLevel(): number {
if (
cc.sys.localStorage.getItem("FreeTheKey" + " - " + "CurrentLevel") == null
) {
cc.sys.localStorage.setItem("FreeTheKey" + " - " + "CurrentLevel", 0);
return 0;
} else
return JSON.parse(
cc.sys.localStorage.getItem("FreeTheKey" + " - " + "CurrentLevel")
);
}
public static setHighestLevel(value: number) {
cc.sys.localStorage.setItem("FreeTheKey" + " - " + "HighestLevel", value);
}
public static getHighestLevel(): number {
if (
cc.sys.localStorage.getItem("FreeTheKey" + " - " + "HighestLevel") == null
) {
cc.sys.localStorage.setItem("FreeTheKey" + " - " + "HighestLevel", 1);
return 1;
} else
return JSON.parse(
cc.sys.localStorage.getItem("FreeTheKey" + " - " + "HighestLevel")
);
}
public static getMinMoveAtLevel(level: number): number {
if (
cc.sys.localStorage.getItem(
"FreeTheKey" + " - " + "Level " + level.toString()
) == null
) {
cc.sys.localStorage.setItem(
"FreeTheKey" + " - " + "Level " + level.toString(),
0
);
return 0;
} else
return JSON.parse(
cc.sys.localStorage.getItem(
"FreeTheKey" + " - " + "Level " + level.toString()
)
);
}
public static setMinMoveAtLevel(level: number, moveValue: number) {
cc.sys.localStorage.setItem(
"FreeTheKey" + " - " + "Level " + level.toString(),
moveValue
);
}
}
{
"ver": "1.1.0",
"uuid": "221106aa-8b17-43c7-8b83-4e85180e840e",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import LocalStorage from "./LocalStorage";
const { ccclass, property } = cc._decorator;
@ccclass
export default class LvManager extends cc.Component {
@property(cc.Node) gridStage1: cc.Node = null;
@property(cc.Node) gridStage2: cc.Node = null;
@property(cc.SpriteFrame) lockSprite: cc.SpriteFrame = null;
@property(cc.AudioClip) soundIntro: cc.AudioClip = null;
static instance: LvManager = null;
highestUnlockedLevel: number;
onLoad() {
this.highestUnlockedLevel = LocalStorage.getHighestLevel();
this.updateLevelStatus();
cc.audioEngine.playEffect(this.soundIntro, false);
}
updateLevelStatus() {
//gridStage1
LvManager.instance = this;
let levelButtons1 = this.gridStage1.children;
for (let i = 0; i < levelButtons1.length; i++) {
const e = levelButtons1[i];
if (i >= LocalStorage.getHighestLevel() - 1) {
e.getChildByName("maxMove").active = false;
}
e.getComponentInChildren(cc.Label).string =
LocalStorage.getMinMoveAtLevel(i).toString();
if (i >= this.highestUnlockedLevel) {
e.getComponentInChildren(cc.Sprite).spriteFrame = this.lockSprite;
e.getComponentInChildren(cc.Label).node.active = false;
e.children[1].active = false;
e.children[2].active = false;
}
}
//gridStage2
let levelButtons2 = this.gridStage2.children;
for (let i = 0; i < levelButtons2.length; i++) {
const e = levelButtons2[i];
const level = i + 20;
if (i >= LocalStorage.getHighestLevel() - 1) {
e.getChildByName("maxMove").active = false;
}
e.getComponentInChildren(cc.Label).string =
LocalStorage.getMinMoveAtLevel(level).toString();
if (level > this.highestUnlockedLevel) {
e.getComponentInChildren(cc.Sprite).spriteFrame = this.lockSprite;
e.getComponentInChildren(cc.Label).node.active = false;
e.children[1].active = false;
e.children[2].active = false;
}
}
}
}
{
"ver": "1.1.0",
"uuid": "e6cbe195-8f8c-4f15-9d28-37d5bd7cc241",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
const { ccclass, property } = cc._decorator;
@ccclass
export default class Start extends cc.Component {
@property(cc.AudioClip) introSound: cc.AudioClip = null;
protected onLoad(): void {
cc.audioEngine.playEffect(this.introSound, false);
}
protected onDestroy(): void {}
}
{
"ver": "1.1.0",
"uuid": "a6db5c1f-5d64-461f-8466-46c39f2478f5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.3",
"uuid": "966c1554-4283-4b45-ae25-942587eb867d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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