110 lines
3.1 KiB
JavaScript
110 lines
3.1 KiB
JavaScript
|
import AudioUtil from "../ts/core/AudioUtil";
|
||
|
import GameModel from "../ts/core/GameModel";
|
||
|
import GameUtil from "../ts/core/GameUtil";
|
||
|
import active_panel from "../ts/zhenFa/active_panel";
|
||
|
|
||
|
const XwItem_Count = (8)
|
||
|
|
||
|
const ZhenFaPos = {
|
||
|
type_Ridge:0, //坎位
|
||
|
type_Gen:1, //艮位
|
||
|
type_Kun:2, //坤位
|
||
|
type_Earth:3, //震位
|
||
|
type_Leave:4, //離位
|
||
|
type_Exchange:5, //兌位
|
||
|
type_Xun:6, //巽位
|
||
|
type_Dry:7, //乾位
|
||
|
}
|
||
|
|
||
|
cc.Class({
|
||
|
extends: cc.Component,
|
||
|
|
||
|
properties: {
|
||
|
xwItem:cc.Prefab,
|
||
|
},
|
||
|
|
||
|
init() {
|
||
|
this.addAllItem()
|
||
|
this.CancelItemActive()
|
||
|
this.CancelItemSelect()
|
||
|
var self = this
|
||
|
this.node.on("onDownItem", (result) => {
|
||
|
this.CancelItemSelect()
|
||
|
var item = self.node.getChildByName("xinwuitem" + result.index)
|
||
|
if (!!item) {
|
||
|
item.getComponent('xwItem').setSelectState(1)
|
||
|
}
|
||
|
self.node.parent.emit('OpenWxList',result)
|
||
|
}, this);
|
||
|
},
|
||
|
|
||
|
addAllItem() {
|
||
|
var node = this.node.getChildByName("spBack")
|
||
|
if (!node) return
|
||
|
let pos = node.getPosition()
|
||
|
const r = 160
|
||
|
var item = null
|
||
|
const angle = 360 / XwItem_Count
|
||
|
for (var i = 0;i < XwItem_Count;++i) {
|
||
|
item = cc.instantiate(this.xwItem)
|
||
|
if (!!item) {
|
||
|
var ary = [2,1,0,7,6,5,4,3]
|
||
|
let x = pos.x + r * Math.cos((angle * ary[i]) * 3.14 / 180)
|
||
|
let y = pos.y + r * Math.sin((angle * ary[i]) * 3.14 / 180)
|
||
|
item.setPosition(x,y)
|
||
|
item.setScale(0.75)
|
||
|
item.setName("xinwuitem" + i)
|
||
|
item.active = true
|
||
|
this.node.addChild(item)
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
CancelItemSelect() {
|
||
|
var item = null
|
||
|
for (var i = 0;i < XwItem_Count;++i) {
|
||
|
item = this.node.getChildByName("xinwuitem" + i)
|
||
|
if (!!item) {
|
||
|
item.getComponent('xwItem').setSelectState(0)
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
CancelItemActive() {
|
||
|
var item = null
|
||
|
for (var i = 0;i < XwItem_Count;++i) {
|
||
|
item = this.node.getChildByName("xinwuitem" + i)
|
||
|
if (!!item) {
|
||
|
item.getComponent('xwItem').setActiveState(0)
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
updateUI(index,info) {
|
||
|
const size = info.length
|
||
|
for (var i = 0;i < size;++i) {
|
||
|
var item = this.node.getChildByName("xinwuitem" + i)
|
||
|
if (!!item) {
|
||
|
item.getComponent('xwItem').updateItem(info[i])
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var title = this.node.getChildByName("strTitle")
|
||
|
if (!!title) {
|
||
|
const TITLE_COUNT = 4
|
||
|
for (var i = 0;i < TITLE_COUNT;++i) {
|
||
|
var str = title.getChildByName("title" + (i + 1))
|
||
|
str.getComponent(cc.Label).string = GameModel.game_conf.ZhenFa[index].title[i]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
onDownActive(e, d) {
|
||
|
var parent = this.node.getParent()
|
||
|
AudioUtil.playCloseAudio();
|
||
|
this.unscheduleAllCallbacks();
|
||
|
active_panel.Instance.setDelegte(parent.getComponent("RolePanel"))
|
||
|
active_panel.Instance.openActivePanel()
|
||
|
}
|
||
|
});
|