Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Action script...
- // [onClipEvent of sprite 634 in frame 9]
- onClipEvent (construct)
- {
- connectedMessage = "Connected";
- connectingMessage = "Connecting...";
- connectionFailedMessage = "Connection failed";
- connectionLostMessage = "Disconnected";
- notConnectedMessage = "Not connected";
- autoConnect = false;
- labelPlacement = "left";
- spacing = 5;
- serverIpAddress = "127.0.0.1";
- serverPort = 9339;
- debug = false;
- }
- // [onClipEvent of sprite 608 in frame 9]
- onClipEvent (construct)
- {
- noGuestLoginMsg = "";
- autoHide = false;
- backgroundWindowTitle = "";
- buttonText = "Login";
- spacing = 15;
- customLoginPage = "";
- layout = "side-top";
- passwordLabelText = "Password:";
- restrict = "^<>";
- zone = "";
- showBackgroundWindow = false;
- showFocusRectangle = false;
- showPassword = false;
- usernameLabelText = "";
- }
- // [onClipEvent of sprite 602 in frame 16]
- onClipEvent (construct)
- {
- spacing = 15;
- errorsDisplayTime = 2;
- groupByRoomType = true;
- joinButtonText = "Join";
- labelMargin = "";
- passwordLabelText = "Enter the password:";
- playButtonText = "Play";
- defaultRoom = "Lobby";
- rowHeight = 32;
- showChatRooms = false;
- showFocusRectangle = false;
- showGameRooms = true;
- showIcons = true;
- showLimboRooms = false;
- showPrivateRooms = true;
- sortOrder = "ASC";
- useSmartList = true;
- watchButtonText = "Watch";
- }
- // [onClipEvent of sprite 524 in frame 16]
- onClipEvent (construct)
- {
- banButtonText = "Ban";
- banMessage = "You have been banned by the Moderator";
- spacing = 15;
- enablePrivateChat = true;
- kickButtonText = "Kick";
- kickMessage = "You have been kicked by the Moderator";
- newPrivateMsgLabelColor = 13369344;
- labelMargin = "";
- moderateLabelTxt = "Moderate user:";
- privateChatLabelTxt = "Private messaging:";
- rowHeight = 32;
- showFocusRectangle = false;
- showIcons = true;
- sortOrder = "ASC";
- useSmartList = true;
- }
- // [onClipEvent of sprite 459 in frame 16]
- onClipEvent (construct)
- {
- adminMessageHeader = "<b>Administrator message received:</b><br>";
- sendButtonText = "Send";
- spacing = 15;
- privateChatMode = false;
- groupMessages = true;
- initialMessage = "Enter your message here";
- labelText = "";
- messageHeader = "<b>#user says:</b><br>";
- moderatorMessageHeader = "<b>Moderator message received:</b><br>";
- restrict = "^<>";
- roomJoinAlert = "<i>You entered the #room</i>";
- showClearButton = false;
- showColorPicker = true;
- showFocusRectangle = false;
- systemAlertsColor = 6710886;
- userEnterRoomAlert = "<i>#user entered the room</i>";
- userLeaveRoomAlert = "<i>#user left the room</i>";
- }
- // [onClipEvent of sprite 442 in frame 16]
- onClipEvent (construct)
- {
- editable = true;
- password = false;
- text = "";
- maxChars = null;
- restrict = "";
- enabled = true;
- visible = true;
- minHeight = 15;
- minWidth = 15;
- }
- // [onClipEvent of sprite 442 in frame 16]
- onClipEvent (construct)
- {
- editable = true;
- password = false;
- text = "";
- maxChars = null;
- restrict = "";
- enabled = true;
- visible = true;
- minHeight = 15;
- minWidth = 15;
- }
- // [onClipEvent of sprite 425 in frame 16]
- onClipEvent (construct)
- {
- icon = "";
- label = "Create";
- labelPlacement = "right";
- selected = false;
- toggle = false;
- enabled = true;
- visible = true;
- minHeight = 15;
- minWidth = 15;
- }
- // [onClipEvent of sprite 459 in frame 22]
- onClipEvent (construct)
- {
- adminMessageHeader = "<b>Administrator message received:</b><br>";
- sendButtonText = "Send";
- spacing = 10;
- privateChatMode = false;
- groupMessages = false;
- initialMessage = "Enter your message here";
- labelText = "";
- messageHeader = "<b>#user says:</b> ";
- moderatorMessageHeader = "<b>Moderator message received:</b><br>";
- restrict = "^<>";
- roomJoinAlert = "";
- showClearButton = false;
- showColorPicker = false;
- showFocusRectangle = false;
- systemAlertsColor = 6710886;
- userEnterRoomAlert = "";
- userLeaveRoomAlert = "";
- }
- // [onClipEvent of sprite 425 in frame 22]
- onClipEvent (construct)
- {
- icon = "";
- label = "EXIT";
- labelPlacement = "right";
- selected = false;
- toggle = false;
- enabled = true;
- visible = true;
- minHeight = 15;
- minWidth = 15;
- }
- // [Action in Frame 1]
- if (getBytesLoaded() / getBytesTotal() >= 1)
- {
- gotoAndStop("connect");
- }
- else
- {
- loading_txt.text = "Loading... " + Math.round(getBytesLoaded() / getBytesTotal() * 100) + "%";
- } // end else if
- // [Action in Frame 2]
- gotoAndPlay("load");
- // [Action in Frame 9]
- function handleConfigLoaded()
- {
- connector_mc.serverIpAddress = smartFox.ipAddress;
- connector_mc.serverPort = smartFox.port;
- connector_mc.debug = smartFox.debug;
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnection, mx.utils.Delegate.create(this, onConnection));
- loginBox_mc.zone = smartFox.defaultZone;
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onLogin, onLogin);
- connector_mc.connect();
- } // End of the function
- function onConnection(evt)
- {
- var _loc1 = evt.__get__params().success;
- if (_loc1)
- {
- if (smartFox.getConnectionMode() == it.gotoandplay.smartfoxserver.SmartFoxClient.CONNECTION_MODE_HTTP)
- {
- connMode_txt.text = "BLUEBOX";
- }
- else
- {
- connMode_txt.text = "SOCKET";
- } // end else if
- var _loc2 = Math.floor(Math.random() * avatars.length);
- myAvatar = avatars[_loc2];
- avatarSelector.gotoAndStop(myAvatar);
- avatarSelector.cow.onPress = onAvatarClick;
- avatarSelector.cat.onPress = onAvatarClick;
- avatarSelector.cock.onPress = onAvatarClick;
- avatarSelector.pig.onPress = onAvatarClick;
- } // end if
- } // End of the function
- function onLogin(evt)
- {
- var _loc1 = evt.__get__params().resObj;
- if (_loc1.success)
- {
- gotoAndStop("chat");
- } // end if
- } // End of the function
- function onAvatarClick()
- {
- myAvatar = this._name;
- avatarSelector.gotoAndStop(myAvatar);
- } // End of the function
- function setSounds()
- {
- bombDrop_snd.attachSound("bombDrop");
- bombDrop_snd.setVolume(100);
- bombExplode_snd.attachSound("bombExplode");
- bombExplode_snd.setVolume(100);
- matchStart_snd.attachSound("matchStart");
- matchStart_snd.setVolume(100);
- matchEnd_snd.attachSound("matchEnd");
- matchEnd_snd.setVolume(100);
- doorOpen_snd.attachSound("doorOpen");
- doorOpen_snd.setVolume(100);
- fruitPick_snd.attachSound("fruitPick");
- fruitPick_snd.setVolume(100);
- soundtrack.attachSound("soundtrack");
- soundtrack.onSoundComplete = function ()
- {
- playSoundtrack(soundtrack.getVolume());
- };
- } // End of the function
- function playSoundFx(snd)
- {
- if (soundsEnabled)
- {
- snd.start();
- } // end if
- } // End of the function
- function playSoundtrack(vol)
- {
- if (soundsEnabled)
- {
- soundtrack.stop();
- soundtrack.setVolume(vol);
- soundtrack.start();
- } // end if
- } // End of the function
- function skinComponents(screen)
- {
- com.metaliq.controls.UIObject.setStyle("fontFamily", "BerlinSansFBDemi");
- com.metaliq.controls.UIObject.setStyle("fontSize", 14);
- com.metaliq.controls.UIObject.setStyle("fontColor", 7039851);
- com.metaliq.controls.UIObject.setStyle("embedFonts", true);
- connector_mc.statusLabel.setInstanceStyle("fontColor", 3473408);
- if (screen == "connect")
- {
- loginBox_mc.usernameTextInput.maxChars = 8;
- loginBox_mc.loginButton.setInstanceStyle("fontSize", 18);
- loginBox_mc.loginButton.setInstanceStyle("fontColor", 16777215);
- loginBox_mc.loginButton.width = 75;
- loginBox_mc.loginButton.height = 28;
- loginBox_mc.refreshView();
- }
- else if (screen == "chat")
- {
- chatBox_mc.clearButton.icon = null;
- roomList_mc.cancelButton.icon = null;
- userList_mc.privateChat.clearButton.icon = null;
- chatBox_mc.colorPicker.background = null;
- roomList_mc.roomsList.background = "PanelBackground";
- userList_mc.usersList.background = "PanelBackground";
- userList_mc.privateChat.chatTextArea.background = "PanelBackground";
- chatBox_mc.chatTextArea.background = "PanelBackground";
- roomList_mc.showFocusRectangle = false;
- userList_mc.showFocusRectangle = false;
- userList_mc.privateChat.showFocusRectangle = false;
- chatBox_mc.showFocusRectangle = false;
- roomList_mc.passwordLabel.setInstanceStyle("fontFamily", "BerlinSansFBDemi");
- roomList_mc.passwordLabel.setInstanceStyle("fontSize", 14);
- roomList_mc.passwordLabel.setInstanceStyle("fontColor", 7039851);
- roomList_mc.passwordLabel.setInstanceStyle("embedFonts", true);
- chatBox_mc.sendButton.setInstanceStyle("fontSize", 18);
- chatBox_mc.sendButton.setInstanceStyle("fontColor", 16777215);
- chatBox_mc.colorPicker.setInstanceStyle("fontSize", 12);
- roomList_mc.joinButton.setInstanceStyle("fontSize", 18);
- roomList_mc.joinButton.setInstanceStyle("fontColor", 16777215);
- roomList_mc.watchButton.setInstanceStyle("fontSize", 18);
- roomList_mc.watchButton.setInstanceStyle("fontColor", 16777215);
- roomList_mc.watchButton.setInstanceStyle("fontSize", 18);
- roomList_mc.watchButton.setInstanceStyle("fontColor", 16777215);
- userList_mc.privateChat.sendButton.setInstanceStyle("fontSize", 18);
- userList_mc.privateChat.sendButton.setInstanceStyle("fontColor", 16777215);
- userList_mc.kickButton.setInstanceStyle("fontSize", 18);
- userList_mc.kickButton.setInstanceStyle("fontColor", 16777215);
- userList_mc.banButton.setInstanceStyle("fontSize", 18);
- userList_mc.banButton.setInstanceStyle("fontColor", 16777215);
- roomList_mc.roomsList.rowRenderer = "CustomRowRenderer";
- userList_mc.usersList.rowRenderer = "CustomRowRenderer";
- userList_mc.newPrivateMsgLabelColor = 8634654;
- userList_mc.privateChat.systemAlertsColor = 8634654;
- userList_mc.privateChat.colorPicker.value = 7039851;
- chatBox_mc.systemAlertsColor = 8634654;
- chatBox_mc.colorPicker.value = 7039851;
- roomList_mc.joinButton.width = 75;
- roomList_mc.joinButton.height = 28;
- roomList_mc.watchButton.width = 75;
- roomList_mc.watchButton.height = 28;
- roomList_mc.cancelButton.width = 26;
- roomList_mc.cancelButton.height = 26;
- roomList_mc.passwordTextInput.height = 22;
- roomList_mc.refreshView();
- chatBox_mc.sendButton.width = 75;
- chatBox_mc.sendButton.height = 28;
- chatBox_mc.colorPicker.width = 28;
- chatBox_mc.colorPicker.height = 28;
- chatBox_mc.clearButton.width = 28;
- chatBox_mc.clearButton.height = 28;
- chatBox_mc.refreshView();
- userList_mc.privateChat.sendButton.width = 75;
- userList_mc.privateChat.sendButton.height = 28;
- userList_mc.privateChat.clearButton.width = 26;
- userList_mc.privateChat.clearButton.height = 26;
- userList_mc.privateChat.messageTextInput.height = 22;
- userList_mc.kickButton.width = 75;
- userList_mc.kickButton.height = 28;
- userList_mc.banButton.width = 75;
- userList_mc.banButton.height = 28;
- userList_mc.refreshView();
- create_bt.setInstanceStyle("fontSize", 18);
- create_bt.setInstanceStyle("fontColor", 16777215);
- create_bt.width = 75;
- create_bt.height = 28;
- }
- else if (screen == "game")
- {
- chatBox_mc.clearButton.icon = null;
- chatBox_mc.colorPicker.background = null;
- chatBox_mc.chatTextArea.background = "PanelBackground";
- chatBox_mc.showFocusRectangle = false;
- chatBox_mc.sendButton.setInstanceStyle("fontSize", 18);
- chatBox_mc.sendButton.setInstanceStyle("fontColor", 16777215);
- chatBox_mc.colorPicker.setInstanceStyle("fontSize", 12);
- chatBox_mc.systemAlertsColor = 8634654;
- chatBox_mc.colorPicker.value = 7039851;
- chatBox_mc.sendButton.width = 75;
- chatBox_mc.sendButton.height = 28;
- chatBox_mc.refreshView();
- exit_bt.setInstanceStyle("fontSize", 18);
- exit_bt.setInstanceStyle("fontColor", 16777215);
- exit_bt.width = 75;
- exit_bt.height = 28;
- } // end else if
- } // End of the function
- stop ();
- Stage.showMenu = false;
- var XT_NAME = "battle";
- var smartFox = connector_mc.connection;
- var stageW = 640;
- var stageH = 640;
- var avatars = ["cow", "cat", "cock", "pig"];
- var myAvatar = "";
- var forceBlueBox = _root.conn == "http";
- var soundsEnabled = true;
- var bombDrop_snd = new Sound();
- var bombExplode_snd = new Sound();
- var matchStart_snd = new Sound();
- var matchEnd_snd = new Sound();
- var doorOpen_snd = new Sound();
- var fruitPick_snd = new Sound();
- var soundtrack = new Sound();
- setSounds();
- playSoundtrack(60);
- skinComponents("connect");
- smartFox.onConfigLoadSuccess = handleConfigLoaded;
- smartFox.loadConfig(forceBlueBox ? ("config_http.xml") : ("config.xml"), false);
- // [Action in Frame 16]
- function onJoinRoom(evt)
- {
- var _loc1 = evt.__get__params().room;
- if (_loc1.isGame())
- {
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onJoinRoom, onJoinRoom);
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onUserVariablesUpdate, onUserVariablesUpdate);
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onExtensionResponse);
- create_bt.removeEventListener("click", onCreateBtClick);
- delete mapSelector.prev_bt.onPress;
- delete mapSelector.next_bt.onPress;
- gotoAndStop("game");
- }
- else
- {
- if (_loc1.getUser(smartFox.myUserId).getVariable("avatar") == undefined)
- {
- var _loc2 = new Object();
- _loc2.avatar = myAvatar;
- smartFox.setUserVariables(_loc2);
- } // end if
- smartFox.sendXtMessage(XT_NAME, "maps", null);
- } // end else if
- } // End of the function
- function onUserVariablesUpdate(evt)
- {
- userList_mc.refreshView();
- } // End of the function
- function onExtensionResponse(evt)
- {
- var _loc7 = evt.__get__params().dataObj._cmd;
- if (_loc7 == "maps")
- {
- var _loc2 = evt.__get__params().dataObj.list;
- var _loc5 = mapSelector.createEmptyMovieClip("itemsHolder", 0);
- _loc5.setMask(mapSelector.itemsHolderMask);
- var _loc6 = [];
- for (var _loc1 = 0; _loc1 < _loc2.length; ++_loc1)
- {
- trace (_loc2[_loc1].id);
- trace (_loc2[_loc1].name);
- trace (_loc2[_loc1].icon);
- trace (_loc2[_loc1].thumb);
- availableMaps[_loc1] = _loc2[_loc1];
- availableMapsById[_loc2[_loc1].id] = _loc2[_loc1];
- var _loc3 = _loc5.attachMovie("item", "item" + _loc1, _loc1);
- _loc3.name_txt.text = _loc2[_loc1].name;
- _loc3.thumb_ldr.contentPath = "thumbnails/" + _loc2[_loc1].thumb + ".jpg";
- _loc3._y = _loc1 * mapMenuItemSize;
- var _loc4 = {};
- _loc4.url = "thumbnails/" + _loc2[_loc1].thumb + ".jpg";
- _loc4.target = _loc3.thumb;
- _loc6.push(_loc4);
- } // end of for
- var _loc8 = new it.gotoandplay.commons.util.QueueLoader(_loc6);
- _loc8.start();
- create_bt.enabled = true;
- roomList_mc.refreshView();
- } // end if
- } // End of the function
- function onCreateBtClick()
- {
- if (name_ti.text != "")
- {
- var _loc1 = new Object();
- _loc1.name = name_ti.text;
- _loc1.password = password_ti.text;
- _loc1.maxUsers = 2;
- _loc1.maxSpectators = 0;
- _loc1.isGame = true;
- _loc1.isTemp = true;
- var _loc2 = {};
- _loc2.name = "map";
- _loc2.val = availableMaps[selectedMapIndex].id;
- _loc2.priv = true;
- _loc2.persistent = true;
- var _loc3 = [];
- _loc3.push(_loc2);
- _loc1.vars = _loc3;
- smartFox.createRoom(_loc1);
- } // end if
- } // End of the function
- function onPrevMapClick()
- {
- trace (selectedMapIndex);
- if (availableMaps.length > 0)
- {
- if (selectedMapIndex > 0)
- {
- --selectedMapIndex;
- scrollMapsMenu();
- } // end if
- } // end if
- } // End of the function
- function onNextMapClick()
- {
- trace (selectedMapIndex);
- if (availableMaps.length > 0)
- {
- if (selectedMapIndex < availableMaps.length - 1)
- {
- ++selectedMapIndex;
- scrollMapsMenu();
- } // end if
- } // end if
- } // End of the function
- function scrollMapsMenu()
- {
- var _loc1 = new mx.transitions.TweenExtended(mapSelector.itemsHolder, ["_y"], Regular.easeOut, [mapSelector.itemsHolder._y], [-mapMenuItemSize * selectedMapIndex], 2.000000E-001, true);
- } // End of the function
- function setCustomRoomLabel(item)
- {
- var _loc2 = item.roomData;
- var _loc1 = _loc2.getName();
- var _loc4 = _loc2.getVariable("map");
- var _loc3 = availableMapsById[_loc4].name;
- if (_loc2.isGame() && _loc3 != undefined)
- {
- _loc1 = _loc1 + "<br>";
- _loc1 = _loc1 + "<font size=\'12\' color=\'#83C11E\'>";
- _loc1 = _loc1 + ("(" + _loc3 + ")");
- _loc1 = _loc1 + "</font>";
- } // end if
- return (_loc1);
- } // End of the function
- function setCustomRoomIcon(item)
- {
- var _loc1 = item.roomData;
- var _loc4 = _loc1.getVariable("map");
- var _loc3 = availableMapsById[_loc4].icon;
- var _loc2 = "";
- if (_loc1.isGame())
- {
- _loc2 = "icon" + _loc3;
- if (_loc1.getUserCount() >= _loc1.getMaxUsers())
- {
- _loc2 = _loc2 + "_full";
- }
- else if (_loc1.isPrivate())
- {
- _loc2 = _loc2 + "_priv";
- } // end if
- } // end else if
- return (_loc2);
- } // End of the function
- function setCustomUserLabel(item)
- {
- var _loc3 = item.userData;
- var _loc1 = "<font";
- if (item.newMsgCount > 0)
- {
- _loc1 = _loc1 + (" color=\'#" + newPrivateMsgLabelColor.toString(16) + "\'");
- } // end if
- _loc1 = _loc1 + (">" + _loc3.getName() + "</font>");
- if (item.newMsgCount > 0)
- {
- _loc1 = _loc1 + "<br>";
- _loc1 = _loc1 + "<font size=\'12\' color=\'#CCCCCC\'>";
- _loc1 = _loc1 + (String(item.newMsgCount) + " message" + (item.newMsgCount > 1 ? ("s") : ("")) + " to read");
- _loc1 = _loc1 + "</font>";
- } // end if
- return (_loc1);
- } // End of the function
- function setCustomUserIcon(item)
- {
- var _loc1 = item.userData;
- var _loc2 = "userIcon_" + _loc1.getVariable("avatar");
- return (_loc2);
- } // End of the function
- stop ();
- var availableMaps = [];
- var availableMapsById = [];
- var selectedMapIndex = 0;
- var mapMenuItemSize = 130;
- playSoundtrack(10);
- skinComponents("chat");
- roomList_mc.labelFunction = setCustomRoomLabel;
- roomList_mc.iconFunction = setCustomRoomIcon;
- userList_mc.labelFunction = setCustomUserLabel;
- userList_mc.iconFunction = setCustomUserIcon;
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onJoinRoom, mx.utils.Delegate.create(this, onJoinRoom));
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onUserVariablesUpdate, mx.utils.Delegate.create(this, onUserVariablesUpdate));
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, mx.utils.Delegate.create(this, onExtensionResponse));
- create_bt.addEventListener("click", onCreateBtClick);
- create_bt.enabled = false;
- mapSelector.prev_bt.onPress = onPrevMapClick;
- mapSelector.next_bt.onPress = onNextMapClick;
- // [Action in Frame 22]
- function onSetFocusIn()
- {
- trace ("FOCUS IN");
- chatFocus = true;
- } // End of the function
- function onSetFocusOut()
- {
- trace ("FOCUS OUT");
- chatFocus = false;
- } // End of the function
- function onEnter()
- {
- trace ("ENTER PRESSED");
- chatBox_mc.sendButton.setFocus();
- } // End of the function
- function init()
- {
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onGameExtensionResponse);
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onRoundTripResponse, onRoundTripResponse);
- connector_mc.addEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnectionLost, onConnectionLost);
- exit_bt.addEventListener("click", onExitBtClick);
- popup = showPopup(POPUP_WAITING);
- smartFox.sendXtMessage(XT_NAME, "ready", null);
- } // End of the function
- function onExitBtClick()
- {
- reset();
- gotoAndStop("chat");
- } // End of the function
- function onConnectionLost()
- {
- reset();
- gotoAndStop("connect");
- } // End of the function
- function reset()
- {
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onExtensionResponse, onGameExtensionResponse);
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onRoundTripResponse, onRoundTripResponse);
- connector_mc.removeEventListener(it.gotoandplay.smartfoxbits.events.SFSEvent.onConnectionLost, onConnectionLost);
- exit_bt.removeEventListener("click", onExitBtClick);
- clearInterval(bench);
- clearInterval(timer);
- gameStarted = false;
- inGame = false;
- popup.removeMovieClip();
- } // End of the function
- function onGameExtensionResponse(evt)
- {
- var _loc4 = evt.__get__params().type;
- var _loc1 = evt.__get__params().dataObj;
- trace ("SFS EVENT RECEIVED: " + _loc4);
- if (_loc4 == "xml")
- {
- if (_loc1._cmd == "map")
- {
- trace ("MAP RECEIVED");
- var _loc2 = availableMaps[selectedMapIndex];
- _loc2.background = _loc1.bg;
- _loc2.foreground = _loc1.fg;
- _loc2.duration = _loc1.dur;
- _loc2.p1x = _loc1.p1x;
- _loc2.p1y = _loc1.p1y;
- _loc2.p2x = _loc1.p2x;
- _loc2.p2y = _loc1.p2y;
- collectibles = _loc1.coll;
- gameDuration = _loc2.duration;
- timer_bg.gotoAndStop(1);
- showTime(gameDuration);
- gameClip.player1.removeMovieClip();
- gameClip.player2.removeMovieClip();
- setupMap(_loc1);
- checkNetwork();
- bench = setInterval(checkNetwork, 1000);
- initPlayers();
- popup = showPopup(POPUP_READY);
- }
- else if (_loc1._cmd == "stop")
- {
- handleStopGame();
- } // end else if
- }
- else
- {
- var _loc3 = _loc1[0];
- var _loc6 = Number(_loc1[1]);
- if (_loc3 == "go")
- {
- trace ("GAME START!");
- playSoundFx(matchStart_snd);
- popup.removeMovieClip();
- startTime = gameDuration;
- clearInterval(bench);
- bench = setInterval(checkNetwork, 5000);
- gameStarted = true;
- gameClip.onEnterFrame = mainThread;
- startTime = startTime - Math.round(averagePing / pingCount / 1000);
- timer_bg.gotoAndStop(1);
- showTime(startTime);
- timer = setInterval(updateTimer, 1000);
- }
- else if (_loc3 == "mv")
- {
- handleOpponentMove(Number(_loc1[2]), Number(_loc1[3]));
- }
- else if (_loc3 == "gi")
- {
- handlePickItem(Number(_loc1[2]), Number(_loc1[3]), Number(_loc1[4]));
- }
- else if (_loc3 == "bb")
- {
- handleOpponentBomb(_loc1[2], Number(_loc1[3]), Number(_loc1[4]));
- }
- else if (_loc3 == "xp")
- {
- handleExplosion(_loc1[2], _loc1[3], Number(_loc1[4]), Number(_loc1[5]), Number(_loc1[6]), _loc1[7], Number(_loc1[8]), _loc1[9]);
- }
- else if (_loc3 == "od")
- {
- handleOpenDoor(Number(_loc1[2]), Number(_loc1[3]));
- }
- else if (_loc3 == "win")
- {
- handleWinner(Number(_loc1[2]));
- } // end else if
- } // end else if
- } // End of the function
- function showPopup(linkageName)
- {
- var _loc2 = _root.attachMovie(linkageName, linkageName, 14000);
- _loc2._x = stageW / 2 - _loc2._width / 2;
- _loc2._y = stageH / 2 - _loc2._height / 2 - 40;
- return (_loc2);
- } // End of the function
- function updateTimer()
- {
- --startTime;
- if (startTime < 20 && startTime > 10)
- {
- timer_bg.gotoAndStop(2);
- }
- else if (startTime < 10)
- {
- timer_bg.gotoAndStop(3);
- } // end else if
- if (startTime == 0)
- {
- clearInterval(timer);
- } // end if
- showTime(startTime);
- } // End of the function
- function showTime(t)
- {
- var _loc2 = "" + Math.floor(t / 60);
- if (_loc2.length < 2)
- {
- _loc2 = "0" + _loc2;
- } // end if
- var _loc1 = "" + t % 60;
- if (_loc1.length < 2)
- {
- _loc1 = "0" + _loc1;
- } // end if
- timer_txt.text = _loc2 + ":" + _loc1;
- } // End of the function
- function onRoundTripResponse(evt)
- {
- var _loc1 = evt.__get__params().elapsed;
- averagePing = averagePing + _loc1 / 2;
- ++pingCount;
- var _loc2 = Math.round(averagePing / pingCount);
- bench_txt.text = "Average lag:\n" + _loc2 + " ms";
- } // End of the function
- function restartGame()
- {
- popup.removeMovieClip();
- smartFox.sendXtMessage(XT_NAME, "restart", {}, "xml");
- } // End of the function
- function setupMap(resObj)
- {
- gameClip.attachMovie("bg_" + resObj.bg, "background", bgDepth);
- var _loc6 = 0;
- for (var _loc5 = 0; _loc5 < mapH; ++_loc5)
- {
- var _loc4 = resObj[_loc5];
- gameMap[_loc5] = [];
- for (var _loc1 = 0; _loc1 < _loc4.length; ++_loc1)
- {
- var _loc3;
- var _loc2 = _loc4.charAt(_loc1);
- gameMap[_loc5][_loc1] = _loc2;
- if (_loc2.charCodeAt(0) >= 65 && _loc2.charCodeAt(0) <= 90)
- {
- _loc3 = gameClip.attachMovie("brick_" + _loc2, "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
- }
- else if (_loc2.charCodeAt(0) >= 97 && _loc2.charCodeAt(0) <= 122)
- {
- _loc3 = gameClip.attachMovie("coll_" + _loc2, "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
- pickupItems[_loc6] = _loc3;
- }
- else
- {
- _loc3 = gameClip.attachMovie("empty", "brick_" + _loc1 + "_" + _loc5, depth + _loc5 * mapW + _loc1);
- } // end else if
- _loc3._x = tileSize * _loc1;
- _loc3._y = tileSize * _loc5;
- } // end of for
- } // end of for
- for (var _loc5 = 0; _loc5 < 10; ++_loc5)
- {
- gameClip["bomb" + _loc5].removeMovieClip();
- gameClip["opBomb" + _loc5].removeMovieClip();
- } // end of for
- for (var _loc5 = 0; _loc5 < bombMax; ++_loc5)
- {
- bombs[_loc5] = true;
- } // end of for
- gameClip.attachMovie("fg_" + resObj.fg, "foreground", fgDepth);
- } // End of the function
- function initPlayers()
- {
- var _loc3 = availableMaps[selectedMapIndex];
- trace (_loc3.name);
- trace (_loc3.duration);
- trace (_loc3.p1x);
- trace (_loc3.p1y);
- trace (_loc3.background);
- var _loc8 = smartFox.getActiveRoom();
- var _loc2 = _loc8.getUserList();
- for (var _loc6 in _loc2)
- {
- if (_loc2[_loc6].getName() != smartFox.myUserName)
- {
- oppPlayerId = _loc2[_loc6].getPlayerId();
- opponentAvatar = _loc2[_loc6].getVariable("avatar");
- opponentName = _loc2[_loc6].getName();
- break;
- } // end if
- } // end of for...in
- _root["player" + myPlayerId].avPlaceHolder.attachMovie("userIcon_" + myAvatar, "icon", 0);
- _root["player" + oppPlayerId].avPlaceHolder.attachMovie("userIcon_" + opponentAvatar, "icon", 0);
- var _loc5 = gameClip.attachMovie("player_" + (myPlayerId == 1 ? (myAvatar) : (opponentAvatar)), "player1", myPlayerId == 1 ? (10001) : (10000));
- _loc5.px = _loc3.p1x;
- _loc5.py = _loc3.p1y;
- _loc5._x = _loc5.px * tileSize;
- _loc5._y = _loc5.py * tileSize;
- _loc5.score = 0;
- var _loc4 = gameClip.attachMovie("player_" + (myPlayerId == 2 ? (myAvatar) : (opponentAvatar)), "player2", myPlayerId == 2 ? (10001) : (10000));
- _loc4.px = _loc3.p2x;
- _loc4.py = _loc3.p2y;
- _loc4._x = _loc4.px * tileSize;
- _loc4._y = _loc4.py * tileSize;
- _loc4.score = 0;
- _loc5.gotoAndStop(4);
- _loc4.gotoAndStop(4);
- myPlayer = gameClip["player" + myPlayerId];
- opPlayer = gameClip["player" + oppPlayerId];
- opPlayer.moves = [];
- myPlayer.moving = false;
- opPlayer.moving = false;
- var _loc7 = gameClip.attachMovie("highlighter", "highlighter", 11000);
- _loc7._x = myPlayer._x + tileSize / 2;
- _loc7._y = myPlayer._y + tileSize / 2;
- _loc7.gotoAndPlay(2);
- updateScores();
- } // End of the function
- function mainThread()
- {
- if (gameStarted)
- {
- if (!myPlayer.moving)
- {
- if (!chatFocus)
- {
- if (Key.isDown(37) && (gameMap[myPlayer.py][myPlayer.px - 1].charCodeAt(0) < 65 || gameMap[myPlayer.py][myPlayer.px - 1].charCodeAt(0) > 90))
- {
- sendMyMove(myPlayer.px - 1, myPlayer.py);
- moveByTime(myPlayer, myPlayer.px - 1, myPlayer.py, playerSpeed);
- }
- else if (Key.isDown(39) && (gameMap[myPlayer.py][myPlayer.px + 1].charCodeAt(0) < 65 || gameMap[myPlayer.py][myPlayer.px + 1].charCodeAt(0) > 90))
- {
- sendMyMove(myPlayer.px + 1, myPlayer.py);
- moveByTime(myPlayer, myPlayer.px + 1, myPlayer.py, playerSpeed);
- }
- else if (Key.isDown(38) && (gameMap[myPlayer.py - 1][myPlayer.px].charCodeAt(0) < 65 || gameMap[myPlayer.py - 1][myPlayer.px].charCodeAt(0) > 90))
- {
- sendMyMove(myPlayer.px, myPlayer.py - 1);
- moveByTime(myPlayer, myPlayer.px, myPlayer.py - 1, playerSpeed);
- }
- else if (Key.isDown(40) && (gameMap[myPlayer.py + 1][myPlayer.px].charCodeAt(0) < 65 || gameMap[myPlayer.py + 1][myPlayer.px].charCodeAt(0) > 90))
- {
- sendMyMove(myPlayer.px, myPlayer.py + 1);
- moveByTime(myPlayer, myPlayer.px, myPlayer.py + 1, playerSpeed);
- } // end else if
- } // end else if
- } // end else if
- if (!chatFocus)
- {
- if (Key.isDown(32))
- {
- if (getTimer() > lastKeyPress + keySpaceDelay)
- {
- lastKeyPress = getTimer();
- var _loc5 = myPlayer.px;
- var _loc4 = myPlayer.py;
- var _loc7 = gameClip["brick_" + _loc5 + "_" + _loc4];
- if (_loc7.bomb == undefined)
- {
- for (var _loc1 = 0; _loc1 < bombMax; ++_loc1)
- {
- if (bombs[_loc1])
- {
- _loc7.bomb = true;
- bombs[_loc1] = false;
- var _loc6 = myPlayerId.toString() + _loc1.toString();
- var _loc3 = gameClip.attachMovie("bomb", "bomb" + _loc1, bombDepth + _loc1);
- gameMap[_loc4][_loc5] = bombSymbol;
- _loc3._x = _loc5 * tileSize;
- _loc3._y = _loc4 * tileSize;
- playSoundFx(bombDrop_snd);
- var _loc2 = [];
- _loc2.push(_loc6);
- _loc2.push(_loc5);
- _loc2.push(_loc4);
- smartFox.sendXtMessage(XT_NAME, "bb", _loc2, "str");
- break;
- } // end if
- } // end of for
- } // end if
- } // end if
- } // end if
- } // end if
- if (!opPlayer.moving && opPlayer.moves.length > 0)
- {
- moveByTime(opPlayer, opPlayer.moves[0].px, opPlayer.moves[0].py, playerSpeed);
- } // end if
- } // end if
- } // End of the function
- function moveByTime(who, px, py, duration)
- {
- who.moving = true;
- if (who.moves.length > 1)
- {
- who._x = who.moves[who.moves.length - 2].px * tileSize;
- who._y = who.moves[who.moves.length - 2].py * tileSize;
- px = who.moves[who.moves.length - 1].px;
- py = who.moves[who.moves.length - 1].py;
- } // end if
- who.moves = [];
- var _loc3 = who._x;
- var _loc2 = who._y;
- var _loc5 = px * tileSize;
- var _loc4 = py * tileSize;
- switch (_loc5 - _loc3)
- {
- case -tileSize:
- {
- who.gotoAndStop(1);
- break;
- }
- case tileSize:
- {
- who.gotoAndStop(2);
- break;
- }
- } // End of switch
- switch (_loc4 - _loc2)
- {
- case -tileSize:
- {
- who.gotoAndStop(3);
- break;
- }
- case tileSize:
- {
- who.gotoAndStop(4);
- break;
- }
- } // End of switch
- who.ani_startTime = getTimer();
- who.ani_endTime = who.ani_startTime + duration;
- who.duration = duration;
- who.sx = _loc3;
- who.sy = _loc2;
- who.dx = _loc5 - _loc3;
- who.dy = _loc4 - _loc2;
- who.onEnterFrame = animateByTime;
- } // End of the function
- function animateByTime()
- {
- var _loc3 = getTimer();
- if (_loc3 > this.ani_endTime)
- {
- delete this.onEnterFrame;
- this._x = this.sx + this.dx;
- this._y = this.sy + this.dy;
- this.px = this._x / tileSize;
- this.py = this._y / tileSize;
- this.moving = false;
- this.avatar.gotoAndStop(1);
- }
- else
- {
- if (this.avatar._currentframe == 1)
- {
- this.avatar.gotoAndPlay("run");
- } // end if
- var _loc4 = _loc3 - this.ani_startTime;
- var _loc2 = _loc4 / this.duration;
- this._x = this.sx + this.dx * _loc2;
- this._y = this.sy + this.dy * _loc2;
- } // end else if
- } // End of the function
- function sendMyMove(px, py)
- {
- var _loc1 = [];
- _loc1.push(px);
- _loc1.push(py);
- smartFox.sendXtMessage(XT_NAME, "mv", _loc1, "str");
- } // End of the function
- function handleOpponentMove(x, y)
- {
- opPlayer.moves.push({px: x, py: y});
- } // End of the function
- function handlePickItem(x, y, i)
- {
- trace ("Get item: px=" + x + " py=" + y + " i=" + i);
- if (i == myPlayerId)
- {
- ++myPlayer.score;
- playSoundFx(fruitPick_snd);
- }
- else
- {
- ++opPlayer.score;
- } // end else if
- updateScores();
- gameMap[y][x] = emptyItem;
- gameClip["brick_" + x + "_" + y].gotoAndStop(2);
- } // End of the function
- function handleStopGame()
- {
- gameStarted = false;
- playSoundFx(matchEnd_snd);
- gameClip.player1.removeMovieClip();
- gameClip.player2.removeMovieClip();
- clearInterval(timer);
- startTime = gameDuration;
- myMatches = 0;
- opMatches = 0;
- popup = showPopup(POPUP_PLAYER_LOST);
- } // End of the function
- function updateScores()
- {
- var _loc2 = smartFox.myUserName + " > Score: " + myPlayer.score + " | Matches: " + myMatches;
- var _loc1 = opponentName + " > Score: " + opPlayer.score + " | Matches: " + opMatches;
- player1.name.text = myPlayerId == 1 ? (_loc2) : (_loc1);
- player2.name.text = myPlayerId == 2 ? (_loc2) : (_loc1);
- } // End of the function
- function checkNetwork()
- {
- smartFox.roundTripBench();
- } // End of the function
- function handleOpponentBomb(id, px, py)
- {
- var _loc2 = Number(id.charAt(1));
- var _loc3 = gameClip["brick_" + px + "_" + py];
- var _loc1 = gameClip.attachMovie("bomb", "opBomb" + _loc2, bombDepth + 5 + _loc2);
- _loc1._x = tileSize * px;
- _loc1._y = tileSize * py;
- _loc3.bomb = true;
- gameMap[py][px] = bombSymbol;
- } // End of the function
- function handleExplosion(id, item, px, py, die1, newItems1, die2, newItems2)
- {
- var _loc9 = Number(id.charAt(0));
- var _loc4 = Number(id.charAt(1));
- var _loc6 = gameClip["brick_" + px + "_" + py];
- _loc6.bomb = undefined;
- gameMap[py][px] = item;
- var _loc5;
- if (_loc9 == myPlayerId)
- {
- _loc5 = "bomb" + _loc4;
- bombs[_loc4] = true;
- }
- else
- {
- _loc5 = "opBomb" + _loc4;
- } // end else if
- gameClip[_loc5].removeMovieClip();
- playSoundFx(bombExplode_snd);
- renderExplosion(px, py);
- var _loc3;
- var _loc2;
- if (myPlayerId == 1)
- {
- _loc3 = myPlayer;
- _loc2 = opPlayer;
- }
- else
- {
- _loc3 = opPlayer;
- _loc2 = myPlayer;
- } // end else if
- var _loc1 = 0;
- if (die1)
- {
- gameClip.player1.square.gotoAndPlay(2);
- attachBubble(gameClip.player1);
- if (_loc3.score < itemTax)
- {
- _loc1 = _loc3.score;
- }
- else
- {
- _loc1 = itemTax;
- } // end else if
- _loc3.score = _loc3.score - _loc1;
- looseCollectibles(_loc3, _loc1, newItems1);
- } // end if
- if (die2)
- {
- gameClip.player2.square.gotoAndPlay(2);
- attachBubble(gameClip.player2);
- if (_loc2.score < itemTax)
- {
- _loc1 = _loc2.score;
- }
- else
- {
- _loc1 = itemTax;
- } // end else if
- _loc2.score = _loc2.score - _loc1;
- looseCollectibles(_loc2, _loc1, newItems2);
- } // end if
- updateScores();
- } // End of the function
- function attachBubble(mc)
- {
- if (!mc.interval)
- {
- var _loc1 = mc.attachMovie("bubble", "bubble", 10);
- _loc1._x = 25;
- _loc1._y = -_loc1._height;
- var _loc3 = Math.floor(Math.random() * taunts.length);
- _loc1.message_txt.text = taunts[_loc3];
- mc.interval = setInterval(clearBubble, 2000, mc);
- } // end if
- } // End of the function
- function clearBubble(mc)
- {
- clearInterval(mc.interval);
- mc.interval = null;
- mc.bubble.removeMovieClip();
- } // End of the function
- function handleOpenDoor(px, py)
- {
- trace ("DOOR SHOULD OPEN at: " + px + "," + py);
- var _loc1 = gameClip.attachMovie("door", "exit", depth + py * mapW + px);
- playSoundFx(doorOpen_snd);
- _loc1._x = tileSize * px;
- _loc1._y = tileSize * py;
- } // End of the function
- function handleWinner(who)
- {
- gameStarted = false;
- playSoundFx(matchEnd_snd);
- clearInterval(timer);
- startTime = gameDuration;
- popup = showPopup(POPUP_MATCH_END);
- if (myPlayerId == who)
- {
- popup.message_txt.text = "Well done! You WON!\n Play again?";
- ++myMatches;
- }
- else
- {
- popup.message_txt.text = "Ouch! You LOST!\n Play again?";
- ++opMatches;
- } // end else if
- popup.score_txt.text = myMatches + " - " + opMatches;
- popup.restart_bt.onPress = restartGame;
- updateScores();
- } // End of the function
- function looseCollectibles(p, d, newItems)
- {
- if (d > 0)
- {
- for (var _loc5 = 0; _loc5 < d; ++_loc5)
- {
- var _loc4 = newItems.substr(0, 4);
- newItems = newItems.slice(4);
- var _loc3 = Number(_loc4.substr(0, 2));
- var _loc2 = Number(_loc4.substr(2, 2));
- var _loc6 = collectibles.charAt(Math.floor(Math.random() * collectibles.length));
- var _loc1 = gameClip.attachMovie("coll_" + _loc6, "brick_" + _loc3 + "_" + _loc2, depth + _loc2 * mapW + _loc3);
- _loc1._x = tileSize * p.px;
- _loc1._y = tileSize * p.py;
- var _loc8 = tileSize * _loc3;
- var _loc7 = tileSize * _loc2;
- _loc1.easingTo("Quint", "Out", _loc8, _loc7, itemAnimTime, 20);
- } // end of for
- } // end if
- } // End of the function
- function renderExplosion(px, py)
- {
- var _loc2 = 0;
- var _loc1 = 0;
- var _loc7 = 0;
- var _loc6 = 0;
- var _loc4 = null;
- for (var _loc5 = 0; _loc5 < 4; ++_loc5)
- {
- _loc7 = dirs[_loc5].ax;
- _loc6 = dirs[_loc5].ay;
- _loc2 = px;
- _loc1 = py;
- while (true)
- {
- _loc2 = _loc2 + _loc7;
- _loc1 = _loc1 + _loc6;
- _loc4 = gameMap[_loc1][_loc2];
- if (_loc2 < 0 || _loc2 > mapW - 1 || _loc1 < 0 || _loc1 > mapH - 1 || _loc4.charCodeAt(0) >= 65 && _loc4.charCodeAt(0) <= 90)
- {
- break;
- continue;
- } // end if
- if (explosionDepth > 8400)
- {
- explosionDepth = 8000;
- } // end if
- var _loc3 = gameClip.attachMovie("boom", "boom_" + explosionDepth, explosionDepth++);
- _loc3._x = tileSize * _loc2;
- _loc3._y = tileSize * _loc1;
- } // end while
- } // end of for
- } // End of the function
- _global.flashAPI = {name: "[flashAPI].mx", version: "2.0", author: "nacho rapallo [nacho@yestoall.com]"};
- _global.Math2 = {};
- Math2.elasticTween = function (t, b, c, d, a, p)
- {
- a = c > 0 && a < c || c < 0 && c < -a ? (c) : (a);
- if (p == undefined)
- {
- p = d / 2;
- } // end if
- 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);
- };
- Math2.linearTween = function (t, b, c, d)
- {
- return (c * t / d + b);
- };
- Math2.easeInQuad = function (t, b, c, d)
- {
- t = t / d;
- return (c * (t) * t + b);
- };
- Math2.easeOutQuad = function (t, b, c, d)
- {
- t = t / d;
- return (-c * (t) * (t - 2) + b);
- };
- Math2.easeInOutQuad = function (t, b, c, d)
- {
- t = t / (d / 2);
- if (t < 1)
- {
- return (c / 2 * t * t + b);
- } // end if
- return (-c / 2 * (--t * (t - 2) - 1) + b);
- };
- Math2.easeInCubic = function (t, b, c, d)
- {
- t = t / d;
- return (c * (t) * t * t + b);
- };
- Math2.easeOutCubic = function (t, b, c, d)
- {
- t = t / d - 1;
- return (c * ((t) * t * t + 1) + b);
- };
- Math2.easeInOutCubic = function (t, b, c, d)
- {
- t = t / (d / 2);
- if (t < 1)
- {
- return (c / 2 * t * t * t + b);
- } // end if
- t = t - 2;
- return (c / 2 * ((t) * t * t + 2) + b);
- };
- Math2.easeInQuart = function (t, b, c, d)
- {
- t = t / d;
- return (c * (t) * t * t * t + b);
- };
- Math2.easeOutQuart = function (t, b, c, d)
- {
- t = t / d - 1;
- return (-c * ((t) * t * t * t - 1) + b);
- };
- Math2.easeInOutQuart = function (t, b, c, d)
- {
- t = t / (d / 2);
- if (t < 1)
- {
- return (c / 2 * t * t * t * t + b);
- } // end if
- t = t - 2;
- return (-c / 2 * ((t) * t * t * t - 2) + b);
- };
- Math2.easeInQuint = function (t, b, c, d)
- {
- t = t / d;
- return (c * (t) * t * t * t * t + b);
- };
- Math2.easeOutQuint = function (t, b, c, d)
- {
- t = t / d - 1;
- return (c * ((t) * t * t * t * t + 1) + b);
- };
- Math2.easeInOutQuint = function (t, b, c, d)
- {
- t = t / (d / 2);
- if (t < 1)
- {
- return (c / 2 * t * t * t * t * t + b);
- } // end if
- t = t - 2;
- return (c / 2 * ((t) * t * t * t * t + 2) + b);
- };
- Math2.easeInSine = function (t, b, c, d)
- {
- return (-c * Math2.cos(t / d * (Math2.PI / 2)) + c + b);
- };
- Math2.easeOutSine = function (t, b, c, d)
- {
- return (c * Math2.sin(t / d * (Math2.PI / 2)) + b);
- };
- Math2.easeInOutSine = function (t, b, c, d)
- {
- return (-c / 2 * (Math2.cos(Math2.PI * t / d) - 1) + b);
- };
- Math2.easeInExpo = function (t, b, c, d)
- {
- return (t == 0 ? (b) : (c * Math2.pow(2, 10 * (t / d - 1)) + b));
- };
- Math2.easeOutExpo = function (t, b, c, d)
- {
- return (t == d ? (b + c) : (c * (-Math2.pow(2, -10 * t / d) + 1) + b));
- };
- Math2.easeInOutExpo = function (t, b, c, d)
- {
- if (t == 0)
- {
- return (b);
- } // end if
- if (t == d)
- {
- return (b + c);
- } // end if
- t = t / (d / 2);
- if (t < 1)
- {
- return (c / 2 * Math2.pow(2, 10 * (t - 1)) + b);
- } // end if
- return (c / 2 * (-Math2.pow(2, -10 * --t) + 2) + b);
- };
- Math2.easeInCirc = function (t, b, c, d)
- {
- t = t / d;
- return (-c * (Math2.sqrt(1 - t * t) - 1) + b);
- };
- Math2.easeOutCirc = function (t, b, c, d)
- {
- t = t / d - 1;
- return (c * Math2.sqrt(1 - (t) * t) + b);
- };
- Math2.easeInOutCirc = function (t, b, c, d)
- {
- t = t / (d / 2);
- if (t < 1)
- {
- return (-c / 2 * (Math2.sqrt(1 - t * t) - 1) + b);
- } // end if
- t = t - 2;
- return (c / 2 * (Math2.sqrt(1 - (t) * t) + 1) + b);
- };
- MovieClip.prototype.easingTo = function (equation, type, x, y, duration, interval)
- {
- this.easingBy(equation, type, x - this._x, y - this._y, duration);
- };
- MovieClip.prototype.easingBy = function (equation, type, x, y, duration, interval)
- {
- if (this.easingActive)
- {
- clearInterval(this.easingThread);
- } // end if
- this.easingActive = true;
- 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};
- this.easingThread = setInterval(this, "easingLoop", this.easingData.interval);
- };
- MovieClip.prototype.easingStop = function ()
- {
- if (!this.easingActive)
- {
- return;
- } // end if
- clearInterval(this.easingThread);
- this.easingActive = false;
- };
- MovieClip.prototype.easingLoop = function ()
- {
- ++this.easingData.counter;
- var d = this.easingData;
- if (d.counter <= d.duration)
- {
- var x = eval("Math2.ease" + d.type + d.equation)(d.counter, d.Xini, d.Xend, d.duration);
- var y = eval("Math2.ease" + d.type + d.equation)(d.counter, d.Yini, d.Yend, d.duration);
- this._x = x;
- this._y = y;
- this.onEasing(x, y);
- }
- else
- {
- this.easingStop();
- this.onEasingEnd();
- } // end else if
- };
- stop ();
- playSoundtrack(20);
- skinComponents("game");
- chatBox_mc.messageTextInput.setFocus = null;
- chatBox_mc.messageTextInput.addEventListener("focusIn", onSetFocusIn);
- chatBox_mc.messageTextInput.addEventListener("focusOut", onSetFocusOut);
- chatBox_mc.messageTextInput.addEventListener("enter", onEnter);
- var POPUP_WAITING = "popup_waiting";
- var POPUP_READY = "popup_ready";
- var POPUP_PLAYER_LOST = "popup_playerLost";
- var POPUP_MATCH_END = "popup_matchEnd";
- var inGame = true;
- var chatFocus = false;
- var moveCount = 0;
- var gameStarted = false;
- var whoseTurn = 1;
- var myPlayerId = smartFox.playerId;
- var oppPlayerId = -1;
- var opponentName = "";
- var opponentAvatar = "";
- var pickupItems = [];
- var tileSize = 32;
- var myPlayer = null;
- var opPlayer = null;
- var playerSpeed = 200;
- var gameMap = [];
- var mapW = 20;
- var mapH = 16;
- var depth = 100;
- var bgDepth = 90;
- var fgDepth = 13500;
- var averagePing = 0;
- var pingCount = 0;
- var lastKeyPress = getTimer();
- var keySpaceDelay = 100;
- var itemTax = 3;
- var itemAnimTime = 60;
- var timer = null;
- var gameDuration = 60;
- var startTime = gameDuration;
- var myMatches = 0;
- var opMatches = 0;
- var taunts = ["Ouch!", "Aaargh!", "Son of a ...", "Damn!", "Go to hell", "WTF!", "!?$@#!!"];
- var bombSymbol = "X";
- var emptyItem = ".";
- var collectibles = "";
- var bench;
- var bombDepth = 9900;
- var bombMax = 3;
- var bombs = new Array(bombMax);
- var explosionDepth = 8000;
- var popup = null;
- var dirs = [];
- dirs[0] = {ax: -1, ay: 0};
- dirs[1] = {ax: 1, ay: 0};
- dirs[2] = {ax: 0, ay: -1};
- dirs[3] = {ax: 0, ay: 1};
- init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement