[fix]
This commit is contained in:
@@ -14,6 +14,13 @@ const enum M_DIR {
|
||||
COUNTER_CLOCKWISE = 1, /** 逆时针 */
|
||||
}
|
||||
|
||||
const AUTO_TIMES : any[] = [
|
||||
"∞",
|
||||
"500",
|
||||
"200",
|
||||
"10",
|
||||
]
|
||||
|
||||
/** 默认消耗 */
|
||||
const DEFAULT_COST = 100
|
||||
|
||||
@@ -43,6 +50,7 @@ export class PageMain extends BaseView {
|
||||
@property(Node) norw: Node = null!;
|
||||
/** 开始游戏按钮 */
|
||||
@property(Node) btn_play: Node = null!;
|
||||
@property(Node) btn_auto: Node = null!;
|
||||
/** 胜利数字 */
|
||||
@property(Node) lab_add: Node = null!;
|
||||
/** 失败数字 */
|
||||
@@ -67,6 +75,12 @@ export class PageMain extends BaseView {
|
||||
@property(VideoClip) video_lose: VideoClip = null!;
|
||||
@property(VideoClip) video_normal: VideoClip = null!;
|
||||
|
||||
@property(Node) item_times: Node = null!;
|
||||
@property(Node) list_times: Node = null!;
|
||||
@property(Node) pnl_times: Node = null!;
|
||||
|
||||
|
||||
|
||||
/** 方块移动方向 */
|
||||
private _move_dir: M_DIR = M_DIR.CLOCKWISE;
|
||||
/** 是否正在游戏 */
|
||||
@@ -74,13 +88,15 @@ export class PageMain extends BaseView {
|
||||
/** 骰子数据 */
|
||||
private _game_data: any = null;
|
||||
/** 是否正在连续 */
|
||||
private _is_continuous : boolean = true
|
||||
private _is_continuous : boolean = false
|
||||
/** 棋盘数据 */
|
||||
private _board_data: any[] = []
|
||||
/** 消耗倍数索引 */
|
||||
private _ante_index : number = 0
|
||||
/** 倍数数据 */
|
||||
private _ante_data : any[] = null
|
||||
/** 剩余次数 */
|
||||
private _now_rest_times : number = 0
|
||||
|
||||
|
||||
/** 标签位置 */
|
||||
@@ -130,6 +146,7 @@ export class PageMain extends BaseView {
|
||||
this.onClickTips()
|
||||
this.bindVideoEvents()
|
||||
this.getConfig()
|
||||
this.initAutoTimes()
|
||||
|
||||
this._canvas = document.createElement('canvas');
|
||||
this._canvas.width = this.video_sprite.getComponent(UITransform).width;
|
||||
@@ -198,12 +215,50 @@ export class PageMain extends BaseView {
|
||||
this.initAnteSet()
|
||||
|
||||
Tools.httpReq("game/lotteryPool", {}, (res:any) => {
|
||||
this._board_data = res
|
||||
this.initBoradData()
|
||||
})
|
||||
this._board_data = res
|
||||
this.initBoradData()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
initAutoTimes(){
|
||||
for (let i = 0; i < AUTO_TIMES.length; i++) {
|
||||
const str = AUTO_TIMES[i]
|
||||
let item = Tools.AddChild(this.list_times, this.item_times)
|
||||
item.active = true
|
||||
Tools.SetChildText(item, "lab", str)
|
||||
Tools.SetTouchEndEvt(item, () => {
|
||||
if (str == "∞"){
|
||||
this._now_rest_times = -1
|
||||
} else{
|
||||
this._now_rest_times = parseInt(str)
|
||||
}
|
||||
this._is_continuous = true
|
||||
this.hideSelectTimes()
|
||||
if (USERDATA.coin >= this._ante_data[this._ante_index].mult * DEFAULT_COST){
|
||||
this.btnGameStart()
|
||||
Tools.ActChild(this.btn_auto, "lab", false)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
hideSelectTimes(){
|
||||
this.pnl_times.active = false
|
||||
}
|
||||
|
||||
switchAuto(){
|
||||
if (this._is_continuous){
|
||||
this._is_continuous = false
|
||||
this._now_rest_times = 0
|
||||
Tools.ActChild(this.btn_auto, "lab", true)
|
||||
Tools.SetChildText(this.btn_auto, "times", "")
|
||||
}else {
|
||||
if (this._is_playing) return
|
||||
this.pnl_times.active = true
|
||||
}
|
||||
}
|
||||
|
||||
initAnteSet(){
|
||||
let d = this._ante_data[this._ante_index]
|
||||
this.lab_ante.string = d.name
|
||||
@@ -212,6 +267,7 @@ export class PageMain extends BaseView {
|
||||
}
|
||||
|
||||
btnAnteAdd(){
|
||||
if (this._is_playing) return
|
||||
if (this._ante_index < this._ante_data.length - 1) {
|
||||
this._ante_index++
|
||||
this.initAnteSet()
|
||||
@@ -220,6 +276,7 @@ export class PageMain extends BaseView {
|
||||
}
|
||||
|
||||
btnAnteSub(){
|
||||
if (this._is_playing) return
|
||||
if (this._ante_index > 0) {
|
||||
this._ante_index--
|
||||
this.initAnteSet()
|
||||
@@ -273,6 +330,14 @@ export class PageMain extends BaseView {
|
||||
this._is_playing = true
|
||||
|
||||
this.lab_earn.string = ""
|
||||
this.btn_ante_sub.getComponent(Sprite).grayscale = true
|
||||
this.btn_ante_add.getComponent(Sprite).grayscale = true
|
||||
this.btn_play.getComponent(Sprite).grayscale = true
|
||||
|
||||
if (this._is_continuous){
|
||||
this._now_rest_times = this._now_rest_times == -1 ? -1 : this._now_rest_times - 1
|
||||
Tools.SetChildText(this.btn_auto, "times", this._now_rest_times == -1 ? "∞" : this._now_rest_times.toString())
|
||||
}
|
||||
|
||||
Tools.httpReq("game/playStart", {
|
||||
"direction" : this._move_dir,
|
||||
@@ -290,7 +355,6 @@ export class PageMain extends BaseView {
|
||||
steps += element
|
||||
}
|
||||
let index:any = this._board_data.findIndex(v => v.grid_number == steps.toString())
|
||||
console.log("steps", steps, index)
|
||||
let b = this.blocks[index]
|
||||
|
||||
// 计算移动路径
|
||||
@@ -307,6 +371,7 @@ export class PageMain extends BaseView {
|
||||
// 如果是豹子,展示豹子特效后停止继续
|
||||
if (baozi){
|
||||
this.scheduleOnce(() => {
|
||||
this.resetStopGame()
|
||||
app.manager.sound.playEffect({name : "effect/eff_unsheathe"})
|
||||
for (let i = 0; i < this.dices.length; i++) {
|
||||
let eff = this.dices[i].getChildByPath("dice/eff")
|
||||
@@ -489,13 +554,15 @@ export class PageMain extends BaseView {
|
||||
if (this._is_continuous){
|
||||
let lab = Tools.AddChild(this.lab_point, this._game_data.win_coin > 0 ? this.lab_add : this.lab_sub)
|
||||
let cb = () => {
|
||||
lab.destroy()
|
||||
USERDATA.coin = this._game_data.coin
|
||||
this.initUserData()
|
||||
if (USERDATA.coin >= this._ante_data[this._ante_index].mult * DEFAULT_COST){
|
||||
this.btnGameStart()
|
||||
}
|
||||
}
|
||||
lab.destroy()
|
||||
USERDATA.coin = this._game_data.coin
|
||||
this.initUserData()
|
||||
if (USERDATA.coin >= this._ante_data[this._ante_index].mult * DEFAULT_COST && (this._now_rest_times > 0 || this._now_rest_times == -1)){
|
||||
this.btnGameStart()
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
// T5是再来一次,不需要飘字
|
||||
if (this._game_data.tier != "T5"){
|
||||
let pos = new Vec3(node.parent.position.x, node.parent.position.y + 80, 0 )
|
||||
@@ -526,7 +593,7 @@ export class PageMain extends BaseView {
|
||||
}
|
||||
}
|
||||
USERDATA.coin = this._game_data.coin
|
||||
USERDATA.total_ticket_count = this._game_data.total_ticket_count
|
||||
this.resetStopGame()
|
||||
this.initUserData()
|
||||
}
|
||||
}
|
||||
@@ -537,6 +604,14 @@ export class PageMain extends BaseView {
|
||||
blink();
|
||||
}
|
||||
|
||||
resetStopGame(){
|
||||
this._is_continuous = false
|
||||
Tools.ActChild(this.btn_auto, "lab", true)
|
||||
Tools.SetChildText(this.btn_auto, "times", "")
|
||||
this.btn_play.getComponent(Sprite).grayscale = false
|
||||
this.initAnteSet()
|
||||
}
|
||||
|
||||
/** 播放骰子动画 */
|
||||
playDiceAni(array:any[]){
|
||||
app.manager.sound.playEffect({name : "effect/shaizi"})
|
||||
|
||||
Reference in New Issue
Block a user