Advertisement
Guest User

Untitled

a guest
Mar 16th, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.85 KB | None | 0 0
  1. // Action script...
  2.  
  3. // [onClipEvent of sprite 634 in frame 9]
  4. onClipEvent (construct)
  5. {
  6. connectedMessage = "Connected";
  7. connectingMessage = "Connecting...";
  8. connectionFailedMessage = "Connection failed";
  9. connectionLostMessage = "Disconnected";
  10. notConnectedMessage = "Not connected";
  11. autoConnect = false;
  12. labelPlacement = "left";
  13. spacing = 5;
  14. serverIpAddress = "127.0.0.1";
  15. serverPort = 9339;
  16. debug = false;
  17. }
  18.  
  19. // [onClipEvent of sprite 608 in frame 9]
  20. onClipEvent (construct)
  21. {
  22. noGuestLoginMsg = "";
  23. autoHide = false;
  24. backgroundWindowTitle = "";
  25. buttonText = "Login";
  26. spacing = 15;
  27. customLoginPage = "";
  28. layout = "side-top";
  29. passwordLabelText = "Password:";
  30. restrict = "^<>";
  31. zone = "";
  32. showBackgroundWindow = false;
  33. showFocusRectangle = false;
  34. showPassword = false;
  35. usernameLabelText = "";
  36. }
  37.  
  38. // [onClipEvent of sprite 602 in frame 16]
  39. onClipEvent (construct)
  40. {
  41. spacing = 15;
  42. errorsDisplayTime = 2;
  43. groupByRoomType = true;
  44. joinButtonText = "Join";
  45. labelMargin = "";
  46. passwordLabelText = "Enter the password:";
  47. playButtonText = "Play";
  48. defaultRoom = "Lobby";
  49. rowHeight = 32;
  50. showChatRooms = false;
  51. showFocusRectangle = false;
  52. showGameRooms = true;
  53. showIcons = true;
  54. showLimboRooms = false;
  55. showPrivateRooms = true;
  56. sortOrder = "ASC";
  57. useSmartList = true;
  58. watchButtonText = "Watch";
  59. }
  60.  
  61. // [onClipEvent of sprite 524 in frame 16]
  62. onClipEvent (construct)
  63. {
  64. banButtonText = "Ban";
  65. banMessage = "You have been banned by the Moderator";
  66. spacing = 15;
  67. enablePrivateChat = true;
  68. kickButtonText = "Kick";
  69. kickMessage = "You have been kicked by the Moderator";
  70. newPrivateMsgLabelColor = 13369344;
  71. labelMargin = "";
  72. moderateLabelTxt = "Moderate user:";
  73. privateChatLabelTxt = "Private messaging:";
  74. rowHeight = 32;
  75. showFocusRectangle = false;
  76. showIcons = true;
  77. sortOrder = "ASC";
  78. useSmartList = true;
  79. }
  80.  
  81. // [onClipEvent of sprite 459 in frame 16]
  82. onClipEvent (construct)
  83. {
  84. adminMessageHeader = "<b>Administrator message received:</b><br>";
  85. sendButtonText = "Send";
  86. spacing = 15;
  87. privateChatMode = false;
  88. groupMessages = true;
  89. initialMessage = "Enter your message here";
  90. labelText = "";
  91. messageHeader = "<b>#user says:</b><br>";
  92. moderatorMessageHeader = "<b>Moderator message received:</b><br>";
  93. restrict = "^<>";
  94. roomJoinAlert = "<i>You entered the #room</i>";
  95. showClearButton = false;
  96. showColorPicker = true;
  97. showFocusRectangle = false;
  98. systemAlertsColor = 6710886;
  99. userEnterRoomAlert = "<i>#user entered the room</i>";
  100. userLeaveRoomAlert = "<i>#user left the room</i>";
  101. }
  102.  
  103. // [onClipEvent of sprite 442 in frame 16]
  104. onClipEvent (construct)
  105. {
  106. editable = true;
  107. password = false;
  108. text = "";
  109. maxChars = null;
  110. restrict = "";
  111. enabled = true;
  112. visible = true;
  113. minHeight = 15;
  114. minWidth = 15;
  115. }
  116.  
  117. // [onClipEvent of sprite 442 in frame 16]
  118. onClipEvent (construct)
  119. {
  120. editable = true;
  121. password = false;
  122. text = "";
  123. maxChars = null;
  124. restrict = "";
  125. enabled = true;
  126. visible = true;
  127. minHeight = 15;
  128. minWidth = 15;
  129. }
  130.  
  131. // [onClipEvent of sprite 425 in frame 16]
  132. onClipEvent (construct)
  133. {
  134. icon = "";
  135. label = "Create";
  136. labelPlacement = "right";
  137. selected = false;
  138. toggle = false;
  139. enabled = true;
  140. visible = true;
  141. minHeight = 15;
  142. minWidth = 15;
  143. }
  144.  
  145. // [onClipEvent of sprite 459 in frame 22]
  146. onClipEvent (construct)
  147. {
  148. adminMessageHeader = "<b>Administrator message received:</b><br>";
  149. sendButtonText = "Send";
  150. spacing = 10;
  151. privateChatMode = false;
  152. groupMessages = false;
  153. initialMessage = "Enter your message here";
  154. labelText = "";
  155. messageHeader = "<b>#user says:</b> ";
  156. moderatorMessageHeader = "<b>Moderator message received:</b><br>";
  157. restrict = "^<>";
  158. roomJoinAlert = "";
  159. showClearButton = false;
  160. showColorPicker = false;
  161. showFocusRectangle = false;
  162. systemAlertsColor = 6710886;
  163. userEnterRoomAlert = "";
  164. userLeaveRoomAlert = "";
  165. }
  166.  
  167. // [onClipEvent of sprite 425 in frame 22]
  168. onClipEvent (construct)
  169. {
  170. icon = "";
  171. label = "EXIT";
  172. labelPlacement = "right";
  173. selected = false;
  174. toggle = false;
  175. enabled = true;
  176. visible = true;
  177. minHeight = 15;
  178. minWidth = 15;
  179. }
  180.  
  181. // [Action in Frame 1]
  182. if (getBytesLoaded() / getBytesTotal() >= 1)
  183. {
  184. gotoAndStop("connect");
  185. }
  186. else
  187. {
  188. loading_txt.text = "Loading... " + Math.round(getBytesLoaded() / getBytesTotal() * 100) + "%";
  189. } // end else if
  190.  
  191. // [Action in Frame 2]
  192. gotoAndPlay("load");
  193.  
  194. // [Action in Frame 9]
  195. function handleConfigLoaded()
  196. {
  197. connector_mc.serverIpAddress = smartFox.ipAddress;
  198. connector_mc.serverPort = smartFox.port;
  199. connector_mc.debug = smartFox.debug;
  200. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnection, mx.utils.Delegate.create(this, onConnection));
  201. loginBox_mc.zone = smartFox.defaultZone;
  202. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onLogin, onLogin);
  203. connector_mc.connect();
  204. } // End of the function
  205. function onConnection(evt)
  206. {
  207. var _loc1 = evt.__get__params().success;
  208. if (_loc1)
  209. {
  210. if (smartFox.getConnectionMode() == it.gotoandplay.smartfoxserver.SmartFoxClient.CONNECTION_MODE_HTTP)
  211. {
  212. connMode_txt.text = "BLUEBOX";
  213. }
  214. else
  215. {
  216. connMode_txt.text = "SOCKET";
  217. } // end else if
  218. var _loc2 = Math.floor(Math.random() * avatars.length);
  219. myAvatar = avatars[_loc2];
  220. avatarSelector.gotoAndStop(myAvatar);
  221. avatarSelector.cow.onPress = onAvatarClick;
  222. avatarSelector.cat.onPress = onAvatarClick;
  223. avatarSelector.cock.onPress = onAvatarClick;
  224. avatarSelector.pig.onPress = onAvatarClick;
  225. } // end if
  226. } // End of the function
  227. function onLogin(evt)
  228. {
  229. var _loc1 = evt.__get__params().resObj;
  230. if (_loc1.success)
  231. {
  232. gotoAndStop("chat");
  233. } // end if
  234. } // End of the function
  235. function onAvatarClick()
  236. {
  237. myAvatar = this._name;
  238. avatarSelector.gotoAndStop(myAvatar);
  239. } // End of the function
  240. function setSounds()
  241. {
  242. bombDrop_snd.attachSound("bombDrop");
  243. bombDrop_snd.setVolume(100);
  244. bombExplode_snd.attachSound("bombExplode");
  245. bombExplode_snd.setVolume(100);
  246. matchStart_snd.attachSound("matchStart");
  247. matchStart_snd.setVolume(100);
  248. matchEnd_snd.attachSound("matchEnd");
  249. matchEnd_snd.setVolume(100);
  250. doorOpen_snd.attachSound("doorOpen");
  251. doorOpen_snd.setVolume(100);
  252. fruitPick_snd.attachSound("fruitPick");
  253. fruitPick_snd.setVolume(100);
  254. soundtrack.attachSound("soundtrack");
  255. soundtrack.onSoundComplete = function ()
  256. {
  257. playSoundtrack(soundtrack.getVolume());
  258. };
  259. } // End of the function
  260. function playSoundFx(snd)
  261. {
  262. if (soundsEnabled)
  263. {
  264. snd.start();
  265. } // end if
  266. } // End of the function
  267. function playSoundtrack(vol)
  268. {
  269. if (soundsEnabled)
  270. {
  271. soundtrack.stop();
  272. soundtrack.setVolume(vol);
  273. soundtrack.start();
  274. } // end if
  275. } // End of the function
  276. function skinComponents(screen)
  277. {
  278. com.metaliq.controls.UIObject.setStyle("fontFamily", "BerlinSansFBDemi");
  279. com.metaliq.controls.UIObject.setStyle("fontSize", 14);
  280. com.metaliq.controls.UIObject.setStyle("fontColor", 7039851);
  281. com.metaliq.controls.UIObject.setStyle("embedFonts", true);
  282. connector_mc.statusLabel.setInstanceStyle("fontColor", 3473408);
  283. if (screen == "connect")
  284. {
  285. loginBox_mc.usernameTextInput.maxChars = 8;
  286. loginBox_mc.loginButton.setInstanceStyle("fontSize", 18);
  287. loginBox_mc.loginButton.setInstanceStyle("fontColor", 16777215);
  288. loginBox_mc.loginButton.width = 75;
  289. loginBox_mc.loginButton.height = 28;
  290. loginBox_mc.refreshView();
  291. }
  292. else if (screen == "chat")
  293. {
  294. chatBox_mc.clearButton.icon = null;
  295. roomList_mc.cancelButton.icon = null;
  296. userList_mc.privateChat.clearButton.icon = null;
  297. chatBox_mc.colorPicker.background = null;
  298. roomList_mc.roomsList.background = "PanelBackground";
  299. userList_mc.usersList.background = "PanelBackground";
  300. userList_mc.privateChat.chatTextArea.background = "PanelBackground";
  301. chatBox_mc.chatTextArea.background = "PanelBackground";
  302. roomList_mc.showFocusRectangle = false;
  303. userList_mc.showFocusRectangle = false;
  304. userList_mc.privateChat.showFocusRectangle = false;
  305. chatBox_mc.showFocusRectangle = false;
  306. roomList_mc.passwordLabel.setInstanceStyle("fontFamily", "BerlinSansFBDemi");
  307. roomList_mc.passwordLabel.setInstanceStyle("fontSize", 14);
  308. roomList_mc.passwordLabel.setInstanceStyle("fontColor", 7039851);
  309. roomList_mc.passwordLabel.setInstanceStyle("embedFonts", true);
  310. chatBox_mc.sendButton.setInstanceStyle("fontSize", 18);
  311. chatBox_mc.sendButton.setInstanceStyle("fontColor", 16777215);
  312. chatBox_mc.colorPicker.setInstanceStyle("fontSize", 12);
  313. roomList_mc.joinButton.setInstanceStyle("fontSize", 18);
  314. roomList_mc.joinButton.setInstanceStyle("fontColor", 16777215);
  315. roomList_mc.watchButton.setInstanceStyle("fontSize", 18);
  316. roomList_mc.watchButton.setInstanceStyle("fontColor", 16777215);
  317. roomList_mc.watchButton.setInstanceStyle("fontSize", 18);
  318. roomList_mc.watchButton.setInstanceStyle("fontColor", 16777215);
  319. userList_mc.privateChat.sendButton.setInstanceStyle("fontSize", 18);
  320. userList_mc.privateChat.sendButton.setInstanceStyle("fontColor", 16777215);
  321. userList_mc.kickButton.setInstanceStyle("fontSize", 18);
  322. userList_mc.kickButton.setInstanceStyle("fontColor", 16777215);
  323. userList_mc.banButton.setInstanceStyle("fontSize", 18);
  324. userList_mc.banButton.setInstanceStyle("fontColor", 16777215);
  325. roomList_mc.roomsList.rowRenderer = "CustomRowRenderer";
  326. userList_mc.usersList.rowRenderer = "CustomRowRenderer";
  327. userList_mc.newPrivateMsgLabelColor = 8634654;
  328. userList_mc.privateChat.systemAlertsColor = 8634654;
  329. userList_mc.privateChat.colorPicker.value = 7039851;
  330. chatBox_mc.systemAlertsColor = 8634654;
  331. chatBox_mc.colorPicker.value = 7039851;
  332. roomList_mc.joinButton.width = 75;
  333. roomList_mc.joinButton.height = 28;
  334. roomList_mc.watchButton.width = 75;
  335. roomList_mc.watchButton.height = 28;
  336. roomList_mc.cancelButton.width = 26;
  337. roomList_mc.cancelButton.height = 26;
  338. roomList_mc.passwordTextInput.height = 22;
  339. roomList_mc.refreshView();
  340. chatBox_mc.sendButton.width = 75;
  341. chatBox_mc.sendButton.height = 28;
  342. chatBox_mc.colorPicker.width = 28;
  343. chatBox_mc.colorPicker.height = 28;
  344. chatBox_mc.clearButton.width = 28;
  345. chatBox_mc.clearButton.height = 28;
  346. chatBox_mc.refreshView();
  347. userList_mc.privateChat.sendButton.width = 75;
  348. userList_mc.privateChat.sendButton.height = 28;
  349. userList_mc.privateChat.clearButton.width = 26;
  350. userList_mc.privateChat.clearButton.height = 26;
  351. userList_mc.privateChat.messageTextInput.height = 22;
  352. userList_mc.kickButton.width = 75;
  353. userList_mc.kickButton.height = 28;
  354. userList_mc.banButton.width = 75;
  355. userList_mc.banButton.height = 28;
  356. userList_mc.refreshView();
  357. create_bt.setInstanceStyle("fontSize", 18);
  358. create_bt.setInstanceStyle("fontColor", 16777215);
  359. create_bt.width = 75;
  360. create_bt.height = 28;
  361. }
  362. else if (screen == "game")
  363. {
  364. chatBox_mc.clearButton.icon = null;
  365. chatBox_mc.colorPicker.background = null;
  366. chatBox_mc.chatTextArea.background = "PanelBackground";
  367. chatBox_mc.showFocusRectangle = false;
  368. chatBox_mc.sendButton.setInstanceStyle("fontSize", 18);
  369. chatBox_mc.sendButton.setInstanceStyle("fontColor", 16777215);
  370. chatBox_mc.colorPicker.setInstanceStyle("fontSize", 12);
  371. chatBox_mc.systemAlertsColor = 8634654;
  372. chatBox_mc.colorPicker.value = 7039851;
  373. chatBox_mc.sendButton.width = 75;
  374. chatBox_mc.sendButton.height = 28;
  375. chatBox_mc.refreshView();
  376. exit_bt.setInstanceStyle("fontSize", 18);
  377. exit_bt.setInstanceStyle("fontColor", 16777215);
  378. exit_bt.width = 75;
  379. exit_bt.height = 28;
  380. } // end else if
  381. } // End of the function
  382. stop ();
  383. Stage.showMenu = false;
  384. var XT_NAME = "battle";
  385. var smartFox = connector_mc.connection;
  386. var stageW = 640;
  387. var stageH = 640;
  388. var avatars = ["cow", "cat", "cock", "pig"];
  389. var myAvatar = "";
  390. var forceBlueBox = _root.conn == "http";
  391. var soundsEnabled = true;
  392. var bombDrop_snd = new Sound();
  393. var bombExplode_snd = new Sound();
  394. var matchStart_snd = new Sound();
  395. var matchEnd_snd = new Sound();
  396. var doorOpen_snd = new Sound();
  397. var fruitPick_snd = new Sound();
  398. var soundtrack = new Sound();
  399. setSounds();
  400. playSoundtrack(60);
  401. skinComponents("connect");
  402. smartFox.onConfigLoadSuccess = handleConfigLoaded;
  403. smartFox.loadConfig(forceBlueBox ? ("config_http.xml") : ("config.xml"), false);
  404.  
  405. // [Action in Frame 16]
  406. function onJoinRoom(evt)
  407. {
  408. var _loc1 = evt.__get__params().room;
  409. if (_loc1.isGame())
  410. {
  411. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onJoinRoom, onJoinRoom);
  412. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onUserVariablesUpdate, onUserVariablesUpdate);
  413. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onExtensionResponse);
  414. create_bt.removeEventListener("click", onCreateBtClick);
  415. delete mapSelector.prev_bt.onPress;
  416. delete mapSelector.next_bt.onPress;
  417. gotoAndStop("game");
  418. }
  419. else
  420. {
  421. if (_loc1.getUser(smartFox.myUserId).getVariable("avatar") == undefined)
  422. {
  423. var _loc2 = new Object();
  424. _loc2.avatar = myAvatar;
  425. smartFox.setUserVariables(_loc2);
  426. } // end if
  427. smartFox.sendXtMessage(XT_NAME, "maps", null);
  428. } // end else if
  429. } // End of the function
  430. function onUserVariablesUpdate(evt)
  431. {
  432. userList_mc.refreshView();
  433. } // End of the function
  434. function onExtensionResponse(evt)
  435. {
  436. var _loc7 = evt.__get__params().dataObj._cmd;
  437. if (_loc7 == "maps")
  438. {
  439. var _loc2 = evt.__get__params().dataObj.list;
  440. var _loc5 = mapSelector.createEmptyMovieClip("itemsHolder", 0);
  441. _loc5.setMask(mapSelector.itemsHolderMask);
  442. var _loc6 = [];
  443. for (var _loc1 = 0; _loc1 < _loc2.length; ++_loc1)
  444. {
  445. trace (_loc2[_loc1].id);
  446. trace (_loc2[_loc1].name);
  447. trace (_loc2[_loc1].icon);
  448. trace (_loc2[_loc1].thumb);
  449. availableMaps[_loc1] = _loc2[_loc1];
  450. availableMapsById[_loc2[_loc1].id] = _loc2[_loc1];
  451. var _loc3 = _loc5.attachMovie("item", "item" + _loc1, _loc1);
  452. _loc3.name_txt.text = _loc2[_loc1].name;
  453. _loc3.thumb_ldr.contentPath = "thumbnails/" + _loc2[_loc1].thumb + ".jpg";
  454. _loc3._y = _loc1 * mapMenuItemSize;
  455. var _loc4 = {};
  456. _loc4.url = "thumbnails/" + _loc2[_loc1].thumb + ".jpg";
  457. _loc4.target = _loc3.thumb;
  458. _loc6.push(_loc4);
  459. } // end of for
  460. var _loc8 = new it.gotoandplay.commons.util.QueueLoader(_loc6);
  461. _loc8.start();
  462. create_bt.enabled = true;
  463. roomList_mc.refreshView();
  464. } // end if
  465. } // End of the function
  466. function onCreateBtClick()
  467. {
  468. if (name_ti.text != "")
  469. {
  470. var _loc1 = new Object();
  471. _loc1.name = name_ti.text;
  472. _loc1.password = password_ti.text;
  473. _loc1.maxUsers = 2;
  474. _loc1.maxSpectators = 0;
  475. _loc1.isGame = true;
  476. _loc1.isTemp = true;
  477. var _loc2 = {};
  478. _loc2.name = "map";
  479. _loc2.val = availableMaps[selectedMapIndex].id;
  480. _loc2.priv = true;
  481. _loc2.persistent = true;
  482. var _loc3 = [];
  483. _loc3.push(_loc2);
  484. _loc1.vars = _loc3;
  485. smartFox.createRoom(_loc1);
  486. } // end if
  487. } // End of the function
  488. function onPrevMapClick()
  489. {
  490. trace (selectedMapIndex);
  491. if (availableMaps.length > 0)
  492. {
  493. if (selectedMapIndex > 0)
  494. {
  495. --selectedMapIndex;
  496. scrollMapsMenu();
  497. } // end if
  498. } // end if
  499. } // End of the function
  500. function onNextMapClick()
  501. {
  502. trace (selectedMapIndex);
  503. if (availableMaps.length > 0)
  504. {
  505. if (selectedMapIndex < availableMaps.length - 1)
  506. {
  507. ++selectedMapIndex;
  508. scrollMapsMenu();
  509. } // end if
  510. } // end if
  511. } // End of the function
  512. function scrollMapsMenu()
  513. {
  514. var _loc1 = new mx.transitions.TweenExtended(mapSelector.itemsHolder, ["_y"], Regular.easeOut, [mapSelector.itemsHolder._y], [-mapMenuItemSize * selectedMapIndex], 2.000000E-001, true);
  515. } // End of the function
  516. function setCustomRoomLabel(item)
  517. {
  518. var _loc2 = item.roomData;
  519. var _loc1 = _loc2.getName();
  520. var _loc4 = _loc2.getVariable("map");
  521. var _loc3 = availableMapsById[_loc4].name;
  522. if (_loc2.isGame() && _loc3 != undefined)
  523. {
  524. _loc1 = _loc1 + "<br>";
  525. _loc1 = _loc1 + "<font size=\'12\' color=\'#83C11E\'>";
  526. _loc1 = _loc1 + ("(" + _loc3 + ")");
  527. _loc1 = _loc1 + "</font>";
  528. } // end if
  529. return (_loc1);
  530. } // End of the function
  531. function setCustomRoomIcon(item)
  532. {
  533. var _loc1 = item.roomData;
  534. var _loc4 = _loc1.getVariable("map");
  535. var _loc3 = availableMapsById[_loc4].icon;
  536. var _loc2 = "";
  537. if (_loc1.isGame())
  538. {
  539. _loc2 = "icon" + _loc3;
  540. if (_loc1.getUserCount() >= _loc1.getMaxUsers())
  541. {
  542. _loc2 = _loc2 + "_full";
  543. }
  544. else if (_loc1.isPrivate())
  545. {
  546. _loc2 = _loc2 + "_priv";
  547. } // end if
  548. } // end else if
  549. return (_loc2);
  550. } // End of the function
  551. function setCustomUserLabel(item)
  552. {
  553. var _loc3 = item.userData;
  554. var _loc1 = "<font";
  555. if (item.newMsgCount > 0)
  556. {
  557. _loc1 = _loc1 + (" color=\'#" + newPrivateMsgLabelColor.toString(16) + "\'");
  558. } // end if
  559. _loc1 = _loc1 + (">" + _loc3.getName() + "</font>");
  560. if (item.newMsgCount > 0)
  561. {
  562. _loc1 = _loc1 + "<br>";
  563. _loc1 = _loc1 + "<font size=\'12\' color=\'#CCCCCC\'>";
  564. _loc1 = _loc1 + (String(item.newMsgCount) + " message" + (item.newMsgCount > 1 ? ("s") : ("")) + " to read");
  565. _loc1 = _loc1 + "</font>";
  566. } // end if
  567. return (_loc1);
  568. } // End of the function
  569. function setCustomUserIcon(item)
  570. {
  571. var _loc1 = item.userData;
  572. var _loc2 = "userIcon_" + _loc1.getVariable("avatar");
  573. return (_loc2);
  574. } // End of the function
  575. stop ();
  576. var availableMaps = [];
  577. var availableMapsById = [];
  578. var selectedMapIndex = 0;
  579. var mapMenuItemSize = 130;
  580. playSoundtrack(10);
  581. skinComponents("chat");
  582. roomList_mc.labelFunction = setCustomRoomLabel;
  583. roomList_mc.iconFunction = setCustomRoomIcon;
  584. userList_mc.labelFunction = setCustomUserLabel;
  585. userList_mc.iconFunction = setCustomUserIcon;
  586. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onJoinRoom, mx.utils.Delegate.create(this, onJoinRoom));
  587. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onUserVariablesUpdate, mx.utils.Delegate.create(this, onUserVariablesUpdate));
  588. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, mx.utils.Delegate.create(this, onExtensionResponse));
  589. create_bt.addEventListener("click", onCreateBtClick);
  590. create_bt.enabled = false;
  591. mapSelector.prev_bt.onPress = onPrevMapClick;
  592. mapSelector.next_bt.onPress = onNextMapClick;
  593.  
  594. // [Action in Frame 22]
  595. function onSetFocusIn()
  596. {
  597. trace ("FOCUS IN");
  598. chatFocus = true;
  599. } // End of the function
  600. function onSetFocusOut()
  601. {
  602. trace ("FOCUS OUT");
  603. chatFocus = false;
  604. } // End of the function
  605. function onEnter()
  606. {
  607. trace ("ENTER PRESSED");
  608. chatBox_mc.sendButton.setFocus();
  609. } // End of the function
  610. function init()
  611. {
  612. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onGameExtensionResponse);
  613. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onRoundTripResponse, onRoundTripResponse);
  614. connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnectionLost, onConnectionLost);
  615. exit_bt.addEventListener("click", onExitBtClick);
  616. popup = showPopup(POPUP_WAITING);
  617. smartFox.sendXtMessage(XT_NAME, "ready", null);
  618. } // End of the function
  619. function onExitBtClick()
  620. {
  621. reset();
  622. gotoAndStop("chat");
  623. } // End of the function
  624. function onConnectionLost()
  625. {
  626. reset();
  627. gotoAndStop("connect");
  628. } // End of the function
  629. function reset()
  630. {
  631. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onGameExtensionResponse);
  632. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onRoundTripResponse, onRoundTripResponse);
  633. connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnectionLost, onConnectionLost);
  634. exit_bt.removeEventListener("click", onExitBtClick);
  635. clearInterval(bench);
  636. clearInterval(timer);
  637. gameStarted = false;
  638. inGame = false;
  639. popup.removeMovieClip();
  640. } // End of the function
  641. function onGameExtensionResponse(evt)
  642. {
  643. var _loc4 = evt.__get__params().type;
  644. var _loc1 = evt.__get__params().dataObj;
  645. trace ("SFS EVENT RECEIVED: " + _loc4);
  646. if (_loc4 == "xml")
  647. {
  648. if (_loc1._cmd == "map")
  649. {
  650. trace ("MAP RECEIVED");
  651. var _loc2 = availableMaps[selectedMapIndex];
  652. _loc2.background = _loc1.bg;
  653. _loc2.foreground = _loc1.fg;
  654. _loc2.duration = _loc1.dur;
  655. _loc2.p1x = _loc1.p1x;
  656. _loc2.p1y = _loc1.p1y;
  657. _loc2.p2x = _loc1.p2x;
  658. _loc2.p2y = _loc1.p2y;
  659. collectibles = _loc1.coll;
  660. gameDuration = _loc2.duration;
  661. timer_bg.gotoAndStop(1);
  662. showTime(gameDuration);
  663. gameClip.player1.removeMovieClip();
  664. gameClip.player2.removeMovieClip();
  665. setupMap(_loc1);
  666. checkNetwork();
  667. bench = setInterval(checkNetwork, 1000);
  668. initPlayers();
  669. popup = showPopup(POPUP_READY);
  670. }
  671. else if (_loc1._cmd == "stop")
  672. {
  673. handleStopGame();
  674. } // end else if
  675. }
  676. else
  677. {
  678. var _loc3 = _loc1[0];
  679. var _loc6 = Number(_loc1[1]);
  680. if (_loc3 == "go")
  681. {
  682. trace ("GAME START!");
  683. playSoundFx(matchStart_snd);
  684. popup.removeMovieClip();
  685. startTime = gameDuration;
  686. clearInterval(bench);
  687. bench = setInterval(checkNetwork, 5000);
  688. gameStarted = true;
  689. gameClip.onEnterFrame = mainThread;
  690. startTime = startTime - Math.round(averagePing / pingCount / 1000);
  691. timer_bg.gotoAndStop(1);
  692. showTime(startTime);
  693. timer = setInterval(updateTimer, 1000);
  694. }
  695. else if (_loc3 == "mv")
  696. {
  697. handleOpponentMove(Number(_loc1[2]), Number(_loc1[3]));
  698. }
  699. else if (_loc3 == "gi")
  700. {
  701. handlePickItem(Number(_loc1[2]), Number(_loc1[3]), Number(_loc1[4]));
  702. }
  703. else if (_loc3 == "bb")
  704. {
  705. handleOpponentBomb(_loc1[2], Number(_loc1[3]), Number(_loc1[4]));
  706. }
  707. else if (_loc3 == "xp")
  708. {
  709. handleExplosion(_loc1[2], _loc1[3], Number(_loc1[4]), Number(_loc1[5]), Number(_loc1[6]), _loc1[7], Number(_loc1[8]), _loc1[9]);
  710. }
  711. else if (_loc3 == "od")
  712. {
  713. handleOpenDoor(Number(_loc1[2]), Number(_loc1[3]));
  714. }
  715. else if (_loc3 == "win")
  716. {
  717. handleWinner(Number(_loc1[2]));
  718. } // end else if
  719. } // end else if
  720. } // End of the function
  721. function showPopup(linkageName)
  722. {
  723. var _loc2 = _root.attachMovie(linkageName, linkageName, 14000);
  724. _loc2._x = stageW / 2 - _loc2._width / 2;
  725. _loc2._y = stageH / 2 - _loc2._height / 2 - 40;
  726. return (_loc2);
  727. } // End of the function
  728. function updateTimer()
  729. {
  730. --startTime;
  731. if (startTime < 20 && startTime > 10)
  732. {
  733. timer_bg.gotoAndStop(2);
  734. }
  735. else if (startTime < 10)
  736. {
  737. timer_bg.gotoAndStop(3);
  738. } // end else if
  739. if (startTime == 0)
  740. {
  741. clearInterval(timer);
  742. } // end if
  743. showTime(startTime);
  744. } // End of the function
  745. function showTime(t)
  746. {
  747. var _loc2 = "" + Math.floor(t / 60);
  748. if (_loc2.length < 2)
  749. {
  750. _loc2 = "0" + _loc2;
  751. } // end if
  752. var _loc1 = "" + t % 60;
  753. if (_loc1.length < 2)
  754. {
  755. _loc1 = "0" + _loc1;
  756. } // end if
  757. timer_txt.text = _loc2 + ":" + _loc1;
  758. } // End of the function
  759. function onRoundTripResponse(evt)
  760. {
  761. var _loc1 = evt.__get__params().elapsed;
  762. averagePing = averagePing + _loc1 / 2;
  763. ++pingCount;
  764. var _loc2 = Math.round(averagePing / pingCount);
  765. bench_txt.text = "Average lag:\n" + _loc2 + " ms";
  766. } // End of the function
  767. function restartGame()
  768. {
  769. popup.removeMovieClip();
  770. smartFox.sendXtMessage(XT_NAME, "restart", {}, "xml");
  771. } // End of the function
  772. function setupMap(resObj)
  773. {
  774. gameClip.attachMovie("bg_" + resObj.bg, "background", bgDepth);
  775. var _loc6 = 0;
  776. for (var _loc5 = 0; _loc5 < mapH; ++_loc5)
  777. {
  778. var _loc4 = resObj[_loc5];
  779. gameMap[_loc5] = [];
  780. for (var _loc1 = 0; _loc1 < _loc4.length; ++_loc1)
  781. {
  782. var _loc3;
  783. var _loc2 = _loc4.charAt(_loc1);
  784. gameMap[_loc5][_loc1] = _loc2;
  785. if (_loc2.charCodeAt(0) >= 65 && _loc2.charCodeAt(0) <= 90)
  786. {
  787. _loc3 = gameClip.attachMovie("brick_" + _loc2, "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
  788. }
  789. else if (_loc2.charCodeAt(0) >= 97 && _loc2.charCodeAt(0) <= 122)
  790. {
  791. _loc3 = gameClip.attachMovie("coll_" + _loc2, "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
  792. pickupItems[_loc6] = _loc3;
  793. }
  794. else
  795. {
  796. _loc3 = gameClip.attachMovie("empty", "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
  797. } // end else if
  798. _loc3._x = tileSize * _loc1;
  799. _loc3._y = tileSize * _loc5;
  800. } // end of for
  801. } // end of for
  802. for (var _loc5 = 0; _loc5 < 10; ++_loc5)
  803. {
  804. gameClip["bomb" + _loc5].removeMovieClip();
  805. gameClip["opBomb" + _loc5].removeMovieClip();
  806. } // end of for
  807. for (var _loc5 = 0; _loc5 < bombMax; ++_loc5)
  808. {
  809. bombs[_loc5] = true;
  810. } // end of for
  811. gameClip.attachMovie("fg_" + resObj.fg, "foreground", fgDepth);
  812. } // End of the function
  813. function initPlayers()
  814. {
  815. var _loc3 = availableMaps[selectedMapIndex];
  816. trace (_loc3.name);
  817. trace (_loc3.duration);
  818. trace (_loc3.p1x);
  819. trace (_loc3.p1y);
  820. trace (_loc3.background);
  821. var _loc8 = smartFox.getActiveRoom();
  822. var _loc2 = _loc8.getUserList();
  823. for (var _loc6 in _loc2)
  824. {
  825. if (_loc2[_loc6].getName() != smartFox.myUserName)
  826. {
  827. oppPlayerId = _loc2[_loc6].getPlayerId();
  828. opponentAvatar = _loc2[_loc6].getVariable("avatar");
  829. opponentName = _loc2[_loc6].getName();
  830. break;
  831. } // end if
  832. } // end of for...in
  833. _root["player" + myPlayerId].avPlaceHolder.attachMovie("userIcon_" + myAvatar, "icon", 0);
  834. _root["player" + oppPlayerId].avPlaceHolder.attachMovie("userIcon_" + opponentAvatar, "icon", 0);
  835. var _loc5 = gameClip.attachMovie("player_" + (myPlayerId == 1 ? (myAvatar) : (opponentAvatar)), "player1", myPlayerId == 1 ? (10001) : (10000));
  836. _loc5.px = _loc3.p1x;
  837. _loc5.py = _loc3.p1y;
  838. _loc5._x = _loc5.px * tileSize;
  839. _loc5._y = _loc5.py * tileSize;
  840. _loc5.score = 0;
  841. var _loc4 = gameClip.attachMovie("player_" + (myPlayerId == 2 ? (myAvatar) : (opponentAvatar)), "player2", myPlayerId == 2 ? (10001) : (10000));
  842. _loc4.px = _loc3.p2x;
  843. _loc4.py = _loc3.p2y;
  844. _loc4._x = _loc4.px * tileSize;
  845. _loc4._y = _loc4.py * tileSize;
  846. _loc4.score = 0;
  847. _loc5.gotoAndStop(4);
  848. _loc4.gotoAndStop(4);
  849. myPlayer = gameClip["player" + myPlayerId];
  850. opPlayer = gameClip["player" + oppPlayerId];
  851. opPlayer.moves = [];
  852. myPlayer.moving = false;
  853. opPlayer.moving = false;
  854. var _loc7 = gameClip.attachMovie("highlighter", "highlighter", 11000);
  855. _loc7._x = myPlayer._x + tileSize / 2;
  856. _loc7._y = myPlayer._y + tileSize / 2;
  857. _loc7.gotoAndPlay(2);
  858. updateScores();
  859. } // End of the function
  860. function mainThread()
  861. {
  862. if (gameStarted)
  863. {
  864. if (!myPlayer.moving)
  865. {
  866. if (!chatFocus)
  867. {
  868. if (Key.isDown(37) && (gameMap[myPlayer.py][myPlayer.px - 1].charCodeAt(0) < 65 || gameMap[myPlayer.py][myPlayer.px - 1].charCodeAt(0) > 90))
  869. {
  870. sendMyMove(myPlayer.px - 1, myPlayer.py);
  871. moveByTime(myPlayer, myPlayer.px - 1, myPlayer.py, playerSpeed);
  872. }
  873. else if (Key.isDown(39) && (gameMap[myPlayer.py][myPlayer.px + 1].charCodeAt(0) < 65 || gameMap[myPlayer.py][myPlayer.px + 1].charCodeAt(0) > 90))
  874. {
  875. sendMyMove(myPlayer.px + 1, myPlayer.py);
  876. moveByTime(myPlayer, myPlayer.px + 1, myPlayer.py, playerSpeed);
  877. }
  878. else if (Key.isDown(38) && (gameMap[myPlayer.py - 1][myPlayer.px].charCodeAt(0) < 65 || gameMap[myPlayer.py - 1][myPlayer.px].charCodeAt(0) > 90))
  879. {
  880. sendMyMove(myPlayer.px, myPlayer.py - 1);
  881. moveByTime(myPlayer, myPlayer.px, myPlayer.py - 1, playerSpeed);
  882. }
  883. else if (Key.isDown(40) && (gameMap[myPlayer.py + 1][myPlayer.px].charCodeAt(0) < 65 || gameMap[myPlayer.py + 1][myPlayer.px].charCodeAt(0) > 90))
  884. {
  885. sendMyMove(myPlayer.px, myPlayer.py + 1);
  886. moveByTime(myPlayer, myPlayer.px, myPlayer.py + 1, playerSpeed);
  887. } // end else if
  888. } // end else if
  889. } // end else if
  890. if (!chatFocus)
  891. {
  892. if (Key.isDown(32))
  893. {
  894. if (getTimer() > lastKeyPress + keySpaceDelay)
  895. {
  896. lastKeyPress = getTimer();
  897. var _loc5 = myPlayer.px;
  898. var _loc4 = myPlayer.py;
  899. var _loc7 = gameClip["brick_" + _loc5 + "_" + _loc4];
  900. if (_loc7.bomb == undefined)
  901. {
  902. for (var _loc1 = 0; _loc1 < bombMax; ++_loc1)
  903. {
  904. if (bombs[_loc1])
  905. {
  906. _loc7.bomb = true;
  907. bombs[_loc1] = false;
  908. var _loc6 = myPlayerId.toString() + _loc1.toString();
  909. var _loc3 = gameClip.attachMovie("bomb", "bomb" + _loc1, bombDepth + _loc1);
  910. gameMap[_loc4][_loc5] = bombSymbol;
  911. _loc3._x = _loc5 * tileSize;
  912. _loc3._y = _loc4 * tileSize;
  913. playSoundFx(bombDrop_snd);
  914. var _loc2 = [];
  915. _loc2.push(_loc6);
  916. _loc2.push(_loc5);
  917. _loc2.push(_loc4);
  918. smartFox.sendXtMessage(XT_NAME, "bb", _loc2, "str");
  919. break;
  920. } // end if
  921. } // end of for
  922. } // end if
  923. } // end if
  924. } // end if
  925. } // end if
  926. if (!opPlayer.moving && opPlayer.moves.length > 0)
  927. {
  928. moveByTime(opPlayer, opPlayer.moves[0].px, opPlayer.moves[0].py, playerSpeed);
  929. } // end if
  930. } // end if
  931. } // End of the function
  932. function moveByTime(who, px, py, duration)
  933. {
  934. who.moving = true;
  935. if (who.moves.length > 1)
  936. {
  937. who._x = who.moves[who.moves.length - 2].px * tileSize;
  938. who._y = who.moves[who.moves.length - 2].py * tileSize;
  939. px = who.moves[who.moves.length - 1].px;
  940. py = who.moves[who.moves.length - 1].py;
  941. } // end if
  942. who.moves = [];
  943. var _loc3 = who._x;
  944. var _loc2 = who._y;
  945. var _loc5 = px * tileSize;
  946. var _loc4 = py * tileSize;
  947. switch (_loc5 - _loc3)
  948. {
  949. case -tileSize:
  950. {
  951. who.gotoAndStop(1);
  952. break;
  953. }
  954. case tileSize:
  955. {
  956. who.gotoAndStop(2);
  957. break;
  958. }
  959. } // End of switch
  960. switch (_loc4 - _loc2)
  961. {
  962. case -tileSize:
  963. {
  964. who.gotoAndStop(3);
  965. break;
  966. }
  967. case tileSize:
  968. {
  969. who.gotoAndStop(4);
  970. break;
  971. }
  972. } // End of switch
  973. who.ani_startTime = getTimer();
  974. who.ani_endTime = who.ani_startTime + duration;
  975. who.duration = duration;
  976. who.sx = _loc3;
  977. who.sy = _loc2;
  978. who.dx = _loc5 - _loc3;
  979. who.dy = _loc4 - _loc2;
  980. who.onEnterFrame = animateByTime;
  981. } // End of the function
  982. function animateByTime()
  983. {
  984. var _loc3 = getTimer();
  985. if (_loc3 > this.ani_endTime)
  986. {
  987. delete this.onEnterFrame;
  988. this._x = this.sx + this.dx;
  989. this._y = this.sy + this.dy;
  990. this.px = this._x / tileSize;
  991. this.py = this._y / tileSize;
  992. this.moving = false;
  993. this.avatar.gotoAndStop(1);
  994. }
  995. else
  996. {
  997. if (this.avatar._currentframe == 1)
  998. {
  999. this.avatar.gotoAndPlay("run");
  1000. } // end if
  1001. var _loc4 = _loc3 - this.ani_startTime;
  1002. var _loc2 = _loc4 / this.duration;
  1003. this._x = this.sx + this.dx * _loc2;
  1004. this._y = this.sy + this.dy * _loc2;
  1005. } // end else if
  1006. } // End of the function
  1007. function sendMyMove(px, py)
  1008. {
  1009. var _loc1 = [];
  1010. _loc1.push(px);
  1011. _loc1.push(py);
  1012. smartFox.sendXtMessage(XT_NAME, "mv", _loc1, "str");
  1013. } // End of the function
  1014. function handleOpponentMove(x, y)
  1015. {
  1016. opPlayer.moves.push({px: x, py: y});
  1017. } // End of the function
  1018. function handlePickItem(x, y, i)
  1019. {
  1020. trace ("Get item: px=" + x + " py=" + y + " i=" + i);
  1021. if (i == myPlayerId)
  1022. {
  1023. ++myPlayer.score;
  1024. playSoundFx(fruitPick_snd);
  1025. }
  1026. else
  1027. {
  1028. ++opPlayer.score;
  1029. } // end else if
  1030. updateScores();
  1031. gameMap[y][x] = emptyItem;
  1032. gameClip["brick_" + x + "_" + y].gotoAndStop(2);
  1033. } // End of the function
  1034. function handleStopGame()
  1035. {
  1036. gameStarted = false;
  1037. playSoundFx(matchEnd_snd);
  1038. gameClip.player1.removeMovieClip();
  1039. gameClip.player2.removeMovieClip();
  1040. clearInterval(timer);
  1041. startTime = gameDuration;
  1042. myMatches = 0;
  1043. opMatches = 0;
  1044. popup = showPopup(POPUP_PLAYER_LOST);
  1045. } // End of the function
  1046. function updateScores()
  1047. {
  1048. var _loc2 = smartFox.myUserName + " > Score: " + myPlayer.score + " | Matches: " + myMatches;
  1049. var _loc1 = opponentName + " > Score: " + opPlayer.score + " | Matches: " + opMatches;
  1050. player1.name.text = myPlayerId == 1 ? (_loc2) : (_loc1);
  1051. player2.name.text = myPlayerId == 2 ? (_loc2) : (_loc1);
  1052. } // End of the function
  1053. function checkNetwork()
  1054. {
  1055. smartFox.roundTripBench();
  1056. } // End of the function
  1057. function handleOpponentBomb(id, px, py)
  1058. {
  1059. var _loc2 = Number(id.charAt(1));
  1060. var _loc3 = gameClip["brick_" + px + "_" + py];
  1061. var _loc1 = gameClip.attachMovie("bomb", "opBomb" + _loc2, bombDepth + 5 + _loc2);
  1062. _loc1._x = tileSize * px;
  1063. _loc1._y = tileSize * py;
  1064. _loc3.bomb = true;
  1065. gameMap[py][px] = bombSymbol;
  1066. } // End of the function
  1067. function handleExplosion(id, item, px, py, die1, newItems1, die2, newItems2)
  1068. {
  1069. var _loc9 = Number(id.charAt(0));
  1070. var _loc4 = Number(id.charAt(1));
  1071. var _loc6 = gameClip["brick_" + px + "_" + py];
  1072. _loc6.bomb = undefined;
  1073. gameMap[py][px] = item;
  1074. var _loc5;
  1075. if (_loc9 == myPlayerId)
  1076. {
  1077. _loc5 = "bomb" + _loc4;
  1078. bombs[_loc4] = true;
  1079. }
  1080. else
  1081. {
  1082. _loc5 = "opBomb" + _loc4;
  1083. } // end else if
  1084. gameClip[_loc5].removeMovieClip();
  1085. playSoundFx(bombExplode_snd);
  1086. renderExplosion(px, py);
  1087. var _loc3;
  1088. var _loc2;
  1089. if (myPlayerId == 1)
  1090. {
  1091. _loc3 = myPlayer;
  1092. _loc2 = opPlayer;
  1093. }
  1094. else
  1095. {
  1096. _loc3 = opPlayer;
  1097. _loc2 = myPlayer;
  1098. } // end else if
  1099. var _loc1 = 0;
  1100. if (die1)
  1101. {
  1102. gameClip.player1.square.gotoAndPlay(2);
  1103. attachBubble(gameClip.player1);
  1104. if (_loc3.score < itemTax)
  1105. {
  1106. _loc1 = _loc3.score;
  1107. }
  1108. else
  1109. {
  1110. _loc1 = itemTax;
  1111. } // end else if
  1112. _loc3.score = _loc3.score - _loc1;
  1113. looseCollectibles(_loc3, _loc1, newItems1);
  1114. } // end if
  1115. if (die2)
  1116. {
  1117. gameClip.player2.square.gotoAndPlay(2);
  1118. attachBubble(gameClip.player2);
  1119. if (_loc2.score < itemTax)
  1120. {
  1121. _loc1 = _loc2.score;
  1122. }
  1123. else
  1124. {
  1125. _loc1 = itemTax;
  1126. } // end else if
  1127. _loc2.score = _loc2.score - _loc1;
  1128. looseCollectibles(_loc2, _loc1, newItems2);
  1129. } // end if
  1130. updateScores();
  1131. } // End of the function
  1132. function attachBubble(mc)
  1133. {
  1134. if (!mc.interval)
  1135. {
  1136. var _loc1 = mc.attachMovie("bubble", "bubble", 10);
  1137. _loc1._x = 25;
  1138. _loc1._y = -_loc1._height;
  1139. var _loc3 = Math.floor(Math.random() * taunts.length);
  1140. _loc1.message_txt.text = taunts[_loc3];
  1141. mc.interval = setInterval(clearBubble, 2000, mc);
  1142. } // end if
  1143. } // End of the function
  1144. function clearBubble(mc)
  1145. {
  1146. clearInterval(mc.interval);
  1147. mc.interval = null;
  1148. mc.bubble.removeMovieClip();
  1149. } // End of the function
  1150. function handleOpenDoor(px, py)
  1151. {
  1152. trace ("DOOR SHOULD OPEN at: " + px + "," + py);
  1153. var _loc1 = gameClip.attachMovie("door", "exit", depth + py * mapW + px);
  1154. playSoundFx(doorOpen_snd);
  1155. _loc1._x = tileSize * px;
  1156. _loc1._y = tileSize * py;
  1157. } // End of the function
  1158. function handleWinner(who)
  1159. {
  1160. gameStarted = false;
  1161. playSoundFx(matchEnd_snd);
  1162. clearInterval(timer);
  1163. startTime = gameDuration;
  1164. popup = showPopup(POPUP_MATCH_END);
  1165. if (myPlayerId == who)
  1166. {
  1167. popup.message_txt.text = "Well done! You WON!\n Play again?";
  1168. ++myMatches;
  1169. }
  1170. else
  1171. {
  1172. popup.message_txt.text = "Ouch! You LOST!\n Play again?";
  1173. ++opMatches;
  1174. } // end else if
  1175. popup.score_txt.text = myMatches + " - " + opMatches;
  1176. popup.restart_bt.onPress = restartGame;
  1177. updateScores();
  1178. } // End of the function
  1179. function looseCollectibles(p, d, newItems)
  1180. {
  1181. if (d > 0)
  1182. {
  1183. for (var _loc5 = 0; _loc5 < d; ++_loc5)
  1184. {
  1185. var _loc4 = newItems.substr(0, 4);
  1186. newItems = newItems.slice(4);
  1187. var _loc3 = Number(_loc4.substr(0, 2));
  1188. var _loc2 = Number(_loc4.substr(2, 2));
  1189. var _loc6 = collectibles.charAt(Math.floor(Math.random() * collectibles.length));
  1190. var _loc1 = gameClip.attachMovie("coll_" + _loc6, "brick_" + _loc3 + "_" + _loc2, depth + _loc2 * mapW + _loc3);
  1191. _loc1._x = tileSize * p.px;
  1192. _loc1._y = tileSize * p.py;
  1193. var _loc8 = tileSize * _loc3;
  1194. var _loc7 = tileSize * _loc2;
  1195. _loc1.easingTo("Quint", "Out", _loc8, _loc7, itemAnimTime, 20);
  1196. } // end of for
  1197. } // end if
  1198. } // End of the function
  1199. function renderExplosion(px, py)
  1200. {
  1201. var _loc2 = 0;
  1202. var _loc1 = 0;
  1203. var _loc7 = 0;
  1204. var _loc6 = 0;
  1205. var _loc4 = null;
  1206. for (var _loc5 = 0; _loc5 < 4; ++_loc5)
  1207. {
  1208. _loc7 = dirs[_loc5].ax;
  1209. _loc6 = dirs[_loc5].ay;
  1210. _loc2 = px;
  1211. _loc1 = py;
  1212. while (true)
  1213. {
  1214. _loc2 = _loc2 + _loc7;
  1215. _loc1 = _loc1 + _loc6;
  1216. _loc4 = gameMap[_loc1][_loc2];
  1217. if (_loc2 < 0 || _loc2 > mapW - 1 || _loc1 < 0 || _loc1 > mapH - 1 || _loc4.charCodeAt(0) >= 65 && _loc4.charCodeAt(0) <= 90)
  1218. {
  1219. break;
  1220. continue;
  1221. } // end if
  1222. if (explosionDepth > 8400)
  1223. {
  1224. explosionDepth = 8000;
  1225. } // end if
  1226. var _loc3 = gameClip.attachMovie("boom", "boom_" + explosionDepth, explosionDepth++);
  1227. _loc3._x = tileSize * _loc2;
  1228. _loc3._y = tileSize * _loc1;
  1229. } // end while
  1230. } // end of for
  1231. } // End of the function
  1232. _global.flashAPI = {name: "[flashAPI].mx", version: "2.0", author: "nacho rapallo [nacho@yestoall.com]"};
  1233. _global.Math2 = {};
  1234. Math2.elasticTween = function (t, b, c, d, a, p)
  1235. {
  1236. a = c > 0 && a < c || c < 0 && c < -a ? (c) : (a);
  1237. if (p == undefined)
  1238. {
  1239. p = d / 2;
  1240. } // end if
  1241. return ((t == d ? (0) : (-a * (-Math2.pow(2, -10 * t / d) + 1) + a)) * Math2.sin((t - p / (2 * Math2.PI) * Math2.asin(c / a)) * (2 * Math2.PI) / p) + b + c);
  1242. };
  1243. Math2.linearTween = function (t, b, c, d)
  1244. {
  1245. return (c * t / d + b);
  1246. };
  1247. Math2.easeInQuad = function (t, b, c, d)
  1248. {
  1249. t = t / d;
  1250. return (c * (t) * t + b);
  1251. };
  1252. Math2.easeOutQuad = function (t, b, c, d)
  1253. {
  1254. t = t / d;
  1255. return (-c * (t) * (t - 2) + b);
  1256. };
  1257. Math2.easeInOutQuad = function (t, b, c, d)
  1258. {
  1259. t = t / (d / 2);
  1260. if (t < 1)
  1261. {
  1262. return (c / 2 * t * t + b);
  1263. } // end if
  1264. return (-c / 2 * (--t * (t - 2) - 1) + b);
  1265. };
  1266. Math2.easeInCubic = function (t, b, c, d)
  1267. {
  1268. t = t / d;
  1269. return (c * (t) * t * t + b);
  1270. };
  1271. Math2.easeOutCubic = function (t, b, c, d)
  1272. {
  1273. t = t / d - 1;
  1274. return (c * ((t) * t * t + 1) + b);
  1275. };
  1276. Math2.easeInOutCubic = function (t, b, c, d)
  1277. {
  1278. t = t / (d / 2);
  1279. if (t < 1)
  1280. {
  1281. return (c / 2 * t * t * t + b);
  1282. } // end if
  1283. t = t - 2;
  1284. return (c / 2 * ((t) * t * t + 2) + b);
  1285. };
  1286. Math2.easeInQuart = function (t, b, c, d)
  1287. {
  1288. t = t / d;
  1289. return (c * (t) * t * t * t + b);
  1290. };
  1291. Math2.easeOutQuart = function (t, b, c, d)
  1292. {
  1293. t = t / d - 1;
  1294. return (-c * ((t) * t * t * t - 1) + b);
  1295. };
  1296. Math2.easeInOutQuart = function (t, b, c, d)
  1297. {
  1298. t = t / (d / 2);
  1299. if (t < 1)
  1300. {
  1301. return (c / 2 * t * t * t * t + b);
  1302. } // end if
  1303. t = t - 2;
  1304. return (-c / 2 * ((t) * t * t * t - 2) + b);
  1305. };
  1306. Math2.easeInQuint = function (t, b, c, d)
  1307. {
  1308. t = t / d;
  1309. return (c * (t) * t * t * t * t + b);
  1310. };
  1311. Math2.easeOutQuint = function (t, b, c, d)
  1312. {
  1313. t = t / d - 1;
  1314. return (c * ((t) * t * t * t * t + 1) + b);
  1315. };
  1316. Math2.easeInOutQuint = function (t, b, c, d)
  1317. {
  1318. t = t / (d / 2);
  1319. if (t < 1)
  1320. {
  1321. return (c / 2 * t * t * t * t * t + b);
  1322. } // end if
  1323. t = t - 2;
  1324. return (c / 2 * ((t) * t * t * t * t + 2) + b);
  1325. };
  1326. Math2.easeInSine = function (t, b, c, d)
  1327. {
  1328. return (-c * Math2.cos(t / d * (Math2.PI / 2)) + c + b);
  1329. };
  1330. Math2.easeOutSine = function (t, b, c, d)
  1331. {
  1332. return (c * Math2.sin(t / d * (Math2.PI / 2)) + b);
  1333. };
  1334. Math2.easeInOutSine = function (t, b, c, d)
  1335. {
  1336. return (-c / 2 * (Math2.cos(Math2.PI * t / d) - 1) + b);
  1337. };
  1338. Math2.easeInExpo = function (t, b, c, d)
  1339. {
  1340. return (t == 0 ? (b) : (c * Math2.pow(2, 10 * (t / d - 1)) + b));
  1341. };
  1342. Math2.easeOutExpo = function (t, b, c, d)
  1343. {
  1344. return (t == d ? (b + c) : (c * (-Math2.pow(2, -10 * t / d) + 1) + b));
  1345. };
  1346. Math2.easeInOutExpo = function (t, b, c, d)
  1347. {
  1348. if (t == 0)
  1349. {
  1350. return (b);
  1351. } // end if
  1352. if (t == d)
  1353. {
  1354. return (b + c);
  1355. } // end if
  1356. t = t / (d / 2);
  1357. if (t < 1)
  1358. {
  1359. return (c / 2 * Math2.pow(2, 10 * (t - 1)) + b);
  1360. } // end if
  1361. return (c / 2 * (-Math2.pow(2, -10 * --t) + 2) + b);
  1362. };
  1363. Math2.easeInCirc = function (t, b, c, d)
  1364. {
  1365. t = t / d;
  1366. return (-c * (Math2.sqrt(1 - t * t) - 1) + b);
  1367. };
  1368. Math2.easeOutCirc = function (t, b, c, d)
  1369. {
  1370. t = t / d - 1;
  1371. return (c * Math2.sqrt(1 - (t) * t) + b);
  1372. };
  1373. Math2.easeInOutCirc = function (t, b, c, d)
  1374. {
  1375. t = t / (d / 2);
  1376. if (t < 1)
  1377. {
  1378. return (-c / 2 * (Math2.sqrt(1 - t * t) - 1) + b);
  1379. } // end if
  1380. t = t - 2;
  1381. return (c / 2 * (Math2.sqrt(1 - (t) * t) + 1) + b);
  1382. };
  1383. MovieClip.prototype.easingTo = function (equation, type, x, y, duration, interval)
  1384. {
  1385. this.easingBy(equation, type, x - this._x, y - this._y, duration);
  1386. };
  1387. MovieClip.prototype.easingBy = function (equation, type, x, y, duration, interval)
  1388. {
  1389. if (this.easingActive)
  1390. {
  1391. clearInterval(this.easingThread);
  1392. } // end if
  1393. this.easingActive = true;
  1394. this.easingData = {equation: equation, type: type, Xini: this._x, Yini: this._y, Xend: x != null ? (x) : (this._x), Yend: y != null ? (y) : (this._y), duration: duration || 10, interval: interval || 10, counter: 0};
  1395. this.easingThread = setInterval(this, "easingLoop", this.easingData.interval);
  1396. };
  1397. MovieClip.prototype.easingStop = function ()
  1398. {
  1399. if (!this.easingActive)
  1400. {
  1401. return;
  1402. } // end if
  1403. clearInterval(this.easingThread);
  1404. this.easingActive = false;
  1405. };
  1406. MovieClip.prototype.easingLoop = function ()
  1407. {
  1408. ++this.easingData.counter;
  1409. var d = this.easingData;
  1410. if (d.counter <= d.duration)
  1411. {
  1412. var x = eval("Math2.ease" + d.type + d.equation)(d.counter, d.Xini, d.Xend, d.duration);
  1413. var y = eval("Math2.ease" + d.type + d.equation)(d.counter, d.Yini, d.Yend, d.duration);
  1414. this._x = x;
  1415. this._y = y;
  1416. this.onEasing(x, y);
  1417. }
  1418. else
  1419. {
  1420. this.easingStop();
  1421. this.onEasingEnd();
  1422. } // end else if
  1423. };
  1424. stop ();
  1425. playSoundtrack(20);
  1426. skinComponents("game");
  1427. chatBox_mc.messageTextInput.setFocus = null;
  1428. chatBox_mc.messageTextInput.addEventListener("focusIn", onSetFocusIn);
  1429. chatBox_mc.messageTextInput.addEventListener("focusOut", onSetFocusOut);
  1430. chatBox_mc.messageTextInput.addEventListener("enter", onEnter);
  1431. var POPUP_WAITING = "popup_waiting";
  1432. var POPUP_READY = "popup_ready";
  1433. var POPUP_PLAYER_LOST = "popup_playerLost";
  1434. var POPUP_MATCH_END = "popup_matchEnd";
  1435. var inGame = true;
  1436. var chatFocus = false;
  1437. var moveCount = 0;
  1438. var gameStarted = false;
  1439. var whoseTurn = 1;
  1440. var myPlayerId = smartFox.playerId;
  1441. var oppPlayerId = -1;
  1442. var opponentName = "";
  1443. var opponentAvatar = "";
  1444. var pickupItems = [];
  1445. var tileSize = 32;
  1446. var myPlayer = null;
  1447. var opPlayer = null;
  1448. var playerSpeed = 200;
  1449. var gameMap = [];
  1450. var mapW = 20;
  1451. var mapH = 16;
  1452. var depth = 100;
  1453. var bgDepth = 90;
  1454. var fgDepth = 13500;
  1455. var averagePing = 0;
  1456. var pingCount = 0;
  1457. var lastKeyPress = getTimer();
  1458. var keySpaceDelay = 100;
  1459. var itemTax = 3;
  1460. var itemAnimTime = 60;
  1461. var timer = null;
  1462. var gameDuration = 60;
  1463. var startTime = gameDuration;
  1464. var myMatches = 0;
  1465. var opMatches = 0;
  1466. var taunts = ["Ouch!", "Aaargh!", "Son of a ...", "Damn!", "Go to hell", "WTF!", "!?$@#!!"];
  1467. var bombSymbol = "X";
  1468. var emptyItem = ".";
  1469. var collectibles = "";
  1470. var bench;
  1471. var bombDepth = 9900;
  1472. var bombMax = 3;
  1473. var bombs = new Array(bombMax);
  1474. var explosionDepth = 8000;
  1475. var popup = null;
  1476. var dirs = [];
  1477. dirs[0] = {ax: -1, ay: 0};
  1478. dirs[1] = {ax: 1, ay: 0};
  1479. dirs[2] = {ax: 0, ay: -1};
  1480. dirs[3] = {ax: 0, ay: 1};
  1481. init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement