Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-demo
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
等吃饭
game-demo
Commits
482fc052
Commit
482fc052
authored
Feb 14, 2023
by
Friends233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
cdbbdef6
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
14 additions
and
1637 deletions
+14
-1637
Game.ts
src/Game.ts
+1
-1
IndexScene.ts
src/scenes/IndexScene.ts
+12
-170
Box.ts
src/scenes/Jump3D/Box.ts
+0
-157
Jump3d.ts
src/scenes/Jump3D/Jump3d.ts
+0
-358
MT.ts
src/scenes/Jump3D/MT.ts
+0
-285
MusicBtn.ts
src/scenes/Jump3D/MusicBtn.ts
+0
-52
Particle.ts
src/scenes/Jump3D/Particle.ts
+0
-106
PlayScene.ts
src/scenes/Jump3D/PlayScene.ts
+0
-142
Player.ts
src/scenes/Jump3D/Player.ts
+0
-189
TorusGeometry.ts
src/scenes/Jump3D/TorusGeometry.ts
+0
-87
yarn.lock
yarn.lock
+1
-90
No files found.
src/Game.ts
View file @
482fc052
...
@@ -118,7 +118,7 @@ export class Game {
...
@@ -118,7 +118,7 @@ export class Game {
Texture
.
fromUrl
(
"https://yun.duiba.com.cn/aurora/assets/a6903842083d8015e2e81d2dc652370574be6774.jpg"
),
Texture
.
fromUrl
(
"https://yun.duiba.com.cn/aurora/assets/a6903842083d8015e2e81d2dc652370574be6774.jpg"
),
]);
]);
MusicBtn
.
changeMusicStatus
(
true
);
/// TODO 进游戏打开音乐先
//
MusicBtn.changeMusicStatus(true); /// TODO 进游戏打开音乐先
changeScene
(
IndexScene
,
{
from
:
"main"
});
changeScene
(
IndexScene
,
{
from
:
"main"
});
}
}
...
...
src/scenes/IndexScene.ts
View file @
482fc052
...
@@ -14,176 +14,18 @@ import Texture = FYGE.Texture;
...
@@ -14,176 +14,18 @@ import Texture = FYGE.Texture;
export
class
IndexScene
extends
Scene
{
export
class
IndexScene
extends
Scene
{
prizeBtn
:
Button
;
get
groupNames
():
string
[]
{
taskBtn
:
Button
;
return
[
ruleBtn
:
Button
;
'index'
,
rankBtn
:
Button
;
]
startBtn
:
Button
;
}
paper
:
Sprite
;
async
initUi
()
{
UI
.
Sp
(
this
,
Texture
.
from
(
'com_bg.jpg'
))
}
timeLabel
:
TextField
;
destroy
()
{
super
.
destroy
();
}
progress
:
IndexProgress
;
}
\ No newline at end of file
get
groupNames
():
string
[]
{
return
[
'index'
,
]
}
async
initUi
()
{
this
.
paper
=
this
.
addChild
(
Sprite
.
fromUrl
(
"https://yun.duiba.com.cn/aurora/assets/70c7fdc45ed8139bdc0a23ac004facc07abf3cfd.jpg"
));
this
.
progress
=
this
.
addChild
(
new
IndexProgress
({
value
:
5200000
}));
this
.
progress
.
y
=
1050
;
// 排行榜
this
.
rankBtn
=
UI
.
Btn
(
this
,
"rankBtn.png"
,
this
.
clickBtn
,
this
,
652
,
450
);
this
.
rankBtn
.
anchorX
=
98
;
// 任务
this
.
taskBtn
=
UI
.
Btn
(
this
,
"taskBtn.png"
,
this
.
clickBtn
,
this
,
599
,
388
);
this
.
taskBtn
.
anchorX
=
151
;
// 我的奖品
this
.
prizeBtn
=
UI
.
Btn
(
this
,
"prizeBtn.png"
,
this
.
clickBtn
,
this
,
0
,
392
);
this
.
prizeBtn
.
anchorX
=
0
;
// 规则
this
.
ruleBtn
=
UI
.
Btn
(
this
,
"ruleBtn.png"
,
this
.
clickBtn
,
this
,
0
,
453
);
this
.
ruleBtn
.
anchorX
=
0
;
// 开始游戏
this
.
startBtn
=
UI
.
Btn
(
this
,
"startBtn.png"
,
this
.
startGame
,
this
,
128
,
1244
);
UI
.
Sp
(
this
.
startBtn
,
"btnTipBg.png"
,
426
,
-
13
);
this
.
timeLabel
=
UI
.
Txt
(
this
.
startBtn
,
`剩余次数:
${
3
}
`
,
20
,
"#ffffff"
,
TEXT_ALIGN
.
CENTER
,
147
,
426
,
-
13
);
this
.
timeLabel
.
textHeight
=
36
;
this
.
timeLabel
.
verticalAlign
=
VERTICAL_ALIGN
.
MIDDLE
;
UI
.
Txt
(
this
,
`单局奇迹值达520分\t\t必得「甜蜜福利」\t发完即止`
,
22
,
"#ffa8d0"
,
TEXT_ALIGN
.
CENTER
,
750
,
0
,
1376
);
}
destroy
()
{
super
.
destroy
();
}
async
start
()
{
super
.
start
();
this
.
paper
.
texture
=
Texture
.
fromUrl
(
"https://yun.duiba.com.cn/aurora/assets/a6903842083d8015e2e81d2dc652370574be6774.jpg"
);
this
.
progress
.
value
=
3000000
;
this
.
timeLabel
.
text
=
`剩余次数:3`
;
}
async
startGame
(
e
)
{
this
.
btnDelay
(
e
.
target
);
changeScene
(
LoadingScene
);
}
private
async
clickBtn
(
e
)
{
this
.
btnDelay
(
e
.
target
);
}
}
class
IndexProgress
extends
Container
{
constructor
(
data
:
{
value
:
number
})
{
super
();
this
.
init
();
this
.
value
=
data
.
value
;
}
private
_value
:
number
=
0
;
public
get
value
():
number
{
return
this
.
_value
;
}
public
set
value
(
value
:
number
)
{
this
.
_value
=
value
;
this
.
miracleTxt
.
text
=
`当前总奇迹值:
${
value
}
`
;
switch
(
true
)
{
case
(
value
<=
5.2
*
10000
):
// 5.2万以下
this
.
fill
.
mask
.
x
=
80
*
value
/
52000
+
72
-
608
;
break
;
case
(
value
<=
52
*
10000
):
// 5.2万 - 52万
this
.
fill
.
mask
.
x
=
160
*
value
/
520000
+
72
-
608
+
80
;
break
;
case
(
value
<=
520
*
10000
):
// 52万 - 520万
this
.
fill
.
mask
.
x
=
304
*
value
/
5200000
+
72
-
608
+
80
+
160
;
break
;
case
(
value
>
520
*
10000
):
// 520万以上
this
.
fill
.
mask
.
x
=
72
;
break
;
}
}
miracleTxt
:
TextField
;
fill
:
Sprite
;
init
()
{
UI
.
Sp
(
this
,
"progressBg.png"
);
this
.
fill
=
UI
.
Sp
(
this
,
"progressFill.png"
);
this
.
fill
.
position
.
set
(
69
,
79
);
const
mask
=
this
.
addChild
(
new
Shape
());
mask
.
beginFill
(
0xff0000
);
mask
.
drawRoundedRect
(
0
,
0
,
608
,
25
,
10
,
10
,
10
,
10
);
mask
.
endFill
();
mask
.
position
.
set
(
73
,
74
);
this
.
fill
.
mask
=
mask
;
this
.
addChild
(
new
ProgressLabel
(
"5.2万"
)).
position
.
set
(
102
,
72
);
this
.
addChild
(
new
ProgressLabel
(
"52万"
)).
position
.
set
(
264
,
72
);
this
.
addChild
(
new
ProgressLabel
(
"520万"
)).
position
.
set
(
564
,
72
);
this
.
miracleTxt
=
UI
.
Txt
(
this
,
`当前总奇迹值:0`
,
24
,
"#ffffff"
,
TEXT_ALIGN
.
CENTER
,
750
,
0
,
39
);
UI
.
Txt
(
this
,
`当奇迹值达到520万时,将于519当天揭秘时尚运动代言人`
,
22
,
"#ffffff"
,
TEXT_ALIGN
.
CENTER
,
750
,
0
,
119
);
}
}
class
ProgressLabel
extends
Container
{
constructor
(
label
:
string
)
{
super
();
UI
.
Sp
(
this
,
"progressLabel.png"
);
const
text
=
UI
.
Txt
(
this
,
label
,
22
,
"#000000"
,
TEXT_ALIGN
.
CENTER
,
87
,
0
,
1.45
);
text
.
textHeight
=
31
;
text
.
verticalAlign
=
VERTICAL_ALIGN
.
MIDDLE
;
}
}
src/scenes/Jump3D/Box.ts
deleted
100644 → 0
View file @
cdbbdef6
/*
* Box.ts
* Created by 还有醋v on 2021/4/13.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import
BaseMaterial
=
FYGE
.
BaseMaterial
;
import
CircleGeometry
=
FYGE
.
CircleGeometry
;
import
Mesh3D
=
FYGE
.
Mesh3D
;
import
Object3D
=
FYGE
.
Object3D
;
import
PlaneGeometry
=
FYGE
.
PlaneGeometry
;
import
Vector2
=
FYGE
.
Vector2
;
import
{
BoxType
,
getBoxConfig
,
M_loadGLB
,
TestFun
,
typeArr
}
from
"./MT"
;
/**
* IOutAreaData
* @param out 0 在外 1 在内 2 加分
* @param verFall? 是否直接垂直掉落,超过边界一定值则为true,则需是直接垂直掉落
* @param fallDir? 掉落方向:-1 向负方向 1 向正方形
* @param fallAxis? 掉落轴:"x" | "z"
*/
export
interface
IOutAreaData
{
out
:
0
|
1
|
2
,
verFall
?:
boolean
,
fallDir
?:
-
1
|
1
,
fallAxis
?:
"x"
|
"z"
}
/**
* Box
*/
export
default
class
Box
extends
Object3D
{
mesh
:
Object3D
;
point
:
Object3D
;
constructor
(
public
type
?:
BoxType
)
{
super
();
if
(
!
type
)
{
this
.
type
=
typeArr
[
Math
.
random
()
*
typeArr
.
length
>>
0
];
// this.type = BoxType.TennisBarrel;
}
// this.type = BoxType.ChocolateShop;
this
.
init
();
}
async
init
()
{
const
{
ow
,
oz
,
ir
,
dx
,
dz
,
src
,
testFun
}
=
getBoxConfig
(
this
.
type
);
this
.
point
=
this
.
addChild
(
new
Mesh3D
(
new
CircleGeometry
(
ir
,
25
,
25
),
new
BaseMaterial
({
color
:
0xaaaaaa
,
alpha
:
0.8
})
));
this
.
point
.
y
=
0.65
;
this
.
point
.
rotationX
=
-
90
;
this
.
point
.
visible
=
false
;
this
.
mesh
=
await
M_loadGLB
(
src
);
this
.
addChild
(
this
.
mesh
);
this
.
mesh
.
children
[
0
].
position
.
set
(
0
,
0
,
0
);
if
(
this
.
type
==
BoxType
.
ChocolateShop
){
this
.
mesh
.
children
[
0
].
position
.
set
(
53.5
,
80
,
59
);
}
else
if
(
this
.
type
==
BoxType
.
TennisBarrel
){
this
.
mesh
.
children
[
0
].
position
.
set
(
6.5
,
36
,
16
);
}
// this.useShadow(this.mesh);
this
.
mesh
.
x
+=
dx
;
this
.
mesh
.
z
+=
dz
;
/// TODO Test
if
(
false
)
{
// this.addChild(new AxesHelper(1000));
const
geoP
=
new
PlaneGeometry
(
ow
,
oz
);
const
geoC
=
new
CircleGeometry
(
ow
,
25
,
25
);
// 落地范围
const
meshOut
=
this
.
addChild
(
new
Mesh3D
(
testFun
==
"rect"
?
geoP
:
geoC
,
new
BaseMaterial
({
color
:
0xff0000
,
alpha
:
0.8
})
));
meshOut
.
y
=
0.66
;
meshOut
.
rotationX
=
-
90
;
// 加分点
const
meshIn
=
this
.
addChild
(
new
Mesh3D
(
new
CircleGeometry
(
ir
,
25
,
25
),
new
BaseMaterial
({
color
:
0x00ff00
,
alpha
:
0.8
})
));
meshIn
.
y
=
0.66
;
meshIn
.
rotationX
=
-
90
;
}
}
useShadow
(
v
:
Object3D
)
{
this
.
mesh
.
castShadow
=
true
;
this
.
mesh
.
receiveShadow
=
true
;
v
.
children
.
forEach
(
v
=>
{
v
.
castShadow
=
true
;
v
.
receiveShadow
=
true
;
v
.
children
&&
this
.
useShadow
(
v
);
});
}
outArea
(
px
:
number
,
pz
:
number
):
IOutAreaData
{
// px, pz 别人的x和z
const
{
x
:
tx
,
z
:
tz
}
=
this
;
// 自己的x,z
// ow oz 外圈,超过即掉出
// ir 内圈半径,在里面则双倍得分
// testFun 检测函数
const
{
ow
,
oz
,
ir
,
testFun
}
=
getBoxConfig
(
this
.
type
);
const
p
=
new
Vector2
(
px
,
pz
);
const
t
=
new
Vector2
(
tx
,
tz
);
// 检查外圈 直接不管多余的参数了,js管个p
let
testOut
=
TestFun
[
testFun
](
p
,
t
,
ow
,
oz
);
// 外圈外返回0
if
(
!
testOut
)
{
// 圈外计算超出范围是多少,负的是超过,正的是没到
const
dv
=
new
Vector2
().
copy
(
p
).
sub
(
t
);
const
pd
=
0.1
;
// 超出这个距离为直落地,否则为摔落
let
d
:
number
,
fallAxis
:
"x"
|
"z"
;
// 其中有一个值必为0
if
(
dv
.
x
!=
0
)
{
d
=
Math
.
abs
(
dv
.
x
)
-
ow
/
2
;
fallAxis
=
"x"
;
}
else
{
d
=
Math
.
abs
(
dv
.
y
)
-
oz
/
2
;
fallAxis
=
"z"
;
}
return
{
out
:
0
,
verFall
:
d
>=
pd
,
fallDir
:
(
dv
.
x
+
dv
.
y
)
>
0
?
1
:
-
1
,
fallAxis
};
}
// 检查内圈
// 内圈内返回2
const
testIn
=
TestFun
.
circle
(
p
,
t
,
ir
);
return
{
out
:
testIn
?
2
:
1
};
}
}
src/scenes/Jump3D/Jump3d.ts
deleted
100644 → 0
View file @
cdbbdef6
import
{
GTool
}
from
"../../../module/tools/GTool"
;
import
Box
,
{
IOutAreaData
}
from
"./Box"
;
import
{
BoxType
,
getBoxConfig
,
getBoxType
,
typeArr
}
from
"./MT"
;
import
ParticleEmitter
from
"./Particle"
;
import
Player
,
{
Direction
}
from
"./Player"
;
import
{
GameEvent
}
from
"./PlayScene"
;
import
AmbientLight
=
FYGE
.
AmbientLight
;
import
Ease
=
FYGE
.
Ease
;
import
Event
=
FYGE
.
Event
;
import
MouseEvent
=
FYGE
.
MouseEvent
;
import
Scene3D
=
FYGE
.
Scene3D
;
import
Tween
=
FYGE
.
Tween
;
import
Vector3
=
FYGE
.
Vector3
;
const
cameraPos
=
new
Vector3
(
5.5
,
3.6
,
5.2
);
export
class
Jump3d
extends
Scene3D
{
public
player
:
Player
;
private
cacheBox
=
{
[
BoxType
.
Cinema
]:
[],
[
BoxType
.
Cube1
]:
[],
[
BoxType
.
Cube2
]:
[],
[
BoxType
.
ChocolateShop
]:
[],
[
BoxType
.
TennisCourt
]:
[],
[
BoxType
.
TennisBarrel
]:
[],
[
BoxType
.
FlowerShop
]:
[],
[
BoxType
.
FILAShop
]:
[],
[
BoxType
.
Logo1
]:
[],
[
BoxType
.
Logo2
]:
[],
};
// 盒子对象池
private
curBox
:
Box
;
// 当前盒子
private
nextBox
:
Box
;
// 下一个盒子
private
canMove
:
boolean
=
false
;
// 是否可移动
/**
* 跳跃方向
*/
private
direction
:
Direction
=
Direction
.
right
;
/**
* 可能要被移除的物体,待回收的物体
*/
private
outBox
=
[];
private
pushParticle
:
ParticleEmitter
;
private
pushObj
:
{
c
:
number
}
=
{
c
:
0
};
// 蓄力
private
bonusScore
:
number
=
0
;
// 连续加分计数
// 停留加分的Tween
private
specialBonusTween
:
Tween
=
Tween
.
get
({});
// private dirLight: DirectionalLight;
// private plane: Mesh3D;
constructor
()
{
super
();
this
.
initScene
();
this
.
addEvents
();
this
.
reset
();
}
setView
(
x
,
y
,
w
,
h
)
{
this
.
viewX
=
x
;
this
.
viewY
=
y
;
this
.
viewWidth
=
w
;
//视窗宽度
this
.
viewHeight
=
h
;
//视窗高度
//@ts-ignore
this
.
camera
.
set
(
undefined
,
w
/
h
,
0.1
,
1000.00
);
}
async
reset
()
{
// 回收所有的方块
for
(
let
i
=
this
.
outBox
.
length
-
1
;
i
>=
0
;
i
--
)
{
let
r
=
this
.
outBox
[
i
];
this
.
removeChild
(
r
);
this
.
cacheBox
[
r
.
type
].
push
(
r
);
}
this
.
outBox
.
length
=
0
;
// 回收当前方块
if
(
this
.
curBox
)
{
this
.
removeChild
(
this
.
curBox
);
this
.
cacheBox
[
this
.
curBox
.
type
].
push
(
this
.
curBox
);
}
if
(
this
.
nextBox
)
{
this
.
removeChild
(
this
.
nextBox
);
this
.
cacheBox
[
this
.
nextBox
.
type
].
push
(
this
.
nextBox
);
}
this
.
pushObj
=
{
c
:
0
};
// 蓄力
this
.
bonusScore
=
0
;
// 连续加分计数
// 初始化Box
this
.
curBox
=
this
.
addChild
(
new
Box
(
BoxType
.
Logo2
));
this
.
curBox
.
position
.
set
(
0
,
0
,
0
);
this
.
nextBox
=
this
.
addChild
(
new
Box
(
BoxType
.
Cinema
));
this
.
nextBox
.
position
.
set
(
0
,
0
,
-
1.7
);
this
.
direction
=
Direction
.
right
;
// 相机
this
.
camera
.
position
.
copy
(
cameraPos
);
this
.
moveCamera
(
0
/
2
,
-
1.7
/
2
);
// this.camera.lookAt(this.camera.x - cameraPos.x, 0, this.camera.z - cameraPos.z)
// this.camera.rotation.set(-0.76, 0.77, 0.59, 0);
await
this
.
player
.
reset
();
this
.
canMove
=
true
;
// 可以继续移动了
// 重制粒子位置和lookAt
this
.
pushParticle
.
position
.
copy
(
this
.
player
.
position
);
const
{
x
,
y
,
z
}
=
this
.
camera
.
position
;
this
.
pushParticle
.
lookAt
(
x
,
y
,
z
);
}
createBox
()
{
const
type
=
getBoxType
();
if
(
this
.
cacheBox
[
type
].
length
)
{
return
this
.
cacheBox
[
type
].
splice
(
0
,
1
)[
0
];
// return this.cacheBox.shift();
}
return
new
Box
(
type
);
}
private
initScene
()
{
// 每种盒子加一个
typeArr
.
forEach
((
type
:
BoxType
)
=>
{
this
.
cacheBox
[
type
].
push
(
new
Box
(
type
));
});
/// TODO 测试
// 手势移动相机,暂时只有旋转
// this.setOrbitControl({ enablePitch: false, autoRotate: false, userZoom: false, userRotateSpeed: 0.5 });//俯仰不可用
// this.setOrbitControl();
this
.
addChild
(
new
AmbientLight
(
0xffffff
,
1.0
));
// 坐标轴
// this.addChild(new AxesHelper(10000));
// 网格
// this.addChild(new GridHelper(20, 20, 0xffffff, 0x00000));
this
.
player
=
this
.
addChild
(
new
Player
());
this
.
pushParticle
=
this
.
addChild
(
new
ParticleEmitter
());
}
private
onUp
=
async
()
=>
{
this
.
pushParticle
.
stop
();
// 停止释放聚力粒子
this
.
nextBox
.
point
.
visible
=
false
;
// 隐藏加分点
Tween
.
removeTweens
(
this
.
pushObj
);
// console.log("jump:", this.pushObj.c);
// 计算起跳参数,位置,方向,距离
const
dis
=
7
*
this
.
pushObj
.
c
;
let
x
=
this
.
curBox
.
x
,
z
=
this
.
curBox
.
z
;
if
(
this
.
direction
==
Direction
.
left
)
{
x
-=
dis
;
}
else
{
z
-=
dis
;
}
await
this
.
jump
(
x
,
z
,
this
.
direction
);
// 跳完设置粒子位置
this
.
pushParticle
.
position
.
copy
(
this
.
player
.
position
);
const
{
x
:
px
,
z
:
pz
}
=
this
.
player
;
// 落在自己内
if
(
this
.
curBox
.
outArea
(
px
,
pz
).
out
>
0
)
{
this
.
canMove
=
true
;
// 可以继续移动了
return
;
}
//检查目标方块
const
outAreaNext
:
IOutAreaData
=
this
.
nextBox
.
outArea
(
px
,
pz
);
if
(
outAreaNext
.
out
==
0
)
{
// 在外, 死了
await
this
.
die
(
outAreaNext
);
}
else
{
// 在内
// 停留加分
const
score
=
getBoxConfig
(
this
.
nextBox
.
type
).
score
;
if
(
score
!=
0
)
{
this
.
specialBonusTween
=
Tween
.
get
({})
.
wait
(
2000
)
.
call
(()
=>
{
this
.
player
.
particleEmitter
.
startLanding
();
this
.
dispatchEvent
(
GameEvent
.
AddScore
,
{
add
:
score
});
});
}
// 释放玩家落到方块上到粒子
this
.
player
.
particleEmitter
.
startLanding
();
this
.
outBox
.
push
(
this
.
curBox
);
this
.
curBox
=
this
.
nextBox
;
let
x
=
this
.
curBox
.
x
,
z
=
this
.
curBox
.
z
;
let
cx
=
x
,
cz
=
z
;
const
dis
=
GTool
.
randomT
(
1.72
,
3.3
);
// const dis = 3.2//GTool.randomT(1.66, 2.6);
if
(
Math
.
random
()
>
0.5
)
{
this
.
direction
=
Direction
.
left
;
x
-=
dis
;
cx
-=
dis
/
2
;
}
else
{
this
.
direction
=
Direction
.
right
;
z
-=
dis
;
cz
-=
dis
/
2
;
}
this
.
nextBox
=
this
.
addRect
(
x
,
z
);
this
.
moveCamera
(
cx
,
cz
);
// TODO 加分范围内
if
(
outAreaNext
.
out
==
2
)
{
this
.
player
.
doubleEffect
(
++
this
.
bonusScore
);
this
.
dispatchEvent
(
GameEvent
.
AddScore
,
{
add
:
this
.
bonusScore
+
4
});
}
else
{
this
.
bonusScore
=
0
;
this
.
dispatchEvent
(
GameEvent
.
AddScore
,
{
add
:
1
});
}
this
.
canMove
=
true
;
// 可以继续移动了
}
}
onDown
=
()
=>
{
if
(
!
this
.
canMove
)
return
;
this
.
canMove
=
false
;
// 先禁止移动
Tween
.
removeTweenSelf
(
this
.
specialBonusTween
);
this
.
pushParticle
.
startPush
();
// 释放聚力粒子
this
.
nextBox
.
point
.
visible
=
true
;
// 显示加分点
this
.
pushObj
=
{
c
:
0
};
Tween
.
get
(
this
.
pushObj
,
{
onChange
:
()
=>
{
this
.
curBox
.
scaleY
=
1
-
this
.
pushObj
.
c
;
this
.
player
.
push
(
this
.
pushObj
.
c
);
}
})
.
to
({
c
:
0.65
},
1600
)
// TODO 变态难度就加上后面的参数 , Ease.quadInOut
.
call
(()
=>
{
console
.
log
(
"最大蓄力了"
);
});
/// TODO 测试
// document.addEventListener("keyup", this.onUp, { once: true });
this
.
once
(
MouseEvent
.
MOUSE_UP
,
this
.
onUp
);
}
private
addEvents
()
{
/// TODO 测试
// document.addEventListener("keydown", (e) => {
// if (e.code != "Space") return;
// this.onDown();
// });
this
.
addEventListener
(
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown
);
//循环
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onUpdate
,
this
);
}
/**
* 根据lookAt位置,移动相机,就是两个物体中间点就行
*/
private
moveCamera
(
x
:
number
,
z
:
number
)
{
const
camX
:
number
=
x
+
cameraPos
.
x
;
const
camZ
:
number
=
z
+
cameraPos
.
z
;
this
.
camera
.
y
=
cameraPos
.
y
;
Tween
.
get
(
this
.
camera
,
{
onChange
:
()
=>
{
const
{
x
,
y
,
z
}
=
this
.
camera
;
this
.
camera
.
lookAt
(
x
-
cameraPos
.
x
,
0
,
z
-
cameraPos
.
z
)
// this.plane.position.set(x - cameraPos.x, 0, z - cameraPos.z);
// this.dirLight.position.set(x - cameraPos.x + 20, 20, z - 10);
}
}).
to
({
x
:
camX
,
z
:
camZ
},
500
,
Ease
.
sineInOut
);
}
private
addRect
(
x
:
number
,
z
:
number
)
{
const
box
=
this
.
createBox
();
box
.
position
.
set
(
x
,
1
,
z
);
this
.
addChild
(
box
);
Tween
.
get
(
box
).
to
({
y
:
0
},
320
,
Ease
.
bounceOut
);
return
box
;
}
/**
* 跳
* @param x
* @param z
* @param d
* @private
*/
private
jump
(
x
:
number
,
z
:
number
,
d
:
Direction
)
{
return
new
Promise
((
resolve
)
=>
{
//恢复吧,或者缓动恢复
this
.
player
.
scaleY
=
1
;
//当前rect的恢复动画
Tween
.
get
(
this
.
curBox
).
to
({
scaleY
:
1
},
300
,
Ease
.
getBackOut
(
2.2
));
this
.
player
.
jump
(
x
,
z
).
then
(
resolve
);
//jump
this
.
player
.
rot
(
d
);
//旋转
});
}
/**
* 死
* @param oad
* @private
*/
private
async
die
(
oad
:
IOutAreaData
)
{
console
.
log
(
oad
,
"die"
);
await
this
.
player
.
fall
(
oad
,
800
);
this
.
dispatchEvent
(
GameEvent
.
GameOver
);
}
async
revive
():
Promise
<
void
>
{
await
this
.
player
.
revive
(
this
.
curBox
);
this
.
pushParticle
.
position
.
copy
(
this
.
player
.
position
);
this
.
canMove
=
true
;
// 复活后可以继续移动了
}
onUpdate
()
{
// 移除Rect
for
(
let
i
=
this
.
outBox
.
length
-
1
;
i
>=
0
;
i
--
)
{
let
r
=
this
.
outBox
[
i
];
let
x
=
this
.
curBox
.
x
,
z
=
this
.
curBox
.
z
;
if
(
r
.
x
>
x
+
8
||
r
.
z
>
z
+
8
)
{
this
.
outBox
.
splice
(
i
,
1
);
this
.
removeChild
(
r
);
this
.
cacheBox
[
r
.
type
].
push
(
r
);
}
}
}
}
src/scenes/Jump3D/MT.ts
deleted
100644 → 0
View file @
cdbbdef6
/*
* MT.ts
* Created by 还有醋v on 2021/4/13.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import
loadGltf
=
FYGE
.
loadGltf
;
import
{
showToast
}
from
"../../../module/ctrls"
;
import
Scene3D
=
FYGE
.
Scene3D
;
import
Vector2
=
FYGE
.
Vector2
;
/**
* glb缓存
*/
const
glbCache
:
{
[
key
:
string
]:
Scene3D
}
=
{};
function
getGlbFromCache
(
src
)
{
const
newScene
=
new
Scene3D
().
copy
(
glbCache
[
src
]);
newScene
.
scale
.
set
(
0.005
,
0.005
,
0.005
);
return
newScene
;
}
/**
* 加载glb模型,缓存里有会从缓存里取
* @param src
* @constructor
*/
export
async
function
M_loadGLB
(
src
):
Promise
<
Scene3D
>
{
return
new
Promise
((
resolve
)
=>
{
if
(
glbCache
[
src
])
{
// 缓存里有就从缓存里取
return
resolve
(
getGlbFromCache
(
src
));
}
loadGltf
(
src
,
(
r
)
=>
{
glbCache
[
src
]
=
r
.
scene
;
// 保存在Cache里
resolve
(
getGlbFromCache
(
src
));
},
(
e
)
=>
{
console
.
error
(
e
);
resolve
(
new
Scene3D
());
// 模型加载失败就返回个空场景,防止外面报错
showToast
(
"加载模型资源失败"
);
});
});
}
export
enum
BoxType
{
Cinema
=
"Cinema"
,
Cube1
=
"Cube1"
,
Cube2
=
"Cube2"
,
ChocolateShop
=
"ChocolateShop"
,
TennisCourt
=
"TennisCourt"
,
TennisBarrel
=
"TennisBarrel"
,
FlowerShop
=
"FlowerShop"
,
FILAShop
=
"FILAShop"
,
Logo1
=
"Logo1"
,
Logo2
=
"Logo2"
,
}
export
const
typeArr
:
BoxType
[]
=
[
BoxType
.
Cinema
,
BoxType
.
Cube1
,
BoxType
.
Cube2
,
BoxType
.
ChocolateShop
,
BoxType
.
TennisCourt
,
BoxType
.
TennisBarrel
,
BoxType
.
FlowerShop
,
BoxType
.
FILAShop
,
BoxType
.
Logo1
,
BoxType
.
Logo2
,
];
// 加分点范围
const
ir
=
0.06
;
export
const
GlobalConfig
:
{
playerConfig
:
{
src
:
string
,
tbsrc
:
string
},
boxConfig
:
{
[
key
in
BoxType
]:
{
src
:
string
,
tbsrc
:
string
,
ow
:
number
,
oz
:
number
,
dx
:
number
,
dz
:
number
,
ir
:
number
,
testFun
:
string
,
score
:
number
,
}
}
}
=
{
playerConfig
:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/80244821c29db4c619fe3f0c90d57132d149d9bf.glb"
,
tbsrc
:
"cloud://CEAE1CD8B6B8EAF842FD9754CF064639//棋子.glb"
,
},
boxConfig
:
{
[
BoxType
.
Cinema
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/ca66f10db4bb98c483a612c2196a2baccf68f9ba.glb"
,
tbsrc
:
"cloud://9C90F5DA62F3DD1FC7C8EB0657CB867D//电影院.glb"
,
ow
:
0.96
,
oz
:
0.94
,
dx
:
0.07
,
dz
:
0.02
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
[
BoxType
.
Cube1
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/660b0f9479686ee3efdbefea233d9cfec66573b1.glb"
,
tbsrc
:
"cloud://F672EE52A61F3CFEA2CD455EC3AC3920//立方体1.glb"
,
ow
:
0.83
,
oz
:
0.83
,
dx
:
0
,
dz
:
0
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
[
BoxType
.
Cube2
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/cc85f0cd4f030874e60966c891d30f79ef0be927.glb"
,
tbsrc
:
"cloud://78804605CF45221AD835915687B35908//立方体2.glb"
,
ow
:
0.87
,
oz
:
0.88
,
dx
:
0
,
dz
:
0
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
[
BoxType
.
ChocolateShop
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/f9fec8a8bcce73e23eb17b824eda33202daecf2f.glb"
,
tbsrc
:
"cloud://D60F1E52845A434408A338CE2037D53F//巧克力店.glb"
,
ow
:
0.65
,
oz
:
0.65
,
dx
:
0.01
,
dz
:
0.01
,
ir
:
ir
,
testFun
:
"circle"
,
score
:
0
,
},
[
BoxType
.
FlowerShop
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/0fcff8d4762f24f468d07f1671a5a8482b88ff41.glb"
,
tbsrc
:
"cloud://5F122FEF16478E0BBEBE63D7B0B71539//花店.glb"
,
ow
:
0.8
,
oz
:
0.91
,
dx
:
0.024
,
dz
:
-
0.031
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
[
BoxType
.
FILAShop
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/d4da10c0518b98a58c6bee9f720a6680fd726925.glb"
,
tbsrc
:
"cloud://4153569ADBB267C5C29A60A2076AF812//file店铺.glb"
,
ow
:
0.92
,
oz
:
1.18
,
dx
:
0
,
dz
:
0.02
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
15
,
},
[
BoxType
.
TennisCourt
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/1e556dbdb1e60a31f87d5e386f2a0a027fd90397.glb"
,
tbsrc
:
"cloud://73E2BDD33A55C202BBE979A93954E0F5//网球场.glb"
,
ow
:
1.2
,
oz
:
1.665
,
dx
:
0
,
dz
:
0
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
[
BoxType
.
TennisBarrel
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/a454a74ba50bc1d6801e510e9355be1de8ac8cda.glb"
,
tbsrc
:
"cloud://CDD8F47A6945FE70A0D15ABF36875356//网球桶.glb"
,
ow
:
0.35
,
oz
:
0.35
,
dx
:
0
,
dz
:
0
,
ir
:
ir
,
testFun
:
"circle"
,
score
:
0
,
},
[
BoxType
.
Logo1
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/74d4d08652acd570d5013226e80f22d0929c596c.glb"
,
tbsrc
:
"cloud://7920741060B24380DBE357505D146877//LOGO1.glb"
,
ow
:
0.84
,
oz
:
0.884
,
dx
:
-
0.09
,
dz
:
0.005
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
10
,
},
[
BoxType
.
Logo2
]:
{
src
:
"https://yun.duiba.com.cn/aurora/assets/00e19f936170dbe9b09eb5dcd2c47e476a9c271b.glb"
,
tbsrc
:
"cloud://92D7323E60199169EF79C8762BEC112A//logo2.glb"
,
ow
:
0.92
,
oz
:
0.92
,
dx
:
0
,
dz
:
0
,
ir
:
ir
,
testFun
:
"rect"
,
score
:
0
,
},
},
}
export
function
getBoxConfig
(
type
:
BoxType
)
{
const
config
=
GlobalConfig
.
boxConfig
[
type
];
if
(
FYGE
.
getEnv
()
==
'tb'
)
{
config
.
src
=
config
.
tbsrc
;
}
return
config
;
}
export
function
getPlayerConfig
()
{
const
config
=
GlobalConfig
.
playerConfig
;
if
(
FYGE
.
getEnv
()
==
'tb'
)
{
config
.
src
=
config
.
tbsrc
;
}
return
config
;
}
/**
* 检测点是否在内
*/
export
const
TestFun
=
{
/**
* 检测矩形
* @param p 点
* @param c 中心点
* @param w 宽度
* @param h 高度
*/
rect
:
function
(
p
:
Vector2
,
c
:
Vector2
,
w
:
number
,
h
:
number
):
boolean
{
const
pc
=
new
Vector2
().
copy
(
p
).
sub
(
c
);
return
!
(
Math
.
abs
(
pc
.
x
)
>
w
/
2
||
Math
.
abs
(
pc
.
y
)
>
h
/
2
);
},
/**
* 检测圆形
* @param p 点
* @param c 圆点
* @param r 半径
*/
circle
:
function
(
p
:
Vector2
,
c
:
Vector2
,
r
:
number
):
boolean
{
return
p
.
distanceTo
(
c
)
<=
r
;
}
}
const
probabilityConfig
:
{
key
:
BoxType
,
probability
:
number
}[]
=
[
{
key
:
BoxType
.
Cinema
,
probability
:
12
,
},
{
key
:
BoxType
.
Cube1
,
probability
:
13
,
},
{
key
:
BoxType
.
Cube2
,
probability
:
13
,
},
{
key
:
BoxType
.
ChocolateShop
,
probability
:
8
,
},
{
key
:
BoxType
.
FlowerShop
,
probability
:
12
,
},
{
key
:
BoxType
.
TennisCourt
,
probability
:
8
,
},
{
key
:
BoxType
.
TennisBarrel
,
probability
:
19
,
},
{
key
:
BoxType
.
FILAShop
,
probability
:
1
,
},
{
key
:
BoxType
.
Logo1
,
probability
:
2
,
},
{
key
:
BoxType
.
Logo2
,
probability
:
12
,
},
];
probabilityConfig
.
sort
((
a
,
b
)
=>
{
return
a
.
probability
-
b
.
probability
;
});
let
pTotal
=
0
;
probabilityConfig
.
forEach
((
v
)
=>
{
pTotal
=
(
v
.
probability
+=
pTotal
);
});
export
const
getBoxType
=
():
BoxType
=>
{
const
p
=
Math
.
random
()
*
pTotal
;
for
(
let
last
=
0
,
now
=
1
;
now
<
probabilityConfig
.
length
;
last
++
,
now
++
)
{
const
l
=
probabilityConfig
[
last
];
const
n
=
probabilityConfig
[
now
];
if
(
p
>
l
.
probability
&&
p
<=
n
.
probability
)
{
return
n
.
key
;
}
}
return
BoxType
.
Cinema
;
}
src/scenes/Jump3D/MusicBtn.ts
deleted
100644 → 0
View file @
cdbbdef6
/*
* MusicBtn.ts
* Created by 还有醋v on 2021/4/27.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import
Button
=
FYGE
.
Button
;
import
Container
=
FYGE
.
Container
;
import
Texture
=
FYGE
.
Texture
;
import
MouseEvent
=
FYGE
.
MouseEvent
;
export
default
class
MusicBtn
extends
Container
{
private
static
status
=
true
;
private
static
btns
:
MusicBtn
[]
=
[];
public
static
changeMusicStatus
(
status
:
boolean
)
{
MusicBtn
.
status
=
status
;
MusicBtn
.
btns
.
forEach
((
v
)
=>
{
v
.
btn
.
changeTexture
(
status
?
v
.
on
:
v
.
off
);
});
// sendTbNet(TbNetName.openMusic, { isOn: status });
}
private
btn
:
Button
;
constructor
(
private
on
:
Texture
,
private
off
:
Texture
)
{
super
();
this
.
btn
=
this
.
addChild
(
new
Button
(
MusicBtn
.
status
?
this
.
on
:
this
.
off
));
this
.
btn
.
addEventListener
(
MouseEvent
.
CLICK
,
MusicBtn
.
onClick
,
this
);
MusicBtn
.
btns
.
push
(
this
);
}
private
static
onClick
()
{
MusicBtn
.
changeMusicStatus
(
!
MusicBtn
.
status
);
}
destroy
()
{
super
.
destroy
();
MusicBtn
.
btns
.
splice
(
MusicBtn
.
btns
.
indexOf
(
this
),
1
);
this
.
btn
.
removeEventListener
(
MouseEvent
.
CLICK
,
MusicBtn
.
onClick
,
this
);
}
}
src/scenes/Jump3D/Particle.ts
deleted
100644 → 0
View file @
cdbbdef6
/*
* Particle.ts
* Created by 还有醋v on 2021/4/9.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import
{
GTool
}
from
"../../../module/tools/GTool"
;
import
Object3D
=
FYGE
.
Object3D
;
import
Mesh3D
=
FYGE
.
Mesh3D
;
import
CircleGeometry
=
FYGE
.
CircleGeometry
;
import
BaseMaterial
=
FYGE
.
BaseMaterial
;
import
Tween
=
FYGE
.
Tween
;
const
particleGeo
=
new
CircleGeometry
(
0.015
,
25
,
25
);
const
particleMatGreen
=
new
BaseMaterial
({
color
:
0x00ff00
});
const
particleMatWhite
=
new
BaseMaterial
({
color
:
0xffffff
});
/**
* 粒子
*/
class
Particle
extends
Mesh3D
{
constructor
()
{
super
(
particleGeo
,
particleMatWhite
);
}
}
/**
* 粒子发射器
*/
export
default
class
ParticleEmitter
extends
Object3D
{
particles
:
Particle
[]
=
[];
cacheParticles
:
Particle
[]
=
[];
constructor
()
{
super
();
}
private
startTween
;
startLanding
()
{
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
const
p
=
this
.
createParticle
();
p
.
position
.
set
(
GTool
.
randomT
(
-
0.3
,
0.3
),
GTool
.
randomT
(
-
1.5
,
0.5
),
GTool
.
randomT
(
-
0.3
,
0.3
)
);
p
.
material
=
particleMatWhite
;
this
.
particles
.
push
(
p
);
this
.
addChild
(
p
);
Tween
.
get
(
p
.
position
)
.
to
({
x
:
p
.
position
.
x
,
y
:
0.8
,
z
:
p
.
position
.
z
},
GTool
.
randomT
(
300
,
1000
))
.
call
(()
=>
{
this
.
removeChild
(
p
);
this
.
cacheParticles
.
push
(
p
);
});
}
setTimeout
(()
=>
{
this
.
stop
();
},
1800
);
}
startPush
()
{
this
.
startTween
=
Tween
.
get
(
this
,
{
loop
:
true
})
.
call
(()
=>
{
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
const
p
=
this
.
createParticle
();
const
rang
=
0.7
;
p
.
position
.
set
(
GTool
.
randomT
(
-
rang
,
rang
),
GTool
.
randomT
(
-
rang
,
rang
),
GTool
.
randomT
(
-
rang
,
rang
)
);
p
.
material
=
Math
.
random
()
<
0.3
?
particleMatGreen
:
particleMatWhite
;
this
.
particles
.
push
(
p
);
this
.
addChild
(
p
);
Tween
.
get
(
p
.
position
)
.
to
({
x
:
0
,
y
:
0
,
z
:
0
},
GTool
.
randomT
(
300
,
1800
))
.
call
(()
=>
{
this
.
removeChild
(
p
);
this
.
cacheParticles
.
push
(
p
);
});
}
})
.
wait
(
600
);
}
stop
()
{
Tween
.
removeTweens
(
this
);
this
.
particles
.
forEach
((
p
)
=>
{
this
.
removeChild
(
p
);
this
.
cacheParticles
.
push
(
p
);
Tween
.
removeTweens
(
p
.
position
);
});
this
.
particles
.
length
=
0
;
}
createParticle
():
Particle
{
if
(
this
.
cacheParticles
.
length
)
return
this
.
cacheParticles
.
shift
();
return
new
Particle
();
}
}
src/scenes/Jump3D/PlayScene.ts
deleted
100644 → 0
View file @
cdbbdef6
import
{
showPanel
}
from
"../../../module/ctrls"
;
import
{
RES
}
from
"../../../module/RES"
;
import
{
layers
}
from
"../../../module/views/layers"
;
import
{
Scene
}
from
"../../../module/views/Scene"
;
import
{
OverPrizePanel
}
from
"../../panels/OverPrizePanel"
;
import
{
RevivePanel
}
from
"../../panels/RevivePanel"
;
import
{
sleep
,
Tools
}
from
"../../tools/Tools"
;
import
UI
from
"../../tools/UI"
;
import
{
Jump3d
}
from
"./Jump3d"
;
import
MusicBtn
from
"./MusicBtn"
;
import
BitmapText
=
FYGE
.
BitmapText
;
import
TEXT_ALIGN
=
FYGE
.
TEXT_ALIGN
;
import
Tween
=
FYGE
.
Tween
;
import
Event
=
FYGE
.
Event
;
import
Ease
=
FYGE
.
Ease
;
export
enum
GameEvent
{
AddScore
=
"AddScore"
,
GameOver
=
"GameOver"
,
}
export
class
PlayScene
extends
Scene
{
get
groupNames
():
string
[]
{
return
[
"game"
];
}
scoreTxt
:
BitmapText
;
musicButton
:
MusicBtn
;
jump3d
:
Jump3d
;
addScoreLabel
:
BitmapText
;
private
_score
:
number
=
0
;
public
get
score
():
number
{
return
this
.
_score
;
}
public
set
score
(
score
:
number
)
{
this
.
_score
=
score
;
this
.
scoreTxt
.
text
=
score
+
''
;
}
async
initUi
()
{
UI
.
Sp
(
this
,
"com_bg.jpg"
);
// @ts-ignore
const
jump3d
:
Jump3d
=
this
.
jump3d
=
this
.
addChild
(
new
Jump3d
());
jump3d
.
setView
(
0
,
layers
.
stageOffsetY
,
layers
.
stageWidth
,
layers
.
stageHeight
);
jump3d
.
addEventListener
(
GameEvent
.
AddScore
,
this
.
addScore
,
this
);
jump3d
.
addEventListener
(
GameEvent
.
GameOver
,
this
.
gameOver
,
this
);
// 音乐按钮
this
.
musicButton
=
this
.
addChild
(
// new Button(RES.getRes("gameMusicOn.png"))
new
MusicBtn
(
RES
.
getRes
(
"gameMusicOn.png"
),
RES
.
getRes
(
"gameMusicOff.png"
))
);
// this.musicButton.position.set(636, layers.stageOffsetY + 265 * layers.stageOffsetY / 422);
this
.
musicButton
.
position
.
set
(
636
,
265
);
// 分数
const
txtObj
=
Tools
.
getNumTextures
(
'gameScore'
);
txtObj
[
"+"
]
=
RES
.
getRes
(
"gameScore+.png"
);
this
.
scoreTxt
=
UI
.
BitTxt
(
this
,
txtObj
,
"0"
,
65
,
305
,
0.5
,
0.5
);
this
.
scoreTxt
.
textAlign
=
TEXT_ALIGN
.
LEFT
;
// 加分
this
.
addScoreLabel
=
UI
.
BitTxt
(
this
,
txtObj
,
""
,
100
,
1000
,
0.5
,
0.5
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
()
=>
{
this
.
addScoreLabel
.
position
.
x
=
this
.
jump3d
.
player
.
stagePos
.
x
;
});
}
destroy
()
{
super
.
destroy
();
}
/**
* 加分
* @param e
*/
addScore
(
e
)
{
console
.
log
(
"加分"
,
e
.
data
);
this
.
score
+=
e
.
data
.
add
;
this
.
addScoreLabel
.
text
=
`+
${
e
.
data
.
add
}
`
;
const
_y
=
this
.
jump3d
.
player
.
stagePos
.
y
;
Tween
.
get
(
this
.
addScoreLabel
)
.
set
({
visible
:
true
,
alpha
:
2
,
y
:
_y
})
.
to
({
y
:
_y
-
100
,
alpha
:
0
},
1500
,
Ease
.
quadOut
)
.
set
({
visible
:
false
});
}
/**
* 游戏结束
* @param e
*/
async
gameOver
(
e
)
{
// 引导入会 复活
showPanel
(
RevivePanel
,
{
gameId
:
"gameId"
,
submit
:
this
.
submitGame
,
revive
:
this
.
reviveGame
});
}
/**
* 复活
*/
reviveGame
=
async
()
=>
{
await
sleep
(
500
);
this
.
jump3d
.
revive
();
}
/**
* 提交
*/
submitGame
=
async
()
=>
{
showPanel
(
OverPrizePanel
,
{
score
:
this
.
score
,
prizeInfo
:
{
id
:
"id"
,
image
:
"https://yun.duiba.com.cn/aurora/assets/001d24bc7a23ffca787beef7d4eb81026f7d6240.png"
,
name
:
"name"
,
type
:
4
},
gameTimes
:
3
});
}
}
src/scenes/Jump3D/Player.ts
deleted
100644 → 0
View file @
cdbbdef6
import
{
IOutAreaData
}
from
"./Box"
;
import
{
getPlayerConfig
,
M_loadGLB
}
from
"./MT"
;
import
ParticleEmitter
from
"./Particle"
;
import
Object3D
=
FYGE
.
Object3D
;
import
Tween
=
FYGE
.
Tween
;
import
Ease
=
FYGE
.
Ease
;
import
Mesh3D
=
FYGE
.
Mesh3D
;
import
BaseMaterial
=
FYGE
.
BaseMaterial
;
import
RingGeometry
=
FYGE
.
RingGeometry
;
export
enum
Direction
{
/**
* -x方向
*/
left
=
0
,
/**
* -z方向
*/
right
}
const
playY
=
0.77
;
const
ringGeo
=
new
RingGeometry
(
0.14
,
0.21
,
30
,
1
);
/**
* 玩家
*/
export
default
class
Player
extends
Object3D
{
particleEmitter
:
ParticleEmitter
;
mesh
:
Object3D
;
constructor
()
{
super
();
this
.
init
();
}
async
init
()
{
const
config
=
getPlayerConfig
();
const
mesh
=
this
.
mesh
=
await
M_loadGLB
(
config
.
src
);
// this.mesh.scale.set(0.0025, 0.0025, 0.0025);
this
.
mesh
.
scale
.
set
(
0.004
,
0.004
,
0.004
);
this
.
mesh
.
children
[
0
].
y
=
-
35
;
// this.mesh.children[0].castShadow = true;
// this.mesh.children[0].receiveShadow = true;
this
.
addChild
(
mesh
);
this
.
particleEmitter
=
this
.
addChild
(
new
ParticleEmitter
());
const
{
x
,
y
,
z
}
=
this
.
scene
.
camera
.
position
;
this
.
particleEmitter
.
lookAt
(
x
,
y
,
z
);
}
async
reset
():
Promise
<
void
>
{
return
new
Promise
((
resolve
)
=>
{
this
.
rotation
.
set
(
0
,
0
,
0
,
0
);
this
.
position
.
set
(
0
,
playY
+
1
,
0
);
Tween
.
get
(
this
)
.
to
({
y
:
playY
},
1000
,
Ease
.
bounceOut
)
.
call
(
resolve
);
});
}
async
jump
(
x
,
z
)
{
return
new
Promise
((
resolve
)
=>
{
//y向上跳;
Tween
.
get
(
this
)
.
to
({
y
:
1.5
},
250
,
Ease
.
quadOut
)
.
to
({
y
:
playY
},
250
,
Ease
.
quadIn
);
//位移
Tween
.
get
(
this
)
.
to
({
x
,
z
},
500
)
.
call
(
resolve
);
});
}
/**
* 蓄力
*/
push
(
s
:
number
)
{
this
.
scaleY
=
1
-
s
;
//位置也要往下
this
.
y
=
playY
-
s
/
2
-
0.13
*
s
/
0.5
;
}
rot
(
d
:
Direction
)
{
let
k
=
"rotationX"
,
c
=
this
.
mesh
;
if
(
d
==
Direction
.
left
)
k
=
"rotationZ"
;
Tween
.
get
(
c
)
.
to
({
[
k
]:
k
==
"rotationX"
?
-
360
:
360
},
500
)
.
call
(()
=>
{
c
[
k
]
=
0
;
});
}
/**
* 落到加分范围内的动画
* @param count 连续几次
*/
doubleEffect
(
count
:
number
=
1
):
void
{
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
Tween
.
get
({})
.
wait
(
180
*
i
)
.
call
(()
=>
{
const
ring
=
this
.
scene
.
addChild
(
new
Mesh3D
(
ringGeo
,
new
BaseMaterial
({
color
:
0xffffff
,
alpha
:
1
})
));
ring
.
position
.
copy
(
this
.
position
);
ring
.
y
+=
0.01
*
i
;
// 防止面重叠渲染出错
ring
.
rotationX
=
-
90
;
Tween
.
get
(
ring
.
material
)
.
to
({
alpha
:
0
},
1000
,
Ease
.
quartOut
);
Tween
.
get
(
ring
)
.
to
({
scaleX
:
5
,
scaleY
:
5
},
800
,
Ease
.
quartOut
)
.
call
(()
=>
{
this
.
scene
.
removeChild
(
ring
);
});
});
}
}
/**
* 跌落
* @param oad IOutAreaData
* @param wait 动画完成后等待时间
*/
async
fall
(
oad
:
IOutAreaData
,
wait
):
Promise
<
void
>
{
/**
* IOutAreaData
* @param out 0 在外 1 在内 2 加分
* @param fall? 是否掉落,超过边界一定值则为true,则需要掉落
* @param fallDir? 掉落方向:-1 向负方向 1 向正方形
* @param fallAxis? 掉落轴:"x" | "z"
*/
// fall: true
// fallAxis: "z"
// fallDir: 1
// out: 0
return
new
Promise
((
resolve
)
=>
{
if
(
oad
.
verFall
)
{
// 垂直落地
Tween
.
get
(
this
)
.
to
({
y
:
0.15
},
130
)
.
wait
(
wait
)
.
call
(
resolve
);
}
else
{
// 摔落
const
{
fallDir
:
fd
,
fallAxis
:
fa
}
=
oad
;
const
r
=
90
*
fd
*
(
fa
==
"x"
?
-
1
:
1
);
Tween
.
get
(
this
)
.
wait
(
50
)
.
to
({
y
:
0.08
,
[
fa
]:
this
[
fa
]
+
0.2
*
fd
,
[
`rotation
${
fa
==
"x"
?
"Z"
:
"X"
}
`
]:
r
},
230
,
Ease
.
quadIn
)
.
wait
(
wait
)
.
call
(
resolve
);
}
});
}
/**
* 复活
* @param box 要停在哪个盒子上
*/
async
revive
(
box
):
Promise
<
void
>
{
return
new
Promise
((
resolve
)
=>
{
Tween
.
get
(
this
)
.
to
({
y
:
playY
,
rotationX
:
0
,
rotationY
:
0
,
rotationZ
:
0
,
},
750
,
Ease
.
quartOut
);
Tween
.
get
(
this
)
.
to
({
x
:
box
.
x
,
z
:
box
.
z
},
750
,
Ease
.
quadIn
)
.
call
(
resolve
);
});
}
}
src/scenes/Jump3D/TorusGeometry.ts
deleted
100644 → 0
View file @
cdbbdef6
/**
* @author oosmoxiecode
* @author mrdoob / http://mrdoob.com/
* @author Mugen87 / https://github.com/Mugen87
*/
import
Geometry
=
FYGE
.
Geometry
;
import
Vector3
=
FYGE
.
Vector3
;
export
class
TorusGeometry
extends
Geometry
{
constructor
(
radius
=
1
,
tube
=
0.4
,
radialSegments
=
8
,
tubularSegments
=
6
,
arc
=
Math
.
PI
*
2
)
{
radialSegments
=
Math
.
floor
(
radialSegments
);
tubularSegments
=
Math
.
floor
(
tubularSegments
);
// buffers
const
indices
=
[];
const
vertices
=
[];
const
normals
=
[];
const
uvs
=
[];
// helper variables
const
center
=
new
Vector3
();
const
vertex
=
new
Vector3
();
const
normal
=
new
Vector3
();
let
j
,
i
;
// generate vertices, normals and uvs
for
(
j
=
0
;
j
<=
radialSegments
;
j
++
)
{
for
(
i
=
0
;
i
<=
tubularSegments
;
i
++
)
{
var
u
=
i
/
tubularSegments
*
arc
;
var
v
=
j
/
radialSegments
*
Math
.
PI
*
2
;
// vertex
vertex
.
x
=
(
radius
+
tube
*
Math
.
cos
(
v
))
*
Math
.
cos
(
u
);
vertex
.
y
=
(
radius
+
tube
*
Math
.
cos
(
v
))
*
Math
.
sin
(
u
);
vertex
.
z
=
tube
*
Math
.
sin
(
v
);
vertices
.
push
(
vertex
.
x
,
vertex
.
y
,
vertex
.
z
);
// normal
center
.
x
=
radius
*
Math
.
cos
(
u
);
center
.
y
=
radius
*
Math
.
sin
(
u
);
normal
.
subVectors
(
vertex
,
center
).
normalize
();
normals
.
push
(
normal
.
x
,
normal
.
y
,
normal
.
z
);
// uv
uvs
.
push
(
i
/
tubularSegments
);
uvs
.
push
(
j
/
radialSegments
);
}
}
// generate indices
for
(
j
=
1
;
j
<=
radialSegments
;
j
++
)
{
for
(
i
=
1
;
i
<=
tubularSegments
;
i
++
)
{
// indices
const
a
=
(
tubularSegments
+
1
)
*
j
+
i
-
1
;
const
b
=
(
tubularSegments
+
1
)
*
(
j
-
1
)
+
i
-
1
;
const
c
=
(
tubularSegments
+
1
)
*
(
j
-
1
)
+
i
;
const
d
=
(
tubularSegments
+
1
)
*
j
+
i
;
// faces
indices
.
push
(
a
,
b
,
d
);
indices
.
push
(
b
,
c
,
d
);
}
}
super
(
vertices
,
indices
,
normals
,
null
,
uvs
);
}
}
yarn.lock
View file @
482fc052
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
browserslist "^4.20.2"
browserslist "^4.20.2"
semver "^6.3.0"
semver "^6.3.0"
"@babel/helper-create-class-features-plugin@^7.18.6"
, "@babel/helper-create-class-features-plugin@^7.18.9"
:
"@babel/helper-create-class-features-plugin@^7.18.6":
version "7.18.9"
version "7.18.9"
resolved "http://npm.dui88.com:80/@babel%2fhelper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz#d802ee16a64a9e824fcbf0a2ffc92f19d58550ce"
resolved "http://npm.dui88.com:80/@babel%2fhelper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz#d802ee16a64a9e824fcbf0a2ffc92f19d58550ce"
integrity sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw==
integrity sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw==
...
@@ -482,13 +482,6 @@
...
@@ -482,13 +482,6 @@
dependencies:
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-jsx@^7.18.6":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz#a8feef63b010150abd97f1649ec296e849943ca0"
integrity sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-syntax-logical-assignment-operators@^7.10.4":
"@babel/plugin-syntax-logical-assignment-operators@^7.10.4":
version "7.10.4"
version "7.10.4"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699"
...
@@ -545,13 +538,6 @@
...
@@ -545,13 +538,6 @@
dependencies:
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-syntax-typescript@^7.18.6":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz#1c09cd25795c7c2b8a4ba9ae49394576d4133285"
integrity sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-transform-arrow-functions@^7.18.6":
"@babel/plugin-transform-arrow-functions@^7.18.6":
version "7.18.6"
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz#19063fcf8771ec7b31d742339dac62433d0611fe"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz#19063fcf8771ec7b31d742339dac62433d0611fe"
...
@@ -738,39 +724,6 @@
...
@@ -738,39 +724,6 @@
dependencies:
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-transform-react-display-name@^7.18.6":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-react-display-name/-/plugin-transform-react-display-name-7.18.6.tgz#8b1125f919ef36ebdfff061d664e266c666b9415"
integrity sha512-TV4sQ+T013n61uMoygyMRm+xf04Bd5oqFpv2jAEQwSZ8NwQA7zeRPg1LMVg2PWi3zWBz+CLKD+v5bcpZ/BS0aA==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-transform-react-jsx-development@^7.18.6":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz#dbe5c972811e49c7405b630e4d0d2e1380c0ddc5"
integrity sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA==
dependencies:
"@babel/plugin-transform-react-jsx" "^7.18.6"
"@babel/plugin-transform-react-jsx@^7.18.6":
version "7.18.10"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-react-jsx/-/plugin-transform-react-jsx-7.18.10.tgz#ea47b2c4197102c196cbd10db9b3bb20daa820f1"
integrity sha512-gCy7Iikrpu3IZjYZolFE4M1Sm+nrh1/6za2Ewj77Z+XirT4TsbJcvOFOyF+fRPwU6AKKK136CZxx6L8AbSFG6A==
dependencies:
"@babel/helper-annotate-as-pure" "^7.18.6"
"@babel/helper-module-imports" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.9"
"@babel/plugin-syntax-jsx" "^7.18.6"
"@babel/types" "^7.18.10"
"@babel/plugin-transform-react-pure-annotations@^7.18.6":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.18.6.tgz#561af267f19f3e5d59291f9950fd7b9663d0d844"
integrity sha512-I8VfEPg9r2TRDdvnHgPepTKvuRomzA8+u+nhY7qSI1fR2hRNebasZEETLyM5mAUr0Ku56OkXJ0I7NHJnO6cJiQ==
dependencies:
"@babel/helper-annotate-as-pure" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-transform-regenerator@^7.18.6":
"@babel/plugin-transform-regenerator@^7.18.6":
version "7.18.6"
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz#585c66cb84d4b4bf72519a34cfce761b8676ca73"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz#585c66cb84d4b4bf72519a34cfce761b8676ca73"
...
@@ -786,18 +739,6 @@
...
@@ -786,18 +739,6 @@
dependencies:
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-transform-runtime@^7.18.10":
version "7.18.10"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-runtime/-/plugin-transform-runtime-7.18.10.tgz#37d14d1fa810a368fd635d4d1476c0154144a96f"
integrity sha512-q5mMeYAdfEbpBAgzl7tBre/la3LeCxmDO1+wMXRdPWbcoMjR3GiXlCLk7JBZVVye0bqTGNMbt0yYVXX1B1jEWQ==
dependencies:
"@babel/helper-module-imports" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.9"
babel-plugin-polyfill-corejs2 "^0.3.2"
babel-plugin-polyfill-corejs3 "^0.5.3"
babel-plugin-polyfill-regenerator "^0.4.0"
semver "^6.3.0"
"@babel/plugin-transform-shorthand-properties@^7.18.6":
"@babel/plugin-transform-shorthand-properties@^7.18.6":
version "7.18.6"
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz#6d6df7983d67b195289be24909e3f12a8f664dc9"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz#6d6df7983d67b195289be24909e3f12a8f664dc9"
...
@@ -834,15 +775,6 @@
...
@@ -834,15 +775,6 @@
dependencies:
dependencies:
"@babel/helper-plugin-utils" "^7.18.9"
"@babel/helper-plugin-utils" "^7.18.9"
"@babel/plugin-transform-typescript@^7.18.6":
version "7.18.12"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-typescript/-/plugin-transform-typescript-7.18.12.tgz#712e9a71b9e00fde9f8c0238e0cceee86ab2f8fd"
integrity sha512-2vjjam0cum0miPkenUbQswKowuxs/NjMwIKEq0zwegRxXk12C9YOF9STXnaUptITOtOJHKHpzvvWYOjbm6tc0w==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.18.9"
"@babel/helper-plugin-utils" "^7.18.9"
"@babel/plugin-syntax-typescript" "^7.18.6"
"@babel/plugin-transform-unicode-escapes@^7.18.10":
"@babel/plugin-transform-unicode-escapes@^7.18.10":
version "7.18.10"
version "7.18.10"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246"
resolved "http://npm.dui88.com:80/@babel%2fplugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246"
...
@@ -950,27 +882,6 @@
...
@@ -950,27 +882,6 @@
"@babel/types" "^7.4.4"
"@babel/types" "^7.4.4"
esutils "^2.0.2"
esutils "^2.0.2"
"@babel/preset-react@^7.17.12":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fpreset-react/-/preset-react-7.18.6.tgz#979f76d6277048dc19094c217b507f3ad517dd2d"
integrity sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-validator-option" "^7.18.6"
"@babel/plugin-transform-react-display-name" "^7.18.6"
"@babel/plugin-transform-react-jsx" "^7.18.6"
"@babel/plugin-transform-react-jsx-development" "^7.18.6"
"@babel/plugin-transform-react-pure-annotations" "^7.18.6"
"@babel/preset-typescript@^7.17.2":
version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fpreset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399"
integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-validator-option" "^7.18.6"
"@babel/plugin-transform-typescript" "^7.18.6"
"@babel/runtime@^7.8.4":
"@babel/runtime@^7.8.4":
version "7.18.9"
version "7.18.9"
resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
...
...
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