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
328daa85
Commit
328daa85
authored
Apr 02, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix BreakingBottleController, add reset bottle
parent
5fabb20b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3726 additions
and
4033 deletions
+3726
-4033
main.fire
assets/main.fire
+3685
-4008
Events.ts
assets/scripts/Events.ts
+2
-1
BreakingBottleController.ts
assets/scripts/GamePlay/BreakingBottleController.ts
+23
-6
FragmentController.ts
assets/scripts/GamePlay/FragmentController.ts
+10
-2
BreakingBottleScreen.ts
assets/scripts/UI/BreakingBottleScreen.ts
+6
-16
No files found.
assets/main.fire
View file @
328daa85
This source diff could not be displayed because it is too large. You can
view the blob
instead.
assets/scripts/Events.ts
View file @
328daa85
...
@@ -23,4 +23,5 @@ export const STOP_GUILD_TAP = 'STOP_GUILD_TAP';
...
@@ -23,4 +23,5 @@ export const STOP_GUILD_TAP = 'STOP_GUILD_TAP';
export
const
CHECK_TOUCH
=
'CHECK_TOUCH'
;
export
const
CHECK_TOUCH
=
'CHECK_TOUCH'
;
export
const
CHECK_FRAGMENT
=
'CHECK_FRAGMENT'
;
export
const
CHECK_FRAGMENT
=
'CHECK_FRAGMENT'
;
export
const
HAMMER
=
'HAMMER'
;
export
const
HAMMER
=
'HAMMER'
;
\ No newline at end of file
export
const
RESET_BOTTLE
=
'RESET_BOTTLE'
;
\ No newline at end of file
assets/scripts/GamePlay/BreakingBottleController.ts
View file @
328daa85
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
eventTarget
,
HAMMER
}
from
"../Events"
;
import
{
CHECK_FRAGMENT
,
CHECK_TOUCH
,
eventTarget
,
HAMMER
,
RESET_BOTTLE
,
SHOW_CARD_POPUP
}
from
"../Events"
;
import
{
Global
}
from
"../Global"
;
import
{
Global
}
from
"../Global"
;
import
FragmentController
from
"./FragmentController"
;
import
FragmentController
from
"./FragmentController"
;
import
TheController
from
"./TheController"
;
import
TheController
from
"./TheController"
;
...
@@ -13,26 +13,44 @@ export default class BreakingBottleController extends cc.Component {
...
@@ -13,26 +13,44 @@ export default class BreakingBottleController extends cc.Component {
private
_spine
:
sp
.
Skeleton
=
null
;
private
_spine
:
sp
.
Skeleton
=
null
;
private
_skins
=
[
"Ga"
,
"Gai_lung"
,
"Gay"
,
"Bua"
,];
private
_skins
=
[
"Ga"
,
"Gai_lung"
,
"Gay"
,
"Bua"
,];
private
_cardNode
:
cc
.
Node
=
null
;
private
_countFragment
=
0
;
private
_countFragment
=
0
;
private
_fragmentsPosition
:
cc
.
Vec3
[]
=
[];
private
_fragmentsNode
:
cc
.
Node
[]
=
[];
onLoad
()
{
onLoad
()
{
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
cc
.
director
.
getPhysicsManager
().
enabled
=
true
;
this
.
_spine
=
this
.
hammerNode
.
getComponentInChildren
(
sp
.
Skeleton
);
this
.
_spine
=
this
.
hammerNode
.
getComponentInChildren
(
sp
.
Skeleton
);
this
.
_cardNode
=
this
.
node
.
getComponentInChildren
(
TheController
).
node
;
this
.
_cardNode
.
active
=
false
;
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
eventTarget
.
on
(
CHECK_FRAGMENT
,
this
.
checkFragment
,
this
);
eventTarget
.
on
(
CHECK_FRAGMENT
,
this
.
checkFragment
,
this
);
eventTarget
.
on
(
HAMMER
,
this
.
onHammer
,
this
);
eventTarget
.
on
(
HAMMER
,
this
.
onHammer
,
this
);
eventTarget
.
on
(
RESET_BOTTLE
,
this
.
resetBottle
,
this
);
this
.
_fragmentsNode
=
this
.
getComponentsInChildren
(
FragmentController
).
map
(
item
=>
item
.
node
);
console
.
log
(
'this._fragmentsAll'
,
this
.
_fragmentsNode
)
this
.
_fragmentsPosition
=
this
.
_fragmentsNode
.
map
(
item
=>
item
.
position
.
clone
());
}
}
protected
start
():
void
{
protected
start
():
void
{
this
.
hideHammer
();
this
.
hideHammer
();
}
}
private
resetBottle
()
{
this
.
_countFragment
=
0
;
this
.
_spine
.
setSkin
(
this
.
_skins
[
Global
.
tool
%
this
.
_skins
.
length
]);
this
.
_spine
.
setAnimation
(
0
,
"Dap4"
,
false
);
this
.
_fragmentsNode
.
forEach
((
item
,
index
)
=>
{
item
.
position
=
this
.
_fragmentsPosition
[
index
];
item
.
getComponent
(
FragmentController
).
reset
();
})
}
private
onHammer
(
newPos
:
cc
.
Vec2
)
{
private
onHammer
(
newPos
:
cc
.
Vec2
)
{
cc
.
tween
(
this
.
hammerNode
)
cc
.
tween
(
this
.
hammerNode
)
.
to
(
0.1
,
{
opacity
:
255
,
position
:
cc
.
v3
(
newPos
.
x
,
newPos
.
y
)
})
.
to
(
0.1
,
{
opacity
:
255
,
position
:
cc
.
v3
(
newPos
.
x
,
newPos
.
y
)
})
...
@@ -44,14 +62,13 @@ export default class BreakingBottleController extends cc.Component {
...
@@ -44,14 +62,13 @@ export default class BreakingBottleController extends cc.Component {
private
checkFragment
(
name
:
string
)
{
private
checkFragment
(
name
:
string
)
{
this
.
_countFragment
++
;
this
.
_countFragment
++
;
if
(
this
.
_countFragment
==
8
)
{
if
(
this
.
_countFragment
==
8
)
{
this
.
_cardNode
.
active
=
true
;
eventTarget
.
emit
(
SHOW_CARD_POPUP
)
;
}
}
}
}
private
onTouchStart
(
event
:
cc
.
Event
.
EventTouch
)
{
private
onTouchStart
(
event
:
cc
.
Event
.
EventTouch
)
{
const
pos
=
event
.
getLocation
();
const
pos
=
event
.
getLocation
();
const
nodePos
=
this
.
node
.
convertToNodeSpaceAR
(
pos
);
const
nodePos
=
this
.
node
.
convertToNodeSpaceAR
(
pos
);
const
newPos
=
cc
.
v3
(
nodePos
.
x
,
nodePos
.
y
);
eventTarget
.
emit
(
CHECK_TOUCH
,
nodePos
);
eventTarget
.
emit
(
CHECK_TOUCH
,
nodePos
);
...
...
assets/scripts/GamePlay/FragmentController.ts
View file @
328daa85
...
@@ -9,18 +9,26 @@ export default class FragmentController extends cc.Component {
...
@@ -9,18 +9,26 @@ export default class FragmentController extends cc.Component {
private
_collider
:
cc
.
PolygonCollider
=
null
;
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
;
onLoad
()
{
onLoad
()
{
this
.
_collider
=
this
.
node
.
getComponent
(
cc
.
PolygonCollider
);
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
.
_physicsCollider
.
points
=
this
.
_collider
.
points
;
this
.
_physicsCollider
.
enabled
=
false
;
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
_rg
=
this
.
node
.
getComponent
(
cc
.
RigidBody
);
this
.
_rg
.
type
=
cc
.
RigidBodyType
.
Static
;
this
.
_siblingIndex
=
this
.
node
.
getSiblingIndex
();
this
.
reset
();
eventTarget
.
on
(
CHECK_TOUCH
,
this
.
checkTouch
,
this
);
eventTarget
.
on
(
CHECK_TOUCH
,
this
.
checkTouch
,
this
);
}
}
public
reset
()
{
this
.
_physicsCollider
.
enabled
=
false
;
this
.
_rg
.
type
=
cc
.
RigidBodyType
.
Static
;
this
.
node
.
angle
=
0
;
this
.
node
.
setSiblingIndex
(
this
.
_siblingIndex
);
}
private
checkTouch
(
point
:
cc
.
Vec2
)
{
private
checkTouch
(
point
:
cc
.
Vec2
)
{
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
));
...
...
assets/scripts/UI/BreakingBottleScreen.ts
View file @
328daa85
import
{
eventTarget
,
SHOW_ACTION_SCREEN
,
SHOW_START_SCREEN
}
from
"../Events"
;
import
{
eventTarget
,
RESET_BOTTLE
,
SHOW_ACTION_SCREEN
,
SHOW_START_SCREEN
}
from
"../Events"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -8,28 +8,18 @@ export default class BreakingBottleScreen extends cc.Component {
...
@@ -8,28 +8,18 @@ export default class BreakingBottleScreen extends cc.Component {
onLoad
()
{
onLoad
()
{
eventTarget
.
on
(
SHOW_ACTION_SCREEN
,
this
.
showScreen
,
this
);
eventTarget
.
on
(
SHOW_ACTION_SCREEN
,
this
.
showScreen
,
this
);
eventTarget
.
on
(
SHOW_START_SCREEN
,
this
.
hideScreen
,
this
);
eventTarget
.
on
(
SHOW_START_SCREEN
,
this
.
hideScreen
,
this
);
// this.node.position = cc.v3(400, 600, 0);
this
.
node
.
position
=
cc
.
v3
(
0
,
0
,
0
);
}
this
.
node
.
opacity
=
0
;
private
hideBottle
()
{
// this.bottleAction.active = true;
// this.bottleIdle.active = false;
}
}
private
showScreen
()
{
private
showScreen
()
{
console
.
log
(
'showScreen'
,
this
.
node
)
this
.
node
.
opacity
=
255
;
// this.bottleAction.active = false;
// this.bottleIdle.active = true;
// this._spine.setAnimation(0, 'Idle', true);
// this._buaController.onSetTool();
this
.
node
.
active
=
true
;
this
.
node
.
position
=
cc
.
v3
();
this
.
node
.
position
=
cc
.
v3
();
eventTarget
.
emit
(
RESET_BOTTLE
);
}
}
private
hideScreen
()
{
private
hideScreen
()
{
this
.
node
.
active
=
false
;
this
.
node
.
opacity
=
0
;
}
}
}
}
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