code
stringlengths
0
56.1M
repo_name
stringclasses
515 values
path
stringlengths
2
147
language
stringclasses
447 values
license
stringclasses
7 values
size
int64
0
56.8M
package; import critter.Critter; import critter.SingleCritterHolder; import flixel.FlxG; import flixel.FlxSprite; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import flixel.util.FlxDestroyUtil; /** * A clue cell capable of holding a single bug, for use in puzzles. */ class Cell extends SingleCritterHolder implements ICell { public var _frontSprite:FlxSprite; public var _clueIndex:Int; public var _pegIndex:Int; private var _assignedCritters:Array<Critter> = []; public function new(X:Float, Y:Float) { super(X, Y); _sprite.loadGraphic(AssetPaths.box_back__png, true, 64, 64); _sprite.setSize(36, 10); _sprite.offset.set(14, 39); _sprite.immovable = true; _frontSprite = new FlxSprite(X, Y+2); _frontSprite.loadGraphic(AssetPaths.box_front__png, true, 64, 64); _frontSprite.setSize(_sprite.width, _sprite.height); _frontSprite.offset.set(_sprite.offset.x, _sprite.offset.y + 2); _frontSprite.immovable = true; } override public function destroy():Void { super.destroy(); _frontSprite = FlxDestroyUtil.destroy(_frontSprite); _assignedCritters = null; } public function traceInfo(prefix:String):Void { trace(prefix + ": box # " + _clueIndex + "," + _pegIndex + " = " + (_critter == null ? null : _critter.myId)); } public function open():Void { SoundStackingFix.play(AssetPaths.box_open_00cb__mp3); _sprite.animation.frameIndex = 0; _frontSprite.animation.frameIndex = 0; } public function close():Void { SoundStackingFix.play(AssetPaths.box_open_00cb__mp3); _sprite.animation.frameIndex = 1; _frontSprite.animation.frameIndex = 1; } public function isClosed():Bool { return _sprite.animation.frameIndex == 1; } public function getClueIndex():Int { return _clueIndex; } public function getFrontSprite():FlxSprite { return _frontSprite; } public function assignCritter(critter:Critter):Void { _assignedCritters.push(critter); } public function unassignCritter(critter:Critter):Void { _assignedCritters.remove(critter); } public function getAssignedCritters():Array<Critter> { return _assignedCritters; } } interface ICell extends IFlxDestroyable { public function getCritters():Array<Critter>; public function open():Void; public function close():Void; public function isClosed():Bool; public function addCritter(critter:Critter):Bool; public function removeCritter(critter:Critter):Bool; public function getSprite():FlxSprite; public function getFrontSprite():FlxSprite; public function getClueIndex():Int; public function assignCritter(critter:Critter):Void; public function unassignCritter(critter:Critter):Void; public function getAssignedCritters():Array<Critter>; }
argonvile/monster
source/Cell.hx
hx
unknown
2,799
package; import flixel.FlxBasic; import flixel.FlxG; /** * When testing the game we let players type things like "MONEY" to get money, * or "ZXC" to cycle through items in the shop. These cheat codes are disabled * for the release build. * * This class handles the logic for accumulating the player's keypresses into * a string, and invoking a callback so we can check which cheat codes the * player has typed. */ class CheatCodes extends FlxBasic { public var callback:Dynamic; private static var codeChars:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; private var code:String = " "; public function new(Callback:Dynamic) { super(); this.callback = Callback; } override public function update(elapsed:Float):Void { super.update(elapsed); var codeKeyPressed:Bool = false; var justPressed:Int = FlxG.keys.firstJustPressed(); if (justPressed != -1) { var justPressedChar = String.fromCharCode(justPressed); if (codeChars.indexOf(justPressedChar) >= 0) { code = code.substring(1) + justPressedChar; codeKeyPressed = true; } } if (codeKeyPressed) { callback(code); } } }
argonvile/monster
source/CheatCodes.hx
hx
unknown
1,189
package; import critter.Critter; import flixel.effects.particles.FlxParticle; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.effects.FlxFlicker; import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxDestroyUtil; import kludge.BetterFlxRandom; import kludge.LateFadingFlxParticle; /** * Graphics and logic for the chests which appear during puzzles and minigames */ class Chest implements IFlxDestroyable { public var _chestSprite:FlxSprite; public var _paySprite:FlxSprite; public var _payGroup:FlxGroup; public var _critter:Critter; public var _reward:Int = 200; public var _payed:Bool = false; public var _minigameCoin:Bool = false; public var z:Float = 0; public var shadow:Shadow; // 0:Wood; 1:Silver; 2:Gold; 3:Diamond public var chestType:Int = 0; public var destroyAfterPay:Bool = true; public var increasePlayerCash:Bool = true; public function new(X:Float=0, Y:Float=0) { _chestSprite = new FlxSprite(X, Y); _chestSprite.loadGraphic(AssetPaths.chests__png, true, 64, 64); _chestSprite.setSize(36, 10); _chestSprite.offset.set(14, 39); _chestSprite.setFacingFlip(FlxObject.LEFT, false, false); _chestSprite.setFacingFlip(FlxObject.RIGHT, true, false); _chestSprite.facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); } public function setReward(Reward:Int, ?UpdateChestType:Bool=true):Void { this._reward = Reward; if (UpdateChestType) { chestType = 0; if (_reward >= 200) { chestType = 1; } if (_reward >= 500) { chestType = 2; } if (_reward >= 1000) { chestType = 3; } } } public function pay(PayGroup:FlxGroup) { if (_payed) { return; } if (_chestSprite == null) { /* * I've added a check to short-circuit the pay logic if this chest * was already destroyed. * * I've never seen this behavior myself, but it could account for * crashes people were seeing when the game was first released. */ return; } _payed = true; this._payGroup = PayGroup; _chestSprite.animation.frameIndex += 4; if (_minigameCoin) { SoundStackingFix.play(AssetPaths.chest_open_00cb__mp3, 0.5); SoundStackingFix.play(AssetPaths.minigame_coin_005f__mp3); _paySprite = new FlxSprite(_chestSprite.x + _chestSprite.width / 2, _chestSprite.y + _chestSprite.height / 2 - 8); _paySprite.loadGraphic(AssetPaths.minigame_coin__png, true, 13, 24); _paySprite.x -= _paySprite.width / 2; _paySprite.y -= _paySprite.height / 2; _paySprite.animation.add("play", [0, 1, 2, 3], 6); _paySprite.animation.play("play"); FlxTween.tween(_paySprite, { y:_paySprite.y - 49 }, 1.6, { ease:FlxEase.circOut, onComplete:finishPay }); } else { SoundStackingFix.play(AssetPaths.chest_open_00cb__mp3); var text:FlxText = new FlxText(_chestSprite.x - 18, _chestSprite.y - 21, 36 + 36, Std.string(_reward), 16); _paySprite = text; text.alignment = "center"; FlxTween.tween(_paySprite, { y:_paySprite.y - 29 }, 0.8, { ease:FlxEase.circOut, onComplete:finishPay }); } PayGroup.add(_paySprite); } public function update(elapsed:Float):Void { if (_chestSprite == null) { return; } if (_critter != null) { if (_critter._bodySprite.animation.name == "run-sw" || _critter._bodySprite.animation.name == "jump-sw") { _chestSprite.animation.frameIndex = 0; } else if (_critter._bodySprite.animation.name == "run-nw" || _critter._bodySprite.animation.name == "jump-nw") { _chestSprite.animation.frameIndex = 1; } else if (_critter._bodySprite.animation.name == "run-n" || _critter._bodySprite.animation.name == "jump-n") { _chestSprite.animation.frameIndex = 3; } else { // idle? facing forward? _chestSprite.animation.frameIndex = 2; } _chestSprite.facing = _critter._bodySprite.facing; _chestSprite.x = _critter._bodySprite.x; _chestSprite.y = _critter._bodySprite.y + 1; z = _critter.z + 17; if (shadow != null) shadow.groundZ = _critter.groundZ; } _chestSprite.animation.frameIndex = _chestSprite.animation.frameIndex % 8 + chestType * 8; _chestSprite.offset.y = 39 + z; } public function finishPay(_):Void { FlxTween.tween(_paySprite, { alpha:0 }, 0.2, { onComplete:finishPay2 }); } public function finishPay2(_):Void { _paySprite = FlxDestroyUtil.destroy(_paySprite); if (!_minigameCoin) { if (increasePlayerCash) { PlayerData.cash += _reward; } } if (destroyAfterPay) { FlxFlicker.flicker(_chestSprite, 0.5, 0.04, false, false, finishPay3); } } public function finishPay3(_):Void { _chestSprite = FlxDestroyUtil.destroy(_chestSprite); } public function destroy() { _chestSprite = FlxDestroyUtil.destroy(_chestSprite); _paySprite = FlxDestroyUtil.destroy(_paySprite); } public function dropChest() { if (_critter != null) { _critter = null; z -= 17; } } }
argonvile/monster
source/Chest.hx
hx
unknown
5,238
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxColor; import openfl.geom.Point; import openfl.geom.Rectangle; /** * Utility methods related to the player's cursor */ class CursorUtils { public static function initializeSystemCursor() { if (PlayerData.cursorType == "none") { FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; } else { FlxG.mouse.useSystemCursor = false; FlxG.mouse.visible = false; } } public static function useSystemCursor() { FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; } public static function initializeHandSprite(spr:FlxSprite, graphic:FlxGraphicAsset) { initializeCustomHandBouncySprite(spr, graphic, 160, 160); } public static function initializeHandBouncySprite(spr:FlxSprite, graphic:FlxGraphicAsset) { initializeCustomHandBouncySprite(spr, graphic, 356, 532); } public static function initializeTallHandBouncySprite(spr:FlxSprite, graphic:FlxGraphicAsset) { initializeCustomHandBouncySprite(spr, graphic, 356, 660); } /** * Initializes a sprite for the player's cursor. This includes drawing the * glove graphics, recoloring them appropriately, and setting the alpha * component. * * @param spr sprite to initialize * @param graphic graphic to initialize with * @param w sprite width * @param h sprite height */ public static function initializeCustomHandBouncySprite(spr:FlxSprite, graphic:FlxGraphicAsset, w:Int, h:Int) { spr.loadGraphic(graphic, true, w, h, true); if (PlayerData.cursorType == "none") { spr.loadGraphic(graphic, true, w, h, true); spr.pixels.fillRect(spr.pixels.rect, FlxColor.TRANSPARENT); } else { spr.pixels.threshold(spr.pixels, new Rectangle(0, 0, spr.pixels.width, spr.pixels.height), new Point(0, 0), '==', 0xffffffff, PlayerData.cursorFillColor); spr.pixels.threshold(spr.pixels, new Rectangle(0, 0, spr.pixels.width, spr.pixels.height), new Point(0, 0), '==', 0xff000000, PlayerData.cursorLineColor); spr.alpha = PlayerData.cursorMaxAlpha; } } }
argonvile/monster
source/CursorUtils.hx
hx
unknown
2,189
package; import MmStringTools.*; import openfl.utils.Object; /** * Pokemon have about 10-15 things they need to say while they're in the den, * such as "Here I am, let's play a game!" or "Really? You want to have sex * again!?" or "I'll see you next time, I'm exhausted!" * * This class acts as a data model for all the phrases a particular Pokemon * says in the den. */ class DenDialog { private var replayMinigames:Array<DenReplayMinigame> = []; private var replaySexes:Array<DenReplaySex> = []; private var repeatSexGreetings:Array<Array<String>> = []; private var tooManyGames:Array<String> = []; private var tooMuchSex:Array<String> = []; private var gameGreeting:Array<String> = []; private var sexGreeting:Array<String> = []; public function new() { } public function addReplayMinigame(preliminaryLines:Array<String>, gameLines:Array<String>, sexLines:Array<String>, quitLines:Array<String>):Void { replayMinigames.push(new DenReplayMinigame(preliminaryLines, gameLines, sexLines, quitLines)); } public function addReplaySex(preliminaryLines:Array<String>, sexLines:Array<String>, quitLines:Array<String>):Void { replaySexes.push(new DenReplaySex(preliminaryLines, sexLines, quitLines)); } public function setGameGreeting(gameGreeting:Array<String>) { this.gameGreeting = gameGreeting; } public function setSexGreeting(sexGreeting:Array<String>) { this.sexGreeting = sexGreeting; } public function setTooManyGames(tooManyGames:Array<String>) { this.tooManyGames = tooManyGames; } public function setTooMuchSex(tooMuchSex:Array<String>) { this.tooMuchSex = tooMuchSex; } public function addRepeatSexGreeting(repeatSexGreeting:Array<String>) { repeatSexGreetings.push(repeatSexGreeting); } public function getRepeatSexGreeting(tree:Array<Array<Object>>) { var count:Int = getTotalMinigames() + PlayerData.denSexCount; var repeatSexGreeting:Array<String> = repeatSexGreetings[count % repeatSexGreetings.length]; var nextLine:Int = 0; for (i in 0...repeatSexGreeting.length) { tree[nextLine++] = [repeatSexGreeting[i]]; } /* * ensure the player starts with a normal cursor, just in case it was * zapped/lost/etc. This should be handled by accompanying dialog, but * the user might skip it. */ tree[nextLine++] = ["%cursor-normal%"]; tree[10000] = ["%cursor-normal%"]; } public function getReplayMinigame(tree:Array<Array<Object>>) { var count:Int = getTotalMinigames(); var replayMinigame:DenReplayMinigame = replayMinigames[count % replayMinigames.length]; var nextLine:Int = 0; for (i in 0...replayMinigame.preliminaryLines.length) { tree[nextLine++] = [replayMinigame.preliminaryLines[i]]; } tree[nextLine++] = [20, 40, 60]; nextLine = 20; tree[nextLine++] = [replayMinigame.gameLines[0]]; tree[nextLine++] = ["%den-game%"]; for (i in 1...replayMinigame.gameLines.length) { tree[nextLine++] = [replayMinigame.gameLines[i]]; } nextLine = 40; tree[nextLine++] = [replayMinigame.sexLines[0]]; tree[nextLine++] = ["%den-sex%"]; for (i in 1...replayMinigame.sexLines.length) { tree[nextLine++] = [replayMinigame.sexLines[i]]; } nextLine = 60; tree[nextLine++] = [replayMinigame.quitLines[0]]; tree[nextLine++] = ["%den-quit%"]; for (i in 1...replayMinigame.quitLines.length) { tree[nextLine++] = [replayMinigame.quitLines[i]]; } } public function getReplaySex(tree:Array<Array<Object>>) { var count:Int = getTotalMinigames() + PlayerData.denSexCount; var replaySex:DenReplaySex = replaySexes[count % replaySexes.length]; var nextLine:Int = 0; if (replaySex.preliminaryLines.length == 1) { tree[nextLine++] = ["%fun-longbreak%"]; tree[nextLine++] = [replaySex.preliminaryLines[0]]; } else { tree[nextLine++] = [replaySex.preliminaryLines[0]]; tree[nextLine++] = ["%fun-longbreak%"]; } for (i in 1...replaySex.preliminaryLines.length) { tree[nextLine++] = [replaySex.preliminaryLines[i]]; } tree[nextLine++] = [20, 40]; nextLine = 20; tree[nextLine++] = [replaySex.sexLines[0]]; tree[nextLine++] = ["%den-sex%"]; for (i in 1...replaySex.sexLines.length) { tree[nextLine++] = [replaySex.sexLines[i]]; } nextLine = 40; tree[nextLine++] = [replaySex.quitLines[0]]; tree[nextLine++] = ["%den-quit%"]; for (i in 1...replaySex.quitLines.length) { tree[nextLine++] = [replaySex.quitLines[i]]; } } public static function getTotalMinigames():Int { var total:Int = 0; for (i in 0...PlayerData.minigameCount.length) { total += PlayerData.minigameCount[i]; } return total; } public function getTooManyGames(tree:Array<Array<Object>>) { var nextLine:Int = 0; for (i in 0...tooManyGames.length) { tree[nextLine++] = [tooManyGames[i]]; } } public function getTooMuchSex(tree:Array<Array<Object>>) { var nextLine:Int = 0; for (i in 0...tooMuchSex.length) { tree[nextLine++] = [tooMuchSex[i]]; } } public function getGameGreeting(tree:Array<Array<Object>>, desc:String) { var nextLine:Int = 0; for (i in 0...gameGreeting.length) { var line:String = gameGreeting[i]; line = StringTools.replace(line, "<minigame>", desc); line = StringTools.replace(line, "<Minigame>", capitalize(desc)); tree[nextLine++] = [line]; } } public function getSexGreeting(tree:Array<Array<Object>>) { var nextLine:Int = 0; for (i in 0...sexGreeting.length) { tree[nextLine++] = [sexGreeting[i]]; } } } class DenReplayMinigame { public var preliminaryLines:Array<String>; public var gameLines:Array<String>; public var sexLines:Array<String>; public var quitLines:Array<String>; public function new(preliminaryLines:Array<String>, gameLines:Array<String>, sexLines:Array<String>, quitLines:Array<String>):Void { this.preliminaryLines = preliminaryLines; this.gameLines = gameLines; this.sexLines = sexLines; this.quitLines = quitLines; } } class DenReplaySex { public var preliminaryLines:Array<String>; public var sexLines:Array<String>; public var quitLines:Array<String>; public function new(preliminaryLines:Array<String>, sexLines:Array<String>, quitLines:Array<String>):Void { this.preliminaryLines = preliminaryLines; this.sexLines = sexLines; this.quitLines = quitLines; } }
argonvile/monster
source/DenDialog.hx
hx
unknown
6,543
package; import MmStringTools.*; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import openfl.utils.Object; /** * Class which handles logic for a single tree of dialog -- a single * conversation with a beginning, end and (optionally) a few choices along the * way. * * As input, this takes a 2-dimensional array of input. The 2-dimensional looks * something like this: * * tree[0] = ["#grov04#Say! What's your favorite part of these puzzles anyways?"]; * tree[1] = ["%disable-skip%"]; * tree[2] = [10, 20, 30, 40]; * tree[10] = ["Our\nconversations"]; * tree[11] = ["#grov00#Ah! Our conversations? Ours specifically? Why that's so flattering, thank you so much... And yet..."]; * tree[12] = ["#grov10#It also places a tremendous burden on me to say something interesting! Ummm..."]; * tree[13] = ["#grov03#Life is about the destination... not about the journey."]; * tree[14] = [60]; * tree[20] = ["Solving the\npuzzles"]; * tree[21] = ["#grov02#Ah yes! There's nothing quite like working through a nice puzzle."]; * tree[22] = ["#grov05#Of course, hitting the little button at the end doesn't mean much of anything! It's about figuring it out, those little leaps of logic along the way."]; * tree[23] = ["#grov03#Just like how life is about the destination... not about the journey."]; * tree[24] = [60]; * * Each line in the input array can be one of the following things: * * 1. A line of dialog: "#grov04#Say! What's your favorite part...?" * * This represents a line of dialog. Lines of dialog should always start * with a six-character code which includes a prefix like "grov" and a * facial expression like "04". The number 04 is an index into the chat * asset, "grovyle-chat.png" in this case. * * 2. A decision point for several branches of dialog: [10, 20, 30, 40] * * This represents several choices the player can decide between; the * dialog can branch to index 10, 20, 30 or 40 in the dialog array. That * index in the dialog array will be shown to the player literally, so it * should always be a dialog branch. * * 3. A redirect: [60] * * This represents a redirect to a new branch of dialog; in this case, line * 60. This can be used when multiple branches of dialog result in the same * dialog, or could be used to deliberately repeat dialog. * * 4. A dialog branch: "Our\nconversations" * * This represents a choice the player can make, which is typically * followed by some dialog -- but could also be followed by a redirect, if * multiple choices result in identical dialog with no side-effects * * 5. Null * * Any indexes of the array which are null or unassigned will cause the * dialog to terminate, even if there's additional dialog later in the * array. So in other words you might have a flow of dialog which progresses * from lines 10-15, but if line 13 is unassigned then the dialog will * terminate after line 12. * * 6. A command: "%disable-skip%" * * Lines starting with a percent sign represent internal commands which * shouldn't be seen by the player. They might do things like turn light on * and off, manipulate bugs during tutorials, or make the pokemon adopt * different poses or run away. * * DialogTree's invokers can receive notification of these commands via a * callback mechanism. * * The DialogTree class will show the dialog starting at index[0], followed by * index[1], [2] and so on, until a null index is reached at which point the * dialog terminates. * * The player can choose to skip dialog, which will usually cause the dialog to * immediately terminate without consequence. However, sometimes skipping the * dialog will lead to consequences or possibly even additional dialog -- for * example, there might be a dialog sequence where a Pokemon will give a player * $1,000 he's owed, in which case we don't want the player to be robbed * because they skipped the dialog. So when the player skips dialog we skip to * index[10,000] in the array. This will usually be null and end the dialog * sequence, but that's where you can put commands or behavior you want to * occur when the player hits the skip button. */ class DialogTree implements IFlxDestroyable { var _tree:Array<Array<Object>> = new Array<Array<Object>>(); var _dialogger:Dialogger; var _currentLine:Int = 0; var _dialogging:Bool = false; /** * The dialogTreeCallback is invoked with any lines starting with a '%'. * If the callback returns a non-null string, that string will be shown as * dialog to the user */ var _dialogTreeCallback:String->String; /** * Initializes a DialogTree with the specified dialog and callback * * @param dialogger * @param Tree * @param DialogTreeCallback */ public function new(dialogger:Dialogger, Tree:Array<Array<Object>>, ?DialogTreeCallback:String->String) { this._dialogger = dialogger; this._tree = Tree; this._dialogTreeCallback = DialogTreeCallback; } public function destroy():Void { _tree = null; } /** * Launches the dialog sequence */ public function go() { _dialogger.reset(); // reset to avoid displaying two sets of dialog simultaneously _dialogging = true; while (_tree[_currentLine] != null && _tree[_currentLine].length == 1) { if (Std.isOfType(_tree[_currentLine][0], Int)) { // redirect _currentLine = cast(_tree[_currentLine][0], Int); } else if (Std.isOfType(_tree[_currentLine][0], String) && Std.string(_tree[_currentLine][0]).substring(0, 1) == "%") { var lineStr:String = _tree[_currentLine][0]; // command if (lineStr == "%enable-skip%") { _dialogger.setSkipEnabled(true); } else if (lineStr == "%disable-skip%") { _dialogger.setSkipEnabled(false); } else if (StringTools.startsWith(lineStr, "%prompts-y-offset")) { _dialogger._promptsYOffset = Std.parseInt(substringBetween(lineStr, "%prompts-y-offset", "%")); } else if (lineStr == "%prompts-dont-cover-clues%") { _dialogger._promptsDontCoverClues = true; } else if (lineStr == "%prompts-dont-cover-7peg-clues%") { _dialogger._promptsDontCover7PegClues = true; } else if (StringTools.startsWith(lineStr, "%jumpto-")) { var mark:String = substringBetween(lineStr, "%jumpto-", "%"); jumpTo("%mark-" + mark + "%", -1); } else if (_dialogTreeCallback != null) { var result:String = _dialogTreeCallback(lineStr); if (result != null) { showDialog(result); return; } } _currentLine++; } else { // something normal break; } } if (_tree[_currentLine] == null) { _dialogging = false; if (_dialogTreeCallback != null) { _dialogTreeCallback(""); } return; } showDialog(_tree[_currentLine][0]); } function showDialog(Text:String):Void { if (_tree[_currentLine + 1] != null && _tree[_currentLine + 1].length > 1) { // choice var choices = new Array<String>(); for (choice in _tree[_currentLine + 1]) { if (_tree[cast (choice, Int)] == null) { // error; dialog tree has a bad link in it choices.push("(" + choice+")"); } else { choices.push(_tree[cast (choice, Int)][0]); } } _dialogger.dialog(Text, callback, choices); } else { // message _dialogger.dialog(Text, callback, null); } } public function callback(choice:Int):Void { if (choice == Dialogger.SKIP) { _currentLine = 9999; } else if (choice >= 0) { _currentLine = cast (_tree[_currentLine + 1][choice], Int); } _currentLine++; go(); } /** * Replace some text on a given dialog line. This is especially useful when * modifying a dialog array to account for genders or player decisions. * * @param Tree dialog tree on which to perform the replacement * @param index dialog tree index on which to perform the replacement * @param sub old word/phrase to be replaced * @param by new word/phrase to act as a replacement */ public static function replace(Tree:Array<Array<Object>>, index:Int, sub:String, by:String) { if (Tree[index] != null && Std.isOfType(Tree[index][0], String)) { Tree[index][0] = StringTools.replace(Tree[index][0], sub, by); } } public static function durationToString(durationInSeconds:Float) { var durationMap:Map<Int, String> = [ 1 => "one second", 2 => "two seconds", 3 => "three seconds", 5 => "five seconds", 10 => "ten seconds", 20 => "twenty seconds", 30 => "thirty seconds", 1 * 60 => "one minute", 2 * 60 => "two minutes", 3 * 60 => "three minutes", 5 * 60 => "five minutes", 10 * 60 => "ten minutes", 15 * 60 => "fifteen minutes", 20 * 60 => "twenty minutes", 30 * 60 => "thirty minutes", 45 * 60 => "forty-five minutes" ]; var minDuration:Int = 60 * 60; var minDurationString:String = "one hour"; for (key in durationMap.keys()) { if (key >= durationInSeconds && key < minDuration) { minDuration = key; minDurationString = durationMap[key]; } } return minDurationString; } /** * Shifts a block of dialog around within an array. For example, lines * 100-200 in a dialog array might represents a certain branch of dialog, * but you need to move all of that dialog to lines 150-250. This method * could be used to shift those lines later in the dialog array. * * @param tree dialog array to manipulate * @param firstLine first line which needs to be moved * @param lastLine last line which needs to be moved * @param amount how far should the lines be moved (positive integer) * @return the "tree" input parameter */ public static function shift(tree:Array<Array<Object>>, firstLine:Int, lastLine:Int, amount:Int):Array<Array<Object>> { var i:Int = lastLine; while (i >= firstLine) { // move item down... var item:Array<Object> = tree[i - amount]; tree[i] = tree[i - amount]; tree[i - amount] = null; i--; // update any references... if (item != null) { for (j in 0...item.length) { if (Std.isOfType(item[j], Int)) { item[j] = cast(item[j], Int) + amount; } } } } return tree; } /** * Prepends a dialog tree with another dialog tree. For example you might * have one dialog tree where Buizel talks about how he's happy to see the * player, and another dialog tree where Grovyle explains how ranked mode * works. This method can be used to merge the two. * * This method also does its best to handle ugly scenarios such as if both * trees have "skip" consequences. * * @param beforeTree dialog array which should go before the other * @param tree dialog array which should go after the other * @return merged dialog array */ public static function prepend(beforeTree:Array<Array<Object>>, tree:Array<Array<Object>>):Array<Array<Object>> { var newTree:Array<Array<Object>> = []; var j = 0; while (tree[j] != null && Std.isOfType(tree[j][0], String) && cast(tree[j][0], String).substring(0, 1) == "%" && cast(tree[j][0], String) != "%noop%") { // prepend "special stuff" that happens before chats -- such as putting on clothes, characters entering newTree.push(tree[j]); j++; } for (i in 0...Std.int(Math.min(9999, beforeTree.length))) { var item:Array<Object> = beforeTree[i]; // prepend normal dialog if (item != null) { for (i in 0...item.length) { if (Std.isOfType(item[i], Int)) { item[i] = cast(item[i], Int) + j; } } newTree[i + j] = beforeTree[i]; } } for (i in 1...Std.int(Math.min(9999, beforeTree.length + 1))) { // add prepended dialog links. prepended dialog links to [1000], which is where appended dialog starts if (beforeTree[i] == null && beforeTree[i - 1] != null) { newTree[i + j] = [1000]; } } for (i in 10000...beforeTree.length) { // add prepended "skip" stuff. if (beforeTree[i] != null) { newTree[i] = beforeTree[i]; } } for (i in j...Std.int(Math.min(8999, tree.length))) { // add normal dialog var item:Array<Object> = tree[i]; if (item != null) { for (i in 0...item.length) { if (Std.isOfType(item[i], Int)) { item[i] = cast(item[i], Int) + (1000 - j); } } newTree[i + 1000 - j] = tree[i]; } } var skipIndex:Int = 10000; while (newTree[skipIndex] != null) { skipIndex++; } for (i in 10000...tree.length) { // add normal "skip" stuff if (tree[i] != null) { newTree[skipIndex++] = tree[i]; } } return newTree; } /** * Locates a dialog line in a dialog array. This does an exact string * match, the entire dialog line must match the entire input string. * * @param Tree dialogTree to search * @param LineText line to search for * @return */ public static function getIndex(Tree:Array<Array<Object>>, LineText:String):Int { for (i in 0...Tree.length) { if (Tree[i] != null && Tree[i][0] == LineText) { return i; } } return -1; } /** * Jumps to a specific dialog line in a dialog array. This does an exact * string match, the entire dialog line must match the entire input string. * * @param LineText line text to jump to * @param offset after jumping, how many lines to adjust by. Can be a * positive or negative integer */ public function jumpTo(LineText:String, ?offset:Int = 0):Void { var index:Int = getIndex(_tree, LineText); if (index == -1) { return; } _currentLine = index + offset; } /** * Returns true if the tree is currently showing dialog to the player. * * @param tree tree to inspect; can be null * @return true if the tree is showing dialog to the player */ public static function isDialogging(tree:DialogTree):Bool { return tree != null && tree._dialogging; } /** * Appends a line to the "skip" section of the active dialog; the series of * lines starting at line 10,000 * * @param line line to append */ public function appendSkipToActiveDialog(line:String) { appendSkip(_tree, line); } /** * Appends a line to the "skip" section of the specified dialog tree; the * series of lines starting at line 10,000 * * @param tree tree to append to * @param line line to append */ public static function appendSkip(tree:Array<Array<Object>>, line:String) { var skipIndex:Int = 10000; while (tree[skipIndex] != null) { skipIndex++; } tree[skipIndex] = [line]; } }
argonvile/monster
source/DialogTree.hx
hx
unknown
15,249
package; import flixel.addons.text.FlxTypeText; import flixel.graphics.FlxGraphic; import openfl.geom.ColorTransform; import openfl.geom.Point; import poke.abra.AbraResource; import poke.buiz.BuizelResource; import flash.display.BlendMode; import flash.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.group.FlxGroup; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.ui.FlxButton; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.math.FlxMath; import flixel.util.FlxSpriteUtil; import poke.grim.GrimerResource; import poke.grov.GrovyleResource; import poke.hera.HeraResource; import poke.luca.LucarioResource; import poke.magn.MagnResource; import poke.rhyd.RhydonResource; import poke.sand.SandslashResource; import poke.sexy.SexyState; /** * Graphics and behavior for the onscreen dialog. This includes sprites and * logic for the Pokemon face, the dialog they're saying, the player's choices * and the skip button. * * This class only knows how to show a single dialog event and invoke * callbacks; it does not have any logic about going through an entire * sequential set of dialog. */ class Dialogger extends FlxGroup { public static var SKIP:Int = -99; private static var MAX_CLICK_TIME:Float = 0.35; // a message has to be finished for a quarter second before you can skip it private static var MIN_ADVANCE_TIME:Float = 0.25; private static var PADDING:Int = 12; private var _replacedText:Map<String, String> = new Map<String, String>(); private var _characterRect:RoundedRectangle; private var _character:FlxSprite; private var _gloveSprite:FlxSprite; public var _textRect:RoundedRectangle; private var _typeText:FlxTypeText; public var _state:Dynamic; private var _selectedChoiceRect:FlxSprite; private var _promptGroup:FlxTypedGroup<FlxSprite>; private var _skipButton:FlxButton; // should be arrays var _promptTexts:Array<FlxText>; var _promptRectangles:Array<RoundedRectangle>; // user must click and hold to make a choice var _mouseHoldTime:Float = 0; // we ignore clicks if they're less than a tenth of a second apart var _clickEnableTimer:Float = 0; // we don't let the user advance text unless it's been a half second or so var _advanceEnableTimer:Float = -MIN_ADVANCE_TIME; var _prompts:Array<String> = new Array<String>(); var _completeCallback:Dynamic; public var _handledClick:Bool = false; public var _clickEnabled:Bool = true; var _skipEnabled:Bool = true; public var _promptsYOffset:Int = 0; public var _promptsDontCoverClues:Bool = false; public var _promptsDontCover7PegClues:Bool = false; // when paused public var _canDismiss:Bool = true; public var _promptsTransparent:Bool = false; private var clickedPromptRectangle:RoundedRectangle; /** * debug flag can be enabled to trace through state-based glitches, like * if the dialogger is reacting to mouse clicks when it shouldn't, things * like that */ private var debug:Bool = false; private var debugText:FlxText = null; public function new() { super(); _characterRect = new RoundedRectangle(); _characterRect.visible = false; _characterRect.relocate(3, FlxG.height - 78, 77, 75, 0xff000000, 0xeeffffff); add(_characterRect); _character = new FlxSprite(_characterRect.x + 2, _characterRect.y + 2); _character.visible = false; add(_character); _textRect = new RoundedRectangle(); _textRect.visible = false; _textRect.relocate(82, FlxG.height - 78, FlxG.width - 85, 75, 0xff000000, 0xeeffffff); add(_textRect); _typeText = new FlxTypeText(_textRect.x + 4, _textRect.y - 1, FlxG.width - 106 - 8, "", 20); _typeText.visible = false; _typeText.color = FlxColor.BLACK; _typeText.font = AssetPaths.hardpixel__otf; add(_typeText); _promptGroup = new FlxTypedGroup<FlxSprite>(); add(_promptGroup); _promptTexts = []; _promptRectangles = []; _selectedChoiceRect = new FlxSprite(); _selectedChoiceRect.visible = false; #if flash _selectedChoiceRect.blend = BlendMode.INVERT; #end _selectedChoiceRect.makeGraphic(FlxG.width, FlxG.height); add(_selectedChoiceRect); _skipButton = SexyState.newBackButton(skip, AssetPaths.skip_button__png); _skipButton.y -= 76; _skipButton.x += 2; _skipButton.visible = false; add(_skipButton); if (debug) { var debugSize:Int = 16; debugText = new FlxText(-10, FlxG.height - debugSize - 10, FlxG.width, "null", debugSize); debugText.color = FlxColor.GREEN; debugText.alignment = "right"; add(debugText); } setReplacedText("<name>", PlayerData.name); setState(null, null); } private function setState(state:Dynamic, stateDesc:String) { _state = state; if (debug) { trace("state=" + stateDesc); debugText.text = (stateDesc == null ? "null" : stateDesc); } } public function skip():Void { if (_canDismiss) { _promptsDontCoverClues = false; _promptsDontCover7PegClues = false; _typeText.completeCallback = null; _typeText.skip(); dismissDialog(SKIP); } } override public function destroy():Void { super.destroy(); _replacedText = null; _characterRect = FlxDestroyUtil.destroy(_characterRect); _character = FlxDestroyUtil.destroy(_character); _gloveSprite = FlxDestroyUtil.destroy(_gloveSprite); _textRect = FlxDestroyUtil.destroy(_textRect); _typeText = FlxDestroyUtil.destroy(_typeText); _state = null; _selectedChoiceRect = FlxDestroyUtil.destroy(_selectedChoiceRect); _promptGroup = FlxDestroyUtil.destroy(_promptGroup); _skipButton = FlxDestroyUtil.destroy(_skipButton); _promptTexts = FlxDestroyUtil.destroyArray(_promptTexts); _promptRectangles = FlxDestroyUtil.destroyArray(_promptRectangles); _prompts = null; _completeCallback = null; debugText = FlxDestroyUtil.destroy(debugText); clickedPromptRectangle = FlxDestroyUtil.destroy(clickedPromptRectangle); } override public function update(elapsed:Float):Void { if (_state == paused) { // don't update, don't increment timers, don't do anything return; } super.update(elapsed); _handledClick = false; _clickEnableTimer += elapsed; if (_state != null && !_skipButton.pressed) { _state(elapsed); } if (_skipButton.visible && FlxG.mouse.justPressed && _skipButton.pressed) { _handledClick = true; } } public function showingDialog(elapsed:Float):Void { if (FlxG.mouse.justPressed && _clickEnableTimer >= 0 && _clickEnabled) { _handledClick = true; _clickEnableTimer = -0.1; _typeText.skip(); } } public function setSkipEnabled(enabled:Bool):Void { _skipEnabled = enabled; } public function skippedDialog(elapsed:Float):Void { } public function isPrompting():Bool { return _state == promptingDialog; } public function promptingDialog(elapsed:Float):Void { if (FlxG.mouse.justPressed && _clickEnableTimer >= 0 && _clickEnabled) { _handledClick = true; _clickEnableTimer = -0.1; _selectedChoiceRect.visible = true; clickedPromptRectangle = findClickedPromptRectangle(); } if (FlxG.mouse.pressed && _selectedChoiceRect.visible && clickedPromptRectangle != null) { _mouseHoldTime += elapsed; FlxSpriteUtil.fill(_selectedChoiceRect, FlxColor.TRANSPARENT); var maxWidth = clickedPromptRectangle.width - 4; var width = Math.min(maxWidth, maxWidth * _mouseHoldTime / MAX_CLICK_TIME); var selectedChoiceRectColor = FlxColor.BLACK; #if flash _selectedChoiceRect.blend = BlendMode.INVERT; selectedChoiceRectColor = FlxColor.WHITE; #end FlxSpriteUtil.drawRect(_selectedChoiceRect, Std.int(clickedPromptRectangle.x + 2), Std.int(clickedPromptRectangle.y + 2), Std.int(width), Std.int(clickedPromptRectangle.height - 4), selectedChoiceRectColor); if (_mouseHoldTime >= MAX_CLICK_TIME && _canDismiss) { var choiceIndex:Int = _promptRectangles.indexOf(clickedPromptRectangle); dismissDialog(choiceIndex); } } else { _mouseHoldTime = 0; _selectedChoiceRect.visible = false; } } /** * Resets the dialogger's internal state, rendering all prompts and dialog * invisible */ public function reset() { _mouseHoldTime = 0; _characterRect.visible = false; _character.visible = false; _textRect.visible = false; _typeText.visible = false; _selectedChoiceRect.visible = false; _skipButton.visible = false; _promptGroup.clear(); _promptRectangles.splice(0, _promptRectangles.length); _promptTexts.splice(0, _promptTexts.length); if (_prompts != null) { _prompts.splice(0, _prompts.length); } setState(null, null); } public function dismissingDialog(elapsed:Float):Void { _advanceEnableTimer += elapsed; if (FlxG.mouse.justPressed && _clickEnableTimer >= 0 && _advanceEnableTimer >= 0 && _clickEnabled && _canDismiss) { _handledClick = true; dismissDialog(-1); } } private function findClickedPromptRectangle():RoundedRectangle { var closestRectangle:RoundedRectangle = null; var minDistance:Float = 10000; for (promptRectangle in _promptRectangles) { var distance:Float = distanceFromRectToMouse(new Rectangle(promptRectangle.x, promptRectangle.y, promptRectangle.width, promptRectangle.height)); if (distance < minDistance) { minDistance = distance; closestRectangle = promptRectangle; } } return closestRectangle; } function dismissDialog(result:Int):Void { _clickEnableTimer = -0.1; _advanceEnableTimer = -MIN_ADVANCE_TIME; reset(); if (_completeCallback != null) { _completeCallback(result); } } function setVisible(visible:Bool):Void { for (member in members) { if (member == null) { continue; } if (Std.isOfType(member, FlxSprite)) { var memberSprite:FlxSprite = cast member; memberSprite.visible = visible; } } _selectedChoiceRect.visible = false; if (_skipButton.visible && !_skipEnabled) { _skipButton.visible = false; } } /** * Distance from rectangle to mouse. Returns 0 for any point within the rectangle. */ public function distanceFromRectToMouse(rect:Rectangle):Float { var minDist:Int = 0x0fffffff; var point1:FlxPoint = FlxG.mouse.getWorldPosition(); var point0:FlxPoint = new FlxPoint(0, 0); if (point1.y < rect.top) { point1.y += rect.top - point1.y; } else if (point1.y > rect.bottom) { point1.y += point1.y - rect.bottom; } if (point1.x < rect.left) { point1.x += rect.left - point1.x; } else if (point1.x > rect.right) { point1.x += point1.x - rect.right; } return point1.distanceTo(point0); } public function dialog(Text:String, CompleteCallback:Int->Void, Prompts:Array<String>=null) { _completeCallback = CompleteCallback; _prompts = Prompts; _characterRect.visible = true; _character.visible = true; _textRect.visible = true; _typeText.visible = true; if (_skipEnabled) { _skipButton.visible = true; } for (from in _replacedText.keys()) { Text = StringTools.replace(Text, from, _replacedText[from]); } Text = StringTools.replace(Text, "&lt;", "<"); Text = StringTools.replace(Text, "&gt;", ">"); if (!PlayerData.profanity) { Text = MmStringTools.bowdlerize(Text, "fuck"); Text = MmStringTools.bowdlerize(Text, "shit"); Text = MmStringTools.bowdlerize(Text, "cunt"); } if (Text.substring(0, 1) == "#") { if (Text.substring(1, 5) == "self") { // big... _character.visible = false; _characterRect.visible = false; _textRect.relocate(4, FlxG.height - 78, FlxG.width - 10, 75, 0xff000000, 0xeeffffff); _typeText.setPosition(_textRect.x + 4, _textRect.y - 1); _typeText.fieldWidth = FlxG.width - 8; } else { // normal size... _character.visible = true; _characterRect.visible = true; _textRect.relocate(82, FlxG.height - 78, FlxG.width - 85, 75, 0xff000000, 0xeeffffff); _typeText.setPosition(_textRect.x + 4, _textRect.y - 1); _typeText.fieldWidth = FlxG.width - 106 - 8; } if (Text.substring(1, 5) == "abra") { _character.loadGraphic(AbraResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.abra_talk__wav, 0.08)]; } else if (Text.substring(1, 5) == "buiz") { _character.loadGraphic(BuizelResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.buizel_talk__wav, 0.08)]; } else if (Text.substring(1, 5) == "grov") { _character.loadGraphic(GrovyleResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.grov_talk__wav, 0.12)]; } else if (Text.substring(1, 5) == "hera") { _character.loadGraphic(HeraResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.hera_talk__wav, 0.08)]; } else if (Text.substring(1, 5) == "sand") { _character.loadGraphic(SandslashResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.sand_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "RHYD" || Text.substring(1, 5) == "rhyd") { _character.loadGraphic(RhydonResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.rhyd_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "smea") { _character.loadGraphic(AssetPaths.smear_chat__png, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.smea_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "kecl") { _character.loadGraphic(AssetPaths.kecl_chat__png, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.kecl_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "magn") { _character.loadGraphic(MagnResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.magn_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "luca") { _character.loadGraphic(LucarioResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.luca_talk__wav, 0.25)]; } else if (Text.substring(1, 5) == "grim") { _character.loadGraphic(GrimerResource.chat, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.grim_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "char") { _character.loadGraphic(AssetPaths.char_chat__png, true, 73, 71); _typeText.sounds = [FlxG.sound.load(AssetPaths.grim_talk__wav, 0.10)]; } else if (Text.substring(1, 5) == "misc") { // #misc#: random objects that might be displayed in chat _character.loadGraphic(AssetPaths.misc_chat__png, true, 73, 71); } else if (Text.substring(1, 5) == "glov") { if (_gloveSprite == null) { _gloveSprite = new FlxSprite(); _gloveSprite.loadGraphic(AssetPaths.empty_chat__png, true, 73, 71, true); var gloveGraphic:FlxGraphic = FlxG.bitmap.add(AssetPaths.glove_chat__png, true); gloveGraphic.bitmap.threshold(gloveGraphic.bitmap, new Rectangle(0, 0, gloveGraphic.bitmap.width, gloveGraphic.bitmap.height), new Point(0, 0), '==', 0xffffffff, PlayerData.cursorFillColor); gloveGraphic.bitmap.threshold(gloveGraphic.bitmap, new Rectangle(0, 0, gloveGraphic.bitmap.width, gloveGraphic.bitmap.height), new Point(0, 0), '==', 0xff000000, PlayerData.cursorLineColor); _gloveSprite.pixels.draw(gloveGraphic.bitmap, null, new ColorTransform(1, 1, 1, PlayerData.cursorMaxAlpha, 0, 0, 0, 0)); } _character.loadGraphicFromSprite(_gloveSprite); _typeText.sounds = [FlxG.sound.load(AssetPaths.abra_talk__wav, 0.08)]; } else if (Text.substring(1, 5) == "self") { _typeText.sounds = [FlxG.sound.load(AssetPaths.abra_talk__wav, 0.08)]; } else { // #zzzz#: empty box _character.loadGraphic(AssetPaths.empty_chat__png, true, 73, 71); } _character.animation.frameIndex = Std.parseInt(Text.substring(5, 7)); if (Text.substring(1, 5) == "RHYD") { Text = Text.toUpperCase(); } Text = Text.substring(8); } _typeText.resetText(Text); _typeText.finishSounds = true; _typeText.setTypingVariation(0.5); _typeText.start(0.020, true); _typeText.completeCallback = dialogDone; if (_state == paused) { setVisible(false); } else { setState(showingDialog, "showingDialog"); } } public function dialogDone() { if (_prompts == null) { if (_state != skippedDialog) { setState(dismissingDialog, "dismissingDialog"); } } else { var x = 0; for (prompt in _prompts) { for (from in _replacedText.keys()) { prompt = StringTools.replace(prompt, from, _replacedText[from]); } if (!PlayerData.profanity) { prompt = MmStringTools.bowdlerize(prompt, "fuck"); prompt = MmStringTools.bowdlerize(prompt, "shit"); prompt = MmStringTools.bowdlerize(prompt, "cunt"); } var promptText:FlxText = new FlxText(x, FlxG.height / 2 - 50, 0, prompt, 20); promptText.alignment = FlxTextAlign.CENTER; promptText.color = FlxColor.BLACK; promptText.font = AssetPaths.hardpixel__otf; promptText.y -= promptText.textField.height / 2; var promptRectangle:RoundedRectangle = new RoundedRectangle(); promptRectangle.relocate(Std.int(promptText.x - 4 - PADDING), Std.int(promptText.y + 2 - PADDING), Std.int(promptText.textField.textWidth + 12 + PADDING * 2), Std.int(promptText.textField.textHeight + PADDING * 2), 0xff000000, 0xeeffffff); _promptGroup.add(promptRectangle); _promptRectangles.push(promptRectangle); _promptGroup.add(promptText); _promptTexts.push(promptText); x += Std.int(promptRectangle.width + 6); } x -= 14 + 2 * PADDING; if (_promptsDontCoverClues) { arrangeIntoTwoRows(x, 512); } else if (_promptsDontCover7PegClues || x > 736) { arrangeIntoTwoRows(x); } else { for (promptItem in _promptGroup) { promptItem.x += (FlxG.width - x) / 2; promptItem.y += _promptsYOffset; } } _promptsYOffset = 0; _promptsDontCoverClues = false; _promptsDontCover7PegClues = false; if (_state != skippedDialog) { setState(promptingDialog, "promptingDialog"); } } } private function arrangeIntoTwoRows(x:Int, rightEdge:Int = 768) { // need two rows var topRowCount:Int = Std.int(_prompts.length / 2) * 2; var lastItemInRow0:FlxSprite = _promptGroup.members[topRowCount - 1]; var firstItemInRow1:FlxSprite = _promptGroup.members[topRowCount + 1]; var a:Int = Std.int(lastItemInRow0.x + lastItemInRow0.width); var b:Int = Std.int(firstItemInRow1.x); for (i in 0...topRowCount) { _promptGroup.members[i].x += (rightEdge - a) / 2; _promptGroup.members[i].y -= 65; } for (i in topRowCount..._promptGroup.members.length) { _promptGroup.members[i].x += (rightEdge - x - b) / 2; _promptGroup.members[i].y += 85; } } public function paused(elapsed:Float) { } /** * Sometimes we might want to pause the dialog while things are happening * -- like if bugs are jumping into their clue boxes or something is * happening during a puzzle tutorial. */ public function pause() { setState(paused, "paused"); setVisible(false); _clickEnabled = false; } public function unpause() { setVisible(true); _clickEnabled = true; } public function setReplacedText(From:String, To:String) { _replacedText[From] = To; } public function getReplacedText(From:String):String { return _replacedText[From]; } }
argonvile/monster
source/Dialogger.hx
hx
unknown
20,035
package; import flixel.FlxG; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; /** * This class provides a way to schedule events to happen in the future. * * It also guarantees events happen in the same order they were scheduled, even * if there's some kind of a performance hiccup where they all occur in the * same frame. */ class EventStack { public var _events:Array<Event> = []; private var _eventIndex:Int = 0; public var _time:Float = 0; public var _alive:Bool = false; public function new() { } /** * Remove all events */ public function reset():Void { _events.splice(0, _events.length); _time = 0; _eventIndex = 0; _alive = false; } public function addEvent(event:Event):Void { if (event.time < _time) { // scheduling events in the past is problematic event.time = _time; } var i:Int = _events.length; while (i > 0 && _events[i - 1].time > event.time) { i--; } _events.insert(i, event); if (!_alive) { _alive = true; _eventIndex = i; } } public function update(elapsed:Float):Void { if (!_alive) { return; } _time += elapsed; while (_eventIndex < _events.length && _events[_eventIndex].time <= _time) { if (_events[_eventIndex].callback != null) { _events[_eventIndex].callback(_events[_eventIndex].args); } // firing an event can remove an event; make sure it's still necessary to increment if (_events[_eventIndex] != null && _events[_eventIndex].time <= _time) { _eventIndex++; } } if (_eventIndex >= _events.length) { _alive = false; } } public static function eventPlaySound(params:Array<Dynamic>):Void { var volume:Float = 1.0; if (params.length >= 2) { volume = params[1]; } SoundStackingFix.play(params[0], volume); } public function isEventScheduled(callback:Dynamic->Void):Bool { for (i in _eventIndex..._events.length) { if (_events[i].callback == callback) { return true; } } return false; } public function removeEvent(callback:Dynamic->Void):Bool { var i:Int = _events.length - 1; while (i >= 0) { if (_events[i].callback == callback) { _events.splice(i, 1); if (_eventIndex > i) { _eventIndex--; } } i--; } return false; } } typedef Event = { time:Float, callback:Dynamic->Void, ?args:Array<Dynamic> }
argonvile/monster
source/EventStack.hx
hx
unknown
2,456
package; import flixel.tweens.FlxTween; import flixel.util.FlxDestroyUtil; /** * Utility classes for working with FlxTwen objects */ class FlxTweenUtil { /** * You sometimes see artifacts when rapidly tweening back and forth. This "retween" method helps to avoid that. */ public static function retween(Tween:FlxTween, Object:Dynamic, Values:Dynamic, Duration:Float = 1, ?Options:TweenOptions):FlxTween { if (Tween != null) { Tween.cancel(); } return FlxTween.tween(Object, Values, Duration, Options); } public static function cancel(Tween:FlxTween) { if (isActive(Tween)) { Tween.cancel(); } } public static function isActive(Tween:FlxTween) { return Tween != null && Tween.active; } /** * FlxDestroyUtil.destroy() will simply call FlxTween.destroy(), which will * not cancel the tween. This means the tween will continue run, despite * being destroyed, and cause a NullPointerException. * * FlxTweenUtil.destroy() cancels a tween, and then destroys it. */ static public function destroy<T:FlxTween>(alphaTween:Null<FlxTween>):T { cancel(alphaTween); return FlxDestroyUtil.destroy(alphaTween); } }
argonvile/monster
source/FlxTweenUtil.hx
hx
unknown
1,206
package; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.effects.particles.FlxParticle; import kludge.BetterFlxRandom; /** * Graphics and business logic for the blue gems which pop out of chests during * puzzles and minigames */ class Gem extends FlxParticle { public var z:Float; public var groundZ:Float = 0; public var zVelocity:Float; public var zAccel:Float = -720; public function new() { super(); loadGraphic(AssetPaths.gems__png, true, 24, 24); setFacingFlip(FlxObject.LEFT, false, false); setFacingFlip(FlxObject.RIGHT, true, false); } override public function update(elapsed:Float):Void { super.update(elapsed); offset.set(12, 6 + z); if (z == groundZ && animation.frameIndex < 4) { animation.frameIndex += 4; drag.x = 160; drag.y = 160; } z = Math.max(groundZ, z + zVelocity * elapsed); zVelocity = Math.max( -1000, zVelocity + zAccel * elapsed); } override public function onEmit():Void { super.onEmit(); animation.frameIndex = FlxG.random.int(0, 3); facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); } override public function reset(X:Float, Y:Float):Void { super.reset(X, Y); drag.x = 0; drag.y = 0; } }
argonvile/monster
source/Gem.hx
hx
unknown
1,290
package; import MmStringTools.*; import critter.Critter; import critter.Critter.CritterColor; import flixel.FlxG; import kludge.BetterFlxRandom; import openfl.utils.Object; import poke.abra.AbraWindow; import puzzle.PuzzleState; /** * Pokemon have about 4 things they say when you click the help button, like * "What do you need?", "Let me ask Abra for a hint," and "See you later!" * * This class acts as a data model for all the phrases a particular Pokemon * says when you press the help button. */ class HelpDialog { private var tree:Array<Array<Object>>; public var greetings:Array<Object>; public var goodbyes:Array<Object>; public var neverminds:Array<Object>; public var hints:Array<Object>; public var abraIntro:Array<Object> = ["#abra04#What's that? ...Oh, I see.", "#abra04#Hmm? Were you looking for me?", "#abra04#It's not too difficult is it? Oh, I understand."]; public var counter:Int = 20; private var hintCounter:Int = 160; private var puzzleState:PuzzleState; public function new(tree:Array<Array<Object>>, puzzleState:PuzzleState) { this.tree = tree; this.puzzleState = puzzleState; } public function help():Void { var endIndex:Int = 10000; while (tree[endIndex] != null) { endIndex++; } if (puzzleState._pokeWindow._partAlpha == 0) { // pokemon's not around; they shouldn't talk greetings = [ "#self00#(Hmmm. Nobody's around. Should I ask anyways?)", "#self00#(Where did they go? I wonder if they'll hear me.)", "#self00#(I don't see anyone to talk to, but I guess I'll try anyway.)", ]; goodbyes = [ "#self00#(This isn't very much fun by myself.)", "#self00#(This is kind of boring without any Pokemon around.)", "#self00#(I'll go see if someone else is around.)", ]; neverminds = [ "#self00#(...I guess I'll need to do this one on my own.)", "#self00#(...Being alone should make it easier to focus, but it's actually distracting me somehow.)", "#self00#(...When are they coming back? I guess I may as well solve this puzzle first.)", ]; hints = [ "#self00#(I wonder if I can summon Abra's help through sheer force of will.)", "#self00#(Abra's telepathic... I wonder if " + (PlayerData.abraMale ? "he":"she") + " realizes I'm struggling with this puzzle?)", "#self00#(I'll just think about hints as hard as I can... Hints... Hints... Hints...)", ]; } if (puzzleState._askedHintCount > 0) { // we've asked for a hint already, skip the part where we run and get him skipGettingAbra(); } tree[0] = [FlxG.random.getObject(greetings)]; tree[1] = [100, 120, 140]; tree[100] = [FlxG.random.getObject(["I think\nI'm done\nfor now", "I'm gonna\ncall it\nquits", "Sorry, I'm\ngonna take\noff"])]; tree[101] = ["%disable-skip%"]; tree[102] = ["%quit-soon%"]; tree[103] = [FlxG.random.getObject(goodbyes)]; tree[104] = ["%quit%"]; tree[120] = [FlxG.random.getObject(["Nevermind", "Oops,\nsorry", "It's\nnothing"])]; tree[121] = [FlxG.random.getObject(neverminds)]; tree[140] = [FlxG.random.getObject(["Can you\ngive me\na hint?", "I could\nuse a hint", "I'm stuck,\ncan I have\na hint?"])]; tree[141] = ["%fun-alpha0%"]; tree[142] = [FlxG.random.getObject(hints)]; tree[143] = [FlxG.random.getObject(["#zzzz04#...", "#zzzz05#...", "#zzzz00#..."])]; tree[144] = ["%mark-29mjm3kq%"]; tree[145] = [FlxG.random.getObject(abraIntro)]; tree[146] = ["%hint-asked%"]; tree[147] = ["%fun-alpha1%"]; if (puzzleState._dispensedHintCount < puzzleState._allowedHintCount) { tree[148] = [FlxG.random.getObject([ "#abra05#Mmm. I can sense you're really struggling with this one. Very well, I'll answer ONE question, so choose carefully.", "#abra05#Oh, this puzzle! I remember this one. Where are you stuck? What kind of information would help you the most right now?", "#abra05#Hmm yes, I can sense your frustration building. Sorry, these puzzles are supposed to be fun. What kind of help do you need?" ])]; tree[149] = []; } else { tree[145] = ["%noop%"]; var timeTaken:Float = puzzleState._hintElapsedTime; var timeTakenStr:String; var timeRemainingStr:String; if (puzzleState._mainRewardCritter._rewardTimer <= 0) { timeTakenStr = null; timeRemainingStr = "a few minutes"; } else { var timeRemaining:Float = Math.max(puzzleState._mainRewardCritter._rewardTimer, 60); timeTakenStr = DialogTree.durationToString(timeTaken); timeRemainingStr = DialogTree.durationToString(timeRemaining); } if (puzzleState._allowedHintCount == 0) { if (PlayerData.isAbraNice()) { if (timeTakenStr == null) { tree[148] = ["#abra10#Ehhhh!? ...You're already asking for a hint? ...You haven't even been trying!"]; } else { tree[148] = ["#abra10#Ehhhh!? ...You're already asking for a hint? ...It's only been like " + timeTakenStr + "..."]; } tree[149] = ["#abra06#I can't just give you the answers right away, <name>. ...But if you're still stuck in " + timeRemainingStr + ", come ask me again, hmm?"]; tree[150] = null; } else if (PlayerData.finalTrial) { tree[148] = ["#abra08#... ... -sigh- Do you really need a hint? ...This whole idea might be hopeless then. I don't know what I was thinking..."]; tree[149] = ["#abra09#If you're still stuck in " + timeRemainingStr + ", ask me again, alright? ...But... I don't really see the point..."]; tree[150] = null; } else { if (timeTakenStr == null) { tree[148] = ["#abra13#You're asking for a hint already? You should at least try solving the puzzle by yourself."]; } else { tree[148] = ["#abra13#You're asking for a hint already? It's only been like " + timeTakenStr + "! You should at least try solving the puzzle by yourself."]; } tree[149] = ["#abra12#Why don't you ask me again in " + timeRemainingStr + ". That'll give me time to decide if you're deserving of a hint."]; tree[150] = null; } } else { if (PlayerData.isAbraNice()) { if (timeTakenStr == null) { tree[148] = ["#abra10#Ehhhh!? ...You're already asking for another hint? ...You haven't even tried anything since I gave you that last hint..."]; } else { tree[148] = ["#abra10#Ehhhh!? ...You're already asking for another hint? ...But it's only been like " + timeTakenStr + " since I gave you that last hint..."]; } tree[149] = ["#abra06#Why don't you give it your best shot, and if you're still stuck in " + timeRemainingStr + "... I suppose you can come ask me for another hint. Is that fair?"]; tree[150] = null; } else if (PlayerData.finalTrial) { tree[148] = ["#abra08#... ...-sigh- Well, the puzzle's already ruined, but... I still think it would be good practice if you can avoid using any more hints."]; tree[149] = ["#abra09#...Why don't you think about it for " + timeRemainingStr + ". ...And I guess if you're still stuck, I can give you another hint."]; tree[150] = null; } else { if (timeTakenStr == null) { tree[148] = ["#abra13#You're already asking for another hint? ...You haven't even tried anything since I gave you that last hint!"]; } else { tree[148] = ["#abra13#You're already asking for another hint? ...It's only been like " + timeTakenStr + " since I gave you that last hint!"]; } tree[149] = ["#abra12#-sigh- How about this, give it your best shot and if you're still stuck in " + timeRemainingStr + "... I suppose I'll see if you're deserving of another hint."]; tree[150] = null; } } } if (puzzleState._dispensedHintCount == 0) { tree[300] = [FlxG.random.getObject([ "#abra04#Give it some thought, experiment a little. If you're still stuck in a few minutes, maybe I can give you a bigger hint.", "#abra04#See what you can figure out using that information. If you're still stuck, come ask me again in a few minutes and I'll give you a bigger hint.", "#abra04#I know these puzzles can be tricky at first. You'll get there. If you still find yourself stuck in a few minutes, come ask for more help." ])]; } else { tree[300] = [FlxG.random.getObject([ "#abra02#That's a pretty big hint, isn't it? I think you should be able to solve it on your own now. Good luck!", "#abra02#You should be able to get a lot from that hint! Take a look at the clues, and think about what I told you. You can do it!", "#abra02#Hmm, I feel like I sort of gave away the entire answer. Oh well, At the very least, you shouldn't be stuck anymore..." ])]; } tree[endIndex++] = ["%lights-on%"]; // some clues dim the lights tree[endIndex] = ["%fun-alpha1%"]; if (puzzleState._dispensedHintCount < puzzleState._allowedHintCount) { addHints(); } if (PlayerData.name == null) { // can't quit until we have your name tree[1].remove(100); } if (puzzleState._pokeWindow._partAlpha == 0) { // don't accidentally make the pokemon visible again tree[120] = [FlxG.random.getObject(["Hello?", "Is anybody\nthere?", "Ummm...?"])]; tree[141] = ["%noop%"]; tree[143] = ["#self00#..."]; tree[147] = ["%noop%"]; tree[endIndex] = ["%noop%"]; } } private function addHints() { var hints:Array<Hint> = []; var critterColorsPresent:Array<CritterColor> = []; { var colorsPresent:Map<Int, Int> = new Map<Int, Int>(); for (c in puzzleState._puzzle._answer) { colorsPresent[c] = c; } for (color in colorsPresent.keys()) { critterColorsPresent.push(Critter.CRITTER_COLORS[color]); } } if (puzzleState._dispensedHintCount == 0) { // small hint for (colorIndex in 0...puzzleState._puzzle._colorCount) { hints.push(new ColorExistsHint(Critter.CRITTER_COLORS[colorIndex], puzzleState._puzzle._answer.indexOf(colorIndex) != -1)); } hints.push(new HowManyColorsHint(Lambda.count(critterColorsPresent))); if (!puzzleState._puzzle._easy) { for (i in 0...puzzleState._puzzle._clueCount) { if (puzzleState._puzzle._markers[i] % 10 > 0) { var clueAnalysis:ClueAnalysis = new ClueAnalysis(puzzleState._puzzle._guesses[i], puzzleState._puzzle._answer); // there are some markers in the wrong position hints.push(new WhichColorsInWrongPosition(i, clueAnalysis.wrongPosition)); } } } } else if (puzzleState._dispensedHintCount == 1 || puzzleState._puzzle._easy) { // medium hint for (colorIndex in 0...puzzleState._puzzle._colorCount) { if (puzzleState._puzzle._answer.indexOf(colorIndex) != -1) { hints.push(new HowManyOfAColorHint(Critter.CRITTER_COLORS[colorIndex], Lambda.count(puzzleState._puzzle._answer, function(a) return a == colorIndex))); } } hints.push(new WhichColorsPresentHint(critterColorsPresent, puzzleState._puzzle._colorCount)); var critterColorsAbsent:Array<CritterColor> = Critter.CRITTER_COLORS.slice(0, puzzleState._puzzle._colorCount); for (color in critterColorsPresent) { critterColorsAbsent.remove(color); } hints.push(new WhichColorsAbsentHint(critterColorsAbsent, puzzleState._puzzle._colorCount)); { var maxColorCount:Int = 0; var colorCount:Map<CritterColor, Int> = new Map<CritterColor, Int>(); for (color in puzzleState._puzzle._answer) { if (colorCount[Critter.CRITTER_COLORS[color]] == null) { colorCount[Critter.CRITTER_COLORS[color]] = 1; } else { colorCount[Critter.CRITTER_COLORS[color]]++; } maxColorCount = Std.int(Math.max(maxColorCount, colorCount[Critter.CRITTER_COLORS[color]])); } var mostColors:Array<CritterColor> = []; for (color in colorCount.keys()) { if (colorCount[color] == maxColorCount) { mostColors.push(color); } } hints.push(new WhichColorIsThereMostOfHint(mostColors)); } } else { // big hint for (i in 0...puzzleState._puzzle._clueCount) { if (puzzleState._puzzle._markers[i] >= 10) { // there are some markers in the right position var clueAnalysis:ClueAnalysis = new ClueAnalysis(puzzleState._puzzle._guesses[i], puzzleState._puzzle._answer); hints.push(new WhichColorsInRightPosition(i, clueAnalysis.rightPosition)); } } for (color in critterColorsPresent) { var colorIndexes:Array<Int> = []; for (i in 0...puzzleState._puzzle._pegCount) { if (Critter.CRITTER_COLORS[puzzleState._puzzle._answer[i]] == color) { colorIndexes.push(i); } } hints.push(new WhereIsColorHint(color, colorIndexes, puzzleState._puzzle._pegCount)); } for (i in 0...puzzleState._puzzle._pegCount) { hints.push(new WhichColorIsHereHint(i, Critter.CRITTER_COLORS[puzzleState._puzzle._answer[i]], puzzleState._puzzle._pegCount)); } } hints.push(new NonsenseHint(puzzleState._puzzle._puzzleIndex)); FlxG.random.shuffle(hints); for (i in 0...Std.int(Math.min(4, hints.length))) { addHint(hints[i]); } } public function removeExitOption() { var branch:Array<Int> = cast tree[1]; branch.remove(100); } public function addCustomOption(choice:String, result:String) { var branch:Array<Int> = cast tree[1]; branch.push(counter); tree[counter] = [choice]; tree[counter + 1] = [result]; counter += 5; } public function addHint(hint:Hint) { var branch:Array<Int> = cast tree[149]; branch.push(hintCounter); var tmp:Int = hintCounter; // 160 hintCounter = hint.writeHint(tree, hintCounter); DialogTree.shift(tree, tmp + 2, hintCounter, 1); hintCounter++; tree[tmp + 1] = ["%hint-given%"]; tree[hintCounter++] = [300]; hintCounter += 2; } public function skipGettingAbra() { hints = [146]; } } class Hint { public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { return hintCounter; }; } class ColorExistsHint extends Hint { private var critterColor:CritterColor; private var exists:Bool; public function new(critterColor:CritterColor, exists:Bool) { this.critterColor = critterColor; this.exists = exists; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Are there\nany " + critterColor.english + "s\nin the\nanswer?"]; if (exists) { tree[hintCounter++] = ["#abra06#Hmm? Well yes, of course there are some " + critterColor.english + " bugs in the answer. ...I don't think I should say how many, it would give away too much."]; } else { tree[hintCounter++] = ["#abra06#Hmm? Well no, of course there aren't any " + critterColor.english + " bugs in the answer. ...Does that help any?"]; } return hintCounter; } } class HowManyColorsHint extends Hint { private var howMany:Int; public function new(howMany:Int) { this.howMany = howMany; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["How many\ndifferent\ncolors are\nin the\nanswer?"]; if (howMany == 1) { tree[hintCounter++] = ["#abra06#Hmm, there is only one color in the answer. I don't think I should say which one, it would give away too much."]; } else { tree[hintCounter++] = ["#abra06#Hmm, there are " + englishNumber(howMany) + " different colors in the answer. I don't think I should say which ones, it would give away too much."]; } return hintCounter; } } class HowManyOfAColorHint extends Hint { private var critterColor:CritterColor; private var howMany:Int; public function new(critterColor:CritterColor, howMany:Int) { this.critterColor = critterColor; this.howMany = howMany; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["How many\n" + critterColor.english + "s are\nin the\nanswer?"]; if (howMany == 0) { tree[hintCounter++] = ["#abra06#Hmm, there actually aren't any " + critterColor.english +" bugs in the answer."]; } else if (howMany == 1) { tree[hintCounter++] = ["#abra06#Hmm, there is only " + englishNumber(howMany) + " " + critterColor.english + " bug in the answer."]; } else { tree[hintCounter++] = ["#abra06#Hmm, there are exactly " + englishNumber(howMany) + " " + critterColor.english +" bugs in the answer."]; } return hintCounter; } } class WhichColorsPresentHint extends Hint { private var critterColors:Array<CritterColor>; private var maxColors:Int; public function new(critterColors:Array<CritterColor>, maxColors:Int) { this.critterColors = critterColors; this.maxColors = maxColors; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Which colors\nare in\nthe answer?"]; if (critterColors.length == 1) { tree[hintCounter++] = ["#abra06#Hmm, the answer has quite a few " + critterColors[0].english + "s in it. Surprisingly, that's the only color in the answer."]; } else if (critterColors.length >= 2 && critterColors.length < maxColors) { var tmp:StringBuf = new StringBuf(); for (i in 0...critterColors.length - 2) { tmp.add(critterColors[i].english + "s, "); } tmp.add(critterColors[critterColors.length - 2].english + "s and " + critterColors[critterColors.length - 1].english + "s"); tree[hintCounter++] = ["#abra06#Hmm, the answer has some " + tmp.toString() + " in it. Those are the only colors in the answer."]; } else if (critterColors.length == maxColors) { tree[hintCounter++] = ["#abra06#Hmm that's interesting, the answer actually has every single color in it."]; } else { // No colors are present in the solution? tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } return hintCounter; } } class WhichColorsAbsentHint extends Hint { private var critterColors:Array<CritterColor>; private var maxColors:Int; public function new(critterColors:Array<CritterColor>, maxColors:Int) { this.critterColors = critterColors; this.maxColors = maxColors; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Which colors\naren't in\nthe answer?"]; if (critterColors.length == 0) { tree[hintCounter++] = ["#abra06#Hmm, the answer actually has every single color in it. Isn't that interesting?"]; } else if (critterColors.length == 1) { tree[hintCounter++] = ["#abra06#Hmm, the answer doesn't have any " + critterColors[0].english + "s in it. All other colors are present in the answer."]; } else if (critterColors.length >= 2 && critterColors.length < maxColors) { var tmp:StringBuf = new StringBuf(); for (i in 0...critterColors.length - 2) { tmp.add(critterColors[i].english + "s, "); } tmp.add(critterColors[critterColors.length - 2].english + "s or " + critterColors[critterColors.length - 1].english + "s"); tree[hintCounter++] = ["#abra06#Hmm, the answer doesn't have any " + tmp.toString() + " in it."]; } else { // All colors are absent from the solution? tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } return hintCounter; } } class NonsenseHint extends Hint { private var key:Int; public function new(key:Int) { this.key = key; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { var which:Int = Std.int(Math.min(FlxG.random.int(0, 4), FlxG.random.int(0, 5))); // number 0-4, but lower numbers are more likely if (which == 0) { tree[hintCounter++] = ["If the answer\nwere an ice\ncream flavor,\nwhich ice\ncream flavor\nwould it be?"]; var flavors = ["peaches 'n cream", "oreo cheesecake", "salted caramel", "chocolate peppermint", "mocha almond fudge"]; tree[hintCounter++] = ["#abra06#Hmm, if the answer were an ice cream flavor, it would definitely be " + flavors[key % flavors.length] + "."]; } else if (which == 1) { tree[hintCounter++] = ["If the answer\nwere a pizza,\nwhat kind of\npizza would\nit be?"]; var flavors = ["Honolulu Hawaiian", "pepperoni", "buffalo chicken pizza", "veggie lover's pizza", "sausage and green peppers", "extra cheese. Maybe with a stuffed crust"]; tree[hintCounter++] = ["#abra06#Hmm, if the answer were a pizza? ...Definitely " + flavors[key % flavors.length] + "."]; } else if (which == 2) { tree[hintCounter++] = ["If the answer were\na post-impressionist\npainting, which\npost-impressionist\npainting would\nit be?"]; var paintings = ["Salvador Dali's Persistence of Memory", "Rene Magritte's Son Of Man", "Piet Mondrian's Tableau No. IV", "Pablo Picasso's Weeping Woman", "Georges Seurat's Sunday Afternoon on the Island of La Grande Jatte"]; var dumbPaintings = ["the one by the ocean with the melty clocks", "the one with the posh-looking fellow and the apple", "the one with the straight lines and fancy colored squares", "the one with the girl with the sideways nose", "the one at the picnic with all of those tiny dots"]; var painting:String = paintings[key % paintings.length]; var dumbPainting:String = dumbPaintings[key % dumbPaintings.length]; tree[hintCounter++] = ["#abra06#Hmm, if the answer were a a post-impressionist painting, it would definitely be " + painting + "."]; tree[hintCounter++] = ["#abra05#"+painting+"? Ring any bells?"]; tree[hintCounter++] = ["#abra08#Oh right, sorry. It's " + dumbPaintings[key % dumbPaintings.length] + ". -cough-"]; } else if (which == 3) { tree[hintCounter++] = ["If the answer\nhad to get rid\nof a dead body,\nwhat would\nit do?"]; var deadBody = ["cut it into smaller pieces with a bone saw, and bury it ten feet deep in the woods, using a combination of dish soap and vinegar to cover up the smell", "dissolve it in a concentrated bath of hydroflouric acid, disposing of the remaining insoluble calcium shell in a landfill", "gain after-hours access to a steel mill and incinerate the body in a blast furnace", "cut the corpse into six pieces, tie it all together, and feed them to a bunch of pigs. He'd need about sixteen pigs to finish a body in one sitting"]; tree[hintCounter++] = ["#abra11#Hmm... If the answer had to get rid of a dead body? Well, I suppose, hmmm..."]; tree[hintCounter++] = ["#abra08#I imagine it would " + deadBody[key % deadBody.length] + "."]; tree[hintCounter++] = ["#abra09#..."]; tree[hintCounter++] = ["#abra10#Please don't ask me for any more hints."]; tree[hintCounter++] = null; } else { tree[hintCounter++] = ["If the answer\ncould go back\nin time and\nmake one change\nin human history,\nwhat would it be?"]; var humanHistory = ["prevent the burning of the libraries of alexandria", "educate scientists in the middle ages on the topics of penicillin, antiseptics and the basics of modern medicine", "have Trotsky take power in the Soviet Union instead of Stalin", "prevent Constantine from making Christianity the official religion of the Roman Empire"]; tree[hintCounter++] = ["#abra04#Hmm, if the answer could travel back in time, it would " + humanHistory[key % humanHistory.length] + "."]; if (key % humanHistory.length >= 2) { tree[hintCounter++] = ["#abra05#Now... That's not any sort of personal political statement, that's just what the answer would do. When you figure out the answer, you'll know what I mean."]; } } return hintCounter; } } class WhichColorsInWrongPosition extends Hint { var clueIndex:Int; var wrongPosition:Array<CritterColor>; public function new(clueIndex:Int, wrongPosition:Array<CritterColor>) { this.clueIndex = clueIndex; this.wrongPosition = wrongPosition; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Which bugs\nare in the\nwrong\nposition for\nclue #" + (clueIndex + 1) + "?"]; tree[hintCounter++] = ["%lights-dim%"]; tree[hintCounter++] = ["%lights-on-wholeclue" + clueIndex + "%"]; if (wrongPosition.length == 1) { tree[hintCounter++] = ["#abra05#Hmm, there's a " + wrongPosition[0].english + " bug which is in the wrong position for clue #" + (clueIndex + 1) + "."]; } else if (wrongPosition.length >= 2) { var map:Map<String, Int> = new Map<String, Int>(); for (color in wrongPosition) { if (map[color.english] == null) { map[color.english] = 1; } else { map[color.english]++; } } var wrongBugStrings:Array<String> = []; for (color in map.keys()) { wrongBugStrings.push(englishNumber(map[color]) + " " + color + " bug" + (map[color] == 1 ? "" : "s")); } var wrongBugBuf:StringBuf = new StringBuf(); if (wrongBugStrings.length == 1) { wrongBugBuf.add(wrongBugStrings[0]); } else { for (i in 0...wrongBugStrings.length - 2) { wrongBugBuf.add(wrongBugStrings[i] + ", "); } wrongBugBuf.add(wrongBugStrings[wrongBugStrings.length - 2] + " and " + wrongBugStrings[wrongBugStrings.length - 1]); } tree[hintCounter++] = ["#abra05#Hmm, there's " + wrongBugBuf + " which are in the wrong position for clue #" + (clueIndex + 1) + "."]; } else { // Nothing's in the right position? tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } tree[hintCounter++] = ["%lights-on%"]; return hintCounter; } } class WhichColorsInRightPosition extends Hint { var clueIndex:Int; var rightPosition:Array<CritterColor>; public function new(clueIndex:Int, rightPosition:Array<CritterColor>) { this.clueIndex = clueIndex; this.rightPosition = rightPosition; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Which bugs\nare in the\ncorrect\nposition for\nclue #" + (clueIndex + 1) + "?"]; tree[hintCounter++] = ["%lights-dim%"]; tree[hintCounter++] = ["%lights-on-wholeclue" + clueIndex + "%"]; if (rightPosition.length == 1) { tree[hintCounter++] = ["#abra05#Hmm, there's a " + rightPosition[0].english + " bug which is in the correct position for clue #" + (clueIndex + 1) + "."]; } else if (rightPosition.length >= 2) { var map:Map<String, Int> = new Map<String, Int>(); for (color in rightPosition) { if (map[color.english] == null) { map[color.english] = 1; } else { map[color.english]++; } } var rightBugStrings:Array<String> = []; for (color in map.keys()) { rightBugStrings.push(englishNumber(map[color]) + " " + color + " bug" + (map[color] == 1 ? "" : "s")); } var rightBugBuf:StringBuf = new StringBuf(); if (rightBugStrings.length == 1) { rightBugBuf.add(rightBugStrings[0]); } else { for (i in 0...rightBugStrings.length - 2) { rightBugBuf.add(rightBugStrings[i] + ", "); } rightBugBuf.add(rightBugStrings[rightBugStrings.length - 2] + " and " + rightBugStrings[rightBugStrings.length - 1]); } tree[hintCounter++] = ["#abra05#Hmm, there's " + rightBugBuf + " which are in the correct position for clue #" + (clueIndex + 1) + "."]; } else { // Nothing's in the right position? tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } tree[hintCounter++] = ["%lights-on%"]; return hintCounter; } } class ClueAnalysis { public var rightPosition:Array<CritterColor> = []; public var wrongPosition:Array<CritterColor> = []; public function new(clue:Array<Int>, answer:Array<Int>) { var answerTmp:Array<Int> = answer.copy(); var clueTmp:Array<Int> = clue.copy(); { var p:Int = 0; while (p < clueTmp.length) { if (clueTmp[p] == answerTmp[p]) { rightPosition.push(Critter.CRITTER_COLORS[clueTmp[p]]); clueTmp.splice(p, 1); answerTmp.splice(p, 1); } else { p++; } } } { var p:Int = 0; while (p < clueTmp.length) { var c:Int = answerTmp.indexOf(clueTmp[p]); if (c != -1) { wrongPosition.push(Critter.CRITTER_COLORS[clueTmp[p]]); clueTmp.splice(p, 1); answerTmp.splice(c, 1); } else { p++; } } } rightPosition.sort(function(a, b) return Critter.CRITTER_COLORS.indexOf(a) - Critter.CRITTER_COLORS.indexOf(b)); wrongPosition.sort(function(a, b) return Critter.CRITTER_COLORS.indexOf(a) - Critter.CRITTER_COLORS.indexOf(b)); } } class WhichColorIsThereMostOfHint extends Hint { var mostColors:Array<CritterColor>; public function new(mostColors:Array<CritterColor>) { this.mostColors = mostColors; } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["In the\nanswer,\nwhich color\nis there\nmost of?"]; if (mostColors.length == 1) { tree[hintCounter++] = ["#abra05#Hmm, there's more " + mostColors[0].english + " bugs in the answer than anything else."]; } else if (mostColors.length >= 2) { var tmp:StringBuf = new StringBuf(); for (i in 0...mostColors.length - 2) { tmp.add(mostColors[i].english + "s, "); } tmp.add(mostColors[mostColors.length - 2].english + "s and " + mostColors[mostColors.length - 1].english + "s"); tree[hintCounter++] = ["#abra06#Hmm, it's actually tied. There's an equal number of " + tmp.toString() + " in the answer."]; } else { // There's the most of nothing?? tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } return hintCounter; } } class WhereIsColorHint extends Hint { private var indexNames:Array<String>; private var color:CritterColor; private var indexes:Array<Int>; public function new(color:CritterColor, indexes:Array<Int>, pegCount:Int) { this.indexes = indexes; this.color = color; if (pegCount == 3) { indexNames == ["left", "middle", "right"]; } else if (pegCount == 4) { indexNames = ["leftmost", "second-from-the-left", "second-from-the-right", "rightmost"]; } else if (pegCount == 5) { indexNames = ["leftmost", "second-from-the-left", "centermost", "second-from-the-right", "rightmost"]; } else { indexNames = ["upper-left", "upper-right", "left", "center", "right", "lower-left", "lower-right"]; } } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["Which bugs\nin the answer\nare " + color.english + "?"]; if (indexes.length == 1) { tree[hintCounter++] = ["#abra05#Hmm, so the " + indexNames[indexes[0]] + " bug is the only " + color.english + " one."]; } else if (indexes.length >= 2) { var tmp:StringBuf = new StringBuf(); for (i in 0...indexes.length - 2) { tmp.add(indexNames[indexes[i]] + ", "); } tmp.add(indexNames[indexes[indexes.length - 2]] + " and " + indexNames[indexes[indexes.length - 1]]); tree[hintCounter++] = ["#abra05#Hmm the " + tmp + " bugs are " + (indexes.length == 2 ? "both" : "all") + " " + color.english + "."]; } else { // There are no bugs of this color. This isn't a valuable hint, we shouldn't give it here tree[hintCounter++] = ["#abra07#Err.... Just a moment, I need to go lay down."]; tree[hintCounter++] = null; } return hintCounter; } } class WhichColorIsHereHint extends Hint { private var indexNames0:Array<String>; private var indexNames1:Array<String>; private var indexNames2:Array<String>; private var index:Int; private var color:CritterColor; public function new(index:Int, color:CritterColor, pegCount:Int) { this.color = color; this.index = index; if (pegCount == 3) { indexNames0 = ["on the left", "in the middle", "on the right"]; indexNames1 = ["left bug", "center bug", "right bug"]; indexNames2 = ["left bug", "center bug", "right bug"]; } else if (pegCount == 4) { indexNames0 = ["on the far\nleft", "second from\nthe left", "second from\nthe right", "on the far\nright"]; indexNames1 = ["leftmost bug", "bug second-from-the-left", "bug second-from-the-right", "rightmost bug"]; indexNames2 = ["leftmost bug", "particular bug", "particular bug", "rightmost bug"]; } else if (pegCount == 5) { indexNames0 = ["on the far\nleft", "second from\nthe left", "in the very\nmiddle", "second from\nthe right", "on the right"]; indexNames1 = ["leftmost bug", "bug second-from-the-left", "bug directly in the center", "bug second-from-the-right", "rightmost bug"]; indexNames2 = ["leftmost bug", "particular bug", "centermost bug", "particular bug", "rightmost bug"]; } else { indexNames0 = ["in the\nupper-left", "in the\nupper-right", "on the\nleft", "in the\ncenter", "on the\nright", "in the\nlower-left", "in the\nlower-right"]; indexNames1 = ["upper-left bug", "upper-right bug", "left bug", "center bug", "right bug", "lower-left bug", "lower-right bug"]; indexNames2 = ["particular bug", "particular bug", "particular bug", "particular bug", "particular bug", "particular bug", "particular bug"]; } } override public function writeHint(tree:Array<Array<Object>>, hintCounter:Int):Int { tree[hintCounter++] = ["What color\nis the bug\n" + indexNames0[index] + "?"]; tree[hintCounter++] = ["#abra05#Hmm, so you're asking about the " + indexNames1[index] + "? ...That " + indexNames2[index] + " is " + color.english + "."]; return hintCounter; } }
argonvile/monster
source/HelpDialog.hx
hx
unknown
34,361
package; import flixel.FlxG; import flixel.math.FlxMath; import poke.hera.HeraShopDialog; import kludge.BetterFlxRandom; /** * ItemDatabase keeps track of which items are purchased, unpurchased, and * available in the shop. */ class ItemDatabase { private static var MIN_REFILL_TIME:Float = 1000 * 60 * 6; // 6 minutes /* * List of prices Heracross will sell items for */ public static var PRICES:Array<Int> = [50, 55, 60, 65, 70, 75, 80, 85, 90, 100, 110, 115, 120, 130, 140, 150, 160, 170, 180, 190, 200, 220, 240, 260, 275, 300, 320, 340, 360, 380, 400, 425, 450, 475, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2200, 2400, 2600, 2750, 3000, 3200, 3400, 3600, 3800, 4000, 4250, 4500, 4750, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 22000, 24000, 26000, 27500, 30000, 32000, 34000, 36000, 38000, 40000, 42500, 45000, 47500, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 99999]; public static var ITEM_COOKIES:Int; public static var ITEM_CALCULATOR:Int; public static var ITEM_HYDROGEN_PEROXIDE:Int; public static var ITEM_ACETONE:Int; public static var ITEM_INCENSE:Int; public static var ITEM_GOLD_PUZZLE_KEY:Int; public static var ITEM_DIAMOND_PUZZLE_KEY:Int; public static var ITEM_MARS_SOFTWARE:Int; public static var ITEM_VENUS_SOFTWARE:Int; public static var ITEM_MAGNETIC_DESK_TOY:Int; public static var ITEM_SMALL_GREY_BEADS:Int; public static var ITEM_SMALL_PURPLE_BEADS:Int; public static var ITEM_LARGE_GLASS_BEADS:Int; public static var ITEM_LARGE_GREY_BEADS:Int; public static var ITEM_FRUIT_BUGS:Int; public static var ITEM_MARSHMALLOW_BUGS:Int; public static var ITEM_SPOOKY_BUGS:Int; public static var ITEM_RETROPIE:Int; public static var ITEM_ASSORTED_GLOVES:Int; public static var ITEM_INSULATED_GLOVES:Int; public static var ITEM_GHOST_GLOVES:Int; public static var ITEM_VANISHING_GLOVES:Int; public static var ITEM_STREAMING_PACKAGE:Int; public static var ITEM_VIBRATOR:Int; public static var ITEM_BLUE_DILDO:Int; public static var ITEM_GUMMY_DILDO:Int; public static var ITEM_HUGE_DILDO:Int; public static var ITEM_HAPPY_MEAL:Int; public static var ITEM_PIZZA_COUPONS:Int; /** * Has the player solved a set of puzzles since we last restocked? */ public static var _solvedPuzzle:Bool = false; /** * When's the last time we last restocked? */ public static var _prevRefillTime:Date; public static var _itemTypes:Array<ItemType> = { var _tmpItems = []; _tmpItems.push( { name:"Cornstarch Cookies", basePrice:900, shopImage:AssetPaths.cookies_shop__png, dialog:HeraShopDialog.cornstarchCookies, index:ITEM_COOKIES=_tmpItems.length } ); _tmpItems.push( { name:"Graphing Calculator", basePrice:2200, shopImage:AssetPaths.calculator_shop__png, dialog:HeraShopDialog.calculator, index:ITEM_CALCULATOR=_tmpItems.length } ); _tmpItems.push( { name:"Hydrogen Peroxide", basePrice:750, shopImage:AssetPaths.hydrogen_peroxide_shop__png, dialog:HeraShopDialog.hydrogenPeroxide, index:ITEM_HYDROGEN_PEROXIDE=_tmpItems.length } ); _tmpItems.push( { name:"Acetone", basePrice:750, shopImage:AssetPaths.acetone_shop__png, dialog:HeraShopDialog.acetone, index:ITEM_ACETONE=_tmpItems.length } ); _tmpItems.push( { name:"Romantic Incense", basePrice:3400, shopImage:AssetPaths.incense_shop__png, dialog:HeraShopDialog.romanticIncense, index:ITEM_INCENSE=_tmpItems.length } ); _tmpItems.push( { name:"Puzzle Keys", basePrice:1400, shopImage:AssetPaths.gold_puzzle_key_shop__png, dialog:HeraShopDialog.goldPuzzleKey, index:ITEM_GOLD_PUZZLE_KEY=_tmpItems.length } ); _tmpItems.push( { name:"Diamond Puzzle Key", basePrice:4000, shopImage:AssetPaths.diamond_puzzle_key_shop__png, dialog:HeraShopDialog.diamondPuzzleKey, index:ITEM_DIAMOND_PUZZLE_KEY=_tmpItems.length } ); _tmpItems.push( { name:"Mars Software", basePrice:1100, shopImage:AssetPaths.boy_software_shop__png, dialog:HeraShopDialog.marsSoftware, index:ITEM_MARS_SOFTWARE=_tmpItems.length } ); _tmpItems.push( { name:"Venus Software", basePrice:1100, shopImage:AssetPaths.girl_software_shop__png, dialog:HeraShopDialog.venusSoftware, index:ITEM_VENUS_SOFTWARE=_tmpItems.length } ); _tmpItems.push( { name:"Magnetic Desk Toy", basePrice:1600, shopImage:AssetPaths.magnetic_desk_toy_shop__png, dialog:HeraShopDialog.magneticDeskToy, index:ITEM_MAGNETIC_DESK_TOY=_tmpItems.length } ); _tmpItems.push( { name:"Grey Anal Beads", basePrice:1400, shopImage:AssetPaths.small_grey_beads_shop__png, dialog:HeraShopDialog.smallGreyBeads, index:ITEM_SMALL_GREY_BEADS=_tmpItems.length } ); // "intro" abra anal beads _tmpItems.push( { name:"Purple Anal Beads", basePrice:3000, shopImage:AssetPaths.small_purple_beads_shop__png, dialog:HeraShopDialog.smallPurpleBeads, index:ITEM_SMALL_PURPLE_BEADS=_tmpItems.length } ); // "expert" abra anal beads _tmpItems.push( { name:"Huge Glass Anal Beads", basePrice:2400, shopImage:AssetPaths.xl_glass_beads_shop__png, dialog:HeraShopDialog.largeGlassBeads, index:ITEM_LARGE_GLASS_BEADS=_tmpItems.length } ); // "intro" rhydon anal beads _tmpItems.push( { name:"Huge Grey Anal Beads", basePrice:4250, shopImage:AssetPaths.xl_grey_beads_shop__png, dialog:HeraShopDialog.largeGreyBeads, index:ITEM_LARGE_GREY_BEADS=_tmpItems.length } ); // "expert" rhydon anal beads _tmpItems.push( { name:"Fruit Bugs", basePrice:300, shopImage:AssetPaths.placeholder_shop__png, dialog:HeraShopDialog.fruitBugs, index:ITEM_FRUIT_BUGS = _tmpItems.length } ); _tmpItems.push( { name:"Marshmallow Bugs", basePrice:700, shopImage:AssetPaths.placeholder_shop__png, dialog:HeraShopDialog.marshmallowBugs, index:ITEM_MARSHMALLOW_BUGS = _tmpItems.length } ); _tmpItems.push( { name:"Spooky Bugs", basePrice:2200, shopImage:AssetPaths.placeholder_shop__png, dialog:HeraShopDialog.spookyBugs, index:ITEM_SPOOKY_BUGS = _tmpItems.length } ); _tmpItems.push( { name:"RetroPie", basePrice:6500, shopImage:AssetPaths.retropie_shop__png, dialog:HeraShopDialog.retroPie, index:ITEM_RETROPIE = _tmpItems.length } ); _tmpItems.push( { name:"Assorted Gloves", basePrice:240, shopImage:AssetPaths.assorted_gloves_shop__png, dialog:HeraShopDialog.assortedGloves, index:ITEM_ASSORTED_GLOVES = _tmpItems.length } ); _tmpItems.push( { name:"Insulated Gloves", basePrice:150, shopImage:AssetPaths.insulated_gloves_shop__png, dialog:HeraShopDialog.insulatedGloves, index:ITEM_INSULATED_GLOVES = _tmpItems.length } ); _tmpItems.push( { name:"Ghost Gloves", basePrice:500, shopImage:AssetPaths.ghost_gloves_shop__png, dialog:HeraShopDialog.ghostGloves, index:ITEM_GHOST_GLOVES = _tmpItems.length } ); _tmpItems.push( { name:"Vanishing Gloves", basePrice:750, shopImage:AssetPaths.vanishing_gloves_shop__png, dialog:HeraShopDialog.vanishingGloves, index:ITEM_VANISHING_GLOVES = _tmpItems.length } ); _tmpItems.push( { name:"Streaming Package", basePrice:8500, shopImage:AssetPaths.streaming_package_shop__png, dialog:HeraShopDialog.streamingPackage, index:ITEM_STREAMING_PACKAGE = _tmpItems.length } ); _tmpItems.push( { name:"Vibrator", basePrice:3800, shopImage:AssetPaths.vibe_shop__png, dialog:HeraShopDialog.vibrator, index:ITEM_VIBRATOR = _tmpItems.length } ); _tmpItems.push( { name:"Blue Dildo", basePrice:1200, shopImage:AssetPaths.blue_dildo_shop__png, dialog:HeraShopDialog.blueDildo, index:ITEM_BLUE_DILDO = _tmpItems.length } ); _tmpItems.push( { name:"Gummy Dildo", basePrice:1900, shopImage:AssetPaths.gummy_dildo_shop__png, dialog:HeraShopDialog.gummyDildo, index:ITEM_GUMMY_DILDO = _tmpItems.length } ); _tmpItems.push( { name:"Huge Dildo", basePrice:6000, shopImage:AssetPaths.xl_dildo_shop__png, dialog:HeraShopDialog.hugeDildo, index:ITEM_HUGE_DILDO = _tmpItems.length } ); _tmpItems.push( { name:"Happy Meal Toys", basePrice:140, shopImage:AssetPaths.happymeal_shop__png, dialog:HeraShopDialog.happyMeal, index:ITEM_HAPPY_MEAL = _tmpItems.length } ); _tmpItems.push( { name:"Pizza Coupons", basePrice:1200, shopImage:AssetPaths.pizza_coupons_shop__png, dialog:HeraShopDialog.pizzaCoupons, index:ITEM_PIZZA_COUPONS= _tmpItems.length } ); _tmpItems; }; public static var _warehouseItemIndexes:Array<Int>; public static var _shopItems:Array<ShopItem>; public static var _newItems:Bool = true; public static var _playerItemIndexes:Array<Int> = []; public static var _mysteryBoxStatus:Int = 0; public static var _magnezoneStatus:MagnezoneStatus = MagnezoneStatus.Absent; public static var _kecleonPresent:Bool = false; /** * 2 boxes: telephone shows up * 5 boxes: lucario can fit the huge dildo, but doesn't enjoy it very much * 8 boxes: electric vibe item available * 11 boxes: lucario can enjoy huge dildo * 11 boxes: can call sandslash on phone * * @return The number of mystery boxes which have been purchased */ public static function getPurchasedMysteryBoxCount():Int { return Std.int(Math.max(0, _mysteryBoxStatus - 1)); } public static function isLocked(index:Int):Bool { var unlockedItems:Map<Int, Bool> = new Map<Int, Bool>(); unlockedItems[ITEM_MAGNETIC_DESK_TOY] = PlayerData.hasMet("magn"); unlockedItems[ITEM_RETROPIE] = PlayerData.hasMet("hera"); unlockedItems[ITEM_HAPPY_MEAL] = PlayerData.recentChatCount("grim.randomChats.0.4") > 0; unlockedItems[ITEM_PIZZA_COUPONS] = PlayerData.hasMet("luca") && PlayerData.hasMet("rhyd"); return unlockedItems[index] == false; } public static function getAllItemIndexes():Array<Int> { var _tmpItemIndexes = []; for (i in 0..._itemTypes.length) { _tmpItemIndexes.push(i); } FlxG.random.shuffle(_tmpItemIndexes); return _tmpItemIndexes; } public static function refillShop():Void { var shouldRefillItems:Bool; var shouldRotateStaff:Bool; if (_prevRefillTime == null) { // first time; fill the shop with its initial stock shouldRefillItems = true; shouldRotateStaff = true; } else { var timeSinceLastRestock:Float = MmTools.time() - _prevRefillTime.getTime(); if (timeSinceLastRestock < 0) { /* * prefRefillTime is in the future; reset it. This avoids a * scenario where a player might cheat their clock into the * future, and then never see any new items again */ _prevRefillTime = Date.now(); } shouldRotateStaff = _solvedPuzzle; shouldRefillItems = _solvedPuzzle && timeSinceLastRestock >= MIN_REFILL_TIME; _solvedPuzzle = false; } if (shouldRotateStaff) { rotateStaff(); } if (shouldRefillItems) { refillItems(); } } public static function rotateStaff():Void { // is kecleon present? if (PlayerData.professors.indexOf(PlayerData.PROF_PREFIXES.indexOf("hera")) != -1) { // kecleon runs the store if heracross is out _kecleonPresent = true; } else if (!PlayerData.hasMet("smea")) { // kecleon doesn't show up until player interacts with smeargle _kecleonPresent = false; } else if (ItemDatabase._playerItemIndexes.length == 0) { // kecleon doesn't show up until player visits the store _kecleonPresent = false; } else if (FlxG.random.bool(8)) { // kecleon shows up if you're really lucky _kecleonPresent = true; } else { _kecleonPresent = false; } if (_kecleonPresent) { BadItemDescriptions.initialize(true); LevelIntroDialog.rotateProfessors([PlayerData.prevProfPrefix, "smea"], false); if (PlayerData.keclStoreChat == 0) { PlayerData.keclStoreChat = 10; } else if (PlayerData.keclStoreChat % 2 == 1) { PlayerData.keclStoreChat += 1; if (PlayerData.keclStoreChat % 10 >= 5) { // don't let it get too big PlayerData.keclStoreChat -= 2; } } } // is magnezone present? if (_kecleonPresent) { // magnezone doesn't harass kecleon _magnezoneStatus = MagnezoneStatus.Absent; } else if (PlayerData.keclStoreChat >= 10 && PlayerData.keclStoreChat < 20) { // heracross needs to give his "how was kecleon?" speech. magnezone is absent _magnezoneStatus = MagnezoneStatus.Absent; } else if (FlxG.random.bool(65)) { // magnezone is usually absent _magnezoneStatus = MagnezoneStatus.Absent; } else if (PlayerData.luckyProfSchedules[0] == PlayerData.PROF_PREFIXES.indexOf("magn")) { // magnezone is the current lucky professor; he's not in the shop _magnezoneStatus = MagnezoneStatus.Absent; } else if (!PlayerData.startedTaping) { // haven't started taping yet; one thing at a time _magnezoneStatus = MagnezoneStatus.Absent; } else if (PlayerData.denProf == PlayerData.PROF_PREFIXES.indexOf("magn")) { // magnezone's in the den; not in the shop _magnezoneStatus = MagnezoneStatus.Absent; } else { var magnMood:Float = 0; magnMood += PlayerData.chatHistory.filter(function(s) { return s != null && StringTools.startsWith(s, "magn"); } ).length * 10; // ~50 each time you play with magnezone magnMood += _playerItemIndexes.length * 8; // 0-200 or so magnMood += PlayerData.magnButtPlug * 5; // 0-70 or so magnMood += playerHasItem(ITEM_MAGNETIC_DESK_TOY) ? 50 : 0; magnMood *= FlxG.random.float(0.6, 1.0); if (magnMood < 30) { _magnezoneStatus = MagnezoneStatus.Angry; } else if (magnMood < 150) { _magnezoneStatus = MagnezoneStatus.Suspicious; } else if (magnMood < 350) { _magnezoneStatus = MagnezoneStatus.Calm; } else { _magnezoneStatus = MagnezoneStatus.Happy; } if (PlayerData.magnButtPlug % 2 == 1 && PlayerData.magnButtPlug <= 5) { PlayerData.magnButtPlug++; if (_magnezoneStatus == MagnezoneStatus.Angry || _magnezoneStatus == MagnezoneStatus.Suspicious) { _magnezoneStatus = MagnezoneStatus.Calm; } } } } public static function refillItems():Void { // if items have been unlocked, we unlock them PlayerDataNormalizer.normalizeItems(); _prevRefillTime = Date.now(); var prunedInventory:Bool = false; var i:Int = 0; while (i < _shopItems.length) { if (_shopItems[i]._discount >= 5 || _shopItems[i]._discount <= -5) { _warehouseItemIndexes.push(_shopItems[i]._itemIndex); _shopItems.remove(_shopItems[i]); prunedInventory = true; } else { i++; } } if (_shopItems.length < 5 && _warehouseItemIndexes.length > 0 && !prunedInventory) { _newItems = true; addShopItem(); } while (_shopItems.length < 3 && _warehouseItemIndexes.length > 0) { _newItems = true; addShopItem(); } var playerHasAllItems:Bool = true; for (itemType in _itemTypes) { if (!playerHasItem(itemType.index)) { playerHasAllItems = false; } } if (playerHasAllItems) { // player has purchased every item. ...mystery box time! if (_mysteryBoxStatus <= 0) { _mysteryBoxStatus = 1; } var mysteryBoxInShop:Bool = false; for (shopItem in _shopItems) { if (Std.isOfType(shopItem, MysteryBoxShopItem)) { mysteryBoxInShop = true; } } if (!mysteryBoxInShop) { _shopItems.insert(0, new ItemDatabase.MysteryBoxShopItem()); _newItems = true; } } if (playerHasAllItems && ItemDatabase.getPurchasedMysteryBoxCount() >= 2) { // player has purchased every item, and two mystery boxes... telephone time! var telephoneInShop:Bool = false; for (shopItem in _shopItems) { if (Std.isOfType(shopItem, TelephoneShopItem)) { telephoneInShop = true; } } if (!telephoneInShop) { _shopItems.insert(0, new ItemDatabase.TelephoneShopItem()); _newItems = true; } } var clearance:Bool = _shopItems.length == 5; var discountArray:Array<ShopItem> = _shopItems.copy(); if (clearance) { var cheapItem:ShopItem = BetterFlxRandom.getObject(discountArray, discountArray.length - 2, discountArray.length - 1); discountArray.remove(cheapItem); var expensiveItem:ShopItem = discountArray[discountArray.length - 1]; discountArray.remove(expensiveItem); FlxG.random.shuffle(discountArray); discountArray.insert(0, cheapItem); discountArray.push(expensiveItem); } else { FlxG.random.shuffle(discountArray); } for (i in 0...discountArray.length) { discountArray[i]._discount = Std.int(FlxMath.bound(FlxG.random.int( i - 2, i + 2), -4, 4)); } if (clearance) { discountArray[0]._discount = FlxG.random.int( -9, -5); discountArray[4]._discount = FlxG.random.int( 5, 7); } } /** * Add a new shop item. We will usually look at the next 3 items in the * warehouse and pick the cheapest one. But, we will have one expensive * item in the shop too, which we find by just grabbing the next random * item from the warehouse regardless of price. */ public static function addShopItem():Void { var anyExpensive:Bool = false; for (shopItem in _shopItems) { anyExpensive = shopItem._expensive || anyExpensive; } var itemBrowseCount:Int = Std.int(Math.min(_warehouseItemIndexes.length, anyExpensive ? 3 : 1)); var cheapItemIndex:Null<Int> = null; for (i in 0...itemBrowseCount) { var expensiveItemIndex:Null<Int> = _warehouseItemIndexes[0]; _warehouseItemIndexes.remove(expensiveItemIndex); if (cheapItemIndex == null || _itemTypes[cheapItemIndex].basePrice > _itemTypes[expensiveItemIndex].basePrice) { var tempItemIndex:Null<Int> = cheapItemIndex; cheapItemIndex = expensiveItemIndex; expensiveItemIndex = tempItemIndex; } if (expensiveItemIndex != null) { _warehouseItemIndexes.push(expensiveItemIndex); } } if (cheapItemIndex != null) { var shopItem:ShopItem = new ShopItem(cheapItemIndex); shopItem._expensive = !anyExpensive; _shopItems.insert(0, shopItem); } } public static function playerHasItem(item:Int) { return _playerItemIndexes.indexOf(item) != -1; } public static function playerHasUneatenItem(item:Int) { return _playerItemIndexes.indexOf(item) != -1 && item != PlayerData.grimEatenItem; } public static function isMagnezonePresent() { return _magnezoneStatus != MagnezoneStatus.Absent; } public static function isKecleonPresent() { return _kecleonPresent; } public static function getItemCount():Int { return ItemDatabase._itemTypes.length; } public static function roundUpPrice(price:Float, ?discount:Int=0) { var priceIndex:Int = 0; while (ItemDatabase.PRICES[priceIndex] < price) { priceIndex++; } priceIndex = Std.int(FlxMath.bound(discount + priceIndex, 0, ItemDatabase.PRICES.length - 1)); return ItemDatabase.PRICES[priceIndex]; } } /** * An item in the warehouse -- Heracross hasn't put this item on sale yet. It * has a theoretical price which might be adjusted. */ typedef ItemType = { name:String, basePrice:Int, shopImage:Dynamic, dialog:Dynamic, index:Int } /** * An item in the shop -- Heracross has put this iutem on sale, and it has a * price which fluctuates. */ class ShopItem { public var _orderIndex:Int = FlxG.random.int(0, 10000); public var _itemIndex:Int; // A discount which fluctuates from [-4, 4]. Lower numbers are better public var _discount:Int; /* * We usually select our stock by taking one of the cheaper items from the * warehouse, except for one token expensive item. Is this item our token * expensive item? */ public var _expensive:Bool; public function new(ItemIndex:Int, Discount:Int=0) { this._itemIndex = ItemIndex; this._discount = Discount; this._expensive = false; } public function getPrice():Int { return ItemDatabase.roundUpPrice(getItemType().basePrice, _discount); } public function getItemType():ItemType { return ItemDatabase._itemTypes[_itemIndex]; } public function toString():String { return "ShopItem " + _itemIndex; } } /** * A mystery box item in the shop. These come in about 9 differently shaped * boxes, and contain the rarest most valuable items in the game. */ class MysteryBoxShopItem extends ShopItem { static var MYSTERY_BOX_PRICES:Array<Int> = [15000, 5500, 27500, 17000, 5000, 55000, 19000, 14000, 9500, 65000, 30000, 7000, 75000, 10000, 6000, 85000, 90000, 34000, 9000, 7500, 40000, 13000, 36000, 99999, 12000, 8000, 20000, 11000, 45000, 60000, 47500, 80000, 50000, 8500, 18000, 26000, 22000, 70000, 6500, 16000, 38000, 42500, 24000, 95000, 32000]; static var MYSTERY_BOX_IMAGES:Array<String> = [ AssetPaths.mystery_box01__png, AssetPaths.mystery_box02__png, AssetPaths.mystery_box05__png, AssetPaths.mystery_box07__png, AssetPaths.mystery_box04__png, AssetPaths.mystery_box08__png, AssetPaths.mystery_box00__png, AssetPaths.mystery_box03__png, AssetPaths.mystery_box06__png, AssetPaths.mystery_box03__png, AssetPaths.mystery_box05__png, AssetPaths.mystery_box02__png, AssetPaths.mystery_box01__png, AssetPaths.mystery_box07__png, AssetPaths.mystery_box00__png, AssetPaths.mystery_box08__png, AssetPaths.mystery_box06__png, AssetPaths.mystery_box04__png, AssetPaths.mystery_box09__png, // wow! fancy box AssetPaths.mystery_box06__png, AssetPaths.mystery_box04__png, AssetPaths.mystery_box01__png, AssetPaths.mystery_box00__png, AssetPaths.mystery_box02__png, AssetPaths.mystery_box07__png, AssetPaths.mystery_box08__png, AssetPaths.mystery_box05__png, AssetPaths.mystery_box03__png, AssetPaths.mystery_box07__png, AssetPaths.mystery_box00__png, AssetPaths.mystery_box03__png, AssetPaths.mystery_box04__png, AssetPaths.mystery_box01__png, AssetPaths.mystery_box05__png, AssetPaths.mystery_box06__png, AssetPaths.mystery_box02__png, AssetPaths.mystery_box08__png, AssetPaths.mystery_box10__png // wow! another fancy box ]; public function new() { // item index is -1, -2, -3... super(-ItemDatabase._mysteryBoxStatus, 0); } override public function getPrice():Int { return MYSTERY_BOX_PRICES[getMysteryBoxIndex() % MYSTERY_BOX_PRICES.length]; } override public function getItemType():ItemType { return { name:"Mystery Box", basePrice:getPrice(), shopImage:MYSTERY_BOX_IMAGES[getMysteryBoxIndex() % MYSTERY_BOX_IMAGES.length], dialog:HeraShopDialog.mysteryBox, index:_itemIndex }; } /* * Converts our item index of -1, -2, -3... to 0, 1, 2... */ private function getMysteryBoxIndex() { if (_itemIndex >= 0) { return 0; } return -1 - _itemIndex; } } /** * The telephone item allows the plaeyr to invite a Pokemon of their choice. */ class TelephoneShopItem extends ShopItem { static var TELEPHONE_PRICES:Array<Int> = [ 3000, 3200, 3400, 3600, 3800, 4000, 4250, 4500, 4750, // 2x middle of the road prices; these prices are the most common 5000, 5500, 6000, 6500, 7000, 7500, 8000, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]; public function new() { super(-100000, 0); } override public function getPrice():Int { return TELEPHONE_PRICES[Std.int(Math.abs( PlayerData.abraSexyBeforeChat + PlayerData.buizSexyBeforeChat + PlayerData.rhydSexyBeforeChat + PlayerData.sandSexyBeforeChat + PlayerData.smeaSexyBeforeChat + PlayerData.grovSexyBeforeChat + PlayerData.lucaSexyBeforeChat + PlayerData.heraSexyBeforeChat + PlayerData.magnSexyBeforeChat + PlayerData.grimSexyBeforeChat ) % TELEPHONE_PRICES.length)]; } override public function getItemType():ItemType { return { name:"Phone call", basePrice:getPrice(), shopImage:AssetPaths.telephone_shop__png, dialog:HeraShopDialog.phoneCall, index:_itemIndex }; } } enum MagnezoneStatus { Absent; Angry; Suspicious; Calm; Happy; }
argonvile/monster
source/ItemDatabase.hx
hx
unknown
24,460
package; import critter.Critter; import flixel.FlxBasic; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.group.FlxGroup; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.ui.FlxButton; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import kludge.BetterFlxRandom; import kludge.FlxSoundKludge; import openfl.Assets; import openfl.geom.Point; import openfl.geom.Rectangle; import poke.sexy.SexyState; /** * There is a screen the player can access to view their items, and to change * which items are active or how they behave. This class is the FlxState which * encompasses the logic for that screen. */ class ItemsMenuState extends FlxState { public static var DARK_BLUE:FlxColor = 0xFF00647F; public static var MEDIUM_BLUE:FlxColor = 0xFF3FA4BF; public static var LIGHT_BLUE:FlxColor = 0xFF7FE4FF; public static var WHITE_BLUE:FlxColor = 0xFFE8FFFF; public var _handSprite:FlxSprite; private var _menuItems:FlxGroup; public var _itemGraphics:FlxGroup; public var handOpacityTween0:FlxTween; public var handOpacityTween1:FlxTween; public var _bgSprite:FlxSprite; private var _menuSprite:FlxSprite; private var _backButton:FlxButton; public var shadowGroup:FlxTypedGroup<FlxSprite> = new FlxTypedGroup<FlxSprite>(); /* * Most items have a visual component. This is a list of the visual * components for each item, encompassing things like what sprite they * should use if they have the item, where the sprite should go, and * whether the sprite should change if they change their settings. */ private var visualItems:Array<VisualItem> = new Array<VisualItem>(); private var shadowMap:Map<FlxSprite, FlxSprite> = new Map<FlxSprite, FlxSprite>(); // for critters... var _targetSprites:FlxTypedGroup<FlxSprite>; var _midInvisSprites:FlxTypedGroup<FlxSprite>; var _midSprites:FlxTypedGroup<FlxSprite>; var _critterShadowGroup:ShadowGroup; /** * 768 x 432 * [384,10 -- 758,384] */ override public function create():Void { Main.overrideFlxGDefaults(); Critter.initialize(Critter.LOAD_ALL); // load all critters, so player can view them super.create(); _bgSprite = new FlxSprite(0, 0, AssetPaths.items_bg__png); add(_bgSprite); _backButton = SexyState.newBackButton(back, AssetPaths.back_button2__png); add(_backButton); add(shadowGroup); _itemGraphics = new FlxGroup(); add(_itemGraphics); _critterShadowGroup = new ShadowGroup(); _targetSprites = new FlxTypedGroup<FlxSprite>(); _midInvisSprites = new FlxTypedGroup<FlxSprite>(); _midInvisSprites.visible = false; _midSprites = new FlxTypedGroup<FlxSprite>(); add(_critterShadowGroup); add(_targetSprites); add(_midInvisSprites); add(_midSprites); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_ASSORTED_GLOVES) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_INSULATED_GLOVES) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_GHOST_GLOVES) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_VANISHING_GLOVES)) { visualItems.push(new ViGloveColors(this)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_FRUIT_BUGS) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARSHMALLOW_BUGS) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_SPOOKY_BUGS)) { visualItems.push(new ViCritterColors(this)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GOLD_PUZZLE_KEY) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_DIAMOND_PUZZLE_KEY)) { visualItems.push(new ViPuzzleKeys(this)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_VIBRATOR)) { visualItems.push(new ViSimple(this, AssetPaths.vibe_shop_items__png, 166, 21)); } if (ItemDatabase.getPurchasedMysteryBoxCount() >= 8) { visualItems.push(new ViSimple(this, AssetPaths.elecvibe_items__png, 200, 29)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_HAPPY_MEAL)) { visualItems.push(new ViSimple(this, AssetPaths.happymeal_items__png, 250, -31)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_SMALL_GREY_BEADS)) { visualItems.push(new ViSimple(this, AssetPaths.small_grey_beads_items__png, 97, -32)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_LARGE_GREY_BEADS)) { visualItems.push(new ViSimple(this, AssetPaths.xl_grey_beads_items__png, -12, -30)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_LARGE_GLASS_BEADS)) { visualItems.push(new ViSimple(this, AssetPaths.xl_glass_beads_items__png, 9, 33)); } if (ItemDatabase.playerHasUneatenItem(ItemDatabase.ITEM_SMALL_PURPLE_BEADS)) { visualItems.push(new ViSimple(this, AssetPaths.small_purple_beads_items__png, -21, 74)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_HUGE_DILDO)) { visualItems.push(new ViSimple(this, AssetPaths.xl_dildo_items__png, 244, 32)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_BLUE_DILDO)) { visualItems.push(new ViSimple(this, AssetPaths.blue_dildo_items__png, 271, 76)); } if (ItemDatabase.playerHasUneatenItem(ItemDatabase.ITEM_GUMMY_DILDO)) { visualItems.push(new ViSimple(this, AssetPaths.gummy_dildo_items__png, 245, 95)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_CALCULATOR)) { visualItems.push(new ViSimple(this, AssetPaths.calculator_items__png, 262, 132)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_STREAMING_PACKAGE)) { visualItems.push(new ViSimple(this, AssetPaths.streaming_package_items__png, 235, 215)); } if (ItemDatabase._playerItemIndexes.length == ItemDatabase._itemTypes.length && PlayerData.isAbraNice()) { visualItems.push(new ViSimple(this, AssetPaths.trophy_items__png, 126, 98, 160, 200)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_COOKIES) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_INCENSE)) { visualItems.push(new ViPokemonLibido(this)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_ACETONE) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_HYDROGEN_PEROXIDE)) { visualItems.push(new ViPegEnergy(this)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARS_SOFTWARE) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_VENUS_SOFTWARE)) { visualItems.push(new ViGenderSoftware(this)); } _menuItems = new FlxGroup(); _menuSprite = new FlxSprite(0, 0); _menuSprite.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT); paintMenuSprite(); _menuItems.add(_menuSprite); var y:Int = 18; for (visualItem in visualItems) { y = visualItem.addMenu(y); visualItem.addGraphics(); } add(_menuItems); _handSprite = new FlxSprite(100, 100); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(3, 3); _handSprite.offset.set(69, 87); add(_handSprite); } function back() { FlxG.switchState(new MainMenuState()); }; function paintMenuSprite() { FlxSpriteUtil.beginDraw(MEDIUM_BLUE & 0xCCFFFFFF); OptionsMenuState.octagon(FlxG.width / 2, 10, FlxG.width-10, FlxG.height-48, 2); FlxSpriteUtil.endDraw(_menuSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:9, color:DARK_BLUE }); OptionsMenuState.octagon(FlxG.width / 2, 10, FlxG.width-10, FlxG.height-48, 2); FlxSpriteUtil.updateSpriteGraphic(_menuSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:7, color:WHITE_BLUE }); OptionsMenuState.octagon(FlxG.width / 2, 10, FlxG.width-10, FlxG.height-48, 2); FlxSpriteUtil.updateSpriteGraphic(_menuSprite); } public function addCritter(critter:Critter, pushToCritterList:Bool = true) { if (_targetSprites.members.indexOf(critter._targetSprite) != -1) { // shouldn't add; already exists return; } _targetSprites.add(critter._targetSprite); _midInvisSprites.add(critter._soulSprite); _midSprites.add(critter._bodySprite); _midSprites.add(critter._headSprite); _midSprites.add(critter._frontBodySprite); _critterShadowGroup.makeShadow(critter._bodySprite); } public function removeCritter(critter:Critter, pushToCritterList:Bool = true) { if (_targetSprites.members.indexOf(critter._targetSprite) == -1) { // can't remove; doesn't exist return; } _targetSprites.remove(critter._targetSprite, true); _midInvisSprites.remove(critter._soulSprite, true); _midSprites.remove(critter._bodySprite, true); _midSprites.remove(critter._headSprite, true); _midSprites.remove(critter._frontBodySprite, true); _critterShadowGroup.killShadow(critter._bodySprite); } override public function update(elapsed:Float):Void { super.update(elapsed); PlayerData.updateTimePlayed(); if (FlxG.mouse.justPressed) { PlayerData.updateCursorVisible(); } _handSprite.setPosition(FlxG.mouse.x - _handSprite.width / 2, FlxG.mouse.y - _handSprite.height / 2); if (FlxG.mouse.justPressed) { for (visualItem in visualItems) { visualItem.mousePressed(); } } for (shadowSprite in shadowGroup) { if (shadowMap.exists(shadowSprite)) { var targetSprite:FlxSprite = shadowMap.get(shadowSprite); shadowSprite.alive = targetSprite.alive; shadowSprite.exists = targetSprite.exists; shadowSprite.animation.frameIndex = targetSprite.animation.frameIndex; shadowSprite.visible = targetSprite.visible; shadowSprite.alpha = targetSprite.alpha; } } _midSprites.sort(LevelState.byYNulls); } public function addMenuText(X:Float, Y:Float, ?Text:String):FlxText { var flxText:FlxText = new FlxText(X, Y - 6, 0, Text, 20); flxText.font = AssetPaths.hardpixel__otf; flxText.color = ItemsMenuState.WHITE_BLUE; _menuItems.add(flxText); return flxText; } public function addMenuGraphic(SpriteGraphic:String, x:Float, y:Float, w:Int=160, h:Int=160):FlxSprite { var newItemImage:FlxSprite = new FlxSprite(x, y); newItemImage.loadGraphic(SpriteGraphic, true, w, h); addMenuItem(newItemImage); return newItemImage; } public function addMenuItem(basic:FlxBasic) { _menuItems.add(basic); } public function addGraphic(SpriteGraphic:String, x:Float, y:Float, w:Int=160, h:Int=160):FlxSprite { var newItemImage:FlxSprite = new FlxSprite(x, y); newItemImage.loadGraphic(SpriteGraphic, true, w, h); _itemGraphics.add(newItemImage); var shadowKey:String = StringTools.replace(SpriteGraphic, ".png", "-shadow.png"); if (Assets.exists(shadowKey)) { var newShadowImage:FlxSprite = new FlxSprite(x, y); newShadowImage.loadGraphic(shadowKey, true, w, h); shadowGroup.add(newShadowImage); shadowMap[newShadowImage] = newItemImage; } return newItemImage; } override public function destroy():Void { super.destroy(); _handSprite = FlxDestroyUtil.destroy(_handSprite); _menuItems = FlxDestroyUtil.destroy(_menuItems); _itemGraphics = FlxDestroyUtil.destroy(_itemGraphics); handOpacityTween0 = FlxTweenUtil.destroy(handOpacityTween0); handOpacityTween1 = FlxTweenUtil.destroy(handOpacityTween1); _bgSprite = FlxDestroyUtil.destroy(_bgSprite); _menuSprite = FlxDestroyUtil.destroy(_menuSprite); _backButton = FlxDestroyUtil.destroy(_backButton); shadowGroup = FlxDestroyUtil.destroy(shadowGroup); visualItems = null; shadowMap = null; _targetSprites = FlxDestroyUtil.destroy(_targetSprites); _midInvisSprites = FlxDestroyUtil.destroy(_midInvisSprites); _midSprites = FlxDestroyUtil.destroy(_midSprites); _critterShadowGroup = FlxDestroyUtil.destroy(_critterShadowGroup); } } /** * The menu on the right half of the items screen includes many spinners for * adjusting values up and down. This class encompasses the logic for those * spinners and their buttons. */ private class Spinner { public var _leftArrow:FlxText; public var _itemText:FlxText; public var _rightArrow:FlxText; public var _options:Array<String>; public var _optionIndex:Int; public var _state:ItemsMenuState; public var _onChange:Dynamic; public var _justPressed:Bool = false; /** * Initializes a new spinner * * @param State itemsMenuState this spinner is embedded in * @param Options options to spin between (e.g ["SMALL", "MEDIUM", "LARGE"]) * @param Option currently selected ooption * @param OnChange callback to invoke when the spinner's value changes */ public function new(State:ItemsMenuState, Options:Array<String>, Option:String, OnChange:Dynamic) { this._state = State; this._options = Options; this._optionIndex = Options.indexOf(Option); this._onChange = OnChange; } /** * Centers the spinner. Its left side should have already been defined by * the create() method * * @param Right the right edge of the bounding box */ public function center(Right:Float) { var currRight:Float = _rightArrow.x + _rightArrow.width; var offset:Float = (Right - currRight) / 2; for (text in [_leftArrow, _itemText, _rightArrow]) { text.x += offset; } } /** * Adds the spinner's visual elements to the itemsMenuState */ public function create(X:Float, Y:Float) { _leftArrow = _state.addMenuText(X, Y, "<"); var maxWidth:Int = 0; _itemText = _state.addMenuText(_leftArrow.x + _leftArrow.width + 2, Y); for (itemOption in _options) { _itemText.text = itemOption; maxWidth = Std.int(Math.max(maxWidth, _itemText.width)); } _itemText.fieldWidth = maxWidth + 1; _itemText.alignment = "center"; _itemText.text = _options[_optionIndex] == null ? "???" : _options[_optionIndex]; _rightArrow = _state.addMenuText(_itemText.x + _itemText.fieldWidth + 2, Y, ">"); } public function mousePressed() { _justPressed = false; if (_leftArrow.getMidpoint().distanceTo(FlxG.mouse.getPosition()) < 20) { FlxSoundKludge.play(AssetPaths.beep_0065__mp3); if (_optionIndex == -1) { _optionIndex = _options.length - 1; } else if (_optionIndex > 0) { _optionIndex--; } _itemText.text = _options[_optionIndex]; _justPressed = true; _onChange(); } if (_rightArrow.getMidpoint().distanceTo(FlxG.mouse.getPosition()) < 20) { FlxSoundKludge.play(AssetPaths.beep_0065__mp3); if (_optionIndex == -1) { _optionIndex = 0; } else if (_optionIndex < _options.length - 1) { _optionIndex++; } _itemText.text = _options[_optionIndex]; _justPressed = true; _onChange(); } } public function setText(text:String) { _itemText.text = text; _optionIndex = _options.indexOf(text); } } /** * Most items have different graphics and behavior on the items menu, such as * an object which appears on the table, a menu item defining their behavior. * This class can be subclassed for items to define their behavior */ private class VisualItem { public var _state:ItemsMenuState; public function new(State:ItemsMenuState) { this._state = State; } public function addGraphics() { } public function addMenu(y:Int):Int { return y; } public function mousePressed():Void { } } /** * VisualItem encompassing all of the libido items (cookies and incense) */ private class ViPokemonLibido extends VisualItem { private static var valueToDescMap:Map<Int,String> = [1 => "ZERO", 2 => "VERY LOW", 3 => "LOW", 4 => "NORMAL", 5 => "HIGH", 6 => "VERY HIGH", 7 => "MAXIMUM"]; private static var descToValueMap:Map<String,Int> = ["ZERO" => 1, "VERY LOW" => 2, "LOW" => 3, "NORMAL" => 4, "HIGH" => 5, "VERY HIGH" => 6, "MAXIMUM" => 7]; private var itemOptions:Array<String>; private var itemImageCookies:FlxSprite; private var itemImageIncense:FlxSprite; private var spinner:Spinner; private var smokeCount:Int = 0; private var smokeGroup:FlxGroup; override public function addMenu(y:Int):Int { var text:FlxText = _state.addMenuText(FlxG.width / 2 + 4, y, "Pokemon Libido:"); var itemOptions:Array<String> = ["NORMAL"]; if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_INCENSE)) itemOptions = itemOptions.concat(["HIGH", "VERY HIGH", "MAXIMUM"]); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_COOKIES)) itemOptions = ["ZERO", "VERY LOW", "LOW"].concat(itemOptions); spinner = new Spinner(_state, itemOptions, valueToDescMap[PlayerData.pokemonLibido], onChange); spinner.create(text.x + text.width + 5, y); return y + 40; } override public function addGraphics() { if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_INCENSE)) { itemImageIncense = _state.addGraphic(AssetPaths.incense_items__png, 79, 145); smokeGroup = new FlxGroup(); _state.add(smokeGroup); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_COOKIES)) itemImageCookies = _state.addGraphic(AssetPaths.cookies_items__png, 3, 151); updateGraphics(); } override public function mousePressed() { spinner.mousePressed(); } function onChange():Void { PlayerData.pokemonLibido = descToValueMap[spinner._itemText.text]; updateGraphics(); } function updateGraphics():Void { if (itemImageCookies != null) itemImageCookies.animation.frameIndex = ["ZERO" => 3, "VERY LOW" => 2, "LOW" => 1, "NORMAL" => 0][spinner._itemText.text]; if (itemImageIncense != null) { smokeGroup.kill(); smokeGroup.clear(); smokeGroup.revive(); itemImageIncense.animation.frameIndex = ["MAXIMUM" => 3, "VERY HIGH" => 2, "HIGH" => 1, "NORMAL" => 0][spinner._itemText.text]; if (itemImageIncense.animation.frameIndex == 1) { addSmoke( -1, -28); } else if (itemImageIncense.animation.frameIndex == 2) { addSmoke( -34, -23); addSmoke( 41, -23); } else if (itemImageIncense.animation.frameIndex == 3) { addSmoke( -1, -28); addSmoke( -34, -23); addSmoke( 41, -23); addSmoke( -25, -27); addSmoke( 43, -19); } } } function addSmoke(x:Int, y:Int) { smokeCount++; var smokeSprite:FlxSprite = new FlxSprite(itemImageIncense.x + x, itemImageIncense.y + y); smokeSprite.loadGraphic(AssetPaths.incense_items_smoke__png, true, 160, 160); smokeSprite.animation.add("default", [(0 + smokeCount) % 3, (1 + smokeCount) % 3, (2 + smokeCount) % 3], 2); smokeSprite.animation.play("default"); smokeGroup.add(smokeSprite); } } /** * VisualItem encompassing all of the peg energy items (acetone, hydrogen peroxide) */ private class ViPegEnergy extends VisualItem { private static var valueToDescMap:Map<Int,String> = [1 => "LOWEST", 2 => "LOWER", 3 => "LOW", 4 => "NORMAL", 5 => "HIGH", 6 => "HIGHER", 7 => "HIGHEST"]; private static var descToValueMap:Map<String,Int> = ["LOWEST" => 1, "LOWER" => 2, "LOW" => 3, "NORMAL" => 4, "HIGH" => 5, "HIGHER" => 6, "HIGHEST" => 7]; private var spinner:Spinner; private var itemImagePeroxide:FlxSprite; private var itemImageAcetone:FlxSprite; override public function addMenu(y:Int):Int { var text:FlxText = _state.addMenuText(FlxG.width / 2 + 4, y, "Peg Energy:"); var itemOptions:Array<String> = ["NORMAL"]; if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_ACETONE)) itemOptions = itemOptions.concat(["HIGH", "HIGHER", "HIGHEST"]); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_HYDROGEN_PEROXIDE)) itemOptions = ["LOWEST", "LOWER", "LOW"].concat(itemOptions); spinner = new Spinner(_state, itemOptions, valueToDescMap[PlayerData.pegActivity], onChange); spinner.create(text.x + text.width + 5, y); return y + 40; } override public function addGraphics() { if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_ACETONE)) itemImageAcetone = _state.addGraphic(AssetPaths.acetone_items__png, 144, 184); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_HYDROGEN_PEROXIDE)) itemImagePeroxide = _state.addGraphic(AssetPaths.hydrogen_peroxide_items__png, 198, 235); updateGraphics(); } override public function mousePressed():Void { spinner.mousePressed(); } function onChange() { PlayerData.pegActivity = descToValueMap[spinner._itemText.text]; updateGraphics(); } function updateGraphics():Void { if (itemImagePeroxide != null) itemImagePeroxide.animation.frameIndex = StringTools.startsWith(spinner._itemText.text, "LOW") ? 1 : 0; if (itemImageAcetone != null) itemImageAcetone.animation.frameIndex = StringTools.startsWith(spinner._itemText.text, "HIGH") ? 1 : 0; } } /** * Visual item encompassing all of the puzzle key items (silver, gold, diamond * keys) */ private class ViPuzzleKeys extends VisualItem { private static var valueToDescMap:Map<PlayerData.Prompt,String> = [PlayerData.Prompt.AlwaysNo => "NO", PlayerData.Prompt.Ask => "ASK", PlayerData.Prompt.AlwaysYes => "YES"]; private static var descToValueMap:Map<String,PlayerData.Prompt> = ["NO" => PlayerData.Prompt.AlwaysNo, "ASK" => PlayerData.Prompt.Ask, "YES" => PlayerData.Prompt.AlwaysYes]; private static var spinnerOptions:Array<String> = ["NO", "ASK", "YES"]; private var silverSpinner:Spinner; private var goldSpinner:Spinner; private var diamondSpinner:Spinner; private var itemSilverKey:FlxSprite; private var itemGoldKey:FlxSprite; private var itemDiamondKey:FlxSprite; override public function addMenu(y:Int):Int { var columnWidth:Float = (FlxG.width / 2 - 10) / 3; var columnX:Float = FlxG.width / 2 + 4; if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GOLD_PUZZLE_KEY)) { var silverText:FlxText = _state.addMenuText(columnX, y, "Silver"); columnX += columnWidth; silverText.fieldWidth = columnWidth; silverText.alignment = "center"; silverSpinner = new Spinner(_state, spinnerOptions, valueToDescMap[PlayerData.promptSilverKey], onChange); silverSpinner.create(silverText.x, y + 20); silverSpinner.center(silverText.x + silverText.width); var goldText:FlxText = _state.addMenuText(columnX, y, "Gold"); columnX += columnWidth; goldText.fieldWidth = columnWidth; goldText.alignment = "center"; goldSpinner = new Spinner(_state, spinnerOptions, valueToDescMap[PlayerData.promptGoldKey], onChange); goldSpinner.create(goldText.x, y + 20); goldSpinner.center(goldText.x + goldText.width); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_DIAMOND_PUZZLE_KEY)) { var diamondText:FlxText = _state.addMenuText(columnX, y, "Diamond"); columnX += columnWidth; diamondText.fieldWidth = columnWidth; diamondText.alignment = "center"; diamondSpinner = new Spinner(_state, spinnerOptions, valueToDescMap[PlayerData.promptDiamondKey], onChange); diamondSpinner.create(diamondText.x, y + 20); diamondSpinner.center(diamondText.x + diamondText.width); } return y + 60; } override public function addGraphics() { var baseX:Float = 242; var baseY:Float = 228; if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GOLD_PUZZLE_KEY)) { itemSilverKey = _state.addGraphic(AssetPaths.silver_key_items__png, baseX - 36, baseY + 12, 54, 40); itemGoldKey = _state.addGraphic(AssetPaths.gold_key_items__png, baseX - 18, baseY + 12, 54, 40); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_DIAMOND_PUZZLE_KEY)) { itemDiamondKey = _state.addGraphic(AssetPaths.diamond_key_items__png, baseX + 10, baseY + 10, 54, 40); } updateGraphics(); } override public function mousePressed():Void { for (spinner in [silverSpinner, goldSpinner, diamondSpinner]) { if (spinner != null) spinner.mousePressed(); } lock (silverSpinner, goldSpinner, 1); lock (silverSpinner, diamondSpinner, 1); lock (goldSpinner, silverSpinner, -1); lock (goldSpinner, diamondSpinner, 1); lock (diamondSpinner, silverSpinner, -1); lock (diamondSpinner, goldSpinner, -1); onChange(); } function lock (rigid:Spinner, loose:Spinner, desiredDir:Int) { if (rigid == null || loose == null) { return; } if (!rigid._justPressed) { return; } var actualDir:Int = spinnerOptions.indexOf(rigid._itemText.text) - spinnerOptions.indexOf(loose._itemText.text); if (actualDir > 0 && desiredDir > 0) { return; } if (actualDir < 0 && desiredDir < 0) { return; } loose.setText(rigid._itemText.text); } function onChange() { if (silverSpinner != null) PlayerData.promptSilverKey = descToValueMap[silverSpinner._itemText.text]; if (goldSpinner != null) PlayerData.promptGoldKey = descToValueMap[goldSpinner._itemText.text]; if (diamondSpinner != null) PlayerData.promptDiamondKey = descToValueMap[diamondSpinner._itemText.text]; updateGraphics(); } function updateGraphics():Void { if (itemSilverKey != null) itemSilverKey.visible = PlayerData.promptSilverKey != PlayerData.Prompt.AlwaysNo; if (itemGoldKey != null) itemGoldKey.visible = PlayerData.promptGoldKey != PlayerData.Prompt.AlwaysNo; if (itemDiamondKey != null) itemDiamondKey.visible = PlayerData.promptDiamondKey != PlayerData.Prompt.AlwaysNo; } } /** * VisualItem which can be used for any item which just needs to display a * static 160x160 image; no menu, no interactivity */ private class ViSimple extends VisualItem { private var spriteGraphic:String; private var x:Int; private var y:Int; private var w:Int; private var h:Int; public function new(state:ItemsMenuState, SpriteGraphic:String, x:Int, y:Int, w:Int=160, h:Int=160) { super(state); this.spriteGraphic = SpriteGraphic; this.x = x; this.y = y; this.w = w; this.h = h; } override public function addGraphics() { _state.addGraphic(spriteGraphic, x, y, w, h); } } private class ViGenderSoftware extends VisualItem { private var abraGraphic:FlxSprite; private var buizelGraphic:FlxSprite; private var grovyleGraphic:FlxSprite; private var sandslashGraphic:FlxSprite; private var rhydonGraphic:FlxSprite; private var smeargleGraphic:FlxSprite; private var kecleonGraphic:FlxSprite; private var heracrossGraphic:FlxSprite; private var magnezoneGraphic:FlxSprite; private var grimerGraphic:FlxSprite; private var lucarioGraphic:FlxSprite; private var iconConfigs:Array<Array<String>> = [ ["abraGraphic", "abra", AssetPaths.abra_gender_icons__png], ["buizelGraphic", "buiz", AssetPaths.buizel_gender_icons__png], ["grovyleGraphic", "grov", AssetPaths.grovyle_gender_icons__png], ["sandslashGraphic", "sand", AssetPaths.sand_gender_icons__png], ["rhydonGraphic", "rhyd", AssetPaths.rhydon_gender_icons__png], ["smeargleGraphic", "smea", AssetPaths.smear_gender_icons__png], ["kecleonGraphic", "kecl", AssetPaths.kecleon_gender_icons__png], ["heracrossGraphic", "hera", AssetPaths.hera_gender_icons__png], ["magnezoneGraphic", "magn", AssetPaths.magn_gender_icons__png], ["grimerGraphic", "grim", AssetPaths.grimer_gender_icons__png], ["lucarioGraphic", "luca", AssetPaths.luca_gender_icons__png], ]; override public function addGraphics() { var itemGenderSoftware:FlxSprite = _state.addGraphic(AssetPaths.gender_software_items__png, 315, 295, 90, 94); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARS_SOFTWARE) && ItemDatabase.playerHasItem(ItemDatabase.ITEM_VENUS_SOFTWARE)) { itemGenderSoftware.animation.frameIndex = 2; } else if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARS_SOFTWARE)) { itemGenderSoftware.animation.frameIndex = 1; } } override public function addMenu(y:Int):Int { var initialY:Int = y; var x:Int = Std.int(FlxG.width / 2 + 216); var secondRow:Bool = false; var iconCount:Int = 0; for (iconConfig in iconConfigs) { if (Reflect.field(PlayerData, iconConfig[1] + "DefaultMale")) { if (!ItemDatabase.playerHasItem(ItemDatabase.ITEM_VENUS_SOFTWARE)) { // venus software is needed to modify males continue; } } else { if (!ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARS_SOFTWARE)) { // mars software is needed to modify females continue; } } if (x > 720 && secondRow == false) { y += 30; x -= 45; secondRow = true; } Reflect.setField(this, iconConfig[0], _state.addMenuGraphic(iconConfig[2], x, y, 30, 30)); updateIconGraphic(Reflect.field(this, iconConfig[0]), iconConfig[1] + "Male"); x = secondRow ? (x - 30) : (x + 30); iconCount++; } if (iconCount == 0) { return y; } var genderText:FlxText = _state.addMenuText(FlxG.width / 2 + 4, initialY + 5, "Pokemon Gender:"); return y + 40; } override public function mousePressed() { for (iconConfig in iconConfigs) { if (handleIconClick(Reflect.field(this, iconConfig[0]), iconConfig[1] + "Male")) { // only one icon is clicked break; } } } private function handleIconClick(graphic:FlxSprite, maleField:String):Bool { if (graphic != null && graphic.getHitbox().containsPoint(FlxG.mouse.getPosition())) { Reflect.setField(PlayerData, maleField, !Reflect.field(PlayerData, maleField)); updateIconGraphic(graphic, maleField); return true; } return false; } private function updateIconGraphic(graphic:FlxSprite, maleField:String) { if (graphic != null) { graphic.animation.frameIndex = Reflect.field(PlayerData, maleField) ? 1 : 0; } } } /** * VisualItem encompassing all of the critter color items (fruit bugs, marshmallow * bugs, spooky bugs) */ private class ViCritterColors extends VisualItem { var critterColors:Array<CritterColor>; var critters:Array<Critter> = []; var critterFrames:Array<FlxSprite> = []; public function new(state:ItemsMenuState) { super(state); critterColors = []; critterColors = critterColors.concat(Critter.CRITTER_COLORS.slice(0, 6)); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_FRUIT_BUGS)) { critterColors = critterColors.concat(Critter.CRITTER_COLORS.slice(6, 9)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARSHMALLOW_BUGS)) { critterColors = critterColors.concat(Critter.CRITTER_COLORS.slice(9, 12)); } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_SPOOKY_BUGS)) { critterColors = critterColors.concat(Critter.CRITTER_COLORS.slice(12, 15)); } } override public function addGraphics() { var critterXOffset:Float = 38 + 8; var critterYOffset:Float = 16 + 9; var critterCoords:Array<FlxPoint> = [ FlxPoint.get(critterXOffset * 1.0, critterYOffset * 2), FlxPoint.get(critterXOffset * 1.5, critterYOffset * 1), FlxPoint.get(critterXOffset * 2.0, critterYOffset * 2), FlxPoint.get(critterXOffset * 2.5, critterYOffset * 3), FlxPoint.get(critterXOffset * 1.5, critterYOffset * 3), FlxPoint.get(critterXOffset * 0.5, critterYOffset * 3), FlxPoint.get(critterXOffset * 0.0, critterYOffset * 2), FlxPoint.get(critterXOffset * 0.5, critterYOffset * 1), FlxPoint.get(critterXOffset * 0.0, critterYOffset * 0), FlxPoint.get(critterXOffset * 4.5, critterYOffset * 3), FlxPoint.get(critterXOffset * 3.5, critterYOffset * 3), FlxPoint.get(critterXOffset * 3.0, critterYOffset * 2), FlxPoint.get(critterXOffset * 2.5, critterYOffset * 1), FlxPoint.get(critterXOffset * 3.5, critterYOffset * 1), FlxPoint.get(critterXOffset * 4.0, critterYOffset * 2), ]; for (i in 0...critterColors.length) { var critterColor:CritterColor = critterColors[i]; var critter:Critter = new Critter(critterCoords[i].x + FlxG.random.float(-8, 8) + 15, critterCoords[i].y + FlxG.random.float(-8, 8) + 290, _state._bgSprite); critter.setColor(critterColor); critter.setImmovable(true); // don't let them run around critters.push(critter); updateIconGraphic(i); } FlxDestroyUtil.putArray(critterCoords); } override public function addMenu(y:Int):Int { var x:Int = Std.int(FlxG.width / 2 + 4); _state.addMenuText(FlxG.width / 2 + 4, y + 5, "Bug Colors:"); var locations:Array<FlxPoint> = []; if (critterColors.length <= 9) { locations.push(new FlxPoint(1.5, 0.0)); locations.push(new FlxPoint(2.5, 0.0)); locations.push(new FlxPoint(3.5, 0.0)); locations.push(new FlxPoint(4.5, 0.0)); locations.push(new FlxPoint(5.5, 0.0)); locations.push(new FlxPoint(6.0, 1.0)); locations.push(new FlxPoint(6.5, 0.0)); locations.push(new FlxPoint(7.0, 1.0)); locations.push(new FlxPoint(7.5, 0.0)); } else if (critterColors.length <= 12) { locations.push(new FlxPoint(1.5, 0.0)); locations.push(new FlxPoint(2.5, 0.0)); locations.push(new FlxPoint(3.0, 1.0)); locations.push(new FlxPoint(3.5, 0.0)); locations.push(new FlxPoint(4.0, 1.0)); locations.push(new FlxPoint(4.5, 0.0)); locations.push(new FlxPoint(5.0, 1.0)); locations.push(new FlxPoint(5.5, 0.0)); locations.push(new FlxPoint(6.0, 1.0)); locations.push(new FlxPoint(6.5, 0.0)); locations.push(new FlxPoint(7.0, 1.0)); locations.push(new FlxPoint(7.5, 0.0)); } else { locations.push(new FlxPoint(0.0, 1.0)); locations.push(new FlxPoint(1.0, 1.0)); locations.push(new FlxPoint(1.5, 0.0)); locations.push(new FlxPoint(2.0, 1.0)); locations.push(new FlxPoint(2.5, 0.0)); locations.push(new FlxPoint(3.0, 1.0)); locations.push(new FlxPoint(3.5, 0.0)); locations.push(new FlxPoint(4.0, 1.0)); locations.push(new FlxPoint(4.5, 0.0)); locations.push(new FlxPoint(5.0, 1.0)); locations.push(new FlxPoint(5.5, 0.0)); locations.push(new FlxPoint(6.0, 1.0)); locations.push(new FlxPoint(6.5, 0.0)); locations.push(new FlxPoint(7.0, 1.0)); locations.push(new FlxPoint(7.5, 0.0)); } for (i in 0...critterColors.length) { var newItemImage:FlxSprite = new FlxSprite(x + 107 + locations[i].x * 30, y + locations[i].y * 30); Critter.loadPaletteShiftedGraphic(newItemImage, critterColors[i], AssetPaths.critter_item_icon__png, true, 30, 30); _state.addMenuItem(newItemImage); critterFrames.push(_state.addMenuGraphic(AssetPaths.critter_item_frame__png, newItemImage.x, newItemImage.y, 30, 30)); } y += 30; return y + 40; } override public function mousePressed() { for (i in 0...critterFrames.length) { if (handleIconClick(i)) { // only one icon is clicked break; } } } public function handleIconClick(i:Int):Bool { if (critterFrames[i].getHitbox().containsPoint(FlxG.mouse.getPosition())) { if (PlayerData.disabledPegColors.indexOf(critterColors[i].englishBackup) == -1) { PlayerData.disabledPegColors.push(critterColors[i].englishBackup); } else { PlayerData.disabledPegColors.remove(critterColors[i].englishBackup); } updateIconGraphic(i); return true; } return false; } public function updateIconGraphic(i:Int) { if (PlayerData.disabledPegColors.indexOf(critterColors[i].englishBackup) == -1) { // it's enabled... _state.addCritter(critters[i]); critterFrames[i].animation.frameIndex = 0; } else { // it's disabled... _state.removeCritter(critters[i]); critterFrames[i].animation.frameIndex = 1; } } } /** * VisualItem encompassing all of the glove items (assorted gloves, insulated * gloves, ghost gloves, vanishing gloves) */ private class ViGloveColors extends VisualItem { var categorizedGloveColors:Array<Array<GloveColor>> = [[], [], []]; var categorizedGloveSprites:Array<Array<FlxSprite>> = [[], [], []]; var categorizedGloveFrames:Array<Array<FlxSprite>> = [[], [], []]; var categorySprites:Array<FlxSprite> = []; var categoryFrames:Array<FlxSprite> = []; var selectedCategoryIndex:Int = 0; var gloveColors:Array<GloveColor>; var tableGloveSprites:Array<FlxSprite> = []; var tableGloveShadows:Array<FlxSprite> = []; public function new(state:ItemsMenuState) { super(state); gloveColors = []; gloveColors.push({fillColor:0xffe7e8e1, lineColor:0xffb3ada2, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // white if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_ASSORTED_GLOVES)) { gloveColors.push({fillColor:0xffebe79c, lineColor:0xffbca66a, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // cream gloveColors.push({fillColor:0xff6d5039, lineColor:0xff4a3124, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // brown gloveColors.push({fillColor:0xffa59b8f, lineColor:0xff5c544c, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // grey gloveColors.push({fillColor:0xff6edce0, lineColor:0xff59c1c9, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // cyan gloveColors.push({fillColor:0xff6cc14e, lineColor:0xff498a2f, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // green gloveColors.push({fillColor:0xff6d72c7, lineColor:0xff474881, minAlpha:1.0, maxAlpha:1.0, insulated:false}); // blue } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_INSULATED_GLOVES)) { gloveColors.push({fillColor:0xffefe659, lineColor:0xffc1a144, minAlpha:1.0, maxAlpha:1.0, insulated:true}); // yellow gloveColors.push({fillColor:0xffefbc59, lineColor:0xffd89140, minAlpha:1.0, maxAlpha:1.0, insulated:true}); // orange gloveColors.push({fillColor:0xff131312, lineColor:0xff4c4945, minAlpha:1.0, maxAlpha:1.0, insulated:true}); // black } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GHOST_GLOVES)) { gloveColors.push({fillColor:0xfff2ebdd, lineColor:0xffdcd7dd, minAlpha:0.70, maxAlpha:0.70, insulated:false}); // white gloveColors.push({fillColor:0xff5c5c5c, lineColor:0xff363433, minAlpha:0.75, maxAlpha:0.75, insulated:false}); // grey gloveColors.push({fillColor:0xff502e6a, lineColor:0xff7b448a, minAlpha:0.85, maxAlpha:0.85, insulated:false}); // dark purple gloveColors.push({fillColor:0xff964980, lineColor:0xff6f2f5b, minAlpha:0.75, maxAlpha:0.75, insulated:false}); // light purple gloveColors.push({fillColor:0xff131312, lineColor:0xff131312, minAlpha:0.65, maxAlpha:0.65, insulated:false}); // solid black gloveColors.push({fillColor:0xcc131312, lineColor:0xff131312, minAlpha:0.75, maxAlpha:0.75, insulated:false}); // hollow black gloveColors.push({fillColor:0xcc75ffe1, lineColor:0xffb8ffeb, minAlpha:0.70, maxAlpha:0.70, insulated:false}); // ice } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_VANISHING_GLOVES)) { gloveColors.push({fillColor:0xffe7e8e1, lineColor:0xffb3ada2, minAlpha:0.60, maxAlpha:1.00, insulated:false}); // white gloveColors.push({fillColor:0xff502e6a, lineColor:0xff7b448a, minAlpha:0.50, maxAlpha:0.85, insulated:false}); // dark purple gloveColors.push({fillColor:0xffa59b8f, lineColor:0xff5c544c, minAlpha:0.40, maxAlpha:1.00, insulated:false}); // grey gloveColors.push({fillColor:0xff964980, lineColor:0xff6f2f5b, minAlpha:0.40, maxAlpha:0.75, insulated:false}); // light purple gloveColors.push({fillColor:0xff131312, lineColor:0xff4c4945, minAlpha:0.25, maxAlpha:1.00, insulated:false}); // black } BetterFlxRandom.shuffle(gloveColors); for (gloveColor in gloveColors) { var categoryIndex; if (gloveColor.minAlpha == 1.0 && gloveColor.maxAlpha == 1.0) { // opaque categoryIndex = 0; } else if (gloveColor.minAlpha != gloveColor.maxAlpha) { // disappearing categoryIndex = 1; } else { // translucent categoryIndex = 2; } categorizedGloveColors[categoryIndex].push(gloveColor); if (isCurrentGloveColor(gloveColor)) { selectedCategoryIndex = categoryIndex; } } } override public function addGraphics() { for (i in 0...gloveColors.length) { var gloveSprite:FlxSprite = new FlxSprite(); var gloveIndex:Int; if (i <= 10) { gloveSprite.setPosition(99, 119); gloveIndex = i; } else if (i <= 21) { gloveSprite.setPosition(106, 137); gloveIndex = 21 - i; } else { // shouldn't reach here... gloveSprite.setPosition(113, 155); gloveIndex = i % 11; } gloveSprite.makeGraphic(200, 100, FlxColor.TRANSPARENT, true); var gloveStamp:FlxSprite = new FlxSprite(0, 0); gloveStamp.loadGraphic(AssetPaths.gloves_items__png, true, 200, 100, true); gloveStamp.animation.frameIndex = gloveIndex; gloveStamp.pixels.threshold(gloveStamp.pixels, new Rectangle(0, 0, gloveStamp.pixels.width, gloveStamp.pixels.height), new Point(0, 0), '==', 0xffffffff, gloveColors[i].fillColor); gloveStamp.pixels.threshold(gloveStamp.pixels, new Rectangle(0, 0, gloveStamp.pixels.width, gloveStamp.pixels.height), new Point(0, 0), '==', 0xff000000, gloveColors[i].lineColor); gloveStamp.alpha = gloveColors[i].maxAlpha; gloveSprite.stamp(gloveStamp); tableGloveSprites.push(gloveSprite); _state._itemGraphics.add(gloveSprite); var shadowSprite:FlxSprite = new FlxSprite(gloveSprite.x, gloveSprite.y); shadowSprite.loadGraphic(AssetPaths.gloves_items_shadow__png, true, 200, 100); shadowSprite.animation.frameIndex = gloveIndex; tableGloveShadows.push(shadowSprite); _state.shadowGroup.add(shadowSprite); } updateGraphics(); } override public function addMenu(y:Int):Int { var x:Int = Std.int(FlxG.width / 2 + 4); _state.addMenuText(FlxG.width / 2 + 4, y + 5, "Gloves:"); var categoryLocs:Array<FlxPoint> = []; categoryLocs.push(new FlxPoint(0.0, 1.0)); categoryLocs.push(new FlxPoint(1.0, 1.0)); categoryLocs.push(new FlxPoint(2.0, 1.0)); for (c in 0...3) { if (categorizedGloveColors[c].length == 0) { // no gloves in category; don't add button continue; } var categorySprite:FlxSprite = new FlxSprite(x + 3 + categoryLocs[categoryFrames.length].x * 30, y + categoryLocs[categoryFrames.length].y * 30); categorySprite.loadGraphic(AssetPaths.glove_category_icon__png, true, 30, 30, true); categorySprite.animation.frameIndex = c; _state.addMenuItem(categorySprite); categorySprites.push(categorySprite); categoryFrames.push(_state.addMenuGraphic(AssetPaths.critter_item_frame__png, categorySprite.x, categorySprite.y, 30, 30)); } if (categorySprites.length == 1) { // only one category; don't display category buttons categorySprites[0].visible = false; categoryFrames[0].visible = false; } var gloveLocs:Array<FlxPoint> = []; gloveLocs.push(new FlxPoint(3.5, 0.0)); gloveLocs.push(new FlxPoint(4.0, 1.0)); gloveLocs.push(new FlxPoint(4.5, 0.0)); gloveLocs.push(new FlxPoint(5.0, 1.0)); gloveLocs.push(new FlxPoint(5.5, 0.0)); gloveLocs.push(new FlxPoint(6.0, 1.0)); gloveLocs.push(new FlxPoint(6.5, 0.0)); gloveLocs.push(new FlxPoint(7.0, 1.0)); gloveLocs.push(new FlxPoint(7.5, 0.0)); gloveLocs.push(new FlxPoint(8.0, 1.0)); gloveLocs.push(new FlxPoint(8.5, 0.0)); gloveLocs.push(new FlxPoint(9.0, 1.0)); gloveLocs.push(new FlxPoint(9.5, 0.0)); gloveLocs.push(new FlxPoint(10.0, 1.0)); for (c in 0...3) { for (i in 0...categorizedGloveColors[c].length) { var gloveSprite:FlxSprite = new FlxSprite(x + 3 + gloveLocs[i].x * 30, y + gloveLocs[i].y * 30); gloveSprite.makeGraphic(30, 30, FlxColor.TRANSPARENT, true); var gloveStamp:FlxSprite = new FlxSprite(); if (categorizedGloveColors[c][i].maxAlpha != categorizedGloveColors[c][i].minAlpha) { // split glove graphic into left/right halves gloveStamp.loadGraphic(AssetPaths.glove_item_icon__png, true, 15, 30, true); } else { gloveStamp.loadGraphic(AssetPaths.glove_item_icon__png, false, 30, 30, true); } gloveStamp.pixels.threshold(gloveStamp.pixels, new Rectangle(0, 0, gloveStamp.pixels.width, gloveStamp.pixels.height), new Point(0, 0), '==', 0xffffffff, categorizedGloveColors[c][i].fillColor); gloveStamp.pixels.threshold(gloveStamp.pixels, new Rectangle(0, 0, gloveStamp.pixels.width, gloveStamp.pixels.height), new Point(0, 0), '==', 0xff000000, categorizedGloveColors[c][i].lineColor); if (categorizedGloveColors[c][i].maxAlpha != categorizedGloveColors[c][i].minAlpha) { gloveStamp.alpha = categorizedGloveColors[c][i].maxAlpha; gloveStamp.animation.frameIndex = 0; gloveSprite.stamp(gloveStamp, 0, 0); gloveStamp.alpha = categorizedGloveColors[c][i].minAlpha; gloveStamp.animation.frameIndex = 1; gloveSprite.stamp(gloveStamp, 15, 0); } else { gloveStamp.alpha = categorizedGloveColors[c][i].maxAlpha; gloveSprite.stamp(gloveStamp, 0, 0); } if (categorizedGloveColors[c][i].insulated) { var c:FlxColor = FlxColor.fromInt(categorizedGloveColors[c][i].fillColor); var isDark:Bool = c.redFloat + c.greenFloat + c.blueFloat < 1.5; var lightningSpr:FlxSprite = new FlxSprite(); lightningSpr.loadGraphic(AssetPaths.insulation_overlay__png, true, 30, 30); if (isDark) { lightningSpr.animation.frameIndex = 1; } gloveSprite.stamp(lightningSpr); } _state.addMenuItem(gloveSprite); categorizedGloveSprites[c].push(gloveSprite); categorizedGloveFrames[c].push(_state.addMenuGraphic(AssetPaths.critter_item_frame__png, gloveSprite.x, gloveSprite.y, 30, 30)); } } y += 30; return y + 40; } override public function mousePressed() { var handledClick:Bool = false; for (i in 0...categoryFrames.length) { if (handleCategoryClick(i)) { handledClick = true; break; } } for (i in 0...categorizedGloveFrames[selectedCategoryIndex].length) { if (handleIconClick(i)) { handledClick = true; break; } } if (handledClick) { updateGraphics(); } } public function handleCategoryClick(i:Int):Bool { if (categoryFrames[i].visible && categoryFrames[i].getHitbox().containsPoint(FlxG.mouse.getPosition())) { selectedCategoryIndex = categorySprites[i].animation.frameIndex; return true; } return false; } public function handleIconClick(i:Int):Bool { if (categorizedGloveFrames[selectedCategoryIndex][i].visible && categorizedGloveFrames[selectedCategoryIndex][i].getHitbox().containsPoint(FlxG.mouse.getPosition())) { PlayerData.cursorFillColor = categorizedGloveColors[selectedCategoryIndex][i].fillColor; PlayerData.cursorLineColor = categorizedGloveColors[selectedCategoryIndex][i].lineColor; PlayerData.cursorMinAlpha = categorizedGloveColors[selectedCategoryIndex][i].minAlpha; PlayerData.cursorMaxAlpha = categorizedGloveColors[selectedCategoryIndex][i].maxAlpha; PlayerData.cursorInsulated = categorizedGloveColors[selectedCategoryIndex][i].insulated; CursorUtils.initializeHandSprite(_state._handSprite, AssetPaths.hands__png); _state._handSprite.setSize(3, 3); _state._handSprite.offset.set(69, 87); _state.handOpacityTween0 = FlxTweenUtil.retween(_state.handOpacityTween0, _state._handSprite, {alpha:PlayerData.cursorMinAlpha}, 0.5, {ease:FlxEase.circOut, startDelay:0.5}); _state.handOpacityTween1 = FlxTweenUtil.retween(_state.handOpacityTween1, _state._handSprite, {alpha:PlayerData.cursorMaxAlpha}, 0.5, {ease:FlxEase.circOut, startDelay:2.0}); return true; } return false; } public function updateGraphics() { for (c in 0...categoryFrames.length) { var categoryIndex:Int = categorySprites[c].animation.frameIndex; categoryFrames[c].animation.frameIndex = (selectedCategoryIndex == categoryIndex) ? 0 : 1; } for (c in 0...categorySprites.length) { var categoryIndex:Int = categorySprites[c].animation.frameIndex; for (i in 0...categorizedGloveColors[categoryIndex].length) { categorizedGloveSprites[categoryIndex][i].visible = (selectedCategoryIndex == categoryIndex); categorizedGloveFrames[categoryIndex][i].visible = (selectedCategoryIndex == categoryIndex); } } for (i in 0...categorizedGloveColors[selectedCategoryIndex].length) { if (isCurrentGloveColor(categorizedGloveColors[selectedCategoryIndex][i])) { // it's enabled... categorizedGloveFrames[selectedCategoryIndex][i].animation.frameIndex = 0; } else { // it's disabled... categorizedGloveFrames[selectedCategoryIndex][i].animation.frameIndex = 1; } } for (i in 0...gloveColors.length) { tableGloveSprites[i].visible = !isCurrentGloveColor(gloveColors[i]); tableGloveShadows[i].visible = tableGloveSprites[i].visible; } } private function isCurrentGloveColor(gloveColor:GloveColor) { return PlayerData.cursorFillColor == gloveColor.fillColor && PlayerData.cursorLineColor == gloveColor.lineColor && PlayerData.cursorMinAlpha == gloveColor.minAlpha && PlayerData.cursorMaxAlpha == gloveColor.maxAlpha && PlayerData.cursorInsulated == gloveColor.insulated; } } typedef GloveColor = { lineColor:Int, fillColor:Int, minAlpha:Float, maxAlpha:Float, insulated:Bool }
argonvile/monster
source/ItemsMenuState.hx
hx
unknown
49,557
package; import poke.PokeWindow; import poke.abra.AbraDialog; import flixel.FlxG; import flixel.math.FlxMath; import poke.grov.GrovyleDialog; import openfl.utils.Object; import minigame.MinigameState; import poke.luca.LucarioDialog; import poke.sexy.SexyState; import puzzle.Puzzle; import puzzle.PuzzleState; /** * Utility methods related to the dialog before each puzzle, as well as a few * other things that happen at the start and end of each puzzle. */ class LevelIntroDialog { private static var FIXED_CHATS:String = "fixedChats"; private static var RANDOM_CHATS:String = "randomChats"; /** * List of professor permutations. Not all Pokemon appear on all * difficulties by design * * Sandslash (4) appears on the easiest 2 difficulties * Smeargle (6) appears on the easiest 3 difficulties * Buizel (1) appears in the middle 2 difficulties * Rhydon (5) appears on the hardest 3 difficulties * Abra (0) only appears on the hardest 2 difficulties * Grovyle (3) appears on the easiest and hardest difficulty */ public static var professorPermutations:Array<Array<Int>> = [ [6, 4, 1, 5], [4, 1, 5, 3], [6, 4, 0, 5], [3, 5, 6, 0], [3, 6, 0, 5], [3, 5, 1, 0], [3, 1, 5, 0], [4, 1, 6, 0], [4, 5, 1, 3], [6, 5, 0, 3], [3, 4, 0, 5], [3, 4, 5, 0], [4, 1, 6, 3], [3, 4, 1, 5], [4, 1, 5, 0], [4, 5, 1, 0], [4, 1, 0, 3], [3, 4, 1, 0], [6, 4, 1, 0], [4, 6, 5, 3], [3, 1, 0, 5], [3, 4, 6, 5], [3, 1, 6, 0], [6, 1, 0, 3], [6, 4, 5, 3], [4, 6, 0, 3], [3, 6, 1, 0], [4, 6, 5, 0], [6, 4, 5, 0], [3, 6, 1, 5], [3, 6, 5, 0], [6, 5, 1, 0], [4, 6, 1, 0], [4, 6, 1, 3], [4, 6, 0, 5], [4, 1, 6, 5], [6, 4, 1, 3], [4, 5, 0, 3], [6, 1, 5, 0], [6, 4, 0, 3], [3, 4, 6, 0], [6, 1, 5, 3], [3, 1, 6, 5], [6, 5, 1, 3], [6, 1, 0, 5], [4, 1, 0, 5], [4, 5, 6, 3], [4, 6, 1, 5], [4, 5, 6, 0] ]; /* * List of professor permutations where the wildcard professor appears in * the easiest 3 difficulties. This is important if a wildcard professor * shows up before the player has unlocked the hardest difficulty * * 99 = Wildcard Professor */ public static var rareProfessorPermutations4:Array<Array<Int>> = [ [3, 99, 5, 0], [99, 4, 5, 0], [99, 4, 5, 3], [6, 1, 99, 5], [6, 1, 99, 0], [3, 99, 1, 0], [3, 5, 99, 0], [99, 4, 6, 3], [99, 6, 1, 3], [99, 4, 1, 3], [6, 1, 99, 3], [4, 6, 99, 0], [4, 6, 99, 5], [3, 99, 6, 5], [3, 6, 99, 5], [4, 99, 6, 5], [99, 1, 5, 3], [6, 4, 99, 0], [99, 1, 6, 3], [99, 1, 6, 0], [6, 99, 0, 3], [3, 99, 6, 0], [99, 6, 1, 0], [4, 99, 1, 5], [6, 5, 99, 0], [99, 5, 1, 3], [4, 1, 99, 0], [99, 6, 5, 3], [99, 4, 6, 0], [99, 5, 6, 3], [4, 99, 0, 5], [99, 4, 6, 5], [99, 6, 5, 0], [6, 99, 1, 3], [99, 6, 1, 5], [99, 4, 0, 5], [4, 99, 6, 0], [99, 6, 0, 5], [6, 99, 1, 0], [3, 1, 99, 5], [3, 4, 99, 5], [99, 1, 0, 3], [4, 1, 99, 3], [99, 5, 1, 0], [3, 1, 99, 0], [4, 99, 0, 3], [6, 4, 99, 3], [6, 4, 99, 5], [99, 1, 0, 5], [3, 99, 0, 5], [99, 1, 6, 5], [4, 5, 99, 0], [99, 5, 6, 0], [4, 1, 99, 5], [6, 99, 5, 3], [4, 99, 6, 3], [3, 4, 99, 0], [6, 99, 1, 5], [3, 99, 1, 5], [4, 6, 99, 3], [99, 4, 1, 0], [3, 6, 99, 0], [99, 5, 0, 3], [4, 99, 5, 3], [99, 4, 0, 3], [99, 4, 1, 5], [6, 99, 5, 0], [4, 99, 1, 3], [99, 1, 5, 0], [4, 5, 99, 3], [4, 99, 5, 0], [6, 99, 0, 5], [4, 99, 1, 0], [6, 5, 99, 3], [99, 6, 0, 3] ]; /* * List of professor permutations including a wildcard professor. This is * used when an unusual pokemon like Lucario is visiting * * 99 = Wildcard Professor */ public static var rareProfessorPermutations5:Array<Array<Int>> = [ [3, 99, 5, 0], [4, 6, 5, 99], [99, 4, 5, 0], [99, 4, 5, 3], [6, 1, 99, 5], [6, 1, 99, 0], [3, 99, 1, 0], [3, 5, 99, 0], [99, 4, 6, 3], [99, 6, 1, 3], [4, 1, 6, 99], [99, 4, 1, 3], [6, 1, 99, 3], [4, 6, 99, 0], [4, 6, 99, 5], [3, 99, 6, 5], [3, 6, 99, 5], [4, 99, 6, 5], [6, 4, 5, 99], [99, 1, 5, 3], [6, 4, 99, 0], [99, 1, 6, 3], [99, 1, 6, 0], [6, 99, 0, 3], [3, 4, 6, 99], [3, 5, 1, 99], [3, 99, 6, 0], [99, 6, 1, 0], [4, 99, 1, 5], [6, 5, 99, 0], [99, 5, 1, 3], [4, 1, 99, 0], [4, 1, 5, 99], [3, 4, 5, 99], [3, 6, 1, 99], [99, 6, 5, 3], [99, 4, 6, 0], [99, 5, 6, 3], [4, 99, 0, 5], [99, 4, 6, 5], [4, 5, 1, 99], [3, 1, 5, 99], [3, 5, 6, 99], [3, 4, 0, 99], [99, 6, 5, 0], [6, 99, 1, 3], [99, 6, 1, 5], [99, 4, 0, 5], [4, 99, 6, 0], [99, 6, 0, 5], [3, 6, 0, 99], [6, 99, 1, 0], [3, 1, 99, 5], [3, 6, 5, 99], [3, 4, 99, 5], [99, 1, 0, 3], [4, 1, 99, 3], [99, 5, 1, 0], [3, 1, 99, 0], [4, 99, 0, 3], [6, 4, 99, 3], [6, 4, 99, 5], [99, 1, 0, 5], [3, 99, 0, 5], [4, 1, 0, 99], [99, 1, 6, 5], [4, 6, 1, 99], [4, 5, 99, 0], [99, 5, 6, 0], [6, 4, 0, 99], [4, 1, 99, 5], [3, 4, 1, 99], [6, 1, 0, 99], [6, 99, 5, 3], [6, 4, 1, 99], [4, 99, 6, 3], [3, 4, 99, 0], [6, 99, 1, 5], [3, 99, 1, 5], [4, 6, 99, 3], [99, 4, 1, 0], [3, 6, 99, 0], [4, 5, 6, 99], [99, 5, 0, 3], [3, 1, 6, 99], [4, 99, 5, 3], [6, 5, 0, 99], [99, 4, 0, 3], [99, 4, 1, 5], [4, 5, 0, 99], [6, 99, 5, 0], [4, 99, 1, 3], [6, 5, 1, 99], [6, 1, 5, 99], [99, 1, 5, 0], [3, 1, 0, 99], [4, 5, 99, 3], [4, 6, 0, 99], [4, 99, 5, 0], [6, 99, 0, 5], [4, 99, 1, 0], [3, 5, 0, 99], [6, 5, 99, 3], [99, 6, 0, 3] ]; /* * Dialog sequences might occasionally want to remember a choice from a * previous puzzle. The "pushes" field stores this kind of temporary state. */ public static var pushes:Array<Int> = [0, 0, 0]; // 120 pseudo-random ints for random chats private static var pseudoRandom:Array<Int> = [ 64, 75, 96, 70, 27, 10, 74, 50, 34, 18, 18, 61, 73, 58, 99, 59, 48, 94, 81, 59, 11, 12, 13, 14, 15, 53, 82, 99, 49, 83, 52, 96, 25, 26, 91, 15, 89, 97, 44, 10, 86, 31, 23, 60, 92, 96, 91, 23, 53, 83, 87, 17, 99, 83, 67, 82, 79, 11, 77, 78, 10, 69, 70, 51, 78, 66, 87, 88, 30, 22, 11, 88, 92, 73, 80, 99, 29, 27, 34, 18, 72, 39, 67, 50, 77, 95, 35, 72, 48, 38, 96, 59, 92, 76, 30, 20, 71, 42, 48, 47, 41, 26, 17, 89, 97, 22, 75, 40, 45, 96, 89, 84, 72, 62, 11, 54, 31, 18, 64, 77 ]; public static function generateSexyBeforeDialog<T:PokeWindow>(sexyState:SexyState<T>):Array<Array<Object>> { var clazz:Dynamic = sexyState._pokeWindow._dialogClass; var prefix:String = sexyState._pokeWindow._prefix; var sexyBeforeChat:Int = Reflect.field(PlayerData, prefix + "SexyBeforeChat"); var sexyBeforeBad:Array<Dynamic> = Reflect.field(clazz, "sexyBeforeBad"); var sexyBeforeChats:Array<Dynamic> = Reflect.field(clazz, "sexyBeforeChats"); var unlockedChats:Map<String, Bool> = getUnlockedChats(clazz); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (PlayerData.cursorSmellTimeRemaining > 0 && (!PlayerData.playerIsInDen || PlayerData.denSexCount == 0)) { if (prefix == "magn" || prefix == "grim") { // magnezone and grimer don't notice... } else { PlayerData.appendChatHistory(prefix + ".cursorSmell"); var cursorSmellFunc:Dynamic = Reflect.field(clazz, "cursorSmell"); cursorSmellFunc(tree, sexyState); return tree; } } if (PlayerData.playerIsInDen) { var denDialogFunc:Dynamic = Reflect.field(clazz, "denDialog"); var denDialog:DenDialog = denDialogFunc(sexyState); if (PlayerData.denSexCount == 0) { // first time having sex in den denDialog.getSexGreeting(tree); return tree; } else { // second, third time having sex in den denDialog.getRepeatSexGreeting(tree); return tree; } } var chat:Dynamic = null; if (sexyBeforeChat < sexyBeforeBad.length) { PlayerData.appendChatHistory(prefix + ".sexyBeforeBad." + sexyBeforeChat); chat = sexyBeforeBad[sexyBeforeChat]; } else { var chatHistoryStr:String; var chats:Array<Dynamic> = sexyBeforeChats.copy(); { /* * We check for conflicts before loading the random chat sequence. We don't want * a chat sequence to randomly involve a pokemon the player hasn't meet yet. */ var index = chats.length - 1; var chatHistoryStr:String; do { chatHistoryStr = prefix + ".sexyBeforeChats." + index; if (isLockedChat(unlockedChats, chatHistoryStr)) { chats.splice(index, 1); } index--; } while (index >= 0); } if (chats.length > 0) { var index:Int; if (sexyBeforeChat == 99) { // special value; default to the 'intro' sexyBeforeChat index = 0; } else { index = pseudoRandom[sexyBeforeChat - sexyBeforeBad.length] % chats.length; } var chatHistoryStr:String = prefix + ".sexyBeforeChats." + sexyBeforeChats.indexOf(chats[index]); PlayerData.appendChatHistory(chatHistoryStr); chat = chats[index]; } } if (chat != null) { chat(tree, sexyState); } return tree; } public static function generateSexyAfterDialog<T:PokeWindow>(sexyState:SexyState<T>):Array<Array<Object>> { var clazz:Dynamic = sexyState._pokeWindow._dialogClass; var prefix:String = sexyState._pokeWindow._prefix; var sexyAfterChat:Int = Reflect.field(PlayerData, prefix + "SexyAfterChat"); var sexyAfterGood:Array<Dynamic> = Reflect.field(clazz, "sexyAfterGood"); var sexyAfterChats:Array<Dynamic> = Reflect.field(clazz, "sexyAfterChats"); var sexyRecords:Array<Float> = Reflect.field(PlayerData, prefix + "SexyRecords"); var unlockedChats:Map<String, Bool> = getUnlockedChats(clazz); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (PlayerData.playerIsInDen) { var denDialogFunc:Dynamic = Reflect.field(clazz, "denDialog"); var denDialog:DenDialog = denDialogFunc(sexyState); var exhausted:Bool = false; if (PlayerData.denSexCount > 0) { var profIndex:Int = PlayerData.PROF_PREFIXES.indexOf(sexyState._pokeWindow._prefix); var formulaThing:Float = (PlayerData.denSexCount - PlayerData.DEN_SEX_RESILIENCE[profIndex]) / PlayerData.denSexCount; var randFloat:Float = FlxG.random.float(); exhausted = randFloat < formulaThing; } if (PlayerData.denTotalReward >= PlayerData.DEN_MAX_REWARD || exhausted) { denDialog.getTooMuchSex(tree); } else { denDialog.getReplaySex(tree); } return tree; } var chat:Dynamic = null; if (sexyState.totalHeartsEmitted > sexyRecords[0] && sexyState.totalHeartsEmitted > sexyRecords[1]) { var index:Int = LevelIntroDialog.pseudoRandom[sexyAfterChat] % sexyAfterGood.length; PlayerData.appendChatHistory(prefix + ".sexyAfterGood." + index); chat = sexyAfterGood[index]; } else { var chatHistoryStr:String; var chats:Array<Dynamic> = sexyAfterChats.copy(); { /* * We check for conflicts before loading the random chat sequence. We don't want * a chat sequence to randomly involve a pokemon the player hasn't meet yet. */ var index = chats.length - 1; var chatHistoryStr:String; do { chatHistoryStr = prefix + ".sexyAfterChats." + index; if (isLockedChat(unlockedChats, chatHistoryStr)) { chats.splice(index, 1); } index--; } while (index >= 0); } if (chats.length > 0) { var index:Int; if (sexyAfterChat == 99) { // special value; default to the 'intro' sexyAfterChat index = 0; } else { index = pseudoRandom[sexyAfterChat] % chats.length; } var chatHistoryStr:String = prefix + ".sexyAfterChats." + sexyAfterChats.indexOf(chats[index]); PlayerData.appendChatHistory(chatHistoryStr); chat = chats[index]; } } if (chat != null) { chat(tree, sexyState); } Reflect.setField(PlayerData, prefix + "SexyAfterChat", FlxG.random.int(0, 99)); return tree; } /** * Return a big number which only changes if the chat is rotated. This number is useful for * generating random events, if we don't want the user to be able to game the random events * by quitting the game. */ public static function getChatChecksum(puzzleState:PuzzleState, ?seed:Int = 5381):Int { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var playerChats:Array<Int> = Reflect.field(PlayerData, prefix + "Chats"); var sum:Int = seed; // append a hash which varies based on the pokemon for (i in 0...prefix.length) { sum = sum * 193 + prefix.charCodeAt(i); } if (playerChats != null) { // append a hash which varies based on the pokemon's chat for (playerChat in playerChats) { sum = sum * 463 + playerChat; } } return Std.int(Math.abs(sum)); } public static function generateDialog(puzzleState:PuzzleState) { pushes[PlayerData.level] = 0; var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var playerChats:Array<Int> = Reflect.field(PlayerData, prefix + "Chats"); var randomChats:Array<Dynamic> = Reflect.field(clazz, RANDOM_CHATS); var fixedChats:Array<Dynamic> = Reflect.field(clazz, FIXED_CHATS); var unlockedChats:Map<String, Bool> = getUnlockedChats(clazz); if (PlayerData.difficulty == PlayerData.Difficulty._7Peg) { playerChats = PlayerData.abra7PegChats; randomChats = AbraDialog.random7Peg; fixedChats = []; } var tree:Array<Array<Object>> = new Array<Array<Object>>(); var chat:Dynamic = null; if (fixedChats != null && playerChats[0] < fixedChats.length) { PlayerData.appendChatHistory(prefix + "." + FIXED_CHATS + "." + playerChats[0]); chat = fixedChats[playerChats[0]]; } else if (randomChats != null) { var index0:Int = Std.int(Math.min(PlayerData.level, 2)); var chats:Array<Dynamic> = randomChats[index0].copy(); var chatType:String = PlayerData.difficulty == PlayerData.Difficulty._7Peg ? "random7Peg" : RANDOM_CHATS; { /* * We check for conflicts before loading the random chat sequence. We don't want * a chat sequence to randomly involve a pokemon the player hasn't meet yet. */ var index1 = chats.length - 1; var chatHistoryStr:String; do { chatHistoryStr = prefix + "." + chatType + "." + index0 + "." + index1; if (isLockedChat(unlockedChats, chatHistoryStr)) { chats.splice(index1, 1); } index1--; } while (index1 >= 0); } if (chats.length > 0) { var index1:Int = pseudoRandom[playerChats[0] - fixedChats.length + PlayerData.level] % chats.length; var chatHistoryStr:String = prefix + "." + chatType + "." + index0 + "." + randomChats[index0].indexOf(chats[index1]); PlayerData.appendChatHistory(chatHistoryStr); chat = chats[index1]; } } if (chat != null) { chat(tree, puzzleState); } return tree; } /** * getUnlockedChats() is a method implemented by each dialog class. It should have a NULL or * TRUE entry if the chat is OK. If the entry is FALSE, then the chat sequence is locked. */ static private function getUnlockedChats(clazz:Dynamic):Map<String, Bool> { if (!Reflect.hasField(clazz, "getUnlockedChats")) { // getUnlockedChats method not defined return new Map<String, Bool>(); } return Reflect.callMethod(clazz, Reflect.field(clazz, "getUnlockedChats"), []); } public static function isFixedChat(puzzleState:PuzzleState):Bool { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var playerChats:Array<Int> = Reflect.field(PlayerData, prefix + "Chats"); var fixedChats:Array<Dynamic> = Reflect.field(clazz, FIXED_CHATS); return playerChats[0] < fixedChats.length; } public static function generateBadGuessDialog(puzzleState:PuzzleState):Array<Array<Object>> { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var clueBad:Dynamic = Reflect.field(clazz, "clueBad"); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (clueBad == null) { clueBad = GrovyleDialog.clueBad; } clueBad(tree, puzzleState); return tree; } public static function generateInvalidAnswerDialog(puzzleState:PuzzleState):Array<Array<Object>> { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var clueBad:Dynamic = Reflect.field(clazz, "invalidAnswer"); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (clueBad == null) { clueBad = AbraDialog.invalidAnswer; } clueBad(tree, puzzleState); return tree; } public static function generateHelp(puzzleState:PuzzleState):Array<Array<Object>> { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (puzzleState._tutorial != null) { // if it's a tutorial, we append the "restart tutorial" option var tutorialHelp:Dynamic = Reflect.field(clazz, "tutorialHelp"); if (tutorialHelp == null) { if (puzzleState._pokeWindow._prefix == "abra") { tutorialHelp = AbraDialog.tutorialHelp; } else { tutorialHelp = GrovyleDialog.tutorialHelp; } } tutorialHelp(tree, puzzleState); } else { var help:Dynamic = Reflect.field(clazz, "help"); if (help == null) { help = GrovyleDialog.help; } help(tree, puzzleState); } return tree; } public static function generateMinigameHelp(dialogClass:Class<Dynamic>, minigameState:Dynamic):Array<Array<Object>> { var tree:Array<Array<Object>> = new Array<Array<Object>>(); var minigameHelp:Dynamic = Reflect.field(dialogClass, "minigameHelp"); if (minigameHelp == null) { minigameHelp = GrovyleDialog.minigameHelp; } minigameHelp(tree, minigameState); return tree; } public static function rotateChat() { var clazz:Dynamic = Type.resolveClass(PlayerData.PROF_DIALOG_CLASS[PlayerData.profIndex]); var prefix:String = PlayerData.PROF_PREFIXES[PlayerData.profIndex]; var playerChats:Array<Int> = Reflect.field(PlayerData, prefix + "Chats"); if (prefix == "magn" && PlayerData.magnGift == 1) { // received gift PlayerData.magnGift = 2; } if (prefix == "smea" && PlayerData.keclGift == 1) { // received gift PlayerData.keclGift = 2; } if (prefix == "rhyd" && PlayerData.rhydGift == 1) { // received gift; summon lucario PlayerData.rhydGift = 2; PlayerData.luckyProfSchedules.remove(PlayerData.PROF_PREFIXES.indexOf("luca")); PlayerData.luckyProfSchedules.insert(0, PlayerData.PROF_PREFIXES.indexOf("luca")); } while (playerChats.length < PlayerData.CHATLENGTH + 1) { appendToChatHistory(prefix); } playerChats.splice(0, 1); if (prefix == "abra") { PlayerData.abra7PegChats.splice(0, 1); while (PlayerData.abra7PegChats.length < PlayerData.CHATLENGTH) { PlayerData.abra7PegChats.push(FlxG.random.int(10, 99)); } } PlayerData.storeChatHistory(); } public static function appendToChatHistory(prefix:String) { var clazz:Dynamic = Type.resolveClass(PlayerData.PROF_DIALOG_CLASS[PlayerData.PROF_PREFIXES.indexOf(prefix)]); var playerChats:Array<Int> = Reflect.field(PlayerData, prefix + "Chats"); var fixedChats:Array<Dynamic> = Reflect.field(clazz, FIXED_CHATS); var unlockedChats:Map<String, Bool> = getUnlockedChats(clazz); if (prefix == "abra" && playerChats.length > 0 && playerChats[playerChats.length - 1] == AbraDialog.FINAL_CHAT_INDEX) { playerChats.push(AbraDialog.FINAL_CHAT_INDEX); } else if (playerChats.length > 0 && playerChats[playerChats.length - 1] < fixedChats.length) { // just had a fixed chat; append a random chat playerChats.push(FlxG.random.int(fixedChats.length, 99)); } else { // append a fixed chat, if possible var tmpFixedChats:Array<Dynamic> = fixedChats.copy(); // the first one is always an intro; never ever repeat it tmpFixedChats.splice(0, 1); { var i:Int = tmpFixedChats.length - 1; var chatType:String = FIXED_CHATS; while (i >= 0) { var chatHistoryStr:String = prefix + "." + chatType + "." + fixedChats.indexOf(tmpFixedChats[i]); if (PlayerData.recentChatCount(chatHistoryStr) > 0) { // recently had this chat tmpFixedChats.splice(i, 1); } else if (isLockedChat(unlockedChats, chatHistoryStr)) { // chat is locked tmpFixedChats.splice(i, 1); } else if (playerChats.indexOf(fixedChats.indexOf(tmpFixedChats[i])) != -1) { // chat is already scheduled tmpFixedChats.splice(i, 1); } i--; } } if (tmpFixedChats.length > 0) { // there are some tmpFixedChats they haven't seen; append one playerChats.push(fixedChats.indexOf(tmpFixedChats[0])); } else { // they've seen it all playerChats.push(FlxG.random.int(fixedChats.length, 99)); } } } static private function isLockedChat(unlockedChats:Map<String, Bool>, chatHistoryStr:String) { return unlockedChats[chatHistoryStr] == false; } /** * Increases the libido of the professors currently on the main screen, * except for the one who was just chosen */ public static function increaseProfReservoirs() { var profPrefixes:Array<String> = new Array<String>(); for (profIndex in 0...PlayerData.professors.length) { profPrefixes.push(PlayerData.PROF_PREFIXES[PlayerData.professors[profIndex]]); } PlayerData.prevProfPrefix = PlayerData.PROF_PREFIXES[PlayerData.profIndex]; var prevProfIndex:Int = PlayerData.PROF_PREFIXES.indexOf(PlayerData.prevProfPrefix); profPrefixes.remove(PlayerData.prevProfPrefix); FlxG.random.shuffle(profPrefixes); // shuffle so that the overflow professor will be random profPrefixes.sort(function(a, b) return -Reflect.compare(Reflect.field(PlayerData, a + "Reservoir"), Reflect.field(PlayerData, b + "Reservoir"))); var overflowProf:String = null; if (Reflect.field(PlayerData, profPrefixes[0] + "Reservoir") == 210) overflowProf = profPrefixes[0]; var distributedAmount:Int = Math.ceil(PlayerData.reservoirReward * 0.4); var distributedToyAmount:Int = Math.ceil(PlayerData.reservoirReward * 0.4); PlayerData.reservoirReward -= distributedAmount; /* * We determine an amount of libido points to distribute among the three unpicked * professors. The first professor gets about 60% of the points; the second gets 75% of * whatever's left, and the final professor gets everything left. However, if any professor * maxes out their libido, the spillover goes to the remaining professors. */ for (i in 0...3) { var reservoir:Int = Reflect.field(PlayerData, profPrefixes[i] + "Reservoir"); var amount:Int = Math.ceil(Math.min(distributedAmount * [0.6, 0.75, 1.0][i], 210 - reservoir)); if (profPrefixes[i] == "smea") { // reduce libido given to smeargle var limit:Int; if (reservoir >= 55) { limit = 2; } else if (reservoir >= 50) { limit = 4; } else if (reservoir >= 40) { limit = 7; } else { limit = 13; } limit = FlxG.random.int(0, limit); var bankAmount:Int = Std.int(FlxMath.bound(amount - limit, 0, 210 - PlayerData.smeaReservoirBank)); PlayerData.smeaReservoirBank += bankAmount; amount -= bankAmount; distributedAmount -= bankAmount; amount = Std.int(FlxMath.bound(amount, 0, limit)); } Reflect.setField(PlayerData, profPrefixes[i] + "Reservoir", reservoir + amount); distributedAmount -= amount; } /* * For toy libido points, we just split them evenly between the four professors */ for (profIndex in PlayerData.professors) { var profPrefix:String = PlayerData.PROF_PREFIXES[profIndex]; var toyReservoir:Int = Reflect.field(PlayerData, profPrefix + "ToyReservoir"); var toyAmount:Int = Math.ceil(Math.min(distributedToyAmount * 0.25, toyReservoir == -1 ? 0 : 180 - toyReservoir)); if (profPrefix == "smea") { // reduce libido given to smeargle var limit:Int; if (toyReservoir >= 45) { limit = 2; } else if (toyReservoir >= 40) { limit = 4; } else if (toyReservoir >= 30) { limit = 7; } else { limit = 13; } limit = FlxG.random.int(0, limit); var toyBankAmount:Int = Std.int(FlxMath.bound(toyAmount - limit, 0, 180 - PlayerData.smeaToyReservoirBank)); PlayerData.smeaToyReservoirBank += toyBankAmount; toyAmount -= toyBankAmount; } Reflect.setField(PlayerData, profPrefix + "ToyReservoir", toyReservoir + toyAmount); } if (distributedAmount > 0) { if (overflowProf == null) { // reservoir overflow Reflect.setField(PlayerData, overflowProf + "Reservoir", 0); distributedAmount += 210; } PlayerData.reimburseCritterBonus(distributedAmount); } } /** * Swaps out the professors on the main screen for a new set * * @param profPrefixesToAvoid prefixes to avoid, if certain professors * shouldn't appear right now * @param afterPuzzle true if the player just solved a puzzle. If they're * deliberately avoiding a certain Pokemon like Grimer, we don't * want that pokemon to keep showing up over and over */ public static function rotateProfessors(profPrefixesToAvoid:Array<String>, afterPuzzle:Bool=true) { var luckyProf:Int = PlayerData.luckyProfSchedules[0]; if (afterPuzzle) { // player just solved a puzzle; did they snub a professor? is a new lucky professor assigned? if (luckyProf != -1) { if (PlayerData.luckyProfSchedules[0] == PlayerData.profIndex) { // just played with lucky prof PlayerData.luckyProfSchedules.remove(luckyProf); // insert somewhere in the back half of the schedule PlayerData.luckyProfSchedules.insert(FlxG.random.int(Math.ceil(PlayerData.luckyProfSchedules.length * 0.5), PlayerData.luckyProfSchedules.length), luckyProf); } else { // snubbed lucky prof if (FlxG.random.bool(44)) { PlayerData.luckyProfSchedules.remove(luckyProf); // insert somewhere in the back half of the schedule PlayerData.luckyProfSchedules.insert(FlxG.random.int(Math.ceil(PlayerData.luckyProfSchedules.length * 0.5), PlayerData.luckyProfSchedules.length), luckyProf); // also move some of the -1s, as compensation. we don't want to punish the player too hard PlayerData.luckyProfReward += 10; } } } while (PlayerData.luckyProfReward >= 5) { PlayerData.luckyProfReward -= 5; PlayerData.luckyProfSchedules.remove( -1); // insert in the back of the schedule PlayerData.luckyProfSchedules.push( -1); } // assign den professor if (PlayerData.denMinigame != -1) { if (PlayerData.nextDenProf != -1) { PlayerData.denProf = PlayerData.nextDenProf; PlayerData.nextDenProf = -1; } else { PlayerData.denProf = PlayerData.PROF_PREFIXES.indexOf(PlayerData.prevProfPrefix); } if (PlayerData.prevProfPrefix == "hera") { PlayerData.denCost = Puzzle.getSmallestRewardGreaterThan(FlxG.random.float(1, 20)); // [5-20] } else { PlayerData.denCost = Puzzle.getSmallestRewardGreaterThan(FlxG.random.float(56, 240)); // [60-240] } } } // rotate in new professors var currentProfPermutations:Array<Array<Int>> = professorPermutations; while (PlayerData.luckyProfSchedules[0] == PlayerData.PROF_PREFIXES.indexOf("magn") && !PlayerData.startedMagnezone // Magnezone doesn't show up until we meet him in the shop || PlayerData.luckyProfSchedules[0] == PlayerData.PROF_PREFIXES.indexOf("hera") && (ItemDatabase._playerItemIndexes.length == 0 || !PlayerData.hasMet("kecl")) // Heracross doesn't show up until we purchase an item from the shop, and meet Kecleon (his replacement) || PlayerData.luckyProfSchedules[0] == PlayerData.profIndex // just played with this particular lucky professor ) { var luckyProf = PlayerData.luckyProfSchedules[0]; PlayerData.luckyProfSchedules.remove(luckyProf); // insert somewhere in the back half of the schedule PlayerData.luckyProfSchedules.insert(FlxG.random.int(Math.ceil(PlayerData.luckyProfSchedules.length * 0.5), PlayerData.luckyProfSchedules.length), luckyProf); // also move some of the -1s, as compensation. we don't want to punish the player too hard PlayerData.luckyProfReward += 10; } if (PlayerData.luckyProfSchedules[0] > -1) { // lucky professor if (LucarioDialog.isLucariosFirstTime()) { // lucario's first time; we leave the regular professors in place } else if (!PlayerData.fivePegUnlocked()) { currentProfPermutations = rareProfessorPermutations4; } else { currentProfPermutations = rareProfessorPermutations5; } } FlxG.random.shuffle(currentProfPermutations); { var i:Int = 0; var done:Bool = false; var profIndexesToAvoid:Array<Int> = []; for (profPrefixToAvoid in profPrefixesToAvoid) { profIndexesToAvoid.push(PlayerData.PROF_PREFIXES.indexOf(profPrefixToAvoid)); } do { done = true; if (i >= currentProfPermutations.length - 1) { break; } for (profIndexToAvoid in profIndexesToAvoid) { if (currentProfPermutations[i].indexOf(profIndexToAvoid) != -1) { done = false; } } if (done == false) { i++; } } while (!done); PlayerData.professors = currentProfPermutations[i].copy(); } if (PlayerData.luckyProfSchedules[0] > -1) { // lucky professor for (i in 0...PlayerData.professors.length) { if (PlayerData.professors[i] == 99) { PlayerData.professors[i] = PlayerData.luckyProfSchedules[0]; } } } } public static function rotateSexyChat<T:PokeWindow>(sexyState:SexyState<T>, ?badThings:Array<Int>):Void { var clazz:Dynamic = sexyState._pokeWindow._dialogClass; var prefix:String = sexyState._pokeWindow._prefix; var sexyBeforeBad:Array<Dynamic> = Reflect.field(clazz, "sexyBeforeBad"); if (sexyState.isFinishedSexyStuff()) { var sexyRecords:Array<Float> = Reflect.field(PlayerData, prefix + "SexyRecords"); sexyRecords.splice(0, 1); sexyRecords.push(sexyState.totalHeartsEmitted); } if (PlayerData.difficulty == PlayerData.Difficulty._7Peg) { PlayerData.abra7PegSexyBeforeChat = FlxG.random.int(10, 99); } else { var index:Int = FlxG.random.int(0, Std.int(Math.max(3, badThings == null ? 0 : badThings.length))); var newChat:Int; if (badThings != null && index < badThings.length) { newChat = badThings[index]; } else { newChat = FlxG.random.int(sexyBeforeBad.length, 99); } Reflect.setField(PlayerData, prefix + "SexyBeforeChat", newChat); } PlayerData.storeChatHistory(); } public static function generateBonusCoinDialog(puzzleState:PuzzleState) { var clazz:Dynamic = puzzleState._pokeWindow._dialogClass; var prefix:String = puzzleState._pokeWindow._prefix; var bonusCoin:Dynamic = Reflect.field(clazz, "bonusCoin"); if (bonusCoin == null) { bonusCoin = GrovyleDialog.bonusCoin; } var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (puzzleState._pokeWindow._partAlpha == 0) { // nobody's around; should just yell? tree[0] = ["#self00#(Uhhh...? I found this bonus coin... But nobody's around...)"]; tree[1] = ["#self00#(HEY EVERYONE! HEY I FOUND A BONUS COIN! IS ANYBODY THERE?)"]; tree[2] = ["#self00#(...)"]; tree[3] = ["#self00#(...Right... I can't yell... because I have no mouth...)"]; tree[4] = ["#self00#(Maybe if I pound something really loudly? Where's something that I can pound!)"]; tree[5] = ["#abra12#Ehh? Hey, stop thinking so loud! I was away doing... Abra stuff."]; if (puzzleState._pokeWindow._prefix == "abra") { tree[6] = ["#abra05#Oh! A bonus coin, yes, I understand now. Alright, let's see what kind of bonus game I... hmmm... maybe... "]; tree[7] = ["#abra03#Oooh! How about THIS one?"]; } else { tree[6] = ["#abra05#Oh! A bonus coin, yes, I understand now. Hmm, " + puzzleState._pokeWindow._name + " should really be handling this."]; tree[7] = ["#abra05#...I'll be right back."]; } } else { bonusCoin(tree, puzzleState); } return tree; } /** * @return which minigame will happen next */ public static function peekNextMinigame():MinigameState { var unlockedMinigames:Array<Int> = []; if (PlayerData.hasMet("buiz")) { // buizel tutorials the scale game unlockedMinigames.push(0); } if (PlayerData.hasMet("rhyd")) { // rhydon tutorials the stair game unlockedMinigames.push(1); } if (PlayerData.hasMet("smea")) { // smneargle tutorials the scale game unlockedMinigames.push(2); } if (unlockedMinigames.length == 0) { return null; } for (i in 0...10) { if (PlayerData.minigameQueue.length <= 1) { /* * We rotate through the minigames equally, by drawing from a * stack of three shuffled cards until the stack is empty. */ PlayerData.minigameQueue = PlayerData.minigameQueue.concat(FlxG.random.getObject([ [0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0], ])); if (PlayerData.minigameQueue[0] == PlayerData.minigameQueue[1]) { var possibleAppends = [0, 1, 2]; possibleAppends.remove(PlayerData.minigameQueue[0]); PlayerData.minigameQueue.insert(1, FlxG.random.getObject(possibleAppends)); } } if (unlockedMinigames.indexOf(PlayerData.minigameQueue[0]) != -1) { return MinigameState.fromInt(PlayerData.minigameQueue[0]); } else { PlayerData.minigameQueue.splice(0, 1); } } // ??? shouldn't happen, but maybe if the player's minigameQueue was modified outside the program return null; } /** * Returns the next minigame, cycling to a new minigame aftewards * * @return the minigame which will happen next */ public static function popNextMinigame():MinigameState { var result:MinigameState = peekNextMinigame(); if (result == null) { return null; } PlayerData.minigameQueue.splice(0, 1); return result; } }
argonvile/monster
source/LevelIntroDialog.hx
hx
unknown
35,010
package; import MmStringTools.*; import critter.Critter; import critter.CritterBody; import critter.CritterHolder; import critter.SexyAnims; import critter.SingleCritterHolder; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.group.FlxGroup; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxPoint; import flixel.math.FlxVector; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.ui.FlxButton; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSort; import kludge.BetterFlxRandom; import kludge.AssetKludge; import kludge.FlxFilterFramesKludge; import kludge.FlxSpriteKludge; import openfl.filters.DropShadowFilter; import poke.PokeWindow; /** * LevelState encompasses the logic common to puzzles and minigames -- things * like how the bugs move, picking up and dropping them, drawing shadows, and * pressing "escape" to bring up help. */ class LevelState extends FlxTransitionableState { public static var GLOBAL_IDLE_FREQUENCY:Float = 100; // frequency of global idle events public static var GLOBAL_SEXY_FREQUENCY:Float = 313; // frequency of global sexy events public static var BUTTON_OFF_ALPHA:Float = 0.30; public var _gameState:Int = 80; public var _stateTime:Float = 0; public var _handSprite:FlxSprite; public var _thumbSprite:FlxSprite; public var _clickedMidpoint:FlxPoint; private var _mousePressedPosition:FlxPoint; private var _mousePressedDuration:Float; private var _clickGrabbed:Bool = false; public var _cursorSprites:FlxTypedGroup<FlxSprite>; public var _hud:FlxGroup; public var _midInvisSprites:FlxTypedGroup<FlxSprite>; public var _midSprites:FlxTypedGroup<FlxSprite>; // mid sprites which need to be sorted for the purposes of rendering public var _targetSprites:FlxTypedGroup<FlxSprite>; // critter target sprites, they have their own group for hit detection public var _blockers:FlxGroup; // blockers, they stop critters from stepping on important things public var _backSprites:FlxGroup; public var _shadowGroup:ShadowGroup; public var _backdrop:FlxSprite; public var _critters:Array<Critter>; public var _grabbedCritter:Critter; private var _dialogTree:DialogTree; public var _dialogger:Dialogger; public var _eventStack:EventStack = new EventStack(); public var _pokeWindow:PokeWindow; public var _cashWindow:CashWindow; /* * Over time, the bugs will do idle things like bouncing around, or sexy * things like giving each other blowjobs. These timers count down to * trigger those events. */ public var _globalIdleTimer:Float; public var _globalSexyTimer:Float; public var _chests:Array<Chest>; private var _gemIndex:Int = 0; public var _gems:Array<Gem> = []; private var _helpButton:FlxButton; /* * When a bug is grabbed, their head goes ahead of your glove but their * butt goes behind your glove. Their butt also has some momentum which * needs to be tracked */ private var _grabbedCritterButtSprite:FlxSprite; private var _grabbedCritterButtVector:FlxVector; public function new(?TransIn:TransitionData, ?TransOut:TransitionData) { super(TransIn, TransOut); } override public function create():Void { if (PlayerData.detailLevel == PlayerData.DetailLevel.Low || PlayerData.detailLevel == PlayerData.DetailLevel.VeryLow) { // clear cached bitmap assets to save memory FlxG.bitmap.dumpCache(); } super.create(); Main.overrideFlxGDefaults(); Critter.initialize(); _backSprites = new FlxGroup(); _shadowGroup = new ShadowGroup(); _targetSprites = new FlxTypedGroup<FlxSprite>(); _blockers = new FlxGroup(); _midInvisSprites = new FlxTypedGroup<FlxSprite>(); _midSprites = new FlxTypedGroup<FlxSprite>(); _hud = new FlxGroup(); _cursorSprites = new FlxTypedGroup<FlxSprite>(); _critters = []; _chests = []; add(_backSprites); /* * shadowGroup.active is false so that it can be updated explicitly. * That way we can ensure the shadows are moved after the sprites move. */ _shadowGroup.active = false; add(_shadowGroup); add(_targetSprites); add(_blockers); add(_midInvisSprites); add(_midSprites); add(_hud); add(_cursorSprites); _backdrop = newBackdrop(); _backSprites.add(_backdrop); _pokeWindow = PokeWindow.fromInt(PlayerData.profIndex); _handSprite = new FlxSprite(100, 100); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(12, 11); _handSprite.offset.set(65, 83); _cursorSprites.add(_handSprite); for (i in 0...50) { _gems.push(new Gem()); } _thumbSprite = new FlxSprite(100, 110); CursorUtils.initializeHandSprite(_thumbSprite, AssetPaths.thumbs__png); _thumbSprite.setSize(12, 1); _thumbSprite.offset.set(65, 93); _cursorSprites.add(_thumbSprite); _grabbedCritterButtSprite = new FlxSprite(); _grabbedCritterButtVector = FlxVector.get(); _dialogger = new Dialogger(); _cashWindow = new CashWindow(); _globalIdleTimer = FlxG.random.float(0, GLOBAL_IDLE_FREQUENCY); _globalSexyTimer = FlxG.random.float(0, GLOBAL_SEXY_FREQUENCY); if (PlayerData.profIndex == -1) { // should actually be initialized by MainMenuState PlayerData.profIndex = PlayerData.professors[PlayerData.difficulty.getIndex()]; } _helpButton = newButton(AssetPaths.help_button__png, FlxG.width - 33, 3, 28, 28, clickHelp); } override public function destroy():Void { super.destroy(); _handSprite = FlxDestroyUtil.destroy(_handSprite); _thumbSprite = FlxDestroyUtil.destroy(_thumbSprite); _clickedMidpoint = FlxDestroyUtil.put(_clickedMidpoint); _cursorSprites = FlxDestroyUtil.destroy(_cursorSprites); _hud = FlxDestroyUtil.destroy(_hud); _midInvisSprites = FlxDestroyUtil.destroy(_midInvisSprites); _midSprites = FlxDestroyUtil.destroy(_midSprites); _targetSprites = FlxDestroyUtil.destroy(_targetSprites); _blockers = FlxDestroyUtil.destroy(_blockers); _backSprites = FlxDestroyUtil.destroy(_backSprites); _shadowGroup = FlxDestroyUtil.destroy(_shadowGroup); _backdrop = FlxDestroyUtil.destroy(_backdrop); _critters = FlxDestroyUtil.destroyArray(_critters); _grabbedCritter = FlxDestroyUtil.destroy(_grabbedCritter); _dialogTree = FlxDestroyUtil.destroy(_dialogTree); _dialogger = FlxDestroyUtil.destroy(_dialogger); _eventStack = null; _pokeWindow = FlxDestroyUtil.destroy(_pokeWindow); _cashWindow = FlxDestroyUtil.destroy(_cashWindow); _chests = FlxDestroyUtil.destroyArray(_chests); _gems = null; _helpButton = FlxDestroyUtil.destroy(_helpButton); _grabbedCritterButtSprite = FlxDestroyUtil.destroy(_grabbedCritterButtSprite); _grabbedCritterButtVector = FlxDestroyUtil.put(_grabbedCritterButtVector); } public static function newBackdrop():FlxSprite { var bgSprite:FlxSprite = new FlxSprite(0, 0); bgSprite.makeGraphic(768, 432, 0x00000000, true); var bgAsset:FlxGraphicAsset = AssetPaths.bg0_tile__png; if (PlayerData.profIndex == 0) { bgAsset = AssetPaths.bg0_tile__png; } else if (PlayerData.profIndex == 1) { bgAsset = AssetPaths.bg1_tile__png; } else if (PlayerData.profIndex == 2) { bgAsset = AssetPaths.bg3_tile__png; // heracross } else if (PlayerData.profIndex == 3) { bgAsset = AssetPaths.bg3_tile__png; } else if (PlayerData.profIndex == 4) { bgAsset = AssetPaths.bg4_tile__png; } else if (PlayerData.profIndex == 5) { bgAsset = AssetPaths.bg5_tile__png; } else if (PlayerData.profIndex == 6) { bgAsset = AssetPaths.bg6_tile__png; } else if (PlayerData.profIndex == 8) { bgAsset = AssetPaths.bg4_tile__png; // magnezone } else if (PlayerData.profIndex == 9) { bgAsset = AssetPaths.bg0_tile__png; // grimer } else if (PlayerData.profIndex == 10) { bgAsset = AssetPaths.bg5_tile__png; // lucario } var bgStamp:FlxSprite = new FlxSprite(0, 0, bgAsset); var x:Int = 0; var y:Int = 0; do { x = 0; do { bgSprite.stamp(bgStamp, x, y); x += Std.int(bgStamp.width); } while (x < 768); y += Std.int(bgStamp.height); } while (y < 432); return bgSprite; } public function moveGrabbedCritter(elapsed:Float):Void { _grabbedCritter.setPosition(_handSprite.x - 18, _handSprite.y + 5); _thumbSprite.setPosition(_handSprite.x, _handSprite.y + 6); moveGrabbedCritterButt(elapsed); } public function moveGrabbedCritterButt(elapsed:Float):Void { _grabbedCritterButtVector.set(_grabbedCritter._soulSprite.x - _grabbedCritterButtSprite.x, _grabbedCritter._soulSprite.y - _grabbedCritterButtSprite.y); if (_grabbedCritterButtVector.length != 0) { if (_grabbedCritterButtVector.length < 90) { if (_grabbedCritterButtVector.length > 150 * elapsed) { _grabbedCritterButtVector.length = 150 * elapsed; } } else { if (_grabbedCritterButtVector.length > 900 * elapsed) { _grabbedCritterButtVector.length = 900 * elapsed; } } _grabbedCritterButtSprite.x += _grabbedCritterButtVector.x; _grabbedCritterButtSprite.y += _grabbedCritterButtVector.y; if (_grabbedCritterButtSprite.x > _grabbedCritter._soulSprite.x + 60) { _grabbedCritter._bodySprite.animation.play("grab-w2"); } else if (_grabbedCritterButtSprite.x > _grabbedCritter._soulSprite.x + 15) { if (_grabbedCritter._bodySprite.animation.name == "grab-w2") { } else { _grabbedCritter._bodySprite.animation.play("grab-w1"); } } else if (_grabbedCritterButtSprite.x < _grabbedCritter._soulSprite.x - 60) { _grabbedCritter._bodySprite.animation.play("grab-e2"); } else if (_grabbedCritterButtSprite.x < _grabbedCritter._soulSprite.x - 15) { if (_grabbedCritter._bodySprite.animation.name == "grab-e2") { } else { _grabbedCritter._bodySprite.animation.play("grab-e1"); } } } if (_grabbedCritter._bodySprite.animation.name.substring(0, 5) == "grab-" && _grabbedCritter._bodySprite.animation.curAnim.curFrame == _grabbedCritter._bodySprite.animation.curAnim.numFrames - 1) { // rest _grabbedCritterButtSprite.setPosition(_grabbedCritter._soulSprite.x, _grabbedCritter._soulSprite.y); } } override public function update(elapsed:Float):Void { PlayerData.updateTimePlayed(); if (FlxG.mouse.justPressed) { PlayerData.updateCursorVisible(); } _stateTime += elapsed; _handSprite.setPosition(FlxG.mouse.x - _handSprite.width / 2, FlxG.mouse.y - _handSprite.height / 2); _eventStack.update(elapsed); if (_grabbedCritter != null) { // currently dragging a critter around moveGrabbedCritter(elapsed); } else { _thumbSprite.setPosition(_handSprite.x, _handSprite.y + 10); } if (FlxG.mouse.justPressed) { _clickedMidpoint = _handSprite.getMidpoint(); } handleClick(elapsed); super.update(elapsed); handleCritterOverlap(elapsed); var shouldFade:Bool = false; if (FlxSpriteKludge.overlap(_handSprite, _pokeWindow._canvas)) { var minDist:Float = FlxG.width; for (_cameraButton in _pokeWindow._cameraButtons) { var dist:Float = FlxPoint.get(_pokeWindow.x + _cameraButton.x + 14, _pokeWindow.y + _cameraButton.y + 14).distanceTo(FlxG.mouse.getPosition()); minDist = Math.min(dist, minDist); } if (minDist <= 30) { // too close to a camera button; don't fade out shouldFade = false; } else { shouldFade = true; } } if (shouldFade) { _pokeWindow._canvas.alpha = Math.max(0.3, _pokeWindow._canvas.alpha - 3.0 * elapsed); } else { _pokeWindow._canvas.alpha = Math.min(1.0, _pokeWindow._canvas.alpha + 3.0 * elapsed); } for (sprite in _midInvisSprites) { if (sprite == null || !sprite.exists || !sprite.alive) { continue; } if (sprite.visible && sprite.isOnScreen()) { _midInvisSprites.remove(sprite); _midSprites.add(sprite); } } for (sprite in _midSprites) { if (sprite == null || !sprite.exists || !sprite.alive) { continue; } if (!sprite.visible || !sprite.isOnScreen()) { _midSprites.remove(sprite); _midInvisSprites.add(sprite); } } for (chest in _chests) { chest.update(elapsed); } _midSprites.sort(byYNulls); _cursorSprites.sort(byYNulls); if (DialogTree.isDialogging(_dialogTree)) { _cashWindow.setShopText(true); } else { _cashWindow.setShopText(false); } _shadowGroup.update(elapsed); if (_helpButton.alpha >= 1.0 && FlxG.keys.justPressed.ESCAPE) { clickHelp(); } } /** * A sorting function which sorts FlxObjects by their y values. * * FlxSort.byY does the same thing, but throws if given null objects */ public static inline function byYNulls(Order:Int, Obj1:FlxObject, Obj2:FlxObject):Int { return FlxSort.byValues(Order, Obj1 == null ? -10000 : Obj1.y, Obj2 == null ? -10000 : Obj2.y); } function handleCritterOverlap(elapsed:Float) { FlxG.overlap(_targetSprites, _targetSprites, critterCollide); FlxG.overlap(_targetSprites, _blockers, critterCollide); } /** * Subclasses can override this to define what happens when the user clicks * the "help" button. */ public function clickHelp():Void { } public function addCritter(critter:Critter, pushToCritterList:Bool = true) { _targetSprites.add(critter._targetSprite); _midInvisSprites.add(critter._soulSprite); _midInvisSprites.add(critter._bodySprite); _midInvisSprites.add(critter._headSprite); _midInvisSprites.add(critter._frontBodySprite); var shadow:Shadow = _shadowGroup.makeShadow(critter._bodySprite); critter.shadow = shadow; if (pushToCritterList) { _critters.push(critter); } } function removeCritter(critter:Critter):Void { _targetSprites.remove(critter._targetSprite, true); _midInvisSprites.remove(critter._soulSprite, true); _midInvisSprites.remove(critter._bodySprite, true); _midInvisSprites.remove(critter._headSprite, true); _midInvisSprites.remove(critter._frontBodySprite, true); _midSprites.remove(critter._bodySprite, true); _midSprites.remove(critter._headSprite, true); _midSprites.remove(critter._frontBodySprite, true); _critters.remove(critter); } function findClosestCritter(point:FlxPoint, distanceThreshold:Float=25):Critter { var minDistance:Float = distanceThreshold + 1; var closestCritter:Critter = null; for (critter in _critters) { var distance:Float = critter._bodySprite.getMidpoint().distanceTo(point); if (distance < minDistance) { minDistance = distance; closestCritter = critter; } } return minDistance < distanceThreshold ? closestCritter : null; } public function findGrabbedCritter():Critter { var offsetPoint:FlxPoint = FlxPoint.get(_clickedMidpoint.x, _clickedMidpoint.y); offsetPoint.y += 10; var critter:Critter = findClosestCritter(offsetPoint); if (critter == null || critter.isCubed()) { return null; } return critter; } /** * Checks whether a recent mouse click should cause a bug-grabbing event, * and grabs the appropriate bug. * * @return true if a bug was grabbed */ public function maybeGrabCritter():Bool { if (_grabbedCritter != null) { return true; } _grabbedCritter = findGrabbedCritter(); if (_grabbedCritter != null) { var success:Bool = removeCritterFromHolder(_grabbedCritter); if (!success) { _grabbedCritter = null; return true; } _targetSprites.remove(_grabbedCritter._targetSprite, true); _midInvisSprites.remove(_grabbedCritter._soulSprite, true); _midSprites.remove(_grabbedCritter._bodySprite, true); _midSprites.remove(_grabbedCritter._headSprite, true); _midSprites.remove(_grabbedCritter._frontBodySprite, true); _cursorSprites.add(_grabbedCritter._targetSprite); _cursorSprites.add(_grabbedCritter._soulSprite); _cursorSprites.add(_grabbedCritter._bodySprite); _cursorSprites.add(_grabbedCritter._headSprite); _cursorSprites.add(_grabbedCritter._frontBodySprite); _handSprite.animation.frameIndex = 1; _thumbSprite.animation.frameIndex = 1; _grabbedCritter.grab(); _thumbSprite.offset.y = _handSprite.offset.y + 6; _grabbedCritterButtSprite.setPosition(_grabbedCritter._soulSprite.x, _grabbedCritter._soulSprite.y); return true; } return false; } /** * Checks whether a recent mouse release should cause a bug-releasing * event, and releases the appropriate bug. * * @return true if a bug was released */ public function maybeReleaseCritter():Bool { if (_grabbedCritter == null) { return false; } // user dropped a critter if (_mousePressedPosition.distanceTo(FlxG.mouse.getWorldPosition()) >= 8 || _mousePressedDuration > 0.50 || _clickGrabbed) { SoundStackingFix.play(AssetPaths.drop__mp3); _grabbedCritter._targetSprite.y += 10; _grabbedCritter._soulSprite.y += 10; _grabbedCritter._bodySprite.y += 10; var targetCritterHolder:CritterHolder = findTargetCritterHolder(); if (targetCritterHolder != null) { placeCritterInHolder(targetCritterHolder, _grabbedCritter); } handleUngrab(); _clickGrabbed = false; } else { _clickGrabbed = true; } return true; } public function handleUngrab():Void { _cursorSprites.remove(_grabbedCritter._targetSprite, true); _cursorSprites.remove(_grabbedCritter._soulSprite, true); _cursorSprites.remove(_grabbedCritter._bodySprite, true); _cursorSprites.remove(_grabbedCritter._headSprite, true); _cursorSprites.remove(_grabbedCritter._frontBodySprite, true); _targetSprites.add(_grabbedCritter._targetSprite); _midInvisSprites.add(_grabbedCritter._soulSprite); _midSprites.add(_grabbedCritter._bodySprite); _midSprites.add(_grabbedCritter._headSprite); _midSprites.add(_grabbedCritter._frontBodySprite); _grabbedCritter.ungrab(); if (!_grabbedCritter._targetSprite.immovable) { // maybe critter should tumble a little? _grabbedCritterButtVector.set(_grabbedCritter._bodySprite.x - _grabbedCritterButtSprite.x, _grabbedCritter._bodySprite.y - _grabbedCritterButtSprite.y); if (_grabbedCritterButtVector.length >= 180) { // reign it in a little _grabbedCritterButtVector.length = 180 + (_grabbedCritterButtVector.length - 180) * 0.5; // tumble _grabbedCritter.z = 20; _grabbedCritter._bodySprite._jumpSpeed = 2 * (_grabbedCritterButtVector.length - (_grabbedCritterButtVector.length - 180) * 0.5); _grabbedCritter.jumpTo(_grabbedCritter._soulSprite.x + _grabbedCritterButtVector.x, _grabbedCritter._soulSprite.y + _grabbedCritterButtVector.y, 0); _grabbedCritter.updateMovingPrefix("tumble"); } else if (_grabbedCritterButtVector.length >= 90) { // jump _grabbedCritter.z = 20; _grabbedCritter._bodySprite._jumpSpeed = Math.max(CritterBody.DEFAULT_JUMP_SPEED, _grabbedCritterButtVector.length); _grabbedCritter.jumpTo(_grabbedCritter._soulSprite.x + _grabbedCritterButtVector.x * 0.5, _grabbedCritter._soulSprite.y + _grabbedCritterButtVector.y * 0.5, 0); } else if (_grabbedCritterButtVector.length >= 30) { // walk _grabbedCritter.runTo(_grabbedCritter._soulSprite.x + _grabbedCritterButtVector.x * 0.3, _grabbedCritter._soulSprite.y + _grabbedCritterButtVector.y * 0.3); } } _grabbedCritter = null; _handSprite.animation.frameIndex = 0; _thumbSprite.animation.frameIndex = 0; _thumbSprite.offset.y = _handSprite.offset.y + 10; _thumbSprite.y = _handSprite.y + 10; } function removeCritterFromHolder(critter:Critter):Bool { return true; } function handleClick(elapsed:Float):Void { if (_dialogTree == null || !DialogTree.isDialogging(_dialogTree)) { if (FlxG.mouse.justReleased) { handleMouseRelease(); } else if (FlxG.mouse.justPressed && !_dialogger._handledClick) { handleMousePress(); } if (FlxG.mouse.justPressed) { _mousePressedPosition = FlxG.mouse.getWorldPosition(); } if (FlxG.mouse.pressed) { _mousePressedDuration += elapsed; } else { _mousePressedDuration = 0; } } } /** * Overridden by subclasses to define mouse press behavior */ function handleMousePress():Void { } /** * Overridden by subclasses to define mouse release behavior */ function handleMouseRelease():Void { } function placeCritterInHolder(holder:CritterHolder, critter:Critter) { holder.holdCritter(critter); if (critter.outCold && Std.isOfType(holder, SingleCritterHolder)) { critter.playAnim("idle-outcold0"); } } /** * Overridden by subclasses to define logic for finding a "critter holder" * -- something which a critter can be dropped onto. This could be a small * or large box for the puzzles, or a platform for the minigames */ function findTargetCritterHolder():CritterHolder { return null; } public function critterCollide(Sprite0:FlxSprite, Sprite1:FlxSprite):Void { if (Sprite0.immovable && Sprite1.immovable) { // two immobile sprites touching... maybe two critters having sex return; } var dx:Float = Sprite1.x + Sprite1.width / 2 - (Sprite0.x + Sprite0.width / 2); var dy:Float = Sprite1.y + Sprite1.height / 2 - (Sprite0.y + Sprite0.height / 2); if (dy == 0 && dx == 0) { dx = 1; } var separateX:Float = dx > 0 ? (Sprite0.x + Sprite0.width + 0.5 - Sprite1.x) : -(Sprite1.x + Sprite1.width + 0.5 - Sprite0.x); var separateY:Float = dy > 0 ? (Sprite0.y + Sprite0.height + 0.5 - Sprite1.y) : -(Sprite1.y + Sprite1.height + 0.5 - Sprite0.y); if (dx == 0 || Math.abs(dy / dx) > Sprite0.height / Sprite0.width) { // move vertically separateX *= 0.33; } else { separateY *= 0.33; } if (Sprite0.immovable && !Sprite1.immovable) { Sprite1.x += separateX; Sprite1.y += separateY; } else if (Sprite1.immovable && !Sprite0.immovable) { Sprite0.x -= separateX; Sprite0.y -= separateY; } else if (!Sprite0.immovable && !Sprite1.immovable) { Sprite1.x += separateX / 2; Sprite1.y += separateY / 2; Sprite0.x -= separateX / 2; Sprite0.y -= separateY / 2; } } function setState(state:Int) { _gameState = state; _stateTime = 0; } public function eventSetState(params:Array<Dynamic>):Void { setState(params[0]); } public function quit() { PlayerData.discardChatHistory(); if (PlayerData.playerIsInDen) { FlxG.switchState(new ShopState()); } else { FlxG.switchState(new MainMenuState()); } } public function dialogTreeCallback(Msg:String):String { if (Msg == "%quit%") { quit(); } if (StringTools.startsWith(Msg, "%setprofindex-")) { var index:Int = Std.parseInt(substringBetween(Msg, "%setprofindex-", "%")); PlayerData.profIndex = index; } return null; } function newButton(Graphic:Dynamic, X:Float, Y:Float, Width:Int, Height:Int, Callback:Void->Void):FlxButton { AssetKludge.buttonifyAsset(Graphic); var button:FlxButton = new FlxButton(X, Y); button.loadGraphic(Graphic, true, Width, Height); button.animation.frameIndex = 1; button.allowSwiping = false; var filter:DropShadowFilter = new DropShadowFilter(3, 90, 0, ShadowGroup.SHADOW_ALPHA, 0, 0); filter.distance = 3; var spriteFilter:FlxFilterFramesKludge = FlxFilterFramesKludge.fromFrames(button.frames, 0, 5, [filter]); spriteFilter.applyToSprite(button, false, true); button.onDown.callback = function() { if (_grabbedCritter == null) { filter.distance = 0; spriteFilter.secretOffset.y = -3; spriteFilter.applyToSprite(button, false, true); } } button.onUp.callback = function() { if (_grabbedCritter == null) { button.onOut.fire(); if (button.alpha == 1.0) { Callback(); } } } button.onOut.callback = function() { if (_grabbedCritter == null) { filter.distance = 3; spriteFilter.secretOffset.y = 0; spriteFilter.applyToSprite(button, false, true); } } return button; } /** * Finds a group of idle bugs. * * @param count the number of critters to return */ public function findIdleCritters(count:Int):Array<Critter> { var start:Int = FlxG.random.int(0, _critters.length - 1); var result:Array<Critter> = []; for (i in 0..._critters.length) { var j = (i + start) % _critters.length; var critter:Critter = _critters[j]; if (!critter._targetSprite.isOnScreen()) { continue; } if (critter._targetSprite.immovable || !critter.idleMove) { // don't return critters which are contained somewhere continue; } if (critter.isIdle()) { result.push(critter); } } FlxG.random.shuffle(result); result.splice(count, result.length - count); return result; } public function getIdleCritterCount():Int { var count:Int = 0; for (critter in _critters) { if (critter._targetSprite.isOnScreen() && critter._bodySprite.animation.name == "idle") { if (critter._targetSprite.immovable || !critter.idleMove) { continue; } count++; } } return count; } public function findIdleCritter(?colorIndex:Int):Critter { var start:Int = FlxG.random.int(0, _critters.length - 1); for (i in 0..._critters.length) { var j = (i + start) % _critters.length; var critter:Critter = _critters[j]; if (colorIndex != null && critter.getColorIndex() != colorIndex) { continue; } if (!critter._targetSprite.isOnScreen()) { continue; } if (critter._targetSprite.immovable || !critter.idleMove) { continue; } if (critter.isIdle()) { return critter; } } return null; } public function updateSexyTimer(elapsed:Float):Void { if (PlayerData.sfw) { // sfw mode; no sexy animations } else if (PlayerData.pokemonLibido == 1) { // disabling pokemon libido also disables sexy animations } else { _globalSexyTimer -= elapsed; } if (_globalSexyTimer <= 0) { var annoyingAnimationConstant:Float = [0, 0, 0.25, 0.5, 1.0, 1.95, 3.10, 4.5][PlayerData.pegActivity]; var map:Map<String,Float> = new Map<String,Float>(); map["global-sexy-rimming-into-doggy"] = 1 * annoyingAnimationConstant; map["global-sexy-rimming-take-turns-and-doggy"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy-then-rim"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy-blitz"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy-spank"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy-gangbang"] = 1 * annoyingAnimationConstant; map["global-sexy-rimming"] = 1 * annoyingAnimationConstant; map["global-sexy-rimming-take-turns"] = 1 * annoyingAnimationConstant; map["global-sexy-rimming-waggle"] = 1 * annoyingAnimationConstant; map["global-sexy-rimming-race"] = 1 * annoyingAnimationConstant; map["global-sexy-mutual-masturbate"] = 1 * annoyingAnimationConstant; map["global-sexy-mutual-masturbate-then-blowjob"] = 1 * annoyingAnimationConstant; map["global-sexy-blowjob"] = 2 * annoyingAnimationConstant; map["global-sexy-blowjob-and-jerk"] = 0.5 * annoyingAnimationConstant; map["global-sexy-blowjob-and-watersports"] = 1 * annoyingAnimationConstant; map["global-sexy-trade-blowjobs"] = 1 * annoyingAnimationConstant; map["global-sexy-multi-blowjob"] = 1 * annoyingAnimationConstant; map["global-sexy-blowjob-then-doggy"] = 1 * annoyingAnimationConstant; map["global-sexy-doggy-then-blowjob"] = 1 * annoyingAnimationConstant; // by default, the "sexy noop" will happen 30% of the time... map["global-sexy-noop"] = [5.8, 5.8, 3.2, 1.8, 1.0, 0.6, 0.3, 0.2][PlayerData.pokemonLibido] * (11 * 0.429); var sexyAnimName:String = BetterFlxRandom.getObjectWithMap(map); SexyAnims.playGlobalAnim(this, sexyAnimName); } } public function addChest():Chest { var chest:Chest = null; for (i in 0..._chests.length) { if (_chests[i] == null || _chests[i]._chestSprite == null) { // chest has been recycled chest = new Chest(); _chests[i] = chest; break; } } if (chest == null) { chest = new Chest(); _chests.push(chest); } _midSprites.add(chest._chestSprite); return chest; } public function emitGems(chest:Chest) { var gemCount:Int = 0; if (PlayerData.detailLevel == PlayerData.DetailLevel.VeryLow) { // up to 15 gems from a chest gemCount += Std.int(Math.min(5, Math.ceil(chest._reward / 30))); gemCount += Std.int(Math.min(5, Math.ceil(chest._reward / 75))); gemCount += Std.int(Math.min(5, Math.floor(chest._reward / 180))); } else if (PlayerData.detailLevel == PlayerData.DetailLevel.Low) { // up to 25 gems from a chest gemCount += Std.int(Math.min(8, Math.ceil(chest._reward / 25))); gemCount += Std.int(Math.min(6, Math.ceil(chest._reward / 100))); gemCount += Std.int(Math.min(6, Math.floor(chest._reward / 200))); gemCount += Std.int(Math.min(5, Math.floor(chest._reward / 400))); } else { // up to 35 gems from a chest gemCount += Std.int(Math.min(12, Math.ceil(chest._reward / 20))); gemCount += Std.int(Math.min(8, Math.ceil(chest._reward / 80))); gemCount += Std.int(Math.min(8, Math.floor(chest._reward / 160))); gemCount += Std.int(Math.min(7, Math.floor(chest._reward / 320))); } if (chest._chestSprite == null) { /* * Chest has already been destroyed? I've never seen this * behavior, but it could account for crashes people are seeing */ } else { for (i in 0...gemCount) { emitGem(chest._chestSprite.x + chest._chestSprite.width / 2 + FlxG.random.float( -10, 10), chest._chestSprite.y + chest._chestSprite.height / 2 + FlxG.random.float( -3, 3), chest.z); } } } public function emitGem(x:Float, y:Float, z:Float):Gem { var gem:Gem = _gems[_gemIndex++% _gems.length]; gem.reset(x, y); gem.velocity.x = FlxG.random.float( -100, 100); gem.velocity.y = FlxG.random.float( -36, 36); gem.z = z + 20; gem.groundZ = 0; gem.zVelocity = FlxG.random.float(80, 120); gem.lifespan = FlxG.random.float(2, 3); gem.onEmit(); _midSprites.remove(gem); _midSprites.add(gem); return gem; } public function eventShowCashWindow(args:Dynamic):Void { _cashWindow.show(); } }
argonvile/monster
source/LevelState.hx
hx
unknown
31,293
package; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; /** * Provides methods for lighting and unlighting different parts of the screen */ class LightsManager implements IFlxDestroyable { public var _spotlights:SpotlightGroup; private var _spotlightAlphaTween:FlxTween; private var _predimmedLightsLevel:Float = 1.0; public function new() { _spotlights = new SpotlightGroup(); _spotlights.dimLights(0); } public function setLightsOff() { setLightsDim(0.7); } public function setLightsUndim() { setLightsOn(_predimmedLightsLevel); } public function setLightsDim(?alpha:Float = 0.35) { _predimmedLightsLevel = _spotlights.alpha; _spotlights.dimLights(alpha); if (_spotlightAlphaTween != null) { _spotlightAlphaTween.cancel(); } _spotlights.refreshSpotlights(); } public function setLightsOn(?alpha:Float = 0) { if (_spotlightAlphaTween != null) { _spotlightAlphaTween.cancel(); } _spotlightAlphaTween = FlxTweenUtil.retween(_spotlightAlphaTween, _spotlights, {alpha:alpha}, 0.6, {ease:FlxEase.circOut}); } public function setSpotlightOn(which:String) { _spotlights.turnOn(which); } public function setSpotlightOff(which:String) { _spotlights.turnOff(which); } public function setSpotlightsOn(which:String) { _spotlights.turnOnMany(which); } public function setSpotlightsOff(which:String) { _spotlights.turnOffMany(which); } public function eventLightsOff(params:Array<Dynamic>):Void { setLightsOff(); } public function eventLightsOn(params:Array<Dynamic>):Void { setLightsOn(); } public function eventLightsDim(params:Array<Dynamic>):Void { if (params == null) { setLightsDim(); } else { setLightsDim(params[0]); } } public function eventSpotlightOn(params:Array<Dynamic>):Void { setSpotlightOn(params[0]); } public function eventSpotlightOff(params:Array<Dynamic>):Void { setSpotlightOff(params[0]); } public function destroy():Void { _spotlights = FlxDestroyUtil.destroy(_spotlights); _spotlightAlphaTween = FlxTweenUtil.destroy(_spotlightAlphaTween); } }
argonvile/monster
source/LightsManager.hx
hx
unknown
2,299
package; import flash.errors.SecurityError; import flash.geom.Point; import flixel.FlxG; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxColor; import flixel.util.typeLimit.OneOfThree; import haxe.Constraints.IMap; import openfl.display.BitmapData; import openfl.geom.Rectangle; typedef LightsOutTarget = OneOfThree<FlxSprite, FlxGraphicAsset, String>; /** * A class for blackening certain pixels in an image, for a silhouette effect */ class LightsOut { private static var UNMAPPED_COLOR:FlxColor = 0xA55FEC35; public static var SHADOW_COLOR:FlxColor = 0xFF181823; // Issue 1791 - enum types cannot be used as Map keys - haxe #1791 private var originalDataMap0:Map<FlxSprite,BitmapData> = new Map<FlxSprite,BitmapData>(); private var originalDataMap1:Map<FlxGraphic,BitmapData> = new Map<FlxGraphic,BitmapData>(); private var originalDataMap2:Map<BitmapData,BitmapData> = new Map<BitmapData,BitmapData>(); private var originalDataMap3:Map<String,BitmapData> = new Map<String,BitmapData>(); public function new() { } private function put(Key:LightsOutTarget, Value:BitmapData) { if (Std.isOfType(Key, FlxSprite)) { originalDataMap0[cast Key] = Value; } else if (Std.isOfType(Key, FlxGraphic)) { originalDataMap1[cast Key] = Value; } else if (Std.isOfType(Key, BitmapData)) { originalDataMap2[cast Key] = Value; } else if (Std.isOfType(Key, String)) { originalDataMap3[cast Key] = Value; } } private function get(Key:LightsOutTarget):BitmapData { if (Std.isOfType(Key, FlxSprite)) { return originalDataMap0[cast Key]; } else if (Std.isOfType(Key, FlxGraphic)) { return originalDataMap1[cast Key]; } else if (Std.isOfType(Key, BitmapData)) { return originalDataMap2[cast Key]; } else if (Std.isOfType(Key, String)) { return originalDataMap3[cast Key]; } return null; } public function lightsOutBody(Item:LightsOutTarget):Void { if (Std.isOfType(Item, FlxGraphic) || Std.isOfType(Item, BitmapData) || Std.isOfType(Item, String)) { var graphic:FlxGraphic = FlxG.bitmap.add(cast Item, false, null); var originalPixels:BitmapData = new BitmapData(graphic.bitmap.width, graphic.bitmap.height, true, 0x00); originalPixels.copyPixels(graphic.bitmap, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0)); put(Item, originalPixels); graphic.bitmap.threshold(originalPixels, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0), '>', 0x00000000, SHADOW_COLOR, 0xFF000000); } } public function lightsOut(Item:LightsOutTarget, colorMapping:Map<FlxColor, FlxColor>):Void { if (Std.isOfType(Item, FlxGraphic) || Std.isOfType(Item, BitmapData) || Std.isOfType(Item, String)) { var graphic:FlxGraphic = FlxG.bitmap.add(cast Item, false, null); var extraMapping:Map<FlxColor, FlxColor> = new Map<FlxColor, FlxColor>(); var pixelMap:Map<Int, String> = new Map<Int, String>(); for (x in 0...graphic.bitmap.width) { for (y in 0...graphic.bitmap.height) { var pixelColor:FlxColor = graphic.bitmap.getPixel32(x, y); if (!colorMapping.exists(pixelColor) && !extraMapping.exists(pixelColor)) { extraMapping[pixelColor] = UNMAPPED_COLOR; for (color in colorMapping.keys()) { if (getDistance(color, pixelColor) < 3) { extraMapping[pixelColor] = colorMapping[color]; break; } } } } } var originalPixels:BitmapData = new BitmapData(graphic.bitmap.width, graphic.bitmap.height, true, 0x00); originalPixels.copyPixels(graphic.bitmap, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0)); put(Item, originalPixels); for (sourceColor in colorMapping.keys()) { graphic.bitmap.threshold(originalPixels, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0), '==', sourceColor, colorMapping[sourceColor]); } for (sourceColor in extraMapping.keys()) { if (extraMapping[sourceColor] != UNMAPPED_COLOR) { graphic.bitmap.threshold(originalPixels, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0), '==', sourceColor, extraMapping[sourceColor]); } } } } private static function getDistance(color0:FlxColor, color1:FlxColor) { var dist:Int = 0; dist += Std.int(Math.abs(color0.red - color1.red)); dist += Std.int(Math.abs(color0.green - color1.green)); dist += Std.int(Math.abs(color0.blue - color1.blue)); dist += Std.int(Math.abs(color0.alpha - color1.alpha)); return dist; } public function lightsOn(Item:LightsOutTarget):Void { if (Std.isOfType(Item, FlxGraphic) || Std.isOfType(Item, BitmapData) || Std.isOfType(Item, String)) { var originalPixels:BitmapData = get(Item); if (originalPixels != null) { var graphic:FlxGraphic = FlxG.bitmap.add(cast Item, false, null); graphic.bitmap.copyPixels(originalPixels, new Rectangle(0, 0, originalPixels.width, originalPixels.height), new Point(0, 0)); } } } }
argonvile/monster
source/LightsOut.hx
hx
unknown
5,297
package; import lime.tools.SplashScreen; import credits.CreditsState; import demo.SexyDebugState; import demo.TeaserTextState; import demo.TextEntryDemo; import flash.Lib; import flash.display.Sprite; import flash.events.Event; import flixel.FlxG; import flixel.FlxGame; import flixel.FlxState; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import openfl.display.StageQuality; import poke.abra.AbraResource; import poke.buiz.BuizelResource; import poke.buiz.BuizelSexyState; import poke.grim.GrimerResource; import poke.grov.GrovyleResource; import poke.grov.GrovyleSexyState; import poke.hera.HeraResource; import poke.hera.HeraSexyState; import poke.kecl.KecleonResource; import poke.luca.LucarioResource; import poke.luca.LucarioSexyState; import poke.magn.MagnResource; import poke.rhyd.RhydonResource; import poke.sand.SandslashResource; import poke.sand.SandslashSexyState; import poke.smea.SmeargleResource; import poke.smea.SmeargleSexyState; import puzzle.PuzzleState; /** * The main class which is invoked to start the rest of the game. Includes * logic for one-time setup such as initializing sprites and configuring * the HaxeFlixel framework. */ class Main extends Sprite { public static var VERSION_STRING:String = "1.07.3-UNSTABLE"; var gameWidth:Int = 768; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom). var gameHeight:Int = 432; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). var initialState:Class<FlxState> = SplashScreenState; // The FlxState the game starts with. var zoom:Float = 1; // If -1, zoom is automatically calculated to fit the window dimensions. var framerate:Int = 60; // How many frames per second the game should run at. var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode. var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets public static function main():Void { #if redirectTraces FlxG.log.redirectTraces = true; #end Lib.current.addChild(new Main()); } public function new() { super(); if (stage != null) { init(); } else { addEventListener(Event.ADDED_TO_STAGE, init); } } private function init(?E:Event):Void { if (hasEventListener(Event.ADDED_TO_STAGE)) { removeEventListener(Event.ADDED_TO_STAGE, init); } setupGame(); } private function setupGame():Void { // Pixelly look is good for the game, but makes the debugger look bad #if !FLX_DEBUG FlxG.stage.quality = StageQuality.LOW; #end var stageWidth:Int = Lib.current.stage.stageWidth; var stageHeight:Int = Lib.current.stage.stageHeight; if (zoom == -1) { var ratioX:Float = stageWidth / gameWidth; var ratioY:Float = stageHeight / gameHeight; zoom = Math.min(ratioX, ratioY); gameWidth = Math.ceil(stageWidth / zoom); gameHeight = Math.ceil(stageHeight / zoom); } addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); } /** * These need to be called after FlxG.reset(), or they get overwritten */ public static function overrideFlxGDefaults():Void { FlxG.fixedTimestep = false; FlxG.autoPause = false; FlxG.sound.muteKeys = null; PlayerSave.flush(); AbraResource.initialize(); HeraResource.initialize(); BuizelResource.initialize(); GrovyleResource.initialize(); SandslashResource.initialize(); RhydonResource.initialize(); SmeargleResource.initialize(); KecleonResource.initialize(); MagnResource.initialize(); GrimerResource.initialize(); LucarioResource.initialize(); FlxTransitionableState.defaultTransIn = new TransitionData(TransitionType.NONE); FlxTransitionableState.defaultTransOut = new TransitionData(TransitionType.NONE); if (PlayerData.clickDate == null) { PlayerData.clickDate = Date.now(); } CursorUtils.initializeSystemCursor(); } }
argonvile/monster
source/Main.hx
hx
unknown
4,159
package; import demo.SexyDebugState; import ReservoirMeter.ReservoirStatus; import credits.CreditsState; import credits.EndingAnim; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.group.FlxGroup; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.ui.FlxButton; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import kludge.FlxSoundKludge; import kludge.FlxSpriteKludge; import minigame.MinigameState; import minigame.scale.ScaleGameState; import minigame.stair.StairGameState; import minigame.tug.TugGameState; import openfl.utils.Object; import poke.abra.AbraDialog; import poke.abra.AbraResource; import poke.abra.AbraSexyState; import poke.buiz.BuizelResource; import poke.grim.GrimerResource; import poke.grov.GrovyleResource; import poke.hera.HeraResource; import poke.luca.LucarioDialog; import poke.luca.LucarioResource; import poke.rhyd.RhydonResource; import poke.sand.SandslashResource; import poke.sexy.SexyState; import puzzle.PuzzleState; import puzzle.RankHistoryState; import puzzle.RankTracker; /** * The main screen where Abra teleports in and you pick your puzzle difficulty */ class MainMenuState extends FlxTransitionableState { private static var TUTORIAL_BUTTON_ID = 975482; private var _handSprite:FlxSprite; private var _abraGroup:WhiteGroup; private var _abraBlackGroup:BlackGroup; private var _abraBrain:BouncySprite; private var _abra0:BouncySprite; private var _buttons:FlxTypedGroup<FlxSprite>; private var _optionsButton:FlxButton; private var _itemsButton:FlxButton; private var _creditsButton:FlxButton; private var _blip:FlxSprite; private var _time:Float = 0; private var _state:Dynamic; private var _rotateProfsCheat:Bool = false; private var _minigameCheat:MinigameState = null; private var _tutorialMode:Bool = false; private var _abraBlackTween:FlxTween; private var fivePegUnlocked:Bool = false; private var sevenPegUnlocked:Bool = false; private var _dialogTree:DialogTree; private var _dialogger:Dialogger; private var lightsManager:LightsManager; private var tutorialToggleButton:BouncySprite; public function new(?TransIn:TransitionData, ?TransOut:TransitionData) { super(TransIn, TransOut); } override public function create():Void { super.create(); bgColor = FlxColor.BLACK; /* * clear cached bitmap assets to avoid running out of memory */ FlxG.bitmap.dumpCache(); Main.overrideFlxGDefaults(); // Reset "per-puzzle" type variables PlayerData.profIndex = -1; // clear profIndex, to avoid hasMet() goofups PlayerData.level = 0; PlayerData.finalRankHistory = []; PlayerData.justFinishedMinigame = false; PlayerData.finalTrial = false; if (PlayerData.name == null) { if (PlayerData.puzzleCount[0] <= 2) { PlayerData.level = PlayerData.puzzleCount[0]; } PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Grovyle"); PlayerData.difficulty = PlayerData.Difficulty.Easy; PlayerSave.clearTransientData(); FlxG.switchState(new PuzzleState()); return; } fivePegUnlocked = PlayerData.fivePegUnlocked(); sevenPegUnlocked = PlayerData.sevenPegUnlocked(); if (PlayerData.abraChats[0] == 6) { // just beat the game; don't allow 7-peg puzzles until the epilogue is over sevenPegUnlocked = false; } add(new FlxSprite(0, 0, AssetPaths.title_screen_bg__png)); _abraGroup = new WhiteGroup(); add(_abraGroup); _abraBlackGroup = new BlackGroup(); _abraBlackGroup.visible = false; add(_abraBlackGroup); _abraBrain = new BouncySprite(0, 0, 10, 4, 0); _abraBrain.loadGraphic(AssetPaths.title_screen_abra_brain__png); _abraBrain.alpha = 0; _abraBrain.visible = false; add(_abraBrain); var sevenPegText:FlxText = new FlxText(325, 60, 100, "7 Pegs", 20); sevenPegText.alignment = CENTER; sevenPegText.font = AssetPaths.hardpixel__otf; sevenPegText.color = OptionsMenuState.WHITE_BLUE; sevenPegText.setBorderStyle(OUTLINE, OptionsMenuState.DARK_BLUE, 2); _abraBrain.stamp(sevenPegText, 325, 60); var mind:BouncySprite = new BouncySprite(0, 0, 10, 4, 0); mind.loadGraphic(AssetPaths.title_screen_mind__png); add(mind); _buttons = new FlxTypedGroup<FlxSprite>(); add(_buttons); _optionsButton = SexyState.newBackButton(options, AssetPaths.options_button__png); _optionsButton.x -= 12; _optionsButton.y = 6; add(_optionsButton); _itemsButton = SexyState.newBackButton(items, AssetPaths.items_button__png); _itemsButton.x -= 6; _itemsButton.y = 32; add(_itemsButton); if (PlayerData.abraStoryInt == 5 || PlayerData.abraStoryInt == 6) { _creditsButton = SexyState.newBackButton(credits, AssetPaths.credits_button__png); _creditsButton.x = 12; _creditsButton.y = 6; add(_creditsButton); } lightsManager = new LightsManager(); add(lightsManager._spotlights); _dialogger = new Dialogger(); add(_dialogger); updateAbraStory(); ItemDatabase.refillShop(); // refill the shop just in case kecleon leaves/shows up initializeButtons(); lightsManager._spotlights.addSpotlight("tutorial"); lightsManager._spotlights.growSpotlight("tutorial", tutorialToggleButton.getHitbox()); _handSprite = new FlxSprite(100, 100); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(3, 3); _handSprite.offset.set(69, 87); add(_handSprite); if (!PlayerData.abraMainScreenTeleport) { PlayerData.abraMainScreenTeleport = true; _state = state0; } else { _abraGroup._whiteness = 0; addAbraSprites(); } if (PlayerData.abraStoryInt == 4) { // abra is missing _abraGroup.visible = false; _abraBlackGroup.visible = false; _abraBrain.visible = false; _state = null; sevenPegUnlocked = false; } add(new CheatCodes(cheatCodeCallback)); } /** * Abra's story proceeds based on the player's money, items, rank, and how * many Pokemon they've met. * * This method checks if it's time for Abra to tell the player something * new on the title screen, like "Hey you're doing great keep it up" or * "Come play some puzzles with me if you get a chance, I need to ask you * something" */ private function updateAbraStory() { var totalCharactersMet = getTotalCharactersMet(); var totalWealth = getTotalWealth(); var rank = RankTracker.computeAggregateRank(); if (PlayerData.abraStoryInt <= 2) { if (totalCharactersMet >= 10 && totalWealth + 600 * rank >= 48000) { setAbraStory(3); return; } } if (PlayerData.abraStoryInt <= 1) { if (totalCharactersMet >= 9 && totalWealth + 600 * rank >= 20000) { setAbraStory(2); return; } } if (PlayerData.abraStoryInt <= 0) { setAbraStory(1); return; } } /** * Launches some Abra dialog. This occurs three times at the start, middle * and end of the game to progress the overarching story. * * 1 = Tutorial dialog * 2 = Mid-point dialog * 3 = End dialog * * @param abraStoryInt new story value */ public function setAbraStory(abraStoryInt:Int) { PlayerData.abraStoryInt = abraStoryInt; var abraDialogFunction:Array<Array<Object>>->Void = null; switch (abraStoryInt) { case 1: abraDialogFunction = AbraDialog.tutorialNotice; case 2: abraDialogFunction = AbraDialog.halfwayNotice; case 3: abraDialogFunction = AbraDialog.storyNotice; PlayerData.abraChats = [2, 3, 4, 5]; } if (abraDialogFunction != null) { var tree:Array<Array<Object>> = new Array<Array<Object>>(); abraDialogFunction(tree); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } } /** * @return number of Pokemon the player has met, out of the main ten */ public function getTotalCharactersMet():Int { var totalCharactersMet:Int = 0; for (prefix in ["abra", "buiz", "hera", "grov", "sand", "rhyd", "smea", "magn", "grim", "luca"]) { if (PlayerData.hasMet(prefix)) { totalCharactersMet++; } } return totalCharactersMet; } /** * @return player's estimated wealth (items + money) */ public static function getTotalWealth():Int { var totalWealth:Int = PlayerData.cash; for (playerItemIndex in ItemDatabase._playerItemIndexes) { totalWealth += ItemDatabase._itemTypes[playerItemIndex].basePrice; } if (ItemDatabase.getPurchasedMysteryBoxCount() > 0) { // player pays about $33,500 for each mystery box they open totalWealth += 33500 * ItemDatabase.getPurchasedMysteryBoxCount(); } return totalWealth; } public static inline function fadeInFast():TransitionData { return new TransitionData(TransitionType.FADE, FlxColor.BLACK, 0.3); } public static inline function fadeOutSlow():TransitionData { return new TransitionData(TransitionType.FADE, FlxColor.BLACK, 1.2); } public function dialogTreeCallback(line:String):String { if (line == "%lights-tutorial%") { lightsManager.setLightsDim(0.6); lightsManager.setSpotlightOn("tutorial"); } if (line == "%lights-on%") { lightsManager.setLightsOn(); } if (line == "%credits%") { transOut = fadeInFast(); var creditsState:CreditsState = new CreditsState(fadeInFast()); creditsState.backToMainMenu = true; FlxG.switchState(creditsState); } return null; } private function options():Void { if (DialogTree.isDialogging(_dialogTree)) { return; } FlxG.switchState(new OptionsMenuState()); } private function items():Void { if (DialogTree.isDialogging(_dialogTree)) { return; } FlxG.switchState(new ItemsMenuState()); } private function credits():Void { if (DialogTree.isDialogging(_dialogTree)) { return; } var tree:Array<Array<Object>> = new Array<Array<Object>>(); tree[0] = ["#self00#(Hmm, do I want to watch the credits again?)"]; tree[1] = [10, 20]; tree[10] = ["Yes"]; tree[11] = ["%credits%"]; tree[20] = ["No"]; _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } public function cheatCodeCallback(Code:String) { var fiveCode:String = Code.substring(Code.length - 5, Code.length); #if debug if (fiveCode == "CHEAT") { PlayerData.cheatsEnabled = !PlayerData.cheatsEnabled; if (PlayerData.cheatsEnabled) { FlxSoundKludge.play(AssetPaths.rank_up_00C4__mp3); } else { FlxSoundKludge.play(AssetPaths.rank_down_00C5__mp3); } } #end if (PlayerData.cheatsEnabled) { if (fiveCode.substring(0, 2) == "AB" || fiveCode.substring(0, 2) == "BU" || fiveCode.substring(0, 2) == "CH" || fiveCode.substring(0, 2) == "GR" || fiveCode.substring(0, 2) == "SA" || fiveCode.substring(0, 2) == "RH" || fiveCode.substring(0, 2) == "SM" || fiveCode.substring(0, 2) == "MA" || fiveCode.substring(0, 2) == "HE" || fiveCode.substring(0, 2) == "LU" || fiveCode.substring(0, 2) == "ZZ") { var level:Null<Int> = Std.parseInt(fiveCode.substring(2, 3)); var scenario:Null<Int> = Std.parseInt(fiveCode.substring(3, 5)); if (scenario != null && level != null) { if (fiveCode.substring(0, 2) != "ZZ") { var prefix:String = "abra"; if (fiveCode.substring(0, 2) == "AB") { prefix = "abra"; } else if (fiveCode.substring(0, 2) == "BU") { prefix = "buiz"; } else if (fiveCode.substring(0, 2) == "CH") { prefix = "grim"; } else if (fiveCode.substring(0, 2) == "GR") { prefix = "grov"; } else if (fiveCode.substring(0, 2) == "SA") { prefix = "sand"; } else if (fiveCode.substring(0, 2) == "RH") { prefix = "rhyd"; } else if (fiveCode.substring(0, 2) == "SM") { prefix = "smea"; } else if (fiveCode.substring(0, 2) == "MA") { prefix = "magn"; } else if (fiveCode.substring(0, 2) == "HE") { prefix = "hera"; } else if (fiveCode.substring(0, 2) == "LU") { prefix = "luca"; } var profIndex = PlayerData.PROF_PREFIXES.indexOf(prefix); if (prefix == "luca" && scenario == 0) { PlayerData.luckyProfSchedules.remove(PlayerData.PROF_PREFIXES.indexOf("luca")); PlayerData.luckyProfSchedules.insert(0, PlayerData.PROF_PREFIXES.indexOf("luca")); LevelIntroDialog.rotateProfessors([], false); initializeButtons(); } else { PlayerData.professors = [profIndex, profIndex, profIndex, profIndex]; } if (scenario != 99) { if (level <= 2) { var chats:Dynamic = Reflect.field(PlayerData, prefix + "Chats"); if (chats.length > PlayerData.CHATLENGTH) { chats[0] = scenario; } else { chats.insert(0, scenario); } } else { Reflect.setField(PlayerData, prefix + "SexyBeforeChat", scenario); } if (prefix == "abra") { if (level == 0) { if (PlayerData.abra7PegChats.length > PlayerData.CHATLENGTH) { PlayerData.abra7PegChats[0] = scenario; } else { PlayerData.abra7PegChats.insert(0, scenario); } } else { PlayerData.abra7PegSexyBeforeChat = scenario; } } } if (prefix == "hera") { // get kecleon out here ItemDatabase._solvedPuzzle = true; ItemDatabase.refillShop(); PlayerData.professors = [profIndex, profIndex, profIndex, profIndex]; } initializeButtons(); } FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3); if (level != 9) { PlayerData.level = level; } } } if (fiveCode.substring(0, 3) == "END") { var scenario:Null<Int> = Std.parseInt(fiveCode.substring(3, 5)); /* * END00...03: reset everything to before the ending, try abra's various main menu conversations * END10...16: "swap ending" progression * END17: "swap ending" final animation * END18: "swap ending" credits * END19: "swap ending" epilogue * END20...27: "don't swap ending" progression * END28: "don't swap ending" credits * END29: "don't swap ending" epilogue */ if (scenario != null) { if (scenario >= 0 && scenario <= 3) { // reset everything to before the ending; try abra's various main menu conversations setFinalTrialCount(0); setAbraStory(scenario); if (scenario < 3 && PlayerData.abraChats.length > 0 && PlayerData.abraChats[0] >= 2 && PlayerData.abraChats[0] <= 5) { // Remove any ending dialog that's queued up PlayerData.abraChats = [69]; PlayerData.abraSexyBeforeChat = 69; } if (scenario == 3) { PlayerData.professors[2] = PlayerData.PROF_PREFIXES.indexOf("abra"); PlayerData.professors[3] = PlayerData.PROF_PREFIXES.indexOf("abra"); initializeButtons(); PlayerData.abraChats = [2, 3, 4, 5]; PlayerData.abraSexyBeforeChat = 69; } FlxSoundKludge.play(AssetPaths.abra1__mp3, 0.4); } else if (scenario >= 10 && scenario <= 19) { // "swap" ending PlayerData.abraStoryInt = 3; if (scenario == 17) { PlayerData.successfulSync(); FlxG.switchState(EndingAnim.newInstance()); } else if (scenario == 18) { PlayerData.successfulSync(); FlxG.switchState(new CreditsState()); } else { if (scenario == 19) { PlayerData.successfulSync(); } else { PlayerData.abraChats = [3, 4, 5]; PlayerData.abraChats.splice(0, Std.int(FlxMath.bound(scenario - 10, 0, 2))); PlayerData.abraSexyBeforeChat = 69; setFinalTrialCount(Std.int(FlxMath.bound(scenario - 12, 0, 99))); } PlayerData.professors[2] = PlayerData.PROF_PREFIXES.indexOf("abra"); PlayerData.professors[3] = PlayerData.PROF_PREFIXES.indexOf("abra"); initializeButtons(); FlxSoundKludge.play(AssetPaths.abra3__mp3, 0.4); } } else if (scenario >= 20 && scenario <= 29) { // "don't swap" ending PlayerData.abraStoryInt = 4; if (scenario == 28) { PlayerData.successfulSync(); FlxG.switchState(new CreditsState()); } else { if (scenario == 29) { PlayerData.successfulSync(); } else { PlayerData.abraChats = [3, 4, 5]; PlayerData.abraChats.splice(0, Std.int(FlxMath.bound(scenario - 20, 0, 2))); PlayerData.abraSexyBeforeChat = 69; setFinalTrialCount(Std.int(FlxMath.bound(scenario - 22, 0, 99))); } PlayerData.professors[2] = PlayerData.PROF_PREFIXES.indexOf("abra"); PlayerData.professors[3] = PlayerData.PROF_PREFIXES.indexOf("abra"); initializeButtons(); FlxSoundKludge.play(AssetPaths.abra2__mp3, 0.4); } } } } if (fiveCode == "INTR0" || fiveCode == "INTR1" || fiveCode == "INTR2") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.name = null; PlayerData.preliminaryName = null; PlayerData.puzzleCount[0] = Std.parseInt(fiveCode.substring(4, 5)); FlxG.switchState(new MainMenuState()); } if (fiveCode == "ITEMS") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); while (ItemDatabase._shopItems.length > 0) { var itemIndex:Int = ItemDatabase._shopItems.splice(0, 1)[0]._itemIndex; if (itemIndex >= 0) { ItemDatabase._playerItemIndexes.push(itemIndex); } } while (ItemDatabase._warehouseItemIndexes.length > 0) { var itemIndex:Int = ItemDatabase._warehouseItemIndexes.splice(0, 1)[0]; ItemDatabase._playerItemIndexes.push(itemIndex); } for (itemType in ItemDatabase._itemTypes) { if (!ItemDatabase.playerHasItem(itemType.index)) { ItemDatabase._playerItemIndexes.push(itemType.index); } } } if (fiveCode == "SMELL") { FlxSoundKludge.play(AssetPaths.grim5__mp3, 0.7); PlayerData.cursorSmellTimeRemaining = 15 * 60; } if (fiveCode == "HAND0" || fiveCode == "HAND1") { PlayerData.cursorType = (fiveCode == "HAND0") ? "none" : "default"; PlayerData.cursorSmellTimeRemaining = 0; CursorUtils.initializeSystemCursor(); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(3, 3); _handSprite.offset.set(69, 87); FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3); } if (fiveCode.substring(0, 3) == "CHT") { var howMany:Null<Int> = Std.parseInt(fiveCode.substring(3, 5)); if (howMany != null) { for (i in 0...howMany) { PlayerData.appendChatHistory("tfyazeckoj"); } PlayerData.storeChatHistory(); FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3); } } if (fiveCode == "BUOYS" || fiveCode == "GIRLS") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); var male = fiveCode == "BUOYS"; for (prefix in PlayerData.PROF_PREFIXES) { Reflect.setField(PlayerData, prefix + "Male", male); } Main.overrideFlxGDefaults(); initializeButtons(); if (_abra0 != null) { _abra0.loadGraphic(AbraResource.titleScreen); } } if (fiveCode == "MONEY") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.cash += 10000; } if (fiveCode == "HORN0") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); for (profIndex in 0...PlayerData.professors.length) { var fieldName:String = PlayerData.PROF_PREFIXES[PlayerData.professors[profIndex]] + "Reservoir"; Reflect.setField(PlayerData, fieldName, 0); } PlayerData.smeaReservoirBank = 0; initializeButtons(); } if (fiveCode == "3WHPR") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerSave.nukeData(); FlxG.switchState(new MainMenuState()); } var sixCode:String = Code.substring(Code.length - 6, Code.length); if (StringTools.startsWith(sixCode, "WAIT")) { var howManyMinutes:Null<Int> = Std.parseInt(sixCode.substring(4, 6)); if (howManyMinutes != null) { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.rewardTime += 60 * howManyMinutes; if (ItemDatabase._prevRefillTime != null) { ItemDatabase._prevRefillTime = Date.fromTime(ItemDatabase._prevRefillTime.getTime() - 1000 * 60 * howManyMinutes); } PlayerData.updateTimePlayed(); } } if (fiveCode == "SCALE") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.minigameReward = Std.int(Math.max(PlayerData.minigameReward, 500)); _minigameCheat = new ScaleGameState(); } if (fiveCode == "TUGOW") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.minigameReward = Std.int(Math.max(PlayerData.minigameReward, 500)); _minigameCheat = new TugGameState(); } if (fiveCode == "STAIR") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.minigameReward = Std.int(Math.max(PlayerData.minigameReward, 500)); _minigameCheat = new StairGameState(); } if (fiveCode == "CYCLE") { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); _rotateProfsCheat = true; } if (fiveCode == "YRANK") { FlxG.switchState(new RankHistoryState()); } if (fiveCode == "UNEAT") { PlayerData.grimEatenItem = -1; PlayerData.grimMoneyOwed = 0; FlxSoundKludge.play(AssetPaths.grim0__mp3); } } } private function setFinalTrialCount(count:Int):Void { PlayerData.removeFromChatHistory("abra.fixedChats." + AbraDialog.FINAL_CHAT_INDEX); for (i in 0...count * 3) { PlayerData.quickAppendChatHistory("abra.fixedChats." + AbraDialog.FINAL_CHAT_INDEX, false); } } private function state0(elapsed:Float):Void { if (_time > 0.3) { _blip = new FlxSprite(0, 0); _blip.loadGraphic(AssetPaths.title_screen_blip__png, true, 768, 432); _blip.animation.add("play", [0, 1, 2, 2], 30, false); _blip.animation.play("play"); var abraGroup:FlxGroup = _abraGroup.visible ? _abraGroup : _abraBlackGroup; abraGroup.add(_blip); _state = state1; } } private function state1(elapsed:Float):Void { if (_blip.animation.curAnim == null || _blip.animation.curAnim.curFrame == 3) { _blip = FlxDestroyUtil.destroy(_blip); var abraGroup:FlxGroup = addAbraSprites(); FlxSoundKludge.play(AssetPaths.abra0__mp3, 0.4); FlxSoundKludge.play(AssetPaths.countdown_go_005c__mp3); if (Std.isOfType(abraGroup, WhiteGroup)) { cast(abraGroup, WhiteGroup).addTeleparticles(319, 34, 319 + 97, 34 + 268, 20); } _state = state2; } } private function addAbraSprites():FlxGroup { var abraGroup:FlxGroup = _abraGroup.visible ? _abraGroup : _abraBlackGroup; _abra0 = new BouncySprite(0, 0, 10, 7, 0); _abra0.loadGraphic(AbraResource.titleScreen, true, 768, 432); _abra0.animation.add("play", [0, 1], 3); _abra0.animation.play("play"); abraGroup.add(_abra0); _abraBrain.synchronize(_abra0); _abraBrain.alpha = 1.0; FlxTween.tween(_abraBrain, {alpha:0.77}, 1.7, {type:FlxTweenType.PINGPONG, ease:FlxEase.sineInOut}); var abra1:BouncySprite = new BouncySprite(0, 0, 10, 7, 0.8); abra1.loadGraphic(AssetPaths.title_screen_abra1__png); abraGroup.add(abra1); var abra2:BouncySprite = new BouncySprite(0, 0, 10, 7, 0); abra2.loadGraphic(AssetPaths.title_screen_abra2__png); abraGroup.add(abra2); return abraGroup; } private function state2(elapsed:Float):Void { _abraGroup._whiteness = Math.max(0, _abraGroup._whiteness - 5 * elapsed); if (_abraGroup._whiteness == 0) { _state = null; } } private function getAnyBouncyButton():BouncySprite { for (member in _buttons.members) { if (member.alive && Std.isOfType(member, BouncySprite)) { return cast(member, BouncySprite); } } return null; } function initializeButtons():Void { var age:Float = 0; var anyBouncyButton:BouncySprite = getAnyBouncyButton(); if (anyBouncyButton != null) { age = anyBouncyButton._age; } _buttons.kill(); _buttons.clear(); _buttons.revive(); var desc:Array<String> = ["Novice", "3 Pegs", "4 Pegs", "5 Pegs", "Shop"]; for (i in 0...5) { var button:BouncySprite = new BouncySprite(0, 0, 8, 3.5, i * 0.2, age); var graphic:FlxGraphicAsset = AbraResource.button; // default to abra; just to avoid crashing if (i == 3 && !fivePegUnlocked) { continue; } if (i == 4) { if (ItemDatabase.isKecleonPresent()) { graphic = AssetPaths.menu_kecl__png; } else { graphic = HeraResource.shopButton; } button.loadGraphic(graphic, false, 0, 0, true); } else { if (_tutorialMode) { graphic = GrovyleResource.tutorialButton; button.loadGraphic(graphic, false, 0, 0, true); } else { if (PlayerData.professors[i] == 0) { graphic = AbraResource.button; } else if (PlayerData.professors[i] == 1) { graphic = BuizelResource.button; } else if (PlayerData.professors[i] == 2) { graphic = HeraResource.button; } else if (PlayerData.professors[i] == 3) { graphic = GrovyleResource.button; } else if (PlayerData.professors[i] == 4) { graphic = SandslashResource.button; } else if (PlayerData.professors[i] == 5) { if (PlayerData.rhydonCameraUp) { graphic = RhydonResource.button; } else { graphic = RhydonResource.buttonCrotch; } } else if (PlayerData.professors[i] == 6) { graphic = AssetPaths.menu_smear__png; } else if (PlayerData.professors[i] == 8) { graphic = AssetPaths.menu_magn__png; } else if (PlayerData.professors[i] == 9) { graphic = GrimerResource.button; } else if (PlayerData.professors[i] == 10) { graphic = LucarioResource.button; } button.loadGraphic(graphic, true, 118, 173, true); if (!PlayerData.hasMet(PlayerData.PROF_PREFIXES[PlayerData.professors[i]])) { button.animation.frameIndex = 1; } } } { var text:FlxText = new FlxText(0, 0, button.width, desc[i], 20); text.alignment = "center"; text.font = AssetPaths.hardpixel__otf; button.stamp(text); } button.ID = i; if (fivePegUnlocked) { button.x = FlxG.width * 0.1 + FlxG.width * 0.2 * i - button.width / 2; } else { button.x = FlxG.width * 0.17 + FlxG.width * 0.22 * i - button.width / 2; if (i == 4) { button.x -= FlxG.width * 0.22; } } button.y = FlxG.height - button.height - 10; _buttons.add(button); if (i == 4 && ItemDatabase._newItems) { var newItems:FlxSprite = new BouncySprite(button.x, button.y, button._bounceAmount, button._bounceDuration, button._bouncePhase, button._age); newItems.loadGraphic(AssetPaths.shop_new__png, true, 118, 207); newItems.animation.add("default", AnimTools.blinkyAnimation([0, 1, 2]), 3); newItems.animation.play("default"); _buttons.add(newItems); } if (i < PlayerData.professors.length) { var prefix:String = PlayerData.PROF_PREFIXES[PlayerData.professors[i]]; if (_tutorialMode) { prefix = "grov"; } var reservoir:Int = Reflect.field(PlayerData, prefix + "Reservoir"); var diminishmentFactor:Float = 0.5; // 1.0 = linear, 2.0 = emptier, 0.5 = fuller if (prefix == "sand") { diminishmentFactor = 0.2; } else if (prefix == "smea") { diminishmentFactor = 1.2; } var percent:Float = Math.pow(reservoir / 210, diminishmentFactor); var reservoirStatus:ReservoirStatus = ReservoirStatus.Green; if (reservoir >= 210) { reservoirStatus = ReservoirStatus.Emergency; } else if (reservoir >= 90) { reservoirStatus = ReservoirStatus.Red; } else if (reservoir >= 30) { reservoirStatus = ReservoirStatus.Yellow; } if (prefix == "smea") { if (reservoir < 60) { reservoirStatus = ReservoirStatus.Green; } else if (reservoir < 120) { reservoirStatus = ReservoirStatus.Yellow; } } if (prefix == "magn") { percent = 0; reservoirStatus = ReservoirStatus.Green; } _buttons.add(new ReservoirMeter(button, percent, reservoirStatus)); } } { tutorialToggleButton = new BouncySprite(0, 0, 8, 3.5, getAnyBouncyButton()._bouncePhase - 0.2, age); if (_tutorialMode) { tutorialToggleButton.loadGraphic(AbraResource.tutorialOffButton); } else { tutorialToggleButton.loadGraphic(GrovyleResource.tutorialOnButton); } tutorialToggleButton.ID = TUTORIAL_BUTTON_ID; tutorialToggleButton.x = _buttons.getFirstAlive().x; tutorialToggleButton.y = _buttons.getFirstAlive().y - tutorialToggleButton.height - 14; _buttons.add(tutorialToggleButton); } } override public function update(elapsed:Float):Void { super.update(elapsed); PlayerData.updateTimePlayed(); if (FlxG.mouse.justPressed) { PlayerData.updateCursorVisible(); } _time += elapsed; if (PlayerData.name == null) { // redirecting to intro... return; } #if debug if (FlxG.keys.justPressed.F5) { FlxG.switchState(new SexyDebugState()); } #end _handSprite.setPosition(FlxG.mouse.x - _handSprite.width / 2, FlxG.mouse.y - _handSprite.height / 2); if (sevenPegUnlocked) { var brainDist:Float = FlxMath.vectorLength(FlxG.mouse.x - 372, FlxG.mouse.y - 81 + _abraBrain.offset.y); if (brainDist < 50 && _abraGroup.visible) { for (member in _abraGroup.members) { _abraBlackGroup.add(member); } _abraGroup.clear(); _abraBlackGroup.visible = true; _abraBrain.visible = true; _abraGroup.visible = false; _abraBlackGroup._blackness = 0; FlxTweenUtil.retween(_abraBlackTween, _abraBlackGroup, {_blackness:0.9}, 0.5, {ease:FlxEase.circOut}); } else if (brainDist > 60 && !_abraGroup.visible) { for (member in _abraBlackGroup.members) { _abraGroup.add(member); } _abraBlackGroup.clear(); _abraGroup.visible = true; _abraBlackGroup.visible = false; _abraBrain.visible = false; } if (FlxG.mouse.justPressed && !_dialogger._handledClick && _abraBlackGroup.visible) { // switch to 7-peg state PlayerData.difficulty = PlayerData.Difficulty._7Peg; PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Abra"); if (PlayerData.level >= 1) { var sexyState:AbraSexyState = new AbraSexyState(); cast(sexyState, AbraSexyState).permaBoner = true; FlxG.switchState(sexyState); } else { FlxG.switchState(new PuzzleState()); } } } if (FlxG.mouse.justPressed && !_dialogger._handledClick) { var clickedButton:FlxSprite = null; for (button in _buttons.members) { if (FlxSpriteKludge.overlap(_handSprite, button) && button.visible) { clickedButton = button; break; } } if (clickedButton != null) { if (clickedButton.ID >= 0 && clickedButton.ID <= 3) { PlayerData.difficulty = [PlayerData.Difficulty.Easy, PlayerData.Difficulty._3Peg, PlayerData.Difficulty._4Peg, PlayerData.Difficulty._5Peg][clickedButton.ID]; if (LucarioDialog.isLucariosFirstTime() && PlayerData.hasMet(LucarioDialog.getLucarioReplacementProfPrefix())) { PlayerData.profIndex = PlayerData.PROF_PREFIXES.indexOf("luca"); } else { PlayerData.profIndex = PlayerData.professors[PlayerData.difficulty.getIndex()]; } if (_rotateProfsCheat) { // don't start level; just rotate the professors LevelIntroDialog.increaseProfReservoirs(); LevelIntroDialog.rotateProfessors([PlayerData.prevProfPrefix]); ItemDatabase._solvedPuzzle = true; ItemDatabase.refillShop(); initializeButtons(); _rotateProfsCheat = false; FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } else if (_tutorialMode) { // start tutorial PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Grovyle"); var puzzleState:PuzzleState = new PuzzleState(); if (clickedButton.ID == 0) { puzzleState._tutorial = TutorialDialog.tutorialNovice; } else if (clickedButton.ID == 1) { puzzleState._tutorial = TutorialDialog.tutorial3Peg; } else if (clickedButton.ID == 2) { puzzleState._tutorial = TutorialDialog.tutorial4Peg; } else { puzzleState._tutorial = TutorialDialog.tutorial5Peg; if (PlayerData.isAbraNice()) { if (PlayerData.level > 1) { PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Abra"); } } else { if (PlayerData.level > 0) { PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Abra"); } } } FlxG.switchState(puzzleState); } else { if (_minigameCheat != null) { // start minigame FlxG.switchState(_minigameCheat); } else if (PlayerData.level >= 3) { // start sexystate? if (PlayerData.sfw) { // skip sexystate; sfw mode transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } else { // start sexystate FlxG.switchState(SexyState.getSexyState()); } } else { // start regular level PlayerData.finalTrial = isFinalTrial(PlayerData.profIndex); FlxG.switchState(new PuzzleState()); } } } else if (clickedButton.ID == 4) { FlxG.switchState(new ShopState()); return; } else if (clickedButton.ID == TUTORIAL_BUTTON_ID) { FlxSoundKludge.play(AssetPaths.beep_0065__mp3); _tutorialMode = !_tutorialMode; initializeButtons(); } } } if (_state != null) { _state(elapsed); } } private function isFinalTrial(profIndex:Int=-1) { if (profIndex != -1 && profIndex != PlayerData.PROF_NAMES.indexOf("Abra")) { return false; } return PlayerData.abraChats.length >= 1 && PlayerData.abraChats[0] == AbraDialog.FINAL_CHAT_INDEX; } override public function destroy():Void { super.destroy(); _handSprite = FlxDestroyUtil.destroy(_handSprite); _abraGroup = FlxDestroyUtil.destroy(_abraGroup); _abraBlackGroup = FlxDestroyUtil.destroy(_abraBlackGroup); _abraBrain = FlxDestroyUtil.destroy(_abraBrain); _abra0 = FlxDestroyUtil.destroy(_abra0); _buttons = FlxDestroyUtil.destroy(_buttons); _optionsButton = FlxDestroyUtil.destroy(_optionsButton); _itemsButton = FlxDestroyUtil.destroy(_itemsButton); _creditsButton = FlxDestroyUtil.destroy(_creditsButton); _blip = FlxDestroyUtil.destroy(_blip); _state = null; _minigameCheat = null; _abraBlackTween = FlxTweenUtil.destroy(_abraBlackTween); _dialogTree = FlxDestroyUtil.destroy(_dialogTree); _dialogger = FlxDestroyUtil.destroy(_dialogger); lightsManager = FlxDestroyUtil.destroy(lightsManager); tutorialToggleButton = FlxDestroyUtil.destroy(tutorialToggleButton); } }
argonvile/monster
source/MainMenuState.hx
hx
unknown
36,979
package; import flixel.effects.particles.FlxParticle; import flixel.math.FlxMath; /** * A particle which spawns a specified distance from an object. This is * sometimes desirable to give a "poof effect" instead of a "spark effect". */ class MinRadiusParticle extends FlxParticle { private var _radius:Float; public function new(radius:Float) { super(); this._radius = radius; } override public function onEmit():Void { if (velocity.x != 0 || velocity.y != 0) { var vdx:Float = velocity.x; var vdy:Float = velocity.y; var a:Float = Math.sqrt((_radius * _radius) / (vdx * vdx + vdy * vdy)); x += vdx * a; y += vdy * a; } } }
argonvile/monster
source/MinRadiusParticle.hx
hx
unknown
689
package; import flixel.FlxG; /** * A collection of string utility functions for MonsterMind */ class MmStringTools { private static var CENSORED_WORDS:Array<String> = ["@*&%", "@!*#", "#!*&", "#*@%", "!#@*", "!@#&", "%&!@", "%#!*", "&%!#", "&!%@", "*&%@", "*%&#"]; public static function substringBetween(Str:String, Open:String, Close:String):String { if (Str == null || Open == null || Close == null) { return null; } var start:Int = Str.indexOf(Open); if (start != -1) { var end:Int = Str.indexOf(Close, start + Open.length); if (end != -1) { return Str.substring(start + Open.length, end); } } return null; } public static function substringBefore(Str:String, Separator:String):String { if (Str == null || Str == "" || Separator == null) { return Str; } if (Separator == "") { return ""; } var pos:Int = Str.indexOf(Separator); if (pos == -1) { return Str; } return Str.substring(0, pos); } public static function substringAfter(Str:String, Separator:String):String { if (Str == null || Str == "") { return Str; } if (Separator == null) { return ""; } var pos:Int = Str.indexOf(Separator); if (pos == -1) { return ""; } return Str.substring(pos + Separator.length); } /** * Capitalize the first character of the string */ public static function capitalize(str:String):String { var strLen:Int; if (str == null || (strLen = str.length) == 0) { return str; } var firstChar:String = str.substr(0, 1); var newChar:String = firstChar.toUpperCase(); if (firstChar == newChar) { // already capitalized return str; } return newChar + str.substr(1, str.length - 1); } public static function isUpperCaseLetter(s:String):Bool { return s >= "A" && s <= "Z"; } public static function isLetter(s:String):Bool { return s >= "A" && s <= "Z" || s >= "a" && s <= "z"; } public static function isConsonant(text:String, ?y:Bool=false):Bool { return (y?"BCDFGHJKLMNPQRSTVWXYZ":"BCDFGHJKLMNPQRSTVWXZ").indexOf(text.toUpperCase()) != -1; } public static function isVowel(text:String, ?y:Bool=true):Bool { return (y?"AEIOUY":"AEIOU").indexOf(text.toUpperCase()) != -1; } /** * Capitalize the first character of every word. */ public static function capitalizeWords(text:String):String { text = text.toUpperCase(); var buf:StringBuf = new StringBuf(); buf.add(text.charAt(0)); for (i in 1...text.length) { if (isUpperCaseLetter(text.charAt(i)) && isUpperCaseLetter(text.charAt(i - 1))) { buf.add(text.charAt(i).toLowerCase()); } else { buf.add(text.charAt(i)); } } return buf.toString(); } public static function beforePipe(Str:String):String { if (Str.indexOf("|") == -1) { return Str; } return substringBefore(Str, "|"); } public static function afterPipe(Str:String):String { if (Str.indexOf("|") == -1) { return Str; } return substringAfter(Str, "|"); } public static function bothPipe(Str:String):String { return StringTools.replace(Str, "|", " "); } public static function stretch(name:String):String { if (name == null) { return null; } var repeatArray:Array<Int> = []; var repeatCount:Int = 0; for (i in 0...name.length) { if (isVowel(name.charAt(i))) { repeatCount += 4; repeatArray[i] = 4; } if (repeatCount >= 8) { break; } } if (repeatCount <= 8) { // no vowels? weird name... if (name.length >= 5) { if (repeatCount <= 8 && repeatArray[name.length - 2] == 0 && isLetter(name.charAt(name.length - 2))) { repeatArray[name.length - 2] = 4; repeatCount += 4; } if (repeatCount <= 8 && repeatArray[name.length - 4] == 0 && isLetter(name.charAt(name.length - 4))) { repeatArray[name.length - 4] = 4; repeatCount += 4; } } else if (name.length >= 3) { if (repeatCount <= 8 && repeatArray[name.length - 1] == 0 && isLetter(name.charAt(name.length - 1))) { repeatArray[name.length - 1] = 4; repeatCount += 1; } if (repeatCount <= 8 && repeatArray[name.length - 2] == 0 && isLetter(name.charAt(name.length - 2))) { repeatArray[name.length - 2] = 4; repeatCount += 2; } } else if (name.length >= 1) { if (repeatCount <= 8 && repeatArray[name.length - 1] == 0 && isLetter(name.charAt(name.length - 1))) { repeatArray[name.length - 1] = 4; repeatCount += 1; } } } var stretched:String = ""; for (i in 0...name.length) { if (repeatArray[i] != 0) { for (j in 0...repeatArray[i]) { if (stretched.length > 0 && isLetter(stretched.charAt(stretched.length-1))) { stretched += name.charAt(i).toLowerCase(); } else { stretched += name.charAt(i); } } } else { stretched += name.charAt(i); } } return stretched; } public static function englishNumber(i:Int):String { if (i < 0 || i > 20) { return commaSeparatedNumber(i); } return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"][i]; } public static function moneyString(price:Int):String { return commaSeparatedNumber(price) + "$"; } public static function commaSeparatedNumber(i:Int):String { if (i < 0) { return "-" + commaSeparatedNumber(Std.int(Math.abs(i))); } var result = Std.string(i); if (result.length > 6) { result = result.substring(0, result.length - 6) + "," + result.substring(result.length - 6); } if (result.length > 3) { result = result.substring(0, result.length - 3) + "," + result.substring(result.length - 3); } return result; } static public function bowdlerize(s:String, profanity:String):String { var result:String = s; var i:Int = 0; do { i = result.toLowerCase().indexOf(profanity.toLowerCase()); if (i > -1) { result = result.substr(0, i) + FlxG.random.getObject(CENSORED_WORDS) + result.substr(i + 4); } } while (i > -1); return result; } }
argonvile/monster
source/MmStringTools.hx
hx
unknown
6,344
package; import haxe.Timer; /** * A collection of utility functions for MonsterMind */ class MmTools { /** * Returns the system time in milliseconds. * * This is intended as a cross-platform replacement for ActionScript's Date.getTime() method. */ public static inline function time():Float { return Timer.stamp() * 1000; } }
argonvile/monster
source/MmTools.hx
hx
unknown
342
package; import flixel.FlxG; /** * This class provides a way to add events which trigger at key points in a * song. * * This is useful for syncing up slideshows and graphics during the credits * sequence. */ class MusicEventStack extends EventStack { public function new() { super(); } override public function reset():Void { super.reset(); _time = FlxG.sound.music == null ? -1 : FlxG.sound.music.time / 1000; } override public function update(elapsed:Float):Void { if (!_alive) { return; } _time = FlxG.sound.music == null ? -1 : FlxG.sound.music.time / 1000; while (_eventIndex < _events.length && _events[_eventIndex].time <= _time) { if (_events[_eventIndex].callback != null) { _events[_eventIndex].callback(_events[_eventIndex].args); } _eventIndex++; } if (_eventIndex >= _events.length) { _alive = false; } } }
argonvile/monster
source/MusicEventStack.hx
hx
unknown
930
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.effects.particles.FlxParticle; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; import flixel.math.FlxRect; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.text.FlxText; import flixel.ui.FlxButton; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import kludge.AssetKludge; import kludge.FlxFilterFramesKludge; import kludge.FlxSoundKludge; import openfl.filters.DropShadowFilter; import poke.Password; import poke.sexy.SexyState; import puzzle.RankTracker; /** * The options screen where the player can change their save slot, toggle sound * effects, disable profanity and other settings. */ class OptionsMenuState extends FlxState { private var _handSprite:FlxSprite; public static var DARK_BLUE:FlxColor = 0xFF00647F; public static var MEDIUM_BLUE:FlxColor = 0xFF3FA4BF; public static var LIGHT_BLUE:FlxColor = 0xFF7FE4FF; public static var WHITE_BLUE:FlxColor = 0xFFE8FFFF; private static var DARK_RED:FlxColor = 0xFF7F3232; private static var MEDIUM_RED:FlxColor = 0xFFBF7171; private static var LIGHT_RED:FlxColor = 0xFFFFB1B1; private static var WHITE_RED:FlxColor = 0xFFFFF3F3; private var _screenSprite:FlxSprite; private var _deleteButton:FlxButton; private var _backButton:FlxButton; private var _soundButton:FlxText; private var _detailButton:FlxText; private var _profanityButton:FlxText; private var _passwordButton:FlxText; private var _sfwButton:FlxText; private var _deleteOn:Bool = false; private var _deleteSlot:Int = -1; private var _bigWhiteX:FlxSprite; private var _bigRedX:FlxSprite; private var _explosionGroup:FlxTypedGroup<FlxParticle>; private var _initialTimePlayed:Float; private var _mouseClickTime:Float = 100; private var _saveDatas:Array<Dynamic> = []; /** * the "delete" button beeps when clicking and unclicking. but it unclicks when the user deletes, and we don't want it to beep then. */ private var _suppressBeep = false; private var _initialSaveSlot:Int; private var rects:Array<FlxRect> = [ new FlxRect(67, 109, 200, 104), new FlxRect(284, 109, 200, 104), new FlxRect(501, 109, 200, 104) ]; override public function create():Void { Main.overrideFlxGDefaults(); super.create(); for (i in 0...3) { _saveDatas[i] = PlayerSave.getSaveData(i); if (_saveDatas[i].cash == null) { _saveDatas[i] = null; } } _initialSaveSlot = PlayerData.saveSlot; _initialTimePlayed = PlayerData.timePlayed; _screenSprite = new FlxSprite(0, 0); _screenSprite.makeGraphic(FlxG.width, FlxG.height); add(_screenSprite); paintScreenSprite(); { var text:FlxText = new FlxText(50, 50, FlxG.width - 100, "FILE SELECT", 40); text.font = AssetPaths.hardpixel__otf; text.alignment = FlxTextAlign.CENTER; text.color = LIGHT_BLUE; add(text); } { _bigWhiteX = new FlxSprite(); _bigWhiteX.makeGraphic(200, 104, FlxColor.TRANSPARENT, false, "big-white-x"); FlxSpriteUtil.drawLine(_bigWhiteX, 10, 10, 190, 94, { thickness:7, color:WHITE_RED } ); FlxSpriteUtil.drawLine(_bigWhiteX, 190, 10, 10, 94, { thickness:7, color:WHITE_RED } ); _bigWhiteX.visible = false; add(_bigWhiteX); } { _bigRedX = new FlxSprite(); _bigRedX.makeGraphic(200, 124, FlxColor.TRANSPARENT, false, "big-red-x"); FlxSpriteUtil.beginDraw(0x80FFB1B1); octagon(1, 1, 199, 103, 2); FlxSpriteUtil.endDraw(_bigRedX); FlxSpriteUtil.drawLine(_bigRedX, 10, 10, 190, 94, { thickness:7, color:MEDIUM_RED } ); FlxSpriteUtil.drawLine(_bigRedX, 190, 10, 10, 94, { thickness:7, color:MEDIUM_RED } ); _bigRedX.visible = false; add(_bigRedX); } _backButton = SexyState.newBackButton(back, AssetPaths.back_button2__png); _backButton.x = FlxG.width / 2 - _backButton.width / 2; _backButton.y = FlxG.height - 50 - _backButton.height - 16; add(_backButton); _soundButton = new FlxText(67, 221, 210, "", 20); _soundButton.text = FlxG.sound.volume == 0 ? "SOUND: DISABLED" : "SOUND: ENABLED"; _soundButton.font = AssetPaths.hardpixel__otf; _soundButton.color = LIGHT_BLUE; add(_soundButton); _profanityButton = new FlxText(284, 221, 210, "", 20); _profanityButton.text = PlayerData.profanity ? "PROFANITY: ENABLED" : "PROFANITY: DISABLED"; _profanityButton.font = AssetPaths.hardpixel__otf; _profanityButton.color = LIGHT_BLUE; add(_profanityButton); _detailButton = new FlxText(67, 246, 210, "", 20); _detailButton.font = AssetPaths.hardpixel__otf; _detailButton.color = LIGHT_BLUE; add(_detailButton); updateDetailButtonText(); _sfwButton = new FlxText(284, 246, 210, "", 20); _sfwButton.text = PlayerData.sfw ? "SFW MODE: SAFE" : "SFW MODE: PORN"; _sfwButton.font = AssetPaths.hardpixel__otf; _sfwButton.color = LIGHT_BLUE; add(_sfwButton); _passwordButton = new FlxText(67, 301, 0, "", 20); _passwordButton.text = "<CLICK FOR PASSWORD>"; _passwordButton.font = AssetPaths.hardpixel__otf; _passwordButton.color = LIGHT_BLUE; add(_passwordButton); _deleteButton = newDeleteButton(toggleDelete); _deleteButton.x = FlxG.width - 50 - _deleteButton.width - 14; _deleteButton.y = 213 + 14; add(_deleteButton); _explosionGroup = new FlxTypedGroup<FlxParticle>(); add(_explosionGroup); var versionText:FlxText = new FlxText(0, 0, 100, Main.VERSION_STRING, 8); versionText.alignment = "left"; versionText.alpha = 0.2; add(versionText); _handSprite = new FlxSprite(100, 100); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(3, 3); _handSprite.offset.set(69, 87); add(_handSprite); } function updateDetailButtonText() { if (PlayerData.detailLevel == PlayerData.DetailLevel.VeryLow) { _detailButton.text = "DETAIL: VERY LOW"; } else if (PlayerData.detailLevel == PlayerData.DetailLevel.Low) { _detailButton.text = "DETAIL: LOW"; } else { _detailButton.text = "DETAIL: MAX"; } } function saveExists(i:Int) { return _saveDatas[i] != null; } function back() { var timeSpentOnScreen:Float = PlayerData.timePlayed - _initialTimePlayed; PlayerSave.setSaveSlot(); if (!Math.isNaN(timeSpentOnScreen)) { PlayerData.timePlayed += timeSpentOnScreen; } FlxG.switchState(new MainMenuState()); }; function toggleDelete(deleteOn:Bool) { _mouseClickTime = 0; _deleteOn = deleteOn; _deleteSlot = -1; if (!_suppressBeep) { FlxSoundKludge.play(_deleteOn ? AssetPaths.bleep_0066__mp3 : AssetPaths.beep_0065__mp3); } paintScreenSprite(); } public static function newDeleteButton(Callback:Bool->Void, asset:FlxGraphicAsset=AssetPaths.delete_button__png):FlxButton { AssetKludge.buttonifyAsset(asset); var button:FlxButton = new FlxButton(); button.loadGraphic(asset); button.allowSwiping = false; button.setPosition(FlxG.width - button.width - 6, FlxG.height - button.height - 6); var filter:DropShadowFilter = new DropShadowFilter(3, 90, 0, ShadowGroup.SHADOW_ALPHA, 0, 0); filter.distance = 3; var spriteFilter:FlxFilterFramesKludge = FlxFilterFramesKludge.fromFrames(button.frames, 0, 5, [filter]); spriteFilter.applyToSprite(button, false, true); button.onDown.callback = function() { if (filter.distance != 0) { filter.distance = 0; spriteFilter.secretOffset.y = -3; } else { filter.distance = 3; spriteFilter.secretOffset.y = 0; } spriteFilter.applyToSprite(button, false, true); if (Callback != null) { Callback(filter.distance == 0); } } button.onUp.callback = function() { } button.onOut.callback = function() { } return button; } function paintScreenSprite() { _screenSprite.stamp(new FlxSprite(0, 0, AssetPaths.title_screen_bg__png)); FlxSpriteUtil.drawRect(_screenSprite, 0, 0, _screenSprite.width, _screenSprite.height, 0xAA003240); FlxSpriteUtil.beginDraw(MEDIUM_BLUE); octagon(50, 50, FlxG.width-50, FlxG.height-50, 2); FlxSpriteUtil.endDraw(_screenSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:9, color:DARK_BLUE }); octagon(50, 50, FlxG.width-50, FlxG.height-50, 2); FlxSpriteUtil.updateSpriteGraphic(_screenSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:7, color:WHITE_BLUE }); octagon(50, 50, FlxG.width-50, FlxG.height-50, 2); FlxSpriteUtil.updateSpriteGraphic(_screenSprite); var x:Int = 67; var y:Int = 109; for (i in 0...3) { var rect = rects[i]; var canDeleteSlot = _deleteOn && saveExists(i); FlxSpriteUtil.beginDraw(canDeleteSlot ? MEDIUM_RED : MEDIUM_BLUE); octagon(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 2); FlxSpriteUtil.endDraw(_screenSprite); if (i == PlayerData.saveSlot) { FlxSpriteUtil.beginDraw(canDeleteSlot ? 0x88FFB1B1 : 0x887FE4FF); octagon(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 2); FlxSpriteUtil.endDraw(_screenSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle( { thickness:7, color:canDeleteSlot ? LIGHT_RED : LIGHT_BLUE } ); octagon(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 2); FlxSpriteUtil.updateSpriteGraphic(_screenSprite); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle( { thickness:5, color:canDeleteSlot ? WHITE_RED : WHITE_BLUE } ); octagon(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 2); FlxSpriteUtil.updateSpriteGraphic(_screenSprite); } else { FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle( { thickness:3, color:canDeleteSlot ? LIGHT_RED : LIGHT_BLUE } ); octagon(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 2); FlxSpriteUtil.updateSpriteGraphic(_screenSprite); } if (!saveExists(i)) { continue; } var saveData:Dynamic = _saveDatas[i]; { var text:FlxText = new FlxText(rects[i].x + 5, rects[i].y, 0, saveData.name == null ? "???" : saveData.name.toUpperCase(), 20); if (text.textField.textWidth > rects[i].width + 28) { while (text.textField.textWidth > rects[i].width + 15) { text.text = text.text.substr(0, text.text.length - 1); } text.text += "..."; } text.font = AssetPaths.hardpixel__otf; text.color = canDeleteSlot ? WHITE_RED : WHITE_BLUE; _screenSprite.stamp(text, Std.int(text.x), Std.int(text.y)); } { var playerItemIndexes:Array<Int> = PlayerSave.def(saveData.playerItemIndexes, []); var abraStoryInt:Int = PlayerSave.def(saveData.abraStoryInt, 0); var progress:Float = playerItemIndexes.length; var availableProgress:Float = ItemDatabase._itemTypes.length; if (abraStoryInt >= 5) { progress += 5; } else if (abraStoryInt >= 3) { progress += 3; } else if (abraStoryInt >= 2) { progress += 2; } else if (abraStoryInt >= 1) { progress += 0.1; } availableProgress += 5; var percent:Float = FlxMath.bound(Math.round(1000 * progress / availableProgress) / 10, 0, 100); var text:FlxText = new FlxText(rects[i].x + 5, rects[i].y + 26, 190, percent + "%", 20); text.font = AssetPaths.hardpixel__otf; text.color = canDeleteSlot ? WHITE_RED : WHITE_BLUE; _screenSprite.stamp(text, Std.int(text.x), Std.int(text.y)); } { var moneyString:String = "$" + CashWindow.formatCash(saveData.cash); var text:FlxText = new FlxText(rects[i].x + 5, rects[i].y + 26, 190, moneyString, 20); text.font = AssetPaths.hardpixel__otf; text.alignment = FlxTextAlign.RIGHT; text.color = canDeleteSlot ? WHITE_RED : WHITE_BLUE; _screenSprite.stamp(text, Std.int(text.x), Std.int(text.y)); } { var timeString:String = ""; var timePlayed:Float = Math.max(0, saveData.timePlayed); // seconds timeString = Std.string(Std.int(timePlayed % 60)) + timeString; if (timeString.length < 2) { timeString = "0" + timeString; } timePlayed /= 60; // minutes timeString = Std.string(Std.int(timePlayed % 60)) + ":" + timeString; if (timeString.length < 5) { timeString = "0" + timeString; } timePlayed /= 60; // hours timeString = Std.string(Std.int(timePlayed)) + ":" + timeString; if (timeString.length < 8) { timeString = "0" + timeString; } if (timePlayed >= 1000) { timeString = "999:59:59"; } var text:FlxText = new FlxText(rects[i].x + 5, rects[i].y + 52, 190, timeString, 20); text.font = AssetPaths.hardpixel__otf; text.alignment = FlxTextAlign.LEFT; text.color = canDeleteSlot ? WHITE_RED : WHITE_BLUE; _screenSprite.stamp(text, Std.int(text.x), Std.int(text.y)); } { var rankHistory:Array<Int> = saveData.rankHistory; var rank:Int = 0; if (rankHistory != null) { rank = RankTracker.computeAggregateRank(rankHistory); }; var rankString:String = "RANK " + rank; var text:FlxText = new FlxText(rects[i].x + 5, rects[i].y + 52, 190, rankString, 20); text.font = AssetPaths.hardpixel__otf; text.alignment = FlxTextAlign.RIGHT; text.color = canDeleteSlot ? WHITE_RED : WHITE_BLUE; _screenSprite.stamp(text, Std.int(text.x), Std.int(text.y)); } } } override public function update(elapsed:Float):Void { super.update(elapsed); PlayerData.updateTimePlayed(); if (FlxG.mouse.justPressed) { PlayerData.updateCursorVisible(); } _handSprite.setPosition(FlxG.mouse.x - _handSprite.width / 2, FlxG.mouse.y - _handSprite.height / 2); if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(_soundButton)) { // clicked sound button if (FlxG.sound.volume == 0) { FlxG.sound.volume = 1.0; } else { FlxG.sound.volume = 0; } _soundButton.text = FlxG.sound.volume == 0 ? "SOUND: DISABLED" : "SOUND: ENABLED"; } if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(_profanityButton)) { // clicked profanity button PlayerData.profanity = !PlayerData.profanity; _profanityButton.text = PlayerData.profanity ? "PROFANITY: ENABLED" : "PROFANITY: DISABLED"; FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(_detailButton)) { // clicked detail button if (PlayerData.detailLevel == PlayerData.DetailLevel.Max) { PlayerData.detailLevel = PlayerData.DetailLevel.Low; } else if (PlayerData.detailLevel == PlayerData.DetailLevel.Low) { PlayerData.detailLevel = PlayerData.DetailLevel.VeryLow; } else { PlayerData.detailLevel = PlayerData.DetailLevel.Max; } updateDetailButtonText(); FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(_sfwButton)) { // clicked sfw button PlayerData.sfw = !PlayerData.sfw; _sfwButton.text = PlayerData.sfw ? "SFW MODE: SAFE" : "SFW MODE: PORN"; FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } if (FlxG.mouse.justPressed && _passwordButton.visible && FlxG.mouse.overlaps(_passwordButton)) { if (StringTools.endsWith(_passwordButton.text, ">")) { var rawPassword:String = Password.extractFromPlayerData(); var prettyPassword = rawPassword.substring(0, 6) + " " + rawPassword.substring(6, 12) + " " + rawPassword.substring(12, 18); _passwordButton.text = (PlayerData.name == null ? "???" : PlayerData.name.toUpperCase()) + ": " + prettyPassword; FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } else { /* * We force the user to click before showing their password, * just in case they're streaming and they don't want people * copying them */ _passwordButton.text = "<CLICK FOR PASSWORD>"; FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } } if (FlxG.mouse.justPressed && _mouseClickTime > 0) { var mouseRect:FlxRect = getMouseRect(); if (_deleteOn) { if (mouseRect != null && saveExists(rects.indexOf(mouseRect))) { if (_deleteSlot != rects.indexOf(mouseRect)) { // select item to delete _deleteSlot = rects.indexOf(mouseRect); FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } else if (_mouseClickTime > 0.3) { // delete! PlayerSave.deleteSave(rects.indexOf(mouseRect)); _saveDatas[rects.indexOf(mouseRect)] = null; _suppressBeep = true; _deleteButton.onDown.callback(); _suppressBeep = false; FlxSoundKludge.play(AssetPaths.delete_0014__mp3); paintScreenSprite(); // first row of particles emitParticles(mouseRect.x + 5, mouseRect.y + 5, 50, 15, 20); // second row of particles emitParticles(mouseRect.right - 95, mouseRect.y + 30, 85, 15, 20); emitParticles(mouseRect.x + 5, mouseRect.y + 30, 85, 15, 20); // third row of particles emitParticles(mouseRect.right - 95, mouseRect.y + 55, 85, 15, 20); emitParticles(mouseRect.x + 5, mouseRect.y + 55, 85, 15, 20); } } else { // unclick button _deleteButton.onDown.callback(); } } else { if (mouseRect != null) { // select save slot PlayerData.saveSlot = rects.indexOf(mouseRect); _passwordButton.visible = (PlayerData.saveSlot == _initialSaveSlot); paintScreenSprite(); FlxSoundKludge.play(AssetPaths.beep_0065__mp3); } } } _bigWhiteX.visible = false; _bigRedX.visible = false; if (_deleteOn && _deleteSlot < 0) { var mouseRect:FlxRect = getMouseRect(); if (mouseRect != null && saveExists(rects.indexOf(mouseRect))) { _bigWhiteX.x = mouseRect.x; _bigWhiteX.y = mouseRect.y; _bigWhiteX.visible = true; } } if (_deleteSlot >= 0) { _bigRedX.visible = true; _bigRedX.x = rects[_deleteSlot].x; _bigRedX.y = rects[_deleteSlot].y; } if (FlxG.mouse.justPressed) { _mouseClickTime = 0; } else { _mouseClickTime += elapsed; } } function emitParticles(x:Float, y:Float, w:Float, h:Float, particleCount:Int) { var itemY = y; var increment = Math.max(1, h / particleCount); while (itemY < y + h) { var newItem:FlxParticle = _explosionGroup.recycle(FlxParticle); newItem.reset(FlxG.random.float(x, x + w), itemY); newItem.alphaRange.set(1, 0.5); newItem.lifespan = FlxG.random.float(0.25, 0.75); var size:Int = FlxG.random.int(4, 8); newItem.makeGraphic(size, size); newItem.velocity.x = FlxG.random.sign() * (2400 / size); newItem.exists = true; itemY += increment; } } function getMouseRect():FlxRect { for (rect in rects) { if (rect.containsPoint(FlxG.mouse.getPosition())) { return rect; } } return null; } public static function octagon(x0:Float, y0:Float, x1:Float, y1:Float, miter:Float):Void { FlxSpriteUtil.flashGfx.moveTo(x0 + miter, y0 - miter); FlxSpriteUtil.flashGfx.lineTo(x1 - miter, y0 - miter); FlxSpriteUtil.flashGfx.lineTo(x1 + miter, y0 + miter); FlxSpriteUtil.flashGfx.lineTo(x1 + miter, y1 - miter); FlxSpriteUtil.flashGfx.lineTo(x1 - miter, y1 + miter); FlxSpriteUtil.flashGfx.lineTo(x0 + miter, y1 + miter); FlxSpriteUtil.flashGfx.lineTo(x0 - miter, y1 - miter); FlxSpriteUtil.flashGfx.lineTo(x0 - miter, y0 + miter); FlxSpriteUtil.flashGfx.lineTo(x0 + miter, y0 - miter); } override public function destroy():Void { super.destroy(); _screenSprite = FlxDestroyUtil.destroy(_screenSprite); _deleteButton = FlxDestroyUtil.destroy(_deleteButton); _backButton = FlxDestroyUtil.destroy(_backButton); _soundButton = FlxDestroyUtil.destroy(_soundButton); _passwordButton = FlxDestroyUtil.destroy(_passwordButton); _bigWhiteX = FlxDestroyUtil.destroy(_bigWhiteX); _bigRedX = FlxDestroyUtil.destroy(_bigRedX); _explosionGroup = FlxDestroyUtil.destroy(_explosionGroup); _saveDatas = null; rects = null; } }
argonvile/monster
source/OptionsMenuState.hx
hx
unknown
20,570
package; import flixel.FlxBasic; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.math.FlxAngle; import flixel.math.FlxMatrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import openfl.display.BitmapData; import openfl.display.BlendMode; import openfl.geom.Matrix; import openfl.geom.Point; import openfl.geom.Rectangle; /** * Utility class for swapping buffers and stamping pixels. */ class PixelFilterUtils { private static var index:Int = 0; private static var _matrix:FlxMatrix = new FlxMatrix(); private static var _flashPoint:Point; private static var _flashRect:Rectangle; private static var _flashRect2:Rectangle; public static function swapCameraBuffer(buffer:FlxSprite):Void { var tmpBuffer:BitmapData = FlxG.camera.buffer; FlxG.camera.buffer = buffer.graphic.bitmap; buffer.graphic.bitmap = tmpBuffer; } public static function drawToBuffer(buffer:FlxSprite, group:FlxTypedGroup<Dynamic>) { var i:Int = 0; var item:FlxBasic; var spriteItem:FlxSprite; var groupItem:FlxTypedGroup<FlxBasic>; while (i < group.length) { item = group.members[i++]; if (item != null && item.exists && item.visible) { if (Std.isOfType(item, FlxSprite)) { spriteItem = cast item; fastStampToBuffer(buffer, spriteItem); } else if (Std.isOfType(item, FlxTypedGroup)) { groupItem = cast item; drawToBuffer(buffer, groupItem); } } } } /** * Stamps to a buffer, but does not invoke calcFrame(). CalcFrame() is a * performance hog and we might be stamping 300+ sprites per frame */ public static function fastStampToBuffer(buffer:FlxSprite, brush:FlxSprite) { var x:Int = Std.int(brush.x - brush.offset.x); var y:Int = Std.int(brush.y - brush.offset.y); brush.drawFrame(); if (buffer.graphic == null || brush.graphic == null) throw "Cannot stamp to or from a FlxSprite with no graphics."; var bitmapData:BitmapData = brush.framePixels; if (buffer.isSimpleRenderBlit()) // simple render { _flashPoint.x = x + buffer.frame.frame.x; _flashPoint.y = y + buffer.frame.frame.y; _flashRect2.width = bitmapData.width; _flashRect2.height = bitmapData.height; buffer.graphic.bitmap.copyPixels(bitmapData, _flashRect2, _flashPoint, null, null, true); _flashRect2.width = buffer.graphic.bitmap.width; _flashRect2.height = buffer.graphic.bitmap.height; } else // complex render { _matrix.identity(); _matrix.translate(-brush.origin.x, -brush.origin.y); _matrix.scale(brush.scale.x, brush.scale.y); if (brush.angle != 0) { _matrix.rotate(brush.angle * FlxAngle.TO_RAD); } _matrix.translate(x + buffer.frame.frame.x + brush.origin.x, y + buffer.frame.frame.y + brush.origin.y); var brushBlend:BlendMode = brush.blend; buffer.graphic.bitmap.draw(bitmapData, _matrix, null, brushBlend, null, brush.antialiasing); } // toggle dirty flag, but do not invoke calcFrame... buffer.dirty = true; } }
argonvile/monster
source/PixelFilterUtils.hx
hx
unknown
3,104
package; import flixel.FlxG; import flixel.math.FlxMath; import minigame.scale.ScaleGameState; import minigame.stair.StairGameState; import minigame.tug.TugGameState; /** * Stores all data related to the player's session. This includes permanent * data like which conversations they've had and how much money they have, * but also transient data like how long it's been since they last touched * the mouse */ class PlayerData { public static inline var CHATLENGTH = 2; public static var PROF_PREFIXES = ["abra", "buiz", "hera", "grov", "sand", "rhyd", "smea", "kecl", "magn", "grim", "luca"]; public static var PROF_NAMES = ["Abra", "Buizel", "Heracross", "Grovyle", "Sandslash", "Rhydon", "Smeargle", "Kecleon", "Magnezone", "Grimer", "Lucario"]; public static var MINIGAME_CLASSES:Array<Class<Dynamic>> = [ScaleGameState, StairGameState, TugGameState]; public static var DEN_SEX_RESILIENCE:Array<Float> = [ 1.60, // abra 1.40, // buiz 3.00, // hera 1.90, // grov 8.00, // sand 3.40, // rhyd 1.30, // smea 2.60, // kecl 3.60, // magn 1.80, // grim 4.00, // luca ]; public static var PROF_DIALOG_CLASS:Array<String> = ["poke.abra.AbraDialog", "poke.buiz.BuizelDialog", "poke.hera.HeraDialog", "poke.grov.GrovyleDialog", "poke.sand.SandslashDialog", "poke.rhyd.RhydonDialog", "poke.smea.SmeargleDialog", null, "poke.magn.MagnDialog", "poke.grim.GrimerDialog", "poke.luca.LucarioDialog"]; public static var MINIGAME_DESCRIPTIONS:Array<String> = ["that bug balancing game", "that stair climbing game", "that tug-of-war game"]; public static var DEN_MINIGAME_NERF = 0.20; // den minigames are only worth a fraction of the usual amount public static var DEN_MAX_REWARD = 600; /* * -1: No save slot; needs to be initialized * 0, 1, 2: Save slot #0, #1, #2 */ public static var saveSlot:Int = -1; public static var recentPuzzleIndexes:Array<Int> = []; // most recent 50 puzzles; we don't want back-to-back identical puzzles public static var difficulty:Difficulty = Easy; public static var rewardTime:Float = 0; // after a minute of time, we reward the player in different ways public static var justFinishedMinigame:Bool = false; // some dialog changes subtly if the player just finished a minigame public static var level:Int = 0; public static var cash:Int; public static var timePlayed:Float = 0; public static var pokeVideos:Array<PokeVideo> = []; public static var videoStatus:VideoStatus = Empty; // Do the videos have poke-orgasms, are they clean, or absent? public static var videoCount:Int = 0; // How many videos has the player recorded, ever? public static var startedTaping:Bool = false; public static var startedMagnezone:Bool = false; public static var magnButtPlug:Int = 0; // Which phase we're in in the "butt plug" chat sequence public static var sandPhone:Int = 0; // Which phase we're in in the "sandslash phone" chat sequence public static var keclStoreChat:Int = 0; // Which phase we're in in the "kecleon store" chat sequence public static var rhydonCameraUp:Bool = false; public static var profIndex:Int = -1; // Which Pokemon is the player playing with? 0=abra, 1=buizel, etc... /* * Bugs will bring you presents as you play. Those presents get appended to * this array, sort of like tossing coins in a bag. Periodically those * coins are popped out of the bag and given to the player when they're * stuck on a puzzle. */ public static var critterBonus:Array<Int> = []; public static var reservoirReward:Int = 0; public static var minigameReward:Int = 0; public static var luckyProfReward:Int = 0; public static var minigameQueue:Array<Int> = []; public static var scaleGamePuzzleDifficulty:Float = 0.35; // The difficulty of the scale game puzzles. They range from easy 3-bug puzzles to hard 6-bug puzzles /* * The difficulty of the scale game opponents. Abra is always abra, but * they won't show up unless you keep winning. Even if you're solving * puzzles with Abra and this minigame comes up, Abra will offer to let you * play a different opponent */ public static var scaleGameOpponentDifficulty:Float = 0.35; public static var denMinigame:Int = -1; public static var denVisitCount:Int = 0; public static var nextDenProf:Int = -1; // after this set of puzzles, is there a pokemon which will randomly show up in the den? (transient value; not saved) public static var denProf:Int = -1; // which pokemon is currently in the den? (transient value; not saved) public static var denCost:Int = 120; // transient value; not saved public static var denSpoogeCount:Int = 0; // transient value; not saved public static var denGameCount:Int = 0; // transient value; not saved public static var denSexCount:Int = 0; // transient value; not saved public static var denTotalReward:Float = 0; // transient value; not saved public static var playerIsInDen:Bool = false; // transient value; not saved /** * Male: he/him, boy, penis, etc... * Female: she/her, girl, vagina, etc... * Complicated: they/theirs, someone, genitals, etc... */ public static var gender:Gender; public static var sexualPreference:SexualPreference; public static var sexualPreferenceLabel:SexualPreferenceLabel; public static var preliminaryName:String; // you can tell Grovyle a name before he asks for your name, and he might reference this later public static var name:String; public static var cursorType:String; public static var cursorFillColor:Int; // internal color public static var cursorLineColor:Int; // outline color public static var cursorMaxAlpha:Float; public static var cursorMinAlpha:Float; public static var cursorInsulated:Bool; public static var cursorSmellTimeRemaining:Float; // number of milliseconds remaining until cursor doesn't smell anymore public static var chatHistory:Array<String>; public static var chatHistoryTmp:Array<String>; public static var abraSexyRecords:Array<Float>; public static var abra7PegChats:Array<Int>; public static var abraChats:Array<Int>; public static var abra7PegSexyBeforeChat:Int; public static var abraSexyBeforeChat:Int; public static var abraSexyAfterChat:Int; public static var abraMale:Bool; public static inline var abraDefaultMale:Bool = false; public static var abraReservoir:Int; // A reservoir of 0-210 libido points, which goes towards giving +30/+90/+210 boosts to the sexy minigames public static var abraToyReservoir:Int; // A reservoir of 0-180 libido points, which goes towards giving +60/+120/+180 boosts to the toy minigames public static var abraBeadCapacity:Int; public static var abraMainScreenTeleport:Bool = false; // Has Abra teleported onto the main screen and made noise? /* * 0: hasn't started * 1: has said "here's what to do next" * 2: has said "you're on your way" * 3: progressing down "swap path" * 4: progressing down "don't swap path" * 5: game over; swapped * 6: game over; didn't swap */ public static var abraStoryInt:Int = 0; public static var finalTrial:Bool = false; // is the player currently attempting to swap? public static var finalRankHistory:Array<Int> = []; // ranks for final swap attempt public static var buizSexyRecords:Array<Float>; public static var buizChats:Array<Int>; public static var buizSexyBeforeChat: Dynamic; public static var buizSexyAfterChat: Dynamic; public static var buizMale:Bool; public static inline var buizDefaultMale:Bool = false; public static var buizReservoir:Int; public static var buizToyReservoir:Int; public static var grovSexyRecords:Array<Float>; public static var grovChats:Array<Int>; public static var grovSexyBeforeChat: Dynamic; public static var grovSexyAfterChat: Dynamic; public static var grovMale:Bool; public static inline var grovDefaultMale:Bool = false; public static var grovReservoir:Int; public static var grovToyReservoir:Int; public static var sandSexyRecords:Array<Float>; public static var sandChats:Array<Int>; public static var sandSexyBeforeChat: Dynamic; public static var sandSexyAfterChat: Dynamic; public static var sandMale:Bool; public static inline var sandDefaultMale:Bool = true; public static var sandReservoir:Int; public static var sandToyReservoir:Int; public static var rhydSexyRecords:Array<Float>; public static var rhydChats:Array<Int>; public static var rhydSexyBeforeChat: Dynamic; public static var rhydSexyAfterChat: Dynamic; public static var rhydMale:Bool; public static inline var rhydDefaultMale:Bool = true; public static var rhydReservoir:Int; public static var rhydToyReservoir:Int; public static var rhydGift:Int; // 0: hasn't purchased gift; 1: gift has been purchased; 2: gift has been received public static var smeaSexyRecords:Array<Float>; public static var smeaChats:Array<Int>; public static var smeaSexyBeforeChat: Dynamic; public static var smeaSexyAfterChat: Dynamic; public static var smeaMale:Bool; public static inline var smeaDefaultMale:Bool = true; public static var smeaReservoir:Int; public static var smeaToyReservoir:Int; public static var smeaReservoirBank:Int; public static var smeaToyReservoirBank:Int; public static var keclMale:Bool; public static inline var keclDefaultMale:Bool = true; public static var keclGift:Int; // 0: hasn't purchased gift; 1: gift has been purchased; 2: gift has been received public static var magnSexyRecords:Array<Float>; public static var magnChats:Array<Int>; public static var magnSexyBeforeChat: Dynamic; public static var magnSexyAfterChat: Dynamic; public static var magnMale:Bool; public static inline var magnDefaultMale:Bool = false; public static var magnReservoir:Int; public static var magnToyReservoir:Int; public static var magnGift:Int; // 0: hasn't purchased gift; 1: gift has been purchased; 2: gift has been received public static var grimSexyRecords:Array<Float>; public static var grimChats:Array<Int>; public static var grimSexyBeforeChat: Dynamic; public static var grimSexyAfterChat: Dynamic; public static var grimMale:Bool; public static inline var grimDefaultMale:Bool = false; public static var grimReservoir:Int; public static var grimToyReservoir:Int; public static var grimTouched:Bool = false; // has the player touched grimer? /* * It's understood that the player undergoes a linear progression of the * game -- meeting more and more pokemon, buying up the store's items, then * buying up some mystery boxes. * * Losing items would have bad implications for save files (passwords * specifically) because we might need to store the state where a player * has bought all the items, and bought 6 mystery boxes, but then had two * of their items eaten -- so their inventory technically isn't full. * * To prevent this, we don't actually remove grimer's eaten items from the * player's inventory -- we just store their eaten item in this * "grimEatenItem" variable. If a player saves and loads their game with a * password after feeding grimer, they'll get their item back. This is * better than the implications of needing to store an extra 3-4 bits of * item information just for some crazy edge case. */ public static var grimEatenItem:Int = -1; // which item did grimer eat? public static var grimMoneyOwed:Int = 0; // grimer ate something expensive; he needs to pay the player public static var heraSexyRecords:Array<Float>; public static var heraChats:Array<Int>; public static var heraSexyBeforeChat: Dynamic; public static var heraSexyAfterChat: Dynamic; public static var heraMale:Bool; public static inline var heraDefaultMale:Bool = true; public static var heraReservoir:Int; public static var heraToyReservoir:Int; public static var lucaSexyRecords:Array<Float>; public static var lucaChats:Array<Int>; public static var lucaSexyBeforeChat: Dynamic; public static var lucaSexyAfterChat: Dynamic; public static var lucaMale:Bool; public static inline var lucaDefaultMale:Bool = false; public static var lucaReservoir:Int; public static var lucaToyReservoir:Int; public static var professors:Array<Int>; public static var prevProfPrefix:String; public static var rankHistory:Array<Int> = []; public static var rankHistoryLog:Array<String>; // a human-readable rank history, for debug purposes public static var puzzleCount:Array<Int>; public static var minigameCount:Array<Int>; public static var luckyProfSchedules:Array<Int> = []; public static var clickDate:Date; public static var rankChance:Bool; // has the player had a "rank chance" event before? public static var rankDefend:Bool; // has the player had a "rank defend" event before? public static var pokemonLibido:Int = 4; // [1-7] public static var pegActivity:Int = 4; // [1-7] public static var promptSilverKey:Prompt = Prompt.AlwaysNo; public static var promptGoldKey:Prompt = Prompt.AlwaysNo; public static var promptDiamondKey:Prompt = Prompt.AlwaysNo; public static var disabledPegColors:Array<String> = []; public static var cheatsEnabled:Bool = false; public static var profanity:Bool = true; /** * If the detail level is lowered, the game tries to conserve memory by * spawning fewer sprites and purging the image cache more frequently */ public static var detailLevel:DetailLevel = DetailLevel.Max; public static var sfw:Bool = false; public static function isPlayerDoingStuff():Bool { return clickDate != null && (clickDate.getTime() > MmTools.time() - 180 * 1000); } public static function updateCursorVisible() { /* * reinitialize the system cursor; right-clicking in WaterFox makes * the cursor visible, but we want it to stay invisible */ CursorUtils.initializeSystemCursor(); } /** * As the player plays the game, they're given money in a bunch of ways. * * For every 60 minutes they play, they should get... * 1. About $1,200 in random reward chests which bugs bring during puzzles * 2. About $1,000 from Heracross, for selling porn videos * 3. About $3,600 from solving puzzles, if they're average at them * 4. About $1,200 from minigames * * In total this works out to about $6,000/hr, although it depends on how * skilled they are at the different facets of the game. There's no real * ceiling, and I imagine people could earn $12,000 if they were good at * puzzles and minigames, or $50,000 if they just cheated and used a * solver. * * There is a bare minimum of about $2,000/hr no matter how bad you are, * which is important. You're given money for losing minigames, and you're * given some money even if you're bad at the sex parts. You're given money * for losing minigames. All in all it's not a lot, but it guarantees * people will eventually beat the game even if they're absolutely awful at * it. */ public static function updateTimePlayed() { if (FlxG.mouse.justPressed) { // if someone's AFK for an hour, or skips their clock ahead, we only count 3 minutes of that hour var oldTimePlayed = timePlayed; var amount:Float = FlxMath.bound((MmTools.time() - clickDate.getTime()) / 1000, 0, 180); timePlayed += amount; rewardTime += amount; clickDate = Date.now(); } if (rewardTime > 60) { var skipReservoirRewardChance:Null<Float> = [1 => 0.80, 2 => 0.75, 3 => 0.45][pokemonLibido]; if (skipReservoirRewardChance == null) skipReservoirRewardChance = 0; var skipCritterBonusChance:Null<Float> = [7 => 0.70, 6 => 0.50, 5 => 0.30][pokemonLibido]; if (skipCritterBonusChance == null) skipCritterBonusChance = 0; while (rewardTime > 60) { rewardTime -= 60; if (FlxG.random.bool(skipCritterBonusChance)) { // skip; critter bonus is applied to reservoir reservoirReward += 20; } else { appendCritterBonus(FlxG.random.getObject([5, 10, 20, 50], [.2, .3, .3, .2])); // average 20 per minute } if (FlxG.random.bool(skipReservoirRewardChance)) { // skip; reservoir reward is applied to critter appendCritterBonus(10); } else { // average 10 per minute... but, this is multiplied if they're good at sexy minigames, so really 20 reservoirReward += 10; } minigameReward += 20; luckyProfReward += 1; cursorSmellTimeRemaining = Math.max(cursorSmellTimeRemaining - 60, 0); } } } /** * Add more money to the random chests which appear during the puzzles. * * @param amount amount of money to add */ private static function appendCritterBonus(amount:Int) { if (critterBonus.length < 50) { critterBonus.push(amount); } else { // critter bonus is getting too long; just increment an existing entry critterBonus[FlxG.random.int(0, critterBonus.length - 1)] += amount; } } public static function siphonCritterBonus(percent:Float):Int { var targetLength:Int = Std.int(critterBonus.length * percent); var bonus:Int = 0; while (critterBonus.length > targetLength) { bonus += critterBonus.pop(); } return bonus; } public static function siphonReservoirReward(percent:Float):Int { var amount:Int = Std.int(reservoirReward * percent / 5) * 5; reservoirReward -= amount; return amount; } /** * Adds another entry to the chatHistoryTmp, which might be stored or discarded later */ public static function appendChatHistory(str:String) { if (chatHistoryTmp == null) { chatHistoryTmp = []; } chatHistoryTmp.push(str); } /** * Adds an entry to the chatHistory immediately, replacing any entries already there */ public static function quickAppendChatHistory(str:String, unique:Bool = true):Void { if (unique) { if (chatHistory.indexOf(str) != -1) { chatHistory.remove(str); } } chatHistory.push(str); chatHistory.splice(0, chatHistory.length - 2000); } /** * Discards the built-up chatHistoryTmp */ public static function discardChatHistory() { chatHistoryTmp = null; } /** * Appends the built-up chatHistoryTmp to the permanent chatHistory */ public static function storeChatHistory() { chatHistory = chatHistory.concat(chatHistoryTmp); chatHistory.splice(0, chatHistory.length - 2000); chatHistoryTmp = null; } public static function recentChatTime(string:String):Int { var index:Int = chatHistory.lastIndexOf(string); if (index == -1) { return 10000; } else { return chatHistory.length - index + 1; } } /** * Adds money to the amount the player receives in periodic random chests. * ...This is a good way to indirectly compensate them for things which * would otherwise drain money from people who are just having fun. * * @param reward The amount of money to add into chests */ public static function reimburseCritterBonus(reward:Int) { while (reward > 60) { appendCritterBonus(50); reward -= 50; } while (reward > 30) { appendCritterBonus(20); reward -= 20; } while (reward > 15) { appendCritterBonus(10); reward -= 10; } while (reward > 2) { appendCritterBonus(5); reward -= 5; } } public static function addPokeVideo(video:PokeVideo):Void { videoCount++; pokeVideos.push(video); pokeVideos.splice(0, pokeVideos.length - 100); } public static function getPokeVideoReward():Int { var total:Float = 0; for (video in pokeVideos) { total += video.reward; } return Math.round(total / 5) * 5; } public static function payVideos():Void { cash += getPokeVideoReward(); pokeVideos.splice(0, pokeVideos.length); videoStatus = VideoStatus.Empty; } public static function getDifficultyInt() { switch (difficulty) { case Easy: return 0; case _3Peg: return 1; case _4Peg: return 2; case _5Peg: return 3; case _7Peg: return 4; default: return 0; } } public static function setSexualPreference(pref:SexualPreference) { sexualPreference = pref; for (prefix in PROF_PREFIXES) { var male:Bool; if (pref == SexualPreference.Boys) { male = true; } else if (pref == SexualPreference.Girls) { male = false; } else { male = Reflect.field(PlayerData, prefix + "DefaultMale"); } Reflect.setField(PlayerData, prefix + "Male", male); } } public static function recentChatCount(chatItem:String) { return chatHistory.filter(function(s) { return s == chatItem; } ).length; } /** * Returns true if the player has already bumped into a specific Pokemon. * This avoids a scenario where a player's never played before, and Buizel * just randomly stops by in an anticlimactic way. Those random "bump ins" * will only happen if the player's met that Pokemon before. * * @param prefix pokemon prefix, "smea" or "hera" for example * @return true if the player has seen the Pokemon before */ public static function hasMet(prefix:String):Bool { if (prefix == "grov" || prefix == "abra") { // we see grovyle/abra during the intro... return true; } if (prefix == PROF_PREFIXES[profIndex]) { // we're currently playing with them -- this is an important loophole for minigames. // minigames exclude pokemon you haven't "met", so if you play with someone for the // first time and have a minigame, it's important that they're flagged as "met" return true; } if (prefix == "kecl") { return hasMet("smea"); } for (chatHistoryItem in chatHistory) { if (chatHistoryItem != null && StringTools.startsWith(chatHistoryItem, prefix)) { return true; } } return false; } public static function fivePegUnlocked() { return puzzleCount[2] >= 3; } /** * Seven-peg puzzles are only accessible if you go through the joke 5-peg * tutorial. Or, if you've solved one before. */ public static function sevenPegUnlocked() { return puzzleCount[4] >= 1 || (puzzleCount[3] >= 3 && recentChatTime("tutorial.3.2") < 800); } public static function getTotalPuzzlesSolved() { var totalPuzzlesSolved:Int = 0; for (p in PlayerData.puzzleCount) { totalPuzzlesSolved += p; } return totalPuzzlesSolved; } /** * After a successful sync, Abra has a few specific conversations with you * next time you play. */ public static function successfulSync() { abraChats = [6]; abraSexyRecords = [99999, 99999]; abraSexyBeforeChat = 8; abraSexyAfterChat = 99; if (abraStoryInt == 3 || abraStoryInt == 4) { abraStoryInt += 2; } removeFromChatHistory("abra.randomChats.2.3"); // reset birthday chat } public static function isAbraNice():Bool { return abraStoryInt == 5 || abraStoryInt == 6; } public static function removeFromChatHistory(str) { var i = PlayerData.chatHistory.length - 1; while (i >= 0) { if (PlayerData.chatHistory[i] == str) { PlayerData.chatHistory.splice(i, 1); } i--; } } } enum Difficulty { Easy; _3Peg; _4Peg; _5Peg; _7Peg; } enum Gender { Boy; Girl; Complicated; } enum SexualPreference { Boys; // likes boys Girls; // likes girls Both; // likes both Idiot; // the player just wants to be obnoxious and difficult } enum SexualPreferenceLabel { Gay; Straight; Lesbian; Bisexual; Complicated; } typedef PokeVideo = { name:String, reward:Float, male:Bool } enum VideoStatus { Empty; Clean; Dirty; } enum Prompt { AlwaysYes; AlwaysNo; Ask; } enum DetailLevel { Max; Low; VeryLow; }
argonvile/monster
source/PlayerData.hx
hx
unknown
23,998
package; import flixel.FlxG; /** * Makes adjustments to fix a player's save data. * * There are certain rules about how often Pokemon show up, which items are for * sale in Heracross's shop, and how horny different Pokemon are. Some of those * rules might get broken briefly if a player purchases a sex toy or an item * which makes a Pokemon show up more often. It could also happen if their save * data gets messed up because of a glitch in the program, or because they * hacked their save file. * * This class fixes the player's save data so the rules apply again. */ class PlayerDataNormalizer { /** * If the player hasn't purchased any toys for a particular Pokemon, that * Pokemon's toy reservoir should be -1. Otherwise, it should be >= 0. */ public static function normalizeToyReservoirs() { if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_SMALL_GREY_BEADS) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_SMALL_PURPLE_BEADS)) { if (PlayerData.abraToyReservoir == -1) { PlayerData.abraToyReservoir = 178; // [61-179] } } else { PlayerData.abraToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_BLUE_DILDO) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_GUMMY_DILDO)) { if (PlayerData.buizToyReservoir == -1) { PlayerData.buizToyReservoir = 156; // [61, 179] } } else { PlayerData.buizToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_VIBRATOR)) { if (PlayerData.heraToyReservoir == -1) { PlayerData.heraToyReservoir = 153; // [61, 179] } } else { PlayerData.heraToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_VIBRATOR)) { if (PlayerData.grovToyReservoir == -1) { PlayerData.grovToyReservoir = 143; // [61-179] } } else { PlayerData.grovToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_HUGE_DILDO)) { if (PlayerData.sandToyReservoir == -1) { PlayerData.sandToyReservoir = 159; // [61-179] } } else { PlayerData.sandToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_LARGE_GLASS_BEADS) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_LARGE_GREY_BEADS)) { if (PlayerData.rhydToyReservoir == -1) { PlayerData.rhydToyReservoir = 149; // [61-179] } } else { PlayerData.rhydToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_VIBRATOR)) { if (PlayerData.smeaToyReservoir == -1) { PlayerData.smeaToyReservoir = 52; // [0-60] } } else { PlayerData.smeaToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_SMALL_PURPLE_BEADS)) { if (PlayerData.magnToyReservoir == -1) { PlayerData.magnToyReservoir = 131; // [61-179] } } else { PlayerData.magnToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_BLUE_DILDO) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_GUMMY_DILDO)) { if (PlayerData.grimToyReservoir == -1) { PlayerData.grimToyReservoir = 115; // [61-179] } } else { PlayerData.grimToyReservoir = -1; } if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_BLUE_DILDO) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_GUMMY_DILDO) || ItemDatabase.playerHasItem(ItemDatabase.ITEM_HUGE_DILDO)) { PlayerData.lucaToyReservoir = 155; // [61-179] } else { PlayerData.lucaToyReservoir = -1; } } /** * Should have 10 * luckyProfCount total entries in the array * * Should have 1 entry for each prof (or 3 if phone number is unlocked) */ public static function normalizeLuckyProfSchedules() { if (PlayerData.luckyProfSchedules.length == 0) { PlayerData.luckyProfSchedules.push( -1); } var actualCounts:Map<Int, Int> = new Map<Int, Int>(); for (luckyProf in PlayerData.luckyProfSchedules) { if (!actualCounts.exists(luckyProf)) { actualCounts[luckyProf] = 0; } actualCounts[luckyProf] = actualCounts[luckyProf] + 1; } /** * while there's a lot of -1s in the array, -1s always get dropped at the end, while * "jackpots" get inserted somewhere in the back half. * * default: x x x x x x x x x x 8 (every 38 minutes, you see a lucky professor) * items: x x 8 x x x 8 x x x 8 x x (every 13 minutes, you see a lucky professor) */ var expectedCounts:Map<Int, Int> = new Map<Int, Int>(); expectedCounts[-1] = 0; expectedCounts[PlayerData.PROF_PREFIXES.indexOf("magn")] = ItemDatabase.playerHasItem(ItemDatabase.ITEM_MAGNETIC_DESK_TOY) ? 3 : 1; expectedCounts[-1] += 10; expectedCounts[PlayerData.PROF_PREFIXES.indexOf("hera")] = ItemDatabase.playerHasItem(ItemDatabase.ITEM_RETROPIE) ? 3 : 1; expectedCounts[-1] += 10; expectedCounts[PlayerData.PROF_PREFIXES.indexOf("grim")] = ItemDatabase.playerHasItem(ItemDatabase.ITEM_HAPPY_MEAL) ? 3 : 1; expectedCounts[-1] += 10; expectedCounts[PlayerData.PROF_PREFIXES.indexOf("luca")] = ItemDatabase.playerHasItem(ItemDatabase.ITEM_PIZZA_COUPONS) ? 3 : 1; expectedCounts[-1] += 10; for (key in expectedCounts.keys()) { var expectedCount:Int = expectedCounts[key]; var actualCount:Int = actualCounts[key]; while (actualCount < expectedCount) { var index:Int = FlxG.random.int(1, PlayerData.luckyProfSchedules.length); PlayerData.luckyProfSchedules.insert(index, key); actualCount++; } while (actualCount > expectedCount) { var startIndex:Int = FlxG.random.int(1, PlayerData.luckyProfSchedules.length); var index:Int = PlayerData.luckyProfSchedules.indexOf(key, startIndex); if (index == -1) { index = PlayerData.luckyProfSchedules.indexOf(key); } if (index == -1) { // item not found, or maybe it's in index 0; don't worry about it this time } else { PlayerData.luckyProfSchedules.splice(index, 1); actualCount--; } } } } /** * All items should be present in warehouse, inventory, or shop. Items * should always have an index within the bounds of "itemTypes" array. * * This will get broken as new items unlock, and need to be added to the * warehouse. * * This could also get broken if someone loaded a new version of the game * with different items, or if their save was corrupted somehow. */ public static function normalizeItems() { // initialize kecleon dialog BadItemDescriptions.initialize(); var startString:String = "warehouse=" + ItemDatabase._warehouseItemIndexes + " player=" + ItemDatabase._playerItemIndexes + " shop=" + ItemDatabase._shopItems; // remove duplicate item indexes from player inventory { var newPlayerItemIndexes = []; for (playerItemIndex in ItemDatabase._playerItemIndexes) { if (newPlayerItemIndexes.indexOf(playerItemIndex) == -1) { newPlayerItemIndexes.push(playerItemIndex); } } ItemDatabase._playerItemIndexes = newPlayerItemIndexes; } // remove bogus item indexes ItemDatabase._warehouseItemIndexes = ItemDatabase._warehouseItemIndexes.filter(function(i) return i >= 0 && i < ItemDatabase._itemTypes.length && !ItemDatabase.isLocked(i)); ItemDatabase._playerItemIndexes = ItemDatabase._playerItemIndexes.filter(function(i) return i >= 0 && i < ItemDatabase._itemTypes.length); ItemDatabase._shopItems = ItemDatabase._shopItems.filter(function(shopItem) return shopItem._itemIndex < 0 || shopItem._itemIndex < ItemDatabase._itemTypes.length && !ItemDatabase.isLocked(shopItem._itemIndex)); // add missing item indexes var missingItemIndexes:Array<Int> = ItemDatabase.getAllItemIndexes(); // locked items aren't "missing"... they're not a mistake we need to fix missingItemIndexes = missingItemIndexes.filter(function(s) {return ItemDatabase.isLocked(s) != true; }); for (i in ItemDatabase._playerItemIndexes) { if (PlayerData.grimEatenItem == i) { // if grimer ate an item, it counts as missing and should appear in the warehouse } else { missingItemIndexes.remove(i); } } for (i in ItemDatabase._warehouseItemIndexes) missingItemIndexes.remove(i); for (shopItem in ItemDatabase._shopItems) missingItemIndexes.remove(shopItem._itemIndex); for (missingItemIndex in missingItemIndexes) { ItemDatabase._warehouseItemIndexes.insert(FlxG.random.int(0, ItemDatabase._warehouseItemIndexes.length), missingItemIndex); } var endString:String = "warehouse=" + ItemDatabase._warehouseItemIndexes + " player=" + ItemDatabase._playerItemIndexes + " shop=" + ItemDatabase._shopItems; if (endString != startString) { trace("item database normalized:"); trace(startString); trace(" -->"); trace(endString); } } }
argonvile/monster
source/PlayerDataNormalizer.hx
hx
unknown
8,968
package; import flixel.FlxG; import flixel.util.FlxSave; import openfl.utils.Object; /** * Permanently stores all data for a save slot, including data like * conversations the player's had and how much money they have */ class PlayerSave { public static var SAVE_FILENAME:String = "MonsterMindSaveSlot"; public static var SAVE_PATH:String = "/"; public static function nukeData():Void { var save:FlxSave = new FlxSave(); save.bind(SAVE_FILENAME, SAVE_PATH); save.erase(); for (i in 0...3) { deleteSave(i); } PlayerData.saveSlot = -1; } public static function deleteSave(slotIndex:Int):Void { var save:FlxSave = new FlxSave(); save.bind(SAVE_FILENAME + slotIndex, SAVE_PATH); save.erase(); } /** * If the save data hasn't yet been initialized, this quickloads. * * If no save data is yet available, it also initializes the first quicksave slot. * * Otherwise, it quicksaves. */ public static function flush():Void { if (PlayerData.saveSlot != -1) { // quicksave quickSave(); return; } var saveSlotSave:FlxSave = new FlxSave(); saveSlotSave.bind(SAVE_FILENAME, SAVE_PATH); if (saveSlotSave.data.slot == null) { // initialize save slot #0 saveSlotSave.data.slot = 0; saveSlotSave.data.volume = 1.0; saveSlotSave.flush(); } // load from save slot PlayerData.saveSlot = def(saveSlotSave.data.slot, 0); FlxG.sound.volume = def(saveSlotSave.data.volume, 1.0); PlayerData.profanity = def(saveSlotSave.data.profanity, true); PlayerData.detailLevel = defEnum(PlayerData.DetailLevel, saveSlotSave.data.detailLevel, PlayerData.DetailLevel.Max); PlayerData.sfw = def(saveSlotSave.data.sfw, false); quickLoad(); } public static function clearTransientData():Void { PlayerData.denProf = -1; PlayerData.finalTrial = false; } public static function setSaveSlot(slot:Int = -1):Void { if (slot != -1) { PlayerData.saveSlot = slot; } var saveSlotSave:FlxSave = new FlxSave(); saveSlotSave.bind(SAVE_FILENAME, SAVE_PATH); if (saveSlotSave.data.slot != PlayerData.saveSlot) { // changing save slots; clear transient data clearTransientData(); } saveSlotSave.data.slot = PlayerData.saveSlot; saveSlotSave.data.volume = FlxG.sound.volume; saveSlotSave.data.profanity = PlayerData.profanity; saveSlotSave.data.detailLevel = PlayerData.detailLevel; saveSlotSave.data.sfw = PlayerData.sfw; saveSlotSave.flush(); quickLoad(); } public static function getSave(slot:Int = -1):FlxSave { var save:FlxSave = new FlxSave(); save.bind(SAVE_FILENAME + (slot == -1 ? PlayerData.saveSlot : slot), SAVE_PATH); return save; } public static function getSaveData(slot:Int = -1):Dynamic { return getSave(slot).data; } static private function quickSave() { var save:FlxSave = getSave(); var saveData:Dynamic = save.data; saveData.cash = PlayerData.cash; saveData.timePlayed = PlayerData.timePlayed; saveData.critterBonus = PlayerData.critterBonus; saveData.pokeVideos = PlayerData.pokeVideos; saveData.videoCount = PlayerData.videoCount; saveData.videoStatus = PlayerData.videoStatus; saveData.startedTaping = PlayerData.startedTaping; saveData.startedMagnezone = PlayerData.startedMagnezone; saveData.magnButtPlug = PlayerData.magnButtPlug; saveData.sandPhone = PlayerData.sandPhone; saveData.keclStoreChat = PlayerData.keclStoreChat; saveData.reservoirReward = PlayerData.reservoirReward; saveData.minigameReward = PlayerData.minigameReward; saveData.luckyProfReward = PlayerData.luckyProfReward; saveData.minigameQueue = PlayerData.minigameQueue; saveData.scaleGamePuzzleDifficulty = PlayerData.scaleGamePuzzleDifficulty; saveData.scaleGameOpponentDifficulty = PlayerData.scaleGameOpponentDifficulty; saveData.denMinigame = PlayerData.denMinigame; saveData.denVisitCount = PlayerData.denVisitCount; saveData.gender = PlayerData.gender; saveData.sexualPreference = PlayerData.sexualPreference; saveData.sexualPreferenceLabel = PlayerData.sexualPreferenceLabel; saveData.preliminaryName = PlayerData.preliminaryName; saveData.name = PlayerData.name; saveData.cursorType = PlayerData.cursorType; saveData.cursorFillColor = PlayerData.cursorFillColor; saveData.cursorLineColor = PlayerData.cursorLineColor; saveData.cursorMaxAlpha = PlayerData.cursorMaxAlpha; saveData.cursorMinAlpha = PlayerData.cursorMinAlpha; saveData.cursorInsulated = PlayerData.cursorInsulated; saveData.cursorSmellTimeRemaining = PlayerData.cursorSmellTimeRemaining; saveData.chatHistory = PlayerData.chatHistory; saveData.abraSexyRecords = PlayerData.abraSexyRecords; saveData.abra7PegChats = PlayerData.abra7PegChats; saveData.abraChats = PlayerData.abraChats; saveData.abraSexyBeforeChat = PlayerData.abraSexyBeforeChat; saveData.abra7PegSexyBeforeChat = PlayerData.abra7PegSexyBeforeChat; saveData.abraSexyAfterChat = PlayerData.abraSexyAfterChat; saveData.abraMale = PlayerData.abraMale; saveData.abraReservoir = PlayerData.abraReservoir; saveData.abraToyReservoir = PlayerData.abraToyReservoir; saveData.abraBeadCapacity = PlayerData.abraBeadCapacity; saveData.abraStoryInt = PlayerData.abraStoryInt; saveData.buizSexyRecords = PlayerData.buizSexyRecords; saveData.buizChats = PlayerData.buizChats; saveData.buizSexyBeforeChat = PlayerData.buizSexyBeforeChat; saveData.buizSexyAfterChat = PlayerData.buizSexyAfterChat; saveData.buizMale = PlayerData.buizMale; saveData.buizReservoir = PlayerData.buizReservoir; saveData.buizToyReservoir = PlayerData.buizToyReservoir; saveData.grovSexyRecords = PlayerData.grovSexyRecords; saveData.grovChats = PlayerData.grovChats; saveData.grovSexyBeforeChat = PlayerData.grovSexyBeforeChat; saveData.grovSexyAfterChat = PlayerData.grovSexyAfterChat; saveData.grovMale = PlayerData.grovMale; saveData.grovReservoir = PlayerData.grovReservoir; saveData.grovToyReservoir = PlayerData.grovToyReservoir; saveData.sandSexyRecords = PlayerData.sandSexyRecords; saveData.sandChats = PlayerData.sandChats; saveData.sandSexyBeforeChat = PlayerData.sandSexyBeforeChat; saveData.sandSexyAfterChat = PlayerData.sandSexyAfterChat; saveData.sandMale = PlayerData.sandMale; saveData.sandReservoir = PlayerData.sandReservoir; saveData.sandToyReservoir = PlayerData.sandToyReservoir; saveData.rhydSexyRecords = PlayerData.rhydSexyRecords; saveData.rhydChats = PlayerData.rhydChats; saveData.rhydSexyBeforeChat = PlayerData.rhydSexyBeforeChat; saveData.rhydSexyAfterChat = PlayerData.rhydSexyAfterChat; saveData.rhydMale = PlayerData.rhydMale; saveData.rhydReservoir = PlayerData.rhydReservoir; saveData.rhydToyReservoir = PlayerData.rhydToyReservoir; saveData.rhydGift = PlayerData.rhydGift; saveData.smeaSexyRecords = PlayerData.smeaSexyRecords; saveData.smeaChats = PlayerData.smeaChats; saveData.smeaSexyBeforeChat = PlayerData.smeaSexyBeforeChat; saveData.smeaSexyAfterChat = PlayerData.smeaSexyAfterChat; saveData.smeaMale = PlayerData.smeaMale; saveData.smeaReservoir = PlayerData.smeaReservoir; saveData.smeaToyReservoir = PlayerData.smeaToyReservoir; saveData.smeaReservoirBank = PlayerData.smeaReservoirBank; saveData.smeaToyReservoirBank = PlayerData.smeaToyReservoirBank; saveData.keclMale = PlayerData.keclMale; saveData.keclGift = PlayerData.keclGift; saveData.magnSexyRecords = PlayerData.magnSexyRecords; saveData.magnChats = PlayerData.magnChats; saveData.magnSexyBeforeChat = PlayerData.magnSexyBeforeChat; saveData.magnSexyAfterChat = PlayerData.magnSexyAfterChat; saveData.magnMale = PlayerData.magnMale; saveData.magnReservoir = PlayerData.magnReservoir; saveData.magnToyReservoir = PlayerData.magnToyReservoir; saveData.magnGift = PlayerData.magnGift; saveData.grimSexyRecords = PlayerData.grimSexyRecords; saveData.grimChats = PlayerData.grimChats; saveData.grimSexyBeforeChat = PlayerData.grimSexyBeforeChat; saveData.grimSexyAfterChat = PlayerData.grimSexyAfterChat; saveData.grimMale = PlayerData.grimMale; saveData.grimReservoir = PlayerData.grimReservoir; saveData.grimToyReservoir = PlayerData.grimToyReservoir; saveData.grimTouched = PlayerData.grimTouched; saveData.grimEatenItem = PlayerData.grimEatenItem; saveData.grimMoneyOwed = PlayerData.grimMoneyOwed; saveData.heraSexyRecords = PlayerData.heraSexyRecords; saveData.heraChats = PlayerData.heraChats; saveData.heraSexyBeforeChat = PlayerData.heraSexyBeforeChat; saveData.heraSexyAfterChat = PlayerData.heraSexyAfterChat; saveData.heraMale = PlayerData.heraMale; saveData.heraReservoir = PlayerData.heraReservoir; saveData.heraToyReservoir = PlayerData.heraToyReservoir; saveData.lucaSexyRecords = PlayerData.lucaSexyRecords; saveData.lucaChats = PlayerData.lucaChats; saveData.lucaSexyBeforeChat = PlayerData.lucaSexyBeforeChat; saveData.lucaSexyAfterChat = PlayerData.lucaSexyAfterChat; saveData.lucaMale = PlayerData.lucaMale; saveData.lucaReservoir = PlayerData.lucaReservoir; saveData.lucaToyReservoir = PlayerData.lucaToyReservoir; saveData.professors = PlayerData.professors; saveData.prevProfPrefix = PlayerData.prevProfPrefix; saveData.rankHistory = PlayerData.rankHistory; saveData.rankHistoryLog = PlayerData.rankHistoryLog; saveData.puzzleCount = PlayerData.puzzleCount; saveData.minigameCount = PlayerData.minigameCount; saveData.luckyProfSchedules = PlayerData.luckyProfSchedules; saveData.rankChance = PlayerData.rankChance; saveData.rankDefend = PlayerData.rankDefend; saveData.pokemonLibido = PlayerData.pokemonLibido; saveData.pegActivity = PlayerData.pegActivity; saveData.promptSilverKey = PlayerData.promptSilverKey; saveData.promptGoldKey = PlayerData.promptGoldKey; saveData.promptDiamondKey = PlayerData.promptDiamondKey; saveData.disabledPegColors = PlayerData.disabledPegColors; saveData.newItems = ItemDatabase._newItems; saveData.solvedPuzzle = ItemDatabase._solvedPuzzle; saveData.prefRefillTime = ItemDatabase._prevRefillTime; saveData.warehouseItemIndexes = ItemDatabase._warehouseItemIndexes; saveData.shopItems = ItemDatabase._shopItems; saveData.playerItemIndexes = ItemDatabase._playerItemIndexes; saveData.mysteryBoxStatus = ItemDatabase._mysteryBoxStatus; saveData.magnezoneStatus = ItemDatabase._magnezoneStatus; saveData.kecleonPresent = ItemDatabase._kecleonPresent; save.flush(); } /** * Provides a default value for a null object. * * @param o an object, maybe null * @param defaultValue default value to return if the input is null. * @return the input object if it's non-null, otherwise the defaultvalue */ public static function def(o:Dynamic, defaultValue:Dynamic):Dynamic { return o != null ? o : defaultValue; } /** * Provides a default value for an enum object. * * @param e enumerated type class * @param o an object, maybe null * @param defaultValue default value to return if the input is null * @return an enum representation of the input object if it's not null, * otherwise the defaultValue */ private static function defEnum<T>(e:Enum<T>, o:Dynamic, defaultValue:Dynamic):T { var result:T; #if flash if (o == null || o.tag == null) { result = defaultValue; } else { result = Type.createEnum(e, o.tag); } #else result = o != null ? o : defaultValue; #end return result; } private static function quickLoad() { var saveData:Dynamic = getSaveData(); PlayerData.cash = def(saveData.cash, 500); PlayerData.timePlayed = def(saveData.timePlayed, 0); PlayerData.critterBonus = def(saveData.critterBonus, [5, 5, 10, 10, 20, 50]); PlayerData.pokeVideos = def(saveData.pokeVideos, []); PlayerData.videoCount = def(saveData.videoCount, []); PlayerData.videoStatus = defEnum(PlayerData.VideoStatus, saveData.videoStatus, PlayerData.VideoStatus.Empty); PlayerData.startedTaping = def(saveData.startedTaping, false); PlayerData.startedMagnezone = def(saveData.startedMagnezone, false); PlayerData.magnButtPlug = def(saveData.magnButtPlug, 0); PlayerData.sandPhone = def(saveData.sandPhone, 0); PlayerData.keclStoreChat = def(saveData.keclStoreChat, 0); PlayerData.reservoirReward = def(saveData.reservoirReward, 100); PlayerData.minigameReward = def(saveData.minigameReward, 200); PlayerData.luckyProfReward = def(saveData.luckyProfReward, 2); PlayerData.minigameQueue = def(saveData.minigameQueue, []); PlayerData.scaleGamePuzzleDifficulty = def(saveData.scaleGamePuzzleDifficulty, 0.35); PlayerData.scaleGameOpponentDifficulty = def(saveData.scaleGameOpponentDifficulty, 0.35); PlayerData.denMinigame = def(saveData.denMinigame, -1); PlayerData.denVisitCount = def(saveData.denVisitCount, 0); PlayerData.gender = defEnum(PlayerData.Gender, saveData.gender, PlayerData.Gender.Boy); PlayerData.sexualPreference = defEnum(PlayerData.SexualPreference, saveData.sexualPreference, PlayerData.SexualPreference.Boys); PlayerData.sexualPreferenceLabel = defEnum(PlayerData.SexualPreferenceLabel, saveData.sexualPreferenceLabel, PlayerData.SexualPreferenceLabel.Gay); PlayerData.preliminaryName = def(saveData.preliminaryName, null); PlayerData.name = def(saveData.name, null); PlayerData.cursorType = def(saveData.cursorType, "default"); PlayerData.cursorFillColor = def(saveData.cursorFillColor, 0xffe7e8e1); // internal color PlayerData.cursorLineColor = def(saveData.cursorLineColor, 0xffb3ada2); // external color PlayerData.cursorMaxAlpha = def(saveData.cursorMaxAlpha, 1.0); PlayerData.cursorMinAlpha = def(saveData.cursorMinAlpha, 1.0); PlayerData.cursorInsulated = def(saveData.cursorInsulated, false); PlayerData.cursorSmellTimeRemaining = def(saveData.cursorSmellTimeRemaining, 0); PlayerData.chatHistory = def(saveData.chatHistory, []); PlayerData.abraSexyRecords = def(saveData.abraSexyRecords, [99999, 99999]); PlayerData.abraChats = def(saveData.abraChats, [0, 67]); PlayerData.abra7PegChats = def(saveData.abra7PegChats, [65, 45, 13]); PlayerData.abraSexyBeforeChat = def(saveData.abraSexyBeforeChat, 99); PlayerData.abra7PegSexyBeforeChat = def(saveData.abra7PegSexyBeforeChat, 99); PlayerData.abraSexyAfterChat = def(saveData.abraSexyAfterChat, 99); PlayerData.abraMale = def(saveData.abraMale, PlayerData.abraDefaultMale); PlayerData.abraReservoir = def(saveData.abraReservoir, 71); PlayerData.abraToyReservoir = def(saveData.abraToyReservoir, -1); PlayerData.abraBeadCapacity = def(saveData.abraBeadCapacity, 42); PlayerData.abraStoryInt = def(saveData.abraStoryInt, 0); PlayerData.buizSexyRecords = def(saveData.buizSexyRecords, [99999, 99999]); PlayerData.buizChats = def(saveData.buizChats, [0, 54]); PlayerData.buizSexyBeforeChat = def(saveData.buizSexyBeforeChat, 99); PlayerData.buizSexyAfterChat = def(saveData.buizSexyAfterChat, 99); PlayerData.buizMale = def(saveData.buizMale, PlayerData.buizDefaultMale); PlayerData.buizReservoir = def(saveData.buizReservoir, 39); PlayerData.buizToyReservoir = def(saveData.buizToyReservoir, -1); PlayerData.grovSexyRecords = def(saveData.grovSexyRecords, [99999, 99999]); PlayerData.grovChats = def(saveData.grovChats, [53, 0]); // don't lead with chat 0; it's a little overbearing PlayerData.grovSexyBeforeChat = def(saveData.grovSexyBeforeChat, 99); PlayerData.grovSexyAfterChat = def(saveData.grovSexyAfterChat, 99); PlayerData.grovMale = def(saveData.grovMale, PlayerData.grovDefaultMale); PlayerData.grovReservoir = def(saveData.grovReservoir, 67); PlayerData.grovToyReservoir = def(saveData.grovToyReservoir, -1); PlayerData.sandSexyRecords = def(saveData.sandSexyRecords, [99999, 99999]); PlayerData.sandChats = def(saveData.sandChats, [0, 93]); PlayerData.sandSexyBeforeChat = def(saveData.sandSexyBeforeChat, 99); PlayerData.sandSexyAfterChat = def(saveData.sandSexyAfterChat, 99); PlayerData.sandMale = def(saveData.sandMale, PlayerData.sandDefaultMale); PlayerData.sandReservoir = def(saveData.sandReservoir, 73); PlayerData.sandToyReservoir = def(saveData.sandToyReservoir, -1); PlayerData.rhydSexyRecords = def(saveData.rhydSexyRecords, [99999, 99999]); PlayerData.rhydChats = def(saveData.rhydChats, [0, 65]); PlayerData.rhydSexyBeforeChat = def(saveData.rhydSexyBeforeChat, 99); PlayerData.rhydSexyAfterChat = def(saveData.rhydSexyAfterChat, 99); PlayerData.rhydMale = def(saveData.rhydMale, PlayerData.rhydDefaultMale); PlayerData.rhydReservoir = def(saveData.rhydReservoir, 53); PlayerData.rhydToyReservoir = def(saveData.rhydToyReservoir, -1); PlayerData.rhydGift = def(saveData.rhydGift, 0); PlayerData.smeaSexyRecords = def(saveData.smeaSexyRecords, [99999, 99999]); PlayerData.smeaChats = def(saveData.smeaChats, [0, 59]); PlayerData.smeaSexyBeforeChat = def(saveData.smeaSexyBeforeChat, 99); PlayerData.smeaSexyAfterChat = def(saveData.smeaSexyAfterChat, 99); PlayerData.smeaMale = def(saveData.smeaMale, PlayerData.smeaDefaultMale); PlayerData.smeaReservoir = def(saveData.smeaReservoir, 25); PlayerData.smeaToyReservoir = def(saveData.smeaToyReservoir, -1); PlayerData.smeaReservoirBank = def(saveData.smeaReservoirBank, 0); PlayerData.smeaToyReservoirBank = def(saveData.smeaToyReservoirBank, 0); PlayerData.keclMale = def(saveData.keclMale, PlayerData.keclDefaultMale); PlayerData.keclGift = def(saveData.keclGift, 0); PlayerData.magnSexyRecords = def(saveData.magnSexyRecords, [99999, 99999]); PlayerData.magnChats = def(saveData.magnChats, [0, 20]); PlayerData.magnSexyBeforeChat = def(saveData.magnSexyBeforeChat, 99); PlayerData.magnSexyAfterChat = def(saveData.magnSexyAfterChat, 99); PlayerData.magnMale = def(saveData.magnMale, PlayerData.magnDefaultMale); PlayerData.magnReservoir = def(saveData.magnReservoir, 64); PlayerData.magnToyReservoir = def(saveData.magnToyReservoir, -1); PlayerData.magnGift = def(saveData.magnGift, 0); PlayerData.grimSexyRecords = def(saveData.grimSexyRecords, [99999, 99999]); PlayerData.grimChats = def(saveData.grimChats, [0, 20]); PlayerData.grimSexyBeforeChat = def(saveData.grimSexyBeforeChat, 99); PlayerData.grimSexyAfterChat = def(saveData.grimSexyAfterChat, 99); PlayerData.grimMale = def(saveData.grimMale, PlayerData.grimDefaultMale); PlayerData.grimReservoir = def(saveData.grimReservoir, 41); PlayerData.grimToyReservoir = def(saveData.grimToyReservoir, -1); PlayerData.grimTouched = def(saveData.grimTouched, false); PlayerData.grimEatenItem = def(saveData.grimEatenItem, -1); PlayerData.grimMoneyOwed = def(saveData.grimMoneyOwed, 0); PlayerData.heraSexyRecords = def(saveData.heraSexyRecords, [99999, 99999]); PlayerData.heraChats = def(saveData.heraChats, [0, 66]); PlayerData.heraSexyBeforeChat = def(saveData.heraSexyBeforeChat, 99); PlayerData.heraSexyAfterChat = def(saveData.heraSexyAfterChat, 99); PlayerData.heraMale = def(saveData.heraMale, PlayerData.heraDefaultMale); PlayerData.heraReservoir = def(saveData.heraReservoir, 210); // heracross is really pent up his first time PlayerData.heraToyReservoir = def(saveData.heraToyReservoir, -1); PlayerData.lucaSexyRecords = def(saveData.lucaSexyRecords, [99999, 99999]); PlayerData.lucaChats = def(saveData.lucaChats, [0, 35]); PlayerData.lucaSexyBeforeChat = def(saveData.lucaSexyBeforeChat, 99); PlayerData.lucaSexyAfterChat = def(saveData.lucaSexyAfterChat, 99); PlayerData.lucaMale = def(saveData.lucaMale, PlayerData.lucaDefaultMale); PlayerData.lucaReservoir = def(saveData.lucaReservoir, 47); PlayerData.lucaToyReservoir = def(saveData.lucaToyReservoir, -1); PlayerData.professors = def(saveData.professors, [3, 1, 6, 0]); PlayerData.prevProfPrefix = def(saveData.prevProfPrefix, ""); PlayerData.rankHistory = def(saveData.rankHistory, [0, 0, 0, 0, 0, 0, 0, 65]); PlayerData.rankHistoryLog = def(saveData.rankHistoryLog, []); PlayerData.puzzleCount = def(saveData.puzzleCount, [0, 0, 0, 0, 0]); PlayerData.minigameCount = def(saveData.minigameCount, [0, 0, 0, 0, 0]); PlayerData.luckyProfSchedules = def(saveData.luckyProfSchedules, []); while (PlayerData.puzzleCount.length < 5) { // people with an older version of the game will have a puzzleCount with only four // zeroes, since the "impossible" difficulty was added later PlayerData.puzzleCount.push(0); } PlayerData.rankChance = def(saveData.rankChance, false); PlayerData.rankDefend = def(saveData.rankDefend, false); PlayerData.pokemonLibido = def(saveData.pokemonLibido, 4); PlayerData.pegActivity = def(saveData.pegActivity, 4); PlayerData.promptSilverKey = defEnum(PlayerData.Prompt, saveData.promptSilverKey, PlayerData.Prompt.AlwaysNo); PlayerData.promptGoldKey = defEnum(PlayerData.Prompt, saveData.promptGoldKey, PlayerData.Prompt.AlwaysNo); PlayerData.promptDiamondKey = defEnum(PlayerData.Prompt, saveData.promptDiamondKey, PlayerData.Prompt.AlwaysNo); PlayerData.disabledPegColors = def(saveData.disabledPegColors, []); ItemDatabase._newItems = def(saveData.newItems, false); ItemDatabase._solvedPuzzle = def(saveData.solvedPuzzle, false); ItemDatabase._prevRefillTime = def(saveData.prefRefillTime, null); ItemDatabase._warehouseItemIndexes = saveData.warehouseItemIndexes != null ? saveData.warehouseItemIndexes : ItemDatabase.getAllItemIndexes(); ItemDatabase._mysteryBoxStatus = def(saveData.mysteryBoxStatus, 0); ItemDatabase._playerItemIndexes = def(saveData.playerItemIndexes, []); ItemDatabase._magnezoneStatus = defEnum(ItemDatabase.MagnezoneStatus, saveData.magnezoneStatus, ItemDatabase.MagnezoneStatus.Absent); ItemDatabase._kecleonPresent = def(saveData.kecleonPresent, false); ItemDatabase._shopItems = []; // Haxe saves shop items as generic objects, so we have to manually convert them back var oShopItems:Array<Dynamic> = def(saveData.shopItems, []); for (oShopItem in oShopItems) { if (oShopItem._itemIndex == null) { // itemIndex could be null if they have old/corrupt item data. don't add those items } else if (oShopItem._itemIndex <= -100000) { // it's a phone call... ItemDatabase._shopItems.push(new ItemDatabase.TelephoneShopItem()); } else if (oShopItem._itemIndex < 0) { // it's a mystery box... ItemDatabase._shopItems.push(new ItemDatabase.MysteryBoxShopItem()); } else { var shopItem:ItemDatabase.ShopItem = new ItemDatabase.ShopItem(oShopItem._itemIndex, oShopItem._discount); shopItem._expensive = oShopItem._expensive; shopItem._orderIndex = oShopItem._orderIndex; ItemDatabase._shopItems.push(shopItem); } } PlayerDataNormalizer.normalizeItems(); PlayerDataNormalizer.normalizeLuckyProfSchedules(); PlayerDataNormalizer.normalizeToyReservoirs(); } }
argonvile/monster
source/PlayerSave.hx
hx
unknown
23,329
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; /** * Long graphical meters filled with red, yellow and green liquid which * represent a pokemon's libido */ class ReservoirMeter extends FlxSprite { private static var NORMAL_FRAME_COUNT:Int = 10; private static var EMERGENCY_FRAME_COUNT:Int = 8; private var mainColor:FlxColor; private var shadowColor:FlxColor; private var parentSprite:FlxSprite; private var yOffset:Int; public function new(ParentSprite:FlxSprite, percent:Float, reservoirStatus:ReservoirStatus, ?yOffset:Int = 158, ?width:Int = 94) { super(); this.parentSprite = ParentSprite; this.yOffset = yOffset; var frameCount:Int = reservoirStatus == ReservoirStatus.Emergency ? EMERGENCY_FRAME_COUNT : NORMAL_FRAME_COUNT; makeGraphic(width, 10 * frameCount, FlxColor.TRANSPARENT, true); loadGraphic(pixels, true, width, 10, false); updatePosition(); // create animation var animationFrames:Array<Int> = []; for (i in 0...frameCount) { animationFrames.push(i); } animation.add("default", animationFrames, 6, true); animation.play("default"); mainColor = [Green => 0xFF6ACA52, Yellow => 0xFFE6D329, Red => 0xFFE65540, Emergency => 0xFFE65540][reservoirStatus]; shadowColor = [Green => 0xFF47A631, Yellow => 0xFFC0B00B, Red => 0xFFC4321B, Emergency => 0xFFC4321B][reservoirStatus]; var targetX:Int = 0; if (percent <= 0.0) { targetX = 0; } else if (percent >= 1.0) { targetX = width - 1; } else { targetX = Math.round(2 + (width - 8) * percent); } for (frameIndex in 0...frameCount + 1) { { // fill transparent background var points:Array<FlxPoint> = []; points.push(FlxPoint.get(2, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 3)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 6)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 9)); points.push(FlxPoint.get(2, frameIndex * 10 + 9)); points.push(FlxPoint.get(0, frameIndex * 10 + 6)); points.push(FlxPoint.get(0, frameIndex * 10 + 3)); points.push(FlxPoint.get(2, frameIndex * 10 + 0)); FlxSpriteUtil.drawPolygon(this, points, 0x22FFFFFF); FlxDestroyUtil.putArray(points); } if (targetX > 0) { { // draw main bar var points:Array<FlxPoint> = []; points.push(FlxPoint.get(2, frameIndex * 10 + 0)); if (targetX < width - 1) { points.push(FlxPoint.get(targetX, frameIndex * 10 + 0)); points.push(FlxPoint.get(targetX, frameIndex * 10 + 9)); } else { points.push(FlxPoint.get(width - 3, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 3)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 6)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 9)); } points.push(FlxPoint.get(2, frameIndex * 10 + 9)); points.push(FlxPoint.get(0, frameIndex * 10 + 6)); points.push(FlxPoint.get(0, frameIndex * 10 + 3)); points.push(FlxPoint.get(2, frameIndex * 10 + 0)); FlxSpriteUtil.drawPolygon(this, points, mainColor); FlxDestroyUtil.putArray(points); } { // draw shadow var points:Array<FlxPoint> = []; points.push(FlxPoint.get(0.67, frameIndex * 10 + 7)); if (targetX < width - 1) { points.push(FlxPoint.get(targetX, frameIndex * 10 + 7)); points.push(FlxPoint.get(targetX, frameIndex * 10 + 9)); } else { points.push(FlxPoint.get(width - 1.67, frameIndex * 10 + 7)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 9)); } points.push(FlxPoint.get(2, frameIndex * 10 + 9)); points.push(FlxPoint.get(0.67, frameIndex * 10 + 7)); FlxSpriteUtil.drawPolygon(this, points, shadowColor); FlxDestroyUtil.putArray(points); } // draw animated bits if (targetX < width - 1) { var yStart:Int = FlxG.random.int(0, 9); var yEnd:Int = yStart + FlxG.random.int(3, 6); if (yEnd <= 9) { drawMeniscus(frameIndex, targetX, yStart, yEnd); } else { drawMeniscus(frameIndex, targetX, 0, yEnd - 10); drawMeniscus(frameIndex, targetX, yStart, 9); } var spootCount:Int = FlxG.random.weightedPick([4, 2, 1]); for (i in 0...spootCount) { var spootSize:Int = FlxG.random.int(1, 2); var spootX:Int = targetX + FlxG.random.int(0, spootSize == 1 ? 3 : 2); var spootY:Int = FlxG.random.int(0, spootSize == 1 ? 9 : 8); var spootColor:FlxColor = spootY < 7 ? mainColor : shadowColor; FlxSpriteUtil.drawRect(this, spootX, frameIndex * 10 + spootY, spootSize, spootSize, spootColor); } } } { // draw shiny bits FlxSpriteUtil.drawLine(this, 4, frameIndex * 10 + 3, 5, frameIndex * 10 + 3, {color:FlxColor.WHITE, thickness:2}); FlxSpriteUtil.drawLine(this, 6, frameIndex * 10 + 3, Std.int(width * 0.181), frameIndex * 10 + 3, {color:FlxColor.WHITE, thickness:2}); FlxSpriteUtil.drawLine(this, Std.int(width * 0.181), frameIndex * 10 + 2, Std.int(width * 0.373), frameIndex * 10 + 2, {color:FlxColor.WHITE, thickness:1}); FlxSpriteUtil.drawLine(this, Std.int(width * 0.383), frameIndex * 10 + 2, Std.int(width * 0.405), frameIndex * 10 + 2, {color:FlxColor.WHITE, thickness:1}); FlxSpriteUtil.drawLine(this, width - 4, frameIndex * 10 + 7, width - 3, frameIndex * 10 + 7, {color:FlxColor.WHITE, thickness:1}); FlxSpriteUtil.drawLine(this, Std.int(width * 0.830), frameIndex * 10 + 7, width - 5, frameIndex * 10 + 7, {color:FlxColor.WHITE, thickness:1}); } if (reservoirStatus == ReservoirStatus.Emergency) { // blinking foreground var points:Array<FlxPoint> = []; points.push(FlxPoint.get(2, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 3)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 6)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 9)); points.push(FlxPoint.get(2, frameIndex * 10 + 9)); points.push(FlxPoint.get(0, frameIndex * 10 + 6)); points.push(FlxPoint.get(0, frameIndex * 10 + 3)); points.push(FlxPoint.get(2, frameIndex * 10 + 0)); var alpha:Float = Math.sin(frameIndex * Math.PI / frameCount); alpha = Math.pow(alpha * alpha, 1.6); var alphaColor:Int = Math.round(alpha * 0xBB) << 24 | 0x00FFFFFF; FlxSpriteUtil.drawPolygon(this, points, alphaColor); FlxDestroyUtil.putArray(points); } { // draw outline var lineStyle:LineStyle = { color:FlxColor.BLACK, thickness: 1 }; var drawStyle:DrawStyle = { smoothing:false }; var points:Array<FlxPoint> = []; points.push(FlxPoint.get(2, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 0)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 3)); points.push(FlxPoint.get(width - 1, frameIndex * 10 + 6)); points.push(FlxPoint.get(width - 3, frameIndex * 10 + 9)); points.push(FlxPoint.get(2, frameIndex * 10 + 9)); points.push(FlxPoint.get(0, frameIndex * 10 + 6)); points.push(FlxPoint.get(0, frameIndex * 10 + 3)); points.push(FlxPoint.get(2, frameIndex * 10 + 0)); FlxSpriteUtil.drawPolygon(this, points, FlxColor.TRANSPARENT, lineStyle, drawStyle); FlxDestroyUtil.putArray(points); } } } function updatePosition() { this.x = parentSprite.x + (parentSprite.width - width) / 2; this.y = parentSprite.y + yOffset; this.offset.x = parentSprite.offset.x; this.offset.y = parentSprite.offset.y; this.visible = parentSprite.visible; } override public function update(elapsed:Float):Void { super.update(elapsed); updatePosition(); } function drawMeniscus(frameIndex:Int, x:Float, minY:Float, maxY:Float) { if (minY < 7 && maxY < 7) { FlxSpriteUtil.drawLine(this, x, frameIndex * 10 + minY, x, frameIndex * 10 + maxY, {color:mainColor, thickness:1}); } else if (minY >= 7 && maxY >= 7) { FlxSpriteUtil.drawLine(this, x, frameIndex * 10 + minY, x, frameIndex * 10 + maxY, {color:shadowColor, thickness:1}); } else { FlxSpriteUtil.drawLine(this, x, frameIndex * 10 + minY, x, frameIndex * 10 + 7, {color:mainColor, thickness:1}); FlxSpriteUtil.drawLine(this, x, frameIndex * 10 + 7, x, frameIndex * 10 + maxY, {color:shadowColor, thickness:1}); } } } enum ReservoirStatus { Green; Yellow; Red; Emergency; }
argonvile/monster
source/ReservoirMeter.hx
hx
unknown
8,864
package; import flixel.FlxSprite; import openfl.display.BitmapData; import openfl.geom.Rectangle; /** * A rectangle with rounded corners. This is used for dialog and chat windows */ class RoundedRectangle extends FlxSprite { public var _unique:Bool = false; public function relocate(X:Int, Y:Int, Width:Int, Height:Int, FgColor:Int=0xff000000, BgColor:Int=0xffffffff, BorderSize:Int=2):Void { this.x = X; this.y = Y; makeGraphic(Width, Height, BgColor, _unique, "rounded-rect-" + StringTools.hex(FgColor, 8) + "-" + StringTools.hex(BgColor, 8) + "-" + Width + "x" + Height + "-" + BorderSize); var tempData:BitmapData = get_pixels(); tempData.fillRect(new Rectangle(0, 0, width, height), FgColor); tempData.fillRect(new Rectangle(BorderSize, BorderSize, Width-2*BorderSize, height-2*BorderSize), BgColor); tempData.setPixel32(0, 0, 0x00000000); tempData.setPixel32(Width-1, 0, 0x00000000); tempData.setPixel32(0, Height-1, 0x00000000); tempData.setPixel32(Width-1, Height-1, 0x00000000); set_pixels(tempData); } }
argonvile/monster
source/RoundedRectangle.hx
hx
unknown
1,071
package; import flixel.FlxSprite; /** * A shadow for an object, which mirrors that object's X and Y movements * * Also includes some specific kludges related to bug shadows */ class Shadow extends FlxSprite { private var _parent:FlxSprite; private static var _critterAssetsKey:String = "assets/images/critter-bodies"; // if the shadow's target is on a platform, groundZ will change and the shadow will be drawn differently public var groundZ:Float = 0; public function new() { super(); loadGraphic(AssetPaths.shadow__png); } public function setParent(Parent:FlxSprite):Void { _parent = Parent; } public function hasParent(Parent:FlxSprite):Bool { return _parent == Parent; } override public function update(elapsed:Float):Void { super.update(elapsed); if (!_parent.exists) { kill(); return; } if (_parent.graphic.assetsKey != null && _parent.graphic.assetsKey.substring(0, _critterAssetsKey.length) == _critterAssetsKey && (_parent.animation.frameIndex == 1 || _parent.animation.frameIndex == 88 || _parent.animation.frameIndex == 89 || _parent.animation.frameIndex == 90 || _parent.animation.frameIndex == 91)) { // shadows drop a little when critters are picked up setPosition(_parent.x + _parent.width / 2 - width / 2, _parent.y + _parent.height + 6 - groundZ); } else { setPosition(_parent.x + _parent.width / 2 - width / 2, _parent.y + _parent.height - 4 - groundZ); } visible = _parent.visible; } }
argonvile/monster
source/Shadow.hx
hx
unknown
1,536
package; import flash.geom.ColorTransform; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import openfl.display.BitmapData; /** * A group of shadows which track different objects around on the screen */ class ShadowGroup extends FlxTypedGroup<Shadow> { // Buffer which this group is rendered to, prior to rendering it to the camera private var _groupBuffer:FlxSprite; public static var SHADOW_ALPHA:Float = 0.25; // extra custom-shaped shadow object; such as the scale's shadow public var _extraShadows:Array<FlxSprite> = []; public function new():Void { super(); _groupBuffer = new FlxSprite(0, 0, new BitmapData(FlxG.camera.width, FlxG.camera.height, true, 0x00)); } public function makeShadow(parent:FlxSprite, scale:Float = 1):Shadow { var shadow:Shadow = recycle(Shadow); shadow.reset(parent.x, parent.y); shadow.scale.x = scale; shadow.scale.y = scale; shadow.exists = true; shadow.setParent(parent); shadow.update(0); // update initial position return shadow; } public function killShadow(parent:FlxSprite) { for (member in members) { if (member.hasParent(parent)) { member.kill(); } } } override public function update(elapsed:Float):Void { super.update(elapsed); for (extraShadow in _extraShadows) { extraShadow.update(elapsed); } } override public function draw():Void { // clear the groupBuffer FlxSpriteUtil.fill(_groupBuffer, FlxColor.TRANSPARENT); #if flash PixelFilterUtils.swapCameraBuffer(_groupBuffer); super.draw(); PixelFilterUtils.swapCameraBuffer(_groupBuffer); #else PixelFilterUtils.drawToBuffer(_groupBuffer, this); #end // render contents to groupBuffer for (extraShadow in _extraShadows) { if (extraShadow != null && extraShadow.exists && extraShadow.visible) { PixelFilterUtils.fastStampToBuffer(_groupBuffer, extraShadow); } } _groupBuffer.graphic.bitmap.colorTransform(_groupBuffer.graphic.bitmap.rect, new ColorTransform(1, 1, 1, SHADOW_ALPHA)); _groupBuffer.dirty = true; // draw groupBuffer to camera _groupBuffer.draw(); } override public function destroy():Void { super.destroy(); _groupBuffer = FlxDestroyUtil.destroy(_groupBuffer); _extraShadows = FlxDestroyUtil.destroyArray(_extraShadows); } }
argonvile/monster
source/ShadowGroup.hx
hx
unknown
2,511
package; import MmStringTools.*; import critter.Critter; import critter.CritterBody; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.ui.FlxButton; import flixel.util.FlxDestroyUtil; import kludge.FlxSoundKludge; import kludge.FlxSpriteKludge; import minigame.MinigameState; import openfl.Assets; import openfl.utils.Object; import poke.abra.AbraResource; import poke.hera.HeraResource; import poke.hera.HeraShopDialog; import poke.kecl.KecleonDialog; import poke.magn.MagnDialog; import poke.magn.MagnResource; import poke.rhyd.RhydonDialog; import poke.sand.SandslashResource; import poke.sexy.SexyState; import poke.smea.SmeargleDialog; /** * FlxState for the shop screen; the screen where Heracross (or sometimes * Kecleon) offers to sell the player items. */ class ShopState extends FlxTransitionableState { private var _bgSprite:FlxSprite; private var _handSprite:FlxSprite; private var _itemSprites:FlxTypedGroup<FlxSprite>; private var _shadowGroup:FlxTypedGroup<FlxSprite> = new FlxTypedGroup<FlxSprite>(); private var _shadowMap:Map<FlxSprite, FlxSprite> = new Map<FlxSprite, FlxSprite>(); private var _itemSpriteToItemMap:Map<FlxSprite, ItemDatabase.ShopItem> = new Map<FlxSprite, ItemDatabase.ShopItem>(); private var _critterToItemMap:Map<Critter, ItemDatabase.ShopItem> = new Map<Critter, ItemDatabase.ShopItem>(); private var _cashWindow:CashWindow; private var _dialogTree:DialogTree; private var _dialogger:Dialogger; private var _clickedItemSprite:FlxSprite; private var _justPurchasedSprite:FlxSprite; private var _backButton:FlxButton; private var _denArrow:FlxSprite; private var _crackerSprite:FlxSprite; private var _crumbSprite:FlxSprite; private var _crackerClickCount:Int; private var _abraSprites:Array<FlxSprite> = []; private var _sandSprites:Array<FlxSprite> = []; private var _keclSprites:Array<FlxSprite> = []; private var _heraSprites:Array<FlxSprite> = []; // for critters... private var _critters:Array<Critter> = []; private var _targetSprites:FlxTypedGroup<FlxSprite>; private var _midInvisSprites:FlxTypedGroup<FlxSprite>; private var _midSprites:FlxTypedGroup<FlxSprite>; private var _critterShadowGroup:ShadowGroup; private var _kecleonPoseTimer:Float = 0; public function new(?TransIn:TransitionData, ?TransOut:TransitionData) { super(TransIn, TransOut); } override public function create():Void { super.create(); Main.overrideFlxGDefaults(); PlayerData.profIndex = -1; // clear profIndex, to avoid hasMet() goofups Critter.initialize(Critter.LOAD_ALL); // load all critters, so player can view them in shop ItemDatabase.refillShop(); ItemDatabase._newItems = false; _bgSprite = new FlxSprite(0, 0); _bgSprite.loadGraphic(AssetPaths.shop_bg__png, true, 768, 432, true); add(_bgSprite); _denArrow = new BouncySprite(191, 44, 6, 4, 0); _denArrow.loadGraphic(AssetPaths.shop_den_arrow__png, true, 60, 40); _denArrow.animation.add("default", AnimTools.blinkyAnimation([0, 1]), 3); _denArrow.animation.play("default"); _denArrow.visible = false; add(_denArrow); if (isDenDoorOpen()) { _bgSprite.animation.frameIndex = 1; } if (ItemDatabase._magnezoneStatus == ItemDatabase.MagnezoneStatus.Absent) { // magnezone is not in the shop } else { var mx = 510; var my = -30; var magnTail:BouncySprite = new BouncySprite(mx, my, 14, 8.8, 0); magnTail.loadGraphic(AssetPaths.shop_magn_tail__png); add(magnTail); var magnLeftScrew:BouncySprite = new BouncySprite(mx, my, 10, 8.8, 0.18); magnLeftScrew.loadGraphic(AssetPaths.shop_magn_left_screw__png); add(magnLeftScrew); var magnLeftHead:BouncySprite = new BouncySprite(mx, my, 12, 8.8, 0.16); magnLeftHead.loadGraphic(AssetPaths.shop_magn_left_head__png, true, 300, 300); magnLeftHead.animation.add("play0", AnimTools.slowBlinkyAnimation([0, 1], [2]), 3); magnLeftHead.animation.add("play1", AnimTools.slowBlinkyAnimation([4, 5], [6]), 3); magnLeftHead.animation.add("play2", AnimTools.slowBlinkyAnimation([8, 9], [6]), 3); magnLeftHead.animation.add("play3", AnimTools.slowBlinkyAnimation([10, 11], [6]), 3); add(magnLeftHead); var magnLeftHand:BouncySprite = new BouncySprite(mx, my, 14, 8.8, 0.08); magnLeftHand.loadGraphic(AssetPaths.shop_magn_left_hand__png); add(magnLeftHand); var magnBody:BouncySprite = new BouncySprite(mx, my, 12, 8.8, 0.16); magnBody.loadGraphic(AssetPaths.shop_magn_body__png, true, 300, 300); magnBody.animation.add("play0", AnimTools.slowBlinkyAnimation([0, 1], [2]), 3); magnBody.animation.add("play1", AnimTools.slowBlinkyAnimation([4, 5], [6]), 3); magnBody.animation.add("play2", AnimTools.slowBlinkyAnimation([8, 9], [6]), 3); magnBody.animation.add("play3", AnimTools.slowBlinkyAnimation([10, 11], [7]), 3); add(magnBody); var magnRightScrew:BouncySprite = new BouncySprite(mx, my, 10, 8.8, 0.18); magnRightScrew.loadGraphic(AssetPaths.shop_magn_right_screw__png); add(magnRightScrew); var magnRightHead:BouncySprite = new BouncySprite(mx, my, 12, 8.8, 0.16); magnRightHead.loadGraphic(AssetPaths.shop_magn_right_head__png, true, 300, 300); magnRightHead.animation.add("play0", AnimTools.slowBlinkyAnimation([0, 1], [2]), 3); magnRightHead.animation.add("play1", AnimTools.slowBlinkyAnimation([4, 5], [6]), 3); magnRightHead.animation.add("play2", AnimTools.slowBlinkyAnimation([8, 9], [6]), 3); magnRightHead.animation.add("play3", AnimTools.slowBlinkyAnimation([10, 11], [6]), 3); add(magnRightHead); var magnRightHand:BouncySprite = new BouncySprite(mx, my, 14, 8.8, 0.08); magnRightHand.loadGraphic(AssetPaths.shop_magn_right_hand__png); add(magnRightHand); var animName:String; switch (ItemDatabase._magnezoneStatus) { case ItemDatabase.MagnezoneStatus.Suspicious: animName = "play1"; case ItemDatabase.MagnezoneStatus.Calm: animName = "play2"; case ItemDatabase.MagnezoneStatus.Happy: animName = "play3"; MagnResource.chat = AssetPaths.magn_chat_hatless__png; default: animName = "play0"; } magnLeftHead.animation.play(animName); magnBody.animation.play(animName); magnRightHead.animation.play(animName); } { var ax:Int = -90; var ay:Int = 0; var abraPants:BouncySprite = new BouncySprite(ax, ay, 0, 7.0, 0); abraPants.loadGraphic(AbraResource.shopPants); add(abraPants); _abraSprites.push(abraPants); var abraTorso:BouncySprite = new BouncySprite(ax, ay, 0, 7.0, 0); abraTorso.loadGraphic(AssetPaths.shop_abra_torso__png); add(abraTorso); _abraSprites.push(abraTorso); var abraHead:BouncySprite = new BouncySprite(ax, ay + 3, 3, 7.0, 0); abraHead.loadGraphic(AbraResource.shopHead, true, 300, 300); abraHead.animation.add("default", AnimTools.blinkyAnimation([0, 1]), 3); abraHead.animation.play("default"); add(abraHead); _abraSprites.push(abraHead); } { var sx:Int = 48; var sy:Int = 21; var sandTail:BouncySprite = new BouncySprite(sx, sy, 6, 5.0, 0.9); sandTail.loadGraphic(AssetPaths.shop_sand_tail__png); add(sandTail); _sandSprites.push(sandTail); var sandBody:BouncySprite = new BouncySprite(sx, sy, 0, 5.0, 0); sandBody.loadGraphic(SandslashResource.shopBody); add(sandBody); _sandSprites.push(sandBody); var sandQuills:BouncySprite = new BouncySprite(sx, sy + 3, 3, 5.0, 0); sandQuills.loadGraphic(AssetPaths.shop_sand_quills__png); add(sandQuills); _sandSprites.push(sandQuills); var sandHead:BouncySprite = new BouncySprite(sx, sy + 3, 3, 5.0, 0.1); sandHead.loadGraphic(SandslashResource.shopHead, true, 300, 300); sandHead.animation.add("default", AnimTools.blinkyAnimation([0, 1], [2]), 3); sandHead.animation.play("default"); add(sandHead); _sandSprites.push(sandHead); } var keclSprite0:BouncySprite = new BouncySprite(288, -10, 0, 6.5, 0); keclSprite0.loadGraphic(AssetPaths.shop_kecl0__png, true, 200, 300); keclSprite0.animation.add("slouch", [0]); keclSprite0.animation.add("unslouch", [1]); keclSprite0.animation.play("slouch"); _keclSprites.push(keclSprite0); add(keclSprite0); var heraSprite0:BouncySprite = new BouncySprite(0, -2, 3, 4.5, 0); heraSprite0.loadGraphic(HeraResource.shop, true, 768, 432); heraSprite0.animation.add("play", AnimTools.blinkyAnimation([0, 1], [2]), 3); heraSprite0.animation.play("play"); _heraSprites.push(heraSprite0); add(heraSprite0); add(new FlxSprite(0, 0, AssetPaths.shop_table__png)); add(_shadowGroup); var _sandArm:FlxSprite = new FlxSprite(48, 21, AssetPaths.shop_sand_arm__png); _sandSprites.push(_sandArm); add(_sandArm); var heraSprite1:FlxSprite = new FlxSprite(0, 0, AssetPaths.shop_hera1__png); _heraSprites.push(heraSprite1); add(heraSprite1); var keclSprite1:FlxSprite = new BouncySprite(288, -10, 0, 6.5, 0); keclSprite1.loadGraphic(AssetPaths.shop_kecl1__png, true, 200, 300); keclSprite1.animation.add("slouch", [0]); keclSprite1.animation.add("unslouch", [1]); keclSprite1.animation.play("slouch"); _keclSprites.push(keclSprite1); add(keclSprite1); var keclHeadSprite:FlxSprite = new BouncySprite(288, -10, 0, 6.5, 0); keclHeadSprite.loadGraphic(AssetPaths.shop_kecl_head__png, true, 200, 300); keclHeadSprite.animation.add("slouch", AnimTools.blinkyAnimation([0, 1], [2]), 3); keclHeadSprite.animation.add("unslouch", AnimTools.blinkyAnimation([3, 4], [5]), 3); keclHeadSprite.animation.play("slouch"); _keclSprites.push(keclHeadSprite); add(keclHeadSprite); var keclSprite2:FlxSprite = new BouncySprite(288, -10, 0, 6.5, 0); keclSprite2.loadGraphic(AssetPaths.shop_kecl2__png, true, 200, 300); keclSprite2.animation.add("slouch", [0]); keclSprite2.animation.add("unslouch", [1]); keclSprite2.animation.play("slouch"); _keclSprites.push(keclSprite2); add(keclSprite2); _itemSprites = new FlxTypedGroup<FlxSprite>(); add(_itemSprites); _critterShadowGroup = new ShadowGroup(); _targetSprites = new FlxTypedGroup<FlxSprite>(); _midInvisSprites = new FlxTypedGroup<FlxSprite>(); _midInvisSprites.visible = false; _midSprites = new FlxTypedGroup<FlxSprite>(); add(_critterShadowGroup); add(_targetSprites); add(_midInvisSprites); add(_midSprites); var shopItems:Array<ItemDatabase.ShopItem> = ItemDatabase._shopItems.copy(); shopItems.sort( function(a:ItemDatabase.ShopItem, b:ItemDatabase.ShopItem) { return a._orderIndex - b._orderIndex; }); var i:Int = 0; for (item in shopItems) { var itemX:Float = 378.5 - 58.5 * shopItems.length + 117 * i + FlxG.random.int( -7, 7); var itemY:Float = 265 - 200 + FlxG.random.int( -3, 3); if (item._itemIndex == ItemDatabase.ITEM_FRUIT_BUGS || item._itemIndex == ItemDatabase.ITEM_SPOOKY_BUGS || item._itemIndex == ItemDatabase.ITEM_MARSHMALLOW_BUGS) { var critterOffsetsX:Array<Float> = FlxG.random.getObject([ [22.1, 4.4, -18.5, -0.6, -12.9, 2.2], [8.1, 19.1, -21.6, -14.5, 6.8, 0], [24.8, -23.5, -2, 0.5, 3.7, -14], [24.9, -25.2, 13.3, 4.7, -3.6, -11.5], [ -20.5, 17, -2.6, 4.3, -0.9, -15.4], [ -16.3, 27, -11.5, 2.9, -5.4, -14.2], [21, -25, 13.5, 4.2, -4.1, -13.5], [ -23.6, 23.9, 3.8, -2.6, -3.1, 11.9], [23.3, -15.2, 7.8, -10.2, -2.9, 11.6], [ -21.3, 19.5, -10.3, -8.9, -5.6, 8.9], ]); var critterOffsetsY:Array<Float> = critterOffsetsX.splice(3, 3); var critterColorIndexes:Array<Int> = [0, 1, 2]; if (item._itemIndex == ItemDatabase.ITEM_FRUIT_BUGS) { critterColorIndexes = [6, 7, 8]; } else if (item._itemIndex == ItemDatabase.ITEM_MARSHMALLOW_BUGS) { critterColorIndexes = [9, 10, 11]; } else if (item._itemIndex == ItemDatabase.ITEM_SPOOKY_BUGS) { critterColorIndexes = [12, 13, 14]; } for (critterIndex in 0...3) { var critter:Critter = new Critter(itemX + 49 + critterOffsetsX[critterIndex], itemY + 160 + critterOffsetsY[critterIndex], _bgSprite); critter.setColor(Critter.CRITTER_COLORS[critterColorIndexes[critterIndex]]); critter.setImmovable(true); // don't let them run around _critterToItemMap[critter] = item; addCritter(critter); _itemSpriteToItemMap[critter._bodySprite] = item; } } else { var spriteGraphic:String = item.getItemType().shopImage; var itemSprite:FlxSprite = addItemGraphic(spriteGraphic, itemX, itemY); _itemSpriteToItemMap.set(itemSprite, shopItems[i]); if (item._itemIndex == ItemDatabase.ITEM_VANISHING_GLOVES) { // alpha oscillates for vanishing gloves FlxTween.tween(itemSprite, {alpha:0.6}, 2, {type:FlxTweenType.PINGPONG, ease:FlxEase.sineInOut}); } } i++; } i = 0; for (item in shopItems) { var priceTag:FlxSprite = new FlxSprite(); priceTag.loadGraphic(AssetPaths.shop_pricetag__png, true, 100, 64); priceTag.x = 391.5 - 61.5 * shopItems.length + 123 * i + FlxG.random.int( -5, 5); priceTag.y = 272 - priceTag.height + FlxG.random.int( -3, 3); if (i == 0 && shopItems.length > 1) { priceTag.animation.frameIndex = 2; } else if (i == 4) { priceTag.animation.frameIndex = 4; } var sale:Bool = item._discount >= 5 || item._discount <= -5; add(priceTag); var priceText:FlxText = new FlxText(priceTag.x - 1, priceTag.y + priceTag.height - 30, priceTag.width, "", 20); priceText.text = Std.string(item.getPrice()) + "$"; priceText.alignment = "center"; priceText.color = 0x52492e; priceText.font = AssetPaths.hardpixel__otf; add(priceText); if (sale) { var saleText:FlxText = new FlxText(priceText.x, priceText.y - 24, priceTag.width, "SALE!", 20); saleText.alignment = "center"; saleText.color = 0xeae8de; saleText.font = AssetPaths.hardpixel__otf; add(saleText); // sale sign priceTag.animation.frameIndex++; priceText.color = 0xeae8de; } i++; } if (ItemDatabase._kecleonPresent) { setHeracrossHere(false); setKecleonHere(true); } else { setHeracrossHere(true); setKecleonHere(false); } setAbraHere(false); setSandslashHere(false); _backButton = SexyState.newBackButton(back); add(_backButton); _cashWindow = new CashWindow(true); _cashWindow._autoHide = false; add(_cashWindow); _dialogger = new Dialogger(); add(_dialogger); _handSprite = new FlxSprite(100, 100); CursorUtils.initializeHandSprite(_handSprite, AssetPaths.hands__png); _handSprite.setSize(3, 3); _handSprite.offset.set(69, 87); add(_handSprite); add(new CheatCodes(cheatCodeCallback)); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (ItemDatabase._kecleonPresent) { if (PlayerData.keclGift == 1) { KecleonDialog.receivedGift(tree); PlayerData.keclGift = 2; } else if (PlayerData.keclStoreChat % 2 == 0) { if (PlayerData.keclStoreChat == 10) { // kecleon intro dialog; KecleonDialog.firstTimeInShop(tree); } else { // regular kecleon dialog var chats:Array<Dynamic> = [ KecleonDialog.shopIntro0, KecleonDialog.shopIntro1, KecleonDialog.shopIntro2, KecleonDialog.shopIntro3, KecleonDialog.shopIntro4, KecleonDialog.shopIntro5 ]; var chat:Dynamic = chats[FlxG.random.int(0, chats.length - 1)]; chat(tree); } PlayerData.keclStoreChat++; } } else { // heracross dialog... if (PlayerData.playerIsInDen) { // just returning from den! No dialog } else if (PlayerData.keclStoreChat >= 10 && PlayerData.keclStoreChat < 20) { HeraShopDialog.howWasKecleon(tree); PlayerData.keclStoreChat += 10; } else if (!PlayerData.startedTaping) { if (PlayerData.videoStatus != PlayerData.VideoStatus.Empty) { // first time HeraShopDialog.firstVideo(tree); } } else if (ItemDatabase.isMagnezonePresent() && !PlayerData.startedMagnezone) { MagnDialog.magnShopIntro(tree); PlayerData.startedMagnezone = true; } else if (ItemDatabase.isMagnezonePresent() && (PlayerData.magnButtPlug > 0 && PlayerData.magnButtPlug % 2 == 0)) { // advance butt plug chat sequence if (PlayerData.magnButtPlug == 2) { MagnDialog.shopPlug0(tree); } else if (PlayerData.magnButtPlug == 4) { MagnDialog.shopPlug1(tree); } else if (PlayerData.magnButtPlug == 6) { MagnDialog.shopPlug2(tree); } PlayerData.magnButtPlug++; } else if (PlayerData.videoStatus != PlayerData.VideoStatus.Empty) { var chats:Array<Dynamic> = [HeraShopDialog.videoReward0, HeraShopDialog.videoReward1, HeraShopDialog.videoReward2, HeraShopDialog.videoReward3]; var chat:Dynamic = chats[FlxG.random.int(0, chats.length - 1)]; if (PlayerData.videoCount == PlayerData.pokeVideos.length) { // first time... chat = HeraShopDialog.firstVideoReward; } chat(tree); } } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); PlayerData.playerIsInDen = false; } function isDenDoorOpen():Bool { if (PlayerData.denProf == -1) { // haven't played with a pokemon today; den door is closed return false; } if (PlayerData.denProf == PlayerData.PROF_PREFIXES.indexOf("abra") && PlayerData.abraChats[0] == 6) { // just beat the game; den door is closed return false; } if (PlayerData.denProf == PlayerData.PROF_PREFIXES.indexOf("abra") && PlayerData.abraStoryInt == 4) { // abra's pissed off; den door is closed return false; } if (PlayerData.MINIGAME_CLASSES[PlayerData.denMinigame] == null) { /* * den minigame is not specified; this shouldn't really happen, but * the game could crash if we don't prevent this */ return false; } return true; } public function addCritter(critter:Critter, pushToCritterList:Bool = true) { _targetSprites.add(critter._targetSprite); _midInvisSprites.add(critter._soulSprite); _midSprites.add(critter._bodySprite); _midSprites.add(critter._headSprite); _midSprites.add(critter._frontBodySprite); _critterShadowGroup.makeShadow(critter._bodySprite); _critters.push(critter); } public function removeCritter(critter:Critter, pushToCritterList:Bool = true) { _targetSprites.remove(critter._targetSprite, true); _midInvisSprites.remove(critter._soulSprite, true); _midSprites.remove(critter._bodySprite, true); _midSprites.remove(critter._headSprite, true); _midSprites.remove(critter._frontBodySprite, true); _critters.remove(critter); } function addItemGraphic(spriteGraphic:String, itemX:Float, itemY:Float):FlxSprite { var newItemImage:FlxSprite = new FlxSprite(itemX, itemY); newItemImage.loadGraphic(spriteGraphic, true, 120, 200); _itemSprites.add(newItemImage); var shadowKey:String = StringTools.replace(spriteGraphic, ".png", "-shadow.png"); if (Assets.exists(shadowKey)) { var newShadowImage:FlxSprite = new FlxSprite(itemX, itemY); newShadowImage.loadGraphic(shadowKey, true, 120, 200); _shadowGroup.add(newShadowImage); _shadowMap[newShadowImage] = newItemImage; } return newItemImage; } override public function destroy():Void { super.destroy(); _handSprite = FlxDestroyUtil.destroy(_handSprite); _itemSprites = FlxDestroyUtil.destroy(_itemSprites); _cashWindow = FlxDestroyUtil.destroy(_cashWindow); _dialogger = FlxDestroyUtil.destroy(_dialogger); } private function getClickedItem():FlxSprite { var satellite:FlxSprite = new FlxSprite(_handSprite.x, _handSprite.y); satellite.makeGraphic(Std.int(_handSprite.width), Std.int(_handSprite.height)); var clickedItem:FlxSprite = null; for (item in _itemSprites.members) { if (item.alive && FlxG.pixelPerfectOverlap(satellite, item, 40)) { return item; } } if (FlxG.mouse.y > 180) { for (item in _itemSprites.members) { if (item.alive && FlxSpriteKludge.overlap(satellite, item)) { return item; } } } { var offsetPoint:FlxPoint = FlxPoint.get(FlxG.mouse.x, FlxG.mouse.y); offsetPoint.y += 10; var minDistance:Float = 40; var closestCritter:Critter = null; for (critter in _critters) { var distance:Float = critter._bodySprite.getMidpoint().distanceTo(offsetPoint); if (distance < minDistance) { minDistance = distance; closestCritter = critter; } } offsetPoint.put(); if (closestCritter != null) { return closestCritter._bodySprite; } } return null; } override public function update(elapsed:Float):Void { super.update(elapsed); PlayerData.updateTimePlayed(); if (FlxG.mouse.justPressed) { PlayerData.updateCursorVisible(); } _handSprite.setPosition(FlxG.mouse.x, FlxG.mouse.y); if (DialogTree.isDialogging(_dialogTree)) { _backButton.visible = false; _cashWindow.setShopText(true); } else { _backButton.visible = true; _cashWindow.setShopText(false); } if (!DialogTree.isDialogging(_dialogTree)) { if (isDenDoorOpen()) { // mouseover door... if (FlxG.mouse.getPosition().distanceTo(FlxPoint.weak(146, 38)) <= 115) { _bgSprite.animation.frameIndex = 2; _denArrow.visible = true; } else { _bgSprite.animation.frameIndex = 1; _denArrow.visible = false; } } } if (ItemDatabase._kecleonPresent) { if (DialogTree.isDialogging(_dialogTree) && _keclSprites[0].animation.name == "slouch") { _kecleonPoseTimer += elapsed; if (_kecleonPoseTimer > 0.5) { _kecleonPoseTimer = 0; for (keclSprite in _keclSprites) { keclSprite.animation.play("unslouch"); } } } else if (!DialogTree.isDialogging(_dialogTree) && _keclSprites[0].animation.name == "unslouch") { _kecleonPoseTimer += elapsed; if (_kecleonPoseTimer > 1.5) { _kecleonPoseTimer = 0; for (keclSprite in _keclSprites) { keclSprite.animation.play("slouch"); } } } } if (FlxG.mouse.justPressed && !DialogTree.isDialogging(_dialogTree) && !_dialogger._handledClick) { if (_bgSprite.animation.frameIndex == 2) { // clicked door? var profPrefix:String = PlayerData.PROF_PREFIXES[PlayerData.denProf]; var profName:String = PlayerData.PROF_NAMES[PlayerData.denProf]; var profMale:Bool = Reflect.field(PlayerData, profPrefix + "Male"); var tree:Array<Array<Object>> = new Array<Array<Object>>(); if (ItemDatabase.isKecleonPresent()) { tree[0] = ["#kecl13#D'ehh, whaddaya you think you're doin'? You can't go back there. Employees only!"]; } else if (PlayerData.cursorType == "none") { // you can't come in the den; you're injured! tree[0] = ["#hera10#<name>, what happened!?! ...You should probably see if Abra can fix you..."]; } else { var minigameDesc:String = PlayerData.MINIGAME_DESCRIPTIONS[PlayerData.denMinigame]; if (PlayerData.denVisitCount == 0) { // first visit is free... tree[0] = ["#hera04#Oh, " + profName + "'s hanging out in the den right now. And I think we've got " + minigameDesc + " set up back there if you want to practice."]; tree[1] = ["#hera06#...Since it's just for practice, he can't give out too many gems for playing. But what do you think, do you want to go back there and play with " + profName + "?"]; tree[2] = [10, 30]; tree[10] = ["Yes"]; tree[11] = ["%buyden%"]; tree[12] = ["#hera02#Oooh! Have fun~"]; tree[13] = ["%den%"]; tree[30] = ["No"]; if (PlayerData.denProf == 2) { // heracross tree[0] = ["#hera03#Oh, I think the den's empty right now! But we've got " + minigameDesc + " set up in there if you want to practice with meeeee~"]; tree[1] = ["#hera06#...Since it's just for practice, I can't give out too many gems for playing. But what do you think, do you want to go back there and practice with me?"]; tree[12] = ["#hera02#Weeeeeeeee! Plaaaytiiime with " + stretch(PlayerData.name) + "~"]; } else if (!profMale) { DialogTree.replace(tree, 1, "practice, he", "practice, she"); } } else if (PlayerData.denVisitCount == 1) { // second visit starts costing money, which we explain tree[0] = ["#hera11#Ack! Sorry, Abra said I have to start charging you to hang out with Pokemon in the den. I guess he's worried you'll stay holed up in there forever instead of solving puzzles..."]; tree[1] = ["#hera06#...Although he didn't say how MUCH I had to charge so... loophoooole! Gweh-heheheh~"]; tree[2] = ["#hera05#So yeah, don't worry, I'll make it super cheap for you! ...Just think of it as one of the benefits of our friendship."]; tree[3] = ["#hera00#Mmm! A friendship with benefits. I could used to something like that, <name>~"]; tree[4] = ["#hera04#...Anyway, " + profName + "'s hanging out in the den right now. And I think we've got " + minigameDesc + " set up back there."]; tree[5] = ["#hera06#You can play with him but I'll have to charge you, oh... let's say " + moneyString(PlayerData.denCost) + ". Does that sound fair?"]; if (FlxG.random.bool()) { tree[6] = [10, 20, 30]; } else { tree[6] = [10, 30, 20]; } if (PlayerData.cash < PlayerData.denCost) { // can't afford... tree[6][0] = 50; } tree[10] = ["Yes"]; tree[11] = ["%buyden%"]; tree[12] = ["#hera02#Oooh! Have fun~"]; tree[13] = ["%den%"]; tree[20] = [FlxG.random.getObject(["Oh, it's only\n" + profName+"...", moneyString(PlayerData.denCost) + " seems\nlike a lot...", "I can see\n" + (profMale ? "him" : "her") + " for free\nlater..."])]; tree[30] = ["No"]; tree[50] = ["Yes...?"]; tree[51] = ["#hera08#Aww raspberries! Looks like you're a little short on money..."]; if (PlayerData.denProf == 2) { // heracross tree[4] = ["#hera03#...Anyway, I think the den's empty right now! But we've got " + minigameDesc + " set up in there if you want to practice with meeeee~"]; tree[5] = ["#hera06#I apparently have to charge you SOMETHING, but ohh... let's just make it " + moneyString(PlayerData.denCost) + ". What do you say?"]; tree[12] = ["#hera02#Weeeeeeeee! Plaaaytiiime with " + stretch(PlayerData.name) + "~"]; tree[20] = [FlxG.random.getObject(["Oh, I thought\nsomeone was\nin there...", moneyString(PlayerData.denCost) + " seems\nlike a lot...", "I'm really\njust here\nto shop..."])]; } else if (!profMale) { DialogTree.replace(tree, 5, "with him", "with her"); } if (!PlayerData.abraMale) { DialogTree.replace(tree, 0, "guess he's", "guess she's"); DialogTree.replace(tree, 1, "Although he", "Although she"); } } else { // third and subsequent visits continue costing money; no explanation necessary tree[0] = ["#hera04#Oh, " + profName + "'s hanging out in the den right now. And I think we've got " + minigameDesc + " set up back there."]; tree[1] = ["#hera06#You can play with him but I'll have to charge you, oh... let's say " + moneyString(PlayerData.denCost) + ". Does that sound fair?"]; if (FlxG.random.bool()) { tree[2] = [10, 20, 30]; } else { tree[2] = [10, 30, 20]; } if (PlayerData.cash < PlayerData.denCost) { // can't afford... tree[2][0] = 50; } tree[10] = ["Yes"]; tree[11] = ["%buyden%"]; tree[12] = ["#hera02#Oooh! Have fun~"]; tree[13] = ["%den%"]; tree[20] = [FlxG.random.getObject(["Oh, it's only\n" + profName+"...", moneyString(PlayerData.denCost) + " seems\nlike a lot...", "I can see\n" + (profMale ? "him" : "her") + " for free\nlater..."])]; tree[30] = ["No"]; tree[50] = ["Yes...?"]; tree[51] = ["#hera08#Aww raspberries! Looks like you're a little short on money..."]; if (PlayerData.denProf == 2) { // heracross tree[0] = ["#hera03#Oh, I think the den's empty right now! But we've got " + minigameDesc + " set up in there if you want to practice with meeeee~"]; tree[1] = ["#hera06#Of course I'll have to charge you, oh... let's say " + moneyString(PlayerData.denCost) + ". What do you say?"]; tree[12] = ["#hera02#Weeeeeeeee! Plaaaytiiime with " + stretch(PlayerData.name) + "~"]; tree[20] = [FlxG.random.getObject(["Oh, I thought\nsomeone was\nin there...", moneyString(PlayerData.denCost) + " seems\nlike a lot...", "I'm really\njust here\nto shop..."])]; } else if (!profMale) { DialogTree.replace(tree, 1, "with him", "with her"); } } } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } else { // clicked item to purchase? _clickedItemSprite = getClickedItem(); if (_clickedItemSprite != null && _clickedItemSprite == _crackerSprite) { var tree:Array<Array<Object>> = new Array<Array<Object>>(); HeraShopDialog.justCrackers(tree, ++_crackerClickCount); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } if (_clickedItemSprite != null && _itemSpriteToItemMap.exists(_clickedItemSprite)) { handleClickedItem(); } } } for (shadowSprite in _shadowGroup) { if (_shadowMap.exists(shadowSprite)) { var targetSprite:FlxSprite = _shadowMap.get(shadowSprite); shadowSprite.alive = targetSprite.alive; shadowSprite.exists = targetSprite.exists; shadowSprite.animation.frameIndex = targetSprite.animation.frameIndex; shadowSprite.visible = targetSprite.visible; shadowSprite.alpha = targetSprite.alpha; } } _midSprites.sort(LevelState.byYNulls); } private function handleClickedItem():Void { var clickedItem:ItemDatabase.ShopItem = _itemSpriteToItemMap.get(_clickedItemSprite); var itemName = clickedItem.getItemType().name; var itemPrice = clickedItem.getPrice(); var tree:Array<Array<Object>>; if (ItemDatabase.isKecleonPresent()) { if (Std.isOfType(clickedItem, ItemDatabase.TelephoneShopItem)) { // kecleon telephone dialog tree = []; KecleonDialog.phoneCall(tree, cast(clickedItem)); } else if (Std.isOfType(clickedItem, ItemDatabase.MysteryBoxShopItem)) { // kecleon mystery box dialog tree = []; KecleonDialog.mysteryBox(tree, cast(clickedItem)); } else { // brain-damaged kecleon dialog tree = BadItemDescriptions.describe(clickedItem); DialogTree.shift(tree, 100, 196, 2); DialogTree.shift(tree, 200, 297, 1); DialogTree.shift(tree, 500, 597, 1); if (tree[0] == null) { tree[0] = ["#kecl06#I ehhh, I don't know what that is. ...Looks like it costs " + itemPrice + "$. Did you want it? Or..."]; } var purchaseChoices:Array<Object> = itemPrice <= PlayerData.cash ? [100, 200, 300] : [500, 200, 300]; { var i:Int = 99; while (tree[i] == null) { i--; } tree[i + 1] = purchaseChoices; } tree[100] = ["Yes"]; tree[101] = ["%buy%"]; if (tree[102] == null) { tree[102] = ["#kecl03#Ayy! I made a sale~"]; } tree[200] = ["No"]; if (tree[300] == null) { tree[300] = ["You...\ndon't know??"]; tree[301] = ["#kecl08#I dunno, it looks sorta like it might be some kinda... electronic... like, one of those things that listens to your voice?"]; tree[302] = ["#kecl06#Or ehh... Maybe a vehicle, for a really tiny animal. You know, what that don't got no legs or somethin'."]; tree[303] = ["#kecl05#Well whatever it is... it's " + moneyString(itemPrice) + "$. Is that okay? You want it for " + moneyString(itemPrice) + "$?"]; } { var i:Int = 399; while (tree[i] == null) { i--; } tree[i + 1] = purchaseChoices; } tree[500] = ["Yes...?"]; tree[501] = ["#kecl12#Ayy I ain't runnin' a charity here! ...Go get more money."]; } } else { // regular heracross dialog tree = new Array<Array<Object>>(); var dialog:Dynamic = clickedItem.getItemType().dialog; if (dialog != null) { dialog(tree, itemPrice); DialogTree.shift(tree, 100, 196, 2); DialogTree.shift(tree, 200, 297, 1); DialogTree.shift(tree, 500, 597, 1); } if (tree[0] == null) { tree[0] = ["#hera05#That's a " + itemName + "! Did you want to buy it for " + itemPrice + "$?"]; } var purchaseChoices:Array<Object> = itemPrice <= PlayerData.cash ? [100, 200, 300] : [500, 200, 300]; // 400 is a choice presented to the player when buying the item if (tree[400] != null) { purchaseChoices.push(400); } var afterPurchaseChoices:Array<Object> = purchaseChoices.copy(); // 450 is a choice presented to the player after being told about the item if (tree[450] != null) { afterPurchaseChoices.push(450); } if (clickedItem.getItemType().index == ItemDatabase.ITEM_VIBRATOR && ItemDatabase.isMagnezonePresent()) { // vibrator dialog doesn't let you repeat the incriminating thing heracross says afterPurchaseChoices.remove(300); } { var i:Int = 99; while (tree[i] == null) { i--; } tree[i + 1] = purchaseChoices; } tree[100] = ["Yes"]; if (Std.isOfType(clickedItem, ItemDatabase.TelephoneShopItem)) { // don't append %buy% dialog thing; telephone is weird tree[101] = ["%noop%"]; } else { tree[101] = ["%buy%"]; } if (tree[102] == null) { tree[102] = ["#hera02#Here you go!"]; } tree[200] = ["No"]; if (tree[300] == null) { tree[300] = [itemName + "?"]; tree[301] = ["#hera03#" + itemName + " is really placeholdery!"]; tree[302] = ["#hera04#You really can't do any placeholding without " + itemName + "."]; tree[303] = ["#hera05#Did you want to buy " + itemName + " for " + itemPrice + "$?"]; } { var i:Int = 399; while (tree[i] == null) { i--; } tree[i + 1] = afterPurchaseChoices; } if (tree[400] != null) { var i:Int = 449; while (tree[i] == null) { i--; } tree[i + 1] = afterPurchaseChoices; } if (tree[450] != null) { var i:Int = 499; while (tree[i] == null) { i--; } tree[i + 1] = afterPurchaseChoices; } tree[500] = ["Yes...?"]; tree[501] = ["#hera09#...Oops! You can't quite afford it yet."]; } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } public function cheatCodeCallback(Code:String) { var threeCode:String = Code.substring(Code.length - 3, Code.length); var fourCode:String = Code.substring(Code.length - 4, Code.length); var fiveCode:String = Code.substring(Code.length - 5, Code.length); #if debug if (fiveCode == "CHEAT") { PlayerData.cheatsEnabled = !PlayerData.cheatsEnabled; if (PlayerData.cheatsEnabled) { FlxSoundKludge.play(AssetPaths.rank_up_00C4__mp3); } else { FlxSoundKludge.play(AssetPaths.rank_down_00C5__mp3); } } #end if (PlayerData.cheatsEnabled) { if (StringTools.startsWith(fiveCode, "BOX")) { if (ItemDatabase._mysteryBoxStatus <= 0) { // not doing mystery boxes yet... } else { var index:Null<Int> = Std.parseInt(fiveCode.substring(3, 5)); if (index != null) { if (index == 0) { if (ItemDatabase._mysteryBoxStatus > 0) { ItemDatabase._mysteryBoxStatus = 0; populateShopFromCheat(0, 0); FlxG.switchState(new ShopState()); } } else if (index >= 1) { ItemDatabase._shopItems.splice(0, ItemDatabase._shopItems.length); ItemDatabase._mysteryBoxStatus = index; ItemDatabase.refillItems(); // force refresh PlayerData.cash += ItemDatabase._shopItems[0].getPrice(); FlxG.switchState(new ShopState()); } } } } if (threeCode == "ZXC") { // cheat ItemDatabase._prevRefillTime = null; ItemDatabase.refillShop(); FlxG.switchState(new ShopState()); } if (StringTools.startsWith(threeCode, "Z")) { var index:Null<Int> = Std.parseInt(threeCode.substring(1, 3)); if (index != null) { populateShopFromCheat(index * 4, index * 4 + 3); FlxG.switchState(new ShopState()); } } if (fourCode == "MAG0") { ItemDatabase._magnezoneStatus = ItemDatabase.MagnezoneStatus.Absent; FlxG.switchState(new ShopState()); } if (fourCode == "MAG1") { ItemDatabase._magnezoneStatus = ItemDatabase.MagnezoneStatus.Angry; FlxG.switchState(new ShopState()); } if (fourCode == "MAG2") { ItemDatabase._magnezoneStatus = ItemDatabase.MagnezoneStatus.Suspicious; FlxG.switchState(new ShopState()); } if (fourCode == "MAG3") { ItemDatabase._magnezoneStatus = ItemDatabase.MagnezoneStatus.Calm; FlxG.switchState(new ShopState()); } if (fourCode == "MAG4") { ItemDatabase._magnezoneStatus = ItemDatabase.MagnezoneStatus.Happy; FlxG.switchState(new ShopState()); } } } function populateShopFromCheat(minItemIndex:Int, maxItemIndex:Int) { // remove existing items... while (ItemDatabase._shopItems.length > 0) { var shopItem:ItemDatabase.ShopItem = ItemDatabase._shopItems.pop(); ItemDatabase._warehouseItemIndexes.push(shopItem._itemIndex); } // populate shop with four chosen items for (itemIndex in minItemIndex...maxItemIndex + 1) { // refund money as necessary if (ItemDatabase._playerItemIndexes.indexOf(itemIndex) >= 0) { PlayerData.cash += ItemDatabase._itemTypes[itemIndex].basePrice; } var playerHadItem:Bool = ItemDatabase._playerItemIndexes.remove(itemIndex); ItemDatabase._warehouseItemIndexes.remove(itemIndex); if (itemIndex < ItemDatabase._itemTypes.length && !ItemDatabase.isLocked(itemIndex)) { ItemDatabase._shopItems.push(new ItemDatabase.ShopItem(itemIndex)); } if (playerHadItem && (itemIndex == ItemDatabase.ITEM_MAGNETIC_DESK_TOY || itemIndex == ItemDatabase.ITEM_RETROPIE)) { // refunded gift; fix luckyProfSchedules so characters don't show up as often PlayerDataNormalizer.normalizeLuckyProfSchedules(); } } } public function dialogTreeCallback(line:String):String { if (line == "%buy%") { // yes, buy the item FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); _justPurchasedSprite = _clickedItemSprite; var item:ItemDatabase.ShopItem = _itemSpriteToItemMap.get(_clickedItemSprite); ItemDatabase._shopItems.remove(item); if (Std.isOfType(item, ItemDatabase.TelephoneShopItem)) { // do nothing } else if (Std.isOfType(item, ItemDatabase.MysteryBoxShopItem)) { ItemDatabase._mysteryBoxStatus++; } else if (item._itemIndex == PlayerData.grimEatenItem) { PlayerData.grimEatenItem = -1; } else { ItemDatabase._playerItemIndexes.push(item._itemIndex); } PlayerData.cash -= item.getPrice(); if (Std.isOfType(_clickedItemSprite, CritterBody)) { var crittersToRemove:Array<Critter> = []; for (critter in _critterToItemMap.keys()) { if (_critterToItemMap[critter] == item) { crittersToRemove.push(critter); } } for (critterToRemove in crittersToRemove) { removeCritter(critterToRemove); _critterToItemMap.remove(critterToRemove); FlxDestroyUtil.destroy(critterToRemove); } } else { _clickedItemSprite.kill(); } } if (line == "%buyden%") { if (PlayerData.denVisitCount == 0) { // first visit is free } else { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.cash -= PlayerData.denCost; } _dialogTree.appendSkipToActiveDialog("%den%"); // ensure player goes to den, even if they click "skip" } if (line == "%den%") { PlayerData.profIndex = PlayerData.denProf; PlayerData.playerIsInDen = true; // after the player leaves the den (or shuts down flash) the den professor is no longer there. PlayerData.denProf = -1; PlayerData.denVisitCount++; var minigameState:MinigameState = MinigameState.fromInt(PlayerData.denMinigame); FlxG.switchState(minigameState); } if (line == "%enterabra%" || line == "%exitabra%") { setAbraHere(line == "%enterabra%"); } if (line == "%entersand%" || line == "%exitsand%") { setSandslashHere(line == "%entersand%"); } if (StringTools.startsWith(line, "%pokemon-libido-")) { PlayerData.pokemonLibido = Std.parseInt(substringBetween(line, "%pokemon-libido-", "%")); PlayerData.pokemonLibido = Std.int(FlxMath.bound(PlayerData.pokemonLibido, 1, 7)); } if (StringTools.startsWith(line, "%pokemon-libboost-")) { var boostAmount:Int = Std.parseInt(substringBetween(line, "%pokemon-libboost-", "%")); for (profIndex in 0...PlayerData.professors.length) { var fieldName:String = PlayerData.PROF_PREFIXES[PlayerData.professors[profIndex]] + "Reservoir"; var reservoir:Int = Reflect.field(PlayerData, fieldName); Reflect.setField(PlayerData, fieldName, Math.min(210, reservoir + boostAmount)); } } if (StringTools.startsWith(line, "%peg-activity-")) { PlayerData.pegActivity = Std.parseInt(substringBetween(line, "%peg-activity-", "%")); PlayerData.pegActivity = Std.int(FlxMath.bound(PlayerData.pegActivity, 1, 7)); } if (line == "%set-started-taping%") { PlayerData.startedTaping = true; PlayerData.videoStatus = PlayerData.VideoStatus.Empty; } if (line == "%pay-videos%") { if (PlayerData.videoStatus != PlayerData.VideoStatus.Empty) { FlxSoundKludge.play(AssetPaths.cash_get_0037__mp3, 0.7); PlayerData.payVideos(); } } if (line == "%reset-sandphone%") { PlayerData.sandPhone = 0; } if (StringTools.startsWith(line, "%crackers")) { if (_crackerSprite == null) { _crackerSprite = addItemGraphic(AssetPaths.just_crackers_shop__png, _justPurchasedSprite.x, _justPurchasedSprite.y); } _crackerSprite.animation.frameIndex = Std.parseInt(substringBetween(line, "%crackers", "%")); } if (StringTools.startsWith(line, "%call-")) { var prefix:String = substringBetween(line, "%call-", "%"); if (prefix == "sand") { PlayerData.sandPhone = 5; PlayerData.sandSexyBeforeChat = 5; PlayerData.appendChatHistory("hera.callSandslash"); } else { PlayerData.luckyProfSchedules.splice(PlayerData.luckyProfSchedules.lastIndexOf(PlayerData.PROF_PREFIXES.indexOf(prefix)), 1); PlayerData.luckyProfSchedules.insert(1, PlayerData.PROF_PREFIXES.indexOf(prefix)); } } if (StringTools.startsWith(line, "%gift-")) { var prefix:String = substringBetween(line, "%gift-", "%"); if (prefix == "magn") { PlayerData.magnGift = 1; PlayerData.luckyProfSchedules.insert(1, PlayerData.PROF_PREFIXES.indexOf("magn")); PlayerDataNormalizer.normalizeLuckyProfSchedules(); if (PlayerData.magnChats[0] < MagnDialog.fixedChats.length) { PlayerData.magnChats.insert(0, FlxG.random.int(MagnDialog.fixedChats.length, 99)); } } else if (prefix == "kecl") { PlayerData.keclGift = 1; PlayerData.luckyProfSchedules.insert(1, PlayerData.PROF_PREFIXES.indexOf("hera")); PlayerDataNormalizer.normalizeLuckyProfSchedules(); if (PlayerData.smeaChats[0] < SmeargleDialog.fixedChats.length) { PlayerData.smeaChats.insert(0, FlxG.random.int(SmeargleDialog.fixedChats.length, 99)); } } else if (prefix == "grim") { PlayerData.luckyProfSchedules.insert(1, PlayerData.PROF_PREFIXES.indexOf("grim")); PlayerDataNormalizer.normalizeLuckyProfSchedules(); } else if (prefix == "luca") { PlayerData.rhydGift = 1; PlayerDataNormalizer.normalizeLuckyProfSchedules(); if (PlayerData.rhydChats[0] < RhydonDialog.fixedChats.length) { PlayerData.rhydChats.insert(0, FlxG.random.int(RhydonDialog.fixedChats.length, 99)); } } } if (StringTools.startsWith(line, "%crumbs")) { if (_crumbSprite == null) { _crumbSprite = addItemGraphic(AssetPaths.just_crumbs_shop__png, _justPurchasedSprite.x, _justPurchasedSprite.y); } _crumbSprite.animation.frameIndex = Std.parseInt(substringBetween(line, "%crumbs", "%")); } if (StringTools.startsWith(line, "%gold-key-")) { var valueStr:String = substringBetween(line, "%gold-key-", "%"); if (valueStr == "default") { if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_DIAMOND_PUZZLE_KEY)) { PlayerData.promptSilverKey = PlayerData.promptDiamondKey; PlayerData.promptGoldKey = PlayerData.promptDiamondKey; } else { PlayerData.promptSilverKey = PlayerData.Prompt.Ask; PlayerData.promptGoldKey = PlayerData.Prompt.Ask; } } else { PlayerData.promptSilverKey = Type.createEnum(PlayerData.Prompt, valueStr); PlayerData.promptGoldKey = Type.createEnum(PlayerData.Prompt, valueStr); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_DIAMOND_PUZZLE_KEY)) { if (PlayerData.promptGoldKey == PlayerData.Prompt.AlwaysNo) { // bump diamond down to "no" PlayerData.promptDiamondKey = PlayerData.Prompt.AlwaysNo; } else if (PlayerData.promptGoldKey == PlayerData.Prompt.Ask) { // bump diamond down to "ask" if (PlayerData.promptDiamondKey == PlayerData.Prompt.AlwaysYes) PlayerData.promptDiamondKey = PlayerData.Prompt.Ask; } else if (PlayerData.promptGoldKey == PlayerData.Prompt.AlwaysYes) { // leave diamond alone } } } } if (StringTools.startsWith(line, "%diamond-key-")) { var valueStr:String = substringBetween(line, "%diamond-key-", "%"); if (valueStr == "default") { if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GOLD_PUZZLE_KEY)) { PlayerData.promptDiamondKey = PlayerData.promptGoldKey; } else { PlayerData.promptDiamondKey = PlayerData.Prompt.Ask; } } else { PlayerData.promptDiamondKey = Type.createEnum(PlayerData.Prompt, valueStr); if (ItemDatabase.playerHasItem(ItemDatabase.ITEM_GOLD_PUZZLE_KEY)) { if (PlayerData.promptDiamondKey == PlayerData.Prompt.AlwaysNo) { // leave gold/silver alone } else if (PlayerData.promptDiamondKey == PlayerData.Prompt.Ask) { // bump gold/silver up to "ask" if (PlayerData.promptGoldKey == PlayerData.Prompt.AlwaysNo) PlayerData.promptGoldKey = PlayerData.Prompt.Ask; if (PlayerData.promptSilverKey == PlayerData.Prompt.AlwaysNo) PlayerData.promptSilverKey = PlayerData.Prompt.Ask; } else if (PlayerData.promptDiamondKey == PlayerData.Prompt.AlwaysYes) { // bump gold/silver up to "always yes" PlayerData.promptGoldKey = PlayerData.Prompt.AlwaysYes; PlayerData.promptSilverKey = PlayerData.Prompt.AlwaysYes; } } } } if (line == "") { _cashWindow.setShopText(false); // done; remove abra and sandslash, they should never stick around setAbraHere(false); setSandslashHere(false); } return null; } function setAbraHere(here:Bool) { for (sprite in _abraSprites) { sprite.exists = here; } } function setSandslashHere(here:Bool) { for (sprite in _sandSprites) { sprite.exists = here; } } function setKecleonHere(here:Bool) { for (sprite in _keclSprites) { sprite.exists = here; } } function setHeracrossHere(here:Bool) { for (sprite in _heraSprites) { sprite.exists = here; } } function back() { if (!DialogTree.isDialogging(_dialogTree)) { FlxG.switchState(new MainMenuState()); } } }
argonvile/monster
source/ShopState.hx
hx
unknown
49,588
package; import flixel.system.FlxSound; import flixel.system.FlxSoundGroup; import kludge.FlxSoundKludge; /** * When 20 or 30 of something happens in a game (like 20 bugs jumping into clue * boxes) it's possible for the same sound to get played over and over, which * is OK. But if it's played 2, 3 or 10 times simultaneously it can result in a * 1,000% volume sound effect which is irritating. * * This class prevents sounds from stacking by keeping a list of recently * played sounds, and preventing those from playing for 20 milliseconds. */ class SoundStackingFix { private static var SOUND_SWALLOW_THRESHOLD_MS:Int = 20; private static var lastPlayedMap:Map<String, Float> = new Map<String, Float>(); private function new() { } public static function play(EmbeddedSound:String, Volume:Float = 1, Looped:Bool = false, ?Group:FlxSoundGroup, AutoDestroy:Bool = true, ?OnComplete:Void->Void):FlxSound { var now:Float = MmTools.time(); if (lastPlayedMap[EmbeddedSound] > now) { /* * clock has been messed with; we reset the sfx time to avoid a * scenario where the user sets the clock into the future and back, * and then no sfx ever play again */ lastPlayedMap[EmbeddedSound] = 0; } if (lastPlayedMap[EmbeddedSound] >= now - 20) { // don't play sound; sound played too recently } else { lastPlayedMap[EmbeddedSound] = now; return FlxSoundKludge.play(EmbeddedSound, Volume, Looped, Group, AutoDestroy, OnComplete); } return null; } }
argonvile/monster
source/SoundStackingFix.hx
hx
unknown
1,557
package; import critter.Critter; import critter.Critter.CritterColor; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSort; import puzzle.PuzzleState; import puzzle.RankTracker; /** * The splash screen which is displayed when the player first launches the game. * * It has a few giant bugs, and a hand and a "Monster Mind" sign. */ class SplashScreenState extends FlxTransitionableState { private var shadowGroup:ShadowGroup; private var fgGroup:FlxTypedGroup<FlxSprite>; private var colorCount:Int; private var critterCountMap:Map<Int, Int> = [ 0 => 2, 1 => 3, 2 => 2, 3 => 3, 4 => 2, 5 => 3, 6 => 2, 7 => 3, 8 => 2, 9 => 3, 10 => 4, 11 => 3, 12 => 4, 13 => 3, 14 => 4, 15 => 5, 16 => 4, 17 => 5, 18 => 4, 19 => 5, 20 => 5, 21 => 5, 22 => 6, 23 => 5, 24 => 6, 25 => 7, 26 => 6, 27 => 7, 28 => 8, 29 => 7, 30 => 8, 31 => 9, 32 => 9, 33 => 10, 34 => 10, 35 => 11, 36 => 11, 37 => 12, 38 => 12, 39 => 13, 40 => 13, 41 => 14, 42 => 14, 43 => 15, 44 => 15, 45 => 16, 46 => 17, 47 => 18, 48 => 19, 49 => 20, 50 => 21, 51 => 22, 52 => 23, 53 => 24, 54 => 25, 55 => 26, 56 => 27, 57 => 28, 58 => 29, 59 => 30, 60 => 30, 61 => 30, 62 => 30, 63 => 30, 64 => 30, 65 => 30, ]; public function new() { super(new TransitionData(TransitionType.NONE), MainMenuState.fadeInFast()); } override public function create():Void { Main.overrideFlxGDefaults(); super.create(); var shaderColor:FlxColor; var shaderAlpha:Float; var wealth:Int = MainMenuState.getTotalWealth(); var bgShader:FlxSprite = new FlxSprite(); /* * The background color changes as the player earns more money */ if (wealth >= 80000) { shaderColor = 0xfff6d481; shaderAlpha = (wealth - 80000) / (400000 - 80000); bgColor = 0xff438cb4; } else if (wealth >= 40000) { shaderColor = 0xff438cb4; shaderAlpha = (wealth - 40000) / (80000 - 40000); bgColor = 0xff6e5384; } else { shaderColor = 0xff6e5384; shaderAlpha = (wealth - 0) / (40000 - 0); bgColor = 0xff516951; } bgShader.alpha = FlxMath.bound(shaderAlpha, 0.0, 1.0); bgShader.makeGraphic(FlxG.width, FlxG.height, shaderColor); add(bgShader); var bgSwoosh:FlxSprite = new FlxSprite(); bgSwoosh.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); { var swooshStamp:FlxSprite = new FlxSprite(); swooshStamp.loadGraphic(AssetPaths.splash_bg_swoosh__png, true, FlxG.width, FlxG.height); for (i in 0...3) { if (FlxG.random.bool()) { swooshStamp.animation.frameIndex = FlxG.random.int(0, swooshStamp.animation.frames - 1); swooshStamp.flipX = FlxG.random.bool(); bgSwoosh.stamp(swooshStamp); } } } bgSwoosh.alpha = 0.25; add(bgSwoosh); Critter.initialize(); Critter.shuffleCritterColors(); colorCount = FlxG.random.getObject([3, 4, 4, 5, 5, 6]); FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; shadowGroup = new ShadowGroup(); add(shadowGroup); fgGroup = new FlxTypedGroup<FlxSprite>(); add(fgGroup); addSign(169, 260); /* * The number of bugs increases as the player increases their rank */ var critterCount:Int = 2; var rank:Int = RankTracker.computeAggregateRank(); if (critterCountMap[rank] != null) { critterCount = critterCountMap[RankTracker.computeAggregateRank()]; } else if (rank > 60) { critterCount = 30; } var critterPositions:Array<FlxPoint> = [ new FlxPoint(0.0, 0.0), new FlxPoint(1.0, 0.0), new FlxPoint(4.5, 0.0), new FlxPoint(0.5, 1.0), new FlxPoint(3.8, 1.1), new FlxPoint(0.0, 2.0), new FlxPoint(1.0, 2.0), new FlxPoint(0.5, 3.0), new FlxPoint(4.0, 2.3), new FlxPoint(5.0, 3.0), new FlxPoint(0.0, 4.0), new FlxPoint(1.0, 4.0), new FlxPoint(2.0, 4.0), new FlxPoint(3.0, 4.0), new FlxPoint(4.0, 4.0), new FlxPoint(5.0, 4.0), new FlxPoint(0.5, 5.0), new FlxPoint(1.6, 5.0), new FlxPoint(2.7, 5.0), new FlxPoint(0.0, 6.0), new FlxPoint(1.0, 6.0), new FlxPoint(2.0, 6.0), new FlxPoint(3.0, 6.0), new FlxPoint(4.0, 6.0), new FlxPoint(0.5, 7.0), new FlxPoint(1.5, 7.0), new FlxPoint(2.5, 7.0), new FlxPoint(3.5, 7.0), new FlxPoint(4.5, 7.0), new FlxPoint(5.5, 7.0), ]; if (critterCount < 10) { // avoid outermost critter positions critterPositions = [ new FlxPoint(0.5, 1.0), new FlxPoint(1.0, 2.0), new FlxPoint(0.5, 3.0), new FlxPoint(1.0, 4.0), new FlxPoint(2.0, 4.0), new FlxPoint(3.0, 4.0), new FlxPoint(4.0, 4.0), new FlxPoint(0.5, 5.0), new FlxPoint(1.6, 5.0), new FlxPoint(2.7, 5.0), new FlxPoint(1.0, 6.0), new FlxPoint(2.0, 6.0), new FlxPoint(3.0, 6.0), new FlxPoint(4.0, 6.0), ]; } FlxG.random.shuffle(critterPositions); critterPositions.splice(0, critterPositions.length - critterCount); for (critterPosition in critterPositions) { addCritter(critterPosition.x * 150 + FlxG.random.int( -15, 15) - 75 , critterPosition.y * 60 + FlxG.random.int( -15, 15) + 60 ); } if (PlayerData.cursorType == "none") { // don't add hand; hand is missing } else { addHand(FlxG.random.int(530, 550), 375); } addBox(FlxG.random.int(567, 587), 164); fgGroup.sort(FlxSort.byY); } function addBox(x:Float, y:Float) { var box:FlxSprite = new FlxSprite(x, y, AssetPaths.splash_box__png); box.offset.set(0, 183); fgGroup.add(box); var boxShadow:FlxSprite = new FlxSprite(x, y, AssetPaths.splash_box_shadow__png); boxShadow.offset.set(0, 183); boxShadow.alpha = 0.5; shadowGroup._extraShadows.push(boxShadow); } function addHand(x:Float, y:Float) { var hand:FlxSprite = new FlxSprite(x, y); CursorUtils.initializeCustomHandBouncySprite(hand, AssetPaths.splash_hand__png, 250, 250); hand.offset.set(0, 167); fgGroup.add(hand); var handGuts:FlxSprite = new FlxSprite(x, y + 1, AssetPaths.splash_hand_electronics__png); handGuts.offset.set(0, 167 + 1); fgGroup.add(handGuts); var handLight:FlxSprite = new FlxSprite(x, y + 2, AssetPaths.splash_hand_light__png); handLight.alpha = 0; handLight.offset.set(0, 167 + 2); fgGroup.add(handLight); FlxTween.tween(handLight, {alpha:1}, 2.6, {ease:FlxEase.expoInOut, type:FlxTweenType.PINGPONG}); var handShadow:FlxSprite = new FlxSprite(x, y, AssetPaths.splash_hand_shadow__png); handShadow.offset.set(0, 167); handShadow.alpha = hand.alpha; shadowGroup._extraShadows.push(handShadow); } function addCritter(x:Float, y:Float) { var critterBody:FlxSprite = new FlxSprite(x, y); var colorIndex:Int = FlxG.random.int(0, colorCount - 1); colorIndex = Std.int(FlxMath.bound(colorIndex, 0, Critter.CRITTER_COLORS.length - 1)); var critterColor:CritterColor = Critter.CRITTER_COLORS[colorIndex]; Critter.loadPaletteShiftedGraphic(critterBody, critterColor, AssetPaths.splash_critter_body__png, true, 150, 200); critterBody.offset.set(0, 125); critterBody.animation.frameIndex = FlxG.random.int(0, critterBody.animation.frames); critterBody.flipX = FlxG.random.bool(); fgGroup.add(critterBody); var critterHead:FlxSprite = new FlxSprite(x, y + 1); Critter.loadPaletteShiftedGraphic(critterHead, critterColor, AssetPaths.splash_critter_head__png, true, 150, 200); critterHead.offset.set(0, 125 + 1); critterHead.flipX = critterBody.flipX; var idleAnim:Array<Int> = []; AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2, 3, 4]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [7, 8, 9]); var blinkFrame:Int = FlxG.random.int(0, 15); while (blinkFrame < idleAnim.length) { if (idleAnim[blinkFrame] >= 0 && idleAnim[blinkFrame] <= 4) { idleAnim[blinkFrame] = FlxG.random.getObject([5, 6]); } else if (idleAnim[blinkFrame] >= 7 && idleAnim[blinkFrame] <= 9) { idleAnim[blinkFrame] = FlxG.random.getObject([10, 11]); } blinkFrame += FlxG.random.int(6, 15); } // slide it over a bit AnimTools.shift(idleAnim); critterHead.animation.add("default", idleAnim, Critter._FRAME_RATE); critterHead.animation.play("default"); fgGroup.add(critterHead); var critterShadow:FlxSprite = new FlxSprite(x, y); critterShadow.loadGraphic(AssetPaths.splash_critter_shadow__png, true, 150, 200); critterShadow.offset.set(0, 125); critterShadow.flipX = critterBody.flipX; critterShadow.animation.add("default", idleAnim, Critter._FRAME_RATE); critterShadow.animation.play("default"); shadowGroup._extraShadows.push(critterShadow); } function addSign(x:Float, y:Float) { var sign:FlxSprite = new FlxSprite(x, y, AssetPaths.splash_sign__png); sign.offset.set(0, 260); fgGroup.add(sign); var signShadow:FlxSprite = new FlxSprite(x, y, AssetPaths.splash_sign_shadow__png); signShadow.offset.set(0, 260); shadowGroup._extraShadows.push(signShadow); } override public function update(elapsed:Float):Void { super.update(elapsed); if (FlxG.keys.justPressed.SPACE || FlxG.keys.justPressed.ENTER || FlxG.keys.justPressed.ESCAPE || FlxG.mouse.justPressed) { SoundStackingFix.play(AssetPaths.click1_00cb__mp3, 0.6); if (PlayerData.name == null) { if (PlayerData.puzzleCount[0] <= 2) { PlayerData.level = PlayerData.puzzleCount[0]; } PlayerData.profIndex = PlayerData.PROF_NAMES.indexOf("Grovyle"); PlayerData.difficulty = PlayerData.Difficulty.Easy; FlxG.switchState(new PuzzleState(MainMenuState.fadeInFast())); return; } else { FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } } } override public function destroy():Void { super.destroy(); shadowGroup = FlxDestroyUtil.destroy(shadowGroup); fgGroup = FlxDestroyUtil.destroy(fgGroup); critterCountMap = null; } }
argonvile/monster
source/SplashScreenState.hx
hx
unknown
11,334
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxRect; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import openfl.display.BlendMode; /** * A sprite which makes the screen darker, except for a few elliptical holes. * * This is useful for lighting up certain parts of the screen when trying to * explain puzzles. */ class SpotlightGroup extends FlxSprite { private var buffer:FlxRect = FlxRect.get(-18, -14, 36, 28); private var spotlights:Map<String, Spotlight> = new Map<String, Spotlight>(); private var spotlightsDirty:Bool = false; public function new() { super(0, 0); makeGraphic(FlxG.width, FlxG.height, 0xFF000022); blend = BlendMode.MULTIPLY; } public function addSpotlight(key:String):Void { spotlights[key] = {on:true}; spotlightsDirty = true; } public function removeSpotlight(key:String):Void { if (spotlights[key] != null && spotlights[key].on) { spotlightsDirty = true; } spotlights.remove(key); } public function growSpotlight(key:String, bounds:FlxRect) { if (spotlights[key].rect == null) { spotlights[key].rect = new FlxRect(); spotlights[key].rect.copyFrom(bounds); } else { spotlights[key].rect.union(bounds); } spotlightsDirty = true; } public function refreshSpotlights():Void { FlxSpriteUtil.fill(this, 0xFF000022); for (spotlight in spotlights) { if (spotlight.on && spotlight.rect != null) { FlxSpriteUtil.drawEllipse(this, spotlight.rect.x - 18, spotlight.rect.y - 14, spotlight.rect.width + 36, spotlight.rect.height + 28, FlxColor.WHITE); } } spotlightsDirty = false; } override public function update(elapsed:Float):Void { super.update(elapsed); if (spotlightsDirty) { refreshSpotlights(); } } public function turnOn(which:String) { if (spotlights[which] == null) { throw "invalid light \"" + which + "\""; } spotlights[which].on = true; spotlightsDirty = true; } public function turnOff(which:String) { if (spotlights[which] == null) { throw "invalid light \"" + which + "\""; } spotlights[which].on = false; spotlightsDirty = true; } public function turnOnMany(which:String) { for (key in spotlights.keys()) { if (StringTools.startsWith(key, which)) { turnOn(key); } } } public function turnOffMany(which:String) { for (key in spotlights.keys()) { if (StringTools.startsWith(key, which)) { turnOff(key); } } } public function getBounds(which:String) { return spotlights[which].rect; } public function dimLights(alpha:Float) { for (key in spotlights.keys()) { turnOff(key); } this.alpha = alpha; } public function traceInfo() { for (key in spotlights.keys()) { var str:String = key + " (" + (spotlights[key].on ? "on" : "off") +"): "; if (spotlights[key].rect == null) { str += "null"; } else { str += spotlights[key].rect.toString(); } trace(str); } } override public function destroy():Void { super.destroy(); buffer = FlxDestroyUtil.put(buffer); spotlights = null; } } typedef Spotlight = { ?rect:FlxRect, on:Bool }
argonvile/monster
source/SpotlightGroup.hx
hx
unknown
3,362
package; import flixel.FlxG; import flixel.effects.particles.FlxParticle; /** * When particles which move especially fast relative to the frame rate, for * example 30 pixels per frame, this results in particles being grouped * together at 30 pixel intervals, resulting in an unpleasant bunching effect * * SubframeParticle is an FlxParticle which, when emitted, will behave as * though it was emitted a fraction of a frame earlier to counteract this * bunching effect. */ class SubframeParticle extends FlxParticle { override public function onEmit():Void { var subFrame:Float = Math.random(); x -= velocity.x * FlxG.elapsed * subFrame; y -= velocity.y * FlxG.elapsed * subFrame; } }
argonvile/monster
source/SubframeParticle.hx
hx
unknown
722
package; import MmStringTools.*; import flash.display.BitmapData; import flash.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import openfl.geom.Matrix; import openfl.geom.Point; import openfl.text.TextLineMetrics; import poke.sexy.SexyState; /** * Graphics for the streaming tablet which appears during the sex scenes * * The tablet captures the window graphics periodically, distorts them and * shows them back, and also provides a fake streaming website with chat, * viewer count, and "likes" */ class Tablet extends FlxGroup { private static var MAGN_EMOJIS:Array<Int> = [0, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23]; private static var MALE_EMOJIS:Array<Int> = [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 21, 22, 23]; private static var FEMALE_EMOJIS:Array<Int> = [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 22, 23]; /* * When different pokemon are using toys, the camera defaults to the bottom * of the screen (0.75). if this is unsuitable, this map lets you override * it to the top (0.00) middle (0.50) or far bottom (1.00) */ private static var toyCamMap:Map<String, Float> = [ "buiz" => 0.85, "hera" => 1.00, "luca" => 0.15, "grov" => 0.80, "sand" => 0.90, "magn" => 0.15, ]; /* * Different people's names show up in the chat */ private static var CHAT_NAMES:Array<String> = [ "Matsuku", "benguin", "Krokmou", "Patchhes", "kllza", "Dragonartw", "Yoshils", "PermHunter", "Phosaggro", "rossy105", "Pawn", "HolloNut", "AsterShock", "Fizz", "Kinikini", "Byclosser", "KamekSans", "soopersuus", "LaPatte", "Tiyahn005", "qualske98", "DartakkaNa", "totodice", "mianbao", "Tantroo", "spider111", "Chimaeraw", "Augmented", "uhhhhh", "Eraquis", "Notokottam", "RedChar", "Kiniesttt", "itachi0325", "Soran", "NeoArts", "Dreamous", "Nickelchad", "regls", "tommyzhong", "Toru", "EliValenti", "SkunkJam", "Talahut", "Darkmask", "Porphyrin", "Duez", "Guil", "nutty", "Linkgamer", "Alcubire", "argonvile", "JonNobo", "Asteyr", "wardawn", "yaatsuuu", "jubjun", "MStuarn", "BraeCor", "DarkM64", "Kiniest", "Fandramon", "ashplosh", "GipBandit", "Pepeluis", "Sashaviel", "bombly", "Wolfxz", "Kamezdov", "Komamura", "Furley", "karras", "JetSharky", "Vurnurs", "Ray517", "Seimei2", "ionadragon", "russia213", "Randall", "OR95", "Sharu", "Evan", "Deltads", "AyJay", "Dezo", "Ryin", "lanceness", "LeSkarmory", "Damaratus", "tygre", "N0gard", "Exons", "KeroKamina", "Darkmon", "Lolwut31", "Panshu", "Bolzan", "RyanZard90", "Darkgon", "Angstyteen", "Kilkakon", ]; /* * Long vaguely englishy phrases. These are cut up and rearranged to make * sentences in the chat window */ private static var LONG_PHRASES:Array<String> = [ "Pema cit patute binap ohut edo vit nidisab. Ohimehu", "Moteyi otagerod teto pati ronabe. Egutes tatavil nitir", "Inu cakirab far; ratun pasenen cepisif cetol hena", "Mide ticer ca yeyon ceyap. Tulalil emahosi ge bawog", "Tu racey. Ociletel rigomiey for lale uteyopim adarir", "Ga etukig lugot corimit puyoles. Pol mecedis obato", "Aren neboro tanet? Cediduh se rin lop. Igehil nuci", "Heho fedexes oranes eranita irilol geta, ini sie sida", "Osadara opat ati otilic xecarut! Yo ehacih arieror", "Saca osorare ma runinod edi. Eri onatiyeg re ne ba;", "Neye irokatod tet fivec pi kifolan. Yierel senel gason", "Rinesa nonon yota. Iehikop oler sesiy tielap lie itadilif", "Netelit egamo ale ata togafa. Iewad risepa yatocuf", "Iperinu man irib yi rocieso esie asap saka hibiro.", "Locovu. Qories urecepon olin: Pip penoken yat sesener", "Hayas deniro pa. Nile yomahe nelahor rom ema eruh", "Acierecan ta: Tievucat arinin got cesacec ica minie", "Rihotub bote ceham niyicit lara ro? Gisane neniewi", "Kodeni leturi soteb dape ditagu le. Iyovimis cotib", "Na etu soxo ru sixor opuso; alene lihe obi adatiso", "Rugi nis? Sacihi isut netut orehiegi ekir cecosie re", "Pelec aba gew ime lu gare; ramipit hilovas gun di!", "Toraren egipiwi saced yameri. Asepubec yutaro toreg", "Le calusu xer; pideb keles bod etehehes renup! Ecu", "Ra rec otarim sebosie daseg, sef koni ebug ugaz awema", "Morasag eladonog pet cebap rob marata vet. Cose iratie", "Rap riluk necase lati erirod none. Rokatic yicar reni", "Emeratan lado te cien lines? Riti tomay lud tu besic", "Lir timerad? To raye nor wiesirax atadut lerilen rofeti.", "Rudi he fepatir bigi. Xec male siesimot gerar ro ladie", "Tix yot ditipet sihodo tet. Enase donuce ubo lasomeb", "Colatot rev olod ye ogop ye. Me ner so rieb tuse loloyet", "Tagite. Yer ieta la. Hi ci gocusi! Ogelete riem ecus", "Ociru. Nisopu tu si! Cecitie niciseg iromatas sopug", "Ro esen raleda ye igaceca pepa lah! Ro uronodo idiseta.", "Patel miwi ewodahie cet beme! Nosofib tesic onirem", "Lura. Bat ton leh irohih! Wi te tot derele hepo riereta", "Erodame gixeden sad voleha ma bilofep. Rimesiy tetac", "Naru tac zofih liy cademe gi. Boson serac ivocere", "Ieratili ronad be ler tona mekece! Niesi ciri notise", "Inanune ro napi du eteselo, sica olaw mi reha. Lotud", "Go. Natorol si yadu taf fit erocinib sot su tarerie", "Sa qipeye afar teqi; wake hi siropam bie kesi socit", "Paser ricemi sapacis dime iyinof ce locoseh cud. Hietide", "Sier nan. Ner tere uli buyu avone: Ani sahoriem cobo", "Cah se. Teneli icagejet tatan te saf cocupim se din", "Tatowu. Sebonup uhiva rabap higo oyetan. Elet epiperab", "Celiye ecap ienim niesoni epoto. Ieyi mahadim riper", "Oyamire yaganec mipas rub ca dapene raloye galo? Bohile", "Ici ratene henofi! Otudoka niramah cefac losen netoka", "Ponimix eyona dele tuletar dexo ejar bif posep perate", "Marow fahe inete mu. Neray laba ragev vet paronat de", "Oyela rat tepa. Tulen aranigiv tefa pupeso metere", "Laro sitar peceser babi lip rugay itemi pieser alu.", "Mi nina naha pat nobi. Ges se nere turo geleg, cahol", "Libib tet iebieqemet onori ne isobig gabicam. Iepawiet", "Isor safien ona. Tope ruh tatine rul ile losohac asasici", "Osotatal isunanar focos tinego otepitul conico qa", "Yime hije mige ne: Veg be dayuman uguy! Azawo ole", "Tare toruno. Tiquka gus asiwed iko vovuf cadiseb si.", "Ocelama eneb cipir ker. Ma davome getab va mesom eyiso", "Ce pe nele la heb ta semie, da sac nalesi natareg", "Gesu eru ri izatan xagator ne ilicaye tetix! Sidipob", "Cadi pefebit relon nelit edatafa ehasalit; cot socerov", "Esodir games tariw usibihic! Ade bol iemilot epuc", "Ba atagelas otebie. Redeti mirenep misomad lagitoh", "Sirem tozeku ahes ala gubuh col serutut lif ni ife,", "Le pid iti gere onod ese: Puh awo osiec sehi omiso", "Curale esicac. Minienad canod wun miep sinoci rul", "Pe fi ovar yiy. Neripa huca sin: Cesa no cete onaci", "Sisit sieniye pe; ata fen lie nabilet ogub eda sanusan.", "Hine gus cenier citibus teva nito sonet. Ri vitecit", "Kosedi alebeluk paro cacalac, mag nelapef omilerus", "Deneye teyis pa etaru ebay winehep peku! Camif sanesu", "Tow lebihas nale mesu. Ludepe rudahet ceseno fotak", "Kal lulut surel hu osa: Uhale alofiku galuni parijul", "Calog hinore hietagot nietuli tetiec hienohan. Nimap", "Roweben. Rosuwic anukieces aneso wapil sepo rute gur", "Ecat tu fel nol gitet esoyuger. Elinone api tolilan,", "Eran ruhag. Ce gegumay qodene utotima gosen rinomiev.", "Hanonet abo! Ierel ca va anegicie. Nilal gabe metefi", "Tetes kevat sicuy! Hi meroyas somihen ritira riseme", "Led sir unime. Cudis ipolad so; rotufi tesi got bidir", "Dey ufuraca monenic firih monit die titabo sas. Iba", "Rac cocabu lo se icimahoc turo oluya ladol tinu pe,", "Ietororas cofe luhacut si. Atoti ni niese ieti mod", "Aba irayo oba he ricob necup sidep yir sorieh. Yu seket", "Rarasu sehecer isosu ano. Irenu cieharuc werieca mapa.", "Neceye elilele cufete hoted hoho. Yeyo woxere cumeta", "Ibolasiy esegag ruyi raci. Dasici batim pamem nim love", "Tid. Ocet mirono meta tesud amiy? Qa kene ga nicari", "Waka lal esorap orin edenolic! Cinuna litanec niyiec", "Gudide. Cirot mimieren hito puze bicaga taxeseh ihut?", "Merep etanan tifef? Anotuve nenacil feg. Hiezi tovedov", "Lu arivune ranatab? Rahebox ibat ca lerere liec. Omopehoy", "Puro cekase ofefatan nef ratanot ielera asosil sonag.", "Ifucetis rovani imelos cala icefie rekise ladiehin.", "Fu. Qebuler cipemoc no. Yato sohec ramo hap les te", "Osog emet. Ohelase ge uso ocicef. Mot toteba siyi", "Latit tinemil nese ti. Decitie pine xeyaten amocili", ]; /* * Short spammy phrases, like ascii art and "lol" and things which people * type in chat. */ private static var SPAMMY_PHRASES:Array<String> = [ "OGX", "OGC", "8====D", "8===D~~~", "8=======> ~~~~", "8======D~~~~~~", ":D~~~~~~", "@}~}~~~", "/X\\(‘-‘)/X\\", "/)^3^(\\", "><((((‘>", "(/.__.)/ \\(.__.\\)", "(/.__.)/", "\\(.__.\\)", "<(^^,)>", "(>'-')> <('-'<)", "^('-')^ v('-')v", "(^-^)", "<-|-‘_’-|->", "--{,_,\">", "@( * O * )@", "^O^", ":Q___", "???????", "ooooooooooooo", "E", "R", "7", "me", "<3", ":3", "(<(<>(<>.(<>..<>).<>)<>)>)", "x3", "Hmmmm", ":D", ":P", "^^", "lol", "XD", "BARKBARKBARK", "Raaaaawr", "woof", "SQUAWK", "( o) ( o) - - - - - - (__(__)", "sorry", "Hi!", "WOTT OWO", "OwO", "AYYYY", "i try :3", "69?", "wok", "footjob, eh?", "aww.", "thta's cute", "aye", "',\" ,:- '\"::::::::::::::.::-.-\" `-. ' ,-//", "I do!", "dude.", "Ah true", "fuck", "alright", "super", "good", "yus", "(>'-')> <('-'<) ^('-')^ v('-')v (>'-')> (^-^)", "yup", "AY IT ME", "g'day", "Allo ^^", "^^;", "^^", "thanks", "KY?", ":x", ":$$ seeee$$$Neeee R$$$F$$$$F", ":3", "link?", "^^^^^^^^", "^^^^^^^6", "oops", "666", "Back", "^", ":D", "c-c-c-cumbobreaker", "x3", "__.....__ , .--/~ ~-._ /`", "cheeses? :D", "<w<", ">w>", ">3<", ":>", "Yes :)", "shut up", "oh dear", "x3", ";-;", "^ yes", "omg", "zomg", "plz", "D A R K S O U L S", "yum yum", "/_\\_\\_\\ /_/_/_/_\\ /_\\_\\_\\_\\ /_/_/_/_/_\\", "...", "memes", ";w;", "yup ^^", "gay", "x3", ";.;", ";-;", "^.^", "niiiiice :3", "W T F", "wtf", "yeeeeeeeeeees", "awwww, geeze", "N I I I I I I I I I I I I I I I I I I I I I I C E", ]; private static var CHAT_COLORS:Array<Int> = [ 0xffed684a, // red 0xffe89f16, // orange 0xffffdf00, // yellow 0xff9de721, // spring green 0xff1cd562, // forest green 0xff20e8b2, // aquamarine 0xff3badde, // blue 0xffc57ed9, // purple 0xfffd92eb, // pink 0xff876766, // brown 0xffb99068, // tan brown 0xff696780, // dark grey 0xff858e9a, // light grey ]; private static var MAX_PREV_NAMES:Int = 8; // how many camera frames do we buffer, to create the illusion of stream delay? private static var CAMERA_DELAY:Int = 5; private var loadingSprite:FlxSprite; private var frameCycleCount:Int = 0; private var mx:Matrix = new Matrix(); private var websiteBgGraphic:FlxSprite = new FlxSprite(0, 0, AssetPaths.website_bg__png); private var websiteGraphic:FlxSprite; // pokeCameras[0]=newest camera; pokeCameras[5]=oldest camera private var pokeCameras:Array<FlxSprite> = []; private var tabletScreen:FlxSprite; private var prevNameIndexes:Array<Int> = []; private var textPool:Array<FlxText> = []; private var textPoolIndex:Int = 0; private var texts:Array<FlxText> = []; private var emojiStamp:FlxSprite; private var badgeStamp:FlxSprite; private var textY:Float = 10; private var sexyState:SexyState<Dynamic>; private var visitorText:FlxText; private var randomVisitors:Int = 0; private var thumbText:FlxText; private var cameraPosition:FlxPoint = FlxPoint.get(); private var camRefreshTimer:Float = 0.8; private var screenRefreshTimer:Float = 0; private var newTextTimer:Float = FlxG.random.float(5, 15); private var thumbTimer:Float = FlxG.random.float(4, 12); private var visitorTimer:Float = FlxG.random.float(3, 9); private var thumbCount:Int = 0; private var visitorCount:Int = 0; private var visualThumbCount:Int = 0; private var visualVisitorCount:Int = 0; public function new(sexyState:SexyState<Dynamic>) { super(); this.sexyState = sexyState; var tabletFrame:FlxSprite = new FlxSprite(560, -5, AssetPaths.tablet_frame__png); var tabletShadow:FlxSprite = new FlxSprite(tabletFrame.x, tabletFrame.y, AssetPaths.tablet_shadow__png); tabletShadow.alpha = 0.25; websiteGraphic = new FlxSprite(0, 0); websiteGraphic.loadGraphic(AssetPaths.website_bg__png, false, 0, 0, true); loadingSprite = new FlxSprite(); loadingSprite.loadGraphic(AssetPaths.tablet_loading__png, true, 42, 15); loadingSprite.animation.add("default", [0, 1, 2, 3, 4], 6, true); loadingSprite.animation.play("default"); tabletScreen = new FlxSprite(560, -5); tabletScreen.makeGraphic(220, 160, FlxColor.TRANSPARENT, true); mx.identity(); mx.rotate(Math.PI * 0.012); mx.scale(0.49, 0.46); mx.translate(32, 12); for (i in 0...CAMERA_DELAY + 1) { var pokeCamera:FlxSprite = new FlxSprite(13, 13); pokeCamera.makeGraphic(183, 181, FlxColor.TRANSPARENT, true); pokeCameras.push(pokeCamera); } thumbText = new FlxText(30, 208, 195, commaSeparatedNumber(thumbCount), 30); thumbText.color = 0xff6b6174; thumbText.font = AssetPaths.just_sayin__ttf; visitorText = new FlxText(130, 208, 195, commaSeparatedNumber(visitorCount), 30); visitorText.color = 0xff6b6174; visitorText.bold = true; visitorText.font = AssetPaths.just_sayin__ttf; add(tabletShadow); add(tabletScreen); add(tabletFrame); emojiStamp = new FlxSprite(); emojiStamp.loadGraphic(AssetPaths.emojis__png, true, 11, 11); badgeStamp = new FlxSprite(); badgeStamp.loadGraphic(AssetPaths.badges__png, true, 6, 7); while (prevNameIndexes.length < MAX_PREV_NAMES) { prevNameIndexes.push(FlxG.random.int(0, CHAT_NAMES.length - 1)); } for (i in 0...50) { textPool.push(new FlxText(0, 0, 115)); } } /** * Converts a raw number of hearts into a thumbs-up count which scales exponentially * * @param input how many hearts have been emitted during the sex scene * @param target a magic number whose purpose frightens and confuses me * @return a number vaguely corresponding to a thumbs-up count */ private function adjustForPopularity(input:Float, target:Float):Float { var result:Float = input; if (result >= target) { return result; } if (sexyState.popularity < 0) { // curve which builds slowly towards the target result = target * Math.pow(result / target, 1 - 2 * sexyState.popularity); } else if (sexyState.popularity > 0) { // fans join right away result += (target - result) * sexyState.popularity * 0.5; } return result; } override public function update(elapsed:Float):Void { super.update(elapsed); loadingSprite.update(elapsed); if (visible) { camRefreshTimer -= elapsed; if (camRefreshTimer <= 0) { camRefreshTimer = 0.8; if (DialogTree.isDialogging(sexyState._dialogTree)) { // don't refresh camera; we're dialogging } else if (sexyState._activePokeWindow._canvas.alpha < 1.0) { // don't refresh camera; it looks goofy with partial opacity. (this can happen when mousing over during toy sequences) } else { var pokeCamera:FlxSprite = pokeCameras.pop(); var prefix:String = PlayerData.PROF_PREFIXES[PlayerData.profIndex]; if (sexyState.displayingToyWindow()) { var yFactor:Float = 0.75; // toy window; lock the camera to the bottom cameraPosition.x = (sexyState._activePokeWindow._canvas.x) * 0.5 + (sexyState._activePokeWindow._canvas.x + sexyState._activePokeWindow._canvas.width - 183 - 3) * 0.5; if (toyCamMap[prefix] != null) { yFactor = toyCamMap[prefix]; } cameraPosition.y = (sexyState._activePokeWindow._canvas.y) * (1 - yFactor) + (sexyState._activePokeWindow._canvas.y + sexyState._activePokeWindow._canvas.height - 181 - 3) * yFactor; } else if (FlxG.mouse.x < sexyState._activePokeWindow.x - 10 || FlxG.mouse.x > sexyState._activePokeWindow.x + sexyState._activePokeWindow.width + 10) { // mouse is somewhere weird; lock the camera to the middle cameraPosition.x = (sexyState._activePokeWindow._canvas.x) * 0.5 + (sexyState._activePokeWindow._canvas.x + sexyState._activePokeWindow._canvas.width - 183 - 3) * 0.5; cameraPosition.y = (sexyState._activePokeWindow._canvas.y) * 0.5 + (sexyState._activePokeWindow._canvas.y + sexyState._activePokeWindow._canvas.height - 181 - 3) * 0.5; } else { cameraPosition.x = FlxG.mouse.x - pokeCamera.width / 2; cameraPosition.y = FlxG.mouse.y - pokeCamera.height / 2; } cameraPosition.x = FlxMath.bound(cameraPosition.x, sexyState._activePokeWindow._canvas.x, sexyState._activePokeWindow._canvas.x + sexyState._activePokeWindow._canvas.width - 183 - 3); cameraPosition.y = FlxMath.bound(cameraPosition.y, sexyState._activePokeWindow._canvas.y, sexyState._activePokeWindow._canvas.y + sexyState._activePokeWindow._canvas.height - 181 - 3); // TODO: Need to handle non-flash targets, possibly by using PixelFilterUtils #if flash pokeCamera.pixels.copyPixels(FlxG.camera.buffer, new Rectangle(cameraPosition.x, cameraPosition.y, 183, 181), new Point()); #end pokeCamera.dirty = true; pokeCameras.insert(0, pokeCamera); frameCycleCount++; } } } thumbTimer -= elapsed; if (thumbTimer <= 0) { var rawT:Float = sexyState.totalHeartsEmitted + sexyState._heartEmitCount; rawT = adjustForPopularity(rawT, 600); thumbCount = Std.int(scaleNumber(rawT * 0.9) * 0.9); thumbCount = Std.int(FlxMath.bound(thumbCount, 0, 999999)); var dir:Int = visualThumbCount > thumbCount ? -1 : 1; if (visualThumbCount != thumbCount) { var remainingThumbCount:Int = Math.ceil(Math.abs(visualThumbCount - thumbCount) * FlxG.random.float(0.2, 0.4)); var timePerThumb:Float = 15 / Math.max(visualThumbCount + thumbCount, 6); if (thumbTimer <= 0.4) { var newThumbCount:Int = Math.ceil(Math.min((0.4 - thumbTimer) / timePerThumb, remainingThumbCount)); visualThumbCount += newThumbCount * dir; thumbTimer += timePerThumb * newThumbCount; } thumbText.text = commaSeparatedNumber(Std.int(FlxMath.bound(visualThumbCount, 0, 9999))); } else { thumbTimer += 1.2; } thumbTimer = Math.max(thumbTimer, 0.4); } visitorTimer -= elapsed; if (visitorTimer <= 0) { var rawV:Float = 0.6 * (sexyState.totalHeartsEmitted + sexyState._heartEmitCount) + 0.4 * (sexyState._toyBank._dickHeartReservoir + sexyState._toyBank._foreplayHeartReservoir + sexyState._heartBank._dickHeartReservoir + sexyState._heartBank._foreplayHeartReservoir); rawV = adjustForPopularity(rawV, 600); if (sexyState._gameState >= 410) { rawV *= 0.05; } visitorCount = scaleNumber(rawV); visitorCount += randomVisitors; visitorCount = Std.int(FlxMath.bound(visitorCount, 0, 999999)); for (i in 0...10) { if (FlxG.random.float() * (visualVisitorCount + 5) < 50) { break; } randomVisitors = Std.int(FlxMath.bound(randomVisitors + FlxG.random.int( -1, 1), 0, 20)); } var dir:Int = visualVisitorCount > visitorCount ? -1 : 1; if (visualVisitorCount != visitorCount) { var remainingVisitorCount:Int = Math.ceil(Math.abs(visualVisitorCount - visitorCount) * FlxG.random.float(0.2, 0.4)); var timePerVisitor:Float = 8 / Math.max(visualVisitorCount + visitorCount, 6); if (thumbTimer <= 0.4) { var newVisitorCount:Int = Math.ceil(Math.min((0.4 - thumbTimer) / timePerVisitor, remainingVisitorCount)); visualVisitorCount += newVisitorCount * dir; visitorTimer += timePerVisitor * newVisitorCount; } visitorText.text = commaSeparatedNumber(Std.int(FlxMath.bound(visualVisitorCount, 0, 9999))); // as new visitors get added, we may need to reduce newTextTimer if (newTextTimer > 90 / visualVisitorCount) { newTextTimer = FlxG.random.float(30, 90) / Math.max(1, visualVisitorCount); } } else { visitorTimer += 1.2; } visitorTimer = Math.max(visitorTimer, 0.4); } if (visible) { newTextTimer -= elapsed; screenRefreshTimer -= elapsed; if (screenRefreshTimer <= 0) { screenRefreshTimer = 0.16; if (newTextTimer <= 0) { var newChatCount:Int = 0; do { newChatCount++; generateChatMessage(); newTextTimer += FlxG.random.float(30, 90) / Math.max(1, visualVisitorCount); } while (newTextTimer <= 0 && newChatCount < 8); newTextTimer = Math.max(newTextTimer, 0); if (textY > 242) { for (text in texts) { text.y -= (textY - 242); } if (texts[0].y < -10) { var firstOnscreenTextIndex:Int = 1; while (texts[firstOnscreenTextIndex].y < -10) { firstOnscreenTextIndex++; } texts.splice(0, firstOnscreenTextIndex - 1); } textY = 242; } } websiteGraphic.stamp(websiteBgGraphic); for (text in texts) { websiteGraphic.stamp(text, Std.int(text.x), Std.int(text.y)); } var pokeCamera:FlxSprite = pokeCameras[pokeCameras.length - 1]; websiteGraphic.stamp(pokeCamera, Std.int(pokeCamera.x), Std.int(pokeCamera.y)); FlxSpriteUtil.drawRect(websiteGraphic, 13, 13, 183, 181, 0x30404040); websiteGraphic.stamp(visitorText, Std.int(visitorText.x), Std.int(visitorText.y)); websiteGraphic.stamp(thumbText, Std.int(thumbText.x), Std.int(thumbText.y)); if (frameCycleCount <= CAMERA_DELAY) { websiteGraphic.stamp(loadingSprite, 13 + Std.int(183 * 0.5 - loadingSprite.width * 0.5), 13 + Std.int(181 * 0.5 - loadingSprite.height * 0.5)); } tabletScreen.pixels.draw(websiteGraphic.pixels, mx); tabletScreen.dirty = true; } } } /** * Scales a raw heart count ranging linearly from [0-960] into a more * exciting number ranging from [0-1,000] or so * @param i raw heart count * @return scaled number */ function scaleNumber(i:Float) { var out:Float = i * 0.3; if (i > 40) out += (i - 40) * 0.3; if (i > 80) out += (i - 80) * 0.7; if (i > 160) out += (i - 160) * 0.9; if (i > 240) out += (i - 240) * 1.2; if (i > 320) out += (i - 320) * 2.2; if (i > 400) out += (i - 400) * 4; if (i > 480) out += (i - 480) * 7; return Std.int(out); } private function generateChatMessage():Void { var nameIndex:Int; if (visualVisitorCount == 0) { // no visitors; don't generate chat message return; } else if (FlxG.random.int(0, visualVisitorCount) > 20 || FlxG.random.bool(6)) { // a new visitor says something nameIndex = FlxG.random.int(0, CHAT_NAMES.length - 1); if (FlxG.random.bool(30)) { // and they're sticking around to chat prevNameIndexes.insert(0, nameIndex); prevNameIndexes.splice(MAX_PREV_NAMES, prevNameIndexes.length - MAX_PREV_NAMES); } } else { // a familiar visitor says something nameIndex = prevNameIndexes[FlxG.random.int(0, Std.int(Math.min((visualVisitorCount - 1) * 0.6, prevNameIndexes.length - 1)))]; } var chatName:String = CHAT_NAMES[nameIndex]; var badges:Int = 0; if (nameIndex <= 0.015 * CHAT_NAMES.length) { // both badges badges = 3; chatName = "__ " + chatName; } else if (nameIndex % 13 == 0) { // badge #1 badges = 1; chatName = "_ " + chatName; } else if (nameIndex % 7 == 0) { // badge #2 badges = 2; chatName = "_ " + chatName; } var tx0:FlxText = popTextPool(); tx0.setPosition(210, textY); tx0.text = chatName + ": "; tx0.color = CHAT_COLORS[nameIndex % CHAT_COLORS.length]; if (badges > 0) { tx0.draw(); if (badges == 1) { badgeStamp.animation.frameIndex = 0; tx0.stamp(badgeStamp, 2, 3); } else if (badges == 2) { badgeStamp.animation.frameIndex = 1; tx0.stamp(badgeStamp, 2, 3); } else if (badges == 3) { badgeStamp.animation.frameIndex = 0; tx0.stamp(badgeStamp, 2, 3); badgeStamp.animation.frameIndex = 1; tx0.stamp(badgeStamp, 8, 3); } } texts.push(tx0); var tx1:FlxText = popTextPool(); tx1.text = ""; tx1.setPosition(210, textY); tx1.color = 0xc6c3c6; var spaceCount:Int = Math.ceil(tx0.textField.textWidth / 3); while (tx1.text.length < spaceCount) { tx1.text += " "; } var emojiCount:Int = 0; var varyEmoji:Bool = true; if (FlxG.random.bool(6)) { // message with tons of the same emoji emojiCount = FlxG.random.int(3, 10); varyEmoji = false; } else if (FlxG.random.bool(6)) { // message with one or two emoji emojiCount = FlxG.random.getObject([1, 2, 3], [9, 3, 1]); } else if (FlxG.random.bool(20)) { // message with text and one or two emoji emojiCount = FlxG.random.getObject([1, 2, 3], [9, 3, 1]); tx1.text += generateRandomText(nameIndex); } else { // message with only text emojiCount = 0; tx1.text += generateRandomText(nameIndex); } if (emojiCount > 0) { // add emojis if (tx1.text.length == 0 || tx1.text.charAt(tx1.text.length - 1) != " ") { // emojis look better some padding tx1.text += " "; } tx1.draw(); var lastLine:TextLineMetrics = tx1.textField.getLineMetrics(tx1.textField.numLines - 1); emojiCount = Std.int(Math.min(emojiCount, (115 - (lastLine.x + lastLine.width)) / 12)); randomEmoji(); for (i in 0...emojiCount) { tx1.stamp(emojiStamp, Std.int(lastLine.x + lastLine.width) + 12 * i, 10 * (tx1.textField.numLines - 1) + 1); if (varyEmoji) { randomEmoji(); } } } texts.push(tx1); textY += tx1.textField.textHeight + 4; } function randomEmoji() { if (sexyState._activePokeWindow._prefix == "magn") { // magnezone emojis emojiStamp.animation.frameIndex = FlxG.random.getObject(MAGN_EMOJIS); } else if (sexyState._male) { // male emojis emojiStamp.animation.frameIndex = FlxG.random.getObject(MALE_EMOJIS); } else { // female emojis emojiStamp.animation.frameIndex = FlxG.random.getObject(FEMALE_EMOJIS); } } function popTextPool() { textPoolIndex = (textPoolIndex + 1) % textPool.length; return textPool[textPoolIndex]; } function generateRandomText(nameIndex:Int):String { if (FlxG.random.bool(15)) { // spammy phrase return FlxG.random.getObject(SPAMMY_PHRASES); } else { var longPhrase:String = FlxG.random.getObject(LONG_PHRASES); var len:Int = Std.int(Math.min(FlxG.random.int(3, longPhrase.length), FlxG.random.int(3, longPhrase.length))); var subPhrase:String = longPhrase.substring(0, len); if (FlxG.random.bool(20) || (nameIndex + 3) % 11 == 0) { subPhrase = subPhrase.toLowerCase(); } else if (FlxG.random.bool(5)) { subPhrase = subPhrase.toUpperCase(); } return subPhrase; } } override public function destroy():Void { super.destroy(); loadingSprite = FlxDestroyUtil.destroy(loadingSprite); mx = null; websiteBgGraphic = FlxDestroyUtil.destroy(websiteBgGraphic); websiteGraphic = FlxDestroyUtil.destroy(websiteGraphic); pokeCameras = FlxDestroyUtil.destroyArray(pokeCameras); tabletScreen = FlxDestroyUtil.destroy(tabletScreen); prevNameIndexes = null; textPool = FlxDestroyUtil.destroyArray(textPool); texts = FlxDestroyUtil.destroyArray(texts); emojiStamp = FlxDestroyUtil.destroy(emojiStamp); badgeStamp = FlxDestroyUtil.destroy(badgeStamp); visitorText = FlxDestroyUtil.destroy(visitorText); thumbText = FlxDestroyUtil.destroy(thumbText); cameraPosition = FlxDestroyUtil.put(cameraPosition); } }
argonvile/monster
source/Tablet.hx
hx
unknown
28,950
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.input.FlxInput.FlxInputState; import flixel.input.keyboard.FlxKey; import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import openfl.display.BitmapData; import openfl.display.BlendMode; /** * Graphics for a keyboard. Three keyboard layouts are available based on * whether the player is entering their name, password, or IP address */ class TextEntryGroup extends FlxGroup { private inline static var REPEAT_DELAY:Float = 0.5; private inline static var REPEAT_FREQUENCY:Float = 0.1; private static var BACKSPACE_BUTTON_DATA:ButtonData = {x:0, y:0, c:"<"}; private static var SPACE_BUTTON_DATA:ButtonData = {x:0, y:0, c:" "}; private static var OK_BUTTON_DATA:ButtonData = {x:0, y:0, c:">"}; private static var CHAR_TO_KEY:Map<String,FlxKey> = [ "0" => FlxKey.ZERO, "1" => FlxKey.ONE, "2" => FlxKey.TWO, "3" => FlxKey.THREE, "4" => FlxKey.FOUR, "5" => FlxKey.FIVE, "6" => FlxKey.SIX, "7" => FlxKey.SEVEN, "8" => FlxKey.EIGHT, "9" => FlxKey.NINE, ]; private var buttonDatas:Array<ButtonData> = []; private var mousePosition:FlxPoint; private var clickedButtonRect:FlxSprite; private var clickedButtonTween:FlxTween; private var spaceBarRect:RoundedRectangle; private var clickedSpaceBarRect:FlxSprite; private var eraseRect:RoundedRectangle; private var clickedEraseRect:FlxSprite; private var okRect:RoundedRectangle; private var clickedOkRect:FlxSprite; private var typedText:FlxText; private var textCursor:FlxSprite; private var mouseDownTime:Float = 0; private var keyDown:FlxKey = 0; private var keyDownTime:Float = 0; private var repeatTimer:Float = 0; private var clickedButtonData:ButtonData = null; private var firstUpdate:Bool = true; private var textEntryCallback:String->Void; private var textMaxLength:Int = 10000; private var textCursorMaxX:Int = 593; private var config:KeyConfig; public function new(?TextEntryCallback:String->Void, config:KeyConfig) { super(); this.config = config; this.textEntryCallback = TextEntryCallback; if (config == KeyConfig.Name) { var firstRow:Array<String> = ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"]; for (i in 0...firstRow.length) { buttonDatas.push({x:59 + 66 * i, y:119, c:firstRow[i]}); } var secondRow:Array<String> = ["A", "S", "D", "F", "G", "H", "J", "K", "L"]; for (i in 0...secondRow.length) { buttonDatas.push({x:81 + 66 * i, y:185, c:secondRow[i]}); } var thirdRow:Array<String> = ["Z", "X", "C", "V", "B", "N", "M", "."]; for (i in 0...thirdRow.length) { buttonDatas.push({x:103 + 66 * i, y:251, c:thirdRow[i]}); } } else if (config == KeyConfig.Ip) { var firstRow:Array<String> = ["0", "1", "2", "3"]; for (i in 0...firstRow.length) { buttonDatas.push({x:257 + 66 * i, y:119, c:firstRow[i]}); } var secondRow:Array<String> = ["4", "5", "6", "7"]; for (i in 0...secondRow.length) { buttonDatas.push({x:279 + 66 * i, y:185, c:secondRow[i]}); } var thirdRow:Array<String> = ["8", "9", "."]; for (i in 0...thirdRow.length) { buttonDatas.push({x:301 + 66 * i, y:251, c:thirdRow[i]}); } } else if (config == KeyConfig.Password) { var firstRow:Array<String> = [null, null, "3", "4", "5", "6", "7", "8", "9", null]; for (i in 0...firstRow.length) { buttonDatas.push({x:37 + 66 * i, y:119, c:firstRow[i]}); } var secondRow:Array<String> = ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"]; for (i in 0...secondRow.length) { buttonDatas.push({x:59 + 66 * i, y:185, c:secondRow[i]}); } var thirdRow:Array<String> = ["A", "S", "D", "F", "G", "H", "J", "K", "L"]; for (i in 0...thirdRow.length) { buttonDatas.push({x:81 + 66 * i, y:251, c:thirdRow[i]}); } var fourthRow:Array<String> = ["Z", "X", "C", null, "B", "N", "M", null]; for (i in 0...fourthRow.length) { buttonDatas.push({x:103 + 66 * i, y:317, c:fourthRow[i]}); } } for (buttonData in buttonDatas) { if (buttonData.c == null) { // missing key; password removes 0, 1, O, I keys from keyboard continue; } var button:RoundedRectangle = new RoundedRectangle(); button.relocate(buttonData.x, buttonData.y, 56, 56, 0xff000000, 0xffffffff, 4); add(button); var text:FlxText = new FlxText(buttonData.x, buttonData.y, 56, buttonData.c, 40); text.alignment = FlxTextAlign.CENTER; text.color = FlxColor.BLACK; text.font = AssetPaths.hardpixel__otf; add(text); } spaceBarRect = new RoundedRectangle(); if (config == KeyConfig.Name) { spaceBarRect.relocate(213, 317, 330, 56, 0xff000000, 0xffffffff, 4); add(spaceBarRect); } var typedTextRect:RoundedRectangle = new RoundedRectangle(); if (config == KeyConfig.Name || config == KeyConfig.Ip) { typedTextRect.relocate(147, 57, 474, 48, OptionsMenuState.LIGHT_BLUE, OptionsMenuState.MEDIUM_BLUE, 4); } else if (config == KeyConfig.Password) { typedTextRect.relocate(27, 57, 714, 48, OptionsMenuState.LIGHT_BLUE, OptionsMenuState.MEDIUM_BLUE, 4); textCursorMaxX = 10000; } add(typedTextRect); typedText = new FlxText(typedTextRect.x + 4, typedTextRect.y - 4, typedTextRect.width, "", 40); typedText.color = OptionsMenuState.LIGHT_BLUE; typedText.font = AssetPaths.hardpixel__otf; add(typedText); textCursor = new FlxSprite(typedTextRect.x + 8, typedTextRect.y + 10); textCursor.loadGraphic(new BitmapData(40, 28, true, 0x00000000), true, 20, 28, true); FlxSpriteUtil.drawRect(textCursor, 0, 0, 20, 28, OptionsMenuState.LIGHT_BLUE); textCursor.animation.add("default", [0, 1], 2); textCursor.animation.play("default"); add(textCursor); eraseRect = new RoundedRectangle(); if (config == KeyConfig.Name || config == KeyConfig.Ip) { eraseRect.relocate(631, 53, 78, 56, 0xff000000, 0xffffffff, 4); } else if (config == KeyConfig.Password) { eraseRect.relocate(631, 119, 78, 56, 0xff000000, 0xffffffff, 4); } add(eraseRect); var eraseKey:FlxSprite = new FlxSprite(eraseRect.x + 4, eraseRect.y + 4, AssetPaths.erase_key__png); add(eraseKey); okRect = new RoundedRectangle(); if (config == KeyConfig.Name) { okRect.relocate(587, 317, 122, 56, 0xff000000, 0xffffffff, 4); } else if (config == KeyConfig.Ip) { okRect.relocate(499, 251, 122, 56, 0xff000000, 0xffffffff, 4); } else if (config == KeyConfig.Password) { okRect.relocate(565, 317, 122, 56, 0xff000000, 0xffffffff, 4); } add(okRect); var okText:FlxText = new FlxText(okRect.x, okRect.y, okRect.width, "Ok", 40); okText.alignment = FlxTextAlign.CENTER; okText.color = FlxColor.BLACK; okText.font = AssetPaths.hardpixel__otf; add(okText); clickedOkRect = new FlxSprite(okRect.x + 4, okRect.y + 4); clickedOkRect.makeGraphic(Std.int(okRect.width - 8), Std.int(okRect.height - 8)); clickedOkRect.blend = BlendMode.DIFFERENCE; clickedOkRect.alpha = 0; add(clickedOkRect); clickedButtonRect = new FlxSprite(); clickedButtonRect.makeGraphic(48, 48); clickedButtonRect.blend = BlendMode.DIFFERENCE; clickedButtonRect.alpha = 0; add(clickedButtonRect); clickedSpaceBarRect = new FlxSprite(spaceBarRect.x + 4, spaceBarRect.y + 4); if (isSpaceBarEnabled()) { clickedSpaceBarRect.makeGraphic(Std.int(spaceBarRect.width - 8), Std.int(spaceBarRect.height - 8)); clickedSpaceBarRect.blend = BlendMode.DIFFERENCE; clickedSpaceBarRect.alpha = 0; add(clickedSpaceBarRect); } clickedEraseRect = new FlxSprite(eraseRect.x + 4, eraseRect.y + 4); clickedEraseRect.makeGraphic(Std.int(eraseRect.width - 8), Std.int(eraseRect.height - 8)); clickedEraseRect.blend = BlendMode.DIFFERENCE; clickedEraseRect.alpha = 0; add(clickedEraseRect); } override public function update(elapsed:Float):Void { super.update(elapsed); if (firstUpdate) { // ignore mouse events for first update -- if we're displayed in response to a click, we'll be double-handling a click firstUpdate = false; return; } if (FlxG.mouse.pressed) { mouseDownTime += elapsed; } else { mouseDownTime = 0; } if (keyDown != 0 && FlxG.keys.checkStatus(keyDown, FlxInputState.PRESSED)) { keyDownTime += elapsed; } else { keyDownTime = 0; } if (mouseDownTime == 0 && keyDownTime == 0) { repeatTimer = 0; } if ((FlxG.mouse.pressed && mouseDownTime > REPEAT_DELAY) || (keyDown != 0 && FlxG.keys.checkStatus(keyDown, FlxInputState.PRESSED) && keyDownTime > REPEAT_DELAY)) { repeatTimer += elapsed; if (repeatTimer > REPEAT_FREQUENCY) { repeatTimer -= REPEAT_FREQUENCY; handleJustPressedButton(); } } if (FlxG.mouse.justPressed) { clickedButtonData = null; mouseDownTime = 0; mousePosition = FlxG.mouse.getPosition(mousePosition); if (isSpaceBarEnabled() && mousePosition.inCoords(spaceBarRect.x, spaceBarRect.y, spaceBarRect.width, spaceBarRect.height)) { clickedButtonData = SPACE_BUTTON_DATA; } else if (mousePosition.inCoords(eraseRect.x, eraseRect.y, eraseRect.width, eraseRect.height)) { clickedButtonData = BACKSPACE_BUTTON_DATA; } else if (mousePosition.inCoords(okRect.x, okRect.y, okRect.width, okRect.height)) { clickedButtonData = OK_BUTTON_DATA; } else { for (buttonData in buttonDatas) { if (buttonData.c == null) { // can't click null buttons continue; } if (mousePosition.inCoords(buttonData.x, buttonData.y, 56, 56)) { clickedButtonData = buttonData; break; } if (buttonData.c == "." && FlxG.keys.justPressed.PERIOD) { clickedButtonData = buttonData; break; } } } handleJustPressedButton(); } var justPressed:Int = FlxG.keys.firstJustPressed(); if (justPressed != -1) { clickedButtonData = null; keyDownTime = 0; if (isSpaceBarEnabled() && FlxG.keys.justPressed.SPACE) { clickedButtonData = SPACE_BUTTON_DATA; keyDown = FlxKey.SPACE; } else if (FlxG.keys.justPressed.BACKSPACE) { clickedButtonData = BACKSPACE_BUTTON_DATA; keyDown = FlxKey.BACKSPACE; } else if (FlxG.keys.justPressed.ENTER) { clickedButtonData = OK_BUTTON_DATA; keyDown = FlxKey.ENTER; } else { var justPressedChar:String = String.fromCharCode(justPressed).toUpperCase(); for (buttonData in buttonDatas) { if (buttonData.c == justPressedChar) { clickedButtonData = buttonData; if (CHAR_TO_KEY[justPressedChar] != null) { keyDown = CHAR_TO_KEY[justPressedChar]; } else { keyDown = FlxKey.fromString(justPressedChar); } break; } if (buttonData.c == "." && FlxG.keys.justPressed.PERIOD) { clickedButtonData = buttonData; keyDown = FlxKey.PERIOD; break; } } } handleJustPressedButton(); } textCursor.x = typedText.x + (typedText.text == "" ? 0 : typedText.textField.textWidth) + 4; while (textCursor.x > textCursorMaxX || typedText.text.length > textMaxLength) { typedText.text = typedText.text.substr(0, Std.int(Math.max(0, typedText.text.length - 1))); textCursor.x = typedText.x + (typedText.text == "" ? 0 : typedText.textField.textWidth) + 4; } } private function isSpaceBarEnabled():Bool { return spaceBarRect.width > 8; } public static inline function squareOut(t:Float):Float { return 0; } public function setMaxLength(textMaxLength:Int) { this.textMaxLength = textMaxLength; } function handleJustPressedButton():Void { if (clickedButtonData != null) { clickedButtonRect.alpha = 0; clickedSpaceBarRect.alpha = 0; clickedEraseRect.alpha = 0; clickedOkRect.alpha = 0; if (clickedButtonData == SPACE_BUTTON_DATA && spaceBarRect != null) { clickedSpaceBarRect.alpha = 1; clickedButtonTween = FlxTweenUtil.retween(clickedButtonTween, clickedSpaceBarRect, {alpha:0}, 0.1, {ease:squareOut}); } else if (clickedButtonData == BACKSPACE_BUTTON_DATA) { clickedEraseRect.alpha = 1; clickedButtonTween = FlxTweenUtil.retween(clickedButtonTween, clickedEraseRect, {alpha:0}, 0.1, {ease:squareOut}); } else if (clickedButtonData == OK_BUTTON_DATA) { clickedOkRect.alpha = 1; clickedButtonTween = FlxTweenUtil.retween(clickedButtonTween, clickedOkRect, {alpha:0}, 0.1, {ease:squareOut}); } else { clickedButtonRect.x = clickedButtonData.x + 4; clickedButtonRect.y = clickedButtonData.y + 4; clickedButtonRect.alpha = 1; clickedButtonTween = FlxTweenUtil.retween(clickedButtonTween, clickedButtonRect, {alpha:0}, 0.1, {ease:squareOut}); } typePressedButton(); } } function typePressedButton():Void { if (clickedButtonData != null) { if (clickedButtonData == BACKSPACE_BUTTON_DATA) { typedText.text = typedText.text.substr(0, Std.int(Math.max(0, typedText.text.length - 1))); if (config == KeyConfig.Password) { if (typedText.text.length == 6 || typedText.text.length == 13) { typedText.text = typedText.text.substr(0, Std.int(Math.max(0, typedText.text.length - 1))); } } } else if (clickedButtonData == OK_BUTTON_DATA) { typedText.text = StringTools.trim(typedText.text); while (typedText.text.indexOf(" ") != -1) { typedText.text = StringTools.replace(typedText.text, " ", " "); } if (textEntryCallback != null) { textEntryCallback(typedText.text); } } else { typedText.text += clickedButtonData.c; if (config == KeyConfig.Password) { if (typedText.text.length == 6 || typedText.text.length == 13) { typedText.text += " "; } } } } } override public function destroy():Void { super.destroy(); buttonDatas = null; mousePosition = FlxDestroyUtil.put(mousePosition); clickedButtonRect = FlxDestroyUtil.destroy(clickedButtonRect); clickedButtonTween = FlxTweenUtil.destroy(clickedButtonTween); spaceBarRect = FlxDestroyUtil.destroy(spaceBarRect); clickedSpaceBarRect = FlxDestroyUtil.destroy(clickedSpaceBarRect); eraseRect = FlxDestroyUtil.destroy(eraseRect); clickedEraseRect = FlxDestroyUtil.destroy(clickedEraseRect); okRect = FlxDestroyUtil.destroy(okRect); clickedOkRect = FlxDestroyUtil.destroy(clickedOkRect); typedText = FlxDestroyUtil.destroy(typedText); textCursor = FlxDestroyUtil.destroy(textCursor); clickedButtonData = null; textEntryCallback = null; config = null; } } typedef ButtonData = { x:Int, y:Int, c:String } enum KeyConfig { Name; Ip; Password; }
argonvile/monster
source/TextEntryGroup.hx
hx
unknown
15,322
package; import MmStringTools.*; import critter.Critter; import flixel.FlxG; import minigame.MinigameState; import minigame.MinigameState.denNerf; import openfl.utils.Object; /** * Dialog for the puzzle tutorials and minigame tutorials. */ class TutorialDialog { public static function tutorialNovice(tree:Array<Array<Object>>):Void { if (PlayerData.level == 0 || PlayerData.level >= 3 // player just entered a password; skipped to level 3/4 ) { tree[0] = ["#grov05#Nice to meet you! I'm sure you're anxious to get your hands dirty but first, let me explain how these puzzles work."]; if (PlayerData.name != null) { // repeating tutorial tree[0] = ["#grov05#Ah, hello again! I'm sure you're once again anxious to get your hands dirty but first, let me explain how these puzzles work."]; } tree[1] = ["%enable-skip%"]; tree[2] = ["%cube-clue-critters%"]; tree[3] = ["%lights-dim%"]; tree[4] = ["%light-on-wholeanswer%"]; tree[5] = ["#grov04#The goal is to drop the correct colored bugs in this box up here! Do that and you complete the puzzle."]; tree[6] = ["%light-off-wholeanswer%"]; tree[7] = ["%lights-on-wholeclue%"]; tree[8] = ["#grov05#Each of these other rows is a clue-- an incorrect guess which most definitely will NOT complete the puzzle."]; tree[9] = ["%lights-off-wholeclue%"]; tree[10] = ["%lights-on-rightclue%"]; tree[11] = ["#grov04#Alongside each guess we show how many bugs in that guess are correct. Each heart indicates one correct bug. The position of the bugs doesn't affect the solution."]; tree[12] = ["%lights-off-rightclue%"]; tree[13] = ["%light-on-wholeclue0%"]; tree[14] = ["#grov05#So for example, looking at this first clue, \"red, red, blue\" has two correct bugs. It's actually only ONE bug away from the correct answer!"]; tree[15] = ["#grov06#The solution might have a purple and two reds... or a purple, red and a blue... or two blues and a red, for example. Hmm, there are other possibilities too."]; tree[16] = ["%prompts-y-offset+30%"]; tree[17] = ["#grov03#But come to think of it, you can deduce something important just from that one clue, can't you?"]; tree[18] = [40, 50, 30]; tree[30] = ["The solution\nhas a red"]; tree[31] = ["#grov02#Yes, spot on! If there were no reds in the solution, it would be impossible for this first clue to yield two hearts."]; tree[32] = [100]; tree[40] = ["The solution\nhas a blue"]; tree[41] = ["#grov15#Err, not necessarily! Something like \"red, red, red\" would still result in two hearts for this first clue, right?"]; tree[42] = ["#grov06#So just looking at this clue in isolation for a moment, it's certainly possible to get two hearts without having any blues in the solution."]; tree[43] = ["#grov04#However, the solution definitely has to have a red in it. If the solution had zero reds, it would be impossible for this clue to yield two hearts."]; tree[44] = [100]; tree[50] = ["The solution\nhas a purple"]; tree[51] = ["#grov15#Err, not necessarily! Something like \"red, red, red\" would still result in two hearts for this first clue, right?"]; tree[52] = ["#grov06#So just looking at this clue in isolation for a moment, it's certainly possible to get two hearts without having any purples in the solution."]; tree[53] = ["#grov04#However, the solution definitely has to have a red in it. If the solution had zero reds, it would be impossible for this clue to yield two hearts."]; tree[54] = [100]; tree[100] = ["%lights-on%"]; tree[101] = ["#grov05#I'll just grab one of these red bugs. The position doesn't matter, so I can just drop it anywhere I want..."]; tree[102] = ["%move-peg-from-red-to-answerempty%"]; tree[103] = ["#grov02#There we are! And the puzzle's already one-third complete."]; tree[104] = ["#grov04#So, do you think you can handle it from here?"]; tree[105] = [130, 120, 140]; tree[120] = ["Yes, it\nseems easy"]; tree[121] = ["#grov02#Wonderful! I'll just get out of your way then. Fill up the remaining boxes and let's see how you do."]; tree[130] = ["Maybe, what\ncomes next?"]; tree[131] = ["%lights-dim%"]; tree[132] = ["%light-on-wholeclue2%"]; tree[133] = ["#grov05#Well hmm... Let's look at this third clue next. We know there's a red bug in the solution right? That's why there's one heart here."]; tree[134] = ["#grov06#But if there were any more reds or purples in the solution... wouldn't that break this third clue? What do you think?"]; tree[135] = [160, 180, 170]; tree[140] = ["No, I\nneed help"]; tree[141] = ["%lights-dim%"]; tree[142] = ["%light-on-wholeclue2%"]; tree[143] = ["#grov05#Sure, let's look at this third clue!"]; tree[144] = ["#grov02#We've already figured out that there's a red bug in the solution right? And aha, that one heart next to the third clue must correspond to the red we've already placed!"]; tree[145] = ["#grov06#But hmm, if there were any more reds or purples in the solution... wouldn't that break this third clue? What do you think?"]; tree[146] = [160, 180, 170]; tree[160] = ["The solution\ncan't have\nany more reds\nor purples"]; tree[161] = ["%lights-on%"]; tree[162] = ["#grov02#That's right! The solution can't have any more reds or purples in it. So we've greatly narrowed it down, yes?"]; tree[163] = ["#grov04#See if you can figure out the answer, and drop the remaining bugs in their corresponding boxes. Good luck!"]; tree[170] = ["The solution\nmust have\nat least\none more red"]; tree[171] = ["#grov15#Well hmm... Let's think this through! What if the correct answer had two red bugs in it? Why, the third clue would have two bugs correct, and two hearts."]; tree[172] = ["#grov04#It would have two hearts because two bugs would match-- the two red bugs. But it only has one heart! So, there must not be two red bugs in the solution."]; tree[173] = ["#grov05#And actually, you can use the same logic to determine there's no purples either!"]; tree[174] = ["%lights-on%"]; tree[175] = ["#grov04#So given that there's no more reds or purples in the solution... that greatly narrows down the choices, yes?"]; tree[176] = ["#grov02#Give it some thought, see if you can figure out the answer. Fill up the remaining boxes as best you can and let's see how you do!"]; tree[180] = ["The solution\nmust have\nat least\none purple"]; tree[181] = ["#grov15#Well hmm... Let's think this through! What if the correct answer had a red and a purple in it? Why, the third clue would have two bugs correct, and two hearts."]; tree[182] = ["#grov04#It would have two hearts because two bugs would match-- the red bug and the purple bug. But it only has one heart! So, there must not be any purples in the solution."]; tree[183] = ["#grov05#And actually, you can use the same logic to determine there's no more reds either! Just the one we've already placed."]; tree[184] = ["%lights-on%"]; tree[185] = ["#grov04#So given that there's no more reds or purples in the solution... that greatly narrows down the choices, yes?"]; tree[186] = ["#grov02#Give it some thought, see if you can figure out the answer. Fill up the remaining boxes as best you can and let's see how you do!"]; tree[200] = ["%mark-startover%"]; tree[201] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[202] = ["%reset-puzzle%"]; tree[203] = ["%lights-dim%"]; tree[204] = ["%light-on-wholeanswer%"]; tree[205] = ["#grov04#So the goal is to drop the correct colored bugs in these boxes up here! Do that and you complete the puzzle."]; tree[206] = [6]; tree[210] = ["%mark-skipwithpassword%"]; tree[211] = ["%skip%"]; tree[212] = ["%skip%"]; tree[213] = ["%skip%"]; // skip to non-existent level 3/4; this signals certain things to happen when repeating tutorial dialog tree[214] = ["#grov04#I'm sure you remember how these puzzles work, so I won't bother explaining them."]; tree[215] = ["#grov03#...Although if for some reason you require an explanation, you can always summon my assistance with that button in the corner."]; tree[216] = ["#grov02#It's good to see you again, <name>~"]; tree[10000] = ["%lights-on%"]; } else if (PlayerData.level == 1) { tree[0] = ["%noop%"]; // don't move this bit to the end tree[1] = ["%cube-clue-critters%"]; tree[2] = ["#grov06#Now this one's a substantial step up in difficulty isn't it? So many different clues..."]; tree[3] = ["%lights-dim%"]; tree[4] = ["%light-on-wholeclue1%"]; tree[5] = ["%prompts-y-offset-70%"]; tree[6] = ["#grov04#Ah, but right away we can figure out something from the second clue, hmm?"]; tree[7] = [30, 20, 40]; tree[20] = ["The solution\ncan't have any\nblues or reds"]; tree[21] = ["%lights-on%"]; tree[22] = ["#grov02#Right! Now you might be wondering what that signpost with the red \"X\" is there for. That's just a helpful way to take notes for these more complicated puzzles."]; tree[23] = ["%move-peg-from-blue-to-367x239%"]; tree[24] = ["%move-peg-from-red-to-397x240%"]; tree[25] = ["#grov04#There, see? Dropping the blue and red bugs here will help me remember that these colors aren't in the solution."]; tree[26] = ["#grov05#I think I can tell from your impatient clicking that you're anxious for this tutorial to end so, I'll stop talking for a moment. Hah! Heheheh."]; tree[30] = ["The solution\nmust have either\na blue or a red"]; tree[31] = ["#grov06#Well, let's think this through. What if the solution had a blue in it? Why, the second clue would have one heart in it for the matching blue. But it doesn't have any!"]; tree[32] = ["%lights-on%"]; tree[33] = ["#grov04#No, the answer certainly can't have any blues in it. Nor can it have any reds, for that matter!"]; tree[34] = ["#grov05#Now, you might be wondering what that signpost with the red \"X\" is there for. That's just a helpful way to take notes for these more complicated puzzles."]; tree[35] = [23]; tree[40] = ["The solution\nmust have both\na blue and a red"]; tree[41] = [31]; tree[100] = ["%mark-startover%"]; tree[101] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[102] = ["%reset-puzzle%"]; tree[103] = ["#grov06#So yes, this one's a substantial step up in difficulty isn't it? So many different clues..."]; tree[104] = [3]; tree[10000] = ["%lights-on%"]; } else if (PlayerData.level == 2) { tree[0] = ["#grov04#I'm fully undressed, but as you can see there's still one final puzzle."]; tree[1] = ["%cube-clue-critters%"]; // cube clue critters after dialog, to work around a glitch where critters jump into boxes prematurely tree[2] = ["%help-button-on%"]; tree[3] = ["%lights-dim%"]; tree[4] = ["%add-light-wq4oq24piy-location-730x000x038x034%"]; tree[5] = ["#grov05#While I won't spoil what happens after this puzzle, I will call your attention to that funny-shaped button in the corner--"]; tree[6] = ["#grov04#If you ever get completely stuck on a puzzle, you can always ask Abra if he'll give you some kind of hint as a last recourse."]; tree[7] = ["%remove-light-wq4oq24piy%"]; tree[8] = ["%lights-on%"]; tree[9] = ["%help-button-off%"]; tree[10] = ["#grov06#But for now, why don't we see if we can make do without his help. Hmm, yes, I'm already getting some ideas from that first clue... Hmm, hmm..."]; tree[50] = ["%mark-startover%"]; tree[51] = ["%help-button-on%"]; tree[52] = ["%lights-dim%"]; tree[53] = ["%add-light-wq4oq24piy-location-730x000x038x034%"]; tree[54] = ["#grov05#Ah, sure thing! I just wanted to make sure you noticed that funny-shaped button in the corner--"]; tree[55] = [6]; tree[10000] = ["%remove-light-wq4oq24piy%"]; tree[10001] = ["%lights-on%"]; tree[10002] = ["%help-button-off%"]; if (!PlayerData.abraMale) { DialogTree.replace(tree, 6, "if he'll", "if she'll"); DialogTree.replace(tree, 10, "without his", "without her"); } } tree[300] = ["%mark-rememberme%"]; tree[301] = ["%disable-skip%"]; tree[302] = ["#grov10#Ah well, err... Of course I remember! ...I have a remarkable knack for names, you know-- I've literally never forgotten a name."]; tree[303] = ["#grov06#Yours is right on the top of my tongue... Hmm, hmm... You must be, err..."]; tree[304] = [310, 315, 330]; tree[310] = ["My name\nis..."]; tree[311] = ["%prompt-name%"]; tree[315] = ["Do you\nwant me to\ntell you?"]; tree[316] = ["#grov10#No, no, I remember! I really do. It's just difficult without your face. But your name is definitely mmmm... Let me think... ..."]; tree[317] = [310, 320, 330]; tree[320] = ["I can't\nbelieve you\nforgot my\nname, Grovyle"]; tree[321] = ["#grov11#Ack! ...No, why, how rude would that be if you remembered my name... but I forgot yours? Of course I remember!"]; tree[322] = ["#grov06#It definitely starts with... a letter N... or perhaps an A, was it? Am I getting warmer or colder?"]; tree[323] = [310, 325, 330]; tree[325] = ["You really\nforgot"]; tree[326] = ["#grov03#Ahh I had you going! Of course I remembered YOUR name. You're umm... that guy! That guy with the really memorable name."]; tree[327] = ["#grov06#That name with all the letters in it... Some pointy letters, and some round ones... All those letters! ... ...Ack, I'll be so embarrassed when I finally remember..."]; tree[328] = [310, 315, 330]; tree[330] = ["Nevermind,\nwe actually\nhaven't met"]; tree[331] = ["%enable-skip%"]; tree[332] = ["#grov03#Ah, of course we haven't! ...Was that some sort of a test? ... ...Did I pass?"]; // no name tree[400] = ["%mark-cdjv0kpk%"]; tree[401] = ["#grov05#Err? Why it sounded like you were about to say something... Not that I need any help! Your name is definitely, err..."]; tree[402] = [310, 315, 330]; // invalid name tree[410] = ["%mark-5w2p2vmw%"]; tree[411] = ["%mark-zs7y5218%"]; tree[412] = ["%mark-agdjhera%"]; tree[413] = ["%mark-7hoh545f%"]; tree[414] = ["#grov04#No, no... THAT definitely wasn't it, I would have never remembered a name like that. Your name was something much more memorable."]; if (PlayerData.gender == PlayerData.Gender.Girl) { tree[415] = ["#grov06#I think I remember that it rhymed with a part of the male anatomy... Nicole? ...Doloreskin? Hmmm, hmmm. It's coming to me..."]; } else { tree[415] = ["#grov06#I think I remember that it rhymed with a part of the male anatomy... Jacques? ...Ernesticle? Hmmm, hmmm. It's coming to me..."]; } tree[416] = [310, 315, 330]; // someone else's name tree[420] = ["%mark-ijrtkh6l%"]; tree[421] = ["%enable-skip%"]; tree[422] = ["#grov13#You are NOT... That is NOT your name!! No! ...Bad! That's such a... You are the sneakiest little... Grrrggghhh!!!"]; tree[423] = ["#grov12#I'm not sure if if I even want to play with you anymore, you sneaky little rascal. ...Pretending you're <random-name>... Hmph!"]; tree[424] = ["#grov06#... ...I'm just going to proceed with the tutorial, and we can pretend this never happened-"]; tree[425] = ["#grov12#-and perhaps YOU can stop trying to break this cute little game with your unwelcome shenanigans! Hmph! Hmph!!"]; tree[426] = ["#grov03#Aaaanyways, let's see if we can get back to this puzzle, and forget this ever happened..."]; // good name tree[450] = ["%mark-79gi267d%"]; tree[451] = ["#grov06#<good-name>? <good-name>... Err... ... ...Hmmmmm..."]; tree[452] = ["#grov08#Very well, you've caught me. ...I've COMPLETELY forgotten your name. Dreadfully sorry about this, this almost never happens!"]; tree[453] = ["#grov05#But errm, I have a remarkable knack for sequences of eighteen alphanumeric characters! ...I never forget a sequence of eighteen alphanumeric characters."]; tree[454] = ["#grov04#I don't suppose you have something like that? ...Something reminiscent of a password perhaps? I'm quite certain that will serve to jog my memory."]; tree[455] = [460, 470, 480]; tree[460] = ["My password\nis..."]; tree[461] = ["%prompt-password%"]; tree[465] = ["Oh, I think\nI typed my\npassword\nwrong"]; tree[466] = ["%prompt-password%"]; tree[470] = ["Actually,\nI think I\ntyped my\nname wrong"]; tree[471] = ["%prompt-name%"]; tree[480] = ["I don't have\nanything\nlike that"]; tree[481] = ["%enable-skip%"]; tree[482] = ["#grov10#Ah, well perhaps I'll eventually remember you without that eighteen character sequence! ... ...If something else were to jog my memory, hmm."]; tree[483] = ["#grov04#...Well in the meantime, let's see what we can do with this puzzle~"]; tree[485] = ["Nevermind,\nlet's just do\nthe tutorial"]; tree[486] = [481]; tree[500] = ["%mark-664xvle5%"]; // empty password tree[501] = ["#grov08#Coming up empty, hmm? ...Well that's a bit of a disappointment."]; tree[502] = ["#grov04#If you could just remember that eighteen character sequence, I'm certain it would jog my memory. ...I never forget a sequence of eighteen alphanumeric characters!"]; tree[503] = [460, 470, 480]; tree[510] = ["%mark-k9hftkyn%"]; // short password tree[511] = ["#grov06#Errm, perhaps my kindergarten counting skills have grown rusty from disuse, but I don't think that was eighteen characters."]; tree[512] = ["#grov04#I'm going to need all eighteen characters in your password to help distinguish you from all the other <good-name>s! ...Do you have that written down somewhere?"]; tree[513] = [460, 470, 480]; tree[520] = ["%mark-wab1rky5%"]; // someone else's password tree[521] = ["#grov02#Ah yes, <random-name>! Of course! ...I believe Abra unceremoniously stuffed your belongings in a closet somewhere back here..."]; tree[522] = ["#grov06#But... Why did you change your name from <random-name> to <good-name>? Unless.... Hmmm..."]; tree[523] = ["#grov12#Say! You're not actually <random-name> at all, are you? Hmph!!"]; tree[524] = ["#grov13#Where did you find their eighteen character sequence, hmmmm? Did you randomly guess it, or were you snooping through their things? Hmph! Hmph I say."]; tree[525] = ["#grov14#...I need YOUR personal eighteen character sequence, <good-name>. Not <random-name>'s."]; tree[526] = [460, 470, 480]; tree[530] = ["%mark-wab1rky6%"]; // invalid password tree[531] = ["#grov06#Hmm. <password>.... <password>... No, that's not ringing any bells."]; tree[532] = ["#grov04#You're <good-name>, and your password is <password>? ...Are you certain you typed all of that correctly?"]; tree[533] = ["#grov05#Or hmmm, sometimes if a 5 has too much to drink, it can start looking like an S... Perhaps something like that?"]; tree[534] = [465, 470, 485]; tree[550] = ["%mark-10xom4oy%"]; // valid password tree[551] = ["%set-name%"]; tree[552] = ["%set-password%"]; tree[553] = ["%enable-skip%"]; tree[554] = ["%skip%"]; tree[555] = ["%skip%"]; tree[556] = ["%skip%"]; // skip to non-existent level 3; this signals certain things to happen when repeating tutorial dialog tree[557] = ["#grov02#Ah yes, <good-name>! Of course! ...I believe Abra unceremoniously stuffed your belongings in a closet somewhere back here..."]; tree[558] = ["%enterabra%"]; tree[559] = ["#grov05#Abra! ...Wouldn't you believe it? <good-name>'s returned to play with us!"]; tree[560] = ["#abra02#Hmm? ...Oh, <good-name>! I hadn't seen you in awhile."]; tree[561] = ["%exitabra%"]; tree[562] = ["#abra05#...Give me a moment and I'll get your things back the way you had them, alright?"]; tree[563] = ["#grov02#Well isn't this exciting! ...It's good to have you back again, <name>~"]; if (PlayerData.gender == PlayerData.Gender.Girl) { DialogTree.replace(tree, 326, "that guy! That guy", "that girl! That girl"); } } public static function tutorial3Peg(tree:Array<Array<Object>>) { if (PlayerData.level == 0) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov05#Hello again! This time, we're going to try out some harder puzzles where the ordering of the bugs affects the solution."]; tree[2] = ["%lights-dim%"]; tree[3] = ["%lights-on-rightclue%"]; tree[4] = ["#grov03#But... We don't expect you to just guess, of course! These white dots and red hearts give you a little extra information, so you can determine logically where each bug goes."]; tree[5] = ["%lights-off-rightclue%"]; tree[6] = ["%light-on-wholeclue0%"]; tree[7] = ["#grov04#A heart next to a clue indicates a bug with the correct color is also in the correct position. So, perhaps the solution has a purple in the center box."]; tree[8] = ["%light-off-wholeclue0%"]; tree[9] = ["%light-on-wholeclue2%"]; tree[10] = ["#grov05#A dot next to a clue indicates a bug has the correct color, but it belongs somewhere different..."]; tree[11] = ["#grov05#So hmm, perhaps the solution has a brown in the left or center box. Or perhaps both!"]; tree[12] = ["%light-off-wholeclue2%"]; tree[13] = ["%light-on-wholeclue1%"]; tree[14] = ["#grov04#Although looking at the second clue, it appears the solution doesn't have any brown bugs at all! ...Nor does it have any blues or purples."]; tree[15] = ["#grov06#I'll just drop those bugs by the red \"X\" signpost..."]; tree[16] = ["%move-peg-from-blue-to-287x209%"]; tree[17] = ["%move-peg-from-purple-to-347x210%"]; tree[18] = ["%move-peg-from-brown-to-317x229%"]; tree[19] = ["%light-off-wholeclue1%"]; tree[20] = ["%light-on-wholeclue0%"]; tree[21] = ["#grov02#And, eureka! With no purples or browns, this first clue lets us place our first bug, doesn't it?"]; tree[22] = ["%prompts-y-offset+50%"]; tree[23] = ["#grov05#After all, with no blues or purples in the solution, there must be a yellow to produce this heart. Although... Where does the yellow belong?"]; tree[24] = [30, 40, 50, 60]; tree[30] = ["The yellow\ngoes in the\nleft box"]; tree[31] = ["%move-peg-from-yellow-to-answer0%"]; tree[32] = ["#grov02#Yes, precisely! You catch on quickly, don't you?"]; tree[33] = [100]; tree[35] = ["One yellow\ngoes in the\nleft box"]; tree[36] = [31]; tree[40] = ["The yellow\ngoes in the\ncenter box"]; tree[41] = ["#grov06#I suppose it's possible there's a second yellow in the center box... I can't think that far ahead! But, there must be a yellow in the left box."]; tree[42] = ["%move-peg-from-yellow-to-answer0%"]; tree[43] = ["#grov05#How can I tell? Well, the first clue's heart indicates that there's a bug in the correct position."]; tree[44] = ["#grov04#That means the yellow bug must be in the correct position, seeing as there's no purples or blues."]; tree[45] = [100]; tree[47] = ["One yellow\ngoes in the\ncenter box"]; tree[48] = [41]; tree[50] = ["The yellow\ngoes in the\nright box"]; tree[51] = ["#grov06#I suppose it's possible there's a second yellow in the right box... I can't think that far ahead! But, there must be a yellow in the left box."]; tree[52] = ["%move-peg-from-yellow-to-answer0%"]; tree[53] = ["#grov05#How can I tell? Well, the first clue's heart indicates that there's a bug in the correct position."]; tree[54] = ["#grov04#That means the yellow bug must be in the correct position, seeing as there's no purples or blues."]; tree[55] = [100]; tree[57] = ["One yellow\ngoes in the\nright box"]; tree[58] = [51]; tree[60] = ["There's more\nthan one\nyellow"]; tree[61] = ["%prompts-y-offset+50%"]; tree[62] = ["#grov04#Er well... Perhaps! But we can at least place ONE of the two yellows in its correct box, can't we?"]; tree[63] = [35, 47, 57]; tree[100] = ["%lights-on%"]; tree[101] = ["#grov05#So, do you think you can handle it from here?"]; tree[102] = [130, 120, 140]; tree[120] = ["Yes, it\nseems easy"]; tree[121] = ["#grov02#Ah I see, I'm just in your way then aren't I? I'll leave you to it!"]; tree[130] = ["Maybe, what\ncomes next?"]; tree[131] = ["%lights-dim%"]; tree[132] = ["%light-on-wholeclue3%"]; tree[133] = ["#grov04#Well hmm... The fourth clue indicates there must be a red in the solution doesn't it?"]; tree[134] = ["#grov06#With no browns or blues in the solution, there must be a red to produce this dot. But... Where does the red bug belong?"]; tree[135] = ["%lights-on%"]; tree[136] = ["#grov02#..Remember a white dot means the bug is in the wrong position. Give it some thought and see what you come up with! Good luck!"]; tree[140] = ["No, I\nneed help"]; tree[141] = ["%lights-dim%"]; tree[142] = ["%light-on-wholeclue3%"]; tree[143] = ["#grov04#Sure, let's look at this fourth clue! One of these three bugs is in the solution, since there's one dot here. And with no browns or blues in the solution, it must be the red!"]; tree[144] = ["#grov05#But... Where does the red bug belong?"]; tree[145] = [160, 170, 180, 190]; tree[160] = ["The red\ngoes in the\nleft box"]; tree[161] = ["#grov10#But, the yellow bug looks so comfortable in the left box! Certainly you're not expecting to cram two bugs in that tiny box?"]; tree[162] = ["#grov06#The red bug needs to go in one of the two empty boxes. And actually, that dot in the fourth clue indicates the red bug is in the wrong position, doesn't it?"]; tree[163] = ["#grov05#So unless I'm mistaken, the red bug can't go in the right box either."]; tree[164] = [200]; tree[170] = ["The red\ngoes in the\ncenter box"]; tree[171] = ["%lights-on%"]; tree[172] = ["%move-peg-from-red-to-answer1%"]; tree[173] = ["#grov02#Sharp as a tack! There's no other logical place for the red bug, is there?"]; tree[174] = [201]; tree[180] = ["The red\ngoes in the\nright box"]; tree[181] = ["#grov06#Well, that dot in the fourth clue indicates the red bug is in the wrong position, doesn't it?"]; tree[182] = ["#grov05#If the answer had a red bug in the right box, that fourth clue would have a heart, not a dot. The red bug definitely doesn't go in the right box!"]; tree[183] = [200]; tree[190] = ["There's more\nthan one\nred"]; tree[191] = ["#grov06#Well, that dot in the fourth clue indicates there's no red bug in the rightmost box, doesn't it?"]; tree[192] = ["#grov05#If there were more than one red bug in the solution, that fourth clue would have a heart, not a dot. There's definitely only one red bug."]; tree[193] = [200]; tree[200] = ["%lights-on%"]; tree[201] = ["#grov04#Anyways go ahead and experiment, see what you can come up with! Don't feel bad if it takes you a few tries, these puzzles take some getting used to. Good luck!"]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["%lights-dim%"]; tree[304] = ["#grov04#So for these harder puzzles, you can't put the bugs in any box you want anymore! The ordering of the bugs matters."]; tree[305] = [3]; tree[10000] = ["%lights-on%"]; } else if (PlayerData.level == 1) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov05#So hmmm... This puzzle looks rather tricky! I don't see any colors we can eliminate right off the bat..."]; tree[2] = ["%lights-dim%"]; tree[3] = ["%light-on-wholeclue1%"]; tree[4] = ["#grov02#A-ha, although looking at the second clue I suppose one thing's certain... The solution has a purple in it!"]; tree[5] = ["%lights-on%"]; tree[6] = ["%prompts-dont-cover-clues%"]; tree[7] = ["#grov04#Although hmmm... where does it belong in the solution?"]; tree[8] = [20, 30, 40, 50, 60]; tree[20] = ["The purple\nbelongs in\nthe left\nbox"]; tree[21] = ["#grov05#Err, well let's see... With the second clue, if a purple were in the left box... I suppose that could mean a second purple could go in the right box..."]; tree[22] = ["#grov06#Or, perhaps a red would go into the center box instead... Oh, but the red bug can't go in the center box because of the fourth clue... Tricky!"]; tree[23] = [70]; tree[30] = ["The purple\nbelongs in\nthe center\nbox"]; tree[31] = ["#grov05#Err, well the first clue indicates the purple is in the wrong position. So it doesn't belong in the center box but..."]; tree[32] = ["#grov06#...Hmm, it could really go in either of the two other boxes! It's a coin toss."]; tree[33] = [70]; tree[40] = ["The purple\nbelongs in\nthe right\nbox"]; tree[41] = ["#grov05#Err, well let's see... With the second clue, if a purple were in the right box... I suppose that could mean a second purple could go in the left box..."]; tree[42] = ["#grov06#Or perhaps a second purple could go in the center box... Oh but it can't go there, because of the first clue... Hmm, tricky!"]; tree[43] = [70]; tree[50] = ["I'm not\nsure"]; tree[51] = ["#grov03#Hah! Heheheheh. To be honest, I'm not sure myself this time. It seems like that purple bug could go in one of two places..."]; tree[52] = [70]; tree[60] = ["There's\nmore than\none purple"]; tree[61] = ["#grov05#Err, well the second clue could have two purples, but it might just have a purple and a red! Doesn't that work too?"]; tree[62] = ["#grov06#Let's see... The red couldn't go in the middle box... And I suppose if it went in the right box, the second clue would have two hearts, so that's no good..."]; tree[63] = ["#grov04#I'm not entirely sure if there's two purples yet! I can tell there's one, but I don't know where it goes."]; tree[64] = [70]; tree[70] = ["#grov05#Sometimes if I can't figure out where a bug goes in the solution, I'll just drop it by this green signpost."]; tree[71] = ["%move-peg-from-purple-to-437x229%"]; tree[72] = ["#grov03#It doesn't do anything meaningful, but it helps me to remember which bugs belong in the solution somewhere."]; tree[73] = ["%lights-dim%"]; tree[74] = ["%light-on-wholeclue0%"]; tree[75] = ["#grov02#Although ooh! Now that we know there's a purple in the solution... We can do something with that first clue, can't we?"]; tree[76] = ["%lights-on%"]; tree[77] = ["#grov04#Hmm yes, I think you can take it from here! Let me know if you get stuck."]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["#grov04#So, this puzzle looks rather tricky! I don't see any colors we can eliminate right off the bat."]; tree[304] = [2]; tree[10000] = ["%lights-on%"]; } else if (PlayerData.level == 2) { tree[0] = ["%lights-dim%"]; tree[1] = ["%add-light-wq4oq24piy-location-664x002x064x030%"]; tree[2] = ["%undo-buttons-on%"]; tree[3] = ["#grov04#I think you're getting the hang of these puzzles now! Although, did you notice these undo/redo buttons in the corner?"]; tree[4] = ["#grov05#They're helpful if you realize you've made a mistake. That way you can go back a few steps and try something different."]; tree[5] = ["%remove-light-wq4oq24piy%"]; tree[6] = ["%undo-buttons-off%"]; tree[7] = ["%lights-on%"]; tree[8] = ["#grov10#Or alternatively if you're really stuck... And of course I would never do this personally! But..."]; tree[9] = ["#grov08#You could try GUESSING something, work forward from there, and undo everything if you hit a contradiction."]; tree[10] = ["#grov14#Of course, I would never resort to something as barbaric as GUESSING my way through a puzzle! ...I mean, guessing!? Pish posh!!"]; tree[11] = ["#grov03#I mean perhaps sometimes, if it's late... Or if I've had a little to drink..."]; tree[12] = ["#grov00#I might occasionally be tempted to experiment... Do something irresponsible..."]; tree[13] = ["#grov01#See where the puzzle takes me..."]; tree[14] = ["#grov00#......"]; tree[15] = ["#grov10#Ahh! Anyways, yes. Final puzzle is it? ...You can do it!"]; tree[300] = ["%mark-startover%"]; tree[301] = ["%lights-dim%"]; tree[302] = ["%add-light-wq4oq24piy-location-664x002x064x030%"]; tree[303] = ["%undo-buttons-on%"]; tree[304] = ["#grov05#Ah, sure thing! I didn't have anything in particular to say about this puzzle, but wanted to point out these undo/redo buttons in the corner."]; tree[305] = ["#grov04#They're helpful if you realize you've made a mistake. That way you can go back a few steps and try something different."]; tree[306] = [5]; tree[10000] = ["%lights-on%"]; tree[10001] = ["%remove-light-wq4oq24piy%"]; tree[10002] = ["%undo-buttons-off%"]; } } public static function tutorial4Peg(tree:Array<Array<Object>>) { if (PlayerData.level == 0) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov02#Tutorial time again, is it? Very well. Although... I'm sort of running out of things to teach you!"]; tree[2] = ["%lights-dim%"]; tree[3] = ["%add-light-7dgnkhnq-location-263x007x242x037%"]; tree[4] = ["#grov05#Well, these four-peg puzzles do introduce one new tool-- these holopads at the top..."]; tree[5] = ["%lights-on%"]; tree[6] = ["#grov04#These holopads are especially useful for puzzles such as this one with a lot of positional clues!"]; tree[7] = ["%lights-dim%"]; tree[8] = ["%light-on-wholeclue1%"]; tree[9] = ["#grov05#For example, this second clue tells us that a blue can't go in the first or third box..."]; tree[10] = ["#grov03#After all, a blue in the first or third box of the solution would be in the correct position, and this clue would have a heart! Any blues definitely have to go somewhere else."]; tree[11] = ["%light-off-wholeclue1%"]; tree[12] = ["%light-on-wholeclue2%"]; tree[13] = ["#grov06#And this third clue indicates a blue can't go in the fourth box either! Hmm, so if there's a blue... then... Interesting!"]; tree[14] = ["%light-off-wholeclue2%"]; tree[15] = ["%light-on-7dgnkhnq%"]; tree[16] = ["%move-peg-from-blue-to-holopad0%"]; tree[17] = ["#grov04#Anyways, sometimes to keep clues like this straight in my head, I'll drop a critter on the holopad up here."]; tree[18] = ["%holopad-state-blue-0100%"]; tree[19] = ["#grov05#Then, since a blue bug can't go in the first, third or fourth boxes, I'll click these holograms to hide them. See?"]; tree[20] = ["%lights-on%"]; tree[21] = ["%remove-light-7dgnkhnq%"]; tree[22] = ["%label-peg-purple-as-2bdpx6wr%"]; tree[23] = ["%move-peg-from-2bdpx6wr-to-holopad1%"]; tree[24] = ["%holopad-state-purple-0010%"]; tree[25] = ["#grov06#Let's see... Similarly, a purple bug can't go in the first, second or fourth boxes..."]; tree[26] = ["%move-peg-from-green-to-holopad2%"]; tree[27] = ["%holopad-state-green-1001%"]; tree[28] = ["%move-peg-from-brown-to-holopad3%"]; tree[29] = ["%holopad-state-brown-1101%"]; tree[30] = ["#grov04#A green bug can't go in the second or third boxes, and a brown bug can't go in the third box..."]; tree[31] = ["%prompts-y-offset+30%"]; tree[32] = ["#grov05#A-ha! There we go, there's one bug we can place in the solution for certain. Do you see it?"]; tree[33] = [50, 70, 90, 110]; tree[50] = ["A green\nbelongs in\nthe first\nbox"]; tree[51] = ["#grov06#Hmm, well, that's possible... But a brown might go in the first box instead! All we know about the first box is that it doesn't have a purple or a blue."]; tree[52] = ["%lights-dim%"]; tree[53] = ["%add-light-mpjed9p8-location-416x004x030x140%"]; tree[54] = ["#grov02#However, we know the third box doesn't have a green, a blue or a brown... It must have a purple!"]; tree[55] = ["%remove-light-mpjed9p8%"]; tree[56] = ["%lights-on%"]; tree[57] = [150]; tree[70] = ["A blue\nbelongs in\nthe second\nbox"]; tree[71] = ["#grov06#Hmm, well, that's possible... But there might not be any blues in the solution at all! All we know about the second box is that it doesn't have a purple or green."]; tree[72] = ["%lights-dim%"]; tree[73] = ["%add-light-mpjed9p8-location-416x004x030x140%"]; tree[74] = ["#grov02#However, we know the third box doesn't have a green, a blue or a brown... It must have a purple!"]; tree[75] = ["%remove-light-mpjed9p8%"]; tree[76] = ["%lights-on%"]; tree[77] = [150]; tree[90] = ["A purple\nbelongs in\nthe third\nbox"]; tree[91] = ["#grov02#Yes, sharp as always! The third box can't have a green, a blue or a brown... It must have a purple."]; tree[92] = [150]; tree[110] = ["A blue\nbelongs in\nthe fourth\nbox"]; tree[111] = ["%lights-dim%"]; tree[112] = ["%light-on-wholeclue2%"]; tree[113] = ["#grov06#Hmm, well, the fourth box in the solution can't have a blue! Otherwise, this third clue would have a bug in the correct position, and would have a heart."]; tree[114] = ["%light-off-wholeclue2%"]; tree[115] = ["%add-light-mpjed9p8-location-416x004x030x140%"]; tree[116] = ["#grov02#However, we know the third box doesn't have a green, a blue or a brown... It must have a purple!"]; tree[117] = ["%remove-light-mpjed9p8%"]; tree[118] = ["%lights-on%"]; tree[119] = [150]; tree[150] = ["%move-peg-from-purple-to-answer2%"]; tree[151] = ["#grov05#I'll go ahead and drop a purple into the third box in the solution. Oh, but look at this--"]; tree[152] = ["#grov03#We can also tell this is the ONLY purple! Based on our positional clues, a second purple can't be placed in the first, second or fourth boxes without breaking a clue."]; tree[153] = ["%move-peg-from-2bdpx6wr-to-287x229%"]; tree[154] = ["#grov04#I'll just move our holopad purple by this red \"X\", so I'll remember there's no more purples in the solution."]; tree[155] = ["#grov02#Anyways I'll leave you to finish the puzzle at your own pace. Have fun!"]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["%lights-dim%"]; tree[304] = ["%add-light-7dgnkhnq-location-263x007x242x037%"]; tree[305] = ["#grov06#So, these four-peg puzzles introduce a new tool-- these holopads at the top..."]; tree[306] = [5]; tree[10000] = ["%lights-on%"]; tree[10001] = ["%remove-light-7dgnkhnq%"]; tree[10002] = ["%remove-light-mpjed9p8%"]; } else if (PlayerData.level == 1) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov06#Hmm, let's see. What's the best way to start this puzzle..."]; tree[2] = ["#grov02#Hmm... Hmm... Ah! We really hit the jackpot with this one."]; tree[3] = ["%lights-dim%"]; tree[4] = ["%light-on-wholeclue0%"]; tree[5] = ["#grov04#Whenever you see clues like this with no hearts, you know those four bugs are each in the wrong position."]; tree[6] = ["%light-off-wholeclue0%"]; tree[7] = ["%light-on-clue1peg0%"]; tree[8] = ["#grov05#So here in clue #2, I know this green bug can't be in the correct position. Otherwise, clue #1 would have a red heart!"]; tree[9] = ["%cluecloud-clue1peg0-no%"]; tree[10] = ["#grov06#I'll click this green bug to mark it with an \"X\". That way I can keep track of which bugs are wrong."]; tree[11] = ["%light-off-clue1peg0%"]; tree[12] = ["%light-on-clue1peg2%"]; tree[13] = ["%cluecloud-clue1peg2-no%"]; tree[14] = ["#grov03#...And, I can tell this blue bug is in the wrong position using the same logic! I'll mark it with an \"X\" as well."]; tree[15] = ["%light-off-clue1peg2%"]; tree[16] = ["%light-on-wholeclue1%"]; tree[17] = ["%prompts-dont-cover-clues%"]; tree[18] = ["#grov04#Hmm, what do you suppose that implies about these remaining two bugs in the second clue?"]; tree[19] = [30, 40, 60, 80]; tree[30] = ["The blue\nand yellow\nare in the\ncorrect\nposition"]; tree[31] = ["%lights-on%"]; tree[32] = ["#grov02#Exactly! The blue and yellow bug must be responsible for the two hearts in clue #2, so they must be in the correct position."]; tree[33] = [100]; tree[40] = ["The blue\nand yellow\nare in the\nwrong\nposition"]; tree[41] = ["#grov06#Err, well... Actually it means exactly the opposite! The blue and yellow bugs must be responsible for the two hearts in clue #2."]; tree[42] = ["%light-on-rightclue0%"]; tree[43] = ["#grov05#After all, if one of the two other bugs was responsible for a heart in clue #2-- we'd see a heart in clue #1 as well."]; tree[44] = ["%light-off-rightclue0%"]; tree[45] = ["%lights-on%"]; tree[46] = [100]; tree[60] = ["The green\nand blue\nare in the\ncorrect\nposition"]; tree[61] = ["%light-on-rightclue0%"]; tree[62] = ["#grov06#Err, well... Actually if the green or the blue bugs were in the correct position, we'd see a heart in clue #1, instead of two dots!"]; tree[63] = ["%light-off-rightclue0%"]; tree[64] = ["#grov04#So actually, what it tells us is that the blue and yellow bugs must be responsible for the two hearts in clue #2. They must be in the correct position."]; tree[65] = ["#grov05#After all, if one of the two other bugs was responsible for a heart in clue #2-- we'd see a heart in clue #1 as well."]; tree[66] = ["%lights-on%"]; tree[67] = [100]; tree[80] = ["The green\nand blue\nare in the\nwrong\nposition"]; tree[81] = ["%light-on-rightclue0%"]; tree[82] = ["#grov06#Err, well... I suppose that's technically correct, given the dots in the first clue. If the green or blue bugs were in the correct position, those would be hearts."]; tree[83] = ["%light-off-rightclue0%"]; tree[84] = ["#grov04#But more specifically, it tells us that the blue and yellow bugs must be responsible for the two hearts in clue #2. They must be in the correct position."]; tree[85] = ["#grov05#After all, if one of the two other bugs was responsible for a heart in clue #2-- we'd see a heart in clue #1 as well."]; tree[86] = ["%lights-on%"]; tree[87] = [100]; tree[100] = ["#grov06#I'll go ahead and drop the blue and yellow bugs into place..."]; tree[101] = ["%move-peg-from-blue-to-answer1%"]; tree[102] = ["%move-peg-from-yellow-to-answer3%"]; tree[103] = ["#grov03#That's a pretty powerful technique isn't it? Why, we're only 30 seconds into the puzzle and it's already half finished."]; tree[104] = ["#grov05#Hmm... I suppose there's a few different directions you could go from here! I'll leave it up to you."]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov05#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["%lights-dim%"]; tree[304] = ["%light-on-wholeclue0%"]; tree[305] = ["#grov04#Now as I was saying, whenever you see clues like this with no hearts, you know those bugs are all in the wrong position..."]; tree[306] = [6]; tree[10000] = ["%lights-on%"]; } else if (PlayerData.level == 2) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov10#Oof, my goodness! Four clues, and they all have exactly two hits."]; tree[2] = ["#grov08#Puzzles like this one can feel a bit impenetrable. If you look at each clue individually, there's no bugs which must be present or absent in the solution."]; tree[3] = ["%lights-dim%"]; tree[4] = ["%light-on-wholeclue0%"]; tree[5] = ["%light-on-wholeclue3%"]; tree[6] = ["%prompts-dont-cover-clues%"]; tree[7] = ["#grov04#Ahh, but look at this! Based on the first and fourth clue... What can we figure out about the blue bugs in the solution?"]; tree[8] = [40, 20, 60, 80]; tree[20] = ["If there's a\nblue bug, it's\nin position\n#3"]; tree[21] = ["#grov06#Sure, the first clue indicates that any blue bugs must be in position #3. But what about the fourth clue? The fourth clue directly contradicts that!"]; tree[22] = ["#grov05#It's actually impossible to have any blue bugs in the solution. Why is that?"]; tree[23] = ["#grov04#Well, it's because a blue bug in position #3 violates the fourth clue, but a blue bug anywhere else violates the first clue."]; tree[24] = ["%lights-on%"]; tree[25] = [100]; tree[40] = ["If there's a\nblue bug, it's\nin position\n#1, #2 or #4"]; tree[41] = ["#grov06#Sure, the fourth clue indicates that any blue bugs must be in position #1, #2 or #4. But what about the first clue? The first clue directly contradicts that!"]; tree[42] = ["#grov05#It's actually impossible to have any blue bugs in the solution. Why is that?"]; tree[43] = ["#grov04#Well, it's because a blue bug in position #3 violates the fourth clue, but a blue bug anywhere else violates the first clue."]; tree[44] = ["%lights-on%"]; tree[45] = [100]; tree[60] = ["There's at\nleast one\nblue bug"]; tree[61] = ["#grov06#Err, well perhaps! Let's think this through. If there were a blue bug, where would it go?"]; tree[62] = ["#grov05#...Perhaps it would go in position #1? That way the fourth clue would produce a dot. But then the first clue would produce a dot too, which is no good."]; tree[63] = ["#grov06#So what if the blue bug were in position #3 instead? The first clue would produce a heart, but the fourth clue would produce a heart as well! That's no good either."]; tree[64] = ["#grov04#It's actually impossible to have any blue bugs in the solution, without either violating clue #1 or #4."]; tree[65] = ["%lights-on%"]; tree[66] = [100]; tree[80] = ["There are\nzero\nblue bugs"]; tree[81] = ["%lights-on%"]; tree[82] = ["#grov02#Spot on! There can't be any blue bugs in the solution, because they'd either violate clue #1 or clue #4."]; tree[83] = [100]; tree[100] = ["#grov05#I'll go ahead and drop a blue bug by that red \"X\"..."]; tree[101] = ["%move-peg-from-blue-to-297x224%"]; tree[102] = ["%lights-dim%"]; tree[103] = ["%light-on-wholeclue2%"]; tree[104] = ["%light-on-wholeclue3%"]; tree[105] = ["%prompts-y-offset-30%"]; tree[106] = ["#grov06#Ah! Now that we know there's no blue bugs in the solution, these last few clues are a lot more helpful, aren't they?"]; tree[107] = [160, 180, 140, 120]; tree[120] = ["There must\nbe a blue\nin the solution"]; tree[121] = ["#grov07#Errr!?! But we just figured out there's..."]; tree[122] = ["#grov10#Wait a moment, are... Are you screwing around with me? You just wanted to see what I'd say, didn't you??"]; tree[123] = ["#grov12#...To think I'd receive this manner of treatment in my very own tutorial! Harumph."]; tree[124] = ["%lights-on%"]; tree[140] = ["There must\nbe a green\nin the solution"]; tree[141] = [200]; tree[160] = ["There must\nbe a purple\nin the solution"]; tree[161] = [200]; tree[180] = ["There must\nbe a yellow\nin the solution"]; tree[181] = [200]; tree[200] = ["%lights-on%"]; tree[201] = ["#grov02#Yes, yes, the student has become the master! ...I'm just in your way at this point, aren't I?"]; tree[202] = ["#grov00#Very well, why don't you show me everything you've learned. I'll just be here... Watching..."]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov05#Sure, I think I can do that! Let me just reset things back to how they were..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["#grov10#So all four of these clues are somewhat useless on their own! With only two markers next to each of them, we can't do very much... logicking."]; tree[304] = [3]; tree[10000] = ["%lights-on%"]; } } public static function tutorial5Peg(tree:Array<Array<Object>>) { if (PlayerData.level == 0) { if (PlayerData.isAbraNice()) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["#grov04#Ah hello again, <name>! One last tutorial, is it? Five pegs? Why, it doesn't get any harder than this. I hope you're ready!!"]; tree[2] = ["#grov05#Now when solving 5-peg puzzles, you'll basically be applying the same concepts you've seen in the other puzzles."]; tree[3] = ["#grov06#...Like, hmm. Oh! We've seen this before."]; tree[4] = ["%lights-dim%"]; tree[5] = ["%light-on-wholeclue0%"]; tree[6] = ["%prompts-dont-cover-clues%"]; tree[7] = ["#grov02#I'll bet this first clue already caught your eye, didn't it? ...Why, that's an important one! What can we learn from that?"]; tree[8] = [30, 20, 10]; tree[10] = ["There's either\na purple,\ngreen or\nred in the\nsolution"]; tree[11] = ["#grov03#Errr, well... Actually it means the exact opposite! There can't be a purple, green or red in the solution."]; tree[12] = ["%light-off-wholeclue0%"]; tree[13] = ["%light-on-rightclue0%"]; tree[14] = ["#grov04#...After all, if there were a purple in the solution, we'd see a dot or a heart for this clue."]; tree[15] = [50]; tree[20] = ["There are no\npurples,\ngreens or\nreds in the\nsolution"]; tree[21] = ["#grov03#That's right. ...I imagine these types of simple deductions are second nature by now, hmm? Heh! Heheheh."]; tree[22] = [50]; tree[30] = ["There's\na purple,\ngreen, and a\nred in the\nsolution"]; tree[31] = [11]; tree[50] = ["%lights-on%"]; tree[51] = ["%move-peg-from-red-to-297x224%"]; tree[52] = ["%move-peg-from-green-to-282x234%"]; tree[53] = ["%move-peg-from-purple-to-312x234%"]; tree[54] = ["#grov05#Why don't we put a purple, green and red by this red signpost to help us remember."]; tree[55] = ["#grov06#Wow, so the solution only includes yellows, browns and blues then! ...Hmm, but how many of each... Let's see..."]; tree[56] = ["%lights-dim%"]; tree[57] = ["%lights-on-wholeclue3%"]; tree[58] = ["#grov04#Well there's a lot of places we could start actually. But how about this fourth clue?"]; tree[59] = ["%prompts-dont-cover-clues%"]; tree[60] = ["#grov05#This fourth clue tells us a tremendous amount, considering we already know there's no greens or reds... What does it tell us?"]; tree[61] = [85, 70, 80, 90]; tree[70] = ["Well,\nthere's a\nbrown in the\nsolution..."]; tree[71] = ["#grov03#Heh! True, but it tells us a whole lot more than that!"]; tree[72] = ["#grov05#After all, three bugs in this clue are correct... But we know the red and green are wrong, from earlier."]; tree[73] = ["#grov04#...That means the two browns and the blue ALL have to be in the solution, doesn't it? ...Goodness!"]; tree[74] = [150]; tree[80] = ["Well,\nthere's a\nblue in the\nsolution..."]; tree[81] = [71]; tree[85] = ["Well,\nthere's a\nbrown and a\nblue in the\nsolution..."]; tree[86] = ["#grov03#Heh! True, but it tells us slightly more information than that."]; tree[87] = [72]; tree[90] = ["Well,\nthere's two\nbrowns and a\nblue in the\nsolution..."]; tree[91] = ["#grov02#Spot on! All three of those colors have to be somewhere in the solution, don't they?"]; tree[92] = ["#grov04#What with the red and green incorrect, those browns and blues are the only bugs left."]; tree[93] = [150]; tree[150] = ["%lights-on%"]; tree[151] = ["%label-peg-brown-as-tkzaz000%"]; tree[152] = ["%label-peg-brown-as-tkzaz001%"]; tree[153] = ["%move-peg-from-tkzaz000-to-437x224%"]; tree[154] = ["%move-peg-from-tkzaz001-to-422x234%"]; tree[155] = ["%move-peg-from-blue-to-452x234%"]; tree[156] = ["#grov05#I'll drop those bugs by this signpost so we remember they're in the solution."]; tree[157] = ["#grov06#Although hmm... there's not much sense in leaving them here, we can place two of them in the solution right away!"]; tree[158] = ["%prompts-dont-cover-clues%"]; tree[159] = ["#grov04#Where do you think the two brown bugs belong?"]; tree[160] = [180, 190, 200, 170]; tree[170] = ["In the\nfirst and...\nthird spot\nfrom the left?"]; tree[171] = ["#grov00#Heh! Heheheh. Perhaps I chose a puzzle that was too easy..."]; tree[172] = ["#grov02#But you're correct of course, the second clue shows the brown bugs can't go anywhere else."]; tree[173] = [210]; tree[180] = ["In the\nfirst and...\nfifth spot\nfrom the left?"]; tree[181] = ["%lights-dim%"]; tree[182] = ["%lights-on-wholeclue1%"]; tree[183] = ["#grov06#Now now, that wouldn't exactly coincide with this second clue would it?"]; tree[184] = ["#grov05#...If there were a brown bug in the fifth spot from the left, this clue would have a bug in the correct position, and a red heart."]; tree[185] = ["#grov04#But since there are no red hearts, there's only two possible positions for those brown bugs; the first and third spots from the left."]; tree[186] = [210]; tree[190] = ["In the\nsecond and...\nfourth spot\nfrom the left?"]; tree[191] = ["%lights-dim%"]; tree[192] = ["%lights-on-wholeclue1%"]; tree[193] = ["#grov06#Now now, that wouldn't exactly coincide with this second clue would it?"]; tree[194] = ["#grov05#...If there were a brown bug in the second spot from the left, this clue would have a bug in the correct position, and a red heart."]; tree[195] = [185]; tree[200] = ["In the\nthird and...\nfifth spot\nfrom the left?"]; tree[201] = ["%lights-dim%"]; tree[202] = ["%lights-on-wholeclue1%"]; tree[203] = ["#grov06#Now now, that wouldn't exactly coincide with this second clue would it?"]; tree[204] = ["#grov05#...If there were a brown bug in the fifth spot from the left, this clue would have a bug in the correct position, and a red heart."]; tree[205] = [185]; tree[210] = ["%lights-on%"]; tree[211] = ["%move-peg-from-tkzaz000-to-answer0%"]; tree[212] = ["%move-peg-from-tkzaz001-to-answer2%"]; tree[213] = ["#grov02#Hopefully that's enough to get you on your way, I think I'll leave you to finish this puzzle at your own pace."]; tree[214] = ["#grov04#Take your time, and remember your training from the other tutorials."]; tree[300] = ["%mark-startover%"]; tree[301] = ["#grov04#Ah, sure thing! Let me just reset the puzzle how it was..."]; tree[302] = ["%reset-puzzle%"]; tree[303] = ["#grov05#Anyways as I was saying, when solving 5-peg puzzles, you'll be applying the same concepts you've seen in the other puzzles."]; tree[304] = [2]; tree[10000] = ["%lights-on%"]; } else { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["%setvar-0-0%"]; // default to regular "start over" state tree[2] = ["#grov04#Ah hello again, <name>! One last tutorial, is it? Five pegs? Why, it doesn't get any harder than this. I hope you're ready!!"]; tree[3] = ["#grov06#Now when solving 5-peg puzzles, you'll basically be applying the same-"]; tree[4] = ["%enterabra%"]; tree[5] = ["#abra06#Hmm. This is some pretty advanced stuff, Grovyle!"]; tree[6] = ["#abra04#Why don't you let me handle this tutorial? I think I can do a better job explaining these harder concepts."]; tree[7] = ["#grov08#But Abra... You're so dreadful at explaining things! ...Don't you remember back when you used to run all these tutorials?"]; tree[8] = ["#grov09#...And all those players quit, demoralized and confused? ...And they sent us all those nasty e-mails?"]; tree[9] = ["#abra12#Yes, yes, I remember. But I'm trying to get better at relating my thoughts to lower life forms."]; tree[10] = ["#abra09#You know, talking to them at their level. ...At their level of stupidness."]; tree[11] = ["#grov08#..."]; tree[12] = ["#abra06#You have no idea how challenging it is for someone of my intelligence! It's like, how should I word this..."]; tree[13] = ["#abra08#It's like trying to explain discrete math to a chimpanzee."]; tree[14] = ["#grov09#......"]; tree[15] = ["#abra09#Well, more like trying to explain discrete math to a snail."]; tree[16] = ["#abra05#A, hmm... A snail of below-average intelligence. A retarded snail."]; tree[17] = ["#grov10#This conversation is not... exactly bestowing me with confidence that you're ready to lead the player in a tutorial, Abra!"]; tree[18] = ["%move-peg-from-red-to-297x224%"]; tree[19] = ["%move-peg-from-green-to-282x234%"]; tree[20] = ["%move-peg-from-purple-to-312x234%"]; tree[21] = ["#abra12#...Is this seriously the puzzle you chose for him? Why, this is insulting! There's no reds, greens OR purples in it?"]; tree[22] = ["#grov06#Well, err... I've found it's nice to start them with something to boost their confidence before-"]; tree[23] = ["%tomidabra%"]; tree[24] = ["%move-peg-from-brown-to-answer0%"]; tree[25] = ["%move-peg-from-brown-to-answer2%"]; tree[26] = ["#abra13#And look at these sloppy positional clues! The browns have to go here and here..."]; tree[27] = ["%move-peg-from-yellow-to-answer4%"]; tree[28] = ["#abra12#And then there must be a yellow here, and a blue would go-"]; tree[29] = ["#grov13#Hey! ...Let <name> do that. You're spoiling the puzzle for him!"]; tree[30] = ["#abra08#..."]; tree[31] = ["#abra09#I shudder to think of how much <name> could have learned if I'd been mentoring him from the beginning. Let me have a turn with him!"]; tree[32] = ["#grov08#...But I'm REALLY fond of <name>, and I just know you're going to scare him off!! Can't you just let me handle this one last tutorial?"]; tree[33] = ["#abra04#Scare him off? ...I like to think I've gotten better at communicating complex concepts while disguising my air of subtle condescension."]; tree[34] = ["#abra05#...But, let's have <name> chime in here."]; tree[35] = ["#abra06#<name>, do you think I'm capable of communicating complex concepts while disguising my air of subtle condescension?"]; tree[36] = ["#abra08#Hmm... That may have been a confusing sentence for a snail of your intelligence..."]; tree[37] = ["#abra06#Do you think I can... teach... without talking like a big meanie?"]; tree[38] = [110, 90, 70, 50]; tree[50] = ["Yes"]; tree[51] = ["%swapwindow-abra%"]; tree[52] = ["%setprofindex-0%"]; tree[53] = ["#abra02#Great! Then let's begin."]; tree[54] = ["#grov10#Oh!! Goodness..."]; tree[55] = ["#grov09#<name>, umm, you might not know what you're in for. I'll tell you in advance I don't think you're a retarded snail."]; tree[56] = ["#grov08#...Maybe you can come visit me afterwards for a confidence boost."]; tree[57] = ["#grov09#...And a handjob."]; tree[58] = ["#grov10#...I'll make this up to you, I promise! Please don't quit the game!"]; tree[59] = ["%move-peg-from-blue-to-answer1%"]; tree[60] = ["%move-peg-from-yellow-to-answer3%"]; tree[61] = ["#abra03#Okay okay, shoo! Shoo! It's my turn. ...And let's get this baby stuff out of the way!"]; tree[70] = ["Maybe?"]; tree[71] = ["%swapwindow-abra%"]; tree[72] = ["%setprofindex-0%"]; tree[73] = ["#abra02#Great! Then let's begin."]; tree[74] = ["#grov10#Err, I think that was a \"maybe\", Abra."]; tree[75] = ["#abra05#Oh! Oh, I forgot you're limited to verbal communication with the player, Grovyle."]; tree[76] = ["#abra04#By probing <name>'s mind I was able to read the intention behind those words. It was an optimistic maybe."]; tree[77] = ["#grov08#I don't... errm... Well, okay."]; tree[78] = ["%swapwindow-abra%"]; tree[79] = ["#abra03#Wheh-heh-heh!"]; tree[80] = [150]; tree[90] = ["...No"]; tree[91] = ["%swapwindow-abra%"]; tree[92] = ["%setprofindex-0%"]; tree[93] = ["#abra02#Great! Then let's begin."]; tree[94] = ["#grov10#Err, I think that was a \"no\", Abra."]; tree[95] = ["#abra05#Oh! Oh, I forgot you're limited to verbal communication with the player, Grovyle."]; tree[96] = ["#abra04#By probing <name>'s mind I was able to read the intention behind those words. It was a sarcastic no."]; tree[97] = [77]; tree[110] = ["Definitely\nnot"]; tree[111] = ["%swapwindow-abra%"]; tree[112] = ["%setprofindex-0%"]; tree[113] = ["#abra02#Great! Then let's begin."]; tree[114] = ["#grov10#Err, I think that was an emphatic \"no\", Abra."]; tree[115] = [95]; tree[150] = ["%move-peg-from-blue-to-answer1%"]; tree[151] = ["%move-peg-from-yellow-to-answer3%"]; tree[152] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[153] = ["#abra05#Now let's get this baby stuff out of the way."]; tree[300] = ["%mark-startovercomplete%"]; tree[301] = ["#abra11#Ehh? ...Explain what again?"]; tree[302] = ["#abra08#..."]; tree[303] = ["%reset-puzzle%"]; tree[304] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[305] = ["%move-peg-from-brown-to-answer0%"]; tree[306] = ["%move-peg-from-blue-to-answer1%"]; tree[307] = ["%move-peg-from-brown-to-answer2%"]; tree[308] = ["%move-peg-from-yellow-to-answer3%"]; tree[309] = ["%move-peg-from-yellow-to-answer4%"]; tree[310] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[311] = ["#abra09#...Just... Just try not to touch anything this time!"]; tree[350] = ["%mark-startover%"]; tree[351] = ["#abra06#Ehh? ...Explain what again?"]; tree[352] = ["#abra08#..."]; tree[353] = ["%reset-puzzle%"]; tree[354] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[355] = ["%move-peg-from-brown-to-answer0%"]; tree[356] = ["%move-peg-from-blue-to-answer1%"]; tree[357] = ["%move-peg-from-brown-to-answer2%"]; tree[358] = ["%move-peg-from-yellow-to-answer3%"]; tree[359] = ["%move-peg-from-yellow-to-answer4%"]; tree[360] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[361] = ["#abra12#...Just... Just stop hitting the skip button! Why do you want a tutorial if you're just going to skip everything?"]; tree[10000] = ["%swapwindow-abra%"]; tree[10001] = ["%setprofindex-0%"]; tree[10002] = ["%exitgrov%"]; if (PlayerData.gender == PlayerData.Gender.Girl) { DialogTree.replace(tree, 21, "for him", "for her"); DialogTree.replace(tree, 29, "for him", "for her"); DialogTree.replace(tree, 31, "mentoring him", "mentoring her"); DialogTree.replace(tree, 31, "with him", "with her"); DialogTree.replace(tree, 32, "scare him", "scare her"); DialogTree.replace(tree, 33, "Scare him", "Scare her"); } else if (PlayerData.gender == PlayerData.Gender.Complicated) { DialogTree.replace(tree, 21, "for him", "for them"); DialogTree.replace(tree, 29, "for him", "for them"); DialogTree.replace(tree, 31, "mentoring him", "mentoring them"); DialogTree.replace(tree, 31, "with him", "with them"); DialogTree.replace(tree, 32, "scare him", "scare them"); DialogTree.replace(tree, 33, "Scare him", "Scare them"); } if (!PlayerData.grovMale) { DialogTree.replace(tree, 57, "And a handjob", "And you can finger me a little"); } } } else if (PlayerData.level == 1) { if (PlayerData.isAbraNice()) { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[2] = ["#grov04#So, you might be surprised to see only four clues for a 5-peg puzzle! But indeed, more pegs doesn't necessarily mean more clues."]; tree[3] = ["#grov05#It just means we have to make better use of the few clues we were given."]; tree[4] = ["#grov06#Like hmm, let's start by thinking about the red bugs. Looking at the-"]; tree[5] = ["%enterabra%"]; tree[6] = ["#abra06#Hmm. This is some pretty advanced stuff, Grovyle! You've been teaching <name> to solve 5-peg puzzles?"]; tree[7] = ["#grov02#Why yes, this is actually our second one! ...He just finished the first puzzle a moment ago, almost entirely by himself."]; tree[8] = ["#abra05#Say, if <name> is ready for 5-peg puzzles, I have a special type of puzzle which might interest him even further..."]; tree[9] = ["#abra06#Sorry, is that okay? ...I wasn't trying to hijack your tutorial."]; tree[10] = ["#grov06#Mmmm, well ordinarily I'd be more apprehensive considering your history with these tutorials..."]; tree[11] = ["#grov03#... ...But, you seem to have turned over a bit of a new leaf as of late. ...Sure, Abra! Take it away."]; tree[12] = ["%swapwindow-abra%"]; tree[13] = ["%setprofindex-0%"]; tree[14] = ["%fun-nude0%"]; tree[15] = ["#abra03#Wheh-heh-heh! Don't worry <name>, this will be fun~"]; tree[16] = [150]; tree[150] = ["%move-peg-from-purple-to-answer1%"]; tree[151] = ["%move-peg-from-blue-to-answer0%"]; tree[152] = ["%move-peg-from-blue-to-answer2%"]; tree[153] = ["%move-peg-from-blue-to-answer3%"]; tree[154] = ["%move-peg-from-blue-to-answer4%"]; tree[155] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[156] = ["#abra05#Now let's get this baby stuff out of the way."]; tree[300] = ["%mark-startovercomplete%"]; tree[301] = ["#abra11#Ehh? ...Explain what again?"]; tree[302] = ["#abra08#..."]; tree[303] = ["%reset-puzzle%"]; tree[304] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[305] = ["%move-peg-from-purple-to-answer1%"]; tree[306] = ["%move-peg-from-blue-to-answer0%"]; tree[307] = ["%move-peg-from-blue-to-answer2%"]; tree[308] = ["%move-peg-from-blue-to-answer3%"]; tree[309] = ["%move-peg-from-blue-to-answer4%"]; tree[310] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[311] = ["#abra09#...Just... Just try not to touch anything this time!"]; tree[350] = ["%mark-startover%"]; tree[351] = ["#abra06#Ehh? ...Explain what again?"]; tree[352] = ["#abra08#..."]; tree[353] = ["%reset-puzzle%"]; tree[354] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[355] = ["%move-peg-from-purple-to-answer1%"]; tree[356] = ["%move-peg-from-blue-to-answer0%"]; tree[357] = ["%move-peg-from-blue-to-answer2%"]; tree[358] = ["%move-peg-from-blue-to-answer3%"]; tree[359] = ["%move-peg-from-blue-to-answer4%"]; tree[360] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[361] = ["#abra12#...Just... Just stop hitting the skip button! Why do you want a tutorial if you're just going to skip everything?"]; tree[10000] = ["%swapwindow-abra%"]; tree[10001] = ["%setprofindex-0%"]; tree[10002] = ["%exitgrov%"]; if (PlayerData.gender == PlayerData.Gender.Girl) { DialogTree.replace(tree, 7, "He just", "She just"); DialogTree.replace(tree, 7, "by himself", "by herself"); DialogTree.replace(tree, 8, "interest him", "interest her"); } else if (PlayerData.gender == PlayerData.Gender.Complicated) { DialogTree.replace(tree, 7, "He just", "They just"); DialogTree.replace(tree, 7, "by himself", "by themselves"); DialogTree.replace(tree, 8, "interest him", "interest them"); } } else { tree[0] = ["%cube-clue-critters%"]; tree[1] = ["%setvar-0-0%"]; // Default to regular "start over" state tree[2] = ["#abra04#So the REAL secret to solving these puzzles quickly is the laughably small solution space."]; tree[3] = ["#abra05#That is, Grovyle likes to call these \"logic puzzles\" but why use logic at all when you can just brute force it?"]; tree[4] = ["#abra06#After all, with only five different colored bugs, and five boxes to place them in... That's a rather a small number of possible solutions isn't it?"]; tree[5] = ["#abra09#..."]; tree[6] = ["#abra12#That wasn't rhetorical! Isn't it a small number?"]; tree[7] = [20, 30, 40, 50, 60, 70]; tree[20] = ["it's um...\nat least 40?"]; tree[21] = ["#abra08#Well... hmm... yes..."]; tree[22] = ["#abra05#That's correct, five to the fifth power IS at least 40! Here, imagine your mommy gives you five boxes of cookies."]; tree[23] = ["#abra04#Each box of cookies has five rows, and each row has five cookies in it. Each cookie has five chocolate chips, and each chocolate chip is five calories."]; tree[24] = ["#abra02#Count on your fingers. Why, that's 3,125 calories worth of chocolate chips isn't it?"]; tree[25] = [100]; tree[30] = ["it's um...\n325?"]; tree[31] = ["#abra08#Well... hmm... yes..."]; tree[32] = ["#abra05#Alright, five to the fifth power is... almost 325! Here, imagine your mommy gives you five crates of cookies."]; tree[33] = [23]; tree[40] = ["it's um...\n625?"]; tree[41] = ["#abra08#Well... hmm... yes..."]; tree[42] = ["#abra05#Alright, five to the fifth power is... almost 625! Here, imagine your mommy gives you five crates of cookies."]; tree[43] = [23]; tree[50] = ["it's um...\n1,875?"]; tree[51] = ["#abra08#Well... hmm... yes..."]; tree[52] = ["#abra05#Alright, five to the fifth power is... almost 1,875! Here, imagine your mommy gives you five crates of cookies."]; tree[53] = [23]; tree[60] = ["it's um...\n3,125?"]; tree[61] = ["#abra04#Right, now with only 3,125 solutions, you could just run through them in your head. But if that's too much, you can split the problem into two parts."]; tree[62] = [101]; tree[70] = ["it's um...\n9,375?"]; tree[71] = ["#abra08#Well... hmm... yes..."]; tree[72] = ["#abra05#Alright, five to the fifth power is... well, 9,375 is close! Here, imagine your mommy gives you five crates of cookies."]; tree[73] = [23]; tree[100] = ["#abra04#Now with only 3,125 solutions, you could just try them all out in your head. But if that's too much, you can split the problem into two parts."]; tree[101] = ["#abra05#The first part is just figuring out which five colored bugs are in the solution, and the second part is figuring out which order they're in."]; tree[102] = ["#abra06#After all, if we only think about which five colors are in the solution, and not which position they're in... there's a trivial number of color combinations, aren't there?"]; tree[103] = ["#abra08#..."]; tree[104] = ["#abra13#Again, that's not a rhetorical question! Why don't you ever answer my questions?"]; tree[105] = [120, 130, 140, 150, 160, 170]; tree[120] = ["There's\nlike...\n1?"]; tree[121] = ["#abra09#..."]; tree[122] = ["#abra05#Well, 1 is... pretty close. Hmm. How can I put this... Let's imagine your daddy gives you money to open a lemonade stand, right?"]; tree[123] = ["#abra04#So your daddy gives you money corresponding to the k-combination at a given place N in a lexicographic ordering, where k represents the number of lemons..."]; tree[124] = ["#abra09#...I thought this would be easier to explain. Just..."]; tree[125] = ["#abra08#-sigh- 126, okay? There's 126 combinations."]; tree[126] = [200]; tree[130] = ["There's\nlike...\n126?"]; tree[131] = ["#abra04#That's right, now 126 is an incredibly trivial number isn't it?"]; tree[132] = ["#abra02#Why... You can probably count to 126 all by yourself can't you? Well maybe not yet, but some day."]; tree[133] = [201]; tree[140] = ["There's\nlike...\n225?"]; tree[141] = ["#abra09#..."]; tree[142] = ["#abra05#Well, 225 is... pretty close. Hmm. How can I put this... Let's imagine your daddy gives you money to open a lemonade stand, right?"]; tree[143] = [123]; tree[150] = ["There's\nlike...\n324?"]; tree[151] = ["#abra09#..."]; tree[152] = ["#abra05#Well, 324 is... pretty close. Hmm. How can I put this... Let's imagine your daddy gives you money to open a lemonade stand, right?"]; tree[153] = [123]; tree[160] = ["There's\nlike...\n625?"]; tree[161] = ["#abra09#..."]; tree[162] = ["#abra05#Well, 625 is... pretty close. Hmm. How can I put this... Let's imagine your daddy gives you money to open a lemonade stand, right?"]; tree[163] = [123]; tree[170] = ["There's\nlike...\n864?"]; tree[171] = ["#abra09#..."]; tree[172] = ["#abra05#Well, 864 is... pretty close. Hmm. How can I put this... Let's imagine your daddy gives you money to open a lemonade stand, right?"]; tree[173] = [123]; tree[200] = ["#abra05#So, 126 is an incredibly trivial number! Why, you can probably count to 126 all by yourself can't you? Well maybe not yet, but some day."]; tree[201] = ["#abra06#Grovyle loves wasting his time with little heuristics and mental shortcuts. He'd probably tell you something about, hmm... Clue #3..."]; tree[202] = ["%lights-dim%"]; tree[203] = ["%light-on-wholeclue2%"]; tree[204] = ["#abra05#Yes, he'd tell you how clue #3 indicates there's no yellows, because a single yellow in clue #3 would rule out the possibility of all colors except purple..."]; tree[205] = ["%lights-on%"]; tree[206] = ["#abra04#But a solution with four purples and a yellow just doesn't work."]; tree[207] = ["%move-peg-from-yellow-to-307x221%"]; tree[208] = ["#abra05#So, he'd say there's no yellows, and drop a bug over here."]; tree[209] = ["%lights-dim%"]; tree[210] = ["%light-on-wholeclue1%"]; tree[211] = ["%light-on-wholeclue2%"]; tree[212] = ["#abra06#Next hmm... He might tell you how clues #2 and #3 indicate there's no reds, since you'd need three reds to avoid creating any dots..."]; tree[213] = ["%light-off-wholeclue1%"]; tree[214] = ["%light-off-wholeclue2%"]; tree[215] = ["%light-on-wholeclue3%"]; tree[216] = ["#abra04#But a solution with three reds contradicts clue #4. Yes, that's a very Grovyle approach to these things."]; tree[217] = ["%lights-on%"]; tree[218] = ["%move-peg-from-red-to-329x228%"]; tree[219] = ["#abra05#He'd use a lot of these little logic shortcuts to gradually whittle down possibilities..."]; tree[220] = ["#abra06#But all these logic shortcuts are pointless when there's only... 126 color combinations!?!"]; tree[221] = ["#abra02#It's like calculating 2+2 by logically deducing that it can't be 7 or 8. When the answer's that obvious, why bother deducing it?"]; tree[222] = ["%prompts-dont-cover-clues%"]; tree[223] = ["#abra04#Why, there's clearly only one color combination which works."]; tree[224] = [230, 240, 250, 260, 270, 280]; tree[230] = ["Four blues\nand a...\nbrown?"]; tree[231] = ["#abra05#Well, I mean..."]; tree[232] = ["#abra04#..."]; tree[233] = ["%lights-dim%"]; tree[234] = ["%light-on-wholeclue3%"]; tree[235] = ["#abra05#...If there were four blues and a brown, clue #4 wouldn't have three bugs correct. Four blues and a brown is wrong."]; tree[236] = ["%lights-on%"]; tree[237] = [300]; tree[240] = ["Four blues\nand a...\npurple?"]; tree[241] = ["%move-peg-from-purple-to-answer1%"]; tree[242] = ["#abra02#Right. And of course, the purple has to go in the second slot or the hearts don't line up..."]; tree[243] = [302]; tree[250] = ["Four browns\nand a...\nblue?"]; tree[251] = ["#abra08#Well, that..."]; tree[252] = ["#abra09#..."]; tree[253] = ["#abra12#...That literally violates EVERY clue. Are you... Do you not understand the rules!?!"]; tree[254] = ["#abra08#-sigh-"]; tree[255] = [300]; tree[260] = ["Four browns\nand a...\npurple?"]; tree[261] = ["#abra05#Well, I mean..."]; tree[262] = ["#abra04#..."]; tree[263] = ["%lights-dim%"]; tree[264] = ["%light-on-wholeclue3%"]; tree[265] = ["#abra05#...If there were four browns and a purple, clue #4 wouldn't have three bugs correct. Four browns and a purple is wrong."]; tree[266] = ["%lights-on%"]; tree[267] = [300]; tree[270] = ["Four purples\nand a...\nblue?"]; tree[271] = ["#abra05#Well, I mean..."]; tree[272] = ["#abra04#..."]; tree[273] = ["%lights-dim%"]; tree[274] = ["%light-on-wholeclue3%"]; tree[275] = ["#abra05#...If there were four purples and a blue, clue #4 wouldn't have three bugs correct. Four purples and a blue is wrong."]; tree[276] = ["%lights-on%"]; tree[277] = [300]; tree[280] = ["Four purples\nand a...\nbrown?"]; tree[281] = ["#abra05#Well, I mean..."]; tree[282] = ["#abra04#..."]; tree[283] = ["%lights-dim%"]; tree[284] = ["%light-on-wholeclue3%"]; tree[285] = ["#abra05#...If there were four purples and a brown, clue #4 wouldn't have three bugs correct. Four purples and a brown is wrong."]; tree[286] = ["%lights-on%"]; tree[287] = [300]; tree[300] = ["%move-peg-from-purple-to-answer1%"]; tree[301] = ["#abra04#There's four blues and a purple. Of course, the purple has to go in the second slot or the hearts don't line up..."]; tree[302] = ["%move-peg-from-blue-to-answer0%"]; tree[303] = ["%move-peg-from-blue-to-answer2%"]; tree[304] = ["%move-peg-from-blue-to-answer3%"]; tree[305] = ["%move-peg-from-blue-to-answer4%"]; tree[306] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[307] = ["#abra06#And then the rest are all blue. As a matter of fact, you can deduce all of that without the first clue. Isn't that strange?"]; tree[308] = ["#abra02#The truth is, I always include one extra clue just to make the puzzles easier."]; tree[309] = ["#abra08#Hmm, maybe I should stop including that extra clue. Are these puzzles too easy? How long did that take you... three minutes?"]; tree[310] = ["#abra05#Well, let's try something more challenging next. Yes, I think I have something that will work."]; tree[400] = ["%mark-startovercomplete%"]; tree[401] = ["%mark-startover%"]; tree[402] = ["#abra08#Oh... Well... Sure. I guess."]; tree[403] = ["%reset-puzzle%"]; tree[404] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[405] = ["#abra09#I'll... try to use smaller words this time."]; tree[406] = [1]; tree[10000] = ["%lights-on%"]; if (!PlayerData.grovMale) { DialogTree.replace(tree, 201, "his time", "her time"); DialogTree.replace(tree, 201, "He'd probably", "She'd probably"); DialogTree.replace(tree, 204, "he'd tell", "she'd tell"); DialogTree.replace(tree, 208, "he'd say", "she'd say"); DialogTree.replace(tree, 212, "He might", "She might"); DialogTree.replace(tree, 219, "He'd use", "She'd use"); } } } else if (PlayerData.level == 2) { tree[0] = ["%lights-off%"]; tree[1] = ["%cube-clue-critters%"]; tree[2] = ["%setvar-0-0%"]; // default to regular "start over" state tree[3] = ["#abra00#So, for those who've mastered 5-peg puzzles, I've been experimenting with something a little more difficult..."]; tree[4] = ["%lights-on%"]; tree[5] = ["#abra03#7-peg puzzles! Ee-heheheh! Pretty nifty yes?"]; tree[6] = [60, 20, 30, 50, 40]; tree[20] = ["Wow!\nCool!"]; tree[21] = [100]; if (PlayerData.abraStoryInt == 5) { tree[30] = ["I already\ninvented\n7-peg\npuzzles..."]; tree[31] = [100]; } else { tree[30] = ["So it's two\nextra pegs?\nThat's a\nlittle trite"]; tree[31] = [100]; } tree[40] = ["Good god,\nwhat have\nyou done"]; tree[41] = [100]; tree[50] = ["Noooooooo-\n-oooooooo-\n-ooooooo"]; tree[51] = [100]; tree[60] = ["Hey asshole!\nFive pegs\nwas already\ntoo much!!"]; tree[61] = [100]; tree[100] = ["#abra02#Oh, but I haven't even explained how they work yet!"]; tree[101] = ["#abra04#You see, seven peg puzzles are just like the other puzzles with one extra rule- a bug can never be next to another bug of the same color."]; tree[102] = ["%label-peg-red-as-6d38q000%"]; tree[103] = ["%label-peg-red-as-6d38q001%"]; tree[104] = ["%label-peg-red-as-6d38q002%"]; tree[105] = ["%move-peg-from-6d38q000-to-answer0%"]; tree[106] = ["%move-peg-from-6d38q001-to-answer3%"]; tree[107] = ["#abra05#So for example, these red bugs are next to each other, which isn't allowed. If there's a red in the corner, there can't be a red in the center too."]; tree[108] = ["%move-peg-from-6d38q001-to-answer4%"]; tree[109] = ["%move-peg-from-6d38q002-to-answer5%"]; tree[110] = ["#abra04#At most, there could be three red bugs in the solution... One in each corner."]; tree[111] = ["%move-peg-from-answer0-to-offscreen%"]; tree[112] = ["%move-peg-from-answer4-to-offscreen%"]; tree[113] = ["%move-peg-from-answer5-to-offscreen%"]; tree[114] = ["%unlabel-pegs%"]; tree[115] = ["#abra06#These puzzles shouldn't be too tough. ...And if you're struggling, you can still use all of Grovyle's so-called \"shortcuts\" on them. Like, let's see..."]; tree[116] = ["%lights-dim%"]; tree[117] = ["%light-on-wholeclue0%"]; tree[118] = ["%light-on-wholeclue4%"]; tree[119] = ["%prompts-dont-cover-7peg-clues%"]; tree[120] = ["#abra05#Oh, I suppose clues #1 and #5 have a lot of hits. We can trivially deduce there's two particular colors in the solution, can't we?"]; tree[121] = [160, 150, 140, 130]; tree[130] = ["Green and\nred?"]; tree[131] = ["%lights-off-wholeclue4%"]; tree[132] = ["#abra02#Right! ...Because we can't get six hits for clue #1 without a green in the solution,"]; tree[133] = ["%lights-off-wholeclue0%"]; tree[134] = ["%lights-on-wholeclue4%"]; tree[135] = ["#abra04#And we can't get five hits for clue #5 without a red in the solution."]; tree[136] = ["%lights-on%"]; tree[137] = ["#abra02#You see? It's the same trick you've used for other puzzles already. Easy! Ee-heh-heh."]; tree[138] = [200]; tree[140] = ["Green and\nbrown?"]; tree[141] = ["%lights-off-wholeclue4%"]; tree[142] = ["#abra09#Well... We can't get six hits for clue #1 without a green in the solution."]; tree[143] = ["%lights-off-wholeclue0%"]; tree[144] = ["%lights-on-wholeclue4%"]; tree[145] = ["#abra04#And we can't get five hits for clue #5 without a red in the solution."]; tree[146] = ["%lights-on%"]; tree[147] = ["#abra05#You see? It's the same trick you've used for other puzzles already, nothing too bad, right?"]; tree[148] = [200]; tree[150] = ["Blue and\nred?"]; tree[151] = [141]; tree[160] = ["Blue and\npurple?"]; tree[161] = [141]; tree[200] = ["%move-peg-from-green-to-427x229%"]; tree[201] = ["%move-peg-from-red-to-447x249%"]; tree[202] = ["#abra04#I'll put those bugs by the green checkmark signpost, and... what next? Hmm... Think like Grovyle... Think like Grovyle..."]; tree[203] = ["%lights-dim%"]; tree[204] = ["%light-on-wholeclue2%"]; tree[205] = ["%light-on-wholeclue5%"]; tree[206] = ["#abra02#Okay, well... Clue #3 shows us several bugs which are in the wrong position for clue #6."]; tree[207] = ["%lights-off-wholeclue5%"]; tree[208] = ["%light-on-clue5peg0%"]; tree[209] = ["%cluecloud-clue5peg0-no%"]; tree[210] = ["#abra05#So clearly this blue must be in the wrong position, or there'd be a heart in clue #3."]; tree[211] = ["%light-off-clue5peg0%"]; tree[212] = ["%light-on-wholeclue5%"]; tree[213] = ["%cluecloud-clue5peg1-no%"]; tree[214] = ["%cluecloud-clue5peg4-no%"]; tree[215] = ["%light-on-wholeclue1%"]; tree[216] = ["%prompts-dont-cover-7peg-clues%"]; tree[217] = ["#abra04#And this yellow and brown are wrong too..."]; tree[218] = ["#abra06#You can tell which two bugs are in the correct position for clue #6 in the bottom-right corner, can't you?"]; tree[219] = [240, 260, 230, 250]; tree[230] = ["Blue and\nyellow?"]; tree[231] = ["%light-off-wholeclue5%"]; tree[232] = ["%light-on-clue5peg5%"]; tree[233] = ["%move-peg-from-blue-to-answer5%"]; tree[234] = ["#abra02#Right, it must be the blue in the bottom-left corner..."]; tree[235] = [304]; tree[240] = ["Brown and\nblue?"]; tree[241] = ["#abra08#Well... There's a brown in the solution, yes. Were you really clever enough to think ahead that far or were you just guessing?"]; tree[242] = ["#abra09#Mmmm, yes. I see. You were just guessing. Okay."]; tree[243] = ["#abra04#So, I was trying to explain how we can deduce which two bugs in clue #6 are in the correct position, without guessing."]; tree[244] = [300]; tree[250] = ["Brown and\nyellow?"]; tree[251] = ["#abra08#Well... There's a brown in the solution, yes. Were you really clever enough to think ahead that far or were you just guessing?"]; tree[252] = [242]; tree[260] = ["Two\nblues?"]; tree[261] = ["#abra08#Well... There's two blues in the solution, yes. Were you really clever enough to deduce that or were you just guessing?"]; tree[262] = [242]; tree[300] = ["%light-off-wholeclue5%"]; tree[301] = ["%light-on-clue5peg5%"]; tree[302] = ["%move-peg-from-blue-to-answer5%"]; tree[303] = ["#abra05#It must be the blue in the bottom-left corner..."]; tree[304] = ["%light-off-clue5peg5%"]; tree[305] = ["%light-on-clue5peg6%"]; tree[306] = ["%move-peg-from-yellow-to-answer6%"]; tree[307] = ["#abra04#And, it must be the yellow in the bottom right corner."]; tree[308] = ["%lights-on%"]; tree[309] = ["#abra05#No other bugs from clue #6 can be in the correct position without invalidating either clue #2 or clue #3."]; tree[310] = ["#abra04#Right? Again, nothing new. You've used all of these techniques before. Oooh, but here's something you haven't seen before-"]; tree[311] = ["%move-peg-from-yellow-to-287x229%"]; tree[312] = ["#abra02#There's no more yellows in the solution. Do you see why?"]; tree[313] = ["%lights-dim%"]; tree[314] = ["%light-on-answer0%"]; tree[315] = ["%light-on-answer1%"]; tree[316] = ["%light-on-answer2%"]; tree[317] = ["%light-on-answer3%"]; tree[318] = ["%light-on-answer4%"]; tree[319] = ["#abra05#It's because there's only five places they can go..."]; tree[320] = ["%light-off-answer1%"]; tree[321] = ["%light-off-answer2%"]; tree[322] = ["%light-on-wholeclue3%"]; tree[323] = ["#abra04#If a yellow was in the left or upper-right corner, it would invalidate clue #4..."]; tree[324] = ["%light-off-wholeclue3%"]; tree[325] = ["%light-on-wholeclue1%"]; tree[326] = ["%light-off-answer0%"]; tree[327] = ["#abra05#If a yellow was in the upper-left corner, it would invalidate clue #2..."]; tree[328] = ["%lights-dim%"]; tree[329] = ["#abra04#And if it were anywhere else, it would be next to the yellow we've already placed!"]; tree[330] = ["%lights-on%"]; tree[331] = ["#abra02#Ah, see? You're understanding it now aren't you."]; tree[332] = ["#abra00#Actually... Wow! Looking at your neural activity, I'm seeing new pathways I've never seen you open before."]; tree[333] = ["#abra02#It looks like spatial reason's handled over here... And deductive reason's handled in this part of your brain. Yes, I see."]; tree[334] = ["#abra07#Now that you're using those two regions at the same time, they're communicating in a way that... Wow..."]; tree[335] = ["#abra00#That's actually, really... Mmm... Mmmmphh..."]; tree[336] = ["#abra01#..."]; tree[337] = ["%lights-dim%"]; tree[338] = ["%light-on-rightclue1%"]; tree[339] = ["%light-on-rightclue3%"]; tree[340] = ["#abra00#Umm anyways, see those white dots in clues #2 and #4? Look at them. Yes, really think about what they mean! Mmm, that's it."]; tree[341] = ["%lights-dim%"]; tree[342] = ["%light-on-wholeclue1%"]; tree[343] = ["%light-on-wholeclue3%"]; tree[344] = ["%prompts-dont-cover-7peg-clues%"]; tree[345] = ["#abra04#Based on those white dots, how many browns do you think are in the solution?"]; tree[346] = [350, 375, 390, 395]; tree[350] = ["Zero\nbrowns?"]; tree[351] = ["%lights-dim%"]; tree[352] = ["%lights-on-wholeclue0%"]; tree[353] = ["%lights-on-wholeclue5%"]; tree[354] = ["#abra06#Well, there's definitely more than zero browns, look at clues #1 and #6!"]; tree[355] = ["#abra04#It's impossible to fulfill both of those clues with no browns in the solution."]; tree[356] = ["%lights-dim%"]; tree[357] = ["%light-on-answer0%"]; tree[358] = ["%light-on-answer1%"]; tree[359] = ["%light-on-answer2%"]; tree[360] = ["%light-on-answer3%"]; tree[361] = ["%light-on-answer4%"]; tree[362] = ["#abra05#But based on clues #2 and #4, there must be fewer than two browns. A second brown would have to contradict one of those two clues."]; tree[363] = [407]; tree[375] = ["Zero or one\nbrowns?"]; tree[376] = ["#abra02#That's... Wow! Did you really figure that out yourself?"]; tree[377] = ["#abra01#There's so much about your primitive brain that I don't... quite... understand yet."]; tree[378] = ["#abra00#I didn't think you'd be able to... Oh! Mmmm, wow..."]; tree[379] = [430]; tree[390] = ["One or two\nbrowns?"]; tree[391] = [400]; tree[395] = ["Two or three\nbrowns?"]; tree[396] = [400]; tree[400] = ["%lights-dim%"]; tree[401] = ["%light-on-answer0%"]; tree[402] = ["%light-on-answer1%"]; tree[403] = ["%light-on-answer2%"]; tree[404] = ["%light-on-answer3%"]; tree[405] = ["%light-on-answer4%"]; tree[406] = ["#abra05#Well, if there were two browns, one of them would have to contradict clue #2 or #4."]; tree[407] = ["%light-off-answer2%"]; tree[408] = ["%light-on-clue1peg2%"]; tree[409] = ["#abra04#A brown in the left cell contradicts clue #2..."]; tree[410] = ["%light-off-answer4%"]; tree[411] = ["%light-off-clue1peg2%"]; tree[412] = ["%light-on-clue3peg4%"]; tree[413] = ["#abra05#Mmm yes, I think you're starting to understand. A brown in the right cell contradicts clue #4, doesn't it?"]; tree[414] = ["#abra04#If there are two browns which occupy neither the left nor right cell, they would be adjacent. And that's not allowed either."]; tree[415] = ["%lights-on%"]; tree[416] = [500]; tree[430] = ["%lights-dim%"]; tree[431] = ["%light-on-answer0%"]; tree[432] = ["%light-on-answer1%"]; tree[433] = ["%light-on-answer3%"]; tree[434] = ["%light-on-answer4%"]; tree[435] = ["%light-on-clue1peg2%"]; tree[436] = ["#abra04#I guess you noticed that a brown in the left cell contradicts clue #2,"]; tree[437] = ["%light-off-answer4%"]; tree[438] = ["%light-off-clue1peg2%"]; tree[439] = ["%light-on-clue3peg4%"]; tree[440] = ["#abra05#A brown in the right cell contradicts clue #4,"]; tree[441] = ["#abra04#And if there are two browns which occupy neither the left nor right cell, they would be adjacent. And that's not allowed either."]; tree[442] = ["%lights-on%"]; tree[443] = [500]; tree[500] = ["#abra00#...Ooogh, there go those neurons of yours again! ...Wow, that cluster is really busy... Mmm... This is very challenging for you isn't it?"]; tree[501] = ["%lights-dim%"]; tree[502] = ["%light-on-wholeanswer%"]; tree[503] = ["%light-on-wholeclue5%"]; tree[504] = ["%move-peg-from-blue-to-answer1%"]; tree[505] = ["%move-peg-from-purple-to-answer2%"]; tree[506] = ["#abra04#So with at most one brown and yellow in the solution, clue #6 lets us place an additional blue and purple..."]; tree[507] = ["%light-off-wholeclue5%"]; tree[508] = ["%move-peg-from-green-to-answer3%"]; tree[509] = ["#abra00#And that means... It means that..."]; tree[510] = ["%move-peg-from-brown-to-answer0%"]; tree[511] = ["%move-peg-from-red-to-answer4%"]; tree[512] = ["%setvar-0-1%"]; // switch to "completely start over" state tree[513] = ["#abra01#Gwahhhhhhhhhhh!! Gw-gwahhhh~~"]; tree[514] = ["#abra00#Ahhh... hah..."]; tree[515] = ["%lights-on%"]; tree[516] = ["#abra01#Sorry, I... hahh... phew, little... braingasm..."]; if (PlayerData.recentChatTime("tutorial.3.2") >= 800 && PlayerData.puzzleCount[4] == 0) { tree[517] = ["#abra10#...I, um. That was your first 7-peg puzzle wasn't it?"]; tree[518] = ["#abra04#I... I should have been gentler. I should have tried to make it more special for you."]; tree[519] = ["#abra00#Maybe... Maybe I can make it up to you? Ee-heheheheh~"]; } else { tree[517] = ["#abra10#...I, um. I swear I'm not usually like this when I'm with most guys."]; tree[518] = ["#abra04#Something about your brain is... different. It just... happened so fast..."]; tree[519] = ["#abra00#Maybe... Maybe I can make it up to you? Ee-heheheheh~"]; if (PlayerData.gender == PlayerData.Gender.Girl) { DialogTree.replace(tree, 517, "most guys", "most girls"); } else if (PlayerData.gender == PlayerData.Gender.Complicated) { DialogTree.replace(tree, 517, "most guys", "most people"); } } tree[800] = ["%mark-startovercomplete%"]; tree[801] = ["#abra02#You want to solve it a second time!?"]; tree[802] = ["#abra00#Ohhh <name>... Twice in one day... You spoil me~"]; tree[803] = ["%reset-puzzle%"]; tree[804] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[805] = ["#abra04#Very well. Ahem! So these puzzles add one extra rule- a bug can never be next to another bug of the same color..."]; tree[806] = [102]; tree[850] = ["%mark-startover%"]; tree[851] = ["#abra06#Ehh? Very well... But try not to interrupt this time."]; tree[852] = ["#abra11#It doesn't feel good to explain something this intense without finishing. ...You're going to give me blue brains!"]; tree[853] = ["%reset-puzzle%"]; tree[854] = ["%setvar-0-0%"]; // switch to regular "start over" state tree[855] = ["#abra04#Ahem! So these puzzles add one extra rule- a bug can never be next to another bug of the same color..."]; tree[856] = [102]; tree[10000] = ["%lights-on%"]; } } /** * prefaced with, "can you handle this one Buizel?" */ public static function scaleGamePartOneLocalHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%set-puzzle-235350%"]; tree[2] = ["#buiz05#Sure! So for this game, <name>, you just gotta use these bugs to balance the two sides of the scale."]; return DialogTree.prepend(tree, scaleGamePartOne()); } static private function scaleGamePartOne():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#buiz06#The bugs all weigh the same, but some of the platforms are further from the center- kinda like uhhh... a messed-up see-saw."]; tree[1] = ["#buiz04#In other words, just putting two bugs on both side won't work. You gotta get the numbers to match up too."]; tree[2] = ["%move-pegs-0-2-1-0%"]; tree[3] = ["#buiz03#Well like, just let me show you 'cause this one looks easy. You put two bugs here, and one over there- because four plus four equals ten."]; tree[4] = ["#buiz04#Sometimes it takes a little while..."]; tree[5] = ["#buiz13#...Hey, is this thing broken or something!?"]; tree[6] = ["%move-pegs-2-0-1-0%"]; tree[7] = ["%answer-bad%"]; tree[8] = ["#buiz00#OH! Oops... five and five makes ten! Ha! Ha! ...I can add... Bwark..."]; tree[9] = ["#buiz06#Huh wait what? Oh okay. I guess you can't leave any bugs behind or it doesn't count?"]; tree[10] = ["#buiz12#So that means... you have to use, exactly... every single bug? GWAH! That's so annoying."]; tree[11] = ["%move-pegs-2-1-0-1%"]; tree[12] = ["%answer-good%"]; tree[13] = ["#buiz06#Let's see uhhh... I guess four more makes fourteen? Is that it?"]; tree[14] = ["#buiz02#Okay, there we go. It's usually something easy, so try not to overthink it."]; tree[15] = ["%set-puzzle-856515%"]; tree[16] = ["#buiz05#Here you know what, why don't you try one."]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function scaleGamePartOneAbruptHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%set-puzzle-235350%"]; tree[2] = ["#buiz05#So for this game <name>, you just gotta use these bugs to balance the two sides of the scale."]; return DialogTree.prepend(tree, scaleGamePartOne()); } /** * prefaced with, "I'll go get Buizel, he can handle this..." */ public static function scaleGamePartOneRemoteHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%set-puzzle-235350%"]; tree[2] = ["#buiz05#What? Oh yeah, this one! So for this game <name>, you just gotta use these bugs to balance the two sides of the scale."]; return DialogTree.prepend(tree, scaleGamePartOne()); } public static function scaleGamePartOneNoHandoff(minigameState:MinigameState):Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#buiz02#Oh okay, it's " + minigameState.description + "! I can explain this one."]; tree[1] = ["%set-puzzle-235350%"]; tree[2] = ["#buiz05#So... You need to use these bugs to balance the two sides of the scale."]; return DialogTree.prepend(tree, scaleGamePartOne()); } public static function scaleGamePartTwo():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#buiz02#Hey nice work! Twelve on the left side, and twelve on the right side. See, you get it!"]; tree[1] = ["#buiz03#Now the catch is, the rest of us will all be racing to complete the same puzzle... so you gotta think fast!"]; tree[2] = ["#buiz00#Well I mean, you at least gotta think faster than Mr. \"Four Plus Four Equals Ten\" over here... Ha! Ha!"]; tree[3] = ["#buiz04#Anyway so whoever completes the puzzle the fastest gets " + moneyString(denNerf(200)) + ", and you play until someone reaches " + moneyString(denNerf(1000)) + "! Simple stuff, right?"]; tree[10000] = ["%skip-tutorial%"]; if (!PlayerData.buizMale) { DialogTree.replace(tree, 2, "than Mr.", "than Mrs."); } return tree; } public static function scaleGameSummary():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#buiz05#So for this game, <name>, you just gotta move those bugs onto the platforms to make the scale balance."]; tree[1] = ["#buiz04#The total numbers on the left need to equal the total numbers on the right. And uhh, you can't have any bugs left over either."]; tree[2] = ["#buiz03#Whoever completes the puzzle the fastest gets " + moneyString(denNerf(200)) + ", and you keep going until someone reaches " + moneyString(denNerf(1000)) + "! Simple stuff, right?"]; return tree; } /** * prefaced with, "I'll go get Rhydon, he can handle this..." */ public static function stairGamePartOneRemoteHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%move-man-2%"]; tree[2] = ["%hide-turn-indicator%"]; tree[3] = ["#RHYD02#What? Oh, this game! Gr-roar! Yeah, I can explain this one."]; tree[4] = ["#RHYD04#So for this game, we're trying to grab those chests from the top of the stairs. Whoever collects two chests first is the winner."]; return DialogTree.prepend(tree, stairGamePartOne()); } public static function stairGamePartOneNoHandoff() { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%move-man-2%"]; tree[2] = ["#RHYD03#Wait, is this that stair climbing game? Awesome, I love this one!"]; tree[3] = ["#RHYD04#So for this game, we're trying to grab those chests from the top of the stairs. Whoever collects two chests first is the winner."]; return DialogTree.prepend(tree, stairGamePartOne()); } public static function stairGamePartOneAbruptHandoff() { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%move-man-2%"]; tree[2] = ["#RHYD04#So for this game, we're trying to grab those chests from the top of the stairs. Whoever collects two chests first is the winner."]; return DialogTree.prepend(tree, stairGamePartOne()); } public static function stairGamePartOne():Array<Array<Object>> { var manColor:String = Critter.CRITTER_COLORS[0].english; var comColor:String = Critter.CRITTER_COLORS[1].english; var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%wait-for-bugs%"]; tree[2] = ["#RHYD05#So like, I'll be " + comColor + ", and you be " + manColor + ", okay? We gotta climb up to the top, grab a chest, and get back down without getting captured."]; tree[3] = ["%roll-com-2%"]; tree[4] = ["%roll-man-1%"]; tree[5] = ["%rmov-com-3%"]; tree[6] = ["#RHYD04#We take turns movin' 1-4 steps, depending on how the dice are rolled."]; tree[7] = ["%wait-for-bugs%"]; tree[8] = ["#RHYD05#See how some of the dice have feet on them? If you roll 1, 2 or 3 feet, you move that many steps."]; tree[9] = ["%roll-com-2%"]; tree[10] = ["%roll-man-2%"]; tree[11] = ["%rmov-man-4%"]; tree[12] = ["%wait-for-bugs%"]; tree[13] = ["#RHYD04#But if you roll 0 or 4 feet, you get to move four steps AND take an extra turn!"]; tree[14] = ["%pick-up-dice%"]; tree[15] = ["%roll-com-1%"]; tree[16] = ["#RHYD06#But the trick is, we don't roll the dice like normal. We each choose two dice we wanna put out, and the dice are the same on every side."]; tree[17] = ["%roll-man-2%"]; tree[18] = ["%rmov-man-3%"]; tree[19] = ["#RHYD02#So like on your turn, you can just put out two of the feet dice. That way you know you're moving forward at least two steps!"]; tree[20] = ["#RHYD06#But we both gotta throw our dice at the same time, like rock paper scissors. So, you never know for sure what the best move is..."]; tree[21] = ["#RHYD03#...That means if you REALLY wanna win, you gotta stay one step ahead of your opponent! Really get in their head! Gr-r-roarr!"]; tree[22] = ["%pick-up-dice%"]; tree[23] = ["%wait-for-bugs%"]; tree[24] = ["#RHYD04#Here let's do a practice round. I'm controlling the " + comColor + " bug and it's my turn. I'm trying to climb up to the top to get a chest."]; tree[25] = ["#RHYD06#...We're gonna count down from three, okay? And after we count, you need to throw out 0, 1 or 2 dice with feet on them."]; tree[26] = ["%prompts-y-offset-50%"]; tree[27] = ["#RHYD05#We gotta do this at the same time, so try not to cheat! Lemme know when you're ready."]; tree[28] = [45, 35, 40]; tree[35] = ["Okay,\nI'm ready!"]; tree[40] = ["On three,\nthen?"]; tree[45] = ["I think I\nunderstand..."]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function stairGameRepromptDice(tree:Array<Array<Object>>):Void { tree[0] = ["#RHYD06#Err, anyways... So you're throwing out 0, 1 or 2 dice with feet on them."]; tree[1] = ["%prompts-y-offset-50%"]; tree[2] = ["#RHYD05#We gotta do this at the same time, so try not to cheat! Lemme know when you're ready."]; tree[3] = [45, 35, 40]; tree[35] = ["Okay,\nI'm ready!"]; tree[40] = ["On three,\nthen?"]; tree[45] = ["I think I\nunderstand..."]; tree[10000] = ["%skip-tutorial%"]; } public static function stairGamePartTwo(rollAmount:Int):Array<Array<Object>> { var manColor:String = Critter.CRITTER_COLORS[0].english; var comColor:String = Critter.CRITTER_COLORS[1].english; var tree:Array<Array<Object>> = []; if (rollAmount == 2) { tree[0] = ["%move-com-2%"]; tree[1] = ["%wait-for-bugs%"]; tree[2] = ["#RHYD03#Awesome, you nailed it! Gr-roarr!"]; tree[3] = [10]; } else if (rollAmount == 0 || rollAmount == 4) { tree[0] = ["#RHYD03#Awesome, you nailed it! Gr-roarr!"]; tree[1] = ["#RHYD11#Although uhh... Rolling a " + englishNumber(rollAmount) + " means I'd move four spaces and capture your piece, which would kinda ruin the tutorial... Uhhhh..."]; tree[2] = ["%move-com-2%"]; tree[3] = ["%wait-for-bugs%"]; tree[4] = ["#RHYD04#...Tell you what, I'll go easy on you. Let's just pretend I rolled a two instead."]; tree[5] = [10]; } else { tree[0] = ["#RHYD03#Awesome, you nailed it! Gr-roarr!"]; tree[1] = ["%move-com-2%"]; tree[2] = ["%wait-for-bugs%"]; tree[3] = ["#RHYD10#But I kinda wanna show you something. So I'm gonna cheat and pretend I rolled a two instead..."]; tree[4] = [10]; } tree[10] = ["%pick-up-dice%"]; tree[11] = ["#RHYD02#Greh-heh-heh! So you mighta guessed, but that center square is special. It gives you a chest when you land on it, like a little shortcut."]; tree[12] = ["%prompts-y-offset-50%"]; tree[13] = ["#RHYD05#...Now it's your turn! Your little " + manColor + " guy already has a chest, so he's on his way back down. You ready?"]; tree[14] = [25, 20, 30]; tree[20] = ["Hmm, so if I\nmove two spaces..."]; tree[25] = ["Alright,\nI'm ready!"]; tree[30] = ["Yep, seems\nsimple"]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function stairGamePartThree(rollAmount:Int):Array<Array<Object>> { var tree:Array<Array<Object>> = []; if (rollAmount == 2) { tree[0] = ["%move-man-2%"]; tree[1] = ["#RHYD10#Whoa! Have you played this before!? Well... Whatever! This doesn't count, it was just for practice!!!"]; tree[2] = ["%wait-for-bugs%"]; tree[3] = [10]; } else if (rollAmount == 0 || rollAmount == 4) { tree[0] = ["#RHYD02#Whoa, awesome! Rolling a " + englishNumber(rollAmount) + " means you'd get to move four spaces AND get a free turn. That's a great roll!"]; tree[1] = ["#RHYD06#But actually, you can do even better in this position... Hmm..."]; tree[2] = ["%rmov-man-2%"]; tree[3] = ["%wait-for-bugs%"]; tree[4] = ["#RHYD05#Y'know, let's pretend you rolled a two instead so you can see how capturing works."]; tree[5] = ["#RHYD10#Agh! Sorry little guy! Now I feel kinda bad..."]; tree[6] = [10]; } else { tree[0] = ["#RHYD02#Nice! You've got the timing part down. Now you just gotta learn how to predict your opponent's moves!"]; tree[1] = ["%rmov-man-2%"]; tree[2] = ["%wait-for-bugs%"]; tree[3] = ["#RHYD05#...Let's pretend you figured out what I was gonna do, and ended up moving two spaces instead. I wanna show you how capturing works..."]; tree[4] = ["#RHYD10#Agh! Sorry little guy! Now I feel kinda bad..."]; tree[5] = [10]; } tree[10] = ["%pick-up-dice%"]; tree[11] = ["#RHYD12#But yeah if you get captured, you go back to the bottom, lose your chest, and your opponent gets a free turn. It really sucks! ...Try not to get captured."]; tree[12] = ["%reset-bugs%"]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function stairGameReroll(tutorialRerollCount:Int):Array<Array<Object>> { var tree:Array<Array<Object>> = []; if (tutorialRerollCount == 0) { tree[0] = ["#RHYD06#Errr... Let's try that again! You were a little late that time."]; } else if (tutorialRerollCount == 1) { tree[0] = ["#RHYD06#Let's uhh... Maybe if we try one more time! It doesn't seem like you're getting it. Throw on the count of three, okay?"]; } else if (tutorialRerollCount == 2) { tree[0] = ["#RHYD10#Uhh... Almost had it! Just a little bit sooner. Don't worry about being too early."]; } else if (tutorialRerollCount > 2) { tree[0] = ["#RHYD10#Are you trying to cheat on purpose? 'Cause like, this is just the practice game! You should save your cheating for the real thing..."]; } tree[1] = [30, 20, 10]; tree[10] = [FlxG.random.getObject(["Oh! My\nbad", "Oops,\nsorry!", "Ah, my\nfault"])]; tree[20] = [FlxG.random.getObject(["This is\nconfusing...", "...Eh?\n...What?", "I don't\nget it..."])]; tree[30] = [FlxG.random.getObject(["Hmph,\nwhatever", "Ugh, let's\njust go", "..."])]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function stairGameSummary():Array<Array<Object>> { var manColor:String = Critter.CRITTER_COLORS[0].english; var comColor:String = Critter.CRITTER_COLORS[1].english; var tree:Array<Array<Object>> = []; tree[0] = ["#RHYD04#So <name>, you gotta got those " + manColor + " bugs up and down the stairs and collect two of those chests. That's how you win, alright?"]; tree[1] = ["#RHYD05#We each roll two dice, and add all four together to see how far you move. If it's 0 or 4, you move 4 steps and get a bonus turn."]; tree[2] = ["#RHYD03#Oh yeah, wr-roar! ...You can capture someone's bug if you land on it. And that center platform is a faster way to get a chest. You get it?"]; return tree; } public static function tugGamePartOneNoHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#smea02#Omigod omigod omigod, it's that tug-of-war game! ...This is like my FAVORITE of all the minigames! Let me explain it."]; tree[1] = ["%tug-tutorial-setup%"]; tree[2] = ["#smea05#It's actually pretty simple, you're trying to get as many chests over to your side as you can."]; return DialogTree.prepend(tree, tugGamePartOne()); } public static function tugGamePartOneRemoteHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%tug-tutorial-setup%"]; tree[2] = ["#smea05#What? Oh yeah, this game! This one's pretty simple, you're trying to get as many chests over to your side as you can."]; return DialogTree.prepend(tree, tugGamePartOne()); } public static function tugGamePartOneAbruptHandoff():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["%noop%"]; tree[1] = ["%tug-tutorial-setup%"]; tree[2] = ["#smea05#For this game <name>, you're trying to get as many chests over to your side as you can."]; return DialogTree.prepend(tree, tugGamePartOne()); } static private function tugGamePartOne():Array<Array<Object>> { var manColor:String = Critter.CRITTER_COLORS[1].english; var comColor:String = Critter.CRITTER_COLORS[0].english; var tree:Array<Array<Object>> = []; tree[0] = ["#smea04#So I'll be " + comColor + ", and you can be " + manColor + ", okay? ...We each have ten bugs on our team, and we can move them wherever we want."]; tree[1] = ["%tugmove%"]; tree[2] = ["#smea06#All the bugs are the same, so really it just comes down to numbers! So like, if I did this..."]; tree[3] = ["#smea03#There! Now I'm going to win the 125$ chest, because I have five bugs to your three."]; tree[4] = ["%tugleap%"]; tree[5] = ["#smea05#That's right, five bugs! ...Don't forget we each have one bug in those tents. You can't see them or move them, but they're still hard at work!"]; tree[6] = ["#smea04#Whoops, well now I actually have THREE bugs in that middle tent. ...I'm still winning five to three, though, so try not to forget!"]; tree[7] = ["#smea03#Here, why don't you rearrange your bugs and see if you can beat my score? ...Normally we'd both go at the same time but... Well this is just for practice!"]; tree[10000] = ["%skip-tutorial%"]; return tree; } public static function tugGamePartTwo():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = ["#smea05#Hmm, okay! So we'll move our little bugs around and after 30 seconds, the round ends and we'll see who won each chest."]; tree[1] = ["#smea03#Whoever gets the most money gets a little bonus too, so hmmm... Check your math! Harf!"]; tree[2] = ["#smea04#The full game lasts three rounds, but... Let's just see who won this practice, alright?"]; tree[10000] = ["%skip-tutorial%"]; return tree; } /* * result: [-999, -1] = player lost; 0 = player tied; [1, 999] = player won */ public static function tugGamePartThree(result:Int):Array<Array<Object>> { var tree:Array<Array<Object>> = []; if (result < 0) { tree[0] = ["#smea04#Aww, well you didn't win. But you know, at least you still get something for losing."]; } else if (result == 0) { tree[0] = ["#smea04#Huh? ...Well... that was super silly of you. Did you just... totally copy me?"]; tree[1] = ["#smea10#Wow, you don't even get any money for a tie!? Well... Don't do that in the real game!"]; } else { tree[0] = ["#smea02#Ack, good job! ...I didn't think you'd figure that out so quickly. I'll have to watch out for you! Bark~"]; } tree[10000] = ["%skip-tutorial%"]; return tree; } public static function tugGameSummary():Array<Array<Object>> { var manColor:String = Critter.CRITTER_COLORS[1].english; var comColor:String = Critter.CRITTER_COLORS[0].english; var tree:Array<Array<Object>> = []; tree[0] = ["#smea04#So <name>, you're moving those " + manColor + " bugs around to try and outnumber the " + comColor + " bugs in each row."]; tree[1] = ["#smea06#Whoever has more bugs in each row wins that chest! And whoever gets more money from chests wins the round."]; tree[2] = ["#smea05#The game lasts three rounds, and whoever has the most money at the end wins! Simple stuff, right?"]; return tree; } }
argonvile/monster
source/TutorialDialog.hx
hx
unknown
114,132
package; import flixel.math.FlxMath; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import kludge.FlxSoundKludge; /** * Controls the sound effects for the vibrator. The vibrator has several sound * effect modes which can be played and looped at different speeds. */ class VibeSfx implements IFlxDestroyable { private var MAX_VOLUME:Float = 0.20; private var sounds:Array<FlxSoundKludge>; public var speed:Int = 0; // [0-5] public var mode:VibeMode = Off; public function new() { sounds = [ new FlxSoundKludge(AssetPaths.vibe0__wav, 0.300), new FlxSoundKludge(AssetPaths.vibe1__wav, 0.227), new FlxSoundKludge(AssetPaths.vibe2__wav, 0.173), new FlxSoundKludge(AssetPaths.vibe3__wav, 0.132), new FlxSoundKludge(AssetPaths.vibe4__wav, 0.100) ]; } /** * @return 1.0 = vibrator is on; 0.3 = vibrator is at one third power, 0.0 = vibrator is off */ public function getVolumePct():Float { if (speed == 0) { return 0; } var totVolume:Float = 0; for (sound in sounds) { totVolume += sound.volume; } return FlxMath.bound(totVolume / MAX_VOLUME, 0, 1); } public function setSpeed(speed:Int) { if (this.speed == speed) { return; } this.speed = speed; updateSound(); } public function setMode(mode:VibeMode) { if (this.mode == mode) { return; } this.mode = mode; updateSound(); } public static var SINE_PERIODS:Array<Float> = [2.19, 1.76, 1.41, 1.13, 0.90]; public static var WARBLE_PERIODS:Array<Float> = [1.28, 1.09, 0.93, 0.79, 0.67]; public static var PULSE_PARAMS:Array<Array<Float>> = [ [0.33, 1.3], [0.23, 0.8], [0.17, 0.5], [0.12, 0.3], [0.10, 0.2], // on; off ]; public function updateSound():Void { for (i in 0...sounds.length) { if (i != speed - 1) { sounds[i].fadeOut(); } } if (speed > 0) { if (mode == Off) { sounds[speed - 1].fadeOut(); } else { if (sounds[speed - 1]._sound == null) { sounds[speed - 1].fadeIn(MAX_VOLUME); } if (mode == Sine) { sounds[speed - 1].sine(SINE_PERIODS[speed - 1]); } else if (mode == Pulse) { sounds[speed - 1].pulse(PULSE_PARAMS[speed - 1][0], PULSE_PARAMS[speed - 1][1]); } else { sounds[speed - 1].sustained(WARBLE_PERIODS[speed - 1]); } } } } /** * @return true if the vibrator is on; it might not be vibrating right now, but it's doing something. */ public function isVibratorOn():Bool { return mode != VibeSfx.VibeMode.Off && speed > 0; } /** * @return true if the vibrator is vibrating a significant amount (at least 60% of max) at this exact moment */ public function isVibrating():Bool { return isVibratorOn() && getVolumePct() >= 0.6; } public function destroy():Void { sounds = FlxDestroyUtil.destroyArray(sounds); } } enum VibeMode { Off; Sustained; Sine; Pulse; }
argonvile/monster
source/VibeSfx.hx
hx
unknown
3,086
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.effects.particles.FlxParticle; import flixel.group.FlxGroup; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import openfl.display.BitmapData; import openfl.geom.ColorTransform; /** * An FlxGroup extension which renders all of its children, but masks them to * be white. Useful for glowy/blinky effects */ class WhiteGroup extends FlxGroup { // Buffer which this group is rendered to, prior to rendering it to the camera private var _groupBuffer:FlxSprite; public var _whiteness:Float = 1.0; public function new() { super(); _groupBuffer = new FlxSprite(0, 0, new BitmapData(FlxG.camera.width, FlxG.camera.height, true, 0x00)); } override public function draw():Void { FlxSpriteUtil.fill(_groupBuffer, FlxColor.TRANSPARENT); #if flash PixelFilterUtils.swapCameraBuffer(_groupBuffer); super.draw(); PixelFilterUtils.swapCameraBuffer(_groupBuffer); #else PixelFilterUtils.drawToBuffer(_groupBuffer, this); #end _groupBuffer.graphic.bitmap.colorTransform(_groupBuffer.graphic.bitmap.rect, new ColorTransform(1 - _whiteness, 1 - _whiteness, 1 - _whiteness, 1, 255 * _whiteness, 255 * _whiteness, 255 * _whiteness)); _groupBuffer.dirty = true; // draw groupBuffer to camera _groupBuffer.draw(); } public function addTeleparticles(minX:Float, minY:Float, maxX:Float, maxY:Float, particleCount:Int):Void { var itemY = minY; var increment = Math.max(1, (maxY - minY) / particleCount); while (itemY < maxY) { var newItem:FlxParticle = new FlxParticle(); newItem.alphaRange.set(1, 0.5); newItem.lifespan = FlxG.random.float(0.25, 0.75); var size:Int = FlxG.random.int(4, 8); newItem.makeGraphic(size, size); newItem.x = FlxG.random.float(minX, maxX); newItem.y = itemY; newItem.velocity.x = FlxG.random.sign() * (2400 / size); newItem.exists = true; add(newItem); itemY += increment; } } override public function destroy():Void { super.destroy(); _groupBuffer = FlxDestroyUtil.destroy(_groupBuffer); } }
argonvile/monster
source/WhiteGroup.hx
hx
unknown
2,217
package credits; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.effects.particles.FlxEmitter; import flixel.effects.particles.FlxParticle; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import kludge.FlxSoundKludge; import kludge.LateFadingFlxParticle; import poke.abra.AbraDialog; /** * The FlxState which shows the credits and the ending sequence, with abra * waking up and all of the different Pokemon scenes */ class CreditsState extends FlxTransitionableState { private static var IMAGE_CRAWL_X_VELOCITY:Float = -34; private static var IMAGE_CRAWL_SPACING:Float = 138; private var musicEventStack:MusicEventStack = new MusicEventStack(); private var eventStack:EventStack = new EventStack(); private var credits:Array<Array<String>> = []; private var topTextY:Float = 0; private var botTextY:Float = 0; private var textY:Float = 0; private var firstVisibleTextIndex:Int = 0; private var texts:FlxTypedGroup<FlxText>; private var mainCreditsImage:FlxSprite; private var zappedAbraImage:FlxSprite; private var sadGrimerImage:FlxSprite; private var happyGrimerImage:FlxSprite; private var smeargleImage:FlxSprite; private var bgImageOld:FlxSprite; private var bgImage:FlxSprite; private var creditsImageFinal:FlxSprite; private var thanksImageFinal:FlxSprite; private var otherCreditsMinIndex:Int = 0; private var otherCreditsMaxIndex:Int = 0; private var otherCreditsImages:FlxTypedGroup<FlxSprite>; private var bgImageAssets:Array<FlxGraphicAsset> = [ AssetPaths.credits_rhyd_bg__png, AssetPaths.credits_buiz_bg__png, AssetPaths.credits_grim_bg__png, AssetPaths.credits_sand_bg__png, AssetPaths.credits_hera_bg__png, AssetPaths.credits_grov_bg__png, AssetPaths.credits_magn_bg__png, AssetPaths.credits_smea_bg__png, AssetPaths.credits_kecl_bg__png, AssetPaths.credits_luca_bg__png, ]; private var otherCreditsImageAssets:Array<FlxGraphicAsset> = [ AssetPaths.credits09__png, // rhydon AssetPaths.credits_rhyd0__png, AssetPaths.credits_rhyd1__png, AssetPaths.credits_rhyd2__png, // buizel AssetPaths.credits_buiz0__png, AssetPaths.credits_buiz1__png, // grimer AssetPaths.credits_grim0__png, AssetPaths.credits_grim1__png, // sandslash AssetPaths.credits_sand0__png, AssetPaths.credits_sand1__png, // heracross AssetPaths.credits_hera0__png, AssetPaths.credits_hera1__png, // grovyle AssetPaths.credits_grov0__png, AssetPaths.credits_grov1__png, // magnezone AssetPaths.credits_magn0__png, AssetPaths.credits_magn1__png, // smeargle AssetPaths.credits_smea0__png, AssetPaths.credits_smea1__png, // kecleon AssetPaths.credits_kecl0__png, AssetPaths.credits_kecl1__png, // lucario AssetPaths.credits_luca0__png, AssetPaths.credits_luca1__png ]; private var wisp:FlxEmitter; private var wispLine:WispLine; private var wispLayer:FlxSprite; private var smallSparkEmitter:FlxTypedEmitter<LateFadingFlxParticle>; private var maskCreditsBot:FlxSprite; private var maskCreditsTop:FlxSprite; private var scheduledFadeOut:Bool = false; public var backToMainMenu:Bool = false; public function new(?TransIn:TransitionData, ?TransOut:TransitionData) { super(TransIn, TransOut); } override public function create():Void { Main.overrideFlxGDefaults(); super.create(); FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; // If music is playing it would mess up our eventing. ...Stop any music, just in case FlxG.sound.music = FlxDestroyUtil.destroy(FlxG.sound.music); topTextY = FlxG.height - 175; botTextY = FlxG.height - 175; textY = topTextY; credits.push(["monster mind"]); credits.push([]); credits.push(["a game by"]); credits.push(["argon vile"]); credits.push([]); credits.push([]); credits.push([]); credits.push([]); credits.push(["#okay so in a way i kind of did everything by myself i guess. " + "but really all i did was steal a bunch of stuff from a lot of people who are way more talented than i am. " + "i'm sorry. i'm really, really sorry to everyone i stole from. " + "i promise i'm not going to sell this game or try to make any money from it. " + "i hope you're not mad but you probably should be mad and i'm an asshole and i'm really sorry."]); credits.push([]); credits.push([]); credits.push([]); credits.push(["sorry:"]); credits.push([]); credits.push(["character design", "shamelessly stolen from nintendo and the pokemon company"]); credits.push(["", "#(sorry. i think your pokemon games are fun)"]); credits.push([]); credits.push(["puzzle design", "shamelessly stolen from hasbro and some guy named mordecai meirowitz"]); credits.push(["", "#(sorry. your mastermind game is fun too)"]); credits.push([]); credits.push(["fonts", "shamelessly stolen from some guy named jovanny lemonad"]); credits.push(["", "#(sorry)"]); credits.push(["", " "]); credits.push(["", "and also some girl named \"misti's fonts\""]); credits.push(["", "#(also sorry)"]); credits.push([]); credits.push(["sound", "shamelessly stolen from pokemon emerald"]); credits.push(["", "#(sorry nintendo)"]); credits.push([]); credits.push(["music", "shamelessly stolen from hyper potions"]); credits.push(["", "#(sorry)"]); credits.push(["", " "]); credits.push(["", "and also stolen from gameboyluke because he paid hyper potions to make this song for him"]); credits.push(["", "#(he what? oh okay wait a minute, wow)"]); credits.push(["", " "]); credits.push(["", "#(...i am seriously the biggest asshole. i'm so sorry, it's just a really pretty song)"]); credits.push([]); credits.push([]); credits.push([]); credits.push(["testers:"]); credits.push([]); credits.push(["!blake", "!dreamous"]); credits.push(["!mattspew", "!nogard"]); credits.push(["!nullbunny", "!spike"]); credits.push(["!sprout", "!tygre"]); credits.push(["...and everyone else"]); credits.push([]); credits.push([]); credits.push([]); credits.push([]); credits.push([]); credits.push(["#sometimes the universe can feel like a lonely place. " + "but technology's a wonderful thing. " + "regardless of where we live, what language we speak, or whether we're real or imaginary... " + "we're all connected to thousands of potential friends through the magic of the internet. " + "so don't be afraid to reach out. " + "because you never know who will reach back."]); texts = new FlxTypedGroup<FlxText>(); add(texts); for (i in 0...credits.length) { if (credits[i].length == 0) { textY += 20; } else if (credits[i].length == 1) { var text:FlxText = makeText(400, credits[i][0]); text.alignment = "center"; texts.add(text); textY += text.textField.textHeight; } else if (credits[i].length == 2) { var leftText:FlxText; var rightText:FlxText; if (StringTools.startsWith(credits[i][0], "!")) { leftText = makeText(190, credits[i][0].substr(1, credits[i][0].length - 1)); leftText.alignment = "center"; rightText = makeText(190, credits[i][1].substr(1, credits[i][1].length - 1)); rightText.x += 200; rightText.alignment = "center"; } else { leftText = makeText(120, credits[i][0]); leftText.alignment = "left"; rightText = makeText(270, credits[i][1]); rightText.x += 130; rightText.alignment = "right"; } texts.add(leftText); texts.add(rightText); textY += Math.max(leftText.textField.textHeight, rightText.textField.textHeight); } } var finalTrialCount:Int = AbraDialog.getFinalTrialCount(); var sick:Bool = finalTrialCount >= 3 || finalTrialCount == 0; var verySick:Bool = finalTrialCount >= 4 || finalTrialCount == 0; maskCreditsTop = new FlxSprite(0, -4); maskCreditsTop.loadGraphic(AssetPaths.credits_blocker__png); add(maskCreditsTop); maskCreditsBot = new FlxSprite(); maskCreditsBot.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); add(maskCreditsBot); bgImageOld = new FlxSprite(); bgImageOld.visible = false; add(bgImageOld); bgImage = new FlxSprite(); bgImage.visible = false; add(bgImage); mainCreditsImage = new FlxSprite(0, 19); mainCreditsImage.loadGraphic(AssetPaths.credits00__png); mainCreditsImage.x = FlxG.width / 2 - mainCreditsImage.width / 2; mainCreditsImage.alpha = 0; add(mainCreditsImage); zappedAbraImage = new FlxSprite(0, 19); zappedAbraImage.loadGraphic(AssetPaths.credits02__png); zappedAbraImage.x = FlxG.width / 2 - mainCreditsImage.width / 2; zappedAbraImage.alpha = 0; add(zappedAbraImage); creditsImageFinal = new FlxSprite(0, 0); creditsImageFinal.loadGraphic(AssetPaths.credits_final__png); creditsImageFinal.alpha = 0; add(creditsImageFinal); thanksImageFinal = new FlxSprite(0, 0); thanksImageFinal.loadGraphic(AssetPaths.credits_thanks__png); thanksImageFinal.alpha = 0; add(thanksImageFinal); otherCreditsImages = new FlxTypedGroup<FlxSprite>(); add(otherCreditsImages); happyGrimerImage = new FlxSprite(); happyGrimerImage.loadGraphic(AssetPaths.credits_grim1b__png); happyGrimerImage.alpha = 0; add(happyGrimerImage); if (verySick) { otherCreditsImageAssets[0] = AssetPaths.credits09_abraless__png; } else if (sick) { otherCreditsImageAssets[0] = AssetPaths.credits08c_abraless__png; } else { otherCreditsImageAssets[0] = AssetPaths.credits08c_abraless__png; } if (PlayerData.sfw) { otherCreditsImageAssets = []; } for (otherCreditsImageAsset in otherCreditsImageAssets) { var imageIndex:Int = otherCreditsImages.length; var otherCreditsImage:FlxSprite = new FlxSprite(0, 10); otherCreditsImage.loadGraphic(otherCreditsImageAsset); otherCreditsImage.x = FlxG.width / 2 - otherCreditsImage.width / 2 - 130; otherCreditsImage.x += IMAGE_CRAWL_SPACING * imageIndex; if (imageIndex % 2 == 1) { otherCreditsImage.y += otherCreditsImage.height + 10; } otherCreditsImage.x += FlxG.random.int( -3, 3); otherCreditsImage.y += FlxG.random.int( -4, 4); otherCreditsImage.visible = false; otherCreditsImages.add(otherCreditsImage); if (otherCreditsImageAsset == AssetPaths.credits_smea1__png) { smeargleImage = otherCreditsImage; } if (otherCreditsImageAsset == AssetPaths.credits_grim1__png) { sadGrimerImage = otherCreditsImage; } } wispLine = new WispLine(); wispLine.age = 10000; wispLayer = new FlxSprite(); wispLayer.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); add(wispLayer); wisp = new FlxEmitter(0, 0, 30); add(wisp); wisp.launchMode = FlxEmitterMode.CIRCLE; wisp.acceleration.set(0); wisp.alpha.set(1.0, 1.0, 0, 0); wisp.lifespan.set(1.2); wisp.scale.set(5); wisp.speed.set(40, 80, 0, 0); for (i in 0...wisp.maxSize) { var particle:FlxParticle = new FadeBlueParticle(); particle.exists = false; wisp.add(particle); } smallSparkEmitter = new FlxTypedEmitter<LateFadingFlxParticle>(0, 0, 12); add(smallSparkEmitter); smallSparkEmitter.launchMode = FlxEmitterMode.SQUARE; smallSparkEmitter.angularVelocity.set(0); smallSparkEmitter.velocity.set(200, 200); smallSparkEmitter.lifespan.set(0.3); for (i in 0...smallSparkEmitter.maxSize) { var particle:LateFadingFlxParticle = new LateFadingFlxParticle(); particle.makeGraphic(3, 3, FlxColor.WHITE); particle.offset.x = 1.5; particle.offset.y = 1.5; particle.exists = false; smallSparkEmitter.add(particle); } if (!PlayerData.sfw) { eventStack.addEvent({time:1.4, callback:eventFadeInImage, args:[AssetPaths.credits00__png]}); musicEventStack.addEvent({time:12.8 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits01__png]}); if (PlayerData.abraStoryInt == 5) { musicEventStack.addEvent({time:16.2, callback:eventZapAbra}); } musicEventStack.addEvent({time:19.2 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits03__png]}); musicEventStack.addEvent({time:25.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits04__png]}); if (verySick) { musicEventStack.addEvent({time:35.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits05__png]}); musicEventStack.addEvent({time:46.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits06__png]}); musicEventStack.addEvent({time:51.2 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits07__png]}); musicEventStack.addEvent({time:61.2 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits08__png]}); musicEventStack.addEvent({time:79.1 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits09__png]}); } else if (sick) { musicEventStack.addEvent({time:35.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits05__png]}); musicEventStack.addEvent({time:46.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits06__png]}); musicEventStack.addEvent({time:51.2 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits07b__png]}); musicEventStack.addEvent({time:61.2 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits07c__png]}); musicEventStack.addEvent({time:79.1 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits08c__png]}); } else { musicEventStack.addEvent({time:35.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits05__png]}); musicEventStack.addEvent({time:45.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits06c__png]}); musicEventStack.addEvent({time:55.6 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits07c__png]}); musicEventStack.addEvent({time:79.1 - 0.6, callback:eventCycleImage, args:[AssetPaths.credits08c__png]}); } musicEventStack.addEvent({time:83.5, callback:eventFadeOutImage, args:[1.2]}); } eventStack.addEvent({time:2.8, callback:eventFadeInCredits}); eventStack.addEvent({time:5.0, callback:eventStartMusic}); musicEventStack.addEvent({time:0, callback:eventMoveCredits}); musicEventStack.addEvent({time:87.8, callback:eventFadeOutCredits, args:[1.2]}); musicEventStack.addEvent({time:89.6 - 0.2, callback:eventFadeInImageCrawl, args:[0.4]}); if (!PlayerData.sfw) { musicEventStack.addEvent({time:113.65, callback:eventSetImageVelocity, args:[IMAGE_CRAWL_X_VELOCITY * 0.25]}); musicEventStack.addEvent({time:113.65, callback:eventFadeNonGrimerImage, args:[0.3]}); musicEventStack.addEvent({time:113.65, callback:eventBgAlpha, args:[0, 0.3]}); musicEventStack.addEvent({time:115.22 - 0.2, callback:grimerGrillVisitors, args:[0.4]}); musicEventStack.addEvent({time:115.22 - 0.2, callback:eventUnfadeNonGrimerImage, args:[0.4]}); musicEventStack.addEvent({time:115.22 - 0.2, callback:eventBgAlpha, args:[1.0, 0.4]}); musicEventStack.addEvent({time:115.22, callback:eventSetImageVelocity, args:[IMAGE_CRAWL_X_VELOCITY]}); } musicEventStack.addEvent({time:90.91, callback:eventChangeBg, args:[bgImageAssets[0]]}); musicEventStack.addEvent({time:99.03, callback:eventChangeBg, args:[bgImageAssets[1]]}); musicEventStack.addEvent({time:107.25, callback:eventChangeBg, args:[bgImageAssets[2]]}); musicEventStack.addEvent({time:116.59, callback:eventChangeBg, args:[bgImageAssets[3]]}); musicEventStack.addEvent({time:124.74, callback:eventChangeBg, args:[bgImageAssets[4]]}); musicEventStack.addEvent({time:132.85, callback:eventChangeBg, args:[bgImageAssets[5]]}); musicEventStack.addEvent({time:140.90, callback:eventChangeBg, args:[bgImageAssets[6]]}); musicEventStack.addEvent({time:149.05, callback:eventChangeBg, args:[bgImageAssets[7]]}); if (!PlayerData.sfw) { musicEventStack.addEvent({time:153.22, callback:smeargleButtSqueeze}); } musicEventStack.addEvent({time:157.04, callback:eventChangeBg, args:[bgImageAssets[8]]}); musicEventStack.addEvent({time:165.29, callback:eventChangeBg, args:[bgImageAssets[9]]}); musicEventStack.addEvent({time:173.45, callback:eventBgAlpha, args:[0, 0.7]}); if (!PlayerData.sfw) { musicEventStack.addEvent({time:180.6 - 0.4, callback:eventCycleImage, args:[AssetPaths.credits96__png]}); musicEventStack.addEvent({time:188.6 - 0.4, callback:eventCycleImage, args:[AssetPaths.credits97__png]}); musicEventStack.addEvent({time:196.6 - 0.4, callback:eventCycleImage, args:[AssetPaths.credits98__png]}); musicEventStack.addEvent({time:204.4 - 0.6, callback:eventFadeOutImage, args:[0.4]}); musicEventStack.addEvent({time:204.4 - 0.2, callback:eventFadeInFinalImage}); } } /** * We fade out all the images to bring the player's attention to the Grimer * image, when the music gets a little sad and pauses */ function eventFadeNonGrimerImage(args:Array<Dynamic>) { var fadeDuration:Float = args[0]; var index:Int = otherCreditsImages.members.indexOf(sadGrimerImage); FlxTween.tween(otherCreditsImages.members[index - 2], {alpha: 0.2}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index - 1], {alpha: 0.2}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index + 1], {alpha: 0.2}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index + 2], {alpha: 0.2}, fadeDuration); } function eventUnfadeNonGrimerImage(args:Array<Dynamic>) { var fadeDuration:Float = args[0]; var index:Int = otherCreditsImages.members.indexOf(sadGrimerImage); FlxTween.tween(otherCreditsImages.members[index - 2], {alpha: 1.0}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index - 1], {alpha: 1.0}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index + 1], {alpha: 1.0}, fadeDuration); FlxTween.tween(otherCreditsImages.members[index + 2], {alpha: 1.0}, fadeDuration); } function eventSetImageVelocity(args:Array<Dynamic>) { var velocity:Float = args[0]; for (image in otherCreditsImages) { if (image != null) { image.velocity.x = velocity; } } happyGrimerImage.velocity.x = velocity; } function grimerGrillVisitors(args:Array<Dynamic>) { var fadeDuration:Float = args[0]; happyGrimerImage.setPosition(sadGrimerImage.x, sadGrimerImage.y); happyGrimerImage.velocity.set(sadGrimerImage.velocity.x, sadGrimerImage.velocity.y); FlxTween.tween(happyGrimerImage, {alpha:1.0}, fadeDuration); } function smeargleButtSqueeze(args:Array<Dynamic>) { smeargleImage.loadGraphic(AssetPaths.credits_smea1b__png); emitSmallSpark(smeargleImage.x + 133, smeargleImage.y + 133); } function emitSmallSpark(x:Float, y:Float):Void { smallSparkEmitter.setPosition(x, y); smallSparkEmitter.start(true, 0, 1); for (i in 0...8) { var particle:LateFadingFlxParticle = smallSparkEmitter.emitParticle(); particle.enableLateFade(2); if (i % 8 < 4) { particle.velocity.x *= 0.5; particle.velocity.y *= 0.5; } if (i % 4 < 2) { particle.velocity.x *= -1; } if (i % 2 < 1) { particle.velocity.y *= -1; } } smallSparkEmitter.emitting = false; } private function eventFadeInImageCrawl(args:Array<Dynamic>) { var fadeDuration:Float = args[0]; if (!PlayerData.sfw) { remove(mainCreditsImage); var imageIndex:Int = otherCreditsImages.length; mainCreditsImage.y = 10; mainCreditsImage.x = FlxG.width / 2 - mainCreditsImage.width / 2 - 130; mainCreditsImage.x += IMAGE_CRAWL_SPACING * imageIndex; if (imageIndex % 2 == 1) { mainCreditsImage.y += mainCreditsImage.height + 10; } mainCreditsImage.x += FlxG.random.int( -3, 3); mainCreditsImage.y += FlxG.random.int( -4, 4); mainCreditsImage.visible = false; mainCreditsImage.loadGraphic(AssetPaths.credits95__png); otherCreditsImages.add(mainCreditsImage); } for (image in otherCreditsImages) { if (image != null) { image.alpha = 0; image.visible = true; image.velocity.x = IMAGE_CRAWL_X_VELOCITY; } } fadeInOtherCreditsImages(fadeDuration); } private function eventFadeOutImage(args:Array<Dynamic>) { var fadeDuration:Float = args[0]; FlxTween.tween(mainCreditsImage, {alpha:0.0}, fadeDuration); } private function eventCycleImage(args:Array<Dynamic>) { var graphicAsset:FlxGraphicAsset = args[0]; eventFadeOutImage([0.4]); eventStack.addEvent({time:eventStack._time + 0.4, callback:eventFadeInImage, args:[graphicAsset]}); } private function eventZapAbra(args:Array<Dynamic>) { zappedAbraImage.alpha = 1.0; FlxTween.tween(zappedAbraImage, {alpha:0.0}, 2.4); wisp.start(false); for (i in 0...24) { wisp.x = FlxG.random.float(zappedAbraImage.x + zappedAbraImage.width * 0.25, zappedAbraImage.x + zappedAbraImage.width * 0.75); wisp.y = FlxG.random.float(zappedAbraImage.y + zappedAbraImage.height * 0.5, zappedAbraImage.y + zappedAbraImage.height * 0.9); wisp.emitParticle(); } wisp.emitting = false; wispLine.set(0, -100, 10, zappedAbraImage.x + zappedAbraImage.width * 0.35, zappedAbraImage.y + zappedAbraImage.height * 0.75, 4); wispLine.age = 0; } private function eventFadeInImage(args:Array<Dynamic>) { var graphicAsset:FlxGraphicAsset = args[0]; mainCreditsImage.loadGraphic(graphicAsset); mainCreditsImage.alpha = 0; FlxTween.tween(mainCreditsImage, {alpha:1.0}, 0.4); } private function eventFadeInFinalImage(args:Array<Dynamic>) { creditsImageFinal.alpha = 0; FlxTween.tween(creditsImageFinal, {alpha:1.0}, 0.4); eventStack.addEvent({time:eventStack._time + 2.0, callback:eventFadeInThanksImage, args:[0.2]}); } private function eventFadeInThanksImage(args:Array<Dynamic>) { var graphicAsset:FlxGraphicAsset = AssetPaths.credits_thanks__png; thanksImageFinal.alpha = 0; FlxTween.tween(thanksImageFinal, {alpha:1.0}, 0.2); } private function eventFadeInCredits(args:Array<Dynamic>) { FlxTween.tween(maskCreditsBot, {alpha:0.0}, 0.4); } private function eventFadeOutCredits(args:Array<Dynamic>) { var fadeTime:Float = args[0]; FlxTween.tween(maskCreditsBot, {alpha:1.0}, fadeTime); } private function eventMoveCredits(args:Array<Dynamic>) { setTextVelocity(-23.5); } private function eventStartMusic(args:Array<Dynamic>) { FlxG.sound.playMusic(FlxSoundKludge.fixPath(AssetPaths.hyper_potions_littleroot_town__mp3), 0.28, false); } private function setTextVelocity(velocity:Float) { for (textObject in texts.members) { if (textObject != null) { textObject.velocity.y = velocity; } } } private function makeText(fieldWidth:Float, text:String):FlxText { var textObject:FlxText = new FlxText(FlxG.width * 0.5 - 200, textY, fieldWidth); textObject.moves = true; textObject.setFormat(AssetPaths.hardpixel__otf, 20); if (text != null && StringTools.startsWith(text, "#")) { textObject.text = text.substring(1); textObject.color = ItemsMenuState.MEDIUM_BLUE; } else { textObject.text = text; } return textObject; } private function fadeOutOtherCreditsImages(fadeDuration:Float) { while (otherCreditsMinIndex < otherCreditsImages.length && otherCreditsImages.members[otherCreditsMinIndex].x < -50) { FlxTween.tween(otherCreditsImages.members[otherCreditsMinIndex], {alpha:0.0}, fadeDuration); otherCreditsMinIndex++; } } private function fadeInOtherCreditsImages(fadeDuration:Float) { while (otherCreditsMaxIndex < otherCreditsImages.length && otherCreditsImages.members[otherCreditsMaxIndex].visible && otherCreditsImages.members[otherCreditsMaxIndex].x < FlxG.width - 80) { otherCreditsImages.members[otherCreditsMaxIndex].alpha = 0; FlxTween.tween(otherCreditsImages.members[otherCreditsMaxIndex], {alpha:1.0}, fadeDuration); otherCreditsMaxIndex++; } } public function eventChangeBg(args:Array<Dynamic>) { var graphic:FlxGraphicAsset = args[0]; if (bgImage.visible) { bgImageOld.loadGraphicFromSprite(bgImage); bgImageOld.visible = true; } bgImage.loadGraphic(graphic); bgImage.visible = true; bgImage.alpha = 0; FlxTween.tween(bgImage, {alpha:1.0}, 0.7); } public function eventBgAlpha(args:Array<Dynamic>) { var alpha:Float = args[0]; var duration:Float = args[1]; FlxTween.tween(bgImage, {alpha:alpha}, duration); bgImageOld.visible = false; } override public function update(elapsed:Float):Void { super.update(elapsed); eventStack.update(elapsed); musicEventStack.update(elapsed); fadeOutOtherCreditsImages(3.6); fadeInOtherCreditsImages(3.6); if (mainCreditsImage.x < FlxG.width / 2 - mainCreditsImage.width / 2 && mainCreditsImage.velocity.x < 0) { // stop other credits scroll for (otherCreditsImage in otherCreditsImages.members) { otherCreditsImage.velocity.x = 0; if (otherCreditsImage != mainCreditsImage && otherCreditsImage.alpha > 0.5) { FlxTween.tween(otherCreditsImage, {alpha:0.0}, 3.6); } } mainCreditsImage.x = FlxG.width / 2 - mainCreditsImage.width / 2; } if (!scheduledFadeOut) { if (texts.members[texts.members.length - 1].y + texts.members[texts.members.length - 1].height <= FlxG.height) { setTextVelocity(0); scheduledFadeOut = true; } } if (wispLine.age < 5) { wispLayer.visible = true; FlxSpriteUtil.fill(wispLayer, FlxColor.TRANSPARENT); wispLine.update(elapsed); wispLine.draw(wispLayer); } else { wispLayer.visible = false; } if (FlxG.keys.justPressed.ESCAPE && backToMainMenu) { transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } if (FlxG.mouse.justPressed) { if (!eventStack._alive && !musicEventStack._alive) { if (PlayerData.abraStoryInt == 6) { // didn't swap transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } else if (backToMainMenu) { // replaying credits transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } else { transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new GloveWakeUpState(MainMenuState.fadeInFast())); } } } } override public function destroy():Void { super.destroy(); /* * Destroy any music objects, so music doesn't continue playing after * we switch states. ...We could just stop the music object, but * having a non-playing music object can cause some unexpected behavior * too, as our eventing is based on the number of seconds that have * played in a song. */ FlxG.sound.music = FlxDestroyUtil.destroy(FlxG.sound.music); musicEventStack = null; eventStack = null; credits = null; texts = FlxDestroyUtil.destroy(texts); mainCreditsImage = FlxDestroyUtil.destroy(mainCreditsImage); zappedAbraImage = FlxDestroyUtil.destroy(zappedAbraImage); sadGrimerImage = FlxDestroyUtil.destroy(sadGrimerImage); happyGrimerImage = FlxDestroyUtil.destroy(happyGrimerImage); smeargleImage = FlxDestroyUtil.destroy(smeargleImage); bgImage = FlxDestroyUtil.destroy(bgImage); creditsImageFinal = FlxDestroyUtil.destroy(creditsImageFinal); thanksImageFinal = FlxDestroyUtil.destroy(thanksImageFinal); otherCreditsImages = FlxDestroyUtil.destroy(otherCreditsImages); bgImageAssets = null; otherCreditsImageAssets = null; wisp = FlxDestroyUtil.destroy(wisp); wispLine = FlxDestroyUtil.destroy(wispLine); wispLayer = FlxDestroyUtil.destroy(wispLayer); smallSparkEmitter = FlxDestroyUtil.destroy(smallSparkEmitter); maskCreditsBot = FlxDestroyUtil.destroy(maskCreditsBot); maskCreditsTop = FlxDestroyUtil.destroy(maskCreditsTop); } }
argonvile/monster
source/credits/CreditsState.hx
hx
unknown
28,685
package credits; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.effects.particles.FlxEmitter; import flixel.effects.particles.FlxParticle; import flixel.math.FlxMath; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.system.FlxSound; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import kludge.FlxSoundKludge; import openfl.geom.Point; import openfl.geom.Rectangle; /** * If the player swaps with abra, there's an animation of the camera zooming * out from their desk to their house to their neighborhood to earth and to * space and then zooming off into space. * * This class is responsible for that animation. */ class EndingAnim extends FlxState { static var DESK_TIMING:Array<Float> = [ 0.80, // starts zooming out 5.00, // fully zoomed out 4.00, // starts rising ]; static var ZWOOSH_TIMING:Array<Float> = [ 3.35, // appears... 3.45, // off to the right of the screen... 4.00, // starts changing from < shape to = shape 4.08, // finished changing to = shape 4.35, // starts changing from = shape to > shape 4.43, // finished changing to > shape 5.45, // abra's appears... 5.55, // off to the left edge of the screen... 8.90, // to credits ]; var wispSfxTimer:Float = 0; var stateFunction:Float->Void; var stateTime:Float = 0; // sprites used while rising from desk var screenshot:FlxSprite; var desk:FlxSprite; var hand:FlxSprite; var ceiling:FlxSprite; // sprites used while zooming out in earth var cloud0:FlxSprite; var cloud1:FlxSprite; var cloud2:FlxSprite; var terrain0:FlxSprite; var terrain1:FlxSprite; var terrain2:FlxSprite; var terrain3:FlxSprite; var terrain4:FlxSprite; var stars0:FlxSprite; var wisp:FlxEmitter; var wispLine:WispLine; var abraWispLine:WispLine; var wispLayer:FlxSprite; var wispSfxVolume:Float = 0; var wispSfx:FlxSound; // sprites used during flyby var stars1:FlxSprite; public function new(screenshot:FlxSprite = null) { super(); this.screenshot = screenshot; } private function addZoomySprite(graphic:FlxGraphicAsset):FlxSprite { var s:FlxSprite = new FlxSprite(0, 0); s.x = 384 / 2; s.y = 216 / 2; s.width = 0; s.height = 0; s.loadGraphic(graphic, true, 384, 216); return s; } override public function create():Void { Main.overrideFlxGDefaults(); super.create(); if (screenshot == null) { screenshot = new FlxSprite(); screenshot.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT); } else { var maskSprite:FlxSprite = new FlxSprite(0, 0); maskSprite.loadGraphic(AssetPaths.screenshot_mask__png); screenshot.stamp(maskSprite); } FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; wisp = new FlxEmitter(0, 0, 30); wisp.launchMode = FlxEmitterMode.CIRCLE; wisp.acceleration.set(0); wisp.alpha.set(1.0, 1.0, 0, 0); wisp.lifespan.set(1.2); for (i in 0...wisp.maxSize) { var particle:FlxParticle = new FadeBlueParticle(); particle.exists = false; wisp.add(particle); } wispLine = new WispLine(); abraWispLine = new WispLine(); wispLayer = new FlxSprite(); wispLayer.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); initDeskZoomOut(); setStateFunction(deskZoomOut); } private function setStateFunction(stateFunction:Float->Void) { this.stateFunction = stateFunction; this.stateTime = 0; /* * invoke it once to assign things like scale, opacity... otherwise we * might have one strange frame where everything's the wrong scale */ stateFunction(0); } private function initDeskZoomOut():Void { clear(); desk = new FlxSprite(0, 0); desk.loadGraphic(AssetPaths.desk__png); desk.x = 0; desk.y = -desk.height + FlxG.height; desk.origin.x = 306; desk.origin.y = 1102; desk.scale.x = 2.33; desk.scale.y = 2.13; add(desk); screenshot.x = 0; screenshot.y = 0; screenshot.origin.x = 306; screenshot.origin.y = 34; screenshot.scale.x = 1.00; screenshot.scale.y = 1.00; add(screenshot); hand = new FlxSprite(0, 0); hand.loadGraphic(AssetPaths.desk_hand__png, true, 120, 120); hand.x = 574; hand.y = 312; hand.origin.x = desk.origin.x - 574; hand.origin.y = desk.origin.y - 1068 - 312; hand.scale.x = 2.33; hand.scale.y = 2.13; hand.animation.frameIndex = 0; add(hand); wisp.alpha.set(0.0, 0.0, 0.0, 0.0); wisp.start(false, 0.05); add(wisp); // wisp size... wisp.scale.set(60); wisp.speed.set(60, 120, 0, 0); ceiling = new FlxSprite(0, 0); ceiling.makeGraphic(1, 1, 0xff96896f); ceiling.origin.set(0, 0); ceiling.scale.x = FlxG.width; ceiling.scale.y = FlxG.height * 2; ceiling.y = -FlxG.height * 4; add(ceiling); } public function deskZoomOut(elapsed:Float) { if (stateTime <= DESK_TIMING[0]) { } else if (stateTime > DESK_TIMING[0] && stateTime <= DESK_TIMING[1]) { var f0 = FlxMath.bound((DESK_TIMING[1] - stateTime) / (DESK_TIMING[1] - DESK_TIMING[0]), 0, 1.0); f0 = Math.pow(f0, 2.2); var f1 = 1.0 - f0; desk.scale.x = 2.33 * f0 + 1.0 * f1; desk.scale.y = 2.13 * f0 + 1.0 * f1; hand.scale.x = 2.33 * f0 + 1.0 * f1; hand.scale.y = 2.13 * f0 + 1.0 * f1; screenshot.scale.x = 1.00 * f0 + 0.429 * f1; screenshot.scale.y = 1.00 * f0 + 0.469 * f1; } { var f0 = FlxMath.bound((3.5 - stateTime) / (3.5 - 1.5), 0, 1.0); var f1 = 1.0 - f0; var wispAlpha:Float = f0 * 0.0 + f1 * 1.0; wisp.alpha.set(wispAlpha, wispAlpha, 0.0, 0.0); var wispSize:Float = 500 * f0 + 60 * f1; wisp.scale.set(wispSize); wisp.speed.set(wispSize, wispSize * 2, 0, 0); if (wispAlpha == 0) { wispSfxVolume = 0; } else { wispSfxVolume = FlxMath.bound(wispAlpha, 0.2, 1.0); } } if (wispSfxVolume > 0) { wispSfxTimer -= elapsed; if (wispSfxTimer <= 0) { wispSfx = SoundStackingFix.play(AssetPaths.soul_sparkle_00ec__mp3, wispSfxVolume * FlxG.random.float(0.8, 1.0)); wispSfxTimer += FlxG.random.float(1.5, 1.7); } } if (stateTime >= DESK_TIMING[2] + 0.8) { hand.animation.frameIndex = 1; } var risingVelocity:Float = FlxMath.bound((stateTime - DESK_TIMING[2]) * 20, 0, 1000) * elapsed; desk.y += risingVelocity; screenshot.y += risingVelocity; hand.y += risingVelocity; ceiling.y += risingVelocity * 1.6; // wisp position... wisp.x = 768 / 2 + Math.sin(stateTime * 2.1) * 60 + Math.sin(stateTime * 5.4 + 0.13) * 60; wisp.y = 432 / 2 + Math.cos(stateTime * 2.1) * 60 + Math.cos(stateTime * 5.4 + 0.13) * 60; if (desk.y > -150) { initEarthZoomOut(); setStateFunction(earthZoomOut); } } private function initEarthZoomOut():Void { clear(); stars0 = addZoomySprite(AssetPaths.stars__png); stars0.scale.x = 3; stars0.scale.y = 3; add(stars0); terrain3 = addZoomySprite(AssetPaths.zoom_out__png); terrain3.animation.frameIndex = 3; add(terrain3); terrain2 = addZoomySprite(AssetPaths.zoom_out__png); terrain2.animation.frameIndex = 2; add(terrain2); terrain1 = addZoomySprite(AssetPaths.zoom_out__png); terrain1.animation.frameIndex = 1; add(terrain1); terrain0 = addZoomySprite(AssetPaths.zoom_out__png); terrain0.animation.frameIndex = 0; add(terrain0); terrain4 = addZoomySprite(AssetPaths.zoom_out__png); terrain4.animation.frameIndex = 4; add(terrain4); cloud0 = addZoomySprite(AssetPaths.zoom_out_clouds__png); cloud0.animation.frameIndex = 0; add(cloud0); cloud1 = addZoomySprite(AssetPaths.zoom_out_clouds__png); cloud1.animation.frameIndex = 1; add(cloud1); cloud2 = addZoomySprite(AssetPaths.zoom_out_clouds__png); cloud2.animation.frameIndex = 2; add(cloud2); for (i in 0...wisp.length) { if (wisp.members[i] != null) { wisp.members[i].kill(); } } add(wisp); wisp.alpha.set(0, 0, 0, 0); wisp.speed.set(60, 120, 0, 0); wisp.start(false, 0.05); add(wispLayer); } public function earthZoomOut(elapsed:Float):Void { var a:Float = stateTime * 7 - 20; if (wisp.alpha.start.min < 1.0) { wisp.alpha.set(wisp.alpha.start.min + elapsed * 2, wisp.alpha.start.min + elapsed * 2, 0.0, 0.0); } if (wispSfxVolume > 0) { wispSfxTimer -= elapsed; if (wispSfxTimer <= 0) { wispSfx = SoundStackingFix.play(AssetPaths.soul_sparkle_00ec__mp3, wispSfxVolume * FlxG.random.float(0.8, 1.0)); wispSfxTimer += FlxG.random.float(1.5, 1.7); } } var zoomFactor:Float; if (a < 58) { zoomFactor = a; } else { zoomFactor = 58 + (a - 58) * 0.3; } zoomFactor = FlxMath.bound(zoomFactor, -20, 63); var moveFactor:Float; moveFactor = FlxMath.bound(a - 53, 0, 30) * 20; terrain4.scale.x = 2000 * Math.pow(0.9, zoomFactor); terrain4.scale.y = 16000 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); terrain4.alpha = FlxMath.bound((a - 15) / 63, 0, 0.6); terrain3.scale.x = 2000 * Math.pow(0.9, zoomFactor); terrain3.scale.y = 16000 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); terrain2.scale.x = 200 * Math.pow(0.9, zoomFactor); terrain2.scale.y = 400 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); terrain1.scale.x = 20 * Math.pow(0.9, zoomFactor); terrain1.scale.y = 20 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); cloud0.scale.x = 80 * Math.pow(0.9, zoomFactor); cloud0.scale.y = 80 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); cloud0.alpha = FlxMath.bound((a - 20) / 20, 0, 1.0); cloud1.scale.x = 800 * Math.pow(0.9, zoomFactor); cloud1.scale.y = 800 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); cloud1.alpha = FlxMath.bound((a - 35) / 20, 0, 1.0); cloud2.scale.x = 1600 * Math.pow(0.9, zoomFactor); cloud2.scale.y = 12800 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); cloud2.alpha = FlxMath.bound((a - 50) / 20, 0, 1.0); terrain0.scale.x = 2 * Math.pow(0.9, zoomFactor); terrain0.scale.y = 2 * Math.pow(0.9, zoomFactor) * Math.pow(0.95, Math.max(0, zoomFactor - 20)); cloud0.y = (216 / 2) + moveFactor; cloud0.x = 4 * a; cloud1.y = (216 / 2) + moveFactor; cloud1.x = -2 * a; cloud2.y = (216 / 2) + moveFactor; cloud2.x = 2 * a; terrain0.y = (216 / 2) + moveFactor; terrain1.y = (216 / 2) + moveFactor; terrain2.y = (216 / 2) + moveFactor; terrain3.y = (216 / 2) + moveFactor; terrain4.y = (216 / 2) + moveFactor; stars0.y = (216 / 2) - 100 + moveFactor * 0.3; // wisp size... var wispSize = FlxMath.bound(60 * Math.pow(0.97, a), 8, 60); wisp.scale.set(wispSize); wisp.speed.set(wispSize, 2 * wispSize, 0, 0); // wisp position... wisp.x = 768 / 2 + Math.sin(a * 0.3) * wispSize + Math.sin((a + 0.17) * 0.77) * wispSize; wisp.y = 432 / 2 + Math.cos(a * 0.3) * wispSize + Math.cos((a + 0.17) * 0.77) * wispSize; if (a <= 92) { wispSfxVolume = FlxMath.bound(wispSize / 60, 0.2, 1.0); } if (a > 92 && wisp.emitting) { wisp.emitting = false; wispLine.set(wisp.x, wisp.y, 8, wisp.x + 200, wisp.y - 105, 0); wispLine.age = 0; wispSfxVolume = 0; FlxSoundKludge.play(AssetPaths.soul_zoom_00b9__mp3, 0.7); } if (a > 92) { FlxSpriteUtil.fill(wispLayer, FlxColor.TRANSPARENT); wispLine.update(elapsed); wispLine.draw(wispLayer); if (wispSfx != null) { wispSfx.volume -= elapsed; } } if (a > 102) { initFlyBy(); setStateFunction(flyBy); } } private function initFlyBy():Void { clear(); stars1 = new FlxSprite(0, 0); stars1.x = 384 / 2; stars1.y = 216 / 2; stars1.width = 0; stars1.height = 0; stars1.loadGraphic(AssetPaths.stars_flyby__png); stars1.scale.x = 2; stars1.scale.y = 2; add(stars1); FlxSpriteUtil.fill(wispLayer, FlxColor.TRANSPARENT); add(wispLayer); wispLine.age = 10000; abraWispLine.age = 10000; } public function flyBy(elapsed:Float):Void { if (stateTime >= ZWOOSH_TIMING[0] && stateTime - elapsed < ZWOOSH_TIMING[0]) { wispSfx = SoundStackingFix.play(AssetPaths.soul_sparkle_00ec__mp3, 0.5); } if (stateTime >= ZWOOSH_TIMING[1] && stateTime - elapsed < ZWOOSH_TIMING[1]) { FlxSoundKludge.play(AssetPaths.soul_zwoosh_00c2__mp3, 1.0); } if (stateTime <= ZWOOSH_TIMING[0]) { stars1.x -= elapsed * 3; } else if (stateTime > ZWOOSH_TIMING[0]) { if (stateTime >= ZWOOSH_TIMING[2] && stateTime <= ZWOOSH_TIMING[5]) { stars1.x -= elapsed * 4000; } if (stateTime > ZWOOSH_TIMING[0] && stateTime <= ZWOOSH_TIMING[2]) { var f0 = FlxMath.bound((ZWOOSH_TIMING[1] - stateTime) / (ZWOOSH_TIMING[1] - ZWOOSH_TIMING[0]), 0, 1.0); var f1 = 1.0 - f0; wispLine.set(246, 228, 0, f0 * 246 + f1 * 800, 229, f0 * 0 + f1 * 30); wispLine.age = 0; } else if (stateTime > ZWOOSH_TIMING[2] && stateTime <= ZWOOSH_TIMING[3]) { var f0 = FlxMath.bound((ZWOOSH_TIMING[3] - stateTime) / (ZWOOSH_TIMING[3] - ZWOOSH_TIMING[2]), 0, 1.0); var f1 = 1.0 - f0; wispLine.set(f0 * 246 + f1 * -50, 228, f0 * 0 + f1 * 30, 800, 229, 30); wispLine.age = 0; } else if (stateTime > ZWOOSH_TIMING[3]) { var f0 = FlxMath.bound((ZWOOSH_TIMING[5] - stateTime) / (ZWOOSH_TIMING[5] - ZWOOSH_TIMING[4]), 0, 1.0); var f1 = 1.0 - f0; wispLine.set( -50, 228, 30, f0 * 800 + f1 * 500, 229, f0 * 30 + f1 * 0); if (wispSfx != null) wispSfx.volume -= 0.2 * elapsed; } if (stateTime > ZWOOSH_TIMING[6]) { if (stateTime - elapsed <= ZWOOSH_TIMING[6]) { FlxSoundKludge.play(AssetPaths.soul_zwoosh_00c2__mp3, 0.5); } var f0 = FlxMath.bound((ZWOOSH_TIMING[7] - stateTime) / (ZWOOSH_TIMING[7] - ZWOOSH_TIMING[6]), 0, 1.0); var f1 = 1.0 - f0; abraWispLine.set( 500 * f0 - 50 * f1, 231 * f0 + 260 * f1, 0 * f0 + 30 * f1, 500, 231, 0); if (stateTime <= ZWOOSH_TIMING[7]) { abraWispLine.age = 0; } } FlxSpriteUtil.fill(wispLayer, FlxColor.TRANSPARENT); wispLine.update(elapsed); abraWispLine.update(elapsed); wispLine.draw(wispLayer); abraWispLine.draw(wispLayer); } if (stateTime >= ZWOOSH_TIMING[8]) { FlxG.switchState(new CreditsState()); } } override public function update(elapsed:Float):Void { super.update(elapsed); stateTime += elapsed; stateFunction(elapsed); } override public function destroy():Void { super.destroy(); stateFunction = null; screenshot = FlxDestroyUtil.destroy(screenshot); desk = FlxDestroyUtil.destroy(desk); hand = FlxDestroyUtil.destroy(hand); ceiling = FlxDestroyUtil.destroy(ceiling); cloud0 = FlxDestroyUtil.destroy(cloud0); cloud1 = FlxDestroyUtil.destroy(cloud1); cloud2 = FlxDestroyUtil.destroy(cloud2); terrain0 = FlxDestroyUtil.destroy(terrain0); terrain1 = FlxDestroyUtil.destroy(terrain1); terrain2 = FlxDestroyUtil.destroy(terrain2); terrain3 = FlxDestroyUtil.destroy(terrain3); terrain4 = FlxDestroyUtil.destroy(terrain4); stars0 = FlxDestroyUtil.destroy(stars0); wisp = FlxDestroyUtil.destroy(wisp); wispLine = FlxDestroyUtil.destroy(wispLine); abraWispLine = FlxDestroyUtil.destroy(abraWispLine); wispLayer = FlxDestroyUtil.destroy(wispLayer); wispSfx = FlxDestroyUtil.destroy(wispSfx); stars1 = FlxDestroyUtil.destroy(stars1); } public static function newInstance():EndingAnim { var screenshot = new FlxSprite(); screenshot.makeGraphic(FlxG.width, FlxG.height, FlxColor.WHITE, true); // TODO: Need to handle non-flash targets #if flash screenshot.pixels.copyPixels(FlxG.camera.buffer, new Rectangle(0, 0, FlxG.width, FlxG.height), new Point()); #end return new EndingAnim(screenshot); } }
argonvile/monster
source/credits/EndingAnim.hx
hx
unknown
16,297
package credits; import flixel.effects.particles.FlxParticle; import flixel.util.FlxColor; /** * A particle that fades from white to midnight blue. Used in the ending * animation */ class FadeBlueParticle extends FlxParticle { public function new() { super(); setColor(0xffffffff); } private function setColor(color:FlxColor) { this.color = color; makeGraphic(1, 1, color); } override public function update(elapsed:Float):Void { super.update(elapsed); if (age > lifespan * 0.3 && age <= lifespan * 0.6 && color != 0xff7fe4ff) { setColor(0xff7fe4ff); } else if (age > lifespan * 0.6 && color != 0xff40a4c0) { setColor(0xff40a4c0); } } override public function reset(X:Float, Y:Float):Void { super.reset(X, Y); setColor(0xffffffff); } }
argonvile/monster
source/credits/FadeBlueParticle.hx
hx
unknown
828
package credits; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import kludge.FlxSoundKludge; import openfl.geom.ColorTransform; import openfl.geom.Point; import openfl.geom.Rectangle; /** * This is an FlxState which makes it look like the game has crashed, producing * some weird graphical artifacts, a fake stack trace, and a very annoying * noise * * It's used towards the end of the game if you make Abra really, really angry */ class FakeCrash extends FlxState { private var bg:FlxSprite; private var screenshot:FlxSprite; private var stackTrace:FlxText; private var eventStack:EventStack; public function new(screenshot:FlxSprite = null) { super(); this.screenshot = screenshot; } override public function destroy():Void { super.destroy(); bg = FlxDestroyUtil.destroy(bg); screenshot = FlxDestroyUtil.destroy(screenshot); stackTrace = FlxDestroyUtil.destroy(stackTrace); eventStack = null; } override public function create():Void { super.create(); Main.overrideFlxGDefaults(); FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; if (screenshot == null) { screenshot = new FlxSprite(0, 0, AssetPaths.shop_bg__png); } bg = new FlxSprite(0, 0); bg.makeGraphic(FlxG.width, FlxG.height, FlxColor.WHITE, true); bg.stamp(screenshot, 200, 0); bg.stamp(screenshot, 200 - FlxG.width, 0); bg.pixels.colorTransform(new Rectangle(0, 0, FlxG.width, FlxG.height), new ColorTransform(1, 0, 1)); bg.dirty = true; add(bg); stackTrace = new FlxText(0, 0, 0, "TypeError: Error #1009: Cannot access a property or method oU+0066 a null object reU+0066erence.\n" + " at puzzle::PuzzleState/create()[D:\\workspace\\MonsterMind\\source\\puzzle\\PuzzleState.hx:33]\n" + " at U+0066lixel::U+0046lxGame/switchState()[C:\\HaxeToolkit\\haxe\\lib\\U+0066lixel\\4,3,0\\U+0066lixel\\U+0046lxGame.hx:627]\n" + " at U+0066lixel::U+0046lxGame/create()[C:\\HaxeToolkit\\haxe\\lib\\U+0066lixel\\4,3,0\\U+0066lixel\\U+0046lxGame.hx:352]\n" + " at U+0066lash.display::DisplayObjectContainer/addChild()\n" + " at Main/setupGame()[D:\\workspace\\MonsterMind\\source\\Main.hx:99]\n" + " at Main/init()[D:\\workspace\\MonsterMind\\source\\Main.hx:77]\n" + " at U+0066lash.display::DisplayObjectContainer/addChild()\n" + " at Main$/main()[D:\\workspace\\MonsterMind\\source\\Main.hx:53]\n" + " at U+0046unction/http://adobe.com/AS3/2006/builtin::apply()\n" + " at U+0046unction/<anonymous>()", 32); stackTrace.color = FlxColor.BLACK; add(stackTrace); add(new FlxSprite()); add(new FlxSprite(200, 200)); eventStack = new EventStack(); eventStack.addEvent({time:eventStack._time + 25.0, callback:switchStateEvent}); FlxSoundKludge.play(AssetPaths.abra_talk__wav, 0.08, true); } public function switchStateEvent(args:Array<Dynamic>):Void { FlxG.switchState(new MainMenuState()); } override public function update(elapsed:Float):Void { super.update(elapsed); eventStack.update(elapsed); } public static function newInstance():FakeCrash { var screenshot = new FlxSprite(); screenshot.makeGraphic(FlxG.width, FlxG.height, FlxColor.WHITE, true); // TODO: Need to handle non-flash targets #if flash screenshot.pixels.copyPixels(FlxG.camera.buffer, new Rectangle(0, 0, FlxG.width, FlxG.height), new Point()); #end return new FakeCrash(screenshot); } }
argonvile/monster
source/credits/FakeCrash.hx
hx
unknown
3,592
package credits; import MmStringTools.*; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import openfl.geom.Point; import openfl.geom.Rectangle; import poke.abra.AbraDialog; /** * After swapping, there is a scene where Abra contacts you when she is now a * glove, and you talk about how things are going. This is the FlxState which * encompasses that scene. */ class GloveWakeUpState extends FlxTransitionableState { private var _dialogTree:DialogTree; public var _dialogger:Dialogger; private var _pokeWindow:GloveWindow; private var _eventStack:EventStack = new EventStack(); private var _deadGlove:FlxSprite; private var _words:FlxSprite; public function new(?TransIn:TransitionData, ?TransOut:TransitionData) { super(TransIn, TransOut); } override public function create():Void { Main.overrideFlxGDefaults(); super.create(); bgColor = 0xFF365B83; var bg:FlxSprite = new FlxSprite(0, 0, AssetPaths.glovechat_bg__png); add(bg); _deadGlove = new FlxSprite(0, 0, AssetPaths.glovechat_deadglove__png); _deadGlove.pixels.threshold(_deadGlove.pixels, new Rectangle(0, 0, _deadGlove.pixels.width, _deadGlove.pixels.height), new Point(0, 0), '==', 0xffffffff, PlayerData.cursorFillColor); _deadGlove.pixels.threshold(_deadGlove.pixels, new Rectangle(0, 0, _deadGlove.pixels.width, _deadGlove.pixels.height), new Point(0, 0), '==', 0xff000000, PlayerData.cursorLineColor); _deadGlove.alpha = PlayerData.cursorMaxAlpha; add(_deadGlove); _words = new FlxSprite(0, 0, AssetPaths.glovechat_words__png); _words.alpha = 0; add(_words); FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; _pokeWindow = new GloveWindow(); _pokeWindow.visible = false; add(_pokeWindow); _dialogger = new Dialogger(); add(_dialogger); _eventStack.addEvent({time:_eventStack._time + 0.8, callback:eventWordsAlpha, args:[1.0]}); _eventStack.addEvent({time:_eventStack._time + 3.8, callback:eventWordsAlpha, args:[0.0]}); _eventStack.addEvent({time:_eventStack._time + 4.0, callback:eventLaunchDialog}); } override public function destroy():Void { super.destroy(); _dialogTree = FlxDestroyUtil.destroy(_dialogTree); _dialogger = FlxDestroyUtil.destroy(_dialogger); _pokeWindow = FlxDestroyUtil.destroy(_pokeWindow); _eventStack = null; _deadGlove = FlxDestroyUtil.destroy(_deadGlove); _words = FlxDestroyUtil.destroy(_words); } public function eventWordsAlpha(args:Array<Dynamic>):Void { var newAlpha:Float = args[0]; FlxTween.tween(_words, {alpha: newAlpha}, 0.4); } override public function update(elapsed:Float):Void { super.update(elapsed); _eventStack.update(elapsed); } public function dialogTreeCallback(Msg:String):String { if (StringTools.startsWith(Msg, "%fun-")) { /* * Dialog strings like %fun-nude2% have an effect on a * PokemonWindow instance. PokemonWindow subclasses can override * the doFun method to define special behavior, such as taking off * a Pokemon's hat, having them give a thumbs up or make a silly * face. */ var funStr:String = substringBetween(Msg, "%fun-", "%"); if (funStr != null) { _pokeWindow.doFun(funStr); } } if (Msg == "%fun-alpha1%") { _deadGlove.visible = false; } if (Msg == "") { _pokeWindow.visible = false; _eventStack.addEvent({time:_eventStack._time + 1.4, callback:eventExit}); } return null; } public function eventLaunchDialog(args:Array<Dynamic>) { _pokeWindow.visible = true; _dialogTree = new DialogTree(_dialogger, AbraDialog.gloveWakeUp(), dialogTreeCallback); _dialogTree.go(); } public function eventExit(args:Array<Dynamic>) { transOut = MainMenuState.fadeOutSlow(); FlxG.switchState(new MainMenuState(MainMenuState.fadeInFast())); } }
argonvile/monster
source/credits/GloveWakeUpState.hx
hx
unknown
4,128
package credits; import flixel.FlxSprite; import flixel.util.FlxDestroyUtil; import openfl.geom.Point; import openfl.geom.Rectangle; import poke.PokeWindow; import poke.rhyd.BreathingSprite; /** * When you swap with Abra, Abra comes to visit you as a glove to say hello. * * GloveWindow is a window used in that scene which resembles an interactive * pokemon windows, but it just has a glove in it. */ class GloveWindow extends PokeWindow { private var _hand:BreathingSprite; public function new(X:Float=0, Y:Float=0, Width:Int=248, Height:Int = 349) { super(X, Y, Width, Height); add(new FlxSprite( -54, -54, AssetPaths.abra_bg__png)); _hand = new BreathingSprite( -54, -54, 0, 7, 0, 0); _hand.loadWindowGraphic(AssetPaths.glove_pokewindow__png, true); _hand.pixels.threshold(_hand.pixels, new Rectangle(0, 0, _hand.pixels.width, _hand.pixels.height), new Point(0, 0), '==', 0xffffffff, PlayerData.cursorFillColor); _hand.pixels.threshold(_hand.pixels, new Rectangle(0, 0, _hand.pixels.width, _hand.pixels.height), new Point(0, 0), '==', 0xff000000, PlayerData.cursorLineColor); _hand.alpha = PlayerData.cursorMaxAlpha; _hand.animation.add("default", [0, 1, 2, 3, 4]); _hand.animation.play("default"); addPart(_hand); } override public function destroy():Void { super.destroy(); _hand = FlxDestroyUtil.destroy(_hand); } /** * Overridden for special "glove shows up" behavior -- most Pokemon are * fully opaque, but the glove has an alpha component * * @param str the "interesting" part of the dialog string; e.g "nude2" */ override public function doFun(str:String) { if (str == "alpha1") { _partAlpha = 1; for (item in _visualItems) { item.alpha = PlayerData.cursorMaxAlpha; } } else { super.doFun(str); } } }
argonvile/monster
source/credits/GloveWindow.hx
hx
unknown
1,863
package credits; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxVector; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import flixel.util.FlxSpriteUtil; /** * During the credits when an object zips through space or zips into abra, * there is a fadey line with a fat end and a skinny end. WispLine * encompasses logic for drawing and fading those lines */ class WispLine implements IFlxDestroyable { var x0:Float = 0; var y0:Float = 0; var w0:Float = 0; var x1:Float = 0; var y1:Float = 0; var w1:Float = 0; var vertices:Array<FlxPoint> = [FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get()]; public var color:FlxColor = 0xffffffff; public var age:Float = 0; public var lifespan:Float = 1.2; public function new() { } public function update(elapsed:Float) { age += elapsed; if (age <= lifespan * 0.3) { color = 0xffffffff; } else if (age > lifespan * 0.3 && age <= lifespan * 0.6) { color = 0xff7fe4ff; } else if (age > lifespan * 0.6) { color = 0xff40a4c0; } color.alphaFloat = FlxMath.bound((lifespan - age) / lifespan, 0, 1); } public function set(x0:Float, y0:Float, w0:Float, x1:Float, y1:Float, w1:Float) { this.x0 = x0; this.y0 = y0; this.w0 = w0; this.x1 = x1; this.y1 = y1; this.w1 = w1; var d:FlxVector = FlxVector.get(); d.set(x1 - x0, y1 - y0); d.length = 1; vertices[0].set(x0 + w0 * 0.5 * d.y, y0 - w0 * 0.5 * d.x); vertices[1].set(x1 + w1 * 0.5 * d.y, y1 - w1 * 0.5 * d.x); vertices[2].set(x1 + w1 * 0.5 * d.y, y1 + w1 * 0.5 * d.x); vertices[3].set(x1 - w1 * 0.5 * d.y, y1 + w1 * 0.5 * d.x); vertices[4].set(x0 - w0 * 0.5 * d.y, y0 + w0 * 0.5 * d.x); vertices[5].set(x0 + w0 * 0.5 * d.y, y0 + w0 * 0.5 * d.x); d.put(); } public function draw(sprite:FlxSprite) { FlxSpriteUtil.drawPolygon(sprite, vertices, color); } public function destroy():Void { vertices = FlxDestroyUtil.putArray(vertices); } }
argonvile/monster
source/credits/WispLine.hx
hx
unknown
2,191
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; import flixel.math.FlxMath; import flixel.math.FlxRandom; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.tweens.misc.VarTween; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import kludge.BetterFlxRandom; import openfl.geom.Point; import openfl.geom.Rectangle; import poke.sexy.RandomPolygonPoint; import puzzle.Puzzle; /** * Graphics and logic for the little bugs which the player interacts with * during puzzles. * * Since "Bug" means something else in the context of computer programs, these * are often referred to as "critters" in code */ class Critter implements IFlxDestroyable { // which critters to load public static var LOAD_DEFAULT:Int = 0; public static var LOAD_ALL:Int = 1; public static var LOAD_BASIC_ONLY:Int = 2; // unambiguous color names; they correspond to different palettes for the critters public static var FJ_RED_DK:String = "red/dark red"; public static var FJ_BLUE_LT:String = "blue/light blue"; public static var FJ_YEL:String = "yellow"; public static var FJ_GREN_DK:String = "green/dark green"; public static var FJ_PRPL:String = "purple"; public static var FJ_BRWN:String = "brown"; public static var FJ_RED_LT:String = "red/light red"; public static var FJ_ORNG:String = "orange"; public static var FJ_GREN_LT:String = "green/light green"; public static var FJ_PINK:String = "pink"; public static var FJ_CYAN:String = "cyan"; public static var FJ_WHIT:String = "white"; public static var FJ_BLAK:String = "black"; public static var FJ_GREY:String = "grey"; public static var FJ_BLUE_DK:String = "blue/dark blue"; // critter color keycodes; they correspond to pixel colors in the source image, we use them for threshold color replacements private static var CCL_SKIN:Int = 0xfff57d86; private static var CCL_SKIN_SHADOW:Int = 0xffd57075; private static var CCL_SKIN_LINE:Int = 0xffb36264; private static var CCL_BELLY:Int = 0xff7b3f43; private static var CCL_BELLY_SHADOW:Int = 0xff6b383b; private static var CCL_BELLY_LINE:Int = 0xff5a3132; private static var CCL_EYES:Int = 0xfffabec3; private static var CCL_EYES_LINE:Int = 0xffffe7e9; private static var CCL_EYES_SHINE:Int = 0xffffffff; private static var STATIC_ID:Int = 0; public var myId:Int = STATIC_ID++; public static var _FRAME_RATE = 6; public static var CRITTER_GENDERS:Array<Float> = []; public static var CRITTER_COLORS:Array<CritterColor> = []; public static var IDLE_ENABLED:Bool = true; public var _targetSprite:FlxSprite; public var _soulSprite:FlxSprite; public var _bodySprite:CritterBody; public var _headSprite:CritterHead; public var _frontBodySprite:FlxSprite; public var _critterColor:CritterColor; public var outCold:Bool; public var _runToCallback:Critter->Void; // Z coordinate; if creature is jumping or carried public var z:Float = 0; // Z coordinate of the surface the critter is standing on; usually zero, but sometimes they are on a platform public var groundZ:Float = 0; public var targetGroundZ:Float = 0; private var _backdrop:FlxSprite; public var _tween0:VarTween = null; public var _tween1:VarTween = null; public var _tween2:VarTween = null; public var _eventStack:EventStack = new EventStack(); public var _frontBodySpriteOffset:Float = 4; public var _bodySpriteOffset:Float = 39; // for auditing purposes; if a critter ends up in a crazy state, we can use this to figure out what happened public var _lastSexyAnim:String = null; public var shadow:Shadow; public var idleMove:Bool = true; // this critter doesn't move unless someone tells it to public var permanentlyImmovable:Bool = false; /* * tracks whether this critter was immovable before the sexy animation * started; when the sexy animation ends, we want to restore them to their * previous state */ public var wasImmovableBeforeSexyAnim:Bool = false; public var jumpType:Int = 0; public var canDie:Bool = true; /** * Initializes a new bug. * * Bugs sometimes barf or cum on the background, so this takes the * background sprite as a parameter so the bugs can do their thing. ...So * don't pass in any sprites which you can't trivially put in the laundry * afterwards. If you need to, cover your sprite with a towel sprite first. * * @param X bug's x position * @param Y bug's y position * @param Backdrop background sprite for the bug to make messes on */ public function new(X:Float, Y:Float, Backdrop:FlxSprite) { this._backdrop = Backdrop; _targetSprite = new FlxSprite(X, Y); _targetSprite.makeGraphic(38, 14, 0x88FFFF00); _targetSprite.visible = false; _targetSprite.offset.set(3, 4); _soulSprite = new FlxSprite(X, Y); _soulSprite.makeGraphic(38, 14, 0x44FF00FF); _soulSprite.visible = false; _soulSprite.offset.set(3, 4); _bodySprite = new CritterBody(this); _bodySprite.setPosition(X, Y); _headSprite = new CritterHead(this); _frontBodySprite = new FlxSprite(); _frontBodySprite.setFacingFlip(FlxObject.LEFT, false, false); _frontBodySprite.setFacingFlip(FlxObject.RIGHT, true, false); _frontBodySprite.facing = _bodySprite.facing; _frontBodySprite.visible = false; _headSprite.addBlinkableFrame(0, 3); _headSprite.addBlinkableFrame(1, 3); _headSprite.addBlinkableFrame(2, 3); _headSprite.addBlinkableFrame(48, 50); _headSprite.addBlinkableFrame(49, 51); _headSprite.addBlinkableFrame(52, 50); _headSprite.addBlinkableFrame(53, 51); _headSprite.addBlinkableFrame(54, 62); _headSprite.addBlinkableFrame(55, 63); _headSprite.addBlinkableFrame(58, 66); _headSprite.addBlinkableFrame(59, 67); _headSprite.addBlinkableFrame(60, 68); _headSprite.addBlinkableFrame(61, 69); _headSprite.addBlinkableFrame(72, 86); _headSprite.addBlinkableFrame(73, 87); _headSprite.addBlinkableFrame(80, 84); _headSprite.addBlinkableFrame(81, 85); _headSprite.addBlinkableFrame(82, 84); _headSprite.addBlinkableFrame(83, 85); _headSprite.addBlinkableFrame(98, 100); _headSprite.addBlinkableFrame(99, 100); _headSprite.addBlinkableFrame(101, 103); _headSprite.addBlinkableFrame(102, 103); // set random default color, for use in minigames that don't care about color setColor(CRITTER_COLORS[FlxG.random.int(0, CRITTER_COLORS.length - 1)]); } public static function loadPaletteShiftedGraphic(sprite:FlxSprite, critterColor:CritterColor, graphicAsset:FlxGraphicAsset, animated:Bool = false, width:Int = 0, height:Int = 0) { var graphicKey:String = graphicAsset + "-" + critterColor.englishBackup; if (FlxG.bitmap.get(graphicKey) == null) { var graphic:FlxGraphic = FlxG.bitmap.add(graphicAsset, false, graphicKey); for (key in critterColor.tint.keys()) { graphic.bitmap.threshold(graphic.bitmap, new Rectangle(0, 0, graphic.bitmap.width, graphic.bitmap.height), new Point(0, 0), '==', key, critterColor.tint[key]); } } sprite.loadGraphic(graphicKey, animated, width, height); } public function setColor(critterColor:CritterColor) { this._critterColor = critterColor; loadPaletteShiftedGraphic(_bodySprite, critterColor, AssetPaths.critter_bodies_0__png, true, 64, 64); loadPaletteShiftedGraphic(_frontBodySprite, critterColor, AssetPaths.critter_bodies_0__png, true, 64, 64); loadPaletteShiftedGraphic(_headSprite, critterColor, AssetPaths.critter_heads_0__png, true, 64, 64); _bodySprite.setSize(36, 10); _bodySprite.offset.set(14, _bodySpriteOffset); _frontBodySprite.setSize(36, 10); _frontBodySprite.offset.set(14, _bodySpriteOffset + _frontBodySpriteOffset + z); _headSprite.setSize(36, 10); _headSprite.offset.set(14, _bodySpriteOffset + 2); loadCritterAnimations(); _headSprite.animation.play("idle"); _bodySprite.animation.play("idle"); _bodySprite.movingPrefix = "run"; _frontBodySprite.animation.play("idle"); } private function loadCritterAnimations():Void { { var idleAnim:Array<Int> = []; AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [4, 5]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [4, 5]); AnimTools.push(idleAnim, FlxG.random.int(7, 10), [0, 1, 2]); AnimTools.push(idleAnim, FlxG.random.int(3, 4), [4, 5]); _headSprite.animation.add("idle", idleAnim, _FRAME_RATE); // This is two frames, so that critterBody logic can tell when it animates _bodySprite.animation.add("idle", [0, 0], _FRAME_RATE); _frontBodySprite.animation.add("idle", [2, 2], _FRAME_RATE); _headSprite.animation.add("sexy-idle", idleAnim, _FRAME_RATE); _bodySprite.animation.add("sexy-idle", [0, 0], _FRAME_RATE); _frontBodySprite.animation.add("sexy-idle", [2, 2], _FRAME_RATE); } _headSprite.animation.add("grab", [6]); _bodySprite.animation.add("grab", [1]); // drag critter west fast _bodySprite.animation.add("grab-w2", [90, 90, 91, 1, 89, 1], _FRAME_RATE, false); _bodySprite.animation.add("grab-w1", [91, 91, 1], _FRAME_RATE, false); // drag critter east fast _bodySprite.animation.add("grab-e2", [88, 88, 89, 1, 91, 1], _FRAME_RATE, false); _bodySprite.animation.add("grab-e1", [89, 89, 1], _FRAME_RATE, false); _headSprite.animation.add("tumble-sw", [36, 37, 38, 39], _FRAME_RATE); _bodySprite.animation.add("tumble-sw", [76, 77, 78, 79], _FRAME_RATE); _headSprite.animation.add("tumble-nw", [36, 37, 38, 39], _FRAME_RATE); _bodySprite.animation.add("tumble-nw", [76, 77, 78, 79], _FRAME_RATE); _headSprite.animation.add("tumble-n", [36, 37, 38, 39], _FRAME_RATE); _bodySprite.animation.add("tumble-n", [76, 77, 78, 79], _FRAME_RATE); _headSprite.animation.add("bad-landing-sw", AnimTools.blinkyAnimation([74, 75]), _FRAME_RATE); _bodySprite.animation.add("bad-landing-sw", [80, 80, 80, 80, 82, 84], _FRAME_RATE, false); _headSprite.animation.add("run-sw", [16]); _bodySprite.animation.add("run-sw", [8, 9, 10], _FRAME_RATE); _headSprite.animation.add("jump-sw", [16]); _bodySprite.animation.add("jump-sw", [9, 10], 0); _headSprite.animation.add("run-nw", [20]); _bodySprite.animation.add("run-nw", [12, 13, 14], _FRAME_RATE); _headSprite.animation.add("jump-nw", [20]); _bodySprite.animation.add("jump-nw", [13, 14], 0); _headSprite.animation.add("run-n", [24]); _bodySprite.animation.add("run-n", [16, 17, 18], _FRAME_RATE); _headSprite.animation.add("jump-n", [24]); _bodySprite.animation.add("jump-n", [17, 18], 0); _headSprite.animation.add("run-s", [0]); _bodySprite.animation.add("run-s", [20, 21, 22], _FRAME_RATE); _headSprite.animation.add("jump-s", [0]); _bodySprite.animation.add("jump-s", [21, 22], 0); _headSprite.animation.add("idle-itch0", [13, 13, 14, 15, 14, 15, 14, 15, 0], _FRAME_RATE, false); _bodySprite.animation.add("idle-itch0", [0, 4, 5, 4, 5, 4, 5, 4, 0], _FRAME_RATE, false); _frontBodySprite.animation.add("idle-itch0", [2, 2, 6, 2, 6, 2, 6, 2], _FRAME_RATE, false); _headSprite.animation.add("idle-itch1", [13, 13, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 0], _FRAME_RATE, false); _bodySprite.animation.add("idle-itch1", [0, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 0], _FRAME_RATE, false); _frontBodySprite.animation.add("idle-itch1", [2, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2], _FRAME_RATE, false); _headSprite.animation.add("idle-shake", [3, 3, 27, 28, 29, 30, 25, 26, 27, 28, 29, 30, 25, 26, 27, 28, 29, 30, 25, 26, 27, 28, 29, 3, 3, 3, 3], 12, false); _bodySprite.animation.add("idle-shake", [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0], 12, false); _headSprite.animation.add("idle-wobble", [17, 17, 0, 18, 18, 1, 17, 17, 2, 18, 18], _FRAME_RATE, false); _bodySprite.animation.add("idle-wobble", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-yawn0", [21, 22, 23, 22, 23, 22, 23, 22, 21, 0, 3, 0], _FRAME_RATE, false); _bodySprite.animation.add("idle-yawn0", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-yawn1", [21, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 21, 0, 3, 3, 0, 3, 0], _FRAME_RATE, false); _bodySprite.animation.add("idle-yawn1", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-outcold0", [32], _FRAME_RATE); _bodySprite.animation.add("idle-outcold0", [0], _FRAME_RATE); { // randomly apply one of three "out cold" animations var outColdFrames:Array<Int> = FlxG.random.getObject([[104, 105, 7], [112, 113, 15], [120, 121, 23]]); var outColdHeadAnim:Array<Int> = []; AnimTools.push(outColdHeadAnim, FlxG.random.int(27, 33), [outColdFrames[0]]); AnimTools.push(outColdHeadAnim, FlxG.random.int(10, 15), [outColdFrames[1]]); AnimTools.shift(outColdHeadAnim); _headSprite.animation.add("idle-outcold1", outColdHeadAnim, _FRAME_RATE); _bodySprite.animation.add("idle-outcold1", [outColdFrames[2]], _FRAME_RATE); } _headSprite.animation.add("outcold-cube", [12], _FRAME_RATE); _headSprite.animation.add("idle-vomit", [45, 46, 45, 46, 45, 47, 46, 45, 47, 46, 47, 45, 34, 35, 33, 2], _FRAME_RATE, false); _bodySprite.animation.add("idle-vomit", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("look-up", [77, 78, 79, 78, 79, 78, 79, 78, 77], _FRAME_RATE, false); _bodySprite.animation.add("look-up", [0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("tug-vgood", AnimTools.blinkyAnimation([107, 108]), _FRAME_RATE); _bodySprite.animation.add("tug-vgood", AnimTools.blinkyAnimation([85, 86, 87]), _FRAME_RATE); _headSprite.animation.add("tug-good", AnimTools.blinkyAnimation([98, 99]), _FRAME_RATE); _bodySprite.animation.add("tug-good", AnimTools.blinkyAnimation([85, 86, 87]), _FRAME_RATE); _headSprite.animation.add("tug-bad", AnimTools.blinkyAnimation([101, 102]), _FRAME_RATE); _bodySprite.animation.add("tug-bad", AnimTools.blinkyAnimation([93, 94, 95]), _FRAME_RATE); _headSprite.animation.add("tug-vbad", AnimTools.blinkyAnimation([109, 110, 111]), 12); _bodySprite.animation.add("tug-vbad", AnimTools.blinkyAnimation([101, 102, 103]), 12); // bob head around _headSprite.animation.add("idle-happy0", [92, 93, 92, 94, 92, 93, 92, 91, 90, 90, 88, 91, 91, 91, 90], _FRAME_RATE, false); _bodySprite.animation.add("idle-happy0", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-veryhappy0", [92, 93, 92, 94, 92, 93, 92, 94, 92, 93, 92, 94, 92, 91, 90, 90, 88, 91, 91, 91, 90], _FRAME_RATE, false); _bodySprite.animation.add("idle-veryhappy0", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); // quick bows _headSprite.animation.add("idle-happy1", [95, 95, 91, 95, 90, 91, 91, 88, 89, 88, 88, 90, 91, 90, 89], _FRAME_RATE, false); _bodySprite.animation.add("idle-happy1", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-veryhappy1", [95, 95, 91, 95, 90, 91, 95, 88, 95, 95, 88, 90, 91, 88, 89, 88, 88, 90, 91, 90, 89], _FRAME_RATE, false); _bodySprite.animation.add("idle-veryhappy1", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); // ear wiggle _headSprite.animation.add("idle-happy2", [96, 97, 96, 97, 96, 89, 90, 91, 88, 88, 89, 88, 90, 91, 88], _FRAME_RATE, false); _bodySprite.animation.add("idle-happy2", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); _headSprite.animation.add("idle-veryhappy2", [92, 93, 92, 96, 97, 96, 97, 96, 97, 96, 97, 96, 97, 89, 88, 88, 89, 88, 90, 91, 88], _FRAME_RATE, false); _bodySprite.animation.add("idle-veryhappy2", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _FRAME_RATE, false); SexyAnims.addAnims(this); { var jitteryHeadAnim:Array<Int> = []; AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); var jitteryBodyAnim:Array<Int> = []; AnimTools.push(jitteryBodyAnim, jitteryHeadAnim.length, [0]); _headSprite.animation.add("idle-jittery0", jitteryHeadAnim, _FRAME_RATE, false); _bodySprite.animation.add("idle-jittery0", jitteryBodyAnim, _FRAME_RATE, false); } { var jitteryHeadAnim:Array<Int> = []; AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(7, 10), [40, 41, 42]); AnimTools.push(jitteryHeadAnim, FlxG.random.int(3, 4), [43, 44]); var jitteryBodyAnim:Array<Int> = []; AnimTools.push(jitteryBodyAnim, jitteryHeadAnim.length, [0]); _headSprite.animation.add("idle-jittery1", jitteryHeadAnim, _FRAME_RATE, false); _bodySprite.animation.add("idle-jittery1", jitteryBodyAnim, _FRAME_RATE, false); } { var sleepAnim:Array<Int> = []; AnimTools.push(sleepAnim, FlxG.random.int(8, 10), [32, 33]); AnimTools.push(sleepAnim, FlxG.random.int(8, 10), [34, 35]); _headSprite.animation.add("idle-sleep", sleepAnim, _FRAME_RATE, true); _bodySprite.animation.add("idle-sleep", [0], _FRAME_RATE, true); _frontBodySprite.animation.add("idle-sleep", [24, 25, 26, 27, 28], _FRAME_RATE, true); } { var napHeadAnim:Array<Int> = []; AnimTools.push(napHeadAnim, FlxG.random.int(4, 5), [32, 33]); AnimTools.push(napHeadAnim, FlxG.random.int(8, 10), [34, 35]); AnimTools.push(napHeadAnim, FlxG.random.int(8, 10), [32, 33]); AnimTools.push(napHeadAnim, FlxG.random.int(8, 10), [34, 35]); AnimTools.push(napHeadAnim, FlxG.random.int(4, 5), [32, 33]); napHeadAnim.push(0); napHeadAnim.push(1); napHeadAnim.push(3); napHeadAnim.push(2); napHeadAnim.push(0); napHeadAnim.push(3); var napBodyAnim:Array<Int> = []; AnimTools.push(napBodyAnim, napHeadAnim.length, [0]); _headSprite.animation.add("idle-nap", napHeadAnim, _FRAME_RATE, false); _bodySprite.animation.add("idle-nap", napBodyAnim, _FRAME_RATE, false); } { var cubeAnim:Array<Int> = []; AnimTools.push(cubeAnim, FlxG.random.int(15, 21), [8, 9, 10]); _headSprite.animation.add("cube", cubeAnim, _FRAME_RATE); _headSprite.addBlinkableFrame(8, 11); _headSprite.addBlinkableFrame(9, 11); _headSprite.addBlinkableFrame(10, 11); _bodySprite.animation.add("cube", [2]); } } public function eventRunDirRadians(args:Array<Dynamic>) { var dx:Float = 100 * Math.cos(args[0]); var dy:Float = 100 * Math.sin(args[0]); runTo(_soulSprite.x + dx, _soulSprite.y + dy); } public function eventRunTo(args:Array<Dynamic>) { runTo(args[0], args[1]); } public function eventStop(args:Array<Dynamic>) { stop(); } public function isStopped() { return _targetSprite.x == _soulSprite.x && _targetSprite.y == _soulSprite.y && _runToCallback == null; } public function eventPlayAnim(args:Array<Dynamic>) { var animName:String = args[0]; var idle:Bool = args[1] == null ? false : args[1]; playAnim(animName, idle); } public function playAnim(animName:String, idle:Bool = false) { if (idle) { _bodySprite._idleTimer = CritterBody.IDLE_FREQUENCY * FlxG.random.float(0.9, 1.11); } if (StringTools.startsWith(animName, "complex-")) { if (_targetSprite.immovable) { // if we're in a box or something, don't run off } else { IdleAnims.playComplex(this, animName); } return; } if (animName == "idle-outcold0" && !canDie) { return; } _bodySprite.animation.play(animName, true); _headSprite.animation.play(animName, true); if (animName == "idle-vomit") { var vomitStamp:FlxSprite = new FlxSprite(0, 0); vomitStamp.setFacingFlip(FlxObject.LEFT, false, false); vomitStamp.setFacingFlip(FlxObject.RIGHT, true, false); vomitStamp.facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); vomitStamp.loadGraphic(AssetPaths.critter_vomit__png, true, 64, 64); vomitStamp.animation.frameIndex = FlxG.random.int(0, 2); _backdrop.stamp(vomitStamp, Std.int(_bodySprite.x - _bodySprite.offset.x + FlxG.random.int(-4, 4)), Std.int(_bodySprite.y - _bodySprite.offset.y + FlxG.random.int(-2, 2))); } if (animName.substr(0, 5) == "sexy-") { wasImmovableBeforeSexyAnim = _targetSprite.immovable; setImmovable(true); SexyAnims.scheduleJizzStamp(this); } if (animName == "idle-outcold0") { outCold = true; } if (_frontBodySprite.animation.getByName(animName) != null) { _headSprite.facing = _bodySprite.facing; _frontBodySprite.facing = _bodySprite.facing; if (animName == "idle-sleep") { // don't flip it _frontBodySprite.facing = FlxObject.LEFT; } _frontBodySprite.visible = true; _frontBodySprite.animation.play(animName, true); } else { _frontBodySprite.visible = false; } } public function eventJizzStamp(args:Array<Dynamic>):Void { var jizzX:Float = args[0]; var jizzY:Float = args[1]; jizzStamp(jizzX, jizzY); } public function jizzStamp(x:Float, y:Float) { var jizzStamp:FlxSprite = new FlxSprite(0, 0); jizzStamp.setFacingFlip(FlxObject.LEFT, false, false); jizzStamp.setFacingFlip(FlxObject.RIGHT, true, false); jizzStamp.facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); jizzStamp.loadGraphic(AssetPaths.critter_jizz__png, true, 64, 64); jizzStamp.animation.frameIndex = FlxG.random.int(0, 5); _backdrop.stamp(jizzStamp, Std.int(_bodySprite.x - _bodySprite.offset.x + x + FlxG.random.int(-2, 2)), Std.int(_bodySprite.y - _bodySprite.offset.y + FlxG.random.int(-1, 1) + y)); } /** * Don't worry, we're not actually destroying the bugs. We're just making * our computer forget about them for a little while so it can think about * other things. I'm sure the bugs are off happily running around on some * digital farm somewhere. */ public function destroy():Void { _targetSprite = FlxDestroyUtil.destroy(_targetSprite); _soulSprite = FlxDestroyUtil.destroy(_soulSprite); _bodySprite = FlxDestroyUtil.destroy(_bodySprite); _headSprite = FlxDestroyUtil.destroy(_headSprite); _frontBodySprite = FlxDestroyUtil.destroy(_frontBodySprite); _critterColor = null; _runToCallback = null; _tween0 = FlxTweenUtil.destroy(_tween0); _tween1 = FlxTweenUtil.destroy(_tween1); _tween2 = FlxTweenUtil.destroy(_tween2); _eventStack = null; _lastSexyAnim = null; } public function ungrab():Void { _bodySprite.facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); if (outCold) { if (_bodySprite.animation.curAnim.name == "idle-outcold0") { // dropped in a box; don't lay down in boxes. it looks silly } else { _bodySprite.animation.play("idle-outcold1"); _headSprite.animation.play("idle-outcold1"); } setImmovable(true); } else { _eventStack.reset(); _bodySprite.moving = false; _bodySprite.animation.play("idle"); _headSprite.animation.play("idle"); _bodySprite.movingPrefix = "run"; _bodySprite._walkSpeed = CritterBody.DEFAULT_WALK_SPEED; _bodySprite._jumpSpeed = CritterBody.DEFAULT_JUMP_SPEED; } _frontBodySprite.animation.play("idle"); } public function setIdle():Void { _bodySprite.animation.play("idle"); _headSprite.animation.play("idle"); _bodySprite.movingPrefix = "run"; resetFrontBodySprite(); } public function eventRecoverFromBadLanding(args:Array<Dynamic>):Void { if (_bodySprite.animation.name == "bad-landing-sw") { setIdle(); } } public function grab():Void { _eventStack.reset(); _runToCallback = null; setGrounded(); _bodySprite.moving = false; _bodySprite.animation.play("grab"); _headSprite.animation.play("grab"); resetFrontBodySprite(); setImmovable(false); } public function setImmovable(Immovable:Bool) { if (permanentlyImmovable && Immovable == false) { return; } _targetSprite.immovable = Immovable; } /** * Sets the bug into "cube mode", like when he's squished inside a clue box */ public function cube() { if (outCold) { _headSprite.animation.play("outcold-cube"); } else { _headSprite.animation.play("cube"); } _bodySprite.animation.play("cube"); resetFrontBodySprite(); setImmovable(true); // performance optimization: kill cubed critters setAlive(false); } /** * Takes the bug out of "cube mode", freeing him from a clue box */ public function uncube() { // performance optimization: revive cubed critters setAlive(true); if (outCold) { _bodySprite.animation.play("idle-outcold1"); _headSprite.animation.play("idle-outcold1"); } else { _bodySprite.animation.play("idle"); _headSprite.animation.play("idle"); _bodySprite.movingPrefix = "run"; } resetFrontBodySprite(); } public function setPosition(X:Float, Y:Float) { _targetSprite.setPosition(X, Y); _soulSprite.setPosition(X, Y); _bodySprite.setPosition(X, Y); _headSprite.moveHead(); _frontBodySprite.setPosition(X, Y); } /** * Adjust a critter's position and target by dx/dy. */ public function movePosition(dx:Float, dy:Float) { _targetSprite.x += dx; _targetSprite.y += dy; _soulSprite.x += dx; _soulSprite.y += dy; _bodySprite.x += dx; _bodySprite.y += dy; _frontBodySprite.x += dx; _frontBodySprite.y += dy; _headSprite.moveHead(); } /** * Reset a critter to being alive and in their default state */ public function reset() { outCold = false; setImmovable(false); setIdle(); _eventStack.reset(); _bodySprite.moving = false; setPosition(_soulSprite.x, _soulSprite.y); } /** * Inserts a waypoint which the critter will run to before their current destination */ public function insertWaypoint(x:Float, y:Float) { runTo(x, y, new RunToWaypoint(_targetSprite.x, _targetSprite.y, _runToCallback).reachedWaypoint); } public function runTo(targetX:Float, targetY:Float, ?RunToCallback:Critter->Void) { if (outCold) { // don't run; out cold return; } setGrounded(); // should we assign a moving animation? if (outCold) { // no; critter is out cold } else if (_bodySprite.animation != null && _bodySprite.animation.name.substr(0, 4) == "run-") { // no; critter is already running } else { _bodySprite.assignMovingAnim(_soulSprite.x, _soulSprite.y, targetX, targetY, "run"); } _targetSprite.setPosition(targetX, targetY); _bodySprite.moving = true; setImmovable(true); _runToCallback = RunToCallback; if (_soulSprite.getPosition().distanceTo(_targetSprite.getPosition()) <= 4) { // special case; told to run somewhere where we already are... _bodySprite.moving = false; setPosition(targetX, targetY); reachedDestination(); } } public function dropTo(X:Float, Y:Float, Z:Float, ?RunToCallback:Critter->Void) { z = Z; _targetSprite.setPosition(X, Y); _bodySprite.moving = true; var dist:Float = _bodySprite.getPosition().distanceTo(_targetSprite.getPosition()); var delay:Float = Math.sqrt(z) / 13 + 0.05; _tween1 = FlxTween.tween(this, { z : 1 }, delay / 2, { ease:FlxEase.quadIn }); _runToCallback = RunToCallback; if (outCold) { playAnim("idle-outcold1", false); } else { _bodySprite.assignMovingAnim(_bodySprite.x, _bodySprite.y, X, Y, "jump"); } } public function jumpTo(targetX:Float, targetY:Float, targetZ:Float, ?RunToCallback:Critter->Void) { if (outCold) { // don't jump; out cold return; } if (z == groundZ) { // enable mid-air flag z = groundZ + 1; } _targetSprite.setPosition(targetX, targetY); _bodySprite.moving = true; if (_soulSprite.getPosition().distanceTo(_targetSprite.getPosition()) > 4) { setImmovable(true); } var dist:Float = _bodySprite.getPosition().distanceTo(_targetSprite.getPosition()); var delay:Float = dist / _bodySprite._jumpSpeed; var height:Float = dist * dist / (_bodySprite._jumpSpeed * _bodySprite._jumpSpeed / 169); _tween0 = FlxTween.tween(this, { z : z / 2 + targetZ / 2 + height}, delay / 2, { ease:FlxEase.quadOut }); _tween1 = FlxTween.tween(this, { z : targetZ + 1 }, delay / 2, { startDelay:delay / 2, ease:FlxEase.quadIn }); if (z != targetZ) { _tween2 = FlxTween.tween(this, {groundZ : targetZ}, delay); targetGroundZ = targetZ; } _runToCallback = RunToCallback; _bodySprite.assignMovingAnim(_bodySprite.x, _bodySprite.y, targetX, targetY, "jump"); } public function updateMovingPrefix(prefix:String) { _bodySprite.assignMovingAnim(_bodySprite.x, _bodySprite.y, _targetSprite.x, _targetSprite.y, prefix); } public function isCubed():Bool { return _headSprite.animation.curAnim.name == "cube" || _headSprite.animation.curAnim.name == "outcold-cube"; } public function reachedDestination() { _bodySprite.setPosition(_targetSprite.x, _targetSprite.y); _headSprite.setPosition(_targetSprite.x, _targetSprite.y + 2); setImmovable(false); var wasMidAir:Bool = isMidAir(); if (wasMidAir) { _bodySprite._jumpSpeed = CritterBody.DEFAULT_JUMP_SPEED; } setGrounded(); if (!outCold) { if (_bodySprite.movingPrefix == "tumble") { _bodySprite.animation.play("bad-landing-sw"); _headSprite.animation.play("bad-landing-sw"); _eventStack.addEvent({time:_eventStack._time + 1.5, callback:eventRecoverFromBadLanding}); } else { _bodySprite.animation.play("idle"); _headSprite.animation.play("idle"); _bodySprite.movingPrefix = "run"; } } if (_runToCallback != null) { var tmpCallback:Critter->Void = _runToCallback; _runToCallback = null; tmpCallback(this); } if (wasMidAir) { if (_bodySprite.animation.name == "bad-landing-sw") { SoundStackingFix.play(AssetPaths.splat_00c6__mp3); } else { SoundStackingFix.play(AssetPaths.drop__mp3); } } } function setGrounded() { if (_tween0 != null) { _tween0.active = false; } if (_tween1 != null) { _tween1.active = false; } if (_tween2 != null) { _tween2.active = false; } groundZ = targetGroundZ; z = targetGroundZ; } public function setAlive(alive:Bool):Void { _bodySprite.alive = alive; _headSprite.alive = alive; _targetSprite.alive = alive; _soulSprite.alive = alive; } public function isMale():Bool { return CRITTER_GENDERS[myId % CRITTER_GENDERS.length] < _critterColor.malePercent; } public static function initialize(?whichCritters:Int = 0) { // reset static id; some code depends on static ids starting at 0 STATIC_ID = 0; CritterBody.IDLE_FREQUENCY = [0, 500, 290, 170, 100, 60, 35, 20][PlayerData.pegActivity]; CritterBody.IDLE_FREQUENCY = Math.min(CritterBody.IDLE_FREQUENCY, 500); CritterBody.IDLE_FREQUENCY = Math.max(CritterBody.IDLE_FREQUENCY, 20); LevelState.GLOBAL_IDLE_FREQUENCY = [0, 300, 200, 100, 60, 40, 30, 20][PlayerData.pegActivity]; LevelState.GLOBAL_SEXY_FREQUENCY = [0, 1213, 813, 513, 313, 213, 113, 13][PlayerData.pegActivity]; CritterBody.DEFAULT_WALK_SPEED = [0, 105, 115, 125, 135, 150, 165, 185][PlayerData.pegActivity]; CRITTER_GENDERS = []; for (i in 0...22) { CRITTER_GENDERS.push((i + 0.5) / 22); } FlxG.random.shuffle(CRITTER_GENDERS); CRITTER_COLORS = []; CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xffb23823, CCL_SKIN_SHADOW => 0xff9e301e, CCL_SKIN_LINE => 0xff8d2b1d, CCL_BELLY => 0xffc9442a, CCL_BELLY_SHADOW => 0xffad3726, CCL_BELLY_LINE => 0xff963027, CCL_EYES => 0xff282828, CCL_EYES_LINE => 0xff525050, CCL_EYES_SHINE => 0xffdedede, ], english:"red", englishBackup:FJ_RED_DK, malePercent:0.6 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xffeeda4d, CCL_SKIN_SHADOW => 0xffe8c640, CCL_SKIN_LINE => 0xffd2b137, CCL_BELLY => 0xfff7f0cc, CCL_BELLY_SHADOW => 0xfff1e398, CCL_BELLY_LINE => 0xffe3cd6d, CCL_EYES => 0xffc0992f, CCL_EYES_LINE => 0xffa27325, CCL_EYES_SHINE => 0xfff1e398, ], english:"yellow", englishBackup:FJ_YEL, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff41a740, CCL_SKIN_SHADOW => 0xff30942b, CCL_SKIN_LINE => 0xff22851d, CCL_BELLY => 0xff4fa94e, CCL_BELLY_SHADOW => 0xff3d9737, CCL_BELLY_LINE => 0xff2d8827, CCL_EYES => 0xffc09a2f, CCL_EYES_LINE => 0xffa27325, CCL_EYES_SHINE => 0xfff1e398, ], english:"green", englishBackup:FJ_GREN_DK, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xffb47922, CCL_SKIN_SHADOW => 0xff9f6621, CCL_SKIN_LINE => 0xff925621, CCL_BELLY => 0xffd0ec5c, CCL_BELLY_SHADOW => 0xffa8d359, CCL_BELLY_LINE => 0xff93a944, CCL_EYES => 0xff7d4c21, CCL_EYES_LINE => 0xff603e21, CCL_EYES_SHINE => 0xffe5cd7d, ], english:"brown", englishBackup:FJ_BRWN, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff6f83db, CCL_SKIN_SHADOW => 0xff6175c7, CCL_SKIN_LINE => 0xff5164b0, CCL_BELLY => 0xff92d8e5, CCL_BELLY_SHADOW => 0xff9acada, CCL_BELLY_LINE => 0xff72accf, CCL_EYES => 0xff374265, CCL_EYES_LINE => 0xff495788, CCL_EYES_SHINE => 0xffeaf2f4, ], english:"blue", englishBackup:FJ_BLUE_LT, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xffa854cb, CCL_SKIN_SHADOW => 0xff974ab8, CCL_SKIN_LINE => 0xff8641a5, CCL_BELLY => 0xffbb73dd, CCL_BELLY_SHADOW => 0xffa15cc9, CCL_BELLY_LINE => 0xff8e4bba, CCL_EYES => 0xff4fa94e, CCL_EYES_LINE => 0xff438b35, CCL_EYES_SHINE => 0xffdbe28e, ], english:"purple", englishBackup:FJ_PRPL, malePercent:0.4 }); if (whichCritters == LOAD_ALL || whichCritters == LOAD_DEFAULT && ItemDatabase.playerHasItem(ItemDatabase.ITEM_FRUIT_BUGS)) { CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xfff57e7d, CCL_SKIN_SHADOW => 0xffed6568, CCL_SKIN_LINE => 0xffd85650, CCL_BELLY => 0xfff57e7d, CCL_BELLY_SHADOW => 0xffed6568, CCL_BELLY_LINE => 0xffd85650, CCL_EYES => 0xff7ac252, CCL_EYES_LINE => 0xffb8db92, CCL_EYES_SHINE => 0xffe9f4dc, ], english:"red", englishBackup:FJ_RED_LT, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xfff9bb4a, CCL_SKIN_SHADOW => 0xfff9984b, CCL_SKIN_LINE => 0xffeb8844, CCL_BELLY => 0xfffff4b2, CCL_BELLY_SHADOW => 0xfffdd28b, CCL_BELLY_LINE => 0xffefae69, CCL_EYES => 0xfff9a74c, CCL_EYES_LINE => 0xfffee799, CCL_EYES_SHINE => 0xfffff6df, ], english:"orange", englishBackup:FJ_ORNG, malePercent:0.5 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff8fea40, CCL_SKIN_SHADOW => 0xff75d531, CCL_SKIN_LINE => 0xff72c72f, CCL_BELLY => 0xffe8fa95, CCL_BELLY_SHADOW => 0xffc4ee7a, CCL_BELLY_LINE => 0xff9ed84c, CCL_EYES => 0xfff5d561, CCL_EYES_LINE => 0xfff8ea9a, CCL_EYES_SHINE => 0xfffcf3cd, ], english:"green", englishBackup:FJ_GREN_LT, malePercent:0.5 }); } if (whichCritters == LOAD_ALL || whichCritters == LOAD_DEFAULT && ItemDatabase.playerHasItem(ItemDatabase.ITEM_MARSHMALLOW_BUGS)) { CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xfffeceef, CCL_SKIN_SHADOW => 0xfffbb9e2, CCL_SKIN_LINE => 0xfff5a8d5, CCL_BELLY => 0xffffeffc, CCL_BELLY_SHADOW => 0xfffcd2ed, CCL_BELLY_LINE => 0xfff3badb, CCL_EYES => 0xffffddf4, CCL_EYES_LINE => 0xfffff4fc, CCL_EYES_SHINE => 0xffffffff, ], english:"pink", englishBackup:FJ_PINK, malePercent:0.1 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xffb1edee, CCL_SKIN_SHADOW => 0xff9be5ec, CCL_SKIN_LINE => 0xff8cdee8, CCL_BELLY => 0xffdff2f0, CCL_BELLY_SHADOW => 0xffbcedf0, CCL_BELLY_LINE => 0xffa2e3eb, CCL_EYES => 0xffc1f1f2, CCL_EYES_LINE => 0xffe0f8f9, CCL_EYES_SHINE => 0xffffffff, ], english:"cyan", englishBackup:FJ_CYAN, malePercent:0.2 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xfff9f7d9, CCL_SKIN_SHADOW => 0xfff6ebbf, CCL_SKIN_LINE => 0xffefe0ae, CCL_BELLY => 0xfff9f7d9, CCL_BELLY_SHADOW => 0xfff6ebbf, CCL_BELLY_LINE => 0xffefe0ae, CCL_EYES => 0xff91e6ff, CCL_EYES_LINE => 0xffc2f1ff, CCL_EYES_SHINE => 0xffffffff, ], english:"white", englishBackup:FJ_WHIT, malePercent:0.3 }); } if (whichCritters == LOAD_ALL || whichCritters == LOAD_DEFAULT && ItemDatabase.playerHasItem(ItemDatabase.ITEM_SPOOKY_BUGS)) { CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff1a1a1e, CCL_SKIN_SHADOW => 0xff050507, CCL_SKIN_LINE => 0xff3c3c3d, CCL_BELLY => 0xff1a1a1e, CCL_BELLY_SHADOW => 0xff050507, CCL_BELLY_LINE => 0xff3c3c3d, CCL_EYES => 0xffb8260b, CCL_EYES_LINE => 0xff880606, CCL_EYES_SHINE => 0xfff45e40, ], english:"black", englishBackup:FJ_BLAK, malePercent:0.9 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff7a8289, CCL_SKIN_SHADOW => 0xff6b7279, CCL_SKIN_LINE => 0xff5c6169, CCL_BELLY => 0xff7a8289, CCL_BELLY_SHADOW => 0xff6b7279, CCL_BELLY_LINE => 0xff5c6169, CCL_EYES => 0xfff5f0d1, CCL_EYES_LINE => 0xffcdcab7, CCL_EYES_SHINE => 0xffffffff, ], english:"grey", englishBackup:FJ_GREY, malePercent:0.8 }); CRITTER_COLORS.push({tint:[ CCL_SKIN => 0xff0b45a6, CCL_SKIN_SHADOW => 0xff053691, CCL_SKIN_LINE => 0xff04277c, CCL_BELLY => 0xff0b45a6, CCL_BELLY_SHADOW => 0xff053691, CCL_BELLY_LINE => 0xff04277c, CCL_EYES => 0xfffad541, CCL_EYES_LINE => 0xfffdf7a9, CCL_EYES_SHINE => 0xffffffff, ], english:"blue", englishBackup:FJ_BLUE_DK, malePercent:0.7 }); } } /** * Each puzzle or minigame uses a subset of the available colors. This * function randomizes the colors we use. * * @param seed optional seed when consistent colors are needed */ public static function shuffleCritterColors(?seed:Null<Int>) { if (seed == null) { /* * These color arrangements are aesthetically pleasing, and include * things like blues and greys together, or primary colors. We try * to avoid giving the player combinations of colors which are * really ugly or frustratingly similar * * FJ_RED_DK, FJ_YEL, FJ_GREN_DK, FJ_BRWN, LIGHT_BLUE, FJ_PRPL, * FJ_RED_LT, FJ_ORNG, FJ_GREN_LT, * FJ_PINK, FJ_CYAN, FJ_WHIT, * FJ_BLAK, FJ_GREY, FJ_BLUE_DK, */ var COLOR_ARRANGEMENTS:Array<Array<String>> = [ // marshmallow arrangements [FJ_RED_DK, FJ_BLUE_LT, FJ_PRPL, FJ_PINK, FJ_CYAN, FJ_WHIT,], [FJ_YEL, FJ_GREN_DK, FJ_BLUE_LT, FJ_PRPL, FJ_CYAN, FJ_WHIT,], [FJ_RED_DK, FJ_YEL, FJ_GREN_DK, FJ_BRWN, FJ_PINK, FJ_CYAN,], // spooky arrangements [FJ_RED_DK, FJ_GREN_DK, FJ_BRWN, FJ_PRPL, FJ_BLAK, FJ_BLUE_DK,], [FJ_RED_DK, FJ_GREN_DK, FJ_BLUE_LT, FJ_PRPL, FJ_GREY, FJ_BLUE_DK,], [FJ_RED_DK, FJ_YEL, FJ_GREN_DK, FJ_BRWN, FJ_BLAK, FJ_GREY,], // fruity arrangements [FJ_YEL, FJ_BRWN, FJ_PRPL, FJ_RED_LT, FJ_ORNG, FJ_GREN_LT,], [FJ_YEL, FJ_GREN_DK, FJ_BLUE_LT, FJ_PRPL, FJ_RED_LT, FJ_ORNG,], [FJ_RED_DK, FJ_GREN_DK, FJ_BRWN, FJ_PRPL, FJ_ORNG, FJ_GREN_LT, ], // spectrums with two different bug packs... [FJ_YEL, FJ_RED_LT, FJ_ORNG, FJ_GREN_LT,FJ_PINK, FJ_CYAN, ], [FJ_YEL, FJ_GREN_DK, FJ_BRWN, FJ_ORNG, FJ_BLAK, FJ_BLUE_DK,], [FJ_RED_DK, FJ_YEL, FJ_BRWN, FJ_ORNG, FJ_BLAK, FJ_GREY,], [FJ_YEL, FJ_GREN_DK, FJ_BLUE_LT, FJ_GREN_LT, FJ_CYAN, FJ_WHIT,], [FJ_RED_DK, FJ_CYAN, FJ_WHIT, FJ_BLAK, FJ_GREY, FJ_BLUE_DK,], [FJ_PRPL, FJ_PINK, FJ_CYAN, FJ_WHIT, FJ_BLAK, FJ_BLUE_DK, ], // arrangements with three different bug packs... [FJ_RED_DK, FJ_YEL, FJ_BRWN, FJ_ORNG, FJ_GREN_LT,FJ_CYAN, ], [FJ_GREN_DK, FJ_PRPL,FJ_RED_LT, FJ_PINK, FJ_BLAK, FJ_BLUE_DK,], [FJ_BRWN, FJ_ORNG, FJ_CYAN, FJ_WHIT, FJ_BLAK, FJ_BLUE_DK,], [FJ_RED_DK, FJ_BLUE_LT, FJ_PRPL, FJ_PINK, FJ_CYAN, FJ_BLUE_DK,], [FJ_PRPL, FJ_ORNG, FJ_GREN_LT, FJ_CYAN, FJ_BLAK, FJ_GREY,], [FJ_GREN_DK, FJ_PRPL, FJ_RED_LT, FJ_CYAN, FJ_WHIT, FJ_BLUE_DK,], [FJ_YEL, FJ_BRWN, FJ_ORNG, FJ_WHIT, FJ_BLAK, FJ_GREY,], [FJ_YEL, FJ_GREN_DK, FJ_BLUE_LT, FJ_RED_LT, FJ_PINK, FJ_GREY,], [FJ_RED_DK, FJ_GREN_DK, FJ_RED_LT, FJ_GREN_LT, FJ_PINK, FJ_GREY,], ]; var colorArrangements:Array<Array<String>> = COLOR_ARRANGEMENTS.copy(); { var i = colorArrangements.length - 1; while (i >= 0) { for (englishBackup in colorArrangements[i]) { if (getColorFromBackupString(englishBackup) == null || PlayerData.disabledPegColors.indexOf(englishBackup) != -1) { // we're missing a color for this arrangement colorArrangements.remove(colorArrangements[i]); break; } } i--; } } BetterFlxRandom.shuffle(CRITTER_COLORS); // move disabled colors to end of the queue var i:Int = CRITTER_COLORS.length - 1; while (i >= 0) { var color:CritterColor = CRITTER_COLORS[i]; if (PlayerData.disabledPegColors.indexOf(color.englishBackup) != -1) { // color is disabled... move it to the end of CRITTER_COLORS CRITTER_COLORS.remove(color); CRITTER_COLORS.push(color); } i--; } // # of arrangements increases from 0 => 3 => 8 => 22, as player purchases bug packs var arrangementChance:Float = FlxMath.bound(8 * colorArrangements.length, 0, 80); if (colorArrangements.length >= 1 && FlxG.random.bool(arrangementChance)) { // pick a color arrangement var selectedArrangement:Array<String> = FlxG.random.getObject(colorArrangements).copy(); BetterFlxRandom.shuffle(selectedArrangement); for (englishBackup in selectedArrangement) { var color:CritterColor = getColorFromBackupString(englishBackup); CRITTER_COLORS.remove(color); CRITTER_COLORS.insert(0, color); } } } else { Puzzle.PUZZLE_RANDOM = new FlxRandom(seed); Puzzle.shuffle(CRITTER_COLORS); Puzzle.PUZZLE_RANDOM = FlxG.random; } } /** * Used during tutorials for commands such as %holopad-state-blue-0100% */ public static function getColorIndexFromString(fromStr:String):Int { for (i in 0...Critter.CRITTER_COLORS.length) { if (Critter.CRITTER_COLORS[i].english == fromStr) { return i; } } return -1; } static private function getColorFromBackupString(fromStr:String):CritterColor { for (critterColor in CRITTER_COLORS) { if (critterColor.englishBackup == fromStr) { return critterColor; } } return null; } public function neverIdle() { this._bodySprite._idleTimer = 9999999999; } public function getColorIndex():Int { return CRITTER_COLORS.indexOf(_critterColor); } public function isIdle() { if (_bodySprite.animation.name != "idle") { return false; } if (_targetSprite.immovable) { return false; } if (_eventStack._alive) { /* * This critter has events scheduled. Don't report this critter as * idle, or we might schedule conflicting events */ return false; } return true; } public function setFrontBodySpriteOffset(offset:Float) { _frontBodySpriteOffset = offset; _frontBodySprite.offset.set(14, _bodySpriteOffset + _frontBodySpriteOffset + z); } public function setBodySpriteOffset(offset:Float) { _bodySpriteOffset = offset; _bodySprite.offset.set(14, _bodySpriteOffset + z); _headSprite.offset.set(14, _bodySpriteOffset + z + 2); _frontBodySprite.offset.set(14, _bodySpriteOffset + _frontBodySpriteOffset + z); } public function resetFrontBodySprite() { if (_frontBodySprite.animation.name != "idle") { _frontBodySprite.animation.play("idle"); _frontBodySprite.visible = false; } if (_frontBodySpriteOffset != 4) { setFrontBodySpriteOffset(4); } if (_bodySpriteOffset != 39) { setBodySpriteOffset(39); } } public function isMidAir():Bool { return z != groundZ; } public function stop() { _targetSprite.x = _soulSprite.x; _targetSprite.y = _soulSprite.y; _bodySprite._walkSpeed = CritterBody.DEFAULT_WALK_SPEED; _bodySprite._jumpSpeed = CritterBody.DEFAULT_JUMP_SPEED; } public function toString() { return "Critter #" + myId + " (" + _critterColor.english + ")"; } } typedef CritterColor = { tint:Map<FlxColor, FlxColor>, malePercent:Float, english:String, englishBackup:String // if the english name is ambiguous, this specifies an alternate name } class RunToWaypoint { var x:Float; var y:Float; var callback:Critter->Void; public function new(x:Float, y:Float, callback:Critter->Void) { this.x = x; this.y = y; this.callback = callback; } public function reachedWaypoint(critter:Critter) { critter.runTo(x, y, callback); } }
argonvile/monster
source/critter/Critter.hx
hx
unknown
47,815
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRandom; import flixel.math.FlxVector; import flixel.util.FlxDestroyUtil; import kludge.BetterFlxRandom; /** * A bug is made of a head and body sprite which animate separately. * CritterBody encompasses the sprites and logic for a bug's body. */ class CritterBody extends FlxSprite { public static var DEFAULT_WALK_SPEED:Float = 130; public static var DEFAULT_JUMP_SPEED:Float = 130; public static var IDLE_FREQUENCY:Float = 100; private var _critter:Critter; public var _idleTimer:Float = FlxG.random.float(0, IDLE_FREQUENCY); public var _walkSpeed:Float = DEFAULT_WALK_SPEED; public var _jumpSpeed:Float = DEFAULT_JUMP_SPEED; public var movingPrefix:String = "run"; // "true" when we start moving; "false" once we reach our destination public var moving:Bool = false; public function new(critter:Critter) { super(); this._critter = critter; setFacingFlip(FlxObject.LEFT, false, false); setFacingFlip(FlxObject.RIGHT, true, false); facing = FlxG.random.getObject([FlxObject.LEFT, FlxObject.RIGHT]); } override public function update(elapsed:Float):Void { offset.set(14, _critter._bodySpriteOffset + _critter.z); if (_critter.shadow != null) { _critter.shadow.groundZ = _critter.groundZ; } var oldFrame:Int = animation.curAnim == null ? -1 : animation.curAnim.curFrame; super.update(elapsed); _critter._eventStack.update(elapsed); var dirVector:FlxVector = FlxVector.get(_critter._targetSprite.x - _critter._soulSprite.x, _critter._targetSprite.y - _critter._soulSprite.y); // seemingly redundant check, but it avoids a bug if elapsed is 0 var moveSpeed:Float = _critter.isMidAir() ? _jumpSpeed : _walkSpeed; if (dirVector.length == 0 || dirVector.length < moveSpeed * elapsed) { dirVector.set(0, 0); _critter._soulSprite.x = _critter._targetSprite.x; _critter._soulSprite.y = _critter._targetSprite.y; } else { dirVector.length = moveSpeed; moving = true; } _critter._soulSprite.velocity.x = dirVector.x; _critter._soulSprite.velocity.y = dirVector.y; if (animation.name == "idle" && !_critter._eventStack._alive && isOnScreen() && Critter.IDLE_ENABLED) { _idleTimer -= elapsed; if (_idleTimer <= 0) { var map:Map<String,Float> = new Map<String,Float>(); map["idle-itch0"] = 1; map["idle-itch1"] = 1; map["idle-shake"] = 1; map["idle-wobble"] = 1; map["idle-happy0"] = 0.1; map["idle-happy1"] = 0.1; map["idle-happy2"] = 0.1; map["idle-veryhappy0"] = 0.1; map["idle-veryhappy1"] = 0.1; map["idle-veryhappy2"] = 0.1; // disabling pokemon libido also disables sexy animations var sexyAnimationConstant:Float = [0, 0, 0.2, 0.4, 1.0, 2.3, 5.2, 12.0][PlayerData.pokemonLibido]; if (PlayerData.sfw) { // sfw mode; disable sexy animations sexyAnimationConstant = 0; } map["sexy-jackoff"] = 0.05 * sexyAnimationConstant; map["sexy-jackoff-short"] = 0.03 * sexyAnimationConstant; map["sexy-jackoff-long"] = 0.02 * sexyAnimationConstant; map["sexy-jackoff-dry"] = 0.01 * sexyAnimationConstant; // "complex" animations move a critter around; they're not suitable if they're in a box var annoyingAnimationConstant:Float = [0, 0, 0.25, 0.5, 1.0, 1.95, 3.10, 4.5][PlayerData.pegActivity]; if (_critter._targetSprite.immovable || _critter.idleMove == false) { annoyingAnimationConstant = 0; } map["complex-figure8"] = 0.35 * annoyingAnimationConstant; map["complex-incomplete-figure8"] = 0.35 * annoyingAnimationConstant; map["complex-amble"] = 0.35 * annoyingAnimationConstant; map["complex-chase-tail"] = 0.35 * annoyingAnimationConstant; map["complex-leave-and-return"] = 0.35 * annoyingAnimationConstant; map["complex-hop"] = 0.08 * annoyingAnimationConstant; map["idle-sleep"] = 0.2; map["idle-nap"] = 0.2; if (PlayerData.pegActivity == 7) { map["idle-sleep"] = 0.0002; map["idle-nap"] = 0.0002; map["idle-jittery0"] = 1.3; map["idle-jittery1"] = 2.7; map["idle-vomit"] = 0.5; } if (PlayerData.pegActivity == 6) { map["idle-sleep"] = 0.002; map["idle-nap"] = 0.002; map["idle-jittery0"] = 1.2; map["idle-jittery1"] = 1.3; map["idle-vomit"] = 0.1; } else if (PlayerData.pegActivity == 5) { map["idle-sleep"] = 0.02; map["idle-nap"] = 0.02; map["idle-jittery0"] = 1; map["idle-jittery1"] = 0.5; } else if (PlayerData.pegActivity == 4) { // default } else if (PlayerData.pegActivity == 3) { map["idle-sleep"] = 0.5; map["idle-nap"] = 0.5; map["idle-yawn0"] = 1.3; map["idle-yawn1"] = 0.7; } else if (PlayerData.pegActivity == 2) { map["idle-sleep"] = 1; map["idle-nap"] = 1; map["idle-yawn0"] = 1.5; map["idle-yawn1"] = 1.5; if (PlayerData.isPlayerDoingStuff()) { /* * Bugs will start passing out -- but, only if the * player's actually using the mouse. Without this * check, the game got sort of depressing if the player * stepped away for a 30 minute break */ map["idle-outcold0"] = 0.3; } } else if (PlayerData.pegActivity == 1) { map["idle-sleep"] = 2; map["idle-nap"] = 2; map["idle-yawn0"] = 3.4; map["idle-yawn1"] = 1.6; if (PlayerData.isPlayerDoingStuff()) { map["idle-outcold0"] = 1.5; } } _critter.playAnim(BetterFlxRandom.getObjectWithMap(map), true); } } if (animation.finished) { if (animation.name.substr(0, 5) == "sexy-") { _critter.setImmovable(_critter.wasImmovableBeforeSexyAnim); } if (animation.name.substr(0, 5) == "grab-") { animation.play("grab"); } else { animation.play("idle"); _critter._headSprite.animation.play("idle"); _critter.resetFrontBodySprite(); } } if (animation.name == "cube" || animation.name == "grab") { // don't run if we're immobile } else if (_critter.outCold && !_critter.isMidAir()) { // don't run if we're out cold... unless we're airborne, maybe someone's tossing a corpse } else { // maybe we should run? if (animation.curAnim != null && (animation.curAnim.curFrame != oldFrame || animation.curAnim.numFrames == 1 || _critter.isMidAir())) { // update graphics... var oldPosition:FlxPoint = getPosition(); setPosition(_critter._soulSprite.x, _critter._soulSprite.y); var movementDir:FlxVector; if (_critter.isMidAir()) { movementDir = FlxVector.get(_critter._targetSprite.x - oldPosition.x, _critter._targetSprite.y - oldPosition.y); } else { movementDir = FlxVector.get(x - oldPosition.x, y - oldPosition.y); } if (movementDir.length > 1) { // moving; assign moving animation if (!_critter.outCold) { assignMovingAnim(0, 0, movementDir.x, movementDir.y, null); } } else { // sitting still; assign idle animation if (animation.name.substr(0, 4) == "run-" || animation.name.substr(0, 5) == "jump-" || animation.name.substr(0, 7) == "tumble-") { // should become idle animation.play("idle"); _critter._headSprite.animation.play("idle"); } } // did we reach our destination? if (!moving) { // well; we already reached our destination before } else if (getPosition().distanceTo(_critter._targetSprite.getPosition()) >= 1) { // no; we're still too far away } else if (animation.name.substr(0, 4) == "run-" || animation.name.substr(0, 5) == "jump-" || animation.name.substr(0, 7) == "tumble-" || animation.name.substr(0, 7) == "idle") { moving = false; _critter.reachedDestination(); if (!exists) return; // reaching a destination can kill us; return to avoid NPEs } } } if (animation.name == "grab") { facing = FlxObject.LEFT; } _critter._headSprite.moveHead(); _critter._frontBodySprite.x = x; _critter._frontBodySprite.y = y + _critter._frontBodySpriteOffset; _critter._frontBodySprite.offset.y = _critter._bodySpriteOffset + _critter._frontBodySpriteOffset + _critter.z; } public function assignMovingAnim(oldX:Float, oldY:Float, newX:Float, newY:Float, prefix:String):Void { if (prefix != null) { this.movingPrefix = prefix; } // should run var dir:String; if (newY >= oldY) { if (newX == 0 || Math.abs((newY - oldY) / (newX - oldX)) > 2) { dir = "s"; } else { dir = "sw"; } } else { if (newX == 0 || Math.abs((newY - oldY) / (newX - oldX)) > 2) { dir = "n"; } else { dir = "nw"; } } var animName:String = movingPrefix + "-" + dir; animation.play(animName, animName != animation.name); _critter._headSprite.animation.play(animName); _critter.resetFrontBodySprite(); if (newX > oldX) { facing = FlxObject.RIGHT; } else if (newX < oldX) { facing = FlxObject.LEFT; } _critter._headSprite.facing = facing; } override public function destroy():Void { super.destroy(); _critter = null; movingPrefix = null; } }
argonvile/monster
source/critter/CritterBody.hx
hx
unknown
9,625
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.math.FlxRandom; /** * A bug is made of a head and body sprite which animate separately. * CritterHead encompasses the sprites and logic for a bug's head. */ class CritterHead extends FlxSprite { // frames where the head goes behind the body private static var aboveFrames:Array<Bool> = [ // 0...7 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, // 40...47 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, // 80...87 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, // 120...127 true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, ]; private var _blinkFrames:Map<Int, Int>; private var _critter:Critter; private var _blinkElapsed:Float; public function new(critter:Critter) { super(critter._bodySprite.x, critter._bodySprite.y); this._critter = critter; this._blinkElapsed = FlxG.random.float(2, 5); _blinkFrames = new Map<Int, Int>(); setFacingFlip(FlxObject.LEFT, false, false); setFacingFlip(FlxObject.RIGHT, true, false); } public function moveHead():Void { x = _critter._bodySprite.x; if (aboveFrames[animation.frameIndex]) { y = _critter._bodySprite.y - 2; offset.set(14, _critter._bodySpriteOffset - 2 + _critter.z); } else { y = _critter._bodySprite.y + 2; offset.set(14, _critter._bodySpriteOffset + 2 + _critter.z); } facing = _critter._bodySprite.facing; } override public function update(elapsed:Float):Void { if (_critter.isCubed()) { moveHead(); } var oldFrameIndex:Int = animation.frameIndex; super.update(elapsed); if (_blinkFrames.exists(animation.frameIndex)) { _blinkElapsed -= elapsed; if (_blinkElapsed <= 0 && oldFrameIndex != animation.frameIndex) { animation.frameIndex = _blinkFrames.get(animation.frameIndex); _blinkElapsed = FlxG.random.float(2, 5); } } } override public function destroy():Void { super.destroy(); _blinkFrames = null; _critter = null; } public function addBlinkableFrame(Frame:Int, BlinkFrame:Int) { _blinkFrames.set(Frame, BlinkFrame); } }
argonvile/monster
source/critter/CritterHead.hx
hx
unknown
3,032
package critter; import critter.Critter; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; /** * An object which contains a set of bugs. This can be a clue box or a platform * for one of the minigames */ class CritterHolder implements IFlxDestroyable { public var _sprite:FlxSprite; public var _critters:Array<Critter> = []; private var _holderPos:FlxPoint; private var _critterPos:FlxPoint; public function new(X:Float, Y:Float) { _sprite = new FlxSprite(X, Y); } public function holdCritter(critter:Critter) { _critters.push(critter); leash(critter, true); } public function leashAll(hard:Bool = false):Void { for (critter in _critters) { if (critter.isCubed()) { // don't leash cubed critters } else { leash(critter, hard); } } } /** * Constrain a bug into an elliptical shape * * @param critter The bug to contain * @param hard true if the bug should be abruptly snapped into place. * this is only used for subclasses, where the bugs have more * freedom */ public function leash(critter:Critter, hard:Bool = false) { critter.setPosition(_sprite.x, _sprite.y + 1); critter.setImmovable(true); return; } public function removeCritter(critter:Critter):Bool { if (_critters.indexOf(critter) == -1) { return false; } _critters.remove(critter); return true; } public function addCritter(critter:Critter):Bool { if (_critters.indexOf(critter) != -1) { return false; } _critters.push(critter); return true; } public function getCritters():Array<Critter> { return _critters; } public function getSprite():FlxSprite { return _sprite; } public function destroy() { _sprite = FlxDestroyUtil.destroy(_sprite); _critters = null; _holderPos = FlxDestroyUtil.put(_holderPos); _critterPos = FlxDestroyUtil.put(_critterPos); } }
argonvile/monster
source/critter/CritterHolder.hx
hx
unknown
2,076
package critter; import critter.Critter; import flixel.FlxG; /* * A large elliptical container which can hold multiple bugs, such as for easy * puzzles or for the scale game */ class EllipseCritterHolder extends CritterHolder { public var _leashRadiusX:Float = 0; public var _leashRadiusY:Float = 0; public var _leashOffsetY:Float = 0; public function new(X:Float, Y:Float) { super(X, Y); } /** * Constrain a bug into an elliptical shape * * @param critter The bug to contain * @param hard true if the bug should be abruptly snapped into place */ override public function leash(critter:Critter, hard:Bool = false) { _holderPos = _sprite.getPosition(_holderPos); _holderPos.x += _sprite.width / 2 - critter._targetSprite.width / 2 + 1; _holderPos.y += _sprite.height / 2 - critter._targetSprite.height / 2 + 2; _holderPos.y += _leashOffsetY; _critterPos = critter._targetSprite.getPosition(_critterPos); var dx = _critterPos.x - _holderPos.x; var dy = _critterPos.y - _holderPos.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist == 0) { critter.setPosition(_holderPos.x, _holderPos.y + 1); return; } var radius:Float = Math.sqrt((dx * dx) / (_leashRadiusX * _leashRadiusX) + (dy * dy) / (_leashRadiusY * _leashRadiusY)); if (radius <= 1) { // already inside ellipse return; } critter.setIdle(); critter._eventStack.reset(); if (hard) { critter.setPosition(dx / (radius * 1.05) + _holderPos.x, dy / (radius * 1.05) + _holderPos.y); } else { critter.runTo((_holderPos.x + _critterPos.x) / 2 + FlxG.random.float(-2, 2), (_holderPos.y + _critterPos.y) / 2 + FlxG.random.float(-2, 2)); } } }
argonvile/monster
source/critter/EllipseCritterHolder.hx
hx
unknown
1,741
package critter; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import kludge.BetterFlxRandom; import puzzle.PuzzleState; /** * Complex idle animations for bugs. This includes animations where one bug * does a few things in a row, and animations with multiple bugs */ class IdleAnims { public function new() { } public static function playComplex(critter:Critter, animName:String) { var targetSprite:FlxSprite = critter._targetSprite; var soulSprite:FlxSprite = critter._soulSprite; var bodySprite:CritterBody = critter._bodySprite; var eventStack:EventStack = critter._eventStack; bodySprite._idleTimer = CritterBody.IDLE_FREQUENCY * FlxG.random.float(0.9, 1.11); if (animName == "complex-figure8") { eventStack.reset(); var direction:Float = FlxG.random.float(0, 2 * Math.PI); var duration:Float = FlxG.random.float(4, 8); var granularity:Float = 0.25; var time:Float = 0; while (time < duration) { eventStack.addEvent({time:time, callback:critter.eventRunDirRadians, args:[direction]}); time += granularity; if (time < duration / 2) { direction += (granularity / duration) * 2 * 2 * Math.PI; } else { direction -= (granularity / duration) * 2 * 2 * Math.PI; } } eventStack.addEvent({time:time, callback:critter.eventStop}); return; } if (animName == "complex-incomplete-figure8") { eventStack.reset(); var direction:Float = FlxG.random.float(0, 2 * Math.PI); var duration:Float = FlxG.random.float(4, 8); var granularity:Float = 0.25; var time:Float = 0; var f:Float = FlxG.random.float(0.4, 1.0); while (time < duration * f) { eventStack.addEvent({time:time, callback:critter.eventRunDirRadians, args:[direction]}); time += granularity; if (time < duration / 2) { direction += (granularity / duration) * 2 * 2 * Math.PI; } else { direction -= (granularity / duration) * 2 * 2 * Math.PI; } } eventStack.addEvent({time:time, callback:critter.eventStop}); return; } if (animName == "complex-chase-tail") { eventStack.reset(); var direction:Float = FlxG.random.float(0, 2 * Math.PI); var duration:Float = FlxG.random.float(6, 12); var granularity:Float = 0.23; var time:Float = 0; var circleDirection:Float = FlxG.random.float(1.4, 1.8) * FlxG.random.sign(); while (time < duration) { eventStack.addEvent({time:time, callback:critter.eventRunDirRadians, args:[direction]}); time += granularity; direction += granularity * circleDirection * Math.PI * FlxG.random.float(0.5, 1.5); } eventStack.addEvent({time:time, callback:critter.eventStop}); return; } if (animName == "complex-amble") { eventStack.reset(); var direction:Float = FlxG.random.float(0, 2 * Math.PI); var duration:Float = FlxG.random.float(4, 8); var granularity:Float = 0.15; var time:Float = 0; bodySprite._walkSpeed = 85; var mystery0:Float = FlxG.random.float(0.5, 1.5); var mystery1:Float = FlxG.random.float(0.5, 1.5); while (time < duration) { eventStack.addEvent({time:time, callback:critter.eventRunDirRadians, args:[direction]}); time += granularity; if (time % 2 < mystery1) { direction += granularity * Math.PI * mystery0; } else { direction -= granularity * Math.PI * mystery0; } } eventStack.addEvent({time:time, callback:critter.eventStop}); return; } if (animName == "complex-leave-and-return") { var direction:Float = FlxG.random.float(0, 2 * Math.PI); var dx:Float = 40 * Math.cos(direction); var dy:Float = 40 * Math.sin(direction); targetSprite.x = soulSprite.x; targetSprite.y = soulSprite.y; while (targetSprite.x >= -80 && targetSprite.y <= FlxG.width + 80 && targetSprite.y >= -80 && targetSprite.y <= FlxG.height + 80) { targetSprite.x += dx; targetSprite.y += dy; } eventStack.reset(); var projectedTime:Float = getProjectedTime(critter, targetSprite.getPosition(), soulSprite.getPosition()); var time:Float = 0; eventStack.addEvent({time:0, callback:critter.eventRunTo, args:[targetSprite.x, targetSprite.y]}); time += projectedTime + 0.5; time += FlxG.random.bool() ? FlxG.random.float(10, 20) : FlxG.random.float(40, 80); eventStack.addEvent({time:time, callback:critter.eventRunTo, args:[soulSprite.x, soulSprite.y]}); time += projectedTime + 0.5; eventStack.addEvent({time:time, callback:critter.eventStop}); } if (animName == "complex-hop") { var duration:Float = FlxG.random.float(3, 5); eventStack.reset(); eventStack.addEvent({time:FlxG.random.float(0, 0.6), callback:eventHopContinuously, args:[critter]}); eventStack.addEvent({time:duration, callback:eventStopHopping, args:[critter]}); } } public static function eventHopContinuously(args:Array<Dynamic>) { var critter:Critter = args[0]; creventHopContinuously(critter); } public static function creventHopContinuously(critter:Critter) { var direction:Float = FlxG.random.float(0, 2 * Math.PI); var dist:Float = FlxG.random.float(20, 80); var dx:Float = dist * Math.cos(direction); var dy:Float = dist * Math.sin(direction); critter.jumpTo(critter._soulSprite.x + dx, critter._soulSprite.y + dy, 0, creventHopContinuously); } public static function eventStopHopping(args:Array<Dynamic>) { var critter:Critter = args[0]; critter._runToCallback = creventStopHopping; } public static function creventStopHopping(critter:Critter) { critter.playAnim(FlxG.random.getObject(["idle-happy0", "idle-happy1", "idle-happy2"])); } public static function getProjectedTime(critter:Critter, from:FlxPoint, to:FlxPoint) { return from.distanceTo(to) / critter._bodySprite._walkSpeed; } public static function playGlobalAnim(puzzleState:PuzzleState, animName:String) { puzzleState._globalIdleTimer = LevelState.GLOBAL_IDLE_FREQUENCY * FlxG.random.float(0.9, 1.11); if (animName == "global-enter") { // find an offscreen critter var critter:Critter = puzzleState.findExtraCritter(); if (critter == null) { // nothing left... unlikely but possible return; } // upper left: [8, 36] var x:Float = FlxG.random.float(8, FlxG.width - 48); var y:Float = FlxG.random.float(36, FlxG.height - 24); critter.runTo(x, y); } if (animName == "global-leave") { var critter:Critter = puzzleState.findIdleCritter(); if (critter == null) { return; } var direction:Float = FlxG.random.float(0, 2 * Math.PI); var dx:Float = 40 * Math.cos(direction); var dy:Float = 40 * Math.sin(direction); critter._targetSprite.x = critter._soulSprite.x; critter._targetSprite.y = critter._soulSprite.y; while (critter._targetSprite.x >= -80 && critter._targetSprite.x <= FlxG.width + 80 && critter._targetSprite.y >= -80 && critter._targetSprite.y <= FlxG.height + 80) { critter._targetSprite.x += dx; critter._targetSprite.y += dy; } critter.runTo(critter._targetSprite.x, critter._targetSprite.y); return; } if (animName == "global-leave-many") { var idleCritterCount = puzzleState.getIdleCritterCount(); var critters:Array<Critter> = puzzleState.findIdleCritters(Math.round(idleCritterCount * FlxG.random.float(0.26, 0.4))); FlxG.random.shuffle(critters); if (critters.length == 0) { return; } var dx:Float = 0; var dy:Float = 0; for (i in 1...critters.length) { dx += (critters[0]._soulSprite.x - critters[i]._soulSprite.x); dy += (critters[0]._soulSprite.y - critters[i]._soulSprite.y); } var maxProjectedTime:Float = 0; for (i in 1...critters.length) { maxProjectedTime = Math.max(maxProjectedTime, getProjectedTime(critters[i], critters[i]._soulSprite.getPosition(), critters[0]._soulSprite.getPosition())); } if (dx == 0 && dy == 0) { dx = FlxG.random.float(0.1, 1.0) * FlxG.random.sign(); dy = FlxG.random.float(0.1, 1.0) * FlxG.random.sign(); } var dMagnitude:Float = Math.sqrt(dx * dx + dy * dy); dx = 100 / dMagnitude; dy = 100 / dMagnitude; var offscreenPoint:FlxPoint = critters[0]._soulSprite.getPosition(); while (offscreenPoint.x >= -80 && offscreenPoint.x <= FlxG.width + 80 && offscreenPoint.y >= -80 && offscreenPoint.y <= FlxG.height + 80) { offscreenPoint.x += dx; offscreenPoint.y += dy; } var projectedTime1:Float = getProjectedTime(critters[0], critters[0]._soulSprite.getPosition(), offscreenPoint); for (i in 1...critters.length) { critters[i]._eventStack.reset(); var dest:FlxPoint = critters[0]._soulSprite.getPosition(); dest.x += FlxG.random.float( -60, 60); dest.y += FlxG.random.float( -30, 30); var projectedTime0:Float = getProjectedTime(critters[i], critters[i]._soulSprite.getPosition(), dest); critters[i]._eventStack.addEvent({time:maxProjectedTime - projectedTime0, callback:critters[i].eventRunTo, args:[dest.x, dest.y]}); } for (i in 0...critters.length) { critters[i]._eventStack.addEvent({time:maxProjectedTime, callback:critters[i].eventRunTo, args:[offscreenPoint.x + FlxG.random.float( -40, 40), offscreenPoint.y + FlxG.random.float( -20, 20)]}); critters[i]._eventStack.addEvent({time:maxProjectedTime + projectedTime1, callback:critters[i].eventStop}); } } if (animName == "global-enter-many") { var critters:Array<Critter> = puzzleState.findIdleCritters(FlxG.random.int(1, 3)); FlxG.random.shuffle(critters); var extraCritters:Array<Critter> = puzzleState.findExtraCritters(FlxG.random.int(1, 4)); critters = critters.concat(extraCritters); for (i in 1...critters.length) { var dest:FlxPoint = critters[0]._soulSprite.getPosition(); dest.x += FlxG.random.float( -60, 60); dest.y += FlxG.random.float( -30, 30); var projectedTime0:Float = getProjectedTime(critters[i], critters[i]._soulSprite.getPosition(), dest); var start:Float = FlxG.random.float(0, 1); critters[i]._eventStack.reset(); critters[i]._eventStack.addEvent({time:start, callback:critters[i].eventRunTo, args:[dest.x, dest.y]}); critters[i]._eventStack.addEvent({time:start + projectedTime0, callback:critters[i].eventStop}); } } } }
argonvile/monster
source/critter/IdleAnims.hx
hx
unknown
10,546
package critter; import critter.Critter; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.math.FlxRandom; import flixel.util.FlxDestroyUtil; import kludge.BetterFlxRandom; import puzzle.PuzzleState; /** * The bug which runs out during a puzzle and gives the player a random chest. * * This controls logic to decide when he should run out, where he should run * to, and logic for carrying/dropping a chest. */ class RewardCritter extends Critter { private var _puzzleState:PuzzleState; public var _rewardTimer:Float = 0; private var _antsyTimer:Float = FlxG.random.float(2, 6); private var _timeBetweenRewards = 150; private var _triedToPayAllChests:Bool = false; public function new(puzzleState:PuzzleState) { super(FlxG.random.int( -40 + 100, FlxG.width - 100), -70, puzzleState._backdrop); this._puzzleState = puzzleState; setColor(Critter.CRITTER_COLORS[FlxG.random.int(0, _puzzleState._puzzle._colorCount - 1)]); // if he idles, he can do crazy things like die and stay offscreen forever neverIdle(); _rewardTimer = [ PlayerData.Difficulty.Easy => 45, PlayerData.Difficulty._3Peg => 75, PlayerData.Difficulty._4Peg => 105, PlayerData.Difficulty._5Peg => 135, PlayerData.Difficulty._7Peg => 165 ][PlayerData.difficulty]; } public function update(elapsed:Float) { if (_targetSprite.y > -70 && _targetSprite.y < FlxG.height + 100 && _puzzleState.getCarriedChest(this) == null) { goAway(); } if (_puzzleState._gameState == 200 && FlxMath.distanceBetween(_soulSprite, _targetSprite) < 1 && _puzzleState.getCarriedChest(this) == null) { _rewardTimer -= elapsed; if (_rewardTimer < 0) { _puzzleState.addAllowedHint(); var rewardQuantity:Int = FlxG.random.getObject([0, 1, 2], [4, 2, 1]); // 0: one 1: half 2: all var carriedChest:Chest = _puzzleState.addChest(); if (rewardQuantity == 0) { carriedChest.setReward(popReward(1)); } else if (rewardQuantity == 1) { carriedChest.setReward(popReward(Std.int(Math.ceil(PlayerData.critterBonus.length / 2)))); } else { carriedChest.setReward(popReward(PlayerData.critterBonus.length)); } carriedChest._critter = this; // update position and animation frame to match critter carriedChest.update(elapsed); } } if (_puzzleState._gameState == 200 && FlxMath.distanceBetween(_soulSprite, _targetSprite) < 1 && _puzzleState.getCarriedChest(this) != null) { if (_rewardTimer < 0) { _antsyTimer -= elapsed; if (_antsyTimer < 0) { comeToCenter(); _antsyTimer = FlxG.random.float(2, 6); } } } if (_puzzleState._gameState >= 300 && FlxMath.distanceBetween(_soulSprite, _targetSprite) < 1) { var runningOnscreen:Bool = _targetSprite.y >= 0 && _targetSprite.y < FlxG.height; if (runningOnscreen) { // reached the "dropping off a chest" spot var carriedChest:Chest = _puzzleState.getCarriedChest(this); if (carriedChest != null) { dropChest(carriedChest); goAway(); } } else { if (!_triedToPayAllChests) { _triedToPayAllChests = true; _puzzleState.maybePayAllChests(); } } } } /** * Remove some $$$ from the player's critterBonus, so they can be put in a chest */ function popReward(count:Int) { var sum = 0; for (i in 0...count) { if (PlayerData.critterBonus.length > 0) { sum += PlayerData.critterBonus.splice(FlxG.random.int(0, PlayerData.critterBonus.length - 1), 1)[0]; } } sum = Std.int(Math.max(sum, 5)); // more than 1,000 at once is silly, and makes the money counter go nuts if (sum > 1000) { PlayerData.reimburseCritterBonus(sum - 1000); sum = 1000; } return sum; } public function comeToCenter():Void { if (!_bodySprite.isOnScreen()) { changeColor(); } _rewardTimer = Math.min(_rewardTimer, 0); _antsyTimer = Math.min(_antsyTimer, 0); runTo(FlxG.random.int(256 + 4, 512 - 4 - 40), FlxG.random.int(30 + 24 + 24 * _puzzleState._puzzle._pegCount, 380 - 16)); } public function immediatelySpawnIdleReward():Void { _rewardTimer = Math.min(_rewardTimer, 0); _antsyTimer = Math.min(_antsyTimer, 0); } public function goAway():Void { if (_rewardTimer < 0) { _rewardTimer = 150; } var y:Float; if (_targetSprite.y > FlxG.height / 2 || _puzzleState._gameState == 300) { y = FlxG.height + 100; } else { y = -70; } runTo(FlxG.random.int( -40 + 100, FlxG.width - 100), y); } /** * If you thought it was a whole bunch of bugs taking turns bringing you * chests, surprise! It's just a very talented chameleon bug * * You should think yourself lucky Abra never included these chameleon bugs * in puzzles... */ private function changeColor():Void { setColor(Critter.CRITTER_COLORS[FlxG.random.int(0, _puzzleState._puzzle._colorCount - 1)]); } public function dropChest(chest:Chest):Void { chest.dropChest(); _puzzleState._shadowGroup.makeShadow(chest._chestSprite); } /** * Reimburse the player for a chest they didn't open */ public function reimburseChestReward():Void { var chest:Chest = _puzzleState.getCarriedChest(this); if (_puzzleState._gameState == 200 && chest != null) { PlayerData.reimburseCritterBonus(chest._reward); } } }
argonvile/monster
source/critter/RewardCritter.hx
hx
unknown
5,551
package critter; import critter.Critter; import flixel.FlxG; import flixel.FlxObject; import flixel.math.FlxPoint; import kludge.BetterFlxRandom; /** * The bugs in the game have different sexual animations they can do. Some of * these animations are complex and include things like a critter waggling his * rump alluringly; several critters racing into position, and taking turns * fucking him * * This class includes all of the logic for the sexy bug activities */ class SexyAnims { /* * When two bugs start having sex, they're linked -- picking up one bug * will interrupt the other. * * This is important, otherwise you might absent-mindedly be solving a * puzzle and you notice another bug having sex with the air. */ public static var critterLinks:Map<Critter, Array<Critter>> = new Map<Critter, Array<Critter>>(); public function new() { } public static function addAnims(critter:Critter) { { var animName:String = "sexy-jackoff"; if (critter.isMale()) { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, 49, 48, 48, 48, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, 35, 36, 37, 2, 2, 34, 35, 36, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } else { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, 49, 48, 48, 48, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 38, 39, 2, 2, 30, 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } } { var animName:String = "sexy-jackoff-short"; if (critter.isMale()) { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 51, 50, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 49, 50, 48, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 33, 33, 32, 32, 33, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, 35, 36, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } else { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 51, 50, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 49, 50, 48, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 31, 31, 32, 32, 31, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 32, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } } { var animName:String = "sexy-jackoff-long"; if (critter.isMale()) { critter._headSprite.animation.add(animName, [ 48, 48, 49, 49, 49, 49, 49, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 48, 48, 49, 49, 48, 49, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 51, 51, 51, 51, 50, 51, 51, 50, 51, 51, 51, 51, 48, 49, 49, 49, 49, 48, 49, 48, 48, 48, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 48, 49, 49, 49, 49, 49, 48, 49, 48, 48, 49, 48, 48, 50, 51, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 49, 49, 49, 48, 49, 48, 49, 49, 49, 49, 49, 48, 48, 49, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 49, 49, 49, 49, 48, 49, 50, 51, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 32, 33, 32, 33, 32, // fast... 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 32, 33, 32, 33, 32, // fast... 33, 32, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 32, 33, 32, 33, 32, // fast... 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 32, 32, 33, 33, // cum... 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, 35, 36, 37, 2, 34, 35, 36, 37, 2, 34, 35, 36, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } else { critter._headSprite.animation.add(animName, [ 48, 48, 49, 49, 49, 49, 49, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 48, 48, 49, 49, 48, 49, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 51, 51, 51, 51, 50, 51, 51, 50, 51, 51, 51, 51, 48, 49, 49, 49, 48, 48, 49, 49, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 48, 49, 49, 49, 49, 49, 48, 49, 48, 48, 49, 48, 48, 50, 51, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 49, 49, 49, 48, 49, 48, 49, 49, 49, 49, 49, 48, 48, 49, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 49, 49, 49, 49, 48, 49, 50, 51, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 50, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 32, 31, 32, 31, 32, // fast... 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 32, 31, 32, 31, 32, // fast... 31, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 32, 31, 32, 31, 32, // fast... 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 32, 31, 32, 32, 31, 31, // cum... 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 38, 39, 2, 30, 38, 39, 2, 2, 30, 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } } { var animName:String = "sexy-jackoff-dry"; if (critter.isMale()) { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, 49, 48, 48, 48, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } else { critter._headSprite.animation.add(animName, [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, 49, 48, 48, 48, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, ], Critter._FRAME_RATE, false); critter._bodySprite.animation.add(animName, [ 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add(animName, [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, true); } } } public static function scheduleJizzStamp(critter:Critter) { var animName:String = critter._bodySprite.animation.name; if (animName == "sexy-jackoff") { if (critter.isMale()) { critter._eventStack.addEvent({time:critter._eventStack._time + 10.4, callback:critter.eventJizzStamp, args:[ -28 * (critter._bodySprite.flipX ? -1 : 1), 6]}); } else { critter._eventStack.addEvent({time:critter._eventStack._time + 10.1, callback:critter.eventJizzStamp, args:[ -6 * (critter._bodySprite.flipX ? -1 : 1), 4]}); } } if (animName == "sexy-jackoff-short") { if (critter.isMale()) { critter._eventStack.addEvent({time:critter._eventStack._time + 3.4, callback:critter.eventJizzStamp, args:[ -28 * (critter._bodySprite.flipX ? -1 : 1), 6]}); } else { critter._eventStack.addEvent({time:critter._eventStack._time + 3.1, callback:critter.eventJizzStamp, args:[ -6 * (critter._bodySprite.flipX ? -1 : 1), 4]}); } } if (animName == "sexy-jackoff-long") { if (critter.isMale()) { critter._eventStack.addEvent({time:critter._eventStack._time + 26.4, callback:critter.eventJizzStamp, args:[ -28 * (critter._bodySprite.flipX ? -1 : 1), 6]}); } else { critter._eventStack.addEvent({time:critter._eventStack._time + 26.1, callback:critter.eventJizzStamp, args:[ -6 * (critter._bodySprite.flipX ? -1 : 1), 4]}); } } } public static function playGlobalAnim(puzzleState:LevelState, animName:String) { puzzleState._globalSexyTimer = LevelState.GLOBAL_SEXY_FREQUENCY * FlxG.random.float(0.9, 1.11); if (animName == "global-sexy-multi-blowjob") { var botCritter:Critter; var topCritters:Array<Critter>; var watchCritters:Array<Critter> = []; { var critters:Array<Critter> = puzzleState.findIdleCritters(FlxG.random.getObject([3, 4, 5, 6, 7, 8], [7, 6, 5, 4, 3, 2])); if (critters.length < 3) { // couldn't find three return; } botCritter = critters.splice(0, 1)[0]; topCritters = critters; var i = topCritters.length - 1; while (i > 1) { if (FlxG.random.bool()) { watchCritters.push(topCritters.splice(i, 1)[0]); } i--; } } immobilizeCritters([botCritter], animName); immobilizeCritters(topCritters, animName); immobilizeCritters(watchCritters, animName); var sexyMultiBlowJob = new SexyMultiBlowJob(topCritters, botCritter, watchCritters); sexyMultiBlowJob.go(); } if (animName == "global-sexy-doggy-then-blowjob") { // a critter fucks another one doggy style, then asks for a blow job. its only smellz? var botCritter:Critter = null; var topCritter:Critter = null; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick 2 that are an appropriate distance for jumping if (farCritters.length < 2) { // couldn't find two return; } for (farCritter in farCritters) { if (farCritter.isMale()) { topCritter = farCritter; break; } } if (topCritter == null) { // no males? return; } farCritters.remove(topCritter); var bestDist:Float = 9999; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(topCritter._bodySprite.getPosition()); if (dist > SexyRimming.JUMP_DIST + 40 && dist < bestDist) { bestDist = dist; botCritter = farCritter; } } if (bestDist == 9999) { // couldn't find two which were a good distance return; } } immobilizeAndLinkCritters([topCritter, botCritter], animName); var _eventTime:Float = 0; { var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); { botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botWait}); } _eventTime = 0.4; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.runToJump}); topCritter._eventStack.addEvent({time:_eventTime += sexyDoggy.getExpectedRunToJumpDuration(), callback:sexyDoggy.jumpIntoPositionAndStartDoggy}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedJumpDuration() + 0.2, callback:sexyDoggy.topPenetrate, args:[0.2]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyDoggy.topHump, args:[1, 2, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); var spankiness:Int = FlxG.random.int( -30, 30); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(100 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(45 + spankiness)]}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(60 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(75 + spankiness)]}); } topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[5, 2, true]}); botCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(80) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); } { var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.refresh}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topSitBack}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.botDoneForNowRunAway}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 5), callback:sexyBlowJob.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topPoint}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 2.0), callback:sexyBlowJob.botNotice}); var whichEnd:Int; if (botCritter.isMale()) { // definitely anal sex; more objectionable outcomes whichEnd = FlxG.random.getObject([0, 1, 2, 3, 4], [0.4, 0.1, 0.2, 0.2, 0.1]); } else { // maybe anal sex; fewer objectionable outcomes whichEnd = FlxG.random.getObject([0, 1, 2, 3, 4], [0.08, 0.02, 0.04, 0.18, 0.68]); } if (whichEnd == 0) { // run away botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.botDoneRunFarAway}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyBlowJob.topDone}); } else if (whichEnd == 1) { // try, but recoil in disgust and vomit; and top runs away botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 3.0), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 5.0), callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topDoneRunFarAway}); botCritter._eventStack.addEvent({time:_eventTime, callback:botCritter.eventPlayAnim, args:["idle-vomit"]}); } else if (whichEnd == 2) { // try, but recoil in disgust botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 3.0), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.botDoneRunAway}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyBlowJob.topDone}); } else if (whichEnd == 3) { // recoil, but fight through it botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 3.0), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 6), callback:sexyBlowJob.botBj}); _eventTime += FlxG.random.float(4, 12); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.5, 2.5), callback:sexyBlowJob.botBj}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topSitBack}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 8), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 3.0), callback:sexyBlowJob.topEyesClosed}); // squirt botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); _eventTime += FlxG.random.float(0, 2); botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDoneRunAway}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); topCritter._eventStack.addEvent({time:_eventTime, callback:topCritter.eventPlayAnim, args:[FlxG.random.getObject(["idle-happy0", "idle-happy1", "idle-happy2"])]}); } else if (whichEnd == 4) { // suck that dick like a champ botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); _eventTime += FlxG.random.float(4, 12); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 8), callback:sexyBlowJob.topHandOffHead}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topEyesHalfOpen}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 8), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 3.0), callback:sexyBlowJob.topEyesClosed}); // swallow it botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSwallow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDoneRunAway}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); topCritter._eventStack.addEvent({time:_eventTime, callback:topCritter.eventPlayAnim, args:[FlxG.random.getObject(["idle-happy0", "idle-happy1", "idle-happy2"])]}); } } } if (animName == "global-sexy-blowjob-then-doggy") { // a critter gives another one a blow job, then gets fucked doggy style var topCritter:Critter; var botCritter:Critter; { var critters:Array<Critter> = puzzleState.findIdleCritters(2); if (critters.length < 2) { // couldn't find two return; } topCritter = critters[0]; botCritter = critters[1]; } immobilizeAndLinkCritters([topCritter, botCritter], animName); var _eventTime:Float = 0; { var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topPoint}); botCritter._eventStack.addEvent({time:_eventTime += 0.4, callback:sexyBlowJob.botRunIntoPositionAndBlow}); _eventTime += sexyBlowJob.getExpectedBotRunDuration(); _eventTime += FlxG.random.float(4, 12); var tenacity:Float = FlxG.random.float(0, 0.7); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 8), callback:sexyBlowJob.topHandOffHead}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topEyesHalfOpen}); } botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topJerkSelf}); } { var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.refresh}); topCritter._eventStack.addEvent({time:_eventTime += 0.1, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 1.2, callback:sexyDoggy.runIntoPositionAndStartDoggy}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.topPenetrate, args:[1.5]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyDoggy.topHump, args:[1, 3, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([3, 6]), callback:sexyDoggy.topHump, args:[1, 2, false]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 4, false]}); var tenacity:Float = FlxG.random.float(0, 0.9); var spankiness:Int = FlxG.random.int( -60, 60); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, true]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, true, FlxG.random.bool(40 + spankiness)]}); botCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(30) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } } if (animName == "global-sexy-mutual-masturbate-then-blowjob") { // two critters jerk off; then one blows the other var topCritter:Critter; var botCritter:Critter; { var critters:Array<Critter> = puzzleState.findIdleCritters(2); if (critters.length < 2) { // couldn't find two return; } topCritter = critters[0]; botCritter = critters[1]; } var _eventTime:Float = 0; immobilizeAndLinkCritters([topCritter, botCritter], animName); { // jerk off together... var sexyMutualMasturbate:SexyMutualMasturbate = new SexyMutualMasturbate([topCritter, botCritter]); _eventTime += sexyMutualMasturbate.go(false, false); _eventTime += 0.5; } { var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.refresh}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.4, 6), callback:sexyBlowJob.botRunIntoPositionAndJerk}); _eventTime += 0.5; botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botBj}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 12), callback:sexyBlowJob.botJerkOff}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botBj}); topCritter._eventStack.addEvent({time:_eventTime + FlxG.random.float(0.5, 2), callback:sexyBlowJob.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 12), callback:sexyBlowJob.botJerkOff}); topCritter._eventStack.addEvent({time:_eventTime + FlxG.random.float(0.5, 3), callback:sexyBlowJob.topEyesHalfOpen}); } // cums topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); // done botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); } } if (animName == "global-sexy-trade-blowjobs") { // a critter jerks off; another critter runs over and blows them, and the first critter returns the favor var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var _eventTime:Float = 0; { var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); immobilizeAndLinkCritters([topCritter, botCritter], animName); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.4, 6), callback:sexyBlowJob.botRunIntoPositionAndBlow}); _eventTime += sexyBlowJob.getExpectedBotRunDuration(); _eventTime += FlxG.random.float(4, 12); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.5, 2.5), callback:sexyBlowJob.botBj}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topSitBack}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 11), callback:sexyBlowJob.topEyesClosed}); // swallow it botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.botSwallow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDoneForNowRunToSwap}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDoneForNow}); } { // swap critters... var tmpCritter:Critter = botCritter; botCritter = topCritter; topCritter = tmpCritter; } { var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topPoint}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.refresh}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.5, 2.0), callback:sexyBlowJob.botNotice}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); _eventTime += 0.5; _eventTime += FlxG.random.float(4, 12); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botJerkOff}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.5, 4.5), callback:sexyBlowJob.botBj}); } botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.botJerkOff}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); } } if (animName == "global-sexy-blowjob-and-watersports") { // a critter runs over and gets their dick sucked, and maybe pisses in the other critter's mouth var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); immobilizeAndLinkCritters([topCritter, botCritter], animName); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topRunIntoPositionAndSitBack}); botCritter._eventStack.addEvent({time:_eventTime += sexyBlowJob.getExpectedTopRunDuration() + FlxG.random.float(0, 0.7), callback:sexyBlowJob.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.startBj}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.5, 4.5), callback:sexyBlowJob.botBj}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topSitBack}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 11), callback:sexyBlowJob.topEyesClosed}); // swallow it botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.botSwallow}); var wsChance:Int = 0; if (PlayerData.pokemonLibido >= 7) { wsChance = 70; } else if (PlayerData.pokemonLibido >= 6) { wsChance = 40; } else if (PlayerData.pokemonLibido >= 5) { wsChance = 20; } else if (PlayerData.pokemonLibido >= 4) { wsChance = 10; } if (FlxG.random.bool(wsChance)) { if (FlxG.random.bool()) { // variation #1; bottom critter leaves but comes back botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDoneForNowRunAway}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 5), callback:sexyBlowJob.topEyesHalfOpen}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topPointEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.0, 3.0), callback:sexyBlowJob.botNotice}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botReturnAndBj}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 3), callback:sexyBlowJob.botSwallow}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(10, 40), callback:sexyBlowJob.topEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.botSitUp}); } else { // variation #2; top critter holds him in place to finish botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botBj}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topHandOnHead}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.botSwallow}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(10, 40), callback:sexyBlowJob.topEyesHalfOpen}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topHandPatsHead}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesOpen}); } } else { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesOpen}); } botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); } if (animName == "global-sexy-blowjob") { // a critter runs over and blows another critter var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); immobilizeAndLinkCritters([topCritter, botCritter], animName); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topPoint}); botCritter._eventStack.addEvent({time:_eventTime += 0.4, callback:sexyBlowJob.botRunIntoPositionAndBlow}); _eventTime += sexyBlowJob.getExpectedBotRunDuration(); _eventTime += FlxG.random.float(4, 12); var pausesWithHandOnHead:Bool = false; var pausesWithJerkingOff:Bool = false; for (i in 0...2) { if (FlxG.random.bool()) { pausesWithHandOnHead = true; } else { pausesWithJerkingOff = true; } } var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { if (pausesWithHandOnHead && !pausesWithJerkingOff || (pausesWithHandOnHead && FlxG.random.bool())) { topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 8), callback:sexyBlowJob.topHandOffHead}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topEyesHalfOpen}); } else { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botJerkOff}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1.5, 4.5), callback:sexyBlowJob.botBj}); } } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 8), callback:sexyBlowJob.topHandOnHead}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 3.0), callback:sexyBlowJob.topEyesClosed}); if (FlxG.random.bool(40)) { // swallow it botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSwallow}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); } else if (FlxG.random.bool(50)) { // squirt botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); _eventTime += FlxG.random.float(0, 2); } else { // squirt, but then swallow botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topOrgasm}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botSwallow}); if (FlxG.random.bool()) { topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([0, 1]), callback:sexyBlowJob.topHandOnHeadSwallow}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.botSitUp}); } botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); } if (animName == "global-sexy-blowjob-and-jerk") { // a critter sucks someone off, then jerks them off until they cum var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var sexyBlowJob:SexyBlowJob = new SexyBlowJob(topCritter, botCritter); immobilizeAndLinkCritters([topCritter, botCritter], animName); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topJerkSelf}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0.4, 6), callback:sexyBlowJob.botRunIntoPositionAndJerk}); _eventTime += sexyBlowJob.getExpectedBotRunDuration(); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botBj}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 12), callback:sexyBlowJob.botJerkOff}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botBj}); topCritter._eventStack.addEvent({time:_eventTime + FlxG.random.float(0.5, 2), callback:sexyBlowJob.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(4, 12), callback:sexyBlowJob.botJerkOff}); topCritter._eventStack.addEvent({time:_eventTime + FlxG.random.float(0.5, 3), callback:sexyBlowJob.topEyesHalfOpen}); } // cums topCritter._eventStack.addEvent({time:_eventTime, callback:sexyBlowJob.topOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); // done botCritter._eventStack.addEvent({time:_eventTime, callback:eventUnlinkCritters, args:[[topCritter, botCritter]]}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.botDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyBlowJob.topDone}); } if (animName == "global-sexy-mutual-masturbate") { // 2-4 critters group up and masturbate var mainCritter:Critter; var otherCritters:Array<Critter> = []; { var critters:Array<Critter> = puzzleState.findIdleCritters(FlxG.random.getObject([2, 3, 4], [0.5, 0.3, 0.2])); if (critters.length < 2) { // couldn't find two return; } immobilizeCritters(critters, animName); var sexyMutualMasturbate:SexyMutualMasturbate = new SexyMutualMasturbate(critters); sexyMutualMasturbate.go(); } } if (animName == "global-sexy-doggy") { // a critter nudges his snout under someone else's rump, and fucks them doggy-style var botCritter:Critter; var topCritter:Critter = null; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } for (farCritter in farCritters) { if (farCritter.isMale()) { topCritter = farCritter; break; } } if (topCritter == null) { // no males? return; } farCritters.remove(topCritter); var closestDist:Float = 1000; botCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(topCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; botCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyDoggy.startDoggy}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.topPenetrate, args:[1.5]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyDoggy.topHump, args:[1, 3, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([3, 6]), callback:sexyDoggy.topHump, args:[1, 2, false]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 4, false]}); var tenacity:Float = FlxG.random.float(0, 0.9); var spankiness:Int = FlxG.random.int( -60, 60); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); } topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, true]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, true, FlxG.random.bool(40 + spankiness)]}); botCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(30) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } if (animName == "global-sexy-doggy-blitz") { // a critter nudges his snout under someone else's rump, and fucks them doggy-style, but cums really quick var botCritter:Critter; var topCritter:Critter = null; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } for (farCritter in farCritters) { if (farCritter.isMale()) { topCritter = farCritter; break; } } if (topCritter == null) { // no males? return; } farCritters.remove(topCritter); var closestDist:Float = 1000; botCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(topCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; botCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyDoggy.startDoggy}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.topPenetrate, args:[1.5]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyDoggy.topHump, args:[1, 2, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[3, 2, false]}); topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[5, 2, true]}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(10) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); botCritter._eventStack.addEvent({time:_eventTime + 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 5.5, callback:sexyDoggy.topAlmostDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } if (animName == "global-sexy-doggy-spank") { // a critter waggles his rump immediately; another critter leaps into place, fucking him doggy style, and spanking him var botCritter:Critter = null; var topCritter:Critter = null; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick 2 that are an appropriate distance for jumping if (farCritters.length < 2) { // couldn't find two return; } for (farCritter in farCritters) { if (farCritter.isMale()) { topCritter = farCritter; break; } } if (topCritter == null) { // no males? return; } farCritters.remove(topCritter); var bestDist:Float = 9999; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(topCritter._bodySprite.getPosition()); if (dist > SexyRimming.JUMP_DIST + 40 && dist < bestDist) { bestDist = dist; botCritter = farCritter; } } if (bestDist == 9999) { // couldn't find two which were a good distance return; } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var _eventTime:Float = 0; { var _eventTime:Float = 0; botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botWait}); } var _eventTime:Float = 0.4; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.runToJump}); topCritter._eventStack.addEvent({time:_eventTime += sexyDoggy.getExpectedRunToJumpDuration(), callback:sexyDoggy.jumpIntoPositionAndStartDoggy}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedJumpDuration() + 0.2, callback:sexyDoggy.topPenetrate, args:[0.2]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyDoggy.topHump, args:[1, 2, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); var spankiness:Int = FlxG.random.int( -30, 30); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(100 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(45 + spankiness)]}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(60 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(75 + spankiness)]}); } topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[5, 2, true]}); botCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(80) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } if (animName == "global-sexy-doggy-gangbang") { // a critter waggles his rump alluringly; several critters race into position, and take turns fucking him var botCritter:Critter; var topCritters:Array<Critter> = []; var watchCritters:Array<Critter> = []; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(7); // find 7; pick one bottom, and a lot of spectators if (farCritters.length < 3) { // couldn't find three return; } botCritter = farCritters.splice(0, 1)[0]; for (farCritter in farCritters) { if (farCritter.isMale()) { topCritters.push(farCritter); } else if (FlxG.random.bool(40)) { // sometimes girls like to watch too watchCritters.push(farCritter); } } if (topCritters.length < 2) { // need at least two males for a gangbang return; } var closestDist:Float = 1000; var closestTopCritter = topCritters[0]; for (topCritter in topCritters) { var dist:Float = topCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; closestTopCritter = topCritter; } } topCritters.remove(closestTopCritter); topCritters.insert(0, closestTopCritter); var i = topCritters.length - 1; while (i > 1) { if (FlxG.random.bool()) { watchCritters.push(topCritters.splice(i, 1)[0]); } i--; } FlxG.random.shuffle(watchCritters); // maximum five spectators topCritters.splice(2, topCritters.length - 5); watchCritters.splice(0, (topCritters.length + watchCritters.length) - 5); } immobilizeCritters([botCritter], animName); immobilizeCritters(topCritters, animName); immobilizeCritters(watchCritters, animName); var sexyGangBang:SexyGangBang = new SexyGangBang(topCritters, botCritter, watchCritters); sexyGangBang.go(); } if (animName == "global-sexy-rimming-into-doggy") { // a critter nudges his snout under someone else's rump, and starts rimming them... then fucks them var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.startRim}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 10.0 + FlxG.random.float(0, 4.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); { var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } } topCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyDoggy.startDoggy, args:[true]}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyDoggy.topPenetrate, args:[1.5]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyDoggy.topHump, args:[1, 2, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); var spankiness:Int = FlxG.random.int( -30, 30); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(100 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(45 + spankiness)]}); { var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(60 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(75 + spankiness)]}); } } topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[5, 2, true]}); botCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(80) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } if (animName == "global-sexy-rimming-take-turns-and-doggy") { // a critter rims someone else, who then returns the favor var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var _eventTime:Float = 0; { var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.startRim}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 7.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } botCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyRimming.topDoneForNow}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDoneForNow}); } { var sexyRimming:SexyRimming = new SexyRimming(botCritter, topCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(botCritter, topCritter); botCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:sexyRimming.refresh}); topCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.runIntoPositionAndRim}); botCritter._eventStack.addEvent({time:_eventTime += 0.4 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 3.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime += 5.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyDoggy.startDoggy, args:[true]}); botCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyDoggy.topPenetrate, args:[0.33]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.botEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 4, false]}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 4, false]}); topCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); var tenacity:Float = FlxG.random.float(0, 0.9); var spankiness:Int = FlxG.random.int( -60, 60); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[5, 4, false]}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[7, 4, false, FlxG.random.bool(30 + spankiness)]}); } botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[9, 4, true]}); botCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[11, 4, true, FlxG.random.bool(40 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime + 1.66, callback:sexyDoggy.botOrgasm}); botCritter._eventStack.addEvent({time:_eventTime += 4, callback:(FlxG.random.bool(30) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); botCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); botCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:eventUnlinkCritters, args:[critters]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.topDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.5, callback:sexyDoggy.botDone}); } } if (animName == "global-sexy-doggy-then-rim") { // a critter waggles his rump immediately; another critter leaps into place, fucking him doggy style, and spanking him var botCritter:Critter = null; var topCritter:Critter = null; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick 2 that are an appropriate distance for jumping if (farCritters.length < 2) { // couldn't find two return; } for (farCritter in farCritters) { if (farCritter.isMale()) { topCritter = farCritter; break; } } if (topCritter == null) { // no males? return; } farCritters.remove(topCritter); var bestDist:Float = 9999; botCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(topCritter._bodySprite.getPosition()); if (dist > SexyRimming.JUMP_DIST + 40 && dist < bestDist) { bestDist = dist; botCritter = farCritter; } } if (bestDist == 9999) { // couldn't find two which were a good distance return; } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter); var _eventTime:Float = 0; { var _eventTime:Float = 0; botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botWait}); } var _eventTime:Float = 0.4; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.runToJump}); topCritter._eventStack.addEvent({time:_eventTime += sexyDoggy.getExpectedRunToJumpDuration(), callback:sexyDoggy.jumpIntoPositionAndStartDoggy}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedJumpDuration() + 0.2, callback:sexyDoggy.topPenetrate, args:[0.2]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyDoggy.botEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyDoggy.topHump, args:[1, 2, false]}); botCritter._eventStack.addEvent({time:_eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); var spankiness:Int = Math.round(Math.min(FlxG.random.int( -30, 30), FlxG.random.int( -30, 30))); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(100 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(45 + spankiness)]}); { var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(60 + spankiness)]}); topCritter._eventStack.addEvent({time:_eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false, FlxG.random.bool(75 + spankiness)]}); } } topCritter._eventStack.addEvent({time:_eventTime += 2, callback:sexyDoggy.topHump, args:[5, 2, true]}); topCritter._eventStack.addEvent({time:_eventTime += 4, callback:sexyDoggy.topOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyDoggy.botLookBack}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.startRim, args:[true]}); botCritter._eventStack.addEvent({time:_eventTime + 0.833, callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 10.0 + FlxG.random.float(0, 4.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); { var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } } botCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDone}); } if (animName == "global-sexy-rimming") { // a critter nudges his snout under someone else's rump, and starts rimming them var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.startRim}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 10.0 + FlxG.random.float(0, 4.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } botCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 2.0, callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDone}); } if (animName == "global-sexy-rimming-take-turns") { // a critter rims someone else, who then returns the favor var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick the closest 2 if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var closestDist:Float = 1000; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist < closestDist) { closestDist = dist; topCritter = farCritter; } } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var _eventTime:Float = 0; { var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runIntoPositionAndPokeSnout}); botCritter._eventStack.addEvent({time:_eventTime += 1.2 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.botNotice}); topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.startRim}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 7.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } botCritter._eventStack.addEvent({time:_eventTime += 2.5, callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 1.0, callback:sexyRimming.topDoneForNow}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDoneForNow}); } { var sexyRimming:SexyRimming = new SexyRimming(botCritter, topCritter); botCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:sexyRimming.refresh}); topCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.runIntoPositionAndRim}); botCritter._eventStack.addEvent({time:_eventTime += 0.4 + sexyRimming.getExpectedRunDuration(), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 3.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime += 5.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.7); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? topCritter._eventStack.addEvent({time:_eventTime += 1.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime += 1.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); botCritter._eventStack.addEvent({time:_eventTime += 1.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 1.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } topCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.botOrgasm}); botCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:sexyRimming.topStop}); botCritter._eventStack.addEvent({time:_eventTime += 0.6, callback:eventUnlinkCritters, args:[critters]}); botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.topDone}); topCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDone}); } } if (animName == "global-sexy-rimming-waggle") { // a critter waggles their rump alluringly, and another critter dives in to rim them var botCritter:Critter; var topCritter:Critter; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(5); // find 5; pick 2 that are an appropriate distance for jumping if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var bestDist:Float = 9999; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist > SexyRimming.JUMP_DIST + 40 && dist < bestDist) { bestDist = dist; topCritter = farCritter; } } if (bestDist == 9999) { // couldn't find two which were a good distance return; } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); { var _eventTime:Float = 0; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botWaggle}); topCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botWait}); } var _eventTime:Float = 0.4; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runToJump}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedRunToJumpDuration(), callback:sexyRimming.jumpIntoPositionAndRim}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedJumpDuration() + 0.4, callback:sexyRimming.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 6.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 5.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } botCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 1.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDone}); } if (animName == "global-sexy-rimming-race") { // a critter waggles their rump alluringly, and several critters race in to rim them var botCritter:Critter; var topCritter:Critter; var otherCritters:Array<Critter> = []; { var farCritters:Array<Critter> = puzzleState.findIdleCritters(7); // find 7; pick the closest one and a few others if (farCritters.length < 2) { // couldn't find two return; } botCritter = farCritters.splice(0, 1)[0]; var bestDist:Float = 9999; topCritter = farCritters[0]; for (farCritter in farCritters) { var dist:Float = farCritter._bodySprite.getPosition().distanceTo(botCritter._bodySprite.getPosition()); if (dist > SexyRimming.JUMP_DIST + 100) { otherCritters.push(farCritter); } if (dist > SexyRimming.JUMP_DIST + 100 && dist < bestDist) { bestDist = dist; topCritter = farCritter; } } otherCritters.remove(topCritter); otherCritters.splice(0, otherCritters.length - 3); if (otherCritters.length == 0) { // couldn't find enough critters for a race return; } } var critters:Array<Critter> = [topCritter, botCritter]; immobilizeAndLinkCritters(critters, animName); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter); { var _eventTime:Float = 0; botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botWait}); } for (critter in otherCritters) { var facing:Int = critter._bodySprite.x > botCritter._bodySprite.x ? FlxObject.LEFT : FlxObject.RIGHT; var jumpTarget:FlxPoint = FlxPoint.get(botCritter._targetSprite.x + (facing == FlxObject.LEFT ? 18 : -18), botCritter._targetSprite.y - 9); var dx:Float = critter._bodySprite.x - jumpTarget.x; var dy:Float = critter._bodySprite.y - jumpTarget.y; jumpTarget.put(); if (dx == 0 && dy == 0) { // avoid divide by zero dx = 2; dy = 1; } var ex:Float = SexyRimming.JUMP_DIST * dx / Math.sqrt(dx * dx + dy * dy); var ey:Float = SexyRimming.JUMP_DIST * dy / Math.sqrt(dx * dx + dy * dy); var jumpSource:FlxPoint = FlxPoint.get(botCritter._targetSprite.x + ex, botCritter._targetSprite.y + ey); critter.runTo(jumpSource.x, jumpSource.y); } var _eventTime:Float = 0.4; topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.runToJump}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedRunToJumpDuration(), callback:sexyRimming.jumpIntoPositionAndRim}); topCritter._eventStack.addEvent({time:_eventTime += sexyRimming.getExpectedJumpDuration() + 0.4, callback:sexyRimming.topEyesClosed}); topCritter._eventStack.addEvent({time:_eventTime += 7.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 6.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && _eventTime < 300) { // go again? botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesOpen}); topCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.topEyesClosed}); botCritter._eventStack.addEvent({time:_eventTime += 2.0 + FlxG.random.float(0, 2.0), callback:sexyRimming.botEyesClosed}); } botCritter._eventStack.addEvent({time:_eventTime += 1.5, callback:sexyRimming.botOrgasm}); topCritter._eventStack.addEvent({time:_eventTime += 1.5 + FlxG.random.float(0, 2.0), callback:sexyRimming.topStop}); topCritter._eventStack.addEvent({time:_eventTime += 0.5 + FlxG.random.float(0, 2.0), callback:eventUnlinkCritters, args:[critters]}); topCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming.topDone}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming.botDone}); } } static private function immobilizeCritters(critters:Array<Critter>, animName:String):Void { for (critter in critters) { critter.setImmovable(true); critter._eventStack.reset(); critter._lastSexyAnim = animName; } } static private function immobilizeAndLinkCritters(critters:Array<Critter>, animName:String):Void { immobilizeCritters(critters, animName); for (critter in critters) { critterLinks[critter] = critters; } } public static function isLinked(critter:Critter) { if (critterLinks[critter] != null) { return true; } for (otherCritter in critterLinks.keys()) { if (critterLinks[otherCritter].indexOf(critter) != -1) { return true; } } return false; } public static function unlinkCritterAndMakeGroupIdle(critter:Critter) { // this critter was picked up; anybody depending on him should be made idle, and he shouldn't depend on anybody anymore if (critterLinks[critter] != null) { for (otherCritter in critterLinks[critter]) { otherCritter.setIdle(); otherCritter._eventStack.reset(); otherCritter.setImmovable(false); // if they're running to do something -- stop them from running, and get rid of the "something" otherCritter._targetSprite.setPosition(otherCritter._soulSprite.x, otherCritter._soulSprite.y); otherCritter._runToCallback = null; } unlinkCritters(critterLinks[critter]); } unlinkCritters([critter]); } public static function unlinkCritters(args:Array<Critter>):Void { // iterate over args.copy() since it's possible it can be changed as we're unlinking stuff for (critter in args.copy()) { var result:Bool = critterLinks.remove(critter); for (key in critterLinks.keys()) { critterLinks[key].remove(critter); } } } public static function eventUnlinkCritters(args:Array<Dynamic>):Void { unlinkCritters(args[0]); } public static function stayImmobile(critter:Critter):Void { critter.playAnim("sexy-idle"); } public static function initialize() { critterLinks = new Map<Critter, Array<Critter>>(); } static public function traceCritterLinks() { for (critterLink in critterLinks.keys()) { trace(critterLink + " -> " + critterLinks[critterLink]); } } }
argonvile/monster
source/critter/SexyAnims.hx
hx
unknown
103,591
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.math.FlxPoint; /** * An animation where a bug blows the other one */ class SexyBlowJob extends SexyCritterAnim { private var topCritter:Critter; // the critter doing the rimming private var botCritter:Critter; // the critter being rimmed public var facing:Int; // is the critter receiving the blowjob facing right or left? private var jumpTarget:FlxPoint; // where the bottom needs to be, to blow the top private var isTopHandOnHead:Bool = false; /** * @param topCritter receives the blowjob * @param botCritter give the blowjob * @param facing the direction the topCritter is facing */ public function new(topCritter:Critter, botCritter:Critter, ?facing:Int = 0) { super(); this.topCritter = topCritter; this.botCritter = botCritter; this.facing = facing; refresh(null); } public function refresh(args:Array<Dynamic>) { facing = topCritter._bodySprite.x > botCritter._bodySprite.x ? FlxObject.LEFT : FlxObject.RIGHT; jumpTarget = FlxPoint.get(topCritter._targetSprite.x + (facing == FlxObject.LEFT ? -19 : 19), topCritter._targetSprite.y + 14); } public function botSitUp(args:Array<Dynamic>) { if (isTopHandOnHead) { topHandOffHead(null); } stopSexyAnim(botCritter); botCritter._headSprite.animation.add("sexy-misc", [ 118, 119, 118, 119, 118, 119, 118, 118, 118, 118, 118, 119, 119, 119, 119, 118, 118, 118, 119, 119, 119, 119, 118, 119, 118, 118, 119, 119, 119, 118, 118, 119, 118, 119, 119, 119, ], Critter._FRAME_RATE, true); botCritter._bodySprite.animation.add("sexy-misc", [ 108, 107, 107, 107, 108, 108, 107, 108, 107, 108, 108, 108, 108, 107, 107, 108, 108, 108, 107, 108, 108, 107, 108, 107, 108, 108, 108, 107, 108, 107, 107, 107, 107, 107, 107, 108, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function topHandOnHead(args:Array<Dynamic>) { botCritter._headSprite.animation.add("sexy-misc", [ 117, 117, 114, 117, 116, 114, 115, 115, 116, 115, 116, 116, 114, 117, 117, 114, 116, 116, 117, 115, 116, 114, 115, 115, 117, 114, 117, 117, 114, 116, 114, 114, 114, 115, 116, 116, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.play("sexy-misc"); topCritter.setFrontBodySpriteOffset(15); topCritter._frontBodySprite.animation.add("sexy-misc", [ 100, 100, 99, 100, 100, 99, 99, 99, 100, 99, 100, 100, 99, 100, 100, 99, 100, 100, 100, 99, 100, 99, 99, 99, 100, 99, 100, 100, 99, 100, 99, 99, 99, 99, 100, 100, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.visible = true; topCritter._frontBodySprite.animation.play("sexy-misc"); isTopHandOnHead = true; } public function topHandPatsHead(args:Array<Dynamic>) { topCritter.setFrontBodySpriteOffset(15); topCritter._frontBodySprite.animation.add("sexy-misc", [ 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, ], Critter._FRAME_RATE, false); topCritter._frontBodySprite.visible = true; topCritter._frontBodySprite.animation.play("sexy-misc"); isTopHandOnHead = true; } public function topHandOnHeadSwallow(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._headSprite.animation.add("sexy-misc", [ 115, 115, 115, 114, 115, 114, 114, 115, 114, 114, 114, 114, 114, 115, 114, 114, 115, 114, 114, 115, 114, 114, 115, 115, ], Critter._FRAME_RATE, true); botCritter._bodySprite.animation.add("sexy-misc", [ 104, 105, 104, 105, 105, 104, 104, 104, 105, 104, 106, 105, 105, 106, 104, 105, 105, 106, 106, 104, 104, 105, 104, 105, 106, 105, 106, 106, 106, 106, 106, 106, 104, 104, 105, 105, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); topCritter.setFrontBodySpriteOffset(15); topCritter._frontBodySprite.animation.add("sexy-misc", [ 99, 99, 99, 99, 99, 99, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.play("sexy-misc"); isTopHandOnHead = true; } public function topHandOffHead(args:Array<Dynamic>) { topCritter._frontBodySprite.visible = false; isTopHandOnHead = false; } public function topEyesClosed(args:Array<Dynamic>) { topCritter._headSprite.animation.add("sexy-misc", [ 51, 51, 50, 51, 51, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 51, 50, 50, 50, 51, 51, 50, 51, 51, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.play("sexy-misc"); } public function topEyesHalfOpen(args:Array<Dynamic>) { topCritter._headSprite.animation.add("sexy-misc", [ 49, 48, 48, 49, 48, 48, 48, 49, 49, 48, 49, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.play("sexy-misc"); } public function topEyesOpen(args:Array<Dynamic>) { topCritter._headSprite.animation.add("sexy-misc", [ 52, 51, 51, 52, 51, 51, 51, 52, 52, 51, 52, 52, 51, 52, 52, 52, 51, 51, 52, 52, 51, 52, 52, 52, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.play("sexy-misc"); } public function botSwallow(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._headSprite.animation.add("sexy-misc", [ 115, 115, 115, 114, 115, 114, 114, 115, 114, 114, 114, 114, 114, 115, 114, 114, 115, 114, 114, 115, 114, 114, 115, 115, ], Critter._FRAME_RATE, true); botCritter._bodySprite.animation.add("sexy-misc", [ 104, 105, 104, 105, 105, 104, 104, 104, 105, 104, 106, 105, 105, 106, 104, 105, 105, 106, 106, 104, 104, 105, 104, 105, 106, 105, 106, 106, 106, 106, 106, 106, 104, 104, 105, 105, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); if (isTopHandOnHead) { topCritter.setFrontBodySpriteOffset(15); topCritter._frontBodySprite.animation.add("sexy-misc", [ 99, 99, 99, 99, 99, 99, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.play("sexy-misc"); } } public function topJerkSelf(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter._bodySprite.facing = facing; topCritter._headSprite.animation.add("sexy-misc", [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, ], Critter._FRAME_RATE, true); if (topCritter.isMale()) { topCritter._bodySprite.animation.add("sexy-misc", [ 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 33, 32, 32, 33, 33, 32, 32, ], Critter._FRAME_RATE, true); } else { topCritter._bodySprite.animation.add("sexy-misc", [ 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 31, 32, 32, 31, 31, 32, 32, ], Critter._FRAME_RATE, false); } topCritter.playAnim("sexy-misc"); } public function topPoint(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter._bodySprite.facing = facing; topCritter._bodySprite.animation.add("sexy-misc", [ 98, 97, 98, 97, 96, 98, 97, 98, 96, 98, 97, 98, 97, 98, 96, 97, 97, 96, 97, 98, 96, 98, 98, 96, 97, 98, 96, 97, 98, 98, 96, 97, 97, 97, 96, 98, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 53, 53, 52, 53, 53, 52, 52, 53, 53, 53, 52, 52, 53, 52, 52, 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 52, 53, 53, 53, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 111, 111, 110, 110, 111, 110, 111, 110, 111, 111, 110, 110, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); topCritter.playAnim("sexy-misc"); } public function topPointEyesHalfOpen(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter._bodySprite.facing = facing; topCritter._bodySprite.animation.add("sexy-misc", [ 98, 97, 98, 97, 96, 98, 97, 98, 96, 98, 97, 98, 97, 98, 96, 97, 97, 96, 97, 98, 96, 98, 98, 96, 97, 98, 96, 97, 98, 98, 96, 97, 97, 97, 96, 98, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 49, 48, 48, 49, 48, 48, 48, 49, 49, 48, 49, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 48, 49, 49, 48, 49, 49, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 111, 111, 110, 110, 111, 110, 111, 110, 111, 111, 110, 110, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); topCritter.playAnim("sexy-misc"); } /** * Bottom critter takes a break and jerks top off for a little while */ public function botJerkOff(args:Array<Dynamic>) { stopSexyAnim(botCritter); if (topCritter.isMale()) { botCritter._bodySprite.animation.add("sexy-misc", [ 114, 114, 112, 114, 114, 112, 112, 114, 112, 114, 112, 114, 112, 114, 114, 114, 112, 114, 112, 112, 112, 112, 114, 114, 114, 112, 114, 114, 114, 114, 112, 114, 114, 114, 114, 112, ], Critter._FRAME_RATE, true); } else { botCritter._bodySprite.animation.add("sexy-misc", [ 113, 113, 112, 113, 113, 112, 112, 113, 112, 113, 112, 113, 112, 113, 113, 113, 112, 113, 112, 112, 112, 112, 113, 113, 113, 112, 113, 113, 113, 113, 112, 113, 113, 113, 113, 112, ], Critter._FRAME_RATE, true); } botCritter._headSprite.animation.add("sexy-misc", [ 118, 118, 118, 118, 118, 119, 119, 119, 119, 118, 118, 118, 119, 119, 119, 119, 118, 119, 118, 118, 119, 119, 119, 118, 118, 119, 118, 119, 119, 119, 118, 119, 118, 119, 118, 119, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botBj(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 104, 105, 104, 105, 105, 104, 104, 104, 105, 104, 106, 105, 105, 106, 104, 105, 105, 106, 106, 104, 104, 105, 104, 105, 106, 105, 106, 106, 106, 106, 106, 106, 104, 104, 105, 105, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 114, 114, 115, 116, 114, 116, 117, 116, 114, 115, 114, 115, 117, 114, 114, 115, 115, 114, 116, 116, 114, 114, 116, 116, 114, 116, 116, 114, 117, 116, 114, 116, 114, 115, 115, 117, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); if (isTopHandOnHead) { topCritter.setFrontBodySpriteOffset(15); topCritter._frontBodySprite.animation.add("sexy-misc", [ 99, 99, 99, 100, 99, 100, 100, 100, 99, 99, 99, 99, 100, 99, 99, 99, 99, 99, 100, 100, 99, 99, 100, 100, 99, 100, 100, 99, 100, 100, 99, 100, 99, 99, 99, 100, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.play("sexy-misc"); } } public function topOrgasm(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(4); topHandOffHead(null); topCritter._bodySprite.animation.add("sexy-misc", [ 96, 97, 98, 98, 98, 96, 96, 97, 98, 96, 98, 96, 96, 97, 98, 97, 98, 96, 97, 98, 97, 96, 97, 98, 98, 98, 97, 98, 97, 98, 98, 96, 98, 97, 96, 98, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 51, 51, 50, 51, 51, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 51, 50, 50, 50, 51, 51, 50, 51, 51, ], Critter._FRAME_RATE, true); if (topCritter.isMale()) { topCritter._frontBodySprite.animation.add("sexy-misc", [ 34, 35, 36, 37, 2, 2, 34, 35, 36, 37, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); } else { topCritter._frontBodySprite.animation.add("sexy-misc", [ 30, 38, 39, 2, 2, 30, 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); } topCritter.playAnim("sexy-misc"); if (topCritter.isMale()) { topCritter._eventStack.addEvent({time:topCritter._eventStack._time + 0.4, callback:topCritter.eventJizzStamp, args:[ 28 * (topCritter._bodySprite.facing == FlxObject.LEFT ? -1 : 1), 6]}); } else { topCritter._eventStack.addEvent({time:topCritter._eventStack._time + 0.1, callback:topCritter.eventJizzStamp, args:[ 6 * (topCritter._bodySprite.facing == FlxObject.LEFT ? -1 : 1), 4]}); } } public function topSitBack(args:Array<Dynamic>) { topCritter._bodySprite.facing = facing; stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(15); topCritter._bodySprite.animation.add("sexy-misc", [ 96, 97, 98, 98, 98, 96, 96, 97, 98, 96, 98, 96, 96, 97, 98, 97, 98, 96, 97, 98, 97, 97, 96, 98, 98, 98, 97, 98, 97, 98, 97, 98, 96, 98, 96, 98, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function startBj(args:Array<Dynamic>) { topCritter._bodySprite.facing = facing; botCritter._bodySprite.facing = (facing == FlxObject.LEFT ? FlxObject.RIGHT : FlxObject.LEFT); botCritter.setPosition(topCritter._bodySprite.x + (facing == FlxObject.LEFT ? -19 : 19), topCritter._targetSprite.y + 14); botBj(null); topSitBack(null); } public function critterStartBj(critter:Critter) { startBj(null); } public function critterStartJerk(critter:Critter) { topCritter._bodySprite.facing = facing; botCritter._bodySprite.facing = (facing == FlxObject.LEFT ? FlxObject.RIGHT : FlxObject.LEFT); stopSexyAnim(botCritter); if (topCritter.isMale()) { botCritter._bodySprite.animation.add("sexy-misc", [ 114, 114, 112, 114, 114, 112, 112, 114, 112, 114, 112, 114, 112, 114, 114, 114, 112, 114, 112, 112, 112, 112, 114, 114, 114, 112, 114, 114, 114, 114, 112, 114, 114, 114, 114, 112, ], Critter._FRAME_RATE, true); } else { botCritter._bodySprite.animation.add("sexy-misc", [ 113, 113, 112, 113, 113, 112, 112, 113, 112, 113, 112, 113, 112, 113, 113, 113, 112, 113, 112, 112, 112, 112, 113, 113, 113, 112, 113, 113, 113, 113, 112, 113, 113, 113, 113, 112, ], Critter._FRAME_RATE, true); } botCritter._headSprite.animation.add("sexy-misc", [ 118, 118, 118, 118, 118, 119, 119, 119, 119, 118, 118, 118, 119, 119, 119, 119, 118, 119, 118, 118, 119, 119, 119, 118, 118, 119, 118, 119, 119, 119, 118, 119, 118, 119, 118, 119, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(15); topCritter._bodySprite.animation.add("sexy-misc", [ 96, 97, 98, 98, 98, 96, 96, 97, 98, 96, 98, 96, 96, 97, 98, 97, 98, 96, 97, 98, 97, 97, 96, 98, 98, 98, 97, 98, 97, 98, 97, 98, 96, 98, 96, 98, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 48, 49, 49, 48, 48, 49, 48, 48, 49, 48, 48, 48, 48, 49, 49, 48, 48, 49, 49, 48, 49, 49, 49, 49, 48, 49, 49, 49, 48, 48, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function botRunIntoPositionAndBlow(args:Array<Dynamic>):Void { botCritter.runTo(jumpTarget.x, jumpTarget.y, critterStartBj); } public function getExpectedTopRunDuration():Float { return IdleAnims.getProjectedTime(topCritter, topCritter._soulSprite.getPosition(), botCritter._targetSprite.getPosition()); } public function getExpectedBotRunDuration():Float { return IdleAnims.getProjectedTime(botCritter, botCritter._soulSprite.getPosition(), topCritter._targetSprite.getPosition()); } public function topDone(args:Array<Dynamic>) { done(topCritter); } public function botDone(args:Array<Dynamic>) { done(botCritter); } public function topDoneForNow(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.playAnim("sexy-idle"); } public function botDoneForNow(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter.playAnim("sexy-idle"); } public function botRunIntoPositionAndJerk(args:Array<Dynamic>):Void { botCritter.runTo(jumpTarget.x, jumpTarget.y, critterStartJerk); } public function critterTopSitBack(critter:Critter):Void { topSitBack(null); } public function topRunIntoPositionAndSitBack(args:Array<Dynamic>) { var otherTarget:FlxPoint = FlxPoint.get(botCritter._targetSprite.x - (facing == FlxObject.LEFT ? -19 : 19), botCritter._targetSprite.y - 14); topCritter.runTo(otherTarget.x, otherTarget.y, critterTopSitBack); } public function botNotice(args:Array<Dynamic>) { botCritter._bodySprite.facing = topCritter._bodySprite.x > botCritter._bodySprite.x ? FlxObject.LEFT : FlxObject.RIGHT; stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 0, 0 ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 65, 65, 65, 65, 64, 65, 64, 65, 65, 65, 64, 64, 64, 65, 65, 65, 64, 64, 65, 65, 64, 65, 64, 65, ], Critter._FRAME_RATE, true); botCritter._frontBodySprite.animation.add("sexy-misc", [ 45, 45, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); botCritter.playAnim("sexy-misc"); } public function botDoneForNowRunAway(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter.runTo(botCritter._soulSprite.x + (facing == FlxObject.RIGHT ? 1 : -1) * 40, botCritter._soulSprite.y + 5); } public function botDoneForNowRunToSwap(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter.runTo(botCritter._soulSprite.x + (facing == FlxObject.RIGHT ? 19 : -19), botCritter._soulSprite.y - 14); } public function botReturnAndBj(args:Array<Dynamic>) { refresh(null); botCritter.runTo(jumpTarget.x, jumpTarget.y, critterStartBj); } public function botDoneRunAway(args:Array<Dynamic>) { done(botCritter); botCritter.runTo(botCritter._soulSprite.x + (facing == FlxObject.RIGHT ? 1 : -1) * FlxG.random.float(20, 60), botCritter._soulSprite.y + FlxG.random.float(-10, 10)); } public function botDoneRunFarAway(args:Array<Dynamic>) { done(botCritter); botCritter.runTo(botCritter._soulSprite.x + (facing == FlxObject.RIGHT ? 1 : -1) * FlxG.random.float(80, 140), botCritter._soulSprite.y + FlxG.random.float(-10, 10)); } public function topDoneRunFarAway(args:Array<Dynamic>) { done(topCritter); topCritter.runTo(topCritter._soulSprite.x + (facing == FlxObject.RIGHT ? -1 : 1) * FlxG.random.float(80, 140), topCritter._soulSprite.y + FlxG.random.float(-10, 10)); } }
argonvile/monster
source/critter/SexyBlowJob.hx
hx
unknown
19,667
package critter; /** * A parent class for sexy animations between bugs. */ class SexyCritterAnim { public function new() { } public function stopSexyAnim(critter:Critter) { critter.playAnim("idle"); critter._bodySprite.animation.remove("sexy-misc"); critter._headSprite.animation.remove("sexy-misc"); critter._frontBodySprite.animation.remove("sexy-misc"); } public function done(critter:Critter) { stopSexyAnim(critter); critter.setIdle(); critter.setImmovable(false); } public function eventStopSexyAnim(args:Array<Dynamic>) { var critter:Critter = args[0]; stopSexyAnim(critter); } }
argonvile/monster
source/critter/SexyCritterAnim.hx
hx
unknown
653
package critter; import critter.Critter; import flixel.FlxG; import flixel.FlxObject; import flixel.math.FlxMath; import flixel.math.FlxPoint; /** * An animation where a bug fucks another bug doggy-style */ class SexyDoggy extends SexyCritterAnim { public var facing:Int; private var topCritter:Critter; // critter doing the fucking private var botCritter:Critter; // critter being fucked private var jumpTarget:FlxPoint; // if the top were to jump, this is where he'd jump to private var jumpSource:FlxPoint; // if the top were to jump, this is where he'd jump from public function new(topCritter:Critter, botCritter:Critter, ?facing:Int = 0) { super(); this.topCritter = topCritter; this.botCritter = botCritter; this.facing = facing; refresh(null); } public function refresh(args:Array<Dynamic>) { if (facing == 0) { facing = topCritter._bodySprite.x > botCritter._bodySprite.x ? FlxObject.LEFT : FlxObject.RIGHT; } jumpTarget = FlxPoint.get(botCritter._targetSprite.x + (facing == FlxObject.LEFT ? 10 : -10), botCritter._targetSprite.y - 12); var dx:Float = topCritter._bodySprite.x - jumpTarget.x; var dy:Float = topCritter._bodySprite.y - jumpTarget.y; if (dx == 0 && dy == 0) { // avoid divide by zero dx = 2; dy = 1; } var ex:Float = SexyRimming.JUMP_DIST * dx / Math.sqrt(dx * dx + dy * dy); var ey:Float = SexyRimming.JUMP_DIST * dy / Math.sqrt(dx * dx + dy * dy); jumpSource = FlxPoint.get(botCritter._targetSprite.x + ex, botCritter._targetSprite.y + ey); } public function critterStartDoggy(critter:Critter) { startDoggy(null); } /* * args[0]: if true, top repositions. otherwise, bottom repositions */ public function startDoggy(args:Array<Dynamic>) { topCritter._bodySprite.facing = facing; botCritter._bodySprite.facing = facing; var topShouldReposition:Bool = args == null ? false : args[0]; if (topShouldReposition) { topCritter.setPosition(botCritter._bodySprite.x + (facing == FlxObject.LEFT ? 10 : -10), botCritter._bodySprite.y - 12); } else { botCritter.setPosition(topCritter._bodySprite.x + (facing == FlxObject.LEFT ? -10 : 10), topCritter._bodySprite.y + 12); } stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(13); topCritter.setBodySpriteOffset(43); topCritter._bodySprite.animation.add("sexy-misc", [ 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 57, 56, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 81, 81, 81, 81, 81, 80, 80, 81, 80, 80, 80, 81, 81, 80, 81, 80, 81, 81, 81, 81, 80, 80, 81, 80, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 72, 73, 73, 73, 73, 72, 73, 72, 73, 73, 73, 72, 72, 73, 73, 72, 73, 72, 73, 73, 73, 72, 73, 73, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } /** * args[0]: how many seconds it should take */ public function topPenetrate(args:Array<Dynamic>) { var bodyAnim:Array<Int> = []; var headAnim:Array<Int> = []; var frontBodyAnim:Array<Int> = []; while (bodyAnim.length < args[0] * 2) { bodyAnim.push(FlxG.random.getObject([58, 59])); headAnim.push(FlxG.random.getObject([84, 85])); frontBodyAnim.push(FlxG.random.getObject([50, 51])); } while (bodyAnim.length < args[0] * 4) { bodyAnim.push(FlxG.random.getObject([60, 61])); headAnim.push(FlxG.random.getObject([84, 85])); frontBodyAnim.push(FlxG.random.getObject([50, 51])); } for (i in 0...60) { bodyAnim.push(FlxG.random.getObject([62, 63])); headAnim.push(FlxG.random.getObject([82, 83])); frontBodyAnim.push(FlxG.random.getObject([50, 51])); } for (i in 0...6) { // restart the animation, just in case something strange happens bodyAnim.push(FlxG.random.getObject([60, 61])); headAnim.push(FlxG.random.getObject([84, 85])); frontBodyAnim.push(FlxG.random.getObject([50, 51])); } stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", bodyAnim, Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", headAnim, Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", frontBodyAnim, Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } /** * args[0]: int: how many humps * args[1]: int: how many seconds * args[2]: bool: eyes closed? * args[3]: bool: spanking? */ public function topHump(args:Array<Dynamic>) { var humpCount:Int = args[0]; var humpSeconds:Int = args[1]; var eyesClosed:Bool = args[2]; var spanking:Bool = args[3]; var spankFrame:Int = FlxG.random.int(0, 5); var targetFrameCount:Int = 0; var bodyAnim:Array<Int> = []; var headAnim:Array<Int> = []; var frontBodyAnim:Array<Int> = []; while (targetFrameCount < 60) { targetFrameCount += humpSeconds * 6; } while (bodyAnim.length < targetFrameCount) { var abc:Float = bodyAnim.length / 3 * (humpCount / humpSeconds) * Math.PI; var frame:Int; var pow:Float = 1; if (Math.sin(abc) < 0) { // pulling out (gentle) pow = 0.5; } else { // inserting (forceful) pow = 2; } var def:Float = Math.cos(abc) < 0 ? -Math.pow( -Math.cos(abc), pow) : Math.pow(Math.cos(abc), pow); frame = Math.round(def * 1.5 + 1.5); if (frame == 0) { bodyAnim.push(FlxG.random.getObject([56, 57])); } else if (frame == 1) { bodyAnim.push(FlxG.random.getObject([58, 59])); } else if (frame == 2) { bodyAnim.push(FlxG.random.getObject([60, 61])); } else { bodyAnim.push(FlxG.random.getObject([62, 63])); } headAnim.push(eyesClosed ? FlxG.random.getObject([84, 85]) : FlxG.random.getObject([82, 83])); frontBodyAnim.push(FlxG.random.getObject([50, 51])); } if (spanking) { // make bottom critter react... stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 53, 52, 52, 52, 52, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); var botHeadAnim:Array<Int> = [ 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, ]; // add top critter animation frames frontBodyAnim[spankFrame] = 65; frontBodyAnim[spankFrame + 1] = 67; frontBodyAnim[spankFrame + 2] = 69; for (i in spankFrame + 1...spankFrame + 4) { botHeadAnim[i] = FlxG.random.getObject([62, 63]); } for (i in spankFrame...spankFrame + 6) { if (bodyAnim[i] == 56 || bodyAnim[i] == 57) { bodyAnim[i] = 64; } else if (bodyAnim[i] == 58 || bodyAnim[i] == 59) { bodyAnim[i] = 66; } else if (bodyAnim[i] == 60 || bodyAnim[i] == 61) { bodyAnim[i] = 68; } else if (bodyAnim[i] == 62 || bodyAnim[i] == 63) { bodyAnim[i] = 70; } } for (i in spankFrame + 3...spankFrame + 6) { frontBodyAnim[i] = FlxG.random.getObject([48, 49]); } botCritter._headSprite.animation.add("sexy-misc", botHeadAnim, Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", bodyAnim, Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", headAnim, Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", frontBodyAnim, Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function botEyesOpen(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botLookBack(args:Array<Dynamic>) { botCritter._bodySprite.facing = facing; stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 72, 73, 73, 73, 73, 72, 73, 72, 73, 73, 73, 72, 72, 73, 73, 72, 73, 72, 73, 73, 73, 72, 73, 73, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botEyesClosed(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 63, 62, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 62, 63, 62, 62, 62, 62, 63, 63, 62, 63, 63, 63, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botOrgasm(args:Array<Dynamic>) { botCritter.jizzStamp(facing == FlxObject.LEFT ? 3 : -3, -3); stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 53, 52, 52, 52, 53, 53, 52, 53, 53, 52, 53, 53, 53, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 52, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 63, 62, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 62, 63, 62, 63, 62, 63, 62, 62, 63, 62, 63, 63, 63, 62, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function topOrgasm(args:Array<Dynamic>) { topCritter.jizzStamp(0, 3); stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", [ 62, 62, 63, 62, 63, 63, 63, 62, 62, 62, 63, 62, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 62, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 84, 84, 84, 85, 85, 85, 84, 85, 84, 84, 85, 84, 84, 85, 84, 85, 85, 85, 84, 84, 85, 85, 84, 85, 85, 84, 85, 82, 83, 83, 83, 82, 83, 83, 83, 82, 82, 83, 83, 82, 83, 82, 82, 82, 82, 83, 83, 83, 82, 83, 82, 82, 83, 82, 82, 83, 82, 83, 83, 83, 82, 82, 83, 83, 82, 83, 83, 82, 83, 83, 83, 82, 83, 82, 83, 82, 83, 83, 82, 83, 83, 83, 83, 82, 82, 83, 82, 83, 82, 83, 83, 82, 83, 83, 83, 83, 82, 82, 83, 82, 82, 83, 82, 82, 83, 82, 82, 82, 83, 83, 83, 83, 82, 83, 83, 83, 82, 82, 82, 82, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function topOrgasmPullOut(args:Array<Dynamic>) { topCritter.jizzStamp(0, 3); stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", [ 60, 58, 60, 62, 63, 62, 62, 62, 63, 62, 63, 63, 62, 62, 63, 62, 63, 63, 63, 62, 62, 62, 63, 62, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 62, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 85, 84, 85, 84, 84, 84, 84, 85, 84, 84, 85, 84, 84, 85, 84, 85, 85, 85, 84, 84, 85, 85, 84, 85, 85, 84, 85, 85, 85, 85, 83, 82, 83, 83, 83, 82, 82, 83, 83, 82, 83, 82, 82, 82, 82, 83, 83, 83, 82, 83, 82, 82, 83, 82, 82, 83, 82, 83, 83, 83, 82, 82, 83, 83, 82, 83, 83, 82, 83, 83, 83, 82, 83, 82, 83, 82, 83, 83, 82, 83, 83, 83, 83, 82, 82, 83, 82, 83, 82, 83, 83, 82, 83, 83, 83, 83, 82, 82, 83, 82, 82, 83, 82, 82, 83, 82, 82, 82, 83, 83, 83, 83, 82, 83, 83, 83, 82, 82, 82, 82, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 51, 51, 51, 72, 73, 74, 75, 50, 50, 50, 72, 73, 74, 75, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function topAlmostDone(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", [ 62, 62, 63, 60, 61, 61, 59, 58, 58, 56, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 57, 56, 57, 57, 57, 56, 56, 56, 59, 58, 60, 51, 62, 62, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 81, 80, 80, 80, 80, 81, 80, 81, 80, 80, 80, 81, 81, 80, 80, 81, 80, 81, 80, 80, 80, 81, 80, 80, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 51, 51, 51, 50, 50, 51, 50, 50, 50, 50, 50, 50, 50, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function topDone(args:Array<Dynamic>) { done(topCritter); } public function botDone(args:Array<Dynamic>) { done(botCritter); } public function runIntoPositionAndStartDoggy(args:Array<Dynamic>):Void { topCritter.runTo(jumpTarget.x, jumpTarget.y, critterStartDoggy); } public function jumpIntoPositionAndStartDoggy(args:Array<Dynamic>):Void { topCritter.jumpTo(jumpTarget.x, jumpTarget.y, 0, critterStartDoggy); } public function runToJump(args:Array<Dynamic>):Void { topCritter.runTo(jumpSource.x, jumpSource.y, SexyAnims.stayImmobile); } public function getExpectedRunToJumpDuration():Float { return IdleAnims.getProjectedTime(topCritter, topCritter._targetSprite.getPosition(), jumpSource); } public function rotateFromJumpTarget(degrees:Float, dist:Float):FlxPoint { var dx:Float = jumpTarget.x - botCritter._bodySprite.x; var dy:Float = jumpTarget.y - botCritter._bodySprite.y; if (dx == 0 && dy == 0) { // avoid divide by zero dx = 2; dy = 1; } var angleRadians:Float = Math.atan2(dy, dx); angleRadians += degrees * Math.PI / 180; var ex:Float = Math.cos(angleRadians) * dist + botCritter._bodySprite.x; var ey:Float = Math.sin(angleRadians) * dist + botCritter._bodySprite.y; return FlxPoint.get(ex, ey); } }
argonvile/monster
source/critter/SexyDoggy.hx
hx
unknown
17,236
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.math.FlxPoint; /** * An animation where a bunch of bugs take turns fucking the same bug */ class SexyGangBang extends SexyCritterAnim { private var botCritter:Critter; private var topCritters:Array<Critter>; private var watchCritters:Array<Critter>; public var eventTime:Float = 0.4; private var sexyMasturbates:Array<SexyMasturbate> = []; private var topEventsMap:Map<Critter, Array<EventStack.Event>> = new Map<Critter, Array<EventStack.Event>>(); private var botEventsMap:Map<Critter, Array<EventStack.Event>> = new Map<Critter, Array<EventStack.Event>>(); public function new(topCritters:Array<Critter>, botCritter:Critter, watchCritters:Array<Critter>) { super(); this.watchCritters = watchCritters; this.topCritters = topCritters; this.botCritter = botCritter; } public function go() { { var jumpTargetAngles:Array<Float> = [60, 120, 180, 240, 300]; FlxG.random.shuffle(jumpTargetAngles); var sexyDoggy0:SexyDoggy = new SexyDoggy(topCritters[0], botCritter); var initialWatchers:Array<Critter> = topCritters.slice(1, topCritters.length); initialWatchers = initialWatchers.concat(watchCritters); for (critter in initialWatchers) { var jumpSource:FlxPoint = sexyDoggy0.rotateFromJumpTarget(jumpTargetAngles.pop(), 50); var sexyMasturbate:SexyMasturbate = new SexyMasturbate(critter, botCritter._bodySprite.x < jumpSource.x ? FlxObject.LEFT : FlxObject.RIGHT); sexyMasturbates.push(sexyMasturbate); sexyMasturbate.runToAndMasturbate(jumpSource); } } var sexyRimming0:SexyRimming = new SexyRimming(topCritters[0], botCritter); { var _eventTime:Float = 0; botCritter._eventStack.addEvent({time:_eventTime, callback:sexyRimming0.botWaggle}); botCritter._eventStack.addEvent({time:_eventTime += 0.8, callback:sexyRimming0.botWait}); } for (topCritter in topCritters) { botCritter._eventStack.addEvent({time:eventTime - 0.1, callback:maybeNextGuysTurn, args:[topCritter]}); var sexyRimming:SexyRimming = new SexyRimming(topCritter, botCritter, sexyRimming0.facing); var sexyDoggy:SexyDoggy = new SexyDoggy(topCritter, botCritter, sexyRimming0.facing); var topEvents:Array<EventStack.Event> = []; var botEvents:Array<EventStack.Event> = []; if (topCritter == topCritters[0]) { topEvents.push({time:eventTime, callback:sexyDoggy.runToJump}); topEvents.push({time:eventTime += sexyDoggy.getExpectedRunToJumpDuration(), callback:sexyDoggy.jumpIntoPositionAndStartDoggy}); topEvents.push({time:eventTime += sexyRimming.getExpectedJumpDuration() + 0.2, callback:sexyDoggy.topPenetrate, args:[0.2]}); } else { topEvents.push({time:eventTime, callback:sexyDoggy.runIntoPositionAndStartDoggy}); topEvents.push({time:eventTime += 1.5, callback:sexyDoggy.topPenetrate, args:[1.5]}); } botEvents.push({time:eventTime, callback:sexyDoggy.botEyesClosed}); topEvents.push({time:eventTime += 2.5, callback:sexyDoggy.topHump, args:[1, 3, false]}); botEvents.push({time:eventTime + 0.66, callback:sexyDoggy.botEyesOpen, args:[1.5]}); topEvents.push({time:eventTime += FlxG.random.getObject([3, 6]), callback:sexyDoggy.topHump, args:[1, 2, false]}); topEvents.push({time:eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 4, false]}); var tenacity:Float = FlxG.random.float(0, 0.9); var spankiness:Int = FlxG.random.int( -60, 60); while (FlxG.random.float(0, 1) < tenacity && eventTime < 300) { // go again? topEvents.push({time:eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, false]}); topEvents.push({time:eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, false, FlxG.random.bool(30 + spankiness)]}); } topEvents.push({time:eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[3, 2, true]}); topEvents.push({time:eventTime += FlxG.random.getObject([2, 4, 6]), callback:sexyDoggy.topHump, args:[4, 2, true, FlxG.random.bool(40 + spankiness)]}); botEvents.push({time:eventTime + 1.66, callback:sexyDoggy.botOrgasm}); topEvents.push({time:eventTime += 4, callback:(FlxG.random.bool(30) ? sexyDoggy.topOrgasmPullOut : sexyDoggy.topOrgasm)}); topEvents.push({time:eventTime += 6.5, callback:sexyDoggy.topAlmostDone}); botEvents.push({time:eventTime += 1.0, callback:sexyDoggy.botLookBack}); topEvents.push({time:eventTime += 0.5, callback:SexyAnims.eventUnlinkCritters, args:[[topCritter]]}); botEvents.push({time:eventTime, callback:sexyDoggy.topDone}); eventTime += 0.4; // next guy's turn? topEventsMap[topCritter] = topEvents; botEventsMap[topCritter] = botEvents; } botCritter._eventStack.addEvent({time:eventTime - 0.1, callback:maybeNextGuysTurn, args:[null]}); // all critters; top, bottom, spectators var allCritters:Array<Critter> = [botCritter]; allCritters = allCritters.concat(topCritters); allCritters = allCritters.concat(watchCritters); SexyAnims.critterLinks[botCritter] = allCritters; { for (sexyMasturbate in sexyMasturbates) { var fuckTime:Float = 999999; var cumTime:Float = FlxG.random.float(sexyMasturbate.getExpectedRunDuration() + 0.4, eventTime + 5); if (topEventsMap[sexyMasturbate.critter] != null && topEventsMap[sexyMasturbate.critter].length > 0) { fuckTime = topEventsMap[sexyMasturbate.critter][0].time; // schedule a cum event far in the future; this keeps their event stack alive cumTime = 999999; } else { } var tenacity:Float = FlxG.random.float(0, 0.9); var eventTime:Float = cumTime - FlxG.random.float(8, 12); var timeCap:Float = 16; while (FlxG.random.float(0, 1) < tenacity && eventTime > 6) { if (eventTime > fuckTime - 10) { // fucking soon; don't add any masturbation events } else { if (!sexyMasturbate.critter.isMale() && FlxG.random.bool()) { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.cum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime + FlxG.random.float(6, 7), callback:sexyMasturbate.masturbate}); } else { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.almostCum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime + FlxG.random.float(5, 7), callback:sexyMasturbate.masturbate}); } } eventTime -= FlxG.random.float(8, timeCap); timeCap += 4; } sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:sexyMasturbate.cum}); // now that i've cum, i shouldn't depend on anybody, and they shouldn't depend on me sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:SexyAnims.eventUnlinkCritters, args:[[sexyMasturbate.critter]]}); sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:critterDone, args:[sexyMasturbate.critter]}); } } } public function maybeNextGuysTurn(args:Array<Dynamic>) { var topCritter:Critter = args[0]; if (topCritter == null || SexyAnims.critterLinks[botCritter].indexOf(topCritter) == -1) { // top critter was interrupted, or there aren't any more... animation should end botCritter._eventStack.addEvent({time:botCritter._eventStack._time + 0.1, callback:SexyAnims.eventUnlinkCritters, args:[[botCritter]]}); botCritter._eventStack.addEvent({time:botCritter._eventStack._time + 0.1, callback:botDone}); return; } SexyAnims.critterLinks[topCritter] = SexyAnims.critterLinks[botCritter].copy(); for (event in topEventsMap[topCritter]) { topCritter._eventStack.addEvent(event); } for (event in botEventsMap[topCritter]) { botCritter._eventStack.addEvent(event); } } public function botDone(args:Array<Dynamic>) { done(botCritter); } public function critterDone(args:Array<Dynamic>) { var critter:Critter = args[0]; done(args[0]); } }
argonvile/monster
source/critter/SexyGangBang.hx
hx
unknown
8,238
package critter; import flixel.FlxG; import flixel.math.FlxPoint; /** * An animation where a bug masturbates */ class SexyMasturbate extends SexyCritterAnim { public var critter:Critter; private var facing:Int; public function new(critter:Critter, facing:Int) { super(); this.critter = critter; this.facing = facing; } /** * Run to a specific place and masturbate. This is used in other more * complex animations, such as if a bug needs to warm up for something. Or * if have a sudden to masturbate at the combination pizza hut/taco bell on * 81st street, I guess. I haven't coded that part yet. * * @param point the point to run to */ public function runToAndMasturbate(point:FlxPoint) { critter.runTo(point.x, point.y, critterMasturbate); } public function critterMasturbate(critter:Critter) { masturbate(null); } public function masturbate(args:Array<Dynamic>) { critter._bodySprite.facing = facing; stopSexyAnim(critter); var bodyFrames:Array<Int> = []; var headFrames:Array<Int> = []; if (critter.isMale()) { AnimTools.push(bodyFrames, FlxG.random.int(30, 60), [32, 33]); } else { AnimTools.push(bodyFrames, FlxG.random.int(30, 60), [32, 31]); } AnimTools.push(headFrames, FlxG.random.int(30, 60), [48, 49]); critter._bodySprite.animation.add("sexy-misc", bodyFrames, Critter._FRAME_RATE, true); critter._headSprite.animation.add("sexy-misc", headFrames, Critter._FRAME_RATE, true); critter._frontBodySprite.animation.add("sexy-misc", [ 2, 2, ], Critter._FRAME_RATE, true); critter.playAnim("sexy-misc"); } /** * Almost cum, but stop and regain composure */ public function almostCum(args:Array<Dynamic>) { critter._bodySprite.facing = facing; stopSexyAnim(critter); if (critter.isMale()) { critter._bodySprite.animation.add("sexy-misc", [ 32, 32, 33, 33, 32, 32, 33, 32, 33, 32, 33, 32, // fast... 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, ], Critter._FRAME_RATE, true); } else { critter._bodySprite.animation.add("sexy-misc", [ 32, 32, 31, 31, 32, 32, 31, 32, 31, 32, 31, 32, // fast... 32, 32, 32, 32, 32, 32, // pause... 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, ], Critter._FRAME_RATE, true); } critter._headSprite.animation.add("sexy-misc", [ 48, 48, 48, 51, 51, 51, 51, 50, 51, 51, 50, 51, 51, 51, 51, 48, 49, 49, 49, 49, 48, 49, 48, 48, 48, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 48, 49, 49, 49, 49, 49, 48, 49, 48, 48, 48, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 48, 49, 49, 49, 49, 49, 48, 49, 48, 48, 48, 48, 49, 48, 49, 49, 49, 48, 48, 48, 48, 48, 49, 48, 48, 49, 49, 49, 49, 49, 48, 49, 48, 48, ], Critter._FRAME_RATE, true); critter._frontBodySprite.animation.add("sexy-misc", [ 2, 2, ], Critter._FRAME_RATE, true); critter.playAnim("sexy-misc"); } public function cum(args:Array<Dynamic>) { stopSexyAnim(critter); if (critter.isMale()) { critter._eventStack.addEvent({time:critter._eventStack._time + 4.4, callback:critter.eventJizzStamp, args:[ -28 * (critter._bodySprite.flipX ? -1 : 1), 6]}); critter._bodySprite.animation.add("sexy-misc", [ 32, 32, 33, 33, 32, 32, 33, 33, 32, 32, 33, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add("sexy-misc", [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, 35, 36, 37, 2, 2, 34, 35, 36, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); } else { critter._eventStack.addEvent({time:critter._eventStack._time + 4.1, callback:critter.eventJizzStamp, args:[ -6 * (critter._bodySprite.flipX ? -1 : 1), 4]}); critter._bodySprite.animation.add("sexy-misc", [ 32, 32, 31, 31, 32, 32, 31, 31, 32, 32, 31, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, ], Critter._FRAME_RATE, false); critter._frontBodySprite.animation.add("sexy-misc", [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 38, 39, 2, 2, 30, 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); } critter._headSprite.animation.add("sexy-misc", [ 48, 48, 49, 48, 49, 49, 49, 48, 48, 49, 49, 48, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 50, 51, 51, 51, 51, 50, 50, 51, 51, 51, 49, 50, 48, 49, 48, 48, 49, 48, 49, 49, ], Critter._FRAME_RATE, false); critter.playAnim("sexy-misc"); } public function getExpectedRunDuration():Float { return IdleAnims.getProjectedTime(critter, critter._soulSprite.getPosition(), critter._targetSprite.getPosition()); } }
argonvile/monster
source/critter/SexyMasturbate.hx
hx
unknown
6,771
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.math.FlxPoint; import poke.sexy.SexyState; /** * An animation where a bug gives oral sex to a whole bunch of bugs in a row */ class SexyMultiBlowJob extends SexyCritterAnim { private var watchCritters:Array<Critter>; private var topCritters:Array<Critter>; private var botCritter:Critter; public var eventTime:Float = 0.4; private var sexyMasturbates:Array<SexyMasturbate> = []; private var topEventsMap:Map<Critter, Array<EventStack.Event>> = new Map<Critter, Array<EventStack.Event>>(); private var botEventsMap:Map<Critter, Array<EventStack.Event>> = new Map<Critter, Array<EventStack.Event>>(); public function new(topCritters:Array<Critter>, botCritter:Critter, watchCritters:Array<Critter>) { super(); this.watchCritters = watchCritters; this.topCritters = topCritters; this.botCritter = botCritter; } public function go() { var masturbateCritters:Array<Critter> = []; masturbateCritters = masturbateCritters.concat(topCritters); masturbateCritters = masturbateCritters.concat(watchCritters); FlxG.random.shuffle(masturbateCritters); var masturbateCritterFacings:Map<Critter, Int> = new Map<Critter, Int>(); var masturbateCritterPositions:Map<Critter, FlxPoint> = new Map<Critter, FlxPoint>(); var jumpTargetAngles:Array<Float> = [0, 60, 120, 180, 240, 300]; FlxG.random.shuffle(jumpTargetAngles); var sexyDoggy0:SexyDoggy = new SexyDoggy(topCritters[0], botCritter); { var initialWatchers:Array<Critter> = topCritters.slice(1, topCritters.length); initialWatchers = initialWatchers.concat(watchCritters); for (critter in initialWatchers) { var jumpTargetAngle:Float = jumpTargetAngles.pop(); masturbateCritterPositions[critter] = sexyDoggy0.rotateFromJumpTarget(jumpTargetAngle, 50); masturbateCritterFacings[critter] = botCritter._bodySprite.x < masturbateCritterPositions[critter].x ? FlxObject.LEFT : FlxObject.RIGHT; } for (critter in initialWatchers) { var sexyMasturbate:SexyMasturbate = new SexyMasturbate(critter, masturbateCritterFacings[critter]); sexyMasturbates.push(sexyMasturbate); sexyMasturbate.runToAndMasturbate(masturbateCritterPositions[critter]); } } for (topCritter in topCritters) { botCritter._eventStack.addEvent({time:eventTime - 0.1, callback:maybeNextGuysTurn, args:[topCritter]}); var sexyBlowJob:SexyBlowJob; var topEvents:Array<EventStack.Event> = []; var botEvents:Array<EventStack.Event> = []; if (topCritter == topCritters[0]) { sexyBlowJob = new SexyBlowJob(topCritter, botCritter); topEvents.push({time:eventTime, callback:sexyBlowJob.topRunIntoPositionAndSitBack}); botEvents.push({time:eventTime += sexyBlowJob.getExpectedTopRunDuration() + FlxG.random.float(0, 0.7), callback:sexyBlowJob.botNotice}); topEvents.push({time:eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.startBj}); } else { sexyBlowJob = new SexyBlowJob(topCritter, botCritter, masturbateCritterFacings[topCritter]); topEvents.push({time:eventTime, callback:sexyBlowJob.refresh}); topEvents.push({time:eventTime, callback:sexyBlowJob.topPoint}); botEvents.push({time:eventTime += FlxG.random.float(0.2, 1.5), callback:sexyBlowJob.botNotice}); botEvents.push({time:eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botRunIntoPositionAndBlow}); eventTime += 0.5; } eventTime += FlxG.random.float(4, 12); var pausesWithHandOnHead:Bool = false; var pausesWithJerkingOff:Bool = false; for (i in 0...2) { if (FlxG.random.bool()) { pausesWithHandOnHead = true; } else { pausesWithJerkingOff = true; } } var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && eventTime < 300) { if (pausesWithHandOnHead && !pausesWithJerkingOff || (pausesWithHandOnHead && FlxG.random.bool())) { topEvents.push({time:eventTime += FlxG.random.float(2, 4), callback:sexyBlowJob.topHandOnHead}); topEvents.push({time:eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.topEyesClosed}); topEvents.push({time:eventTime += FlxG.random.float(3, 8), callback:sexyBlowJob.topHandOffHead}); topEvents.push({time:eventTime, callback:sexyBlowJob.topEyesHalfOpen}); } else { botEvents.push({time:eventTime += FlxG.random.float(3, 9), callback:sexyBlowJob.botJerkOff}); botEvents.push({time:eventTime += FlxG.random.float(1.5, 4.5), callback:sexyBlowJob.botBj}); } } topEvents.push({time:eventTime += FlxG.random.float(4, 8), callback:sexyBlowJob.topHandOnHead}); topEvents.push({time:eventTime += FlxG.random.float(0, 3.0), callback:sexyBlowJob.topEyesClosed}); if (FlxG.random.bool(40)) { // swallow it botEvents.push({time:eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSwallow}); botEvents.push({time:eventTime += FlxG.random.float(3, 7), callback:sexyBlowJob.botSitUp}); } else if (FlxG.random.bool(50)) { // squirt botEvents.push({time:eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); topEvents.push({time:eventTime, callback:sexyBlowJob.topOrgasm}); topEvents.push({time:eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); eventTime += FlxG.random.float(0, 2); } else { // squirt, but then swallow botEvents.push({time:eventTime += FlxG.random.float(0, 2.0), callback:sexyBlowJob.botSitUp}); topEvents.push({time:eventTime, callback:sexyBlowJob.topOrgasm}); botEvents.push({time:eventTime += FlxG.random.float(1, 3), callback:sexyBlowJob.botSwallow}); if (FlxG.random.bool()) { topEvents.push({time:eventTime += FlxG.random.getObject([0, 1]), callback:sexyBlowJob.topHandOnHeadSwallow}); } topEvents.push({time:eventTime += FlxG.random.float(3, 5), callback:sexyBlowJob.topEyesHalfOpen}); botEvents.push({time:eventTime += FlxG.random.float(0, 2), callback:sexyBlowJob.botSitUp}); } botEvents.push({time:eventTime, callback:SexyAnims.eventUnlinkCritters, args:[[topCritter]]}); topEvents.push({time:eventTime += 0.5, callback:sexyBlowJob.topDone}); eventTime += 0.4; // next guy's turn? topEventsMap[topCritter] = topEvents; botEventsMap[topCritter] = botEvents; } botCritter._eventStack.addEvent({time:eventTime - 0.1, callback:maybeNextGuysTurn, args:[null]}); // all critters; top, bottom, spectators var allCritters:Array<Critter> = [botCritter]; allCritters = allCritters.concat(topCritters); allCritters = allCritters.concat(watchCritters); SexyAnims.critterLinks[botCritter] = allCritters; { for (sexyMasturbate in sexyMasturbates) { var blowJobTime:Float = 999999; var cumTime:Float = FlxG.random.float(sexyMasturbate.getExpectedRunDuration() + 0.4, eventTime + 5); if (topEventsMap[sexyMasturbate.critter] != null && topEventsMap[sexyMasturbate.critter].length > 0) { blowJobTime = topEventsMap[sexyMasturbate.critter][0].time; // schedule a cum event far in the future; this keeps their event stack alive cumTime = 999999; } else { } var tenacity:Float = FlxG.random.float(0, 0.9); var eventTime:Float = cumTime - FlxG.random.float(8, 12); var timeCap:Float = 16; while (FlxG.random.float(0, 1) < tenacity && eventTime > 6) { if (eventTime > blowJobTime - 10) { // blowing soon; don't add any masturbation events } else { if (!sexyMasturbate.critter.isMale() && FlxG.random.bool()) { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.cum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime + FlxG.random.float(6, 7), callback:sexyMasturbate.masturbate}); } else { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.almostCum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime + FlxG.random.float(5, 7), callback:sexyMasturbate.masturbate}); } } eventTime -= FlxG.random.float(8, timeCap); timeCap += 4; } sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:sexyMasturbate.cum}); // now that i've cum, i shouldn't depend on anybody, and they shouldn't depend on me sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:SexyAnims.eventUnlinkCritters, args:[[sexyMasturbate.critter]]}); sexyMasturbate.critter._eventStack.addEvent({time:cumTime, callback:critterDone, args:[sexyMasturbate.critter]}); } } } public function maybeNextGuysTurn(args:Array<Dynamic>) { var topCritter:Critter = args[0]; if (topCritter == null || SexyAnims.critterLinks[botCritter].indexOf(topCritter) == -1) { // top critter was interrupted, or there aren't any more... animation should end botCritter._eventStack.addEvent({time:botCritter._eventStack._time + 0.1, callback:SexyAnims.eventUnlinkCritters, args:[[botCritter]]}); botCritter._eventStack.addEvent({time:botCritter._eventStack._time + 0.1, callback:botDone}); return; } SexyAnims.critterLinks[topCritter] = SexyAnims.critterLinks[botCritter].copy(); for (event in topEventsMap[topCritter]) { topCritter._eventStack.addEvent(event); } for (event in botEventsMap[topCritter]) { botCritter._eventStack.addEvent(event); } } public function botDone(args:Array<Dynamic>) { done(botCritter); } public function critterDone(args:Array<Dynamic>) { var critter:Critter = args[0]; done(args[0]); } }
argonvile/monster
source/critter/SexyMultiBlowJob.hx
hx
unknown
9,902
package critter; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.math.FlxPoint; /** * An animation where two bugs masturbate with each other */ class SexyMutualMasturbate extends SexyCritterAnim { private var critters:Array<Critter>; private var sexyMasturbates:Array<SexyMasturbate> = []; public function new(critters:Array<Critter>) { super(); this.critters = critters; } public function go(doFinish:Bool = true, movable:Bool = true):Float { var bigFinish:Bool = FlxG.random.bool(20); if (!doFinish) { // critters aren't cumming; just keep them doing stuff bigFinish = false; } var positions:Array<FlxPoint>; var facings:Array<Int>; if (FlxG.random.bool()) { positions = [ FlxPoint.get(critters[0]._soulSprite.x + 0, critters[0]._soulSprite.y + 0), FlxPoint.get(critters[0]._soulSprite.x + 40, critters[0]._soulSprite.y + FlxG.random.int(-10, 30)), FlxPoint.get(critters[0]._soulSprite.x + -40, critters[0]._soulSprite.y + FlxG.random.int(-10, 30)), FlxPoint.get(critters[0]._soulSprite.x + 80, critters[0]._soulSprite.y + FlxG.random.int(-20, 60)), ]; facings = [ FlxObject.RIGHT, FlxObject.LEFT, FlxObject.RIGHT, FlxObject.LEFT, ]; } else { positions = [ FlxPoint.get(critters[0]._soulSprite.x + 0, critters[0]._soulSprite.y + 0), FlxPoint.get(critters[0]._soulSprite.x + -40, critters[0]._soulSprite.y + FlxG.random.int(-10, 30)), FlxPoint.get(critters[0]._soulSprite.x + 40, critters[0]._soulSprite.y + FlxG.random.int(-10, 30)), FlxPoint.get(critters[0]._soulSprite.x + -80, critters[0]._soulSprite.y + FlxG.random.int(-20, 60)), ]; facings = [ FlxObject.LEFT, FlxObject.RIGHT, FlxObject.LEFT, FlxObject.RIGHT, ]; } var bigFinishTime:Float = 99999; for (i in 0...critters.length) { var sexyMasturbate = new SexyMasturbate(critters[i], facings[i]); sexyMasturbate.runToAndMasturbate(positions[i]); var eventTime:Float = 0; eventTime += sexyMasturbate.getExpectedRunDuration(); if (movable) { sexyMasturbate.critter._eventStack.addEvent({time:eventTime + 0.3, callback:eventMakeCritterMovable, args:[critters[i]]}); } var tenacity:Float = FlxG.random.float(0, 0.9); while (FlxG.random.float(0, 1) < tenacity && eventTime < bigFinishTime - 8) { eventTime += FlxG.random.float(2, 8); if (!sexyMasturbate.critter.isMale() && FlxG.random.bool()) { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.cum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime += FlxG.random.float(6, 7), callback:sexyMasturbate.masturbate}); } else { sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.almostCum}); sexyMasturbate.critter._eventStack.addEvent({time:eventTime += FlxG.random.float(5, 7), callback:sexyMasturbate.masturbate}); } } if (doFinish) { if (bigFinish) { if (i == 0) { while (eventTime < 10) { eventTime += FlxG.random.float(4, 24); } bigFinishTime = eventTime; } else { eventTime = Math.max(bigFinishTime, eventTime) + FlxG.random.float(-1, 1); } } else { while (eventTime < 10) { eventTime += FlxG.random.float(4, 24); } } sexyMasturbate.critter._eventStack.addEvent({time:eventTime, callback:sexyMasturbate.cum}); } else { if (i == 0) { while (eventTime < 10) { eventTime += FlxG.random.float(4, 24); } bigFinishTime = eventTime; } } } return bigFinishTime; } public function eventMakeCritterMovable(args:Array<Dynamic>) { var critter:Critter = args[0]; critter.setImmovable(false); } }
argonvile/monster
source/critter/SexyMutualMasturbate.hx
hx
unknown
3,956
package critter; import flixel.FlxObject; import flixel.math.FlxPoint; /** * An animation where a bug rims/eats out the other bug */ class SexyRimming extends SexyCritterAnim { public static var JUMP_DIST:Float = 60; private var topCritter:Critter; // the critter doing the rimming private var botCritter:Critter; // the critter being rimmed public var facing:Int; private var jumpTarget:FlxPoint; // if the top were to jump, this is where he'd jump to private var jumpSource:FlxPoint; // if the top were to jump, this is where he'd jump from public function new(topCritter:Critter, botCritter:Critter, ?facing:Int = 0) { super(); this.topCritter = topCritter; this.botCritter = botCritter; this.facing = facing; refresh(null); } public function refresh(args:Array<Dynamic>) { if (facing == 0) { facing = topCritter._bodySprite.x > botCritter._bodySprite.x ? FlxObject.LEFT : FlxObject.RIGHT; } jumpTarget = FlxPoint.get(botCritter._targetSprite.x + (facing == FlxObject.LEFT ? 18 : -18), botCritter._targetSprite.y - 9); var dx:Float = topCritter._bodySprite.x - jumpTarget.x; var dy:Float = topCritter._bodySprite.y - jumpTarget.y; if (dx == 0 && dy == 0) { // avoid divide by zero dx = 2; dy = 1; } var ex:Float = JUMP_DIST * dx / Math.sqrt(dx * dx + dy * dy); var ey:Float = JUMP_DIST * dy / Math.sqrt(dx * dx + dy * dy); jumpSource = FlxPoint.get(botCritter._targetSprite.x + ex, botCritter._targetSprite.y + ey); } public function critterPokeSnout(critter:Critter) { pokeSnout(null); } public function pokeSnout(args:Array<Dynamic>) { topCritter._bodySprite.facing = facing; stopSexyAnim(topCritter); topCritter._bodySprite.animation.add("sexy-misc", [ 40, 41, 40, 40, 41, 40, 40, 40, 41, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 40, 40, 40, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 56, 62, 62, 56, 57, 57, 57, 63, 56, 63, 63, 56, 63, 56, 57, 56, 57, 57, 57, 62, 62, 62, 56, 62, 63, 57, 57, 57, 62, 62, 62, 63, 57, 57, 57, 63, 56, 63, 56, 63, 62, 57, 62, 57, 63, 57, 56, 57, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function botNotice(args:Array<Dynamic>) { botCritter._bodySprite.facing = facing; stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 0, 0 ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 65, 65, 65, 65, 64, 65, 64, 65, 65, 65, 64, 64, 64, 65, 65, 65, 64, 64, 65, 65, 64, 65, 64, 65, ], Critter._FRAME_RATE, true); botCritter._frontBodySprite.animation.add("sexy-misc", [ 45, 45, 2, 2, 2, 2, ], Critter._FRAME_RATE, false); botCritter.playAnim("sexy-misc"); } /** * args[0]: if true, top repositions. otherwise, bottom repositions */ public function startRim(args:Array<Dynamic>) { topCritter._bodySprite.facing = facing; botCritter._bodySprite.facing = facing; var topShouldReposition:Bool = args == null ? false : args[0]; if (topShouldReposition) { topCritter.resetFrontBodySprite(); // reset front body sprite, just in case we were standing up or something topCritter.setPosition(botCritter._bodySprite.x + (facing == FlxObject.LEFT ? 12 : -12), botCritter._bodySprite.y - 6); } else { botCritter.setPosition(topCritter._bodySprite.x + (facing == FlxObject.LEFT ? -12 : 12), topCritter._bodySprite.y + 6); } stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(7); topCritter._bodySprite.animation.add("sexy-misc", [ 43, 42, 42, 43, 42, 43, 43, 43, 43, 42, 43, 42, 43, 42, 42, 42, 42, 42, 43, 43, 43, 42, 42, 43, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 60, 58, 59, 61, 59, 61, 59, 58, 59, 61, 59, 58, 59, 58, 60, 58, 59, 59, 58, 60, 59, 61, 58, 59, 58, 58, 60, 59, 60, 59, 61, 58, 61, 58, 61, 58, 59, 58, 61, 61, 59, 58, 58, 60, 58, 58, 58, 58, 61, 59, 59, 61, 61, 61, 60, 58, 58, 58, 60, 61, 61, 59, 58, 61, 60, 59, 61, 58, 61, 60, 59, 60, 58, 58, 58, 61, 61, 61, 60, 60, 61, 60, 61, 58, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 44, 44 ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function critterStartRim(critter:Critter) { startRim(null); botEyesOpen(null); } public function topEyesOpen(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(7); topCritter._bodySprite.animation.add("sexy-misc", [ 43, 42, 42, 43, 42, 43, 43, 43, 43, 42, 43, 42, 43, 42, 42, 42, 42, 42, 43, 43, 43, 42, 42, 43, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 60, 58, 59, 61, 59, 61, 59, 58, 59, 61, 59, 58, 59, 58, 60, 58, 59, 59, 58, 60, 59, 61, 58, 59, 58, 58, 60, 59, 60, 59, 61, 58, 61, 58, 61, 58, 59, 58, 61, 61, 59, 58, 58, 60, 58, 58, 58, 58, 61, 59, 59, 61, 61, 61, 60, 58, 58, 58, 60, 61, 61, 59, 58, 61, 60, 59, 61, 58, 61, 60, 59, 60, 58, 58, 58, 61, 61, 61, 60, 60, 61, 60, 61, 58, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 44, 44 ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function topEyesClosed(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(7); topCritter._bodySprite.animation.add("sexy-misc", [ 43, 42, 42, 43, 42, 43, 43, 43, 43, 42, 43, 42, 43, 42, 42, 42, 42, 42, 43, 43, 43, 42, 42, 43, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 67, 69, 69, 66, 69, 66, 69, 68, 66, 68, 66, 69, 68, 67, 69, 69, 69, 68, 66, 68, 66, 68, 66, 67, 68, 68, 68, 66, 67, 67, 69, 66, 68, 68, 66, 66, 66, 68, 67, 68, 69, 67, 66, 67, 69, 67, 66, 69, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 44, 44 ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function botEyesOpen(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 47, 47, 47, 46, 46, 46, 46, 47, 46, 46, 46, 47, 46, 47, 46, 47, 47, 47, 47, 47, 47, 47, 47, 46, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 54, 54, 55, 54, 55, 55, 55, 54, 55, 55, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 55, 55, 54, 54, 54, 54, 55, 54, 55, 55, 54, 54, 55, 55, 55, 54, 54, 55, 54, 55, 54, 55, 54, 55, 55, 55, 54, 54, 54, 54, 54, 55, 54, 55, 55, 54, 54, 55, 54, 54, 55, 55, 54, 54, 54, 54, 54, 55, 55, 55, 54, 54, 54, 55, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botEyesClosed(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 47, 47, 47, 46, 46, 46, 46, 47, 46, 46, 46, 47, 46, 47, 46, 47, 47, 47, 47, 47, 47, 47, 47, 46, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 63, 62, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 62, 63, 62, 62, 62, 62, 63, 63, 62, 63, 63, 63, 62, 62, 63, 63, 63, 62, 63, 62, 63, 62, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 63, 62, 63, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botOrgasm(args:Array<Dynamic>) { botCritter.jizzStamp(facing == FlxObject.LEFT ? 6 : -6, -3); stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 47, 47, 47, 46, 46, 46, 46, 47, 46, 46, 46, 47, 46, 47, 46, 47, 47, 47, 47, 47, 47, 47, 47, 46, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 63, 62, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 63, 54, 63, 55, 55, 54, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 55, 54, 55, 55, 55, 54, 55, 54, 55, 54, 54, 54, 55, 55, 55, 54, 55, 55, 54, 55, 54, 55, ], Critter._FRAME_RATE, false); botCritter.playAnim("sexy-misc"); } public function topStop(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.setFrontBodySpriteOffset(7); topCritter._bodySprite.animation.add("sexy-misc", [ 43, 42, 42, 43, 42, 43, 43, 43, 43, 42, 43, 42, 43, 42, 42, 42, 42, 42, 43, 43, 43, 42, 42, 43, ], Critter._FRAME_RATE, true); topCritter._headSprite.animation.add("sexy-misc", [ 58, 59, 59, 58, 59, 59, 58, 58, 58, 58, 58, 58, 59, 58, 58, 59, 59, 59, 59, 59, 58, 59, 58, 59, ], Critter._FRAME_RATE, true); topCritter._frontBodySprite.animation.add("sexy-misc", [ 44, 44, ], Critter._FRAME_RATE, true); topCritter.playAnim("sexy-misc"); } public function botWaggle(args:Array<Dynamic>) { botCritter._bodySprite.facing = facing; stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 54, 55, 54, 55, 54, 55, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 72, 72, 73, 72, 72, 73, 72, 72, 72, 73, 72, 73, 73, 72, 72, 73, 73, 72, 73, 72, 72, 73, 73, 73, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function botWait(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter._bodySprite.animation.add("sexy-misc", [ 47, 46, 46, 47, 47, 47, 46, 46, 47, 46, 46, 46, 47, 47, 46, 46, 46, 47, 47, 46, 46, 47, 47, 47, ], Critter._FRAME_RATE, true); botCritter._headSprite.animation.add("sexy-misc", [ 73, 72, 72, 73, 73, 72, 73, 72, 72, 73, 73, 73, 72, 72, 73, 72, 72, 73, 72, 72, 72, 73, 72, 73, ], Critter._FRAME_RATE, true); botCritter.playAnim("sexy-misc"); } public function topDone(args:Array<Dynamic>) { done(topCritter); } public function topDoneForNow(args:Array<Dynamic>) { stopSexyAnim(topCritter); topCritter.runTo(botCritter._bodySprite.x + (facing == FlxObject.LEFT ? 24 : -24), botCritter._bodySprite.y + 6, SexyAnims.stayImmobile); } public function botDoneForNow(args:Array<Dynamic>) { stopSexyAnim(botCritter); botCritter.playAnim("sexy-idle"); } public function botDone(args:Array<Dynamic>) { done(botCritter); } public function runIntoPositionAndPokeSnout(args:Array<Dynamic>):Void { topCritter.runTo(jumpTarget.x, jumpTarget.y, critterPokeSnout); } public function runIntoPositionAndRim(args:Array<Dynamic>):Void { topCritter.runTo(jumpTarget.x, jumpTarget.y, critterStartRim); } public function runToJump(args:Array<Dynamic>):Void { topCritter.runTo(jumpSource.x, jumpSource.y, SexyAnims.stayImmobile); } public function jumpIntoPositionAndRim(args:Array<Dynamic>):Void { topCritter.jumpTo(jumpTarget.x, jumpTarget.y, 0, critterStartRim); } public function getExpectedJumpDuration():Float { return JUMP_DIST / topCritter._bodySprite._jumpSpeed; } public function getExpectedRunDuration():Float { return IdleAnims.getProjectedTime(topCritter, topCritter._soulSprite.getPosition(), topCritter._targetSprite.getPosition()); } public function getExpectedRunToJumpDuration():Float { return IdleAnims.getProjectedTime(topCritter, topCritter._targetSprite.getPosition(), jumpSource); } }
argonvile/monster
source/critter/SexyRimming.hx
hx
unknown
12,268
package critter; import critter.Critter; import flixel.FlxSprite; /** * An object which contains zero or one bugs. This can be a holopad or a clue * cell, for example. */ class SingleCritterHolder extends CritterHolder { public var _critter(get, set):Critter; public function new(X:Float, Y:Float) { super(X, Y); } override public function holdCritter(critter:Critter) { if (_critter == null) { _critters.splice(0, _critters.length); super.holdCritter(critter); } } function get__critter() { return _critters[0]; } function set__critter(critter:Critter):Critter { removeCritter(_critter); if (critter != null) { addCritter(critter); } return critter; } }
argonvile/monster
source/critter/SingleCritterHolder.hx
hx
unknown
746
package demo; import flixel.FlxState; import flixel.text.FlxText; /** * A demo which shows passwords being scrambled and unscrambled. */ class BinaryStringTest extends FlxState { var textY:Int = 0; public function new() { super(); } override public function create():Void { super.create(); // hash/unhash { var b:BinaryString = BinaryString.fromAlphanumeric("3LL"); var original:String = b.toAlphanumeric(3); b.hash("HG"); var hashed:String = b.toAlphanumeric(3); b.hash("HG"); var unhashed:String = b.toAlphanumeric(3); addText(original + " -> " + hashed + " -> " + unhashed); } // readInt { var b:BinaryString = new BinaryString(); b.writeInt(6, 3); b.writeInt(14, 4); b.writeInt(25, 5); addText(b.readInt(3) + "=6 " + b.readInt(4) + "=14 " + b.readInt(5) + "=25"); } // shuffle/unshuffle { addText(BinaryString.shuffle("ABCDEF") + "=ABECDF"); addText(BinaryString.shuffle("ABCDEFG") + "=DFACGEB"); addText(BinaryString.shuffle("ABCDEFGH") + "=HFADCGEB"); addText(BinaryString.shuffle("ABCDEFGHI") + "=FDCHBIGEA"); addText(BinaryString.shuffle("ABCDEFGHIJ") + "=AJDFHCIBEG"); addText(BinaryString.unshuffle("ABECDF") + "=ABCDEF"); addText(BinaryString.unshuffle("DFACGEB") + "=ABCDEFG"); addText(BinaryString.unshuffle("HFADCGEB") + "=ABCDEFGH"); addText(BinaryString.unshuffle("FDCHBIGEA") + "=ABCDEFGHI"); addText(BinaryString.unshuffle("AJDFHCIBEG") + "=ABCDEFGHIJ"); } // alphanumeric/binarystring { var b0:BinaryString = new BinaryString(); b0.writeInt(6, 3); b0.writeInt(14, 4); b0.writeInt(25, 5); addText("toAlphanumeric: " + b0.toAlphanumeric(10)); var alphanumeric:String = b0.toAlphanumeric(10); var b1:BinaryString = BinaryString.fromAlphanumeric(alphanumeric); addText(b1.readInt(3) + "=6 " + b1.readInt(4) + "=14 " + b1.readInt(5) + "=25"); } } function addText(s:String):Void { add(new FlxText(0, textY, 0, s)); textY += 12; } }
argonvile/monster
source/demo/BinaryStringTest.hx
hx
unknown
2,063
package demo; import flash.display.BitmapData; import flash.display.Sprite; import flash.geom.Point; import flash.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.math.FlxPoint; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; /** * A debug tool for masking different parts of an image, such as for deciding * which parts of Grovyle's sprites should be in shadow during the intro. * * A -> flag a color for masking * B -> flag a color for masking * SPACE -> print all masked colors */ class ColoringDebugState extends FlxState { var oldMousePosition:FlxPoint; var newMousePosition:FlxPoint; var sprite:FlxSprite; var spritePoint:FlxPoint; var overlaySprite:FlxSprite; var cursorSprite:FlxSprite; var colorMapping:Map<FlxColor, String> = new Map<FlxColor, String>(); var FIDELITY:Int = 2; public function new() { super(); } override public function create():Void { super.create(); sprite = new FlxSprite(0, 0); sprite.loadGraphic(AssetPaths.critter_heads_0__png); sprite.scale.x = FIDELITY; sprite.scale.y = FIDELITY; sprite.updateHitbox(); add(sprite); sprite.screenCenter(); spritePoint = sprite.getPosition(); sprite.x = Math.round(spritePoint.x / FIDELITY) * FIDELITY; sprite.y = Math.round(spritePoint.y / FIDELITY) * FIDELITY; overlaySprite = new FlxSprite(0, 0); overlaySprite.makeGraphic(sprite.pixels.width, sprite.pixels.height, FlxColor.TRANSPARENT); overlaySprite.scale.x = FIDELITY; overlaySprite.scale.y = FIDELITY; overlaySprite.updateHitbox(); add(overlaySprite); cursorSprite = new FlxSprite(0, 0); cursorSprite.loadGraphic(new BitmapData(6 * FIDELITY, FIDELITY), true, FIDELITY, FIDELITY, true); FlxSpriteUtil.drawRect(cursorSprite, 0 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.RED); FlxSpriteUtil.drawRect(cursorSprite, 1 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.ORANGE); FlxSpriteUtil.drawRect(cursorSprite, 2 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.YELLOW); FlxSpriteUtil.drawRect(cursorSprite, 3 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.GREEN); FlxSpriteUtil.drawRect(cursorSprite, 4 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.BLUE); FlxSpriteUtil.drawRect(cursorSprite, 5 * FIDELITY, 0, FIDELITY, FIDELITY, FlxColor.PURPLE); cursorSprite.animation.add("default", [0, 1, 2, 3, 4, 5], 30); cursorSprite.animation.play("default"); add(cursorSprite); oldMousePosition = FlxG.mouse.getPosition(); } override public function update(elapsed:Float):Void { super.update(elapsed); newMousePosition = FlxG.mouse.getPosition(newMousePosition); cursorSprite.setPosition(Math.round((newMousePosition.x - FIDELITY * 0.5) / FIDELITY) * FIDELITY, Math.round((newMousePosition.y - FIDELITY * 0.5) / FIDELITY) * FIDELITY); if (FlxG.mouse.pressed) { spritePoint.add(newMousePosition.x, newMousePosition.y); spritePoint.subtract(oldMousePosition.x, oldMousePosition.y); sprite.x = Math.round(spritePoint.x / FIDELITY) * FIDELITY; sprite.y = Math.round(spritePoint.y / FIDELITY) * FIDELITY; } if (FlxG.keys.justPressed.A || FlxG.keys.justPressed.B || FlxG.keys.justPressed.C || FlxG.keys.justPressed.D || FlxG.keys.justPressed.E || FlxG.keys.justPressed.F) { var pixelPoint:FlxPoint = FlxPoint.get(cursorSprite.x, cursorSprite.y); pixelPoint.subtract(sprite.x, sprite.y); pixelPoint.x /= FIDELITY; pixelPoint.y /= FIDELITY; var sourceColor:FlxColor = sprite.pixels.getPixel32(Std.int(pixelPoint.x), Std.int(pixelPoint.y)); pixelPoint.put(); var targetColor:FlxColor; if (FlxG.keys.justPressed.A) { targetColor = 0xffadd8e6; // light blue colorMapping[sourceColor] = "0xAAAAAAAA"; trace("A: " + StringTools.hex(sourceColor)); } else if (FlxG.keys.justPressed.B) { targetColor = 0xff191970; // midnight blue colorMapping[sourceColor] = "0xBBBBBBBB"; trace("B: " + StringTools.hex(sourceColor)); } else if (FlxG.keys.justPressed.B) { targetColor = 0xffe6add8; // light red colorMapping[sourceColor] = "0xCCCCCCCC"; trace("C: " + StringTools.hex(sourceColor)); } else if (FlxG.keys.justPressed.B) { targetColor = 0xff701919; // midnight red colorMapping[sourceColor] = "0xDDDDDDDD"; trace("D: " + StringTools.hex(sourceColor)); } else if (FlxG.keys.justPressed.B) { targetColor = 0xffd8e6ad; // light green colorMapping[sourceColor] = "0xEEEEEEEE"; trace("E: " + StringTools.hex(sourceColor)); } else { targetColor = 0xff197019; // midnight green colorMapping[sourceColor] = "0xFFFFFFFF"; trace("F: " + StringTools.hex(sourceColor)); } overlaySprite.pixels.threshold(sprite.pixels, new Rectangle(0, 0, sprite.width, sprite.height), new Point(0, 0), '==', sourceColor, targetColor); overlaySprite.dirty = true; } if (FlxG.keys.justPressed.SPACE) { for (key in colorMapping.keys()) { trace("colorMapping[0x" + StringTools.hex(key) + "] = " + colorMapping[key] + ";"); } } overlaySprite.x = sprite.x; overlaySprite.y = sprite.y; oldMousePosition.copyFrom(newMousePosition); } }
argonvile/monster
source/demo/ColoringDebugState.hx
hx
unknown
5,304
package demo; import critter.Critter; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.text.FlxText; import flixel.util.FlxDestroyUtil; import minigame.scale.ScaleGameState; import minigame.stair.StairGameState; import minigame.tug.TugGameState; import openfl.system.System; import poke.abra.AbraBeadWindow; import poke.abra.AbraSexyState; import poke.abra.AbraWindow; import poke.buiz.BuizelSexyState; import poke.grim.GrimerSexyState; import poke.grov.GrovyleSexyState; import poke.hera.HeraSexyState; import poke.kecl.KecleonWindow; import poke.magn.MagnSexyState; import poke.rhyd.RhydonBeadWindow; import poke.rhyd.RhydonSexyState; import poke.sand.SandslashResource; import poke.sand.SandslashSexyState; import poke.sand.SandslashWindow; import poke.sexy.WordManager; import poke.smea.SmeargleSexyState; import puzzle.PuzzleState; /** * A demo which initializes a given FlxState over and over and checks for * memory leaks. This is useful for figuring out if you're not destroying * objects correctly, which was an issue in earlier versions of the game. */ class MemLeakState extends FlxState { private var checking:Dynamic = null; private var trialCount:Int = 0; private var totalMemoryConsumed:Float = 0; private var startMemoryConsumed:Float = 0; private var trialLabel:FlxText = new FlxText(0, 0, 0, null, 16); private var avgMemoryLabel:FlxText = new FlxText(0, 20, 0, null, 16); private var finalMemoryLabel:FlxText = new FlxText(0, 40, 0, null, 16); private var eventStack:EventStack = new EventStack(); override public function create():Void { Main.overrideFlxGDefaults(); Critter.initialize(); add(trialLabel); add(avgMemoryLabel); add(finalMemoryLabel); } override public function update(elapsed:Float):Void { super.update(elapsed); eventStack.update(elapsed); if (checking != null) { var oldMemory = System.totalMemory; doIt(checking); var memoryConsumed = System.totalMemory - oldMemory; totalMemoryConsumed += memoryConsumed; trialCount++; trialLabel.text = "Trials: " + trialCount; avgMemoryLabel.text = "Avg memory: " + MmStringTools.commaSeparatedNumber(Std.int(totalMemoryConsumed / trialCount)); } finalMemoryLabel.text = "Final memory consumed: " + MmStringTools.commaSeparatedNumber(Std.int((System.totalMemory - startMemoryConsumed) / trialCount)); var clazzUnderTest = OptionsMenuState; if (FlxG.keys.justPressed.O) { doIt(clazzUnderTest); trialCount = 1; totalMemoryConsumed = 0; } if (FlxG.keys.justPressed.P) { startCheck(clazzUnderTest); } } private function startCheck(clazz:Dynamic) { eventStack.reset(); var time:Float = eventStack._time; // execute once, so we ignore one-time memory stuff startMemoryConsumed = System.totalMemory; trialCount = 0; totalMemoryConsumed = 0; checking = clazz; // run for awhile, then fire off garbage collection and end trails... eventStack.addEvent({time:time+=5.0, callback:finishTrials }); } public function finishTrials(args:Array<Dynamic>) { checking = null; } private function doIt(clazz:Dynamic) { var c = Type.createInstance(clazz, []); if (Std.isOfType(c, FlxState)) { var flxState:FlxState = cast(c, FlxState); flxState.create(); } c = FlxDestroyUtil.destroy(c); } }
argonvile/monster
source/demo/MemLeakState.hx
hx
unknown
3,441
package demo; import flash.utils.ByteArray; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import poke.buiz.BuizelSexyState; import poke.grim.GrimerSexyState; import poke.grov.GrovyleSexyState; import poke.hera.HeraSexyState; import openfl.display.BlendMode; import openfl.geom.Rectangle; import poke.luca.LucarioSexyState; import poke.sand.SandslashSexyState; import poke.smea.SmeargleSexyState; /** * A demo for creating and exporting coordinates, vectors and polygons for the * sex scenes. Change this to extend the Pokemon SexyState of your choice, and * use the following keys to print diagnostic information which you can paste * back into the SexyState code as necessary * * SPACE: select a body part * [, ] : toggle body part frame * shift+[, ] : toggle body part alpha * CLICK: draw points to define an area of that body part * ENTER: print the corresponding points to output * BKSP: remove a point * ESC: clear points * * C: show some encouragement text, 'ooh' 'mmm' * P: toggle cumshot * SPACE: select the penis/head * [, ] : toggle penis/head frame * CLICK: click the urethra/mouth * CLICK: click a point behind the urethra/mouth * ENTER: print the corresponding points to output * BKSP: remove a point * ESC: clear points */ class SexyDebugState extends SmeargleSexyState { var canvas:BouncySprite; var points:Array<FlxPoint>; var touchedPart:BouncySprite; public static var debug:Bool = false; override public function create():Void { debug = true; super.create(); FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; canvas = new BouncySprite(0, 0, 0, 0, 0); canvas.alpha = 0.7; canvas.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); add(canvas); points = []; _dialogger.skip(); } override public function update(elapsed:Float):Void { super.update(elapsed); if (FlxG.mouse.justPressed) { /* * SexyState explicitly makes the cursor invisible sometimes; but * when debugging, we need to counteract this */ FlxG.mouse.useSystemCursor = true; FlxG.mouse.visible = true; } _cSatellite.setPosition(FlxG.mouse.x, FlxG.mouse.y); if (FlxG.keys.justPressed.ZERO) { if (touchedPart != null) { touchedPart.alpha = 0.1; } } if (FlxG.keys.justPressed.FIVE) { if (touchedPart != null) { touchedPart.alpha = 0.5; } } if (FlxG.keys.justPressed.ONE) { if (touchedPart != null) { touchedPart.alpha = 1.0; } } if (FlxG.keys.justPressed.C) { emitWords(encouragementWords, 0, 0); } if (FlxG.mouse.justPressed) { var minDist:Float = FlxG.width; for (_cameraButton in _pokeWindow._cameraButtons) { var buttonPoint:FlxPoint = FlxPoint.get(_pokeWindow.x + _cameraButton.x + 14, _pokeWindow.y + _cameraButton.y + 14); var dist:Float = buttonPoint.distanceTo(FlxG.mouse.getPosition()); buttonPoint.put(); minDist = Math.min(dist, minDist); } if (minDist <= 30) { // clicking camera button } else if (touchedPart != null) { var point:FlxPoint = FlxG.mouse.getScreenPosition(); point.x += touchedPart.offset.x - touchedPart.x; point.y += touchedPart.offset.y - touchedPart.y; points.push(point); } } if (FlxG.keys.justPressed.BACKSPACE) { if (points.length > 0) { points.pop(); } } if (FlxG.keys.justPressed.SPACE) { touchedPart = getTouchedPart(); if (touchedPart != null) { touchedPart.blend = BlendMode.INVERT; canvas.synchronize(touchedPart); canvas.y = 0; canvas.x = 0; } } if (FlxG.keys.justReleased.SPACE) { if (touchedPart != null) { touchedPart.blend = BlendMode.NORMAL; } } if (FlxG.keys.justPressed.RBRACKET || FlxG.keys.justPressed.LBRACKET) { if (touchedPart != null) { if (FlxG.keys.pressed.SHIFT) { if (touchedPart.alpha == 1.0) { touchedPart.alpha = 0.3; } else { touchedPart.alpha = 1.0; } } var dir = FlxG.keys.justPressed.RBRACKET ? 1 : touchedPart.frames.numFrames - 1; do { touchedPart.animation.frameIndex = (touchedPart.animation.frameIndex + dir) % touchedPart.frames.numFrames; touchedPart.animation.pause(); } while (isBlank(touchedPart)); trace("Switched to frame index ", touchedPart.animation.frameIndex); } } if (FlxG.keys.justPressed.ENTER) { if (touchedPart != null) { if (points.length <= 3 && touchedPart == getSpoogeSource()) { var velocity:Float = 260; var output:String = "dickAngleArray"; output += "[" + touchedPart.animation.frameIndex + "] = ["; var tmpPoints:Array<FlxPoint> = new Array<FlxPoint>(); for (point in points) { tmpPoints.push(new FlxPoint()); } tmpPoints[0].x = points[0].x - 4; tmpPoints[0].y = points[0].y - 4; for (i in 1...points.length) { var length = points[0].distanceTo(points[i]); tmpPoints[i].x = (points[0].x - points[i].x) * velocity / length; tmpPoints[i].y = (points[0].y - points[i].y) * velocity / length; } for (i in 0...tmpPoints.length) { var point:FlxPoint = tmpPoints[i]; output += "new FlxPoint(" + Math.round(point.x) + ", " + Math.round(point.y) + ")"; if (i != tmpPoints.length - 1) { output += ", "; } } output += "];"; trace(output); getSpoogeAngleArray()[touchedPart.animation.frameIndex] = tmpPoints; } else { if (points.length == 2 && touchedPart == _head) { var velocity:Float = 80; var output:String = "breathAngleArray"; output += "[" + touchedPart.animation.frameIndex + "] = ["; var tmpPoints:Array<FlxPoint> = [new FlxPoint(), new FlxPoint()]; tmpPoints[0].x = points[0].x - 4; tmpPoints[0].y = points[0].y - 4; var length = points[0].distanceTo(points[1]); tmpPoints[1].x = (points[0].x - points[1].x) * velocity / length; tmpPoints[1].y = (points[0].y - points[1].y) * velocity / length; for (i in 0...tmpPoints.length) { var point:FlxPoint = tmpPoints[i]; output += "new FlxPoint(" + Math.round(point.x) + ", " + Math.round(point.y) + ")"; if (i != tmpPoints.length - 1) { output += ", "; } } output += "];"; trace(output); breathAngleArray[touchedPart.animation.frameIndex] = tmpPoints; } if (points.length >= 3) { var output:String = ""; output += "mouthPolyArray[" + touchedPart.animation.frameIndex + "] = "; output += "["; for (i in 0...points.length) { var point:FlxPoint = points[i]; output += "new FlxPoint(" + Math.round(point.x) + ", " + Math.round(point.y) + ")"; if (i != points.length - 1) { output += ", "; } } output += "];"; trace(output); } } } } if (FlxG.keys.justPressed.ESCAPE) { points.splice(0, points.length); } if (FlxG.keys.justPressed.Q) { trace(_cumShots.length); } } override public function draw():Void { super.draw(); FlxSpriteUtil.fill(canvas, FlxColor.TRANSPARENT); if (touchedPart != null && points.length >= 1) { var pointsCopy:Array<FlxPoint> = points.copy(); for (i in 0...pointsCopy.length) { pointsCopy[i] = FlxPoint.get(pointsCopy[i].x + touchedPart.x, pointsCopy[i].y + touchedPart.y); } if (points.length == 1) { FlxSpriteUtil.drawRect(canvas, pointsCopy[0].x - 1, pointsCopy[0].y - 1, 3, 3, FlxColor.GREEN, null ); } else if (points.length == 2) { FlxSpriteUtil.drawLine(canvas, pointsCopy[0].x, pointsCopy[0].y, pointsCopy[1].x, pointsCopy[1].y, { color:FlxColor.BLUE, thickness:3 } ); } else if (points.length > 2) { FlxSpriteUtil.drawPolygon(canvas, pointsCopy, FlxColor.GREEN, null ); } FlxDestroyUtil.putArray(pointsCopy); } } override public function sexyStuff(elapsed:Float):Void { } override public function handleToyWindow(elapsed:Float):Void { } function isBlank(Sprite:FlxSprite):Bool { Sprite.drawFrame(); var byteArray:ByteArray = Sprite.framePixels.getPixels(new Rectangle(0, 0, Sprite.width, Sprite.height)); byteArray.position = 0; while (byteArray.bytesAvailable > 0) { if (byteArray.readUnsignedByte() << 3 > 0) { return false; } } return true; } }
argonvile/monster
source/demo/SexyDebugState.hx
hx
unknown
8,873
package demo; import flixel.FlxG; import flixel.FlxState; import flixel.text.FlxText; import flixel.util.FlxColor; /** * Demo for when I need to create MonsterMind-style text in teasers */ class TeaserTextState extends FlxState { var textY:Int = 0; override public function create():Void { super.create(); bgColor = FlxColor.WHITE; /* addText("monster mind 1.07\nis out today"); addText("it has a lot of\ncool changes"); addText("mystery boxes are\na little better"); addText("there are some\nsexy new items"); addText("and i've improved\nsome of the old ones"); addText("there are 26 new\npokemon to meet"); addText("minigames are now\nmore challenging"); addText("sandslash is still\nsandslash (sorry)"); */ addText("2019.04.01\n(april fools)"); } function addText(s:String):Void { var text:FlxText = new FlxText(0, textY, 0, s, 20); text.color = FlxColor.BLACK; text.font = AssetPaths.hardpixel__otf; add(text); textY += 50; } }
argonvile/monster
source/demo/TeaserTextState.hx
hx
unknown
1,035
package demo; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.util.FlxColor; /** * Demo for experimenting with the keyboard */ class TextEntryDemo extends FlxState { override public function create():Void { super.create(); var bgSprite:FlxSprite = new FlxSprite(0, 0); bgSprite.makeGraphic(FlxG.width, FlxG.height, FlxColor.GRAY); add(bgSprite); add(new TextEntryGroup(null, TextEntryGroup.KeyConfig.Password)); } }
argonvile/monster
source/demo/TextEntryDemo.hx
hx
unknown
487
package kludge; import flixel.FlxSprite; /** * Workaround for asset-related glitches in Flixel */ class AssetKludge { /** * Between Flixel 3.3.12 and 4.1.1, Flixel made it so that you can't apply drop shadows to * buttons unless you jump through this very silly hoop first * * http://forum.haxeflixel.com/topic/179/i-don-t-understand-the-change-from-flxspritefilter-to-flxfilterframes */ public static function buttonifyAsset<T>(asset:Dynamic):Void { new FlxSprite(0, 0, asset); } }
argonvile/monster
source/kludge/AssetKludge.hx
hx
unknown
518
package kludge; import flixel.FlxG; import flixel.math.FlxMath; import flixel.math.FlxRandom; /** * This works around some FlxRandom issues in 4.1.1. Some of these remain in * 4.2.0 but should be fixed in an upcoming HaxeFlixel release. */ class BetterFlxRandom { /** * Internal shared helper variable. Used by getObject(). */ private static var _arrayFloatHelper:Array<Float> = null; /** * FlxG.random.shuffle doesn't work for enum arrays. */ public static function shuffle<T>(arr:Array<T>):Array<T> { if (arr != null) { for (i in 0...arr.length) { var j = FlxG.random.int(0, arr.length - 1); var tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } } return arr; } /** * FlxG.random.getObject() doesn't work. It always returns items from the * start of the array regardless of StartIndex. * * WARNING: This implementation does not support WeightsArray. * * https://github.com/HaxeFlixel/flixel/issues/2009 */ @:generic public static function getObject<T>(Objects:Array<T>, ?WeightsArray:Array<Float>, StartIndex:Int = 0, ?EndIndex:Null<Int>):T { var selected:Null<T> = null; if (Objects.length != 0) { if (EndIndex == null) { EndIndex = Objects.length - 1; } selected = Objects[FlxG.random.int(StartIndex, EndIndex)]; } return selected; } /** * Same functionality as getObject(Objects, WeightsArray) but using a map */ public static function getObjectWithMap<T>(map:Map<T, Float>) { var objects:Array<T> = []; var weights:Array<Float> = []; for (key in map.keys()) { objects.push(key); weights.push(map[key]); } return FlxG.random.getObject(objects, weights); } }
argonvile/monster
source/kludge/BetterFlxRandom.hx
hx
unknown
1,759
package kludge; import flash.display.BitmapData; import flash.geom.Point; import flash.geom.Rectangle; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxFilterFrames; import flixel.graphics.frames.FlxFramesCollection; import flixel.graphics.frames.FlxFramesCollection.FlxFrameCollectionType; import flixel.math.FlxPoint; import flixel.math.FlxRect; import flixel.util.FlxColor; import openfl.filters.BitmapFilter; /** * A workaround for a bug where applying a filter wipes out a sprite's offsets * * http://forum.haxeflixel.com/topic/179/i-don-t-understand-the-change-from-flxspritefilter-to-flxfilterframes */ class FlxFilterFramesKludge extends FlxFilterFrames { public var secretOffset:FlxPoint = new FlxPoint(); private function new(sourceFrames:FlxFramesCollection, widthInc:Int = 0, heightInc:Int = 0, ?filters:Array<BitmapFilter>) { super(sourceFrames, widthInc, heightInc, filters); } public static function fromFrames(frames:FlxFramesCollection, widthInc:Int = 0, heightInc:Int = 0, ?filters:Array<BitmapFilter>):FlxFilterFramesKludge { return new FlxFilterFramesKludge(frames, widthInc, heightInc, filters); } override public function applyToSprite(spr:FlxSprite, saveAnimations:Bool = false, updateFrames:Bool = false):Void { super.applyToSprite(spr, saveAnimations, updateFrames); spr.offset.set(secretOffset.x, secretOffset.y); } }
argonvile/monster
source/kludge/FlxFilterFramesKludge.hx
hx
unknown
1,454
package kludge; import flash.media.SoundTransform; import flixel.FlxG; import flixel.math.FlxMath; import flixel.system.FlxSound; import flixel.system.FlxSoundGroup; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxDestroyUtil; import openfl.Assets; import openfl.events.Event; import openfl.media.Sound; import openfl.media.SoundChannel; /** * Workaround for seamless sound looping. * * The built in FlxSound class can not loop sound seamlessly, it has a * noticable pause on each loop. */ class FlxSoundKludge implements IFlxDestroyable { public var soundAsset:String; public var _sound:Sound; public var _channel:SoundChannel; public var _transform:SoundTransform = new SoundTransform(); public var fadeSeconds:Float; /** * Internal tracker for volume. */ private var _volume:Float = 0; /** * Set volume to a value between 0 and 1 to change how this sound is. */ public var volume(get, set):Float; private var _volumeTween:FlxTween; private var _volumeWarbleTween0:FlxTween; private var maxVolume:Float = 0; private var pulseOnDuration:Float = 0; public function new(soundAsset:String, fadeSeconds:Float) { this.soundAsset = soundAsset; this.fadeSeconds = fadeSeconds; } private function playLooped() { if (_sound == null) { _sound = Assets.getSound(soundAsset, true); } if (_channel == null) { _channel = _sound.play(0, 9999999); } } public function fadeIn(maxVolume:Float) { cancelVibeTweens(); this.maxVolume = maxVolume; if (_sound == null) { // sound wasn't playing; create new sound object playLooped(); set_volume(0); } _volumeTween = FlxTweenUtil.retween(_volumeTween, this, {volume:maxVolume}, fadeSeconds); } /** * @param period How many seconds it takes to warble */ public function sustained(period:Float) { cancelVibeTweens(); _volumeTween = FlxTweenUtil.retween(_volumeTween, this, {volume:maxVolume}, fadeSeconds); _volumeWarbleTween0 = FlxTweenUtil.retween(_volumeWarbleTween0, this, {volume:maxVolume * 0.85}, period, {startDelay:fadeSeconds, type:FlxTweenType.PINGPONG}); } /** * @param period How many seconds it takes for a full cycle */ public function sine(period:Float) { cancelVibeTweens(); _volumeTween = FlxTweenUtil.retween(_volumeTween, this, {volume:maxVolume * 0.15}, fadeSeconds); _volumeWarbleTween0 = FlxTweenUtil.retween(_volumeWarbleTween0, this, {volume:maxVolume}, period, {startDelay:fadeSeconds, type:FlxTweenType.PINGPONG, ease:FlxEase.sineInOut}); } /** * @param on How long the sound is at maximum volume * @param off How long the sound is at minimum volume */ public function pulse(on:Float, off:Float) { cancelVibeTweens(); this.pulseOnDuration = on; _volumeTween = FlxTweenUtil.retween(_volumeTween, this, {volume:maxVolume}, fadeSeconds, {type:FlxTweenType.LOOPING, loopDelay:on + off + fadeSeconds, onStart:schedulePulseOff}); } private function schedulePulseOff(tween:FlxTween) { _volumeWarbleTween0 = FlxTweenUtil.retween(_volumeWarbleTween0, this, {volume:0}, fadeSeconds, {startDelay:pulseOnDuration + fadeSeconds}); } private function cancelVibeTweens() { if (_volumeWarbleTween0 != null) { _volumeWarbleTween0.cancel(); _volumeWarbleTween0 = null; } } public function fadeOut() { cancelVibeTweens(); if (_volumeTween != null) { _volumeTween = FlxTweenUtil.retween(_volumeTween, this, {volume:0}, fadeSeconds, {onComplete:stopCallback}); } } private function stopCallback(tween:FlxTween) { stop(); } private function stop() { if (_channel != null) { _channel.stop(); _channel = null; } if (_sound != null) { _sound = null; } if (_transform != null) { _transform = null; _transform = new SoundTransform(); } } private inline function get_volume():Float { return _volume; } private function set_volume(Volume:Float):Float { _volume = FlxMath.bound(Volume, 0, 1); updateTransform(); return Volume; } /** * Call after adjusting the volume to update the sound channel's settings. */ private function updateTransform():Void { _transform.volume = #if FLX_SOUND_SYSTEM (FlxG.sound.muted ? 0 : 1) * FlxG.sound.volume * #end _volume; if (_channel != null) _channel.soundTransform = _transform; } public function destroy() { _transform = null; if (_channel != null) { _channel.stop(); _channel = null; } if (_sound != null) { _sound = null; } _volumeTween = FlxTweenUtil.destroy(_volumeTween); _volumeWarbleTween0 = FlxTweenUtil.destroy(_volumeWarbleTween0); } /** * Plays a sound using FlxG.sound.play, but changes MP3 references to OGG as necessary */ public static function play(EmbeddedSound:String, Volume:Float = 1, Looped:Bool = false, ?Group:FlxSoundGroup, AutoDestroy:Bool = true, ?OnComplete:Void->Void):FlxSound { return FlxG.sound.play(fixPath(EmbeddedSound), Volume, Looped, Group, AutoDestroy, OnComplete); } /** * Changes an MP3 path to an OGG path for non-flash platforms */ public static function fixPath(sfxPath:Dynamic) { #if !flash return StringTools.replace(sfxPath, ".mp3", ".ogg"); #else return sfxPath; #end } }
argonvile/monster
source/kludge/FlxSoundKludge.hx
hx
unknown
5,465
package kludge; import flixel.FlxSprite; import kludge.LateFadingFlxParticle; /** * Various hacky workarounds for bugs and idiosynchracies in HaxeFlixel */ class FlxSpriteKludge { /** * Workaround for https://github.com/HaxeFlixel/flixel/issues/2100 -- FlxG.overlap() produces strange results sometimes. * * Additionally, this is a more performant way of checking for collision of two sprites since it does not use a quadtree. */ public static inline function overlap(s0:FlxSprite, s1:FlxSprite) { return s0.x <= s1.x + s1.width && s1.x <= s0.x + s0.width && s0.y <= s1.y + s1.height && s1.y <= s0.y + s0.height; } /** * When recycled, FlxParticles are curved in random directions because... why wouldn't they be! * * https://www.reddit.com/r/haxeflixel/comments/752pqj/unexpected_flxemitter_behavior_when_in_square_mode/ */ public static function unfuckParticle(particle:LateFadingFlxParticle) { particle.velocityRange.end.set(particle.velocityRange.start.x, particle.velocityRange.start.y); particle.accelerationRange.end.set(particle.accelerationRange.start.x, particle.accelerationRange.start.y); } }
argonvile/monster
source/kludge/FlxSpriteKludge.hx
hx
unknown
1,167
package kludge; import flixel.effects.particles.FlxParticle; /** * An FlxParticle which fades out after some time passes. * * Older versions of HaxeFlixel would allow you to set the alpha component to * an absurd value such as 500%. This had the benefit that if the alpha * component decreased linearly, no visible change would occur until the alpha * dipped below 100%. This produced an effect where a particle was 100% visible * for awhile, and then faded out after a delay. * * This class was created to recreate this fading behavior in newer HaxeFlixel * versions. */ class LateFadingFlxParticle extends FlxParticle { private var lateFade:Float; override public function update(elapsed:Float):Void { if (alphaRange.active == false && lateFade * (age / lifespan) > lateFade - 1) { alphaRange.active = true; } super.update(elapsed); } public function enableLateFade(lateFade:Float) { this.lateFade = lateFade; alphaRange.set(lateFade, 0); alphaRange.active = false; } }
argonvile/monster
source/kludge/LateFadingFlxParticle.hx
hx
unknown
1,045
package minigame; import MmStringTools.*; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; /** * Parent class which handles scoreboard logic which is common to all of the * minigames */ class FinalScoreboard extends FlxGroup { private var _scoreboardBg:FlxSprite; private var _bonusGroups:Array<FlxGroup> = []; private var _bonusGroupIndex:Int = 0; private var _bonusY:Int = 25; public var _totalReward:Int = 0; public function new() { super(); _scoreboardBg = new FlxSprite(0, 0); _scoreboardBg.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); add(_scoreboardBg); addBonuses(); var totalGroup:FlxGroup = new FlxGroup(); _bonusGroups.push(totalGroup); var bottomY:Float = Math.max(175, _bonusY); var bottom:Float = bottomY + 35; totalGroup.add(leftText(bottomY, "Total:")); totalGroup.add(rightText(bottomY, commaSeparatedNumber(_totalReward) + "$")); FlxSpriteUtil.beginDraw(OptionsMenuState.MEDIUM_BLUE & 0xCCFFFFFF); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.endDraw(_scoreboardBg); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:9, color:OptionsMenuState.DARK_BLUE }); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.updateSpriteGraphic(_scoreboardBg); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:7, color:OptionsMenuState.WHITE_BLUE }); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.updateSpriteGraphic(_scoreboardBg); } public function addBonuses() { } public function addBonus(bonusDesc:String, amount:Int) { var bonusGroup:FlxGroup = new FlxGroup(); _bonusGroups.push(bonusGroup); bonusGroup.add(leftText(_bonusY, bonusDesc + ":")); bonusGroup.add(rightText(_bonusY, commaSeparatedNumber(amount) + "$")); _bonusY += 50; _totalReward += amount; } public function addScore(scoreDesc:String, amount:Int) { var leftGroup:FlxGroup = new FlxGroup(); _bonusGroups.push(leftGroup); leftGroup.add(leftText(_bonusY, "Score:")); var rightGroup:FlxGroup = new FlxGroup(); _bonusGroups.push(rightGroup); rightGroup.add(rightText(_bonusY, commaSeparatedNumber(amount) + "$")); _bonusY += 50; _totalReward += amount; } public function getBonusGroupCount():Int { return _bonusGroups.length; } public function eventTurnOnBonusGroup(args:Dynamic):Void { SoundStackingFix.play(AssetPaths.beep_0065__mp3); add(_bonusGroups[_bonusGroupIndex++]); } private function leftText(Y:Float, ?Text:String):FlxText { var flxText:FlxText = new FlxText(197, Y - 6, 274, Text, 30); flxText.font = AssetPaths.hardpixel__otf; flxText.color = ItemsMenuState.WHITE_BLUE; return flxText; } private function rightText(Y:Float, ?Text:String):FlxText { var flxText:FlxText = new FlxText(466, Y - 6, 110, Text, 30); flxText.alignment = FlxTextAlign.RIGHT; flxText.font = AssetPaths.hardpixel__otf; flxText.color = ItemsMenuState.WHITE_BLUE; return flxText; } override public function destroy():Void { super.destroy(); _scoreboardBg = FlxDestroyUtil.destroy(_scoreboardBg); _bonusGroups = FlxDestroyUtil.destroyArray(_bonusGroups); } }
argonvile/monster
source/minigame/FinalScoreboard.hx
hx
unknown
3,461
package minigame; import MmStringTools.*; import PlayerData.Gender; import flixel.FlxG; import flixel.util.FlxDestroyUtil; import kludge.BetterFlxRandom; import minigame.scale.ScaleGameState; import minigame.tug.TugGameState; import openfl.utils.Object; import minigame.stair.StairGameState; /** * Pokemon have about 20 things they say during the minigames, like "Augh I * lost the game!" or "Wow, you just made a really good move..." or "It's time * for round 4!" * * This class acts as a data model for all the phrases a particular Pokemon * says during a minigame * * The dialog supports replaceable entities like <round>, <leader> and pronouns like <leaderHe> <leadershe> * * Losing dialog supports <money> for dialog referencing winnings, and <nomoney> as a flag if the player won 0$. */ class GameDialog implements IFlxDestroyable { private var roundStarts:Array<GameDialogLine> = []; private var defaultRoundStarts:Array<GameDialogLine> = []; private var winnings:Array<GameDialogLine> = []; private var losings:Array<GameDialogLine> = []; private var roundWins:Array<GameDialogLine> = []; private var roundLoses:Array<GameDialogLine> = []; private var stairReadies:Array<GameDialogLine> = []; private var defaultStairReady:GameDialogLine = new GameDialogLine("#zzzz05#Ready?", ["Sure\nthing", "Let's go!", "Hmm..."]); private var stairPlayerStarts:Array<GameDialogLine> = []; private var defaultPlayerStarts:GameDialogLine = new GameDialogLine("#zzzz02#Oh, so you get to go first. Are you ready?", ["Hmm,\nsure...", "Ha, I knew\nyou'd pick\nthat!", "I'm ready!"]); private var stairComputerStarts:Array<GameDialogLine> = []; private var defaultComputerStarts:GameDialogLine = new GameDialogLine("#zzzz02#Oh, so I get to go first! Are you ready?", ["Yep,\nready!", "Hmph!\nDid you\ncheat?", "I think\nso..."]); private var stairOddsEvens:Array<GameDialogLine> = []; private var defaultOddsEvens:GameDialogLine = new GameDialogLine("#zzzz06#Let's throw odds and evens to see who goes first. You'll go first if it's odd, and I'll go first if it's even. Alright?", ["Yep", "Let's\ndo it", "Okay, so\nI'm odds..."]); private var stairCheats:Array<GameDialogLine> = []; private var defaultStairCheat:GameDialogLine = new GameDialogLine("#zzzz05#You need to throw your dice sooner! Let's try again.", ["I didn't\nmean to\ndo that...", "Ehh,\nwhatever", "Oops!\nOkay"]); private var stairCapturedComputers:Array<GameDialogLine> = []; private var defaultStairCapturedComputer:GameDialogLine = new GameDialogLine("#zzzz10#Ahh! You caught me!", ["Heh!\nHeh heh", "Oops,\nsorry...", "You're not\nvery good"]); private var stairCapturedHumans:Array<GameDialogLine> = []; private var defaultStairCapturedHuman:GameDialogLine = new GameDialogLine("#zzzz02#Hah! I caught you!", ["Nice\njob!", "Ugh, so\nlucky...", "I'll get\nyou yet"]); private var closeGames:Array<GameDialogLine> = []; private var defaultCloseGame:GameDialogLine = new GameDialogLine("#zzzz04#Wow! Close game.", ["Yeah!", "I'll still\nwin...", "This is\nfun~"]); private var gameStartQueries:Array<String> = []; private var playerBeatMes:Array<Array<String>> = []; private var beatPlayers:Array<Array<String>> = []; private var shortPlayerBeatMes:Array<String> = []; private var shortWeWereBeatens:Array<String> = []; private var postTutorialGameStarts:Array<String> = []; private var gameAnnouncements:Array<String> = []; private var remoteExplanationHandoffs:Array<String> = []; private var localExplanationHandoffs:Array<String> = []; private var skipMinigames:Array<Array<String>> = []; private var illSitOuts:Array<String> = []; private var fineIllPlays:Array<String> = []; private var gameStateClass:Class<MinigameState> = null; public function new(gameStateClass:Class<MinigameState>) { this.gameStateClass = gameStateClass; } public function help(tree:Array<Array<Object>>, helpDialog:HelpDialog) { tree[0] = [FlxG.random.getObject(helpDialog.greetings)]; tree[1] = [100, 120, 140, 160]; tree[100] = [FlxG.random.getObject(["I think\nI'm done\nfor now", "I'm gonna\ncall it\nquits", "Sorry, I'm\ngonna take\noff"])]; tree[101] = ["%disable-skip%"]; tree[102] = [FlxG.random.getObject(helpDialog.goodbyes)]; tree[103] = ["%quit%"]; tree[120] = [FlxG.random.getObject(["Nevermind", "Oops,\nsorry", "It's\nnothing"])]; tree[121] = [FlxG.random.getObject(helpDialog.neverminds)]; tree[140] = [FlxG.random.getObject(["Can I skip\nthis minigame?", "Is there\na way\nto skip\nover this?", "Can we do\nsomething else?"])]; tree[160] = [FlxG.random.getObject(["Can you\nexplain this\nagain?", "Can you\nremind me\nhow to play?", "How does\nthis game\nwork?"])]; var skipMinigame:Array<String> = FlxG.random.getObject(skipMinigames); tree[141] = ["%disable-skip%"]; tree[142] = ["%skip-minigame%"]; var tutorialTree:Array<Array<Object>> = []; if (gameStateClass == ScaleGameState) { tutorialTree = TutorialDialog.scaleGameSummary(); } else if (gameStateClass == StairGameState) { tutorialTree = TutorialDialog.stairGameSummary(); } else if (gameStateClass == TugGameState) { tutorialTree = TutorialDialog.tugGameSummary(); } for (i in 0...tutorialTree.length) { tree[161 + i] = tutorialTree[i]; } } public function addRoundWin(dialog:String, choices:Array<String>) { roundWins.push(new GameDialogLine(dialog, choices)); } public function popRoundWin(tree:Array<Array<Object>>) { popRoundStartLine(tree, roundWins); } /** * Supports <leader> <leaderhe> for round winner */ public function addRoundLose(dialog:String, choices:Array<String>) { roundLoses.push(new GameDialogLine(dialog, choices)); } public function popRoundLose(tree:Array<Array<Object>>, ?leader:String, ?leaderGender:PlayerData.Gender) { var roundLose:GameDialogLine = popRoundStartLine(tree, roundLoses); roundLose.filterLeader(tree, leader, leaderGender); } public function addStairPlayerStarts(dialog:String, choices:Array<String>) { pushRandom(stairPlayerStarts, new GameDialogLine(dialog, choices)); } public function popStairPlayerStarts(tree:Array<Array<Object>>) { var stairPlayerStarts:GameDialogLine = popAndCycle(this.stairPlayerStarts, defaultPlayerStarts); stairPlayerStarts.generateDialog(tree); } /** * Supports <playerthrow>, <computerthrow>, <Playerthrow>, <Computerthrow> */ public function addStairCapturedHuman(dialog:String, choices:Array<String>) { pushRandom(stairCapturedHumans, new GameDialogLine(dialog, choices)); } public function popStairCapturedHuman(tree:Array<Array<Object>>, playerThrow:Int, computerThrow:Int) { var stairCapturedHuman:GameDialogLine = popAndCycle(this.stairCapturedHumans, defaultStairCapturedHuman); stairCapturedHuman.generateDialog(tree); stairCapturedHuman.filterStairThrow(tree, playerThrow, computerThrow); } /** * Supports <playerthrow>, <computerthrow>, <Playerthrow>, <Computerthrow> */ public function addStairCapturedComputer(dialog:String, choices:Array<String>) { pushRandom(stairCapturedComputers, new GameDialogLine(dialog, choices)); } public function popStairCapturedComputer(tree:Array<Array<Object>>, playerThrow:Int, computerThrow:Int) { var stairCapturedComputer:GameDialogLine = popAndCycle(this.stairCapturedComputers, defaultStairCapturedComputer); stairCapturedComputer.generateDialog(tree); stairCapturedComputer.filterStairThrow(tree, playerThrow, computerThrow); } public function addStairComputerStarts(dialog:String, choices:Array<String>) { pushRandom(stairComputerStarts, new GameDialogLine(dialog, choices)); } public function popStairComputerStarts(tree:Array<Array<Object>>) { var stairComputerStarts:GameDialogLine = popAndCycle(this.stairComputerStarts, defaultComputerStarts); stairComputerStarts.generateDialog(tree); } public function addStairOddsEvens(dialog:String, choices:Array<String>) { pushRandom(stairOddsEvens, new GameDialogLine(dialog, choices)); } public function popStairOddsEvens(tree:Array<Array<Object>>) { var stairOddsEvens:GameDialogLine = popAndCycle(this.stairOddsEvens, defaultOddsEvens); stairOddsEvens.generateDialog(tree); } public function addCloseGame(dialog:String, choices:Array<String>) { pushRandom(closeGames, new GameDialogLine(dialog, choices)); } public function popCloseGame(tree:Array<Array<Object>>) { var closeGame:GameDialogLine = popAndCycle(closeGames, defaultCloseGame); closeGame.generateDialog(tree); } public function addStairReady(dialog:String, choices:Array<String>) { pushRandom(stairReadies, new GameDialogLine(dialog, choices)); } public function popStairReady(tree:Array<Array<Object>>) { var stairReady:GameDialogLine = popAndCycle(stairReadies, defaultStairReady); stairReady.generateDialog(tree, [["%prompts-y-offset-50%"]]); } public function addStairCheat(dialog:String, choices:Array<String>) { pushRandom(stairCheats, new GameDialogLine(dialog, choices)); } public function popStairCheat(tree:Array<Array<Object>>) { var stairCheat:GameDialogLine = popAndCycle(stairCheats, defaultStairCheat); stairCheat.generateDialog(tree, [["%prompts-y-offset-50%"]]); } /** * Pushes an item into a random position in the array */ private static function pushRandom<T>(objects:Array<T>, obj:T) { objects.insert(FlxG.random.int(0, objects.length), obj); } /** * Pop an item from somewhere near the front of the array, and stick it on the back. This is a simple way to avoid generating the same dialog twice in a row. */ private static function popAndCycle<T>(objects:Array<T>, defaultAnswer:T):T { var obj:T; if (objects == null || objects.length <= 1) { obj = objects[0]; } else { obj = FlxG.random.getObject(objects.slice(0, objects.length - 1)); } if (obj == null) { return defaultAnswer; } objects.remove(obj); objects.push(obj); return obj; } /** * Supports <round> for round number. * * However, the first "round" message shouldn't have any <round> variables. * This is our safety choice if for some reason we can't pick the choice we * wanted. */ public function addRoundStart(dialog:String, choices:Array<String>) { roundStarts.push(new GameDialogLine(dialog, choices)); defaultRoundStarts.push(new GameDialogLine(dialog, choices)); } public function popRoundStart(tree:Array<Array<Object>>, roundNum:Int) { var roundStart:GameDialogLine = popRoundStartLine(tree, roundStarts); roundStart.filterRound(tree, roundNum); } public function addWinning(dialog:String, choices:Array<String>) { winnings.push(new GameDialogLine(dialog, choices)); } public function popWinning(tree:Array<Array<Object>>) { popRoundStartLine(tree, winnings); } /** * Supports <leader>, <leaderhe> for overall leader */ public function addLosing(dialog:String, choices:Array<String>) { losings.push(new GameDialogLine(dialog, choices)); } public function popLosing(tree:Array<Array<Object>>, leader:String, leaderGender:Gender) { var losing:GameDialogLine = popRoundStartLine(tree, losings); losing.filterLeader(tree, leader, leaderGender); } /** * Supports <Minigame>, <minigame> for minigame name */ public function addGameAnnouncement(line:String) { gameAnnouncements.push(line); } public function popGameAnnouncement(tree:Array<Array<Object>>, desc:String) { var line:String = FlxG.random.getObject(gameAnnouncements); line = StringTools.replace(line, "<minigame>", desc); line = StringTools.replace(line, "<Minigame>", capitalize(desc)); tree.push([line]); } public function addGameStartQuery(line:String) { gameStartQueries.push(line); } public function popGameStartQuery(tree:Array<Array<Object>>) { var line:String = FlxG.random.getObject(gameStartQueries); var i:Int = tree.length; tree[i] = [line]; tree[i + 1] = [i + 3, i + 6, i + 9, i + 12]; tree[i + 3] = ["Yeah!"]; tree[i + 6] = ["Hmm, I\nguess..."]; tree[i + 9] = ["Can you go\nover the\nrules again?"]; tree[i + 10] = ["%restart-tutorial%"]; tree[i + 12] = [FlxG.random.getObject(["No, I'll pass\nthis time", "No thanks,\nI'd rather not", "No, I don't\nreally\nwant to"])]; tree[i + 13] = ["%skip-minigame%"]; } /** * Supports <money> for the amount of money the player won */ public function addPlayerBeatMe(lines:Array<String>) { playerBeatMes.push(lines); } public function popPlayerBeatMe(tree:Array<Array<Object>>, rewardMoney:Int) { var lines:Array<String>; do { lines = playerBeatMes.splice(FlxG.random.int(0, playerBeatMes.length - 1), 1)[0]; } while (rewardMoneyMismatch(lines, rewardMoney)); for (line in lines) { line = StringTools.replace(line, "<money>", commaSeparatedNumber(rewardMoney) + "$"); line = StringTools.replace(line, "<nomoney>", ""); tree.push([line]); } return tree; } /** * Supports <money> <nomoney> for the amount of player the player won */ public function addBeatPlayer(lines:Array<String>) { beatPlayers.push(lines); } public function popBeatPlayer(tree:Array<Array<Object>>, rewardMoney:Int) { var lines:Array<String>; do { lines = beatPlayers.splice(FlxG.random.int(0, beatPlayers.length - 1), 1)[0]; } while (rewardMoneyMismatch(lines, rewardMoney)); for (line in lines) { line = StringTools.replace(line, "<money>", commaSeparatedNumber(rewardMoney) + "$"); line = StringTools.replace(line, "<nomoney>", ""); tree.push([line]); } return tree; } /** * Supports <money> for the amount of money the player won */ public function addShortPlayerBeatMe(line:String) { shortPlayerBeatMes.push(line); } public function popShortPlayerBeatMe(tree:Array<Array<Object>>, rewardMoney:Int) { var line:String; do { line = shortPlayerBeatMes.splice(FlxG.random.int(0, shortPlayerBeatMes.length - 1), 1)[0]; } while (rewardMoneyMismatch(line, rewardMoney)); line = StringTools.replace(line, "<money>", commaSeparatedNumber(rewardMoney) + "$"); line = StringTools.replace(line, "<nomoney>", ""); tree.push([line]); return tree; } /** * Supports <money> <nomoney> for the player's winnings, and <leader> <leaderhe> for the winner */ public function addShortWeWereBeaten(line:String) { shortWeWereBeatens.push(line); } public function popShortWeWereBeaten(tree:Array<Array<Object>>, rewardMoney:Int, leader:String, leaderGender:PlayerData.Gender) { var line:String; do { line = shortWeWereBeatens.splice(FlxG.random.int(0, shortWeWereBeatens.length - 1), 1)[0]; } while (rewardMoneyMismatch(line, rewardMoney)); line = StringTools.replace(line, "<money>", commaSeparatedNumber(rewardMoney) + "$"); line = StringTools.replace(line, "<nomoney>", ""); line = replaceLeader(line, leader, leaderGender); tree.push([line]); return tree; } private function rewardMoneyMismatch(arg:Dynamic, rewardMoney:Int):Bool { if (Std.isOfType(arg, Array)) { var lines:Array<String> = cast(arg); for (line in lines) { if (rewardMoneyMismatch(line, rewardMoney)) { return true; } } } else if (Std.isOfType(arg, String)) { var line:String = cast(arg); if (rewardMoney <= 0 && line.indexOf("<money>") != -1) { return true; } else if (rewardMoney > 0 && line.indexOf("<nomoney>") != -1) { return true; } } return false; } public static function replaceLeader(line:String, leader:String, leaderGender:Gender):String { line = StringTools.replace(line, "<leader>", leader); if (leaderGender != null) { if (leaderGender == PlayerData.Gender.Boy) { line = StringTools.replace(line, "<leaderHe>", "He"); line = StringTools.replace(line, "<leaderhe>", "he"); line = StringTools.replace(line, "<leaderHe's>", "He's"); line = StringTools.replace(line, "<leaderhe's>", "he's"); line = StringTools.replace(line, "<leaderHe'd>", "He'd"); line = StringTools.replace(line, "<leaderhe'd>", "he'd"); line = StringTools.replace(line, "<leaderHim>", "Him"); line = StringTools.replace(line, "<leaderhim>", "him"); line = StringTools.replace(line, "<leaderHis>", "His"); line = StringTools.replace(line, "<leaderhis>", "his"); } else if (leaderGender == PlayerData.Gender.Girl) { line = StringTools.replace(line, "<leaderHe>", "She"); line = StringTools.replace(line, "<leaderhe>", "she"); line = StringTools.replace(line, "<leaderHe's>", "She's"); line = StringTools.replace(line, "<leaderhe's>", "she's"); line = StringTools.replace(line, "<leaderHe'd>", "She'd"); line = StringTools.replace(line, "<leaderhe'd>", "she'd"); line = StringTools.replace(line, "<leaderHim>", "Her"); line = StringTools.replace(line, "<leaderhim>", "her"); line = StringTools.replace(line, "<leaderHis>", "Her"); line = StringTools.replace(line, "<leaderhis>", "her"); } else { line = StringTools.replace(line, "<leaderHe>", "They"); line = StringTools.replace(line, "<leaderhe>", "they"); line = StringTools.replace(line, "<leaderHe's>", "They're"); line = StringTools.replace(line, "<leaderhe's>", "they're"); line = StringTools.replace(line, "<leaderHe'd>", "They'd"); line = StringTools.replace(line, "<leaderhe'd>", "they'd"); line = StringTools.replace(line, "<leaderHim>", "Them"); line = StringTools.replace(line, "<leaderhim>", "them"); line = StringTools.replace(line, "<leaderHis>", "Their"); line = StringTools.replace(line, "<leaderhis>", "their"); } } return line; } public function addSkipMinigame(lines:Array<String>) { this.skipMinigames.push(lines); } public function popSkipMinigame():Array<Array<Object>> { var tree:Array<Array<Object>> = []; var lines:Array<String> = FlxG.random.getObject(skipMinigames); for (line in lines) { tree.push([line]); } return tree; } public function addPostTutorialGameStart(line:String) { this.postTutorialGameStarts.push(line); } public function popPostTutorialGameStartQuery(tree:Array<Array<Object>>, desc:String) { var line:String = FlxG.random.getObject(postTutorialGameStarts); var i:Int = 0; line = StringTools.replace(line, "<minigame>", desc); line = StringTools.replace(line, "<Minigame>", capitalize(desc)); tree[i] = [line]; i++; tree[i] = [i + 10, i + 20, i + 30, i + 40]; tree[i + 10] = ["Yeah!"]; tree[i + 20] = ["Hmm, I\nguess..."]; tree[i + 30] = ["Can you go\nover that\none more time?"]; tree[i + 31] = ["%restart-tutorial%"]; tree[i + 40] = [FlxG.random.getObject(["No, I'll pass\nthis time", "No thanks,\nI'd rather not", "No, I don't\nreally\nwant to"])]; tree[i + 41] = ["%skip-minigame%"]; } /** * Supports <leader> <leaderhe> for the person who's giving the tutorial */ public function addRemoteExplanationHandoff(line:String) { this.remoteExplanationHandoffs.push(line); } public function popRemoteExplanationHandoff(tree:Array<Array<Object>>, leader:String, leaderGender:Gender) { var line:String = FlxG.random.getObject(remoteExplanationHandoffs); line = replaceLeader(line, leader, leaderGender); tree.push([line]); } /** * Supports <leader> <leaderhe> for the person who's giving the tutorial */ public function addLocalExplanationHandoff(line:String) { this.localExplanationHandoffs.push(line); } public function popLocalExplanationHandoff(tree:Array<Array<Object>>, leader:String, leaderGender:Gender) { var line:String = FlxG.random.getObject(localExplanationHandoffs); line = replaceLeader(line, leader, leaderGender); tree.push([line]); } public function addIllSitOut(line:String) { illSitOuts.push(line); } public function addFineIllPlay(line:String) { fineIllPlays.push(line); } public function popPlayWithoutMe():Array<Array<Object>> { var tree:Array<Array<Object>> = []; tree[0] = [FlxG.random.getObject(cast(illSitOuts))]; tree[1] = [10, 30, 20]; tree[10] = [FlxG.random.getObject(["Aw, well\nokay", "Hmm, if you\ninsist", "Well, that\nseems fair"])]; tree[11] = [31]; tree[20] = [FlxG.random.getObject(["Hey, don't be\nlike that!", "Aww, don't\nsit out!", "C'mon, play\nwith us!"])]; tree[21] = [FlxG.random.getObject(cast(fineIllPlays))]; tree[30] = [FlxG.random.getObject(["Huh?\nWhatever", "I don't\ncare", "Yeah, see\nyou later"])]; tree[31] = ["%play-without-me%"]; return tree; } private function popRoundStartLine(tree:Array<Array<Object>>, lines:Array<GameDialogLine>):GameDialogLine { var line:GameDialogLine; line = lines.splice(FlxG.random.int(0, lines.length - 1), 1)[0]; if (line == null) { line = defaultRoundStarts[0]; } line.generateDialog(tree); return line; } public function destroy() { roundStarts = null; defaultRoundStarts = null; winnings = null; losings = null; roundWins = null; roundLoses = null; stairReadies = null; defaultStairReady = null; stairPlayerStarts = null; defaultPlayerStarts = null; stairComputerStarts = null; defaultComputerStarts = null; stairOddsEvens = null; defaultOddsEvens = null; stairCheats = null; defaultStairCheat = null; stairCapturedComputers = null; defaultStairCapturedComputer = null; stairCapturedHumans = null; defaultStairCapturedHuman = null; closeGames = null; defaultCloseGame = null; gameStartQueries = null; playerBeatMes = null; beatPlayers = null; shortPlayerBeatMes = null; shortWeWereBeatens = null; postTutorialGameStarts = null; gameAnnouncements = null; remoteExplanationHandoffs = null; localExplanationHandoffs = null; skipMinigames = null; illSitOuts = null; fineIllPlays = null; gameStateClass = null; } } class GameDialogLine { private static var DIALOG_SPACING:Int = 3; public var _dialog:String; public var _choices:Array<String>; public function new(dialog:String, choices:Array<String>) { this._dialog = dialog; this._choices = choices; } public function generateDialog(tree:Array<Array<Object>>, ?prepend:Array<Array<Object>> = null) { var lineIndex:Int = 0; if (prepend != null) { for (i in 0...prepend.length) { tree[i] = prepend[i]; } lineIndex = prepend.length; } tree[lineIndex++] = [_dialog]; var choiceInts:Array<Object> = []; for (i in 0..._choices.length) { var choice:String = _choices[i]; var line:Int = lineIndex + (i + 1) * DIALOG_SPACING; tree[line] = [choice]; choiceInts.push(line); } tree[lineIndex++] = choiceInts; } public function filterRound(tree:Array<Array<Object>>, roundNum:Int) { var lineIndex:Int = 0; while (lineIndex < tree.length) { DialogTree.replace(tree, lineIndex, "<round>", englishNumber(roundNum)); lineIndex++; } } public function filterStairThrow(tree:Array<Array<Object>>, playerThrow:Int, computerThrow:Int) { var lineIndex:Int = 0; while (lineIndex < tree.length) { DialogTree.replace(tree, lineIndex, "<playerthrow>", englishNumber(playerThrow)); DialogTree.replace(tree, lineIndex, "<Playerthrow>", capitalize(englishNumber(playerThrow))); DialogTree.replace(tree, lineIndex, "<computerthrow>", englishNumber(computerThrow)); DialogTree.replace(tree, lineIndex, "<Computerthrow>", capitalize(englishNumber(computerThrow))); lineIndex++; } } public function filterLeader(tree:Array<Array<Object>>, ?leader:String, ?leaderGender:PlayerData.Gender) { var lineIndex:Int = 0; while (lineIndex < tree.length) { if (tree[lineIndex] != null && Std.isOfType(tree[lineIndex][0], String)) { var line:String = tree[lineIndex][0]; if (line.indexOf("|") != -1) { if (leader == PlayerData.name) { line = substringAfter(line, "|"); } else { line = substringBefore(line, "|"); } } line = GameDialog.replaceLeader(line, leader, leaderGender); tree[lineIndex][0] = line; } lineIndex++; } } public function toString():String { return "\"" + _dialog + "\""; } }
argonvile/monster
source/minigame/GameDialog.hx
hx
unknown
24,776
package minigame; import flixel.util.FlxDestroyUtil; import poke.abra.AbraDialog; import flixel.FlxG; import flixel.FlxState; import flixel.math.FlxMath; import flixel.ui.FlxButton; import openfl.utils.Object; import poke.sexy.SexyState; import puzzle.PuzzleState; /** * Parent class which includes logic common to all minigames -- skipping * minigames, showing the scoreboard, deciding where to go after the * minigame, stuff like that */ class MinigameState extends LevelState { public var description:String; public var duration:Float = 3.0; // duration in minutes; public var avgReward:Int = 1000; // expected reward; private var finalScoreboard:FinalScoreboard; private var _helpButtonAlphaTimer:Float = 0; // help button needs to change for ~0.5s before it turns on private var denDestination:String = null; override public function create():Void { super.create(); _helpButton.alpha = LevelState.BUTTON_OFF_ALPHA; var minigameIndex:Int = PlayerData.MINIGAME_CLASSES.indexOf(Type.getClass(this)); PlayerData.denMinigame = minigameIndex; } override public function dialogTreeCallback(Msg:String):String { super.dialogTreeCallback(Msg); if (Msg == "%den-game%" || Msg == "%den-sex%" || Msg == "%den-quit%") { denDestination = Msg; } if (Msg == "%skip-minigame%") { denDestination = "%den-sex%"; } return ""; } override public function update(elapsed:Float):Void { super.update(elapsed); if (DialogTree.isDialogging(_dialogTree) || _gameState >= 400) { if (_helpButton.alpha == 1.0) { _helpButton.alpha = LevelState.BUTTON_OFF_ALPHA; } } else { if (_helpButton.alpha == LevelState.BUTTON_OFF_ALPHA) { _helpButtonAlphaTimer += elapsed; if (_helpButtonAlphaTimer > 0.4) { _helpButton.alpha = 1.0; } } else { _helpButtonAlphaTimer = 0; } } } public function getMinigameOpponentDialogClass():Class<Dynamic> { return AbraDialog; } override public function clickHelp():Void { var dialogClass:Class<Dynamic> = getMinigameOpponentDialogClass(); var tree:Array<Array<Object>> = LevelIntroDialog.generateMinigameHelp(dialogClass, this); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } public function payMinigameReward(reward:Int) { PlayerData.cash += reward; var minigameIndex:Int = PlayerData.MINIGAME_CLASSES.indexOf(Type.getClass(this)); PlayerData.minigameCount[minigameIndex]++; if (PlayerData.playerIsInDen) { // don't reduce minigameReward; player is only practicing } else { // reduce minigameReward variable; player will encounter a new minigame in about 30-40 minutes PlayerData.minigameReward -= Std.int((avgReward + reward) * 0.5); /** * We compensate them for time they would have spent solving puzzles instead of doing minigames. */ PlayerData.minigameReward += Std.int(duration * 60); } } function eventPay(args:Array<Dynamic>) { payMinigameReward(finalScoreboard._totalReward); } public static function fromInt(minigameIndex:Int):MinigameState { return Type.createInstance(PlayerData.MINIGAME_CLASSES[minigameIndex], []); } public static function roundUpToFive(i:Float):Int { return Math.ceil(i * 0.2) * 5; } /** * Calculates the reward for a certain aspect of a minigame, diminishing * the reward if the player's in the den. * * Rewards are reduced in the den -- instead of receiving $200 for winning * a round in the scale game, the player might only win $40. This lets * them practice without breaking the games'e economy. * * @param reward money the player would normally earn for a given * minigame event * @return money the player should earn, diminished if the player is in the * den */ public static function denNerf(reward:Int):Int { if (PlayerData.playerIsInDen) { // player is in den; minigame winnings are reduced return roundUpToFive(reward * PlayerData.DEN_MINIGAME_NERF); } return reward; } public function handleDenGameOver(tree:Array<Array<Object>>, playerVictory:Bool) { PlayerData.denGameCount++; var clazz:Dynamic = getMinigameOpponentDialogClass(); var denDialogFunc:Dynamic = Reflect.field(clazz, "denDialog"); var denDialog:DenDialog = denDialogFunc(null, playerVictory); PlayerData.denTotalReward += finalScoreboard._totalReward; _dialogger._promptsYOffset = 80; // move prompts down to where they don't cover the final score if (PlayerData.denTotalReward >= PlayerData.DEN_MAX_REWARD) { denDialog.getTooManyGames(tree); } else { denDialog.getReplayMinigame(tree); } } public function exitMinigameState() { var newState:FlxState; if (PlayerData.playerIsInDen) { if (denDestination == "%den-game%") { // rematch newState = MinigameState.fromInt(PlayerData.denMinigame); } else if (denDestination == "%den-sex%") { if (PlayerData.sfw) { // skip sexystate; sfw mode... transOut = MainMenuState.fadeOutSlow(); newState = new ShopState(MainMenuState.fadeInFast()); } else { // sex newState = SexyState.getSexyState(); } } else { // shop newState = new ShopState(); } } else { if (PlayerData.sfw) { // skip sexystate; sfw mode... LevelIntroDialog.rotateChat(); LevelIntroDialog.increaseProfReservoirs(); LevelIntroDialog.rotateProfessors([PlayerData.prevProfPrefix]); transOut = MainMenuState.fadeOutSlow(); newState = new MainMenuState(MainMenuState.fadeInFast()); } else { PlayerData.justFinishedMinigame = true; newState = PuzzleState.initializeSexyState(); } } FlxG.switchState(newState); } public function handleGameAnnouncement(tree:Array<Array<Object>>) { var opponentClass:Class<Dynamic> = getMinigameOpponentDialogClass(); if (PlayerData.playerIsInDen) { var denDialogFunc:Dynamic = Reflect.field(opponentClass, "denDialog"); var denDialog:DenDialog = denDialogFunc(); if (PlayerData.denGameCount == 0) { // first practice game in den denDialog.getGameGreeting(tree, description); } else { // second, third practice game in den } } else { // regular minigame var gameDialogFunc:Dynamic = Reflect.field(opponentClass, "gameDialog"); var gameDialog:GameDialog = gameDialogFunc(Type.getClass(this)); gameDialog.popGameAnnouncement(tree, description); } } public function showFinalScoreboard():Void { _hud.insert(_hud.members.indexOf(_dialogger), finalScoreboard); var eventTime:Float = _eventStack._time + 0.8; for (i in 0...finalScoreboard.getBonusGroupCount()) { _eventStack.addEvent({time:eventTime, callback:finalScoreboard.eventTurnOnBonusGroup}); eventTime += 0.8; } eventTime -= 0.3; _eventStack.addEvent({time:eventTime, callback:eventShowCashWindow}); eventTime += 1.0; _eventStack.addEvent({time:eventTime, callback:eventPay}); eventTime += 2.5; // keep the player here for a little while after payment is done _eventStack.addEvent({time:eventTime, callback:null}); } override public function destroy():Void { super.destroy(); description = null; finalScoreboard = FlxDestroyUtil.destroy(finalScoreboard); denDestination = null; } }
argonvile/monster
source/minigame/MinigameState.hx
hx
unknown
7,554
package minigame.scale; import flixel.FlxSprite; import flixel.effects.FlxFlicker; import flixel.math.FlxMath; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; /** * Countdown graphics used for minigames. * * This does the "3... 2... 1... go!" thing you see at the start of the scale * game. */ class CountdownSprite extends FlxSprite { public static var COUNTDOWN_SECONDS:Float = 0.77; var countdownTime:Float = 0; public function new() { super(334, 136); loadGraphic(AssetPaths.countdown__png, true, 100, 100); exists = false; } override public function update(elapsed:Float):Void { super.update(elapsed); countdownTime += elapsed; var oldIndex:Int = animation.frameIndex; animation.frameIndex = Std.int(FlxMath.bound(countdownTime / COUNTDOWN_SECONDS, 0, 3)); if (oldIndex != animation.frameIndex) { squishEffect(); } if (countdownTime >= COUNTDOWN_SECONDS * 4.5) { exists = false; } } function squishEffect() { FlxTween.tween(scale, {x:1.33, y:0.75}, 0.1, {ease:FlxEase.cubeInOut}); FlxTween.tween(scale, {x:0.75, y:1.33}, 0.1, {ease:FlxEase.cubeInOut, startDelay:0.1}); FlxTween.tween(scale, {x:1, y:1}, 0.1, {ease:FlxEase.cubeInOut, startDelay:0.2}); if (animation.frameIndex < 3) { SoundStackingFix.play(AssetPaths.countdown_00c6__mp3); } if (animation.frameIndex == 3) { FlxFlicker.flicker(this, 0.5, 0.04, false, false); } } public function startCount():Void { countdownTime = 0; exists = true; visible = true; animation.frameIndex = 0; squishEffect(); } }
argonvile/monster
source/minigame/scale/CountdownSprite.hx
hx
unknown
1,639
package minigame.scale; import flixel.util.FlxDestroyUtil; import minigame.scale.ScalePuzzle; import critter.CritterHolder; import critter.EllipseCritterHolder; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.math.FlxAngle; import flixel.math.FlxMath; import flixel.math.FlxRect; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import openfl.geom.Rectangle; /** * Graphics for the scale part of the scale minigame. * * Handles drawing the different parts of the scale, drawing the clock and * bouncing the two halves of the scale up and down */ class Scale extends FlxGroup { private static var MOVEMENT_RANGE:Int = 23; private var _puzzle:ScalePuzzle; public var _posts:Array<FlxSprite> = []; public var _joints:Array<FlxSprite> = []; public var _pads:Array<CritterHolder> = []; public var _notes:Array<FlxSprite> = []; public var _scaleBody:FlxSprite; public var _scaleCenter:FlxSprite; public var _scaleNeedle:FlxSprite; public var _scaleClockBg:FlxSprite; public var _scaleClockHand:FlxSprite; /* * The balance of the scale is simulated with an invisible bouncing sprite. * If the scale is unbalanced heavily to the right, the sprite will be * accelerated to a higher point, such as (0, 250). If the scale is * balanced slightly to the left, the sprite would instead be accelerated * towards a lower point, such as (0, 75). The position of this sprite * decides how we draw the scale. */ public var _balanceSprite:FlxSprite; public var _balance:Float = 0; public var _leftBalanceOffset:Float = 0; public var _rightBalanceOffset:Float = 0; public var _leftJoist:FlxSprite; public var _rightJoist:FlxSprite; public var _centerJoist:FlxSprite; public var _scaleShadow:FlxSprite; private var _leftRange:Float = -1; private var _rightRange:Float = 1; public var _shortScale:Bool; public function new() { super(); _scaleBody = new FlxSprite(21, 231); add(_scaleBody); _scaleCenter = new FlxSprite(0, 104, AssetPaths.scale_center__png); _scaleShadow = new FlxSprite(21, 231); add(_scaleCenter); _scaleClockBg = new FlxSprite(0, 254, AssetPaths.scale_clock_bg__png); add(_scaleClockBg); _scaleClockHand = new FlxSprite(0, 254); _scaleClockHand.makeGraphic(27, 23, FlxColor.TRANSPARENT, true); add(_scaleClockHand); setScaleClockAngle(0, false); _leftJoist = new FlxSprite(0, 183); add(_leftJoist); _rightJoist = new FlxSprite(0, 183); add(_rightJoist); _centerJoist = new FlxSprite(0, 183); add(_centerJoist); _scaleNeedle = new FlxSprite(341, 104, AssetPaths.scale_needle__png); _scaleNeedle.origin.y += 5; add(_scaleNeedle); for (i in 0...4) { var post:FlxSprite = new FlxSprite(0, 179, AssetPaths.scale_post__png); add(post); _posts.push(post); } for (i in 0...4) { var jointAsset:String = (i == 0 || i == 3) ? AssetPaths.scale_joint_end__png : AssetPaths.scale_joint_mid__png; var joint:FlxSprite = new FlxSprite(0, 179, jointAsset); joint.flipX = i >= 2; add(joint); _joints.push(joint); } for (j in 0...7) { if (j % 2 == 1) { continue; } var padY:Int = 170; var pad:EllipseCritterHolder = new EllipseCritterHolder(0, padY); pad._sprite.loadGraphic(AssetPaths.scale_platform__png); pad._sprite.height = 45; pad._sprite.offset.y = 6; pad._leashRadiusX = 45; pad._leashRadiusY = 22; pad._leashOffsetY = -12; _pads.push(pad); add(pad._sprite); } for (i in 0...4) { var note:FlxSprite = new FlxSprite(0, 197); note.makeGraphic(40, 40, FlxColor.TRANSPARENT, true); add(note); _notes.push(note); } _balanceSprite = new FlxSprite(200, 100); _balanceSprite.makeGraphic(6, 6, FlxColor.RED); _balanceSprite.offset.x = 3; _balanceSprite.offset.y = 3; _balanceSprite.elasticity = 0.5; _balanceSprite.visible = false; add(_balanceSprite); } override public function update(elapsed:Float):Void { for (holder in _pads) { holder.leashAll(); } super.update(elapsed); updateSpritesForBalance(elapsed); } public function recalculateBalance():Void { if (_puzzle == null) { return; } _balance = _pads[2]._critters.length * _puzzle._weights[2] + _pads[3]._critters.length * _puzzle._weights[3] - _pads[0]._critters.length * _puzzle._weights[0] - _pads[1]._critters.length * _puzzle._weights[1]; } public function getCritterCount():Int { return _pads[0]._critters.length + _pads[1]._critters.length + _pads[2]._critters.length + _pads[3]._critters.length; } /** * Reshapes the scale according to the specified puzzle */ public function setPuzzle(puzzle:ScalePuzzle) { this._puzzle = puzzle; _balanceSprite.y = 100; _balanceSprite.acceleration.y = 0; _balanceSprite.velocity.y = 0; updateSpritesForBalance(0); for (i in 0...4) { _notes[i].pixels.fillRect(_notes[i].pixels.rect, FlxColor.TRANSPARENT); var noteSprite:FlxSprite = new FlxSprite(0, 0); noteSprite.loadGraphic(AssetPaths.scale_note_small__png, true, 40, 30); noteSprite.animation.frameIndex = FlxG.random.int(0, noteSprite.animation.frames - 1); noteSprite.flipX = FlxG.random.bool(); _notes[i].stamp(noteSprite, 0, 6); var text:FlxText = new FlxText(0, 0, 40, Std.string(_puzzle._weights[i]), 22); text.alignment = "center"; text.color = ItemsMenuState.DARK_BLUE; text.font = AssetPaths.just_sayin__ttf; _notes[i].stamp(text, 0, 10); var tape:FlxSprite = new FlxSprite(0, 0); tape.loadGraphic(AssetPaths.scale_tape__png, true, 20, 20); tape.animation.frameIndex = FlxG.random.int(0, noteSprite.animation.frames - 1); tape.flipX = FlxG.random.bool(); tape.alpha = 0.4; _notes[i].stamp(tape, 10, 0); } var sortedWeights:Array<Int> = _puzzle._weights.copy(); sortedWeights.sort(function(a, b) return a - b); var padPositionIndexes:Array<Float> = []; var centerPostPosition:Float = 0; var padMin:Float = 7; var padMax:Float = 0; for (i in 0...4) { var weightSize:Int = sortedWeights.indexOf(_puzzle._weights[i]); if (i < 2) { padPositionIndexes.push(3 - weightSize); } else { padPositionIndexes.push(4 + weightSize); } if (weightSize == 0) { if (i < 2) { centerPostPosition = 3.8; } else { centerPostPosition = 3.2; } } padMin = Math.min(padMin, padPositionIndexes[padPositionIndexes.length - 1]); padMax = Math.max(padMin, padPositionIndexes[padPositionIndexes.length - 1]); } _shortScale = padMax - padMin < 6 ; _scaleBody.loadGraphic(_shortScale ? AssetPaths.scale_short__png : AssetPaths.scale__png); var shiftAmount:Float = 3 - 0.5 * padMax - 0.5 * padMin; for (i in 0...4) { padPositionIndexes[i] += shiftAmount; } centerPostPosition += shiftAmount; for (i in 0...4) { _pads[i]._sprite.x = padPositionIndexes[i] * 108 + 16; _joints[i].x = padPositionIndexes[i] * 108 + 45; _posts[i].x = padPositionIndexes[i] * 108 + 45; _notes[i].x = padPositionIndexes[i] * 108 + 41 + FlxG.random.float( -10, 10); _notes[i].y = 197; } _scaleCenter.x = centerPostPosition * 108 + 17; _scaleNeedle.x = centerPostPosition * 108 + 17; _scaleClockBg.x = centerPostPosition * 108 + 48; _scaleClockHand.x = centerPostPosition * 108 + 48; { makeJoistGraphic(_leftJoist, Std.int(_pads[1]._sprite.x - _pads[0]._sprite.x)); _leftJoist.x = _pads[0]._sprite.x + 45; makeJoistGraphic(_centerJoist, Std.int(_pads[2]._sprite.x - _pads[1]._sprite.x)); _centerJoist.x = _pads[1]._sprite.x + 45; _centerJoist.origin.x = (_scaleCenter.x + _scaleCenter.width / 2) - _centerJoist.x; makeJoistGraphic(_rightJoist, Std.int(_pads[3]._sprite.x - _pads[2]._sprite.x)); _rightJoist.x = _pads[2]._sprite.x + 45; } { // what's the range of motion for the two sets of platforms? var center1:Float = _scaleCenter.x + _scaleCenter.width / 2; var dist0:Float = center1 - (_pads[1]._sprite.x + _pads[1]._sprite.width / 2); var dist1:Float = (_pads[2]._sprite.x + _pads[2]._sprite.width / 2) - center1; if (dist1 > dist0) { // right side will be moving more _rightRange = MOVEMENT_RANGE; _leftRange = -MOVEMENT_RANGE * (dist0 / dist1); } else { // left side will be moving more _leftRange = -MOVEMENT_RANGE; _rightRange = MOVEMENT_RANGE * (dist1 / dist0); } } // reshape shadow, and clear away the notch at the bottom of the shadow for the center _scaleShadow.loadGraphic(padMax - padMin >= 6 ? AssetPaths.scale_shadow__png : AssetPaths.scale_shadow_short__png, false, 730, 68, true); _scaleShadow.pixels.fillRect(new Rectangle(Std.int(_scaleCenter.x) - _scaleShadow.x, 56, 89, 1), FlxColor.TRANSPARENT); _scaleShadow.pixels.fillRect(new Rectangle(Std.int(_scaleCenter.x) - _scaleShadow.x + 1, 56, 87, 2), FlxColor.TRANSPARENT); _scaleShadow.pixels.fillRect(new Rectangle(Std.int(_scaleCenter.x) - _scaleShadow.x + 2, 56, 85, 3), FlxColor.TRANSPARENT); _scaleShadow.pixels.fillRect(new Rectangle(Std.int(_scaleCenter.x) - _scaleShadow.x + 3, 56, 83, 4), FlxColor.TRANSPARENT); } function makeJoistGraphic(sprite:FlxSprite, width:Int) { var joistTemplate:FlxSprite = new FlxSprite(0, 0, AssetPaths.scale_horizontal_joist__png); joistTemplate.flipX = FlxG.random.bool(); sprite.makeGraphic(width, 38, FlxColor.TRANSPARENT, true); sprite.stamp(joistTemplate, FlxG.random.int(Std.int(width - joistTemplate.width), 0), 0); } function updateSpritesForBalance(elapsed:Float):Void { var balanceSpriteTargetY:Float = _balance * 7 + 100; if (_balance < 0) { balanceSpriteTargetY -= 21; } else if (_balance > 0) { balanceSpriteTargetY += 21; } if (Math.abs(_balanceSprite.y - balanceSpriteTargetY) < 5) { _balanceSprite.acceleration.y = 0; } else if (_balanceSprite.y < balanceSpriteTargetY) { _balanceSprite.acceleration.y = _balanceSprite.y >= 400 ? 0 : 400; } else { _balanceSprite.acceleration.y = _balanceSprite.y <= 0 ? 0 : -400; } if (_balanceSprite.velocity.y > 0) { _balanceSprite.velocity.y = Math.max(0, _balanceSprite.velocity.y - 100 * elapsed); } else if (_balanceSprite.velocity.y < 0) { _balanceSprite.velocity.y = Math.min(0, _balanceSprite.velocity.y + 100 * elapsed); } if (_balanceSprite.y < 0) { _balanceSprite.y = 0; _balanceSprite.velocity.y = Math.max(0, Math.abs(_balanceSprite.velocity.y) * _balanceSprite.elasticity - 3); } else if (_balanceSprite.y > 200) { _balanceSprite.y = 200; _balanceSprite.velocity.y = -Math.max(0, Math.abs(_balanceSprite.velocity.y) * _balanceSprite.elasticity - 3); } var newLeftBalanceOffset:Float = _leftRange * (FlxMath.bound(_balanceSprite.y, 1, 199) - 100) / 100; var newRightBalanceOffset:Float = _rightRange * (FlxMath.bound(_balanceSprite.y, 1, 199) - 100) / 100; if (Std.int(newLeftBalanceOffset) != Std.int(_leftBalanceOffset) || Std.int(newRightBalanceOffset) != Std.int(_rightBalanceOffset)) { for (i in 0...4) { var offsetDiff:Int = i < 2 ? (Std.int(newLeftBalanceOffset) - Std.int(_leftBalanceOffset)) : (Std.int(newRightBalanceOffset) - Std.int(_rightBalanceOffset)); _pads[i]._sprite.y += offsetDiff; for (critter in _pads[i]._critters) { critter.movePosition(0, offsetDiff); } _notes[i].y += offsetDiff; _joints[i].y += offsetDiff; } _leftJoist.y += (Std.int(newLeftBalanceOffset) - Std.int(_leftBalanceOffset)); _rightJoist.y += (Std.int(newRightBalanceOffset) - Std.int(_rightBalanceOffset)); _centerJoist.angle = FlxAngle.asDegrees(Math.atan2(_rightJoist.y - _leftJoist.y, _rightJoist.x - (_leftJoist.x + _leftJoist.width))); _scaleNeedle.angle = _centerJoist.angle; } _leftBalanceOffset = newLeftBalanceOffset; _rightBalanceOffset = newRightBalanceOffset; } public function setScaleClockAngle(angle:Float, flash:Bool):Void { var angleRadians:Float = Math.PI / 2 - FlxAngle.asRadians(angle); _scaleClockHand.pixels.fillRect(new Rectangle(0, 0, _scaleClockHand.width, _scaleClockHand.height), FlxColor.TRANSPARENT); var originX:Int = 13; var originY:Int = 11; if (angle <= 90) { originY += 1; } FlxSpriteUtil.drawLine(_scaleClockHand, originX, originY, originX + Math.cos(angleRadians) * 7, originY - Math.sin(angleRadians) * 7, { color:0xff694c28, thickness: 2 }); FlxSpriteUtil.drawLine(_scaleClockHand, originX, originY, originX + Math.cos(angleRadians) * 8, originY - Math.sin(angleRadians) * 8, { color:0xff694c28, thickness: 1 }); if (flash) { var flashSprite:FlxSprite = new FlxSprite(0, 0, AssetPaths.scale_clock_bg_flash__png); flashSprite.alpha = 0.5; _scaleClockHand.stamp(flashSprite); } } override public function destroy():Void { super.destroy(); _posts = FlxDestroyUtil.destroyArray(_posts); _joints = FlxDestroyUtil.destroyArray(_joints); _pads = FlxDestroyUtil.destroyArray(_pads); _notes = FlxDestroyUtil.destroyArray(_notes); _scaleBody = FlxDestroyUtil.destroy(_scaleBody); _scaleCenter = FlxDestroyUtil.destroy(_scaleCenter); _scaleNeedle = FlxDestroyUtil.destroy(_scaleNeedle); _scaleClockBg = FlxDestroyUtil.destroy(_scaleClockBg); _scaleClockHand = FlxDestroyUtil.destroy(_scaleClockHand); _balanceSprite = FlxDestroyUtil.destroy(_balanceSprite); _leftJoist = FlxDestroyUtil.destroy(_leftJoist); _rightJoist = FlxDestroyUtil.destroy(_rightJoist); _centerJoist = FlxDestroyUtil.destroy(_centerJoist); _scaleShadow = FlxDestroyUtil.destroy(_scaleShadow); } }
argonvile/monster
source/minigame/scale/Scale.hx
hx
unknown
13,821
package minigame.scale; import flixel.FlxG; import flixel.math.FlxMath; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; /** * Defines the behavior for an opponent in the scale minigame */ class ScaleAgent implements IFlxDestroyable { public static var UNFINISHED:Int = 1000; // reflexes; how long you stare at a puzzle before you understand it private static var REFLEXES:Array<Float> = [10.115, 5.871, 3.386, 2.218, 1.440, 1.200, 1.000, 0.909, 0.826, 0.751]; // cleverness; after you understand a puzzle, how long does it take you to find an answer private static var CLEVERNESS:Array<Float> = [2.822, 1.872, 1.440, 1.100, 0.833, 0.688, 0.568, 0.516, 0.469, 0.426]; // reliability; how consistent are you at finding an answer private static var RELIABILITY:Array<Float> = [0.992, 1.282, 1.667, 2.182, 2.880, 3.456, 4.147, 4.562, 5.018, 5.520]; // physical; how quickly can you hit the keys on the keyboard and click the mouse private static var PHYSICAL:Array<Float> = [4.180, 3.234, 2.488, 1.584, 1.200, 1.000, 0.833, 0.757, 0.688, 0.625]; private var _reflexes:Int; private var _cleverness:Int; private var _reliability:Int; private var _physical:Int; public var _time:Float = 1000000; public var _finishedOrder:Int = UNFINISHED; public var _soundAsset:String; public var _chatAsset:String; public var _dialogClass:Dynamic; public var _name:String; public var _gender:PlayerData.Gender; public var _gameDialog:GameDialog; public var _mercy:Float = 0; public function new(reflexes:Int=0, cleverness:Int=0, reliability:Int=0, physical:Int=0) { this._reflexes = reflexes; this._cleverness = cleverness; this._reliability = reliability; this._physical = physical; } public function setDialogClass(dialogClass:Dynamic) { this._dialogClass = dialogClass; var gameDialog:Dynamic = Reflect.field(_dialogClass, "gameDialog"); this._gameDialog = gameDialog(ScaleGameState); } /** * Computes the amount of time it takes a Pokemon to solve a given scale * puzzle. * * I originally had a rudimentary AI where they'd experiment with different * solutions and actually move bugs around -- but, it was less performant * and less predictable. * * From a black-box perspective there's not much difference between an * algorithm spitting out a number like "8.6 seconds" and an algorithm * simulating an AI for 8.6 seconds. Although, I'll admit the former does * feel a little icky. * * @param difficulty scale puzzle's difficulty (3, 4, 5 or 6 bugs) * @param puzzleSolution sum on both sides of the scale; the AI is slower * at solving puzzles with bigger numbers */ public function computeTime(difficulty:Int, puzzleSolution:Int) { var cMin:Float; var cMax:Float; if (difficulty == 3) { cMin = 0.5; cMax = 0.4; } else if (difficulty == 4) { cMin = 1.0; cMax = 0.6; } else if (difficulty == 5) { cMin = 3.3; cMax = 1.5; } else if (difficulty == 6) { cMin = 4.7; cMax = 3.0; } else { cMin = 54; cMax = 24; } var clev = CLEVERNESS[Std.int(FlxMath.bound(_cleverness - _mercy * 0.25 + 0.80, 0, 9))]; var refl = REFLEXES[Std.int(FlxMath.bound(_reflexes - _mercy * 0.25 + 0.60, 0, 9))]; var reli = RELIABILITY[Std.int(FlxMath.bound(_reliability - _mercy * 0.25 + 0.40, 0, 9))]; var phys = PHYSICAL[Std.int(FlxMath.bound(_physical - _mercy * 0.25 + 0.20, 0, 9))]; var randBetween:Float = puzzleSolution * (clev * 0.3 + 0.7) * cMax * (refl * FlxG.random.float(0.8, 1.2)); var d:Float = FlxG.random.float(0, 2); while (d < reli) { var a:Float = (refl * FlxG.random.float(0.8, 1.2) * 0.7 + 0.3) * cMin; var b:Float = puzzleSolution * clev * cMax; randBetween = Math.min(randBetween, FlxG.random.float(a, b)); var e:Float = 2 / (reli * 0.7 + 0.6); cMin += FlxG.random.float(0, e); d += FlxG.random.float(0, 2); } // it takes about 1 second to move a peg to a scale platform var taskLength:Float = (0.95 * difficulty) * FlxG.random.float(0.8, 1.2); randBetween += taskLength * phys * 0.5; if (_reflexes == 9 && _cleverness == 9 && _reliability == 9) { // someone this clever just solves stuff instantly randBetween = 0; } randBetween = Math.max(randBetween, taskLength); _time = randBetween + ScaleGameState.BALANCE_DURATION; } public function isDone() { return _finishedOrder != UNFINISHED; } public function destroy():Void { _soundAsset = null; _chatAsset = null; _dialogClass = null; _name = null; _gameDialog = FlxDestroyUtil.destroy(_gameDialog); } }
argonvile/monster
source/minigame/scale/ScaleAgent.hx
hx
unknown
4,751
package minigame.scale; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import poke.abra.AbraDialog; import poke.abra.AbraResource; import minigame.scale.ScaleAgent; import poke.buiz.BuizelDialog; import poke.buiz.BuizelResource; import flixel.FlxG; import flixel.math.FlxMath; import poke.grim.GrimerDialog; import poke.grim.GrimerResource; import poke.grov.GrovyleDialog; import poke.grov.GrovyleResource; import poke.hera.HeraDialog; import poke.hera.HeraResource; import poke.kecl.KecleonDialog; import poke.luca.LucarioDialog; import poke.luca.LucarioResource; import poke.magn.MagnDialog; import poke.magn.MagnResource; import poke.rhyd.RhydonDialog; import poke.rhyd.RhydonResource; import poke.sand.SandslashDialog; import poke.sand.SandslashResource; import poke.smea.SmeargleDialog; /** * Stores the behavior for the different opponents in the scale minigame. * * I simulated about 60 agents and chose a variety of behaviors to represent * as Pokemon. The lines prefixed with numbers and asterisks correspond to * certain Pokemon; for example "bonnie" is "Grovyle". * * 01**patrick: reflexes=6 cleverness=8 reliability=9 physical=8: 10.49 * dennis: reflexes=6 cleverness=9 reliability=8 physical=8: 10.52 * anette: reflexes=5 cleverness=8 reliability=9 physical=6: 10.94 * angela: reflexes=7 cleverness=8 reliability=7 physical=6: 11.09 * kaya: reflexes=9 cleverness=9 reliability=6 physical=4: 11.28 * 02**sam: reflexes=9 cleverness=7 reliability=8 physical=4: 11.61 * ariana: reflexes=4 cleverness=7 reliability=8 physical=6: 11.64 * michael: reflexes=4 cleverness=9 reliability=7 physical=4: 11.97 * pierce: reflexes=5 cleverness=8 reliability=5 physical=7: 12.11 * matthew: reflexes=7 cleverness=6 reliability=6 physical=7: 12.11 * alan: reflexes=6 cleverness=5 reliability=8 physical=6: 12.24 * william: reflexes=5 cleverness=5 reliability=8 physical=9: 12.27 * natalie: reflexes=9 cleverness=6 reliability=5 physical=4: 13.19 * harold: reflexes=4 cleverness=5 reliability=6 physical=6: 13.67 * bruce: reflexes=3 cleverness=9 reliability=8 physical=3: 13.76 * eriq: reflexes=9 cleverness=3 reliability=9 physical=8: 13.78 * 03**stephen: reflexes=2 cleverness=9 reliability=5 physical=9: 14.02 * glenn: reflexes=5 cleverness=4 reliability=7 physical=5: 14.14 * boyd: reflexes=4 cleverness=7 reliability=3 physical=9: 14.43 * jeff: reflexes=6 cleverness=3 reliability=9 physical=5: 14.62 * jessica: reflexes=3 cleverness=5 reliability=8 physical=4: 14.88 * mackenzie: reflexes=8 cleverness=3 reliability=8 physical=8: 14.99 * morena: reflexes=6 cleverness=8 reliability=5 physical=2: 15.01 * joseph: reflexes=6 cleverness=9 reliability=5 physical=2: 15.10 * anne: reflexes=2 cleverness=6 reliability=6 physical=7: 15.13 * orlando: reflexes=5 cleverness=5 reliability=4 physical=7: 15.23 * ryan: reflexes=2 cleverness=7 reliability=4 physical=8: 15.72 * 04**andie: reflexes=3 cleverness=7 reliability=3 physical=3: 16.83 * ed: reflexes=8 cleverness=2 reliability=8 physical=3: 17.93 * rachel: reflexes=1 cleverness=6 reliability=4 physical=9: 18.70 * matt: reflexes=4 cleverness=4 reliability=7 physical=1: 19.09 * keanu: reflexes=1 cleverness=5 reliability=6 physical=9: 19.32 * gina: reflexes=1 cleverness=4 reliability=8 physical=9: 19.79 * geoffrey: reflexes=7 cleverness=2 reliability=5 physical=6: 20.44 * sarah: reflexes=4 cleverness=1 reliability=8 physical=6: 20.69 * 05**brenton: reflexes=1 cleverness=8 reliability=7 physical=2: 20.90 * johnny: reflexes=6 cleverness=2 reliability=6 physical=3: 21.22 * joe: reflexes=3 cleverness=1 reliability=9 physical=5: 21.47 * jack: reflexes=5 cleverness=1 reliability=7 physical=5: 21.49 * eliza: reflexes=1 cleverness=4 reliability=9 physical=3: 21.57 * tia: reflexes=4 cleverness=5 reliability=2 physical=9: 22.92 * hugh: reflexes=1 cleverness=4 reliability=5 physical=3: 23.12 * reginald: reflexes=3 cleverness=8 reliability=2 physical=9: 24.03 * 06**arnold: reflexes=6 cleverness=2 reliability=8 physical=0: 24.67 * tom: reflexes=8 cleverness=5 reliability=0 physical=6: 25.00 * 07**richard: reflexes=9 cleverness=0 reliability=9 physical=2: 26.60 * alexander: reflexes=7 cleverness=4 reliability=1 physical=3: 26.96 * brianna: reflexes=8 cleverness=2 reliability=2 physical=8: 27.98 * 08**aura: reflexes=2 cleverness=1 reliability=5 physical=4: 28.72 * javier: reflexes=4 cleverness=1 reliability=4 physical=3: 29.75 * 09**bill: reflexes=4 cleverness=3 reliability=1 physical=8: 35.76 * sandra: reflexes=9 cleverness=0 reliability=2 physical=8: 37.45 * rick: reflexes=8 cleverness=2 reliability=0 physical=1: 38.29 * 10**jamie: reflexes=8 cleverness=1 reliability=1 physical=2: 38.74 * 11**bonnie: reflexes=1 cleverness=3 reliability=1 physical=8: 92.75 */ class ScaleAgentDatabase implements IFlxDestroyable { var _allAgents:Array<ScaleAgent> = []; var _nameToAgentMap:Map<String, ScaleAgent> = new Map<String, ScaleAgent>(); public function new() { /* * These agents are approximately sorted in order of difficulty, * although they each have subtle strengths and weaknesses */ { // grovyle is always available var agent:ScaleAgent = new ScaleAgent(1, 3, 1, 8); agent._soundAsset = AssetPaths.grovyle__mp3; agent._chatAsset = GrovyleResource.chat; agent._name = "Grovyle"; agent._gender = PlayerData.grovMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(GrovyleDialog); addAgent(agent); } if (PlayerData.hasMet("sand")) { var agent:ScaleAgent = new ScaleAgent(8, 1, 1, 2); agent._soundAsset = AssetPaths.sand__mp3; agent._chatAsset = SandslashResource.chat; agent._name = "Sandslash"; agent._gender = PlayerData.sandMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(SandslashDialog); addAgent(agent); } if (PlayerData.hasMet("rhyd")) { var agent:ScaleAgent = new ScaleAgent(4, 3, 1, 8); agent._soundAsset = AssetPaths.rhyd__mp3; agent._chatAsset = RhydonResource.chat; agent._name = "Rhydon"; agent._gender = PlayerData.rhydMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(RhydonDialog); addAgent(agent); } { // always add buizel; he teaches the rules anyways var agent:ScaleAgent = new ScaleAgent(2, 1, 5, 4); agent._soundAsset = AssetPaths.buizel__mp3; agent._chatAsset = BuizelResource.chat; agent._name = "Buizel"; agent._gender = PlayerData.buizMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(BuizelDialog); addAgent(agent); } if (PlayerData.hasMet("grim")) { var agent:ScaleAgent = new ScaleAgent(9, 0, 9, 2); agent._soundAsset = AssetPaths.grim__mp3; agent._chatAsset = GrimerResource.chat; agent._name = "Grimer"; agent._gender = PlayerData.grimMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(GrimerDialog); addAgent(agent); } if (PlayerData.hasMet("luca")) { var agent:ScaleAgent = new ScaleAgent(6, 2, 8, 0); agent._soundAsset = AssetPaths.luca__mp3; agent._chatAsset = LucarioResource.chat; agent._name = "Lucario"; agent._gender = PlayerData.lucaMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(LucarioDialog); addAgent(agent); } if (PlayerData.hasMet("kecl")) { var agent:ScaleAgent = new ScaleAgent(1, 8, 7, 2); agent._soundAsset = AssetPaths.kecleon__mp3; agent._chatAsset = AssetPaths.kecl_chat__png; agent._name = "Kecleon"; agent._gender = PlayerData.keclMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(KecleonDialog); addAgent(agent); } { // heracross is always available var agent:ScaleAgent = new ScaleAgent(2, 9, 5, 9); agent._soundAsset = AssetPaths.hera__mp3; agent._chatAsset = HeraResource.chat; agent._name = "Heracross"; agent._gender = PlayerData.heraMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(HeraDialog); addAgent(agent); } if (PlayerData.hasMet("smea")) { var agent:ScaleAgent = new ScaleAgent(9, 7, 8, 4); agent._soundAsset = AssetPaths.smea__mp3; agent._chatAsset = AssetPaths.smear_chat__png; agent._name = "Smeargle"; agent._gender = PlayerData.smeaMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(SmeargleDialog); addAgent(agent); } if (PlayerData.hasMet("magn")) { var agent:ScaleAgent = new ScaleAgent(6, 8, 9, 8); agent._soundAsset = AssetPaths.magn__mp3; agent._chatAsset = MagnResource.chat; agent._name = "Magnezone"; agent._gender = PlayerData.magnMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(MagnDialog); addAgent(agent); } { // abra is always available var agent:ScaleAgent = new ScaleAgent(9, 9, 9, 5); agent._soundAsset = AssetPaths.abra__mp3; agent._chatAsset = AbraResource.chat; agent._name = "Abra"; agent._gender = PlayerData.abraMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl; agent.setDialogClass(AbraDialog); addAgent(agent); } } /** * Decide the list of opponents. * * The opponents include the player's puzzle partner, and an opponent who's * at the player's skill level. It also includes a third opponent who is * usually weaker than the player, but occasionally stronger. * * This is so that even bad players might *occasionally* get to play * against a really strong opponent. It's not very much fun to lose, but * it's at least nice to play against the stronger pokemon once in a while * * @return opponents the player will play against */ public function getAgents():Array<ScaleAgent> { var _agents:Array<ScaleAgent> = []; { // Player is agent #0... var agent:ScaleAgent = new ScaleAgent(); agent._time = 1000000000; agent._chatAsset = AssetPaths.empty_chat__png; agent._name = PlayerData.name; agent._gender = PlayerData.gender; _agents.push(agent); } var _tempAgents:Array<ScaleAgent> = _allAgents.copy(); // Current opponent is agent #1... if (_nameToAgentMap[PlayerData.PROF_NAMES[PlayerData.profIndex]] == null) { // active professor doesn't have minigame persona? ...just add someone as a placeholder _agents.push(_tempAgents[0]); } else { _agents.push(_nameToAgentMap[PlayerData.PROF_NAMES[PlayerData.profIndex]]); } _tempAgents.remove(_agents[_agents.length - 1]); if (PlayerData.playerIsInDen) { // player's in the den; no other opponents return _agents; } var fair:Bool = FlxG.random.float() > 0.1; var matchIndex:Int = Std.int(FlxMath.bound(PlayerData.scaleGameOpponentDifficulty * _tempAgents.length, 0, _tempAgents.length - 1)); if (PlayerData.minigameCount[0] == 0) { // Always stick Buizel in someone's first scale game, so he can teach the rules for (i in 0..._tempAgents.length) { if (_tempAgents[i]._name == "Buizel") { matchIndex = i; break; } } fair = true; } // Properly matched agent is agent #2... _agents.push(_tempAgents.splice(matchIndex, 1)[0]); _tempAgents.remove(_agents[_agents.length - 1]); // Determine eligible agents based on difficulty... if (fair) { // 90% chance of fair match; remove hard professors _tempAgents = _tempAgents.slice(0, Std.int(Math.max(1, matchIndex))); } else { // 10% chance of unfair match; remove easy professors _tempAgents = _tempAgents.slice(Std.int(Math.min(matchIndex, _tempAgents.length - 1)), _tempAgents.length); } // Agent #3 is random, but usually worse than agent #2 _agents.push(FlxG.random.getObject(_tempAgents)); if (PlayerData.minigameCount[0] == 0 && _allAgents.indexOf(_agents[3]) > _allAgents.indexOf(_agents[2])) { // agent #3 is too hard for an intro game _agents.splice(3, 1); } return _agents; } function addAgent(agent:ScaleAgent):Void { _allAgents.push(agent); _nameToAgentMap[agent._name] = agent; } /** * Calculates whether or not the computer opponent is too challenging. If * this is the case, the computer player will offer to not play. * * @param agent computer opponent to check * @return true if the computer opponent is too challenging */ public function isMismatched(agent:ScaleAgent):Bool { var matchIndex:Int = Std.int(PlayerData.scaleGameOpponentDifficulty * _allAgents.length); var agentIndex:Int = _allAgents.indexOf(agent); if (PlayerData.minigameCount[0] == 0) { var buizelIndex:Int = 0; for (i in 0..._allAgents.length) { if (_allAgents[i]._name == "Buizel") { buizelIndex = i; break; } } // for someone's first game -- don't match them with anyone harder than buizel return agentIndex > buizelIndex; } // if the player's ideal opponent is #5... then #5 and #6 are OK, but #7 is not return agentIndex > matchIndex + 1; } public function destroy():Void { _allAgents = FlxDestroyUtil.destroyArray(_allAgents); _nameToAgentMap = null; } }
argonvile/monster
source/minigame/scale/ScaleAgentDatabase.hx
hx
unknown
13,402
package minigame.scale; import minigame.MinigameState.denNerf; import minigame.scale.ScaleGameState; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import puzzle.Puzzle; /** * The scoreboard which displays at the very end of the scale minigame, showing * the player how many points they earned */ class ScaleFinalScoreboard extends FinalScoreboard { private var scaleGameState:ScaleGameState; public function new(scaleGameState:ScaleGameState) { this.scaleGameState = scaleGameState; super(); } override public function addBonuses():Void { addScore("Score", scaleGameState._scalePlayerStatus._totalScores[0]); var victoryMargin:Int = 10000; var bestAgentName:String = "Abra"; for (i in 1...scaleGameState._agentSprites.length) { var difference:Int = Std.int(Math.min(victoryMargin, scaleGameState._scalePlayerStatus._totalScores[0] - scaleGameState._scalePlayerStatus._totalScores[i])); if (difference < victoryMargin) { victoryMargin = difference; bestAgentName = scaleGameState._scalePlayerStatus._agents[i]._name; } } if (victoryMargin >= 0) { addBonus("Victory bonus", denNerf(400)); } if (victoryMargin >= denNerf(350)) { addBonus("Flawless bonus", denNerf(600)); } if (_totalReward > 0 && _totalReward < denNerf(400)) { // player didn't do very well; give them some compensation in the form of a silly bonus var pityAmount:Int = Puzzle.getSmallestRewardGreaterThan((denNerf(400) - _totalReward) * FlxG.random.float(0.18, 0.54)); var randomBonuses:Array<String> = ["Style bonus", "Happening bonus", "Slow and steady bonus", bestAgentName + " cheated bonus", "Good sport bonus", "Pineapple bonus", "Banana bonus", "Math is hard bonus"]; if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Gay) { randomBonuses.push("Homosexual bonus"); randomBonuses.push("Zero vagina bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Lesbian) { randomBonuses.push("Lesbian bonus"); randomBonuses.push("Zero penis bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Straight) { randomBonuses.push("Heterosexual bonus"); randomBonuses.push("Hooray for boobies bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Bisexual) { randomBonuses.push("Bisexual bonus"); randomBonuses.push("Hooray for boobies bonus"); } if (PlayerData.gender == PlayerData.Gender.Boy) { randomBonuses.push("Penis bonus"); randomBonuses.push("Bold erection bonus"); } else if (PlayerData.gender == PlayerData.Gender.Girl) { randomBonuses.push("Vagina bonus"); randomBonuses.push("Menstruation bonus"); } addBonus(FlxG.random.getObject(randomBonuses), pityAmount); } } }
argonvile/monster
source/minigame/scale/ScaleFinalScoreboard.hx
hx
unknown
3,070
package minigame.scale; import minigame.scale.ScaleAgent; import flixel.FlxSprite; import flixel.math.FlxRect; import flixel.util.FlxColor; import openfl.display.BitmapData; /** * A Pokemon portrait which appears on the side during the scale minigame */ class ScaleFrame extends RoundedRectangle { private var _target:FlxSprite; private var _targetRect:FlxRect = FlxRect.get(0, 0, 0, 0); private var _tmpRect:FlxRect; private var _agent:ScaleAgent; private var _done:Bool = false; public function new(target:FlxSprite, agent:ScaleAgent) { super(); this._target = target; this._agent = agent; // needs to be unique because of the 1st/2nd/3rd stuff this._unique = true; maybeRefreshRect(); } override public function update(elapsed:Float):Void { super.update(elapsed); if (!_target.exists) { kill(); return; } maybeRefreshRect(); visible = _target.visible; } /** * Redraws the frame's picture if necessary (if the Pokemon recently solved * the puzzle) */ function maybeRefreshRect() { _tmpRect = _target.getHitbox(_tmpRect); if (!_tmpRect.equals(_targetRect) || _done != _agent.isDone()) { var borderColor:FlxColor = _agent.isDone() ? 0xFF00FF18 : ItemsMenuState.DARK_BLUE; var centerColor:FlxColor = _agent.isDone() ? 0x443FA4BF : FlxColor.TRANSPARENT; relocate(Std.int(_tmpRect.x - 1), Std.int(_tmpRect.y - 1), Std.int(_tmpRect.width + 2), Std.int(_tmpRect.height + 2), borderColor, centerColor, 2); _targetRect.copyFrom(_tmpRect); _done = _agent.isDone(); if (_agent._finishedOrder < ScaleAgent.UNFINISHED) { var first:FlxSprite = new FlxSprite(0, 0); first.loadGraphic(AssetPaths.scale_1st__png, true, 73, 71); first.animation.frameIndex = Std.int(Math.min(2, _agent._finishedOrder - 1)); first.scale.copyFrom(_target.scale); first.updateHitbox(); stamp(first, -Std.int(first.offset.x), -Std.int(first.offset.y)); } } } }
argonvile/monster
source/minigame/scale/ScaleFrame.hx
hx
unknown
2,003
package minigame.scale; import MmStringTools.*; import critter.Critter; import critter.CritterHolder; import flixel.FlxG; import flixel.FlxSprite; import flixel.effects.particles.FlxEmitter; import flixel.effects.particles.FlxParticle; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRect; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxDestroyUtil; import kludge.FlxSoundKludge; import kludge.LateFadingFlxParticle; import minigame.scale.ScaleAgent; import minigame.scale.ScaleScoreboard; import openfl.utils.Object; /** * The FlxState for the scale minigame. * * The scale game lasts about 5-10 rounds. During each round, the player races * other Pokemon to arrange 3-6 bugs on scales to get the two sides to balance. * You're awarded points for 1st, 2nd or 3rd, and the first person to reach * 1,000 points is the winner. */ class ScaleGameState extends MinigameState { public static var BALANCE_DURATION = 3.6; public static var TARGET_SCORE:Int = 1000; private var _whumpClouds:FlxEmitter; private var _scale:Scale; public var _answerOkGroup:FlxTypedGroup<LateFadingFlxParticle>; private var _puzzle:ScalePuzzle; private var _releaseTimer:Float = 0; private var _crucialCritters:Array<Critter> = []; private var _lightsManager:LightsManager; public var _scalePlayerStatus:ScalePlayerStatus; public var _agentSprites:Array<FlxSprite> = []; private var _clockToggle:Array<Float> = []; private var _canClickCritters:Bool = false; private var _scaleScoreboard:ScaleScoreboard; private var _speedupTimer:Float = 0; private var _countdownSprite:CountdownSprite; private var _roundNumber:Int = 0; private var _puzzleArea:FlxRect = FlxRect.get(45, 292, 642, 113); public function new() { super(); description = PlayerData.MINIGAME_DESCRIPTIONS[0]; duration = 3.0; avgReward = 1000; } override public function create():Void { super.create(); Critter.shuffleCritterColors(); setState(100); _lightsManager = new LightsManager(); for (i in 0...10) { var critter = new Critter(100 + 40 * i, 550, _backdrop); critter.setColor(Critter.CRITTER_COLORS[FlxG.random.int(0, 4)]); addCritter(critter); } _scalePlayerStatus = new ScalePlayerStatus(); _scalePlayerStatus._doneCallback = playerFinished; _scale = new Scale(); _puzzle = ScalePuzzleDatabase.randomPuzzle(); preparePuzzleAndCritters(); _backSprites.add(_scale); _whumpClouds = new FlxEmitter(0, 0, 37); for (i in 0..._whumpClouds.maxSize) { var particle:FlxParticle = new FlxParticle(); particle.loadGraphic(AssetPaths.poofs__png, true, 40, 40); particle.flipX = FlxG.random.bool(); particle.animation.frameIndex = FlxG.random.int(0, particle.animation.frames); particle.exists = false; _whumpClouds.add(particle); } _whumpClouds.launchMode = FlxEmitterMode.SQUARE; _whumpClouds.velocity.start.set(new FlxPoint(-200, -100), new FlxPoint(200, 50)); _whumpClouds.alpha.start.set(0.5, 1.0); _whumpClouds.alpha.end.set(0); _whumpClouds.lifespan.set(0.25, 0.5); _whumpClouds.start(false, 1.0, 0x0FFFFFFF); _whumpClouds.emitting = false; _backSprites.add(_whumpClouds); _shadowGroup._extraShadows.push(_scale._scaleShadow); _hud.add(_lightsManager._spotlights); _scaleScoreboard = new ScaleScoreboard(this); _hud.add(_scaleScoreboard); _scaleScoreboard.exists = false; for (i in 0..._scalePlayerStatus._agents.length) { var agentSprite:FlxSprite = new FlxSprite(2, 2); if (i == 0) { /* * one might expect "unique" to guarantee stamping doesn't gunk up the original sprite; * but other references to empty_chat will have hands stamped on them unless we set a key */ agentSprite.loadGraphic(_scalePlayerStatus._agents[i]._chatAsset, true, 73, 71, false, "A92CP7AE95"); } else { agentSprite.loadGraphic(_scalePlayerStatus._agents[i]._chatAsset, true, 73, 71); } agentSprite.scale.x = 0.55; agentSprite.scale.y = 0.55; agentSprite.updateHitbox(); agentSprite.animation.frameIndex = 4; if (i == 0) { agentSprite.animation.frameIndex = 1; agentSprite.stamp(_handSprite, -50, -70); } _hud.add(agentSprite); _agentSprites.push(agentSprite); } updateAgentSpritePositions(); for (i in 0..._scalePlayerStatus._agents.length) { _hud.add(new ScaleFrame(_agentSprites[i], _scalePlayerStatus._agents[i])); } _answerOkGroup = new FlxTypedGroup<LateFadingFlxParticle>(); _answerOkGroup.maxSize = 1; for (i in 0..._answerOkGroup.maxSize) { var sprite:LateFadingFlxParticle = new LateFadingFlxParticle(); sprite.loadGraphic(AssetPaths.clue_checkmark__png, true, 64, 64); sprite.exists = false; _answerOkGroup.add(sprite); } _countdownSprite = new CountdownSprite(); _hud.add(_countdownSprite); _hud.add(_answerOkGroup); _hud.add(_cashWindow); _hud.add(_dialogger); _hud.add(_helpButton); if (PlayerData.minigameCount[0] == 0) { // start tutorial setState(79); } } /** * @return The dialog class which handles when the user clicks the help button */ override public function getMinigameOpponentDialogClass():Class<Dynamic> { return _scalePlayerStatus._agents[1]._dialogClass; } function updateAgentSpritePositions() { if (_gameState <= 200 || _gameState >= 400) { var orderedAgents:Array<ScaleAgent> = _scalePlayerStatus._agents.copy(); orderedAgents.sort(function(a, b) { if (a._finishedOrder != b._finishedOrder) return a._finishedOrder - b._finishedOrder; return _scalePlayerStatus._agents.indexOf(a) - _scalePlayerStatus._agents.indexOf(b); }); for (i in 0...orderedAgents.length) { var agentSprite:FlxSprite = _agentSprites[_scalePlayerStatus._agents.indexOf(orderedAgents[i])]; agentSprite.x = 3; agentSprite.y = 3 + 42 * i; } for (i in 1..._scalePlayerStatus._agents.length) { if (_gameState == 190) { _agentSprites[i].animation.frameIndex = 4; } else if (_scalePlayerStatus._agents[i]._finishedOrder == 1) { _agentSprites[i].animation.frameIndex = 2; } else if (_scalePlayerStatus._agents[i]._finishedOrder < ScaleAgent.UNFINISHED) { _agentSprites[i].animation.frameIndex = 4; } else { _agentSprites[i].animation.frameIndex = 6; } } } } /** * The game state progresses through several states: * * 79-89: tutorial * 100: pregame * 190: countdown * 200: playing * 300: displaying scoreboard * 400: displaying end-game scoreboard * 500: skip minigame */ override public function update(elapsed:Float):Void { if (_gameState == 81 && _eventStack._alive) { // during tutorials, don't let them dismiss if events are playing _dialogger._canDismiss = false; } else { _dialogger._canDismiss = true; } if (_gameState == 200) { _scalePlayerStatus.update(elapsed); } updateClock(elapsed); if (_gameState == 190) { // countdown if (!_countdownSprite.exists) { _countdownSprite.startCount(); _canClickCritters = false; } if (_countdownSprite.animation.frameIndex == 3) { _canClickCritters = true; setState(200); updateAgentSpritePositions(); setScaleVisible(true); } } if (_gameState == 200 || _gameState == 82) { if (_scalePlayerStatus._agents[0].isDone()) { _speedupTimer -= elapsed; if (_speedupTimer < 0) { // player is done; make everyone else finish quickly for (i in 0...5) { _scalePlayerStatus.update(elapsed); updateClock(elapsed); } } } if (_releaseTimer > 0) { _releaseTimer -= elapsed; if (_releaseTimer <= 0) { if (_scale.getCritterCount() == _puzzle._totalPegCount) { // solved humanSolvedPuzzle(); if (_gameState == 82) { // you don't keep your 200 points _scalePlayerStatus._roundScores[0] = 0; // progress to the next part of the tutorial var tree:Array<Array<Object>> = TutorialDialog.scaleGamePartTwo(); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); _eventStack.addEvent({time:_eventStack._time + 0.8, callback:eventSetState, args:[84]}); } } else { // balanced, but didn't use all the critters var eventTime:Float = _eventStack._time + 0.1; var unusedCritter:Critter = null; for (critter in _crucialCritters) { if (findPad(critter) == null) { unusedCritter = critter; } } _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[AssetPaths.clue_bad_00ff__mp3]}); _eventStack.addEvent({time:eventTime, callback:eventAnswerOk, args:[0, false]}); if (unusedCritter != null) { _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventLightsDim}); _eventStack.addEvent({time:eventTime, callback:eventCreateCritterSpotlight, args:[unusedCritter, "wrongCritter"]}); _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventSpotlightOn, args:["wrongCritter"]}); _eventStack.addEvent({time:eventTime + 1.5, callback:_lightsManager.eventLightsOn}); _eventStack.addEvent({time:eventTime + 2.1, callback:eventDeleteCritterSpotlight, args:["wrongCritter"]}); } } } } } super.update(elapsed); if (_gameState == 200) { if (_scalePlayerStatus.isRoundOver()) { var eventTime:Float = _eventStack._time + 0.1; if (!_scalePlayerStatus._agents[0].isDone()) { if (_scale.getCritterCount() == _puzzle._totalPegCount && _scale._balance == 0) { // human solved it at the last second humanSolvedPuzzle(); } else { // human was stumped eventTime = spoilAnswer(); } } _scalePlayerStatus.finishRound(); _eventStack.addEvent({time:eventTime + 1.5, callback:eventSetState, args:[300]}); for (i in 0..._agentSprites.length) { // did any computer players solve it at the last second too? var agent:ScaleAgent = _scalePlayerStatus._agents[i]; if (!agent.isDone() && agent._time <= _scalePlayerStatus._elapsedPuzzleTime + BALANCE_DURATION) { if (agent._soundAsset != null) { FlxSoundKludge.play(agent._soundAsset, 0.4); } _scalePlayerStatus.playerFinished(i); } } } } for (critter in _crucialCritters) { if (_grabbedCritter == critter) { // don't mess with grabbed critter continue; } if (findPad(critter) != null) { // critters on pads don't wander home continue; } if (!isInPuzzleArea(critter)) { critter.setIdle(); critter._eventStack.reset(); // critter should run back to the puzzle area if (critter._soulSprite.x < 390) { critter.runTo(FlxG.random.float(_puzzleArea.left + 10, 390), FlxG.random.float(_puzzleArea.top + 10, _puzzleArea.bottom - 10)); } else { critter.runTo(FlxG.random.float(390, _puzzleArea.right - 10), FlxG.random.float(_puzzleArea.top + 10, _puzzleArea.bottom - 10)); } } } if (_gameState == 300) { // drop any held critters in between rounds maybeReleaseCritter(); _lightsManager.setLightsDim(); _scaleScoreboard.exists = true; setState(305); { // scoreboard should appear var eventTime:Float = _eventStack._time + 0.1; _eventStack.addEvent({time:eventTime += 0.8, callback:_scaleScoreboard.eventShowRoundScores}); _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[AssetPaths.beep_0065__mp3]}); _eventStack.addEvent({time:eventTime += 1.3, callback:_scaleScoreboard.eventShowTotalScores}); _eventStack.addEvent({time:eventTime, callback:_scaleScoreboard.eventAccumulateTotalScores}); _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventLightsOn}); _eventStack.addEvent({time:eventTime += 2.4, callback:eventSetState, args:[310]}); } { // critters should get off of scales var eventTime:Float = _eventStack._time + 0.1; var crittersToJumpOff:Array<Critter> = []; for (i in 0...4) { for (j in 0..._scale._pads[i]._critters.length) { if (_scale._pads[i]._critters[j].outCold) { // out cold; can't jump } else { crittersToJumpOff.push(_scale._pads[i]._critters[j]); } } } FlxG.random.shuffle(crittersToJumpOff); for (critter in crittersToJumpOff) { _eventStack.addEvent({time:eventTime += 0.2, callback:eventCritterJumpOff, args:[critter]}); } _crucialCritters.splice(0, _crucialCritters.length); } if (!_scalePlayerStatus._agents[0].isDone()) { // human didn't finish; lower the puzzle difficulty adjustPuzzleDifficulty(); } if (!_scalePlayerStatus.isGameOver()) { var tree:Array<Array<Object>> = []; var agent:ScaleAgent = _scalePlayerStatus._agents[FlxG.random.int(1, _scalePlayerStatus._agents.length - 1)]; var roundWinningAgent:ScaleAgent = null; var gameWinningAgents:Array<ScaleAgent> = []; var maxScore:Int = 0; for (i in 0..._scalePlayerStatus._agents.length) { if (_scalePlayerStatus._agents[i]._finishedOrder == 1) { roundWinningAgent = _scalePlayerStatus._agents[i]; } if (_scalePlayerStatus._totalScores[i] + _scalePlayerStatus._roundScores[i] > maxScore) { maxScore = _scalePlayerStatus._totalScores[i] + _scalePlayerStatus._roundScores[i]; gameWinningAgents = [_scalePlayerStatus._agents[i]]; } else if (_scalePlayerStatus._totalScores[i] + _scalePlayerStatus._roundScores[i] == maxScore) { gameWinningAgents.push(_scalePlayerStatus._agents[i]); } } if (_roundNumber >= 2 && agent._finishedOrder <= 2 && gameWinningAgents.length == 1 && gameWinningAgents[0] == agent && FlxG.random.bool(75)) { // winning... agent._gameDialog.popWinning(tree); } else if (_roundNumber >= 2 && agent._finishedOrder >= 2 && gameWinningAgents.indexOf(agent) == -1 && FlxG.random.bool()) { // losing... agent._gameDialog.popLosing(tree, gameWinningAgents[0]._name, gameWinningAgents[0]._gender); } else if (agent._finishedOrder == 1) { // finished first agent._gameDialog.popRoundWin(tree); } else if (agent._finishedOrder >= 3) { if (roundWinningAgent == null) { // shouldn't happen... but for safety agent._gameDialog.popRoundStart(tree, _roundNumber + 1); } else { agent._gameDialog.popRoundLose(tree, roundWinningAgent._name, roundWinningAgent._gender); } } else { agent._gameDialog.popRoundStart(tree, _roundNumber + 1); } var beforeTree:Array<Array<Object>> = []; beforeTree[0] = ["%prompts-y-offset+" + (31 + 21 * _agentSprites.length) + "%"]; tree = DialogTree.prepend(beforeTree, tree); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } } if (_gameState == 310) { if (!DialogTree.isDialogging(_dialogTree)) { startNewPuzzle(); } } if (_gameState == 79 || _gameState == 80) { // Take the player through the guided tutorial. var tree:Array<Array<Object>>; if (_gameState == 80) { /* * The player is asking for the tutorial, even though they've * heard it before. We don't do the intro dialog -- we just * have Buizel start explaining the rules. The handoff is a * little clunky, but there's too many silly edge cases. */ tree = TutorialDialog.scaleGamePartOneAbruptHandoff(); } else if (_scalePlayerStatus._agents[1]._name == "Buizel") { // I'm buizel; I can explain this tree = TutorialDialog.scaleGamePartOneNoHandoff(this); } else { // I'm not buizel. Where's buizel? var buizelAgent:ScaleAgent = _scalePlayerStatus._agents.filter(function (a) {return a._name == "Buizel"; })[0]; var tutorialTree:Array<Array<Object>>; tree = []; handleGameAnnouncement(tree); if (buizelAgent != null) { // Buizel's in the room with us; he can explain it _scalePlayerStatus._agents[1]._gameDialog.popLocalExplanationHandoff(tree, "Buizel", PlayerData.buizMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl); tutorialTree = TutorialDialog.scaleGamePartOneLocalHandoff(); } else { // Let me get Buizel... _scalePlayerStatus._agents[1]._gameDialog.popRemoteExplanationHandoff(tree, "Buizel", PlayerData.buizMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl); tree.push(["#zzzz04#..."]); tutorialTree = TutorialDialog.scaleGamePartOneRemoteHandoff(); } tree = DialogTree.prepend(tree, tutorialTree); } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); _puzzleArea.set(45, 292, 642, 50); setState(81); } if (_gameState == 81) { if (!DialogTree.isDialogging(_dialogTree)) { _canClickCritters = true; setState(82); } } if (_gameState == 84) { if (!DialogTree.isDialogging(_dialogTree)) { _canClickCritters = false; setState(86); } } if (_gameState == 86 || _gameState == 100) { _canClickCritters = false; var tree:Array<Array<Object>> = []; var agent:ScaleAgent = _scalePlayerStatus._agents[1]; if (_gameState == 86) { agent._gameDialog.popPostTutorialGameStartQuery(tree, description); } else { handleGameAnnouncement(tree); agent._gameDialog.popGameStartQuery(tree); } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setState(103); } if (_gameState == 500) { var agent:ScaleAgent = _scalePlayerStatus._agents[1]; var tree:Array<Array<Object>> = agent._gameDialog.popSkipMinigame(); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setState(505); } if (_gameState == 505) { if (!DialogTree.isDialogging(_dialogTree)) { if (!PlayerData.playerIsInDen) { // i award you no points and may god have mercy on your soul payMinigameReward(0); } exitMinigameState(); return; } } if (_gameState == 103) { if (!DialogTree.isDialogging(_dialogTree)) { if (_scalePlayerStatus.isMismatched() && _scalePlayerStatus._agents.length > 2) { var agent:ScaleAgent = _scalePlayerStatus._agents[1]; var tree:Array<Array<Object>> = agent._gameDialog.popPlayWithoutMe(); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } setState(115); } } if (_gameState == 115) { if (!DialogTree.isDialogging(_dialogTree)) { _scaleScoreboard.init(); startNewPuzzle(); } } if (_gameState == 400) { if (DialogTree.isDialogging(_dialogTree)) { // still dialogging; don't exit } else if (_eventStack._alive) { // still going through events; don't exit } else if (_cashWindow._currentAmount != PlayerData.cash) { // still accumulating cash; don't exit } else { exitMinigameState(); return; } } #if debug // hit 'I' to make someone do an idle animation if (FlxG.keys.justPressed.I) { var closestCritter:Critter = null; for (critter in _critters) { if (closestCritter == null || closestCritter._bodySprite.getPosition().distanceTo(FlxG.mouse.getPosition()) > critter._bodySprite.getPosition().distanceTo(FlxG.mouse.getPosition())) { closestCritter = critter; } } if (closestCritter != null) { closestCritter.playAnim("complex-figure8", true); } } if (FlxG.keys.justPressed.R) { setState(190); startNewPuzzle(); } #end } public function eventCritterJumpOff(args:Array<Dynamic>):Void { var critter:Critter = args[0]; releaseCritter(critter); findPad(critter).removeCritter(critter); recalculateBalance(); critter._runToCallback = critterRunOffscreen; } public function critterRunOffscreen(critter:Critter):Void { critter.runTo(critter._soulSprite.x + FlxG.random.float(-100, 100), 550); } override function dialogTreeCallback(Msg:String):String { super.dialogTreeCallback(Msg); if (StringTools.startsWith(Msg, "%set-puzzle-")) { var puzzleIndex:Int = Std.parseInt(substringBetween(Msg, "%set-puzzle-", "%")); var eventTime:Float = _eventStack._time + 0.1; _eventStack.addEvent({time:eventTime, callback:eventSetScaleVisible, args:[false]}); _eventStack.addEvent({time:eventTime, callback:eventSetPuzzle, args:[puzzleIndex]}); _eventStack.addEvent({time:eventTime+0.6, callback:eventSetScaleVisible, args:[true]}); } if (StringTools.startsWith(Msg, "%move-pegs-")) { var pegStrings:Array<String> = substringBetween(Msg, "%move-pegs-", "%").split("-"); var pegTarget:Array<Int> = [0, 0, 0, 0]; for (i in 0...4) { pegTarget[i] = Std.parseInt(pegStrings[i]); } // who's in the wrong place? var wrongCritters:Array<Critter> = _crucialCritters.filter(function(s) return findPad(s) == null); for (i in 0...4) { var extraCritterCount:Int = _scale._pads[i]._critters.length - pegTarget[i]; for (j in 0...extraCritterCount) { wrongCritters.push(_scale._pads[i]._critters[j]); } } var eventTime:Float = _eventStack._time + 0.1; var lights:Array<String> = []; // which pads need more critters? for (i in 0...4) { var missingCritterCount:Int = pegTarget[i] - _scale._pads[i]._critters.length; for (j in 0...missingCritterCount) { var critter:Critter = wrongCritters.pop(); _eventStack.addEvent({time:eventTime, callback:eventMoveCritterToPad, args:[critter, i]}); _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[AssetPaths.drop__mp3]}); eventTime += 0.6; } } } if (Msg == "%answer-bad%" || Msg == "%answer-good%") { var eventTime:Float = _eventStack._time + 3.6; var answerGood:Bool = Msg == "%answer-good%"; _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[answerGood ? AssetPaths.clue_ok_00fa__mp3 : AssetPaths.clue_bad_00ff__mp3]}); _eventStack.addEvent({time:eventTime, callback:eventAnswerOk, args:[answerGood ? 1 : 0, answerGood]}); if (!answerGood) { var unusedCritter:Critter = null; for (critter in _crucialCritters) { if (findPad(critter) == null) { unusedCritter = critter; } } if (unusedCritter != null) { _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventLightsDim}); _eventStack.addEvent({time:eventTime, callback:eventCreateCritterSpotlight, args:[unusedCritter, "wrongCritter"]}); _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventSpotlightOn, args:["wrongCritter"]}); _eventStack.addEvent({time:eventTime + 0.75, callback:_lightsManager.eventLightsOn}); _eventStack.addEvent({time:eventTime + 1.05, callback:eventDeleteCritterSpotlight, args:["wrongCritter"]}); } } } if (Msg == "%skip-tutorial%") { setState(103); } if (Msg == "%skip-minigame%") { setState(500); } if (Msg == "%restart-tutorial%") { setState(80); } if (Msg == "%play-without-me%") { var agentSprite:FlxSprite = _agentSprites[1]; _hud.remove(agentSprite); _agentSprites.remove(agentSprite); FlxDestroyUtil.destroy(agentSprite); _scalePlayerStatus._roundScores.splice(1, 1); _scalePlayerStatus._totalScores.splice(1, 1); _scalePlayerStatus._agents.splice(1, 1); } return null; } public function eventSetScaleVisible(args:Array<Dynamic>):Void { setScaleVisible(args[0]); } public function eventSetPuzzle(args:Array<Dynamic>):Void { _puzzle = ScalePuzzleDatabase.fixedPuzzle(args[0]); preparePuzzleAndCritters(); } public function eventMoveCritterToPad(args:Array<Dynamic>):Void { var critter:Critter = args[0]; var padIndex:Int = args[1]; removeCritterFromHolder(critter); placeCritterInHolder(_scale._pads[padIndex], critter); var _holderPos:FlxPoint = _scale._pads[padIndex]._sprite.getPosition(); _holderPos.x += _scale._pads[padIndex]._sprite.width / 2 - critter._targetSprite.width / 2 + 1; _holderPos.y += _scale._pads[padIndex]._sprite.height / 2 - critter._targetSprite.height / 2 + 2; critter.setPosition(_holderPos.x + FlxG.random.float( -2, 2), _holderPos.y + FlxG.random.float( -2, 2)); _scale.recalculateBalance(); } public function eventCreateCritterSpotlight(args:Array<Dynamic>):Void { var critter:Critter = args[0]; var spotlightName:String = args[1]; _lightsManager._spotlights.addSpotlight(spotlightName); var lightRect:FlxRect = critter._soulSprite.getHitbox(); lightRect.y -= 25; lightRect.height += 25; _lightsManager._spotlights.growSpotlight(spotlightName, lightRect); } public function eventDeleteCritterSpotlight(args:Array<Dynamic>):Void { var spotlightName:String = args[0]; _lightsManager._spotlights.removeSpotlight(spotlightName); } public function isInPuzzleArea(critter:Critter) { return isCoordInPuzzleArea(critter._soulSprite.x, critter._soulSprite.y) || isCoordInPuzzleArea(critter._targetSprite.x, critter._targetSprite.y); } function isCoordInPuzzleArea(x:Float, y:Float) { return FlxMath.pointInFlxRect(x, y, _puzzleArea); } override public function moveGrabbedCritter(elapsed:Float):Void { _grabbedCritter.setPosition(_handSprite.x - 18, _handSprite.y + 5); if (_grabbedCritter != null && _grabbedCritter._soulSprite.y < 164) { var z:Float = 164 - _grabbedCritter._soulSprite.y; // confine critter to the bottom half of the screen _grabbedCritter._soulSprite.y = 164; _grabbedCritter._targetSprite.y = _grabbedCritter._soulSprite.y; _grabbedCritter._bodySprite.y = _grabbedCritter._soulSprite.y; _grabbedCritter.z = z; } _thumbSprite.setPosition(_handSprite.x, _handSprite.y + 6); moveGrabbedCritterButt(elapsed); } override function handleMousePress():Void { maybeGrabCritter(); recalculateBalance(); } private function recalculateBalance() { var oldBalance:Float = _scale._balance; _scale.recalculateBalance(); if (oldBalance != _scale._balance) { if (_scale._balance == 0 && _scale.getCritterCount() > 0) { _releaseTimer = BALANCE_DURATION; } else { _releaseTimer = 0; } } } override function handleMouseRelease():Void { maybeReleaseCritter(); recalculateBalance(); } override public function maybeReleaseCritter():Bool { var critter:Critter = _grabbedCritter; var result:Bool = super.maybeReleaseCritter(); if (_grabbedCritter == null && critter != null) { if (findPad(critter) != null) { critter.z = 0; return result; } releaseCritter(critter); } return result; } private function releaseCritter(critter:Critter):Void { if (critter._soulSprite.y - critter.z < 284) { var z:Float = (284 - critter._soulSprite.y) + critter.z; // confine critter to the bottom half of the screen critter._soulSprite.y = 284; critter._targetSprite.y = critter._soulSprite.y; critter._bodySprite.y = critter._soulSprite.y; critter._headSprite.moveHead(); var dir:Float; if (critter._soulSprite.x < 100) { dir = 1.75 * Math.PI; } else if (critter._soulSprite.x > FlxG.width - 100) { dir = 1.25 * Math.PI; } else { dir = FlxG.random.float(Math.PI, 2 * Math.PI); } var delay:Float = Math.sqrt(z) / 13 + 0.05; var dist:Float = (delay / 2) * 130; critter.dropTo(critter._soulSprite.x + Math.cos(dir) * dist, critter._soulSprite.y - Math.sin(dir) * dist, z); } } public function eventAnswerOk(params:Array<Dynamic>):Void { var sprite:LateFadingFlxParticle = _answerOkGroup.recycle(LateFadingFlxParticle); sprite.reset(0, 0); sprite.alpha = 1; sprite.lifespan = params[1] ? 1 : 3; sprite.x = (3 * 108 + 16) - 32; sprite.y = (250 + 22) - 16; sprite.animation.frameIndex = params[0] ? 0 : 1; sprite.alphaRange.set(1, 0); sprite.enableLateFade(2); FlxTween.tween(sprite, {y:sprite.y - 32}, params[1] ? 1 : 3, {ease:FlxEase.circOut}); _answerOkGroup.add(sprite); } public function startNewPuzzle():Void { _roundNumber++; setScaleVisible(false); _puzzleArea.set(45, 292, 642, 113); // just in case scores didn't fully accumulate for (i in 0..._scalePlayerStatus._totalScores.length) { _scalePlayerStatus._totalScores[i] += _scalePlayerStatus._roundScores[i]; _scalePlayerStatus._roundScores[i] = 0; } _scaleScoreboard.exists = false; if (_scalePlayerStatus.isGameOver()) { finalScoreboard = new ScaleFinalScoreboard(this); showFinalScoreboard(); setState(400); var bestScore:Int = 0; var bestAgent:ScaleAgent = _scalePlayerStatus._agents[0]; for (i in 0..._agentSprites.length) { if (_scalePlayerStatus._totalScores[i] > bestScore) { bestScore = _scalePlayerStatus._totalScores[i]; bestAgent = _scalePlayerStatus._agents[i]; } } var tree:Array<Array<Object>> = []; if (PlayerData.playerIsInDen) { // just practicing handleDenGameOver(tree, bestAgent == _scalePlayerStatus._agents[0]); } else if (bestAgent == _scalePlayerStatus._agents[0]) { // player won _scalePlayerStatus._agents[1]._gameDialog.popPlayerBeatMe(tree, finalScoreboard._totalReward); for (i in 2..._scalePlayerStatus._agents.length) { _scalePlayerStatus._agents[i]._gameDialog.popShortPlayerBeatMe(tree, finalScoreboard._totalReward); } } else { // player lost bestAgent._gameDialog.popBeatPlayer(tree, finalScoreboard._totalReward); for (i in 1..._scalePlayerStatus._agents.length) { if (_scalePlayerStatus._agents[i] != bestAgent) { _scalePlayerStatus._agents[i]._gameDialog.popShortWeWereBeaten(tree, finalScoreboard._totalReward, bestAgent._name, bestAgent._gender); } } } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); updateAgentSpritePositions(); resetCritters(); // ensure critters left over on scales are removed return; } setState(190); updateAgentSpritePositions(); _releaseTimer = 0; var seed:Int = FlxG.random.int(100000, 999999); _puzzle = ScalePuzzleDatabase.randomPuzzle(); preparePuzzleAndCritters(); _scalePlayerStatus.startRound(_puzzle); _canClickCritters = true; recalculateBalance(); _clockToggle.splice(0, _clockToggle.length); var j:Float = 0.001; while (j < 1) { _clockToggle.push(j += 1 / 6); } while (j < 3) { _clockToggle.push(j += 1 / 4); } while (j < 6) { _clockToggle.push(j += 1 / 2); } while (j < 10) { _clockToggle.push(j += 1); } } override function findTargetCritterHolder():CritterHolder { var minDistance:Float = 125; var closestCritterHolder:CritterHolder = null; var grabbedMidpoint:FlxPoint = _grabbedCritter._bodySprite.getMidpoint(); grabbedMidpoint.y -= _grabbedCritter.z; for (pad in _scale._pads) { var midPoint:FlxPoint = pad._sprite.getMidpoint(); var dx:Float = (midPoint.x - grabbedMidpoint.x); var dy:Float = (midPoint.y - grabbedMidpoint.y - 6) * 1.6; if (dx * dx + dy * dy < minDistance * minDistance) { minDistance = Math.sqrt(dx * dx + dy * dy); closestCritterHolder = pad; } } return closestCritterHolder; } override function removeCritterFromHolder(critter:Critter):Bool { for (pad in _scale._pads) { if (pad.removeCritter(critter)) { return true; } } return true; } function findPad(critter:Critter):CritterHolder { for (pad in _scale._pads) { if (pad._critters.indexOf(critter) != -1) { return pad; } } return null; } function updateClock(elapsed:Float):Void { if (Std.int(_scalePlayerStatus._remainingPuzzleTime) != Std.int(_scalePlayerStatus._remainingPuzzleTime + elapsed) || _scalePlayerStatus._remainingPuzzleTime < _clockToggle[_clockToggle.length - 1]) { if (_scalePlayerStatus._remainingPuzzleTime < _clockToggle[_clockToggle.length - 1]) { _clockToggle.pop(); SoundStackingFix.play(_clockToggle.length % 2 == 1 ? AssetPaths.beep_0065__wav : AssetPaths.beep_hi_0065__wav); } _scale.setScaleClockAngle(6 * FlxMath.bound(Std.int(_scalePlayerStatus._remainingPuzzleTime), 0, 30), _clockToggle.length % 2 == 1); } } public function playerFinished() { updateAgentSpritePositions(); } override function findGrabbedCritter():Critter { if (!_canClickCritters) { return null; } return super.findGrabbedCritter(); } function spoilAnswer():Float { _releaseTimer = 0; _canClickCritters = false; // release held critters, so they can be shown in the answer maybeReleaseCritter(); // who's in the wrong place? var wrongCritters:Array<Critter> = _crucialCritters.filter(function(s) return findPad(s) == null); for (i in 0...4) { var extraCritterCount:Int = _scale._pads[i]._critters.length - _puzzle._answer[i]; for (j in 0...extraCritterCount) { wrongCritters.push(_scale._pads[i]._critters[j]); } } if (wrongCritters.length == 0) { // was correct all along? } var eventTime:Float = _eventStack._time + 0.1; _eventStack.addEvent({time:eventTime, callback:_lightsManager.eventLightsDim}); eventTime += 1.0; var lights:Array<String> = []; // which pads need more critters? for (i in 0...4) { var missingCritterCount:Int = _puzzle._answer[i] - _scale._pads[i]._critters.length; for (j in 0...missingCritterCount) { var critter:Critter = wrongCritters.pop(); var lightName:String = "wrongCritter" + i; _eventStack.addEvent({time:eventTime, callback:eventMoveCritterToPad, args:[critter, i]}); _eventStack.addEvent({time:eventTime, callback:eventCreateCritterSpotlight, args:[critter, lightName]}); _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[AssetPaths.drop__mp3]}); eventTime += 0.4; } } eventTime += 2.0; for (lightName in lights) { _eventStack.addEvent({time:eventTime, callback:eventDeleteCritterSpotlight, args:[lightName]}); } return eventTime; } function humanSolvedPuzzle():Void { _releaseTimer = 0; _canClickCritters = false; _scalePlayerStatus.playerFinished(0); var eventTime:Float = _eventStack._time + 0.1; _eventStack.addEvent({time:eventTime, callback:EventStack.eventPlaySound, args:[AssetPaths.clue_ok_00fa__mp3]}); _eventStack.addEvent({time:eventTime, callback:eventAnswerOk, args:[1, true]}); _speedupTimer = 1.2; adjustPuzzleDifficulty(); } /** * Adjust the puzzle difficulty. If they solved a puzzle in less than 18 * seconds, they'll have a harder puzzle. If it took them longer than 18 * seconds, they'll have an easier puzzle. */ function adjustPuzzleDifficulty() { if (_gameState < 200) { // we don't want to adjust puzzle difficulty during tutorials. } else if (_scalePlayerStatus._elapsedPuzzleTime <= 0) { // times less than 0 mess up our log arithmetic... They shouldn't happen anyway } else { var adjustAmount:Float = -Math.log(_scalePlayerStatus._elapsedPuzzleTime / 18) / Math.log(2); adjustAmount = FlxMath.bound(adjustAmount, -3, 3); PlayerData.scaleGamePuzzleDifficulty = FlxMath.bound(PlayerData.scaleGamePuzzleDifficulty + adjustAmount * 0.13, 0, 1); } } function preparePuzzleAndCritters():Void { resetCritters(); for (i in 0..._puzzle._totalPegCount) { _crucialCritters.push(_critters[i]); _critters[i].setPosition(FlxG.random.float(_puzzleArea.left + 10, _puzzleArea.right - 10), FlxG.random.float(FlxG.height + 28, FlxG.height + 58)); } _scale.setPuzzle(_puzzle); } function resetCritters():Void { for (pad in _scale._pads) { pad._critters.splice(0, pad._critters.length); } _crucialCritters.splice(0, _crucialCritters.length); var x:Int = 100; for (critter in _critters) { critter.setPosition(x, 550); critter.reset(); x += 40; } FlxG.random.shuffle(_critters); } function setScaleVisible(scaleVisible:Bool):Void { var oldScaleVisible:Bool = _scale.exists; _scale.exists = scaleVisible; _scale._scaleShadow.exists = scaleVisible; if (scaleVisible && !oldScaleVisible) { var leftX:Int = _scale._shortScale ? 78 : 24; var rightX:Int = _scale._shortScale ? 694 : 748; for (i in 0...15) { _whumpClouds.x = FlxG.random.int(leftX, rightX); _whumpClouds.y = FlxG.random.int(277, 297); var particle:FlxParticle = _whumpClouds.emitParticle(); particle.angle = FlxG.random.getObject([0, 90, 180, 270]); } SoundStackingFix.play(AssetPaths.countdown_go_005c__mp3); } } override public function payMinigameReward(reward:Int) { super.payMinigameReward(reward); if (reward > 0) { /** * Adjust difficulty for next time. If the player won at least * $1,000, they'll face harder opponents next time. If they won * less than $1,000, they'll face easier opponents next time. */ var adjustAmount:Float = Math.log(reward / avgReward) / Math.log(2); adjustAmount = FlxMath.bound(adjustAmount, -2, 2); PlayerData.scaleGameOpponentDifficulty = FlxMath.bound(PlayerData.scaleGameOpponentDifficulty + adjustAmount * 0.21, 0, 1); } } override public function destroy():Void { super.destroy(); _whumpClouds = FlxDestroyUtil.destroy(_whumpClouds); _scale = FlxDestroyUtil.destroy(_scale); _answerOkGroup = FlxDestroyUtil.destroy(_answerOkGroup); _puzzle = null; _crucialCritters = FlxDestroyUtil.destroyArray(_crucialCritters); _lightsManager = FlxDestroyUtil.destroy(_lightsManager); _scalePlayerStatus = FlxDestroyUtil.destroy(_scalePlayerStatus); _agentSprites = FlxDestroyUtil.destroyArray(_agentSprites); _clockToggle = null; _scaleScoreboard = FlxDestroyUtil.destroy(_scaleScoreboard); _countdownSprite = FlxDestroyUtil.destroy(_countdownSprite); _puzzleArea = FlxDestroyUtil.put(_puzzleArea); } }
argonvile/monster
source/minigame/scale/ScaleGameState.hx
hx
unknown
39,477
package minigame.scale; import flixel.FlxG; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDestroyUtil.IFlxDestroyable; import kludge.FlxSoundKludge; import minigame.MinigameState.denNerf; import minigame.scale.ScaleAgent; /** * Tracks the state of a round in the scale minigame -- whether the player's * finished, whether the computer players have finished, and how much time is * left in the round. */ class ScalePlayerStatus implements IFlxDestroyable { public var _totalScores:Array<Int> = []; /** * _agents[0] = human * _agents[1] = leader -- the person you were solving puzzles with, unless he hands it off * _agents[2...x] = other opponents */ public var _agents:Array<ScaleAgent>; public var _roundScores:Array<Int> = []; private var _remainingRewards:Array<Int>; public var _elapsedPuzzleTime:Float = 0; public var _doneCallback:Void->Void; public var _remainingPuzzleTime:Float = 1000000000; private var _roundRunning:Bool = false; private var _agentDatabase:ScaleAgentDatabase = new ScaleAgentDatabase(); public function new() { _agents = _agentDatabase.getAgents(); initializeRemainingRewards(); for (i in 0..._agents.length) { _totalScores.push(0); _roundScores.push(0); } } function initializeRemainingRewards() { _remainingRewards = [denNerf(125), denNerf(200)]; } public function update(elapsed:Float) { if (_roundRunning) { _remainingPuzzleTime -= elapsed; _elapsedPuzzleTime += elapsed; for (i in 1..._agents.length) { var agent:ScaleAgent = _agents[i]; if (!agent.isDone() && agent._time <= _elapsedPuzzleTime) { if (agent._soundAsset != null) { FlxSoundKludge.play(agent._soundAsset, 0.25); } playerFinished(i); } } } } public function playerFinished(index:Int) { _agents[index]._finishedOrder = _agents.filter(function(s) return s.isDone()).length + 1; _roundScores[index] = _remainingRewards.length > 0 ? _remainingRewards.pop() : MinigameState.denNerf(50); _remainingPuzzleTime = Math.min(_remainingPuzzleTime, 30); if (_doneCallback != null) { _doneCallback(); } } public function isRoundOver():Bool { var allAgentsDone:Bool = _agents.filter(function(s) return s.isDone()).length == _agents.length; if (!_roundRunning) { return false; } if (allAgentsDone) { return true; } if (_remainingPuzzleTime <= 0) { return true; } return false; } public function finishRound():Void { _roundRunning = false; } public function startRound(_puzzle:ScalePuzzle):Void { _elapsedPuzzleTime = 0; _remainingPuzzleTime = 1000000000; initializeRemainingRewards(); _roundRunning = true; var shouldHaveMercy:Bool = false; for (i in 1..._agents.length) { if (_totalScores[i] >= _totalScores[0] + denNerf(400)) { shouldHaveMercy = true; } } if (shouldHaveMercy) { for (i in 1..._agents.length) { _agents[i]._mercy += (_totalScores[i] - _totalScores[0]) / denNerf(100); } } else { for (i in 1..._agents.length) { _agents[i]._mercy = 0; } } for (agent in _agents) { agent._finishedOrder = ScaleAgent.UNFINISHED; } for (i in 1..._agents.length) { _agents[i].computeTime(_puzzle._totalPegCount, _puzzle._sum); } } public function isGameOver():Bool { for (i in 0..._agents.length) { if (_roundScores[i] + _totalScores[i] >= denNerf(ScaleGameState.TARGET_SCORE)) { return true; } } return false; } public function isMismatched() { return _agentDatabase.isMismatched(_agents[1]); } public function destroy():Void { _totalScores = null; _agents = FlxDestroyUtil.destroyArray(_agents); _roundScores = null; _remainingRewards = null; _doneCallback = null; _agentDatabase = FlxDestroyUtil.destroy(_agentDatabase); } }
argonvile/monster
source/minigame/scale/ScalePlayerStatus.hx
hx
unknown
3,999
package minigame.scale; /** * A scale puzzle's data, including how many bugs there are and which bugs are used in the answer */ class ScalePuzzle { public var _totalPegCount:Int; public var _sum:Int; public var _weights:Array<Int>; public var _answer:Array<Int>; public function new(array:Array<Int>) { this._totalPegCount = array[0]; this._sum = array[1]; this._weights = array.slice(2, 6); this._answer = array.slice(6, 10); } }
argonvile/monster
source/minigame/scale/ScalePuzzle.hx
hx
unknown
468
package minigame.scale; import flixel.FlxG; import flixel.math.FlxMath; import flixel.math.FlxRandom; import puzzle.Puzzle; /** * A database of puzzles for the Scale minigame. */ class ScalePuzzleDatabase { public static var recentScalePuzzleIndexes:Array<Int> = []; // most recent 50 puzzles; we don't want back-to-back identical puzzles /* * Each index in this array represents a scale puzzle and its solution. The * puzzles are vaguely sorted by difficulty, with the understanding that a * 6-bug puzzle is harder than a 3-peg puzzle, and a puzzle which adds up * to 42 is harder than a puzzle which adds up to 12. * * For example, [5, 25, 25, 24, 4, 7, 1, 0, 1, 3] is a puzzle: * * [ * 5, (The puzzle has five bugs) * 25, (The answer adds up to 25) * 25, (The leftmost scale is 25) * 24, (The second scale is 24) * 4, (The third scale is 4) * 7, (The fourth scale is 7) * 1, (The solution has 1 bug on the leftmost scale) * 0, (The solution has 0 bugs on the second scale) * 1, (The solution has 1 bug on the third scale) * 3, (The solution has 3 bugs on the fourth scale) * ] */ private static var _puzzles:Array<Array<Int>> = [ [3, 6, 7, 3, 4, 6, 0, 2, 0, 1], [3, 6, 7, 3, 5, 6, 0, 2, 0, 1], [3, 6, 10, 6, 3, 8, 0, 1, 2, 0], [3, 6, 12, 6, 3, 4, 0, 1, 2, 0], [3, 6, 13, 3, 6, 11, 0, 2, 1, 0], [3, 6, 15, 3, 6, 11, 0, 2, 1, 0], [3, 6, 15, 6, 3, 10, 0, 1, 2, 0], [3, 6, 15, 6, 3, 11, 0, 1, 2, 0], [3, 6, 17, 3, 6, 8, 0, 2, 1, 0], [3, 6, 18, 3, 6, 16, 0, 2, 1, 0], [3, 6, 18, 3, 6, 17, 0, 2, 1, 0], [3, 6, 20, 6, 3, 5, 0, 1, 2, 0], [3, 6, 24, 3, 4, 6, 0, 2, 0, 1], [3, 6, 25, 3, 4, 6, 0, 2, 0, 1], [3, 6, 25, 3, 6, 14, 0, 2, 1, 0], [3, 6, 25, 6, 3, 4, 0, 1, 2, 0], [3, 6, 30, 6, 3, 10, 0, 1, 2, 0], [3, 7, 7, 5, 3, 4, 1, 0, 1, 1], [3, 7, 10, 7, 3, 4, 0, 1, 1, 1], [3, 7, 11, 7, 3, 4, 0, 1, 1, 1], [3, 7, 12, 7, 3, 4, 0, 1, 1, 1], [3, 7, 15, 7, 3, 4, 0, 1, 1, 1], [3, 7, 17, 7, 3, 4, 0, 1, 1, 1], [3, 8, 8, 4, 3, 5, 1, 0, 1, 1], [3, 8, 8, 7, 3, 5, 1, 0, 1, 1], [3, 8, 8, 7, 4, 6, 1, 0, 2, 0], [3, 8, 9, 8, 3, 4, 0, 1, 0, 2], [3, 8, 10, 4, 3, 8, 0, 2, 0, 1], [3, 8, 10, 4, 7, 8, 0, 2, 0, 1], [3, 8, 10, 4, 8, 9, 0, 2, 1, 0], [3, 8, 10, 8, 4, 7, 0, 1, 2, 0], [3, 8, 11, 4, 8, 10, 0, 2, 1, 0], [3, 8, 11, 8, 3, 5, 0, 1, 1, 1], [3, 8, 11, 8, 4, 6, 0, 1, 2, 0], [3, 8, 11, 8, 4, 10, 0, 1, 2, 0], [3, 8, 12, 4, 5, 8, 0, 2, 0, 1], [3, 8, 12, 4, 7, 8, 0, 2, 0, 1], [3, 8, 12, 4, 8, 10, 0, 2, 1, 0], [3, 8, 12, 8, 3, 5, 0, 1, 1, 1], [3, 8, 12, 8, 4, 5, 0, 1, 2, 0], [3, 8, 12, 8, 4, 9, 0, 1, 2, 0], [3, 8, 12, 8, 4, 10, 0, 1, 2, 0], [3, 8, 12, 8, 4, 11, 0, 1, 2, 0], [3, 8, 13, 4, 8, 12, 0, 2, 1, 0], [3, 8, 13, 8, 4, 5, 0, 1, 2, 0], [3, 8, 13, 8, 4, 10, 0, 1, 2, 0], [3, 8, 13, 8, 4, 11, 0, 1, 2, 0], [3, 8, 14, 4, 8, 11, 0, 2, 1, 0], [3, 8, 14, 4, 8, 12, 0, 2, 1, 0], [3, 8, 15, 4, 5, 8, 0, 2, 0, 1], [3, 8, 15, 8, 3, 5, 0, 1, 1, 1], [3, 8, 16, 8, 3, 5, 0, 1, 1, 1], [3, 8, 16, 8, 4, 10, 0, 1, 2, 0], [3, 8, 16, 8, 4, 14, 0, 1, 2, 0], [3, 8, 17, 4, 7, 8, 0, 2, 0, 1], [3, 8, 17, 4, 8, 10, 0, 2, 1, 0], [3, 8, 18, 8, 3, 5, 0, 1, 1, 1], [3, 8, 20, 4, 3, 8, 0, 2, 0, 1], [3, 8, 20, 4, 5, 8, 0, 2, 0, 1], [3, 8, 20, 4, 8, 16, 0, 2, 1, 0], [3, 8, 20, 4, 8, 18, 0, 2, 1, 0], [3, 8, 20, 8, 3, 5, 0, 1, 1, 1], [3, 8, 20, 8, 4, 9, 0, 1, 2, 0], [3, 8, 20, 8, 4, 12, 0, 1, 2, 0], [3, 8, 20, 8, 4, 13, 0, 1, 2, 0], [3, 8, 24, 4, 5, 8, 0, 2, 0, 1], [3, 8, 24, 4, 8, 17, 0, 2, 1, 0], [3, 8, 24, 8, 3, 5, 0, 1, 1, 1], [3, 8, 24, 8, 4, 11, 0, 1, 2, 0], [3, 8, 25, 4, 8, 15, 0, 2, 1, 0], [3, 8, 25, 8, 3, 5, 0, 1, 1, 1], [3, 8, 25, 8, 4, 7, 0, 1, 2, 0], [3, 8, 30, 4, 8, 10, 0, 2, 1, 0], [3, 8, 30, 4, 8, 12, 0, 2, 1, 0], [3, 8, 30, 8, 4, 9, 0, 1, 2, 0], [3, 9, 9, 4, 3, 6, 1, 0, 1, 1], [3, 9, 9, 6, 4, 5, 1, 0, 1, 1], [3, 9, 9, 7, 4, 5, 1, 0, 1, 1], [3, 9, 9, 8, 3, 6, 1, 0, 1, 1], [3, 9, 10, 9, 3, 6, 0, 1, 1, 1], [3, 9, 11, 9, 3, 6, 0, 1, 1, 1], [3, 9, 11, 9, 4, 5, 0, 1, 1, 1], [3, 9, 12, 9, 4, 5, 0, 1, 1, 1], [3, 9, 13, 9, 4, 5, 0, 1, 1, 1], [3, 9, 15, 9, 4, 5, 0, 1, 1, 1], [3, 9, 16, 9, 4, 5, 0, 1, 1, 1], [3, 9, 20, 9, 4, 5, 0, 1, 1, 1], [3, 9, 25, 9, 4, 5, 0, 1, 1, 1], [3, 9, 30, 9, 4, 5, 0, 1, 1, 1], [3, 10, 10, 3, 5, 8, 1, 0, 2, 0], [3, 10, 10, 4, 5, 6, 1, 0, 2, 0], [3, 10, 10, 4, 5, 7, 1, 0, 2, 0], [3, 10, 10, 5, 3, 7, 1, 0, 1, 1], [3, 10, 10, 5, 4, 6, 1, 0, 1, 1], [3, 10, 10, 6, 5, 8, 1, 0, 2, 0], [3, 10, 10, 7, 4, 5, 1, 0, 0, 2], [3, 10, 10, 7, 4, 6, 1, 0, 1, 1], [3, 10, 10, 8, 3, 7, 1, 0, 1, 1], [3, 10, 10, 8, 5, 6, 1, 0, 2, 0], [3, 10, 10, 8, 5, 7, 1, 0, 2, 0], [3, 10, 11, 5, 3, 10, 0, 2, 0, 1], [3, 10, 11, 5, 4, 10, 0, 2, 0, 1], [3, 10, 11, 10, 3, 7, 0, 1, 1, 1], [3, 10, 11, 10, 4, 6, 0, 1, 1, 1], [3, 10, 11, 10, 5, 7, 0, 1, 2, 0], [3, 10, 11, 10, 5, 8, 0, 1, 2, 0], [3, 10, 11, 10, 5, 9, 0, 1, 2, 0], [3, 10, 12, 5, 3, 10, 0, 2, 0, 1], [3, 10, 12, 5, 4, 10, 0, 2, 0, 1], [3, 10, 12, 5, 8, 10, 0, 2, 0, 1], [3, 10, 12, 5, 9, 10, 0, 2, 0, 1], [3, 10, 12, 10, 3, 7, 0, 1, 1, 1], [3, 10, 12, 10, 5, 9, 0, 1, 2, 0], [3, 10, 12, 10, 5, 11, 0, 1, 2, 0], [3, 10, 13, 5, 8, 10, 0, 2, 0, 1], [3, 10, 14, 10, 4, 6, 0, 1, 1, 1], [3, 10, 15, 10, 3, 7, 0, 1, 1, 1], [3, 10, 15, 10, 4, 6, 0, 1, 1, 1], [3, 10, 16, 10, 3, 7, 0, 1, 1, 1], [3, 10, 16, 10, 4, 6, 0, 1, 1, 1], [3, 10, 17, 5, 10, 11, 0, 2, 1, 0], [3, 10, 17, 10, 4, 6, 0, 1, 1, 1], [3, 10, 18, 5, 3, 10, 0, 2, 0, 1], [3, 10, 18, 10, 4, 6, 0, 1, 1, 1], [3, 10, 18, 10, 5, 11, 0, 1, 2, 0], [3, 10, 20, 10, 4, 6, 0, 1, 1, 1], [3, 10, 24, 5, 6, 10, 0, 2, 0, 1], [3, 10, 24, 5, 8, 10, 0, 2, 0, 1], [3, 10, 24, 10, 3, 7, 0, 1, 1, 1], [3, 10, 24, 10, 4, 6, 0, 1, 1, 1], [3, 10, 25, 10, 4, 6, 0, 1, 1, 1], [3, 10, 30, 10, 4, 6, 0, 1, 1, 1], [3, 11, 11, 3, 4, 7, 1, 0, 1, 1], [3, 11, 11, 4, 5, 6, 1, 0, 1, 1], [3, 11, 11, 5, 3, 8, 1, 0, 1, 1], [3, 11, 11, 6, 4, 7, 1, 0, 1, 1], [3, 11, 11, 7, 3, 8, 1, 0, 1, 1], [3, 11, 11, 8, 5, 6, 1, 0, 1, 1], [3, 11, 11, 9, 4, 7, 1, 0, 1, 1], [3, 11, 11, 9, 5, 6, 1, 0, 1, 1], [3, 11, 11, 10, 3, 8, 1, 0, 1, 1], [3, 11, 11, 10, 4, 7, 1, 0, 1, 1], [3, 11, 12, 11, 3, 8, 0, 1, 1, 1], [3, 11, 12, 11, 4, 7, 0, 1, 1, 1], [3, 11, 13, 11, 4, 7, 0, 1, 1, 1], [3, 11, 14, 11, 5, 6, 0, 1, 1, 1], [3, 11, 15, 11, 3, 8, 0, 1, 1, 1], [3, 11, 15, 11, 4, 7, 0, 1, 1, 1], [3, 11, 15, 11, 5, 6, 0, 1, 1, 1], [3, 11, 16, 11, 5, 6, 0, 1, 1, 1], [3, 11, 17, 11, 3, 8, 0, 1, 1, 1], [3, 11, 20, 11, 3, 8, 0, 1, 1, 1], [3, 11, 20, 11, 5, 6, 0, 1, 1, 1], [3, 11, 24, 11, 4, 7, 0, 1, 1, 1], [3, 11, 24, 11, 5, 6, 0, 1, 1, 1], [3, 11, 25, 11, 4, 7, 0, 1, 1, 1], [3, 12, 12, 3, 4, 8, 1, 0, 1, 1], [3, 12, 12, 4, 3, 9, 1, 0, 1, 1], [3, 12, 12, 4, 5, 7, 1, 0, 1, 1], [3, 12, 12, 4, 6, 11, 1, 0, 2, 0], [3, 12, 12, 5, 4, 6, 1, 0, 0, 2], [3, 12, 12, 5, 4, 8, 1, 0, 1, 1], [3, 12, 12, 6, 4, 8, 1, 0, 1, 1], [3, 12, 12, 6, 5, 7, 1, 0, 1, 1], [3, 12, 12, 7, 3, 9, 1, 0, 1, 1], [3, 12, 12, 7, 4, 8, 1, 0, 1, 1], [3, 12, 12, 7, 6, 11, 1, 0, 2, 0], [3, 12, 12, 8, 3, 9, 1, 0, 1, 1], [3, 12, 12, 8, 5, 6, 1, 0, 0, 2], [3, 12, 12, 8, 5, 7, 1, 0, 1, 1], [3, 12, 12, 8, 6, 10, 1, 0, 2, 0], [3, 12, 12, 9, 4, 8, 1, 0, 1, 1], [3, 12, 12, 9, 5, 7, 1, 0, 1, 1], [3, 12, 12, 9, 6, 10, 1, 0, 2, 0], [3, 12, 12, 10, 3, 9, 1, 0, 1, 1], [3, 12, 12, 10, 4, 8, 1, 0, 1, 1], [3, 12, 12, 11, 3, 9, 1, 0, 1, 1], [3, 12, 12, 11, 4, 8, 1, 0, 1, 1], [3, 12, 12, 11, 5, 7, 1, 0, 1, 1], [3, 12, 12, 11, 6, 10, 1, 0, 2, 0], [3, 12, 13, 6, 5, 12, 0, 2, 0, 1], [3, 12, 13, 12, 4, 8, 0, 1, 1, 1], [3, 12, 14, 6, 5, 12, 0, 2, 0, 1], [3, 12, 14, 12, 3, 9, 0, 1, 1, 1], [3, 12, 14, 12, 4, 8, 0, 1, 1, 1], [3, 12, 15, 6, 4, 12, 0, 2, 0, 1], [3, 12, 15, 6, 5, 12, 0, 2, 0, 1], [3, 12, 15, 6, 8, 12, 0, 2, 0, 1], [3, 12, 15, 6, 10, 12, 0, 2, 0, 1], [3, 12, 15, 12, 4, 6, 0, 1, 0, 2], [3, 12, 15, 12, 4, 8, 0, 1, 1, 1], [3, 12, 15, 12, 5, 7, 0, 1, 1, 1], [3, 12, 15, 12, 6, 7, 0, 1, 2, 0], [3, 12, 15, 12, 6, 8, 0, 1, 2, 0], [3, 12, 15, 12, 6, 13, 0, 1, 2, 0], [3, 12, 16, 12, 3, 9, 0, 1, 1, 1], [3, 12, 17, 6, 11, 12, 0, 2, 0, 1], [3, 12, 17, 6, 12, 16, 0, 2, 1, 0], [3, 12, 17, 12, 3, 9, 0, 1, 1, 1], [3, 12, 17, 12, 4, 8, 0, 1, 1, 1], [3, 12, 18, 12, 4, 8, 0, 1, 1, 1], [3, 12, 18, 12, 5, 7, 0, 1, 1, 1], [3, 12, 20, 12, 3, 9, 0, 1, 1, 1], [3, 12, 20, 12, 4, 8, 0, 1, 1, 1], [3, 12, 20, 12, 5, 7, 0, 1, 1, 1], [3, 12, 20, 12, 6, 7, 0, 1, 2, 0], [3, 12, 20, 12, 6, 9, 0, 1, 2, 0], [3, 12, 20, 12, 6, 11, 0, 1, 2, 0], [3, 12, 24, 12, 3, 9, 0, 1, 1, 1], [3, 12, 24, 12, 4, 8, 0, 1, 1, 1], [3, 12, 25, 12, 4, 8, 0, 1, 1, 1], [3, 12, 25, 12, 6, 7, 0, 1, 2, 0], [3, 12, 25, 12, 6, 17, 0, 1, 2, 0], [3, 12, 30, 12, 3, 9, 0, 1, 1, 1], [3, 12, 30, 12, 4, 8, 0, 1, 1, 1], [3, 12, 30, 12, 5, 7, 0, 1, 1, 1], [3, 13, 13, 4, 3, 10, 1, 0, 1, 1], [3, 13, 13, 5, 6, 7, 1, 0, 1, 1], [3, 13, 13, 6, 5, 8, 1, 0, 1, 1], [3, 13, 13, 8, 6, 7, 1, 0, 1, 1], [3, 13, 13, 9, 5, 8, 1, 0, 1, 1], [3, 13, 13, 10, 4, 9, 1, 0, 1, 1], [3, 13, 13, 10, 6, 7, 1, 0, 1, 1], [3, 13, 13, 11, 3, 10, 1, 0, 1, 1], [3, 13, 13, 11, 5, 8, 1, 0, 1, 1], [3, 13, 13, 12, 4, 9, 1, 0, 1, 1], [3, 13, 13, 12, 5, 8, 1, 0, 1, 1], [3, 13, 14, 13, 4, 9, 0, 1, 1, 1], [3, 13, 15, 13, 3, 10, 0, 1, 1, 1], [3, 13, 15, 13, 5, 8, 0, 1, 1, 1], [3, 13, 16, 13, 4, 9, 0, 1, 1, 1], [3, 13, 18, 13, 3, 10, 0, 1, 1, 1], [3, 13, 20, 13, 4, 9, 0, 1, 1, 1], [3, 13, 20, 13, 5, 8, 0, 1, 1, 1], [3, 13, 24, 13, 4, 9, 0, 1, 1, 1], [3, 14, 14, 3, 4, 10, 1, 0, 1, 1], [3, 14, 14, 4, 3, 11, 1, 0, 1, 1], [3, 14, 14, 6, 4, 10, 1, 0, 1, 1], [3, 14, 14, 7, 3, 11, 1, 0, 1, 1], [3, 14, 14, 7, 4, 10, 1, 0, 1, 1], [3, 14, 14, 8, 5, 9, 1, 0, 1, 1], [3, 14, 14, 9, 7, 12, 1, 0, 2, 0], [3, 14, 14, 10, 3, 11, 1, 0, 1, 1], [3, 14, 14, 10, 4, 7, 1, 0, 0, 2], [3, 14, 14, 10, 6, 8, 1, 0, 1, 1], [3, 14, 14, 11, 4, 10, 1, 0, 1, 1], [3, 14, 14, 11, 5, 9, 1, 0, 1, 1], [3, 14, 14, 12, 3, 7, 1, 0, 0, 2], [3, 14, 14, 12, 3, 11, 1, 0, 1, 1], [3, 14, 14, 12, 4, 10, 1, 0, 1, 1], [3, 14, 14, 12, 5, 9, 1, 0, 1, 1], [3, 14, 14, 13, 3, 11, 1, 0, 1, 1], [3, 14, 14, 13, 4, 10, 1, 0, 1, 1], [3, 14, 15, 7, 10, 14, 0, 2, 0, 1], [3, 14, 15, 7, 12, 14, 0, 2, 0, 1], [3, 14, 15, 14, 3, 11, 0, 1, 1, 1], [3, 14, 15, 14, 4, 10, 0, 1, 1, 1], [3, 14, 15, 14, 6, 8, 0, 1, 1, 1], [3, 14, 17, 14, 4, 10, 0, 1, 1, 1], [3, 14, 18, 7, 14, 15, 0, 2, 1, 0], [3, 14, 20, 14, 5, 9, 0, 1, 1, 1], [3, 14, 20, 14, 6, 8, 0, 1, 1, 1], [3, 14, 25, 7, 13, 14, 0, 2, 0, 1], [3, 14, 25, 14, 7, 12, 0, 1, 2, 0], [3, 14, 30, 14, 4, 10, 0, 1, 1, 1], [3, 14, 30, 14, 5, 9, 0, 1, 1, 1], [3, 15, 15, 3, 7, 8, 1, 0, 1, 1], [3, 15, 15, 4, 3, 12, 1, 0, 1, 1], [3, 15, 15, 4, 6, 9, 1, 0, 1, 1], [3, 15, 15, 5, 3, 12, 1, 0, 1, 1], [3, 15, 15, 5, 4, 11, 1, 0, 1, 1], [3, 15, 15, 5, 6, 9, 1, 0, 1, 1], [3, 15, 15, 6, 4, 11, 1, 0, 1, 1], [3, 15, 15, 6, 7, 8, 1, 0, 1, 1], [3, 15, 15, 8, 3, 12, 1, 0, 1, 1], [3, 15, 15, 8, 6, 9, 1, 0, 1, 1], [3, 15, 15, 9, 3, 12, 1, 0, 1, 1], [3, 15, 15, 9, 4, 11, 1, 0, 1, 1], [3, 15, 15, 10, 3, 12, 1, 0, 1, 1], [3, 15, 15, 10, 4, 11, 1, 0, 1, 1], [3, 15, 15, 10, 6, 9, 1, 0, 1, 1], [3, 15, 15, 10, 7, 8, 1, 0, 1, 1], [3, 15, 15, 11, 3, 12, 1, 0, 1, 1], [3, 15, 15, 11, 6, 9, 1, 0, 1, 1], [3, 15, 15, 11, 7, 8, 1, 0, 1, 1], [3, 15, 15, 12, 4, 11, 1, 0, 1, 1], [3, 15, 15, 12, 7, 8, 1, 0, 1, 1], [3, 15, 15, 13, 3, 12, 1, 0, 1, 1], [3, 15, 17, 15, 6, 9, 0, 1, 1, 1], [3, 15, 20, 15, 3, 12, 0, 1, 1, 1], [3, 15, 20, 15, 6, 9, 0, 1, 1, 1], [3, 15, 24, 15, 4, 11, 0, 1, 1, 1], [3, 15, 24, 15, 7, 8, 0, 1, 1, 1], [3, 15, 25, 15, 3, 12, 0, 1, 1, 1], [3, 15, 25, 15, 6, 9, 0, 1, 1, 1], [3, 15, 25, 15, 7, 8, 0, 1, 1, 1], [3, 16, 16, 3, 4, 12, 1, 0, 1, 1], [3, 16, 16, 4, 5, 11, 1, 0, 1, 1], [3, 16, 16, 4, 6, 10, 1, 0, 1, 1], [3, 16, 16, 4, 7, 9, 1, 0, 1, 1], [3, 16, 16, 5, 3, 13, 1, 0, 1, 1], [3, 16, 16, 5, 4, 12, 1, 0, 1, 1], [3, 16, 16, 6, 7, 8, 1, 0, 0, 2], [3, 16, 16, 6, 7, 9, 1, 0, 1, 1], [3, 16, 16, 6, 8, 9, 1, 0, 2, 0], [3, 16, 16, 6, 8, 11, 1, 0, 2, 0], [3, 16, 16, 7, 4, 12, 1, 0, 1, 1], [3, 16, 16, 7, 5, 11, 1, 0, 1, 1], [3, 16, 16, 7, 6, 10, 1, 0, 1, 1], [3, 16, 16, 7, 8, 10, 1, 0, 2, 0], [3, 16, 16, 8, 5, 11, 1, 0, 1, 1], [3, 16, 16, 8, 6, 10, 1, 0, 1, 1], [3, 16, 16, 9, 3, 13, 1, 0, 1, 1], [3, 16, 16, 9, 4, 12, 1, 0, 1, 1], [3, 16, 16, 9, 5, 8, 1, 0, 0, 2], [3, 16, 16, 9, 6, 10, 1, 0, 1, 1], [3, 16, 16, 9, 8, 12, 1, 0, 2, 0], [3, 16, 16, 10, 4, 12, 1, 0, 1, 1], [3, 16, 16, 10, 6, 8, 1, 0, 0, 2], [3, 16, 16, 10, 7, 9, 1, 0, 1, 1], [3, 16, 16, 10, 8, 13, 1, 0, 2, 0], [3, 16, 16, 11, 3, 13, 1, 0, 1, 1], [3, 16, 16, 11, 4, 12, 1, 0, 1, 1], [3, 16, 16, 11, 6, 10, 1, 0, 1, 1], [3, 16, 16, 12, 3, 13, 1, 0, 1, 1], [3, 16, 16, 12, 5, 11, 1, 0, 1, 1], [3, 16, 16, 12, 8, 10, 1, 0, 2, 0], [3, 16, 16, 13, 4, 12, 1, 0, 1, 1], [3, 16, 16, 13, 5, 11, 1, 0, 1, 1], [3, 16, 16, 13, 8, 10, 1, 0, 2, 0], [3, 16, 16, 14, 4, 12, 1, 0, 1, 1], [3, 16, 16, 14, 6, 10, 1, 0, 1, 1], [3, 16, 16, 15, 6, 10, 1, 0, 1, 1], [3, 16, 16, 15, 7, 9, 1, 0, 1, 1], [3, 16, 17, 8, 9, 16, 0, 2, 0, 1], [3, 16, 17, 16, 4, 12, 0, 1, 1, 1], [3, 16, 17, 16, 5, 11, 0, 1, 1, 1], [3, 16, 17, 16, 6, 10, 0, 1, 1, 1], [3, 16, 18, 8, 12, 16, 0, 2, 0, 1], [3, 16, 18, 16, 5, 11, 0, 1, 1, 1], [3, 16, 20, 16, 4, 12, 0, 1, 1, 1], [3, 16, 20, 16, 5, 11, 0, 1, 1, 1], [3, 16, 25, 8, 3, 16, 0, 2, 0, 1], [3, 16, 25, 16, 5, 11, 0, 1, 1, 1], [3, 16, 25, 16, 6, 10, 0, 1, 1, 1], [3, 16, 30, 16, 4, 12, 0, 1, 1, 1], [3, 16, 30, 16, 8, 9, 0, 1, 2, 0], [3, 16, 30, 16, 8, 13, 0, 1, 2, 0], [3, 16, 30, 16, 8, 18, 0, 1, 2, 0], [3, 16, 30, 16, 8, 25, 0, 1, 2, 0], [3, 17, 17, 3, 7, 10, 1, 0, 1, 1], [3, 17, 17, 4, 3, 14, 1, 0, 1, 1], [3, 17, 17, 4, 5, 12, 1, 0, 1, 1], [3, 17, 17, 4, 7, 10, 1, 0, 1, 1], [3, 17, 17, 5, 3, 14, 1, 0, 1, 1], [3, 17, 17, 5, 4, 13, 1, 0, 1, 1], [3, 17, 17, 5, 6, 11, 1, 0, 1, 1], [3, 17, 17, 6, 4, 13, 1, 0, 1, 1], [3, 17, 17, 7, 6, 11, 1, 0, 1, 1], [3, 17, 17, 8, 5, 12, 1, 0, 1, 1], [3, 17, 17, 8, 7, 10, 1, 0, 1, 1], [3, 17, 17, 9, 5, 12, 1, 0, 1, 1], [3, 17, 17, 9, 6, 11, 1, 0, 1, 1], [3, 17, 17, 10, 4, 13, 1, 0, 1, 1], [3, 17, 17, 12, 8, 9, 1, 0, 1, 1], [3, 17, 17, 15, 5, 12, 1, 0, 1, 1], [3, 17, 17, 15, 6, 11, 1, 0, 1, 1], [3, 17, 17, 16, 5, 12, 1, 0, 1, 1], [3, 17, 17, 16, 6, 11, 1, 0, 1, 1], [3, 17, 18, 17, 4, 13, 0, 1, 1, 1], [3, 17, 20, 17, 5, 12, 0, 1, 1, 1], [3, 17, 30, 17, 3, 14, 0, 1, 1, 1], [3, 17, 30, 17, 5, 12, 0, 1, 1, 1], [3, 18, 18, 3, 8, 10, 1, 0, 1, 1], [3, 18, 18, 4, 3, 15, 1, 0, 1, 1], [3, 18, 18, 6, 5, 13, 1, 0, 1, 1], [3, 18, 18, 6, 7, 11, 1, 0, 1, 1], [3, 18, 18, 6, 8, 10, 1, 0, 1, 1], [3, 18, 18, 7, 3, 15, 1, 0, 1, 1], [3, 18, 18, 7, 8, 10, 1, 0, 1, 1], [3, 18, 18, 8, 3, 15, 1, 0, 1, 1], [3, 18, 18, 8, 7, 11, 1, 0, 1, 1], [3, 18, 18, 9, 7, 11, 1, 0, 1, 1], [3, 18, 18, 9, 8, 10, 1, 0, 1, 1], [3, 18, 18, 10, 4, 14, 1, 0, 1, 1], [3, 18, 18, 10, 6, 9, 1, 0, 0, 2], [3, 18, 18, 10, 7, 9, 1, 0, 0, 2], [3, 18, 18, 12, 3, 15, 1, 0, 1, 1], [3, 18, 18, 12, 5, 13, 1, 0, 1, 1], [3, 18, 18, 12, 7, 11, 1, 0, 1, 1], [3, 18, 18, 12, 8, 10, 1, 0, 1, 1], [3, 18, 18, 12, 9, 10, 1, 0, 2, 0], [3, 18, 18, 12, 9, 15, 1, 0, 2, 0], [3, 18, 18, 12, 9, 16, 1, 0, 2, 0], [3, 18, 18, 13, 4, 14, 1, 0, 1, 1], [3, 18, 18, 13, 8, 10, 1, 0, 1, 1], [3, 18, 18, 14, 8, 10, 1, 0, 1, 1], [3, 18, 18, 15, 4, 14, 1, 0, 1, 1], [3, 18, 18, 16, 3, 15, 1, 0, 1, 1], [3, 18, 18, 17, 8, 10, 1, 0, 1, 1], [3, 18, 24, 18, 8, 10, 0, 1, 1, 1], [3, 18, 25, 9, 10, 18, 0, 2, 0, 1], [3, 18, 25, 18, 4, 14, 0, 1, 1, 1], [3, 18, 25, 18, 8, 10, 0, 1, 1, 1], [3, 18, 30, 18, 8, 10, 0, 1, 1, 1], [3, 20, 20, 3, 4, 16, 1, 0, 1, 1], [3, 20, 20, 3, 7, 13, 1, 0, 1, 1], [3, 20, 20, 3, 8, 10, 1, 0, 0, 2], [3, 20, 20, 3, 8, 12, 1, 0, 1, 1], [3, 20, 20, 3, 10, 16, 1, 0, 2, 0], [3, 20, 20, 4, 7, 10, 1, 0, 0, 2], [3, 20, 20, 4, 7, 13, 1, 0, 1, 1], [3, 20, 20, 4, 9, 10, 1, 0, 0, 2], [3, 20, 20, 4, 9, 11, 1, 0, 1, 1], [3, 20, 20, 5, 3, 17, 1, 0, 1, 1], [3, 20, 20, 5, 4, 16, 1, 0, 1, 1], [3, 20, 20, 5, 6, 14, 1, 0, 1, 1], [3, 20, 20, 5, 7, 13, 1, 0, 1, 1], [3, 20, 20, 5, 8, 12, 1, 0, 1, 1], [3, 20, 20, 6, 4, 10, 1, 0, 0, 2], [3, 20, 20, 6, 4, 16, 1, 0, 1, 1], [3, 20, 20, 6, 8, 10, 1, 0, 0, 2], [3, 20, 20, 6, 9, 11, 1, 0, 1, 1], [3, 20, 20, 6, 10, 17, 1, 0, 2, 0], [3, 20, 20, 6, 10, 18, 1, 0, 2, 0], [3, 20, 20, 7, 4, 16, 1, 0, 1, 1], [3, 20, 20, 7, 6, 10, 1, 0, 0, 2], [3, 20, 20, 7, 8, 12, 1, 0, 1, 1], [3, 20, 20, 7, 10, 12, 1, 0, 2, 0], [3, 20, 20, 7, 10, 17, 1, 0, 2, 0], [3, 20, 20, 8, 3, 10, 1, 0, 0, 2], [3, 20, 20, 8, 9, 11, 1, 0, 1, 1], [3, 20, 20, 8, 10, 18, 1, 0, 2, 0], [3, 20, 20, 9, 4, 10, 1, 0, 0, 2], [3, 20, 20, 9, 4, 16, 1, 0, 1, 1], [3, 20, 20, 9, 8, 12, 1, 0, 1, 1], [3, 20, 20, 9, 10, 12, 1, 0, 2, 0], [3, 20, 20, 10, 4, 16, 1, 0, 1, 1], [3, 20, 20, 10, 6, 14, 1, 0, 1, 1], [3, 20, 20, 10, 7, 13, 1, 0, 1, 1], [3, 20, 20, 10, 8, 12, 1, 0, 1, 1], [3, 20, 20, 11, 3, 17, 1, 0, 1, 1], [3, 20, 20, 11, 8, 12, 1, 0, 1, 1], [3, 20, 20, 11, 9, 10, 1, 0, 0, 2], [3, 20, 20, 12, 4, 16, 1, 0, 1, 1], [3, 20, 20, 12, 7, 13, 1, 0, 1, 1], [3, 20, 20, 12, 9, 10, 1, 0, 0, 2], [3, 20, 20, 13, 4, 10, 1, 0, 0, 2], [3, 20, 20, 13, 9, 11, 1, 0, 1, 1], [3, 20, 20, 13, 10, 16, 1, 0, 2, 0], [3, 20, 20, 14, 8, 12, 1, 0, 1, 1], [3, 20, 20, 15, 3, 17, 1, 0, 1, 1], [3, 20, 20, 15, 7, 13, 1, 0, 1, 1], [3, 20, 20, 15, 8, 12, 1, 0, 1, 1], [3, 20, 20, 15, 9, 11, 1, 0, 1, 1], [3, 20, 20, 16, 9, 11, 1, 0, 1, 1], [3, 20, 20, 16, 10, 11, 1, 0, 2, 0], [3, 20, 20, 17, 8, 12, 1, 0, 1, 1], [3, 20, 20, 17, 10, 12, 1, 0, 2, 0], [3, 20, 20, 18, 3, 17, 1, 0, 1, 1], [3, 20, 20, 18, 8, 12, 1, 0, 1, 1], [3, 20, 25, 20, 4, 16, 0, 1, 1, 1], [3, 20, 25, 20, 8, 12, 0, 1, 1, 1], [3, 20, 30, 20, 4, 16, 0, 1, 1, 1], [3, 20, 30, 20, 6, 14, 0, 1, 1, 1], [3, 20, 30, 20, 8, 12, 0, 1, 1, 1], [3, 24, 24, 4, 9, 15, 1, 0, 1, 1], [3, 24, 24, 5, 7, 17, 1, 0, 1, 1], [3, 24, 24, 5, 11, 12, 1, 0, 0, 2], [3, 24, 24, 6, 4, 20, 1, 0, 1, 1], [3, 24, 24, 6, 11, 13, 1, 0, 1, 1], [3, 24, 24, 8, 10, 12, 1, 0, 0, 2], [3, 24, 24, 8, 11, 13, 1, 0, 1, 1], [3, 24, 24, 8, 12, 17, 1, 0, 2, 0], [3, 24, 24, 9, 4, 20, 1, 0, 1, 1], [3, 24, 24, 9, 7, 12, 1, 0, 0, 2], [3, 24, 24, 9, 10, 12, 1, 0, 0, 2], [3, 24, 24, 9, 10, 14, 1, 0, 1, 1], [3, 24, 24, 10, 7, 12, 1, 0, 0, 2], [3, 24, 24, 10, 8, 12, 1, 0, 0, 2], [3, 24, 24, 10, 12, 13, 1, 0, 2, 0], [3, 24, 24, 11, 8, 12, 1, 0, 0, 2], [3, 24, 24, 11, 9, 12, 1, 0, 0, 2], [3, 24, 24, 11, 9, 15, 1, 0, 1, 1], [3, 24, 24, 11, 10, 14, 1, 0, 1, 1], [3, 24, 24, 12, 4, 20, 1, 0, 1, 1], [3, 24, 24, 12, 10, 14, 1, 0, 1, 1], [3, 24, 24, 13, 9, 15, 1, 0, 1, 1], [3, 24, 24, 15, 4, 20, 1, 0, 1, 1], [3, 24, 24, 15, 8, 12, 1, 0, 0, 2], [3, 24, 24, 15, 10, 12, 1, 0, 0, 2], [3, 24, 24, 15, 12, 20, 1, 0, 2, 0], [3, 24, 24, 17, 4, 12, 1, 0, 0, 2], [3, 24, 24, 20, 11, 13, 1, 0, 1, 1], [3, 24, 24, 20, 12, 17, 1, 0, 2, 0], [3, 24, 25, 12, 5, 24, 0, 2, 0, 1], [3, 24, 25, 12, 8, 24, 0, 2, 0, 1], [3, 24, 30, 24, 11, 13, 0, 1, 1, 1], [3, 25, 25, 3, 12, 13, 1, 0, 1, 1], [3, 25, 25, 4, 9, 16, 1, 0, 1, 1], [3, 25, 25, 4, 12, 13, 1, 0, 1, 1], [3, 25, 25, 9, 8, 17, 1, 0, 1, 1], [3, 25, 25, 10, 9, 16, 1, 0, 1, 1], [3, 25, 25, 10, 11, 14, 1, 0, 1, 1], [3, 25, 25, 11, 9, 16, 1, 0, 1, 1], [3, 25, 25, 12, 7, 18, 1, 0, 1, 1], [3, 25, 25, 12, 8, 17, 1, 0, 1, 1], [3, 25, 25, 15, 8, 17, 1, 0, 1, 1], [3, 25, 25, 17, 7, 18, 1, 0, 1, 1], [3, 25, 30, 25, 7, 18, 0, 1, 1, 1], [3, 25, 30, 25, 8, 17, 0, 1, 1, 1], [3, 30, 30, 3, 14, 16, 1, 0, 1, 1], [3, 30, 30, 4, 6, 15, 1, 0, 0, 2], [3, 30, 30, 4, 14, 16, 1, 0, 1, 1], [3, 30, 30, 9, 4, 15, 1, 0, 0, 2], [3, 30, 30, 9, 11, 15, 1, 0, 0, 2], [3, 30, 30, 9, 15, 17, 1, 0, 2, 0], [3, 30, 30, 10, 13, 17, 1, 0, 1, 1], [3, 30, 30, 11, 9, 15, 1, 0, 0, 2], [3, 30, 30, 12, 7, 15, 1, 0, 0, 2], [3, 30, 30, 12, 14, 15, 1, 0, 0, 2], [3, 30, 30, 24, 4, 15, 1, 0, 0, 2], [3, 30, 30, 25, 14, 16, 1, 0, 1, 1], [4, 8, 8, 4, 3, 5, 0, 2, 1, 1], [4, 8, 10, 4, 3, 5, 0, 2, 1, 1], [4, 8, 12, 4, 3, 5, 0, 2, 1, 1], [4, 8, 20, 4, 3, 5, 0, 2, 1, 1], [4, 8, 24, 4, 3, 5, 0, 2, 1, 1], [4, 9, 6, 3, 4, 5, 1, 1, 1, 1], [4, 9, 9, 4, 3, 8, 1, 0, 3, 0], [4, 9, 9, 5, 3, 6, 1, 0, 3, 0], [4, 9, 9, 6, 3, 5, 1, 0, 3, 0], [4, 9, 9, 8, 3, 6, 1, 0, 3, 0], [4, 9, 12, 9, 3, 8, 0, 1, 3, 0], [4, 9, 13, 9, 3, 12, 0, 1, 3, 0], [4, 9, 16, 3, 5, 9, 0, 3, 0, 1], [4, 9, 16, 9, 3, 12, 0, 1, 3, 0], [4, 9, 24, 9, 3, 7, 0, 1, 3, 0], [4, 10, 7, 3, 4, 5, 1, 1, 0, 2], [4, 10, 8, 5, 3, 7, 0, 2, 1, 1], [4, 10, 9, 5, 4, 6, 0, 2, 1, 1], [4, 10, 10, 5, 3, 4, 1, 0, 2, 1], [4, 10, 10, 5, 4, 6, 0, 2, 1, 1], [4, 10, 10, 6, 3, 4, 1, 0, 2, 1], [4, 10, 10, 7, 3, 4, 1, 0, 2, 1], [4, 10, 10, 8, 3, 4, 1, 0, 2, 1], [4, 10, 14, 10, 3, 4, 0, 1, 2, 1], [4, 10, 15, 5, 4, 6, 0, 2, 1, 1], [4, 10, 15, 10, 3, 4, 0, 1, 2, 1], [4, 10, 17, 10, 3, 4, 0, 1, 2, 1], [4, 10, 20, 5, 3, 7, 0, 2, 1, 1], [4, 10, 20, 5, 4, 6, 0, 2, 1, 1], [4, 10, 20, 10, 3, 4, 0, 1, 2, 1], [4, 10, 24, 5, 4, 6, 0, 2, 1, 1], [4, 10, 25, 10, 3, 4, 0, 1, 2, 1], [4, 10, 30, 10, 3, 4, 0, 1, 2, 1], [4, 11, 7, 4, 5, 6, 1, 1, 1, 1], [4, 11, 11, 5, 3, 4, 1, 0, 1, 2], [4, 11, 11, 6, 3, 4, 1, 0, 1, 2], [4, 11, 11, 7, 3, 4, 1, 0, 1, 2], [4, 11, 11, 7, 3, 5, 1, 0, 2, 1], [4, 11, 11, 8, 3, 4, 1, 0, 1, 2], [4, 11, 11, 10, 3, 5, 1, 0, 2, 1], [4, 11, 14, 11, 3, 4, 0, 1, 1, 2], [4, 11, 16, 11, 3, 4, 0, 1, 1, 2], [4, 11, 20, 11, 3, 4, 0, 1, 1, 2], [4, 11, 20, 11, 3, 5, 0, 1, 2, 1], [4, 11, 24, 11, 3, 4, 0, 1, 1, 2], [4, 11, 30, 11, 3, 4, 0, 1, 1, 2], [4, 12, 8, 4, 3, 6, 1, 1, 0, 2], [4, 12, 8, 4, 5, 6, 1, 1, 0, 2], [4, 12, 8, 4, 5, 7, 1, 1, 1, 1], [4, 12, 8, 4, 6, 7, 1, 1, 2, 0], [4, 12, 9, 3, 5, 6, 1, 1, 0, 2], [4, 12, 9, 3, 6, 8, 1, 1, 2, 0], [4, 12, 9, 6, 4, 8, 0, 2, 1, 1], [4, 12, 10, 6, 3, 9, 0, 2, 1, 1], [4, 12, 10, 6, 5, 7, 0, 2, 1, 1], [4, 12, 11, 6, 3, 9, 0, 2, 1, 1], [4, 12, 11, 6, 5, 7, 0, 2, 1, 1], [4, 12, 12, 4, 3, 6, 1, 0, 2, 1], [4, 12, 12, 5, 3, 6, 1, 0, 2, 1], [4, 12, 12, 6, 4, 10, 1, 0, 3, 0], [4, 12, 12, 8, 3, 4, 1, 0, 0, 3], [4, 12, 12, 8, 3, 6, 1, 0, 2, 1], [4, 12, 12, 8, 4, 5, 1, 0, 3, 0], [4, 12, 12, 8, 4, 6, 1, 0, 3, 0], [4, 12, 12, 8, 4, 9, 1, 0, 3, 0], [4, 12, 12, 9, 4, 6, 1, 0, 3, 0], [4, 12, 12, 9, 4, 7, 1, 0, 3, 0], [4, 12, 12, 10, 3, 6, 1, 0, 2, 1], [4, 12, 12, 10, 4, 5, 1, 0, 3, 0], [4, 12, 12, 10, 4, 8, 1, 0, 3, 0], [4, 12, 12, 10, 4, 9, 1, 0, 3, 0], [4, 12, 12, 11, 3, 6, 1, 0, 2, 1], [4, 12, 13, 4, 8, 12, 0, 3, 0, 1], [4, 12, 13, 12, 4, 7, 0, 1, 3, 0], [4, 12, 14, 4, 5, 12, 0, 3, 0, 1], [4, 12, 14, 4, 8, 12, 0, 3, 0, 1], [4, 12, 14, 6, 4, 8, 0, 2, 1, 1], [4, 12, 15, 4, 6, 12, 0, 3, 0, 1], [4, 12, 15, 4, 10, 12, 0, 3, 0, 1], [4, 12, 15, 6, 4, 8, 0, 2, 1, 1], [4, 12, 15, 12, 4, 8, 0, 1, 3, 0], [4, 12, 16, 4, 6, 12, 0, 3, 0, 1], [4, 12, 16, 4, 11, 12, 0, 3, 0, 1], [4, 12, 16, 12, 3, 6, 0, 1, 2, 1], [4, 12, 16, 12, 4, 7, 0, 1, 3, 0], [4, 12, 17, 12, 4, 6, 0, 1, 3, 0], [4, 12, 17, 12, 4, 8, 0, 1, 3, 0], [4, 12, 18, 6, 4, 8, 0, 2, 1, 1], [4, 12, 18, 12, 4, 9, 0, 1, 3, 0], [4, 12, 20, 6, 3, 9, 0, 2, 1, 1], [4, 12, 20, 12, 3, 6, 0, 1, 2, 1], [4, 12, 20, 12, 4, 5, 0, 1, 3, 0], [4, 12, 20, 12, 4, 6, 0, 1, 3, 0], [4, 12, 20, 12, 4, 15, 0, 1, 3, 0], [4, 12, 20, 12, 4, 18, 0, 1, 3, 0], [4, 12, 24, 4, 9, 12, 0, 3, 0, 1], [4, 12, 24, 6, 5, 7, 0, 2, 1, 1], [4, 12, 25, 4, 12, 16, 0, 3, 1, 0], [4, 12, 25, 6, 4, 8, 0, 2, 1, 1], [4, 12, 25, 12, 3, 6, 0, 1, 2, 1], [4, 12, 25, 12, 4, 8, 0, 1, 3, 0], [4, 12, 25, 12, 4, 13, 0, 1, 3, 0], [4, 12, 30, 4, 5, 12, 0, 3, 0, 1], [4, 12, 30, 4, 7, 12, 0, 3, 0, 1], [4, 12, 30, 4, 12, 16, 0, 3, 1, 0], [4, 12, 30, 6, 4, 8, 0, 2, 1, 1], [4, 12, 30, 12, 4, 8, 0, 1, 3, 0], [4, 13, 8, 5, 6, 7, 1, 1, 1, 1], [4, 13, 9, 4, 5, 8, 1, 1, 1, 1], [4, 13, 10, 3, 5, 8, 1, 1, 1, 1], [4, 13, 13, 6, 3, 5, 1, 0, 1, 2], [4, 13, 13, 7, 4, 5, 1, 0, 2, 1], [4, 13, 13, 8, 3, 5, 1, 0, 1, 2], [4, 13, 13, 8, 4, 5, 1, 0, 2, 1], [4, 13, 13, 9, 4, 5, 1, 0, 2, 1], [4, 13, 13, 10, 3, 5, 1, 0, 1, 2], [4, 13, 13, 11, 3, 7, 1, 0, 2, 1], [4, 13, 13, 12, 3, 5, 1, 0, 1, 2], [4, 13, 13, 12, 3, 7, 1, 0, 2, 1], [4, 13, 15, 13, 3, 7, 0, 1, 2, 1], [4, 13, 17, 13, 3, 5, 0, 1, 1, 2], [4, 13, 18, 13, 4, 5, 0, 1, 2, 1], [4, 13, 20, 13, 3, 7, 0, 1, 2, 1], [4, 13, 30, 13, 3, 7, 0, 1, 2, 1], [4, 14, 8, 6, 3, 7, 1, 1, 0, 2], [4, 14, 8, 6, 4, 7, 1, 1, 0, 2], [4, 14, 9, 5, 6, 7, 1, 1, 0, 2], [4, 14, 9, 5, 6, 8, 1, 1, 1, 1], [4, 14, 10, 4, 3, 7, 1, 1, 0, 2], [4, 14, 10, 4, 5, 7, 1, 1, 0, 2], [4, 14, 10, 4, 5, 9, 1, 1, 1, 1], [4, 14, 10, 4, 6, 7, 1, 1, 0, 2], [4, 14, 10, 4, 6, 8, 1, 1, 1, 1], [4, 14, 10, 4, 7, 9, 1, 1, 2, 0], [4, 14, 10, 7, 5, 9, 0, 2, 1, 1], [4, 14, 11, 3, 4, 7, 1, 1, 0, 2], [4, 14, 11, 3, 6, 8, 1, 1, 1, 1], [4, 14, 12, 7, 3, 11, 0, 2, 1, 1], [4, 14, 12, 7, 6, 8, 0, 2, 1, 1], [4, 14, 13, 7, 6, 8, 0, 2, 1, 1], [4, 14, 14, 4, 3, 8, 1, 0, 2, 1], [4, 14, 14, 5, 3, 8, 1, 0, 2, 1], [4, 14, 14, 6, 3, 8, 1, 0, 2, 1], [4, 14, 14, 7, 4, 6, 1, 0, 2, 1], [4, 14, 14, 7, 4, 10, 0, 2, 1, 1], [4, 14, 14, 8, 4, 5, 1, 0, 1, 2], [4, 14, 14, 9, 4, 5, 1, 0, 1, 2], [4, 14, 14, 10, 4, 5, 1, 0, 1, 2], [4, 14, 14, 10, 4, 6, 1, 0, 2, 1], [4, 14, 14, 11, 4, 6, 1, 0, 2, 1], [4, 14, 14, 12, 3, 8, 1, 0, 2, 1], [4, 14, 15, 7, 6, 8, 0, 2, 1, 1], [4, 14, 15, 14, 4, 6, 0, 1, 2, 1], [4, 14, 16, 7, 4, 10, 0, 2, 1, 1], [4, 14, 16, 14, 3, 8, 0, 1, 2, 1], [4, 14, 17, 7, 4, 10, 0, 2, 1, 1], [4, 14, 17, 7, 5, 9, 0, 2, 1, 1], [4, 14, 20, 7, 3, 11, 0, 2, 1, 1], [4, 14, 20, 7, 4, 10, 0, 2, 1, 1], [4, 14, 20, 14, 4, 5, 0, 1, 1, 2], [4, 14, 25, 7, 6, 8, 0, 2, 1, 1], [4, 14, 25, 14, 4, 5, 0, 1, 1, 2], [4, 14, 30, 7, 5, 9, 0, 2, 1, 1], [4, 14, 30, 7, 6, 8, 0, 2, 1, 1], [4, 14, 30, 14, 4, 5, 0, 1, 1, 2], [4, 15, 11, 4, 5, 10, 1, 1, 1, 1], [4, 15, 11, 4, 7, 8, 1, 1, 1, 1], [4, 15, 15, 3, 4, 5, 1, 0, 0, 3], [4, 15, 15, 4, 3, 6, 1, 0, 1, 2], [4, 15, 15, 5, 4, 7, 1, 0, 2, 1], [4, 15, 15, 6, 5, 8, 1, 0, 3, 0], [4, 15, 15, 7, 4, 5, 1, 0, 0, 3], [4, 15, 15, 8, 5, 12, 1, 0, 3, 0], [4, 15, 15, 9, 4, 7, 1, 0, 2, 1], [4, 15, 15, 10, 3, 6, 1, 0, 1, 2], [4, 15, 15, 10, 3, 9, 1, 0, 2, 1], [4, 15, 15, 10, 4, 7, 1, 0, 2, 1], [4, 15, 15, 12, 3, 9, 1, 0, 2, 1], [4, 15, 15, 12, 5, 7, 1, 0, 3, 0], [4, 15, 15, 13, 4, 7, 1, 0, 2, 1], [4, 15, 16, 15, 4, 7, 0, 1, 2, 1], [4, 15, 16, 15, 5, 11, 0, 1, 3, 0], [4, 15, 17, 15, 4, 5, 0, 1, 0, 3], [4, 15, 20, 15, 3, 6, 0, 1, 1, 2], [4, 15, 24, 15, 5, 11, 0, 1, 3, 0], [4, 15, 25, 15, 3, 9, 0, 1, 2, 1], [4, 15, 25, 15, 4, 7, 0, 1, 2, 1], [4, 15, 30, 15, 4, 7, 0, 1, 2, 1], [4, 16, 9, 7, 4, 8, 1, 1, 0, 2], [4, 16, 10, 6, 3, 8, 1, 1, 0, 2], [4, 16, 10, 6, 7, 8, 1, 1, 0, 2], [4, 16, 10, 6, 8, 9, 1, 1, 2, 0], [4, 16, 11, 5, 3, 8, 1, 1, 0, 2], [4, 16, 11, 5, 4, 8, 1, 1, 0, 2], [4, 16, 11, 5, 6, 10, 1, 1, 1, 1], [4, 16, 11, 5, 7, 8, 1, 1, 0, 2], [4, 16, 11, 5, 8, 10, 1, 1, 2, 0], [4, 16, 11, 8, 6, 10, 0, 2, 1, 1], [4, 16, 12, 4, 3, 8, 1, 1, 0, 2], [4, 16, 12, 4, 5, 8, 1, 1, 0, 2], [4, 16, 12, 4, 5, 11, 1, 1, 1, 1], [4, 16, 12, 4, 6, 8, 1, 1, 0, 2], [4, 16, 12, 4, 6, 10, 1, 1, 1, 1], [4, 16, 12, 4, 7, 8, 1, 1, 0, 2], [4, 16, 12, 4, 8, 9, 1, 1, 2, 0], [4, 16, 12, 4, 8, 10, 1, 1, 2, 0], [4, 16, 12, 4, 8, 11, 1, 1, 2, 0], [4, 16, 12, 8, 5, 11, 0, 2, 1, 1], [4, 16, 13, 3, 4, 8, 1, 1, 0, 2], [4, 16, 13, 3, 6, 8, 1, 1, 0, 2], [4, 16, 13, 8, 6, 10, 0, 2, 1, 1], [4, 16, 14, 8, 4, 12, 0, 2, 1, 1], [4, 16, 14, 8, 6, 10, 0, 2, 1, 1], [4, 16, 15, 8, 4, 12, 0, 2, 1, 1], [4, 16, 15, 8, 6, 10, 0, 2, 1, 1], [4, 16, 16, 3, 4, 6, 1, 0, 1, 2], [4, 16, 16, 3, 5, 6, 1, 0, 2, 1], [4, 16, 16, 5, 4, 8, 1, 0, 2, 1], [4, 16, 16, 7, 3, 10, 1, 0, 2, 1], [4, 16, 16, 7, 4, 8, 1, 0, 2, 1], [4, 16, 16, 7, 5, 6, 1, 0, 2, 1], [4, 16, 16, 8, 3, 10, 1, 0, 2, 1], [4, 16, 16, 8, 4, 6, 1, 0, 1, 2], [4, 16, 16, 8, 5, 6, 1, 0, 2, 1], [4, 16, 16, 8, 7, 9, 0, 2, 1, 1], [4, 16, 16, 9, 4, 8, 1, 0, 2, 1], [4, 16, 16, 10, 4, 6, 1, 0, 1, 2], [4, 16, 16, 10, 5, 6, 1, 0, 2, 1], [4, 16, 16, 11, 4, 6, 1, 0, 1, 2], [4, 16, 16, 12, 3, 10, 1, 0, 2, 1], [4, 16, 16, 12, 5, 6, 1, 0, 2, 1], [4, 16, 16, 13, 3, 10, 1, 0, 2, 1], [4, 16, 16, 13, 5, 6, 1, 0, 2, 1], [4, 16, 16, 14, 3, 10, 1, 0, 2, 1], [4, 16, 16, 14, 4, 8, 1, 0, 2, 1], [4, 16, 16, 15, 4, 6, 1, 0, 1, 2], [4, 16, 16, 15, 4, 8, 1, 0, 2, 1], [4, 16, 17, 8, 4, 12, 0, 2, 1, 1], [4, 16, 17, 8, 7, 9, 0, 2, 1, 1], [4, 16, 18, 8, 5, 11, 0, 2, 1, 1], [4, 16, 18, 8, 7, 9, 0, 2, 1, 1], [4, 16, 18, 16, 3, 10, 0, 1, 2, 1], [4, 16, 20, 8, 5, 11, 0, 2, 1, 1], [4, 16, 20, 8, 6, 10, 0, 2, 1, 1], [4, 16, 20, 16, 3, 10, 0, 1, 2, 1], [4, 16, 20, 16, 4, 6, 0, 1, 1, 2], [4, 16, 20, 16, 5, 6, 0, 1, 2, 1], [4, 16, 24, 8, 5, 11, 0, 2, 1, 1], [4, 16, 24, 8, 6, 10, 0, 2, 1, 1], [4, 16, 25, 8, 4, 12, 0, 2, 1, 1], [4, 16, 25, 8, 6, 10, 0, 2, 1, 1], [4, 16, 25, 16, 5, 6, 0, 1, 2, 1], [4, 16, 30, 8, 4, 12, 0, 2, 1, 1], [4, 16, 30, 8, 5, 11, 0, 2, 1, 1], [4, 16, 30, 16, 4, 8, 0, 1, 2, 1], [4, 17, 10, 7, 8, 9, 1, 1, 1, 1], [4, 17, 12, 5, 6, 11, 1, 1, 1, 1], [4, 17, 12, 5, 7, 10, 1, 1, 1, 1], [4, 17, 12, 5, 8, 9, 1, 1, 1, 1], [4, 17, 17, 4, 3, 7, 1, 0, 1, 2], [4, 17, 17, 6, 3, 7, 1, 0, 1, 2], [4, 17, 17, 6, 3, 11, 1, 0, 2, 1], [4, 17, 17, 6, 4, 9, 1, 0, 2, 1], [4, 17, 17, 8, 3, 11, 1, 0, 2, 1], [4, 17, 17, 10, 4, 9, 1, 0, 2, 1], [4, 17, 17, 10, 5, 6, 1, 0, 1, 2], [4, 17, 17, 12, 3, 7, 1, 0, 1, 2], [4, 17, 17, 12, 5, 6, 1, 0, 1, 2], [4, 17, 17, 13, 3, 11, 1, 0, 2, 1], [4, 17, 17, 13, 4, 9, 1, 0, 2, 1], [4, 17, 17, 14, 3, 11, 1, 0, 2, 1], [4, 17, 18, 17, 5, 7, 0, 1, 2, 1], [4, 17, 25, 17, 5, 7, 0, 1, 2, 1], [4, 17, 30, 17, 4, 9, 0, 1, 2, 1], [4, 18, 10, 8, 4, 9, 1, 1, 0, 2], [4, 18, 10, 8, 5, 9, 1, 1, 0, 2], [4, 18, 10, 8, 6, 9, 1, 1, 0, 2], [4, 18, 11, 7, 8, 10, 1, 1, 1, 1], [4, 18, 12, 6, 7, 9, 1, 1, 0, 2], [4, 18, 12, 6, 7, 11, 1, 1, 1, 1], [4, 18, 12, 6, 8, 9, 1, 1, 0, 2], [4, 18, 12, 6, 8, 10, 1, 1, 1, 1], [4, 18, 12, 6, 9, 10, 1, 1, 2, 0], [4, 18, 12, 6, 9, 11, 1, 1, 2, 0], [4, 18, 12, 9, 7, 11, 0, 2, 1, 1], [4, 18, 12, 9, 8, 10, 0, 2, 1, 1], [4, 18, 13, 5, 8, 10, 1, 1, 1, 1], [4, 18, 13, 9, 8, 10, 0, 2, 1, 1], [4, 18, 14, 4, 5, 9, 1, 1, 0, 2], [4, 18, 14, 4, 7, 9, 1, 1, 0, 2], [4, 18, 14, 4, 8, 9, 1, 1, 0, 2], [4, 18, 14, 4, 9, 11, 1, 1, 2, 0], [4, 18, 15, 3, 8, 10, 1, 1, 1, 1], [4, 18, 15, 9, 4, 14, 0, 2, 1, 1], [4, 18, 15, 9, 7, 11, 0, 2, 1, 1], [4, 18, 15, 9, 8, 10, 0, 2, 1, 1], [4, 18, 16, 9, 7, 11, 0, 2, 1, 1], [4, 18, 16, 9, 8, 10, 0, 2, 1, 1], [4, 18, 17, 9, 4, 14, 0, 2, 1, 1], [4, 18, 18, 3, 4, 7, 1, 0, 1, 2], [4, 18, 18, 3, 4, 10, 1, 0, 2, 1], [4, 18, 18, 5, 4, 7, 1, 0, 1, 2], [4, 18, 18, 5, 4, 10, 1, 0, 2, 1], [4, 18, 18, 6, 5, 8, 1, 0, 2, 1], [4, 18, 18, 7, 5, 6, 1, 0, 0, 3], [4, 18, 18, 7, 5, 8, 1, 0, 2, 1], [4, 18, 18, 7, 6, 10, 1, 0, 3, 0], [4, 18, 18, 7, 6, 17, 1, 0, 3, 0], [4, 18, 18, 8, 3, 6, 1, 0, 0, 3], [4, 18, 18, 8, 3, 12, 1, 0, 2, 1], [4, 18, 18, 8, 4, 10, 1, 0, 2, 1], [4, 18, 18, 9, 4, 10, 1, 0, 2, 1], [4, 18, 18, 9, 8, 10, 0, 2, 1, 1], [4, 18, 18, 11, 4, 10, 1, 0, 2, 1], [4, 18, 18, 13, 5, 6, 1, 0, 0, 3], [4, 18, 18, 15, 3, 12, 1, 0, 2, 1], [4, 18, 18, 17, 4, 10, 1, 0, 2, 1], [4, 18, 20, 9, 6, 12, 0, 2, 1, 1], [4, 18, 20, 9, 8, 10, 0, 2, 1, 1], [4, 18, 20, 18, 4, 10, 0, 1, 2, 1], [4, 18, 25, 6, 3, 18, 0, 3, 0, 1], [4, 18, 25, 9, 6, 12, 0, 2, 1, 1], [4, 18, 25, 18, 4, 10, 0, 1, 2, 1], [4, 18, 25, 18, 5, 8, 0, 1, 2, 1], [4, 18, 30, 18, 5, 8, 0, 1, 2, 1], [4, 19, 12, 7, 9, 10, 1, 1, 1, 1], [4, 19, 13, 6, 7, 12, 1, 1, 1, 1], [4, 19, 13, 6, 8, 11, 1, 1, 1, 1], [4, 19, 15, 4, 8, 11, 1, 1, 1, 1], [4, 19, 15, 4, 9, 10, 1, 1, 1, 1], [4, 19, 16, 3, 6, 13, 1, 1, 1, 1], [4, 20, 11, 9, 4, 10, 1, 1, 0, 2], [4, 20, 11, 9, 5, 10, 1, 1, 0, 2], [4, 20, 11, 9, 7, 10, 1, 1, 0, 2], [4, 20, 12, 8, 3, 10, 1, 1, 0, 2], [4, 20, 12, 8, 5, 10, 1, 1, 0, 2], [4, 20, 12, 8, 7, 10, 1, 1, 0, 2], [4, 20, 12, 8, 9, 10, 1, 1, 0, 2], [4, 20, 12, 8, 9, 11, 1, 1, 1, 1], [4, 20, 13, 7, 3, 10, 1, 1, 0, 2], [4, 20, 13, 7, 8, 10, 1, 1, 0, 2], [4, 20, 13, 7, 8, 12, 1, 1, 1, 1], [4, 20, 13, 10, 8, 12, 0, 2, 1, 1], [4, 20, 14, 6, 4, 10, 1, 1, 0, 2], [4, 20, 14, 6, 5, 10, 1, 1, 0, 2], [4, 20, 14, 6, 8, 10, 1, 1, 0, 2], [4, 20, 14, 6, 10, 12, 1, 1, 2, 0], [4, 20, 15, 5, 8, 12, 1, 1, 1, 1], [4, 20, 15, 10, 8, 12, 0, 2, 1, 1], [4, 20, 16, 4, 5, 10, 1, 1, 0, 2], [4, 20, 16, 4, 6, 10, 1, 1, 0, 2], [4, 20, 16, 4, 9, 10, 1, 1, 0, 2], [4, 20, 16, 4, 10, 11, 1, 1, 2, 0], [4, 20, 17, 3, 4, 10, 1, 1, 0, 2], [4, 20, 17, 3, 7, 10, 1, 1, 0, 2], [4, 20, 17, 3, 10, 12, 1, 1, 2, 0], [4, 20, 17, 3, 10, 15, 1, 1, 2, 0], [4, 20, 17, 10, 9, 11, 0, 2, 1, 1], [4, 20, 18, 10, 8, 12, 0, 2, 1, 1], [4, 20, 20, 3, 4, 8, 1, 0, 1, 2], [4, 20, 20, 3, 4, 12, 1, 0, 2, 1], [4, 20, 20, 3, 6, 7, 1, 0, 1, 2], [4, 20, 20, 4, 6, 7, 1, 0, 1, 2], [4, 20, 20, 4, 6, 8, 1, 0, 2, 1], [4, 20, 20, 5, 3, 14, 1, 0, 2, 1], [4, 20, 20, 5, 4, 8, 1, 0, 1, 2], [4, 20, 20, 5, 4, 12, 1, 0, 2, 1], [4, 20, 20, 6, 4, 12, 1, 0, 2, 1], [4, 20, 20, 7, 4, 8, 1, 0, 1, 2], [4, 20, 20, 9, 4, 8, 1, 0, 1, 2], [4, 20, 20, 10, 3, 14, 1, 0, 2, 1], [4, 20, 20, 10, 4, 8, 1, 0, 1, 2], [4, 20, 20, 10, 4, 12, 1, 0, 2, 1], [4, 20, 20, 10, 4, 16, 0, 2, 1, 1], [4, 20, 20, 10, 6, 7, 1, 0, 1, 2], [4, 20, 20, 10, 6, 8, 1, 0, 2, 1], [4, 20, 20, 10, 8, 12, 0, 2, 1, 1], [4, 20, 20, 10, 9, 11, 0, 2, 1, 1], [4, 20, 20, 12, 6, 7, 1, 0, 1, 2], [4, 20, 20, 12, 6, 8, 1, 0, 2, 1], [4, 20, 20, 13, 4, 8, 1, 0, 1, 2], [4, 20, 20, 13, 6, 8, 1, 0, 2, 1], [4, 20, 20, 14, 4, 12, 1, 0, 2, 1], [4, 20, 20, 15, 4, 12, 1, 0, 2, 1], [4, 20, 20, 15, 6, 8, 1, 0, 2, 1], [4, 20, 20, 16, 4, 12, 1, 0, 2, 1], [4, 20, 20, 16, 6, 8, 1, 0, 2, 1], [4, 20, 20, 17, 4, 8, 1, 0, 1, 2], [4, 20, 20, 17, 6, 8, 1, 0, 2, 1], [4, 20, 20, 18, 4, 12, 1, 0, 2, 1], [4, 20, 24, 20, 3, 14, 0, 1, 2, 1], [4, 20, 24, 20, 6, 7, 0, 1, 1, 2], [4, 20, 25, 10, 8, 12, 0, 2, 1, 1], [4, 20, 30, 10, 8, 12, 0, 2, 1, 1], [4, 20, 30, 20, 6, 7, 0, 1, 1, 2], [4, 21, 15, 6, 8, 13, 1, 1, 1, 1], [4, 21, 15, 6, 10, 11, 1, 1, 1, 1], [4, 21, 16, 5, 9, 12, 1, 1, 1, 1], [4, 22, 12, 10, 3, 11, 1, 1, 0, 2], [4, 22, 12, 10, 5, 11, 1, 1, 0, 2], [4, 22, 12, 10, 7, 11, 1, 1, 0, 2], [4, 22, 12, 10, 8, 11, 1, 1, 0, 2], [4, 22, 14, 8, 6, 11, 1, 1, 0, 2], [4, 22, 15, 7, 6, 11, 1, 1, 0, 2], [4, 22, 15, 7, 8, 11, 1, 1, 0, 2], [4, 22, 16, 6, 5, 11, 1, 1, 0, 2], [4, 22, 16, 6, 7, 11, 1, 1, 0, 2], [4, 22, 16, 6, 7, 15, 1, 1, 1, 1], [4, 22, 16, 6, 9, 11, 1, 1, 0, 2], [4, 22, 16, 6, 10, 11, 1, 1, 0, 2], [4, 22, 16, 6, 11, 12, 1, 1, 2, 0], [4, 22, 17, 5, 6, 11, 1, 1, 0, 2], [4, 22, 17, 5, 11, 16, 1, 1, 2, 0], [4, 22, 17, 11, 7, 15, 0, 2, 1, 1], [4, 22, 18, 4, 5, 11, 1, 1, 0, 2], [4, 22, 20, 11, 8, 14, 0, 2, 1, 1], [4, 22, 20, 11, 10, 12, 0, 2, 1, 1], [4, 22, 24, 11, 10, 12, 0, 2, 1, 1], [4, 23, 15, 8, 9, 14, 1, 1, 1, 1], [4, 23, 15, 8, 11, 12, 1, 1, 1, 1], [4, 23, 16, 7, 11, 12, 1, 1, 1, 1], [4, 23, 18, 5, 10, 13, 1, 1, 1, 1], [4, 24, 13, 11, 4, 12, 1, 1, 0, 2], [4, 24, 13, 11, 5, 12, 1, 1, 0, 2], [4, 24, 13, 11, 9, 12, 1, 1, 0, 2], [4, 24, 14, 10, 4, 12, 1, 1, 0, 2], [4, 24, 14, 10, 5, 12, 1, 1, 0, 2], [4, 24, 14, 10, 11, 12, 1, 1, 0, 2], [4, 24, 15, 9, 4, 12, 1, 1, 0, 2], [4, 24, 15, 9, 10, 12, 1, 1, 0, 2], [4, 24, 15, 9, 10, 14, 1, 1, 1, 1], [4, 24, 15, 9, 12, 13, 1, 1, 2, 0], [4, 24, 15, 9, 12, 14, 1, 1, 2, 0], [4, 24, 15, 12, 11, 13, 0, 2, 1, 1], [4, 24, 16, 8, 5, 12, 1, 1, 0, 2], [4, 24, 16, 8, 6, 12, 1, 1, 0, 2], [4, 24, 16, 8, 7, 12, 1, 1, 0, 2], [4, 24, 16, 8, 9, 12, 1, 1, 0, 2], [4, 24, 16, 8, 9, 15, 1, 1, 1, 1], [4, 24, 16, 8, 10, 12, 1, 1, 0, 2], [4, 24, 16, 8, 11, 12, 1, 1, 0, 2], [4, 24, 16, 8, 12, 13, 1, 1, 2, 0], [4, 24, 16, 8, 12, 15, 1, 1, 2, 0], [4, 24, 16, 12, 9, 15, 0, 2, 1, 1], [4, 24, 17, 7, 3, 12, 1, 1, 0, 2], [4, 24, 17, 7, 8, 12, 1, 1, 0, 2], [4, 24, 17, 7, 12, 16, 1, 1, 2, 0], [4, 24, 20, 4, 6, 18, 1, 1, 1, 1], [4, 24, 20, 4, 10, 14, 1, 1, 1, 1], [4, 24, 20, 12, 11, 13, 0, 2, 1, 1], [4, 24, 24, 3, 8, 12, 1, 0, 3, 0], [4, 24, 24, 4, 6, 9, 1, 0, 1, 2], [4, 24, 24, 4, 7, 10, 1, 0, 2, 1], [4, 24, 24, 4, 8, 15, 1, 0, 3, 0], [4, 24, 24, 5, 4, 10, 1, 0, 1, 2], [4, 24, 24, 5, 7, 8, 1, 0, 0, 3], [4, 24, 24, 6, 4, 16, 1, 0, 2, 1], [4, 24, 24, 6, 7, 10, 1, 0, 2, 1], [4, 24, 24, 8, 4, 10, 1, 0, 1, 2], [4, 24, 24, 8, 7, 10, 1, 0, 2, 1], [4, 24, 24, 9, 4, 8, 1, 0, 0, 3], [4, 24, 24, 9, 4, 10, 1, 0, 1, 2], [4, 24, 24, 9, 7, 10, 1, 0, 2, 1], [4, 24, 24, 10, 3, 8, 1, 0, 0, 3], [4, 24, 24, 10, 5, 14, 1, 0, 2, 1], [4, 24, 24, 11, 6, 9, 1, 0, 1, 2], [4, 24, 24, 12, 3, 8, 1, 0, 0, 3], [4, 24, 24, 12, 7, 10, 1, 0, 2, 1], [4, 24, 24, 13, 4, 16, 1, 0, 2, 1], [4, 24, 24, 14, 7, 10, 1, 0, 2, 1], [4, 24, 24, 15, 4, 10, 1, 0, 1, 2], [4, 24, 24, 15, 7, 10, 1, 0, 2, 1], [4, 24, 24, 16, 7, 10, 1, 0, 2, 1], [4, 24, 24, 17, 4, 10, 1, 0, 1, 2], [4, 24, 24, 20, 4, 10, 1, 0, 1, 2], [4, 24, 25, 24, 4, 10, 0, 1, 1, 2], [4, 25, 16, 9, 11, 14, 1, 1, 1, 1], [4, 25, 17, 8, 10, 15, 1, 1, 1, 1], [4, 25, 25, 3, 4, 17, 1, 0, 2, 1], [4, 25, 25, 4, 8, 9, 1, 0, 2, 1], [4, 25, 25, 5, 3, 11, 1, 0, 1, 2], [4, 25, 25, 5, 4, 17, 1, 0, 2, 1], [4, 25, 25, 5, 6, 13, 1, 0, 2, 1], [4, 25, 25, 5, 7, 9, 1, 0, 1, 2], [4, 25, 25, 5, 7, 11, 1, 0, 2, 1], [4, 25, 25, 8, 3, 11, 1, 0, 1, 2], [4, 25, 25, 8, 6, 13, 1, 0, 2, 1], [4, 25, 25, 10, 3, 11, 1, 0, 1, 2], [4, 25, 25, 10, 7, 9, 1, 0, 1, 2], [4, 25, 25, 10, 8, 9, 1, 0, 2, 1], [4, 25, 25, 12, 3, 11, 1, 0, 1, 2], [4, 25, 25, 12, 6, 13, 1, 0, 2, 1], [4, 25, 25, 15, 7, 11, 1, 0, 2, 1], [4, 25, 25, 16, 3, 11, 1, 0, 1, 2], [4, 25, 25, 16, 7, 11, 1, 0, 2, 1], [4, 25, 25, 16, 8, 9, 1, 0, 2, 1], [4, 25, 25, 17, 7, 9, 1, 0, 1, 2], [4, 25, 30, 25, 7, 9, 0, 1, 1, 2], [4, 26, 16, 10, 3, 13, 1, 1, 0, 2], [4, 26, 16, 10, 8, 13, 1, 1, 0, 2], [4, 26, 16, 10, 11, 15, 1, 1, 1, 1], [4, 26, 16, 10, 12, 13, 1, 1, 0, 2], [4, 26, 17, 9, 10, 13, 1, 1, 0, 2], [4, 26, 18, 8, 4, 13, 1, 1, 0, 2], [4, 26, 18, 8, 5, 13, 1, 1, 0, 2], [4, 26, 18, 8, 7, 13, 1, 1, 0, 2], [4, 26, 18, 8, 13, 15, 1, 1, 2, 0], [4, 26, 20, 6, 3, 13, 1, 1, 0, 2], [4, 26, 20, 6, 4, 13, 1, 1, 0, 2], [4, 26, 25, 13, 6, 20, 0, 2, 1, 1], [4, 27, 20, 7, 10, 17, 1, 1, 1, 1], [4, 27, 20, 7, 11, 16, 1, 1, 1, 1], [4, 28, 16, 12, 8, 14, 1, 1, 0, 2], [4, 28, 17, 11, 12, 14, 1, 1, 0, 2], [4, 28, 17, 14, 12, 16, 0, 2, 1, 1], [4, 28, 18, 10, 8, 14, 1, 1, 0, 2], [4, 28, 18, 10, 12, 14, 1, 1, 0, 2], [4, 28, 18, 10, 13, 14, 1, 1, 0, 2], [4, 28, 20, 8, 5, 14, 1, 1, 0, 2], [4, 28, 20, 8, 10, 14, 1, 1, 0, 2], [4, 28, 20, 8, 10, 18, 1, 1, 1, 1], [4, 28, 20, 8, 12, 14, 1, 1, 0, 2], [4, 28, 20, 8, 14, 15, 1, 1, 2, 0], [4, 28, 20, 8, 14, 18, 1, 1, 2, 0], [4, 28, 24, 4, 10, 18, 1, 1, 1, 1], [4, 28, 24, 4, 14, 17, 1, 1, 2, 0], [4, 28, 24, 14, 12, 16, 0, 2, 1, 1], [4, 28, 25, 3, 10, 14, 1, 1, 0, 2], [4, 28, 25, 14, 10, 18, 0, 2, 1, 1], [4, 28, 30, 14, 11, 17, 0, 2, 1, 1], [4, 29, 17, 12, 13, 16, 1, 1, 1, 1], [4, 29, 25, 4, 14, 15, 1, 1, 1, 1], [4, 30, 16, 14, 11, 15, 1, 1, 0, 2], [4, 30, 16, 14, 12, 15, 1, 1, 0, 2], [4, 30, 17, 13, 8, 15, 1, 1, 0, 2], [4, 30, 18, 12, 10, 15, 1, 1, 0, 2], [4, 30, 20, 10, 13, 17, 1, 1, 1, 1], [4, 30, 24, 6, 4, 15, 1, 1, 0, 2], [4, 30, 24, 6, 13, 15, 1, 1, 0, 2], [4, 30, 25, 5, 12, 18, 1, 1, 1, 1], [4, 30, 30, 4, 3, 10, 1, 0, 0, 3], [4, 30, 30, 4, 10, 11, 1, 0, 3, 0], [4, 30, 30, 5, 9, 12, 1, 0, 2, 1], [4, 30, 30, 8, 9, 12, 1, 0, 2, 1], [4, 30, 30, 10, 3, 24, 1, 0, 2, 1], [4, 30, 30, 10, 4, 13, 1, 0, 1, 2], [4, 30, 30, 10, 7, 16, 1, 0, 2, 1], [4, 30, 30, 10, 8, 11, 1, 0, 1, 2], [4, 30, 30, 10, 8, 14, 1, 0, 2, 1], [4, 30, 30, 10, 9, 12, 1, 0, 2, 1], [4, 30, 30, 12, 8, 11, 1, 0, 1, 2], [4, 30, 30, 12, 10, 13, 1, 0, 3, 0], [4, 30, 30, 12, 10, 16, 1, 0, 3, 0], [4, 30, 30, 15, 3, 24, 1, 0, 2, 1], [4, 30, 30, 16, 4, 13, 1, 0, 1, 2], [4, 30, 30, 16, 10, 12, 1, 0, 3, 0], [4, 30, 30, 17, 10, 12, 1, 0, 3, 0], [4, 30, 30, 18, 8, 14, 1, 0, 2, 1], [4, 30, 30, 24, 4, 13, 1, 0, 1, 2], [4, 30, 30, 25, 7, 16, 1, 0, 2, 1], [4, 30, 30, 25, 8, 11, 1, 0, 1, 2], [4, 32, 17, 15, 10, 16, 1, 1, 0, 2], [4, 32, 17, 15, 12, 16, 1, 1, 0, 2], [4, 32, 18, 14, 8, 16, 1, 1, 0, 2], [4, 32, 20, 12, 9, 16, 1, 1, 0, 2], [4, 32, 20, 12, 10, 16, 1, 1, 0, 2], [4, 32, 20, 16, 15, 17, 0, 2, 1, 1], [4, 32, 25, 7, 5, 16, 1, 1, 0, 2], [4, 32, 25, 7, 15, 16, 1, 1, 0, 2], [4, 33, 25, 8, 13, 20, 1, 1, 1, 1], [4, 34, 18, 16, 8, 17, 1, 1, 0, 2], [4, 34, 24, 10, 6, 17, 1, 1, 0, 2], [4, 34, 30, 4, 6, 17, 1, 1, 0, 2], [4, 34, 30, 4, 8, 17, 1, 1, 0, 2], [4, 34, 30, 4, 17, 24, 1, 1, 2, 0], [4, 35, 20, 15, 17, 18, 1, 1, 1, 1], [4, 36, 20, 16, 9, 18, 1, 1, 0, 2], [4, 36, 25, 11, 6, 18, 1, 1, 0, 2], [4, 36, 25, 11, 8, 18, 1, 1, 0, 2], [4, 38, 30, 8, 18, 20, 1, 1, 1, 1], [4, 40, 24, 16, 5, 20, 1, 1, 0, 2], [4, 40, 24, 16, 6, 20, 1, 1, 0, 2], [4, 40, 24, 16, 15, 20, 1, 1, 0, 2], [5, 9, 8, 3, 4, 5, 0, 3, 1, 1], [5, 9, 13, 3, 4, 5, 0, 3, 1, 1], [5, 9, 14, 3, 4, 5, 0, 3, 1, 1], [5, 9, 15, 3, 4, 5, 0, 3, 1, 1], [5, 12, 7, 5, 3, 6, 1, 1, 2, 1], [5, 12, 8, 4, 5, 7, 0, 3, 1, 1], [5, 12, 9, 3, 4, 8, 1, 1, 3, 0], [5, 12, 9, 4, 5, 7, 0, 3, 1, 1], [5, 12, 9, 6, 4, 8, 0, 2, 3, 0], [5, 12, 10, 4, 5, 6, 0, 3, 0, 2], [5, 12, 10, 4, 5, 7, 0, 3, 1, 1], [5, 12, 10, 6, 4, 5, 0, 2, 3, 0], [5, 12, 11, 6, 4, 10, 0, 2, 3, 0], [5, 12, 12, 4, 6, 11, 0, 3, 2, 0], [5, 12, 13, 6, 4, 12, 0, 2, 3, 0], [5, 12, 14, 6, 4, 10, 0, 2, 3, 0], [5, 12, 15, 4, 5, 6, 0, 3, 0, 2], [5, 12, 15, 6, 4, 5, 0, 2, 3, 0], [5, 12, 15, 6, 4, 12, 0, 2, 3, 0], [5, 12, 17, 4, 6, 11, 0, 3, 2, 0], [5, 12, 17, 6, 4, 11, 0, 2, 3, 0], [5, 12, 18, 4, 5, 6, 0, 3, 0, 2], [5, 12, 20, 4, 6, 18, 0, 3, 2, 0], [5, 12, 20, 6, 4, 10, 0, 2, 3, 0], [5, 12, 25, 4, 6, 8, 0, 3, 2, 0], [5, 12, 25, 6, 4, 12, 0, 2, 3, 0], [5, 13, 8, 5, 3, 7, 1, 1, 2, 1], [5, 13, 13, 10, 3, 4, 1, 0, 3, 1], [5, 13, 18, 13, 3, 4, 0, 1, 3, 1], [5, 13, 20, 13, 3, 4, 0, 1, 3, 1], [5, 14, 10, 4, 3, 8, 1, 1, 2, 1], [5, 14, 13, 7, 3, 8, 0, 2, 2, 1], [5, 14, 14, 6, 3, 5, 1, 0, 3, 1], [5, 14, 14, 8, 3, 4, 1, 0, 2, 2], [5, 14, 14, 8, 3, 5, 1, 0, 3, 1], [5, 14, 14, 9, 3, 4, 1, 0, 2, 2], [5, 14, 14, 10, 3, 4, 1, 0, 2, 2], [5, 14, 14, 10, 3, 5, 1, 0, 3, 1], [5, 14, 14, 11, 3, 4, 1, 0, 2, 2], [5, 14, 14, 11, 3, 5, 1, 0, 3, 1], [5, 14, 15, 7, 4, 6, 0, 2, 2, 1], [5, 14, 17, 14, 3, 4, 0, 1, 2, 2], [5, 14, 18, 7, 3, 8, 0, 2, 2, 1], [5, 14, 20, 14, 3, 4, 0, 1, 2, 2], [5, 14, 24, 7, 3, 8, 0, 2, 2, 1], [5, 14, 25, 7, 3, 8, 0, 2, 2, 1], [5, 14, 30, 14, 3, 4, 0, 1, 2, 2], [5, 14, 30, 14, 3, 5, 0, 1, 3, 1], [5, 15, 9, 5, 7, 8, 0, 3, 1, 1], [5, 15, 9, 6, 3, 5, 1, 1, 0, 3], [5, 15, 9, 6, 5, 7, 1, 1, 3, 0], [5, 15, 10, 5, 4, 7, 1, 1, 2, 1], [5, 15, 10, 5, 6, 9, 0, 3, 1, 1], [5, 15, 10, 5, 7, 8, 0, 3, 1, 1], [5, 15, 11, 4, 5, 8, 1, 1, 3, 0], [5, 15, 11, 4, 5, 10, 1, 1, 3, 0], [5, 15, 11, 5, 6, 9, 0, 3, 1, 1], [5, 15, 12, 3, 5, 7, 1, 1, 3, 0], [5, 15, 12, 3, 5, 10, 1, 1, 3, 0], [5, 15, 12, 3, 5, 11, 1, 1, 3, 0], [5, 15, 15, 5, 3, 12, 0, 3, 1, 1], [5, 15, 15, 5, 4, 11, 0, 3, 1, 1], [5, 15, 15, 7, 3, 6, 1, 0, 3, 1], [5, 15, 15, 8, 3, 4, 1, 0, 1, 3], [5, 15, 15, 8, 3, 6, 1, 0, 3, 1], [5, 15, 15, 9, 3, 4, 1, 0, 1, 3], [5, 15, 15, 10, 3, 4, 1, 0, 1, 3], [5, 15, 15, 10, 3, 6, 1, 0, 3, 1], [5, 15, 15, 11, 3, 4, 1, 0, 1, 3], [5, 15, 15, 11, 3, 6, 1, 0, 3, 1], [5, 15, 16, 5, 3, 12, 0, 3, 1, 1], [5, 15, 17, 15, 3, 4, 0, 1, 1, 3], [5, 15, 20, 5, 3, 12, 0, 3, 1, 1], [5, 15, 20, 5, 6, 9, 0, 3, 1, 1], [5, 15, 20, 5, 7, 8, 0, 3, 1, 1], [5, 15, 20, 15, 3, 4, 0, 1, 1, 3], [5, 15, 20, 15, 3, 6, 0, 1, 3, 1], [5, 15, 30, 15, 3, 4, 0, 1, 1, 3], [5, 16, 8, 3, 4, 6, 2, 0, 1, 2], [5, 16, 8, 3, 5, 6, 2, 0, 2, 1], [5, 16, 9, 7, 4, 8, 1, 1, 2, 1], [5, 16, 10, 3, 7, 8, 1, 2, 0, 2], [5, 16, 11, 5, 4, 6, 1, 1, 1, 2], [5, 16, 11, 8, 3, 10, 0, 2, 2, 1], [5, 16, 11, 8, 4, 6, 0, 2, 1, 2], [5, 16, 12, 8, 4, 6, 0, 2, 1, 2], [5, 16, 12, 8, 5, 6, 0, 2, 2, 1], [5, 16, 13, 8, 4, 6, 0, 2, 1, 2], [5, 16, 14, 8, 5, 6, 0, 2, 2, 1], [5, 16, 16, 4, 3, 5, 1, 0, 2, 2], [5, 16, 16, 6, 3, 5, 1, 0, 2, 2], [5, 16, 16, 6, 3, 7, 1, 0, 3, 1], [5, 16, 16, 8, 3, 5, 1, 0, 2, 2], [5, 16, 16, 8, 3, 7, 1, 0, 3, 1], [5, 16, 16, 8, 3, 10, 0, 2, 2, 1], [5, 16, 16, 9, 3, 7, 1, 0, 3, 1], [5, 16, 18, 16, 3, 7, 0, 1, 3, 1], [5, 16, 25, 8, 4, 6, 0, 2, 1, 2], [5, 16, 25, 16, 3, 5, 0, 1, 2, 2], [5, 16, 30, 8, 4, 6, 0, 2, 1, 2], [5, 16, 30, 16, 3, 5, 0, 1, 2, 2], [5, 17, 9, 8, 3, 7, 1, 1, 1, 2], [5, 17, 9, 8, 5, 7, 1, 1, 2, 1], [5, 17, 12, 5, 4, 9, 1, 1, 2, 1], [5, 17, 14, 3, 4, 9, 1, 1, 2, 1], [5, 17, 17, 4, 3, 8, 1, 0, 3, 1], [5, 17, 17, 5, 3, 8, 1, 0, 3, 1], [5, 17, 17, 9, 3, 8, 1, 0, 3, 1], [5, 17, 17, 9, 4, 5, 1, 0, 3, 1], [5, 17, 17, 10, 4, 5, 1, 0, 3, 1], [5, 17, 17, 11, 3, 8, 1, 0, 3, 1], [5, 17, 17, 12, 4, 5, 1, 0, 3, 1], [5, 17, 17, 14, 4, 5, 1, 0, 3, 1], [5, 17, 17, 15, 4, 5, 1, 0, 3, 1], [5, 17, 17, 16, 3, 8, 1, 0, 3, 1], [5, 17, 24, 17, 4, 5, 0, 1, 3, 1], [5, 17, 30, 17, 4, 5, 0, 1, 3, 1], [5, 18, 9, 3, 6, 8, 2, 0, 3, 0], [5, 18, 9, 4, 5, 8, 2, 0, 2, 1], [5, 18, 9, 5, 6, 8, 2, 0, 3, 0], [5, 18, 9, 7, 5, 8, 2, 0, 2, 1], [5, 18, 10, 6, 8, 9, 0, 3, 0, 2], [5, 18, 10, 8, 3, 6, 1, 1, 0, 3], [5, 18, 10, 8, 4, 7, 1, 1, 1, 2], [5, 18, 10, 8, 6, 9, 1, 1, 3, 0], [5, 18, 11, 6, 8, 10, 0, 3, 1, 1], [5, 18, 11, 7, 4, 10, 1, 1, 2, 1], [5, 18, 11, 7, 5, 6, 1, 1, 0, 3], [5, 18, 11, 9, 5, 8, 0, 2, 2, 1], [5, 18, 12, 6, 5, 9, 0, 3, 0, 2], [5, 18, 13, 5, 4, 6, 1, 1, 0, 3], [5, 18, 13, 5, 6, 8, 1, 1, 3, 0], [5, 18, 13, 5, 6, 12, 1, 1, 3, 0], [5, 18, 14, 6, 9, 12, 0, 3, 2, 0], [5, 18, 14, 9, 4, 10, 0, 2, 2, 1], [5, 18, 15, 3, 5, 8, 1, 1, 2, 1], [5, 18, 15, 6, 5, 9, 0, 3, 0, 2], [5, 18, 15, 6, 8, 9, 0, 3, 0, 2], [5, 18, 16, 6, 8, 10, 0, 3, 1, 1], [5, 18, 16, 6, 9, 12, 0, 3, 2, 0], [5, 18, 16, 9, 5, 8, 0, 2, 2, 1], [5, 18, 17, 6, 8, 10, 0, 3, 1, 1], [5, 18, 18, 5, 3, 6, 1, 0, 2, 2], [5, 18, 18, 7, 3, 6, 1, 0, 2, 2], [5, 18, 18, 8, 3, 6, 1, 0, 2, 2], [5, 18, 18, 8, 4, 5, 1, 0, 2, 2], [5, 18, 18, 9, 3, 5, 1, 0, 1, 3], [5, 18, 18, 9, 6, 17, 0, 2, 3, 0], [5, 18, 18, 10, 4, 5, 1, 0, 2, 2], [5, 18, 18, 10, 4, 6, 1, 0, 3, 1], [5, 18, 18, 11, 3, 5, 1, 0, 1, 3], [5, 18, 18, 11, 3, 6, 1, 0, 2, 2], [5, 18, 18, 11, 3, 9, 1, 0, 3, 1], [5, 18, 18, 11, 4, 5, 1, 0, 2, 2], [5, 18, 18, 11, 4, 6, 1, 0, 3, 1], [5, 18, 18, 12, 4, 5, 1, 0, 2, 2], [5, 18, 18, 14, 4, 6, 1, 0, 3, 1], [5, 18, 18, 15, 3, 5, 1, 0, 1, 3], [5, 18, 18, 15, 4, 5, 1, 0, 2, 2], [5, 18, 18, 15, 4, 6, 1, 0, 3, 1], [5, 18, 18, 17, 3, 6, 1, 0, 2, 2], [5, 18, 18, 17, 4, 6, 1, 0, 3, 1], [5, 18, 20, 18, 3, 6, 0, 1, 2, 2], [5, 18, 24, 18, 3, 5, 0, 1, 1, 3], [5, 18, 25, 6, 8, 10, 0, 3, 1, 1], [5, 18, 25, 18, 3, 9, 0, 1, 3, 1], [5, 18, 25, 18, 4, 5, 0, 1, 2, 2], [5, 18, 30, 6, 8, 10, 0, 3, 1, 1], [5, 18, 30, 6, 9, 10, 0, 3, 2, 0], [5, 18, 30, 6, 9, 15, 0, 3, 2, 0], [5, 18, 30, 9, 4, 10, 0, 2, 2, 1], [5, 18, 30, 18, 4, 5, 0, 1, 2, 2], [5, 19, 10, 9, 3, 8, 1, 1, 1, 2], [5, 19, 10, 9, 5, 7, 1, 1, 1, 2], [5, 19, 11, 8, 5, 9, 1, 1, 2, 1], [5, 19, 15, 4, 3, 8, 1, 1, 1, 2], [5, 19, 15, 4, 3, 13, 1, 1, 2, 1], [5, 20, 10, 3, 6, 7, 2, 0, 1, 2], [5, 20, 10, 5, 4, 8, 2, 0, 1, 2], [5, 20, 10, 5, 6, 7, 2, 0, 1, 2], [5, 20, 10, 5, 6, 8, 2, 0, 2, 1], [5, 20, 10, 7, 4, 8, 2, 0, 1, 2], [5, 20, 10, 7, 6, 8, 2, 0, 2, 1], [5, 20, 11, 10, 4, 8, 0, 2, 1, 2], [5, 20, 12, 4, 9, 10, 1, 2, 0, 2], [5, 20, 12, 8, 5, 10, 1, 1, 2, 1], [5, 20, 12, 8, 6, 7, 1, 1, 1, 2], [5, 20, 14, 3, 10, 11, 1, 2, 2, 0], [5, 20, 15, 5, 4, 8, 1, 1, 1, 2], [5, 20, 15, 5, 6, 7, 1, 1, 1, 2], [5, 20, 15, 10, 4, 8, 0, 2, 1, 2], [5, 20, 15, 10, 4, 12, 0, 2, 2, 1], [5, 20, 15, 10, 6, 7, 0, 2, 1, 2], [5, 20, 15, 10, 6, 8, 0, 2, 2, 1], [5, 20, 16, 10, 6, 8, 0, 2, 2, 1], [5, 20, 17, 10, 4, 12, 0, 2, 2, 1], [5, 20, 18, 10, 3, 14, 0, 2, 2, 1], [5, 20, 20, 3, 4, 8, 1, 0, 3, 1], [5, 20, 20, 4, 3, 11, 1, 0, 3, 1], [5, 20, 20, 5, 4, 6, 1, 0, 2, 2], [5, 20, 20, 5, 4, 8, 1, 0, 3, 1], [5, 20, 20, 6, 3, 7, 1, 0, 2, 2], [5, 20, 20, 7, 4, 8, 1, 0, 3, 1], [5, 20, 20, 8, 3, 7, 1, 0, 2, 2], [5, 20, 20, 8, 3, 11, 1, 0, 3, 1], [5, 20, 20, 9, 3, 11, 1, 0, 3, 1], [5, 20, 20, 9, 4, 8, 1, 0, 3, 1], [5, 20, 20, 10, 3, 7, 1, 0, 2, 2], [5, 20, 20, 10, 3, 11, 1, 0, 3, 1], [5, 20, 20, 10, 4, 6, 1, 0, 2, 2], [5, 20, 20, 10, 4, 12, 0, 2, 2, 1], [5, 20, 20, 10, 6, 8, 0, 2, 2, 1], [5, 20, 20, 11, 3, 7, 1, 0, 2, 2], [5, 20, 20, 11, 4, 6, 1, 0, 2, 2], [5, 20, 20, 11, 4, 8, 1, 0, 3, 1], [5, 20, 20, 12, 4, 6, 1, 0, 2, 2], [5, 20, 20, 13, 3, 7, 1, 0, 2, 2], [5, 20, 20, 13, 4, 6, 1, 0, 2, 2], [5, 20, 20, 14, 3, 7, 1, 0, 2, 2], [5, 20, 20, 15, 3, 11, 1, 0, 3, 1], [5, 20, 20, 15, 4, 6, 1, 0, 2, 2], [5, 20, 20, 15, 4, 8, 1, 0, 3, 1], [5, 20, 20, 17, 4, 6, 1, 0, 2, 2], [5, 20, 20, 17, 4, 8, 1, 0, 3, 1], [5, 20, 20, 18, 3, 11, 1, 0, 3, 1], [5, 20, 20, 18, 4, 8, 1, 0, 3, 1], [5, 20, 24, 20, 3, 11, 0, 1, 3, 1], [5, 20, 25, 20, 4, 8, 0, 1, 3, 1], [5, 20, 30, 10, 4, 12, 0, 2, 2, 1], [5, 20, 30, 10, 6, 7, 0, 2, 1, 2], [5, 20, 30, 20, 4, 6, 0, 1, 2, 2], [5, 21, 11, 10, 3, 9, 1, 1, 1, 2], [5, 21, 11, 10, 4, 7, 1, 1, 0, 3], [5, 21, 11, 10, 5, 7, 1, 1, 0, 3], [5, 21, 11, 10, 5, 8, 1, 1, 1, 2], [5, 21, 12, 7, 10, 11, 0, 3, 1, 1], [5, 21, 12, 9, 5, 7, 1, 1, 0, 3], [5, 21, 13, 8, 5, 7, 1, 1, 0, 3], [5, 21, 13, 8, 7, 9, 1, 1, 3, 0], [5, 21, 13, 8, 7, 10, 1, 1, 3, 0], [5, 21, 14, 7, 5, 8, 1, 1, 1, 2], [5, 21, 14, 7, 9, 12, 0, 3, 1, 1], [5, 21, 15, 6, 7, 8, 1, 1, 3, 0], [5, 21, 16, 5, 7, 10, 1, 1, 3, 0], [5, 21, 16, 5, 7, 12, 1, 1, 3, 0], [5, 21, 16, 5, 7, 15, 1, 1, 3, 0], [5, 21, 16, 7, 8, 13, 0, 3, 1, 1], [5, 21, 17, 4, 3, 15, 1, 1, 2, 1], [5, 21, 17, 7, 5, 16, 0, 3, 1, 1], [5, 21, 18, 3, 6, 9, 1, 1, 2, 1], [5, 21, 18, 3, 7, 9, 1, 1, 3, 0], [5, 21, 18, 7, 10, 11, 0, 3, 1, 1], [5, 21, 25, 7, 5, 16, 0, 3, 1, 1], [5, 22, 11, 4, 7, 8, 2, 0, 2, 1], [5, 22, 11, 6, 7, 8, 2, 0, 2, 1], [5, 22, 11, 7, 4, 9, 2, 0, 1, 2], [5, 22, 11, 8, 4, 9, 2, 0, 1, 2], [5, 22, 12, 10, 4, 9, 1, 1, 1, 2], [5, 22, 14, 4, 10, 12, 1, 2, 1, 1], [5, 22, 14, 8, 6, 10, 1, 1, 2, 1], [5, 22, 15, 7, 6, 8, 1, 1, 1, 2], [5, 22, 16, 3, 9, 13, 1, 2, 1, 1], [5, 22, 16, 11, 6, 8, 0, 2, 1, 2], [5, 22, 17, 11, 6, 10, 0, 2, 2, 1], [5, 22, 18, 4, 7, 8, 1, 1, 2, 1], [5, 22, 18, 11, 6, 8, 0, 2, 1, 2], [5, 22, 20, 11, 6, 10, 0, 2, 2, 1], [5, 23, 13, 10, 6, 11, 1, 1, 2, 1], [5, 23, 13, 10, 7, 9, 1, 1, 2, 1], [5, 23, 14, 9, 3, 10, 1, 1, 1, 2], [5, 23, 15, 4, 9, 14, 1, 2, 1, 1], [5, 23, 15, 8, 5, 9, 1, 1, 1, 2], [5, 23, 15, 8, 5, 13, 1, 1, 2, 1], [5, 23, 16, 7, 3, 10, 1, 1, 1, 2], [5, 23, 18, 5, 3, 17, 1, 1, 2, 1], [5, 23, 20, 3, 4, 15, 1, 1, 2, 1], [5, 23, 20, 3, 6, 11, 1, 1, 2, 1], [5, 23, 20, 3, 7, 8, 1, 1, 1, 2], [5, 24, 12, 3, 4, 8, 2, 0, 0, 3], [5, 24, 12, 3, 4, 10, 2, 0, 1, 2], [5, 24, 12, 3, 7, 10, 2, 0, 2, 1], [5, 24, 12, 5, 4, 8, 2, 0, 0, 3], [5, 24, 12, 5, 4, 10, 2, 0, 1, 2], [5, 24, 12, 5, 6, 8, 2, 0, 0, 3], [5, 24, 12, 5, 7, 10, 2, 0, 2, 1], [5, 24, 12, 5, 8, 10, 2, 0, 3, 0], [5, 24, 12, 7, 6, 9, 2, 0, 1, 2], [5, 24, 12, 7, 8, 9, 2, 0, 3, 0], [5, 24, 12, 7, 8, 10, 2, 0, 3, 0], [5, 24, 12, 8, 4, 10, 2, 0, 1, 2], [5, 24, 12, 8, 7, 10, 2, 0, 2, 1], [5, 24, 12, 10, 6, 9, 2, 0, 1, 2], [5, 24, 12, 11, 8, 10, 2, 0, 3, 0], [5, 24, 13, 8, 4, 12, 0, 3, 0, 2], [5, 24, 13, 11, 4, 10, 1, 1, 1, 2], [5, 24, 13, 11, 5, 8, 1, 1, 0, 3], [5, 24, 13, 11, 6, 12, 1, 1, 2, 1], [5, 24, 14, 10, 3, 8, 1, 1, 0, 3], [5, 24, 15, 8, 3, 12, 0, 3, 0, 2], [5, 24, 15, 9, 4, 8, 1, 1, 0, 3], [5, 24, 15, 9, 7, 8, 1, 1, 0, 3], [5, 24, 15, 12, 4, 8, 0, 2, 0, 3], [5, 24, 15, 12, 6, 8, 0, 2, 0, 3], [5, 24, 16, 4, 7, 12, 1, 2, 0, 2], [5, 24, 16, 4, 12, 15, 1, 2, 2, 0], [5, 24, 16, 8, 3, 12, 0, 3, 0, 2], [5, 24, 16, 8, 5, 14, 1, 1, 2, 1], [5, 24, 16, 8, 6, 9, 1, 1, 1, 2], [5, 24, 16, 8, 7, 10, 1, 1, 2, 1], [5, 24, 16, 8, 10, 14, 0, 3, 1, 1], [5, 24, 16, 12, 8, 15, 0, 2, 3, 0], [5, 24, 17, 7, 5, 8, 1, 1, 0, 3], [5, 24, 17, 7, 6, 8, 1, 1, 0, 3], [5, 24, 17, 7, 8, 11, 1, 1, 3, 0], [5, 24, 17, 8, 5, 12, 0, 3, 0, 2], [5, 24, 17, 8, 11, 13, 0, 3, 1, 1], [5, 24, 18, 6, 8, 16, 1, 1, 3, 0], [5, 24, 18, 8, 11, 13, 0, 3, 1, 1], [5, 24, 20, 4, 3, 8, 1, 1, 0, 3], [5, 24, 20, 4, 7, 10, 1, 1, 2, 1], [5, 24, 20, 4, 8, 9, 1, 1, 3, 0], [5, 24, 20, 4, 8, 10, 1, 1, 3, 0], [5, 24, 20, 4, 8, 11, 1, 1, 3, 0], [5, 24, 20, 4, 8, 12, 1, 1, 3, 0], [5, 24, 20, 4, 8, 13, 1, 1, 3, 0], [5, 24, 20, 8, 6, 12, 0, 3, 0, 2], [5, 24, 20, 8, 10, 14, 0, 3, 1, 1], [5, 24, 20, 8, 11, 12, 0, 3, 0, 2], [5, 24, 20, 12, 8, 17, 0, 2, 3, 0], [5, 24, 24, 3, 4, 8, 1, 0, 2, 2], [5, 24, 24, 3, 5, 7, 1, 0, 2, 2], [5, 24, 24, 4, 5, 9, 1, 0, 3, 1], [5, 24, 24, 5, 3, 9, 1, 0, 2, 2], [5, 24, 24, 5, 4, 8, 1, 0, 2, 2], [5, 24, 24, 5, 4, 12, 1, 0, 3, 1], [5, 24, 24, 6, 5, 7, 1, 0, 2, 2], [5, 24, 24, 7, 3, 9, 1, 0, 2, 2], [5, 24, 24, 7, 4, 8, 1, 0, 2, 2], [5, 24, 24, 7, 4, 12, 1, 0, 3, 1], [5, 24, 24, 8, 3, 7, 1, 0, 1, 3], [5, 24, 24, 8, 5, 7, 1, 0, 2, 2], [5, 24, 24, 9, 4, 8, 1, 0, 2, 2], [5, 24, 24, 10, 3, 7, 1, 0, 1, 3], [5, 24, 24, 10, 5, 7, 1, 0, 2, 2], [5, 24, 24, 11, 3, 9, 1, 0, 2, 2], [5, 24, 24, 11, 4, 8, 1, 0, 2, 2], [5, 24, 24, 11, 4, 12, 1, 0, 3, 1], [5, 24, 24, 11, 5, 9, 1, 0, 3, 1], [5, 24, 24, 12, 7, 8, 0, 2, 0, 3], [5, 24, 24, 14, 3, 9, 1, 0, 2, 2], [5, 24, 24, 15, 4, 8, 1, 0, 2, 2], [5, 24, 24, 15, 5, 7, 1, 0, 2, 2], [5, 24, 24, 16, 5, 9, 1, 0, 3, 1], [5, 24, 24, 18, 3, 15, 1, 0, 3, 1], [5, 24, 24, 18, 4, 8, 1, 0, 2, 2], [5, 24, 24, 18, 5, 7, 1, 0, 2, 2], [5, 24, 24, 20, 4, 12, 1, 0, 3, 1], [5, 24, 25, 8, 4, 20, 0, 3, 1, 1], [5, 24, 25, 8, 10, 12, 0, 3, 0, 2], [5, 24, 25, 24, 3, 7, 0, 1, 1, 3], [5, 24, 25, 24, 4, 8, 0, 1, 2, 2], [5, 24, 30, 8, 10, 12, 0, 3, 0, 2], [5, 24, 30, 12, 8, 9, 0, 2, 3, 0], [5, 24, 30, 12, 8, 10, 0, 2, 3, 0], [5, 25, 13, 12, 5, 10, 1, 1, 1, 2], [5, 25, 15, 10, 7, 9, 1, 1, 1, 2], [5, 25, 15, 10, 7, 11, 1, 1, 2, 1], [5, 25, 16, 9, 5, 15, 1, 1, 2, 1], [5, 25, 17, 4, 10, 15, 1, 2, 1, 1], [5, 25, 17, 8, 6, 13, 1, 1, 2, 1], [5, 25, 17, 8, 7, 11, 1, 1, 2, 1], [5, 25, 20, 5, 8, 9, 1, 1, 2, 1], [5, 25, 25, 3, 4, 7, 1, 0, 1, 3], [5, 25, 25, 3, 4, 13, 1, 0, 3, 1], [5, 25, 25, 5, 4, 7, 1, 0, 1, 3], [5, 25, 25, 6, 3, 16, 1, 0, 3, 1], [5, 25, 25, 8, 4, 13, 1, 0, 3, 1], [5, 25, 25, 10, 4, 7, 1, 0, 1, 3], [5, 25, 25, 11, 4, 13, 1, 0, 3, 1], [5, 25, 25, 13, 6, 7, 1, 0, 3, 1], [5, 25, 25, 14, 3, 16, 1, 0, 3, 1], [5, 25, 25, 17, 4, 7, 1, 0, 1, 3], [5, 25, 25, 24, 4, 7, 1, 0, 1, 3], [5, 25, 30, 25, 4, 7, 0, 1, 1, 3], [5, 26, 13, 4, 8, 10, 2, 0, 2, 1], [5, 26, 15, 11, 7, 12, 1, 1, 2, 1], [5, 26, 16, 5, 12, 14, 1, 2, 1, 1], [5, 26, 16, 10, 8, 9, 1, 1, 1, 2], [5, 26, 18, 8, 6, 10, 1, 1, 1, 2], [5, 26, 20, 3, 10, 16, 1, 2, 1, 1], [5, 26, 20, 3, 11, 15, 1, 2, 1, 1], [5, 26, 20, 6, 7, 12, 1, 1, 2, 1], [5, 26, 24, 13, 8, 10, 0, 2, 2, 1], [5, 27, 14, 13, 5, 9, 1, 1, 0, 3], [5, 27, 15, 12, 7, 9, 1, 1, 0, 3], [5, 27, 16, 9, 12, 15, 0, 3, 1, 1], [5, 27, 16, 11, 6, 9, 1, 1, 0, 3], [5, 27, 16, 11, 6, 15, 1, 1, 2, 1], [5, 27, 16, 11, 7, 9, 1, 1, 0, 3], [5, 27, 16, 11, 9, 10, 1, 1, 3, 0], [5, 27, 16, 11, 9, 13, 1, 1, 3, 0], [5, 27, 17, 5, 12, 15, 1, 2, 1, 1], [5, 27, 17, 10, 5, 9, 1, 1, 0, 3], [5, 27, 17, 10, 5, 11, 1, 1, 1, 2], [5, 27, 17, 10, 8, 11, 1, 1, 2, 1], [5, 27, 20, 7, 8, 11, 1, 1, 2, 1], [5, 27, 20, 7, 9, 10, 1, 1, 3, 0], [5, 27, 20, 9, 11, 16, 0, 3, 1, 1], [5, 27, 20, 9, 12, 15, 0, 3, 1, 1], [5, 27, 24, 3, 4, 9, 1, 1, 0, 3], [5, 27, 24, 3, 8, 11, 1, 1, 2, 1], [5, 28, 14, 5, 8, 10, 2, 0, 1, 2], [5, 28, 15, 14, 4, 12, 0, 2, 1, 2], [5, 28, 15, 14, 8, 12, 0, 2, 2, 1], [5, 28, 16, 6, 14, 15, 1, 2, 2, 0], [5, 28, 17, 14, 8, 12, 0, 2, 2, 1], [5, 28, 18, 5, 3, 14, 1, 2, 0, 2], [5, 28, 18, 5, 7, 14, 1, 2, 0, 2], [5, 28, 18, 10, 6, 11, 1, 1, 1, 2], [5, 28, 18, 10, 6, 16, 1, 1, 2, 1], [5, 28, 20, 4, 10, 14, 1, 2, 0, 2], [5, 28, 20, 8, 6, 16, 1, 1, 2, 1], [5, 28, 20, 8, 9, 10, 1, 1, 2, 1], [5, 28, 24, 4, 8, 12, 1, 1, 2, 1], [5, 29, 18, 11, 9, 10, 1, 1, 1, 2], [5, 29, 20, 9, 7, 15, 1, 1, 2, 1], [5, 29, 25, 4, 5, 12, 1, 1, 1, 2], [5, 29, 25, 4, 7, 15, 1, 1, 2, 1], [5, 29, 25, 4, 9, 10, 1, 1, 1, 2], [5, 30, 15, 4, 8, 10, 2, 0, 0, 3], [5, 30, 15, 4, 10, 12, 2, 0, 3, 0], [5, 30, 15, 6, 8, 14, 2, 0, 2, 1], [5, 30, 15, 8, 4, 13, 2, 0, 1, 2], [5, 30, 15, 8, 10, 11, 2, 0, 3, 0], [5, 30, 15, 10, 6, 12, 2, 0, 1, 2], [5, 30, 15, 11, 7, 10, 2, 0, 0, 3], [5, 30, 15, 12, 4, 13, 2, 0, 1, 2], [5, 30, 15, 12, 10, 11, 2, 0, 3, 0], [5, 30, 15, 13, 7, 10, 2, 0, 0, 3], [5, 30, 16, 14, 8, 11, 1, 1, 1, 2], [5, 30, 16, 15, 8, 11, 0, 2, 1, 2], [5, 30, 18, 10, 14, 16, 0, 3, 1, 1], [5, 30, 18, 12, 4, 13, 1, 1, 1, 2], [5, 30, 18, 12, 10, 14, 1, 1, 3, 0], [5, 30, 18, 12, 10, 15, 1, 1, 3, 0], [5, 30, 18, 12, 10, 17, 1, 1, 3, 0], [5, 30, 18, 15, 7, 10, 0, 2, 0, 3], [5, 30, 18, 15, 9, 10, 0, 2, 0, 3], [5, 30, 20, 10, 6, 12, 1, 1, 1, 2], [5, 30, 20, 10, 6, 18, 1, 1, 2, 1], [5, 30, 20, 10, 12, 18, 0, 3, 1, 1], [5, 30, 20, 15, 8, 11, 0, 2, 1, 2], [5, 30, 24, 3, 10, 15, 1, 2, 0, 2], [5, 30, 24, 6, 5, 10, 1, 1, 0, 3], [5, 30, 24, 6, 10, 11, 1, 1, 3, 0], [5, 30, 24, 6, 10, 17, 1, 1, 3, 0], [5, 30, 24, 10, 7, 15, 0, 3, 0, 2], [5, 30, 24, 15, 9, 12, 0, 2, 2, 1], [5, 30, 25, 5, 9, 12, 1, 1, 2, 1], [5, 30, 25, 15, 9, 12, 0, 2, 2, 1], [5, 30, 30, 4, 3, 12, 1, 0, 2, 2], [5, 30, 30, 4, 7, 8, 1, 0, 2, 2], [5, 30, 30, 5, 6, 8, 1, 0, 1, 3], [5, 30, 30, 5, 7, 9, 1, 0, 3, 1], [5, 30, 30, 6, 7, 8, 1, 0, 2, 2], [5, 30, 30, 7, 3, 12, 1, 0, 2, 2], [5, 30, 30, 7, 6, 9, 1, 0, 2, 2], [5, 30, 30, 8, 3, 9, 1, 0, 1, 3], [5, 30, 30, 8, 6, 9, 1, 0, 2, 2], [5, 30, 30, 9, 7, 8, 1, 0, 2, 2], [5, 30, 30, 10, 3, 9, 1, 0, 1, 3], [5, 30, 30, 10, 3, 12, 1, 0, 2, 2], [5, 30, 30, 10, 7, 8, 1, 0, 2, 2], [5, 30, 30, 11, 3, 9, 1, 0, 1, 3], [5, 30, 30, 11, 3, 12, 1, 0, 2, 2], [5, 30, 30, 11, 4, 18, 1, 0, 3, 1], [5, 30, 30, 12, 4, 11, 1, 0, 2, 2], [5, 30, 30, 12, 7, 9, 1, 0, 3, 1], [5, 30, 30, 13, 3, 9, 1, 0, 1, 3], [5, 30, 30, 13, 3, 12, 1, 0, 2, 2], [5, 30, 30, 13, 7, 8, 1, 0, 2, 2], [5, 30, 30, 14, 6, 9, 1, 0, 2, 2], [5, 30, 30, 15, 3, 12, 1, 0, 2, 2], [5, 30, 30, 15, 4, 11, 1, 0, 2, 2], [5, 30, 30, 15, 6, 8, 1, 0, 1, 3], [5, 30, 30, 15, 6, 9, 1, 0, 2, 2], [5, 30, 30, 15, 7, 8, 1, 0, 2, 2], [5, 30, 30, 15, 7, 9, 1, 0, 3, 1], [5, 30, 30, 15, 9, 12, 0, 2, 2, 1], [5, 30, 30, 16, 3, 12, 1, 0, 2, 2], [5, 30, 30, 16, 7, 8, 1, 0, 2, 2], [5, 30, 30, 17, 4, 11, 1, 0, 2, 2], [5, 30, 30, 17, 6, 8, 1, 0, 1, 3], [5, 30, 30, 18, 4, 11, 1, 0, 2, 2], [5, 30, 30, 18, 7, 9, 1, 0, 3, 1], [5, 30, 30, 20, 3, 9, 1, 0, 1, 3], [5, 30, 30, 20, 3, 12, 1, 0, 2, 2], [5, 30, 30, 20, 4, 11, 1, 0, 2, 2], [5, 30, 30, 20, 6, 8, 1, 0, 1, 3], [5, 30, 30, 24, 4, 11, 1, 0, 2, 2], [5, 30, 30, 25, 4, 11, 1, 0, 2, 2], [5, 31, 16, 15, 9, 11, 1, 1, 1, 2], [5, 31, 17, 14, 10, 11, 1, 1, 2, 1], [5, 31, 18, 13, 8, 15, 1, 1, 2, 1], [5, 31, 20, 11, 8, 15, 1, 1, 2, 1], [5, 32, 16, 8, 10, 11, 2, 0, 1, 2], [5, 32, 16, 9, 8, 12, 2, 0, 1, 2], [5, 32, 16, 9, 10, 11, 2, 0, 1, 2], [5, 32, 16, 9, 10, 12, 2, 0, 2, 1], [5, 32, 16, 10, 8, 12, 2, 0, 1, 2], [5, 32, 16, 12, 10, 11, 2, 0, 1, 2], [5, 32, 16, 15, 8, 12, 2, 0, 1, 2], [5, 32, 17, 15, 8, 12, 1, 1, 1, 2], [5, 32, 17, 15, 8, 16, 1, 1, 2, 1], [5, 32, 17, 16, 8, 12, 0, 2, 1, 2], [5, 32, 20, 6, 16, 18, 1, 2, 2, 0], [5, 32, 20, 12, 6, 13, 1, 1, 1, 2], [5, 32, 20, 12, 10, 11, 1, 1, 1, 2], [5, 32, 24, 8, 7, 18, 1, 1, 2, 1], [5, 32, 25, 7, 8, 16, 1, 1, 2, 1], [5, 32, 25, 16, 8, 12, 0, 2, 1, 2], [5, 33, 18, 15, 9, 11, 1, 1, 0, 3], [5, 33, 20, 13, 3, 15, 1, 1, 1, 2], [5, 33, 24, 9, 10, 13, 1, 1, 2, 1], [5, 33, 24, 9, 11, 12, 1, 1, 3, 0], [5, 33, 25, 8, 3, 11, 1, 1, 0, 3], [5, 33, 25, 8, 9, 11, 1, 1, 0, 3], [5, 33, 25, 8, 10, 11, 1, 1, 0, 3], [5, 33, 25, 8, 11, 16, 1, 1, 3, 0], [5, 33, 25, 8, 11, 24, 1, 1, 3, 0], [5, 33, 25, 11, 13, 20, 0, 3, 1, 1], [5, 33, 30, 3, 6, 11, 1, 1, 0, 3], [5, 33, 30, 3, 11, 15, 1, 1, 3, 0], [5, 34, 17, 5, 4, 15, 2, 0, 1, 2], [5, 34, 17, 5, 10, 12, 2, 0, 1, 2], [5, 34, 17, 6, 10, 12, 2, 0, 1, 2], [5, 34, 17, 12, 6, 14, 2, 0, 1, 2], [5, 34, 24, 10, 7, 20, 1, 1, 2, 1], [5, 34, 30, 4, 5, 24, 1, 1, 2, 1], [5, 34, 30, 4, 11, 12, 1, 1, 2, 1], [5, 34, 30, 17, 11, 12, 0, 2, 2, 1], [5, 35, 25, 10, 11, 12, 1, 1, 1, 2], [5, 35, 30, 5, 11, 12, 1, 1, 1, 2], [5, 36, 18, 3, 6, 15, 2, 0, 1, 2], [5, 36, 18, 3, 8, 14, 2, 0, 1, 2], [5, 36, 18, 4, 7, 12, 2, 0, 0, 3], [5, 36, 18, 5, 10, 12, 2, 0, 0, 3], [5, 36, 18, 14, 12, 16, 2, 0, 3, 0], [5, 36, 18, 16, 6, 15, 2, 0, 1, 2], [5, 36, 20, 16, 8, 14, 1, 1, 1, 2], [5, 36, 20, 16, 9, 18, 1, 1, 2, 1], [5, 36, 20, 16, 10, 13, 1, 1, 1, 2], [5, 36, 24, 12, 11, 14, 1, 1, 2, 1], [5, 36, 24, 18, 10, 13, 0, 2, 1, 2], [5, 36, 25, 11, 3, 12, 1, 1, 0, 3], [5, 36, 25, 11, 4, 12, 1, 1, 0, 3], [5, 36, 25, 11, 8, 20, 1, 1, 2, 1], [5, 36, 25, 11, 9, 12, 1, 1, 0, 3], [5, 36, 25, 11, 12, 14, 1, 1, 3, 0], [5, 36, 25, 11, 12, 15, 1, 1, 3, 0], [5, 36, 30, 6, 8, 14, 1, 1, 1, 2], [5, 36, 30, 6, 10, 13, 1, 1, 1, 2], [5, 37, 30, 7, 9, 14, 1, 1, 1, 2], [5, 37, 30, 7, 11, 15, 1, 1, 2, 1], [5, 38, 25, 13, 9, 20, 1, 1, 2, 1], [5, 38, 25, 13, 11, 16, 1, 1, 2, 1], [5, 38, 30, 8, 4, 17, 1, 1, 1, 2], [5, 38, 30, 8, 6, 16, 1, 1, 1, 2], [5, 39, 24, 15, 12, 13, 1, 1, 0, 3], [5, 39, 25, 14, 13, 16, 1, 1, 3, 0], [5, 40, 20, 3, 8, 16, 2, 0, 1, 2], [5, 40, 20, 5, 8, 16, 2, 0, 1, 2], [5, 40, 20, 5, 12, 14, 2, 0, 1, 2], [5, 40, 20, 9, 12, 16, 2, 0, 2, 1], [5, 40, 20, 10, 4, 18, 2, 0, 1, 2], [5, 40, 20, 10, 8, 16, 2, 0, 1, 2], [5, 40, 20, 10, 12, 16, 2, 0, 2, 1], [5, 40, 20, 13, 6, 17, 2, 0, 1, 2], [5, 40, 20, 13, 8, 16, 2, 0, 1, 2], [5, 40, 20, 14, 8, 16, 2, 0, 1, 2], [5, 40, 20, 16, 13, 14, 2, 0, 2, 1], [5, 40, 24, 16, 10, 15, 1, 1, 1, 2], [5, 40, 25, 15, 12, 16, 1, 1, 2, 1], [5, 40, 30, 5, 16, 24, 1, 2, 1, 1], [5, 40, 30, 10, 12, 14, 1, 1, 1, 2], [5, 40, 30, 20, 12, 14, 0, 2, 1, 2], [5, 41, 25, 16, 13, 15, 1, 1, 2, 1], [5, 42, 24, 18, 3, 14, 1, 1, 0, 3], [5, 42, 25, 17, 10, 16, 1, 1, 1, 2], [5, 42, 30, 12, 4, 14, 1, 1, 0, 3], [5, 42, 30, 12, 10, 14, 1, 1, 0, 3], [5, 42, 30, 12, 10, 16, 1, 1, 1, 2], [5, 42, 30, 12, 13, 16, 1, 1, 2, 1], [5, 44, 30, 14, 12, 16, 1, 1, 1, 2], [5, 48, 24, 7, 8, 20, 2, 0, 1, 2], [5, 48, 24, 7, 10, 16, 2, 0, 0, 3], [5, 48, 24, 11, 12, 16, 2, 0, 0, 3], [5, 48, 25, 16, 12, 24, 0, 3, 0, 2], [5, 50, 25, 3, 16, 18, 2, 0, 2, 1], [5, 60, 30, 6, 7, 20, 2, 0, 0, 3], [5, 60, 30, 14, 9, 20, 2, 0, 0, 3], [6, 12, 9, 3, 4, 8, 0, 4, 1, 1], [6, 12, 11, 3, 4, 8, 0, 4, 1, 1], [6, 12, 13, 4, 3, 6, 0, 3, 2, 1], [6, 12, 20, 3, 5, 7, 0, 4, 1, 1], [6, 13, 7, 3, 4, 5, 1, 2, 2, 1], [6, 14, 9, 5, 3, 4, 1, 1, 2, 2], [6, 14, 12, 7, 3, 5, 0, 2, 3, 1], [6, 14, 20, 7, 3, 5, 0, 2, 3, 1], [6, 15, 8, 7, 3, 6, 1, 1, 3, 1], [6, 15, 10, 5, 3, 9, 0, 3, 2, 1], [6, 15, 10, 5, 4, 7, 0, 3, 2, 1], [6, 15, 12, 5, 4, 7, 0, 3, 2, 1], [6, 15, 15, 5, 4, 7, 0, 3, 2, 1], [6, 15, 16, 5, 3, 9, 0, 3, 2, 1], [6, 15, 20, 5, 3, 6, 0, 3, 1, 2], [6, 16, 9, 7, 4, 8, 1, 1, 4, 0], [6, 16, 10, 4, 7, 9, 0, 4, 1, 1], [6, 16, 11, 5, 3, 4, 1, 1, 0, 4], [6, 16, 11, 5, 4, 8, 1, 1, 4, 0], [6, 16, 12, 4, 3, 5, 1, 1, 2, 2], [6, 16, 12, 4, 5, 11, 0, 4, 1, 1], [6, 16, 13, 8, 3, 7, 0, 2, 3, 1], [6, 16, 14, 4, 5, 11, 0, 4, 1, 1], [6, 16, 15, 4, 6, 10, 0, 4, 1, 1], [6, 16, 16, 5, 3, 4, 1, 0, 4, 1], [6, 16, 16, 9, 3, 4, 1, 0, 4, 1], [6, 16, 16, 10, 3, 4, 1, 0, 4, 1], [6, 16, 16, 12, 3, 4, 1, 0, 4, 1], [6, 16, 17, 4, 6, 10, 0, 4, 1, 1], [6, 16, 18, 8, 3, 7, 0, 2, 3, 1], [6, 16, 24, 16, 3, 4, 0, 1, 4, 1], [6, 16, 25, 4, 6, 10, 0, 4, 1, 1], [6, 17, 9, 4, 5, 6, 1, 2, 1, 2], [6, 17, 9, 4, 5, 7, 1, 2, 2, 1], [6, 17, 11, 6, 4, 5, 1, 1, 3, 1], [6, 17, 12, 5, 3, 8, 1, 1, 3, 1], [6, 17, 17, 4, 3, 5, 1, 0, 4, 1], [6, 17, 17, 5, 3, 4, 1, 0, 3, 2], [6, 17, 17, 9, 3, 4, 1, 0, 3, 2], [6, 17, 17, 10, 3, 4, 1, 0, 3, 2], [6, 17, 17, 11, 3, 4, 1, 0, 3, 2], [6, 17, 17, 12, 3, 4, 1, 0, 3, 2], [6, 17, 17, 13, 3, 4, 1, 0, 3, 2], [6, 17, 17, 13, 3, 5, 1, 0, 4, 1], [6, 17, 17, 14, 3, 4, 1, 0, 3, 2], [6, 17, 17, 16, 3, 5, 1, 0, 4, 1], [6, 17, 18, 17, 3, 5, 0, 1, 4, 1], [6, 17, 30, 17, 3, 4, 0, 1, 3, 2], [6, 17, 30, 17, 3, 5, 0, 1, 4, 1], [6, 18, 9, 4, 3, 5, 2, 0, 1, 3], [6, 18, 10, 8, 3, 6, 1, 1, 2, 2], [6, 18, 10, 8, 3, 9, 1, 1, 3, 1], [6, 18, 12, 3, 4, 7, 1, 2, 1, 2], [6, 18, 12, 3, 5, 8, 1, 2, 2, 1], [6, 18, 12, 6, 4, 5, 1, 1, 2, 2], [6, 18, 13, 5, 4, 6, 1, 1, 3, 1], [6, 18, 13, 9, 3, 5, 0, 2, 1, 3], [6, 18, 14, 9, 3, 5, 0, 2, 1, 3], [6, 18, 15, 3, 4, 5, 1, 1, 2, 2], [6, 18, 15, 6, 4, 7, 0, 3, 1, 2], [6, 18, 15, 6, 4, 10, 0, 3, 2, 1], [6, 18, 15, 6, 5, 8, 0, 3, 2, 1], [6, 18, 16, 9, 4, 6, 0, 2, 3, 1], [6, 18, 18, 5, 3, 4, 1, 0, 2, 3], [6, 18, 18, 6, 4, 7, 0, 3, 1, 2], [6, 18, 18, 7, 3, 6, 1, 0, 4, 1], [6, 18, 18, 9, 3, 4, 1, 0, 2, 3], [6, 18, 18, 9, 3, 5, 0, 2, 1, 3], [6, 18, 18, 9, 4, 6, 0, 2, 3, 1], [6, 18, 18, 10, 3, 4, 1, 0, 2, 3], [6, 18, 18, 10, 3, 6, 1, 0, 4, 1], [6, 18, 18, 12, 3, 4, 1, 0, 2, 3], [6, 18, 18, 13, 3, 6, 1, 0, 4, 1], [6, 18, 20, 18, 3, 6, 0, 1, 4, 1], [6, 18, 25, 6, 4, 10, 0, 3, 2, 1], [6, 18, 25, 9, 4, 6, 0, 2, 3, 1], [6, 18, 25, 18, 3, 4, 0, 1, 2, 3], [6, 18, 30, 6, 4, 10, 0, 3, 2, 1], [6, 18, 30, 9, 3, 5, 0, 2, 1, 3], [6, 18, 30, 18, 3, 4, 0, 1, 2, 3], [6, 19, 10, 9, 4, 7, 1, 1, 3, 1], [6, 19, 11, 4, 6, 7, 1, 2, 2, 1], [6, 19, 12, 7, 4, 5, 1, 1, 1, 3], [6, 19, 13, 6, 4, 5, 1, 1, 1, 3], [6, 19, 16, 3, 4, 5, 1, 1, 1, 3], [6, 19, 16, 3, 4, 7, 1, 1, 3, 1], [6, 20, 8, 4, 6, 7, 2, 1, 1, 2], [6, 20, 10, 5, 6, 8, 1, 2, 2, 1], [6, 20, 10, 9, 4, 8, 2, 0, 3, 1], [6, 20, 11, 3, 8, 10, 1, 3, 0, 2], [6, 20, 11, 9, 4, 8, 1, 1, 3, 1], [6, 20, 11, 9, 5, 8, 1, 1, 4, 0], [6, 20, 12, 8, 5, 10, 1, 1, 4, 0], [6, 20, 12, 8, 5, 11, 1, 1, 4, 0], [6, 20, 13, 5, 8, 12, 0, 4, 1, 1], [6, 20, 13, 7, 4, 6, 1, 1, 2, 2], [6, 20, 13, 7, 5, 10, 1, 1, 4, 0], [6, 20, 14, 3, 4, 12, 1, 2, 2, 1], [6, 20, 14, 3, 5, 10, 1, 2, 2, 1], [6, 20, 15, 5, 4, 8, 1, 1, 3, 1], [6, 20, 15, 5, 8, 12, 0, 4, 1, 1], [6, 20, 15, 5, 9, 11, 0, 4, 1, 1], [6, 20, 15, 10, 4, 8, 0, 2, 3, 1], [6, 20, 16, 4, 5, 6, 1, 1, 4, 0], [6, 20, 16, 4, 5, 10, 1, 1, 4, 0], [6, 20, 17, 3, 5, 8, 1, 1, 4, 0], [6, 20, 17, 10, 4, 8, 0, 2, 3, 1], [6, 20, 18, 5, 4, 16, 0, 4, 1, 1], [6, 20, 20, 5, 3, 8, 1, 0, 4, 1], [6, 20, 20, 9, 3, 8, 1, 0, 4, 1], [6, 20, 20, 10, 3, 8, 1, 0, 4, 1], [6, 20, 20, 10, 3, 11, 0, 2, 3, 1], [6, 20, 20, 17, 3, 8, 1, 0, 4, 1], [6, 20, 25, 5, 6, 14, 0, 4, 1, 1], [6, 20, 25, 5, 8, 12, 0, 4, 1, 1], [6, 20, 30, 5, 8, 12, 0, 4, 1, 1], [6, 20, 30, 5, 9, 11, 0, 4, 1, 1], [6, 21, 9, 7, 5, 8, 0, 3, 1, 2], [6, 21, 11, 10, 4, 9, 1, 1, 3, 1], [6, 21, 12, 3, 10, 11, 1, 3, 1, 1], [6, 21, 12, 7, 5, 8, 0, 3, 1, 2], [6, 21, 13, 8, 3, 12, 1, 1, 3, 1], [6, 21, 14, 7, 5, 11, 0, 3, 2, 1], [6, 21, 15, 3, 4, 13, 1, 2, 2, 1], [6, 21, 15, 3, 5, 8, 1, 2, 1, 2], [6, 21, 15, 7, 4, 13, 0, 3, 2, 1], [6, 21, 16, 5, 3, 12, 1, 1, 3, 1], [6, 21, 16, 7, 3, 15, 0, 3, 2, 1], [6, 21, 17, 4, 3, 12, 1, 1, 3, 1], [6, 21, 20, 7, 5, 11, 0, 3, 2, 1], [6, 21, 24, 7, 3, 9, 0, 3, 1, 2], [6, 21, 25, 7, 3, 9, 0, 3, 1, 2], [6, 22, 10, 6, 7, 8, 1, 2, 2, 1], [6, 22, 11, 6, 5, 7, 2, 0, 3, 1], [6, 22, 11, 7, 4, 10, 2, 0, 3, 1], [6, 22, 11, 9, 4, 10, 2, 0, 3, 1], [6, 22, 12, 5, 4, 9, 1, 2, 1, 2], [6, 22, 12, 10, 3, 8, 1, 1, 2, 2], [6, 22, 12, 10, 4, 7, 1, 1, 2, 2], [6, 22, 12, 11, 4, 10, 0, 2, 3, 1], [6, 22, 13, 3, 10, 11, 1, 3, 0, 2], [6, 22, 13, 3, 10, 12, 1, 3, 1, 1], [6, 22, 13, 9, 3, 8, 1, 1, 2, 2], [6, 22, 13, 9, 5, 6, 1, 1, 2, 2], [6, 22, 15, 7, 4, 6, 1, 1, 1, 3], [6, 22, 15, 11, 4, 6, 0, 2, 1, 3], [6, 22, 15, 11, 4, 10, 0, 2, 3, 1], [6, 22, 16, 3, 4, 9, 1, 2, 1, 2], [6, 22, 16, 3, 5, 12, 1, 2, 2, 1], [6, 22, 16, 11, 4, 6, 0, 2, 1, 3], [6, 22, 16, 11, 4, 10, 0, 2, 3, 1], [6, 22, 17, 11, 4, 6, 0, 2, 1, 3], [6, 22, 18, 4, 5, 6, 1, 1, 2, 2], [6, 22, 18, 4, 5, 7, 1, 1, 3, 1], [6, 22, 18, 11, 4, 6, 0, 2, 1, 3], [6, 22, 20, 11, 5, 7, 0, 2, 3, 1], [6, 22, 24, 11, 4, 10, 0, 2, 3, 1], [6, 22, 25, 11, 4, 10, 0, 2, 3, 1], [6, 23, 9, 5, 7, 8, 2, 1, 1, 2], [6, 23, 10, 3, 7, 8, 2, 1, 1, 2], [6, 23, 10, 3, 7, 9, 2, 1, 2, 1], [6, 23, 12, 11, 5, 8, 1, 1, 3, 1], [6, 23, 13, 5, 7, 8, 1, 2, 1, 2], [6, 23, 14, 3, 10, 13, 1, 3, 1, 1], [6, 23, 15, 4, 5, 9, 1, 2, 1, 2], [6, 23, 15, 8, 5, 6, 1, 1, 1, 3], [6, 23, 20, 3, 5, 8, 1, 1, 3, 1], [6, 24, 12, 4, 5, 9, 2, 0, 3, 1], [6, 24, 12, 6, 7, 8, 1, 2, 0, 3], [6, 24, 12, 6, 8, 9, 1, 2, 3, 0], [6, 24, 12, 8, 7, 10, 0, 3, 2, 1], [6, 24, 13, 8, 6, 12, 0, 3, 2, 1], [6, 24, 13, 8, 7, 10, 0, 3, 2, 1], [6, 24, 13, 11, 4, 12, 1, 1, 3, 1], [6, 24, 13, 12, 3, 7, 0, 2, 1, 3], [6, 24, 14, 5, 6, 9, 1, 2, 1, 2], [6, 24, 14, 5, 6, 12, 1, 2, 2, 1], [6, 24, 14, 10, 4, 12, 1, 1, 3, 1], [6, 24, 14, 10, 6, 9, 1, 1, 4, 0], [6, 24, 15, 3, 4, 12, 1, 3, 0, 2], [6, 24, 15, 3, 5, 12, 1, 3, 0, 2], [6, 24, 15, 3, 8, 12, 1, 3, 0, 2], [6, 24, 15, 3, 12, 14, 1, 3, 2, 0], [6, 24, 15, 9, 4, 8, 1, 1, 2, 2], [6, 24, 15, 9, 4, 12, 1, 1, 3, 1], [6, 24, 15, 9, 6, 7, 1, 1, 4, 0], [6, 24, 15, 9, 6, 10, 1, 1, 4, 0], [6, 24, 15, 12, 5, 9, 0, 2, 3, 1], [6, 24, 16, 8, 3, 6, 1, 1, 0, 4], [6, 24, 16, 8, 5, 7, 1, 1, 2, 2], [6, 24, 16, 8, 7, 10, 0, 3, 2, 1], [6, 24, 17, 6, 9, 15, 0, 4, 1, 1], [6, 24, 17, 8, 6, 9, 0, 3, 1, 2], [6, 24, 18, 3, 8, 11, 1, 2, 3, 0], [6, 24, 18, 6, 4, 8, 1, 1, 2, 2], [6, 24, 18, 6, 8, 16, 0, 4, 1, 1], [6, 24, 20, 4, 3, 9, 1, 1, 2, 2], [6, 24, 20, 4, 3, 15, 1, 1, 3, 1], [6, 24, 20, 4, 5, 6, 1, 1, 0, 4], [6, 24, 20, 4, 5, 9, 1, 1, 3, 1], [6, 24, 20, 4, 6, 12, 1, 1, 4, 0], [6, 24, 20, 4, 6, 15, 1, 1, 4, 0], [6, 24, 20, 6, 9, 15, 0, 4, 1, 1], [6, 24, 20, 8, 5, 14, 0, 3, 2, 1], [6, 24, 20, 12, 3, 15, 0, 2, 3, 1], [6, 24, 24, 3, 4, 5, 1, 0, 1, 4], [6, 24, 24, 5, 4, 6, 1, 0, 3, 2], [6, 24, 24, 5, 4, 8, 1, 0, 4, 1], [6, 24, 24, 6, 4, 5, 1, 0, 1, 4], [6, 24, 24, 6, 4, 8, 1, 0, 4, 1], [6, 24, 24, 7, 3, 6, 1, 0, 2, 3], [6, 24, 24, 7, 4, 5, 1, 0, 1, 4], [6, 24, 24, 7, 4, 6, 1, 0, 3, 2], [6, 24, 24, 7, 4, 8, 1, 0, 4, 1], [6, 24, 24, 8, 3, 6, 1, 0, 2, 3], [6, 24, 24, 9, 4, 8, 1, 0, 4, 1], [6, 24, 24, 10, 3, 6, 1, 0, 2, 3], [6, 24, 24, 11, 4, 5, 1, 0, 1, 4], [6, 24, 24, 11, 4, 8, 1, 0, 4, 1], [6, 24, 24, 12, 4, 5, 1, 0, 1, 4], [6, 24, 24, 13, 4, 6, 1, 0, 3, 2], [6, 24, 24, 14, 3, 6, 1, 0, 2, 3], [6, 24, 24, 14, 4, 5, 1, 0, 1, 4], [6, 24, 24, 14, 4, 6, 1, 0, 3, 2], [6, 24, 24, 15, 4, 6, 1, 0, 3, 2], [6, 24, 24, 16, 4, 5, 1, 0, 1, 4], [6, 24, 24, 16, 4, 6, 1, 0, 3, 2], [6, 24, 24, 17, 3, 6, 1, 0, 2, 3], [6, 24, 24, 17, 4, 5, 1, 0, 1, 4], [6, 24, 24, 17, 4, 6, 1, 0, 3, 2], [6, 24, 24, 17, 4, 8, 1, 0, 4, 1], [6, 24, 24, 20, 3, 6, 1, 0, 2, 3], [6, 24, 25, 6, 4, 20, 0, 4, 1, 1], [6, 24, 25, 6, 10, 14, 0, 4, 1, 1], [6, 24, 25, 24, 3, 6, 0, 1, 2, 3], [6, 24, 25, 24, 4, 8, 0, 1, 4, 1], [6, 24, 30, 6, 4, 20, 0, 4, 1, 1], [6, 24, 30, 24, 4, 8, 0, 1, 4, 1], [6, 25, 10, 5, 7, 9, 2, 1, 1, 2], [6, 25, 11, 3, 7, 9, 2, 1, 1, 2], [6, 25, 13, 6, 5, 10, 1, 2, 1, 2], [6, 25, 13, 12, 5, 10, 1, 1, 3, 1], [6, 25, 14, 11, 5, 10, 1, 1, 3, 1], [6, 25, 15, 5, 6, 13, 1, 2, 2, 1], [6, 25, 15, 5, 7, 11, 1, 2, 2, 1], [6, 25, 15, 10, 4, 7, 1, 1, 1, 3], [6, 25, 15, 10, 6, 7, 1, 1, 3, 1], [6, 25, 16, 9, 6, 7, 1, 1, 3, 1], [6, 25, 20, 5, 3, 16, 1, 1, 3, 1], [6, 25, 25, 3, 4, 9, 1, 0, 4, 1], [6, 25, 25, 5, 3, 8, 1, 0, 3, 2], [6, 25, 25, 5, 3, 13, 1, 0, 4, 1], [6, 25, 25, 5, 4, 9, 1, 0, 4, 1], [6, 25, 25, 7, 4, 9, 1, 0, 4, 1], [6, 25, 25, 8, 3, 13, 1, 0, 4, 1], [6, 25, 25, 9, 3, 8, 1, 0, 3, 2], [6, 25, 25, 9, 3, 13, 1, 0, 4, 1], [6, 25, 25, 10, 3, 8, 1, 0, 3, 2], [6, 25, 25, 10, 4, 9, 1, 0, 4, 1], [6, 25, 25, 12, 4, 9, 1, 0, 4, 1], [6, 25, 25, 13, 3, 8, 1, 0, 3, 2], [6, 25, 25, 14, 3, 8, 1, 0, 3, 2], [6, 25, 25, 15, 4, 9, 1, 0, 4, 1], [6, 25, 25, 17, 3, 8, 1, 0, 3, 2], [6, 25, 25, 20, 3, 13, 1, 0, 4, 1], [6, 25, 25, 24, 3, 8, 1, 0, 3, 2], [6, 25, 25, 24, 4, 9, 1, 0, 4, 1], [6, 25, 30, 25, 3, 13, 0, 1, 4, 1], [6, 26, 10, 6, 8, 9, 2, 1, 1, 2], [6, 26, 12, 7, 8, 9, 1, 2, 1, 2], [6, 26, 12, 7, 8, 10, 1, 2, 2, 1], [6, 26, 13, 6, 5, 7, 2, 0, 1, 3], [6, 26, 13, 7, 6, 8, 2, 0, 3, 1], [6, 26, 13, 10, 6, 8, 2, 0, 3, 1], [6, 26, 14, 6, 4, 11, 1, 2, 1, 2], [6, 26, 14, 6, 8, 10, 1, 2, 2, 1], [6, 26, 14, 12, 4, 9, 1, 1, 2, 2], [6, 26, 16, 5, 4, 11, 1, 2, 1, 2], [6, 26, 16, 10, 4, 9, 1, 1, 2, 2], [6, 26, 18, 4, 7, 12, 1, 2, 2, 1], [6, 26, 18, 13, 6, 8, 0, 2, 3, 1], [6, 26, 20, 13, 5, 7, 0, 2, 1, 3], [6, 26, 20, 13, 6, 8, 0, 2, 3, 1], [6, 27, 12, 3, 9, 11, 2, 1, 3, 0], [6, 27, 15, 6, 5, 9, 1, 2, 0, 3], [6, 27, 15, 6, 7, 13, 1, 2, 2, 1], [6, 27, 15, 6, 8, 9, 1, 2, 0, 3], [6, 27, 15, 6, 9, 10, 1, 2, 3, 0], [6, 27, 16, 11, 4, 15, 1, 1, 3, 1], [6, 27, 16, 11, 5, 12, 1, 1, 3, 1], [6, 27, 16, 11, 6, 7, 1, 1, 1, 3], [6, 27, 16, 11, 6, 9, 1, 1, 3, 1], [6, 27, 17, 5, 9, 12, 1, 2, 3, 0], [6, 27, 17, 10, 3, 8, 1, 1, 1, 3], [6, 27, 17, 10, 4, 15, 1, 1, 3, 1], [6, 27, 20, 7, 3, 18, 1, 1, 3, 1], [6, 27, 20, 7, 5, 12, 1, 1, 3, 1], [6, 27, 20, 9, 5, 17, 0, 3, 2, 1], [6, 27, 30, 9, 7, 10, 0, 3, 1, 2], [6, 28, 11, 6, 8, 10, 2, 1, 1, 2], [6, 28, 12, 8, 9, 10, 1, 2, 2, 1], [6, 28, 14, 7, 8, 12, 1, 2, 2, 1], [6, 28, 14, 9, 6, 10, 2, 0, 3, 1], [6, 28, 15, 13, 4, 7, 1, 1, 0, 4], [6, 28, 15, 13, 7, 11, 1, 1, 4, 0], [6, 28, 16, 12, 4, 7, 1, 1, 0, 4], [6, 28, 16, 12, 4, 10, 1, 1, 2, 2], [6, 28, 16, 12, 5, 13, 1, 1, 3, 1], [6, 28, 16, 12, 7, 10, 1, 1, 4, 0], [6, 28, 16, 12, 7, 15, 1, 1, 4, 0], [6, 28, 17, 7, 12, 16, 0, 4, 1, 1], [6, 28, 17, 11, 4, 8, 1, 1, 1, 3], [6, 28, 17, 11, 4, 16, 1, 1, 3, 1], [6, 28, 17, 11, 6, 7, 1, 1, 0, 4], [6, 28, 17, 11, 7, 8, 1, 1, 4, 0], [6, 28, 17, 11, 7, 12, 1, 1, 4, 0], [6, 28, 18, 10, 4, 7, 1, 1, 0, 4], [6, 28, 18, 10, 6, 7, 1, 1, 0, 4], [6, 28, 18, 10, 7, 12, 1, 1, 4, 0], [6, 28, 20, 7, 12, 16, 0, 4, 1, 1], [6, 28, 20, 8, 3, 11, 1, 1, 2, 2], [6, 28, 20, 8, 5, 7, 1, 1, 0, 4], [6, 28, 20, 8, 5, 9, 1, 1, 2, 2], [6, 28, 20, 8, 7, 15, 1, 1, 4, 0], [6, 28, 24, 4, 5, 13, 1, 1, 3, 1], [6, 28, 24, 14, 4, 16, 0, 2, 3, 1], [6, 28, 25, 3, 4, 16, 1, 1, 3, 1], [6, 28, 25, 7, 12, 16, 0, 4, 1, 1], [6, 28, 25, 14, 4, 16, 0, 2, 3, 1], [6, 28, 30, 14, 4, 8, 0, 2, 1, 3], [6, 29, 15, 14, 5, 8, 1, 1, 1, 3], [6, 29, 17, 12, 5, 8, 1, 1, 1, 3], [6, 29, 18, 11, 5, 8, 1, 1, 1, 3], [6, 29, 18, 11, 7, 8, 1, 1, 3, 1], [6, 29, 20, 9, 5, 8, 1, 1, 1, 3], [6, 29, 20, 9, 6, 11, 1, 1, 3, 1], [6, 29, 20, 9, 7, 8, 1, 1, 3, 1], [6, 29, 24, 5, 3, 20, 1, 1, 3, 1], [6, 30, 11, 8, 6, 10, 2, 1, 0, 3], [6, 30, 12, 6, 5, 10, 2, 1, 0, 3], [6, 30, 12, 6, 9, 10, 2, 1, 0, 3], [6, 30, 12, 9, 8, 10, 1, 2, 0, 3], [6, 30, 12, 10, 8, 11, 0, 3, 1, 2], [6, 30, 13, 4, 6, 12, 2, 1, 1, 2], [6, 30, 13, 4, 9, 12, 2, 1, 2, 1], [6, 30, 13, 4, 10, 12, 2, 1, 3, 0], [6, 30, 14, 8, 5, 10, 1, 2, 0, 3], [6, 30, 15, 5, 6, 8, 2, 0, 1, 3], [6, 30, 15, 5, 6, 12, 2, 0, 3, 1], [6, 30, 15, 7, 6, 12, 2, 0, 3, 1], [6, 30, 15, 8, 7, 9, 2, 0, 3, 1], [6, 30, 15, 10, 6, 8, 2, 0, 1, 3], [6, 30, 15, 10, 8, 11, 0, 3, 1, 2], [6, 30, 15, 10, 9, 12, 0, 3, 2, 1], [6, 30, 15, 11, 6, 12, 2, 0, 3, 1], [6, 30, 15, 12, 7, 9, 2, 0, 3, 1], [6, 30, 16, 7, 4, 10, 1, 2, 0, 3], [6, 30, 16, 7, 9, 10, 1, 2, 0, 3], [6, 30, 16, 7, 10, 11, 1, 2, 3, 0], [6, 30, 16, 7, 10, 15, 1, 2, 3, 0], [6, 30, 16, 15, 6, 12, 0, 2, 3, 1], [6, 30, 18, 4, 15, 16, 1, 3, 2, 0], [6, 30, 18, 6, 10, 11, 1, 2, 3, 0], [6, 30, 18, 12, 4, 11, 1, 1, 2, 2], [6, 30, 20, 5, 8, 11, 1, 2, 1, 2], [6, 30, 20, 10, 3, 12, 1, 1, 2, 2], [6, 30, 20, 10, 6, 8, 1, 1, 1, 3], [6, 30, 20, 10, 8, 11, 0, 3, 1, 2], [6, 30, 20, 10, 8, 14, 0, 3, 2, 1], [6, 30, 20, 10, 9, 12, 0, 3, 2, 1], [6, 30, 24, 3, 7, 10, 1, 2, 0, 3], [6, 30, 24, 6, 7, 9, 1, 1, 3, 1], [6, 30, 25, 5, 4, 11, 1, 1, 2, 2], [6, 30, 25, 5, 6, 8, 1, 1, 1, 3], [6, 30, 25, 5, 7, 9, 1, 1, 3, 1], [6, 30, 25, 10, 3, 24, 0, 3, 2, 1], [6, 30, 25, 15, 7, 9, 0, 2, 3, 1], [6, 30, 30, 3, 4, 9, 1, 0, 3, 2], [6, 30, 30, 5, 3, 8, 1, 0, 2, 3], [6, 30, 30, 5, 3, 18, 1, 0, 4, 1], [6, 30, 30, 5, 4, 9, 1, 0, 3, 2], [6, 30, 30, 5, 4, 14, 1, 0, 4, 1], [6, 30, 30, 7, 3, 8, 1, 0, 2, 3], [6, 30, 30, 7, 4, 9, 1, 0, 3, 2], [6, 30, 30, 9, 3, 8, 1, 0, 2, 3], [6, 30, 30, 10, 3, 8, 1, 0, 2, 3], [6, 30, 30, 10, 4, 9, 1, 0, 3, 2], [6, 30, 30, 10, 4, 14, 1, 0, 4, 1], [6, 30, 30, 11, 4, 9, 1, 0, 3, 2], [6, 30, 30, 12, 3, 8, 1, 0, 2, 3], [6, 30, 30, 12, 4, 9, 1, 0, 3, 2], [6, 30, 30, 13, 3, 8, 1, 0, 2, 3], [6, 30, 30, 14, 3, 8, 1, 0, 2, 3], [6, 30, 30, 15, 4, 9, 1, 0, 3, 2], [6, 30, 30, 16, 3, 18, 1, 0, 4, 1], [6, 30, 30, 20, 3, 18, 1, 0, 4, 1], [6, 31, 13, 5, 7, 12, 2, 1, 1, 2], [6, 31, 15, 8, 9, 11, 1, 2, 1, 2], [6, 31, 16, 15, 4, 9, 1, 1, 1, 3], [6, 31, 25, 6, 7, 8, 1, 1, 1, 3], [6, 31, 25, 6, 7, 10, 1, 1, 3, 1], [6, 32, 12, 8, 10, 11, 2, 1, 1, 2], [6, 32, 16, 6, 5, 9, 2, 0, 1, 3], [6, 32, 16, 8, 10, 12, 1, 2, 2, 1], [6, 32, 16, 10, 7, 11, 2, 0, 3, 1], [6, 32, 16, 15, 5, 9, 2, 0, 1, 3], [6, 32, 17, 5, 12, 16, 1, 3, 0, 2], [6, 32, 17, 15, 8, 12, 1, 1, 4, 0], [6, 32, 17, 16, 5, 9, 0, 2, 1, 3], [6, 32, 18, 7, 10, 12, 1, 2, 2, 1], [6, 32, 20, 4, 7, 16, 1, 3, 0, 2], [6, 32, 20, 4, 15, 16, 1, 3, 0, 2], [6, 32, 20, 8, 14, 18, 0, 4, 1, 1], [6, 32, 20, 12, 5, 11, 1, 1, 2, 2], [6, 32, 20, 12, 8, 13, 1, 1, 4, 0], [6, 32, 20, 12, 8, 15, 1, 1, 4, 0], [6, 32, 20, 12, 8, 17, 1, 1, 4, 0], [6, 32, 24, 8, 6, 10, 1, 1, 2, 2], [6, 32, 24, 8, 7, 9, 1, 1, 2, 2], [6, 32, 25, 7, 8, 12, 1, 1, 4, 0], [6, 32, 30, 16, 5, 17, 0, 2, 3, 1], [6, 33, 12, 9, 4, 11, 2, 1, 0, 3], [6, 33, 13, 11, 9, 12, 0, 3, 1, 2], [6, 33, 14, 5, 9, 12, 2, 1, 1, 2], [6, 33, 15, 11, 7, 13, 0, 3, 1, 2], [6, 33, 16, 11, 5, 14, 0, 3, 1, 2], [6, 33, 16, 11, 9, 12, 0, 3, 1, 2], [6, 33, 16, 11, 9, 15, 0, 3, 2, 1], [6, 33, 17, 8, 3, 11, 1, 2, 0, 3], [6, 33, 20, 11, 3, 15, 0, 3, 1, 2], [6, 33, 20, 11, 9, 15, 0, 3, 2, 1], [6, 33, 20, 13, 6, 15, 1, 1, 3, 1], [6, 33, 20, 13, 7, 12, 1, 1, 3, 1], [6, 33, 20, 13, 8, 9, 1, 1, 3, 1], [6, 33, 25, 4, 3, 11, 1, 2, 0, 3], [6, 33, 25, 4, 11, 12, 1, 2, 3, 0], [6, 33, 25, 8, 3, 10, 1, 1, 1, 3], [6, 33, 25, 8, 6, 15, 1, 1, 3, 1], [6, 33, 25, 8, 7, 12, 1, 1, 3, 1], [6, 34, 13, 8, 10, 12, 2, 1, 1, 2], [6, 34, 15, 4, 6, 14, 2, 1, 1, 2], [6, 34, 15, 4, 10, 12, 2, 1, 1, 2], [6, 34, 16, 9, 4, 15, 1, 2, 1, 2], [6, 34, 17, 3, 8, 10, 2, 0, 3, 1], [6, 34, 17, 6, 8, 10, 2, 0, 3, 1], [6, 34, 17, 7, 8, 10, 2, 0, 3, 1], [6, 34, 17, 9, 8, 10, 2, 0, 3, 1], [6, 34, 17, 10, 6, 16, 2, 0, 3, 1], [6, 34, 17, 10, 7, 9, 2, 0, 1, 3], [6, 34, 17, 11, 8, 10, 2, 0, 3, 1], [6, 34, 17, 12, 4, 10, 2, 0, 1, 3], [6, 34, 17, 13, 8, 10, 2, 0, 3, 1], [6, 34, 17, 14, 8, 10, 2, 0, 3, 1], [6, 34, 17, 15, 4, 10, 2, 0, 1, 3], [6, 34, 17, 15, 6, 16, 2, 0, 3, 1], [6, 34, 17, 16, 4, 10, 2, 0, 1, 3], [6, 34, 20, 7, 9, 16, 1, 2, 2, 1], [6, 34, 20, 14, 8, 9, 1, 1, 2, 2], [6, 34, 24, 10, 8, 9, 1, 1, 2, 2], [6, 34, 25, 9, 4, 10, 1, 1, 1, 3], [6, 34, 25, 17, 4, 10, 0, 2, 1, 3], [6, 34, 30, 4, 7, 10, 1, 1, 2, 2], [6, 34, 30, 17, 8, 10, 0, 2, 3, 1], [6, 35, 14, 7, 11, 13, 2, 1, 2, 1], [6, 35, 15, 5, 11, 13, 2, 1, 2, 1], [6, 35, 15, 10, 7, 14, 1, 2, 1, 2], [6, 35, 15, 10, 11, 12, 1, 2, 1, 2], [6, 35, 16, 3, 11, 13, 2, 1, 2, 1], [6, 35, 17, 9, 11, 12, 1, 2, 1, 2], [6, 35, 24, 11, 8, 9, 1, 1, 1, 3], [6, 35, 30, 5, 7, 14, 1, 1, 3, 1], [6, 35, 30, 5, 8, 9, 1, 1, 1, 3], [6, 35, 30, 5, 8, 11, 1, 1, 3, 1], [6, 36, 14, 8, 3, 12, 2, 1, 0, 3], [6, 36, 15, 6, 8, 14, 2, 1, 1, 2], [6, 36, 16, 4, 9, 12, 2, 1, 0, 3], [6, 36, 16, 4, 10, 12, 2, 1, 0, 3], [6, 36, 16, 10, 3, 12, 1, 2, 0, 3], [6, 36, 16, 10, 6, 15, 1, 2, 1, 2], [6, 36, 18, 5, 7, 15, 2, 0, 3, 1], [6, 36, 18, 7, 6, 10, 2, 0, 1, 3], [6, 36, 18, 8, 6, 10, 2, 0, 1, 3], [6, 36, 18, 9, 6, 10, 2, 0, 1, 3], [6, 36, 18, 9, 11, 12, 1, 2, 0, 3], [6, 36, 18, 11, 6, 10, 2, 0, 1, 3], [6, 36, 18, 11, 8, 12, 2, 0, 3, 1], [6, 36, 18, 15, 6, 10, 2, 0, 1, 3], [6, 36, 18, 17, 8, 12, 2, 0, 3, 1], [6, 36, 20, 8, 5, 12, 1, 2, 0, 3], [6, 36, 20, 8, 11, 12, 1, 2, 0, 3], [6, 36, 20, 16, 6, 12, 1, 1, 2, 2], [6, 36, 20, 16, 9, 14, 1, 1, 4, 0], [6, 36, 24, 6, 8, 14, 1, 2, 1, 2], [6, 36, 24, 12, 5, 13, 1, 1, 2, 2], [6, 36, 24, 12, 7, 9, 1, 1, 0, 4], [6, 36, 24, 18, 3, 11, 0, 2, 1, 3], [6, 36, 25, 11, 6, 18, 1, 1, 3, 1], [6, 36, 25, 11, 8, 12, 1, 1, 3, 1], [6, 36, 25, 12, 4, 16, 0, 3, 1, 2], [6, 36, 25, 12, 8, 20, 0, 3, 2, 1], [6, 36, 25, 12, 10, 16, 0, 3, 2, 1], [6, 36, 30, 3, 8, 12, 1, 2, 0, 3], [6, 36, 30, 3, 10, 12, 1, 2, 0, 3], [6, 36, 30, 3, 10, 13, 1, 2, 1, 2], [6, 36, 30, 6, 5, 13, 1, 1, 2, 2], [6, 36, 30, 6, 8, 9, 1, 1, 0, 4], [6, 36, 30, 6, 9, 16, 1, 1, 4, 0], [6, 36, 30, 12, 4, 16, 0, 3, 1, 2], [6, 36, 30, 12, 10, 16, 0, 3, 2, 1], [6, 37, 16, 5, 11, 15, 2, 1, 2, 1], [6, 37, 16, 5, 12, 13, 2, 1, 2, 1], [6, 37, 17, 10, 12, 13, 1, 2, 2, 1], [6, 37, 25, 12, 7, 10, 1, 1, 1, 3], [6, 37, 25, 12, 9, 10, 1, 1, 3, 1], [6, 37, 30, 7, 9, 10, 1, 1, 3, 1], [6, 38, 14, 10, 12, 13, 2, 1, 1, 2], [6, 38, 15, 8, 10, 14, 2, 1, 1, 2], [6, 38, 16, 11, 12, 14, 1, 2, 2, 1], [6, 38, 17, 4, 10, 14, 2, 1, 1, 2], [6, 38, 18, 10, 4, 17, 1, 2, 1, 2], [6, 38, 18, 10, 8, 15, 1, 2, 1, 2], [6, 38, 20, 18, 8, 14, 1, 1, 3, 1], [6, 38, 24, 7, 11, 16, 1, 2, 2, 1], [6, 38, 24, 14, 9, 11, 1, 1, 3, 1], [6, 38, 30, 4, 10, 14, 1, 2, 1, 2], [6, 38, 30, 4, 10, 18, 1, 2, 2, 1], [6, 38, 30, 4, 12, 13, 1, 2, 1, 2], [6, 38, 30, 8, 5, 11, 1, 1, 1, 3], [6, 38, 30, 8, 9, 11, 1, 1, 3, 1], [6, 39, 15, 9, 13, 14, 2, 1, 3, 0], [6, 39, 16, 7, 9, 13, 2, 1, 0, 3], [6, 39, 16, 7, 12, 13, 2, 1, 0, 3], [6, 39, 17, 5, 8, 13, 2, 1, 0, 3], [6, 39, 17, 5, 12, 15, 2, 1, 2, 1], [6, 39, 24, 15, 6, 11, 1, 1, 1, 3], [6, 39, 25, 7, 3, 18, 1, 2, 1, 2], [6, 40, 16, 12, 10, 15, 1, 2, 1, 2], [6, 40, 20, 4, 9, 13, 2, 0, 3, 1], [6, 40, 20, 5, 8, 16, 2, 0, 3, 1], [6, 40, 20, 6, 9, 13, 2, 0, 3, 1], [6, 40, 20, 7, 8, 16, 2, 0, 3, 1], [6, 40, 20, 10, 12, 14, 1, 2, 1, 2], [6, 40, 20, 10, 12, 16, 1, 2, 2, 1], [6, 40, 20, 11, 9, 13, 2, 0, 3, 1], [6, 40, 20, 15, 8, 16, 2, 0, 3, 1], [6, 40, 25, 15, 4, 12, 1, 1, 1, 3], [6, 40, 25, 15, 8, 12, 1, 1, 2, 2], [6, 40, 25, 15, 8, 16, 1, 1, 3, 1], [6, 40, 25, 20, 8, 16, 0, 2, 3, 1], [6, 40, 30, 5, 8, 16, 1, 2, 1, 2], [6, 40, 30, 5, 8, 24, 1, 2, 2, 1], [6, 40, 30, 5, 13, 14, 1, 2, 2, 1], [6, 40, 30, 10, 4, 12, 1, 1, 1, 3], [6, 40, 30, 10, 8, 12, 1, 1, 2, 2], [6, 40, 30, 10, 8, 16, 1, 1, 3, 1], [6, 40, 30, 20, 8, 16, 0, 2, 3, 1], [6, 41, 17, 12, 11, 15, 1, 2, 1, 2], [6, 41, 25, 8, 13, 15, 1, 2, 2, 1], [6, 42, 15, 12, 10, 14, 2, 1, 0, 3], [6, 42, 16, 13, 3, 14, 1, 2, 0, 3], [6, 42, 17, 8, 6, 14, 2, 1, 0, 3], [6, 42, 17, 8, 12, 15, 2, 1, 1, 2], [6, 42, 20, 11, 14, 18, 1, 2, 3, 0], [6, 42, 30, 6, 8, 14, 1, 2, 0, 3], [6, 42, 30, 6, 8, 17, 1, 2, 1, 2], [6, 42, 30, 12, 5, 16, 1, 1, 2, 2], [6, 43, 20, 3, 11, 16, 2, 1, 1, 2], [6, 44, 17, 10, 12, 16, 2, 1, 1, 2], [6, 44, 18, 8, 10, 17, 2, 1, 1, 2], [6, 44, 20, 12, 13, 18, 1, 2, 2, 1], [6, 44, 24, 20, 6, 11, 1, 1, 0, 4], [6, 44, 30, 7, 4, 20, 1, 2, 1, 2], [6, 44, 30, 7, 12, 20, 1, 2, 2, 1], [6, 44, 30, 14, 5, 17, 1, 1, 2, 2], [6, 44, 30, 14, 11, 25, 1, 1, 4, 0], [6, 45, 16, 13, 3, 15, 2, 1, 0, 3], [6, 45, 20, 5, 11, 17, 2, 1, 1, 2], [6, 45, 25, 20, 9, 12, 1, 1, 1, 3], [6, 45, 25, 20, 9, 18, 1, 1, 3, 1], [6, 46, 18, 10, 15, 16, 2, 1, 2, 1], [6, 46, 20, 13, 12, 17, 1, 2, 1, 2], [6, 46, 30, 16, 10, 12, 1, 1, 1, 3], [6, 48, 20, 8, 15, 18, 2, 1, 2, 1], [6, 48, 20, 16, 12, 18, 0, 3, 1, 2], [6, 48, 24, 4, 6, 14, 2, 0, 1, 3], [6, 48, 24, 8, 11, 15, 2, 0, 3, 1], [6, 48, 24, 12, 7, 16, 1, 2, 0, 3], [6, 48, 24, 12, 16, 17, 1, 2, 3, 0], [6, 48, 24, 20, 3, 15, 2, 0, 1, 3], [6, 48, 30, 9, 5, 16, 1, 2, 0, 3], [6, 48, 30, 18, 8, 16, 1, 1, 2, 2], [6, 50, 20, 15, 16, 18, 1, 2, 2, 1], [6, 51, 18, 15, 6, 17, 2, 1, 0, 3], [6, 51, 20, 11, 12, 17, 2, 1, 0, 3], [6, 54, 25, 4, 6, 18, 2, 1, 0, 3], [6, 54, 25, 4, 15, 18, 2, 1, 0, 3], [6, 54, 30, 12, 4, 25, 1, 2, 1, 2], [6, 54, 30, 12, 17, 20, 1, 2, 2, 1], [6, 56, 24, 8, 18, 20, 2, 1, 2, 1], [6, 60, 24, 12, 5, 20, 2, 1, 0, 3], [6, 60, 24, 12, 10, 20, 2, 1, 0, 3], [6, 60, 24, 12, 11, 20, 2, 1, 0, 3], [6, 60, 30, 10, 12, 16, 2, 0, 1, 3]]; public static function randomPuzzle():ScalePuzzle { var a:Float = FlxMath.bound(PlayerData.scaleGamePuzzleDifficulty * 0.96 + 0.02, 0.02, 0.98); var puzzleIndex:Int = 0; var mercy:Int = 0; do { if (mercy++ > 50) { // too many collisions break; } puzzleIndex = Std.int((a + Puzzle.PUZZLE_RANDOM.floatNormal(0, 0.13)) * _puzzles.length); } while (puzzleIndex < 0 || puzzleIndex >= _puzzles.length || recentScalePuzzleIndexes.indexOf(puzzleIndex) != -1); recentScalePuzzleIndexes.push(puzzleIndex); recentScalePuzzleIndexes = recentScalePuzzleIndexes.splice(0, recentScalePuzzleIndexes.length - 50); var puzzle:ScalePuzzle = new ScalePuzzle(_puzzles[puzzleIndex]); if (Puzzle.PUZZLE_RANDOM.bool()) { swap(puzzle._answer, 0, 3); swap(puzzle._answer, 1, 2); swap(puzzle._weights, 0, 3); swap(puzzle._weights, 1, 2); } return puzzle; } private static function swap(arr:Array<Int>, index0:Int, index1:Int) { var tmp:Int = arr[index0]; arr[index0] = arr[index1]; arr[index1] = tmp; } public static function fixedPuzzle(seed:Int):ScalePuzzle { Puzzle.PUZZLE_RANDOM = new FlxRandom(seed); var puzzle:ScalePuzzle = new ScalePuzzle(Puzzle.PUZZLE_RANDOM.getObject(_puzzles)); if (Puzzle.PUZZLE_RANDOM.bool()) { swap(puzzle._answer, 0, 3); swap(puzzle._answer, 1, 2); swap(puzzle._weights, 0, 3); swap(puzzle._weights, 1, 2); } Puzzle.PUZZLE_RANDOM = FlxG.random; return puzzle; } }
argonvile/monster
source/minigame/scale/ScalePuzzleDatabase.hx
hx
unknown
95,230
package minigame.scale; import MmStringTools.*; import flixel.FlxG; import flixel.FlxSprite; import flixel.effects.particles.FlxEmitter; import flixel.effects.particles.FlxParticle; import flixel.group.FlxGroup; import flixel.system.FlxSound; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import kludge.FlxSoundKludge; import minigame.MinigameState.denNerf; import minigame.scale.ScaleAgent; import minigame.scale.ScaleGameState; /** * The scoreboard which displays during the scale scoreboard, to show the * player how they're measuring up against each of their opponents */ class ScaleScoreboard extends FlxGroup { private var _accumulationPerSecond:Float; private var _scoreboardBg:FlxSprite; private var _scaleGameState:ScaleGameState; private var _scoreTexts:Array<FlxText> = []; private var _showingRoundScores:Bool = false; private var _accumulatingTotalScores:Bool = false; private var _accumulationTimer:Float = 0; private var _accumulateSfx:FlxSound; private var _victoryParticles:FlxEmitter; public function new(scaleGameState:ScaleGameState) { super(); this._scaleGameState = scaleGameState; this._accumulationPerSecond = denNerf(125); _scoreboardBg = new FlxSprite(0, 0); _scoreboardBg.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); add(_scoreboardBg); _accumulateSfx = FlxG.sound.load(FlxSoundKludge.fixPath(AssetPaths.cash_accumulate_0065__mp3)); } override public function update(elapsed:Float):Void { super.update(elapsed); updateAgentSpritePositions(); if (_accumulatingTotalScores) { _accumulationTimer += elapsed; var accumulationAmount:Float = _accumulationPerSecond * _accumulationTimer; _accumulationTimer -= Std.int(accumulationAmount) / _accumulationPerSecond; accumulationAmount = Std.int(accumulationAmount); for (i in 0..._scoreTexts.length) { var accumulationAmount:Int = Std.int(Math.min(accumulationAmount, _scaleGameState._scalePlayerStatus._roundScores[i])); _scaleGameState._scalePlayerStatus._totalScores[i] += accumulationAmount; _scaleGameState._scalePlayerStatus._roundScores[i] -= accumulationAmount; } var accumulating:Bool = false; for (i in 0..._scoreTexts.length) { if (_scaleGameState._scalePlayerStatus._roundScores[i] > 0) { accumulating = true; } } if (!accumulating) { _accumulatingTotalScores = false; _accumulateSfx.stop(); } } } public function init() { var bottom:Float = 33 + 42 * (_scaleGameState._agentSprites.length); var tmpSprite:FlxSprite = new FlxSprite(); tmpSprite.makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT, true); FlxSpriteUtil.beginDraw(OptionsMenuState.MEDIUM_BLUE); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.endDraw(tmpSprite); var rectSprite:FlxSprite = new FlxSprite(); rectSprite.makeGraphic(149, Std.int(bottom - 30), OptionsMenuState.LIGHT_BLUE, true); rectSprite.alpha = 0.5; var diagonalX:Int = Std.int( -rectSprite.height); do { FlxSpriteUtil.drawLine(rectSprite, -rectSprite.height + diagonalX - 10, -10, diagonalX + 10, rectSprite.height + 10, { thickness:7, color:OptionsMenuState.MEDIUM_BLUE }); diagonalX += 18; } while (diagonalX < rectSprite.width + rectSprite.height); tmpSprite.stamp(rectSprite, 422, 25); tmpSprite.alpha = 0.77; _scoreboardBg.stamp(tmpSprite, 0, 0); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:9, color:OptionsMenuState.DARK_BLUE }); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.updateSpriteGraphic(_scoreboardBg); FlxSpriteUtil.flashGfx.clear(); FlxSpriteUtil.setLineStyle({ thickness:7, color:OptionsMenuState.WHITE_BLUE }); OptionsMenuState.octagon(192, 20, 576, bottom, 2); FlxSpriteUtil.updateSpriteGraphic(_scoreboardBg); for (i in 0..._scaleGameState._agentSprites.length) { var scoreText:FlxText = new FlxText(0, 0, 100, "0", 30); _scoreTexts.push(scoreText); scoreText.font = AssetPaths.hardpixel__otf; scoreText.color = OptionsMenuState.LIGHT_BLUE; scoreText.setBorderStyle(OUTLINE, OptionsMenuState.MEDIUM_BLUE, 2); add(scoreText); } } public function eventShowRoundScores(args:Dynamic) { _showingRoundScores = true; _accumulatingTotalScores = false; } public function eventShowTotalScores(args:Dynamic) { _showingRoundScores = false; _accumulatingTotalScores = false; for (agent in _scaleGameState._scalePlayerStatus._agents) { // remove "1st/2nd" frames when accumulating scores agent._finishedOrder = ScaleAgent.UNFINISHED; } } public function eventAccumulateTotalScores(args:Dynamic) { _showingRoundScores = false; _accumulatingTotalScores = true; _accumulationTimer = 0; _accumulateSfx.play(); } function updateAgentSpritePositions() { for (i in 0..._scaleGameState._agentSprites.length) { _scaleGameState._agentSprites[i].x = 192 + 8 + Math.min(245, 225 * _scaleGameState._scalePlayerStatus._totalScores[i] / denNerf(ScaleGameState.TARGET_SCORE)); _scaleGameState._agentSprites[i].y = 20 + 8 + 42 * i; if (_showingRoundScores) { _scoreTexts[i].text = "+" + _scaleGameState._scalePlayerStatus._roundScores[i]; } else { _scoreTexts[i].text = commaSeparatedNumber(_scaleGameState._scalePlayerStatus._totalScores[i]); } _scoreTexts[i].x = _scaleGameState._agentSprites[i].x + _scaleGameState._agentSprites[i].width + 8; _scoreTexts[i].y = _scaleGameState._agentSprites[i].y - 2; } if (_victoryParticles == null) { for (i in 0..._scaleGameState._agentSprites.length) { if (_scaleGameState._scalePlayerStatus._totalScores[i] >= denNerf(ScaleGameState.TARGET_SCORE)) { // victory if (_scaleGameState._scalePlayerStatus._agents[i]._soundAsset != null) { SoundStackingFix.play(_scaleGameState._scalePlayerStatus._agents[i]._soundAsset, 0.25); } if (_victoryParticles == null) { SoundStackingFix.play(AssetPaths.finish_scalegame_00b9__mp3); _victoryParticles = new FlxEmitter(0, 0, 32); add(_victoryParticles); _victoryParticles.angularVelocity.set(0); _victoryParticles.launchMode = FlxEmitterMode.CIRCLE; _victoryParticles.speed.set(60, 120, 0, 0); _victoryParticles.acceleration.set(0); _victoryParticles.alpha.set(0.88, 0.88, 0, 0); _victoryParticles.lifespan.set(0.6); for (i in 0..._victoryParticles.maxSize) { var particle:FlxParticle = new MinRadiusParticle(18); particle.makeGraphic(3, 3, 0xFFFFFFFF); particle.exists = false; _victoryParticles.add(particle); } } _victoryParticles.x = _scaleGameState._agentSprites[i].x + _scaleGameState._agentSprites[i].width / 2; _victoryParticles.y = _scaleGameState._agentSprites[i].y + _scaleGameState._agentSprites[i].height / 2; _victoryParticles.start(true, 0, 1); for (j in 0...8) { _victoryParticles.emitParticle(); } } } } if (_showingRoundScores) { for (i in 1..._scaleGameState._scalePlayerStatus._agents.length) { if (_scaleGameState._scalePlayerStatus._agents[i]._finishedOrder == 1) { _scaleGameState._agentSprites[i].animation.frameIndex = 2; } else if (_scaleGameState._scalePlayerStatus._agents[i]._finishedOrder < ScaleAgent.UNFINISHED) { _scaleGameState._agentSprites[i].animation.frameIndex = 4; } else { _scaleGameState._agentSprites[i].animation.frameIndex = 8; } } } else { var lowScore:Int = 1000; var hiScore:Int = 0; for (i in 0..._scaleGameState._scalePlayerStatus._agents.length) { lowScore = Std.int(Math.min(lowScore, _scaleGameState._scalePlayerStatus._totalScores[i])); hiScore = Std.int(Math.max(hiScore, _scaleGameState._scalePlayerStatus._totalScores[i])); } for (i in 1..._scaleGameState._scalePlayerStatus._agents.length) { if (_scaleGameState._scalePlayerStatus._totalScores[i] == hiScore) { _scaleGameState._agentSprites[i].animation.frameIndex = 2; } else if (_scaleGameState._scalePlayerStatus._totalScores[i] != lowScore) { _scaleGameState._agentSprites[i].animation.frameIndex = 4; } else { _scaleGameState._agentSprites[i].animation.frameIndex = 8; } } } } }
argonvile/monster
source/minigame/scale/ScaleScoreboard.hx
hx
unknown
8,630
package minigame.stair; /** * A solver for bimatrix games * * This is used for calculating the AI's move in the stair climbing minigame. */ class MatrixSolver { private static var EPSILON:Float = .000000000001; private var rowHeaders:Array<Int>; private var colHeaders:Array<Int>; private var m:Array<Array<Float>>; private function new() { } private function storeMatrix(input:Array<Array<Float>>):Void { m = new Array<Array<Float>>(); for (row in 0...input.length) { // deep copy of input matrixes... m.push(input[row].copy()); } // pad right/bottom of matrix with zeroes m.push([]); for (row in 0...m.length) { while (m[row].length < input[0].length + 1) { m[row].push(0); } } rowHeaders = []; while (rowHeaders.length < m.length) { rowHeaders.push(0); } colHeaders = []; while (colHeaders.length < m[0].length) { colHeaders.push(0); } for (row in 0...m.length) { rowHeaders[row] = row + 1; m[row][m[0].length - 1] = 1; } for (col in 0...m[0].length) { colHeaders[col] = -col - 1; m[m.length - 1][col] = -1; } m[m.length - 1][m[0].length - 1] = 0; } public function makePositive():Void { var minValue:Float = m[0][0]; for (row in 0...m.length - 1) { for (col in 0...m[0].length - 1) { minValue = Math.min(minValue, m[row][col]); } } for (row in 0...m.length - 1) { for (col in 0...m[0].length - 1) { m[row][col] = m[row][col] - minValue + 1; } } } public function solve():Void { var pivotRow:Int = -1; var pivotCol:Int = 0; while (pivotCol != -1) { var r:Float = 0; // find pivot row for (row in 0...m.length - 1) { var t1:Float = m[row][pivotCol]; if (t1 > EPSILON) // to avoid rounding error { var t2:Float = m[row][m[0].length - 1]; if (t2 <= 0) { pivotRow = row; break; } else if (t1 / t2 > r) { pivotRow = row; r = t1 / t2; } } } var d:Float = m[pivotRow][pivotCol]; // begin pivot on (pivotRow, pivotCol) for (col in 0...m[0].length) { // pivot row if (col != pivotCol) { m[pivotRow][col] = m[pivotRow][col] / d; } } for (row in 0...m.length) { // pivot main part if (row != pivotRow) { for (col in 0...m[0].length) { if (col != pivotCol) { m[row][col] = m[row][col] - m[row][pivotCol] * m[pivotRow][col]; } } } } for (row in 0...m.length) { // pivot col if (row != pivotRow) { m[row][pivotCol] = -m[row][pivotCol] / d; } } m[pivotRow][pivotCol] = 1 / d; var t1:Int = rowHeaders[pivotRow]; rowHeaders[pivotRow] = colHeaders[pivotCol]; colHeaders[pivotCol] = t1; // end pivot pivotCol = -1; for (col in 0...m.length - 1) { // find pivot col if (m[m.length - 1][col] < 0) { pivotCol = col; break; } } } } /** * Returns a strategy for P1 which maximizes P1's score, assuming P2 plays * optimally * * @param mat matrix to solve * @return array of probabilities for an optimal strategy */ public static function getStrategyP1(mat:Array<Array<Float>>):Array<Float> { var solver:MatrixSolver = new MatrixSolver(); solver.doSolve(mat); var y:Array<Float> = []; while (y.length < solver.m[0].length - 1) { y.push(0); } for (row in 0...solver.m.length - 1) { if (solver.rowHeaders[row] < 0) { y[-solver.rowHeaders[row] - 1] = solver.m[row][solver.m[0].length - 1] / solver.m[solver.m.length - 1][solver.m[0].length - 1]; } } return y; } /** * Returns a strategy for P2 which minimizes P1's score, assuming P1 plays * optimally * * @param mat matrix to solve * @return array of probabilities for an optimal P2 strategy */ public static function getStrategyP2(mat:Array<Array<Float>>):Array<Float> { var solver:MatrixSolver = new MatrixSolver(); solver.doSolve(mat); var x:Array<Float> = []; while (x.length < solver.m.length - 1) { x.push(0); } for (col in 0...solver.m[0].length-1) { if (solver.colHeaders[col] > 0) { x[solver.colHeaders[col] - 1] = solver.m[solver.m.length - 1][col] / solver.m[solver.m.length - 1][solver.m[0].length - 1]; } } return x; } /** * Returns a strategy for P1 which naively maximizes P1's score, with the * assumption that P2 will behave randomly * * @param rewardMatrix matrix to solve * @return array of probabilities for a naive P1 strategy */ public static function getDumbStrategyP1(rewardMatrix:Array<Array<Float>>):Array<Float> { var result:Array<Float> = []; for (row in 0...rewardMatrix.length) { result.push(0); for (col in 0...rewardMatrix[row].length) { result[row] += rewardMatrix[row][col]; } } // narrow the choices down to the 1 or 2 smallest columns... var max:Float = result[0]; for (i in 1...result.length) { max = Math.max(max, result[i]); } for (i in 0...result.length) { result[i] = max - result[i]; } return normalizeStrategy(result); } /** * Returns a strategy for P2 which naively minimizes P1's score, with the * assumption that P1 will behave randomly * * @param rewardMatrix matrix to solve * @return array of probabilities for a naive P2 strategy */ public static function getDumbStrategyP2(rewardMatrix:Array<Array<Float>>):Array<Float> { var result:Array<Float> = []; for (col in 0...rewardMatrix[0].length) { result.push(0); for (row in 0...rewardMatrix.length) { result[col] += rewardMatrix[row][col]; } } // narrow the choices down to the 1 or 2 largest rows... var max:Float = result[0]; var min:Float = result[0]; for (i in 1...result.length) { max = Math.max(max, result[i]); min = Math.min(min, result[i]); } if (max != min) { for (i in 0...result.length) { result[i] -= min; } } return normalizeStrategy(result); } /** * Strategies are defined as an array of probabilities like * [0.21, 0.29, 0.50], although while performing calculations they might * temporarily be something absurd like [1.19, 1.64, 2.83]. * * This method normalizes a probability array so that all of the * probabilities add up to 1.00 * * @param result probability array which is modified inline * @return scaled probability array which adds up to 1.0 */ public static function normalizeStrategy(result:Array<Float>):Array<Float> { var total:Float = 0; for (i in 0...result.length) { total += result[i]; } if (total == 0) { // avoid divide by zero return result; } for (i in 0...result.length) { result[i] /= total; } return result; } private function doSolve(mat:Array<Array<Float>>):Void { storeMatrix(mat); makePositive(); solve(); } }
argonvile/monster
source/minigame/stair/MatrixSolver.hx
hx
unknown
7,156
package minigame.stair; import poke.abra.AbraDialog; import minigame.GameDialog; /** * Defines the behavior for an opponent in the stair climbing minigame */ class StairAgent { // [0.0-1.0] How often does this agent throw a zero, in the hopes their opponent will throw a zero as well? public var diminishedZeroZero:Float = 1.0; // [0.0-1.0] How much does this agent ignore their opponent's likely decisions? public var dumbness:Float = 0.0; // [0.0-5.0] How much does this agent like picking the best option? public var bias0:Float = 1.0; // [0.0-5.0] How much does this agent like picking the second best option? public var bias1:Float = 1.0; // [0.0-14.0] How often do this agent's decisions get clouded by randomness? public var fuzzFactor:Float = 0.01; public var oddsEvens:Array<Float> = [0.25, 0.5, 0.25]; public var chatAsset:String; public var thinkyFaces:Array<Int> = [6]; public var neutralFaces:Array<Int> = [4, 5]; public var goodFaces:Array<Int> = [2, 3]; public var badFaces:Array<Int> = [7, 10, 11, 12, 13]; public var gameDialog:GameDialog; public var dialogClass:Dynamic; public function new() { } public function setDialogClass(dialogClass:Dynamic) { this.dialogClass = dialogClass; var gameDialog:Dynamic = Reflect.field(dialogClass, "gameDialog"); this.gameDialog = gameDialog(StairGameState); } }
argonvile/monster
source/minigame/stair/StairAgent.hx
hx
unknown
1,402
package minigame.stair; import poke.abra.AbraDialog; import poke.abra.AbraResource; import poke.buiz.BuizelDialog; import poke.buiz.BuizelResource; import flixel.FlxG; import poke.grim.GrimerDialog; import poke.grim.GrimerResource; import poke.grov.GrovyleDialog; import poke.grov.GrovyleResource; import poke.hera.HeraDialog; import poke.hera.HeraResource; import poke.kecl.KecleonDialog; import poke.kecl.KecleonResource; import poke.luca.LucarioDialog; import poke.luca.LucarioResource; import poke.magn.MagnDialog; import poke.magn.MagnResource; import poke.rhyd.RhydonDialog; import poke.rhyd.RhydonResource; import poke.sand.SandslashDialog; import poke.sand.SandslashResource; import poke.smea.SmeargleDialog; import poke.smea.SmeargleResource; /** * Stores the behavior for the different opponents in the stair climbing * minigame */ class StairAgentDatabase { public static function getAgent():StairAgent { var agents:Array<StairAgent> = []; { // abra (51.35%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(AbraDialog); agent.oddsEvens = [0.25, 0.50, 0.25]; // 50% agent.bias1 = 3.0; agents.push(agent); agent.chatAsset = AbraResource.chat; agent.thinkyFaces = [4, 5]; agent.badFaces = [8, 9, 10, 11, 12, 13]; } { // buizel (39.95%, plus fuzz factor nerf) var agent:StairAgent = new StairAgent(); agent.setDialogClass(BuizelDialog); agent.oddsEvens = [0.00, 0.85, 0.15]; // 85% agent.diminishedZeroZero = 0.4; agent.dumbness = 0.9; agent.bias0 = 5.0; agent.fuzzFactor = 5.0; agents.push(agent); agent.chatAsset = BuizelResource.chat; agent.goodFaces = [2]; agent.badFaces = [10, 11, 13, 15]; } { // heracross (43.84%, plus fuzz factor nerf) var agent:StairAgent = new StairAgent(); agent.setDialogClass(HeraDialog); agent.oddsEvens = [0.05, 0.95, 0.00]; // 95% agent.diminishedZeroZero = 0.4; agent.dumbness = 0.4; agent.fuzzFactor = 1.0; agents.push(agent); agent.chatAsset = HeraResource.chat; } { // grovyle (49.91%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(GrovyleDialog); agent.oddsEvens = [0.30, 0.40, 0.30]; // 60% agent.dumbness = 0.4; agent.bias0 = 5.0; agents.push(agent); agent.chatAsset = GrovyleResource.chat; agent.goodFaces = [2]; } { // sandslash (41.26%, plus fuzz factor nerf) var agent:StairAgent = new StairAgent(); agent.setDialogClass(SandslashDialog); agent.oddsEvens = [0.60, 0.30, 0.10]; // 70% agent.dumbness = 0.8; agent.bias1 = 0.5; agent.fuzzFactor = 3.0; agents.push(agent); agent.chatAsset = SandslashResource.chat; agent.goodFaces = [3, 14, 15]; agent.badFaces = [7, 9, 10, 11, 12, 13]; } { // rhydon (50.00%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(RhydonDialog); agent.oddsEvens = [0.25, 0.65, 0.10]; // 65% agent.bias0 = 5.0; agents.push(agent); agent.chatAsset = RhydonResource.chat; agent.goodFaces = [2, 14]; } { // smeargle (45.95%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(SmeargleDialog); agent.oddsEvens = [0.10, 0.10, 0.80]; // 90% agent.dumbness = 0.7; agent.bias1 = 5.0; agents.push(agent); agent.chatAsset = AssetPaths.smear_chat__png; agent.badFaces = [7, 10, 11, 13]; } { // kecleon (??? should never play) (38.63%, plus fuzz factor nerf) var agent:StairAgent = new StairAgent(); agent.setDialogClass(KecleonDialog); agent.oddsEvens = [0.10, 0.75, 0.15]; // 75% agent.dumbness = 1.0; agent.fuzzFactor = 7.0; agents.push(agent); agent.chatAsset = AssetPaths.kecl_chat__png; agent.badFaces = [7, 10, 11, 13]; } { // magnezone (50.00%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(MagnDialog); agent.oddsEvens = [0.50, 0.50, 0.00]; agents.push(agent); agent.chatAsset = MagnResource.chat; agent.thinkyFaces = [6, 14, 15]; agent.goodFaces = [0, 1, 2, 3]; agent.badFaces = [7, 10, 11]; } { // grimer (47.83%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(GrimerDialog); agent.oddsEvens = [0.90, 0.00, 0.10]; // 100% agent.diminishedZeroZero = 0.6; agents.push(agent); agent.chatAsset = GrimerResource.chat; } { // lucario (47.39%) var agent:StairAgent = new StairAgent(); agent.setDialogClass(LucarioDialog); agent.oddsEvens = [0.40, 0.20, 0.40]; // 80% agent.dumbness = 0.2; agent.bias1 = 3.0; agents.push(agent); agent.chatAsset = LucarioResource.chat; agent.thinkyFaces = [6, 7, 10]; } if (PlayerData.profIndex < agents.length) { return agents[PlayerData.profIndex]; } // active professor doesn't have minigame persona? ...just return someone as a placeholder return FlxG.random.getObject(agents); } }
argonvile/monster
source/minigame/stair/StairAgentDatabase.hx
hx
unknown
5,028
package minigame.stair; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.system.FlxAssets.FlxGraphicAsset; /** * Graphics and logic for each of the two dice in the stair minigame * * Yes, I know singular of "dice" is "die". But "die" means a lot of things in * the context of video games, while "dice" is unambiguous */ class StairDice extends FlxSprite { private static var DICE_SETTLE_ANIMS:Array<Array<Int>> = [ [7, 2, 0], [1, 6, 0], [0, 4, 1], [3, 0, 1], [7, 0, 2], [1, 0, 2], [0, 5, 3], [7, 6, 3], [5, 3, 1, 0], [4, 7, 2, 0], [7, 4, 0, 1], [2, 0, 4, 1], [1, 0, 7, 2], [6, 0, 6, 2], [7, 4, 5, 3], [4, 1, 4, 3], [2, 3, 6, 5, 0], [3, 5, 0, 1, 0], [5, 2, 1, 6, 1], [6, 4, 7, 6, 1], [0, 5, 0, 6, 2], [5, 2, 1, 0, 2], [6, 4, 1, 0, 3], [6, 4, 2, 1, 3], ]; public var z:Float; public var zVelocity:Float; public var zAccel:Float = -1440; public var sfxTimer:Float; public var rollTimer:Float = 0; public var sfxVolume:Float = 0; public function new(graphic:FlxGraphicAsset) { super(); loadGraphic(graphic, true, 60, 60); width = 38; height = 14; setFacingFlip(FlxObject.LEFT, false, false); setFacingFlip(FlxObject.RIGHT, true, false); } private function resetSfxTimer() { if (FlxG.random.bool()) { sfxTimer = Math.min(FlxG.random.float(0.09, 0.12), FlxG.random.float(0.09, 0.12)); } else { sfxTimer = Math.max(FlxG.random.float(0.12, 0.15), FlxG.random.float(0.12, 0.15)); } playDiceSfx(sfxVolume); sfxVolume *= FlxG.random.float(0.4, 0.9); } private function playDiceSfx(volume:Float) { SoundStackingFix.play(FlxG.random.getObject([ AssetPaths.stair_dice0_00cf__wav, AssetPaths.stair_dice1_00cf__wav, AssetPaths.stair_dice2_00cf__wav, AssetPaths.stair_dice3_00cf__wav, AssetPaths.stair_dice4_00cf__wav, AssetPaths.stair_dice5_00cf__wav, ]), volume); } override public function update(elapsed:Float):Void { var oldFrame:Int = animation.curAnim == null ? -1 : animation.curAnim.curFrame; super.update(elapsed); offset.set(11, 32 + z); if (z == 0 && drag.x == 0) { // just landed animation.add("settle", FlxG.random.getObject(DICE_SETTLE_ANIMS), 6, false); animation.play("settle"); drag.set(240, 240); rollTimer = FlxG.random.float(0.4, 0.6); sfxTimer = 0; sfxVolume = 1.0; } if (rollTimer > 0) { rollTimer -= FlxG.elapsed; sfxTimer -= FlxG.elapsed; if (sfxTimer <= 0) { resetSfxTimer(); } } if (animation.curAnim != null && animation.curAnim.curFrame != oldFrame) { // dice just rattled... if (animation.curAnim.curFrame == animation.curAnim.numFrames - 1) { // cock it so that a flat side is facing the ground angle = 0; } else { // cock it randomly angle = FlxG.random.getObject([0, 90, 180, 270]); } facing = FlxG.random.bool() ? FlxObject.LEFT : FlxObject.RIGHT; //super.update(0); } if (y < 310) { // bounce off of back wall y += 2 * (310 - y); velocity.y = -velocity.y; animation.frameIndex = (animation.frameIndex + FlxG.random.int(0, 3)) % 4; facing = FlxG.random.bool() ? FlxObject.LEFT : FlxObject.RIGHT; playDiceSfx(0.6); } z = Math.max(0, z + zVelocity * elapsed); zVelocity = Math.max( -1000, zVelocity + zAccel * elapsed ); } public function tossDice() { animation.frameIndex = FlxG.random.int(0, animation.frames); facing = FlxG.random.bool() ? FlxObject.LEFT : FlxObject.RIGHT; angle = FlxG.random.getObject([0, 90, 180, 270]); z = 120; zVelocity = FlxG.random.float(120, 180); drag.set(0, 0); // update offset based on new Z update(0); } }
argonvile/monster
source/minigame/stair/StairDice.hx
hx
unknown
3,811
package minigame.stair; import minigame.FinalScoreboard; import minigame.MinigameState.denNerf; import flixel.FlxG; import puzzle.Puzzle; /** * The scoreboard which displays at the end of the stair climbing minigame, to * show the player how much money they earned */ class StairFinalScoreboard extends FinalScoreboard { var stairGameState:StairGameState; public function new(stairGameState:StairGameState) { this.stairGameState = stairGameState; super(); } override public function addBonuses() { if (stairGameState.stairStatus0.deliveredChestCount == 0) { addScore("Score", 0); } else if (stairGameState.stairStatus0.deliveredChestCount == 1) { addScore("Score", denNerf(250)); } else { addScore("Score", denNerf(750)); } if (stairGameState.stairStatus0.deliveredChestCount == 2) { addBonus("Victory bonus", denNerf(400)); } if (stairGameState.stairStatus1.deliveredChestCount == 0 && stairGameState.stairStatus1.captureBonus == 0) { addBonus("Flawless bonus", denNerf(600)); } if (stairGameState.stairStatus0.captureBonus > 0) { addBonus("Capture bonus", stairGameState.stairStatus0.captureBonus); } if (_totalReward < denNerf(400)) { // player didn't do very well; give them some compensation in the form of a silly bonus var pityAmount:Int = Puzzle.getSmallestRewardGreaterThan((denNerf(400) - _totalReward) * FlxG.random.float(0.18, 0.54)); var randomBonuses:Array<String> = ["WIFOM bonus", "Stair stamina bonus", "Second place bonus", "Mind reader bonus", "Bad beat bonus", "Pacifist bonus", "Dirty socks bonus", "Fresh breath bonus"]; if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Gay) { randomBonuses.push("Homosexual bonus"); randomBonuses.push("Zero vagina bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Lesbian) { randomBonuses.push("Lesbian bonus"); randomBonuses.push("Zero penis bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Straight) { randomBonuses.push("Heterosexual bonus"); randomBonuses.push("Hooray for boobies bonus"); } else if (PlayerData.sexualPreferenceLabel == PlayerData.SexualPreferenceLabel.Bisexual) { randomBonuses.push("Bisexual bonus"); randomBonuses.push("Hooray for boobies bonus"); } if (PlayerData.gender == PlayerData.Gender.Boy) { randomBonuses.push("Penis bonus"); randomBonuses.push("Bold erection bonus"); } else if (PlayerData.gender == PlayerData.Gender.Girl) { randomBonuses.push("Vagina bonus"); randomBonuses.push("Menstruation bonus"); } addBonus(FlxG.random.getObject(randomBonuses), pityAmount); } } }
argonvile/monster
source/minigame/stair/StairFinalScoreboard.hx
hx
unknown
2,856
package minigame.stair; import minigame.stair.StairGameState.StairStatus; /** * Current state and variables for the stair minigame. Keeps track of things * like whose turn it is, how many chests each player has delivered, and how * many spaces a bug is currently moving. */ class StairGameLogic { var stairGameState:StairGameState; // 0: human; 1: com public var activePlayer:Int = 0; var state:Void->Void; public var extraTurn:Bool = false; public var remainingMoves:Int = 0; public var activeStairStatus:StairStatus; public var otherStairStatus:StairStatus; public var justCaptured:Bool = false; /* * 1: first silver chest obtained * 2: first chest turned in * 3: first gold chest obtained */ private var milestone:Int = 0; public var justReachedMilestone:Bool = false; public var tutorial:Bool = false; public function new(stairGameState:StairGameState) { this.stairGameState = stairGameState; refreshStairStatusHelpers(); } /** * Reset following a tutorial */ public function reset():Void { milestone = 0; tutorial = false; activePlayer = 0; refreshStairStatusHelpers(); } function refreshStairStatusHelpers() { activeStairStatus = [stairGameState.stairStatus0, stairGameState.stairStatus1][activePlayer]; otherStairStatus = [stairGameState.stairStatus1, stairGameState.stairStatus0][activePlayer]; } public function eventMoveCritterFromRoll(args:Array<Dynamic>) { roll(stairGameState.stairStatus0.rollAmount + stairGameState.stairStatus1.rollAmount); } public function roll(rollAmount:Int) { justCaptured = false; justReachedMilestone = false; if (rollAmount == 0 || rollAmount == 4) { extraTurn = true; } var moveAmount:Int = rollAmount == 0 ? 4 : rollAmount; state = characterMovingState; if (!activeStairStatus.hasChest() && activeStairStatus.stairIndex + moveAmount >= 8) { remainingMoves = activeStairStatus.stairIndex + moveAmount - 8; } stairGameState.changeTargetStair(activeStairStatus, activeStairStatus.hasChest() ? -moveAmount : moveAmount); state = characterMovingState; } public function characterMovingState():Void { if (activeStairStatus.critter.isStopped()) { if (activeStairStatus.stairIndex == 0 && activeStairStatus.hasChest()) { extraTurn = false; stairGameState.deliverChest(activeStairStatus); state = waitingForChestDeliveredState; } else if (activeStairStatus.stairIndex == 5 && !activeStairStatus.hasChest()) { stairGameState.giveChest(activeStairStatus); state = waitingForChestGivenState; } else if (activeStairStatus.stairIndex == 8 && !activeStairStatus.hasChest()) { stairGameState.giveChest(activeStairStatus); state = waitingForChestGivenState; } else { if (justCaptured) { state = null; stairGameState._eventStack.addEvent({time:stairGameState._eventStack._time + 2.0, callback:eventNextPlayer}); } else { nextPlayer(); } } } } public function waitingForChestDeliveredState():Void { if (activeStairStatus.critter._bodySprite.animation.curAnim.name == "idle" && !activeStairStatus.hasChest()) { if (activeStairStatus.chest0.z <= 60 && activeStairStatus.chest1.z <= 60) { // both chests delivered? stairGameState.gameOver(); state = null; } else { if (milestone < 2) { milestone = 2; justReachedMilestone = true; } nextPlayer(); } } } public function waitingForChestGivenState():Void { if (activeStairStatus.critter._bodySprite.animation.curAnim.name == "idle" && activeStairStatus.hasChest()) { if (activeStairStatus.chest1._critter == activeStairStatus.critter) { if (milestone < 3) { milestone = 3; justReachedMilestone = true; } } else if (activeStairStatus.chest0._critter == activeStairStatus.critter) { if (milestone < 1) { milestone = 1; justReachedMilestone = true; } } if (remainingMoves == 0) { nextPlayer(); } else { stairGameState.changeTargetStair(activeStairStatus, -remainingMoves); remainingMoves = 0; state = characterMovingState; } } } public function update(elapsed:Float) { if (state != null) { state(); } } public function eventNextPlayer(args:Array<Dynamic>) { nextPlayer(); } public function nextPlayer():Void { state = null; if (!tutorial && stairGameState._gameState < 200) { /* * if the player skips rhydon's explanation, it's possible for a * bug to finish his movement during the odds-and-evens sequence. * if this happens, we just disregard the movement and don't change * player or anything. */ return; } if (extraTurn) { extraTurn = false; stairGameState.showRollAgain(); } else { activePlayer = (activePlayer + 1) % 2; refreshStairStatusHelpers(); stairGameState.showTurnIndicator(); } if (tutorial) { // don't prompt for roll during tutorial. just notify the tutorial that it can continue stairGameState.tutorialFinishedMove(); } else { stairGameState.promptRoll0(); } } public function setActivePlayer(activePlayer:Int) { this.activePlayer = activePlayer; refreshStairStatusHelpers(); stairGameState.showTurnIndicator(); } }
argonvile/monster
source/minigame/stair/StairGameLogic.hx
hx
unknown
5,509
package minigame.stair; import minigame.MinigameState.denNerf; import MmStringTools.*; import critter.Critter; import critter.CritterBody; import critter.SexyAnims; import flixel.FlxG; import flixel.FlxSprite; import flixel.effects.particles.FlxEmitter; import flixel.effects.particles.FlxParticle; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRect; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.ui.FlxButton; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import flixel.util.FlxSpriteUtil; import kludge.BetterFlxRandom; import kludge.FlxSpriteKludge; import kludge.LateFadingFlxParticle; import openfl.utils.Object; import poke.rhyd.RhydonResource; import minigame.MinigameState; import minigame.stair.StairGameState.StairStatus; /** * The FlxState for the stair climbing minigame. * * The stair minigame lasts about 20 turns. Each player tries to get their bug * up and down the stairs before their opponent. The bugs move 1, 2, 3 or 4 * spaces each turn with a sort of rock-paper-scissors mechanism where you need * to outguess your opponent. */ class StairGameState extends MinigameState { public var stairStatus0:StairStatus; public var stairStatus1:StairStatus; private var extraCritters:Array<Critter> = []; public var puzzleArea:FlxRect = FlxRect.get(0, 0, 160, 300); private var leds:FlxSprite; private var confettiParticles:FlxEmitter; private var glowyLights:FlxSprite; private var darkness:FlxSprite; private var darknessTween:FlxTween; public var poofParticles:FlxEmitter; // 0: default; 1: emitting gems from stairs; 2: emitting gems from trophy private var gemMode:Int = 0; public var stairGameLogic:StairGameLogic; private var buttonGroup:WhiteGroup; public var rollHandler:Array<Dynamic>->Void; public var turnIndicator:BouncySprite; public var agent:StairAgent; public var stateFunction:Float->Void; public var stateFunctionTime:Float = 0; // if the user clicks the "help" button, we restore them to their previous state afterwards public var interruptedStateFunction:Float->Void; // if the player is more than 0.5s late, the computer will flagrantly cheat once public var computerCheatsOnce:Bool = false; // the place you'd jump up from to get to the next stair private var stairBot:Array<FlxPoint> = [ FlxPoint.get(206, 251), FlxPoint.get(275, 253 + 15 * 1), FlxPoint.get(359, 251 + 15 * 2), FlxPoint.get(457, 244 + 15 * 3), FlxPoint.get(539, 215 + 15 * 4), FlxPoint.get(610, 182 + 15 * 5), FlxPoint.get(630, 133 + 15 * 6), FlxPoint.get(631, 101 + 15 * 7), FlxPoint.get(632, 63 + 15 * 8), ]; // the place you'd jump down from to get to the previous stair private var stairTop:Array<FlxPoint> = [ FlxPoint.get(170, 220), FlxPoint.get(247, 225 + 15 * 1), FlxPoint.get(319, 230 + 15 * 2), FlxPoint.get(400, 225 + 15 * 3), FlxPoint.get(483, 207 + 15 * 4), FlxPoint.get(561, 179 + 15 * 5), FlxPoint.get(610, 141 + 15 * 6), FlxPoint.get(621, 104 + 15 * 7), FlxPoint.get(622, 64 + 15 * 8), ]; // the out-of-the-way area you go if someone's trying to get by private var stairSafe:Array<FlxPoint> = [ FlxPoint.get(234, 279), FlxPoint.get(304, 271 + 15 * 1), FlxPoint.get(393, 266 + 15 * 2), FlxPoint.get(488, 259 + 15 * 3), FlxPoint.get(579, 219 + 15 * 4), FlxPoint.get(653, 178 + 15 * 5), FlxPoint.get(662, 148 + 15 * 6), FlxPoint.get(670, 97 + 15 * 7), FlxPoint.get(650, 48 + 15 * 8), ]; public var bottomSafe:FlxRect = FlxRect.get(75, 300, 100, 100); private var acceptingInput:Bool = true; private var opponentFrame:RoundedRectangle; private var opponentChatFace:FlxSprite; private var playerFrame:RoundedRectangle; private var playerChatFace:FlxSprite; private var countdownSeconds:Float = 0.77; private var countdownSprite:FlxSprite; private var aiTossTiming:Float = -1; // -1: just toss when the player does private var playerTossTiming:Float = 0; private var firstTurn:Bool = true; private var tutorialBugsMoving:Bool = false; private var tutorialRerollCount:Int = 0; private var button0:FlxButton; private var button1:FlxButton; private var button2:FlxButton; // if something important happens while we're in the help dialog, we queue it up and call it once the dialog closes private var queuedCall:Void->Void = null; // if the user clicks the help button after the computer rolls, that's cheaty. if they do it too much, the computer will cheat private var helpButtonCheatCount:Int = 0; public function new() { super(); description = PlayerData.MINIGAME_DESCRIPTIONS[1]; duration = 3.0; avgReward = 1000; } override public function create():Void { super.create(); Critter.shuffleCritterColors(); if (Critter.CRITTER_COLORS[0].english == Critter.CRITTER_COLORS[1].english) { // disambiguate critter color names for tutorial Critter.CRITTER_COLORS[0].english = substringAfter(Critter.CRITTER_COLORS[0].englishBackup, "/"); Critter.CRITTER_COLORS[1].english = substringAfter(Critter.CRITTER_COLORS[1].englishBackup, "/"); } _backSprites.add(new FlxSprite(188, -5, AssetPaths.stairs__png)); var stairShadow:FlxSprite = new FlxSprite(188, -5, AssetPaths.stair_shadow__png); _shadowGroup._extraShadows.push(stairShadow); turnIndicator = new BouncySprite(0, 0, 6, 2.5, 0); turnIndicator.loadGraphic(AssetPaths.stair_turn_indicator__png, true, 60, 36); turnIndicator.animation.add("default", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 6); turnIndicator.animation.add("reveal", [3, 2, 0], 6, false); turnIndicator.animation.add("hide", [2, 3, 8], 6, false); turnIndicator.animation.add("roll-again", [6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 5, 4, 3, 2, 0, 0], 12, false); turnIndicator.animation.add("invisible", [8], 6, false); turnIndicator.offset.x = 11; turnIndicator._baseOffsetY = 60; turnIndicator.animation.play("invisible"); _midSprites.add(turnIndicator); leds = new FlxSprite(368, 0); leds.loadGraphic(AssetPaths.stair_leds__png, true, 400, 300); leds.animation.add("blink-lo", [0, 2], 3); leds.animation.add("blink-hi", [1, 3], 3); leds.visible = false; _backSprites.add(leds); confettiParticles = new FlxEmitter(0, 0, 12); confettiParticles.launchMode = FlxEmitterMode.SQUARE; confettiParticles.velocity.start.set(FlxPoint.get(-30, -20), FlxPoint.get(30, 0)); confettiParticles.velocity.end.set(FlxPoint.get(0, 20)); confettiParticles.acceleration.start.set(FlxPoint.get(0, 60)); confettiParticles.acceleration.end.set(FlxPoint.get(0, 60)); confettiParticles.alpha.start.set(1.0); confettiParticles.alpha.end.set(0); confettiParticles.lifespan.set(3, 3); insert(members.indexOf(_midSprites) + 1, confettiParticles); for (i in 0...confettiParticles.maxSize) { var particle:LateFadingFlxParticle = new LateFadingFlxParticle(); var frames:Array<Int> = [0, 1, 2, 3, 4, 5]; FlxG.random.shuffle(frames); particle.loadGraphic(AssetPaths.stair_confetti__png, true, 20, 20); particle.animation.add("default", frames, 6); particle.animation.play("default"); particle.maxVelocity.y = 20; particle.flipX = FlxG.random.bool(); particle.exists = false; confettiParticles.add(particle); } poofParticles = new FlxEmitter(0, 0, 23); insert(members.indexOf(_midSprites) + 1, poofParticles); poofParticles.angularVelocity.set(0); poofParticles.launchMode = FlxEmitterMode.CIRCLE; poofParticles.speed.set(30, 60, 0, 0); poofParticles.acceleration.set(0); poofParticles.alpha.start.set(0.5, 1.0); poofParticles.alpha.end.set(0); poofParticles.lifespan.set(0.25, 0.5); for (i in 0...poofParticles.maxSize) { var particle:FlxParticle = new MinRadiusParticle(7); particle.loadGraphic(AssetPaths.poofs_tiny__png, true, 20, 20); particle.flipX = FlxG.random.bool(); particle.animation.frameIndex = FlxG.random.int(0, particle.animation.frames); particle.exists = false; poofParticles.add(particle); } stairStatus0 = new StairStatus(this, 0); addCritter(stairStatus0.critter); stairStatus1 = new StairStatus(this, 1); addCritter(stairStatus1.critter); for (i in 0...8) { var critter:Critter = new Critter(FlxG.random.float(puzzleArea.left, puzzleArea.right), FlxG.random.float(puzzleArea.top, puzzleArea.bottom), _backdrop); critter.setColor(Critter.CRITTER_COLORS[i % 2]); extraCritters.push(critter); addCritter(critter); } darkness = new FlxSprite(); darkness.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK, true); darkness.alpha = 0; _hud.add(darkness); buttonGroup = new WhiteGroup(); button0 = new FlxButton(0, 0); button0.loadGraphic(AssetPaths.stair_choice0__png, true, 768, 118); button0.onDown.callback = button0Down; buttonGroup.add(button0); button1 = new FlxButton(0, 118); button1.loadGraphic(AssetPaths.stair_choice1__png, true, 768, 118); button1.onDown.callback = button1Down; buttonGroup.add(button1); button2 = new FlxButton(0, 236); button2.loadGraphic(AssetPaths.stair_choice2__png, true, 768, 118); button2.onDown.callback = button2Down; buttonGroup.add(button2); buttonGroup.visible = false; _hud.add(buttonGroup); agent = StairAgentDatabase.getAgent(); opponentFrame = new RoundedRectangle(); opponentFrame.relocate(3, FlxG.height - 78, 77, 75, 0xff000000, 0xeeffffff); _hud.add(opponentFrame); opponentChatFace = new FlxSprite(opponentFrame.x + 2, opponentFrame.y + 2); opponentChatFace.loadGraphic(agent.chatAsset, true, 73, 71); opponentChatFace.animation.frameIndex = 4; _hud.add(opponentChatFace); playerFrame = new RoundedRectangle(); playerFrame.relocate(FlxG.width - 81, FlxG.height - 78, 77, 75, 0xff000000, 0xeeffffff); _hud.add(playerFrame); playerChatFace = new FlxSprite(playerFrame.x + 2, playerFrame.y + 2); /* * one might expect "unique" to guarantee stamping doesn't gunk up the original sprite; * but other references to empty_chat will have hands stamped on them unless we set a key */ playerChatFace.loadGraphic(AssetPaths.empty_chat__png, true, 73, 71, false, "3RCU5TZ48D"); playerChatFace.stamp(_handSprite, -50, -70); _hud.add(playerChatFace); _hud.add(_cashWindow); _hud.add(_dialogger); glowyLights = new FlxSprite(); glowyLights.loadGraphic(AssetPaths.stair_colored_spotlights__png, true, 400, 300); glowyLights.visible = false; glowyLights.animation.add("blink-lo", [0, 2, 4, 6, 8, 10], 3); glowyLights.animation.add("blink-hi", [1, 3, 5, 7, 9, 11], 3); countdownSprite = new FlxSprite(334, 136); countdownSprite.loadGraphic(AssetPaths.countdown__png, true, 100, 100); _hud.add(countdownSprite); countdownSprite.exists = false; countdownSprite.visible = false; stairGameLogic = new StairGameLogic(this); _hud.add(_helpButton); if (PlayerData.minigameCount[1] == 0) { // start tutorial var tree:Array<Array<Object>> = []; if (agent.chatAsset == RhydonResource.chat) { // I'm Rhydon; I can explain this tree = TutorialDialog.stairGamePartOneNoHandoff(); } else { var tutorialTree:Array<Array<Object>>; // Let me get Rhydon agent.gameDialog.popRemoteExplanationHandoff(tree, "Rhydon", PlayerData.rhydMale ? PlayerData.Gender.Boy : PlayerData.Gender.Girl); tree.push(["#zzzz04#..."]); tutorialTree = TutorialDialog.stairGamePartOneRemoteHandoff(); tree = DialogTree.prepend(tree, tutorialTree); } launchTutorial(tree); } else { setState(100); } } override public function addCritter(critter:Critter, pushToCritterList:Bool = true) { super.addCritter(critter, pushToCritterList); critter.canDie = false; } override public function getMinigameOpponentDialogClass():Class<Dynamic> { return agent.dialogClass; } private function launchTutorial(tree:Array<Array<Object>>) { stairGameLogic.tutorial = true; opponentChatFace.loadGraphic(RhydonResource.chat, true, 73, 71); opponentChatFace.animation.frameIndex = 4; setStateFunction(waitForTutorialPartOneToEnd); setState(70); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } public function waitForTutorialPartOneToEnd(elapsed:Float):Void { if (!DialogTree.isDialogging(_dialogTree)) { setState(75); setStateFunction(null); rollHandler = tutorialPartOneRoll; promptRoll1(); } } public function tutorialPartOneRoll(args:Array<Dynamic>) { if (DialogTree.isDialogging(_dialogTree)) { queuedCall = tutorialPartTwo; return; } tutorialPartTwo(); } public function tutorialPartTwo():Void { var tree:Array<Array<Object>> = TutorialDialog.stairGamePartTwo(stairStatus0.rollAmount + stairStatus1.rollAmount); setState(80); rollHandler = tutorialPartTwoRoll; _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setStateFunction(waitForTutorialPartTwoToEnd); } public function waitForTutorialPartTwoToEnd(elapsed:Float):Void { if (!DialogTree.isDialogging(_dialogTree)) { setState(85); setStateFunction(null); rollHandler = tutorialPartTwoRoll; promptRoll1(); } } public function tutorialPartTwoRoll(args:Array<Dynamic>) { if (DialogTree.isDialogging(_dialogTree)) { queuedCall = tutorialPartThree; return; } tutorialPartThree(); } public function tutorialPartThree():Void { var tree:Array<Array<Object>> = TutorialDialog.stairGamePartThree(stairStatus0.rollAmount + stairStatus1.rollAmount); setState(90); setStateFunction(null); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } private function resetTutorialStuff() { _eventStack.reset(); resetStairStatus(stairStatus0); resetStairStatus(stairStatus1); hideTurnIndicator(); stairGameLogic.reset(); countdownSeconds = 0.77; opponentChatFace.loadGraphic(agent.chatAsset, true, 73, 71); } override public function dialogTreeCallback(msg:String):String { super.dialogTreeCallback(msg); if (msg == "%skip-tutorial%") { setState(150); setStateFunction(waitForGameStartState); resetTutorialStuff(); } if (msg == "%skip-minigame%") { setState(500); } if (msg == "%restart-tutorial%") { var tree:Array<Array<Object>> = TutorialDialog.stairGamePartOneAbruptHandoff(); launchTutorial(tree); } if (msg == "%hide-turn-indicator%") { turnIndicator.animation.play("invisible"); } if (msg == "%reset-bugs%") { resetTutorialStuff(); } if (StringTools.startsWith(msg, "%roll-")) { var manOrCom:String = msg.substr(6, 3); var roll:Int = Std.parseInt(msg.substr(10, 1)); if (manOrCom == "man") { stairStatus0.rollDice(roll); } else if (manOrCom == "com") { stairStatus1.rollDice(roll); } } if (msg == "%pick-up-dice%") { stairStatus0.unrollDice(); stairStatus1.unrollDice(); } if (msg == "%wait-for-bugs%") { if (tutorialBugsMoving) { _dialogger._canDismiss = false; } } if (StringTools.startsWith(msg, "%move-") || StringTools.startsWith(msg, "%rmov-")) { tutorialBugsMoving = true; if (StringTools.startsWith(msg, "%move-")) { tutorialMove(msg); } if (StringTools.startsWith(msg, "%rmov-")) { _eventStack.addEvent({time:_eventStack._time + 1.7, callback:tutorialMoveEvent, args:[msg]}); } } return null; } public function tutorialFinishedMove() { // player can't dismiss dialog until the bugs finish moving tutorialBugsMoving = false; _dialogger._canDismiss = true; } public function tutorialMoveEvent(args:Dynamic) { var msg:String = args[0]; tutorialMove(msg); } public function tutorialMove(msg:String) { var manOrCom:String = msg.substr(6, 3); var dist:Int = Std.parseInt(msg.substr(10, 1)); if (manOrCom == "man") { if (stairGameLogic.activePlayer != 0) { stairGameLogic.setActivePlayer(0); } hideTurnIndicator(); stairGameLogic.roll(dist); } else if (manOrCom == "com") { if (stairGameLogic.activePlayer != 1) { stairGameLogic.setActivePlayer(1); } hideTurnIndicator(); stairGameLogic.roll(dist); } } /** * Calculate the AI's move. * * This is very similar to a bimatrix game which can be solved perfectly. * But that's no fun, so each AI opponent also has slight weaknesses and * preferences * * @return The number of movement dice the AI will throw (0, 1 or 2) */ public function getAiTossAmount():Int { if (rollHandler == eventAdjustStartPlayerFromRoll) { if (computerCheatsOnce) { computerCheatsOnce = false; return stairStatus0.rollAmount == 1 ? 1 : FlxG.random.getObject([0, 2]); } return FlxG.random.getObject([0, 1, 2], agent.oddsEvens); } var rewardMatrix:Array<Array<Float>> = [ [7, 1, 2], [1, 2, 3], [2, 3, 7], ]; var stairStatus:StairStatus = stairGameLogic.activeStairStatus; var otherStairStatus:StairStatus = getOtherStairStatus(stairStatus.critter); // is the active player really close to the bottom? if (stairStatus.hasChest() && stairStatus.stairIndex <= 6) { var maxMove:Int = stairStatus.stairIndex; for (i in 0...3) { for (j in 0...3) { if (rewardMatrix[i][j] >= maxMove) { rewardMatrix[i][j] += 50; } } } } // can the active player hit the shortcut? if (!stairStatus.hasChest() && stairStatus.stairIndex >= 1 && stairStatus.stairIndex <= 4) { tweakRewardMatrix(rewardMatrix, 5 - stairStatus.stairIndex, 6); } // can the active player capture the opponent? if (otherStairStatus.stairIndex > 0) { var captureIncentive:Int = otherStairStatus.hasChest() ? 16 - otherStairStatus.stairIndex : otherStairStatus.stairIndex; captureIncentive += 3; // you also get a bonus turn... // where will I be if I move one square... for (roll in 1...5) { if (destinationSquare(stairStatus, roll) == otherStairStatus.stairIndex) { tweakRewardMatrix(rewardMatrix, roll, captureIncentive); } } } /* * Add tiny variance to the reward matrix; otherwise in a trivial case (such as when a critter is one square from the goal) * it will always roll 0, which is optimal but still a bit robotic */ for (i in 0...3) { for (j in 0...3) { rewardMatrix[i][j] += FlxG.random.float(0, agent.fuzzFactor); } } var strategy:Array<Float> = []; if (computerCheatsOnce) { computerCheatsOnce = false; var humanRoll:Int = stairStatus0.rollAmount; strategy = [0, 0, 0]; var bestMove = 0; if (stairGameLogic.activePlayer == 0) { // it's the human's turn; minimize the score for (i in 1...3) { if (rewardMatrix[humanRoll][i] < rewardMatrix[humanRoll][bestMove]) { bestMove = i; } } } else { // it's the computer's turn; maximize the score for (i in 1...3) { if (rewardMatrix[i][humanRoll] > rewardMatrix[bestMove][humanRoll]) { bestMove = i; } } } strategy[bestMove] = 1.0; } else { rewardMatrix[0][0] *= agent.diminishedZeroZero; var smartStrategy:Array<Float>; var dumbStrategy:Array<Float>; if (stairGameLogic.activePlayer == 0) { // it's the human's turn; minimize the score smartStrategy = MatrixSolver.getStrategyP1(rewardMatrix); dumbStrategy = MatrixSolver.getDumbStrategyP1(rewardMatrix); } else { // it's the computer's turn; maximize the score smartStrategy = MatrixSolver.getStrategyP2(rewardMatrix); dumbStrategy = MatrixSolver.getDumbStrategyP2(rewardMatrix); } for (i in 0...smartStrategy.length) { strategy[i] = smartStrategy[i] * (1 - agent.dumbness) + dumbStrategy[i] * agent.dumbness; } var maxIndex0:Int = 0; { var max:Float = strategy[0]; for (i in 1...strategy.length) { if (strategy[i] > max) { max = strategy[i]; maxIndex0 = i; } } } strategy[maxIndex0] *= agent.bias0; var maxIndex1:Int = 0; { var max:Float = strategy[0]; for (i in 1...strategy.length) { if (i != maxIndex0 && strategy[i] > max) { max = strategy[i]; maxIndex1 = i; } } } strategy[maxIndex1] *= agent.bias1; MatrixSolver.normalizeStrategy(strategy); } var result:Int = FlxG.random.getObject([0, 1, 2], strategy); return result; } private static function destinationSquare(stairStatus:StairStatus, roll:Int) { var target:Int = stairStatus.stairIndex + (stairStatus.hasChest() ? -1 * roll : 1 * roll); return target > 8 ? 16 - target : target; } private static function tweakRewardMatrix(rewardMatrix:Array<Array<Float>>, roll:Int, amount:Int) { for (i in 0...3) { var j = roll - i; if (j >= 0 && j <= 2) { rewardMatrix[i][j] += amount; } } if (roll == 4) { rewardMatrix[0][0] += amount; } } public function handlePlayerToss(playerTossAmount:Int):Void { buttonGroup.visible = false; stairStatus0.rollDice(playerTossAmount); playerTossTiming = stateFunctionTime; if (aiTossTiming == -1) { var delay:Float = FlxG.random.float(0.1, 0.25); if (computerCheatsOnce) { // flagrantly cheat delay += 0.75; } _eventStack.addEvent({time:_eventStack._time + delay, callback:eventHandleAiToss}); } } public function eventHandleAiToss(args:Array<Dynamic>) { handleAiToss(); } public function showRollAgain() { turnIndicator.animation.play("roll-again"); emitPoofParticles(turnIndicator.x - turnIndicator.offset.x + 32, turnIndicator.y - turnIndicator.offset.y + 14); _eventStack.addEvent({time:_eventStack._time + 3.0, callback:eventPlayTurnIndicatorAnim, args:["default"]}); SoundStackingFix.play(AssetPaths.roll_again_00cc__mp3); } public function showTurnIndicator() { turnIndicator.animation.play("reveal"); _eventStack.addEvent({time:_eventStack._time + 1.0, callback:eventPlayTurnIndicatorAnim, args:["default"]}); } public function eventHideTurnIndicator(args:Array<Dynamic>) { hideTurnIndicator(); } public function hideTurnIndicator() { if (_eventStack.isEventScheduled(eventPlayTurnIndicatorAnim)) { _eventStack.removeEvent(eventPlayTurnIndicatorAnim); } if (turnIndicator.animation.name == "invisible") { // already hidden... } else { turnIndicator.animation.play("hide"); } } public function eventPlayTurnIndicatorAnim(args:Array<Dynamic>) { var animName:String = args[0]; turnIndicator.animation.play(animName); } public function promptRoll0():Void { if (DialogTree.isDialogging(_dialogTree)) { // currently dialogging; queue this up and we'll do it later queuedCall = promptRoll0; return; } var tree:Array<Array<Object>> = []; if (_gameState < 150) { // still in tutorial; user clicked help button, so now they're being reprompted TutorialDialog.stairGameRepromptDice(tree); } else if (rollHandler == eventAdjustStartPlayerFromRoll) { agent.gameDialog.popStairOddsEvens(tree); } else if (firstTurn) { firstTurn = false; if (stairGameLogic.activePlayer == 0) { agent.gameDialog.popStairPlayerStarts(tree); } else { agent.gameDialog.popStairComputerStarts(tree); } } else if (stairGameLogic.justCaptured && stairGameLogic.activePlayer == 0) { agent.gameDialog.popStairCapturedComputer(tree, stairStatus0.rollAmount, stairStatus1.rollAmount); } else if (stairGameLogic.justCaptured && stairGameLogic.activePlayer == 1) { agent.gameDialog.popStairCapturedHuman(tree, stairStatus0.rollAmount, stairStatus1.rollAmount); } else if (stairGameLogic.justReachedMilestone) { var activeScore:Int = stairGameLogic.activeStairStatus.getScore(); var otherScore:Int = stairGameLogic.otherStairStatus.getScore(); /* * players will average 2.7 squares per turn... if the current player is ahead by a * little, or the player who just went is ahead by a lot, we comment on it */ if (activeScore > otherScore - 1.4 + 2.7 || otherScore > activeScore + 1.4 + 2.7) { if (stairStatus0.getScore() > stairStatus1.getScore()) { agent.gameDialog.popLosing(tree, PlayerData.name, PlayerData.gender); } else { agent.gameDialog.popWinning(tree); } } else { agent.gameDialog.popCloseGame(tree); } } else { agent.gameDialog.popStairReady(tree); } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setStateFunction(waitForReadyPromptState); } public function setStateFunction(stateFunction:Float->Void) { this.stateFunction = stateFunction; this.stateFunctionTime = 0; } public function waitForGameStartState(elapsed:Float):Void { if (!DialogTree.isDialogging(_dialogTree)) { setStateFunction(null); rollHandler = eventAdjustStartPlayerFromRoll; promptRoll0(); } } public function waitForReadyPromptState(elapsed:Float):Void { if (!DialogTree.isDialogging(_dialogTree)) { promptRoll1(); } } public function doCountdownState(elapsed:Float):Void { var oldIndex:Int = countdownSprite.animation.frameIndex; countdownSprite.animation.frameIndex = Std.int(FlxMath.bound(stateFunctionTime / countdownSeconds, 0, 3)); countdownSprite.visible = true; if (countdownSprite.animation.frameIndex == 3 && countdownSprite.exists) { countdownSprite.exists = false; countdownSprite.visible = false; } else if (oldIndex != countdownSprite.animation.frameIndex) { FlxTween.tween(countdownSprite.scale, {x:1.33, y:0.75}, 0.1, {ease:FlxEase.cubeInOut}); FlxTween.tween(countdownSprite.scale, {x:0.75, y:1.33}, 0.1, {ease:FlxEase.cubeInOut, startDelay:0.1}); FlxTween.tween(countdownSprite.scale, {x:1, y:1}, 0.1, {ease:FlxEase.cubeInOut, startDelay:0.2}); if (countdownSprite.animation.frameIndex < 3) { SoundStackingFix.play(AssetPaths.countdown_00c6__mp3); } if (countdownSprite.animation.frameIndex >= 1) { acceptingInput = true; } } if (aiTossTiming >= 0) { // ordinary timing if (stateFunctionTime > aiTossTiming && stateFunctionTime - elapsed <= aiTossTiming) { handleAiToss(); } } else if (aiTossTiming == -1) { // wait for human; they cheated? } if (stairStatus0.isDiceRolled() && stairStatus1.isDiceRolled()) { countdownSprite.exists = false; countdownSprite.visible = false; var playerLate:Bool = playerTossTiming >= countdownSeconds * 3 + 0.440; if (playerLate) { // reset the countdown timer; player was too late countdownSeconds = 0.90; } else { // shorten the countdown timer a little countdownSeconds = FlxMath.bound(countdownSeconds * 0.94, 0.44, 1.00); } if (playerLate && aiTossTiming >= 0) { _eventStack.addEvent({time:_eventStack._time + 1.7, callback:eventReroll}); } else { _eventStack.addEvent({time:_eventStack._time + 1.7, callback:rollHandler}); if (turnIndicator.animation.name == "hide" || turnIndicator.animation.name == "invisible") { // don't hide turn indicator; already hidden } else { _eventStack.addEvent({time:_eventStack._time + 0.5, callback:eventHideTurnIndicator}); } } setStateFunction(null); } } public function eventReroll(args:Array<Dynamic>):Void { // computer player picks up dice... stairStatus1.unrollDice(); var tree:Array<Array<Object>>; if (_gameState < 150) { // reroll during tutorial... don't punish it setStateFunction(null); tree = TutorialDialog.stairGameReroll(tutorialRerollCount++); if (_gameState == 75) { setState(72); } else if (_gameState == 85) { setState(82); } } else { computerCheatsOnce = true; tree = []; agent.gameDialog.popStairCheat(tree); setStateFunction(waitForReadyPromptState); } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); } public function handleAiToss():Void { stairStatus1.rollDice(getAiTossAmount()); opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.neutralFaces); } public function promptRoll1():Void { stairStatus0.unrollDice(); stairStatus1.unrollDice(); opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.thinkyFaces); buttonGroup.visible = true; buttonGroup._whiteness = 1.0; FlxTween.tween(buttonGroup, {_whiteness:0.0}, 1.0); acceptingInput = false; countdownSprite.exists = true; countdownSprite.visible = false; countdownSprite.animation.frameIndex = 3; if (countdownSeconds > 0.77 && _gameState >= 150) { // oops! busted for cheating. let's have the AI just wait for the player aiTossTiming = -1; } else { aiTossTiming = countdownSeconds * 3 + FlxG.random.float( -0.500, 0.100); } setStateFunction(doCountdownState); } public function eventAdjustStartPlayerFromRoll(args:Array<Dynamic>):Void { setState(200); if ((stairStatus0.rollAmount + stairStatus1.rollAmount) % 2 == 1) { // player won odds/evens; set active player to 0 (player) stairGameLogic.setActivePlayer(0); } else { // player won odds/evens; set active player to 0 (player) stairGameLogic.setActivePlayer(1); } rollHandler = stairGameLogic.eventMoveCritterFromRoll; promptRoll0(); } public function button0Down():Void { if (buttonGroup.visible && acceptingInput) { if (FlxG.mouse.y < _helpButton.y + _helpButton.height && FlxG.mouse.x > _helpButton.x) { // mouse is over help button } else { handlePlayerToss(0); } } } public function button1Down():Void { if (buttonGroup.visible && acceptingInput) { handlePlayerToss(1); } } public function button2Down():Void { if (buttonGroup.visible && acceptingInput) { handlePlayerToss(2); } } override public function clickHelp():Void { super.clickHelp(); if (stateFunction == doCountdownState) { countdownSprite.visible = false; buttonGroup.visible = false; } interruptedStateFunction = stateFunction; setStateFunction(waitForHelpDismissedState); } public function waitForHelpDismissedState(elapsed:Float) { if (!DialogTree.isDialogging(_dialogTree)) { if (interruptedStateFunction == doCountdownState) { if (helpButtonCheatCount > 0) { // once is an accident, but 2-3 times means they're trying to cheat computerCheatsOnce = true; countdownSeconds = 0.90; } helpButtonCheatCount++; promptRoll0(); } interruptedStateFunction = null; } } override public function update(elapsed:Float):Void { super.update(elapsed); stairGameLogic.update(elapsed); if (stateFunction != null) { stateFunctionTime += elapsed; stateFunction(elapsed); } if (DialogTree.isDialogging(_dialogTree)) { playerFrame.visible = false; playerChatFace.visible = false; } else { playerFrame.visible = true; playerChatFace.visible = true; } if (stairGameLogic.activePlayer == 0) { turnIndicator.x = stairStatus0.critter._headSprite.x; turnIndicator.y = stairStatus0.critter._headSprite.y; turnIndicator.setBaseOffsetY(60 + stairStatus0.critter.z); } else { turnIndicator.x = stairStatus1.critter._headSprite.x; turnIndicator.y = stairStatus1.critter._headSprite.y; turnIndicator.setBaseOffsetY(60 + stairStatus1.critter.z); } for (critter in extraCritters) { if (!isInPuzzleArea(critter)) { critter.setIdle(); critter._eventStack.reset(); if (SexyAnims.isLinked(critter)) { SexyAnims.unlinkCritterAndMakeGroupIdle(critter); } // critter should run back to the puzzle area critter.runTo(FlxG.random.float(puzzleArea.left + 10, puzzleArea.right - 10), FlxG.random.float(puzzleArea.top + 10, puzzleArea.bottom - 10)); } } if (darkness.alpha > 0) { glowyLights.update(elapsed); if (glowyLights.animation.name != null) { FlxSpriteUtil.fill(darkness, FlxColor.BLACK); darkness.stamp(glowyLights, 368, 0); } } updateSexyTimer(elapsed); if (button0.visible && button0.animation.frameIndex == 1 && FlxG.mouse.y < _helpButton.y + _helpButton.height && FlxG.mouse.x > _helpButton.x) { // user is mousing over the help button, but it also intersects button0's rectangle... un-highlight button0 button0.status = FlxButton.NORMAL; button0.animation.frameIndex = 0; } // if the critters are both on stair 1-8 together... and they're colliding... if (FlxSpriteKludge.overlap(stairStatus0.critter._targetSprite, stairStatus1.critter._targetSprite) && stairStatus0.stairIndex == stairStatus1.stairIndex && stairStatus0.stairIndex > 0) { if (shouldCapture(stairStatus0, stairStatus1)) { // we're capturing; other critter stays put } else { // the other critter gets out of the way moveOutOfWay(getOtherStairStatus(stairGameLogic.activeStairStatus.critter).critter, null); } } if ((_gameState == 72 || _gameState == 82) && !DialogTree.isDialogging(_dialogTree)) { if (_gameState == 72) { setState(75); } else if (_gameState == 82) { setState(85); } setStateFunction(null); promptRoll1(); } if (_gameState == 90 && !DialogTree.isDialogging(_dialogTree)) { setState(95); } if (_gameState == 95 || _gameState == 100) { var tree:Array<Array<Object>> = []; if (_gameState == 95) { agent.gameDialog.popPostTutorialGameStartQuery(tree, description); } else { handleGameAnnouncement(tree); agent.gameDialog.popGameStartQuery(tree); } setStateFunction(waitForGameStartState); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setState(150); } if (_gameState == 500) { var tree:Array<Array<Object>> = agent.gameDialog.popSkipMinigame(); _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setStateFunction(null); setState(505); } if (_gameState == 505) { if (!DialogTree.isDialogging(_dialogTree)) { if (!PlayerData.playerIsInDen) { // i award you no points and may god have mercy on your soul payMinigameReward(0); } exitMinigameState(); return; } } if (queuedCall != null && !DialogTree.isDialogging(_dialogTree)) { queuedCall(); queuedCall = null; } } public function deliverChest(stairStatus:StairStatus) { stairStatus.deliveredChestCount++; var time:Float = _eventStack._time; _eventStack.addEvent({time:time, callback:eventConfetti, args:[stairStatus]}); _eventStack.addEvent({time:time += 0.1, callback:eventCritterImmovable, args:[stairStatus, true]}); _eventStack.addEvent({time:time += 0.1, callback:eventPlayAnim, args:[stairStatus, "look-up"]}); _eventStack.addEvent({time:time += 1.3, callback:eventPlayAnim, args:[stairStatus, FlxG.random.getObject(["idle-happy0", "idle-happy1", "idle-happy2"])]}); _eventStack.addEvent({time:time += 0.5, callback:eventChestToTrophy, args:[stairStatus]}); _eventStack.addEvent({time:time += 0.1, callback:eventCritterImmovable, args:[stairStatus, false]}); _eventStack.addEvent({time:time += 0.2, callback:eventOpenDeliveredChest, args:[stairStatus, stairStatus.getCarriedChest()]}); if (stairStatus == stairStatus1) { opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.goodFaces); } } function eventCritterImmovable(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; var immovable:Bool = args[1]; stairStatus.critter.setImmovable(immovable); } public function giveChest(stairStatus:StairStatus) { var time:Float = _eventStack._time; _eventStack.addEvent({time:time, callback:eventBlinkOn, args:[stairStatus]}); _eventStack.addEvent({time:time += 1.0, callback:eventPlayAnim, args:[stairStatus, FlxG.random.getObject(["idle-happy0", "idle-happy1", "idle-happy2"])]}); _eventStack.addEvent({time:time += 0.5, callback:eventChestToCritter, args:[stairStatus]}); _eventStack.addEvent({time:time += 1.5, callback:eventBlinkOff, args:[stairStatus]}); if (stairStatus == stairStatus1) { opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.goodFaces); } } public function eventChestToTrophy(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; var chest:Chest = stairStatus.getCarriedChest(); chest._critter = null; // emit poof particles at old location... emitPoofParticlesFromChest(stairStatus.chest0._chestSprite); chest._chestSprite.animation.frameIndex -= chest._chestSprite.animation.frameIndex % 8; if (chest == stairStatus.chest0) { chest._chestSprite.setPosition(stairStatus.trophyPlatform.x + 8, stairStatus.trophyPlatform.y + 31); } else { chest._chestSprite.setPosition(stairStatus.trophyPlatform.x + 28, stairStatus.trophyPlatform.y + 21); } chest.z = 15; chest.shadow.groundZ = 15; // emit poof particles at new location, too... emitPoofParticlesFromChest(chest._chestSprite); SoundStackingFix.play(AssetPaths.chest_to_platform_0063_0093__mp3); } public function eventChestToCritter(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; var chest:Chest; if (stairStatus.chest0.z > 60) { chest = stairStatus.chest0; } else { chest = stairStatus.chest1; } chest._critter = stairStatus.critter; stairStatus.critter; // emit poof particles at old location... emitPoofParticlesFromChest(chest._chestSprite); chest.update(0); // emit poof particles at new location, too... emitPoofParticlesFromChest(chest._chestSprite); SoundStackingFix.play(AssetPaths.chest_to_critter_0076_0093__mp3); } public function eventPlayAnim(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; var animName:String = args[1]; stairStatus.critter.playAnim(animName); } public function eventBlinkOff(args:Array<Dynamic>) { leds.visible = false; glowyLights.animation.stop(); FlxTweenUtil.retween(darknessTween, darkness, {alpha:0}, 1.5); } public function eventBlinkOn(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; leds.visible = true; FlxTweenUtil.retween(darknessTween, darkness, {alpha:0.4}, 0.1); SoundStackingFix.play(AssetPaths.chest_fanfare_00c3__mp3); if (stairStatus.stairIndex <= 6) { // light up lower platform leds.animation.play("blink-lo"); glowyLights.animation.play("blink-lo"); } else { // light up upper platform leds.animation.play("blink-hi"); glowyLights.animation.play("blink-hi"); } } public function eventConfetti(args:Array<Dynamic>) { var stairStatus:StairStatus = args[0]; confettiParticles.setPosition(stairStatus.critter._soulSprite.x + stairStatus.critter._soulSprite.width / 2, stairStatus.critter._soulSprite.y - stairStatus.critter.z - 40); SoundStackingFix.play(AssetPaths.confetti_0029__mp3); for (i in 0...10) { confettiParticles.start(true, 0, 1); var particle:LateFadingFlxParticle = cast(confettiParticles.emitParticle(), LateFadingFlxParticle); particle.setPosition(particle.x + FlxG.random.float( -10, 10), particle.y + FlxG.random.float( -10, 10)); particle.velocity.x += -45 + 10 * i; particle.enableLateFade(3); particle.drag.set(40, 40); particle.angle = FlxG.random.getObject([0, 90, 180, 270]); FlxSpriteKludge.unfuckParticle(particle); confettiParticles.emitting = false; } } public function isInPuzzleArea(critter:Critter) { return isCoordInPuzzleArea(critter._soulSprite.x, critter._soulSprite.y) || isCoordInPuzzleArea(critter._targetSprite.x, critter._targetSprite.y); } function isCoordInPuzzleArea(x:Float, y:Float) { return FlxMath.pointInFlxRect(x, y, puzzleArea); } public function changeTargetStair(stairStatus:StairStatus, dir:Int) { stairStatus.targetStairIndex = Std.int(FlxMath.bound(stairStatus.targetStairIndex + dir, 0, 8)); if (stairStatus.stairIndex < stairStatus.targetStairIndex && stairStatus.critter._runToCallback == null) { goUpStair(stairStatus); } else if (stairStatus.stairIndex > stairStatus.targetStairIndex && stairStatus.critter._runToCallback == null) { goDownStair(stairStatus); } } function goUpStair(stairStatus:StairStatus) { runToStairBottom(stairStatus.critter); } function goDownStair(stairStatus:StairStatus) { runToStairTop(stairStatus.critter); } private function getStairStatus(critter:Critter):StairStatus { return critter == stairStatus0.critter ? stairStatus0 : stairStatus1; } private function getOtherStairStatus(critter:Critter):StairStatus { return critter == stairStatus0.critter ? stairStatus1 : stairStatus0; } public function moveOutOfWay(critter:Critter, runToCallback:Critter->Void) { var stairStatus:StairStatus = getStairStatus(critter); critter.runTo(stairSafe[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - critter._targetSprite.height / 2, runToCallback); } public function hopDown(critter:Critter) { var stairStatus:StairStatus = getStairStatus(critter); var otherStairStatus:StairStatus = getOtherStairStatus(critter); stairStatus.stairIndex--; if (stairStatus.stairIndex == 0) { critter.permanentlyImmovable = false; } if (shouldCapture(stairStatus, otherStairStatus)) { moveOutOfWay(otherStairStatus.critter, null); critter.jumpTo(stairSafe[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - critter._targetSprite.height / 2, stairStatus.stairIndex * 15, knockAway); } else { var runToCallback:Critter->Void = null; if (stairStatus.targetStairIndex < stairStatus.stairIndex) { runToCallback = runToStairTop; } else if (stairStatus.stairIndex == 0) { runToCallback = runOutOfWay; } critter.jumpTo(stairBot[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairBot[stairStatus.stairIndex].y - critter._targetSprite.height / 2, stairStatus.stairIndex * 15, runToCallback); } } public function runOutOfWay(critter:Critter) { critter.runTo(FlxG.random.float(bottomSafe.left, bottomSafe.right), FlxG.random.float(bottomSafe.top, bottomSafe.bottom)); } /** * Reset the stair status following the tutorial. */ public function resetStairStatus(stairStatus:StairStatus) { stairStatus.captureBonus = 0; stairStatus.deliveredChestCount = 0; stairStatus.unrollDice(); stairStatus.critter.stop(); stairStatus.critter._runToCallback = null; stairStatus.critter._eventStack.reset(); if (stairStatus.stairIndex > 0) { stairStatus.critter.runTo(stairSafe[stairStatus.stairIndex].x - stairStatus.critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - stairStatus.critter._targetSprite.height / 2, eventHopOff); } stairStatus.targetStairIndex = 0; if (stairStatus.chest0._critter == stairStatus.critter) { SoundStackingFix.play(AssetPaths.chest_to_platform_0063_0093__mp3); emitPoofParticlesFromChest(stairStatus.chest0._chestSprite); stairStatus.chest0.destroy(); stairStatus.makeChest0(); stairStatus.chest0.update(0); emitPoofParticlesFromChest(stairStatus.chest0._chestSprite); } } public function eventHopOff(critter:Critter) { var stairStatus:StairStatus = getStairStatus(critter); stairStatus.stairIndex = 0; stairStatus.targetStairIndex = 0; critter.jumpTo(critter._soulSprite.x + 50, critter._soulSprite.y + 50, 0); swapCritter(stairStatus); } public function knockAway(critter:Critter) { stairGameLogic.extraTurn = true; stairGameLogic.justCaptured = true; var stairStatus = getStairStatus(critter); var otherStairStatus = getOtherStairStatus(critter); otherStairStatus.targetStairIndex = 0; otherStairStatus.stairIndex = 0; otherStairStatus.critter.jumpTo(otherStairStatus.critter._soulSprite.x + 50, otherStairStatus.critter._soulSprite.y + 50, 0); otherStairStatus.critter.updateMovingPrefix("tumble"); critter.runTo(stairBot[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairBot[stairStatus.stairIndex].y - critter._targetSprite.height / 2); SoundStackingFix.play(AssetPaths.swipe_0057__mp3); if (critter == stairStatus0.critter) { opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.badFaces); } else { opponentChatFace.animation.frameIndex = FlxG.random.getObject(agent.goodFaces); } if (otherStairStatus.hasChest()) { var chest:Chest = otherStairStatus.getCarriedChest(); stairStatus.captureBonus += chest._reward; chest._critter = null; chest._chestSprite.setPosition(stairSafe[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - critter._targetSprite.height / 2); var targetZ:Float = otherStairStatus.chest0.z - 17; var impact:Float = 80; var delay:Float = 80 / otherStairStatus.critter._bodySprite._jumpSpeed; var height:Float = 80 * 80 / 100; FlxTween.tween(chest, { z : otherStairStatus.chest0.z / 2 + targetZ / 2 + height}, delay / 2, { ease:FlxEase.quadOut }); FlxTween.tween(chest, { z : targetZ }, delay / 2, { startDelay:delay / 2, ease:FlxEase.quadIn }); _eventStack.addEvent({time:_eventStack._time + delay, callback:eventOpenDroppedChest, args:[otherStairStatus, chest == otherStairStatus.chest0 ? 0 : 1]}); _eventStack.addEvent({time:_eventStack._time + delay + 0.6, callback:makeNewChest, args:[otherStairStatus, chest == otherStairStatus.chest0 ? 0 : 1]}); } // swap with a different critter swapCritter(otherStairStatus); } private function swapCritter(stairStatus:StairStatus):Void { { stairStatus.critter._eventStack.addEvent({time:stairStatus.critter._eventStack._time + 3.5, callback:eventRunTowardEverybody, args:[stairStatus.critter]}); } var newCritter:Critter = findIdleCritter(stairStatus.critter.getColorIndex()); if (newCritter == null) { // couldn't find an idle critter... everyone's busy? for (critter in extraCritters) { if (critter.getColorIndex() == stairStatus.critter.getColorIndex() && !critter.outCold) { critter.setIdle(); critter._eventStack.reset(); if (SexyAnims.isLinked(critter)) { SexyAnims.unlinkCritterAndMakeGroupIdle(critter); } newCritter = critter; break; } } } if (newCritter == null) { // couldn't find ANY critter... everyone's out cold!? just continue with the same critter } else { extraCritters.remove(newCritter); newCritter.idleMove = false; newCritter.runTo(FlxG.random.float(bottomSafe.left, bottomSafe.right), FlxG.random.float(bottomSafe.top, bottomSafe.bottom)); stairStatus.critter = newCritter; } } public function eventRunTowardEverybody(args:Array<Dynamic>):Void { var critter:Critter = args[0]; runTowardEverybody(critter); } public function runTowardEverybody(critter:Critter) { // final stop; then stop running if (critter == stairStatus0.critter || critter == stairStatus1.critter) { // go sit next to the puzzle; we couldn't find anybody to swap with critter.runTo(FlxG.random.float(bottomSafe.left, bottomSafe.right), FlxG.random.float(bottomSafe.top, bottomSafe.bottom)); critter._eventStack.reset(); } else { // rejoin everybody; this critter no longer participates in the game critter.runTo(FlxG.random.float(puzzleArea.left, puzzleArea.right), FlxG.random.float(puzzleArea.top * 0.5 + puzzleArea.bottom * 0.5, puzzleArea.bottom), rejoinCritters); critter._eventStack.reset(); } // run to the left and upward, without cutting across the giant structure if (critter._soulSprite.x >= 260) critter.insertWaypoint(160, 296); if (critter._soulSprite.x >= 390) critter.insertWaypoint(270, 337); if (critter._soulSprite.x >= 500) critter.insertWaypoint(400, 357); if (critter._soulSprite.x >= 590) critter.insertWaypoint(510, 364); if (critter._soulSprite.x >= 660) critter.insertWaypoint(600, 360); } public function rejoinCritters(critter:Critter) { extraCritters.push(critter); critter.idleMove = true; critter.permanentlyImmovable = false; critter.setImmovable(false); } public function eventOpenDroppedChest(args:Array<Dynamic>):Void { var stairStatus:StairStatus = args[0]; var chestIndex:Int = args[1]; var chest:Chest = chestIndex == 0 ? stairStatus.chest0 : stairStatus.chest1; chest.pay(_hud); emitGemsInMode(chest, 1); } public function emitGemsInMode(chest:Chest, gemMode:Int) { this.gemMode = gemMode; emitGems(chest); this.gemMode = 0; } public function eventOpenDeliveredChest(args:Array<Dynamic>):Void { var stairStatus:StairStatus = args[0]; var chest:Chest = args[1]; chest.destroyAfterPay = false; chest.pay(_hud); emitGemsInMode(chest, 2); } public function makeNewChest(args:Array<Dynamic>):Void { var stairStatus:StairStatus = args[0]; var chestIndex:Int = args[1]; var chest:Chest; if (chestIndex == 0) { chest = stairStatus.makeChest0(); } else { chest = stairStatus.makeChest1(); } chest.update(0); emitPoofParticlesFromChest(chest._chestSprite); SoundStackingFix.play(AssetPaths.chest_to_platform_0063_0093__mp3); } public function runToStairTop(critter:Critter) { var stairStatus:StairStatus = getStairStatus(critter); var runToCallback:Critter->Void = null; if (stairStatus.targetStairIndex < stairStatus.stairIndex) { runToCallback = hopDown; } critter.runTo(stairTop[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairTop[stairStatus.stairIndex].y - critter._targetSprite.height / 2, runToCallback); } public function hopUp(critter:Critter) { var stairStatus:StairStatus = getStairStatus(critter); var otherStairStatus:StairStatus = getOtherStairStatus(critter); stairStatus.stairIndex++; if (shouldCapture(stairStatus, otherStairStatus)) { moveOutOfWay(otherStairStatus.critter, null); critter.jumpTo(stairSafe[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - critter._targetSprite.height / 2, stairStatus.stairIndex * 15, knockAway); } else { critter.jumpTo(stairTop[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairTop[stairStatus.stairIndex].y - critter._targetSprite.height / 2, stairStatus.stairIndex * 15, runToStairBottom); } } public function shouldCapture(stairStatus:StairStatus, otherStairStatus:StairStatus, ?stairOffset:Int = 0):Bool { return otherStairStatus.stairIndex != 0 && stairStatus.stairIndex + stairOffset == otherStairStatus.stairIndex && stairStatus.targetStairIndex == otherStairStatus.targetStairIndex && stairGameLogic.remainingMoves == 0; } public function runToStairBottom(critter:Critter) { var stairStatus:StairStatus = getStairStatus(critter); var otherStairStatus:StairStatus = getOtherStairStatus(critter); if (stairStatus.stairIndex == 0) { critter.permanentlyImmovable = true; } if (shouldCapture(stairStatus, otherStairStatus, 1)) { critter.runTo(stairSafe[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairSafe[stairStatus.stairIndex].y - critter._targetSprite.height / 2, hopUp); } else { var runToCallback:Critter->Void = null; if (stairStatus.targetStairIndex > stairStatus.stairIndex) { runToCallback = hopUp; } critter.runTo(stairBot[stairStatus.stairIndex].x - critter._targetSprite.width / 2, stairBot[stairStatus.stairIndex].y - critter._targetSprite.height / 2, runToCallback); } } function emitPoofParticlesFromChest(chestSprite:FlxSprite):Void { emitPoofParticles(chestSprite.x - chestSprite.offset.x + chestSprite.width / 2 - 10 + 24, chestSprite.y - chestSprite.offset.y + chestSprite.height / 2 - 10 + 46); } function emitPoofParticles(x:Float, y:Float) { poofParticles.setPosition(x, y); poofParticles.start(true, 0, 1); poofParticles.emitParticle(); poofParticles.emitParticle(); poofParticles.emitParticle(); poofParticles.emitParticle(); poofParticles.emitting = false; } override public function emitGem(x:Float, y:Float, z:Float):Gem { var gem:Gem = super.emitGem(x, y, z); if (gemMode == 1) { if (gem.velocity.y <= 8) { gem.groundZ = z; } } else if (gemMode == 2) { if (gem.velocity.x + gem.velocity.y * 2 <= 60) { gem.groundZ = z; } } return gem; } public function gameOver() { if (DialogTree.isDialogging(_dialogTree)) { queuedCall = gameOver; return; } setState(400); finalScoreboard = new StairFinalScoreboard(this); showFinalScoreboard(); var tree:Array<Array<Object>> = []; if (PlayerData.playerIsInDen) { handleDenGameOver(tree, stairStatus0.deliveredChestCount == 2); } else if (stairStatus0.deliveredChestCount == 2) { // player won agent.gameDialog.popPlayerBeatMe(tree, finalScoreboard._totalReward); } else { // player lost agent.gameDialog.popBeatPlayer(tree, finalScoreboard._totalReward); } _dialogTree = new DialogTree(_dialogger, tree, dialogTreeCallback); _dialogTree.go(); setStateFunction(waitForGameOverState); playerChatFace.visible = false; playerFrame.visible = false; opponentChatFace.visible = false; opponentFrame.visible = false; } public function waitForGameOverState(elapsed:Float ) { if (DialogTree.isDialogging(_dialogTree)) { // still dialogging; don't exit } else if (_eventStack._alive) { // still going through events; don't exit } else if (_cashWindow._currentAmount != PlayerData.cash) { // still accumulating cash; don't exit } else { setStateFunction(null); exitMinigameState(); } } override public function destroy():Void { super.destroy(); stairStatus0 = FlxDestroyUtil.destroy(stairStatus0); stairStatus1 = FlxDestroyUtil.destroy(stairStatus1); extraCritters = FlxDestroyUtil.destroyArray(extraCritters); puzzleArea = FlxDestroyUtil.put(puzzleArea); leds = FlxDestroyUtil.destroy(leds); confettiParticles = FlxDestroyUtil.destroy(confettiParticles); glowyLights = FlxDestroyUtil.destroy(glowyLights); darkness = FlxDestroyUtil.destroy(darkness); darknessTween = FlxTweenUtil.destroy(darknessTween); poofParticles = FlxDestroyUtil.destroy(poofParticles); stairGameLogic = null; buttonGroup = FlxDestroyUtil.destroy(buttonGroup); rollHandler = null; turnIndicator = FlxDestroyUtil.destroy(turnIndicator); agent = null; stateFunction = null; interruptedStateFunction = null; stairBot = FlxDestroyUtil.putArray(stairBot); stairTop = FlxDestroyUtil.putArray(stairTop); stairSafe = FlxDestroyUtil.putArray(stairSafe); bottomSafe = FlxDestroyUtil.put(bottomSafe); opponentFrame = FlxDestroyUtil.destroy(opponentFrame); opponentChatFace = FlxDestroyUtil.destroy(opponentChatFace); playerFrame = FlxDestroyUtil.destroy(playerFrame); playerChatFace = FlxDestroyUtil.destroy(playerChatFace); countdownSprite = FlxDestroyUtil.destroy(countdownSprite); button0 = FlxDestroyUtil.destroy(button0); button1 = FlxDestroyUtil.destroy(button1); button2 = FlxDestroyUtil.destroy(button2); queuedCall = null; } } class StairStatus implements IFlxDestroyable { // player 0 (human) is on the right; player 1 (computer) is on the left public static var trophyPlatformPositions:Array<FlxPoint> = [FlxPoint.get(697, 310), FlxPoint.get(0, 320)]; public static var chest0Positions:Array<FlxPoint> = [FlxPoint.get(547, 45 + 15 * 9), FlxPoint.get(575, 16 + 15 * 9)]; public static var chest1Positions:Array<FlxPoint> = [FlxPoint.get(522, 34 + 15 * 9), FlxPoint.get(552, 11 + 15 * 9)]; public static var dicePositions:Array<FlxPoint> = [FlxPoint.get(668, 462), FlxPoint.get(60, 462)]; var playerIndex:Int; var state:StairGameState; public var critter:Critter; public var stairIndex:Int = 0; public var targetStairIndex:Int = 0; public var chest0:Chest; public var chest1:Chest; public var trophyPlatform:FlxSprite; public var dice0Blank:StairDice; public var dice1Blank:StairDice; public var dice0Foot:StairDice; public var dice1Foot:StairDice; public var captureBonus:Int = 0; public var rollAmount:Int = 0; public var deliveredChestCount:Int = 0; public function new(state:StairGameState, playerIndex:Int) { this.state = state; this.playerIndex = playerIndex; critter = new Critter(FlxG.random.float(state.bottomSafe.left, state.bottomSafe.right), FlxG.random.float(state.bottomSafe.top, state.bottomSafe.bottom), state._backdrop); critter.setColor(Critter.CRITTER_COLORS[playerIndex]); critter.idleMove = false; makeChest0(); makeChest1(); trophyPlatform = new FlxSprite(trophyPlatformPositions[playerIndex].x, trophyPlatformPositions[playerIndex].y); Critter.loadPaletteShiftedGraphic(trophyPlatform, Critter.CRITTER_COLORS[playerIndex], AssetPaths.stair_trophy_platform__png); state._backSprites.add(trophyPlatform); var trophyShadow:FlxSprite = new FlxSprite(trophyPlatformPositions[playerIndex].x, trophyPlatformPositions[playerIndex].y, AssetPaths.stair_trophy_platform_shadow__png); state._shadowGroup._extraShadows.push(trophyShadow); dice0Blank = makeDice(AssetPaths.stair_dice_blank0__png); dice1Blank = makeDice(AssetPaths.stair_dice_blank1__png); dice0Foot = makeDice(AssetPaths.stair_dice_foot0__png); dice1Foot = makeDice(AssetPaths.stair_dice_foot1__png); } public function makeChest0():Chest { chest0 = state.addChest(); chest0.increasePlayerCash = false; chest0.shadow = state._shadowGroup.makeShadow(chest0._chestSprite); chest0.shadow.groundZ = 9 * 15; chest0.setReward(denNerf(250)); chest0.z = 15 * 9; chest0._chestSprite.setPosition(chest0Positions[playerIndex].x, chest0Positions[playerIndex].y); return chest0; } public function makeChest1():Chest { chest1 = state.addChest(); chest1.increasePlayerCash = false; chest1.shadow = state._shadowGroup.makeShadow(chest1._chestSprite); chest1.shadow.groundZ = 9 * 15; chest1.setReward(denNerf(500)); chest1.z = 15 * 9; chest1._chestSprite.setPosition(chest1Positions[playerIndex].x, chest1Positions[playerIndex].y); return chest1; } public function unrollDice() { dice0Blank.visible = false; dice1Blank.visible = false; dice0Foot.visible = false; dice1Foot.visible = false; } public function isDiceRolled():Bool { var diceRolledCount:Int = 0; diceRolledCount += dice0Blank.visible ? 1 : 0; diceRolledCount += dice1Blank.visible ? 1 : 0; diceRolledCount += dice0Foot.visible ? 1 : 0; diceRolledCount += dice1Foot.visible ? 1 : 0; return diceRolledCount == 2; } public function rollDice(rollAmount:Int) { this.rollAmount = rollAmount; var dice0:StairDice = rollAmount == 0 ? dice0Blank : dice0Foot; var dice1:StairDice = rollAmount == 0 ? dice1Blank : dice1Foot; if (rollAmount == 1) { if (FlxG.random.bool()) { dice0 = dice0Blank; } else { dice1 = dice1Blank; } } // ensure a maximum two dice are visible at a time; just in case dice0Blank.visible = false; dice1Blank.visible = false; dice0Foot.visible = false; dice1Foot.visible = false; for (dice in [dice0, dice1]) { dice.visible = true; dice.setPosition(dicePositions[playerIndex].x, dicePositions[playerIndex].y); dice.velocity.x = FlxG.random.float( 250, 170); if (playerIndex == 0) { // roll left dice.velocity.x *= -1; } dice.velocity.y = FlxG.random.float( -300, -200); dice.exists = false; // set exists to false so it won't move or anything until it's "tossed" state._eventStack.addEvent({time:state._eventStack._time + FlxG.random.float(0, 0.2), callback:eventTossOneDice, args:[dice]}); } if (state.stairGameLogic.tutorial) { dice0.velocity.y = FlxG.random.float(-260, -240); dice1.velocity.y = FlxG.random.float(-260, -240); } // ensure dice paths don't cross if (dice1.velocity.x > dice0.velocity.x) { dice1.x = dice0.x + 40; } else { dice0.x = dice1.x + 40; } } public function eventTossOneDice(args:Array<Dynamic>) { var dice:StairDice = args[0]; dice.exists = true; dice.tossDice(); if (state.stairGameLogic.tutorial) { dice.z = 100; dice.zVelocity = 150; } dice.y += dice.z; } public function hasChest() { return getCarriedChest() != null; } public function getCarriedChest() { if (chest0._critter == critter) { return chest0; } if (chest1._critter == critter) { return chest1; } return null; } public function getScore() { var score:Int = 0; if (deliveredChestCount == 2) { score += 32; } else if (deliveredChestCount == 1) { score += 16; } else if (deliveredChestCount == 0) { score += 0; } if (getCarriedChest() != null) { score += (16 - stairIndex); } else { score += stairIndex; } return score; } function makeDice(graphic:FlxGraphicAsset):StairDice { var dice:StairDice = new StairDice(graphic); dice.exists = false; state._midSprites.add(dice); state._shadowGroup.makeShadow(dice); return dice; } public function destroy() { critter = FlxDestroyUtil.destroy(critter); chest0 = FlxDestroyUtil.destroy(chest0); chest1 = FlxDestroyUtil.destroy(chest1); trophyPlatform = FlxDestroyUtil.destroy(trophyPlatform); dice0Blank = FlxDestroyUtil.destroy(dice0Blank); dice1Blank = FlxDestroyUtil.destroy(dice1Blank); dice0Foot = FlxDestroyUtil.destroy(dice0Foot); dice1Foot = FlxDestroyUtil.destroy(dice1Foot); } }
argonvile/monster
source/minigame/stair/StairGameState.hx
hx
unknown
63,682
package minigame.tug; import critter.Critter; import flixel.FlxG; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import openfl.display.BitmapData; import openfl.geom.Matrix; import openfl.geom.Rectangle; import minigame.tug.TugGameState.isTugAnim; /** * Graphics and logic for a rope in the tug-of-war minigame */ class Rope extends FlxSprite { var mx:Matrix = new Matrix(); var clip:Rectangle = new Rectangle(); var bounds:Rectangle; var ropePulledGraphic:FlxGraphic = FlxGraphic.fromAssetKey(AssetPaths.rope_pulled__png); var ropeDroopGraphic:FlxGraphic = FlxGraphic.fromAssetKey(AssetPaths.rope_droop__png); var tugRow:TugRow; public function new(tugRow:TugRow) { super(); this.tugRow = tugRow; bounds = new Rectangle(0, 0, 768, 18); offset.y = 3; makeGraphic(Std.int(bounds.width), Std.int(bounds.height), FlxColor.TRANSPARENT); } override public function draw():Void { pixels.fillRect(bounds, FlxColor.TRANSPARENT); drawHalf(tugRow.leftCritters, true); drawHalf(tugRow.rightCritters, false); dirty = true; super.draw(); } /** * Each rope includes of four components -- the droopy part on the left, * the taut part connecting the left bug to the chest, the taut part * connecting the right bug to the chest, and the droopy part on the right * * This function draws the left half, or the right half * * @param critters bugs which are holding their half of the rope * @param left true for the left half of the rope; false for the right */ function drawHalf(critters:Array<Critter>, left:Bool) { var outer:Float = 0; var inner:Float = 0; var ropeY:Float = 0; var graphic:BitmapData = ropeDroopGraphic.bitmap; var i:Int = critters.length - 1; while (i >= -1) { mx.identity(); inner = tugRow.tugChest._chestSprite.x + tugRow.tugChest._chestSprite.width * 0.5 + (left ? -12 : 12); while (i >= 0) { if (isTugAnim(critters[i])) { inner = critters[i]._bodySprite.x + critters[i]._bodySprite.width * 0.5; break; } i--; } if (left && graphic == ropeDroopGraphic.bitmap) { outer = inner - ropeDroopGraphic.width; } else if (!left && graphic == ropeDroopGraphic.bitmap) { mx.scale( -1, 1); mx.translate(graphic.width, 0); outer = 768; } if (left) { if (graphic == ropePulledGraphic.bitmap) { mx.translate(inner - ropePulledGraphic.bitmap.width, ropeY); } else { mx.translate(outer, ropeY); } clip.setTo(outer, 0, inner - outer, bounds.height); } else { mx.translate(inner, ropeY); clip.setTo(inner, 0, outer - inner, bounds.height); } pixels.draw(graphic, mx, null, null, clip); graphic = ropePulledGraphic.bitmap; if (i >= 0) { if (critters[i]._bodySprite.animation.name == "tug-vgood") { ropeY = 6; } else if (critters[i]._bodySprite.animation.name == "tug-good") { ropeY = 1; } else if (critters[i]._bodySprite.animation.name == "tug-bad") { ropeY = 0; } else if (critters[i]._bodySprite.animation.name == "tug-vbad") { ropeY = -1; } } outer = inner; i--; } } override public function destroy():Void { super.destroy(); mx = null; clip = null; bounds = null; ropePulledGraphic = null; ropeDroopGraphic = null; } }
argonvile/monster
source/minigame/tug/Rope.hx
hx
unknown
3,549