| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 |
- window.task = {
- taskPrefab: [
- "prefab/taskPrefab",
- "prefab/taskPrefabfinger",
- "prefab/taskPrefabLuckInfo",
- "prefab/taskPrefabEveyDay",
- "prefab/taskPrefabreturn",
- "prefab/taskPrefabAdministration",
- "prefab/taskPrefabBuilding",
- "prefab/taskPrefabEnd",
- ],
- sharePrefab: [
- "prefab/share",
- "prefab/sharepublic",
- ],
- returnPrefab: [
- "prefab/taskPrefabreturnLuck",
- "prefab/taskPrefabreturnEveyDay",
- "prefab/taskPrefabreturnAdministration",
- "prefab/taskPrefabreturnBuilding",
- ],
- //建筑物的那个新手教学
- novice: [
- "prefab/taskPrefabnovice1",
- "prefab/taskPrefabnovice2",
- "prefab/taskPrefabnovice3",
- "prefab/taskPrefabnovice4",
- ],
- taskCursorName: [
- //提示 去点击转盘 的dialog
- "taskCursor1",
- //场景转盘按钮 上面的提示光圈
- "taskCursor2",
- //提示去点签到
- "taskCursor3",
- //提示去点签到
- "taskCursor4",
- //提示去点签到
- "taskCursor5",
- ],
- newTaskName: [
- //0黑背景0
- "prefab/taskPrefabAgb",
- //1欢迎来到《首富小镇》
- "prefab/taskPrefabStart",
- //2您新招聘的员工已经到位了
- "prefab/taskPrefabbuy",
- //3 5块钱买地
- "prefab/taskPrefabbuyBuyinggrain",
- //4
- "prefab/taskPrefabbuyBuyinggrainwait",
- //5每一个员工都需要有个休息的地方来回复体力
- "prefab/task/taskPrefab1",
- //6多开坑土地初期是一个赚钱的好办法
- "prefab/task/taskPrefab2",
- //7种下农田后
- "prefab/task/taskPrefab3",
- //8 哎呀!好像赚钱的速度好慢啊!这样什么时候可以成为《首富》
- "prefab/task/taskPrefab4",
- //9 再盖一个农舍吧
- "prefab/task/taskPrefabFarmhouse",
- //10 地里面有钻石
- "prefab/task/taskPrefab5",
- //11 收钻石 之后的提示
- "prefab/task/taskPrefab6",
- //12 去每日签到
- "prefab/task/taskPrefab7",
- //13 欢乐大转盘,抽奖抽到手软。
- "prefab/task/taskPrefab8",
- //14 先完成一个小目标 存款50W
- "prefab/task/taskPrefab9",
- //15 恭喜您的财富累计到达50W
- "prefab/task/taskPrefab10",
- //16 有了加工厂后,我们试试开出您的第一个商店
- "prefab/task/taskPrefab11",
- //17 有了加工厂后,我们试试开出您的第一个商店
- "prefab/task/taskPrefab12",
- //18 有了加工厂后,我们试试开出您的第一个商店
- "prefab/task/taskPrefab13",
- //19
- "prefab/task/taskPrefabVideo",
- ],
- //农舍 农田 的 虚影
- TiledTile: [
- "prefab/taskPrefabTiledTileFarmhouse",
- "prefab/taskPrefabTiledTileFarmland",
- ],
- //必须建造在虚影上面
- //如果为true 的话,就是进入虚影建造状态
- isMushBuildState: false,
- //虚影所在的位置
- virtualShadowPos: null,
- //虚影所在的位置的终点坐标
- virtualShadowPosEnd: null,
- TaskIconCount: [
- "prefab/taskPrefabTiledTileFarmhouse",
- ],
- itemPrefab: [
- "prefab/item/taskPrefabItem0",
- "prefab/item/taskPrefabItem1",
- "prefab/item/taskPrefabItemFarmhouse",
- "prefab/item/taskPrefabItem2",
- "prefab/item/taskPrefabItem3",
- "prefab/item/taskPrefabItem4",
- "prefab/item/taskPrefabItem5",
- "prefab/item/taskPrefabItem6",
- "prefab/item/taskPrefabItem7",
- "prefab/item/taskPrefabItem8",
- "prefab/item/taskPrefabItem9",
- "prefab/item/taskPrefabItem10",
- "prefab/item/taskPrefabItemShare",
- ],
- publicGive: [
- //种下田地
- 200,
- ],
- managerUi: null,
- //农田人物购买,只能触发一次
- taskGotoBuyOnly: false,
- // LIFE-CYCLE CALLBACKS:
- taskOnLoad() {
- this._init();
- //点钻石 之后的进入限定
- this.taskZSTag = false;
- this.taskCount = 0;
- this.taskCursor = this.taskCount;
- this.taskNodes = [];
- task.setOnClickTaskIcon(function () {
- task.showtaskPrefabView(task.taskCallBack);
- }.bind(this));
- },
- taskOnLoadno() {
- this.taskNodes = [];
- task.setOnClickTaskIcon(function () {
- task.showtaskPrefabView(task.taskCallBack);
- }.bind(this));
- },
- _init: function () {
- this.Canvas = cc.find("Canvas/UICamera");
- //管理建造 股市 转盘 什么的父类
- this.BelowTheMask = cc.find("Canvas/UICamera/BelowTheMask/TopButton");
- //外面管理的node
- this.personnelview = cc.find("Canvas/UICamera/BelowTheMask/BottomButton/personnel");
- //外面建造的node
- this.Buildingview = cc.find("Canvas/UICamera/BelowTheMask/BottomButton/Building");
- //外面股市的node
- this.EquityMarketview = cc.find("Canvas/UICamera/BelowTheMask/TopButton/EquityMarket");
- //外面转盘的node
- this.LuckDrawview = cc.find("Canvas/UICamera/BelowTheMask/TopButton/LuckDraw");
- //外面签到的node
- this.EveryDaySignview = cc.find("Canvas/UICamera/BelowTheMask/TopButton/EveryDaySign");
- //人才管理里面的招聘按钮
- this.RecruitButton = cc.find("Canvas/UICamera/PersonnelContainer/PersonnelView/WorkerASaleManage/Worker/Recruit/RecruitBtn");
- //里面的 住宅
- this.Env = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/Menu/Env");
- //里面的 劳动
- this.Labour = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/Menu/Labour");
- //里面的 商铺
- this.Shop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/Menu/Shop");
- //里面的 特殊
- this.SpeBuilding = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/Menu/SpeBuilding");
- //todo 住宅
- //建造里面的农舍1
- this.Farmhouse = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Farmhouse");
- //建造里面的农舍2
- this.Apartment = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Apartment");
- //建造里面的农舍3
- this.Villa = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Villa");
- //建造里面的道路
- this.Road = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Road");
- //建造里面的铲子
- this.Shovel = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Shovel");
- //建造里面的拆迁
- this.Hammer = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/EnvContent/Hammer");
- //todo 劳动
- //农田
- this.FamerLand = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/LabourContent/FamerLand");
- //树木
- this.LoggingYard = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/LabourContent/LoggingYard");
- //矿石
- this.MineField = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/LabourContent/MineField");
- //加工厂
- this.Factory = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/LabourContent/Factory");
- //todo 商铺
- //shop 1
- this.ConvenienceStore = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/ConvenienceStore");
- //shop 2
- this.FlowerShop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/FlowerShop");
- //shop 3
- this.DessertShop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/DessertShop");
- //shop 4
- this.FastFoodShop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/FastFoodShop");
- //shop 5
- this.CoffeeShop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/CoffeeShop");
- //shop 6
- this.DressShop = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/DressShop");
- //shop 7
- this.Bar = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/ShopContent/Bar");
- //todo 特殊
- //樱花树
- this.GreenBelt = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/GreenBelt");
- //喷泉
- this.Fountain = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/Fountain");
- //游乐场
- this.Playground = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/Playground");
- //医院
- this.Hospital = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/Hospital");
- //警察局
- this.PoliceOffice = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/PoliceOffice");
- //警察局
- this.Bank = cc.find("Canvas/UICamera/BuildingContainer/BuildingView/ScrollContent/view/content/SpeBuildingContent/Bank");
- this.ManagerViews = [];
- //0
- this.ManagerViews.push(this.personnelview);
- this.ManagerViews.push(this.Buildingview);
- this.ManagerViews.push(this.EquityMarketview);
- this.ManagerViews.push(this.LuckDrawview);
- this.ManagerViews.push(this.EveryDaySignview);
- //5
- this.ManagerViews.push(this.Env);
- this.ManagerViews.push(this.Labour);
- this.ManagerViews.push(this.Shop);
- this.ManagerViews.push(this.SpeBuilding);
- //住宅
- //9
- this.ManagerViews.push(this.Farmhouse);
- //10
- this.ManagerViews.push(this.Apartment);
- //11
- this.ManagerViews.push(this.Villa);
- //12
- this.ManagerViews.push(this.Road);
- //13
- this.ManagerViews.push(this.Shovel);
- //14
- this.ManagerViews.push(this.Hammer);
- //劳动
- //15 农舍
- this.ManagerViews.push(this.FamerLand);
- //16
- this.ManagerViews.push(this.LoggingYard);
- //17
- this.ManagerViews.push(this.MineField);
- //18
- this.ManagerViews.push(this.Factory);
- //商店
- //19
- this.ManagerViews.push(this.ConvenienceStore);
- //20
- this.ManagerViews.push(this.FlowerShop);
- //21
- this.ManagerViews.push(this.DessertShop);
- //22
- this.ManagerViews.push(this.FastFoodShop);
- //23
- this.ManagerViews.push(this.CoffeeShop);
- //24
- this.ManagerViews.push(this.DressShop);
- //25
- this.ManagerViews.push(this.Bar);
- //特殊
- //26 绿化带
- this.ManagerViews.push(this.GreenBelt);
- //27
- this.ManagerViews.push(this.Fountain);
- //28
- this.ManagerViews.push(this.Playground);
- //29
- this.ManagerViews.push(this.Hospital);
- //30
- this.ManagerViews.push(this.PoliceOffice);
- //31
- this.ManagerViews.push(this.Bank);
- this.taskTags = false;
- this.sharetime = 2000;
- this.addTaskCountClicktime = 2000;
- },
- //显示手
- showPointer: function (type, x, y, sc) {
- var s = 1;
- if (sc != null) {
- s = sc;
- }
- var height = this.ManagerViews[type].height / 2;
- var width = this.ManagerViews[type].width / 2;
- if (this.showPointerNode == null) {
- this.addTaskTipsNoArr(this.ManagerViews[type], task.taskPrefab[1], x, y, this.ManagerViews[type].name, function (nodePrefabs) {
- nodePrefabs.parent = this.ManagerViews[type];
- this.showPointerNode = nodePrefabs;
- this.showPointerNode.active = true;
- this.showPointerNode.scale = s;
- this.showPointerNode.x = x;
- this.showPointerNode.y = y;
- this.showPointerNode.y -= height - 30;
- this.showPointerNode.x += width - 30;
- }.bind(this));
- } else {
- this.showPointerNode.parent = this.ManagerViews[type];
- this.showPointerNode.active = true;
- this.showPointerNode.scale = s;
- this.showPointerNode.x = x;
- this.showPointerNode.y = y;
- this.showPointerNode.y -= height - 30;
- this.showPointerNode.x += width - 30;
- }
- // console.log("现在里面的数据是",this.showPointerNode);
- },
- //隐藏 手
- hidePointer: function () {
- if (this.showPointerNode != null) {
- this.showPointerNode.active = false;
- }
- },
- //重置一下建造的虚影的初始参数
- onShadowArchitectureReset() {
- task.isMushBuildState = false;
- task.virtualShadowPos = null;
- task.virtualShadowPosEnd = null;
- },
- //260,-860
- //可以显示虚影建筑提示
- showTiledTile: function (type, myx, myy, x, y) {
- task.isMushBuildState = true;
- task.virtualShadowPos = cc.v2(x + 1, y + 1);
- var MyMapNode = cc.find("Canvas/MyMapNode");
- //移动camera 对应位置
- cc.find('GameNode/ManageTask').getComponent('ManageTask').onMoveToTiledTile(x, y);
- //引导 农舍
- task.addTaskTips(MyMapNode, task.TiledTile[type], myx, myy, task.taskCursorName[4], function (nodePrefabs1) {
- // console.log("现在里面的数据是", nodePrefabs1);
- var nodePrefabss = UtilsPrefabs.getNode("nodes", nodePrefabs1);
- var TiledTile = nodePrefabss.getComponent("TiledTile");
- TiledTile.setTiledTilePos(x, y);
- }.bind(this));
- },
- showManagerhide: function () {
- this.removeTaskNodes();
- },
- //点击任务按钮时候,显示 任务列表
- showtaskPrefabView: function (onclick) {
- if (task.TaskIconCountClick >= 13) {
- task.SeneceTaskIconNode
- .getChildByName("SureBtn")
- .getChildByName("redtips").active = false;
- return;
- }
- this.addTaskTips(this.Canvas, "prefab/taskPrefabView", 0, 0, "taskPrefabView", function (nodePrefabs) {
- this.taskPrefabView = nodePrefabs;
- // 任务条目
- this.addItemtaskView(this.TaskIconCountClick, onclick);
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("close"), function () {
- this.hidetaskPrefabView();
- }.bind(this))
- }.bind(this));
- },
- //任务按钮调用
- taskCallBack: function () {
- console.log('taskCallBack:', task.TaskIconCountClick);
- if (task.TaskIconCountClick == 0) {
- //农田
- dialogmanager.init(task.Canvas, function () {
- dialogmanager.creatorFarming();
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- //创建 农田 引导 去点建造
- task.showManagerhide();
- task.showTiledTile(1, 0, -50, 25, 25);
- task.onTaskFarmlandMask();
- }.bind(this));
- } else if (task.TaskIconCountClick == 1) {
- //招聘
- dialogmanager.init(task.Canvas, function () {
- dialogmanager.Recruit();
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- let _taskNodes = [];
- _taskNodes.push(task.personnelview);
- _taskNodes.push(task.RecruitButton);
- task.onInitTaskMask(_taskNodes);
- }.bind(this));
- } else if (task.TaskIconCountClick == 2) {//中间这部分全部直接跳转铺路教程
- //重新盖宿舍
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 3) {
- //领取农田的钻石
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 4) {
- //每日签到
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 5) {
- //转盘
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 6) {
- //目标赚3k
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 7) {
- //创建一个加工厂
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 8) {
- //创建一个便利店
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 9) {
- //创建一个绿化带
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 10) {
- this.onTaskPaveRoadsDialog();
- } else if (task.TaskIconCountClick == 12) {
- //最后分享任务
- dialogmanager.init(task.Canvas, function () {
- dialogmanager.Share1();
- task.SeneceTaskIconNode
- .getChildByName("SureBtn")
- .getChildByName("redtips").active = false;
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- UtilsPrefabs.startSharePrefab(function () {
- task._setTaskIconCountClick(13);
- setTimeout(() => {
- task.taskCallBack();
- }, 500);
- }.bind(this), function () {
- task._setTaskIconCountClick(13);
- setTimeout(() => {
- task.taskCallBack();
- }, 500);
- }.bind(this), function (node) {
- var anim = node.getComponent(cc.Animation);
- anim.play();
- node.getChildByName("SharePicBG").getChildByName('Ribbon-cutting').zIndex = 10000;
- node.getChildByName("LittleTitleLabel").getComponent(cc.Label).string = "新店开张!快邀请好友一起来剪彩吧!";
- node.getChildByName("gosharebtn").getChildByName("Btn_Share_Cutting").zIndex = 10000;
- }.bind(this));
- }.bind(this));
- } else if (task.TaskIconCountClick == 13) {
- //商人去农田购买,新手任务最后一步 todo...
- task._setTaskCount(2);
- } else if (task.TaskIconCountClick == 14) {
- //结束任务调用
- task.onSetTaskEnd();
- } else {//旧用户都是11结束,这里如果TaskIconCountClick不存在上面流程,默认设置为结束。 if (task.TaskIconCountClick == 11)
- if (task.SeneceTaskIconNode)
- task.SeneceTaskIconNode.getChildByName("SureBtn").getChildByName("redtips").active = false;
- //没有任务
- task.taskCursor = -1;
- //跳过教程的时候,设置结束
- task.TaskIconCountClick = 14
- task.onShadowArchitectureReset();
- }
- },
- onSetTaskEnd() {
- if (task.SeneceTaskIconNode)
- task.SeneceTaskIconNode.getChildByName("SureBtn").getChildByName("redtips").active = false;
- //农田购买
- if (task.TaskIconCountClick < 13) {
- task.TaskIconCountClick = 13;
- return;
- }
- //如果是商人部分,直接设置结束
- //没有任务
- task.taskCursor = -1;
- //跳过教程的时候,设置商人为最后一步
- task.TaskIconCountClick = 14
- task.onShadowArchitectureReset();
- },
- //农田模板
- onTaskFarmlandMask() {
- let _taskNodes = [];
- _taskNodes.push(task.Buildingview);
- _taskNodes.push(task.Labour);
- _taskNodes.push(task.FamerLand);
- task.onInitTaskMask(_taskNodes, 'Farmland');
- },
- //农舍模板
- onTaskBuildAHouseMask() {
- let _taskNodes = [];
- _taskNodes.push(task.Buildingview);
- _taskNodes.push(task.Farmhouse);
- task.onInitTaskMask(_taskNodes, 'House');
- },
- //铺路对话开始
- onTaskPaveRoadsDialog() {
- //铺路教程
- dialogmanager.init(task.Canvas, function () {
- dialogmanager.pave();
- // task.setListView(18);
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- task.showManagerhide();
- cc.loader.loadRes("prefab/taskPrefabTiledTileHighway", function (err, texture) {
- let _taskMask = cc.instantiate(texture);
- //添加进控制数组
- task.pushTaskNodes(_taskMask);
- //设置生成遮罩的节点
- _taskMask.parent = cc.find('Canvas/MyMapNode');
- let _tiled = GlobalD.TiledMap._tilePosFromLocation(_taskMask.getPosition());
- //移动camera 对应位置
- cc.find('GameNode/ManageTask').getComponent('ManageTask').onMoveToTiledTile(_tiled.x, _tiled.y);
- task.isMushBuildState = true;
- task.virtualShadowPos = cc.v2(_tiled.x, _tiled.y);
- let _taskNodes = [];
- _taskNodes.push(task.Buildingview);
- _taskNodes.push(task.Road);
- task.onInitTaskMask(_taskNodes, 'Highway');
- }.bind(this));
- }.bind(this));
- },
- //铺路模板
- onTaskPaveRoadsMask() {
- let _taskMask = task.getTaskNode('taskPrefabTiledTileHighway');
- if (!_taskMask || !task.isMushBuildState) return;
- let _tiled = GlobalD.TiledMap._tilePosFromLocation(_taskMask.getPosition());
- //移动camera 对应位置
- cc.find('GameNode/ManageTask').getComponent('ManageTask').onMoveToTiledTile(_tiled.x, _tiled.y);
- task.isMushBuildState = true;
- task.virtualShadowPos = cc.v2(_tiled.x, _tiled.y);
- let _taskNodes = [];
- _taskNodes.push(task.Buildingview);
- _taskNodes.push(task.Road);
- task.onInitTaskMask(_taskNodes, 'Highway');
- },
- setListView: function (num) {
- task.addTaskTips(this.Canvas, task.newTaskName[num], 0, 0, task.taskCursorName[0], function (nodePrefabs) {
- // console.log("是什么呢",nodePrefabs);
- this.ListView = nodePrefabs;
- this.addListView();
- }.bind(this));
- },
- addListView: function (ListView, callback) {
- var nodePrefabs = null;
- if (ListView != null) {
- nodePrefabs = ListView;
- } else {
- nodePrefabs = this.ListView;
- }
- var count = 0;
- this.layout = nodePrefabs.getChildByName("layout");
- // console.log("是什么呢", nodePrefabs);
- for (var i = 0; i < this.layout.children.length; i++) {
- var children = this.layout.children[i];
- children.active = false;
- }
- this.layout.children[count].active = true;
- // console.log("是什么呢",this.layout.children[count]);
- //黑底
- // this.nodePrefabsbg = nodePrefabs;
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- count++;
- if (this.layout.children[count] == null) {
- if (callback != null) {
- callback();
- } else {
- task.removeTaskNode(task.taskCursorName[0]);
- this.startSharePrefab();
- }
- return;
- }
- for (var i = 0; i < this.layout.children.length; i++) {
- var children = this.layout.children[i];
- children.active = false;
- }
- this.layout.children[count].active = true;
- this.layout.children[count].getChildByName("curr").getComponent(cc.Label).string = "(" + (count + 1) + '/' + this.layout.children.length + ")";
- }.bind(this))
- },
- //显示 任务View
- hidetaskPrefabView: function () {
- this.removeNode(this.taskPrefabView);
- },
- addItemtaskView: function (num, onclick) {
- this.addTaskTips(this.taskPrefabView, this.itemPrefab[num], 0, 130, "taskPrefabItem", function (nodePrefabs) {
- // console.log("条目",nodePrefabs);
- var guideview = UtilsPrefabs.getNode("guideview", nodePrefabs);
- var guide = UtilsPrefabs.getNode("guide", guideview);
- UtilsPrefabs.setOn(guide, function () {
- // console.log("数组是很么",nodePrefabs);
- this.hidetaskPrefabView();
- if (onclick != null) {
- onclick(nodePrefabs);
- }
- }.bind(this))
- }.bind(this));
- },
- //页面上增加任务按钮
- addSeneceTaskIcon: function (callback) {
- this.addTaskTipsNoArr(this.BelowTheMask, "prefab/SeneceTaskIcon", 150, 400, "SeneceTaskIcon", function (nodePrefabs) {
- this.SeneceTaskIconNode = nodePrefabs;
- nodePrefabs.parent = this.BelowTheMask;
- //如果没有任务,去掉提示
- if (task.TaskIconCountClick >= 13) {
- this.SeneceTaskIconNode
- .getChildByName("SureBtn")
- .getChildByName("redtips").active = false;
- }
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- // console.log("调用了么",this.BelowTheMask);
- if (this.onClickTaskIcon != null) {
- this.onClickTaskIcon(this.SeneceTaskIconNode);
- }
- }.bind(this));
- if (callback)
- callback();
- }.bind(this));
- },
- //点击了 任务按钮
- setOnClickTaskIcon: function (onClickTaskIcon) {
- this.onClickTaskIcon = onClickTaskIcon;
- },
- onClickTaskIcon: function () {
- },
- addTaskTips: function (node, PrefabsName, x, y, name, callback) {
- var _x = 0;
- var _y = 0;
- if (x != null) {
- _x = x;
- }
- if (y != null) {
- _y = y;
- }
- UtilsPrefabs
- .init(node)
- .addPrefabs(PrefabsName, null, function (nodePrefabs) {
- if (name != null) {
- nodePrefabs.name = name;
- }
- nodePrefabs.x = _x;
- nodePrefabs.y = _y;
- this.pushTaskNodes(nodePrefabs);
- if (callback != null) {
- callback(nodePrefabs);
- }
- }.bind(this));
- },
- addTaskTipsNoArr: function (node, PrefabsName, x, y, name, callback) {
- var _x = 0;
- var _y = 0;
- if (x != null) {
- _x = x;
- }
- if (y != null) {
- _y = y;
- }
- UtilsPrefabs
- .init(node)
- .addPrefabs(PrefabsName, null, function (nodePrefabs) {
- if (name != null) {
- nodePrefabs.name = name;
- }
- nodePrefabs.x = _x;
- nodePrefabs.y = _y;
- if (callback != null) {
- callback(nodePrefabs);
- }
- }.bind(this));
- },
- addTaskCount: function () {
- //0 提示 需要 去点 转盘
- //1 提示转盘 外框
- //2 删除手 和 提示转盘 外框
- this.taskCount++;
- this.taskCursor = this.taskCount;
- },
- //直接设置人物点
- _setTaskCount(num) {
- this.taskCount = num;
- this.taskCursor = this.taskCount;
- },
- //任务 增加索引
- addTaskIconCountClick: function () {
- //0 提示 需要 去点 转盘
- //1 提示转盘 外框
- //2 删除手 和 提示转盘 外框
- this.TaskIconCountClick++;
- cc.sys.localStorage.setItem('TaskIconCountClick', this.TaskIconCountClick);
- task.hidePointer();
- if (this.TaskIconCountClick != 4
- || this.TaskIconCountClick != 5
- ) {
- task.showtaskPrefabView(task.taskCallBack);
- }
- switch (this.TaskIconCountClick) {
- case 4:
- this.EveryDaySignview.active = true;
- break;
- }
- },
- _setTaskIconCountClick(num) {
- this.TaskIconCountClick = num;
- cc.sys.localStorage.setItem('TaskIconCountClick', this.TaskIconCountClick);
- // task.hidePointer();
- // if (this.TaskIconCountClick != 4 || this.TaskIconCountClick != 5) {
- // task.showtaskPrefabView(task.taskCallBack);
- // }
- if (this.TaskIconCountClick == 4) {
- this.EveryDaySignview.active = true;
- }
- },
- pushTaskNodes: function (node) {
- if (node != null) {
- // console.log("數組",task);
- this.taskNodes.push(node)
- }
- },
- removeTaskNodes: function () {
- for (var i = 0; i < this.taskNodes.length; i++) {
- if (cc.isValid(this.taskNodes[i])) {
- this.taskNodes[i].destroy();
- }
- }
- this.taskNodes = [];
- },
- removeTaskNode: function (name) {
- for (var i = 0; i < this.taskNodes.length; i++) {
- if (this.taskNodes[i].name == name) {
- if (cc.isValid(this.taskNodes[i])) {
- this.taskNodes[i].destroy();
- }
- }
- }
- },
- getTaskNode(name) {
- for (var i = 0; i < this.taskNodes.length; i++) {
- if (this.taskNodes[i].name == name) {
- if (cc.isValid(this.taskNodes[i])) {
- return this.taskNodes[i];
- }
- }
- }
- },
- removeNode: function (node) {
- if (node != null) {
- node.destroy();
- }
- },
- isShowTaskNode: function (name, b) {
- if (this.taskNodes.length <= 0) return;
- for (var i = 0; i < this.taskNodes.length; i++) {
- if (this.taskNodes[i].name == name) {
- this.taskNodes[i].active = b;
- }
- }
- },
- // 公用 提示框
- tipsNode: function (num, x, y, callback) {
- var _x = 0;
- var _y = 0;
- if (x != null) {
- _x = x;
- }
- if (y != null) {
- _y = y;
- }
- task.removeTaskNode(task.taskCursorName[0]);
- task.addTaskTips(this.Canvas, task.newTaskName[num], _x, _y, task.taskCursorName[0], function (nodePrefabs) {
- // console.log("是什么呢",nodePrefabs);
- //黑底
- // this.nodePrefabsbg = nodePrefabs;
- UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[0]);
- if (callback != null) {
- callback(nodePrefabs);
- }
- }.bind(this))
- }.bind(this));
- },
- // 万元户 50W
- task50W: function () {
- //50W 万元户任务
- if (task.TaskIconCountClick == 6) {
- if (this.task50wtag == null) {
- if (GlobalD.GameData.Golden >= 3000) {
- this.task50wtag = true;
- let Index = 9
- var BuildingStateArray = GlobalD.GameData.GetBuildingStateArray();
- BuildingStateArray[Index] = 1;
- let Building = this.managerUi.getComponent('ManageBuildings').BuildingArray[Index];
- Building.active = true;
- GlobalD.GameData.SetBuildingStateArray(BuildingStateArray);
- this.startSharePrefab(function (node) {
- }.bind(this));
- }
- }
- }
- },
- //弹出分享对话框
- startSharePrefab: function (callbackNode) {
- this.taskTags = false;
- UtilsPrefabs.startSharePrefab(function () {
- this.addTaskIconCountClick();
- }.bind(this), function () {
- this.addTaskIconCountClick();
- }.bind(this), function (node) {
- var anim = node.getComponent(cc.Animation);
- anim.play();
- var arr2 = [
- "SharePic",
- "Recruit",
- "Ribbon-cutting",
- ];
- //招聘
- if (this.TaskIconCountClick == 1) {
- node.getChildByName("SharePicBG").getChildByName(arr2[1]).zIndex = 10000;
- node.getChildByName("LittleTitleLabel").getComponent(cc.Label).string = "恭喜你又获得一名新员工!快邀请好友来帮忙审核!";
- node.getChildByName("gosharebtn").getChildByName("Btn_Share_Recruit").zIndex = 10000;
- }
- //获得房屋
- //恭喜获得幸运奖励!离首富又近了一步!
- else if (this.TaskIconCountClick == 2) {
- node.getChildByName("SharePicBG").getChildByName(arr2[0]).zIndex = 10000;
- node.getChildByName("LittleTitleLabel").getComponent(cc.Label).string = "乔迁之喜!让朋友来参观一下吧!";
- node.getChildByName("gosharebtn").getChildByName("Btn_Share_Other").zIndex = 10000;
- }
- //商店开业
- else if (this.TaskIconCountClick == 8) {
- node.getChildByName("SharePicBG").getChildByName(arr2[2]).zIndex = 10000;
- node.getChildByName("LittleTitleLabel").getComponent(cc.Label).string = "新店开张!快邀请好友一起来剪彩吧!";
- node.getChildByName("gosharebtn").getChildByName("Btn_Share_Cutting").zIndex = 10000;
- }
- }.bind(this));
- },
- taskShowBuildingView: function () {
- if (task.TaskIconCountClick == 7) {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- if (this.nodeHand != null) {
- task.removeNode(this.nodeHand)
- }
- task.addTaskTips(BuildingView, task.taskPrefab[1], -100, 350, task.taskCursorName[2], function (nodePrefabs) {
- //手指
- this.nodeHand = nodePrefabs;
- }.bind(this));
- }
- },
- //商铺 提示
- taskshops: function () {
- if (task.TaskIconCountClick == 8) {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- if (this.nodeHandshops != null) {
- task.removeNode(this.nodeHandshops)
- }
- task.addTaskTips(BuildingView, task.taskPrefab[1], 0, 330, task.taskCursorName[2], function (nodePrefabs) {
- //手指
- this.nodeHandshops = nodePrefabs;
- }.bind(this));
- }
- },
- //特殊 提示
- taskspecial: function () {
- if (task.TaskIconCountClick == 9) {
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView");
- if (this.nodeHandspecial != null) {
- task.removeNode(this.nodeHandspecial)
- task.removeNode(this.nodeHandspecial)
- }
- task.addTaskTips(BuildingView, task.taskPrefab[1], 100, 330, task.taskCursorName[2], function (nodePrefabs) {
- //手指
- this.nodeHandspecial = nodePrefabs;
- }.bind(this));
- }
- },
- taskGreenBeltShare: function () {
- //任务
- if (task.TaskIconCountClick == 9) {
- task.removeTaskNode(task.taskCursorName[4]);
- task.removeTaskNodes();
- //开始分享
- this.startSharePrefab();
- }
- },
- taskShare: function () {
- console.log('task.taskCursor = ', task.taskCursor);
- // console.log("走着了吗");
- if (task.taskCursor == 0) {
- task.clearNodeHandnodePrefabsnoviceend();
- task.addTaskCount();
- }
- //任务
- if (task.taskCursor == 1) {
- // cc.log("建筑物创建");
- task.removeTaskNode(task.taskCursorName[4]);
- task.removeTaskNodes();
- //新手引导第一部分,创建完房子之后
- //slam todo
- //直接设置增加农田
- task._setTaskCount(3);
- task.addSeneceTaskIcon();
- task._setTaskIconCountClick(0);
- task.taskCallBack();
- }
- },
- //旅行者 第一次 买农田
- buyFarming: function (callback) {
- dialogmanager.init(this.Canvas, function () {
- dialogmanager.buyFarming();
- //任务结束
- task.onSetTaskEnd();
- }.bind(this), function () {
- //任务结束
- task.onSetTaskEnd();
- }.bind(this), function () {
- //结束按钮
- if (callback != null) {
- callback();
- }
- }.bind(this));
- dialogmanager.setOnCloseDialog(function () {
- //对话结束回调
- if (callback != null) {
- callback();
- }
- }.bind(this));
- },
- //放置农田(现在为果树)之后
- Farming: function () {
- if (task.taskCursor == -1) return;
- // 种田之后
- task.showManagerhide();
- setTimeout(() => {
- //设置视频任务帮助
- this._setTaskIconCountClick(10);
- task.taskCallBack();
- }, 300);
- },
- //建造建工厂
- taskfactory: function () {
- if (task.TaskIconCountClick == 7) {
- // console.log("农田创建完毕");
- task.showManagerhide();
- // GlobalD.GameData.PlusGolden(task.publicGive[0]);
- this.startSharePrefab();
- }
- },
- clearNodeHandLabour: function () {
- if (this.nodeHandLabour != null) {
- task.removeNode(this.nodeHandLabour)
- }
- },
- clearNodeHandnodePrefabsnoviceend: function () {
- if (this.nodePrefabsnoviceend != null) {
- task.removeNode(this.nodePrefabsnoviceend)
- }
- },
- clearNodeHandshopsshow: function () {
- if (this.nodeHandshopsshow != null) {
- task.removeNode(this.nodeHandshopsshow)
- }
- },
- clearNodeHandGreenBelt: function () {
- if (this.nodeHandGreenBelt != null) {
- task.removeNode(this.nodeHandGreenBelt)
- }
- },
- taskZS: function () {
- if (task.TaskIconCountClick == 3 && !this.taskZSTag) {
- this.taskZSTag = true;
- task.showManagerhide();
- this.startSharePrefab();
- }
- },
- //盖完了 农舍之后
- taskFarmhouse: function () {
- if (task.TaskIconCountClick == 2) {
- // //开始分享
- this.startSharePrefab();
- }
- },
- //便利店 提示
- taskConvenienceStore: function () {
- if (task.TaskIconCountClick == 8) {
- // console.log("农田创建完毕");
- task.showManagerhide();
- this.startSharePrefab();
- }
- },
- //视频教程
- videoTutorial: function () {
- var Canvas = cc.find("Canvas/UICamera");
- task.addTaskTips(Canvas, task.newTaskName[18], 0, 0, task.taskCursorName[3], function (node) {
- UtilsWX.getSystemInfo(function (obj) {
- this.width = 0 - obj.windowWidth + 100;
- this.height = obj.windowHeight - 150;
- node.getChildByName("SureBtn").y = node.getChildByName("SureBtn").y + this.height;
- node.getChildByName("SureBtn").x = this.width;
- console.log("关闭按钮", node.getChildByName("SureBtn"));
- UtilsWX.createVideo();
- }.bind(this));
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- task.removeTaskNode(task.taskCursorName[3]);
- UtilsWX.removeVideo();
- }.bind(this))
- }.bind(this));
- },
- showvideoTutorial: function () {
- var node = cc.find("Canvas/UICamera/taskPrefab13");
- node.x = 0;
- node.y = 0;
- UtilsWX.createVideo();
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- UtilsWX.removeVideo();
- // node.active = false;
- node.x = -2000;
- node.y = 0;
- }.bind(this))
- },
- //视频教程
- videoTutorialCreatorBtn: function () {
- task.addTaskTipsNoArr(this.BelowTheMask, "prefab/videoTutorialCreatorBtn", -300, -360, "videoTutorialCreatorBtn", function (node) {
- node.parent = this.BelowTheMask;
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- task.showvideoTutorial();
- }.bind(this))
- }.bind(this));
- },
- //创建 帮助
- CreatorBtnHelp: function (BelowTheMask) {
- task.addTaskTipsNoArr(this.BelowTheMask, "prefab/videoTutorialCreatorBtn", -300, 280, "videoTutorialCreatorBtn", function (node) {
- node.parent = this.BelowTheMask;//this.BelowTheMask;
- // node.active = false;
- this.BtnHelp = node;
- UtilsPrefabs.setOn(node.getChildByName("SureBtn"), function () {
- task.openHelp();
- }.bind(this))
- }.bind(this));
- },
- openHelp: function () {
- // console.log("打开帮助");
- task.addTaskTipsNoArr(this.Canvas, "prefab/help/taskPrefabViewhelp", 0, 0, "videoTutorialCreatorBtn", function (node) {
- node.parent = this.Canvas;
- // console.log("打开帮助node",node);
- UtilsPrefabs.setOn(node.getChildByName("layout").getChildByName("close"), function () {
- task.removeNode(node);
- }.bind(this))
- }.bind(this));
- },
- //初始化模板遮罩
- onInitTaskMask(_taskNodes, _taskName) {
- cc.loader.loadRes("prefab/task/Scene/TaskMask", function (err, texture) {
- let _taskMask = cc.instantiate(texture);
- //设置生成遮罩的节点
- _taskMask.parent = cc.find('Canvas/UICamera');
- //设置遮罩的适配目标
- let _widget = _taskMask.getChildByName('Mask').getChildByName('Bg').getComponent(cc.Widget);
- _widget.target = cc.find('Canvas');
- let taskMaskScript = _taskMask.getComponent('TaskMask');
- // console.log('_offset =', _offset, _Count, '=taskMaskScript.offsetCount', taskMaskScript.offsetCount);
- taskMaskScript.onInitTaskMask(_taskNodes, _taskName);
- }.bind(this));
- },
- };
|