| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- import GameM, { AUDIO_TYPE } from "../../manager/GameM";
- import PoolMgr, { NODEPOOLPREFABTYPE } from "../../manager/PoolMgr";
- import UiM from "../../manager/UiM";
- import Random from "../../utils/Random";
- import ClubMain from "../ClubMain";
- import EffectNode from "../EffectNode";
- import ClubShouquShanggong from "./ClubShouquShanggong";
- import ClubTixianNode from "./ClubTixianNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class ClubActiveNode extends cc.Component {
- @property(cc.Node)
- bubleOne: cc.Node = null;
- @property(cc.Node)
- bubleTwo: cc.Node = null;
- @property(cc.Node)
- bubleThree: cc.Node = null;
- @property(cc.Label)
- moneyLabel: cc.Label = null
- @property(cc.Label)
- moneyTwoLabel: cc.Label = null
- @property(cc.Node)
- dailyNode: cc.Node = null
- @property(cc.Node)
- otherNode: cc.Node = null
- @property(sp.Skeleton)
- bubbleBreak: sp.Skeleton = null
- @property(cc.Node)
- iconNode: cc.Node = null
- @property(cc.Node)
- bgNode: cc.Node = null
- @property(cc.Node)
- bubblePNode: cc.Node = null
- @property(cc.Node)
- bigBubbleNode: cc.Node = null
- @property(cc.Node)
- dangweiNode: cc.Node = null
- @property(cc.Node)
- bigBubbleIcon:cc.Node = null
- @property([cc.SpriteFrame])
- tixianSpriteFrame:cc.SpriteFrame[] = []
- bubleDataOne = null
- bubleDataTwo = null
- bubleDataThree = null
- private dailyTixianInfo = null
- private maxTixianInfo = null
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- start() {
- this.bubleOne.active = false
- this.bubleTwo.active = false
- this.bubleThree.active = false
- let addY = cc.winSize.height - 1334
- // this.bgNode.height += addY
- this.bubblePNode.y = this.bubblePNode.y - addY * 0.25
- this.bigBubbleNode.y = this.bigBubbleNode.y - addY * 0.25
- this.dangweiNode.y = this.dangweiNode.y - addY * 0.25
- GameM.ClubData.requestClubMyBubbleData()
- GameM.ClubData.requestClubWithdrawDenominations()
- this.updateMoney()
- }
- updateTimes() {
- // this.leftTimesLabel.string = "剩余提现次数:" + GameM.commonData.roleData.clubLeijiTixian + "/2"
- }
- updateView(data) {
- if (data == null || data == undefined) {
- this.showEmptyBubble()
- this.downTime = -1
- return
- }
- this.bubleOne.active = false
- this.bubleTwo.active = false
- this.bubleThree.active = false
- if (data.length == 0) {
- this.showEmptyBubble()
- this.downTime = -1
- return
- }
- for (let i = 0; i < 3; i++) {
- let node: cc.Node = null
- if (i == 0) {
- node = this.bubleOne
- this.bubleDataOne = data[i]
- } else if (i == 1) {
- node = this.bubleTwo
- this.bubleDataTwo = data[i]
- } else if (i == 2) {
- node = this.bubleThree
- this.bubleDataThree = data[i]
- }
- this.initBubleNode(node, data[i])
- }
- }
- showEmptyBubble() {
- this.bubleOne.active = false
- this.bubleTwo.active = true
- this.bubleThree.active = false
- this.bubleDataTwo = null
- this.bubleTwo.getChildByName("num").getComponent(cc.Label).string = "结算中"
- this.bubleTwo.getChildByName("time").getComponent(cc.Label).string = ""
- this.bubleTwo.getChildByName("icon").getComponent(cc.Button).interactable = true
- this.bubleTwo.getChildByName("qipaoNormal").active = true
- this.bubleTwo.getChildByName("qipaoGrey").active = false
- this.bubleTwo.getChildByName("desc").getComponent(cc.Label).string = ""
- }
- initBubleNode(node: cc.Node, info) {
- if (info == null || info == undefined) {
- return
- }
- node.active = true
- node.getChildByName("num").getComponent(cc.Label).string = info.coinNum
- if (info.expired) {
- node.getChildByName("qipaoNormal").active = false
- node.getChildByName("qipaoGrey").active = true
- node.getChildByName("time").getComponent(cc.Label).string = "已过期"
- node.getChildByName("icon").getComponent(cc.Button).interactable = false
- node.getChildByName("desc").getComponent(cc.Label).string = ""
- node.getChildByName("desc").color = cc.Color.WHITE
- } else {
- node.getChildByName("qipaoNormal").active = true
- node.getChildByName("qipaoGrey").active = false
- node.getChildByName("time").getComponent(cc.Label).string = ""
- node.getChildByName("icon").getComponent(cc.Button).interactable = true
- let num = Number(info.generation)
- node.getChildByName("desc").color = cc.color(255,253,88)
- let str = ""
- if(num == 1){
- str = "一代贡献"
- }else if(num == 2){
- str = "二代贡献"
- }else if(num == 3){
- str = "三代贡献"
- }else if(num == 4){
- str = "四代贡献"
- }else if(num == 5){
- str = "五代贡献"
- }
- node.getChildByName("desc").getComponent(cc.Label).string = str
- if(this.downTime <= 0){
- if(this.downTime <= 0){
- let currentTime = Date.now()
- let hours = new Date(currentTime).getHours()
- let minitus = new Date(currentTime).getMinutes()
- let second = new Date(currentTime).getSeconds()
- let leftTime = -1
- if (hours > 12) {
- leftTime = 36*3600 - hours*3600 - minitus*60 - second
- }else{
- leftTime = 12*3600 - hours*3600 - minitus*60 - second
- }
-
- let time = leftTime
- this.downTime = time
- }
- }
- }
- }
- initTixianBtn(data) {
- if (data == null || data == undefined) {
- return
- }
- this.dailyTixianInfo = null
- this.maxTixianInfo = null
- let count = 0
- for (let entry of data) {
- if (entry.gearNo == 0) {
- this.dailyTixianInfo = entry
- this.setNodeInfo(this.dailyNode, entry)
- } else {
- count ++
- //设置累计提现档位,用于统计上报
- //每日统计不记录档位
- entry.umIndex = count
- if (entry.status == 1) {
- this.maxTixianInfo = entry
- this.setNodeInfo(this.otherNode, entry)
- }
- }
- }
- if (this.maxTixianInfo == null) {
- for (let i = 0; i < data.length; i++) {
- if (data[i].gearNo != 0 && data[i].withdrawTimestamp != 0 && data[i + 1] && data[i + 1].withdrawTimestamp == 0) {
- this.maxTixianInfo = data[i + 1]
- this.setNodeInfo(this.otherNode, data[i + 1])
- break
- }
- }
- }
- if (this.maxTixianInfo == null) {
- this.maxTixianInfo = data[data.length - 1]
- this.setNodeInfo(this.otherNode, data[data.length - 1])
- }
- }
- setNodeInfo(node: cc.Node, info) {
- if (info.amount % 10000 != 0) {
- node.getChildByName("moneyLabel").getComponent(cc.Label).string = (info.amount / 10000).toFixed(2) + "元"
- } else {
- node.getChildByName("moneyLabel").getComponent(cc.Label).string = (info.amount / 10000) + "元"
- }
- if (info.status == 0) {
- // node.getComponent(cc.Button).interactable = true
- node.getComponent(cc.Sprite).spriteFrame = this.tixianSpriteFrame[2]
- } else {
- if(info.gearNo == 0){
- node.getComponent(cc.Sprite).spriteFrame = this.tixianSpriteFrame[1]
- }else{
- node.getComponent(cc.Sprite).spriteFrame = this.tixianSpriteFrame[0]
- }
- // node.getComponent(cc.Button).interactable = false
- }
- if (info.gearNo == 0) {
- node.getChildByName("tishi").getChildByName("tishiLabel").getComponent(cc.Label).string = "每日"
- } else {
- if (GameM.ClubData.clubBaseInfo.currentAddition > 0) {
- node.getChildByName("tishi").active = true
- node.getChildByName("tishi").getChildByName("tishiLabel").getComponent(cc.Label).string = "多" + GameM.ClubData.clubBaseInfo.currentAddition + "%"
- } else {
- node.getChildByName("tishi").active = false
- }
- }
- }
- updateMoney() {
- if (GameM.ClubData.clubBaseInfo) {
- let totalMoney = GameM.ClubData.clubBaseInfo.pool
- this.moneyLabel.string = ""
- this.moneyTwoLabel.string = (totalMoney / 10000).toFixed(2) + "元"
- }
- }
- showShouyiNode() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- cc.loader.loadRes('prefabs/club/clubShouyiInfo', cc.Prefab, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- let node: cc.Node = cc.instantiate(assets)
- node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- })
- }
- showBubleOne() {
- // return
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- this.showShangGongView(this.bubleDataOne, this.bubleOne)
- }
- showBubleTwo() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- if (this.bubleDataTwo == null || this.bubleDataTwo == undefined) {
- this.showShouyiNode()
- return
- }
- // UiM.Instance.clubMainNode.getComponent(ClubMain).activeNode.getComponent(ClubActiveNode).showIconFly(this.bubleTwo)
- // return
- this.showShangGongView(this.bubleDataTwo, this.bubleTwo)
- }
- showBubleThree() {
- // UiM.Instance.clubMainNode.getComponent(ClubMain).topNode.getComponent(ClubTopNode).showLevelUp()
- // return
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- this.showShangGongView(this.bubleDataThree, this.bubleThree)
- }
- showShangGongView(info, bubbleNode) {
- if (info == null || info == undefined) {
- return
- }
- cc.loader.loadRes('prefabs/club/clubShouquShanggong', cc.Prefab, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- let node: cc.Node = cc.instantiate(assets)
- node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- node.getComponent(ClubShouquShanggong).initView(info, bubbleNode)
- })
- }
- clickDailyTixian() {
- // this.showIconFly(this.bubleTwo)
- // UiM.Instance.clubMainNode.getComponent(ClubMain).topNode.getComponent(ClubTopNode).showLevelUp()
- // return
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- if(this.dailyTixianInfo.status == 0){
- EffectNode.instance.PlayTip("今日已提现")
- return
- }
- if (GameM.ClubData.clubBaseInfo.pool < this.dailyTixianInfo.amount) {
- EffectNode.instance.PlayTip("功德币不足")
- return
- }
- this.readyToLingqu(1 + "", this.dailyTixianInfo.amount / 10000, GameM.ClubData.clubBaseInfo.totalRecruitNum,-1)
- // GameM.ClubData.requestClubDoWithdraw(GameM.commonData.version, 1 + "", GameM.ClubData.clubBaseInfo.totalRecruitNum, this.dailyTixianInfo.amount / 10000)
- }
- clickOtherTixian() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- if(this.maxTixianInfo.status == 0){
- EffectNode.instance.PlayTip("今日提现次数不足")
- return
- }
- if (GameM.ClubData.clubBaseInfo.pool < this.maxTixianInfo.amount) {
- EffectNode.instance.PlayTip("功德币不足")
- return
- }
- let money = (1+GameM.ClubData.clubBaseInfo.currentAddition/100)*this.maxTixianInfo.amount
- if(money % 10000 != 0){
- let tempMoney = (money/10000).toFixed(2)
- money = Number(tempMoney)
- }else{
- money = Math.floor(money/10000)
- }
- this.readyToLingqu(2 + "", money, GameM.ClubData.clubBaseInfo.totalRecruitNum,this.maxTixianInfo.umIndex)
- // GameM.ClubData.requestClubDoWithdraw(GameM.commonData.version, 2 + "", GameM.ClubData.clubBaseInfo.totalRecruitNum, this.maxTixianInfo.amount / 10000)
- }
- updateTixianInfo(type) {
- if (type == 1) {
- this.dailyNode.getComponent(cc.Button).interactable = false
- } else {
- this.otherNode.getComponent(cc.Button).interactable = false
- }
- }
- showBubbleBreak(bubbleNode: cc.Node,callback=null) {
- bubbleNode.active = false
- this.bubbleBreak.node.position = bubbleNode.position
- this.bubbleBreak.node.active = true
- this.bubbleBreak.setAnimation(0, 'animation', false);
- this.scheduleOnce(() => {
- GameM.ClubData.requestClubMyBubbleData()
- }, 1)
- }
- showIconFly(bubbleNode: cc.Node) {
- // this.iconNode.position = bubbleNode.position
- // this.iconNode.active = true
- let targetPos = cc.v2(5, 18)
- this.showBubbleBreak(bubbleNode)
- bubbleNode.active = false
- this.PlayCoinAnim(12, 20, cc.v2(bubbleNode.position));
- // this.iconNode.runAction(cc.sequence(cc.moveTo(0.5, targetPos), cc.callFunc(() => {
- // this.iconNode.active = false
- // GameM.ClubData.requestClubMyBubbleData()
- // })))
- }
- readyToLingqu(type, money, peopleNum,index) {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- // this.tixianNode.active = true
- cc.loader.loadRes('prefabs/club/ClubTixianNode', cc.Prefab, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- let node: cc.Node = cc.instantiate(assets)
- node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
- UiM.Instance.openPanel(node)
- node.getComponent(ClubTixianNode).initView(type, money, peopleNum,index)
- })
- }
- /**
- * @param type 类型,0 金币,1 红包币 3 鲜花 5 活跃
- */
- public PlayCoinAnim(type: number = 0, num: number, pos: cc.Vec2, fly: boolean = true) {
- let cam_pos;
- let tempPos3D = pos
- pos = cc.v2(tempPos3D.x, tempPos3D.y);
- for (let i = 0; i < num; i++) {
- //FC:-
- //let copyCoin = cc.instantiate(this.eftPrefabs[type]);//type == 0 ? this.coinPrefab : this.goldPrefab);
- //FC:+ 对象池
- let copyCoin = null;
- copyCoin = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.ClubIcon);
- copyCoin.setParent(this.node);
- copyCoin.scale = Random.Range(0.8, 1.2, false);
- copyCoin.angle = Random.Range(-45, 45, false);
- let dir = cc.v2(Random.Range(-1, 1, false), Random.Range(-1, 1, false));
- dir = dir.normalize();
- let deltaInit = cc.v2(Random.Range(10, 160, false) * dir.x, Random.Range(10, 160, false) * dir.y);
- //FC:-无效计算
- //let deltaEnd = cc.v2(Random.Range(250, 800, false) * dir.x, Random.Range(250, 800, false) * dir.y);
- let initPos = pos.add(deltaInit);
- //copyCoin.setPosition(initPos);
- copyCoin.setPosition(pos);
- this.FlyIn(type, copyCoin, initPos, fly);
- }
- }
- FlyIn(type: number = 0, target: cc.Node, end: cc.Vec2, fly: boolean) {
- let ac1
- if (fly) {
- ac1 = cc.moveTo(Random.Range(0.3, 1, false), end).easing(cc.easeSineOut());
- }
- else {
- ac1 = cc.moveTo(Random.Range(0.3, 0.6, false), end).easing(cc.easeSineOut());
- }
- let callback = cc.callFunc(() => {
- //target.destroy();
- if (fly) {
- let tarWorldPos = this.bigBubbleIcon.parent.convertToWorldSpaceAR(this.bigBubbleIcon.position)
- let curLocalPos = this.node.convertToNodeSpaceAR(tarWorldPos)
- this.scheduleOnce(() => { this.FlyOut(type, target, cc.v2(curLocalPos) )}, 0);
- }
- });
- let total = cc.sequence(ac1, callback);
- target.runAction(total);
- }
- FlyOut(type: number = 0, target: cc.Node, end: cc.Vec2) {
- let dur = Random.Range(0.3, 1, false);
- target.runAction(cc.scaleTo(dur, 0.8));
- let ac1 = cc.moveTo(dur, end).easing(cc.easeSineOut());
- let callback = cc.callFunc(() => {
- //FC:-
- //target.destroy();
- //FC:+ 对象池
- PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.ClubIcon, target);
- //type == 0 ? this.CoinIconAni() : this.RedMoneyIconAni();
- });
- let total = cc.sequence(ac1, callback);
- target.runAction(total);
- }
- private downTime = -1
- private secondTime = 0
- update (dt) {
- if(this.downTime<0){
- return
- }
- this.secondTime+=dt
- if(this.secondTime >=1){
- this.downTime -= this.secondTime
- this.secondTime = 0
- if(this.downTime <0 ){
- GameM.ClubData.requestClubMyBubbleData()
- return
- }
- this.checkNeedShowTime()
- }
- }
- checkNeedShowTime(){
- let timeStr = this.getTimeTxt()
- if(this.bubleDataOne && !this.bubleDataOne.expired){
- this.bubleOne.getChildByName("time").getComponent(cc.Label).string = timeStr
- }
- if(this.bubleDataTwo && !this.bubleDataTwo.expired){
- this.bubleTwo.getChildByName("time").getComponent(cc.Label).string = timeStr
- }
- if(this.bubleDataThree && !this.bubleDataThree.expired){
- this.bubleThree.getChildByName("time").getComponent(cc.Label).string = timeStr
- }
- }
- getTimeTxt():string{
- if(this.downTime<=0){
- return ""
- }
- let hour = Math.floor(this.downTime/3600)
- let minitue = Math.floor((this.downTime%3600)/60)
- let second = Math.floor(this.downTime%60)
- let hourstr = ""
- let minituesStr = ""
- let secondsStr = ""
- if(hour <10){
- hourstr = "0"+hour
- }else{
- hourstr = hour+""
- }
- if(minitue<10){
- minituesStr = "0"+minitue
- }else{
- minituesStr = minitue+""
- }
- if(second<10){
- secondsStr ="0"+ second
- }else{
- secondsStr = second+""
- }
- return hourstr+":"+minituesStr+":"+secondsStr
- }
- }
|