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
8b846837
Commit
8b846837
authored
Oct 07, 2023
by
Nguyễn Quang Sáng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
07/10/23 commit
parent
2e09a438
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
GameController.ts
assets/Scripts/Controllers/GameController.ts
+13
-4
Block.ts
assets/Scripts/Objects/Block.ts
+0
-1
No files found.
assets/Scripts/Controllers/GameController.ts
View file @
8b846837
...
...
@@ -147,6 +147,9 @@ export default class GameController extends cc.Component {
}
checkMergeability
(
row
:
number
,
col
:
number
)
{
const
node
=
this
.
board
.
children
[
row
*
5
+
col
].
children
[
0
];
if
(
node
)
this
.
currentBlock
=
node
;
const
mergedValue
=
this
.
currentBlock
.
getComponent
(
Block
).
value
;
const
neighbors
=
[
...
...
@@ -324,6 +327,7 @@ export default class GameController extends cc.Component {
const
data
=
this
.
blocksData
.
blockData
;
const
cells
=
this
.
board
.
children
;
let
fallingDown
=
false
;
let
hasCheckMerge
=
false
;
for
(
let
row
=
0
;
row
<
data
.
length
;
row
++
)
{
for
(
let
col
=
0
;
col
<
data
[
row
].
length
;
col
++
)
{
...
...
@@ -351,6 +355,9 @@ export default class GameController extends cc.Component {
const
globalPos
=
cellMerge
.
convertToWorldSpaceAR
(
cc
.
Vec2
.
ZERO
);
const
localPos
=
cellMove
.
convertToNodeSpaceAR
(
globalPos
);
data
[
newRow
][
newCol
]
=
data
[
newRow
-
1
][
newCol
];
data
[
newRow
-
1
][
newCol
]
=
0
;
cc
.
tween
(
nodeToMove
)
.
to
(
0.3
,
{
position
:
cc
.
v3
(
localPos
.
x
,
localPos
.
y
)
})
.
call
(()
=>
{
...
...
@@ -359,11 +366,12 @@ export default class GameController extends cc.Component {
cellMerge
.
addChild
(
nodeToMove
);
nodeToMove
.
setPosition
(
cc
.
Vec2
.
ZERO
);
data
[
newRow
][
newCol
]
=
data
[
newRow
-
1
][
newCol
];
data
[
newRow
-
1
][
newCol
]
=
0
;
console
.
log
(
data
);
if
(
!
hasCheckMerge
)
{
console
.
log
(
row
,
col
);
this
.
checkMergeability
(
row
,
col
);
this
.
checkMergeability
(
row
,
col
);
hasCheckMerge
=
true
;
}
})
.
start
();
}
...
...
@@ -372,6 +380,7 @@ export default class GameController extends cc.Component {
}
}
}
if
(
!
fallingDown
)
{
this
.
checkMergeability
(
this
.
currentBlockRow
,
this
.
currentBlockCol
);
}
...
...
assets/Scripts/Objects/Block.ts
View file @
8b846837
import
GameController
from
"../Controllers/GameController"
;
import
BlockData
from
"../Data/BlockData"
;
import
Utils
from
"../Tools/Utils"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
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