| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172 |
- import { HTTP_TYPE } from "../datas/CommonData";
- import { RichData, RichPropItemParam } from "../datas/RichData";
- import Main from "../Main";
- import { GameController } from "../manager/GameController";
- import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
- import GuideMng from "../manager/GuideMng";
- import HttpM from "../manager/HttpM";
- import UiM from "../manager/UiM";
- import RoadItem from "../other/item/RoadItem";
- import Roads from "../other/item/Roads";
- import { EventMng } from "../tools/EventMng";
- import MyExtends, { PlayerPrefs } from "../tools/MyExtends";
- import BasePanel from "../uiFrames/BasePanel";
- import UIMng, { PanelType } from "../uiFrames/UIMng";
- import Random from "../utils/Random";
- import Sciencen_M from "../utils/Sciencen_M";
- import { Utils } from "../utils/Utils";
- import EffectNode from "./EffectNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class RichPanel extends BasePanel {
- @property(cc.Node)
- bgRoot: cc.Node = null;
- @property(cc.Node)
- bg: cc.Node = null;
- @property(cc.Node)
- mapBgParent: cc.Node = null;
- @property(cc.Node)
- bgObj: cc.Node = null;
- @property(cc.Node)
- roadParent: cc.Node = null;
- @property(cc.Node)
- tipQiPao: cc.Node = null;
- @property(cc.Node)
- diceNode: cc.Node = null;
- @property(cc.Sprite)
- diceTouchImg: cc.Sprite = null;
- @property(cc.Node)
- diceNo1: cc.Node = null;
- @property(cc.Node)
- diceNo2: cc.Node = null;
- @property(cc.Node)
- diceDoubleSign: cc.Node = null;
- @property(cc.Label)
- txtDiceNum: cc.Label = null;
- @property(cc.Node)
- diceNode1: cc.Node = null;
- @property(cc.Sprite)
- diceSliderImg: cc.Sprite = null;
- @property(cc.Node)
- diceSliderSign: cc.Node = null;
- @property(cc.Label)
- txtDiceNumSign: cc.Label = null;
- @property(cc.Node)
- diceNode2: cc.Node = null;
- @property(cc.Sprite)
- diceSliderImg2: cc.Sprite = null;
- @property(cc.Node)
- diceSliderSign2: cc.Node = null;
- @property(cc.Label)
- txtDiceNumSign2: cc.Label = null;
- @property(cc.Node)
- timeRevertNode: cc.Node = null;
- @property(cc.Label)
- txtUpdate: cc.Label = null;
- @property(cc.Node)
- doubleNode: cc.Node = null;
- @property(cc.Sprite)
- doubleSliderImg: cc.Sprite = null;
- @property(cc.Node)
- doubleFullSgin: cc.Node = null;
- @property(cc.Node)
- ctrlNode: cc.Node = null;
- @property(cc.Sprite)
- ctrlSliderImg: cc.Sprite = null;
- @property(cc.Node)
- ctrlFullSgin: cc.Node = null;
- @property(cc.Node)
- ctrlFreeBtn: cc.Node = null;
- @property(cc.Node)
- headNode: cc.Node = null;
- @property(cc.Node)
- headQiPao: cc.Node = null;
- @property(cc.RichText)
- txtHeadQiPao: cc.RichText = null;
- @property(cc.Node)
- touchValid: cc.Node = null;
- @property(cc.Sprite)
- touchValidSlider: cc.Sprite = null;
- @property(sp.Skeleton)
- touchSpine: sp.Skeleton = null;
- @property(cc.Node)
- finger: cc.Node = null;
- @property(sp.Skeleton)
- diceSpine: sp.Skeleton = null;
- @property(cc.Sprite)
- diceCur: cc.Sprite = null;
- @property(sp.Skeleton)
- tangSpine: sp.Skeleton = null;
- @property(cc.Node)
- private tsQipao: cc.Node = null;
- @property(cc.Label)
- private tsDice: cc.Label = null;
- @property(cc.Node)
- bookBtnImg: cc.Node = null;
- @property(cc.Label)
- txtBook: cc.Label = null;
- @property(cc.Node)
- pointBook: cc.Node = null;
- @property(cc.Node)
- eft_ctrlCard: cc.Node = null;
- @property(cc.Node)
- eft_doubleCard: cc.Node = null;
- @property(cc.Node)
- eft_cszNode: cc.Node = null;
- @property(sp.Skeleton)
- eft_cszSpine: sp.Skeleton = null;
- @property(cc.Node)
- eft_csz1: cc.Node = null;
- @property(cc.Node)
- eft_csz2: cc.Node = null;
- @property(cc.Label)
- eft_csztxt: cc.Label = null;
- @property(cc.Node)
- eft_particle: cc.Node = null;
- @property(cc.Node)
- panel_gift: cc.Node = null;
- @property(cc.Node)
- panel_gift_panel: cc.Node = null;
- @property(cc.Node)
- gift_titles: cc.Node[] = [];
- //@property(cc.Label)
- //txtTilteGift: cc.Label = null;
- @property(cc.Label)
- txtGiftType: cc.Label = null;
- @property(cc.Label)
- txtGiftDice: cc.Label = null;
- @property(cc.Node)
- inputMask: cc.Node = null;
- @property(cc.Prefab)
- pfb_Road: cc.Prefab = null;
- isDiceTimer: boolean = false;
- diceMinTime: number = 1;
- diceMaxTime: number = 10;
- diceSpeed: number = 0.4;
- diceTimer: number = 0;
- //diceSlider: number = 0;
- speed: number = 1
- //骰子恢复
- isRevertDice: boolean = false;
- revertTimer: number = 0;
- lastStandMode: number = 0;
- curStepNum: number = 0;
- needStepNum: number = 1;
- isNewPlayGift: boolean = false;
- private isGoldDice: boolean = false;
- private isInit: boolean = false;
- onLoad() {
- this.diceNode.on(cc.Node.EventType.TOUCH_START, this.OnDiceTouchStart, this);
- this.diceNode.on(cc.Node.EventType.TOUCH_END, this.OnDiceTouchEnd, this);
- this.diceNode.on(cc.Node.EventType.TOUCH_CANCEL, this.OnDiceTouchEnd, this);
- this.bgRoot.on(cc.Node.EventType.TOUCH_CANCEL, this.OnScreenTouch, this);
- this.diceMinTime = RichData.Ins.richItemCardCfg.diceChargeMin;
- this.diceMaxTime = RichData.Ins.richItemCardCfg.diceChargeMax;
- this.diceSpeed = RichData.Ins.richItemCardCfg.diceSpeed;
- //this.tsQipao = this.tangSpine.node.getChildByName("qipao");
- //this.tsDice = this.tangSpine.node.getChildByName("qipao/dice").getComponent(cc.Sprite);
- //console.log("0--------->Child Name:" + this.tsDice.spriteFrame.name);
- console.log("this.di---------------------------" + this.diceMinTime + " Max:" + this.diceMaxTime + " Speed:" + this.diceSpeed);
- EventMng.Register_Event("NewPlayGift", this.NewPlayGift, this);
- }
- OnEnter() {
- this.Init();
- this.node.active = true;
- RichData.Ins.isOpenRichPanel = true;
- GameM.audioM.setPauseMusic();
- GameM.audioM.playMateEffect(AUDIO_TYPE.sutrabgm, true);
- this.CheckCanCollectBook();
- }
- OnExit() {
- this.node.active = false;
- this.tipQiPao.active = false;
- RichData.Ins.isOpenRichPanel = false;
- GameController.Ins.SwitchAudio(3);
- UiM.Instance.hallNode.getComponent(Main).UpdateRichManQipao();
- }
- update(dt) {
- this.TimerDiceTouch(dt);
- this.TimerRevertDice(dt);
- }
- Init() {
- if (!this.isInit) {
- this.isInit = true;
- let road = cc.instantiate(this.pfb_Road);
- this.roadParent.addChild(road);
- let roadsScr = road.getComponent(Roads);
- RichData.Ins.MapInit(this, this.bgRoot, this.bg, roadsScr);
- this.UpdateInfo();
- this.PanelActiveInit();
- this.CheckNewDayGift();
- } else {
- //页面刷新
- RichData.Ins.RichPanelUpdateInit();
- }
- //HttpM.Instance.SendData(HTTP_TYPE.richManInitCardInfo, {}, (res) => {
- // console.log("--->Init Info:", res);
- // //if (res.data != null && res.data.code == 1) {
- // // UIMng.Ins.GetPanel(PanelType.RichCollectPanel).OnEnter(res.data.fairyjadec);
- // //} else {
- // // console.log("request fail : msg:" + res.errmsg);
- // //}
- //}, null, (res) => {
- // console.log("--->Init Info Error:", res);
- //}, null, false);
- }
- CheckNewDayGift() {
- if (RichData.Ins.newPlayer == 1) {
- PlayerPrefs.SetInt("RichNewDay", (new Date()).getDate());
- this.isNewPlayGift = true;
- this.txtDiceNum.string = (RichData.Ins.diceTotalNum - RichData.Ins.richItemCardCfg.diceNewPlayer) + "";
- //this.scheduleOnce(() => {
- // //引导取经 大富翁
- // GuideMng.Ins.CheckRichGuide26();
- // //GuideMng.Ins.CheckRichGuide21();
- //}, 0.15);
- } else {
- let d = new Date();
- if (PlayerPrefs.GetInt("RichNewDay", -1) != d.getDate()) {
- this.isNewPlayGift = false;
- this.gift_titles[0].active = false;
- this.gift_titles[1].active = true;
- this.txtGiftType.string = "每天都会赠送哦!";
- this.txtGiftDice.string = "x" + RichData.Ins.richItemCardCfg.diceDailyNum;
- this.panel_gift_panel.scale = 0;
- this.panel_gift.active = true;
- cc.tween(this.panel_gift_panel).to(0.2, { scale: 1 }, { easing: "backOut" })
- .call(() => {
- })
- .start();
- PlayerPrefs.SetInt("RichNewDay", d.getDate());
- }
- }
- //if (PlayerPrefs.GetInt("RichNewDay", 0) == 0) {
- // PlayerPrefs.SetInt("RichNewDay", (new Date()).getDate());
- // console.log("----Rich Day:" + PlayerPrefs.GetInt("RichNewDay"));
- // this.isNewPlayGift = true;
- // this.txtDiceNum.string = (RichData.Ins.diceTotalNum - RichData.Ins.richItemCardCfg.diceNewPlayer) + "";
- //} else {
- // let d = new Date();
- // if (PlayerPrefs.GetInt("RichNewDay", 0) != d.getDate()) {
- // this.isNewPlayGift = false;
- // this.gift_titles[0].active = false;
- // this.gift_titles[1].active = true;
- // this.txtGiftType.string = "每天都会赠送哦!";
- // this.txtGiftDice.string = "x" + RichData.Ins.richItemCardCfg.diceDailyNum;
- // this.panel_gift_panel.scale = 0;
- // this.panel_gift.active = true;
- // cc.tween(this.panel_gift_panel).to(0.2, { scale: 1 }, { easing: "backOut" })
- // .call(() => {
- // })
- // .start();
- // PlayerPrefs.SetInt("RichNewDay", d.getDate());
- // }
- //}
- }
- NewPlayGift() {
- if (RichData.Ins.newPlayer == 1) {
- this.gift_titles[0].active = true;
- this.gift_titles[1].active = false;
- this.txtGiftType.string = "获得新玩家专享奖励";
- this.txtGiftDice.string = "x" + RichData.Ins.richItemCardCfg.diceNewPlayer;
- this.panel_gift_panel.scale = 0;
- this.panel_gift.active = true;
- cc.tween(this.panel_gift_panel).to(0.2, { scale: 1 }, { easing: "backOut" })
- .call(() => {
- })
- .start();
- }
- }
- UpdateInfo() {
- this.txtDiceNum.string = RichData.Ins.diceTotalNum + "";
- //this.txtBook.string = RichData.Ins.scriptureNum + "";
- this.txtBook.string = Sciencen_M.instance.format(RichData.Ins.scriptureNum.toString()) + "/" + Sciencen_M.instance.format(RichData.Ins.scriptureNextNum.toString());
- if (RichData.Ins.diceTotalNum > 0) {
- this.diceNo1.active = false;
- this.diceNo2.active = false;
- this.diceTouchImg.node.active = true;
- } else {
- this.diceNo1.active = true;
- this.diceNo2.active = false;
- this.diceTouchImg.node.active = false;
- }
- if (RichData.Ins.doubleRemain > 0) {
- this.diceDoubleSign.active = true;
- this.headQiPao.active = true;
- this.txtHeadQiPao.string = "<b width=5>双倍奖励\n只有<color=red><size=30>" + RichData.Ins.doubleRemain + "次</size></color>了!</b>";
- if (!this.isGoldDice) {
- cc.loader.loadRes("xiyou/richman/dice_gold" + this.needStepNum, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.diceCur.spriteFrame = assets;
- this.isGoldDice = true;
- })
- }
- }
- else {
- this.diceDoubleSign.active = false;
- this.headQiPao.active = false;
- if (this.isGoldDice) {
- cc.loader.loadRes("xiyou/richman/dice_nor" + this.needStepNum, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.diceCur.spriteFrame = assets;
- this.isGoldDice = false;
- })
- }
- }
- this.ctrlSliderImg.fillRange = RichData.Ins.remoteCtrlNum / 3;
- this.ctrlFullSgin.active = RichData.Ins.remoteCtrlNum == 3;
- this.ctrlFreeBtn.active = RichData.Ins.remoteCtrlNum <= 0;
- this.doubleSliderImg.fillRange = RichData.Ins.doubleNum / 3;
- //console.log("-----------------------------" + (RichData.Ins.doubleNum / 3));
- this.doubleFullSgin.active = RichData.Ins.doubleNum == 3;
- //let url;
- //if (this.diceDoubleSign.active)
- // url = "xiyou/richman/dice_gold6";
- //else
- // url = "xiyou/richman/dice_nor6";
- ////url += Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1;
- //
- //cc.loader.loadRes(url, cc.SpriteFrame, (err, assets) => {
- // if (err) {
- // cc.error(err);
- // return;
- // }
- // this.diceTouchImg.spriteFrame = assets;
- //})
- }
- /**更新恢复骰子*/
- CheckUpdateRevertTime() {
- if (RichData.Ins.diceSingleRecoverTime != 0) {
- this.timeRevertNode.active = true;
- //let targetTime=new Date(RichData.Ins.diceRecoverTime);
- let deltaTime = RichData.Ins.diceSingleRecoverTime - (new Date()).getTime();
- console.log("----Update Revert Time:" + deltaTime + " ms:" + (deltaTime / 1000));
- //let time = Math.floor(deltaTime * 0.001) % (3600 / RichData.Ins.richItemCardCfg.diceRecover);
- //this.revertTimer = time == 0 ? (3600 / RichData.Ins.richItemCardCfg.diceRecover) : time;
- RichData.Ins.revertTimer = deltaTime * 0.001;
- //this.revertTimer = deltaTime * 0.001;
- //TEST
- //this.revertTimer = 1;
- this.isRevertDice = true;
- } else {
- this.isRevertDice = false;
- RichData.Ins.revertTimer = 0;
- //this.revertTimer = 0;
- this.timeRevertNode.active = false;
- }
- }
- CheckUpdateRevering() {
- return this.isRevertDice;
- }
- /**检查加载地图*/
- CheckLoadMap() {
- let type = RichData.Ins.CheckLoadMapType();
- if (type != 0) {
- let road = cc.instantiate(this.pfb_Road);
- this.roadParent.addChild(road);
- if (type == 1)
- road.setSiblingIndex(0);
- let roadsScr = road.getComponent(Roads);
- RichData.Ins.LoadMap(type, roadsScr);
- }
- }
- /**加载背景地图*/
- LoadMapBg(pos: cc.Vec2) {
- let bg = cc.instantiate(this.bgObj);
- this.mapBgParent.addChild(bg);
- bg.setPosition(pos);
- }
- TimerDiceTouch(dt) {
- if (this.isDiceTimer) {
- this.diceTimer += dt;
- if (this.touchValidSlider.fillRange >= 1) {
- //松开后消失
- // if (this.touchValid.active) {
- // this.touchValid.active = false;
- // this.touchSpine.node.active = true;
- // this.touchSpine.setAnimation(0, "animation", false);
- // setTimeout(() => {
- // this.touchSpine.node.active = false;
- // }, 1000);
- // }
- }
- else { this.touchValidSlider.fillRange = this.diceTimer / this.diceMinTime; }
- //this.diceSlider += dt;
- //slider1
- this.diceSliderSign.x = -165 + this.diceSliderImg.fillRange * 330;
- this.txtDiceNumSign.string = (Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1) + "";
- //slider2
- this.diceSliderSign2.x = -165 + this.diceSliderImg2.fillRange * 330;
- this.txtDiceNumSign2.string = (Math.floor(this.diceSliderImg2.fillRange / (1 / 6)) + 1) + "";
- if (this.diceTimer >= this.diceMaxTime) {
- EffectNode.instance.PlayTip("投掷时间过长,系统自动掷出");
- this.DiceAniSuccessEnd();
- }
- }
- }
- TimerRevertDice(dt) {
- if (this.isRevertDice) {
- RichData.Ins.revertTimer -= dt;
- //this.revertTimer -= dt;
- if (RichData.Ins.revertTimer <= 0) {
- this.isRevertDice = false;
- RichData.Ins.revertTimer = 0;
- RichData.Ins.UpdateItemCard(0, 1, 0, 0, 0, 0, 0);
- this.timeRevertNode.active = false;
- }
- this.txtUpdate.string = MyExtends.TimeToFormat(RichData.Ins.revertTimer, 3);
- }
- }
- TimerTipQipao(dt) {
- }
- DiceAniFailEnd() {
- this.isDiceTimer = false;
- this.diceTimer = 0;
- cc.Tween.stopAllByTarget(this.diceSliderImg);
- cc.Tween.stopAllByTarget(this.diceSliderImg2);
- this.diceSpine.clearTrack(0);
- this.diceSpine.node.active = false;
- this.diceCur.node.active = true;
- this.diceSliderImg.fillRange = 0;
- this.diceSliderImg2.fillRange = 0;
- this.touchValid.active = false;
- this.diceSliderSign.x = -165;
- this.txtDiceNumSign.string = "0";
- this.diceSliderSign2.x = -165;
- this.txtDiceNumSign2.string = "0";
- console.log("Cur Dice Num:" + (Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1));
- GameM.audioM.stopLoopEffect();
- }
- /**骰子 投掷成功*/
- DiceAniSuccessEnd() {
- this.isDiceTimer = false;
- this.diceTimer = 0;
- cc.Tween.stopAllByTarget(this.diceSliderImg);
- cc.Tween.stopAllByTarget(this.diceSliderImg2);
- this.diceSpine.clearTrack(0);
- this.diceSpine.node.active = false;
- //this.touchValid.active = false;
- if (this.touchValid.active) {
- this.touchValid.active = false;
- this.touchSpine.node.active = true;
- this.touchSpine.setAnimation(0, "animation", false);
- setTimeout(() => {
- this.touchSpine.node.active = false;
- }, 1000);
- }
- this.diceSliderSign.x = -165 + this.diceSliderImg.fillRange * 330;
- this.txtDiceNumSign.string = (Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1) + "";
- this.diceSliderSign2.x = -165 + this.diceSliderImg2.fillRange * 330;
- this.txtDiceNumSign2.string = (Math.floor(this.diceSliderImg2.fillRange / (1 / 6)) + 1) + "";
- let url;
- if (this.diceDoubleSign.active)
- url = "xiyou/richman/dice_gold";
- else
- url = "xiyou/richman/dice_nor";
- let dicenum = 0;
- if (this.diceNode1.active)
- dicenum = Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1;
- else
- dicenum = Math.floor(this.diceSliderImg2.fillRange / (1 / 6)) + 1;
- url += dicenum;
- cc.loader.loadRes(url, cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.diceCur.spriteFrame = assets;
- this.diceTouchImg.spriteFrame = assets;
- this.diceCur.node.active = true;
- })
- this.tsDice.node.scaleX = Math.abs(this.tsDice.node.scaleX) * (this.tangSpine.node.scaleX > 0 ? 1 : -1);
- this.tsDice.string = "前进" + dicenum + "步";
- console.log("Cur Dice Num:" + dicenum);
- this.inputMask.active = true;
- console.log("Dice End: " + true);
- this.CloudAni(dicenum);
- //this.scheduleOnce(() => {
- // this.StartMove(dicenum);
- //}, 1);
- RichData.Ins.UseDice();
- //this.UpdateInfo();
- GameM.audioM.stopLoopEffect();
- }
- /**遥控卡 使用成功
- * @param diceNum 遥控选择的骰子点数
- */
- UseCtrlCardEnd(diceNum: number) {
- this.inputMask.active = true;
- this.tsDice.node.scaleX = Math.abs(this.tsDice.node.scaleX) * (this.tangSpine.node.scaleX > 0 ? 1 : -1);
- this.tsDice.string = "前进" + diceNum + "步";
- console.log("Ctrl End: " + true);
- this.CloudAni(diceNum);
- //this.scheduleOnce(() => {
- // this.StartMove(diceNum);
- //}, 1);
- }
- CloudAni(dicenum: number) {
- this.tsQipao.opacity = 0;
- this.tsQipao.active = true;
- let a1 = cc.fadeTo(0.3, 255);
- let a2 = cc.delayTime(0.8);
- let a3 = cc.fadeTo(0.3, 0);
- let a4 = cc.callFunc(() => {
- this.tsQipao.active = false;
- this.StartMove(dicenum);
- });
- this.tsQipao.runAction(cc.sequence(a1, a2, a3, a4));
- }
- step = 0;
- StartMove(diceNum: number) {
- //this.diceCur.node.active = false;
- //this.inputMask.active = false;
- this.needStepNum = diceNum;// (Math.floor(this.diceSliderImg.fillRange / (1 / 6)) + 1);
- //if (this.step == 0)
- //this.needStepNum = 1; //TEST
- //else if (this.step == 1)
- // this.needStepNum = 2;
- //else if (this.step == 2)
- // this.needStepNum = 6;
- //else if (this.step == 3)
- // this.needStepNum = 3;
- //this.step++;
- //this.needStepNum = 6;
- if (this.needStepNum > 0) {
- this.curStepNum = 0;
- //let roads = RichData.Ins.GetMoveRoads(this.needStepNum * (Random.GetBool() ? 1 : -1));
- let roads = RichData.Ins.GetMoveRoads(this.needStepNum);
- console.log("Road::::", roads);
- let pos = MyExtends.convetOtherNodeSpaceAR(roads[roads.length - 1].node, this.bgRoot);
- //let deltaLen = roads[roads.length - 1].node.y - this.tangSpine.node.y;
- console.log("------------> " + pos.y);
- if (pos.y > 0) {
- let a1 = cc.moveBy(0.5 * this.needStepNum, 0, -pos.y);
- let a2 = cc.callFunc(() => { console.log("start move end"); });
- this.bg.runAction(cc.sequence(a1, a2));
- RichData.Ins.CheckLoadMapBg(cc.v2(0, this.bg.y - pos.y));
- }
- this.MoveAni(roads);
- } else {
- console.log("you dice 0 step")
- }
- }
- MoveAni(roads: RoadItem[]) {
- //this.curMoveNum++;
- this.tangSpine.node.active = true;
- let pos = MyExtends.convetOtherNodeSpaceAR(roads[this.curStepNum].node, this.bg);
- console.log("Last::::: " + this.lastStandMode + " Mode::::: " + roads[this.curStepNum].standMode);
- if (this.lastStandMode != roads[this.curStepNum].standMode) {
- this.lastStandMode = roads[this.curStepNum].standMode;
- if (roads[this.curStepNum].standMode == 1) {
- this.tangSpine.node.scaleX = 1;
- //this.tangSpine.setAnimation(0, "walk", true);
- }
- else if (roads[this.curStepNum].standMode == 2) {
- this.tangSpine.node.scaleX = 1;
- //this.tangSpine.setAnimation(0, "b_walk", true);
- }
- else {
- this.tangSpine.node.scaleX = -1;
- //this.tangSpine.setAnimation(0, "b_walk", true);
- }
- }
- cc.tween(this.tangSpine.node)
- .to(0.5, { position: pos })
- .call(() => {
- //roads[this.curStepNum].ActiveLight(false);
- this.curStepNum++;
- if (this.curStepNum >= this.needStepNum) {
- console.log("Move End: " + false);
- this.lastStandMode = 0;
- if (roads[this.curStepNum - 1].standMode == 1) {
- this.tangSpine.node.scaleX = 1;
- //this.tangSpine.setAnimation(0, "idle", true);
- }
- else if (roads[this.curStepNum - 1].standMode == 2) {
- this.tangSpine.node.scaleX = 1;
- //this.tangSpine.setAnimation(0, "b_idle", true);
- }
- else {
- this.tangSpine.node.scaleX = -1;
- //this.tangSpine.setAnimation(0, "b_idle", true);
- }
- RichData.Ins.UpdatePlayPos();
- this.CheckLoadMap();
- //棋盘道具检测
- roads[this.curStepNum - 1].CheckReward();
- this.UpdateInfo();
- console.log("move end");
- } else {
- this.MoveAni(roads);
- }
- })
- .start();
- cc.tween(this.tangSpine.node)
- .delay(0.25)
- .call(() => {
- console.log("length: " + roads.length + " num: " + this.curStepNum);
- if (this.curStepNum < roads.length)
- roads[this.curStepNum].ActiveLight(false);
- })
- .start();
- GameM.audioM.playEffect(AUDIO_TYPE.sutrawalk);
- }
- /**整个移动结束*/
- MoveEnd() {
- this.inputMask.active = false;
- //引导取经 大富翁
- //GuideMng.Ins.CheckRichGuide22();
- }
- DiceAni() {
- this.speed = Random.Range(90, 110, false) / 100;
- if (this.diceNode1.active) {
- cc.tween(this.diceSliderImg)
- .to(this.diceSpeed * this.speed, { fillRange: 1 })
- .call(() => {
- this.diceSliderImg.fillRange = 0;
- //this.speed = Random.Range(90, 110, false) / 100;//* (Random.GetBool() ? 1 : -1);
- //console.log("Speed:" + this.speed);
- this.DiceAni();
- GameM.audioM.playEffect(AUDIO_TYPE.sutratouchborder);
- })
- .start();
- } else {
- cc.tween(this.diceSliderImg2)
- .to(this.diceSpeed * this.speed, { fillRange: 1 })
- .call(() => {
- this.diceSliderImg2.fillRange = 0;
- //this.speed = Random.Range(90, 110, false) / 100;//* (Random.GetBool() ? 1 : -1);
- //console.log("Speed:" + this.speed);
- this.DiceAni();
- GameM.audioM.playEffect(AUDIO_TYPE.sutratouchborder);
- })
- .start();
- }
- }
- OnDiceTouchStart() {
- if (RichData.Ins.IsCanDice()) {
- this.diceSliderImg.fillRange = 0;
- this.diceSliderImg2.fillRange = 0;
- this.diceTimer = 0;
- this.isDiceTimer = true;
- this.diceSpine.node.active = true;
- if (RichData.Ins.doubleRemain > 0) {
- this.diceSpine.clearTrack(0);
- this.diceSpine.setToSetupPose();
- this.diceSpine.setAnimation(0, "animation2", true);
- }
- else {
- this.diceSpine.clearTrack(0);
- this.diceSpine.setToSetupPose();
- this.diceSpine.setAnimation(0, "animation", true);
- }
- this.diceCur.node.active = false;
- this.touchValid.active = true;
- this.touchValidSlider.fillRange = 0;
- this.DiceAni();
- GameM.audioM.playLoopEffect(AUDIO_TYPE.sutradice);
- } else {
- console.log("you can not dice");
- //打开获取骰子方法界面
- UIMng.Ins.AsyncGetPanel(PanelType.RichPropPanel, (panel) => {
- panel.OnEnter(3);
- });
- //UIMng.Ins.GetPanel(PanelType.RichPropPanel).OnEnter(3);
- }
- }
- OnDiceTouchEnd() {
- this.isDiceTimer = false;
- if (this.diceTimer > this.diceMinTime && this.diceTimer < this.diceMaxTime) {
- this.DiceAniSuccessEnd();
- } else {
- this.DiceAniFailEnd();
- if (RichData.Ins.IsCanDice())
- EffectNode.instance.PlayTip("请长按超过" + this.diceMinTime + "秒才能投掷");
- //this.isDiceTimer = false;
- //this.diceTimer = 0;
- //cc.Tween.stopAllByTarget(this.diceSliderImg);
- }
- //let p = new RichPropItemParam();
- //p.diceDailyNum = 0;
- //RichData.Ins.UpdateItemCardNew(p);
- //RichData.Ins.GetASubject();
- //this.PlayCSZEft(3);
- //RichData.Ins.TESTPlayDoubleEft();
- // UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => {
- // panel.OnEnter();
- // });
- }
- OnScreenTouch() {
- if (this.finger.active)
- this.finger.active = false;
- //console.log("----------------OnScreenTouch");
- }
- /**
- * 显示气泡
- * @param context 提示上下文
- */
- DisplayTipQiPao(context: string, pos: cc.Vec2) {
- this.unschedule(this.CloseTipQiPao);
- this.tipQiPao.setPosition(pos);
- this.tipQiPao.active = true;
- this.tipQiPao.getComponentInChildren(cc.Label).string = context;
- this.scheduleOnce(this.CloseTipQiPao, 2);
- }
- CloseTipQiPao() {
- this.tipQiPao.active = false;
- }
- async Play2RewardEft() {
- let eftNode = cc.instantiate(await Utils.loadResPromise("prefabs/item/Rich2RwdDiceEft"));
- eftNode.parent = this.diceTouchImg.node;
- eftNode.setPosition(0, 0);
- //let time = eftNode.getComponent(sp.Skeleton).findAnimation("animation").duration;
- //console.log("-------------Time:" + time);
- let a = setTimeout(() => {
- eftNode.destroy();
- eftNode = null;
- }, 1160);
- }
- /**
- * 播放传送阵文字效果
- * @param stepNum 传送的格数 +为前进 -为后退
- */
- PlayCSZEft(stepNum: number) {
- cc.Tween.stopAllByTarget(this.eft_cszNode);
- this.eft_cszNode.x = -750;
- this.eft_csztxt.string = Math.abs(stepNum) + "";
- if (stepNum > 0) {
- this.eft_csz1.active = true;
- this.eft_csz2.active = false;
- } else {
- this.eft_csz1.active = false;
- this.eft_csz2.active = true;
- }
- //this.eft_cszSpine.node.active = true;
- //console.log("---Time1 "+this.eft_cszSpine.findAnimation("qianjin").duration)
- //console.log("---Time2 "+this.eft_cszSpine.findAnimation("houtui").duration)
- this.eft_cszNode.active = true;
- this.eft_cszSpine.setAnimation(0, "qianjin", false);
- cc.tween(this.eft_cszNode)
- .to(0.2, { position: cc.v2(0, this.eft_cszNode.y) })
- .delay(1.5)
- .call(() => {
- this.eft_cszSpine.setAnimation(0, "houtui", false);
- })
- .to(0.2, { position: cc.v2(750, this.eft_cszNode.y) })
- .call(() => {
- this.eft_cszNode.active = false;
- //this.eft_cszSpine.node.active = false;
- })
- .start();
- }
- /**
- * 播放粒子特效
- * @param proptype 道具类型 10001 金币 10002 红包币 10004 武将宝盒 20001 加速卡 20002 转盘卡 20003 夺宝券 20006 天赋石 30001 骰子 30002 遥控卡 30003 传送阵 30004 经书 30005 双倍卡
- * @param type 播放类型 1 飞头像 2 飞骰子 3 飞遥控 4 飞双倍 5 飞经书
- * @param startpos 开始位置
- * @param cb 回调
- */
- PlayParticleEft(proptype: number, type: number, startpos: cc.Vec2, cb: Function = null) {
- //let eft = new cc.Node("eft");
- //let eftimg = eft.addComponent(cc.Sprite);
- //cc.loader.loadRes("xiyou/icon/reward" + proptype, cc.SpriteFrame, (error, assets) => {
- // if (error != null) {
- // return;
- // }
- // eftimg.spriteFrame = assets;
- //});
- //eft.parent = GameController.Ins.Canvas;
- //let eft = cc.instantiate(this.eft_particle);
- //eft.parent = GameController.Ins.Canvas;
- //eft.setPosition(startpos);
- //eft.active = true;
- let endPos = cc.v2();
- let anitype = 6;
- switch (proptype) {
- case 10001: anitype = 0;
- break;
- case 10002: anitype = 1;
- break;
- case 20001: anitype = 10;
- break;
- case 20002: anitype = 11;
- break;
- case 20003: anitype = 12;
- break;
- case 20006: anitype = 13;
- break;
- case 30001: anitype = 6;
- break;
- case 30002: anitype = 7;
- break;
- case 30004: anitype = 9;
- break;
- case 30005: anitype = 8;
- break;
- }
- switch (type) {
- case 1:
- endPos = MyExtends.convetOtherNodeSpaceAR(this.headNode, this.node);
- break;
- case 2:
- endPos = MyExtends.convetOtherNodeSpaceAR(this.diceTouchImg.node, this.node);
- break;
- case 3:
- endPos = MyExtends.convetOtherNodeSpaceAR(this.ctrlSliderImg.node, this.node);
- break;
- case 4:
- endPos = MyExtends.convetOtherNodeSpaceAR(this.doubleSliderImg.node, this.node);
- break;
- case 5:
- endPos = MyExtends.convetOtherNodeSpaceAR(this.txtBook.node, this.node);
- break;
- }
- EffectNode.instance.PlayCoinAnim(anitype, 6, startpos, true, endPos, () => {
- switch (type) {
- case 1:
- break;
- case 2:
- this.diceCur.node.runAction(cc.sequence(cc.scaleTo(0.15, 1.1), cc.scaleTo(0.15, 1)));
- this.txtDiceNum.node.runAction(cc.sequence(cc.scaleTo(0.15, 1.1), cc.scaleTo(0.15, 1)));
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- this.txtBook.node.runAction(cc.sequence(cc.scaleTo(0.15, 1.1), cc.scaleTo(0.15, 1)));
- this.bookBtnImg.runAction(cc.sequence(cc.scaleTo(0.15, 1.1), cc.scaleTo(0.15, 1)));
- break;
- }
- if (cb != null)
- cb();
- this.UpdateInfo();
- });
- GameM.audioM.playEffect(AUDIO_TYPE.sutraitemfly);
- }
- /**红点控制 是否有经书可以兑换红包币*/
- CheckCanCollectBook() {
- RichData.Ins.CheckCanCollect((isCanCollect) => {
- console.log("------->CheckCanCollectBook: " + isCanCollect);
- this.pointBook.active = isCanCollect;
- });
- //this.diceSpine.setCompleteListener(()=>{
- //
- //});
- //let entry=this.diceSpine.setAnimation(0,"animaiton",false);
- //this.diceSpine.setTrackEventListener(entry,()=>{});
- }
- /**操作界面初始化*/
- PanelActiveInit() {
- if (RichData.Ins.remoteCtrlNum > 0)
- PlayerPrefs.SetInt("RichCtrl", 1);
- if (RichData.Ins.doubleNum > 0)
- PlayerPrefs.SetInt("RichDouble", 1);
- this.ctrlNode.active = PlayerPrefs.GetInt("RichCtrl", 0) == 1;
- this.doubleNode.active = PlayerPrefs.GetInt("RichDouble", 0) == 1;
- this.diceNode1.active = PlayerPrefs.GetInt("RichCtrl", 0) == 1 || PlayerPrefs.GetInt("RichDouble", 0) == 1;
- this.diceNode2.active = !this.diceNode1.active;
- }
- /**操作界面激活
- * @param type 激活类型 1 获取遥控卡激活 2 获取双倍卡激活
- */
- CheckPanelActive(type: number) {
- if (type == 1) {
- if (PlayerPrefs.GetInt("RichCtrl", 0) == 0) {
- PlayerPrefs.SetInt("RichCtrl", 1);
- this.ctrlNode.active = true;
- if (!this.diceNode1.active) {
- this.diceNode1.active = true;
- this.diceNode2.active = false;
- }
- if (!this.finger.active) {
- this.finger.setPosition(this.ctrlNode.getPosition());
- this.finger.active = true;
- }
- }
- } else if (type == 2) {
- if (PlayerPrefs.GetInt("RichDouble", 0) == 0) {
- PlayerPrefs.SetInt("RichDouble", 1);
- this.doubleNode.active = true;
- if (!this.diceNode1.active) {
- this.diceNode1.active = true;
- this.diceNode2.active = false;
- }
- if (!this.finger.active) {
- this.finger.setPosition(this.doubleNode.getPosition());
- this.finger.active = true;
- }
- }
- }
- }
- Click_CtrlBtn() {
- if (RichData.Ins.remoteCtrlNum <= 0) {
- UIMng.Ins.AsyncGetPanel(PanelType.RichPropPanel, (panel) => {
- panel.OnEnter(4);
- });
- //UIMng.Ins.GetPanel(PanelType.RichPropPanel).OnEnter(4);
- //GameM.audioM.playEffect(AUDIO_TYPE.sutraitemfly);
- } else {
- if (RichData.Ins.diceTotalNum > 0) {
- //this.inputMask.active = true;
- //this.eft_ctrlCard.setPosition(MyExtends.convetOtherNodeSpaceAR(this.ctrlSliderImg.node, this.node));
- //this.eft_ctrlCard.active = true;
- //this.eft_ctrlCard.scale = 1;
- //this.eft_ctrlCard.angle = 0;
- //let a1 = cc.moveTo(0.5, cc.v2());
- //let a2 = cc.scaleTo(0.5, 3).easing(cc.easeQuadraticActionIn());
- //let a3 = cc.rotateTo(0.5, 1440);
- //let b = cc.callFunc(() => {
- // this.inputMask.active = false;
- // this.eft_ctrlCard.active = false;
- UIMng.Ins.AsyncGetPanel(PanelType.RichPropPanel, (panel) => {
- panel.OnEnter(1);
- });
- //UIMng.Ins.GetPanel(PanelType.RichPropPanel).OnEnter(1);
- //});
- //this.eft_ctrlCard.runAction(cc.sequence(cc.spawn(a1, a2, a3), b));
- }
- else {
- EffectNode.instance.PlayTip("骰子不足");
- }
- }
- //RichData.Ins.GetBossRewards();
- //RichData.Ins.UpdateItemCard(5,20,1,1,1,1);
- if (this.finger.active)
- this.finger.active = false;
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- }
- Click_DoubleBtn() {
- if (RichData.Ins.doubleNum > 0) {
- //this.inputMask.active = true;
- //this.eft_doubleCard.setPosition(MyExtends.convetOtherNodeSpaceAR(this.doubleSliderImg.node, this.node));
- //this.eft_doubleCard.active = true;
- //this.eft_doubleCard.scale = 1;
- //this.eft_doubleCard.angle = 0;
- //let a1 = cc.moveTo(0.5, cc.v2());
- //let a2 = cc.scaleTo(0.5, 3).easing(cc.easeQuadraticActionIn());
- //let a3 = cc.rotateTo(0.5, 1440);
- //let b = cc.callFunc(() => {
- // this.inputMask.active = false;
- // this.eft_doubleCard.active = false;
- UIMng.Ins.AsyncGetPanel(PanelType.RichPropPanel, (panel) => {
- panel.OnEnter(2);
- });
- //UIMng.Ins.GetPanel(PanelType.RichPropPanel).OnEnter(2);
- //});
- //this.eft_doubleCard.runAction(cc.sequence(cc.spawn(a1, a2, a3), b));
- //GameM.audioM.playEffect(AUDIO_TYPE.sutraitemfly);
- } else {
- EffectNode.instance.PlayTip("击杀BOSS可以掉落双倍卡");
- }
- //RichData.Ins.GetASubject();
- //RichData.Ins.GetBossRewards();
- //if (RichData.Ins.doubleRemain > 0) {
- // RichData.Ins.UpdateItemCard(0, 0, 0, 0, 0, 0, -1);
- //}
- //RichData.Ins.CheckDoubleEft();
- //this.Play2RewardEft();
- if (this.finger.active)
- this.finger.active = false;
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- }
- Click_BookBtn() {
- RichData.Ins.BookCollectInit();
- //RichData.Ins.RichDataInit();
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- }
- Click_HelpBtn() {
- UIMng.Ins.AsyncGetPanel(PanelType.RichHelpPanel, (panel) => {
- panel.OnEnter();
- });
- //UIMng.Ins.GetPanel(PanelType.RichHelpPanel).OnEnter();
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- }
- Click_BackBtn() {
- this.OnExit();
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- }
- Click_GiftCloseBtn() {
- this.panel_gift.active = false;
- if (this.isNewPlayGift) {
- GuideMng.Ins.CheckRichGuide27();
- RichData.Ins.PlayParticleEft(30001, 2, this.node);
- //this.txtDiceNum.string = RichData.Ins.diceTotalNum + "";
- } else {
- RichData.Ins.PlayParticleEft(30001, 2, this.node);
- }
- }
- }
- /*
- IT 2.35
- Program Files 3.38
- Program Files 86 4.76
- ProgramData 1.42
- Windows 23.7
- Windows.old 34.7 (占用 28.9)
- 用户 31.5 (占用 25.9)
- hiberfil.sys 6.38
- pagefile.sys 10
- */
|