Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
babycare_xiaoxiao
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
翁阳
babycare_xiaoxiao
Commits
bf0439d4
Commit
bf0439d4
authored
Jul 24, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
fa4e1cc2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
215 additions
and
44 deletions
+215
-44
babycare.getPrizesByLevel.json
mock/miniTb/babycare.getPrizesByLevel.json
+43
-7
GTool.ts
module/tools/GTool.ts
+5
-0
output.js
output.js
+13
-14
output.js.map
output.js.map
+1
-1
LotteryScene.ts
src/scene/LotteryScene.ts
+152
-21
MapUI.ts
src/scene/map/MapUI.ts
+1
-1
No files found.
mock/miniTb/babycare.getPrizesByLevel.json
View file @
bf0439d4
...
...
@@ -22,12 +22,12 @@
"name"
:
"60关奖品3"
,
"useStock"
:
1
,
"rank"
:
""
,
"_id"
:
"
5f08084e0cb7338a0a377c8e
"
,
"_id"
:
"
123
"
,
"id"
:
""
,
"stock"
:
200
},
{
"image"
:
"https://
img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png
"
,
"image"
:
"https://
source.unsplash.com/user/erondu/80x80
"
,
"isBackUp"
:
true
,
"properiodto"
:
10000
,
"level"
:
2
,
...
...
@@ -42,10 +42,10 @@
"deleteStatus"
:
1
,
"name"
:
"谢谢参与"
,
"useStock"
:
0
,
"_id"
:
"
5f0c043852bbde91d1ca5682
"
"_id"
:
"
456
"
},
{
"image"
:
"https://
img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png
"
,
"image"
:
"https://
source.unsplash.com/user/erondu/90x90
"
,
"isBackUp"
:
true
,
"properiodto"
:
10000
,
"level"
:
2
,
...
...
@@ -60,10 +60,46 @@
"deleteStatus"
:
1
,
"name"
:
"谢谢参与"
,
"useStock"
:
0
,
"_id"
:
"
5f0c043852bbde91d1ca5682
"
"_id"
:
"
789
"
},
{
"image"
:
"https://img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png"
,
"image"
:
"https://source.unsplash.com/user/erondu/100x100"
,
"isBackUp"
:
true
,
"properiodto"
:
10000
,
"level"
:
2
,
"probability"
:
"84"
,
"prizeType"
:
60
,
"updateTime"
:
1594623032197
,
"type"
:
5
,
"properiodfrom"
:
1601
,
"activityId"
:
"5f08084ec3ad3494b9201c0e"
,
"lockStatus"
:
1
,
"createTime"
:
1594623032197
,
"deleteStatus"
:
1
,
"name"
:
"谢谢参与"
,
"useStock"
:
0
,
"_id"
:
"1213"
},
{
"image"
:
"https://source.unsplash.com/user/erondu/110x110"
,
"isBackUp"
:
true
,
"properiodto"
:
10000
,
"level"
:
2
,
"probability"
:
"84"
,
"prizeType"
:
60
,
"updateTime"
:
1594623032197
,
"type"
:
5
,
"properiodfrom"
:
1601
,
"activityId"
:
"5f08084ec3ad3494b9201c0e"
,
"lockStatus"
:
1
,
"createTime"
:
1594623032197
,
"deleteStatus"
:
1
,
"name"
:
"谢谢参与"
,
"useStock"
:
0
,
"_id"
:
"9898"
},
{
"image"
:
"https://source.unsplash.com/user/erondu/120x120"
,
"isBackUp"
:
true
,
"properiodto"
:
10000
,
"level"
:
2
,
...
...
@@ -78,7 +114,7 @@
"deleteStatus"
:
1
,
"name"
:
"谢谢参与"
,
"useStock"
:
0
,
"_id"
:
"
5f0c043852bbde91d1ca5682
"
"_id"
:
"
9654
"
}
],
"success"
:
true
,
...
...
module/tools/GTool.ts
View file @
bf0439d4
...
...
@@ -155,6 +155,11 @@ export class GTool {
return
(
0.5
-
Math
.
random
());
});
}
public
static
disturbArr
(
arr
:
any
[])
{
return
arr
.
sort
(
function
()
{
return
(
0.5
-
Math
.
random
());
});
}
/**
* 其实打乱数组取前几个就行
...
...
output.js
View file @
bf0439d4
...
...
@@ -17256,9 +17256,9 @@ var StartPanel = (function (_super) {
this.checkTex.textAlign = TEXT_ALIGN.CENTER;
this.checkTex.x = 0;
this.checkTex.text = "\u7B2C\t" + this.data.level + "\t\u5173";
this.startBtn.visible =
(this.data.stars < 3)
;
this.startBtn2.visible =
(this.data.stars >= 3)
;
this.tipsTex.visible =
(this.data.stars < 3)
;
this.startBtn.visible =
!this.data.isPlayed
;
this.startBtn2.visible =
this.data.isPlayed
;
this.tipsTex.visible =
!this.data.isPlayed
;
this.addChild(new StartTarget(this.data.level))
.position.set(0, 682);
};
...
...
@@ -17267,7 +17267,7 @@ var StartPanel = (function (_super) {
};
StartPanel.prototype.startGame = function () {
var _this = this;
if (
this.data.stars < 3
&& Tools_1.Tools.gameData.power <= 0) {
if (
!this.data.isPlayed
&& Tools_1.Tools.gameData.power <= 0) {
ctrls_1.showPanel(NoEnergyPanel_1.NoEnergyPanel);
return;
}
...
...
@@ -17412,8 +17412,8 @@ var StartPanelPrize = (function (_super) {
this.checkTex.textAlign = TEXT_ALIGN.CENTER;
this.checkTex.x = 0;
this.checkTex.text = "\u7B2C\t" + this.data.level + "\t\u5173";
this.startBtn.visible =
(this.data.stars < 3)
;
this.startBtn2.visible =
(this.data.stars >= 3)
;
this.startBtn.visible =
!this.data.isPlayed
;
this.startBtn2.visible =
this.data.isPlayed
;
this.addChild(new StartPanel_1.StartTarget(this.data.level))
.position.set(0, 682);
this.prizeImg.texture = Texture.fromUrl(Tools_1.Tools.baseInfo.levelPrize["level_" + this.data.level]);
...
...
@@ -17425,7 +17425,7 @@ var StartPanelPrize = (function (_super) {
};
StartPanelPrize.prototype.startGame = function () {
var _this = this;
if (
this.data.stars < 3
&& Tools_1.Tools.gameData.power <= 0) {
if (
!this.data.isPlayed
&& Tools_1.Tools.gameData.power <= 0) {
ctrls_1.showPanel(NoEnergyPanel_1.NoEnergyPanel);
return;
}
...
...
@@ -17548,10 +17548,10 @@ var SuccessNoPrizePanel = (function (_super) {
if (curLevel_1 <= value && d >= 0 && d <= dLevel_1) {
upLevel_1 = value;
if (curLevel_1 == _this.data.level) {
dLevel_1 = d
+ 1
;
dLevel_1 = d;
}
else {
dLevel_1 = d;
dLevel_1 = d
+ 1
;
}
}
});
...
...
@@ -21384,7 +21384,8 @@ var MapScene = (function (_super) {
var openPrize = GTool_1.GTool.readCache('openPrize');
if (Tools_1.Tools.gameData.topAward && Tools_1.Tools.gameData.topAward._id && openPrize !== 'true') {
GTool_1.GTool.writeCache('openPrize', 'true');
ctrls_1.showPanel(PrizePanel_1.PrizePanel, Tools_1.Tools.gameData.topAward);
ctrls_1.showPanel(PrizePanel_1.PrizePanel, JSON.parse(JSON.stringify(Tools_1.Tools.gameData.topAward)));
Tools_1.Tools.gameData.topAward = null;
}
};
MapScene.prototype.updateMapCheck = function () {
...
...
@@ -21831,10 +21832,7 @@ var CreditsBox = (function (_super) {
case 1:
creditsData = _a.sent();
jfLabel = '积分:0';
if (!creditsData || !creditsData.data) {
jfLabel = '积分:0';
}
else {
if (creditsData.success && creditsData.data && creditsData.data.credits) {
jfLabel = "\u79EF\u5206:" + creditsData.data.credits;
}
this.countLabel.text = jfLabel;
...
...
@@ -21880,6 +21878,7 @@ var PrizeBox = (function (_super) {
this.checkTip.text = "\u518D\u95EF" + dLevel_1 + "\u5173";
this.tip.text = '';
this.prizeImg.texture = Texture.fromUrl(Tools_1.Tools.baseInfo.levelPrize["level_" + upLevel_1]);
this.prizeImg.y -= 20;
}
else if (prizes.length == 1 && +prizes[0].level == 120) {
this.checkTip.text = "\u7B49\u5F85\u5F00\u5956";
output.js.map
View file @
bf0439d4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/scene/LotteryScene.ts
View file @
bf0439d4
...
...
@@ -2,8 +2,9 @@ import { Scene } from "../../module/views/Scene";
import
{
RES
}
from
"../../module/RES"
;
import
{
layers
}
from
"../../module/views/layers"
;
import
{
Tools
}
from
"../Tools"
;
import
{
showWaiting
}
from
"../../module/ctrls"
;
import
{
showWaiting
,
wait
}
from
"../../module/ctrls"
;
import
{
sendTbNet
,
TbNetName
}
from
"../TaoBaoNet"
;
import
{
GTool
}
from
"../../module/tools/GTool"
;
/**
* 摇奖机弹框
...
...
@@ -46,7 +47,7 @@ export class LotteryScene extends Scene {
FYGE
.
TEXT_ALIGN
.
CENTER
,
488
,
(
750
-
488
)
/
2
,
36
0
42
0
))
//抽奖按钮
this
.
addChild
(
new
FYGE
.
Button
(
RES
.
getRes
(
"lotteryBtn.png"
)))
...
...
@@ -64,7 +65,16 @@ export class LotteryScene extends Scene {
scroll
.
position
.
set
(
195
,
1013
);
scroll
.
updateData
(
prizeList
||
[])
//摇奖部分
var
p
=
[
201
,
620
]
var
lotScroll
=
this
.
addChild
(
new
LotteryScroll
(
prizeList
))
lotScroll
.
position
.
set
(
p
[
0
],
p
[
1
]);
// console.log(lotScroll);
window
[
"aa"
]
=
function
(
id
)
{
lotScroll
.
lot
(
id
,
()
=>
{
console
.
log
(
123123
)
})
}
}
lottery
()
{
...
...
@@ -104,48 +114,169 @@ class PrizeItem extends FYGE.Container implements FYGE.IScrollListItem {
}
class
LotteryItem
extends
FYGE
.
Container
{
private
showImage
:
FYGE
.
Sprite
;
private
cusPosition
:
number
;
constructor
(
tex
?:
FYGE
.
Texture
)
{
id
:
string
constructor
(
data
:
PrizeInt
)
{
super
();
this
.
id
=
data
.
_id
;
this
.
addChild
(
new
FYGE
.
Sprite
(
RES
.
getRes
(
"lotteryItemBg.png"
)));
this
.
showImage
=
this
.
addChild
(
new
FYGE
.
Sprite
(
tex
));
this
.
showImage
=
this
.
addChild
(
new
FYGE
.
Sprite
(
FYGE
.
Texture
.
from
(
data
.
image
)
));
this
.
showImage
.
width
=
this
.
showImage
.
height
=
88
;
this
.
showImage
.
position
.
set
((
103
-
88
)
/
2
,
6
);
var
mask
=
this
.
addChild
(
new
FYGE
.
Shape
())
mask
.
beginFill
(
0
);
mask
.
drawRoundedRect
((
103
-
88
)
/
2
,
6
,
88
,
88
,
10
);
mask
.
endFill
();
this
.
showImage
.
mask
=
mask
}
changeShowImage
(
tex
:
FYGE
.
Texture
)
{
this
.
showImage
.
texture
=
tex
;
reset
(
data
:
PrizeInt
)
{
this
.
showImage
.
texture
=
FYGE
.
Texture
.
from
(
data
.
image
);
this
.
id
=
data
.
_id
;
}
}
const
HEIGHT
=
123
;
/**
* 滚动条
* 功能可以滚动到指定的图
*/
class
LotteryScroll
extends
FYGE
.
Container
{
private
currentIndex
:
number
;
constructor
(
textures
:
FYGE
.
Texture
[])
{
class
LotteryScrollItem
extends
FYGE
.
Container
{
/**
* 当前childre的中位索引
*/
get
currentIndex
():
number
{
var
a
=
1
-
this
.
cusP
;
var
l
=
this
.
children
.
length
return
a
<
0
?
a
%
l
+
l
:
a
%
l
};
private
cusP
:
number
constructor
(
datas
:
PrizeInt
[])
{
super
();
textures
.
forEach
((
t
,
i
)
=>
{
this
.
addChild
(
new
LotteryItem
(
t
))
.
position
.
set
(
0
,
i
*
123
)
datas
.
forEach
((
d
)
=>
{
this
.
addChild
(
new
LotteryItem
(
d
))
})
this
.
cusP
=
0
;
this
.
updatePosition
();
//修改位置
this
.
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
()
=>
{
this
.
children
.
forEach
((
c
)
=>
{
// if () { }
})
},
this
)
this
.
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
this
.
updatePosition
,
this
)
}
scrollTo
(
index
:
number
,
time
:
number
,
callback
:
()
=>
void
)
{
scrollTo
(
id
:
string
,
callback
:
()
=>
void
)
{
//找出目标图
let
child
,
curIndex
;
for
(
var
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
if
(
this
.
children
[
i
].
id
==
id
)
{
child
=
this
.
children
[
i
];
curIndex
=
i
;
break
}
}
var
delta
=
this
.
currentIndex
-
curIndex
;
if
(
delta
<
0
)
delta
+=
this
.
children
.
length
;
//目标图的位置必须是,多加几圈
var
cusP
=
this
.
cusP
+
delta
+
10
*
this
.
children
.
length
;
FYGE
.
Tween
.
get
(
this
)
.
to
({
cusP
},
5000
,
FYGE
.
Ease
.
quadInOut
)
.
call
(()
=>
{
callback
&&
callback
();
})
}
reset
()
{
}
updatePosition
()
{
this
.
children
.
forEach
((
c
)
=>
{
// if () { }
this
.
children
.
forEach
((
c
:
LotteryItem
,
j
)
=>
{
c
.
y
=
((
this
.
cusP
+
j
)
%
this
.
children
.
length
)
*
HEIGHT
-
HEIGHT
;
//超过一定距离,移到上面
if
(
c
.
y
>
HEIGHT
*
1.5
)
{
c
.
y
=
c
.
y
-
this
.
children
.
length
*
HEIGHT
}
})
}
// 0 0- 10 21 1
// 1 00 11 2- 0
// 2 01 1- 20 2
// 3 0- 10 21 1
destroy
()
{
FYGE
.
Tween
.
removeTweens
(
this
);
super
.
destroy
()
}
}
/**
* 暂时固定3列,宽高
*/
class
LotteryScroll
extends
FYGE
.
Container
{
ids
:
string
[]
scrollItems
:
LotteryScrollItem
[];
constructor
(
datas
:
PrizeInt
[])
{
super
();
this
.
scrollItems
=
[]
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
var
s
=
this
.
addChild
(
new
LotteryScrollItem
(
GTool
.
disturbArr
(
datas
.
slice
())))
s
.
position
.
set
(
116
*
i
,
0
);
this
.
scrollItems
.
push
(
s
)
}
this
.
ids
=
[];
datas
.
forEach
((
d
)
=>
{
this
.
ids
.
push
(
d
.
_id
)
});
var
h
=
-
50
//遮罩
var
mask
=
this
.
addChild
(
new
FYGE
.
Shape
())
mask
.
beginFill
(
0
)
mask
.
drawRect
(
0
,
h
+
3
,
350
,
195
-
5
)
mask
.
endFill
();
this
.
mask
=
mask
;
//蒙层
this
.
addChild
(
new
FYGE
.
Sprite
(
RES
.
getRes
(
"shadowMask.png"
)))
.
position
.
set
(
0
,
h
)
}
lot
(
id
?:
string
,
callback
?:
()
=>
void
)
{
if
(
id
)
{
//确保得是ids里的id。否则无效
if
(
this
.
ids
.
indexOf
(
id
)
==
-
1
)
{
console
.
error
(
"中奖id不存在"
)
return
;
}
let
count
=
0
;
let
countAll
=
this
.
scrollItems
.
length
;
this
.
scrollItems
.
forEach
((
c
:
LotteryScrollItem
,
i
)
=>
{
wait
(()
=>
{
c
.
scrollTo
(
id
,
()
=>
{
if
(
++
count
==
countAll
&&
callback
)
callback
();
})
},
400
*
i
)
})
}
else
{
//保证几个id不能一致
var
ids
=
[
GTool
.
randomT
(
this
.
ids
),
GTool
.
randomT
(
this
.
ids
),
];
//如果都相同
// if(!ids.some(function (value, index) { return value !== ids[0];})){
// ids.push()
// }
//才两个,直接判断
ids
[
0
]
===
ids
[
1
]
?
ids
.
push
(
GTool
.
randomT
((()
=>
{
var
arr
=
this
.
ids
.
slice
();
arr
.
splice
(
this
.
ids
.
indexOf
(
ids
[
0
]),
1
)
return
arr
})())
)
:
ids
.
push
(
GTool
.
randomT
(
this
.
ids
));
console
.
log
(
ids
)
let
count
=
0
;
let
countAll
=
this
.
scrollItems
.
length
;
this
.
scrollItems
.
forEach
((
c
:
LotteryScrollItem
,
i
)
=>
{
wait
(()
=>
{
c
.
scrollTo
(
ids
[
i
],
()
=>
{
if
(
++
count
==
countAll
&&
callback
)
callback
();
})
},
400
*
i
)
})
}
}
}
\ No newline at end of file
src/scene/map/MapUI.ts
View file @
bf0439d4
...
...
@@ -61,7 +61,7 @@ export default class MapUI extends Container {
break
;
case
this
.
prizeBox
:
/// TODO 奖励盒子
/// TODO 奖励盒子
,有条件的吧
console
.
log
(
'奖励盒子'
);
break
;
...
...
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