avk_body.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210
  1. function avk_start()
  2. {
  3. var sgLangs = SG.lang;
  4. setTimeout("window.scrollTo(0, 1)", 10);
  5. function gl_vars()
  6. {
  7. this.TUTOR=0;
  8. this.HEART=false;
  9. this.MAX_PROG=false;
  10. this.TUTOR_STEPS=[2000,1000000,5000];
  11. this.CLEAR_DATA=false;
  12. this.FINISH=true;
  13. this.RUN=false;
  14. this.PATH_POINTS=1000;
  15. this.PAUSE=false;
  16. this.D=0;
  17. this.X=0;
  18. this.INSERTS=250;
  19. this.BACK_A=1/1000;
  20. this.HS=2;
  21. this.VS=2;
  22. this.BS=0.15;
  23. this.COLORS=[false,false,false,false,false,false,false];
  24. this.BULLET=null;
  25. this.BALLS=null;
  26. this.LENGTH=0;
  27. this.BACK_SPRITE=null;
  28. this.SPRITE=null;
  29. this.OSKOLKI=new Array();
  30. this.KILLED=new Array();
  31. this.MUL=0;
  32. this.SCORE=0;
  33. this.CURRENT_SCORE=0;
  34. this.WIN_PROGRESS=3;
  35. this.TR_1=0;
  36. this.TR_2=0;
  37. this.TR_3=0;
  38. this.TR=0;
  39. this.LEVELS=[-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2];
  40. this.PROGRESS=[];
  41. this.CLOUDS=[];
  42. this.TIME=0;
  43. this.STAT= [{start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  44. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  45. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  46. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  47. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  48. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  49. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  50. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  51. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  52. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  53. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  54. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  55. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  56. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  57. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  58. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  59. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  60. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0},
  61. {start_cnt:0,win_cnt:0,win_time:0,win_score:0,win_next:0,win_emprove_cnt:0,loose_cnt:0,loose_time:0,loose_score:0,loose_refresh:0,loose_emprove_cnt:0}]
  62. this.SHOW_HANDLER=null;
  63. this.WND_GAME=null;
  64. this.LOG=function(txt)
  65. {
  66. game.MAIN.txt_log.set_text(game.MAIN.txt_log.caption+"\n"+txt);
  67. game.MAIN.txt_log.sprite.position.y=game.MAIN.txt_log.y+(game.MAIN.log_place.uni_height-game.MAIN.txt_log.txt.textHeight);
  68. game.MAIN.txt_log.txt.position.y=0;
  69. }
  70. var tk=(new Date()).getTime();
  71. this.FUNC=function(txt)
  72. {
  73. var tm = (new Date()).getTime();
  74. game.MAIN.txt_log.set_text(game.MAIN.txt_log.caption+"\n"+txt+"["+(tm-tk)+"]");
  75. tk=tm;
  76. game.MAIN.txt_log.sprite.position.y=game.MAIN.txt_log.y+(game.MAIN.log_place.uni_height-game.MAIN.txt_log.txt.textHeight);
  77. game.MAIN.txt_log.txt.position.y=0;
  78. }
  79. }
  80. var GLOBAL=new gl_vars();
  81. var that = this;
  82. var order = [];
  83. var to_update = [];
  84. var game = new AVK_GAME(init,update,event);
  85. var actions={ pr:{pause:0,time:350,changes:{prop:{beg:0,end:1,trans:"sqrt"}}},
  86. to_left:{pause:0,time:350,changes:{global_x:{beg:0,end:-1,trans:"sqrt"}}},
  87. from_right:{pause:0,time:350,changes:{global_x:{beg:1,end:0,trans:"sqrt"}}},
  88. to_right:{pause:0,time:350,changes:{global_x:{beg:0,end:1,trans:"sqrt"}}},
  89. alpha:{pause:0,time:1000,changes:{alpha:{beg:0,end:1,trans:"lin"}}},
  90. tutor_alpha:{pause:0,time:350,changes:{alpha:{beg:0,end:1,trans:"lin"}}},
  91. tutor_alpha_hide:{pause:0,time:350,changes:{alpha:{beg:1,end:0,trans:"lin"}}},
  92. light:{pause:0,time:500,changes:{prop:{beg:0,end:1,trans:"lin"}}},
  93. hide:{pause:0,time:1000,changes:{prop:{beg:0,end:1,trans:"n2"}}},
  94. show:{pause:0,time:700,changes:{prop:{beg:0,end:1,trans:"n2"}}},
  95. from_up:{pause:0,time:350,changes:{global_y:{beg:-1,end:0,trans:"sqrt"}}},
  96. show_zw:{pause:350,time:1000,changes:{prop:{beg:0,end:1,trans:"lin"}}},
  97. ui_scale:{pause:0,time:1000,changes:{prop:{beg:0,end:Math.PI*2,trans:"sin"}}},
  98. from_left:{pause:0,time:350,changes:{global_x:{beg:-1,end:0,trans:"sqrt"}}}
  99. };
  100. function show_wnd_right(wnd)
  101. {
  102. game.GUI_BUSY=true;
  103. order.push(wnd);
  104. wnd.sprite.visible = true;
  105. game.ACT.start("from_left",wnd);
  106. game.ACT.start("to_right",order[order.length-2],hide_old);
  107. }
  108. function show_wnd_left(wnd)
  109. {
  110. game.GUI_BUSY=true;
  111. order.push(wnd);
  112. wnd.sprite.visible = true;
  113. game.ACT.start("from_right",wnd,on_show);
  114. game.ACT.start("to_left",order[order.length-2],hide_old);
  115. }
  116. function hide_wnd_right()
  117. {
  118. game.GUI_BUSY=true;
  119. order[order.length-2].sprite.visible = true;
  120. game.ACT.start("from_right",order[order.length-2]);
  121. game.ACT.start("to_left",order[order.length-1],hide_old);
  122. order.pop();
  123. }
  124. function hide_wnd_left()
  125. {
  126. game.GUI_BUSY=true;
  127. order[order.length-2].sprite.visible = true;
  128. game.ACT.start("from_left",order[order.length-2]);
  129. game.ACT.start("to_right",order[order.length-1],hide_old);
  130. order.pop();
  131. }
  132. function on_show()
  133. {
  134. if (GLOBAL.SHOW_HANDLER!=null)
  135. {
  136. GLOBAL.SHOW_HANDLER();
  137. GLOBAL.SHOW_HANDLER=null;
  138. }
  139. }
  140. function hide_old(wnd)
  141. {
  142. game.GUI_BUSY=false;
  143. PAUSE=false;
  144. wnd.sprite.visible = false;
  145. }
  146. function convert(value)
  147. {
  148. var s = "";
  149. var t = 0;
  150. value=""+value;
  151. for (var i = value.length - 1; i >= 0; i--)
  152. {
  153. if (t == 3)
  154. {
  155. t = 0;
  156. s = " " + s;
  157. }
  158. if ((value.charAt(i) != "0") && (value.charAt(i) != "1") && (value.charAt(i) != "2") && (value.charAt(i) != "3") && (value.charAt(i) != "4") && (value.charAt(i) != "5") && (value.charAt(i) != "6") && (value.charAt(i) != "7") && (value.charAt(i) != "8") && (value.charAt(i) != "9"))
  159. return value;
  160. s = value.charAt(i) + s;
  161. t++;
  162. }
  163. return s;
  164. }
  165. function AVK_CONTAINER()
  166. {
  167. var cnt=0;
  168. var maked_objects={};
  169. var here=this;
  170. this.init=function(obj,place)
  171. {
  172. obj.active=1;
  173. obj.sprite.visible=true;
  174. if (place!=null)
  175. place.add(obj);
  176. return obj;
  177. }
  178. this.free=function(obj)
  179. {
  180. obj.active=0;
  181. obj.sprite.visible=false;
  182. if (obj.sprite.parent!=null)
  183. obj.sprite.parent.removeChild(obj.sprite);
  184. return obj;
  185. }
  186. this.get_object=function(owner,prototype,place,heap)
  187. {
  188. if (maked_objects[owner+"_"+prototype]==null)
  189. maked_objects[owner+"_"+prototype]=[];
  190. var tmp_array=maked_objects[owner+"_"+prototype];
  191. for (var i=0;i<tmp_array.length;i++)
  192. {
  193. var tmp_res=tmp_array[i];
  194. if (tmp_res.active<=0)
  195. return here.init(tmp_res,place);
  196. }
  197. if (tmp_array.length==0)
  198. {
  199. tmp_res=game[owner][prototype];
  200. tmp_res.ID=0;
  201. tmp_array.push(tmp_res);
  202. return here.init(tmp_res,place);
  203. }else
  204. {
  205. tmp_res=tmp_array[tmp_array.length-1].make_copy();
  206. tmp_array.push(tmp_res);
  207. return here.init(tmp_res,place);
  208. }
  209. }
  210. }
  211. var CONTAINER=new AVK_CONTAINER();
  212. function is_snd()
  213. {
  214. return game.GAME.btn_no_snd.sprite.visible;
  215. }
  216. function change_snd()
  217. {
  218. if (GLOB_M)
  219. {
  220. game.GAME.btn_snd.sprite.visible=!game.GAME.btn_snd.sprite.visible;
  221. game.MAIN.btn_snd.sprite.visible=!game.MAIN.btn_snd.sprite.visible;
  222. game.GAME.btn_no_snd.sprite.visible=!game.GAME.btn_no_snd.sprite.visible;
  223. game.MAIN.btn_no_snd.sprite.visible=!game.MAIN.btn_no_snd.sprite.visible;
  224. GLOB_in_menu.stop();
  225. GLOB_in_game.stop();
  226. if (is_snd())
  227. if (order.length==1)
  228. GLOB_in_menu.play("none",0,0,-1);
  229. else
  230. GLOB_in_game.play("none",0,0,-1);
  231. }else
  232. {
  233. game.GAME.btn_snd.sprite.visible=false;
  234. game.MAIN.btn_snd.sprite.visible=false;
  235. game.GAME.btn_no_snd.sprite.visible=false;
  236. game.MAIN.btn_no_snd.sprite.visible=false;
  237. }
  238. }
  239. function save()
  240. {
  241. try
  242. {
  243. localStorage.avk_maya_data=GLOBAL.LEVELS;
  244. } catch(e) {};
  245. }
  246. function load_stat()
  247. {
  248. }
  249. function save_stat()
  250. {
  251. }
  252. function init_select()
  253. {
  254. try
  255. {
  256. if ((typeof(localStorage.avk_maya_data)=='undefined')||(GLOBAL.CLEAR_DATA))
  257. {
  258. localStorage.avk_maya_data=GLOBAL.LEVELS;
  259. }
  260. var n=0;
  261. var t=0;
  262. var s=localStorage.avk_maya_data+",";
  263. for (var i=0;i<s.length;i++)
  264. {
  265. if(s[i]==",")
  266. {
  267. GLOBAL.LEVELS[t]=(s.substring(n,i)/1);
  268. n=i+1;
  269. t++;
  270. }
  271. }
  272. } catch(e) {};
  273. var last=null;
  274. for (var i=18;i>=0;i--)
  275. {
  276. var prg=GLOBAL.PROGRESS[i];
  277. prg.prg_2.sprite.visible=(GLOBAL.LEVELS[i]>2);
  278. prg.prg_1.sprite.visible=(GLOBAL.LEVELS[i]>1);
  279. prg.prg_0.sprite.visible=(GLOBAL.LEVELS[i]>0);
  280. prg.prg_back.sprite.visible=(GLOBAL.LEVELS[i]>-1);
  281. prg.prg_close.sprite.visible=(GLOBAL.LEVELS[i]==-2);
  282. game.MAIN["btn_lev_"+i].enabled=(!prg.prg_close.sprite.visible);
  283. if ((last==null)&&(game.MAIN["btn_lev_"+i].enabled))
  284. last=game.MAIN["btn_lev_"+i]
  285. }
  286. if (GLOBAL.WND_GAME.scle_btn.targ!=null)
  287. {
  288. GLOBAL.WND_GAME.scle_btn.targ.sprite.scale.x=1;
  289. GLOBAL.WND_GAME.scle_btn.targ.sprite.scale.y=1;
  290. }
  291. if (last.sprite.anchor.x!=0.5)
  292. {
  293. last.sprite.anchor.x=0.5;
  294. last.sprite.anchor.y=0.5;
  295. last.sprite.position.x+=0.5*last.uni_width;
  296. last.sprite.position.y+=0.5*last.uni_height;
  297. last.refresh();
  298. }
  299. GLOBAL.WND_GAME.scle_btn.targ=last;
  300. }
  301. function init()
  302. {
  303. if (GLOB_M)
  304. {
  305. if (GLOB_ball==0)
  306. GLOB_M=false;
  307. }
  308. game.ACT.init(actions);
  309. order.push(game.MAIN);
  310. GLOBAL.D=game.BALLS.b_0.uni_width*0.95;
  311. GLOBAL.HS*=game.SCREEN_HEIGHT/1000;
  312. GLOBAL.VS*=game.SCREEN_HEIGHT/1000;
  313. GLOBAL.BS*=game.SCREEN_HEIGHT/1000;
  314. game.LANGUAGE="TXT";
  315. game.init_captions();
  316. GLOBAL.PATH_POINTS=game.SCREEN_HEIGHT*10;
  317. GLOBAL.WND_GAME = new AVK_WND_GAME();
  318. game.GAME.back.sprite.interactive = true;
  319. if(isMobile.iOS()){
  320. game.GAME.back.sprite.mousemove = game.GAME.back.sprite.touchmove = game.GAME.back.sprite.touch = function(data)
  321. {
  322. if (!GLOBAL.RUN)
  323. return;
  324. GLOBAL.X=data.global.x;
  325. event("move","GLOBAL","GLOBAL",data.global.x,data.global.y);
  326. }
  327. }else{
  328. game.GAME.back.sprite.mousemove = function(data)
  329. {
  330. if (!GLOBAL.RUN)
  331. return;
  332. GLOBAL.X=data.global.x;
  333. event("move","GLOBAL","GLOBAL",data.global.x,data.global.y);
  334. }
  335. }
  336. if(isMobile.iOS()){
  337. game.GAME.back.sprite.mouseout = game.GAME.back.sprite.mouseupoutside = game.GAME.back.sprite.mouseup = game.GAME.back.sprite.touchend = game.GAME.back.spritemouseupoutside = game.GAME.back.sprite.touchendoutside = function(data)
  338. {
  339. if (!GLOBAL.RUN)
  340. return;
  341. GLOBAL.X=data.global.x;
  342. event("finish","GLOBAL","GLOBAL",data.global.x,data.global.y);
  343. }
  344. }else{
  345. game.GAME.back.sprite.mouseout = game.GAME.back.sprite.mouseupoutside = game.GAME.back.sprite.mouseup = game.GAME.back.spritemouseupoutside = function(data)
  346. {
  347. if (!GLOBAL.RUN)
  348. return;
  349. GLOBAL.X=data.global.x;
  350. event("finish","GLOBAL","GLOBAL",data.global.x,data.global.y);
  351. }
  352. }
  353. if(isMobile.iOS()){
  354. game.GAME.back.sprite.mousedown = game.GAME.back.sprite.touchstart = function(data)
  355. {
  356. if (!GLOBAL.RUN)
  357. return;
  358. GLOBAL.X=data.global.x;
  359. event("start","GLOBAL","GLOBAL",data.global.x,data.global.y);
  360. }
  361. }else{
  362. game.GAME.back.sprite.mousedown = function(data)
  363. {
  364. if (!GLOBAL.RUN)
  365. return;
  366. GLOBAL.X=data.global.x;
  367. event("start","GLOBAL","GLOBAL",data.global.x,data.global.y);
  368. }
  369. }
  370. for (var i=0;i<19;i++)
  371. {
  372. game.MAIN["btn_lev_"+i].sprite.anchor.x=0.5;
  373. game.MAIN["btn_lev_"+i].sprite.anchor.y=0.5;
  374. game.MAIN["btn_lev_"+i].sprite.position.x+=0.5*game.MAIN["btn_lev_"+i].uni_width;
  375. game.MAIN["btn_lev_"+i].sprite.position.y+=0.5*game.MAIN["btn_lev_"+i].uni_height;
  376. game.MAIN["btn_lev_"+i].refresh();
  377. var prg=CONTAINER.get_object("MAIN","my_prg",game.MAIN["btn_lev_"+i]);
  378. if (i==0)
  379. {
  380. prg.sprite.position.x=game.MAIN.my_prg.sprite.position.x-0.5*game.MAIN["btn_lev_"+i].uni_width;
  381. prg.sprite.position.y=game.MAIN.my_prg.sprite.position.y-0.5*game.MAIN["btn_lev_"+i].uni_height;
  382. }else
  383. {
  384. prg.sprite.position.x=game.MAIN.my_prg.sprite.position.x;
  385. prg.sprite.position.y=game.MAIN.my_prg.sprite.position.y;
  386. }
  387. GLOBAL.PROGRESS.push(prg);
  388. }
  389. init_select();
  390. if (GLOBAL.LEVELS[0]==-1)
  391. GLOBAL.TUTOR=0;
  392. else
  393. GLOBAL.TUTOR=1000000;
  394. for (i=0;i<10;i++)
  395. game.GAME["level_"+i].sprite.parent.removeChild(game.GAME["level_"+i].sprite);
  396. game.MAIN.levels.sprite.visible=false;
  397. game.GAME.uppper.sprite.anchor.x=0.5;
  398. game.GAME.up_b.sprite.position.x-=0.5*game.GAME.uppper.uni_width;
  399. game.GAME.ready_1.sprite.position.x-=0.5*game.GAME.uppper.uni_width;
  400. game.GAME.ready_0.sprite.position.x-=0.5*game.GAME.uppper.uni_width;
  401. game.GAME.ready_1.sprite.visible=false;
  402. game.GAME.ready_0.sprite.visible=false;
  403. game.GAME.wrays.sprite.visible=false;
  404. game.GAME.wrays.sprite.scale.x=8;
  405. game.GAME.wrays.sprite.scale.y=8;
  406. game.GAME.wrays.sprite.anchor.x=0.5;
  407. game.GAME.wrays.sprite.anchor.y=0.5;
  408. game.GAME.wrays.sprite.position.x+=game.GAME.wrays.uni_width/2;
  409. game.GAME.wrays.sprite.position.y+=game.GAME.wrays.uni_height/2;
  410. game.GAME.brays.sprite.visible=false;
  411. game.GAME.brays.sprite.scale.x=8;
  412. game.GAME.brays.sprite.scale.y=8;
  413. game.GAME.brays.sprite.anchor.x=0.5;
  414. game.GAME.brays.sprite.anchor.y=0.5;
  415. game.GAME.brays.sprite.position.x+=game.GAME.brays.uni_width/2;
  416. game.GAME.brays.sprite.position.y+=game.GAME.brays.uni_height/2;
  417. game.GAME.btn_snd.sprite.visible=false;
  418. game.MAIN.btn_snd.sprite.visible=false;
  419. game.GAME.btn_no_snd.sprite.visible=GLOB_M;
  420. game.MAIN.btn_no_snd.sprite.visible=GLOB_M;
  421. game.GAME.shadow.sprite.scale.x=25.2;
  422. game.GAME.shadow.sprite.scale.y=25.2;
  423. game.GAME.shadow.sprite.position.x=-10;
  424. game.GAME.shadow.sprite.position.y=-10;
  425. game.GAME.loose_wnd.sprite.visible=false;
  426. game.GAME.win_wnd.sprite.visible=false;
  427. game.GAME.shadow.sprite.visible=false;
  428. game.GAME.shadow.sprite.interactive = true;
  429. if(isMobile.iOS()){
  430. game.GAME.shadow.sprite.mousemove = game.GAME.shadow.sprite.touchmove = game.GAME.shadow.sprite.touch = game.GAME.shadow.sprite.mouseout = game.GAME.shadow.sprite.mouseupoutside = game.GAME.shadow.sprite.mouseup = game.GAME.shadow.sprite.touchend = game.GAME.shadow.spritemouseupoutside = game.GAME.shadow.sprite.touchendoutside = game.GAME.shadow.sprite.mousedown = game.GAME.shadow.sprite.touchstart = function(data)
  431. {
  432. if (data.originalEvent!=null)
  433. {
  434. data.originalEvent.stopPropagation();
  435. data.originalEvent.preventDefault();
  436. }
  437. }
  438. }else{
  439. game.GAME.shadow.sprite.mousemove = game.GAME.shadow.sprite.mouseout = game.GAME.shadow.sprite.mouseupoutside = game.GAME.shadow.sprite.mouseup = game.GAME.shadow.spritemouseupoutside = game.GAME.shadow.sprite.mousedown= function(data)
  440. {
  441. if (data.originalEvent!=null)
  442. {
  443. data.originalEvent.stopPropagation();
  444. data.originalEvent.preventDefault();
  445. }
  446. }
  447. }
  448. game.GAME.loose_wnd.y=game.GAME.loose_wnd.sprite.position.y;
  449. game.GAME.win_wnd.y=game.GAME.win_wnd.sprite.position.y;
  450. game.GAME.txt_score.set_style(0.5,"AVK_FNT_main","right");
  451. game.GAME.txt_score_part.sprite.visible=false;
  452. game.GAME.zvezda_part.sprite.visible=false;
  453. game.GAME.star_0.sprite.anchor.x=0.5;
  454. game.GAME.star_0.sprite.anchor.y=0.5;
  455. game.GAME.star_0.sprite.position.x+=game.GAME.star_0.uni_width*0.5;
  456. game.GAME.star_0.sprite.position.y+=game.GAME.star_0.uni_height*0.5;
  457. game.GAME.star_1.sprite.anchor.x=0.5;
  458. game.GAME.star_1.sprite.anchor.y=0.5;
  459. game.GAME.star_1.sprite.position.x+=game.GAME.star_1.uni_width*0.5;
  460. game.GAME.star_1.sprite.position.y+=game.GAME.star_1.uni_height*0.5;
  461. game.GAME.star_2.sprite.anchor.x=0.5;
  462. game.GAME.star_2.sprite.anchor.y=0.5;
  463. game.GAME.star_2.sprite.position.x+=game.GAME.star_2.uni_width*0.5;
  464. game.GAME.star_2.sprite.position.y+=game.GAME.star_2.uni_height*0.5;
  465. game.GAME.riska_0.sprite.anchor.x=0.5;
  466. game.GAME.riska_0.sprite.anchor.y=0.5;
  467. game.GAME.riska_0.sprite.position.x+=game.GAME.riska_0.uni_width*0.5;
  468. game.GAME.riska_0.sprite.position.y+=game.GAME.riska_0.uni_height*0.5;
  469. game.GAME.riska_1.sprite.anchor.x=0.5;
  470. game.GAME.riska_1.sprite.anchor.y=0.5;
  471. game.GAME.riska_1.sprite.position.x+=game.GAME.riska_1.uni_width*0.5;
  472. game.GAME.riska_1.sprite.position.y+=game.GAME.riska_1.uni_height*0.5;
  473. for (i=0;i<10;i++)
  474. {
  475. game.GAME["head_"+i].sprite.parent.removeChild(game.GAME["head_"+i].sprite);
  476. game.GAME["up_"+i].sprite.parent.removeChild(game.GAME["up_"+i].sprite);
  477. game.GAME["res_"+i].sprite.parent.removeChild(game.GAME["res_"+i].sprite);
  478. }
  479. GLOBAL.UP_SPR = new PIXI.DisplayObjectContainer();
  480. GLOBAL.HEAD_SPR = new PIXI.DisplayObjectContainer();
  481. game.GAME.sprite.addChildAt(GLOBAL.UP_SPR,3);
  482. game.GAME.sprite.addChildAt(GLOBAL.HEAD_SPR,6);
  483. for (var level=0;level<10;level++)
  484. {
  485. game.GAME["up_"+level].sprite.position.x-=game.GAME["up_"+level].uni_width*0.25/2;
  486. game.GAME["up_"+level].sprite.position.y-=game.GAME["up_"+level].uni_height*0.25/2;
  487. game.GAME["up_"+level].sprite.scale.x=1.25;
  488. game.GAME["up_"+level].sprite.scale.y=1.25;
  489. game.GAME["res_"+level].sprite.position.x-=game.GAME["res_"+level].uni_width*0.25/2;
  490. game.GAME["res_"+level].sprite.position.y-=game.GAME["res_"+level].uni_height*0.25/2;
  491. game.GAME["res_"+level].sprite.scale.x=1.25;
  492. game.GAME["res_"+level].sprite.scale.y=1.25;
  493. }
  494. var tmp=game.GAME.btn_refresh_win.make_copy();
  495. tmp.sprite.position.x=0;
  496. tmp.sprite.position.y=0;
  497. tmp.refresh();
  498. game.GAME.pbtn_refresh.add(tmp);
  499. tmp=game.GAME.btn_menu_win.make_copy()
  500. tmp.sprite.position.x=0;
  501. tmp.sprite.position.y=0;
  502. tmp.refresh();
  503. game.GAME.pbtn_menu.add(tmp);
  504. //tmp=game.GAME.btn_more.make_copy()
  505. //tmp.sprite.position.x=0;
  506. //tmp.sprite.position.y=0;
  507. //tmp.refresh();
  508. //game.GAME.pbtn_more.add(tmp);
  509. CONTAINER.free(CONTAINER.get_object("MAIN","cloud",game.MAIN.zag));
  510. function AVK_HIDE()
  511. {
  512. function AVK_BTNS()
  513. {
  514. var my_here=this;
  515. var first=true;
  516. this.set_property = function (newVal)
  517. {
  518. if (newVal<0.2)
  519. {
  520. newVal=newVal/0.2;
  521. game.MAIN.btn_start.sprite.scale.x=1.2-0.2*newVal;
  522. game.MAIN.btn_start.sprite.scale.y=1.2-0.2*newVal;
  523. game.MAIN.btn_start.sprite.alpha=newVal;
  524. game.MAIN.up_back.sprite.scale.x=1.2-0.2*newVal;
  525. game.MAIN.up_back.sprite.scale.y=1.2-0.2*newVal;
  526. game.MAIN.up_back.sprite.alpha=newVal;
  527. }else
  528. {
  529. if (first)
  530. {
  531. first=false;
  532. for (var i=0;i<4;i++)
  533. {
  534. var c=CONTAINER.get_object("MAIN","cloud",game.MAIN.zag);
  535. c.sprite.scale.x=0.5+Math.random()*4;
  536. c.sprite.scale.y=c.sprite.scale.x;
  537. c.sprite.alpha=c.sprite.scale.x/4.5;
  538. c.sprite.position.x=game.SCREEN_WIDTH*Math.random()-c.uni_width*c.sprite.scale.y/2;
  539. c.sprite.position.y=game.SCREEN_HEIGHT*Math.random()/2-c.uni_height*c.sprite.scale.y/2;
  540. GLOBAL.CLOUDS.push(c)
  541. }
  542. }
  543. newVal=1-(Math.sin(Math.PI*(newVal-0.2)/0.8*6)*0.03)*(1-(newVal-0.2)/0.8);
  544. game.MAIN.sprite.position.x=-game.SCREEN_WIDTH*(newVal-1)/2;
  545. game.MAIN.sprite.position.y=-game.SCREEN_HEIGHT*(newVal-1)/2;
  546. game.MAIN.sprite.scale.x=newVal;
  547. game.MAIN.sprite.scale.y=newVal;
  548. }
  549. }
  550. function finish()
  551. {
  552. game.GUI_BUSY=false;
  553. }
  554. this.start = function()
  555. {
  556. if (is_snd())
  557. GLOB_light_on.play();
  558. game.MAIN.btn_start.sprite.anchor.x=0.5;
  559. game.MAIN.btn_start.sprite.anchor.y=0.5;
  560. game.MAIN.btn_start.sprite.position.x+=game.MAIN.btn_start.uni_width/2;
  561. game.MAIN.btn_start.sprite.position.y+=game.MAIN.btn_start.uni_height/2;
  562. game.MAIN.btn_start.sprite.scale.x=1.2;
  563. game.MAIN.btn_start.sprite.scale.y=1.2;
  564. game.MAIN.btn_start.sprite.alpha=0;
  565. game.MAIN.btn_start.sprite.visible=true;
  566. game.MAIN.btn_start.refresh();
  567. game.MAIN.up_back.sprite.anchor.x=0.5;
  568. game.MAIN.up_back.sprite.anchor.y=0.5;
  569. game.MAIN.up_back.sprite.position.x+=game.MAIN.up_back.uni_width/2;
  570. game.MAIN.up_back.sprite.position.y+=game.MAIN.up_back.uni_height/2;
  571. game.MAIN.up_back.sprite.scale.x=1.2;
  572. game.MAIN.up_back.sprite.scale.y=1.2;
  573. game.MAIN.up_back.sprite.alpha=0;
  574. game.MAIN.up_back.sprite.visible=true;
  575. game.ACT.start("show",my_here,finish);
  576. }
  577. }
  578. var here=this;
  579. var btns=new AVK_BTNS();
  580. this.up=null;
  581. this.down=null;
  582. this.set_property = function (newVal)
  583. {
  584. if (newVal<0.2)
  585. newVal=-Math.sin(Math.PI*newVal*5)/10;
  586. else
  587. newVal=(newVal-0.2)/0.8;
  588. here.up.position.y=here.up.sy+(-here.up.height-here.up.sy)*newVal;
  589. here.down.position.y=here.down.sy+40*newVal;
  590. }
  591. function finish_up()
  592. {
  593. btns.start();
  594. }
  595. function finish()
  596. {
  597. game.MAIN.sprite.visible = true;
  598. while(game.UP_SPR.children.length>0)
  599. {
  600. var ch=game.UP_SPR.children[0];
  601. game.UP_SPR.removeChild(ch);
  602. }
  603. game.MAIN.sprite.position.y=game.SCREEN_HEIGHT;
  604. game.MAIN.btn_start.sprite.visible=false;
  605. game.MAIN.up_back.sprite.visible=false;
  606. game.ACT.start("from_up",game.MAIN,finish_up);
  607. }
  608. this.start = function()
  609. {
  610. here.up=game.UP_SPR.children[1];
  611. here.down=game.UP_SPR.children[0];
  612. here.up.sy=here.up.position.y;
  613. here.down.sy=here.down.position.y;
  614. game.ACT.start("hide",here,finish);
  615. }
  616. }
  617. game.GUI_BUSY=true;
  618. var hide=new AVK_HIDE();
  619. hide.start();
  620. }
  621. function get_l(dx,dy)
  622. {
  623. var l=Math.sqrt(dx*dx+dy*dy);
  624. if (l==0)
  625. l=0.001;
  626. return l;
  627. }
  628. function angle(dx,dy)
  629. {
  630. var l=get_l(dx,dy);
  631. var a = Math.acos(dx/l);
  632. if (dy<0)
  633. a = 2 * Math.PI - a;
  634. return a;
  635. }
  636. function update(tk)
  637. {
  638. if (tk>200)
  639. tk=200;
  640. game.GAME.win_wnd.sprite.rotation=0;
  641. game.GAME.loose_wnd.sprite.rotation=0;
  642. for (var i=0;i<to_update.length;i++)
  643. {
  644. to_update[i](tk);
  645. }
  646. for (i=0;i<GLOBAL.CLOUDS.length;i++)
  647. {
  648. var cl=GLOBAL.CLOUDS[i];
  649. cl.sprite.position.x-=cl.sprite.scale.x*tk/200;
  650. if (cl.sprite.position.x<-cl.uni_width*cl.sprite.scale.x)
  651. cl.sprite.position.x=game.SCREEN_WIDTH;
  652. }
  653. }
  654. function add_to_update(f)
  655. {
  656. to_update.push(f);
  657. }
  658. function event(act,wnd,el,id,tag)
  659. {
  660. if ((game.GUI_BUSY)&&(el!="btn_m0")&&(el!="btn_m1")&&(el!="btn_m2"))
  661. return;
  662. if (act=="click")
  663. {
  664. if (el=="btn_more")
  665. //Play68.goHome();
  666. if (is_snd())
  667. GLOB_click.play();
  668. //game.deb(act+";"+wnd+";"+el+";"+id+";"+tag);
  669. switch (wnd)
  670. {
  671. case "MAIN":
  672. if (el.substring(0,8)=="btn_lev_")
  673. {
  674. GLOBAL.WND_GAME.show(el.substring(8,el.length)/1);
  675. if (is_snd())
  676. {
  677. GLOB_in_menu.stop();
  678. GLOB_in_game.play("none",0,0,-1);
  679. }
  680. }
  681. switch (el)
  682. {
  683. case "btn_snd":
  684. case "btn_no_snd":
  685. change_snd();
  686. break;
  687. case "btn_start":
  688. GLOBAL.WND_GAME.show_level();
  689. break;
  690. case "btn_back":
  691. GLOBAL.WND_GAME.hide_level();
  692. break;
  693. }
  694. break;
  695. case "GAME":
  696. switch (el)
  697. {
  698. case "btn_snd":
  699. case "btn_no_snd":
  700. change_snd();
  701. break;
  702. case "btn_close":
  703. GLOBAL.WND_GAME.pause();
  704. break;
  705. case "btn_menu":
  706. case "btn_menu_win":
  707. if (is_snd())
  708. {
  709. GLOB_heart.stop();
  710. GLOB_in_game.stop();
  711. GLOB_in_menu.play("none",0,0,-1);
  712. }
  713. GLOBAL.WND_GAME.close();
  714. GLOBAL.PAUSE=false;
  715. break;
  716. case "btn_refresh":
  717. GLOBAL.STAT[GLOBAL.WND_GAME.level_num].loose_refresh++;
  718. save_stat();
  719. case "btn_refresh_win":
  720. GLOBAL.WND_GAME.pre_show();
  721. GLOBAL.WND_GAME.on_show();
  722. if (is_snd())
  723. GLOB_in_game.play("none",0,0,-1);
  724. break;
  725. case "btn_next":
  726. GLOBAL.STAT[GLOBAL.WND_GAME.level_num].win_next++;
  727. save_stat();
  728. if (!GLOBAL.PAUSE)
  729. {
  730. if (GLOBAL.WND_GAME.level_num<18)
  731. GLOBAL.WND_GAME.level_num++;
  732. else
  733. {
  734. GLOBAL.WND_GAME.close();
  735. return;
  736. }
  737. GLOBAL.WND_GAME.pre_show();
  738. GLOBAL.WND_GAME.on_show();
  739. if (is_snd())
  740. GLOB_in_game.play("none",0,0,-1);
  741. }else
  742. {
  743. GLOBAL.PAUSE=false;
  744. GLOBAL.RUN=true;
  745. game.GAME.win_wnd.sprite.visible=false;
  746. game.GAME.shadow.sprite.visible=false;
  747. }
  748. break;
  749. }
  750. break;
  751. }
  752. }else if (act=="start")
  753. GLOBAL.WND_GAME.start();
  754. }
  755. function AVK_WND_BULLET(b)
  756. {
  757. var here=this;
  758. var all_balls=b;
  759. var ball=null;
  760. var up_ball=null;
  761. var x=0;
  762. var y=game.GAME.start_place.sprite.position.y+game.GAME.start_place.uni_height/2;
  763. var target_x=-1;
  764. var speed=0;
  765. var ready=0;
  766. this.color=0;
  767. this.up_color=0;
  768. game.GAME.bullet_place.add(game.LIGHT.react.reaction);
  769. game.LIGHT.react.reaction.sprite.position.y=y/3;
  770. game.LIGHT.react.reaction.sprite.scale.y=game.SCREEN_HEIGHT*1.2/game.LIGHT.react.reaction.uni_height;
  771. game.LIGHT.react.reaction.sprite.scale.x=game.LIGHT.react.reaction.sprite.scale.y/2;
  772. game.LIGHT.react.reaction.sprite.anchor.x=0.45;
  773. game.LIGHT.react.reaction.sprite.visible=false;
  774. game.GAME.bullet_place.add(game.BALLS.l);
  775. game.BALLS.l.sprite.anchor.x=0.5;
  776. game.BALLS.l.sprite.anchor.y=0.5;
  777. game.BALLS.l.sprite.visible=false;
  778. function AVK_LIGHT()
  779. {
  780. var t=this;
  781. this.set_property = function (newVal)
  782. {
  783. game.LIGHT.react.reaction.sprite.alpha=Math.sin(newVal*Math.PI);
  784. }
  785. this.finish_scale=function ()
  786. {
  787. game.LIGHT.react.reaction.sprite.visible=false;
  788. here.clear_ready();
  789. }
  790. this.start = function()
  791. {
  792. game.LIGHT.react.reaction.sprite.visible=true;
  793. game.LIGHT.react.reaction.sprite.alpha=0;
  794. game.ACT.start("light",t,t.finish_scale);
  795. GLOBAL.BALLS.try_light(game.LIGHT.react.reaction.sprite.position.x);
  796. }
  797. }
  798. var light=new AVK_LIGHT();
  799. this.add_ready=function()
  800. {
  801. if (ready==2)
  802. {
  803. if ((is_snd())&&(!game.BALLS.l.sprite.visible))
  804. GLOB_light_on.play();
  805. game.BALLS.l.sprite.visible=true;
  806. if ((ball!=null)&&(speed==0))
  807. {
  808. ball.sprite.visible=false;
  809. }
  810. return;
  811. }
  812. game.GAME["ready_"+ready].sprite.visible=true;
  813. ready++;
  814. }
  815. this.clear_ready=function()
  816. {
  817. ready=0;
  818. game.GAME.ready_0.sprite.visible=false;
  819. game.GAME.ready_1.sprite.visible=false;
  820. game.BALLS.l.sprite.visible=false;
  821. if (ball!=null)
  822. ball.sprite.visible=true;
  823. }
  824. this.born=function()
  825. {
  826. var f=false;
  827. for (var i=0;i<GLOBAL.COLORS.length;i++)
  828. if (GLOBAL.COLORS[i])
  829. f=true;
  830. if (f)
  831. here.reset_color();
  832. else
  833. here.set_color();
  834. }
  835. this.reset_color=function()
  836. {
  837. here.color=here.up_color;
  838. here.up_color=Math.floor(Math.random()*7);
  839. while (!GLOBAL.COLORS[here.up_color])
  840. here.up_color=Math.floor(Math.random()*7);
  841. while (!GLOBAL.COLORS[here.color])
  842. here.color=Math.floor(Math.random()*7);
  843. here.set_color();
  844. }
  845. this.clear=function()
  846. {
  847. if (ball!=null)
  848. CONTAINER.free(ball);
  849. ball=null;
  850. }
  851. this.set_color=function()
  852. {
  853. if (GLOBAL.TUTOR==0)
  854. {
  855. here.color=1;
  856. here.up_color=0;
  857. }
  858. if (ball!=null)
  859. CONTAINER.free(ball);
  860. if (up_ball!=null)
  861. CONTAINER.free(up_ball);
  862. ball=CONTAINER.get_object("BALLS","b_"+here.color,game.GAME.bullet_place);
  863. ball.time=Math.PI*ball.uni_width;
  864. ball.sprite.anchor.x=0.5;
  865. ball.sprite.anchor.y=0.5;
  866. ball.sprite.scale.x=1;
  867. ball.sprite.scale.y=1;
  868. ball.sprite.alpha=1;
  869. ball.sprite.position.x=x;
  870. ball.sprite.position.y=y;
  871. ball.sprite.rotation=Math.PI/2;
  872. ball.color=here.color;
  873. ball.sprite.visible=!game.BALLS.l.sprite.visible;
  874. up_ball=CONTAINER.get_object("BALLS","b_"+here.up_color,game.GAME.up_b);
  875. up_ball.time=Math.PI*up_ball.uni_width;
  876. up_ball.sprite.anchor.x=0.5;
  877. up_ball.sprite.anchor.y=0.5;
  878. up_ball.sprite.alpha=1;
  879. up_ball.sprite.position.x=game.GAME.up_b.uni_width/2;
  880. up_ball.sprite.position.y=game.GAME.up_b.uni_height/2;
  881. up_ball.sprite.scale.x=0.3;
  882. up_ball.sprite.scale.y=0.3;
  883. up_ball.sprite.rotation=Math.PI/2;
  884. up_ball.color=here.up_color;
  885. }
  886. this.start=function()
  887. {
  888. if (GLOBAL.TUTOR==1)
  889. {
  890. if ((GLOBAL.X>GLOBAL.D+game.GAME.hand_center.sprite.position.x)||(GLOBAL.X<game.GAME.hand_center.sprite.position.x-GLOBAL.D))
  891. return;
  892. GLOBAL.WND_GAME.TUTOR.stop();
  893. GLOBAL.X=game.GAME.hand_center.sprite.position.x-GLOBAL.D*2/3;
  894. GLOBAL.TUTOR++;
  895. }
  896. if (GLOBAL.TUTOR==3)
  897. {
  898. if ((GLOBAL.X>GLOBAL.D+game.GAME.hand_center.sprite.position.x)||(GLOBAL.X<game.GAME.hand_center.sprite.position.x-GLOBAL.D))
  899. return;
  900. GLOBAL.WND_GAME.TUTOR.stop();
  901. GLOBAL.X=game.GAME.hand_center.sprite.position.x-GLOBAL.D*2/3;
  902. GLOBAL.TUTOR=1000000;
  903. }
  904. if ((speed==0)&&(target_x<0))
  905. {
  906. target_x=GLOBAL.X;
  907. }
  908. }
  909. this.update=function(tk)
  910. {
  911. game.GAME.uppper.sprite.position.x=GLOBAL.X;
  912. game.BALLS.l.sprite.position.y=y;
  913. game.BALLS.l.sprite.position.x=game.GAME.uppper.sprite.position.x;
  914. game.LIGHT.react.reaction.sprite.position.x=game.GAME.uppper.sprite.position.x;
  915. //game.BALLS.l.sprite.rotation+=tk/300;
  916. game.BALLS.l.update(tk*2);
  917. game.LIGHT.react.reaction.update(tk*7);
  918. game.LIGHT.react.reaction.sprite.rotation=0;
  919. //game.deb(GLOBAL.X);
  920. if (ball==null)
  921. return;
  922. ball.update(tk/15);
  923. //ball.sprite.rotation+=Math.PI*tk/1000;
  924. up_ball.update(-tk/5);
  925. //up_ball.sprite.rotation-=Math.PI*tk/1000;
  926. var f=false;
  927. for (var i=0;i<GLOBAL.COLORS.length;i++)
  928. if (GLOBAL.COLORS[i])
  929. f=true;
  930. if (target_x>=0)
  931. {
  932. if (Math.abs(target_x-x)<GLOBAL.HS*tk)
  933. {
  934. x=target_x;
  935. target_x=-1;
  936. if (game.BALLS.l.sprite.visible)
  937. {
  938. if (!game.LIGHT.react.reaction.sprite.visible)
  939. {
  940. light.start();
  941. if (is_snd())
  942. GLOB_light.play();
  943. }
  944. }else
  945. {
  946. speed=GLOBAL.VS;
  947. if (is_snd())
  948. GLOB_ball.play();
  949. }
  950. }else
  951. {
  952. x+=(target_x-x)/Math.abs(target_x-x)*GLOBAL.HS*tk;
  953. }
  954. game.GAME.uppper.sprite.position.x=x;
  955. game.BALLS.l.sprite.position.x=game.GAME.uppper.sprite.position.x;
  956. game.LIGHT.react.reaction.sprite.position.x=game.GAME.uppper.sprite.position.x;
  957. }else if (speed==0)
  958. {
  959. x=GLOBAL.X;
  960. ball.sprite.position.y=y;
  961. }else
  962. {
  963. if (all_balls.verify_bullet(ball,ball.sprite.position.x,ball.sprite.position.x,ball.sprite.position.y,ball.sprite.position.y+tk*speed))
  964. {
  965. x=GLOBAL.X;
  966. speed=0;
  967. ball=null;
  968. return;
  969. }else
  970. {
  971. ball.sprite.position.y+=tk*speed;
  972. if (ball.sprite.position.y>game.SCREEN_HEIGHT+ball.uni_height)
  973. {
  974. x=GLOBAL.X;
  975. speed=0;
  976. if (f)
  977. here.reset_color();
  978. else
  979. here.set_color();
  980. }
  981. }
  982. }
  983. ball.sprite.position.x=x;
  984. if ((!GLOBAL.COLORS[this.color])&&(f))
  985. here.reset_color();
  986. }
  987. }
  988. function AVK_WND_CHAIN(bl)
  989. {
  990. var here=this;
  991. this.color=0;
  992. this.next=null;
  993. this.prev=null;
  994. this.shad=null;
  995. this.ball=null;
  996. this.active=false;
  997. this.progress=0;
  998. this.p_progress=0;
  999. this.beg_time=0;
  1000. this.end_time=0;
  1001. this.speed=GLOBAL.BS;
  1002. this.prev_child=null;
  1003. this.next_child=null;
  1004. this.need_verify=false;
  1005. this.a=0;
  1006. this.delta=0;
  1007. this.chained=true;
  1008. this.none=false;
  1009. var back_speed=0;
  1010. var on_event=null;
  1011. var max_prog=0;
  1012. var all_balls=bl;
  1013. this.set_max_prog=function(s,o)
  1014. {
  1015. max_prog=s;
  1016. on_event=o;
  1017. if (here.next!=null)
  1018. here.next.set_max_prog(s,o);
  1019. }
  1020. this.get_max_prog=function()
  1021. {
  1022. return max_prog;
  1023. }
  1024. this.get_max_on=function()
  1025. {
  1026. return on_event;
  1027. }
  1028. this.set_speed=function(s)
  1029. {
  1030. back_speed=s;
  1031. }
  1032. this.get_back_speed=function(s)
  1033. {
  1034. return back_speed;
  1035. }
  1036. function add_to_killed()
  1037. {
  1038. for (var i=0;i<GLOBAL.KILLED.length;i++)
  1039. if (GLOBAL.KILLED[i]==null)
  1040. {
  1041. GLOBAL.KILLED[i]=here.ball;
  1042. GLOBAL.KILLED[i].time=250;
  1043. GLOBAL.KILLED[i].start_time=250;
  1044. here.ball=null;
  1045. return;
  1046. }
  1047. GLOBAL.KILLED.push(here.ball);
  1048. GLOBAL.KILLED[i].time=150;
  1049. GLOBAL.KILLED[i].start_time=150;
  1050. here.ball=null;
  1051. }
  1052. this.kill=function(init)
  1053. {
  1054. if (here.ball!=null)
  1055. {
  1056. if (!init)
  1057. {
  1058. all_balls.born_oskolki(here.ball.sprite.position.x,here.ball.sprite.position.y,here.color);
  1059. add_to_killed();
  1060. }else
  1061. {
  1062. CONTAINER.free(here.ball);
  1063. here.ball=null;
  1064. }
  1065. }
  1066. if (here.shad!=null)
  1067. {
  1068. CONTAINER.free(here.shad);
  1069. here.shad=null;
  1070. }
  1071. if (here.prev_child!=null)
  1072. {
  1073. CONTAINER.free(here.prev_child);
  1074. GLOBAL.BULLET.born_after=true;
  1075. }
  1076. if (here.next_child!=null)
  1077. {
  1078. CONTAINER.free(here.next_child);
  1079. GLOBAL.BULLET.born_after=true;
  1080. }
  1081. if (here.prev!=null)
  1082. {
  1083. here.prev.next=here.next;
  1084. }
  1085. if (here.next!=null)
  1086. {
  1087. here.next.prev=here.prev;
  1088. }
  1089. if ((here.prev==null)&&(!init))
  1090. all_balls.change_first(here,here.next);
  1091. here.active=false;
  1092. here.next=null;
  1093. here.prev=null;
  1094. }
  1095. this.born=function(color,prev,x,y,p,max_p,on_max)
  1096. {
  1097. here.beg_time=0;
  1098. here.end_time=0;
  1099. if (!game.TOO_SLOW)
  1100. {
  1101. here.shad=CONTAINER.get_object("BALLS","shadow",game.GAME.place_shad);
  1102. here.shad.sprite.scale.x=1;
  1103. here.shad.sprite.scale.y=1;
  1104. here.shad.sprite.anchor.x=0.5;
  1105. here.shad.sprite.anchor.y=0.5;
  1106. here.shad.sprite.position.x=x-GLOBAL.D*0.1;
  1107. here.shad.sprite.position.y=y+GLOBAL.D*0.1;
  1108. }
  1109. here.ball=CONTAINER.get_object("BALLS","b_"+color,game.GAME.place);
  1110. here.ball.time=Math.PI*here.ball.uni_width;
  1111. here.ball.sprite.alpha=1;
  1112. here.ball.sprite.scale.x=1;
  1113. here.ball.sprite.scale.y=1;
  1114. here.ball.sprite.anchor.x=0.5;
  1115. here.ball.sprite.anchor.y=0.5;
  1116. here.ball.sprite.position.x=x;
  1117. here.ball.sprite.position.y=y;
  1118. here.color=color;
  1119. here.progress=p;
  1120. here.prev=prev;
  1121. here.next=null;
  1122. here.need_verify=false;
  1123. here.a=0;
  1124. here.delta=0;
  1125. back_speed=0;
  1126. here.chained=true;
  1127. here.none=false;
  1128. here.prev_child=null;
  1129. here.next_child=null;
  1130. here.active=true;
  1131. max_prog=max_p;
  1132. on_event=on_max;
  1133. return here;
  1134. }
  1135. this.step=function(tk)
  1136. {
  1137. var tmp=here;
  1138. while ((tmp.next!=null)&&(tmp.chained))
  1139. tmp=tmp.next;
  1140. var mul=tmp.progress/GLOBAL.LENGTH;
  1141. while (tmp.next!=null)
  1142. tmp=tmp.next;
  1143. if (GLOBAL.MAX_PROG<tmp.progress)
  1144. GLOBAL.MAX_PROG=tmp.progress;
  1145. mul=(mul+tmp.progress/GLOBAL.LENGTH)/2;
  1146. if (mul<=0)
  1147. mul+=0.001;
  1148. if (mul>=1)
  1149. mul=1;
  1150. if (mul<0.4)
  1151. {
  1152. mul=2+(1-2)*mul/0.4;//Math.sqrt(1/mul)+50*(1-mul)*(1-mul)*(1-mul)*(1-mul);
  1153. mul*=mul*mul*mul*mul;
  1154. }else if (mul>0.7)
  1155. mul=1+(0.1-1)*(mul-0.7)/0.3;
  1156. else mul=1;
  1157. mul*=GLOBAL.MUL;
  1158. here.press(here.progress+here.speed*tk*mul,tk);
  1159. }
  1160. this.on_max=function()
  1161. {
  1162. if (max_prog==1000000)
  1163. return;
  1164. max_prog=1000000;
  1165. if (here.next!=null)
  1166. here.next.on_max();
  1167. if (here.prev!=null)
  1168. here.prev.on_max();
  1169. else if (on_event!=null)
  1170. {
  1171. if (here.active)
  1172. on_event();
  1173. on_event=null;
  1174. }
  1175. }
  1176. this.press=function(previos_progress,tk)
  1177. {
  1178. if (!here.active)
  1179. return;
  1180. var child=null;
  1181. var just_chained=false;
  1182. if (here.next_child!=null)
  1183. child=here.next_child;
  1184. if (here.prev_child!=null)
  1185. child=here.prev_child;
  1186. if (child!=null)
  1187. {
  1188. child.end_time-=tk;
  1189. if (child.end_time<0)
  1190. child.end_time=0;
  1191. child.progress=(child.beg_time-child.end_time)/child.beg_time;
  1192. var l=Math.abs(Math.cos(child.angle))*GLOBAL.D*2-GLOBAL.D;
  1193. if (l<0)
  1194. l=0;
  1195. if (child.progress>=1)
  1196. {
  1197. child.end_time=0;
  1198. child.beg_time=0;
  1199. child.progress=1;
  1200. var tmp=null;
  1201. var inserted=null;
  1202. if (here.next_child!=null)
  1203. {
  1204. here.next_child=null;
  1205. tmp=here.next;
  1206. here.next=all_balls.get_chain().born(child.color,here,child.sprite.position.x,child.sprite.position.y,here.progress+GLOBAL.D,max_prog,on_event);
  1207. inserted=here.next;
  1208. here.next.next=tmp;
  1209. if (tmp!=null)
  1210. tmp.prev=here.next;
  1211. }else
  1212. {
  1213. here.prev_child=null;
  1214. tmp=here.prev;
  1215. here.prev=all_balls.get_chain().born(child.color,tmp,child.sprite.position.x,child.sprite.position.y,here.progress-GLOBAL.D,max_prog,on_event);
  1216. inserted=here.prev;
  1217. inserted.chained=here.chained;
  1218. just_chained=true;
  1219. here.prev.next=here;
  1220. if (tmp!=null)
  1221. {
  1222. tmp.next=here.prev;
  1223. previos_progress+=l;
  1224. }else
  1225. all_balls.change_first(here,here.prev);
  1226. }
  1227. GLOBAL.BULLET.born_after=true;
  1228. CONTAINER.free(child);
  1229. inserted.ball.sprite.rotation=child.sprite.rotation;
  1230. inserted.none=true;
  1231. if (all_balls.try_match(inserted))
  1232. return;
  1233. if ((inserted.next!=null)&&(!inserted.next.chained)&&(inserted.next.color==inserted.color))
  1234. {
  1235. inserted.next.a=GLOBAL.BACK_A;
  1236. inserted.next.need_verify=true;
  1237. inserted.need_verify=true;
  1238. }else if ((!inserted.chained)&&(inserted.prev!=null)&&(inserted.prev.color==inserted.color))
  1239. {
  1240. inserted.a=GLOBAL.BACK_A;
  1241. inserted.prev.need_verify=true;
  1242. inserted.need_verify=true;
  1243. }
  1244. }else
  1245. {
  1246. child.angle=child.start_angle+(child.finish_angle-child.start_angle)*child.progress;
  1247. }
  1248. }
  1249. if ((here.prev_child!=null)&&(l>0)&&(here.prev!=null))
  1250. previos_progress+=l;
  1251. if (here.a>0)
  1252. {
  1253. back_speed+=here.a*tk;
  1254. here.progress-=back_speed*tk;
  1255. here.delta=-back_speed*tk;
  1256. }else if (here.a<0)
  1257. {
  1258. back_speed+=here.a*tk;
  1259. here.progress-=back_speed*tk;
  1260. if (here.chained)
  1261. previos_progress=here.progress;
  1262. here.delta=-back_speed*tk;
  1263. }
  1264. here.ball.update(here.progress-here.pprogress);
  1265. here.pprogress=here.progress;
  1266. if (here.a<0)
  1267. {
  1268. back_speed+=here.a*tk;
  1269. if (back_speed<=0)
  1270. {
  1271. here.a=0;
  1272. back_speed=0;
  1273. }
  1274. }
  1275. if (here.progress<previos_progress)
  1276. {
  1277. if (here.a!=0)
  1278. {
  1279. tmp=here.prev;
  1280. if (tmp!=null)
  1281. {
  1282. while ((tmp.prev!=null)&&(tmp.chained))
  1283. tmp=tmp.prev;
  1284. tmp.set_speed(back_speed);
  1285. tmp.a=-1.2*GLOBAL.BACK_A;
  1286. if (is_snd())
  1287. GLOB_knock.play();
  1288. }
  1289. }
  1290. here.a=0;
  1291. back_speed=0;
  1292. here.chained=true;
  1293. if ((here.prev!=null)&&(here.prev.need_verify)&&(here.need_verify))
  1294. {
  1295. here.need_verify=false;
  1296. here.prev.need_verify=false;
  1297. if (all_balls.try_match(here))
  1298. {
  1299. here.progress=previos_progress;
  1300. return;
  1301. }
  1302. }
  1303. }
  1304. if (here.chained)
  1305. {
  1306. here.delta=previos_progress-here.progress;
  1307. here.progress=previos_progress;
  1308. }else if (just_chained)
  1309. here.chained=true;
  1310. if (here.next!=null)
  1311. {
  1312. if ((here.next_child!=null)&&(l>0))
  1313. here.next.press(here.progress+GLOBAL.D+l,tk);
  1314. else
  1315. here.next.press(here.progress+GLOBAL.D,tk);
  1316. }
  1317. if ((here.prev==null)&&(here.progress>=max_prog)&&(here.active))
  1318. {
  1319. here.on_max();
  1320. }
  1321. }
  1322. }
  1323. function AVK_WND_BALLS(w,p)
  1324. {
  1325. var here=this;
  1326. var waves_cnt=0;
  1327. var wave_len=0;
  1328. var colors_cnt=0;
  1329. var progress_trigger=0;
  1330. var rnd_min=0;
  1331. var rnd_mul=0;
  1332. var stack=[];
  1333. var chains=[];
  1334. var scores=[];
  1335. var to_kill=[];
  1336. var random_cnt=0;
  1337. var random_color=0;
  1338. var start_x=0;
  1339. var start_y=0;
  1340. var path=p;
  1341. var way=w;
  1342. var chain_cnt=0
  1343. var tutor_colors=[3,3,0,0,3,2,2,0,0,1,1,0,2];
  1344. this.export_chains=chains;
  1345. function AVK_COLLISION()
  1346. {
  1347. this.active=false;
  1348. this.blt=null;
  1349. this.trg=null;
  1350. this.x=0;
  1351. this.y=0;
  1352. this.p=0;
  1353. }
  1354. var collision_result=new AVK_COLLISION();
  1355. /*game.GAME.b_0.sprite.visible=false;
  1356. game.GAME.b_1.sprite.visible=false;
  1357. game.GAME.b_2.sprite.visible=false;
  1358. game.GAME.b_3.sprite.visible=false;
  1359. game.GAME.b_4.sprite.visible=false;
  1360. game.GAME.b_5.sprite.visible=false;
  1361. game.GAME.b_6.sprite.visible=false;*/
  1362. function random_init()
  1363. {
  1364. random_cnt=Math.floor(rnd_min+Math.random()*rnd_mul);
  1365. random_color=Math.floor(Math.random()*colors_cnt);
  1366. }
  1367. function get_color()
  1368. {
  1369. if (GLOBAL.TUTOR==0)
  1370. {
  1371. chain_cnt++;
  1372. return tutor_colors[chain_cnt-1];
  1373. }
  1374. random_cnt--;
  1375. if (random_cnt<0)
  1376. {
  1377. random_init();
  1378. random_cnt--;
  1379. }
  1380. return random_color;
  1381. }
  1382. function get_chain()
  1383. {
  1384. for (var i=0;i<stack.length;i++)
  1385. if (!stack[i].active)
  1386. break;
  1387. if (i==stack.length)
  1388. stack.push(new AVK_WND_CHAIN(here));
  1389. return stack[i];
  1390. }
  1391. this.get_chain=get_chain;
  1392. function get_first()
  1393. {
  1394. chain_cnt=0;
  1395. var f=get_chain().born(get_color(),null,start_x,start_y,-GLOBAL.D*(wave_len-1),progress_trigger,born);
  1396. for (var i=0;i<chains.length;i++)
  1397. if (chains[i]==null)
  1398. {
  1399. chains[i]=f;
  1400. return f;
  1401. }
  1402. chains.push(f);
  1403. return f;
  1404. }
  1405. function update_waves()
  1406. {
  1407. for (var i=0;i<24;i++)
  1408. {
  1409. game.GAME["waves_"+i].sprite.visible=i<waves_cnt;
  1410. }
  1411. }
  1412. function born()
  1413. {
  1414. waves_cnt--;
  1415. update_waves();
  1416. if (waves_cnt>=0)
  1417. {
  1418. var first=get_first();
  1419. for (var i=1;i<wave_len;i++)
  1420. {
  1421. first.next=get_chain().born(get_color(),first,start_x,start_y,-GLOBAL.D*(wave_len-i-1),progress_trigger,born);
  1422. first=first.next;
  1423. }
  1424. }
  1425. }
  1426. this.try_match=function(b)
  1427. {
  1428. var first=b;
  1429. while ((first.chained)&&(first.prev!=null)&&(first.prev.color==b.color))
  1430. first=first.prev;
  1431. var cnt=1;
  1432. var x=first.ball.sprite.position.x;
  1433. var y=first.ball.sprite.position.y;
  1434. while ((first.next!=null)&&(first.next.chained)&&(first.next.color==b.color))
  1435. {
  1436. first=first.next;
  1437. x+=first.ball.sprite.position.x;
  1438. y+=first.ball.sprite.position.y;
  1439. cnt++;
  1440. }
  1441. if (cnt>2)
  1442. {
  1443. if (is_snd())
  1444. GLOB_match.play();
  1445. GLOBAL.BALLS.add_score(cnt,x/cnt,y/cnt);
  1446. if (GLOBAL.LEVEL_MUL>1)
  1447. GLOBAL.BULLET.add_ready();
  1448. while ((b.next!=null)&&(b.next.chained)&&(b.next.color==b.color))
  1449. b.next.kill(false);
  1450. while ((b.chained)&&(b.prev!=null)&&(b.prev.color==b.color))
  1451. b.prev.kill(false);
  1452. if (b.next!=null)
  1453. {
  1454. b.next.chained=false;
  1455. if ((b.prev!=null)&&(b.next.color==b.prev.color))
  1456. {
  1457. GLOBAL.LEVEL_MUL++;
  1458. b.next.a=GLOBAL.BACK_A;
  1459. b.next.need_verify=true;
  1460. b.prev.need_verify=true;
  1461. }else GLOBAL.LEVEL_MUL=1;
  1462. }else GLOBAL.LEVEL_MUL=1;
  1463. b.kill(false);
  1464. return true;
  1465. }
  1466. GLOBAL.LEVEL_MUL=1;
  1467. return false;
  1468. }
  1469. this.try_light=function(x)
  1470. {
  1471. GLOBAL.LEVEL_MUL=1;
  1472. for (var i=0;i<to_kill.length;i++)
  1473. to_kill[i]=null;
  1474. function ver_now(b)
  1475. {
  1476. if ((b.ball.sprite.position.x>x-2*b.ball.uni_width)&&(b.ball.sprite.position.x<x+2*b.ball.uni_width))
  1477. {
  1478. GLOBAL.BALLS.add_score(1,b.ball.sprite.position.x,b.ball.sprite.position.y);
  1479. for (var i=0;i<to_kill.length;i++)
  1480. if(to_kill[i]==null)
  1481. {
  1482. to_kill[i]=b;
  1483. break;
  1484. }
  1485. if (i==to_kill.length)
  1486. to_kill.push(b);
  1487. }
  1488. }
  1489. for (i=0;i<chains.length;i++)
  1490. {
  1491. var b=chains[i];
  1492. if (b!=null)
  1493. {
  1494. ver_now(b);
  1495. while (b.next!=null)
  1496. {
  1497. b=b.next;
  1498. ver_now(b);
  1499. }
  1500. }
  1501. }
  1502. for (i=0;i<to_kill.length;i++)
  1503. {
  1504. b=to_kill[i];
  1505. if (b!=null)
  1506. {
  1507. if (b.next!=null)
  1508. {
  1509. b.next.chained=false;
  1510. if (b.prev!=null)
  1511. {
  1512. if (b.next.color==b.prev.color)
  1513. {
  1514. b.next.a=GLOBAL.BACK_A;
  1515. b.next.need_verify=true;
  1516. b.prev.need_verify=true;
  1517. }else
  1518. {
  1519. b.next.a=0;
  1520. b.next.need_verify=false;
  1521. b.prev.need_verify=false;
  1522. }
  1523. }
  1524. }
  1525. b.kill(false);
  1526. }
  1527. }
  1528. }
  1529. this.change_first=function(first,new_first)
  1530. {
  1531. for (var i=0;i<chains.length;i++)
  1532. if (chains[i]==first)
  1533. {
  1534. chains[i]=new_first;
  1535. }
  1536. if (new_first==null)
  1537. first.on_max();
  1538. var f=true;
  1539. while(f)
  1540. {
  1541. f=false;
  1542. for (i=1;i<chains.length;i++)
  1543. {
  1544. if ((chains[i-1]==null)&&(chains[i]!=null))
  1545. {
  1546. f=true;
  1547. chains[i-1]=chains[i];
  1548. chains[i]=null;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. this.clear_scores=function()
  1554. {
  1555. for (var i=0;i<scores.length;i++)
  1556. if (scores[i]!=null)
  1557. {
  1558. CONTAINER.free(scores[i]);
  1559. scores[i]=null;
  1560. }
  1561. }
  1562. this.init=function(waves,len,colors,progress,r_min,r_mul,x,y)
  1563. {
  1564. waves_cnt=waves;
  1565. wave_len=len;
  1566. colors_cnt=colors;
  1567. progress_trigger=progress;
  1568. rnd_min=r_min;
  1569. rnd_mul=r_mul;
  1570. start_x=x;
  1571. start_y=y;
  1572. for (var i=0;i<stack.length;i++)
  1573. stack[i].kill(true);
  1574. for (i=0;i<chains.length;i++)
  1575. chains[i]=null;
  1576. here.clear_scores();
  1577. random_init();
  1578. }
  1579. this.start=born;
  1580. function step(c)
  1581. {
  1582. var ball=c.ball;
  1583. var progress=Math.floor(c.progress);
  1584. if (way.length<=progress)
  1585. progress=way.length;
  1586. if (0>progress)
  1587. progress=0;
  1588. if ((way.length>progress)&&(progress>=0))
  1589. {
  1590. var id_0=way[progress].path_id;
  1591. var id_1=way[progress].index;
  1592. var e=way[progress].enabled;
  1593. var x=path[id_0].x[id_1];
  1594. var y=path[id_0].y[id_1];
  1595. var dx=x-ball.sprite.position.x;
  1596. var dy=y-ball.sprite.position.y;
  1597. var a=0;
  1598. ball.enabled=e;
  1599. if (ball.enabled)
  1600. {
  1601. if (c.shad!=null)
  1602. game.GAME.place_shad.sprite.addChild(c.shad.sprite);
  1603. game.GAME.place.sprite.addChild(ball.sprite);
  1604. if (c.next_child!=null)
  1605. {
  1606. game.GAME.place.sprite.addChild(c.next_child.sprite);
  1607. }else if (c.prev_child!=null)
  1608. {
  1609. game.GAME.place.sprite.addChild(c.prev_child.sprite);
  1610. }
  1611. }else
  1612. {
  1613. if (c.shad!=null)
  1614. game.GAME.back_place_shad.sprite.addChild(c.shad.sprite);
  1615. game.GAME.back_place.sprite.addChild(ball.sprite);
  1616. if (c.next_child!=null)
  1617. {
  1618. game.GAME.back_place.sprite.addChild(c.next_child.sprite);
  1619. }else if (c.prev_child!=null)
  1620. {
  1621. game.GAME.back_place.sprite.addChild(c.prev_child.sprite);
  1622. }
  1623. }
  1624. if ((dx!=0)||(dy!=0))
  1625. {
  1626. if (c.delta>0)
  1627. a=angle(dx,dy);
  1628. else
  1629. a=angle(-dx,-dy);
  1630. ball.sprite.position.x=x;
  1631. ball.sprite.position.y=y;
  1632. if (c.shad!=null)
  1633. {
  1634. c.shad.sprite.position.x=x-GLOBAL.D*0.1;
  1635. c.shad.sprite.position.y=y+GLOBAL.D*0.1;
  1636. }
  1637. if (!c.none)
  1638. ball.sprite.rotation=a;
  1639. else
  1640. c.none=false;
  1641. }
  1642. var child=null;
  1643. var a=0;
  1644. if (c.next_child!=null)
  1645. {
  1646. child=c.next_child;
  1647. }
  1648. if (c.prev_child!=null)
  1649. {
  1650. child=c.prev_child;
  1651. }
  1652. if (child!=null)
  1653. {
  1654. child.angle=child.start_angle+(child.finish_angle-child.start_angle)*child.progress;
  1655. child.sprite.rotation=ball.sprite.rotation-child.angle;
  1656. child.sprite.position.x=ball.sprite.position.x+Math.cos(child.sprite.rotation)*GLOBAL.D;
  1657. child.sprite.position.y=ball.sprite.position.y+Math.sin(child.sprite.rotation)*GLOBAL.D;
  1658. if (c.prev_child!=null)
  1659. {
  1660. child.sprite.rotation+=Math.PI;
  1661. if ((c.prev!=null)&&(c.chained))
  1662. {
  1663. a=c.prev.ball.sprite.rotation-ball.sprite.rotation;
  1664. if (a>Math.PI)
  1665. a=-2*Math.PI+a;
  1666. if (a<-Math.PI)
  1667. a=2*Math.PI+a;
  1668. a/=2;
  1669. child.sprite.rotation+=a*child.progress;
  1670. }
  1671. }else
  1672. {
  1673. if ((c.next!=null)&&(c.next.chained))
  1674. {
  1675. a=c.next.ball.sprite.rotation-ball.sprite.rotation;
  1676. if (a>Math.PI)
  1677. a=-2*Math.PI+a;
  1678. if (a<-Math.PI)
  1679. a=2*Math.PI+a;
  1680. a/=2;
  1681. child.sprite.rotation+=a*child.progress;
  1682. }
  1683. }
  1684. }
  1685. }
  1686. }
  1687. this.born_oskolki=function(x,y,color)
  1688. {
  1689. var num=Math.floor(Math.random()*2)+2;
  1690. for(var n=0;n<num;n++)
  1691. {
  1692. var a=null;
  1693. for (var i=0;i<GLOBAL.OSKOLKI.length;i++)
  1694. if (GLOBAL.OSKOLKI[i]==null)
  1695. {
  1696. a=CONTAINER.get_object("BALLS","star_"+color,game.GAME.bullet_place);
  1697. GLOBAL.OSKOLKI[i]=a;
  1698. break;
  1699. }
  1700. if (a==null)
  1701. {
  1702. a=CONTAINER.get_object("BALLS","star_"+color,game.GAME.bullet_place);
  1703. GLOBAL.OSKOLKI.push(a);
  1704. }
  1705. a.sprite.alpha=1;
  1706. a.sprite.anchor.x=0.5;
  1707. a.sprite.anchor.y=0.5;
  1708. a.sprite.scale.x=0.5+Math.random()*0.3;
  1709. a.sprite.scale.y=a.sprite.scale.x;
  1710. a.scale=a.sprite.scale.x;
  1711. a.alpha=0.5+Math.random()*0.5;
  1712. a.sprite.position.x=x;
  1713. a.sprite.position.y=y;
  1714. a.ang=Math.random()*Math.PI*2;
  1715. a.r=GLOBAL.D/4+Math.random()*GLOBAL.D/2;
  1716. a.rad=GLOBAL.D/2;
  1717. a.speedx=Math.cos(a.ang);
  1718. a.speedy=Math.sin(a.ang);
  1719. a.tx=game.GAME.txt_score.sprite.position.x+game.GAME.txt_score.uni_width/2;
  1720. a.ty=game.GAME.txt_score.sprite.position.y+game.GAME.txt_score.uni_height/2;
  1721. a.sx=x+GLOBAL.D*8-Math.random()*GLOBAL.D*16;
  1722. a.sy=y+GLOBAL.D*8-Math.random()*GLOBAL.D*4;
  1723. a.time=1+5*(Math.sqrt((x-a.sx)*(x-a.sx)+(y-a.sy)*(y-a.sy))+Math.sqrt((a.sx-a.tx)*(a.sx-a.tx)+(a.sy-a.ty)*(a.sy-a.ty)))/2;
  1724. a.start_time=a.time;
  1725. a.ax=a.speedx/500;
  1726. a.ay=a.speedy/500;
  1727. a.sprite.position.x=x+a.rad*a.speedx;
  1728. a.sprite.position.y=y+a.rad*a.speedy;
  1729. a.x=a.sprite.position.x;
  1730. a.y=a.sprite.position.y;
  1731. a.rot=(Math.random()-0.5)/100;
  1732. }
  1733. }
  1734. function update_oskolki(tk)
  1735. {
  1736. if (GLOBAL.PAUSE)
  1737. return;
  1738. var cnt=0;
  1739. for (var i=0;i<GLOBAL.OSKOLKI.length;i++)
  1740. if ((GLOBAL.OSKOLKI[i]!=null)&&(GLOBAL.OSKOLKI[i].sprite.visible))
  1741. {
  1742. var a=GLOBAL.OSKOLKI[i];
  1743. a.time-=tk;
  1744. if (a.time<=0)
  1745. {
  1746. CONTAINER.free(a);
  1747. GLOBAL.OSKOLKI[i]=null;
  1748. }else
  1749. {
  1750. var pr=(a.start_time-a.time)/a.start_time;
  1751. a.sprite.scale.x=a.scale+(0.2-a.scale)*pr;
  1752. a.sprite.scale.y=a.sprite.scale.x;
  1753. a.ang+=tk/1000*Math.PI;
  1754. a.speedx=Math.cos(a.ang);
  1755. a.speedy=Math.sin(a.ang);
  1756. a.rad=GLOBAL.D/4+a.r*(a.start_time-a.time)/a.start_time;
  1757. a.sprite.position.x=a.x+(a.sx-a.x)*pr+(a.sx+(a.tx-a.sx)*pr-(a.x+(a.sx-a.x)*pr))*pr;
  1758. a.sprite.position.y=a.y+(a.sy-a.y)*pr+(a.sy+(a.ty-a.sy)*pr-(a.y+(a.sy-a.y)*pr))*pr;
  1759. }
  1760. }
  1761. for (i=0;i<GLOBAL.KILLED.length;i++)
  1762. if ((GLOBAL.KILLED[i]!=null)&&(GLOBAL.KILLED[i].sprite.visible))
  1763. {
  1764. cnt++;
  1765. var a=GLOBAL.KILLED[i];
  1766. a.time-=tk;
  1767. if (a.time<=0)
  1768. {
  1769. CONTAINER.free(a);
  1770. GLOBAL.KILLED[i]=null;
  1771. }else
  1772. {
  1773. var pr=(a.start_time-a.time)/a.start_time;
  1774. a.sprite.scale.x=1-pr;
  1775. a.sprite.scale.y=a.sprite.scale.x;
  1776. a.sprite.alpha=0.9-0.9*pr;
  1777. }
  1778. }
  1779. if (GLOBAL.FINISH)
  1780. return;
  1781. if (cnt==0)
  1782. {
  1783. for (i=0;i<chains.length;i++)
  1784. if (chains[i]!=null)
  1785. return;
  1786. GLOBAL.WND_GAME.show_win();
  1787. }
  1788. }
  1789. this.born_stars=function(x,y)
  1790. {
  1791. for (var n=0;n<15;n++)
  1792. {
  1793. var a=null;
  1794. for (var i=0;i<scores.length;i++)
  1795. if (scores[i]==null)
  1796. {
  1797. a=CONTAINER.get_object("GAME","zvezda_part",game.GAME.part_place);
  1798. scores[i]=a;
  1799. break;
  1800. }
  1801. if (a==null)
  1802. {
  1803. a=CONTAINER.get_object("GAME","zvezda_part",game.GAME.part_place);
  1804. scores.push(a);
  1805. }
  1806. a.speedx=(Math.random()-0.5)*0.33;
  1807. a.speeddx=0;
  1808. a.speedy=(Math.random()-0.9)*0.48;
  1809. a.speeddy=0.0009;
  1810. a.sprite.anchor.x=0.5;
  1811. a.sprite.anchor.y=0.5;
  1812. a.sprite.position.x=x;
  1813. a.sprite.position.y=y;
  1814. a.sprite.scale.x=Math.random();
  1815. a.sprite.scale.y=a.sprite.scale.x;
  1816. }
  1817. }
  1818. function born_score(txt,x,y)
  1819. {
  1820. var a=null;
  1821. for (var i=0;i<scores.length;i++)
  1822. if (scores[i]==null)
  1823. {
  1824. a=CONTAINER.get_object("GAME","txt_score_part",game.GAME.bullet_place);
  1825. scores[i]=a;
  1826. break;
  1827. }
  1828. if (a==null)
  1829. {
  1830. a=CONTAINER.get_object("GAME","txt_score_part",game.GAME.bullet_place);
  1831. scores.push(a);
  1832. }
  1833. a.set_style(0.43,"AVK_FNT_main","left");
  1834. a.set_text(convert(txt));
  1835. a.speedx=-0.03;
  1836. a.speeddx=0;
  1837. a.speedy=-0.1;
  1838. a.speeddy=-0.0005;
  1839. a.sprite.position.x=x;
  1840. a.sprite.position.y=y;
  1841. }
  1842. function update_scores(tk)
  1843. {
  1844. if (GLOBAL.CURRENT_SCORE<GLOBAL.SCORE)
  1845. {
  1846. var delta=Math.floor((GLOBAL.SCORE-GLOBAL.CURRENT_SCORE)*tk/200);
  1847. if (delta<1)
  1848. delta=1;
  1849. GLOBAL.CURRENT_SCORE+=delta;
  1850. if (GLOBAL.CURRENT_SCORE>GLOBAL.SCORE)
  1851. GLOBAL.CURRENT_SCORE=GLOBAL.SCORE;
  1852. var s=convert(""+GLOBAL.CURRENT_SCORE);
  1853. game.GAME.txt_score.set_text(s);
  1854. var i=s.length;
  1855. var n=Math.floor(i/4);
  1856. i-=n;
  1857. game.GAME.txt_score.txt.position.x=game.GAME.txt_score.uni_width-i*22-n*12;
  1858. if (GLOBAL.CURRENT_SCORE>=GLOBAL.TR_1)
  1859. {
  1860. if (GLOBAL.WIN_PROGRESS==0)
  1861. {
  1862. game.GAME.prog_0.sprite.scale.x=GLOBAL.TR_1/GLOBAL.TR;
  1863. GLOBAL.WIN_PROGRESS++;
  1864. GLOBAL.BALLS.born_oskolki(game.GAME.prog_1.sprite.position.x,game.GAME.prog_1.sprite.position.y,1);
  1865. GLOBAL.BALLS.born_oskolki(game.GAME.prog_1.sprite.position.x,game.GAME.prog_1.sprite.position.y,1);
  1866. GLOBAL.BALLS.born_oskolki(game.GAME.prog_1.sprite.position.x,game.GAME.prog_1.sprite.position.y,1);
  1867. if (is_snd())
  1868. GLOB_up.play();
  1869. }else if (GLOBAL.CURRENT_SCORE>=GLOBAL.TR_2+GLOBAL.TR_1)
  1870. {
  1871. if (GLOBAL.WIN_PROGRESS==1)
  1872. {
  1873. game.GAME.prog_1.sprite.scale.x=GLOBAL.TR_2/GLOBAL.TR;
  1874. GLOBAL.WIN_PROGRESS++;
  1875. GLOBAL.BALLS.born_oskolki(game.GAME.prog_2.sprite.position.x,game.GAME.prog_2.sprite.position.y,2);
  1876. GLOBAL.BALLS.born_oskolki(game.GAME.prog_2.sprite.position.x,game.GAME.prog_2.sprite.position.y,2);
  1877. GLOBAL.BALLS.born_oskolki(game.GAME.prog_2.sprite.position.x,game.GAME.prog_2.sprite.position.y,2);
  1878. if (is_snd())
  1879. GLOB_up.play();
  1880. }else if (GLOBAL.CURRENT_SCORE>=GLOBAL.TR_3+GLOBAL.TR_2+GLOBAL.TR_1)
  1881. {
  1882. if (GLOBAL.WIN_PROGRESS==2)
  1883. {
  1884. game.GAME.prog_2.sprite.scale.x=GLOBAL.TR_3/GLOBAL.TR;
  1885. GLOBAL.WIN_PROGRESS++;
  1886. GLOBAL.BALLS.born_oskolki(game.GAME.prog_0.sprite.position.x+game.GAME.prog_0.uni_width,game.GAME.prog_0.sprite.position.y,0);
  1887. GLOBAL.BALLS.born_oskolki(game.GAME.prog_0.sprite.position.x+game.GAME.prog_0.uni_width,game.GAME.prog_0.sprite.position.y,0);
  1888. GLOBAL.BALLS.born_oskolki(game.GAME.prog_0.sprite.position.x+game.GAME.prog_0.uni_width,game.GAME.prog_0.sprite.position.y,0);
  1889. if (is_snd())
  1890. GLOB_up.play();
  1891. }
  1892. }else
  1893. {
  1894. game.GAME.prog_2.sprite.scale.x=GLOBAL.TR_3/GLOBAL.TR*(GLOBAL.CURRENT_SCORE-GLOBAL.TR_2-GLOBAL.TR_1)/GLOBAL.TR_3;
  1895. }
  1896. }else
  1897. {
  1898. game.GAME.prog_1.sprite.scale.x=GLOBAL.TR_2/GLOBAL.TR*(GLOBAL.CURRENT_SCORE-GLOBAL.TR_1)/GLOBAL.TR_2;
  1899. }
  1900. }else
  1901. {
  1902. game.GAME.prog_0.sprite.scale.x=GLOBAL.TR_1/GLOBAL.TR*GLOBAL.CURRENT_SCORE/GLOBAL.TR_1;
  1903. }
  1904. }
  1905. for (var i=0;i<scores.length;i++)
  1906. if ((scores[i]!=null)&&(scores[i].sprite.visible))
  1907. {
  1908. a=scores[i];
  1909. a.sprite.position.x+=a.speedx*tk;
  1910. a.sprite.position.y+=a.speedy*tk;
  1911. a.speedx+=a.speeddx*tk;
  1912. a.speedy+=a.speeddy*tk;
  1913. if ((a.sprite.position.y<=-a.uni_height)||(a.sprite.position.y>=game.SCREEN_HEIGHT+a.uni_height)||(a.sprite.position.x<=-a.uni_width)||(a.sprite.position.x>=game.SCREEN_WIDTH+a.uni_width))
  1914. {
  1915. CONTAINER.free(a);
  1916. scores[i]=null;
  1917. }
  1918. }
  1919. }
  1920. this.update_scores=update_scores;
  1921. function add_score(m,x,y)
  1922. {
  1923. born_score(convert(m*10*GLOBAL.LEVEL_MUL),x,y);
  1924. GLOBAL.SCORE+=GLOBAL.LEVEL_MUL*m*10;
  1925. }
  1926. this.add_score=add_score;
  1927. this.update=function(tk)
  1928. {
  1929. update_oskolki(tk);
  1930. update_scores(tk);
  1931. if (!GLOBAL.RUN)
  1932. return;
  1933. for (var i=0;i<GLOBAL.COLORS.length;i++)
  1934. GLOBAL.COLORS[i]=false;
  1935. GLOBAL.BULLET.born_after=false;
  1936. GLOBAL.MAX_PROG=0;
  1937. for (i=0;i<chains.length;i++)
  1938. {
  1939. var tmp=chains[i];
  1940. if (tmp!=null)
  1941. {
  1942. tmp.step(tk);
  1943. tmp=chains[i];
  1944. }
  1945. }
  1946. if (GLOBAL.MAX_PROG>=GLOBAL.LENGTH)
  1947. {
  1948. GLOBAL.WND_GAME.show_loose();
  1949. if((is_snd())&&(GLOBAL.HEART))
  1950. {
  1951. GLOBAL.HEART=false;
  1952. GLOB_heart.stop();
  1953. }
  1954. }else if (GLOBAL.MAX_PROG>=GLOBAL.LENGTH-GLOBAL.D*5)
  1955. {
  1956. if ((is_snd())&&(!GLOBAL.HEART))
  1957. {
  1958. GLOBAL.HEART=true;
  1959. GLOB_heart.play("none",0,0,-1);
  1960. }
  1961. }else if ((is_snd()) &&(GLOBAL.HEART))
  1962. {
  1963. GLOBAL.HEART=false;
  1964. GLOB_heart.stop();
  1965. }
  1966. for (i=0;i<chains.length;i++)
  1967. {
  1968. var tmp=chains[i];
  1969. while (tmp!=null)
  1970. {
  1971. GLOBAL.COLORS[tmp.color]=true;
  1972. tmp=tmp.next;
  1973. }
  1974. }
  1975. if (GLOBAL.BULLET.born_after)
  1976. GLOBAL.BULLET.born();
  1977. var last=null;
  1978. var prev=null;
  1979. var prev_index=null;
  1980. var l=0;
  1981. var tmp=0;
  1982. for (i=0;i<chains.length;i++)
  1983. {
  1984. tmp=chains[i];
  1985. if (tmp!=null)
  1986. {
  1987. if (prev!=null)
  1988. {
  1989. last=tmp;
  1990. while (last.next!=null)
  1991. last=last.next;
  1992. l=0;
  1993. if (last.next_child!=null)
  1994. l=Math.abs(Math.cos(last.next_child.angle))*GLOBAL.D*2-GLOBAL.D;
  1995. if (prev.prev_child!=null)
  1996. l+=Math.abs(Math.cos(prev.prev_child.angle))*GLOBAL.D*2-GLOBAL.D;
  1997. if (last.progress+GLOBAL.D+l>=prev.progress)
  1998. {
  1999. if (is_snd())
  2000. GLOB_knock.play();
  2001. last.next=prev;
  2002. prev.set_max_prog(last.get_max_prog(),last.get_max_on());
  2003. prev.prev=last;
  2004. prev.chained=true;
  2005. chains[prev_index]=null;
  2006. if (prev.a!=0)
  2007. {
  2008. tmp=prev.prev;
  2009. if (tmp!=null)
  2010. {
  2011. while ((tmp.prev!=null)&&(tmp.chained))
  2012. tmp=tmp.prev;
  2013. tmp.set_speed(prev.get_back_speed());
  2014. tmp.a=-1.2*GLOBAL.BACK_A;
  2015. }
  2016. }
  2017. prev.a=0;
  2018. prev.set_speed(0);
  2019. prev.press(last.progress+GLOBAL.D,0);
  2020. }
  2021. }
  2022. prev=tmp;
  2023. prev_index=i;
  2024. }
  2025. }
  2026. last=true
  2027. while(last)
  2028. {
  2029. last=false;
  2030. for (i=1;i<chains.length;i++)
  2031. {
  2032. if ((chains[i-1]==null)&&(chains[i]!=null))
  2033. {
  2034. last=true;
  2035. chains[i-1]=chains[i];
  2036. chains[i]=null;
  2037. }
  2038. }
  2039. }
  2040. for (i=0;i<chains.length;i++)
  2041. {
  2042. var tmp=chains[i];
  2043. while(tmp!=null)
  2044. {
  2045. step(tmp);
  2046. tmp=tmp.next;
  2047. }
  2048. }
  2049. }
  2050. function on_collision(blt,target,xr,yr,pr)
  2051. {
  2052. if (pr<collision_result.p)
  2053. {
  2054. collision_result.active=true;
  2055. collision_result.blt=blt;
  2056. collision_result.trg=target;
  2057. collision_result.x=xr;
  2058. collision_result.y=yr;
  2059. collision_result.p=pr;
  2060. }
  2061. }
  2062. this.verify_bullet=function(blt,lx0,lx1,ly0,ly1)
  2063. {
  2064. collision_result.active=false;
  2065. collision_result.p=1000000;
  2066. for (i=0;i<chains.length;i++)
  2067. {
  2068. target=chains[i];
  2069. while (target!=null)
  2070. {
  2071. if (target.ball.enabled)
  2072. {
  2073. var ox=target.ball.sprite.position.x;
  2074. var oy=target.ball.sprite.position.y;
  2075. var or=target.ball.uni_height/2;
  2076. var l=get_l(lx1-lx0,ly1-ly0);
  2077. var r=Math.abs(((ly0-ly1)*ox+(lx1-lx0)*oy+(lx0*ly1-lx1*ly0))/l);//Кратчайшее расстояние до прямой
  2078. if (r<2*or)
  2079. {
  2080. var l1=Math.sqrt(4*or*or-r*r);//расстояние от точки проекции до центра шара с касанием
  2081. var m=Math.sqrt((ox-lx0)*(ox-lx0)+(oy-ly0)*(oy-ly0)-r*r);//расстояние от точки проекции до начала отрезка
  2082. var rp=m-l1;//расстояние, которое нужно пройти до пересечения
  2083. if (l>=rp)//расстояние пройдено с лихвой
  2084. {
  2085. var pr=rp/l;
  2086. var xr=lx0+(lx1-lx0)*pr;
  2087. var yr=ly0+(ly1-ly0)*pr;
  2088. on_collision(blt,target,xr,yr,pr);
  2089. }
  2090. }
  2091. }
  2092. target=target.next;
  2093. }
  2094. }
  2095. if (collision_result.active)
  2096. {
  2097. if (is_snd())
  2098. GLOB_knock.play();
  2099. var a=collision_result.trg.ball.sprite.rotation-angle(collision_result.blt.sprite.position.x-collision_result.trg.ball.sprite.position.x,collision_result.blt.sprite.position.y-collision_result.trg.ball.sprite.position.y);
  2100. if (Math.abs(a)>Math.PI)
  2101. {
  2102. if (a>0)
  2103. a=2*Math.PI-a;
  2104. else if (a<0)
  2105. a=2*Math.PI+a;
  2106. }
  2107. collision_result.blt.start_angle=a;
  2108. collision_result.blt.angle=a;
  2109. collision_result.blt.progress=0;
  2110. game.GAME.place.sprite.addChild(collision_result.blt.sprite);
  2111. if (Math.abs(a)<Math.PI/2)
  2112. {//спереди стыкуем
  2113. collision_result.blt.finish_angle=0;
  2114. collision_result.trg.next_child=collision_result.blt;
  2115. collision_result.trg.next_child.beg_time=1+GLOBAL.INSERTS*Math.abs(a)/(Math.PI/2);
  2116. collision_result.trg.next_child.end_time=collision_result.trg.next_child.beg_time;
  2117. }else
  2118. {//сзади
  2119. collision_result.trg.prev_child=collision_result.blt;
  2120. collision_result.trg.prev_child.beg_time=1+GLOBAL.INSERTS*(Math.PI-Math.abs(a))/(Math.PI/2);
  2121. collision_result.trg.prev_child.end_time=collision_result.trg.prev_child.beg_time;
  2122. if (a>0)
  2123. collision_result.blt.finish_angle=Math.PI;
  2124. else
  2125. collision_result.blt.finish_angle=-Math.PI;
  2126. }
  2127. collision_result.blt.sprite.position.x=collision_result.x;
  2128. collision_result.blt.sprite.position.y=collision_result.y;
  2129. return true;
  2130. }
  2131. return false;
  2132. }
  2133. }
  2134. function AVK_WND_GAME()
  2135. {
  2136. var here=this;
  2137. var path=[];
  2138. var way=[];
  2139. var path_length=0;
  2140. var balls=new AVK_WND_BALLS(way,path);
  2141. GLOBAL.BALLS=balls;
  2142. GLOBAL.BULLET=new AVK_WND_BULLET(balls);
  2143. this.level_num=0;
  2144. function AVK_WAY()
  2145. {
  2146. this.path_id=0;
  2147. this.index=0;
  2148. this.enabled=true;
  2149. }
  2150. function AVK_PATH()
  2151. {
  2152. this.x=new Array(GLOBAL.PATH_POINTS);
  2153. this.y=new Array(GLOBAL.PATH_POINTS);
  2154. this.l=new Array(GLOBAL.PATH_POINTS);
  2155. this.l[GLOBAL.PATH_POINTS-1]=0;
  2156. }
  2157. function update(tk)
  2158. {
  2159. if (game.GAME.tutor.sprite.visible)
  2160. return;
  2161. game.GAME.wrays.sprite.rotation+=tk/1500;
  2162. game.GAME.brays.sprite.rotation-=tk/1500;
  2163. balls.update(tk);
  2164. if (!GLOBAL.RUN)
  2165. return;
  2166. GLOBAL.TIME+=tk;
  2167. if (GLOBAL.TUTOR<1000000)
  2168. {
  2169. if(GLOBAL.TUTOR_STEPS[GLOBAL.TUTOR]<GLOBAL.TIME)
  2170. {
  2171. GLOBAL.TUTOR++;
  2172. switch(GLOBAL.TUTOR)
  2173. {
  2174. case 1:
  2175. var tmp=balls.export_chains[0];
  2176. for (var i=0;i<10;i++)
  2177. tmp=tmp.next;
  2178. tutor.start(tmp.ball.sprite.position.x,game.SCREEN_HEIGHT-game.GAME.hand.uni_height*1.1);
  2179. break;
  2180. case 3:
  2181. var tmp=balls.export_chains[0];
  2182. for (var i=0;i<3;i++)
  2183. tmp=tmp.next;
  2184. tutor.start(tmp.ball.sprite.position.x,game.SCREEN_HEIGHT-game.GAME.hand.uni_height*1.1);
  2185. break;
  2186. }
  2187. }
  2188. }
  2189. GLOBAL.BULLET.update(tk);
  2190. }
  2191. add_to_update(update);
  2192. function get_coord(start,middle,finish,progress)
  2193. {
  2194. return start+(middle-start)*progress+(middle+(finish-middle)*progress-(start+(middle-start)*progress))*progress;
  2195. }
  2196. function init_path(level,pnt_cnt)
  2197. {
  2198. var start_x=0;
  2199. var start_y=0;
  2200. var mid_x=0;
  2201. var mid_y=0;
  2202. var finish_x=0;
  2203. var finish_y=0;
  2204. for (var i=0;i<pnt_cnt;i++)
  2205. {
  2206. if (i+1>=path.length)
  2207. {
  2208. path.push(new AVK_PATH());
  2209. }
  2210. var pnt_name="l_"+level+"_pnt_"+(i-1);
  2211. var n1_pnt_name="l_"+level+"_pnt_"+(i+0);
  2212. var n2_pnt_name="l_"+level+"_pnt_"+(i+1);
  2213. if (i==0)
  2214. {
  2215. start_x=game.GAME[n1_pnt_name].sprite.position.x+game.GAME[n1_pnt_name].uni_width/2;
  2216. start_y=game.GAME[n1_pnt_name].sprite.position.y+game.GAME[n1_pnt_name].uni_width/2;
  2217. var l=get_l(start_x-(game.GAME[n2_pnt_name].sprite.position.x+game.GAME[n2_pnt_name].uni_width/2),start_y-(game.GAME[n2_pnt_name].sprite.position.y+game.GAME[n2_pnt_name].uni_width/2));
  2218. start_x+=(start_x-(game.GAME[n2_pnt_name].sprite.position.x+game.GAME[n2_pnt_name].uni_width/2))/l;
  2219. start_y+=(start_y-(game.GAME[n2_pnt_name].sprite.position.y+game.GAME[n2_pnt_name].uni_width/2))/l;
  2220. }else
  2221. {
  2222. start_x=game.GAME[pnt_name].sprite.position.x+game.GAME[pnt_name].uni_width/2;
  2223. start_y=game.GAME[pnt_name].sprite.position.y+game.GAME[pnt_name].uni_width/2;
  2224. }
  2225. mid_x=game.GAME[n1_pnt_name].sprite.position.x+game.GAME[n1_pnt_name].uni_width/2;
  2226. mid_y=game.GAME[n1_pnt_name].sprite.position.y+game.GAME[n1_pnt_name].uni_width/2;
  2227. if (i==pnt_cnt-1)
  2228. {
  2229. l=get_l(mid_x-start_x,mid_y-start_y);
  2230. finish_x=mid_x+(mid_x-start_x)/l;
  2231. finish_y=mid_y+(mid_y-start_y)/l;
  2232. }else
  2233. {
  2234. finish_x=game.GAME[n2_pnt_name].sprite.position.x+game.GAME[n2_pnt_name].uni_width/2;
  2235. finish_y=game.GAME[n2_pnt_name].sprite.position.y+game.GAME[n2_pnt_name].uni_width/2;
  2236. }
  2237. start_x=(start_x+mid_x)/2;
  2238. start_y=(start_y+mid_y)/2;
  2239. finish_x=(finish_x+mid_x)/2;
  2240. finish_y=(finish_y+mid_y)/2;
  2241. for (var progress=0;progress<path[i].x.length;progress++)
  2242. {
  2243. path[i].x[progress]=get_coord(start_x,mid_x,finish_x,progress/(path[i].x.length-1));//последняя точка тоже в массиве
  2244. path[i].y[progress]=get_coord(start_y,mid_y,finish_y,progress/(path[i].x.length-1));
  2245. if (progress>0)
  2246. {
  2247. path[i].l[progress-1]=Math.sqrt((path[i].x[progress]-path[i].x[progress-1])*(path[i].x[progress]-path[i].x[progress-1])+(path[i].y[progress]-path[i].y[progress-1])*(path[i].y[progress]-path[i].y[progress-1]));
  2248. }
  2249. }
  2250. }
  2251. }
  2252. function add_way(pnt,e)
  2253. {
  2254. for (var progress=0;progress<path[pnt].x.length;progress++)
  2255. {
  2256. path_length+=path[pnt].l[progress];
  2257. if (path_length>=1)
  2258. {
  2259. var a=new AVK_WAY();
  2260. a.path_id=pnt;
  2261. a.index=progress;
  2262. a.enabled=e;
  2263. way.push(a);
  2264. path_length-=1;
  2265. }
  2266. }
  2267. }
  2268. function init(level)
  2269. {
  2270. GLOBAL.PAUSE=false;
  2271. load_stat();
  2272. GLOBAL.HEART=false;
  2273. game.GAME.wrays.sprite.visible=false;
  2274. game.GAME.brays.sprite.visible=false;
  2275. GLOBAL.BULLET.clear_ready();
  2276. GLOBAL.LEVEL_MUL=1;
  2277. GLOBAL.SCORE=0;
  2278. GLOBAL.CURRENT_SCORE=0;
  2279. GLOBAL.WIN_PROGRESS=0;
  2280. game.GAME.txt_score.set_text("");
  2281. for (i=0;i<10;i++)
  2282. {
  2283. if (game.GAME["head_"+i].sprite.parent!=null)
  2284. game.GAME["head_"+i].sprite.parent.removeChild(game.GAME["head_"+i].sprite);
  2285. if (game.GAME["up_"+i].sprite.parent!=null)
  2286. game.GAME["up_"+i].sprite.parent.removeChild(game.GAME["up_"+i].sprite);
  2287. if (game.GAME["res_"+i].sprite.parent!=null)
  2288. game.GAME["res_"+i].sprite.parent.removeChild(game.GAME["res_"+i].sprite);
  2289. }
  2290. GLOBAL.UP_SPR.addChild(game.GAME["up_"+level].sprite);
  2291. GLOBAL.HEAD_SPR.addChild(game.GAME["head_"+level].sprite);
  2292. game.GAME.back.sprite.addChild(game.GAME["res_"+level].sprite);
  2293. game.GAME["head_"+level].sprite.visible=true;
  2294. game.GAME["up_"+level].sprite.visible=true;
  2295. /*game.GAME["up_"+level].sprite.position.x=0;
  2296. game.GAME["up_"+level].sprite.position.y=0;
  2297. game.GAME["up_"+level].sprite.scale.y=2;*/
  2298. game.GAME["res_"+level].sprite.visible=true;
  2299. //game.GAME["res_"+level].sprite.position.x=0;
  2300. //game.GAME["res_"+level].sprite.position.y=0;
  2301. //game.GAME["real_back_"+level].sprite.visible=true;
  2302. path_length=0;
  2303. while (way.length>0)
  2304. way.pop();
  2305. var cnt=0;
  2306. var elem=game.filtered("points","pnt",cnt,"level",level);
  2307. while(elem!=null)
  2308. {
  2309. cnt++;
  2310. elem=game.filtered("points","pnt",cnt,"level",level);
  2311. }
  2312. init_path(level,cnt);
  2313. for (var i=0;i<cnt;i++)
  2314. add_way(i,game.filtered("points","enabled",i,"level",level)==1);
  2315. GLOBAL.LENGTH=way.length;
  2316. }
  2317. function on_show()
  2318. {
  2319. SG_Hooks.start();
  2320. GLOBAL.RUN=true;
  2321. GLOBAL.TIME=0;
  2322. GLOBAL.BULLET.set_color();
  2323. balls.start();
  2324. GLOBAL.FINISH=false;
  2325. var tmp=balls.export_chains[0];
  2326. while (tmp.next!=null)
  2327. tmp=tmp.next;
  2328. }
  2329. this.on_show=on_show;
  2330. this.start=function()
  2331. {
  2332. if ((GLOBAL.TUTOR==0)||(GLOBAL.TUTOR==2))
  2333. return;
  2334. GLOBAL.BULLET.start();
  2335. }
  2336. this.show_level=function()
  2337. {
  2338. game.MAIN.levels.sprite.visible=true;
  2339. game.MAIN.main.sprite.visible=true;
  2340. game.ACT.start("from_right",game.MAIN.levels);
  2341. game.ACT.start("to_left",game.MAIN.main,hide_btn_start);
  2342. game.GUI_BUSY=true;
  2343. function hide_btn_start()
  2344. {
  2345. game.GUI_BUSY=false;
  2346. game.MAIN.levels.sprite.visible=true;
  2347. game.MAIN.main.sprite.visible=false;
  2348. }
  2349. }
  2350. this.hide_level=function()
  2351. {
  2352. game.MAIN.levels.sprite.visible=true;
  2353. game.MAIN.main.sprite.visible=true;
  2354. game.ACT.start("to_right",game.MAIN.levels);
  2355. game.ACT.start("from_left",game.MAIN.main,hide_levels);
  2356. game.GUI_BUSY=true;
  2357. function hide_levels()
  2358. {
  2359. game.GUI_BUSY=false;
  2360. game.MAIN.levels.sprite.visible=false;
  2361. game.MAIN.main.sprite.visible=true;
  2362. }
  2363. for (var i=0;i<GLOBAL.OSKOLKI.length;i++)
  2364. if (GLOBAL.OSKOLKI[i]!=null)
  2365. {
  2366. var a=GLOBAL.OSKOLKI[i];
  2367. CONTAINER.free(a);
  2368. GLOBAL.OSKOLKI[i]=null;
  2369. }
  2370. for (i=0;i<GLOBAL.KILLED.length;i++)
  2371. if (GLOBAL.KILLED[i]!=null)
  2372. {
  2373. var a=GLOBAL.KILLED[i];
  2374. CONTAINER.free(a);
  2375. GLOBAL.KILLED[i]=null;
  2376. }
  2377. }
  2378. this.show=function(id)
  2379. {
  2380. here.level_num=id;
  2381. here.pre_show();
  2382. GLOBAL.SHOW_HANDLER=on_show;
  2383. show_wnd_left(game.GAME);
  2384. }
  2385. this.pre_show=function()
  2386. {
  2387. var id=here.level_num;
  2388. game.GAME.shadow.sprite.visible=false;
  2389. game.GAME.win_wnd.sprite.visible=false;
  2390. game.GAME.loose_wnd.sprite.visible=false;
  2391. for (var i=0;i<10;i++)
  2392. {
  2393. game.GAME["head_"+i].sprite.visible=false;
  2394. game.GAME["up_"+i].sprite.visible=false;
  2395. game.GAME["res_"+i].sprite.visible=false;
  2396. }
  2397. init(game.get("levels","level",id));//waves,len,colors,progress,r_min,r_mul,x,y
  2398. GLOBAL.MUL=game.get("levels","mul",id);
  2399. balls.init(game.get("levels","waves",id),game.get("levels","len",id),game.get("levels","colors",id),game.get("levels","progress",id),game.get("levels","r_min",id),game.get("levels","r_max",id),path[0].x[0],path[0].y[0]);
  2400. GLOBAL.TR_1=game.get("levels","t1",id);
  2401. GLOBAL.TR_2=game.get("levels","t2",id)-GLOBAL.TR_1;
  2402. GLOBAL.TR_3=game.get("levels","t3",id)-GLOBAL.TR_2-GLOBAL.TR_1;;
  2403. GLOBAL.TR=GLOBAL.TR_1+GLOBAL.TR_2+GLOBAL.TR_3;
  2404. game.GAME.prog_0.sprite.scale.x=GLOBAL.TR_1/GLOBAL.TR;
  2405. game.GAME.prog_1.sprite.position.x=game.GAME.prog_0.sprite.position.x+game.GAME.prog_0.uni_width*GLOBAL.TR_1/GLOBAL.TR;
  2406. game.GAME.riska_0.sprite.position.x=game.GAME.prog_1.sprite.position.x;
  2407. game.GAME.prog_1.sprite.scale.x=GLOBAL.TR_2/GLOBAL.TR;
  2408. game.GAME.prog_2.sprite.position.x=game.GAME.prog_1.sprite.position.x+game.GAME.prog_1.uni_width*GLOBAL.TR_2/GLOBAL.TR;
  2409. game.GAME.riska_1.sprite.position.x=game.GAME.prog_2.sprite.position.x;
  2410. game.GAME.prog_2.sprite.scale.x=GLOBAL.TR_3/GLOBAL.TR;
  2411. game.GAME.prog_0.sprite.scale.x=0;
  2412. game.GAME.prog_1.sprite.scale.x=0;
  2413. game.GAME.prog_2.sprite.scale.x=0;
  2414. GLOBAL.BULLET.clear();
  2415. game.GAME.txt_score.set_text("");
  2416. }
  2417. this.close=function()
  2418. {
  2419. game.GAME.brays.sprite.visible=false;
  2420. game.GAME.wrays.sprite.visible=false;
  2421. GLOBAL.FINISH=true;
  2422. game.GAME.shadow.sprite.visible=false;
  2423. game.GAME.win_wnd.sprite.visible=false;
  2424. game.GAME.loose_wnd.sprite.visible=false;
  2425. GLOBAL.RUN=false;
  2426. hide_wnd_left();
  2427. }
  2428. this.pause=function()
  2429. {
  2430. GLOBAL.PAUSE=true;
  2431. GLOBAL.RUN=false;
  2432. game.GAME.star_0.sprite.visible=false;
  2433. game.GAME.star_1.sprite.visible=false;
  2434. game.GAME.star_2.sprite.visible=false;
  2435. game.GAME.win_wnd.sprite.position.y=-game.GAME.win_wnd.uni_height;
  2436. game.GAME.win_wnd.sprite.visible=true;
  2437. here.wnd.wnd=game.GAME.win_wnd;
  2438. game.ACT.start("pr",here.wnd);
  2439. game.GAME.shadow.sprite.visible=true;
  2440. game.GAME.shadow.sprite.alpha=0;
  2441. game.GAME.win_wnd_back.sprite.visible=false;
  2442. }
  2443. function AVK_show_wnd()
  2444. {
  2445. var here=this;
  2446. this.wnd=null;
  2447. this.set_property=function (val)
  2448. {
  2449. here.wnd.sprite.position.y=-this.wnd.uni_height+(this.wnd.y+this.wnd.uni_height)*val;
  2450. game.GAME.shadow.sprite.alpha=val/2;
  2451. }
  2452. this.finish=function ()
  2453. {
  2454. var w=null;
  2455. if (here.wnd==game.GAME.win_wnd)
  2456. w=game.GAME.wrays;
  2457. else
  2458. w=game.GAME.brays;
  2459. w.sprite.visible=true;
  2460. w.sprite.alpha=0;
  2461. game.ACT.start("alpha",w);
  2462. if (here.wnd==game.GAME.loose_wnd)
  2463. game.GUI_BUSY=false;
  2464. }
  2465. }
  2466. this.wnd=new AVK_show_wnd();
  2467. function AVK_zvezda()
  2468. {
  2469. var here=this;
  2470. var prog;
  2471. var f=0;
  2472. this.set_property=function(p)
  2473. {
  2474. if (p<1/3)
  2475. {
  2476. if (!game.GAME.star_0.sprite.visible)
  2477. game.GUI_BUSY=false;
  2478. game.GAME.star_0.sprite.alpha=p*3;
  2479. game.GAME.star_0.sprite.scale.x=-3+12*p;
  2480. game.GAME.star_0.sprite.scale.y=3-6*p;
  2481. }else if (p<2/3)
  2482. {
  2483. if (!game.GAME.star_1.sprite.visible)
  2484. game.GUI_BUSY=false;
  2485. else if (f==0)
  2486. {
  2487. f++;
  2488. if (is_snd())
  2489. GLOB_match.play();
  2490. }
  2491. if ((prog==0)&&(game.GAME.star_0.sprite.visible))
  2492. {
  2493. balls.born_stars(game.GAME.star_0.sprite.position.x+game.GAME.win_wnd.sprite.position.x,game.GAME.star_0.sprite.position.y+game.GAME.win_wnd.sprite.position.y);
  2494. prog++;
  2495. }
  2496. game.GAME.star_0.sprite.alpha=1;
  2497. game.GAME.star_1.sprite.alpha=(p-1/3)*3;
  2498. game.GAME.star_1.sprite.scale.x=-3+12*(p-1/3);
  2499. game.GAME.star_1.sprite.scale.y=3-6*(p-1/3);
  2500. }else
  2501. {
  2502. if (!game.GAME.star_2.sprite.visible)
  2503. game.GUI_BUSY=false;
  2504. else if (f==1)
  2505. {
  2506. f++;
  2507. if (is_snd())
  2508. GLOB_match.play();
  2509. }
  2510. if ((prog==1)&&(game.GAME.star_1.sprite.visible))
  2511. {
  2512. balls.born_stars(game.GAME.star_1.sprite.position.x+game.GAME.win_wnd.sprite.position.x,game.GAME.star_1.sprite.position.y+game.GAME.win_wnd.sprite.position.y);
  2513. prog++;
  2514. }
  2515. game.GAME.star_0.sprite.alpha=1;
  2516. game.GAME.star_1.sprite.alpha=1;
  2517. game.GAME.star_0.sprite.scale.x=1;
  2518. game.GAME.star_0.sprite.scale.y=1;
  2519. game.GAME.star_1.sprite.scale.x=1;
  2520. game.GAME.star_1.sprite.scale.y=1;
  2521. game.GAME.star_2.sprite.alpha=(p-2/3)*3;
  2522. game.GAME.star_2.sprite.scale.x=-3+12*(p-2/3);
  2523. game.GAME.star_2.sprite.scale.y=3-6*(p-2/3);
  2524. }
  2525. }
  2526. this.finish=function()
  2527. {
  2528. if (game.GAME.star_2.sprite.visible)
  2529. {
  2530. balls.born_stars(game.GAME.star_2.sprite.position.x+game.GAME.win_wnd.sprite.position.x,game.GAME.star_2.sprite.position.y+game.GAME.win_wnd.sprite.position.y);
  2531. if (is_snd())
  2532. GLOB_match.play();
  2533. }
  2534. game.GUI_BUSY=false;
  2535. }
  2536. this.start=function()
  2537. {
  2538. game.GUI_BUSY=true;
  2539. prog=0;
  2540. f=0;
  2541. game.GAME.star_0.sprite.visible=GLOBAL.WIN_PROGRESS>0;
  2542. game.GAME.star_1.sprite.visible=GLOBAL.WIN_PROGRESS>1;
  2543. game.GAME.star_2.sprite.visible=GLOBAL.WIN_PROGRESS>2;
  2544. game.GAME.star_0.sprite.alpha=0;
  2545. game.GAME.star_1.sprite.alpha=0;
  2546. game.GAME.star_2.sprite.alpha=0;
  2547. game.ACT.start("show_zw",here,here.finish);
  2548. }
  2549. }
  2550. var zvezda=new AVK_zvezda();
  2551. this.show_win=function()
  2552. {
  2553. //SG_Hooks.levelUp(here.level_num+1, GLOBAL.SCORE);
  2554. if (is_snd())
  2555. {
  2556. GLOB_heart.stop();
  2557. GLOB_win.play();
  2558. GLOB_in_game.stop();
  2559. }
  2560. var stat=GLOBAL.STAT[here.level_num];
  2561. stat.win_cnt++;
  2562. stat.win_time+=GLOBAL.TIME;
  2563. stat.win_score+=GLOBAL.SCORE;
  2564. if (GLOBAL.LEVELS[here.level_num]>=0)
  2565. stat.win_emprove_cnt++;
  2566. save_stat();
  2567. GLOBAL.LEVELS[here.level_num]=GLOBAL.WIN_PROGRESS;
  2568. if (here.level_num+1<19)
  2569. {
  2570. if (GLOBAL.LEVELS[here.level_num+1]==-2)
  2571. GLOBAL.LEVELS[here.level_num+1]=-1;
  2572. }
  2573. save();
  2574. init_select();
  2575. GLOBAL.BALLS.update_scores(1000000);
  2576. game.GAME.win_wnd.sprite.position.y=-game.GAME.win_wnd.uni_height;
  2577. GLOBAL.FINISH=true;
  2578. GLOBAL.RUN=false;
  2579. game.GAME.win_wnd.sprite.visible=true;
  2580. here.wnd.wnd=game.GAME.win_wnd;
  2581. zvezda.start();
  2582. game.ACT.start("pr",here.wnd,here.wnd.finish);
  2583. game.GAME.shadow.sprite.visible=true;
  2584. game.GAME.shadow.sprite.alpha=0;
  2585. game.GAME.win_wnd_back.sprite.visible=true;
  2586. //Play68.setRankingLevelScoreDesc(here.level_num+1,GLOBAL.SCORE);
  2587. //play68_submitScore(here.level_num+1,GLOBAL.SCORE);
  2588. }
  2589. this.show_loose=function()
  2590. {
  2591. //SG_Hooks.gameOver(here.level_num+1, GLOBAL.SCORE);
  2592. if (is_snd())
  2593. {
  2594. GLOB_heart.stop();
  2595. GLOB_gameover.play();
  2596. GLOB_in_game.stop();
  2597. }
  2598. var stat=GLOBAL.STAT[here.level_num];
  2599. stat.loose_cnt++;
  2600. stat.loose_time+=GLOBAL.TIME;
  2601. stat.loose_score+=GLOBAL.SCORE;
  2602. if (GLOBAL.LEVELS[here.level_num]>=0)
  2603. stat.loose_emprove_cnt++;
  2604. save_stat();
  2605. game.GAME.loose_wnd.sprite.position.y=-game.GAME.loose_wnd.uni_height;
  2606. GLOBAL.FINISH=true;
  2607. GLOBAL.RUN=false;
  2608. game.GAME.loose_wnd.sprite.visible=true;
  2609. here.wnd.wnd=game.GAME.loose_wnd;
  2610. game.GUI_BUSY=true;
  2611. game.ACT.start("pr",here.wnd,here.wnd.finish);
  2612. game.GAME.shadow.sprite.visible=true;
  2613. game.GAME.shadow.sprite.alpha=0;
  2614. }
  2615. function AVK_WND_TITLE()
  2616. {
  2617. var here=this;
  2618. var stop_ui=false;
  2619. this.targ=null;
  2620. function AVK_BTN_SCALE()
  2621. {
  2622. this.set_property = function (newVal)
  2623. {
  2624. if (stop_ui)
  2625. return;
  2626. game.MAIN.btn_start.sprite.scale.x=1+0.02*newVal;
  2627. game.MAIN.btn_start.sprite.scale.y=1-0.02*newVal;
  2628. if (here.targ!=null)
  2629. {
  2630. here.targ.sprite.scale.x=1+0.05*newVal;
  2631. here.targ.sprite.scale.y=1-0.05*newVal;
  2632. }
  2633. }
  2634. }
  2635. var btn_scale=new AVK_BTN_SCALE();
  2636. function finish_scale()
  2637. {
  2638. if (stop_ui)
  2639. return;
  2640. game.ACT.start("ui_scale",btn_scale,finish_scale);
  2641. }
  2642. this.stop_scale_ui = function()
  2643. {
  2644. stop_ui=true;
  2645. }
  2646. finish_scale();
  2647. }
  2648. this.scle_btn=new AVK_WND_TITLE();
  2649. function AVK_WND_TUTOR()
  2650. {
  2651. var here=this;
  2652. this.stoped=true;
  2653. this.x=0;
  2654. this.y=0;
  2655. var sh1=game.GAME.shadow.make_copy();
  2656. var sh2=game.GAME.shadow.make_copy();
  2657. game.GAME.tutor.sprite.addChildAt(sh1.sprite,0);
  2658. sh1.sprite.alpha=0.5;
  2659. sh1.sprite.scale.x=25.2;
  2660. sh1.sprite.scale.y=25.2;
  2661. sh1.sprite.position.x=-10;
  2662. sh1.sprite.position.y=-10;
  2663. game.GAME.tutor.sprite.addChildAt(sh2.sprite,0);
  2664. sh2.sprite.alpha=0.5;
  2665. sh2.sprite.scale.x=25.2;
  2666. sh2.sprite.scale.y=25.2;
  2667. sh2.sprite.position.x=-10;
  2668. sh2.sprite.position.y=-10;
  2669. game.GAME.tutor.sprite.visible=false;
  2670. this.start = function (x,y)
  2671. {
  2672. if (!here.stoped)
  2673. return;
  2674. sh1.sprite.position.x=x-GLOBAL.D-sh1.sprite.scale.x*sh1.uni_width;
  2675. sh2.sprite.position.x=x+GLOBAL.D;
  2676. game.GAME.hand_center.sprite.position.x=x;
  2677. game.GAME.hand_center.sprite.position.y=y;
  2678. here.stoped=false;
  2679. game.GAME.tutor.sprite.visible=true;
  2680. game.GAME.tutor.sprite.alpha=0;
  2681. here.x=x;
  2682. here.y=y;
  2683. finish_scale();
  2684. game.ACT.start("tutor_alpha",game.GAME.tutor);
  2685. }
  2686. this.stop = function ()
  2687. {
  2688. if (here.stoped)
  2689. return;
  2690. here.stoped=true;
  2691. function fin()
  2692. {
  2693. game.GAME.tutor.sprite.visible=false;
  2694. }
  2695. game.ACT.start("tutor_alpha_hide",game.GAME.tutor,fin);
  2696. }
  2697. this.set_property = function (newVal)
  2698. {
  2699. if (here.stoped)
  2700. return;
  2701. game.GAME.hand_center.sprite.scale.x=1+0.05*newVal;
  2702. game.GAME.hand_center.sprite.scale.y=1+0.05*newVal;
  2703. }
  2704. function finish_scale()
  2705. {
  2706. if (here.stoped)
  2707. return;
  2708. game.ACT.start("ui_scale",here,finish_scale);
  2709. }
  2710. }
  2711. var tutor=new AVK_WND_TUTOR();
  2712. this.TUTOR=tutor;
  2713. }
  2714. }