Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_taobao
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
wildfirecode13
new_taobao
Commits
4bfd7253
Commit
4bfd7253
authored
Oct 01, 2020
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified: project/src/canvas/game/src/com/MatchingPanel.ts
parent
eab321e5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
42 deletions
+176
-42
MatchingPanel.ts
project/src/canvas/game/src/com/MatchingPanel.ts
+6
-6
CircleItem.ts
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
+1
-1
Robot.ts
project/src/canvas/game/src/xiaoxiaole/Robot.ts
+52
-0
XxlConfig.ts
project/src/canvas/game/src/xiaoxiaole/XxlConfig.ts
+5
-1
XxlScene.ts
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
+112
-34
No files found.
project/src/canvas/game/src/com/MatchingPanel.ts
View file @
4bfd7253
...
...
@@ -70,9 +70,9 @@ export class MatchingPanel extends Panel {
leftAvatar
.
y
=
-
25
lContainer
.
addChild
(
leftAvatar
)
//遮罩
let
lcircle
=
Tools
.
getCircle
(
48
,
0xffff00
)
lcircle
.
x
=
23
3
lcircle
.
y
=
2
7
let
lcircle
=
Tools
.
getCircle
(
50
,
0xffff00
)
lcircle
.
x
=
23
2
lcircle
.
y
=
2
6
lContainer
.
addChild
(
lcircle
)
leftAvatar
.
mask
=
lcircle
...
...
@@ -103,9 +103,9 @@ export class MatchingPanel extends Panel {
rightAvatar
.
y
=
-
25
rContainer
.
addChild
(
rightAvatar
)
//遮罩
let
rcircle
=
Tools
.
getCircle
(
48
,
0xffff00
)
rcircle
.
x
=
right
.
width
-
23
3
rcircle
.
y
=
2
7
let
rcircle
=
Tools
.
getCircle
(
50
,
0xffff00
)
rcircle
.
x
=
right
.
width
-
23
2
rcircle
.
y
=
2
6
rContainer
.
addChild
(
rcircle
)
rightAvatar
.
mask
=
rcircle
...
...
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
View file @
4bfd7253
...
...
@@ -16,7 +16,7 @@ export default class CircleItem extends FYGE.Container {
//类型
type
:
number
circleRes
=
[
'2a747211-0210-4215-86a2-a6955b37c45b'
,
'7d1ec658-9371-4d52-b4d7-e75d04037daf'
,
'6a1345f6-969c-4969-8bfb-f4de637df34d'
,
'2e12a9ec-46be-487f-a9cd-550dd0af3746'
,
'b022fbdd-8607-435a-a205-19fc3b5123eb'
]
circleRes
=
config
.
circleRes
point
:
point
index
:
number
...
...
project/src/canvas/game/src/xiaoxiaole/Robot.ts
0 → 100644
View file @
4bfd7253
export
class
Robot
{
private
_needWin
:
boolean
=
true
private
_score
:
number
=
0
private
_time
:
number
=
120
+
Math
.
random
()
*
30
constructor
(
needWin
)
{
this
.
_needWin
=
needWin
}
getScore
(
userScore
:
number
,
gameLeftTime
:
number
):
number
{
if
(
this
.
_time
<
0
)
{
if
(
this
.
_needWin
)
{
//机器人赢
if
(
userScore
>
2600
)
{
this
.
_score
=
3000
+
(
Math
.
floor
(
Math
.
random
()
*
8
)
+
2
)
*
10
}
else
{
if
(
gameLeftTime
>
60
)
{
if
(
this
.
_score
>
userScore
)
{
this
.
_score
+=
(
Math
.
floor
(
Math
.
random
()
*
6
)
+
2
)
*
10
}
else
{
this
.
_score
=
userScore
+
(
Math
.
floor
(
Math
.
random
()
*
3
)
+
2
)
*
10
}
}
else
{
if
(
this
.
_score
>
userScore
)
{
this
.
_score
+=
(
Math
.
floor
(
Math
.
random
()
*
8
)
+
3
)
*
10
}
else
{
this
.
_score
=
userScore
+
(
Math
.
floor
(
Math
.
random
()
*
8
)
+
6
)
*
10
}
}
}
}
else
{
//机器人输
if
(
this
.
_score
>=
userScore
)
{
return
this
.
_score
}
else
{
//应该的分数
let
gapScore
=
userScore
-
this
.
_score
let
randomScore
=
(
Math
.
floor
(
Math
.
random
()
*
3
)
+
2
)
*
10
if
(
randomScore
<
gapScore
)
{
this
.
_score
+=
randomScore
return
this
.
_score
}
}
}
this
.
_time
=
120
+
Math
.
random
()
*
60
}
this
.
_time
--
return
this
.
_score
}
}
\ No newline at end of file
project/src/canvas/game/src/xiaoxiaole/XxlConfig.ts
View file @
4bfd7253
...
...
@@ -6,5 +6,9 @@ export const config = {
second
:
2000
,
third
:
3000
,
//5种每个球的分数
score
:
[
10
,
10
,
10
,
10
,
10
]
score
:
[
10
,
10
,
10
,
10
,
10
],
//游戏难度3,4,5
difficulty
:
3
,
//球的资源
circleRes
:
[
'2a747211-0210-4215-86a2-a6955b37c45b'
,
'7d1ec658-9371-4d52-b4d7-e75d04037daf'
,
'6a1345f6-969c-4969-8bfb-f4de637df34d'
,
'2e12a9ec-46be-487f-a9cd-550dd0af3746'
,
'b022fbdd-8607-435a-a205-19fc3b5123eb'
]
}
\ No newline at end of file
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
View file @
4bfd7253
...
...
@@ -13,6 +13,7 @@ import { sendTbNet, TbNetName } from "../TaoBaoNet";
import
{
config
}
from
"./XxlConfig"
;
import
{
MatchingPanel
}
from
"../com/MatchingPanel"
;
import
{
GDispatcher
}
from
"../Main"
;
import
{
Robot
}
from
"./Robot"
;
declare
interface
point
{
x
:
number
;
...
...
@@ -70,6 +71,9 @@ export class XxlScene extends Scene {
//左头像
lavatar
:
FYGE
.
Sprite
// 右边用户container
rightUserContainer
:
FYGE
.
Container
//右边用户昵称
rnickname
:
FYGE
.
TextField
//右边关卡
...
...
@@ -92,6 +96,7 @@ export class XxlScene extends Scene {
star3
:
Star
/**
* 游戏状态参数
*/
...
...
@@ -101,12 +106,16 @@ export class XxlScene extends Scene {
//当前用户游戏关卡
level
:
number
=
0
//当前游戏难度
difficulty
:
number
=
3
difficulty
:
number
=
config
.
difficulty
//是否可以游戏
isGameStart
:
boolean
=
false
//游戏是否结束
isGameEnd
:
boolean
=
false
//机器人用户
robot
:
Robot
=
null
//机器人用户分数
robotScore
:
number
=
0
/**
* 右移偶数行
...
...
@@ -211,6 +220,7 @@ export class XxlScene extends Scene {
this
.
userInfo
=
userInfoRes
.
data
as
UserInfo
(
function
init
()
{
for
(
var
i
=
0
;
i
<
that
.
ROW_NUM
;
i
++
)
{
for
(
var
j
=
0
;
j
<
that
.
COL_NUM
;
j
++
)
{
...
...
@@ -227,6 +237,7 @@ export class XxlScene extends Scene {
}
})()
this
.
robot
=
new
Robot
(
!
this
.
userInfo
.
win
)
this
.
bg
=
Ins
.
initSprite
(
"7fcd3fb3-57bd-436a-afca-989b68b6b311"
)
...
...
@@ -320,30 +331,32 @@ export class XxlScene extends Scene {
this
.
topContainer
.
addChild
(
leftUserContainer
)
console
.
log
(
this
.
width
,)
//右边用户信息
let
rightUserContainer
=
new
FYGE
.
Container
()
this
.
rightUserContainer
=
new
FYGE
.
Container
()
//头像
let
ravatarBg
=
Ins
.
initSprite
(
"2a8ee937-a863-4f5f-89eb-c8be40e0d5c5"
)
ravatarBg
.
x
=
Ins
.
stageW
-
55
-
ravatarBg
.
width
ravatarBg
.
y
=
78
-
(
ravatarBg
.
width
>>
1
)
rightUserContainer
.
addChild
(
ravatarBg
)
this
.
rightUserContainer
.
addChild
(
ravatarBg
)
let
circle2
=
Tools
.
getCircle
(
48
,
0xffff00
)
circle2
.
x
=
Ins
.
stageW
-
ravatarBg
.
width
-
3
circle2
.
y
=
77
rightUserContainer
.
addChild
(
circle2
)
this
.
rightUserContainer
.
addChild
(
circle2
)
this
.
ravatar
=
FYGE
.
Sprite
.
fromUrl
(
this
.
userInfo
.
fakeUserImgUrl
)
this
.
ravatar
.
mask
=
circle2
this
.
ravatar
.
x
=
Ins
.
stageW
-
50
-
ravatarBg
.
width
this
.
ravatar
.
y
=
78
-
(
ravatarBg
.
height
>>
1
)
rightUserContainer
.
addChild
(
this
.
ravatar
)
this
.
rightUserContainer
.
addChild
(
this
.
ravatar
)
//分数
this
.
rscore
=
Tools
.
getText
(
"0"
,
30
,
"#ffffff"
,
FYGE
.
TEXT_ALIGN
.
RIGHT
)
this
.
rscore
=
Tools
.
getText
(
"0"
,
30
,
"#ffffff"
)
this
.
rscore
.
bold
=
true
this
.
rscore
.
x
=
Ins
.
stageW
-
175
-
this
.
rscore
.
textWidth
this
.
rscore
.
anchorX
=
this
.
rscore
.
textWidth
>>
1
...
...
@@ -351,7 +364,7 @@ export class XxlScene extends Scene {
this
.
rscore
.
y
=
63
this
.
rscore
.
stroke
=
3
this
.
rscore
.
strokeColor
=
"#ed767c"
rightUserContainer
.
addChild
(
this
.
rscore
)
this
.
rightUserContainer
.
addChild
(
this
.
rscore
)
//用户昵称
this
.
rnickname
=
Tools
.
getText
(
this
.
userInfo
.
fakeUserName
,
18
,
"#ffffff"
,
FYGE
.
TEXT_ALIGN
.
RIGHT
)
...
...
@@ -360,21 +373,23 @@ export class XxlScene extends Scene {
this
.
rnickname
.
y
=
35
this
.
rnickname
.
stroke
=
3
this
.
rnickname
.
strokeColor
=
"#ed767c"
rightUserContainer
.
addChild
(
this
.
rnickname
)
this
.
rightUserContainer
.
addChild
(
this
.
rnickname
)
//第几关
let
rlevelBg
=
Ins
.
initSprite
(
"3edac9c3-f88b-46cb-b763-525c3c774f1b"
)
rlevelBg
.
x
=
Ins
.
stageW
-
170
-
rlevelBg
.
width
rlevelBg
.
y
=
95
rightUserContainer
.
addChild
(
rlevelBg
)
this
.
rightUserContainer
.
addChild
(
rlevelBg
)
this
.
rlevelText
=
Tools
.
getText
(
"第1关"
,
20
,
"#000"
,
FYGE
.
TEXT_ALIGN
.
CENTER
)
this
.
rlevelText
.
x
=
15
this
.
rlevelText
.
y
=
9
rlevelBg
.
addChild
(
this
.
rlevelText
)
this
.
topContainer
.
addChild
(
rightUserContainer
)
this
.
topContainer
.
addChild
(
this
.
rightUserContainer
)
//先隐藏
this
.
rightUserContainer
.
visible
=
false
//分数进度条区
...
...
@@ -599,8 +614,10 @@ export class XxlScene extends Scene {
}
}
console
.
log
(
this
.
ItemMap
)
this
.
isImpasse
()
let
isImpasse
=
this
.
isImpasse
()
if
(
isImpasse
)
{
this
.
refresh
()
}
if
(
this
.
userInfo
.
isNewUser
)
{
let
i
=
0
...
...
@@ -643,9 +660,11 @@ export class XxlScene extends Scene {
let
per
=
(
this
.
userScore
-
1000
)
/
2000
>
1
?
1
:
(
this
.
userScore
-
1000
)
/
2000
this
.
updateProgress
(
per
)
FYGE
.
Tween
.
get
(
this
.
lscore
).
to
({
scaleX
:
1.5
,
scaleY
:
1.5
},
200
).
call
(()
=>
{
FYGE
.
Tween
.
get
(
this
.
lscore
).
call
(()
=>
{
this
.
lscore
.
text
=
""
+
this
.
userScore
}).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
)
this
.
lscore
.
anchorX
=
this
.
lscore
.
textWidth
>>
1
this
.
lscore
.
anchorY
=
this
.
lscore
.
textHeight
>>
1
}).
to
({
scaleX
:
1.5
,
scaleY
:
1.5
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
)
}
gameOver
()
{
...
...
@@ -669,17 +688,29 @@ export class XxlScene extends Scene {
}
updateFakeScore
(
userGetScore
:
number
)
{
if
(
this
.
userInfo
.
win
)
{
FYGE
.
Tween
.
get
(
this
.
rscore
).
to
({
scaleX
:
1.5
,
scaleY
:
1.5
},
200
).
call
(()
=>
{
this
.
rscore
.
text
=
""
+
(
this
.
userScore
-
~
Math
.
random
()
*
5
)
this
.
rscore
.
x
=
Ins
.
stageW
-
175
-
this
.
rscore
.
textWidth
this
.
rscore
.
anchorX
=
this
.
rscore
.
textWidth
>>
1
this
.
rscore
.
anchorY
=
this
.
rscore
.
textHeight
>>
1
}).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
)
if
(
this
.
robotScore
==
userGetScore
)
{
return
}
if
(
this
.
level
<
2
&&
userGetScore
>=
1000
&&
userGetScore
<
2000
)
{
this
.
rlevelText
.
text
=
"第"
+
2
+
"关"
}
else
if
(
this
.
level
<
3
&&
userGetScore
>=
2000
&&
userGetScore
<
3000
)
{
this
.
rlevelText
.
text
=
"第"
+
3
+
"关"
}
else
if
(
userGetScore
>=
3000
)
{
this
.
gameOver
()
}
FYGE
.
Tween
.
get
(
this
.
rscore
).
call
(()
=>
{
this
.
rscore
.
text
=
userGetScore
+
""
this
.
rscore
.
x
=
Ins
.
stageW
-
175
-
this
.
rscore
.
textWidth
this
.
rscore
.
anchorX
=
this
.
rscore
.
textWidth
>>
1
this
.
rscore
.
anchorY
=
this
.
rscore
.
textHeight
>>
1
}).
to
({
scaleX
:
1.5
,
scaleY
:
1.5
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
)
this
.
robotScore
=
userGetScore
}
mouseDown
(
e
)
{
if
(
this
.
isRemove
||
!
this
.
isGameStart
||
this
.
isGameEnd
)
{
console
.
log
(
"游戏不可操作"
)
...
...
@@ -705,7 +736,6 @@ export class XxlScene extends Scene {
mouseMove
(
e
)
{
console
.
log
(
1111
)
let
p
:
point
=
{
x
:
e
.
localX
-
this
.
container
.
x
,
y
:
e
.
localY
-
this
.
container
.
y
}
let
co
=
this
.
firstSelectItem
if
(
this
.
selectItems
.
length
>
0
)
{
...
...
@@ -787,6 +817,10 @@ export class XxlScene extends Scene {
drop
()
{
if
(
this
.
emptyHexIndices
.
length
==
0
)
{
this
.
isRemove
=
false
let
isImpasse
=
this
.
isImpasse
()
if
(
isImpasse
)
{
this
.
refresh
()
}
}
this
.
emptyHexIndices
=
Array
.
from
(
new
Set
(
this
.
emptyHexIndices
));
this
.
emptyHexIndices
.
sort
((
a
,
b
)
=>
b
-
a
)
...
...
@@ -875,7 +909,6 @@ export class XxlScene extends Scene {
exchange
(
vo
:
CircleItem
,
p
:
point
)
{
this
.
drop
()
if
(
vo
.
x
>
p
.
x
)
{
FYGE
.
Tween
.
get
(
vo
).
to
({
x
:
p
.
x
-
5
,
y
:
p
.
y
+
5
},
150
).
to
({
x
:
p
.
x
,
y
:
p
.
y
},
150
).
call
(()
=>
{
vo
.
point
=
{
x
:
p
.
x
+
39
,
y
:
p
.
y
+
39
}
...
...
@@ -960,31 +993,65 @@ export class XxlScene extends Scene {
//是否是僵局
isImpasse
():
boolean
{
let
isImpasse
=
true
for
(
let
i
in
this
.
ItemMap
)
{
let
noder
=
this
.
ItemMap
[
i
]
let
iter
=
this
.
ItemMap
.
values
()
let
item
while
(
item
=
iter
.
next
(),
!
item
.
done
)
{
let
noder
=
item
.
value
if
(
noder
.
father
&&
noder
.
item
.
type
==
noder
.
father
.
item
.
type
)
{
isImpasse
=
false
break
}
if
(
noder
.
mother
&&
noder
.
item
.
type
==
noder
.
mother
.
item
.
type
)
{
isImpasse
=
true
isImpasse
=
false
break
}
if
(
noder
.
bother
&&
noder
.
item
.
type
==
noder
.
bother
.
item
.
type
)
{
isImpasse
=
true
isImpasse
=
false
break
}
if
(
noder
.
sister
&&
noder
.
item
.
type
==
noder
.
sister
.
item
.
type
)
{
isImpasse
=
true
isImpasse
=
false
break
}
if
(
noder
.
son
&&
noder
.
item
.
type
==
noder
.
son
.
item
.
type
)
{
isImpasse
=
true
isImpasse
=
false
break
}
if
(
noder
.
daughter
&&
noder
.
item
.
type
==
noder
.
daughter
.
item
.
type
)
{
isImpasse
=
true
isImpasse
=
false
break
}
console
.
log
(
1
)
}
console
.
log
(
isImpasse
)
return
isImpasse
}
//刷新
refresh
()
{
let
circleItems
=
this
.
circleItems
circleItems
.
forEach
(
co
=>
{
this
.
emptyHexIndices
.
push
(
co
.
index
)
this
.
ItemMap
.
get
(
co
.
index
).
item
=
null
let
lc
=
this
.
objectPool
.
getLightCircle
()
this
.
container
.
addChild
(
lc
)
lc
.
x
=
co
.
point
.
x
-
103
lc
.
y
=
co
.
point
.
y
-
103
co
.
explode
(()
=>
{
this
.
objectPool
.
putLightCircle
(
lc
)
this
.
objectPool
.
putItem
(
co
)
})
lc
.
play
()
})
setTimeout
(()
=>
{
this
.
circleItems
.
splice
(
0
)
this
.
drop
()
},
500
)
}
initEvents
()
{
var
that
=
this
;
...
...
@@ -999,31 +1066,44 @@ export class XxlScene extends Scene {
gameStart
()
{
console
.
log
(
"游戏开始"
)
this
.
rightUserContainer
.
visible
=
true
this
.
isGameStart
=
true
GDispatcher
.
removeEventListener
(
"MatchCompelete"
,
this
.
gameStart
)
}
lt
=
0
tt
=
0
updateFrame
()
{
if
(
!
this
.
isGameStart
)
{
console
.
log
(
"游戏未开始"
)
//
console.log("游戏未开始")
return
}
if
(
this
.
isGameEnd
)
{
this
.
gameOver
()
console
.
log
(
"游戏结束"
)
//
console.log("游戏结束")
return
}
if
(
this
.
tt
>=
config
.
time
)
{
this
.
updateFakeScore
(
this
.
robot
.
getScore
(
this
.
userScore
,
this
.
timeNum
))
this
.
time
.
text
=
"0"
this
.
gameOver
()
return
}
//更新机器人分数
this
.
updateFakeScore
(
this
.
robot
.
getScore
(
this
.
userScore
,
this
.
timeNum
))
if
(
this
.
lt
)
{
let
nt
=
new
Date
().
getTime
()
let
dt
=
nt
-
this
.
lt
this
.
tt
+=
dt
/
1000
>>
0
let
ntt
=
config
.
time
-
this
.
tt
if
(
ntt
!=
this
.
timeNum
)
{
...
...
@@ -1046,8 +1126,6 @@ export class XxlScene extends Scene {
this
.
timeNum
=
ntt
this
.
time
.
text
=
this
.
timeNum
+
""
this
.
lt
=
nt
}
}
else
{
this
.
lt
=
new
Date
().
getTime
()
...
...
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