Main.ts 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884
  1. import GameM, { VIDEO_TYPE, AUDIO_TYPE, Game_Quality } from "./manager/GameM";
  2. import CarSpace from "./prefabs/CarSpace";
  3. import CarMove from "./prefabs/CarMove";
  4. import CarInfo from "./prefabs/CarInfo";
  5. import UiM, { PANEL_NAME } from "./manager/UiM";
  6. import GlobalStorage, { STORAGE_KEY } from "./datas/GlobalStorage";
  7. import Shop from "./ui/Shop";
  8. import Gift from "./ui/Gift";
  9. import RedPointM, { RedPointType } from "./manager/RedPointM";
  10. import Task from "./ui/Task";
  11. import AdM from "./manager/AdM";
  12. import PoolMgr, { NODEPOOLPREFABTYPE } from "./manager/PoolMgr";
  13. import EffectNode from "./ui/EffectNode";
  14. import Sciencen_M from "./utils/Sciencen_M";
  15. import BuyProAdd from "./prefabs/BuyProAdd";
  16. import Daily from "./ui/Daily";
  17. import DailyCashProAdd from "./prefabs/DailyCashProAdd";
  18. import GuideManager from "./manager/GuideManager";
  19. import LogUtil from "./utils/LogUtil";
  20. import BankQipaoTip from "./ui/BankQipaoTip";
  21. import LocalManagerData from "./datas/LocalManagerData";
  22. import Spray from "./prefabs/Spray";
  23. import EachNodeAnim from "./ui/EachNodeAnim";
  24. import TreasureData from "./datas/TreasureData";
  25. import TurntableData from "./datas/TurntableData";
  26. import CashOutData from "./datas/CashOutData";
  27. import UIMng, { PanelType } from "./uiFrames/UIMng";
  28. import { Role } from "./other/item/Role";
  29. import { FightData } from "./datas/FightData";
  30. import { MateData } from "./datas/MateData";
  31. import MoreGameData from "./datas/MoreGameData";
  32. import { Utils } from "./utils/Utils";
  33. import { HTTP_TYPE, MONEY_TYPE, RecordTYPE } from "./datas/CommonData";
  34. import UsualCaidanData from "./datas/UsualCaidanData";
  35. import GuideMng from "./manager/GuideMng";
  36. import DailyCashData from "./datas/DailyCashData";
  37. import { GameController } from "./manager/GameController";
  38. import { thirdVideoTS } from "./manager/topon/AnyThinkAdsMgr/thirdVideoTS";
  39. import UsualCaidanNode from "./ui/UsualCaidanNode";
  40. import NativeAdAwardData from "./manager/NativeAdAwardData";
  41. import MyExtends from "./tools/MyExtends";
  42. import ClubData from "./datas/ClubData";
  43. import DailyData from "./datas/DailyData";
  44. import HttpM from "./manager/HttpM";
  45. import InvestData from "./datas/InvestData";
  46. import WealthMng from "./manager/WealthMng";
  47. import { WealthData } from "./datas/WealthData";
  48. import Random from "./utils/Random";
  49. import { RichData } from "./datas/RichData";
  50. import DownloadApkData from "./datas/DownloadApkData";
  51. import SwitchM from "./manager/SwitchM";
  52. const { ccclass, property } = cc._decorator;
  53. @ccclass
  54. export default class Main extends cc.Component {
  55. @property(cc.Node)
  56. topPart: cc.Node = null
  57. @property(cc.Node)
  58. centerPart: cc.Node = null
  59. @property(cc.Sprite)
  60. head: cc.Sprite = null
  61. @property(cc.Label)
  62. labGold: cc.Label = null
  63. @property(cc.Label)
  64. labGoldSecond: cc.Label = null
  65. @property(cc.Node)
  66. CarPark: cc.Node = null
  67. @property(cc.Node)
  68. btnBuy: cc.Node = null
  69. @property(cc.Node)
  70. posBtnBuy: cc.Node = null
  71. @property(cc.Label)
  72. labLevel: cc.Label = null
  73. @property(cc.Label)
  74. labMoney: cc.Label = null
  75. @property(cc.Sprite)
  76. expFill: cc.Sprite = null
  77. @property(sp.Skeleton)
  78. composeAni: sp.Skeleton = null
  79. @property(cc.Animation)
  80. cicleFade: cc.Animation = null
  81. @property(cc.Node)
  82. hand: cc.Node = null
  83. @property(cc.Node)
  84. buyHand: cc.Node = null
  85. @property(cc.Animation)
  86. airshipAni: cc.Animation = null
  87. @property(cc.Animation)
  88. airshipHandAni: cc.Animation = null
  89. @property(cc.Button)
  90. chatBtn: cc.Button = null;
  91. @property(cc.Button)
  92. cashBtn: cc.Button = null;
  93. @property(cc.Node)
  94. redeemBtn: cc.Node = null;
  95. //看视频领红包
  96. @property(cc.Node)
  97. adRbBtn: cc.Node = null;
  98. //模块按钮
  99. @property(cc.Button)
  100. shopBtn: cc.Button = null;
  101. @property(cc.Button)
  102. taskBtn: cc.Button = null;
  103. @property(cc.Button)
  104. turntableBtn: cc.Button = null;
  105. @property(cc.Button)
  106. investBtn: cc.Button = null;
  107. @property(cc.Button)
  108. dailyCashBtn: cc.Button = null;
  109. @property(cc.Button)
  110. dailyBtn: cc.Button = null;
  111. @property(cc.Button)
  112. tixianProBtn: cc.Button = null;
  113. @property(cc.Node)
  114. wealthBtn: cc.Node = null;
  115. @property(cc.Node)
  116. richmanBtn: cc.Node = null;
  117. @property(cc.Button)
  118. treasureBtn: cc.Button = null;
  119. @property(cc.Button)
  120. bankBtn: cc.Button = null;
  121. @property(cc.Button)
  122. moreGameBtn: cc.Button = null;
  123. @property(cc.Button)
  124. shareBtn: cc.Button = null;
  125. //彩蛋按钮
  126. @property(cc.Button)
  127. caidanBtn: cc.Button = null;
  128. @property(cc.Button)
  129. guideInstallBtn: cc.Button = null;
  130. @property(cc.Node)
  131. caidanHand: cc.Node = null;
  132. @property(cc.Node)
  133. cashHand: cc.Node = null
  134. @property(cc.Node)
  135. tipPos: cc.Node = null
  136. @property(cc.Node)
  137. canGet: cc.Node = null
  138. @property(cc.Sprite)
  139. tixianPro: cc.Sprite = null
  140. @property(cc.Label)
  141. labTixian: cc.Label = null
  142. @property(cc.Label)
  143. labTixianLv: cc.Label = null
  144. @property(cc.Label)
  145. labtargetCarLevel: cc.Label = null;
  146. @property(cc.Sprite)
  147. spTixianCar: cc.Sprite = null
  148. @property(cc.Sprite)
  149. carProSp: cc.Sprite = null;
  150. @property(cc.Node)
  151. approachEff: cc.Node = null
  152. @property(cc.Animation)
  153. hallLabAddEff: cc.Animation = null;
  154. @property(cc.Sprite)
  155. tixianFill: cc.Sprite = null;
  156. @property(cc.Label)
  157. tixianPercent: cc.Label = null
  158. @property(cc.Node)
  159. bankQipaoNode: cc.Node = null;
  160. @property(cc.Label)
  161. labTixianPro: cc.Label = null;
  162. @property(cc.Node)
  163. labWuFuNode: cc.Node = null;
  164. @property(BankQipaoTip)
  165. BankQipaoTip: BankQipaoTip = null;
  166. //常规彩蛋
  167. @property(cc.Sprite)
  168. spCaidan: cc.Sprite = null;
  169. @property(cc.Node)
  170. newdan1: cc.Node = null;
  171. @property(cc.Label)
  172. labCaidanCount: cc.Label = null;
  173. @property(cc.Prefab)
  174. private pfb_Guide: cc.Prefab = null;
  175. //西游
  176. @property(cc.Node)
  177. private xiYou_mates: cc.Node[] = [];
  178. //@property(sp.Skeleton)
  179. //private xiYou_spineSun: sp.Skeleton = null;
  180. //@property(sp.Skeleton)
  181. //private xiYou_spineBa: sp.Skeleton = null;
  182. @property(cc.Node)
  183. private xiYou_bgback: cc.Node = null;
  184. @property(cc.Sprite)
  185. private xiYou_bg: cc.Sprite = null;
  186. @property(cc.Node)
  187. private xiYou_bg_bottom: cc.Node = null;
  188. @property(cc.Node)
  189. private xiYou_talentParent: cc.Node = null;
  190. @property(cc.Prefab)
  191. private xiYouPfb_telentItem: cc.Prefab = null;
  192. @property(cc.Label)
  193. private txt_buyBtn: cc.Label = null;
  194. @property(cc.Node)
  195. private xiyou_guide_click: cc.Node = null;
  196. @property(cc.Node)
  197. private xiyou_guide_drag: cc.Node = null;
  198. private txt_wealthCoolTimer: cc.Label = null;
  199. @property(cc.Sprite)
  200. private spMoregame: cc.Sprite = null
  201. @property(cc.Label)
  202. private labMoregame: cc.Label = null
  203. private richBtnQipao: cc.Node = null;
  204. private richQipaoTxt: cc.Label = null;
  205. curCashCfg = null
  206. facLock: cc.Node = null
  207. carP: cc.Node
  208. carSpaceP: cc.Node
  209. index_s: number = 0
  210. carSpaceArr = []
  211. //offPos: cc.Vec2 = cc.v2(375, 627)
  212. offPos: cc.Vec2 = cc.v2(375, 667) //根据不同设备适配
  213. P1: cc.Node = null
  214. P2: cc.Node = null
  215. hasHand = false
  216. handTween = null
  217. /** 舞台宽高 */
  218. sW: number = 0
  219. sH: number = 0
  220. /** 当前买车类型 */
  221. curBuyType: number = 0
  222. //帧频采样数组
  223. startGetFrameTime = false
  224. frameTotal = 0
  225. frameTimeTotal = 0
  226. frameAdd = 0
  227. testFrames = 60
  228. averageTime = 0
  229. /** 放弃飞艇飞走中 */
  230. airshipUp = false
  231. /** 每日提现当前配置 */
  232. dailyCash = null
  233. //西游
  234. /**车位尺寸*/
  235. //carParkSize:cc.Vec2=cc.v2(138,138);
  236. //carParkSize: cc.Vec2 = cc.v2(100, 100);
  237. carParkSize: cc.Vec2 = cc.v2(141, 141);
  238. /**移动或合成最终y轴偏移量 标准分辨率为-303*/
  239. moveEndY: number = -303;
  240. /**CarPark下边离屏幕下边距离*/
  241. parkBottom: number = 152.50;// 189;// 162;
  242. //parkBottom: number = 230;
  243. /**park layout spacing x*/
  244. parkSpaceX: number = 8;//25;
  245. /**park layout spacing y*/
  246. parkSpaceY: number = 25;//70;// 40;
  247. /**点击时间戳 在此时间内的点击算单击车位 否为算拖拽*/
  248. dragTime: number = 0.2;
  249. /**点击计时器*/
  250. dragTimer: number = 0;
  251. onLoad() {
  252. //AdM.onSendEvent('loadEnd', '加载结束', 'load');
  253. cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
  254. }
  255. async start() {
  256. if (!GameM.commonData.redSwitch) {
  257. cc.find('Canvas/HallNode/topPart/btnFight').active = false
  258. cc.find('Canvas/HallNode/centorPart/btnTask').active = false
  259. cc.find('Canvas/HallNode/downPart/btnInvestment').active = false
  260. cc.find('Canvas/HallNode/downPart/btnMate').active = false
  261. }
  262. this.composeRectNode = cc.find("Canvas/HallNode/ComposeRect");
  263. this.txt_wealthCoolTimer = this.wealthBtn.getChildByName('normal').getChildByName('txtcooling').getComponent(cc.Label);
  264. this.richBtnQipao = this.richmanBtn.getChildByName('normal').getChildByName('qipao');
  265. this.richQipaoTxt = this.richBtnQipao.getComponentInChildren(cc.Label);
  266. //this.txt_wealthCoolTimer=this.wealthBtn.getChildByName('normal').getChildByName('labLock').getComponent(cc.Label);
  267. cc.game.addPersistRootNode(this.node)
  268. GameM.commonData.updateGold('0')
  269. TurntableData.Instance.updateResetTurntable()
  270. //各模块是否解锁
  271. this.checkModelBtnsUnlock();
  272. this.addParkCar()
  273. this.carBuyInfo()
  274. this.updateBuyBtnState();
  275. this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
  276. this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) //西游
  277. this.sW = cc.winSize.width
  278. this.sH = cc.winSize.height
  279. this.offPos = cc.v2(375, this.sH / 2);
  280. //西游
  281. let temppy = this.parkBottom + this.CarPark.height / 2;
  282. this.moveEndY = -((temppy <= this.sH / 2 ? this.sH / 2 - temppy : temppy - this.sH / 2) + 86.9);
  283. //this.moveEndY = -(86.9 + Math.abs(this.CarPark.y));
  284. //console.log("----->" + this.moveEndY + " temppy:" + temppy + "PY:" + (temppy <= this.sH ? this.sH - temppy : temppy - this.sH));
  285. if (this.sH > 1500) {
  286. this.topPart.y += 90
  287. }
  288. this.delayAddGift()
  289. this.startAddTimer()
  290. this.schedule(this.storeGameTime, 10)
  291. this.storeGameTime()
  292. GameM.commonData.updateRoleDataExp('0')
  293. // let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2))
  294. // if (percent >= 1) {
  295. // let videoSpan = 15
  296. // this.schedule(this.checkPopVideo, videoSpan)
  297. // }
  298. UiM.Instance.taskNode.getComponent(Task).init()
  299. this.setGuideInstallVisible(false)
  300. this.setImg()
  301. if (GameM.commonData.redSwitch) {
  302. this.labMoney.string = `${Math.floor(GameM.commonData.redMoney)} ≈ ${(GameM.commonData.redMoney * 0.0001).toFixed(3)}元`
  303. }
  304. else {
  305. this.labMoney.string = `${GameM.commonData.redMoney}`
  306. }
  307. this.checkShowAirship()
  308. GameM.httpM.sendDatas(HTTP_TYPE.getRedMoneyRecord, null, GameM.commonData.resultRedMoneyRecord.bind(GameM.commonData))
  309. GameM.audioM.init()
  310. this.checkNewUser()
  311. this.scheduleOnce(() => {
  312. this.checkOfflineAward()
  313. }, 0.5)
  314. this.chatBtn.node.active = GameM.commonData.redSwitch
  315. //西游
  316. //this.cashBtn.node.active = GameM.commonData.redSwitch
  317. this.dailyBtn.node.active = GameM.commonData.redSwitch
  318. this.dailyCashBtn.node.active = GameM.commonData.redSwitch
  319. this.bankBtn.node.active = GameM.commonData.redSwitch
  320. this.treasureBtn.node.active = GameM.commonData.redSwitch
  321. this.tixianProBtn.node.active = GameM.commonData.redSwitch
  322. this.shareBtn.node.active = false // GameM.commonData.redSwitch
  323. this.freshDailyRed()
  324. GameM.commonData.quality = Game_Quality.mediumHigh
  325. this.checkTixianPro(true)
  326. TreasureData.Instance.getLuckydrawConfig()
  327. let loadEnd = GameM.globalStorage.getStorage(STORAGE_KEY.firstLoadEnd)
  328. if (loadEnd == null) {
  329. loadEnd = 1
  330. GameM.globalStorage.setStorage(STORAGE_KEY.firstLoadEnd, loadEnd)
  331. AdM.onSendEvent('firstLoadEnd', '第一次加载结束')
  332. }
  333. AdM.onSendEvent('loadEnd', '加载结束进入主场景', 'load')
  334. if (SwitchM.firstLoginLog) {
  335. AdM.sendUmeng('umLoadEnd', '加载结束')
  336. }
  337. SwitchM.firstLoginLog = false
  338. //检查授权
  339. //注释掉 还原为一上线就授权
  340. // AdM.checkPermission()
  341. let can = GameM.commonData.checkCanShowSplash()
  342. if (can) {
  343. AdM.showSplash()
  344. }
  345. this.checkCanVideo()
  346. GameM.commonData.checkShowFull()
  347. if (GameM.commonData.maxCarLevel >= GameM.commonData.richBankUnLockLevel && GameM.commonData.isopenrichbank == 0) {
  348. GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank)
  349. GameM.commonData.isopenrichbank = 1
  350. }
  351. //UIMng.Ins.GetPanel(PanelType.TestPanel).OnEnter();
  352. // this.caidanBtn.node.active = false
  353. UsualCaidanData.Instance.getUsualEggData(false)
  354. // //test
  355. // this.caidanBtn.node.active = true
  356. this.freshDailyPro()
  357. //每日登录奖励红点
  358. DailyData.Instance.checkHasGet()
  359. MateData.Ins.checkMateRedPoint()
  360. //西游
  361. this.DisplayMate();
  362. MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem);
  363. MoreGameData.Instance.sendRecommendList();
  364. this.UpdateMainBg();
  365. //首次新手引导
  366. GuideMng.Ins.CheckGuide1();
  367. //西游测试
  368. this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal;
  369. //常规引导
  370. this.schedule(this.CheckNormalGuide, 5);
  371. if (GameM.commonData.IsTest) {
  372. this.scheduleOnce(() => {
  373. GameM.commonData.updateGold("999999999999999999999999");
  374. GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold });
  375. }, 3);
  376. }
  377. //请求工会数据 用于埋点
  378. ClubData.Instance.requestClubMyRecruitMembers()
  379. //初始化天降财神
  380. let wealth = cc.instantiate(await Utils.loadResPromise("prefabs/GameWealth"));
  381. wealth.parent = this.node.parent;
  382. wealth.setSiblingIndex(this.node.getSiblingIndex() + 1);
  383. //大富翁
  384. this.RichManInit();
  385. //this.UpdateRichManQipao();
  386. //礼包兑换
  387. this.CheckRedeem();
  388. //看视频领红包
  389. this.CheckAdRb();
  390. this.checkShowCashBtns();
  391. }
  392. freshDailyPro() {
  393. if (GameM.commonData.roleData.dailyCashAniPlayed == 1) {
  394. if (DailyCashData.Instance.userDailyCashInfo) {
  395. this.labTixianPro.node.active = true
  396. // this.dailyCash = DailyCashData.Instance.getTodayDailyCash()
  397. this.dailyCash = DailyCashData.Instance.userDailyCashInfo
  398. this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime
  399. this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
  400. this.labWuFuNode.active = false
  401. }
  402. else {
  403. DailyCashData.Instance.getDailyCashBuyTime()
  404. }
  405. }
  406. else {
  407. this.labTixianPro.node.active = false
  408. this.labWuFuNode.active = true
  409. }
  410. }
  411. /**更新金币*/
  412. UpdateCoinTxt(num: string) {
  413. this.labGold.string = num;
  414. cc.Tween.stopAllByTarget(this.labGold.node);
  415. cc.tween(this.labGold.node)
  416. .to(0.15, { scale: 1.2 })
  417. .to(0.15, { scale: 1 })
  418. .start();
  419. }
  420. /**获取引导物体*/
  421. GetGuide() {
  422. return cc.instantiate(this.pfb_Guide);
  423. }
  424. update(dt) {
  425. this.frameTotal++
  426. if (this.frameTotal == 600) {
  427. this.startGetFrameTime = true
  428. this.frameTimeTotal = 0
  429. this.frameAdd = 0
  430. }
  431. if (this.startGetFrameTime) {
  432. this.frameAdd++
  433. if (this.frameAdd <= this.testFrames) {
  434. this.frameTimeTotal += dt
  435. if (this.frameAdd == this.testFrames) {
  436. this.averageTime = this.frameTimeTotal / this.testFrames
  437. this.frameTotal = 0
  438. this.startGetFrameTime = false
  439. if (this.averageTime > 0.0222222) {
  440. if (GameM.commonData.quality > Game_Quality.low) {
  441. GameM.commonData.quality--
  442. }
  443. }
  444. else {
  445. if (GameM.commonData.quality < Game_Quality.high) {
  446. GameM.commonData.quality++
  447. }
  448. }
  449. }
  450. }
  451. }
  452. this.MoveBg(dt);
  453. this.TimerWealthCooling();
  454. }
  455. freshDailyRed() {
  456. RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, true)
  457. // let len = GameM.commonData.dailyCfg.length
  458. // let red = false
  459. // let data = null
  460. // for (var i = 0; i < len; i++) {
  461. // data = GameM.commonData.dailyCfg[i]
  462. // if (GameM.commonData.dailyGetArr[i] == '0') {
  463. // if (GameM.commonData.loginDays >= data.getDay) {
  464. // if (data.conditionType == 1) {
  465. // red = true
  466. // break
  467. // }
  468. // if (data.conditionType == 2) {
  469. // if (GameM.commonData.maxCarLevel >= data.conditionLv) {
  470. // red = true
  471. // break
  472. // }
  473. // }
  474. // else if (data.conditionType == 3) {
  475. // if (GameM.commonData.roleData.lv >= data.conditionLv) {
  476. // red = true
  477. // break
  478. // }
  479. // }
  480. // }
  481. // }
  482. // }
  483. // RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, red)
  484. }
  485. /** 显示提现引导 */
  486. showCashHand() {
  487. this.cashHand.active = true
  488. }
  489. hideCashHand() {
  490. this.cashHand.active = false
  491. }
  492. /** 是否是新用户 */
  493. checkNewUser() {
  494. if (GameM.commonData.redSwitch) {
  495. if (GameM.commonData.roleData.newuser < 2) {
  496. if (GameM.commonData.roleData.newuser == 0) {
  497. this.scheduleOnce(() => {
  498. //先创建全屏的秘书引导,再进行之前的引导
  499. GuideManager.Instance.createFullGuide(this.node, 1, () => {
  500. this.checkNewUser()
  501. })
  502. //GuideMng.Ins.CheckGuide1();
  503. }, 1)
  504. }
  505. else {
  506. this.scheduleOnce(() => {
  507. //先创建全屏的秘书引导,再进行之前的引导
  508. GuideManager.Instance.createFullGuide(this.node, 4, () => {
  509. if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) {
  510. this.buyHand.active = false
  511. // UiM.Instance.guideNode.getComponent(Guide).showStep()
  512. }
  513. })
  514. }, 0.1)
  515. }
  516. }
  517. else {
  518. this.scheduleOnce(() => {
  519. if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) {
  520. this.buyHand.active = false
  521. // UiM.Instance.guideNode.getComponent(Guide).showStep()
  522. }
  523. }, 0.1)
  524. }
  525. }
  526. }
  527. /** 第二天登录,满足条件弹出 */
  528. checkPopSecretary() {
  529. this.scheduleOnce(() => {
  530. if (GameM.commonData.loginDays >= 2) {
  531. if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 0) {
  532. UiM.Instance.redPackageNode.init(0, 0, 4, null, true)
  533. UiM.Instance.redPackageNode.node.x = 0
  534. UiM.Instance.redPackageNode.node.active = true
  535. //西游
  536. if (!RichData.Ins.isOpenRichPanel) {
  537. GameM.audioM.setPauseMusic();
  538. GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm);
  539. }
  540. }
  541. else {
  542. this.checkShowClubGuideNode()
  543. // if (GameM.commonData.roleData.ifGuideSecrtary) {
  544. // GameM.commonData.checkDaysPieceUnlock()
  545. // }
  546. }
  547. } else {
  548. }
  549. }, 2)
  550. }
  551. //弹出俱乐部海报
  552. checkShowClubGuideNode() {
  553. //吐槽 不弹出 裂变海报
  554. return;
  555. let showClubGirl = GameM.globalStorage.getStorage(STORAGE_KEY.showClubGirl)
  556. if (showClubGirl > 0) {
  557. GameM.globalStorage.setStorage(STORAGE_KEY.showClubGirl, 0)
  558. UiM.Instance.onPanel(PANEL_NAME.clubGuideNode)
  559. }
  560. }
  561. showDialyPanel(force = false) {
  562. if (GameM.commonData.redSwitch) {
  563. if (force) {
  564. //console.log("-------------------1")
  565. UiM.Instance.onPanel(PANEL_NAME.DailyNode)
  566. }
  567. else {
  568. if (!UiM.Instance.dailyNode && GameM.commonData.maxCarLevel >= 10) {
  569. //console.log("-------------------2")
  570. UiM.Instance.onPanel(PANEL_NAME.DailyNode)
  571. }
  572. }
  573. }
  574. }
  575. setImg() {
  576. let self = this
  577. if (GameM.commonData.headimgurl != '') {
  578. cc.loader.load(GameM.commonData.headimgurl + "?aaa=aa.jpg", (err, res) => {
  579. if (err) {
  580. console.log('err:', err);
  581. return;
  582. }
  583. if (self.head) {
  584. let tex: cc.Texture2D = res as cc.Texture2D;
  585. self.head.spriteFrame = new cc.SpriteFrame(tex);
  586. }
  587. })
  588. }
  589. this.checkShowGuideInstall()
  590. }
  591. /**检查各模块是否解锁*/
  592. checkModelBtnsUnlock() {
  593. if (GameM.commonData.maxCarLvCanBuy >= GameM.commonData.curVideoCarType) {
  594. RedPointM.instance.ActiveRedPoint(RedPointType.Shop, true)
  595. }
  596. else {
  597. RedPointM.instance.ActiveRedPoint(RedPointType.Shop, false)
  598. }
  599. this.checkTaskRed()
  600. this.checkTurntableRed()
  601. let isUnlockInvest = GameM.commonData.maxCarLevel >= GameM.commonData.investOpenLevel ? true : false
  602. if (isUnlockInvest) {
  603. InvestData.Instance.getInvestInfo()
  604. }
  605. RedPointM.instance.UpdateRedPointState();
  606. //提现
  607. //this.unLockBtn(this.tixianProBtn, GameM.commonData.cashOpenLevel)
  608. //每日提现
  609. this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel)
  610. //投资引导
  611. //this.checkMateLockBtn(3, GameM.commonData.investOpenLevel)
  612. this.unLockBtn(this.investBtn, GameM.commonData.investOpenLevel)
  613. //转盘
  614. this.unLockBtn(this.turntableBtn, GameM.commonData.turntableOpenLevel)
  615. //小秘书
  616. // this.unLockBtn(this.secretaryBtn, 9)
  617. //登录豪礼
  618. this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel)
  619. //现金夺宝
  620. this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel)
  621. // //银行富翁 改为判断4号伙伴
  622. // this.checkMateLockBtn(4, GameM.commonData.richBankUnLockLevel)
  623. //银行富翁
  624. this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel)
  625. //每日任务
  626. this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel)
  627. //财神降临
  628. this.unLockBtn(this.wealthBtn.getComponent(cc.Button), GameM.commonData.unlockWealthLevel)
  629. }
  630. /** 检查任务红点 */
  631. checkTaskRed() {
  632. if (GameM.commonData.dailyTaskRedNum > 0) {
  633. RedPointM.instance.ActiveRedPoint(RedPointType.Task, true)
  634. }
  635. else {
  636. RedPointM.instance.ActiveRedPoint(RedPointType.Task, false)
  637. }
  638. if (UiM.Instance.taskNode) {
  639. UiM.Instance.taskNode.getComponent(Task).freshRed()
  640. }
  641. }
  642. /** 是否显示飞艇 */
  643. checkShowAirship() {
  644. if (GameM.commonData.step > 3) {
  645. this.airshipAni.node.active = false
  646. if (this.airshipHandAni.node.active) {
  647. this.airshipHandAni.node.active = false;
  648. }
  649. if (GameM.commonData.airshipTimes < 10) {
  650. let delayTime = 90
  651. this.scheduleOnce(this.showAirship, delayTime)
  652. NativeAdAwardData.Instance.resetGetAward(2)
  653. // this.schedule(this.getAirByRan, 90)
  654. }
  655. }
  656. }
  657. curAirCfg = null
  658. getAirByRan() {
  659. LogUtil.logV("getAirByRan", "start")
  660. if (GameM.commonData.airshipTimes < 10) {
  661. let tempCfg = GameM.commonData.airshipCfg
  662. let airCfg = new Array<any>()
  663. let range = 0
  664. for (let entry of tempCfg) {
  665. if (entry.limit != null && entry.limit != undefined) {
  666. let reward = new Number(entry.reward).valueOf()
  667. let nowTimes = 0
  668. let canAdd = true
  669. switch (reward) {
  670. case MONEY_TYPE.speedCard:
  671. nowTimes = GameM.commonData.roleData.airshipSpeedCard
  672. if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) {
  673. canAdd = false
  674. }
  675. break;
  676. case MONEY_TYPE.turnTableCard:
  677. nowTimes = GameM.commonData.roleData.airshipTurntableCard
  678. break;
  679. case MONEY_TYPE.treasureCard:
  680. nowTimes = GameM.commonData.roleData.airshipTicket
  681. if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) {
  682. canAdd = false
  683. }
  684. break;
  685. }
  686. if (nowTimes < entry.limit && canAdd) {
  687. airCfg.push(entry)
  688. range += entry.chance
  689. }
  690. } else {
  691. airCfg.push(entry)
  692. range += entry.chance
  693. }
  694. }
  695. // LogUtil.logV("getAirByRan airCfg", airCfg)
  696. let ran = Math.floor(Math.random() * range)
  697. let add = 0
  698. for (var i = 0; i < airCfg.length; i++) {
  699. add += airCfg[i].chance
  700. if (ran <= add) {
  701. if (this.curAirCfg == airCfg[i]) {
  702. this.getAirByRan()
  703. }
  704. else {
  705. this.curAirCfg = airCfg[i]
  706. }
  707. break
  708. }
  709. }
  710. }
  711. else {
  712. this.unschedule(this.getAirByRan)
  713. }
  714. // LogUtil.logV("getAirByRan curAirCfg", this.curAirCfg)
  715. }
  716. showAirship() {
  717. this.getAirByRan()
  718. this.airshipAni.node.active = true
  719. this.airshipAni.setCurrentTime(0, 'airship')
  720. this.airshipAni.play()
  721. NativeAdAwardData.Instance.setGetAward(2)
  722. }
  723. /** 离线奖励 */
  724. checkOfflineAward() {
  725. if (GameM.commonData.offlineTime >= 60) {
  726. let awardTime = GameM.commonData.offlineTime <= GameM.commonData.offlineTimeMax ? GameM.commonData.offlineTime : GameM.commonData.offlineTimeMax
  727. let goldNum = Sciencen_M.instance.accMul(GameM.commonData.goldSecond.toString(), String(awardTime * 1))
  728. //白龙马天赋2
  729. goldNum = Sciencen_M.instance.addition(goldNum, Sciencen_M.instance.accMul(goldNum, (MateData.Ins.Mate3Talent2 * 0.01).toString()))
  730. if (goldNum != '0') {
  731. UiM.Instance.checkDelayShow(() => {
  732. UiM.Instance.giftNode.active = true
  733. let gift = UiM.Instance.giftNode.getComponent(Gift)
  734. gift.init(MONEY_TYPE.offlineGold, goldNum)
  735. GameM.commonData.offlineTime = 0
  736. })
  737. }
  738. }
  739. else {
  740. if (DailyData.Instance.checkHasGet() && GameM.commonData.maxCarLevel >= GameM.commonData.loginRewardOpenLevel) {
  741. UiM.Instance.onPanel(PANEL_NAME.DailyNode)
  742. } else {
  743. this.checkPopSecretary()
  744. }
  745. }
  746. }
  747. /** 开始游戏检查是否可以看视频
  748. * @param start true 开始游戏检查 false 点击视频检查
  749. */
  750. checkCanVideo(start = true) {
  751. if (start) {
  752. if (GameM.commonData.videoCoolDown > 0) {
  753. this.schedule(this.onVideoTimeSchedule, 1)
  754. }
  755. }
  756. else {
  757. let can = false
  758. if (GameM.commonData.videoCoolDown <= 0) {
  759. can = true
  760. }
  761. else {
  762. can = false
  763. EffectNode.instance.PlayTip(`当前看视频太频繁了,请${GameM.commonData.videoCoolDown}秒后再试`)
  764. }
  765. return can
  766. }
  767. }
  768. /** 开始看视频冷却倒计时 */
  769. startVideoCoolDown() {
  770. GameM.commonData.videoCoolDown = GameM.commonData.videoCoolTime
  771. console.log('startVideoCoolDown ', GameM.commonData.videoCoolDown)
  772. GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown)
  773. this.schedule(this.onVideoTimeSchedule, 1)
  774. }
  775. onVideoTimeSchedule() {
  776. GameM.commonData.videoCoolDown--
  777. console.log('onVideoTimeSchedule ', GameM.commonData.videoCoolDown)
  778. if (GameM.commonData.videoCoolDown % 10 == 0) {
  779. GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown)
  780. }
  781. if (GameM.commonData.videoCoolDown <= 0) {
  782. this.unschedule(this.onVideoTimeSchedule)
  783. }
  784. }
  785. checkTurntableRed() {
  786. if (TurntableData.Instance.turntableTimes > 0) {
  787. RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, true)
  788. }
  789. else {
  790. RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, false)
  791. }
  792. }
  793. /** 探索红点 */
  794. setInvestRed(state) {
  795. // this.schedule(this.freshInvestTime, 1)
  796. RedPointM.instance.ActiveRedPoint(RedPointType.Invest, state)
  797. }
  798. // /** 刷新投资倒计时 */
  799. // freshInvestTime() {
  800. // InvestData.Instance.updateInvestDataTime()
  801. // }
  802. private firstIn = true
  803. /** 存储游戏时间戳,用来计算离线时间 */
  804. storeGameTime() {
  805. if (this.firstIn) {
  806. this.firstIn = false
  807. if (!GameM.commonData.useLocalData) {
  808. GameM.commonData.gameTime = GameM.commonData.currentTime
  809. }
  810. this.schedule(this.onGameTimeAdd, 1)
  811. }
  812. else {
  813. GameM.commonData.gameAdd += 10
  814. GameM.globalStorage.setStorage(STORAGE_KEY.gameAdd, GameM.commonData.gameAdd)
  815. }
  816. if (GameM.commonData.useLocalData) {
  817. GameM.commonData.gameTime = new Date().getTime()
  818. GameM.globalStorage.setStorage(STORAGE_KEY.gameTime, GameM.commonData.gameTime)
  819. }
  820. else {
  821. GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
  822. }
  823. TurntableData.Instance.updateResetTurntable()
  824. if (GameM.commonData.popIdentifySwitch) {
  825. GameM.commonData.todayPlayTime += 10
  826. GameM.globalStorage.setStorage(STORAGE_KEY.todayPlayTime, GameM.commonData.todayPlayTime)
  827. if (UiM.Instance.AntiAddictionNode == null) {
  828. if (GameM.commonData.identification == 2) {
  829. if (GameM.commonData.todayPlayTime >= 5400) {
  830. UiM.Instance.onPanel(PANEL_NAME.AntiAddictionNode)
  831. }
  832. }
  833. }
  834. }
  835. }
  836. onGameTimeAdd() {
  837. if (!GameM.commonData.useLocalData) {
  838. GameM.commonData.gameTime += 1 * 1000
  839. }
  840. }
  841. /** 自动拉取视频 */
  842. checkPopVideo() {
  843. if (GameM.commonData.maxCarLevel < 7) {
  844. return
  845. }
  846. if (!GameM.commonData.isWatchVideo) {
  847. if (!GameM.commonData.hasTouch) {
  848. let percent1 = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2))
  849. if (percent1 < 1) {
  850. this.unschedule(this.checkPopVideo)
  851. return
  852. }
  853. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2))
  854. //弹出视频
  855. if (GameM.commonData.hasPopVideo) {
  856. GameM.commonData.hasTouch = true
  857. let gift = UiM.Instance.giftNode.getComponent(Gift)
  858. let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
  859. num = Sciencen_M.instance.accMul(num, percent.toString())
  860. percent = Math.floor(percent * 100)
  861. gift.init(MONEY_TYPE.gold, num, null, false, 0, null, percent)
  862. UiM.Instance.giftNode.active = true
  863. UiM.Instance.giftNode.x = 1000
  864. if (GameM.commonData.isVideoTest) {
  865. this.onHangUpAdEnd()
  866. }
  867. else {
  868. GameM.adM.watchVideo(VIDEO_TYPE.hangUp)
  869. }
  870. }
  871. else {
  872. GameM.commonData.hasPopVideo = true
  873. let gift = UiM.Instance.giftNode.getComponent(Gift)
  874. let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
  875. num = Sciencen_M.instance.accMul(num, percent.toString())
  876. percent = Math.floor(percent * 100)
  877. UiM.Instance.giftNode.x = 0
  878. gift.init(MONEY_TYPE.popVideo, num, null, false, 0, null, percent)
  879. UiM.Instance.giftNode.active = true
  880. // if (!UiM.Instance.guideNode.active) {
  881. // }
  882. }
  883. }
  884. else {
  885. GameM.commonData.hasTouch = false
  886. }
  887. }
  888. else {
  889. GameM.commonData.hasTouch = false
  890. }
  891. }
  892. onHandUpAdFail() {
  893. GameM.commonData.hasPopVideo = false
  894. UiM.Instance.giftNode.active = false
  895. UiM.Instance.giftNode.x = 0
  896. AdM.destroyNative()
  897. }
  898. onHangUpAdEnd() {
  899. EffectNode.instance.PlayTip('视频观看成功,额外奖励已发放')
  900. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2))
  901. let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold
  902. num = Sciencen_M.instance.accMul(num, percent.toString())
  903. GameM.commonData.updateGold(num)
  904. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  905. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  906. GameM.commonData.updateHangupVideoTimes()
  907. GameM.commonData.hasPopVideo = false
  908. }
  909. /**西游 增加一个角色*/
  910. addRunRole(type, carspace: CarSpace, startRan = false) {
  911. let role = new Role();
  912. role.Init(type, startRan, carspace);
  913. //GameM.commonData.roleArr.push(role)
  914. carspace.role = role;
  915. GameM.commonData.updateGoldSecond();
  916. }
  917. /**西游 删除一个角色*/
  918. removeRunRole(carspace: CarSpace) {
  919. if (carspace.role != null) {
  920. carspace.role.RemoveStrike();
  921. }
  922. carspace.role = null;
  923. carspace.RoleInit(false);
  924. GameM.commonData.updateGoldSecond();
  925. }
  926. /**西游 清除所有的罢工状态*/
  927. clearAllCoolTime() {
  928. for (let entry of this.carSpaceArr) {
  929. // if(entry){
  930. if (cc.isValid(entry)) {
  931. let carSprace: CarSpace = entry.getComponent(CarSpace)
  932. if (carSprace && carSprace.role) {
  933. carSprace.role.RemoveStrike()
  934. carSprace.RoleInit(false)
  935. }
  936. }
  937. }
  938. }
  939. async addParkCar() {
  940. let pre = await Utils.loadResPromise("prefabs/CarMove")
  941. GameM.selCarMove = cc.instantiate(pre)
  942. this.node.addChild(GameM.selCarMove)
  943. GameM.otherCarMove = cc.instantiate(pre)
  944. this.node.addChild(GameM.otherCarMove)
  945. let s;
  946. let data = null
  947. console.log("CarParkNum:" + this.CarPark.childrenCount);
  948. this.CarPark.children.forEach(space => {
  949. s = space.getComponent(CarSpace)
  950. s.index = this.index_s
  951. space.name = s.index.toString()
  952. //console.log("--->index:"+s.index);
  953. data = GameM.commonData.getBagCarDataByPos(s.index)
  954. s.type = data.type
  955. if (s.type == MONEY_TYPE.redMoney) {
  956. GameM.commonData.hasRedMoney++
  957. }
  958. if (s.type != 0 && s.type < 10000) {
  959. //西游
  960. if (GameM.commonData.isUseXiYouAddCoin) {
  961. this.addRunRole(s.type, s, true);
  962. //s.AddCoinSpawn(true);
  963. }
  964. }
  965. s.init(true, data.num)
  966. this.index_s++
  967. this.carSpaceArr.push(space)
  968. });
  969. LogUtil.logV('GameM.commonData.hasRedMoney ', GameM.commonData.hasRedMoney)
  970. }
  971. addAParkCar(pos, type) {
  972. GameM.commonData.updateBagCarData(pos, type)
  973. let space = this.CarPark.getChildByName(pos)
  974. let s = space.getComponent(CarSpace)
  975. s.type = type
  976. s.init(true)
  977. if (GameM.commonData.isUseXiYouAddCoin) {
  978. //西游
  979. this.addRunRole(type, s);
  980. //s.AddCoinSpawn();
  981. }
  982. }
  983. /**是否存在空车位*/
  984. IsHaveEmptySpace() {
  985. let len = GameM.commonData.bagCar.length
  986. for (var i = 0; i < len; i++) {
  987. if (GameM.commonData.bagCar[i].type == 0) {
  988. return true;
  989. }
  990. }
  991. return false;
  992. }
  993. /** 获取一个空位 */
  994. getEmptySpace() {
  995. let value = ''
  996. let len = GameM.commonData.bagCar.length
  997. //console.log("Length:" + len);
  998. // for (var i = 0; i < len; i++) {
  999. // if (GameM.commonData.bagCar[i].type == 0) {
  1000. // value = GameM.commonData.bagCar[i].pos.toString()
  1001. // break
  1002. // }
  1003. // }
  1004. //西游
  1005. for (var i = 0; i < len; i++) {
  1006. if (GameM.commonData.bagCar[i].type == 0) {
  1007. if (this.carSpaceArr[i].getComponent(CarSpace).isCanOperate) {
  1008. value = GameM.commonData.bagCar[i].pos.toString()
  1009. break
  1010. }
  1011. }
  1012. }
  1013. return value
  1014. }
  1015. private strikeNode: cc.Node = null;
  1016. /**
  1017. * 西游
  1018. * 获取一个有车车位索引
  1019. */
  1020. GetRoleSpaceIndex() {
  1021. let value = ''
  1022. let len = GameM.commonData.bagCar.length
  1023. for (var i = 0; i < len; i++) {
  1024. if (GameM.commonData.bagCar[i].type != 0 && GameM.commonData.bagCar[i].type < 10000) {
  1025. value = GameM.commonData.bagCar[i].pos.toString()
  1026. this.strikeNode = this.CarPark.getChildByName(value);
  1027. break
  1028. }
  1029. }
  1030. return value;
  1031. }
  1032. /** 检测是否点到
  1033. * @param point 点击的点
  1034. * @param state 0 起始点 1 结束点
  1035. */
  1036. checkClickPos(point: cc.Vec2, state: number) {
  1037. let result = false
  1038. let addX = this.CarPark.width * 0.5
  1039. let addY = this.CarPark.height * 0.5
  1040. //let pointY = point.y - 130
  1041. let pointY = point.y - this.offPos.y;
  1042. //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY));
  1043. //let pointY = point.y - 100
  1044. if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) {
  1045. console.log("false 1")
  1046. return result
  1047. }
  1048. if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) {
  1049. //console.log("false 2")
  1050. return result
  1051. }
  1052. //航海
  1053. //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) {
  1054. // console.log("false 2")
  1055. // return result
  1056. //}
  1057. if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) {
  1058. if (point.x > this.offPos.x + addX - 200) {
  1059. console.log("false 3")
  1060. return result
  1061. }
  1062. //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
  1063. //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
  1064. //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
  1065. //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
  1066. if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游
  1067. console.log("false 4")
  1068. return result
  1069. }
  1070. }
  1071. let localPosX = point.x - this.offPos.x
  1072. //let localPosY = pointY - this.offPos.y //航海
  1073. //let localPosY = pointY - this.CarPark.y - 80;
  1074. let localPosY = pointY - this.CarPark.y;
  1075. //let localPosY = pointY - this.CarPark.y - 26;
  1076. //console.log("LocalY: " + localPosY);
  1077. //let tx = 170 * 0.5
  1078. //let ty = 120 * 0.5
  1079. let tx = this.carParkSize.x * 0.5
  1080. let ty = this.carParkSize.x * 0.5
  1081. this.CarPark.children.forEach(element => {
  1082. if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) {
  1083. //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) {
  1084. //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) {
  1085. if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) {
  1086. if (state == 0) {
  1087. this.P1 = element
  1088. let s = this.P1.getComponent(CarSpace)
  1089. if (s.type != 0 && s.type < 10000) {
  1090. s.hideImg()
  1091. }
  1092. GameM.selCarMove.getComponent(CarMove).onShow(s.index, s.type)
  1093. if (s.type != 0) {
  1094. result = true
  1095. }
  1096. }
  1097. else if (state == 1) {
  1098. this.P2 = element
  1099. let s = this.P2.getComponent(CarSpace)
  1100. if (this.P1 != null && s.type < 10000) {
  1101. //西游
  1102. if (this.coolTime && this.curGuideId != 11) {
  1103. let s1 = this.P1.getComponent(CarSpace)
  1104. if (s1.type != 0 && s1.type < 10000) {
  1105. if (s.isCanOperate) {
  1106. s.hideImg()
  1107. GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY))
  1108. GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type)
  1109. result = true
  1110. }
  1111. }
  1112. }
  1113. //航海
  1114. //let s1 = this.P1.getComponent(CarSpace)
  1115. //if (s1.type != 0 && s1.type < 10000) {
  1116. // s.hideImg()
  1117. // GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY))
  1118. // GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type)
  1119. // result = true
  1120. //}
  1121. }
  1122. }
  1123. }
  1124. }
  1125. })
  1126. return result
  1127. }
  1128. /** 检测是否点到非空非车位(角色 金币 礼包等)
  1129. * @param point 点击的点
  1130. */
  1131. checkClickNoEmptyOther(point: cc.Vec2,) {
  1132. let result = false
  1133. let addX = this.CarPark.width * 0.5
  1134. let addY = this.CarPark.height * 0.5
  1135. //let pointY = point.y - 130
  1136. let pointY = point.y - this.offPos.y;
  1137. //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY));
  1138. //let pointY = point.y - 100
  1139. if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) {
  1140. //console.log("false 1")
  1141. return result
  1142. }
  1143. if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) {
  1144. //console.log("false 2")
  1145. return result
  1146. }
  1147. //航海
  1148. //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) {
  1149. // console.log("false 2")
  1150. // return result
  1151. //}
  1152. if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) {
  1153. if (point.x > this.offPos.x + addX - 200) {
  1154. console.log("false 3")
  1155. return result
  1156. }
  1157. //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
  1158. //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
  1159. //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
  1160. //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
  1161. if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游
  1162. console.log("false 4")
  1163. return result
  1164. }
  1165. }
  1166. let localPosX = point.x - this.offPos.x
  1167. //let localPosY = pointY - this.offPos.y //航海
  1168. //let localPosY = pointY - this.CarPark.y - 80;
  1169. let localPosY = pointY - this.CarPark.y;
  1170. //let localPosY = pointY - this.CarPark.y - 26;
  1171. //console.log("LocalY: " + localPosY);
  1172. //let tx = 170 * 0.5
  1173. //let ty = 120 * 0.5
  1174. let tx = this.carParkSize.x * 0.5
  1175. let ty = this.carParkSize.x * 0.5
  1176. this.CarPark.children.forEach(element => {
  1177. if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) {
  1178. //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) {
  1179. //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) {
  1180. if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) {
  1181. //console.log("------ok");
  1182. this.P1 = element
  1183. let s = this.P1.getComponent(CarSpace)
  1184. if (s.type != 0 && s.type > 0) {
  1185. result = true;
  1186. }
  1187. //if (s.type != 0) {
  1188. // if (s.type >= 10000) {
  1189. // result = true;
  1190. // } else {
  1191. // //单击到角色
  1192. // result = false;
  1193. // //s.ClickRole();
  1194. // }
  1195. //}
  1196. }
  1197. }
  1198. })
  1199. return result
  1200. }
  1201. hideHandGuide() {
  1202. if (this.hasHand) {
  1203. this.hasHand = false
  1204. if (this.handTween) {
  1205. this.handTween.stop()
  1206. }
  1207. this.hand.active = false
  1208. }
  1209. }
  1210. hideAllHand() {
  1211. this.hasHand = false
  1212. if (this.handTween) {
  1213. this.handTween.stop()
  1214. }
  1215. this.hand.active = false
  1216. this.buyHand.active = false
  1217. this.cashHand.active = false
  1218. }
  1219. showBuyCarHand() {
  1220. // this.hideHandGuide()
  1221. // this.buyHand.x = 50
  1222. // this.buyHand.active = true
  1223. cc.tween(this.btnBuy)
  1224. .delay(0.3)
  1225. .to(0.3, { scale: 1.2 })
  1226. .to(0.3, { scale: 1 })
  1227. .start()
  1228. }
  1229. showInvestHand() {
  1230. this.hideHandGuide()
  1231. //this.buyHand.x = 200
  1232. this.buyHand.x = 180
  1233. this.buyHand.active = true
  1234. }
  1235. private coolTime = false
  1236. onTouchStart(evt) {
  1237. //MyExtends.GetAryByAry(5, [1, 2, 3, 4, 5, 6, 7], true);
  1238. //console.log("----Cool" + this.coolTime);
  1239. if (this.coolTime) {
  1240. return
  1241. }
  1242. this.P1 = null
  1243. this.P2 = null
  1244. //西游
  1245. let tempstartpos = evt.touch._point;
  1246. this.moveStartPos = cc.v2();
  1247. this.moveStartPos.x = tempstartpos.x;
  1248. this.moveStartPos.y = tempstartpos.y;
  1249. this.IsClickOther = this.checkClickNoEmptyOther(evt.touch._point);
  1250. if (this.IsClickOther) {
  1251. this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
  1252. this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
  1253. //console.log("--->On End")
  1254. }
  1255. this.curGuideId = GuideMng.Ins.CurGuideId;
  1256. //航海
  1257. //let result = this.checkClickPos(evt.touch._point, 0)
  1258. //if (result) {
  1259. // this.coolTime = true
  1260. // this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
  1261. // this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
  1262. // this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
  1263. //
  1264. // let localPosX = evt.touch._point.x - this.sW * 0.5
  1265. // let localPosY = evt.touch._point.y - this.sH * 0.5
  1266. // GameM.selCarMove.setPosition(localPosX, localPosY)
  1267. //
  1268. // this.showCanCompose()
  1269. // this.hideHandGuide()
  1270. //
  1271. // if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
  1272. // this.ActiceTrashState(true);
  1273. //}
  1274. }
  1275. showCanCompose() {
  1276. let type = this.P1.getComponent(CarSpace).type
  1277. let s
  1278. this.CarPark.children.forEach(element => {
  1279. if (element != this.P1) {
  1280. s = element.getComponent(CarSpace)
  1281. if (s.type != 0 && s.type < 10000 && s.type == type) {
  1282. s.showCanCompose()
  1283. }
  1284. }
  1285. })
  1286. }
  1287. hideCanCompose() {
  1288. let s
  1289. this.CarPark.children.forEach(element => {
  1290. s = element.getComponent(CarSpace)
  1291. s.hideCanCompose()
  1292. })
  1293. }
  1294. //西游
  1295. /**合成引导移动限制区域*/
  1296. composeRectNode: cc.Node = null;
  1297. curGuideId: number = -1;
  1298. /**是否点击到非车位 金币 礼包等*/
  1299. IsClickOther: boolean = false;
  1300. /**移动相应距离算拖拽*/
  1301. moveDisTarget: number = 30;
  1302. /**移动的距离*/
  1303. moveDis: number = 0;
  1304. /**点击坐标*/
  1305. moveStartPos: cc.Vec2 = null;
  1306. /**拖动坐标*/
  1307. moveingPos: cc.Vec2 = cc.v2();
  1308. /**是否可以拖动*/
  1309. moveOpen: boolean = false
  1310. onTouchMove(evt) {
  1311. //西游
  1312. if (this.moveStartPos == null) return;
  1313. this.moveingPos = this.moveStartPos.sub(evt.touch._point);
  1314. this.moveDis = this.moveingPos.len();
  1315. if (this.moveDis >= this.moveDisTarget && !this.coolTime) {
  1316. let result = this.checkClickPos(this.moveStartPos, 0)
  1317. if (result) {
  1318. this.coolTime = true
  1319. //console.log("---Set true")
  1320. this.moveOpen = true;
  1321. if (!this.IsClickOther) {
  1322. //this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)//航海
  1323. this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
  1324. this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
  1325. //console.log("--->On End move")
  1326. }
  1327. let localPosX = evt.touch._point.x - this.sW * 0.5;
  1328. let localPosY = evt.touch._point.y - this.sH * 0.5;
  1329. GameM.selCarMove.setPosition(localPosX, localPosY);
  1330. this.showCanCompose()
  1331. this.hideHandGuide()
  1332. if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
  1333. this.ActiceTrashState(true);
  1334. }
  1335. }
  1336. if (this.coolTime) {
  1337. if (GameM.selCarMove.getComponent(CarMove).sel) {
  1338. let localPosX = evt.touch._point.x - this.sW * 0.5
  1339. let localPosY = evt.touch._point.y - this.sH * 0.5
  1340. if (this.curGuideId == 1) {
  1341. if (!MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) {
  1342. GameM.selCarMove.setPosition(localPosX, localPosY);
  1343. }
  1344. } else if (this.curGuideId == 11) {
  1345. }
  1346. else {
  1347. GameM.selCarMove.setPosition(localPosX, localPosY);
  1348. }
  1349. //let localPosX = evt.touch._point.x - this.sW * 0.5
  1350. //let localPosY = evt.touch._point.y - this.sH * 0.5
  1351. //GameM.selCarMove.setPosition(localPosX, localPosY)
  1352. }
  1353. }
  1354. //console.log("---Move CooolTime:" + this.coolTime);
  1355. //航海
  1356. //console.log("Start:" + this.moveStartPos.x + " Move:" + this.moveingPos.x + "---Length:" + this.moveDis);
  1357. //if (GameM.selCarMove.getComponent(CarMove).sel) {
  1358. // let localPosX = evt.touch._point.x - this.sW * 0.5
  1359. // let localPosY = evt.touch._point.y - this.sH * 0.5
  1360. // GameM.selCarMove.setPosition(localPosX, localPosY)
  1361. //}
  1362. }
  1363. onTouchEnd(evt) {
  1364. let ms = GameM.selCarMove.getComponent(CarMove)
  1365. let os = GameM.otherCarMove.getComponent(CarMove)
  1366. let self = this
  1367. //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
  1368. this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
  1369. this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
  1370. //console.log("--->Off End")
  1371. this.checkClickPos(evt.touch._point, 1)
  1372. if (this.curGuideId == 1) {
  1373. //if (point.x > this.offPos.x + addX - 200) {
  1374. // console.log("false 3")
  1375. // return result
  1376. //}
  1377. //
  1378. ////if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海
  1379. ////if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游
  1380. ////console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45));
  1381. ////if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游
  1382. //if (pointY < this.CarPark.y - addY + 138 * 2 + 80) { //西游
  1383. // console.log("false 4")
  1384. // return result
  1385. //}
  1386. let localPosX = evt.touch._point.x - this.sW * 0.5
  1387. let localPosY = evt.touch._point.y - this.sH * 0.5
  1388. if (MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) {
  1389. cc.tween(GameM.selCarMove)
  1390. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1391. .call(function () {
  1392. ms.onHide()
  1393. self.P1.getComponent(CarSpace).showImg()
  1394. self.coolTime = false
  1395. })
  1396. .start()
  1397. this.ActiceTrashState(false);
  1398. this.moveStartPos = null;
  1399. this.hideCanCompose();
  1400. return;
  1401. }
  1402. } else if (this.curGuideId == 11) {
  1403. GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY));
  1404. ms.onHide();
  1405. self.P1.getComponent(CarSpace).showImg();
  1406. //self.coolTime = false;
  1407. this.ActiceTrashState(false);
  1408. //this.moveStartPos = null;
  1409. this.hideCanCompose();
  1410. if (ms.sel && ms.type != 0 && ms.type < 10000) { }
  1411. else {
  1412. if (this.P1 == this.P2) {
  1413. let s = this.P1.getComponent(CarSpace)
  1414. //console.log("Click type:"+s.type);
  1415. if (s.type <= 10000) {
  1416. //点击角色
  1417. if (s.type != 0 && s.type < 10000) {
  1418. s.ClickRole();
  1419. }
  1420. }
  1421. }
  1422. }
  1423. self.coolTime = false;
  1424. this.moveStartPos = null;
  1425. return;
  1426. }
  1427. if (ms.sel && ms.type != 0 && ms.type < 10000) {
  1428. this.hideCanCompose()
  1429. //回到原位置
  1430. if (!os.sel) {
  1431. let localPosX = evt.touch._point.x - this.sW * 0.5
  1432. let localPosY = evt.touch._point.y - this.sH * 0.5
  1433. let tw = this.btnBuy.width * 0.5
  1434. let ty = this.btnBuy.height * 0.5
  1435. if (localPosX >= this.btnBuy.x - tw && localPosX <= this.btnBuy.x + tw
  1436. && localPosY >= this.btnBuy.y - ty && localPosY <= this.btnBuy.y + ty && GameM.commonData.step > 3) {
  1437. //回收
  1438. ms.onHide()
  1439. self.P1.getComponent(CarSpace).changeType(0)
  1440. GameM.commonData.updateBagCarData(ms.index.toString(), 0)
  1441. //西游
  1442. if (GameM.commonData.isUseXiYouAddCoin) {
  1443. self.removeRunRole(self.P1.getComponent(CarSpace));
  1444. }
  1445. GameM.commonData.updateGold(GameM.commonData.carCfg[ms.type.toString()].price)
  1446. this.scheduleOnce(() => {
  1447. self.checkGiftByQucece()
  1448. self.coolTime = false
  1449. }, 0.1)
  1450. this.ActiceTrashState(false);
  1451. EffectNode.instance.PlayTrashAni(Number(GameM.commonData.carCfg[ms.type.toString()].price));
  1452. this.CheckNormalGuide();
  1453. }
  1454. else {
  1455. if (GameM.commonData.quality > Game_Quality.medium) {
  1456. cc.tween(GameM.selCarMove)
  1457. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1458. .call(function () {
  1459. ms.onHide()
  1460. self.P1.getComponent(CarSpace).showImg()
  1461. self.coolTime = false
  1462. })
  1463. .start()
  1464. }
  1465. else {
  1466. GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
  1467. ms.onHide()
  1468. self.P1.getComponent(CarSpace).showImg()
  1469. self.coolTime = false
  1470. }
  1471. this.ActiceTrashState(false);
  1472. }
  1473. }
  1474. else {
  1475. //合成
  1476. if (os.type != 0) {
  1477. if (os.type >= 10000) {
  1478. //回到原位置
  1479. if (GameM.commonData.quality > Game_Quality.medium) {
  1480. cc.tween(GameM.selCarMove)
  1481. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1482. .call(function () {
  1483. ms.onHide()
  1484. self.P1.getComponent(CarSpace).showImg()
  1485. self.coolTime = false
  1486. })
  1487. .start()
  1488. }
  1489. else {
  1490. GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
  1491. ms.onHide()
  1492. self.P1.getComponent(CarSpace).showImg()
  1493. self.coolTime = false
  1494. }
  1495. os.onHide()
  1496. }
  1497. else {
  1498. if (ms.index != os.index) {
  1499. if (ms.type == os.type) {
  1500. self.scheduleOnce(function () {
  1501. GameM.audioM.playEffect(AUDIO_TYPE.compose)
  1502. self.composeAni.node.setPosition(cc.v2(self.P2.position.x, self.P2.position.y + 74 + this.moveEndY))
  1503. self.composeAni.node.active = true
  1504. self.composeAni.setAnimation(0, 'animation', false)
  1505. self.scheduleOnce(() => { self.composeAni.node.active = false }, 1.5)
  1506. }, 0.13)
  1507. GameM.selCarMove.setPosition(cc.v2(this.P2.position.x - 120, this.P2.position.y + 74 + this.moveEndY))
  1508. GameM.selCarMove.angle = 0
  1509. GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x + 120, this.P2.position.y + 74 + this.moveEndY))
  1510. GameM.otherCarMove.angle = 0
  1511. cc.tween(GameM.selCarMove)
  1512. .to(0.05, { position: cc.v2(this.P2.position.x - 150, this.P2.position.y + 74 + this.moveEndY), angle: 30 })
  1513. .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 })
  1514. .call(function () {
  1515. ms.onHide()
  1516. let p1CarSpace = self.P1.getComponent(CarSpace)
  1517. p1CarSpace.changeType(0)
  1518. //self.P1.getComponent(CarSpace).changeType(0)
  1519. //西游
  1520. if (GameM.commonData.isUseXiYouAddCoin) {
  1521. self.removeRunRole(p1CarSpace);
  1522. //p1CarSpace.RemoveCoinSpawn();
  1523. }
  1524. self.checkGiftByQucece()
  1525. })
  1526. .start()
  1527. cc.tween(GameM.otherCarMove)
  1528. .to(0.05, { position: cc.v2(this.P2.position.x + 150, this.P2.position.y + 74 + this.moveEndY), angle: -30 })
  1529. .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 })
  1530. .call(function () {
  1531. os.onHide()
  1532. let p2CarSpace = self.P2.getComponent(CarSpace);
  1533. p2CarSpace.changeType(Number(os.type) + 1)
  1534. //self.P2.getComponent(CarSpace).changeType(Number(os.type) + 1)
  1535. let last = Sciencen_M.instance.accMul(GameM.commonData.carCfg[(Number(ms.type)).toString()].exp, '2')
  1536. let exp = Sciencen_M.instance.subtraction(GameM.commonData.carCfg[(Number(ms.type) + 1).toString()].exp, last)
  1537. //西游 因为会重新AddCoinSpawn所以不用Remove
  1538. //p1CarSpace.RemoveCoinSpawn();
  1539. if (GameM.commonData.isUseXiYouAddCoin) {
  1540. self.removeRunRole(p2CarSpace);
  1541. }
  1542. GameM.commonData.updateBagCarData(ms.index.toString(), 0, 1, false)
  1543. GameM.commonData.updateBagCarData(os.index.toString(), Number(os.type) + 1)
  1544. //西游
  1545. if (GameM.commonData.isUseXiYouAddCoin) {
  1546. self.addRunRole(Number(os.type) + 1, p2CarSpace);
  1547. p2CarSpace.role.ComposeRole();
  1548. //p2CarSpace.AddCoinSpawn();
  1549. }
  1550. UiM.Instance.panelFuns.push(() => GameM.commonData.updateRoleDataExp(exp));
  1551. UiM.Instance.panelFuns.push(() => GameM.commonData.updateMaxCarLevel(Number(os.type) + 1)); //最先执行 后进先出
  1552. //西游
  1553. //弃用 继续使用 maxCarLevel 更新合成的最高等级
  1554. //GameM.commonData.UpdateComposeMaxRoleLv(Number(os.type) + 1);
  1555. UiM.Instance.displayPanel();
  1556. self.coolTime = false
  1557. // if (GameM.commonData.step == 3) {
  1558. // UiM.Instance.guideNode.getComponent(Guide).setStep()
  1559. // }
  1560. self.CheckNormalGuide();
  1561. })
  1562. .start()
  1563. //西游 切换背景
  1564. //this.UpdateMainBg();
  1565. //this.ChangeBgSelf();
  1566. if (GameM.commonData.composeCarTimes == 0) {
  1567. AdM.onSendEvent('compose_1', '合成第1只武将', 'compose')
  1568. }
  1569. GameM.commonData.updateComposeCarTimes()
  1570. AdM.onSendEvent(`operate${Number(os.type) + 1}`, `合成${Number(os.type) + 1}级的武将`)
  1571. this.ActiceTrashState(false);
  1572. //EffectNode.instance.PlayExpEffect(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY));
  1573. }
  1574. //交换位置
  1575. else {
  1576. let cs1 = self.P1.getComponent(CarSpace)
  1577. let cs2 = self.P2.getComponent(CarSpace)
  1578. let tempCs1role: any = cs1.role
  1579. let tempCs2Role: any = cs2.role
  1580. if (GameM.commonData.quality > Game_Quality.medium) {
  1581. cc.tween(GameM.selCarMove)
  1582. .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) })
  1583. .call(function () {
  1584. ms.onHide()
  1585. cs2.changeType(ms.type)
  1586. cs2.role = tempCs1role
  1587. cs2.role.UpdateRoleSpace(cs2)
  1588. })
  1589. .start()
  1590. GameM.otherCarMove.y += 130
  1591. cc.tween(GameM.otherCarMove)
  1592. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1593. .call(function () {
  1594. os.onHide()
  1595. cs1.changeType(os.type)
  1596. cs1.role = tempCs2Role
  1597. cs1.role.UpdateRoleSpace(cs1)
  1598. GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
  1599. GameM.commonData.updateBagCarData(ms.index.toString(), os.type)
  1600. self.coolTime = false
  1601. //console.log("---Set False quality")
  1602. self.CheckNormalGuide();
  1603. })
  1604. .start()
  1605. }
  1606. else {
  1607. GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY))
  1608. ms.onHide()
  1609. cs2.changeType(ms.type)
  1610. cs2.role = tempCs1role
  1611. cs2.role.UpdateRoleSpace(cs2)
  1612. GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
  1613. GameM.otherCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
  1614. os.onHide()
  1615. cs1.changeType(os.type)
  1616. cs1.role = tempCs2Role
  1617. cs1.role.UpdateRoleSpace(cs1)
  1618. GameM.commonData.updateBagCarData(ms.index.toString(), os.type)
  1619. self.coolTime = false
  1620. //console.log("---Set False no quality")
  1621. this.CheckNormalGuide();
  1622. }
  1623. this.ActiceTrashState(false);
  1624. }
  1625. }
  1626. else {
  1627. //回到原位置
  1628. if (GameM.commonData.quality > Game_Quality.medium) {
  1629. cc.tween(GameM.selCarMove)
  1630. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1631. .call(function () {
  1632. ms.onHide()
  1633. self.P1.getComponent(CarSpace).showImg()
  1634. self.coolTime = false
  1635. })
  1636. .start()
  1637. }
  1638. else {
  1639. GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
  1640. ms.onHide()
  1641. self.P1.getComponent(CarSpace).showImg()
  1642. self.coolTime = false
  1643. }
  1644. os.onHide()
  1645. this.ActiceTrashState(false);
  1646. }
  1647. }
  1648. }
  1649. else {
  1650. let cs1 = self.P1.getComponent(CarSpace)
  1651. let cs2 = self.P2.getComponent(CarSpace)
  1652. let tempCs1role: any = cs1.role
  1653. if (GameM.commonData.quality > Game_Quality.medium) {
  1654. cc.tween(GameM.selCarMove)
  1655. .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) })
  1656. .call(function () {
  1657. ms.onHide()
  1658. os.onHide()
  1659. cs2.changeType(ms.type)
  1660. cs1.changeType(0)
  1661. tempCs1role.RemoveOldStrike()
  1662. cs2.role = tempCs1role
  1663. cs2.role.UpdateRoleSpace(cs2)
  1664. cs1.ClearRole();
  1665. //cs1.role
  1666. GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
  1667. GameM.commonData.updateBagCarData(ms.index.toString(), 0)
  1668. self.coolTime = false
  1669. self.CheckNormalGuide();
  1670. })
  1671. .start()
  1672. }
  1673. else {
  1674. GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY))
  1675. ms.onHide()
  1676. os.onHide()
  1677. self.P2.getComponent(CarSpace).changeType(ms.type)
  1678. self.P1.getComponent(CarSpace).changeType(0)
  1679. GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false)
  1680. GameM.commonData.updateBagCarData(ms.index.toString(), 0)
  1681. self.coolTime = false
  1682. }
  1683. this.ActiceTrashState(false);
  1684. this.CheckNormalGuide();
  1685. }
  1686. }
  1687. }
  1688. else {
  1689. if (this.P1 == this.P2) {
  1690. let s = this.P1.getComponent(CarSpace)
  1691. //console.log("Click type:"+s.type);
  1692. if (s.type > 10000) {
  1693. //打开礼包
  1694. if (s.type == MONEY_TYPE.box) {
  1695. let type = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_car)
  1696. this.P1.getComponent(CarSpace).openBox(type)
  1697. //console.log("click box");
  1698. }
  1699. else {
  1700. if (s.type == MONEY_TYPE.redMoney) {
  1701. UiM.Instance.redPackageNode.init(s.num, 1, 3, this.P1)
  1702. UiM.Instance.openPanel(UiM.Instance.redPackageNode.node, false)
  1703. //console.log("click redmoney");
  1704. }
  1705. else {
  1706. //console.log("click others");
  1707. //显示领取道具
  1708. UiM.Instance.checkDelayShow(() => {
  1709. UiM.Instance.giftNode.active = true
  1710. UiM.Instance.giftNode.x = 0
  1711. let gift = UiM.Instance.giftNode.getComponent(Gift)
  1712. gift.init(s.type, String(s.num), this.P1, false, 0)
  1713. })
  1714. }
  1715. }
  1716. this.CheckNormalGuide();
  1717. } else {
  1718. //点击角色
  1719. if (s.type != 0 && s.type < 10000) {
  1720. s.ClickRole();
  1721. }
  1722. }
  1723. }
  1724. self.coolTime = false
  1725. }
  1726. //this.unschedule(this.CheckNormalGuide)
  1727. //this.scheduleOnce(this.CheckNormalGuide, 0.2)
  1728. //常规引导
  1729. this.unschedule(this.CheckNormalGuide)
  1730. this.scheduleOnce(() => {
  1731. //console.log("----------End")
  1732. //this.CheckNormalGuide();
  1733. this.schedule(this.CheckNormalGuide, 5);
  1734. }, 0.2)
  1735. //西游 清空点击点坐标数据 防止误操作
  1736. this.moveStartPos = null
  1737. //console.log("------>End");
  1738. }
  1739. onTouchCacel(evt) {
  1740. //西游 清空点击点坐标数据
  1741. this.moveStartPos = null
  1742. let self = this
  1743. let ms = GameM.selCarMove.getComponent(CarMove)
  1744. if (ms.sel) {
  1745. if (GameM.commonData.quality > Game_Quality.medium) {
  1746. cc.tween(GameM.selCarMove)
  1747. .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) })
  1748. .call(function () {
  1749. ms.onHide()
  1750. self.P1.getComponent(CarSpace).showImg()
  1751. })
  1752. .start()
  1753. }
  1754. else {
  1755. GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY))
  1756. ms.onHide()
  1757. self.P1.getComponent(CarSpace).showImg()
  1758. }
  1759. //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
  1760. this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
  1761. this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this)
  1762. self.coolTime = false
  1763. console.log("--->Off End cancel")
  1764. }
  1765. console.log("----------Cancel")
  1766. if (GameM.commonData.maxCarLevel >= 10) {
  1767. }
  1768. else {
  1769. this.CheckNormalGuide();
  1770. }
  1771. }
  1772. /** 开启判断给礼包定时器 */
  1773. startAddTimer() {
  1774. LogUtil.logV("startAddTimer", "start")
  1775. if (GameM.commonData.maxCarLevel >= GameM.commonData.dropGiftOpenLevel) {
  1776. if (GameM.commonData.giftTimes < GameM.commonData.giftMaxTimes) {
  1777. //let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5)
  1778. //test
  1779. let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5)
  1780. this.scheduleOnce(() => {
  1781. GameM.commonData.updateGiftCacheNum(1)
  1782. this.addGiftBag()
  1783. this.startAddTimer()
  1784. }, timespan)
  1785. }
  1786. }
  1787. }
  1788. /** 有空位检查添加礼包 */
  1789. checkGiftByQucece() {
  1790. LogUtil.logV("checkGiftByQucece", "")
  1791. if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) {
  1792. return;
  1793. }
  1794. if (GameM.commonData.boxCacheNum > 0) {
  1795. this.addBoxBag()
  1796. }
  1797. else if (GameM.commonData.giftCacheNum > 0) {
  1798. this.addGiftBag()
  1799. }
  1800. }
  1801. delayAddGift() {
  1802. if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) {
  1803. return;
  1804. }
  1805. if (GameM.commonData.giftCacheNum > 0 || GameM.commonData.boxCacheNum > 0) {
  1806. this.schedule(this.addGifts, 1, GameM.commonData.giftCacheNum)
  1807. }
  1808. }
  1809. addGifts() {
  1810. if (GameM.commonData.boxCacheNum <= 0 && GameM.commonData.giftCacheNum <= 0) {
  1811. this.unschedule(this.addGifts)
  1812. }
  1813. else {
  1814. this.checkGiftByQucece()
  1815. }
  1816. }
  1817. /** 立即获得box礼包 */
  1818. addBoxGiftNow() {
  1819. let pos = this.getEmptySpace()
  1820. if (pos != '') {
  1821. GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
  1822. let num = 1
  1823. GameM.commonData.updateBagCarData(pos, MONEY_TYPE.box, num)
  1824. let space = this.CarPark.getChildByName(pos)
  1825. let s = space.getComponent(CarSpace)
  1826. s.type = MONEY_TYPE.box
  1827. s.init(true, num)
  1828. }
  1829. else {
  1830. this.CheckNormalGuide()
  1831. GameM.commonData.updateBoxCacheNum(1)
  1832. }
  1833. }
  1834. /** 添加礼包
  1835. * @param type 礼包类型
  1836. * 10001:金币
  1837. * 10002:红包币
  1838. * 10003:时间段收益(当前的每秒收益*时间段)
  1839. * 10004:惊喜礼包(打开后获得对应等级的轮船)
  1840. */
  1841. addGiftBag() {
  1842. LogUtil.logV("addGiftBag", "")
  1843. //只在此处可能出现元宝币
  1844. let data = GameM.commonData.giftRandomAdd()
  1845. let pos = this.getEmptySpace()
  1846. //console.log("Empty:" + pos)
  1847. if (pos != '') {
  1848. GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
  1849. let num = 0
  1850. if (data[0] == MONEY_TYPE.gold.toString()) {
  1851. num = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_gold)
  1852. }
  1853. else {
  1854. num = Number(data[1])
  1855. }
  1856. if (data[0] == MONEY_TYPE.redMoney.toString()) {
  1857. this.redMoneyInGiftBag(pos, MONEY_TYPE.redMoney)
  1858. } else {
  1859. GameM.commonData.updateBagCarData(pos, Number(data[0]), num)
  1860. this.scheduleOnce(() => {
  1861. let space = this.CarPark.getChildByName(pos)
  1862. let s = space.getComponent(CarSpace)
  1863. s.type = Number(data[0])
  1864. s.init(true, num)
  1865. GameM.commonData.updateGiftCacheNum(-1)
  1866. }, 0.05)
  1867. }
  1868. }
  1869. else {
  1870. this.CheckNormalGuide()
  1871. }
  1872. }
  1873. redMoneyInGiftBag(pos, type) {
  1874. HttpM.Instance.SendData(HTTP_TYPE.adShowConfig,
  1875. {}, (res) => {
  1876. LogUtil.logV("redMoneyInGiftBag:", res)
  1877. if (res && res.data) {
  1878. let num = 0
  1879. let average_ecpm = res.data.average_ecpm
  1880. if (average_ecpm == 0) {
  1881. num = GameM.commonData.giftBagRedMoney[0][2]
  1882. } else {
  1883. for (let entry of GameM.commonData.giftBagRedMoney) {
  1884. if (average_ecpm > entry[0] && average_ecpm <= entry[1]) {
  1885. num = entry[2]
  1886. break
  1887. }
  1888. }
  1889. if (num == 0) {
  1890. num = GameM.commonData.giftBagRedMoney[0][2]
  1891. }
  1892. }
  1893. GameM.commonData.updateBagCarData(pos, type, num)
  1894. this.scheduleOnce(() => {
  1895. let space = this.CarPark.getChildByName(pos)
  1896. let s = space.getComponent(CarSpace)
  1897. s.type = Number(type)
  1898. s.init(true, num)
  1899. GameM.commonData.updateGiftCacheNum(-1)
  1900. }, 0.05)
  1901. }
  1902. //console.log("-->uplevel talent:", res);
  1903. })
  1904. }
  1905. /** 只添加box
  1906. * @param type
  1907. * 10004:惊喜礼包(打开后获得对应等级的轮船)
  1908. */
  1909. addBoxBag() {
  1910. let pos = this.getEmptySpace()
  1911. if (pos != '') {
  1912. GameM.audioM.playEffect(AUDIO_TYPE.giftFall)
  1913. let num = 1
  1914. let type = 10004
  1915. GameM.commonData.updateBagCarData(pos, type, num)
  1916. this.scheduleOnce(() => {
  1917. let space = this.CarPark.getChildByName(pos)
  1918. let s = space.getComponent(CarSpace)
  1919. s.type = type
  1920. s.init(true, num)
  1921. GameM.commonData.updateBoxCacheNum(-1)
  1922. }, 0.1)
  1923. }
  1924. else {
  1925. this.CheckNormalGuide()
  1926. }
  1927. }
  1928. private lvupPos = ''
  1929. private lvupLv = -1
  1930. private lvupPreLv = -1
  1931. /** 点击购买车辆 */
  1932. onBuyCar() {
  1933. GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar)
  1934. let pos = this.getEmptySpace()
  1935. if (pos != '') {
  1936. let price = GameM.commonData.getPriceByType(this.curBuyType)
  1937. //白龙马天赋3
  1938. price = Sciencen_M.instance.subtraction(price, Sciencen_M.instance.accMul(price, (MateData.Ins.Mate3Talent3 * 0.01).toString()));
  1939. if (GameM.commonData.updateGoldMinus(price)) {
  1940. if (GameM.commonData.maxCarLevel > 14) {
  1941. let result = GameM.commonData.checkShowLvUp()
  1942. if (result > 0) {
  1943. if (GameM.commonData.buyTimeTotal - GameM.commonData.lastVideoUpCarBuyTimes >= 10) {
  1944. GameM.commonData.updatelastVideoUpCarBuyTimes()
  1945. UiM.Instance.checkDelayShow(() => {
  1946. UiM.Instance.giftNode.active = true
  1947. this.lvupPos = pos
  1948. this.lvupLv = result
  1949. this.lvupPreLv = this.curBuyType
  1950. let gift = UiM.Instance.giftNode.getComponent(Gift)
  1951. gift.init(MONEY_TYPE.carLvUp, String(result), this.curBuyType, false, 0, VIDEO_TYPE.carLvUp)
  1952. })
  1953. }
  1954. }
  1955. }
  1956. if (this.buyHand.active) {
  1957. this.buyHand.active = false
  1958. }
  1959. this.addAParkCar(pos, this.curBuyType)
  1960. GameM.commonData.updateBuyTimeData(this.curBuyType)
  1961. GameM.commonData.updateBuyTimeTotal()
  1962. this.CheckNormalGuide()
  1963. //西游测试
  1964. this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal;
  1965. if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 1) {
  1966. // this.dailyCash = DailyCashData.Instance.getTodayDailyCash()
  1967. if (DailyCashData.Instance.userDailyCashInfo) {
  1968. this.dailyCash = DailyCashData.Instance.userDailyCashInfo
  1969. if (GameM.commonData.roleData.dailyPro < this.dailyCash.buyTime) {
  1970. let addGold = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.DailyCashProAdd);
  1971. addGold.getComponent(DailyCashProAdd).init("进度+1");
  1972. // addGold.x = 50;
  1973. this.dailyCashBtn.node.addChild(addGold);
  1974. GameM.commonData.updateDailyCash(0, 1, true)
  1975. this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime
  1976. this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
  1977. // let str = `当前提现进度: ${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}`
  1978. // let labPre = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.BuyProAdd);
  1979. // labPre.getComponent(BuyProAdd).init(str)
  1980. // this.posBtnBuy.addChild(labPre)
  1981. this.labTixianPro.node.active = true
  1982. this.labWuFuNode.active = false
  1983. //飞红包
  1984. EffectNode.instance.PlayCoinAnim(14, 5, cc.v2(this.btnBuy.position.x, this.btnBuy.position.y), true,
  1985. cc.v2(this.dailyCashBtn.node.position.x, this.dailyCashBtn.node.position.y + this.centerPart.y))
  1986. GameM.audioM.playEffect(AUDIO_TYPE.getGold)
  1987. cc.tween(this.dailyCashBtn.node)
  1988. .delay(1)
  1989. .to(0.2, { scale: 1.2 })
  1990. .to(0.2, { scale: 1 })
  1991. .start()
  1992. if (GameM.commonData.roleData.dailyPro == this.dailyCash.buyTime && GameM.commonData.roleData.canDailyCash != 0) {
  1993. AdM.onSendEvent('nextcash_finish', '明日提现任务完成', 'nextcash')
  1994. }
  1995. if (this.dailyBtn != null) {
  1996. if (GameM.commonData.roleData.dailyPro >= this.dailyCash.buyTime) {
  1997. GuideMng.Ins.CheckFiveluck2Guide12()
  1998. }
  1999. }
  2000. // EffectNode.instance.PlayExpEffect(cc.v2(this.posBtnBuy.x, this.posBtnBuy.y), 2);
  2001. }
  2002. }
  2003. }
  2004. let exp = GameM.commonData.carCfg[this.curBuyType.toString()].exp
  2005. GameM.commonData.updateRoleDataExp(exp)
  2006. GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
  2007. this.carBuyInfo()
  2008. //财神降临
  2009. WealthData.Ins.CheckTrigger();
  2010. AdM.onSendEvent(`buy_${GameM.commonData.buyTimeTotal}`, `第${GameM.commonData.buyTimeTotal}次买车`, 'buy')
  2011. } else {
  2012. if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
  2013. EffectNode.instance.PlayTip('今日金币获取次数已用尽')
  2014. this.hideAllHand()
  2015. this.CheckNormalGuide()
  2016. //弹出金币获取方式界面
  2017. UiM.Instance.onPanel(PANEL_NAME.CoinTipNode)
  2018. }
  2019. else {
  2020. if (GameM.commonData.checkShowMainPop()) {
  2021. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2022. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2023. //唐僧天赋3
  2024. videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
  2025. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
  2026. videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
  2027. percent = Math.floor(percent * 100)
  2028. gift.init(MONEY_TYPE.mainBuyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent)
  2029. UiM.Instance.giftNode.x = 0
  2030. UiM.Instance.giftNode.active = true
  2031. }
  2032. else {
  2033. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2034. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2035. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
  2036. videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
  2037. //唐僧天赋3
  2038. videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
  2039. percent = Math.floor(percent * 100)
  2040. gift.init(MONEY_TYPE.gold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent)
  2041. UiM.Instance.giftNode.x = 1000
  2042. UiM.Instance.giftNode.active = true
  2043. GameM.adM.watchVideo(VIDEO_TYPE.buyCarMainBtn);
  2044. }
  2045. }
  2046. }
  2047. //判断是否可以购买车辆
  2048. this.updateBuyBtnState();
  2049. }
  2050. else {
  2051. EffectNode.instance.PlayTip("位置已满");
  2052. this.CheckNormalGuide()
  2053. }
  2054. }
  2055. resetFillRange() {
  2056. this.tixianFill.fillRange = 0
  2057. }
  2058. getDailyCar(carlv) {
  2059. let pos = this.getEmptySpace()
  2060. if (pos != '') {
  2061. this.addAParkCar(pos, carlv)
  2062. GameM.commonData.updateMaxCarLevel(carlv, true)
  2063. // let exp = GameM.commonData.carCfg[carlv.toString()].exp
  2064. // GameM.commonData.updateRoleDataExp(exp)
  2065. UiM.Instance.dailyNode.getComponent(Daily).hasOpen()
  2066. EffectNode.instance.PlayTip("武将已发放到位置");
  2067. }
  2068. else {
  2069. EffectNode.instance.PlayTip("位置已满,请空出位置再领");
  2070. }
  2071. }
  2072. getTaskAwardCar(carlv) {
  2073. let pos = this.getEmptySpace()
  2074. if (pos != '') {
  2075. this.addAParkCar(pos, carlv)
  2076. GameM.commonData.updateMaxCarLevel(carlv, true)
  2077. EffectNode.instance.PlayTip(`${carlv}级武将已发放`);
  2078. }
  2079. else {
  2080. EffectNode.instance.PlayTip("位置已满,请空出位置再领");
  2081. }
  2082. }
  2083. /** 看视频升级车成功 */
  2084. carLvUpVideoEnd() {
  2085. UiM.Instance.giftNode.active = false
  2086. EffectNode.instance.PlayTip("升级成功!");
  2087. GameM.commonData.updateBagCarData(this.lvupPos, this.lvupLv)
  2088. let space = this.CarPark.getChildByName(this.lvupPos)
  2089. let s = space.getComponent(CarSpace)
  2090. s.type = this.lvupLv
  2091. s.init()
  2092. let expPre = GameM.commonData.carCfg[this.lvupPreLv.toString()].exp
  2093. let exp = GameM.commonData.carCfg[this.lvupLv.toString()].exp
  2094. GameM.commonData.updateRoleDataExp(Sciencen_M.instance.subtraction(exp, expPre))
  2095. //西游
  2096. if (GameM.commonData.isUseXiYouAddCoin) {
  2097. this.addRunRole(this.lvupLv, s);
  2098. //s.AddCoinSpawn();
  2099. }
  2100. this.hideHandGuide()
  2101. this.CheckNormalGuide()
  2102. if (UiM.Instance.shopNode) {
  2103. UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.shopBuyCarType)
  2104. this.shopBuyCarType = 0
  2105. }
  2106. }
  2107. /**
  2108. * 判断是否有足够金币买车
  2109. * 显示按钮状态
  2110. */
  2111. updateBuyBtnState() {
  2112. //判断是否可以购买车辆
  2113. let nextPrice = GameM.commonData.getPriceByType(this.curBuyType);
  2114. if (Sciencen_M.instance.ContrastNumber(GameM.commonData.gold, nextPrice)) {
  2115. //显示购买按钮
  2116. this.btnBuy.getComponent(CarInfo).ShowBuyBtn();
  2117. } else {
  2118. //显示广告按钮
  2119. this.btnBuy.getComponent(CarInfo).ShowAdBtn();
  2120. }
  2121. }
  2122. /**显示或隐藏立即回收按钮*/
  2123. ActiceTrashState(active: boolean) {
  2124. if (GameM.commonData.step <= 3) {
  2125. return
  2126. }
  2127. if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0)
  2128. this.btnBuy.getComponent(CarInfo).ActiveTrasnBtn(active, GameM.commonData.carCfg[GameM.selCarMove.getComponent(CarMove).type.toString()].price);
  2129. }
  2130. private shopBuyCarType = 0
  2131. /** 购买指定车辆
  2132. * @param type 指定类型车
  2133. * @param buyMoney 0 金币 1 视频 2 红包币
  2134. */
  2135. onBuyTypeCar(type, buyMoney = 0) {
  2136. GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar)
  2137. let pos = this.getEmptySpace()
  2138. if (pos != '') {
  2139. if (buyMoney == 0) {
  2140. let price = GameM.commonData.getPriceByType(type)
  2141. if (GameM.commonData.updateGoldMinus(price)) {
  2142. this.addAParkCar(pos, type)
  2143. GameM.commonData.roleData.shopTotal++
  2144. // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
  2145. let exp = GameM.commonData.carCfg[type.toString()].exp
  2146. GameM.commonData.updateRoleDataExp(exp)
  2147. GameM.commonData.updateBuyTimeData(type, true)
  2148. GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold })
  2149. //购买次数修改
  2150. let times = LocalManagerData.Instance.getBuyCarData(type)
  2151. times++
  2152. LocalManagerData.Instance.saveBuyCarData(type, times)
  2153. UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type)
  2154. EffectNode.instance.PlayTip("购买成功");
  2155. //判断是否可以购买车辆
  2156. this.updateBuyBtnState();
  2157. } else {
  2158. // EffectNode.instance.PlayTip("金币不足,购买失败");
  2159. if (GameM.commonData.isVideoTest) {
  2160. if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
  2161. EffectNode.instance.PlayTip('金币不足,并且今日金币获取次数已用尽')
  2162. this.hideAllHand()
  2163. this.CheckNormalGuide()
  2164. }
  2165. else {
  2166. this.shopBuyCarType = type
  2167. UiM.Instance.checkDelayShow(() => {
  2168. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2169. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2170. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
  2171. videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
  2172. //唐僧天赋3
  2173. videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
  2174. percent = Math.floor(percent * 100)
  2175. gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent)
  2176. UiM.Instance.giftNode.x = 0
  2177. UiM.Instance.giftNode.active = true
  2178. })
  2179. }
  2180. }
  2181. else {
  2182. if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) {
  2183. EffectNode.instance.PlayTip('今日金币获取次数已用尽')
  2184. this.hideAllHand()
  2185. this.CheckNormalGuide()
  2186. }
  2187. else {
  2188. this.shopBuyCarType = type
  2189. UiM.Instance.checkDelayShow(() => {
  2190. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2191. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2192. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
  2193. videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
  2194. //唐僧天赋3
  2195. videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
  2196. percent = Math.floor(percent * 100)
  2197. gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent)
  2198. UiM.Instance.giftNode.x = 0
  2199. UiM.Instance.giftNode.active = true
  2200. })
  2201. }
  2202. }
  2203. }
  2204. }
  2205. else if (buyMoney == 1) {
  2206. //调取看视频接口
  2207. this.tempPos = pos
  2208. this.tempType = type
  2209. GameM.adM.watchVideo(VIDEO_TYPE.buyCar)
  2210. }
  2211. else if (buyMoney == 2) {
  2212. let price = GameM.commonData.getMoneyPriceBuyType(type)
  2213. if (GameM.commonData.updateRedMoney(-price, RecordTYPE.buyNewCar)) {
  2214. this.addAParkCar(pos, type)
  2215. GameM.commonData.roleData.shopTotal++
  2216. // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
  2217. let exp = GameM.commonData.carCfg[type.toString()].exp
  2218. GameM.commonData.updateRoleDataExp(exp)
  2219. GameM.commonData.updateBuyTimeData(type, true)
  2220. UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type)
  2221. EffectNode.instance.PlayTip("购买成功");
  2222. } else {
  2223. EffectNode.instance.PlayTip("红包币不足,购买失败");
  2224. }
  2225. }
  2226. }
  2227. else {
  2228. EffectNode.instance.PlayTip("位置已满");
  2229. this.CheckNormalGuide()
  2230. }
  2231. }
  2232. /**购买按钮视频广告回调*/
  2233. onBuyCarAdEnd() {
  2234. if (GameM.commonData.checkShowMainPop()) {
  2235. this.onGetGold()
  2236. }
  2237. else {
  2238. UiM.Instance.giftNode.active = true
  2239. UiM.Instance.giftNode.x = 0
  2240. AdM.showNative(0)
  2241. }
  2242. GameM.commonData.updateClickVideoTimes()
  2243. GameM.commonData.addDailyFinishTimesDataByType(7)
  2244. this.updateBuyBtnState();
  2245. }
  2246. onShopBuyCarAdEnd() {
  2247. this.onGetGold()
  2248. }
  2249. onGetGold() {
  2250. let key = 'dddddddddddddddddddddddddddddddd'
  2251. GameM.commonData.dayBuyCarVideoLimitTimes--
  2252. let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid)
  2253. GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1)
  2254. UiM.Instance.giftNode.active = false
  2255. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  2256. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2257. let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10))
  2258. videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString())
  2259. //唐僧天赋3
  2260. videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString()));
  2261. GameM.commonData.updateGold(videoPrice)
  2262. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  2263. EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
  2264. }
  2265. onBuyCarAdFail() {
  2266. // UiM.Instance.giftNode.active = false
  2267. // UiM.Instance.giftNode.x = 0
  2268. // AdM.destroyNative()
  2269. }
  2270. private tempType = 0
  2271. private tempPos = ''
  2272. onVideoBuyCarEnd() {
  2273. this.addAParkCar(this.tempPos, this.tempType)
  2274. GameM.commonData.roleData.shopTotal++
  2275. // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car')
  2276. let exp = GameM.commonData.carCfg[this.tempType.toString()].exp
  2277. GameM.commonData.updateRoleDataExp(exp)
  2278. GameM.commonData.updateBuyTimeData(this.tempType, true)
  2279. UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.tempType)
  2280. GameM.commonData.addDailyFinishTimesDataByType(7)
  2281. EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放");
  2282. }
  2283. /** 设置购买车信息 */
  2284. carBuyInfo() {
  2285. //console.log("---->BuyTimes:" + GameM.commonData.buyTimeTotal);
  2286. let info = this.btnBuy.getComponent(CarInfo)
  2287. let times = GameM.commonData.buyTimeTotal + 1
  2288. this.curBuyType = Number(GameM.commonData.buyNumCfg[times.toString()].car_level)
  2289. //TEST
  2290. if (GameM.commonData.IsTest)
  2291. this.curBuyType = GameM.commonData.maxCarLevel <= 0 ? 1 : GameM.commonData.maxCarLevel;
  2292. info.changeType(this.curBuyType)
  2293. }
  2294. /** 点击打开商店 */
  2295. clickOpenShop() {
  2296. AdM.onSendEvent('button_11', '妖洞icon', 'button')
  2297. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2298. UiM.Instance.onPanel(PANEL_NAME.ShopNode)
  2299. }
  2300. /** 点击打开设置 */
  2301. clickHead() {
  2302. AdM.onSendEvent('button_14', '头像icon', 'button')
  2303. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2304. UiM.Instance.onPanel(PANEL_NAME.SettingNode)
  2305. }
  2306. /** 打开转盘 */
  2307. clickTurntable() {
  2308. AdM.onSendEvent('button_10', '转盘icon', 'button')
  2309. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2310. if (GameM.commonData.maxCarLevel < GameM.commonData.turntableOpenLevel) {
  2311. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.turntableOpenLevel}级武将解锁`)
  2312. return
  2313. }
  2314. UiM.Instance.onPanel(PANEL_NAME.TurnTableNode)
  2315. }
  2316. /** 打开任务 */
  2317. clickTask() {
  2318. AdM.onSendEvent('button_7', '日常icon', 'button')
  2319. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2320. if (GameM.commonData.maxCarLevel < GameM.commonData.taskOpenLevel) {
  2321. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.taskOpenLevel}级武将解锁`)
  2322. return
  2323. }
  2324. UiM.Instance.taskNode.active = true;
  2325. }
  2326. /** 打开提现 */
  2327. clickCash() {
  2328. AdM.onSendEvent('button_15', '提现icon', 'button')
  2329. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2330. if (!GameM.commonData.redSwitch) {
  2331. EffectNode.instance.PlayTip('敬请期待')
  2332. return
  2333. }
  2334. if (GameM.commonData.maxCarLevel < GameM.commonData.cashOpenLevel) {
  2335. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.cashOpenLevel}级武将可查看`)
  2336. return
  2337. }
  2338. UiM.Instance.onPanel(PANEL_NAME.CashNode, true)
  2339. }
  2340. /** 打开投资 */
  2341. clickInvest() {
  2342. AdM.onSendEvent('button_12', '探索icon', 'button')
  2343. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2344. // //test
  2345. // UiM.Instance.onPanel(PANEL_NAME.InvestNode)
  2346. // return
  2347. //if (MateData.Ins.mateUnlockAry[3] == 0) {
  2348. if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) {
  2349. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.investOpenLevel}级武将解锁`)
  2350. return
  2351. }
  2352. UiM.Instance.onPanel(PANEL_NAME.InvestNode)
  2353. if (GameM.commonData.roleData.investGuide == 0) {
  2354. GameM.commonData.roleData.investGuide = 1
  2355. GameM.commonData.updateRoleData()
  2356. this.hideAllHand()
  2357. // UiM.Instance.guideNode.getComponent(Guide).showInvestStep2()
  2358. }
  2359. }
  2360. /** 打开保险箱 */
  2361. clickSafeBox() {
  2362. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2363. AdM.onSendEvent("button_8", "钱庄icon", 'button')
  2364. // if (MateData.Ins.mateUnlockAry[4] == 0) {
  2365. // EffectNode.instance.PlayTip('收服23级沙僧解锁')
  2366. // return
  2367. // }
  2368. if (GameM.commonData.maxCarLevel < GameM.commonData.richBankUnLockLevel) {
  2369. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.richBankUnLockLevel}级武将解锁`)
  2370. return
  2371. }
  2372. UiM.Instance.onPanel(PANEL_NAME.SafeDepositBox)
  2373. if (GameM.commonData.roleData.investGuide == 0) {
  2374. GameM.commonData.roleData.investGuide = 1
  2375. GameM.commonData.updateRoleData()
  2376. this.hideAllHand()
  2377. }
  2378. }
  2379. /** 每日豪礼 */
  2380. clickChat() {
  2381. AdM.onSendEvent('button_6', '登录奖励icon', 'button')
  2382. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2383. if (GameM.commonData.maxCarLevel < GameM.commonData.loginRewardOpenLevel) {
  2384. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.loginRewardOpenLevel}级武将解锁`)
  2385. return
  2386. }
  2387. UiM.Instance.onPanel(PANEL_NAME.DailyNode)
  2388. }
  2389. /**俱乐部 */
  2390. clickClubShare() {
  2391. AdM.onSendEvent('button_1', '师徒icon', 'button')
  2392. if (GameM.commonData.maxCarLevel < GameM.commonData.clubOpenLevel) {
  2393. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2394. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.clubOpenLevel}级武将解锁`)
  2395. return
  2396. }
  2397. if (GameM.commonData.isAuth) {
  2398. LogUtil.logV("ClubMain", "clickShare")
  2399. UiM.Instance.onPanel(PANEL_NAME.clubMainNode)
  2400. }
  2401. else {
  2402. AdM.WxLogin();
  2403. }
  2404. }
  2405. /**分享 */
  2406. clickShare() {
  2407. // AdM.onSendEvent('shareClick', '分享icon点击')
  2408. if (GameM.commonData.isAuth) {
  2409. AdM.sharePic();
  2410. }
  2411. else {
  2412. AdM.WxLogin();
  2413. }
  2414. }
  2415. clickAirship() {
  2416. AdM.onSendEvent('button_16', '空投icon', 'button')
  2417. GameM.audioM.playEffect(AUDIO_TYPE.Airship)
  2418. if (this.airshipUp) {
  2419. return
  2420. }
  2421. this.airshipAni.pause()
  2422. UiM.Instance.checkDelayShow(() => {
  2423. let data = this.curAirCfg
  2424. UiM.Instance.giftNode.active = true
  2425. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2426. let num = String(data.num)
  2427. if (data.reward == MONEY_TYPE.gold) {
  2428. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2429. num = Sciencen_M.instance.accMul(videoPrice, num)
  2430. }
  2431. gift.init(data.reward, num, null, true, data.is_video)
  2432. })
  2433. }
  2434. /** 随机一个新的热气球奖励 */
  2435. ranNewAirShip() {
  2436. this.getAirByRan()
  2437. let data = this.curAirCfg
  2438. UiM.Instance.giftNode.active = true
  2439. let gift = UiM.Instance.giftNode.getComponent(Gift)
  2440. let num = String(data.num)
  2441. if (data.reward == MONEY_TYPE.gold) {
  2442. let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold;
  2443. num = Sciencen_M.instance.accMul(videoPrice, num)
  2444. }
  2445. gift.init(data.reward, num, null, true, data.is_video)
  2446. }
  2447. /** 恢复飞艇飞行 */
  2448. resumeAirShip() {
  2449. if (this.airshipUp) {
  2450. return
  2451. }
  2452. this.airshipAni.resume()
  2453. }
  2454. /** 放弃飞艇 */
  2455. dropAirShip() {
  2456. this.airshipAni.stop()
  2457. this.airshipUp = true
  2458. EffectNode.instance.PlayTip('我会回来的!')
  2459. cc.tween(this.airshipAni.node)
  2460. .to(0.2, { scale: 0.6 })
  2461. .to(0.3, { scale: 1.2 })
  2462. .to(0.2, { scale: 1 })
  2463. .by(1, { x: -1000 }, cc.easeIn(3.0))
  2464. .call(() => {
  2465. this.airshipUp = false
  2466. this.checkShowAirship()
  2467. })
  2468. .start()
  2469. }
  2470. /** 每日提现 */
  2471. clickTixian() {
  2472. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2473. AdM.onSendEvent('button_4', '天天红包icon', 'button')
  2474. if (GameM.commonData.maxCarLevel < GameM.commonData.dailyCashOpenLevel) {
  2475. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.dailyCashOpenLevel}级武将解锁`)
  2476. return
  2477. }
  2478. UiM.Instance.redPackageNode.init(0, 0, 4, null, false)
  2479. UiM.Instance.redPackageNode.node.x = 0
  2480. UiM.Instance.redPackageNode.node.active = true
  2481. //西游
  2482. GameM.audioM.setPauseMusic();
  2483. GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm);
  2484. }
  2485. /** 检查提现进度 */
  2486. checkTixianPro(checkNew = false) {
  2487. if (checkNew) {
  2488. this.curCashCfg = null
  2489. }
  2490. if (!this.curCashCfg) {
  2491. let cfg = CashOutData.Instance.cashCft
  2492. let len = cfg.length
  2493. for (var i = 0; i < len; i++) {
  2494. if (CashOutData.Instance.getCashStatus(cfg[i].index) == 0) {
  2495. this.curCashCfg = cfg[i]
  2496. break
  2497. }
  2498. }
  2499. }
  2500. let money = this.curCashCfg.moneyshow.split('~')[1]
  2501. this.labTixian.string = `${money}`
  2502. //西游
  2503. this.labtargetCarLevel.string = GameM.commonData.fightRoleCfg[this.curCashCfg.type_value.toString()].name;
  2504. this.labTixianLv.string = this.curCashCfg.type_value.toString()
  2505. let pro = GameM.commonData.maxCarLevel / this.curCashCfg.type_value
  2506. this.tixianPro.fillRange = pro
  2507. this.tixianPercent.string = Math.floor(GameM.commonData.maxCarLevel / this.curCashCfg.type_value * 100) + "%"
  2508. if (pro >= 1) {
  2509. this.canGet.active = true
  2510. }
  2511. else {
  2512. this.canGet.active = false
  2513. }
  2514. if (pro >= 0.8) {
  2515. this.approachEff.active = true
  2516. }
  2517. else {
  2518. this.approachEff.active = false
  2519. }
  2520. if (checkNew) {
  2521. cc.loader.loadRes('carPic/side/side_' + this.curCashCfg.type_value.toString(), cc.SpriteFrame, (err, assets) => {
  2522. if (err) {
  2523. cc.error(err);
  2524. return;
  2525. }
  2526. this.spTixianCar.spriteFrame = assets
  2527. })
  2528. }
  2529. }
  2530. playCarProEff() {
  2531. // cc.loader.loadRes('carPic/side/side_' + GameM.commonData.maxCarLevel, cc.SpriteFrame, (err, assets) => {
  2532. // if (err) {
  2533. // cc.error(err);
  2534. // return;
  2535. // }
  2536. // this.carProSp.spriteFrame = assets
  2537. // // this.carProSp.node.setPosition(cc.v2(0, 0))
  2538. // this.carProSp.node.setPosition(GameM.selCarMove.position)
  2539. // this.carProSp.node.scale = 0.4
  2540. // this.carProSp.node.active = true
  2541. // cc.tween(this.carProSp.node).to(0.7, { position: this.tixianProBtn.node.position, scale: 0.4 })
  2542. // .call(() => {
  2543. // this.carProSp.node.active = false
  2544. // let nodeAnim = UiM.Instance.hallNode.getComponent(Main).tixianProBtn.node.getComponent(EachNodeAnim)
  2545. // nodeAnim.startChildAnim()
  2546. // this.scheduleOnce(() => {
  2547. // this.hallLabAddEff.play('upFadeC', 0)
  2548. // }, 0.4)
  2549. // // this.hallLabAddEff.play('upFadeC', 0)
  2550. // this.checkTixianPro()
  2551. // })
  2552. // .start()
  2553. // })
  2554. //改为飞红包
  2555. EffectNode.instance.PlayCoinAnim(14, 10, cc.v2(GameM.selCarMove.position.x, GameM.selCarMove.position.y), true,
  2556. cc.v2(this.tixianProBtn.node.position.x, this.tixianProBtn.node.position.y + this.topPart.y))
  2557. GameM.audioM.playEffect(AUDIO_TYPE.getGold)
  2558. cc.tween(this.tixianProBtn.node)
  2559. .delay(1)
  2560. .to(0.2, { scale: 1.2 })
  2561. .to(0.2, { scale: 1 })
  2562. .start()
  2563. this.checkTixianPro()
  2564. }
  2565. //-----现金夺宝功能----
  2566. private hasTap = false
  2567. clickTreasure() {
  2568. // //test
  2569. // EffectNode.instance.playEggIn()
  2570. // return
  2571. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2572. if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) {
  2573. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.trerasureOpenLevel}级武将解锁`)
  2574. return
  2575. }
  2576. AdM.onSendEvent('button_9', '现金icon', 'button')
  2577. if (!GameM.commonData.isAuth) {
  2578. if (!this.hasTap) {
  2579. console.log('clickGoAuth')
  2580. this.hasTap = true
  2581. AdM.WxLogin()
  2582. this.scheduleOnce(() => {
  2583. this.hasTap = false
  2584. }, 1)
  2585. }
  2586. }
  2587. else {
  2588. UiM.Instance.onPanel(PANEL_NAME.TreasureNode)
  2589. }
  2590. }
  2591. clickMoreGame() {
  2592. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2593. AdM.onSendEvent('button_3', '更多红包icon', 'button')
  2594. UiM.Instance.onPanel(PANEL_NAME.moreGameNode)
  2595. }
  2596. setUnlockBtnColor() {
  2597. if (GameM.commonData.maxCarLevel == GameM.commonData.dailyCashOpenLevel) {
  2598. //每日提现
  2599. this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel)
  2600. }
  2601. else if (GameM.commonData.maxCarLevel == GameM.commonData.investOpenLevel) {
  2602. //投资引导
  2603. this.unLockBtn(this.investBtn, GameM.commonData.cashOpenLevel)
  2604. InvestData.Instance.getInvestInfo()
  2605. // if (GameM.commonData.roleData.investGuide == 0) {
  2606. // UiM.Instance.guideNode.getComponent(Guide).showInvestStep1()
  2607. // }
  2608. }
  2609. else if (GameM.commonData.maxCarLevel == GameM.commonData.loginRewardOpenLevel) {
  2610. //登录豪礼
  2611. this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel)
  2612. }
  2613. else if (GameM.commonData.maxCarLevel == GameM.commonData.taskOpenLevel) {
  2614. //每日任务
  2615. this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel)
  2616. }
  2617. else if (GameM.commonData.maxCarLevel == GameM.commonData.trerasureOpenLevel) {
  2618. //现金夺宝
  2619. this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel)
  2620. } else if (GameM.commonData.maxCarLevel == GameM.commonData.richBankUnLockLevel) {
  2621. this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel)
  2622. }
  2623. }
  2624. /**
  2625. * 判断伙伴解锁按钮
  2626. */
  2627. checkMateLockBtn(mateData, unlockLv: number) {
  2628. if (mateData == 3) { //
  2629. this.unLockBtn(this.investBtn, 0, mateData)
  2630. } else if (mateData == 4) {
  2631. this.unLockBtn(this.bankBtn, 0, mateData)
  2632. }
  2633. }
  2634. /** 设置按钮解锁显示状态
  2635. * @param btn 按钮
  2636. * @param unlockLv 解锁等级
  2637. */
  2638. unLockBtn(btn: cc.Button, unlockLv: number, mateData = -1) {
  2639. let normal = btn.node.getChildByName('normal')
  2640. let lock = btn.node.getChildByName('lock')
  2641. if (mateData != -1) {
  2642. if (MateData.Ins.mateUnlockAry[mateData] == 1) {
  2643. normal.active = true
  2644. lock.active = false
  2645. } else {
  2646. normal.active = false
  2647. lock.active = true
  2648. let labLock = lock.getChildByName('labLock')
  2649. if (mateData == 3) {
  2650. labLock.getComponent(cc.Label).string = `收服八戒`
  2651. } else if (mateData == 4) {
  2652. labLock.getComponent(cc.Label).string = `收服沙僧`
  2653. }
  2654. }
  2655. return
  2656. }
  2657. if (GameM.commonData.maxCarLevel >= unlockLv) {
  2658. normal.active = true
  2659. lock.active = false
  2660. }
  2661. else {
  2662. normal.active = false
  2663. lock.active = true
  2664. let labLock = lock.getChildByName('labLock')
  2665. labLock.getComponent(cc.Label).string = `${unlockLv}级解锁`
  2666. }
  2667. }
  2668. //西游
  2669. /**战斗按钮*/
  2670. Click_FightBtn() {
  2671. AdM.onSendEvent('button_2', '降妖伏魔icon', 'button')
  2672. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2673. FightData.Ins.EnterFight();
  2674. }
  2675. /**伙伴按钮*/
  2676. Click_MateBtn() {
  2677. AdM.onSendEvent('button_13', '伙伴icon', 'button')
  2678. GameM.audioM.playEffect(AUDIO_TYPE.button);
  2679. UIMng.Ins.AsyncGetPanel(PanelType.MatePanel, (panel) => {
  2680. panel.OnEnter();
  2681. });
  2682. //UIMng.Ins.GetPanel(PanelType.MatePanel).OnEnter();
  2683. }
  2684. /**财神按钮*/
  2685. Click_WealthBtn() {
  2686. //console.log("-------------Max" + GameM.commonData.maxCarLevel + " unlock:" + GameM.commonData.unlockWealthLevel);
  2687. //RichManData.Ins.GetData();
  2688. AdM.onSendEvent(`button_17`, `财神icon点击`, 'button');
  2689. GameM.audioM.playEffect(AUDIO_TYPE.button)
  2690. if (!WealthData.Ins.isUnlock) {
  2691. EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`)
  2692. return
  2693. }
  2694. //if (GameM.commonData.maxCarLevel < GameM.commonData.unlockWealthLevel) {
  2695. // EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`)
  2696. // return
  2697. //}
  2698. WealthData.Ins.Click_MainWealthBtn();
  2699. }
  2700. Click_GetCoinBtn() {
  2701. UiM.Instance.onPanel(PANEL_NAME.CoinTipNode);
  2702. }
  2703. Click_RichManBtn() {
  2704. UIMng.Ins.AsyncGetPanel(PanelType.RichPanel, (panel) => {
  2705. panel.OnEnter();
  2706. });
  2707. //UIMng.Ins.GetPanel(PanelType.RichPanel).OnEnter();
  2708. AdM.onSendEvent(`button_18`, `取经icon点击`, 'button');
  2709. }
  2710. Click_AdRbBtn() {
  2711. //UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => {
  2712. // panel.OnEnter();
  2713. //});
  2714. //AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button');
  2715. //return;
  2716. if (GameM.commonData.isAuth) {
  2717. UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => {
  2718. panel.OnEnter();
  2719. });
  2720. }
  2721. else {
  2722. AdM.WxLogin();
  2723. }
  2724. AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button');
  2725. }
  2726. /**更新天赋详情*/
  2727. UpdateTalentDetaile() {
  2728. MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem);
  2729. }
  2730. private mateBaJiePos: cc.Vec2 = null;
  2731. /**
  2732. * 显示伙伴
  2733. */
  2734. DisplayMate() {
  2735. let num = MateData.Ins.GetUnlcokMateNum();
  2736. let posAry: cc.Vec2[];
  2737. let index = 0;
  2738. if (MateData.Ins.mateUnlockAry[2] == 0) {
  2739. //白龙马未解锁
  2740. } else {
  2741. //白龙马已解锁
  2742. }
  2743. if (num == 1 || num == 0) {
  2744. posAry = MateData.Ins.matePosAry1;
  2745. } else if (num == 2) {
  2746. if (MateData.Ins.mateUnlockAry[2] == 1)
  2747. posAry = MateData.Ins.matePosAry1;
  2748. else
  2749. posAry = MateData.Ins.matePosAry2;
  2750. } else if (num == 3) {
  2751. if (MateData.Ins.mateUnlockAry[2] == 1)
  2752. posAry = MateData.Ins.matePosAry3;
  2753. else
  2754. posAry = MateData.Ins.matePosAry4;
  2755. } else if (num == 4) {
  2756. if (MateData.Ins.mateUnlockAry[2] == 1)
  2757. posAry = MateData.Ins.matePosAry4;
  2758. else
  2759. posAry = MateData.Ins.matePosAry5;
  2760. } else if (num == 5) {
  2761. posAry = MateData.Ins.matePosAry5;
  2762. }
  2763. // console.log("---------------------> ", posAry);
  2764. //if (MateData.Ins.mateUnlockAry[2] == 1) {
  2765. // this.xiYou_mates[0].active = false;
  2766. // this.xiYou_mates[2].active = true;
  2767. // this.xiYou_mates[2].setPosition(posAry[index]);
  2768. //} else {
  2769. // this.xiYou_mates[0].active = true;
  2770. // this.xiYou_mates[2].active = false;
  2771. // this.xiYou_mates[0].setPosition(posAry[index]);
  2772. //}
  2773. //index++;
  2774. for (let i = 0; i < 5; i++) {
  2775. this.xiYou_mates[i].active = false;
  2776. if (MateData.Ins.mateUnlockAry[i] == 1) {
  2777. this.xiYou_mates[i].active = true;
  2778. // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x);
  2779. //if (i == 3)
  2780. // this.mateBaJiePos = posAry[index];
  2781. //this.xiYou_mates[i].setPosition(posAry[index]);
  2782. //index++;
  2783. }
  2784. //if (i != 0 && i != 2) {
  2785. // this.xiYou_mates[i].active = false;
  2786. // if (MateData.Ins.mateUnlockAry[i] == 1) {
  2787. // this.xiYou_mates[i].active = true;
  2788. // // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x);
  2789. // if (i == 3)
  2790. // this.mateBaJiePos = posAry[index];
  2791. // this.xiYou_mates[i].setPosition(posAry[index]);
  2792. // index++;
  2793. // }
  2794. //}
  2795. }
  2796. }
  2797. private isUpdateBg = true;
  2798. private bgPos: cc.Vec2 = cc.v2(-375, 310);
  2799. private bgBackPos: cc.Vec2 = cc.v2(-375, 310);
  2800. private mateBaTimer: number = 0;
  2801. private mateSunTimer: number = 0;
  2802. private mateBaIndex = 0;
  2803. private mateSunIndex = 0;
  2804. private mateBaUpdate1: boolean = false;
  2805. private mateBaPos: cc.Vec2 = cc.v2(-375, 310);
  2806. private mateBaAniTime: number[] = [3, 8, 11];
  2807. private mateSunAniTime: number[] = [2, 3, 4, 6, 7];
  2808. /**移动背景*/
  2809. MoveBg(dt) {
  2810. if (this.isUpdateBg) {
  2811. //三国战戟 不再移动背景
  2812. return;
  2813. this.bgPos.x -= dt * 100;
  2814. if (this.bgPos.x <= -1333) {
  2815. this.bgPos.x = -375;
  2816. }
  2817. this.bgBackPos.x -= dt * 50;
  2818. if (this.bgBackPos.x <= -1333) {
  2819. this.bgBackPos.x = -375;
  2820. }
  2821. this.xiYou_bgback.setPosition(this.bgBackPos);
  2822. //console.log("POS:",this.bgPos);
  2823. ////伙伴动画处理
  2824. //if (this.xiYou_mates[3].active) {
  2825. // this.mateBaTimer += dt;
  2826. //
  2827. //
  2828. // if (this.mateBaUpdate1) {
  2829. // this.mateBaPos.x -= dt * 100;
  2830. // this.xiYou_mates[3].setPosition(this.mateBaPos);
  2831. // }
  2832. //
  2833. // if (this.mateBaTimer > this.mateBaAniTime[this.mateBaIndex]) {
  2834. // if (this.mateBaIndex == 0) {
  2835. // //this.xiYou_spineBa.clearTrack(0);
  2836. // //this.xiYou_spineBa.setBonesToSetupPose();
  2837. // this.xiYou_spineBa.setAnimation(0, "fall", false);
  2838. // this.mateBaIndex++;
  2839. // this.scheduleOnce(() => {
  2840. // this.mateBaPos = this.xiYou_mates[3].getPosition();
  2841. // this.mateBaUpdate1 = true;
  2842. // }, 0.5)
  2843. // } else if (this.mateBaIndex == 1) {
  2844. // this.mateBaUpdate1 = false;
  2845. // //this.xiYou_spineBa.clearTrack(0);
  2846. // //this.xiYou_spineBa.setBonesToSetupPose();
  2847. // this.xiYou_spineBa.setAnimation(0, "run", true);
  2848. //
  2849. // cc.tween(this.xiYou_mates[3])
  2850. // .to(1, { position: this.mateBaJiePos })
  2851. // .call(() => {
  2852. // //this.xiYou_spineBa.clearTrack(0);
  2853. // //this.xiYou_spineBa.setBonesToSetupPose();
  2854. // this.xiYou_spineBa.setAnimation(0, "walk", true);
  2855. // })
  2856. // .start();
  2857. // this.mateBaIndex++;
  2858. // } else if (this.mateBaIndex == 2) {
  2859. // this.mateBaTimer = 0
  2860. // this.mateBaIndex = 0;
  2861. // }
  2862. // }
  2863. //}
  2864. //
  2865. //if (this.xiYou_mates[1]) {
  2866. // this.mateSunTimer += dt;
  2867. //
  2868. // if (this.mateSunTimer > this.mateSunAniTime[this.mateSunIndex]) {
  2869. // if (this.mateSunIndex == 0) {
  2870. // //this.xiYou_spineSun.clearTrack(0);
  2871. // //this.xiYou_spineSun.setBonesToSetupPose();
  2872. // this.xiYou_spineSun.setAnimation(0, "jump", false);
  2873. // this.mateSunIndex++;
  2874. // } else if (this.mateSunIndex == 1) {
  2875. // //this.xiYou_spineSun.clearTrack(0);
  2876. // //this.xiYou_spineSun.setBonesToSetupPose();
  2877. // this.xiYou_spineSun.setAnimation(0, "idle", true);
  2878. // this.mateSunIndex++;
  2879. // } else if (this.mateSunIndex == 2) {
  2880. // //this.xiYou_spineSun.clearTrack(0);
  2881. // //this.xiYou_spineSun.setBonesToSetupPose();
  2882. // this.xiYou_spineSun.setAnimation(0, "idle_ue", false);
  2883. // this.mateSunIndex++;
  2884. // } else if (this.mateSunIndex == 3) {
  2885. // //this.xiYou_spineSun.clearTrack(0);
  2886. // //this.xiYou_spineSun.setBonesToSetupPose();
  2887. // this.xiYou_spineSun.setAnimation(0, "jump down", false);
  2888. // this.mateSunIndex++;
  2889. // } else if (this.mateSunIndex == 4) {
  2890. // //this.xiYou_spineSun.clearTrack(0);
  2891. // //this.xiYou_spineSun.setBonesToSetupPose();
  2892. // this.xiYou_spineSun.setAnimation(0, "walk", true);
  2893. // this.mateSunTimer = 0;
  2894. // this.mateSunIndex = 0;
  2895. // }
  2896. // }
  2897. //}
  2898. }
  2899. }
  2900. private id = 1;
  2901. private bgIndex = 0;
  2902. UpdateMainBg() {
  2903. let bgCfg = GameM.commonData.mainBgCfg;
  2904. //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel);
  2905. for (let i = 0; i < bgCfg.length; i++) {
  2906. //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel + " CfgLv:" + bgCfg[i].maxLv + " Index:" + i);
  2907. if (GameM.commonData.maxCarLevel <= bgCfg[i].maxLv) {
  2908. this.ChangeBg(bgCfg[i].bgId, cc.color(bgCfg[i].color[0], bgCfg[i].color[1], bgCfg[i].color[2]))
  2909. return;
  2910. }
  2911. }
  2912. let len = bgCfg.length;
  2913. this.ChangeBg(bgCfg[len - 1].bgId, cc.color(bgCfg[len - 1].color[0], bgCfg[len - 1].color[1], bgCfg[len - 1].color[2]));
  2914. }
  2915. /**切换背景*/
  2916. ChangeBgSelf() {
  2917. //this.xiYou_spineBa.clearTrack(0);
  2918. //this.xiYou_spineBa.setBonesToSetupPose();
  2919. //this.xiYou_spineBa.setAnimation(0, "walk", true);
  2920. //this.scheduleOnce(()=>{
  2921. // this.xiYou_spineBa.clearTrack(0);
  2922. // this.xiYou_spineBa.setBonesToSetupPose();
  2923. // this.xiYou_spineBa.setAnimation(0, "fall", false);
  2924. // this.scheduleOnce(()=>{
  2925. // this.xiYou_spineBa.clearTrack(0);
  2926. // this.xiYou_spineBa.setBonesToSetupPose();
  2927. // this.xiYou_spineBa.setAnimation(0, "run", true);
  2928. // },1)
  2929. //},1)
  2930. this.UpdateMainBg();
  2931. //this.id++;
  2932. //this.bgIndex++;
  2933. //if (this.id > 8) this.id = 1;
  2934. //if (this.bgIndex > 7) this.id = 0;
  2935. ////this.id = this.id == 1 ? 2 : 1;
  2936. //this.ChangeBg(this.id,GameM.commonData.mainBgCfg[this.bgIndex]);
  2937. }
  2938. private xiYou_bgColors: cc.Color[] = [
  2939. cc.color(93, 75, 34),
  2940. cc.color(71, 96, 99),
  2941. cc.color(40, 65, 55),
  2942. cc.color(89, 43, 23),
  2943. cc.color(11, 69, 20),
  2944. cc.color(64, 22, 22),
  2945. cc.color(21, 101, 38),
  2946. cc.color(123, 116, 106)
  2947. ]
  2948. /**
  2949. * 更新背景
  2950. * @param bgId 背景id
  2951. */
  2952. ChangeBg(bgId: number, color: cc.Color) {
  2953. cc.loader.loadRes("maps/tucao_bg" + bgId, cc.SpriteFrame, (err, res2) => {
  2954. if (err) {
  2955. console.log("load xiYou bg back err:" + err + " id:" + bgId);
  2956. } else {
  2957. this.xiYou_bg.spriteFrame = res2;
  2958. this.xiYou_bg_bottom.color = color;
  2959. }
  2960. });
  2961. //cc.loader.loadRes("maps/xiyou_bgfront_" + bgId, cc.SpriteFrame, (err, res) => {
  2962. // if (err) {
  2963. // console.log("load xiYou bg err:" + err + " id:" + bgId);
  2964. // } else {
  2965. // cc.loader.loadRes("maps/xiyou_bgback_" + bgId, cc.SpriteFrame, (err, res2) => {
  2966. // if (err) {
  2967. // console.log("load xiYou bg back err:" + err + " id:" + bgId);
  2968. // } else {
  2969. // this.xiYou_bgUp.opacity = 0;
  2970. // for (let i = 0; i < this.xiYou_bgUpImgs.length; i++) {
  2971. // this.xiYou_bgUpImgs[i].spriteFrame = res;
  2972. // }
  2973. // this.xiYou_bgUpBottom.color = color;
  2974. // cc.tween(this.xiYou_bgUp).to(0.7, { opacity: 255 })
  2975. // .call(() => {
  2976. // for (let i = 0; i < this.xiYou_bgImgs.length; i++) {
  2977. // this.xiYou_bgImgs[i].spriteFrame = res;
  2978. // }
  2979. // this.xiYou_bgBottom.color = color;
  2980. // })
  2981. // .start();
  2982. // cc.tween(this.xiYou_bgDown).to(0.7, { opacity: 0 })
  2983. // .call(() => {
  2984. // this.xiYou_bgDown.opacity = 255;
  2985. // })
  2986. // .start();
  2987. //
  2988. //
  2989. // this.xiYou_bgBackUp.opacity = 0;
  2990. // for (let i = 0; i < this.xiYou_bgBackUpImgs.length; i++) {
  2991. // this.xiYou_bgBackUpImgs[i].spriteFrame = res2;
  2992. // }
  2993. // cc.tween(this.xiYou_bgBackUp).to(0.7, { opacity: 255 })
  2994. // .call(() => {
  2995. // for (let i = 0; i < this.xiYou_bgBackImgs.length; i++) {
  2996. // this.xiYou_bgBackImgs[i].spriteFrame = res2;
  2997. // }
  2998. // })
  2999. // .start();
  3000. // cc.tween(this.xiYou_bgBackDown).to(0.7, { opacity: 0 })
  3001. // .call(() => {
  3002. // this.xiYou_bgBackDown.opacity = 255;
  3003. // })
  3004. // .start();
  3005. // }
  3006. // });
  3007. // }
  3008. //});
  3009. }
  3010. private isOpenNormalGuide = true;
  3011. private carSpaceNum = 15;
  3012. /**是否有可合成的武将*/
  3013. private guideHaveCompose = false;
  3014. /**是否有金币*/
  3015. private guideHaveCoin = false;
  3016. /**是否有宝箱*/
  3017. private guideHaveBox = false;
  3018. /**是否有多余空位*/
  3019. private guideHaveEmpty = false;
  3020. /**主界面常规引导*/
  3021. CheckNormalGuide() {
  3022. if (this.isOpenNormalGuide && !GuideMng.Ins.IsGuideing) {
  3023. this.guideHaveCompose = false;
  3024. this.guideHaveCoin = false;
  3025. this.guideHaveBox = false;
  3026. let otherItem: cc.Node = null;
  3027. let other2Item: cc.Node = null;
  3028. let item1: cc.Node = null;
  3029. let item2: cc.Node = null;
  3030. let temp1 = null;
  3031. let temp2 = null;
  3032. let s1: CarSpace = null;
  3033. let s2: CarSpace = null;
  3034. let curMaxlv = 0;
  3035. let curMinlv = 100;
  3036. for (let i = 0; i < this.carSpaceNum; i++) {
  3037. temp1 = this.CarPark.getChildByName(i.toString())
  3038. s1 = temp1.getComponent(CarSpace)
  3039. if (s1.type == 10001) {
  3040. if (!this.guideHaveCoin) {
  3041. this.guideHaveCoin = true;
  3042. otherItem = temp1;
  3043. }
  3044. }
  3045. if (s1.type == 10004) {
  3046. if (!this.guideHaveCoin && !this.guideHaveBox) {
  3047. this.guideHaveBox = true;
  3048. otherItem = temp1;
  3049. }
  3050. }
  3051. if (s1.type > 0 && s1.type < 10000) {
  3052. if (!this.guideHaveCoin && !this.guideHaveBox) {
  3053. if (s1.type > curMaxlv && s1.CheckIsStrike()) {
  3054. curMaxlv = s1.type;
  3055. otherItem = temp1;
  3056. }
  3057. if (s1.type <= curMinlv) {
  3058. curMinlv = s1.type;
  3059. other2Item = temp1;
  3060. }
  3061. }
  3062. }
  3063. if (s1.type > 10000 || s1.type == 0) {
  3064. continue
  3065. }
  3066. item1 = temp1;
  3067. for (var j = i + 1; j < this.carSpaceNum; j++) {
  3068. temp2 = this.CarPark.getChildByName(j.toString())
  3069. s2 = temp2.getComponent(CarSpace)
  3070. if (s1.type == s2.type) {
  3071. item2 = temp2
  3072. this.guideHaveCompose = true;
  3073. break
  3074. }
  3075. }
  3076. if (this.guideHaveCompose) {
  3077. break
  3078. }
  3079. }
  3080. if (this.guideHaveCompose) {
  3081. if (item1 == null || item2 == null) return;
  3082. this.xiyou_guide_click.active = false;
  3083. this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1));
  3084. this.xiyou_guide_drag.active = true;
  3085. this.xiyou_guide_drag.stopAllActions();
  3086. let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(item2));
  3087. let f2 = cc.delayTime(0.5);
  3088. let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1)) });
  3089. let f = cc.sequence(f1, f2, f3).repeatForever();
  3090. this.xiyou_guide_drag.runAction(f);
  3091. } else {
  3092. if (this.guideHaveCoin) {
  3093. this.xiyou_guide_drag.active = false;
  3094. this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
  3095. this.xiyou_guide_click.active = true;
  3096. } else {
  3097. if (this.guideHaveBox) {
  3098. this.xiyou_guide_drag.active = false;
  3099. this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
  3100. this.xiyou_guide_click.active = true;
  3101. } else {
  3102. //判断是否有多余空位
  3103. if (this.IsHaveEmptySpace()) {
  3104. let nextPrice = GameM.commonData.getPriceByType(this.curBuyType);
  3105. let need = Sciencen_M.instance.subtraction(nextPrice, GameM.commonData.gold)
  3106. if (need[0] == '-') {
  3107. //今日视频次数没达到上限
  3108. if (GameM.commonData.dayBuyCarVideoLimitTimes > 0) {
  3109. this.xiyou_guide_drag.active = false;
  3110. this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy));
  3111. this.xiyou_guide_click.active = true;
  3112. }
  3113. else {
  3114. //引导点击未罢工的最高级武将
  3115. if (curMaxlv != 0) {
  3116. this.xiyou_guide_drag.active = false;
  3117. this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem));
  3118. this.xiyou_guide_click.active = true;
  3119. } else {
  3120. this.xiyou_guide_drag.stopAllActions();
  3121. this.xiyou_guide_drag.active = false;
  3122. this.xiyou_guide_click.active = false;
  3123. }
  3124. }
  3125. } else {
  3126. this.xiyou_guide_drag.active = false;
  3127. this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy));
  3128. this.xiyou_guide_click.active = true;
  3129. }
  3130. } else {
  3131. //无多余空位
  3132. if (curMinlv != 100) {
  3133. this.xiyou_guide_click.active = false;
  3134. this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item));
  3135. this.xiyou_guide_drag.active = true;
  3136. this.xiyou_guide_drag.stopAllActions();
  3137. let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(this.btnBuy));
  3138. let f2 = cc.delayTime(0.5);
  3139. let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item)) });
  3140. let f = cc.sequence(f1, f2, f3).repeatForever();
  3141. this.xiyou_guide_drag.runAction(f);
  3142. } else {
  3143. this.xiyou_guide_drag.stopAllActions();
  3144. this.xiyou_guide_drag.active = false;
  3145. this.xiyou_guide_click.active = false;
  3146. }
  3147. }
  3148. }
  3149. }
  3150. }
  3151. } else {
  3152. this.xiyou_guide_drag.stopAllActions();
  3153. this.xiyou_guide_drag.active = false;
  3154. this.xiyou_guide_click.active = false;
  3155. }
  3156. }
  3157. /**
  3158. * 改变常规引导状态
  3159. * @param state 状态 1 开启 0 关闭
  3160. */
  3161. ChangeNormalGuideState(state: number) {
  3162. if (state == 1) {
  3163. this.isOpenNormalGuide = true;
  3164. } else {
  3165. this.isOpenNormalGuide = false;
  3166. this.xiyou_guide_drag.stopAllActions();
  3167. this.xiyou_guide_drag.active = false;
  3168. this.xiyou_guide_click.active = false;
  3169. }
  3170. }
  3171. /** 检查显示彩蛋返回
  3172. * @param type 彩蛋类型 1 投放彩蛋 2 常规彩蛋 3 裂变彩蛋
  3173. */
  3174. showCaidan(type) {
  3175. this.caidanBtn.node.y = 202.2
  3176. this.caidanBtn.node.active = true
  3177. this.spCaidan.node.active = false
  3178. this.newdan1.active = true
  3179. if (type != 1) {
  3180. this.labCaidanCount.node.parent.active = false
  3181. }
  3182. }
  3183. /** 点击彩蛋 */
  3184. clickCaidan() {
  3185. GameM.audioM.playEffect(AUDIO_TYPE.button)
  3186. AdM.onSendEvent('button_5', '彩蛋icon', 'button')
  3187. if (UsualCaidanData.Instance.userUsualEggInfo.isTodayFinished == 1) {
  3188. if (GameM.commonData.roleData.canDailyCash == 1) {
  3189. EffectNode.instance.PlayTip('今日已经领取三个彩蛋奖励了,请明天再来')
  3190. }
  3191. else {
  3192. EffectNode.instance.PlayTip('每日提现后开启!')
  3193. }
  3194. }
  3195. else {
  3196. if (UsualCaidanData.Instance.userUsualEggInfo.isEnd == 0) {
  3197. this.caidanHand.active = false
  3198. UiM.Instance.onPanel(PANEL_NAME.UsualCaidanNode, false, () => {
  3199. UiM.Instance.usualCaidanNode.getComponent(UsualCaidanNode).init()
  3200. })
  3201. }
  3202. }
  3203. }
  3204. /** 彩蛋飞走 */
  3205. caidanFlyAway() {
  3206. cc.tween(this.caidanBtn.node)
  3207. .to(1, { y: 1000 })
  3208. .call(() => {
  3209. this.caidanBtn.node.active = false
  3210. LogUtil.logV('UsualCaidan ', "彩蛋消失4 ")
  3211. })
  3212. .start()
  3213. }
  3214. /** 获取彩蛋效果 */
  3215. caiDanEff() {
  3216. this.caidanBtn.node.active = true
  3217. this.labCaidanCount.node.parent.active = false
  3218. this.spCaidan.node.active = true
  3219. this.newdan1.active = false
  3220. this.spCaidan.node.scale = 1
  3221. let parPos = this.caidanBtn.node.position
  3222. this.spCaidan.node.setPosition(-parPos.x, -parPos.y + 110)
  3223. cc.tween(this.spCaidan.node)
  3224. .to(1, { position: cc.v2(0, 18), scale: 0.5 })
  3225. .call(() => {
  3226. // if (CaiDanData.Instance.leftTime > 0) {
  3227. // this.labCaidanCount.node.parent.active = true
  3228. // }
  3229. // else {
  3230. // this.labCaidanCount.node.parent.active = false
  3231. // }
  3232. this.labCaidanCount.node.parent.active = false
  3233. this.spCaidan.node.active = false
  3234. this.newdan1.active = true
  3235. })
  3236. .start()
  3237. }
  3238. // caiDanCount() {
  3239. // CaiDanData.Instance.leftTime--
  3240. // this.labCaidanCount.string = utils.ParseTime2Format(CaiDanData.Instance.leftTime)
  3241. // if (CaiDanData.Instance.leftTime <= 0) {
  3242. // this.caidanBtn.node.active = false
  3243. // this.unschedule(this.caiDanCount)
  3244. // }
  3245. // }
  3246. //财神降临
  3247. TimerWealthCooling() {
  3248. if (WealthData.Ins.wealthInfo != null) {
  3249. if (WealthData.Ins.wealthInfo.wealthGodStatus == 1) {
  3250. if (WealthData.Ins.coolingTimer > 0) {
  3251. this.txt_wealthCoolTimer.string = MyExtends.TimeToFormat(WealthData.Ins.coolingTimer, 3);
  3252. }
  3253. else {
  3254. this.txt_wealthCoolTimer.string = ""
  3255. }
  3256. }
  3257. else {
  3258. this.txt_wealthCoolTimer.string = ""
  3259. }
  3260. }
  3261. else {
  3262. this.txt_wealthCoolTimer.string = ""
  3263. }
  3264. }
  3265. RichManInit() {
  3266. this.richmanBtn.active = RichData.Ins.richCfg.richmanopen == 1;
  3267. this.UpdateRichManQipao();
  3268. }
  3269. UpdateRichManQipao() {
  3270. this.richBtnQipao.active = RichData.Ins.diceTotalNum > 0;
  3271. this.richQipaoTxt.string = RichData.Ins.diceTotalNum + "";
  3272. }
  3273. isgamepause: boolean = false;
  3274. onKeyDown(event: cc.Event.EventKeyboard) {
  3275. switch (event.keyCode) {
  3276. case cc.macro.KEY.space:
  3277. if (this.isgamepause) {
  3278. cc.game.resume();
  3279. this.isgamepause = false;
  3280. } else {
  3281. cc.game.pause();
  3282. this.isgamepause = true;
  3283. }
  3284. break;
  3285. }
  3286. }
  3287. setGuideInstallVisible(active) {
  3288. this.guideInstallBtn.node.active = active
  3289. }
  3290. /** 打开引导安装 */
  3291. clickGuideInstall() {
  3292. GameM.audioM.playEffect(AUDIO_TYPE.button);
  3293. AdM.onSendEvent('button_19', '宝葫芦icon点击', 'button')
  3294. UiM.Instance.onPanel(PANEL_NAME.GuideInstallApkNode)
  3295. }
  3296. /** 检查是否显示宝葫芦 */
  3297. checkShowGuideInstall() {
  3298. if (DownloadApkData.Instance.installSwitch && GameM.commonData.isAuth) {
  3299. AdM.checkPathApk()
  3300. //定时检查是否有新安装包
  3301. this.schedule(() => {
  3302. if (!this.guideInstallBtn.node.active) {
  3303. AdM.checkPathApk()
  3304. }
  3305. }, 60)
  3306. }
  3307. }
  3308. /**
  3309. * 检查是否有礼包兑换
  3310. */
  3311. CheckRedeem() {
  3312. HttpM.Instance.SendData(HTTP_TYPE.redeemGetRedemption, {}, (res) => {
  3313. console.log("--->RedeemGift:", res);
  3314. if (res.data != null && res.errcode == 0) {
  3315. GameM.commonData.redeemData = res.data;
  3316. this.redeemBtn.active = res.data.code == 1;
  3317. }
  3318. });
  3319. }
  3320. Click_RedeemBtn() {
  3321. UiM.Instance.onPanel(PANEL_NAME.RedeemNode);
  3322. GameM.audioM.playEffect(AUDIO_TYPE.button);
  3323. AdM.onSendEvent('button_20', '兑换码icon点击', 'button')
  3324. }
  3325. CheckAdRb() {
  3326. this.adRbBtn.active = GameM.commonData.globalCfg.VideoRedBagOpen == 1;
  3327. }
  3328. /** 设置更多游戏图片 */
  3329. setMoreGameSp(arr) {
  3330. let len = arr.length
  3331. let index = Utils.rnd(0, len - 1)
  3332. let data = arr[index]
  3333. this.showMoreGameSp(data)
  3334. this.schedule(() => {
  3335. index++
  3336. index = (index % len)
  3337. LogUtil.logV('setMoreGameSp ', 'index ' + index)
  3338. data = arr[index]
  3339. this.showMoreGameSp(data)
  3340. }, 10)
  3341. }
  3342. showMoreGameSp(data) {
  3343. cc.loader.load(data.icon, (err, res) => {
  3344. if (err) {
  3345. console.log('err:', err);
  3346. return;
  3347. }
  3348. if (this.spMoregame) {
  3349. let tex: cc.Texture2D = res as cc.Texture2D;
  3350. this.spMoregame.spriteFrame = new cc.SpriteFrame(tex);
  3351. }
  3352. })
  3353. this.labMoregame.string = data.title
  3354. }
  3355. /** 是否显示常规提现、每日提现、钱庄按钮 */
  3356. checkShowCashBtns() {
  3357. if (GameM.commonData.loginDays == 1 || (CashOutData.Instance.cashStatus.length + DailyCashData.Instance.dailyCashStatus.length) <= 0) {
  3358. }
  3359. else {
  3360. if (GameM.commonData.cashStateBtnsArr[0] == '1') {
  3361. this.tixianProBtn.node.active = true
  3362. }
  3363. else {
  3364. this.tixianProBtn.node.active = false
  3365. }
  3366. if (GameM.commonData.cashStateBtnsArr[1] == '1') {
  3367. this.dailyCashBtn.node.active = true
  3368. }
  3369. else {
  3370. this.dailyCashBtn.node.active = false
  3371. }
  3372. if (GameM.commonData.cashStateBtnsArr[2] == '1') {
  3373. this.bankBtn.node.active = true
  3374. }
  3375. else {
  3376. this.bankBtn.node.active = false
  3377. }
  3378. }
  3379. }
  3380. }