From 27f3b0d47b678dc4db33ac5379e1754c6723fa15 Mon Sep 17 00:00:00 2001 From: Melos Han-Tani Date: Sat, 4 Apr 2020 19:53:31 +0900 Subject: [PATCH] global, helper, state code --- intra/src/global/Keys.as | 537 ++++++ intra/src/global/Registry.as | 795 ++++++++ intra/src/helper/ANEFix.as | 161 ++ intra/src/helper/Achievements.as | 255 +++ intra/src/helper/Cutscene.as | 469 +++++ intra/src/helper/DH.as | 630 +++++++ intra/src/helper/EventScripts.as | 569 ++++++ intra/src/helper/Joypad_Config_Group.as | 296 +++ intra/src/helper/Parabola_Thing.as | 108 ++ intra/src/helper/S_NPC.as | 128 ++ intra/src/helper/ScreenFade.as | 175 ++ intra/src/helper/SpriteFactory.as | 540 ++++++ intra/src/helper/SteamThing.as | 18 + intra/src/helper/UI_Offsets.as | 172 ++ intra/src/helper/invertRGB.pbj | Bin 0 -> 245 bytes intra/src/helper/static.pbj | Bin 0 -> 382 bytes intra/src/states/ControlsState.as | 234 +++ intra/src/states/DialogueState.as | 425 +++++ intra/src/states/EndingState.as | 637 +++++++ intra/src/states/IntroScene.as | 127 ++ intra/src/states/MinimapState.as | 239 +++ intra/src/states/MobileConfig.as | 39 + intra/src/states/PauseState.as | 2198 +++++++++++++++++++++++ intra/src/states/PlayState.as | 2075 +++++++++++++++++++++ intra/src/states/PushableFlxState.as | 50 + intra/src/states/RoamState.as | 618 +++++++ intra/src/states/TitleState.as | 1047 +++++++++++ intra/src/states/noairPauseState.as | 1800 +++++++++++++++++++ 28 files changed, 14342 insertions(+) create mode 100644 intra/src/global/Keys.as create mode 100644 intra/src/global/Registry.as create mode 100644 intra/src/helper/ANEFix.as create mode 100644 intra/src/helper/Achievements.as create mode 100644 intra/src/helper/Cutscene.as create mode 100644 intra/src/helper/DH.as create mode 100644 intra/src/helper/EventScripts.as create mode 100644 intra/src/helper/Joypad_Config_Group.as create mode 100644 intra/src/helper/Parabola_Thing.as create mode 100644 intra/src/helper/S_NPC.as create mode 100644 intra/src/helper/ScreenFade.as create mode 100644 intra/src/helper/SpriteFactory.as create mode 100644 intra/src/helper/SteamThing.as create mode 100644 intra/src/helper/UI_Offsets.as create mode 100644 intra/src/helper/invertRGB.pbj create mode 100644 intra/src/helper/static.pbj create mode 100644 intra/src/states/ControlsState.as create mode 100644 intra/src/states/DialogueState.as create mode 100644 intra/src/states/EndingState.as create mode 100644 intra/src/states/IntroScene.as create mode 100644 intra/src/states/MinimapState.as create mode 100644 intra/src/states/MobileConfig.as create mode 100644 intra/src/states/PauseState.as create mode 100644 intra/src/states/PlayState.as create mode 100644 intra/src/states/PushableFlxState.as create mode 100644 intra/src/states/RoamState.as create mode 100644 intra/src/states/TitleState.as create mode 100644 intra/src/states/noairPauseState.as diff --git a/intra/src/global/Keys.as b/intra/src/global/Keys.as new file mode 100644 index 0000000..67e4bcb --- /dev/null +++ b/intra/src/global/Keys.as @@ -0,0 +1,537 @@ +package global +{ + import org.flixel.FlxSprite; + import org.flixel.FlxG; + import org.flixel.system.FlxDebugger; + //import flash.ui.GameInput; + //import flash.events.GameInputEvent; + //import flash.ui.GameInputControl; + //import flash.ui.GameInputDevice; + + /* A handy dandy "sprite" that keeps track of keypresses, + * and allows easy, global modification of what keypresses do what + * (as to welcome alternate control schemes without heavy rewriting!) */ + public class Keys extends FlxSprite + { + + // Read by the game for determinig actions + public var UP:Boolean = false; + public var DOWN:Boolean = false; + public var LEFT:Boolean = false; + public var RIGHT:Boolean = false; + public var JP_RIGHT:Boolean = false; + public var JP_LEFT:Boolean = false; + public var JP_DOWN:Boolean = false; + public var JP_UP:Boolean = false; + public var JR_RIGHT:Boolean = false; + public var JR_LEFT:Boolean = false; + public var JR_UP:Boolean = false; + public var JR_DOWN:Boolean = false; + public var JUST_PRESSED_PAUSE:Boolean = false; + public var JUST_RELEASED_PAUSE:Boolean = false; + public var ACTION_1:Boolean = false; + public var ACTION_2:Boolean = false; + public var JP_ACTION_1:Boolean = false; + public var JP_ACTION_2:Boolean = false; + + + // For joypad crap + public var ALLOW_JP_RIGHT:Boolean = false; + public var ALLOW_JP_LEFT:Boolean = false; + public var ALLOW_JP_DOWN:Boolean = false; + public var ALLOW_JP_UP:Boolean = false; + public var ALLOW_JP_ACTION_1:Boolean = false; + public var ALLOW_JP_ACTION_2:Boolean = false; + public var ALLOW_JP_PAUSE:Boolean = false; + + + // Bools for mobile input + public var SIG_JP_RIGHT:Boolean = false; + public var SIG_JP_LEFT:Boolean = false; + public var SIG_JP_DOWN:Boolean = false; + public var SIG_JP_UP:Boolean = false; + public static var FORCE_ACTION_1:Boolean = false; + public static var FORCE_ACTION_2:Boolean = false; + public static var FORCE_RIGHT:Boolean = false; + public static var FORCE_DOWN:Boolean = false; + public static var FORCE_UP:Boolean = false; + public static var FORCE_LEFT:Boolean = false; + public static var FORCE_PAUSE:Boolean = false; + + + /* Index into the serialized controls array to figure out key bindings */ + public static var IDX_UP:int = 0; + public static var IDX_DOWN:int = 1; + public static var IDX_LEFT:int = 2; + public static var IDX_RIGHT:int = 3; + public static var IDX_ACTION_1:int = 4; + public static var IDX_ACTION_2:int = 5; + public static var IDX_PAUSE:int = 7; + + public function Keys() + { + + //initGameInput(); + super(-5000, 0); + } + + /* + public function initGameInput() { + if (!gameInputInitialized) { + gameInputInitialized = true; + gameInput = new GameInput(); + trace("Initialized gameinput"); + gameInput.addEventListener(GameInputEvent.DEVICE_ADDED, handleDeviceAdded); + gameInput.addEventListener(GameInputEvent.DEVICE_REMOVED, handleDeviceRemovedEvent); + } + } + + public static var gameInputDevice:GameInputDevice; + public static var gameInput:GameInput; + public static var gameInputExists:Boolean = false; + public static var gameInputID:String = ""; + public static var gameInputName:String = ""; + public static var gameInputInitialized:Boolean = false; + + public function handleDeviceAdded(e:GameInputEvent):void { + trace(11111); + if (gameInputExists) return; + gameInputDevice = e.device; + gameInputName = gameInputDevice.name; + gameInputID = gameInputDevice.id; + gameInputExists = true; + trace("Added " + gameInputName+" with ID: " + gameInputID); + } + + public function handleDeviceRemovedEvent(e:GameInputEvent):void { + + trace("Trying to remove " + e.device.name +" with ID: " + e.device.id); + if (e.device.name == gameInputName && e.device.id == gameInputID) { + trace("Removed!"); + gameInputExists = false; + gameInputDevice = null; + } else { + trace("Didn't remove."); + } + } + */ + + + public static var has_joypad:Boolean = false; + public static var nr_axes:int = 0; + public static var nr_btns:int = 0; + + + public static function init_joypad():void { + if (Intra.IS_WINDOWS) { + nr_axes = Main.joy.getTotalAxes(0); + nr_btns = Main.joy.getTotalButtons(0); + trace("Joypad 0 has ", nr_axes, " axes ", nr_btns, " buttons"); + } else if (Intra.IS_MAC) { + + nr_axes = Main.mac_joy_manager.joysticks[0].axes.length; + nr_btns = Main.mac_joy_manager.joysticks[0].buttons.length; + trace("Joypad 0 has ", nr_axes, " axes ", nr_btns, " buttons"); + } + if (nr_axes > 4) nr_axes = 4; + } + + // Give the state of a certain control binding, based on an index into the joybinds array + public static function get_joy_state(idx:int):Boolean { + if (Intra.IS_WINDOWS || Intra.IS_MAC) { + // Hacky way to ignore uninitizliaed controls + if (Registry.joybinds[IDX_ACTION_1] == Registry.joybinds[IDX_DOWN]) { + return false; + } + // axes first (one state for each dir), then buttons + // ID is an axis state + var id:int = Registry.joybinds[idx]; + if (Math.abs(id) - 1 < 2 * nr_axes) { + var axis_state:Number; + var new_id:int = Math.abs(id) - 1; + + if (Intra.IS_WINDOWS) { + axis_state = Main.joy.getAxis(0, int(new_id / 2)); + } else if (Intra.IS_MAC) { + axis_state = Main.mac_joy_manager.joysticks[0].getAxis(int(new_id / 2)); + } + + if (id < 0) { // Threshold is negative + if (axis_state < -0.25) { + return true; + } + } else { + if (axis_state > 0.25) { + return true; + } + } + } else { + var button_state:Boolean; + id = id - 1 - 2 * nr_axes; + if (Intra.IS_WINDOWS) { + return Main.joy.buttonIsDown(0, id); + } else if (Intra.IS_MAC) { + return Main.mac_joy_manager.joysticks[0].getButton(id); + } + + } + } else if (Intra.is_ouya) { + //if (Main.game_input_device != null) { + //var min:Number = Main.game_input_device.getControlAt(Registry.joybinds[idx]).minValue; + //var max:Number = Main.game_input_device.getControlAt(Registry.joybinds[idx]).maxValue; + //var val:Number = Main.game_input_device.getControlAt(Registry.joybinds[idx]).value; + // + // BLIND GUESS!!! + //if (val > min) { + //return true; + //} + //} + //if (idx == IDX_UP) { + //if (joypad.DPAD_UP || joypad.STICK_UP) { + //return true; + //} + //} else if (idx == IDX_RIGHT) { + //return joypad.DPAD_RIGHT || joypad.STICK_RIGHT; + //} else if (idx == IDX_DOWN) { + //return joypad.DPAD_DOWN || joypad.STICK_DOWN; + //} else if (idx == IDX_LEFT) { + //return joypad.DPAD_LEFT || joypad.STICK_LEFT; + //} else if (idx == IDX_ACTION_1) { + //return joypad.BUTTON_O; + //} else if (idx == IDX_ACTION_2) { + //return joypad.BUTTON_U; + //} else if (idx == IDX_PAUSE) { + //if (joypad.BUTTON_Y) { + //return true; + //} + //} + + } + return false; + } + + public static function joy_any_button():Boolean { + if (Intra.IS_WINDOWS) { + for (var i:int = 0; i < nr_btns; i++) { + if (Main.joy.buttonIsDown(0, i)) { + return true; + } + } + } else if (Intra.IS_MAC) { + for (i = 0; i < nr_btns; i++) { + if (Main.mac_joy_manager.joysticks[0].getButton(i)) { + return true; + } + } + } + return false; + } + + public static function joy_any_axis():int { + if (Intra.IS_WINDOWS) { + for (var i:int = 0; i < nr_axes; i++) { + if (Math.abs(Main.joy.getAxis(0, i)) > 0.25) { + if (Main.joy.getAxis(0, i) < 0) { + return -1; + } else { + return 1; + } + } + } + } else if (Intra.IS_MAC) { + for (i = 0; i < nr_axes; i++) { + if (Math.abs(Main.mac_joy_manager.joysticks[0].getAxis(i)) > 0.25) { + if (Main.mac_joy_manager.joysticks[0].getAxis(i) < 0) { + return -1; + } else { + return 1; + } + } + } + } + return 0; + } + + // Returns the button ID as ready for serialization (offset by 1, shifted over for being a button) + public static function joy_get_first_active_button_id():int { + var i:int = 0; + if (Intra.IS_WINDOWS) { + for (i = 0; i < nr_btns; i++) { + if (Main.joy.buttonIsDown(0, i)) { + return i + 1 + 2 * nr_axes; + } + } + } else if (Intra.IS_MAC) { + for (i = 0; i < nr_btns; i++) { + if (Main.mac_joy_manager.joysticks[0].getButton(i)) { + return i + 1 + 2 * nr_axes; + } + } + } + return 0; + } + + public static function joy_get_first_active_axis_id():int { + var i:int = 0; + if (Intra.IS_WINDOWS) { + for (i = 0; i < nr_axes; i++) { + if (Math.abs(Main.joy.getAxis(0, i)) > 0.7) { + if (Main.joy.getAxis(0, i) < 0) { + return -(1 + i*2); // OFFSET - usually left or down + } else { + return 2 + i*2; // OFFSET + 1 - usually right or up + } + } + } + } else if (Intra.IS_MAC) { + for (i = 0; i < nr_axes; i++) { + if (Math.abs(Main.mac_joy_manager.joysticks[0].getAxis(i)) > 0.7) { + if (Main.mac_joy_manager.joysticks[0].getAxis(i) < 0) { + return -(1 + i * 2); + } else { + return 2 + i * 2; + } + } + } + } + return 0; + } + + public static function get_axis_stats():String { + var s:String = ""; + var axis_state:Number = 0; + for (var i:int = 0; i < nr_axes; i++) { + + if (Intra.IS_WINDOWS) { + axis_state = Main.joy.getAxis(0, i); + } else if (Intra.IS_MAC) { + axis_state = Main.mac_joy_manager.joysticks[0].getAxis(i); + } + if (axis_state < -0.7) { + s += "-"; + } else if (axis_state > 0.7) { + s += "+"; + } else { + s += "0"; + } + } + return s; + } + + public static function get_btn_stats():String { + var s:String = ""; + var bs:Boolean = false; + for (var i:int = 0; i < nr_btns; i++) { + if (Intra.IS_WINDOWS) { + bs = Main.joy.buttonIsDown(0, i); + } else if (Intra.IS_MAC) { + bs = Main.mac_joy_manager.joysticks[0].getButton(i); + } + if (bs){ + s += "1"; + } else { + s += "0"; + } + if (i == 15) { + s += "\n "; + } + } + return s; + } + + + override public function update():void { + //if (!Intra.is_ouya) { + UP = FlxG.keys.pressed(Registry.controls[IDX_UP]); + DOWN = FlxG.keys.pressed(Registry.controls[IDX_DOWN]); + LEFT = FlxG.keys.pressed(Registry.controls[IDX_LEFT]); + RIGHT = FlxG.keys.pressed(Registry.controls[IDX_RIGHT]); + JP_UP = FlxG.keys.justPressed(Registry.controls[IDX_UP]); + JP_DOWN = FlxG.keys.justPressed(Registry.controls[IDX_DOWN]); + JP_LEFT = FlxG.keys.justPressed(Registry.controls[IDX_LEFT]); + JP_RIGHT = FlxG.keys.justPressed(Registry.controls[IDX_RIGHT]); + + JR_UP = FlxG.keys.justReleased(Registry.controls[IDX_UP]); + JR_RIGHT = FlxG.keys.justReleased(Registry.controls[IDX_RIGHT]); + JR_LEFT = FlxG.keys.justReleased(Registry.controls[IDX_LEFT]); + JR_DOWN = FlxG.keys.justReleased(Registry.controls[IDX_DOWN]); + + + + JUST_PRESSED_PAUSE = FlxG.keys.justPressed(Registry.controls[IDX_PAUSE]); + if (Registry.disable_menu) { + JUST_PRESSED_PAUSE = false; + } + if (FORCE_PAUSE && false == Registry.disable_menu) { + FORCE_PAUSE = false; + JUST_PRESSED_PAUSE = true; + } + + + JUST_RELEASED_PAUSE = FlxG.keys.justReleased(Registry.controls[IDX_PAUSE]); + + JP_ACTION_1 = FlxG.keys.justPressed(Registry.controls[IDX_ACTION_1]); + JP_ACTION_2 = FlxG.keys.justPressed(Registry.controls[IDX_ACTION_2]); + ACTION_1 = FlxG.keys.pressed(Registry.controls[IDX_ACTION_1]); + ACTION_2 = FlxG.keys.pressed(Registry.controls[IDX_ACTION_2]); + + //} + + + if ((Intra.IS_WINDOWS && Main.joy != null && Keys.has_joypad) || (Intra.IS_MAC && Keys.has_joypad && Main.mac_joy_manager.joysticks[0] != null) || (0 && Intra.is_ouya)) { + if (get_joy_state(IDX_LEFT)) { + if (!LEFT && ALLOW_JP_LEFT) { + JP_LEFT = true; + ALLOW_JP_LEFT = false; + } + LEFT = true; + } else { + if (!ALLOW_JP_LEFT) { + JR_LEFT = true; + } + ALLOW_JP_LEFT = true; + } + + if (get_joy_state(IDX_RIGHT)) { + if (!RIGHT && ALLOW_JP_RIGHT) { + JP_RIGHT = true; + ALLOW_JP_RIGHT = false; + } + RIGHT = true; + } else { + if (!ALLOW_JP_RIGHT) { + JR_RIGHT = true; + } + ALLOW_JP_RIGHT = true; + } + + if (get_joy_state(IDX_DOWN)) { + if (!DOWN && ALLOW_JP_DOWN) { + JP_DOWN = true; + ALLOW_JP_DOWN= false; + } + DOWN = true; + + } else { + if (!ALLOW_JP_DOWN) { + JR_DOWN = true; + } + ALLOW_JP_DOWN = true; + } + + if (get_joy_state(IDX_UP)) { + if (!UP && ALLOW_JP_UP) { + JP_UP = true; + ALLOW_JP_UP = false; + } + UP = true; + } else { + if (!ALLOW_JP_UP) { + JR_UP = true; + } + ALLOW_JP_UP = true; + } + + if (get_joy_state(IDX_ACTION_1)) { + if (!ACTION_1 && ALLOW_JP_ACTION_1) { + JP_ACTION_1 = true; + ALLOW_JP_ACTION_1 = false; + } + ACTION_1 = true; + } else { + ALLOW_JP_ACTION_1 = true; + } + + if (get_joy_state(IDX_ACTION_2)) { + if (!ACTION_2 && ALLOW_JP_ACTION_2) { + JP_ACTION_2 = true; + ALLOW_JP_ACTION_2 = false; + } + ACTION_2 = true; + } else { + ALLOW_JP_ACTION_2 = true; + } + + if (get_joy_state(IDX_PAUSE)) { + if (ALLOW_JP_PAUSE) { + ALLOW_JP_PAUSE = false; + JUST_PRESSED_PAUSE = true; + } + } else { + ALLOW_JP_PAUSE = true; + } + + //var a:Array = new Array(); + //var asdf:int = 0; + //for (var asdf:int = 0; asdf < nr_btns; asdf++) { + //a.push(int(Main.joy.buttonIsDown(0, asdf))); + //} + //for (asdf = 0; asdf < nr_axes + 2; asdf++) { + //a.push(Main.joy.getAxis(0, asdf)); + //} + //trace(a); + } + + if (Intra.is_ouya) { + + if (FORCE_ACTION_2) { + ACTION_2 = true; + JP_ACTION_2 = true; + FORCE_ACTION_2 = false; + } + } + if (Intra.is_mobile) { + if (FORCE_ACTION_1) { + ACTION_1 = true; + JP_ACTION_1 = true; + FORCE_ACTION_1 = false; + } + + if (FORCE_ACTION_2) { + ACTION_2 = true; + JP_ACTION_2 = true; + FORCE_ACTION_2 = false; + } + + if (SIG_JP_DOWN) { + SIG_JP_DOWN = false; + JP_DOWN = true; + } + + if (SIG_JP_UP) { + SIG_JP_UP = false; + JP_UP = true; + } + + if (SIG_JP_RIGHT) { + SIG_JP_RIGHT = false; + JP_RIGHT = true; + } + + if (SIG_JP_LEFT) { + SIG_JP_LEFT = false; + JP_LEFT = true; + } + + if (FORCE_RIGHT) { + RIGHT = true; + } + if (FORCE_DOWN) { + DOWN = true; + } + if (FORCE_UP) { + UP = true; + } + if (FORCE_LEFT) { + LEFT = true; + } + } + + if (Intra.allow_fuck_it_mode && FlxG.keys.justPressed("SPACE")) { + Registry.FUCK_IT_MODE_ON = !Registry.FUCK_IT_MODE_ON; + } + super.update(); + } + } + +} \ No newline at end of file diff --git a/intra/src/global/Registry.as b/intra/src/global/Registry.as new file mode 100644 index 0000000..e5e8f8a --- /dev/null +++ b/intra/src/global/Registry.as @@ -0,0 +1,795 @@ +package global +{ + /** + * ... + * @author seaga + */ + import data.SoundData; + import entity.decoration.Map_Preview; + import entity.interactive.npc.Trade_NPC; + import flash.accessibility.AccessibilityImplementation; + import flash.display.BitmapData; + import flash.geom.Point; + import flash.media.Sound; + import flash.utils.ByteArray; + import global.Keys; + import helper.DH; + import helper.Joypad_Config_Group; + import org.flixel.FlxGroup; + import org.flixel.FlxSprite; + import states.PlayState; + import states.RoamState; +public class Registry { + + public static var MOBILE_ASK_TO_EXIT_WITH_BACK:Boolean = false; + public static var MOBILE_OKAY_TO_EXIT_WITH_BACK:Boolean = false; + public static var FUCK_IT_MODE_ON:Boolean = false; + + /* game constants */ + public static const MAX_DOOR_PAIRS:int = 95; + public static var DOOR_REFS:Array = new Array(); + public static var DOOR_INFO:Array = new Array(MAX_DOOR_PAIRS); + public static const SCREEN_WIDTH_IN_TILES:int = 10; + public static const SCREEN_HEIGHT_IN_TILES:int = 10; + public static const TILE_WIDTH:int = 16; + public static const TILE_HEIGHT:int = 16; + public static const SCREEN_WIDTH_IN_PIXELS:int = 160; + public static const SCREEN_HEIGHT_IN_PIXELS:int = 160; + public static const HEADER_HEIGHT:int = 20; //Height of header. Needed in screen scrolling + public static var SAVE_NAME:String = "ANODYNE_SAVE_123"; + public static var DIALOGUE:Object; + public static var DIALOGUE_STATE:Object; + public static const DUNGEON_ENTRANCES:Object = { STREET: new Point(232, 737), BEDROOM: new Point(400, 765), REDCAVE: new Point(555, 764), CROWD: new Point(555, 1239), APARTMENT: new Point(391, 911), HOTEL: new Point(394, 440), CIRCUS: new Point(715, 1396), NEXUS: new Point(710,1090) }; + + /* Global state */ + public static var BOI:Boolean = false; // BOI Sprites on in easter egg redcave + public static var is_playstate:Boolean = true; + public static var volume_scale:Number = 1.0; + public static var pillar_switch_state:Boolean = false; //Reset when entering a map with differentname + public static var ENTRANCE_GRID_X:int; + public static var ENTRANCE_GRID_Y:int; + public static var ENTRANCE_PLAYER_X:int; + public static var ENTRANCE_PLAYER_Y:int; + public static var PLAYER_X:int; + public static var PLAYER_Y:int; + public static var CURRENT_GRID_X:int; + public static var CURRENT_GRID_Y:int; + public static var autosave_on:Boolean = true; + public static var checkpoint:Object = { x: 0, y: 0, area: "" }; + public static var cur_dialogue:String; + /** + * Used for disabling the menu during an event because you could potentially break the game otherwise + */ + public static var disable_menu:Boolean = false; + + /* Grid-local state that needs to be accessed globally for events */ + public static var GRID_ENEMIES_DEAD:int = 0; + public static var GRID_PUZZLES_DONE:int = 0; + + /* Subgroups, speeds collisions */ + public static var subgroup_dust:Array = new Array(); + public static var subgroup_propelled:Array = new Array(); + public static var subgroup_interactives:Array = new Array(); + public static var subgroup_on_off_lasers:Array = new Array(); + public static var subgroup_switch_pillars:Array = new Array(); + public static var subgroup_gates:Array = new Array(); + public static var subgroup_dash_traps:Array = new Array(); + public static var subgroup_gas:Array = new Array(); + public static var subgroup_spike_rollers:Array = new Array(); + public static var subgroup_destroyems:Array = new Array(); + + /* Input, sound, state entities */ + public static var keywatch:Keys; + public static var sound_data:SoundData = null; + public static var GAMESTATE:* = null; + public static var PLAYSTATE:PlayState; + //public static var ROAMSTATE:RoamState; + public static var NEXT_MAP_NAME:String = ""; + + /* Sprite hit return values */ + public static var HIT_NORMAL:int = 0; + public static var HIT_KEY:int = 1; + + /********************** + /* START EVENTS ****** + * *******************/ + + + /* Get the broom */ + public static var EVENT_OPEN_BROOM:Boolean = false; + /* Upgrade health */ + public static var EVENT_EXTEND_HEALTH:Boolean = false; + + public static var EVENT_OSCILLATE_DARKNESS_ALPHA:Boolean = false; + /* If set in a grid, alpha is changed to target value and then these values are set to 0 */ + public static var EVENT_CHANGE_DARKNESS_ALPHA:Boolean = false; + public static var EVENT_CHANGE_DARKNESS_ALPHA_TARGET:Number = 0; + public static var EVENT_CHANGE_VOLUME_SCALE:Boolean = false; + public static var EVENT_CHANGE_VOLUME_SCALE_TARGET:Number = 1.0; + public static var E_FADE_AND_SWITCH:Boolean = false; + public static var E_FADE_AND_SWITCH_SONG:String = " "; + public static var E_FADED:Boolean = false; + public static var E_NEXT_MAP_DARKNESS_8:Boolean = false; + public static var E_NEXT_MAP_NO_STATIC:Boolean = false; + public static var E_NEXT_MAP_TURN_ON_LIGHT:Boolean = false; + + public static var EVENT_LEARN_TO_EQUIP:Boolean = false; + public static var EVENT_TELEPORT_DOWN_SOUND:Boolean = false; + public static var E_Enter_Whirlpool_Down:Boolean = false; + public static var E_Enter_Fall_Down:Boolean = false; + public static var E_Blank_Fade:Boolean = false; + public static var E_Transformer_On:Boolean = false; + public static var E_Transformer_Off:Boolean = false; + public static var E_Dialogue_Just_Finished:Boolean = false; + public static var E_DESTROY_PLAYSTATE:Boolean = false; + /** + * The next map load will play the roof song + */ + public static var E_PLAY_ROOF:Boolean = false; + /** + * If the cur and next map are the same, then restart the song anyways + */ + public static var E_OVERRIDE_SAME_MAP_SONG:Boolean = false; + + + /* Elevator in HOTEL */ + public static var E_From_Elevator:Boolean = false; + + public static var GFX_WAVE_EFFECT_ON:Boolean = false; + public static var GFX_WAVE_EFFECT_START:Number = 0; + public static var GFX_WAVE_TABLE:Array = new Array(-3,-2,-1,0,1,2,3,2,1,0,-1,-2); + public static var GFX_WAVE_TABLE_INDEX:int = 0; + public static var GFX_WAVE_EFFECT_FREQ:int = 0; + public static var GFX_WAVE_TABLE_ROLLOVER:int = 0; + public static var GFX_BUFFER:BitmapData = new BitmapData(160, 180, true); + + public static var EVENT_FADE_BEGUN:Boolean = false; + public static var EVENT_FADE_OVER:Boolean = false; + + public static var CURRENT_CUTSCENE:int; + public static var E_Load_Cutscene:Boolean = false; + + + /********************** + /* END EVENTS ****** + * *******************/ + + /* font */ + [Embed (source = "../res/font/font-black.png")] public static var C_FONT_BLACK:Class; + [Embed (source = "../res/font/font-black-apple-7x8.png")] public static var C_FONT_APPLE_BLACK:Class; + [Embed (source = "../res/font/font-white-apple-7x8.png")] public static var C_FONT_APPLE_WHITE:Class; + [Embed(source = "../res/font/jp_white.png")] public static var C_FONT_JP_WHITE:Class; + [Embed(source = "../res/font/kr_white.png")] public static var C_FONT_KO_WHITE:Class; + [Embed(source = "../res/font/11x12_ZHS.png")] public static var C_FONT_ZHS_WHITE:Class; + [Embed(source = "../res/font/es_white.png")] public static var C_FONT_ES_WHITE:Class; // also for pt-br + //[Embed(source = "../res/font/jp_white_test.png")] public static var C_FONT_JP_WHITE:Class; + + public static var C_FONT_BLACK_STRING:String = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890.:,;'\"(!?)+-*/=[]"; + public static var C_FONT_APPLE_BLACK_STRING:String = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ’1234567890.:,;\'\"(!?)+-*/=$]"; + public static var C_FONT_APPLE_WHITE_STRING:String = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ’1234567890.:,;\'\"(!?)+-*/=$]"; + public static var FONT_cpl:int = 27; + public static var FONT_w:int = 8; + public static var FONT_h:int = 8; + public static var APPLE_FONT_w:int = 7; + + /* base xml of the game */ + [Embed (source = '../xml/Intra.xml', mimeType = "application/octet-stream")] private static const EmbedXML:Class; + public static var embedXML:XML; + + /* These refer to the serialized inventory array which stores the state of having an item */ + public static const IDX_BROOM:int = 0; + public static const IDX_JUMP:int = 1; + public static const IDX_TRANSFORMER:int = 2; + public static const IDX_WIDEN:int = 4; + public static const IDX_LENGTHEN:int = 5; + public static const IDX_GREEN_KEY:int = 6; + public static const IDX_RED_KEY:int = 7; + public static const IDX_BLUE_KEY:int = 8; + public static const IDX_BOX:int = 9; + public static const IDX_BIKE_SHOES:int = 10; + public static const IDX_POO:int = 11; + public static const IDX_SPAM:int = 12; + public static const IDX_MISSINGNO:int = 13; + public static const IDX_AUS_HEART:int = 14; + public static const IDX_ELECTRIC:int = 15; + public static const IDX_KITTY:int = 16; + public static const IDX_MELOS:int = 17; + public static const IDX_MARINA:int = 18; + public static const IDX_BLACK:int = 19; + public static const IDX_RED:int = 20; + public static const IDX_GREEN:int = 21; + public static const IDX_BLUE:int = 22; + public static const IDX_WHITE:int = 23; + public static const item_names:Array = new Array("BROOM","JUMP","TRANSFORMER","BAR","WIDEN","LENGTHEN","keyg","keyr","keyb","box","bikeshoes","poo","spam","missingno","ausheart","electric","kitty"); + public static const default_controls:Array = new Array("UP", "DOWN", "LEFT", "RIGHT", "C", "X", "Z", "ENTER"); + + + private static var RAW_STATEFUL:XML; + private static var RAW_STATELESS:XML; + /** BEGIN SERIALIZED **/ + public static var statefulXML:XML; // Represents things that need to keep state - bosses, etc + public static var statelessXML:XML; // Things that don't need state - breakables, torches, blah blah blah + public static var controls:Array = new Array("UP", "DOWN", "LEFT", "RIGHT", "C", "X", "Z", "ENTER"); // Array of control bindings + + //public static var controls = new Array("UP","DOWN","LEFT","RIGHT","ENTER","OUYA_A","Z","OUYA_START"); + + + public static var joybinds:Array = new Array(0,0,0,0,0,0,0,0); + public static var inventory:Array = new Array( + 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); + + public static var achivement_state:Array = new Array( + 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 + ); + public static var modified_mobile_landscape:Boolean = false; + public static var modified_mobile_portrait:Boolean = false; + + public static var death_count:int = 0; + public static var nr_growths:int; + public static const CARD_GOLDMAN_IDX:int = 43; + public static var card_states:Array = new Array( + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + public static var CURRENT_MAP_NAME:String = ""; + public static var bound_item_1:String; + public static var bound_item_2:String; + public static var bound_effect:String; + public static var playtime:int = 0; + public static var nr_keys:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0); //keys in get_nr_keys + public static var CUR_HEALTH:int; + public static var MAX_HEALTH:int; + //indexed by constants in Cutscene.as + public static var CUTSCENES_PLAYED:Array = new Array(0, 0, 0, 0, 0, 0,0,0,0,0,0); + + // Whether or not this big door has been opened. Keys stored in BIG_DOOR. + public static var Big_Door_State:Array = new Array(false, false, false, false); + // Whether or not this nexus door is open on the nexus side. Keys in Door.as + // Street vlaue always true + public static var Nexus_Door_State:Array = new Array(false, true, false, false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false); + + public static var Big_Door_Reqs:Array = new Array(1, 3,10,15,20,25,32); + + public static var Event_Nr_Red_Pillars_Broken:int = 0; + public static var Event_Biofilm_Broken:Boolean = false; + public static var Event_Nr_Suburb_Killed:int = 0; + /* + * An array holding state of events in the game - boss deaths, cutscenes (if any) + * */ + public static var GE_States:Array = new Array( + 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, + false, false, false, false, false); //45 + public static const GE_Bedroom_Boss_Dead_Idx:int = 0; + public static const GE_Redcave_Boss_Dead_Idx:int = 1; + public static const GE_Crowd_Boss_Dead_Idx:int = 2; + public static const GE_Apartment_Boss_Dead_Idx:int = 3; + public static const GE_Hotel_Boss_Dead_Idx:int = 4; + public static const GE_Circus_Boss_Dead_Idx:int = 5; + public static const GE_Bedroom_Visited:int = 6; + public static const GE_Did_A_Checkpoint:int = 7; + public static const GE_Swept_Dust:int = 8; + public static const GE_Left_BDR_After_Boss_Dead:int = 9; + public static const GE_ent_str:int = 10; // entered street + public static const GE_Sage_Dead_Idx:int = 11; + public static const GE_Happy_Started:int = 12; + public static const GE_Left_RDC_After_Boss_Dead:int = 13; + public static const GE_Left_CRD_After_Boss_Dead:int = 14; + public static const GE_Finished_Game:int = 15; + public static const GE_Briar_Happy_Done:int = 16; + public static const GE_Briar_Blue_Done:int = 17; + public static const GE_MOBILE_IS_RHAND:int = 18; + public static const GE_MOBILE_IS_XC:int = 19; + public static const GE_BRIAR_BOSS_DEAD:int = 20; + // Whehter these NPCs have been talked to for the quest that + // gives the clue to the NW overworld room. + public static const GE_QUEST_MITRA:int = 21; + public static const GE_QUEST_CLIFF:int = 22; + public static const GE_QUEST_BEACH:int = 23; + public static const GE_QUEST_FOREST:int = 24; + public static const GE_QUEST_FIELDS:int = 25; + public static const GE_QUEST_CELL:int = 26; + public static const GE_QUEST_SUBURB:int = 27; + public static const GE_QUEST_SPACE:int = 28; + public static const GE_QUEST_GO:int = 29; + // + public static const GE_tradequestspookedmonster:int = 30; + public static const GE_tradequesthelpedmonster:int = 31; + public static const GE_tradequesthelpedshopkeeper:int = 32; + // + public static const GE_ENTERED_NEXUS_ONCE:int = 33; + public static const GE_go_mitra:int = 34; + public static const GE_got_all_cards_inanarea:int = 35; + public static const GE_ENTERED_BLUE_ONCE:int = 36; + public static const GE_HAVE_A_SECRET:int = 37; + public static const GE_DID_JOYPAD_CONFIG_ONCE:int = 38; + + public static var joy_grp:Joypad_Config_Group; + + + /** END SERIALIZED **/ + + //1, 2, 3... + // Some XML that holds other data, but for now: + + /** BEGIN HELPER FUNCTIONS **/ + + public static function all_bosses_dead():Boolean { + var indices:Array = new Array(GE_Apartment_Boss_Dead_Idx, GE_Bedroom_Boss_Dead_Idx, GE_Circus_Boss_Dead_Idx, GE_Crowd_Boss_Dead_Idx, GE_Hotel_Boss_Dead_Idx, GE_Redcave_Boss_Dead_Idx); + + for (var i:int = 0; i < 6; i++) { + if (!GE_States[indices[i]]) return false; + } + + return true; + } + + public static function set_all_bosses_dead():void { + trace ("Registry.as : set_all_bosses_dead"); + var indices:Array = new Array(GE_Apartment_Boss_Dead_Idx, GE_Bedroom_Boss_Dead_Idx, GE_Circus_Boss_Dead_Idx, GE_Crowd_Boss_Dead_Idx, GE_Hotel_Boss_Dead_Idx, GE_Redcave_Boss_Dead_Idx); + + for (var i:int = 0; i < 6; i++) { + GE_States[indices[i]] = true; + } + } + public static function get_nr_keys():int { + if (nr_keys == null) return 0; + if (CURRENT_MAP_NAME == "BEDROOM") { + return nr_keys[0]; + } else if (CURRENT_MAP_NAME == "STREET") { + return nr_keys[1]; + } else if (CURRENT_MAP_NAME == "REDCAVE"){ + return nr_keys[2]; + } else if (CURRENT_MAP_NAME == "CROWD") { + return nr_keys[3]; + } else if (CURRENT_MAP_NAME == "APARTMENT") { + return nr_keys[4]; + } else if (CURRENT_MAP_NAME == "HOTEL") { + return nr_keys[5]; + } else if (CURRENT_MAP_NAME == "CIRCUS") { + return nr_keys[6]; + } else { + return 0; + } + + } + + public static function change_nr_keys(amount:int):void { + if (CURRENT_MAP_NAME == "BEDROOM") { + nr_keys[0] += amount; + } else if (CURRENT_MAP_NAME == "STREET") { + nr_keys[1] += amount; + } else if (CURRENT_MAP_NAME == "REDCAVE") { + nr_keys[2] += amount; + } else if (CURRENT_MAP_NAME == "CROWD") { + nr_keys[3] += amount; + }else if (CURRENT_MAP_NAME == "APARTMENT") { + nr_keys[4] += amount; + } else if (CURRENT_MAP_NAME == "HOTEL") { + nr_keys[5] += amount; + } else if (CURRENT_MAP_NAME == "CIRCUS") { + nr_keys[6] += amount; + } + + } + + + public static function reset_events():void { + EVENT_OPEN_BROOM = false; + EVENT_CHANGE_DARKNESS_ALPHA = false; + EVENT_OSCILLATE_DARKNESS_ALPHA = false; + EVENT_CHANGE_VOLUME_SCALE = false; + volume_scale = 1; + E_Enter_Whirlpool_Down = false; + } + /** + * Clear out any groups of specific objects used to + * speed up collisions (e.g., subgroup of dusts) + */ + public static function reset_subgroups():void { + var ctr:int; + + while (subgroup_dust.length > 0) { + subgroup_dust.pop(); + } + while (subgroup_propelled.length > 0) { + subgroup_propelled.pop(); + } + while (subgroup_interactives.length > 0) { + subgroup_interactives.pop(); + } + while (subgroup_on_off_lasers.length > 0) { + subgroup_on_off_lasers.pop(); + } + while (subgroup_switch_pillars.length > 0) { + subgroup_switch_pillars.pop(); + } + while (subgroup_spike_rollers.length > 0) { + subgroup_spike_rollers.pop(); + } + + subgroup_spike_rollers = null; + subgroup_spike_rollers = new Array(); + + subgroup_gates = null; + subgroup_gates = new Array(); + subgroup_dash_traps = null; + subgroup_dash_traps = new Array(); + subgroup_gas = null; + subgroup_gas = new Array(); + + // SHOULD ALL BE ZEROS + trace(subgroup_dust.length, subgroup_propelled.length, subgroup_interactives.length, subgroup_on_off_lasers.length, subgroup_switch_pillars.length, subgroup_spike_rollers.length, subgroup_gates.length, subgroup_dash_traps.length, subgroup_gas.length); + } + + public static function checkDoorInfo():void { + var door_debug:Boolean = false; + for (var i:int = 0; i < DOOR_INFO.length; i++) { + if (DOOR_INFO[i].length != 0) { + if (door_debug) { + trace("DOOR PAIR ", i , ":"); + trace(DOOR_INFO[i][0]); + if (DOOR_INFO[i][1] != null) { + + trace(DOOR_INFO[i][1]); + } + } + } + } + } + + + // Changes the DAME-exported XML into + // Something grid-related for our game. + public static function embed2saveXML():void { + + var newMap:XML; //Will be a map node for our stateless/ful XML tree. + var o:XML; //Generic object XML + var map:XML; //For each "level" (house/dungeon/whatever) + var grid:XML; //Represents a "grid" + var grid_exists:Boolean; // Set to true when an existing grid is found + // while iterating through some level's grids + var name:String; + var x:int; var grid_x:int; + var y:int; var grid_y:int; + var ba:ByteArray = new ByteArray(); + embedXML = new XML(new EmbedXML); + RAW_STATEFUL = ; + RAW_STATELESS = ; + statelessXML = ; + statefulXML = ; + //Every level corresponds to a floor of a dungeon, + //a house, the world map, etc. + for each (map in embedXML.map) { + + newMap = ; + newMap.@name = map.@name; + newMap.@type = map.@type; + // These are all the DAME objects. + for each (o in map.*) { + //convert XY into Grid X,Y. + x = parseInt(o.@x); + y = parseInt(o.@y); + grid_x = x / Registry.SCREEN_WIDTH_IN_PIXELS; + grid_y = y / Registry.SCREEN_HEIGHT_IN_PIXELS; + y += Registry.HEADER_HEIGHT; + if (o.name() == "Door") { + Registry.DOOR_INFO[parseInt(o.@frame)].push(new Array(x, y, newMap.@name)); + } + // Append the object "o" to the grid node if it already exists. + grid_exists = false; + for each (grid in newMap.grid) { + if (grid.@grid_x == grid_x.toString() && grid.@grid_y == grid_y.toString()) { + grid.appendChild(o); + grid_exists = true; + break; + } + } + // Otherwise, create a new grid node and append "o" to it. + if (!grid_exists) { + grid = ; + grid.@grid_x = grid_x.toString(); + grid.@grid_y = grid_y.toString(); + grid.appendChild(o); + newMap.appendChild(grid); + } + } + //Finally, append the transformed level node to the serialized XML. + // it's okay to just append references, + // because a save file will change the statelessXML ref + // This way we have a copy of what was in the game swf + ba.clear(); + ba.writeObject(newMap); + ba.position = 0; + if (newMap.@type == "Stateless") { + RAW_STATELESS.appendChild(ba.readObject() as XML); + statelessXML.appendChild(newMap); + } else { + RAW_STATEFUL.appendChild(ba.readObject() as XML); + statefulXML.appendChild(newMap); + } + + } + } + + // Reads the embedded xml, compares it against the save file one. + public static function patch_xml(load:*):void { + // First convert it into a tree... poop! + + + if (RAW_STATEFUL != null && RAW_STATELESS != null) { + patch_some_tree(RAW_STATEFUL, load.data.stateful); + patch_some_tree(RAW_STATELESS, load.data.stateless); + } + + RAW_STATEFUL = null; + RAW_STATELESS = null; + } + + + private static function patch_some_tree(disk:XML,save:XML):void { + + + // For each area + // For each grid: + // If SAVE has something but DISK doesn't, remove it from save. + // If DISK has something but SAVE doesn't, add to SAVE. + // Update SAVE's x,y to be DISK's x,y (I don't think I modify any object's x,y permanently? I hope o__o) + var map:XML; // Iterators for the children of root and maps + var s_map:XML; + var grid:XML; + var s_grid:XML; + + var o:XML; // + var found_map_match:Boolean = false; + var found_obj_match:Boolean = false; + + var guid:String; // A guid for a dame object + + var debug:Boolean = false; + + var i:int; // Iterators for objects in the grid xmls + var j:int; + + var ba:ByteArray = new ByteArray(); // resuable byte array for hard copying xml + var foundgridmatch:Boolean = false; + if (debug) trace("Patching Stateful XML"); + + for each (map in disk.map) { + for each (s_map in save.map) { + if (s_map.@name.toXMLString() == map.@name.toXMLString()) { + found_map_match = true; + break; + } + } + // If we don't have this map from disk in the save, + // then add it to the save and continue. + if (false == found_map_match) { + save.appendChild(map); + if (debug) trace("added new map !**!*!*!*"); + continue; + } + + // Otherwise we do have it, so let's check its grids. + // We assume maps won't change size (God help us) + for each (grid in map.grid) { + for each (s_grid in s_map.grid) { + if (s_grid.@grid_x.toXMLString() == grid.@grid_x.toXMLString() && + s_grid.@grid_y.toXMLString() == grid.@grid_y.toXMLString()) { + foundgridmatch = true; + break; + } + } + + if (foundgridmatch == false) { + s_grid = ; + s_grid.@grid_x = grid.@grid_x.toXMLString(); + s_grid.@grid_y = grid.@grid_y.toXMLString(); + } + + // Look for DISK objs not in SAVE. + for (i = 0; i < grid.child("*").length(); i++) { + o = grid.child("*")[i]; + guid = o.@guid.toXMLString(); + for (j = 0; j < s_grid.child("*").length(); j++) { + // If we find a match, then the SAVE obj should have its + // xy-coords the same as the DISK obj + if (guid == s_grid.child("*")[j].@guid.toXMLString()) { + found_obj_match = true; + if (s_grid.child("*")[j].@x != o.@x || s_grid.child("*")[j].@y != o.@y) { + if (debug) trace("_----------------"); + if (debug) trace("OLD " + s_grid.child("*")[j].toXMLString()); + s_grid.child("*")[j].@x = o.@x; + s_grid.child("*")[j].@y = o.@y; + if (debug) trace("WHOA SHIT. CHANGING X AND Y: " + s_grid.child("*")[j].toXMLString()); + } + break; + } + } + // If not found in SAVE, add to SAVE. + if (false == found_obj_match) { + + ba.clear(); + ba.position = 0; + ba.writeObject(o); + ba.position = 0; + s_grid.appendChild(ba.readObject() as XML); + if (debug) trace ("ADDING OBJ "+o.toXMLString()+"TO SAVE STATEFUL"); + if (debug) trace(s_grid.toXMLString()); + } + found_obj_match = false; + } + + if (s_map.@name.toXMLString() == "BEACH") { + var a:int = 3; + if (s_grid.@grid_x.toXMLString() == "8" && s_grid.@grid_y.toXMLString() == "3") { + + } + a += 2; + } + + // look for SAVE objs not in DISK + for (i = 0; i < s_grid.child("*").length(); i++) { + o = s_grid.child("*")[i]; + guid = o.@guid.toXMLString(); + for (j = 0; j < grid.child("*").length(); j++) { + if (guid == grid.child("*")[j].@guid.toXMLString()) { + found_obj_match = true; + } + } + // If no match found in DISK, remove from SAVE + if (false == found_obj_match) { + if (debug) trace ("REMOVING OBJ"+o.toXMLString()+"FROM SAVE STATEFUL"); + delete s_grid.child("*").(@guid == guid)[0]; //fuck there is no way this works + if (debug) trace(s_grid.toXMLString()); + } + found_obj_match = false; + } + + if (foundgridmatch == false) { + ba.clear(); + ba.position = 0; + ba.writeObject(s_grid); + ba.position = 0; + s_map.appendChild(ba.readObject() as XML); + } + foundgridmatch = false; + } + found_map_match = false; + } + + // In case we have objects in a grid in the save + // that aren't in a grid in the disk (and thus weren't caught earlier) + // we remove them from the save here. + for each (s_map in save.map) { + + for each (map in disk.map) { + if (s_map.@name.toXMLString() == map.@name.toXMLString()) { + found_map_match = true; + break; + } + } + if (found_map_match == false) { + continue; + } + found_map_match = false; + + for each (s_grid in s_map.grid) { + for each (grid in map.grid) { + if (s_grid.@grid_x.toXMLString() == grid.@grid_x.toXMLString() && + s_grid.@grid_y.toXMLString() == grid.@grid_y.toXMLString()) { + foundgridmatch = true; + break; + } + } + // DELETE ERRTHANG + if (foundgridmatch == false) { + if (debug) trace("ALLEGEDLY DELETING GHOST GRID",s_map.@name.toXMLString(), s_grid); + delete s_map.child("*").(@grid_x == s_grid.@grid_x && @grid_y == s_grid.@grid_y)[0]; + } + foundgridmatch = false; + } + + } + } + /** + * sets is_playstate param based on the next map to be loaded. + * distinguishes between dungeon and free-roaming areas + * @param next_map_name + */ + + public static function set_is_playstate(next_map_name:String):void { + switch (next_map_name) { + /*case "FIELDS": case "NEXUS": case "REDSEA": case "BEACH": + case "CLIFF": case "FOREST" : case "CELL": case "TERMINAL": case "WINDMILL": + case "GO": case "HAPPY": case "BLUE": case "SUBURB": case "SPACE": + is_playstate = false; + trace("Loading map ", next_map_name, " it's a RoamState"); + break;*/ + default: + is_playstate = true; + break; + } + } + + public static function destroy_destroyems():void { + while (subgroup_destroyems.length > 0) { + var p:* = subgroup_destroyems.pop(); + if (p != null) { + p.destroy(); + } + } + } + + public static function is_dungeon(n:String):Boolean { + switch (n) { + case "BEDROOM": + case "STREET": + case "REDCAVE": + case "CROWD": + case "APARTMENT": + case "HOTEL": + case "CIRCUS": + return true; + break; + default: + return false; + break; + } + + } + + public static function cleanup_on_map_change():void + { + + if (Trade_NPC.cat_ref != null) { + Registry.GAMESTATE.sortables.remove(Trade_NPC.cat_ref, true); + Registry.GAMESTATE.sortables.remove(Trade_NPC.cat_dust_ref, true); + Trade_NPC.cat_ref.destroy(); + Trade_NPC.cat_ref = null; + Trade_NPC.cat_dust_ref.destroy(); + Trade_NPC.cat_dust_ref = null; + } + Registry.volume_scale = 1; + Registry.reset_events(); + Registry.reset_subgroups(); + //Event_Nr_Suburb_Killed = 0; + // Reset other things? + DH.reset_scenes_on_map_change(); + } + + public static var es_string:String = "ªÂâàÀáÁãÃçÇéÉêÊÍíóôÓÔõúÚüÜÑñabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’1234567890.:,; \' \"(!?)+- */=$]¡¿ŒœËëÈèÎîÏïùÙìò"; + + public static var zhs_string:String = "#=ENGLISHDAOU-CTRby./Jzfoucldmenthgisvrwa!\"'PKYWB:(k,)pM[]F4\\jq^_*?0123 456789xXV%>;+Q$欢音乐吗?那就和个终端一只小雨机对话吧!疼痛路向南行名杂技演员快要失去平衡了喜安全网在哪里狮子们正包围耍人’荆棘:我累,扬。已经厌倦这样的循环感觉自己活同美梦中、噩不断地…事情是会发生改变永远都无能为力再见老兄啊呀抬起脚步挥动手臂如果没有你分钟也下好走弄三明治或者别什么贤做很多神秘声喂嘿噢听到太着马上醒过来可以使用方键四周移需按与物体他互时调出菜单将提供关身及境相信息想帮处理切希望得比祝运某种程度说总既又完却忽略掉现实知道应该怎助世界究竟转更所奇怪真成朋友直努白清楚最后告诫等谁麦卓叫车东西问字干嘛并记“”胆敢怂恿让滚意思—闭嘴愚蠢还漂亮坚持把糟糕搞定办瞧蒙面何角色静待之因撒谎解决算从前消尽而戴斗篷男候呃村长片大被邪恶量笼罩召唤此寻找传企图利达目必须抢先且保护它进左边激送门开始任务叹逗留兆头入然乃至整拯救扇死儿继续刚钥匙许九牛毛罢阻止唯途径拿往深求管探索懂值齐其区域卡顶部颗宝石测试展座殿考验存集智慧才通件武器玩当根扫帚言抱怨简傻站刻脑弱受伤害恐惧箱类似象征重选择回口英雄穿呢像冲危歉另式劝但场游戏法忘加强聪条便引导准备首接收张哦确否错非虑毫义战胜兽漫炼千万放松警惕海滩看低鸣闻股甜味打败丽担心困雪绝哈请喝杯混球靠热流汗越饥渴难耐金跟模带块砖跑愁吃辈哇赶撬于恢复初急旅虽些蛮酷商诉支次顾介绍优秀近嗯衣服背写匆山迷组森林风涡轮启产影响兑换新附结构怕庆幸作效跳鞋棒合颜观察宫藏匿满敌房间仔细查荒废邻居公寓家伙隐检外岛屿沿河底点红树逛洞穴锁北源唔黑暗喷火团夫妇坑缘肯裂缝特高诡异彩凉灰酒店层破第赌二主给桥拜托扯冒险精几遇姓操纵·笑氏型偷案例落文遗古代工艺品侵猜烦恼各琐碎雕庄橱获取数购买饮料克除坏脾气尊讲俗套压冷漠布雷耶爱德华浴室镜摄木框翻梅油皂电短献麻尘扮证每诚孤建议幻魔巢项输节停顿拒资原独隧稳少天曾升坝年月日秋丝罗格斯摔胫骨折七丑严肺题退休兰牌化妆常疑由脸侧尚未驯咬瑟抖双凶猛闪光眼睛况苦予追随搏愿佑诸顺辨认号(晓)窟勘峭壁延伸爬垂降承占位符画碰触两住弃注材质撞素墙设计制击率趣挑牢血监狱迎内容标置际勾勒概档谨慎价飓旧缩减迹峡谷湖泊池塘歇守卫替蓝掌繁忙灵魂依锈蚀铺伴般帐命逃亡绿属郊屋慢形星辰慰藉视领土圆圈约绕吱乱联系聊封邮显示屏乎五十享施财衰母亲离她毒青蛙遭志段沉睡状态坦据祖褪笔潦草空僚踏洋差禁忌善眠虹刺本伯袋萨维仓库修拥缺乏市民擅交立列划造城愉伟闯访偶尔句迪燃偏遥怒暴踪景塔早眺久损屹倒插云共宽固焰灯芒盖惜今统反挺啦散宜钱基职适较坐台表份诠释王迅速隔彼专则疯充鼓励仅足兴遍故税毕排益欲谈论识够欠连尾霸瓜揍喇叭裤耻胸腔蜜蜂性飞残病杀虫剂臭苍蝇幼徒劳旁吓猫咪绒嗷呜盒苗黏恙谢噜荣培训辆帅薄荷误花功易奖伊博责编辑辐射营养学嗨妈爸温柔喔截具湿皮肤极寒腾剧骼咀嚼冰习惯岁线突蝎报纸菌滋冻餐仿佛癌症蛋讨脏穷增添妙盏怀揣密窗户轨堕夜胡八聆卸囊扔丢粉睹迭龙虾螯砍咸挤沙剥夺雅蛄紫广泛朵飘阳遮挡询詹姆浆食季啪串诗莓奥弗兔超呵灌济妻孩贾汀六队噗鲍勃鼠称省哭泣滴泪眶刮莫盔猴念咖喱黄辣码躲躯攻推跌尖镇浪著乡牺牲读;敏锐旷野汇殊投悬崖秒呐盟糖招呼沮丧客憩历抗惩罚赎扰付庇迟水健挠痒馆惠券祸怜轻校涯恩参甩卖班紧拾陌熟宁弟曲惊茫播育尸举典骚犯谋女钝殴致册晚盯柯乔泥泡茶圣坛祭玻璃限蜡烛昨枕舒烟熏蘑菇授鱼渔吉米蝙蝠铁弯腰脊椎科蟾蜍斜药刷歧酬棍控右跃版悔《》柄默返弹配摸语拉拽钮师官妖鉴障碍靴装级朝阵零戈曼储若倔指踩板搭芬缇帕珊货抚晴朗晨甲币吼夹款吸期陋您呈协序术免费辛勤漏姐父估扩词史莱搬伐氓狗旋银洁爆炸植扭柱仆亚韦沃拘束楼"; + + + + + + + + + + + + + + + + public static var ko_string:String = "가각간갇갈갉갊감갑값갓갔강갖갗같갚갛개객갠갤갬갭갯갰갱갸갹갼걀걋걍걔걘걜거걱건걷걸걺검겁것겄겅겆겉겊겋게겐겔겜겝겟겠겡겨격겪견겯결겸겹겻겼경곁계곈곌곕곗고곡곤곧골곪곬곯곰곱곳공곶과곽관괄괆괌괍괏광괘괜괠괩괬괭괴괵괸괼굄굅굇굉교굔굘굡굣구국군굳굴굵굶굻굼굽굿궁궂궈궉권궐궜궝궤궷귀귁귄귈귐귑귓규균귤그극근귿글긁금급긋긍긔기긱긴긷길긺김깁깃깅깆깊까깍깎깐깔깖깜깝깟깠깡깥깨깩깬깰깸깹깻깼깽꺄꺅꺌꺼꺽꺾껀껄껌껍껏껐껑께껙껜껨껫껭껴껸껼꼇꼈꼍꼐꼬꼭꼰꼲꼴꼼꼽꼿꽁꽂꽃꽈꽉꽐꽜꽝꽤꽥꽹꾀꾄꾈꾐꾑꾕꾜꾸꾹꾼꿀꿇꿈꿉꿋꿍꿎꿔꿜꿨꿩꿰꿱꿴꿸뀀뀁뀄뀌뀐뀔뀜뀝뀨끄끅끈끊끌끎끓끔끕끗끙끝끼끽낀낄낌낍낏낑나낙낚난낟날낡낢남납낫났낭낮낯낱낳내낵낸낼냄냅냇냈냉냐냑냔냘냠냥너넉넋넌널넒넓넘넙넛넜넝넣네넥넨넬넴넵넷넸넹녀녁년녈념녑녔녕녘녜녠노녹논놀놂놈놉놋농높놓놔놘놜놨뇌뇐뇔뇜뇝뇟뇨뇩뇬뇰뇹뇻뇽누눅눈눋눌눔눕눗눙눠눴눼뉘뉜뉠뉨뉩뉴뉵뉼늄늅늉느늑는늘늙늚늠늡늣능늦늪늬늰늴니닉닌닐닒님닙닛닝닢다닥닦단닫달닭닮닯닳담답닷닸당닺닻닿대댁댄댈댐댑댓댔댕댜더덕덖던덛덜덞덟덤덥덧덩덫덮데덱덴델뎀뎁뎃뎄뎅뎌뎐뎔뎠뎡뎨뎬도독돈돋돌돎돐돔돕돗동돛돝돠돤돨돼됐되된될됨됩됫됴두둑둔둘둠둡둣둥둬뒀뒈뒝뒤뒨뒬뒵뒷뒹듀듄듈듐듕드득든듣들듦듬듭듯등듸디딕딘딛딜딤딥딧딨딩딪따딱딴딸땀땁땃땄땅땋때땍땐땔땜땝땟땠땡떠떡떤떨떪떫떰떱떳떴떵떻떼떽뗀뗄뗌뗍뗏뗐뗑뗘뗬또똑똔똘똥똬똴뙈뙤뙨뚜뚝뚠뚤뚫뚬뚱뛔뛰뛴뛸뜀뜁뜅뜨뜩뜬뜯뜰뜸뜹뜻띄띈띌띔띕띠띤띨띰띱띳띵라락란랄람랍랏랐랑랒랖랗래랙랜랠램랩랫랬랭랴략랸럇량러럭런럴럼럽럿렀렁렇레렉렌렐렘렙렛렝려력련렬렴렵렷렸령례롄롑롓로록론롤롬롭롯롱롸롼뢍뢨뢰뢴뢸룀룁룃룅료룐룔룝룟룡루룩룬룰룸룹룻룽뤄뤘뤠뤼뤽륀륄륌륏륑류륙륜률륨륩륫륭르륵른를름릅릇릉릊릍릎리릭린릴림립릿링마막만많맏말맑맒맘맙맛망맞맡맣매맥맨맬맴맵맷맸맹맺먀먁먈먕머먹먼멀멂멈멉멋멍멎멓메멕멘멜멤멥멧멨멩며멱면멸몃몄명몇몌모목몫몬몰몲몸몹못몽뫄뫈뫘뫙뫼묀묄묍묏묑묘묜묠묩묫무묵묶문묻물묽묾뭄뭅뭇뭉뭍뭏뭐뭔뭘뭡뭣뭬뮈뮌뮐뮤뮨뮬뮴뮷므믄믈믐믓미믹민믿밀밂밈밉밋밌밍및밑바박밖밗반받발밝밞밟밤밥밧방밭배백밴밸뱀뱁뱃뱄뱅뱉뱌뱍뱐뱝버벅번벋벌벎범법벗벙벚베벡벤벧벨벰벱벳벴벵벼벽변별볍볏볐병볕볘볜보복볶본볼봄봅봇봉봐봔봤봬뵀뵈뵉뵌뵐뵘뵙뵤뵨부북분붇불붉붊붐붑붓붕붙붚붜붤붰붸뷔뷕뷘뷜뷩뷰뷴뷸븀븃븅브븍븐블븜븝븟비빅빈빌빎빔빕빗빙빚빛빠빡빤빨빪빰빱빳빴빵빻빼빽뺀뺄뺌뺍뺏뺐뺑뺘뺙뺨뻐뻑뻔뻗뻘뻠뻣뻤뻥뻬뼁뼈뼉뼘뼙뼛뼜뼝뽀뽁뽄뽈뽐뽑뽕뾔뾰뿅뿌뿍뿐뿔뿜뿟뿡쀼쁑쁘쁜쁠쁨쁩삐삑삔삘삠삡삣삥사삭삯산삳살삵삶삼삽삿샀상샅새색샌샐샘샙샛샜생샤샥샨샬샴샵샷샹섀섄섈섐섕서석섞섟선섣설섦섧섬섭섯섰성섶세섹센셀셈셉셋셌셍셔셕션셜셤셥셧셨셩셰셴셸솅소속솎손솔솖솜솝솟송솥솨솩솬솰솽쇄쇈쇌쇔쇗쇘쇠쇤쇨쇰쇱쇳쇼쇽숀숄숌숍숏숑수숙순숟술숨숩숫숭숯숱숲숴쉈쉐쉑쉔쉘쉠쉥쉬쉭쉰쉴쉼쉽쉿슁슈슉슐슘슛슝스슥슨슬슭슴습슷승시식신싣실싫심십싯싱싶싸싹싻싼쌀쌈쌉쌌쌍쌓쌔쌕쌘쌜쌤쌥쌨쌩썅써썩썬썰썲썸썹썼썽쎄쎈쎌쏀쏘쏙쏜쏟쏠쏢쏨쏩쏭쏴쏵쏸쐈쐐쐤쐬쐰쐴쐼쐽쑈쑤쑥쑨쑬쑴쑵쑹쒀쒔쒜쒸쒼쓩쓰쓱쓴쓸쓺쓿씀씁씌씐씔씜씨씩씬씰씸씹씻씽아악안앉않알앍앎앓암압앗았앙앝앞애액앤앨앰앱앳앴앵야약얀얄얇얌얍얏양얕얗얘얜얠얩어억언얹얻얼얽얾엄업없엇었엉엊엌엎에엑엔엘엠엡엣엥여역엮연열엶엷염엽엾엿였영옅옆옇예옌옐옘옙옛옜오옥온올옭옮옰옳옴옵옷옹옻와왁완왈왐왑왓왔왕왜왝왠왬왯왱외왹왼욀욈욉욋욍요욕욘욜욤욥욧용우욱운울욹욺움웁웃웅워웍원월웜웝웠웡웨웩웬웰웸웹웽위윅윈윌윔윕윗윙유육윤율윰윱윳융윷으윽은을읊음읍읏응읒읓읔읕읖읗의읜읠읨읫이익인일읽읾잃임입잇있잉잊잎자작잔잖잗잘잚잠잡잣잤장잦재잭잰잴잼잽잿쟀쟁쟈쟉쟌쟎쟐쟘쟝쟤쟨쟬저적전절젊점접젓정젖제젝젠젤젬젭젯젱져젼졀졈졉졌졍졔조족존졸졺좀좁좃종좆좇좋좌좍좔좝좟좡좨좼좽죄죈죌죔죕죗죙죠죡죤죵주죽준줄줅줆줌줍줏중줘줬줴쥐쥑쥔쥘쥠쥡쥣쥬쥰쥴쥼즈즉즌즐즘즙즛증지직진짇질짊짐집짓징짖짙짚짜짝짠짢짤짧짬짭짯짰짱째짹짼쨀쨈쨉쨋쨌쨍쨔쨘쨩쩌쩍쩐쩔쩜쩝쩟쩠쩡쩨쩽쪄쪘쪼쪽쫀쫄쫌쫍쫏쫑쫓쫘쫙쫬쫴쬈쬐쬔쬘쬠쬡쬬쭁쭈쭉쭌쭐쭘쭙쭝쭤쭸쭹쮜쮸쯔쯤쯧쯩찌찍찐찔찜찝찡찢찧차착찬찮찰참찹찻찼창찾채책챈챌챔챕챗챘챙챠챤챦챨챰챵처척천철첨첩첫첬청체첵첸첼쳄쳅쳇쳉쳐쳔쳤쳬쳰촁초촉촌촐촘촙촛총촤촨촬촹최쵠쵤쵬쵭쵯쵱쵸춈추축춘출춤춥춧충춰췄췌췐취췬췰췸췹췻췽츄츈츌츔츙츠측츤츨츰츱츳층치칙친칟칠칡침칩칫칭카칵칸칼캄캅캇캉캐캑캔캘캠캡캣캤캥캬캭컁커컥컨컫컬컴컵컷컸컹케켁켄켈켐켑켓켕켜켠켤켬켭켯켰켱켸코콕콘콜콤콥콧콩콰콱콴콸쾀쾅쾌쾡쾨쾰쿄쿠쿡쿤쿨쿰쿱쿳쿵쿼퀀퀄퀑퀘퀭퀴퀵퀸퀼큄큅큇큉큐큔큘큠크큭큰클큼큽킁키킥킨킬킴킵킷킹타탁탄탈탉탐탑탓탔탕태택탠탤탬탭탯탰탱탸턍터턱턴털턺텀텁텃텄텅테텍텐텔템텝텟텡텨텬텼톄톈토톡톤톨톰톱톳통톺톼퇀퇘퇴퇸툇툉툐투툭툰툴툼툽툿퉁퉈퉜퉤튀튁튄튈튐튑튕튜튠튤튬튱트특튼튿틀틂틈틉틋틔틘틜틤틥티틱틴틸팀팁팃팅파팍팎판팔팖팜팝팟팠팡팥패팩팬팰팸팹팻팼팽퍄퍅퍼퍽펀펄펌펍펏펐펑페펙펜펠펨펩펫펭펴편펼폄폅폈평폐폘폡폣포폭폰폴폼폽폿퐁퐈퐝푀푄표푠푤푭푯푸푹푼푿풀풂품풉풋풍풔풩퓌퓐퓔퓜퓟퓨퓬퓰퓸퓻퓽프픈플픔픕픗피픽핀필핌핍핏핑하학한할핥함합핫항해핵핸핼햄햅햇했행햐향허헉헌헐헒험헙헛헝헤헥헨헬헴헵헷헹혀혁현혈혐협혓혔형혜혠혤혭호혹혼홀홅홈홉홋홍홑화확환활홧황홰홱홴횃횅회획횐횔횝횟횡효횬횰횹횻후훅훈훌훑훔훗훙훠훤훨훰훵훼훽휀휄휑휘휙휜휠휨휩휫휭휴휵휸휼흄흇흉흐흑흔흖흗흘흙흠흡흣흥흩희흰흴흼흽힁히힉힌힐힘힙힛힝엤 !#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS TUVWXYZ[ ]^_`abcdefghijklmnopqrstuvwxyz{|}~'’\"「」々。"; + + //public static var jp_string:String = "abcdefghijklmnopqrstuvwxyzぁ......................."; + // Note that the first line has whitespace - the ' ' one and the ' ' one + public static var jp_string:String = "ぁあぃいぅうぇえぉおかがきぎくぐけげ゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜゜  こごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをん゛゜ゝゞァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ・ーヽヾ㈱㈲㈹㊤㊥㊦㊧㊨㌃㌍㌔㌘㌢㌣㌦㌧㌫㌶㌻㍉㍊㍍㍑㍗㍻㍼㍽㍾㎎㎏㎜㎝㎞㎡㏄㏍一丁七万丈三上下不与丐丑且丕世丗丘丙丞両並个中丱串丶丸丹主丼丿乂乃久之乍乎乏乕乖乗乘乙九乞也乢乱乳乾亀亂亅了予争亊事二于云互五井亘亙些亜亞亟亠亡亢交亥亦亨享京亭亮亰亳亶人什仁仂仄仆仇今介仍从仏仔仕他仗付仙仝仞仟代令以仭仮仰仲件价任企伉伊伍伎伏伐休会伜伝伯估伴伶伸伺似伽佃但佇位低住佐佑体何佗余佚佛作佝佞佩佯佰佳併佶佻佼使侃來侈例侍侏侑侖侘供依侠価侫侭侮侯侵侶便係促俄俊俎俐俑俔俗俘俚俛保俟信俣俤俥修俯俳俵俶俸俺俾倅倆倉個倍倏們倒倔倖候倚借倡倣値倥倦倨倩倪倫倬倭倶倹偃假偈偉偏偐偕偖做停健偬偲側偵偶偸偽傀傅傍傑傘備傚催傭傲傳傴債傷傾僂僅僉僊働像僑僕僖僚僞僣僥僧僭僮僵價僻儀儁儂億儉儒儔儕儖儘儚償儡優儲儷儺儻儼儿兀允元兄充兆兇先光克兌免兎児兒兔党兜兢入全兩兪八公六兮共兵其具典兼冀冂内円冉冊册再冏冐冑冒冓冕冖冗写冠冢冤冥冦冨冩冪冫冬冰冱冲决冴况冶冷冽凄凅准凉凋凌凍凖凛凜凝几凡処凧凩凪凭凰凱凵凶凸凹出函凾刀刃刄分切刈刊刋刎刑刔列初判別刧利刪刮到刳制刷券刹刺刻剃剄則削剋剌前剏剔剖剛剞剣剤剥剩剪副剰剱割剳剴創剽剿劃劇劈劉劍劑劒劔力功加劣助努劫劬劭励労劵効劼劾勁勃勅勇勉勍勒動勗勘務勝勞募勠勢勣勤勦勧勲勳勵勸勹勺勾勿匁匂包匆匈匍匏匐匕化北匙匚匝匠匡匣匪匯匱匳匸匹区医匿區十千卅卆升午卉半卍卑卒卓協南単博卜卞占卦卩卮卯印危即却卵卷卸卻卿厂厄厖厘厚原厠厥厦厨厩厭厮厰厳厶去参參又叉及友双反収叔取受叙叛叟叡叢口古句叨叩只叫召叭叮可台叱史右叶号司叺吁吃各合吉吊吋同名后吏吐向君吝吟吠否吩含听吭吮吶吸吹吻吼吽吾呀呂呆呈呉告呎呑呟周呪呰呱味呵呶呷呻呼命咀咄咆咋和咎咏咐咒咢咤咥咨咫咬咯咲咳咸咼咽咾哀品哂哄哇哈哉哘員哢哥哦哨哩哭哮哲哺哽唄唆唇唏唐唔唖售唯唱唳唸唹唾啀啄啅商啌問啓啖啗啜啝啣啻啼啾喀喃善喇喉喊喋喘喙喚喜喝喞喟喧喨喩喪喫喬單喰営嗄嗅嗇嗔嗚嗜嗟嗣嗤嗷嗹嗽嗾嘆嘉嘔嘖嘗嘘嘛嘩嘯嘱嘲嘴嘶嘸噂噌噎噐噛噤器噪噫噬噴噸噺嚀嚆嚇嚊嚏嚔嚠嚢嚥嚮嚴嚶嚼囀囁囂囃囈囎囑囓囗囘囚四回因団囮困囲図囹固国囿圀圃圄圈圉國圍圏園圓圖團圜土圦圧在圭地圷圸圻址坂均坊坎坏坐坑坡坤坦坩坪坿垂垈垉型垓垠垢垣垤垪垰垳埀埃埆埋城埒埓埔埖埜域埠埣埴執培基埼堀堂堅堆堊堋堕堙堝堡堤堪堯堰報場堵堺堽塀塁塊塋塑塒塔塗塘塙塚塞塢塩填塰塲塵塹塾境墅墓増墜墟墨墫墮墳墸墹墺墻墾壁壅壇壊壌壑壓壕壗壘壙壜壞壟壤壥士壬壮壯声壱売壷壹壺壻壼壽夂変夊夏夐夕外夘夙多夛夜夢夥大天太夫夬夭央失夲夷夸夾奄奇奈奉奎奏奐契奔奕套奘奚奠奢奥奧奨奩奪奬奮女奴奸好妁如妃妄妊妍妓妖妙妛妝妣妥妨妬妲妹妻妾姆姉始姐姑姓委姙姚姜姥姦姨姪姫姶姻姿威娃娉娑娘娚娜娟娠娥娩娯娵娶娼婀婁婆婉婚婢婦婪婬婿媒媚媛媼媽媾嫁嫂嫉嫋嫌嫐嫖嫗嫡嫣嫦嫩嫺嫻嬉嬋嬌嬖嬢嬪嬬嬰嬲嬶嬾孀孃孅子孑孔孕字存孚孛孜孝孟季孤孥学孩孫孰孱孳孵學孺宀它宅宇守安宋完宍宏宕宗官宙定宛宜宝実客宣室宥宦宮宰害宴宵家宸容宿寂寃寄寅密寇寉富寐寒寓寔寛寝寞察寡寢寤寥實寧寨審寫寮寰寳寵寶寸寺対寿封専射尅将將專尉尊尋對導小少尓尖尚尠尢尤尨尭就尸尹尺尻尼尽尾尿局屁居屆屈届屋屍屎屏屐屑屓展属屠屡層履屬屮屯山屶屹岌岐岑岔岡岨岩岫岬岱岳岶岷岸岻岼岾峅峇峙峠峡峨峩峪峭峯峰島峺峻峽崇崋崎崑崔崕崖崗崘崙崚崛崟崢崩嵋嵌嵎嵐嵒嵜嵩嵬嵯嵳嵶嶂嶄嶇嶋嶌嶐嶝嶢嶬嶮嶷嶺嶼嶽巉巌巍巒巓巖巛川州巡巣工左巧巨巫差己已巳巴巵巷巻巽巾市布帆帋希帑帖帙帚帛帝帥師席帯帰帳帶帷常帽幀幃幄幅幇幌幎幔幕幗幟幡幢幣幤干平年幵并幸幹幺幻幼幽幾广庁広庄庇床序底庖店庚府庠度座庫庭庵庶康庸廁廂廃廈廉廊廏廐廓廖廚廛廝廟廠廡廢廣廨廩廬廰廱廳廴延廷廸建廻廼廾廿弁弃弄弉弊弋弌弍式弐弑弓弔引弖弗弘弛弟弥弦弧弩弭弯弱張強弸弼弾彁彈彊彌彎彑当彖彗彙彜彝彡形彦彩彪彫彬彭彰影彳彷役彼彿往征徂徃径待徇很徊律後徐徑徒従得徘徙從徠御徨復循徭微徳徴徹徼徽心必忌忍忖志忘忙応忝忠忤快忰忱念忸忻忽忿怎怏怐怒怕怖怙怛怜思怠怡急怦性怨怩怪怫怯怱怺恁恂恃恆恊恋恍恐恒恕恙恚恟恠恢恣恤恥恨恩恪恫恬恭息恰恵恷悁悃悄悉悋悌悍悒悔悖悗悚悛悟悠患悦悧悩悪悲悳悴悵悶悸悼悽情惆惇惑惓惘惚惜惟惠惡惣惧惨惰惱想惴惶惷惹惺惻愀愁愃愆愈愉愍愎意愕愚愛感愡愧愨愬愴愼愽愾愿慂慄慇慈慊態慌慍慎慓慕慘慙慚慝慟慢慣慥慧慨慫慮慯慰慱慳慴慵慶慷慾憂憇憊憎憐憑憔憖憙憚憤憧憩憫憬憮憲憶憺憾懃懆懇懈應懊懋懌懍懐懣懦懲懴懶懷懸懺懼懽懾懿戀戈戉戊戌戍戎成我戒戔或戚戛戝戞戟戡戦截戮戯戰戲戳戴戸戻房所扁扇扈扉手才扎打払托扛扞扠扣扨扮扱扶批扼找承技抂抃抄抉把抑抒抓抔投抖抗折抛抜択披抬抱抵抹抻押抽拂担拆拇拈拉拊拌拍拏拐拑拒拓拔拗拘拙招拜拝拠拡括拭拮拯拱拳拵拶拷拾拿持挂指挈按挌挑挙挟挧挨挫振挺挽挾挿捉捌捍捏捐捕捗捜捧捨捩捫据捲捶捷捺捻掀掃授掉掌掎掏排掖掘掛掟掠採探掣接控推掩措掫掬掲掴掵掻掾揀揃揄揆揉描提插揖揚換握揣揩揮援揶揺搆損搏搓搖搗搜搦搨搬搭搴搶携搾摂摎摘摧摩摯摶摸摺撃撈撒撓撕撚撞撤撥撩撫播撮撰撲撹撻撼擁擂擅擇操擒擔擘據擠擡擢擣擦擧擬擯擱擲擴擶擺擽擾攀攅攘攜攝攣攤攪攫攬支攴攵收攷攸改攻放政故效敍敏救敕敖敗敘教敝敞敢散敦敬数敲整敵敷數斂斃文斈斉斌斎斐斑斗料斛斜斟斡斤斥斧斫斬断斯新斷方於施旁旃旄旅旆旋旌族旒旗旙旛无旡既日旦旧旨早旬旭旱旺旻昂昃昆昇昊昌明昏易昔昜星映春昧昨昭是昴昵昶昼昿晁時晃晄晉晋晏晒晝晞晟晢晤晦晧晨晩普景晰晴晶智暁暃暄暇暈暉暎暑暖暗暘暝暢暦暫暮暴暸暹暼暾曁曄曇曉曖曙曚曜曝曠曦曩曰曲曳更曵曷書曹曼曽曾替最會月有朋服朏朔朕朖朗望朝朞期朦朧木未末本札朮朱朴朶朷朸机朽朿杁杆杉李杏材村杓杖杙杜杞束杠条杢杣杤来杪杭杯杰東杲杳杵杷杼松板枅枇枉枋枌析枕林枚果枝枠枡枢枦枩枯枳枴架枷枸枹柁柄柆柊柎柏某柑染柔柘柚柝柞柢柤柧柩柬柮柯柱柳柴柵査柾柿栂栃栄栓栖栗栞校栢栩株栫栲栴核根格栽桀桁桂桃框案桍桎桐桑桓桔桙桜桝桟档桧桴桶桷桾桿梁梃梅梍梏梓梔梗梛條梟梠梢梦梧梨梭梯械梱梳梵梶梹梺梼棄棆棉棊棋棍棒棔棕棗棘棚棟棠棡棣棧森棯棲棹棺椀椁椄椅椈椋椌植椎椏椒椙椚椛検椡椢椣椥椦椨椪椰椴椶椹椽椿楊楓楔楕楙楚楜楝楞楠楡楢楪楫業楮楯楳楴極楷楸楹楼楽楾榁概榊榎榑榔榕榛榜榠榧榮榱榲榴榻榾榿槁槃槇槊構槌槍槎槐槓様槙槝槞槧槨槫槭槲槹槻槽槿樂樅樊樋樌樒樓樔樗標樛樞樟模樢樣権横樫樮樵樶樸樹樺樽橄橇橈橋橘橙機橡橢橦橲橸橿檀檄檍檎檐檗檜檠檢檣檪檬檮檳檸檻櫁櫂櫃櫑櫓櫚櫛櫞櫟櫨櫪櫺櫻欄欅權欒欖欝欟欠次欣欧欲欷欸欹欺欽款歃歇歉歌歎歐歓歔歙歛歟歡止正此武歩歪歯歳歴歸歹死歿殀殃殄殆殉殊残殍殕殖殘殞殤殪殫殯殱殲殳殴段殷殺殻殼殿毀毅毆毋母毎毒毓比毘毛毟毫毬毯毳氈氏民氓气気氛氣氤水氷永氾汀汁求汎汐汕汗汚汝汞江池汢汨汪汰汲汳決汽汾沁沂沃沈沌沍沐沒沓沖沙沚沛没沢沫沮沱河沸油沺治沼沽沾沿況泄泅泉泊泌泓法泗泙泛泝泡波泣泥注泪泯泰泱泳洋洌洒洗洙洛洞洟津洩洪洫洲洳洵洶洸活洽派流浄浅浙浚浜浣浤浦浩浪浬浮浴海浸浹涅消涌涎涓涕涙涛涜涯液涵涸涼淀淅淆淇淋淌淑淒淕淘淙淞淡淤淦淨淪淫淬淮深淳淵混淹淺添清渇済渉渊渋渓渕渙渚減渝渟渠渡渣渤渥渦温渫測渭渮港游渺渾湃湊湍湎湖湘湛湟湧湫湮湯湲湶湾湿満溂溌溏源準溘溜溝溟溢溥溪溯溲溶溷溺溽滂滄滅滉滋滌滑滓滔滕滝滞滬滯滲滴滷滸滾滿漁漂漆漉漏漑漓演漕漠漢漣漫漬漱漲漸漾漿潁潅潔潘潛潜潟潤潦潭潮潯潰潴潸潺潼澀澁澂澄澆澎澑澗澡澣澤澪澱澳澹激濁濂濃濆濔濕濘濛濟濠濡濤濫濬濮濯濱濳濶濺濾瀁瀉瀋瀏瀑瀕瀘瀚瀛瀝瀞瀟瀦瀧瀬瀰瀲瀾灌灑灘灣火灯灰灸灼災炉炊炎炒炙炬炭炮炯炳炸点為烈烋烏烙烝烟烱烹烽焉焔焙焚焜無焦然焼煉煌煎煕煖煙煢煤煥煦照煩煬煮煽熄熈熊熏熔熕熙熟熨熬熱熹熾燃燈燉燎燐燒燔燕燗營燠燥燦燧燬燭燮燵燹燻燼燿爆爍爐爛爨爪爬爭爰爲爵父爺爻爼爽爾爿牀牆片版牋牌牒牘牙牛牝牟牡牢牧物牲牴特牽牾犀犁犂犇犒犖犠犢犧犬犯犲状犹狂狃狄狆狎狐狒狗狙狛狠狡狢狩独狭狷狸狹狼狽猊猖猗猛猜猝猟猥猩猪猫献猯猴猶猷猾猿獄獅獎獏獗獣獨獪獰獲獵獸獺獻玄率玉王玖玩玲玳玻珀珂珈珊珍珎珞珠珥珪班珮珱珸現球琅理琉琢琥琲琳琴琵琶琺琿瑁瑕瑙瑚瑛瑜瑞瑟瑠瑣瑤瑩瑪瑯瑰瑳瑶瑾璃璋璞璢璧環璽瓊瓏瓔瓜瓠瓢瓣瓦瓧瓩瓮瓰瓱瓲瓶瓷瓸甃甄甅甌甍甎甑甓甕甘甚甜甞生産甥甦用甫甬田由甲申男甸町画甼畄畆畉畊畋界畍畏畑畔留畚畛畜畝畠畢畤略畦畧畩番畫畭異畳畴當畷畸畿疂疆疇疉疊疋疎疏疑疔疚疝疣疥疫疱疲疳疵疸疹疼疽疾痂痃病症痊痍痒痔痕痘痙痛痞痢痣痩痰痲痳痴痺痼痾痿瘁瘉瘋瘍瘟瘠瘡瘢瘤瘧瘰瘴瘻療癆癇癈癌癒癖癘癜癡癢癧癨癩癪癬癰癲癶癸発登發白百皀皃的皆皇皈皋皎皐皓皖皙皚皮皰皴皷皸皹皺皿盂盃盆盈益盍盒盖盗盛盜盞盟盡監盤盥盧盪目盲直相盻盾省眄眇眈眉看県眛眞真眠眤眥眦眩眷眸眺眼着睇睚睛睡督睥睦睨睫睹睾睿瞋瞎瞑瞞瞠瞥瞬瞭瞰瞳瞶瞹瞻瞼瞽瞿矇矍矗矚矛矜矢矣知矧矩短矮矯石矼砂砌砒研砕砠砥砦砧砲破砺砿硅硝硫硬硯硲硴硼碁碆碇碌碍碎碑碓碕碗碚碣碧碩碪碯碵確碼碾磁磅磆磊磋磐磑磔磚磧磨磬磯磴磽礁礇礎礑礒礙礦礪礫礬示礼社祀祁祇祈祉祐祓祕祖祗祚祝神祟祠祢祥票祭祷祺祿禀禁禄禅禊禍禎福禝禦禧禪禮禰禳禹禺禽禾禿秀私秉秋科秒秕秘租秡秣秤秦秧秩秬称移稀稈程稍税稔稗稘稙稚稜稟稠種稱稲稷稻稼稽稾稿穀穂穃穆穉積穎穏穐穗穡穢穣穩穫穰穴究穹空穽穿突窃窄窈窒窓窕窖窗窘窟窩窪窮窯窰窶窺窿竃竄竅竇竈竊立竍竏竒竓竕站竚竜竝竟章竡竢竣童竦竪竭端竰競竸竹竺竿笂笄笆笈笊笋笏笑笘笙笛笞笠笥符笨第笳笵笶笹筅筆筈等筋筌筍筏筐筑筒答策筝筥筧筬筮筰筱筴筵筺箆箇箋箍箏箒箔箕算箘箙箚箜箝箟管箪箭箱箴箸節篁範篆篇築篋篌篏篝篠篤篥篦篩篭篳篶篷簀簇簍簑簒簓簔簗簟簡簣簧簪簫簷簸簽簾簿籀籃籌籍籏籐籔籖籘籟籠籤籥籬米籵籾粁粂粃粉粋粍粐粒粕粗粘粛粟粡粢粤粥粧粨粫粭粮粱粲粳粹粽精糀糂糅糊糎糒糖糘糜糞糟糠糢糧糯糲糴糶糸糺系糾紀紂約紅紆紊紋納紐純紕紗紘紙級紛紜素紡索紫紬紮累細紲紳紵紹紺紿終絃組絅絆絋経絎絏結絖絛絞絡絢絣給絨絮統絲絳絵絶絹絽綉綏經継続綛綜綟綢綣綫綬維綮綯綰綱網綴綵綸綺綻綽綾綿緇緊緋総緑緒緕緘線緜緝緞締緡緤編緩緬緯緲練緻縁縄縅縉縊縋縒縛縞縟縡縢縣縦縫縮縱縲縵縷縹縺縻總績繁繃繆繊繋繍織繕繖繙繚繝繞繦繧繩繪繭繰繹繻繼繽繿纂纃纈纉續纎纏纐纒纓纔纖纛纜缶缸缺罅罌罍罎罐网罔罕罘罟罠罧罨罩罪罫置罰署罵罷罸罹羂羃羅羆羇羈羊羌美羔羚羝羞羣群羨義羮羯羲羶羸羹羽翁翅翆翊翌習翔翕翠翡翦翩翫翰翳翹翻翼耀老考耄者耆耋而耐耒耕耗耘耙耜耡耨耳耶耻耽耿聆聊聒聖聘聚聞聟聡聢聨聯聰聲聳聴聶職聹聽聾聿肄肅肆肇肉肋肌肓肖肘肚肛肝股肢肥肩肪肬肭肯肱育肴肺胃胄胆背胎胖胙胚胛胝胞胡胤胥胯胱胴胸胼能脂脅脆脇脈脉脊脚脛脣脩脯脱脳脹脾腆腋腎腐腑腓腔腕腟腥腦腫腮腰腱腴腸腹腺腿膀膂膃膈膊膏膓膕膚膜膝膠膣膤膨膩膰膳膵膸膺膽膾膿臀臂臆臈臉臍臑臓臘臙臚臟臠臣臥臧臨自臭至致臺臻臼臾舁舂舅與興舉舊舌舍舎舐舒舖舗舘舛舜舞舟舩航舫般舮舳舵舶舷舸船艀艇艘艙艚艝艟艢艤艦艨艪艫艮良艱色艶艷艸艾芋芍芒芙芝芟芥芦芫芬芭芯花芳芸芹芻芽苅苑苒苓苔苗苙苛苜苞苟苡苣若苦苧苫英苳苴苹苺苻茂范茄茅茆茉茎茖茗茘茜茣茨茫茯茱茲茴茵茶茸茹荀荅草荊荏荐荒荘荳荵荷荻荼莅莇莉莊莎莓莖莚莞莟莠莢莨莪莫莱莵莽菁菅菊菌菎菓菖菘菜菟菠菩菫華菰菱菲菴菷菻菽萃萄萇萋萌萍萎萓萠萢萩萪萬萱萵萸萼落葆葉葎著葛葡葢董葦葩葫葬葭葮葯葱葵葷葹葺蒂蒄蒋蒐蒔蒙蒜蒟蒡蒭蒲蒸蒹蒻蒼蒿蓁蓄蓆蓉蓊蓋蓍蓐蓑蓖蓙蓚蓬蓮蓴蓼蓿蔀蔆蔑蔓蔔蔕蔗蔘蔚蔟蔡蔦蔬蔭蔵蔽蕀蕁蕃蕈蕉蕊蕋蕎蕕蕗蕘蕚蕣蕨蕩蕪蕭蕷蕾薀薄薇薈薊薐薑薔薗薙薛薜薤薦薨薩薪薫薬薮薯薹薺藁藉藍藏藐藕藜藝藤藥藩藪藷藹藺藻藾蘂蘆蘇蘊蘋蘓蘖蘗蘚蘢蘭蘯蘰蘿虍虎虐虔處虚虜虞號虧虫虱虹虻蚊蚋蚌蚓蚕蚣蚤蚩蚪蚫蚯蚰蚶蛄蛆蛇蛉蛋蛍蛎蛔蛙蛛蛞蛟蛤蛩蛬蛭蛮蛯蛸蛹蛻蛾蜀蜂蜃蜆蜈蜉蜊蜍蜑蜒蜘蜚蜜蜥蜩蜴蜷蜻蜿蝉蝋蝌蝎蝓蝕蝗蝙蝟蝠蝣蝦蝨蝪蝮蝴蝶蝸蝿螂融螟螢螫螯螳螺螻螽蟀蟄蟆蟇蟋蟐蟒蟠蟯蟲蟶蟷蟹蟻蟾蠅蠍蠎蠏蠑蠕蠖蠡蠢蠣蠧蠱蠶蠹蠻血衂衄衆行衍衒術街衙衛衝衞衡衢衣表衫衰衲衵衷衽衾衿袁袂袈袋袍袒袖袗袙袞袢袤被袮袰袱袴袵袷袿裁裂裃裄装裏裔裕裘裙補裝裟裡裨裲裳裴裸裹裼製裾褂褄複褊褌褐褒褓褝褞褥褪褫褶褸褻襁襃襄襌襍襖襞襟襠襤襦襪襭襯襲襴襷襾西要覃覆覇覈覊見規覓視覗覘覚覡覦覧覩親覬覯覲観覺覽覿觀角觚觜觝解触觧觴觸言訂訃計訊訌討訐訓訖託記訛訝訟訣訥訪設許訳訴訶診註証詁詆詈詐詑詒詔評詛詞詠詢詣試詩詫詬詭詮詰話該詳詼誂誄誅誇誉誌認誑誓誕誘誚語誠誡誣誤誥誦誨説読誰課誹誼調諂諄談請諌諍諏諒論諚諛諜諞諠諡諢諤諦諧諫諭諮諱諳諷諸諺諾謀謁謂謄謇謌謎謐謔謖謗謙謚講謝謠謡謦謨謫謬謳謹謾譁證譌譎譏譖識譚譛譜譟警譫譬譯議譱譲譴護譽讀讃變讌讎讐讒讓讖讙讚谷谺谿豁豆豈豊豌豎豐豕豚象豢豪豫豬豸豹豺豼貂貅貉貊貌貍貎貔貘貝貞負財貢貧貨販貪貫責貭貮貯貰貲貳貴貶買貸費貼貽貿賀賁賂賃賄資賈賊賍賎賑賓賚賛賜賞賠賢賣賤賦質賭賺賻購賽贄贅贇贈贊贋贍贏贐贓贔贖赤赦赧赫赭走赱赳赴起趁超越趙趣趨足趺趾跂跋跌跏跖跚跛距跟跡跣跨跪跫路跳践跼跿踈踉踊踏踐踝踞踟踪踰踴踵蹂蹄蹇蹈蹉蹊蹌蹐蹕蹙蹟蹠蹣蹤蹲蹴蹶蹼躁躄躅躇躊躋躍躑躓躔躙躡躪身躬躯躰躱躾軅軆軈車軋軌軍軒軛軟転軣軫軸軻軼軽軾較輅載輊輌輒輓輔輕輙輛輜輝輟輦輩輪輯輳輸輹輻輾輿轂轄轅轆轉轌轍轎轗轜轟轡轢轣轤辛辜辞辟辣辧辨辭辮辯辰辱農辷辺辻込辿迂迄迅迎近返迚迢迥迦迩迪迫迭迯述迴迷迸迹迺追退送逃逅逆逋逍逎透逐逑逓途逕逖逗這通逝逞速造逡逢連逧逮週進逵逶逸逹逼逾遁遂遅遇遉遊運遍過遏遐遑遒道達違遖遘遙遜遞遠遡遣遥遨適遭遮遯遲遵遶遷選遺遼遽避邀邁邂邃還邇邉邊邏邑那邦邨邪邯邱邵邸郁郊郎郛郡郢郤部郭郵郷都鄂鄒鄙鄭鄰鄲酉酊酋酌配酎酒酔酖酘酢酣酥酩酪酬酲酳酵酷酸醂醇醉醋醍醐醒醗醜醢醤醪醫醯醴醵醸醺釀釁釆采釈釉釋里重野量釐金釖釘釛釜針釟釡釣釦釧釵釶釼釿鈍鈎鈑鈔鈕鈞鈩鈬鈴鈷鈿鉄鉅鉈鉉鉋鉐鉗鉚鉛鉞鉢鉤鉦鉱鉾銀銃銅銑銓銕銖銘銚銛銜銭銷銹鋏鋒鋤鋩鋪鋭鋲鋳鋸鋺鋼錆錏錐錘錙錚錠錢錣錦錨錫錬錮錯録錵錺錻鍄鍋鍍鍔鍖鍛鍜鍠鍬鍮鍵鍼鍾鎌鎔鎖鎗鎚鎧鎬鎭鎮鎰鎹鏃鏈鏐鏑鏖鏗鏘鏝鏡鏤鏥鏨鐃鐇鐐鐓鐔鐘鐙鐚鐡鐫鐵鐶鐸鐺鑁鑄鑑鑒鑓鑚鑛鑞鑠鑢鑪鑰鑵鑷鑼鑽鑾鑿钁長門閂閃閇閉閊開閏閑間閔閖閘閙閠関閣閤閥閧閨閭閲閹閻閼閾闃闇闊闌闍闔闕闖闘關闡闢闥阜阡阨阪阮阯防阻阿陀陂附陋陌降陏限陛陜陝陞陟院陣除陥陦陪陬陰陲陳陵陶陷陸険陽隅隆隈隊隋隍階随隔隕隗隘隙際障隠隣隧隨險隰隱隲隴隶隷隸隹隻隼雀雁雄雅集雇雉雋雌雍雎雑雕雖雙雛雜離難雨雪雫雰雲零雷雹電需霄霆震霈霊霍霎霏霑霓霖霙霜霞霤霧霪霰露霸霹霽霾靂靄靆靈靉青靖静靜非靠靡面靤靦靨革靫靭靱靴靹靺靼鞁鞄鞅鞆鞋鞍鞏鞐鞘鞜鞠鞣鞦鞨鞫鞭鞳鞴韃韆韈韋韓韜韭韮韲音韵韶韻響頁頂頃項順須頌頏預頑頒頓頗領頚頡頤頬頭頴頷頸頻頼頽顆顋題額顎顏顔顕願顛類顧顫顯顰顱顳顴風颪颯颱颶飃飄飆飛飜食飢飩飫飭飮飯飲飴飼飽飾餃餅餉養餌餐餒餓餔餘餝餞餠餡餤館餬餮餽餾饂饅饉饋饌饐饑饒饕饗首馗馘香馥馨馬馭馮馳馴馼駁駄駅駆駈駐駑駒駕駘駛駝駟駢駭駮駱駲駸駻駿騁騅騎騏騒験騙騨騫騰騷騾驀驂驃驅驍驕驗驚驛驟驢驤驥驩驪驫骨骭骰骸骼髀髄髏髑髓體高髞髟髢髣髦髪髫髭髮髯髱髴髷髻鬆鬘鬚鬟鬢鬣鬥鬧鬨鬩鬪鬮鬯鬱鬲鬻鬼魁魂魃魄魅魍魎魏魑魔魘魚魯魴鮃鮎鮑鮒鮓鮖鮗鮟鮠鮨鮪鮫鮭鮮鮴鮹鯀鯆鯉鯊鯏鯑鯒鯔鯖鯛鯡鯢鯣鯤鯨鯰鯱鯲鯵鰄鰆鰈鰉鰊鰌鰍鰐鰒鰓鰔鰕鰛鰡鰤鰥鰭鰮鰯鰰鰲鰹鰺鰻鰾鱆鱇鱈鱒鱗鱚鱠鱧鱶鱸鳥鳧鳩鳫鳬鳰鳳鳴鳶鴃鴆鴇鴈鴉鴎鴒鴕鴛鴟鴣鴦鴨鴪鴫鴬鴻鴾鴿鵁鵄鵆鵈鵐鵑鵙鵜鵝鵞鵠鵡鵤鵬鵯鵲鵺鶇鶉鶏鶚鶤鶩鶫鶯鶲鶴鶸鶺鶻鷁鷂鷄鷆鷏鷓鷙鷦鷭鷯鷲鷸鷹鷺鷽鸚鸛鸞鹵鹸鹹鹽鹿麁麈麋麌麑麒麓麕麗麝麟麥麦麩麪麭麸麹麺麻麼麾麿黄黌黍黎黏黐黒黔默黙黛黜黝點黠黥黨黯黴黶黷黹黻黼黽鼇鼈鼎鼓鼕鼠鼡鼬鼻鼾齊齋齎齏齒齔齟齠齡齢齣齦齧齪齬齲齶齷龍龕龜龝龠!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[ ]^_`abcdefghijklmnopqrstuvwxyz{|}~'’\"「」々。"; +} +} diff --git a/intra/src/helper/ANEFix.as b/intra/src/helper/ANEFix.as new file mode 100644 index 0000000..c1813dd --- /dev/null +++ b/intra/src/helper/ANEFix.as @@ -0,0 +1,161 @@ +package helper +{ + import flash.desktop.NativeProcess; + import flash.desktop.NativeProcessStartupInfo; + import flash.events.IOErrorEvent; + import flash.events.NativeProcessExitEvent; + import flash.events.ProgressEvent; + import flash.external.ExtensionContext; + import flash.filesystem.File; + import flash.filesystem.FileMode; + import flash.filesystem.FileStream; + /** + * ... + * @author Melos Han-Tani + */ + public class ANEFix + { + private static var + callback_error:Function = null, + callback_ioerror:Function = null, + callback_output:Function = null; + + /** @param extensionID:String id of the ane extension to fix + * @param onExit:Function callback function with first arguments the value of extensionID and for the second the boolean state of the fix operation + **/ + public static function fixANE(extensionID:String, onExit:Function = null,is_steam:Boolean = false):Boolean { + + if (!NativeProcess.isSupported) { + if (onExit != null) { + trace("Nope! 30"); + onExit(extensionID, false); + } + trace("Nope! 33"); + return false; + } + // init event listners + if (callback_output==null) + callback_output = + function(event:ProgressEvent):void { + var process:NativeProcess = event.target as NativeProcess; + trace("OUT -", process.standardOutput.readUTFBytes(process.standardError.bytesAvailable)); + }; + if (callback_error==null) + callback_error = + function(event:ProgressEvent):void { + var process:NativeProcess = event.target as NativeProcess; + trace("ERROR -", process.standardError.readUTFBytes(process.standardError.bytesAvailable)); + }; + if (callback_ioerror==null) + callback_ioerror = + function(event:IOErrorEvent):void { + trace(event.toString()); + }; + + var ext_dir:File; + try { + ext_dir = ExtensionContext.getExtensionDirectory(extensionID); + } catch (e:*) { + if (onExit != null) { + trace("Nope! 59"); + onExit(extensionID, false); + } + trace("Nope! 63"); + return false; + } + if (!ext_dir.isDirectory) { + if (onExit != null) { + trace("Nope! 64"); + onExit(extensionID, false); + } + trace("Nope! 71"); + return false; + } + + var ane_dir:File = ext_dir.resolvePath("META-INF/ANE/"); + var ext_stream:FileStream = new FileStream(); + ext_stream.open(ane_dir.resolvePath("extension.xml"), FileMode.READ); + var ext_xml:XML = XML(ext_stream.readUTFBytes(ext_stream.bytesAvailable)); + ext_stream.close(); + + var defaultNS:Namespace = ext_xml.namespace(""); + var framework:String = ext_xml.defaultNS::platforms.defaultNS::platform.(@name=="MacOS-x86").defaultNS::applicationDeployment.defaultNS::nativeLibrary.text(); + if (!framework) { + if (onExit != null) { + trace("Nope! 80"); + onExit(extensionID, false); + } + trace("Nope! 85"); + return false; + } + + var framework_dir:File = ane_dir.resolvePath('MacOS-x86/'+framework); + // list of symlink files + var symlink:Vector. = new Vector.(3, true); + symlink[0] = 'Resources'; + symlink[1] = framework_dir.name.substr(0, framework_dir.name.length-framework_dir.extension.length-1); + symlink[2] = 'Versions/Current'; + var fileToFix:int = symlink.length, + fileFixed:int = 0, + fileFailed:int = 0; + symlink.every( + function(item:String, index:int, a:Vector.):Boolean { + var f:File = framework_dir.resolvePath(item); + if (!f.isSymbolicLink) { + var fs:FileStream = new FileStream(); + fs.open(f, FileMode.READ); + var lnk:String = fs.readUTFBytes(fs.bytesAvailable); + fs.close(); + var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); + nativeProcessStartupInfo.executable = new File('/bin/ln'); + nativeProcessStartupInfo.workingDirectory = f.parent; + nativeProcessStartupInfo.arguments = new Vector.(3, true); + nativeProcessStartupInfo.arguments[0] = "-Fs"; + nativeProcessStartupInfo.arguments[1] = lnk; + nativeProcessStartupInfo.arguments[2] = f.name; + + + var process:NativeProcess = new NativeProcess(); + process.start(nativeProcessStartupInfo); + //process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, callback_output); + process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, callback_error); + process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, callback_ioerror); + process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, callback_ioerror); + process.addEventListener( + NativeProcessExitEvent.EXIT, + function (event:NativeProcessExitEvent):void { + if (event.exitCode==0) + fileFixed++; + else + fileFailed++ + + if (fileFixed+fileFailed==fileToFix) { + if (fileFailed==0) { + trace('ANE '+extensionID+' fixed.'); + } else { + trace('Unable to fix ANE ' + extensionID + '!'); + } + if (onExit != null) { + trace("Nope! 133"); + onExit(extensionID, fileFailed == 0); + } + } + } + ); + } else { + trace("A file fixed.? 146"); + fileFixed++; + } + return true; + } + ); + if (fileFixed == 3) { + if (onExit != null) { + onExit(extensionID, true); + } + } + trace("Exiting: 150"); + return true; + } + } +} \ No newline at end of file diff --git a/intra/src/helper/Achievements.as b/intra/src/helper/Achievements.as new file mode 100644 index 0000000..4a17ecb --- /dev/null +++ b/intra/src/helper/Achievements.as @@ -0,0 +1,255 @@ +package helper +{ + import com.amanitadesign.steam.FRESteamWorks; + import com.amanitadesign.steam.SteamConstants; + import com.amanitadesign.steam.SteamEvent; + import flash.desktop.NativeApplication; + import flash.utils.ByteArray; + import global.Registry; + import org.flixel.FlxG; + import org.flixel.FlxGame; + public class Achievements + { + + private static var IS_NEWGROUNDS:Boolean = false; + public static var IS_KONG:Boolean = false; + public static var KONG_LOADED:Boolean = false; + public static var IS_STEAM:Boolean = true; + + public static const Card_1:int = 0; + public static const Card_7:int = 1; + public static const Extra_health_1:int = 2; + public static const Fast_fields:int = 3; + public static const No_damage_sunguy:int = 4; + public static const Trophy_1:int = 5; + public static const Greenlit:int = 6; + public static const Website:int = 7; + + public static const A_GET_BROOM:int = 8; + public static const A_GET_WINDMILL_CARD:int = 9; + public static const A_DEFEAT_BRIAR:int = 10; + + public static const A_100_PERCENT_ANY_TIME:int = 11; + public static const A_200_PERCENT:int = 12; + public static const A_GET_RED_CUBE:int = 13; + public static const A_GET_GREEN_CUBE:int = 14; + public static const A_GET_BLUE_CUBE:int = 15; + public static const A_GET_BW_CUBES:int = 16; + public static const A_CONSOLE:int = 17; + public static const A_GET_GOLDEN_POO:int = 18; + public static const A_GET_48_CARDS:int = 19; + public static const A_GET_49TH_CARD:int = 20; + + public static const A_ENDING_SUB_15_M:int = 21; + public static const A_100_PERCENT_SUB_3_HR:int = 22; + + public static const achvname:Object = { 8:"broom", 9: "windmill", 10: "briar", + 11: "100" , 12: "200" , 13: "red", 14: "green", 15: "blue", 16: "bw", + 17: "console", 18: "poo", 19: "48", 20: "49", 21: "fast", 22:"100fast"}; + + public static var Steamworks:FRESteamWorks; + + private static var did_init:Boolean = false; + public static var DEBUG_TEXT:String = ""; + + public static function init(root:*):void { + if (did_init) return; + did_init = true; + + } + + public static function kong_loaded():void { + KONG_LOADED = true; + } + + public static function init_steam():void { + DEBUG_TEXT += "In Init Steam\n"; + if (IS_STEAM && Steamworks == null) { + if (Intra.IS_LINUX) { + //return; + } + DEBUG_TEXT += "LOADING STEAM\n"; + Steamworks = new FRESteamWorks(); + Steamworks.addEventListener(SteamEvent.STEAM_RESPONSE, onSteamResponse); + if (Steamworks.init()) { + if (Steamworks.isReady) { + if (false == Intra.IS_LINUX) { + Steamworks.setCloudEnabledForApp(true); + } + DEBUG_TEXT += "STEAM LOADED\n"; + } + //DEBUG_TEXT = DEBUG_TEXT + "atest: " + Steamworks.setAchievement("ACH_WIN_ONE_GAME").toString() + "\n"; + //Steamworks.clearAchievement("ACH_WIN_ONE_GAME"); + //Steamworks.setStatFloat('FeetTraveled', 42.42); + //Steamworks.storeStats(); + //DEBUG_TEXT = DEBUG_TEXT + Steamworks.getStatFloat('FeetTraveled').toString() + "\n"; + // + + } else { + DEBUG_TEXT += "FAILED\n"; + } + } + } + + public static function get_completion_rate():int { + + // 36 Cards (+2) = 72 + // 10 health ups (+1) = 10 + // 4 broom upgrades (+4) = 16 + // Jump shoes (+2) = 2 + + // 12 Cards + // 13 weird items - all + 5 + + var rate:int = 0; + + for (var i:int = 0; i < 48; i++) { + if (Registry.card_states[i] == 1) { + if (i < 36) { + rate += 2; + } else { + rate += 4; + } + } + } + + rate += (Registry.MAX_HEALTH - 6); + + if (Registry.inventory[Registry.IDX_BROOM]) rate += 4; + if (Registry.inventory[Registry.IDX_WIDEN]) rate += 4; + if (Registry.inventory[Registry.IDX_LENGTHEN]) rate += 4; + if (Registry.inventory[Registry.IDX_TRANSFORMER]) rate += 4; + + if (Registry.inventory[Registry.IDX_JUMP]) rate += 2; + + for (i = 11; i <= Registry.IDX_WHITE; i++) { + if (Registry.inventory[i]) { + rate += 4; + } + } + + Achievements.DEBUG_TEXT += rate.toString() + "\n"; + return rate; + } + + public static function set_steam_achievements():void { + if (IS_STEAM && Steamworks != null && Steamworks.isReady) { + trace("Steam achievement state:", Registry.achivement_state); + for (var i:int = 8; i < 23; i++) { + if (Registry.achivement_state[i]) { + Steamworks.setAchievement(achvname[i]); + } + } + } + } + + public static function writeFileToCloud(fileName:String, data:Object):Boolean { + var dataOut:ByteArray = new ByteArray(); + dataOut.writeObject(data); + return Steamworks.fileWrite(fileName, dataOut); + } + + public static function readFileFromCloud(fileName:String):Object { + var dataIn:ByteArray = new ByteArray(); + var dataOut:Object = new Object(); + dataIn.position = 0; + dataIn.length = Steamworks.getFileSize(fileName); + DEBUG_TEXT += dataIn.length.toString(); + + if(dataIn.length>0 && Steamworks.fileRead(fileName,dataIn)){ + return dataIn.readObject(); + } + return null; + } + + + public static function is_100_percent():Boolean { + if (Registry.MAX_HEALTH >= 16 && Registry.inventory[Registry.IDX_TRANSFORMER] && Registry.inventory[Registry.IDX_WIDEN] && Registry.inventory[Registry.IDX_LENGTHEN] && Registry.nr_growths >= 37) { + Achievements.unlock(Achievements.A_100_PERCENT_ANY_TIME); + if (Registry.playtime < 3 * 60 * 60) { + Achievements.unlock(Achievements.A_100_PERCENT_SUB_3_HR); + } + return true; + } + return false; + } + + public static function is_200_percent():Boolean { + var a:Array = Registry.inventory; + if (is_100_percent() && Registry.nr_growths >= 49 && a[Registry.IDX_BLUE] && a[Registry.IDX_GREEN] && a[Registry.IDX_RED] && a[Registry.IDX_BLACK] && a[Registry.IDX_WHITE] && a[Registry.IDX_KITTY] && a[Registry.IDX_POO] && a[Registry.IDX_AUS_HEART] && a[Registry.IDX_ELECTRIC] && a[Registry.IDX_MARINA] && a[Registry.IDX_MELOS] && a[Registry.IDX_MISSINGNO] && a[Registry.IDX_SPAM]) { + Achievements.unlock(Achievements.A_200_PERCENT); + return true; + } + return false; + } + + public static function onSteamResponse(e:SteamEvent):void { + //Achievements.DEBUG_TEXT = DEBUG_TEXT + "STEAMresponse type:" + e.req_type + " response:" + e.response + "\n"; + switch(e.req_type){ + case SteamConstants.RESPONSE_OnUserStatsStored: + //DEBUG_TEXT = DEBUG_TEXT + "RESPONSE_OnUserStatsStored: " + e.response + "\n"; + break; + case SteamConstants.RESPONSE_OnUserStatsReceived: + //DEBUG_TEXT = DEBUG_TEXT + "RESPONSE_OnUserStatsReceived: " + e.response + "\n"; + break; + case SteamConstants.RESPONSE_OnAchievementStored: + //DEBUG_TEXT = DEBUG_TEXT + "RESPONSE_OnAchievementStored: " + e.response + "\n"; + break; + case 3: + //case SteamConstants.RESPONSE_OnGameOverlayActivated: + //FlxGame.HARD_PAUSED = !FlxGame.HARD_PAUSED; // This is probably not the right hting to do. + break; + default: + } + } + + + + public static function unlock_all():void { + for (var i:int = 8; i < 23; i++) { + unlock(i); + } + } + public static function unlock(id:int):void { + if (!IS_STEAM && false == Intra.is_web) return; + + if (IS_STEAM) { + trace("Achievement: ", id, achvname[id]); + + + if (Steamworks != null && Steamworks.isReady) { + switch (id) { + case A_GET_BROOM://** + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + case A_GET_WINDMILL_CARD: //** + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + case A_100_PERCENT_ANY_TIME:// ** + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + case A_100_PERCENT_SUB_3_HR:// ** + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + case A_GET_48_CARDS:// + Registry.achivement_state[id] = true; + Steamworks.setAchievement(achvname[id]); + break; + } + } + } + + + + } + + } + +} \ No newline at end of file diff --git a/intra/src/helper/Cutscene.as b/intra/src/helper/Cutscene.as new file mode 100644 index 0000000..5b25fee --- /dev/null +++ b/intra/src/helper/Cutscene.as @@ -0,0 +1,469 @@ +package helper +{ + import data.Common_Sprites; + import data.CSV_Data; + import data.TileData; + import entity.decoration.Solid_Sprite; + import entity.interactive.Dungeon_Statue; + import entity.interactive.Terminal_Gate; + import flash.geom.Point; + import global.Registry; + import org.flixel.FlxG; + import org.flixel.FlxGroup; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxTileblock; + import org.flixel.FlxTilemap; + import org.flixel.FlxU; + import states.PushableFlxState; + public class Cutscene extends PushableFlxState + { + /* Cutscene types */ + public static const Red_Cave_Left:int = 0; + public static const Red_Cave_Right:int = 1; + public static const Red_Cave_North:int = 2; + public static const Terminal_Gate_Bedroom:int = 3; + public static const Terminal_Gate_Redcave:int = 4; + public static const Terminal_Gate_Crowd:int = 5; + public static const Windmill_Opening:int = 6; + + // pointers to functions for transitioning in and out of the cutscene + private var transition_in:Function; + private var transition_out:Function; + private var step_cutscene:Function; + + // parameters you set that will be used in the above functions + private var tran_in_args:Array = new Array(1, 2); + private var tran_out_args:Array = new Array(3, 4); + + public const s_transition_in:int = -1; + public const s_in_progress:int = 0; + public const s_transition_out:int = 2; + public const s_done:int = 3; + public var state:int = -1; + + public var timer:Number; + public var timer_max:Number; + public var pushdown:int = 0; + public var pushee:FlxSprite; + + public var entity_1:FlxSprite; + public var entity_2:FlxSprite; + public var entity_3:FlxSprite; + + private var ctr_cutscene:int = 0; + + private var _parent:*; + + + public var scene_1:FlxTilemap; + public var scene_2:FlxTilemap; + public var scene_3:FlxTilemap; + + public var fade:FlxSprite; + + public function Cutscene(v_parent:*) { + _parent = v_parent; + create(); + } + + + /* Initialize the entities with each cutscene */ + override public function create():void + { + transition_in = do_nothing; + transition_out = do_nothing; + switch (Registry.CURRENT_CUTSCENE) { + case Red_Cave_Left: + transition_in = red_in; + transition_out = red_out; + step_cutscene = step_red_cave; + timer = timer_max = 0.02; + inst_red_cave_left(); + //Load the sprites and store 'em + //Pick a section of map to load from the right map and load it + break; + case Red_Cave_North: + transition_in = red_in; + transition_out = red_out; + step_cutscene = step_red_cave; + timer = timer_max = 0.02; + inst_red_cave_north(); + break; + case Red_Cave_Right: + transition_in = red_in; + transition_out = red_out; + step_cutscene = step_red_cave; + timer = timer_max = 0.02; + inst_red_cave_right(); + break; + case Terminal_Gate_Bedroom: + case Terminal_Gate_Crowd: + case Terminal_Gate_Redcave: + transition_in = terminal_gate_in; + transition_out = terminal_gate_out; + step_cutscene = step_terminal_gate; + inst_terminal_gate(); + + break; + case Windmill_Opening: + transition_in = windmill_in; + transition_out = windmill_out; + step_cutscene = step_windmill_opening; + inst_windmill(); + break; + } + } + + override public function update():void + { + if (state == s_transition_in) { + transition_in.apply(null, tran_in_args); + } else if (state == s_in_progress) { + step_cutscene(); + } else if (state == s_transition_out) { + transition_out.apply(null, tran_out_args); + } else if (state == s_done) { + + } + super.update(); + } + + public function do_nothing():void { + + } + + private function windmill_in(a:int, b:int):void { + state = s_in_progress; + } + private function windmill_out(a:int, b:int):void { + state = s_done; + } + private function step_windmill_opening():void { + + switch (ctr_cutscene) { + case 0: + Registry.volume_scale -= 0.01; + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + if (Registry.volume_scale <= 0) { + Registry.volume_scale = 0; + Registry.sound_data.wb_tap_ground.play(); + ctr_cutscene += 2; + } else { + Registry.volume_scale = 0; + } + break; + case 1: + break; + case 2: + ctr_cutscene++; + fade.exists = true; + fade.alpha = 0; + break; + case 3: + fade.alpha += 0.01; + if (fade.alpha == 1) { + ctr_cutscene++; + entity_1.exists = scene_1.exists = true; + } + break; + case 4: // Move bedroom satue + fade.alpha -= 0.01; + if (fade.alpha <= 0.45 && fade.alpha > 0.43) { + Registry.sound_data.red_cave_rise.play(); + } + if (fade.alpha == 0) { + if (EventScripts.send_property_to(entity_1, "y", 20, 0.2)) { + Registry.sound_data.wb_hit_ground.play(); + FlxG.shake(0.05, 0.5); + ctr_cutscene++; + } + } + break; + case 5: + fade.alpha += 0.01; + if (fade.alpha == 1) { + entity_1.exists = scene_1.exists = false; + entity_2.exists = scene_2.exists = true; + ctr_cutscene++; + } + break; + case 6: // move red stat + fade.alpha -= 0.01; + if (fade.alpha <= 0.45 && fade.alpha > 0.43) { + Registry.sound_data.red_cave_rise.play(); + } + if (fade.alpha == 0) { + if (EventScripts.send_property_to(entity_2, "x", 4 * 16 + 32, 0.2)) { + Registry.sound_data.wb_hit_ground.play(); + FlxG.shake(0.05, 0.5); + ctr_cutscene++; + } + } + break; + case 7: + fade.alpha += 0.01; + if (fade.alpha == 1) { + entity_2.exists = scene_2.exists = false; + entity_3.exists = scene_3.exists = true; + ctr_cutscene++; + } + break; + case 8: // move blue stat + fade.alpha -= 0.01; + if (fade.alpha <= 0.45 && fade.alpha > 0.43) { + Registry.sound_data.red_cave_rise.play(); + } + if (fade.alpha == 0) { + if (EventScripts.send_property_to(entity_3, "x", 4 * 16 + 32, 0.2)) { + Registry.sound_data.wb_hit_ground.play(); + FlxG.shake(0.05, 0.5); + ctr_cutscene++; + } + } + break; + case 9: + fade.alpha += 0.01; + if (fade.alpha == 1) { + ctr_cutscene++; + entity_3.exists = scene_3.exists = false; + } + break; + case 10: + fade.alpha -= 0.01; + if (Registry.volume_scale < 1) { + Registry.volume_scale += 0.01; + } else { + Registry.volume_scale = 1; + } + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + if (fade.alpha == 0 && Registry.volume_scale == 1) { + state = s_transition_out; + Registry.sound_data.start_song_from_title("WINDMILL"); + } + break; + + } + } + + private function red_out(a:int, b:int):void { + state = s_done; + switch (Registry.CURRENT_CUTSCENE) { + case Cutscene.Red_Cave_Left: + Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Left] = 1; break; + case Cutscene.Red_Cave_Right: + Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Right] = 1; break; + case Cutscene.Red_Cave_North: + Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_North] = 1; break; + } + } + + private function red_in(a:int, b:int):void { + state = s_in_progress; + Registry.sound_data.red_cave_rise.play(); + } + + private function step_red_cave():void { + //perform the rise effect. + if (ctr_cutscene == 0) { + timer -= FlxG.elapsed; + if (timer < 0) { + pushdown--; + pushee.framePixels_y_push = pushdown; + + timer = timer_max; + FlxG.shake(0.05); + if (pushdown == 0) { + ctr_cutscene = 1; + timer = 1.5; + } + } + } else if (ctr_cutscene == 1) { + timer -= FlxG.elapsed; + if (timer < 0) { + ctr_cutscene++; + } + } else { + state = s_transition_out; + } + } + + + private function terminal_gate_out(a:int, b:int):void { + state = s_done; + switch (Registry.CURRENT_CUTSCENE) { + case Cutscene.Terminal_Gate_Bedroom: + Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Bedroom] = 1; + break; + case Cutscene.Terminal_Gate_Redcave: + Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Redcave] = 1; + break; + case Cutscene.Terminal_Gate_Crowd: + Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Crowd] = 1; + break; + } + } + + private function terminal_gate_in(a:int, b:int):void { + state = s_in_progress; + + } + + private function step_terminal_gate():void { + var tg:Terminal_Gate = entity_1 as Terminal_Gate; + switch (Registry.CURRENT_CUTSCENE) { + case Cutscene.Terminal_Gate_Bedroom: + tg.gate_bedroom.alpha -= 0.005; + if (tg.gate_bedroom.alpha == 0) { + state = s_transition_out; + } + break; + case Cutscene.Terminal_Gate_Redcave: + tg.gate_redcave.alpha -= 0.005; + if (tg.gate_redcave.alpha == 0) { + state = s_transition_out; + } + break; + case Cutscene.Terminal_Gate_Crowd: + tg.gate_crowd.alpha -= 0.005; + if (tg.gate_crowd.alpha == 0) { + state = s_transition_out; + } + break; + + } + } + /** + * loads a cutscenes view + * @param map_name The name of the map + * @param tileset the reference to the embedded tileste + * @param gx the top left grid coordinate of the view. + * @param gy see gx + * @param w width of the view in tiles + * @param h height ... + * @param off_gx grid offset for the view to start. + * @param off_gy see off_gx + * @return the requested tilemap for viewin'. + */ + public function load_cutscene_view(map_name:String, tileset:Class, gx:int,gy:int, w:int=10,h:int=10,off_gx:int=0,off_gy:int=0):FlxTilemap { + var CSV:String = CSV_Data.getMap(map_name); + var tilemap:FlxTilemap = new FlxTilemap(); + tilemap.loadMap(CSV, tileset, 16, 16); + var submap_data:Array = new Array(); + for (var i:int = 0; i < w*h; i++) { + submap_data.push(tilemap.getTile(gx * 10 + (i % w), gy * 10 + (i / h))); + } + tilemap.destroy(); + tilemap = new FlxTilemap(); + tilemap.loadMap(FlxTilemap.arrayToCSV(submap_data, 10), tileset, 16, 16); + tilemap.scrollFactor.x = tilemap.scrollFactor.y = 0; + tilemap.y = Registry.HEADER_HEIGHT; + return tilemap; + + } + private function inst_red_cave_left():void { + add (load_cutscene_view("REDSEA", TileData.Red_Sea_Tiles, 2, 4)); + var ss:Solid_Sprite = new Solid_Sprite(EventScripts.fake_xml("Solid_Sprite","48", "68", "red_cave_r_ss"), true); + add(ss); + pushee = ss; + pushdown = ss.framePixels_y_push = 64; + var overlay:FlxSprite = new FlxSprite(0, 20, Common_Sprites.redsea_blend); + overlay.scrollFactor.x = overlay.scrollFactor.y = 0; + overlay.blend = "hardlight"; + add(overlay); + } + + private function inst_red_cave_right():void { + add (load_cutscene_view("REDSEA", TileData.Red_Sea_Tiles, 4, 4)); + var ss:Solid_Sprite = new Solid_Sprite(EventScripts.fake_xml("Solid_Sprite", "48", "68", "red_cave_r_ss"), true); + add(ss); + var overlay:FlxSprite = new FlxSprite(0, 20, Common_Sprites.redsea_blend); + add(overlay); + overlay.blend = "hardlight"; + overlay.scrollFactor.x = overlay.scrollFactor.y = 0; + pushee = ss; + pushdown = ss.framePixels_y_push = 64; + } + + private function inst_red_cave_north():void { + add (load_cutscene_view("REDSEA", TileData.Red_Sea_Tiles, 3, 3)); + var ss:Solid_Sprite = new Solid_Sprite(EventScripts.fake_xml("Solid_Sprite", "48", + "68", "red_cave_n_ss"), true); + add(ss); + pushee = ss; + + var overlay:FlxSprite = new FlxSprite(0, 20, Common_Sprites.redsea_blend); + add(overlay); + overlay.blend = "hardlight"; + overlay.scrollFactor.x = overlay.scrollFactor.y = 0; + pushdown = ss.framePixels_y_push = 64; + } + + private function inst_terminal_gate():void { + add(load_cutscene_view("WINDMILL", TileData.Terminal_Tiles, 0, 2)); + var tg:Terminal_Gate = new Terminal_Gate(EventScripts.fake_xml("Terminal_Gate", "30", "50", "n"), _parent.player, _parent,true); + var grp:FlxGroup = new FlxGroup(); + grp.add(tg.button); + grp.add(tg.gate_bedroom); + grp.add(tg.gate_crowd); + grp.add(tg.gate_redcave); + grp.setAll("scrollFactor", new FlxPoint(0, 0)); + add(grp); + entity_1 = tg; + } + + + private function inst_windmill():void { + Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening] = 1; + scene_1 = load_cutscene_view("BEDROOM", TileData._Bedroom_Tiles, 4, 0, 10, 10, 0, 0); + entity_1 = new FlxSprite(5 * 16, 2 * 16 + 20); + entity_1.loadGraphic(Dungeon_Statue.statue_bedroom_embed, true, false, 32, 48); + entity_1.frame = 0; + + scene_2 = load_cutscene_view("REDCAVE", TileData.REDCAVE_Tiles, 6, 2, 10, 10, 0, 0); + entity_2 = new FlxSprite(4 * 16, 4 * 16 + 20); + entity_2.loadGraphic(Dungeon_Statue.statue_bedroom_embed, true, false, 32, 48); + entity_2.frame = 1; + + scene_3 = load_cutscene_view("CROWD", TileData._Crowd_Tiles, 9, 4, 10, 10); + entity_3 = new FlxSprite(4 * 16, 2 * 16 + 20); + entity_3.loadGraphic(Dungeon_Statue.statue_bedroom_embed, true, false, 32, 48); + entity_3.frame = 2; + + fade = new FlxSprite(0, 20); + fade.makeGraphic(160, 160, 0xff000000); + fade.alpha = 1; + + add(scene_1); add(entity_1); + add(scene_2); add(entity_2); + add(scene_3); add(entity_3); + add(fade); + + setAll("scrollFactor", new FlxPoint(0, 0)); + setAll("exists", false); + } + + + override public function destroy():void + + { + + entity_1 = null; + entity_2 = null; + entity_3 = null; + pushee = null; + tran_in_args = null; + tran_out_args = null; + transition_in = null; + transition_out = null; + step_cutscene = null; + scene_1 = null; + scene_2 = null; + scene_3 = null; + + + super.destroy(); + } + } + +} diff --git a/intra/src/helper/DH.as b/intra/src/helper/DH.as new file mode 100644 index 0000000..e89cd81 --- /dev/null +++ b/intra/src/helper/DH.as @@ -0,0 +1,630 @@ +package helper +{ + import data.NPC_Data_EN; + import data.NPC_Data_ES; + import data.NPC_Data_JP; + import data.NPC_Data_KR; + import data.NPC_Data_PT; + import data.NPC_Data_IT; + import data.NPC_Data_ZHS; + import entity.player.Player; + import flash.utils.ByteArray; + import flash.utils.describeType; + import global.Registry; + import org.flixel.FlxObject; + import org.flixel.FlxSprite; + import states.DialogueState; + + /** + * Dialogue Helper (DH) + * Contains helper functions to query the Dialogue state object + */ + + public class DH + { + // A copy of the raw dialogue state. Used for updating + // Dialogue state in patches + public static var RAW_DIALOGUE_STATE:Object; + + public static const name_card:String = "card"; + public static const name_arthur:String = "arthur"; + public static const name_briar:String = "briar"; + public static const name_javiera:String = "javiera"; + public static const name_mitra:String = "mitra"; + public static const name_sage:String = "sage"; + public static const name_statue:String = "statue"; + public static const name_test:String = "test"; + public static const name_sun_guy:String = "sun_guy"; + public static const name_rock:String = "rock"; + public static const name_sadbro:String = "sadbro"; + public static const name_dungeon_statue:String = "dungeon_statue"; + public static const name_splitboss:String = "splitboss"; + public static const name_wallboss:String = "wallboss"; + public static const name_eyeboss:String = "eyeboss"; + public static const name_redboss:String = "redboss"; + public static const name_circus_folks:String = "circus_folks"; + public static const name_suburb_walker:String = "suburb_walker"; + public static const name_suburb_blocker:String = "suburb_blocker"; + public static const name_cube_king:String = "cube_king"; + public static const name_cliff_dog:String = "cliff_dog"; + public static const name_generic_npc:String = "generic_npc"; + public static const name_forest_npc:String = "forest_npc"; + public static const name_geoms:String = "geoms"; + public static const name_miao:String = "miao"; + public static const name_shopkeeper:String = "shopkeeper"; + public static const name_goldman:String = "goldman"; + public static const name_happy_npc:String = "happy_npc"; + + // For card popups, treasure dialogs + public static var area_etc:String = "ETC"; + + + + public static var scene_arthur_circus_alone:String = "alone"; + + public static var scene_briar_go_before_fight:String = "before_fight"; + public static var scene_briar_go_after_fight:String = "after_fight"; + + + public static var scene_card_one:String = "one"; + + public static var scene_cliff_dog_top_left:String = "top_left"; + + public static var scene_dungeon_statue_bedroom_one:String = "one"; + public static var scene_dungeon_statue_bedroom_two:String = "two"; + + public static var scene_forest_npc_bunny:String = "bunny"; + public static var scene_forest_npc_thorax:String = "thorax"; + + public static var scene_snowman_one:String = "one"; + + public static var scene_goldman_etc:String = "etc"; + public static var scene_goldman_inside:String = "inside"; + public static var scene_goldman_outside:String = "outside"; + + public static var scene_generic_npc_any_quest_normal:String = "quest_normal"; + public static var scene_generic_npc_any_second:String = "second"; + public static var scene_generic_npc_any_first:String = "first"; + public static var scene_generic_npc_any_quest_event:String = "quest_event"; + public static var scene_generic_npc_any_easter_egg:String = "easter_egg"; + public static var scene_rank_bush:String = "bush"; + + public static var scene_happy_npc_beautiful:String = "beautiful"; + public static var scene_happy_npc_drink:String = "drink"; + public static var scene_happy_npc_hot:String = "hot"; + public static var scene_happy_npc_dump:String = "dump"; + public static var scene_happy_npc_gold:String = "gold"; + public static var scene_happy_npc_briar:String = "briar"; + + public static var scene_javiera_circus_alone:String = "alone"; + + public static var scene_miao_init:String = "init"; + public static var scene_miao_randoms:String = "randoms"; + public static var scene_miao_philosophy:String = "philosophy"; + + public static var scene_mitra_overworld_initial_overworld:String = "initial_overworld"; + public static var scene_mitra_blue_one:String = "one"; + public static var scene_mitra_fields_init:String = "init"; + public static var scene_mitra_fields_game_hints:String = "game_hints"; + public static var scene_mitra_fields_card_hints:String = "card_hints"; + public static var scene_mitra_fields_general_banter:String = "general_banter"; + public static var scene_mitra_fields_quest_event:String = "quest_event"; + + public static var scene_rock_one:String = "one"; + public static var scene_rock_two:String = "two"; + public static var scene_rock_three:String = "three"; + public static var scene_rock_four:String = "four"; + public static var scene_rock_five:String = "five"; + public static var scene_rock_six:String = "six"; + + public static var scene_shopkeeper_init:String = "init"; + + public static var scene_suburb_walker_words_adult:String = "words_adult"; + public static var scene_suburb_walker_words_teen:String = "words_teen"; + public static var scene_suburb_walker_words_kid:String = "words_kid"; + public static var scene_suburb_walker_family:String = "family"; + public static var scene_suburb_walker_hanged:String = "hanged"; + public static var scene_suburb_walker_festive:String = "festive"; + public static var scene_suburb_walker_paranoid:String = "paranoid"; + public static var scene_suburb_walker_dead:String = "dead"; + public static var scene_suburb_walker_older_kid:String = "older_kid"; + + public static const scene_suburb_blocker_one:String = "one"; + + public static var scene_sadbro_overworld_initial_forced:String = "initial_forced"; + public static var scene_sadbro_overworld_bedroom_done:String = "bedroom_done"; + public static var scene_sadbro_overworld_bedroom_not_done:String = "bedroom_not_done"; + + public static var scene_sage_blank_intro:String = "intro"; + public static var scene_sage_nexus_enter_nexus:String = "enter_nexus"; + public static var scene_sage_nexus_after_ent_str:String = "after_ent_str"; + public static var scene_sage_nexus_after_bed:String = "after_bed"; + public static var scene_sage_nexus_before_windmill:String = "before_windmill"; + public static var scene_sage_nexus_after_windmill:String = "after_windmill"; + public static var scene_sage_nexus_all_card_first:String = "all_card_first"; + public static var scene_sage_overworld_bedroom_entrance:String = "bedroom_entrance"; + public static var scene_sage_bedroom_after_boss:String = "after_boss"; + public static var scene_sage_redcave_one:String = "one"; + public static var scene_sage_crowd_one:String = "one"; + public static var scene_sage_terminal_before_fight:String = "before_fight"; + public static var scene_sage_terminal_after_fight:String = "after_fight"; + public static var scene_sage_terminal_entrance:String = "entrance"; + public static var scene_sage_terminal_etc:String = "etc"; + public static var scene_sage_happy_posthappy_sage:String = "posthappy_sage"; + public static var scene_sage_happy_posthappy_mitra:String = "posthappy_mitra"; + + public static var scene_splitboss_before_fight:String = "before_fight"; + public static var scene_splitboss_after_fight:String = "after_fight"; + + public static var scene_redboss_before_fight:String = "before_fight"; + public static var scene_redboss_after_fight:String = "after_fight"; + + public static var scene_eyeboss_before_fight:String = "before_fight"; + public static var scene_eyeboss_after_fight:String = "after_fight"; + + public static var scene_wallboss_before_fight:String = "before_fight"; + public static var scene_wallboss_after_fight:String = "after_fight"; + + public static var scene_circus_folks_before_fight:String = "before_fight"; + public static var scene_circus_folks_after_fight:String = "after_fight"; + + public static var scene_sun_guy_before_fight:String = "before_fight"; + public static var scene_sun_guy_after_fight:String = "after_fight"; + + public static var scene_statue_nexus_enter_nexus:String = "enter_nexus"; + public static var scene_statue_bedroom_after_boss:String = "after_boss"; + public static var scene_statue_overworld_bedroom_entrance:String = "bedroom_entrance"; + + public static var scene_cube_king_space_color:String = "color"; + public static var scene_cube_king_space_gray:String = "gray"; + + public static var scene_geoms_space_color:String = "color"; + public static var scene_geoms_space_gray:String = "gray"; + + + public static var scene_test_debug_scene_1:String = "scene_1"; + + private static var property_resettable:String = "does_reset"; + + private static var scenes_to_reset_on_map_change:Array = new Array(); + private static var current_active_scene:Object; + private static var current_active_dialogue:Array; + /** + * Whether or not a chunk of dialogue has finished playing. Reset whenever + * a new chunk is fetched. + */ + private static var recently_finished_chunk:Boolean = false; + private static var chunk_is_playing:Boolean = false; + private static var most_recently_played_chunk_pos:int; + + + /** + * Start a dialogue popup given the parameters. Increments the chosen scene's pos parameter, + * or loops it to its loop point. Marks this scene as dirty (i.e., "read at least once"). + * @param name The name of the npc. Use constants in DH.as when you can - DH.name_sage, etc. + * @param scene The name of the scene. Use constants in DH.as when you can - DH.scene_sage_blank_intro, etc. + * @param area What map this occurs in. Defaults to current player's map. + * @param pos which dialogue to show. If -1, reads the next one and increments the position state. Otherwise returns the requested chunk + * @param has_alternate Whether this NPC has altenrate text based on state from helper.S_NPC.as + * @return true on success (read a dialogue chunk), crash the game otherwise + */ + public static function start_dialogue(name:String, scene:String, _area:String = "", pos:int = -1,has_alternate:Boolean=false):Boolean { + if (true == a_chunk_is_playing() || (Registry.GAMESTATE != null && Registry.GAMESTATE.dialogue_latency > 0)) { + return false; + } + recently_finished_chunk = false; + + // Maybe get an alternate text. + if (has_alternate == true) { + // S_NPC.something... + } + // Grab the area of the dialogue to take place + var area:String = (_area == "") ? Registry.CURRENT_MAP_NAME : _area; + + // Grab the scene associated with this area + var cur_scene_state:Object = Registry.DIALOGUE_STATE[name][area][scene]; + var cur_scene_dialogue:Array = Registry.DIALOGUE[name][area][scene].dialogue; + cur_scene_state.dirty = true; + + // Make the box at top or bottom + if (cur_scene_state.hasOwnProperty("top")) { + DialogueState.set_dialogue_box_align(FlxObject.UP); + } else { + DialogueState.set_dialogue_box_align(FlxObject.DOWN); + } + + + // Grab the dialogue chunk, if we hit the end, loop, otherwise increment position counter + if (pos == -1) { + most_recently_played_chunk_pos = cur_scene_state.pos; + Registry.cur_dialogue = cur_scene_dialogue[cur_scene_state.pos]; + if (cur_scene_state.pos == cur_scene_dialogue.length - 1) { + cur_scene_state.pos = cur_scene_state.loop; + } else { + cur_scene_state.pos++; + } + } else { + most_recently_played_chunk_pos = pos; + Registry.cur_dialogue = cur_scene_dialogue[pos]; + } + + + + // If resettable, add its reference to list of references to reset dialogue position on map change + if (Registry.DIALOGUE_STATE[name].hasOwnProperty(property_resettable) && Registry.DIALOGUE_STATE[name][property_resettable]) { + scenes_to_reset_on_map_change.push(cur_scene_state); + } + + + if (Registry.GAMESTATE != null) { + Registry.GAMESTATE.load_dialogue = true; + } + current_active_scene = cur_scene_state; + current_active_dialogue = cur_scene_dialogue; + chunk_is_playing = true; + return true; + } + + public static function dialogue_popup_misc_any(scene:String, pos:int):void { + dialogue_popup(DH.lookup_string("misc", "any", scene, pos)); + } + /** + * Make a dialogue popup with 'words'. + * @param words + */ + public static function dialogue_popup(words:String):void { + Registry.cur_dialogue = words; + Registry.GAMESTATE.load_dialogue = true; + + } + /** + * Get the dialogue position in a given scene. + * @param name + * @param scene + * @param _area + * @return an integer >= 0 denoting the position, or -1 if not found + */ + public static function get_scene_position(name:String, scene:String, _area:String = ""):int { + _area = (_area == "") ? Registry.CURRENT_MAP_NAME : _area; + return Registry.DIALOGUE_STATE[name][_area][scene].pos; + } + + /** + * Check if the scene had any dialogue started at any point in time. Useful if you don't want to add in + * another boolean to wherever the dialogue is being played from, and the call originally sits in a block + * that is iterated over. + * @param name + * @param scene + * @param _area + * @return + */ + public static function scene_is_dirty(name:String, scene:String, _area:String = ""):Boolean { + _area = (_area == "") ? Registry.CURRENT_MAP_NAME : _area; + return Registry.DIALOGUE_STATE[name][_area][scene].dirty; + } + + /** + * Check if the scene has finished completely. Useful for say, boss intro dialogue which blocks scripting of an intro sequence + * @param name + * @param scene + * @param _area + * @return + */ + public static function scene_is_finished(name:String, scene:String, _area:String = ""):Boolean { + _area = (_area == "") ? Registry.CURRENT_MAP_NAME : _area; + return Registry.DIALOGUE_STATE[name][_area][scene].finished; + } + + /** + * Updates current scene to be "finished" if all dialogue is played from that scene. + * Also sets "recently_finished_chunk" to true, and "chunk_is_playing" to false; + */ + public static function update_current_scene_on_chunk_finish():void { + if (current_active_scene == null) return; + if (most_recently_played_chunk_pos == current_active_dialogue.length - 1) { + current_active_scene.finished = true; + } + current_active_dialogue = null; + current_active_scene = null; + recently_finished_chunk = true; + chunk_is_playing = false; + } + + public static function get_scene_length(name:String, scene:String, _area:String = ""):int { + _area = (_area == "") ? Registry.CURRENT_MAP_NAME : _area; + + return Registry.DIALOGUE[name][_area][scene].dialogue.length; + } + /** + * Called when transitioning out of a Roam or Playstate. + */ + public static function reset_scenes_on_map_change():void { + while (scenes_to_reset_on_map_change.length > 0) { + var scene:Object = scenes_to_reset_on_map_change.pop() as Object; + scene.pos = 0; + } + } + + public static function a_chunk_just_finished():Boolean { + if (recently_finished_chunk) { + recently_finished_chunk = false; + return true; + } + return false; + } + public static function dont_need_recently_finished():void { + recently_finished_chunk = false; + } + + public static function a_chunk_is_playing():Boolean { + return chunk_is_playing; + } + + /** + * Fill Registry.DIALOGUE with all the game's dialogue, make a copy of the initial dialogue state + * into Registry.DIALOGUE_STATE + */ + public static function init_dialogue_state(only_change_dialogue:Boolean=false):void { + + Registry.DIALOGUE = { }; + var varList:XMLList = null; + if (language_type == LANG_ja) { + + varList = describeType(NPC_Data_JP)..variable; + } else if (language_type == LANG_ko) { + varList = describeType(NPC_Data_KR)..variable; + } else if (language_type == LANG_es) { + varList = describeType(NPC_Data_ES)..variable; + } else if (language_type == LANG_it) { + varList = describeType(NPC_Data_IT)..variable; + } else if (language_type == LANG_pt) { + varList = describeType(NPC_Data_PT)..variable; + } else if (language_type == LANG_zhs) { + varList = describeType(NPC_Data_ZHS)..variable; + } else { + varList = describeType(NPC_Data_EN)..variable; + } + var d:Object = { }; + for (var i:int = 0; i < varList.length(); i++) { + if (varList[i].@name.toXMLString().indexOf("_state") == -1) { + if (language_type == LANG_ja) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_JP[varList[i].@name]; + } else if (language_type == LANG_ko) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_KR[varList[i].@name]; + } else if (language_type == LANG_es) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_ES[varList[i].@name]; + } else if (language_type == LANG_it) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_IT[varList[i].@name]; + } else if (language_type == LANG_pt) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_PT[varList[i].@name]; + } else if (language_type == LANG_zhs) { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_ZHS[varList[i].@name]; + } else { + Registry.DIALOGUE[varList[i].@name] = NPC_Data_EN[varList[i].@name]; + } + } else { // Add the bob npc object state, with all of its areas and scenes + if (language_type == LANG_ja) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_JP[varList[i].@name]; + } else if (language_type == LANG_ko) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_KR[varList[i].@name]; + } else if (language_type == LANG_pt) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_PT[varList[i].@name]; + } else if (language_type == LANG_es) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_ES[varList[i].@name]; + } else if (language_type == LANG_it) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_IT[varList[i].@name]; + } else if (language_type == LANG_zhs) { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_ZHS[varList[i].@name]; + } else { + d[varList[i].@name.toXMLString().split("_state")[0]] = NPC_Data_EN[varList[i].@name]; + } + } + } + + if (false == only_change_dialogue) { + var myBA:ByteArray = new ByteArray(); + myBA.writeObject(d); + myBA.position = 0; + // dialogue state doesnt hold any "dialogue" just state + Registry.DIALOGUE_STATE = myBA.readObject(); + myBA.position = 0; + RAW_DIALOGUE_STATE = myBA.readObject(); + } + + } + + public static function isZH():Boolean { + if (language_type == LANG_zhs) return true; + return false; + } + + public static var language_type:String = "en"; + public static const LANG_en:String = "en"; + public static const LANG_ja:String = "ja"; + public static const LANG_ko:String = "ko"; + public static const LANG_es:String = "es"; + public static const LANG_pt:String = "pt"; + public static const LANG_zhs:String = "zh-CN"; + public static const LANG_it:String = "it"; + public static function set_language(lang_string:String):void { + if (lang_string == LANG_ja) { + trace("Japanese Language set."); + DialogueState.Max_Line_Size = 18; + language_type = LANG_ja; + } else if (lang_string == LANG_ko) { + trace("Korean language set."); + DialogueState.Max_Line_Size = 18; + language_type = LANG_ko; + } else if (lang_string == LANG_es) { + trace("Spanish language set."); + DialogueState.Max_Line_Size = 24; + language_type = LANG_es; + } else if (lang_string == LANG_it) { + trace("Italian language set."); + DialogueState.Max_Line_Size = 24; + language_type = LANG_it; + } else if (lang_string == LANG_pt) { + trace("pt-br language set."); + DialogueState.Max_Line_Size = 24; + language_type = LANG_pt; + } else if (lang_string == LANG_zhs || lang_string == "zh" || lang_string == "zh-TW") { + trace("zh-CN langage set."); + DialogueState.Max_Line_Size = 13; + language_type = LANG_zhs; + } else { + trace("English Language set."); + language_type = LANG_en; + DialogueState.Max_Line_Size = 21; + } + // When called a 2nd time in game or after loading or whatever + if (Registry.PLAYSTATE != null && Registry.PLAYSTATE.dialogue_state != null) { + Registry.PLAYSTATE.dialogue_state.create_bitmap_text(); + } + + // Change the pointer to the new object but don't update the state. + init_dialogue_state(true); + + // Update these strings after re-initializing dialogue state + if (Registry.PLAYSTATE != null && Registry.PLAYSTATE.pause_state != null) { + Registry.PLAYSTATE.pause_state.set_pausemenu_labels(); + } + + } + // Patches the save file's dialogue state + // with the raw dialogue state. + // Useful if we add an NPC or somethin' . + public static function patch_dialogue_state():void { + var debug:Boolean = false; + var npc_ctr:int = 0; + var area_ctr:int = 0; + var scene_ctr:int = 0; + if (debug) trace("Patching dialogue state."); + + for (var npc:String in RAW_DIALOGUE_STATE) { + npc_ctr++; + // If the save file already has this NPC then we need to check its areas + if (Registry.DIALOGUE_STATE.hasOwnProperty(npc)) { + // Check the NPC's areas. + for (var area:String in RAW_DIALOGUE_STATE[npc]) { + area_ctr++; + if (area == "does_reset") continue; + // Check its scenes. + if (Registry.DIALOGUE_STATE[npc].hasOwnProperty(area)) { + for (var scene:String in RAW_DIALOGUE_STATE[npc][area]) { + scene_ctr++; + // If this scene exists, just update its loop property + if (Registry.DIALOGUE_STATE[npc][area].hasOwnProperty(scene)) { + Registry.DIALOGUE_STATE[npc][area][scene]["loop"] = RAW_DIALOGUE_STATE[npc][area][scene]["loop"] + if (RAW_DIALOGUE_STATE[npc][area][scene].hasOwnProperty("top")) { + Registry.DIALOGUE_STATE[npc][area][scene]["top"] = true; + } + } else { + if (debug) trace("New scene: " + scene + " , " + area + " , " + npc) + Registry.DIALOGUE_STATE[npc][area][scene] = RAW_DIALOGUE_STATE[npc][area][scene]; + } + } + } else { + if (debug) trace("New Area: " + area+" , "+npc); + Registry.DIALOGUE_STATE[npc][area] = RAW_DIALOGUE_STATE[npc][area]; + } + } + // Otherwise just add it in! + } else { + if (debug) trace("New NPC: " + npc); + Registry.DIALOGUE_STATE[npc] = RAW_DIALOGUE_STATE[npc]; + } + } + + if (debug) trace("And now for # of things we had to check..."); + if (debug) trace("NPCs: " + npc_ctr.toString() + " Areas: " + area_ctr.toString() + " scenes: " + scene_ctr.toString()); + } + + /** + * Increments an integer property on this ENTIRE NPC by one + * Creates the property if it doesn't exist, inits to 1. + * @return 1 if property exists, 0 otherswise + */ + public static function increment_property(name:String,property:String):int { + if (!Registry.DIALOGUE_STATE[name].hasOwnProperty(property)) { + Registry.DIALOGUE_STATE[name][property] = 1; + + } else { + Registry.DIALOGUE_STATE[name][property]++; + return 1; + } + return 0; + } + + /** + * Get an integer property of the NPC ENTIRE NPC + * @param name + * @param property + * @return + */ + public static function get_int_property(name:String, property:String):int { + if (Registry.DIALOGUE_STATE[name].hasOwnProperty(property)) { + return Registry.DIALOGUE_STATE[name][property]; + } + return -1; + + } + + public static function enable_menu():void { + Registry.disable_menu = false; + } + public static function disable_menu():void { + Registry.disable_menu = true; + } + + /** + * Specify what chunk of dialogue to play next, by the "pos" var + * @param pos + * @return the new position in this scene, or -1 if current scene null + */ + + public static function set_scene_to_pos(name:String,scene:String,pos:int):int { + if (Registry.DIALOGUE_STATE[name][Registry.CURRENT_MAP_NAME][scene] == null) return -1; + + Registry.DIALOGUE_STATE[name][Registry.CURRENT_MAP_NAME][scene].pos = pos; + return pos; + } + + /** + * Set pos to the last chunk of dialogue. + * @param pos + * @return the new position in this scene, or or -1 if current scene null + */ + public static function set_scene_to_end(name:String,scene:String):int { + if (Registry.DIALOGUE_STATE[name][Registry.CURRENT_MAP_NAME][scene] == null) return -1; + + var new_pos:int = Registry.DIALOGUE[name][Registry.CURRENT_MAP_NAME][scene].dialogue.length - 1; + Registry.DIALOGUE_STATE[name][Registry.CURRENT_MAP_NAME][scene].pos = new_pos; + return new_pos; + } + + /** + * Macro: "Normal Condition" Does the conditional checks for entering a dialogue, covers 95% of cases + * @param p - player reference + * @param ar - active region of the sprites talking to + * @return whether to talk or not + */ + public static function nc(player:Player, active_region:FlxObject):Boolean { + if (player.overlaps(active_region) && DH.a_chunk_is_playing() == false && player.state == player.S_GROUND && Registry.keywatch.JP_ACTION_1) { + player.be_idle(); + return true; + } + return false; + } + + public static function lookup_string(name:String, map:String, scene:String, pos:int):String { + var retval:String = Registry.DIALOGUE[name][map][scene].dialogue[pos]; + return retval; + } + + public static function lk(scene:String, pos:int):String { + var retval:String = Registry.DIALOGUE["misc"]["any"][scene].dialogue[pos]; + return retval; + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/EventScripts.as b/intra/src/helper/EventScripts.as new file mode 100644 index 0000000..85cf3a8 --- /dev/null +++ b/intra/src/helper/EventScripts.as @@ -0,0 +1,569 @@ +package helper +{ + /** + * ... + * @author seagaia + + + */ + import data.CLASS_ID; + import data.Common_Sprites; + import entity.enemy.etc.Briar_Boss; + import entity.player.HealthPickup; + import flash.geom.Point; + import global.Registry; + import mx.core.FlexSprite; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxG; + import org.flixel.FlxTilemap; + import org.flixel.FlxU; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import org.flixel.system.FlxTile; + import states.DialogueState; + import states.PlayState; + public class EventScripts extends FlxSprite + { + + [Embed (source = "../res/sprites/enemies/enemy_explode_2.png")] public static var small_explosion_sprite:Class; + + public var xml:XML; + public var cid:int = CLASS_ID.EVENT_SCRIPT; + public function EventScripts() { + super(0, 0); + makeGraphic(1, 1, 0x00ffffff); + xml = ; + } + public static function move_to_x_and_stop(o:FlxSprite, vel:Number, x:Number):void { + if (vel > 0 && o.x > x) { + o.velocity.x = 0; + } else if (vel < 0 && o.x < x) { + o.velocity.x = 0; + } else { + o.velocity.x = vel; + } + return; + } + + public static function move_to_x(o:FlxSprite, vel:Number, x:Number):Boolean { + o.velocity.x = vel; + if (vel < 0) { + if (o.x <= x) return true; + } else { + if (o.x >= x) return true; + } + return false; + } + public static function check_x_zero(...args):Boolean { + var next:FlxSprite; + var ret:Boolean = true; + for (var i:int = 0; i < args.length; i++) { + next = args[i]; + if (next.velocity.x != 0) { + ret = false; + break; + } + } + return ret; + } + + /** + * Decreases or increases the given FlxSprite's alpha at rate to a target value. + * -rate for decrease, +rate for increase. + * @return true if the alpha reached the target value, false otherwise + */ + + + public static function send_alpha_to(o:FlxSprite, target:Number, rate:Number):Boolean { + if (rate > 0) { + if (o.alpha >= target) return true; + o.alpha = Math.min(1, o.alpha + rate); + } else { + if (o.alpha <= target) return true; + o.alpha = Math.max(0, o.alpha + rate); + } + return false; + } + + public static function send_property_to(o:Object, property:String, target:Number, rate:Number):Boolean { + if (rate < 0) rate *= -1; + + if (o[property] > target) { + o[property] = Math.max(target, o[property] - rate); + } else if (o[property] < target) { + o[property] = Math.min(target, o[property] + rate); + } + if (o[property] == target) return true; + return false; + } + + /** + * + * @param chance A number from 0 to 1, the probability of the health dropping + */ + public static function drop_small_health(x:int,y:int,chance:Number):void { + var hp:HealthPickup = new HealthPickup(x, y, HealthPickup.HP_1, Registry.GAMESTATE); + if (Math.random() > (1 - chance)) { + if (Registry.is_playstate) { + Registry.GAMESTATE.otherObjects.push(hp); //So we remove these on screen transition + Registry.GAMESTATE.bg_sprites.add(hp); //So these are immediately drawn + } else { + Registry.GAMESTATE.entities.push(hp); + Registry.GAMESTATE.add(hp); + } + } + } + + public static function drop_big_health(x:int,y:int,chance:Number):void { + var hp:HealthPickup = new HealthPickup(x, y, HealthPickup.HP_3, Registry.GAMESTATE); + if (Math.random() > (1 - chance)) { + if (Registry.is_playstate) { + Registry.GAMESTATE.otherObjects.push(hp); + Registry.GAMESTATE.bg_sprites.add(hp); + } else { + Registry.GAMESTATE.entities.push(hp); + } + } + } + + /** + * Create an explosion sprite and add it to the current draw group. + * @param enemy The enemy that's exploding - used for deciding the explosion + */ + /* Images for explosions are embedded at the top of EventScripts.as */ + /* Sounds are managed in SoundData.as */ + public static function make_explosion_and_sound(enemy:FlxSprite,ignore:int=0,this_parameter:int=0):void { + var class_name:String = FlxU.getClassName(enemy, true); + var explosion:FlxSprite = new FlxSprite(enemy.x, enemy.y); + + /* Make the explosion */ + + /* Later, load the explosion and sound based on the class name. */ + switch (class_name) { // e.g., "Dog", "Lion", "Contort" + case "Velociraptor X3000": + // load the graphic, add animation, offset the explosion, play a sound + break; + default: // Executed when there is no case statement for the enemy + + if (ignore == 1) { + explosion.loadGraphic(Briar_Boss.embed_dust_explosion, true, false, 48, 48); + explosion.addAnimation("explode", [0, 1, 2, 3, 4, 5], 12, false); + explosion.x += enemy.width * Math.random(); + explosion.y += enemy.height * Math.random(); + } else if (ignore == 2) { + explosion.loadGraphic(Briar_Boss.embed_ice_explosion, true, false, 24, 24); + explosion.addAnimation("explode", [0, 1, 2, 3,4], 15, false); + explosion.x += enemy.width * Math.random(); + explosion.y += enemy.height * Math.random(); + } else if (ignore == 3) { + explosion.loadGraphic(small_explosion_sprite, true, false, 24, 24); + explosion.addAnimation("explode", [0, 1, 2, 3, 4], 12, false); + explosion.x += enemy.width * Math.random(); + explosion.y += enemy.height * Math.random(); + + } else if (Registry.CURRENT_MAP_NAME == "TRAIN") { + explosion.loadGraphic(small_explosion_sprite, true, false, 24, 24); + explosion.addAnimation("explode", [5,6,7,8,9], 10, false); + explosion.x -= 4; + explosion.y -= 4; + + } else { + explosion.loadGraphic(small_explosion_sprite, true, false, 24, 24); + explosion.addAnimation("explode", [0, 1, 2, 3, 4], 12, false); + explosion.x -= 4; + explosion.y -= 4; + } + + + Registry.sound_data.play_sound_group(Registry.sound_data.enemy_explode_1_group); + break; + } + + if (ignore > 0) { + Registry.GAMESTATE.fg_sprites.add(explosion); + } else { + Registry.GAMESTATE.bg_sprites.add(explosion); + } + explosion.play("explode"); + + + /* Play sound */ + + } + public static function boss_drop_health_up(x:int, y:int):void { + trace("Boss dropping health up"); + var hp:HealthPickup = new HealthPickup(x, y, HealthPickup.HP_EXTEND,Registry.GAMESTATE); + hp.xml = fake_xml("HealthPickup", x.toString(), y.toString(), HealthPickup.HP_EXTEND.toString(), "true", "2"); + Registry.GAMESTATE.stateful_gridXML.appendChild(hp.xml); + Registry.GAMESTATE.bg_sprites.add(hp); + } + + /** + * Create a fake xml to be used for some sprite that wasnte + * exported with dame + * @param name name of the node + * @param x x value + * @param y y value + * @param type_attr value of "type" if relevant + * @return the new xml objet + */ + public static function fake_xml(name:String,x:String,y:String,type_attr:String="",alive:String="true",p:String="0",frame:String="0"):XML { + var xml:XML = < Root x = "0" y = "0" p = "" alive = "" type = "" frame = "" /> ; + trace(xml.toXMLString()); + xml.setName(name); + xml.@p = p; + xml.@["x"] = x; + xml.@y = y; + xml.@frame = frame; + xml.@alive = alive; + xml.@type = type_attr; + trace(xml.toXMLString()); + + return xml; + + } + + + /** + * Rotates ROTATEE about PIVOT's top-left pt with offset (off_x,off_y), + * at some velocity (per game tick), at a radius of...radius! + * + * ROTATEE NEEDS A rotate_angle PROPERTY. + */ + public static function rotate_about_center_of_sprite(pivot:FlxSprite,rotatee:*,radius:Number,velocity:Number,off_x:int=-8,off_y:int=-5):void { + var pivot_x:Number = pivot.x + pivot.width / 2; + var pivot_y:Number = pivot.y + pivot.height / 2; + + + rotatee.x = Math.cos(rotatee.rotate_angle) * (radius) + pivot_x + off_x; + rotatee.y = Math.sin(rotatee.rotate_angle) * (radius) + pivot_y + off_y; + rotatee.rotate_angle = (rotatee.rotate_angle + velocity) % 6.28; + } + + /** + * Gives the angle swept from the x axis to ((x1,y1),(x2,y2)) by treating x1,y1 as the origin + * */ + + public static function get_angle(x1:Number, y1:Number, x2:Number, y2:Number):Number { + + var x:Number = x2 - x1; + var y:Number = y2 - y1; + return Math.atan2(y, x); + } + + + /** + * Set "out" to be a vector in the direction of to - from, + * with magnitude new_mag. + * @param from + * @param to + * @param out + * @param new_mag + * @return + */ + public static function scale_vector(from:*, to:*, out:*, new_mag:Number ):FlxPoint { + + var dx:Number = to.x - from.x; + var dy:Number = to.y - from.y; + var mag:Number = Math.sqrt(dx * dx + dy * dy); + var scale:Number = new_mag / mag; + out.x = scale * dx; + out.y = scale * dy; + return out; + } + + /** + * Return the distance between two points. + * Input is any objects with an x and y property. + */ + public static function distance(a:*, b:*):Number { + var dx:Number = a.x - b.x; + var dy:Number = a.y - b.y; + return Math.sqrt(dx * dx + dy * dy); + } + + public static function prevent_leaving_map(playstate:PlayState,o:FlxSprite):void { + if (o.y < playstate.upperBorder) o.y = playstate.upperBorder; + if (o.y + o.height > playstate.lowerBorder) o.y = playstate.lowerBorder - o.height; + if (o.x + o.width > playstate.rightBorder) o.x = playstate.rightBorder - o.width; + if (o.x < playstate.leftBorder) o.x = playstate.leftBorder; + } + + /** + * Inits a bitmap font object with the default + * variables for Anodyne + * Types: black apple_black apple_white + */ + public static function init_bitmap_font(text:String = " ", alignment:String = "center", x:int = 0, y:int = 0, scrollFactor:Point = null, type:String="black"):FlxBitmapFont { + + var b:FlxBitmapFont; + + switch (type) { + case "apple_black": + if (DH.language_type == DH.LANG_ja) { + b = new FlxBitmapFont(Registry.C_FONT_JP_WHITE,8,8, Registry.jp_string, 50, 0, 0, 0,0); + } else if (DH.language_type == DH.LANG_ko) { + b = new FlxBitmapFont(Registry.C_FONT_KO_WHITE, 8, 8, Registry.ko_string, 64, 0, 0, 0, 0); + } else if (DH.language_type == DH.LANG_zhs) { + b = new FlxBitmapFont(Registry.C_FONT_ZHS_WHITE, 11, 12, Registry.zhs_string, 72, 0, 0, 0, 0); + } else if (DH.language_type == DH.LANG_es || DH.language_type == DH.LANG_pt || DH.language_type == DH.LANG_it) { + b = new FlxBitmapFont(Registry.C_FONT_ES_WHITE, 6, 8, Registry.es_string, 27, 0, 0, 0, 0); + } else { // english, normal font + b = new FlxBitmapFont(Registry.C_FONT_APPLE_BLACK, Registry.APPLE_FONT_w, Registry.FONT_h, Registry.C_FONT_APPLE_BLACK_STRING, Registry.FONT_cpl, 0, 0, 0, 1); + } + break; + case "apple_white": + if (DH.language_type == DH.LANG_ja) { + b = new FlxBitmapFont(Registry.C_FONT_JP_WHITE, 8, 8, Registry.jp_string, 50, 0, 0, 0, 0); + } else if (DH.language_type == DH.LANG_ko) { + b = new FlxBitmapFont(Registry.C_FONT_KO_WHITE, 8, 8, Registry.ko_string, 64, 0, 0, 0, 0); + } else if (DH.language_type == DH.LANG_zhs) { + b = new FlxBitmapFont(Registry.C_FONT_ZHS_WHITE, 11, 12, Registry.zhs_string, 72, 0, 0, 0, 0); + }else if (DH.language_type == DH.LANG_es || DH.language_type == DH.LANG_pt || DH.language_type == DH.LANG_it) { + b = new FlxBitmapFont(Registry.C_FONT_ES_WHITE, 6, 8, Registry.es_string, 27, 0, 0, 0, 0); + } else { // english, normal font + b = new FlxBitmapFont(Registry.C_FONT_APPLE_WHITE, Registry.APPLE_FONT_w, Registry.FONT_h, Registry.C_FONT_APPLE_WHITE_STRING, Registry.FONT_cpl, 0, 0, 0, 1); + } + break; + case "apple_white_OLD": + b = new FlxBitmapFont(Registry.C_FONT_APPLE_WHITE, Registry.APPLE_FONT_w, Registry.FONT_h, Registry.C_FONT_APPLE_WHITE_STRING, Registry.FONT_cpl, 0, 0, 0, 1); + break; + case "black": + default: + b = new FlxBitmapFont(Registry.C_FONT_BLACK, Registry.FONT_w, Registry.FONT_h, Registry.C_FONT_BLACK_STRING, Registry.FONT_cpl, 0, 0, 0, 0); + break; + } + b.setText(text, true, 0, 0, alignment, true); + b.x = x; + b.y = y; + if (scrollFactor == null) { + b.scrollFactor.x = b.scrollFactor.y = 0; + } else { + b.scrollFactor.x = scrollFactor.x; + b.scrollFactor.y = scrollFactor.y; + } + return b; + } + + /** + * This function keeps a sprite's hitbox entirely in the specified + * box, and flips its velocities when needed to keep it inside the box. + * @return RES, where RES = X_FLIP | Y_FLIP, where X_FLIP = 0b01, Y_FLIP = 0b10 + */ + public static function bounce_in_box(o:FlxSprite, x_max:int, x_min:int, y_max:int, y_min:int):int { + var res:int = 0; + if (o.velocity.x < 0) { + if (o.x < x_min) { + o.velocity.x *= -1; res |= 1; + } + } else { + if (o.x + o.width > x_max) { + o.velocity.x *= -1; res |= 1; + } + } + + if (o.velocity.y < 0) { + if (o.y < y_min) { + o.velocity.y *= -1; res |= 2; + } + } else { + if (o.y + o.height > y_max) { + o.velocity.y *= -1; res |= 2; + } + } + return res; + } + + /** + * Lookup the tile at (x,y) of map, and then check its properties according to submap. + * @param x + * @param y + * @param map + * @param submap + * @return + */ + public static function get_tile_collision_flags(x:int, y:int, map:FlxTilemap,submap:FlxTilemap):uint { + var tile_type:int = map.getTile(x / 16, (y - Registry.HEADER_HEIGHT) / 16); + + if (submap._tileObjects[tile_type] == null) return NONE; + + return submap._tileObjects[tile_type].allowCollisions; + } + + /** + * Get the direction from entity 1's position (e1x,e1y) to entity + * 2's position (e2x,e2y), using the rotated quadrants method. + * + * @param e1x + * @param e1y + * @param e2x + * @param e2y + * @return The FlxObject constant showing where the 2nd entity is relative to entity 1 + */ + public static function get_entity_to_entity_dir(e1x:int, e1y:int, e2x:int, e2y:int):uint { + + var dx:int = e2x - e1x; + var dy:int = e2y - e1y; + + if (dx > 0) { + if (Math.abs(dy) < dx) { + return RIGHT; + } + } else { + if (Math.abs(dy) < Math.abs(dx)) { + return LEFT; + } + } + return ((dy > 0) ? DOWN : UP); + } + + /** + * Makes e1's facing flag set towards e2. Also then plays the associated directional + * animation - prefix+"_"+{d,u,r,l} + */ + public static function face_and_play(e1:*, e2:*, prefix:String = "idle"):String { + e1.facing = get_entity_to_entity_dir(e1.x, e1.y, e2.x, e2.y); + switch (e1.facing) { + case UP: + e1.play(prefix + "_u"); + break; + case DOWN: + e1.play(prefix + "_d"); + break; + case LEFT: + e1.play(prefix + "_l"); + break; + case RIGHT: + e1.play(prefix + "_r"); + break; + } + return (e1._curAnim == null) ? "" : e1._curAnim.name; + } + + public static function play_based_on_facing(e1:*,prefix:String = "idle"):String { + switch (e1.facing) { + case UP: + e1.play(prefix + "_u"); + break; + case DOWN: + e1.play(prefix + "_d"); + break; + case LEFT: + e1.play(prefix + "_l"); + break; + case RIGHT: + e1.play(prefix + "_r"); + break; + } + return (e1._curAnim == null) ? "" : e1._curAnim.name; + } + + /** + * Checks if e1 and e2's facing flags are directional opposites. + * @param e1 + * @param e2 + * @return True or False. + */ + public static function are_facing_opposite(e1:*, e2:*):Boolean { + if (e1.facing == UP && e2.facing == DOWN) return true; + if (e2.facing == UP && e1.facing == DOWN) return true; + if (e1.facing == LEFT && e2.facing == RIGHT) return true; + if (e2.facing == LEFT && e1.facing == RIGHT) return true; + + return false; + + } + + /** + * Create a shadow specified by name, and adds the animations get_big and get_small, + * and also makes it invisible. You still need to add it to the parent. + * @param name : 8_small + * @return the shadow + */ + public static function make_shadow(name:String,visible:Boolean=false,fps:int=8):FlxSprite { + var shadow:FlxSprite = new FlxSprite; + + switch (name) { + case "8_small": + default: + shadow.loadGraphic(Common_Sprites.shadow_sprite_8_8, true, false, 8, 8); + shadow.addAnimation("get_big", [0, 1, 2, 3], fps, false); + shadow.addAnimation("get_small", [3, 2, 1, 0], fps, false); + shadow.play("get_big"); + shadow.visible = visible; + + break; + } + + return shadow; + + } + + /** + * Called by create() in PlayState and roamstate, this returns a reference to the loaded + * autosave icon. Gives it an animation, to boot. + * @param autosave_icon + * @param autosave_icon_embed + * @return + */ + public static function init_autosave_icon(autosave_icon:FlxSprite, autosave_icon_embed:Class):FlxSprite { + + autosave_icon = new FlxSprite(160 - 80 - 32, 20);//(160 - 2 - 64, 20 + 160 - 2 - 64); + autosave_icon.loadGraphic(autosave_icon_embed, true, false, 64, 16); + autosave_icon.visible = false; + autosave_icon.addAnimation("a", [0, 1, 2, 3, 4, 5], 8, true); + autosave_icon.play("a"); + autosave_icon.scrollFactor.x = autosave_icon.scrollFactor.y = 0; + return autosave_icon; + } + + /** + * Gets the tile's collision flags at (x,y) (default screenspace coords) + * @param x + * @param y + * @param map + * @param screen_coords + * @return + */ + public static function get_tile_allow_collisions(x:int, y:int, map:FlxTilemap, screen_coords:Boolean = true):uint { + + if (screen_coords) { + var _x:int = (x % 160) / 16; //FCK IT + var _y:int = ((y - 20) % 160) / 16; + var tile_idx:int = map.getTileByIndex(_y * 10 + _x); + var tile:FlxTile = map._tileObjects[tile_idx]; + return tile.allowCollisions; + } + return NONE; + } + + public static function get_tile_nr(x:int, y:int, map:FlxTilemap):int { + var _x:int = (x % 160) / 16; //FCK IT + var _y:int = ((y - 20) % 160) / 16; + var tile_idx:int = map.getTileByIndex(_y * 10 + _x); + return tile_idx; + } + + public static function fade_and_switch(name:String):void { + Registry.E_FADE_AND_SWITCH = true; + Registry.E_FADE_AND_SWITCH_SONG = name; + Registry.E_FADED = false; + } + + /** + * Increments timer until it reaches timer_max, then sets timer to 0. + * @param timer + * @param timer_max + * @return false if timer < timer_max, true otherwise + */ + public static function time_cond(ref:*,timer:String, timer_max:String):Boolean { + ref[timer] += FlxG.elapsed; + if (ref[timer] > ref[timer_max]) { + ref[timer] = 0; + return true; + } + return false; + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/Joypad_Config_Group.as b/intra/src/helper/Joypad_Config_Group.as new file mode 100644 index 0000000..dcf3f9e --- /dev/null +++ b/intra/src/helper/Joypad_Config_Group.as @@ -0,0 +1,296 @@ +package helper +{ + import global.Keys; + import global.Registry; + import org.flixel.FlxG; + import org.flixel.FlxGroup; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import states.PauseState; + + /** + * ... + * @author Melos Han-Tani + */ + public class Joypad_Config_Group extends FlxGroup + { + + public var controls:FlxBitmapFont = EventScripts.init_bitmap_font("JOYPAD CONFIG", "left", 5, 20, null, "apple_white"); + public var instructions:FlxBitmapFont = EventScripts.init_bitmap_font("h", "left", 5, 65, null, "apple_white"); + public var yesno:FlxBitmapFont = EventScripts.init_bitmap_font("Yes No", "center", 20, 140, null, "apple_white"); + public var debugtext:FlxBitmapFont = EventScripts.init_bitmap_font(".", "left", 2, 150, null, "apple_white"); + public var selector:FlxSprite = new FlxSprite; + + + public static var REAL_JOYBINDS:Array; + private var state:int = 0; + private var cursor_state:int = 0; + + private const S_DETECTED:int = 0; + private const S_INPUT:int = 1; + private const S_IDLE:int = -1; + private const S_DONE:int = 2; + private const S_TEST:int = 3; + + private var move_square:FlxSprite = new FlxSprite(100, 110); + private var goal_square:FlxSprite = new FlxSprite(20, 130); + + private var blackscrn:FlxSprite = new FlxSprite(0, 0); + public function Joypad_Config_Group() + { + + blackscrn.makeGraphic(160, 180, 0xff000000); + blackscrn.scrollFactor = new FlxPoint(0, 0); + add(blackscrn); + add(controls); + add(instructions); + add(yesno); + add(debugtext); + + set_instructions_text(); + + selector.loadGraphic(PauseState.arrows_sprite, true, false, 7, 7); + selector.frame = 2; + selector.scrollFactor = new FlxPoint(0, 0); + selector.x = yesno.x - 8; + selector.y = yesno.y; + add(selector); + + move_square.scrollFactor.x = goal_square.scrollFactor.x = 0; + move_square.scrollFactor.y = goal_square.scrollFactor.y = 0; + move_square.makeGraphic(16, 16, 0xfff0f0f0); + goal_square.makeGraphic(16, 16, 0xffff0000); + add(move_square); + add(goal_square); + move_square.visible = goal_square.visible = false; + + } + + // keys_idx is 0 to 7 + // so earlier it was checking input_id != keys_idx + // that person was having errors with action 1 + 2, which are keys_idx = 4 and 5 + // it wasn't detecting a duplicate when keys_idx = 5 + // they had two axes, meaning button input_id would be from 5 to ... + // meaning the checkk is 5 != 5. his controller probably double-inputs presses? + // this should work now.. + private function no_dups(input_id:int,keys_idx:int):Boolean { + for (var i:int = 0; i < 8; i++) { + if (Registry.joybinds[i] == input_id && i != keys_idx) { + return false; + } + } + return true; + } + private var delay:Number = 1; + private var timeout:Number = 15; + private var wait_time:Number = 4; + override public function update():void + { + + // Force an exit out of the config if we d/c while configing + if (Keys.has_joypad == false || (Intra.IS_MAC && Main.mac_joy_manager.joysticks[0] == null)) { + state = S_DONE; + return; + } + + if (Main.mac_joy_manager != null) { + for (var a:int = 1; a < Main.mac_joy_manager.joysticks.length; a++) { + if (Main.mac_joy_manager.joysticks[a] != null) { + Main.mac_joy_manager.joysticks[0] = Main.mac_joy_manager.joysticks[a]; + break; + } + } + } + + debugtext.text = "Axes " + Keys.get_axis_stats() + "\n" + "Btns " + Keys.get_btn_stats() + "\n" + Keys.nr_axes.toString() + "/" + Keys.nr_btns.toString(); + + if (state == S_DETECTED) { + if (FlxG.keys.justPressed("SPACE")) { + state = S_DONE; + cursor_state = 0; + selector.x -= 40; + } else if (cursor_state == 0 && (1 == Keys.joy_any_axis() || Registry.keywatch.JP_RIGHT)) { + cursor_state = 1; + selector.x += 40; + + } else if (cursor_state == 1 && (-1 == Keys.joy_any_axis() || Registry.keywatch.JP_LEFT)) { + cursor_state = 0; + selector.x -= 40; + } else if (Keys.joy_any_button() || FlxG.keys.any()) { + if (Registry.keywatch.RIGHT || Registry.keywatch.LEFT) return; + if (cursor_state == 0) { + for (var j:int = 0; j < 8; j++) { + Registry.joybinds[j] = 0; + } + + yesno.visible = false; + selector.visible = false; + instructions.visible = false; + state = S_IDLE; + + } else { + trace(Registry.joybinds); + state = S_DONE; + cursor_state = 0; + selector.x -= 40; + } + } + } else if (state == S_IDLE) { + controls.text = "Don't press anything.\n\nConfig starting in\n\n" + wait_time.toFixed(2); + wait_time -= FlxG.elapsed; + if (wait_time < 0) { + wait_time = 4; + controls.text = "Press input for\nUP."; + state = S_INPUT; + } + } else if (state == S_INPUT) { + + if (delay > 0) { + delay -= FlxG.elapsed; + return; + } + + if (Keys.joy_get_first_active_button_id() != 0 || Keys.joy_get_first_active_axis_id() != 0) { + + var next_id:int = Keys.joy_get_first_active_button_id(); + if (next_id == 0) { + next_id = Keys.joy_get_first_active_axis_id(); + } + + debugtext.text += "(" + next_id.toString() + ")"; + + if (cursor_state == 0) { + if (no_dups(next_id, Keys.IDX_UP) == false) return; + Registry.joybinds[Keys.IDX_UP] = next_id; + controls.text = "Press input for\nRIGHT."; + } else if (cursor_state == 1) { + if (no_dups(next_id, Keys.IDX_RIGHT) == false) return; + Registry.joybinds[Keys.IDX_RIGHT] = next_id; + controls.text = "Press input for\nDOWN."; + } else if (cursor_state == 2) { + if (no_dups(next_id, Keys.IDX_DOWN) == false) return; + Registry.joybinds[Keys.IDX_DOWN] = next_id; + controls.text = "Press input for\nLEFT."; + } else if (cursor_state == 3) { + if (no_dups(next_id, Keys.IDX_LEFT) == false) return; + Registry.joybinds[Keys.IDX_LEFT] = next_id; + controls.text = "Press input for\nConfirm."; + } else if (cursor_state == 4) { + if (no_dups(next_id, Keys.IDX_ACTION_1) == false) return; + Registry.joybinds[Keys.IDX_ACTION_1] = next_id; + controls.text = "Press input for\nCancel."; + } else if (cursor_state == 5) { + if (no_dups(next_id, Keys.IDX_ACTION_2) == false) return; + Registry.joybinds[Keys.IDX_ACTION_2] = next_id; + controls.text = "Press input for\nPause."; + } else if (cursor_state == 6) { + if (no_dups(next_id, Keys.IDX_PAUSE) == false) return; + Registry.joybinds[Keys.IDX_PAUSE] = next_id; + } + cursor_state++; + if (cursor_state == 7) { + cursor_state = 0; + controls.text = "Move the white square\nto the red square\nto confirm.\n\nOr, wait for the timer\nto run out\nto rebind the controls."; + instructions.visible = true; + instructions.y += 24; + + goal_square.visible = move_square.visible = true; + state = S_TEST; //Need to do test thing + } + + } + } else if (state == S_TEST) { + timeout -= FlxG.elapsed; + instructions.y = 89; + instructions.text = timeout.toFixed(2); + if (timeout < 10) instructions.text += " "; + + if (Keys.get_joy_state(Keys.IDX_ACTION_1)) { + instructions.text += " CONFIRM: ON\n"; + } else { + instructions.text += " CONFIRM: OFF\n"; + } + + if (Keys.get_joy_state(Keys.IDX_ACTION_2)) { + instructions.text += " CANCEL: ON\n"; + } else { + instructions.text += " CANCEL: OFF\n"; + } + + + if (Keys.get_joy_state(Keys.IDX_PAUSE)) { + instructions.text += " PAUSE: ON\n"; + } else { + instructions.text += " PAUSE: OFF\n"; + } + + if (timeout <= 0) { + reset_before_leave(); + state = S_DETECTED; + return; + } + + if (Registry.keywatch.LEFT) { + move_square.velocity.x = -20; + } else if (Registry.keywatch.RIGHT) { + move_square.velocity.x = 20; + } else { + move_square.velocity.x = 0; + } + + if (Registry.keywatch.UP) { + move_square.velocity.y = -20; + } else if (Registry.keywatch.DOWN) { + move_square.velocity.y = 20; + } else { + move_square.velocity.y = 0; + } + + if (move_square.overlaps(goal_square)) { + REAL_JOYBINDS = Registry.joybinds; + state = S_DONE; + } + } else if (state == S_DONE) { + + } + + super.update(); + } + + public function is_done():Boolean { + if (state == S_DONE) { + state = S_DETECTED; + reset_before_leave(); + return true; + } + return false; + } + + private function set_instructions_text():void + { + if (Registry.GE_States[Registry.GE_DID_JOYPAD_CONFIG_ONCE] == false) { + instructions.text = "Joypad detected for\nthe first time.\n\nConfiguration is\nnecessary!\n\nConfigure?\n(Skip w/ SPACE)"; + Registry.GE_States[Registry.GE_DID_JOYPAD_CONFIG_ONCE] = true; + } else { + instructions.text = "Joypad detected.\n\nReconfigure?\n(Skip w/ SPACE)\n"; + } + + } + + private function reset_before_leave():void + { + timeout = 15; + goal_square.visible = move_square.visible = false; + move_square.velocity.x = move_square.velocity.y = 0; + move_square.x = 100; move_square.y = 110; + set_instructions_text(); + yesno.visible = true; + delay = 1; + selector.visible = true; + instructions.y -= 24; + controls.text = "JOYPAD CONFIG"; + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/Parabola_Thing.as b/intra/src/helper/Parabola_Thing.as new file mode 100644 index 0000000..a510016 --- /dev/null +++ b/intra/src/helper/Parabola_Thing.as @@ -0,0 +1,108 @@ +package helper +{ + import org.flixel.FlxG; + import org.flixel.FlxSprite; + /** + * ... + * @author Seagaia + */ + public class Parabola_Thing + { + + /** + */ + /** + * helper class for making stuff move like a parabola. when tick is called it will + * change the given PROPERTY. changes it over a PERIOD of time, reaches MAX value.. + * up to you to use the return stuff blahbalh + * DOESNT CHECK FOR ERRORS so get your values right. ia m lazy + * @param s + * @param max + * @param period + * @param property + */ + + private var sprite_ref:FlxSprite; + private var height:Number; + public var period:Number; + public var t:Number; + private var coeff:Number; + private var prop:String; + private var subprop:String; + + private var shadow_fall_anim:String; + + private var has_fallen:Boolean = true; + + public var OFFSET:int = 0; + + public function Parabola_Thing(s:FlxSprite,_height:Number,_period:Number,_property:String,_subprop:String="") + { + sprite_ref = s; + height = _height; + period = _period; + prop = _property; + subprop = _subprop; + t = 0; + coeff = get_parabola_coeff(height, period); + + } + + public function destroy():void { + sprite_ref = null; + } + /** + * Set an animation for the shadow to play when it falls. + * (Falls = current t > period/2) + * @param name + */ + public function set_shadow_fall_animation(name:String):void { + shadow_fall_anim = name; + has_fallen = false; + } + /** + * changes its set property according to the parabola and blah blah. + * @return 1 if done, 0 if not. might be useful, but this sets "done" for you anyways + */ + public function tick():int { + + if (t > period) { + return 1; + } + if (!has_fallen && (t > period/2)) { + has_fallen = true; + sprite_ref.my_shadow.play(shadow_fall_anim); + } + if (subprop != "") { + sprite_ref[prop][subprop] = OFFSET + get_next_parabola_param(t, period, coeff); + } else { + sprite_ref[prop] = OFFSET + get_next_parabola_param(t, period, coeff); + } + + t += FlxG.elapsed; + return 0; + } + + + public function reset_time():void { + t = 0; + } + /* Returns the coefficient for a parameterization of parabola-like path */ + + public static function get_parabola_coeff(h:Number, period:Number):Number { + return (-4*h)/(period*period); + } + + /** + * given current time, period, and coeff, return the next value of + * what ever value is being changed + * @return next value yo + */ + public static function get_next_parabola_param(t:Number,period:Number,coeff:Number):Number { + return coeff * t * (t - period); + } + + + } + +} \ No newline at end of file diff --git a/intra/src/helper/S_NPC.as b/intra/src/helper/S_NPC.as new file mode 100644 index 0000000..b747cd1 --- /dev/null +++ b/intra/src/helper/S_NPC.as @@ -0,0 +1,128 @@ +package helper +{ + import global.Registry; + /** + * Helper functions for stateful npcs. + * @author Melos Han-Tani + */ + public class S_NPC + { + + public static var states:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + public static const IDX_TEST:int = 0; + public static const IDX_LOBSTER:int = 1; + public static const IDX_HAIR:int = 2; + public static const IDX_BEAR:int = 3; + public static const IDX_GOLEM:int = 4; + + private static const BIT_DIRTY:uint = 1 << 9; + private static const BIT_SECOND_PLAYED:uint = 1 << 8; + private static const BIT_BEDROOM_BOSS:uint = 1 << 7; + private static const BIT_REDCAVE_BOSS:uint = 1 << 6; + private static const BIT_CROWD_BOSS:uint = 1 << 5; + private static const BIT_APARTMENT_BOSS:uint = 1 << 4; + private static const BIT_HOTEL_BOSS:uint = 1 << 3; + private static const BIT_CIRCUS_BOSS:uint = 1 << 2; + private static const MAX_STATE:uint = 0xfc; + + //Dirty bit, read_second bit, bits on bosses. + + + // Set state, based on index into state and current Boss states. + + public static function test():void { + // WOOO INCOMPREHENSIBLE TESTS!!! + trace(check_to_play_second(DH.name_test), "FALSE!"); // Playing when clean plays first + trace(check_to_play_second(DH.name_test), "FALSE!"); // Playing when dirty but no state change doesnt play 2nd + Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx] = true; + trace(check_to_play_second(DH.name_test), "TRUE!"); // Make sure state changing plays the 2nd + Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] = true; + trace(check_to_play_second(DH.name_test), "TRUE!"); // Make sure playing the 2nd once makes any further play the 2nd + + states[IDX_TEST] = 0; + trace(check_to_play_second(DH.name_test), "FALSE!"); // Check that starting clean but with state plays 1st + trace(check_to_play_second(DH.name_test), "FALSE!"); // Dirty and state plays 1st (state donst change) + Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx] = true; + trace(check_to_play_second(DH.name_test), "TRUE!"); + + states[IDX_TEST] = 0; + + Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx] = true; + Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] = true; + Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx] = true; + Registry.GE_States[Registry.GE_Apartment_Boss_Dead_Idx] = true; + Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx] = true; + Registry.GE_States[Registry.GE_Circus_Boss_Dead_Idx] = true; + trace(check_to_play_second(DH.name_test), "FALSE!"); // PLaying hwen clena plays first + trace(check_to_play_second(DH.name_test), "TRUE!"); // play with all state set plays 2nd + + + } + + /** + * check if you need to play the 2nd dialogue choice. + * if you leave 'scene' blank, then the functiond only relies on + * the stored state of the npc rather than the state of the scene too + * @param name + * @param scene + * @param map + * @return + */ + public static function check_to_play_second(name:String, scene:String = "", map:String = ""):Boolean { + var res:Boolean = false; + if (name == DH.name_test) { + res = update(IDX_TEST); + } else if (name == DH.name_generic_npc && map == "BEACH") { // Lobster + res = update(IDX_LOBSTER); + } else if (name == DH.name_generic_npc && map == "REDSEA") { + res = update(IDX_HAIR); + } else if (name == DH.name_generic_npc && map == "FOREST") { + res = update(IDX_BEAR); + } else if (name == DH.name_generic_npc && map == "CLIFF") { + res = update(IDX_GOLEM); + } + if (scene != "" && DH.scene_is_finished(name, scene, map) == false) return false; // We want all of the first set of dialogue to play at least once + // Put the call after the update because we + // always want to record state + return res; + } + + // Returns true if: All event-bits set, or new result greater than current and dirty is set + private static function update(idx:int):Boolean { + if (states[idx] & BIT_DIRTY) { + var s_new:uint = get_current_states() | states[idx]; + // i.e., if we've done all the events and talked to the NPC once, then play its second dialogue set + // OR if the new state is newer then try to play the 2nd + // or if we've tried to play the 2nd. + var sidx:uint = states[idx]; + //trace("S_NPC.update: New: ", s_new, " Old: ", states[idx]); + if ((sidx & MAX_STATE) == MAX_STATE || s_new > sidx || s_new & BIT_SECOND_PLAYED) { + states[idx] = s_new; + states[idx] |= BIT_SECOND_PLAYED; + return true; + } + } else { + states[idx] |= BIT_DIRTY; + states[idx] |= get_current_states(); + return false; + } + return false; + } + + static private function get_current_states():uint + { + var s_new:uint = 0; + Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx] ? s_new |= BIT_BEDROOM_BOSS : 1; + Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] ? s_new |= BIT_REDCAVE_BOSS : 1; + Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx] ? s_new |= BIT_CROWD_BOSS : 1; + Registry.GE_States[Registry.GE_Apartment_Boss_Dead_Idx] ? s_new |= BIT_APARTMENT_BOSS: 1; + Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx] ? s_new |= BIT_HOTEL_BOSS : 1; + Registry.GE_States[Registry.GE_Circus_Boss_Dead_Idx] ? s_new |= BIT_CIRCUS_BOSS : 1; + //trace("S_NPC.get_current_states returns ", s_new); + return s_new; + } + + } + +} \ No newline at end of file diff --git a/intra/src/helper/ScreenFade.as b/intra/src/helper/ScreenFade.as new file mode 100644 index 0000000..fecda7b --- /dev/null +++ b/intra/src/helper/ScreenFade.as @@ -0,0 +1,175 @@ +package helper +{ + import flash.display.BitmapData; + import flash.display.Bitmap; + import flash.geom.Rectangle; + import flash.utils.ByteArray; + import org.flixel.FlxG; + import org.flixel.FlxState; + + public class ScreenFade + { + + public var base:BitmapData; + public var old:BitmapData; + public var thing_to_draw:Bitmap; + public var parent:FlxState; + + private var timer:Number; + public var timer_max:Number; + private var type:int; + public var rate:int; + private var cur:int = 1; + public static var T_RECT:int = 0; + public static var T_DS:int = 1; //downsample + public static var T_US:int = 2; //upsample + + public static var DONE:int = 0; + public static var NOT_DONE:int = 1; + + public var width:int = 160; + public var height:int = 180; //change as needed + + public var offset:int = 0; + public var ADDED_CHILD:Boolean = false; + public function ScreenFade(width:int,height:int,_parent:FlxState,_type:int) + { + base = new BitmapData(width, height, true,0x00000000); + old = new BitmapData(width, height, true,0x00000000); + thing_to_draw = new Bitmap(base); + + type = _type; + switch (type) { + case T_RECT: + FlxG.stage.addChild(thing_to_draw); + rate = 8; + timer = timer_max = 0.02; + break; + case T_DS: + rate = 10; + cur = 1; + thing_to_draw = new Bitmap(FlxG.camera.buffer); + timer = timer_max = 0.01; + break; + case T_US: + rate = 1; //min + cur = 10; //start + thing_to_draw = new Bitmap(FlxG.camera.buffer); + timer = timer_max = 0.01; + break; + } + parent = _parent; + } + + public function reset():void { + if (type == T_DS) { + rate = 10; + cur = 1; + } else if (type == T_US) { + rate = 1; + cur = 10; + } + + } + + public function do_effect():int { + + timer -= FlxG.elapsed; + if (timer < 0) { + timer = timer_max; + switch (type) { + case T_RECT: + return fx_rect(rate); + break; + case T_DS: + FlxG.camera.buffer.copyPixels(thing_to_draw.bitmapData, thing_to_draw.bitmapData.rect, thing_to_draw.bitmapData.rect.topLeft); + cur++; + return fx_downsample(cur,rate); + break; + case T_US: + FlxG.camera.buffer.copyPixels(thing_to_draw.bitmapData, thing_to_draw.bitmapData.rect, thing_to_draw.bitmapData.rect.topLeft); + cur--; + return fx_downsample(cur, rate); + } + } else { + if (type == T_DS) { + return fx_downsample(cur,rate); + } else if (type == T_US) { + return fx_downsample(cur, rate); + } + + } + return NOT_DONE; + } + + private function fx_rect(rate:int):int { + + for (var i:int = offset; i < offset + rate; i++) { + for (var j:int = 0; j < base.width; j++) { + base.setPixel32(j, i, 0xff000000); + } + } + offset += rate; + if (offset >= base.height) return DONE; + return NOT_DONE; + } + + /* + * Downsamples the camera buffer with a from-top-left-square-downsample effect. + * This is a post-processing effect. The camera's buffer is copied to thing_to_draw, + * then on every iteration it copies a downsampled version on top + **/ + private function fx_downsample(stride:int, max:int):int { + var next_color:uint; + if (stride < 1) stride = 1; //prevent infinite loop + for (var y:int = 0; y < height; y += stride) { + for (var x:int = 0; x < width; x += stride) { + next_color = thing_to_draw.bitmapData.getPixel32(x,y); + for (var _x:int = x; _x < x + stride; _x++) { + for (var _y:int = y; _y < y + stride; _y++) { + thing_to_draw.bitmapData.setPixel32(_x, _y, next_color); + } + } + } + } + FlxG.camera.buffer.copyPixels(thing_to_draw.bitmapData, thing_to_draw.bitmapData.rect, thing_to_draw.bitmapData.rect.topLeft); + if (type == T_DS) { + if (stride > max) return DONE; + } else if (type == T_US) { + if (stride <= max) return DONE; + } + return NOT_DONE; + } + + /* Downsamples buf based on the top-left squares method. + * Internal locking of buf. + * This should be called before this buffer gets copied out to + * flash. */ + public static function dumsample(stride:int, buf:BitmapData):void { + + var next_color:uint; + buf.lock(); + for (var y:int = 0; y < buf.height; y += stride) { + for (var x:int = 0; x < buf.width; x += stride) { + next_color = buf.getPixel32(x,y); + for (var _x:int = x; _x < x + stride; _x++) { + for (var _y:int = y; _y < y + stride; _y++) { + buf.setPixel32(_x, _y, next_color); + } + } + } + } + buf.unlock(); + } + public function destroy():void { + if (type == T_RECT) { + FlxG.stage.removeChild(thing_to_draw); + } + + base = old = null; + thing_to_draw = null; + parent = null + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/SpriteFactory.as b/intra/src/helper/SpriteFactory.as new file mode 100644 index 0000000..ff7522b --- /dev/null +++ b/intra/src/helper/SpriteFactory.as @@ -0,0 +1,540 @@ +package helper +{ + import entity.decoration.*; + import entity.enemy.apartment.*; + import entity.enemy.bedroom.*; + import entity.enemy.circus.*; + import entity.enemy.crowd.*; + import entity.enemy.etc.*; + import entity.enemy.hotel.*; + import entity.enemy.redcave.*; + import entity.enemy.suburb.Suburb_Killer; + import entity.enemy.suburb.Suburb_Walker; + import entity.gadget.*; + import entity.interactive.*; + import entity.interactive.npc.Forest_NPC; + import entity.interactive.npc.Happy_NPC; + import entity.interactive.npc.Huge_Fucking_Stag; + import entity.interactive.npc.Mitra; + import entity.interactive.npc.Redsea_NPC; + import entity.interactive.npc.Sage; + import entity.interactive.npc.Shadow_Briar; + import entity.interactive.npc.Space_NPC; + import entity.interactive.npc.Trade_NPC; + import entity.player.*; + import flash.geom.Point; + import global.*; + import org.flixel.*; + import org.flixel.plugin.photonstorm.*; + import states.*; + public class SpriteFactory { + + public static var P_GRID_LOCAL:int = 0; + public static var P_MAP_LOCAL:int = 1; + public static var P_GLOBAL:int = 2; + + // HI + // TODO + /* Events come from one spritesheet and the frames */ + public static var EVENT_TYPE_DARKNESS_ALPHA:int = 0; + public static var EVENT_TYPE_SCALE_VOLUME:int = 1; + public static var EVENT_TYPE_SET_ENTRANCE:int = 2; + public static var EVENT_TYPE_TEXT:int = 3; + public static var EVENT_TYPE_STATIC_OFF:int = 4; + + [Embed (source = "../res/sprites/enemies/enemy_explode_2.png")] public static var SPRITE_ENEMY_EXPLODE_2:Class; + /** + * + * @param sprite the xml reference for this object + * @param id deprecated? + * @param gridObjects array ofs tateless/stateful sprites + * @param otherObjects + * @param player player object + * @param parent_state sometimes we directly add stuff + * @return -1 if no sprite made, otherwise the number of subsprites in addition to main sprites + */ + public static function makeSprite(sprite:XML, id:int, gridObjects:Array, otherObjects:Array = null, player:Player=null, parent_state:*=null, darkness:FlxSprite = null):int { + var newSprite:FlxSprite; + var x:int = parseInt(sprite.@x); + var y:int = parseInt(sprite.@y) + Registry.HEADER_HEIGHT; + var frame_type:int = parseInt(sprite.@frame); + var permanence:int = parseInt(sprite.@p); + var name:String = sprite.name(); + + if (permanence == 0 && sprite.@alive == "false") sprite.@alive = "true"; + if (name == "Slime") { + if (sprite.@alive == "false") { + Registry.GRID_ENEMIES_DEAD++; + return -1; + } + if (frame_type == Slime.KEY_T) sprite.@p = P_GLOBAL; + newSprite = new Slime(x, y, id, frame_type,sprite,player,parent_state); + gridObjects.push(newSprite); + return 0; + } else if (name == "SinglePushBlock") { + var spb:SinglePushBlock = new SinglePushBlock(x, y, sprite,player); + gridObjects.push(spb); + otherObjects.push(spb.sentinel); + return 0; + } else if (name == "Door") { + newSprite = new Door(x, y, sprite, parent_state); + parent_state.bg_sprites.add(newSprite); + if (parseInt(sprite.@type.toXMLString()) == Door.NEXUS_PAD) { + trace("Faking nexus pad"); + var _npc:NPC = new NPC(EventScripts.fake_xml("NPC",x.toString(),y.toString(),"generic","true","0","2"), parent_state,player); + gridObjects.push(_npc); + otherObjects.push(_npc.active_region); + return 1; + } + return -1; + } else if (name == "Wall_Laser") { + var newerSprite:Wall_Laser = new Wall_Laser(x, y, sprite.@type, id); + gridObjects.push(newerSprite); + otherObjects.push(newerSprite.laser); + return 1; + } else if (name == "Eye_Light") { + var eye_light:Eye_Light = new Eye_Light(x, y, sprite, darkness); + gridObjects.push(eye_light); + otherObjects.push(eye_light.light); + return 0; + } else if (name == "Mover") { + var mover:Mover = new Mover(x, y, player, 1.0,sprite,player,parent_state); + gridObjects.push(mover); return 0; + } else if (name == "KeyBlock") { + if (sprite.@alive == "false") return -1; + var keyBlock:KeyBlock = new KeyBlock(x, y, frame_type,player, sprite); + gridObjects.push(keyBlock); return 0; + } else if (name == "Key") { + var key:Key = new Key(x, y,player,parent_state,sprite); + gridObjects.push(key); + } else if (name == "Hole") { + var hole:Hole = new Hole(x, y, sprite,player); + parent_state.bg_sprites.add(hole); return -1; + } else if (name == "Gate") { + sprite.@p = "2"; + var gate:Gate = new Gate(x, y, sprite,player); + + gridObjects.push(gate); return 0; + } else if (name == "Treasure") { + var treasure:Treasure = new Treasure(x, y, sprite,parent_state as FlxState); + sprite.@p = "2"; + parent_state.fg_sprites.add(treasure.item); + gridObjects.push(treasure); return 0; + } else if (name == "CrackedTile") { + var cracked_tile:CrackedTile = new CrackedTile(x, y, sprite,player); + parent_state.anim_tiles_group.add(cracked_tile.hole); + parent_state.anim_tiles_group.add(cracked_tile); //will get drawn because anim tiles added later + return -1; + } else if (name == "Button") { + var button:Button = new Button(x, y, sprite,parent_state); + parent_state.anim_tiles_group.add(button); + return -1; + } else if (name == "Sun_Guy") { + if (sprite.@alive == "false") { + Registry.GRID_ENEMIES_DEAD++; + return -1; + } + var sun_guy:Sun_Guy = new Sun_Guy(x, y, darkness, parent_state as PlayState, sprite,player); + gridObjects.push(sun_guy); + return 0; + } else if (name == "Dust") { + var dust:Dust = new Dust(x, y, sprite, parent_state); + parent_state.bg_sprites.add(dust); + return -1; + } else if (name == "Event") { + //var event_script:EventScripts = new EventScripts(); + //gridObjects.push(event_script); //For consistency + deal_with_event(sprite, parent_state); + return -1; + + } else if (name == "Shieldy") { + if (sprite.@alive == "false") { + Registry.GRID_ENEMIES_DEAD++; + return -1; + } + var shieldy:Shieldy = new Shieldy(x, y, sprite,parent_state as PlayState); + gridObjects.push(shieldy); return 0; + } else if (name == "Pew_Laser") { + var pew_laser:Pew_Laser = new Pew_Laser(x, y, sprite, parent_state as PlayState); + gridObjects.push(pew_laser); return 0; + } else if (name == "Annoyer") { + var annoyer:Annoyer = new Annoyer(x, y, sprite, player,parent_state); + gridObjects.push(annoyer); return 0; + } else if (name == "Console") { + var console:Console = new Console(x, y, sprite,player); + gridObjects.push(console); + return 0; + } else if (name == "Follower_Bro") { + var fb:Follower_Bro = new Follower_Bro(sprite, player); + fb.y += Registry.HEADER_HEIGHT; + gridObjects.push(fb); + return 0; + } else if (name == "Sadbro") { + var sadbro:Sadbro = new Sadbro(sprite, player); + sadbro.y += Registry.HEADER_HEIGHT; + gridObjects.push(sadbro); + return 0; + } else if (name == "Red_Walker") { + var redwalker:Red_Walker = new Red_Walker(sprite,player); + redwalker.y += Registry.HEADER_HEIGHT; + gridObjects.push(redwalker); + return 0; + } else if (name == "Four_Shooter") { + var fsht:Four_Shooter = new Four_Shooter(sprite, parent_state as PlayState, player); + fsht.y += Registry.HEADER_HEIGHT; + gridObjects.push(fsht); + return 0; + } else if (name == "Slasher") { + var slasher:Slasher = new Slasher(sprite, parent_state as PlayState, player); + slasher.y += Registry.HEADER_HEIGHT; + gridObjects.push(slasher); + return 0; + } else if (name == "On_Off_Laser") { + var oolasser:On_Off_Laser = new On_Off_Laser(sprite,player); + oolasser.y += Registry.HEADER_HEIGHT; + oolasser.laser.y += Registry.HEADER_HEIGHT; + gridObjects.push(oolasser); + otherObjects.push(oolasser.laser); + return 0; + } else if (name == "Red_Pillar") { + var red_pillar:Red_Pillar = new Red_Pillar(sprite,player,parent_state); + red_pillar.y += Registry.HEADER_HEIGHT; + gridObjects.push(red_pillar); + return 0; + } else if (name == "Solid_Sprite") { + var ss:Solid_Sprite = new Solid_Sprite(sprite,false,player); + ss.y += Registry.HEADER_HEIGHT; + gridObjects.push(ss); + ss.y += 0; + return 0; + } else if (name == "Big_Door") { + var bigdoor:Big_Door = new Big_Door(sprite, player); + bigdoor.y += Registry.HEADER_HEIGHT; + otherObjects.push(bigdoor.active_region); + gridObjects.push(bigdoor); + parent_state.fg_sprites.add(bigdoor.locked_squares); + parent_state.fg_sprites.add(bigdoor.white_flash); + parent_state.fg_sprites.add(bigdoor.score_text_1); + parent_state.fg_sprites.add(bigdoor.score_text_2); + return 0; + } else if (name == "Fisherman") { + var fisherman:Fisherman = new Fisherman(sprite, player); + fisherman.y += Registry.HEADER_HEIGHT; + gridObjects.push(fisherman); + return 0; + } else if (name == "Jump_Trigger" || name == "Spring_Pad") { + var jt:Jump_Trigger = new Jump_Trigger(sprite, player,parent_state); + jt.y += Registry.HEADER_HEIGHT; + gridObjects.push(jt); + + return 0; + } else if (name == "NPC") { + var npc:NPC = new NPC(sprite, parent_state,player); + npc.y += Registry.HEADER_HEIGHT; + gridObjects.push(npc); + otherObjects.push(npc.active_region); + return 0; + } else if (name == "Red_Boss") { + var redboss:Red_Boss = new Red_Boss(sprite, parent_state as PlayState, player); + redboss.y += Registry.HEADER_HEIGHT; + gridObjects.push(redboss); + return 0; + } else if (name == "Propelled") { + var propelled:Propelled = new Propelled(sprite, player, parent_state); + propelled.y += Registry.HEADER_HEIGHT; + parent_state.bg_sprites.add(propelled); + return -1; + } else if (name == "Stop_Marker") { + var stopmarker:Stop_Marker = new Stop_Marker(sprite, parent_state); + stopmarker.y += Registry.HEADER_HEIGHT; + gridObjects.push(stopmarker); + return 0; + } else if (name == "Person") { + var person:Person = new Person(sprite, player, parent_state); + person.y += Registry.HEADER_HEIGHT; + gridObjects.push(person); + return 0; + } else if (name == "Rotator") { + var rotator:Rotator = new Rotator(sprite, player); + rotator.y += Registry.HEADER_HEIGHT; + gridObjects.push(rotator); + otherObjects.push(rotator.sprite_ball); + return 0; + } else if (name == "Frog") { + var frog:Frog = new Frog(sprite, player, parent_state); + frog.y += Registry.HEADER_HEIGHT; + gridObjects.push(frog); + return 0; + }else if (name == "Spike_Roller") { + var spike_roller:Spike_Roller = new Spike_Roller(sprite, player, parent_state); + spike_roller.y += Registry.HEADER_HEIGHT; + gridObjects.push(spike_roller); + //adding done inside class + return 0; + } else if (name == "Dog") { + var dog:Dog = new Dog(sprite, player, parent_state); + dog.y += Registry.HEADER_HEIGHT; + gridObjects.push(dog); + return 0; + } else if (name == "WallBoss") { + var wallboss:WallBoss = new WallBoss(sprite, player, parent_state); + gridObjects.push(wallboss); + return 0; + } else if (name == "Pillar_Switch") { + var psw:Pillar_Switch = new Pillar_Switch(sprite, player, parent_state); + psw.y += 20; gridObjects.push(psw); return 0; + } else if (name == "Switch_Pillar") { + var ssss:Switch_Pillar = new Switch_Pillar(sprite, player, parent_state); + ssss.y += 20; parent_state.bg_sprites.add(ssss); return -1; + } else if (name == "Silverfish") { + var silverfish:Silverfish = new Silverfish(sprite, player, parent_state); + silverfish.y += Registry.HEADER_HEIGHT; gridObjects.push(silverfish); return 0; + } else if (name == "Rat") { + var rat:Rat = new Rat(sprite, player, parent_state); + rat.y += Registry.HEADER_HEIGHT; gridObjects.push(rat); return 0; + } else if (name == "Teleguy") { + var teleguy:Teleguy = new Teleguy(sprite, player, parent_state); + teleguy.y += Registry.HEADER_HEIGHT; gridObjects.push(teleguy); return 0; + } else if (name == "Dash_Trap") { + var dashtrap:Dash_Trap = new Dash_Trap(sprite, player, parent_state); + dashtrap.y += Registry.HEADER_HEIGHT; gridObjects.push(dashtrap); return 0; + } else if (name == "Gasguy") { + var gasguy:Gasguy = new Gasguy(sprite, player, parent_state); + gasguy.y += Registry.HEADER_HEIGHT; gridObjects.push(gasguy); return 0; + + } else if (name == "Terminal_Gate") { + var tgate:Terminal_Gate = new Terminal_Gate(sprite, player, parent_state); + tgate.y += Registry.HEADER_HEIGHT; gridObjects.push(tgate); return 0; + } else if (name == "Dustmaid") { + var dustmaid:Dustmaid = new Dustmaid(sprite, player, parent_state); + dustmaid.y += Registry.HEADER_HEIGHT; gridObjects.push(dustmaid); return 0; + } else if (name == "Splitboss") { + var splitboss:Splitboss = new Splitboss(sprite, player, parent_state); + splitboss.y += Registry.HEADER_HEIGHT; gridObjects.push(splitboss); return 0; + } else if (name == "Nonsolid") { + var nonsolid:Nonsolid = new Nonsolid(sprite); + nonsolid.y += Registry.HEADER_HEIGHT; gridObjects.push(nonsolid); return 0; + } else if (name == "Steam_Pipe") { + var steam_pipe:Steam_Pipe = new Steam_Pipe(sprite, player, parent_state); + steam_pipe.y += Registry.HEADER_HEIGHT; gridObjects.push(steam_pipe); return 0; + } else if (name == "Burst_Plant") { + var burstplant:Burst_Plant = new Burst_Plant(sprite, player, parent_state); + burstplant.y += Registry.HEADER_HEIGHT; gridObjects.push(burstplant); return 0; + } else if (name == "Dash_Pad") { + var dashpad:Dash_Pad = new Dash_Pad(sprite, player, parent_state); + dashpad.y += Registry.HEADER_HEIGHT; parent_state.bg_sprites.add(dashpad); return -1; + } else if (name == "Elevator") { + var elevator:Elevator = new Elevator(sprite, player, parent_state); + elevator.y += Registry.HEADER_HEIGHT; parent_state.fg_sprites.add(elevator); + return -1; + } else if (name == "Eye_Boss") { + var eyeboss:Eye_Boss = new Eye_Boss(sprite, player, parent_state); + eyeboss.y += Registry.HEADER_HEIGHT; + if (Eye_Boss.global_state != eyeboss.gs_water) { + gridObjects.push(eyeboss); + } else { + parent_state.bg_sprites.add(eyeboss); + } + return -1; + } else if (name == "HealthPickup") { + var healthpickup:HealthPickup = new HealthPickup(x, y + 20, parseInt(sprite.@type), parent_state, sprite); + + gridObjects.push(healthpickup); return 0; //broken + } else if (name == "Contort") { + var contort:Contort = new Contort(sprite, player, parent_state); + contort.y += Registry.HEADER_HEIGHT; + gridObjects.push(contort); return 0; + } else if (name == "Lion") { + var lion:Lion = new Lion(sprite, player, parent_state); + lion.y += Registry.HEADER_HEIGHT; + gridObjects.push(lion); return 0; + } else if (name == "Circus_Folks") { + var circus_folk:Circus_Folks = new Circus_Folks(sprite, player, parent_state); + circus_folk.y += Registry.HEADER_HEIGHT; + gridObjects.push(circus_folk); return 0; + + } else if (name == "Fire_Pillar") { + var fire_pillar:Fire_Pillar = new Fire_Pillar(sprite, player, parent_state); + fire_pillar.y += Registry.HEADER_HEIGHT; + gridObjects.push(fire_pillar); return 0; + } else if (name == "solid_tile") { + var g:FlxTilemap; + var tx:int; + var ty:int; + + g = parent_state.curMapBuf; + tx = int((x % 160) / 16); + ty = int(((y - 20) % 160) / 16); + g.setTileByIndex(10 * ty + tx,1, false); + + // Now set the BG2 and FG2 layers since they don't load dynamically. + tx = int(x / 16); + ty = int((y - 20)/ 16); + + g = parent_state.map_bg_2; + g.setTileByIndex(g.widthInTiles * ty + tx, 1, false); + g = parent_state.map_fg; + g.setTileByIndex(g.widthInTiles * ty + tx, 1, false); + + } else if (name == "Sage") { + var sage:Sage = new Sage(player, parent_state, sprite); + sage.y += Registry.HEADER_HEIGHT; + gridObjects.push(sage); return 0; + } else if (name == "Mitra") { + var mitra:Mitra = new Mitra(player, parent_state, sprite); + mitra.y += Registry.HEADER_HEIGHT; + gridObjects.push(mitra); return 0; + } else if (name == "Health_Cicada") { + var hc:Health_Cicada = new Health_Cicada(player, parent_state, sprite); + hc.y += Registry.HEADER_HEIGHT; + parent_state.header_group.add(hc.boxes); + parent_state.header_group.add(hc); + + Registry.subgroup_destroyems.push(hc); + return -1; + } else if (name == "Dungeon_Statue") { + var dunst:Dungeon_Statue = new Dungeon_Statue(player, parent_state, sprite); + dunst.y += Registry.HEADER_HEIGHT; + gridObjects.push(dunst); + return 0; + } else if (name == "Chaser") { + var chaser:Chaser = new Chaser(sprite, player, parent_state); + chaser.y += Registry.HEADER_HEIGHT; + gridObjects.push(chaser); + return 0; + } else if (Registry.CURRENT_MAP_NAME == "SUBURB") { + if (name == "Suburb_Walker") { + var subwalk:Suburb_Walker = new Suburb_Walker(new Array(sprite, player, parent_state,true)); + gridObjects.push(subwalk); + return 0; + } else if (name == "Suburb_Killer") { + var subkiller:Suburb_Killer = new Suburb_Killer(new Array(sprite, player, parent_state,true)); + gridObjects.push(subkiller); + return 0; + } + } else if (name == "Space_Face") { + var space_face:Space_Face = new Space_Face(new Array(sprite, player, parent_state,true)); + gridObjects.push(space_face); + return 0; + } else if (name == "Water_Anim") { + var waternaim:Water_Anim = new Water_Anim(new Array(sprite, player, parent_state)); + gridObjects.push(waternaim); + return 0; + } else if (name == "Go_Detector") { + var gd:Go_Detector = new Go_Detector(new Array(sprite, player, parent_state,true)); + gridObjects.push(gd); + return 0; + } else if (name == "Sage_Boss") { + var sbb:Sage_Boss = new Sage_Boss(new Array(sprite, player, parent_state, true)); + gridObjects.push(sbb); + return 0; + } else if (name == "Shadow_Briar") { + if (Registry.CURRENT_MAP_NAME == "GO") { + var briarboss:Briar_Boss = new Briar_Boss(new Array(sprite, player, parent_state, true)); + gridObjects.push(briarboss); + return 0; + } + var sbri:Shadow_Briar = new Shadow_Briar(new Array(sprite, player, parent_state, true)); + gridObjects.push(sbri); + return 0; + } else if (name == "Trade_NPC") { //cat, monster, shopkeeper - in FIELDS + var tradenpc:Trade_NPC = new Trade_NPC(new Array(sprite, player, parent_state, true)); + // only add to statelesses or wahetvver if it isnt the cat + if (parseInt(sprite.@frame) != 0) { + gridObjects.push(tradenpc); + return 0; + } + return -1; + } else if (name == "Forest_NPC") { + var forestnpc:Forest_NPC = new Forest_NPC(new Array(sprite, player, parent_state, true)); + gridObjects.push(forestnpc); + return 0; + } else if (name == "Redsea_NPC") { + var redseanpc:Redsea_NPC = new Redsea_NPC(new Array(sprite, player, parent_state, true)); + gridObjects.push(redseanpc); + return 0; + } else if (name == "Happy_NPC") { + var hapnpc:Happy_NPC = new Happy_NPC(new Array(sprite, player, parent_state, true)); + gridObjects.push(hapnpc); + return 0; + } else if (name == "Space_NPC") { + var spacenpc:Space_NPC = new Space_NPC(new Array(sprite, player, parent_state, true)); + gridObjects.push(spacenpc); + return 0; + } else if (name == "Huge_Fucking_Stag") { + var hfs:Huge_Fucking_Stag = new Huge_Fucking_Stag(new Array(sprite, player, parent_state, true)); + gridObjects.push(hfs); + return 0; + } else if (name == "Black_Thing") { + var blackthing:Black_Thing = new Black_Thing(new Array(sprite, player, parent_state, true)); + gridObjects.push(blackthing); + } + + + + return -1; + } + + public static function deal_with_event(e:XML,parent:*=null):int { + var event_type:int = parseInt(e.@frame); + + switch (event_type) { + case EVENT_TYPE_DARKNESS_ALPHA: + Registry.EVENT_CHANGE_DARKNESS_ALPHA = true; + Registry.EVENT_CHANGE_DARKNESS_ALPHA_TARGET = parseFloat(e.@type); + break; + case EVENT_TYPE_SCALE_VOLUME: + Registry.EVENT_CHANGE_VOLUME_SCALE = true; + Registry.EVENT_CHANGE_VOLUME_SCALE_TARGET = parseFloat(e.@type); + break; + case EVENT_TYPE_SET_ENTRANCE: + var checkpoint:Checkpoint = new Checkpoint(parent.player, parent, e); + checkpoint.y += Registry.HEADER_HEIGHT; + parent.bg_sprites.add(checkpoint); + break; + case EVENT_TYPE_TEXT: + var font:FlxBitmapFont; + if (e.@type.toString() == "street1") { + font = EventScripts.init_bitmap_font(" ", "center", 0, 0, new Point(1, 1), "apple_white"); + } else { + font = EventScripts.init_bitmap_font(" ", "center", 0, 0, new Point(1, 1), "apple_black"); + } + font.setText(set_text_event(e.@type.toString()),true,0,0,"center",true); + font.x = parseInt(e.@x); + font.y = parseInt(e.@y); + parent.bg_sprites.add(font); + //parent.sortables.add(font); + font.y += Registry.HEADER_HEIGHT; + return 1; + + break; + case EVENT_TYPE_STATIC_OFF: + PlayState.GFX_STATIC_ALWAYS_ON = false; + parent.dec_over.exists = false; + break; + } + return 0; + } + + public static function set_text_event(type:String):String { + if (type == "blank1") { + return " \nMove with \n" + Registry.controls[Keys.IDX_UP] +", " + Registry.controls[Keys.IDX_DOWN] + + ",\n" + Registry.controls[Keys.IDX_LEFT] + ", " + Registry.controls[Keys.IDX_RIGHT]; + } else if (type == "blank2") { + return "Interact with\nthe " + Registry.controls[Keys.IDX_ACTION_1] + " key."; + } else if (type == "blank3") { + if (!Intra.is_demo) { + return "Press " + Registry.controls[Keys.IDX_PAUSE] + " \nto open the menu \nand save the game.\n"; + } else { + return " "; + } + + } else if (type == "street1") { + return "Attack to pick up\nand drop dust."; + } + return "a"; + + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/SteamThing.as b/intra/src/helper/SteamThing.as new file mode 100644 index 0000000..356af9b --- /dev/null +++ b/intra/src/helper/SteamThing.as @@ -0,0 +1,18 @@ +package helper +{ + import com.amanitadesign.steam.FRESteamWorks; + /** + * ... + * @author Melos Han-Tani + */ + public class SteamThing + { + + public var SteamWorks:FRESteamWorks; + public function init():void { + SteamWorks = new FRESteamWorks(); + } + + } + +} \ No newline at end of file diff --git a/intra/src/helper/UI_Offsets.as b/intra/src/helper/UI_Offsets.as new file mode 100644 index 0000000..f8aae62 --- /dev/null +++ b/intra/src/helper/UI_Offsets.as @@ -0,0 +1,172 @@ +package helper +{ + import flash.geom.Point; + import flash.geom.Rectangle; + import org.flixel.FlxG; + /** + * ... + * @author Copyright Melos Han-Tani, Developer of Analgesic Productions LLC, 2013 - ? , www.twitter.com/seagaia2 + */ + public class UI_Offsets + { + + public function UI_Offsets() + { + // Set defaults + } + + public var save_array:Array; + + public var portrait_dpad:Point = new Point(); + public var portrait_x_a1:Point = new Point(); + public var portrait_c_a2:Point = new Point(); + public var portrait_pause:Point = new Point(); + public var portrait_game:Point = new Point(); + + public var landscape_dpad:Point = new Point(); + public var landscape_x_a1:Point = new Point(); + public var landscape_c_a2:Point = new Point(); + public var landscape_pause:Point = new Point(); + public var landscape_game:Point = new Point(); + + public var scale_portrait_dpad:Number = 1; + public var scale_portrait_x_a1:Number = 1; + public var scale_portrait_c_a2:Number = 1; + public var scale_portrait_pause:Number = 1; + public var scale_portrait_game:Number = 1; + + public var scale_landscape_dpad:Number = 1; + public var scale_landscape_x_a1:Number = 1; + public var scale_landscape_c_a2:Number = 1; + public var scale_landscape_pause:Number = 1; + public var scale_landscape_game:Number = 1; + + public function get_save_array():Array { + var a:Array = new Array( + portrait_dpad.x, portrait_dpad.y, scale_portrait_dpad, + portrait_x_a1.x, portrait_x_a1.y, scale_portrait_x_a1, + portrait_c_a2.x, portrait_c_a2.y, scale_portrait_c_a2, + portrait_pause.x, portrait_pause.y, scale_portrait_pause, + portrait_game.x,portrait_game.y,scale_portrait_game, + landscape_dpad.x, landscape_dpad.y, scale_landscape_dpad, + landscape_x_a1.x, landscape_x_a1.y, scale_landscape_x_a1, + landscape_c_a2.x, landscape_c_a2.y, scale_landscape_c_a2, + landscape_pause.x, landscape_pause.y, scale_landscape_pause, + landscape_game.x,landscape_game.y,scale_landscape_game); + return a; + + + } + + public function load_save_array(a:Array):void { + if (a == null) return; + save_array = a; + portrait_dpad.x = a[0]; portrait_dpad.y = a[1]; scale_portrait_dpad = a[2]; + portrait_x_a1.x = a[3]; portrait_x_a1.y = a[4]; scale_portrait_x_a1 = a[5]; + portrait_c_a2.x = a[6]; portrait_c_a2.y = a[7]; scale_portrait_c_a2 = a[8]; + portrait_pause.x = a[9]; portrait_pause.y = a[10]; scale_portrait_pause = a[11]; + portrait_game.x = a[12]; portrait_game.y = a[13]; scale_portrait_game = a[14]; + landscape_dpad.x = a[15]; landscape_dpad.y = a[16]; scale_landscape_dpad = a[17]; + landscape_x_a1.x = a[18]; landscape_x_a1.y = a[19]; scale_landscape_x_a1 = a[20]; + landscape_c_a2.x = a[21]; landscape_c_a2.y = a[22]; scale_landscape_c_a2 = a[23]; + landscape_pause.x = a[24]; landscape_pause.y = a[25]; scale_landscape_pause = a[26]; + landscape_game.x = a[27]; landscape_game.y = a[28]; scale_landscape_game = a[29]; + } + + public function set_defaults(sw:int, sh:int,fsw:int,fsh:int,only_land:Boolean=false,only_portrait:Boolean=false):void { + + var l:int = sw > sh ? sw : sh; + var s:int = sw > sh ? sh : sw; + + trace(s, l); + //Landscape + //scale_landscape_game = int(3 * (s / 540.0)) / 3.0; + if (!only_portrait) { + scale_landscape_game = (s / 540.0); + + var margin_w:int = (l - 480.0 * scale_landscape_game) / 2; + scale_landscape_dpad = int(4 * ((margin_w - 8) / 144.0)) / 4.0; + if (scale_landscape_dpad <= 0.85) { + scale_landscape_dpad = 1; + } + landscape_dpad.x = (margin_w - 144.0 * scale_landscape_dpad) / 2.0; + if (s < 600) { + landscape_dpad.y = (s - 144.0 * scale_landscape_dpad); + } else { + landscape_dpad.y = (s - 144.0 * scale_landscape_dpad) / 2.0; + } + if (landscape_dpad.x < 0) landscape_dpad.x = 0; + + scale_landscape_x_a1 = scale_landscape_c_a2 = int (4 * ((margin_w - 6 ) / (2 * 48.0))) / 4.0; + if (scale_landscape_c_a2 < 1) { + scale_landscape_c_a2 = scale_landscape_x_a1 = 1; + } + landscape_x_a1.x = (l - margin_w) + ((margin_w / 2) - (48.0 * scale_landscape_x_a1)) / 2.0; + landscape_c_a2.x = landscape_x_a1.x + (margin_w / 2); + + var action_bottom:int = 3 * (s / 5.0); + landscape_x_a1.y = action_bottom - 96.0 * scale_landscape_x_a1; + landscape_c_a2.y = action_bottom - 96.0 * scale_landscape_c_a2; + + scale_landscape_pause = int (4 * ((margin_w - 6 ) / 96.0)) / 4.0; + landscape_pause.x = (l - margin_w) + (margin_w - (scale_landscape_pause * 96.0)) / 2; + landscape_pause.y = s - 4.0 - 48 * scale_landscape_pause; + + + landscape_game.x = (l - 480.0 * scale_landscape_game) / 2; + landscape_game.x /= scale_landscape_game; // ??? + landscape_game.y = (s - 540.0 * scale_landscape_game) / 2; + landscape_game.y /= scale_landscape_game; + } + // Portrait + //scale_portrait_game = int(3*((2*l / 3) / 480.0))/3.0; + if (!only_land) { + scale_portrait_game =Math.min((2 * l / 3) / 480.0, s / 480.0); + var game_bottom:int = scale_portrait_game * 540.0; + var margin_h:int = l - game_bottom; + action_bottom = (game_bottom + (3 / 4) * margin_h); + margin_w = s / 2; + + scale_portrait_dpad = int(3 * ((Math.min(margin_h, margin_w) * 0.9) / 144.0)) / 3.0; + if (scale_portrait_dpad <= 1) { + scale_portrait_dpad = 0.85; + } + portrait_dpad.x = (margin_w - 144.0 * scale_portrait_dpad) / 2.0; + portrait_dpad.y = ((margin_h - scale_portrait_dpad * 144.0) / 2) + game_bottom; + + scale_portrait_c_a2 = scale_portrait_x_a1 = Math.min( int(4 * ((margin_w * 0.8) / (2 * 48.0))) / 4.0, int(4 * (((3 / 4) * margin_h - 6) / 96.0)) / 4.0); + if (scale_portrait_c_a2 < 1) { // on a fucking iphone + scale_portrait_c_a2 = 0.86; + scale_portrait_x_a1 = 0.86; + } + portrait_x_a1.x = (margin_w) + ((margin_w / 2.0) - (48.0 * scale_portrait_x_a1)) / 2.0; + portrait_c_a2.x = portrait_x_a1.x + (margin_w / 2.0); + + portrait_c_a2.y = portrait_x_a1.y = game_bottom + ((action_bottom - game_bottom) - (scale_portrait_c_a2 * 96.0)) / 2.0; + + scale_portrait_pause = Math.min(int(((margin_w * 0.8) / 96.0) * 2) / 2.0, int(((margin_h * 0.9 * .25) / 48.0) * 2) / 2.0); + if (scale_portrait_pause < 1) scale_portrait_pause = 0.77; + portrait_pause.x = ((margin_w - 96.0 * scale_portrait_pause) / 2) + margin_w; + portrait_pause.y = action_bottom + ((l - action_bottom) - (48.0 * scale_portrait_pause)) / 2.0; + + if (scale_portrait_pause < 1) { + portrait_pause.y -= 2; + } + + + portrait_game.x = (s - 480.0 * scale_portrait_game) / 2; + portrait_game.x /= scale_portrait_game; + portrait_game.y = 0; + } + //scale_portrait_game = int(3*((2*l / 3) / 480.0))/3.0; + //scale_landscape_game = int(3 * (s / 540.0)) / 3.0; + + + + //Intra.scale_ctr = Intra.SCALE_TYPE_FIT; + //var i:Intra = FlxG._game as Intra; + //i.resize_mobile_game(); + } + } + +} \ No newline at end of file diff --git a/intra/src/helper/invertRGB.pbj b/intra/src/helper/invertRGB.pbj new file mode 100644 index 0000000000000000000000000000000000000000..80e02fac38d85fd66eb7afcfdac21657db87d7f5 GIT binary patch literal 245 zcmXZUO-chn5Cz~jJ+n|4NR|N^r~?F%Tp)j7n3WI@Af4{g3}mW9cPHR3N134B!?WZD z;sxv>u0CGzUVUW%K5tRWk$qgR7F{X2<*?U=F|Qxdl}8rqJm%JIn4aH5>#VymC?U+`cSxAee#qPjlwpxUDf!u34Qq$@;#yL|!`SNs# zOXs}B2a4bg&Z@{Tup#0>;RhI^%JHjkhl#>zdP48)U+S$2Togu7$vjzQxD;21Ill1+ D;ru|z literal 0 HcmV?d00001 diff --git a/intra/src/helper/static.pbj b/intra/src/helper/static.pbj new file mode 100644 index 0000000000000000000000000000000000000000..7ab06aa9eb4e6ecf4190bcc954415c54def3203a GIT binary patch literal 382 zcmZ8dK}y9i6r8+Na8a>)ss1BqPZ0SBaObv^HeeS&k+yztWscI1dXIV}@dD0kHzEWk zGt+tV(oX~6;{xN}(b!#lEZXmOIv;IbPhT$}U-6evx)GpWF>;Ctm3KY}Ziz|L|ZE=6?8 z3m_>kEU}{Q9FPeKk6m$DbF5as*uMegKcBrxefB!TWJS)wsAR)ZRChQd3VrgV-&rCh p&5=8Z&iUituut`hecH>toNzApa=^kI*sFOs{n5l7uZn!nf?py-M^XR) literal 0 HcmV?d00001 diff --git a/intra/src/states/ControlsState.as b/intra/src/states/ControlsState.as new file mode 100644 index 0000000..80d3921 --- /dev/null +++ b/intra/src/states/ControlsState.as @@ -0,0 +1,234 @@ +package states +{ + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxText; + import global.Registry; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import global.Keys; + import org.flixel.FlxG; + import flash.events.KeyboardEvent; + /** + * ... + * @author Seagaia + */ + public class ControlsState extends PushableFlxState + { + + [Embed (source = "../res/sprites/inventory/controls.png")] public static var S_CONTROLS:Class; + public var bg:FlxSprite = new FlxSprite(0, 0); + public var instruction:FlxBitmapFont; + + public var controls:FlxBitmapFont; + public var i:int = 0; + private var input:String; + private var recent_key_code:uint = 1000; + public var updating:Boolean = false; + private var filler:String = " \n"; + public var is_blank_world:Boolean = false; + + public function ControlsState() { + create(); + } + override public function create():void { + + controls = EventScripts.init_bitmap_font(" ", "center", 8,16, null, "apple_white"); + instruction = EventScripts.init_bitmap_font(" ", "center", 22, 102, null, "apple_white"); + + //instruction.setText("Press " + Registry.controls[Keys.IDX_LEFT] + "\nto set controls.\n"+Registry.controls[Keys.IDX_PAUSE]+"\n to cancel.", true, 0, 0, "center", true); + instruction.setText(DH.lk("controls",0) + " "+Registry.controls[Keys.IDX_LEFT] + "\n"+DH.lk("controls",1)+"\n"+Registry.controls[Keys.IDX_PAUSE]+"\n "+DH.lk("controls",2), true, 0, 0, "center", true); + instruction.x = 25; instruction.y = 102; instruction.scrollFactor = new FlxPoint(0, 0); + bg.scrollFactor = new FlxPoint(0, 0); + bg.x = 16; + bg.y = 16; + bg.loadGraphic(S_CONTROLS, false, false, 135, 125); + + add(bg); + + controls.setText(filler, true, 0, 0, "center", true); + controls.x = 18; controls.y = 16; controls.scrollFactor = new FlxPoint(0, 0); + instruction.color = controls.color = 0xffffff; + instruction.drop_shadow = controls.drop_shadow = true; + FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown); + add(controls); + add(instruction); + } + + override public function destroy():void { + FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown); + controls.destroy(); + controls = null; + instruction.destroy(); + instruction = null; + bg = null; + super.destroy(); + } + + public function change_text():void { + remove(controls, true); + remove(instruction, true); + + controls = EventScripts.init_bitmap_font(" ", "center", 8,16, null, "apple_white"); + instruction = EventScripts.init_bitmap_font(" ", "center", 22, 102, null, "apple_white"); + + if (DH.language_type == DH.LANG_ko) { + instruction.setText(Registry.controls[Keys.IDX_LEFT] + "\n" + DH.lk("controls", 1) + "\n" + Registry.controls[Keys.IDX_PAUSE] + "\n " + DH.lk("controls", 2), true, 0, 0, "center", true); + + } else { + instruction.setText(DH.lk("controls", 0) + " " + Registry.controls[Keys.IDX_LEFT] + "\n" + DH.lk("controls", 1) + "\n" + Registry.controls[Keys.IDX_PAUSE] + "\n " + DH.lk("controls", 2), true, 0, 0, "center", true); + } + + instruction.x = 25; instruction.y = 102; instruction.scrollFactor = new FlxPoint(0, 0); + + controls.setText(filler, true, 0, 0, "center", true); + controls.x = 18; controls.y = 16; controls.scrollFactor = new FlxPoint(0, 0); + + instruction.color = controls.color = 0xffffff; + instruction.drop_shadow = controls.drop_shadow = true; + + add(controls); + add(instruction); + } + public function reportKeyDown(event:KeyboardEvent):void { + recent_key_code = event.keyCode; + } + override public function update():void { + + if (is_blank_world) { + controls.setText(filler+DH.lk("controls",3)+": " + Registry.controls[Keys.IDX_UP] + + "\n"+DH.lk("controls",4)+": " + Registry.controls[Keys.IDX_DOWN] + + "\n"+DH.lk("controls",5)+": " + Registry.controls[Keys.IDX_LEFT] + + "\n"+DH.lk("controls",6)+": " + Registry.controls[Keys.IDX_RIGHT], true, 0, 0, "center", true); + } else { + + var jump:String = "???"; + if (Registry.inventory[Registry.IDX_JUMP]) { + jump = DH.lk("controls",7); + } + controls.setText(filler+DH.lk("controls",3)+": " + Registry.controls[Keys.IDX_UP] + + "\n"+DH.lk("controls",4)+": " + Registry.controls[Keys.IDX_DOWN] + + "\n"+DH.lk("controls",5)+": " + Registry.controls[Keys.IDX_LEFT] + + "\n"+DH.lk("controls",6)+": " + Registry.controls[Keys.IDX_RIGHT] + + "\n"+DH.lk("controls",8)+": " + Registry.controls[Keys.IDX_ACTION_1] + + "\n"+jump+": " + Registry.controls[Keys.IDX_ACTION_2] + + "\n"+DH.lk("controls",9)+": " + Registry.controls[Keys.IDX_PAUSE], true, 0, 0, "center", true); + } + + + if (recent_key_code != 1000) { + if (i != 0) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + input = FlxG.keys.getKeyName(recent_key_code); + recent_key_code = 1000; + } + } + + if (i < 3 && FlxG.keys.justPressed("ESCAPE")) { + updating = false; + return; + } + + if (Registry.keywatch.LEFT && (i == 0)) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + i += 2; + //instruction.setText("Press key for\nUp", true, 0, 0, "center", true); + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",3), true, 0, 0, "center", true); + recent_key_code = 1000; + updating = true; + return; + } + + switch (i) { + case 2: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",3), true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_UP, input)) break; + Registry.controls[Keys.IDX_UP] = input; + i++; + } + break; + case 3: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",4), true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_DOWN, input)) break; + Registry.controls[Keys.IDX_DOWN] = input; + i++; + } + break; + case 4: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",5), true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_LEFT, input)) break; + Registry.controls[Keys.IDX_LEFT] = input; + i++; + } + break; + case 5: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",6),true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_RIGHT, input)) break; + Registry.controls[Keys.IDX_RIGHT] = input; + i++; + if (is_blank_world) i = 10; + } + break; + case 6: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",8), true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_ACTION_1, input)) break; + Registry.controls[Keys.IDX_ACTION_1] = input; + i++; + } + break; + case 7: + + var jump_2:String = "???"; + if (Registry.inventory[Registry.IDX_JUMP]) { + jump_2 = DH.lk("controls", 7); + } + + instruction.setText(DH.lk("controls",0)+"\n"+jump_2+"\n", true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_ACTION_2, input)) break; + Registry.controls[Keys.IDX_ACTION_2] = input; + i++; + } + break; + case 8: + i++; + break; + case 9: + instruction.setText(DH.lk("controls",0)+"\n"+DH.lk("controls",9), true, 0, 0, "center", true); + if (input != "") { + if (is_valid(Keys.IDX_PAUSE, input)) break; + Registry.controls[Keys.IDX_PAUSE] = input; + i++; + } + break; + case 10: + instruction.setText(DH.lk("controls",0)+" "+Registry.controls[Keys.IDX_PAUSE]+"\n "+DH.lk("controls",11),true, 0, 0, "center", true); + if (input != "") { + i = 0; + updating = false; + instruction.setText(DH.lk("controls",0)+" " + Registry.controls[Keys.IDX_LEFT] + "\n"+DH.lk("controls",12)+"\n" + +Registry.controls[Keys.IDX_PAUSE]+" "+DH.lk("controls",2), true, 0, 0, "left", true); + } + break; + } + input = ""; + } + + public function is_valid(index:int, input:String):int { + if (index == 0) return (input == "ESCAPE") ? 1 : 0; + for (var i:int = 0; i < index; i++) { + if (input == "ESCAPE") return 1; + if (Registry.controls[i] == input) return 1; + } + + return 0; + } + } + +} \ No newline at end of file diff --git a/intra/src/states/DialogueState.as b/intra/src/states/DialogueState.as new file mode 100644 index 0000000..86438c3 --- /dev/null +++ b/intra/src/states/DialogueState.as @@ -0,0 +1,425 @@ +package states +{ + import global.Registry; + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxG; + import org.flixel.FlxObject; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxState; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + /** + * ... + * @author Seagaia + */ + public class DialogueState extends PushableFlxState + { + + public var dialogue_box:FlxSprite = new FlxSprite(0, 0); + public var dialogue:FlxBitmapFont; + public var dialogue_shadow:FlxBitmapFont; + public var is_finished:Boolean = false; + private var next_char_timer_max:Number = 0.022; + private var next_char_timer:Number = 0.022; + private var chunked_dialogue:Boolean = false; + private var cur_line_nr:int = 0; + private var cur_char_nr:int = 0; + private var nr_lines_in_buffer:int = 0; + private var lines:Array; + private var Max_Lines_In_Buffer:int = 3; + public static var Max_Line_Size:int = 21; + + private var s_writing:int = 0; + private var max_lines_since_last_wait:int = 3; + // Counter # of lines since the last time the player had a non-forced required input. + private var lines_since_last_wait:int = 0; + // Whether the first X lines were read. + private var did_initial_read:Boolean = false; + // Whether a ^ was read, meaning the player needs to input to proceed + private var forced_input:Boolean = false; + + private var s_bumping_up:int = 1; + private var bump_timer_max:Number = 0.2; + private var bump_timer:Number = 0.2; + private var nr_bumps:int = 0; + private var bump_state_ctr:int = 0; + private var s_waiting:int = 2; + + private var s_done:int = 3; + + private var state:int = s_writing; + + private var base_y:int; //y-coord of the text when displayed. + private var bumped_y:int; //y-coord of text when moving up. + + public var blinky_box:FlxSprite = new FlxSprite(0, 0); + private var blinky_box_timer_max:Number = 0.4; + private var blinky_box_timer:Number = 0.4; + + private static var box_align:uint = FlxObject.DOWN; + + [Embed (source = "../res/sprites/menu/dialogue_box.png")] public static var menu_dialogue_box:Class; + [Embed(source = "../res/sprites/menu/menudialogue_box.png")] public static var real_menu_dialogue_Box:Class; + [Embed (source = "../res/sprites/menu/dialogue_blinky_box.png")] public static var menu_dialogue_blinky_box:Class; + + public function DialogueState() + { + create(); + } + + public function create_bitmap_text():void { + var idx_1:int = members.indexOf(dialogue); + var idx_2:int = members.indexOf(dialogue_shadow); + dialogue = EventScripts.init_bitmap_font(" ", "left", dialogue_box.x + 4, dialogue_box.y + 7, null, "apple_white"); + dialogue_shadow = EventScripts.init_bitmap_font(" ", "left", dialogue_box.x + 4, dialogue_box.y + 7, null, "apple_white"); + if (idx_1 != -1 && idx_2 != -1) { + members[idx_1] = dialogue; + members[idx_2] = dialogue_shadow; + } + dialogue_shadow.customSpacingY = 2; + dialogue.customSpacingY = 2; + set_dialogue_box(); + } + override public function create():void + { + dialogue_box.loadGraphic(menu_dialogue_box, false, false, 156, 44); + add(dialogue_box); + + create_bitmap_text(); + + add(dialogue_shadow); + add(dialogue); + + // Blinky box for dialogue + blinky_box.loadGraphic(menu_dialogue_blinky_box, true, false, 8, 8); + blinky_box.addAnimation("a", [0], 10, true); + blinky_box.play("a"); + + blinky_box.visible = false; + add(blinky_box); + + change_visibility(false); + + setAll("scrollFactor", new FlxPoint(0, 0)); + + set_box_position(FlxObject.DOWN); + + + } + + override public function draw():void + { + super.draw(); + } + + public function set_dialogue_box():void { + if (Registry.GAMESTATE != null && Registry.GAMESTATE.state == Registry.GAMESTATE.S_PAUSED) { + dialogue.color = 0xFFFFFF; + dialogue_shadow.color = 0x000000; + dialogue_box.loadGraphic(real_menu_dialogue_Box, false, false, 156, 44); + } else if (Registry.CURRENT_MAP_NAME == "TRAIN" && Registry.GAMESTATE != null) { + dialogue.color = 0xffffff; + + dialogue_box.makeGraphic(156, 44, 0xff000000); + } else { + dialogue.color = 0xFFFFFF; + dialogue_shadow.color = 0x000000; + dialogue_box.loadGraphic(menu_dialogue_box, false, false, 156, 44); + } + } + + public static function set_dialogue_box_align(direction:uint):void { + box_align = direction; + } + + override public function update():void + { + if (!chunked_dialogue && !is_finished) { + set_box_position(box_align); + lines = get_chunks(Registry.cur_dialogue); + chunked_dialogue = true; + did_initial_read = false; + change_visibility(true); + blinky_box.visible = false; + + } + + switch (state) { + case s_writing: + next_char_timer -= FlxG.elapsed; + if (next_char_timer < 0) { + next_char_timer = next_char_timer_max; + if ( Registry.keywatch.ACTION_1 || Registry.keywatch.ACTION_2) { //impatient!! + next_char_timer /= 2; + } + if (cur_line_nr == 0 && cur_char_nr == 0) { + dialogue.text = get_next_char(lines); + } else { + Registry.sound_data.play_sound_group(Registry.sound_data.dialogue_blip_group); + dialogue.text = dialogue.text + get_next_char(lines); + if (Registry.FUCK_IT_MODE_ON) { + for (var asdf:int = 0; asdf < 10; asdf++) { + if (state != s_writing) break; + dialogue.text = dialogue.text + get_next_char(lines); + } + + } + } + + } + break; + case s_bumping_up: // onnly enter this state with at least 2 or 3 lines. + //bump + //wait + //bump + //wait + if (bump_state_ctr == 0) { + var chunks:Array = dialogue.text.split("\n"); + dialogue.text = " \n"; + for (var i:int = 1; i < Max_Lines_In_Buffer; i++) { + dialogue.text += chunks[i]; + dialogue.text += "\n"; + } + dialogue.y = bumped_y; + bump_state_ctr = 1; + } else { + bump_timer -= FlxG.elapsed; + if (bump_timer < 0) { + bump_timer = bump_timer_max; + if (Registry.FUCK_IT_MODE_ON) { + bump_timer = 0.01; + } + // Prevent empty string breaking FLxBitmapFont + dialogue.text = dialogue.text.substring(2); + dialogue.y = base_y; + state = s_writing; + bump_state_ctr = 0; + } + } + break; + case s_waiting: + blinky_box_timer -= FlxG.elapsed; + if (blinky_box_timer < 0) { + blinky_box_timer = blinky_box_timer_max; + blinky_box.visible = !blinky_box.visible; + } + if ( Registry.keywatch.ACTION_1 || Registry.keywatch.ACTION_2) { + // When done + Registry.sound_data.dialogue_bloop.play(); + if (cur_line_nr == lines.length && ( Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2)) { + is_finished = true; + chunked_dialogue = false; + cur_line_nr = cur_char_nr = 0; + nr_lines_in_buffer = 0; + blinky_box.visible = false; + state = s_done; + Registry.cur_dialogue = ""; + change_visibility(false); + } else if (!forced_input && cur_line_nr != lines.length) { + blinky_box.visible = false; + state = s_bumping_up; + } else if (forced_input) { + blinky_box.visible = false; + state = s_writing; + forced_input = false; + } + } + break; + case s_done: + break; + } + + dialogue_shadow.x = dialogue.x; + dialogue_shadow.y = dialogue.y + 1; + dialogue_shadow.text = dialogue.text; + + + super.update(); + } + + private function get_chunks(dialogue:String):Array { + var lines:Array = new Array(); + var line:String = ""; + + // Split on [\n!?.] + var punc:Array = new Array("\n", ".", "!", "。","…","?","!", "?"); + + var punc_chunks:Array = new Array(); + // Break dialogue into chunks by punctuation. Lone newlines become whitespace + for (var pos:int = 0; pos < dialogue.length; pos++) { + + + line += dialogue.charAt(pos); + if (punc.indexOf(dialogue.charAt(pos)) != -1) { + if (dialogue.charAt(pos) == "\n") { + line = line.substring(0, line.length -1); + if (line.length == 0) { + line = " "; + } + } else { + if (dialogue.length - 1 > pos) { + var next_char:String = dialogue.charAt(pos +1); + // Don't push this sentence chunk if the next character is in {.!?} , or + // if the next character is not whittespace. + if (punc.indexOf(next_char) != -1 || next_char != " ") { + continue; //skips the pushing of current sentence + // Double space = line break + } else if (next_char == " ") { + //Skip one of the two whitespaces, and then end up pushing the line anyways + pos++; + } + } + } + punc_chunks.push(line); + line = ""; + } + + } + if (line != "") { + punc_chunks.push(line); + } + line = ""; + + + var cc:Array = new Array(); // chunk chunks <_> + for each (var chunk:String in punc_chunks) { + // If this chunk fits, just push it into the list. + if (chunk.length <= Max_Line_Size) { + //Remove trailing whitespace if not a single character + var nr_forced_breaks:int = 0; + for (pos = 0; pos < chunk.length; pos++) { + if (chunk.charAt(pos) == "^") { + nr_forced_breaks++; + } + } + // Prevent bitmap font error w/ empty str + if ((chunk.charAt(0) == " " || chunk.charAt(0) == " " )&& (chunk.length - nr_forced_breaks) > 1) { + chunk = chunk.substring(1); + } + lines.push(chunk); + continue; + } + /* Otherwise we gotta break it up */ + cc = chunk.split(" "); + var cur_len:int = 0; + for each (var c:String in cc) { + //make a new line if the current word doesnt fit + if (line.length + c.length + 1 > Max_Line_Size) { + if (line.length != 0) { + lines.push(line); + } + if (c.length > Max_Line_Size) { + var intermedIdx:int = 0; + var intermedstring:String = c; + while (intermedstring.length > Max_Line_Size) { + lines.push(c.substr(Max_Line_Size * intermedIdx, Max_Line_Size)); + intermedIdx++; + intermedstring = c.substr(Max_Line_Size * intermedIdx); + } + line = intermedstring; + } else { + line = c; + } + } else { + if (line.length == 0) { + line += c; + } else { + line += " " + c; + } + } + } + lines.push(line); + line = ""; + } + + return lines; + + } + + /* Return the next character in this line. + * if we reach the end, return a new line and increment + * the number of lines in the buffer, and change state + * if needed. */ + private function get_next_char(lines:Array):String { + var line:String = lines[cur_line_nr]; + if (line.charAt(cur_char_nr) == "^") { + cur_char_nr++; + state = s_waiting; + forced_input = true; + return ""; + // wait for input + } + if (cur_char_nr >= line.length) { + cur_char_nr = 0; + cur_line_nr++; + nr_lines_in_buffer++; + if (!did_initial_read) { + if (nr_lines_in_buffer == Max_Lines_In_Buffer) { + state = s_waiting; + did_initial_read = true; + } else if (cur_line_nr == lines.length) { + state = s_waiting; + blinky_box.visible = true; + blinky_box_timer = blinky_box_timer_max; + } + } else { + lines_since_last_wait++; + if (lines_since_last_wait == max_lines_since_last_wait || cur_line_nr == lines.length) { + lines_since_last_wait = 0; + state = s_waiting; + blinky_box.visible = true; + blinky_box_timer = blinky_box_timer_max; + } else { + state = s_bumping_up; + } + } + // read, read, read, wait + // bump, read, bump, read, bump, read + // wait + // bump, read, bump, read + return "\n"; + } else { + return line.charAt(cur_char_nr++); + } + } + + private function set_box_position(position:uint):void + { + if (position == FlxObject.DOWN) { + dialogue_box.y = 180 - dialogue_box.height - 2; + } else if (position == FlxObject.UP) { + dialogue_box.y = 22; + } + + dialogue_box.x = 2; + + dialogue.x = dialogue_box.x + 4; + dialogue.y = dialogue_box.y + 7; + if (DH.isZH()) dialogue.y = dialogue_box.y + 2; + base_y = dialogue.y; + bumped_y = dialogue.y - 5; + + blinky_box.x = dialogue_box.x + dialogue_box.width - 10; + blinky_box.y = dialogue_box.y + dialogue_box.height - 10; + } + + private function change_visibility(visible:Boolean):void { + dialogue_shadow.visible = dialogue.visible = dialogue_box.visible = blinky_box.visible = visible; + } + + override public function push(_parent:FlxState):void + { + dialogue.text = "."; + super.push(_parent); + } + + public function reset():void { + state = s_writing; + is_finished = false; + DH.update_current_scene_on_chunk_finish(); + + } + } + +} \ No newline at end of file diff --git a/intra/src/states/EndingState.as b/intra/src/states/EndingState.as new file mode 100644 index 0000000..f54cb3c --- /dev/null +++ b/intra/src/states/EndingState.as @@ -0,0 +1,637 @@ +package states +{ + import entity.enemy.*; + import entity.enemy.bedroom.*; + import entity.enemy.etc.Chaser; + import entity.enemy.etc.Follower_Bro; + import entity.enemy.etc.Red_Walker; + import entity.enemy.etc.Sadbro; + import entity.enemy.etc.Space_Face; + import entity.enemy.redcave.*; + import entity.enemy.crowd.*; + import entity.enemy.apartment.*; + import entity.enemy.hotel.*; + import entity.enemy.circus.*; + import entity.enemy.suburb.Suburb_Killer; + import entity.enemy.suburb.Suburb_Walker; + import entity.gadget.Checkpoint; + import entity.interactive.Fisherman; + import entity.interactive.NPC; + import entity.interactive.npc.Forest_NPC; + import entity.interactive.npc.Mitra; + import entity.interactive.npc.Sage; + import entity.interactive.npc.Shadow_Briar; + import entity.interactive.npc.Space_NPC; + import entity.interactive.npc.Trade_NPC; + import entity.player.Player; + import flash.geom.Point; + import global.Keys; + import global.Registry; + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxG; + import org.flixel.FlxGroup; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxState; + import org.flixel.FlxText; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + + public class EndingState extends FlxState + { + public function EndingState () { + + } + [Embed(source = "../res/sprites/npcs/easter/dev_npcs.png")] public static const embed_dev_npcs:Class; + private var state:int = 1; + private const S_DONE:int = 2; + private const S_DIALOGUE_DONE:int = 3; + public var text:FlxBitmapFont; + public var text2:FlxBitmapFont; + + private var sprites_1:FlxGroup = new FlxGroup(12); + private var sprites_2:FlxGroup = new FlxGroup(12); + + private var init_sprites:Array = new Array(30); + + private var positions_1:Array = new Array(new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point); + private var positions_2:Array = new Array(new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point, new Point); + + public var save_dialog_bg:FlxSprite; + public var save_dialog_text:FlxBitmapFont; + public var save_dialog_selector:FlxSprite; + public var s_ctr:int = 0; + public var ctr:int = 0; + + public var timer:Number = 0; + public var timer_text:FlxText = new FlxText(0, 0, 200); + + private var filler:String = "\n \n"; + + private var overlay:FlxSprite = new FlxSprite(); + private var bg:FlxSprite = new FlxSprite(); + private var stop_text:FlxBitmapFont; + + private var dimoverlay:FlxSprite; + + private var PG_SPRITES_START:int = 12; + // Array of the dialogue. These should be almsot as screen height, so that when + // They + private var text_ctr:int = 0; + private var dialogue:Array = new Array(); + + private var bg_ctr:int = 0; + + [Embed(source = "../res/sprites/ending/go.png")] public static const embed_go:Class; + [Embed(source = "../res/sprites/ending/screenies.png")] public static const embed_screenies:Class; + + + + override public function destroy():void + { + + super.destroy(); + save_dialog_bg = save_dialog_selector = save_dialog_text = null; + overlay = null; + timer_text = null; + bg = null; + text = text2 = null; + + } + override public function create():void + { + // debug + //ctr = 8; + dialogue = new Array(); + for (var i:int = 0; i < 24; i++) { + dialogue.push(DH.lk("ending", i)); + } + // REMOVE ABOVE LATER + text = EventScripts.init_bitmap_font(Registry.C_FONT_APPLE_WHITE_STRING, "center", 1, 180, null, "apple_white"); + text2 = EventScripts.init_bitmap_font(Registry.C_FONT_APPLE_WHITE_STRING, "center", 1, 360, null, "apple_white"); + if (DH.isZH()) { + filler = "\n \n"; + } + //text.text = "thanks for playing lol"; + text.text = dialogue[ctr] + filler; + ctr++; + text2.text = dialogue[ctr] + filler; + ctr++; + text.velocity.y = text2.velocity.y = -15; // -15 is good + text.drop_shadow = text2.drop_shadow = true; + + + dimoverlay = new FlxSprite(0, 0); + dimoverlay.makeGraphic(160, 180, 0xff000000); + dimoverlay.alpha = 0.2; + + bg.loadGraphic(embed_go, false, false, 160, 480); + bg.x = 0; bg.y = -bg.height + 180; + overlay.makeGraphic(160, 160, 0xff171717); + add(bg); + add(overlay); + + add(dimoverlay); + add(text); + add(text2) + //add(timer_text); + + + poopy_save_stuff(); + + + + add(save_dialog_bg); + add(save_dialog_text); + add(save_dialog_selector); + save_dialog_bg.visible = save_dialog_selector.visible = save_dialog_text.visible = false; + + for (i=0; i < sprites_1.maxSize; i++) { + var s1:FlxSprite = new FlxSprite; + var s2:FlxSprite = new FlxSprite; + s1.exists = s2.exists = false; + sprites_1.add(s1); + sprites_2.add(s2); + } + add(sprites_1); + add(sprites_2); + + for (i = 0; i < 30; i++) { + init_sprites[i] = false; + } + + //ctr--; + // REMOVE LATER + //make_sprites(ctr-1, text); + //make_sprites(ctr, text2); + + + if (Registry.keywatch == null) { + Registry.keywatch = new Keys(); + } + add(Registry.keywatch); + Registry.sound_data.stop_current_song(); + Registry.sound_data.start_song_from_title("ENDING"); + } + + private var fade_out:Boolean = false; + + private var depth:int = 0; + override public function update():void + { + if (Registry.keywatch.ACTION_1 && depth < 8 && ctr < 24) { + depth++; + update(); + depth--; + } + + timer += FlxG.elapsed; + timer_text.text = timer.toFixed(2); + if (state == S_DONE) { + if (ctr == 0) { + if (Registry.keywatch.JP_DOWN) { + save_dialog_selector.y += 8; + ctr = 1; + } + if (Registry.keywatch.JP_ACTION_1) { + Registry.GE_States[Registry.GE_Finished_Game] = true; + Save.save(); + Registry.sound_data.stop_current_song(); + FlxG.switchState(new TitleState()); + } + } else { + if (Registry.keywatch.JP_UP) { + ctr = 0; + save_dialog_selector.y -= 8; + } + if (Registry.keywatch.JP_ACTION_1) { + Registry.sound_data.stop_current_song(); + FlxG.switchState(new TitleState()); + } + } + super.update(); + return; + } else if (state == S_DIALOGUE_DONE) { + //stop_text.color = 0xebf600; + + if (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JUST_PRESSED_PAUSE) { + fade_out = true; + } + if (fade_out) { + dimoverlay.alpha += 0.02; + stop_text.alpha -= 0.014; + } + if (stop_text.alpha <= 0) { + stop_text.y = 0; + stop_text.alpha = 1; + //stop_text.text = filler + "Now you have\nthe ability\nto explore Young's\nworld with (almost) no\nlimitations, via \nthe swap.\n"; + stop_text.text = filler + DH.lk("ending", 25); + state = S_DONE; + ctr = 0; + save_dialog_bg.visible = save_dialog_selector.visible = save_dialog_text.visible = true; + return; + } + } + + if (text.y < -165 && ctr < dialogue.length - 1) { + text.y = 180; + ctr++; + text.text = dialogue[ctr] + filler; + if (ctr == dialogue.length - 1) { + stop_text = text; + } else if (ctr >= PG_SPRITES_START) { + make_sprites(ctr, text); + } + + } else if (text2.y < -165 && ctr < dialogue.length - 1) { + text2.y = 180; + ctr++; + text2.text = dialogue[ctr] + filler; + if (ctr == dialogue.length - 1) { + stop_text = text2; + } else if (ctr >= PG_SPRITES_START) { + make_sprites(ctr, text2); + } + } + + if (stop_text != null) { + if (stop_text.y <= 0) { + stop_text.y = 0; + stop_text.velocity.y = 0; + state = S_DIALOGUE_DONE; + } + } + + // woot! + if (ctr >= PG_SPRITES_START) { + for (var i:int = 0; i < sprites_1.maxSize; i++) { + if (sprites_1.members[i] == null) continue; + sprites_1.members[i].x = positions_1[i].x + text.x; + sprites_1.members[i].y = positions_1[i].y + text.y; + } + for (i = 0; i < sprites_2.maxSize; i++) { + if (sprites_2.members[i] == null) continue; + sprites_2.members[i].x = positions_2[i].x + text2.x; + sprites_2.members[i].y = positions_2[i].y + text2.y; + } + } + + // set velocity thingies here etc + switch (ctr) { + case 0: case 1: case 2: case 3: case 4: case 5: + overlay.alpha = 0; + bg.alpha = 1; + if (bg.y >= 0){ + bg.velocity.y = 0; + bg.y = 0; + } else { + bg.velocity.y = 10; + } + break; + case 6: + text.color = 0x000000; + text2.color = 0x000000; + text.drop_shadow = text2.drop_shadow = false; + bg.x = overlay.x = 0; + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.loadGraphic(embed_screenies, true, false, 160, 160); + overlay.y = 10; + overlay.alpha = 0; + overlay.frame = 0; + bg.velocity.y = 0; + } + bg.alpha -= fade_rate; + overlay.alpha += fade_rate; + + break; + case 7: + text.color = 0xffffff; + text2.color = 0xffffff; + text.drop_shadow = text2.drop_shadow = true; + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.loadGraphic(embed_screenies, true, false, 160, 160); + bg.frame = 1; + bg.y = 10; + + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 8: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 2; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 9: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 3; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 10: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 4; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 11: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 5; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 12: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 6; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 13: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 7; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 14: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 8; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 15: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 9; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 16: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 10; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 17: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 11; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 18: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 12; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 19: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 13; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 20: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 14; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 21: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 15; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + break; + case 22: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 16; + } + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + break; + case 23: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + bg.frame = 17; + } + bg.alpha += fade_rate; + overlay.alpha -= fade_rate; + dimoverlay.alpha -= 0.001; + break; + case 24: + if (!init_sprites[ctr-2]) { + init_sprites[ctr - 2] = true; + overlay.frame = 18; + if (stop_text == text2) { + make_sprites(ctr, text2); + } else { + make_sprites(ctr, text); + } + } + init_sprites[ctr - 2] = true; + overlay.alpha += fade_rate; + bg.alpha -= fade_rate; + + if (overlay.alpha >= 1) { + stop_text.y = -100; + } + break; + } + + super.update(); + } + + private var fade_rate:Number = 0.009; + private var new_ctr:int = 0; + private var bg_timer:Number = 0; + private static var cur_m:Array; + private static var cur_p:Array; + private static var pos_ctr:int; + private function make_sprites(pg:int, _text:FlxBitmapFont):void { + if (text == _text) { + cur_m = sprites_1.members; + sprites_1.setAll("exists", false); + cur_p = positions_1; + } else { + cur_m = sprites_2.members; + sprites_2.setAll("exists", false); + cur_p= positions_2; + } + + + pos_ctr = 0; + if (pg == PG_SPRITES_START) { + mk(Slime.Slime_Sprite, 16, 16, [0, 1],5, 4, 20); + mk(Annoyer.S_ANNOYER_SPRITE, 16, 16, [0, 1, 2, 3, 4, 5], 8, 130, 46); + mk( Pew_Laser.PEW_LASER, 16, 16, [0], 2, 5, 66); + mk(Shieldy.SPRITE_SHIELDY, 16, 16, [1, 2, 1, 0, 1, 2, 1, 0, 16, 17, 18], 5, 130, 92); + mk( Pew_Laser.PEW_LASER_BULLET, 16, 8, [0, 1], 8, 5, 84); + mk(Sun_Guy.C_SUN_GUY, 16, 24, [0, 1, 2, 3, 4], 3, 11, 110); + mk(Sun_Guy.C_LIGHT_ORB, 16, 16, [0, 1, 2, 3, 4, 3, 2, 1], 6, 125, 120); + mk( Sun_Guy.C_SUN_GUY_WAVE, 128, 8, [3, 4, 5], 8, 8, 144); + } else if (pg == PG_SPRITES_START + 1) { + mk(Mover.mover_sprite, 16, 16, [0, 1], 4, 35, -4); + mk(On_Off_Laser.on_off_shooter_sprite, 16, 16, [0, 1, 2, 2, 1, 0], 2, 108, 30); + mk(Four_Shooter.four_shooter_sprite, 16, 16, [0, 1, 2, 2, 1, 0], 3, 4, 20); + mk(Slasher.slasher_sprite, 24, 24, [0, 1, 0, 1, 0, 1], 3, 115, 68); + mk(Red_Boss.red_boss_sprite, 32, 32, [0, 0, 1, 0, 0, 2], 3, 12, 110); + mk(Red_Boss.ripple_sprite, 48, 8, [0, 1], 12, 4, 138); + } else if (pg == PG_SPRITES_START + 2) { + mk(Dog.dog_sprite, 16, 16, [2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 2, 3], 4, 22, -3); + mk(Frog.frog_sprite, 16, 16, [0, 1, 0, 1, 3, 3], 2, 118, 20); + mk(Rotator.rotator_sprite, 16, 16, [0, 1], 10, 20, 42); + mk(Person.person_sprite, 16, 16, [0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 2, 3, 2, 3], 5, 120, 68); + mk(WallBoss.wall_sprite, 160, 32, [0, 1], 4, -1, 120); + mk(WallBoss.face_sprite, 64, 32, [0, 2, 0, 2,0,2, 1,1, 4,4], 5, -1 + 48, 120); + mk(WallBoss.r_hand_sprite, 32, 32, [0, 1, 2, 3], 1, 8, 150); + mk(WallBoss.l_hand_sprite, 32, 32, [0, 1, 2, 3], 1, 128, 150); + cur_m[7].scale.x = -1; + } else if (pg == PG_SPRITES_START + 3) { + mk(Rat.rat_sprite, 16, 16, [0, 1], 5, 16, 3); + mk(Gasguy.gas_guy_sprite, 16, 24, [0, 1],4, 122, 20); + mk(Gasguy.gas_guy_cloud_sprite, 24, 24, [0, 1], 3, 137, 34); + mk(Silverfish.silverfish_sprite, 16, 16, [4, 5], 6, 5, 46); + mk(Dash_Trap.dash_trap_sprite, 16, 16, [4, 5], 12, 137, 66); + mk(Spike_Roller.Spike_Roller_Sprite_H, 128, 16, [0, 1], 5, 5, 78); + mk(Splitboss.splitboss_sprite, 24, 32, [0, 1, 2, 1], 5, 70, 120); + } else if (pg == PG_SPRITES_START + 4) { + mk(Dustmaid.dustmaid_sprite, 16, 24, [0, 0, 0, 1, 2, 1, 2, 3, 4,3,4], 7, 5, -3); + mk(Burst_Plant.burst_plant_sprite, 16, 16, [0, 0, 1, 0, 1, 3, 3, 3,3,0], 8, 140, 25); + mk(Eye_Boss.eye_boss_water_sprite, 24, 24, [0, 1, 2, 3, 2, 1], 10, 5, 70); + mk(Eye_Boss.eye_boss_water_sprite, 24, 24, [4, 5, 4, 5, 6, 7, 6], 6, 120, 70); + } else if (pg == PG_SPRITES_START + 5) { + mk(Lion.lion_sprite, 32, 32, [10, 11, 10, 11, 10, 11, 12, 12], 4, 10, -5); + mk(Contort.contort_big_sprite, 16, 32, [0, 1, 2, 1], 9, 140, 20); + mk(Contort.contort_small_sprite, 16, 16, [0, 1], 9, 140, 50); + mk(Contort.contort_small_sprite, 16, 16, [2,3], 9, 118, 50); + mk(Contort.contort_small_sprite, 16, 16, [4, 5], 9, 126, 65); + mk(Fire_Pillar.fire_pillar_base_sprite, 16, 16, [0, 1], 8, 5, 54 + 32 - 4 - 12); + mk(Fire_Pillar.fire_pillar_sprite, 16, 32, [0, 0, 0, 0, 1, 2, 3, 4, 3, 4, 5, 6, 0], 9, 5, 54); + mk(Circus_Folks.both_sprite, 16, 32, [0, 1], 8, 65, 94); + } else if (pg == PG_SPRITES_START + 6) { + //follower + mk(Follower_Bro.sprite_follower, 16, 24, [1, 2, 1, 0], 4, 14, -5); + //edward + mk(Sadbro.sadman_sprite, 16, 16, [0, 1], 2, 120, 20); + //fisherman + mk(NPC.embed_beach_npcs, 16, 16, [10,11], 3, 6, 52); + //walker + mk(Red_Walker.sprite_redwalker, 32, 48, [0, 1, 2, 3, 4], 6, 130, 50); + // lobster + mk(NPC.embed_beach_npcs, 16, 16, [0], 2, 6, 80); + //hairs + //bombs + + }else if (pg == PG_SPRITES_START + 7) { + // Miao, Icky, Goldman, Shopguy, Rank + mk(Trade_NPC.embed_dame_trade_npc, 16, 16, [0,1], 4,140, 49); + mk(Trade_NPC.embed_dame_trade_npc, 16, 16, [10,11], 4,2, 15); + mk(Trade_NPC.embed_dame_trade_npc, 16, 16, [20,21], 4,124, 91); + mk(Trade_NPC.embed_dame_trade_npc, 16, 16, [50, 51], 4, 2, 45); + mk(Forest_NPC.embed_forest_npcs, 16, 16, [30,31], 4, 129, 15); + mk(Trade_NPC.embed_dame_trade_npc, 32, 32, [15, 15, 15, 15, 15, 15, 15, 15, 16, 17, 17, 18, 18], 18, 2, 80); + }else if (pg == PG_SPRITES_START + 8) { + // James, Thorax, Rabbit, Golem + mk(Forest_NPC.embed_forest_npcs, 16, 16, [0, 1], 4, 4, 0); + mk(Forest_NPC.embed_forest_npcs, 16, 16, [10,10,11,10,10,12], 4, 130, 0); + mk(Forest_NPC.embed_forest_npcs, 16, 16, [20,21,20,22], 4, 4, 20); + mk(Forest_NPC.embed_forest_npcs, 16, 16, [30,31], 4, 130, 20); + mk(NPC.embed_cliff_npcs, 16, 16, [1,3,1,5,1,1,1,0,2,0,4,0,0,1,1], 4, 4, 40); // More ? + //folks + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [0,1],4, 3, 83); + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [9,10],4, 140, 80); + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [18,19],4, 3, 103); + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [27,28],4, 140, 103); + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [36,37],4, 3, 123); + mk(Suburb_Walker.embed_suburb_folk, 16, 16, [45,46],4, 140, 123); + }else if (pg == PG_SPRITES_START + 9) { + mk(Chaser.embed_chaser_sprite, 16, 32, [8,9], 4, 2, 4); + mk(Space_NPC.embed_space_npc, 32, 32, [10,11], 4, 120, 106); + mk(Space_NPC.embed_space_npc, 32, 32, [12,13], 4, 3, 106); + mk(Space_NPC.embed_space_npc, 16,16,[0,1], 4, 20, 40); + mk(Space_NPC.embed_space_npc, 16,16,[20,21], 4, 20, 70); + mk(Space_NPC.embed_space_npc, 16,16,[22,23], 4, 20, 70); + mk(Space_NPC.embed_space_npc, 16,16,[10,11], 4, 120, 40); + + //entities + } else if (pg == PG_SPRITES_START + 10) { + mk(Player.Player_Sprite, 16, 16, [1, 0, 1, 0], 6, 39, -5); + mk(Mitra.mitra_sprite, 16, 16, [0, 1, 0, 1], 6, 110, 17); + mk(Sage.sage_sprite, 16, 16, [0, 1], 6, 20, 44); + mk(Shadow_Briar.embed_briar, 16, 16, [0, 1], 6, 125, 67); + } else if (pg == PG_SPRITES_START + 11) { + //us??? + + mk(embed_dev_npcs, 16, 16, [0], 1, 6, 28); + mk(embed_dev_npcs, 16, 16, [10], 1, 140, 28); + + } + } + + // Set sprite ref at a[idx] to graphic, with width w, height h. + // Play the anim FRAMES at frame rate FR. + // Set its position relative to its accompanying text to posx,posy. + private function mk(graphic:Class, w:int, h:int, frames:Array, fr:int,posx:int,posy:int):void { + cur_m[pos_ctr].loadGraphic(graphic, true, false, w, h); + cur_m[pos_ctr].scale.x = 1; + cur_m[pos_ctr].addAnimation("anim"+ctr.toString(), frames, fr, true); + cur_m[pos_ctr].play("anim"+ctr.toString()); + cur_m[pos_ctr].exists = true; + cur_p[pos_ctr].x = posx; + cur_p[pos_ctr].y = posy; + pos_ctr ++; + } + private function poopy_save_stuff():void { + + save_dialog_bg = new FlxSprite; + save_dialog_bg.loadGraphic(Checkpoint.checkpoint_save_box_sprite, true, false, 80, 29); + save_dialog_bg.x = (160 - save_dialog_bg.width) / 2; + save_dialog_bg.y = 20 + (160 - save_dialog_bg.height) / 2; + save_dialog_bg.scrollFactor = new FlxPoint(0, 0); + save_dialog_text = EventScripts.init_bitmap_font(DH.lk("checkpoint",0), "left", save_dialog_bg.x + 5, save_dialog_bg.y + 2, null, "apple_white"); + save_dialog_text.drop_shadow = true; + save_dialog_selector = new FlxSprite; + save_dialog_selector.loadGraphic(PauseState.arrows_sprite, true, false, 7, 7); + save_dialog_selector.scrollFactor = new FlxPoint(0, 0); + save_dialog_selector.addAnimation("flash", [0, 1], 8); + save_dialog_selector.play("flash"); + save_dialog_selector.scale.x = -1; + + + save_dialog_selector.x = save_dialog_text.x + 4; + save_dialog_selector.y = save_dialog_text.y + 8; + if (DH.isZH()) save_dialog_selector.y = save_dialog_text.y + 16; + } + } + +} \ No newline at end of file diff --git a/intra/src/states/IntroScene.as b/intra/src/states/IntroScene.as new file mode 100644 index 0000000..98ec381 --- /dev/null +++ b/intra/src/states/IntroScene.as @@ -0,0 +1,127 @@ +package states { + import entity.decoration.Light; + import global.Keys; + import global.Registry; + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxG; + import org.flixel.FlxSprite; + import org.flixel.FlxState; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + + + public class IntroScene extends FlxState { + + + public var darkness:FlxSprite = new FlxSprite(0, 0); + public var dialogue_state:DialogueState = new DialogueState; + public var started_dialogue:Boolean = false; + public var popped_dialogue:Boolean = false; + public var c_sprite:FlxBitmapFont; + + public var light_timer:Number = 2; + public function IntroScene() { + + } + override public function create():void { + + Registry.keywatch = new Keys(); + add(Registry.keywatch); + Registry.keywatch.visible = false; + darkness.makeGraphic(160, 180, 0xff000000); + + darkness.blend = "multiply"; + add(darkness); + //Registry.sound_data.stop_current_song(); + + Registry.sound_data.start_song_from_title("BLANK"); + Registry.ENTRANCE_PLAYER_X = 397 - 320; + Registry.ENTRANCE_PLAYER_Y = 107; + Registry.CURRENT_MAP_NAME = "BLANK"; + + c_sprite = EventScripts.init_bitmap_font(Registry.controls[Keys.IDX_ACTION_1], "center", 146, 165, null, "apple_white"); + c_sprite.color = 0xff2222; + + } + + private var t_csprite:Number = 0; + private var c_ctr:int = 0; + + override public function update():void + { + light_timer -= FlxG.elapsed; + if (!started_dialogue && light_timer < 1) { + started_dialogue = true; + // handle edge case when we restart a new game + // and the gamestate object isn'tnull + if (Registry.GAMESTATE != null) Registry.GAMESTATE.dialogue_latency = -1; + + DH.set_scene_to_pos(DH.name_sage, DH.scene_sage_blank_intro, 0); + DH.start_dialogue(DH.name_sage, DH.scene_sage_blank_intro, "BLANK"); + //DH.dialogue_popup("Young...^Young...^are you there?^ Wake up!"); + dialogue_state.push(this as FlxState); + dialogue_state.blinky_box.exists = false; + add(c_sprite); + } else if (!started_dialogue) { + super.update(); + return; + } + + t_csprite += FlxG.elapsed; + if (c_sprite.alive) { + if (t_csprite > 0.6) { + t_csprite = 0; + c_sprite.alive = c_sprite.visible = false; + } + } else { + if (t_csprite > 0.6) { + t_csprite = 0; + c_sprite.visible = true; + c_sprite.alive = true; + } + } + if (Registry.keywatch.JP_ACTION_1) { + c_ctr ++; + } + if (c_ctr > 3) { + c_sprite.exists = false; + dialogue_state.blinky_box.exists = true; + } + + if (dialogue_state.is_finished) { + DH.update_current_scene_on_chunk_finish(); + if (!popped_dialogue) { + popped_dialogue = true; + light_timer = 2; + c_sprite.visible = false; + dialogue_state.pop(this as FlxState); + } + if (light_timer < 0.5) { + Registry.E_Blank_Fade = true; + FlxG.switchState(new PlayState); + } + } else { + if (FlxG.keys.any()) { // havent said to press anything yet + Registry.keywatch.JP_ACTION_1 = true; + } + dialogue_state.update(); + } + super.update(); + } + + override public function draw():void { + darkness.fill(0xff000000); + super.draw(); + } + + override public function destroy():void + { + remove(Registry.keywatch, true); + dialogue_state.destroy(); + dialogue_state = null; + c_sprite = null; + darkness = null; + super.destroy(); + } + } +} \ No newline at end of file diff --git a/intra/src/states/MinimapState.as b/intra/src/states/MinimapState.as new file mode 100644 index 0000000..d500a71 --- /dev/null +++ b/intra/src/states/MinimapState.as @@ -0,0 +1,239 @@ +package states +{ + import data.CSV_Data; + import data.TileData; + import global.Registry; + import org.flixel.FlxG; + import org.flixel.FlxPoint; + import org.flixel.FlxSprite; + import org.flixel.FlxState; + import org.flixel.FlxTilemap; + import org.flixel.system.FlxTile; + /** + * ... + * @author Seagaia + */ + public class MinimapState extends PushableFlxState + { + + public var minimap:FlxTilemap; + private var blank_tile_index:int = 9; + + /* contants, screen width and height, used for centering the map */ + private var sw:int = 160; + private var sh:int = 180; + + public static var visited:Object = { STREET: new Array(), BEDROOM: new Array(), REDCAVE: new Array(), CROWD: new Array(), APARTMENT: new Array(), CIRCUS: new Array(), HOTEL: new Array(), FIELDS: new Array(), CLIFF: new Array(), OVERWORLD: new Array(), BEACH: new Array(), REDSEA: new Array(), FOREST: new Array(), SUBURB: new Array(), TRAIN: new Array(), SPACE: new Array() , TERMINAL: new Array()}; + public static var minimap_strings:Array = new Array("","","","","","","","","","","","","","","",""); + + public static var minimap_areas:Array = new Array("STREET", "BEDROOM", "REDCAVE", "CROWD", "APARTMENT", "CIRCUS", "HOTEL","FIELDS","CLIFF","OVERWORLD","BEACH","REDSEA","FOREST","SUBURB","TRAIN","SPACE","TERMINAL"); + + public var is_finished:Boolean = false; + + public var entrance:FlxSprite = new FlxSprite(); + public var player_marker:FlxSprite = new FlxSprite(); + public var player_marker_blink_timer:Number = 0; + public var player_marker_blink_timer_max:Number = 0.4; + public var has_map:Boolean = false; + + public var nr_times_coords_set:int = 0; + public var invalid:Boolean = false; + + public function MinimapState() + { + + trace("Initializing Minimap"); + minimap = new FlxTilemap(); + minimap.loadMap("0,2", TileData.Minimap_Tiles, 7, 7); + reset_minimap(); + + add(minimap); + add(entrance); + + add(player_marker); + + setAll("scrollFactor", new FlxPoint(0, 0)); + + } + public static function save_delete_routine():void { + visited["STREET"] = new Array(); + visited["BEDROOM"] = new Array(); + visited["CROWD"] = new Array(); + visited["REDCAVE"] = new Array(); + visited["APARTMENT"] = new Array(); + visited["CIRCUS"] = new Array(); + visited["HOTEL"] = new Array(); + + visited["FOREST"] = new Array(); + visited["CLIFF"] = new Array(); + visited["BEACH"] = new Array(); + visited["REDSEA"] = new Array(); + visited["OVERWORLD"] = new Array(); + visited["FIELDS"] = new Array(); + + visited["SPACE"] = new Array(); + visited["TERMINAL"] = new Array(); + visited["SUBURB"] = new Array(); + visited["TRAIN"] = new Array(); + + MinimapState.minimap_strings = new Array("","","","","","","","","","","","","","","","",""); + } + + public function get_minimap():FlxTilemap { + if (has_map) return minimap; + return null; + } + private function reset_minimap():void { + + nr_times_coords_set = 0; + is_finished = false; + + + if (CSV_Data.minimap_csv.hasOwnProperty(Registry.CURRENT_MAP_NAME)) { + player_marker.makeGraphic(3, 3, 0xffff5949); + entrance.makeGraphic(3, 3, 0xff0d52af); + } + + + var idx:int = minimap_areas.indexOf(Registry.CURRENT_MAP_NAME); + if (idx == -1) { + visible = false; + invalid = true; + has_map = false; + return; + } + visible = true; + + minimap.null_buffer(0); // Force a redraw? + minimap.loadMap(new CSV_Data.minimap_csv[Registry.CURRENT_MAP_NAME], TileData.Minimap_Tiles, 7, 7); + set_coords(minimap); // Set alignment of minimap + + var tmap:FlxTilemap = new FlxTilemap; + // If we have not yet initialized this according to the serialized + // minimap state, then mark all rooms as not visited + if (minimap_strings[idx] == "" || minimap_strings[idx] == null) { + for (var i:int = 0; i < minimap.totalTiles; i++) { + visited[Registry.CURRENT_MAP_NAME].push(0); + } + // Otherwise use a dirty hack to get the visited data + } else { + tmap.loadMap(minimap_strings[idx], TileData.Minimap_Tiles, 7, 7); + visited[Registry.CURRENT_MAP_NAME] = tmap.getData(); + } + + + + minimap.draw(); // Maybe redraw?? + update_map(); // Make rooms invisible if not visited yet + + set_marker_coords(); // Set entrance/player spot etc + } + + + + override public function update():void + { + + player_marker_blink_timer += FlxG.elapsed; + if (player_marker_blink_timer > player_marker_blink_timer_max) { + player_marker.visible = !player_marker.visible; + player_marker_blink_timer = 0; + } + + super.update(); + } + + public function stuff_for_pause_state():void { + + if (CSV_Data.minimap_csv.hasOwnProperty(Registry.CURRENT_MAP_NAME)) { + // UPdate a room as visited + update_visited_array(Registry.CURRENT_MAP_NAME, Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + // Reload the uncovered rooms + minimap.loadMap(new CSV_Data.minimap_csv[Registry.CURRENT_MAP_NAME], TileData.Minimap_Tiles, 7, 7) + // Redraw the map + update_map(); + // MOve markers + set_marker_coords(); + } + } + + override public function push(_parent:FlxState):void + { + if (minimap_areas.indexOf(Registry.CURRENT_MAP_NAME) != -1) { + is_finished = false; + minimap.loadMap(new CSV_Data.minimap_csv[Registry.CURRENT_MAP_NAME], TileData.Minimap_Tiles, 7, 7) + update_visited_array(Registry.CURRENT_MAP_NAME, Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + update_map(); + minimap_strings[minimap_areas.indexOf(Registry.CURRENT_MAP_NAME)] = FlxTilemap.arrayToCSV(visited[Registry.CURRENT_MAP_NAME],minimap.widthInTiles); + set_marker_coords(); + } + super.push(_parent); + } + + public function init_minimap():void { + if (minimap_areas.indexOf(Registry.CURRENT_MAP_NAME) != -1) { + invalid = false; + is_finished = false; + has_map = true; + minimap.visible = player_marker.visible = entrance.visible = true; + player_marker.exists = true; + reset_minimap(); + minimap.loadMap(new CSV_Data.minimap_csv[Registry.CURRENT_MAP_NAME], TileData.Minimap_Tiles,7, 7) + update_visited_array(Registry.CURRENT_MAP_NAME, Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + minimap_strings[minimap_areas.indexOf(Registry.CURRENT_MAP_NAME)] = FlxTilemap.arrayToCSV(visited[Registry.CURRENT_MAP_NAME],minimap.widthInTiles); + update_map(); + set_marker_coords(); + } else { + has_map = false; + invalid = true; + minimap.visible = player_marker.visible = entrance.visible = false; + player_marker.exists = false; + } + } + + public function set_coords(map:FlxTilemap):void { + + minimap.x = 60 + (100 - map.width) / 2; + minimap.y = Registry.HEADER_HEIGHT + (100 - map.height) / 2; + + } + override public function destroy():void + { + // Calls the level up, destroys all things added to this state + super.destroy(); + } + + public function update_visited_array(mapName:String, gx:int, gy:int):void { + if (!invalid) { + if (minimap == null) return; + var idx:int = gy * minimap.widthInTiles + gx; + trace("Updated!", gx, gy); + visited[mapName][idx] = 1; + // Update the serialized map state + minimap_strings[minimap_areas.indexOf(Registry.CURRENT_MAP_NAME)] = FlxTilemap.arrayToCSV(visited[Registry.CURRENT_MAP_NAME], minimap.widthInTiles); + + } + } + + private function update_map():void + { + for (var i:int = 0; i < minimap.widthInTiles * minimap.heightInTiles; i++) { + if (1 != visited[Registry.CURRENT_MAP_NAME][i]) { + minimap.setTileByIndex(i, blank_tile_index, true); + } + } + } + + private function set_marker_coords():void + { + if (nr_times_coords_set < 2) { + nr_times_coords_set++; + entrance.x = minimap.x + 2 + Registry.CURRENT_GRID_X * 7; + entrance.y = minimap.y + 2 + Registry.CURRENT_GRID_Y * 7; + } + player_marker.x = minimap.x + 2 + Registry.CURRENT_GRID_X * 7; + player_marker.y = minimap.y + 2 + Registry.CURRENT_GRID_Y * 7; + } + } + +} \ No newline at end of file diff --git a/intra/src/states/MobileConfig.as b/intra/src/states/MobileConfig.as new file mode 100644 index 0000000..1df225e --- /dev/null +++ b/intra/src/states/MobileConfig.as @@ -0,0 +1,39 @@ +package states +{ + /** + * update loop for configuring mobile ui + * @author Copyright Melos Han-Tani, Developer of Analgesic Productions LLC, 2013 - ? , www.twitter.com/seagaia2 + */ + public class MobileConfig + { + + public function MobileConfig() + { + + } + + + public static var did_init:Boolean = false; + public static var in_progress:Boolean = false; + public static var done:Boolean = false; + public static function update():Boolean { + + if (!did_init) { + did_init = true; + in_progress = true; + } + + if (done) { + done = false; + in_progress = false; + did_init = false; + return true; + } + return false; + } + + + + } + +} \ No newline at end of file diff --git a/intra/src/states/PauseState.as b/intra/src/states/PauseState.as new file mode 100644 index 0000000..9703b85 --- /dev/null +++ b/intra/src/states/PauseState.as @@ -0,0 +1,2198 @@ +package states +{ + import data.SoundData; + import entity.gadget.Treasure; + import entity.interactive.NPC; + import entity.interactive.npc.Trade_NPC; + import flash.desktop.NativeApplication; + import flash.events.Event; + import flash.system.Capabilities; + import helper.Achievements; + import helper.Joypad_Config_Group; + //import flash.desktop.NativeApplication; + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxBasic; + import org.flixel.FlxGroup; + import org.flixel.FlxPoint; + import org.flixel.FlxSound; + import org.flixel.FlxSprite; + import org.flixel.FlxG; + import entity.*; + import entity.player.*; + import global.Registry; + import global.Keys; + import org.flixel.FlxState; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import org.flixel.system.FlxAnim; + + public class PauseState extends PushableFlxState + { + + + + /* Position of these two are set in PlayState */ + + + + /** NEW!!!!!!! **/ + + + private var no_scroll_point:FlxPoint = new FlxPoint(0, 0); + public var current_substate_visible:Boolean = false; + private var init_parent:Boolean = false; + + public var state:int = 0; + private var s_browse:int = 0; + private var s_map:int = 1; // Probably not used. + private var s_equip:int = 2; + private var s_cards:int = 3; + private var s_save:int = 4; + private var s_settings:int = 5; + private var s_dialogue:int = 6; + private var s_cheatz:int = 7; + private var s_secretz:int = 8; + public var done:Boolean = false; + public var exit_latency:Number = 0.5; + + private var load_dialogue:Boolean = false; + private var t_d:Number = 0; + private var tm_d:Number = 0.2; + + private var text_1:FlxBitmapFont; + private var text_2:FlxBitmapFont; + private var text_3:FlxBitmapFont; + + private var base_group:FlxGroup = new FlxGroup; + private var base_menu:FlxSprite; + private var text_categories:FlxBitmapFont; + private var text_info:FlxBitmapFont; + private var base_index:int = 0; + private var max_base_index:int = 4; + private var menu_select_inactive:FlxSprite; + private var menu_select_active:FlxSprite; + + [Embed (source = "../res/sprites/menu/arrows.png")] public static var arrows_sprite:Class; + [Embed (source = "../res/sprites/menu/menu_select_active.png")] public static var men_sel_act:Class; + [Embed (source = "../res/sprites/menu/menu_select_inactive.png")] public static var men_sel_inact:Class; + [Embed (source = "../res/sprites/menu/menu_bg.png")] public static var menu_bg_sprite:Class; + + + + private var selectors:FlxGroup = new FlxGroup(4); + + public var minimap:MinimapState; + private var map_cursor_idx:int = 0; + private var map_ctr:int = 0; + + private var legend_entrance:FlxSprite; + private var legend_cur:FlxSprite; + private var legend_entrance_b:FlxSprite; + private var legend_cur_b:FlxSprite; + + [Embed (source = "../res/sprites/menu/equipped_icon.png")] public static var equipped_icon:Class; + [Embed (source = "../res/sprites/menu/none_icon.png")] public static var none_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/long_icon.png")] public static var long_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/wide_icon.png")] public static var wide_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/transformer_icon.png")] public static var transformer_icon_sprite:Class; + + + private var equip_overlay:FlxSprite; + private var equip_boxes:FlxGroup = new FlxGroup(4); + private var equip_cursor_idx:int = 0; + private var equip_icon:FlxSprite; + private var key_icons:FlxGroup = new FlxGroup(3); + private var trade_item:FlxSprite; + private var jump_shoes:FlxSprite; + + + [Embed (source = "../res/sprites/menu/card_empty.png")] public static var card_empty_sprite:Class; + [Embed (source = "../res/sprites/menu/card_1.png")] public static var card_1_sprite:Class; + [Embed (source = "../res/sprites/menu/card_sheet.png")] public static var card_sheet_embed:Class; + + private var cards:FlxGroup = new FlxGroup(12); + private var cur_cards_pg:int = 0; + private var cards_cursor_idx:int = 0; + + private var save_cursor_idx:int = 0; + + [Embed (source = "../res/sprites/menu/volume_bar.png")] public static var volume_bar_embed:Class; + + private var volume_bar:FlxSprite; + private var volume_bar_overlay:FlxSprite = new FlxSprite; + private var volume_bar_bg:FlxSprite; + private var doing_window_config:Boolean = false; + public var controls_state:ControlsState = new ControlsState; + private var window_config:FlxSprite; + private var window_words:FlxBitmapFont; + private var settings_cursor_idx:int = 0; + private var ctr_settings:int = 0; + + private var trophies:FlxGroup; + + private var playtime_text:FlxBitmapFont; + + + + + public function PauseState() + { + create(); + } + + override public function add(Object:FlxBasic):FlxBasic + { + if (Registry.GAMESTATE != null && Registry.GAMESTATE.dialogue_state != null ) { + Registry.GAMESTATE.dialogue_state.set_dialogue_box(); + } + + Registry.nr_growths = 0; + for each (var val:int in Registry.card_states) { + if (val == 1) { + Registry.nr_growths += 1; + } + } + + text_categories.dirty = true; + if (DH.isZH()) text_categories.text = DH.lk("map", 0) + "\n" + DH.lk("items", 0) + "\n" + DH.lk("cards", 0) + "\n" + DH.lk("save", 0) + "\n" + DH.lk("config", 0)+"\n"; + if (Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + //text_categories.text = "Map\n\nItems\n\nCards\n\nSave\n\nConfig\n\n???"; + text_categories.text = DH.lk("map", 0) + "\n\n" + DH.lk("items", 0) + "\n\n" + DH.lk("cards", 0) + "\n\n" + DH.lk("save", 0) + "\n\n" + DH.lk("config", 0) + "\n\n???"; + if (DH.isZH()) text_categories.text = DH.lk("map", 0) + "\n" + DH.lk("items", 0) + "\n" + DH.lk("cards", 0) + "\n" + DH.lk("save", 0) + "\n" + DH.lk("config", 0) + "\n???"; + } + if (trophies != null) { + for (var i:int = 0; i < trophies.length; i++) { + set_trophy_vis(trophies, i); + } + } + text_info.text = Registry.controls[Keys.IDX_ACTION_1] + DH.lk("secrets",13)+" " + Registry.controls[Keys.IDX_ACTION_2] + DH.lk("secrets",14); + return super.add(Object); + } + + override public function draw():void + { + + + super.draw(); + } + override public function destroy():void + { + if (minimap != null) minimap.destroy(); + minimap = null; + + if (controls_state != null) controls_state.destroy(); + controls_state = null; + + /** NEW **/ + + /* Call destroy on and null all added Flixel objects */ + /* Pushable flxstates have all of their added objects removed from here*/ + super.destroy(); + + /* Remove refs */ + playtime_text = null; + text_categories = null; + text_info = null; + text_1 = null; + text_2 = null; + text_3 = null; + window_words = null; + window_config = null; + base_menu = null; + legend_entrance = legend_cur = null; + selectors = null; + equip_overlay = null; + equip_boxes = null; + key_icons = null; + trade_item = null; + jump_shoes = null; + cards = null; + legend_cur_b = legend_entrance_b = null; + volume_bar_bg = null; + + volume_bar = null; + volume_bar_overlay = null; + + base_group = null; + + trophies = null; + } + + override public function create():void { + /* Begin new logic */ + var i:int = 0; + current_substate_visible = false; + /* COMMON OBJECTS */ + base_menu = new FlxSprite(0, Registry.HEADER_HEIGHT); + base_menu.loadGraphic(menu_bg_sprite); + base_menu.scrollFactor.x = base_menu.scrollFactor.y = 0; + + set_pausemenu_labels(); + + secretz_wordz = new Array(); + for (var ij:int = 0; ij < 13; ij++) { + secretz_wordz.push(DH.lk("secrets", ij)); + } + + menu_select_inactive = new FlxSprite(0, 30); + menu_select_active = new FlxSprite(0, 30); + menu_select_active.scrollFactor = menu_select_inactive.scrollFactor = no_scroll_point; + menu_select_active.addAnimation("flash", [0, 1], 4); + menu_select_active.play("flash"); + menu_select_inactive.loadGraphic(men_sel_act, true, false, 61, 15); + + menu_select_active.loadGraphic(men_sel_act, true, false, 61,15); + menu_select_inactive.visible = false; + menu_select_inactive.frame = 2; + + var selector:FlxSprite; + for (i = 0; i < selectors.maxSize; i++) { + selector = new FlxSprite; + selector.loadGraphic(arrows_sprite, true, false, 7,7); + selector.addAnimation("disabled", [2]); + selector.addAnimation("enabled", [2,3], 6); + selector.play("disabled"); + selector.visible = false; + selector.scrollFactor = no_scroll_point; + selectors.add(selector); + } + selector = null; + + add(selectors); + + base_group.add(base_menu); + base_group.add(menu_select_active); + base_group.add(menu_select_inactive); + base_group.add(text_categories); + base_group.add(text_info); + base_group.add(text_1); + base_group.add(text_2); + base_group.add(text_3); + add(base_group); + add(selectors); + + /* MINIMAP */ + minimap = new MinimapState(); + add(minimap); + + legend_cur = new FlxSprite(63, 117); + legend_cur.makeGraphic(4,4,0xffff5949); + legend_entrance = new FlxSprite(63, 125); + legend_entrance.makeGraphic(4, 4, 0xff0d52af); + + legend_cur_b = new FlxSprite(62, 116); + legend_cur_b.makeGraphic(6,6,0xff000000); + legend_entrance_b = new FlxSprite(62, 124); + legend_entrance_b.makeGraphic(6, 6, 0xff000000); + legend_cur_b.scrollFactor = legend_entrance_b.scrollFactor = legend_cur.scrollFactor = legend_entrance.scrollFactor = no_scroll_point; + add(legend_cur_b); add(legend_entrance_b); + add(legend_cur); add(legend_entrance); + + + /* EQUIP */ + + var equip_box:FlxSprite; + for (i = 0; i < equip_boxes.maxSize; i++) { + equip_box = new FlxSprite; + equip_box.loadGraphic(none_icon_sprite, true, false, 18, 18); + equip_box.x = 65; + equip_box.y = 25 + 24 * i; + equip_box.scrollFactor = no_scroll_point; + equip_boxes.add(equip_box); + + switch (i) { + case 0: + break; + case 1: + equip_box.loadGraphic(long_icon_sprite, false, false, 18, 18); + break; + case 2: + equip_box.loadGraphic(wide_icon_sprite, false, false, 18, 18); + break; + case 3: + equip_box.loadGraphic(transformer_icon_sprite, false, false, 18, 18); + break; + + } + } + equip_box = null; + add(equip_boxes); + + //Load key icons + for (i = 0; i < 3; i++) { + var key:FlxSprite = new FlxSprite; + key_icons.add(key); + key.x = 95 + 16 * i; + key.y = 130; + } + set_key_graphics(); + key_icons.setAll("scrollFactor", no_scroll_point); + add(key_icons); + + trade_item = new FlxSprite(78, 130); + trade_item.scrollFactor.x = trade_item.scrollFactor.y = 0; + set_trade_item(); + add(trade_item); + + jump_shoes = new FlxSprite(62, 130, Treasure.embed_jump_shoes); + jump_shoes.scrollFactor.x = jump_shoes.scrollFactor.y = 0; + add(jump_shoes); + + equip_icon = new FlxSprite(equip_boxes.members[0].x + 12, equip_boxes.members[0].y - 1); + equip_icon.scrollFactor = no_scroll_point; + equip_icon.loadGraphic(equipped_icon, true, false, 7, 9); + add(equip_icon); + + /* CARDS*/ + var card:FlxSprite; + for (i = 0; i < cards.maxSize; i++) { + card = new FlxSprite; + card.loadGraphic(card_sheet_embed, false, false, 24, 24); + card.frame = 36; + // LOGIC FOR LOADING DIFFERENT CARD PICTURE HERE + card.x = 60 + 8 + (24 + 6) * (i % 3); + card.y = 20 + 8 + (24 + 6) * int(i / 3); + cards.add(card); + card.scrollFactor = no_scroll_point; + } + add(cards); + card = null; + + /* SAVE GAME */ + // ---- + + /* SETTINGS */ + + + volume_bar = new FlxSprite; + volume_bar.makeGraphic(2, 7, 0xffc7003d); + volume_bar.scale.x = int(FlxG.volume * 30); + volume_bar.x = 73; + volume_bar.y = 58; + + volume_bar_bg = new FlxSprite; + volume_bar_bg.makeGraphic(60, 7, 0xff000000); + volume_bar_bg.x = volume_bar.x; + volume_bar_bg.y = volume_bar.y; + + + volume_bar_bg.scrollFactor = volume_bar.scrollFactor = volume_bar_overlay.scrollFactor = no_scroll_point; + + volume_bar_overlay.loadGraphic(volume_bar_embed, false, false, 60, 11); + volume_bar_overlay.x = volume_bar.x; + volume_bar_overlay.y = volume_bar.y - 2; + volume_bar.x = volume_bar_overlay.x + volume_bar.scale.x - 1; + + window_config = new FlxSprite( -3, -3); + window_config.scrollFactor.x = window_config.scrollFactor.y = 0; + window_config.loadGraphic(TitleState.embed_screen_config, false, false, 166, 186); + window_words = EventScripts.init_bitmap_font("Please use the\narrow keys to resize\nthe window until\nyou cannot see\nany black around\n the borders.\n\nPress "+Registry.controls[Keys.IDX_ACTION_1]+"\nwhen done.", "center", 10, 10, null, "apple_white"); + add(volume_bar_bg); + add(volume_bar); + add(volume_bar_overlay); + window_config.visible = window_words.visible = false; + add(window_config); + add(window_words); + + /* secrets * + * */ + + trophies = new FlxGroup; + for (i = 0; i < 16; i++) { + var trophy:FlxSprite = new FlxSprite; + trophy.loadGraphic(Treasure.embed_secret_trophies, true, false, 16, 16); + trophy.frame = i; + trophies.add(trophy); + set_trophy_vis(trophies, i); + trophy.x = 64 + (i % 4) * 24; + trophy.y = 40 + int(i / 4) * 24; + trophy.scrollFactor.x = trophy.scrollFactor.y = 0; + } + add(trophies); + +   + /* playtime **/ + + playtime_text = EventScripts.init_bitmap_font("00:00:00", "left", 1, 156, null, "apple_white_OLD"); + playtime_text.color = 0xffffff; + playtime_text.drop_shadow = true; + base_group.add(playtime_text); + add(playtime_text); + + } + override public function update():void { + text_info.y = 170; + if (DH.isZH()) text_info.y = 168; + + // Calc playtime!!!! + var playtime_dat:int = 0; + playtime_dat = Registry.playtime; + var hrs:int = int(playtime_dat / 3600); + + if (hrs >= 10) { + playtime_text.text = int(playtime_dat / 3600).toString() + ":"; + } else { + playtime_text.text = "0" + int(playtime_dat / 3600).toString() + ":"; + } + playtime_dat -= 3600 * hrs; + + var mins:int = int(playtime_dat / 60); + if (mins >= 10) { + playtime_text.text += int(playtime_dat / 60).toString() + ":"; + } else { + playtime_text.text = playtime_text.text + "0" + int(playtime_dat / 60).toString() + ":"; + } + playtime_dat -= 60 * mins; + + if (playtime_dat >= 10) { + playtime_text.text += playtime_dat.toString(); + } else { + playtime_text.text = playtime_text.text + "0"+ playtime_dat.toString(); + } + + if (Registry.GAMESTATE.load_dialogue) { + Registry.GAMESTATE.dialogue_state.push(this as FlxState); + Registry.GAMESTATE.load_dialogue = false; + state = s_dialogue; + return; + + } else if (state == s_dialogue) { + dialogue_logic(); + super.update(); + return; + } + + if (ctr_settings != 1 && ctr_settings != 5) { + if (state == s_browse) { + check_for_exit_with(Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JUST_PRESSED_PAUSE); + } else { + check_for_exit_with(Registry.keywatch.JUST_PRESSED_PAUSE); + } + } + if (!init_parent) { + parent = Registry.GAMESTATE; + init_parent = true; + } + switch (state) { + case s_browse: + browse_logic(); + break; + case s_map: + map_logic(); + break; + case s_equip: + equip_logic(); + break; + case s_cards: + cards_logic(); + break; + case s_save: + save_logic(); + break; + case s_settings: + settings_logic(); + break; + case s_secretz: + secretz_logic(); + break; + case s_cheatz: + cheatz_logic(); + break; + } + + if (Registry.keywatch.JP_UP || Registry.keywatch.JP_DOWN || Registry.keywatch.JP_LEFT || Registry.keywatch.JP_RIGHT) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group); + } + + if (Registry.keywatch.JP_ACTION_1) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + } + + super.update(); + } + + + private function set_equip_vis(idx:int):void { + var equip_box:FlxSprite = equip_boxes.members[idx]; + + switch (idx) { + case 1: //long + idx = Registry.IDX_LENGTHEN; + break; + case 2: //widen + idx = Registry.IDX_WIDEN; + break; + case 3: //stransform + idx = Registry.IDX_TRANSFORMER; + break; + } + if (!Registry.inventory[idx]) { + equip_box.visible = false; + } else { + equip_box.visible = true; + } + } + + public var secret_counter:int = 0; + public function browse_logic():void { + + /* Pop up substates but don't do their logic */ + if (!current_substate_visible) { + + current_substate_visible = true; + + remove(base_group, true); + add(base_group); + remove(selectors, true); + add(selectors); + + selectors.setAll("visible", false); + + switch (base_index) { + case 0: // Minimap + if (minimap.has_map) { + minimap.stuff_for_pause_state(); + } + remove(minimap, true); + add(minimap); + remove(legend_cur_b, true); + add(legend_cur_b); + remove(legend_entrance_b, true); + add(legend_entrance_b); + remove(legend_cur, true); + add(legend_cur); + remove(legend_entrance, true); + add(legend_entrance); + remove(selectors, true); add(selectors); + text_1.visible = text_2.visible = true; + //text_1.text = " :Current room\n\ + //:Door/Exit\n"; + text_1.text = " :"+DH.lk("map",1)+"\n\ + :"+DH.lk("map",2)+"\n"; + + text_1.x = 60; + text_1.y = 115; + + text_2.multiLine = true; + text_2.autoUpperCase = false; + + text_3.visible = false; + text_3.text = "Yes No"; + if (DH.isZH()) text_3.text = "是 否"; + + if (Registry.GE_States[Registry.GE_ENTERED_NEXUS_ONCE] == true && false == is_crowd_minidungeon()) { + if (false == Registry.is_dungeon(Registry.CURRENT_MAP_NAME)) { + + //text_2.text = "Return to\nNexus"; + text_2.text = DH.lk("map", 4); + if (DH.isZH()) text_2.text = text_2.text.replace("\n", ""); + if (minimap.has_map) { + text_2.x = text_1.x + 19; + text_3.x = text_1.x + 14; + text_2.y = 135; + text_3.y = 153; + + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = true; + } else { + //text_1.text = "No map"; + text_1.text = DH.lk("map",3); + text_1.x = equip_boxes.members[0].x + equip_boxes.members[0].width + 4; + text_1.y = 30; + text_2.x = 60 + 19; + text_2.y = 135; + text_3.x = 79; + text_3.y = 153; + text_2.text = DH.lk("map", 4); + + if (DH.isZH()) text_2.text = text_2.text.replace("\n", ""); + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = false; + } + + } else { + // Return to entrance + text_2.text = DH.lk("map", 5); + if (DH.isZH()) text_2.text = text_2.text.replace("\n", ""); + + text_2.x = text_1.x + 19; + text_3.x = text_1.x + 14; + text_2.y = 135; + text_3.y = 153; + + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = true; + } + if (DH.isZH()) text_2.y += 3; + } else { + text_2.visible = false; + } + break; + case 1: // eqip + remove(equip_overlay, true); add(equip_overlay); + remove(equip_boxes, true); add(equip_boxes); + remove(key_icons, true); add(key_icons); + remove(equip_icon, true); add(equip_icon); + remove(selectors, true); add(selectors); + remove(trade_item, true); add(trade_item); + remove(jump_shoes, true); add(jump_shoes); + + jump_shoes.visible = (Registry.bound_item_2 == "JUMP"); + set_trade_item(); + + set_key_graphics(); + + for (var fuckme:int = 0; fuckme < 4; fuckme++) { + equip_boxes.members[fuckme].visible = false; + } + + if (Registry.inventory[Registry.IDX_BROOM]) { + equip_boxes.members[0].visible = true; + } + if (Registry.inventory[Registry.IDX_LENGTHEN]) { + equip_boxes.members[1].visible = true; + } + if (Registry.inventory[Registry.IDX_WIDEN]) { + equip_boxes.members[2].visible = true; + } + if (Registry.inventory[Registry.IDX_TRANSFORMER]) { + equip_boxes.members[3].visible = true; + } + + if (Registry.bound_item_1 == Registry.item_names[Registry.IDX_TRANSFORMER]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24*3; + } else if (Registry.bound_effect == Registry.item_names[Registry.IDX_WIDEN]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24*2; + } else if (Registry.bound_effect == Registry.item_names[Registry.IDX_LENGTHEN]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24; + } else { + equip_icon.y = equip_boxes.members[0].y - 1; + } + if (!Registry.inventory[Registry.IDX_BROOM]) { + equip_icon.visible = false; + } else { + equip_icon.visible = true; + } + var normal_string:String = Registry.inventory[Registry.IDX_BROOM] ? DH.lk("items",1) : "-"; // Normal + var status_1:String = Registry.inventory[Registry.IDX_LENGTHEN] ? DH.lk("items",3) : "-"; //Extend + var status_2:String = Registry.inventory[Registry.IDX_WIDEN] ? DH.lk("items",4) : "-"; // WIden + var status_3:String = Registry.inventory[Registry.IDX_TRANSFORMER] ? DH.lk("items",2) : "-"; // Swap + + text_1.visible = true; + text_1.setText(normal_string + "\n\n\n" + status_1 + "\n\n\n" + status_2 + "\n\n\n" + status_3, true, 0, 0, "left", true); + if (DH.isZH()) text_1.setText(normal_string+"\n\n"+status_1+"\n\n"+status_2+"\n\n"+status_3, true, 0, 0, "left", true); + text_1.x = equip_boxes.members[0].x + equip_boxes.members[0].width + 4; + text_1.y = 30; + text_2.visible = text_3.visible = false; + break; + case 2: //card + remove(cards, true); add(cards); + remove(selectors, true); add(selectors); + cards_cursor_idx = 0; + cur_cards_pg = 0; + set_card_images(); + text_1.visible = true; + text_1.setText("1/4", true, 0, 0, "center", true); + text_1.x = 99; + text_1.y = 158; + text_2.visible = true; + //text_2.setText(Registry.nr_growths.toString() + " cards", true, 0, 0, "left", true); + if (DH.language_type == DH.LANG_ja) { + text_2.setText(Registry.nr_growths.toString() +DH.lk("cards",1), true, 0, 0, "left", true); + } else { + text_2.setText(Registry.nr_growths.toString() + " "+DH.lk("cards",1), true, 0, 0, "left", true); + } + text_2.x = 70; + text_2.y = 148; + if (DH.isZH()) { + text_1.y -= 4; + text_2.y -= 4; + } + text_3.visible = false; + break; + case 3: // save + text_1.visible = true; + if (Intra.is_ios) { + //text_1.setText("Save\nSave and go\n to title\nGo to title", true, 0, 0, "left", true) + text_1.setText(DH.lk("save",0)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",4), true, 0, 0, "left", true) + } else { + //text_1.setText("Save\nSave and go\n to title\nSave and quit\nQuit game", true, 0, 0, "left", true); + text_1.setText(DH.lk("save",0)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",5)+"\n"+DH.lk("save",6), true, 0, 0, "left", true); + } + //text_1.text += "\n\n\n\nDeaths: " + Registry.death_count.toString(); + text_1.text += "\n\n\n\n"+DH.lk("save",7)+" " + Registry.death_count.toString(); + + text_1.x = 69; + text_1.y = 30; + text_2.visible = text_3.visible = false; + break; + case 4: //settings + text_1.visible = text_3.visible = true; + //var autosave_state:String = Registry.autosave_on ? "On" : "Off"; + var autosave_state:String = Registry.autosave_on ? DH.lk("config",4) : DH.lk("config",5); + set_settings_text(true); + text_1.x = 68; + text_1.y = 30; + text_2.visible = false; + text_3.x = 68; + text_3.y = 120; + if (DH.isZH()) text_3.y = 125; + if (Intra.is_mobile) text_3.visible = false; + text_3.setText(DH.lk("config",16)+" " + Intra.scale_factor.toString() + "x",true,0,0,"left",true); + + remove(volume_bar_bg, true); add(volume_bar_bg); + remove(volume_bar, true); add(volume_bar); + remove(volume_bar_overlay, true); add(volume_bar_overlay); + remove(window_config, true); add(window_config); + remove(window_words, true); add(window_words); + break; + case 5: // SECRETS!!! + text_1.visible = text_2.visible = text_3.visible = false; + remove(trophies, true); add(trophies); + remove(selectors, true); add(selectors); + break; + case 6: // CHEATS!!! + break; + } + } + + if (Registry.keywatch.JP_DOWN) { + if (base_index < max_base_index) { + current_substate_visible = false; + base_index++; + secret_counter = 0; + menu_select_active.y += 16; + menu_select_inactive.y = menu_select_active.y; + } else { + if (base_index == 4 && Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + current_substate_visible = false; + menu_select_active.y += 16; + menu_select_inactive.y = menu_select_active.y; + base_index++; + } else { + secret_counter++; + if (secret_counter > 20 && base_index != 6) { + current_substate_visible = false; + if (base_index == 4) { + menu_select_active.y += 32; + } else { + menu_select_active.y += 16; + } + menu_select_inactive.y = menu_select_active.y; + base_index = 6; + } + } + } + return; + } else if (Registry.keywatch.JP_UP) { + if (base_index > 0) { + current_substate_visible = false; + if (base_index == 6 && false == Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + base_index = 4; + menu_select_active.y -= 32; + } else { + base_index--; + menu_select_active.y -= 16; + } + menu_select_inactive.y = menu_select_active.y; + } + return; + } + + /* State change to submenus, also change cursor animations and positions */ + if (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_RIGHT) { + menu_select_active.visible = false; + menu_select_inactive.visible = true; + + switch (base_index) { + case 0: + + if (Registry.GE_States[Registry.GE_ENTERED_NEXUS_ONCE] == false || is_crowd_minidungeon()) { + menu_select_active.visible = true; + menu_select_inactive.visible = false; + break; + } + state = s_map; + selectors.members[1].scale.x = 1; + selectors.members[2].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = 70; + selectors.members[1].y = 135; + if (DH.isZH()) selectors.members[1].y = 142; + + selectors.members[1].play("enabled"); + map_cursor_idx = 1; + break; + case 1: + // If no items, equip submenu is inacessible. + if (!equip_icon.visible) { + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } else { + state = s_equip; + equip_cursor_idx = 0; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = 80; + selectors.members[1].y = 30; + selectors.members[1].play("enabled"); + } + break; + case 2: + + //selectors.members[1].visible = selectors.members[2].visible = true; + selectors.members[1].x = text_1.x - 7; + selectors.members[1].y = text_1.y; + selectors.members[2].x = text_1.x + text_1.width; + selectors.members[2].y = text_1.y; + if (DH.isZH()) selectors.members[1].y += 4; + if (DH.isZH()) selectors.members[2].y += 4; + selectors.members[1].play("enabled"); + selectors.members[2].play("enabled"); + selectors.members[1].scale.x = -1; + selectors.members[2].scale.x = 1; + + + cards_cursor_idx = 0; + state = s_cards; + card_pg_to_cards(); + break; + case 3: + state = s_save; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = text_1.x - 8; + selectors.members[1].y = text_1.y; + selectors.members[1].play("enabled"); + save_cursor_idx = 0; + break; + case 4: + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = text_1.x - 7; + selectors.members[1].y = text_1.y; + selectors.members[1].play("enabled"); + settings_cursor_idx = 0; + state = s_settings; + break; + case 5: + //secretsx + state = s_secretz; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = trophies.members[0].x - 7; + selectors.members[1].y = trophies.members[0].y + 4; + selectors.members[1].play("enabled"); + secretz_idx = 0; + break; + case 6: //cheatsz + state = s_cheatz; + break; + } + } + + + + } + + + + private function map_logic():void { + + // Cancel + if (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_LEFT) { + // Return to browse, or + if (map_ctr == 0) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + selectors.members[2].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + map_cursor_idx = 1; + // Return to top-level of map submenu + } else if (!Registry.keywatch.JP_LEFT) { + selectors.members[2].visible = false; + selectors.members[1].play("enabled"); + map_cursor_idx = 1; + map_ctr = 0; + } + } + + // Select + if (Registry.keywatch.JP_ACTION_1) { + switch (map_ctr) { + // Go to yes/no context for return to entrance + case 0: + selectors.members[2].visible = true; + selectors.members[2].play("enabled"); + selectors.members[1].play("disabled"); + selectors.members[2].x = text_3.x - 6 + 45; + selectors.members[2].y = text_3.y; + text_3.visible = true; + map_ctr++; + + break; + // Eitehr go back, or switch maps + case 1: + if (map_cursor_idx == 0) { + // switch state + Registry.cleanup_on_map_change(); + if (false == Registry.is_dungeon(Registry.CURRENT_MAP_NAME)) { // If not in a dungeon want 2 warp to nexus + if (Registry.CURRENT_MAP_NAME == "BLANK" || Registry.CURRENT_MAP_NAME == "DRAWER" || Registry.CURRENT_MAP_NAME == "NEXUS") { + Registry.NEXT_MAP_NAME = "NEXUS"; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["NEXUS"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["NEXUS"].y; + } else { + NPC.load_nexus_data(); + } + } else { + Registry.NEXT_MAP_NAME = Registry.CURRENT_MAP_NAME; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES[Registry.CURRENT_MAP_NAME].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES[Registry.CURRENT_MAP_NAME].y; + } + //FlxG.switchState(new PlayState); + Registry.BOI = false; + parent.SWITCH_MAPS = true; + Registry.sound_data.start_song_from_title(Registry.NEXT_MAP_NAME); + reset_counters(); + done = true; + } else { + selectors.members[1].play("enabled"); + selectors.members[2].visible = false; + map_cursor_idx = 1; + map_ctr = 0; + } + break; + } + } + + // Deal with/left right for yes/no context + if (map_ctr == 1) { + if (Registry.keywatch.JP_RIGHT && map_cursor_idx < 1) { + map_cursor_idx++; + selectors.members[2].x += 47; + } else if (Registry.keywatch.JP_LEFT && map_cursor_idx > 0) { + map_cursor_idx--; + selectors.members[2].x -= 47; + } + } + } + private function equip_logic():void { + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && equip_cursor_idx <= 10)) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + if (Registry.keywatch.JP_DOWN) { + if (equip_cursor_idx < 3) { + equip_cursor_idx++; + selectors.members[1].y += 24; + } else if (equip_cursor_idx == 3) { + equip_cursor_idx = 10; + + if (Registry.inventory[Registry.IDX_JUMP]) { + selectors.members[1].y = jump_shoes.y; + selectors.members[1].x = jump_shoes.x - 3; + } else if (Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX]) { + selectors.members[1].y = trade_item.y; + selectors.members[1].x = trade_item.x - 3; + equip_cursor_idx = 11; + } else { + selectors.members[1].y = key_icons.members[0].y; + selectors.members[1].x = key_icons.members[0].x - 3; + equip_cursor_idx = 12; + } + + } + } else if (Registry.keywatch.JP_UP) { + if (equip_cursor_idx > 0) { + if (equip_cursor_idx >= 10) { + selectors.members[1].y = 102; + selectors.members[1].x = 80; + equip_cursor_idx = 3; + } else { + equip_cursor_idx--; + selectors.members[1].y -= 24; + } + } + } + + if (Registry.keywatch.JP_RIGHT) { + if (equip_cursor_idx < 14) { + if (equip_cursor_idx == 10) { + if (!(Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX])) { + equip_cursor_idx = 12; + } else { + equip_cursor_idx = 11; + } + } else { + equip_cursor_idx++; + } + } + // oh my goddd + } else if (Registry.keywatch.JP_LEFT) { + if (equip_cursor_idx > 10) { + if (equip_cursor_idx == 11) { + if (Registry.inventory[Registry.IDX_JUMP]) { + equip_cursor_idx = 10; + } + } else { + if (equip_cursor_idx == 12) { + if ((Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX])) { + equip_cursor_idx = 11; + } else if (Registry.inventory[Registry.IDX_JUMP]) { + equip_cursor_idx = 10; + } + } else { + equip_cursor_idx--; + } + } + } + } + + if (Registry.keywatch.JP_LEFT || Registry.keywatch.JP_RIGHT) { + if (equip_cursor_idx == 10) { + selectors.members[1].y = jump_shoes.y; + selectors.members[1].x = jump_shoes.x - 3; + } else if (equip_cursor_idx == 11) { + selectors.members[1].y = trade_item.y; + selectors.members[1].x = trade_item.x - 3; + } else if (equip_cursor_idx > 11) { + selectors.members[1].y = key_icons.members[equip_cursor_idx - 12].y; + selectors.members[1].x = key_icons.members[equip_cursor_idx - 12].x - 3; + } + } + + if (Registry.keywatch.JP_ACTION_1) { + + switch(equip_cursor_idx) { + case 0: + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + set_passive_effect(Registry.IDX_BROOM); + + equip_icon.y = equip_boxes.members[0].y - 1; + break; + case 1: + if (Registry.inventory[Registry.IDX_LENGTHEN]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + if (Registry.bound_effect != Registry.item_names[Registry.IDX_LENGTHEN]) { + set_passive_effect(Registry.IDX_LENGTHEN); + } + equip_icon.y = equip_boxes.members[0].y - 1 + 24; + } + break; + case 2: + if (Registry.inventory[Registry.IDX_WIDEN]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + if (Registry.bound_effect != Registry.item_names[Registry.IDX_WIDEN]) { + set_passive_effect(Registry.IDX_WIDEN); + } + equip_icon.y = equip_boxes.members[0].y - 1 + 24*2; + } + break; + case 3: + if (Registry.inventory[Registry.IDX_TRANSFORMER]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_TRANSFORMER]; + set_passive_effect(Registry.IDX_BROOM); // Remove the passive effect + equip_icon.y = equip_boxes.members[0].y - 1 + 24*3; + } + break; + case 10: + //DH.dialogue_popup("A pair of spring-loaded shoes - press "+Registry.controls[Keys.IDX_ACTION_2]+" to jump!"); + DH.dialogue_popup(DH.lk("items",5)+" "+Registry.controls[Keys.IDX_ACTION_2]+" "+DH.lk("items",6)); + break; + case 11: + if (Registry.inventory[Registry.IDX_BIKE_SHOES]) { + //DH.dialogue_popup("A pair of shoes for biking."); + DH.dialogue_popup(DH.lk("items",7)); + } else { + //DH.dialogue_popup("An empty cardboard box."); + DH.dialogue_popup(DH.lk("items",8)); + } + break; + case 12: + if (Registry.inventory[Registry.IDX_GREEN_KEY]) + //DH.dialogue_popup("A key found in the Temple of the Seeing One."); + DH.dialogue_popup(DH.lk("items",9)); + break; + case 13: + if (Registry.inventory[Registry.IDX_RED_KEY]) + //DH.dialogue_popup("A key found in a red, underground cave."); + DH.dialogue_popup(DH.lk("items",10)); + break; + case 14: + if (Registry.inventory[Registry.IDX_BLUE_KEY]) + //DH.dialogue_popup("A key found in a mountain cave."); + DH.dialogue_popup(DH.lk("items",11)); + break; + } + + if (equip_cursor_idx < 4) { + if (Registry.bound_item_1 == "TRANSFORMER" || Registry.bound_item_2 == "TRANSFORMER") { + Registry.E_Transformer_On = true; + } else { + Registry.E_Transformer_Off = true; + } + + + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + current_substate_visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + //set_placeholder_image(1); + } + + } + + // The locations of the cards, so we can map them to proper images when opening a chest. + // Dungeon x/y vals are the room, roamstates are the actual coordinates in DAME-coords (so no y-offset of 20) + public static var card_data:Object = { + "BLANK": new Array( { id: 44, x: 5, y: 1 } ), + "DRAWER": new Array( {id: 36, x:2, y:1}, {id: 37, x:4, y:7}), + "OVERWORLD": new Array( { id: 0, x:1, y:9 } , {id: 1, x:5, y:7} ), + "BEDROOM": new Array( { id: 2, x: 3, y: 0 }, { id:3, x:1, y:0 }, { id:4, x:2, y:3 }, { id:5, x:5, y:0 } ), + "SUBURB": new Array( { id : 6 , x: 1, y:7 } , {id: 42, x:2 , y:7}), + "APARTMENT": new Array( { id: 7, x : 8, y : 7 }, { id: 8, x:3, y:5 }, { id:9, x:0, y:0 } ) , + "FIELDS": new Array( { id: 10, x :3, y: 8}, {id : 11, x : 6, y: 9}, {id: 43, x: 8, y : 0}, {id: 45,x:11,y:9}), + "WINDMILL": new Array( {id: 12, x: 1, y:5} ), + "FOREST" :new Array( {id: 13, x:3, y:2}), + "CLIFF": new Array( { id: 14, x:4, y:2 }, { id: 15, x: 2, y:7}), + "BEACH": new Array( { id: 16, x:4, y:3 } ) , + "REDSEA": new Array( { id: 17, x:2, y:2}, {id: 47, x:0,y:6} ), + "REDCAVE": new Array( { id: 18, x:3 , y :1 } , { id : 19, x:0, y:0 }, { id: 20, x:6, y:1 } ), + "TRAIN" : new Array( { id: 21, x: 0 , y:0 } , {id: 40, x:5, y : 8}), // CELL + "CIRCUS" : new Array( { id: 23, x: 0 , y : 3 }, { id : 22, x:3, y:6 } , { id : 24, x: 3, y:2 }, { id:25, x: 7, y: 0 } ), + "CROWD" : new Array( {id : 26, x:2 , y: 2} , {id: 27, x: 8, y: 2} , {id: 28 , x:9, y:5 }), + "SPACE" : new Array ( { id: 29, x:0, y:0} , {id: 30, x:9,y:0}, {id:41, x:5, y:7}), + "HOTEL": new Array( { id: 31, x:3, y:6 }, { id:32, x:1, y:8 }, { id:33, x:9, y:3 } , { id:34, x:8, y:11 } , {id:38, x:5, y:0}), + "TERMINAL" : new Array ( { id: 35, x: 4, y:2 } ), + "DEBUG" : new Array( { id: 39, x:4, y:3 } ), + "STREET": new Array( {id:46, x:1, y:6}) + + }; + + private function cards_logic():void { + + // Exit card select, or exit card submenu + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && cur_cards_pg == 0 && (cards_cursor_idx % 3 == 0))) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[3].visible = false; + selectors.members[1].visible = selectors.members[2].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + //cur_cards_pg = 0; + //cards_cursor_idx = 0; + } + + + + // Move about card select, or move between pages + if (selectors.members[3].visible) { //if card select + if ((cards_cursor_idx % 12) > 2 && Registry.keywatch.JP_UP) { + cards_cursor_idx -= 3; + selectors.members[3].y -= 29; + } else if ((cards_cursor_idx % 12) < 9 && Registry.keywatch.JP_DOWN) { + cards_cursor_idx += 3; + selectors.members[3].y += 29; + } else if (Registry.keywatch.JP_DOWN) { + selectors.members[3].visible = false; + selectors.members[1].visible = true; + selectors.members[2].visible = true; + selectors.members[1].play("enabled"); + selectors.members[2].play("enabled"); + } + + if ((cards_cursor_idx % 3) < 2 && Registry.keywatch.JP_RIGHT) { + cards_cursor_idx ++; + selectors.members[3].x += 30; + } else if ((cards_cursor_idx % 3) > 0 && Registry.keywatch.JP_LEFT) { + cards_cursor_idx --; + selectors.members[3].x -= 30; + } else if ((cards_cursor_idx % 3) == 0 && Registry.keywatch.JP_LEFT) { + if (cur_cards_pg > 0) { + cur_cards_pg --; + cards_cursor_idx += 2; + selectors.members[3].x += 60; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4"; + } else { + text_1.text = "1/4"; + } + } + } else if ((cards_cursor_idx % 3) == 2 && Registry.keywatch.JP_RIGHT) { + if (cur_cards_pg < 3) { + cur_cards_pg ++; + cards_cursor_idx -= 2; + selectors.members[3].x -= 60; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4" + } else { + text_1.text = "4/4"; + } + } + } + } else { + if (cur_cards_pg < 3 && Registry.keywatch.JP_RIGHT) { + cur_cards_pg++; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4" + } else { + text_1.text = "4/4"; + } + //Load new sprites.... + } else if (cur_cards_pg > 0 && Registry.keywatch.JP_LEFT) { + cur_cards_pg--; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4"; + } else { + text_1.text = "1/4"; + } + //load new sprites... + } + if (Registry.keywatch.JP_UP) { + card_pg_to_cards(); + } + } + + // Go to card select or do something with a single card + if (Registry.keywatch.JP_ACTION_1) { + if (selectors.members[3].visible) { + var idx:int = cards_cursor_idx + cur_cards_pg * 12; + if (Registry.card_states[idx]) { + DH.start_dialogue(DH.name_card, DH.scene_card_one, DH.area_etc, idx); + } + // Do something + } else { // Go to card select + card_pg_to_cards(); + } + } + } + private function save_logic():void { + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + var spacin:int = 8; + if (DH.isZH()) spacin = 12; + if (Registry.keywatch.JP_DOWN) { + if (save_cursor_idx < 3) { + if (Intra.is_ios && save_cursor_idx == 2) { + return; + } + save_cursor_idx++; + if (save_cursor_idx == 2) { + selectors.members[1].y += spacin*2; + } else { + selectors.members[1].y += spacin; + } + } + } else if (Registry.keywatch.JP_UP) { + if (save_cursor_idx > 0) { + save_cursor_idx--; + if (save_cursor_idx == 1) { + selectors.members[1].y -= spacin*2; + } else { + selectors.members[1].y -= spacin; + } + } + } + + if (Registry.keywatch.JP_ACTION_1) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + switch (save_cursor_idx) { + case 0: + if (Save.save()) { + if (Intra.is_ios) { + text_1.setText(DH.lk("save",1)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",4), true, 0, 0, "left", true) + } else { + text_1.setText(DH.lk("save",1)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",5)+"\n"+DH.lk("save",6), true, 0, 0, "left", true); + } + text_1.text += "\n\n\n\n"+DH.lk("save",7)+" " + Registry.death_count.toString(); + } else { + if (Intra.is_ios) { + text_1.setText(DH.lk("save",2)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",4), true, 0, 0, "left", true) + } else { + text_1.setText(DH.lk("save",2)+"\n"+DH.lk("save",3)+"\n"+DH.lk("save",5)+"\n"+DH.lk("save",6), true, 0, 0, "left", true); + } + text_1.text += "\n\n\n\n"+DH.lk("save",7)+" " + Registry.death_count.toString(); + } + break; + case 1: + Registry.cleanup_on_map_change(); + Registry.sound_data.stop_current_song(); + Save.save(); + FlxG.switchState(new TitleState); + break; + case 2: + if (Intra.is_ios) { + Registry.cleanup_on_map_change(); + Registry.sound_data.stop_current_song(); + FlxG.switchState(new TitleState); + } else { + Save.save(); + if (Intra.IS_WINDOWS && Main.joy != null) { + Main.joy.kill(); + } + //if (Intra.is_ios) { + //Intra.intraintra.dispatchEvent(new Event(Event.DEACTIVATE,true)); + //} else { + NativeApplication.nativeApplication.exit(); + } + break; + case 3: + if (Intra.IS_WINDOWS && Main.joy != null) { + Main.joy.kill(); + } + NativeApplication.nativeApplication.exit(); + + break; + + } + } + + } + + private var entered_lang:String; + private function settings_logic():void { + + if (ctr_settings == 0) { + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && !selectors.members[2].visible)) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + if (Registry.keywatch.JP_DOWN) { + if (settings_cursor_idx < 6) { + settings_cursor_idx ++; + if (settings_cursor_idx == 2) { + selectors.members[1].y += 24; + } else if (settings_cursor_idx == 3) { + selectors.members[1].y += 32; + } else if (settings_cursor_idx == 4) { + selectors.members[1].y += 16; + if (DH.isZH()) selectors.members[1].y += 8; + //if (Intra.is_ios) { + //settings_cursor_idx = 3; + //} else if (Intra.is_mobile) { + //settings_cursor_idx = 6; + //selectors.members[1].y += 48; + //} + } else if (settings_cursor_idx == 5) { + selectors.members[1].y += 16; + } else if (settings_cursor_idx == 6) { + if (Intra.is_mobile) { + settings_cursor_idx --; + } else { + selectors.members[1].y += 8; + } + } else if (settings_cursor_idx == 7) { + settings_cursor_idx = 6; + } else { + selectors.members[1].y += 16; + } + } + } else if (Registry.keywatch.JP_UP) { + if (settings_cursor_idx > 0) { + settings_cursor_idx -- ; + if (settings_cursor_idx == 1) { + selectors.members[1].y -= 24; + } else if (settings_cursor_idx == 2) { + selectors.members[1].y -= 32; + } else if (settings_cursor_idx == 3) { + selectors.members[1].y -= 16; + if (DH.isZH()) selectors.members[1].y -= 8; + } else if (settings_cursor_idx == 4) { + selectors.members[1].y -= 16; + } else if (settings_cursor_idx == 5) { + selectors.members[1].y -= 8; + } else { + selectors.members[1].y -= 16; + } + } + } + + if (Registry.keywatch.JP_ACTION_1) { + if (settings_cursor_idx == 0) { + // Goto controls + if (!Intra.is_mobile) { + ctr_settings = 1; + controls_state.change_text(); + controls_state.push(this); + } else { + /* CONFIGURE UI */ + ctr_settings = 1; + volume_bar.visible = false; + selectors.members[1].visible = false; + volume_bar_bg.visible = false; + volume_bar_overlay.visible = false; + + //text_1.text = "Drag the\nbuttons\nuntil you're\nsatisfied.\n\nThen, tap\nthe menu\nto continue.\n\n"; + text_1.text = DH.lk("config",20); + //var gam:Intra = FlxG._game as Intra; + //gam.mobile_flip_x_c(); + } + } else if (settings_cursor_idx == 1) { // goto volume + ctr_settings = 2; + selectors.members[1].play("disabled"); + selectors.members[2].play("enabled"); + selectors.members[3].play("enabled"); + selectors.members[2].visible = selectors.members[3].visible = true; + selectors.members[2].scale.x = -1; + selectors.members[2].x = selectors.members[1].x; selectors.members[2].y = 58; + selectors.members[3].x = 138; selectors.members[3].y = 58; + + } else if (settings_cursor_idx == 2) { + Registry.autosave_on = !Registry.autosave_on; + set_settings_text(true); + + } else if (settings_cursor_idx == 3) { // Change resize type + if (!Intra.is_mobile) { + Intra.force_scale = true; + } else { + resize_mobile(); + } + set_settings_text(); + + } else if (settings_cursor_idx == 4) { // Change integer scaling + if (Intra.is_mobile) { + // dpad + touch, dpad, touch + var intra_ref:Intra = FlxG._game as Intra; + if (Intra.allow_dpad_move && Intra.allow_game_move) { + Intra.allow_dpad_move = true; + Intra.allow_game_move = false; + } else if (Intra.allow_dpad_move) { + //intra_ref.turn_on_touch_only_listeners(true); + Intra.allow_game_move = true; + Intra.allow_dpad_move = false; + } else if (Intra.allow_game_move) { + //intra_ref.turn_on_touch_only_listeners(false); + Intra.allow_dpad_move = true; + } + set_settings_text(); + } else { + ctr_settings = 3; + selectors.members[1].play("disabled"); + selectors.members[2].play("enabled"); + selectors.members[3].play("enabled"); + selectors.members[1].visible = false; + selectors.members[2].visible = selectors.members[3].visible = true; + selectors.members[2].scale.x = -1; + selectors.members[2].x = selectors.members[1].x + 58; selectors.members[2].y = 120; + selectors.members[3].x = 147; selectors.members[3].y = 120; + } + + } else if (settings_cursor_idx == 5) { //window size config + //if (Intra.is_mobile) { + //var _gam:Intra = FlxG._game as Intra; + //_gam.mobile_flip_handedness(); + //} else if (false == Intra.is_web) { + //ctr_settings = 4; + //Intra.scale_factor = 3; + //Intra.force_scale = true; + //window_words.visible = window_config.visible = true; + //} + + ctr_settings = 24; + entered_lang = DH.language_type; + selectors.members[1].play("disabled"); + selectors.members[2].play("enabled"); + selectors.members[3].play("enabled"); + selectors.members[1].visible = false; + selectors.members[2].visible = selectors.members[3].visible = true; + selectors.members[2].scale.x = -1; + selectors.members[2].x = selectors.members[1].x + 61; selectors.members[2].y = 136; + selectors.members[3].x = 153; selectors.members[3].y = 136; + + if (DH.LANG_ja == DH.language_type || DH.language_type == DH.LANG_ko) { + selectors.members[2].x -= 8 * 4; + selectors.members[3].x -= 8 * 4; + } + if (DH.LANG_pt == DH.language_type || DH.language_type == DH.LANG_es) { + selectors.members[2].x -= 8 * 2; + selectors.members[3].x -= 8 * 2; + } + + } else if (settings_cursor_idx == 6) { + if (Intra.is_air && !Intra.is_mobile) { + if (Intra.IS_WINDOWS && Main.joy.getTotal() > 0) { + trace("JOYPAD DETECTED!"); + Keys.has_joypad = true; + Keys.init_joypad(); + Main.joy.exists = true; + + if (Registry.joy_grp == null) { + Registry.joy_grp = new Joypad_Config_Group(); + } + add(Registry.joy_grp); + ctr_settings = 5; + } else if (Intra.IS_MAC && Main.mac_joy_manager != null && Main.mac_joy_manager.numberOfJoysticks() > 0 && Main.mac_joy_manager.joysticks[0] != null) { + trace("JOYPAD DETECTED!"); + Keys.has_joypad = true; + Keys.init_joypad(); + Main.macmanexists = true; + if (Registry.joy_grp == null) { + Registry.joy_grp = new Joypad_Config_Group(); + } + add(Registry.joy_grp); + ctr_settings = 5; + } else { + trace("NO JOYPAD DETECTED!"); + Registry.sound_data.player_hit_1.play(); + if (Intra.IS_WINDOWS) { + Main.joy.exists = false; + } else if (Intra.IS_MAC) { + Main.macmanexists = false; + } + } + + } else if (Intra.is_mobile && !Intra.is_ios) { + // Configure controller + Registry.sound_data.player_hit_1.play(); + } + } + } + } else if (ctr_settings == 1) { //controls + + if (Intra.is_mobile) { + + if (MobileConfig.update()) { + ctr_settings = 0; + set_settings_text(false); + volume_bar.visible = true; + selectors.members[1].visible = true; + volume_bar_bg.visible = true; + volume_bar_overlay.visible = true; + } + return; + } + + + controls_state.update(); + if (!controls_state.updating && (Registry.keywatch.JUST_PRESSED_PAUSE || FlxG.keys.justPressed("ESCAPE")) ) { + controls_state.pop(this); + ctr_settings = 0; + text_info.text = Registry.controls[Keys.IDX_ACTION_1] + DH.lk("secrets",13) + Registry.controls[Keys.IDX_ACTION_2] + DH.lk("secrets",14); + } + } else if (ctr_settings == 2) { //volume + if (Registry.keywatch.JP_ACTION_2) { + selectors.members[1].play("enabled"); + ctr_settings = 0; + selectors.members[2].visible = selectors.members[3].visible = false; + selectors.members[2].scale.x = 1; + } + + if (Registry.keywatch.JP_LEFT) { + FlxG.volume > 0 ? FlxG.volume -= 0.1 : 1; + } else if (Registry.keywatch.JP_RIGHT) { + FlxG.volume < 1 ? FlxG.volume += 0.1 : 1; + } + + + //text_2.setText(int(FlxG.volume * 10).toString()); + volume_bar.scale.x = int(FlxG.volume * 30); + volume_bar.x = volume_bar_overlay.x + volume_bar.scale.x -1; + } else if (ctr_settings == 3) { // Integer scaling + if (Registry.keywatch.JP_ACTION_2) { + selectors.members[1].play("enabled"); + ctr_settings = 0; + selectors.members[1].visible = true + selectors.members[2].visible = selectors.members[3].visible = false; + selectors.members[2].scale.x = 1; + } + + + text_3.setText(DH.lk("config",16) + " "+Intra.scale_factor.toString() + "x",true,0,0,"left",true); + + if (Registry.keywatch.JP_LEFT) { + if (Intra.scale_factor > 1) { + Intra.scale_factor--; + Intra.scale_ctr = (Intra.scale_ctr - 1) % 3; + Intra.force_scale = true; + } + } else if (Registry.keywatch.JP_RIGHT) { + // See if we can scale further + var ratio:Number = (Intra.scale_factor + 1 ) / 3; + if (FlxG._game.stage.fullScreenHeight < ratio * 540*0.4 || FlxG._game.stage.fullScreenWidth < ratio * 480*0.4) { + + }else if (Intra.scale_factor < 8) { + Intra.scale_factor++; + Intra.scale_ctr = (Intra.scale_ctr - 1) % 3; // Display style should stay the same + Intra.force_scale = true; + } + } + } else if (ctr_settings == 4) { + TitleState.window_config_logic(Registry.keywatch); + if (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_ACTION_1) { + ctr_settings = 0; + window_words.visible = window_config.visible = false; + } + } else if (ctr_settings == 5) { // Joypad + if (Registry.joy_grp.is_done()) { + remove(Registry.joy_grp, true); + ctr_settings = 0; + } + } else if (ctr_settings == 24) { //language + + if (Registry.keywatch.JP_ACTION_1) { + if (entered_lang != DH.language_type) { + DH.set_language(DH.language_type); + entered_lang = DH.language_type; + Registry.keywatch.JP_ACTION_2 = true; + } + } + if (Registry.keywatch.JP_ACTION_2) { + if (DH.language_type != entered_lang) { + DH.language_type = entered_lang; + } + + + set_settings_text(false); + + text_3.setText(DH.lk("config", 16) + " " + Intra.scale_factor.toString() + "x", true, 0, 0, "left", true); + + text_3.x = 68; + text_3.y = 120; + if (DH.isZH()) text_3.y = 125; + if (Intra.is_mobile) text_3.visible = false; + text_1.x = 68; + text_1.y = 30; + selectors.members[1].play("enabled"); + ctr_settings = 0; + selectors.members[1].visible = true; + selectors.members[2].visible = selectors.members[3].visible = false; + selectors.members[2].scale.x = 1; + } + // [en,ja,ko,es,pt-br,it,zhs] + if (Registry.keywatch.JP_RIGHT) { + if (DH.language_type == DH.LANG_en) { + DH.language_type = DH.LANG_ja; + } else if (DH.language_type == DH.LANG_ja) { + DH.language_type = DH.LANG_ko; + } else if (DH.language_type == DH.LANG_ko) { + DH.language_type = DH.LANG_es; + } else if (DH.language_type == DH.LANG_es) { + DH.language_type = DH.LANG_pt; + } else if (DH.language_type == DH.LANG_pt) { + DH.language_type = DH.LANG_it; + } else if (DH.language_type == DH.LANG_it) { + DH.language_type = DH.LANG_zhs; + } else { + DH.language_type = DH.LANG_en; + } + set_settings_text(false,entered_lang); + } else if (Registry.keywatch.JP_LEFT) { + if (DH.language_type == DH.LANG_ja) { + DH.language_type = DH.LANG_en; + } else if (DH.language_type == DH.LANG_en) { + DH.language_type = DH.LANG_zhs; + } else if (DH.language_type == DH.LANG_zhs) { + DH.language_type = DH.LANG_it; + } else if (DH.language_type == DH.LANG_it) { + DH.language_type = DH.LANG_pt; + } else if (DH.language_type == DH.LANG_pt) { + DH.language_type = DH.LANG_es; + } else if (DH.language_type == DH.LANG_es) { + DH.language_type = DH.LANG_ko; + } else { + DH.language_type = DH.LANG_ja; + } + set_settings_text(false,entered_lang); + } + } + } + + private function cheatz_logic():void { + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + text_1.visible = true; + text_1.x = 64; + text_1.y = 50; + + + if (text_1.text.length < 11) { + if (Registry.keywatch.JP_DOWN) { + text_1.text += "D"; + } else if (Registry.keywatch.JP_RIGHT) { + text_1.text += "R"; + } else if (Registry.keywatch.JP_UP) { + text_1.text += "U"; + } else if (Registry.keywatch.JP_LEFT) { + text_1.text += "L"; + } else if (Registry.keywatch.JP_ACTION_1) { + text_1.text += "1"; + } else if (Registry.keywatch.JP_ACTION_2) { + text_1.text += "2"; + } + + + } else { + switch (text_1.text) { + case " UUDDLRLR21": + Registry.sound_data.get_key.play(); + Registry.GAMESTATE.player.health_bar.modify_health(20); + Registry.inventory[Registry.IDX_JUMP] = true; + Registry.inventory[Registry.IDX_BROOM] = true; + Registry.inventory[Registry.IDX_TRANSFORMER] = true; + Achievements.unlock_all(); + Registry.bound_item_1 = "BROOM"; + Registry.bound_item_2 = "JUMP"; + for (var ij:int = 0; ij < 24; ij++) { + Registry.inventory[ij] = true; + Registry.card_states[ij] = 1; + } + Registry.GE_States[Registry.GE_HAVE_A_SECRET] = true; + + + break; + case " URDLURDLUR": + Registry.sound_data.shieldy_hit.play(); + Registry.sound_data.small_wave.play(); + Registry.sound_data.big_door_locked.play(); + FlxG.flash(0xffffffff, 3); + FlxG.shake(0.05, 3); + FlxG.scramble_cache(); + break; + case " URLDURLD11": + var p:Player = Registry.GAMESTATE.player; + p.loadGraphic(Player.Cell_Player_Sprite, true, false, 16, 16); + + break; + case " LRLR121212": + Registry.FUCK_IT_MODE_ON = !Registry.FUCK_IT_MODE_ON; + break; + default: + Registry.GAMESTATE.player.health_bar.modify_health( -2); + Registry.sound_data.sb_hurt.play(); + break; + } + text_1.text = " "; + } + + } + + private var secretz_idx:int = 0; + private var secretz_wordz:Array = new Array(); + + private function secretz_logic():void { + + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + secretz_idx = 0; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + selectors.members[1].visible = false; + } + + if (Registry.keywatch.JP_RIGHT && (secretz_idx % 4) < 3) { + selectors.members[1].x += 24; + secretz_idx ++; + } else if (Registry.keywatch.JP_LEFT && (secretz_idx % 4) > 0) { + selectors.members[1].x -= 24; + secretz_idx --; + } + + if (Registry.keywatch.JP_DOWN && int(secretz_idx / 4) < 3) { + selectors.members[1].y += 20; + secretz_idx += 4; + } else if (Registry.keywatch.JP_UP && int(secretz_idx / 4) > 0) { + selectors.members[1].y -= 20; + secretz_idx -= 4; + } + + if (Registry.keywatch.JP_ACTION_1) { + if (trophies.members.length - 1 >= secretz_idx && trophies.members[secretz_idx].visible) { + secretz_wordz = new Array(); + for (var ij:int = 0; ij < 13; ij++) { + secretz_wordz.push(DH.lk("secrets", ij)); + } + + DH.dialogue_popup(secretz_wordz[secretz_idx]); + } + } + } + + private function set_passive_effect(selector_index:int):void + { + var p:* = parent; + if (selector_index == Registry.IDX_WIDEN) { + // bound_effect ripples over to the state of the broom + if (Registry.bound_effect == Registry.item_names[Registry.IDX_WIDEN]) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } else { + Registry.bound_effect = Registry.item_names[Registry.IDX_WIDEN]; + p.player.action_latency_max = Player.WATK_DELAY; + } + } else if (selector_index == Registry.IDX_LENGTHEN) { + // bound_effect ripples over to the state of the broom + if (Registry.bound_effect == Registry.item_names[Registry.IDX_LENGTHEN]) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } else { + Registry.bound_effect = Registry.item_names[Registry.IDX_LENGTHEN]; + p.player.action_latency_max = Player.LATK_DELAY; + } + } else if (selector_index == Registry.IDX_BROOM) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } + } + + private function set_card_images():void + { + for (var card_page_idx:int = 0; card_page_idx < 12; card_page_idx++) { + if (1 == Registry.card_states[card_page_idx + cur_cards_pg * 12]) { + trace(card_page_idx + cur_cards_pg * 12); + cards.members[card_page_idx].frame = card_page_idx + cur_cards_pg * 12; + } else { + cards.members[card_page_idx].frame = 49; + } + } + } + + private function set_key_graphics():void + { + //not working + for (var i:int = 0; i < 3; i++) { + var key:FlxSprite = key_icons.members[i]; + key.loadGraphic(NPC.key_green_embed, true, false, 16, 16); + switch (i) { + case 0: if (Registry.inventory[Registry.IDX_GREEN_KEY]) { + key.frame = 0; + } else { + key.frame = 1; + } + break; + case 1: if (Registry.inventory[Registry.IDX_RED_KEY]) { + key.frame = 2; + } else { + key.frame = 3; + } + break; + case 2: if (Registry.inventory[Registry.IDX_BLUE_KEY]) { + key.frame = 4; + } else { + key.frame = 5; + } + break; + } + } + } + + private function check_for_exit_with(condition:Boolean):void + { + if (condition) { + if (exit_latency < 0) { + done = true; + exit_latency = 0.5; + current_substate_visible = false; + Registry.GAMESTATE.player.no_jump_ticks = 7; + reset_counters(); + menu_select_active.visible = true; + menu_select_inactive.visible = false; + window_words.visible = window_config.visible = false; + } + } else { + if (exit_latency > 0) { + exit_latency -= FlxG.elapsed; + } + } + } + + private function reset_counters():void { + + state = s_browse; + ctr_settings = 0; + map_ctr = 0; + map_cursor_idx = save_cursor_idx = settings_cursor_idx = equip_cursor_idx = equip_cursor_idx = 0; + doing_window_config = false; + + } + + private function dialogue_logic():void + { + Registry.GAMESTATE.dialogue_state.update(); + if (t_d > tm_d) { + if (Registry.GAMESTATE.dialogue_state.is_finished && (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_ACTION_1)) { + t_d = 0; + Registry.GAMESTATE.dialogue_state.reset(); + if (equip_cursor_idx >= 10) { + state = s_equip; + } else if (base_index == 5) { + state = s_secretz; + } else { + state = s_cards; // mayneed to change later + } + Registry.GAMESTATE.dialogue_state.pop(this as FlxState); + DH.dont_need_recently_finished(); + } + } else { + t_d += FlxG.elapsed; + } + } + private function resize_mobile():void { + switch (Intra.scale_ctr) { + case Intra.SCALE_TYPE_FIT: + Intra.scale_ctr = Intra.SCALE_TYPE_INT; + break; + case Intra.SCALE_TYPE_INT: + default: + Intra.scale_ctr = Intra.SCALE_TYPE_FIT; + break; + } + var i:Intra = FlxG._game as Intra; + i.resize_mobile_game(); + + } + private function get_resolution_string(is_init:Boolean=false):String { + + if (Intra.is_mobile) { + switch (Intra.scale_ctr) { + case Intra.SCALE_TYPE_FIT: + res = DH.lk("config",15); + break; + case Intra.SCALE_TYPE_INT: + default: + res = DH.lk("config",14); + break; + } + return res; + } + if (is_init) { + Intra.scale_ctr--; + } + var res:String = DH.lk("config",13); + switch (Intra.scale_ctr) { + case 1: + res = DH.lk("config",14); + break; + case 2: + res = DH.lk("config",15); + break; + case 0: + res = DH.lk("config",13); + break; + } + if (is_init) { + Intra.scale_ctr++; + } + return res; + } + private function set_settings_text(is_init:Boolean = false, enteredlang:String = ""):void { + if (enteredlang == "") enteredlang = DH.language_type; + var autosave_state:String = Registry.autosave_on ? DH.lk("config",4) : DH.lk("config",5); //on off + var first:String = Intra.is_mobile ? DH.lk("config",7) : DH.lk("config",1); //config ui / set keybinds + //var last:String = Intra.is_mobile ? " " : DH.lk("config",21); // " " / resize window + var last:String = Intra.is_mobile ? " " : " "; // " " / resize window + var res:String = Intra.is_mobile ? "\n"+DH.lk("config",6)+"\n " : "\n\n"+DH.lk("config",12)+"\n "; // change res/ resolution + var joypart:String = Intra.is_ios ? " " : DH.lk("config",22); + var langpart:String = DH.lk("config", 17) +" " + String(DH.language_type); + if (DH.LANG_pt == DH.language_type) { + langpart = DH.lk("config", 17) +" " + "pt-BR"; + } + if (entered_lang == DH.LANG_zhs) { + langpart = DH.lk("config", 17) + String(DH.language_type); + langpart = langpart.replace(" ", ""); + } + + if (enteredlang == DH.LANG_ja) { + + langpart = DH.lk("config", 17) +" " + String(DH.language_type); + } + + var movepart:String = ""; + + if (Intra.allow_dpad_move && Intra.allow_game_move) { + //movepart = "Touch+D-Pad"; + movepart = DH.lk("config",8); + } else if (Intra.allow_dpad_move) { + movepart = DH.lk("config",9); + } else if (Intra.allow_game_move) { + movepart = DH.lk("config",10); + } + + if (Intra.is_mobile) { + text_1.setText(first + "\n\n" + DH.lk("config", 2) + "\n\n\n" + DH.lk("config", 3) + "\n " + autosave_state + res + get_resolution_string(is_init) + "\n" + DH.lk("config", 11) + "\n" + movepart + "\n" + langpart, true, 0, 0, "left", true); + if (enteredlang==DH.LANG_zhs) text_1.setText(first + "\n" + DH.lk("config", 2) + "\n\n" + DH.lk("config", 3) + autosave_state + res + get_resolution_string(is_init) + "\n" + DH.lk("config", 11) + "\n" + movepart+"\n"+ langpart, true, 0, 0, "left", true); + } else { + if (is_init) { + text_1.setText(first + "\n\n" + DH.lk("config", 2) + "\n\n\n" + DH.lk("config", 3) + "\n " + autosave_state + res + get_resolution_string(true) + "\n\n\n" + langpart + "\n" + joypart, true, 0, 0, "left", true); + if (enteredlang==DH.LANG_zhs) text_1.setText(first + "\n" + DH.lk("config", 2) + "\n\n" + DH.lk("config", 3) + autosave_state + res + get_resolution_string(true) + "\n\n" + langpart + "\n" + joypart, true, 0, 0, "left", true); + } else { + text_1.setText(first+"\n\n"+DH.lk("config",2)+"\n\n\n"+DH.lk("config",3)+"\n " + autosave_state + res + get_resolution_string()+"\n\n\n"+langpart+"\n"+joypart+"\n"+last, true, 0, 0, "left", true); + if (enteredlang==DH.LANG_zhs) text_1.setText(first + "\n" + DH.lk("config", 2) + "\n\n" + DH.lk("config", 3) + autosave_state + res + get_resolution_string() + "\n\n" + langpart + "\n" + joypart+"\n"+last, true, 0, 0, "left", true); + } + } + + + } + + private function set_trade_item():void { + trade_item.visible = true; + if (Registry.inventory[Registry.IDX_BOX]) { + trade_item.loadGraphic(Trade_NPC.embed_dame_trade_npc, true, false, 16, 16); + trade_item.frame = 31; + } else if (Registry.inventory[Registry.IDX_BIKE_SHOES]) { + trade_item.loadGraphic(Trade_NPC.embed_dame_trade_npc, true, false, 16, 16); + trade_item.frame = 56; + } else { + trade_item.visible = false; + } + } + + private function set_trophy_vis(_trophies:FlxGroup, idx:int):void { + _trophies.members[idx].visible = false; + //_trophies.members[idx].visible = true; + switch (idx) { + case 0: + if (Registry.inventory[Registry.IDX_POO]) _trophies.members[idx].visible = true; + break; + case 1: + if (Registry.inventory[Registry.IDX_SPAM]) _trophies.members[idx].visible = true; + break; + case 2: + if (Registry.inventory[Registry.IDX_MISSINGNO]) _trophies.members[idx].visible = true; + break; + case 3: + if (Registry.inventory[Registry.IDX_AUS_HEART]) _trophies.members[idx].visible = true; + break; + case 4: + if (Registry.inventory[Registry.IDX_ELECTRIC]) _trophies.members[idx].visible = true; + break; + case 5: + if (Registry.inventory[Registry.IDX_KITTY]) _trophies.members[idx].visible = true; + break; + case 6: + if (Registry.inventory[Registry.IDX_MELOS]) _trophies.members[idx].visible = true; + break; + case 7: + if (Registry.inventory[Registry.IDX_MARINA]) _trophies.members[idx].visible = true; + break; + case 8: + if (Registry.inventory[Registry.IDX_BLACK]) _trophies.members[idx].visible = true; + break; + case 9: + if (Registry.inventory[Registry.IDX_RED]) _trophies.members[idx].visible = true; + break; + case 10: + if (Registry.inventory[Registry.IDX_GREEN]) _trophies.members[idx].visible = true; + break; + case 11: + if (Registry.inventory[Registry.IDX_BLUE]) _trophies.members[idx].visible = true; + break; + case 12: + if (Registry.inventory[Registry.IDX_WHITE]) _trophies.members[idx].visible = true; + break; + + + } + } + + private function is_crowd_minidungeon():Boolean { + return (Registry.CURRENT_MAP_NAME == "CROWD" && + ( + (Registry.CURRENT_GRID_X >= 4 && Registry.CURRENT_GRID_X <= 7 && Registry.CURRENT_GRID_Y == 7) || + (Registry.CURRENT_GRID_X == 7 && Registry.CURRENT_GRID_Y == 6) + ) + ); + } + private function card_pg_to_cards():void + { + selectors.members[3].visible = true; + selectors.members[2].visible = false; + selectors.members[1].visible = false; + selectors.members[3].play("enabled"); + selectors.members[2].play("disabled"); + selectors.members[1].play("disabled"); + selectors.members[3].x = cards.members[0].x - 10 + ((cards_cursor_idx % 3) * 30); + selectors.members[3].y = cards.members[0].y + 10 + (int(cards_cursor_idx / 3) * 29); + } + + // do this eventually + public function set_pausemenu_labels():void + { + var idx:int = -1; + var an_string:String = DH.lk("map", 0) + "\n\n" + DH.lk("items", 0) + "\n\n" + DH.lk("cards", 0) + "\n\n" + DH.lk("save", 0) + "\n\n" + DH.lk("config", 0); + if (DH.isZH()) an_string = DH.lk("map", 0) + "\n" + DH.lk("items", 0) + "\n" + DH.lk("cards", 0) + "\n" + DH.lk("save", 0) + "\n" + DH.lk("config", 0); + if (Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + if (DH.isZH()) { + an_string += "\n???"; + } else { + an_string += "\n\n???"; + } + } + + if (text_categories != null) { + idx = base_group.members.indexOf(text_categories); + } + text_categories = EventScripts.init_bitmap_font(an_string, "left", 10, 13 + Registry.HEADER_HEIGHT, null, "apple_white"); + if (DH.isZH()) { + text_categories.y -= 3; + text_categories.customSpacingY += 4; + } + text_categories.color = 0xffffff; + text_categories.drop_shadow = true; + if (idx != -1) { + base_group.members[idx] = text_categories; + } + + idx = -1; + if (text_info != null) idx = base_group.members.indexOf(text_info); + //text_info = EventScripts.init_bitmap_font(Registry.controls[Keys.IDX_ACTION_1] + ":Select " + Registry.controls[Keys.IDX_ACTION_2] + ":Back", "left", 2, 150 + Registry.HEADER_HEIGHT, null, "apple_white"); + text_info = EventScripts.init_bitmap_font(Registry.controls[Keys.IDX_ACTION_1] + DH.lk("secrets",13)+ Registry.controls[Keys.IDX_ACTION_2] + DH.lk("secrets",14), "left", 2, 150 + Registry.HEADER_HEIGHT, null, "apple_white"); + text_info.color = 0x909ab1; + if (idx != -1) base_group.members[idx] = text_info; + + //11323b + idx = -1; + if (text_1 != null) idx = base_group.members.indexOf(text_1); + text_1 = EventScripts.init_bitmap_font(" ", "left", 0, 0, null, "apple_white"); + if (idx != -1) base_group.members[idx] = text_1; + + idx = -1; + if (text_2 != null) idx = base_group.members.indexOf(text_2); + text_2 = EventScripts.init_bitmap_font(" ", "left",0,0,null,"apple_white"); + if (idx != -1) base_group.members[idx] = text_2; + + idx = -1; + if (text_3 != null) idx = base_group.members.indexOf(text_3); + text_3 = EventScripts.init_bitmap_font(" ", "left", 0, 0, null, "apple_white"); + if (idx != -1) base_group.members[idx] = text_3; + + text_1.color = text_2.color = text_3.color = 0xffffff; + text_1.drop_shadow = text_2.drop_shadow = text_3.drop_shadow = true; + } + + } + +} \ No newline at end of file diff --git a/intra/src/states/PlayState.as b/intra/src/states/PlayState.as new file mode 100644 index 0000000..34d95ed --- /dev/null +++ b/intra/src/states/PlayState.as @@ -0,0 +1,2075 @@ +package states +{ + import adobe.utils.CustomActions; + import data.*; + import entity.*; + import entity.decoration.*; + import entity.enemy.hotel.Eye_Boss; + import entity.gadget.*; + import entity.player.*; + import flash.display.BitmapData; + import flash.display.Shader; + import flash.filters.ShaderFilter; + import flash.geom.Point; + import flash.geom.Rectangle; + import flash.utils.ByteArray; + import flash.utils.getTimer; + import global.*; + import helper.*; + import org.flixel.*; + import org.flixel.plugin.photonstorm.*; + import states.*; + + + + + public class PlayState extends FlxState { + + public function PlayState() { + + } + + private var BACK_TEXT_MOBILE:FlxBitmapFont; + // shaders + private var static_shader:Shader = new Shader(new Common_Sprites.static_shader); + private var static_shaderFilter:ShaderFilter; + + private var noScrollPt:FlxPoint; + private var keyWatch:Keys; + public var player:Player; + public var player_group:FlxGroup; + public var last_song_time:Number; // Hacky, used to check if the song has been "stuck" at the end and force a loop + private var t_last_song_pos_checked:Number = 0; + private var ambience:FlxSound = new FlxSound(); + private var has_ambient_sound:Boolean = false; + + + private var stateful_mapXML:XML; + public var stateful_gridXML:XML; + public var statefuls:Array; // The current statefuls being interacted with + private var stateless_mapXML:XML; + private var stateless_gridXML:XML; + public var statelesses:Array; + public var anim_tiles_group:FlxGroup; + + /* movable flat gadgets - dust basically */ + public var intra_bg_bg2_sprites:FlxGroup; + public var bg_sprites:FlxGroup; + public var fg_sprites:FlxGroup;//stuff from ceiling + public var otherObjects:Array; //Holds sub-sprites, like a lser of wall laser + private var oldObjects:Array; // A buffer that holds the next to be loaded.. + private var oldStateless:Array; + private var oldOthers:Array; + public var sortables:FlxGroup; + //BG anim_tiles BG2 flat_tiles sortables etc... + + /* BG */ + [Embed (source = "../res/sprites/decoration/BLANK_BG.png")] public static var BLANK_BG:Class; + public var bg:FlxSprite; //background sprite + public var has_bg:Boolean = false; + public var map:FlxTilemap; + private var mapData:Array; + public var curMapBuf:FlxTilemap; + public var prevMapBuf:FlxTilemap; + public var map_bg_2:FlxTilemap; //on top of the bg map + public var map_fg:FlxTilemap; // on top of all sprites but below darkness + public var SWITCH_MAPS:Boolean = false; + + + /* State vars and associated objects */ + public var state:int; + public var S_NORMAL:int = 0; + public var S_TRANSITION:int = 1; + private var justTransitioned:Boolean = false; + public static var dont_change_songs:Boolean = false; + + public var S_PAUSED:int = 2; + public var pause_state:PauseState; + private var pause_timer:Number = 0.2; + + private var S_PLAYER_DIED:int = 4; + private var death_fadein:FlxSprite; + private var death_text:FlxBitmapFont; + private var played_death_sound:Boolean; + private var start_death_fade_out:Boolean; + + private var S_JUST_ENTERED_MAP:int = 5; + + + private var S_DIRECT_CONTROLS:int = 6; + private var S_CUTSCENE:int = 7; + private var cutscene:Cutscene; + + public var S_DIALOGUE:int = 8; + public var load_dialogue:Boolean = false; + public var dialogue_state:DialogueState; + public var dialogue_latency:Number = 0.3; + + public var S_MINIMAP:int = 9; + + // reset sprites/arrays/etc before leavign + private var cleaned_up_before_exit:Boolean; + + public var upperBorder:int; + public var lowerBorder:int; + public var rightBorder:int; + public var leftBorder:int; + public var Scroll_Increment:int = 4; + + public var debugText:FlxText; + + /* UI/Header entities */ + [Embed (source = "../res/sprites/inventory/header.png")] public static var Header:Class; + [Embed (source = "../res/sprites/menu/autosave_icon.png")] public static var autosave_icon_embed:Class; + public var header_group:FlxGroup; + public var header:FlxSprite; + public var mm_map:Miniminimap; + public var item_placeholder_1:FlxSprite; + public var item_placeholder_2:FlxSprite; + public var number_of_keys_text:FlxBitmapFont; + public var autosave_icon:FlxSprite; + + /* Various graphical effect entities */ + + public var darkness:FlxSprite; + public var darkness_timer:Number = 1.5; + public var black_overlay:FlxSprite; + public var downscale:int = 1; + public var downsample_fade:ScreenFade; + public var upsample_fade:ScreenFade; + public var dec_over:FlxSprite; + public var has_decor_overlay:Boolean; + public var made_overlay:Boolean; + public var fg_solid:Boolean = false; + public var before_fg_overlay:FlxSprite; + + private var ran_constructors:Boolean = false; + private var ran_Add:Boolean = false; + private var playtime_timer:Number = 0; + + /** + * Allocate memory for everything. This should only be done ONCE + * over the entire life of the program. + */ + private function run_constructors():void { + if (ran_constructors) return; + trace("RUNNING CONSTRUCTORS"); + if (Registry.keywatch == null) { + Registry.keywatch = new Keys(); + } + //BACK_TEXT_MOBILE = EventScripts.init_bitmap_font("Press BACK again\nto exit.\nUnsaved progress\nwill be lost.", "center", 21, 22, null,"apple_white"); + BACK_TEXT_MOBILE = EventScripts.init_bitmap_font(DH.lk("title",17), "center", 21, 22, null,"apple_white"); + static_shaderFilter = new ShaderFilter(static_shader); + + noScrollPt = new FlxPoint(0, 0); + player_group = new FlxGroup(); + + statefuls = new Array(); // The current statefuls being interacted with + statelesses = new Array(); + anim_tiles_group = new FlxGroup(); + + /* movable flat gadgets - dust basically */ + intra_bg_bg2_sprites = new FlxGroup(); + bg_sprites = new FlxGroup(); + fg_sprites = new FlxGroup(); //stuff from ceiling + otherObjects = new Array(); //Holds sub-sprites, like a lser of wall laser + oldObjects = new Array(); // A buffer that holds the next to be loaded.. + oldStateless = new Array(); + oldOthers = new Array(); + sortables = new FlxGroup(); + + before_fg_overlay = new FlxSprite(0, 0); + + darkness = new FlxSprite(0, Registry.HEADER_HEIGHT); + dec_over = new FlxSprite(0, 0); + dec_over.scrollFactor = noScrollPt; + player = new Player(Registry.ENTRANCE_PLAYER_X, Registry.ENTRANCE_PLAYER_Y, Registry.keywatch,darkness,this); + + bg = new FlxSprite(0, 0); + map = new FlxTilemap(); + mapData = new Array(); + curMapBuf = new FlxTilemap(); + prevMapBuf = new FlxTilemap(); + map_bg_2 = new FlxTilemap(); + map_fg= new FlxTilemap(); + + + number_of_keys_text = EventScripts.init_bitmap_font("x" + Registry.get_nr_keys().toString(), "left", 37, 7, null, "apple_white"); + death_fadein = new FlxSprite(0, 0); + black_overlay = new FlxSprite(0, 0); + death_text = EventScripts.init_bitmap_font("Continue?", "center", 50, 60, null, "apple_white"); + + pause_state = new PauseState(); + + dialogue_state = new DialogueState(); + debugText = new FlxText(0, 0, 160); + downsample_fade = new ScreenFade(160, 180, this, ScreenFade.T_DS); + upsample_fade = new ScreenFade(160, 180, this, ScreenFade.T_US); + + header_group = new FlxGroup(); + header = new FlxSprite(0, 0); + mm_map = new Miniminimap(); + item_placeholder_1 = new FlxSprite(10, 2); + item_placeholder_2 = new FlxSprite(37, 2); + autosave_icon = EventScripts.init_autosave_icon(autosave_icon, autosave_icon_embed); + + FlxG.watch(Registry,"GRID_PUZZLES_DONE","puzct"); + FlxG.watch(Registry, "GRID_ENEMIES_DEAD", "enmct"); + + Registry.PLAYSTATE = this; + ran_constructors = true; + } + + // Called once per area. + public function init():void { + Registry.PLAYSTATE = this; + + dialogue_state.set_dialogue_box(); + // Determine the decorative overlay if any, sits on top of all graphic + made_overlay = false; + GFX_STATIC_ALWAYS_ON = false; + if (Registry.CURRENT_MAP_NAME == "SUBURB") { + if (Registry.E_NEXT_MAP_NO_STATIC == true) { + GFX_STATIC_ALWAYS_ON = true; + Registry.E_NEXT_MAP_NO_STATIC = false; + } else { + GFX_STATIC_ALWAYS_ON = true; + player.broom.loadGraphic(Broom.Knife_Sprite, true, false, 16, 16); + } + } else if (Registry.CURRENT_MAP_NAME == "DRAWER") { + if (false == in_death_room) { + GFX_STATIC_ALWAYS_ON = true; + } else { + DH.disable_menu(); + } + } else if (Registry.CURRENT_MAP_NAME == "TRAIN") { + player.broom.loadGraphic(Broom.Cell_Sprite, true, false, 16, 16); + } else { + player.broom.loadGraphic(Broom.Broom_Sprite,true,false,16,16); + } + + has_decor_overlay = false; + dec_over.exists = false; + dec_over.velocity.x = dec_over.velocity.y = 0; + + // overlay before the FG (for forest) + + set_before_fg(); + state = S_JUST_ENTERED_MAP; + SWITCH_MAPS = false; + cleaned_up_before_exit = false; + played_death_sound = false; + start_death_fade_out = false; + has_bg = false; + fg_solid = false; + Registry.GFX_WAVE_EFFECT_ON = false; + number_of_keys_text.text = "x" + Registry.get_nr_keys().toString(); + + /* Set some globals*/ + Registry.GAMESTATE = this; + + /* Flip some bools*/ + if (Registry.CURRENT_MAP_NAME == "BEDROOM") { + Registry.GE_States[Registry.GE_Bedroom_Visited] = true; + } else if (Registry.CURRENT_MAP_NAME == "STREET") { + Registry.GE_States[Registry.GE_ent_str] = true; + } else if (Registry.CURRENT_MAP_NAME == "REDCAVE") { + + } else if (Registry.CURRENT_MAP_NAME == "CROWD") { + } else { + if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) { + Registry.GE_States[Registry.GE_Left_BDR_After_Boss_Dead] = true; + } + + if (Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx]) { + Registry.GE_States[Registry.GE_Left_RDC_After_Boss_Dead] = true; + trace("GE: Left Redcave after boss!"); + } + + if (Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) { + trace("GE: Left Crowd after boss!"); + Registry.GE_States[Registry.GE_Left_CRD_After_Boss_Dead] = true; + } + } + + if (Registry.CURRENT_MAP_NAME == "NEXUS") { + Registry.GE_States[Registry.GE_ENTERED_NEXUS_ONCE] = true; + } else if (Registry.CURRENT_MAP_NAME == "BLUE") { + Registry.GE_States[Registry.GE_ENTERED_BLUE_ONCE] = true; + } + if (Registry.nr_growths < 36 || Registry.GE_States[Registry.GE_ENTERED_BLUE_ONCE] == false) { + Registry.Nexus_Door_State[13] = false; + } + + + set_do_dark_fill(Registry.CURRENT_MAP_NAME); + set_darkness(Registry.CURRENT_MAP_NAME); + + /* set player data */ + trace("Instantiating player at (",Registry.CURRENT_MAP_NAME, Registry.ENTRANCE_PLAYER_X, Registry.ENTRANCE_PLAYER_Y, ")"); + player.x = Registry.ENTRANCE_PLAYER_X; + player.y = Registry.ENTRANCE_PLAYER_Y; + player.gridX = Registry.CURRENT_GRID_X = int(player.x / 160); + player.gridY = Registry.CURRENT_GRID_Y = int((player.y - Registry.HEADER_HEIGHT) / 160); + player.grid_entrance_x = player.x; + player.grid_entrance_y = player.y; + player.reset_anodyne(); + + downsample_fade.reset(); + upsample_fade.reset(); + + + black_overlay.alpha = 0; + start_death_fade_out = false; + played_death_sound = false; + death_text.visible = false; + death_fadein.visible = false; + death_fadein.alpha = 0; + + last_song_time = 0; + header.scrollFactor = noScrollPt; + } + // Essentially the "reset" function. Resets all thingies. + override public function create():void { + run_constructors(); + init(); + noScrollPt.x = noScrollPt.y = 0; + /* Add watcher for keypresses */ + keyWatch = Registry.keywatch; + + // New-s a CSV + pause_state.minimap.init_minimap(); + pause_state.minimap.stuff_for_pause_state(); + pause_state.minimap.update_visited_array(Registry.CURRENT_MAP_NAME, Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + mm_map.switch_map(); + mm_map.switch_rooms(Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + + /* Load initial map data */ // No reset needed + TileData.setTileset(Registry.CURRENT_MAP_NAME); + // getMap new-s a CSV Object + map.loadMap(CSV_Data.getMap(Registry.CURRENT_MAP_NAME), TileData.Tiles, 16, 16); + mapData = map.getData(); + map_bg_2.null_buffer(0); + map_fg.null_buffer(0); + map_bg_2.loadMap(CSV_Data.getMap(Registry.CURRENT_MAP_NAME, 2), TileData.Tiles, 16, 16); + map_bg_2.y = Registry.HEADER_HEIGHT; + map_fg.loadMap(CSV_Data.getMap(Registry.CURRENT_MAP_NAME, 3), TileData.Tiles, 16, 16); + map_fg.y = Registry.HEADER_HEIGHT; + TileData.set_tile_properties(map_bg_2); + if (Registry.CURRENT_MAP_NAME == "OVERWORLD") { + TileData.set_tile_properties(map_fg); + fg_solid = true; + } + + /* Uses player, and left/right/etcborder to set new borders */ + updateScreenBorders(); + + /* UI stuff */ + header.loadGraphic(Header, false, false, 160, 20); + header.scrollFactor = noScrollPt; + number_of_keys_text.color = 0x7ca3b1; + + + /* Init camera, player position */ + FlxG.camera.setBounds(0, 0, 160, 180, true); + FlxG.camera.bounds.x = player.gridX * 160; + FlxG.camera.bounds.y = player.gridY * 160; + + FlxG.worldBounds.copyFrom(FlxG.camera.bounds); + + /* Set debug text if necessary */ + debugText.text = "Foo."; debugText.scrollFactor = noScrollPt; + + FlxG.debug = true; + + /* Modifies the cur/left/etcmapBufs */ + fillMapBuffers(true); + + /* Death screen entities */ + death_fadein.scrollFactor = noScrollPt; + if (Registry.CURRENT_MAP_NAME == "TRAIN") { + death_text.color = 0xffffff; + death_fadein.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, 0xff000000); + } else { + death_text.color = 0x000000; + death_fadein.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, 0xffffffff); + } + death_fadein.alpha = 0; + + + death_text.visible = false; + + /* Draw order */ + /* BG1, anim-tiles, BG2, bg_sprites, sortables (depth sorting here), above draw group, FG */ + set_bg(); + + initXML(); + reviveGridLocalSprites(); + Registry.reset_subgroups(); // In case some leftover from previous state + loadStatelessSprites(); + loadStatefulSprites(); + + + //NEEDS TO STAY + for (var id:int = 0; id < otherObjects.length; id++) { + trace("otherObject constructor: ", otherObjects[id]); + sortables.add(otherObjects[id]); + } + + /* Add to player group */ + player.foot_overlay.map = map; + player.foot_overlay.reset_anodyne(); + player.foot_overlay_bg_bg2.map = map; + player.foot_overlay_bg_bg2.reset_anodyne(); + if (Registry.CURRENT_MAP_NAME == "WINDMILL") { + player.foot_overlay.exists = false; + } else { + player.foot_overlay_bg_bg2.exists = false; + } + + black_overlay.scrollFactor = noScrollPt; + black_overlay.makeGraphic(Registry.SCREEN_HEIGHT_IN_PIXELS, Registry.HEADER_HEIGHT + Registry.SCREEN_WIDTH_IN_PIXELS, 0xff000000); + black_overlay.alpha = 1; + if (Registry.FUCK_IT_MODE_ON) { + black_overlay.alpha = 0.02; + } + + /* Graphical effects */ + + Registry.EVENT_FADE_BEGUN = true; + // Decorative overlay + load_decoration_overlay_graphic(); + + /* Maybe play special sounds and songs */ + has_ambient_sound = false; + if (!dont_change_songs) { + Registry.sound_data.start_song_from_title(Registry.CURRENT_MAP_NAME); + if (Registry.CURRENT_MAP_NAME == "BEACH") { + has_ambient_sound = true; + ambience = Registry.sound_data.waves; + Registry.sound_data.waves.play(); + + } else if (Registry.CURRENT_MAP_NAME == "WINDMILL") { + has_ambient_sound = true; + ambience = Registry.sound_data.rain; + Registry.sound_data.rain.play(); + } else { + Registry.sound_data.rain.stop(); + Registry.sound_data.waves.stop(); + + } + } + dont_change_songs = false; + + + + if (Registry.EVENT_TELEPORT_DOWN_SOUND) { + Registry.sound_data.teleport_down.play(); + Registry.EVENT_TELEPORT_DOWN_SOUND = false; + } + + /* Check for debug mode */ + if (Registry.FUCK_IT_MODE_ON) { + Scroll_Increment = 160; + + } + + // Misc. + Eye_Boss.global_state = Eye_Boss.gs_new; + + if (!ran_Add) { + init_add(); + ran_Add = true; + } + + if (Registry.CURRENT_MAP_NAME == "FIELDS") { + if (Registry.playtime < 60 * 10) { + Achievements.unlock(Achievements.Fast_fields); + } + } + + } + + // Do all of the adding, only once in the lifetime of the program. + private function init_add():void { + + add(keyWatch); + + header_group.add(header); + header_group.add(number_of_keys_text); + header_group.add(player.health_bar); + header_group.add(autosave_icon); + header_group.add(mm_map); + + add(bg); + add(prevMapBuf); + add(curMapBuf); + + add(anim_tiles_group); + add(player.reflection); + add(player.reflection_broom); + add(intra_bg_bg2_sprites); + add(map_bg_2); + add(bg_sprites); + + player.init_player_group(player_group, player, map); + sortables.add(player_group); + add(sortables); + + add(before_fg_overlay); + add(fg_sprites); + add(map_fg); + + add(dec_over); + add(darkness); + add(header_group); + add(death_fadein); + add(death_text); + add(black_overlay); + + //add(debugText); + debugText.text = Achievements.DEBUG_TEXT; + debugText.exists = true; + + BACK_TEXT_MOBILE.alpha = 0; + add(BACK_TEXT_MOBILE); + } + + private var t_mobile_back:Number = 0; + override public function update():void { + number_of_keys_text.x = 37; + if (DH.isZH()) number_of_keys_text.x = 35; + + if (Registry.MOBILE_ASK_TO_EXIT_WITH_BACK && state != S_PAUSED && pause_timer < 0) { + t_mobile_back = 2; + Registry.MOBILE_ASK_TO_EXIT_WITH_BACK = false; + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = true; + } else if (state == S_PAUSED) { + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = false; + Registry.MOBILE_ASK_TO_EXIT_WITH_BACK = false; + } + if (t_mobile_back > 0 ) { + BACK_TEXT_MOBILE.alpha = t_mobile_back / 2.0; + t_mobile_back -= FlxG.elapsed; + if (t_mobile_back < 0) { + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = false; + } + } + + playtime_timer += FlxG.elapsed; + if (playtime_timer >= 1) { + playtime_timer -= 1; + Registry.playtime += 1; + } + // Sometimes there's an issue where a song gets stuck even if I put the samples correctly + // So this checks every half second if the ms head has stopped moving, and if so, loops the song. + t_last_song_pos_checked += FlxG.elapsed; + if (t_last_song_pos_checked > 0.5) { + if (Registry.sound_data.current_song != null && Registry.sound_data.current_song._channel != null) { + if (last_song_time != 0 && Registry.sound_data.current_song._channel.position - last_song_time < 5) { + Registry.sound_data.start_song_from_title(Registry.sound_data.current_song_name); + } + last_song_time = Registry.sound_data.current_song._channel.position; + } + t_last_song_pos_checked = 0; + } + + // Test mode stuff + if (Intra.is_test) { + ugly_test_mode_functions(); + } + + + // Change alpha value of darkness overlay, maybe. + darkness_timer -= FlxG.elapsed; + + if (Registry.EVENT_CHANGE_DARKNESS_ALPHA) { + if (darkness.alpha >= Registry.EVENT_CHANGE_DARKNESS_ALPHA_TARGET) { + if (EventScripts.send_alpha_to(darkness, Registry.EVENT_CHANGE_DARKNESS_ALPHA_TARGET, -0.02)) { + Registry.EVENT_CHANGE_DARKNESS_ALPHA = false; + } + } else { + if (EventScripts.send_alpha_to(darkness, Registry.EVENT_CHANGE_DARKNESS_ALPHA_TARGET, 0.02)) { + Registry.EVENT_CHANGE_DARKNESS_ALPHA = false; + } + } + darkness.alpha = int(Math.round(darkness.alpha * 100)) / 100; + //??? + + } + + if (Registry.E_FADE_AND_SWITCH) { + Registry.EVENT_CHANGE_VOLUME_SCALE = false; + if (!Registry.E_FADED) { + Registry.volume_scale -= 0.027; + if (Registry.volume_scale <= 0) { + Registry.volume_scale = 0; + Registry.sound_data.start_song_from_title(Registry.E_FADE_AND_SWITCH_SONG); + Registry.E_FADED = true; + } + } else { + Registry.volume_scale += 0.027; + if (Registry.volume_scale >= 1) { + Registry.volume_scale = 1; + Registry.E_FADE_AND_SWITCH = false; + Registry.E_FADED = false; + } + } + } + + + // Makes the overlay, if it's a image tiled in a 2x2 pattern, + // repeat as it hits the edges, based on its width. should be larger than 160x160 to not appear awkward unless + // it's not obvious how it repeats. + update_decoration_overlay(); + + // Scale ambience + if (has_ambient_sound) { + ambience.volume = FlxG.volume * Registry.volume_scale; + if (Registry.CURRENT_MAP_NAME == "BEACH") { + if (Registry.CURRENT_GRID_Y == 2) { + ambience.volume *= 0.55; + } else if (Registry.CURRENT_GRID_Y < 2) { + ambience.volume *= 0.21; + } + } + } + + + if (state == S_NORMAL) { + stateNormal(); + } else if (state == S_TRANSITION) { + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + stateTransition(); doCollisions(); super.update(); return; + } else if (state == S_PAUSED) { + statePaused(); + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + return; + } else if (state == S_PLAYER_DIED) { + state_player_died(); + if (SWITCH_MAPS) { + state = S_NORMAL; + } + super.update(); + return; + } else if (state == S_JUST_ENTERED_MAP) { + black_overlay.alpha -= 0.02; + player.dontMove = true; + if (Registry.FUCK_IT_MODE_ON) { + + Registry.EVENT_FADE_BEGUN = false; + Registry.EVENT_FADE_BEGUN = true; + } + if (black_overlay.alpha <= 0 && Registry.EVENT_FADE_OVER) { + state = S_NORMAL; player.dontMove = false; + Registry.EVENT_FADE_BEGUN = Registry.EVENT_FADE_OVER = false; + } + super.update(); + return; + } else if (state == S_DIRECT_CONTROLS) { + stateControls(); + return; + } else if (state == S_CUTSCENE) { //update cutscene event or whatever + stateCutscene(); + return; + } else if (state == S_DIALOGUE) { + dialogue_state.update(); + if (dialogue_state.is_finished) { + + reset_dialogue_state_on_finish(); + } + } + + // Only actually transition once any dialogue is done + if (SWITCH_MAPS && DH.a_chunk_is_playing() == false) { + state = S_NORMAL; + transition_out(); + return; + } + + if (has_bg) { + if (bg.x < -160) bg.x = 0; + if (Registry.CURRENT_MAP_NAME == "BLANK") { + if (Math.random() < 0.1) FlxG.shake(0.002, 0.1); + if (Math.random() < 0.01) darkness.alpha = 0.2; + darkness.alpha -= 0.05; + } + if (Registry.CURRENT_MAP_NAME == "GO") { + if (bg.y > 20) { + bg.y = -140; + } + } + + if (Registry.CURRENT_MAP_NAME == "NEXUS") { + if (bg.y > 20) { + bg.y = -140; + } + } + } + + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + checkEvents(); + doCollisions(); + super.update(); + Registry.E_Dialogue_Just_Finished = false; + } + + + + private function checkEvents():void { + if (Registry.EVENT_OPEN_BROOM) { + //Registry.sound_data.start_song_from_title("STREET_2"); + Registry.EVENT_OPEN_BROOM = false; + } + + if (Registry.EVENT_OSCILLATE_DARKNESS_ALPHA) { + if (darkness_timer > 0) { + EventScripts.send_alpha_to(darkness, 0, -0.003); + } else { + EventScripts.send_alpha_to(darkness, 1, 0.003); + if (darkness_timer < -3) darkness_timer = 3; + } + } + + + if (Registry.EVENT_EXTEND_HEALTH) { + + HealthBar.upgrade_health(player); + //Add blocking event functionality here if you want... + Registry.EVENT_EXTEND_HEALTH = false; + } + + if (Registry.EVENT_CHANGE_VOLUME_SCALE) { + if (EventScripts.send_property_to(Registry, "volume_scale", Registry.EVENT_CHANGE_VOLUME_SCALE_TARGET, 0.01)) + Registry.EVENT_CHANGE_VOLUME_SCALE = false; + } + + /* If this is thrown, reset the current cutscene (if it exists), + * then initialize the next cutscene's views/objects etc + * */ + if (Registry.E_Load_Cutscene) { + state = S_CUTSCENE; + Registry.E_Load_Cutscene = false; + cutscene = new Cutscene(this); + cutscene.push(this as FlxState); + + } + + + } + + /** These obviously aren't really collisions but updating state and checking fo shit */ + private function doCollisions():void { + + FlxG.collide(curMapBuf, player); + FlxG.collide(map_bg_2, player); + if (fg_solid) { + FlxG.collide(map_fg, player); + } + + } + + + /** Functions associated with NORMAL STATE **/ + private function stateNormal():void { + checkForTransition(); + + /* Only pause or enter controls if we're not in the middle of a transition */ + if (pause_timer < 0 && (Registry.keywatch.JUST_PRESSED_PAUSE || FlxG.keys.justPressed("ESCAPE")) && state != S_TRANSITION) { + + pause_timer = 0.2; + if (FlxG.keys.justPressed("ESCAPE") && Registry.disable_menu == false) { + if (false == in_death_room) { + state = S_DIRECT_CONTROLS; + pause_state.controls_state.change_text(); + pause_state.controls_state.push(this); + } + } else if (Registry.disable_menu == false) { + state = S_PAUSED; + pause_state.current_substate_visible = false; + add(pause_state); + //pause_state.push(this); + Registry.sound_data.play_sound_group(Registry.sound_data.pause_sound_group); + //pause_state.set_inventory_icons(pause_state.inventory_icon_array); + pause_timer = 0.2; + } + } else { + pause_timer -= FlxG.elapsed; + } + + /* Check for player death */ + if (player.health_bar.cur_health <= 0) { + player.play("die"); + player.ANIM_STATE = player.ANIM_DEAD; + player.alive = false; + //player.unraftify_safely(); + var pt:FlxPoint = player.getScreenXY(); + player.scrollFactor.x = player.scrollFactor.y = 0; + player.x = pt.x; + player.y = pt.y; + Registry.sound_data.stop_current_song(); + player.velocity.x = player.velocity.y = 0; + player.framePixels_y_push = 0; + + remove(player, true); + add(player); + state = S_PLAYER_DIED; + } + + + if (dialogue_latency > 0) { + dialogue_latency -= FlxG.elapsed; + } + if (load_dialogue) { + load_dialogue = false; + if (dialogue_latency < 0) { //only load dialogue if latency over + state = S_DIALOGUE; + player.dontMove = true; + player.state = player.S_INTERACT; + dialogue_state.push(this as FlxState); + + } + } + + } + + /*Check for a transition. + * If we need to transition, "bump" the player to the next part, change the grid + * coordinates, and switch state to S_TRANSITION, where camera movement/sprite spawning/map buffering + * will be taken care of. */ + private function checkForTransition():void { + if (player.x < leftBorder) { + state = S_TRANSITION; player.gridX--; Registry.CURRENT_GRID_X--; + player.x = leftBorder - 12; + } else if (player.y < upperBorder) { + state = S_TRANSITION; player.gridY--; Registry.CURRENT_GRID_Y--; + + player.y = upperBorder - 12; + } else if (player.y > lowerBorder - 12) { + state = S_TRANSITION; player.gridY++; Registry.CURRENT_GRID_Y++; + player.y = lowerBorder; + } else if (player.x > rightBorder - 12) { + state = S_TRANSITION; player.gridX++;Registry.CURRENT_GRID_X++; + player.x = rightBorder; + } else { + + } + + //debugText.text += " ub: " + upperBorder.toString() + "leb: " + leftBorder.toString() + "\n camx: " + FlxG.camera.bounds.x.toString() + "camy: " + FlxG.camera.bounds.y.toString() + + //"\n x: " + player.x.toFixed(2) + " y: " + player.y.toFixed(2); + + if (state == S_TRANSITION) { + player.grid_entrance_x = player.x; + player.grid_entrance_y = player.y; + justTransitioned = true; + player.dontMove = true; + } + } + + /* Move the camera's active viewport during a screen transition. */ + private function updateCamera():int { + + if (FlxG.camera.bounds.x < leftBorder) { + FlxG.camera.bounds.x += Scroll_Increment; return 1; + } else if (FlxG.camera.bounds.y < upperBorder - Registry.HEADER_HEIGHT) { + FlxG.camera.bounds.y += Scroll_Increment; return 1; + } else if (FlxG.camera.bounds.y > upperBorder - Registry.HEADER_HEIGHT) { + FlxG.camera.bounds.y -= Scroll_Increment; return 1; + } else if (FlxG.camera.bounds.x > leftBorder) { + FlxG.camera.bounds.x -= Scroll_Increment; return 1; + } else { + FlxG.worldBounds.copyFrom(FlxG.camera.bounds); return 0; + } + } + + /** Functions associated with TRANSITION STATE **/ + /** + * Reset count of enemies killed and puzzles done on grid. + * Save the state of any stateful objects. Reset the state of stateless objects. + * Move the camera to the next screen, making sure to keep the draw order correct + * scanlines > player assets > everything else + * Load in the new sprites. + */ + private function stateTransition():void { + player.invincible = true; + if (justTransitioned) { + Registry.destroy_destroyems(); // Try not to put stuff in here + // Keep in mind you have to manually remove things you add to sortables, since sortables + // is stupidly a mix of things added through spritefactory, and inside of separate classes + Registry.GRID_ENEMIES_DEAD = 0; + Registry.GRID_PUZZLES_DONE = 0; + updateScreenBorders(); + clearOthers(); //Move the fg/bg/sortables into the oldOthers array. + fillMapBuffers(false); + clearStateless(); + Registry.reset_subgroups(); + loadStatelessSprites(); + clearStateful(); // Update the XML as necessary + loadStatefulSprites(); + for (var id:int = 0; id < otherObjects.length; id++) { + sortables.add(otherObjects[id]); + } + //trace("Added ", id, " other objects to grid from XML"); + player.cleanup_on_grid_transition(); + fade_songs_screen_change(); + justTransitioned = false; + } + if (!updateCamera()) { // The order of these calls is very important. + player.invincible = false; + deleteOtherObjects(); // Stop everything in oldOthers from drawing, and call destroy on them. + deletePrevStateless(); + deletePrevStateful(); + mm_map.switch_rooms(Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + player.broom.visible = false; + player.broom.frame = 9; + player.broom._curAnim = null; + player.transformer.reset_next(); + player.dontMove = false; // Give player control + // update the minimap + pause_state.minimap.update_visited_array(Registry.CURRENT_MAP_NAME, Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y); + state = S_NORMAL; + } + } + + private function fade_songs_screen_change():void { + switch (Registry.CURRENT_MAP_NAME) { + case "HAPPY": + var x:int = Registry.CURRENT_GRID_X; + var y:int = Registry.CURRENT_GRID_Y; + var b:Boolean = Registry.E_FADE_AND_SWITCH; + if (x == 2 && y == 2 && ( b || Registry.sound_data.current_song_name == "HAPPY") + + ) { + Registry.E_FADE_AND_SWITCH = true; + Registry.E_FADE_AND_SWITCH_SONG = "HAPPYINIT"; + } else if (x == 1 && y == 2 && ( b || Registry.sound_data.current_song_name == "HAPPYINIT") && Registry.GE_States[Registry.GE_Happy_Started]) { + Registry.E_FADE_AND_SWITCH = true; + Registry.E_FADE_AND_SWITCH_SONG = "HAPPY"; + } else if (x == 4 && y == 2 && ( b || Registry.sound_data.current_song_name == "HAPPY")) { + Registry.E_FADE_AND_SWITCH = true; + Registry.E_FADE_AND_SWITCH_SONG = "HAPPYINIT"; + } else if (x == 4 && y == 1 && ( b || Registry.sound_data.current_song_name == "HAPPYINIT") && Registry.GE_States[Registry.GE_Happy_Started]) { + Registry.E_FADE_AND_SWITCH = true; + Registry.E_FADE_AND_SWITCH_SONG = "HAPPY"; + } + break; + default: + } + } + /** Various functions with map drawing **/ + + private function fillMapBuffers(isInit:Boolean):void { + /* Entity map array - enemies, switches, locked doors, doors, etc. When drawing through this, everything will have an ID: + * 0 - no state - everything resets upon leaving/re-entering, or no state at all - Doors. + * 1 - partial state - should be stored to the local area array upon first entry, or checked to reload. stores + * things like position, alive/dead, on/off. resets upon area entry/re-entry + * 2 - global state - things like events, bosses, treasure boxes, NPCs. These should be serialized into a save file + * upon saving, and stored in memory throughput a play session. These will need to be imported with XML and proper + * IDs. When entering a room, always check to see if we need to load from the global state rather than what's stored + * on the map/xml data struct or whatever. */ + + var nextMapData:Array = get_submap_from_map(player.gridX, player.gridY, true); + var prevMapData:Array = get_submap_from_map(curMapBuf.x / 160, (curMapBuf.y - Registry.HEADER_HEIGHT) / 160, false); + if (isInit) { + curMapBuf.loadMap(FlxTilemap.arrayToCSV(nextMapData, Registry.SCREEN_WIDTH_IN_TILES), TileData.Tiles, 16, 16); + prevMapBuf.loadMap(FlxTilemap.arrayToCSV(nextMapData, Registry.SCREEN_WIDTH_IN_TILES), TileData.Tiles, 16, 16); + curMapBuf.x = player.gridX * Registry.SCREEN_WIDTH_IN_PIXELS; + curMapBuf.y = player.gridY * Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT; + prevMapBuf.y = curMapBuf.y; + + } else { + prevMapBuf.loadMap(FlxTilemap.arrayToCSV(prevMapData, Registry.SCREEN_WIDTH_IN_TILES), TileData.Tiles, 16, 16); + prevMapBuf.x = curMapBuf.x; + prevMapBuf.y = curMapBuf.y; + curMapBuf.loadMap(FlxTilemap.arrayToCSV(nextMapData, Registry.SCREEN_WIDTH_IN_TILES), TileData.Tiles, 16, 16); + curMapBuf.x = player.gridX * Registry.SCREEN_WIDTH_IN_PIXELS; + curMapBuf.y = player.gridY * Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT; + } + nextMapData = null; + prevMapData = null; + + //Set static tile properties + TileData.set_tile_properties(curMapBuf); + } + + public function ext_make_anims():void { + get_submap_from_map(Registry.CURRENT_GRID_X, Registry.CURRENT_GRID_Y, true); + } + private function get_submap_from_map(gridX:int, gridY:int,make_anims:Boolean):Array { + var submap:Array = new Array(); + var gridTileOffsetX:int = gridX * Registry.SCREEN_WIDTH_IN_TILES + var gridTileOffsetY:int = gridY * Registry.SCREEN_HEIGHT_IN_TILES; + var tileType:int; + + var i:int; var j:int; + for (j = 0; j < Registry.SCREEN_HEIGHT_IN_TILES; j++) { + for (i = 0; i < Registry.SCREEN_WIDTH_IN_TILES; i++) { + tileType = mapData[(gridTileOffsetY + j) * map.widthInTiles + gridTileOffsetX + i]; + if (make_anims) { + TileData.make_anim_tile(anim_tiles_group, Registry.CURRENT_MAP_NAME, tileType, gridTileOffsetX * 16 + 16 * i, gridTileOffsetY * 16 + 16 * j + 20); + } + submap.push(tileType); + } + } + + return submap; + } + + + private function updateScreenBorders():void { + leftBorder = player.gridX * Registry.SCREEN_WIDTH_IN_PIXELS; + rightBorder = (1 + player.gridX) * Registry.SCREEN_WIDTH_IN_PIXELS; + upperBorder = player.gridY * Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT; + lowerBorder = (1 + player.gridY) * Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT; + } + + /* Functions associated with maintaining the state via XML */ + + /** + * Sets the stateful_mapXML::XML and stateless_mapXML::XML to + * the current subtree for the area, so that sprites can be spawned. + */ + private function initXML():void { + var map:XML; + stateful_mapXML = null; + stateless_mapXML = null; + for each (map in Registry.statefulXML.map) { + if (map.@name == Registry.CURRENT_MAP_NAME) { + stateful_mapXML = map; break; + } + } + for each (map in Registry.statelessXML.map) { + if (map.@name == Registry.CURRENT_MAP_NAME) { + stateless_mapXML = map; break; + } + } + } + + /** + * Loads sprites that generally do not have any state associated with them + * and places them into statelesses::Array . Then, adds them to + * sortables::FlxGroup . + */ + private function loadStatelessSprites():void { + var grid:XML; + if (stateless_mapXML == null) return; + + for each (grid in stateless_mapXML.grid) { + if (grid.@grid_x == player.gridX.toString() && grid.@grid_y == player.gridY.toString()) { + stateless_gridXML = grid; break; + } + } + if (stateless_gridXML == null) return; + + var i:int; + var retval:int; + var offset:int = 0; + /** Terrible hack. Retval is how many extra *STATELESS* sprites were added. + * So offset compensates to figure out where to add the "parent" sprite */ + for (i = 0; i < stateless_gridXML.child("*").length(); i++) { + retval = SpriteFactory.makeSprite(stateless_gridXML.child("*")[i], i, statelesses, otherObjects, player, this, darkness); + if (retval != -1) { + sortables.add(statelesses[offset]); + //trace(statelesses[offset]); + offset += (retval + 1); + } + } + } + + private function deletePrevStateless():void { + var nrKilled:int = 0; + var o:FlxBasic; + while (oldStateless.length > 0) { + o = oldStateless.pop(); + //trace(o); + sortables.remove(o, true); + if (o != null) o.destroy(); + o = null; + nrKilled++; + } + } + + private function clearStateless():void { + while (statelesses.length > 0) { + oldStateless.push(statelesses.pop()); + } + stateless_gridXML = null; + } + + /** + * Load some sprites that generally have serialized state and + * place them into statefuls::Array . Then, add them to sortables::FlxGroup . + */ + private function loadStatefulSprites():void { + var grid:XML; + if (stateful_mapXML == null) return; + for each (grid in stateful_mapXML.grid) { + if (grid.@grid_x == player.gridX.toString() && grid.@grid_y == player.gridY.toString()) { + stateful_gridXML = grid; break; + } + } + if (stateful_gridXML == null) return; //No stateful sprites on this grid + var id:int; //Stateful objects will have IDs set to index into the XML + var nrStatefuls:int = 0; + for (id = 0; id < stateful_gridXML.child("*").length(); id++) { + if ( -1 != SpriteFactory.makeSprite(stateful_gridXML.child("*")[id], id, statefuls,otherObjects,player,this,darkness)) { + nrStatefuls++; //Number of stateful objects we made in DAME, not counting sprites that have subsprites (i.e., laser of wall laser) + } else { + continue; + } + } + // Now add these sprites in + for (id = 0; id < statefuls.length; id++) { + sortables.add(statefuls[id]); + } + } + /** + * Saves the references to the current stateful sprites so they can be removed when they are + * off-screen. Clears the stateful array so the new ones can be added. + */ + private function clearStateful():void { + var o:Object; + while (statefuls.length > 0) { + o = statefuls.pop(); + if (o != null) { + oldObjects.push(o); + } + } + stateful_gridXML = null; + } + + /** + * Call destroy on all objects in oldObjects::Array and also removes them + * from sortables::FlxGroup . + */ + private function deletePrevStateful():void { + var o:FlxBasic; + var nr:int; + while (oldObjects.length > 0) { + o = oldObjects.pop() as FlxBasic; + if (o != null) { + nr++; + sortables.remove(o, true); + o.destroy(); + } + } + } + + /** + * Push some objects into the bag to be deleted later + */ + private function clearOthers():void { + while (otherObjects.length > 0) { + oldOthers.push(otherObjects.pop()); + } + var o:*; + for each (o in bg_sprites.members) { + oldOthers.push(o); + } + + for each (o in fg_sprites.members) { + oldOthers.push(o); + } + + for each (o in intra_bg_bg2_sprites.members) { + //foot overlay in windmill goes here don't EVER fckign remov it fuck + if (o != player.foot_overlay_bg_bg2) { + oldOthers.push(o); + } + } + for each (o in anim_tiles_group.members) { + if (o != null) oldOthers.push(o); + } + } + private function deleteOtherObjects():void { + //trace("Removing ", oldOthers.length, " other objects"); + var o:*; + while (oldOthers.length > 0) { + o = oldOthers.pop(); + if (o == null) continue; + sortables.remove(o, true); + bg_sprites.remove(o, true); //lol + fg_sprites.remove(o, true); + intra_bg_bg2_sprites.remove(o, true); + anim_tiles_group.remove(o, true); + o.destroy(); + } + } + /* Revive sprites with permanence level 1 (MAP_LOCAL) when leaving a map */ + private function reviveGridLocalSprites():void { + var grid:XML; + var id:int; + if (stateful_mapXML != null) { + for each (grid in stateful_mapXML.grid) { + for (id = 0; id < grid.child("*").length(); id++) { + if (grid.child("*")[id].@p == 1 && grid.child("*")[id].@alive == "false") { + grid.child("*")[id].@alive = "true"; + } + } + } + } + + if (stateless_mapXML != null) { + for each (grid in stateless_mapXML.grid) { + for (id = 0; id < grid.child("*").length(); id++) { + if (grid.child("*")[id].@p == 1 && grid.child("*")[id].@alive == "false") { + grid.child("*")[id].@alive = "true"; + } + } + } + } + } + + /* Direct access to controls state */ + private function stateControls():void { + pause_state.controls_state.update(); + Registry.keywatch.update(); + if (!pause_state.controls_state.updating && Registry.keywatch.JUST_PRESSED_PAUSE) { + state = S_NORMAL; + pause_state.controls_state.pop(this); + } + } + /** Functions associated with PAUSED STATE **/ + + private function statePaused():void { + pause_state.update(); + Registry.keywatch.update(); + if (pause_state.done == true) { + pause_state.done = false; + state = S_NORMAL; + //pause_state.pop(this); + remove(pause_state, true); + if (Registry.GAMESTATE != null) { + Registry.GAMESTATE.dialogue_state.set_dialogue_box(); + } + } + } + + + // Based on the map name, load a graphic for the decorative overlay. + // Then add anims, set its velocity if needed, etc + // Add embedded graphics to src/data/Common_Sprites.as ! + private function load_decoration_overlay_graphic():void + { + made_overlay = true; + switch (Registry.CURRENT_MAP_NAME) { + case "WINDMILL": + //default: + // break; + + dec_over.loadGraphic(Common_Sprites.windmill_overlay, true, false, 320, 320); + dec_over.addAnimation("blah", [0], 2); + dec_over.play("blah"); + dec_over.exists = true; + dec_over.velocity.y = 160; + dec_over.velocity.x = -10; + break; + case "SUBURB": + case "DRAWER": + if (GFX_STATIC_ALWAYS_ON == false) return; + //dec_over.loadGraphic(Common_Sprites.static_map as Class, true, false, 160, 160); + dec_over.y = 20; + dec_over.velocity.x = dec_over.velocity.y = 0; + dec_over.pixels = Common_Sprites.static_map.bitmapData; + dec_over.width = dec_over.height = 160; + dec_over.frameHeight = dec_over.frameWidth = 160; + dec_over.addAnimation("a", [0, 1, 2, 3], 8); + dec_over.play("a"); + dec_over.exists = true; + break; + case "STREET": + dec_over.blend = "overlay"; + dec_over.y = 20; + dec_over.loadGraphic(Common_Sprites.street_blend, true, false, 160, 160); + //dec_over.exists = true; + dec_over.velocity.x = dec_over.velocity.y = 0; + break; + + } + } + + private function update_decoration_overlay():void + { + if (dec_over.exists) { + if (dec_over.x < -dec_over.width / 2) { + dec_over.x += dec_over.width / 2; + } else if (dec_over.x > 0) { + dec_over.x -= dec_over.width / 2; + } + if (dec_over.y > Registry.HEADER_HEIGHT) { + dec_over.y -= dec_over.height / 2; + } else if (dec_over.y < -dec_over.height / 2 + Registry.HEADER_HEIGHT) { + dec_over.y += dec_over.height / 2; + } + } + + } + + /** + * Called if the game is in Test_mode. + * Currently just lets you warp around the dungeons + */ + private function ugly_test_mode_functions():void + { + if (FlxG.keys.D) { + if (FlxG.keys.justPressed("ONE")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "BEDROOM"; + Registry.inventory[Registry.IDX_JUMP] = false; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 6); + header_group.add(player.health_bar); + + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["BEDROOM"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["BEDROOM"].y; + } else if (FlxG.keys.justPressed("TWO")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "REDCAVE"; + Registry.inventory[Registry.IDX_JUMP] = false; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["REDCAVE"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["REDCAVE"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 7); + header_group.add(player.health_bar); + }else if (FlxG.keys.justPressed("THREE")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "CROWD"; + Registry.inventory[Registry.IDX_JUMP] = false; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["CROWD"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["CROWD"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 7); + header_group.add(player.health_bar); + }else if (FlxG.keys.justPressed("FOUR")) { + SWITCH_MAPS = true; + player.health_bar = new HealthBar(155, 2, 9); + Registry.NEXT_MAP_NAME = "APARTMENT"; + Registry.inventory[Registry.IDX_JUMP] = true; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["APARTMENT"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["APARTMENT"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 9); + header_group.add(player.health_bar); + }else if (FlxG.keys.justPressed("FIVE")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "HOTEL"; + Registry.inventory[Registry.IDX_JUMP] = true; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["HOTEL"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["HOTEL"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 9); + header_group.add(player.health_bar); + }else if (FlxG.keys.justPressed("SIX")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "CIRCUS"; + Registry.inventory[Registry.IDX_JUMP] = true; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["CIRCUS"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["CIRCUS"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 9); + header_group.add(player.health_bar); + } else if (FlxG.keys.justPressed("SEVEN")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "STREET"; + Registry.inventory[Registry.IDX_BROOM] = false; + Registry.inventory[Registry.IDX_JUMP] = false; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["STREET"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["STREET"].y; + header_group.remove(player.health_bar, true); + player.health_bar = new HealthBar(155, 2, 6); + header_group.add(player.health_bar); + } else if (FlxG.keys.justPressed("EIGHT")) { + SWITCH_MAPS = true; + Registry.NEXT_MAP_NAME = "DEBUG"; + Registry.ENTRANCE_PLAYER_X = 10; + Registry.ENTRANCE_PLAYER_Y = 10; + } + + Registry.inventory[Registry.IDX_BROOM] = true; + Registry.bound_item_1 = "BROOM"; + Registry.inventory[Registry.IDX_WIDEN] = true; + Registry.inventory[Registry.IDX_LENGTHEN] = true; + + if (Registry.inventory[Registry.IDX_JUMP]) { + Registry.bound_item_2 = "JUMP"; + } else { + Registry.bound_item_2 = ""; + } + } + } + + private function reset_dialogue_state_on_finish():void + { + player.dontMove = false; + player.state = player.S_GROUND; + state = S_NORMAL; + dialogue_latency = 0.3; + + + dialogue_state.reset(); + Registry.E_Dialogue_Just_Finished = true; + dialogue_state.pop(this as FlxState); + } + + private function set_bg():void + { + has_bg = true; + bg.visible = true; + bg.scrollFactor = noScrollPt; + bg.velocity.x = bg.velocity.y = 0; + bg.x = 0; + bg.y = 0; + if (Registry.CURRENT_MAP_NAME == "BLANK") { + bg.loadGraphic(BLANK_BG, false, false, 320, 160); + bg.y = 20; + bg.velocity.x = -20; + } else if (Registry.CURRENT_MAP_NAME == "SPACE") { + bg.loadGraphic(Common_Sprites.space_bg, false, false, 320, 160); + bg.y = Registry.HEADER_HEIGHT; + bg.velocity.x = -15; + } else if (Registry.CURRENT_MAP_NAME == "GO") { + bg.loadGraphic(Common_Sprites.briar_Bg, false, false, 160,320); + bg.y = Registry.HEADER_HEIGHT; + bg.velocity.y = 15; + } else if (Registry.CURRENT_MAP_NAME == "NEXUS") { + bg.loadGraphic(Common_Sprites.nexus_bg, false, false, 160, 320); + bg.y = Registry.HEADER_HEIGHT - 160; + bg.velocity.y = 15; + bg.velocity.x = 0; + } else { + has_bg = false; + bg.visible = false; + } + + } + + private function set_before_fg():void + { + before_fg_overlay.visible = true; + before_fg_overlay.scrollFactor.x = before_fg_overlay.scrollFactor.y = 0; + before_fg_overlay.y = 20; + if (Registry.CURRENT_MAP_NAME == "FOREST") { + before_fg_overlay.loadGraphic(Common_Sprites.forest_blend, false, false, 160, 160); + before_fg_overlay.blend = "overlay"; + } else if (Registry.CURRENT_MAP_NAME == "HOTEL" && Registry.E_PLAY_ROOF) { + before_fg_overlay.loadGraphic(Common_Sprites.roof_blend, false, false, 160, 160); + before_fg_overlay.blend = "hardlight"; + } else if (Registry.CURRENT_MAP_NAME == "SUBURB") { + before_fg_overlay.loadGraphic(Common_Sprites.suburbs_Blend, false, false, 160, 160); + before_fg_overlay.blend = "overlay"; + } else { + before_fg_overlay.visible = false; + } + + } + + + public function stateCutscene():void { + cutscene.update(); + keyWatch.update(); + if (cutscene.state == cutscene.s_done) { + cutscene.pop(this as FlxState); + cutscene.destroy(); + cutscene = null; + state = S_NORMAL; + } + } + + private var arrow:FlxSprite; + private var arrow_state:int = 0; + public var in_death_room:Boolean = false; + + public function state_player_died():void { + Registry.keywatch.update(); + + + + EventScripts.send_property_to(player, "x", 80, 0.5); + EventScripts.send_property_to(player, "y", 100, 0.5); + // Play the death noise (hit ground) and then show the death text. + // Also make the arrow show up. + if (player.frame == player.DEATH_FRAME && !played_death_sound) { + played_death_sound = true; + Registry.sound_data.player_hit_1.play(); + Registry.sound_data.GameOver.play(); + death_text.visible = true; + death_text.alpha = 1; + death_text.setText("Continue?\n" + "Yes\nNo..", true, 0, 0, "center", true); + + if (arrow == null) { + arrow = new FlxSprite; + arrow.scrollFactor.x = arrow.scrollFactor.y = 0; + arrow.loadGraphic(PauseState.arrows_sprite, true, false, 7, 7); + arrow.addAnimation("flash", [2, 3], 8); + add(arrow); + } + arrow.x = death_text.x + 4; + arrow.y = death_text.y + 8; + arrow.play("flash"); + arrow.visible = true; + remove(arrow, true); + add(arrow); + } + + death_fadein.visible = true; + if (death_fadein.alpha < 1) death_fadein.alpha += 0.03; + if (death_fadein.alpha > 0.7) { + death_text.visible = true; + + } + + if (arrow != null) { + if (arrow.visible == true) { + if (arrow_state == 0) { + if (Registry.keywatch.JP_DOWN) { + arrow_state = 1; + arrow.y += 8; + } + } else { + if (Registry.keywatch.JP_UP) { + arrow_state = 0; + arrow.y -= 8; + } + } + } + } + + if (start_death_fade_out || (played_death_sound && Registry.keywatch.JP_ACTION_1 && death_text.visible )) { + + start_death_fade_out = true; + black_overlay.alpha += 0.02; + player.alpha -= 0.02; + death_text.alpha -= 0.02; + if (black_overlay.alpha == 1) { + Registry.sound_data.GameOver.stop(); + Registry.sound_data.GameOver = null; + Registry.sound_data.GameOver = new FlxSound(); + Registry.sound_data.GameOver.loadEmbedded(SoundData.GameOver_Song, false); + Registry.ENTRANCE_PLAYER_X = Registry.checkpoint.x; + Registry.ENTRANCE_PLAYER_Y = Registry.checkpoint.y; + Registry.CURRENT_MAP_NAME = Registry.checkpoint.area; + // When we die we want to make sure the song restarts + dont_change_songs = false; + Registry.E_OVERRIDE_SAME_MAP_SONG = true; + Registry.death_count++; + Registry.BOI = false; + Registry.CUR_HEALTH = Registry.MAX_HEALTH; + player.health_bar.modify_health(Registry.MAX_HEALTH); + if (arrow_state == 1) { + Registry.CURRENT_MAP_NAME = Registry.NEXT_MAP_NAME = "DRAWER"; + Registry.ENTRANCE_PLAYER_X = 368; + Registry.ENTRANCE_PLAYER_Y = 224 + 20; + player.start_in_slump = true; + in_death_room = true; + } else { + Registry.NEXT_MAP_NAME = Registry.checkpoint.area; + trace("(death) Loading checkpoint: ", Registry.checkpoint.area, Registry.checkpoint.x, Registry.checkpoint.y); + } + header.scrollFactor = noScrollPt; + SWITCH_MAPS = true; + DH.enable_menu(); + remove(player, true); + remove(arrow, true); + arrow.visible = false; + } + + } + + } + /* + * last things before leaving the map (transitions, changing global map name) + * */ + public function transition_out():void { + /* Mark all sprites to be cleaned up, reset any events set, + * reset grid state, determine beginning state of the transition */ + if (!cleaned_up_before_exit) { + cleaned_up_before_exit = true; + Registry.destroy_destroyems(); + reviveGridLocalSprites(); + clearOthers(); + clearStateful(); + clearStateless(); + Registry.reset_events(); + Registry.GRID_ENEMIES_DEAD = 0; + Registry.GRID_PUZZLES_DONE = 0; + + //trace(Registry.E_OVERRIDE_SAME_MAP_SONG, Registry.CURRENT_MAP_NAME, Registry.NEXT_MAP_NAME); + if (Registry.E_OVERRIDE_SAME_MAP_SONG || Registry.CURRENT_MAP_NAME != Registry.NEXT_MAP_NAME) { + Registry.pillar_switch_state = false; + Registry.E_OVERRIDE_SAME_MAP_SONG = false; + } else { + dont_change_songs = true; + } + + if (Registry.E_Enter_Whirlpool_Down) { + + } else { + Registry.EVENT_FADE_BEGUN = true; + } + + if (Registry.FUCK_IT_MODE_ON) { + Registry.EVENT_FADE_OVER = true; + Registry.EVENT_FADE_BEGUN = false; + black_overlay.alpha = 1; + } + } + /* Fade out the song and other sounds playing */ + + if (!dont_change_songs) { + Registry.sound_data.current_song.volume -= 0.03; + if (Registry.sound_data.current_song.playing && Registry.sound_data.current_song.volume < 0.05) { + Registry.sound_data.stop_current_song(); + } + + if (Registry.CURRENT_MAP_NAME == "BEACH") { + Registry.sound_data.waves.stop(); + } else if (Registry.CURRENT_MAP_NAME == "WINDMILL") { + Registry.sound_data.rain.stop(); + } + } + + /* Do door-specific stuff here (events, etc) */ + if (Registry.CURRENT_MAP_NAME == "BLANK") { + black_overlay.alpha += 0.01; + } else if (Registry.E_Enter_Whirlpool_Down) { + + super.update(); + player.play('whirl'); + if (player.framePixels_y_push != 15) { + player.framePixels_y_push++; + } + if (player.framePixels_y_push >= 15) { + black_overlay.alpha += 0.015; + Registry.EVENT_FADE_BEGUN = true; + } + } else { + black_overlay.alpha += 0.02; + } + + /* Actually make the transition when the overlay is completely + * opaque and the downsampling is done */ + if (black_overlay.alpha >= 0.99 && + (dont_change_songs || !Registry.sound_data.current_song.playing) && + Registry.EVENT_FADE_OVER) { + + DH.reset_scenes_on_map_change(); + Registry.EVENT_FADE_OVER = Registry.EVENT_FADE_BEGUN = false; + + Registry.CURRENT_MAP_NAME = Registry.NEXT_MAP_NAME; + + Registry.set_is_playstate(Registry.CURRENT_MAP_NAME); + deleteOtherObjects(); + deletePrevStateful(); + deletePrevStateless(); + Registry.cleanup_on_map_change(); + create(); + } + } + + public function set_darkness(map:String):void { + + var color:uint; + darkness.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS, 0xff000000); + darkness.blend = "overlay"; + darkness.visible = true; + darkness.alpha = 1; + darkness.y = 20; + if (map == "DRAWER") { + darkness.blend = "multiply"; + if (in_death_room == false) { + darkness.alpha = 1; + } else { + darkness.alpha = 0.8; + } + } else if (map == "HAPPY") { + darkness.loadGraphic(Common_Sprites.happy_blend, true, false, 160, 160); + darkness.blend = "hardlight"; + if (Registry.GE_States[Registry.GE_Happy_Started]) { + darkness.alpha = 1.0; + } else { + darkness.visible = false; + darkness.alpha = 0; + } + // or "screen" or "lighten" etc + } else if (map == "REDSEA") { + darkness.loadGraphic(Common_Sprites.redsea_blend, true, false, 160, 160); + darkness.blend = "hardlight"; + } else if (map == "GO") { + darkness.loadGraphic(Common_Sprites.go_blend, true, false, 160, 160); + darkness.blend = "hardlight"; + } else if (map == "CLIFF") { + darkness.loadGraphic(Common_Sprites.cliff_blend, false, false, 160, 160); + } else if (map == "APARTMENT") { + darkness.loadGraphic(Common_Sprites.apartment_Blend, false, false, 160, 160); + } else if (map == "SPACE") { + darkness.loadGraphic(Common_Sprites.space_blend, false, false, 160, 160); + } else if (map == "BEACH") { + darkness.loadGraphic(Common_Sprites.beach_blend, false, false, 160, 160); + darkness.blend = "hardlight"; + } else if (map == "HOTEL") { + darkness.loadGraphic(Common_Sprites.hotel_blend, false, false, 160, 160); + } else if (map == "BLUE") { + darkness.loadGraphic(Common_Sprites.blue_blend, false, false, 160, 160); + } else if (map == "CROWD") { + darkness.loadGraphic(Common_Sprites.crowd_blend, false, false, 160, 160); + } else if (map == "GO") { + darkness.loadGraphic(Common_Sprites.go_blend, false, false, 160, 160); + darkness.blend = "hardlight"; + } else if (map == "REDCAVE") { + darkness.loadGraphic(Common_Sprites.redcave_blend, false, false, 160, 160); + } else if (map == "WINDMILL") { + darkness.loadGraphic(Common_Sprites.windmill2_Blend, false, false, 160, 160); + } else if (map == "NEXUS") { + darkness.loadGraphic(Common_Sprites.nexus_Blend, false, false, 160, 160); + } else if (map == "TERMINAL") { + darkness.loadGraphic(Common_Sprites.terminal_blend, false, false, 160, 160); + } else { + darkness.alpha = 0; + //darkness.visible = false; + darkness.blend = "multiply"; + } + + if (Registry.E_NEXT_MAP_DARKNESS_8 == true) { + Registry.E_NEXT_MAP_DARKNESS_8 = false; + darkness.alpha = 0.91; + } + + + darkness.scrollFactor = noScrollPt; + + } + + override public function destroy():void { + + if (!Registry.E_DESTROY_PLAYSTATE) { + trace("Not destryoing playstate"); + return; + } + trace("destroying playstate"); + Registry.E_DESTROY_PLAYSTATE = false; + + remove(Registry.keywatch, true); + + for (var i:int = 0; i < members.length; i++) { + if (members[i] != null) members[i] = null; + } + mapData = null; + if (!dont_change_songs) { + Registry.sound_data.current_song = null; + + } + /* Need to null all of the non-added references and destroy their children*/ + statelesses = null; + statefuls = null; + pause_state.destroy(); + pause_state = null; + if (cutscene != null) { + cutscene.destroy(); + cutscene = null; + } + dialogue_state.destroy(); + dialogue_state = null; + oldObjects = otherObjects = oldOthers = oldStateless = null; + downsample_fade.destroy(); + upsample_fade.destroy(); + upsample_fade = downsample_fade = null; + noScrollPt = null; + dec_over = null; + before_fg_overlay = null; + number_of_keys_text = null; + + FlxG.clearBitmapCache(); + + super.destroy(); + } + + public static var GFX_DISCO:int = 0; + private static var GFX_DISCO_ON:Boolean = false; + private static var GFX_DISCO_CTR:int = 0; + private static var GFX_DISCO_A:int = 0; + + public static var GFX_STATIC_ALWAYS_ON:Boolean = false; + private static var GFX_STATIC_ON:Boolean = false; + public static var GFX_STATIC:int = 1; + + private static var GFX_GLITCH_ALWAYS_ON:Boolean = false; + + public static function turn_on_effect(effect:int):void { + switch (effect) { + case GFX_DISCO: + GFX_DISCO_ON = true; + break; + case GFX_STATIC: + GFX_STATIC_ON = true; + break; + } + } + + // For static shader + //private static var shades:Array = new Array(0x000000, 0x202020, 0x404040, 0x606060, 0x808080, 0xa0a0a0, 0xc0c0c0, 0xe0e0e0, 0xffffff); + private static var shades:Array = new Array(); + + private static var lookup:Array = new Array(); + private static var lookup_init:Boolean = false; + private static var lookup1:Array = new Array(); + private static var lookup3:Array = new Array(); + private static var lookup5:Array = new Array(); + private static var lookup7:Array = new Array(); + private static var lookup_qe:Array = new Array(); + private static var poop:int = 0; + private static var lookupa:Array; + private static var nr_shades:int = 25; + private static var bm:BitmapData = new BitmapData(160, 180, true); + + + // For glitch shader + + private static var glitch_min:Point = new Point(16, 16); // Min w, h of a part + private static var glitch_max:Point = new Point(32, 32); // max + private static var glitch_r:Rectangle = new Rectangle; + private static var glitch_dest:Point = new Point; + private static var glitch_iters:int = 50; // How many transformations should happen. + private static var glitch_f:Number = 0; // frame counter, +1 per draw call + private static var glitch_fm:Number = 1; // glitch_f decremented by this when greater + private static var glitch_rf:Number = 0; // + private static var glitch_rfm:Number = 10; // How often the glitched things change + private static var glitch_data:Array = new Array(new Array(glitch_iters), new Array(glitch_iters), new Array(glitch_iters), new Array(glitch_iters), new Array(glitch_iters), new Array(glitch_iters)); // x, y, w, h + + + private var redo_darknes:Boolean = false; + private var do_dark_fill:Boolean = false; + + private function set_do_dark_fill(map:String):void { + if (Registry.CURRENT_MAP_NAME != "BLANK" && Registry.CURRENT_MAP_NAME != "OVERWORLD" && Registry.CURRENT_MAP_NAME != "FIELDS" && Registry.CURRENT_MAP_NAME != "TRAIN" && Registry.CURRENT_MAP_NAME != "BEDROOM" && Registry.CURRENT_MAP_NAME != "SUBURB" && Registry.CURRENT_MAP_NAME != "DRAWER" && Registry.CURRENT_MAP_NAME != "CIRCUS") { + do_dark_fill = false; + } else { + if (Registry.CURRENT_MAP_NAME == "CIRCUS") { + darkness.alpha = 0; + } + do_dark_fill = true; + } + } + override public function draw():void { + + + if (false == do_dark_fill) { + if (redo_darknes) { + redo_darknes = false; + + set_darkness(Registry.CURRENT_MAP_NAME); + } + } else { + darkness.fill(0xff000000); + redo_darknes = true; + } + + + + /* Sort by y value */ + sortables.sort("y_bottom", ASCENDING); + + super.draw(); + + if (true == GFX_DISCO_ON) { + GFX_DISCO_CTR += 1; + if (GFX_DISCO_CTR > 14) { + GFX_DISCO_CTR = 0; + GFX_DISCO_A = int(8 * Math.random()); + } + + FlxG.camera.buffer.lock(); + for (var i:int = 0; i < 180; i++) { + for (var j:int = 0; j < 160; j++) { + //FlxG.camera.buffer.setPixel32(j, i, FlxG.camera.buffer.getPixel32(j, i) / GFX_DISCO_A); + } + } + FlxG.camera.buffer.unlock(); + GFX_DISCO_ON = false; + } + + //state for static effect + + if (!lookup_init) { + //FlxG.camera.getContainerSprite().filters = [static_shaderFilter]; + lookup_init = true; + var d:int = 0; + for (i = 0; i < nr_shades; i++) { + d = i * (255 / (nr_shades - 1)); + if (i == nr_shades - 1) { + shades.push(0x00ffffff); + } else { + + // UNCOMMENT FOR UFCKED UP GLOW + //shades.push(d * 256 + d * 16 + d); + shades.push(d * 256*256 + d * 256 + d); + } + } + + for (i = 0; i < 256; i++) { + lookup.push(shades[int(i / (1 + (255/nr_shades)))]); // if we want 9 shades + lookup1.push(int((10 / 16) * i) * 0x010101); + lookup3.push(int((23 / 24) * i) * 0x010101); // Some fraction of the "error" that will be added to a pixel's value + lookup5.push(int((22 / 24) * i) * 0x010101); + lookup7.push(int((21 / 24) * i) * 0x010101); + // Error value based on distance from nearest shade + lookup_qe.push((Math.max(0,(i * 0x010101) - (shades[int(i / 27)]))) >> 16); + } + } + + if (Registry.CURRENT_GRID_X >= map.widthInTiles / 10 || Registry.CURRENT_GRID_X < 0 || Registry.CURRENT_GRID_Y < 0 || Registry.CURRENT_GRID_Y >= map.heightInTiles / 10) { + GFX_GLITCH_ALWAYS_ON = true ; + } else { + GFX_GLITCH_ALWAYS_ON = false; + } + if (GFX_GLITCH_ALWAYS_ON) { + glitch_rf += 1; + FlxG.camera.buffer.lock(); + for (i = 0; i < glitch_iters; i++) { + if (glitch_rf >= glitch_rfm) { + glitch_data[2][i] = Math.max(glitch_min.x, int(Math.random() * glitch_max.x)); + glitch_data[3][i] = Math.max(glitch_min.y, int(Math.random() * glitch_max.y)); + glitch_data[0][i] = int(160 * Math.random()); + glitch_data[1][i] = int(180 * Math.random()); + glitch_data[4][i] = int(160 * Math.random()); + glitch_data[5][i] = int(180 * Math.random()); + } + glitch_r.width = glitch_data[2][i]; + glitch_r.height = glitch_data[3][i]; + glitch_r.x = glitch_data[0][i]; + glitch_r.y = glitch_data[1][i]; + glitch_dest.x = glitch_data[4][i]; + glitch_dest.y = glitch_data[5][i]; + FlxG.camera.buffer.copyPixels(FlxG.camera.buffer, glitch_r, glitch_dest); + } + if (glitch_rf > glitch_rfm) { + glitch_rf -= glitch_rfm; + } + FlxG.camera.buffer.unlock(); + + } + + + + + if (GFX_STATIC_ON || GFX_STATIC_ALWAYS_ON) { + + if (!Intra.is_mobile) { + FlxG.camera.buffer.applyFilter(FlxG.camera.buffer, FlxG.camera.buffer.rect, FlxG.camera.buffer.rect.topLeft, static_shaderFilter); + if (Registry.CURRENT_MAP_NAME == "SUBURB") { + before_fg_overlay.draw(); + + } + } + /*var gray:uint = 0; + var r:uint = 0; + var g:uint = 0; + var b:uint = 0; + var qe:uint = 0; + var old:uint = 0; + + if (poop > 15) poop = 0; + if (poop == 0) { + lookupa = lookup7; + } else if (poop == 5) { + lookupa = lookup3; + } else if (poop == 10){ + lookupa = lookup5; + } + poop += 1; + + // If it's mobile then the static effect is likely too slow, so just do grayscaling. + if (Intra.is_mobile) { + if (poop % 2 == 0) { + FlxG.camera.buffer.lock(); + for (i = 0; i < 180; i++) { // dont want out of bounds? + for (j = 0; j < 160; j++) { + old = FlxG.camera.buffer.getPixel(j, i); + r = (old & 0x00ff0000) >> 16; + g = (old & 0x0000ff00) >> 8; + b = (old & 0x000000ff); + gray = (r + g + b) / 3; + FlxG.camera.buffer.setPixel(j, i, lookup[gray]); + } + } + FlxG.camera.buffer.unlock(); + bm.copyPixels(FlxG.camera.buffer, bm.rect, bm.rect.topLeft); + } else { + FlxG.camera.buffer.copyPixels(bm, bm.rect, bm.rect.topLeft); + } + } else { + if (poop % 3 == 0) { + FlxG.camera.buffer.lock(); + for (i = 0; i < 180; i++) { // dont want out of bounds? + for (j = 0; j < 160; j++) { + old = FlxG.camera.buffer.getPixel(j, i); + r = (old & 0x00ff0000) >> 16; + g = (old & 0x0000ff00) >> 8; + b = (old & 0x000000ff); + gray = (r + g + b) / 3; + qe = lookup_qe[gray]; + FlxG.camera.buffer.setPixel(j, i, lookup[gray]); + old = FlxG.camera.buffer.getPixel(j, i+1); + FlxG.camera.buffer.setPixel(j , i + 1, old + lookupa[qe]); + } + } + FlxG.camera.buffer.unlock(); + bm.copyPixels(FlxG.camera.buffer, bm.rect, bm.rect.topLeft); + } else { + FlxG.camera.buffer.copyPixels(bm, bm.rect, bm.rect.topLeft); + } + } + if (state == S_DIALOGUE) { + dialogue_state.dialogue.draw(); + }*/ + } + GFX_STATIC_ON = false; + // End static effect + + if (Registry.EVENT_FADE_BEGUN && state == S_NORMAL) { + if (downsample_fade.do_effect() == ScreenFade.DONE) { + Registry.EVENT_FADE_OVER = true; + } + } else if (Registry.EVENT_FADE_BEGUN && state == S_JUST_ENTERED_MAP) { + if (upsample_fade.do_effect() == ScreenFade.DONE) { + Registry.EVENT_FADE_OVER = true; + + } + } + /** HOrizontal wavy effect **/ + if ( Registry.GFX_WAVE_EFFECT_ON) { + if (last_time == 0) { + last_time = getTimer(); + } + if (getTimer() - last_time > 60) { + Registry.GFX_WAVE_EFFECT_ON = false; + last_time = 0; + } else { + last_time = getTimer(); + } + Registry.GFX_WAVE_TABLE_INDEX = 0; + Registry.GFX_WAVE_EFFECT_START = (Registry.GFX_WAVE_EFFECT_START + 3) % 180; + Registry.GFX_BUFFER.copyPixels(FlxG.camera.buffer, FlxG.camera.buffer.rect, FlxG.camera.buffer.rect.topLeft); + FlxG.camera.buffer.lock() + for (i = 0; i < 180; i++) { + for (j = 0; j < 160; j++) { + + FlxG.camera.buffer.setPixel32(j , Registry.GFX_WAVE_EFFECT_START, + Registry.GFX_BUFFER.getPixel32(Math.min(Math.max(j + Registry.GFX_WAVE_TABLE[Registry.GFX_WAVE_TABLE_INDEX],0),159), + + Registry.GFX_WAVE_EFFECT_START)); + } + Registry.GFX_WAVE_TABLE_ROLLOVER = ( Registry.GFX_WAVE_TABLE_ROLLOVER + 1) % 15; + if (Registry.GFX_WAVE_TABLE_ROLLOVER == 0) { + Registry.GFX_WAVE_TABLE_INDEX++; + if (Registry.GFX_WAVE_TABLE_INDEX + 1> Registry.GFX_WAVE_TABLE.length) Registry.GFX_WAVE_TABLE_INDEX = 0; + } + Registry.GFX_WAVE_EFFECT_START = (Registry.GFX_WAVE_EFFECT_START + 1) % 180; + } + FlxG.camera.buffer.unlock(); + } + + } + + private var last_time:int = 0; + } +} \ No newline at end of file diff --git a/intra/src/states/PushableFlxState.as b/intra/src/states/PushableFlxState.as new file mode 100644 index 0000000..d5796cc --- /dev/null +++ b/intra/src/states/PushableFlxState.as @@ -0,0 +1,50 @@ +package states +{ + import org.flixel.FlxGroup; + import org.flixel.FlxState; + + /* A totally needless abstraction. oh well */ + public class PushableFlxState extends FlxState + { + public var parent:*; + override public function create():void { + + } + + public function PushableFlxState() { + + } + /** + * Pushes all of this state's ADDED OBJETS onto its parents draw group + * @param _parent The FlxState that is being drawn. + */ + public function push(_parent:FlxState):void { + parent = _parent; + for (var i:int = 0; i < members.length; i++) { + if (members[i] != null) { + _parent.add(members[i]); + } + } + } + /** + * Removes this state's ADDED OBJECTS from its parents draw group + * If you allocate memory that isn't added, don't forget to null it! + * @param FlxState The FlxState that is being drawn. + */ + public function pop(parent:FlxState):void { + for (var i:int = 0; i < members.length; i++) { + if (members[i] != null) { + parent.remove(members[i], true); + + } + } + } + + override public function destroy():void { + super.destroy(); + parent = null; + } + + } + +} \ No newline at end of file diff --git a/intra/src/states/RoamState.as b/intra/src/states/RoamState.as new file mode 100644 index 0000000..c710cc9 --- /dev/null +++ b/intra/src/states/RoamState.as @@ -0,0 +1,618 @@ +package states +{ + import data.CSV_Data; + import data.SoundData; + import data.TileData; + import entity.player.Foot_Overlay; + import entity.player.Player; + import global.*; + import helper.Cutscene; + import helper.DH; + import helper.EventScripts; + import helper.ScreenFade; + import helper.SpriteFactory; + import org.flixel.*; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + + + public class RoamState extends FlxState + { + + + private var keywatch:Keys; + private var stateful_mapXML:XML; + private var stateless_mapXML:XML; + public var map:FlxTilemap; + public var map_bg_2:FlxTilemap = new FlxTilemap(); + public var map_fg:FlxTilemap = new FlxTilemap(); + public var curMapBuf:FlxTilemap; //probably deprecated + public var player:Player; + public var player_group:FlxGroup = new FlxGroup(); + public var entities:Array = new Array(); + public var anim_tiles_group:FlxGroup = new FlxGroup(); + public var statelesses:Array; //deprecated + public var sortables:FlxGroup = new FlxGroup(); + public var bg_sprites:FlxGroup = new FlxGroup(); + public var fg_sprites:FlxGroup = new FlxGroup(); //stuff from ceiling + + + public var state:int = 5; + + public var S_EXITING:int = -1; + public var SWITCH_MAPS:Boolean = false; + private var cleaned_up_before_exit:Boolean = false; + + public var S_NORMAL:int = 0; + public var S_TRANSITION:int = 1; + public var S_PAUSED:int = 2; + public var pause_state:PauseState = new PauseState(); + public var pause_timer:Number = 0.2; + + + public var S_OPEN_TREASURE:int = 3; + public var S_PLAYER_DIED:int = 4; + private var death_fadein:FlxSprite; + private var death_text:FlxBitmapFont; + private var played_death_sound:Boolean = false; + private var start_death_fade_out:Boolean = false; + + public var S_JUST_ENTERED_MAP:int = 5; + public var S_DIRECT_CONTROLS:int = 6; + + + private var S_CUTSCENE:int = 7; + private var cutscene:Cutscene; + + public var S_DIALOGUE:int = 8; + public var load_dialogue:Boolean = false; + public var dialogue_state:DialogueState = new DialogueState(); + public var dialogue_latency:Number = 0.3; + + //header ccrap + [Embed (source = "../res/sprites/menu/autosave_icon.png")] public static var autosave_icon_embed:Class; + public var header_group:FlxGroup = new FlxGroup(); + public var header:FlxSprite = new FlxSprite(0, 0); + public var number_of_keys_text:FlxBitmapFont; + public var autosave_icon:FlxSprite; + + // graphical overlay stuff + public var darkness:FlxSprite = new FlxSprite(0, 0); + private var downsample_fade:ScreenFade; + private var upsample_fade:ScreenFade; + private var black_overlay:FlxSprite = new FlxSprite(0, 0); + + // misc + public var noScrollPt:FlxPoint = new FlxPoint(0, 0); + + public function RoamState() { + + } + + override public function create():void + { + trace("Creating roamstate"); + + // Add the keywatch + if (Registry.keywatch == null) { + Registry.keywatch = new Keys(); + } + + keywatch = Registry.keywatch; + Registry.GAMESTATE = this; + + // Load the background if needed. + + //Determine the proper CSV and tileset to use. + //Load a tilemap and add it. + var csv:String = CSV_Data.getMap(Registry.CURRENT_MAP_NAME); + map = new FlxTilemap(); + TileData.setTileset(Registry.CURRENT_MAP_NAME) + map.loadMap(csv, TileData.Tiles, 16, 16); + map.y += Registry.HEADER_HEIGHT; + TileData.set_tile_properties(map); + make_anim_tiles(map, anim_tiles_group); + add(map); + + map_bg_2.loadMap(CSV_Data.getMap(Registry.CURRENT_MAP_NAME, 2), TileData.Tiles, 16, 16); + map_bg_2.y += Registry.HEADER_HEIGHT; + TileData.set_tile_properties(map_bg_2); + + map_fg.loadMap(CSV_Data.getMap(Registry.CURRENT_MAP_NAME, 3), TileData.Tiles, 16, 16) + map_fg.y += Registry.HEADER_HEIGHT; + + // Make darkness + darkness = new FlxSprite(0, Registry.HEADER_HEIGHT); + darkness.scrollFactor = noScrollPt; + set_darkness(darkness); + + + // Find the entrance and make the player there. Done before + // sprite init because sprites use the player ref. + player = new Player(0, 0, keywatch, darkness, this); + player.foot_overlay = new Foot_Overlay(player); + player.foot_overlay.map = map; + player.x = Registry.ENTRANCE_PLAYER_X; + player.y = Registry.ENTRANCE_PLAYER_Y; + + //Grab the relevant chunk of XML. + initXML(); + //Instantiate and add all sprites to sortables here. + + Registry.reset_subgroups(); //clear from prev state + load_entities(0, 0, true); + + + add(anim_tiles_group); + add(map_bg_2); + add(bg_sprites); + + statelesses = entities; + curMapBuf = map; //for now... + + // Draw player on top of everything. + player.init_player_group(player_group, player, map); + sortables.add(player_group); + add(sortables); + add(fg_sprites); + + //Add fg + add(map_fg); + + + // Make the header + header.loadGraphic(PlayState.Header, false, false, 160, 20); + header.scrollFactor = noScrollPt; + number_of_keys_text = EventScripts.init_bitmap_font("x" + Registry.get_nr_keys().toString(), "left", 42,7, null, "apple_white"); + + autosave_icon = EventScripts.init_autosave_icon(autosave_icon, autosave_icon_embed); + + header_group.add(autosave_icon); + header_group.add(header); + header_group.add(number_of_keys_text); + header_group.add(player.health_bar); + add(header_group); + + //Death entities + + death_fadein = new FlxSprite(0, 0); death_fadein.scrollFactor = noScrollPt; + death_fadein.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, 0xffffffff); + death_fadein.alpha = 0; + + death_text = EventScripts.init_bitmap_font("Keep exploring?", "center", 0, 60, null, "apple_black"); + death_text.visible = false; + + add(death_fadein); + add(death_text); + + // Add the darkness + add(darkness); + + // add screen fade effects + + downsample_fade = new ScreenFade(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, this as FlxState, ScreenFade.T_DS); + upsample_fade = new ScreenFade(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, this as FlxState, ScreenFade.T_US); + black_overlay.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT, 0xff000000); + black_overlay.alpha = 1; + black_overlay.scrollFactor = noScrollPt; + add(black_overlay); + + // Add the death overlay objects. + + + // Play song. + if (Registry.sound_data == null) { + Registry.sound_data = new SoundData(); + } + Registry.sound_data.start_song_from_title(Registry.CURRENT_MAP_NAME); + + // Make the camera follow the player + + FlxG.camera.follow(player); + FlxG.camera.setBounds(0, 0,map.width,map.height + 20, true); + FlxG.camera.deadzone = new FlxRect(50, 80, 160 - 100, 160 - 120); + + } + + override public function update():void + { + /* First, the bare minimum. */ + if (SWITCH_MAPS) state = S_EXITING; + + // State if-then. + if (state == S_NORMAL) { + FlxG.collide(curMapBuf, player); + FlxG.collide(map_bg_2, player); + keywatch.update(); + state_normal(); + + } else if (state == S_PAUSED) { + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + keywatch.update(); + pause_state.update(); + if (pause_state.done) { + pause_state.done = false; + state = S_NORMAL; + remove(pause_state, true); + } + return; + + + + } else if (state == S_DIRECT_CONTROLS) { + pause_state.controls_state.update(); + keywatch.update(); + if (!pause_state.controls_state.updating && ( Registry.keywatch.JUST_PRESSED_PAUSE || FlxG.keys.justPressed("ESCAPE"))) { + state = S_NORMAL; + pause_state.controls_state.pop(this); + } + } else if (state == S_EXITING) { + state_exiting(); + return; + } else if (state == S_JUST_ENTERED_MAP) { + state_just_entered_map(); + return; + } else if (state == S_DIALOGUE) { + player.state = player.S_INTERACT; + keywatch.update(); + dialogue_state.update(); + if (dialogue_state.is_finished) { + player.state = player.S_GROUND; + player.dontMove = false; + dialogue_state.is_finished = false; + state = S_NORMAL; + dialogue_latency = 0.3; + dialogue_state.reset(); + Registry.E_Dialogue_Just_Finished = true; + dialogue_state.pop(this as FlxState); + } + } else if (state == S_OPEN_TREASURE) { + state_open_treasure(); + return; + } else if (state == S_PLAYER_DIED) { + state_player_died(); + } else if (state == S_CUTSCENE) { + + } + + + Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; + check_events(); + // Check entity's distances from player to determine if need to update + // - exists vs. not + + // When enemies refactored, will call update. + super.update(); + } + + private function check_events():void { + if (Registry.EVENT_CHANGE_VOLUME_SCALE) { + if (EventScripts.send_property_to(Registry, "volume_scale", Registry.EVENT_CHANGE_VOLUME_SCALE_TARGET, 0.01)) + Registry.EVENT_CHANGE_VOLUME_SCALE = false; + } + + + if (Registry.E_Load_Cutscene) { + state = S_CUTSCENE; + Registry.E_Load_Cutscene = false; + cutscene = new Cutscene(this); + cutscene.push(this as FlxState); + + } + + } + + private function state_normal():void + { + /* Only pause or enter controls if we're not in the middle of a transition */ + if (pause_timer < 0 && (keywatch.JUST_PRESSED_PAUSE || FlxG.keys.justPressed("ESCAPE"))) { + + Registry.sound_data.play_sound_group(Registry.sound_data.pause_sound_group); + pause_timer = 0.2; + if (FlxG.keys.justPressed("ESCAPE")) { + state = S_DIRECT_CONTROLS; + pause_state.controls_state.push(this); + } else { + state = S_PAUSED; + add(pause_state); + pause_timer = 0.2; + } + } else { + pause_timer -= FlxG.elapsed; + } + //triggered by an npc or whatever + if (dialogue_latency > 0) { + dialogue_latency -= FlxG.elapsed; + } + if (load_dialogue) { + load_dialogue = false; + if (dialogue_latency < 0) { + state = S_DIALOGUE; + player.dontMove = true; + dialogue_state.push(this as FlxState); + + } + } + + if (player.health_bar.cur_health <= 0) { + player.play("die"); + player.ANIM_STATE = player.ANIM_DEAD; + player.alive = false; + var pt:FlxPoint = player.getScreenXY(); + player.scrollFactor = noScrollPt; + player.x = pt.x; + player.y = pt.y; + Registry.sound_data.stop_current_song(); + player.velocity.x = player.velocity.y = 0; + + remove(player, true); + add(player); + state = S_PLAYER_DIED; + } + } + + private function state_exiting():void { + /* Mark all sprites to be cleaned up, reset any events set, + * reset grid state, determine beginning state of the transition */ + if (!cleaned_up_before_exit) { + Registry.reset_events(); + for (var i:int = 0; i < entities.length; i++) { + entities.pop(); + } + + cleaned_up_before_exit = true; + player.dontMove = true; + + if (Registry.E_Enter_Whirlpool_Down) { + + } else { + Registry.EVENT_FADE_BEGUN = true; + } + + if (Registry.FUCK_IT_MODE_ON) { + Registry.EVENT_FADE_OVER = true; + Registry.EVENT_FADE_BEGUN = false; + // black_overlay.alpha = 1; + } + } + /* Fade out the song and other sounds playing */ + Registry.sound_data.current_song.volume -= 0.03; + if (Registry.sound_data.current_song.playing && Registry.sound_data.current_song.volume < 0.05) { + Registry.sound_data.stop_current_song(); + if (Registry.CURRENT_MAP_NAME == "BEACH") { + Registry.sound_data.waves.stop(); + } + } + + /* Do door-specific stuff here (events, etc) */ + if (Registry.CURRENT_MAP_NAME == "BLANK") { + black_overlay.alpha += 0.01; + } else if (Registry.E_Enter_Whirlpool_Down) { + + super.update(); + player.play('whirl'); + if (player.framePixels_y_push != 15) { + player.framePixels_y_push++; + } + if (player.framePixels_y_push >= 15) { + black_overlay.alpha += 0.015; + Registry.EVENT_FADE_BEGUN = true; + } + } else { + black_overlay.alpha += 0.02; + } + + /* Actually make the transition when the overlay is completely + * opaque and the downsampling is done */ + if (black_overlay.alpha >= 0.99 && !Registry.sound_data.current_song.playing && Registry.EVENT_FADE_OVER) { + Registry.EVENT_FADE_OVER = Registry.EVENT_FADE_BEGUN = false; + + DH.reset_scenes_on_map_change(); + Registry.CURRENT_MAP_NAME = Registry.NEXT_MAP_NAME; + Registry.set_is_playstate(Registry.CURRENT_MAP_NAME); + if (Registry.is_playstate) { + //FlxG.switchState(Registry.PLAYSTATE); + FlxG.switchState(new PlayState); + } else { + FlxG.switchState(new RoamState); + } + } + + + } + + private function state_just_entered_map():void { + Registry.EVENT_FADE_BEGUN = true; + black_overlay.alpha -= 0.02; + player.dontMove = true; + if (Registry.FUCK_IT_MODE_ON) { + Registry.EVENT_FADE_BEGUN = false; + Registry.EVENT_FADE_OVER = true; + } + if (black_overlay.alpha <= 0 && Registry.EVENT_FADE_OVER) { + state = S_NORMAL; player.dontMove = false; + Registry.EVENT_FADE_BEGUN = Registry.EVENT_FADE_OVER = false; + } + + super.update(); + } + + + public function state_player_died():void { + Registry.keywatch.update(); + + + + EventScripts.send_property_to(player, "x", 80, 0.5); + EventScripts.send_property_to(player, "y", 100, 0.5); + if (player.frame == player.DEATH_FRAME && !played_death_sound) { + played_death_sound = true; + Registry.sound_data.player_hit_1.play(); + Registry.sound_data.GameOver.play(); + death_text.visible = true; + + death_text.setText("Keep exploring?\n" + "Press " + Registry.controls[Keys.IDX_ACTION_1], true, 0, 0, "center", true); + } + death_fadein.visible = true; + if (death_fadein.alpha < 1) death_fadein.alpha += 0.03; + if (death_fadein.alpha > 0.7) { + death_text.visible = true; + + } + if (start_death_fade_out || (played_death_sound && Registry.keywatch.JP_ACTION_1 && death_text.visible )) { + + start_death_fade_out = true; + black_overlay.alpha += 0.02; + player.alpha -= 0.02; + death_text.alpha -= 0.02; + if (black_overlay.alpha == 1) { + Registry.sound_data.GameOver.stop(); + Registry.sound_data.GameOver = new FlxSound(); + Registry.sound_data.GameOver.loadEmbedded(SoundData.GameOver_Song, false); + Registry.ENTRANCE_PLAYER_X = Registry.checkpoint.x; + Registry.ENTRANCE_PLAYER_Y = Registry.checkpoint.y; + Registry.CURRENT_MAP_NAME = Registry.checkpoint.area; + Registry.CUR_HEALTH = Registry.MAX_HEALTH; + player.health_bar.modify_health(Registry.MAX_HEALTH); + Registry.set_is_playstate(Registry.CURRENT_MAP_NAME); + if (Registry.is_playstate) { + //FlxG.switchState(Registry.PLAYSTATE); + FlxG.switchState(new PlayState); + } else { + FlxG.switchState(new RoamState); + } + } + + } + + } + + private function state_open_treasure():void { + Registry.keywatch.update(); // o_O + state = S_NORMAL; + } + + private function initXML():void { + var map:XML; + for each (map in Registry.statefulXML.map) { + if (map.@name == Registry.CURRENT_MAP_NAME) { + stateful_mapXML = map; break; + } + } + for each (map in Registry.statelessXML.map) { + if (map.@name == Registry.CURRENT_MAP_NAME) { + stateless_mapXML = map; break; + } + } + } + + private function load_entities(gx:int, gy:int, load_all:Boolean = false):void { + if (stateless_mapXML != null) { + add_from_xml(stateless_mapXML.grid,gx,gy,load_all); + } + + if (stateful_mapXML != null) { + add_from_xml(stateful_mapXML.grid,gx,gy,load_all); + } + } + + private function add_from_xml(xml:XMLList,gx:int,gy:int,load_all:Boolean=false):void + { + var prev_len:int = entities.length; + for each (var grid:XML in xml) { + if (load_all || (parseInt(grid.@grid_x) == gx && parseInt(grid.@grid_y) == gy)) { + for (var i:int = 0; i < grid.child("*").length(); i++) { + SpriteFactory.makeSprite(grid.child("*")[i], i, entities, entities, player, this, darkness); + if (entities.length != prev_len) { + while (prev_len < entities.length) { + if (entities[prev_len].hasOwnProperty("gx")) { + entities[prev_len].gx = parseInt(grid.@grid_x); + entities[prev_len].gy = parseInt(grid.@grid_y); + } + sortables.add(entities[prev_len]); + prev_len++; + } + } + } + } + } + } + + + /* Check if the tile is an animated tile, change the tilemap tile if needed, + * and then also implicitly add the animated tile to the group. */ + private function make_anim_tiles(_map:FlxTilemap, _anim_tiles_group:FlxGroup):void { + for (var i:int = 0; i < _map.totalTiles; i++) { + var tile_type:int = _map.getTileByIndex(i); + TileData.make_anim_tile(_anim_tiles_group, Registry.CURRENT_MAP_NAME, tile_type, 16 * (i % _map.widthInTiles), 20 + 16 * int(i / _map.widthInTiles)); + _map.setTileByIndex(i, tile_type, true); + } + } + + + + override public function destroy():void { + + remove(keywatch, true); + // Might change this to use recycling. + entities = null; + statelesses = null; + if (downsample_fade != null) downsample_fade.destroy(); + downsample_fade = null; + if (upsample_fade != null) upsample_fade.destroy(); + upsample_fade = null; + if (pause_state != null) pause_state.destroy(); + pause_state = null; + if (dialogue_state != null) dialogue_state.destroy(); + dialogue_state = null; + if (cutscene != null) cutscene.destroy(); + cutscene = null; + + number_of_keys_text = null; + autosave_icon = null; + curMapBuf = map = map_bg_2 = map_fg = null; + noScrollPt = null; + + + noScrollPt = null + super.destroy(); + } + + private function set_darkness(_darkness:FlxSprite):void { + if (Registry.CURRENT_MAP_NAME == "BEACH") { + _darkness.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS, 0xffef8100); + _darkness.blend = "overlay"; + _darkness.alpha = 1; + _darkness.visible = false; + } else { + _darkness.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, Registry.SCREEN_HEIGHT_IN_PIXELS, 0x00ef8100); + _darkness.blend = "overlay"; + _darkness.alpha = 1; + _darkness.visible = false; + + } + } + override public function draw():void + { + if (Registry.CURRENT_MAP_NAME == "BEACH") { + darkness.fill(0xff000000); + } + // effects and wahtnot + sortables.sort("y_bottom", ASCENDING); + super.draw(); + + if (Registry.EVENT_FADE_BEGUN && state == S_EXITING) { + if (downsample_fade.do_effect() == ScreenFade.DONE) { + Registry.EVENT_FADE_OVER = true; + } + } else if (Registry.EVENT_FADE_BEGUN && state == S_JUST_ENTERED_MAP) { + if (upsample_fade.do_effect() == ScreenFade.DONE) { + Registry.EVENT_FADE_OVER = true; + + } + } + } + + + } + +} \ No newline at end of file diff --git a/intra/src/states/TitleState.as b/intra/src/states/TitleState.as new file mode 100644 index 0000000..3c95b69 --- /dev/null +++ b/intra/src/states/TitleState.as @@ -0,0 +1,1047 @@ +package states +{ + import ca.wegetsignal.nativeextensions.MacJoystickManager; + import data.SoundData; + import entity.gadget.Button; + import entity.interactive.npc.Shadow_Briar; + import entity.player.HealthBar; + import entity.player.Player; + import flash.desktop.NativeApplication; + import flash.filters.BlurFilter; + import flash.net.navigateToURL; + import global.Keys; + import global.Registry; + import helper.Achievements; + import helper.DH; + import helper.EventScripts; + import helper.Joypad_Config_Group; + import helper.ScreenFade; + import org.flixel.*; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import flash.net.URLRequest; + + /** + * the title screen duh + * @author Seagaia + */ + public class TitleState extends FlxState + { + + private var BACK_TEXT_MOBILE:FlxBitmapFont; + private var bg:FlxSprite = new FlxSprite(0, 0); + private var text:FlxBitmapFont; + private var filler:String = " \n"; + private var version:String; + private var version_text:FlxBitmapFont; + private var ad_text:FlxBitmapFont; + private var mac_text:FlxBitmapFont; + + private var DEBUGTEXT:FlxBitmapFont; + + private var selector:FlxSprite; + + private var keywatch:Keys = new Keys(); + + private var state:int = 7; + private var loaded:Boolean = false; + private var S_NEW:int = 0; + private var S_CONTINUE:int = 1; + private var S_DELETE:int = 2; + private var S_NAME_FADE:int = 3; + private var S_NAME_BLUR:int = 4; + private var S_CONTROLS:int = 5; + + private const S_BEGIN:int = 7; + private const S_NEXUS_SCROLL:int = 6; + private var ctr:int = 0; + + + // New stuff + + private var black_overlay:FlxSprite; + private var scrolly_background:FlxSprite; + private var scrolly_background2:FlxSprite; + private var nexus_image:FlxSprite; + private var dark_blend:FlxSprite; + private var glow_blend:FlxSprite; + private var wordmark:FlxSprite; + private var wordmark_white:FlxSprite; + private var press_enter_sprite:FlxSprite; + private var door_glow:FlxSprite; + private var door_spin_1:FlxSprite; + private var door_spin_2:FlxSprite; + private var downsample_fade:ScreenFade; + private var btn:FlxSprite; + + private var health_bar:HealthBar; + private var status_text:FlxBitmapFont; + private var t_briar:FlxSprite; + private var t_young:FlxSprite; + + [Embed(source = "../res/title/door.png")] public static const embed_nexus_image:Class; + [Embed(source = "../res/title/door_glow.png")] public static const embed_door_glow:Class; + [Embed(source = "../res/title/door_spinglow1.png")] public static const embed_spin_glow1:Class; + [Embed(source = "../res/title/door_spinglow2.png")] public static const embed_spin_glow2:Class; + [Embed(source = "../res/title/press_enter.png")] public static const embed_press_enter:Class; + [Embed(source = "../res/title/title_bg.png")] public static const embed_title_bg:Class; + [Embed(source = "../res/title/title_overlay1.png")] public static const embed_overlay_dark:Class; + [Embed(source = "../res/title/title_overlay2.png")] public static const embed_overlay_glow:Class; + [Embed(source = "../res/title/title_text.png")] public static const embed_wordmark:Class; + [Embed(source = "../res/title/title_text_white.png")] public static const embed_wordmark_white:Class; + + + + //end new stuff + + + private var other_fade:FlxSprite = new FlxSprite(0, 0); + private var name_fade:FlxSprite = new FlxSprite(0, 0); + private var name_buffer:FlxBitmapFont; + private var name:String; + private var name_array:Array = new Array(); + private var name_array_nrs:Array = new Array(); + private var name_array_visibilities:Array = new Array(); + private var name_timer_max:Number = 0.04; + private var name_timer:Number = name_timer_max; + private var downscale:int = 2; + + private var transition_out:Boolean = false; + + private var controls_state:ControlsState = new ControlsState(); + + private var rect_fade:FlxSprite; + + private static var do_joypad_config:Boolean = true; + + private var do_window_config:Boolean = false; + private var window_config:FlxSprite; + private var window_words:FlxBitmapFont; + + [Embed (source = "../res/title/titlepicture.png")] public var S_TITLE_PICTURE:Class; + [Embed (source = "../res/title/selector.png")] public static var S_SELECTOR:Class; + [Embed (source = "../res/sprites/screen_config.png")] public static var embed_screen_config:Class; + + private var did_init_fadein:Boolean = false; + + private var mobile_message:FlxBitmapFont; + public function TitleState() { + + } + override public function create():void { + name = DH.lk("title", 3); + name = "Melos Han-Tani\nMarina Kittaka"; + if (Intra.is_release) version = "Demo"; + //BACK_TEXT_MOBILE = EventScripts.init_bitmap_font("Press BACK again\nto exit.\nUnsaved progress\nwill be lost.", "center", 21, 16, null,"apple_white"); + BACK_TEXT_MOBILE = EventScripts.init_bitmap_font(DH.lk("title",17), "center", 21, 16, null,"apple_white"); + rect_fade = new FlxSprite(0, 0); + rect_fade.scrollFactor.x = rect_fade.scrollFactor.y = 0; + rect_fade.makeGraphic(160, 180, 0xff000000); + + + bg.loadGraphic(S_TITLE_PICTURE, false, false, 160, 180); + add(bg); + + Registry.sound_data = new SoundData(); + + Registry.sound_data.start_song_from_title("TITLE"); + if (Intra.is_mobile) { + Registry.sound_data.current_song.volume = 0; + //mobile_message = EventScripts.init_bitmap_font("NOTE\n\nIf you have input\nlag during gameplay,\nreturn to your\nhome screen and\nre-enter Anodyne.\n\nPRESS C TO CONTINUE", "center", 9, 20, null, "apple_white"); + mobile_message = EventScripts.init_bitmap_font(DH.lk("title",16), "center", 9, 20, null, "apple_white"); + } + + btn = new FlxSprite(FlxG.width - 80, FlxG.height - 40); + btn.loadGraphic(Button.S_BUTTON, true, false, 16, 16); + btn.frame = 2; + + + selector = new FlxSprite(); + selector.loadGraphic(PauseState.arrows_sprite, true, false, 7,7); + selector.addAnimation("enabled", [2,3], 6); + selector.play("enabled"); + + //ad_text = EventScripts.init_bitmap_font("Press 'G' to vote for\nAnodyne on\n Steam Greenlight.\nPress 'B' to purchase\n the full version!", "left", 2, 106, null, "apple_white"); + ad_text = EventScripts.init_bitmap_font("Yeah no", "left", 2, 106, null, "apple_white"); + //mac_text = EventScripts.init_bitmap_font("Anodyne supports\nmost controllers.\n\nWill you use one?\n\nYes No\n\nIf so, connect it now.\n\nMove with arrow keys\n\nSelect with\nC, SPACE, or ENTER\n\nDefaulting to yes in\n", "left", 8, 8, null,"apple_white"); + mac_text = EventScripts.init_bitmap_font(DH.lk("title",15), "left", 8, 8, null,"apple_white"); + mac_text.visible = false; + name_fade.makeGraphic(160, 180, 0xff000000); + add(name_fade); + + name_buffer = EventScripts.init_bitmap_font(" ", "center", 38, 88, null, "apple_white"); + name_buffer.setText(name, true, 0, 0, "center", true); + name_buffer.color = 0x758d91; + name_buffer.customSpacingY = 2; + name_buffer.text = " "; + for (var i:int = 0; i < name.length; i++) { + name_array.push(name.charAt(i)); + name_array_nrs.push(i); + name_array_visibilities.push(false); + if (i == 13) { + name_buffer.text += "\n"; + } else { + name_buffer.text += " "; + } + } + name_buffer.x = 80 - name_buffer.width/2; + name_buffer.y = 90; + other_fade.makeGraphic(160, 180, 0xff000000); + + + if (Save.load()) { + //text.setText(filler + "Continue\nNew Game", true, 0, 0, "left", true); + text = EventScripts.init_bitmap_font(" ", "left", 41, 41, null, "apple_white"); + if (DH.isZH()) text = EventScripts.init_bitmap_font(" ", "left", 41, 28, null, "apple_white"); + text.setText(filler + DH.lk("title", 8) + "\n" + DH.lk("title", 9) + "\nBuy Anodyne 2", true, 0, 0, "left", true); + if (DH.isZH()) text.setText(filler + DH.lk("title",8)+"\n"+DH.lk("title",9)+"\nAnodyne 2", true, 0, 0, "left", true); + + selector.x = text.x - selector.width - 1; + selector.y = text.y + 8; + if (DH.isZH()) selector.y += 8; + + loaded = true; + + // Grab steam achievements if we didnt connet last time + Achievements.set_steam_achievements(); + } else { + selector.visible = false; + //text.setText(filler + "Press C\n"+"to start", true, 0, 0, "left", true); + text = EventScripts.init_bitmap_font(" ", "left", 42, 41, null, "apple_white"); + text.setText(filler + DH.lk("title", 5) + " " + Registry.controls[Keys.IDX_ACTION_1] + "\n" + DH.lk("title", 6) + "\nPress X to\nbuy Anodyne 2 ", true, 0, 0, "left", true); + if (DH.isZH()) text.setText(filler + DH.lk("title",5)+" "+Registry.controls[Keys.IDX_ACTION_1]+"\n"+DH.lk("title",6)+"\nX = Buy\nAnodyne 2", true, 0, 0, "left", true); + loaded = false; + Registry.controls = Registry.default_controls; + + } + + + text.color = 0x758d91; + version = DH.lk("title", 7) + " 1.55S"; + version_text = EventScripts.init_bitmap_font(version, "left", 2, 156, null, "apple_white"); + version_text.visible = false; + + if (Intra.is_ouya) { + Registry.controls = new Array("UP","DOWN","LEFT","RIGHT","ENTER","T","Z","Y"); + } + keywatch.x = 2000; + add(keywatch); + rect_fade.y = -180; + add(rect_fade); + Registry.keywatch = keywatch; + + + + + black_overlay = new FlxSprite(0, 0); + black_overlay.makeGraphic(160, 180, 0xff000000); + + scrolly_background = new FlxSprite(0, 0, embed_title_bg); + scrolly_background2 = new FlxSprite(0, -320, embed_title_bg); + + dark_blend = new FlxSprite(0, 0, embed_overlay_dark); + dark_blend.blend = "overlay"; + + glow_blend = new FlxSprite(0, 0, embed_overlay_glow); + glow_blend.blend = "overlay"; + glow_blend.visible = false; + + door_glow = new FlxSprite(0, 0, embed_door_glow); + door_glow.visible = false; + door_spin_1 = new FlxSprite(0, 0, embed_spin_glow1); + door_spin_2 = new FlxSprite(0, 0, embed_spin_glow2); + door_spin_1.visible = door_spin_2.visible = false; + + press_enter_sprite = new FlxSprite(0, 0, embed_press_enter); + press_enter_sprite.visible = false; + + wordmark = new FlxSprite(16, 16, embed_wordmark); + wordmark.visible = false; + wordmark_white = new FlxSprite(16, 16, embed_wordmark_white); + wordmark_white.visible = false; + + nexus_image = new FlxSprite(0, 180, embed_nexus_image); + + + downsample_fade = new ScreenFade(160, 180, this, ScreenFade.T_DS); + + add(scrolly_background); + add(scrolly_background2); + add(nexus_image); + add(door_glow); + add(door_spin_1); + add(door_spin_2); + + add(name_buffer); + add(wordmark); + add(wordmark_white); + add(dark_blend); + add(glow_blend); + add(press_enter_sprite); + add(black_overlay); + + add(text); + add(selector); + add(version_text); + if (Intra.is_release) { + add(ad_text); + } + add(mac_text); + if (Intra.is_mobile) { + add(mobile_message); + add(btn); + } + + status_text = EventScripts.init_bitmap_font(" ", "left", 4, 76,null,"apple_white"); + if (loaded) { + var playtime_dat:int = 0; + playtime_dat = Registry.playtime; + var hrs:int = int(playtime_dat / 3600); + + if (hrs >= 10) { + status_text.text = int(playtime_dat / 3600).toString() + ":"; + } else { + status_text.text = "0" + int(playtime_dat / 3600).toString() + ":"; + } + playtime_dat -= 3600 * hrs; + + var mins:int = int(playtime_dat / 60); + if (mins >= 10) { + status_text.text += int(playtime_dat / 60).toString() + ":"; + } else { + status_text.text = status_text.text + "0" + int(playtime_dat / 60).toString() + ":"; + } + playtime_dat -= 60 * mins; + + if (playtime_dat >= 10) { + status_text.text += playtime_dat.toString(); + } else { + status_text.text = status_text.text + "0"+ playtime_dat.toString(); + } + + //status_text.text += "\n" + Registry.death_count.toString() + " deaths\n" + Registry.nr_growths.toString() + " cards"; + if (DH.language_type == DH.LANG_ja) { + status_text.text += "\n死亡" + Registry.death_count.toString() +"回\nカード" + Registry.nr_growths.toString() + "枚"; + + } else { + status_text.text += "\n" + Registry.death_count.toString() +" " + DH.lk("title", 13) + " \n" + Registry.nr_growths.toString() + " " + DH.lk("title", 14); + } + } + + var hby:int = 80; + if (DH.isZH()) hby = 92; + if (loaded) { + health_bar = new HealthBar(150, hby, Registry.MAX_HEALTH); + } else { + health_bar = new HealthBar(150,hby, 6); + health_bar.exists = false; + } + t_briar = new FlxSprite; t_briar.exists = false; + t_young = new FlxSprite; t_young.exists = false; + + if (Registry.GE_States[Registry.GE_BRIAR_BOSS_DEAD]) { + t_briar.x = 2; + t_briar.y = 2; + t_briar.loadGraphic(Shadow_Briar.embed_briar, true, false, 16, 16); + t_briar.exists = true; t_briar.visible = false; + add(t_briar); + } + if (Registry.nr_growths > 48) { + t_young.x = 160 - 2 - 16; + t_young.y = 2; + t_young.loadGraphic(Player.Player_Sprite, true, false, 16, 16); + t_young.exists = true; t_young.visible = false; + add(t_young); + } + + health_bar.visible = status_text.visible = ad_text.visible = version_text.visible = text.visible = selector.visible = false; + add(status_text); add(health_bar); + + + add(other_fade); + other_fade.alpha = 0; + + // Only bother with this when not on the computer + if (!Intra.did_window_config && !Intra.is_mobile) { + //window_words = EventScripts.init_bitmap_font("Please use the\narrow keys to resize\nthe window until\nyou cannot see\nany black around\n the borders.\n\nPress "+Registry.controls[Keys.IDX_ACTION_1]+"\nwhen done.", "center", 10, 10, null, "apple_white"); + window_words = EventScripts.init_bitmap_font(DH.lk("title",0)+" "+Registry.controls[Keys.IDX_ACTION_1]+" "+DH.lk("title",1), "center", 10, 10, null, "apple_white"); + + window_config = new FlxSprite(-3,-3); + window_config.loadGraphic(embed_screen_config, false, false, 166, 186); + add(window_config); + add(window_words); + Intra.force_window(3); + do_window_config = true; + // Otherwise do a Left or Right hand config + } else if (Intra.is_mobile) { + + } + + DEBUGTEXT = EventScripts.init_bitmap_font(Achievements.DEBUG_TEXT, "left", 0, 0, null, "apple_white"); + DEBUGTEXT.visible = true; + //add(DEBUGTEXT); + DEBUGTEXT.text += Main.debugstring; + + BACK_TEXT_MOBILE.alpha = 0; + add(BACK_TEXT_MOBILE); + } + + public function name_fade_state():void { + other_fade.alpha -= 0.008; + name_timer -= FlxG.elapsed; + if (name_timer < 0) { + name_buffer.text = " "; + name_timer = name_timer_max; + var idx:int = int(Math.random() * name_array_nrs.length); + name_array_visibilities[13] = true; + name_array_visibilities[name_array_nrs[idx]] = true; + name_array_nrs.splice(idx, 1); + for (var i:int = 0; i < name.length; i++) { + if (name_array_visibilities[i]) { + name_buffer.text += name_array[i]; + } else { + name_buffer.text += " "; + } + } + } + + if (name_array_nrs.length == 0 ) { + state = S_NAME_BLUR; + } + return; + } + public function name_blur_state():void { + + other_fade.alpha -= 0.008; + name_buffer.alpha -= 0.006; + name_timer -= FlxG.elapsed; + name_timer_max = 0.1; + if (name_timer < 0 && name_buffer.alpha < 0.64 ) { + name_timer = name_timer_max; + name_buffer.pixels.applyFilter(name_buffer.framePixels, name_buffer.framePixels.rect, name_buffer.framePixels.rect.topLeft, new BlurFilter(2,2, 1)); + } + + name_buffer.dirty = true; + if (name_buffer.alpha < 0.2) { + name_fade.alpha -= 0.03; + if (name_fade.alpha < 0.03) { + state = S_NEXUS_SCROLL; + if (loaded) { + //state = S_CONTINUE; + } else { + //state = S_NEW; + } + } + } + } + + override public function draw():void + { + + super.draw(); + downsample_fade.rate = 15; + if (state == S_NEXUS_SCROLL && ctr == 2) { + black_overlay.alpha += 0.006; + if (downsample_fade.do_effect() == ScreenFade.DONE) { + black_overlay.alpha += 0.01; + if (black_overlay.alpha == 1) { + t_young.visible = t_briar.visible = health_bar.visible = status_text.visible = ad_text.visible = version_text.visible = text.visible = selector.visible = true; + if (loaded) { + state = S_CONTINUE; + } else { + selector.visible = false; + state = S_NEW; + } + } + } + } + } + + private var reeeeeesize:Boolean = false; // Force the game to be windowed if we need to do manual window resize + private var window_during_joyconfig:Boolean = false; // Force the game to be windowed if we need to do manual window resize + private var window_to_joyconfig_delay:Number = 0; + private var window_to_joyconfig_happened:Boolean = false; + private static var do_prevent_mac_joy_error:Boolean = false; + private var mac_selector_state:int = 0; + private var mac_timeout:Number = 10; + public static var restart_on_mobile_enter:Boolean = false; + public static var mobile_message_done:Boolean = false; + + private var t_mobile_back:Number = 0; + override public function update():void { + + if (Registry.MOBILE_ASK_TO_EXIT_WITH_BACK) { + t_mobile_back = 2; + Registry.MOBILE_ASK_TO_EXIT_WITH_BACK = false; + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = true; + } + if (t_mobile_back > 0 ) { + BACK_TEXT_MOBILE.alpha = t_mobile_back / 2.0; + t_mobile_back -= FlxG.elapsed; + if (t_mobile_back < 0) { + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = false; + } + } + + if (Intra.is_mobile) { + + + + if (did_init_fadein == false) { + Registry.sound_data.current_song.volume += 0.0025; + if (Registry.sound_data.current_song.volume == 1) { + Registry.sound_data.current_song.play(); + did_init_fadein = true; + } + } + + } + if (restart_on_mobile_enter) { + restart_on_mobile_enter = false; + Registry.sound_data.start_song_from_title("TITLE"); + } + + + if (Intra.is_mobile) { + if (mobile_message_done == false) { + if (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2) { + mobile_message_done = true; + mobile_message.visible = false; + btn.visible = false; + } + Registry.keywatch.update(); + return; + } + } + + if (FlxG.keys.THREE && FlxG.keys.D && FlxG.keys.justPressed("T")) { + DEBUGTEXT.visible = !DEBUGTEXT.visible; + } + //if (Intra.is_release) { + //if (FlxG.keys.justPressed("G")) { + //Achievements.unlock(Achievements.Greenlit); + //FlxU.openURL("http://steamcommunity.com/sharedfiles/filedetails/?id=92921739"); + //} + // + //if (FlxG.keys.justPressed("B")) { + //Achievements.unlock(Achievements.Website); + //FlxU.openURL("http://www.anodynegame.com"); + //} + //} + if (Achievements.IS_STEAM) { + //DEBUGTEXT.text = Achievements.DEBUG_TEXT; + } + + if (Intra.is_ouya) { + //DEBUGTEXT.text = Main.debugstring; + } else if (Intra.is_mobile && !Intra.is_ios) { + //DEBUGTEXT.text = Main.debugstring; + } + + if (do_window_config) { + if (reeeeeesize == false) { + reeeeeesize = true; + trace("Windowing for window config."); + Intra.force_window(3); + } + window_config_logic(keywatch); + if (keywatch.JP_ACTION_1 || keywatch.JP_ACTION_2) { + do_window_config = false; + remove(window_config, true); + remove(window_words, true); + trace("Exiting window config, fullscreening."); + Intra.scale_factor = FlxG.stage.fullScreenHeight / 180; + Intra.force_scale = true; + Intra.scale_ctr = Intra.SCALE_TYPE_INT; + window_to_joyconfig_delay = 1; + reeeeeesize = false; + } + super.update(); + return; + } + + // prevent bad controllers from crashing the extension (and thus the game) + if (!do_prevent_mac_joy_error && Intra.IS_MAC && Main.fixedjoy) { + + mac_text.visible = true; + //mac_text.text = "Anodyne supports\nmost controllers.\n\nWill you use one?\n\nYes No\n\nIf so, connect it now.\n\nMove with arrow keys\n\nSelect with\nC, SPACE, or ENTER\n\nDefaulting to YES in\n" + mac_timeout.toFixed(2); + mac_text.text = DH.lk("title",15) + mac_timeout.toFixed(2); + mac_timeout -= FlxG.elapsed; + + selector.visible = true; + + if (mac_selector_state == 0) { + selector.x = mac_text.x + 32; + selector.y = mac_text.y + 40; + if (Registry.keywatch.JP_LEFT) { + mac_selector_state = 1; + } else if (FlxG.keys.justPressed("C") || FlxG.keys.justPressed("SPACE") || FlxG.keys.justPressed("ENTER")) { + do_prevent_mac_joy_error = true; + mac_text.visible = false; + window_to_joyconfig_delay = 1; + selector.visible = false; + } + } else { // yes + selector.x = mac_text.x - 6 ; + selector.y = mac_text.y + 40; + + if (Registry.keywatch.JP_RIGHT) { + mac_selector_state = 0; + } else if (FlxG.keys.justPressed("C") || FlxG.keys.justPressed("SPACE") || FlxG.keys.justPressed("ENTER")) { + do_prevent_mac_joy_error = true; + Main.mac_joy_manager = new MacJoystickManager(); + Main.macmanexists = true; + mac_text.visible = false; + window_to_joyconfig_delay = 1; + selector.visible = false; + } + } + + if (mac_timeout < 0) { + do_prevent_mac_joy_error = true; + Main.mac_joy_manager = new MacJoystickManager(); + Main.macmanexists = true; + mac_text.visible = false; + window_to_joyconfig_delay = 1; + selector.visible = false; + + } + + super.update(); + return; + } + + if (Keys.has_joypad) { + if (do_joypad_config) { + + if (window_to_joyconfig_delay > 0) { + window_to_joyconfig_happened = true; + window_to_joyconfig_delay -= FlxG.elapsed; + super.update(); + return; + } + + // If we did the window config then we shouldn't fullscreen + if (false == reeeeeesize) { + trace("Windowing for joypad config."); + reeeeeesize = true; + Intra.force_window(3); + } + + if (Registry.joy_grp == null) { + Registry.joy_grp = new Joypad_Config_Group(); + add(Registry.joy_grp); + } + + if (Registry.joy_grp.is_done()) { + trace("Title joypad config done"); + do_joypad_config = false; + remove(Registry.joy_grp, true); + window_to_joyconfig_delay = 1; + if (window_to_joyconfig_happened) { + trace("Fullscreening from joypad config"); + Intra.scale_factor = FlxG.stage.fullScreenHeight / 180; + Intra.force_scale = true; + Intra.scale_ctr = Intra.SCALE_TYPE_INT; + } else { + Save.load(); + // Prevent zerooing out the array from loading a game that + // has no joy bindings, if we set joy bindings previously + if (Joypad_Config_Group.REAL_JOYBINDS != null) { + Registry.joybinds = Joypad_Config_Group.REAL_JOYBINDS; + } + } + + } + super.update(); + return; + } + } + + + if (scrolly_background.y <= -320) { + scrolly_background.y = 180; + } + if (scrolly_background2.y <= -320) { + scrolly_background2.y = 180; + } + if (state == S_BEGIN) { + switch (ctr) { + case 0: + scrolly_background.velocity.y = scrolly_background2.velocity.y = -30; + black_overlay.alpha -= 0.0079; + if (black_overlay.alpha == 0) { + ctr = 0; + state = S_NAME_FADE; + } + break; + } + + if (window_to_joyconfig_delay < 0) { + do_skip(); + } else { + window_to_joyconfig_delay -= FlxG.elapsed; + } + super.update(); + return; + } else if (state == S_NEXUS_SCROLL) { + switch(ctr) { + case 0: + nexus_image.velocity.y = -20; + + if (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2) { + nexus_image.y = 180 - nexus_image.height; + } + if (nexus_image.y + nexus_image.height <= 180) { + nexus_image.y = 180 - nexus_image.height; + nexus_image.velocity.y = 0; + FlxG.flash(0xffffffff, 1.5); + glow_blend.visible = true; + dark_blend.visible = false; + + door_glow.visible = true; + + door_glow.x = (160 - 64) / 2; + door_glow.y = nexus_image.y + 17; + + door_spin_1.visible = true; + door_spin_1.x = door_spin_2.x = door_glow.x; + door_spin_1.y = nexus_image.y; + door_spin_1.blend = "screen"; + door_spin_2.angularVelocity = -90; + + door_spin_2.visible = true; + door_spin_2.y = nexus_image.y; + door_spin_2.blend = "screen"; + door_spin_1.angularVelocity = 90; + + wordmark.visible = wordmark_white.visible = true; + + press_enter_sprite.visible = true; + + press_enter_sprite.x = (160 - press_enter_sprite.width) / 2; + press_enter_sprite.y = 160; + + name_timer = 0; + + ctr++; + } + break; + //17 + case 1: + wordmark_white.alpha -= 0.0033; + + name_timer += FlxG.elapsed; + if (press_enter_sprite.visible) { + if (name_timer > 1) { + name_timer = 0; + press_enter_sprite.visible = false; + } + } else { + if (name_timer > 0.75) { + name_timer = 0; + press_enter_sprite.visible = true; + } + } + + if (glow_blend.alive) { + glow_blend.alpha -= 0.001; + if (glow_blend.alpha <= 0.7) { + glow_blend.alive = false; + } + } else { + glow_blend.alpha += 0.001; + if (glow_blend.alpha >= 1) { + glow_blend.alive = true; + } + } + + if (door_spin_1.alive) { + door_spin_1.alpha -= 0.003; + if (door_spin_1.alpha <= 0.5) { + door_spin_1.alive = false; + } + } else { + door_spin_1.alpha += 0.003; + if (door_spin_1.alpha >= 1) { + door_spin_1.alive = true; + } + } + + if (door_spin_2.alive) { + door_spin_2.alpha -= 0.0015; + if (door_spin_2.alpha <= 0.7) { + door_spin_2.alive = false; + } + } else { + door_spin_2.alpha += 0.0015; + if (door_spin_2.alpha >= 1) { + door_spin_2.alive = true; + } + } + + if (FlxG.keys.justPressed("ENTER") || Registry.keywatch.JUST_PRESSED_PAUSE || Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2) { + ctr++; + downsample_fade.timer_max = 0.03; + } + break; + case 2: + + selector.x = text.x - selector.width - 1; + selector.y = text.y + (text.characterHeight+text.customSpacingY); + black_overlay.alpha += 0.002; + break; + } + super.update(); + return; + } + + + if (transition_out) { + other_fade.alpha += 0.012; + if (other_fade.alpha >= 1) { + + if (state == S_CONTINUE) { + Registry.CURRENT_MAP_NAME = Registry.checkpoint.area; + Registry.set_is_playstate(Registry.CURRENT_MAP_NAME); + Registry.ENTRANCE_PLAYER_X = Registry.checkpoint.x; + Registry.ENTRANCE_PLAYER_Y = Registry.checkpoint.y; + + if (Registry.is_playstate) { + FlxG.switchState(new PlayState); + Registry.MOBILE_OKAY_TO_EXIT_WITH_BACK = false; + } else { + FlxG.switchState(new RoamState); + } + } else { + FlxG.switchState(new IntroScene); + Registry.MAX_HEALTH = Registry.CUR_HEALTH = 6; + Registry.CURRENT_MAP_NAME = "BLANK"; + Registry.checkpoint.x = Registry.ENTRANCE_PLAYER_X = 23; + Registry.checkpoint.y = Registry.ENTRANCE_PLAYER_Y = 130; + Registry.checkpoint.area = "BLANK"; + } + } + super.update(); + return; + } + + if (state == S_NAME_FADE) { + do_skip(); + name_fade_state(); + super.update(); + return; + } else if (state == S_NAME_BLUR) { + do_skip(); + name_blur_state(); + super.update(); + return; + + } + + if (keywatch.JP_ACTION_1) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + } + + if (keywatch.JP_DOWN || keywatch.JP_UP) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group); + } + + switch (state) { + case S_CONTROLS: + keywatch.update(); + controls_state.update(); + if (FlxG.keys.justPressed("ESCAPE") || (keywatch.JUST_PRESSED_PAUSE && !controls_state.updating)) { + controls_state.updating = false; + controls_state.pop(this as FlxState); + if (loaded) { + state = S_CONTINUE; + } else { + state = S_NEW; + } + } + return; + + case S_NEW: + if (keywatch.JP_ACTION_1 || FlxG.keys.justPressed("ENTER")) { + transition_out = true; + rect_fade.velocity.y = 80; + } + if (keywatch.JP_ACTION_2) { + navigateToURL(new URLRequest("https://store.steampowered.com/app/877810/Anodyne_2_Return_to_Dust/")); + } + /* Check for ESC input to bring up controls */ + if (FlxG.keys.justPressed("ESCAPE")) { + state = S_CONTROLS; + controls_state.change_text(); + controls_state.push(this as FlxState); + } + break; + case S_CONTINUE: + var lineHeightCont:int = text.characterHeight + text.customSpacingY; + if (keywatch.JP_DOWN) { + + //some_stupid_shit(downscale); + downscale++; + if (selector.y < text.y + 3*lineHeightCont) + selector.y += lineHeightCont; + } else if (keywatch.JP_UP) { + if (selector.y > text.y + lineHeightCont) + selector.y -= lineHeightCont; + } + if (keywatch.JP_ACTION_1 || FlxG.keys.justPressed("ENTER")) { + if (selector.y == text.y + lineHeightCont) { + + rect_fade.velocity.y = 80; + transition_out = true; + } else if (selector.y == text.y + 2*lineHeightCont) { + state = S_DELETE; + //text.text = filler+"Are you sure?\nNo\nYes"; + text.text = filler + DH.lk("title", 10); + + } else { + navigateToURL(new URLRequest("https://store.steampowered.com/app/877810/Anodyne_2_Return_to_Dust/")); + } + } + + /* Check for ESC input to bring up controls */ + if (FlxG.keys.justPressed("ESCAPE")) { + state = S_CONTROLS; + controls_state.push(this as FlxState); + } + break; + case S_DELETE: + + var lineHeightDel:int = text.characterHeight + text.customSpacingY; + if (keywatch.JP_DOWN) { + if (selector.y < text.y + 3*lineHeightDel) + selector.y += lineHeightDel; + } else if (keywatch.JP_UP) { + if (selector.y > text.y + 2*lineHeightDel) + selector.y -= lineHeightDel; + } + + if (keywatch.JP_ACTION_1 || FlxG.keys.justPressed("ENTER")) { + selector.x = text.x - selector.width - 1; + if (selector.y == text.y + 2*lineHeightDel) { + state = S_CONTINUE; + selector.x = text.x - selector.width - 1; + //text.setText(filler + "Continue\nNew Game", true, 0, 0, "left", true); + text.setText(filler + DH.lk("title", 8) + "\n" + DH.lk("title", 9) + "\nBuy Anodyne 2", true, 0, 0, "left", true); + if (DH.isZH()) text.setText(filler + DH.lk("title",8)+"\n"+DH.lk("title",9)+"\nAnodyne 2", true, 0, 0, "left", true); + selector.y -= lineHeightDel; + } else { + selector.y -= lineHeightDel; + if (text.text == filler+DH.lk("title",11)) { + selector.x = text.x - selector.width - 1; + //text.text = filler+"No going back!\nForget it\nI know" + text.text = filler + DH.lk("title", 12); + } else if (text.text == filler + DH.lk("title", 12)) { + Registry.embed2saveXML(); //Reset this current session's XML. + Registry.controls = Registry.default_controls; + Save.delete_save(); + status_text.visible = false; + health_bar.visible = false; + t_young.visible = t_briar.visible = false; + //text.setText(filler + "Press C" + "\nto start", true, 0, 0, "left", true); + text.setText(filler + DH.lk("title",5)+" "+Registry.controls[Keys.IDX_ACTION_1]+"\n"+DH.lk("title",6), true, 0, 0, "left", true); + state = S_NEW; + selector.visible = false; + + //FlxG.switchState(new FirstRoomState); + } else { + text.text = filler+DH.lk("title",11); + + } + } + } + break; + + } + super.update(); + //Add a glitch effect to the words, or a blur effect. Make it blink too. + //Particles in the background? + } + + override public function destroy():void { + remove(keywatch, true); + bg = null; + controls_state.destroy(); + controls_state = null; + keywatch = null; + name_buffer = null; + name_fade = null; + other_fade = null; + rect_fade = null; + version_text = null; + selector = null; + text = null; + + black_overlay = null; + downsample_fade = null; + scrolly_background = null; + nexus_image = null; + door_glow = null; + door_spin_1 = null; + door_spin_2 = null; + press_enter_sprite = null; + wordmark = null; + wordmark_white = null; + + health_bar = null; + mac_text = null; + status_text = null; + DEBUGTEXT = null; + BACK_TEXT_MOBILE = null; + + super.destroy(); + } + + /** + * Based on keypresses, + * change the size of the windowed windwos + */ + public static function window_config_logic(_keywatch:Keys):void + { + if (_keywatch.JP_DOWN) { + if (Intra.frame_y_px < 50) { + Intra.frame_y_px++; + } + } else if (_keywatch.JP_UP) { + if (Intra.frame_y_px > 0) { + Intra.frame_y_px--; + } + } + + if (_keywatch.JP_RIGHT) { + if (Intra.frame_x_px < 50) { + Intra.frame_x_px++; + } + } else if (_keywatch.JP_LEFT) { + if (Intra.frame_x_px > 0) { + Intra.frame_x_px--; + } + } + + if (_keywatch.JP_RIGHT || _keywatch.JP_LEFT || _keywatch.JP_DOWN || _keywatch.JP_UP) { + NativeApplication.nativeApplication.activeWindow.width = 480 + Intra.frame_x_px; + NativeApplication.nativeApplication.activeWindow.height = 540 + Intra.frame_y_px; + } + + } + + private function do_skip():void + { + if (FlxG.keys.justPressed("ENTER") || Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2) { + state = S_NEXUS_SCROLL; + ctr = 0; + wordmark_white.alpha = 1; + nexus_image.y = 180 - nexus_image.height; + name_buffer.visible = false; + dark_blend.visible = false; + glow_blend.visible = true; + black_overlay.alpha = 0; + } + } + } + +} \ No newline at end of file diff --git a/intra/src/states/noairPauseState.as b/intra/src/states/noairPauseState.as new file mode 100644 index 0000000..81852ad --- /dev/null +++ b/intra/src/states/noairPauseState.as @@ -0,0 +1,1800 @@ +package states +{ + import data.SoundData; + import entity.gadget.Treasure; + import entity.interactive.NPC; + import entity.interactive.npc.Trade_NPC; + import flash.desktop.NativeApplication; + import helper.Achievements; + //import flash.desktop.NativeApplication; + import helper.DH; + import helper.EventScripts; + import org.flixel.FlxBasic; + import org.flixel.FlxGroup; + import org.flixel.FlxPoint; + import org.flixel.FlxSound; + import org.flixel.FlxSprite; + import org.flixel.FlxG; + import entity.*; + import entity.player.*; + import global.Registry; + import global.Keys; + import org.flixel.FlxState; + import org.flixel.plugin.photonstorm.FlxBitmapFont; + import org.flixel.system.FlxAnim; + + public class PauseState extends PushableFlxState + { + + + + /* Position of these two are set in PlayState */ + + + + /** NEW!!!!!!! **/ + + + private var no_scroll_point:FlxPoint = new FlxPoint(0, 0); + public var current_substate_visible:Boolean = false; + private var init_parent:Boolean = false; + + public var state:int = 0; + private var s_browse:int = 0; + private var s_map:int = 1; // Probably not used. + private var s_equip:int = 2; + private var s_cards:int = 3; + private var s_save:int = 4; + private var s_settings:int = 5; + private var s_dialogue:int = 6; + private var s_cheatz:int = 7; + private var s_secretz:int = 8; + public var done:Boolean = false; + public var exit_latency:Number = 0.5; + + private var load_dialogue:Boolean = false; + private var t_d:Number = 0; + private var tm_d:Number = 0.2; + + private var text_1:FlxBitmapFont; + private var text_2:FlxBitmapFont; + private var text_3:FlxBitmapFont; + + private var base_group:FlxGroup = new FlxGroup; + private var base_menu:FlxSprite; + private var text_categories:FlxBitmapFont; + private var text_info:FlxBitmapFont; + private var base_index:int = 0; + private var max_base_index:int = 4; + private var menu_select_inactive:FlxSprite; + private var menu_select_active:FlxSprite; + + [Embed (source = "../res/sprites/menu/arrows.png")] public static var arrows_sprite:Class; + [Embed (source = "../res/sprites/menu/menu_select_active.png")] public static var men_sel_act:Class; + [Embed (source = "../res/sprites/menu/menu_select_inactive.png")] public static var men_sel_inact:Class; + [Embed (source = "../res/sprites/menu/menu_bg.png")] public static var menu_bg_sprite:Class; + + + + private var selectors:FlxGroup = new FlxGroup(4); + + public var minimap:MinimapState; + private var map_cursor_idx:int = 0; + private var map_ctr:int = 0; + + private var legend_entrance:FlxSprite; + private var legend_cur:FlxSprite; + private var legend_entrance_b:FlxSprite; + private var legend_cur_b:FlxSprite; + + [Embed (source = "../res/sprites/menu/equipped_icon.png")] public static var equipped_icon:Class; + [Embed (source = "../res/sprites/menu/none_icon.png")] public static var none_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/long_icon.png")] public static var long_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/wide_icon.png")] public static var wide_icon_sprite:Class; + [Embed (source = "../res/sprites/menu/transformer_icon.png")] public static var transformer_icon_sprite:Class; + + + private var equip_overlay:FlxSprite; + private var equip_boxes:FlxGroup = new FlxGroup(4); + private var equip_cursor_idx:int = 0; + private var equip_icon:FlxSprite; + private var key_icons:FlxGroup = new FlxGroup(3); + private var trade_item:FlxSprite; + private var jump_shoes:FlxSprite; + + + [Embed (source = "../res/sprites/menu/card_empty.png")] public static var card_empty_sprite:Class; + [Embed (source = "../res/sprites/menu/card_1.png")] public static var card_1_sprite:Class; + [Embed (source = "../res/sprites/menu/card_sheet.png")] public static var card_sheet_embed:Class; + + private var cards:FlxGroup = new FlxGroup(12); + private var cur_cards_pg:int = 0; + private var cards_cursor_idx:int = 0; + + private var save_cursor_idx:int = 0; + + [Embed (source = "../res/sprites/menu/volume_bar.png")] public static var volume_bar_embed:Class; + + private var volume_bar:FlxSprite; + private var volume_bar_overlay:FlxSprite = new FlxSprite; + private var volume_bar_bg:FlxSprite; + private var doing_window_config:Boolean = false; + public var controls_state:ControlsState = new ControlsState; + private var window_config:FlxSprite; + private var window_words:FlxBitmapFont; + private var settings_cursor_idx:int = 0; + private var ctr_settings:int = 0; + + private var trophies:FlxGroup; + + private var playtime_text:FlxBitmapFont; + + + + + public function PauseState() + { + create(); + } + + override public function add(Object:FlxBasic):FlxBasic + { + if (Registry.GAMESTATE != null) { + Registry.GAMESTATE.dialogue_state.set_dialogue_box(); + } + + if (Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + text_categories.text = "Map\n\nItems\n\nCards\n\nSave\n\nConfig\n\n???"; + } + if (trophies != null) { + for (var i:int = 0; i < trophies.length; i++) { + set_trophy_vis(trophies, i); + } + } + text_info.text = Registry.controls[Keys.IDX_ACTION_1] + ":Select " + Registry.controls[Keys.IDX_ACTION_2] + ":Back"; + return super.add(Object); + } + + override public function draw():void + { + + + super.draw(); + } + override public function destroy():void + { + if (minimap != null) minimap.destroy(); + minimap = null; + + if (controls_state != null) controls_state.destroy(); + controls_state = null; + + /** NEW **/ + + /* Call destroy on and null all added Flixel objects */ + /* Pushable flxstates have all of their added objects removed from here*/ + super.destroy(); + + /* Remove refs */ + playtime_text = null; + text_categories = null; + text_info = null; + text_1 = null; + text_2 = null; + text_3 = null; + window_words = null; + window_config = null; + base_menu = null; + legend_entrance = legend_cur = null; + selectors = null; + equip_overlay = null; + equip_boxes = null; + key_icons = null; + trade_item = null; + jump_shoes = null; + cards = null; + legend_cur_b = legend_entrance_b = null; + volume_bar_bg = null; + + volume_bar = null; + volume_bar_overlay = null; + + base_group = null; + + trophies = null; + } + + override public function create():void { + /* Begin new logic */ + var i:int = 0; + current_substate_visible = false; + /* COMMON OBJECTS */ + base_menu = new FlxSprite(0, Registry.HEADER_HEIGHT); + base_menu.loadGraphic(menu_bg_sprite); + base_menu.scrollFactor.x = base_menu.scrollFactor.y = 0; + + text_categories = EventScripts.init_bitmap_font("Map\n\nItems\n\nCards\n\nSave\n\nConfig", "left", 10, 13 + Registry.HEADER_HEIGHT, null, "apple_white"); + text_categories.color = 0xffffff; + text_categories.drop_shadow = true; + + + + text_info = EventScripts.init_bitmap_font(Registry.controls[Keys.IDX_ACTION_1] + ":Select " + Registry.controls[Keys.IDX_ACTION_2] + ":Back", "left", 2, 150 + Registry.HEADER_HEIGHT, null, "apple_white"); + text_info.color = 0x909ab1; + + //11323b + text_1 = EventScripts.init_bitmap_font(" ", "left",0,0,null,"apple_white"); + text_2 = EventScripts.init_bitmap_font(" ", "left",0,0,null,"apple_white"); + text_3 = EventScripts.init_bitmap_font(" ", "left", 0, 0, null, "apple_white"); + text_1.color = text_2.color = text_3.color = 0xffffff; + text_1.drop_shadow = text_2.drop_shadow = text_3.drop_shadow = true; + + menu_select_inactive = new FlxSprite(0, 30); + menu_select_active = new FlxSprite(0, 30); + menu_select_active.scrollFactor = menu_select_inactive.scrollFactor = no_scroll_point; + menu_select_active.addAnimation("flash", [0, 1], 4); + menu_select_active.play("flash"); + menu_select_inactive.loadGraphic(men_sel_act, true, false, 61, 15); + + menu_select_active.loadGraphic(men_sel_act, true, false, 61,15); + menu_select_inactive.visible = false; + menu_select_inactive.frame = 2; + + var selector:FlxSprite; + for (i = 0; i < selectors.maxSize; i++) { + selector = new FlxSprite; + selector.loadGraphic(arrows_sprite, true, false, 7,7); + selector.addAnimation("disabled", [2]); + selector.addAnimation("enabled", [2,3], 6); + selector.play("disabled"); + selector.visible = false; + selector.scrollFactor = no_scroll_point; + selectors.add(selector); + } + selector = null; + + add(selectors); + + base_group.add(base_menu); + base_group.add(menu_select_active); + base_group.add(menu_select_inactive); + base_group.add(text_categories); + base_group.add(text_info); + base_group.add(text_1); + base_group.add(text_2); + base_group.add(text_3); + add(base_group); + add(selectors); + + /* MINIMAP */ + minimap = new MinimapState(); + add(minimap); + + legend_cur = new FlxSprite(63, 117); + legend_cur.makeGraphic(4,4,0xffff5949); + legend_entrance = new FlxSprite(63, 125); + legend_entrance.makeGraphic(4, 4, 0xff0d52af); + + legend_cur_b = new FlxSprite(62, 116); + legend_cur_b.makeGraphic(6,6,0xff000000); + legend_entrance_b = new FlxSprite(62, 124); + legend_entrance_b.makeGraphic(6, 6, 0xff000000); + legend_cur_b.scrollFactor = legend_entrance_b.scrollFactor = legend_cur.scrollFactor = legend_entrance.scrollFactor = no_scroll_point; + add(legend_cur_b); add(legend_entrance_b); + add(legend_cur); add(legend_entrance); + + + /* EQUIP */ + + var equip_box:FlxSprite; + for (i = 0; i < equip_boxes.maxSize; i++) { + equip_box = new FlxSprite; + equip_box.loadGraphic(none_icon_sprite, true, false, 18, 18); + equip_box.x = 65; + equip_box.y = 25 + 24 * i; + equip_box.scrollFactor = no_scroll_point; + equip_boxes.add(equip_box); + + switch (i) { + case 0: + break; + case 1: + equip_box.loadGraphic(long_icon_sprite, false, false, 18, 18); + break; + case 2: + equip_box.loadGraphic(wide_icon_sprite, false, false, 18, 18); + break; + case 3: + equip_box.loadGraphic(transformer_icon_sprite, false, false, 18, 18); + break; + + } + } + equip_box = null; + add(equip_boxes); + + //Load key icons + for (i = 0; i < 3; i++) { + var key:FlxSprite = new FlxSprite; + key_icons.add(key); + key.x = 95 + 16 * i; + key.y = 130; + } + set_key_graphics(); + key_icons.setAll("scrollFactor", no_scroll_point); + add(key_icons); + + trade_item = new FlxSprite(78, 130); + trade_item.scrollFactor.x = trade_item.scrollFactor.y = 0; + set_trade_item(); + add(trade_item); + + jump_shoes = new FlxSprite(62, 130, Treasure.embed_jump_shoes); + jump_shoes.scrollFactor.x = jump_shoes.scrollFactor.y = 0; + add(jump_shoes); + + equip_icon = new FlxSprite(equip_boxes.members[0].x + 12, equip_boxes.members[0].y - 1); + equip_icon.scrollFactor = no_scroll_point; + equip_icon.loadGraphic(equipped_icon, true, false, 7, 9); + add(equip_icon); + + /* CARDS*/ + var card:FlxSprite; + for (i = 0; i < cards.maxSize; i++) { + card = new FlxSprite; + card.loadGraphic(card_sheet_embed, false, false, 24, 24); + card.frame = 36; + // LOGIC FOR LOADING DIFFERENT CARD PICTURE HERE + card.x = 60 + 8 + (24 + 6) * (i % 3); + card.y = 20 + 8 + (24 + 6) * int(i / 3); + cards.add(card); + card.scrollFactor = no_scroll_point; + } + add(cards); + card = null; + + /* SAVE GAME */ + // ---- + + /* SETTINGS */ + + + volume_bar = new FlxSprite; + volume_bar.makeGraphic(2, 7, 0xffc7003d); + volume_bar.scale.x = int(FlxG.volume * 30); + volume_bar.x = 73; + volume_bar.y = 58; + + volume_bar_bg = new FlxSprite; + volume_bar_bg.makeGraphic(60, 7, 0xff000000); + volume_bar_bg.x = volume_bar.x; + volume_bar_bg.y = volume_bar.y; + + + volume_bar_bg.scrollFactor = volume_bar.scrollFactor = volume_bar_overlay.scrollFactor = no_scroll_point; + + volume_bar_overlay.loadGraphic(volume_bar_embed, false, false, 60, 11); + volume_bar_overlay.x = volume_bar.x; + volume_bar_overlay.y = volume_bar.y - 2; + volume_bar.x = volume_bar_overlay.x + volume_bar.scale.x - 1; + + window_config = new FlxSprite( -3, -3); + window_config.scrollFactor.x = window_config.scrollFactor.y = 0; + window_config.loadGraphic(TitleState.embed_screen_config, false, false, 166, 186); + window_words = EventScripts.init_bitmap_font("Please use the\narrow keys to resize\nthe window until\nyou cannot see\nany black around\n the borders.\n\nPress "+Registry.controls[Keys.IDX_ACTION_1]+"\nwhen done.", "center", 10, 10, null, "apple_white"); + add(volume_bar_bg); + add(volume_bar); + add(volume_bar_overlay); + window_config.visible = window_words.visible = false; + add(window_config); + add(window_words); + + /* secrets * + * */ + + trophies = new FlxGroup; + for (i = 0; i < 16; i++) { + var trophy:FlxSprite = new FlxSprite; + trophy.loadGraphic(Treasure.embed_secret_trophies, true, false, 16, 16); + trophy.frame = i; + trophies.add(trophy); + set_trophy_vis(trophies, i); + trophy.x = 64 + (i % 4) * 24; + trophy.y = 40 + int(i / 4) * 24; + trophy.scrollFactor.x = trophy.scrollFactor.y = 0; + } + add(trophies); + + + /* playtime **/ + + playtime_text = EventScripts.init_bitmap_font("00:00:00", "left", 1, 156, null, "apple_white"); + playtime_text.color = 0xffffff; + playtime_text.drop_shadow = true; + base_group.add(playtime_text); + add(playtime_text); + + } + override public function update():void { + + // Calc playtime!!!! + var playtime_dat:int = 0; + playtime_dat = Registry.playtime; + var hrs:int = int(playtime_dat / 3600); + + if (hrs >= 10) { + playtime_text.text = int(playtime_dat / 3600).toString() + ":"; + } else { + playtime_text.text = "0" + int(playtime_dat / 3600).toString() + ":"; + } + playtime_dat -= 3600 * hrs; + + var mins:int = int(playtime_dat / 60); + if (mins >= 10) { + playtime_text.text += int(playtime_dat / 60).toString() + ":"; + } else { + playtime_text.text = playtime_text.text + "0" + int(playtime_dat / 60).toString() + ":"; + } + playtime_dat -= 60 * mins; + + if (playtime_dat >= 10) { + playtime_text.text += playtime_dat.toString(); + } else { + playtime_text.text = playtime_text.text + "0"+ playtime_dat.toString(); + } + + if (Registry.GAMESTATE.load_dialogue) { + Registry.GAMESTATE.dialogue_state.push(this as FlxState); + Registry.GAMESTATE.load_dialogue = false; + state = s_dialogue; + return; + + } else if (state == s_dialogue) { + dialogue_logic(); + super.update(); + return; + } + + if (ctr_settings != 1) { + if (state == s_browse) { + check_for_exit_with(Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JUST_PRESSED_PAUSE); + } else { + check_for_exit_with(Registry.keywatch.JUST_PRESSED_PAUSE); + } + } + if (!init_parent) { + parent = Registry.GAMESTATE; + init_parent = true; + } + switch (state) { + case s_browse: + browse_logic(); + break; + case s_map: + map_logic(); + break; + case s_equip: + equip_logic(); + break; + case s_cards: + cards_logic(); + break; + case s_save: + save_logic(); + break; + case s_settings: + settings_logic(); + break; + case s_secretz: + secretz_logic(); + break; + case s_cheatz: + cheatz_logic(); + break; + } + + if (Registry.keywatch.JP_UP || Registry.keywatch.JP_DOWN || Registry.keywatch.JP_LEFT || Registry.keywatch.JP_RIGHT) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group); + } + + if (Registry.keywatch.JP_ACTION_1) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + } + + super.update(); + } + + + private function set_equip_vis(idx:int):void { + var equip_box:FlxSprite = equip_boxes.members[idx]; + + switch (idx) { + case 1: //long + idx = Registry.IDX_LENGTHEN; + break; + case 2: //widen + idx = Registry.IDX_WIDEN; + break; + case 3: //stransform + idx = Registry.IDX_TRANSFORMER; + break; + } + if (!Registry.inventory[idx]) { + equip_box.visible = false; + } else { + equip_box.visible = true; + } + } + + public var secret_counter:int = 0; + public function browse_logic():void { + + /* Pop up substates but don't do their logic */ + if (!current_substate_visible) { + + current_substate_visible = true; + + remove(base_group, true); + add(base_group); + remove(selectors, true); + add(selectors); + + selectors.setAll("visible", false); + + switch (base_index) { + case 0: // Minimap + if (minimap.has_map) { + minimap.stuff_for_pause_state(); + } + remove(minimap, true); + add(minimap); + remove(legend_cur_b, true); + add(legend_cur_b); + remove(legend_entrance_b, true); + add(legend_entrance_b); + remove(legend_cur, true); + add(legend_cur); + remove(legend_entrance, true); + add(legend_entrance); + remove(selectors, true); add(selectors); + text_1.visible = text_2.visible = true; + text_1.text = " :Current room\n\ + :Door/Exit\n"; + text_1.x = 60; + text_1.y = 115; + + text_2.multiLine = true; + text_2.autoUpperCase = false; + + text_3.visible = false; + text_3.text = "Yes No"; + if (Registry.GE_States[Registry.GE_ENTERED_NEXUS_ONCE] == true && false == is_crowd_minidungeon()) { + if (false == Registry.is_dungeon(Registry.CURRENT_MAP_NAME)) { + + text_2.text = "Return to\nNexus"; + if (minimap.has_map) { + text_2.x = text_1.x + 19; + text_3.x = text_1.x + 14; + text_2.y = 135; + text_3.y = 153; + + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = true; + } else { + text_1.text = "No map"; + text_1.x = equip_boxes.members[0].x + equip_boxes.members[0].width + 4; + text_1.y = 30; + text_2.x = 60 + 19; + text_2.y = 135; + text_3.x = 79; + text_3.y = 153; + text_2.text = "Return to\nNexus"; + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = false; + } + + } else { + text_2.text = "Return to\nentrance" + text_2.x = text_1.x + 19; + text_3.x = text_1.x + 14; + text_2.y = 135; + text_3.y = 153; + + legend_cur_b.visible = legend_entrance_b.visible = legend_cur.visible = legend_entrance.visible = true; + } + } else { + text_2.visible = false; + } + break; + case 1: // eqip + remove(equip_overlay, true); add(equip_overlay); + remove(equip_boxes, true); add(equip_boxes); + remove(key_icons, true); add(key_icons); + remove(equip_icon, true); add(equip_icon); + remove(selectors, true); add(selectors); + remove(trade_item, true); add(trade_item); + remove(jump_shoes, true); add(jump_shoes); + + jump_shoes.visible = (Registry.bound_item_2 == "JUMP"); + set_trade_item(); + + set_key_graphics(); + + for (var fuckme:int = 0; fuckme < 4; fuckme++) { + equip_boxes.members[fuckme].visible = false; + } + + if (Registry.inventory[Registry.IDX_BROOM]) { + equip_boxes.members[0].visible = true; + } + if (Registry.inventory[Registry.IDX_LENGTHEN]) { + equip_boxes.members[1].visible = true; + } + if (Registry.inventory[Registry.IDX_WIDEN]) { + equip_boxes.members[2].visible = true; + } + if (Registry.inventory[Registry.IDX_TRANSFORMER]) { + equip_boxes.members[3].visible = true; + } + + if (Registry.bound_item_1 == Registry.item_names[Registry.IDX_TRANSFORMER]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24*3; + } else if (Registry.bound_effect == Registry.item_names[Registry.IDX_WIDEN]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24*2; + } else if (Registry.bound_effect == Registry.item_names[Registry.IDX_LENGTHEN]) { + equip_icon.y = equip_boxes.members[0].y - 1 + 24; + } else { + equip_icon.y = equip_boxes.members[0].y - 1; + } + if (!Registry.inventory[Registry.IDX_BROOM]) { + equip_icon.visible = false; + } else { + equip_icon.visible = true; + } + var normal_string:String = Registry.inventory[Registry.IDX_BROOM] ? "Normal" : "-"; + var status_1:String = Registry.inventory[Registry.IDX_LENGTHEN] ? "Extend" : "-"; + var status_2:String = Registry.inventory[Registry.IDX_WIDEN] ? "Widen" : "-"; + var status_3:String = Registry.inventory[Registry.IDX_TRANSFORMER] ? "Swap" : "-"; + + text_1.visible = true; + text_1.setText(normal_string+"\n\n\n"+status_1+"\n\n\n"+status_2+"\n\n\n"+status_3, true, 0, 0, "left", true); + text_1.x = equip_boxes.members[0].x + equip_boxes.members[0].width + 4; + text_1.y = 30; + text_2.visible = text_3.visible = false; + break; + case 2: //card + remove(cards, true); add(cards); + remove(selectors, true); add(selectors); + set_card_images(); + text_1.visible = true; + text_1.setText("1/4", true, 0, 0, "center", true); + text_1.x = 99; + text_1.y = 158; + text_2.visible = true; + text_2.setText(Registry.nr_growths.toString() + " cards", true, 0, 0, "left", true); + text_2.x = 70; + text_2.y = 148; + text_3.visible = false; + cards_cursor_idx = 0; + cur_cards_pg = 0; + break; + case 3: // save + text_1.visible = true; + text_1.setText("Save\nSave and go\n to title\nSave and quit\nQuit game", true, 0, 0, "left", true); + text_1.text += "\n\n\n\nDeaths: " + Registry.death_count.toString(); + + text_1.x = 69; + text_1.y = 30; + text_2.visible = text_3.visible = false; + break; + case 4: //settings + text_1.visible = text_3.visible = true; + var autosave_state:String = Registry.autosave_on ? "On" : "Off"; + set_settings_text(true); + text_1.x = 68; + text_1.y = 30; + text_2.visible = false; + text_3.x = 68; + text_3.y = 120; + if (Intra.is_mobile) text_3.visible = false; + text_3.setText("Scaling: " + Intra.scale_factor.toString() + "x",true,0,0,"left",true); + + remove(volume_bar_bg, true); add(volume_bar_bg); + remove(volume_bar, true); add(volume_bar); + remove(volume_bar_overlay, true); add(volume_bar_overlay); + remove(window_config, true); add(window_config); + remove(window_words, true); add(window_words); + break; + case 5: // SECRETS!!! + text_1.visible = text_2.visible = text_3.visible = false; + remove(trophies, true); add(trophies); + remove(selectors, true); add(selectors); + break; + case 6: // CHEATS!!! + break; + } + } + + if (Registry.keywatch.JP_DOWN) { + if (base_index < max_base_index) { + current_substate_visible = false; + base_index++; + secret_counter = 0; + menu_select_active.y += 16; + menu_select_inactive.y = menu_select_active.y; + } else { + if (base_index == 4 && Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + current_substate_visible = false; + menu_select_active.y += 16; + menu_select_inactive.y = menu_select_active.y; + base_index++; + } else { + secret_counter++; + if (secret_counter > 20 && base_index != 6) { + current_substate_visible = false; + if (base_index == 4) { + menu_select_active.y += 32; + } else { + menu_select_active.y += 16; + } + menu_select_inactive.y = menu_select_active.y; + base_index = 6; + } + } + } + } else if (Registry.keywatch.JP_UP) { + if (base_index > 0) { + current_substate_visible = false; + if (base_index == 6 && false == Registry.GE_States[Registry.GE_HAVE_A_SECRET]) { + base_index = 4; + menu_select_active.y -= 32; + } else { + base_index--; + menu_select_active.y -= 16; + } + menu_select_inactive.y = menu_select_active.y; + } + } + + /* State change to submenus, also change cursor animations and positions */ + if (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_RIGHT) { + menu_select_active.visible = false; + menu_select_inactive.visible = true; + + switch (base_index) { + case 0: + + if (Registry.GE_States[Registry.GE_ENTERED_NEXUS_ONCE] == false || is_crowd_minidungeon()) { + menu_select_active.visible = true; + menu_select_inactive.visible = false; + break; + } + state = s_map; + selectors.members[1].scale.x = 1; + selectors.members[2].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = 70; + selectors.members[1].y = 135; + selectors.members[1].play("enabled"); + map_cursor_idx = 1; + break; + case 1: + // If no items, equip submenu is inacessible. + if (!equip_icon.visible) { + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } else { + state = s_equip; + equip_cursor_idx = 0; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = 80; + selectors.members[1].y = 30; + selectors.members[1].play("enabled"); + } + break; + case 2: + + //selectors.members[1].visible = selectors.members[2].visible = true; + selectors.members[1].x = text_1.x - 7; + selectors.members[1].y = text_1.y; + selectors.members[2].x = text_1.x + text_1.width; + selectors.members[2].y = text_1.y; + selectors.members[1].play("enabled"); + selectors.members[2].play("enabled"); + selectors.members[1].scale.x = -1; + selectors.members[2].scale.x = 1; + + + cards_cursor_idx = 0; + state = s_cards; + card_pg_to_cards(); + break; + case 3: + state = s_save; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = text_1.x - 8; + selectors.members[1].y = text_1.y; + selectors.members[1].play("enabled"); + save_cursor_idx = 0; + break; + case 4: + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = text_1.x - 7; + selectors.members[1].y = text_1.y; + selectors.members[1].play("enabled"); + settings_cursor_idx = 0; + state = s_settings; + break; + case 5: + //secretsx + state = s_secretz; + selectors.members[1].scale.x = 1; + selectors.members[1].visible = true; + selectors.members[1].x = trophies.members[0].x - 7; + selectors.members[1].y = trophies.members[0].y + 4; + selectors.members[1].play("enabled"); + secretz_idx = 0; + break; + case 6: //cheatsz + state = s_cheatz; + break; + } + } + + + + } + + + + private function map_logic():void { + + // Cancel + if (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_LEFT) { + // Return to browse, or + if (map_ctr == 0) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + selectors.members[2].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + map_cursor_idx = 1; + // Return to top-level of map submenu + } else if (!Registry.keywatch.JP_LEFT) { + selectors.members[2].visible = false; + selectors.members[1].play("enabled"); + map_cursor_idx = 1; + map_ctr = 0; + } + } + + // Select + if (Registry.keywatch.JP_ACTION_1) { + switch (map_ctr) { + // Go to yes/no context for return to entrance + case 0: + selectors.members[2].visible = true; + selectors.members[2].play("enabled"); + selectors.members[1].play("disabled"); + selectors.members[2].x = text_3.x - 6 + 45; + selectors.members[2].y = text_3.y; + text_3.visible = true; + map_ctr++; + + break; + // Eitehr go back, or switch maps + case 1: + if (map_cursor_idx == 0) { + // switch state + Registry.cleanup_on_map_change(); + if (false == Registry.is_dungeon(Registry.CURRENT_MAP_NAME)) { // If not in a dungeon want 2 warp to nexus + if (Registry.CURRENT_MAP_NAME == "BLANK" || Registry.CURRENT_MAP_NAME == "DRAWER" || Registry.CURRENT_MAP_NAME == "NEXUS") { + Registry.NEXT_MAP_NAME = "NEXUS"; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES["NEXUS"].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES["NEXUS"].y; + } else { + NPC.load_nexus_data(); + } + } else { + Registry.NEXT_MAP_NAME = Registry.CURRENT_MAP_NAME; + Registry.ENTRANCE_PLAYER_X = Registry.DUNGEON_ENTRANCES[Registry.CURRENT_MAP_NAME].x; + Registry.ENTRANCE_PLAYER_Y = Registry.DUNGEON_ENTRANCES[Registry.CURRENT_MAP_NAME].y; + } + //FlxG.switchState(new PlayState); + Registry.BOI = false; + parent.SWITCH_MAPS = true; + Registry.sound_data.start_song_from_title(Registry.NEXT_MAP_NAME); + reset_counters(); + done = true; + } else { + selectors.members[1].play("enabled"); + selectors.members[2].visible = false; + map_cursor_idx = 1; + map_ctr = 0; + } + break; + } + } + + // Deal with/left right for yes/no context + if (map_ctr == 1) { + if (Registry.keywatch.JP_RIGHT && map_cursor_idx < 1) { + map_cursor_idx++; + selectors.members[2].x += 47; + } else if (Registry.keywatch.JP_LEFT && map_cursor_idx > 0) { + map_cursor_idx--; + selectors.members[2].x -= 47; + } + } + } + private function equip_logic():void { + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && equip_cursor_idx <= 10)) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + if (Registry.keywatch.JP_DOWN) { + if (equip_cursor_idx < 3) { + equip_cursor_idx++; + selectors.members[1].y += 24; + } else if (equip_cursor_idx == 3) { + equip_cursor_idx = 10; + + if (Registry.inventory[Registry.IDX_JUMP]) { + selectors.members[1].y = jump_shoes.y; + selectors.members[1].x = jump_shoes.x - 3; + } else if (Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX]) { + selectors.members[1].y = trade_item.y; + selectors.members[1].x = trade_item.x - 3; + equip_cursor_idx = 11; + } else { + selectors.members[1].y = key_icons.members[0].y; + selectors.members[1].x = key_icons.members[0].x - 3; + equip_cursor_idx = 12; + } + + } + } else if (Registry.keywatch.JP_UP) { + if (equip_cursor_idx > 0) { + if (equip_cursor_idx >= 10) { + selectors.members[1].y = 102; + selectors.members[1].x = 80; + equip_cursor_idx = 3; + } else { + equip_cursor_idx--; + selectors.members[1].y -= 24; + } + } + } + + if (Registry.keywatch.JP_RIGHT) { + if (equip_cursor_idx < 14) { + if (equip_cursor_idx == 10) { + if (!(Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX])) { + equip_cursor_idx = 12; + } else { + equip_cursor_idx = 11; + } + } else { + equip_cursor_idx++; + } + } + // oh my goddd + } else if (Registry.keywatch.JP_LEFT) { + if (equip_cursor_idx > 10) { + if (equip_cursor_idx == 11) { + if (Registry.inventory[Registry.IDX_JUMP]) { + equip_cursor_idx = 10; + } + } else { + if (equip_cursor_idx == 12) { + if ((Registry.inventory[Registry.IDX_BIKE_SHOES] || Registry.inventory[Registry.IDX_BOX])) { + equip_cursor_idx = 11; + } else if (Registry.inventory[Registry.IDX_JUMP]) { + equip_cursor_idx = 10; + } + } else { + equip_cursor_idx--; + } + } + } + } + + if (Registry.keywatch.JP_LEFT || Registry.keywatch.JP_RIGHT) { + if (equip_cursor_idx == 10) { + selectors.members[1].y = jump_shoes.y; + selectors.members[1].x = jump_shoes.x - 3; + } else if (equip_cursor_idx == 11) { + selectors.members[1].y = trade_item.y; + selectors.members[1].x = trade_item.x - 3; + } else if (equip_cursor_idx > 11) { + selectors.members[1].y = key_icons.members[equip_cursor_idx - 12].y; + selectors.members[1].x = key_icons.members[equip_cursor_idx - 12].x - 3; + } + } + + if (Registry.keywatch.JP_ACTION_1) { + + switch(equip_cursor_idx) { + case 0: + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + set_passive_effect(Registry.IDX_BROOM); + + equip_icon.y = equip_boxes.members[0].y - 1; + break; + case 1: + if (Registry.inventory[Registry.IDX_LENGTHEN]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + if (Registry.bound_effect != Registry.item_names[Registry.IDX_LENGTHEN]) { + set_passive_effect(Registry.IDX_LENGTHEN); + } + equip_icon.y = equip_boxes.members[0].y - 1 + 24; + } + break; + case 2: + if (Registry.inventory[Registry.IDX_WIDEN]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_BROOM]; + if (Registry.bound_effect != Registry.item_names[Registry.IDX_WIDEN]) { + set_passive_effect(Registry.IDX_WIDEN); + } + equip_icon.y = equip_boxes.members[0].y - 1 + 24*2; + } + break; + case 3: + if (Registry.inventory[Registry.IDX_TRANSFORMER]) { + Registry.bound_item_1 = Registry.item_names[Registry.IDX_TRANSFORMER]; + set_passive_effect(Registry.IDX_BROOM); // Remove the passive effect + equip_icon.y = equip_boxes.members[0].y - 1 + 24*3; + } + break; + case 10: + DH.dialogue_popup("A pair of spring-loaded shoes - press "+Registry.controls[Keys.IDX_ACTION_2]+" to jump!"); + break; + case 11: + if (Registry.inventory[Registry.IDX_BIKE_SHOES]) { + DH.dialogue_popup("A pair of shoes for biking."); + } else { + DH.dialogue_popup("An empty cardboard box."); + } + break; + case 12: + if (Registry.inventory[Registry.IDX_GREEN_KEY]) + DH.dialogue_popup("A key found in the Temple of the Seeing One."); + break; + case 13: + if (Registry.inventory[Registry.IDX_RED_KEY]) + DH.dialogue_popup("A key found in a red, underground cave."); + break; + case 14: + if (Registry.inventory[Registry.IDX_BLUE_KEY]) + DH.dialogue_popup("A key found in a mountain cave."); + break; + } + + if (equip_cursor_idx < 4) { + if (Registry.bound_item_1 == "TRANSFORMER" || Registry.bound_item_2 == "TRANSFORMER") { + Registry.E_Transformer_On = true; + } else { + Registry.E_Transformer_Off = true; + } + + + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + current_substate_visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + //set_placeholder_image(1); + } + + } + + // The locations of the cards, so we can map them to proper images when opening a chest. + // Dungeon x/y vals are the room, roamstates are the actual coordinates in DAME-coords (so no y-offset of 20) + public static var card_data:Object = { + "BLANK": new Array( { id: 44, x: 5, y: 1 } ), + "DRAWER": new Array( {id: 36, x:2, y:1}, {id: 37, x:4, y:7}), + "OVERWORLD": new Array( { id: 0, x:1, y:9 } , {id: 1, x:5, y:7} ), + "BEDROOM": new Array( { id: 2, x: 3, y: 0 }, { id:3, x:1, y:0 }, { id:4, x:2, y:3 }, { id:5, x:5, y:0 } ), + "SUBURB": new Array( { id : 6 , x: 1, y:7 } , {id: 42, x:2 , y:7}), + "APARTMENT": new Array( { id: 7, x : 8, y : 7 }, { id: 8, x:3, y:5 }, { id:9, x:0, y:0 } ) , + "FIELDS": new Array( { id: 10, x :3, y: 8}, {id : 11, x : 6, y: 9}, {id: 43, x: 8, y : 0}, {id: 45,x:11,y:9}), + "WINDMILL": new Array( {id: 12, x: 1, y:5} ), + "FOREST" :new Array( {id: 13, x:3, y:2}), + "CLIFF": new Array( { id: 14, x:4, y:2 }, { id: 15, x: 2, y:7}), + "BEACH": new Array( { id: 16, x:4, y:3 } ) , + "REDSEA": new Array( { id: 17, x:2, y:2}, {id: 47, x:0,y:6} ), + "REDCAVE": new Array( { id: 18, x:3 , y :1 } , { id : 19, x:0, y:0 }, { id: 20, x:6, y:1 } ), + "TRAIN" : new Array( { id: 21, x: 0 , y:0 } , {id: 40, x:5, y : 8}), // CELL + "CIRCUS" : new Array( { id: 23, x: 0 , y : 3 }, { id : 22, x:3, y:6 } , { id : 24, x: 3, y:2 }, { id:25, x: 7, y: 0 } ), + "CROWD" : new Array( {id : 26, x:2 , y: 2} , {id: 27, x: 8, y: 2} , {id: 28 , x:9, y:5 }), + "SPACE" : new Array ( { id: 29, x:0, y:0} , {id: 30, x:9,y:0}, {id:41, x:5, y:7}), + "HOTEL": new Array( { id: 31, x:3, y:6 }, { id:32, x:1, y:8 }, { id:33, x:9, y:3 } , { id:34, x:8, y:11 } , {id:38, x:5, y:0}), + "TERMINAL" : new Array ( { id: 35, x: 4, y:2 } ), + "DEBUG" : new Array( { id: 39, x:4, y:3 } ), + "STREET": new Array( {id:46, x:1, y:6}) + + }; + + private function cards_logic():void { + + // Exit card select, or exit card submenu + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && cur_cards_pg == 0 && (cards_cursor_idx % 3 == 0))) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[3].visible = false; + selectors.members[1].visible = selectors.members[2].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + //cur_cards_pg = 0; + //cards_cursor_idx = 0; + } + + + + // Move about card select, or move between pages + if (selectors.members[3].visible) { //if card select + if ((cards_cursor_idx % 12) > 2 && Registry.keywatch.JP_UP) { + cards_cursor_idx -= 3; + selectors.members[3].y -= 29; + } else if ((cards_cursor_idx % 12) < 9 && Registry.keywatch.JP_DOWN) { + cards_cursor_idx += 3; + selectors.members[3].y += 29; + } else if (Registry.keywatch.JP_DOWN) { + selectors.members[3].visible = false; + selectors.members[1].visible = true; + selectors.members[2].visible = true; + selectors.members[1].play("enabled"); + selectors.members[2].play("enabled"); + } + + if ((cards_cursor_idx % 3) < 2 && Registry.keywatch.JP_RIGHT) { + cards_cursor_idx ++; + selectors.members[3].x += 30; + } else if ((cards_cursor_idx % 3) > 0 && Registry.keywatch.JP_LEFT) { + cards_cursor_idx --; + selectors.members[3].x -= 30; + } else if ((cards_cursor_idx % 3) == 0 && Registry.keywatch.JP_LEFT) { + if (cur_cards_pg > 0) { + cur_cards_pg --; + cards_cursor_idx += 2; + selectors.members[3].x += 60; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4"; + } else { + text_1.text = "1/4"; + } + } + } else if ((cards_cursor_idx % 3) == 2 && Registry.keywatch.JP_RIGHT) { + if (cur_cards_pg < 3) { + cur_cards_pg ++; + cards_cursor_idx -= 2; + selectors.members[3].x -= 60; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4" + } else { + text_1.text = "4/4"; + } + } + } + } else { + if (cur_cards_pg < 3 && Registry.keywatch.JP_RIGHT) { + cur_cards_pg++; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4" + } else { + text_1.text = "4/4"; + } + //Load new sprites.... + } else if (cur_cards_pg > 0 && Registry.keywatch.JP_LEFT) { + cur_cards_pg--; + set_card_images(); + if (cur_cards_pg == 1) { + text_1.text = "2/4"; + } else if (cur_cards_pg == 2) { + text_1.text = "3/4"; + } else { + text_1.text = "1/4"; + } + //load new sprites... + } + if (Registry.keywatch.JP_UP) { + card_pg_to_cards(); + } + } + + // Go to card select or do something with a single card + if (Registry.keywatch.JP_ACTION_1) { + if (selectors.members[3].visible) { + var idx:int = cards_cursor_idx + cur_cards_pg * 12; + if (Registry.card_states[idx]) { + DH.start_dialogue(DH.name_card, DH.scene_card_one, DH.area_etc, idx); + } + // Do something + } else { // Go to card select + card_pg_to_cards(); + } + } + } + private function save_logic():void { + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + if (Registry.keywatch.JP_DOWN) { + if (save_cursor_idx < 3) { + save_cursor_idx++; + if (save_cursor_idx == 2) { + selectors.members[1].y += 16; + } else { + selectors.members[1].y += 8; + } + } + } else if (Registry.keywatch.JP_UP) { + if (save_cursor_idx > 0) { + save_cursor_idx--; + if (save_cursor_idx == 1) { + selectors.members[1].y -= 16; + } else { + selectors.members[1].y -= 8; + } + } + } + + if (Registry.keywatch.JP_ACTION_1) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + switch (save_cursor_idx) { + case 0: + if (Save.save()) { + text_1.text = "Saved!\nSave and go\n to title\nSave and quit\nQuit game"; + text_1.text += "\n\n\n\nDeaths: " + Registry.death_count.toString(); + } else { + text_1.text = "ERROR\nSave and go\n to title\nSave and quit\nQuit game"; + text_1.text += "\n\n\n\nDeaths: " + Registry.death_count.toString(); + } + break; + case 1: + Registry.cleanup_on_map_change(); + Registry.sound_data.stop_current_song(); + Save.save(); + FlxG.switchState(new TitleState); + break; + case 2: + Save.save(); + //NativeApplication.nativeApplication.exit(); + break; + case 3: + //NativeApplication.nativeApplication.exit(); + break; + + } + } + + } + + private function settings_logic():void { + + if (ctr_settings == 0) { + if (Registry.keywatch.JP_ACTION_2 || (Registry.keywatch.JP_LEFT && !selectors.members[2].visible)) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + selectors.members[1].visible = false; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + if (Registry.keywatch.JP_DOWN) { + if (settings_cursor_idx < 5) { + settings_cursor_idx ++; + if (settings_cursor_idx == 2) { + selectors.members[1].y += 24; + } else if (settings_cursor_idx == 3) { + selectors.members[1].y += 32; + if (Intra.is_mobile) { + selectors.members[1].y += 32; + settings_cursor_idx = 5; + } + } else { + selectors.members[1].y += 16; + } + } + } else if (Registry.keywatch.JP_UP) { + if (settings_cursor_idx > 0) { + settings_cursor_idx -- ; + if (settings_cursor_idx == 1) { + selectors.members[1].y -= 24; + } else if (settings_cursor_idx == 2) { + selectors.members[1].y -= 32; + } else if (settings_cursor_idx == 4 && Intra.is_mobile) { + selectors.members[1].y -= 64; + settings_cursor_idx = 2; + } else { + selectors.members[1].y -= 16; + } + } + } + + if (Registry.keywatch.JP_ACTION_1) { + if (settings_cursor_idx == 0) { + // Goto controls + if (!Intra.is_mobile) { + ctr_settings = 1; + controls_state.push(this); + // If mobile, just flip X/C functions + } else { + var gam:Intra = FlxG._game as Intra; + gam.mobile_flip_x_c(); + } + } else if (settings_cursor_idx == 1) { // goto volume + ctr_settings = 2; + selectors.members[1].play("disabled"); + selectors.members[2].play("enabled"); + selectors.members[3].play("enabled"); + selectors.members[2].visible = selectors.members[3].visible = true; + selectors.members[2].scale.x = -1; + selectors.members[2].x = selectors.members[1].x; selectors.members[2].y = 58; + selectors.members[3].x = 138; selectors.members[3].y = 58; + + } else if (settings_cursor_idx == 2) { + Registry.autosave_on = !Registry.autosave_on; + set_settings_text(true); + + } else if (settings_cursor_idx == 3) { // Change resize type + Intra.force_scale = true; + set_settings_text(); + + } else if (settings_cursor_idx == 4) { // Change integer scaling + ctr_settings = 3; + selectors.members[1].play("disabled"); + selectors.members[2].play("enabled"); + selectors.members[3].play("enabled"); + selectors.members[1].visible = false; + selectors.members[2].visible = selectors.members[3].visible = true; + selectors.members[2].scale.x = -1; + selectors.members[2].x = selectors.members[1].x + 58; selectors.members[2].y = 120; + selectors.members[3].x = 147; selectors.members[3].y = 120; + + } else if (settings_cursor_idx == 5) { //window size config + if (Intra.is_mobile) { + var _gam:Intra = FlxG._game as Intra; + _gam.mobile_flip_handedness(); + } else if (false == Intra.is_web) { + ctr_settings = 4; + Intra.scale_factor = 3; + Intra.force_scale = true; + window_words.visible = window_config.visible = true; + } + } + } + } else if (ctr_settings == 1) { //controls + controls_state.update(); + if (!controls_state.updating && (Registry.keywatch.JUST_PRESSED_PAUSE || FlxG.keys.justPressed("ESCAPE")) ) { + controls_state.pop(this); + ctr_settings = 0; + text_info.text = Registry.controls[Keys.IDX_ACTION_1] + ":Select " + Registry.controls[Keys.IDX_ACTION_2] + ":Back"; + } + } else if (ctr_settings == 2) { //volume + if (Registry.keywatch.JP_ACTION_2) { + selectors.members[1].play("enabled"); + ctr_settings = 0; + selectors.members[2].visible = selectors.members[3].visible = false; + selectors.members[2].scale.x = 1; + } + + if (Registry.keywatch.JP_LEFT) { + FlxG.volume > 0 ? FlxG.volume -= 0.1 : 1; + } else if (Registry.keywatch.JP_RIGHT) { + FlxG.volume < 1 ? FlxG.volume += 0.1 : 1; + } + + + //text_2.setText(int(FlxG.volume * 10).toString()); + volume_bar.scale.x = int(FlxG.volume * 30); + volume_bar.x = volume_bar_overlay.x + volume_bar.scale.x -1; + } else if (ctr_settings == 3) { // Integer scaling + if (Registry.keywatch.JP_ACTION_2) { + selectors.members[1].play("enabled"); + ctr_settings = 0; + selectors.members[1].visible = true + selectors.members[2].visible = selectors.members[3].visible = false; + selectors.members[2].scale.x = 1; + } + + + text_3.setText("Scaling: " + Intra.scale_factor.toString() + "x",true,0,0,"left",true); + + if (Registry.keywatch.JP_LEFT) { + if (Intra.scale_factor > 1) { + Intra.scale_factor--; + Intra.scale_ctr = (Intra.scale_ctr - 1) % 3; + Intra.force_scale = true; + } + } else if (Registry.keywatch.JP_RIGHT) { + // See if we can scale further + var ratio:Number = (Intra.scale_factor + 1 ) / 3; + if (FlxG._game.stage.fullScreenHeight < ratio * 540 || FlxG._game.stage.fullScreenWidth < ratio * 480) { + + }else if (Intra.scale_factor < 8) { + Intra.scale_factor++; + Intra.scale_ctr = (Intra.scale_ctr - 1) % 3; // Display style should stay the same + Intra.force_scale = true; + } + } + } else if (ctr_settings == 4) { + //TitleState.window_config_logic(Registry.keywatch); + if (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_ACTION_1) { + ctr_settings = 0; + window_words.visible = window_config.visible = false; + } + } + } + + private function cheatz_logic():void { + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + } + + text_1.visible = true; + text_1.x = 64; + text_1.y = 50; + + + if (text_1.text.length < 11) { + if (Registry.keywatch.JP_DOWN) { + text_1.text += "D"; + } else if (Registry.keywatch.JP_RIGHT) { + text_1.text += "R"; + } else if (Registry.keywatch.JP_UP) { + text_1.text += "U"; + } else if (Registry.keywatch.JP_LEFT) { + text_1.text += "L"; + } else if (Registry.keywatch.JP_ACTION_1) { + text_1.text += "1"; + } else if (Registry.keywatch.JP_ACTION_2) { + text_1.text += "2"; + } + + + } else { + switch (text_1.text) { + case " UUDDLRLR21": + Registry.sound_data.get_key.play(); + Registry.GAMESTATE.player.health_bar.modify_health(20); + Achievements.unlock_all(); + break; + case " URDLURDLUR": + Registry.sound_data.shieldy_hit.play(); + Registry.sound_data.small_wave.play(); + Registry.sound_data.big_door_locked.play(); + FlxG.flash(0xffffffff, 3); + FlxG.shake(0.05, 3); + FlxG.scramble_cache(); + break; + case " URLDURLD11": + var p:Player = Registry.GAMESTATE.player; + p.loadGraphic(Player.Cell_Player_Sprite, true, false, 16, 16); + + break; + case " LRLR121212": + Registry.FUCK_IT_MODE_ON = !Registry.FUCK_IT_MODE_ON; + break; + default: + Registry.GAMESTATE.player.health_bar.modify_health( -2); + Registry.sound_data.sb_hurt.play(); + break; + } + text_1.text = " "; + } + + } + + private var secretz_idx:int = 0; + private var secretz_wordz:Array = new Array( + "You’re rolling in it!", + "Once the property of a famous Bubble Mage.", + "If your graphics become scrambled, look at the pokedex entry of an official Pokemon.", + "This heart has no name.", + "Please visit the electric monsters' world.", + "A kitty statue. Cute, but useless.", + "Oh my!!!!", + "Oh no!!!!", + "It's black.", + "It's red.", + "It's green.", + "It's blue.", + "It's white." + ); + private function secretz_logic():void { + if (Registry.keywatch.JP_ACTION_2) { + Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group); + state = s_browse; + secretz_idx = 0; + menu_select_active.visible = true; + menu_select_inactive.visible = false; + selectors.members[1].visible = false; + } + + if (Registry.keywatch.JP_RIGHT && (secretz_idx % 4) < 3) { + selectors.members[1].x += 24; + secretz_idx ++; + } else if (Registry.keywatch.JP_LEFT && (secretz_idx % 4) > 0) { + selectors.members[1].x -= 24; + secretz_idx --; + } + + if (Registry.keywatch.JP_DOWN && int(secretz_idx / 4) < 3) { + selectors.members[1].y += 20; + secretz_idx += 4; + } else if (Registry.keywatch.JP_UP && int(secretz_idx / 4) > 0) { + selectors.members[1].y -= 20; + secretz_idx -= 4; + } + + if (Registry.keywatch.JP_ACTION_1) { + if (trophies.members.length - 1 >= secretz_idx && trophies.members[secretz_idx].visible) { + DH.dialogue_popup(secretz_wordz[secretz_idx]); + } + } + } + + private function set_passive_effect(selector_index:int):void + { + var p:* = parent; + if (selector_index == Registry.IDX_WIDEN) { + // bound_effect ripples over to the state of the broom + if (Registry.bound_effect == Registry.item_names[Registry.IDX_WIDEN]) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } else { + Registry.bound_effect = Registry.item_names[Registry.IDX_WIDEN]; + p.player.action_latency_max = Player.WATK_DELAY; + } + } else if (selector_index == Registry.IDX_LENGTHEN) { + // bound_effect ripples over to the state of the broom + if (Registry.bound_effect == Registry.item_names[Registry.IDX_LENGTHEN]) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } else { + Registry.bound_effect = Registry.item_names[Registry.IDX_LENGTHEN]; + p.player.action_latency_max = Player.LATK_DELAY; + } + } else if (selector_index == Registry.IDX_BROOM) { + Registry.bound_effect = "none"; //de-equip the effect + p.player.action_latency_max = Player.ATK_DELAY; + } + } + + private function set_card_images():void + { + for (var card_page_idx:int = 0; card_page_idx < 12; card_page_idx++) { + if (1 == Registry.card_states[card_page_idx + cur_cards_pg * 12]) { + trace(card_page_idx + cur_cards_pg * 12); + cards.members[card_page_idx].frame = card_page_idx + cur_cards_pg * 12; + } else { + cards.members[card_page_idx].frame = 49; + } + } + } + + private function set_key_graphics():void + { + //not working + for (var i:int = 0; i < 3; i++) { + var key:FlxSprite = key_icons.members[i]; + key.loadGraphic(NPC.key_green_embed, true, false, 16, 16); + switch (i) { + case 0: if (Registry.inventory[Registry.IDX_GREEN_KEY]) { + key.frame = 0; + } else { + key.frame = 1; + } + break; + case 1: if (Registry.inventory[Registry.IDX_RED_KEY]) { + key.frame = 2; + } else { + key.frame = 3; + } + break; + case 2: if (Registry.inventory[Registry.IDX_BLUE_KEY]) { + key.frame = 4; + } else { + key.frame = 5; + } + break; + } + } + } + + private function check_for_exit_with(condition:Boolean):void + { + if (condition) { + if (exit_latency < 0) { + done = true; + exit_latency = 0.5; + current_substate_visible = false; + Registry.GAMESTATE.player.no_jump_ticks = 7; + reset_counters(); + menu_select_active.visible = true; + menu_select_inactive.visible = false; + window_words.visible = window_config.visible = false; + } + } else { + if (exit_latency > 0) { + exit_latency -= FlxG.elapsed; + } + } + } + + private function reset_counters():void { + + state = s_browse; + ctr_settings = 0; + map_ctr = 0; + map_cursor_idx = save_cursor_idx = settings_cursor_idx = equip_cursor_idx = equip_cursor_idx = 0; + doing_window_config = false; + + } + + private function dialogue_logic():void + { + Registry.GAMESTATE.dialogue_state.update(); + if (t_d > tm_d) { + if (Registry.GAMESTATE.dialogue_state.is_finished && (Registry.keywatch.JP_ACTION_2 || Registry.keywatch.JP_ACTION_1)) { + t_d = 0; + Registry.GAMESTATE.dialogue_state.reset(); + if (equip_cursor_idx >= 10) { + state = s_equip; + } else if (base_index == 5) { + state = s_secretz; + } else { + state = s_cards; // mayneed to change later + } + Registry.GAMESTATE.dialogue_state.pop(this as FlxState); + DH.dont_need_recently_finished(); + } + } else { + t_d += FlxG.elapsed; + } + } + + private function get_resolution_string(is_init:Boolean=false):String { + + if (Intra.is_mobile) return " "; + if (is_init) { + Intra.scale_ctr--; + } + var res:String = "Windowed"; + switch (Intra.scale_ctr) { + case 1: + res = "Int. Scaled"; + break; + case 2: + res = "Fit Scaled"; + break; + case 0: + res = "Windowed"; + break; + } + if (is_init) { + Intra.scale_ctr++; + } + return res; + } + private function set_settings_text(is_init:Boolean=false):void { + var autosave_state:String = Registry.autosave_on ? "On" : "Off"; + var first:String = Intra.is_mobile ? "Flip actions" : "Set controls"; + var last:String = Intra.is_mobile ? "Flip controls" : "Resize window"; + var res:String = Intra.is_mobile ? "\n\n\n" : "\n\nResolution:\n "; + if (is_init) { + text_1.setText(first+"\n\nSet volume\n\n\nAutosave at\ncheckpoints:\n " + autosave_state + res + get_resolution_string(true)+"\n\n\n"+last, true, 0, 0, "left", true); + } else { + text_1.setText(first+"\n\nSet volume\n\n\nAutosave at\ncheckpoints:\n " + autosave_state + res + get_resolution_string()+"\n\n\n"+last, true, 0, 0, "left", true); + } + } + + private function set_trade_item():void { + trade_item.visible = true; + if (Registry.inventory[Registry.IDX_BOX]) { + trade_item.loadGraphic(Trade_NPC.embed_dame_trade_npc, true, false, 16, 16); + trade_item.frame = 31; + } else if (Registry.inventory[Registry.IDX_BIKE_SHOES]) { + trade_item.loadGraphic(Trade_NPC.embed_dame_trade_npc, true, false, 16, 16); + trade_item.frame = 56; + } else { + trade_item.visible = false; + } + } + + private function set_trophy_vis(_trophies:FlxGroup, idx:int):void { + _trophies.members[idx].visible = false; + //_trophies.members[idx].visible = true; + switch (idx) { + case 0: + if (Registry.inventory[Registry.IDX_POO]) _trophies.members[idx].visible = true; + break; + case 1: + if (Registry.inventory[Registry.IDX_SPAM]) _trophies.members[idx].visible = true; + break; + case 2: + if (Registry.inventory[Registry.IDX_MISSINGNO]) _trophies.members[idx].visible = true; + break; + case 3: + if (Registry.inventory[Registry.IDX_AUS_HEART]) _trophies.members[idx].visible = true; + break; + case 4: + if (Registry.inventory[Registry.IDX_ELECTRIC]) _trophies.members[idx].visible = true; + break; + case 5: + if (Registry.inventory[Registry.IDX_KITTY]) _trophies.members[idx].visible = true; + break; + case 6: + if (Registry.inventory[Registry.IDX_MELOS]) _trophies.members[idx].visible = true; + break; + case 7: + if (Registry.inventory[Registry.IDX_MARINA]) _trophies.members[idx].visible = true; + break; + case 8: + if (Registry.inventory[Registry.IDX_BLACK]) _trophies.members[idx].visible = true; + break; + case 9: + if (Registry.inventory[Registry.IDX_RED]) _trophies.members[idx].visible = true; + break; + case 10: + if (Registry.inventory[Registry.IDX_GREEN]) _trophies.members[idx].visible = true; + break; + case 11: + if (Registry.inventory[Registry.IDX_BLUE]) _trophies.members[idx].visible = true; + break; + case 12: + if (Registry.inventory[Registry.IDX_WHITE]) _trophies.members[idx].visible = true; + break; + + + } + } + + private function is_crowd_minidungeon():Boolean { + return (Registry.CURRENT_MAP_NAME == "CROWD" && + ( + (Registry.CURRENT_GRID_X >= 4 && Registry.CURRENT_GRID_X <= 7 && Registry.CURRENT_GRID_Y == 7) || + (Registry.CURRENT_GRID_X == 7 && Registry.CURRENT_GRID_Y == 6) + ) + ); + } + private function card_pg_to_cards():void + { + selectors.members[3].visible = true; + selectors.members[2].visible = false; + selectors.members[1].visible = false; + selectors.members[3].play("enabled"); + selectors.members[2].play("disabled"); + selectors.members[1].play("disabled"); + selectors.members[3].x = cards.members[0].x - 10 + ((cards_cursor_idx % 3) * 30); + selectors.members[3].y = cards.members[0].y + 10 + (int(cards_cursor_idx / 3) * 29); + } + } + +} \ No newline at end of file