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
73822ca3
Commit
73822ca3
authored
Apr 28, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add script in break jar
parent
c742359e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6245 additions
and
6283 deletions
+6245
-6283
main.fire
assets/main.fire
+6141
-6278
BreakingJarController.ts
assets/scripts/GamePlay/BreakingJarController.ts
+102
-0
FragmentJarController.ts
assets/scripts/GamePlay/FragmentJarController.ts
+2
-5
No files found.
assets/main.fire
View file @
73822ca3
This diff is collapsed.
Click to expand it.
assets/scripts/GamePlay/BreakingJarController.ts
View file @
73822ca3
import
{
BEAT_GUILD
,
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
RESET_BOTTLE
,
RESET_FRAGMENT
,
SHOW_CARD_POPUP
,
STOP_GUILD_TAP
}
from
"../Events"
;
import
{
Global
}
from
"../Global"
;
import
FragmentJarController
from
"./FragmentJarController"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
@
ccclass
export
default
class
BreakingJarController
extends
cc
.
Component
{
export
default
class
BreakingJarController
extends
cc
.
Component
{
@
property
(
cc
.
Node
)
private
hammerNode
:
cc
.
Node
=
null
;
private
_spine
:
sp
.
Skeleton
=
null
;
private
_skins
=
[
"Ga"
,
"Gai_lung"
,
"Gay"
,
"Bua"
,];
private
_countFragment
=
0
;
private
_fragmentsPosition
:
cc
.
Vec3
[]
=
[];
private
_fragmentsNode
:
cc
.
Node
[]
=
[];
private
_bodyFragments
:
string
[]
=
[];
private
_isEnd
=
false
;
private
_BG
:
cc
.
Node
=
null
;
private
_BG
:
cc
.
Node
=
null
;
private
_behindJar
:
cc
.
Node
=
null
;
private
_behindJar
:
cc
.
Node
=
null
;
private
_frontJar
:
cc
.
Node
=
null
;
private
_frontJar
:
cc
.
Node
=
null
;
...
@@ -21,5 +37,91 @@ export default class BreakingJarController extends cc.Component {
...
@@ -21,5 +37,91 @@ export default class BreakingJarController extends cc.Component {
this
.
_slotsJarChild
.
forEach
((
slot
)
=>
{
this
.
_slotsJarChild
.
forEach
((
slot
)
=>
{
slot
.
active
=
false
;
slot
.
active
=
false
;
})
})
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
// cc.director.getPhysicsManager().debugDrawFlags = cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_jointBit |
// cc.PhysicsManager.DrawBits.e_shapeBit;
this
.
_spine
=
this
.
hammerNode
.
getComponentInChildren
(
sp
.
Skeleton
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
eventTarget
.
on
(
CHECK_FRAGMENT
,
this
.
checkFragment
,
this
);
eventTarget
.
on
(
HAMMER
,
this
.
onHammer
,
this
);
eventTarget
.
on
(
RESET_BOTTLE
,
this
.
resetBottle
,
this
);
eventTarget
.
on
(
BEAT_GUILD
,
this
.
beatGuild
,
this
);
this
.
_fragmentsNode
=
this
.
getComponentsInChildren
(
FragmentJarController
).
map
(
item
=>
item
.
node
);
this
.
_fragmentsPosition
=
this
.
_fragmentsNode
.
map
(
item
=>
item
.
position
.
clone
());
}
private
beatGuild
()
{
// this.onHammer(cc.v2(100));
}
protected
start
():
void
{
this
.
resetHammer
();
}
private
resetBottle
()
{
this
.
_countFragment
=
0
;
this
.
_bodyFragments
=
[];
this
.
_spine
.
setSkin
(
this
.
_skins
[
Global
.
tool
%
this
.
_skins
.
length
]);
this
.
_fragmentsNode
.
forEach
((
node
,
index
)
=>
{
node
.
position
=
this
.
_fragmentsPosition
[
index
];
})
eventTarget
.
emit
(
RESET_FRAGMENT
);
this
.
_isEnd
=
false
;
}
private
onHammer
(
newPos
:
cc
.
Vec2
)
{
cc
.
Tween
.
stopAllByTarget
(
this
.
hammerNode
);
this
.
_spine
.
setAnimation
(
0
,
"Dap4"
,
false
);
this
.
hammerNode
.
active
=
true
;
cc
.
tween
(
this
.
hammerNode
)
.
to
(
0.5
,
{
position
:
cc
.
v3
(
newPos
.
x
,
newPos
.
y
,
0
)
})
.
delay
(
0.3
)
.
to
(
0.3
,
{
position
:
cc
.
v3
(
400
,
-
400
)
})
.
call
(()
=>
this
.
hammerNode
.
active
=
false
)
.
start
();
}
private
checkFragment
(
name
:
string
)
{
if
(
this
.
_isEnd
)
{
return
;
}
if
(
!
name
.
includes
(
'nap'
))
{
this
.
_bodyFragments
.
push
(
name
);
}
this
.
_countFragment
++
;
if
(
this
.
_countFragment
==
8
)
{
this
.
scheduleOnce
(()
=>
eventTarget
.
emit
(
SHOW_CARD_POPUP
),
1.5
);
this
.
_isEnd
=
true
;
}
if
(
this
.
_bodyFragments
.
length
==
6
)
{
eventTarget
.
emit
(
DROP_FRAGMENT
);
}
}
private
onTouchStart
(
event
:
cc
.
Event
.
EventTouch
)
{
eventTarget
.
emit
(
STOP_GUILD_TAP
);
const
pos
=
event
.
getLocation
();
const
nodePos
=
this
.
node
.
convertToNodeSpaceAR
(
pos
);
eventTarget
.
emit
(
CHECK_TOUCH
,
nodePos
);
this
.
_spine
.
setSkin
(
this
.
_skins
[
Global
.
tool
%
this
.
_skins
.
length
]);
}
private
onTouchEnd
(
event
:
cc
.
Event
.
EventTouch
)
{
}
private
resetHammer
()
{
this
.
hammerNode
.
position
=
cc
.
v3
(
300
);
this
.
hammerNode
.
active
=
false
;
}
}
}
}
assets/scripts/GamePlay/FragmentJarController.ts
View file @
73822ca3
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
PLAY_DROP_SOUND
,
RESET_FRAGMENT
}
from
"../Events"
;
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
DROP_FRAGMENT
,
eventTarget
,
HAMMER
,
PLAY_DROP_SOUND
,
RESET_FRAGMENT
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
@
ccclass
export
default
class
FragmentJarController
extends
cc
.
Component
{
export
default
class
FragmentJarController
extends
cc
.
Component
{
private
_collider
:
cc
.
PolygonCollider
=
null
;
private
_physicsCollider
:
cc
.
PhysicsPolygonCollider
=
null
;
private
_physicsCollider
:
cc
.
PhysicsPolygonCollider
=
null
;
private
_rg
:
cc
.
RigidBody
=
null
;
private
_rg
:
cc
.
RigidBody
=
null
;
private
_siblingIndex
:
number
=
0
;
private
_siblingIndex
:
number
=
0
;
private
_isDropped
:
boolean
=
false
;
private
_isDropped
:
boolean
=
false
;
onLoad
()
{
onLoad
()
{
this
.
_collider
=
this
.
node
.
getComponent
(
cc
.
PolygonCollider
);
this
.
_physicsCollider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
this
.
_physicsCollider
=
this
.
node
.
getComponent
(
cc
.
PhysicsPolygonCollider
);
this
.
_physicsCollider
.
points
=
this
.
_collider
.
points
;
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
_siblingIndex
=
this
.
node
.
getSiblingIndex
();
this
.
_siblingIndex
=
this
.
node
.
getSiblingIndex
();
this
.
reset
();
this
.
reset
();
...
@@ -37,7 +34,7 @@ export default class FragmentJarController extends cc.Component {
...
@@ -37,7 +34,7 @@ export default class FragmentJarController extends cc.Component {
}
}
const
pos
=
point
.
clone
().
subtract
(
cc
.
v2
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
));
const
pos
=
point
.
clone
().
subtract
(
cc
.
v2
(
this
.
node
.
position
.
x
,
this
.
node
.
position
.
y
));
let
isInside
=
cc
.
Intersection
.
pointInPolygon
(
pos
,
this
.
_
c
ollider
.
points
);
let
isInside
=
cc
.
Intersection
.
pointInPolygon
(
pos
,
this
.
_
physicsC
ollider
.
points
);
if
(
isInside
)
{
if
(
isInside
)
{
eventTarget
.
emit
(
HAMMER
,
point
);
eventTarget
.
emit
(
HAMMER
,
point
);
this
.
dropFragment
();
this
.
dropFragment
();
...
...
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