Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
崔立强
db-game-template
Commits
28e608e7
Commit
28e608e7
authored
Dec 12, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gifts' of gitlab2.dui88.com:clq/db-game-template into gifts
parents
bca13172
d404a8fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
27 deletions
+113
-27
SlotPanel.ts
egret/libs/new_wx/components/SlotPanel.ts
+66
-26
default.res.json
egret/resource/default.res.json
+46
-1
SlotSkin.exml
egret/resource/skins/SlotSkin.exml
+1
-0
No files found.
egret/libs/new_wx/components/SlotPanel.ts
View file @
28e608e7
import
{
DataManager
}
from
"../../tw/manager/DataManager"
;
import
{
DataManager
}
from
"../../tw/manager/DataManager"
;
import
{
NetManager
}
from
"../../tw/manager/NetManager"
;
import
{
NetManager
}
from
"../../tw/manager/NetManager"
;
import
{
ModuleTypes
}
from
"../../../libs/new_wx/types/sceneTypes"
;
import
wait
from
"../../../libs/new_tc/wait"
;
import
submitAfterDostart
from
"../../../libs/new_tw/ctrls/submitAfterDostart"
;
import
PanelCtrl
from
"../../../libs/new_wx/ctrls/panelCtrl"
;
import
Panel
from
"./Panel"
;
import
Panel
from
"./Panel"
;
import
centerAnchorOffset
from
"../views/centerAnchorOffset"
import
centerAnchorOffset
from
"../views/centerAnchorOffset"
import
showAlertPanel
from
"../../../libs/new_wx/ctrls/showAlertPanel"
;
import
getCountTxt
from
"../../../libs/new_tw/datas/getCountTxt"
;
export
default
class
SlotPanel
extends
Panel
{
export
default
class
SlotPanel
extends
Panel
{
optionList
:
any
;
optionList
:
any
;
...
@@ -11,6 +17,7 @@ export default class SlotPanel extends Panel {
...
@@ -11,6 +17,7 @@ export default class SlotPanel extends Panel {
itemWidth
:
number
;
itemWidth
:
number
;
speed
:
number
;
speed
:
number
;
prizeIndex
:
number
;
prizeIndex
:
number
;
countTxt
:
eui
.
Label
;
start
()
{
start
()
{
this
.
optionList
=
[]
this
.
optionList
=
[]
this
.
itemList
=
[]
this
.
itemList
=
[]
...
@@ -26,43 +33,50 @@ export default class SlotPanel extends Panel {
...
@@ -26,43 +33,50 @@ export default class SlotPanel extends Panel {
this
.
initSlot
()
this
.
initSlot
()
}
}
private
async
initSlot
()
{
private
async
initSlot
()
{
this
[
'slotStartBtn'
]
&&
this
[
'slotStartBtn'
].
once
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTap_slotStart
,
this
);
this
.
optionList
=
DataManager
.
ins
.
getOptionsData
.
optionList
.
filter
(
item
=>
(
item
as
any
).
scoreArea
===
'1,10'
)
this
.
optionList
=
DataManager
.
ins
.
getOptionsData
.
optionList
.
filter
(
item
=>
(
item
as
any
).
scoreArea
===
'1,10'
)
this
.
drawMask
()
this
.
drawMask
()
this
.
renderSlotWrap
()
this
.
renderSlotWrap
()
this
.
updateCountTxt
()
}
}
play
()
{
play
()
{
egret
.
startTick
(
this
.
onTick
,
this
)
egret
.
startTick
(
this
.
onTick
,
this
)
}
}
onTick
()
{
onTick
()
{
this
.
itemList
.
forEach
(
item
=>
{
this
.
itemList
.
forEach
(
item
=>
{
item
.
x
-=
this
.
speed
item
.
x
-=
this
.
speed
if
(
item
.
x
<
-
300
){
if
(
item
.
x
<
-
300
)
{
item
.
x
=
this
.
itemList
[
this
.
itemList
.
length
-
1
].
x
+
this
.
itemWidth
item
.
x
=
this
.
itemList
[
this
.
itemList
.
length
-
1
].
x
+
this
.
itemWidth
this
.
itemList
.
push
(
item
)
this
.
itemList
.
push
(
item
)
this
.
itemList
.
shift
()
this
.
itemList
.
shift
()
}
}
})
})
this
.
conveyorList
.
forEach
(
item
=>
{
this
.
conveyorList
.
forEach
(
item
=>
{
item
.
x
-=
this
.
speed
item
.
x
-=
this
.
speed
if
(
item
.
x
<
-
300
){
if
(
item
.
x
<
-
300
)
{
item
.
x
=
this
.
conveyorList
[
this
.
conveyorList
.
length
-
1
].
x
+
item
.
width
item
.
x
=
this
.
conveyorList
[
this
.
conveyorList
.
length
-
1
].
x
+
item
.
width
this
.
conveyorList
.
push
(
item
)
this
.
conveyorList
.
push
(
item
)
this
.
conveyorList
.
shift
()
this
.
conveyorList
.
shift
()
}
}
})
})
if
((
this
.
prizeIndex
>
-
1
)
&&
this
.
itemList
[
this
.
prizeIndex
].
x
<
385
)
{
if
((
this
.
prizeIndex
>
-
1
)
&&
this
.
itemList
[
this
.
prizeIndex
].
x
<
385
)
{
this
.
speed
=
0
this
.
speed
=
0
}
}
return
false
return
false
}
}
onTap_slotStart
()
{
onTap_slotStart
()
{
if
(
!
this
.
check
())
return
;
// this.gameReset()
// this.gameReset()
this
.
closeBtns
.
forEach
(
btn
=>
btn
.
touchEnabled
=
false
);
this
[
'slotStartBtn'
].
touchEnabled
=
false
;
this
.
calcSpeed
(
1
,
20
)
this
.
calcSpeed
(
1
,
20
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
stop
()
this
.
stop
()
})
})
}
}
calcSpeed
(
count
,
val
)
{
calcSpeed
(
count
,
val
)
{
...
@@ -74,7 +88,7 @@ export default class SlotPanel extends Panel {
...
@@ -74,7 +88,7 @@ export default class SlotPanel extends Panel {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
calc
()
calc
()
},
100
)
},
100
)
}
else
{
}
else
{
resolve
()
resolve
()
}
}
}
}
...
@@ -84,12 +98,21 @@ export default class SlotPanel extends Panel {
...
@@ -84,12 +98,21 @@ export default class SlotPanel extends Panel {
}
}
stop
()
{
stop
()
{
setTimeout
(()
=>
{
submitAfterDostart
((
status
,
data
)
=>
{
this
.
speed
=
4
let
prizeName
=
data
.
lottery
.
name
this
.
prizeIndex
=
this
.
optionList
.
findIndex
(
item
=>
item
.
name
===
'场景1奖品B'
)
wait
(
2000
).
then
(()
=>
{
console
.
log
(
this
.
prizeIndex
)
this
.
speed
=
4
},
2000
)
this
.
prizeIndex
=
this
.
optionList
.
findIndex
(
item
=>
item
.
name
===
prizeName
)
console
.
log
(
this
.
prizeIndex
)
wait
(
300
).
then
(()
=>
PanelCtrl
.
instance
.
show
(
ModuleTypes
.
PRIZE_PANEL
));
wait
(
300
).
then
(()
=>
{
NetManager
.
ins
.
getInfo
()
this
.
gameReset
()
});
})
},
10
);
}
}
gameReset
()
{
gameReset
()
{
this
.
speed
=
1
this
.
speed
=
1
this
.
prizeIndex
=
-
1
this
.
prizeIndex
=
-
1
...
@@ -98,29 +121,30 @@ export default class SlotPanel extends Panel {
...
@@ -98,29 +121,30 @@ export default class SlotPanel extends Panel {
this
.
renderOptions
(
slotWrap
)
this
.
renderOptions
(
slotWrap
)
this
.
renderConveyor
(
slotWrap
)
this
.
renderConveyor
(
slotWrap
)
}
}
private
renderConveyor
=
async
(
container
:
any
)
=>
{
private
renderConveyor
=
async
(
container
:
any
)
=>
{
let
conveyor
let
conveyor
await
loadImageByUrl
(
'conveyor_png'
).
then
((
img
:
any
)
=>
{
await
loadImageByUrl
(
'conveyor_png'
).
then
((
img
:
any
)
=>
{
conveyor
=
img
conveyor
=
img
})
})
this
.
conveyorList
=
[]
this
.
conveyorList
=
[]
for
(
let
i
=
0
;
i
<
this
.
optionList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
optionList
.
length
;
i
++
)
{
let
conveyorHash
let
conveyorHash
conveyorHash
=
cloneImage
(
conveyor
)
conveyorHash
=
cloneImage
(
conveyor
)
conveyorHash
.
y
=
244
conveyorHash
.
y
=
244
conveyorHash
.
x
=
150
+
conveyor
.
width
*
(
i
-
1
)
conveyorHash
.
x
=
150
+
conveyor
.
width
*
(
i
-
1
)
this
.
conveyorList
.
push
(
conveyorHash
)
this
.
conveyorList
.
push
(
conveyorHash
)
}
}
this
.
conveyorList
.
forEach
(
element
=>
{
container
.
addChild
(
element
)})
this
.
conveyorList
.
forEach
(
element
=>
{
container
.
addChild
(
element
)
})
}
}
private
drawMask
=
()
=>
{
private
drawMask
=
()
=>
{
var
circle
:
egret
.
Shape
=
new
egret
.
Shape
();
var
circle
:
egret
.
Shape
=
new
egret
.
Shape
();
circle
.
graphics
.
beginFill
(
0x0000ff
);
circle
.
graphics
.
beginFill
(
0x0000ff
);
circle
.
graphics
.
drawCircle
(
0
,
0
,
432
/
2
);
circle
.
graphics
.
drawCircle
(
0
,
0
,
432
/
2
);
circle
.
graphics
.
endFill
();
circle
.
graphics
.
endFill
();
circle
.
x
=
159
+
432
/
2
circle
.
x
=
159
+
432
/
2
circle
.
y
=
367
+
432
/
2
circle
.
y
=
367
+
432
/
2
this
.
addChild
(
circle
)
this
.
addChild
(
circle
)
this
.
mask
=
circle
this
.
mask
=
circle
}
}
...
@@ -134,7 +158,6 @@ export default class SlotPanel extends Panel {
...
@@ -134,7 +158,6 @@ export default class SlotPanel extends Panel {
this
.
addChild
(
slotWrap
)
this
.
addChild
(
slotWrap
)
this
.
play
()
this
.
play
()
slotWrap
.
mask
=
this
.
mask
slotWrap
.
mask
=
this
.
mask
this
.
addChild
(
this
[
'slotWrapTop'
])
this
.
addChild
(
this
[
'slotWrapTop'
])
}
}
...
@@ -147,7 +170,7 @@ export default class SlotPanel extends Panel {
...
@@ -147,7 +170,7 @@ export default class SlotPanel extends Panel {
return
loadImageByUrl
(
item
.
logo
).
then
(
image
=>
{
return
loadImageByUrl
(
item
.
logo
).
then
(
image
=>
{
gift
=
image
gift
=
image
gift
.
x
=
x
+=
this
.
itemWidth
gift
.
x
=
x
+=
this
.
itemWidth
gift
.
y
=
gift
.
height
/
2
gift
.
y
=
gift
.
height
/
2
centerAnchorOffset
(
gift
)
centerAnchorOffset
(
gift
)
this
.
itemList
.
push
(
gift
)
this
.
itemList
.
push
(
gift
)
container
.
addChild
(
gift
)
container
.
addChild
(
gift
)
...
@@ -156,10 +179,27 @@ export default class SlotPanel extends Panel {
...
@@ -156,10 +179,27 @@ export default class SlotPanel extends Panel {
},
Promise
.
resolve
())
},
Promise
.
resolve
())
}
}
updateCountTxt
()
{
if
(
this
.
countTxt
)
{
this
.
countTxt
.
text
=
getCountTxt
();
}
}
check
()
{
if
(
DataManager
.
ins
.
getInfoData
.
status
.
code
==
2
)
{
showAlertPanel
(
'对不起,您的积分不足。'
,
null
,
'lackOfMoney'
)
return
false
;
}
if
(
DataManager
.
ins
.
getInfoData
.
status
.
code
==
3
)
{
showAlertPanel
(
'对不起,参与次数已用完。'
,
null
,
'lackOfChance'
)
return
false
;
}
return
true
;
}
get
skinKey
()
{
return
'Slot'
}
get
skinKey
()
{
return
'Slot'
}
protected
get
closeBtns
():
eui
.
Button
[]
{
protected
get
closeBtns
():
eui
.
Button
[]
{
this
[
'slotStartBtn'
]
&&
this
[
'slotStartBtn'
].
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTap_slotStart
,
this
);
return
[
this
[
'slotClose'
]]
return
[
this
[
'slotClose'
]]
}
}
}
}
...
...
egret/resource/default.res.json
View file @
28e608e7
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
},
},
{
{
"name"
:
"preload"
,
"name"
:
"preload"
,
"keys"
:
"conveyor_png,slot_close_png,slot_start_btn_png,slot_wrap-bottom_png,slot_wrap-top_png"
"keys"
:
"conveyor_png,slot_close_png,slot_start_btn_png,slot_wrap-bottom_png,slot_wrap-top_png
,closeBtn2_png,hand2_png,treasurebg3_png,treasurebg22_png,conveyor2_png,slot_close2_png,slot_start_btn2_png,slot_wrap-bottom2_png,slot_wrap-top2_png
"
}
}
],
],
"resources"
:
[
"resources"
:
[
...
@@ -313,6 +313,51 @@
...
@@ -313,6 +313,51 @@
"name"
:
"slot_wrap-top_png"
,
"name"
:
"slot_wrap-top_png"
,
"type"
:
"image"
,
"type"
:
"image"
,
"url"
:
"assets/slot/slot_wrap-top.png"
"url"
:
"assets/slot/slot_wrap-top.png"
},
{
"name"
:
"closeBtn2_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/closeBtn.png"
},
{
"name"
:
"hand2_png"
,
"type"
:
"image"
,
"url"
:
"assets/treasure/hand.png"
},
{
"name"
:
"treasurebg3_png"
,
"type"
:
"image"
,
"url"
:
"assets/treasure/treasurebg.png"
},
{
"name"
:
"treasurebg22_png"
,
"type"
:
"image"
,
"url"
:
"assets/treasure/treasurebg2.png"
},
{
"name"
:
"conveyor2_png"
,
"type"
:
"image"
,
"url"
:
"assets/slot/conveyor.png"
},
{
"name"
:
"slot_close2_png"
,
"type"
:
"image"
,
"url"
:
"assets/slot/slot_close.png"
},
{
"name"
:
"slot_start_btn2_png"
,
"type"
:
"image"
,
"url"
:
"assets/slot/slot_start_btn.png"
},
{
"name"
:
"slot_wrap-bottom2_png"
,
"type"
:
"image"
,
"url"
:
"assets/slot/slot_wrap-bottom.png"
},
{
"name"
:
"slot_wrap-top2_png"
,
"type"
:
"image"
,
"url"
:
"assets/slot/slot_wrap-top.png"
}
}
]
]
}
}
\ No newline at end of file
egret/resource/skins/SlotSkin.exml
View file @
28e608e7
...
@@ -17,4 +17,5 @@
...
@@ -17,4 +17,5 @@
</e:skinName>
</e:skinName>
</e:Button>
</e:Button>
<e:Image
id=
"slotWrapTop"
x=
"159"
y=
"367.06"
source=
"slot_wrap-top_png"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
/>
<e:Image
id=
"slotWrapTop"
x=
"159"
y=
"367.06"
source=
"slot_wrap-top_png"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
/>
<e:Label
id=
"countTxt"
text=
"1/1"
width=
"100%"
verticalAlign=
"middle"
textAlign=
"center"
left=
"0"
y=
"1011"
/>
</e:Skin>
</e:Skin>
\ No newline at end of file
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