| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 |
- // const constants = require('Constants');
- // var reGameStates = require('GameStates');
- var AConfig = require('../Config');
- cc.Class({
- extends: cc.Component,
- properties: {
- //左上角按钮列表
- LeftMenu: cc.Node,
- //编辑建筑物时候的ui显示
- EditorialBuildings: cc.Node,
- //记录编辑按钮的父对象
- _thisEditBuildingsParent: cc.Node,
- _Cancellation: cc.Button,
- _Comfirmation: cc.Button,
- _buildTarget: cc.Node,
- //显示建筑的详细信息
- //建筑面板
- BuildingInfoView: cc.Node,
- //ui Mask 对应的touch
- UITouch: {
- default: null,
- type: cc.Node,
- },
- //设置面板
- SettingInfoView: cc.Node,
- //建筑面板
- //建筑物列表.后面根据数据动态添加content的内容。
- //todo..
- BuildView: cc.Node,
- BuildContent_Button: { default: null, type: cc.Button, visible: false },
- BuildContent_OldButton: { default: null, type: cc.Button, visible: false },
- BuildContent_Normal_Sprite: cc.SpriteFrame,
- BuildContent_Pressed_Sprite: cc.SpriteFrame,
- ButtonSelectedFrame: cc.Node,
- //建筑版面的介绍模板
- BuildContent_Name: cc.Label,
- BuildContent_Price: cc.Label,
- BuildContent_Synopsis: cc.Label,
- //人才面板
- PersonnelView: cc.Node,
- //股票面板
- StockView: cc.Node,
- //幸运转盘
- LuckView: cc.Node,
- // 底部的菜单栏
- BottomView: cc.Node,
- Evn: cc.Node,
- EveryDaySignView: cc.Node,
- //提示面板
- TipView: cc.Node,
- //提示面板预制
- TipViewPrefab: cc.Prefab,
- ShowRewards: cc.Node,
- BuildingFrameArray: {
- default: [],
- type: [cc.Node],
- serializable: true,
- },
- Goldenlabel: cc.Node,
- Diamondlabel: cc.Node,
- //显示的库存总量,人才界面
- cropContent: cc.Label,
- woodContent: cc.Label,
- mineContent: cc.Label,
- //ad
- ManageAd: cc.Node,
- },
- onLoad() {
- cc.game.setFrameRate(30);
- cc.director.preloadScene('Login', function () {
- }.bind(this));
- if (this.EditorialBuildings) {
- this._thisEditBuildingsParent = this.EditorialBuildings.parent;
- this._Cancellation = this.EditorialBuildings.getChildByName('Cancellation').getComponent(cc.Button);
- this._Comfirmation = this.EditorialBuildings.getChildByName('Confirmation').getComponent(cc.Button);
- }
- task.managerUi = this;
- var data1 = {
- name: "Whoareyou",
- openId: userData.openId,
- }
- UtilsWX.postMessage(data1);
- UtilsWX.shareMenu();
- // this.isGame();
- UtilsWX.initWXSubContextView(cc.find("Canvas/UICamera/wx"));
- UtilsWX.openWXSubContextView(false);
- this._ManageAd = this.ManageAd.getComponent('ManageAd');
- },
- isGame: function () {
- this.times = 0;
- cc.game.on(cc.game.EVENT_HIDE, function () {
- console.log("游戏进入后台", this.getTime());
- if (UtilsWX.shareTag == 0) {
- // this.onHideGame();//处理游戏切到后台时的事件
- this.times = this.getTime();
- task.onLoad();
- // this.onShowGame();//处理游戏切回前台时的事件
- cc.director.loadScene('Login', function () {
- task.showPointerNode = null;
- }.bind(this));
- }
- }, this);
- cc.game.on(cc.game.EVENT_SHOW, function () {
- console.log("重新返回游戏", this.getTime());
- // if (this.getTime()-this.times>=30000) {
- if (UtilsWX.shareTag == 0) {
- }
- UtilsWX.setShareTag(0);
- // }
- }, this);
- //本地测试
- // task.onLoad();
- // task.CreatorBtnHelpTest();
- },
- getTime: function () {
- return new Date().getTime();
- },
- // InitTask(BFirstLoadGame) {
- // // let BFirstLoadGame = parseInt(cc.sys.localStorage.getItem('BFirstLoadGame'));
- // // todo 新手教学 初始化
- // // console.log("初始化真的假的", BFirstLoadGame);
- // if (!BFirstLoadGame) {
- // // console.log("走这吗真", BFirstLoadGame);
- // task.onLoad();
- // //引导
- // this.taskCursor0();
- // } else {
- // // console.log("走这吗假", BFirstLoadGame);
- // this.initLayout();
- // task.onLoadno();
- // }
- // this.Init();
- // },
- initLayout: function () {
- task._init();
- task.addSeneceTaskIcon();
- task.CreatorBtnHelp();
- },
- start() {
- /*
- 其中第一个参数为捕捉的时间名,在官方文档中给出了几个选择,我们主要列举下触碰时间
- cc.Node.EventType.TOUCH_START 当手按下时触发
- cc.Node.EventType.TOUCH_END 当手抬起时候
- cc.Node.EventType.TOUCH_MOVE 当手按下滑动时
- cc.Node.EventType.TOUCH_CANCEL 当手按下滑动后 抬起时
- */
- if (this._Cancellation) this._Cancellation.node.on(cc.Node.EventType.TOUCH_END, this.onCancellationEditor, this);
- if (this._Comfirmation) this._Comfirmation.node.on(cc.Node.EventType.TOUCH_END, this.onConfirmationEditor, this);
- },
- Init() {
- let BuildingStateArray = GlobalD.GameData.GetBuildingLockStateArray();
- for (let i = 0; i < BuildingStateArray.length; i++) {
- if (BuildingStateArray[i] == 1) {
- this.OpenBuildingUILock(i, false);
- }
- let Price = this.BuildingFrameArray[i].getChildByName('Lock').getChildByName('PriceBG').getChildByName('label').getComponent(cc.Label).string = this.FormatMoney(AConfig.BuildingUnlockMoneyArray[i]);
- }
- //初始化,面板信息
- //运营费用数组
- let _runningCostArray = AConfig.RunningCostArray;
- for (let i = 0; i < _runningCostArray.length; i++) {
- let _contentButton = this.BuildingFrameArray[i].getComponent('Content_Button');
- _contentButton.Price = AConfig.RunningCostArray[i]; //运营费用
- //设置新的钻石价格
- let _DiamondNumArray = GlobalD.GameData.GetDiamondNumArray();
- _contentButton.DiamondPrice = _DiamondNumArray[i]; //钻石费用
- }
- },
- OpenBuildingUILock(Index, BLock) {
- let Lock = this.BuildingFrameArray[Index].getChildByName('Lock').active = BLock;
- let BuildingStateArray = GlobalD.GameData.GetBuildingLockStateArray();
- if (!BLock && BuildingStateArray[Index] == 0) {
- BuildingStateArray[Index] = 1;
- GlobalD.GameData.SetBuildingLockStateArray(BuildingStateArray);
- }
- },
- OnUnLockBuilding(event, CustomEventData, callback) {
- cc.loader.loadRes("prefab/UnlockBuiding", function (err, texture) {
- this.UnlockBuildingDialogView = cc.instantiate(texture);
- this.BuildView.addChild(this.UnlockBuildingDialogView);
- {
- //CloseBtn
- let close = this.UnlockBuildingDialogView.getChildByName("close");
- let clickEventHandler = new cc.Component.EventHandler();
- clickEventHandler.target = this.node;
- clickEventHandler.component = "ManageUI";
- clickEventHandler.handler = "onClickCloseInUnlockBuilding";
- let button = close.getComponent(cc.Button);
- button.clickEvents.push(clickEventHandler);
- }
- {
- //NoBtn
- let NoBTN = this.UnlockBuildingDialogView.getChildByName("NoBTN");
- let clickEventHandler = new cc.Component.EventHandler();
- clickEventHandler.target = this.node;
- clickEventHandler.component = "ManageUI";
- clickEventHandler.handler = "onClickNoBTNInUnlockBuilding";
- let button = NoBTN.getComponent(cc.Button);
- button.clickEvents.push(clickEventHandler);
- }
- {
- //YesBtn
- let YesBTN = this.UnlockBuildingDialogView.getChildByName("YesBTN");
- let clickEventHandler = new cc.Component.EventHandler();
- clickEventHandler.target = this.node;
- clickEventHandler.component = "ManageUI";
- clickEventHandler.handler = "onClickYesBTNInUnlockBuilding";
- clickEventHandler.customEventData = CustomEventData;
- let button = YesBTN.getComponent(cc.Button);
- button.clickEvents.push(clickEventHandler);
- }
- {
- //reButton
- let reButton = this.UnlockBuildingDialogView.getChildByName("reButton");
- let clickEventHandler = new cc.Component.EventHandler();
- clickEventHandler.target = this.node;
- clickEventHandler.component = "ManageUI";
- clickEventHandler.handler = "onWatchVideo";
- clickEventHandler.customEventData = CustomEventData;
- let button = reButton.getComponent(cc.Button);
- button.clickEvents.push(clickEventHandler);
- //预加载广告
- // 'adunit-3031ded224c6f52a',//视频激励广告2
- AD.loadVideoAdFromIndex('ManageUI', 3, (res) => {
- console.log('预加载广告回调:', res);
- });
- }
- //Close
- if (callback != null) {
- callback(this.UnlockBuildingDialogView);
- }
- }.bind(this));
- },
- onWatchVideo(event) {
- this.UnlockBuildingDialogView.destroy();
- //观看广告视频
- AD.playVideoAd((res) => {
- if (!res.isPlay) {
- console.log('ManageUi不能播放广告:', res.data);
- } else {
- GlobalD.GameData.PlusGolden(GlobalD.GameData.manageUIVideoAdGive[0]);
- GlobalD.GameData.PlusDiamond(GlobalD.GameData.manageUIVideoAdGive[1]);
- }
- });
- },
- onClickCloseInUnlockBuilding(event) {
- this.UnlockBuildingDialogView.destroy();
- },
- onClickNoBTNInUnlockBuilding(event) {
- this.UnlockBuildingDialogView.destroy();
- },
- onClickYesBTNInUnlockBuilding(event, CustomEventData) {
- this.UnlockBuildingDialogView.destroy();
- let Index = parseInt(CustomEventData);
- let CostCoin = AConfig.BuildingUnlockMoneyArray[Index];
- if (GlobalD.GameData.GetDiamond() > CostCoin || GlobalD.GameData.GetDiamond() == CostCoin) {
- GlobalD.GameData.PlusDiamond(-CostCoin);
- this.OpenBuildingUILock(Index, false);
- cc.loader.loadRes("prefab/show", function (err, texture) {
- this.ShowRewardsView = cc.instantiate(texture);
- this.BuildView.addChild(this.ShowRewardsView);
- let Rewards = this.ShowRewardsView.getChildByName('GivePrize').getChildByName('Rewards');
- Rewards.getComponent(cc.Sprite).spriteFrame = this.BuildingFrameArray[Index].getChildByName('New Sprite(Splash)').getComponent(cc.Sprite).spriteFrame;
- var Sunshine = this.ShowRewardsView.getChildByName('GivePrize').getChildByName('Sunshine');
- var GivePrize = this.ShowRewardsView.getChildByName('GivePrize');
- Sunshine.scaleX = 0;
- Sunshine.scaleY = 0;
- GivePrize.scaleX = 0;
- GivePrize.scaleY = 0;
- Sunshine.stopAllActions();
- GivePrize.stopAllActions();
- this.scheduleOnce(function () {
- var sc2 = cc.scaleTo(0.5, 0.5, 0.5);
- Sunshine.runAction(sc2);
- var sc3 = cc.scaleTo(0.5, 1, 1);
- GivePrize.runAction(sc3);
- var repeat = cc.repeatForever(cc.rotateBy(5.0, 360));
- Sunshine.runAction(repeat);
- }, 0.1);
- //CloseBtn
- let close = this.ShowRewardsView.getChildByName("close");
- let clickEventHandler = new cc.Component.EventHandler();
- clickEventHandler.target = this.node;
- clickEventHandler.component = "ManageUI";
- clickEventHandler.handler = "OnShowRewardsViewClose";
- let button = close.getComponent(cc.Button);
- button.clickEvents.push(clickEventHandler);
- }.bind(this));
- return;
- }
- //No Enough Diamond
- cc.loader.loadRes("prefab/ShowNoMoney", function (err, texture) {
- this.ShowNoMoneyView = cc.instantiate(texture);
- this.BuildView.addChild(this.ShowNoMoneyView);
- let DetailLabel = this.ShowNoMoneyView.getChildByName('DetailLabel');
- DetailLabel.getComponent(cc.Label).string = '钻石不够!'
- this.scheduleOnce(function () {
- this.ShowNoMoneyView.destroy();
- }.bind(this), 1);
- }.bind(this));
- },
- OnShowRewardsViewClose(event, CustomEventData) {
- this.ShowRewardsView.destroy();
- //分享页面
- //解锁房屋时候领取奖励后弹出分享
- task.startSharePrefab();
- },
- //欢迎光临
- taskCursor0: function () {
- //引导
- if (task.taskCursor == 0) {
- // let BelowTheMask = cc.find('Canvas/UICamera/BelowTheMask');
- //创建员工
- cc.find('GameNode/ManageWorker').getComponent('ManageWorker').onRecruit();
- cc.find('GameNode/ManageWorker').getComponent('ManageWorker').onRecruit();
- var Canvas = cc.find("Canvas/UICamera");
- dialogmanager.init(Canvas, function () {
- dialogmanager.dialog1();
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- task.CreatorBtnHelp();
- task.tasksstartBuildingview();
- this.noviceBuilding();
- }.bind(this));
- }
- },
- //去建造1
- taskCursor1: function () {
- //引导
- task.addTaskTips(this.nodePrefabsbg, task.newTaskName[2], 0, 0, task.taskCursorName[2], function (nodePrefabs) {
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[2]);
- this.taskCursor2();
- }.bind(this))
- }.bind(this));
- },
- //去建造农舍2
- taskCursor2: function () {
- task.addTaskTips(this.nodePrefabsbg, task.newTaskName[5], 0, 0, task.taskCursorName[2], function (nodePrefabs) {
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[2]);
- task.removeNode(this.nodePrefabsbg);
- //开始的 下面建造 提示
- task.tasksstartBuildingview();
- // this.taskCursor2();
- this.noviceBuilding();
- // this.novice();
- }.bind(this))
- }.bind(this));
- },
- //弹出购买提示
- onPurchaseTips(_contentButton) {
- // cc.log('是否用钻石购买建筑', _contentButton.node.name);
- if (this.TipViewPrefab) {
- let _TipView;
- _TipView = cc.instantiate(this.TipViewPrefab);
- _TipView.parent = this.TipView;
- _TipView.setPosition(cc.v2(0, 0));
- _TipView.getComponent('TipView').onShowTip({ ContentButton: _contentButton, TipViewNode: this.TipView });
- // cc.log(_TipView.name);
- }
- },
- //点击了建造列表里面的按钮时候改变样式
- onSetButtonState(Data, Synopsis) {
- // console.log("点了什么",Data);
- cc.Component.EventHandler.emitEvents(Data.Target.clickEvents);
- },
- onSetButtonInfoState(Data, Synopsis) {
- if (Synopsis) {
- this.onSetButtonInfo(Synopsis.Name, Synopsis.Price, Synopsis.Synopsis)
- }
- },
- //设置介绍信息
- onSetButtonInfo(_Name, _Price, _Synopsis) {
- this.BuildContent_Name.string = _Name;
- this.BuildContent_Price.string = _Price;
- this.BuildContent_Synopsis.string = _Synopsis;
- },
- //建筑详情
- openBuildView(event, index) {
- if (this.BuildView) {
- //面板设置index
- //环境
- if ('0' == index) {
- // this._className.string = '环境';
- }
- //劳动
- else if ('1' == index) {
- // this._className.string = '劳动';
- }
- //商铺
- else if ('2' == index) {
- // this._className.string = '商店';
- }
- }
- },
- //编辑对应的建筑
- onEditorialBuildings(mUI_buildTarget) {
- if (!this.EditorialBuildings) {
- cc.warn('EditorialBuildings is Null!')
- return;
- }
- this.EditorialBuildings.active = true;
- //重置上一个编辑建筑的状态
- if (this._buildTarget && this._buildTarget.getComponent('buildingsTouch')) {
- this._buildTarget.getComponent('buildingsTouch').onCancelEdit();
- }
- this._buildTarget = mUI_buildTarget;
- this.EditorialBuildings.parent = mUI_buildTarget;
- this.EditorialBuildings.setPosition(cc.v2(0, 0));
- },
- //取消编辑
- onCancellationEditor() {
- let buildTouch = this._buildTarget.getComponent('buildingsTouch');
- let isTaskNext = buildTouch.onTaskBuild();
- if (!isTaskNext) return;
- if (task.isMushBuildState) {
- cc.loader.loadRes('resUI/ShowNotEnoughMoney', function (err, texture) {
- var prefab = cc.instantiate(texture);
- prefab.getComponent('ShowNotEnoughMoney').Text("请点击'√'号");
- this._buildTarget.addChild(prefab);
- }.bind(this));
- return;
- }
- buildTouch.onCancelEdit();
- this.EditorialBuildings.active = false;
- this.EditorialBuildings.parent = this._thisEditBuildingsParent;
- this.EditorialBuildings.setPosition(cc.v2(10000, 100));
- this._buildTarget = null;
- },
- //确定编辑(创建建筑物 对号)
- onConfirmationEditor() {
- //获取建筑物上的组件
- let buildTouch = this._buildTarget.getComponent('buildingsTouch');
- let isTaskNext = buildTouch.onTaskBuild();
- if (!isTaskNext) return;
- buildTouch.onFinishEdit();
- this.EditorialBuildings.active = false;
- this.EditorialBuildings.parent = this._thisEditBuildingsParent;
- this.EditorialBuildings.setPosition(cc.v2(10000, 100));
- this._buildTarget = null;
- },
- //如果相等的话返回true
- verctor3IsEqual(vector1, vector2) {
- let isEqual = false;
- let out = new cc.Vec3();
- out.x = vector2.x - vector1.x;
- out.y = vector2.y - vector1.y;
- out.z = vector2.z - vector1.z;
- if (out.x == 0 && out.y == 0 && out.z == 0) {
- isEqual = true;
- }
- return isEqual;
- },
- //收起全部菜单
- onHideMenu() {
- // if (this.BuildView) {
- // this.BuildView.active = false;
- // }
- //音效设置界面
- if (this.SettingInfoView.active)
- this.onSetTouchStatus(this.SettingInfoView, false);
- //建造界面
- if (this.BuildView.active)
- this.onSetTouchStatus(this.BuildView, false);
- //人才界面
- if (this.PersonnelView.active)
- this.onSetTouchStatus(this.PersonnelView, false);
- //股票界面
- if (this.StockView.active)
- this.onSetTouchStatus(this.StockView, false);
- //转盘界面
- if (this.LuckView.active)
- this.onSetTouchStatus(this.LuckView, false);
- this._ManageAd.onCloseBannerAd();
- },
- //底部菜单栏
- onBottomMenuView(isActive) {
- if (this.BottomView) {
- this.BottomView.active = isActive;
- }
- if (isActive)
- this._ManageAd.onPlayBannerAd();
- else
- this._ManageAd.onCloseBannerAd();
- // cc.log('不能显示面板信息:');
- GlobalD.GameControl._isBuildingCanEdit = !isActive;
- },
- //开启信息显示
- onShowBuildingInfo(buildingInfo) {
- this.BuildingInfoView.active = true;
- if (!this._buildingInfoViewScript)
- this._buildingInfoViewScript = this.BuildingInfoView.getComponent('buildingInfoView');
- //显示房屋信息
- this._buildingInfoViewScript.onSetBuildingInfoView(buildingInfo);
- },
- //关闭信息显示
- onCloseBuildingInfo() {
- this.BuildingInfoView.active = false;
- },
- //进入编辑模式,
- onEnterEditing() {
- },
- onSetTouchStatus(target, isActive) {
- target.active = isActive;
- if (this.UITouch) {
- this.UITouch.active = isActive;
- }
- if (!isActive)
- this._ManageAd.onPlayBannerAd();
- },
- //音效设置界面
- onButtonEvent_Setting_OPen() {
- this.onHideMenu();
- this.onSetTouchStatus(this.SettingInfoView, true);
- },
- onButtonEvent_Setting_Close() {
- this.onSetTouchStatus(this.SettingInfoView, false);
- },
- //建造界面
- onButtonEvent_Building_OPen() {
- this.onHideMenu();
- this.onSetTouchStatus(this.BuildView, true);
- this.BuildView.getComponent('BuildingView').onSwitchBuildingContent(this.Evn.getComponent(cc.Button), 0);
- },
- novice: function () {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- task.removeTaskNode(task.taskCursorName[2]); //左上
- task.addTaskTips(BuildingView, task.taskPrefab[1], -180, 180, task.taskCursorName[2], function (nodePrefabs) {
- //手指
- this.nodePrefabs = nodePrefabs;
- }.bind(this));
- },
- novice1: function () {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- task.addTaskTips(BuildingView, task.novice[1], 0, 50, task.taskCursorName[3], function (node) {
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- UtilsPrefabs.setOff(node.getChildByName("SureBtn"));
- var mt = cc.moveTo(1, 110, 180);//右上
- var finished = cc.callFunc(function () {
- task.removeTaskNode(task.taskCursorName[3]);
- this.novice2();
- }.bind(this));
- var sequence = cc.sequence(mt, finished);
- this.nodePrefabs.runAction(sequence);
- task.isShowTaskNode(task.taskCursorName[3], false);
- }.bind(this))
- }.bind(this));
- },
- novice2: function () {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- task.addTaskTips(BuildingView, task.novice[2], 0, 50, task.taskCursorName[3], function (node) {
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- UtilsPrefabs.setOff(node.getChildByName("SureBtn"));
- var mt = cc.moveTo(1, -200, 0);//
- var finished = cc.callFunc(function () {
- task.removeTaskNode(task.taskCursorName[3]);
- this.novice3();
- }.bind(this));
- var sequence = cc.sequence(mt, finished);
- this.nodePrefabs.runAction(sequence);
- task.isShowTaskNode(task.taskCursorName[3], false);
- }.bind(this))
- }.bind(this));
- },
- novice3: function () {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- task.addTaskTips(BuildingView, task.novice[3], 0, -150, task.taskCursorName[3], function (node) {
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[3]);
- }.bind(this))
- }.bind(this));
- },
- noviceend: function () {
- // task.noviceend();
- },
- //外面管理的手指
- novicepersonnel: function () {
- task.removeTaskNode(task.taskCursorName[2]); //左上
- task.addTaskTips(task.personnelview, task.taskPrefab[1], 0, 0, task.taskCursorName[2], function (nodePrefabs) {
- //手指
- this.nodePrefabs = nodePrefabs;
- }.bind(this));
- },
- //外面的 建筑手指
- noviceBuilding: function () {
- // task.showManager(1,-50,-50);
- //建造农舍指引
- task.showTiledTile(0, 0, 0, 23, 25);
- task.onTaskBuildAHouseMask();
- },
- novice4: function () {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- task.addTaskTips(BuildingView, task.novice[4], 0, -200, task.taskCursorName[3], function (node) {
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[3]);
- }.bind(this))
- }.bind(this));
- },
- //关闭 建造框
- onButtonEvent_Building_Close() {
- // cc.log(this.BuildView);
- this.onSetTouchStatus(this.BuildView, false);
- },
- //人才界面
- onButtonEvent_Personnel_OPen() {
- this.onHideMenu();
- this.onSetTouchStatus(this.PersonnelView, true);
- },
- onButtonEvent_Personnel_Close() {
- this.onSetTouchStatus(this.PersonnelView, false);
- },
- //股票界面
- onButtonEvent_Stock_OPen() {
- this.onHideMenu();
- this.onSetTouchStatus(this.StockView, true);
- // console.log("所有建筑物数据", GlobalD.game.buildingsTiledMapUnit);
- UtilsWX.lookRankList(true);
- this.showFriend();
- },
- //限制
- returnDialog: function (cursor) {
- var num = 0;
- // console.log("要创建什么提示呢数字", cursor);
- switch (cursor) {
- case 1:
- num = 0;
- break;
- case 4:
- num = 1;
- break;
- case 6:
- num = 2;
- break;
- }
- console.log("要创建什么提示呢", task.returnPrefab[num]);
- var Canvas = cc.find("Canvas/UICamera");
- task.addTaskTips(Canvas, task.returnPrefab[num], 0, 0, task.taskCursorName[4], function (nodePrefabs) {
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[4]);
- }.bind(this))
- }.bind(this));
- },
- showFriend: function () {
- // var data1 = {
- // name: "Whoareyou",
- // openId : userData.openId
- // }
- // UtilsWX.postMessage(data1);
- var data = {
- name: "showFriend",
- }
- UtilsWX.postMessage(data);
- },
- onButtonEvent_Stock_Close() {
- this.onSetTouchStatus(this.StockView, false);
- var data = {
- name: "hideFriend",
- }
- UtilsWX.postMessage(data);
- setTimeout(function () {
- UtilsWX.lookRankList(false);
- }.bind(this), 200);
- },
- //转盘界面
- onButtonEvent_Luck_OPen() {
- this.onHideMenu();
- this.onSetTouchStatus(this.LuckView, true);
- if (this.nodePrefabsLuck != null) {
- task.removeNode(this.nodePrefabsLuck);
- }
- },
- isTask: function (obj) {
- var Canvas = cc.find("Canvas/UICamera");
- UtilsPrefabs
- .init(Canvas)
- .addPrefabs(UtilsPrefabs.sharePrefab[1], null, function (node) {
- var gosharebtn = UtilsPrefabs.getNode("gosharebtn", node);
- var close = UtilsPrefabs.getNode("close", node);
- UtilsPrefabs.setOn(close, function () {
- UtilsPrefabs.removePrefabs(Canvas, node.name);
- if (task.TaskIconCountClick == 5) {
- if (obj.currentTarget.name == "GetGift") {
- task.addTaskIconCountClick();
- task.removeTaskNodes();
- }
- }
- }.bind(this))
- UtilsPrefabs.setOn(gosharebtn, function () {
- // console.log("点击分享按钮");
- UtilsWX.sharebtn(function () {
- UtilsPrefabs.setOff(gosharebtn);
- GlobalD.GameData.PlusGolden(GlobalD.GameData.shareGive[0]);
- GlobalD.GameData.PlusDiamond(GlobalD.GameData.shareGive[1]);
- if (task.TaskIconCountClick == 5) {
- if (obj.currentTarget.name == "GetGift") {
- task.addTaskIconCountClick();
- task.removeTaskNodes();
- }
- }
- }.bind(this));
- UtilsPrefabs.removePrefabs(Canvas, node.name);
- }.bind(this))
- }.bind(this));
- },
- isTask4: function () {
- // console.log("现在是多少呢", task.TaskIconCountClick);
- if (task.TaskIconCountClick == 4) {
- task.addTaskIconCountClick();
- task.removeTaskNodes();
- }
- },
- onButtonEvent_Luck_Close(obj) {
- // console.log("现在是谁点的", obj);
- let Wheel = this.LuckView.getChildByName('Wheel').getComponent('Wheel');
- Wheel.node.active = true;
- Wheel.ShowRewards.active = false;
- this.onSetTouchStatus(this.LuckView, false);
- if (obj.target.name == "GetGift") {
- this.isTask(obj);
- }
- },
- onButtonEvent_EveryDay_OPen() {
-
- this.onHideMenu();
- this.onSetTouchStatus(this.EveryDaySignView, true);
- // console.log("我们进来了么",task.TaskIconCountClick);
- //打开每日签到 外面的按钮
- if (task.TaskIconCountClick == 4) {
- var EveryDaySign = cc.find("Canvas/UICamera/OverTheMask/EveryDaySignContainer/EveryDaySignView");
-
- task.removeTaskNode(task.taskCursorName[4]);
- task.addTaskTips(EveryDaySign, task.taskPrefab[1], 20, -470, task.taskCursorName[4], function (nodePrefabs) {
-
- }.bind(this));
- }
- },
- onButtonEvent_EveryDay_Close() {
- this.onSetTouchStatus(this.EveryDaySignView, false);
- // console.log("现在是多少呢",task.TaskIconCountClick);
- // this.isTask4();
- },
- onShowRewards: function (Index) {
- let ManageBuildingScript = this.node.getComponent('ManageBuildings');
- console.log("走了吗", Index);
- let GivePrize = this.ShowRewards.getChildByName('GivePrize');
- let Rewards = GivePrize.getChildByName('Rewards');
- Rewards.getComponent(cc.Sprite).spriteFrame = this.BuildingFrameArray[Index].getChildByName('New Sprite(Splash)').getComponent(cc.Sprite).spriteFrame;
- //开始播放
- var Sunshine = this.ShowRewards.getChildByName('GivePrize').getChildByName('Sunshine');
- Sunshine.scaleX = 0;
- Sunshine.scaleY = 0;
- GivePrize.scaleX = 0;
- GivePrize.scaleY = 0;
- Sunshine.stopAllActions();
- GivePrize.stopAllActions();
- this.scheduleOnce(function () {
- this.ShowRewards.opacity = 255;
- this.ShowRewards.active = true;
- var sc2 = cc.scaleTo(1, 0.5, 0.5);
- Sunshine.runAction(sc2);
- var sc3 = cc.scaleTo(1, 1, 1);
- GivePrize.runAction(sc3);
- var repeat = cc.repeatForever(cc.rotateBy(5.0, 360));
- Sunshine.runAction(repeat);
- }, 0.1);
- },
- onCloseShowRewards: function () {
- this.ShowRewards.active = false;
- },
- GoldenChangeCallBack: function (Num, LastMoney, CurrentMoney) {
- let Scale = 30;
- let Index = -1;
- // if(Num>10*Scale)
- // {
- // Index = 7;//伐木场
- // }
- // if(Num>30*Scale)
- // {
- // Index = 8;//矿坑
- // }
- // if(Num>70*Scale)
- // {
- // // Index = 9;//加工厂
- // }
- // if(Num>350*Scale && Num<450*Scale)
- // {
- // Index = 4;//单元楼
- // }
- if (Num > 4000 && Num < 4500) {
- Index = 4;//单元楼
- }
- // else if(Num>450*Scale && Num<550*Scale)
- // {
- // Index = 11;//鲜花店
- // }
- else if (Num > 4500 && Num < 5500) {
- Index = 11;//鲜花店
- } else if (Num > 550 * Scale && Num < 650 * Scale) {
- Index = 12;//甜品店
- }
- if (Num > 650 * Scale && Num < 750 * Scale) {
- Index = 7;//伐木场
- } else if (Num > 750 * Scale && Num < 950 * Scale) {
- Index = 13;//汉堡店
- }
- // else if(Num>850*Scale)
- // {
- // Index = 0;//公路
- // }
- else if (Num > 950 * Scale && Num < 1050 * Scale) {
- Index = 14;//咖啡店
- } else if (Num > 1050 * Scale && Num < 1150 * Scale) {
- Index = 5;//别墅
- } else if (Num > 1150 * Scale && Num < 1250 * Scale) {
- Index = 15;//洋装店
- }
- if (Num > 1250 * Scale && Num < 1350 * Scale) {
- Index = 8;//矿坑
- } else if (Num > 1350 * Scale) {
- Index = 16;//酒吧
- }
- // else if(Num>250*Scale)
- // {
- // Index = 4;//单元楼
- // }
- // else if(Num>600*Scale)
- // {
- // Index = 5;//别墅
- // }
- var BuildingStateArray = GlobalD.GameData.GetBuildingStateArray();
- if (Index == 0) {
- if (BuildingStateArray[Index] != 1) {
- BuildingStateArray[0] = 1;//公路
- BuildingStateArray[1] = 1;//路铲
- BuildingStateArray[2] = 1;//拆迁
- let Building0 = this.node.getComponent('ManageBuildings').BuildingArray[0];
- let Building1 = this.node.getComponent('ManageBuildings').BuildingArray[1];
- let Building2 = this.node.getComponent('ManageBuildings').BuildingArray[2];
- Building0.active = true;
- Building1.active = true;
- Building2.active = true;
- GlobalD.GameData.SetBuildingStateArray(BuildingStateArray);
- this.onShowRewards(Index);
- }
- } else {
- if (BuildingStateArray[Index] != 1 && Index != -1) {
- cc.log('Index=' + Index);
- BuildingStateArray[Index] = 1;
- let Building = this.node.getComponent('ManageBuildings').BuildingArray[Index];
- Building.active = true;
- GlobalD.GameData.SetBuildingStateArray(BuildingStateArray);
- this.onShowRewards(Index);
- }
- }
- let Diff = CurrentMoney - LastMoney;
- let InitMoneyNum = LastMoney;
- let AnimTimes = 0;
- let Times = 3;
- this.schedule(function () {
- if (Diff > 0) {
- InitMoneyNum += parseInt((CurrentMoney - LastMoney) / Times);
- } else {
- InitMoneyNum -= parseInt((CurrentMoney - LastMoney) / Times);
- }
- let result = this.FormatMoney(InitMoneyNum);
- if (AnimTimes == Times - 1) {
- this.Goldenlabel.getComponent(cc.Label).string = this.FormatMoney(CurrentMoney);
- return;
- }
- this.Goldenlabel.getComponent(cc.Label).string = result;
- AnimTimes++;
- }, 0.05, Times);
- },
- DiamondChangeCallBack: function (Num, LastMoney, CurrentMoney) {
- let Diff = CurrentMoney - LastMoney;
- let InitMoneyNum = LastMoney;
- let AnimTimes = 0;
- let Times = 3;
- this.schedule(function () {
- if (Diff > 0) {
- InitMoneyNum += parseInt((CurrentMoney - LastMoney) / Times);
- } else {
- InitMoneyNum -= parseInt((CurrentMoney - LastMoney) / Times);
- }
- let result = this.FormatMoney(InitMoneyNum);
- if (AnimTimes == Times - 1) {
- this.Diamondlabel.getComponent(cc.Label).string = this.FormatMoney(CurrentMoney);
- return;
- }
- this.Diamondlabel.getComponent(cc.Label).string = result;
- AnimTimes++;
- }, 0.05, Times);
- },
- FormatMoney(s, n) {
- n = n > 0 && n <= 20 ? n : 2;
- s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
- var l = s.split(".")[0].split("").reverse(),
- r = s.split(".")[1];
- let t = "";
- for (let i = 0; i < l.length; i++) {
- t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
- }
- return t.split("").reverse().join(""); //+ "." + r;
- }
- });
|