Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DropAndMergeTheNumber
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyễn Quang Sáng
DropAndMergeTheNumber
Commits
2e09a438
Commit
2e09a438
authored
Oct 06, 2023
by
Nguyễn Quang Sáng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
06/10/23 commit
parent
4b85df29
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
261 additions
and
731 deletions
+261
-731
background.png
assets/Resources/Sprites/UI/Backgrounds/background.png
+0
-0
board.png
assets/Resources/Sprites/UI/Backgrounds/board.png
+0
-0
board.png.meta
assets/Resources/Sprites/UI/Backgrounds/board.png.meta
+5
-5
cover.png
assets/Resources/Sprites/UI/Backgrounds/cover.png
+0
-0
cover.png.meta
assets/Resources/Sprites/UI/Backgrounds/cover.png.meta
+10
-10
startBar.png
assets/Resources/Sprites/UI/Backgrounds/startBar.png
+0
-0
startBar.png.meta
assets/Resources/Sprites/UI/Backgrounds/startBar.png.meta
+38
-0
gameplay.fire
assets/Scenes/gameplay.fire
+158
-655
GameController.ts
assets/Scripts/Controllers/GameController.ts
+50
-61
No files found.
assets/Resources/Sprites/UI/Backgrounds/background.png
deleted
100644 → 0
View file @
4b85df29
911 Bytes
assets/Resources/Sprites/UI/B
utton
s/board.png
→
assets/Resources/Sprites/UI/B
ackground
s/board.png
View file @
2e09a438
File moved
assets/Resources/Sprites/UI/B
utton
s/board.png.meta
→
assets/Resources/Sprites/UI/B
ackground
s/board.png.meta
View file @
2e09a438
{
"ver": "2.3.7",
"uuid": "
05bd40d3-f0d9-49e6-a807-1a18c072d5f8
",
"uuid": "
b971e505-a4fb-4bd1-951a-b0adb49418f3
",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
...
...
@@ -14,9 +14,9 @@
"subMetas": {
"board": {
"ver": "1.0.6",
"uuid": "
72614e26-8584-481b-be35-1a58541bca6e
",
"uuid": "
56deaa84-0d07-4862-bf7a-464463fe0b20
",
"importer": "sprite-frame",
"rawTextureUuid": "
05bd40d3-f0d9-49e6-a807-1a18c072d5f8
",
"rawTextureUuid": "
b971e505-a4fb-4bd1-951a-b0adb49418f3
",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
...
...
@@ -28,8 +28,8 @@
"height": 232,
"rawWidth": 629,
"rawHeight": 232,
"borderTop":
6
0,
"borderBottom":
60
,
"borderTop":
5
0,
"borderBottom":
54
,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
...
...
assets/Resources/Sprites/UI/Backgrounds/cover.png
0 → 100644
View file @
2e09a438
25.8 KB
assets/Resources/Sprites/UI/Backgrounds/
background
.png.meta
→
assets/Resources/Sprites/UI/Backgrounds/
cover
.png.meta
View file @
2e09a438
{
"ver": "2.3.7",
"uuid": "
6ef10c61-7948-4a75-bcdc-d78b4d4a3739
",
"uuid": "
22d327b7-97f5-454a-abeb-449c8f236e08
",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
...
...
@@ -8,15 +8,15 @@
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width":
100
,
"height": 1
180
,
"width":
688
,
"height": 1
27
,
"platformSettings": {},
"subMetas": {
"
background
": {
"
cover
": {
"ver": "1.0.6",
"uuid": "
dc2bc766-5d14-4d73-bf9c-0fd9128ded4b
",
"uuid": "
bc1ff98b-19b9-47d3-9d2e-e210fd915684
",
"importer": "sprite-frame",
"rawTextureUuid": "
6ef10c61-7948-4a75-bcdc-d78b4d4a3739
",
"rawTextureUuid": "
22d327b7-97f5-454a-abeb-449c8f236e08
",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
...
...
@@ -24,10 +24,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width":
125
,
"height": 12
5
,
"rawWidth":
125
,
"rawHeight": 12
5
,
"width":
688
,
"height": 12
7
,
"rawWidth":
688
,
"rawHeight": 12
7
,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
...
...
assets/Resources/Sprites/UI/Backgrounds/startBar.png
0 → 100644
View file @
2e09a438
5.46 KB
assets/Resources/Sprites/UI/Backgrounds/startBar.png.meta
0 → 100644
View file @
2e09a438
{
"ver": "2.3.7",
"uuid": "df371361-80fe-4eb1-97e3-2f914c6d1f10",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 604,
"height": 105,
"platformSettings": {},
"subMetas": {
"startBar": {
"ver": "1.0.6",
"uuid": "693b3bd4-5606-4e95-b740-c3df1e66624e",
"importer": "sprite-frame",
"rawTextureUuid": "df371361-80fe-4eb1-97e3-2f914c6d1f10",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 604,
"height": 105,
"rawWidth": 604,
"rawHeight": 105,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/Scenes/gameplay.fire
View file @
2e09a438
This diff is collapsed.
Click to expand it.
assets/Scripts/Controllers/GameController.ts
View file @
2e09a438
...
...
@@ -277,14 +277,14 @@ export default class GameController extends cc.Component {
newValue
);
this
.
merge
Mo
tion
(
this
.
merge
Ac
tion
(
cellToMerge
,
this
.
currentBlock
.
getComponent
(
Block
).
value
,
index
);
}
merge
Mo
tion
(
cellToMerge
:
cc
.
Node
,
value
:
number
,
index
:
number
)
{
merge
Ac
tion
(
cellToMerge
:
cc
.
Node
,
value
:
number
,
index
:
number
)
{
let
hasCheckedEmptyCell
=
false
;
for
(
let
i
=
0
;
i
<
this
.
cachedBlocksToMerge
.
length
;
i
++
)
{
...
...
@@ -307,7 +307,8 @@ export default class GameController extends cc.Component {
.
call
(()
=>
{
nodeClone
.
destroy
();
nodeClone
.
parent
.
removeAllChildren
();
this
.
currentBlock
.
getComponent
(
Block
).
setSpriteBlock
(
index
);
cellToMerge
.
children
[
0
].
getComponent
(
Block
).
setSpriteBlock
(
index
);
this
.
cachedBlocksToMerge
.
length
=
0
;
if
(
!
hasCheckedEmptyCell
)
{
...
...
@@ -321,70 +322,58 @@ export default class GameController extends cc.Component {
checkEmptyCell
()
{
const
data
=
this
.
blocksData
.
blockData
;
const
numRows
=
data
.
length
;
const
numCols
=
data
[
0
].
length
;
let
newRow
=
0
;
let
newCol
=
0
;
// detected empty cell
for
(
let
col
=
0
;
col
<
numCols
;
col
++
)
{
for
(
let
row
=
numRows
-
2
;
row
>=
0
;
row
--
)
{
if
(
data
[
row
][
col
]
!==
0
)
{
let
currentRow
=
row
;
while
(
currentRow
+
1
<
numRows
)
{
if
(
data
[
currentRow
+
1
][
col
]
==
0
)
{
data
[
currentRow
+
1
][
col
]
=
data
[
currentRow
][
col
];
data
[
currentRow
][
col
]
=
0
;
currentRow
++
;
newRow
=
currentRow
;
newCol
=
col
;
return
this
.
checkMergeability
(
newRow
,
newCol
);
}
else
{
break
;
}
}
}
}
}
const
cells
=
this
.
board
.
children
;
let
fallingDown
=
false
;
for
(
let
row
=
0
;
row
<
data
.
length
;
row
++
)
{
for
(
let
col
=
0
;
col
<
data
[
row
].
length
;
col
++
)
{
const
value
=
data
[
row
][
col
];
// no empty cell detected
if
(
newRow
==
0
&&
newCol
==
0
)
{
return
this
.
checkMergeability
(
this
.
currentBlockRow
,
this
.
currentBlockCol
);
if
(
value
==
0
)
{
for
(
let
i
=
row
-
1
;
i
>=
0
;
i
--
)
{
if
(
data
[
i
][
col
]
!==
0
)
{
fallingDown
=
true
;
break
;
}
}
// updateBoardChildren() {
// const data = this.blocksData.blockData;
// const childrens = this.board.children;
// for (let row = 0; row < 6; row++) {
// for (let col = 0; col < 5; col++) {
// const index = row * 5 + col;
// const cell = childrens[index];
// const value = data[row][col];
if
(
fallingDown
)
{
let
cellMoveIndex
=
row
*
5
+
col
-
5
;
// cell.removeAllChildren();
for
(
let
j
=
cellMoveIndex
;
j
>=
0
;
j
-=
5
)
{
if
(
cells
[
j
].
children
.
length
>
0
)
{
const
cellMerge
=
cells
[
j
+
5
];
const
cellMove
=
cells
[
j
];
const
nodeToMove
=
cellMove
.
children
[
0
];
const
newRow
=
Math
.
floor
(
j
/
5
)
+
1
;
const
newCol
=
j
%
5
;
// if (value !== 0) {
// const newValueNode = this.createValueNode(value);
// cell.addChild(newValueNode);
// if (cell.children.length > 1) cell.children.shift();
// }
// }
// }
// }
const
globalPos
=
cellMerge
.
convertToWorldSpaceAR
(
cc
.
Vec2
.
ZERO
);
const
localPos
=
cellMove
.
convertToNodeSpaceAR
(
globalPos
);
// createValueNode(value: number) {
// const newNode = new cc.Node();
cc
.
tween
(
nodeToMove
)
.
to
(
0.3
,
{
position
:
cc
.
v3
(
localPos
.
x
,
localPos
.
y
)
})
.
call
(()
=>
{
nodeToMove
.
removeFromParent
();
cellMerge
.
removeAllChildren
();
cellMerge
.
addChild
(
nodeToMove
);
nodeToMove
.
setPosition
(
cc
.
Vec2
.
ZERO
);
// newNode.addComponent(cc.Sprite).spriteFrame =
// this.blockPrefab.data.getComponent(Block).listSpriteBlocks[
// Math.log(value) / Math.log(2) - 1
// ];
data
[
newRow
][
newCol
]
=
data
[
newRow
-
1
][
newCol
];
data
[
newRow
-
1
][
newCol
]
=
0
;
console
.
log
(
data
);
// return newNode;
// }
this
.
checkMergeability
(
row
,
col
);
})
.
start
();
}
}
}
}
}
}
if
(
!
fallingDown
)
{
this
.
checkMergeability
(
this
.
currentBlockRow
,
this
.
currentBlockCol
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment