Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dap-hu
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
Vũ Gia Vương
dap-hu
Commits
296dfde1
Commit
296dfde1
authored
Apr 28, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update slot when beat
parent
73822ca3
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
439 additions
and
377 deletions
+439
-377
main.fire
assets/main.fire
+380
-366
Events.ts
assets/scripts/Events.ts
+2
-1
BreakingJarController.ts
assets/scripts/GamePlay/BreakingJarController.ts
+6
-6
FragmentJarController.ts
assets/scripts/GamePlay/FragmentJarController.ts
+13
-4
SlotController.ts
assets/scripts/GamePlay/SlotController.ts
+28
-0
SlotController.ts.meta
assets/scripts/GamePlay/SlotController.ts.meta
+10
-0
No files found.
assets/main.fire
View file @
296dfde1
This diff is collapsed.
Click to expand it.
assets/scripts/Events.ts
View file @
296dfde1
...
...
@@ -27,3 +27,4 @@ export const HAMMER = 'HAMMER';
export
const
RESET_BOTTLE
=
'RESET_BOTTLE'
;
export
const
RESET_FRAGMENT
=
'RESET_FRAGMENT'
;
export
const
DROP_FRAGMENT
=
'DROP_FRAGMENT'
;
export
const
BEAT_FRAGMENT
=
'BEAT_FRAGMENT'
;
\ No newline at end of file
assets/scripts/GamePlay/BreakingJarController.ts
View file @
296dfde1
...
...
@@ -30,13 +30,13 @@ export default class BreakingJarController extends cc.Component {
onLoad
()
{
[
this
.
_BG
,
this
.
_behindJar
,
this
.
_frontJar
,
this
.
_slotsJar
]
=
this
.
node
.
children
;
this
.
_behindJarChild
=
this
.
_behindJar
.
children
;
this
.
_frontJarChild
=
this
.
_frontJar
.
children
;
this
.
_slotsJarChild
=
this
.
_slotsJar
.
children
;
//
this._behindJarChild = this._behindJar.children;
//
this._frontJarChild = this._frontJar.children;
//
this._slotsJarChild = this._slotsJar.children;
this
.
_slotsJarChild
.
forEach
((
slot
)
=>
{
slot
.
active
=
false
;
})
//
this._slotsJarChild.forEach((slot) => {
//
slot.active = false;
//
})
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
// cc.director.getPhysicsManager().debugDrawFlags = cc.PhysicsManager.DrawBits.e_aabbBit |
...
...
assets/scripts/GamePlay/FragmentJarController.ts
View file @
296dfde1
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
PLAY_DROP_SOUND
,
RESET_FRAGMENT
}
from
"../Events"
;
import
{
BEAT_FRAGMENT
,
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
PLAY_DROP_SOUND
,
RESET_FRAGMENT
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -8,6 +8,7 @@ export default class FragmentJarController extends cc.Component {
private
_rg
:
cc
.
RigidBody
=
null
;
private
_siblingIndex
:
number
=
0
;
private
_isDropped
:
boolean
=
false
;
private
_numberOfBeats
=
3
;
onLoad
()
{
this
.
_physicsCollider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
...
...
@@ -35,8 +36,16 @@ export default class FragmentJarController extends cc.Component {
const
pos
=
point
.
clone
().
subtract
(
cc
.
v2
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
));
let
isInside
=
cc
.
Intersection
.
pointInPolygon
(
pos
,
this
.
_physicsCollider
.
points
);
if
(
isInside
)
{
if
(
!
isInside
)
{
return
;
}
eventTarget
.
emit
(
BEAT_FRAGMENT
,
this
.
_siblingIndex
,
this
.
_numberOfBeats
);
this
.
_numberOfBeats
--
;
eventTarget
.
emit
(
HAMMER
,
point
);
if
(
this
.
_numberOfBeats
<=
0
)
{
this
.
dropFragment
();
}
}
...
...
@@ -44,7 +53,7 @@ export default class FragmentJarController extends cc.Component {
private
dropFragment
()
{
this
.
_isDropped
=
true
;
const
pos
=
this
.
node
.
position
;
this
.
node
.
setSiblingIndex
(
-
1
);
//
this.node.setSiblingIndex(-1);
eventTarget
.
emit
(
CHECK_FRAGMENT
,
this
.
node
.
name
);
cc
.
tween
(
this
.
node
)
...
...
assets/scripts/GamePlay/SlotController.ts
0 → 100644
View file @
296dfde1
import
{
BEAT_FRAGMENT
,
eventTarget
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
SlotController
extends
cc
.
Component
{
private
_slots
:
cc
.
Node
[][]
=
[];
protected
onLoad
():
void
{
this
.
_slots
=
this
.
node
.
children
.
map
(
fragment
=>
fragment
.
children
.
map
(
slot
=>
{
slot
.
active
=
false
;
return
slot
;
}));
console
.
log
(
'this._slots'
,
this
.
_slots
)
eventTarget
.
on
(
BEAT_FRAGMENT
,
this
.
onBeat
,
this
);
}
private
onBeat
(
fragmentIndex
:
number
,
beatIndex
:
number
):
void
{
if
(
3
-
beatIndex
>
1
)
{
this
.
_slots
[
fragmentIndex
].
map
(
slot
=>
slot
.
active
=
false
);
return
;
}
this
.
_slots
[
fragmentIndex
][
3
-
beatIndex
].
active
=
true
;
}
}
assets/scripts/GamePlay/SlotController.ts.meta
0 → 100644
View file @
296dfde1
{
"ver": "1.1.0",
"uuid": "2dadf33a-b19b-4abb-9a33-ec0d14e46375",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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