diff --git a/config.js b/config.js index 708a513..8f4d821 100644 --- a/config.js +++ b/config.js @@ -174,7 +174,7 @@ module.exports = { // 62: "Custom pictures" in the settings menu, to hide players' item pictures. // 83: den items tinted (the tint in their version, DenItemHelper.applyTint). // 84: fixes from the owner's list of bugs (bugs.txt, 2026-10-23). - buildVersion: env.AJ_BUILD_VERSION || "84", + buildVersion: env.AJ_BUILD_VERSION || "85", // what the official CDN is asked for; not ours to change. upstreamBuildVersion: "3", diff --git a/lib/adventures/return-of-the-phantoms.js b/lib/adventures/return-of-the-phantoms.js index 4e85bbc..ccd7af7 100644 --- a/lib/adventures/return-of-the-phantoms.js +++ b/lib/adventures/return-of-the-phantoms.js @@ -537,9 +537,12 @@ module.exports = { for (const number of [2, 3, 4]) { set(q, `cork_${number}${pick("abc")}`, 1, 1, 0); } - for (const number of [1, 2, 3, 4]) { + // the last key's other places lie off where an animal can walk: + // players had to jump to it. it lies where the recording had it. + for (const number of [1, 2, 3]) { set(q, `bunny_key_${number}${pick("abcdef")}`, 1, 1, 0); } + set(q, "bunny_key_4c", 1, 1, 0); }); }, diff --git a/lib/amf3.js b/lib/amf3.js index 4c1c412..62f2872 100644 --- a/lib/amf3.js +++ b/lib/amf3.js @@ -307,7 +307,21 @@ class Amf3Writer { this.value(element); } } - else if (typeof value === "object" && !Buffer.isBuffer(value)) { + else if (value instanceof Date) { + // A date (a room file's timestamps): its milliseconds, written in place. + this.byte(0x08); + this.u29(1); + this.room(8); + this.pos = this.buf.writeDoubleBE(value.getTime(), this.pos); + } + else if (Buffer.isBuffer(value)) { + // A ByteArray (a room file's pictures and shapes). + this.byte(0x0c); + this.u29((value.length << 1) | 1); + this.room(value.length); + this.pos += value.copy(this.buf, this.pos); + } + else if (typeof value === "object") { // A dynamic object of no class, with its traits written in place. this.byte(0x0a); this.byte(0x0b); diff --git a/lib/games.json b/lib/games.json index bfe9c01..23337d4 100644 --- a/lib/games.json +++ b/lib/games.json @@ -3,11 +3,11 @@ {"id": 4, "swf": "Pachinko", "title": "Gem Ball", "type": 1, "vars": [16,17,0], "icon": 4295, "card": 58}, {"id": 5, "swf": "MiniGame_Memory", "title": "Double Up", "type": 1, "vars": [6,7,0], "icon": 4291, "card": 61}, {"id": 6, "swf": "MoatMadness", "title": "Overflow", "type": 1, "vars": [8,9,9], "icon": 4300, "card": 59}, - {"id": 10, "swf": "ParachuteGlider", "title": "Wind Rider", "type": 1, "vars": [12,13,0], "start": "seed", "icon": 4311, "card": 65}, + {"id": 10, "swf": "ParachuteGlider", "title": "Wind Rider", "type": 1, "vars": [12,13,0], "start": "seedAndCrosshairs", "icon": 4311, "card": 65}, {"id": 11, "swf": "Trivia", "title": "Temple of Trivia", "type": 1, "vars": [10,11,0], "icon": 4309, "card": 64, "ready": false}, {"id": 12, "swf": "RiverRace", "title": "River Race", "type": 1, "vars": [22,23,0], "start": "seed", "card": 62}, {"id": 13, "swf": "PhantomFighter", "title": "Phantom Fighter", "type": 1, "vars": [14,15,0], "icon": 4312, "card": 60}, - {"id": 14, "swf": "SpiderShooter", "title": "Spider Zapper", "type": 1, "vars": [18,19,0], "start": "seed", "icon": 4305, "card": 63}, + {"id": 14, "swf": "SpiderShooter", "title": "Spider Zapper", "type": 1, "vars": [18,19,0], "start": "seedAndCrosshairs", "icon": 4305, "card": 63}, {"id": 15, "swf": "MicroPopcorn", "title": "Popcorn Machine", "type": 0}, {"id": 16, "swf": "MicroCrane", "title": "The Claw", "type": 0}, {"id": 17, "swf": "MicroSmoothie", "title": "Smoothie Machine", "type": 0}, diff --git a/lib/http.js b/lib/http.js index 135df79..a496617 100644 --- a/lib/http.js +++ b/lib/http.js @@ -28,6 +28,7 @@ const extraMusic = require("./extramusic.js"); const customMusic = require("./custommusic.js"); const itemControl = require("./itemcontrol.js"); const masterpieces = require("./masterpieces.js"); +const themeRooms = require("./themerooms.js"); const panel = require("./panel.js"); const totp = require("./totp.js"); const world = require("./world.js"); @@ -1191,8 +1192,11 @@ const handle = async (req, res) => { // or from the current one when the room did not exist yet back then. const themed = THEMED_ROOM.exec(relPath); const mayFetch = () => from.local || cacheMisses.allow(from.key); - const body = (themed && Object.values(config.themes).some(theme => theme.build === Number(themed[2])) && await cdn.get(`${themed[2]}/roomDefs/${themed[3]}`, mayFetch)) - || await cdn.get(themed ? `${themed[1]}/roomDefs/${themed[3]}` : relPath, mayFetch); + const currentPath = themed ? `${themed[1]}/roomDefs/${themed[3]}` : relPath; + const oldBody = themed && themed[2] !== themed[1] && Object.values(config.themes).some(theme => theme.build === Number(themed[2])) + && await cdn.get(`${themed[2]}/roomDefs/${themed[3]}`, mayFetch); + // its shops and other spots as today's room has them (lib/themerooms.js) + const body = oldBody ? await themeRooms.fix(relPath, oldBody, () => cdn.get(currentPath, mayFetch)) : await cdn.get(currentPath, mayFetch); if (!body) { // one the CDN does not have is asked for again and again (the same few // hundred, by every client that meets them): its client may keep the diff --git a/lib/minigames.js b/lib/minigames.js index b08d069..f6e520c 100644 --- a/lib/minigames.js +++ b/lib/minigames.js @@ -88,7 +88,16 @@ const START = { // which player is its own by the id (GemBreakerPlayer.init), and only // that one aims and shoots. seedAndPlayers: game => [serial(), game.players.length, ...game.players.flatMap(player => [player.id, 0])], + // Spider Zapper and Wind Rider (SpiderShooterPlayer.init, + // ParachuteGliderPlayer.init): each player's sfs id and where it starts. + // given only the seed they had no players, none of them their own: + // nothing could be shot, and nobody glided. + seedAndCrosshairs: game => [serial(), game.players.length, + ...game.players.flatMap((player, at) => [player.id, CROSSHAIR_X + at * CROSSHAIR_GAP, CROSSHAIR_Y])], }; +const CROSSHAIR_X = 400; +const CROSSHAIR_GAP = 100; +const CROSSHAIR_Y = 300; // the room games several players play together: "Multiplayer" on the // game's waiting list (MinigameManager.setupWaitListPopup), for players in @@ -601,6 +610,18 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => { }, // the touch pool: the same again, with six prizes; which one is in the // first number. + // Spider Zapper, after each wave: "wave" [1 if the player shot enough, + // else 0] -> "wavesuccess" (the next wave) or "wavefail" (the end), and + // "waveend" [spiders shot] -> "waveend" [spiders shot] (its results). + // they went unanswered and the game waited after the first wave. + SpiderShooter: { + wave(session, game, [passed], reply) { + reply(passed === "1" ? "wavesuccess" : "wavefail"); + }, + waveend(session, game, [shot], reply) { + reply("waveend", /^\d{1,4}$/.test(String(shot)) ? Number(shot) : 0); + }, + }, TouchPool: { ts(session, game, params, reply) { session.prizeSerial = serial(); diff --git a/lib/themerooms.js b/lib/themerooms.js new file mode 100644 index 0000000..ab0da1e --- /dev/null +++ b/lib/themerooms.js @@ -0,0 +1,67 @@ +"use strict"; + +const zlib = require("zlib"); +const amf3 = require("./amf3.js"); + +// a room file of a seasonal theme comes from an older build (lib/http.js, +// roomAsSeenBy in lib/world.js), and so do its clickable spots: a shop there +// names the generic list it had then, which today's lists may have as +// something else or as nothing, so one theme's shops worked and another's +// did not. each spot the room has today too (by its name) is given today's +// list, kind and message; what only the old room has stays as it was. + +// the volume fields that say what a click does (RoomManagerWorld: type 1 a +// minigame by typeDefId, 7 a message, 12 a generic list) +const ACTION_FIELDS = ["type", "typeDefId", "message"]; +const MAX_KEPT = 40; // rooms remembered, made once each (files of up to a few MB) + +const kept = new Map(); // old file's path -> the file with today's spots, or null for "as it was" + +const volumes = room => (room && room.actors && Array.isArray(room.actors.ActorVolume) ? room.actors.ActorVolume : []); + +const withTodaysSpots = (oldBody, currentBody) => { + const old = amf3.decode(zlib.inflateSync(oldBody)); + const today = new Map(volumes(amf3.decode(zlib.inflateSync(currentBody))).filter(volume => volume && volume.name).map(volume => [volume.name, volume])); + let changed = false; + for (const volume of volumes(old)) { + const now = volume && today.get(volume.name); + if (now && ACTION_FIELDS.some(field => volume[field] !== now[field])) { + for (const field of ACTION_FIELDS) { + if (now[field] === undefined) { + delete volume[field]; + } + else { + volume[field] = now[field]; + } + } + changed = true; + } + } + return changed ? zlib.deflateSync(amf3.encode(old)) : oldBody; +}; + +// `oldBody` with today's spots, `current` giving today's file (or null); +// the old one as it was when that cannot be had or read. +const fix = async (key, oldBody, current) => { + if (kept.has(key)) { + return kept.get(key) || oldBody; + } + let body = oldBody; + try { + const currentBody = await current(); + if (currentBody) { + body = withTodaysSpots(oldBody, currentBody); + } + } + catch (err) { + console.log(`[themes] ${key}: ${err.message}`); + body = oldBody; + } + if (kept.size >= MAX_KEPT) { + kept.delete(kept.keys().next().value); + } + kept.set(key, body === oldBody ? null : body); + return body; +}; + +module.exports = {fix}; diff --git a/lib/trades.js b/lib/trades.js index 38f138c..1d82c76 100644 --- a/lib/trades.js +++ b/lib/trades.js @@ -53,8 +53,11 @@ module.exports = ({findOnline, blocks, showTrading}) => { // createdTs, lBits, uBits, eBits, name, personality, toy, food)...] const sendTradeList = (to, account) => { const listed = type => account.tradeList.filter(entry => entry.type === type).map(entry => entry.inv); - const clothing = account.items.filter(item => listed(TYPE_CLOTHING).includes(item.inv)); - const denItems = account.denItems.filter(item => listed(TYPE_DEN_ITEM).includes(item.inv) && masterpieces.itemApproved(item)); + // one whose def is gone (a custom item deleted) is left out: the client + // cannot make an item of it, and the list stopped there. + const clothing = account.items.filter(item => listed(TYPE_CLOTHING).includes(item.inv) && defpacks.itemDef(item.def)); + const denItems = account.denItems.filter(item => listed(TYPE_DEN_ITEM).includes(item.inv) && masterpieces.itemApproved(item) + && defpacks.denItemDef(item.def)); const pets = account.pets.filter(pet => listed(TYPE_PET).includes(pet.inv)); to.sendXt("tl", -1, account.username, clothing.length, ...clothing.flatMap(item => [item.def, item.inv, item.color]), @@ -71,8 +74,10 @@ module.exports = ({findOnline, blocks, showTrading}) => { (type === TYPE_CLOTHING ? account.items : type === TYPE_DEN_ITEM ? account.denItems : type === TYPE_PET ? account.pets : []); // A masterpiece still waiting for review is nobody's to trade. + // nor one whose def is gone. const find = (account, type, inv) => collectionOf(account, type) - .find(entry => entry.inv === inv && (type !== TYPE_DEN_ITEM || masterpieces.itemApproved(entry))); + .find(entry => entry.inv === inv && (type !== TYPE_DEN_ITEM || masterpieces.itemApproved(entry)) + && (type === TYPE_CLOTHING ? Boolean(defpacks.itemDef(entry.def)) : type === TYPE_DEN_ITEM ? Boolean(defpacks.denItemDef(entry.def)) : true)); // the field layouts differ between the offer the owner is shown (no // inventory ids for clothing and den items) and the completed trade. diff --git a/lib/world.js b/lib/world.js index 660302d..62ab7a4 100644 --- a/lib/world.js +++ b/lib/world.js @@ -156,6 +156,9 @@ const DIAMOND_ANIMAL_AND_PET_LISTS = [166, 214, 293]; // the Diamond Shop's two den displays ("one" and "two" in its room file). // taken for the dens sold for diamonds: nothing else in the room is. const DIAMOND_DEN_LIST = 196; +// the egg the egg stands sell (pet.EggPetGuiManager, list 624): one at +// random of these, the diamond shop's eggs. empty, the stand threw. +const DIAMOND_EGG_LIST = 624; const LANG_ENG = 0; const IDLE_ANIM_LAND = 14; const IDLE_ANIM_OCEAN = 29; @@ -591,8 +594,10 @@ const sortStock = () => { // two out-of-the-way shops keep what was never in one: the shop in the // Chamber of Knowledge's base (reached from a hidden spot on the world map) // has the den items, the one in the Zios archives the clothing. see -// oddDenItemIds in lib/defpacks.js. -const ODDITY_SHOPS = new Map([[396, () => defpacks.oddDenItemIds()], [666, () => defpacks.oddClothingIds()]]); +// oddDenItemIds in lib/defpacks.js. of the clothing only the Founder's Hat +// (oddClothingIds' first): the rest, nameless pieces never finished, made the +// Forgotten Archive a heap of broken items. +const ODDITY_SHOPS = new Map([[396, () => defpacks.oddDenItemIds()], [666, () => defpacks.oddClothingIds().slice(0, 1)]]); // the items staff have made (lib/customitems.js) are sold there too, first. const CUSTOM_ITEM_SHOPS = new Map([[396, "den"], [666, "clothing"]]); const ticketStock = kind => sortStock()[kind]; @@ -931,6 +936,12 @@ const handlers = { const real = shopStock.list(listId, type); entries = [...new Set([...defpacks.customShopIds(CUSTOM_ITEM_SHOPS.get(Number(listId))), ...(real ? real.entries : []), ...ODDITY_SHOPS.get(Number(listId))()])]; } + else if (Number(listId) === DIAMOND_EGG_LIST) { + entries = defpacks.diamondIds().filter(id => { + const def = defpacks.diamondDef(id); + return def.type === DIAMOND_TYPES.pet && (defpacks.petDef(Number(def.refId)) || {}).isEgg === "1"; + }); + } else if (Number(listId) === DIAMOND_DEN_LIST) { entries = defpacks.diamondIds().filter(id => { const def = defpacks.diamondDef(id); diff --git a/public/captcha.js b/public/captcha.js index 1558051..b2a7c08 100644 --- a/public/captcha.js +++ b/public/captcha.js @@ -41,12 +41,15 @@ window.captcha = (() => { return loading; }; - // `options`: {appearance} ("interaction-only" by default: seen only when - // cloudflare wants a click), {onAnswer(token)}. + // `options`: {appearance} ("always" by default: hidden till cloudflare + // wanted a click, it was taken for one that never showed), {onAnswer(token)}. + const MAX_RETRIES = 2; // a widget that errs is started again this often first const mount = (element, action, options = {}) => { let widget = null; let answer = null; // a token, "" when none could be had, null while waiting let waiting = []; + let retries = 0; + let starting = false; const settle = value => { answer = value; if (value && options.onAnswer) { @@ -57,22 +60,38 @@ window.captcha = (() => { } waiting = []; }; - if (siteKey) { + const start = () => { + if (!siteKey || starting || widget !== null) { + return; + } + starting = true; load().then(turnstile => { + starting = false; try { widget = turnstile.render(element, { sitekey: siteKey, action, theme: "dark", - appearance: options.appearance || "interaction-only", - callback: settle, + appearance: options.appearance || "always", + callback: value => { + retries = 0; + settle(value); + }, "expired-callback": () => { answer = null; }, - // its code is cloudflare's (110200: this site's name is not on the widget) + // its code is cloudflare's (110200: this site's name is not on + // the widget). many pass with a second go: it is had first. "error-callback": code => { console.log(`captcha error ${code}`); + if (retries < MAX_RETRIES) { + retries++; + answer = null; + setTimeout(() => window.turnstile.reset(widget), 1000 * retries); + return true; + } settle(""); + return true; }, }); } @@ -80,20 +99,29 @@ window.captcha = (() => { console.log(`captcha could not start: ${err.message}`); settle(""); } - }, () => settle("")); - } + }, () => { + starting = false; + settle(""); + }); + }; + start(); return { on: Boolean(siteKey), answer: () => { if (!siteKey) { return Promise.resolve(undefined); } + // one that could not load is tried again when an answer is wanted + if (answer === "" && widget === null) { + answer = null; + start(); + } return answer !== null ? Promise.resolve(answer) : new Promise(resolve => waiting.push(resolve)); }, - // (a widget that never loaded keeps its "" so nothing waits on it) reset: () => { if (widget !== null) { answer = null; + retries = 0; window.turnstile.reset(widget); } }, diff --git a/swf-src/AvatarWorldView.as b/swf-src/AvatarWorldView.as index 51ea100..86459ad 100644 --- a/swf-src/AvatarWorldView.as +++ b/swf-src/AvatarWorldView.as @@ -826,7 +826,22 @@ package avatar public function getBaseIdle() : int { - return _roomType == 1 ? 32 : 14; + return drawnSwimming() ? 32 : 14; + } + + // whether the animal is drawn with its swimming animations: the + // room's kind when it has art for both, else the one it has. a land + // animal in water (or a sea one on land) asked for art it has none of, + // and stood invisible until it did something it had art for. + private function drawnSwimming() : Boolean + { + var _loc1_:Boolean = _avatar == null || Utility.isLand(_avatar.enviroTypeFlag); + var _loc2_:Boolean = _avatar == null || Utility.isOcean(_avatar.enviroTypeFlag); + if(_loc1_ == _loc2_) + { + return _roomType == 1; + } + return _loc2_; } public function setPath(param1:Array) : void @@ -2679,7 +2694,7 @@ package avatar _lastMoveAngle = _loc7_; var _loc8_:Object = convertToIdle(_lastMoveAngle); _lastIdleAnim = _loc8_.anim; - if(_roomType == 1) + if(drawnSwimming()) { _lastIdleAnim = getBaseIdle(); } @@ -2746,7 +2761,7 @@ package avatar _loc9_ = 14; } } - if(_roomType == 1) + if(drawnSwimming()) { _loc9_ = 29; } @@ -2839,7 +2854,7 @@ package avatar public function preload(param1:Function) : void { var _loc2_:Array = []; - if(_roomType == 1) + if(drawnSwimming()) { _loc2_.push(29); _loc2_.push(32); diff --git a/swf-src/NGFactManager.as b/swf-src/NGFactManager.as index 5bc4250..79951fb 100644 --- a/swf-src/NGFactManager.as +++ b/swf-src/NGFactManager.as @@ -702,11 +702,17 @@ package gui { _loc2_.txt.text = ""; } - if(_loc2_.title != null) + // the Alpha HQ's bios have no title (string 0), and an id with no + // string throws: the popup stayed on screen with nothing able to + // close it. none is left as it is. + if(_loc2_.title != null && param1.title > 0) { LocalizationManager.translateId(_loc2_.title.txt,param1.title); } - LocalizationManager.translateId(_loc2_.txt,param1.description); + if(param1.description > 0) + { + LocalizationManager.translateId(_loc2_.txt,param1.description); + } if(param1.media && param1.media != 0) { _loc3_ = new MediaHelper(); @@ -724,7 +730,13 @@ package gui } } _loc2_.addEventListener("mouseDown",factMouseDownHandler,false,0,true); - if(_loc2_.nextBtn) + // one fact on its own (not one of a list) has no next or previous + if(_loc2_.nextBtn && (_genericFactDefIndexList == null || isNaN(param1.index))) + { + _loc2_.nextBtn.visible = false; + _loc2_.prevBtn.visible = false; + } + else if(_loc2_.nextBtn) { _loc2_.nextBtn.addEventListener("mouseDown",factNextPrevBtnHandler,false,0,true); _loc2_.prevBtn.addEventListener("mouseDown",factNextPrevBtnHandler,false,0,true); diff --git a/swf-src/PetBase.as b/swf-src/PetBase.as new file mode 100644 index 0000000..bb7e97c --- /dev/null +++ b/swf-src/PetBase.as @@ -0,0 +1,487 @@ +package pet +{ + import flash.display.MovieClip; + import flash.display.Sprite; + import loader.MediaHelper; + import localization.LocalizationManager; + + public class PetBase extends Sprite + { + + public static const DEF_ID_CAT:int = 1; + + public static const DEF_ID_FROG:int = 2; + + public static const DEF_ID_DUCK:int = 3; + + public static const DEF_ID_DOG:int = 4; + + public static const DEF_ID_BFLY:int = 5; + + public static const DEF_ID_HAMS:int = 6; + + public static const DEF_ID_BAT:int = 7; + + public static const DEF_ID_SEAHORSE:int = 8; + + public static const DEF_ID_ANGLER:int = 9; + + public static const DEF_ID_REINDEER:int = 10; + + public static const DEF_ID_SNAKE:int = 11; + + public static const DEF_ID_JELLYFISH:int = 12; + + public static const DEF_ID_BUNNY:int = 13; + + public static const DEF_ID_HUMMINGBIRD:int = 14; + + public static const DEF_ID_TURTLE:int = 15; + + public static const DEF_ID_MONKEY:int = 16; + + public static const DEF_ID_TARANTUAL:int = 17; + + public static const DEF_ID_FOX:int = 18; + + public static const DEF_ID_OWL:int = 19; + + public static const DEF_ID_TIGER:int = 20; + + public static const DEF_ID_ARCTIC_WOLF:int = 21; + + public static const DEF_ID_RACCOON:int = 22; + + public static const DEF_ID_JOEY:int = 23; + + public static const DEF_ID_EAGLET:int = 24; + + public static const DEF_ID_CHEETAH:int = 25; + + public static const DEF_ID_RHINO:int = 26; + + public static const DEF_ID_GIRAFFE:int = 27; + + public static const DEF_ID_SUGAR_GLIDER:int = 28; + + public static const DEF_ID_LION_CUB:int = 29; + + public static const DEF_ID_PANDA:int = 30; + + public static const DEF_ID_POLAR_BEAR_CUB:int = 31; + + public static const DEF_ID_GECKO:int = 32; + + public static const DEF_ID_PONY:int = 34; + + public static const DEF_ID_PIGLET:int = 35; + + public static const DEF_ID_FERRET:int = 36; + + public static const DEF_ID_ELEPHANT:int = 37; + + public static const DEF_ID_ARMADILLO:int = 38; + + public static const DEF_ID_PEACOCK:int = 39; + + public static const DEF_ID_BEE:int = 40; + + public static const DEF_ID_ROOSTER:int = 41; + + public static const DEF_ID_SKUNK:int = 42; + + public static const DEF_ID_TURKEY:int = 43; + + public static const DEF_ID_PENGUIN:int = 44; + + public static const DEF_ID_SNOW_LEOPARD:int = 45; + + public static const DEF_ID_MANITS:int = 46; + + public static const DEF_ID_LADYBUG:int = 47; + + public static const DEF_ID_CRICKET:int = 48; + + public static const DEF_ID_SQUIRREL:int = 49; + + public static const DEF_ID_MOUSE:int = 50; + + public static const DEF_ID_FIREFLY:int = 51; + + public static const DEF_ID_LEMUR:int = 52; + + public static const DEF_ID_HIPPO:int = 53; + + public static const DEF_ID_GOAT:int = 54; + + public static const DEF_ID_MEERKAT:int = 55; + + public static const DEF_ID_GOLDEN_BUNNY:int = 56; + + public static const DEF_ID_PHANTOM:int = 57; + + public static const DEF_ID_SEAL:int = 58; + + public static const DEF_ID_OTTER:int = 59; + + public static const DEF_ID_PHANTOM_RARE:int = 60; + + public static const DEF_ID_GROUND_HOG:int = 61; + + public static const DEF_ID_LLAMA:int = 62; + + public static const DEF_ID_ARCTIC_FOX:int = 63; + + public static const DEF_ID_HYENA:int = 64; + + public static const DEF_ID_SLOTH:int = 65; + + public static const DEF_ID_DOVE:int = 66; + + public static const DEF_ID_CHICK:int = 67; + + public static const DEF_ID_GOLDEN_ARMADILLO:int = 68; + + public static const DEF_ID_FALCON:int = 69; + + public static const DEF_ID_CROCODILE:int = 70; + + public static const DEF_ID_PLATYPUS:int = 71; + + public static const DEF_ID_PHANTOM_JW:int = 72; + + public static const DEF_ID_GOLDEN_PONY:int = 73; + + public static const DEF_ID_SHARK:int = 74; + + public static const DEF_ID_DOLPHIN:int = 75; + + public static const DEF_ID_ECHIDNA:int = 76; + + public static const DEF_ID_KOALA:int = 77; + + public static const DEF_ID_LYNX:int = 80; + + public static const DEF_ID_OCTOPUS:int = 81; + + public static const DEF_ID_FENNEC_FOX_JW:int = 82; + + public static const DEF_ID_HEDGEHOG:int = 83; + + public static const DEF_ID_SCORPION:int = 84; + + public static const DEF_ID_CROW:int = 85; + + public static const DEF_ID_MOOSE:int = 86; + + public static const DEF_ID_POODLE:int = 87; + + public static const DEF_ID_LOVEBUNNY:int = 88; + + public static const DEF_ID_SABERTOOTH:int = 89; + + public static const DEF_ID_DIREWOLF:int = 90; + + public static const DEF_ID_DODO:int = 91; + + public static const DEF_ID_FANTASY_PEACOCK:int = 92; + + public static const DEF_ID_MILLIPEDE:int = 93; + + public static const DEF_ID_MOTH:int = 94; + + public static const DEF_ID_VULTURE:int = 95; + + public static const DEF_ID_COYOTE:int = 96; + + public static const DEF_ID_MEAGYNS:int = 97; + + public static const DEF_ID_FALCON2:int = 98; + + public static const DEF_ID_LOVE_BUG:int = 99; + + public static const DEF_ID_FLYING_PIG:int = 100; + + public static const DEF_ID_SPARROW:int = 101; + + public static const DEF_ID_FENNEC_FOX:int = 102; + + public static const DEF_ID_CARDINAL:int = 103; + + public static const DEF_ID_FRILLED_LIZARD:int = 104; + + public static const DEF_ID_DRAGONFLY:int = 105; + + public static const DEF_ID_MAGENTA_SEAL:int = 106; + + public static const DEF_ID_PANGOLIN:int = 107; + + public static const DEF_ID_CAMEL:int = 108; + + public static const DEF_ID_SNAIL:int = 109; + + public static const DEF_ID_GALACTIC_FIREFLY:int = 110; + + public static const DEF_ID_CATERPILLAR:int = 111; + + public static const DEF_ID_LAMB:int = 112; + + public static const DEF_ID_GOLDEN_REINDEER:int = 113; + + public static const DEF_ID_HIGHLANDCOW:int = 114; + + public static const DEF_ID_NIGHTHAWK:int = 115; + + public static const DEF_ID_FRANKENKITTEN:int = 116; + + public static const TYPE_LAND_GROUND:int = 0; + + public static const TYPE_LAND_AIR:int = 1; + + public static const TYPE_OCEAN_GROUND:int = 2; + + public static const TYPE_OCEAN_AIR:int = 3; + + public static const TYPE_AMPHIB_GROUND:int = 4; + + public static const TYPE_AMPHIB_AIR:int = 5; + + protected var _petDef:PetDef; + + protected var _lBits:uint; + + protected var _uBits:uint; + + protected var _eBits:uint; + + protected var _traitDefId:uint; + + protected var _toyDefId:uint; + + protected var _foodDefId:uint; + + protected var _content:MovieClip; + + protected var _createdTs:Number; + + private var _mediaHelper:MediaHelper; + + private var _onPetLoadedCallback:Function; + + public function PetBase(param1:Number, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint, param8:Function) + { + super(); + _createdTs = param1; + _lBits = param2; + _uBits = param3; + _eBits = param4; + _traitDefId = param5; + _toyDefId = param6; + _foodDefId = param7; + _onPetLoadedCallback = param8; + _petDef = PetManager.getPetDef(param2 & 0xFF); + // bits naming no pet the game has: the first pet, rather than + // a pet that never loads and stops what was drawing it + if(_petDef == null) + { + _petDef = PetManager.getPetDef(1); + } + _mediaHelper = new MediaHelper(); + _mediaHelper.init(mediaIdForDefId(_petDef.defId),onMediaLoaded,true); + } + + public function destroy() : void + { + } + + public function getPetTitleName() : String + { + return LocalizationManager.translateIdOnly(_petDef.titleStrId); + } + + public function isGround() : Boolean + { + if(_petDef.isEgg && !PetManager.hasHatched(_createdTs)) + { + return true; + } + return PetManager.isGround(_petDef.type); + } + + public function isEggAndHasNotHatched() : Boolean + { + if(_petDef.isEgg) + { + return PetManager.hasHatched(_createdTs) == false; + } + return false; + } + + public function isEgg() : Boolean + { + return _petDef.isEgg; + } + + public function getType() : int + { + return _petDef.type; + } + + public function getDefID() : int + { + return _petDef.defId; + } + + public function canGoInOcean() : Boolean + { + if(_petDef.type == 2 || _petDef.type == 3 || _petDef.type == 4 || _petDef.type == 5) + { + return true; + } + return false; + } + + public function canGoOnLand() : Boolean + { + if(_petDef.type == 0 || _petDef.type == 1 || _petDef.type == 4 || _petDef.type == 5) + { + return true; + } + return false; + } + + public function getLBits() : uint + { + return _lBits; + } + + public function getUBits() : uint + { + return _uBits; + } + + public function getEBits() : uint + { + return _eBits; + } + + public function getContent() : MovieClip + { + return _content; + } + + public function getCreatedTs() : Number + { + return _createdTs; + } + + public function colorMyItem(param1:int, param2:MovieClip, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int) : void + { + if(_content) + { + _content.colorMe(param1,param2,param3,param4,param5,param6,param7,param8); + } + } + + public function updateAllBits(param1:uint, param2:uint, param3:uint) : void + { + if(_content) + { + _lBits = param1; + _uBits = param2; + _eBits = param3; + PetManager.setPetState(_content,_lBits,_uBits,_eBits); + } + } + + public function updateUBits(param1:uint) : void + { + _uBits = param1; + PetManager.setPetState(_content,_lBits,_uBits,_eBits); + } + + public function animatePet(param1:Boolean) : void + { + if(_content && "willItAnimate" in _content.pet) + { + _content.pet.willItAnimate(param1); + } + } + + protected function setSparkle(param1:int) : void + { + if(_content) + { + _content.pet.setSparkle(param1); + } + } + + private function onMediaLoaded(param1:MovieClip) : void + { + var _loc2_:int = 0; + if(param1) + { + _content = param1; + this.addChild(_content); + _mediaHelper.destroy(); + delete _content.mediaHelper; + delete _content.passback; + PetManager.setPetState(_content,_lBits,_uBits,_eBits); + if(_onPetLoadedCallback != null) + { + _onPetLoadedCallback(_content); + } + _content.pet.setAnim(0); + if(_petDef.isEgg) + { + if(_content.pet.hasOwnProperty("setEggDayInt")) + { + _loc2_ = _createdTs > 0 ? Math.floor((Utility.getInitialEpochTime() - _createdTs) / 86400) : 0; + _content.pet.setEggDayInt(_loc2_); + } + } + } + } + + private function mediaIdForDefId(param1:int) : int + { + var _loc2_:PetDef = PetManager.getPetDef(param1); + if(_loc2_) + { + return _loc2_.mediaRefId; + } + return -1; + } + + public function get personalityDefId() : uint + { + return _traitDefId; + } + + public function set personalityDefId(param1:uint) : void + { + _traitDefId = param1; + } + + public function get favoriteToyDefId() : uint + { + return _toyDefId; + } + + public function set favoriteToyDefId(param1:uint) : void + { + _toyDefId = param1; + } + + public function get favoriteFoodDefId() : uint + { + return _foodDefId; + } + + public function set favoriteFoodDefId(param1:uint) : void + { + _foodDefId = param1; + } + } +} + diff --git a/swf-src/PetManager.as b/swf-src/PetManager.as new file mode 100644 index 0000000..a60bca8 --- /dev/null +++ b/swf-src/PetManager.as @@ -0,0 +1,1489 @@ +package pet +{ + import Party.PartyManager; + import avatar.AvatarInfo; + import avatar.AvatarManager; + import avatar.AvatarWorldView; + import avatar.UserCommXtCommManager; + import avatar.UserInfo; + import collection.PetItemCollection; + import com.sbi.bit.ScalableBitField; + import com.sbi.debug.DebugUtility; + import com.sbi.popup.SBOkPopup; + import currency.UserCurrency; + import den.DenXtCommManager; + import diamond.DiamondXtCommManager; + import flash.display.MovieClip; + import flash.display.Sprite; + import gui.DarkenManager; + import gui.GuiManager; + import gui.PetCreator; + import gui.PetMastery; + import inventory.Iitem; + import localization.LocalizationManager; + + public class PetManager + { + + public static const TYPE_LAND_LOW:int = 0; + + public static const TYPE_LAND_HIGH:int = 1; + + public static const TYPE_OCEAN_LOW:int = 2; + + public static const TYPE_OCEAN_HIGH:int = 3; + + public static const TYPE_AMPHIB_LOW:int = 4; + + public static const TYPE_AMPHIB_HIGH:int = 5; + + public static const LIMITED_TIME:int = 1; + + public static const MASTERY_ACHIV_MIN_COUNT:int = 100; + + private static const EVT_ICON_ID:int = 44; + + private static var _petDefs:Vector.; + + private static var _myPetList:Array; + + private static var _myActivePetInvId:int; + + private static var _petFinder:PetCreator; + + private static var _petMasteryMgr:PetMastery; + + private static var _petFinderCallback:Function; + + private static var _unlockedPets:ScalableBitField; + + public function PetManager() + { + super(); + } + + public static function init() : void + { + _myPetList = []; + } + + public static function set petDefs(param1:Vector.) : void + { + _petDefs = param1; + } + + public static function relocalizePetDefs() : void + { + for each(var _loc1_:PetDef in _petDefs) + { + if(_loc1_) + { + _loc1_.title = LocalizationManager.translateIdOnly(_loc1_.titleStrId); + } + } + } + + public static function openPetFinder(param1:String = "", param2:Function = null, param3:Boolean = false, param4:Array = null, param5:Iitem = null, param6:int = 0, param7:int = 0, param8:Boolean = false) : void + { + if(_petFinder) + { + _petFinder.destroy(); + _petFinder = null; + } + _petFinder = new PetCreator(); + _petFinderCallback = param2; + if(param1 == "") + { + _petFinder.init(-1,onPetFinderClose,false,null,param6,null,param7); + } + else + { + _petFinder.init(petDefIdForName(param1),onPetFinderClose,param3,param4,param6,param5,param7,param8); + } + } + + private static function onPetFinderClose(param1:Boolean) : void + { + var _loc2_:Function = null; + if(_petFinder) + { + _petFinder.destroy(); + _petFinder = null; + } + if(_petFinderCallback != null) + { + _loc2_ = _petFinderCallback; + _petFinderCallback = null; + if(_loc2_.length == 1) + { + _loc2_(param1); + } + else + { + _loc2_(); + } + } + } + + public static function checkAndOpenMasteryPopup(param1:Boolean) : void + { + if(myActivePet && myActivePet.masteryCounter >= 100 && param1) + { + if(!_petMasteryMgr) + { + _petMasteryMgr = new PetMastery(); + _petMasteryMgr.init(); + } + _petMasteryMgr.displayMasteryPopup(); + } + } + + public static function hasAtLeastOneHatchedEggPet() : Boolean + { + var _loc1_:PetDef = null; + var _loc2_:int = 0; + _loc2_ = 0; + while(_loc2_ < _myPetList.length) + { + _loc1_ = getPetDef(_myPetList[_loc2_].defId); + if(_loc1_) + { + if(_loc1_.isEgg && hasHatched(_myPetList[_loc2_].createdTs) && _myPetList[_loc2_].name == "") + { + return true; + } + } + _loc2_++; + } + return false; + } + + public static function showPetHatchedPopups() : void + { + var _loc2_:PetDef = null; + var _loc3_:int = 0; + var _loc1_:Array = []; + _loc3_ = 0; + while(_loc3_ < _myPetList.length) + { + _loc2_ = getPetDef(_myPetList[_loc3_].defId); + if(_loc2_) + { + if(_loc2_.isEgg && hasHatched(_myPetList[_loc3_].createdTs) && _myPetList[_loc3_].name == "") + { + _loc1_.push(_loc3_); + } + } + _loc3_++; + } + if(_loc1_.length > 0) + { + EggPetGuiManager.openEggHatchedPopup(_loc1_); + } + } + + public static function onPetListResponse(param1:Array, param2:Function) : void + { + var _loc9_:Array = null; + var _loc7_:String = null; + var _loc3_:int = 0; + var _loc4_:Object = null; + var _loc8_:int = 0; + var _loc5_:int = 0; + var _loc6_:int = 2; + var _loc10_:String = param1[_loc6_++]; + if(_loc10_ == "1") + { + _loc7_ = param1[_loc6_++]; + _loc3_ = int(param1[_loc6_++]); + _loc9_ = []; + _loc8_ = -1; + _loc5_ = 0; + while(_loc5_ < _loc3_) + { + _loc4_ = { + "idx":int(param1[_loc6_++]), + "createdTs":Number(param1[_loc6_++]), + "name":param1[_loc6_++], + "lBits":uint(param1[_loc6_++]), + "uBits":uint(param1[_loc6_++]), + "eBits":uint(param1[_loc6_++]), + "masteryCounter":uint(param1[_loc6_++]), + "isSparkling":false, + "personalityDefId":uint(param1[_loc6_++]), + "favoriteToyDefId":uint(param1[_loc6_++]), + "favoriteFoodDefId":uint(param1[_loc6_++]), + "denStoreInvId":int(param1[_loc6_++]) + }; + _loc4_.defId = getDefIdFromLBits(_loc4_.lBits); + _loc4_.type = petTypeForDefId(_loc4_.defId); + _loc4_.currPetDef = PetManager.getPetDef(_loc4_.lBits & 0xFF); + _loc4_.isGround = _loc4_.currPetDef.isGround; + _loc9_.push(_loc4_); + _loc5_++; + } + _loc9_.sortOn("idx",16); + if(_loc7_.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase()) + { + _myPetList = _loc9_; + } + } + if(param2 != null) + { + param2(_loc9_,_loc10_); + } + } + + public static function isGround(param1:int) : Boolean + { + return param1 == 0 || param1 == 2 || param1 == 4; + } + + public static function onPetCreateResponse(param1:Array, param2:Function) : void + { + var _loc7_:int = 0; + var _loc3_:int = 0; + var _loc8_:* = undefined; + var _loc17_:int = 0; + var _loc4_:* = 0; + var _loc10_:* = 0; + var _loc5_:* = 0; + var _loc13_:String = null; + var _loc11_:Number = NaN; + var _loc15_:* = 0; + var _loc6_:* = 0; + var _loc12_:* = 0; + var _loc16_:Boolean = false; + var _loc14_:int = 0; + var _loc9_:int = 2; + if(param1[_loc9_++] == "1") + { + _loc7_ = int(param1[_loc9_++]); + _loc3_ = int(param1[_loc9_++]); + _loc8_ = UserCurrency.getCurrency(_loc3_); + if(_loc8_ == null) + { + throw new Error("ItemManager: Received unknown currencyType: " + _loc3_); + } + UserCurrency.setCurrency(_loc7_,_loc3_); + if(_loc8_ != _loc7_) + { + AJAudio.playShopCachingSound(); + } + _loc17_ = int(param1[_loc9_++]); + _loc4_ = uint(param1[_loc9_++]); + _loc10_ = uint(param1[_loc9_++]); + _loc5_ = uint(param1[_loc9_++]); + _loc13_ = param1[_loc9_++]; + _loc11_ = Number(param1[_loc9_++]); + _loc15_ = uint(param1[_loc9_++]); + _loc6_ = uint(param1[_loc9_++]); + _loc12_ = uint(param1[_loc9_++]); + _loc16_ = param1[_loc9_++] == "1"; + _loc14_ = getDefIdFromLBits(_loc4_); + if(insertPet(_loc14_,_loc11_,_loc4_,_loc10_,_loc5_,_loc13_,_loc17_,_loc15_,_loc6_,_loc12_,_loc16_)) + { + if(param2 != null) + { + param2(true); + } + // an egg hatches at once on this server, and waits for its + // name: the hatch window only came at the next login, and + // the egg was no use till then + if(hasAtLeastOneHatchedEggPet()) + { + showPetHatchedPopups(); + } + } + } + else + { + DarkenManager.showLoadingSpiral(false); + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14809)); + if(param2 != null) + { + param2(false); + } + } + } + + public static function insertPet(param1:int, param2:Number, param3:int, param4:int, param5:int, param6:String, param7:int, param8:int, param9:int, param10:int, param11:Boolean, param12:int = 0) : Boolean + { + var _loc14_:PetItem = null; + var _loc13_:PetDef = getPetDef(param1); + if(_loc13_) + { + _loc14_ = new PetItem(); + _loc14_.init(param2,param1,[param3,param4,param5],param8,param9,param10,param7,param6); + return insertPetItem(_loc14_,param11,param12); + } + return false; + } + + public static function insertPetItem(param1:PetItem, param2:Boolean, param3:int) : Boolean + { + var _loc4_:Array = null; + var _loc6_:Object = null; + var _loc5_:PetDef = param1.currPetDef; + if(_loc5_) + { + _loc4_ = param1.petBits; + _loc6_ = { + "idx":param1.invIdx, + "name":param1.name, + "defId":param1.defId, + "type":_loc5_.type, + "lBits":_loc4_[0], + "uBits":_loc4_[1], + "eBits":_loc4_[2], + "isSparkling":false, + "personalityDefId":param1.traitDefId, + "favoriteToyDefId":param1.toyDefId, + "favoriteFoodDefId":param1.foodDefId, + "createdTs":param1.createdTs, + "denStoreInvId":0, + "masteryCounter":param3 + }; + _loc6_.masteryCounter = param3; + _loc6_.currPetDef = _loc5_; + _myPetList.push(_loc6_); + DenXtCommManager.addPetToDen(param1); + if(param2) + { + if(PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,_loc5_,param1.createdTs)) + { + if(!_loc5_.isMember || Boolean(gMainFrame.userInfo.isMember)) + { + AvatarManager.playerAvatarWorldView.setActivePet(param1.createdTs,_loc4_[0],_loc4_[1],_loc4_[2],param1.name,param1.traitDefId,param1.toyDefId,param1.foodDefId); + myActivePetInvId = param1.invIdx; + } + } + AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0); + } + return true; + } + return false; + } + + public static function onPetSwitchResponse(param1:Array, param2:Function) : void + { + var _loc3_:AvatarWorldView = null; + var _loc19_:int = 0; + var _loc11_:Boolean = false; + var _loc16_:* = null; + var _loc20_:UserInfo = null; + var _loc12_:Object = null; + var _loc4_:int = 0; + var _loc13_:int = 0; + var _loc6_:int = 0; + var _loc17_:String = null; + var _loc14_:Number = NaN; + var _loc18_:* = 0; + var _loc15_:* = 0; + var _loc7_:* = 0; + var _loc8_:Object = null; + var _loc9_:AvatarInfo = null; + var _loc10_:int = 2; + var _loc21_:Boolean = param1[_loc10_++] == "1"; + if(_loc21_) + { + _loc19_ = int(param1[_loc10_++]); + _loc3_ = AvatarManager.getAvatarWorldViewBySfsUserId(_loc19_); + if(_loc19_ == gMainFrame.server.userId) + { + myActivePetInvId = int(param1[_loc10_++]); + if(_loc3_) + { + if(myActivePetInvId != 0) + { + for each(_loc16_ in _myPetList) + { + if(_loc16_.idx == myActivePetInvId) + { + _loc3_.setActivePet(_loc16_.createdTs,_loc16_.lBits,_loc16_.uBits,_loc16_.eBits,_loc16_.name,_loc16_.personalityDefId,_loc16_.favoriteFoodDefId,_loc16_.favoriteToyDefId); + _loc11_ = true; + break; + } + } + } + else + { + _loc3_.setActivePet(0,0,0,0,"",0,0,0); + } + _loc20_ = gMainFrame.userInfo.getUserInfoByUserName(_loc3_.userName); + for each(var _loc5_:AvatarInfo in _loc20_.avList) + { + if(_loc5_.perUserAvId == _loc3_.perUserAvId) + { + if(AvatarManager.roomEnviroType == 0) + { + _loc5_.landPetInvId = myActivePetInvId; + } + else + { + _loc5_.oceanPetInvId = myActivePetInvId; + } + gMainFrame.userInfo.setUserInfoByUserName(_loc3_.userName,_loc20_); + break; + } + } + AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0); + _loc12_ = myActivePet; + if(_loc12_) + { + _loc3_.setActivePet(_loc12_.createdTs,_loc12_.lBits,_loc12_.uBits,_loc12_.eBits,_loc12_.name,_loc12_.personalityDefId,_loc12_.favoriteFoodDefId,_loc12_.favoriteToyDefId); + _loc12_.isSparkling = false; + } + } + } + else + { + _loc4_ = int(param1[_loc10_++]); + _loc13_ = int(param1[_loc10_++]); + _loc6_ = int(param1[_loc10_++]); + _loc17_ = param1[_loc10_++]; + _loc14_ = Number(param1[_loc10_++]); + _loc18_ = uint(param1[_loc10_++]); + _loc15_ = uint(param1[_loc10_++]); + _loc7_ = uint(param1[_loc10_++]); + if(_loc3_) + { + _loc3_.setActivePet(_loc14_,_loc4_,_loc13_,_loc13_,_loc17_,_loc18_,_loc15_,_loc7_); + } + _loc8_ = null; + if(_loc4_ != 0) + { + _loc8_ = { + "name":_loc17_, + "lBits":_loc4_, + "uBits":_loc13_, + "eBits":_loc6_, + "createdTs":_loc14_, + "personalityDefId":_loc18_, + "favoriteFoodDefId":_loc15_, + "favoriteToyDefId":_loc7_ + }; + _loc8_.defId = PetManager.getDefIdFromLBits(_loc8_.lBits); + _loc8_.type = PetManager.petTypeForDefId(_loc8_.defId); + _loc8_.isGround = PetManager.isGround(_loc8_.type); + } + _loc9_ = gMainFrame.userInfo.getAvatarInfoByUserName(_loc3_.userName); + if(_loc9_) + { + _loc9_.currPet = _loc8_; + } + } + } + else + { + DarkenManager.showLoadingSpiral(false); + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14810)); + } + if(param2 != null) + { + param2(_loc21_); + } + } + + public static function onPetItemsResponse(param1:Array, param2:Function) : void + { + var _loc5_:Object = null; + var _loc7_:int = 0; + var _loc4_:int = 0; + var _loc9_:int = 0; + var _loc6_:int = 0; + var _loc3_:int = 0; + var _loc8_:int = 2; + var _loc10_:Boolean = param1[_loc8_++] == "1"; + if(_loc10_) + { + UserCurrency.setCurrency(int(param1[_loc8_++]),0); + AJAudio.playShopCachingSound(); + _loc5_ = myActivePet; + if(_loc5_ == null) + { + trace("ERROR: myActivePet is null"); + return; + } + _loc7_ = int(param1[_loc8_++]); + if(myActivePet.idx != _loc7_) + { + trace("ERROR: Invalid pet invId"); + return; + } + _loc4_ = int(param1[_loc8_++]); + _loc9_ = int(param1[_loc8_++]); + _loc6_ = int(param1[_loc8_++]); + _loc5_.lBits = _loc4_; + _loc5_.uBits = _loc9_; + _loc5_.eBits = _loc6_; + AvatarManager.playerAvatarWorldView.setActivePet(_loc5_.createdTs,_loc4_,_loc9_,_loc6_,myActivePetName,_loc5_.personalityDefId,_loc5_.favoriteFoodDefId,_loc5_.favoriteToyDefId); + myActivePetInvId = _loc7_; + _loc3_ = getDefIdFromLBits(_loc4_); + DenXtCommManager.reloadPetInDen(_loc7_,_loc5_.createdTs,petTypeForDefId(_loc3_),_loc5_.name,_loc4_,_loc9_,_loc6_,_loc5_.personalityDefId,_loc5_.favoriteFoodDefId,_loc5_.favoriteToyDefId); + } + if(param2 != null) + { + param2(_loc10_); + } + } + + public static function onPetMasteryResponse(param1:Array, param2:Function) : void + { + var _loc5_:int = 0; + var _loc6_:int = 0; + var _loc3_:int = 0; + var _loc8_:int = 0; + var _loc4_:int = 0; + var _loc7_:int = 2; + var _loc9_:Boolean = param1[_loc7_++] == "1"; + if(_loc9_) + { + _loc5_ = int(param1[_loc7_++]); + _loc6_ = 0; + while(_loc6_ < _myPetList.length) + { + if(_myPetList[_loc6_].idx == _loc5_) + { + _loc3_ = int(param1[_loc7_++]); + _loc8_ = int(param1[_loc7_++]); + _loc4_ = int(param1[_loc7_++]); + _myPetList[_loc6_].lBits = _loc3_; + _myPetList[_loc6_].uBits = _loc8_; + _myPetList[_loc6_].eBits = _loc4_; + DenXtCommManager.reloadPetInDen(_loc5_,_myPetList[_loc6_].createdTs,_myPetList[_loc6_].type,_myPetList[_loc6_].name,_loc3_,_loc8_,_loc4_,_myPetList[_loc6_].personalityDefId,_myPetList[_loc6_].favoriteFoodDefId,_myPetList[_loc6_].favoriteToyDefId); + break; + } + _loc6_++; + } + } + DarkenManager.showLoadingSpiral(false); + if(param2 != null) + { + param2(_loc9_); + } + } + + public static function onPetDismissResponse(param1:Array, param2:Function) : void + { + var _loc3_:Boolean = false; + var _loc4_:Boolean = false; + var _loc7_:Object = null; + var _loc6_:Boolean = param1[2] == "1"; + var _loc5_:int = int(param1[3]); + if(_loc6_) + { + _loc7_ = removePetInvIdx([_loc5_]); + _loc3_ = Boolean(_loc7_.isFound); + _loc4_ = Boolean(_loc7_.wasActivePet); + } + else + { + DarkenManager.showLoadingSpiral(false); + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14786)); + } + if(param2 != null) + { + param2(_loc6_,_loc3_,_loc4_); + } + } + + public static function onPetEggNameResponse(param1:Array, param2:Function) : void + { + var _loc6_:int = 0; + var _loc4_:Boolean = param1[2] == "1"; + var _loc5_:int = int(param1[3]); + var _loc3_:String = param1[4]; + _loc6_ = 0; + while(_loc6_ < _myPetList.length) + { + if(_myPetList[_loc6_].idx == _loc5_) + { + _myPetList[_loc6_].name = _loc3_; + if(myActivePetInvId == _loc5_) + { + AvatarManager.playerAvatarWorldView.setActivePet(_myPetList[_loc6_].createdTs,_myPetList[_loc6_].lBits,_myPetList[_loc6_].uBits,_myPetList[_loc6_].eBits,_loc3_,_myPetList[_loc6_].personalityDefId,_myPetList[_loc6_].favoriteFoodDefId,_myPetList[_loc6_].favoriteToyDefId); + } + DenXtCommManager.reloadPetInDen(_loc5_,_myPetList[_loc6_].createdTs,_myPetList[_loc6_].type,_myPetList[_loc6_].name,_myPetList[_loc6_].lBits,_myPetList[_loc6_].uBits,_myPetList[_loc6_].eBits,_myPetList[_loc6_].personalityDefId,_myPetList[_loc6_].favoriteFoodDefId,_myPetList[_loc6_].favoriteToyDefId); + break; + } + _loc6_++; + } + if(param2 != null) + { + param2(_loc4_); + } + else + { + DarkenManager.showLoadingSpiral(false); + } + } + + public static function removePetInvIdx(param1:Array) : Object + { + var _loc2_:Boolean = false; + var _loc6_:Boolean = false; + var _loc3_:PetItem = null; + var _loc7_:Object = null; + var _loc5_:int = 0; + var _loc4_:int = 0; + _loc5_ = 0; + while(_loc5_ < param1.length) + { + _loc4_ = 0; + while(_loc4_ < _myPetList.length) + { + if(_myPetList[_loc4_].idx == param1[_loc5_]) + { + _loc7_ = _myPetList[_loc4_]; + if(_myActivePetInvId == _loc7_.idx) + { + _myActivePetInvId = 0; + if(AvatarManager.playerAvatarWorldView) + { + AvatarManager.playerAvatarWorldView.setActivePet(0,0,0,0,"",0,0,0); + } + _loc6_ = true; + AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0); + } + _loc3_ = new PetItem(); + _loc3_.init(_loc7_.createdTs,_loc7_.defId,[_loc7_.lBits,_loc7_.uBits,_loc7_.eBits],_loc7_.personalityDefId,_loc7_.favoriteToyDefId,_loc7_.favoriteFoodDefId,_loc7_.idx,_loc7_.name,false,null,DiamondXtCommManager.getDiamondItem(DiamondXtCommManager.getDiamondDefIdByRefId(_loc7_.defId,2))); + DenXtCommManager.removePetFromDen(param1[_loc5_],_loc3_); + _myPetList.splice(_loc4_,1); + _loc2_ = true; + } + _loc4_++; + } + _loc5_++; + } + return { + "wasActivePet":_loc6_, + "isFound":_loc2_ + }; + } + + public static function getPetSprite(param1:Number, param2:uint, param3:uint, param4:uint, param5:int, param6:Function = null) : Sprite + { + return Sprite(new PetBase(param1,param2,param3,param4,0,0,0,param6)); + } + + public static function getGuiPet(param1:Number, param2:int, param3:uint, param4:uint, param5:uint, param6:int, param7:String, param8:int, param9:int, param10:int, param11:Function = null) : GuiPet + { + return new GuiPet(param1,param2,param3,param4,param5,param6,param7,param8,param10,param9,param11); + } + + public static function get myPetList() : Array + { + return _myPetList; + } + + public static function get myPetListAsIitem() : PetItemCollection + { + var _loc1_:PetItem = null; + var _loc2_:PetItemCollection = new PetItemCollection(); + for each(var _loc3_:Object in _myPetList) + { + _loc1_ = new PetItem(); + _loc1_.init(_loc3_.createdTs,_loc3_.defId,[_loc3_.lBits,_loc3_.uBits,_loc3_.eBits],_loc3_.personalityDefId,_loc3_.favoriteToyDefId,_loc3_.favoriteFoodDefId,_loc3_.idx,_loc3_.name,false,null,DiamondXtCommManager.getDiamondItem(DiamondXtCommManager.getDiamondDefIdByRefId(_loc3_.defId,2)),_loc3_.denStoreInvId); + _loc2_.pushPetItem(_loc1_); + } + return _loc2_; + } + + public static function get myActivePetName() : String + { + var _loc1_:Object = getMyPetByInvId(_myActivePetInvId); + if(_loc1_) + { + return _loc1_.name; + } + return ""; + } + + public static function set myActivePetInvId(param1:int) : void + { + _myActivePetInvId = param1; + } + + public static function addToActivePetMastery(param1:int) : void + { + myActivePet.masteryCounter += param1; + } + + public static function get myActivePetInvId() : int + { + return _myActivePetInvId; + } + + public static function getMyPetByInvId(param1:int) : Object + { + var _loc2_:* = null; + for each(_loc2_ in _myPetList) + { + if(_loc2_.idx == param1) + { + return _loc2_; + } + } + return null; + } + + public static function get myActivePet() : Object + { + var _loc1_:* = null; + for each(_loc1_ in _myPetList) + { + if(_loc1_.idx == _myActivePetInvId) + { + return _loc1_; + } + } + return null; + } + + // a Vector read past its end throws (#1125): a pet's bits naming a def + // past the last (a den item's version read as a pet's, say) stopped the + // pet, or the den item, from loading at all + public static function petTypeForDefId(param1:int) : int + { + if(_petDefs && param1 >= 0 && param1 < _petDefs.length && _petDefs[param1]) + { + return _petDefs[param1].type; + } + return -1; + } + + public static function getPetDef(param1:int) : PetDef + { + if(_petDefs && param1 >= 0 && param1 < _petDefs.length) + { + return _petDefs[param1]; + } + return null; + } + + public static function petForPetDefId(param1:int) : Object + { + var _loc2_:* = null; + for each(_loc2_ in _myPetList) + { + if(_loc2_.defId == param1) + { + return _loc2_; + } + } + return null; + } + + public static function getEnviroTypeByPetType(param1:PetDef, param2:Number, param3:int = 0) : int + { + if(param1.isEgg && !hasHatched(param2)) + { + return 0; + } + if(param1.type == 0) + { + return 0; + } + if(param1.type == 1) + { + return Utility.isAir(param3) ? 2 : 0; + } + if(param1.type == 3 || param1.type == 2) + { + return 1; + } + if(param1.type == 4 || param1.type == 5) + { + return AvatarManager.roomEnviroType; + } + return -1; + } + + public static function setPetState(param1:MovieClip, param2:uint, param3:uint, param4:uint) : void + { + var _loc5_:int = param2 & 0xFF; + DebugUtility.debugErrorTracking("setPetState with petMC=" + param1 + "lBits=" + param2 + "uBits=" + param3 + "eBits=" + param4 + "AvatarManager.roomEnviroType=" + AvatarManager.roomEnviroType); + if(PetManager.petTypeForDefId(_loc5_) == 4) + { + param1.pet.setState(param2,param3,param4,AvatarManager.roomEnviroType); + } + else + { + param1.pet.setState(param2,param3); + } + DebugUtility.clearDebugErrorTracking(); + } + + public static function petDefIdForName(param1:String) : int + { + switch(param1) + { + case "frog": + return 2; + case "kitten": + return 1; + case "puppy": + return 4; + case "ducky": + return 3; + case "butterfly": + return 5; + case "hamster": + return 6; + case "bat": + return 7; + case "seahorse": + return 8; + case "anglerfish": + return 9; + case "reindeer": + return 10; + case "snake": + return 11; + case "jellyfish": + return 12; + case "bunny": + return 13; + case "hummingbird": + return 14; + case "turtle": + return 15; + case "monkey": + return 16; + case "tarantula": + return 17; + case "fox": + return 18; + case "owl": + return 19; + case "tiger": + return 20; + case "arcticwolfpup": + return 21; + case "raccoon": + return 22; + case "joey": + return 23; + case "eaglet": + return 24; + case "cheetah": + return 25; + case "rhino": + return 26; + case "giraffe": + return 27; + case "sugarglider": + return 28; + case "lionCub": + return 29; + case "panda": + return 30; + case "polarbearcub": + return 31; + case "gecko": + return 32; + case "pony": + return 34; + case "piglet": + return 35; + case "ferret": + return 36; + case "elephant": + return 37; + case "armadillo": + return 38; + case "peacock": + return 39; + case "bee": + return 40; + case "skunk": + return 42; + case "turkey": + return 43; + case "penguin": + return 44; + case "snowLeopard": + return 45; + case "mantis": + return 46; + case "ladybug": + return 47; + case "cricket": + return 48; + case "squirrel": + return 49; + case "mouse": + return 50; + case "firefly": + return 51; + case "lemur": + return 52; + case "hippo": + return 53; + case "goat": + return 54; + case "meerkat": + return 55; + case "goldenbunny": + return 56; + case "phantom": + return 57; + case "seal": + return 58; + case "otter": + return 59; + case "rarephantom": + return 60; + case "groundhog": + return 61; + case "llama": + return 62; + case "arcticfox": + return 63; + case "rooster": + return 41; + case "hyena": + return 64; + case "chick": + return 67; + case "goldenarmadillo": + return 68; + case "falcon": + return 69; + case "crocodile": + return 70; + case "platypus": + return 71; + case "shark": + return 74; + case "dolphin": + return 75; + case "echidna": + return 76; + case "sloth": + return 65; + case "dove": + return 66; + case "koala": + return 77; + case "goldenpony": + return 73; + case "phantomJW": + return 72; + case "lynx": + return 80; + case "octopus": + return 81; + case "fennecfoxjw": + return 82; + case "hedgehog": + return 83; + case "scorpion": + return 84; + case "crow": + return 85; + case "moose": + return 86; + case "poodle": + return 87; + case "lovebunny": + return 88; + case "sabertooth": + return 89; + case "direwolf": + return 90; + case "dodo": + return 91; + case "fantasypeacock": + return 92; + case "millipede": + return 93; + case "moth": + return 94; + case "vulture": + return 95; + case "coyote": + return 96; + case "meagynsbear": + return 97; + case "falcon2": + return 98; + case "lovebug": + return 99; + case "flyingpig": + return 100; + case "sparrow": + return 101; + case "fennecfox": + return 102; + case "cardinal": + return 103; + case "frilledlizard": + return 104; + case "dragonfly": + return 105; + case "magentaseal": + return 106; + case "pangolin": + return 107; + case "camel": + return 108; + case "snail": + return 109; + case "galacticfirefly": + return 110; + case "caterpillar": + return 111; + case "lamb": + return 112; + case "goldenreindeer": + return 113; + case "highlandcow": + return 114; + case "nighthawk": + return 115; + case "frankenkitten": + return 116; + default: + return -1; + } + } + + public static function petNameForDefId(param1:int) : String + { + switch(param1) + { + case 2: + return "frog"; + case 1: + return "kitten"; + case 4: + return "puppy"; + case 3: + return "ducky"; + case 5: + return "butterfly"; + case 6: + return "hamster"; + case 7: + return "bat"; + case 8: + return "seahorse"; + case 9: + return "anglerfish"; + case 10: + return "reindeer"; + case 11: + return "snake"; + case 12: + return "jellyfish"; + case 13: + return "bunny"; + case 14: + return "hummingbird"; + case 15: + return "turtle"; + case 16: + return "monkey"; + case 17: + return "tarantula"; + case 18: + return "fox"; + case 19: + return "owl"; + case 20: + return "tiger"; + case 21: + return "arcticwolfpup"; + case 22: + return "raccoon"; + case 23: + return "joey"; + case 24: + return "eaglet"; + case 25: + return "cheetah"; + case 26: + return "rhino"; + case 27: + return "giraffe"; + case 28: + return "sugarglider"; + case 29: + return "lionCub"; + case 30: + return "panda"; + case 31: + return "polarbearcub"; + case 32: + return "gecko"; + case 34: + return "pony"; + case 35: + return "piglet"; + case 36: + return "ferret"; + case 37: + return "elephant"; + case 38: + return "armadillo"; + case 39: + return "peacock"; + case 40: + return "bee"; + case 42: + return "skunk"; + case 43: + return "turkey"; + case 44: + return "penguin"; + case 45: + return "snowLeopard"; + case 46: + return "mantis"; + case 47: + return "ladybug"; + case 48: + return "cricket"; + case 49: + return "squirrel"; + case 50: + return "mouse"; + case 51: + return "firefly"; + case 52: + return "lemur"; + case 53: + return "hippo"; + case 54: + return "goat"; + case 55: + return "meerkat"; + case 56: + return "goldenbunny"; + case 57: + return "phantom"; + case 58: + return "seal"; + case 59: + return "otter"; + case 60: + return "rarephantom"; + case 61: + return "groundhog"; + case 62: + return "llama"; + case 63: + return "arcticfox"; + case 41: + return "rooster"; + case 64: + return "hyena"; + case 67: + return "chick"; + case 68: + return "goldenarmadillo"; + case 69: + return "falcon"; + case 70: + return "crocodile"; + case 71: + return "platypus"; + case 74: + return "shark"; + case 75: + return "dolphin"; + case 76: + return "echidna"; + case 65: + return "sloth"; + case 66: + return "dove"; + case 77: + return "koala"; + case 73: + return "goldenpony"; + case 72: + return "phantomJW"; + case 80: + return "lynx"; + case 81: + return "octopus"; + case 82: + return "fennecfoxjw"; + case 83: + return "hedgehog"; + case 84: + return "scorpion"; + case 85: + return "crow"; + case 86: + return "moose"; + case 87: + return "poodle"; + case 88: + return "lovebunny"; + case 89: + return "sabertooth"; + case 90: + return "direwolf"; + case 91: + return "dodo"; + case 92: + return "fantasypeacock"; + case 93: + return "millipede"; + case 94: + return "moth"; + case 95: + return "vulture"; + case 96: + return "coyote"; + case 97: + return "meagynsbear"; + case 98: + return "falcon2"; + case 99: + return "lovebug"; + case 100: + return "flyingpig"; + case 101: + return "sparrow"; + case 102: + return "fennecfox"; + case 103: + return "cardinal"; + case 104: + return "frilledlizard"; + case 105: + return "dragonfly"; + case 106: + return "magentaseal"; + case 107: + return "pangolin"; + case 108: + return "camel"; + case 109: + return "snail"; + case 110: + return "galacticfirefly"; + case 111: + return "caterpillar"; + case 112: + return "lamb"; + case 113: + return "goldenreindeer"; + case 114: + return "highlandcow"; + case 115: + return "nighthawk"; + case 116: + return "frankenkitten"; + default: + return ""; + } + } + + public static function getDefIdFromLBits(param1:int) : int + { + return param1 & 0xFF; + } + + public static function sendPetSparkle(param1:int) : void + { + UserCommXtCommManager.sendPetAction(1,param1); + } + + public static function getPetInventoryMax() : Number + { + return Math.max(gMainFrame.userInfo.userVarCache.getUserVarValueById(338),1000); + } + + public static function set unlockedPets(param1:String) : void + { + if(param1 != null && param1.length > 0) + { + _unlockedPets = new ScalableBitField(param1); + } + } + + public static function isPetAvailable(param1:Number) : Boolean + { + return _unlockedPets.isBitSet(param1 - 1); + } + + public static function canCurrAvatarUsePet(param1:int, param2:PetDef, param3:Number) : Boolean + { + var _loc5_:Boolean = false; + var _loc4_:Object = null; + if(gMainFrame.clientInfo.roomType == 5) + { + _loc4_ = PartyManager.getPartyDef(gMainFrame.clientInfo.secondaryDefId); + if(_loc4_ != null) + { + if(_loc4_.restrictions == 4 || _loc4_.restrictions == 8) + { + _loc5_ = true; + } + } + } + return canBeUsedInEnviroType(param2,param3,AvatarManager.roomEnviroType) && (_loc5_ ? true : canBeUsedByEnviroTypeFlag(param2,param3,param1)); + } + + public static function hasHatched(param1:Number) : Boolean + { + return param1 + 259200 <= Utility.getInitialEpochTime(); + } + + public static function canPetGoInBothEnviroTypes(param1:PetDef, param2:Number) : Boolean + { + if(param1.isEgg && !hasHatched(param2)) + { + return false; + } + if(param1.type == 4 || param1.type == 5) + { + return true; + } + return false; + } + + private static function canBeUsedInEnviroType(param1:PetDef, param2:Number, param3:int) : Boolean + { + if(param1.isEgg && !hasHatched(param2)) + { + return param3 == 0; + } + if(param1.type == 0 || param1.type == 1) + { + return param3 == 0; + } + if(param1.type == 2 || param1.type == 3) + { + return param3 == 1; + } + if(param1.type == 4 || param1.type == 5) + { + return param3 == 0 || param3 == 1; + } + return false; + } + + private static function canBeUsedByEnviroTypeFlag(param1:PetDef, param2:Number, param3:int) : Boolean + { + if(param1.isEgg && !hasHatched(param2)) + { + return !Utility.isAir(param3) && Utility.isLand(param3); + } + if(param1.type == 0) + { + return !Utility.isAir(param3) && Utility.isLand(param3); + } + if(param1.type == 1) + { + return Utility.isAir(param3) || Utility.isLand(param3); + } + if(param1.type == 2 || param1.type == 3) + { + return Utility.isOcean(param3); + } + if(param1.type == 4) + { + return !Utility.isAir(param3) && (Utility.isLand(param3) || Utility.isOcean(param3)); + } + if(param1.type == 5) + { + return Utility.isLand(param3) || Utility.isOcean(param3); + } + return false; + } + + public static function canPetGoInEnviroType(param1:PetDef, param2:Number, param3:int) : Boolean + { + var _loc4_:int = 0; + if(param1.isEgg && !hasHatched(param2)) + { + _loc4_ = 0; + } + else + { + _loc4_ = getEnviroTypeByPetType(param1,param2,param3); + } + if(Utility.isSameEnviroType(param3,_loc4_)) + { + return true; + } + return false; + } + + public static function checkIfHasPet(param1:int) : Boolean + { + var _loc4_:* = null; + var _loc2_:int = 0; + var _loc3_:PetDef = null; + for each(_loc4_ in _myPetList) + { + _loc3_ = getPetDef(_loc4_.defId); + if(_loc3_) + { + _loc2_ = getEnviroTypeByPetType(_loc3_,_loc4_.createdTs,param1); + if(_loc2_ == 0) + { + if(Utility.isSameEnviroType(param1,_loc2_) && !Utility.isAir(param1)) + { + return true; + } + } + else if(Utility.isSameEnviroType(param1,_loc2_)) + { + return true; + } + } + } + return false; + } + + public static function createRandomPet(param1:int) : Array + { + var _loc6_:int = Math.random() * 19; + var _loc4_:int = Math.random() * 19; + var _loc5_:int = 0; + var _loc2_:int = Math.random() * 5; + var _loc3_:int = Math.random() * 3; + var _loc8_:int = Math.random() * 3; + var _loc9_:int = Math.random() * 3; + var _loc7_:int = 0; + return [param1,_loc6_,_loc4_,_loc5_,_loc2_,_loc3_,_loc8_,_loc9_,_loc7_,0,0,0,0,0,0]; + } + + public static function packPetBits(param1:Array) : Array + { + var _loc2_:uint = uint(param1[5] << 28 | param1[4] << 24 | param1[3] << 19 | param1[2] << 14 | param1[1] << 8 | param1[0]); + var _loc4_:uint = uint(param1[11] << 20 | param1[10] << 16 | param1[9] << 12 | param1[8] << 8 | param1[7] << 4 | param1[6]); + var _loc3_:uint = 0; + return [_loc2_,_loc4_,_loc3_]; + } + + public static function unpackPetBits(param1:uint, param2:uint, param3:uint) : Array + { + var _loc9_:int = param1 & 0xFF; + var _loc15_:int = param1 >> 8 & 0x3F; + var _loc12_:int = param1 >> 14 & 0x1F; + var _loc13_:int = param1 >> 19 & 0x1F; + var _loc10_:int = param1 >> 24 & 0x0F; + var _loc11_:int = param1 >> 28 & 0x0F; + var _loc7_:int = param2 & 0x0F; + var _loc8_:int = param2 >> 4 & 0x0F; + var _loc5_:int = param2 >> 8 & 0x0F; + var _loc6_:int = param2 >> 12 & 0x0F; + var _loc16_:int = param2 >> 16 & 0x0F; + var _loc17_:int = param2 >> 20 & 0x0F; + var _loc18_:int = param3 & 0x0F; + var _loc14_:int = param3 >> 4 & 0x0F; + var _loc4_:int = param3 >> 8 & 0x0F; + return [_loc9_,_loc15_,_loc12_,_loc13_,_loc10_,_loc11_,_loc7_,_loc8_,_loc5_,_loc6_,_loc16_,_loc17_,_loc18_,_loc14_,_loc4_]; + } + } +} + diff --git a/swf-src/PhantomsTreasure.as b/swf-src/PhantomsTreasure.as new file mode 100644 index 0000000..bbe7aab --- /dev/null +++ b/swf-src/PhantomsTreasure.as @@ -0,0 +1,1120 @@ +package game.phantomsTreasure +{ + import achievement.AchievementManager; + import achievement.AchievementXtCommManager; + import com.sbi.corelib.audio.SBMusic; + import flash.display.BitmapData; + import flash.display.Loader; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.KeyboardEvent; + import flash.events.MouseEvent; + import flash.geom.Point; + import flash.media.SoundChannel; + import flash.utils.getTimer; + import game.GameBase; + import game.IMinigame; + import game.MinigameManager; + import game.SoundManager; + import gskinner.motion.GTween; + import loader.MediaHelper; + import localization.LocalizationManager; + + public class PhantomsTreasure extends GameBase implements IMinigame + { + + private static const POPUP_X:int = 450; + + private static const POPUP_Y:int = 275; + + private static const HINT_STAGE1_RADIUS:Number = 150; + + private static const HINT_STAGE2_RADIUS:Number = 35; + + private static const HINT_STAGE2_TWEENTIME:Number = 3.5; + + private static const HINT_STAGE1_PAUSETIME:Number = 15; + + private static const MISS_PENALTY:Number = 20; + + private static const MISS_CLICK_DELAY_PENALTY:Number = 0.5; + + private static const PT_ACHIEVEMENTID_GAMECOUNT:int = 281; + + private static const PT_ACHIEVEMENTID_ITEMCOUNT:int = 282; + + private static const PT_ACHIEVEMENTID_LEVELBEST_TIME:int = 283; + + private static const PT_ACHIEVEMENT_LEVELBEST_TIME:int = 60; + + private static const MAX_HINT_COUNT:int = 3; + + private static const POINTS_PER_HINT_REMAINING:int = 300; + + private var _background:Sprite; + + private var _foreground:Sprite; + + private var _levelScore:int; + + private var _gemsEarned:int; + + private var _allGemsEarned:int; + + private var _timeSinceLastFind:Number; + + private var _lastTime:int; + + private var _totalGameTime:Number; + + private var _totalLevelTime:Number; + + private var _levelComplete:Boolean; + + private var _ui:Object; + + private var _hintOverlay:Object; + + private var _hintButton:MovieClip; + + private var _hintCount:int; + + private var _hintActive:Boolean; + + private var _hintTimer:Number; + + private var _hintCenterX:Number; + + private var _hintCenterY:Number; + + public var _displayAchievementTimer:Number; + + private var _hiddenObjects:Array; + + private var _previewObjects:Array; + + private var _levelBackground:Object; + + private var _missObjects:Array; + + private var _clickPenaltyTimer:Number; + + public var _soundMan:SoundManager; + + public var _factsOrder:Array; + + public var _factsIndex:int; + + private var _mediaObjectHelper:MediaHelper; + + private var _loadingImage:Boolean; + + private var _greatJobPopup:MovieClip; + + private var _factImageMediaObject:MovieClip; + + public var _levelProgression:Array; + + public var _currentStage:int; + + public var _backgroundIndex:int; + + public var _currentLevel:int; + + public var _itemsRemaining:int; + + public var _theRipples:Array; + + private var _bInit:Boolean; + + public var _SFX_Music:SBMusic; + + public var _musicLoop:SoundChannel; + + private var _soundNameNewRound:String; + + private var _soundNameCorrect:String; + + private var _soundNameIncorrect:String; + + private var _soundNamePopup:String; + + public var _data:PhantomsTreasureData; + + public function PhantomsTreasure() + { + super(); + _data = new PhantomsTreasureData(); + init(); + } + + public function start(param1:uint, param2:Array) : void + { + init(); + } + + private function init() : void + { + var _loc1_:int = 0; + _hintButton = null; + _displayAchievementTimer = 0; + _allGemsEarned = 0; + _theRipples = []; + _lastTime = getTimer(); + _factsOrder = []; + _loc1_ = 0; + while(_loc1_ < _data._facts.length) + { + _factsOrder.push(_loc1_); + _loc1_++; + } + _factsOrder = randomizeArray(_factsOrder); + _factsIndex = 0; + if(!_bInit) + { + _background = new Sprite(); + _foreground = new Sprite(); + _guiLayer = new Sprite(); + addChild(_background); + addChild(_foreground); + addChild(_guiLayer); + loadScene("PhantomsTreasure/room_main.xroom",_data._audio); + _mediaObjectHelper = null; + _loadingImage = false; + _greatJobPopup = null; + _factImageMediaObject = null; + _bInit = true; + } + } + + public function loadNextFactImage() : void + { + if(!_loadingImage) + { + _factsIndex = _factsIndex + 1; + if(_factsIndex >= _factsOrder.length) + { + _factsIndex = 0; + } + _loadingImage = true; + if(_mediaObjectHelper != null) + { + _mediaObjectHelper.destroy(); + } + _mediaObjectHelper = new MediaHelper(); + _mediaObjectHelper.init(_data._facts[_factsOrder[_factsIndex]].imageID,mediaObjectLoaded); + } + } + + private function mediaObjectLoaded(param1:MovieClip) : void + { + if(_factImageMediaObject != null && _greatJobPopup) + { + _factImageMediaObject.parent.removeChild(_factImageMediaObject); + } + param1.x = 0; + param1.y = 0; + _factImageMediaObject = param1; + if(_greatJobPopup) + { + _greatJobPopup.result_pic.addChild(_factImageMediaObject); + } + _loadingImage = false; + } + + private function loadSounds() : void + { + _SFX_Music = _soundMan.addStream("aj_mus_phantoms_treasure",0.6); + _soundNameNewRound = _data._audio[0]; + _soundNameCorrect = _data._audio[1]; + _soundNameIncorrect = _data._audio[2]; + _soundNamePopup = _data._audio[3]; + _soundMan.addSoundByName(_audioByName[_soundNameNewRound],_soundNameNewRound,0.96); + _soundMan.addSoundByName(_audioByName[_soundNameCorrect],_soundNameCorrect,0.76); + _soundMan.addSoundByName(_audioByName[_soundNameIncorrect],_soundNameIncorrect,0.86); + _soundMan.addSoundByName(_audioByName[_soundNamePopup],_soundNamePopup,1); + } + + public function message(param1:Array) : void + { + } + + public function end(param1:Array) : void + { + exit(); + } + + private function exit() : void + { + cleanUpLevel(); + releaseBase(); + if(_musicLoop) + { + _musicLoop.stop(); + _musicLoop = null; + } + if(_musicLoop) + { + _musicLoop.stop(); + _musicLoop = null; + } + stage.removeEventListener("keyDown",showGreatJobKeyDown); + stage.removeEventListener("keyDown",showFactKeyDown); + stage.removeEventListener("keyDown",optionsKeyDown); + removeEventListener("enterFrame",Heartbeat); + stage.removeEventListener("click",onMouseClick); + removeLayer(_background); + removeLayer(_foreground); + removeLayer(_guiLayer); + _background = null; + _foreground = null; + _guiLayer = null; + MinigameManager.leave(); + _bInit = false; + } + + public function randomizeArray(param1:Array) : Array + { + var _loc4_:int = 0; + var _loc2_:int = 0; + var _loc3_:int = 0; + var _loc5_:Number = param1.length - 1; + _loc4_ = 0; + while(_loc4_ < _loc5_) + { + _loc2_ = Math.round(Math.random() * _loc5_); + _loc3_ = int(param1[_loc4_]); + param1[_loc4_] = param1[_loc2_]; + param1[_loc2_] = _loc3_; + _loc4_++; + } + return param1; + } + + override protected function sceneLoaded(param1:Event) : void + { + var _loc2_:int = 0; + var _loc3_:Object = null; + _soundMan = new SoundManager(this); + loadSounds(); + _musicLoop = _soundMan.playStream(_SFX_Music,0,999999); + _ui = _scene.getLayer("ui"); + _ui.loader.x = 0; + _ui.loader.y = 0; + _guiLayer.addChild(_ui.loader); + _foreground.mouseEnabled = false; + _hintOverlay = _scene.getLayer("hint"); + _hintOverlay.loader.content.gotoAndPlay("off"); + _hintOverlay.loader.mouseEnabled = false; + _hintOverlay.loader.mouseChildren = false; + _foreground.addChild(_hintOverlay.loader); + addEventListener("enterFrame",Heartbeat); + stage.addEventListener("click",onMouseClick); + _loc3_ = _scene.getLayer("closeButton"); + _closeBtn = addBtn("CloseButton",847,5,onCloseBtn); + _hintButton = addBtn("chest",726,440,hintButtonPressed); + _totalGameTime = 0; + _levelProgression = []; + _currentStage = 0; + _currentLevel = -1; + super.sceneLoaded(param1); + showTitleScreen(); + } + + private function Heartbeat(param1:Event) : void + { + var _loc6_:int = 0; + var _loc8_:* = null; + var _loc4_:Number = NaN; + var _loc9_:Number = NaN; + var _loc7_:GTween = null; + var _loc5_:Number = (getTimer() - _lastTime) / 1000; + _lastTime = getTimer(); + _clickPenaltyTimer -= _loc5_; + if(_pauseGame) + { + _hintOverlay.loader.content.pauseGame(); + return; + } + _hintOverlay.loader.content.unpauseGame(); + _totalGameTime += _loc5_; + _timeSinceLastFind += _loc5_; + if(_levelComplete == false) + { + _totalLevelTime += _loc5_; + } + if(_totalLevelTime >= 15 && _totalLevelTime - _loc5_ < 15) + { + if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1) + { + AchievementXtCommManager.requestSetUserVar(281,1); + _displayAchievementTimer = 1; + } + } + var _loc3_:int = _totalLevelTime / 60; + var _loc2_:int = _totalLevelTime - _loc3_ * 60; + if(_loc3_ < 10) + { + _ui.loader.content.time.text = "0" + _loc3_ + ":"; + } + else + { + _ui.loader.content.time.text = _loc3_ + ":"; + } + if(_loc2_ < 10) + { + _ui.loader.content.time.text += "0" + _loc2_; + } + else + { + _ui.loader.content.time.text += _loc2_; + } + if(_hintActive) + { + if(_hintTimer > 0) + { + _hintTimer -= _loc5_; + if(_hintTimer <= 0) + { + _loc4_ = _hintCenterX - 35 + Math.random() * 35 * 2; + _loc9_ = _hintCenterY - 35 + Math.random() * 35 * 2; + if(_loc4_ < 50) + { + _loc4_ = 50; + } + if(_loc4_ > 850) + { + _loc4_ = 850; + } + if(_loc9_ < 50) + { + _loc9_ = 50; + } + if(_loc9_ > 400) + { + _loc9_ = 400; + } + _loc7_ = new GTween(_hintOverlay.loader,3.5,{ + "x":_loc4_, + "y":_loc9_ + }); + _hintOverlay.loader.content.gotoAndPlay("stage2"); + } + } + } + if(_missObjects) + { + _loc6_ = _missObjects.length - 1; + while(_loc6_ >= 0) + { + if(_missObjects[_loc6_].loader["content"] && _missObjects[_loc6_].loader["content"].finished) + { + removeMissObject(_loc6_); + } + _loc6_--; + } + } + if(_displayAchievementTimer > 0) + { + _displayAchievementTimer -= _loc5_; + if(_displayAchievementTimer <= 0) + { + _displayAchievementTimer = 0; + AchievementManager.displayNewAchievements(); + } + } + } + + private function onMouseClick(param1:MouseEvent) : void + { + } + + private function addRipple() : void + { + var _loc1_:PhantomsTreasureRipple = null; + var _loc2_:int = 0; + _loc2_ = 0; + while(_loc2_ < _theRipples.length) + { + if(_theRipples[_loc2_]._rippleComplete) + { + _theRipples[_loc2_].rippleIt(); + return; + } + _loc2_++; + } + _loc1_ = new PhantomsTreasureRipple(_background); + _loc1_.rippleIt(); + _theRipples.push(_loc1_); + } + + private function addMiss(param1:Number, param2:Number) : void + { + var _loc3_:Object = null; + _loc3_ = _scene.cloneAsset("missobject"); + _loc3_.loader.x = param1; + _loc3_.loader.y = param2; + _foreground.addChild(_loc3_.loader); + _loc3_.loader.contentLoaderInfo.addEventListener("complete",onMissComplete); + _missObjects.push(_loc3_); + _soundMan.playByName(_soundNameIncorrect); + } + + private function onBackgroundClick(param1:MouseEvent) : void + { + if(_clickPenaltyTimer <= 0 && !_pauseGame && _levelComplete == false) + { + addRipple(); + addMiss(param1.stageX,param1.stageY); + _clickPenaltyTimer = 0.5; + } + } + + public function onMissComplete(param1:Event) : void + { + var _loc2_:String = "-20"; + _totalLevelTime += 20; + param1.target.content.miss(_loc2_); + param1.target.removeEventListener("complete",onMissComplete); + } + + private function onHiddenObjectClick(param1:MouseEvent) : void + { + var _loc2_:Boolean = false; + var _loc3_:int = 0; + if(!_pauseGame && _clickPenaltyTimer <= 0) + { + _loc2_ = true; + _loc3_ = 0; + while(_loc3_ < _hiddenObjects.length) + { + if(param1.currentTarget == _hiddenObjects[_loc3_].loader) + { + if(testForMouseHit(_hiddenObjects[_loc3_],param1.localX,param1.localY)) + { + _soundMan.playByName(_soundNameCorrect); + if(_hintActive) + { + if(_hintCount < 3) + { + _hintButton.mouseEnabled = true; + _hintButton.mouseChildren = true; + } + _hintActive = false; + _hintOverlay.loader.content.gotoAndPlay("stage3"); + } + if(_timeSinceLastFind > 8) + { + _levelScore += 100; + } + else if(_timeSinceLastFind > 6) + { + _levelScore += 200; + } + else if(_timeSinceLastFind > 4) + { + _levelScore += 300; + } + else if(_timeSinceLastFind > 2) + { + _levelScore += 400; + } + else + { + _levelScore += 500; + } + _timeSinceLastFind = 0; + _hiddenObjects[_loc3_].loader["content"].correct(); + _previewObjects[_loc3_].loader["content"].correct(); + _itemsRemaining = _itemsRemaining - 1; + param1.currentTarget.removeEventListener("click",onHiddenObjectClick); + param1.currentTarget.mouseEnabled = false; + param1.currentTarget.content.mouseEnabled = false; + param1.currentTarget.mouseChildren = false; + param1.currentTarget.content.mouseChildren = false; + if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1) + { + AchievementXtCommManager.requestSetUserVar(282,1); + _displayAchievementTimer = 1; + } + if(!_levelComplete && _itemsRemaining == 0) + { + if(_totalLevelTime <= 60) + { + if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1) + { + AchievementXtCommManager.requestSetUserVar(283,1); + _displayAchievementTimer = 1; + } + } + _levelComplete = true; + if(_hintCount < 3) + { + _levelScore += 300 * (3 - _hintCount); + } + _gemsEarned = _levelScore / 100; + _allGemsEarned += _gemsEarned; + addGemsToBalance(_gemsEarned); + showFactPopup(); + } + } + else + { + addMiss(param1.stageX,param1.stageY); + } + break; + } + _loc3_++; + } + if(_loc2_) + { + addRipple(); + } + } + } + + // (as the decompiler gave it this had a goto, which does not compile: + // the same as onPreviewComplete below, with the object put in place) + public function onHiddenComplete(param1:Event) : void + { + var _loc3_:int = 0; + var _loc2_:String = null; + var _loc4_:Array = null; + _loc3_ = 0; + while(_loc3_ < _hiddenObjects.length) + { + if(param1.target.loader == _hiddenObjects[_loc3_].loader) + { + _loc2_ = _backgroundIndex + 1 + "_" + (_hiddenObjects[_loc3_].objectID + 1); + _loc4_ = _backgroundIndex == 0 ? _hiddenObjects[_loc3_].loader["content"].positions1 : (_backgroundIndex == 1 ? _hiddenObjects[_loc3_].loader["content"].positions2 : (_backgroundIndex == 2 ? _hiddenObjects[_loc3_].loader["content"].positions3 : null)); + if(_loc4_ != null) + { + Loader(_hiddenObjects[_loc3_].loader).x = _loc4_[_hiddenObjects[_loc3_].objectID][0]; + Loader(_hiddenObjects[_loc3_].loader).y = _loc4_[_hiddenObjects[_loc3_].objectID][1]; + } + _hiddenObjects[_loc3_].loader["content"].showObject(_loc2_); + break; + } + _loc3_++; + } + param1.target.removeEventListener("complete",onHiddenComplete); + } + + public function onPreviewComplete(param1:Event) : void + { + var _loc3_:int = 0; + var _loc2_:String = null; + _loc3_ = 0; + while(_loc3_ < _previewObjects.length) + { + if(param1.target.loader == _previewObjects[_loc3_].loader) + { + _loc2_ = _backgroundIndex + 1 + "_" + (_previewObjects[_loc3_].objectID + 1); + _previewObjects[_loc3_].loader["content"].showPreview(_loc2_); + break; + } + _loc3_++; + } + param1.target.removeEventListener("complete",onPreviewComplete); + } + + public function addObject(param1:int, param2:int) : void + { + var _loc4_:Object = null; + var _loc3_:Object = null; + _loc4_ = _scene.cloneAsset("hiddenobject"); + _loc4_.objectID = param1; + _loc3_ = _scene.cloneAsset("hiddenobject"); + _loc3_.objectID = param1; + _loc3_.loader.x = _ui.loader.content.previewPositions[param2][0]; + _loc3_.loader.y = _ui.loader.content.previewPositions[param2][1]; + _loc4_.loader.addEventListener("click",onHiddenObjectClick); + _background.addChild(_loc4_.loader); + _loc4_.loader.contentLoaderInfo.addEventListener("complete",onHiddenComplete); + _hiddenObjects.push(_loc4_); + _guiLayer.addChild(_loc3_.loader); + _loc3_.loader.contentLoaderInfo.addEventListener("complete",onPreviewComplete); + _previewObjects.push(_loc3_); + switch(param2) + { + case 0: + LocalizationManager.translateId(_ui.loader.content.object1,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 1: + LocalizationManager.translateId(_ui.loader.content.object2,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 2: + LocalizationManager.translateId(_ui.loader.content.object3,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 3: + LocalizationManager.translateId(_ui.loader.content.object4,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 4: + LocalizationManager.translateId(_ui.loader.content.object5,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 5: + LocalizationManager.translateId(_ui.loader.content.object6,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 6: + LocalizationManager.translateId(_ui.loader.content.object7,_data._itemNames[_backgroundIndex].items[param1]); + break; + case 7: + LocalizationManager.translateId(_ui.loader.content.object8,_data._itemNames[_backgroundIndex].items[param1]); + } + } + + private function setUpLevelProgression() : void + { + var _loc1_:int = 0; + var _loc2_:Array = []; + _loc1_ = 0; + while(_loc1_ < _data._levelProgression[_currentStage].items.length) + { + _loc2_.push(_loc1_); + _loc1_++; + } + do + { + _loc2_ = randomizeArray(_loc2_); + _loc2_ = randomizeArray(_loc2_); + } + while(_loc2_[0] == _levelProgression[_currentStage][0]); + _levelProgression[_currentStage] = _loc2_; + } + + private function setLevel(param1:int) : void + { + var _loc2_:int = 0; + _currentStage = param1; + _currentLevel = -1; + var _loc3_:Array = []; + _loc3_.push(-1); + _levelProgression[_currentStage] = _loc3_; + setUpLevelProgression(); + setNextLevel(); + } + + private function setNextLevel() : void + { + var _loc1_:int = 0; + if(_soundMan != null && _musicLoop == null) + { + _musicLoop = _soundMan.playStream(_SFX_Music,0,999999); + } + _soundMan.playByName(_soundNameNewRound); + _clickPenaltyTimer = 0; + _levelScore = 0; + _gemsEarned = 0; + _timeSinceLastFind = 0; + _currentLevel = _currentLevel + 1; + if(_currentLevel >= _levelProgression[_currentStage].length) + { + _currentLevel = 0; + setUpLevelProgression(); + } + _ui.loader.content.time.text = "0:00"; + _hintButton.resetHints(); + _hintCount = 0; + _hintButton.mouseEnabled = true; + _hintButton.mouseChildren = true; + _hintActive = false; + _hintOverlay.loader.content.gotoAndPlay("off"); + _totalLevelTime = 0; + _levelComplete = false; + cleanUpLevel(); + _missObjects = []; + _hiddenObjects = []; + _previewObjects = []; + switch(_data._levelProgression[_currentStage].background) + { + case 1: + _backgroundIndex = 0; + _levelBackground = _scene.getLayer("background1"); + break; + case 2: + _backgroundIndex = 1; + _levelBackground = _scene.getLayer("background2"); + break; + case 3: + _backgroundIndex = 2; + _levelBackground = _scene.getLayer("background3"); + } + _levelBackground.loader.x = 0; + _levelBackground.loader.y = 0; + _background.addChild(_levelBackground.loader); + _levelBackground.loader.addEventListener("click",onBackgroundClick); + var _loc2_:Array = []; + _loc1_ = 0; + while(_loc1_ < _data._levelProgression[_currentStage].items[_levelProgression[_currentStage][_currentLevel]].length) + { + _loc2_.push(_data._levelProgression[_currentStage].items[_levelProgression[_currentStage][_currentLevel]][_loc1_]); + _loc1_++; + } + _loc2_ = randomizeArray(_loc2_); + _loc2_ = randomizeArray(_loc2_); + _itemsRemaining = 0; + _loc1_ = 0; + while(_loc1_ < _loc2_.length) + { + addObject(_loc2_[_loc1_] - 1,_loc1_); + _itemsRemaining = _itemsRemaining + 1; + _loc1_++; + } + if(_factImageMediaObject && _greatJobPopup != null) + { + _factImageMediaObject.parent.removeChild(_factImageMediaObject); + _factImageMediaObject = null; + } + if(!_loadingImage) + { + loadNextFactImage(); + } + _greatJobPopup = null; + } + + private function endLevel() : void + { + } + + private function removeMissObject(param1:int) : void + { + if(Loader(_missObjects[param1].loader).parent) + { + Loader(_missObjects[param1].loader).parent.removeChild(_missObjects[param1].loader); + } + _scene.releaseCloneAsset(_missObjects[param1].loader); + _missObjects.splice(param1,1); + } + + private function cleanUpLevel() : void + { + if(_levelBackground) + { + if(_levelBackground.loader.parent) + { + _levelBackground.loader.parent.removeChild(_levelBackground.loader); + _levelBackground.loader.removeEventListener("click",onBackgroundClick); + _levelBackground = null; + } + } + if(_hiddenObjects) + { + while(_hiddenObjects.length > 0) + { + if(Loader(_hiddenObjects[0].loader).parent) + { + Loader(_hiddenObjects[0].loader).parent.removeChild(_hiddenObjects[0].loader); + } + Loader(_hiddenObjects[0].loader).removeEventListener("click",onHiddenObjectClick); + _scene.releaseCloneAsset(_hiddenObjects[0].loader); + _hiddenObjects.splice(0,1); + } + } + if(_previewObjects) + { + while(_previewObjects.length > 0) + { + if(Loader(_previewObjects[0].loader).parent) + { + Loader(_previewObjects[0].loader).parent.removeChild(_previewObjects[0].loader); + } + _scene.releaseCloneAsset(_previewObjects[0].loader); + _previewObjects.splice(0,1); + } + } + if(_missObjects) + { + while(_missObjects.length > 0) + { + removeMissObject(0); + } + } + } + + private function hintButtonPressed() : void + { + var _loc3_:int = 0; + var _loc2_:int = 0; + var _loc1_:int = 0; + if(!_pauseGame && _hintActive == false && _hintCount < 3) + { + _hintCount = _hintCount + 1; + _hintButton.hint(_hintCount); + _hintButton.mouseEnabled = false; + _hintButton.mouseChildren = false; + _loc2_ = 0; + _loc3_ = 0; + while(_loc3_ < _hiddenObjects.length) + { + if(!_hiddenObjects[_loc3_].loader["content"].collected) + { + _loc2_++; + } + _loc3_++; + } + if(_loc2_ > 0) + { + _loc1_ = Math.random() * _loc2_; + _loc3_ = 0; + while(_loc3_ < _hiddenObjects.length) + { + if(!_hiddenObjects[_loc3_].loader["content"].collected) + { + if(--_loc1_ < 0) + { + _hintCenterX = Loader(_hiddenObjects[_loc3_].loader).x + _hiddenObjects[_loc3_].loader["width"] / 2; + _hintCenterY = Loader(_hiddenObjects[_loc3_].loader).y + _hiddenObjects[_loc3_].loader["height"] / 2; + if(_hintCenterX < 50) + { + _hintCenterX = 50; + } + if(_hintCenterX > 850) + { + _hintCenterX = 850; + } + if(_hintCenterY < 50) + { + _hintCenterY = 50; + } + if(_hintCenterY > 400) + { + _hintCenterY = 400; + } + break; + } + } + _loc3_++; + } + } + _hintActive = true; + _hintTimer = 15; + _hintOverlay.loader.x = _hintCenterX - 150 + Math.random() * 150 * 2; + _hintOverlay.loader.y = _hintCenterY - 150 + Math.random() * 150 * 2; + _hintOverlay.loader.content.gotoAndPlay("stage1"); + } + } + + private function testForMouseHit(param1:Object, param2:Number, param3:Number) : Boolean + { + var _loc4_:BitmapData = new BitmapData(param1.loader.width,param1.loader.height,true,0); + _loc4_.draw(param1.loader.content); + return _loc4_.hitTest(new Point(0,0),1,new Point(param2,param3)); + } + + private function optionsKeyDown(param1:KeyboardEvent) : void + { + switch(param1.keyCode) + { + case 8: + case 46: + case 27: + onUnpause(); + } + } + + private function showOptions() : void + { + var _loc1_:MovieClip = showDlg("PhTr_Options",[{ + "name":"btn_unpauseGame", + "f":onUnpause + },{ + "name":"btn_levelSelect", + "f":onLevelSelect + },{ + "name":"btn_exitGame", + "f":showExitConfirmationDlg + }]); + _loc1_.x = 450; + _loc1_.y = 275; + stage.addEventListener("keyDown",optionsKeyDown); + } + + // the title screen and the level choice are dialogs, which hide the + // close button, and neither has a way out: nobody could leave before + // playing a level. the button stays over them, and leaves at once. + private function keepCloseBtn() : void + { + if(_closeBtn) + { + _closeBtn.visible = true; + _guiLayer.setChildIndex(_closeBtn,_guiLayer.numChildren - 1); + } + } + + private function onCloseBtn() : void + { + if(_currentLevel < 0) + { + hideDlg(); + exit(); + } + else + { + showOptions(); + } + } + + private function onUnpause() : void + { + stage.removeEventListener("keyDown",optionsKeyDown); + hideDlg(); + } + + private function showExitConfirmationDlg() : void + { + var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{ + "name":"button_yes", + "f":onExit_Yes + },{ + "name":"button_no", + "f":onExit_No + }]); + _loc1_.x = 450; + _loc1_.y = 275; + } + + private function onExit_Yes() : void + { + hideDlg(); + if(showGemMultiplierDlg(onGemMultiplierDone) == null) + { + exit(); + } + } + + private function onGemMultiplierDone() : void + { + hideDlg(); + exit(); + } + + private function onExit_No() : void + { + hideDlg(); + showOptions(); + } + + private function showTitleScreen() : void + { + if(_soundMan != null && _musicLoop == null) + { + _musicLoop = _soundMan.playStream(_SFX_Music,0,999999); + } + var _loc1_:MovieClip = showDlg("PhTr_TitleScreen",[{ + "name":"btn_level1", + "f":showLevelSelect + }]); + _loc1_.x = 450; + _loc1_.y = 275; + keepCloseBtn(); + } + + private function showLevelSelect() : void + { + var _loc1_:MovieClip = showDlg("PhTr_LevelSelect",[{ + "name":"btn_level1", + "f":onLevelSelect1 + },{ + "name":"btn_level2", + "f":onLevelSelect2 + }]); + _loc1_.x = 450; + _loc1_.y = 275; + keepCloseBtn(); + } + + private function onLevelSelect1() : void + { + hideDlg(); + setLevel(0); + } + + private function onLevelSelect2() : void + { + hideDlg(); + setLevel(1); + } + + private function showFactKeyDown(param1:KeyboardEvent) : void + { + switch(param1.keyCode) + { + case 13: + case 32: + case 8: + case 46: + case 27: + showGreatJob(); + } + } + + private function showFactPopup() : void + { + var _loc1_:MovieClip = showDlg("PhTr_Result",[{ + "name":"continue_btn", + "f":showGreatJob + }]); + _loc1_.x = 450; + _loc1_.y = 275; + stage.addEventListener("keyDown",showFactKeyDown); + _greatJobPopup = _loc1_; + if(_factImageMediaObject) + { + _greatJobPopup.result_pic.addChild(_factImageMediaObject); + } + LocalizationManager.translateId(_loc1_.result_factCont.result_fact,_data._facts[_factsOrder[_factsIndex]].text); + _soundMan.playByName(_soundNamePopup); + } + + private function showGreatJobKeyDown(param1:KeyboardEvent) : void + { + switch(param1.keyCode) + { + case 13: + case 32: + onNextLevel(); + break; + case 8: + case 46: + case 27: + onLevelSelect(); + } + } + + private function showGreatJob() : void + { + stage.removeEventListener("keyDown",showFactKeyDown); + hideDlg(); + _greatJobPopup = null; + var _loc1_:MovieClip = showDlg("Great_Job_PhTr",[{ + "name":"button_levelSelect", + "f":onLevelSelect + },{ + "name":"button_nextlevel", + "f":onNextLevel + }]); + _loc1_.x = 450; + _loc1_.y = 275; + stage.addEventListener("keyDown",showGreatJobKeyDown); + LocalizationManager.translateIdAndInsert(_loc1_.text_time,11800,_ui.loader.content.time.text); + LocalizationManager.translateIdAndInsert(_loc1_.Gems_Earned,11554,_gemsEarned); + LocalizationManager.translateIdAndInsert(_loc1_.Gems_Total,11549,_allGemsEarned); + } + + private function onLevelSelect() : void + { + stage.removeEventListener("keyDown",showGreatJobKeyDown); + hideDlg(); + showLevelSelect(); + } + + private function onNextLevel() : void + { + stage.removeEventListener("keyDown",showGreatJobKeyDown); + hideDlg(); + setNextLevel(); + } + } +} + diff --git a/swf-src/TierPathPopup.as b/swf-src/TierPathPopup.as new file mode 100644 index 0000000..aef3401 --- /dev/null +++ b/swf-src/TierPathPopup.as @@ -0,0 +1,178 @@ +package adoptAPet +{ + import flash.display.MovieClip; + import flash.events.MouseEvent; + import gui.DarkenManager; + import gui.GuiManager; + import loader.MediaHelper; + + public class TierPathPopup + { + + private const POPUP_MEDIA_ID:int = 7208; + + private var _tierPopup:MovieClip; + + private var _mediaHelper:MediaHelper; + + private var _closeCallback:Function; + + public function TierPathPopup(param1:Function) + { + super(); + DarkenManager.showLoadingSpiral(true); + _closeCallback = param1; + _mediaHelper = new MediaHelper(); + _mediaHelper.init(7208,onPopupLoaded); + } + + public function destroy() : void + { + removeEventListeners(); + DarkenManager.unDarken(_tierPopup); + GuiManager.guiLayer.removeChild(_tierPopup); + _closeCallback = null; + _tierPopup = null; + } + + private function onPopupLoaded(param1:MovieClip) : void + { + DarkenManager.showLoadingSpiral(false); + _tierPopup = MovieClip(param1.getChildAt(0)); + _tierPopup.x = 900 / 2; + _tierPopup.y = 550 / 2; + // a fault laying out the path left the window unshown, its + // checklist waiting under it: it is shown either way now + try + { + setupPathAndDots(); + } + catch(e:Error) + { + GlobalErrorCatch.reportToServer("adopt a pet gift path: " + e + "\n" + e.getStackTrace()); + } + addEventListeners(); + GuiManager.guiLayer.addChild(_tierPopup); + DarkenManager.darken(_tierPopup); + } + + private function setupPathAndDots() : void + { + var _loc4_:int = 0; + var _loc3_:MovieClip = null; + var _loc8_:MovieClip = null; + var _loc1_:MovieClip = null; + var _loc7_:MovieClip = null; + var _loc10_:Boolean = false; + var _loc2_:Boolean = false; + var _loc5_:int = int(AdoptAPetManager.TIERED_GIFT_COUNTS[AdoptAPetManager.TIERED_GIFT_COUNTS.length - 1]); + var _loc9_:int = AdoptAPetManager.numTieredGiftCount; + var _loc6_:Boolean = false; + // frames count from 1: none adopted yet is the first + _tierPopup.pinkPath.gotoAndStop(Math.max(1,Math.min(_loc9_,_tierPopup.pinkPath.totalFrames))); + _loc4_ = 1; + while(_loc4_ <= _loc5_) + { + _loc3_ = _tierPopup["dot_" + _loc4_]; + _loc8_ = _tierPopup["threshold" + _loc4_]; + if(_loc4_ <= _loc9_) + { + _loc2_ = true; + } + if(_loc3_ != null) + { + _loc7_ = _loc3_; + if(_loc2_) + { + _loc10_ = false; + _loc2_ = false; + _loc1_ = _loc3_; + _loc3_.num.text = _loc4_; + _loc3_.star.visible = true; + if(_loc7_ != null) + { + _loc7_.num.visible = false; + if(_loc7_.num.text != "1") + { + _loc7_.star.visible = false; + } + else + { + _loc7_.star.visible = false; + } + } + } + else + { + _loc3_.num.visible = false; + _loc3_.star.visible = false; + } + } + else if(_loc8_ != null) + { + if(_loc4_ <= _loc9_) + { + _loc10_ = true; + _loc8_.gotoAndStop("open"); + } + else + { + if(!_loc6_) + { + _loc8_.gotoAndStop("next"); + _loc6_ = true; + } + else + { + _loc8_.gotoAndStop("future"); + } + _loc8_.numTxt.text = _loc4_; + } + } + else if(!_loc10_) + { + _loc2_ = false; + } + _loc4_++; + } + if(_loc1_ != null) + { + if(_loc10_) + { + _loc1_.num.visible = false; + _loc1_.star.visible = false; + } + else + { + _loc1_.num.visible = true; + _loc1_.star.visible = true; + _loc1_.num.text = _loc9_; + } + } + } + + private function addEventListeners() : void + { + _tierPopup.bx.addEventListener("mouseDown",onCloseBtn,false,0,true); + } + + private function removeEventListeners() : void + { + _tierPopup.bx.removeEventListener("mouseDown",onCloseBtn); + } + + private function onCloseBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_closeCallback != null) + { + _closeCallback(); + } + else + { + destroy(); + } + } + } +} + diff --git a/swf-src/TouchPool.as b/swf-src/TouchPool.as new file mode 100644 index 0000000..63d6bfe --- /dev/null +++ b/swf-src/TouchPool.as @@ -0,0 +1,1404 @@ +package game.touchPool +{ + import achievement.AchievementManager; + import achievement.AchievementXtCommManager; + import com.sbi.corelib.audio.SBMusic; + import den.DenItem; + import flash.display.BitmapData; + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.KeyboardEvent; + import flash.events.MouseEvent; + import flash.geom.ColorTransform; + import flash.geom.Matrix; + import flash.geom.Point; + import flash.geom.Rectangle; + import flash.media.SoundChannel; + import flash.ui.Mouse; + import flash.utils.getTimer; + import game.GameBase; + import game.IMinigame; + import game.MinigameManager; + import game.SoundManager; + import giftPopup.GiftPopup; + import loader.MediaHelper; + import localization.LocalizationManager; + + public class TouchPool extends GameBase implements IMinigame + { + + private static const POPUP_X:int = 450; + + private static const POPUP_Y:int = 275; + + public static const RIPPLE_TIME:int = 7; + + public var _background:Sprite; + + public var _layerStarUrchin:Sprite; + + public var _layerSeaslug:Sprite; + + public var _layerHermit:Sprite; + + public var _layerObstacles:Sprite; + + public var _layerSwimmers:Sprite; + + public var _layerGems:Sprite; + + private var _foreground:Sprite; + + private var _lastTime:int; + + private var _totalGameTime:Number; + + private var _ui:Object; + + public var _soundMan:SoundManager; + + private var _bInit:Boolean; + + private var _serialNumber:int; + + private var _prizeAwarded:int; + + public var _creatures:Array = []; + + public var _poolPoints:Array = []; + + private var _globalBox1:Point = new Point(); + + private var _globalBox2:Point = new Point(); + + private var _currentTouchTimer:Number = 0; + + private var _currentTouchTime:Number; + + private var _currentTouchingIndex:int; + + public var _ripple:Array = new Array(3); + + public var _currentRippleIndex:int; + + private var _rippleTimer:int; + + private var _prevPos:Point = new Point(); + + private var _log:Object; + + private var _logActive:Boolean; + + private var _logBitVar1:uint; + + private var _logBitVar2:uint; + + private var _logArray:Array; + + private var _logCreatureCount:Array = []; + + private var _factPopup:MovieClip; + + private var _factPopupActive:Boolean; + + private var _factData:TouchPoolData; + + private var _queueShowFact:Boolean; + + private var _currentFactID:int; + + private var _currentLogID:int; + + private var _mediaObjectHelper:MediaHelper = new MediaHelper(); + + public var _dustClouds:Array = []; + + private var _collectPopup:Object; + + private var _currentColor:int; + + private var _currentType:int; + + private var _gemsEarned:int; + + private var _gemsAwarded:int; + + private var _gemPool:Array; + + private var _gemsActive:Array; + + private var _minimap:Object; + + private var _minimapOffsetX:Number; + + private var _minimapOffsetY:Number; + + private var _minimapViewX:Number; + + private var _minimapViewY:Number; + + private var _prizeDenItems:Array = new Array(6); + + private var _prizePopup:GiftPopup; + + private var _raysInARow:int; + + public var _displayAchievementTimer:Number; + + private var _giftLogIndex:int; + + private var _awardGiftButton:Object; + + private var _sortedArray:Array = new Array(12); + + private var _isNew:Boolean; + + private var MOVEWINDOWWIDTH:int = 450; + + private var MOVEWINDOWHEIGHT:int = 300; + + private var _soundNameGemNew:String = TouchPoolData._audio[0]; + + private var _soundNameCd4Sec:String = TouchPoolData._audio[1]; + + private var _soundNameGemBurst:String = TouchPoolData._audio[2]; + + internal var _soundNameGemCollision1:String = TouchPoolData._audio[3]; + + internal var _soundNameGemCollision2:String = TouchPoolData._audio[4]; + + internal var _soundNameGemCollision3:String = TouchPoolData._audio[5]; + + private var _soundNameLoggedStinger:String = TouchPoolData._audio[6]; + + internal var _soundNamePoof:String = TouchPoolData._audio[7]; + + private var _soundNamePopUpEnter:String = TouchPoolData._audio[8]; + + private var _soundNamePopUpExit:String = TouchPoolData._audio[9]; + + private var _soundNamePopUpSuccess:String = TouchPoolData._audio[10]; + + private var _soundNameRolloverCountDown:String = TouchPoolData._audio[11]; + + private var _soundNameTileSelect:String = TouchPoolData._audio[12]; + + private var _soundNameInMenuRollover:String = TouchPoolData._audio[13]; + + private var _soundNameExitRollover:String = TouchPoolData._audio[14]; + + private var _soundNameExitSelect:String = TouchPoolData._audio[15]; + + public var _SFX_TouchPool_Music:SBMusic; + + public var _musicLoop:SoundChannel; + + public var _timerSound:SoundChannel; + + public function TouchPool() + { + super(); + init(); + } + + private function loadSounds() : void + { + _SFX_TouchPool_Music = _soundMan.addStream("aj_mus_touchPool",0.5); + _soundMan.addSoundByName(_audioByName[_soundNameGemNew],_soundNameGemNew,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameCd4Sec],_soundNameCd4Sec,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameGemBurst],_soundNameGemBurst,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameGemCollision1],_soundNameGemCollision1,0.15); + _soundMan.addSoundByName(_audioByName[_soundNameGemCollision2],_soundNameGemCollision2,0.15); + _soundMan.addSoundByName(_audioByName[_soundNameGemCollision3],_soundNameGemCollision3,0.15); + _soundMan.addSoundByName(_audioByName[_soundNameLoggedStinger],_soundNameLoggedStinger,0.3); + _soundMan.addSoundByName(_audioByName[_soundNamePoof],_soundNamePoof,0.3); + _soundMan.addSoundByName(_audioByName[_soundNamePopUpEnter],_soundNamePopUpEnter,0.3); + _soundMan.addSoundByName(_audioByName[_soundNamePopUpExit],_soundNamePopUpExit,0.3); + _soundMan.addSoundByName(_audioByName[_soundNamePopUpSuccess],_soundNamePopUpSuccess,0.35); + _soundMan.addSoundByName(_audioByName[_soundNameRolloverCountDown],_soundNameRolloverCountDown,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameTileSelect],_soundNameTileSelect,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameInMenuRollover],_soundNameInMenuRollover,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameExitRollover],_soundNameExitRollover,0.3); + _soundMan.addSoundByName(_audioByName[_soundNameExitSelect],_soundNameExitSelect,0.3); + } + + public function start(param1:uint, param2:Array) : void + { + MinigameManager.msg(["ts"]); + init(); + } + + private function init() : void + { + _lastTime = getTimer(); + if(!_bInit) + { + _background = new Sprite(); + _layerStarUrchin = new Sprite(); + _layerSeaslug = new Sprite(); + _layerHermit = new Sprite(); + _layerObstacles = new Sprite(); + _layerSwimmers = new Sprite(); + _layerGems = new Sprite(); + _foreground = new Sprite(); + _guiLayer = new Sprite(); + addChild(_background); + addChild(_foreground); + addChild(_guiLayer); + loadScene("TouchPoolAssets/main_room.xroom",TouchPoolData._audio); + _bInit = true; + } + } + + public function message(param1:Array) : void + { + var _loc3_:int = 0; + var _loc2_:int = 0; + if(param1[0] == "mm") + { + if(param1[2] == "ts") + { + _serialNumber = parseInt(param1[3]); + } + } + } + + private function getWorldCoords(param1:Object, param2:Point) : void + { + param2.x = param1.x; + param2.y = param1.y; + var _loc3_:Object = param1; + while(_loc3_.parent) + { + _loc3_ = _loc3_.parent; + param2.x += _loc3_.x; + param2.y += _loc3_.y; + } + } + + private function boxCollisionTestGlobal(param1:Object, param2:Object) : Boolean + { + var _loc9_:Number = NaN; + var _loc7_:Number = NaN; + var _loc5_:Number = NaN; + var _loc6_:Number = NaN; + var _loc8_:Number = NaN; + var _loc10_:Number = NaN; + var _loc4_:Number = NaN; + var _loc3_:Number = NaN; + getWorldCoords(param1,_globalBox1); + getWorldCoords(param2,_globalBox2); + _loc9_ = _globalBox1.x - param1.width * 0.5; + _loc7_ = _globalBox2.x - param2.width * 0.5; + _loc5_ = _globalBox1.x + param1.width * 0.5; + _loc6_ = _globalBox2.x + param2.width * 0.5; + _loc8_ = _globalBox1.y - param1.height * 0.5; + _loc10_ = _globalBox2.y - param2.height * 0.5; + _loc4_ = _globalBox1.y + param1.height * 0.5; + _loc3_ = _globalBox2.y + param2.height * 0.5; + if(_loc4_ < _loc10_) + { + return false; + } + if(_loc8_ > _loc3_) + { + return false; + } + if(_loc5_ < _loc7_) + { + return false; + } + if(_loc9_ > _loc6_) + { + return false; + } + return true; + } + + public function end(param1:Array) : void + { + exit(); + } + + private function exit() : void + { + if(_prizePopup) + { + _prizePopup.destroy(); + _prizePopup = null; + } + hideDlg(); + Mouse.show(); + addGemsToBalance(_gemsEarned - _gemsAwarded); + releaseBase(); + if(_musicLoop) + { + _musicLoop.stop(); + _musicLoop = null; + } + stage.removeEventListener("keyDown",showTutKeyDown); + removeEventListener("enterFrame",Heartbeat); + _log.openLogButton.removeEventListener("click",logClick); + _log.openLogButton.removeEventListener("mouseOver",logOver); + _log.tierneyLog.x_btn.removeEventListener("click",closeLog); + _log.tierneyLog.x_btn.removeEventListener("mouseOver",doneButtonOver); + _log.tierneyLog.infoBtn1.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn2.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn3.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn4.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn5.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn6.removeEventListener("click",logFactPopup); + _log.tierneyLog.infoBtn1.removeEventListener("mouseOver",infoBtnOver); + _log.tierneyLog.infoBtn2.removeEventListener("mouseOver",infoBtnOver); + _log.tierneyLog.infoBtn3.removeEventListener("mouseOver",infoBtnOver); + _log.tierneyLog.infoBtn4.removeEventListener("mouseOver",infoBtnOver); + _log.tierneyLog.infoBtn5.removeEventListener("mouseOver",infoBtnOver); + _log.tierneyLog.infoBtn6.removeEventListener("mouseOver",infoBtnOver); + _factPopup.factPopup.doneButton.removeEventListener("mouseOver",doneButtonOver); + _factPopup.factPopup.doneButton.removeEventListener("mouseOut",doneButtonOut); + _factPopup.factPopup.doneButton.removeEventListener("click",doneButtonClick); + _factPopup.factPopup.x_btn.removeEventListener("mouseOver",doneButtonOver); + _factPopup.factPopup.x_btn.removeEventListener("mouseOut",doneButtonOut); + _factPopup.factPopup.x_btn.removeEventListener("click",doneButtonClick); + _background.removeChild(_layerStarUrchin); + _background.removeChild(_layerSeaslug); + _background.removeChild(_layerHermit); + _background.removeChild(_layerObstacles); + _background.removeChild(_layerSwimmers); + _background.removeChild(_layerGems); + removeLayer(_background); + removeLayer(_foreground); + removeLayer(_guiLayer); + _background = null; + _foreground = null; + _guiLayer = null; + MinigameManager.leave(); + _bInit = false; + } + + override protected function sceneLoaded(param1:Event) : void + { + var _loc5_:int = 0; + var _loc9_:* = null; + var _loc2_:Object = null; + var _loc6_:Array = null; + var _loc3_:Object = null; + var _loc7_:Sprite = null; + var _loc8_:int = 0; + _soundMan = new SoundManager(this); + loadSounds(); + _musicLoop = _soundMan.playStream(_SFX_TouchPool_Music,0,999999); + _raysInARow = 0; + _displayAchievementTimer = 0; + addEventListener("enterFrame",Heartbeat); + _closeBtn = addBtn("CloseButton",847,5,showExitConfirmationDlg); + var _loc4_:Object = _scene.getLayer("bg").loader; + _background.addChild(_loc4_ as DisplayObject); + _background.addChild(_layerStarUrchin); + _background.addChild(_layerSeaslug); + _background.addChild(_layerHermit); + _background.addChild(_layerObstacles); + _background.addChild(_layerSwimmers); + _background.addChild(_layerGems); + _minimapOffsetX = _loc4_.x; + _minimapOffsetY = _loc4_.y; + _prizeDenItems[0] = new DenItem(); + _prizeDenItems[0].initShopItem(867,0); + _prizeDenItems[1] = new DenItem(); + _prizeDenItems[1].initShopItem(869,0); + _prizeDenItems[2] = new DenItem(); + _prizeDenItems[2].initShopItem(872,0); + _prizeDenItems[3] = new DenItem(); + _prizeDenItems[3].initShopItem(868,0); + _prizeDenItems[4] = new DenItem(); + _prizeDenItems[4].initShopItem(870,0); + _prizeDenItems[5] = new DenItem(); + _prizeDenItems[5].initShopItem(871,0); + _loc6_ = _scene.getActorList("ActorSpawn"); + for each(_loc9_ in _loc6_) + { + _loc9_.used = false; + _poolPoints.push(_loc9_); + } + _poolPoints = randomizeArray(_poolPoints); + _loc6_ = _scene.getActorList("ActorLayer"); + for each(_loc9_ in _loc6_) + { + if(_loc9_.name == "anem") + { + _layerObstacles.addChild(_loc9_.s as DisplayObject); + } + } + _loc5_ = 0; + while(_loc5_ < 12) + { + _sortedArray[_loc5_] = {}; + _loc8_ = Math.floor(_loc5_ * 0.5); + _loc7_ = getLayerFromType(_loc8_); + _loc3_ = _poolPoints[_loc5_]; + _creatures[_loc5_] = new TouchPoolCreature(this); + _creatures[_loc5_].init(_loc8_,_loc3_.x,_loc3_.y,_loc5_ % 2 == 0); + if(_loc8_ > 3) + { + _poolPoints[_loc5_].used = true; + _creatures[_loc5_]._spawnIndex = _loc5_; + } + if(_creatures[_loc5_]._wake) + { + for each(_loc9_ in _creatures[_loc5_]._wake) + { + _background.addChildAt(_loc9_ as DisplayObject,1); + } + } + _loc7_.addChild(_creatures[_loc5_]._clone.loader); + _loc5_++; + } + _currentRippleIndex = 0; + _loc5_ = 0; + while(_loc5_ < _ripple.length) + { + _ripple[_loc5_] = GETDEFINITIONBYNAME("tierneyPool_ripple"); + _background.addChild(_ripple[_loc5_] as DisplayObject); + _ripple[_loc5_].scaleX = _ripple[_loc5_].scaleY = 1.5; + _loc5_++; + } + _loc2_ = _scene.getLayer("timer"); + _foreground.addChild(_scene.getLayer("paw").loader); + _foreground.addChild(_loc2_.loader); + _loc2_.loader.visible = false; + _log = GETDEFINITIONBYNAME("tierneyPool_logBook"); + _guiLayer.addChild(_log as DisplayObject); + _log.openLogButton.addEventListener("click",logClick,false,0,true); + _log.openLogButton.addEventListener("mouseOver",logOver,false,0,true); + _log.tierneyLog.x_btn.addEventListener("click",closeLog,false,0,true); + _log.tierneyLog.x_btn.addEventListener("mouseOver",doneButtonOver,false,0,true); + _log.tierneyLog.infoBtn1.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn2.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn3.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn4.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn5.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn6.addEventListener("click",logFactPopup,false,0,true); + _log.tierneyLog.infoBtn1.addEventListener("mouseOver",infoBtnOver,false,0,true); + _log.tierneyLog.infoBtn2.addEventListener("mouseOver",infoBtnOver,false,0,true); + _log.tierneyLog.infoBtn3.addEventListener("mouseOver",infoBtnOver,false,0,true); + _log.tierneyLog.infoBtn4.addEventListener("mouseOver",infoBtnOver,false,0,true); + _log.tierneyLog.infoBtn5.addEventListener("mouseOver",infoBtnOver,false,0,true); + _log.tierneyLog.infoBtn6.addEventListener("mouseOver",infoBtnOver,false,0,true); + _logActive = false; + _minimap = _scene.getLayer("minimap").loader; + _foreground.addChild(_scene.getLayer("minimap").loader); + _minimapViewX = _minimap.content.view.x; + _minimapViewY = _minimap.content.view.y; + setupLog(); + _factPopup = GETDEFINITIONBYNAME("tierneyPool_factPopup"); + _factPopup.factPopup.doneButton.addEventListener("mouseOver",doneButtonOver,false,0,true); + _factPopup.factPopup.doneButton.addEventListener("mouseOut",doneButtonOut,false,0,true); + _factPopup.factPopup.doneButton.addEventListener("click",doneButtonClick,false,0,true); + _factPopup.factPopup.x_btn.addEventListener("mouseOver",doneButtonOver,false,0,true); + _factPopup.factPopup.x_btn.addEventListener("mouseOut",doneButtonOut,false,0,true); + _factPopup.factPopup.x_btn.addEventListener("click",doneButtonClick,false,0,true); + _queueShowFact = false; + _factPopupActive = false; + _mediaObjectHelper.init(397,mediaObjectSpiralLoaded); + _collectPopup = GETDEFINITIONBYNAME("tierneyPool_collect"); + _guiLayer.addChild(_collectPopup as DisplayObject); + _guiLayer.addChild(_factPopup); + _factData = new TouchPoolData(); + _totalGameTime = 0; + _prevPos.x = mouseX; + _prevPos.y = mouseY; + _gemsEarned = 0; + _gemsAwarded = 0; + _log.gems.text = _gemsEarned.toString(); + _gemsActive = []; + _gemPool = []; + _loc5_ = 0; + while(_loc5_ < 10) + { + _gemPool[_loc5_] = new TouchPoolGem(this); + _loc5_++; + } + showTutorialDlg(); + super.sceneLoaded(param1); + } + + private function respawnCreature(param1:Object) : void + { + var _loc3_:Object = null; + var _loc2_:int = findFarthestPointIndex(param1._clone.loader.x,param1._clone.loader.y,param1._type > 3); + _loc3_ = _poolPoints[_loc2_]; + param1._spawnIndex = _loc2_; + param1._clone.loader.x = _loc3_.x; + param1._clone.loader.y = _loc3_.y; + param1._color = Math.floor(Math.random() * 5) + 1; + param1._content.changeColor(param1._color); + } + + private function awardGift(param1:int) : void + { + _pauseGame = true; + _prizePopup = new GiftPopup(); + _prizeAwarded = param1; + _prizePopup.init(this.parent,_prizeDenItems[param1].icon,_prizeDenItems[param1].name,_prizeDenItems[param1].defId,5,2,keptItem,rejectedItem,destroyPrizePopup); + } + + private function keptItem() : void + { + var _loc1_:Number = _prizeAwarded * 5 + (gMainFrame.server.userId + 99) * 3 + (_serialNumber + 49) * 5; + var _loc2_:Number = (_serialNumber + gMainFrame.server.userId + _prizeAwarded) * 3 + _prizeAwarded * 3; + MinigameManager.msg(["tp",_loc1_,_loc2_]); + _prizePopup.close(); + markGiftUnwrapped(); + } + + private function rejectedItem() : void + { + _prizePopup.close(); + markGiftUnwrapped(); + } + + private function markGiftUnwrapped() : void + { + _logArray[_giftLogIndex][0] = 2; + if(_giftLogIndex == 6) + { + _logBitVar2 |= 1; + AchievementXtCommManager.requestSetUserVar(300,_logBitVar2); + } + else + { + _logBitVar1 |= 1 << (_giftLogIndex - 1) * 6; + AchievementXtCommManager.requestSetUserVar(299,_logBitVar1); + } + _log.tierneyLog.collectionList = _logArray; + _log.tierneyLog.openWindow(); + _awardGiftButton.removeEventListener("click",presentClick); + } + + private function destroyPrizePopup() : void + { + if(_prizePopup) + { + _pauseGame = false; + _prizePopup.destroy(); + _prizePopup = null; + } + } + + public function getLayerFromType(param1:int) : Sprite + { + switch(param1) + { + case 0: + case 1: + return _layerSwimmers; + case 2: + return _layerSeaslug; + case 3: + return _layerHermit; + case 4: + case 5: + return _layerStarUrchin; + default: + return null; + } + } + + public function spawnGems(param1:int, param2:Number, param3:Number) : void + { + var _loc5_:Object = null; + var _loc4_:int = 0; + _soundMan.playByName(_soundNameGemBurst); + _loc4_ = 0; + while(_loc4_ < param1) + { + if(_gemPool.length) + { + _loc5_ = _gemPool.pop(); + } + else + { + _loc5_ = new TouchPoolGem(this); + } + _loc5_._clone.newGem(); + _loc5_.reset(); + _layerGems.addChild(_loc5_._clone as DisplayObject); + _loc5_._clone.x = param2; + _loc5_._clone.y = param3; + _gemsActive.push(_loc5_); + _loc4_++; + } + } + + public function creatureFlee(param1:Object) : void + { + if(_currentTouchingIndex >= 0 && _creatures[_currentTouchingIndex] == param1) + { + _currentTouchTimer = 0; + } + } + + private function logFactPopup(param1:MouseEvent) : void + { + var _loc2_:int = 0; + var _loc3_:int = 0; + var _loc4_:int = 0; + if(param1.currentTarget.currentLabel != "off") + { + _loc2_ = 1; + _loc3_ = int(param1.currentTarget.name.charAt(7)); + _loc4_ = 1; + while(_loc4_ < 6) + { + if(_logArray[_loc3_][_loc4_] == 1) + { + break; + } + _loc4_++; + } + showFactPopup(TouchPoolCreature.getTypeFromLogIndex(parseInt(param1.currentTarget.name.charAt(7))),_loc4_,false); + } + } + + private function doneButtonOver(param1:MouseEvent) : void + { + param1.currentTarget.gotoAndStop("on"); + if(param1.currentTarget["buttonText"]) + { + if(_isNew) + { + LocalizationManager.translateId(param1.currentTarget.buttonText.buttonLabel,11939); + } + else + { + LocalizationManager.translateId(param1.currentTarget.buttonText.buttonLabel,11940); + } + } + _soundMan.playByName(_soundNameExitRollover); + } + + private function doneButtonOut(param1:MouseEvent) : void + { + param1.currentTarget.gotoAndStop("off"); + if(param1.currentTarget["buttonText"]) + { + if(_isNew) + { + LocalizationManager.translateId(param1.currentTarget.buttonText.buttonLabel,11939); + } + else + { + LocalizationManager.translateId(param1.currentTarget.buttonText.buttonLabel,11940); + } + } + } + + // closed whether or not its picture came: one picture loader serves + // every fact, and one still loading when the next was asked for never + // came, and the game stayed stopped behind the window for good + private function doneButtonClick(param1:MouseEvent) : void + { + if(_factPopupActive) + { + if(!_logActive) + { + _factPopup.addFact(); + Mouse.hide(); + } + else + { + _factPopup.factOff(); + } + _factPopupActive = false; + _soundMan.playByName(_soundNamePopUpExit); + } + } + + private function setupLog() : void + { + var _loc3_:int = 0; + var _loc5_:int = 0; + var _loc1_:int = 0; + var _loc4_:int = 0; + var _loc2_:* = 0; + _logArray = []; + _loc3_ = 0; + while(_loc3_ < 6) + { + _logArray[_loc3_ + 1] = []; + _loc3_++; + } + _logBitVar1 = gMainFrame.userInfo.userVarCache.getUserVarValueById(299); + _logBitVar2 = gMainFrame.userInfo.userVarCache.getUserVarValueById(300); + if(_logBitVar1 == 4294967295) + { + _logBitVar1 = 0; + } + if(_logBitVar2 == 4294967295) + { + _logBitVar2 = 0; + } + _loc2_ = _logBitVar1; + _loc3_ = 0; + while(_loc3_ < 6) + { + _logCreatureCount[_loc3_ + 1] = gMainFrame.userInfo.userVarCache.getUserVarValueById(301 + _loc3_); + if(_logCreatureCount[_loc3_ + 1] < 0) + { + _logCreatureCount[_loc3_ + 1] = 0; + } + _log.tierneyLog["count" + (_loc3_ + 1)].text = _logCreatureCount[_loc3_ + 1]; + if(_loc3_ == 5) + { + _loc2_ = _logBitVar2; + } + _loc1_ = 0; + _loc5_ = 1; + while(_loc5_ < 6) + { + _loc4_ = int((_loc2_ & 1 << (_loc3_ * 6 + _loc5_) % 30) != 0); + _logArray[_loc3_ + 1][_loc5_] = _loc4_; + _loc1_ += _loc4_; + _loc5_++; + } + if((_loc2_ & 1 << _loc3_ * 6 % 30) != 0) + { + _logArray[_loc3_ + 1][0] = 2; + } + else if(_loc1_ == 5) + { + _logArray[_loc3_ + 1][0] = 1; + _log.tierneyLog["present" + (_loc3_ + 1)].addEventListener("click",presentClick,false,0,true); + } + else + { + _logArray[_loc3_ + 1][0] = 0; + } + _loc3_++; + } + } + + private function touchCreature() : void + { + var _loc4_:TouchPoolCreature = _creatures[_currentTouchingIndex]; + var _loc1_:int = TouchPoolCreature.getLogIndexFromType(_loc4_._type); + var _loc2_:int = 0; + var _loc3_:int = 0; + if(_loc4_._type == 1) + { + _raysInARow = _raysInARow + 1; + if(_raysInARow == 10) + { + AchievementXtCommManager.requestSetUserVar(309,10); + } + } + else + { + _raysInARow = 0; + } + if(_logArray[_loc1_][_loc4_._color] == 0) + { + _logArray[_loc1_][_loc4_._color] = 1; + if(_loc1_ == 6) + { + _logBitVar2 |= 1 << _loc4_._color; + AchievementXtCommManager.requestSetUserVar(300,_logBitVar2); + } + else + { + _logBitVar1 |= 1 << (_loc1_ - 1) * 6 + _loc4_._color; + AchievementXtCommManager.requestSetUserVar(299,_logBitVar1); + } + _queueShowFact = true; + _currentType = _loc4_._type; + _currentColor = _loc4_._color; + _loc2_ = 1; + while(_loc2_ < 6) + { + if(_logArray[_loc1_][_loc2_] == 0) + { + break; + } + _loc2_++; + } + if(_loc2_ == 6) + { + _logArray[_loc1_][0] = 1; + _log.tierneyLog["present" + _loc1_].addEventListener("click",presentClick,false,0,true); + } + } + if(_loc4_._type > 3) + { + _poolPoints[_loc4_._spawnIndex].used = false; + } + spawnGems(_loc4_.getNumGems(),_loc4_._clone.loader.x,_loc4_._clone.loader.y); + _logCreatureCount[_loc1_]++; + _log.tierneyLog["count" + _loc1_].text = _logCreatureCount[_loc1_]; + AchievementXtCommManager.requestSetUserVar(300 + _loc1_,1); + AchievementXtCommManager.requestSetUserVar(308,1); + _collectPopup.x = _loc4_._clone.loader.x + _loc4_._clone.loader.parent.parent.x; + _collectPopup.y = _loc4_._clone.loader.y + _loc4_._clone.loader.parent.parent.y; + _collectPopup.counter.counterText.text = _logCreatureCount[_loc1_].toString(); + _collectPopup.gotoAndPlay("on"); + _collectPopup.critterIcons(_loc1_); + _soundMan.playByName(_soundNameLoggedStinger); + _loc2_ = 1; + while(_loc2_ <= 6) + { + if(_logArray[_loc2_][0] == 0) + { + break; + } + _loc2_++; + } + if(_loc2_ == 7) + { + AchievementXtCommManager.requestSetUserVar(310,30); + } + else + { + _loc2_ = 1; + while(_loc2_ <= 6) + { + if(_logCreatureCount[_loc2_] == 0) + { + break; + } + _loc2_++; + } + if(_loc2_ == 7) + { + AchievementXtCommManager.requestSetUserVar(310,6); + } + } + respawnCreature(_loc4_); + _displayAchievementTimer = 1; + } + + private function presentClick(param1:MouseEvent) : void + { + _giftLogIndex = parseInt(param1.currentTarget.name.charAt(7)); + _awardGiftButton = param1.currentTarget; + awardGift(_giftLogIndex - 1); + } + + private function closeLog(param1:MouseEvent) : void + { + Mouse.hide(); + _log.closeLog(); + _logActive = false; + _soundMan.playByName(_soundNameExitSelect); + } + + private function logClick(param1:MouseEvent) : void + { + if(!_pauseGame) + { + if(_logActive) + { + Mouse.hide(); + closeLog(null); + } + else + { + Mouse.show(); + _log.tierneyLog.collectionList = _logArray; + _log.tierneyLog.openWindow(); + _log.openLog(); + _logActive = true; + _soundMan.playByName(_soundNamePopUpEnter); + } + } + } + + private function logOver(param1:MouseEvent) : void + { + _soundMan.playByName(_soundNameInMenuRollover); + } + + private function infoBtnOver(param1:MouseEvent) : void + { + _soundMan.playByName(_soundNameInMenuRollover); + } + + private function isColliding(param1:DisplayObject, param2:DisplayObject, param3:DisplayObjectContainer, param4:Boolean = true, param5:int = 255) : Boolean + { + var _loc11_:Rectangle = param1.getBounds(param3); + var _loc12_:Rectangle = param2.getBounds(param3); + var _loc8_:Rectangle = _loc11_.intersection(_loc12_); + if(!param4) + { + return !_loc8_.isEmpty(); + } + _loc8_.x = Math.floor(_loc8_.x); + _loc8_.y = Math.floor(_loc8_.y); + _loc8_.width = Math.ceil(_loc8_.width); + _loc8_.height = Math.ceil(_loc8_.height); + if(_loc8_.isEmpty()) + { + return false; + } + var _loc6_:Matrix = param3.transform.concatenatedMatrix.clone(); + _loc6_.invert(); + var _loc10_:Matrix = param1.transform.concatenatedMatrix.clone(); + _loc10_.concat(_loc6_); + var _loc13_:Matrix = param2.transform.concatenatedMatrix.clone(); + _loc13_.concat(_loc6_); + _loc10_.translate(-_loc8_.x,-_loc8_.y); + _loc13_.translate(-_loc8_.x,-_loc8_.y); + var _loc7_:BitmapData = new BitmapData(_loc8_.width,_loc8_.height,false); + _loc7_.draw(param1,_loc10_,new ColorTransform(1,1,1,1,255,-255,-255,param5),"normal"); + _loc7_.draw(param2,_loc13_,new ColorTransform(1,1,1,1,255,255,255,param5),"difference"); + var _loc9_:Rectangle = _loc7_.getColorBoundsRect(4294967295,4278255615); + _loc9_.offset(_loc8_.x,_loc8_.y); + _loc7_.dispose(); + return !_loc9_.isEmpty(); + } + + public function randomizeArray(param1:Array) : Array + { + var _loc4_:int = 0; + var _loc2_:int = 0; + var _loc3_:* = undefined; + var _loc5_:Number = param1.length - 1; + _loc4_ = 0; + while(_loc4_ < _loc5_) + { + _loc2_ = Math.round(Math.random() * _loc5_); + _loc3_ = param1[_loc4_]; + param1[_loc4_] = param1[_loc2_]; + param1[_loc2_] = _loc3_; + _loc4_++; + } + return param1; + } + + public function findFarthestPointIndex(param1:Number, param2:Number, param3:Boolean) : int + { + var _loc5_:int = 0; + var _loc4_:int = 0; + _loc5_ = 0; + while(_loc5_ < _poolPoints.length) + { + _sortedArray[_loc5_].curDistSq = (param1 - _poolPoints[_loc5_].x) * (param1 - _poolPoints[_loc5_].x) + (param2 - _poolPoints[_loc5_].y) * (param2 - _poolPoints[_loc5_].y); + _sortedArray[_loc5_].i = _loc5_; + _loc5_++; + } + _sortedArray.sortOn("curDistSq",2 | 0x10); + if(param3) + { + _loc5_ = 0; + while(_loc5_ < _poolPoints.length) + { + if(_poolPoints[_sortedArray[_loc5_].i].used == false) + { + _poolPoints[_sortedArray[_loc5_].i].used = true; + return _sortedArray[_loc5_].i; + } + _loc5_++; + } + } + return _sortedArray[0].i; + } + + private function Heartbeat(param1:Event) : void + { + var _loc9_:int = 0; + var _loc13_:* = null; + var _loc3_:Number = NaN; + var _loc18_:* = null; + var _loc11_:Object = null; + var _loc17_:Number = NaN; + var _loc15_:Number = NaN; + var _loc16_:Number = NaN; + var _loc7_:Number = (getTimer() - _lastTime) / 1000; + var _loc10_:int = (900 - MOVEWINDOWWIDTH) * 0.5; + var _loc12_:int = (550 - MOVEWINDOWHEIGHT) * 0.5; + var _loc4_:int = 18; + _lastTime = getTimer(); + if(_pauseGame || _logActive || _factPopupActive) + { + return; + } + if(!_queueShowFact && !_factPopupActive && _displayAchievementTimer > 0) + { + _displayAchievementTimer -= _loc7_; + if(_displayAchievementTimer <= 0) + { + _displayAchievementTimer = 0; + AchievementManager.displayNewAchievements(); + } + } + var _loc6_:Object = _background; + var _loc8_:Object = _scene.getLayer("paw").loader; + if(_queueShowFact) + { + if(_collectPopup.done) + { + _queueShowFact = false; + try + { + showFactPopup(_currentType,_currentColor,true); + } + catch(e:Error) + { + // the game runs on without the fact + _factPopupActive = false; + GlobalErrorCatch.reportToServer("touch pool fact: " + e + "\n" + e.getStackTrace()); + } + } + } + _loc8_.x = mouseX; + _loc8_.y = mouseY; + var _loc5_:Number = Number(_loc6_.x); + var _loc2_:Number = Number(_loc6_.y); + if(mouseX >= _minimap.x - 20 && mouseY >= _minimap.y - 20) + { + _loc3_ = 0.3; + } + else + { + _loc3_ = 1; + } + if(_loc3_ > _minimap.alpha) + { + _minimap.alpha += _loc7_ * 2; + if(_minimap.alpha > _loc3_) + { + _minimap.alpha = _loc3_; + } + } + else if(_loc3_ < _minimap.alpha) + { + _minimap.alpha -= _loc7_ * 2; + if(_minimap.alpha < _loc3_) + { + _minimap.alpha = _loc3_; + } + } + if(mouseX < _loc10_) + { + _loc6_.x += _loc4_ * (_loc10_ - mouseX) / _loc10_; + if(_loc6_.x > 675) + { + _loc6_.x = 675; + } + } + else if(mouseX > 900 - _loc10_) + { + _loc6_.x -= _loc4_ * (mouseX - 900 + _loc10_) / 200; + if(_loc6_.x < -1530) + { + _loc6_.x = -1530; + } + } + if(mouseY < _loc12_) + { + _loc6_.y += _loc4_ * (_loc12_ - mouseY) / _loc12_; + if(_loc6_.y > 330) + { + _loc6_.y = 330; + } + } + else if(mouseY > 550 - _loc12_) + { + _loc6_.y -= _loc4_ * (mouseY - 550 + _loc12_) / _loc12_; + if(_loc6_.y < -1530) + { + _loc6_.y = -1530; + } + } + _loc5_ -= _loc6_.x; + _loc2_ -= _loc6_.y; + _minimap.content.view.x = (_minimapOffsetX - _background.x) * 0.05 + _minimapViewX; + _minimap.content.view.y = (_minimapOffsetY - _background.y) * 0.05 + _minimapViewY; + var _loc14_:Object = _scene.getLayer("timer"); + _loc14_.loader.visible = false; + if(_currentTouchingIndex >= 0 && boxCollisionTestGlobal(_loc8_,_creatures[_currentTouchingIndex]._clone.loader)) + { + _loc14_.loader.visible = true; + _loc14_.loader.x = mouseX; + _loc14_.loader.y = mouseY; + } + else + { + _loc9_ = 0; + while(_loc9_ < _creatures.length) + { + if(boxCollisionTestGlobal(_loc8_,_creatures[_loc9_]._clone.loader)) + { + _loc14_.loader.visible = true; + _loc14_.loader.x = mouseX; + _loc14_.loader.y = mouseY; + if(_currentTouchingIndex != _loc9_) + { + _currentTouchingIndex = _loc9_; + _currentTouchTimer = 0; + _currentTouchTime = _creatures[_loc9_].getTouchTime(); + _timerSound = _soundMan.playByName(_soundNameCd4Sec); + _loc8_.content.gotoAndPlay("on"); + } + break; + } + _loc9_++; + } + } + for each(_loc18_ in _creatures) + { + _loc18_.heartbeat(_loc7_); + } + if(_loc14_.loader.visible) + { + _currentTouchTimer += _loc7_; + if(_currentTouchTimer >= _currentTouchTime) + { + touchCreature(); + _currentTouchingIndex = -1; + } + _loc14_.loader.content.time(Math.floor(_currentTouchTimer * 1000 / _currentTouchTime)); + } + else + { + _currentTouchTimer = 0; + _loc8_.content.gotoAndPlay("off"); + _currentTouchingIndex = -1; + if(_timerSound) + { + _timerSound.stop(); + } + } + _loc9_ = 0; + while(_loc9_ < _gemsActive.length) + { + _loc11_ = _gemsActive[_loc9_]._clone; + if(_loc11_.collectible) + { + _gemsActive[_loc9_].heartbeat(_loc7_); + if(!_gemsActive[_loc9_]._collected && boxCollisionTestGlobal(_loc8_,_loc11_.gem.gem)) + { + _gemsActive[_loc9_].collect(); + _gemsEarned = _gemsEarned + 1; + _log.gems.text = _gemsEarned.toString(); + _soundMan.playByName(_soundNameGemNew); + if(_gemsEarned - _gemsAwarded == 300) + { + addGemsToBalance(300); + _gemsAwarded += 300; + } + } + else if(_loc11_.parent == null) + { + _gemPool.push(_gemsActive[_loc9_]); + _gemsActive.splice(_loc9_,1); + _loc9_--; + } + } + _loc9_++; + } + if(_rippleTimer == 0) + { + _loc17_ = _loc8_.x - _background.x; + _loc15_ = _loc8_.y - _background.y; + if(!(_loc15_ < -50 || _loc17_ > 2150 || _loc15_ > 1750 || _loc17_ < -350)) + { + _loc16_ = Math.sqrt((mouseX - _prevPos.x + _loc5_) * (mouseX - _prevPos.x + _loc5_) + (mouseY - _prevPos.y + _loc2_) * (mouseY - _prevPos.y + _loc2_)) / _loc7_; + if(_loc16_ > 625) + { + _ripple[_currentRippleIndex].x = _loc8_.x - _background.x; + _ripple[_currentRippleIndex].y = _loc8_.y - _background.y; + _ripple[_currentRippleIndex].rippleOn(); + _rippleTimer = 7; + _currentRippleIndex = _currentRippleIndex + 1; + if(_currentRippleIndex >= _ripple.length) + { + _currentRippleIndex = 0; + } + } + } + } + else + { + _rippleTimer -= 1; + } + _prevPos.x = mouseX; + _prevPos.y = mouseY; + _totalGameTime += _loc7_; + } + + private function mediaObjectLoaded(param1:MovieClip) : void + { + param1.x = 0; + param1.y = 0; + _factPopup.factPopup.result_pic.addChild(param1); + } + + private function mediaObjectSpiralLoaded(param1:MovieClip) : void + { + param1.x = 0; + param1.y = 0; + _factPopup.factPopup.loadArrowContainer.addChild(param1); + } + + private function showFactPopup(param1:int, param2:int, param3:Boolean) : void + { + Mouse.show(); + _factPopupActive = true; + _currentFactID = TouchPoolCreature.getFactIndexFromType(param1) * 5 + param2 - 1; + _currentLogID = TouchPoolCreature.getLogIndexFromType(param1); + _factPopup.factPopup.showIcons(_currentLogID,[false,Boolean(_logArray[_currentLogID][1]),Boolean(_logArray[_currentLogID][2]),Boolean(_logArray[_currentLogID][3]),Boolean(_logArray[_currentLogID][4]),Boolean(_logArray[_currentLogID][5])]); + setFactButtons(param2); + _isNew = param3; + if(param3) + { + _factPopup.newFact(); + LocalizationManager.translateId(_factPopup.factPopup.factTitle,11941); + LocalizationManager.translateId(_factPopup.factPopup.doneButton.buttonText.buttonLabel,11939); + _factPopup.factPopup.x_btn.visible = false; + _soundMan.playByName(_soundNamePopUpSuccess); + } + else + { + _factPopup.factOn(); + LocalizationManager.translateId(_factPopup.factPopup.factTitle,_factData._facts[_currentFactID].title); + LocalizationManager.translateId(_factPopup.factPopup.doneButton.buttonText.buttonLabel,11940); + _factPopup.factPopup.x_btn.visible = true; + _soundMan.playByName(_soundNameTileSelect); + _soundMan.playByName(_soundNamePopUpEnter); + } + } + + private function setFactButtons(param1:int) : void + { + var _loc2_:Object = null; + var _loc3_:int = 0; + _currentFactID = TouchPoolCreature.getFactIndexFromType(TouchPoolCreature.getTypeFromLogIndex(_currentLogID)) * 5 + param1 - 1; + _factPopup.factPopup.factSelect.x = _factPopup.factPopup["item_" + param1].x; + _factPopup.factPopup.factSelect.y = _factPopup.factPopup["item_" + param1].y; + _loc3_ = 1; + while(_loc3_ < 6) + { + _loc2_ = _factPopup.factPopup["item_" + _loc3_]; + if(_logArray[_currentLogID][_loc3_] == 1) + { + if(_loc3_ == param1) + { + _loc2_.gotoAndPlay("on"); + _loc2_.removeEventListener("mouseOver",factButtonEvent); + _loc2_.removeEventListener("mouseOut",factButtonEvent); + _loc2_.removeEventListener("mouseDown",factButtonEvent); + _loc2_.removeEventListener("click",factButtonEvent); + } + else if(!_loc2_.hasEventListener("mouseOver")) + { + _loc2_.addEventListener("mouseOver",factButtonEvent,false,0,true); + _loc2_.addEventListener("mouseOut",factButtonEvent,false,0,true); + _loc2_.addEventListener("mouseDown",factButtonEvent,false,0,true); + _loc2_.addEventListener("click",factButtonEvent,false,0,true); + } + } + else + { + _loc2_.gotoAndPlay("off"); + _loc2_.removeEventListener("mouseOver",factButtonEvent); + _loc2_.removeEventListener("mouseOut",factButtonEvent); + _loc2_.removeEventListener("mouseDown",factButtonEvent); + _loc2_.removeEventListener("click",factButtonEvent); + } + _loc3_++; + } + LocalizationManager.translateId(_factPopup.factPopup.result_fact,_factData._facts[_currentFactID].text); + if(_factPopup.factPopup.result_pic.numChildren > 0) + { + _factPopup.factPopup.result_pic.removeChildAt(0); + } + _mediaObjectHelper.init(_factData._facts[_currentFactID].imageID,mediaObjectLoaded); + } + + private function factButtonEvent(param1:MouseEvent) : void + { + if(param1.type == "mouseOver") + { + param1.currentTarget.gotoAndPlay("rollover"); + _soundMan.playByName(_soundNameInMenuRollover); + } + else if(param1.type == "mouseOut") + { + param1.currentTarget.gotoAndPlay("on"); + } + else if(param1.type == "mouseDown") + { + param1.currentTarget.gotoAndPlay("pressed"); + _soundMan.playByName(_soundNameTileSelect); + } + else + { + param1.currentTarget.gotoAndPlay("on"); + setFactButtons(param1.currentTarget.name.charAt(5)); + } + } + + private function showTutKeyDown(param1:KeyboardEvent) : void + { + switch(param1.keyCode) + { + case 13: + case 32: + case 8: + case 46: + case 27: + onExit_No(); + } + } + + private function showTutorialDlg() : void + { + var _loc1_:MovieClip = showDlg("tierneyPool_tutorial",[{ + "name":"doneButton", + "f":onExit_No + },{ + "name":"x_btn", + "f":onExit_No + }]); + _loc1_.x = 450; + _loc1_.y = 275; + stage.addEventListener("keyDown",showTutKeyDown); + _minimap.alpha = 0; + Mouse.show(); + } + + private function showExitConfirmationDlg() : void + { + var _loc1_:MovieClip = showDlg("tierneyPool_exit",[{ + "name":"yesButton", + "f":onExit_Yes + },{ + "name":"noButton", + "f":onExit_No + },{ + "name":"x_btn", + "f":onExit_No + }]); + LocalizationManager.translateIdAndInsert(_loc1_.gemsEarned,11577,_gemsEarned.toString()); + _loc1_.x = 450; + _loc1_.y = 275; + Mouse.show(); + } + + private function onExit_Yes() : void + { + hideDlg(); + exit(); + } + + private function onExit_No() : void + { + stage.removeEventListener("keyDown",showTutKeyDown); + Mouse.hide(); + hideDlg(); + } + } +} + diff --git a/swf/ajclient.swf b/swf/ajclient.swf index e2c9bb8..72bf9f4 100644 Binary files a/swf/ajclient.swf and b/swf/ajclient.swf differ diff --git a/tools/build-client.sh b/tools/build-client.sh index 943ad36..3fd12ed 100755 --- a/tools/build-client.sh +++ b/tools/build-client.sh @@ -101,6 +101,11 @@ set -- \ gameRedemption.CodeRedemptionPopup CodeRedemptionPopup.as \ playerWall.PlayerWallXtCommManager PlayerWallXtCommManager.as \ playerWall.PlayerWallGui PlayerWallGui.as \ + pet.PetManager PetManager.as \ + adoptAPet.TierPathPopup TierPathPopup.as \ + pet.PetBase PetBase.as \ + game.touchPool.TouchPool TouchPool.as \ + game.phantomsTreasure.PhantomsTreasure PhantomsTreasure.as \ game.microSmoothie.MicroSmoothie MicroSmoothie.as \ room.DenItemHolder ../tools/decompiled/room/DenItemHolder.as # not in the game: added before the replace (game.ArtStudioKit is Strawberry