| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953 |
- import AdM from "../manager/AdM";
- import { GameController } from "../manager/GameController";
- import GameM 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 MyExtends from "../tools/MyExtends";
- import Time from "../tools/Time";
- import EffectNode from "../ui/EffectNode";
- import RichPanel from "../ui/RichPanel";
- import Task from "../ui/Task";
- import UIMng, { PanelType } from "../uiFrames/UIMng";
- import Sciencen_M from "../utils/Sciencen_M";
- import { Utils } from "../utils/Utils";
- import { HTTP_TYPE } from "./CommonData";
- export class RichData {
- //财神降临数据管理类
- private static _ins: RichData = null;
- public static get Ins(): RichData {
- if (this._ins == null) {
- this._ins = new RichData();
- }
- return this._ins;
- }
- Destroy() {
- RichData._ins = null;
- }
- richItemCardCfg: any = null;
- richCfg: any = null;
- /**骰子总次数*/
- diceTotalNum: number = 0;
- /**累加骰子数量*/
- diceAdNum: number = 0;
- /**免费骰子数量*/
- diceDailyNum: number = 0;
- /**免费骰子完全恢复时间*/
- diceRecoverTime: number = 0;
- /**免费骰子恢复一个的时间*/
- diceSingleRecoverTime: number = 0;
- /**重置骰子时间段标识*/
- diceResetValue: number = 0;
- /**双倍卡当日已获取数量*/
- doubleDailyGetNum: number = 0;
- /**双倍卡数量*/
- doubleNum: number = 0;
- /**双倍效果剩余次数*/
- doubleRemain: number = 0;
- /**红包币兑换记录*/
- fairyJade: number[] = null;
- //latticeEvent:
- /**当前格子id 1-48*/
- latticeIndex: number = 0;
- /**是否是新用户*/
- newPlayer: number = 0;
- /**页码*/
- pageIndex: number = 1;
- /**遥控卡当日已获取数量*/
- remoteCtrlDailyGetNum: number = 0;
- /**遥控卡数量*/
- remoteCtrlNum: number = 0;
- /**奖励次数*/
- rewardNum: number = 0;
- /**经书数量*/
- scriptureNum: number = 0;
- /**下一级领取兑换的经书数量*/
- scriptureNextNum: number = 0;
- /**骰子恢复时间计时器*/
- revertTimer: number = 0;
- /**视频观看次数 看视频获取骰子*/
- adDiceDaily: number = 0;
- richPanel: RichPanel = null;
- bg: cc.Node = null;
- bgRoot: cc.Node = null;
- /**已加载的地图路径上下边界Y坐标 x 为下坐标 y 为上坐标*/
- mapPosSide: cc.Vec2 = cc.v2();
- /**已加载的地图背景上下边界Y坐标 x 为下坐标 y 为上坐标*/
- mapBgPosSide: cc.Vec2 = cc.v2();
- /**视角背景坐标边界 this.bg 坐标边界 x 最下 y 最上*/
- viewBgPosSide: cc.Vec2 = cc.v2();
- /**棋盘上下页码边界 x 地图下页码 y 地图上页码 id 不是索引 最低 1 开始*/
- latticePageSide: cc.Vec2 = cc.v2(1, 1);
- roadsAry: Roads[] = [];
- roadItems: RoadItem[] = [];
- roadData: any[] = [];
- /**0 48 96 基本就是0 不改动*/
- curRoadStartIndex: number = 0;
- /**当前角色所在位置 索引*/
- curPosIndex: number = 0;
- /**当前骰子投掷的点数*/
- diceNum: number = 0;
- /**踩到武将时 该武将的type 奖励类型 用于请求boss挑战奖励接口*/
- masterType = "1";
- isNetEnd: boolean = true;
- isOpenRichPanel: boolean = false;
- //private isMoveUp: boolean = false;
- //private isMveDown: boolean = false;
- ServerInit(data: any) {
- console.log("------->Data:", data);
- this.diceAdNum = data.diceAdNum;
- this.diceDailyNum = data.diceDailyNum;
- this.diceRecoverTime = data.diceRecoverTime;
- this.diceSingleRecoverTime = data.diceSingleRecoverTime;
- this.diceResetValue = data.diceResetValue;
- this.doubleDailyGetNum = data.doubleDailyGetNum;
- this.doubleNum = data.doubleNum;
- this.doubleRemain = data.doubleRemain;
- this.fairyJade = data.fairyJade;
- this.latticeIndex = data.latticeIndex;
- this.newPlayer = data.newPlayer;
- this.pageIndex = data.pageIndex;
- this.remoteCtrlDailyGetNum = data.remoteCtrlDailyGetNum;
- this.remoteCtrlNum = data.remoteCtrlNum;
- this.rewardNum = data.rewardNum;
- this.scriptureNum = data.scriptureNum;
- this.adDiceDaily = data.diceDaily;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- this.curPosIndex = this.latticeIndex - 1;
- //TEST
- //this.curPosIndex = 6;
- this.latticePageSide.x = this.latticePageSide.y = data.pageIndex;
- }
- async MapInit(richpanel: RichPanel, bgRoot: cc.Node, bg: cc.Node, roads: Roads) {
- this.richPanel = richpanel;
- this.bgRoot = bgRoot;
- this.bg = bg;
- this.roadsAry.push(roads);
- this.mapPosSide = cc.v2(0, 0);
- this.mapBgPosSide = cc.v2(0, 1334);
- //获取数据
- await Utils.loadResPromise('prefabs/TransitNode')
- GameController.Ins.PlayTransitAniForHttp();
- HttpM.Instance.SendData(HTTP_TYPE.richManChessboar, { page: this.pageIndex }, (res) => {
- console.log("--->chess data:", res);
- if (res.data != null) {
- GameController.Ins.PlayCloseTransitAniForHttp(() => {
- roads.Init(res.data.LearningChessboardInfo);
- this.MapPosInit();
- this.richPanel.CheckLoadMap();
- //引导取经 大富翁
- GuideMng.Ins.CheckRichGuide26();
- });
- }
- }, null, null, false, false);
- //console.log("Items:", this.roadItems);
- }
- /**
- * 加载地图
- * @param loadType 1 向上加载 2 向下加载 0 不加载
- */
- LoadMap(loadType: number, roads: Roads) {
- //获取数据
- if (loadType == 1) {
- this.latticePageSide.y++;
- this.mapPosSide.y += 1936;
- this.roadsAry.push(roads);
- roads.node.setPosition(0, this.mapPosSide.y);
- //roads.Init(null);
- } else {
- this.latticePageSide.x--;
- this.mapPosSide.x -= 1936;
- this.roadsAry.unshift(roads);
- roads.node.setPosition(0, this.mapPosSide.x);
- this.curPosIndex += 48;
- //roads.Init(null);
- }
- let page = loadType == 1 ? this.latticePageSide.y : this.latticePageSide.x;
- //获取数据
- HttpM.Instance.SendData(HTTP_TYPE.richManChessboar, { page: page }, (res) => {
- console.log("--->chess data load:", res);
- if (res.data != null) {
- roads.Init(res.data.LearningChessboardInfo, loadType);
- }
- }, null, null, false, false);
- }
- /**检测是否加载地图
- * 1 向上加载 2 向下加载 0 不加载
- */
- CheckLoadMapType() {
- // max 18 min 6
- let a = this.roadItems.length + this.curRoadStartIndex;
- console.log("Cur::::" + this.curPosIndex + " A::" + (a - 20))
- if (this.curPosIndex >= a - 20) {
- //向上加载
- return 1;
- } else if (this.curPosIndex > 47 && this.curPosIndex > this.curRoadStartIndex && this.curPosIndex < this.curRoadStartIndex + 6) {
- //向下加载
- return 2;
- }
- return 0;
- }
- MapPosInit() {
- let pos = MyExtends.convetOtherNodeSpaceAR(this.roadItems[this.curPosIndex - this.curRoadStartIndex].node, this.bg);
- this.richPanel.tangSpine.node.setPosition(pos);
- if (this.roadItems[this.curPosIndex - this.curRoadStartIndex].standMode == 1) {
- this.richPanel.tangSpine.node.scaleX = 1;
- //this.richPanel.tangSpine.setAnimation(0, "idle", true);
- } else if (this.roadItems[this.curPosIndex - this.curRoadStartIndex].standMode == 2) {
- this.richPanel.tangSpine.node.scaleX = 1;
- //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
- }
- else {
- this.richPanel.tangSpine.node.scaleX = -1;
- //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
- }
- let pos2 = MyExtends.convetOtherNodeSpaceAR(this.richPanel.tangSpine.node, this.bgRoot);
- if (pos2.y > 0) {
- this.bg.setPosition(0, -pos2.y);
- }
- this.MapBgInit();
- //if (this.curPosIndex > 23) {
- // this.bg.setPosition(0, -968);
- //} else {
- // this.bg.setPosition(0, 0);
- //}
- }
- MapBgInit() {
- if (this.bg.y < -968) {
- this.mapBgPosSide.y += 1334;
- this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.y));
- this.viewBgPosSide = cc.v2(-968, 0);
- } else {
- this.viewBgPosSide = cc.v2(0, 0);
- }
- }
- /**检测加载背景*/
- CheckLoadMapBg(targetBgPos: cc.Vec2) {
- if (targetBgPos.y < this.viewBgPosSide.x) {
- this.viewBgPosSide.x -= 968;
- this.mapBgPosSide.y += 1334;
- this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.y));
- } else {
- if (targetBgPos.y > this.viewBgPosSide.y) {
- this.viewBgPosSide.y += 968;
- this.mapBgPosSide.x -= 1334;
- this.richPanel.LoadMapBg(cc.v2(0, this.mapBgPosSide.x));
- }
- }
- }
- /**更新加载背景与背景移动*/
- UpdateLoadMapBgAndMoveBg(targetNode: cc.Node) {
- let pos = MyExtends.convetOtherNodeSpaceAR(targetNode, this.bgRoot);
- if (Math.abs(pos.y) > 0) {
- this.bg.runAction(cc.moveBy(0.5, 0, -pos.y));
- this.CheckLoadMapBg(cc.v2(0, this.bg.y - pos.y));
- }
- }
- /**触发传送技能
- * @param roaditem roaditem
- * @param step 步骤数
- */
- async TriggerConveySkill(roaditem: RoadItem, step: number) {
- let targetRoadItem = this.GetConveyTargetRoad(roaditem, step);
- if (targetRoadItem != null) {
- if (this.richPanel != null)
- this.richPanel.PlayCSZEft(step);
- await Time.WaitForSeconds(0.5);
- let eftNode = cc.instantiate(await Utils.loadResPromise("prefabs/item/RichCSZEft"));
- eftNode.parent = this.bg;
- eftNode.setPosition(this.richPanel.tangSpine.node.getPosition());
- //eftNode.parent = roaditem.node;
- //eftNode.setPosition(0, 0);
- let ani = eftNode.getComponent(sp.Skeleton);
- let time = ani.findAnimation("xiaoshi").duration;
- ani.setAnimation(0, "xiaoshi", false);
- await Time.WaitForSeconds(time / 2);
- this.richPanel.tangSpine.node.active = false;
- await Time.WaitForSeconds(time / 2 + 0.5);
- let pos = RichData.Ins.GetPosForRoadItem(targetRoadItem.node);
- //eftNode.parent = targetRoadItem.node;
- //eftNode.setPosition(0, 0);
- eftNode.setPosition(pos);
- ani.setAnimation(0, "chuxian", false);
- let time2 = ani.findAnimation("chuxian").duration;
- this.richPanel.tangSpine.node.setPosition(pos);
- this.richPanel.tangSpine.node.active = true;
- if (targetRoadItem.standMode == 1) {
- this.richPanel.tangSpine.node.scaleX = 1;
- //this.richPanel.tangSpine.setAnimation(0, "idle", true);
- } else if (targetRoadItem.standMode == 2) {
- this.richPanel.tangSpine.node.scaleX = 1;
- //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
- } else {
- this.richPanel.tangSpine.node.scaleX = -1;
- //this.richPanel.tangSpine.setAnimation(0, "b_idle", true);
- }
- this.curPosIndex += step;
- let bgpos = MyExtends.convetOtherNodeSpaceAR(targetRoadItem.node, this.bgRoot);
- //console.log("----->pos:", pos);
- //console.log("------->bgpos:", bgpos);
- if (Math.abs(bgpos.y) > 0) {
- this.bg.stopAllActions();
- //let posy = this.bg.y - pos.y;
- //this.bg.setPosition(0,posy);
- //console.log("-------1>:" + bgpos.y + " bg Y:" + this.bg.y);
- //this.bg.setPosition(0, this.bg.y - bgpos.y);
- let a1 = cc.moveBy(0.5, 0, -bgpos.y);
- let a2 = cc.callFunc(() => {
- targetRoadItem.CheckReward();
- });
- this.bg.runAction(cc.sequence(a1, a2));
- this.CheckLoadMapBg(cc.v2(0, this.bg.y - bgpos.y));
- }
- console.log("-------------Time2:" + time2);
- setTimeout(() => {
- eftNode.destroy();
- eftNode = null;
- }, time2 * 1000);
- setTimeout(() => {
- }, 1500);
- AdM.onSendEvent('Qujing_Delivery', '取经传送阵触发', "qujing");
- }
- }
- /**获取移动的路段数据
- * @param diceNum 骰子点数 -表示向下 +表示向上
- */
- GetMoveRoads(diceNum: number) {
- this.diceNum = diceNum;
- return this.GetRoadItems(diceNum);
- }
- GetRoadItems(num: number) {
- let roads: RoadItem[] = [];
- for (let i = 1; i < num + 1; i++) {
- this.roadItems[this.curPosIndex + i].ActiveLight(true);
- roads.push(this.roadItems[this.curPosIndex + i]);
- //console.log("Get::::",this.roadItems[this.curPosIndex + i]);
- }
- return roads;
- }
- /**获取传送目标road*/
- GetConveyTargetRoad(roaditem: RoadItem, step: number) {
- let curindex = this.roadItems.indexOf(roaditem);
- if (curindex != -1) {
- return this.roadItems[curindex + step];
- }
- return null;
- }
- /**获取roaditem的坐标
- * @param roaditem roadItem
- */
- GetPosForRoadItem(roaditem: cc.Node) {
- return MyExtends.convetOtherNodeSpaceAR(roaditem, this.bg);
- }
- UpdatePlayPos() {
- this.curPosIndex += this.diceNum;
- this.diceNum = 0;
- }
- MoveEnd() {
- if (this.richPanel != null)
- this.richPanel.MoveEnd();
- }
- /**是否可以投掷骰子*/
- IsCanDice() {
- return this.diceTotalNum > 0;// && (this.curPosIndex - this.curRoadStartIndex) < (this.roadItems.length - 6);
- }
- /**使用骰子*/
- UseDice() {
- if (this.diceAdNum > 0) {
- //this.diceAdNum--;
- this.UpdateItemCard(-1, 0, 0, 0, 0, 0, 0);
- } else {
- //this.diceDailyNum--;
- this.UpdateItemCard(0, -1, 0, 0, 0, 0, 0);
- }
- //this.diceTotalNum = this.diceAdNum + this.diceDailyNum;
- AdM.onSendEvent('Qujing_UseDice', '取经骰子消耗', "qujing");
- }
- /**使用遥控卡
- * @param diceNum 点数
- */
- UseCtrlCard(diceNum: number) {
- if (this.diceAdNum > 0) {
- //this.diceAdNum--;
- this.UpdateItemCard(-1, 0, 0, -1, 0, 0, 0);
- } else {
- //this.diceDailyNum--;
- this.UpdateItemCard(0, -1, 0, -1, 0, 0, 0);
- }
- //this.UpdateItemCard(0,0,0,-1,0,0,0);
- //this.remoteCtrlNum--;
- this.richPanel.UseCtrlCardEnd(diceNum);
- //this.richPanel.UpdateInfo();
- }
- /**使用双倍卡*/
- UseDoubleCard() {
- this.UpdateItemCard(0, 0, -1, 0, 0, 0, RichData.Ins.richItemCardCfg.doubleTimes);
- this.CheckDoubleEft();
- if (this.richPanel != null)
- this.richPanel.Play2RewardEft();
- }
- TESTPlayDoubleEft() {
- this.CheckDoubleEft();
- if (this.richPanel != null)
- this.richPanel.Play2RewardEft();
- }
- /**显示双倍奖励*/
- CheckDoubleEft() {
- let startIndex = 0;
- let endIndex = this.curPosIndex + 12;
- let num = endIndex - startIndex;
- if (this.curPosIndex - 12 < 0) {
- startIndex = 0;
- } else {
- startIndex = this.curPosIndex - 12;
- }
- for (let i = startIndex; i < num; i++) {
- this.roadItems[i].CheckPlayDoubleEft();
- }
- this.roadItems.forEach(item => {
- item.DisplayDoubleEft(true);
- });
- }
- /**
- * 获取道具奖励 (弃用)
- * @param propType 道具类型 0 免费骰子 1 累加骰子 2 遥控卡 3 双倍卡 4 经书 5 奖励次数
- * @param opType 操作类型 0 添加 1 减少
- * @param num 数量
- */
- GetPropReward(propType: number, opType: number, num: number) {
- let opSign = opType == 0 ? 1 : -1;
- switch (propType) {
- case 0:
- this.diceDailyNum += num * opSign;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- break;
- case 1:
- this.diceAdNum += num * opSign;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- break;
- case 2:
- this.remoteCtrlNum += num * opSign;
- break;
- case 3:
- this.doubleNum += num * opSign;
- break;
- case 4:
- this.scriptureNum += num * opSign;
- break;
- case 5:
- this.rewardNum += num * opSign;
- break;
- }
- HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, { type: propType, opType: opType, num: num }, (res) => {
- console.log("--->update item card:", res);
- });
- /*
- [
- {type:1,opType:2,num:1},
- {type:1,opType:2,num:1}
- {type:1,opType:2,num:1}
- {type:1,opType:2,num:1}
- ]
- {
- diceDailyNum:1000,
- diceAdNum:100000,
- ...
- }
- */
- }
- /**更新道具信息
- * @param pdiceAdNum 累加骰子变化量 +加 -减
- * @param pdiceDailyNUm 免费骰子变化量
- * @param pdoubleNum 双倍卡变化量
- * @param premoteCtrlNum 遥控卡变化量
- * @param prewardNum 奖励次数变化量
- * @param pscriptureNum 经书数变化量
- * @param pdoubleRemain 双倍奖励效果剩余次数
- * @param pdiceAdvertise 看视频获取骰子
- */
- UpdateItemCard(pdiceAdNum = 0, pdiceDailyNUm = 0, pdoubleNum = 0, premoteCtrlNum = 0, prewardNum = 0, pscriptureNum = 0, pdoubleRemain = 0, callback: Function = null, isupdateinfo: boolean = true) {
- let param: any = {};
- if (pdiceAdNum != 0)
- param.diceAdNum = pdiceAdNum;
- if (pdiceDailyNUm != 0)
- param.diceDailyNum = pdiceDailyNUm;
- if (pdoubleNum != 0)
- param.doubleNum = pdoubleNum;
- if (premoteCtrlNum != 0)
- param.remoteCtrlNum = premoteCtrlNum;
- if (prewardNum != 0)
- param.rewardNum = prewardNum;
- if (pscriptureNum != 0)
- param.scriptureNum = pscriptureNum;
- if (pdoubleRemain != 0)
- param.doubleRemain = pdoubleRemain;
- console.log("---->Update Item Card:", param);
- HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
- console.log("--->update item card:", res);
- if (res.data.userLearningInfo != null) {
- this.diceAdNum = res.data.userLearningInfo.diceAdNum;
- this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
- this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
- this.diceSingleRecoverTime = res.data.userLearningInfo.diceSingleRecoverTime;
- //this.diceResetValue = res.data.userLearningInfo.diceResetValue;
- //this.doubleDailyGetNum = res.data.userLearningInfo.doubleDailyGetNum;
- this.doubleNum = res.data.userLearningInfo.doubleNum;
- this.doubleRemain = res.data.userLearningInfo.doubleRemain;
- //this.fairyJade = res.data.userLearningInfo.fairyJade;
- //this.latticeIndex = res.data.userLearningInfo.latticeIndex;
- //this.newPlayer = res.data.userLearningInfo.newPlayer;
- //this.pageIndex = res.data.userLearningInfo.pageIndex;
- //this.remoteCtrlDailyGetNum = res.data.userLearningInfo.remoteCtrlDailyGetNum;
- this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
- this.rewardNum = res.data.userLearningInfo.rewardNum;
- this.scriptureNum = res.data.userLearningInfo.scriptureNum;
- this.adDiceDaily = res.data.userLearningInfo.diceDaily;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- if (this.richPanel != null && !this.richPanel.CheckUpdateRevering())
- this.richPanel.CheckUpdateRevertTime();
- if (isupdateinfo)
- this.UpdateInfo();
- if (pscriptureNum != 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckCanCollectBook();
- }
- }
- if (premoteCtrlNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(1);
- }
- }
- if (pdoubleNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(2);
- }
- }
- //console.log("-----------------------P:" + JSON.stringify(param) + " Data:" + res.data.userLearningInfo.scriptureNum);
- //console.log("----------------------------------------1:Param: " + pdoubleRemain + " Remain: " + this.doubleRemain);
- //取消显示双倍效果
- if (pdoubleRemain < 0 && this.doubleRemain <= 0) {
- this.roadItems.forEach(item => {
- item.DisplayDoubleEft(false);
- });
- }
- if (callback != null) {
- callback();
- }
- //if (UiM.Instance.taskNode) {
- // UiM.Instance.taskNode.getComponent(Task).freshDice()
- //}
- }
- }, null, () => {
- console.log("----->UpdateItemCard Error");
- }, null, false);
- }
- /**更新道具信息
- * @param param 道具变化量参数
- * @param callback 回调
- * @param isupdateinfo 是否更新界面道具信息
- */
- UpdateItemCardNew(param: RichPropItemParam, callback: Function = null, isupdateinfo: boolean = true) {
- console.log("---->Update Item Card New:", param);
- HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
- console.log("--->update item card New:", res);
- if (res.data.userLearningInfo != null) {
- this.diceAdNum = res.data.userLearningInfo.diceAdNum;
- this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
- this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
- this.diceSingleRecoverTime = res.data.userLearningInfo.diceSingleRecoverTime;
- this.doubleNum = res.data.userLearningInfo.doubleNum;
- this.doubleRemain = res.data.userLearningInfo.doubleRemain;
- this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
- this.rewardNum = res.data.userLearningInfo.rewardNum;
- this.scriptureNum = res.data.userLearningInfo.scriptureNum;
- this.adDiceDaily = res.data.userLearningInfo.diceDaily;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- if (this.richPanel != null && !this.richPanel.CheckUpdateRevering())
- this.richPanel.CheckUpdateRevertTime();
- if (isupdateinfo)
- this.UpdateInfo();
- if (param.scriptureNum != 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckCanCollectBook();
- }
- }
- if (param.remoteCtrlNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(1);
- }
- }
- if (param.doubleNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(2);
- }
- }
- //取消显示双倍效果
- if (param.doubleRemain < 0 && this.doubleRemain <= 0) {
- this.roadItems.forEach(item => {
- item.DisplayDoubleEft(false);
- });
- }
- if (callback != null) {
- callback();
- }
- }
- }, null, () => {
- console.log("----->UpdateItemCard Error");
- }, null, false);
- }
- /**
- *更新道具信息
- @param param 参数 各道具变化量 pdiceAdNum = 0, pdiceDailyNUm = 0, pdoubleNum = 0, premoteCtrlNum = 0, prewardNum = 0, pscriptureNum = 0,pdoubleRemain = 0
- */
- UpdateItemCard2(param: any, cb: Function = null, isupdateinfo: boolean = true) {
- //console.log("---->Update Item Card2:", param);
- HttpM.Instance.SendData(HTTP_TYPE.richManUpdateItemCard, param, (res) => {
- //console.log("--->update item card2:", res);
- if (res.data.userLearningInfo != null) {
- this.diceAdNum = res.data.userLearningInfo.diceAdNum;
- this.diceDailyNum = res.data.userLearningInfo.diceDailyNum;
- //this.diceRecoverTime = res.data.userLearningInfo.diceRecoverTime;
- //this.diceResetValue = res.data.userLearningInfo.diceResetValue;
- //this.doubleDailyGetNum = res.data.userLearningInfo.doubleDailyGetNum;
- this.doubleNum = res.data.userLearningInfo.doubleNum;
- this.doubleRemain = res.data.userLearningInfo.doubleRemain;
- //this.fairyJade = res.data.userLearningInfo.fairyJade;
- //this.latticeIndex = res.data.userLearningInfo.latticeIndex;
- //this.newPlayer = res.data.userLearningInfo.newPlayer;
- //this.pageIndex = res.data.userLearningInfo.pageIndex;
- //this.remoteCtrlDailyGetNum = res.data.userLearningInfo.remoteCtrlDailyGetNum;
- this.remoteCtrlNum = res.data.userLearningInfo.remoteCtrlNum;
- this.rewardNum = res.data.userLearningInfo.rewardNum;
- this.scriptureNum = res.data.userLearningInfo.scriptureNum;
- this.adDiceDaily = res.data.userLearningInfo.diceDaily;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- //console.log("----------------------------------------2: Remain: " + this.doubleRemain);
- if (isupdateinfo)
- this.UpdateInfo();
- if (param.remoteCtrlNum && param.remoteCtrlNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(1);
- }
- }
- if (param.doubleNum && param.doubleNum > 0) {
- if (this.richPanel != null) {
- this.richPanel.CheckPanelActive(2);
- }
- }
- if (cb != null) {
- cb();
- }
- }
- }, null, () => {
- console.log("----->UpdateItemCard Error");
- }, null, false);
- }
- /**获取boss奖励 弃用 调试 */
- GetBossRewards() {
- HttpM.Instance.SendData(HTTP_TYPE.richManBossReward, { type: "1" }, (res) => {
- //console.log("--->boss rewards:", res);
- }, null, null, null, false);
- }
- /**更新面板信息*/
- UpdateInfo() {
- if (this.richPanel != null)
- this.richPanel.UpdateInfo();
- }
- /**
- * 显示气泡提示
- * @param context 提示上下文
- */
- DisplayQiPao(context: string, item: cc.Node) {
- if (this.richPanel != null) {
- let pos = MyExtends.convetOtherNodeSpaceAR(item, this.bg);
- this.richPanel.DisplayTipQiPao(context, cc.v2(pos.x + 50, pos.y + 150));
- }
- }
- /**
- * 播放粒子效果
- * @param proptype 道具类型 10001 金币 10002 红包币 10004 武将宝盒 20001 加速卡 20002 转盘卡 20003 夺宝券 20006 天赋石 30001 骰子 30002 遥控卡 30003 传送阵 30004 经书 30005 双倍卡
- * @param type 播放类型 1 飞头像 2 飞骰子 3 飞遥控 4 飞双倍 5 飞经书
- * @param startNode 开始位置节点
- * @param cb 回调
- */
- PlayParticleEft(proptype: number, type: number, startNode: cc.Node, cb: Function = null) {
- if (this.richPanel != null) {
- let startpos = MyExtends.convetOtherNodeSpaceAR(startNode, this.bgRoot);
- this.richPanel.PlayParticleEft(proptype, type, startpos, cb);
- }
- }
- /**
- * 获取一道题
- */
- GetASubject() {
- HttpM.Instance.SendData(HTTP_TYPE.richManGetSubject, {}, (res) => {
- console.log("--->get subject:", res);
- if (res.data != null && res.data.code == 1) {
- UIMng.Ins.AsyncGetPanel(PanelType.RichBookPanel, (panel) => {
- panel.OnEnter(res.data.question);
- });
- //UIMng.Ins.GetPanel(PanelType.RichBookPanel).OnEnter(res.data.question);
- } else {
- console.log("request fail : msg:" + res.errmsg);
- }
- }, null, () => {
- console.log("get subject request error");
- }, null, false);
- }
- BookCollectInit() {
- HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
- console.log("--->book list:", res);
- if (res.data != null && res.data.code == 1) {
- UIMng.Ins.AsyncGetPanel(PanelType.RichCollectPanel, (panel) => {
- panel.OnEnter(res.data.fairyjadec);
- });
- //UIMng.Ins.GetPanel(PanelType.RichCollectPanel).OnEnter(res.data.fairyjadec);
- } else {
- console.log("request fail : msg:" + res.errmsg);
- }
- });
- }
- /**大富翁数据更新*/
- RichPanelUpdateInit() {
- HttpM.Instance.SendData(HTTP_TYPE.richManInitCardInfo, {}, (res) => {
- console.log("--->Init Info:", res);
- if (res.data.cardInfo != null) {
- this.diceAdNum = res.data.cardInfo.diceAdNum;
- this.diceDailyNum = res.data.cardInfo.diceDailyNum;
- this.diceRecoverTime = res.data.cardInfo.diceRecoverTime;
- this.diceSingleRecoverTime = res.data.cardInfo.diceSingleRecoverTime;
- //this.diceResetValue = res.data.cardInfo.diceResetValue;
- //this.doubleDailyGetNum = res.data.cardInfo.doubleDailyGetNum;
- this.doubleNum = res.data.cardInfo.doubleNum;
- this.doubleRemain = res.data.cardInfo.doubleRemain;
- //this.fairyJade = res.data.cardInfo.fairyJade;
- //this.latticeIndex = res.data.cardInfo.latticeIndex;
- //this.newPlayer = res.data.cardInfo.newPlayer;
- //this.pageIndex = res.data.cardInfo.pageIndex;
- //this.remoteCtrlDailyGetNum = res.data.cardInfo.remoteCtrlDailyGetNum;
- this.remoteCtrlNum = res.data.cardInfo.remoteCtrlNum;
- this.rewardNum = res.data.cardInfo.rewardNum;
- this.scriptureNum = res.data.cardInfo.scriptureNum;
- this.adDiceDaily = res.data.cardInfo.diceDaily;
- this.diceTotalNum = this.diceDailyNum + this.diceAdNum;
- if (this.richPanel != null)
- this.richPanel.CheckUpdateRevertTime();
- this.UpdateInfo();
- }
- });
- }
- /**经书是否可以兑换红包币*/
- CheckCanCollect(callback: Function) {
- let isCanCollect = false;
- HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
- //console.log("--->book list1:", res);
- if (res.data != null && res.data.code == 1) {
- let data = res.data.fairyjadec;
- for (let i = 0; i < data.length; i++) {
- if (i == 0)
- this.scriptureNextNum = data[i].scripture;
- if (this.scriptureNum >= data[i].scripture) {
- isCanCollect = true;
- break;
- }
- }
- if (this.richPanel != null)
- this.richPanel.txtBook.string = Sciencen_M.instance.format(this.scriptureNum.toString()) + "/" + Sciencen_M.instance.format(this.scriptureNextNum.toString());
- callback(isCanCollect);
- } else {
- console.log("request fail : msg:" + res.errmsg);
- }
- });
- }
- /**经书是否可以兑换红包币2*/
- CheckCanCollectBook() {
- if (this.richPanel != null) {
- let isCanCollect = false;
- HttpM.Instance.SendData(HTTP_TYPE.richManBookList, {}, (res) => {
- //console.log("--->book list2:", res);
- if (res.data != null && res.data.code == 1) {
- let data = res.data.fairyjadec;
- for (let i = 0; i < data.length; i++) {
- if (i == 0)
- this.scriptureNextNum = data[i].scripture;
- if (this.scriptureNum >= data[i].scripture) {
- isCanCollect = true;
- break;
- }
- }
- this.richPanel.pointBook.active = isCanCollect;
- this.richPanel.txtBook.string = Sciencen_M.instance.format(this.scriptureNum.toString()) + "/" + Sciencen_M.instance.format(this.scriptureNextNum.toString());
- } else {
- console.log("request fail : msg:" + res.errmsg);
- }
- });
- }
- }
- /**是否可以领取奖励*/
- CheckCanReward() {
- let result = this.rewardNum < this.richCfg.rewardnumber;
- if (!result)
- EffectNode.instance.PlayTip("今日领取奖励次数已达上限");
- return result;
- }
- /**是否可以领取奖励2*/
- CheckCanReward2() {
- return this.rewardNum < this.richCfg.rewardnumber;
- }
- }
- /**更新道具参数*/
- export class RichPropItemParam {
- /**累加骰子变化量 +加 -减*/
- diceAdNum: number = 0;
- /**免费骰子变化量*/
- diceDailyNum: number = 0;
- /**双倍卡变化量*/
- doubleNum: number = 0;
- /**遥控卡变化量*/
- remoteCtrlNum: number = 0;
- /**奖励次数变化量*/
- rewardNum: number = 0;
- /**经书数变化量*/
- scriptureNum: number = 0;
- /**双倍奖励效果剩余次数*/
- doubleRemain: number = 0;
- /**看视频获取骰子 视频观看次数变化量*/
- diceAdvertise: number = 0;
- }
- /*
- 1.RedPackageNode jinrititle mingrititle null
- let targetPos: cc.Vec2 = this.target.getPosition();
- let bulletPos: cc.Vec2 = this.node.getPosition();
- let normalizeVec: cc.Vec2 = targetPos.subtract(bulletPos).normalize();
- //角度变化以y轴正方向为起点,逆时针角度递增
- this.node.angle = cc.v2(0, 1).signAngle(normalizeVec) * 180 / Math.PI;
- */
|