| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884 |
- import GameM, { VIDEO_TYPE, AUDIO_TYPE, Game_Quality } from "./manager/GameM";
- import CarSpace from "./prefabs/CarSpace";
- import CarMove from "./prefabs/CarMove";
- import CarInfo from "./prefabs/CarInfo";
- import UiM, { PANEL_NAME } from "./manager/UiM";
- import GlobalStorage, { STORAGE_KEY } from "./datas/GlobalStorage";
- import Shop from "./ui/Shop";
- import Gift from "./ui/Gift";
- import RedPointM, { RedPointType } from "./manager/RedPointM";
- import Task from "./ui/Task";
- import AdM from "./manager/AdM";
- import PoolMgr, { NODEPOOLPREFABTYPE } from "./manager/PoolMgr";
- import EffectNode from "./ui/EffectNode";
- import Sciencen_M from "./utils/Sciencen_M";
- import BuyProAdd from "./prefabs/BuyProAdd";
- import Daily from "./ui/Daily";
- import DailyCashProAdd from "./prefabs/DailyCashProAdd";
- import GuideManager from "./manager/GuideManager";
- import LogUtil from "./utils/LogUtil";
- import BankQipaoTip from "./ui/BankQipaoTip";
- import LocalManagerData from "./datas/LocalManagerData";
- import Spray from "./prefabs/Spray";
- import EachNodeAnim from "./ui/EachNodeAnim";
- import TreasureData from "./datas/TreasureData";
- import TurntableData from "./datas/TurntableData";
- import CashOutData from "./datas/CashOutData";
- import UIMng, { PanelType } from "./uiFrames/UIMng";
- import { Role } from "./other/item/Role";
- import { FightData } from "./datas/FightData";
- import { MateData } from "./datas/MateData";
- import MoreGameData from "./datas/MoreGameData";
- import { Utils } from "./utils/Utils";
- import { HTTP_TYPE, MONEY_TYPE, RecordTYPE } from "./datas/CommonData";
- import UsualCaidanData from "./datas/UsualCaidanData";
- import GuideMng from "./manager/GuideMng";
- import DailyCashData from "./datas/DailyCashData";
- import { GameController } from "./manager/GameController";
- import { thirdVideoTS } from "./manager/topon/AnyThinkAdsMgr/thirdVideoTS";
- import UsualCaidanNode from "./ui/UsualCaidanNode";
- import NativeAdAwardData from "./manager/NativeAdAwardData";
- import MyExtends from "./tools/MyExtends";
- import ClubData from "./datas/ClubData";
- import DailyData from "./datas/DailyData";
- import HttpM from "./manager/HttpM";
- import InvestData from "./datas/InvestData";
- import WealthMng from "./manager/WealthMng";
- import { WealthData } from "./datas/WealthData";
- import Random from "./utils/Random";
- import { RichData } from "./datas/RichData";
- import DownloadApkData from "./datas/DownloadApkData";
- import SwitchM from "./manager/SwitchM";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Main extends cc.Component {
- @property(cc.Node)
- topPart: cc.Node = null
- @property(cc.Node)
- centerPart: cc.Node = null
- @property(cc.Sprite)
- head: cc.Sprite = null
- @property(cc.Label)
- labGold: cc.Label = null
- @property(cc.Label)
- labGoldSecond: cc.Label = null
- @property(cc.Node)
- CarPark: cc.Node = null
- @property(cc.Node)
- btnBuy: cc.Node = null
- @property(cc.Node)
- posBtnBuy: cc.Node = null
- @property(cc.Label)
- labLevel: cc.Label = null
- @property(cc.Label)
- labMoney: cc.Label = null
- @property(cc.Sprite)
- expFill: cc.Sprite = null
- @property(sp.Skeleton)
- composeAni: sp.Skeleton = null
- @property(cc.Animation)
- cicleFade: cc.Animation = null
- @property(cc.Node)
- hand: cc.Node = null
- @property(cc.Node)
- buyHand: cc.Node = null
- @property(cc.Animation)
- airshipAni: cc.Animation = null
- @property(cc.Animation)
- airshipHandAni: cc.Animation = null
- @property(cc.Button)
- chatBtn: cc.Button = null;
- @property(cc.Button)
- cashBtn: cc.Button = null;
- @property(cc.Node)
- redeemBtn: cc.Node = null;
- //看视频领红包
- @property(cc.Node)
- adRbBtn: cc.Node = null;
- //模块按钮
- @property(cc.Button)
- shopBtn: cc.Button = null;
- @property(cc.Button)
- taskBtn: cc.Button = null;
- @property(cc.Button)
- turntableBtn: cc.Button = null;
- @property(cc.Button)
- investBtn: cc.Button = null;
- @property(cc.Button)
- dailyCashBtn: cc.Button = null;
- @property(cc.Button)
- dailyBtn: cc.Button = null;
- @property(cc.Button)
- tixianProBtn: cc.Button = null;
- @property(cc.Node)
- wealthBtn: cc.Node = null;
- @property(cc.Node)
- richmanBtn: cc.Node = null;
- @property(cc.Button)
- treasureBtn: cc.Button = null;
- @property(cc.Button)
- bankBtn: cc.Button = null;
- @property(cc.Button)
- moreGameBtn: cc.Button = null;
- @property(cc.Button)
- shareBtn: cc.Button = null;
- //彩蛋按钮
- @property(cc.Button)
- caidanBtn: cc.Button = null;
- @property(cc.Button)
- guideInstallBtn: cc.Button = null;
- @property(cc.Node)
- caidanHand: cc.Node = null;
- @property(cc.Node)
- cashHand: cc.Node = null
- @property(cc.Node)
- tipPos: cc.Node = null
- @property(cc.Node)
- canGet: cc.Node = null
- @property(cc.Sprite)
- tixianPro: cc.Sprite = null
- @property(cc.Label)
- labTixian: cc.Label = null
- @property(cc.Label)
- labTixianLv: cc.Label = null
- @property(cc.Label)
- labtargetCarLevel: cc.Label = null;
- @property(cc.Sprite)
- spTixianCar: cc.Sprite = null
- @property(cc.Sprite)
- carProSp: cc.Sprite = null;
- @property(cc.Node)
- approachEff: cc.Node = null
- @property(cc.Animation)
- hallLabAddEff: cc.Animation = null;
- @property(cc.Sprite)
- tixianFill: cc.Sprite = null;
- @property(cc.Label)
- tixianPercent: cc.Label = null
- @property(cc.Node)
- bankQipaoNode: cc.Node = null;
- @property(cc.Label)
- labTixianPro: cc.Label = null;
- @property(cc.Node)
- labWuFuNode: cc.Node = null;
- @property(BankQipaoTip)
- BankQipaoTip: BankQipaoTip = null;
- //常规彩蛋
- @property(cc.Sprite)
- spCaidan: cc.Sprite = null;
- @property(cc.Node)
- newdan1: cc.Node = null;
- @property(cc.Label)
- labCaidanCount: cc.Label = null;
- @property(cc.Prefab)
- private pfb_Guide: cc.Prefab = null;
- //西游
- @property(cc.Node)
- private xiYou_mates: cc.Node[] = [];
- //@property(sp.Skeleton)
- //private xiYou_spineSun: sp.Skeleton = null;
- //@property(sp.Skeleton)
- //private xiYou_spineBa: sp.Skeleton = null;
- @property(cc.Node)
- private xiYou_bgback: cc.Node = null;
- @property(cc.Sprite)
- private xiYou_bg: cc.Sprite = null;
- @property(cc.Node)
- private xiYou_bg_bottom: cc.Node = null;
- @property(cc.Node)
- private xiYou_talentParent: cc.Node = null;
- @property(cc.Prefab)
- private xiYouPfb_telentItem: cc.Prefab = null;
- @property(cc.Label)
- private txt_buyBtn: cc.Label = null;
- @property(cc.Node)
- private xiyou_guide_click: cc.Node = null;
- @property(cc.Node)
- private xiyou_guide_drag: cc.Node = null;
- private txt_wealthCoolTimer: cc.Label = null;
- @property(cc.Sprite)
- private spMoregame: cc.Sprite = null
- @property(cc.Label)
- private labMoregame: cc.Label = null
- private richBtnQipao: cc.Node = null;
- private richQipaoTxt: cc.Label = null;
- curCashCfg = null
- facLock: cc.Node = null
- carP: cc.Node
- carSpaceP: cc.Node
- index_s: number = 0
- carSpaceArr = []
- //offPos: cc.Vec2 = cc.v2(375, 627)
- offPos: cc.Vec2 = cc.v2(375, 667) //根据不同设备适配
- P1: cc.Node = null
- P2: cc.Node = null
- hasHand = false
- handTween = null
- /** 舞台宽高 */
- sW: number = 0
- sH: number = 0
- /** 当前买车类型 */
- curBuyType: number = 0
- //帧频采样数组
- startGetFrameTime = false
- frameTotal = 0
- frameTimeTotal = 0
- frameAdd = 0
- testFrames = 60
- averageTime = 0
- /** 放弃飞艇飞走中 */
- airshipUp = false
- /** 每日提现当前配置 */
- dailyCash = null
- //西游
- /**车位尺寸*/
- //carParkSize:cc.Vec2=cc.v2(138,138);
- //carParkSize: cc.Vec2 = cc.v2(100, 100);
- carParkSize: cc.Vec2 = cc.v2(141, 141);
- /**移动或合成最终y轴偏移量 标准分辨率为-303*/
- moveEndY: number = -303;
- /**CarPark下边离屏幕下边距离*/
- parkBottom: number = 152.50;// 189;// 162;
- //parkBottom: number = 230;
- /**park layout spacing x*/
- parkSpaceX: number = 8;//25;
- /**park layout spacing y*/
- parkSpaceY: number = 25;//70;// 40;
- /**点击时间戳 在此时间内的点击算单击车位 否为算拖拽*/
- dragTime: number = 0.2;
- /**点击计时器*/
- dragTimer: number = 0;
- onLoad() {
- //AdM.onSendEvent('loadEnd', '加载结束', 'load');
- cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
- }
- async start() {
- if (!GameM.commonData.redSwitch) {
- cc.find('Canvas/HallNode/topPart/btnFight').active = false
- cc.find('Canvas/HallNode/centorPart/btnTask').active = false
- cc.find('Canvas/HallNode/downPart/btnInvestment').active = false
- cc.find('Canvas/HallNode/downPart/btnMate').active = false
- }
- this.composeRectNode = cc.find("Canvas/HallNode/ComposeRect");
- this.txt_wealthCoolTimer = this.wealthBtn.getChildByName('normal').getChildByName('txtcooling').getComponent(cc.Label);
- this.richBtnQipao = this.richmanBtn.getChildByName('normal').getChildByName('qipao');
- this.richQipaoTxt = this.richBtnQipao.getComponentInChildren(cc.Label);
- //this.txt_wealthCoolTimer=this.wealthBtn.getChildByName('normal').getChildByName('labLock').getComponent(cc.Label);
- cc.game.addPersistRootNode(this.node)
- GameM.commonData.updateGold('0')
- TurntableData.Instance.updateResetTurntable()
- //各模块是否解锁
- this.checkModelBtnsUnlock();
- this.addParkCar()
- this.carBuyInfo()
- this.updateBuyBtnState();
- this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
- this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) //西游
- this.sW = cc.winSize.width
- this.sH = cc.winSize.height
- this.offPos = cc.v2(375, this.sH / 2);
- //西游
- let temppy = this.parkBottom + this.CarPark.height / 2;
- this.moveEndY = -((temppy <= this.sH / 2 ? this.sH / 2 - temppy : temppy - this.sH / 2) + 86.9);
- //this.moveEndY = -(86.9 + Math.abs(this.CarPark.y));
- //console.log("----->" + this.moveEndY + " temppy:" + temppy + "PY:" + (temppy <= this.sH ? this.sH - temppy : temppy - this.sH));
- if (this.sH > 1500) {
- this.topPart.y += 90
- }
- this.delayAddGift()
- this.startAddTimer()
- this.schedule(this.storeGameTime, 10)
- this.storeGameTime()
- GameM.commonData.updateRoleDataExp('0')
- // let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2))
- // if (percent >= 1) {
- // let videoSpan = 15
- // this.schedule(this.checkPopVideo, videoSpan)
- // }
- UiM.Instance.taskNode.getComponent(Task).init()
- this.setGuideInstallVisible(false)
- this.setImg()
- if (GameM.commonData.redSwitch) {
- this.labMoney.string = `${Math.floor(GameM.commonData.redMoney)} ≈ ${(GameM.commonData.redMoney * 0.0001).toFixed(3)}元`
- }
- else {
- this.labMoney.string = `${GameM.commonData.redMoney}`
- }
- this.checkShowAirship()
- GameM.httpM.sendDatas(HTTP_TYPE.getRedMoneyRecord, null, GameM.commonData.resultRedMoneyRecord.bind(GameM.commonData))
- GameM.audioM.init()
- this.checkNewUser()
- this.scheduleOnce(() => {
- this.checkOfflineAward()
- }, 0.5)
- this.chatBtn.node.active = GameM.commonData.redSwitch
- //西游
- //this.cashBtn.node.active = GameM.commonData.redSwitch
- this.dailyBtn.node.active = GameM.commonData.redSwitch
- this.dailyCashBtn.node.active = GameM.commonData.redSwitch
- this.bankBtn.node.active = GameM.commonData.redSwitch
- this.treasureBtn.node.active = GameM.commonData.redSwitch
- this.tixianProBtn.node.active = GameM.commonData.redSwitch
- this.shareBtn.node.active = false // GameM.commonData.redSwitch
- this.freshDailyRed()
- GameM.commonData.quality = Game_Quality.mediumHigh
- this.checkTixianPro(true)
- TreasureData.Instance.getLuckydrawConfig()
- let loadEnd = GameM.globalStorage.getStorage(STORAGE_KEY.firstLoadEnd)
- if (loadEnd == null) {
- loadEnd = 1
- GameM.globalStorage.setStorage(STORAGE_KEY.firstLoadEnd, loadEnd)
- AdM.onSendEvent('firstLoadEnd', '第一次加载结束')
- }
- AdM.onSendEvent('loadEnd', '加载结束进入主场景', 'load')
- if (SwitchM.firstLoginLog) {
- AdM.sendUmeng('umLoadEnd', '加载结束')
- }
- SwitchM.firstLoginLog = false
- //检查授权
- //注释掉 还原为一上线就授权
- // AdM.checkPermission()
- let can = GameM.commonData.checkCanShowSplash()
- if (can) {
- AdM.showSplash()
- }
- this.checkCanVideo()
- GameM.commonData.checkShowFull()
- if (GameM.commonData.maxCarLevel >= GameM.commonData.richBankUnLockLevel && GameM.commonData.isopenrichbank == 0) {
- GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank)
- GameM.commonData.isopenrichbank = 1
- }
- //UIMng.Ins.GetPanel(PanelType.TestPanel).OnEnter();
- // this.caidanBtn.node.active = false
- UsualCaidanData.Instance.getUsualEggData(false)
- // //test
- // this.caidanBtn.node.active = true
- this.freshDailyPro()
- //每日登录奖励红点
- DailyData.Instance.checkHasGet()
- MateData.Ins.checkMateRedPoint()
- //西游
- this.DisplayMate();
- MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem);
- MoreGameData.Instance.sendRecommendList();
- this.UpdateMainBg();
- //首次新手引导
- GuideMng.Ins.CheckGuide1();
- //西游测试
- this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal;
- //常规引导
- this.schedule(this.CheckNormalGuide, 5);
- if (GameM.commonData.IsTest) {
- this.scheduleOnce(() => {
- GameM.commonData.updateGold("999999999999999999999999");
- GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold });
- }, 3);
- }
- //请求工会数据 用于埋点
- ClubData.Instance.requestClubMyRecruitMembers()
- //初始化天降财神
- let wealth = cc.instantiate(await Utils.loadResPromise("prefabs/GameWealth"));
- wealth.parent = this.node.parent;
- wealth.setSiblingIndex(this.node.getSiblingIndex() + 1);
- //大富翁
- this.RichManInit();
- //this.UpdateRichManQipao();
- //礼包兑换
- this.CheckRedeem();
- //看视频领红包
- this.CheckAdRb();
- this.checkShowCashBtns();
- }
- freshDailyPro() {
- if (GameM.commonData.roleData.dailyCashAniPlayed == 1) {
- if (DailyCashData.Instance.userDailyCashInfo) {
- this.labTixianPro.node.active = true
- // this.dailyCash = DailyCashData.Instance.getTodayDailyCash()
- this.dailyCash = DailyCashData.Instance.userDailyCashInfo
- this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime
- this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
- this.labWuFuNode.active = false
- }
- else {
- DailyCashData.Instance.getDailyCashBuyTime()
- }
- }
- else {
- this.labTixianPro.node.active = false
- this.labWuFuNode.active = true
- }
- }
- /**更新金币*/
- UpdateCoinTxt(num: string) {
- this.labGold.string = num;
- cc.Tween.stopAllByTarget(this.labGold.node);
- cc.tween(this.labGold.node)
- .to(0.15, { scale: 1.2 })
- .to(0.15, { scale: 1 })
- .start();
- }
- /**获取引导物体*/
- GetGuide() {
- return cc.instantiate(this.pfb_Guide);
- }
- update(dt) {
- this.frameTotal++
- if (this.frameTotal == 600) {
- this.startGetFrameTime = true
- this.frameTimeTotal = 0
- this.frameAdd = 0
- }
- if (this.startGetFrameTime) {
- this.frameAdd++
- if (this.frameAdd <= this.testFrames) {
- this.frameTimeTotal += dt
- if (this.frameAdd == this.testFrames) {
- this.averageTime = this.frameTimeTotal / this.testFrames
- this.frameTotal = 0
- this.startGetFrameTime = false
- if (this.averageTime > 0.0222222) {
- if (GameM.commonData.quality > Game_Quality.low) {
- GameM.commonData.quality--
- }
- }
- else {
- if (GameM.commonData.quality < Game_Quality.high) {
- GameM.commonData.quality++
- }
- }
- }
- }
- }
- this.MoveBg(dt);
- this.TimerWealthCooling();
- }
- freshDailyRed() {
- RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, true)
- // let len = GameM.commonData.dailyCfg.length
- // let red = false
- // let data = null
- // for (var i = 0; i < len; i++) {
- // data = GameM.commonData.dailyCfg[i]
- // if (GameM.commonData.dailyGetArr[i] == '0') {
- // if (GameM.commonData.loginDays >= data.getDay) {
- // if (data.conditionType == 1) {
- // red = true
- // break
- // }
- // if (data.conditionType == 2) {
- // if (GameM.commonData.maxCarLevel >= data.conditionLv) {
- // red = true
- // break
- // }
- // }
- // else if (data.conditionType == 3) {
- // if (GameM.commonData.roleData.lv >= data.conditionLv) {
- // red = true
- // break
- // }
- // }
- // }
- // }
- // }
- // RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, red)
- }
- /** 显示提现引导 */
- showCashHand() {
- this.cashHand.active = true
- }
- hideCashHand() {
- this.cashHand.active = false
- }
- /** 是否是新用户 */
- checkNewUser() {
- if (GameM.commonData.redSwitch) {
- if (GameM.commonData.roleData.newuser < 2) {
- if (GameM.commonData.roleData.newuser == 0) {
- this.scheduleOnce(() => {
- //先创建全屏的秘书引导,再进行之前的引导
- GuideManager.Instance.createFullGuide(this.node, 1, () => {
- this.checkNewUser()
- })
- //GuideMng.Ins.CheckGuide1();
- }, 1)
- }
- else {
- this.scheduleOnce(() => {
- //先创建全屏的秘书引导,再进行之前的引导
- GuideManager.Instance.createFullGuide(this.node, 4, () => {
- if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) {
- this.buyHand.active = false
- // UiM.Instance.guideNode.getComponent(Guide).showStep()
- }
- })
- }, 0.1)
- }
- }
- else {
- this.scheduleOnce(() => {
- if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) {
- this.buyHand.active = false
- // UiM.Instance.guideNode.getComponent(Guide).showStep()
- }
- }, 0.1)
- }
- }
- }
- /** 第二天登录,满足条件弹出 */
- checkPopSecretary() {
- this.scheduleOnce(() => {
- if (GameM.commonData.loginDays >= 2) {
- if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 0) {
- UiM.Instance.redPackageNode.init(0, 0, 4, null, true)
- UiM.Instance.redPackageNode.node.x = 0
- UiM.Instance.redPackageNode.node.active = true
- //西游
- if (!RichData.Ins.isOpenRichPanel) {
- GameM.audioM.setPauseMusic();
- GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm);
- }
- }
- else {
- this.checkShowClubGuideNode()
- // if (GameM.commonData.roleData.ifGuideSecrtary) {
- // GameM.commonData.checkDaysPieceUnlock()
- // }
- }
- } else {
- }
- }, 2)
- }
- //弹出俱乐部海报
- checkShowClubGuideNode() {
- //吐槽 不弹出 裂变海报
- return;
- let showClubGirl = GameM.globalStorage.getStorage(STORAGE_KEY.showClubGirl)
- if (showClubGirl > 0) {
- GameM.globalStorage.setStorage(STORAGE_KEY.showClubGirl, 0)
- UiM.Instance.onPanel(PANEL_NAME.clubGuideNode)
- }
- }
- showDialyPanel(force = false) {
- if (GameM.commonData.redSwitch) {
- if (force) {
- //console.log("-------------------1")
- UiM.Instance.onPanel(PANEL_NAME.DailyNode)
- }
- else {
- if (!UiM.Instance.dailyNode && GameM.commonData.maxCarLevel >= 10) {
- //console.log("-------------------2")
- UiM.Instance.onPanel(PANEL_NAME.DailyNode)
- }
- }
- }
- }
- setImg() {
- let self = this
- if (GameM.commonData.headimgurl != '') {
- cc.loader.load(GameM.commonData.headimgurl + "?aaa=aa.jpg", (err, res) => {
- if (err) {
- console.log('err:', err);
- return;
- }
- if (self.head) {
- let tex: cc.Texture2D = res as cc.Texture2D;
- self.head.spriteFrame = new cc.SpriteFrame(tex);
- }
- })
- }
- this.checkShowGuideInstall()
- }
- /**检查各模块是否解锁*/
- checkModelBtnsUnlock() {
- if (GameM.commonData.maxCarLvCanBuy >= GameM.commonData.curVideoCarType) {
- RedPointM.instance.ActiveRedPoint(RedPointType.Shop, true)
- }
- else {
- RedPointM.instance.ActiveRedPoint(RedPointType.Shop, false)
- }
- this.checkTaskRed()
- this.checkTurntableRed()
- let isUnlockInvest = GameM.commonData.maxCarLevel >= GameM.commonData.investOpenLevel ? true : false
- if (isUnlockInvest) {
- InvestData.Instance.getInvestInfo()
- }
- RedPointM.instance.UpdateRedPointState();
- //提现
- //this.unLockBtn(this.tixianProBtn, GameM.commonData.cashOpenLevel)
- //每日提现
- this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel)
- //投资引导
- //this.checkMateLockBtn(3, GameM.commonData.investOpenLevel)
- this.unLockBtn(this.investBtn, GameM.commonData.investOpenLevel)
- //转盘
- this.unLockBtn(this.turntableBtn, GameM.commonData.turntableOpenLevel)
- //小秘书
- // this.unLockBtn(this.secretaryBtn, 9)
- //登录豪礼
- this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel)
- //现金夺宝
- this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel)
- // //银行富翁 改为判断4号伙伴
- // this.checkMateLockBtn(4, GameM.commonData.richBankUnLockLevel)
- //银行富翁
- this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel)
- //每日任务
- this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel)
- //财神降临
- this.unLockBtn(this.wealthBtn.getComponent(cc.Button), GameM.commonData.unlockWealthLevel)
- }
- /** 检查任务红点 */
- checkTaskRed() {
- if (GameM.commonData.dailyTaskRedNum > 0) {
- RedPointM.instance.ActiveRedPoint(RedPointType.Task, true)
- }
- else {
- RedPointM.instance.ActiveRedPoint(RedPointType.Task, false)
- }
- if (UiM.Instance.taskNode) {
- UiM.Instance.taskNode.getComponent(Task).freshRed()
- }
- }
- /** 是否显示飞艇 */
- checkShowAirship() {
- if (GameM.commonData.step > 3) {
- this.airshipAni.node.active = false
- if (this.airshipHandAni.node.active) {
- this.airshipHandAni.node.active = false;
- }
- if (GameM.commonData.airshipTimes < 10) {
- let delayTime = 90
- this.scheduleOnce(this.showAirship, delayTime)
- NativeAdAwardData.Instance.resetGetAward(2)
- // this.schedule(this.getAirByRan, 90)
- }
- }
- }
- curAirCfg = null
- getAirByRan() {
- LogUtil.logV("getAirByRan", "start")
- if (GameM.commonData.airshipTimes < 10) {
- let tempCfg = GameM.commonData.airshipCfg
- let airCfg = new Array<any>()
- let range = 0
- for (let entry of tempCfg) {
- if (entry.limit != null && entry.limit != undefined) {
- let reward = new Number(entry.reward).valueOf()
- let nowTimes = 0
- let canAdd = true
- switch (reward) {
- case MONEY_TYPE.speedCard:
- nowTimes = GameM.commonData.roleData.airshipSpeedCard
- if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) {
- canAdd = false
- }
- break;
- case MONEY_TYPE.turnTableCard:
- nowTimes = GameM.commonData.roleData.airshipTurntableCard
- break;
- case MONEY_TYPE.treasureCard:
- nowTimes = GameM.commonData.roleData.airshipTicket
- if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) {
- canAdd = false
- }
- break;
- }
- if (nowTimes < entry.limit && canAdd) {
- airCfg.push(entry)
- range += entry.chance
- }
- } else {
- airCfg.push(entry)
- range += entry.chance
- }
- }
- // LogUtil.logV("getAirByRan airCfg", airCfg)
- let ran = Math.floor(Math.random() * range)
- let add = 0
- for (var i = 0; i < airCfg.length; i++) {
- add += airCfg[i].chance
- if (ran <= add) {
- if (this.curAirCfg == airCfg[i]) {
- this.getAirByRan()
- }
- else {
- this.curAirCfg = airCfg[i]
- }
- break
- }
- }
- }
- else {
- this.unschedule(this.getAirByRan)
- }
- // LogUtil.logV("getAirByRan curAirCfg", this.curAirCfg)
- }
- showAirship() {
- this.getAirByRan()
- this.airshipAni.node.active = true
- this.airshipAni.setCurrentTime(0, 'airship')
- this.airshipAni.play()
- NativeAdAwardData.Instance.setGetAward(2)
- }
- /** 离线奖励 */
- checkOfflineAward() {
- if (GameM.commonData.offlineTime >= 60) {
- let awardTime = GameM.commonData.offlineTime <= GameM.commonData.offlineTimeMax ? GameM.commonData.offlineTime : GameM.commonData.offlineTimeMax
- let goldNum = Sciencen_M.instance.accMul(GameM.commonData.goldSecond.toString(), String(awardTime * 1))
- //白龙马天赋2
- goldNum = Sciencen_M.instance.addition(goldNum, Sciencen_M.instance.accMul(goldNum, (MateData.Ins.Mate3Talent2 * 0.01).toString()))
- if (goldNum != '0') {
- UiM.Instance.checkDelayShow(() => {
- UiM.Instance.giftNode.active = true
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- gift.init(MONEY_TYPE.offlineGold, goldNum)
- GameM.commonData.offlineTime = 0
- })
- }
- }
- else {
- if (DailyData.Instance.checkHasGet() && GameM.commonData.maxCarLevel >= GameM.commonData.loginRewardOpenLevel) {
- UiM.Instance.onPanel(PANEL_NAME.DailyNode)
- } else {
- this.checkPopSecretary()
- }
- }
- }
- /** 开始游戏检查是否可以看视频
- * @param start true 开始游戏检查 false 点击视频检查
- */
- checkCanVideo(start = true) {
- if (start) {
- if (GameM.commonData.videoCoolDown > 0) {
- this.schedule(this.onVideoTimeSchedule, 1)
- }
- }
- else {
- let can = false
- if (GameM.commonData.videoCoolDown <= 0) {
- can = true
- }
- else {
- can = false
- EffectNode.instance.PlayTip(`当前看视频太频繁了,请${GameM.commonData.videoCoolDown}秒后再试`)
- }
- return can
- }
- }
- /** 开始看视频冷却倒计时 */
- startVideoCoolDown() {
- GameM.commonData.videoCoolDown = GameM.commonData.videoCoolTime
- console.log('startVideoCoolDown ', GameM.commonData.videoCoolDown)
- GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown)
- this.schedule(this.onVideoTimeSchedule, 1)
- }
- onVideoTimeSchedule() {
- GameM.commonData.videoCoolDown--
- console.log('onVideoTimeSchedule ', GameM.commonData.videoCoolDown)
- if (GameM.commonData.videoCoolDown % 10 == 0) {
- GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown)
- }
- if (GameM.commonData.videoCoolDown <= 0) {
- this.unschedule(this.onVideoTimeSchedule)
- }
- }
- checkTurntableRed() {
- if (TurntableData.Instance.turntableTimes > 0) {
- RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, true)
- }
- else {
- RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, false)
- }
- }
- /** 探索红点 */
- setInvestRed(state) {
- // this.schedule(this.freshInvestTime, 1)
- RedPointM.instance.ActiveRedPoint(RedPointType.Invest, state)
- }
- // /** 刷新投资倒计时 */
- // freshInvestTime() {
- // InvestData.Instance.updateInvestDataTime()
- // }
- private firstIn = true
- /** 存储游戏时间戳,用来计算离线时间 */
- storeGameTime() {
- if (this.firstIn) {
- this.firstIn = false
- if (!GameM.commonData.useLocalData) {
- GameM.commonData.gameTime = GameM.commonData.currentTime
- }
- this.schedule(this.onGameTimeAdd, 1)
- }
- else {
- GameM.commonData.gameAdd += 10
- GameM.globalStorage.setStorage(STORAGE_KEY.gameAdd, GameM.commonData.gameAdd)
- }
- if (GameM.commonData.useLocalData) {
- GameM.commonData.gameTime = new Date().getTime()
- GameM.globalStorage.setStorage(STORAGE_KEY.gameTime, GameM.commonData.gameTime)
- }
- else {
- GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
- }
- TurntableData.Instance.updateResetTurntable()
- if (GameM.commonData.popIdentifySwitch) {
- GameM.commonData.todayPlayTime += 10
- GameM.globalStorage.setStorage(STORAGE_KEY.todayPlayTime, GameM.commonData.todayPlayTime)
- if (UiM.Instance.AntiAddictionNode == null) {
- if (GameM.commonData.identification == 2) {
- if (GameM.commonData.todayPlayTime >= 5400) {
- UiM.Instance.onPanel(PANEL_NAME.AntiAddictionNode)
- }
- }
- }
- }
- }
- onGameTimeAdd() {
- if (!GameM.commonData.useLocalData) {
- GameM.commonData.gameTime += 1 * 1000
- }
- }
- /** 自动拉取视频 */
- checkPopVideo() {
- if (GameM.commonData.maxCarLevel < 7) {
- return
- }
- if (!GameM.commonData.isWatchVideo) {
- if (!GameM.commonData.hasTouch) {
- let percent1 = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2))
- if (percent1 < 1) {
- this.unschedule(this.checkPopVideo)
- return
- }
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2))
- //弹出视频
- if (GameM.commonData.hasPopVideo) {
- GameM.commonData.hasTouch = true
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
- num = Sciencen_M.instance.accMul(num, percent.toString())
- percent = Math.floor(percent * 100)
- gift.init(MONEY_TYPE.gold, num, null, false, 0, null, percent)
- UiM.Instance.giftNode.active = true
- UiM.Instance.giftNode.x = 1000
- if (GameM.commonData.isVideoTest) {
- this.onHangUpAdEnd()
- }
- else {
- GameM.adM.watchVideo(VIDEO_TYPE.hangUp)
- }
- }
- else {
- GameM.commonData.hasPopVideo = true
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
- num = Sciencen_M.instance.accMul(num, percent.toString())
- percent = Math.floor(percent * 100)
- UiM.Instance.giftNode.x = 0
- gift.init(MONEY_TYPE.popVideo, num, null, false, 0, null, percent)
- UiM.Instance.giftNode.active = true
- // if (!UiM.Instance.guideNode.active) {
- // }
- }
- }
- else {
- GameM.commonData.hasTouch = false
- }
- }
- else {
- GameM.commonData.hasTouch = false
- }
- }
- onHandUpAdFail() {
- GameM.commonData.hasPopVideo = false
- UiM.Instance.giftNode.active = false
- UiM.Instance.giftNode.x = 0
- AdM.destroyNative()
- }
- onHangUpAdEnd() {
- EffectNode.instance.PlayTip('视频观看成功,额外奖励已发放')
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2))
- let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
- num = Sciencen_M.instance.accMul(num, percent.toString())
- GameM.commonData.updateGold(num)
- GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
- EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
- GameM.commonData.updateHangupVideoTimes()
- GameM.commonData.hasPopVideo = false
- }
- /**西游 增加一个角色*/
- addRunRole(type, carspace: CarSpace, startRan = false) {
- let role = new Role();
- role.Init(type, startRan, carspace);
- //GameM.commonData.roleArr.push(role)
- carspace.role = role;
- GameM.commonData.updateGoldSecond();
- }
- /**西游 删除一个角色*/
- removeRunRole(carspace: CarSpace) {
- if (carspace.role != null) {
- carspace.role.RemoveStrike();
- }
- carspace.role = null;
- carspace.RoleInit(false);
- GameM.commonData.updateGoldSecond();
- }
- /**西游 清除所有的罢工状态*/
- clearAllCoolTime() {
- for (let entry of this.carSpaceArr) {
- // if(entry){
- if (cc.isValid(entry)) {
- let carSprace: CarSpace = entry.getComponent(CarSpace)
- if (carSprace && carSprace.role) {
- carSprace.role.RemoveStrike()
- carSprace.RoleInit(false)
- }
- }
- }
- }
- async addParkCar() {
- let pre = await Utils.loadResPromise("prefabs/CarMove")
- GameM.selCarMove = cc.instantiate(pre)
- this.node.addChild(GameM.selCarMove)
- GameM.otherCarMove = cc.instantiate(pre)
- this.node.addChild(GameM.otherCarMove)
- let s;
- let data = null
- console.log("CarParkNum:" + this.CarPark.childrenCount);
- this.CarPark.children.forEach(space => {
- s = space.getComponent(CarSpace)
- s.index = this.index_s
- space.name = s.index.toString()
- //console.log("--->index:"+s.index);
- data = GameM.commonData.getBagCarDataByPos(s.index)
- s.type = data.type
- if (s.type == MONEY_TYPE.redMoney) {
- GameM.commonData.hasRedMoney++
- }
- if (s.type != 0 && s.type < 10000) {
- //西游
- if (GameM.commonData.isUseXiYouAddCoin) {
- this.addRunRole(s.type, s, true);
- //s.AddCoinSpawn(true);
- }
- }
- s.init(true, data.num)
- this.index_s++
- this.carSpaceArr.push(space)
- });
- LogUtil.logV('GameM.commonData.hasRedMoney ', GameM.commonData.hasRedMoney)
- }
- addAParkCar(pos, type) {
- GameM.commonData.updateBagCarData(pos, type)
- let space = this.CarPark.getChildByName(pos)
- let s = space.getComponent(CarSpace)
- s.type = type
- s.init(true)
- if (GameM.commonData.isUseXiYouAddCoin) {
- //西游
- this.addRunRole(type, s);
- //s.AddCoinSpawn();
- }
- }
- /**是否存在空车位*/
- IsHaveEmptySpace() {
- let len = GameM.commonData.bagCar.length
- for (var i = 0; i < len; i++) {
- if (GameM.commonData.bagCar[i].type == 0) {
- return true;
- }
- }
- return false;
- }
- /** 获取一个空位 */
- getEmptySpace() {
- let value = ''
- let len = GameM.commonData.bagCar.length
- //console.log("Length:" + len);
- // for (var i = 0; i < len; i++) {
- // if (GameM.commonData.bagCar[i].type == 0) {
- // value = GameM.commonData.bagCar[i].pos.toString()
- // break
- // }
- // }
- //西游
- for (var i = 0; i < len; i++) {
- if (GameM.commonData.bagCar[i].type == 0) {
- if (this.carSpaceArr[i].getComponent(CarSpace).isCanOperate) {
- value = GameM.commonData.bagCar[i].pos.toString()
- break
- }
- }
- }
- return value
- }
- private strikeNode: cc.Node = null;
- /**
- * 西游
- * 获取一个有车车位索引
- */
- GetRoleSpaceIndex() {
- let value = ''
- let len = GameM.commonData.bagCar.length
- for (var i = 0; i < len; i++) {
- if (GameM.commonData.bagCar[i].type != 0 && GameM.commonData.bagCar[i].type < 10000) {
- value = GameM.commonData.bagCar[i].pos.toString()
- this.strikeNode = this.CarPark.getChildByName(value);
- break
- }
- }
- return value;
- }
- /** 检测是否点到
- * @param point 点击的点
- * @param state 0 起始点 1 结束点
- */
- checkClickPos(point: cc.Vec2, state: number) {
- let result = false
- let addX = this.CarPark.width * 0.5
- let addY = this.CarPark.height * 0.5
- //let pointY = point.y - 130
- let pointY = point.y - this.offPos.y;
- //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY));
- //let pointY = point.y - 100
- if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) {
- console.log("false 1")
- return result
- }
- if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) {
- //console.log("false 2")
- return result
- }
- //航海
- //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) {
- // console.log("false 2")
- // return result
- //}
- if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) {
- if (point.x > this.offPos.x + addX - 200) {
- console.log("false 3")
- return result
- }
- //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
- //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
- //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
- //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
- if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游
- console.log("false 4")
- return result
- }
- }
- let localPosX = point.x - this.offPos.x
- //let localPosY = pointY - this.offPos.y //航海
- //let localPosY = pointY - this.CarPark.y - 80;
- let localPosY = pointY - this.CarPark.y;
- //let localPosY = pointY - this.CarPark.y - 26;
- //console.log("LocalY: " + localPosY);
- //let tx = 170 * 0.5
- //let ty = 120 * 0.5
- let tx = this.carParkSize.x * 0.5
- let ty = this.carParkSize.x * 0.5
- this.CarPark.children.forEach(element => {
- if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) {
- //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) {
- //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) {
- if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) {
- if (state == 0) {
- this.P1 = element
- let s = this.P1.getComponent(CarSpace)
- if (s.type != 0 && s.type < 10000) {
- s.hideImg()
- }
- GameM.selCarMove.getComponent(CarMove).onShow(s.index, s.type)
- if (s.type != 0) {
- result = true
- }
- }
- else if (state == 1) {
- this.P2 = element
- let s = this.P2.getComponent(CarSpace)
- if (this.P1 != null && s.type < 10000) {
- //西游
- if (this.coolTime && this.curGuideId != 11) {
- let s1 = this.P1.getComponent(CarSpace)
- if (s1.type != 0 && s1.type < 10000) {
- if (s.isCanOperate) {
- s.hideImg()
- GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY))
- GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type)
- result = true
- }
- }
- }
- //航海
- //let s1 = this.P1.getComponent(CarSpace)
- //if (s1.type != 0 && s1.type < 10000) {
- // s.hideImg()
- // GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY))
- // GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type)
- // result = true
- //}
- }
- }
- }
- }
- })
- return result
- }
- /** 检测是否点到非空非车位(角色 金币 礼包等)
- * @param point 点击的点
- */
- checkClickNoEmptyOther(point: cc.Vec2,) {
- let result = false
- let addX = this.CarPark.width * 0.5
- let addY = this.CarPark.height * 0.5
- //let pointY = point.y - 130
- let pointY = point.y - this.offPos.y;
- //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY));
- //let pointY = point.y - 100
- if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) {
- //console.log("false 1")
- return result
- }
- if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) {
- //console.log("false 2")
- return result
- }
- //航海
- //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) {
- // console.log("false 2")
- // return result
- //}
- if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) {
- if (point.x > this.offPos.x + addX - 200) {
- console.log("false 3")
- return result
- }
- //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
- //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
- //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
- //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
- if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游
- console.log("false 4")
- return result
- }
- }
- let localPosX = point.x - this.offPos.x
- //let localPosY = pointY - this.offPos.y //航海
- //let localPosY = pointY - this.CarPark.y - 80;
- let localPosY = pointY - this.CarPark.y;
- //let localPosY = pointY - this.CarPark.y - 26;
- //console.log("LocalY: " + localPosY);
- //let tx = 170 * 0.5
- //let ty = 120 * 0.5
- let tx = this.carParkSize.x * 0.5
- let ty = this.carParkSize.x * 0.5
- this.CarPark.children.forEach(element => {
- if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) {
- //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) {
- //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) {
- if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) {
- //console.log("------ok");
- this.P1 = element
- let s = this.P1.getComponent(CarSpace)
- if (s.type != 0 && s.type > 0) {
- result = true;
- }
- //if (s.type != 0) {
- // if (s.type >= 10000) {
- // result = true;
- // } else {
- // //单击到角色
- // result = false;
- // //s.ClickRole();
- // }
- //}
- }
- }
- })
- return result
- }
- hideHandGuide() {
- if (this.hasHand) {
- this.hasHand = false
- if (this.handTween) {
- this.handTween.stop()
- }
- this.hand.active = false
- }
- }
- hideAllHand() {
- this.hasHand = false
- if (this.handTween) {
- this.handTween.stop()
- }
- this.hand.active = false
- this.buyHand.active = false
- this.cashHand.active = false
- }
- showBuyCarHand() {
- // this.hideHandGuide()
- // this.buyHand.x = 50
- // this.buyHand.active = true
- cc.tween(this.btnBuy)
- .delay(0.3)
- .to(0.3, { scale: 1.2 })
- .to(0.3, { scale: 1 })
- .start()
- }
- showInvestHand() {
- this.hideHandGuide()
- //this.buyHand.x = 200
- this.buyHand.x = 180
- this.buyHand.active = true
- }
- private coolTime = false
- onTouchStart(evt) {
- //MyExtends.GetAryByAry(5, [1, 2, 3, 4, 5, 6, 7], true);
- //console.log("----Cool" + this.coolTime);
- if (this.coolTime) {
- return
- }
- this.P1 = null
- this.P2 = null
- //西游
- let tempstartpos = evt.touch._point;
- this.moveStartPos = cc.v2();
- this.moveStartPos.x = tempstartpos.x;
- this.moveStartPos.y = tempstartpos.y;
- this.IsClickOther = this.checkClickNoEmptyOther(evt.touch._point);
- if (this.IsClickOther) {
- this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
- this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
- //console.log("--->On End")
- }
- this.curGuideId = GuideMng.Ins.CurGuideId;
- //航海
- //let result = this.checkClickPos(evt.touch._point, 0)
- //if (result) {
- // this.coolTime = true
- // this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
- // this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
- // this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
- //
- // let localPosX = evt.touch._point.x - this.sW * 0.5
- // let localPosY = evt.touch._point.y - this.sH * 0.5
- // GameM.selCarMove.setPosition(localPosX, localPosY)
- //
- // this.showCanCompose()
- // this.hideHandGuide()
- //
- // if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
- // this.ActiceTrashState(true);
- //}
- }
- showCanCompose() {
- let type = this.P1.getComponent(CarSpace).type
- let s
- this.CarPark.children.forEach(element => {
- if (element != this.P1) {
- s = element.getComponent(CarSpace)
- if (s.type != 0 && s.type < 10000 && s.type == type) {
- s.showCanCompose()
- }
- }
- })
- }
- hideCanCompose() {
- let s
- this.CarPark.children.forEach(element => {
- s = element.getComponent(CarSpace)
- s.hideCanCompose()
- })
- }
- //西游
- /**合成引导移动限制区域*/
- composeRectNode: cc.Node = null;
- curGuideId: number = -1;
- /**是否点击到非车位 金币 礼包等*/
- IsClickOther: boolean = false;
- /**移动相应距离算拖拽*/
- moveDisTarget: number = 30;
- /**移动的距离*/
- moveDis: number = 0;
- /**点击坐标*/
- moveStartPos: cc.Vec2 = null;
- /**拖动坐标*/
- moveingPos: cc.Vec2 = cc.v2();
- /**是否可以拖动*/
- moveOpen: boolean = false
- onTouchMove(evt) {
- //西游
- if (this.moveStartPos == null) return;
- this.moveingPos = this.moveStartPos.sub(evt.touch._point);
- this.moveDis = this.moveingPos.len();
- if (this.moveDis >= this.moveDisTarget && !this.coolTime) {
- let result = this.checkClickPos(this.moveStartPos, 0)
- if (result) {
- this.coolTime = true
- //console.log("---Set true")
- this.moveOpen = true;
- if (!this.IsClickOther) {
- //this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)//航海
- this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
- this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
- //console.log("--->On End move")
- }
- let localPosX = evt.touch._point.x - this.sW * 0.5;
- let localPosY = evt.touch._point.y - this.sH * 0.5;
- GameM.selCarMove.setPosition(localPosX, localPosY);
- this.showCanCompose()
- this.hideHandGuide()
- if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
- this.ActiceTrashState(true);
- }
- }
- if (this.coolTime) {
- if (GameM.selCarMove.getComponent(CarMove).sel) {
- let localPosX = evt.touch._point.x - this.sW * 0.5
- let localPosY = evt.touch._point.y - this.sH * 0.5
- if (this.curGuideId == 1) {
- if (!MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) {
- GameM.selCarMove.setPosition(localPosX, localPosY);
- }
- } else if (this.curGuideId == 11) {
- }
- else {
- GameM.selCarMove.setPosition(localPosX, localPosY);
- }
- //let localPosX = evt.touch._point.x - this.sW * 0.5
- //let localPosY = evt.touch._point.y - this.sH * 0.5
- //GameM.selCarMove.setPosition(localPosX, localPosY)
- }
- }
- //console.log("---Move CooolTime:" + this.coolTime);
- //航海
- //console.log("Start:" + this.moveStartPos.x + " Move:" + this.moveingPos.x + "---Length:" + this.moveDis);
- //if (GameM.selCarMove.getComponent(CarMove).sel) {
- // let localPosX = evt.touch._point.x - this.sW * 0.5
- // let localPosY = evt.touch._point.y - this.sH * 0.5
- // GameM.selCarMove.setPosition(localPosX, localPosY)
- //}
- }
- onTouchEnd(evt) {
- let ms = GameM.selCarMove.getComponent(CarMove)
- let os = GameM.otherCarMove.getComponent(CarMove)
- let self = this
- //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
- this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
- this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
- //console.log("--->Off End")
- this.checkClickPos(evt.touch._point, 1)
- if (this.curGuideId == 1) {
- //if (point.x > this.offPos.x + addX - 200) {
- // console.log("false 3")
- // return result
- //}
- //
- ////if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
- ////if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
- ////console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
- ////if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
- //if (pointY < this.CarPark.y - addY + 138 * 2 + 80) { //西游
- // console.log("false 4")
- // return result
- //}
- let localPosX = evt.touch._point.x - this.sW * 0.5
- let localPosY = evt.touch._point.y - this.sH * 0.5
- if (MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- })
- .start()
- this.ActiceTrashState(false);
- this.moveStartPos = null;
- this.hideCanCompose();
- return;
- }
- } else if (this.curGuideId == 11) {
- GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY));
- ms.onHide();
- self.P1.getComponent(CarSpace).showImg();
- //self.coolTime = false;
- this.ActiceTrashState(false);
- //this.moveStartPos = null;
- this.hideCanCompose();
- if (ms.sel && ms.type != 0 && ms.type < 10000) { }
- else {
- if (this.P1 == this.P2) {
- let s = this.P1.getComponent(CarSpace)
- //console.log("Click type:"+s.type);
- if (s.type <= 10000) {
- //点击角色
- if (s.type != 0 && s.type < 10000) {
- s.ClickRole();
- }
- }
- }
- }
- self.coolTime = false;
- this.moveStartPos = null;
- return;
- }
- if (ms.sel && ms.type != 0 && ms.type < 10000) {
- this.hideCanCompose()
- //回到原位置
- if (!os.sel) {
- let localPosX = evt.touch._point.x - this.sW * 0.5
- let localPosY = evt.touch._point.y - this.sH * 0.5
- let tw = this.btnBuy.width * 0.5
- let ty = this.btnBuy.height * 0.5
- if (localPosX >= this.btnBuy.x - tw && localPosX <= this.btnBuy.x + tw
- && localPosY >= this.btnBuy.y - ty && localPosY <= this.btnBuy.y + ty && GameM.commonData.step > 3) {
- //回收
- ms.onHide()
- self.P1.getComponent(CarSpace).changeType(0)
- GameM.commonData.updateBagCarData(ms.index.toString(), 0)
- //西游
- if (GameM.commonData.isUseXiYouAddCoin) {
- self.removeRunRole(self.P1.getComponent(CarSpace));
- }
- GameM.commonData.updateGold(GameM.commonData.carCfg[ms.type.toString()].price)
- this.scheduleOnce(() => {
- self.checkGiftByQucece()
- self.coolTime = false
- }, 0.1)
- this.ActiceTrashState(false);
- EffectNode.instance.PlayTrashAni(Number(GameM.commonData.carCfg[ms.type.toString()].price));
- this.CheckNormalGuide();
- }
- else {
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- }
- this.ActiceTrashState(false);
- }
- }
- else {
- //合成
- if (os.type != 0) {
- if (os.type >= 10000) {
- //回到原位置
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- }
- os.onHide()
- }
- else {
- if (ms.index != os.index) {
- if (ms.type == os.type) {
- self.scheduleOnce(function () {
- GameM.audioM.playEffect(AUDIO_TYPE.compose)
- self.composeAni.node.setPosition(cc.v2(self.P2.position.x, self.P2.position.y + 74 + this.moveEndY))
- self.composeAni.node.active = true
- self.composeAni.setAnimation(0, 'animation', false)
- self.scheduleOnce(() => { self.composeAni.node.active = false }, 1.5)
- }, 0.13)
- GameM.selCarMove.setPosition(cc.v2(this.P2.position.x - 120, this.P2.position.y + 74 + this.moveEndY))
- GameM.selCarMove.angle = 0
- GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x + 120, this.P2.position.y + 74 + this.moveEndY))
- GameM.otherCarMove.angle = 0
- cc.tween(GameM.selCarMove)
- .to(0.05, { position: cc.v2(this.P2.position.x - 150, this.P2.position.y + 74 + this.moveEndY), angle: 30 })
- .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 })
- .call(function () {
- ms.onHide()
- let p1CarSpace = self.P1.getComponent(CarSpace)
- p1CarSpace.changeType(0)
- //self.P1.getComponent(CarSpace).changeType(0)
- //西游
- if (GameM.commonData.isUseXiYouAddCoin) {
- self.removeRunRole(p1CarSpace);
- //p1CarSpace.RemoveCoinSpawn();
- }
- self.checkGiftByQucece()
- })
- .start()
- cc.tween(GameM.otherCarMove)
- .to(0.05, { position: cc.v2(this.P2.position.x + 150, this.P2.position.y + 74 + this.moveEndY), angle: -30 })
- .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 })
- .call(function () {
- os.onHide()
- let p2CarSpace = self.P2.getComponent(CarSpace);
- p2CarSpace.changeType(Number(os.type) + 1)
- //self.P2.getComponent(CarSpace).changeType(Number(os.type) + 1)
- let last = Sciencen_M.instance.accMul(GameM.commonData.carCfg[(Number(ms.type)).toString()].exp, '2')
- let exp = Sciencen_M.instance.subtraction(GameM.commonData.carCfg[(Number(ms.type) + 1).toString()].exp, last)
- //西游 因为会重新AddCoinSpawn所以不用Remove
- //p1CarSpace.RemoveCoinSpawn();
- if (GameM.commonData.isUseXiYouAddCoin) {
- self.removeRunRole(p2CarSpace);
- }
- GameM.commonData.updateBagCarData(ms.index.toString(), 0, 1, false)
- GameM.commonData.updateBagCarData(os.index.toString(), Number(os.type) + 1)
- //西游
- if (GameM.commonData.isUseXiYouAddCoin) {
- self.addRunRole(Number(os.type) + 1, p2CarSpace);
- p2CarSpace.role.ComposeRole();
- //p2CarSpace.AddCoinSpawn();
- }
- UiM.Instance.panelFuns.push(() => GameM.commonData.updateRoleDataExp(exp));
- UiM.Instance.panelFuns.push(() => GameM.commonData.updateMaxCarLevel(Number(os.type) + 1)); //最先执行 后进先出
- //西游
- //弃用 继续使用 maxCarLevel 更新合成的最高等级
- //GameM.commonData.UpdateComposeMaxRoleLv(Number(os.type) + 1);
- UiM.Instance.displayPanel();
- self.coolTime = false
- // if (GameM.commonData.step == 3) {
- // UiM.Instance.guideNode.getComponent(Guide).setStep()
- // }
- self.CheckNormalGuide();
- })
- .start()
- //西游 切换背景
- //this.UpdateMainBg();
- //this.ChangeBgSelf();
- if (GameM.commonData.composeCarTimes == 0) {
- AdM.onSendEvent('compose_1', '合成第1只武将', 'compose')
- }
- GameM.commonData.updateComposeCarTimes()
- AdM.onSendEvent(`operate${Number(os.type) + 1}`, `合成${Number(os.type) + 1}级的武将`)
- this.ActiceTrashState(false);
- //EffectNode.instance.PlayExpEffect(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY));
- }
- //交换位置
- else {
- let cs1 = self.P1.getComponent(CarSpace)
- let cs2 = self.P2.getComponent(CarSpace)
- let tempCs1role: any = cs1.role
- let tempCs2Role: any = cs2.role
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- cs2.changeType(ms.type)
- cs2.role = tempCs1role
- cs2.role.UpdateRoleSpace(cs2)
- })
- .start()
- GameM.otherCarMove.y += 130
- cc.tween(GameM.otherCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- os.onHide()
- cs1.changeType(os.type)
- cs1.role = tempCs2Role
- cs1.role.UpdateRoleSpace(cs1)
- GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
- GameM.commonData.updateBagCarData(ms.index.toString(), os.type)
- self.coolTime = false
- //console.log("---Set False quality")
- self.CheckNormalGuide();
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY))
- ms.onHide()
- cs2.changeType(ms.type)
- cs2.role = tempCs1role
- cs2.role.UpdateRoleSpace(cs2)
- GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
- GameM.otherCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
- os.onHide()
- cs1.changeType(os.type)
- cs1.role = tempCs2Role
- cs1.role.UpdateRoleSpace(cs1)
- GameM.commonData.updateBagCarData(ms.index.toString(), os.type)
- self.coolTime = false
- //console.log("---Set False no quality")
- this.CheckNormalGuide();
- }
- this.ActiceTrashState(false);
- }
- }
- else {
- //回到原位置
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- self.coolTime = false
- }
- os.onHide()
- this.ActiceTrashState(false);
- }
- }
- }
- else {
- let cs1 = self.P1.getComponent(CarSpace)
- let cs2 = self.P2.getComponent(CarSpace)
- let tempCs1role: any = cs1.role
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- os.onHide()
- cs2.changeType(ms.type)
- cs1.changeType(0)
- tempCs1role.RemoveOldStrike()
- cs2.role = tempCs1role
- cs2.role.UpdateRoleSpace(cs2)
- cs1.ClearRole();
- //cs1.role
- GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
- GameM.commonData.updateBagCarData(ms.index.toString(), 0)
- self.coolTime = false
- self.CheckNormalGuide();
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY))
- ms.onHide()
- os.onHide()
- self.P2.getComponent(CarSpace).changeType(ms.type)
- self.P1.getComponent(CarSpace).changeType(0)
- GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
- GameM.commonData.updateBagCarData(ms.index.toString(), 0)
- self.coolTime = false
- }
- this.ActiceTrashState(false);
- this.CheckNormalGuide();
- }
- }
- }
- else {
- if (this.P1 == this.P2) {
- let s = this.P1.getComponent(CarSpace)
- //console.log("Click type:"+s.type);
- if (s.type > 10000) {
- //打开礼包
- if (s.type == MONEY_TYPE.box) {
- let type = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_car)
- this.P1.getComponent(CarSpace).openBox(type)
- //console.log("click box");
- }
- else {
- if (s.type == MONEY_TYPE.redMoney) {
- UiM.Instance.redPackageNode.init(s.num, 1, 3, this.P1)
- UiM.Instance.openPanel(UiM.Instance.redPackageNode.node, false)
- //console.log("click redmoney");
- }
- else {
- //console.log("click others");
- //显示领取道具
- UiM.Instance.checkDelayShow(() => {
- UiM.Instance.giftNode.active = true
- UiM.Instance.giftNode.x = 0
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- gift.init(s.type, String(s.num), this.P1, false, 0)
- })
- }
- }
- this.CheckNormalGuide();
- } else {
- //点击角色
- if (s.type != 0 && s.type < 10000) {
- s.ClickRole();
- }
- }
- }
- self.coolTime = false
- }
- //this.unschedule(this.CheckNormalGuide)
- //this.scheduleOnce(this.CheckNormalGuide, 0.2)
- //常规引导
- this.unschedule(this.CheckNormalGuide)
- this.scheduleOnce(() => {
- //console.log("----------End")
- //this.CheckNormalGuide();
- this.schedule(this.CheckNormalGuide, 5);
- }, 0.2)
- //西游 清空点击点坐标数据 防止误操作
- this.moveStartPos = null
- //console.log("------>End");
- }
- onTouchCacel(evt) {
- //西游 清空点击点坐标数据
- this.moveStartPos = null
- let self = this
- let ms = GameM.selCarMove.getComponent(CarMove)
- if (ms.sel) {
- if (GameM.commonData.quality > Game_Quality.medium) {
- cc.tween(GameM.selCarMove)
- .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
- .call(function () {
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- })
- .start()
- }
- else {
- GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
- ms.onHide()
- self.P1.getComponent(CarSpace).showImg()
- }
- //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
- this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
- this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
- self.coolTime = false
- console.log("--->Off End cancel")
- }
- console.log("----------Cancel")
- if (GameM.commonData.maxCarLevel >= 10) {
- }
- else {
- this.CheckNormalGuide();
- }
- }
- /** 开启判断给礼包定时器 */
- startAddTimer() {
- LogUtil.logV("startAddTimer", "start")
- if (GameM.commonData.maxCarLevel >= GameM.commonData.dropGiftOpenLevel) {
- if (GameM.commonData.giftTimes < GameM.commonData.giftMaxTimes) {
- //let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5)
- //test
- let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5)
- this.scheduleOnce(() => {
- GameM.commonData.updateGiftCacheNum(1)
- this.addGiftBag()
- this.startAddTimer()
- }, timespan)
- }
- }
- }
- /** 有空位检查添加礼包 */
- checkGiftByQucece() {
- LogUtil.logV("checkGiftByQucece", "")
- if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) {
- return;
- }
- if (GameM.commonData.boxCacheNum > 0) {
- this.addBoxBag()
- }
- else if (GameM.commonData.giftCacheNum > 0) {
- this.addGiftBag()
- }
- }
- delayAddGift() {
- if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) {
- return;
- }
- if (GameM.commonData.giftCacheNum > 0 || GameM.commonData.boxCacheNum > 0) {
- this.schedule(this.addGifts, 1, GameM.commonData.giftCacheNum)
- }
- }
- addGifts() {
- if (GameM.commonData.boxCacheNum <= 0 && GameM.commonData.giftCacheNum <= 0) {
- this.unschedule(this.addGifts)
- }
- else {
- this.checkGiftByQucece()
- }
- }
- /** 立即获得box礼包 */
- addBoxGiftNow() {
- let pos = this.getEmptySpace()
- if (pos != '') {
- GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
- let num = 1
- GameM.commonData.updateBagCarData(pos, MONEY_TYPE.box, num)
- let space = this.CarPark.getChildByName(pos)
- let s = space.getComponent(CarSpace)
- s.type = MONEY_TYPE.box
- s.init(true, num)
- }
- else {
- this.CheckNormalGuide()
- GameM.commonData.updateBoxCacheNum(1)
- }
- }
- /** 添加礼包
- * @param type 礼包类型
- * 10001:金币
- * 10002:红包币
- * 10003:时间段收益(当前的每秒收益*时间段)
- * 10004:惊喜礼包(打开后获得对应等级的轮船)
- */
- addGiftBag() {
- LogUtil.logV("addGiftBag", "")
- //只在此处可能出现元宝币
- let data = GameM.commonData.giftRandomAdd()
- let pos = this.getEmptySpace()
- //console.log("Empty:" + pos)
- if (pos != '') {
- GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
- let num = 0
- if (data[0] == MONEY_TYPE.gold.toString()) {
- num = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_gold)
- }
- else {
- num = Number(data[1])
- }
- if (data[0] == MONEY_TYPE.redMoney.toString()) {
- this.redMoneyInGiftBag(pos, MONEY_TYPE.redMoney)
- } else {
- GameM.commonData.updateBagCarData(pos, Number(data[0]), num)
- this.scheduleOnce(() => {
- let space = this.CarPark.getChildByName(pos)
- let s = space.getComponent(CarSpace)
- s.type = Number(data[0])
- s.init(true, num)
- GameM.commonData.updateGiftCacheNum(-1)
- }, 0.05)
- }
- }
- else {
- this.CheckNormalGuide()
- }
- }
- redMoneyInGiftBag(pos, type) {
- HttpM.Instance.SendData(HTTP_TYPE.adShowConfig,
- {}, (res) => {
- LogUtil.logV("redMoneyInGiftBag:", res)
- if (res && res.data) {
- let num = 0
- let average_ecpm = res.data.average_ecpm
- if (average_ecpm == 0) {
- num = GameM.commonData.giftBagRedMoney[0][2]
- } else {
- for (let entry of GameM.commonData.giftBagRedMoney) {
- if (average_ecpm > entry[0] && average_ecpm <= entry[1]) {
- num = entry[2]
- break
- }
- }
- if (num == 0) {
- num = GameM.commonData.giftBagRedMoney[0][2]
- }
- }
- GameM.commonData.updateBagCarData(pos, type, num)
- this.scheduleOnce(() => {
- let space = this.CarPark.getChildByName(pos)
- let s = space.getComponent(CarSpace)
- s.type = Number(type)
- s.init(true, num)
- GameM.commonData.updateGiftCacheNum(-1)
- }, 0.05)
- }
- //console.log("-->uplevel talent:", res);
- })
- }
- /** 只添加box
- * @param type
- * 10004:惊喜礼包(打开后获得对应等级的轮船)
- */
- addBoxBag() {
- let pos = this.getEmptySpace()
- if (pos != '') {
- GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
- let num = 1
- let type = 10004
- GameM.commonData.updateBagCarData(pos, type, num)
- this.scheduleOnce(() => {
- let space = this.CarPark.getChildByName(pos)
- let s = space.getComponent(CarSpace)
- s.type = type
- s.init(true, num)
- GameM.commonData.updateBoxCacheNum(-1)
- }, 0.1)
- }
- else {
- this.CheckNormalGuide()
- }
- }
- private lvupPos = ''
- private lvupLv = -1
- private lvupPreLv = -1
- /** 点击购买车辆 */
- onBuyCar() {
- GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar)
- let pos = this.getEmptySpace()
- if (pos != '') {
- let price = GameM.commonData.getPriceByType(this.curBuyType)
- //白龙马天赋3
- price = Sciencen_M.instance.subtraction(price, Sciencen_M.instance.accMul(price, (MateData.Ins.Mate3Talent3 * 0.01).toString()));
- if (GameM.commonData.updateGoldMinus(price)) {
- if (GameM.commonData.maxCarLevel > 14) {
- let result = GameM.commonData.checkShowLvUp()
- if (result > 0) {
- if (GameM.commonData.buyTimeTotal - GameM.commonData.lastVideoUpCarBuyTimes >= 10) {
- GameM.commonData.updatelastVideoUpCarBuyTimes()
- UiM.Instance.checkDelayShow(() => {
- UiM.Instance.giftNode.active = true
- this.lvupPos = pos
- this.lvupLv = result
- this.lvupPreLv = this.curBuyType
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- gift.init(MONEY_TYPE.carLvUp, String(result), this.curBuyType, false, 0, VIDEO_TYPE.carLvUp)
- })
- }
- }
- }
- if (this.buyHand.active) {
- this.buyHand.active = false
- }
- this.addAParkCar(pos, this.curBuyType)
- GameM.commonData.updateBuyTimeData(this.curBuyType)
- GameM.commonData.updateBuyTimeTotal()
- this.CheckNormalGuide()
- //西游测试
- this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal;
- if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 1) {
- // this.dailyCash = DailyCashData.Instance.getTodayDailyCash()
- if (DailyCashData.Instance.userDailyCashInfo) {
- this.dailyCash = DailyCashData.Instance.userDailyCashInfo
- if (GameM.commonData.roleData.dailyPro < this.dailyCash.buyTime) {
- let addGold = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.DailyCashProAdd);
- addGold.getComponent(DailyCashProAdd).init("进度+1");
- // addGold.x = 50;
- this.dailyCashBtn.node.addChild(addGold);
- GameM.commonData.updateDailyCash(0, 1, true)
- this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime
- this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
- // let str = `当前提现进度: ${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
- // let labPre = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.BuyProAdd);
- // labPre.getComponent(BuyProAdd).init(str)
- // this.posBtnBuy.addChild(labPre)
- this.labTixianPro.node.active = true
- this.labWuFuNode.active = false
- //飞红包
- EffectNode.instance.PlayCoinAnim(14, 5, cc.v2(this.btnBuy.position.x, this.btnBuy.position.y), true,
- cc.v2(this.dailyCashBtn.node.position.x, this.dailyCashBtn.node.position.y + this.centerPart.y))
- GameM.audioM.playEffect(AUDIO_TYPE.getGold)
- cc.tween(this.dailyCashBtn.node)
- .delay(1)
- .to(0.2, { scale: 1.2 })
- .to(0.2, { scale: 1 })
- .start()
- if (GameM.commonData.roleData.dailyPro == this.dailyCash.buyTime && GameM.commonData.roleData.canDailyCash != 0) {
- AdM.onSendEvent('nextcash_finish', '明日提现任务完成', 'nextcash')
- }
- if (this.dailyBtn != null) {
- if (GameM.commonData.roleData.dailyPro >= this.dailyCash.buyTime) {
- GuideMng.Ins.CheckFiveluck2Guide12()
- }
- }
- // EffectNode.instance.PlayExpEffect(cc.v2(this.posBtnBuy.x, this.posBtnBuy.y), 2);
- }
- }
- }
- let exp = GameM.commonData.carCfg[this.curBuyType.toString()].exp
- GameM.commonData.updateRoleDataExp(exp)
- GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
- this.carBuyInfo()
- //财神降临
- WealthData.Ins.CheckTrigger();
- AdM.onSendEvent(`buy_${GameM.commonData.buyTimeTotal}`, `第${GameM.commonData.buyTimeTotal}次买车`, 'buy')
- } else {
- if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
- EffectNode.instance.PlayTip('今日金币获取次数已用尽')
- this.hideAllHand()
- this.CheckNormalGuide()
- //弹出金币获取方式界面
- UiM.Instance.onPanel(PANEL_NAME.CoinTipNode)
- }
- else {
- if (GameM.commonData.checkShowMainPop()) {
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- //唐僧天赋3
- videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
- videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
- percent = Math.floor(percent * 100)
- gift.init(MONEY_TYPE.mainBuyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent)
- UiM.Instance.giftNode.x = 0
- UiM.Instance.giftNode.active = true
- }
- else {
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
- videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
- //唐僧天赋3
- videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
- percent = Math.floor(percent * 100)
- gift.init(MONEY_TYPE.gold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent)
- UiM.Instance.giftNode.x = 1000
- UiM.Instance.giftNode.active = true
- GameM.adM.watchVideo(VIDEO_TYPE.buyCarMainBtn);
- }
- }
- }
- //判断是否可以购买车辆
- this.updateBuyBtnState();
- }
- else {
- EffectNode.instance.PlayTip("位置已满");
- this.CheckNormalGuide()
- }
- }
- resetFillRange() {
- this.tixianFill.fillRange = 0
- }
- getDailyCar(carlv) {
- let pos = this.getEmptySpace()
- if (pos != '') {
- this.addAParkCar(pos, carlv)
- GameM.commonData.updateMaxCarLevel(carlv, true)
- // let exp = GameM.commonData.carCfg[carlv.toString()].exp
- // GameM.commonData.updateRoleDataExp(exp)
- UiM.Instance.dailyNode.getComponent(Daily).hasOpen()
- EffectNode.instance.PlayTip("武将已发放到位置");
- }
- else {
- EffectNode.instance.PlayTip("位置已满,请空出位置再领");
- }
- }
- getTaskAwardCar(carlv) {
- let pos = this.getEmptySpace()
- if (pos != '') {
- this.addAParkCar(pos, carlv)
- GameM.commonData.updateMaxCarLevel(carlv, true)
- EffectNode.instance.PlayTip(`${carlv}级武将已发放`);
- }
- else {
- EffectNode.instance.PlayTip("位置已满,请空出位置再领");
- }
- }
- /** 看视频升级车成功 */
- carLvUpVideoEnd() {
- UiM.Instance.giftNode.active = false
- EffectNode.instance.PlayTip("升级成功!");
- GameM.commonData.updateBagCarData(this.lvupPos, this.lvupLv)
- let space = this.CarPark.getChildByName(this.lvupPos)
- let s = space.getComponent(CarSpace)
- s.type = this.lvupLv
- s.init()
- let expPre = GameM.commonData.carCfg[this.lvupPreLv.toString()].exp
- let exp = GameM.commonData.carCfg[this.lvupLv.toString()].exp
- GameM.commonData.updateRoleDataExp(Sciencen_M.instance.subtraction(exp, expPre))
- //西游
- if (GameM.commonData.isUseXiYouAddCoin) {
- this.addRunRole(this.lvupLv, s);
- //s.AddCoinSpawn();
- }
- this.hideHandGuide()
- this.CheckNormalGuide()
- if (UiM.Instance.shopNode) {
- UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.shopBuyCarType)
- this.shopBuyCarType = 0
- }
- }
- /**
- * 判断是否有足够金币买车
- * 显示按钮状态
- */
- updateBuyBtnState() {
- //判断是否可以购买车辆
- let nextPrice = GameM.commonData.getPriceByType(this.curBuyType);
- if (Sciencen_M.instance.ContrastNumber(GameM.commonData.gold, nextPrice)) {
- //显示购买按钮
- this.btnBuy.getComponent(CarInfo).ShowBuyBtn();
- } else {
- //显示广告按钮
- this.btnBuy.getComponent(CarInfo).ShowAdBtn();
- }
- }
- /**显示或隐藏立即回收按钮*/
- ActiceTrashState(active: boolean) {
- if (GameM.commonData.step <= 3) {
- return
- }
- if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
- this.btnBuy.getComponent(CarInfo).ActiveTrasnBtn(active, GameM.commonData.carCfg[GameM.selCarMove.getComponent(CarMove).type.toString()].price);
- }
- private shopBuyCarType = 0
- /** 购买指定车辆
- * @param type 指定类型车
- * @param buyMoney 0 金币 1 视频 2 红包币
- */
- onBuyTypeCar(type, buyMoney = 0) {
- GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar)
- let pos = this.getEmptySpace()
- if (pos != '') {
- if (buyMoney == 0) {
- let price = GameM.commonData.getPriceByType(type)
- if (GameM.commonData.updateGoldMinus(price)) {
- this.addAParkCar(pos, type)
- GameM.commonData.roleData.shopTotal++
- // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
- let exp = GameM.commonData.carCfg[type.toString()].exp
- GameM.commonData.updateRoleDataExp(exp)
- GameM.commonData.updateBuyTimeData(type, true)
- GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
- //购买次数修改
- let times = LocalManagerData.Instance.getBuyCarData(type)
- times++
- LocalManagerData.Instance.saveBuyCarData(type, times)
- UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type)
- EffectNode.instance.PlayTip("购买成功");
- //判断是否可以购买车辆
- this.updateBuyBtnState();
- } else {
- // EffectNode.instance.PlayTip("金币不足,购买失败");
- if (GameM.commonData.isVideoTest) {
- if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
- EffectNode.instance.PlayTip('金币不足,并且今日金币获取次数已用尽')
- this.hideAllHand()
- this.CheckNormalGuide()
- }
- else {
- this.shopBuyCarType = type
- UiM.Instance.checkDelayShow(() => {
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
- videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
- //唐僧天赋3
- videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
- percent = Math.floor(percent * 100)
- gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent)
- UiM.Instance.giftNode.x = 0
- UiM.Instance.giftNode.active = true
- })
- }
- }
- else {
- if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
- EffectNode.instance.PlayTip('今日金币获取次数已用尽')
- this.hideAllHand()
- this.CheckNormalGuide()
- }
- else {
- this.shopBuyCarType = type
- UiM.Instance.checkDelayShow(() => {
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
- videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
- //唐僧天赋3
- videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
- percent = Math.floor(percent * 100)
- gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent)
- UiM.Instance.giftNode.x = 0
- UiM.Instance.giftNode.active = true
- })
- }
- }
- }
- }
- else if (buyMoney == 1) {
- //调取看视频接口
- this.tempPos = pos
- this.tempType = type
- GameM.adM.watchVideo(VIDEO_TYPE.buyCar)
- }
- else if (buyMoney == 2) {
- let price = GameM.commonData.getMoneyPriceBuyType(type)
- if (GameM.commonData.updateRedMoney(-price, RecordTYPE.buyNewCar)) {
- this.addAParkCar(pos, type)
- GameM.commonData.roleData.shopTotal++
- // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
- let exp = GameM.commonData.carCfg[type.toString()].exp
- GameM.commonData.updateRoleDataExp(exp)
- GameM.commonData.updateBuyTimeData(type, true)
- UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type)
- EffectNode.instance.PlayTip("购买成功");
- } else {
- EffectNode.instance.PlayTip("红包币不足,购买失败");
- }
- }
- }
- else {
- EffectNode.instance.PlayTip("位置已满");
- this.CheckNormalGuide()
- }
- }
- /**购买按钮视频广告回调*/
- onBuyCarAdEnd() {
- if (GameM.commonData.checkShowMainPop()) {
- this.onGetGold()
- }
- else {
- UiM.Instance.giftNode.active = true
- UiM.Instance.giftNode.x = 0
- AdM.showNative(0)
- }
- GameM.commonData.updateClickVideoTimes()
- GameM.commonData.addDailyFinishTimesDataByType(7)
- this.updateBuyBtnState();
- }
- onShopBuyCarAdEnd() {
- this.onGetGold()
- }
- onGetGold() {
- let key = 'dddddddddddddddddddddddddddddddd'
- GameM.commonData.dayBuyCarVideoLimitTimes--
- let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid)
- GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1)
- UiM.Instance.giftNode.active = false
- EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
- videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
- //唐僧天赋3
- videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
- GameM.commonData.updateGold(videoPrice)
- GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
- EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
- }
- onBuyCarAdFail() {
- // UiM.Instance.giftNode.active = false
- // UiM.Instance.giftNode.x = 0
- // AdM.destroyNative()
- }
- private tempType = 0
- private tempPos = ''
- onVideoBuyCarEnd() {
- this.addAParkCar(this.tempPos, this.tempType)
- GameM.commonData.roleData.shopTotal++
- // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
- let exp = GameM.commonData.carCfg[this.tempType.toString()].exp
- GameM.commonData.updateRoleDataExp(exp)
- GameM.commonData.updateBuyTimeData(this.tempType, true)
- UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.tempType)
- GameM.commonData.addDailyFinishTimesDataByType(7)
- EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
- }
- /** 设置购买车信息 */
- carBuyInfo() {
- //console.log("---->BuyTimes:" + GameM.commonData.buyTimeTotal);
- let info = this.btnBuy.getComponent(CarInfo)
- let times = GameM.commonData.buyTimeTotal + 1
- this.curBuyType = Number(GameM.commonData.buyNumCfg[times.toString()].car_level)
- //TEST
- if (GameM.commonData.IsTest)
- this.curBuyType = GameM.commonData.maxCarLevel <= 0 ? 1 : GameM.commonData.maxCarLevel;
- info.changeType(this.curBuyType)
- }
- /** 点击打开商店 */
- clickOpenShop() {
- AdM.onSendEvent('button_11', '妖洞icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- UiM.Instance.onPanel(PANEL_NAME.ShopNode)
- }
- /** 点击打开设置 */
- clickHead() {
- AdM.onSendEvent('button_14', '头像icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- UiM.Instance.onPanel(PANEL_NAME.SettingNode)
- }
- /** 打开转盘 */
- clickTurntable() {
- AdM.onSendEvent('button_10', '转盘icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- if (GameM.commonData.maxCarLevel < GameM.commonData.turntableOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.turntableOpenLevel}级武将解锁`)
- return
- }
- UiM.Instance.onPanel(PANEL_NAME.TurnTableNode)
- }
- /** 打开任务 */
- clickTask() {
- AdM.onSendEvent('button_7', '日常icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- if (GameM.commonData.maxCarLevel < GameM.commonData.taskOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.taskOpenLevel}级武将解锁`)
- return
- }
- UiM.Instance.taskNode.active = true;
- }
- /** 打开提现 */
- clickCash() {
- AdM.onSendEvent('button_15', '提现icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (!GameM.commonData.redSwitch) {
- EffectNode.instance.PlayTip('敬请期待')
- return
- }
- if (GameM.commonData.maxCarLevel < GameM.commonData.cashOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.cashOpenLevel}级武将可查看`)
- return
- }
- UiM.Instance.onPanel(PANEL_NAME.CashNode, true)
- }
- /** 打开投资 */
- clickInvest() {
- AdM.onSendEvent('button_12', '探索icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- // //test
- // UiM.Instance.onPanel(PANEL_NAME.InvestNode)
- // return
- //if (MateData.Ins.mateUnlockAry[3] == 0) {
- if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.investOpenLevel}级武将解锁`)
- return
- }
- UiM.Instance.onPanel(PANEL_NAME.InvestNode)
- if (GameM.commonData.roleData.investGuide == 0) {
- GameM.commonData.roleData.investGuide = 1
- GameM.commonData.updateRoleData()
- this.hideAllHand()
- // UiM.Instance.guideNode.getComponent(Guide).showInvestStep2()
- }
- }
- /** 打开保险箱 */
- clickSafeBox() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- AdM.onSendEvent("button_8", "钱庄icon", 'button')
- // if (MateData.Ins.mateUnlockAry[4] == 0) {
- // EffectNode.instance.PlayTip('收服23级沙僧解锁')
- // return
- // }
- if (GameM.commonData.maxCarLevel < GameM.commonData.richBankUnLockLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.richBankUnLockLevel}级武将解锁`)
- return
- }
- UiM.Instance.onPanel(PANEL_NAME.SafeDepositBox)
- if (GameM.commonData.roleData.investGuide == 0) {
- GameM.commonData.roleData.investGuide = 1
- GameM.commonData.updateRoleData()
- this.hideAllHand()
- }
- }
- /** 每日豪礼 */
- clickChat() {
- AdM.onSendEvent('button_6', '登录奖励icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (GameM.commonData.maxCarLevel < GameM.commonData.loginRewardOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.loginRewardOpenLevel}级武将解锁`)
- return
- }
- UiM.Instance.onPanel(PANEL_NAME.DailyNode)
- }
- /**俱乐部 */
- clickClubShare() {
- AdM.onSendEvent('button_1', '师徒icon', 'button')
- if (GameM.commonData.maxCarLevel < GameM.commonData.clubOpenLevel) {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.clubOpenLevel}级武将解锁`)
- return
- }
- if (GameM.commonData.isAuth) {
- LogUtil.logV("ClubMain", "clickShare")
- UiM.Instance.onPanel(PANEL_NAME.clubMainNode)
- }
- else {
- AdM.WxLogin();
- }
- }
- /**分享 */
- clickShare() {
- // AdM.onSendEvent('shareClick', '分享icon点击')
- if (GameM.commonData.isAuth) {
- AdM.sharePic();
- }
- else {
- AdM.WxLogin();
- }
- }
- clickAirship() {
- AdM.onSendEvent('button_16', '空投icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.Airship)
- if (this.airshipUp) {
- return
- }
- this.airshipAni.pause()
- UiM.Instance.checkDelayShow(() => {
- let data = this.curAirCfg
- UiM.Instance.giftNode.active = true
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let num = String(data.num)
- if (data.reward == MONEY_TYPE.gold) {
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- num = Sciencen_M.instance.accMul(videoPrice, num)
- }
- gift.init(data.reward, num, null, true, data.is_video)
- })
- }
- /** 随机一个新的热气球奖励 */
- ranNewAirShip() {
- this.getAirByRan()
- let data = this.curAirCfg
- UiM.Instance.giftNode.active = true
- let gift = UiM.Instance.giftNode.getComponent(Gift)
- let num = String(data.num)
- if (data.reward == MONEY_TYPE.gold) {
- let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
- num = Sciencen_M.instance.accMul(videoPrice, num)
- }
- gift.init(data.reward, num, null, true, data.is_video)
- }
- /** 恢复飞艇飞行 */
- resumeAirShip() {
- if (this.airshipUp) {
- return
- }
- this.airshipAni.resume()
- }
- /** 放弃飞艇 */
- dropAirShip() {
- this.airshipAni.stop()
- this.airshipUp = true
- EffectNode.instance.PlayTip('我会回来的!')
- cc.tween(this.airshipAni.node)
- .to(0.2, { scale: 0.6 })
- .to(0.3, { scale: 1.2 })
- .to(0.2, { scale: 1 })
- .by(1, { x: -1000 }, cc.easeIn(3.0))
- .call(() => {
- this.airshipUp = false
- this.checkShowAirship()
- })
- .start()
- }
- /** 每日提现 */
- clickTixian() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- AdM.onSendEvent('button_4', '天天红包icon', 'button')
- if (GameM.commonData.maxCarLevel < GameM.commonData.dailyCashOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.dailyCashOpenLevel}级武将解锁`)
- return
- }
- UiM.Instance.redPackageNode.init(0, 0, 4, null, false)
- UiM.Instance.redPackageNode.node.x = 0
- UiM.Instance.redPackageNode.node.active = true
- //西游
- GameM.audioM.setPauseMusic();
- GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm);
- }
- /** 检查提现进度 */
- checkTixianPro(checkNew = false) {
- if (checkNew) {
- this.curCashCfg = null
- }
- if (!this.curCashCfg) {
- let cfg = CashOutData.Instance.cashCft
- let len = cfg.length
- for (var i = 0; i < len; i++) {
- if (CashOutData.Instance.getCashStatus(cfg[i].index) == 0) {
- this.curCashCfg = cfg[i]
- break
- }
- }
- }
- let money = this.curCashCfg.moneyshow.split('~')[1]
- this.labTixian.string = `${money}`
- //西游
- this.labtargetCarLevel.string = GameM.commonData.fightRoleCfg[this.curCashCfg.type_value.toString()].name;
- this.labTixianLv.string = this.curCashCfg.type_value.toString()
- let pro = GameM.commonData.maxCarLevel / this.curCashCfg.type_value
- this.tixianPro.fillRange = pro
- this.tixianPercent.string = Math.floor(GameM.commonData.maxCarLevel / this.curCashCfg.type_value * 100) + "%"
- if (pro >= 1) {
- this.canGet.active = true
- }
- else {
- this.canGet.active = false
- }
- if (pro >= 0.8) {
- this.approachEff.active = true
- }
- else {
- this.approachEff.active = false
- }
- if (checkNew) {
- cc.loader.loadRes('carPic/side/side_' + this.curCashCfg.type_value.toString(), cc.SpriteFrame, (err, assets) => {
- if (err) {
- cc.error(err);
- return;
- }
- this.spTixianCar.spriteFrame = assets
- })
- }
- }
- playCarProEff() {
- // cc.loader.loadRes('carPic/side/side_' + GameM.commonData.maxCarLevel, cc.SpriteFrame, (err, assets) => {
- // if (err) {
- // cc.error(err);
- // return;
- // }
- // this.carProSp.spriteFrame = assets
- // // this.carProSp.node.setPosition(cc.v2(0, 0))
- // this.carProSp.node.setPosition(GameM.selCarMove.position)
- // this.carProSp.node.scale = 0.4
- // this.carProSp.node.active = true
- // cc.tween(this.carProSp.node).to(0.7, { position: this.tixianProBtn.node.position, scale: 0.4 })
- // .call(() => {
- // this.carProSp.node.active = false
- // let nodeAnim = UiM.Instance.hallNode.getComponent(Main).tixianProBtn.node.getComponent(EachNodeAnim)
- // nodeAnim.startChildAnim()
- // this.scheduleOnce(() => {
- // this.hallLabAddEff.play('upFadeC', 0)
- // }, 0.4)
- // // this.hallLabAddEff.play('upFadeC', 0)
- // this.checkTixianPro()
- // })
- // .start()
- // })
- //改为飞红包
- EffectNode.instance.PlayCoinAnim(14, 10, cc.v2(GameM.selCarMove.position.x, GameM.selCarMove.position.y), true,
- cc.v2(this.tixianProBtn.node.position.x, this.tixianProBtn.node.position.y + this.topPart.y))
- GameM.audioM.playEffect(AUDIO_TYPE.getGold)
- cc.tween(this.tixianProBtn.node)
- .delay(1)
- .to(0.2, { scale: 1.2 })
- .to(0.2, { scale: 1 })
- .start()
- this.checkTixianPro()
- }
- //-----现金夺宝功能----
- private hasTap = false
- clickTreasure() {
- // //test
- // EffectNode.instance.playEggIn()
- // return
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.trerasureOpenLevel}级武将解锁`)
- return
- }
- AdM.onSendEvent('button_9', '现金icon', 'button')
- if (!GameM.commonData.isAuth) {
- if (!this.hasTap) {
- console.log('clickGoAuth')
- this.hasTap = true
- AdM.WxLogin()
- this.scheduleOnce(() => {
- this.hasTap = false
- }, 1)
- }
- }
- else {
- UiM.Instance.onPanel(PANEL_NAME.TreasureNode)
- }
- }
- clickMoreGame() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- AdM.onSendEvent('button_3', '更多红包icon', 'button')
- UiM.Instance.onPanel(PANEL_NAME.moreGameNode)
- }
- setUnlockBtnColor() {
- if (GameM.commonData.maxCarLevel == GameM.commonData.dailyCashOpenLevel) {
- //每日提现
- this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel)
- }
- else if (GameM.commonData.maxCarLevel == GameM.commonData.investOpenLevel) {
- //投资引导
- this.unLockBtn(this.investBtn, GameM.commonData.cashOpenLevel)
- InvestData.Instance.getInvestInfo()
- // if (GameM.commonData.roleData.investGuide == 0) {
- // UiM.Instance.guideNode.getComponent(Guide).showInvestStep1()
- // }
- }
- else if (GameM.commonData.maxCarLevel == GameM.commonData.loginRewardOpenLevel) {
- //登录豪礼
- this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel)
- }
- else if (GameM.commonData.maxCarLevel == GameM.commonData.taskOpenLevel) {
- //每日任务
- this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel)
- }
- else if (GameM.commonData.maxCarLevel == GameM.commonData.trerasureOpenLevel) {
- //现金夺宝
- this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel)
- } else if (GameM.commonData.maxCarLevel == GameM.commonData.richBankUnLockLevel) {
- this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel)
- }
- }
- /**
- * 判断伙伴解锁按钮
- */
- checkMateLockBtn(mateData, unlockLv: number) {
- if (mateData == 3) { //
- this.unLockBtn(this.investBtn, 0, mateData)
- } else if (mateData == 4) {
- this.unLockBtn(this.bankBtn, 0, mateData)
- }
- }
- /** 设置按钮解锁显示状态
- * @param btn 按钮
- * @param unlockLv 解锁等级
- */
- unLockBtn(btn: cc.Button, unlockLv: number, mateData = -1) {
- let normal = btn.node.getChildByName('normal')
- let lock = btn.node.getChildByName('lock')
- if (mateData != -1) {
- if (MateData.Ins.mateUnlockAry[mateData] == 1) {
- normal.active = true
- lock.active = false
- } else {
- normal.active = false
- lock.active = true
- let labLock = lock.getChildByName('labLock')
- if (mateData == 3) {
- labLock.getComponent(cc.Label).string = `收服八戒`
- } else if (mateData == 4) {
- labLock.getComponent(cc.Label).string = `收服沙僧`
- }
- }
- return
- }
- if (GameM.commonData.maxCarLevel >= unlockLv) {
- normal.active = true
- lock.active = false
- }
- else {
- normal.active = false
- lock.active = true
- let labLock = lock.getChildByName('labLock')
- labLock.getComponent(cc.Label).string = `${unlockLv}级解锁`
- }
- }
- //西游
- /**战斗按钮*/
- Click_FightBtn() {
- AdM.onSendEvent('button_2', '降妖伏魔icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- FightData.Ins.EnterFight();
- }
- /**伙伴按钮*/
- Click_MateBtn() {
- AdM.onSendEvent('button_13', '伙伴icon', 'button')
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- UIMng.Ins.AsyncGetPanel(PanelType.MatePanel, (panel) => {
- panel.OnEnter();
- });
- //UIMng.Ins.GetPanel(PanelType.MatePanel).OnEnter();
- }
- /**财神按钮*/
- Click_WealthBtn() {
- //console.log("-------------Max" + GameM.commonData.maxCarLevel + " unlock:" + GameM.commonData.unlockWealthLevel);
- //RichManData.Ins.GetData();
- AdM.onSendEvent(`button_17`, `财神icon点击`, 'button');
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (!WealthData.Ins.isUnlock) {
- EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`)
- return
- }
- //if (GameM.commonData.maxCarLevel < GameM.commonData.unlockWealthLevel) {
- // EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`)
- // return
- //}
- WealthData.Ins.Click_MainWealthBtn();
- }
- Click_GetCoinBtn() {
- UiM.Instance.onPanel(PANEL_NAME.CoinTipNode);
- }
- Click_RichManBtn() {
- UIMng.Ins.AsyncGetPanel(PanelType.RichPanel, (panel) => {
- panel.OnEnter();
- });
- //UIMng.Ins.GetPanel(PanelType.RichPanel).OnEnter();
- AdM.onSendEvent(`button_18`, `取经icon点击`, 'button');
- }
- Click_AdRbBtn() {
- //UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => {
- // panel.OnEnter();
- //});
- //AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button');
- //return;
- if (GameM.commonData.isAuth) {
- UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => {
- panel.OnEnter();
- });
- }
- else {
- AdM.WxLogin();
- }
- AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button');
- }
- /**更新天赋详情*/
- UpdateTalentDetaile() {
- MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem);
- }
- private mateBaJiePos: cc.Vec2 = null;
- /**
- * 显示伙伴
- */
- DisplayMate() {
- let num = MateData.Ins.GetUnlcokMateNum();
- let posAry: cc.Vec2[];
- let index = 0;
- if (MateData.Ins.mateUnlockAry[2] == 0) {
- //白龙马未解锁
- } else {
- //白龙马已解锁
- }
- if (num == 1 || num == 0) {
- posAry = MateData.Ins.matePosAry1;
- } else if (num == 2) {
- if (MateData.Ins.mateUnlockAry[2] == 1)
- posAry = MateData.Ins.matePosAry1;
- else
- posAry = MateData.Ins.matePosAry2;
- } else if (num == 3) {
- if (MateData.Ins.mateUnlockAry[2] == 1)
- posAry = MateData.Ins.matePosAry3;
- else
- posAry = MateData.Ins.matePosAry4;
- } else if (num == 4) {
- if (MateData.Ins.mateUnlockAry[2] == 1)
- posAry = MateData.Ins.matePosAry4;
- else
- posAry = MateData.Ins.matePosAry5;
- } else if (num == 5) {
- posAry = MateData.Ins.matePosAry5;
- }
- // console.log("---------------------> ", posAry);
- //if (MateData.Ins.mateUnlockAry[2] == 1) {
- // this.xiYou_mates[0].active = false;
- // this.xiYou_mates[2].active = true;
- // this.xiYou_mates[2].setPosition(posAry[index]);
- //} else {
- // this.xiYou_mates[0].active = true;
- // this.xiYou_mates[2].active = false;
- // this.xiYou_mates[0].setPosition(posAry[index]);
- //}
- //index++;
- for (let i = 0; i < 5; i++) {
- this.xiYou_mates[i].active = false;
- if (MateData.Ins.mateUnlockAry[i] == 1) {
- this.xiYou_mates[i].active = true;
- // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x);
- //if (i == 3)
- // this.mateBaJiePos = posAry[index];
- //this.xiYou_mates[i].setPosition(posAry[index]);
- //index++;
- }
- //if (i != 0 && i != 2) {
- // this.xiYou_mates[i].active = false;
- // if (MateData.Ins.mateUnlockAry[i] == 1) {
- // this.xiYou_mates[i].active = true;
- // // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x);
- // if (i == 3)
- // this.mateBaJiePos = posAry[index];
- // this.xiYou_mates[i].setPosition(posAry[index]);
- // index++;
- // }
- //}
- }
- }
- private isUpdateBg = true;
- private bgPos: cc.Vec2 = cc.v2(-375, 310);
- private bgBackPos: cc.Vec2 = cc.v2(-375, 310);
- private mateBaTimer: number = 0;
- private mateSunTimer: number = 0;
- private mateBaIndex = 0;
- private mateSunIndex = 0;
- private mateBaUpdate1: boolean = false;
- private mateBaPos: cc.Vec2 = cc.v2(-375, 310);
- private mateBaAniTime: number[] = [3, 8, 11];
- private mateSunAniTime: number[] = [2, 3, 4, 6, 7];
- /**移动背景*/
- MoveBg(dt) {
- if (this.isUpdateBg) {
- //三国战戟 不再移动背景
- return;
- this.bgPos.x -= dt * 100;
- if (this.bgPos.x <= -1333) {
- this.bgPos.x = -375;
- }
- this.bgBackPos.x -= dt * 50;
- if (this.bgBackPos.x <= -1333) {
- this.bgBackPos.x = -375;
- }
- this.xiYou_bgback.setPosition(this.bgBackPos);
- //console.log("POS:",this.bgPos);
- ////伙伴动画处理
- //if (this.xiYou_mates[3].active) {
- // this.mateBaTimer += dt;
- //
- //
- // if (this.mateBaUpdate1) {
- // this.mateBaPos.x -= dt * 100;
- // this.xiYou_mates[3].setPosition(this.mateBaPos);
- // }
- //
- // if (this.mateBaTimer > this.mateBaAniTime[this.mateBaIndex]) {
- // if (this.mateBaIndex == 0) {
- // //this.xiYou_spineBa.clearTrack(0);
- // //this.xiYou_spineBa.setBonesToSetupPose();
- // this.xiYou_spineBa.setAnimation(0, "fall", false);
- // this.mateBaIndex++;
- // this.scheduleOnce(() => {
- // this.mateBaPos = this.xiYou_mates[3].getPosition();
- // this.mateBaUpdate1 = true;
- // }, 0.5)
- // } else if (this.mateBaIndex == 1) {
- // this.mateBaUpdate1 = false;
- // //this.xiYou_spineBa.clearTrack(0);
- // //this.xiYou_spineBa.setBonesToSetupPose();
- // this.xiYou_spineBa.setAnimation(0, "run", true);
- //
- // cc.tween(this.xiYou_mates[3])
- // .to(1, { position: this.mateBaJiePos })
- // .call(() => {
- // //this.xiYou_spineBa.clearTrack(0);
- // //this.xiYou_spineBa.setBonesToSetupPose();
- // this.xiYou_spineBa.setAnimation(0, "walk", true);
- // })
- // .start();
- // this.mateBaIndex++;
- // } else if (this.mateBaIndex == 2) {
- // this.mateBaTimer = 0
- // this.mateBaIndex = 0;
- // }
- // }
- //}
- //
- //if (this.xiYou_mates[1]) {
- // this.mateSunTimer += dt;
- //
- // if (this.mateSunTimer > this.mateSunAniTime[this.mateSunIndex]) {
- // if (this.mateSunIndex == 0) {
- // //this.xiYou_spineSun.clearTrack(0);
- // //this.xiYou_spineSun.setBonesToSetupPose();
- // this.xiYou_spineSun.setAnimation(0, "jump", false);
- // this.mateSunIndex++;
- // } else if (this.mateSunIndex == 1) {
- // //this.xiYou_spineSun.clearTrack(0);
- // //this.xiYou_spineSun.setBonesToSetupPose();
- // this.xiYou_spineSun.setAnimation(0, "idle", true);
- // this.mateSunIndex++;
- // } else if (this.mateSunIndex == 2) {
- // //this.xiYou_spineSun.clearTrack(0);
- // //this.xiYou_spineSun.setBonesToSetupPose();
- // this.xiYou_spineSun.setAnimation(0, "idle_ue", false);
- // this.mateSunIndex++;
- // } else if (this.mateSunIndex == 3) {
- // //this.xiYou_spineSun.clearTrack(0);
- // //this.xiYou_spineSun.setBonesToSetupPose();
- // this.xiYou_spineSun.setAnimation(0, "jump down", false);
- // this.mateSunIndex++;
- // } else if (this.mateSunIndex == 4) {
- // //this.xiYou_spineSun.clearTrack(0);
- // //this.xiYou_spineSun.setBonesToSetupPose();
- // this.xiYou_spineSun.setAnimation(0, "walk", true);
- // this.mateSunTimer = 0;
- // this.mateSunIndex = 0;
- // }
- // }
- //}
- }
- }
- private id = 1;
- private bgIndex = 0;
- UpdateMainBg() {
- let bgCfg = GameM.commonData.mainBgCfg;
- //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel);
- for (let i = 0; i < bgCfg.length; i++) {
- //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel + " CfgLv:" + bgCfg[i].maxLv + " Index:" + i);
- if (GameM.commonData.maxCarLevel <= bgCfg[i].maxLv) {
- this.ChangeBg(bgCfg[i].bgId, cc.color(bgCfg[i].color[0], bgCfg[i].color[1], bgCfg[i].color[2]))
- return;
- }
- }
- let len = bgCfg.length;
- this.ChangeBg(bgCfg[len - 1].bgId, cc.color(bgCfg[len - 1].color[0], bgCfg[len - 1].color[1], bgCfg[len - 1].color[2]));
- }
- /**切换背景*/
- ChangeBgSelf() {
- //this.xiYou_spineBa.clearTrack(0);
- //this.xiYou_spineBa.setBonesToSetupPose();
- //this.xiYou_spineBa.setAnimation(0, "walk", true);
- //this.scheduleOnce(()=>{
- // this.xiYou_spineBa.clearTrack(0);
- // this.xiYou_spineBa.setBonesToSetupPose();
- // this.xiYou_spineBa.setAnimation(0, "fall", false);
- // this.scheduleOnce(()=>{
- // this.xiYou_spineBa.clearTrack(0);
- // this.xiYou_spineBa.setBonesToSetupPose();
- // this.xiYou_spineBa.setAnimation(0, "run", true);
- // },1)
- //},1)
- this.UpdateMainBg();
- //this.id++;
- //this.bgIndex++;
- //if (this.id > 8) this.id = 1;
- //if (this.bgIndex > 7) this.id = 0;
- ////this.id = this.id == 1 ? 2 : 1;
- //this.ChangeBg(this.id,GameM.commonData.mainBgCfg[this.bgIndex]);
- }
- private xiYou_bgColors: cc.Color[] = [
- cc.color(93, 75, 34),
- cc.color(71, 96, 99),
- cc.color(40, 65, 55),
- cc.color(89, 43, 23),
- cc.color(11, 69, 20),
- cc.color(64, 22, 22),
- cc.color(21, 101, 38),
- cc.color(123, 116, 106)
- ]
- /**
- * 更新背景
- * @param bgId 背景id
- */
- ChangeBg(bgId: number, color: cc.Color) {
- cc.loader.loadRes("maps/tucao_bg" + bgId, cc.SpriteFrame, (err, res2) => {
- if (err) {
- console.log("load xiYou bg back err:" + err + " id:" + bgId);
- } else {
- this.xiYou_bg.spriteFrame = res2;
- this.xiYou_bg_bottom.color = color;
- }
- });
- //cc.loader.loadRes("maps/xiyou_bgfront_" + bgId, cc.SpriteFrame, (err, res) => {
- // if (err) {
- // console.log("load xiYou bg err:" + err + " id:" + bgId);
- // } else {
- // cc.loader.loadRes("maps/xiyou_bgback_" + bgId, cc.SpriteFrame, (err, res2) => {
- // if (err) {
- // console.log("load xiYou bg back err:" + err + " id:" + bgId);
- // } else {
- // this.xiYou_bgUp.opacity = 0;
- // for (let i = 0; i < this.xiYou_bgUpImgs.length; i++) {
- // this.xiYou_bgUpImgs[i].spriteFrame = res;
- // }
- // this.xiYou_bgUpBottom.color = color;
- // cc.tween(this.xiYou_bgUp).to(0.7, { opacity: 255 })
- // .call(() => {
- // for (let i = 0; i < this.xiYou_bgImgs.length; i++) {
- // this.xiYou_bgImgs[i].spriteFrame = res;
- // }
- // this.xiYou_bgBottom.color = color;
- // })
- // .start();
- // cc.tween(this.xiYou_bgDown).to(0.7, { opacity: 0 })
- // .call(() => {
- // this.xiYou_bgDown.opacity = 255;
- // })
- // .start();
- //
- //
- // this.xiYou_bgBackUp.opacity = 0;
- // for (let i = 0; i < this.xiYou_bgBackUpImgs.length; i++) {
- // this.xiYou_bgBackUpImgs[i].spriteFrame = res2;
- // }
- // cc.tween(this.xiYou_bgBackUp).to(0.7, { opacity: 255 })
- // .call(() => {
- // for (let i = 0; i < this.xiYou_bgBackImgs.length; i++) {
- // this.xiYou_bgBackImgs[i].spriteFrame = res2;
- // }
- // })
- // .start();
- // cc.tween(this.xiYou_bgBackDown).to(0.7, { opacity: 0 })
- // .call(() => {
- // this.xiYou_bgBackDown.opacity = 255;
- // })
- // .start();
- // }
- // });
- // }
- //});
- }
- private isOpenNormalGuide = true;
- private carSpaceNum = 15;
- /**是否有可合成的武将*/
- private guideHaveCompose = false;
- /**是否有金币*/
- private guideHaveCoin = false;
- /**是否有宝箱*/
- private guideHaveBox = false;
- /**是否有多余空位*/
- private guideHaveEmpty = false;
- /**主界面常规引导*/
- CheckNormalGuide() {
- if (this.isOpenNormalGuide && !GuideMng.Ins.IsGuideing) {
- this.guideHaveCompose = false;
- this.guideHaveCoin = false;
- this.guideHaveBox = false;
- let otherItem: cc.Node = null;
- let other2Item: cc.Node = null;
- let item1: cc.Node = null;
- let item2: cc.Node = null;
- let temp1 = null;
- let temp2 = null;
- let s1: CarSpace = null;
- let s2: CarSpace = null;
- let curMaxlv = 0;
- let curMinlv = 100;
- for (let i = 0; i < this.carSpaceNum; i++) {
- temp1 = this.CarPark.getChildByName(i.toString())
- s1 = temp1.getComponent(CarSpace)
- if (s1.type == 10001) {
- if (!this.guideHaveCoin) {
- this.guideHaveCoin = true;
- otherItem = temp1;
- }
- }
- if (s1.type == 10004) {
- if (!this.guideHaveCoin && !this.guideHaveBox) {
- this.guideHaveBox = true;
- otherItem = temp1;
- }
- }
- if (s1.type > 0 && s1.type < 10000) {
- if (!this.guideHaveCoin && !this.guideHaveBox) {
- if (s1.type > curMaxlv && s1.CheckIsStrike()) {
- curMaxlv = s1.type;
- otherItem = temp1;
- }
- if (s1.type <= curMinlv) {
- curMinlv = s1.type;
- other2Item = temp1;
- }
- }
- }
- if (s1.type > 10000 || s1.type == 0) {
- continue
- }
- item1 = temp1;
- for (var j = i + 1; j < this.carSpaceNum; j++) {
- temp2 = this.CarPark.getChildByName(j.toString())
- s2 = temp2.getComponent(CarSpace)
- if (s1.type == s2.type) {
- item2 = temp2
- this.guideHaveCompose = true;
- break
- }
- }
- if (this.guideHaveCompose) {
- break
- }
- }
- if (this.guideHaveCompose) {
- if (item1 == null || item2 == null) return;
- this.xiyou_guide_click.active = false;
- this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1));
- this.xiyou_guide_drag.active = true;
- this.xiyou_guide_drag.stopAllActions();
- let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(item2));
- let f2 = cc.delayTime(0.5);
- let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1)) });
- let f = cc.sequence(f1, f2, f3).repeatForever();
- this.xiyou_guide_drag.runAction(f);
- } else {
- if (this.guideHaveCoin) {
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
- this.xiyou_guide_click.active = true;
- } else {
- if (this.guideHaveBox) {
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
- this.xiyou_guide_click.active = true;
- } else {
- //判断是否有多余空位
- if (this.IsHaveEmptySpace()) {
- let nextPrice = GameM.commonData.getPriceByType(this.curBuyType);
- let need = Sciencen_M.instance.subtraction(nextPrice, GameM.commonData.gold)
- if (need[0] == '-') {
- //今日视频次数没达到上限
- if (GameM.commonData.dayBuyCarVideoLimitTimes > 0) {
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy));
- this.xiyou_guide_click.active = true;
- }
- else {
- //引导点击未罢工的最高级武将
- if (curMaxlv != 0) {
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
- this.xiyou_guide_click.active = true;
- } else {
- this.xiyou_guide_drag.stopAllActions();
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.active = false;
- }
- }
- } else {
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy));
- this.xiyou_guide_click.active = true;
- }
- } else {
- //无多余空位
- if (curMinlv != 100) {
- this.xiyou_guide_click.active = false;
- this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item));
- this.xiyou_guide_drag.active = true;
- this.xiyou_guide_drag.stopAllActions();
- let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(this.btnBuy));
- let f2 = cc.delayTime(0.5);
- let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item)) });
- let f = cc.sequence(f1, f2, f3).repeatForever();
- this.xiyou_guide_drag.runAction(f);
- } else {
- this.xiyou_guide_drag.stopAllActions();
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.active = false;
- }
- }
- }
- }
- }
- } else {
- this.xiyou_guide_drag.stopAllActions();
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.active = false;
- }
- }
- /**
- * 改变常规引导状态
- * @param state 状态 1 开启 0 关闭
- */
- ChangeNormalGuideState(state: number) {
- if (state == 1) {
- this.isOpenNormalGuide = true;
- } else {
- this.isOpenNormalGuide = false;
- this.xiyou_guide_drag.stopAllActions();
- this.xiyou_guide_drag.active = false;
- this.xiyou_guide_click.active = false;
- }
- }
- /** 检查显示彩蛋返回
- * @param type 彩蛋类型 1 投放彩蛋 2 常规彩蛋 3 裂变彩蛋
- */
- showCaidan(type) {
- this.caidanBtn.node.y = 202.2
- this.caidanBtn.node.active = true
- this.spCaidan.node.active = false
- this.newdan1.active = true
- if (type != 1) {
- this.labCaidanCount.node.parent.active = false
- }
- }
- /** 点击彩蛋 */
- clickCaidan() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- AdM.onSendEvent('button_5', '彩蛋icon', 'button')
- if (UsualCaidanData.Instance.userUsualEggInfo.isTodayFinished == 1) {
- if (GameM.commonData.roleData.canDailyCash == 1) {
- EffectNode.instance.PlayTip('今日已经领取三个彩蛋奖励了,请明天再来')
- }
- else {
- EffectNode.instance.PlayTip('每日提现后开启!')
- }
- }
- else {
- if (UsualCaidanData.Instance.userUsualEggInfo.isEnd == 0) {
- this.caidanHand.active = false
- UiM.Instance.onPanel(PANEL_NAME.UsualCaidanNode, false, () => {
- UiM.Instance.usualCaidanNode.getComponent(UsualCaidanNode).init()
- })
- }
- }
- }
- /** 彩蛋飞走 */
- caidanFlyAway() {
- cc.tween(this.caidanBtn.node)
- .to(1, { y: 1000 })
- .call(() => {
- this.caidanBtn.node.active = false
- LogUtil.logV('UsualCaidan ', "彩蛋消失4 ")
- })
- .start()
- }
- /** 获取彩蛋效果 */
- caiDanEff() {
- this.caidanBtn.node.active = true
- this.labCaidanCount.node.parent.active = false
- this.spCaidan.node.active = true
- this.newdan1.active = false
- this.spCaidan.node.scale = 1
- let parPos = this.caidanBtn.node.position
- this.spCaidan.node.setPosition(-parPos.x, -parPos.y + 110)
- cc.tween(this.spCaidan.node)
- .to(1, { position: cc.v2(0, 18), scale: 0.5 })
- .call(() => {
- // if (CaiDanData.Instance.leftTime > 0) {
- // this.labCaidanCount.node.parent.active = true
- // }
- // else {
- // this.labCaidanCount.node.parent.active = false
- // }
- this.labCaidanCount.node.parent.active = false
- this.spCaidan.node.active = false
- this.newdan1.active = true
- })
- .start()
- }
- // caiDanCount() {
- // CaiDanData.Instance.leftTime--
- // this.labCaidanCount.string = utils.ParseTime2Format(CaiDanData.Instance.leftTime)
- // if (CaiDanData.Instance.leftTime <= 0) {
- // this.caidanBtn.node.active = false
- // this.unschedule(this.caiDanCount)
- // }
- // }
- //财神降临
- TimerWealthCooling() {
- if (WealthData.Ins.wealthInfo != null) {
- if (WealthData.Ins.wealthInfo.wealthGodStatus == 1) {
- if (WealthData.Ins.coolingTimer > 0) {
- this.txt_wealthCoolTimer.string = MyExtends.TimeToFormat(WealthData.Ins.coolingTimer, 3);
- }
- else {
- this.txt_wealthCoolTimer.string = ""
- }
- }
- else {
- this.txt_wealthCoolTimer.string = ""
- }
- }
- else {
- this.txt_wealthCoolTimer.string = ""
- }
- }
- RichManInit() {
- this.richmanBtn.active = RichData.Ins.richCfg.richmanopen == 1;
- this.UpdateRichManQipao();
- }
- UpdateRichManQipao() {
- this.richBtnQipao.active = RichData.Ins.diceTotalNum > 0;
- this.richQipaoTxt.string = RichData.Ins.diceTotalNum + "";
- }
- isgamepause: boolean = false;
- onKeyDown(event: cc.Event.EventKeyboard) {
- switch (event.keyCode) {
- case cc.macro.KEY.space:
- if (this.isgamepause) {
- cc.game.resume();
- this.isgamepause = false;
- } else {
- cc.game.pause();
- this.isgamepause = true;
- }
- break;
- }
- }
- setGuideInstallVisible(active) {
- this.guideInstallBtn.node.active = active
- }
- /** 打开引导安装 */
- clickGuideInstall() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- AdM.onSendEvent('button_19', '宝葫芦icon点击', 'button')
- UiM.Instance.onPanel(PANEL_NAME.GuideInstallApkNode)
- }
- /** 检查是否显示宝葫芦 */
- checkShowGuideInstall() {
- if (DownloadApkData.Instance.installSwitch && GameM.commonData.isAuth) {
- AdM.checkPathApk()
- //定时检查是否有新安装包
- this.schedule(() => {
- if (!this.guideInstallBtn.node.active) {
- AdM.checkPathApk()
- }
- }, 60)
- }
- }
- /**
- * 检查是否有礼包兑换
- */
- CheckRedeem() {
- HttpM.Instance.SendData(HTTP_TYPE.redeemGetRedemption, {}, (res) => {
- console.log("--->RedeemGift:", res);
- if (res.data != null && res.errcode == 0) {
- GameM.commonData.redeemData = res.data;
- this.redeemBtn.active = res.data.code == 1;
- }
- });
- }
- Click_RedeemBtn() {
- UiM.Instance.onPanel(PANEL_NAME.RedeemNode);
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- AdM.onSendEvent('button_20', '兑换码icon点击', 'button')
- }
- CheckAdRb() {
- this.adRbBtn.active = GameM.commonData.globalCfg.VideoRedBagOpen == 1;
- }
- /** 设置更多游戏图片 */
- setMoreGameSp(arr) {
- let len = arr.length
- let index = Utils.rnd(0, len - 1)
- let data = arr[index]
- this.showMoreGameSp(data)
- this.schedule(() => {
- index++
- index = (index % len)
- LogUtil.logV('setMoreGameSp ', 'index ' + index)
- data = arr[index]
- this.showMoreGameSp(data)
- }, 10)
- }
- showMoreGameSp(data) {
- cc.loader.load(data.icon, (err, res) => {
- if (err) {
- console.log('err:', err);
- return;
- }
- if (this.spMoregame) {
- let tex: cc.Texture2D = res as cc.Texture2D;
- this.spMoregame.spriteFrame = new cc.SpriteFrame(tex);
- }
- })
- this.labMoregame.string = data.title
- }
- /** 是否显示常规提现、每日提现、钱庄按钮 */
- checkShowCashBtns() {
- if (GameM.commonData.loginDays == 1 || (CashOutData.Instance.cashStatus.length + DailyCashData.Instance.dailyCashStatus.length) <= 0) {
- }
- else {
- if (GameM.commonData.cashStateBtnsArr[0] == '1') {
- this.tixianProBtn.node.active = true
- }
- else {
- this.tixianProBtn.node.active = false
- }
- if (GameM.commonData.cashStateBtnsArr[1] == '1') {
- this.dailyCashBtn.node.active = true
- }
- else {
- this.dailyCashBtn.node.active = false
- }
- if (GameM.commonData.cashStateBtnsArr[2] == '1') {
- this.bankBtn.node.active = true
- }
- else {
- this.bankBtn.node.active = false
- }
- }
- }
- }
|