| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 |
- import date from "../Unit/date.js"
- var reGameStates = require('GameStates');
- /**
- * 操作租赁土地的相关业务
- */
- cc.Class({
- extends: cc.Component,
- properties: {
- leasePanelPrefabs: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //主信息面板
- infoBox: cc.Node,
- //时间计算对象
- showTimeOut: { default: null, visible: false },
- /**
- * 显示天数部分
- */
- upSliderNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- numLabel: {
- default: null,
- type: cc.Label,
- serializable: true,
- toolTip: "显示养的数量,这里对应的是租赁倍数"
- },
- leaseDate: {
- default: null,
- type: cc.Label,
- serializable: true,
- toolTip: "剩余天数/总天数"
- },
- levelLabel: {
- default: null,
- type: cc.Label,
- serializable: true,
- toolTip: "显示当前土地级别"
- },
- /**
- * 成熟期部分
- */
- midSliderNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- midDate: {
- default: null,
- type: cc.Label,
- serializable: true,
- toolTip: "剩余天数/总天数"
- },
- midAnimal: {
- default: null,
- type: cc.Node,
- serializable: true,
- toolTip: "养殖时候节点显示部分"
- },
- midSliderProgressNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- toolTip: "进度条"
- },
- notLeased: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- //初始化时候对应的土地的id
- initConfigLandId: -1,
- // configLandId: 1
- // createTime: "2022-01-10 21:25:30"
- // id: 1
- // isLease: 1
- // isPlant: 0
- // landDescribe: "土地1xxx"
- // leaseMultiple: 1
- // leaseTime: "2022-01-10 21:25:17"
- // name: "土地1"
- // plantMature: 0
- // plantStart: "2022-01-10 21:25:22"
- // updateTime: "2022-01-10 21:25:33"
- // userId: "4"
- // 已经租赁的土地信息
- leaseLandInfo: {
- default: null,
- visible: false
- },
- // createTime: "2022-01-10 21:25:30"
- // id: 4
- // initMultiple: 1
- // isInit: 1
- // isLease: 0
- // isPlant: 0
- // landDescribe: "一倍土地"
- // leaseMultiple: 1
- // leaseTime: "2022-01-10 21:25:17"
- // name: "土地4"
- // plantMature: 0
- // plantStart: "2022-01-10 21:25:22"
- // posX: 19
- // posY: 10
- // sizeX: 2
- // sizeY: 2
- // updateTime: "2022-01-10 21:25:33"
- // 未初始化时候的土地信息
- configLandInfo: {
- default: null,
- visible: false
- },
- showLandInfo: {
- default: null,
- type: cc.Node,
- serializable: true,
- toolTip: "显示土地信息"
- },
- landInfoPrefabs: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- // 已经种植的作物信息
- plantInfo: {
- default: null,
- visible: false
- },
- showPlantInfo: {
- default: null,
- type: cc.Node,
- serializable: true,
- toolTip: "显示种植信息"
- },
- plantInfoPrefabs: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //收获阶段
- harvestNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- stealHarvestNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- isHarvest: false,
- /**
- * 成熟时候显示的图片
- */
- harvestSprite: {
- default: null,
- type: cc.SpriteFrame,
- },
- _workingBuildingAnimal: null,
- //时间计算对象
- timeInterval: null,
- //是否显示showHarvest
- isShowHarvest: false,
- isShowIndex: 0,
- //检查土地是否到期
- isCheckLandState: false,
- _buildingView: null,
- //是否是自己的土地,记录一下
- bSelfLand: true,
- //
- giveOutLightNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- envBg: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- envBgSpriteFrameList: {
- default: [],
- type: cc.SpriteFrame,
- },
- currentAnimalType: {
- default: reGameStates.AnimalType.None,
- type: cc.Enum(reGameStates.AnimalType),
- toolTip: '当前的养殖动物类型'
- }
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- this._workingBuildingAnimal = this.node.getComponent("WorkingBuildingAnimal");
- this._buildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
- },
- start() {
- this.harvestNode.on(cc.Node.EventType.TOUCH_START, () => {
- if (GlobalD.GameData.isOnAddFruit) return;
- console.log("点击收获");
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获中..", 5);
- let data = { landId: this.leaseLandInfo.configLandId };
- //果实收入仓库,重置土地种植信息
- GlobalD.GameData.onAddFruit(data, (value) => {
- // console.log(value);
- if (0 === value.code) {
- //收成后处理相关状态
- this.leaseLandInfo.plant = 0;
- this.leaseLandInfo.seedInfo = null;
- this._resetLandInfo();
- //更新仓库列表
- this._buildingView.onUpdateList();
- if (value.data.isWithered) {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.data.msg, 2);
- } else {
- // "收获成功!"
- if (value.data.lossAmount > 0) {
- console.log("loss amount:" + value.data.lossAmount);
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获成功!损失了" + value.data.lossAmount + "个果实", 2);
- } else {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.data.msg, 2);
- }
- }
- } else if (706 === value.code) {
- //土地到期,没有更新刷新的处理刷新
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
- //重置锁定状态显示
- this.onLockLand();
- } else {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
- }
- });
- })
- this.stealHarvestNode.on(cc.Node.EventType.TOUCH_START, () => {
- //改成单个收取果实
- if (GlobalD.GameData.isOnAddFruit) return;
- let data = { otherUserId: GlobalD.OtherUserInfo.userId, otherLandId: this.leaseLandInfo.configLandId };
- //偷取果实收入仓库,重置土地种植信息
- GlobalD.GameData.onStealFruit(data, (value) => {
- if (0 === value.code) {
- //收成后处理相关状态
- this.onHideStealHarvest();
- let _manageUI = cc.find("GameNode/ManageUI");
- _manageUI.getComponent("ManageUI").onInitStealViewSuccessPrefab(value.data);
- //更新仓库列表
- this._buildingView.onUpdateList();
- //更新snb
- GlobalD.GameData.SetSNB(value.data.snb + value.data.snbPart);
- } else {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
- }
- });
- })
- },
- onSwitchEnvBgFromLevel(agent_level) {
- this.envBg.getComponent(cc.Sprite).spriteFrame = this.envBgSpriteFrameList[agent_level];
- },
- onSpawnLeasePanel() {
- let leasePanel = cc.instantiate(this.leasePanelPrefabs);
- let parent = cc.find('Canvas/UICamera/DAPPContainer');
- leasePanel.parent = parent;
- leasePanel.setPosition(0, 0);
- //把操作对象传入
- let leasePanelScript = leasePanel.getComponent("LeaseAnimalPlantInfo");
- leasePanelScript.leaseAnimalLandInfoNode = this;
- leasePanelScript.onInitLeaseInfo();
- },
- onLevelUpLand() {
- if (this.leaseLandInfo == null) {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "租赁土地不存在!", 1);
- return;
- }
- let data = {
- configLandId: this.leaseLandInfo.configLandId
- }
- GlobalD.GameData.onPostLandLevelUp(data, (value) => {
- //设置土地等级
- if (0 === value.code) {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 2);
- if (value.flag) {
- console.log(value);
- this.levelLabel.string = value.data.name;
- this.leaseLandInfo.landLevel = value.data.id;
- this.onSwitchEnvBgFromLevel(this.leaseLandInfo.landLevel - 1);
- }
- }
- });
- },
- /**
- * 解锁土地操作
- */
- onUnlockLand() {
- //直接删除此节点
- if (this.notLeased) {
- this.notLeased.active = false;
- this.midSliderNode.active = true;
- }
- },
- /**
- * 获取锁定状态
- */
- onGetUnlockLandState() {
- return this.notLeased.active;
- },
- /**
- * 重新锁定
- */
- onLockLand() {
- //显示按钮
- if (this.notLeased) {
- this.notLeased.active = true;
- }
- //清除当前租赁数据
- this.leaseLandInfo = null;
- this._resetLandInfo();
- },
- _resetLandInfo() {
- //隐藏养殖
- this.midAnimal.active = false;
- this._workingBuildingAnimal.onResetAnimal();
- this.isShowHarvest = false;
- this.isShowIndex = 0;
- if (this.timeInterval) {
- clearInterval(this.timeInterval);
- this.timeInterval = null;
- }
- //去除提示框
- this.upSliderNode.parent.active = false;
- this.midSliderNode.active = false;
- this.harvestNode.active = false;
- this.stealHarvestNode.active = false;
- //重置养殖场状态
- this._workingBuildingAnimal.onResetAnimal();
- this.onSetInfoBoxActive(false);
- },
- //设置config的土地信息
- setConfigLandInfo(value) {
- this.configLandInfo = value;
- // console.log("configLandInfo:",value);
- },
- /**
- * 设置其他用户租赁的土地信息
- * 比如去其他用户家里偷取物品,目前统一在这处理
- */
- setLeaseLandInfo(value, bSelf) {
- // console.log("土地信息是,bSelf:", bSelf);
- if (!value) {
- console.log("已租赁土地状态为空:", value);
- return;
- }
- this.onSetInfoBoxActive(false);
- //设置意思显示相关
- this.isShowHarvest = false;
- this.isShowIndex = 0;
- //重新设置租赁检测状态
- this.isCheckLandState = false;
- this.leaseLandInfo = value;
- this.midAnimal.active = false;
- //先解绑一下信息
- this.showLandInfo.off(cc.Node.EventType.TOUCH_START, this._showLandInfo, this);
- this.showPlantInfo.off(cc.Node.EventType.TOUCH_START, this._showPlantInfo, this);
- //每个作物直接实时计算时间
- if (this.timeInterval) {
- clearInterval(this.timeInterval);
- this.timeInterval = null;
- }
- //删除解锁图标
- this.onUnlockLand();
- this.bSelfLand = bSelf;
- // console.log("animal leaseLandInfo:", this.leaseLandInfo);
- //更新一下土地信息
- this.updateLandState(bSelf);
- },
- updateLandState(bSelf) {
- //如果是种植状态并且有返回种植信息
- if (1 === this.leaseLandInfo.isPlant && this.leaseLandInfo.seedInfo) {
- //这里处理的是养殖场
- //todo 处理枯萎状态
- switch (this.leaseLandInfo.seedInfo.picture) {
- case "cow":
- this.currentAnimalType = reGameStates.AnimalType.Cow;
- break;
- case "sheep":
- this.currentAnimalType = reGameStates.AnimalType.Sheep;
- break;
- case "pig":
- this.currentAnimalType = reGameStates.AnimalType.Pig;
- break;
- case "chicken":
- this.currentAnimalType = reGameStates.AnimalType.Chicken;
- break;
- case "duck":
- this.currentAnimalType = reGameStates.AnimalType.Duck;
- break;
- case "goose":
- this.currentAnimalType = reGameStates.AnimalType.Goose;
- break;
- case "carp":
- this.currentAnimalType = reGameStates.AnimalType.Carp;
- break;
- case "grassCarp":
- this.currentAnimalType = reGameStates.AnimalType.GrassCarp;
- break;
- case "silver":
- this.currentAnimalType = reGameStates.AnimalType.Silver;
- break;
- case "seaFish":
- this.currentAnimalType = reGameStates.AnimalType.SeaFish;
- break;
- case "shrimp":
- this.currentAnimalType = reGameStates.AnimalType.Shrimp;
- break;
- case "crab":
- this.currentAnimalType = reGameStates.AnimalType.Crab;
- break;
- }
- //显示养殖
- this.midAnimal.active = true;
- //显示进度条
- this.midSliderProgressNode.active = bSelf;
- this.numLabel.string = 'x' + this.leaseLandInfo.leaseMultiple;
- // 进度条按小时计算
- let _maturityAllHour = this.leaseLandInfo.seedInfo.maturity * 24
- let _remainAllHour = this.leaseLandInfo.plantDaysRemaining * 24 + this.leaseLandInfo.plantHoursRemaining;
- //计算剩余时间显示(进度条)
- let _midProccess = _maturityAllHour === 0 ? 0 : _remainAllHour / _maturityAllHour;
- this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = _midProccess;
- /**
- * 绑定生成显示信息面板,种植信息
- */
- this.showPlantInfo.on(cc.Node.EventType.TOUCH_START, this._showPlantInfo, this);
- }
- //显示剩余天数
- this.upSliderNode.parent.active = bSelf;
- // this.multipleLabel.string = this.leaseLandInfo.leaseMultiple;
- // 进去条按天算
- let sliderProgressScript = this.upSliderNode.getComponent("slider_progress");
- let _proccess = this.leaseLandInfo.leaseDays === 0 ? 0 : this.leaseLandInfo.leaseDaysRemaining / this.leaseLandInfo.leaseDays;
- sliderProgressScript.onSetProcgress(_proccess);
- // console.log(this.leaseLandInfo.configLandId,this.leaseLandInfo.landLevel);
- //设置土地等级,根据土地等级显示土地状态
- if (this.leaseLandInfo.landLevel != null && GlobalD.ConfigLevel != null) {
- this.onSwitchEnvBgFromLevel(this.leaseLandInfo.landLevel - 1);
- let _configLevelArray = GlobalD.ConfigLevel;
- for (let i = 0; i < _configLevelArray.length; i++) {
- if (this.leaseLandInfo.landLevel == _configLevelArray[i].id) {
- this.levelLabel.string = _configLevelArray[i].name;
- }
- }
- }
- /**
- * 绑定生成显示信息面板,现在土地信息
- */
- this.showLandInfo.on(cc.Node.EventType.TOUCH_START, this._showLandInfo, this);
- let lastUpdateTime = Date.now();
- let elapsedTime = 0;
- let updateFrequency = 1; //ms
- this.timeInterval = setInterval(() => {
- let currentTime = Date.now();
- let deltaTime = currentTime - lastUpdateTime;
- elapsedTime += deltaTime;
- if (elapsedTime >= updateFrequency) {
- elapsedTime -= updateFrequency;
- let _leaseDaysMill = this.leaseLandInfo.leaseDaysMill - elapsedTime;
- let _plantDaysMill = this.leaseLandInfo.plantDaysMill - elapsedTime;
- lastUpdateTime = currentTime;
- // 更新计时显示
- let [_lDay, _lHour, _lMinutes, _lSeconds] = date.remainFromMillisecond(_leaseDaysMill);
- //todo 处理了 this.leaseLandInfo.leaseDaysRemaining
- if (0 !== _lDay) {
- this.leaseDate.string = "剩" + _lDay + "天/" + this.leaseLandInfo.leaseDays + "天";
- } else if (0 !== _lHour) {
- this.leaseDate.string = "剩" + _lHour + "时/" + this.leaseLandInfo.leaseDays + "天";
- } else if (0 !== _lMinutes) {
- this.leaseDate.string = "剩" + _lMinutes + "分/" + this.leaseLandInfo.leaseDays + "天";
- } else {
- this.leaseDate.string = "剩" + _lSeconds + "秒/" + this.leaseLandInfo.leaseDays + "天";
- }
- //todo 如果租赁时间到了,重新锁定
- //重置锁定状态显示
- if (!this.isCheckLandState) {
- if (_leaseDaysMill <= 0) {
- this.isCheckLandState = true;
- //检查一次土地
- this.onCheckLand(this.leaseLandInfo.configLandId);
- }
- }
- if (1 === this.leaseLandInfo.isPlant && this.leaseLandInfo.seedInfo) {
- //获得服务器种植日期毫秒
- let [_pDay, _pHour, _pMinutes, _pSeconds] = date.remainFromMillisecond(_plantDaysMill);
- //todo 处理了 this.leaseLandInfo.plantDaysRemaining
- if (0 !== _pDay) {
- //否则显示天和小时
- this.midDate.string = "剩" + _pDay + "天" + _pHour + "时";
- } else if (0 !== _pHour) {
- this.midDate.string = "剩" + _pHour + "时" + _pMinutes + "分";
- } else {
- this.midDate.string = "剩" + _pMinutes + "分" + _pSeconds + "秒";
- }
- if (!this.isShowHarvest) {
- if (_plantDaysMill <= 0) {
- this.isShowHarvest = true;
- this.isShowIndex = 3;
- //如果传回的毫秒是小于零,说明成熟了
- //成熟阶段
- // this._workingBuildingAnimal.onSetGrow(this.currentAnimalType, 3, false);
- this.midAnimal.active = false;
- //成熟时候需要判断是否是收成状态
- //如果是自己的,显示收成
- //显示收成时候,需要处理一个枯萎状态,枯萎状态不能收成
- if (bSelf) {
- this.harvestNode.getChildByName("harvest").getComponent(cc.Sprite).spriteFrame = this._workingBuildingAnimal.onGetMatureBreed(this.leaseLandInfo.withered, this.currentAnimalType);
- //console.log(this.harvestNode.getChildByName("harvest").getComponent(cc.Sprite).spriteFrame);
- this.onShowHarvest();
- } else {
- //存在可偷的状态才设置这个图标,
- if (1 === this.leaseLandInfo.canSteal) {
- this.stealHarvestNode.getChildByName("harvest").getComponent(cc.Sprite).spriteFrame = this._workingBuildingAnimal.onGetMatureBreed(this.leaseLandInfo.withered, this.currentAnimalType);
- this.onShowStealHarvest();
- }
- }
- } else {
- let _maturityHour = this.leaseLandInfo.seedInfo.maturity * 24
- let _ratio = (_pDay * 24 + _pHour) / _maturityHour;
- if (_ratio > 0.5 && 1 !== this.isShowIndex) {
- this.isShowIndex = 1;
- this._workingBuildingAnimal.onSetGrow(this.currentAnimalType, 0, !this.leaseLandInfo.animalEat);
- console.log("_ratio:" + _ratio + "=" + this.leaseLandInfo.configLandId + ",状态:" + this.isShowIndex);
- } else if (_ratio <= 0.5 && _ratio >= 0 && 2 !== this.isShowIndex) {
- this.isShowIndex = 2;
- this._workingBuildingAnimal.onSetGrow(this.currentAnimalType, 1, !this.leaseLandInfo.animalEat);
- console.log("_ratio:" + _ratio + "=" + this.leaseLandInfo.configLandId + ",状态:" + this.isShowIndex);
- }
- }
- }
- }
- }
- });
- },
- _showLandInfo() {
- let leasePanel = cc.instantiate(this.landInfoPrefabs);
- let parent = cc.find('Canvas/UICamera/DAPPContainer');
- leasePanel.parent = parent;
- leasePanel.setPosition(0, 0);
- let leasePanelScript = leasePanel.getComponent("LandAnimalTextInfo");
- let _date = date.datedifference(this.leaseLandInfo.createTime, this.leaseLandInfo.leaseTime);
- let { configLandId, rentalExpenses, createTime, leaseTime, leaseMultiple, landDescribe } = this.leaseLandInfo;
- leasePanelScript.setInfo(configLandId, rentalExpenses, _date + "天", createTime, leaseTime, leaseMultiple, landDescribe, this);
- },
- _showPlantInfo() {
- let leasePanel = cc.instantiate(this.plantInfoPrefabs);
- let parent = cc.find('Canvas/UICamera/DAPPContainer');
- leasePanel.parent = parent;
- leasePanel.setPosition(0, 0);
- let leasePanelScript = leasePanel.getComponent("PlantInfo");
- let _harvest = this.leaseLandInfo.seedInfo.harvestQuantity + "x" + this.leaseLandInfo.leaseMultiple + "个";
- //price,maturity,plantStart,harvestQuantity,describe
- let { name, priceSnb, maturity, seedDescribe } = this.leaseLandInfo.seedInfo;
- leasePanelScript.setInfo(name, priceSnb, maturity + "天", this.leaseLandInfo.plantStart, _harvest, seedDescribe);
- },
- //检查土地状态
- onCheckLand(configLandId) {
- GlobalD.GameData.getLandState({
- landId: configLandId,
- callback: (value) => {
- console.log("检查土地数据:" + JSON.stringify(value.msg));
- //这里只判断土地是否过期
- if (706 === value.code) {
- //土地到期,没有更新刷新的处理刷新
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), configLandId + "号," + value.msg, 2);
- //重置锁定状态显示
- this.onLockLand();
- }
- }
- });
- },
- /**
- * 场景有多个收获预制时候,用GameData限制
- * 点击之后,重置土地信息, 并且收入进仓库果实列表中去
- * 需要防多次触发
- */
- onShowHarvest() {
- this.harvestNode.active = true;
- },
- /**
- * 场景有多个收获预制时候,用GameData限制
- * 点击之后,偷取果实
- * 需要防多次触发
- */
- onShowStealHarvest() {
- this.stealHarvestNode.active = true;
- },
- onHideStealHarvest() {
- this.stealHarvestNode.active = false;
- },
- /**
- * 设置总体信息面板显示
- * @param {boolean} bActive
- */
- onSetInfoBoxActive(bActive) {
- this.giveOutLightNode.active = bActive;
- if (!this.bSelfLand) {
- // console.log("其他用户的不用显示面板");
- return;
- }
- if (this.leaseLandInfo) {
- this.infoBox.active = bActive;
- if (bActive) {
- if (this.showTimeOut) {
- clearTimeout(this.showTimeOut);
- this.showTimeOut = null;
- }
- //自动隐藏面板
- this.showTimeOut = setTimeout(() => {
- this.infoBox.active = false;
- }, 5000)
- }
- }
- },
- /**
- * 喂养
- */
- onBuyAnimalFood() {
- if (!this.leaseLandInfo) {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "土地未租赁!", 2);
- return;
- }
- let data = { configLandId: this.leaseLandInfo.configLandId }
- GlobalD.GameData.onBuyAnimalFood(data, (value) => {
- if (0 === value.code && value.flag) {
- // this.leaseLandInfo.animalEat = true;
- // this._workingBuildingAnimal.onSetGrow(this.currentAnimalType, 1, !this.leaseLandInfo.animalEat);
- this.setLeaseLandInfo(value.data, true);
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 2);
- } else {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 2);
- }
- });
- },
- //显示光圈提示
- onSetGiveOutLight(bActive) {
- this.giveOutLightNode.active = bActive;
- },
- onDestroy() {
- if (this.timeInterval) {
- clearInterval(this.timeInterval);
- this.timeInterval = null;
- }
- if (this.showTimeOut) {
- clearTimeout(this.showTimeOut);
- this.showTimeOut = null;
- }
- }
- });
|