entity code
This commit is contained in:
parent
033ca7065e
commit
ad9514e54b
|
@ -0,0 +1,37 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import org.flixel.FlxSprite;
|
||||
/**
|
||||
* ...
|
||||
* @author seaga
|
||||
*/
|
||||
public class Eye_Light extends FlxSprite
|
||||
{
|
||||
[Embed(source = "../../res/sprites/decoration/eyelight.png")] public var Eye_Light_Sprite:Class;
|
||||
public var type:String = "Eye_Light";
|
||||
public var xml:XML;
|
||||
public var darkness:FlxSprite;
|
||||
public var light:FlxSprite;
|
||||
public var cid:int = CLASS_ID.EYE_LIGHT;
|
||||
|
||||
public function Eye_Light(x:int,y:int,_xml:XML, _darkness:FlxSprite)
|
||||
{
|
||||
super(x, y);
|
||||
xml = _xml;
|
||||
loadGraphic(Eye_Light_Sprite, true, false, 16, 16);
|
||||
immovable = true;
|
||||
addAnimation("glow", [0, 1, 2], 5, true);
|
||||
play("glow");
|
||||
darkness = _darkness;
|
||||
light = new Light(x - 16, y - 36, darkness, Light.T_FIVE_FRAME_GLOW,false,null);
|
||||
light.addAnimation("glow", [0, 0, 1, 2, 3, 4, 3, 2, 1, 0, 0, 0], 7, true);
|
||||
light.play("glow");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxBasic;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import flash.geom.ColorTransform;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Light extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../res/sprites/light/glow-light.png")] public var GLOW_LIGHT:Class;
|
||||
[Embed (source = "../../res/sprites/light/cone-light.png")] public var CONE_LIGHT:Class;
|
||||
[Embed (source = "../../res/sprites/light/5-frame-glow.png")] private var FIVE_FRAME_GLOW:Class;
|
||||
[Embed (source = "../../res/sprites/light/beach-screen-light.png")] private var BEACH_GLOW:Class;
|
||||
|
||||
public static var T_GLOW_LIGHT:int = 0;
|
||||
public static var T_FIVE_FRAME_GLOW:int = 1;
|
||||
public static var T_CONE_LIGHT:int = 2;
|
||||
public static var T_BEACH_GLOW:int = 3;
|
||||
public static var T_BEDROOM_BOUNCE:int = 4;
|
||||
private var locked_on:Boolean = false;
|
||||
private var lock_latency:Number = 2.0;
|
||||
private var lock_latency_max:Number = 2.0;
|
||||
private var current_room:Point = new Point(0, 0);
|
||||
|
||||
public static var L_PLAYER:int = 1;
|
||||
public static var L_SUN_GUY_ORBS:int = 2;
|
||||
public static var L_BEDROOM_BOUNCE:int = 3;
|
||||
|
||||
public var darkness:FlxSprite;
|
||||
public var followee:FlxSprite;
|
||||
public var flicker_rate:int = 0;
|
||||
public var base_x_scale:Number = 3.0;
|
||||
public var base_y_scale:Number = 3.0;
|
||||
public var flicker_timer:int = flicker_rate;
|
||||
public var special_type:int = 0;
|
||||
|
||||
public var xml:XML;
|
||||
/**
|
||||
* Creates a light at the given point, to be blended with the darkness reference. Specifying the type will
|
||||
* determine what to use. Client must specify the animation and offset.
|
||||
* @param _x
|
||||
* @param _y
|
||||
* @param _darkness A reference to the darkness sprite to draw into
|
||||
* @param type What type of light sprite to use
|
||||
* @param follows
|
||||
* @param _followee The sprite to follow
|
||||
* @param _flicker_rate
|
||||
* @param _special_type
|
||||
*/
|
||||
public function Light(_x:int, _y:int, _darkness:FlxSprite, type:int, follows:Boolean = false, _followee:FlxSprite=null,_flicker_rate:int=0,_special_type:int=0)
|
||||
{
|
||||
super(_x, _y);
|
||||
xml = <Light/>;
|
||||
setlighttype(type);
|
||||
|
||||
flicker_rate = _flicker_rate;
|
||||
darkness = _darkness;
|
||||
special_type = _special_type;
|
||||
blend = "screen";
|
||||
|
||||
followee = _followee;
|
||||
if (follows) {
|
||||
x = followee.x - ((followee.width - width) / 2);
|
||||
y = followee.y - ((followee.height - height) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
if (followee != null) {
|
||||
if (special_type == L_PLAYER) {
|
||||
x = followee.x- ((width - followee.width) / 2);
|
||||
y = followee.y - ((height - followee.height) / 2) - 16;
|
||||
} else if (special_type == L_SUN_GUY_ORBS) {
|
||||
x = followee.x + (followee.width / 2) - 26;
|
||||
y = followee.y + (followee.height / 2) - 45;
|
||||
} else if (special_type == L_BEDROOM_BOUNCE) {
|
||||
if (velocity.x > 0) {
|
||||
if (x > Registry.SCREEN_WIDTH_IN_PIXELS) {
|
||||
velocity.x *= -1;
|
||||
}
|
||||
} else {
|
||||
if (x < 0) {
|
||||
velocity.x *= -1;
|
||||
}
|
||||
}
|
||||
if (velocity.y > 0) {
|
||||
if (y > Registry.SCREEN_HEIGHT_IN_PIXELS) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
} else {
|
||||
if (y < 0) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
lock_latency -= FlxG.elapsed;
|
||||
/* Wait for a bit before locking onto the player */
|
||||
if (overlaps(followee, true) && lock_latency < 0) {
|
||||
locked_on = true;
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
/* If locked on follow the player */
|
||||
if (locked_on) {
|
||||
var _x:int = (followee.x - ((width - followee.width) / 2)) % Registry.SCREEN_WIDTH_IN_PIXELS;
|
||||
var _y:int = ((followee.y - 20) % Registry.SCREEN_HEIGHT_IN_PIXELS) - 16;
|
||||
EventScripts.send_property_to(this, "x", _x, 0.5);
|
||||
EventScripts.send_property_to(this, "y", _y, 0.5);
|
||||
} else { /* Randomize the velocity a bit */
|
||||
velocity.x += (Math.random() * 2 + -1);
|
||||
velocity.y += (Math.random() * 2 + -1);
|
||||
}
|
||||
/* Unlock on room transition */
|
||||
if (Registry.CURRENT_GRID_X != current_room.x || Registry.CURRENT_GRID_Y != current_room.y) {
|
||||
locked_on = false;
|
||||
lock_latency = lock_latency_max;
|
||||
current_room.x = Registry.CURRENT_GRID_X;
|
||||
current_room.y = Registry.CURRENT_GRID_Y;
|
||||
randomize_velocity();
|
||||
}
|
||||
|
||||
/* Not visible if sun boss defeated. */
|
||||
if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
flicker_timer--;
|
||||
if (flicker_timer < 0 && flicker_rate != 0) {
|
||||
scale.x = base_x_scale + Math.random() * 0.2;
|
||||
scale.y = base_y_scale + Math.random() * 0.2;
|
||||
flicker_timer = flicker_rate;
|
||||
} else {
|
||||
scale.x = base_x_scale;
|
||||
scale.y = base_y_scale;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
override public function draw():void {
|
||||
var screenXY:FlxPoint = getScreenXY();
|
||||
darkness.stamp(this, screenXY.x, screenXY.y);
|
||||
}
|
||||
|
||||
private function randomize_velocity():void
|
||||
{
|
||||
var i:int = int(4 * Math.random());
|
||||
var base_speed:int = 30;
|
||||
switch (i) {
|
||||
case 0:
|
||||
velocity.x = velocity.y = base_speed; break;
|
||||
case 1:
|
||||
velocity.x = velocity.y = -base_speed; break;
|
||||
case 2:
|
||||
velocity.x = base_speed; velocity.y = -base_speed; break;
|
||||
case 3:
|
||||
velocity.x = -base_speed; velocity.y = base_speed; break;
|
||||
}
|
||||
}
|
||||
|
||||
public function setlighttype(type:int):void
|
||||
{
|
||||
|
||||
if (type == T_GLOW_LIGHT) {
|
||||
loadGraphic(GLOW_LIGHT, false, false, 64, 64);
|
||||
framePixels.colorTransform(framePixels.rect, new ColorTransform(0.5, 0.5, 1, 1, 0, 0, -5));
|
||||
} else if (type == T_FIVE_FRAME_GLOW) {
|
||||
loadGraphic(FIVE_FRAME_GLOW, true, false, 48, 48);
|
||||
} else if (type == T_CONE_LIGHT) {
|
||||
loadGraphic(CONE_LIGHT, false, false, 32, 32);
|
||||
base_x_scale = 0.2;
|
||||
base_y_scale = 0.2;
|
||||
} else if (type == T_BEACH_GLOW) {
|
||||
loadGraphic(BEACH_GLOW, false, false, 160, 160);
|
||||
base_x_scale = base_y_scale = 1;
|
||||
scrollFactor = new FlxPoint(0, 0);
|
||||
} else if (type == T_BEDROOM_BOUNCE) {
|
||||
special_type = L_BEDROOM_BOUNCE;
|
||||
loadGraphic(GLOW_LIGHT, false, false, 64, 64);
|
||||
scrollFactor = new FlxPoint(0, 0);
|
||||
x = 160 * Math.random();
|
||||
y = 160 * Math.random();
|
||||
randomize_velocity();
|
||||
base_x_scale = base_y_scale = 2;
|
||||
current_room.x = Registry.CURRENT_GRID_X;
|
||||
current_room.y = Registry.CURRENT_GRID_Y;
|
||||
//x = followee.x - ((followee.width - width) / 2);
|
||||
//y = followee.y - ((followee.height - height) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BitmapDataChannel;
|
||||
import flash.geom.Point;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* test
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Map_Preview extends FlxSprite
|
||||
{
|
||||
|
||||
var erase_mask:FlxSprite = new FlxSprite();
|
||||
public function Map_Preview()
|
||||
{
|
||||
makeGraphic(16, 16, 0xffff0000);
|
||||
erase_mask.makeGraphic(16, 16, 0x00000000);
|
||||
for (var i:int = 0; i < 256; i++) {
|
||||
if (i % 2 == 0) {
|
||||
erase_mask.framePixels.setPixel32(i % 16, i / 16, 0xff000000);
|
||||
} else {
|
||||
erase_mask.framePixels.setPixel32(i % 16, i / 16, 0x00000000);
|
||||
}
|
||||
}
|
||||
erase_mask.blend = 'erase';
|
||||
draw();
|
||||
}
|
||||
|
||||
override public function draw():void
|
||||
{
|
||||
pixels.copyChannel(erase_mask.framePixels, erase_mask.framePixels.rect, new Point, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
|
||||
dirty = true;
|
||||
super.draw();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Nonsolid extends FlxSprite
|
||||
{
|
||||
|
||||
// embed the sprite file into the code.
|
||||
[Embed (source = "../../res/sprites/decoration/grass_1.png")] public static var grass_1_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/grass_REDSEA.png")] public static var grass_REDSEA_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/rail.png")] public static var rail_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/rail_NEXUS.png")] public static var rail_NEXUS_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/rail_CROWD.png")] public static var rail_CROWD_sprite:Class;
|
||||
|
||||
public function Nonsolid(_xml:XML)
|
||||
{
|
||||
// When adding one of these to DAME, supply it the image file,
|
||||
// the size of one frame, and add the "type" property to the DAME sprite
|
||||
// where "type" is some identifier.
|
||||
// There's a "Grass_1" sprite in there for an example.
|
||||
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
switch (_xml.@type.toString()) {
|
||||
// The word after "case" will be whatever you put in for "Type" in the DAME file.
|
||||
case "Grass_1":
|
||||
loadGraphic(grass_1_sprite, true, false, 16, 6);
|
||||
addAnimation("whatever", [0, 1], 10); //Add animations if you need to.
|
||||
play("whatever");
|
||||
break; //Don't forget this so the code exits the switch block. one for every case.
|
||||
case "Grass_REDSEA":
|
||||
loadGraphic(grass_REDSEA_sprite, true, false, 16, 16);
|
||||
play("whatever");
|
||||
break;
|
||||
case "Rail_1":
|
||||
loadGraphic(rail_sprite, true, false, 16, 16);
|
||||
break;
|
||||
case "Rail_NEXUS":
|
||||
loadGraphic(rail_NEXUS_sprite, true, false, 16, 17);
|
||||
break;
|
||||
case "Rail_CROWD":
|
||||
loadGraphic(rail_CROWD_sprite, true, false, 16, 22);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/**
|
||||
* RetroEffect
|
||||
* -- Generates a retro CRT distortion effect on the requested camera.
|
||||
* Inspired from the article http://active.tutsplus.com/tutorials/effects/create-a-retro-crt-distortion-effect-using-rgb-shifting/
|
||||
*
|
||||
* @version 1.0 - 31st January 2012
|
||||
* @link http://www.alanzucconi.com
|
||||
* @author Alan Zucconi
|
||||
*/
|
||||
package entity.decoration
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BitmapDataChannel;
|
||||
import flash.display.BlendMode;
|
||||
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
|
||||
import org.flixel.FlxCamera;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
|
||||
/** Class to generate a retro CRT distortion effect.
|
||||
* @author Alan Zucconi
|
||||
*/
|
||||
public class RetroEffect extends FlxSprite
|
||||
{
|
||||
private static var _zeroPoint:Point = new Point();
|
||||
|
||||
/** The camera where the effect should be applied. */
|
||||
private static var _camera:FlxCamera;
|
||||
/** The buffer where the effect is constructed. */
|
||||
private var _buffer : BitmapData;
|
||||
/** The buffer where the effect is constructed. */
|
||||
private var _output : BitmapData;
|
||||
|
||||
private var _bitmap : Bitmap;
|
||||
|
||||
/** The counter for the distortion effect. */
|
||||
private var _counter : Number = 0;
|
||||
/** The matrix to distort the image. */
|
||||
private var _distortion : Matrix = new Matrix();
|
||||
|
||||
/** Generates a new istance of the retro CTR distortion effect.
|
||||
* @param camera The camera where the effect should be applied.
|
||||
*/
|
||||
public function RetroEffect(camera:FlxCamera)
|
||||
{
|
||||
_camera = camera;
|
||||
|
||||
_buffer = new BitmapData(_camera.width, _camera.height, true, 0xFF000000);
|
||||
_output = new BitmapData(_camera.width, _camera.height, true, 0xFF000000);
|
||||
|
||||
_bitmap = new Bitmap();
|
||||
_bitmap.bitmapData = _buffer;
|
||||
}
|
||||
|
||||
/** Updates the counter. */
|
||||
override public function update():void
|
||||
{
|
||||
_counter += FlxG.elapsed;
|
||||
super.update();
|
||||
}
|
||||
|
||||
/** Apply the effect. */
|
||||
override public function draw ():void
|
||||
{
|
||||
var output : BitmapData = effect(_camera.screen.pixels);
|
||||
_camera.screen.pixels.draw(output);
|
||||
}
|
||||
|
||||
public function randRange(min:Number, max:Number):Number {
|
||||
var randomNum:Number = (Math.random() * (max - min)) + min;
|
||||
return randomNum;
|
||||
}
|
||||
|
||||
/** Apply the effect on the image.
|
||||
* @param source The bitamp to change.
|
||||
* @return The changed bitmap.
|
||||
*/
|
||||
private function effect (source:BitmapData):BitmapData
|
||||
{
|
||||
// Red channel ------------------------------------------
|
||||
_buffer.fillRect(source.rect, 0xFF000000);
|
||||
_buffer.copyChannel(source, source.rect, _zeroPoint, BitmapDataChannel.RED, BitmapDataChannel.RED );
|
||||
_bitmap.alpha = randRange(8, 10) / 10;
|
||||
|
||||
_distortion.a = sinusoid(_counter + 0 / 5, 1.09, 1.2 , 0.5);
|
||||
_distortion.d = sinusoid(_counter + 2 / 5, 1, 1.21 , 0.5);
|
||||
|
||||
//_distortion.ty = sinusoid(_counter + 0/5, 0, -1 ,0.5)
|
||||
_output.draw(_bitmap, _distortion, null, null, null, true);
|
||||
|
||||
// Green channel ------------------------------------------
|
||||
_buffer.fillRect(source.rect, 0xFF000000);
|
||||
_buffer.copyChannel(source, source.rect, _zeroPoint, BitmapDataChannel.GREEN, BitmapDataChannel.GREEN);
|
||||
_bitmap.alpha = randRange(8, 10) / 10;
|
||||
|
||||
_distortion.a = sinusoid(_counter + 1 / 5, 0.89, 1.00 , 0.5);
|
||||
_distortion.d = sinusoid(_counter + 1 / 5, 1, 1.01 , 0.5);
|
||||
//_distortion.ty = sinusoid(_counter + 1/5, 0, -1 ,0.5)
|
||||
_output.draw(_bitmap, _distortion, null, BlendMode.SCREEN, null, true);
|
||||
|
||||
// Blue channel ------------------------------------------
|
||||
_buffer.fillRect(source.rect, 0xFF000000);
|
||||
_buffer.copyChannel(source, source.rect, _zeroPoint, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE );
|
||||
_bitmap.alpha = randRange(8, 10)/10;
|
||||
|
||||
_distortion.a = sinusoid(_counter + 2 / 5, 0.99, 1.20 , 3.5);
|
||||
_distortion.d = sinusoid(_counter + 0 / 5, 1, 1.01 , 3.5);
|
||||
//_distortion.ty = sinusoid(_counter + 2/5, 0, -1 ,0.5)
|
||||
_output.draw(_bitmap, _distortion, null, BlendMode.SCREEN, null, true);
|
||||
|
||||
return _output;
|
||||
}
|
||||
|
||||
/** Generate a custom sinusoid curve.
|
||||
* @param x The x value.
|
||||
* @param min The minimun value of this sinusoid.
|
||||
* @param max The maximum value of this sinusoid.
|
||||
* @param period The period of this sinusoid.
|
||||
* @return The y value.
|
||||
*/
|
||||
public function sinusoid (x:Number, min:Number, max:Number, periodo:Number) : Number {
|
||||
var escursione :Number = max - min;
|
||||
var coefficiente :Number = Math.PI * 2 / periodo;
|
||||
return escursione / 2 * (1 + Math.sin(x * coefficiente)) + min;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.interactive.NPC;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import org.flixel.FlxBasic;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Solid_Sprite extends FlxSprite
|
||||
{
|
||||
/* * * * *
|
||||
* a dame-placed solid sprite. can be animated.
|
||||
* * * * */
|
||||
[Embed (source = "../../res/sprites/decoration/red_cave_left.png")] public static var red_cave_left_sprite:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/TREE.png")] public static var trees_sprites:Class;
|
||||
public var xml:XML;
|
||||
public var type_str:String;
|
||||
public var cid:int = CLASS_ID.SOLID_SPRITE;
|
||||
public var player:Player;
|
||||
public var dame_frame:int;
|
||||
public var active_region:FlxObject;
|
||||
|
||||
|
||||
public function Solid_Sprite(_xml:XML,is_cutscene:Boolean=false,_player:Player=null)
|
||||
{
|
||||
x = parseInt(_xml.@x);
|
||||
y = parseInt(_xml.@y);
|
||||
xml = _xml;
|
||||
type_str = _xml.@type;
|
||||
dame_frame = parseInt(_xml.@frame);
|
||||
|
||||
super(x, y);
|
||||
player = _player;
|
||||
if (type_str == "red_cave_l_ss" && Registry.CURRENT_GRID_X != 3 && Registry.CURRENT_GRID_Y > 3) {
|
||||
immovable = true;
|
||||
if (!is_cutscene && !Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Left]) {
|
||||
exists = false;
|
||||
} else {
|
||||
loadGraphic(red_cave_left_sprite, true, false, 64, 64);
|
||||
width = 56; height = 28;
|
||||
offset.y = 32; y += 32;
|
||||
offset.x = 4; x += 4;
|
||||
if (is_cutscene) {
|
||||
addAnimation("a", [0], 20, true); play("a"); scrollFactor.x = scrollFactor.y = 0;
|
||||
}
|
||||
}
|
||||
} else if (type_str == "red_cave_l_ss") { // CENTRAL ACTUALLY.
|
||||
immovable = true;
|
||||
loadGraphic(red_cave_left_sprite, true, false, 64, 64);
|
||||
width = 56; height = 28;
|
||||
offset.y = 32; y += 32;
|
||||
offset.x = 4; x += 4;
|
||||
|
||||
} else if (type_str == "red_cave_r_ss") {
|
||||
immovable = true;
|
||||
if (!is_cutscene && !Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Right]) {
|
||||
exists = false;
|
||||
} else {
|
||||
loadGraphic(red_cave_left_sprite, true, false, 64, 64);
|
||||
width = 56; height = 28;
|
||||
offset.y = 32; y += 32;
|
||||
offset.x = 4; x += 4;
|
||||
if (is_cutscene) {
|
||||
addAnimation("a", [0], 20, true); play("a"); scrollFactor.x = scrollFactor.y = 0;
|
||||
}
|
||||
}
|
||||
} else if (type_str == "red_cave_n_ss") {
|
||||
immovable = true;
|
||||
if (!is_cutscene && !Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_North]) {
|
||||
exists = false;
|
||||
} else {
|
||||
loadGraphic(red_cave_left_sprite, true, false, 64, 64);
|
||||
width = 56; height = 28;
|
||||
offset.y = 32; y += 32;
|
||||
offset.x = 4; x += 4;
|
||||
if (is_cutscene) {
|
||||
addAnimation("a", [0], 20, true); play("a"); scrollFactor.x = scrollFactor.y = 0;
|
||||
}
|
||||
}
|
||||
} else if (type_str == "blocker") {
|
||||
immovable = true;
|
||||
makeGraphic(64, 4, 0x00000000);
|
||||
} else if (type_str == "vblock") {
|
||||
immovable = true;
|
||||
makeGraphic(4, 16, 0x00000000);
|
||||
} else if (type_str == "tree") {
|
||||
// Change the w/h of this draw call if you want the max size of a tree (or whatever) to be bigger/smaller
|
||||
loadGraphic(trees_sprites, true, false, 64,64);
|
||||
frame = dame_frame;
|
||||
|
||||
immovable = true;
|
||||
switch (dame_frame) {
|
||||
case 0:
|
||||
// Set where the hitbox is and its size
|
||||
set_props(16, 32, 32, 32);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (type_str == "sign") {
|
||||
loadGraphic(NPC.note_rock, true, false, 16, 16);
|
||||
frame = parseInt(xml.@frame);
|
||||
active_region = new FlxObject(x - 2, y + 14, 20, 5);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
immovable = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this solid sprites properites
|
||||
* @param ox offset of the hitbox
|
||||
* @param oy offset of the hitbox (y)
|
||||
* @param w width of hitbox
|
||||
* @param h
|
||||
*/
|
||||
private function set_props(ox:int, oy:int, w:int, h:int):void {
|
||||
offset.x = ox;
|
||||
offset.y = oy;
|
||||
width = w;
|
||||
height = h;
|
||||
x += ox;
|
||||
y += oy;
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (player != null) {
|
||||
if (type_str == "blocker") {
|
||||
if (player.overlaps(this) && player.velocity.y > 0 && player.y < y) {
|
||||
player.y = y - player.height;
|
||||
} else if (player.overlaps(this) && player.velocity.y < 0 && player.y > y) {
|
||||
player.y = y + height;
|
||||
}
|
||||
} else if (type_str == "vblock") {
|
||||
if (player.overlaps(this)) {
|
||||
if (player.velocity.x < 0) {
|
||||
player.x = x + width;
|
||||
} else {
|
||||
player.x = x - player.width;
|
||||
}
|
||||
}
|
||||
} else if (type_str == "tree") {
|
||||
FlxG.collide(player, this);
|
||||
} else if (type_str == "sign") {
|
||||
FlxG.collide(player, this);
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y + 14;
|
||||
if (DH.nc(player, active_region)) {
|
||||
if (frame == 2) { //r
|
||||
//DH.dialogue_popup("The sign points to the east but the words on it are faded.");
|
||||
DH.dialogue_popup(DH.lk("solidsprite", 0));
|
||||
} else if (frame == 3) { //l
|
||||
//DH.dialogue_popup("The sign points to the west but the words on it are faded.");
|
||||
DH.dialogue_popup(DH.lk("solidsprite", 1));
|
||||
} else if (frame == 4) { // u/d
|
||||
//DH.dialogue_popup("The words on the sign are faded.");
|
||||
DH.dialogue_popup(DH.lk("solidsprite", 2));
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
FlxG.collide(player, this);
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package entity.decoration
|
||||
{
|
||||
import data.TileData;
|
||||
import global.Registry;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxTilemap;
|
||||
/**
|
||||
* Given a map buffer will transform a list of tiles at some rate into water or whatever
|
||||
*/
|
||||
public class Water_Anim extends AnoSprite
|
||||
{
|
||||
|
||||
private var started:Boolean = false;
|
||||
|
||||
private var target_tiles:Array; // List of tiles [0,99] that will be transformed in order
|
||||
private var target_tile_types:Array; // What each tile will change to.
|
||||
|
||||
private var latency:Number = 0.3; //Time between tile transforms
|
||||
private var t:Number = 0;
|
||||
|
||||
private var map_ref:FlxTilemap;
|
||||
private var map_name:String;
|
||||
|
||||
public var anim_tiles:FlxGroup; // Group of animated tiles, added to parent.
|
||||
|
||||
private var anim_idx:int = 0; // Which animated tile in anim_tiles will be visible next.
|
||||
private var cur_idx:int = 0; // Which tile in target_tiles, w.r.t. the current wscreen, will change next.
|
||||
|
||||
|
||||
public static var START_WATER_ANIM:Boolean = false;
|
||||
public function Water_Anim(args:Array)
|
||||
{
|
||||
super(args);
|
||||
map_name = Registry.CURRENT_MAP_NAME;
|
||||
START_WATER_ANIM = false; // Reset this every tiemmmm
|
||||
switch (map_name) {
|
||||
case "DEBUG":
|
||||
target_tiles = new Array(10, 11, 12, 13, 14);
|
||||
target_tile_types = new Array(16,17,18,19,19);
|
||||
latency = 0.3;
|
||||
break;
|
||||
case "BLUE":
|
||||
target_tiles = new Array(3,13,23,33,32,31,30);
|
||||
target_tile_types = new Array(31,31,31,30,30,30,30);
|
||||
latency = 0.3;
|
||||
break;
|
||||
case "HAPPY":
|
||||
target_tiles = new Array(6,16,26,36,37,38,39);
|
||||
target_tile_types = new Array(41,41,41,40,40,40,40);
|
||||
latency = 0.3;
|
||||
break;
|
||||
case "GO":
|
||||
var gx:int = Registry.CURRENT_GRID_X;
|
||||
var gy:int = Registry.CURRENT_GRID_Y;
|
||||
|
||||
if (gx == 0 && gy == 2) {
|
||||
if (Registry.GE_States[Registry.GE_Briar_Happy_Done]) {
|
||||
xml.@alive = "true";
|
||||
}
|
||||
target_tiles = new Array(30, 31, 32, 33, 34, 35, 36, 37, 38, 39);
|
||||
target_tile_types = new Array(190,190,190,190,190,190,190,190,190,190);
|
||||
|
||||
} else if (gx == 1 && gy == 2) {
|
||||
if (Registry.GE_States[Registry.GE_Briar_Happy_Done]) xml.@alive = "true";
|
||||
target_tiles = new Array(30,31,32,33,34,35,36,37,27,17,7);
|
||||
target_tile_types = new Array(190,190,190,190,190,190,190,191,191,191,191);
|
||||
} else if (gx == 2 && gy == 1) {
|
||||
latency = 0.2;
|
||||
target_tiles = new Array(40, 41, 31, 21, 22, 12, 13, 49, 48, 38, 28, 27, 17, 16, 15, 5, 14, 4);
|
||||
target_tile_types = new Array(190,191,191,190,191,190,190,192,193,193,192,193,192,192,194,194,194,194);
|
||||
|
||||
} else if (gx == 3 && gy == 2) {
|
||||
if (Registry.GE_States[Registry.GE_Briar_Blue_Done]) xml.@alive = "true";
|
||||
target_tiles = new Array(2,12,22,32,33,34,35,36,37,38,39);
|
||||
target_tile_types = new Array(193,193,193,193,192,192,192,192,192,192,192);
|
||||
} else if (gx == 4 && gy == 2) {
|
||||
if (Registry.GE_States[Registry.GE_Briar_Blue_Done]) xml.@alive = "true";
|
||||
target_tiles = new Array(30, 31, 32, 33, 34, 35, 36, 37, 38, 39);
|
||||
target_tile_types = new Array(192,192,192,192,192,192,192,192,192,192);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
exists = false;
|
||||
break;
|
||||
}
|
||||
visible = false;
|
||||
anim_tiles = new FlxGroup();
|
||||
//set up group and indices
|
||||
//TileData.make_anim_tile(anim_tiles,map_name,.,
|
||||
|
||||
for (var i:int = 0; i < target_tiles.length; i++) {
|
||||
TileData.make_anim_tile(anim_tiles, map_name, target_tile_types[i], tl.x + 16 * (target_tiles[i] % 10), tl.y + 16 * int(target_tiles[i] / 10));
|
||||
}
|
||||
anim_tiles.setAll("visible", false);
|
||||
parent.anim_tiles_group.add(anim_tiles);
|
||||
|
||||
// If we activated this event already, the animated tiles should be visible.
|
||||
if (xml.@alive == "true") {
|
||||
anim_tiles.setAll("visible", true);
|
||||
|
||||
while (set_next_tile()) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function set_next_tile():Boolean {
|
||||
|
||||
if (cur_idx < target_tiles.length) {
|
||||
if (TileData.animtiles_indices_dict[Registry.CURRENT_MAP_NAME].indexOf(target_tile_types[cur_idx]) != -1) {
|
||||
anim_tiles.members[anim_idx].visible = true;
|
||||
anim_idx++;
|
||||
}
|
||||
|
||||
parent.curMapBuf.setTileByIndex(target_tiles[cur_idx], target_tile_types[cur_idx], true);
|
||||
cur_idx++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static var UNALIVE:Boolean = false;
|
||||
override public function update():void
|
||||
|
||||
{
|
||||
|
||||
if (UNALIVE) {
|
||||
xml.@alive = "false";
|
||||
UNALIVE = false;
|
||||
}
|
||||
|
||||
if (START_WATER_ANIM) {
|
||||
START_WATER_ANIM = false;
|
||||
if (xml.@alive == "false") {
|
||||
started = true;
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
}
|
||||
}
|
||||
|
||||
if (started) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > latency) {
|
||||
t = 0;
|
||||
if (!set_next_tile()) { // When finished...
|
||||
started = false;
|
||||
xml.@alive = "true";
|
||||
if (Registry.CURRENT_MAP_NAME != "BLUE") {
|
||||
|
||||
player.state = player.S_GROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function start():void {
|
||||
|
||||
if (xml.@alive == "true") {
|
||||
return;
|
||||
//Yeah no.
|
||||
}
|
||||
started = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function START_WATER_ANIMF():void {
|
||||
START_WATER_ANIM = true;
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
target_tile_types = null;
|
||||
target_tiles = null;
|
||||
anim_tiles = null;
|
||||
map_ref = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a single screen's 10x10 tilemap
|
||||
* @param map
|
||||
*/
|
||||
public function set_map(map:FlxTilemap):void {
|
||||
map_ref = map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Dust;
|
||||
import entity.gadget.Switch_Pillar;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Dash_Trap extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/apartment/dash_trap.png")] public static var dash_trap_sprite:Class;
|
||||
private var xml:XML;
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
|
||||
public var state:int = 0;
|
||||
private var s_idle:int = 0;
|
||||
private var s_moving:int = 1;
|
||||
private var s_retracting:int = 2;
|
||||
|
||||
private var idle_pt:Point = new Point;
|
||||
private var dash_vel:int = 80;
|
||||
private var h_sight:FlxSprite = new FlxSprite();
|
||||
private var v_sight:FlxSprite = new FlxSprite();
|
||||
|
||||
private var retract_vel:Point = new Point();
|
||||
|
||||
public var cid:int = CLASS_ID.DASHTRAP;
|
||||
|
||||
private var frame_type:int = 0;
|
||||
private var t_normal:int = 0;
|
||||
private var t_bounce_v:int = 2;
|
||||
private var t_bounce_h:int = 1;
|
||||
|
||||
private var ctr:int = 0;
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
public function Dash_Trap(_x:XML, _p:Player, _pa:*)
|
||||
{
|
||||
|
||||
xml = _x;
|
||||
player = _p;
|
||||
parent = _pa;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Dash Trap anims */
|
||||
makeGraphic(16, 16, 0xff594312);
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
addAnimation("idle", [6], 12); //when still
|
||||
addAnimation("dash", [6], 12, false); //when beginning to move
|
||||
addAnimation("bounce", [6], 12, false); //when hitting anything
|
||||
} else {
|
||||
addAnimation("idle", [4], 12); //when still
|
||||
addAnimation("dash", [5], 12, false); //when beginning to move
|
||||
addAnimation("bounce", [4, 5], 12, false); //when hitting anything
|
||||
}
|
||||
play("idle");
|
||||
loadGraphic(dash_trap_sprite, true, false, 16, 16);
|
||||
|
||||
|
||||
h_sight.makeGraphic(320, 10, 0xff114411);
|
||||
h_sight.x = x - 160;
|
||||
h_sight.y = y + 3 + Registry.HEADER_HEIGHT;
|
||||
v_sight.makeGraphic(14, 320, 0xff441144);
|
||||
v_sight.x = x + 1;
|
||||
v_sight.y = y - 160 + Registry.HEADER_HEIGHT;
|
||||
|
||||
Registry.subgroup_dash_traps.push(this);
|
||||
|
||||
width = height = 14;
|
||||
centerOffsets(true);
|
||||
idle_pt.x = x;
|
||||
idle_pt.y = y + Registry.HEADER_HEIGHT;
|
||||
|
||||
parent.bg_sprites.add(h_sight);
|
||||
parent.bg_sprites.add(v_sight);
|
||||
h_sight.visible = v_sight.visible = false;
|
||||
|
||||
add_sfx("dash", Registry.sound_data.slasher_atk);
|
||||
add_sfx("hit", Registry.sound_data.shieldy_ineffective);
|
||||
|
||||
}
|
||||
|
||||
private var ticker:int = 0;
|
||||
override public function preUpdate():void
|
||||
{
|
||||
ticker += 1;
|
||||
if (ticker == 3) {
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
ticker = 0;
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
if (parseInt(xml.@frame) > 0) {
|
||||
play("dash");
|
||||
frame_type = parseInt(xml.@frame);
|
||||
switch (frame_type) {
|
||||
case t_bounce_h:
|
||||
state = s_moving;
|
||||
velocity.x = dash_vel;
|
||||
break;
|
||||
case t_bounce_v:
|
||||
state = s_moving;
|
||||
velocity.y = dash_vel;
|
||||
break;
|
||||
case 6:
|
||||
frame_type = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//EventScripts.prevent_leaving_map(parent, this);
|
||||
} else {
|
||||
velocity.x = velocity.y = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (maybe_bounce()) return;
|
||||
|
||||
if (state == s_idle) {
|
||||
if (player.overlaps(h_sight)) {
|
||||
if (player.x >= x) {
|
||||
velocity.x = dash_vel;
|
||||
retract_vel.x = -dash_vel / 2;
|
||||
} else {
|
||||
velocity.x = -dash_vel;
|
||||
retract_vel.x = dash_vel / 2;
|
||||
}
|
||||
play_sfx("dash");
|
||||
state = s_moving;
|
||||
play("dash");
|
||||
} else if (player.overlaps(v_sight)) {
|
||||
if (player.y <= y) {
|
||||
velocity.y = -dash_vel;
|
||||
retract_vel.y = dash_vel / 2;
|
||||
} else {
|
||||
velocity.y = dash_vel;
|
||||
retract_vel.y = -dash_vel / 2;
|
||||
}
|
||||
state = s_moving;
|
||||
play_sfx("dash");
|
||||
play("dash");
|
||||
}
|
||||
if ( player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
} else if (state == s_moving) {
|
||||
if (touching != NONE) {
|
||||
play_sfx("hit");
|
||||
state = s_retracting;
|
||||
}
|
||||
|
||||
if (player.state != player.S_AIR && player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
state = s_retracting;
|
||||
play_sfx("hit");
|
||||
}
|
||||
|
||||
for each (var dashtrap:Dash_Trap in Registry.subgroup_dash_traps) {
|
||||
if (dashtrap == null) continue;
|
||||
if (dashtrap != this && dashtrap.overlaps(this)) {
|
||||
state = s_retracting;
|
||||
play_sfx("hit");
|
||||
}
|
||||
}
|
||||
|
||||
for each (var dust:Dust in Registry.subgroup_dust) {
|
||||
if (dust == null) continue;
|
||||
if (dust.overlaps(this)) {
|
||||
play_sfx("hit");
|
||||
state = s_retracting;
|
||||
}
|
||||
}
|
||||
|
||||
for each (var sp:Switch_Pillar in Registry.subgroup_switch_pillars) {
|
||||
if (sp == null) continue;
|
||||
if (sp.overlaps(this) && sp.up_frame == sp.frame) {
|
||||
play_sfx("hit");
|
||||
state = s_retracting;
|
||||
}
|
||||
}
|
||||
|
||||
if (y > Registry.CURRENT_GRID_Y * 160 + 16 * 9 + 20) {
|
||||
play_sfx("hit");
|
||||
state = s_retracting;
|
||||
}
|
||||
|
||||
if (state == s_retracting) {
|
||||
|
||||
play("bounce", true);
|
||||
velocity.x = retract_vel.x;
|
||||
velocity.y = retract_vel.y;
|
||||
}
|
||||
} else if (state == s_retracting) {
|
||||
if (Math.abs(x - idle_pt.x) < 2 && Math.abs(y - idle_pt.y) < 2) {
|
||||
state = s_idle;
|
||||
play("idle");
|
||||
x = idle_pt.x;
|
||||
y = idle_pt.y;
|
||||
retract_vel.x = retract_vel.y = velocity.y = velocity.x = 0;
|
||||
}
|
||||
if (player.state != player.S_AIR && player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic for dash traps that bounce back and forth
|
||||
* */
|
||||
private function maybe_bounce():Boolean
|
||||
{
|
||||
if (frame_type > 0) {
|
||||
if (!player.invincible && player.overlaps(this) && player.state != player.S_AIR) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (Registry.is_playstate) {
|
||||
if (x + width > parent.rightBorder) {
|
||||
touching = RIGHT;
|
||||
} else if (x < parent.leftBorder) {
|
||||
touching = LEFT;
|
||||
} else if (y < parent.upperBorder) {
|
||||
touching = UP;
|
||||
} else if (y + height > parent.lowerBorder) {
|
||||
touching = DOWN;
|
||||
}
|
||||
}
|
||||
if (frame_type == t_bounce_h) {
|
||||
if (ctr == 0) {
|
||||
if (touching == RIGHT) {
|
||||
velocity.x = -dash_vel;
|
||||
ctr = 1;
|
||||
play_sfx("hit");
|
||||
play("bounce", true);
|
||||
}
|
||||
} else {
|
||||
if (touching == LEFT) {
|
||||
velocity.x = dash_vel;
|
||||
ctr = 0;
|
||||
play_sfx("hit");
|
||||
play("bounce", true);
|
||||
}
|
||||
}
|
||||
} else if (frame_type == t_bounce_v) {
|
||||
if (ctr == 0) {
|
||||
if (touching == DOWN) {
|
||||
velocity.y = -dash_vel;
|
||||
ctr = 1;
|
||||
play_sfx("hit");
|
||||
play("bounce", true);
|
||||
}
|
||||
} else {
|
||||
if (touching == UP) {
|
||||
velocity.y = dash_vel;
|
||||
ctr = 0;
|
||||
play_sfx("hit");
|
||||
play("bounce", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Gasguy extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/apartment/gas_guy.png")] public static var gas_guy_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/apartment/gas_guy_cloud.png")] public static var gas_guy_cloud_sprite:Class;
|
||||
|
||||
public var xml:XML;
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
private var gas_group:FlxGroup = new FlxGroup(3);
|
||||
|
||||
private var state:int = 1;
|
||||
private var s_normal:int = 0;
|
||||
|
||||
private var s_shoot:int = 1;
|
||||
private var t:Number = 4;
|
||||
private var tm:Number = 5.0;
|
||||
private var initial_latency:Number = 1.5;
|
||||
private var tm_shoot_latency:Number = 1.2;
|
||||
|
||||
private var s_dying:int = 2;
|
||||
private var s_dead:int = 3;
|
||||
|
||||
private var s_shoot_latency:int = 4;
|
||||
|
||||
private var tm_move_sound:Number;
|
||||
private var t_move_sound:Number = 0;
|
||||
|
||||
|
||||
private var just_hit:Boolean = false;
|
||||
|
||||
public var cid:int = CLASS_ID.GASGUY;
|
||||
|
||||
public function Gasguy(_x:XML, _p:Player, _pa:*)
|
||||
{
|
||||
|
||||
xml = _x;
|
||||
player = _p;
|
||||
parent = _pa;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* add gas guy anims */
|
||||
loadGraphic(gas_guy_sprite, true, false, 16, 24);
|
||||
addAnimation("float", [0, 1], 2, true);
|
||||
addAnimation("release_gas", [2], 20, true);
|
||||
play("float");
|
||||
|
||||
/* Make gas and add adnimations for gas*/
|
||||
for (var i:int = 0; i < gas_group.maxSize; i++ ) {
|
||||
var gas:FlxSprite = new FlxSprite();
|
||||
gas.loadGraphic(gas_guy_cloud_sprite, true, false, 24, 24);
|
||||
gas.addAnimation("gas_move", [0, 1], 3);
|
||||
gas.width = gas.height = 16;
|
||||
gas.offset.x = 4;
|
||||
gas.offset.y = 4;
|
||||
gas.centerOffsets(true);
|
||||
gas.play("gas_move");
|
||||
gas.flicker( -1);
|
||||
|
||||
gas_group.add(gas);
|
||||
gas.x = x;
|
||||
gas.visible = false;
|
||||
gas.y = y;
|
||||
Registry.subgroup_gas.push(gas);
|
||||
}
|
||||
|
||||
parent.fg_sprites.add(gas_group);
|
||||
|
||||
|
||||
drag.x = drag.y = 30;
|
||||
has_tile_callbacks = false;
|
||||
health = 3;
|
||||
state = s_normal;
|
||||
|
||||
add_sfx("move", Registry.sound_data.gasguy_move);
|
||||
add_sfx("shoot", Registry.sound_data.gasguy_shoot);
|
||||
|
||||
tm_move_sound = 1.5 + Math.random();
|
||||
}
|
||||
|
||||
private var ticks:int = 0;
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
t_move_sound += FlxG.elapsed;
|
||||
if (t_move_sound > tm_move_sound && visible) {
|
||||
t_move_sound = 0;
|
||||
play_sfx("move");
|
||||
}
|
||||
|
||||
if (initial_latency > 0) {
|
||||
initial_latency -= FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
}
|
||||
}
|
||||
|
||||
var gas:FlxSprite;
|
||||
|
||||
ticks += 1;
|
||||
for each (gas in gas_group.members) {
|
||||
|
||||
//broom reduces gas lifepan
|
||||
if (ticks == 3) {
|
||||
if (player.broom.visible && player.broom.overlaps(gas)) {
|
||||
gas.alpha -= 0.025;
|
||||
}
|
||||
gas.alpha -= 0.003;
|
||||
}
|
||||
//use sin table or dont dum
|
||||
// gas.scale.x = 1 + 0.25*Math.sin(12 * (t / tm));
|
||||
// gas.scale.y = 1 + 0.25*Math.sin(6 * (t / tm));
|
||||
if (gas.alpha > 0.3 && gas.visible && gas.overlaps(player)) {
|
||||
player.sig_reverse = true;
|
||||
}
|
||||
}
|
||||
if (ticks == 3) ticks = 0;
|
||||
|
||||
if (state == s_dead) return;
|
||||
|
||||
EventScripts.send_property_to(this, "x", player.x, 0.2);
|
||||
EventScripts.send_property_to(this, "y", player.y, 0.2);
|
||||
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(this)) {
|
||||
health--;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
flicker(0.5);
|
||||
if (health <= 0) state = s_dying;
|
||||
var p:Point = new Point(player.x, player.y);
|
||||
var _p:Point = new Point(x, y);
|
||||
EventScripts.scale_vector(p, _p, velocity, 100);
|
||||
}
|
||||
|
||||
if (player.overlaps(this)) {
|
||||
if (state != s_dead) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//wait a bit befoore shooting again
|
||||
if (state == s_normal) {
|
||||
t += FlxG.elapsed;
|
||||
|
||||
if (t > tm) {
|
||||
state = s_shoot_latency;
|
||||
play("release_gas");
|
||||
t = 0;
|
||||
}
|
||||
} else if (state == s_shoot) {
|
||||
var p1:Point = new Point(player.x, player.y);
|
||||
var _p1:Point = new Point(x, y);
|
||||
for each (gas in gas_group.members) {
|
||||
EventScripts.scale_vector(_p1, p1, gas.velocity, 30);
|
||||
gas.visible = true;
|
||||
gas.x = x;
|
||||
gas.y = y;
|
||||
play_sfx("shoot");
|
||||
gas.velocity.x += ( -10 + 20 * Math.random());
|
||||
gas.velocity.y += ( -10 + 20 * Math.random());
|
||||
gas.alpha = 0.8;
|
||||
}
|
||||
state = s_normal;
|
||||
play("float");
|
||||
|
||||
} else if (state == s_shoot_latency) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_shoot_latency) {
|
||||
t = 0;
|
||||
state = s_shoot;
|
||||
}
|
||||
} else if (state == s_dying) {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
|
||||
EventScripts.drop_big_health(x, y, 0.6);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
|
||||
xml.@alive = "false";
|
||||
state = s_dead;
|
||||
alive = false;
|
||||
visible = false;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Dust;
|
||||
import entity.gadget.Switch_Pillar;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
import org.flixel.system.FlxTile;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Rat extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/apartment/rat.png")] public static var rat_sprite:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
private var move_vel:int = 40;
|
||||
private var lookahead:FlxSprite = new FlxSprite();
|
||||
private var pp_off:Point = new Point(0, 0); //pin point for lookahead
|
||||
|
||||
public var cid:int = CLASS_ID.RAT;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_normal:int = 0;
|
||||
private var s_dying:int = 1;
|
||||
private var s_dead:int = 2;
|
||||
|
||||
private var do_rotations:Boolean = false;
|
||||
|
||||
private var hurt_box:FlxSprite = new FlxSprite;
|
||||
|
||||
public function Rat(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
solid = false;
|
||||
|
||||
loadGraphic(rat_sprite, true, false, 16, 16);
|
||||
var o:int = (Registry.CURRENT_MAP_NAME == "TRAIN") ? 6 : 0;
|
||||
addAnimation("up", [o+4, o+5], 5);
|
||||
addAnimation("down", [o+0, o+1], 5);
|
||||
addAnimation("r", [o+2, o+3], 5); //DEFAULT: RIGHT
|
||||
addAnimation("l", [o+2, o+3], 5);
|
||||
/* Flip this boolean if you want rotations instead of separate right/down/up sprites */
|
||||
/* If so, rotations assume that the spritesheet is originally facing DOWN */
|
||||
do_rotations = false;
|
||||
|
||||
addAnimation("die", [0, 1], 30);
|
||||
play("down");
|
||||
|
||||
if (parseInt(xml.@frame) == 0) {
|
||||
play("down");
|
||||
facing = DOWN;
|
||||
velocity.y = move_vel;
|
||||
|
||||
pp_off.x = 7;
|
||||
pp_off.y = 18;
|
||||
y -= 20;
|
||||
}
|
||||
|
||||
width = height = 12;
|
||||
centerOffsets(true);
|
||||
x += 2;
|
||||
y += 2;
|
||||
lookahead.makeGraphic(1, 1, 0x00000000);
|
||||
lookahead.x = x + pp_off.x;
|
||||
lookahead.y = y + Registry.HEADER_HEIGHT + pp_off.y;
|
||||
parent.bg_sprites.add(lookahead);
|
||||
|
||||
hurt_box.makeGraphic(8, 8, 0xff00000);
|
||||
|
||||
add_sfx("move", Registry.sound_data.rat_move);
|
||||
}
|
||||
|
||||
|
||||
/* Rotate, scale the sprite, change the velocity, and set the right anim */
|
||||
private function switch_dir(a:FlxTile, b:Object):void {
|
||||
if (do_rotations) {
|
||||
angle = (angle + 90) % 360;
|
||||
}
|
||||
play_sfx("move");
|
||||
scale.x = 1;
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
play("l");
|
||||
|
||||
scale.x = -1;
|
||||
facing = LEFT;
|
||||
pp_off.x = 0;
|
||||
pp_off.y = 8;
|
||||
velocity.x = -move_vel;
|
||||
velocity.y = 0;
|
||||
break;
|
||||
case LEFT:
|
||||
play("up");
|
||||
facing = UP;
|
||||
pp_off.x = 8;
|
||||
pp_off.y = -2;
|
||||
velocity.x = 0;
|
||||
velocity.y = -move_vel;
|
||||
break;
|
||||
case UP:
|
||||
play("r");
|
||||
facing = RIGHT;
|
||||
pp_off.x = 12;
|
||||
pp_off.y = 8;
|
||||
velocity.x = move_vel;
|
||||
velocity.y = 0;
|
||||
break;
|
||||
case RIGHT:
|
||||
play("down");
|
||||
facing = DOWN;
|
||||
pp_off.x = 8;
|
||||
pp_off.y = 15;
|
||||
velocity.x = 0;
|
||||
velocity.y = move_vel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
if (!exists) return;
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
|
||||
/* Check running into switch pillars */
|
||||
for each (var sp:Switch_Pillar in Registry.subgroup_switch_pillars) {
|
||||
if (sp == null) continue;
|
||||
if (sp.frame == sp.up_frame && sp.overlaps(lookahead)) {
|
||||
switch_dir(null, null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for each (var dust:Dust in Registry.subgroup_dust) {
|
||||
if (dust == null) continue;
|
||||
|
||||
if (dust.frame != Dust.EMPTY_FRAME && dust.overlaps(lookahead)) {
|
||||
switch_dir(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
for each (var dash_trap:Dash_Trap in Registry.subgroup_dash_traps) {
|
||||
if (dash_trap == null) continue;
|
||||
if (dash_trap.overlaps(this)) {
|
||||
state = s_dying;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for touching a solid tile to turn right */
|
||||
var t:FlxTilemap = parent.curMapBuf;
|
||||
var _x:int = (lookahead.x % 160) / 16; //FCK IT
|
||||
var _y:int = ((lookahead.y - 20) % 160) / 16;
|
||||
var tile_idx:int = t.getTileByIndex(_y * 10 + _x);
|
||||
var tile:FlxTile = t._tileObjects[tile_idx];
|
||||
if (tile.callback != null || tile.allowCollisions != NONE) {
|
||||
switch_dir(null, null);
|
||||
}
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
lookahead.x = x + pp_off.x;
|
||||
lookahead.y = y + pp_off.y;
|
||||
if (state == s_normal) {
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
state = s_dying;
|
||||
}
|
||||
} else if (state == s_dying) {
|
||||
//play("die");
|
||||
//alpha -= 0.025;
|
||||
alpha = 0;
|
||||
if (alpha == 0) {
|
||||
state = s_dead;
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
EventScripts.drop_small_health(x, y, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (state == s_dead) {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
hurt_box.x = x + 4;
|
||||
hurt_box.y = y + 4;
|
||||
if (!player.invincible && player.overlaps(hurt_box) && player.state == player.S_GROUND) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Gate;
|
||||
import entity.gadget.Switch_Pillar;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Silverfish extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/apartment/silverfish.png")] public static var silverfish_sprite:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_normal:int = 0;
|
||||
private var s_seen:int = 1;
|
||||
private var s_turning:int = 2;
|
||||
private var s_dying:int = 3;
|
||||
private var s_gas:int = 4;
|
||||
|
||||
private var t_turn:Number = 0;
|
||||
private var tm_turn:Number = 0.8;
|
||||
|
||||
private var vel:int = 50;
|
||||
private var death_timer:Number = 0.7;
|
||||
private var seen_distance:Number = 30; //
|
||||
|
||||
private var init_latency:Number = 1.0;
|
||||
|
||||
public var cid:int = CLASS_ID.SILVERFISH;
|
||||
|
||||
public function Silverfish(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Add silverifsh adnimations*/
|
||||
loadGraphic(silverfish_sprite, true, false, 16, 16);
|
||||
addAnimation("move_l", [6, 7], 7, true);
|
||||
addAnimation("move_d", [4, 5], 7, true);
|
||||
addAnimation("move_r", [6, 7], 7, true); // DEFAULT: RIGHT
|
||||
addAnimation("move_u", [8, 9], 7, true);
|
||||
addAnimation("idle_d", [4], 12, true);
|
||||
addAnimation("idle_u", [8], 12, true);
|
||||
addAnimation("idle_r", [6], 12, true); // DEFAULT: RIGHT
|
||||
addAnimation("idle_l", [6], 12, true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//addAnimation("die", [4, 5], 30, true);
|
||||
|
||||
// LDRU
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0:
|
||||
play("idle_l");
|
||||
scale.x = -1;
|
||||
facing = LEFT; break;
|
||||
case 1:
|
||||
play("idle_d");
|
||||
facing = DOWN; break;
|
||||
case 2:
|
||||
play("idle_r");
|
||||
facing = RIGHT; break;
|
||||
case 3:
|
||||
play("idle_u");
|
||||
facing = UP; break;
|
||||
}
|
||||
|
||||
add_sfx("move", Registry.sound_data.sf_move);
|
||||
}
|
||||
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
|
||||
if (FlxG.collide(this, parent.curMapBuf) && state == s_seen) {
|
||||
state = s_turning;
|
||||
}
|
||||
for each (var gate:Gate in Registry.subgroup_gates) {
|
||||
if (gate == null) continue;
|
||||
if (FlxG.collide(gate, this) && state == s_seen) {
|
||||
state = s_turning;
|
||||
}
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (y < Registry.CURRENT_GRID_Y * 160 - 16) {
|
||||
exists = false;
|
||||
|
||||
}
|
||||
if (init_latency > 0) {
|
||||
init_latency -= FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
// get hurt
|
||||
if (player.broom.visible && player.broom.overlaps(this) && state != s_dying) {
|
||||
state = s_dying;
|
||||
}
|
||||
|
||||
//hurt player
|
||||
if (player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
//get gased maybe
|
||||
if (state != s_gas) {
|
||||
for each (var gas:FlxSprite in Registry.subgroup_gas) {
|
||||
if (gas == null || !gas.visible) continue;
|
||||
if (gas.alpha > 0.3 && gas.overlaps(this)) {
|
||||
state = s_gas;
|
||||
play_sfx("move");
|
||||
drag.x = drag.y = 10;
|
||||
var p:Point = new Point(player.x, player.y);
|
||||
var _p:Point = new Point(x, y);
|
||||
EventScripts.scale_vector(_p, p, velocity, 70);
|
||||
EventScripts.face_and_play(this, player, "move");
|
||||
if (facing != LEFT) {
|
||||
scale.x = 1;
|
||||
} else {
|
||||
scale.x = -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (state == s_normal) {
|
||||
if (sees(player) || (EventScripts.distance(player,this) < seen_distance)) {
|
||||
//play sfx, then move
|
||||
flip_and_move();
|
||||
play_sfx("move");
|
||||
state = s_seen;
|
||||
}
|
||||
} else if (state == s_seen) {
|
||||
if (touching != NONE) {
|
||||
state = s_turning;
|
||||
}
|
||||
} else if (state == s_turning) {
|
||||
velocity.x = velocity.y = 0;
|
||||
t_turn += FlxG.elapsed;
|
||||
|
||||
|
||||
if (facing & LEFT) {
|
||||
facing = LEFT;
|
||||
play("idle_l");
|
||||
} else if (facing & UP) {
|
||||
facing = UP;
|
||||
play("idle_u");
|
||||
} else if (facing & RIGHT) {
|
||||
facing = RIGHT;
|
||||
play("idle_r");
|
||||
} else if (facing & DOWN) {
|
||||
facing = DOWN;
|
||||
play("idle_d");
|
||||
}
|
||||
|
||||
|
||||
if (t_turn > tm_turn) {
|
||||
t_turn = 0;
|
||||
scale.x = 1;
|
||||
if (facing & LEFT) {
|
||||
facing = UP;
|
||||
} else if (facing & UP) {
|
||||
facing = RIGHT;
|
||||
} else if (facing & RIGHT) {
|
||||
facing = DOWN;
|
||||
} else if (facing & DOWN) {
|
||||
facing = LEFT;
|
||||
scale.x = -1;
|
||||
}
|
||||
} else if (sees(player) || (EventScripts.distance(player, this) < seen_distance) ) {
|
||||
facing = EventScripts.get_entity_to_entity_dir(x,y,player.x,player.y);
|
||||
t_turn = 0;
|
||||
state = s_seen;
|
||||
play_sfx("move");
|
||||
flip_and_move();
|
||||
}
|
||||
} else if (state == s_dying) {
|
||||
//play("die");
|
||||
//death_timer -= FlxG.elapsed;
|
||||
death_timer = -0.1;
|
||||
if (death_timer < 0) {
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.drop_small_health(x, y, 0.5);
|
||||
exists = false;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
}
|
||||
} else if (state == s_gas) {
|
||||
if (velocity.x < 2) {
|
||||
state = s_dying;
|
||||
}
|
||||
}
|
||||
|
||||
// stop at switch pillars
|
||||
for each (var sp:Switch_Pillar in Registry.subgroup_switch_pillars) {
|
||||
if (sp == null) continue;
|
||||
|
||||
if (sp.frame == sp.up_frame && sp.overlaps(this)) {
|
||||
var yes:Boolean = false;
|
||||
if (velocity.x > 0 && sp.x > x) {
|
||||
yes = true;
|
||||
} else if (velocity.x < 0 && sp.x < x) {
|
||||
yes = true;
|
||||
} else if (velocity.y > 0 && sp.y > y) {
|
||||
yes = true;
|
||||
} else if (velocity.y < 0 && sp.y < y) {
|
||||
yes = true;
|
||||
}
|
||||
if (yes) {
|
||||
velocity.x = velocity.y = 0;
|
||||
state = s_turning;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function flip_and_move():void {
|
||||
scale.x = 1;
|
||||
if (facing & LEFT) {
|
||||
velocity.x = vel;
|
||||
facing = RIGHT;
|
||||
play("move_r");
|
||||
|
||||
} else if (facing & RIGHT) {
|
||||
scale.x = -1;
|
||||
facing = LEFT;
|
||||
velocity.x = -vel;
|
||||
play("move_l");
|
||||
} else if (facing & UP) {
|
||||
facing = DOWN;
|
||||
velocity.y = vel;
|
||||
play("move_d");
|
||||
} else if (facing & DOWN) {
|
||||
facing = UP;
|
||||
velocity.y = -vel;
|
||||
play("move_u");
|
||||
}
|
||||
}
|
||||
//finish this
|
||||
private function sees(o:FlxObject):Boolean {
|
||||
if (facing == LEFT) {
|
||||
if (o.x < x && (o.y + o.height > y) && (o.y < y + height)) return true;
|
||||
} else if (facing == RIGHT) {
|
||||
if (o.x > x && (o.y + o.height > y) && (o.y < y + height)) return true;
|
||||
} else if (facing == UP) {
|
||||
if ((o.y + o.height < y) && (o.x < x + width) && (o.x + o.width > x)) return true;
|
||||
} else {
|
||||
if ((o.y > y + height) && (o.x < x + width) && (o.x + o.width > x)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,655 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
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;
|
||||
|
||||
public class Splitboss extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
private var added_to_parent:Boolean = false;
|
||||
private var white_overlay:FlxSprite;
|
||||
|
||||
|
||||
private var DETHBALLZ:FlxGroup = new FlxGroup(12);
|
||||
private var copies:FlxGroup = new FlxGroup(2);
|
||||
private var copy_1:FlxSprite;
|
||||
private var copy_2:FlxSprite;
|
||||
|
||||
private var is_damaged:Boolean = false;
|
||||
private var t_damaged:Number = 0;
|
||||
private var tm_damaged:Number = 0.8;
|
||||
|
||||
|
||||
public var state:int = 0;
|
||||
private var s_dead:int = -2;
|
||||
private var s_dying:int = -1;
|
||||
private var s_intro:int = 0;
|
||||
|
||||
private var s_dethballz:int = 1;
|
||||
private var s_dethballz_times_shot:int = 0;
|
||||
private var h_dethballz_counts:Array = new Array(2, 1, 4);
|
||||
private var h_dethballz_shots:Array = new Array(4, 10, 7);
|
||||
private var h_dethballz_timeouts:Array = new Array(0.7, 0.2, 0.8);
|
||||
private var t_dethballz:Number = 0;
|
||||
private var dethball_queue:Array = new Array();
|
||||
|
||||
private var s_h_dash:int = 2;
|
||||
private var Y_OFF_R_DASH:int = 6;
|
||||
private var h_dash_vel:Array = new Array(80, 100, 120);
|
||||
private var h_dash_ball_vel:Array = new Array(80, 100, 120);
|
||||
private var h_dashes_done:int = 0;
|
||||
private var nr_dashes:Array = new Array(2, 3, 4);
|
||||
private var h_dash_ball_pos:Array = new Array(1, 4);
|
||||
private var t_h_dash:Number = 0;
|
||||
private var tm_h_dash:Number = 0.5;
|
||||
private var nr_dropped:int = 0;
|
||||
private var nr_to_drop:Array = new Array(2, 3, 4);
|
||||
private var next_drop:Number = 0;
|
||||
|
||||
private var s_split:int = 3;
|
||||
private var t_split:Number = 0;
|
||||
private var split_vels:Array = new Array(40, 50, 60);
|
||||
|
||||
|
||||
public var phase:int = 0;
|
||||
|
||||
|
||||
private var MAX_HEALTH:int = 12;
|
||||
private var PHASE_2_HEALTH:int = 8;
|
||||
private var PHASE_3_HEALTH:int = 4;
|
||||
private var AREA_TILE_W:int = 6;
|
||||
private var AREA_TILE_H:int = 5;
|
||||
|
||||
|
||||
private var tl:Point = new Point(); //top left of movable area (2,2) in this case, relative to rooom
|
||||
public var ctr:int = 0;
|
||||
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/apartment/splitboss.png")] public static var splitboss_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/apartment/splitboss_fireball.png")] public static var splitboss_fireball_sprite:Class;
|
||||
|
||||
public function Splitboss(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
solid = false;
|
||||
solid = false;
|
||||
immovable = true;
|
||||
|
||||
tl.x = 160 * Registry.CURRENT_GRID_X + 32;
|
||||
tl.y = 160 * Registry.CURRENT_GRID_Y + Registry.HEADER_HEIGHT + 48;
|
||||
|
||||
health = MAX_HEALTH + 1;
|
||||
|
||||
/* Make bullets (shuriken)*/
|
||||
for (var i:int = 0; i < DETHBALLZ.maxSize; i++) {
|
||||
var DETHBALL:FlxSprite = new FlxSprite;
|
||||
DETHBALL.loadGraphic(splitboss_fireball_sprite, true, false, 16, 16);
|
||||
DETHBALL.height = DETHBALL.width = 6;
|
||||
DETHBALL.centerOffsets(true);
|
||||
DETHBALLZ.add(DETHBALL);
|
||||
DETHBALL.addAnimation("pulsate", [0, 1, 2, 3], 12); // IDLE
|
||||
DETHBALL.addAnimation("shoot", [0, 1, 2, 3], 12,true); // MOVING
|
||||
DETHBALL.addAnimation("fizzle", [4, 5, 6, 7], 12, false); //DISAPEPARING
|
||||
}
|
||||
DETHBALLZ.setAll("exists", false);
|
||||
|
||||
/* Make sprite and copies */
|
||||
loadGraphic(splitboss_sprite, true, false, 24, 32);
|
||||
width -= 8;
|
||||
height -= 12;
|
||||
centerOffsets(true);
|
||||
|
||||
addAnimation("float", [0, 1, 2, 1], 5); //facing downwards, idle
|
||||
addAnimation("idle_r", [4, 5, 6, 5], 5);
|
||||
addAnimation("dash_r", [10, 11], 8);
|
||||
addAnimation("dash_d", [8, 9], 8);
|
||||
addAnimation("die", [0, 3], 14);
|
||||
play("float");
|
||||
|
||||
for (i = 0; i < copies.maxSize; i++) {
|
||||
var copy:FlxSprite = new FlxSprite(0, 0);
|
||||
copy.loadGraphic(splitboss_sprite, true, false, 24, 32);
|
||||
copy.width -= 8;
|
||||
copy.height -= 12;
|
||||
copy.centerOffsets(true);
|
||||
|
||||
copy.addAnimation("float", [0, 1, 2, 1], 5);
|
||||
//copy.addAnimation("hurt", [0, 3], 14);
|
||||
copy.addAnimation("idle_r", [4, 5, 6, 5], 5);
|
||||
copy.addAnimation("dash_r", [10, 11], 8);
|
||||
copy.addAnimation("dash_d", [8, 9], 8);
|
||||
copy.play("float");
|
||||
copy.alpha = 0.5;
|
||||
copy.visible = false;
|
||||
copy.solid = false;
|
||||
copies.add(copy);
|
||||
}
|
||||
copy_1 = copies.members[0];
|
||||
|
||||
copy_2 = copies.members[1];
|
||||
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
} else {
|
||||
state = s_intro;
|
||||
}
|
||||
|
||||
player.grid_entrance_x = tl.x + 42;
|
||||
player.grid_entrance_y = tl.y + 40;
|
||||
|
||||
parent.bg_sprites.add(DETHBALLZ);
|
||||
|
||||
FlxG.watch(this,"state", "state");
|
||||
FlxG.watch(this, "phase", "phase");
|
||||
FlxG.watch(this, "ctr", "ctr");
|
||||
|
||||
add_sfx("split", Registry.sound_data.sb_split);
|
||||
add_sfx("hurt", Registry.sound_data.sb_hurt);
|
||||
add_sfx("dash", Registry.sound_data.sb_dash);
|
||||
add_sfx("shoot", Registry.sound_data.sb_ball_appear);
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (!added_to_parent) {
|
||||
added_to_parent = true;
|
||||
parent.sortables.add(copies);
|
||||
white_overlay = new FlxSprite(0, 0);
|
||||
white_overlay.scrollFactor = new FlxPoint(0, 0);
|
||||
white_overlay.makeGraphic(160, 160 + Registry.HEADER_HEIGHT, 0xffffffff);
|
||||
white_overlay.alpha = 0;
|
||||
white_overlay.x = white_overlay.y = 0;
|
||||
parent.fg_sprites.add(white_overlay);
|
||||
}
|
||||
|
||||
if (!player.invincible && player.overlaps(this)) {
|
||||
if (state != s_dead && state != s_dying && state != s_intro && !(state == s_split && ctr == 0)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle health and phase chanages */
|
||||
if (!is_damaged && player.broom.visible && player.broom.overlaps(this)) {
|
||||
if ((state == s_intro || state == s_split) && ctr < 5 ) {
|
||||
|
||||
} else {
|
||||
health--;
|
||||
play_sfx("hurt");
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
is_damaged = true;
|
||||
t_damaged = 0;
|
||||
flicker(tm_damaged);
|
||||
if (health <= PHASE_2_HEALTH) {
|
||||
phase = 1;
|
||||
}
|
||||
if (health <= PHASE_3_HEALTH) {
|
||||
phase = 2;
|
||||
}
|
||||
if (state != s_dying && state != s_dead) {
|
||||
if (health <= 0) {
|
||||
state = s_dying;
|
||||
ctr = 0;
|
||||
t_split = 5.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
t_damaged += FlxG.elapsed;
|
||||
if (t_damaged > tm_damaged) {
|
||||
is_damaged = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine behavior */
|
||||
if (state == s_dethballz) {
|
||||
do_h_dethballz();
|
||||
} else if (state == s_h_dash) {
|
||||
do_h_dash();
|
||||
} else if (state == s_split) {
|
||||
do_split();
|
||||
} else if (state == s_intro) {
|
||||
do_intro();
|
||||
} else if (state == s_dying) {
|
||||
|
||||
if (ctr == 0) {
|
||||
DH.start_dialogue(DH.name_splitboss, DH.scene_splitboss_after_fight, "APARTMENT");
|
||||
ctr++;
|
||||
|
||||
} else if (ctr == 1) {
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
ctr++;
|
||||
Registry.sound_data.big_door_locked.play();
|
||||
}
|
||||
} else {
|
||||
Registry.volume_scale -= 0.005;
|
||||
flicker(0.1);
|
||||
play("die");
|
||||
var tm_split:Number = 5;
|
||||
t_split -= FlxG.elapsed;
|
||||
x = tl.x + 40;
|
||||
y = tl.y + 40;
|
||||
var r:Number = -65 * (1 - (t_split /tm_split));
|
||||
x += (r + Math.random() * -2 * r);
|
||||
y += (r + Math.random() * -2 * r);
|
||||
|
||||
white_overlay.alpha = (1 - (t_split / tm_split));
|
||||
for each (var dethball:FlxSprite in DETHBALLZ.members) {
|
||||
if (dethball == null) continue;
|
||||
dethball.alpha -= 0.05;
|
||||
}
|
||||
copy_1.alpha -= 0.1;
|
||||
copy_2.alpha -= 0.1;
|
||||
|
||||
if (t_split < 0) {
|
||||
state = s_dead;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.volume_scale = 1;
|
||||
|
||||
//
|
||||
Registry.sound_data.start_song_from_title("APARTMENT");
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
Registry.GE_States[Registry.GE_Apartment_Boss_Dead_Idx] = true;
|
||||
visible = false;
|
||||
xml.@alive = "false";
|
||||
|
||||
}
|
||||
}
|
||||
} else if (state == s_dead) {
|
||||
white_overlay.alpha -= 0.05;
|
||||
if (white_overlay.alpha == 0) {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function do_h_dash():void {
|
||||
|
||||
var DETHBALL:FlxSprite;
|
||||
if (ctr == 0) {
|
||||
play("idle_r");
|
||||
offset.y = Y_OFF_R_DASH;
|
||||
alpha -= 0.1;
|
||||
if (alpha == 0) {
|
||||
x = tl.x - 32;
|
||||
y = player.y;
|
||||
velocity.x = 0;
|
||||
ctr = 1;
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
alpha += 0.15;
|
||||
y = player.y;
|
||||
if (alpha == 1) {
|
||||
t_h_dash += FlxG.elapsed; // y-track the player as a warning
|
||||
if (t_h_dash > tm_h_dash) {
|
||||
t_h_dash = 0;
|
||||
ctr = 2;
|
||||
play("dash_r");
|
||||
play_sfx("dash");
|
||||
velocity.x = h_dash_vel[phase];
|
||||
next_drop = tl.x + 16 * Math.random();
|
||||
}
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
|
||||
offset.y = player.offset.y - player.DEFAULT_Y_OFFSET + Y_OFF_R_DASH;
|
||||
if (nr_dropped < nr_to_drop[phase]) { //drop a ball when needed.
|
||||
if (x > next_drop && (x > tl.x && x < tl.x + 96)) {
|
||||
DETHBALL = DETHBALLZ.getFirstAvailable() as FlxSprite;
|
||||
if (DETHBALL != null) { //set next drop point.
|
||||
next_drop = x + 16 + 16 * Math.random();
|
||||
DETHBALL.exists = true;
|
||||
play_sfx("shoot");
|
||||
DETHBALL.play("pulsate");
|
||||
DETHBALL.x = x;
|
||||
DETHBALL.y = y;
|
||||
nr_dropped ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x > tl.x + 16*8) { //when far enough, dash aagain, or state change
|
||||
alpha -= 0.1;
|
||||
if (alpha == 0) {
|
||||
nr_dropped = 0;
|
||||
h_dashes_done++;
|
||||
if (h_dashes_done >= nr_dashes[phase]) {
|
||||
ctr = 3;
|
||||
h_dashes_done = 0;
|
||||
for each (DETHBALL in DETHBALLZ.members) {
|
||||
if (DETHBALL.exists) {
|
||||
DETHBALL.play("shoot");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for each (DETHBALL in DETHBALLZ.members) {
|
||||
DETHBALL.flicker(0.05);
|
||||
}
|
||||
|
||||
} else if (ctr == 3) {
|
||||
t_h_dash += FlxG.elapsed;
|
||||
if (t_h_dash < tm_h_dash) return; //wait a bit as a warning for the balls
|
||||
|
||||
var pt:Point = new Point;
|
||||
var p_pt:Point = new Point;
|
||||
for each (DETHBALL in DETHBALLZ.members) { //set destinations for the balls
|
||||
if (DETHBALL != null && DETHBALL.exists) {
|
||||
pt.x = DETHBALL.x;
|
||||
pt.y = DETHBALL.y;
|
||||
p_pt.x = player.x - 10 + 20 * Math.random();
|
||||
p_pt.y = player.y - 10 + 20 * Math.random();
|
||||
EventScripts.scale_vector(pt, p_pt, DETHBALL.velocity, h_dash_ball_vel[phase]);
|
||||
}
|
||||
|
||||
}
|
||||
play_sfx("split");
|
||||
ctr = 4;
|
||||
} else if (ctr == 4) {
|
||||
for each (DETHBALL in DETHBALLZ.members) { //balls acan now daamage player on the ground
|
||||
if (DETHBALL != null && DETHBALL.exists) {
|
||||
if (!player.invincible && player.state == player.S_GROUND && player.overlaps(DETHBALL)) {
|
||||
player.touchDamage(1);
|
||||
DETHBALL.exists = false;
|
||||
}
|
||||
DETHBALL.alpha -= 0.005;
|
||||
if (DETHBALL.alpha == 0) {
|
||||
for each (DETHBALL in DETHBALLZ.members) {
|
||||
DETHBALL.exists = false;
|
||||
DETHBALL.alpha = 1;
|
||||
DETHBALL.velocity.x = DETHBALL.velocity.y = 0;
|
||||
}
|
||||
alpha = 1;
|
||||
ctr = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ctr == 5) {
|
||||
velocity.x = 0;
|
||||
centerOffsets(true);
|
||||
var r:Number = Math.random();
|
||||
if (r > 0.6) {
|
||||
state = s_dethballz;
|
||||
} else if (r > 0.3) {
|
||||
state = s_split;
|
||||
} else {
|
||||
state = s_h_dash;
|
||||
}
|
||||
ctr = 0;
|
||||
}
|
||||
}
|
||||
private function do_h_dethballz():void {
|
||||
var iter:int = 0;
|
||||
var len:int = 0;
|
||||
var DETHBALL:FlxSprite;
|
||||
|
||||
/***********/
|
||||
/*H_DETHBALLZ*/
|
||||
/***********/
|
||||
if (ctr == 0) {
|
||||
play("float");
|
||||
velocity.x = 0;
|
||||
x = tl.x + 40;
|
||||
y = tl.y - 32;
|
||||
/* Set number of balls to appear, and their positions.*/
|
||||
var tx:int = int(6 * Math.random());
|
||||
play_sfx("shoot");
|
||||
for (iter = 0; iter < h_dethballz_counts[phase]; iter++) {
|
||||
DETHBALL = DETHBALLZ.getFirstAvailable() as FlxSprite;
|
||||
if (DETHBALL == null) break;
|
||||
DETHBALL.exists = true;
|
||||
DETHBALL.play("pulsate");
|
||||
DETHBALL.y = tl.y - DETHBALL.height;
|
||||
DETHBALL.x = tl.x + ((16 - DETHBALL.width) / 2) + ((tx + 1 * iter) % 6) * 16;
|
||||
dethball_queue.push(DETHBALL);
|
||||
}
|
||||
ctr = 1;
|
||||
/* After a charge period, move the balls. */
|
||||
} else if (ctr == 1) {
|
||||
t_dethballz += FlxG.elapsed;
|
||||
if (t_dethballz > h_dethballz_timeouts[phase]) {
|
||||
//sfx pew pew
|
||||
len = dethball_queue.length;
|
||||
for (iter = 0; iter < len; iter++) {
|
||||
DETHBALL = dethball_queue.pop();
|
||||
DETHBALL.velocity.y = 40;
|
||||
DETHBALL.play("shoot", true);
|
||||
}
|
||||
/* Loop back to ball-spawn unless we've shot enough times. */
|
||||
ctr = 0;
|
||||
t_dethballz = 0;
|
||||
s_dethballz_times_shot++;
|
||||
if (s_dethballz_times_shot >= h_dethballz_shots[phase]) {
|
||||
ctr = 2;
|
||||
s_dethballz_times_shot = 0;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
if (DETHBALLZ.countExisting() == 0) {
|
||||
ctr = 0;
|
||||
var r:Number = Math.random();
|
||||
if (r > 0.63) {
|
||||
state = s_h_dash;
|
||||
} else if (r > 0.38) {
|
||||
state = s_dethballz;
|
||||
} else {
|
||||
state = s_split;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Boilerplate overlap with player code. */
|
||||
if (!player.invincible && player.state != player.S_AIR) {
|
||||
for each (DETHBALL in DETHBALLZ.members) {
|
||||
if (DETHBALL != null && DETHBALL.exists) {
|
||||
if (DETHBALL._curAnim.name == "fizzle" && (DETHBALL._curFrame == DETHBALL._curAnim.frames.length - 1)) {
|
||||
DETHBALL.exists = false;
|
||||
DETHBALL.velocity.y = 0;
|
||||
}
|
||||
if (!player.invincible && player.overlaps(DETHBALL) ) {
|
||||
player.touchDamage(1);
|
||||
//sfx fizzle
|
||||
DETHBALL.play("fizzle");
|
||||
}
|
||||
if (DETHBALL.y > tl.y + AREA_TILE_H * 16) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.fireball_group);
|
||||
DETHBALL.play("fizzle");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function do_split():void {
|
||||
if (ctr == 0) { // move to top of playing area and flicker
|
||||
centerOffsets(true);
|
||||
play("float");
|
||||
x = tl.x + 40;
|
||||
y = tl.y - 16;
|
||||
ctr++;
|
||||
flicker(1.5);
|
||||
visible = true;
|
||||
|
||||
} else if (ctr == 1) { //when hit, split into three
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
play_sfx("split");
|
||||
alpha = copy_1.alpha = copy_2.alpha = 1;
|
||||
copy_1.x = copy_2.x = x;
|
||||
copy_1.y = copy_2.y = y;
|
||||
velocity.y = -40;
|
||||
copy_1.visible = copy_2.visible = true;
|
||||
copy_1.velocity.x = -40; // copy 1 faces left
|
||||
copy_2.velocity.x = 40; // copy 2 faces right
|
||||
copy_1.play("idle_r"); copy_1.scale.x = -1;
|
||||
copy_2.play("idle_r");
|
||||
copy_1.offset.y = copy_2.offset.y = Y_OFF_R_DASH;
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 2) { //fade out while moving
|
||||
alpha -= 0.02;
|
||||
copy_1.alpha = copy_2.alpha = alpha;
|
||||
if (alpha == 0) {
|
||||
copy_1.velocity.x = copy_2.velocity.x = velocity.x = 0;
|
||||
copy_1.velocity.y = copy_2.velocity.y = velocity.y = 0;
|
||||
ctr++;
|
||||
alpha = copy_1.alpha = copy_2.alpha = 0.7;
|
||||
t_split = 1.0;
|
||||
}
|
||||
} else if (ctr == 3) { //pin to the player and successively dash
|
||||
x = player.x; y = player.y - 24;
|
||||
t_split -= FlxG.elapsed;
|
||||
if (t_split < 0) { //flicker for a bit before dashing
|
||||
copy_1.flicker(0.2);
|
||||
copy_2.flicker(0.2);
|
||||
if (t_split < -0.7) {
|
||||
ctr++;
|
||||
copy_1.play("dash_r");
|
||||
copy_2.play("dash_r");
|
||||
}
|
||||
} else {
|
||||
copy_1.x = player.x + 25; copy_1.y = player.y;
|
||||
copy_2.x = player.x - 25; copy_2.y = player.y;
|
||||
}
|
||||
} else if (ctr == 4) { //dash the copies horizontally
|
||||
copy_1.velocity.x = -split_vels[phase];
|
||||
copy_2.velocity.x = split_vels[phase];
|
||||
play_sfx("dash");
|
||||
if (player.overlaps(copy_1) || player.overlaps(copy_2)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
x = player.x; y = player.y - 24;
|
||||
copy_1.alpha -= 0.02;
|
||||
copy_2.alpha = copy_1.alpha;
|
||||
if (copy_1.alpha == 0) { // give a warning for the boss
|
||||
ctr++;
|
||||
copy_1.velocity.x = copy_2.velocity.x = 0;
|
||||
flicker(1);
|
||||
}
|
||||
|
||||
} else if (ctr == 5) { // when warning done, dash
|
||||
if (!flickering) {
|
||||
play_sfx("dash");
|
||||
play("dash_d");
|
||||
velocity.y = split_vels[phase];
|
||||
alpha -= 0.02;
|
||||
if (alpha == 0) {
|
||||
alpha = 1;
|
||||
ctr++;
|
||||
velocity.y = 0;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 6) { //determine next attack
|
||||
play("float");
|
||||
var r:Number = Math.random();
|
||||
ctr = 0;
|
||||
if (phase <= 1) {
|
||||
if (r <= 0.3) {
|
||||
state = s_h_dash;
|
||||
} else if (r <= 0.7) {
|
||||
state = s_dethballz;
|
||||
} else {
|
||||
state = s_split;
|
||||
}
|
||||
} else {
|
||||
if (r <= 0.5) {
|
||||
state = s_h_dash;
|
||||
} else if (r <= 0.75) {
|
||||
state = s_dethballz;
|
||||
} else {
|
||||
state = s_split;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
private function do_intro():void {
|
||||
var sub_ctr:int = 0;
|
||||
if (ctr == 0) {
|
||||
x = tl.x + 48 - (width / 2);
|
||||
y = tl.y + 32;
|
||||
Registry.volume_scale -= 0.005;
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
ctr = 1;
|
||||
DH.start_dialogue(DH.name_splitboss, DH.scene_splitboss_before_fight, "APARTMENT");
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
play_sfx("split");
|
||||
Registry.volume_scale = 1;
|
||||
Registry.sound_data.start_song_from_title("BOSS");
|
||||
visible = false;
|
||||
copy_1.visible = true;
|
||||
copy_2.visible = true;
|
||||
copy_1.x = copy_2.x = x;
|
||||
copy_1.y = copy_2.y = y;
|
||||
copy_1.velocity.x = -50;
|
||||
copy_2.velocity.x = 50;
|
||||
ctr = 2;
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
copy_1.alpha -= 0.01;
|
||||
copy_2.alpha -= 0.01;
|
||||
if (copy_1.alpha == 0 && copy_2.alpha == 0) {
|
||||
ctr = 3;
|
||||
alpha = 0;
|
||||
copy_1.y = y = copy_2.y = tl.y - 32;
|
||||
copy_1.x = x - 40;
|
||||
copy_2.x = x + 40;
|
||||
copy_1.velocity.x = copy_2.velocity.x = 0;
|
||||
visible = true;
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
alpha += 0.01;
|
||||
copy_1.alpha = copy_2.alpha = alpha;
|
||||
if (alpha == 1) {
|
||||
ctr = 4;
|
||||
}
|
||||
} else if (ctr == 4) {
|
||||
copy_1.flicker(0.5); copy_2.flicker(0.5); flicker(0.5);
|
||||
if (EventScripts.send_property_to(copy_1, "x", x, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(copy_2, "x", x, 0.5)) sub_ctr++;
|
||||
if (sub_ctr == 2) {
|
||||
ctr = 5;
|
||||
copy_1.visible = copy_2.visible = false;
|
||||
}
|
||||
} else {
|
||||
ctr = 0;
|
||||
visible = true;
|
||||
state = s_dethballz;
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
DH.dont_need_recently_finished();
|
||||
parent.sortables.remove(copies, true);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
package entity.enemy.apartment
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Teleguy extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
|
||||
|
||||
public var state:int = 0;
|
||||
private var s_idle:int = 0
|
||||
private var s_teleporting:int = 1;
|
||||
private var ctr:int = 0;
|
||||
private var t_ctr:Number = 0;
|
||||
|
||||
|
||||
private var s_attacking:int = 2;
|
||||
private var atk_pt:Point = new Point;
|
||||
private var attack_speed:Number = 0.9;
|
||||
|
||||
private var s_dying:int = 3;
|
||||
private var s_dead:int = 4;
|
||||
|
||||
public var cid:int = CLASS_ID.TELEGUY;
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/apartment/teleport_guy.png")] public var teleguy_sprite:Class;
|
||||
|
||||
public function Teleguy(_x:XML, _p:Player, _pa:*)
|
||||
{
|
||||
|
||||
xml = _x;
|
||||
player = _p;
|
||||
parent = _pa;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
loadGraphic(teleguy_sprite, true, false, 16, 24);
|
||||
offset.y = 6;
|
||||
height = 16;
|
||||
|
||||
/* Add animations */
|
||||
addAnimation("idle_d", [0,1], 3);
|
||||
addAnimation("idle_r", [2,3], 3); //DEFAULT: RIGHT
|
||||
addAnimation("idle_u", [4,5], 3);
|
||||
addAnimation("idle_l", [2,3], 3);
|
||||
addAnimation("poof", [6,7,8,9],12,false);
|
||||
addAnimation("unpoof", [8,7,6], 12,false);
|
||||
addAnimation("dying", [0]);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
state = s_dead;
|
||||
alive = false;
|
||||
}
|
||||
health = 1;
|
||||
//FlxG.watch(this, "state", "teleguy state");
|
||||
|
||||
add_sfx("up", Registry.sound_data.teleguy_up);
|
||||
add_sfx("down", Registry.sound_data.teleguy_down);
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (alive && player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
//Cleanup before death logic
|
||||
if (health <= 0 && state != s_dead && state != s_dying ) {
|
||||
t_ctr = 2;
|
||||
play("dying");
|
||||
state = s_dying;
|
||||
xml.@alive = "false";
|
||||
alive = false;
|
||||
}
|
||||
|
||||
// Idle until attacked
|
||||
if (state == s_idle) {
|
||||
scale.x = 1;
|
||||
/* Get the direction to the player and face that way*/
|
||||
switch (EventScripts.get_entity_to_entity_dir(x + 8, y + 16, player.x + 5, player.y + 7)) {
|
||||
case UP:
|
||||
play("idle_u");
|
||||
break;
|
||||
case DOWN:
|
||||
play("idle_d");
|
||||
break;
|
||||
case RIGHT:
|
||||
play("idle_r");
|
||||
break;
|
||||
case LEFT:
|
||||
play("idle_l");
|
||||
scale.x = -1;
|
||||
break;
|
||||
}
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
state = s_teleporting;
|
||||
}
|
||||
|
||||
} else if (state == s_teleporting) {
|
||||
if (ctr == 0) {
|
||||
play_sfx("up");
|
||||
play("poof"); //goesto invisible
|
||||
t_ctr = 0.5;
|
||||
ctr++;
|
||||
alive = false;
|
||||
} else if (ctr == 1) {
|
||||
/* Move behind player, set the point to dash attack to */
|
||||
t_ctr -= FlxG.elapsed;
|
||||
if (t_ctr < 0) {
|
||||
atk_pt.x = x;
|
||||
atk_pt.y = y;
|
||||
teleport();
|
||||
play_sfx("down");
|
||||
play("unpoof"); // ends on teleport thing almost done
|
||||
ctr++;
|
||||
t_ctr = 0.5
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
/* Face the player before dashing */
|
||||
t_ctr -= FlxG.elapsed;
|
||||
if (t_ctr < 0) {
|
||||
alive = true;
|
||||
scale.x = 1;
|
||||
if (facing == LEFT) {
|
||||
play("idle_l");
|
||||
scale.x = -1;
|
||||
}
|
||||
if (facing == RIGHT) play("idle_r");
|
||||
if (facing == DOWN) play("idle_d");
|
||||
if (facing == UP) play("idle_u");
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
ctr = 0;
|
||||
//sfx atack
|
||||
state = s_attacking;
|
||||
t_ctr = 1.5;
|
||||
}
|
||||
} else if (state == s_attacking) {
|
||||
/* Move to the attack pooint, if attacked, then start teleporting again */
|
||||
t_ctr -= FlxG.elapsed;
|
||||
if (t_ctr < 0) {
|
||||
state = s_idle;
|
||||
} else {
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
if (Math.random() < 0.5) {
|
||||
state = s_teleporting;
|
||||
} else {
|
||||
flicker(1);
|
||||
state = s_idle;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
health--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EventScripts.send_property_to(this, "x", atk_pt.x, attack_speed);
|
||||
EventScripts.send_property_to(this, "y", atk_pt.y, attack_speed);
|
||||
} else if (state == s_dying) {
|
||||
//t_ctr -= FlxG.elapsed;
|
||||
//flicker(1);
|
||||
t_ctr = -0.1;
|
||||
if (t_ctr < 0) {
|
||||
state = s_dead;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.drop_small_health(x, y, 0.7);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
}
|
||||
} else if (state == s_dead) {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function teleport():void {
|
||||
|
||||
if (player.facing == LEFT) {
|
||||
x = player.x + 16;
|
||||
y = player.y
|
||||
facing = LEFT;
|
||||
} else if (player.facing == RIGHT) {
|
||||
x = player.x - 16;
|
||||
y = player.y;
|
||||
facing = RIGHT;
|
||||
} else if (player.facing == UP) {
|
||||
x = player.x;
|
||||
y = player.y + 17;
|
||||
facing = UP;
|
||||
} else if (player.facing == DOWN) {
|
||||
x = player.x;
|
||||
y = player.y - 16;
|
||||
facing = DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
package entity.enemy.bedroom
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.SoundData;
|
||||
import entity.enemy.circus.Lion;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import helper.SpriteFactory;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSound;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Annoyer extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
[Embed (source = "../../../res/sprites/enemies/annoyer.png")] public static var S_ANNOYER_SPRITE:Class;
|
||||
public var target:Player;
|
||||
|
||||
private var state:int = -1;
|
||||
|
||||
private var S_WAIT:int = -1;
|
||||
private var S_APPROACH:int = 0;
|
||||
private var S_CIRCLE:int = 1;
|
||||
private var S_ATTACK:int = 2;
|
||||
private var S_DEAD:int = 3;
|
||||
private var S_HIT:int = 4;
|
||||
private var hit_timer:Number = 0.25;
|
||||
|
||||
private var WAIT_TIMER_MAX:Number = 0.25;
|
||||
private var APPROACH_DISTANCE:int = 64;
|
||||
private var CIRCLE_DISTANCE:int = 24;
|
||||
private var wait_timer:Number = 0.25;
|
||||
private var CIRCLE_TIMER_MAX:Number = 3.00;
|
||||
private var circle_timer:Number = 3.00;
|
||||
private var swoop_to_point:Point = new Point(0, 0);
|
||||
|
||||
private var rotate_radius:Number = 20;
|
||||
private var rotate_velocity:Number = 0.14;
|
||||
|
||||
private var just_hit_timer:Number = 0.4;
|
||||
private var just_hit:Boolean = false;
|
||||
public var cid:int = CLASS_ID.ANNOYER;
|
||||
|
||||
public var INCREMENTED_REG:Boolean = false;
|
||||
public var parent:*;
|
||||
|
||||
|
||||
private var frame_type:int = 0;
|
||||
private var T_NORMAL:int = 0;
|
||||
private var T_SUPER:int = 2;
|
||||
|
||||
private var fireballs:FlxGroup = new FlxGroup(4);
|
||||
private var t_fireball:Number = 0;
|
||||
private var tm_fireball:Number = 2.3;
|
||||
private var vel_fireball:int = 30;
|
||||
|
||||
|
||||
public function Annoyer(x:int,y:int,_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
super(x, y);
|
||||
xml = _xml;
|
||||
target = _player;
|
||||
loadGraphic(S_ANNOYER_SPRITE, true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
addAnimation("flap", [6, 7], 4, true);
|
||||
} else if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
addAnimation("flap", [8, 9], 8, true);
|
||||
} else if (parseInt(xml.@frame) == T_SUPER) {
|
||||
addAnimation("flap", [12,13,14,15,16,17], 8, true);
|
||||
} else {
|
||||
addAnimation("flap", [0, 1, 2, 3,4,5], 8, true);
|
||||
}
|
||||
play("flap");
|
||||
height = 7;
|
||||
width = 8;
|
||||
solid = false;
|
||||
offset.x = 3;
|
||||
offset.y = 2;
|
||||
health = 1;
|
||||
parent = _parent;
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
|
||||
}
|
||||
|
||||
if (parseInt(xml.@frame) == T_SUPER) {
|
||||
frame_type = T_SUPER;
|
||||
for (var i:int = 0; i < fireballs.maxSize; i++) {
|
||||
var fireball:FlxSprite = new FlxSprite;
|
||||
fireball.loadGraphic(Lion.lion_fireball_sprite, true, false, 16, 16);
|
||||
fireball.width = fireball.height = 8;
|
||||
fireball.centerOffsets(true);
|
||||
fireballs.add(fireball);
|
||||
fireball.addAnimation("shoot",[0, 1], 8);
|
||||
fireball.addAnimation("poof",[2,3,4,5], 8,false);
|
||||
fireball.play("shoot");
|
||||
}
|
||||
fireballs.setAll("visible", false);
|
||||
fireballs.setAll("alive", false);
|
||||
|
||||
parent.fg_sprites.add(fireballs);
|
||||
health = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override public function update():void {
|
||||
var dx:Number;
|
||||
var dy:Number;
|
||||
if (just_hit) {
|
||||
just_hit_timer -= FlxG.elapsed;
|
||||
if (just_hit_timer < 0 && state != S_DEAD) {
|
||||
state = S_WAIT;
|
||||
velocity.x = velocity.y = 0;
|
||||
just_hit_timer = 0.4;
|
||||
just_hit = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (frame_type == T_SUPER && (state != S_DEAD)) {
|
||||
var fireball:FlxSprite;
|
||||
t_fireball += FlxG.elapsed;
|
||||
if (t_fireball > tm_fireball) {
|
||||
t_fireball = 0;
|
||||
fireball = fireballs.getFirstDead() as FlxSprite;
|
||||
if (fireball == null) return;
|
||||
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.fireball_group);
|
||||
fireball.x = x; fireball.y = y;
|
||||
fireball.alpha = 1;
|
||||
EventScripts.scale_vector(new Point(x, y), new Point(target.x, target.y), fireball.velocity, vel_fireball);
|
||||
fireball.visible = fireball.alive = true;
|
||||
fireball.play("shoot");
|
||||
}
|
||||
|
||||
for each (fireball in fireballs.members) {
|
||||
|
||||
if (fireball._curAnim != null && fireball._curAnim.name != "poof") {
|
||||
if (fireball.alpha < 0.9 && !target.invincible && fireball.alive && target.overlaps(fireball)) {
|
||||
target.touchDamage(1);
|
||||
fireball.play("poof");
|
||||
}
|
||||
fireball.alpha -= 0.002;
|
||||
if (fireball.alpha <= 0.6) {
|
||||
fireball.play("poof");
|
||||
}
|
||||
|
||||
if (target.broom.overlaps(fireball) && target.broom.visible) {
|
||||
fireball.play("poof");
|
||||
Dust.dust_sound.play();
|
||||
}
|
||||
} else {
|
||||
if (fireball.finished) {
|
||||
fireball.alive = fireball.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (overlaps(target)) {
|
||||
if (xml.@alive != "false") {
|
||||
target.touchDamage(1);
|
||||
}
|
||||
}
|
||||
if (target.broom.overlaps(this) && target.broom.visible) {
|
||||
hit("broom", target.broom.root.facing);
|
||||
}
|
||||
|
||||
|
||||
if (parent.state == parent.S_TRANSITION) {
|
||||
state = S_WAIT;
|
||||
}
|
||||
|
||||
|
||||
switch (state) {
|
||||
case S_WAIT:
|
||||
wait_timer -= FlxG.elapsed;
|
||||
if (wait_timer < 0) {
|
||||
wait_timer = WAIT_TIMER_MAX;
|
||||
dx = x - target.x;
|
||||
dy = y - target.y;
|
||||
|
||||
if (Math.sqrt(dx * dx + dy * dy) < APPROACH_DISTANCE) state = S_APPROACH;
|
||||
}
|
||||
break;
|
||||
case S_APPROACH:
|
||||
EventScripts.send_property_to(this, "x", target.x + target.width/2 + rotate_radius, 0.6);
|
||||
EventScripts.send_property_to(this, "y", target.y + target.height/2, 0.6);
|
||||
|
||||
dx = x - (target.x + target.width/2 + rotate_radius)
|
||||
dy = y - (target.y + target.height/2);
|
||||
if (Math.sqrt(dx * dx + dy * dy) < 2) state = S_CIRCLE;
|
||||
break;
|
||||
case S_CIRCLE:
|
||||
rotate_about_center_of_sprite(target, this, rotate_radius, rotate_velocity);
|
||||
circle_timer -= FlxG.elapsed;
|
||||
if (circle_timer < 0) {
|
||||
circle_timer = CIRCLE_TIMER_MAX;
|
||||
state = S_ATTACK;
|
||||
dx = x - target.x;
|
||||
if (dx < 0) {
|
||||
swoop_to_point.x = (x + 3 * (target.x - x));
|
||||
} else {
|
||||
swoop_to_point.x = (x - 3 * (x - target.x));
|
||||
}
|
||||
|
||||
|
||||
dy = y - target.y;
|
||||
if (dy < 0) {
|
||||
swoop_to_point.y = y + 3 * (target.y - y);
|
||||
} else {
|
||||
swoop_to_point.y = y - 3 * (y - target.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case S_ATTACK:
|
||||
var res:Boolean = EventScripts.send_property_to(this, "x", swoop_to_point.x, 2.5);
|
||||
var res2:Boolean = EventScripts.send_property_to(this, "y", swoop_to_point.y, 2.5);
|
||||
if (res && res2) {
|
||||
state = S_APPROACH;
|
||||
rotate_angle = 0;
|
||||
}
|
||||
break;
|
||||
case S_HIT:
|
||||
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
hit_timer -= FlxG.elapsed;
|
||||
if (hit_timer < 0) {
|
||||
//explode
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.enemy_explode_1_group);
|
||||
solid = false;
|
||||
loadGraphic(SpriteFactory.SPRITE_ENEMY_EXPLODE_2, true, false, 24, 24);
|
||||
addAnimation("explode", [0, 1, 2, 3, 4], 12, false);
|
||||
play("explode");
|
||||
velocity.x = velocity.y = 0;
|
||||
state = S_DEAD;
|
||||
}
|
||||
break;
|
||||
case S_DEAD:
|
||||
if (frame == 5) {
|
||||
EventScripts.drop_small_health(x, y,0.5);
|
||||
exists = false;
|
||||
}
|
||||
if (!INCREMENTED_REG) {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
INCREMENTED_REG = true;
|
||||
}
|
||||
xml.@alive = "false";
|
||||
fireballs.setAll("exists", false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
if (x < Registry.CURRENT_GRID_X * 160) x = Registry.CURRENT_GRID_X * 160;
|
||||
if (x > (Registry.CURRENT_GRID_X + 1) * 160 - 16) x = (Registry.CURRENT_GRID_X + 1) * 160 - 16;
|
||||
if (y < (Registry.CURRENT_GRID_Y * 160) + 20) y = Registry.CURRENT_GRID_Y * 160 + 20;
|
||||
if (y > (Registry.CURRENT_GRID_Y + 1) * 160 + 20 ) y = (Registry.CURRENT_GRID_Y + 1) * 160 + 20;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Note, requires the rotatee to have a "rotate_angle" property
|
||||
* that will be updated to reflect its progress around the target
|
||||
*/
|
||||
private function rotate_about_center_of_sprite(pivot:FlxSprite,rotatee:*,radius:Number,velocity:Number):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 - 8;
|
||||
rotatee.y = Math.sin(rotatee.rotate_angle) * (radius) + pivot_y - 5;
|
||||
rotatee.rotate_angle = (rotatee.rotate_angle + velocity) % 6.28;
|
||||
}
|
||||
|
||||
public function hit(type:String, hit_dir:uint):int {
|
||||
if (!just_hit) {
|
||||
Registry.sound_data.player_hit_1.play();
|
||||
switch (hit_dir) {
|
||||
case UP:
|
||||
velocity.y = -150; velocity.x = -30 + 60 * Math.random();
|
||||
break;
|
||||
case DOWN:
|
||||
velocity.y = 150;
|
||||
break;
|
||||
case LEFT:
|
||||
velocity.x = -150;
|
||||
break;
|
||||
case RIGHT:
|
||||
velocity.x = 150;
|
||||
break;
|
||||
}
|
||||
just_hit = true;
|
||||
flicker(0.2);
|
||||
health--;
|
||||
state = S_APPROACH;
|
||||
if (health <= 0) state = S_HIT;
|
||||
}
|
||||
return Registry.HIT_NORMAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
package entity.enemy.bedroom
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.SoundData;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.*;
|
||||
import states.PlayState;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
|
||||
public class Pew_Laser extends FlxSprite
|
||||
|
||||
{
|
||||
//[embed laser gfx
|
||||
[Embed (source = "../../../res/sprites/enemies/pew_laser.png")] public static var PEW_LASER:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/pew_laser_bullet.png")] public static var PEW_LASER_BULLET:Class;
|
||||
public var xml:XML;
|
||||
public var parent:PlayState;
|
||||
public var bullets:FlxGroup;
|
||||
public var BULLET_TIMER_MAX:Number = 0.5;
|
||||
public var cur_velocity:Number = 0;
|
||||
public static var BULLET_VELOCITY:Number = 40;
|
||||
public static var BULLET_FAST_VELOCITY:Number = 70;
|
||||
public var bullet_timer:Number = 1;
|
||||
|
||||
private var dir_type:int;
|
||||
private static var T_DOWN:int = 0;
|
||||
private static var T_RIGHT:int = 1;
|
||||
private static var T_UP:int = 2;
|
||||
private static var T_LEFT:int = 3;
|
||||
private static var T_FAST_DOWN:int = 4;
|
||||
private static var T_FAST_RIGHT:int = 5;
|
||||
private static var T_FAST_UP:int = 6
|
||||
private static var T_FAST_LEFT:int = 7;
|
||||
|
||||
private var draw_fix:Boolean = false;
|
||||
private var latency_ticks:int = 3;
|
||||
|
||||
public var cid:int = CLASS_ID.PEW_LASER;
|
||||
public function Pew_Laser(X:Number, Y:Number, _xml:XML,_parent:PlayState)
|
||||
{
|
||||
super(X, Y);
|
||||
xml = _xml;
|
||||
|
||||
//determine frame/animations
|
||||
loadGraphic(PEW_LASER, true, false, 16, 16);
|
||||
|
||||
if (parseInt(xml.@frame) > 3) {
|
||||
cur_velocity = BULLET_FAST_VELOCITY;
|
||||
} else {
|
||||
cur_velocity = BULLET_VELOCITY;
|
||||
}
|
||||
|
||||
dir_type = parseInt(xml.@frame);
|
||||
immovable = true;
|
||||
solid = false;
|
||||
bullets = new FlxGroup(5);
|
||||
parent = _parent;
|
||||
for (var i:int = 0; i < 5; i++) {
|
||||
var bullet:FlxSprite = new FlxSprite(x, y);
|
||||
bullet.loadGraphic(PEW_LASER_BULLET, true, false, 16, 8);
|
||||
bullet.exists = false;
|
||||
bullet.has_tile_callbacks = false;
|
||||
bullet.width = 12;
|
||||
bullet.height = 8;
|
||||
bullets.add(bullet);
|
||||
bullet.addAnimation("a", [0, 1], 8, true);
|
||||
bullet.addAnimation("b", [4, 5, 6, 7], 8, false);
|
||||
bullet.play("a");
|
||||
}
|
||||
parent.fg_sprites.add(bullets);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
switch (parseInt(xml.@frame) % 4) {
|
||||
case 0: frame = 0; break;
|
||||
case 1: frame = 1; bullets.setAll("angle", 270); break;
|
||||
case 2: frame = 2; bullets.setAll("angle", 180); break;
|
||||
case 3: frame = 3;
|
||||
bullets.setAll("angle", 90); bullets.setAll("width", 8);
|
||||
bullets.setAll("height", 16); bullets.setAll("offset", new FlxPoint(2,-4));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void {
|
||||
//taken care of in remove_otehrobjects etc
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public function bullet_on_map(b:FlxSprite, m:FlxTilemap):void {
|
||||
|
||||
b.play("b");
|
||||
}
|
||||
override public function update():void {
|
||||
bullet_timer -= FlxG.elapsed;
|
||||
|
||||
latency_ticks--;
|
||||
if (latency_ticks > 0) {
|
||||
FlxG.collide(bullets, parent.curMapBuf, bullet_on_map);
|
||||
} else {
|
||||
latency_ticks = 3;
|
||||
}
|
||||
|
||||
/*if (!draw_fix) {
|
||||
draw_fix = true;
|
||||
var idx1:int = parent.members.indexOf(bullets.members[0]);
|
||||
parent.members.splice(parent.members.indexOf(this), 1);
|
||||
parent.members.splice(idx1, 0, this);
|
||||
}*/
|
||||
|
||||
for (var j:int = 0; j < bullets.members.length; j++) {
|
||||
var b1:FlxSprite = bullets.members[j];
|
||||
if ((b1.y < parent.upperBorder) || (b1.y + b1.height > parent.lowerBorder) ||
|
||||
(b1.x + b1.width > parent.rightBorder) || (b1.x < parent.leftBorder)) {
|
||||
b1.exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i:int = 0; i < bullets.length; i++) {
|
||||
// Set exists to false at end of anim
|
||||
if (!bullets.members[i].exists) continue;
|
||||
if (bullets.members[i].frame == 7) bullets.members[i].exists = false;
|
||||
if (dir_type % 2 == 0 && bullets.members[i].velocity.y == 0) {
|
||||
|
||||
bullets.members[i].play("b");
|
||||
bullets.members[i].velocity.x = bullets.members[i].velocity.y = 0;
|
||||
bullets.members[i].solid = false;
|
||||
continue;
|
||||
}
|
||||
/* LOL FUCK IT EVERYTHING BECOMES GLOBAL */
|
||||
for (var k:int = 0; k < Registry.subgroup_dust.length; k++) {
|
||||
|
||||
if (Registry.subgroup_dust[k].cid == CLASS_ID.DUST) {
|
||||
if (Registry.subgroup_dust[k].visible && Registry.subgroup_dust[k].frame != Dust.EMPTY_FRAME && Registry.subgroup_dust[k].overlaps(bullets.members[i])) {
|
||||
bullets.members[i].play("b");
|
||||
bullets.members[i].velocity.x = bullets.members[i].velocity.y = 0;
|
||||
bullets.members[i].solid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var ka:int = 0; ka < parent.statefuls.length; ka++) {
|
||||
if (parent.statefuls[ka] == null) continue;
|
||||
if (parent.statefuls[ka].cid == CLASS_ID.SHIELDY && (parent.statefuls[ka].health > 0) && bullets.members[i]._curAnim.name == "a") {
|
||||
if (bullets.members[i].overlaps(parent.statefuls[ka])) {
|
||||
parent.statefuls[ka].hit("Pew_Laser", 0);
|
||||
bullets.members[i].velocity.x = bullets.members[i].velocity.y = 0;
|
||||
bullets.members[i].play("b");
|
||||
bullets.members[i].solid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parent.player.overlaps(bullets.members[i]) && bullets.members[i].exists) {
|
||||
parent.player.touchDamage(1, "zap");
|
||||
bullets.members[i].play("b");
|
||||
bullets.members[i].velocity.x = bullets.members[i].velocity.y = 0;
|
||||
bullets.members[i].solid = false;
|
||||
|
||||
}
|
||||
}
|
||||
if (bullet_timer < 0) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.laser_pew_group);
|
||||
var b:FlxSprite = bullets.getFirstAvailable() as FlxSprite;
|
||||
if (b != null) {
|
||||
b.exists = true;
|
||||
b.solid = true;
|
||||
b.play("a");
|
||||
switch (dir_type) {
|
||||
case T_DOWN: case T_FAST_DOWN: b.height = 3; b.velocity.y = cur_velocity; b.y = y + 11; b.offset.y = 4; b.x = x + 2; b.offset.x = 2; break;
|
||||
case T_UP: case T_FAST_UP: b.height = 3; b.velocity.y = -cur_velocity; b.y = y + 8; b.x = x + 2; b.offset.x = 2; b.offset.y = 1; break;
|
||||
case T_LEFT: case T_FAST_LEFT: b.width = 3; b.velocity.x = -cur_velocity; b.x = x + 8; b.offset.y = -4; b.offset.x = 5; break;
|
||||
case T_RIGHT: case T_FAST_RIGHT: b.y = y + 2; b.offset.y = -2; b.offset.x = 9; b.velocity.x = cur_velocity; b.x = x + 2; b.width = 3; b.height = 12; break;
|
||||
}
|
||||
bullet_timer = BULLET_TIMER_MAX;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
package entity.enemy.bedroom
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Switch_Pillar;
|
||||
import entity.player.HealthBar;
|
||||
import entity.player.HealthPickup;
|
||||
import entity.player.Player;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import global.Registry;
|
||||
import states.PlayState;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia */
|
||||
public class Shieldy extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/shieldy.png")] public static var SPRITE_SHIELDY:Class;
|
||||
public var xml:XML;
|
||||
public var just_hit:Boolean = false;
|
||||
public var hit_timer_max:Number = 0.4;
|
||||
public var hit_timer:Number = 0.4;
|
||||
public var parent:PlayState;
|
||||
public static var FLOATING_VELOCITY:int = 30;
|
||||
public static var T_LEFT:int = 4;
|
||||
public static var T_UP:int = 5;
|
||||
public static var T_RIGHT:int = 6;
|
||||
public static var T_DOWN:int = 7;
|
||||
public var INCREMENTED_REGISTRY:Boolean = false;
|
||||
|
||||
public var state:int;
|
||||
public static var S_L:int = 0;
|
||||
public static var S_R:int = 1;
|
||||
public static var S_U:int = 2;
|
||||
public static var S_D:int = 3;
|
||||
public static var S_NOTHING:int = 4;
|
||||
public var ul_pt:FlxSprite;
|
||||
public var dr_pt:FlxSprite;
|
||||
|
||||
public var cid:int = CLASS_ID.SHIELDY;
|
||||
public var player:Player;
|
||||
|
||||
|
||||
public function Shieldy(x:int,y:int,_xml:XML,_parent:PlayState)
|
||||
{
|
||||
super(x +2, y);
|
||||
xml = _xml;
|
||||
parent = _parent;
|
||||
loadGraphic(SPRITE_SHIELDY, true, false, 16, 16);
|
||||
addAnimation("float", [1, 2, 1, 0], 5, true);
|
||||
//addAnimation("unhurt", [4], 7, true);
|
||||
addAnimation("front_hit", [16, 17, 18, 1], 12, false);
|
||||
addAnimation("back_hit", [13, 1], 12);
|
||||
//addAnimation("die", [8, 9, 10, 11,14], 10, false);
|
||||
play("float");
|
||||
immovable = true;
|
||||
solid = true;
|
||||
height = 10;
|
||||
width = 10;
|
||||
|
||||
offset.x = 3;
|
||||
offset.y = 4;
|
||||
health = 2;
|
||||
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0: state = S_NOTHING; break;
|
||||
case T_LEFT: velocity.x = - FLOATING_VELOCITY; state = S_L; break;
|
||||
case T_RIGHT: velocity.x = FLOATING_VELOCITY; state = S_R; break;
|
||||
case T_UP: velocity.y = -FLOATING_VELOCITY; state = S_U; break;
|
||||
case T_DOWN: velocity.y = FLOATING_VELOCITY; state = S_D; break;
|
||||
}
|
||||
|
||||
ul_pt = new FlxSprite(x, y);
|
||||
dr_pt = new FlxSprite(x, y + 10);
|
||||
ul_pt.makeGraphic(10, 1, 0xffff0000);
|
||||
|
||||
dr_pt.makeGraphic(10, 1, 0xffff0000);
|
||||
player = _parent.player;
|
||||
|
||||
add_sfx("ineffective", Registry.sound_data.shieldy_ineffective);
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
}
|
||||
}
|
||||
|
||||
/* check for hit*/
|
||||
if (solid && player.broom.visible && player.broom.overlaps(this)) {
|
||||
hit("broom", player.facing);
|
||||
}
|
||||
/* hurt player */
|
||||
if (FlxG.overlap(this, player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
/* drop health and animate if die */
|
||||
if (health <= 0 && solid) {
|
||||
EventScripts.drop_small_health(x,y,0.5);
|
||||
if (!INCREMENTED_REGISTRY) {
|
||||
INCREMENTED_REGISTRY = true;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
}
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
visible = false;
|
||||
velocity.y = velocity.x = 0;
|
||||
Registry.sound_data.shieldy_hit.play();
|
||||
exists = false;
|
||||
solid = false;
|
||||
}
|
||||
|
||||
|
||||
if (just_hit) {
|
||||
hit_timer -= FlxG.elapsed;
|
||||
if (hit_timer < 0) {
|
||||
hit_timer = hit_timer_max;
|
||||
just_hit = false;
|
||||
}
|
||||
} else {
|
||||
if (health > 0)
|
||||
play("float");
|
||||
}
|
||||
|
||||
/* collide with map and switch dirs */
|
||||
ul_pt.x = x;
|
||||
ul_pt.y = y;
|
||||
dr_pt.x = x;
|
||||
dr_pt.y = y + 10;
|
||||
switch (state) {
|
||||
case S_R:
|
||||
if (touches_something() || FlxG.collide(dr_pt, parent.curMapBuf)) {
|
||||
state = S_L;
|
||||
velocity.x = -FLOATING_VELOCITY;
|
||||
}
|
||||
break;
|
||||
case S_L:
|
||||
if (touches_something() || FlxG.collide(ul_pt, parent.curMapBuf)) {
|
||||
state = S_R;
|
||||
velocity.x = FLOATING_VELOCITY;
|
||||
}
|
||||
break;
|
||||
case S_U:
|
||||
if (touches_something() || FlxG.collide(ul_pt, parent.curMapBuf)) {
|
||||
state = S_D;
|
||||
velocity.y = FLOATING_VELOCITY;
|
||||
}
|
||||
break;
|
||||
case S_D:
|
||||
if (touches_something() || FlxG.collide(dr_pt, parent.curMapBuf)) {
|
||||
state = S_U;
|
||||
velocity.y = -FLOATING_VELOCITY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function touches_something():Boolean {
|
||||
for each (var sp:Switch_Pillar in Registry.subgroup_switch_pillars) {
|
||||
if (sp == null) continue;
|
||||
if (sp.overlaps(this) && (sp.frame == sp.up_frame)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function hit(hitter:String, dir_player_facing:uint):int {
|
||||
if (hitter == "Pew_Laser") {
|
||||
health -= 5;
|
||||
return Registry.HIT_NORMAL;
|
||||
}
|
||||
if (dir_player_facing == FlxObject.DOWN && !just_hit) {
|
||||
Registry.sound_data.shieldy_hit.play();
|
||||
just_hit = true;
|
||||
health --;
|
||||
flicker(hit_timer_max / 2);
|
||||
play("back_hit");
|
||||
return Registry.HIT_NORMAL;
|
||||
} else if (!just_hit) {
|
||||
play("front_hit");
|
||||
play_sfx("ineffective");
|
||||
var old_x:int = int(x);
|
||||
var old_y:int = int(y);
|
||||
switch (dir_player_facing) {
|
||||
case LEFT:
|
||||
if (x % 160 > 20) {
|
||||
x -= 8;
|
||||
}
|
||||
break;
|
||||
|
||||
case UP:
|
||||
y -= 8; break;
|
||||
case RIGHT:
|
||||
if (x % 160 < 125) {
|
||||
x += 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
just_hit = true;
|
||||
var tile_type:int = parent.map.getTile(int(int(x) / 16), int((int(y) - 20) / 16));
|
||||
if (parent.curMapBuf._tileObjects[tile_type].allowCollisions == FlxObject.ANY) {
|
||||
x = old_x;
|
||||
y = old_y;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
package entity.enemy.bedroom
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Key;
|
||||
import entity.player.HealthPickup;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxEmitter;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSound;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxG;
|
||||
import global.Registry;
|
||||
public class Slime extends FlxSprite
|
||||
{
|
||||
[Embed ("../../../res/sprites/enemies/slime.png")] public static var Slime_Sprite:Class;
|
||||
[Embed ("../../../res/sprites/enemies/bedroom/slime_goo.png")] public var Slime_Goo_Sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/slime_bullet.png")] public static const embed_slime_bullet:Class;
|
||||
[Embed ("../../../../../sfx/hit_slime.mp3")] public var Slime_Hit_Sound:Class;
|
||||
public var slime_hit_sound:FlxSound = new FlxSound();
|
||||
|
||||
public var local_id:int;
|
||||
public var gotHit:Boolean = false;
|
||||
public var hitTimer:Number = 0;
|
||||
public var deathTimer:Number = 0;
|
||||
public var HIT_TIMEOUT:Number = 0.3;
|
||||
public var xml:XML;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_dead:int = 1;
|
||||
private var dropped_health:Boolean = false;
|
||||
|
||||
public var type:int;
|
||||
public static var NORMAL_T:int = 0;
|
||||
public static var KEY_T:int = 1;
|
||||
public static var RISE_T:int = 2;
|
||||
public static var SUPER_T:int = 3;
|
||||
|
||||
public var played_rise:Boolean = false;
|
||||
public var has_key:Boolean = false;
|
||||
public var cid:int = CLASS_ID.SLIME;
|
||||
public var INCREMENTED_REGISTRY:Boolean = false;
|
||||
|
||||
public var change_vel_timer:Number = 0.5;
|
||||
public var change_vel_timer_max:Number = 0.5;
|
||||
private var VEL:int = 20;
|
||||
private var BULLET_VEL:int = 40;
|
||||
|
||||
public var t_shoot:Number = 0;
|
||||
public var tm_shoot:Number = 1.8;
|
||||
public var goo_collide_ticks:int = 4;
|
||||
|
||||
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
public var goo_group:FlxGroup = new FlxGroup(7);
|
||||
public var goo_bullets:FlxGroup = new FlxGroup(4);
|
||||
|
||||
public var move_frame_sound_sync:Boolean = false;
|
||||
|
||||
public function Slime(x:int, y:int, _local_id:int, frame_type:int, _xml:XML, _p:Player,_parent:*) {
|
||||
super(x, y);
|
||||
slime_hit_sound.loadEmbedded(Slime_Hit_Sound, false);
|
||||
health = 2;
|
||||
loadGraphic(Slime_Sprite, true, false, 16, 16);
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
addAnimation("Move", [2,3], 3);
|
||||
addAnimation("Hurt", [2,8], 15);
|
||||
addAnimation("Dead", [2, 8, 2, 8, 15, 9, 9], 12, false);
|
||||
} else {
|
||||
addAnimation("Move", [0, 1], 3);
|
||||
addAnimation("Hurt", [0, 8], 15);
|
||||
addAnimation("Dead", [0, 8, 0, 8, 15, 9, 9], 12, false);
|
||||
}
|
||||
addAnimation("Rise", [7, 7, 6, 6, 5, 5, 4, 4, 8, 0, 8, 0], 15, false);
|
||||
width = height = 12;
|
||||
offset.x = offset.y = 2;
|
||||
if (frame_type != RISE_T) {
|
||||
play("Move");
|
||||
} else {
|
||||
visible = false;
|
||||
solid = true;
|
||||
}
|
||||
local_id = _local_id;
|
||||
xml = _xml;
|
||||
|
||||
if (frame_type == KEY_T) {
|
||||
has_key = true;
|
||||
} else if (frame_type == SUPER_T) {
|
||||
VEL = 40;
|
||||
}
|
||||
type = frame_type;
|
||||
|
||||
player = _p;
|
||||
parent = _parent;
|
||||
|
||||
|
||||
for (var i:int = 0; i < goo_group.maxSize; i++) {
|
||||
var goo:FlxSprite = new FlxSprite(0, 0);
|
||||
goo.loadGraphic(Slime_Goo_Sprite, true, false, 6, 6);
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
goo.addAnimation("move", [4,5,6,7,5,7,5,6,5,4], 5 + int(5 * Math.random()));
|
||||
} else {
|
||||
goo.addAnimation("move", [0,1,2,3,1,3,1,2,1,0],5 + int(5*Math.random()));
|
||||
}
|
||||
goo.play("move");
|
||||
|
||||
goo.my_shadow = new FlxSprite();
|
||||
goo.my_shadow.makeGraphic(3, 3, 0xff010101);
|
||||
goo_group.add(goo);
|
||||
parent.bg_sprites.add(goo.my_shadow);
|
||||
|
||||
goo.exists = goo.my_shadow.exists = false;
|
||||
goo.velocity.x = Math.random() > 0.5 ? -10 - 5 * Math.random() : 10 + 5 * Math.random();
|
||||
goo.velocity.y = Math.random() > 0.5 ? -10 - 5 * Math.random() : 10 + 5 * Math.random();
|
||||
goo.parabola_thing = new Parabola_Thing(goo, 16, 0.8 + 0.3 * Math.random(), "offset", "y");
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < goo_bullets.maxSize; i++) {
|
||||
goo = new FlxSprite(0, 0);
|
||||
goo.loadGraphic(Slime_Goo_Sprite, true, false, 6, 6);
|
||||
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
goo.addAnimation("move", [4,5,6,7,5,7,5,6,5,4], 5 + int(5 * Math.random()));
|
||||
} else {
|
||||
|
||||
goo.loadGraphic(embed_slime_bullet, true, false, 8,8);
|
||||
goo.addAnimation("move", [0, 1], 5 + int(5 * Math.random()));
|
||||
}
|
||||
goo.play("move");
|
||||
|
||||
goo.exists = false;
|
||||
goo_bullets.add(goo);
|
||||
}
|
||||
|
||||
parent.bg_sprites.add(goo_group);
|
||||
parent.bg_sprites.add(goo_bullets);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
add_sfx("walk", Registry.sound_data.slime_walk_group);
|
||||
add_sfx("shoot", Registry.sound_data.slime_shoot_group);
|
||||
add_sfx("splash", Registry.sound_data.slime_splash_group);
|
||||
}
|
||||
override public function preUpdate():void
|
||||
{
|
||||
FlxG.collide(this, parent.map_bg_2);
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void {
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
}
|
||||
}
|
||||
if (state == s_dead) {
|
||||
} else {
|
||||
|
||||
if (frame == 1) {
|
||||
if (!move_frame_sound_sync) {
|
||||
move_frame_sound_sync = true;
|
||||
play_sfx("walk");
|
||||
}
|
||||
} else if (frame == 0) {
|
||||
move_frame_sound_sync = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hurt logic */
|
||||
if (xml.@alive == "true") {
|
||||
if (FlxG.overlap(this, player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (player.broom.visible && FlxG.overlap(this, player.broom) ){
|
||||
var res:int = hit("broom", player.broom.root.facing);
|
||||
if (res == Registry.HIT_KEY) {
|
||||
var key:Key = new Key(x, y,player,parent);
|
||||
parent.bg_sprites.add(key);
|
||||
if (Registry.is_playstate) {
|
||||
//bug with roamstate as is
|
||||
parent.stateful_gridXML.appendChild(key.xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Broken
|
||||
if (type == RISE_T) {
|
||||
if (Registry.EVENT_OPEN_BROOM) {
|
||||
if (!played_rise) {
|
||||
play("Rise");
|
||||
solid = true;
|
||||
visible = true;
|
||||
}
|
||||
if (frame == 0) play("Move");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* If dead, disappear, otherwise, change direction */
|
||||
if (health == 0) {
|
||||
if (!dropped_health) {
|
||||
dropped_health = true;
|
||||
EventScripts.drop_small_health(x, y, 0.5);
|
||||
}
|
||||
xml.@alive = "false";
|
||||
if (frame == 9 && state != s_dead) {
|
||||
deathTimer += FlxG.elapsed;
|
||||
if (deathTimer > 0.5) {
|
||||
solid = false;
|
||||
state = s_dead;
|
||||
goo_group.setAll("velocity", new FlxPoint(0, 0));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
change_vel_timer -= FlxG.elapsed;
|
||||
if (!gotHit && change_vel_timer < 0) {
|
||||
change_vel_timer = change_vel_timer_max
|
||||
velocity.x = VEL * Math.random() - VEL/2;
|
||||
velocity.y = VEL * Math.random() - VEL/2;
|
||||
if (frame == 1) {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
} else {
|
||||
if (gotHit) {
|
||||
hitTimer += FlxG.elapsed;
|
||||
}
|
||||
if (hitTimer > HIT_TIMEOUT) {
|
||||
play("Move");
|
||||
hitTimer = 0; gotHit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update goo effect */
|
||||
for each (var goo:FlxSprite in goo_group.members) {
|
||||
if (goo != null && goo.exists) {
|
||||
if (goo.parabola_thing.tick()) {
|
||||
if (goo.alpha == 1) {
|
||||
play_sfx("splash");
|
||||
}
|
||||
goo.alpha -= 0.01;
|
||||
goo.my_shadow.exists = false;
|
||||
goo._curAnim = null;
|
||||
goo.velocity.x = goo.velocity.y = 0;
|
||||
} else {
|
||||
goo.my_shadow.x = goo.x;
|
||||
goo.my_shadow.y = goo.y;
|
||||
FlxG.collide(goo, parent.curMapBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* do bullets, maybe */
|
||||
goo_collide_ticks < 0 ? goo_collide_ticks = 3 : goo_collide_ticks -- ;
|
||||
if (type == SUPER_T) {
|
||||
t_shoot += FlxG.elapsed;
|
||||
if (t_shoot > tm_shoot) {
|
||||
t_shoot = 0;
|
||||
goo = goo_bullets.getFirstAvailable() as FlxSprite;
|
||||
// Only shoot when alive
|
||||
if (goo != null && xml.@alive != "false") {
|
||||
goo.alpha = 1;
|
||||
goo.exists = true;
|
||||
goo.x = x; goo.y = y;
|
||||
play_sfx("shoot");
|
||||
EventScripts.scale_vector( new Point(x, y), new Point(player.x, player.y), goo.velocity, BULLET_VEL);
|
||||
}
|
||||
}
|
||||
for each (goo in goo_bullets.members) {
|
||||
if (goo == null || !goo.exists) continue;
|
||||
if (goo_collide_ticks == 0) {
|
||||
if (FlxG.collide(goo, parent.curMapBuf)) {
|
||||
goo.exists = false;
|
||||
}
|
||||
}
|
||||
goo.alpha -= 0.013;
|
||||
if (goo.alpha <= 0.3) {
|
||||
goo.exists = false;
|
||||
goo.velocity.y = goo.velocity.x = 0;
|
||||
|
||||
} else {
|
||||
if (!player.invincible && player.state != player.S_AIR && goo.overlaps(player)) {
|
||||
goo.velocity.x = goo.velocity.y = 0;
|
||||
goo.alpha = 0;
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uh, getting hit. Type is what hits it. Dir is what direction.
|
||||
* @param type
|
||||
* @param dir
|
||||
* @return HIT_NORMAL if died or normal. HIT_KEY if drops key...
|
||||
*/
|
||||
|
||||
public function hit(type:String, dir:int):int {
|
||||
if (visible == false) return -1;
|
||||
if (type == "broom" && !gotHit) {
|
||||
for (var i:int = 0; i < 2; i++) {
|
||||
var goo:FlxSprite = goo_group.getFirstAvailable() as FlxSprite;
|
||||
goo.exists = goo.my_shadow.exists = true;
|
||||
goo.x = x;
|
||||
goo.y = y;
|
||||
}
|
||||
health -= 1;
|
||||
slime_hit_sound.play();
|
||||
if (health == 0) {
|
||||
velocity.x = velocity.y = 0;
|
||||
if (!INCREMENTED_REGISTRY) {
|
||||
INCREMENTED_REGISTRY = true;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
visible = false;
|
||||
play("Dead");
|
||||
}
|
||||
|
||||
if (has_key) {
|
||||
has_key = false;
|
||||
gotHit = true;
|
||||
return Registry.HIT_KEY;
|
||||
}
|
||||
|
||||
} else {
|
||||
play("Hurt");
|
||||
}
|
||||
switch (dir) {
|
||||
|
||||
case FlxObject.LEFT: velocity.x = -100; break;
|
||||
case FlxObject.RIGHT: velocity.x = 100; break;
|
||||
case FlxObject.UP: velocity.y = -100; break;
|
||||
case FlxObject.DOWN: velocity.y = 100; break;
|
||||
}
|
||||
}
|
||||
gotHit = true;
|
||||
return Registry.HIT_NORMAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,637 @@
|
|||
package entity.enemy.bedroom
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.SoundData;
|
||||
import entity.decoration.Light;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import helper.Achievements;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import org.flixel.*;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import flash.geom.Point;
|
||||
import states.PlayState;
|
||||
|
||||
|
||||
public class Sun_Guy extends FlxSprite
|
||||
{
|
||||
|
||||
/*intro: statue, darkened room, rays of light rotate out of eyes
|
||||
* then whole room gets lit?
|
||||
*
|
||||
* floats, moves horizontally, usually has a force field
|
||||
* shoots lasers across the screen, you must push dust to block them
|
||||
* these comes from two orbs
|
||||
* can only hit him when the orbs are not circling
|
||||
* can attack the orbs too
|
||||
* */
|
||||
public var xml:XML;
|
||||
|
||||
/* state vars */
|
||||
protected var times_hurt_player:int = 0;
|
||||
protected var S_INTRO_1:int = 0;
|
||||
protected var S_INTRO_2:int = 6;
|
||||
protected var S_INTRO_0:int = 7;
|
||||
protected var S_HORIZONTAL_FLOAT:int = 1;
|
||||
private var HF_1:Boolean = false;
|
||||
private var VF_1:Boolean = false;
|
||||
protected var S_CHARGE:int = 2;
|
||||
protected var S_CHARGE_CTR:int = 0;
|
||||
protected var S_FIRE_LASER:int = 3;
|
||||
protected var S_DYING:int = 4;
|
||||
protected var S_DYING_CTR:int = 0;
|
||||
protected var S_DEAD:int = 5;
|
||||
protected var S_VERTIFLOAT:int = 8;
|
||||
protected var S_VERTIFLOAT_CTR:int = 0;
|
||||
|
||||
protected var STATE:int;
|
||||
private var INCREMENTED_REGISTRY:Boolean = false;
|
||||
|
||||
public var just_got_hurt:Boolean = false;
|
||||
public var hit_timer:Number = 1;
|
||||
public var HIT_TIMER_MAX:Number = 1.5;
|
||||
|
||||
/* other stuff */
|
||||
public var dusts:FlxGroup = new FlxGroup(3);
|
||||
private var dusts_poofed:Boolean = false;
|
||||
/* Lighting for intro */
|
||||
private var light_cone_1:Light;
|
||||
private var light_cone_2:Light;
|
||||
|
||||
/* entities for dying outr o */
|
||||
private var white_overlay:FlxSprite = new FlxSprite(0, 0);
|
||||
/* Circular protective orbs */
|
||||
private var light_orb_1:FlxSprite;
|
||||
private var light_orb_2:FlxSprite;
|
||||
private var orb_illum_1:Light;
|
||||
private var orb_illum_2:Light;
|
||||
private var sun_guy_wave:FlxSprite;
|
||||
private var sun_wave_evaporating:Boolean = false;
|
||||
|
||||
/* Radii of circulation, rotation velocity (degrees/tick), angle about boss */
|
||||
public var lr_1:Number = 16;
|
||||
public var lr_2:Number = 32;
|
||||
public var rv_1:Number = 0.05;
|
||||
public var rv_2:Number = 0.04;
|
||||
private var a_1:Number = 0;
|
||||
private var a_2:Number = 0;
|
||||
|
||||
private var MAX_HEALTH:int = 7; //health of boss
|
||||
private var center_pt:FlxPoint = new FlxPoint(0, 0); //used for rotations
|
||||
|
||||
/* References we need for events/lighting */
|
||||
private var player:Player;
|
||||
private var darkness:FlxSprite;
|
||||
private var parent:PlayState;
|
||||
|
||||
private var y_timer:Number = 0; //For y-oscillations
|
||||
private var stopped_song:Boolean = false;
|
||||
private var started_song:Boolean = false;
|
||||
private var base_pt:Point; //Spawn point of the boss
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/sun_guy.png")] public static var C_SUN_GUY:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/light_orb.png")] public static var C_LIGHT_ORB:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/sun_guy_wave.png")] public static var C_SUN_GUY_WAVE:Class;
|
||||
|
||||
|
||||
private var DEAD_FRAME:int = 4;
|
||||
public var cid:int = CLASS_ID.SUN_GUY;
|
||||
|
||||
public function Sun_Guy(_x:int,_y:int,_darkness:FlxSprite,_parent:PlayState,_xml:XML,_player:Player)
|
||||
{
|
||||
super(_x, _y);
|
||||
base_pt = new Point(_x, _y);
|
||||
xml = _xml;
|
||||
health = MAX_HEALTH;
|
||||
player = _player;
|
||||
darkness = _darkness;
|
||||
immovable = true;
|
||||
parent = _parent;
|
||||
if (Registry.FUCK_IT_MODE_ON) {
|
||||
MAX_HEALTH = 1;
|
||||
xml.@alive = "false";
|
||||
}
|
||||
if (xml.@alive == "false") {
|
||||
STATE = S_DEAD;
|
||||
} else {
|
||||
STATE = S_INTRO_0;
|
||||
}
|
||||
|
||||
/* Animations for boss */
|
||||
loadGraphic(C_SUN_GUY, true, false, 16, 24);
|
||||
addAnimation("foo", [0, 1, 2, 3, 4], 3);
|
||||
addAnimation("death_fade", [12, 13, 14, 15, 16, 17, 18,19], 6,false);
|
||||
play("foo");
|
||||
if (STATE == S_DEAD) frame = DEAD_FRAME;
|
||||
|
||||
|
||||
light_cone_1 = new Light(x - 12, y- 32, darkness, Light.T_CONE_LIGHT, false);
|
||||
light_cone_2 = new Light(x - 6, y - 32, darkness, Light.T_CONE_LIGHT, false);
|
||||
|
||||
/* ANIMS FOR ORBS */
|
||||
light_orb_1 = new FlxSprite(x - 16, y);
|
||||
light_orb_2 = new FlxSprite(x + 32, y);
|
||||
|
||||
light_orb_1.addAnimation("glow", [0, 1, 2, 3, 4/*, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12*/], 10, true);
|
||||
light_orb_2.addAnimation("glow", [2, 3, 4, 0, 1/*6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3, 4, 5*/], 10, true);
|
||||
light_orb_1.play("glow");
|
||||
light_orb_2.play("glow");
|
||||
|
||||
light_orb_1.loadGraphic(C_LIGHT_ORB, true, false, 16, 16);
|
||||
light_orb_2.loadGraphic(C_LIGHT_ORB, true, false, 16, 16);
|
||||
light_orb_1.width = light_orb_1.height = light_orb_2.height = light_orb_2.width = 12;
|
||||
light_orb_1.offset.x = light_orb_1.offset.y = 2;
|
||||
light_orb_2.offset.x = light_orb_2.offset.y = 2;
|
||||
orb_illum_1 = new Light(x, y, darkness, Light.T_FIVE_FRAME_GLOW, true, light_orb_1, 5, Light.L_SUN_GUY_ORBS);
|
||||
orb_illum_2 = new Light(x, y, darkness, Light.T_FIVE_FRAME_GLOW, true, light_orb_2, 5, Light.L_SUN_GUY_ORBS);
|
||||
orb_illum_1.base_x_scale = orb_illum_1.base_y_scale = orb_illum_2.base_y_scale = orb_illum_2.base_x_scale = 0.8;
|
||||
orb_illum_1.addAnimation("flicker", [0, 1, 2, 3, 4,3,2,1], 6, true);
|
||||
orb_illum_2.addAnimation("flicker", [0, 1, 2, 3, 4,3,2,1], 6, true);
|
||||
orb_illum_1.play("flicker");
|
||||
orb_illum_2.play("flicker");
|
||||
|
||||
/* BIG WAVE ANIMS */
|
||||
sun_guy_wave = new FlxSprite(base_pt.x - 50, base_pt.y +8);
|
||||
|
||||
sun_guy_wave.loadGraphic(C_SUN_GUY_WAVE, true, false, 128, 8);
|
||||
sun_guy_wave.addAnimation("play", [3, 4, 5], 8, true);
|
||||
sun_guy_wave.addAnimation("evaporate", [2, 1, 0], 8, false);
|
||||
sun_guy_wave.play("play");
|
||||
parent.add(sun_guy_wave);
|
||||
sun_guy_wave.visible = false;
|
||||
|
||||
for (var i:int = 0; i < 3; i++) {
|
||||
var dust:Dust = new Dust(0, 0, null,parent);
|
||||
dust.exists = false;
|
||||
dusts.add(dust);
|
||||
parent.bg_sprites.add(dusts);
|
||||
|
||||
}
|
||||
|
||||
light_orb_1.visible = light_orb_2.visible = false;
|
||||
orb_illum_1.visible = orb_illum_2.visible = false;
|
||||
parent.add(light_cone_1);
|
||||
parent.add(light_cone_2);
|
||||
parent.add(light_orb_1);
|
||||
parent.add(light_orb_2);
|
||||
parent.add(orb_illum_1);
|
||||
parent.add(orb_illum_2);
|
||||
alpha = light_cone_1.alpha = light_cone_2.alpha = 0;
|
||||
|
||||
/* White overlay */
|
||||
white_overlay.makeGraphic(160, 180, 0xffffffff);
|
||||
white_overlay.scrollFactor = new FlxPoint(0, 0);
|
||||
parent.add(white_overlay);
|
||||
white_overlay.visible = false;
|
||||
|
||||
|
||||
Registry.EVENT_CHANGE_DARKNESS_ALPHA = false;
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
|
||||
if (player.health_bar.cur_health <= 0) {
|
||||
light_orb_1.alpha -= 0.05;
|
||||
light_orb_2.alpha = sun_guy_wave.alpha = light_orb_1.alpha;
|
||||
dusts.setAll("visible", false);
|
||||
}
|
||||
|
||||
if (player.broom.overlaps(this)) {
|
||||
if (player.broom.visible) {
|
||||
hit("broom", player.broom.root.facing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (just_got_hurt) {
|
||||
hit_timer -= FlxG.elapsed;
|
||||
if (hit_timer < 0) {
|
||||
hit_timer = HIT_TIMER_MAX;
|
||||
just_got_hurt = false;
|
||||
}
|
||||
if (health == 0) {
|
||||
STATE = S_DYING;
|
||||
light_cone_2.base_x_scale = light_cone_2.base_y_scale = 1;
|
||||
light_cone_2.x = x -8;
|
||||
light_cone_2.y = y - 24;
|
||||
parent.remove(white_overlay, true);
|
||||
parent.add(white_overlay);
|
||||
play("death_fade");
|
||||
health = -1;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
FlxG.shake(0.01,1);
|
||||
}
|
||||
}
|
||||
switch (STATE) {
|
||||
case S_INTRO_0:
|
||||
intro_state_0();
|
||||
break;
|
||||
case S_INTRO_1:
|
||||
intro_state_1();
|
||||
break;
|
||||
case S_INTRO_2:
|
||||
intro_state_2();
|
||||
break;
|
||||
case S_HORIZONTAL_FLOAT:
|
||||
horizontal_float_state();
|
||||
break;
|
||||
case S_VERTIFLOAT:
|
||||
vertifloat_state();
|
||||
break;
|
||||
case S_DYING:
|
||||
dying_state();
|
||||
break;
|
||||
case S_DEAD:
|
||||
dead_state();
|
||||
break;
|
||||
case S_CHARGE:
|
||||
charge_state();
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function intro_state_0():void {
|
||||
|
||||
if (Registry.sound_data.sun_guy_scream.playing) {
|
||||
Registry.sound_data.sun_guy_scream = new FlxSound();
|
||||
Registry.sound_data.sun_guy_scream.loadEmbedded(SoundData.S_SUN_GUY_SCREAM);
|
||||
|
||||
}
|
||||
if (!stopped_song) {
|
||||
stopped_song = true;
|
||||
Registry.sound_data.stop_current_song();
|
||||
}
|
||||
EventScripts.send_alpha_to(darkness, 0.9, 0.006);
|
||||
|
||||
EventScripts.send_property_to(player.light, "base_x_scale", 1.7, -0.02);
|
||||
EventScripts.send_property_to(player.light, "base_y_scale", 1.7, -0.02);
|
||||
if ((player.y - y) < 48) {
|
||||
|
||||
if (!started_song) {
|
||||
started_song = true;
|
||||
DH.start_dialogue(DH.name_sun_guy, DH.scene_sun_guy_before_fight);
|
||||
}
|
||||
player.dontMove = true;
|
||||
EventScripts.send_alpha_to(light_cone_1, 1.0, 0.01);
|
||||
EventScripts.send_alpha_to(light_cone_2, 1.0, 0.01);
|
||||
EventScripts.send_alpha_to(this, 1.0, 0.007);
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
Registry.sound_data.start_song_from_title("BOSS");
|
||||
STATE = S_INTRO_1;
|
||||
player.dontMove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function intro_state_1():void {
|
||||
EventScripts.send_alpha_to(darkness, 0.1, -0.02);
|
||||
EventScripts.send_property_to(light_cone_1, "base_x_scale", 3, 0.01);
|
||||
EventScripts.send_property_to(light_cone_2, "base_x_scale", 3, 0.01);
|
||||
if (EventScripts.send_property_to(light_cone_1, "base_y_scale", 3, 0.02) ||
|
||||
EventScripts.send_property_to(light_cone_2, "base_y_scale", 3, 0.02)) {
|
||||
STATE = S_INTRO_2;
|
||||
}
|
||||
FlxG.shake(0.01,1);
|
||||
EventScripts.send_property_to(player.light, "base_x_scale", 1.0, -0.02);
|
||||
EventScripts.send_property_to(player.light, "base_y_scale", 1.0, -0.02);
|
||||
|
||||
FlxG.collide(player, this);
|
||||
}
|
||||
|
||||
private function intro_state_2():void {
|
||||
if (EventScripts.send_property_to(light_cone_1, "angle", 180, 5)) {
|
||||
if (EventScripts.send_property_to(light_cone_1, "base_x_scale", 5, 0.3)) {
|
||||
STATE = S_HORIZONTAL_FLOAT;
|
||||
light_orb_1.visible = light_orb_2.visible = true;
|
||||
orb_illum_1.visible = orb_illum_2.visible = true;
|
||||
}
|
||||
}
|
||||
FlxG.collide(player, this);
|
||||
}
|
||||
private function horizontal_float_state():void {
|
||||
/* Oscillate boss */
|
||||
y_timer += FlxG.elapsed;
|
||||
y = base_pt.y + 10 * Math.sin(y_timer);
|
||||
/* Move left and right */
|
||||
|
||||
move_horizontally();
|
||||
|
||||
/* Rotate orbs around boss */
|
||||
|
||||
rotate_orbs_about_sun_guy();
|
||||
|
||||
|
||||
|
||||
|
||||
/* Touch damage with player */
|
||||
if (FlxG.collide(player, this) || FlxG.overlap(player, light_orb_1) || FlxG.overlap(player, light_orb_2)) {
|
||||
player.touchDamage(1);
|
||||
times_hurt_player++;
|
||||
}
|
||||
|
||||
if (health <= 6) {
|
||||
STATE = S_VERTIFLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
private function dying_state():void {
|
||||
velocity.x = velocity.y = 0;
|
||||
alpha -= 0.05;
|
||||
switch (S_DYING_CTR) {
|
||||
case 0:
|
||||
// Get dark, then show dialogue
|
||||
if (times_hurt_player == 0) {
|
||||
times_hurt_player = 1;
|
||||
Achievements.unlock(Achievements.No_damage_sunguy);
|
||||
}
|
||||
if (EventScripts.send_alpha_to(darkness, 1, 0.01)) {
|
||||
if (!DH.scene_is_dirty(DH.name_sun_guy,DH.scene_sun_guy_after_fight)) {
|
||||
DH.start_dialogue(DH.name_sun_guy, DH.scene_sun_guy_after_fight);
|
||||
}
|
||||
}
|
||||
|
||||
// Fade out other objects
|
||||
EventScripts.send_alpha_to(orb_illum_1, 0, -0.01);
|
||||
EventScripts.send_alpha_to(orb_illum_2, 0, -0.01);
|
||||
EventScripts.send_alpha_to(light_orb_1, 0, -0.01);
|
||||
EventScripts.send_alpha_to(light_orb_2, 0, -0.01);
|
||||
EventScripts.send_alpha_to(light_cone_1, 0, -0.02);
|
||||
EventScripts.send_alpha_to(sun_guy_wave, 0, -0.03);
|
||||
|
||||
// When dialogue's finihsed, do the flashes etc.
|
||||
if (DH.scene_is_finished(DH.name_sun_guy,DH.scene_sun_guy_after_fight)) {
|
||||
|
||||
if (!white_overlay.visible) {
|
||||
FlxG.shake(0.01,1);
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
white_overlay.visible = true;
|
||||
}
|
||||
if (EventScripts.send_alpha_to(white_overlay, 0, -0.007)) {
|
||||
FlxG.shake(0.01,1);
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
white_overlay.alpha = 1;
|
||||
frame++;
|
||||
S_DYING_CTR++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (EventScripts.send_alpha_to(white_overlay, 0, -0.007)) {
|
||||
S_DYING_CTR++;
|
||||
frame++;
|
||||
FlxG.shake(0.01,1);
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
white_overlay.alpha = 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (EventScripts.send_alpha_to(white_overlay, 0, -0.007)) {
|
||||
S_DYING_CTR++;
|
||||
frame++;
|
||||
FlxG.shake(0.02,2);
|
||||
Registry.sound_data.sun_guy_death_l.play();
|
||||
white_overlay.alpha = 1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (EventScripts.send_alpha_to(white_overlay, 0, -0.005)) {
|
||||
frame++;
|
||||
S_DYING_CTR++;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
EventScripts.send_alpha_to(darkness, 0.75, -0.005);
|
||||
if (EventScripts.send_property_to(player.light, "base_x_scale", 4, 0.06)) S_DYING_CTR++;
|
||||
EventScripts.send_property_to(player.light, "base_y_scale", 4, 0.06);
|
||||
break;
|
||||
default:
|
||||
STATE = S_DEAD;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Change the XML, global state, so forth...cleanup etc */
|
||||
private function dead_state():void {
|
||||
//One-off
|
||||
if (!INCREMENTED_REGISTRY) {
|
||||
/* if (!Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Bedroom]) {
|
||||
Registry.E_Load_Cutscene = true;
|
||||
Registry.CURRENT_CUTSCENE = Cutscene.Terminal_Gate_Bedroom;
|
||||
}*/
|
||||
darkness.alpha = 0.5;
|
||||
Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx] = true;
|
||||
for (var i:int = 0; i < 3; i++) {
|
||||
dusts.members[i].x = -5000; //HEHHEH
|
||||
}
|
||||
xml.@alive = "false";
|
||||
trace("boss dead");
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
trace("grid enemies dead",Registry.GRID_ENEMIES_DEAD);
|
||||
INCREMENTED_REGISTRY = true;
|
||||
//EventScripts.boss_drop_health_up(x, y);
|
||||
Registry.sound_data.start_song_from_title(Registry.CURRENT_MAP_NAME);
|
||||
exists = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function vertifloat_state():void {
|
||||
var res:Boolean;
|
||||
switch (S_VERTIFLOAT_CTR) {
|
||||
case 0:
|
||||
if (x > base_pt.x) {
|
||||
res = EventScripts.send_property_to(this, "x", base_pt.x, -3);
|
||||
} else {
|
||||
res = EventScripts.send_property_to(this, "x", base_pt.x, 3);
|
||||
}
|
||||
if (res && EventScripts.send_property_to(this, "y", base_pt.y - 30, -0.2)) S_VERTIFLOAT_CTR++;
|
||||
break;
|
||||
case 1:
|
||||
EventScripts.send_property_to(this, "lr_1", 8, -0.5);
|
||||
EventScripts.send_property_to(this, "lr_2", 8, -0.5);
|
||||
EventScripts.send_property_to(this, "rv_1", 0.4, 0.001);
|
||||
EventScripts.send_property_to(this, "rv_2", 0.4, 0.001);
|
||||
move_horizontally();
|
||||
move_vertically();
|
||||
if (FlxG.overlap(player, this) || FlxG.overlap(player, light_orb_1) || FlxG.overlap(player, light_orb_2)) {
|
||||
player.touchDamage(1);
|
||||
times_hurt_player++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
rotate_orbs_about_sun_guy();
|
||||
}
|
||||
private function charge_state():void {
|
||||
//move orbs to guy
|
||||
if (FlxG.overlap(player, this) || FlxG.overlap(player, light_orb_1) || FlxG.overlap(player, light_orb_2)) {
|
||||
player.touchDamage(1);
|
||||
times_hurt_player++;
|
||||
}
|
||||
var res:Boolean;
|
||||
var i:int;
|
||||
switch (S_CHARGE_CTR) {
|
||||
case 0:
|
||||
EventScripts.send_property_to(light_orb_1, "x", x+4, 2);
|
||||
EventScripts.send_property_to(light_orb_1, "y", y+10, 2);
|
||||
EventScripts.send_property_to(this, "x", base_pt.x + 30, 1);
|
||||
EventScripts.send_property_to(light_orb_2, "x", x-4, 2);
|
||||
EventScripts.send_property_to(light_orb_2, "y", y + 10, 2);
|
||||
if (EventScripts.send_property_to(this, "y", base_pt.y - 20, 1)) {
|
||||
S_CHARGE_CTR++;
|
||||
sun_guy_wave.play("play");
|
||||
Registry.sound_data.sun_guy_charge.play();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
sun_guy_wave.visible = true;
|
||||
sun_guy_wave.flicker(3);
|
||||
FlxG.shake(0.02, 0.1);
|
||||
sun_guy_wave.x = base_pt.x - 50;
|
||||
sun_guy_wave.y = base_pt.y - 10;
|
||||
sun_guy_wave.velocity.y = 0;
|
||||
velocity.x = velocity.y = 0;
|
||||
if (FlxG.overlap(sun_guy_wave, player)) { sun_guy_wave.visible = false; player.touchDamage(1); S_CHARGE_CTR = 3;
|
||||
times_hurt_player++; }
|
||||
EventScripts.send_property_to(light_orb_1, "x", base_pt.x - 50, 0.3);
|
||||
if (EventScripts.send_property_to(light_orb_2, "x", base_pt.x + 75, 0.3)) {
|
||||
S_CHARGE_CTR++;
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sun_guy_wave.velocity.y = 30;
|
||||
if (!sun_wave_evaporating) {
|
||||
for (i = 0; i < dusts.length; i++) {
|
||||
if (sun_guy_wave.overlaps(dusts.members[i]) && dusts.members[i].exists) {
|
||||
sun_guy_wave.play("evaporate");
|
||||
sun_wave_evaporating = true;
|
||||
//sun_guy_wave.visible = false;
|
||||
}
|
||||
}
|
||||
move_horizontally();
|
||||
if (sun_guy_wave.visible && FlxG.overlap(sun_guy_wave, player)) {
|
||||
sun_guy_wave.play("evaporate");
|
||||
sun_wave_evaporating = true;
|
||||
player.touchDamage(1);
|
||||
times_hurt_player++;
|
||||
}
|
||||
} else {
|
||||
if (sun_guy_wave._curFrame == sun_guy_wave._curAnim.frames.length -1) {
|
||||
sun_guy_wave.visible = false;
|
||||
sun_wave_evaporating = false;
|
||||
S_CHARGE_CTR = 3;
|
||||
velocity.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (sun_guy_wave.y > 180) {
|
||||
S_CHARGE_CTR = 3;
|
||||
sun_wave_evaporating = false;
|
||||
sun_guy_wave.play("evaporate");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!dusts_poofed) {
|
||||
for (i = 0; i < dusts.length; i++) {
|
||||
dusts.members[i].play("poof");
|
||||
}
|
||||
dusts_poofed = true;
|
||||
} else {
|
||||
if (dusts.members[0]._curFrame == dusts.members[0]._curAnim.frames.length - 1) {
|
||||
STATE = S_VERTIFLOAT;
|
||||
S_CHARGE_CTR = 0;
|
||||
dusts_poofed = false;
|
||||
dusts.setAll("exists", false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
private function rotate_orbs_about_sun_guy():void {
|
||||
center_pt.x = x + 8;
|
||||
center_pt.y = y + 13;
|
||||
|
||||
light_orb_1.x = Math.cos(a_1) * (lr_1) + center_pt.x - 8;
|
||||
light_orb_1.y = Math.sin(a_1) * (lr_1) + center_pt.y;
|
||||
a_1 = (a_1 + rv_1) % 6.28;
|
||||
light_orb_2.x = Math.cos(a_2) * (lr_2) + center_pt.x - 8;
|
||||
light_orb_2.y = Math.sin(a_2) * (lr_2) + center_pt.y;
|
||||
a_2 = (a_2 + rv_2) % 6.28;
|
||||
}
|
||||
|
||||
private function move_horizontally():void {
|
||||
if (HF_1) {
|
||||
|
||||
if (EventScripts.move_to_x(this, 50, base_pt.x + 60)) {
|
||||
HF_1 = false;
|
||||
}
|
||||
} else {
|
||||
if (EventScripts.move_to_x(this, -50, base_pt.x - 50))
|
||||
HF_1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function move_vertically():void {
|
||||
if (VF_1) {
|
||||
if (EventScripts.send_property_to(this, "y", base_pt.y + 80, 1.5)) {
|
||||
VF_1 = false;
|
||||
FlxG.shake(0.05, 0.3);
|
||||
var dust:Dust = dusts.getFirstAvailable() as Dust;
|
||||
if (dust == null) { STATE = S_CHARGE; S_VERTIFLOAT_CTR = 0; return; }
|
||||
dust.exists = true;
|
||||
dust.x = x;
|
||||
dust.y = y;
|
||||
Dust.dust_sound.play();
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.enemy_explode_1_group);
|
||||
dust.play("unpoof");
|
||||
parent.bg_sprites.add(dust);
|
||||
|
||||
}
|
||||
} else {
|
||||
if (EventScripts.send_property_to(this, "y", base_pt.y - 32, -2)) {
|
||||
VF_1 = true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public function hit(type:String, dir:int):int {
|
||||
|
||||
if (just_got_hurt) return -1;
|
||||
if (health <= 0) return -1;
|
||||
//if (STATE == S_VERTIFLOAT) return -1;
|
||||
if (flickering) return -1;
|
||||
just_got_hurt = true;
|
||||
Registry.sound_data.sun_guy_scream.play();
|
||||
flicker(1);
|
||||
|
||||
health--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
override public function destroy():void {
|
||||
DH.a_chunk_just_finished();
|
||||
parent.remove(light_cone_1, true);
|
||||
parent.remove(light_cone_2, true);
|
||||
parent.remove(light_orb_1, true);
|
||||
parent.remove(light_orb_2, true);
|
||||
parent.remove(orb_illum_1, true);
|
||||
parent.remove(sun_guy_wave, true);
|
||||
parent.remove(orb_illum_2, true);
|
||||
light_cone_1 = light_cone_2 = orb_illum_1 = orb_illum_2 = null;
|
||||
light_orb_1 = light_orb_2 = sun_guy_wave = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,297 @@
|
|||
package entity.enemy.circus
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Mechanically the same as a shieldy at first,
|
||||
* but hitting it once splits it into
|
||||
* two balls that bounce about the room. and blood. eeew
|
||||
*/
|
||||
public class Contort extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/contort_small.png")] public static var contort_small_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/contort_big.png")] public static var contort_big_sprite:Class;
|
||||
|
||||
private var BIG_HEALTH:int = 3;
|
||||
private var t_big_hit:Number = 0;
|
||||
private var tm_big_hit:Number = 1.5;
|
||||
private var just_hurt:Boolean = false;
|
||||
private var big_death_timeout:Number = 1.0;
|
||||
|
||||
private var t_small_roll:Number = 0;
|
||||
private var tm_small_roll:Number = 0.8;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_big_roll:int = 0;
|
||||
private var s_big_dying:int = 1;
|
||||
private var s_big_dead:int = 2;
|
||||
private var big_is_h_flipped:Boolean = false;
|
||||
private var big_is_v_flipped:Boolean = false;
|
||||
|
||||
private var VEL:int = 35;
|
||||
|
||||
public var small_sprites:FlxGroup = new FlxGroup(3);
|
||||
|
||||
private var added_to_parent:Boolean = false;
|
||||
private var collide_ctr:int = 0;
|
||||
private var tl:Point = new Point(0, 0);
|
||||
|
||||
private var did_normal:Boolean = false;
|
||||
|
||||
public function Contort(_xml:XML, _player:Player, _parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Add anims for the big sprite */
|
||||
loadGraphic(contort_big_sprite, true, false, 16, 32);
|
||||
height = 12;
|
||||
width = 12;
|
||||
offset.x = 2;
|
||||
offset.y = 20;
|
||||
addAnimation("move", [0, 1, 2, 1], 9);
|
||||
play("move");
|
||||
health = BIG_HEALTH;
|
||||
|
||||
tl.x = Registry.CURRENT_GRID_X * 160;
|
||||
tl.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT;
|
||||
|
||||
for (var i:int = 0; i < small_sprites.maxSize; i++) {
|
||||
var ss:FlxSprite = new FlxSprite();
|
||||
ss.loadGraphic(contort_small_sprite, true, false, 16, 16);
|
||||
//yellow purple blue
|
||||
switch (i) {
|
||||
case 0:
|
||||
ss.addAnimation("move", [0,1], 9, true); //b
|
||||
break;
|
||||
case 1:
|
||||
ss.addAnimation("move", [4,5], 9, true);//p
|
||||
break;
|
||||
case 2: //y
|
||||
ss.addAnimation("move", [2,3], 9, true); //y
|
||||
break;
|
||||
}
|
||||
ss.visible = false;
|
||||
ss.play("move");
|
||||
ss.offset.y = 12 * i;
|
||||
|
||||
ss.my_shadow = EventScripts.make_shadow("8_small", true);
|
||||
ss.parabola_thing = new Parabola_Thing(ss, 16 + 8 * i, 1.2, "offset", "y");
|
||||
ss.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
|
||||
small_sprites.add(ss);
|
||||
parent.bg_sprites.add(ss.my_shadow);
|
||||
}
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
if (collide_ctr == 3) {
|
||||
collide_ctr = 0;
|
||||
FlxG.collide(parent.curMapBuf, this);
|
||||
} else {
|
||||
collide_ctr++;
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
if (!added_to_parent) {
|
||||
if (parent.state == parent.S_NORMAL) {
|
||||
added_to_parent = true;
|
||||
parent.sortables.add(small_sprites);
|
||||
|
||||
velocity.x = Math.random() > 0.5 ? VEL : -VEL;
|
||||
velocity.y = Math.random() > 0.5 ? VEL : -VEL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
big_logic();
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function big_logic():void
|
||||
{
|
||||
|
||||
if (did_normal && parent.state == parent.S_TRANSITION) {
|
||||
velocity.x = velocity.y = 0;
|
||||
small_sprites.setAll("velocity", new FlxPoint(0, 0));
|
||||
//EventScripts.prevent_leaving_map(parent, this);
|
||||
} else {
|
||||
did_normal = true;
|
||||
}
|
||||
|
||||
if (state == s_big_roll) {
|
||||
|
||||
|
||||
if (x < tl.x) {
|
||||
touching = LEFT;
|
||||
|
||||
} else if (x + width > tl.x + 160) {
|
||||
touching = RIGHT;
|
||||
} else if (y < tl.y ) {
|
||||
touching = UP;
|
||||
} else if (y + height > tl.y + 160) {
|
||||
touching = DOWN;
|
||||
}
|
||||
|
||||
//Bounce
|
||||
if (touching != NONE) {
|
||||
if (touching & RIGHT) {
|
||||
velocity.x = -VEL;
|
||||
} else if (touching & LEFT) {
|
||||
velocity.x = VEL;
|
||||
}
|
||||
|
||||
if (touching & UP) {
|
||||
velocity.y = VEL;
|
||||
} else if (touching & DOWN) {
|
||||
velocity.y = -VEL;
|
||||
}
|
||||
|
||||
velocity.x = velocity.x - 10 + 20 * Math.random();
|
||||
velocity.y = velocity.y - 10 + 20 * Math.random();
|
||||
}
|
||||
|
||||
//Hit player
|
||||
if (!player.invincible && player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
//Damage logic
|
||||
if (!just_hurt && player.broom.visible && player.broom.overlaps(this)) {
|
||||
health--;
|
||||
t_big_hit = 0;
|
||||
flicker(tm_big_hit);
|
||||
just_hurt = true;
|
||||
|
||||
} else {
|
||||
if (just_hurt) {
|
||||
t_big_hit += FlxG.elapsed;
|
||||
if (t_big_hit > tm_big_hit) {
|
||||
just_hurt = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (health == 0) {
|
||||
play("release_smalls");
|
||||
state = s_big_dying;
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
} else if (state == s_big_dying) {
|
||||
big_death_timeout -= FlxG.elapsed;
|
||||
if (big_death_timeout < 0) {
|
||||
solid = visible = false;
|
||||
state = s_big_dead;
|
||||
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
/* Init small sprites */
|
||||
small_sprites.setAll("visible", true);
|
||||
small_sprites.setAll("x", x+2);
|
||||
small_sprites.setAll("y", y + 2);
|
||||
for each (var ss:FlxSprite in small_sprites.members) {
|
||||
ss.my_shadow.x = ss.x + 4;
|
||||
ss.my_shadow.y = ss.y + 6;
|
||||
ss.velocity.x = Math.random() > 0.5 ? VEL : -VEL;
|
||||
ss.velocity.y = Math.random() > 0.5 ? VEL : -VEL;
|
||||
ss.velocity.x = ss.velocity.x - 5 + 10 * Math.random();
|
||||
ss.velocity.y = ss.velocity.y - 5 + 10 * Math.random();
|
||||
ss.health = 1;
|
||||
ss.flicker(1);
|
||||
ss.my_shadow.play("get_small");
|
||||
}
|
||||
}
|
||||
} else if (state == s_big_dead) {
|
||||
var sub_ctr:int = 0;
|
||||
for each (var _ss:FlxSprite in small_sprites.members) {
|
||||
if (_ss.parabola_thing.tick()) {
|
||||
_ss.my_shadow.visible = false;
|
||||
}
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, _ss);
|
||||
}
|
||||
_ss.my_shadow.x = _ss.x + 4;
|
||||
_ss.my_shadow.y = _ss.y + 6;
|
||||
FlxG.collide(parent.curMapBuf, _ss);
|
||||
|
||||
if (t_small_roll > tm_small_roll) {
|
||||
_ss.velocity.x = Math.random() > 0.5 ? VEL : -VEL;
|
||||
_ss.velocity.y = Math.random() > 0.5 ? VEL : -VEL;
|
||||
|
||||
_ss.velocity.x = _ss.velocity.x - 5 + 10 * Math.random();
|
||||
_ss.velocity.y = _ss.velocity.y - 5 + 10 * Math.random();
|
||||
}
|
||||
|
||||
|
||||
if (x < tl.x || x + width > tl.x + 160) {
|
||||
velocity.x *= -1;
|
||||
} else if (y < tl.y || y + height > tl.y + 160) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
|
||||
if (_ss.health > 0) {
|
||||
if (!player.invincible && player.overlaps(_ss)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(_ss)) {
|
||||
_ss.health --;
|
||||
_ss.my_shadow.exists = false;
|
||||
EventScripts.drop_small_health(_ss.x, _ss.y, 0.4);
|
||||
EventScripts.make_explosion_and_sound(_ss);
|
||||
}
|
||||
} else {
|
||||
_ss.alpha -= 0.07;
|
||||
if (_ss.alpha == 0) {
|
||||
sub_ctr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t_small_roll > tm_small_roll) {
|
||||
t_small_roll = 0;
|
||||
}
|
||||
t_small_roll += FlxG.elapsed;
|
||||
|
||||
if (sub_ctr == 3) {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
// Keep track of the small guys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(small_sprites, true);
|
||||
small_sprites = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package entity.enemy.circus
|
||||
{
|
||||
import entity.enemy.crowd.Spike_Roller;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import flash.display.InterpolationMethod;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
public class Fire_Pillar extends FlxSprite {
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/fire_pillar.png")] public static var fire_pillar_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/fire_pillar_base.png")] public static var fire_pillar_base_sprite:Class;
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
private var added_to_parent:Boolean = false;
|
||||
|
||||
public var hitbox:FlxSprite = new FlxSprite;
|
||||
public var base:FlxSprite = new FlxSprite;
|
||||
|
||||
private var t:Number = 0;
|
||||
private var tm_idle:Number = 0.74;
|
||||
private var tm_emerge:Number = 0.3;
|
||||
private var tm_flame:Number = 1.0;
|
||||
private var tm_recede:Number = 0.3;
|
||||
|
||||
private var ctr:int = 0;
|
||||
|
||||
public function Fire_Pillar(_xml:XML, _player:Player, _parent:*) {
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
loadGraphic(fire_pillar_sprite, true, false, 16, 32);
|
||||
|
||||
hitbox.makeGraphic(16, 9, 0x00112332);
|
||||
base.loadGraphic(fire_pillar_base_sprite, true, false, 16, 16);
|
||||
base.addAnimation("dormant", [0, 1], 6);
|
||||
base.play("dormant");
|
||||
|
||||
addAnimation("idle", [0], 15);
|
||||
addAnimation("emerge", [1, 2, 3, 4], 8, false);
|
||||
addAnimation("flame", [3, 4], 10);
|
||||
addAnimation("recede", [5, 6, 0], 8, false);
|
||||
play("idle");
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.flame_pillar_group);
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (!added_to_parent) {
|
||||
added_to_parent = true;
|
||||
height = 23;
|
||||
base.x = hitbox.x = x
|
||||
base.y = hitbox.y = y + 16;
|
||||
|
||||
parent.bg_sprites.members.splice(0, 0, base);
|
||||
parent.bg_sprites.length++;
|
||||
}
|
||||
|
||||
for each (var dust:Dust in Registry.subgroup_dust) {
|
||||
if (dust == null) continue;
|
||||
if (dust.visible && dust.overlaps(hitbox)) {
|
||||
ctr = 0;
|
||||
play("idle");
|
||||
}
|
||||
}
|
||||
|
||||
for each (var spike_roller:Spike_Roller in Registry.subgroup_spike_rollers) {
|
||||
if (spike_roller == null) continue;
|
||||
if (spike_roller.visible && spike_roller.overlaps(hitbox)) {
|
||||
ctr = 0;
|
||||
play("idle");
|
||||
}
|
||||
}
|
||||
|
||||
if (ctr == 0) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_idle) {
|
||||
t = 0;
|
||||
ctr++;
|
||||
play("emerge");
|
||||
flicker(.25);
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_emerge) {
|
||||
t = 0;
|
||||
ctr++;
|
||||
play_sfx("shoot");
|
||||
play("flame");
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_flame) {
|
||||
t = 0;
|
||||
ctr++;
|
||||
play("recede");
|
||||
flicker(.25)
|
||||
}
|
||||
if (player.overlaps(hitbox)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_recede) {
|
||||
t = 0;
|
||||
ctr = 0;
|
||||
play("idle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,543 @@
|
|||
package entity.enemy.circus
|
||||
{
|
||||
import data.Common_Sprites;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Lion extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/lion.png")] public static var lion_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/circus/lion_fireballs.png")] public static var lion_fireball_sprite:Class;
|
||||
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
private var max_health:int = 4;
|
||||
private var is_hurt:Boolean = false;
|
||||
|
||||
private var hori_hitbox:FlxSprite = new FlxSprite;
|
||||
private var H_OFF_X:int = 3;
|
||||
private var H_OFF_Y:int = 11;
|
||||
private var vert_hitbox:FlxSprite = new FlxSprite;
|
||||
private var V_OFF_X:int = 10;
|
||||
private var V_OFF_Y:int = 4;
|
||||
private var hitbox:FlxSprite;
|
||||
|
||||
private var state:int = 0;
|
||||
private var state_pace:int = 0;
|
||||
private var t_pace:Number = 0;
|
||||
private var tm_pace:Number = 0.8;
|
||||
private var vel_pace:Number = 43;
|
||||
private var ctr_pace:int = 0;
|
||||
|
||||
private var state_shoot:int = 1;
|
||||
private var fireballs:FlxGroup = new FlxGroup(10);
|
||||
private var vel_fireball:int = 88;
|
||||
private var max_fireball_x_distance:int = 80;
|
||||
private var ctr_shoot:int = 0;
|
||||
private var t_shoot:Number = 0;
|
||||
private var tm_shoot:Number = 0.165;
|
||||
private var tm_shoot_warning:Number = 0.8;
|
||||
private var ctr_shots:int = 0;
|
||||
private var max_shots:int = 18;
|
||||
|
||||
private var state_charge:int = 2;
|
||||
private var ctr_charge:int = 0;
|
||||
private var vel_charge:int = 110;
|
||||
private var t_charge:Number = 0;
|
||||
private var h_shadow:FlxSprite = new FlxSprite;
|
||||
private var v_shadow:FlxSprite = new FlxSprite;
|
||||
|
||||
|
||||
private var state_dying:int = 3;
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
public function Lion(_xml:XML, _player:Player, _parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
health = max_health;
|
||||
solid = false;
|
||||
|
||||
loadGraphic(lion_sprite, true, false, 32, 32);
|
||||
addAnimation("walk_l", [0, 1], 5);
|
||||
addAnimation("walk_r", [0, 1], 5);
|
||||
addAnimation("walk_d", [10,11], 5);
|
||||
addAnimation("walk_u", [5,6], 5);
|
||||
|
||||
addAnimation("warn_l", [3], 5, true);
|
||||
addAnimation("warn_r", [3], 5, true);
|
||||
|
||||
addAnimation("shoot_l", [2], 15, true);
|
||||
addAnimation("shoot_r", [2], 15, true);
|
||||
addAnimation("shoot_d", [12], 15, true);
|
||||
addAnimation("shoot_u", [7], 15, true);
|
||||
|
||||
addAnimation("pounce_r", [4]);
|
||||
addAnimation("pounce_l", [4]);
|
||||
addAnimation("pounce_u", [9]);
|
||||
addAnimation("pounce_d", [14]);
|
||||
|
||||
play("walk_r");
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.fireball_group);
|
||||
|
||||
/* Make shadows */
|
||||
h_shadow.loadGraphic(Common_Sprites.shadow_sprite_28_10, true, false, 28, 10);
|
||||
v_shadow.loadGraphic(Common_Sprites.shadow_sprite_28_10, true, false, 28, 10);
|
||||
v_shadow.visible = h_shadow.visible = false;
|
||||
h_shadow.frame = v_shadow.frame = 4;
|
||||
h_shadow.offset.x = -2; h_shadow.offset.y = -24;
|
||||
v_shadow.offset.y = -12;
|
||||
v_shadow.scale.x = 0.5; v_shadow.scale.y = 2; // Remove when you add teha ctual shadows
|
||||
|
||||
parabola_thing = new Parabola_Thing(this, 12, 1.0, "offset", "y");
|
||||
|
||||
hori_hitbox.makeGraphic(26, 13, 0x00ff0000);
|
||||
vert_hitbox.makeGraphic(10, 20, 0x0000ff00);
|
||||
hitbox = hori_hitbox;
|
||||
hitbox.velocity.x = vel_pace;
|
||||
|
||||
for (var i:int = 0; i < fireballs.maxSize; i++) {
|
||||
var fireball:FlxSprite = new FlxSprite;
|
||||
|
||||
fireball.loadGraphic(lion_fireball_sprite, true, false, 16, 16);
|
||||
fireball.width = fireball.height = 8;
|
||||
fireball.centerOffsets(true);
|
||||
|
||||
fireball.addAnimation("shoot", [0, 1], 10);
|
||||
fireball.addAnimation("poof", [2,3,4,5], 10,false);
|
||||
fireball.play("shoot");
|
||||
fireball.alive = fireball.exists = false;
|
||||
fireballs.add(fireball);
|
||||
}
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
state = state_pace;
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (parent.state == parent.S_TRANSITION) {
|
||||
hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
return;
|
||||
}
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
center_hitboxes();
|
||||
parent.fg_sprites.add(vert_hitbox);
|
||||
parent.fg_sprites.add(hori_hitbox);
|
||||
parent.fg_sprites.add(fireballs);
|
||||
parent.bg_sprites.add(v_shadow);
|
||||
parent.bg_sprites.add(h_shadow);
|
||||
}
|
||||
|
||||
//Graphic pinned to hitbox (hitbox moves)
|
||||
if (hitbox == vert_hitbox) {
|
||||
x = hitbox.x - V_OFF_X;
|
||||
y = hitbox.y - V_OFF_Y;
|
||||
} else if (hitbox == hori_hitbox) {
|
||||
x = hitbox.x - H_OFF_X;
|
||||
y = hitbox.y - H_OFF_Y;
|
||||
}
|
||||
|
||||
//Stop moving if touchign solid tile
|
||||
FlxG.collide(hitbox, parent.curMapBuf);
|
||||
|
||||
if (hitbox.touching != NONE) {
|
||||
hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
}
|
||||
|
||||
//hurt player
|
||||
if (!player.invincible && player.overlaps(hitbox)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
// Get hurt
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(hitbox)) {
|
||||
flicker(1);
|
||||
is_hurt = true;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
health--;
|
||||
if (health <= 0) {
|
||||
state = state_dying;
|
||||
}
|
||||
} else {
|
||||
is_hurt = false;
|
||||
}
|
||||
|
||||
if (state == state_pace) {
|
||||
pace_state();
|
||||
} else if (state == state_shoot) {
|
||||
shoot_state();
|
||||
} else if (state == state_charge) {
|
||||
charge_state();
|
||||
} else if (state == state_dying) {
|
||||
alpha -= 0.05;
|
||||
if (alpha == 0) {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
exists = false;
|
||||
v_shadow.exists = h_shadow.exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function on_anim_change(name:String, frame_nr:uint, frame_index:uint):void {
|
||||
if (name == "walk_l" || name == "shoot_l" || name == "warn_l" || name == "pounce_l") {
|
||||
facing = LEFT;
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
if (name == "walk_r" || name == "shoot_r") {
|
||||
facing = RIGHT;
|
||||
} else if (name == "walk_u" || name == "shoot_u") {
|
||||
facing = UP;
|
||||
} else if (name == "walk_d" || name == "shoot_d") {
|
||||
facing = DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function center_hitboxes():void
|
||||
{
|
||||
hori_hitbox.x = x + H_OFF_X;
|
||||
hori_hitbox.y = y + H_OFF_Y;
|
||||
vert_hitbox.x = x + V_OFF_X;
|
||||
vert_hitbox.y = y + V_OFF_Y;
|
||||
}
|
||||
|
||||
private function pace_state():void
|
||||
{
|
||||
t_pace += FlxG.elapsed;
|
||||
if (t_pace > tm_pace) {
|
||||
t_pace = 0;
|
||||
ctr_pace = int(6 * Math.random());
|
||||
var r:Number = Math.random();
|
||||
if (r < 0.25) {
|
||||
state = state_shoot;
|
||||
if (player.x > x + 16) {
|
||||
play("warn_r");
|
||||
} else {
|
||||
play("warn_l");
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (r < 0.55) {
|
||||
state = state_charge;
|
||||
return;
|
||||
}
|
||||
switch (ctr_pace) {
|
||||
case 0:
|
||||
hitbox = hori_hitbox;
|
||||
hitbox.velocity.x = vel_pace;
|
||||
hitbox.velocity.y = 0;
|
||||
center_hitboxes();
|
||||
play("walk_r");
|
||||
break;
|
||||
case 1:
|
||||
hitbox = vert_hitbox;
|
||||
hitbox.velocity.x = 0;
|
||||
hitbox.velocity.y = vel_pace;
|
||||
play("walk_d");
|
||||
center_hitboxes();
|
||||
break;
|
||||
case 2:
|
||||
hitbox = hori_hitbox;
|
||||
hitbox.velocity.y = 0;
|
||||
hitbox.velocity.x = -vel_pace;
|
||||
play("walk_l");
|
||||
center_hitboxes();
|
||||
break;
|
||||
case 3:
|
||||
hitbox = vert_hitbox;
|
||||
hitbox.velocity.x = 0;
|
||||
hitbox.velocity.y = -vel_pace;
|
||||
play("walk_u");
|
||||
center_hitboxes();
|
||||
break;
|
||||
default:
|
||||
//hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function shoot_state():void
|
||||
{
|
||||
hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
|
||||
var fireball:FlxSprite;
|
||||
|
||||
if (ctr_shoot == 0) {
|
||||
t_shoot += FlxG.elapsed;
|
||||
if (t_shoot <= tm_shoot_warning) {
|
||||
return;
|
||||
} else {
|
||||
t_shoot = 0;
|
||||
ctr_shoot++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Periodically shoot a fireball
|
||||
t_shoot += FlxG.elapsed;
|
||||
if (t_shoot > tm_shoot) {
|
||||
t_shoot = 0;
|
||||
if (ctr_shots < max_shots && fireballs.countDead() > 0) {
|
||||
fireball = fireballs.getFirstDead() as FlxSprite;
|
||||
if (fireball != null) {
|
||||
ctr_shots++;
|
||||
play_sfx("shoot");
|
||||
face_player();
|
||||
switch (facing) {
|
||||
case UP:
|
||||
fireball.x = x + width / 2;
|
||||
fireball.y = y - 2;
|
||||
EventScripts.scale_vector(getMidpoint(), new Point(x + 32*Math.random(), y - 32), fireball.velocity, vel_fireball);
|
||||
break;
|
||||
case DOWN:
|
||||
fireball.x = x + width / 2;
|
||||
fireball.y = y + height + 2;
|
||||
EventScripts.scale_vector(getMidpoint(), new Point(x + 32*Math.random(), y + 32), fireball.velocity, vel_fireball);
|
||||
break;
|
||||
case RIGHT:
|
||||
fireball.x = x + width;
|
||||
fireball.y = y + 6;
|
||||
EventScripts.scale_vector(new Point(x + width, y + 6), new Point(x + 80, y - 26 + 52*Math.random()), fireball.velocity, vel_fireball);
|
||||
break;
|
||||
case LEFT:
|
||||
fireball.x = x;
|
||||
fireball.y = y + 6;
|
||||
EventScripts.scale_vector(new Point(x, y + 6), new Point(x - 30, y - 26 + 52*Math.random()), fireball.velocity, vel_fireball);
|
||||
break;
|
||||
}
|
||||
fireball.exists = fireball.alive = true;
|
||||
fireball.finished = false;
|
||||
fireball.play("shoot");
|
||||
}
|
||||
} else {
|
||||
ctr_shots = 0;
|
||||
state = state_pace;
|
||||
}
|
||||
}
|
||||
// Fireballs hit player and map
|
||||
for each (fireball in fireballs.members) {
|
||||
|
||||
if (fireball._curAnim != null && fireball._curAnim.name != "poof") {
|
||||
for each (var dust:Dust in Registry.subgroup_dust) {
|
||||
if (dust != null) {
|
||||
if (dust.visible && dust.overlaps(fireball)) {
|
||||
fireball.play("poof"); fireball.finished = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fireball.alive) {
|
||||
if (!player.invincible && player.overlaps(fireball)) {
|
||||
player.touchDamage(1);
|
||||
fireball.play("poof"); fireball.finished = false;
|
||||
//fireball.alive = false;
|
||||
}
|
||||
if (player.broom.visible && player.broom.overlaps(fireball)) {
|
||||
fireball.play("poof"); fireball.finished = false;
|
||||
//fireball.alive = false;
|
||||
}
|
||||
}
|
||||
if (Math.abs(fireball.x - x) > max_fireball_x_distance) {
|
||||
//fireball.alive = fireball.exists = false;
|
||||
|
||||
fireball.play("poof"); fireball.finished = false;
|
||||
} else if (Math.abs(fireball.y - y) > max_fireball_x_distance) {
|
||||
//fireball.alive = fireball.exists = false;
|
||||
fireball.play("poof"); fireball.finished = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (fireball.finished && fireball._curAnim != null && fireball._curAnim.name == "poof" ) {
|
||||
fireball.exists = fireball.alive = false;
|
||||
fireball.play("shoot");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If hurt then go back to charge
|
||||
if (is_hurt) {
|
||||
ctr_shots = max_shots;
|
||||
}
|
||||
}
|
||||
|
||||
private function charge_state():void
|
||||
{
|
||||
if (ctr_charge == 0) { // Walk away forom the player
|
||||
hitbox = hori_hitbox;
|
||||
center_hitboxes();
|
||||
hitbox.velocity.x = 20;
|
||||
hitbox.velocity.y = 0;
|
||||
if (player.x > x) {
|
||||
hitbox.velocity.x *= -1;
|
||||
play("walk_l");
|
||||
} else {
|
||||
play("walk_r");
|
||||
}
|
||||
ctr_charge++;
|
||||
} else if (ctr_charge == 1) { // Face the player
|
||||
t_charge += FlxG.elapsed;
|
||||
if (t_charge > 1.4) {
|
||||
hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
if (_curAnim.name == "walk_r") {
|
||||
hitbox.velocity.x = -10;
|
||||
play("warn_l");
|
||||
} else {
|
||||
hitbox.velocity.x = 10;
|
||||
play("warn_r");
|
||||
}
|
||||
t_charge = 0;
|
||||
ctr_charge++;
|
||||
|
||||
}
|
||||
} else if (ctr_charge == 2) { //pause a little
|
||||
t_charge += FlxG.elapsed;
|
||||
if (t_charge > 0.6) {
|
||||
t_charge = 0;
|
||||
ctr_charge++;
|
||||
}
|
||||
} else if (ctr_charge == 3) { //dash to theplayer
|
||||
EventScripts.scale_vector(new Point(x, y), new Point(player.x, player.y), hitbox.velocity, vel_charge);
|
||||
ctr_charge++;
|
||||
scale.x = 1;
|
||||
switch (EventScripts.get_entity_to_entity_dir(x, y, player.x, player.y)) {
|
||||
case UP:
|
||||
v_shadow.visible = true;
|
||||
play("pounce_u");
|
||||
break;
|
||||
case DOWN:
|
||||
v_shadow.visible = true;
|
||||
play("pounce_d");
|
||||
break;
|
||||
case LEFT:
|
||||
h_shadow.visible = true;
|
||||
play("pounce_l");
|
||||
break;
|
||||
case RIGHT:
|
||||
h_shadow.visible = true;
|
||||
play("pounce_r");
|
||||
break;
|
||||
}
|
||||
if (v_shadow.visible) {
|
||||
v_shadow.x = x;
|
||||
v_shadow.y = y;
|
||||
} else {
|
||||
h_shadow.x = x;
|
||||
h_shadow.y = y;
|
||||
}
|
||||
|
||||
} else if (ctr_charge == 4) { //Check the graphic against tilemap to avoid weird graphics steppingoutside the bounds
|
||||
solid = true;
|
||||
|
||||
if (v_shadow.visible) {
|
||||
v_shadow.x = x;
|
||||
v_shadow.y = y;
|
||||
} else {
|
||||
h_shadow.x = x;
|
||||
h_shadow.y = y;
|
||||
}
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
if (parabola_thing.tick() || (touching != NONE && offset.y > 4)) {
|
||||
offset.y = 0;
|
||||
parabola_thing.reset_time();
|
||||
h_shadow.visible = v_shadow.visible = false;
|
||||
hitbox.velocity.x = hitbox.velocity.y = 0;
|
||||
ctr_charge = 0;
|
||||
if (_curAnim.name == "pounce_l") {
|
||||
play("walk_l");
|
||||
} else if (_curAnim.name == "pounce_r") {
|
||||
play("walk_r");
|
||||
} else if (_curAnim.name == "pounce_d") {
|
||||
play("walk_d");
|
||||
} else {
|
||||
play("walk_u");
|
||||
|
||||
}
|
||||
state = state_pace;
|
||||
}
|
||||
solid = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get dy/dx and the slope to figure out which way to face */
|
||||
private function face_player():void {
|
||||
var midpoint:FlxPoint = getMidpoint();
|
||||
var dy:Number = midpoint.y - player.midpoint.y;
|
||||
var dx:Number = midpoint.x - player.midpoint.x;
|
||||
var eps:Number = 0.0001;
|
||||
(Math.abs(dx) < eps) ? (dx < 0 ? dx = -0.1 : dx = 0.1) : 1;
|
||||
var m:Number = Math.abs(dy / dx);
|
||||
if (m > 1) {
|
||||
if (dy > 0) {
|
||||
if (state == state_shoot) {
|
||||
play("shoot_u");
|
||||
} else {
|
||||
play("walk_u")
|
||||
}
|
||||
} else {
|
||||
if (state == state_shoot) {
|
||||
play("shoot_d");
|
||||
} else {
|
||||
play ("walk_d");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (dx > 0) {
|
||||
if (state == state_shoot) {
|
||||
play("shoot_l");
|
||||
} else {
|
||||
play("walk_l");
|
||||
}
|
||||
} else {
|
||||
if (state == state_shoot) {
|
||||
play("shoot_r");
|
||||
} else {
|
||||
play("walk_r");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
fireballs = null;
|
||||
h_shadow = null;
|
||||
hori_hitbox = null;
|
||||
hitbox = null;
|
||||
v_shadow = null;
|
||||
vert_hitbox = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,277 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import entity.gadget.Gate;
|
||||
import entity.gadget.Switch_Pillar;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxRect;
|
||||
import org.flixel.FlxSprite;
|
||||
import entity.player.Player;
|
||||
import data.CLASS_ID;
|
||||
import org.flixel.FlxTilemap;
|
||||
|
||||
public class Dog extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.DOG;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
//dame props - alive (false or true), p (1)
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/dog.png")] public static var dog_sprite:Class;
|
||||
|
||||
|
||||
private var timer:Number = 0;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_pace:int = 0;
|
||||
private var pace_vel:int = 20;
|
||||
private var pace_timer_max:Number = 1.0;
|
||||
|
||||
private var s_alert:int = 1;
|
||||
private var alert_timer_max:Number = 1.0;
|
||||
private var s_attack:int = 2;
|
||||
private var attack_pts:Array = new Array(new Point(), new Point(), new Point(), new Point(), new Point());
|
||||
private var vel_base_attack:Number = 60;
|
||||
private var attack_speeds:Array = new Array(1.1, 1.4, 1.4, 1.6, 1.7);
|
||||
private var attack_timer_max:Number = 1.0; //latency before dog "gives up" going to a pt
|
||||
|
||||
private var s_attack_phase:int = 0;
|
||||
private var s_dead:int = 3;
|
||||
|
||||
private var Dead_Frame:int = 7;
|
||||
|
||||
private var hit_timer_max:Number = 1.5;
|
||||
private var hit_timer:Number = 0;
|
||||
|
||||
private var active_region:FlxObject = new FlxObject(0, 0, 96, 96);
|
||||
|
||||
private var type:int = 0;
|
||||
private var T_NORMAL:int = 0;
|
||||
private var T_SUPER:int = 1;
|
||||
|
||||
public function Dog(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* DOG ANIMATIONS*/
|
||||
loadGraphic(dog_sprite, true, false, 16, 16);
|
||||
width = height = 12;
|
||||
offset.y = offset.x = 2;
|
||||
drag.x = 20;
|
||||
|
||||
addAnimation("stop_d", [0]);
|
||||
/* walk_l is walk_r reflected */
|
||||
addAnimation("walk_l", [2, 3], 4, true);
|
||||
addAnimation("walk_r", [2, 3], 4, true);
|
||||
addAnimation("alert", [4, 5], 5);
|
||||
/* attack_l is attack_r reflected */
|
||||
addAnimation("attack_r", [6, 7],6,true);
|
||||
addAnimation("attack_l", [6, 7 ],6,true);
|
||||
addAnimation("die", [1, 2, 3, 4, 4, 3, 1, 3, 2, 1,7], 15, false);
|
||||
|
||||
addAnimationCallback(set_scale);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
|
||||
if (parseInt(xml.@type) == T_SUPER) {
|
||||
type = T_SUPER;
|
||||
health = 3;
|
||||
} else {
|
||||
health = 3;
|
||||
type = T_NORMAL;
|
||||
}
|
||||
|
||||
add_sfx("bark", Registry.sound_data.dog_bark_group);
|
||||
add_sfx("dash", Registry.sound_data.dog_dash);
|
||||
}
|
||||
override public function preUpdate():void
|
||||
{
|
||||
FlxG.collide(parent.curMapBuf, this);
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
}
|
||||
}
|
||||
|
||||
for each (var sp:Switch_Pillar in Registry.subgroup_switch_pillars) {
|
||||
if (sp != null && (sp.frame == sp.up_frame)) {
|
||||
FlxG.collide(sp, this);
|
||||
}
|
||||
}
|
||||
if (player.state != player.S_AIR && player.overlaps(this) && (xml.@alive != "false")) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
for each (var g:Gate in Registry.subgroup_gates) {
|
||||
if (g != null) {
|
||||
if (g.overlaps(this)) {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* pin active region to self */
|
||||
active_region.x = x - 40;
|
||||
active_region.y = y - 40;
|
||||
if (hit_timer < hit_timer_max) {
|
||||
hit_timer += FlxG.elapsed;
|
||||
}
|
||||
|
||||
/* die if health too low */
|
||||
if (health <= 0 && state != s_dead) {
|
||||
state = s_dead;
|
||||
} else if (state != s_dead) {
|
||||
if (hit_timer >= hit_timer_max) {
|
||||
if (player.broom.overlaps(this) && player.broom.visible) {
|
||||
hit_timer = 0;
|
||||
health--;
|
||||
flicker(hit_timer_max);
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* pace and wait for player to get near */
|
||||
if (state == s_pace) {
|
||||
timer += FlxG.elapsed;
|
||||
if (timer > pace_timer_max) {
|
||||
if (FlxG.random() > 0.33) {
|
||||
play("walk_r");
|
||||
velocity.x = pace_vel;
|
||||
} else {
|
||||
if (FlxG.random() > 0.5) {
|
||||
play("walk_l");
|
||||
velocity.x = -pace_vel;
|
||||
} else {
|
||||
play("stop_d");
|
||||
velocity.x = 0;
|
||||
}
|
||||
}
|
||||
timer = 0;
|
||||
}
|
||||
if (active_region.overlaps(player)) {
|
||||
state = s_alert;
|
||||
velocity.x = velocity.y = 0;
|
||||
play("alert");
|
||||
play_sfx("bark");
|
||||
timer = 0;
|
||||
}
|
||||
/* set points for dash attack */
|
||||
} else if (state == s_alert) {
|
||||
timer += FlxG.elapsed;
|
||||
if (timer > alert_timer_max) {
|
||||
state = s_attack;
|
||||
timer = 0;
|
||||
velocity.y = 30;
|
||||
/* Set up points for dog to dash to */
|
||||
attack_pts[0].x = player.x - 50 + 12 * Math.random(); // LEFT
|
||||
attack_pts[0].y = player.y - 8;
|
||||
|
||||
attack_pts[1].x = player.x + 30 + 12 * Math.random();
|
||||
attack_pts[1].y = player.y - 8; // right
|
||||
|
||||
attack_pts[2].x = player.x - 50 + 12*Math.random();
|
||||
attack_pts[2].y = player.y - 8; // DOWN
|
||||
|
||||
EventScripts.scale_vector(new Point(x, y), attack_pts[0], velocity, vel_base_attack * attack_speeds[0]);
|
||||
|
||||
|
||||
if (velocity.x > 0) {
|
||||
play("attack_r");
|
||||
} else {
|
||||
play("attack_l");
|
||||
}
|
||||
}
|
||||
/* dash to points and then reset */
|
||||
} else if (state == s_attack) {
|
||||
var p_done:int = 0;
|
||||
|
||||
timer += FlxG.elapsed;
|
||||
if (timer > attack_timer_max) {
|
||||
velocity.x = velocity.y = 0;
|
||||
timer = 0;
|
||||
p_done = 2;
|
||||
s_attack_phase++;
|
||||
|
||||
}
|
||||
/* When the dash timer runs out*/
|
||||
if (p_done == 2) {
|
||||
|
||||
/* If SUPER dog,dynamically determine dash points */
|
||||
if (s_attack_phase <= 4 && type == T_SUPER) {
|
||||
if (player.x > x) {
|
||||
attack_pts[s_attack_phase].x = player.x + 25;// RIGHT
|
||||
attack_pts[s_attack_phase].y = player.y + 8;
|
||||
} else {
|
||||
attack_pts[s_attack_phase].x = player.x - 28; // LEFT
|
||||
attack_pts[s_attack_phase].y = player.y - 8;
|
||||
}
|
||||
}
|
||||
/* change the velocity if the dog doesn't need to stop */
|
||||
if (s_attack_phase < 5) {
|
||||
EventScripts.scale_vector(new Point(x, y), attack_pts[s_attack_phase], velocity, vel_base_attack * attack_speeds[s_attack_phase]);
|
||||
}
|
||||
/* Set the correct attacking anim*/
|
||||
if (velocity.x > 0) {
|
||||
play("attack_r");
|
||||
} else {
|
||||
play("attack_l");
|
||||
}
|
||||
|
||||
/* State change */
|
||||
if (type == T_NORMAL && s_attack_phase > 2) {
|
||||
state = s_pace;
|
||||
velocity.x = velocity.y = 0;
|
||||
play("walk_r");
|
||||
s_attack_phase = 0;
|
||||
} else if (s_attack_phase > 4) {
|
||||
state = s_pace;
|
||||
s_attack_phase = 0;
|
||||
} else {
|
||||
|
||||
play_sfx("dash");
|
||||
}
|
||||
}
|
||||
} else if (state == s_dead) {
|
||||
// if (frame == Dead_Frame) {
|
||||
xml.@alive = "false";
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.drop_small_health(x, y, 1.0);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
//play die sound effect
|
||||
exists = false; // :(
|
||||
//}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function set_scale(name:String,frame_nr:uint,frame_idx:uint):void {
|
||||
if (name == "walk_l" || name == "stop_l") {
|
||||
scale.x = -1;
|
||||
} else if (name == "attack_l") {
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import data.Common_Sprites;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxBasic;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import entity.player.Player;
|
||||
import data.CLASS_ID;
|
||||
public class Frog extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.FROG;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/frog.png")] public static var frog_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/frog_bullet.png")] public var frog_bullet_sprite:Class;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_face_player:int = 0;
|
||||
private var s_shoot:int = 1;
|
||||
private var s_dying:int = 2;
|
||||
private var s_dead:int = 3;
|
||||
private var has_shot:Boolean = false
|
||||
private var did_shoot_anim:Boolean = false
|
||||
private var added_to_parent:Boolean = false;
|
||||
|
||||
public var y_bullets:FlxGroup = new FlxGroup();
|
||||
public var BULLET_EMPTY_FRAME:int = 3;
|
||||
|
||||
private var dame_frame:int;
|
||||
private var hit_timer:Number = 0;
|
||||
private var hit_timer_max:Number = 1.0;
|
||||
|
||||
private var init_latency:Number = 0.8;
|
||||
|
||||
|
||||
//dame - p (1), alive , frame (attk type)
|
||||
public function Frog(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Frog animations */
|
||||
loadGraphic(frog_sprite, true, false, 16, 16);
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
addAnimation("idle_d", [6,7], 2, true);
|
||||
addAnimation("shoot_d", [8], 3, false);
|
||||
addAnimation("shoot_r", [8], 3, false); // DEFAULT: R
|
||||
addAnimation("shoot_l", [8], 3, false);
|
||||
addAnimation("shoot_u", [8], 3, false);
|
||||
} else {
|
||||
addAnimation("idle_d", [0, 1], 2, true);
|
||||
addAnimation("shoot_d", [3], 3, false);
|
||||
addAnimation("shoot_r", [4], 3, false); // DEFAULT: R
|
||||
addAnimation("shoot_l", [4], 3, false);
|
||||
addAnimation("shoot_u", [5], 3, false);
|
||||
}
|
||||
play("idle_d");
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.bubble_triple_group);
|
||||
add_sfx("pop", Registry.sound_data.bubble_group);
|
||||
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
immovable = true;
|
||||
health = 2;
|
||||
|
||||
for (var i:int = 0; i < 3; i++) {
|
||||
var b:FlxSprite = new FlxSprite;
|
||||
// TODO: add bullet gfx, test frog placeholders
|
||||
b.loadGraphic(frog_bullet_sprite, true, false, 8, 8);
|
||||
b.exists = false;
|
||||
/* Add bullet shadow anims, of which there are none */
|
||||
b.my_shadow = EventScripts.make_shadow("8_small",true);
|
||||
b.my_shadow.play("get_big");
|
||||
|
||||
|
||||
/* Add bullet animations */
|
||||
if (Registry.BOI && Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
b.addAnimation("bullet_move", [4,5], 12);
|
||||
b.addAnimation("bullet_explode", [2, 3, 3], 8, false);
|
||||
} else {
|
||||
b.addAnimation("bullet_move", [0, 1], 12);
|
||||
b.addAnimation("bullet_explode", [2, 3, 3], 8, false);
|
||||
}
|
||||
BULLET_EMPTY_FRAME = 3;
|
||||
b.play("bullet_move");
|
||||
|
||||
y_bullets.add(b);
|
||||
var p:Parabola_Thing = new Parabola_Thing(b, 16,0.8 + Math.random(), "offset", "y");
|
||||
if (dame_frame == 2) {
|
||||
b.velocity.y = 15 * (i + 1);
|
||||
} else {
|
||||
b.velocity.x = -15 * (i + 1);
|
||||
}
|
||||
b.parabola_thing = p;
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
}
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function on_anim_change(name:String, frame:int, index:int):void {
|
||||
if (name == "shoot_l") {
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (init_latency > 0) {
|
||||
init_latency -= FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.overlaps(this) && visible && player.state != player.S_AIR) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (health <= 0 && state != s_dead) {
|
||||
state = s_dying;
|
||||
}
|
||||
var b:FlxSprite;
|
||||
if (!added_to_parent) {
|
||||
added_to_parent = true;
|
||||
//get draw order right later
|
||||
for each (b in y_bullets.members) {
|
||||
if (b == null) continue;
|
||||
parent.bg_sprites.add(b.my_shadow)
|
||||
parent.fg_sprites.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
hit_timer -= FlxG.elapsed;
|
||||
if (player.broom.overlaps(this) && player.broom.visible) {
|
||||
if (hit_timer <= 0) {
|
||||
flicker(hit_timer_max);
|
||||
hit_timer = hit_timer_max;
|
||||
health--;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
if (state == s_face_player) {
|
||||
|
||||
var dx:int = player.x - x;
|
||||
var dy:int = player.y - y;
|
||||
|
||||
if (dx > 0) {
|
||||
if (Math.abs(dy) < dx) {
|
||||
facing = RIGHT;
|
||||
} else if (dy > 0) {
|
||||
facing = DOWN;
|
||||
} else {
|
||||
facing = UP;
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(dy) < Math.abs(dx)) {
|
||||
facing = LEFT;
|
||||
} else if (dy > 0) {
|
||||
facing = DOWN;
|
||||
} else {
|
||||
facing = UP;
|
||||
}
|
||||
}
|
||||
|
||||
if (EventScripts.distance(player, this) < 64) {
|
||||
state = s_shoot;
|
||||
|
||||
}
|
||||
} else if (state == s_shoot) {
|
||||
if (!did_shoot_anim) {
|
||||
|
||||
if (facing == DOWN) {
|
||||
play("shoot_d");
|
||||
} else if (facing == LEFT) {
|
||||
play("shoot_l");
|
||||
} else if (facing == RIGHT) {
|
||||
play("shoot_r");
|
||||
} else {
|
||||
play("shoot_u");
|
||||
}
|
||||
did_shoot_anim = true;
|
||||
|
||||
for each (b in y_bullets.members) {
|
||||
if (b == null) continue;
|
||||
b.my_shadow.play("get_small");
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
b.parabola_thing.reset_time();
|
||||
b.velocity = EventScripts.scale_vector(this, player, b.velocity, 15 * (y_bullets.members.indexOf(b) + 1)) as FlxPoint;
|
||||
b.exists = b.visible = true;
|
||||
b.my_shadow.exists = true;
|
||||
b.x = b.my_shadow.x = x;
|
||||
b.y = b.my_shadow.y = y;
|
||||
b.play("bullet_move");
|
||||
}
|
||||
|
||||
play_sfx("shoot");
|
||||
} else {
|
||||
var nr_done:int = 0;
|
||||
|
||||
for each (b in y_bullets.members) {
|
||||
if (b == null) continue;
|
||||
if (!b.exists) {
|
||||
nr_done++;
|
||||
continue;
|
||||
}
|
||||
// Move until touches player...
|
||||
if (!b.parabola_thing.tick()) {
|
||||
|
||||
b.my_shadow.y = b.y;
|
||||
b.my_shadow.x = b.x;
|
||||
if (b.offset.y < 8) {
|
||||
if (player.overlaps(b)) {
|
||||
player.touchDamage(1);
|
||||
b.play("bullet_explode");
|
||||
}
|
||||
}
|
||||
//...or hits ground.
|
||||
} else {
|
||||
// First time it hits ground, play pop sound.
|
||||
if (b.velocity.x != 0 && b.velocity.y != 0) {
|
||||
play_sfx("pop");
|
||||
}
|
||||
b.play("bullet_explode");
|
||||
b.velocity.x = b.velocity.y = 0;
|
||||
if (b.frame == BULLET_EMPTY_FRAME) {
|
||||
b.offset.y = 0;
|
||||
b.my_shadow.exists = false;
|
||||
b.exists = b.visible = false;
|
||||
nr_done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nr_done == 3) {
|
||||
state = s_face_player;
|
||||
did_shoot_anim = false;
|
||||
play("idle_d");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else if (state == s_dying) {
|
||||
//play("die");
|
||||
//sfx
|
||||
//do the below once
|
||||
trace("dead!");
|
||||
state = s_dead;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.drop_small_health(x, y, 0.7);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
xml.@alive = "false";
|
||||
solid = false;
|
||||
visible = false;
|
||||
} else if (state == s_dead) {
|
||||
for each (b in y_bullets.members) {
|
||||
if (b == null) continue;
|
||||
if (!b.parabola_thing.tick()) {
|
||||
|
||||
b.my_shadow.y = b.y;
|
||||
b.my_shadow.x = b.x;
|
||||
if (b.offset.y < 8) {
|
||||
if (player.overlaps(b)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
b.play("bullet_explode");
|
||||
b.my_shadow.exists = false;
|
||||
|
||||
b.velocity.x = b.velocity.y = 0;
|
||||
if (b.frame == BULLET_EMPTY_FRAME) {
|
||||
b.offset.y = 0;
|
||||
b.exists = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
|
||||
for each (var b:FlxSprite in y_bullets.members) {
|
||||
|
||||
parent.fg_sprites.remove(b, true);
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
import org.flixel.system.FlxTile;
|
||||
|
||||
public class Person extends FlxSprite
|
||||
{
|
||||
|
||||
|
||||
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.PERSON;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
public var switch_dir_timer_max:Number = 1.3;
|
||||
public var switch_dir_timer:Number = 0.6;
|
||||
public var initial_vel_timeout:Number = 2;
|
||||
public var wait:int = 0;
|
||||
public var speed:int = 10;
|
||||
|
||||
public var cur_x_vel:int = 0;
|
||||
public var cur_y_vel:int = 0;
|
||||
|
||||
public var init_vel:Point = new Point(0, 0);
|
||||
|
||||
public var dame_frame:int;
|
||||
|
||||
private var collide_timeout:int = 0;
|
||||
|
||||
private var talk_timer:Number;
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/person.png")] public static var person_sprite:Class;
|
||||
/*
|
||||
* dame params: frame: the direction of player travel this one opposes (or none at all)
|
||||
* URDLN, unsurprisingly... 01234
|
||||
* direction given away by the way they walk initially
|
||||
* */
|
||||
public function Person(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
loadGraphic(person_sprite, true, false, 16, 16);
|
||||
addAnimation("walk_d", [0, 1], 5);
|
||||
addAnimation("walk_r", [2,3], 5);
|
||||
addAnimation("walk_u", [4,5], 5);
|
||||
addAnimation("walk_l", [2, 3], 5);
|
||||
addAnimationCallback(on_anim_change);
|
||||
height = 2;
|
||||
width = 4;
|
||||
offset.y = 13;
|
||||
offset.x = 7;
|
||||
talk_timer = 0.5 + Math.random();
|
||||
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
switch (dame_frame) { //urdln
|
||||
case 0: init_vel.y = 10; play("walk_d"); break;
|
||||
case 1: init_vel.x = 10; play("walk_r"); break;
|
||||
case 2: init_vel.y = -10; play("walk_u");break;
|
||||
case 3: init_vel.x = -10; play("walk_l"); break;
|
||||
case 4: init_vel.x = init_vel.y = -10 + 20 * Math.random();
|
||||
if (init_vel.x > 0) {
|
||||
play("walk_r");
|
||||
} else {
|
||||
play("walk_l");
|
||||
}
|
||||
switch_dir_timer = 0.3;
|
||||
switch_dir_timer_max = 0.5;
|
||||
drag.x = 20;
|
||||
drag.y = 20;
|
||||
break;
|
||||
}
|
||||
|
||||
add_sfx("talk", Registry.sound_data.talk_group);
|
||||
}
|
||||
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
|
||||
//urdln
|
||||
//which dir of travel it blocks
|
||||
//allow pushing if touching to olong
|
||||
if (collide_timeout > 1) {
|
||||
collide_timeout = 0;
|
||||
FlxG.collide(parent.curMapBuf, this);
|
||||
} else {
|
||||
collide_timeout++;
|
||||
}
|
||||
|
||||
/* When the player touches, change player's velocity and
|
||||
* maybe collide with the player as well. */
|
||||
if (player.overlaps(this)) {
|
||||
player.slow_mul = 0.5;
|
||||
player.slow_ticks = 7;
|
||||
player.velocity.x *= 0.25;
|
||||
player.velocity.y *= 0.25;
|
||||
FlxG.collide(this, player);
|
||||
player.velocity.x *= 4;
|
||||
player.velocity.y *= 4;
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (talk_timer < 0) {
|
||||
talk_timer = 0.5 + Math.random();
|
||||
play_sfx("talk",true);
|
||||
} else {
|
||||
talk_timer -= FlxG.elapsed;
|
||||
}
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch_dir_timer -= FlxG.elapsed;
|
||||
initial_vel_timeout -= FlxG.elapsed;
|
||||
/* Switch directions semi-randomly */
|
||||
if (switch_dir_timer < 0) {
|
||||
/* Walk in an initial velocity for a fixed period of time */
|
||||
if (initial_vel_timeout > 0) {
|
||||
velocity.x = init_vel.x;
|
||||
velocity.y = init_vel.y;
|
||||
} else {
|
||||
switch_dir_timer = switch_dir_timer_max;
|
||||
if (Math.random() > 0.5) {
|
||||
velocity.y = 0;
|
||||
if (Math.random() > 0.5) {
|
||||
velocity.x = speed;
|
||||
play("walk_r");
|
||||
} else {
|
||||
velocity.x = -speed;
|
||||
play("walk_l");
|
||||
}
|
||||
} else {
|
||||
velocity.x = 0;
|
||||
if (Math.random() > 0.5) {
|
||||
velocity.y = speed;
|
||||
play("walk_d");
|
||||
} else {
|
||||
velocity.y = -speed;
|
||||
play("walk_u");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function on_anim_change(name:String, frame:int, index:int):void {
|
||||
if (name == "walk_l") {
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Simple enemy - harmful sprite rotates about center thing
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Rotator extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/f_rotator.png")] public static var rotator_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/f_rotator_ball.png")] public static var rotator_ball_sprite:Class;
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.ROTATOR;
|
||||
public var player:Player;
|
||||
public var sprite_ball:FlxSprite;
|
||||
public var avel:Number = 0.02;
|
||||
public var r:Number = 0;
|
||||
|
||||
private var t_timeout:Number = 1.4;
|
||||
/**
|
||||
* dame props:
|
||||
* frame: both the sprite to use as well as the rotational radius/speed... see types
|
||||
*
|
||||
*/
|
||||
public function Rotator(_xml:XML,_player:Player)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
|
||||
sprite_ball = new FlxSprite(0, 0);
|
||||
sprite_ball.loadGraphic(rotator_ball_sprite, true, false, 8, 8);
|
||||
sprite_ball.rotate_angle = 0;
|
||||
sprite_ball.addAnimation("ball_move", [0, 1], 10);
|
||||
sprite_ball.play("ball_move");
|
||||
|
||||
sprite_ball.width = sprite_ball.height = 4;
|
||||
sprite_ball.offset.x = sprite_ball.offset.y = 2;
|
||||
sprite_ball.x += 2; sprite_ball.y += 2;
|
||||
|
||||
loadGraphic(rotator_sprite, true, false, 16, 16);
|
||||
|
||||
|
||||
width = 6;
|
||||
height = 5;
|
||||
offset.x = 5;
|
||||
offset.y = 2;
|
||||
x += 5; y += 2;
|
||||
|
||||
|
||||
addAnimation("tower_pulsate", [0, 1], 10);
|
||||
play("tower_pulsate");
|
||||
immovable = true;
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (r < 59) {
|
||||
r += 0.5;
|
||||
}
|
||||
EventScripts.rotate_about_center_of_sprite(this, sprite_ball, r, avel, 8, 8);
|
||||
FlxG.collide(player, this);
|
||||
if (Registry.GAMESTATE.state != Registry.GAMESTATE.S_TRANSITION && sprite_ball.overlaps(player) && player.state != player.S_AIR) {
|
||||
|
||||
player.touchDamage(1);
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
import entity.player.Player;
|
||||
import data.CLASS_ID;
|
||||
|
||||
/**
|
||||
* pretty self explanatoory
|
||||
* falls from ceiling and rolls across the room stops on other side
|
||||
* roomm should be empty from obstacles or this looks awkward
|
||||
*/
|
||||
public class Spike_Roller extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.SPIKE_ROLLER;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var added_extras:Boolean = false;
|
||||
private var transitioned_in:Boolean = false;
|
||||
public var dame_type:int = 0;
|
||||
private var state:int = 0;
|
||||
private var s_hidden:int = 0;
|
||||
private var s_fall:int = 1;
|
||||
private var s_roll:int = 2;
|
||||
private var s_stopped:int = 3;
|
||||
|
||||
private var vel_x:int = 0;
|
||||
private var vel_y:int = 0;
|
||||
private var Fall_Rate:Number = 1.0;
|
||||
private var init_pt:Point = new Point();
|
||||
|
||||
private var is_bounce:Boolean = false;
|
||||
private var bounce_vel:int = 45;
|
||||
private var ctr:int = 0;
|
||||
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/spike_roller.png")] public var Spike_Roller_Sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/spike_roller_horizontal.png")] public static var Spike_Roller_Sprite_H:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/spike_roller_shadow.png")] public var vert_shadow_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/spike_roller_horizontal_shadow.png")] public var hori_shadow_sprite:Class;
|
||||
|
||||
|
||||
|
||||
// Dame: Frame: URLD 0123
|
||||
// Bounce - 4567
|
||||
public function Spike_Roller(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
dame_type = parseInt(_xml.@frame);
|
||||
|
||||
my_shadow = new FlxSprite(x, y);
|
||||
|
||||
switch (dame_type % 4) {
|
||||
case 0:
|
||||
loadGraphic(Spike_Roller_Sprite_H, true, false, 128, 16);
|
||||
height = 12;
|
||||
my_shadow.loadGraphic(hori_shadow_sprite, true, false, 128, 16);
|
||||
vel_y = -20;
|
||||
facing = UP; break;
|
||||
case 1:
|
||||
loadGraphic(Spike_Roller_Sprite, true, false, 16, 128);
|
||||
width = 12;
|
||||
vel_x = 20;
|
||||
my_shadow.loadGraphic(vert_shadow_sprite, true, false, 16, 128);
|
||||
facing = RIGHT; break;
|
||||
case 3:
|
||||
loadGraphic(Spike_Roller_Sprite_H, true, false, 128, 16);
|
||||
height = 12;
|
||||
my_shadow.loadGraphic(hori_shadow_sprite, true, false, 128, 16);
|
||||
vel_y = 20;
|
||||
facing = DOWN; break;
|
||||
case 2:
|
||||
loadGraphic(Spike_Roller_Sprite, true, false, 16, 128);
|
||||
width = 12;
|
||||
my_shadow.loadGraphic(vert_shadow_sprite, true, false, 16, 128);
|
||||
vel_x = -20;
|
||||
facing = LEFT; break;
|
||||
|
||||
}
|
||||
|
||||
/* ADd spike roller animations */
|
||||
addAnimation("roll_l", [0, 1], 5);
|
||||
addAnimation("roll_r", [0, 1], 5); // DEFAULT RIGHT
|
||||
addAnimation("roll_d", [0, 1], 5); //DEFAULT DOWN
|
||||
addAnimation("roll_u", [0, 1], 5);
|
||||
addAnimation("idle", [0]);
|
||||
play("idle");
|
||||
|
||||
/* add shadow animations */
|
||||
my_shadow.addAnimation("hiding", [0]);
|
||||
my_shadow.addAnimation("fall", [0], 2);
|
||||
my_shadow.play("hiding");
|
||||
my_shadow.flicker( -1);
|
||||
|
||||
|
||||
visible = my_shadow.visible = false;
|
||||
|
||||
/* If bounce type */
|
||||
if (dame_type > 3) {
|
||||
has_tile_callbacks = false;
|
||||
offset.y = 0;
|
||||
is_bounce = true;
|
||||
play("roll_l");
|
||||
if (vel_x > 0) {
|
||||
play("roll_r");
|
||||
} else if (vel_x < 0) {
|
||||
play("roll_l");
|
||||
} else if (vel_y < 0) {
|
||||
play("roll_u");
|
||||
} else {
|
||||
play("roll_d");
|
||||
}
|
||||
visible = true;
|
||||
} else {
|
||||
offset.y = 80;
|
||||
immovable = true;
|
||||
}
|
||||
|
||||
Registry.subgroup_spike_rollers.push(this);
|
||||
}
|
||||
override public function preUpdate():void
|
||||
{
|
||||
ctr++;
|
||||
if (is_bounce && ctr == 4) {
|
||||
ctr = 0;
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
private function bounce_logic():void {
|
||||
if (touching) {
|
||||
if (touching & LEFT) {
|
||||
play("roll_r");
|
||||
velocity.x = bounce_vel;
|
||||
} else if (touching & RIGHT) {
|
||||
play("roll_l");
|
||||
scale.x = -1;
|
||||
velocity.x = -bounce_vel;
|
||||
} else if (touching & DOWN) {
|
||||
play("roll_u");
|
||||
scale.y = -1;
|
||||
velocity.y = -bounce_vel;
|
||||
} else {
|
||||
play("roll_d");
|
||||
velocity.y = bounce_vel;
|
||||
}
|
||||
|
||||
Registry.sound_data.hitground1.play();
|
||||
}
|
||||
|
||||
|
||||
if (player.state != player.S_AIR && player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var move_that_shit_to_front_ticks:int = 5;
|
||||
private var moveeeeeeeeeeeed:Boolean = false;
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (!added_extras) {
|
||||
added_extras = true;
|
||||
init_pt.x = x;
|
||||
init_pt.y = y;
|
||||
if (is_bounce) {
|
||||
velocity.x = vel_x * 2;
|
||||
velocity.y = vel_y * 2;
|
||||
parent.sortables.remove(this, true);
|
||||
parent.bg_sprites.add(this);
|
||||
} else {
|
||||
my_shadow.x = x;
|
||||
my_shadow.y = y;
|
||||
parent.bg_sprites.add(my_shadow);
|
||||
parent.sortables.remove(this, true);
|
||||
parent.fg_sprites.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (move_that_shit_to_front_ticks > 0) {
|
||||
move_that_shit_to_front_ticks -= 1;
|
||||
} else {
|
||||
if (Registry.CURRENT_MAP_NAME != "BLUE" && Registry.CURRENT_MAP_NAME != "CIRCUS" && moveeeeeeeeeeeed == false && is_bounce ) {
|
||||
moveeeeeeeeeeeed = true;
|
||||
parent.bg_sprites.move_to_front(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (parent.state == parent.S_TRANSITION) {
|
||||
if (!transitioned_in) {
|
||||
x = init_pt.x;
|
||||
y = init_pt.y;
|
||||
} else {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
transitioned_in = true;
|
||||
}
|
||||
|
||||
if (is_bounce) {
|
||||
bounce_logic();
|
||||
return;
|
||||
}
|
||||
switch (state) {
|
||||
case s_hidden:
|
||||
if (player.overlaps(my_shadow)) {
|
||||
state = s_fall;
|
||||
my_shadow.play("fall");
|
||||
my_shadow.exists = true;
|
||||
exists = true;
|
||||
Registry.sound_data.fall1.play();
|
||||
my_shadow.visible = visible = true;
|
||||
}
|
||||
break;
|
||||
case s_fall:
|
||||
offset.y -= Fall_Rate;
|
||||
if (offset.y < 0) {
|
||||
if (facing == UP || facing == DOWN) {
|
||||
offset.y = 2;
|
||||
} else {
|
||||
offset.y = 0;
|
||||
offset.x = 2;
|
||||
}
|
||||
Registry.sound_data.hitground1.play();
|
||||
state = s_roll;
|
||||
velocity.x = vel_x;
|
||||
velocity.y = vel_y;
|
||||
parent.fg_sprites.remove(this, true);
|
||||
parent.bg_sprites.add(this);
|
||||
my_shadow.visible = false;
|
||||
|
||||
if (vel_x > 0) {
|
||||
play("roll_r");
|
||||
} else if (vel_x < 0) {
|
||||
play("roll_l");
|
||||
scale.x = -1;
|
||||
} else if (vel_y < 0) {
|
||||
play("roll_u");
|
||||
scale.y = -1;
|
||||
} else {
|
||||
play("roll_d");
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case s_roll:
|
||||
if (player.state != player.S_AIR && (player.overlaps(this)) ) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (Math.abs(init_pt.x - x) >= 112) {
|
||||
Registry.sound_data.hitground1.play();
|
||||
velocity.x = 0;
|
||||
state = s_stopped;
|
||||
} else if (Math.abs(init_pt.y - y) >= 112) {
|
||||
Registry.sound_data.hitground1.play();
|
||||
velocity.y = 0;
|
||||
state = s_stopped;
|
||||
}
|
||||
break;
|
||||
case s_stopped:
|
||||
frame = 0;
|
||||
if (player.state != player.S_AIR && (player.overlaps(this)) ) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,898 @@
|
|||
package entity.enemy.crowd
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.Common_Sprites;
|
||||
import data.TileData;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
import org.flixel.FlxU;
|
||||
|
||||
/**
|
||||
* The 3rd boss. Face on a wall, and two fists.
|
||||
* Basically.
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class WallBoss extends FlxSprite
|
||||
{
|
||||
|
||||
/* Generic properties */
|
||||
public var tl:Point = new Point();
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
public var cid:int = CLASS_ID.WALLBOSS;
|
||||
private var max_health:int = 12;
|
||||
public var cur_phase:int = 0;
|
||||
private var phase_2_health:int = 10;
|
||||
private var phase_3_health:int = 5;
|
||||
private var fade_in_alpha_rate:Number = 0.04;
|
||||
private var fade_out_alpha_rate:Number = 0.003;
|
||||
private var broke_ground:Boolean = false;
|
||||
|
||||
private var talk_timer:Number = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
/* wall properties */
|
||||
public var wall:FlxSprite;
|
||||
private var death_explosions:FlxGroup = new FlxGroup(4);
|
||||
private var death_explosion_timer:Number = 0.25;
|
||||
private var tm_de:Number = 0.20;
|
||||
|
||||
/* Face properties */
|
||||
public var face:FlxSprite;
|
||||
private var s_face:int = -1;
|
||||
private var s_face_intro:int = -1;
|
||||
private var s_face_normal:int = 0;
|
||||
private var s_face_charge:int = 1;
|
||||
private var s_face_hit:int = 2;
|
||||
private var s_face_dying:int = 3;
|
||||
private var s_face_dead:int = 4;
|
||||
private var s_face_shoot:int = 5;
|
||||
public var hurt_t:Number = 0;
|
||||
public var hurt_tm:Number = 1.0;
|
||||
public var charge_t:Number = 0;
|
||||
public var charge_tm:Number = 3.0;
|
||||
public var finish_charge_tm:Number = 1.0;
|
||||
public var face_bullets:FlxGroup = new FlxGroup(8);
|
||||
public var nr_bullets:Array = new Array(5, 6, 8);
|
||||
|
||||
/* Hand properties */
|
||||
public var lhand:FlxSprite;
|
||||
public var rhand:FlxSprite;
|
||||
private var lhand_init_pt:Point = new Point();
|
||||
private var rhand_init_pt:Point = new Point();
|
||||
|
||||
private var lhand_poof:FlxSprite = new FlxSprite;
|
||||
private var rhand_poof:FlxSprite = new FlxSprite;
|
||||
|
||||
|
||||
private var s_hand:int = 0;
|
||||
private var s_hand_intro:int = 0;
|
||||
|
||||
private var s_hand_float:int = 1;
|
||||
private var t_float:Number = 0;
|
||||
private var tm_float:Number = 2.0;
|
||||
|
||||
private var s_hand_push:int = 2;
|
||||
private var max_nr_pushes:Array = new Array(2,3, 3);
|
||||
private var nr_pushes:int = 0;
|
||||
private var push_y_vel:Array = new Array(60, 90, 120);
|
||||
private var p_double_push:Array = new Array(0.5, 0.7, 0.8);
|
||||
|
||||
|
||||
/**
|
||||
* Lhand only = 0, rhand = 1, both = 2
|
||||
*/
|
||||
private var push_type:int = 0;
|
||||
private var ctr_hand_push:int = 0;
|
||||
|
||||
|
||||
private var s_hand_stomp:int = 3;
|
||||
private var s_hand_stomp_rhand:int = LEFT;
|
||||
private var max_nr_falls:Array = new Array(2, 3, 4);
|
||||
private var nr_falls:int = 0; //counter
|
||||
private var period_lhand_stomp:Number = 2.0;
|
||||
private var ctr_hand_stomp:int = 0; //sub-state ctr
|
||||
private var rhand_stomp_vel:Number = 30;
|
||||
private var t_lhand_stomp:Number = 0;
|
||||
private var tm_lhand_stomp:Number = 0.7
|
||||
private var played_sound:Boolean = false;
|
||||
|
||||
/* laser states*/
|
||||
|
||||
private var s_hand_h_laser:int = 4;
|
||||
private var s_hand_h_laser_ctr:int = 0;
|
||||
public var h_laser:FlxSprite = new FlxSprite();
|
||||
|
||||
private var s_hand_dying:int = 5;
|
||||
private var t_dying:Number = 0;
|
||||
private var tm_dying:Number = 3;
|
||||
|
||||
private var s_hand_dead:int = 6;
|
||||
|
||||
private var do_intro:Boolean = true;
|
||||
private var intro_ctr:int = 0;
|
||||
|
||||
|
||||
/* Assets */
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/wallboss_wall.png")] public static var wall_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/wallboss_laser.png")] public var laser_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/crowd/wallboss_bullet.png")] public var bullet_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/crowd/f_wallboss_face.png")] public static var face_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/crowd/f_wallboss_l_hand.png")] public static var l_hand_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/crowd/f_wallboss_l_hand.png")] public static var r_hand_sprite:Class;
|
||||
|
||||
/* N.B. all interactive entities added and removed directly in this code */
|
||||
public function WallBoss(_x:XML,_p:Player,_s:*)
|
||||
{
|
||||
/* boilerplate */
|
||||
xml = _x;
|
||||
player = _p;
|
||||
parent = _s;
|
||||
|
||||
super(parseInt(_x.@x), parseInt(_x.@y));
|
||||
tl.x = Registry.CURRENT_GRID_X * 160 + 16;
|
||||
tl.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT + 16;
|
||||
var ctr:int;
|
||||
|
||||
health = max_health;
|
||||
visible = false;
|
||||
|
||||
|
||||
wall = new FlxSprite(tl.x - 16, tl.y - 16);
|
||||
face = new FlxSprite(tl.x + (128 - 64) / 2, tl.y - 16);
|
||||
lhand = new FlxSprite(tl.x, tl.y + 16);
|
||||
rhand = new FlxSprite(tl.x + 16 * 6, tl.y + 16);
|
||||
|
||||
/* init wall entities */
|
||||
wall.loadGraphic(wall_sprite, true, false, 160, 32);
|
||||
wall.addAnimation("move", [0, 1], 4);
|
||||
wall.play("move");
|
||||
wall.immovable = true;
|
||||
|
||||
// Death explosions
|
||||
for (ctr = 0; ctr < death_explosions.maxSize; ctr++) {
|
||||
var de:FlxSprite = new FlxSprite;
|
||||
de.loadGraphic(EventScripts.small_explosion_sprite, true, false, 24,24);
|
||||
de.addAnimation("explode", [0, 1, 2, 3, 4,4], 14, false);
|
||||
de.visible = false;
|
||||
death_explosions.add(de);
|
||||
}
|
||||
death_explosions.exists = false;
|
||||
tm_de = 0.15;
|
||||
|
||||
|
||||
/* init face entities */
|
||||
face.loadGraphic(face_sprite, true, false, 64, 32);
|
||||
face.immovable = true;
|
||||
face.addAnimation("normal", [0,2],5);
|
||||
face.addAnimation("hurt", [3, 5],14,true);
|
||||
face.addAnimation("charge", [1], 5, true);
|
||||
face.addAnimation("shoot", [4], 10, true);
|
||||
face.play("normal");
|
||||
|
||||
for (ctr = 0; ctr < face_bullets.maxSize; ctr++) {
|
||||
var b:FlxSprite = new FlxSprite(0, 0);
|
||||
b.loadGraphic(bullet_sprite, true, false, 8, 8);
|
||||
b.addAnimation("move", [0, 1], 12, true);
|
||||
b.addAnimation("explode", [2, 3, 4], 10, false);
|
||||
b.play("move");
|
||||
|
||||
b.my_shadow = EventScripts.make_shadow("8_small");
|
||||
b.my_shadow.visible = true;
|
||||
b.my_shadow.exists = false;
|
||||
b.addAnimation("get_small", [4, 3, 2, 1, 0], 12, false);
|
||||
b.addAnimation("get_big", [0,1,2,3,4], 12, false);
|
||||
b.my_shadow.play("get_small");
|
||||
parent.bg_sprites.add(b.my_shadow);
|
||||
face_bullets.add(b);
|
||||
}
|
||||
face_bullets.setAll("exists", false);
|
||||
|
||||
/* Init hand stuff */
|
||||
/* Hand ANIMS */
|
||||
lhand.loadGraphic(l_hand_sprite, true, false, 32, 32);
|
||||
rhand.loadGraphic(r_hand_sprite, true, false, 32, 32);
|
||||
rhand.scale.x = -1;
|
||||
lhand.addAnimation("idle", [0]);
|
||||
lhand.addAnimation("stomp", [1]);
|
||||
lhand.addAnimation("push", [3]);
|
||||
lhand.addAnimation("shoot", [2]);
|
||||
lhand.play("idle");
|
||||
rhand.addAnimation("idle", [0]);
|
||||
rhand.addAnimation("stomp", [1]);
|
||||
rhand.addAnimation("push", [3]);
|
||||
rhand.addAnimation("shoot", [2]);
|
||||
rhand.play("idle");
|
||||
|
||||
|
||||
lhand_init_pt.y = lhand.y;
|
||||
lhand_init_pt.x = lhand.x;
|
||||
rhand_init_pt.y = rhand.y;
|
||||
rhand_init_pt.x = rhand.x;
|
||||
rhand.immovable = lhand.immovable = true;
|
||||
lhand.parabola_thing = new Parabola_Thing(lhand, 64, period_lhand_stomp, "offset", "y");
|
||||
rhand.parabola_thing = new Parabola_Thing(rhand, 32, 1.0, "offset", "y");
|
||||
lhand.my_shadow = new FlxSprite(0, 0);
|
||||
rhand.my_shadow = new FlxSprite(0, 0);
|
||||
/* Load shadow anims */
|
||||
/* This shadow has 5 frames, and its frame is determined by the fist's y-offset
|
||||
* (or height) */
|
||||
lhand.my_shadow.loadGraphic(Common_Sprites.shadow_sprite_28_10, true, false, 28, 10);
|
||||
rhand.my_shadow.loadGraphic(Common_Sprites.shadow_sprite_28_10, true, false, 28, 10);
|
||||
|
||||
/* Hand poofs */
|
||||
lhand_poof.loadGraphic(EventScripts.small_explosion_sprite, true, false, 24,24);
|
||||
rhand_poof.loadGraphic(EventScripts.small_explosion_sprite, true, false, 24,24);
|
||||
lhand_poof.addAnimation("poof", [0, 1, 2, 3,4,4], 12, false); // Last frame should be empty
|
||||
rhand_poof.addAnimation("poof", [0, 1, 2, 3,4,4], 12, false);
|
||||
lhand_poof.exists = false;
|
||||
rhand_poof.exists = false;
|
||||
|
||||
/* Load laser anims */
|
||||
h_laser.loadGraphic(laser_sprite, true, false, 64, 10);
|
||||
h_laser.addAnimation("charge", [0], 12);
|
||||
h_laser.addAnimation("move", [1,2], 12);
|
||||
h_laser.play("charge");
|
||||
h_laser.visible = false;
|
||||
|
||||
|
||||
/* Add to parent draw group */
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
} else {
|
||||
parent.bg_sprites.add(lhand.my_shadow);
|
||||
parent.bg_sprites.add(rhand.my_shadow);
|
||||
parent.bg_sprites.add(wall);
|
||||
parent.bg_sprites.add(h_laser);
|
||||
parent.sortables.add(face);
|
||||
parent.fg_sprites.add(face_bullets);
|
||||
parent.fg_sprites.add(death_explosions);
|
||||
parent.sortables.add(lhand);
|
||||
parent.sortables.add(rhand);
|
||||
parent.sortables.add(rhand_poof);
|
||||
parent.sortables.add(lhand_poof);
|
||||
}
|
||||
|
||||
|
||||
if (Registry.FUCK_IT_MODE_ON) {
|
||||
s_face = s_face_dying;
|
||||
}
|
||||
|
||||
lhand.alpha = rhand.alpha = 0;
|
||||
|
||||
/* Change player respawn point */
|
||||
player.grid_entrance_x = tl.x + 70;
|
||||
player.grid_entrance_y = tl.y + 65;
|
||||
|
||||
|
||||
FlxG.watch(this, "cur_phase", "phase");
|
||||
face.alpha = wall.alpha = lhand.alpha = rhand.alpha = 0;
|
||||
|
||||
|
||||
add_sfx("hit_ground", Registry.sound_data.wb_hit_ground);
|
||||
add_sfx("tap_ground", Registry.sound_data.wb_tap_ground);
|
||||
add_sfx("fall", Registry.sound_data.fall1);
|
||||
add_sfx("charge", Registry.sound_data.sun_guy_charge);
|
||||
add_sfx("shoot", Registry.sound_data.wb_shoot);
|
||||
add_sfx("pop", Registry.sound_data.four_shooter_pop_group);
|
||||
add_sfx("push", Registry.sound_data.slasher_atk);
|
||||
add_sfx("hurt", Registry.sound_data.wb_moan);
|
||||
add_sfx("hurt_2", Registry.sound_data.wb_moan_2);
|
||||
add_sfx("death", Registry.sound_data.talk_death);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (do_intro) {
|
||||
if (intro_ctr == 0) {
|
||||
Registry.volume_scale -= 0.005;
|
||||
if (player.y < tl.y + 80 ) {
|
||||
DH.start_dialogue(DH.name_wallboss, DH.scene_wallboss_before_fight);
|
||||
intro_ctr++;
|
||||
player.be_idle();
|
||||
}
|
||||
super.update();
|
||||
return;
|
||||
} else if (intro_ctr == 1) {
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
|
||||
intro_ctr++;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.sound_data.start_song_from_title("BOSS");
|
||||
Registry.volume_scale = 1;
|
||||
}
|
||||
super.update();
|
||||
return;
|
||||
} else if (intro_ctr == 2) {
|
||||
face.alpha += 0.003;
|
||||
wall.alpha = lhand.alpha = rhand.alpha = face.alpha;
|
||||
if (face.alpha == 1) {
|
||||
do_intro = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Act solid */
|
||||
FlxG.collide(face, player);
|
||||
FlxG.collide(wall, player);
|
||||
|
||||
var s:FlxSprite;
|
||||
var ctr:int;
|
||||
|
||||
|
||||
/* Hurting the boss logic */
|
||||
//in normal state, boss can be hurt. also set current attack phase.
|
||||
if (s_face == s_face_normal) {
|
||||
|
||||
charge_t += FlxG.elapsed;
|
||||
if (charge_t > charge_tm) {
|
||||
s_face = s_face_charge;
|
||||
charge_t = 0;
|
||||
}
|
||||
if (hurt_t > hurt_tm) {
|
||||
if (player.broom.visible && player.broom.overlaps(face)) {
|
||||
health--;
|
||||
if (health == phase_2_health) cur_phase = 1;
|
||||
if (health == phase_3_health) cur_phase = 2;
|
||||
if (health == 0) {
|
||||
s_face = s_face_dying;
|
||||
s_hand = s_hand_dying;
|
||||
play_sfx("hurt_2");
|
||||
} else {
|
||||
|
||||
play_sfx("hurt");
|
||||
}
|
||||
hurt_t = 0;
|
||||
face.play("hurt");
|
||||
} else {
|
||||
face.play("normal");
|
||||
}
|
||||
} else {
|
||||
hurt_t += FlxG.elapsed;
|
||||
}
|
||||
//charge up, and then set all teh bullet properties
|
||||
} else if (s_face == s_face_charge) {
|
||||
face.play("charge");
|
||||
charge_t += FlxG.elapsed;
|
||||
if (charge_t > finish_charge_tm) {
|
||||
charge_t = 0;
|
||||
s_face = s_face_shoot;
|
||||
face.play("shoot");
|
||||
play_sfx("shoot");
|
||||
face_bullets.setAll("exists", true);
|
||||
|
||||
for each (s in face_bullets.members) { //BARF
|
||||
if (s == null) continue;
|
||||
s.x = face.x + 32;
|
||||
s.y = face.y + 16;
|
||||
s.parabola_thing = null;
|
||||
s.parabola_thing = new Parabola_Thing(s, 16 + int(8 * Math.random()), 1 + 0.5 * Math.random(), "offset", "y");
|
||||
s.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
s.velocity.x = -30 + int(60 * Math.random());
|
||||
s.velocity.y = 30;
|
||||
|
||||
s.my_shadow.exists = true;
|
||||
s.my_shadow.play("get_small");
|
||||
s.my_shadow.x = s.x;
|
||||
s.my_shadow.y = s.y;
|
||||
}
|
||||
}
|
||||
//release bullets and chek for collisions. return to normal state
|
||||
// when all bullets have hit the ground.
|
||||
} else if (s_face == s_face_shoot) {
|
||||
for each (s in face_bullets.members) {
|
||||
s.my_shadow.x = s.x; //pin shadow to bullet
|
||||
s.my_shadow.y = s.y;
|
||||
if (!player.invincible && s.overlaps(player) && s.alive && s.exists) { //check overlap only if player vulnerable
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
if (s.parabola_thing.tick()) {
|
||||
if (s.alive && s.exists) {
|
||||
s.alive = false;
|
||||
s.play("explode");
|
||||
play_sfx("pop");
|
||||
s.my_shadow.exists = false;
|
||||
s.velocity.x = s.velocity.y = 0;
|
||||
|
||||
} else {
|
||||
if (s._curAnim.frames.length - 1 == s._curFrame) {
|
||||
if (s.exists) {
|
||||
s.alive = true;
|
||||
s.exists = false;
|
||||
s.play("move");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!s.exists) {
|
||||
ctr++;
|
||||
}
|
||||
}
|
||||
if (ctr >= face_bullets.maxSize) {
|
||||
s_face = s_face_normal;
|
||||
}
|
||||
} else if (s_face == s_face_intro) {
|
||||
//play some sort of animation
|
||||
//wait for hands to appear
|
||||
if (s_hand != s_hand_intro) {
|
||||
s_face = s_face_normal;
|
||||
}
|
||||
|
||||
} else if (s_face == s_face_dying) {
|
||||
|
||||
if (t_dying < 0) {
|
||||
if (!played_sound) {
|
||||
DH.start_dialogue(DH.name_wallboss, DH.scene_wallboss_after_fight);
|
||||
player.be_idle();
|
||||
played_sound = true;
|
||||
play_sfx("death");
|
||||
}
|
||||
|
||||
if (!DH.scene_is_finished(DH.name_wallboss, DH.scene_wallboss_after_fight)) {
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
face.alpha -= fade_out_alpha_rate;
|
||||
wall.alpha -= fade_out_alpha_rate;
|
||||
if (face.alpha == 0 && wall.alpha == 0) {
|
||||
s_face = s_face_dead;
|
||||
t_dying = 1;
|
||||
}
|
||||
} else if (s_hand == s_hand_dead) {
|
||||
t_dying -= FlxG.elapsed;
|
||||
}
|
||||
|
||||
} else if (s_face == s_face_dead) {
|
||||
if (t_dying < 0) {
|
||||
Registry.sound_data.start_song_from_title("CROWD");
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
//if (!Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Crowd]) {
|
||||
// Registry.CURRENT_CUTSCENE = Cutscene.Terminal_Gate_Crowd;
|
||||
// Registry.E_Load_Cutscene = true;
|
||||
//}
|
||||
Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx] = true;
|
||||
xml.@alive = "false";
|
||||
exists = false;
|
||||
} else {
|
||||
t_dying -= FlxG.elapsed;
|
||||
}
|
||||
}
|
||||
|
||||
/**************/
|
||||
/* Hand logic */
|
||||
//only collide if not in stomp state
|
||||
|
||||
set_shadow_size(lhand);
|
||||
set_shadow_size(rhand);
|
||||
|
||||
if (s_hand != s_hand_stomp) {
|
||||
FlxG.collide(player, lhand);
|
||||
FlxG.collide(player, rhand);
|
||||
}
|
||||
if (s_hand == s_hand_intro) {
|
||||
rhand.alpha += fade_in_alpha_rate;
|
||||
lhand.alpha += fade_in_alpha_rate;
|
||||
if (lhand.alpha == 1 && rhand.alpha == 1) {
|
||||
s_hand = s_hand_float;
|
||||
}
|
||||
/* Floating logic */
|
||||
} else if (s_hand == s_hand_float) {
|
||||
t_float += FlxG.elapsed;
|
||||
if (t_float > tm_float) {
|
||||
t_float = 0;
|
||||
|
||||
choose_attack();
|
||||
if (s_hand == s_hand_push) {
|
||||
nr_pushes = max_nr_pushes[cur_phase];
|
||||
}
|
||||
|
||||
}
|
||||
lhand.y = lhand_init_pt.y + 4 + Math.sin(t_float * 6.28) * 8;
|
||||
rhand.y = rhand_init_pt.y + 4 - Math.sin(t_float * 6.28) * 8;
|
||||
/* Logic for pushing */
|
||||
} else if (s_hand == s_hand_push) {
|
||||
var sub_ctr:int = 0;
|
||||
//move hands to correct place then depending on the type of
|
||||
//attack, set velocities
|
||||
if (ctr_hand_push == 0) {
|
||||
if (push_type != 0) {
|
||||
if (EventScripts.send_property_to(lhand, "y", tl.y, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(lhand, "x", tl.x, 0.5)) sub_ctr++;
|
||||
} else {
|
||||
sub_ctr += 2;
|
||||
}
|
||||
if (push_type != 1) {
|
||||
if (EventScripts.send_property_to(rhand, "y", tl.y, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "x", tl.x + 16*6, 0.5)) sub_ctr++;
|
||||
} else {
|
||||
sub_ctr += 2;
|
||||
}
|
||||
|
||||
if (sub_ctr == 4) {
|
||||
if (push_type != 1) {
|
||||
rhand.play("push");
|
||||
play_sfx("push");
|
||||
rhand.velocity.y = push_y_vel[cur_phase];
|
||||
rhand.velocity.x = -20 - 40 * Math.random();
|
||||
}
|
||||
if (push_type != 0) {
|
||||
lhand.play("push");
|
||||
play_sfx("push");
|
||||
lhand.velocity.y = push_y_vel[cur_phase];
|
||||
lhand.velocity.x = 20 + 40 * Math.random();
|
||||
}
|
||||
|
||||
ctr_hand_push++;
|
||||
}
|
||||
//if the hand goes far enough, then change states
|
||||
} else if (ctr_hand_push == 1) {
|
||||
if (lhand.y > tl.y + 5 * 16 || rhand.y > tl.y + 5*16) {
|
||||
ctr_hand_push++;
|
||||
}
|
||||
//reset hand push script if more pushes, otherwise go back to float
|
||||
} else if (ctr_hand_push == 2) {
|
||||
if (EventScripts.send_property_to(lhand, "y", lhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(lhand, "x", lhand_init_pt.x, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "y", rhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "x", rhand_init_pt.x, 3)) sub_ctr++;
|
||||
|
||||
if (sub_ctr == 4) {
|
||||
ctr_hand_push = 0;
|
||||
lhand.play("idle");
|
||||
rhand.play("idle");
|
||||
lhand.velocity.y = lhand.velocity.x = 0;
|
||||
rhand.velocity.y = rhand.velocity.x = 0;
|
||||
set_next_push();
|
||||
nr_pushes--;
|
||||
if (nr_pushes == 0) {
|
||||
s_hand = s_hand_float;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Logic for stomping */
|
||||
} else if (s_hand == s_hand_stomp) {
|
||||
sub_ctr = 0;
|
||||
// Pin shadows to hands
|
||||
lhand.my_shadow.x = lhand.x;
|
||||
lhand.my_shadow.y = lhand.y + 20;
|
||||
rhand.my_shadow.x = rhand.x;
|
||||
rhand.my_shadow.y = rhand.y + 20;
|
||||
// Init nuumber of falls and other things
|
||||
if (ctr_hand_stomp == 0) {
|
||||
lhand.play("stomp");
|
||||
rhand.play("stomp");
|
||||
if (EventScripts.send_property_to(rhand, "y", tl.y + 16, 0.5)) {
|
||||
ctr_hand_stomp++;
|
||||
nr_falls = max_nr_falls[cur_phase];
|
||||
lhand.my_shadow.visible = rhand.my_shadow.visible = true;
|
||||
}
|
||||
//Stomp the rhand back and forth, have the lhand sort of follow the player
|
||||
//state change when lhand stomps enough times
|
||||
} else if (ctr_hand_stomp == 1) {
|
||||
if (rhand.parabola_thing.tick()) {
|
||||
play_sfx("tap_ground");
|
||||
rhand_poof.exists = true;
|
||||
rhand_poof.play("poof");
|
||||
rhand_poof.x = rhand.x;
|
||||
rhand_poof.y = rhand.y;
|
||||
rhand.parabola_thing.reset_time();
|
||||
}
|
||||
if (rhand.offset.y <= 8 && rhand.my_shadow.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (s_hand_stomp_rhand == LEFT) {
|
||||
rhand.velocity.x = -rhand_stomp_vel;
|
||||
if (rhand.x < tl.x) {
|
||||
s_hand_stomp_rhand = RIGHT;
|
||||
}
|
||||
} else {
|
||||
rhand.velocity.x = rhand_stomp_vel;
|
||||
if (rhand.x > (tl.x + 16 * 8 - rhand.width)) {
|
||||
s_hand_stomp_rhand = LEFT;
|
||||
}
|
||||
}
|
||||
//rise and fall for lhand
|
||||
if (lhand.parabola_thing.t > (lhand.parabola_thing.period / 2)) {
|
||||
if (!played_sound) {
|
||||
play_sfx("fall");
|
||||
played_sound = true;
|
||||
}
|
||||
if (t_lhand_stomp > tm_lhand_stomp) {
|
||||
if (lhand.parabola_thing.tick()) {
|
||||
lhand_poof.exists = true;
|
||||
lhand_poof.play("poof");
|
||||
play_sfx("hit_ground");
|
||||
lhand_poof.x = lhand.x;
|
||||
lhand_poof.y = lhand.y;
|
||||
lhand.parabola_thing.reset_time();
|
||||
nr_falls--;
|
||||
played_sound = false;
|
||||
FlxG.shake(0.01, 0.2);
|
||||
//break the ground if damaged a bit
|
||||
if (!broke_ground && cur_phase >= 1) {
|
||||
FlxG.shake(0.02, 0.5);
|
||||
Registry.sound_data.floor_crack.play();
|
||||
if (break_ground()) {
|
||||
broke_ground = true;
|
||||
}
|
||||
}
|
||||
if (nr_falls == 0) {
|
||||
ctr_hand_stomp = 2;
|
||||
rhand.velocity.x = 0;
|
||||
rhand.my_shadow.visible = lhand.my_shadow.visible = false;
|
||||
}
|
||||
}
|
||||
if (lhand.offset.y < 8 && lhand.my_shadow.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
} else {
|
||||
t_lhand_stomp += FlxG.elapsed;
|
||||
}
|
||||
} else {
|
||||
EventScripts.send_property_to(lhand, "x", player.x, 1);
|
||||
EventScripts.send_property_to(lhand, "y", player.y - 16, 1);
|
||||
lhand.parabola_thing.tick();
|
||||
}
|
||||
//reset then return to float state
|
||||
} else if (ctr_hand_stomp == 2) {
|
||||
if (EventScripts.send_property_to(lhand, "y", lhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(lhand, "x", lhand_init_pt.x, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "y", rhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "x", rhand_init_pt.x, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand.offset, "y", 0, 2)) sub_ctr++;
|
||||
|
||||
if (sub_ctr == 5) {
|
||||
|
||||
lhand.play("idle");
|
||||
rhand.play("idle");
|
||||
s_hand = s_hand_float;
|
||||
ctr_hand_stomp = 0;
|
||||
|
||||
}
|
||||
}
|
||||
} else if (s_hand == s_hand_h_laser) {
|
||||
if (player.y < tl.y + 16) {
|
||||
player.y = tl.y + 16;
|
||||
}
|
||||
sub_ctr = 0;
|
||||
h_laser.x = lhand.x + 32;
|
||||
h_laser.y = lhand.y + 11;
|
||||
|
||||
if (h_laser.visible && !h_laser.flickering && (player.state != player.S_AIR) && h_laser.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
//Play shooting animation for hands, move them into position, flicker the laser, and then begin moving.
|
||||
if (s_hand_h_laser_ctr == 0) {
|
||||
h_laser.play("charge");
|
||||
rhand.play("shoot");
|
||||
lhand.play("shoot");
|
||||
if (EventScripts.send_property_to(lhand, "x", tl.x, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "x", tl.x + 96, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(lhand, "y", lhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "y", rhand_init_pt.y, 3)) sub_ctr++;
|
||||
if (sub_ctr == 4 && !h_laser.visible) {
|
||||
h_laser.visible = true;
|
||||
play_sfx("charge");
|
||||
h_laser.flicker(1.3);
|
||||
}
|
||||
|
||||
if (h_laser.visible && !h_laser.flickering) {
|
||||
s_hand_h_laser_ctr++;
|
||||
h_laser.play("move");
|
||||
lhand.velocity.y = rhand.velocity.y = 50;
|
||||
}
|
||||
} else if (s_hand_h_laser_ctr == 1) {
|
||||
if (lhand.y > tl.y + 16 * 5) {
|
||||
lhand.velocity.y = rhand.velocity.y = -65;
|
||||
s_hand_h_laser_ctr++;
|
||||
}
|
||||
} else if (s_hand_h_laser_ctr == 2) {
|
||||
if (lhand.y < tl.y + 18) {
|
||||
lhand.velocity.y = rhand.velocity.y = 80;
|
||||
s_hand_h_laser_ctr++;
|
||||
}
|
||||
} else if (s_hand_h_laser_ctr == 3) {
|
||||
if (lhand.y > tl.y + 16 * 5) {
|
||||
s_hand_h_laser_ctr++;
|
||||
lhand.velocity.y = rhand.velocity.y = -20;
|
||||
}
|
||||
} else {
|
||||
if (EventScripts.send_property_to(lhand, "y", lhand_init_pt.y, 1.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(lhand, "x", lhand_init_pt.x, 1.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "y", rhand_init_pt.y, 1.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(rhand, "x", rhand_init_pt.x, 1.5)) sub_ctr++;
|
||||
if (sub_ctr == 4) {
|
||||
h_laser.visible = false;
|
||||
lhand.velocity.y = rhand.velocity.y = 0;
|
||||
s_hand = s_hand_float;
|
||||
lhand.play("idle");
|
||||
rhand.play("idle");
|
||||
s_hand_h_laser_ctr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (s_hand == s_hand_dying) {
|
||||
|
||||
if (Registry.sound_data.current_song.playing) {
|
||||
rhand.velocity.x = rhand.velocity.y = lhand.velocity.x = lhand.velocity.y = 0;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
FlxG.flash(0xffffffff, 3);
|
||||
t_dying = tm_dying;
|
||||
}
|
||||
if (t_dying > 0) {
|
||||
t_dying -= FlxG.elapsed;
|
||||
death_explosions.exists = true;
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
FlxG.shake(0.02, 0.1, null, true);
|
||||
|
||||
|
||||
rhand.alpha -= fade_out_alpha_rate;
|
||||
lhand.alpha -= fade_out_alpha_rate;
|
||||
rhand.my_shadow.alpha -= fade_out_alpha_rate;
|
||||
lhand.my_shadow.alpha -= fade_out_alpha_rate;
|
||||
|
||||
if (death_explosion_timer < 0) {
|
||||
death_explosion_timer = tm_de;
|
||||
for each (var de:FlxSprite in death_explosions.members) {
|
||||
if (!de.visible) {
|
||||
de.visible = true;
|
||||
de.play("explode");
|
||||
de.x = wall.x + (160 - de.width) * Math.random();
|
||||
de.y = wall.y + 32 * Math.random();
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.enemy_explode_1_group);
|
||||
break;
|
||||
} else {
|
||||
if (de._curAnim.frames.length - 1 == de._curFrame) {
|
||||
de.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
death_explosion_timer -= FlxG.elapsed;
|
||||
}
|
||||
if (rhand.alpha <= 0.03 && lhand.alpha <= 0.03) {
|
||||
s_hand = s_hand_dead;
|
||||
h_laser.visible = false;
|
||||
rhand.my_shadow.visible = false;
|
||||
lhand.my_shadow.visible = false;
|
||||
}
|
||||
} else if (s_hand == s_hand_dead) {
|
||||
lhand.velocity.x = rhand.velocity.x = lhand.velocity.y = rhand.velocity.y = 0;
|
||||
|
||||
}
|
||||
|
||||
//laser attacks
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function choose_attack():void {
|
||||
var r:Number = Math.random();
|
||||
switch (cur_phase) {
|
||||
case 0:
|
||||
if (r <= 0.7) {
|
||||
s_hand = s_hand_stomp;
|
||||
} else {
|
||||
s_hand = s_hand_push;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (r <= 0.35) {
|
||||
s_hand = s_hand_h_laser;
|
||||
} else if (r <= 0.7) {
|
||||
s_hand = s_hand_stomp;
|
||||
} else {
|
||||
s_hand = s_hand_push;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (r <= 0.5) {
|
||||
s_hand = s_hand_h_laser;
|
||||
} else if (r <= 0.75) {
|
||||
s_hand = s_hand_stomp;
|
||||
} else {
|
||||
s_hand = s_hand_push;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function set_shadow_size(fist:FlxSprite):void {
|
||||
var y_off:int = fist.offset.y;
|
||||
|
||||
if (y_off >= 29) {
|
||||
fist.my_shadow.frame = 0;
|
||||
} else if (y_off >= 24) {
|
||||
fist.my_shadow.frame = 1;
|
||||
} else if (y_off >= 16) {
|
||||
fist.my_shadow.frame = 2;
|
||||
} else if (y_off >= 8) {
|
||||
fist.my_shadow.frame = 3;
|
||||
} else {
|
||||
fist.my_shadow.frame = 4;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Breaks the ground in the 6th row of the play area
|
||||
*/
|
||||
private function break_ground():int {
|
||||
var tile_indices:Array = new Array(62, 63, 64, 65, 66, 67);
|
||||
var cracked_index:int = 71;
|
||||
var is_broken:Boolean = false;
|
||||
for each (var index:int in tile_indices) {
|
||||
var tm:FlxTilemap = parent.curMapBuf;
|
||||
if (tm.getTileByIndex(index) != cracked_index) {
|
||||
tm.setTileByIndex(index, cracked_index, true);
|
||||
} else {
|
||||
tm.setTileByIndex(index, 81, true);
|
||||
is_broken = true;
|
||||
}
|
||||
}
|
||||
|
||||
return is_broken ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function, sets the some of the next push properties
|
||||
*/
|
||||
private function set_next_push():void {
|
||||
|
||||
if (Math.random() < p_double_push[cur_phase]) {
|
||||
push_type = 2; //Both hands
|
||||
} else {
|
||||
if (Math.random() <= 0.5) {
|
||||
push_type = 0;
|
||||
} else {
|
||||
push_type = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(face, true);
|
||||
parent.sortables.remove(lhand, true);
|
||||
parent.sortables.remove(rhand, true);
|
||||
|
||||
max_nr_falls = null;
|
||||
p_double_push = null;
|
||||
push_y_vel = null;
|
||||
max_nr_pushes = null;
|
||||
|
||||
tl = null;
|
||||
|
||||
wall = null;
|
||||
death_explosions = null;
|
||||
face = null;
|
||||
lhand_init_pt = rhand_init_pt = null;
|
||||
rhand = lhand = null;
|
||||
lhand_poof = rhand_poof = null;
|
||||
face_bullets = null;
|
||||
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,195 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.system.FlxTile;
|
||||
|
||||
public class Chaser extends FlxSprite
|
||||
{
|
||||
private var xml:XML;
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
|
||||
|
||||
private var state:int;
|
||||
private const s_idle:int = 0;
|
||||
private const s_moving:int = 1;
|
||||
|
||||
private var dame_type:int;
|
||||
private var dt_hori:int = 0;
|
||||
private var dt_vert:int = 1;
|
||||
|
||||
private var float_vel:int = 15;
|
||||
|
||||
private var tl:Point;
|
||||
|
||||
private var lookahead:Point;
|
||||
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/etc/chaser.png")] public static var embed_chaser_sprite:Class;
|
||||
|
||||
public function Chaser(_xml:XML, _player:Player, _parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
dame_type = parseInt(xml.@frame);
|
||||
|
||||
state = s_idle;
|
||||
|
||||
tl = new Point(Registry.CURRENT_GRID_X * 160, Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT);
|
||||
lookahead = new Point(0, 0);
|
||||
|
||||
|
||||
loadGraphic(embed_chaser_sprite, true, false, 16, 32);
|
||||
width = height = 8;
|
||||
offset.y = 20;
|
||||
offset.x = 4;
|
||||
x += 4;
|
||||
y += 20;
|
||||
// MARINA_ANIMS
|
||||
if (dame_type == dt_hori) {
|
||||
frame = 6;
|
||||
} else {
|
||||
frame = 4;
|
||||
}
|
||||
addAnimation("d", [4, 5], 8);
|
||||
addAnimation("r", [6,7], 8);
|
||||
addAnimation("u", [8, 9], 8);
|
||||
addAnimation("l", [10,11], 8);
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.mover_move_group);
|
||||
}
|
||||
|
||||
if (player.broom.visible) {
|
||||
if (Math.abs(velocity.x) < 100 && Math.abs(velocity.y) < 100) {
|
||||
velocity.x *= 1.025;
|
||||
velocity.y *= 1.025;
|
||||
}
|
||||
} else {
|
||||
float_vel = 15;
|
||||
}
|
||||
switch (state) {
|
||||
case s_idle:
|
||||
|
||||
if (dame_type == dt_hori) {
|
||||
if (player.y > y - player.height && player.y < y + height) {
|
||||
state = s_moving;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.mover_die_group);
|
||||
if (player.x > x) {
|
||||
velocity.x = float_vel;
|
||||
play("r");
|
||||
} else {
|
||||
velocity.x = -float_vel;
|
||||
play("l");
|
||||
}
|
||||
}
|
||||
} else if (dame_type == dt_vert) {
|
||||
if (player.x + player.width > x && player.x < x + width) {
|
||||
state = s_moving;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.mover_die_group);
|
||||
if (player.y > y) {
|
||||
play("d");
|
||||
velocity.y = float_vel;
|
||||
} else {
|
||||
play("u");
|
||||
velocity.y = -float_vel;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case s_moving:
|
||||
if (EventScripts.get_tile_allow_collisions(lookahead.x,lookahead.y,parent.curMapBuf)) {
|
||||
switch (facing) {
|
||||
case UP:
|
||||
facing = DOWN;
|
||||
play("d");
|
||||
velocity.y *= -1;
|
||||
break;
|
||||
case DOWN:
|
||||
play("u");
|
||||
facing = UP;
|
||||
velocity.y *= -1;
|
||||
break;
|
||||
case LEFT:
|
||||
play("r");
|
||||
facing = RIGHT;
|
||||
velocity.x *= -1;
|
||||
break;
|
||||
case RIGHT:
|
||||
play("l");
|
||||
facing = LEFT;
|
||||
velocity.x *= -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Now update the lookahead point to reflect the possible state change above
|
||||
if (facing & (UP | DOWN)) {
|
||||
if (facing & UP) {
|
||||
lookahead.y = y;
|
||||
lookahead.x = x + width / 2;
|
||||
} else {
|
||||
lookahead.x = x + width / 2;
|
||||
lookahead.y = y + height;
|
||||
}
|
||||
} else {
|
||||
if (facing & RIGHT) {
|
||||
lookahead.x = x + width;
|
||||
lookahead.y = y + height / 2;
|
||||
} else {
|
||||
lookahead.x = x;
|
||||
lookahead.y = y + height / 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to kill the player
|
||||
if (player.overlaps(this)) {
|
||||
player.touchDamage(6);
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function on_anim_change(name:String, frame:int, index:int):void {
|
||||
switch (name) {
|
||||
case "u":
|
||||
facing = UP;
|
||||
break;
|
||||
case "d":
|
||||
facing = DOWN;
|
||||
break;
|
||||
case "l":
|
||||
facing = LEFT;
|
||||
break;
|
||||
case "r":
|
||||
facing = RIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
tl = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import global.Keys;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.FlxBitmapFont;
|
||||
import global.Registry;
|
||||
import states.ControlsState;
|
||||
import states.PlayState;
|
||||
import flash.events.KeyboardEvent;
|
||||
import entity.player.Player;
|
||||
|
||||
/**
|
||||
* straightforward, an invisible event thing that
|
||||
* lets you set hte movement controls
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class ControlsDeity extends FlxSprite
|
||||
{//FUCK IT!!!
|
||||
|
||||
public var cid:int = CLASS_ID.CONTROLSDEITY;
|
||||
public var xml:XML;
|
||||
public var text:FlxBitmapFont = new FlxBitmapFont(Registry.C_FONT_BLACK, 8, 8, Registry.C_FONT_BLACK_STRING, 27);
|
||||
public var state:int = 1;
|
||||
public var S_CONTROL:int = 0;
|
||||
public var control_ctr:int = 0;
|
||||
public var S_NORMAL:int = 1;
|
||||
public var normal_ctr:int = 0;
|
||||
public var S_CONTROL_2:int = 2;
|
||||
public var recent_key_code:int = 1000;
|
||||
|
||||
public var player:Player;
|
||||
public var input:String = " ";
|
||||
public var portal:FlxSprite = new FlxSprite(120, 100);
|
||||
public var type:int = 0;
|
||||
public var T_1:int = 0;
|
||||
public var T_2:int = 1;
|
||||
public function ControlsDeity(x:int,y:int,_xml:XML,_player:Player)
|
||||
{
|
||||
super(x, y);
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
|
||||
makeGraphic(1, 1, 0xffffffff);
|
||||
|
||||
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
|
||||
portal.makeGraphic(16, 16, 0xffffff00);
|
||||
portal.visible = false;
|
||||
|
||||
if (parseInt(xml.@frame) == 1) type = T_2;
|
||||
|
||||
if (type == T_1) {
|
||||
text.setText(" \nMove. \n" + Registry.controls[Keys.IDX_UP] +", " + Registry.controls[Keys.IDX_DOWN]
|
||||
+ ",\n" + Registry.controls[Keys.IDX_LEFT] + ", " + Registry.controls[Keys.IDX_RIGHT] +
|
||||
"\nESC to\nchange controls.",
|
||||
true, 0, 0, "center", true);
|
||||
text.x = 10;
|
||||
text.y = 24;
|
||||
} else if (type == T_2) {
|
||||
text.setText("Interact. \nUse " + Registry.controls[Keys.IDX_ACTION_1] + " or " + Registry.controls[Keys.IDX_ACTION_2]
|
||||
+ ".\nESC to \nchange controls.", true, 0, 0, "center", true);
|
||||
//text.scrollFactor = new FlxPoint(0, 0);
|
||||
text.x = 5 + 320; //hehheh
|
||||
text.y = 24;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
super.update();
|
||||
switch (state) {
|
||||
case S_CONTROL:
|
||||
update_control();
|
||||
break;
|
||||
case S_CONTROL_2:
|
||||
update_control_2();
|
||||
break;
|
||||
case S_NORMAL:
|
||||
if (FlxG.keys.justPressed("SPACE")) {
|
||||
if (type == T_2)
|
||||
state = S_CONTROL_2;
|
||||
else
|
||||
state = S_CONTROL;
|
||||
player.dontMove = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public function update_control_2():void {
|
||||
|
||||
if (recent_key_code != 1000) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
input = FlxG.keys.getKeyName(recent_key_code);
|
||||
trace(input);
|
||||
recent_key_code = 1000;
|
||||
if (input == "SPACE") {
|
||||
input = " ";
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (control_ctr) {
|
||||
case 0:
|
||||
text.text = "Press what you want\nto use for\naction 1.";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_ACTION_1, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_ACTION_1] = input;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
text.text = "Press what you want\nto use to for\n action 2\n";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_ACTION_2, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_ACTION_2] = input;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
text.setText("Interact. \nUse " + Registry.controls[Keys.IDX_ACTION_1] + " or " + Registry.controls[Keys.IDX_ACTION_2]
|
||||
+ ".\nESC to \nchange controls.", true, 0, 0, "center", true);
|
||||
control_ctr = 0;
|
||||
state = S_NORMAL;
|
||||
player.dontMove = false;
|
||||
break;
|
||||
}
|
||||
input = " ";
|
||||
return;
|
||||
}
|
||||
public function update_control():void {
|
||||
if (recent_key_code != 1000) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
input = FlxG.keys.getKeyName(recent_key_code);
|
||||
trace(input);
|
||||
recent_key_code = 1000;
|
||||
if (input == "SPACE") {
|
||||
input = " ";
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (control_ctr) {
|
||||
case 0:
|
||||
text.text = "Press what you want\nto use to move\nupwards.\n";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_UP, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_UP] = input;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
text.text = "Press what you want\nto use to move\ndownwards.\n";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_DOWN, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_DOWN] = input;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
text.text = "Press what you want\nto use to move\nto the left.\n";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_LEFT, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_LEFT] = input;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
text.text = "Press what you want\nto use to move\nto the right.\n";
|
||||
if (input != " ") {
|
||||
if (is_valid(Keys.IDX_RIGHT, input)) break;
|
||||
control_ctr++;
|
||||
Registry.controls[Keys.IDX_RIGHT] = input;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
text.setText("Move here with\n" + Registry.controls[Keys.IDX_UP] +", " + Registry.controls[Keys.IDX_DOWN]
|
||||
+ ",\n" + Registry.controls[Keys.IDX_LEFT] + ", " + Registry.controls[Keys.IDX_RIGHT] +
|
||||
"\nPress ESC to set\ndifferent controls",
|
||||
true, 0, 0, "center", true);
|
||||
control_ctr = 0;
|
||||
state = S_NORMAL;
|
||||
player.dontMove = false;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
input = " ";
|
||||
return;
|
||||
}
|
||||
|
||||
public function is_valid(index:int, input:String):int {
|
||||
trace("----");
|
||||
trace("input: ", input);
|
||||
for (var i:int = 0; i < index; i++) {
|
||||
trace(Registry.controls[i]);
|
||||
if (input == "ESCAPE") return 1;
|
||||
if (Registry.controls[i] == input) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
public function reportKeyDown(event:KeyboardEvent):void {
|
||||
recent_key_code = event.keyCode;
|
||||
}
|
||||
|
||||
override public function destroy():void {
|
||||
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Follower_Bro extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/npcs/follower_bro.png")] public static var sprite_follower:Class;
|
||||
public var player_ref:Player;
|
||||
public var cid:int = CLASS_ID.FOLLOWER_BRO;
|
||||
public var xml:XML;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_hidden:int = 0;
|
||||
private var s_walk:int = 1;
|
||||
private var s_gone:int = 2;
|
||||
private var s_disappearing:int = 3;
|
||||
public function Follower_Bro(_xml:XML,p:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
player_ref = p;
|
||||
xml = _xml;
|
||||
loadGraphic(sprite_follower, true, false, 16, 24);
|
||||
addAnimation("walk", [1, 2, 1, 0], 4, true);
|
||||
alpha = 0;
|
||||
immovable = true;
|
||||
trace("makin bro");
|
||||
if (xml.@alive == "false") {
|
||||
state = s_gone;
|
||||
visible = solid = false;
|
||||
}
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
switch (state) {
|
||||
case s_hidden:
|
||||
solid = false;
|
||||
if (player_ref.y - y < -20) {
|
||||
player_ref.dontMove = true;
|
||||
alpha += 0.02;
|
||||
}
|
||||
if (alpha > 0.96) {
|
||||
player_ref.dontMove = false;
|
||||
state = s_walk;
|
||||
}
|
||||
break;
|
||||
case s_walk:
|
||||
if (FlxG.overlap(player_ref, this)) state = s_disappearing;
|
||||
solid = true;
|
||||
if (player_ref.y > y) {
|
||||
velocity.y = velocity.x = 0;
|
||||
frame = 1;
|
||||
} else {
|
||||
velocity.y = -10;
|
||||
velocity.x = (player_ref.x > x) ? 10 : -10;
|
||||
play("walk");
|
||||
}
|
||||
break;
|
||||
case s_gone:
|
||||
return;
|
||||
case s_disappearing:
|
||||
alpha -= 0.02;
|
||||
if (alpha <= 0) {
|
||||
visible = solid = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
xml.@alive = "false";
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Red_Walker extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/redwalker.png")] public static var sprite_redwalker:Class;
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.RED_WALKER;
|
||||
public var tl:Point;
|
||||
|
||||
public var player:Player;
|
||||
public function Red_Walker(_xml:XML,_player:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
loadGraphic(sprite_redwalker, true, false, 32, 48);
|
||||
addAnimation("walk", [0, 1, 2, 3, 4], 5, true);
|
||||
play("walk");
|
||||
|
||||
velocity.x = 5 + 15 * Math.random();
|
||||
_curFrame = int(5 * Math.random());
|
||||
player = _player;
|
||||
immovable = true;
|
||||
|
||||
width = 20;
|
||||
height = 8;
|
||||
offset.x = 4;
|
||||
x += 4;
|
||||
offset.y = 40;
|
||||
y += 40;
|
||||
|
||||
tl = new Point(Registry.CURRENT_GRID_X * 160, Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT);
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
FlxG.collide(this, player);
|
||||
|
||||
if (velocity.x > 0 && x + width > tl.x + 160) {
|
||||
velocity.x *= -1;
|
||||
scale.x *= -1;
|
||||
} else if (velocity.x < 0 && x < tl.x) {
|
||||
velocity.x *= -1;
|
||||
scale.x *= -1;
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Sadbro extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var p:Player;
|
||||
[Embed (source = "../../../res/sprites/npcs/sadman.png")] public static var sadman_sprite:Class;
|
||||
|
||||
public var active_region:FlxObject;
|
||||
public function Sadbro(_xml:XML,player:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
loadGraphic(sadman_sprite,true, false, 16, 16);
|
||||
addAnimation("a", [0, 1], 2, true);
|
||||
play("a");
|
||||
immovable = true;
|
||||
p = player;
|
||||
|
||||
active_region = new FlxObject(x, y, 20, 20);
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(p, this);
|
||||
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
|
||||
if (p.overlaps(active_region) && p.state == p.S_GROUND) {
|
||||
// Don't let player attack/jump
|
||||
if (Registry.keywatch.JP_ACTION_1 && Registry.GAMESTATE.state == Registry.GAMESTATE.S_NORMAL ) {
|
||||
EventScripts.face_and_play(Registry.GAMESTATE.player, this, "idle");
|
||||
// don't let player logic register an attack if player updated after
|
||||
Registry.keywatch.JP_ACTION_1 = false;
|
||||
//Make sure first things is said
|
||||
if (DH.scene_is_dirty(DH.name_sadbro, DH.scene_sadbro_overworld_initial_forced)) {
|
||||
// check if visited the bedroom
|
||||
if (Registry.GE_States[Registry.GE_Bedroom_Visited]) {
|
||||
//If boss dead...
|
||||
if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) {
|
||||
DH.start_dialogue(DH.name_sadbro, DH.scene_sadbro_overworld_bedroom_done)
|
||||
|
||||
//otherwise...
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_sadbro, DH.scene_sadbro_overworld_bedroom_not_done);
|
||||
}
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_sadbro, DH.scene_sadbro_overworld_initial_forced);
|
||||
}
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_sadbro, DH.scene_sadbro_overworld_initial_forced);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,881 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import entity.gadget.Dust;
|
||||
import entity.interactive.npc.Sage;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Sage_Boss extends AnoSprite
|
||||
{
|
||||
|
||||
private const S_RESET:int = -1; // going betwen substates of ACTIVE state
|
||||
private const S_WAITING:int = 0; // intro
|
||||
private const S_ACTIVE:int = 1; // fighting
|
||||
private const S_DYING:int = 2;
|
||||
private const S_DEAD:int = 3;
|
||||
|
||||
private var active_substate:int = 0;
|
||||
private var substate_ctr:int = 0;
|
||||
|
||||
private var gt:Number = 0; // generic timer
|
||||
|
||||
private var s_bullets:FlxGroup = new FlxGroup(6);
|
||||
private var l_bullets:FlxGroup = new FlxGroup(6);
|
||||
private var dusts:FlxGroup = new FlxGroup(2);
|
||||
|
||||
private var do_s1_debug:Boolean = false;
|
||||
private var do_s2_debug:Boolean = false;
|
||||
private var do_s3_debug:Boolean = false;
|
||||
private var do_s4_debug:Boolean = false;
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/etc/sage_fight_long_dust.png")] public static var embed_long_dust:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/etc/sage_attacks.png")] public static var embed_sage_attacks:Class;
|
||||
[Embed(source="../../../res/sprites/enemies/etc/sage_fight_long_dust.png")] public static var embed_sage_long_attacks:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/etc/sage_boss.png")] public static var embed_sage_boss:Class;
|
||||
|
||||
public function Sage_Boss(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
// MARINA_ANIMS
|
||||
loadGraphic(embed_sage_boss, true, false, 16, 24);
|
||||
addAnimation("a", [0, 4], 10, true);
|
||||
addAnimation("idle", [4]);
|
||||
addAnimation("idle_d", [0, 1, 2, 3], 5, true);
|
||||
addAnimation("dash_d",[0, 1, 2, 3], 5, true);
|
||||
addAnimation("dash_u", [0, 1, 2, 3], 5, true);
|
||||
addAnimation("walk_u", [0, 1, 2, 3], 5, true);
|
||||
play("idle");
|
||||
width = height = 10;
|
||||
offset.x = offset.y = 3;
|
||||
offset.y = 8;
|
||||
|
||||
x = tl.x + 72;
|
||||
x += 3; y += 3;
|
||||
|
||||
// 16x16 dust-razors
|
||||
for (var i:int = 0; i < s_bullets.maxSize; i++) {
|
||||
var b:FlxSprite = new FlxSprite(0, 0);
|
||||
b.loadGraphic(embed_sage_attacks, true, false, 16, 16);
|
||||
b.addAnimation("spin", [0, 1], 24, true);
|
||||
b.addAnimation("poof", [0,1,2], 12, false);
|
||||
b.addAnimation("shoot", [4,5], 12);
|
||||
b.play("spin");
|
||||
b.width = b.height = 8;
|
||||
b.offset.x = b.offset.y = 4;
|
||||
|
||||
s_bullets.add(b);
|
||||
}
|
||||
s_bullets.setAll("exists", false);
|
||||
parent.sortables.add(s_bullets);
|
||||
|
||||
// 64x16 dust razors
|
||||
for (i = 0; i < l_bullets.maxSize; i++) {
|
||||
b = new FlxSprite(0, 0);
|
||||
b.loadGraphic(embed_sage_long_attacks, true, false, 64, 16);
|
||||
b.addAnimation("spin", [0,1], 24, true);
|
||||
b.addAnimation("poof", [0,1,2], 12, false);
|
||||
b.play("spin");
|
||||
b.width = 56; b.height = 10;
|
||||
b.offset.x = 4; b.offset.y = 3;
|
||||
|
||||
l_bullets.add(b);
|
||||
}
|
||||
l_bullets.setAll("exists", false);
|
||||
parent.sortables.add(l_bullets);
|
||||
|
||||
// Dusts
|
||||
for (i = 0; i < dusts.maxSize; i++) {
|
||||
var d:Dust = new Dust(0, 0, null, parent);
|
||||
dusts.add(d)
|
||||
d.y = tl.y + 8 * 16;
|
||||
if (i == 0) {
|
||||
d.x = tl.x + 48;
|
||||
} else {
|
||||
d.x = tl.x + 48 + 48;
|
||||
}
|
||||
|
||||
}
|
||||
//parent.bg_sprites.add(dusts);
|
||||
|
||||
//sfx
|
||||
add_sfx("warp_out", Registry.sound_data.teleguy_up);
|
||||
add_sfx("warp_in", Registry.sound_data.teleguy_down);
|
||||
add_sfx("hurt", Registry.sound_data.broom_hit);
|
||||
|
||||
xml.@p = "2";
|
||||
// If we don't have all cards or are already dead don't show up.
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
} else {
|
||||
state = S_WAITING;
|
||||
}
|
||||
|
||||
|
||||
if (Registry.FUCK_IT_MODE_ON) {
|
||||
exists = true;
|
||||
}
|
||||
|
||||
|
||||
// Debug flags, for skipping to certain stages of the fight
|
||||
//do_s2_debug = true;
|
||||
//do_s1_debug = true;
|
||||
//do_s3_debug = true;
|
||||
//do_s4_debug = true;
|
||||
if (do_s1_debug) {
|
||||
state = S_ACTIVE;
|
||||
substate_ctr = 0;
|
||||
active_substate = 1;
|
||||
} else if (do_s2_debug) {
|
||||
state = S_RESET;
|
||||
active_substate = 1;
|
||||
substate_ctr = 0;
|
||||
} else if (do_s3_debug) {
|
||||
state = S_RESET;
|
||||
active_substate = 2;
|
||||
substate_ctr = 0;
|
||||
} else if (do_s4_debug) {
|
||||
state = S_RESET;
|
||||
active_substate = 3;
|
||||
substate_ctr = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(s_bullets,true);
|
||||
if (s_bullets != null) s_bullets.destroy();
|
||||
s_bullets = null;
|
||||
|
||||
parent.sortables.remove(l_bullets,true);
|
||||
if (l_bullets != null) l_bullets.destroy();
|
||||
l_bullets = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
if (state == S_WAITING) {
|
||||
// Idle around
|
||||
wait_state();
|
||||
} else if (state == S_ACTIVE) {
|
||||
active_state();
|
||||
} else if (state == S_DYING) {
|
||||
dying_state();
|
||||
// Exit speech, etc
|
||||
} else if (state == S_DEAD) {
|
||||
// Cleanup and modify global state.
|
||||
Registry.GE_States[Registry.GE_Sage_Dead_Idx] = true;
|
||||
xml.@alive = "false";
|
||||
exists = false;
|
||||
Registry.sound_data.start_song_from_title("TERMINAL");
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
} else if (state == S_RESET) {
|
||||
reset_state();
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
// Logic for fight
|
||||
private function active_state():void {
|
||||
|
||||
switch (active_substate) {
|
||||
case 1:
|
||||
stage_1();
|
||||
break;
|
||||
case 2:
|
||||
stage_2();
|
||||
break;
|
||||
case 3:
|
||||
stage_3();
|
||||
break;
|
||||
case 4:
|
||||
stage_4();
|
||||
break;
|
||||
}
|
||||
dust_routine(1);
|
||||
}
|
||||
|
||||
|
||||
// Intro stuff.
|
||||
private function wait_state():void {
|
||||
if (substate_ctr == 0) {
|
||||
facing = DOWN;
|
||||
play("idle");
|
||||
substate_ctr++;
|
||||
|
||||
|
||||
} else if (substate_ctr == 1) {
|
||||
Registry.volume_scale = (Registry.volume_scale > 0) ? Registry.volume_scale -= 0.01 : 0;
|
||||
if (Registry.volume_scale != 0) return;
|
||||
|
||||
if (EventScripts.distance(this, player) < 32 && player.state == player.S_GROUND) {
|
||||
player.be_idle();
|
||||
player.state = player.S_INTERACT;
|
||||
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_before_fight, Registry.CURRENT_MAP_NAME);
|
||||
|
||||
Registry.sound_data.stop_current_song();
|
||||
|
||||
substate_ctr++;
|
||||
}
|
||||
} else if (substate_ctr == 2) {
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
substate_ctr++;
|
||||
play("idle_d");
|
||||
play_sfx("warp_out");
|
||||
alpha = 0;
|
||||
visible = false;
|
||||
x = tl.x + 80 - width / 2;
|
||||
y = tl.y + 24;
|
||||
}
|
||||
} else if (substate_ctr == 3) {
|
||||
// relaly bad timing hacks
|
||||
alpha += 0.008;
|
||||
if (alpha >= 0.4) {
|
||||
visible = true;
|
||||
if (alpha <= 0.43) {
|
||||
play_sfx("warp_in");
|
||||
}
|
||||
|
||||
if (alpha == 1) {
|
||||
substate_ctr++;
|
||||
Registry.sound_data.start_song_from_title("SAGEFIGHT");
|
||||
Registry.volume_scale = 1;
|
||||
FlxG.flash(0xff000000, 2.18);
|
||||
FlxG.shake(0.02, 1.5);
|
||||
}
|
||||
}
|
||||
} else if (substate_ctr == 4) {
|
||||
alpha += 0.07;
|
||||
if (alpha >= 1) {
|
||||
|
||||
substate_ctr++;
|
||||
}
|
||||
} else if (substate_ctr == 5) {
|
||||
|
||||
gt += FlxG.elapsed;
|
||||
|
||||
if (gt > 2.18) {
|
||||
gt = 0;
|
||||
FlxG.flash(0xff000000, 2.15);
|
||||
FlxG.shake(0.025, 1.5);
|
||||
substate_ctr++;
|
||||
}
|
||||
} else if (substate_ctr == 6) {
|
||||
gt += FlxG.elapsed;
|
||||
|
||||
x = tl.x + 40 + 60 * Math.random();
|
||||
y = tl.y + 70 - 40 * Math.random();
|
||||
|
||||
if (gt > 2.16) {
|
||||
gt = 0;
|
||||
FlxG.flash(0xff000000, 2.15);
|
||||
FlxG.shake(0.03, 1.5);
|
||||
x = player.x - 2;
|
||||
y = player.y - 16;
|
||||
substate_ctr++;
|
||||
}
|
||||
|
||||
} else if (substate_ctr == 7) {
|
||||
gt += FlxG.elapsed;
|
||||
if (gt > 2.15) {
|
||||
gt = 0;
|
||||
|
||||
x = tl.x + 80 - width / 2;
|
||||
y = tl.y + 25;
|
||||
|
||||
FlxG.flash(0xff000000, 6);
|
||||
FlxG.shake(0.035, 1.7);
|
||||
substate_ctr++;
|
||||
alpha = 0;
|
||||
}
|
||||
} else if (substate_ctr == 8) {
|
||||
alpha += 0.005;
|
||||
if (alpha == 1) {
|
||||
substate_ctr++;
|
||||
}
|
||||
} else {
|
||||
state = S_ACTIVE;
|
||||
substate_ctr = 0;
|
||||
active_substate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private const s1_vel:int = 50;
|
||||
private var t_s1:Number = 0;
|
||||
private var tm_s1:Array = new Array(1.6, 1.4, 1.2);
|
||||
private const s1_max_health:int = 3;
|
||||
private var s1_health:int = 3;
|
||||
|
||||
/**
|
||||
* Stage 1: Razors become large razors, sweep vertically, must jump forward to reach and hit sage
|
||||
*/
|
||||
private function stage_1():void {
|
||||
|
||||
var b:FlxSprite;
|
||||
// Periodically shoot
|
||||
t_s1 += FlxG.elapsed;
|
||||
if (t_s1 > tm_s1[s1_max_health - s1_health]) {
|
||||
b = l_bullets.getFirstAvailable() as FlxSprite;
|
||||
if (b != null) {
|
||||
b.play("spin");
|
||||
b.exists = true;
|
||||
b.x = tl.x + 48 + (64 - b.width) / 2;
|
||||
b.y = tl.y + 20;
|
||||
b.velocity.y = s1_vel;
|
||||
}
|
||||
|
||||
t_s1 = 0;
|
||||
|
||||
}
|
||||
|
||||
// Check to destroy some bullets
|
||||
// Dust or wall
|
||||
for each (b in l_bullets.members) {
|
||||
if (b != null && b.exists) {
|
||||
if (b.y > tl.y + 16 * 9) {
|
||||
if (b._curAnim.name != "poof") {
|
||||
b.play("poof");
|
||||
} else {
|
||||
if (b.finished) {
|
||||
b.exists = false;
|
||||
b.velocity.y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check to hurt player
|
||||
|
||||
for each (b in l_bullets.members) {
|
||||
if (b != null && b.exists) {
|
||||
if (player.state == player.S_GROUND) {
|
||||
if (b.overlaps(player) && b._curAnim.name != "poof") {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*if (b.overlaps(dusts.members[0]) || b.overlaps(dusts.members[1])) {
|
||||
b.play("poof");
|
||||
b.exists = false;
|
||||
b.velocity.y = 0;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
// Check if boss hurt
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(this)) {
|
||||
flicker(1);
|
||||
play_sfx("hurt");
|
||||
s1_health--;
|
||||
}
|
||||
|
||||
|
||||
if (s1_health <= 0) {
|
||||
l_bullets.setAll("x", -1000);
|
||||
state = S_RESET;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stage 2: Razors go to ends of bridge, sage dashes up and down with razors in front and back
|
||||
*/
|
||||
private const s2_max_health:int = 3;
|
||||
private var s2_health:int = 3;
|
||||
private var s2_dash_vel:Array = new Array(50, 70, 90);
|
||||
|
||||
private var s2_d1:FlxSprite;
|
||||
private var s2_d2:FlxSprite;
|
||||
private var s2_set_vel:Boolean = false;
|
||||
|
||||
private function stage_2():void {
|
||||
// Wait for sage to stop flickering
|
||||
if (substate_ctr == 0) {
|
||||
if (!flickering) {
|
||||
substate_ctr++;
|
||||
}
|
||||
return;
|
||||
// Make long dusts appear flicker for a bit
|
||||
} else if (substate_ctr == 1) {
|
||||
for (var i:int = 0; i < 2; i++) {
|
||||
var ld:FlxSprite = l_bullets.getFirstAvailable() as FlxSprite;
|
||||
ld.velocity.x = ld.velocity.y = 0;
|
||||
ld.exists = true;
|
||||
ld.play("spin");
|
||||
ld.x = tl.x + 48 + (64 - ld.width) / 2;
|
||||
if (i == 0) {
|
||||
ld.y = tl.y + 16 + (16 - ld.height) / 2;
|
||||
} else {
|
||||
ld.y = tl.y + 8 * 16 + (16 - ld.height) / 2;
|
||||
}
|
||||
ld.flicker(1);
|
||||
}
|
||||
substate_ctr ++ ;
|
||||
return;
|
||||
// Start fight when lds stop flickering
|
||||
} else if (substate_ctr == 2) {
|
||||
ld = l_bullets.getFirstExtant() as FlxSprite;
|
||||
if (!ld.flickering) {
|
||||
substate_ctr++;
|
||||
s2_d1 = s_bullets.getFirstAvailable() as FlxSprite;
|
||||
s2_d1.exists = true;
|
||||
s2_d2 = s_bullets.getFirstAvailable() as FlxSprite;
|
||||
s2_d2.exists = true;
|
||||
}
|
||||
velocity.x = 40;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Snap dusts to sage
|
||||
s2_d1.x = x + (width - s2_d1.width) / 2;
|
||||
s2_d2.x = x + (width - s2_d2.width) / 2;
|
||||
|
||||
s2_d1.y = y - 10;
|
||||
s2_d2.y = y + 12;
|
||||
|
||||
// Dash up and down
|
||||
if (substate_ctr == 3) { // Down
|
||||
if (!s2_set_vel) {
|
||||
velocity.y = s2_dash_vel[s2_max_health - s2_health];
|
||||
s2_set_vel = true;
|
||||
play("dash_d");
|
||||
}
|
||||
if (y > tl.y + 16 * 8) {
|
||||
substate_ctr = 4;
|
||||
s2_set_vel = false;
|
||||
}
|
||||
} else if (substate_ctr == 4) {
|
||||
if (!s2_set_vel) {
|
||||
play("dash_u");
|
||||
velocity.y = -s2_dash_vel[s2_max_health - s2_health];
|
||||
s2_set_vel = true;
|
||||
}
|
||||
if (y < tl.y + 16) {
|
||||
substate_ctr = 3;
|
||||
s2_set_vel = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.x > 0) {
|
||||
if (x > tl.x + 16 * 7 - 4) {
|
||||
velocity.x = -40;
|
||||
}
|
||||
} else {
|
||||
if (x < tl.x + 48) {
|
||||
velocity.x = 40;
|
||||
}
|
||||
}
|
||||
|
||||
hit_hurt_logic();
|
||||
|
||||
// Check for phase change
|
||||
if (s2_health <= 0) {
|
||||
state = S_RESET;
|
||||
substate_ctr = 0;
|
||||
s2_d1 = null;
|
||||
s2_d2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stage 3: Stage 2 but with 4 things on sage (can still hit but harder!)
|
||||
*/
|
||||
|
||||
private var s3_t:Number = 0;
|
||||
private var s3_dust_osc_t:Number = 0;
|
||||
|
||||
private var s3_nr_dusts_made:int = 0;
|
||||
|
||||
private var s3_d1:FlxSprite;
|
||||
private var s3_d2:FlxSprite;
|
||||
private var s3_d3:FlxSprite;
|
||||
private var s3_d4:FlxSprite;
|
||||
|
||||
private var s3_health:int = 4;
|
||||
private var s3_set_vel:Boolean = false;
|
||||
private var s3_max_health:int = 4;
|
||||
|
||||
private var s3_dash_vel:Array = new Array(80, 90, 100, 115);
|
||||
|
||||
private function stage_3():void {
|
||||
|
||||
// Move to top
|
||||
// Poof the 4 dusts in order
|
||||
// Start movin'
|
||||
switch (substate_ctr) {
|
||||
case 0:
|
||||
x = tl.x + 80 - width / 2;
|
||||
y = tl.y + 25;
|
||||
substate_ctr++;
|
||||
|
||||
return;
|
||||
case 1:
|
||||
s3_t += FlxG.elapsed;
|
||||
if (s3_t > 1) {
|
||||
s3_t = 0;
|
||||
substate_ctr++;
|
||||
s_bullets.setAll("exists", false);
|
||||
}
|
||||
return;
|
||||
// Make the small bullets appear around sage slowly
|
||||
case 2:
|
||||
s3_t += FlxG.elapsed;
|
||||
if (s3_t > 0.8) {
|
||||
s3_t = 0;
|
||||
var d:FlxSprite = s_bullets.getFirstAvailable() as FlxSprite;
|
||||
d.exists = true;
|
||||
d.play("spin");
|
||||
Dust.dust_sound.play();
|
||||
switch (s3_nr_dusts_made) {
|
||||
case 0:
|
||||
s3_d1 = d;
|
||||
s3_d1.y = y - 10 - off;
|
||||
s3_d1.x = x + (width - s3_d1.width) / 2;
|
||||
break;
|
||||
case 1:
|
||||
s3_d2 = d;
|
||||
s3_d2.y = y + 12 + off;
|
||||
s3_d2.x = x + (width - s3_d2.width) / 2;
|
||||
break;
|
||||
case 2:
|
||||
s3_d3 = d;
|
||||
s3_d3.x = x - 12;
|
||||
s3_d3.y = y;
|
||||
break;
|
||||
case 3:
|
||||
s3_d4 = d;
|
||||
s3_d4.x = x + 14;
|
||||
s3_d4.y = y;
|
||||
break;
|
||||
}
|
||||
s3_nr_dusts_made++;
|
||||
if (s3_nr_dusts_made == 4) {
|
||||
substate_ctr++;
|
||||
velocity.x = 20;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (substate_ctr == 3) { // Down
|
||||
if (!s3_set_vel) {
|
||||
velocity.y = s3_dash_vel[s3_max_health - s3_health];
|
||||
s3_set_vel = true;
|
||||
play("dash_d");
|
||||
}
|
||||
if (y > tl.y + 16 * 8) {
|
||||
substate_ctr = 4;
|
||||
s3_set_vel = false;
|
||||
}
|
||||
} else if (substate_ctr == 4) {
|
||||
if (!s3_set_vel) {
|
||||
play("dash_u");
|
||||
velocity.y = -s3_dash_vel[s3_max_health - s3_health];
|
||||
s3_set_vel = true;
|
||||
}
|
||||
if (y < tl.y + 16) {
|
||||
substate_ctr = 3;
|
||||
s3_set_vel = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.x > 0) {
|
||||
if (x > tl.x + 16 * 7 - 4) {
|
||||
velocity.x = -20;
|
||||
}
|
||||
} else {
|
||||
if (x < tl.x + 48) {
|
||||
velocity.x = 20;
|
||||
}
|
||||
}
|
||||
|
||||
// Snap dusts to sage, but vary their distance with time
|
||||
s3_dust_osc_t += FlxG.elapsed;
|
||||
var r:Number;
|
||||
|
||||
if (s3_dust_osc_t > 2) {
|
||||
s3_dust_osc_t = 0;
|
||||
}
|
||||
if (s3_dust_osc_t < 1) {
|
||||
r = s3_dust_osc_t;
|
||||
} else {
|
||||
r = 2 - s3_dust_osc_t;
|
||||
}
|
||||
var off:int = int(r * 34);
|
||||
s3_d1.x = x + (width - s3_d1.width) / 2;
|
||||
s3_d2.x = x + (width - s3_d2.width) / 2;
|
||||
s3_d3.x = x - 12 - off;
|
||||
s3_d4.x = x + 14 + off;
|
||||
|
||||
s3_d1.y = y - 10 - off;
|
||||
s3_d2.y = y + 12 + off;
|
||||
s3_d3.y = y;
|
||||
s3_d4.y = y;
|
||||
|
||||
hit_hurt_logic();
|
||||
|
||||
if (s3_health <= 0) {
|
||||
state = S_RESET;
|
||||
substate_ctr = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stage 4: Lots of small dusts thrown at you.
|
||||
*/
|
||||
private var s4_t:Number = 0;
|
||||
private var s4_tm:Number = 0.55;
|
||||
|
||||
private var s4_health:int = 3;
|
||||
private var s4_health_max:int = 3;
|
||||
private var s4_vel:Array = new Array(50, 60, 70);
|
||||
|
||||
private function stage_4():void {
|
||||
if (substate_ctr == 0) {
|
||||
play_sfx("warp_out");
|
||||
x = tl.x + 80 - width / 2;
|
||||
y = tl.y + 38;
|
||||
velocity.x = velocity.y = 0;
|
||||
substate_ctr++;
|
||||
return;
|
||||
}
|
||||
|
||||
var d:FlxSprite;
|
||||
|
||||
s4_t += FlxG.elapsed;
|
||||
if (s4_t > s4_tm) {
|
||||
s4_t = 0;
|
||||
d = s_bullets.getFirstDead() as FlxSprite;
|
||||
if (d != null) {
|
||||
d.exists = d.alive = true;
|
||||
d.x = tl.x + 4 + 48 + 16 * (int (4 * Math.random()));
|
||||
d.y = tl.y + 16;
|
||||
d.velocity.y = s4_vel[s4_health_max - s4_health];
|
||||
d.play("shoot");
|
||||
}
|
||||
}
|
||||
|
||||
for each (d in s_bullets.members) {
|
||||
var undo:Boolean = false;
|
||||
if (d != null && d.alive) {
|
||||
if (d.overlaps(player) && player.state != player.S_AIR) {
|
||||
undo = true;
|
||||
player.touchDamage(1);
|
||||
}
|
||||
// if (d.overlaps(dusts)) {
|
||||
// undo = true;
|
||||
// }
|
||||
|
||||
if (d.y > tl.y + 16 * 9) {
|
||||
undo = true;
|
||||
}
|
||||
|
||||
if (undo) {
|
||||
d.play("poof");
|
||||
d.alive = false;
|
||||
d.velocity.x = d.velocity.y = 0;
|
||||
undo = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
|
||||
}
|
||||
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(this)) {
|
||||
flicker(2.5);
|
||||
play_sfx("hurt");
|
||||
s4_health--;
|
||||
|
||||
|
||||
/*dusts.members[0].x = tl.x + 48;
|
||||
dusts.members[1].x = tl.x + 48;
|
||||
dusts.members[0].y = tl.y + 16 * 7;
|
||||
dusts.members[1].y = tl.y + 16 * 7;
|
||||
*/
|
||||
}
|
||||
|
||||
if (s4_health <= 0) {
|
||||
state = S_RESET;
|
||||
substate_ctr = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function dying_state():void {
|
||||
switch (substate_ctr) {
|
||||
case 0:
|
||||
Registry.sound_data.stop_current_song();
|
||||
play("idle_d");
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_after_fight);
|
||||
substate_ctr++;
|
||||
break;
|
||||
case 1:
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
DH.dont_need_recently_finished();
|
||||
substate_ctr = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
play("walk_u");
|
||||
player.state = player.S_INTERACT;
|
||||
velocity.y = -20;
|
||||
substate_ctr = 3;
|
||||
break;
|
||||
case 3:
|
||||
if (y + 16 < tl.y) {
|
||||
visible = false;
|
||||
substate_ctr = 4;
|
||||
player.state = player.S_GROUND;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
state = S_DEAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
private function reset_state():void {
|
||||
var d:FlxSprite;
|
||||
switch (active_substate) {
|
||||
case 1:
|
||||
FlxG.flash(0xff000000, 1.0);
|
||||
play_sfx("warp_out");
|
||||
flicker(1.5);
|
||||
poof_big();
|
||||
state = S_ACTIVE;
|
||||
active_substate++;
|
||||
break;
|
||||
case 2:
|
||||
play_sfx("warp_out");
|
||||
flicker(1.5);
|
||||
state = S_ACTIVE;
|
||||
active_substate++;
|
||||
velocity.x = velocity.y = 0;
|
||||
poof_small();
|
||||
break;
|
||||
case 3:
|
||||
flicker(1.5);
|
||||
state = S_ACTIVE;
|
||||
active_substate++;
|
||||
velocity.x = velocity.y;
|
||||
poof_big();
|
||||
|
||||
poof_small();
|
||||
break;
|
||||
case 4:
|
||||
poof_big();
|
||||
poof_small();
|
||||
state = S_DYING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Revives the dust every LATENCY seconds
|
||||
* @param latency When the dusts should revive when poofed.
|
||||
*/
|
||||
private var t_dust:Number = 0;
|
||||
private function dust_routine(latency:Number):void {
|
||||
|
||||
/* t_dust += FlxG.elapsed;
|
||||
if (t_dust > latency) {
|
||||
t_dust = 0;
|
||||
var d:Dust;
|
||||
for each (d in dusts.members) {
|
||||
if (d.fell_in_hole) {
|
||||
d.exists = true;
|
||||
d.fell_in_hole = false;
|
||||
d.play("unpoof");
|
||||
d.flicker(0.5);
|
||||
var idx:int = dusts.members.indexOf(d);
|
||||
d.y = tl.y + 8 * 16;
|
||||
if (idx == 0) {
|
||||
d.x = tl.x + 48;
|
||||
} else {
|
||||
d.x = tl.x + 48 + 48;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private function hit_hurt_logic():void
|
||||
{
|
||||
//Check for player hitting sage
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(this)) {
|
||||
flicker(1);
|
||||
play_sfx("hurt");
|
||||
FlxG.flash(0xff000000, 0.4);
|
||||
if (active_substate == 2) {
|
||||
s2_health--;
|
||||
} else if (active_substate == 3) {
|
||||
s3_health--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check for player getting hurt (Sage, sage dusts, long dusts)
|
||||
if (player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
var s:FlxSprite;
|
||||
|
||||
if (player.state == player.S_AIR) return;
|
||||
|
||||
for each (s in s_bullets.members) {
|
||||
if (s != null && s.exists && s.visible) {
|
||||
if (s.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for each (s in l_bullets.members) {
|
||||
if (s != null && s.exists) {
|
||||
if (s.overlaps(player) && s.visible) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function poof_small():void
|
||||
{
|
||||
var d:FlxSprite;
|
||||
for each (d in s_bullets.members) {
|
||||
if (d != null) {
|
||||
d.play("poof");
|
||||
d.alive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function poof_big():void
|
||||
{
|
||||
var d:FlxSprite;
|
||||
for each (d in l_bullets.members) {
|
||||
if (d != null) {
|
||||
d.play("poof");
|
||||
d.alive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import entity.interactive.npc.Space_NPC;
|
||||
import flash.display.InterpolationMethod;
|
||||
import flash.geom.Point;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Space_Face extends AnoSprite
|
||||
{
|
||||
|
||||
|
||||
public var t_dash:Number = 0;
|
||||
public var tm_dash:Number;
|
||||
|
||||
public var t_calc_angle:Number = 0;
|
||||
public var tm_calc_angle:Number = 0.2;
|
||||
|
||||
|
||||
public function Space_Face(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
loadGraphic(Space_NPC.embed_space_npc,true,false,16,16);
|
||||
|
||||
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
|
||||
// MARINA_ANIMS (face)
|
||||
// Happy
|
||||
if (dame_frame == 0) {
|
||||
addAnimation("a", [22,23], 6, true);
|
||||
// Sad
|
||||
} else if (dame_frame == 1) {
|
||||
addAnimation("a", [20,21], 6);
|
||||
}
|
||||
play("a");
|
||||
|
||||
tm_dash = 0.5 + 1.5 * Math.random();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
parent.sortables.remove(this, true);
|
||||
parent.bg_sprites.add(this);
|
||||
}
|
||||
|
||||
if (EventScripts.time_cond(this,"t_dash","tm_dash")) {
|
||||
EventScripts.scale_vector(this, player, velocity, 55); // dash vel
|
||||
drag.x = drag.y = 15 + 10 * Math.random();
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package entity.enemy.etc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import org.flixel.FlxSound;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxObject;
|
||||
public class Wall_Laser extends FlxSprite
|
||||
{
|
||||
|
||||
//[Embed (source = "../../../res/sprites/enemies/wall_laser.png")] public var Wall_Laser_Sprite:Class;
|
||||
[Embed (source = "../../../../../sfx/laser_charge.mp3")] public var Laser_Charge_Sound:Class;
|
||||
[Embed (source = "../../../../../sfx/laser_fire.mp3")] public var Laser_Fire_Sound:Class;
|
||||
|
||||
|
||||
|
||||
public var dir_type:int; //left, right, down, up
|
||||
public var local_id:int;
|
||||
public var type:String = "Wall_Laser";
|
||||
public var is_charging:Boolean = false;
|
||||
public var charge_timer:Number = 0;
|
||||
public var laser:FlxSprite = new FlxSprite();
|
||||
public var sound_state:int = 0;
|
||||
public var sound_state_charge:int = 1;
|
||||
public var sound_state_fire:int = 2;
|
||||
public var soundObj:FlxSound = new FlxSound();
|
||||
|
||||
public var cid:int = CLASS_ID.WALL_LASER;
|
||||
|
||||
public function Wall_Laser(_x:int , _y:int, _type:String, _local_id:int )
|
||||
{
|
||||
super(_x , _y);
|
||||
local_id = _local_id;
|
||||
//FlxG.visualDebug = true;
|
||||
if (_type.indexOf("left") != -1) {
|
||||
dir_type = FlxObject.LEFT;
|
||||
//loadGraphic(Wall_Laser_Sprite, true, false, 16, 16);
|
||||
addAnimation("blink", [0, 1], 4, true);
|
||||
addAnimation("charge", [1, 2, 1, 3], 6, true);
|
||||
}
|
||||
laser = new FlxSprite(x - Registry.SCREEN_WIDTH_IN_PIXELS, y);
|
||||
laser.makeGraphic(Registry.SCREEN_WIDTH_IN_PIXELS, 16, 0xffffffff);
|
||||
laser.visible = false;
|
||||
laser.solid = false;
|
||||
play("blink");
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
if (is_charging) {
|
||||
play("charge");
|
||||
if (sound_state == 0) {
|
||||
sound_state = sound_state_charge;
|
||||
soundObj.loadEmbedded(Laser_Charge_Sound, false);
|
||||
soundObj.play();
|
||||
}
|
||||
charge_timer += FlxG.elapsed;
|
||||
} else {
|
||||
play("blink");
|
||||
}
|
||||
if (charge_timer > 1.5) {
|
||||
//BOOM!
|
||||
if (sound_state == sound_state_charge) {
|
||||
soundObj.stop();
|
||||
sound_state = sound_state_fire;
|
||||
soundObj.loadEmbedded(Laser_Fire_Sound, false);
|
||||
soundObj.play();
|
||||
}
|
||||
laser.visible = true;
|
||||
if (charge_timer > 3) {
|
||||
charge_timer = 0;
|
||||
sound_state = 0;
|
||||
is_charging = false;
|
||||
laser.visible = false;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function touches(sprite:FlxSprite):void {
|
||||
if (dir_type == FlxObject.LEFT || dir_type == FlxObject.RIGHT) {
|
||||
if (sprite.y > (y - sprite.height) && sprite.y < (y + height)) {
|
||||
is_charging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
package entity.enemy.hotel
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.Common_Sprites;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
public class Burst_Plant extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var bullets:FlxGroup = new FlxGroup(8);
|
||||
private var added_to_parent:Boolean = false;
|
||||
|
||||
private var t_timeout:Number = 0;
|
||||
private var tm_timeout:Number = 1;
|
||||
|
||||
|
||||
private var t_hurt:Number = 0;
|
||||
private var tm_hurt:Number = 1.0;
|
||||
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_idle:int = 0;
|
||||
private var s_charge:int = 1;
|
||||
private var t_charge:Number = 0;
|
||||
private var tm_charge:Number = 0.5;
|
||||
private var s_shoot:int = 2;
|
||||
private var s_dying:int = 3;
|
||||
private var s_dead:int = 4;
|
||||
public var cid:int = CLASS_ID.BURSTPLANT;
|
||||
private var max_x_vel:int = 50;
|
||||
|
||||
private var init_latency:Number = 0.4;
|
||||
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/hotel/burst_plant.png")] public static var burst_plant_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/hotel/burst_plant_bullet.png")] public static var burst_plant_bullet_sprite:Class;
|
||||
|
||||
public function Burst_Plant(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Burst Plant Anims */
|
||||
loadGraphic(burst_plant_sprite, true, false, 16, 16);
|
||||
addAnimation("idle", [0], 1);
|
||||
addAnimation("charge", [0, 1], 8);
|
||||
addAnimation("shoot", [3]);
|
||||
play("idle");
|
||||
|
||||
for (var i:int = 0; i < bullets.maxSize; i++) {
|
||||
/* Bullet and bullet shadow anims */
|
||||
var bullet:FlxSprite = new FlxSprite();
|
||||
bullet.loadGraphic(burst_plant_bullet_sprite, true, false, 8, 8);
|
||||
bullet.addAnimation("move", [0, 1], 12);
|
||||
bullet.addAnimation("explode", [2, 3, 4,4], 10, false);
|
||||
bullet.play("move");
|
||||
|
||||
bullet.my_shadow = new FlxSprite();
|
||||
bullet.my_shadow.loadGraphic(Common_Sprites.shadow_sprite_8_8, true, false, 8, 8);
|
||||
bullet.my_shadow.addAnimation("get_big", [0, 1, 2, 3], 8, false);
|
||||
bullet.my_shadow.addAnimation("get_small", [3, 2, 1, 0], 8, false);
|
||||
bullet.my_shadow.play("get_big");
|
||||
|
||||
bullets.add(bullet);
|
||||
bullet.parabola_thing = new Parabola_Thing(bullet, 24 + int(10 * Math.random()), 0.7 + Math.random(), "offset", "y");
|
||||
bullet.velocity.x = 10;
|
||||
}
|
||||
|
||||
tm_timeout = 0.4 + Math.random();
|
||||
|
||||
health = 2;
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.bubble_triple_group);
|
||||
add_sfx("pop", Registry.sound_data.four_shooter_pop_group);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (!added_to_parent ) {
|
||||
added_to_parent = true;
|
||||
parent.fg_sprites.add(bullets);
|
||||
for each (var b:FlxSprite in bullets.members) {
|
||||
parent.bg_sprites.add(b.my_shadow);
|
||||
}
|
||||
}
|
||||
|
||||
if (init_latency > 0) {
|
||||
init_latency -= FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
//get hurt and transition to dying if needed
|
||||
if ((t_hurt > tm_hurt) && player.broom.visible && player.broom.overlaps(this)) {
|
||||
if (state != s_dying && state != s_dead) {
|
||||
health--;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
t_hurt = 0;
|
||||
flicker(tm_hurt);
|
||||
if (health <= 0) {
|
||||
state = s_dying;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
t_hurt += FlxG.elapsed;
|
||||
}
|
||||
|
||||
var subctr:int = 0;
|
||||
var bullet:FlxSprite;
|
||||
if (state == s_idle) { //wait a bit before charging
|
||||
t_timeout += FlxG.elapsed;
|
||||
if (t_timeout > tm_timeout) {
|
||||
play("charge");
|
||||
state = s_charge;
|
||||
t_timeout = 0;
|
||||
tm_timeout = 0.4 + Math.random();
|
||||
}
|
||||
} else if (state == s_charge) {
|
||||
t_charge += FlxG.elapsed; //charge
|
||||
if (t_charge > tm_charge) {
|
||||
for each (bullet in bullets.members) { //init pos, vel etc - randomized a bit of course
|
||||
bullet.x = bullet.my_shadow.x = x + 5;
|
||||
bullet.y = bullet.my_shadow.y = y + 6;
|
||||
|
||||
bullet.exists = bullet.my_shadow.exists = true;
|
||||
bullet.parabola_thing.reset_time();
|
||||
bullet.play("move");
|
||||
bullet.my_shadow.play("get_small");
|
||||
bullet.parabola_thing.set_shadow_fall_animation("get_big"); // Reset the bullet fall anim thing
|
||||
|
||||
var sign:int = Math.random() > 0.5 ? -1 : 1;
|
||||
max_x_vel = 10 + 30 * Math.random();
|
||||
if (subctr > 0) {
|
||||
bullet.velocity.x = -max_x_vel + 2 * max_x_vel * Math.random();
|
||||
bullet.velocity.y = sign * Math.sqrt(max_x_vel * max_x_vel - bullet.velocity.x * bullet.velocity.x);
|
||||
} else { //one bullet tries to hit the player
|
||||
EventScripts.scale_vector(new Point(x, y), new Point(player.x, player.y), bullet.velocity, 2.5 * max_x_vel);
|
||||
bullet.parabola_thing.period = 1.5;
|
||||
}
|
||||
subctr++;
|
||||
}
|
||||
t_charge = 0;
|
||||
state = s_shoot;
|
||||
play("shoot");
|
||||
play_sfx("shoot");
|
||||
}
|
||||
} else if (state == s_shoot) {
|
||||
for each (bullet in bullets.members) { //move the bullets' offsets
|
||||
bullet.my_shadow.x = bullet.x;
|
||||
bullet.my_shadow.y = bullet.y;
|
||||
if (bullet.parabola_thing.tick()) {
|
||||
//do something
|
||||
subctr++;
|
||||
if (bullet.exists) { // If bullet hits ground, explode
|
||||
bullet.my_shadow.exists = false;
|
||||
bullet.play("explode");
|
||||
bullet.velocity.x = bullet.velocity.y = 0;
|
||||
|
||||
if (bullet.frame == bullet._curAnim.frames.length - 1) {
|
||||
bullet.exists = false;
|
||||
play_sfx("pop");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bullet.offset.y <= 4) {
|
||||
if (!player.invincible && player.overlaps(bullet) && bullet.velocity.x != 0) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (subctr == bullets.maxSize) {
|
||||
play("idle");
|
||||
state = s_idle;
|
||||
}
|
||||
} else if (state == s_dying) {
|
||||
//die, sfx...
|
||||
//timer...
|
||||
state = s_dead;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.drop_small_health(x, y, 0.7);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
xml.@alive = "false";
|
||||
} else if (state == s_dead) {
|
||||
bullets.setAll("exists", false);
|
||||
for each (bullet in bullets.members) {
|
||||
bullet.my_shadow.exists = false;
|
||||
}
|
||||
|
||||
|
||||
exists = false;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package entity.enemy.hotel
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Dustmaid extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_idle:int = 0;
|
||||
private var s_chasing:int = 1;
|
||||
private var s_dying:int = 2;
|
||||
private var s_dead:int = 3;
|
||||
|
||||
private var ctr:int = 0;
|
||||
private var freq:int = 10;
|
||||
|
||||
private var player_pt:Point = new Point();
|
||||
private var pt:Point = new Point();
|
||||
|
||||
private var t_hit:Number = 0;
|
||||
private var tm_hit:Number = 1.0;
|
||||
public var cid:int = CLASS_ID.DUSTMAID;
|
||||
[Embed (source = "../../../res/sprites/enemies/hotel/dustmaid.png")] public static var dustmaid_sprite:Class;
|
||||
|
||||
public function Dustmaid(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
health = 3;
|
||||
state = s_idle;
|
||||
alpha = 0.7;
|
||||
|
||||
loadGraphic(dustmaid_sprite, true, false, 16, 24);
|
||||
width = 8;
|
||||
height = 18;
|
||||
centerOffsets(true);
|
||||
offset.x += 1;
|
||||
offset.y += 2;
|
||||
addAnimation("idle", [0],1);
|
||||
addAnimation("turn_dark", [1,2,1,2],12,false);
|
||||
addAnimation("move_r", [5,6],7);
|
||||
addAnimation("move_l", [5,6],7);
|
||||
addAnimation("move_d", [3,4],7);
|
||||
addAnimation("move_u", [7,8],7);
|
||||
play("idle");
|
||||
|
||||
add_sfx("alert", Registry.sound_data.dustmaid_alert);
|
||||
|
||||
}
|
||||
override public function preUpdate():void
|
||||
{
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (state != s_dying && !player.invincible && player.overlaps(this)) {
|
||||
if (state != s_dead) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
t_hit += FlxG.elapsed;
|
||||
if (health > 0 && player.broom.visible && state == s_chasing && player.broom.overlaps(this)) {
|
||||
if (t_hit > tm_hit) {
|
||||
flicker(1);
|
||||
t_hit = 0;
|
||||
health--;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
if (health == 0) {
|
||||
state = s_dying;
|
||||
}
|
||||
if (state == s_idle) {
|
||||
state = s_chasing;
|
||||
play("turn_dark");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (state == s_idle) {
|
||||
if (player.broom.has_dust) {
|
||||
state = s_chasing;
|
||||
play("turn_dark");
|
||||
alpha = 1;
|
||||
play_sfx("alert");
|
||||
}
|
||||
|
||||
} else if (state == s_chasing) {
|
||||
if (_curAnim.name == "turn_dark") {
|
||||
if (_curFrame == _curAnim.frames.length - 1) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ctr == freq) {
|
||||
ctr = 0;
|
||||
player_pt.x = player.x;
|
||||
player_pt.y = player.y;
|
||||
pt.x = x;
|
||||
pt.y = y;
|
||||
scale.x = 1;
|
||||
offset.x = 5;
|
||||
switch (EventScripts.get_entity_to_entity_dir(pt.x, pt.y, player_pt.x, player_pt.y)) {
|
||||
case UP:
|
||||
play("move_u");
|
||||
offset.x = 1;
|
||||
break;
|
||||
case LEFT:
|
||||
scale.x = -1;
|
||||
play("move_l");
|
||||
break;
|
||||
case RIGHT:
|
||||
play("move_r");
|
||||
break;
|
||||
case DOWN:
|
||||
play("move_d");
|
||||
break;
|
||||
}
|
||||
EventScripts.scale_vector(pt, player_pt, velocity, 20);
|
||||
}
|
||||
|
||||
ctr++;
|
||||
|
||||
|
||||
} else if (state == s_dying) {
|
||||
//play dying
|
||||
//sfx dying
|
||||
//alpha -= 0.04;
|
||||
alpha = 0;
|
||||
if (alpha == 0) {
|
||||
EventScripts.drop_small_health(x, y, 0.7);
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
state = s_dead;
|
||||
}
|
||||
} else if (state == s_dead) {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,753 @@
|
|||
package entity.enemy.hotel
|
||||
{
|
||||
import data.Common_Sprites;
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.HealthBar;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import flash.text.engine.BreakOpportunity;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.BaseTypes.Bullet;
|
||||
|
||||
public class Eye_Boss extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
private var parent:*;
|
||||
private var player:Player;
|
||||
private var tl:Point = new Point();
|
||||
|
||||
private var hitbox:FlxSprite;
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/hotel/eye_boss_water.png")] public static var eye_boss_water_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/hotel/eye_boss_bullet.png")] public static var eye_boss_bullet_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/hotel/eye_boss_splash.png")] public static var eye_boss_splash_sprite:Class;
|
||||
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
public static var global_state:int = 0;
|
||||
public static var gs_new:int = 0;
|
||||
public var gs_land:int = 1;
|
||||
public var gs_water:int = 2;
|
||||
public var gs_dead:int = 3;
|
||||
public var gs_transition_to_land:int = 4;
|
||||
|
||||
|
||||
public static var cur_health:int;
|
||||
private var max_health:int = 12;
|
||||
private var phase_2_health:int = 6;
|
||||
private var ctr:int = 0;
|
||||
public var state:int = 0;
|
||||
|
||||
/* Land state var s*/
|
||||
|
||||
private var s_land_pace:int = 0;
|
||||
private var s_land_shoot:int = 1;
|
||||
private var s_land_charge:int = 2;
|
||||
private var s_land_dying:int = 3;
|
||||
private var s_land_dead:int = 4;
|
||||
|
||||
private var t_pace:Number = 0;
|
||||
private var tm_pace:Number = 1;
|
||||
|
||||
private var t_shoot:Number = 0;
|
||||
private var tm_shoot:Array = new Array(1, 1, 0.9, 0.8, 0.7, 0.65);
|
||||
|
||||
private var grp_land_splashes:FlxGroup = new FlxGroup(18);
|
||||
|
||||
private var base_pt:Point = new Point();
|
||||
private var rel_coords:Point = new Point(1, 1);
|
||||
|
||||
private var land_hitbox:FlxSprite = new FlxSprite;
|
||||
|
||||
/* Water state vars */
|
||||
private var intro_ctr:int = 0;
|
||||
private var s_water_intro:int = -1;
|
||||
private var s_water_waiting:int = 0;
|
||||
private var s_water_moving:int = 3;
|
||||
private var s_water_dying:int = 1;
|
||||
private var s_water_dead:int = 2;
|
||||
private var s_water_blinded:int = 4;
|
||||
private var s_water_leaving:int = 5;
|
||||
|
||||
|
||||
private var grp_water_bullets:FlxGroup = new FlxGroup(8);
|
||||
private var vel_water_bullet:int = 70;
|
||||
private var t_blink:Number = 0;
|
||||
private var tm_blink:Array = new Array(1.1, 0.95, 0.9, 0.8, 0.7, 0.65);
|
||||
|
||||
private var move_vel:Number = 100;
|
||||
private var t_move:Number = 0;
|
||||
private var tm_move:Number = 0.8;
|
||||
|
||||
|
||||
public function Eye_Boss(_xml:XML, _player:Player, _parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
parent = _parent;
|
||||
player = _player;
|
||||
tl.x = Registry.CURRENT_GRID_X*160 + 16;
|
||||
tl.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT + 16;
|
||||
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
// Set hitboxes/sprites
|
||||
if (global_state == gs_water || global_state == gs_new) {
|
||||
hitbox = this;
|
||||
} else {
|
||||
land_hitbox.makeGraphic(24, 11, 0xff123123);
|
||||
hitbox = land_hitbox;
|
||||
}
|
||||
|
||||
loadGraphic(eye_boss_water_sprite, true, false, 24, 24);
|
||||
parabola_thing = new Parabola_Thing(this, 16, 0.6, "offset", "y");
|
||||
my_shadow = new FlxSprite;
|
||||
my_shadow.loadGraphic(Common_Sprites.shadow_sprite_28_10, true, false, 28, 10);
|
||||
|
||||
/* Water anims for Eye */
|
||||
addAnimation("blink", [0, 1, 2, 3, 2, 1, 0], 10, false);
|
||||
addAnimation("blink_fast", [0, 1, 2, 3, 2, 1], 20, true);
|
||||
addAnimation("idle", [0]);
|
||||
addAnimation("closed", [3]);
|
||||
addAnimation("open", [3, 2, 1, 0],5);
|
||||
/* Land anims for Eye (same spritesheet a water anims ) */
|
||||
addAnimation("walk", [4, 5], 6);
|
||||
addAnimation("blink_land", [5, 6, 7, 6, 5,5], 6,false);
|
||||
|
||||
for (var i:int = 0; i < grp_water_bullets.maxSize; i++) {
|
||||
var b:FlxSprite = new FlxSprite;
|
||||
/* Bullet and bullet shadow anims */
|
||||
b.loadGraphic(eye_boss_bullet_sprite, true, false, 16, 16);
|
||||
b.addAnimation("move", [0, 1], 12);
|
||||
b.addAnimation("pop", [2, 3, 4, 5], 12, false);
|
||||
b.addAnimation("move_land", [6, 7], 12);
|
||||
b.addAnimation("pop_land", [2, 3, 4, 5], 24, false);
|
||||
|
||||
b.play("move");
|
||||
b.width = b.height = 8;
|
||||
b.centerOffsets(true);
|
||||
|
||||
b.my_shadow = EventScripts.make_shadow("8_small",true);
|
||||
b.my_shadow.exists = false;
|
||||
b.my_shadow.visible = true;
|
||||
b.my_shadow.play("get_big");
|
||||
|
||||
b.parabola_thing = new Parabola_Thing(b, 45, 1.5, "offset", "y");
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
grp_water_bullets.add(b);
|
||||
}
|
||||
grp_water_bullets.setAll("exists", false);
|
||||
grp_water_bullets.setAll("alive", false);
|
||||
|
||||
|
||||
for (i = 0; i < grp_land_splashes.maxSize; i++) {
|
||||
/* Small splash and small splash shadow ANIMS */
|
||||
var splash:FlxSprite = new FlxSprite;
|
||||
splash.makeGraphic(8, 8, 0xff123412);
|
||||
splash.loadGraphic(eye_boss_splash_sprite, true, false, 8, 8);
|
||||
splash.addAnimation("move", [0, 1], 10);
|
||||
splash.addAnimation("explode", [2, 3, 3], 12, false);
|
||||
splash.play("move");
|
||||
|
||||
splash.my_shadow = EventScripts.make_shadow("8_small",true);
|
||||
splash.my_shadow.play("get_big");
|
||||
splash.my_shadow.exists = false;
|
||||
|
||||
splash.parabola_thing = new Parabola_Thing(splash, 36, 1 + 0.4 * Math.random(), "offset", "y");
|
||||
splash.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
|
||||
grp_land_splashes.add(splash);
|
||||
|
||||
}
|
||||
grp_land_splashes.setAll("exists", false);
|
||||
grp_land_splashes.setAll("alive", false);
|
||||
|
||||
|
||||
|
||||
//if land room
|
||||
/* NOTE TO MARINA: flip TEST_LAND to get straight to hte land phase for testing its anims */
|
||||
var TEST_LAND:Boolean = false;
|
||||
if (TEST_LAND) {
|
||||
global_state = gs_transition_to_land;
|
||||
cur_health = phase_2_health;
|
||||
}
|
||||
|
||||
|
||||
if (Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx] == true) {
|
||||
exists = false;
|
||||
Registry.GRID_PUZZLES_DONE ++;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
}
|
||||
|
||||
if (Registry.CURRENT_GRID_X == 8 && Registry.CURRENT_GRID_Y == 10) { // If land room
|
||||
if (global_state == gs_dead) {
|
||||
exists = false;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx] = true;
|
||||
} else if (global_state == gs_water) {
|
||||
|
||||
exists = false;
|
||||
/*health = cur_health = 6;
|
||||
global_state = gs_transition_to_land;
|
||||
Registry.GRID_PUZZLES_DONE++;*/
|
||||
|
||||
} else {
|
||||
state = s_land_pace;
|
||||
Registry.GRID_PUZZLES_DONE++; //open the door for land fight
|
||||
y = tl.y + 75;
|
||||
x = tl.x + 16;
|
||||
base_pt.x = x - 16;
|
||||
base_pt.y = y - 16;
|
||||
play("walk");
|
||||
}
|
||||
} else { //if water room
|
||||
play("closed");
|
||||
if (xml.@alive == "false" || global_state == gs_dead) { // Already killed: open north and south door
|
||||
exists = false;
|
||||
Registry.GRID_PUZZLES_DONE ++;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
global_state = gs_dead;
|
||||
} else if (global_state == gs_land) { // In land state: open the door
|
||||
Registry.GRID_PUZZLES_DONE ++;
|
||||
exists = false;
|
||||
} else if (global_state == gs_transition_to_land) { //
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
exists = false;
|
||||
} else {
|
||||
state = s_water_intro;
|
||||
global_state = gs_new;
|
||||
}
|
||||
}
|
||||
|
||||
// Set health
|
||||
if (global_state == gs_new) {
|
||||
health = max_health;
|
||||
} else {
|
||||
health = cur_health;
|
||||
}
|
||||
FlxG.watch(this, "health", "health");
|
||||
FlxG.watch(this, "state", "state");
|
||||
|
||||
|
||||
// Set position, maybe.
|
||||
if (global_state == gs_transition_to_land) {
|
||||
x = tl.x + 44;
|
||||
y = tl.y - 32;
|
||||
alpha = 0;
|
||||
}
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.gasguy_shoot);
|
||||
add_sfx("poof", Dust.dust_sound);
|
||||
add_sfx("bounce", Registry.sound_data.wb_tap_ground);
|
||||
add_sfx("hit_ground", Registry.sound_data.hitground1);
|
||||
add_sfx("pop", Registry.sound_data.four_shooter_pop_group);
|
||||
add_sfx("unpop", Registry.sound_data.four_shooter_shoot_group);
|
||||
add_sfx("land_shoot", Registry.sound_data.slasher_atk);
|
||||
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (parent.state == parent.S_TRANSITION) {
|
||||
return;
|
||||
}
|
||||
if (global_state == gs_land ) {
|
||||
do_land();
|
||||
} else if (global_state == gs_water) {
|
||||
do_water();
|
||||
} else if (global_state == gs_new) {
|
||||
do_new();
|
||||
} else if (global_state == gs_transition_to_land) {
|
||||
do_transition_to_land();
|
||||
}
|
||||
|
||||
if (!did_init) {
|
||||
if (global_state == gs_water) {
|
||||
player.grid_entrance_x = tl.x + 80;
|
||||
player.grid_entrance_y = tl.y + 20;
|
||||
} else {
|
||||
player.grid_entrance_x = tl.x + 70;
|
||||
player.grid_entrance_y = tl.y + 50;
|
||||
}
|
||||
did_init = true;
|
||||
parent.fg_sprites.add(grp_water_bullets);
|
||||
for each (var b:FlxSprite in grp_water_bullets.members) {
|
||||
parent.bg_sprites.add(b.my_shadow);
|
||||
}
|
||||
parent.fg_sprites.add(grp_land_splashes);
|
||||
for each (b in grp_land_splashes.members) {
|
||||
parent.bg_sprites.add(b.my_shadow);
|
||||
}
|
||||
parent.bg_sprites.add(my_shadow);
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
private function do_transition_to_land():void {
|
||||
my_shadow.x = x;
|
||||
my_shadow.y = y + 21;
|
||||
|
||||
|
||||
if (offset.y <= 20) {
|
||||
my_shadow.frame = 4;
|
||||
} else if (offset.y <= 40) {
|
||||
my_shadow.frame = 3;
|
||||
|
||||
} else {
|
||||
my_shadow.frame = 2;
|
||||
}
|
||||
|
||||
if (ctr == 0) {
|
||||
my_shadow.visible = false;
|
||||
play("closed");
|
||||
if (framePixels_y_push < 22) {
|
||||
framePixels_y_push++;
|
||||
}
|
||||
velocity.y = 6;
|
||||
alpha += 0.03;
|
||||
if (y > tl.y && alpha == 1 && framePixels_y_push == 22) {
|
||||
velocity.y = 0;
|
||||
play("walk");
|
||||
framePixels_y_push = 0;
|
||||
my_shadow.visible = true;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.bubble_triple_group);
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
offset.y += 1.5;
|
||||
if (offset.y > 90) {
|
||||
ctr++;
|
||||
y = tl.y + 75;
|
||||
x = tl.x + 16;
|
||||
Registry.sound_data.fall1.play();
|
||||
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
offset.y -= 3;
|
||||
if (offset.y <= 0) {
|
||||
offset.y = 0;
|
||||
FlxG.shake(0.03, 0.5);
|
||||
global_state = gs_land;
|
||||
state = s_land_pace;
|
||||
my_shadow.visible = false;
|
||||
|
||||
base_pt.x = x - 16;
|
||||
base_pt.y = y - 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var land_ctr:int = 0;
|
||||
|
||||
private function do_land():void {
|
||||
hitbox.x = x;
|
||||
hitbox.y = y + (height - hitbox.height);
|
||||
|
||||
var b:FlxSprite;
|
||||
if (state == s_land_pace) {
|
||||
|
||||
// Occasionally shoot a big bullet.
|
||||
t_shoot += FlxG.elapsed;
|
||||
if (t_shoot > tm_shoot[phase_2_health - health]) {
|
||||
t_shoot = 0;
|
||||
play("blink_land");
|
||||
play_sfx("land_shoot");
|
||||
shoot_big_bullet();
|
||||
}
|
||||
|
||||
if (_curAnim.name == "blink_land" && _curAnim.frames.length - 1 == _curFrame) {
|
||||
play("walk");
|
||||
}
|
||||
|
||||
// Pace about a small 3x3 grid of points
|
||||
t_pace += FlxG.elapsed;
|
||||
|
||||
if (t_pace > tm_pace) {
|
||||
t_pace = 0;
|
||||
var r:Number = Math.random();
|
||||
if (r < 0.7) {
|
||||
rel_coords.x = int(3 * Math.random());
|
||||
rel_coords.y = int(3 * Math.random());
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
EventScripts.send_property_to(this, "x", base_pt.x + rel_coords.x * 16, 1);
|
||||
EventScripts.send_property_to(this, "y", base_pt.y + rel_coords.y * 16, 1);
|
||||
|
||||
// Get hurt by the player maybe
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(hitbox)) {
|
||||
ctr = 0;
|
||||
get_hurt();
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
if (player.x > x) {
|
||||
ctr = 1;
|
||||
velocity.x = -20;
|
||||
my_shadow.exists = true;
|
||||
my_shadow.x = x;
|
||||
my_shadow.y = y + (height - my_shadow.height);
|
||||
}
|
||||
state = s_land_charge;
|
||||
}
|
||||
|
||||
} else if (state == s_land_charge) {
|
||||
if (ctr == 0) { // Charge to the right side
|
||||
var sub_ctr:int = 0;
|
||||
if (EventScripts.send_property_to(this, "x", tl.x + 16 * 8 - width, 1.7)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(this, "y", tl.y + 57, 1)) sub_ctr++;
|
||||
if (sub_ctr == 2) { //Shoot some bullets when hitting the wall
|
||||
FlxG.shake(0.05, 0.3);
|
||||
play_sfx("hit_ground");
|
||||
for (var j:int = 0; j < 3; j++) {
|
||||
shoot_big_bullet();
|
||||
}
|
||||
state = s_land_pace;
|
||||
}
|
||||
} else if (ctr == 1) { // If hit from the front hop back a bit
|
||||
my_shadow.visible = true;
|
||||
my_shadow.x = x;
|
||||
my_shadow.y = y + (height - my_shadow.height);
|
||||
if (offset.y >= 10) {
|
||||
my_shadow.frame = 2;
|
||||
} else if (offset.y >= 6) {
|
||||
my_shadow.frame = 3;
|
||||
} else {
|
||||
my_shadow.frame = 4;
|
||||
}
|
||||
if (parabola_thing.tick()) {
|
||||
offset.y = 0;
|
||||
ctr = 0;
|
||||
play_sfx("bounce");
|
||||
parabola_thing.reset_time();
|
||||
my_shadow.visible = false;
|
||||
|
||||
}
|
||||
}
|
||||
} else if (state == s_land_dying) {
|
||||
player.invincible_timer = 0.3;
|
||||
if (DH.scene_is_finished(DH.name_eyeboss, DH.scene_eyeboss_after_fight)) {
|
||||
|
||||
if (land_ctr == 0) {
|
||||
ctr = 0;
|
||||
land_ctr = 1;
|
||||
offset.x = 5;
|
||||
offset.y = 5;
|
||||
} else if (land_ctr == 1) {
|
||||
t_blink += FlxG.elapsed;
|
||||
if (t_blink > 0.3) {
|
||||
x += ( -4 + 8 * Math.random());
|
||||
y += ( -4 + 8 * Math.random());
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
t_blink = 0;
|
||||
ctr += 1;
|
||||
if (ctr >= 10) {
|
||||
land_ctr = 2;
|
||||
FlxG.flash(0xffffffff, 2);
|
||||
Registry.sound_data.sun_guy_death_l.play();
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
my_shadow.exists = false;
|
||||
if (grp_land_splashes.countLiving() == 0) {
|
||||
if (grp_water_bullets.countLiving() == 0) {
|
||||
state = s_land_dead;
|
||||
exists = false;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx] = true;
|
||||
Registry.sound_data.start_song_from_title("HOTEL");
|
||||
global_state = gs_dead;
|
||||
xml.@alive = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!DH.scene_is_dirty(DH.name_eyeboss, DH.scene_eyeboss_after_fight)) {
|
||||
DH.start_dialogue(DH.name_eyeboss, DH.scene_eyeboss_after_fight);
|
||||
Registry.sound_data.stop_current_song();
|
||||
FlxG.flash(0xffffffff, 1);
|
||||
velocity.x = velocity.y = 0;
|
||||
Registry.sound_data.sun_guy_death_l.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update "bombs"
|
||||
for each (b in grp_water_bullets.members) {
|
||||
if (b.exists) {
|
||||
b.my_shadow.x = b.x;
|
||||
b.my_shadow.y = b.y;
|
||||
|
||||
if (b.offset.y < 7 && !player.invincible && player.overlaps(b)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
|
||||
if (b.parabola_thing.tick()) {
|
||||
b.play("pop_land");
|
||||
|
||||
if (b._curAnim.frames.length - 1 == b._curFrame) {
|
||||
b.parabola_thing.reset_time();
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
b.exists = b.alive = b.my_shadow.exists = false;
|
||||
b.velocity.x = b.velocity.y = 0;
|
||||
play_sfx("unpop");
|
||||
// Make little splash sprites and move them sort of randomly
|
||||
for (var i:int = 0; i < 4; i ++) {
|
||||
var splash:FlxSprite = grp_land_splashes.getFirstDead() as FlxSprite;
|
||||
if (splash == null) break;
|
||||
splash.play("move");
|
||||
splash.my_shadow.play("get_small");
|
||||
splash.x = b.x;
|
||||
splash.y = b.y;
|
||||
splash.alive = splash.exists = splash.my_shadow.exists = true;
|
||||
splash.velocity.x = -20 + 40 * Math.random();
|
||||
splash.velocity.y = Math.sqrt(20 * 20 - Math.pow(splash.velocity.x, 2));
|
||||
Math.random() > 0.5 ? splash.velocity.y *= -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update slow-you-down-splashes - mostly boilerplate
|
||||
|
||||
for each (b in grp_land_splashes.members) {
|
||||
if (b.exists) {
|
||||
if (b.offset.y < 9 && !player.invincible && player.overlaps(b)) {
|
||||
//player.touchDamage(1);
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.bubble_group);
|
||||
b.my_shadow.exists = false;
|
||||
player.slow_mul = 0.3;
|
||||
player.slow_ticks = 100;
|
||||
}
|
||||
b.my_shadow.x = b.x;
|
||||
b.my_shadow.y = b.y;
|
||||
if (b.parabola_thing.tick()) {
|
||||
b.play("explode");
|
||||
if (b._curAnim.frames.length - 1 == b._curFrame) {
|
||||
b.parabola_thing.reset_time();
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
b.alive = b.exists = b.my_shadow.exists = false;
|
||||
b.velocity.x = b.velocity.y = 0;
|
||||
play_sfx("pop");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hit the player
|
||||
|
||||
if (state != s_land_dying && !player.invincible && player.overlaps(hitbox) && state != s_land_dead) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
if (health <= 0) {
|
||||
|
||||
state = s_land_dying;
|
||||
}
|
||||
|
||||
/* Occasionally charge */
|
||||
}
|
||||
|
||||
private function do_water():void {
|
||||
var bullet:FlxSprite;
|
||||
|
||||
switch (state) {
|
||||
case s_water_intro:
|
||||
if (intro_ctr == 0) {
|
||||
Registry.volume_scale -= 0.007;
|
||||
if (player.y > tl.y + 24 && player.state != player.S_AIR) {
|
||||
if (!DH.scene_is_dirty(DH.name_eyeboss, DH.scene_eyeboss_before_fight)) {
|
||||
DH.start_dialogue(DH.name_eyeboss, DH.scene_eyeboss_before_fight);
|
||||
player.be_idle();
|
||||
}
|
||||
|
||||
if (!DH.scene_is_finished(DH.name_eyeboss, DH.scene_eyeboss_before_fight)) {
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
play("open");
|
||||
Registry.volume_scale = 1;
|
||||
Registry.sound_data.start_song_from_title("BOSS");
|
||||
state = s_water_moving;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case s_water_waiting:
|
||||
if (EventScripts.bounce_in_box(hitbox, tl.x + 16 * 7 + 4, tl.x + 12, tl.y + 16 * 8, tl.y + 16) != 0) {
|
||||
play_sfx("bounce");
|
||||
}
|
||||
// Timeout for launching a bullet
|
||||
t_blink += FlxG.elapsed;
|
||||
if (t_blink > tm_blink[max_health - health]) {
|
||||
|
||||
t_blink = 0;
|
||||
bullet = grp_water_bullets.getFirstDead() as FlxSprite;
|
||||
if (bullet == null) break;
|
||||
bullet.exists = true;
|
||||
bullet.alive = true;
|
||||
bullet.play("move");
|
||||
play("blink");
|
||||
|
||||
play_sfx("shoot");
|
||||
bullet.velocity.x = bullet.velocity.y = 50;
|
||||
bullet.x = x; bullet.y = y;
|
||||
}
|
||||
|
||||
// If harmed, bounce about the room, initially away from player
|
||||
// Or if at low enough health, move to land
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(hitbox)) {
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
get_hurt();
|
||||
if (health <= phase_2_health) {
|
||||
water_death_logic();
|
||||
} else {
|
||||
state = s_water_moving;
|
||||
}
|
||||
play("closed", true);
|
||||
velocity.x = Math.min(20, move_vel * Math.random());
|
||||
velocity.y = Math.sqrt(move_vel * move_vel - velocity.x * velocity.x);
|
||||
|
||||
player.facing == UP ? velocity.y *= -1 : 1;
|
||||
player.facing == LEFT ? velocity.x *= -1: 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case s_water_moving:
|
||||
// Bounce in a box.
|
||||
if (EventScripts.bounce_in_box(hitbox, tl.x + 16 * 7 + 4, tl.x + 12, tl.y + 16 * 8, tl.y + 16) != 0) {
|
||||
play_sfx("bounce");
|
||||
}
|
||||
if (!player.invincible && hitbox.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
// After a timeout, return back to drifting state,
|
||||
// speed based on current health
|
||||
t_move += FlxG.elapsed;
|
||||
if (t_move > tm_move) {
|
||||
t_move = 0;
|
||||
velocity.x = velocity.y = (max_health - health) * 15;
|
||||
play("blink");
|
||||
state = s_water_waiting;
|
||||
}
|
||||
if (!flickering && player.broom.visible && player.broom.overlaps(hitbox)) {
|
||||
get_hurt();
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
if (health <= phase_2_health) {
|
||||
water_death_logic();
|
||||
} else {
|
||||
t_move = 0;
|
||||
velocity.x *= 1.5;
|
||||
velocity.y *= 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
// If hit, reset the timeout and bounce even faster.
|
||||
|
||||
break;
|
||||
case s_water_leaving:
|
||||
velocity.x = 0;
|
||||
//play smoe harmed animation
|
||||
velocity.y = 40;
|
||||
if (y > tl.y + 16 * 6) {
|
||||
framePixels_y_push++;
|
||||
alpha -= 0.05;
|
||||
if (alpha == 0) {
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
global_state = gs_transition_to_land;
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for each (bullet in grp_water_bullets.members) {
|
||||
if (bullet == null || !bullet.alive) continue;
|
||||
if (!player.invincible && bullet.overlaps(player) && player.state != player.S_AIR) {
|
||||
player.touchDamage(1);
|
||||
bullet.play("pop");
|
||||
bullet.alive = false;
|
||||
bullet.velocity.x = bullet.velocity.y = 0;
|
||||
play_sfx("poof");
|
||||
}
|
||||
|
||||
if (player.broom.visible && player.broom.overlaps(bullet)) {
|
||||
bullet.play("pop");
|
||||
bullet.alive = false;
|
||||
bullet.velocity.x = bullet.velocity.y = 0;
|
||||
play_sfx("poof");
|
||||
}
|
||||
|
||||
EventScripts.bounce_in_box(bullet, tl.x + 16 * 8, tl.x, tl.y + 16 * 9, tl.y);
|
||||
}
|
||||
}
|
||||
|
||||
//intro stuff, transitions to water
|
||||
private function do_new():void {
|
||||
global_state = gs_water;
|
||||
}
|
||||
|
||||
private function water_death_logic():void
|
||||
{
|
||||
velocity.x = 0;
|
||||
state = s_water_leaving;
|
||||
EventScripts.drop_big_health(x, y, 1);
|
||||
cur_health = health;
|
||||
for each (var bullet:FlxSprite in grp_water_bullets.members) {
|
||||
bullet.play("pop");
|
||||
bullet.alive = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_hurt():void
|
||||
{
|
||||
health--;
|
||||
if (global_state == gs_land) {
|
||||
flicker(1.0);
|
||||
} else {
|
||||
flicker(2.3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function shoot_big_bullet():void
|
||||
{
|
||||
var b:FlxSprite = grp_water_bullets.getFirstDead() as FlxSprite;
|
||||
if (b == null) return;
|
||||
b.play("move_land");
|
||||
b.my_shadow.play("get_small");
|
||||
b.alive = b.exists = b.my_shadow.exists = true;
|
||||
b.x = x + width;
|
||||
b.y = y + 2;
|
||||
EventScripts.scale_vector(new Point(x + width, y + 4), new Point(player.x, player.y), b.velocity, (EventScripts.distance(player, this) - width) / b.parabola_thing.period);
|
||||
b.velocity.y += 5 * Math.random();
|
||||
b.velocity.x += 5 * Math.random();
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
cur_health = health;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
package entity.enemy.hotel
|
||||
{
|
||||
import entity.gadget.Dust;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
public class Steam_Pipe extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
private var dame_frame:int;
|
||||
private var added_to_parent:Boolean = false;
|
||||
|
||||
private var eject_pt:Point;
|
||||
private var eject_vel:int = 50;
|
||||
public var steam_clouds:FlxGroup = new FlxGroup(6);
|
||||
public var timers:Array;
|
||||
private var PUSH_VEL:int = 50;
|
||||
|
||||
|
||||
private var active_region:FlxSprite = new FlxSprite();
|
||||
private var disabled:Boolean = false;
|
||||
|
||||
|
||||
//dame frames - DRUL
|
||||
|
||||
[Embed(source = "../../../res/sprites/enemies/hotel/steam_pipe.png")] public static var steam_pipe_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/hotel/steam.png")] public static var steam_sprite:Class;
|
||||
|
||||
public function Steam_Pipe(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
loadGraphic(steam_pipe_sprite, true, false, 16, 16);
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
|
||||
// Set directions and active regions (where you are pushed), and ejection points for the steam clouds
|
||||
/* ADD ANIMATIONS FOR STEAM PIPE (if any) */
|
||||
switch(dame_frame) {
|
||||
case 0:
|
||||
eject_pt = new Point(x + 2, y + Registry.HEADER_HEIGHT + 10);
|
||||
active_region = new FlxSprite(x + 3, y + 16 + Registry.HEADER_HEIGHT);
|
||||
active_region.makeGraphic(10, 16, 0xff123123);
|
||||
frame = 0; facing = DOWN;
|
||||
break;
|
||||
case 1:
|
||||
eject_pt = new Point(x + 14, y + 5 + Registry.HEADER_HEIGHT);
|
||||
active_region = new FlxSprite(x + 16, y + Registry.HEADER_HEIGHT + 3);
|
||||
active_region.makeGraphic(16, 10, 0xff123123);
|
||||
addAnimation("do_something", [1], 12);
|
||||
frame = 1; facing = RIGHT;
|
||||
break;
|
||||
case 2:
|
||||
eject_pt = new Point(x + 3, y - 2 + Registry.HEADER_HEIGHT);
|
||||
frame = 2; facing = UP;
|
||||
active_region = new FlxSprite(x + 3, y + Registry.HEADER_HEIGHT - 16);
|
||||
active_region.makeGraphic(10, 16, 0xff123123);
|
||||
addAnimation("do_something", [2], 12);
|
||||
break;
|
||||
case 3:
|
||||
eject_pt = new Point(x - 6, y + 3 + Registry.HEADER_HEIGHT);
|
||||
frame = 3; facing = LEFT;
|
||||
active_region = new FlxSprite(x - 16, y + Registry.HEADER_HEIGHT + 3);
|
||||
active_region.makeGraphic(16, 10, 0xff123123);
|
||||
addAnimation("do_something", [3], 12);
|
||||
break;
|
||||
}
|
||||
play("do_something");
|
||||
|
||||
active_region.visible = false;
|
||||
|
||||
timers = new Array(steam_clouds.maxSize);
|
||||
|
||||
|
||||
//Randomize the size of the clouds a little
|
||||
/* ADD ANIMATIONS FOR STEAM CLOU */
|
||||
for (var i:int = 0; i < steam_clouds.maxSize; i++) {
|
||||
var steam_cloud:FlxSprite = new FlxSprite();
|
||||
steam_cloud.loadGraphic(steam_sprite, true, false, 16, 16);
|
||||
steam_cloud.addAnimation("s", [0, 1], 10);
|
||||
steam_cloud.play("s");
|
||||
//steam_cloud.flicker( -1);
|
||||
steam_clouds.add(steam_cloud);
|
||||
steam_cloud.x = eject_pt.x;
|
||||
steam_cloud.y = eject_pt.y;
|
||||
steam_cloud.scale.x = steam_cloud.scale.y = 0.8 + 0.2 * Math.random();
|
||||
steam_cloud.width = steam_cloud.height = width * steam_cloud.scale.x;
|
||||
//steam_cloud.angle = 360 * Math.random();
|
||||
timers[i] = 30 + int(20 * Math.random()); //Timeouts for steam clouds to reset
|
||||
set_vel(steam_cloud);
|
||||
}
|
||||
|
||||
add_sfx("pew", Registry.sound_data.fireball_group);
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (!added_to_parent) {
|
||||
added_to_parent = true;
|
||||
parent.bg_sprites.add(active_region);
|
||||
parent.fg_sprites.add(steam_clouds);
|
||||
}
|
||||
|
||||
// dust on the active region disables the pushing effect
|
||||
disabled = false;
|
||||
for each (var dust:Dust in Registry.subgroup_dust) {
|
||||
if (dust != null) {
|
||||
if (dust.overlaps(active_region) && (dust.frame != Dust.EMPTY_FRAME) && (dust != player.raft)) {
|
||||
disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for each (var gas:FlxSprite in Registry.subgroup_gas) {
|
||||
if (gas != null) {
|
||||
for each (var steam_cloud:FlxSprite in steam_clouds.members) {
|
||||
if (steam_cloud != null) {
|
||||
if (gas.overlaps(steam_cloud)) {
|
||||
gas.velocity.x += 0.01 * steam_cloud.velocity.x;
|
||||
gas.velocity.y += 0.01 * steam_cloud.velocity.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ctr:int = 0;
|
||||
//Change timers for the visual effect of steam spewing forth, or being held by the dust
|
||||
for each (var steam:FlxSprite in steam_clouds.members) {
|
||||
timers[ctr]--;
|
||||
if (timers[ctr] == 0) {
|
||||
if (!disabled) {
|
||||
timers[ctr] = 30 + int(20 * Math.random());
|
||||
} else {
|
||||
timers[ctr] = 3 + int(2 * Math.random());
|
||||
}
|
||||
steam.x = eject_pt.x;
|
||||
steam.y = eject_pt.y;
|
||||
set_vel(steam);
|
||||
play_sfx("pew");
|
||||
}
|
||||
ctr++;
|
||||
|
||||
if (disabled == false) {
|
||||
if (steam.overlaps(player)) {
|
||||
pushplayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Push the player if the pipe isn't disabled, and player touches active region
|
||||
if (!disabled) {
|
||||
if (player.overlaps(active_region)) {
|
||||
pushplayer();
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
//randomize velocity of clouds within certain ranges
|
||||
private function set_vel(steam_cloud:FlxSprite):void
|
||||
{
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
steam_cloud.velocity.y = eject_vel + 20 * Math.random();
|
||||
steam_cloud.velocity.x = -30 + 60 * Math.random();
|
||||
break;
|
||||
case UP:
|
||||
steam_cloud.velocity.y = -eject_vel - 20 * Math.random();
|
||||
steam_cloud.velocity.x = -30 + 60 * Math.random();
|
||||
break;
|
||||
case LEFT:
|
||||
steam_cloud.velocity.x = -eject_vel - 20 * Math.random();
|
||||
steam_cloud.velocity.y = -30 + 60 * Math.random();
|
||||
break;
|
||||
case RIGHT:
|
||||
steam_cloud.velocity.x = eject_vel + 20 * Math.random();
|
||||
steam_cloud.velocity.y = -30 + 60 * Math.random();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function pushplayer():void
|
||||
{
|
||||
switch(facing) {
|
||||
case DOWN:
|
||||
player.additional_y_vel = PUSH_VEL; break;
|
||||
case UP:
|
||||
player.additional_y_vel = -PUSH_VEL; break;
|
||||
case LEFT:
|
||||
player.additional_x_vel = -PUSH_VEL; break;
|
||||
case RIGHT:
|
||||
player.additional_x_vel = PUSH_VEL; break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
package entity.enemy.redcave
|
||||
{
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import mx.core.FlexSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
import states.PlayState;
|
||||
public class Four_Shooter extends FlxSprite
|
||||
{
|
||||
[Embed(source = "../../../res/sprites/enemies/redcave/f_four_shooter.png")] public static var four_shooter_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/enemies/redcave/f_four_shooter_bullet.png")] public static var four_shooter_bullet_sprite:Class;
|
||||
|
||||
|
||||
|
||||
public var cid:int = CLASS_ID.FOUR_SHOOTER;
|
||||
public var xml:XML;
|
||||
public var timer_max:Number = 1.5;
|
||||
public var timer:Number = timer_max;
|
||||
public var state:int = 0;
|
||||
public var S_STRAIGHT:int = 0;
|
||||
public var S_DIAG:int = 1;
|
||||
public var bullets:FlxGroup;
|
||||
public var NR_BULLETS:int = 12;
|
||||
public var parent:PlayState;
|
||||
public var VEL:int = 50;
|
||||
public var player:Player;
|
||||
public function Four_Shooter(_xml:XML, _parent:PlayState, _player:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
|
||||
bullets = new FlxGroup();
|
||||
for (var i:int = 0; i < NR_BULLETS; i++) {
|
||||
var bullet:FlxSprite = new FlxSprite(0, 0);
|
||||
/* Animations for bullets */
|
||||
bullet.loadGraphic(four_shooter_bullet_sprite, true, false, 8, 8);
|
||||
bullet.addAnimation("move", [0, 1], 12, true);
|
||||
bullet.addAnimation("explode", [2, 3], 10, false);
|
||||
|
||||
bullet.play("move");
|
||||
bullet.has_tile_callbacks = false;
|
||||
bullets.add(bullet);
|
||||
bullet.width = bullet.height = 4;
|
||||
bullet.offset.x = bullet.offset.y = 2;
|
||||
}
|
||||
immovable = true;
|
||||
bullets.setAll("alive", false);
|
||||
parent = _parent;
|
||||
parent.otherObjects.push(bullets);
|
||||
player = _player;
|
||||
|
||||
/* Animations for four_shooter */
|
||||
loadGraphic(four_shooter_sprite, true, false, 16, 16);
|
||||
addAnimation("nesw", [0]);
|
||||
addAnimation("shoot_then_nesw_to_diag", [0, 1, 2, 2], 3, false);
|
||||
addAnimation("diag", [2]);
|
||||
addAnimation("shoot_then_diag_to_nesw", [2, 1, 0, 0], 3, false);
|
||||
play("nesw");
|
||||
|
||||
add_sfx("shoot", Registry.sound_data.four_shooter_shoot_group);
|
||||
add_sfx("pop", Registry.sound_data.four_shooter_pop_group);
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(player, this);
|
||||
timer -= FlxG.elapsed;
|
||||
if (timer < 0) {
|
||||
timer = timer_max;
|
||||
shoot();
|
||||
rotate();
|
||||
} else {
|
||||
if (_curAnim.frames.length - 1 == _curFrame) {
|
||||
if (state == S_DIAG) {
|
||||
play("diag");
|
||||
} else {
|
||||
play("nesw");
|
||||
}
|
||||
}
|
||||
}
|
||||
check_overlap();
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function reset_bullet(b:FlxSprite, m:Object):void {
|
||||
if (!b.alive) return;
|
||||
b.alive = false;
|
||||
play_sfx("pop");
|
||||
b.velocity.x = b.velocity.y = 0;
|
||||
b.play("explode");
|
||||
}
|
||||
public function check_overlap():void {
|
||||
FlxG.collide(bullets, parent.curMapBuf, reset_bullet);
|
||||
for each (var b:FlxSprite in bullets.members) {
|
||||
if (b != null) {
|
||||
if (player.state != player.S_AIR && b.alive && b.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
reset_bullet(b, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for each (var s:FlxSprite in bullets.members) {
|
||||
if (s == null || !s.alive) continue;
|
||||
if (s.velocity.x == 0) {
|
||||
if (s.y > parent.lowerBorder) {
|
||||
reset_bullet(s, null); continue;
|
||||
} else if (s.y < parent.upperBorder) {
|
||||
reset_bullet(s, null); continue;
|
||||
}
|
||||
} else {
|
||||
if (s.x > parent.rightBorder) {
|
||||
reset_bullet(s, null); continue;
|
||||
} else if (s.x < parent.leftBorder) {
|
||||
reset_bullet(s, null); continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function shoot():void {
|
||||
var b:FlxSprite;
|
||||
var is_diag:Boolean = false;
|
||||
play_sfx("shoot");
|
||||
if (state == S_DIAG) {
|
||||
is_diag = true;
|
||||
}
|
||||
for (var i:int = 0; i < 4; i ++) {
|
||||
b = bullets.getFirstDead() as FlxSprite;
|
||||
if (b == null) break;
|
||||
b.alive = true;
|
||||
b.play("move");
|
||||
switch (i) {
|
||||
case 0:
|
||||
b.velocity.x = -VEL;
|
||||
b.x = x - 2;
|
||||
b.y = y + 6;
|
||||
if (is_diag) { b.velocity.y = VEL * .7; b.velocity.x = -VEL * .7;
|
||||
b.y = y + 11; b.x = x + 2; }
|
||||
|
||||
|
||||
break;
|
||||
case 1:
|
||||
b.velocity.x = VEL;
|
||||
b.x = x + 12;
|
||||
b.y = y + 7;
|
||||
if (is_diag) { b.velocity.y = -VEL * .7; b.velocity.x = VEL * .7;
|
||||
b.y = y + 2; b.x = x + 11; }
|
||||
break;
|
||||
case 2:
|
||||
b.velocity.y = VEL;
|
||||
b.x = x + 6;
|
||||
b.y = y + 13 ;
|
||||
if (is_diag) { b.velocity.y = VEL * .7; b.velocity.x = VEL * .7;
|
||||
b.x = x + 12; b.y = y +11; }
|
||||
|
||||
break;
|
||||
case 3:
|
||||
b.velocity.y = -VEL;
|
||||
b.x = x + 6;
|
||||
b.y = y - 1;
|
||||
if (is_diag) { b.velocity.y = -VEL * .7; b.velocity.x = -VEL * .7;
|
||||
b.x = x + 1; b.y = y + 1; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function rotate():void {
|
||||
if (state == S_STRAIGHT) {
|
||||
play("shoot_then_nesw_to_diag");
|
||||
state = S_DIAG;
|
||||
} else {
|
||||
play("shoot_then_diag_to_nesw");
|
||||
state = S_STRAIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package entity.enemy.redcave
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
/**
|
||||
* ...
|
||||
* @author seagaia
|
||||
|
||||
*/
|
||||
public class Mover extends FlxSprite
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param _x duh
|
||||
* @param _y duh
|
||||
* @param target Where the Mover periodically moves toward.
|
||||
* @param _move_timer Latency between dashes
|
||||
*/
|
||||
|
||||
public var move_timer:Number;
|
||||
public var move_timer_init:Number;
|
||||
public var target:FlxSprite;
|
||||
public var cid:int = CLASS_ID.MOVER;
|
||||
public var INCREMENTED_REG:Boolean = false;
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
private var parent:*;
|
||||
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_mover.png")] public static var mover_sprite:Class;
|
||||
|
||||
public function Mover(_x:int, _y:int, _target:FlxSprite, _move_timer:Number,_xml:XML,_p:Player,_parent:*) {
|
||||
super(_x, _y);
|
||||
|
||||
loadGraphic(mover_sprite, true, false, 16, 16);
|
||||
addAnimation("foom", [0,1], 4, false);
|
||||
addAnimation("still", [1]);
|
||||
addAnimation("die", [0, 1, 2, 1, 2, 1, 2], 12, false);
|
||||
play("foom");
|
||||
|
||||
move_timer = _move_timer;
|
||||
move_timer_init = move_timer;
|
||||
target = _target;
|
||||
drag.x = 100;
|
||||
drag.y = 100;
|
||||
xml = _xml;
|
||||
|
||||
player = _p;
|
||||
parent = _parent;
|
||||
|
||||
add_sfx("move", Registry.sound_data.mover_move_group);
|
||||
add_sfx("die", Registry.sound_data.mover_die_group);
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
FlxG.collide(parent.curMapBuf, this);
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
|
||||
override public function update():void {
|
||||
|
||||
if (alive) {
|
||||
if (move_timer > 0) {
|
||||
if (_curAnim.name == "foom" && (_curAnim.frames.length - 1 == _curFrame)) {
|
||||
play("still");
|
||||
}
|
||||
move_timer -= FlxG.elapsed;
|
||||
} else {
|
||||
play("foom");
|
||||
play_sfx("move");
|
||||
move_timer = move_timer_init;
|
||||
var dx:Number = target.x - x;
|
||||
var dy:Number = target.y - y;
|
||||
var norm:Number = Math.min(3, 100 / Math.sqrt(dx * dx + dy * dy));
|
||||
velocity.x = dx * norm + (-5 + 5*Math.random());
|
||||
velocity.y = dy * norm + ( -5 * 5 * Math.random());
|
||||
}
|
||||
}
|
||||
|
||||
if (!visible) {
|
||||
if (!INCREMENTED_REG) {
|
||||
INCREMENTED_REG = true;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If movers touch a laser they disappear
|
||||
if (visible) {
|
||||
if (player.overlaps(this)) {
|
||||
player.additional_x_vel = velocity.x;
|
||||
player.additional_y_vel = velocity.y;
|
||||
}
|
||||
|
||||
if (_curAnim.name == "die" && (_curAnim.frames.length - 1 == _curFrame)) {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
for each (var l:On_Off_Laser in Registry.subgroup_on_off_lasers) {
|
||||
if (l == null) continue;
|
||||
if (l.laser.overlaps(this) && l.state == l.s_hurting) {
|
||||
if (_curAnim.name != "die") {
|
||||
alive = false;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
play_sfx("die");
|
||||
}
|
||||
play("die");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
package entity.enemy.redcave
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* DAME PROPS:
|
||||
* frame - direction of the laser (URDL)
|
||||
* note, row determines period
|
||||
*
|
||||
*/
|
||||
public class On_Off_Laser extends FlxSprite
|
||||
{
|
||||
|
||||
public var cid:int = CLASS_ID.ON_OFF_LASER;
|
||||
public var xml:XML;
|
||||
private var LASER_WIDTH:int = 12;
|
||||
private var OFFSET:int = 0;//2;
|
||||
|
||||
|
||||
public var laser:FlxSprite;
|
||||
public var laser_active:Boolean = false;
|
||||
private var played_sound:Boolean = false;
|
||||
|
||||
private var player:Player;
|
||||
|
||||
public var state:int = 0;
|
||||
private var s_idle:int = 0;
|
||||
private var s_emerging:int = 1;
|
||||
public var s_hurting:int = 2;
|
||||
private var s_receding:int = 3;
|
||||
|
||||
private var t:Number = 0;
|
||||
private var tm_idle:Number = 0;
|
||||
private var tm_hurting:Number = 0;
|
||||
|
||||
private var did_move_offset:Boolean = false;
|
||||
// up, left
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_on_off_h.png")] public var h_on_off_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_on_off_v.png")] public var v_on_off_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/on_off_shooter.png")] public static var on_off_shooter_sprite:Class;
|
||||
|
||||
public function On_Off_Laser(_xml:XML,_player:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
immovable = true;
|
||||
var dame_frame:int = parseInt(xml.@frame);
|
||||
switch (dame_frame) {
|
||||
case 0: //up
|
||||
laser = new FlxSprite(x + OFFSET, y - 144);
|
||||
laser.loadGraphic(v_on_off_sprite, true, true, 16, 144);
|
||||
laser.height = 112;
|
||||
laser.scale.y = -1;
|
||||
laser.width = 8;
|
||||
laser.offset.x = 4;
|
||||
laser.x += 4;
|
||||
laser.y += 32;
|
||||
laser.offset.y += 32;
|
||||
|
||||
break;
|
||||
case 1: //r
|
||||
laser = new FlxSprite(x + width, y + OFFSET);
|
||||
laser.loadGraphic(h_on_off_sprite, true, true, 144, 16);
|
||||
laser.scale.x = -1;
|
||||
laser.offset.x = 16;
|
||||
laser.width = 128;
|
||||
laser.offset.x = 16;
|
||||
laser.height = 8;
|
||||
laser.offset.y = 4;
|
||||
laser.y += 4;
|
||||
break;
|
||||
case 2: //down
|
||||
laser = new FlxSprite(x + OFFSET, y + 16); //+height );
|
||||
laser.loadGraphic(v_on_off_sprite, true, false, 16, 144);
|
||||
laser.height = 112;
|
||||
laser.offset.y = 16;
|
||||
laser.width = 8;
|
||||
laser.offset.x = 4;
|
||||
laser.x += 4;
|
||||
break;
|
||||
case 3:
|
||||
laser = new FlxSprite(x - 144, y + OFFSET);
|
||||
laser.loadGraphic(h_on_off_sprite, true, false, 144, 16);
|
||||
laser.offset.x = -16;
|
||||
laser.width = 112;
|
||||
laser.height = 8;
|
||||
laser.offset.x = 16;
|
||||
laser.x += 32;
|
||||
laser.offset.y = 4;
|
||||
laser.y += 4;
|
||||
break;
|
||||
}
|
||||
/* Shooter/node's animations */
|
||||
//urdl
|
||||
|
||||
loadGraphic(on_off_shooter_sprite, true, false, 16, 16);
|
||||
switch (dame_frame) {
|
||||
case 2: // If pointing down
|
||||
addAnimation("shooter_closed", [0,1], 2);
|
||||
addAnimation("shooter_open", [2]);
|
||||
break;
|
||||
case 1: //pointing right
|
||||
case 0: // ...down
|
||||
case 3: //left
|
||||
if (dame_frame == 1) {
|
||||
angle = 90;
|
||||
} else if (dame_frame == 3) {
|
||||
angle = -90;
|
||||
}
|
||||
addAnimation("shooter_closed", [3,4], 2);
|
||||
addAnimation("shooter_open", [5]);
|
||||
break;
|
||||
}
|
||||
play("shooter_closed");
|
||||
|
||||
/* Steam's animations */
|
||||
laser.addAnimation("steam_is_harmful", [3, 4, 5, 6], 15, true);
|
||||
/* for these non-looping anims, keep the extra frame index at the end because I use the animation
|
||||
* index to tell the steam to change to the next state */
|
||||
laser.addAnimation("recede", [0, 1, 2, 2], 5, false);
|
||||
laser.addAnimation("emerge", [2, 1, 0, 0], 5, false);
|
||||
laser.addAnimation("idle_invisible", [0], 2,true);
|
||||
laser.visible = false;
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0: case 1: case 2: case 3:
|
||||
tm_hurting = tm_idle = 2;
|
||||
break;
|
||||
}
|
||||
laser.play("idle_invisible");
|
||||
laser.visible = false;
|
||||
|
||||
player = _player;
|
||||
Registry.subgroup_on_off_lasers.push(this);
|
||||
// anims: steam from head, head opening
|
||||
// sfx: steam blowing
|
||||
add_sfx("shoot", Registry.sound_data.on_off_laser_shoot);
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (!did_move_offset) {
|
||||
//urdl
|
||||
did_move_offset = true;
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0:
|
||||
laser.offset.y -= 16;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case s_idle:
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_idle) {
|
||||
t = 0;
|
||||
laser.visible = true;
|
||||
state = s_emerging;
|
||||
play("shooter_open");
|
||||
play_sfx("shoot");
|
||||
laser.play("emerge");
|
||||
}
|
||||
break;
|
||||
case s_emerging:
|
||||
laser.flicker(0.05);
|
||||
if (laser._curFrame == (laser._curAnim.frames.length - 1)) {
|
||||
laser.play("steam_is_harmful");
|
||||
state = s_hurting;
|
||||
}
|
||||
break;
|
||||
case s_hurting:
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm_hurting) {
|
||||
laser.play("recede");
|
||||
t = 0;
|
||||
state = s_receding;
|
||||
}
|
||||
if (player.overlaps(laser)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
break;
|
||||
case s_receding:
|
||||
laser.flicker(0.05);
|
||||
if (laser._curFrame == (laser._curAnim.frames.length - 1)) {
|
||||
laser.play("idle_invisible");
|
||||
laser.visible = false;
|
||||
state = s_idle;
|
||||
play("shooter_closed");
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,853 @@
|
|||
package entity.enemy.redcave
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import mx.core.FlexSprite;
|
||||
import org.flixel.FlxBasic;
|
||||
import org.flixel.FlxCamera;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSave;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.BaseTypes.Bullet;
|
||||
import states.PlayState;
|
||||
|
||||
/**
|
||||
* Red cave boss
|
||||
*/
|
||||
public class Red_Boss extends FlxSprite
|
||||
{
|
||||
private var player:Player;
|
||||
private var parent:PlayState;
|
||||
private var xml:XML;
|
||||
private var timer:Number = 0;
|
||||
|
||||
private var ripple:FlxSprite;
|
||||
|
||||
private var added_to_parent:Boolean = false;
|
||||
public var cid:int = CLASS_ID.RED_BOSS;
|
||||
private var hit_timer_max:Number = 1.3;
|
||||
|
||||
private var pushdown_angle:Number = 0;
|
||||
private var amp:int = 5;
|
||||
|
||||
public var state:int = 0;
|
||||
private var s_intro:int = 0;
|
||||
private var intro_push_px:int = 32;
|
||||
private var boss_fight_started:Boolean = false;
|
||||
|
||||
private var s_dead:int = 6;
|
||||
private var s_dying:int = 5;
|
||||
private var played_death_anim:Boolean = false;
|
||||
private var t_death_to_cutscene:Number = 0;
|
||||
private var t_death_push_tick:Number = 0;
|
||||
private var tm_death_to_cutscene:Number = 2;
|
||||
private var tm_death_push_tick:Number = 0.15;
|
||||
private var death_push_pixels:int = 0;
|
||||
private var final_alpha:Number = 1;
|
||||
|
||||
private var ctr:int = 0;
|
||||
/* stun wave entitites */
|
||||
private var s_stun_wave:int = 2;
|
||||
private var small_wave:FlxSprite = new FlxSprite();
|
||||
private var big_wave:FlxSprite = new FlxSprite();
|
||||
private var player_hit_big_wave:Boolean = false;
|
||||
private var small_wave_risen:Boolean = false;
|
||||
private var small_wave_fallen:Boolean = false;
|
||||
private var big_wave_risen:Boolean = false;
|
||||
private var big_wave_fallen:Boolean = false;
|
||||
|
||||
/* Dash entities */
|
||||
private var s_dash:int = 3;
|
||||
private var dash_timer:Number = 0;
|
||||
private var dash_timer_max:Number = 5.0;
|
||||
|
||||
|
||||
/* L-splash entities */
|
||||
private var s_l_splash:int = 1;
|
||||
public var too_close_count:int = 0;
|
||||
|
||||
private var timer_l_splash_max:Number = 3.0;
|
||||
private var timer_l_splash:Number = 0;
|
||||
private var sig_l_splash:Boolean = false;
|
||||
private var on_l_splash:Boolean = false;
|
||||
private var group_l_splash:FlxGroup = new FlxGroup(8);
|
||||
private var group_l_splash_shadows:FlxGroup = new FlxGroup(8);
|
||||
private var l_splash_start_tile_coords:Array = new Array(new Point(1, 2), new Point(1, 3), new Point(1, 4), new Point(1, 5));
|
||||
private var l_splash_coeffs:Array = new Array(0,0,0,0,0,0,0,0);
|
||||
private var l_splash_periods:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
private var l_splash_timers:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
/* Tentacles */
|
||||
private var tentacles:FlxGroup = new FlxGroup(4);
|
||||
private var tentacle_warnings:FlxGroup = new FlxGroup(4);
|
||||
private var sig_tentacle_thrust:Boolean = false;
|
||||
private var on_tentacle_thrust:Boolean = false;
|
||||
private var timer_tentacle_thrust_max:Number = 3.0;
|
||||
private var timer_tentacle_thrust:Number = 3.0;
|
||||
private var tentacle_thrust_timers:Array = new Array(0, 0, 0, 0);
|
||||
private var tt_type:int = NONE;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Top left walkable tile's world coordinates.
|
||||
*/
|
||||
private var pt_rm_tl:Point = new Point();
|
||||
|
||||
private var bullet_pool:FlxGroup = new FlxGroup(10);
|
||||
private var bullet_shadows:FlxGroup = new FlxGroup(10);
|
||||
private var tl:FlxPoint;
|
||||
[Embed (source = "../../../res/sprites/enemies/red_boss.png")] public static var red_boss_sprite:Class;
|
||||
[Embed(source = "../../../res/sprites/redboss_alternate.png")] public var red_boss_alternate_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_big_wave.png")] public var big_wave_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_small_wave.png")] public var small_wave_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_tentacle.png")] public var tentacle_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_warning.png")] public var warning_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_bullet.png")] public var bullet_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/red_boss_ripple.png")] public static var ripple_sprite:Class;
|
||||
|
||||
public function Red_Boss(_xml:XML,_parent:PlayState,_player:Player )
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
|
||||
if (Registry.FUCK_IT_MODE_ON) {
|
||||
state = s_dying;
|
||||
//state = s_stun_wave;
|
||||
}
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
tl = new FlxPoint(Registry.CURRENT_GRID_X * 160, Registry.CURRENT_GRID_Y * 160 + 20);
|
||||
player.grid_entrance_x = tl.x + 23;
|
||||
player.grid_entrance_y = tl.y + 40;
|
||||
|
||||
immovable = true;
|
||||
|
||||
/* HEAD SPRITES */
|
||||
var stupid:Boolean = false;
|
||||
if (stupid) {
|
||||
loadGraphic(red_boss_alternate_sprite, true, false, 32, 32);
|
||||
} else {
|
||||
loadGraphic(red_boss_sprite, true, false, 32, 32);
|
||||
}
|
||||
addAnimation("bob", [0], 20, true);
|
||||
addAnimation("close_eyes", [1],10,false);
|
||||
addAnimation("warn", [2,2],24);
|
||||
addAnimation("die", [0, 1, 2], 3, false);
|
||||
addAnimation("last_death_frame", [1], 2);
|
||||
play("bob");
|
||||
height = 19;
|
||||
offset.y = 13;
|
||||
width = 26;
|
||||
offset.x = 3;
|
||||
framePixels_y_push = 32;
|
||||
|
||||
ripple = new FlxSprite;
|
||||
ripple.loadGraphic(ripple_sprite, true, false, 48, 8);
|
||||
ripple.addAnimation("move", [0, 1], 12);
|
||||
ripple.play("move");
|
||||
|
||||
pt_rm_tl.x = Registry.CURRENT_GRID_X * Registry.SCREEN_WIDTH_IN_PIXELS + Registry.TILE_WIDTH;
|
||||
pt_rm_tl.y = Registry.CURRENT_GRID_Y * Registry.SCREEN_HEIGHT_IN_PIXELS + Registry.HEADER_HEIGHT + Registry.TILE_WIDTH;
|
||||
|
||||
/* BULLET + BULLET SHADOW SPRITES */
|
||||
for (var i:int = 0; i < bullet_pool.maxSize; i++) {
|
||||
|
||||
var b:FlxSprite = new FlxSprite();
|
||||
b.loadGraphic(bullet_sprite, true, false, 8, 8);
|
||||
b.addAnimation("move", [0, 1], 12);
|
||||
b.addAnimation("explode", [2, 3, 4, 4], 14, false);
|
||||
/* load bulet shadow gfx */
|
||||
b.my_shadow = EventScripts.make_shadow("8_small");
|
||||
b.parabola_thing = new Parabola_Thing(b, 48, 1.2 + Math.random(), "offset", "y");
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
b.visible = true;
|
||||
|
||||
b.play("move");
|
||||
b.my_shadow.play("get_big");
|
||||
|
||||
bullet_pool.add(b);
|
||||
bullet_shadows.add(b.my_shadow);
|
||||
|
||||
}
|
||||
bullet_pool.setAll("exists", false);
|
||||
|
||||
bullet_shadows.setAll("exists", false);
|
||||
|
||||
var j:int;
|
||||
|
||||
/* TENTACLE + WARNING SPRITES */
|
||||
for (j = 0; j < tentacles.maxSize; j++) {
|
||||
var tentacle:FlxSprite = new FlxSprite();
|
||||
tentacle.loadGraphic(tentacle_sprite, true, false, 10, 64);
|
||||
tentacle.addAnimation("move", [0, 1], 8);
|
||||
tentacle.play("move");
|
||||
tentacles.add(tentacle);
|
||||
|
||||
var tentacle_warning:FlxSprite = new FlxSprite();
|
||||
tentacle_warning.loadGraphic(warning_sprite, true, false, 10, 10);
|
||||
tentacle_warning.addAnimation("move", [0, 1], 8);
|
||||
tentacle_warning.play("move");
|
||||
tentacle_warnings.add(tentacle_warning);
|
||||
}
|
||||
tentacles.setAll("exists", false);
|
||||
tentacle_warnings.setAll("exists", false);
|
||||
tentacles.setAll("immovable", true);
|
||||
tentacle_warnings.setAll("immovable", true);
|
||||
|
||||
|
||||
/* SMALL AND BIG WAVE SPRITES */
|
||||
small_wave = new FlxSprite(0, 0);
|
||||
small_wave.loadGraphic(small_wave_sprite, true, false, 16, 64);
|
||||
small_wave.addAnimation("move", [0, 1], 8);
|
||||
small_wave.addAnimation("rise", [2, 3], 8, true);
|
||||
small_wave.addAnimation("fall", [1, 2, 3, 4], 8, false);
|
||||
small_wave.play("move");
|
||||
|
||||
big_wave = new FlxSprite(0, 0);
|
||||
big_wave.loadGraphic(big_wave_sprite, true, false, 32, 80);
|
||||
big_wave.addAnimation("move", [0, 1], 8);
|
||||
big_wave.addAnimation("rise", [2, 1, 0], 8, false);
|
||||
big_wave.addAnimation("fall", [1, 2, 3], 8, false);
|
||||
big_wave.play("move");
|
||||
|
||||
big_wave.exists = small_wave.exists = false;
|
||||
|
||||
|
||||
/* SFX* */
|
||||
add_sfx("rise_from_water", Registry.sound_data.bubble_loop);
|
||||
add_sfx("bubble", Registry.sound_data.bubble_group);
|
||||
add_sfx("bubble_triple", Registry.sound_data.bubble_triple_group);
|
||||
add_sfx("moan", Registry.sound_data.redboss_moan);
|
||||
add_sfx("small_wave", Registry.sound_data.small_wave);
|
||||
add_sfx("big_wave", Registry.sound_data.big_wave);
|
||||
add_sfx("death", Registry.sound_data.redboss_death);
|
||||
|
||||
health = 12;
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
player.AUTO_JUMP_HEIGHT = 22;
|
||||
parent.bg_sprites.remove(bullet_shadows,true);
|
||||
parent.fg_sprites.remove(bullet_pool,true);
|
||||
for each (var t:FlxSprite in tentacles.members) {
|
||||
if (t != null) parent.sortables.remove(t, true);
|
||||
t.destroy(); t = null;
|
||||
}
|
||||
|
||||
for each (t in tentacle_warnings.members) {
|
||||
if (t != null) parent.sortables.remove(t,true);
|
||||
t.destroy(); t = null;
|
||||
}
|
||||
group_l_splash = null;
|
||||
group_l_splash_shadows = null;
|
||||
tentacles = null;
|
||||
parent.bg_sprites.remove(small_wave,true);
|
||||
parent.fg_sprites.remove(big_wave,true);
|
||||
ripple = null;
|
||||
tentacle_warnings = null; bullet_pool = null; bullet_shadows = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
timer += FlxG.elapsed;
|
||||
|
||||
ripple.x = x - 11;
|
||||
ripple.y = y + 17;
|
||||
|
||||
/* Add children to parent draw group */
|
||||
if (!added_to_parent) {
|
||||
parent.bg_sprites.add(bullet_shadows);
|
||||
parent.fg_sprites.add(bullet_pool);
|
||||
for each (var t:FlxSprite in tentacles.members) {
|
||||
if (t != null) parent.sortables.add(t);
|
||||
}
|
||||
|
||||
for each (t in tentacle_warnings.members) {
|
||||
if (t != null) parent.sortables.add(t);
|
||||
}
|
||||
added_to_parent = true;
|
||||
|
||||
parent.bg_sprites.add(ripple);
|
||||
parent.bg_sprites.add(small_wave);
|
||||
parent.bg_sprites.add(big_wave);
|
||||
}
|
||||
|
||||
/* Intro */
|
||||
if (state == s_intro) {
|
||||
play("close_eyes");
|
||||
if (!boss_fight_started) {
|
||||
Registry.sound_data.current_song.volume -= 0.05;
|
||||
if (Registry.sound_data.current_song.volume == 0) {
|
||||
Registry.sound_data.current_song.stop();
|
||||
}
|
||||
if (player.x >= pt_rm_tl.x + 32) {
|
||||
|
||||
if (!DH.scene_is_dirty(DH.name_redboss, DH.scene_redboss_before_fight)) {
|
||||
DH.start_dialogue(DH.name_redboss, DH.scene_redboss_before_fight);
|
||||
play_sfx("rise_from_water");
|
||||
player.be_idle();
|
||||
}
|
||||
|
||||
if (DH.scene_is_finished(DH.name_redboss, DH.scene_redboss_before_fight)) {
|
||||
boss_fight_started = true;
|
||||
state = s_l_splash;
|
||||
Registry.sound_data.start_song_from_title("BOSS");
|
||||
stop_sfx("rise_from_water");
|
||||
play("bob");
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
framePixels_y_push = intro_push_px;
|
||||
t_death_push_tick += FlxG.elapsed;
|
||||
if (t_death_push_tick > tm_death_push_tick) {
|
||||
t_death_push_tick = 0;
|
||||
if (intro_push_px > 0) {
|
||||
FlxG.shake(0.021, 0.1);
|
||||
intro_push_px--;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// collisions for damage etc
|
||||
if (player.broom.overlaps(this) && player.broom.visible) {
|
||||
if (timer > hit_timer_max && health >= 0) {
|
||||
timer = 0;
|
||||
health--;
|
||||
play_sfx("moan");
|
||||
flicker(0.5);
|
||||
if (health <= 0) {
|
||||
state = s_dying;
|
||||
stop_sfx("rise_from_water");
|
||||
velocity.x = velocity.y = 0;
|
||||
tentacles.exists = false;
|
||||
bullet_pool.exists = false;
|
||||
bullet_shadows.exists = false;
|
||||
tentacle_warnings.exists = false;
|
||||
tentacles.exists = false;
|
||||
big_wave.exists = small_wave.exists = false;
|
||||
player.angle = 0;
|
||||
player.angularVelocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (state == s_dying) {
|
||||
//die etc
|
||||
|
||||
if (!DH.scene_is_dirty(DH.name_redboss, DH.scene_redboss_after_fight)) {
|
||||
Registry.sound_data.stop_current_song();
|
||||
DH.start_dialogue(DH.name_redboss, DH.scene_redboss_after_fight);
|
||||
player.be_idle();
|
||||
FlxG.shake(0.05, 0.1);
|
||||
FlxG.flash(0xffff0000, 1);
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DH.scene_is_finished(DH.name_redboss, DH.scene_redboss_after_fight)) {
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
tentacles.setAll("alpha", final_alpha);
|
||||
tentacle_warnings.setAll("alpha", final_alpha);
|
||||
bullet_shadows.setAll("alpha", final_alpha);
|
||||
bullet_pool.setAll("alpha", final_alpha);
|
||||
small_wave.alpha = final_alpha;
|
||||
big_wave.alpha = final_alpha;
|
||||
ripple.alpha -= 0.005;
|
||||
|
||||
final_alpha -= 0.005;
|
||||
|
||||
if (!played_death_anim) {
|
||||
Registry.GFX_WAVE_EFFECT_ON = true;
|
||||
played_death_anim = true;
|
||||
play_sfx("death");
|
||||
play("die");
|
||||
} else {
|
||||
if (_curAnim.name == "die" && _curAnim.frames.length - 1 == _curFrame) {
|
||||
play("last_death_frame");
|
||||
}
|
||||
}
|
||||
|
||||
framePixels_y_push = death_push_pixels;
|
||||
if (framePixels_y_push >= 32) {
|
||||
framePixels_y_push = 32;
|
||||
if (t_death_to_cutscene < tm_death_to_cutscene) {
|
||||
t_death_to_cutscene += FlxG.elapsed;
|
||||
} else {
|
||||
state = s_dead;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
Registry.sound_data.start_song_from_title("REDCAVE");
|
||||
//if (!Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Redcave]) {
|
||||
//Registry.E_Load_Cutscene = true;
|
||||
//Registry.CURRENT_CUTSCENE = Cutscene.Terminal_Gate_Redcave;
|
||||
// }
|
||||
Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] = true;
|
||||
xml.@alive = "false";
|
||||
}
|
||||
}
|
||||
|
||||
if (t_death_push_tick <= tm_death_push_tick) {
|
||||
t_death_push_tick += FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
t_death_push_tick = 0;
|
||||
death_push_pixels++;
|
||||
return;
|
||||
} else if (state == s_dead) {
|
||||
Registry.GFX_WAVE_EFFECT_ON = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (FlxG.collide(this, player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
|
||||
|
||||
/* Check to send signals to attack patterns */
|
||||
if (state == s_l_splash) {
|
||||
|
||||
pushdown_angle += 0.05;
|
||||
framePixels_y_push = 5 + Math.sin(pushdown_angle % 6.28) * 5;
|
||||
timer_l_splash -= FlxG.elapsed;
|
||||
if (timer_l_splash <= 0) {
|
||||
timer_l_splash = timer_l_splash_max;
|
||||
sig_l_splash = true;
|
||||
}
|
||||
|
||||
timer_tentacle_thrust -= FlxG.elapsed;
|
||||
if (timer_tentacle_thrust <= 0) {
|
||||
timer_tentacle_thrust = timer_tentacle_thrust_max;
|
||||
sig_tentacle_thrust = true;
|
||||
tt_type = get_player_proximity_type();
|
||||
/* If player approaches too many times, then dive under */
|
||||
if (tt_type != NONE) too_close_count++;
|
||||
}
|
||||
|
||||
if (too_close_count == 2) {
|
||||
too_close_count = 0;
|
||||
state = s_stun_wave;
|
||||
}
|
||||
} else if (state == s_stun_wave) {
|
||||
do_stun_wave();
|
||||
} else if (state == s_dash) {
|
||||
|
||||
|
||||
dash_timer += FlxG.elapsed;
|
||||
if (dash_timer > dash_timer_max) {
|
||||
dash_timer = 0;
|
||||
state = s_stun_wave;
|
||||
velocity.x = velocity.y = 0;
|
||||
return;
|
||||
}
|
||||
timer_tentacle_thrust -= FlxG.elapsed;
|
||||
if (timer_tentacle_thrust <= 0) {
|
||||
timer_tentacle_thrust = timer_tentacle_thrust_max/2;
|
||||
sig_tentacle_thrust = true;
|
||||
tt_type = get_player_proximity_type();
|
||||
/* If player approaches too many times, then dive under */
|
||||
if (tt_type != NONE) too_close_count++;
|
||||
}
|
||||
|
||||
if (too_close_count == 2) {
|
||||
too_close_count = 0;
|
||||
state = s_l_splash;
|
||||
velocity.x = velocity.y = 0;
|
||||
return;
|
||||
}
|
||||
//Set xvel
|
||||
var vel:int = 60;
|
||||
if (velocity.x > 0) {
|
||||
if (x + width > pt_rm_tl.x + 7 * 16) {
|
||||
velocity.x = -vel;
|
||||
FlxG.shake(0.05, 0.1, null, true, FlxCamera.SHAKE_HORIZONTAL_ONLY);
|
||||
}
|
||||
} else {
|
||||
if (x < pt_rm_tl.x + 16) {
|
||||
FlxG.shake(0.05, 0.1, null, true, FlxCamera.SHAKE_HORIZONTAL_ONLY);
|
||||
velocity.x = vel;
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.y > 0) {
|
||||
if (y + height > pt_rm_tl.y + 7 * 16) {
|
||||
FlxG.shake(0.05, 0.1, null, true, FlxCamera.SHAKE_VERTICAL_ONLY);
|
||||
velocity.y = -vel;
|
||||
}
|
||||
} else {
|
||||
if (y < pt_rm_tl.y + 16) {
|
||||
FlxG.shake(0.05, 0.1, null, true, FlxCamera.SHAKE_VERTICAL_ONLY);
|
||||
velocity.y = vel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Animation logic */
|
||||
|
||||
|
||||
sub_l_splash();
|
||||
sub_tentacle_thrust(tt_type);
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function get_player_proximity_type():uint {
|
||||
var close_u:FlxSprite = new FlxSprite(x , y - 21);
|
||||
close_u.makeGraphic(width, 8, 0xff000000);
|
||||
var close_l:FlxSprite = new FlxSprite(x - 18, y - 10);
|
||||
close_l.makeGraphic(12, height + 20, 0xf000000);
|
||||
|
||||
var close_d:FlxSprite = new FlxSprite(x, y + height + 8);
|
||||
close_d.makeGraphic(width + 4, 12, 0xff000000);
|
||||
var close_r:FlxSprite = new FlxSprite(x + width + 7, y - 8);
|
||||
close_r.makeGraphic(8, height + 16, 0xff000000);
|
||||
|
||||
if (player.overlaps(close_u)) {
|
||||
return UP;
|
||||
} else if (player.overlaps(close_l)) {
|
||||
return LEFT;
|
||||
} else if (player.overlaps(close_r)) {
|
||||
return RIGHT;
|
||||
} else if (player.overlaps(close_d)) {
|
||||
return DOWN;
|
||||
}
|
||||
|
||||
close_u.destroy();
|
||||
close_l.destroy();
|
||||
close_d.destroy();
|
||||
close_r.destroy();
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* document...this isn't totally straightforward to re-read
|
||||
* */
|
||||
private function sub_tentacle_thrust(tt_type:int):void {
|
||||
var t:FlxSprite;
|
||||
if (sig_tentacle_thrust && !on_tentacle_thrust) {
|
||||
sig_tentacle_thrust = false;
|
||||
on_tentacle_thrust = true;
|
||||
|
||||
var t_ct:int = 0;
|
||||
for each (t in tentacles.members) {
|
||||
if (t != null) {
|
||||
t.exists = true;
|
||||
t.visible = false;
|
||||
t.framePixels_y_push = t.height;
|
||||
|
||||
switch (tt_type) {
|
||||
case NONE:
|
||||
t.x = pt_rm_tl.x + 12 * (1 + t_ct) - 5 + int(10 * Math.random());
|
||||
t.y = pt_rm_tl.y + 16 * int(Math.random() * 3) - 5 + int(10 * Math.random());
|
||||
break;
|
||||
case LEFT:
|
||||
t.x = x - 14;
|
||||
t.y = y - 16 + t_ct * 16; break;
|
||||
case RIGHT:
|
||||
t.x = x + width + 2;
|
||||
t.y = y - 16 + t_ct * 16; break;
|
||||
case UP:
|
||||
t.x = x - 14 + 16 * t_ct;
|
||||
t.y = y - 13; break;
|
||||
case DOWN:
|
||||
t.x = x - 14 + 16 * t_ct;
|
||||
t.y = y + height + 2; break;
|
||||
}
|
||||
|
||||
tentacle_thrust_timers[t_ct] = 2.0 + Math.random();
|
||||
if (tt_type != NONE) {
|
||||
t.y -= (t.height - 10);
|
||||
}
|
||||
}
|
||||
t_ct++;
|
||||
}
|
||||
|
||||
var tw_ct:int = 0;
|
||||
for each (var tw:FlxSprite in tentacle_warnings.members) {
|
||||
if (tw != null) {
|
||||
|
||||
tw.exists = true;
|
||||
tw.visible = true;
|
||||
tw.x = tentacles.members[tw_ct].x;
|
||||
tw.y = tentacles.members[tw_ct].y + tentacles.members[tw_ct].height - tw.height + 3;
|
||||
tw.flicker(1);
|
||||
}
|
||||
tw_ct++;
|
||||
}
|
||||
}
|
||||
|
||||
if (on_tentacle_thrust) {
|
||||
var idx:int = 0;
|
||||
for each (t in tentacles.members) {
|
||||
|
||||
if (t != null && t.visible) {
|
||||
if (!player.invincible && player.overlaps(tentacle_warnings.members[idx])) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
if (tentacle_thrust_timers[idx] < 0 && t.framePixels_y_push == t.height && !t.alive) {
|
||||
t.exists = false;
|
||||
t.alive = true;
|
||||
tentacle_warnings.members[idx].visible = false;
|
||||
}
|
||||
}
|
||||
tentacle_thrust_timers[idx] -= FlxG.elapsed;
|
||||
if (tentacle_thrust_timers[idx] < 1.3) {
|
||||
|
||||
if (t.alive && t.framePixels_y_push > 0) {
|
||||
t.framePixels_y_push -= 2;
|
||||
if (t.framePixels_y_push <= 0) {
|
||||
t.alive = false;
|
||||
}
|
||||
} else if (tentacle_thrust_timers[idx] < 0.3) {
|
||||
if (t.framePixels_y_push < t.height) {
|
||||
t.framePixels_y_push = Math.min(t.height, t.framePixels_y_push + 3);
|
||||
}
|
||||
}
|
||||
if (!t.visible) {
|
||||
play_sfx("bubble_triple");
|
||||
}
|
||||
t.visible = true;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
if (tentacles.countExisting() == 0) {
|
||||
on_tentacle_thrust = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private function sub_l_splash():void {
|
||||
var b:FlxSprite;
|
||||
var shadow:FlxSprite;
|
||||
/* Do initialization. A signal to do the left splash
|
||||
* attack will generate four bullet thingies */
|
||||
if (sig_l_splash) {
|
||||
sig_l_splash = false;
|
||||
on_l_splash = true;
|
||||
for (var i:int = 0; i < 4; i++) {
|
||||
b = bullet_pool.getFirstAvailable() as FlxSprite;
|
||||
if (b == null) continue;
|
||||
b.exists = b.my_shadow.exists = true;
|
||||
shadow = b.my_shadow;
|
||||
shadow.visible = true;
|
||||
b.visible = false;
|
||||
|
||||
shadow.x = b.x = l_splash_start_tile_coords[i].x * 16 + pt_rm_tl.x + 3;
|
||||
shadow.y = b.y = l_splash_start_tile_coords[i].y * 16 + pt_rm_tl.y + 4;
|
||||
b.velocity.x = 0;
|
||||
l_splash_timers[bullet_pool.members.indexOf(b)] = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* do something with "to be removed" so that removing is in sync */
|
||||
if (on_l_splash) {
|
||||
for each (b in bullet_pool.members) {
|
||||
|
||||
if (b == null || !b.exists) continue;
|
||||
|
||||
b.my_shadow.x = b.x;
|
||||
b.my_shadow.y = b.y;
|
||||
|
||||
l_splash_timers[bullet_pool.members.indexOf(b)] += FlxG.elapsed;
|
||||
if (l_splash_timers[bullet_pool.members.indexOf(b)] > 0.5) {
|
||||
if (b.velocity.x == 0) {
|
||||
b.visible = true;
|
||||
play_sfx("bubble", true);
|
||||
b.velocity.x = int(10 + 7 * Math.random());
|
||||
b.my_shadow.play("get_small");
|
||||
}
|
||||
|
||||
if (b.offset.y < 10) {
|
||||
if (b.overlaps(player)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (b.parabola_thing.tick() && b.offset.y <= 4) {
|
||||
b.play("explode");
|
||||
if (b._curAnim.frames.length - 1 == b._curFrame) {
|
||||
b.my_shadow.exists = b.exists = false;
|
||||
b.parabola_thing.reset_time();
|
||||
b.play("move");
|
||||
play_sfx("bubble", true);
|
||||
b.parabola_thing.set_shadow_fall_animation("get_big");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
b.my_shadow.flicker(0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function do_stun_wave():void
|
||||
{
|
||||
var sub_ctr:int = 0;
|
||||
|
||||
/* Oscillation incrments */
|
||||
pushdown_angle += 0.05;
|
||||
framePixels_y_push = amp + Math.sin(pushdown_angle % 6.28) * amp;
|
||||
|
||||
/* big 'n' small wave logic. */
|
||||
if (small_wave.exists) {
|
||||
if (small_wave.overlaps(player)) {
|
||||
EventScripts.send_property_to(player, "x", 0, -0.5);
|
||||
}
|
||||
if (small_wave.x < pt_rm_tl.x + 16) {
|
||||
if (!small_wave_fallen && small_wave.exists) {
|
||||
small_wave_fallen = true;
|
||||
small_wave.play("fall");
|
||||
}
|
||||
|
||||
if (small_wave._curAnim.name == "fall" && (small_wave._curAnim.frames.length - 1 == small_wave._curFrame)) {
|
||||
small_wave.exists = false;
|
||||
small_wave_fallen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player_hit_big_wave && player.state == player.S_AUTO_JUMP) {
|
||||
player.framePixels_y_push = 0;
|
||||
|
||||
EventScripts.send_property_to(player, "x", pt_rm_tl.x, -1.5);
|
||||
|
||||
EventScripts.send_property_to(player, "y", pt_rm_tl.y + 60, -1.5);
|
||||
} else {
|
||||
player.angularVelocity = player.angle = 0;
|
||||
}
|
||||
|
||||
if (big_wave.exists) {
|
||||
if (big_wave.overlaps(player) && (big_wave._curAnim.name == "move")) {
|
||||
if (!player_hit_big_wave) {
|
||||
Registry.sound_data.player_hit_1.play();
|
||||
player_hit_big_wave = true;
|
||||
player.angularVelocity = -500;
|
||||
player.framePixels_y_push = 0;
|
||||
player.auto_jump_base_y = y;
|
||||
player.AUTO_JUMP_HEIGHT = 50;
|
||||
player.auto_jump_distance = 50;
|
||||
player.auto_jump_period = 1;
|
||||
player.my_shadow.visible = true;
|
||||
player.state = player.S_AUTO_JUMP;
|
||||
}
|
||||
}
|
||||
if (big_wave.x < pt_rm_tl.x + 16) {
|
||||
|
||||
big_wave.play("fall");
|
||||
if (big_wave._curAnim.frames.length - 1 == big_wave._curFrame) {
|
||||
big_wave.exists = false;
|
||||
player.angularVelocity = 0;
|
||||
player.angle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ctr == 0) { //move to the left.
|
||||
play("warn");
|
||||
if (EventScripts.send_property_to(this, "y", pt_rm_tl.y + 48, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(this, "x", pt_rm_tl.x + 16 * 5, 0.5)) sub_ctr++;
|
||||
if (framePixels_y_push == 0) sub_ctr++;
|
||||
|
||||
if (!small_wave_risen) {
|
||||
small_wave_risen = true;
|
||||
small_wave.exists = true;
|
||||
small_wave.x = pt_rm_tl.x + 80;
|
||||
small_wave.y = pt_rm_tl.y + 32;
|
||||
small_wave.play("rise");
|
||||
}
|
||||
|
||||
if (sub_ctr == 3) {
|
||||
play_sfx("rise_from_water");
|
||||
small_wave_risen = false;
|
||||
ctr++;
|
||||
amp = 13;
|
||||
}
|
||||
} else if (ctr == 1) { //generate small wave when down
|
||||
if (framePixels_y_push > amp - 1) {
|
||||
FlxG.camera.shake(0.03, 1.0);
|
||||
ctr++;
|
||||
play_sfx("small_wave");
|
||||
small_wave.play("move");
|
||||
small_wave.velocity.x = -20;
|
||||
}
|
||||
} else if (ctr == 2) { //wait to be up to continue
|
||||
if (framePixels_y_push == 0) {
|
||||
ctr++;
|
||||
amp = 20;
|
||||
}
|
||||
} else if (ctr == 3) { //when down generate big wave
|
||||
if (framePixels_y_push > 18) {
|
||||
if (!big_wave_risen) {
|
||||
big_wave.x = pt_rm_tl.x + 64;
|
||||
big_wave.y = pt_rm_tl.y + 32;
|
||||
big_wave.exists = true;
|
||||
big_wave_risen = true;
|
||||
big_wave.play("rise");
|
||||
}
|
||||
}
|
||||
if (big_wave._curAnim.name == "rise" && (big_wave._curFrame == big_wave._curAnim.frames.length - 1)) {
|
||||
ctr++;
|
||||
big_wave_risen = false;
|
||||
big_wave.play("move");
|
||||
FlxG.camera.shake(0.05, 1.0);
|
||||
play_sfx("big_wave");
|
||||
big_wave.velocity.x = -40;
|
||||
}
|
||||
|
||||
} else if (ctr == 4) { //wait to be up
|
||||
play("close_eyes");
|
||||
if (framePixels_y_push < 2) {
|
||||
ctr++;
|
||||
amp = 5;
|
||||
}
|
||||
} else if (ctr == 5) { //when waves gone, go back to dash satate
|
||||
if (!small_wave.exists && !big_wave.exists) {
|
||||
if (EventScripts.send_property_to(this, "y", pt_rm_tl.y + 48, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(this, "x", pt_rm_tl.x + 16 * 4, 0.5)) sub_ctr++;
|
||||
if (sub_ctr == 2) {
|
||||
small_wave.velocity.x = big_wave.velocity.x = 0;
|
||||
player_hit_big_wave = false;
|
||||
state = s_dash;
|
||||
play("bob");
|
||||
stop_sfx("rise_from_water");
|
||||
velocity.x = 30;
|
||||
velocity.y = 20;
|
||||
ctr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,450 @@
|
|||
package entity.enemy.redcave
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import entity.player.Player;
|
||||
import org.flixel.FlxU;
|
||||
import states.PlayState;
|
||||
|
||||
public class Slasher extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_slasher.png")] public static var slasher_sprite:Class;
|
||||
/* A little confusign: */
|
||||
/* wide has down-facing Wide attack, right-facing long attack */
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_slasher_wide.png")] public static var wide_atk_sprite:Class;
|
||||
/* long has right-facing wide attack, up-facing long attack */
|
||||
[Embed (source = "../../../res/sprites/enemies/redcave/f_slasher_long.png")] public static var long_atk_sprite:Class;
|
||||
public var harmful_wide_atk_frames:Array = new Array(0, 1, 2);
|
||||
public var harmful_long_atk_frames:Array = new Array(3, 4, 5);
|
||||
|
||||
|
||||
public var cid:int = CLASS_ID.SLASHER;
|
||||
public var xml:XML;
|
||||
|
||||
public var long_sprite:FlxSprite = new FlxSprite();
|
||||
public var wide_sprite:FlxSprite = new FlxSprite();
|
||||
|
||||
public var SPRITE_WIDTH:int = 16;
|
||||
public var state:int = 0;
|
||||
public var S_MOVE:int = 0;
|
||||
public var move_timer_max:Number = 1.4;
|
||||
public var move_timer:Number = 0;
|
||||
private var initial_latency:Number = 1.4;
|
||||
|
||||
public var S_ATK_LONG:int = 1;
|
||||
public var LONG_ATK_TIMEOUT_MAX:Number = 0.8;
|
||||
public var LONG_ATK_TIMEOUT:Number = LONG_ATK_TIMEOUT_MAX;
|
||||
public var S_ATK_WIDE:int = 2;
|
||||
public var S_ATK_WIDE_DELAY:int = 3;
|
||||
public var WIDE_ATK_DISTANCE:int = 36;
|
||||
public var WIDE_ATK_DELAY_MAX:Number = 0.3;
|
||||
public var WIDE_ATK_DELAY:Number = WIDE_ATK_DELAY_MAX;
|
||||
public var WIDE_ATK_TIMER_MAX:Number = 0.4;
|
||||
public var WIDE_ATK_TIMER:Number = WIDE_ATK_TIMER_MAX;
|
||||
public var INCREMENTED_REG:Boolean = false;
|
||||
|
||||
public var t_warning:Number = 0;
|
||||
public var tm_warning:Number = 0.5;
|
||||
public var played_warning:Boolean = false;
|
||||
|
||||
public var activate_attack_frame:int = 0;
|
||||
public var started_attack_anim:Boolean = false;
|
||||
|
||||
|
||||
|
||||
|
||||
public var player:Player;
|
||||
public var parent:PlayState;
|
||||
|
||||
|
||||
public function Slasher(_xml:XML, _parent:PlayState, _player:Player)
|
||||
{
|
||||
|
||||
// anims:
|
||||
// walk urdl
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
|
||||
/** Note to Marina:
|
||||
* All scalings are taken care of for the attack, the default facings of the attacks that
|
||||
* i've programmed for are commented below */
|
||||
/* Add attack animations */
|
||||
long_sprite.loadGraphic(long_atk_sprite, true, false, 16, 48);
|
||||
long_sprite.addAnimation("tall", [3, 4, 5, 6], 12, false); //Faces up, from the long sprite sheet
|
||||
long_sprite.addAnimation("wide", [3, 4, 5, 6], 12, false); // Faces right, from the wide spritesheet
|
||||
long_sprite.play("tall");
|
||||
|
||||
// 10 x 36
|
||||
|
||||
wide_sprite.loadGraphic(wide_atk_sprite, true, false, 48, 16);
|
||||
wide_sprite.addAnimation("tall", [0, 1, 2, 6], 12, false); // Faces right, from the long spritesheet
|
||||
wide_sprite.addAnimation("wide", [0, 1, 2, 6], 12, false); //faces down, from the wide spritesheet
|
||||
wide_sprite.play("wide");
|
||||
|
||||
parent.otherObjects.push(long_sprite);
|
||||
parent.otherObjects.push(wide_sprite);
|
||||
|
||||
health = 3;
|
||||
|
||||
/* Add slasher's animations */
|
||||
/* Spritesheet horizontal facing is RIGHT */
|
||||
loadGraphic(slasher_sprite, true, false, 24, 24);
|
||||
addAnimation("float_d", [0, 1], 3);
|
||||
addAnimation("float_l", [2, 3], 3);
|
||||
addAnimation("float_r", [2, 3], 3);
|
||||
addAnimation("float_u", [4, 5], 3);
|
||||
addAnimation("warning_d", [6,6], 10,false); //Duplicate the last frame
|
||||
addAnimation("warning_l", [7,7], 10,false);
|
||||
addAnimation("warning_r", [7,7], 10,false);
|
||||
addAnimation("warning_u", [8,8], 10,false);
|
||||
addAnimation("attack_d", [9,9], 10,false);
|
||||
addAnimation("attack_l", [10,10], 10,false);
|
||||
addAnimation("attack_r", [10,10], 10,false);
|
||||
addAnimation("attack_u", [11,11], 10, false);
|
||||
addAnimation("die", [9, 10, 11,11], 3, false);
|
||||
play("float_d");
|
||||
addAnimationCallback(on_anim_change);
|
||||
width = height = 16;
|
||||
centerOffsets(true);
|
||||
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
add_sfx("attack", Registry.sound_data.slasher_atk);
|
||||
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (touching != NONE) {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
if (initial_latency > 0) {
|
||||
initial_latency -= FlxG.elapsed;
|
||||
return;
|
||||
}
|
||||
if (Registry.is_playstate) {
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
EventScripts.prevent_leaving_map(parent, this);
|
||||
}
|
||||
}
|
||||
/* Chceck if dead */
|
||||
if (xml.@alive == "false") {
|
||||
// When the death anim finishes, blow up
|
||||
//if (_curAnim.frames.length - 1 == _curFrame) {
|
||||
/* Always immediately blow up unless we do make a death anim*/
|
||||
if (1) {
|
||||
visible = false;
|
||||
if (!INCREMENTED_REG) {
|
||||
EventScripts.drop_big_health(x, y, 1);
|
||||
INCREMENTED_REG = true;
|
||||
Registry.GRID_ENEMIES_DEAD++;
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
}
|
||||
wide_sprite.visible = long_sprite.visible = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state == S_MOVE) {
|
||||
movement();
|
||||
} else {
|
||||
if (!started_attack_anim) {
|
||||
started_attack_anim = true;
|
||||
switch (_curAnim.name) {
|
||||
case "warning_r":
|
||||
play("attack_r");
|
||||
break;
|
||||
case "warning_l":
|
||||
play("attack_l");
|
||||
break;
|
||||
case "warning_d":
|
||||
play("attack_d");
|
||||
break;
|
||||
case "warning_u":
|
||||
play("attack_u");
|
||||
break;
|
||||
}
|
||||
/* Some frame in the attack animation trigger sthe appearance of the slash attack */
|
||||
} else if (_curFrame >= activate_attack_frame) {
|
||||
velocity.x = velocity.y = 0;
|
||||
attack(); //Decrement the attack timers until state change
|
||||
}
|
||||
}
|
||||
collisions();
|
||||
check_for_death();
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function check_for_death():void {
|
||||
if (health <= 0) {
|
||||
xml.@alive = "false";
|
||||
play("die");
|
||||
}
|
||||
}
|
||||
public function on_anim_change(name:String, frame:int, index:int):void {
|
||||
if (name == "float_r" || name == "warning_r" || name == "attack_r") {
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private var t_move:Number = 0;
|
||||
public function movement():void {
|
||||
t_move += FlxG.elapsed;
|
||||
if (t_move > 0.25) {
|
||||
t_move = 0;
|
||||
EventScripts.scale_vector(this, player, velocity, 20);
|
||||
}
|
||||
//EventScripts.send_property_to(this, "x", player.x + 8, 0.3);
|
||||
//EventScripts.send_property_to(this, "y", player.y + 8, 0.3);
|
||||
var dx:int = (player.x + 8) - (x + SPRITE_WIDTH/2);
|
||||
var dy:int = (player.y + 8) - (y + SPRITE_WIDTH / 2);
|
||||
|
||||
if (!played_warning) {
|
||||
facing = EventScripts.get_entity_to_entity_dir(x + SPRITE_WIDTH / 2, y + SPRITE_WIDTH / 2, player.x + 8, player.y + 8);
|
||||
switch (facing) {
|
||||
case UP:
|
||||
play("float_u");
|
||||
break;
|
||||
case RIGHT:
|
||||
play("float_r");
|
||||
break;
|
||||
case LEFT:
|
||||
play("float_l");
|
||||
break;
|
||||
case DOWN:
|
||||
play("float_d");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
move_timer -= FlxG.elapsed;
|
||||
if (move_timer < 0) {
|
||||
if (!played_warning) {
|
||||
switch (_curAnim.name) {
|
||||
case "float_r":
|
||||
play("warning_r");
|
||||
break;
|
||||
case "float_d":
|
||||
play("warning_d");
|
||||
break;
|
||||
case "float_u":
|
||||
play("warning_u");
|
||||
break;
|
||||
case "float_l":
|
||||
play("warning_l");
|
||||
break;
|
||||
}
|
||||
played_warning = true;
|
||||
}
|
||||
t_warning += FlxG.elapsed;
|
||||
if (t_warning > tm_warning) {
|
||||
played_warning = false;
|
||||
t_warning = 0;
|
||||
move_timer = move_timer_max;
|
||||
if (Math.sqrt(dx * dx + dy * dy) < WIDE_ATK_DISTANCE) {
|
||||
state = S_ATK_WIDE;
|
||||
play_sfx("attack");
|
||||
update_wide_pos();
|
||||
//sfx
|
||||
//anim
|
||||
} else {
|
||||
play_sfx("attack");
|
||||
state = S_ATK_LONG;
|
||||
update_long_pos();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function update_long_pos():void {
|
||||
|
||||
long_sprite.visible = true;
|
||||
long_sprite.scale.x = 1;
|
||||
long_sprite.scale.y = 1;
|
||||
/* Determine position of long attack */
|
||||
|
||||
|
||||
if (facing & (UP | DOWN)) {
|
||||
long_sprite.loadGraphic(long_atk_sprite, true, false, 16, 48);
|
||||
|
||||
|
||||
long_sprite.x = x + (SPRITE_WIDTH / 2) - long_sprite.width / 2;
|
||||
long_sprite.play("tall");
|
||||
|
||||
|
||||
long_sprite.width = 10; long_sprite.height = 36;
|
||||
long_sprite.offset.x = 3; long_sprite.x += 3;
|
||||
if (facing & UP) { // UP
|
||||
long_sprite.y = y - 48; //sorry
|
||||
long_sprite.offset.y = 12;
|
||||
long_sprite.y += 12;
|
||||
} else {
|
||||
long_sprite.scale.y = -1; // DOWN
|
||||
long_sprite.y = y + SPRITE_WIDTH ;
|
||||
}
|
||||
} else {
|
||||
long_sprite.loadGraphic(wide_atk_sprite, true, false, 48, 16);
|
||||
long_sprite.y = y + SPRITE_WIDTH / 2 - long_sprite.height / 2;
|
||||
long_sprite.play("wide");
|
||||
|
||||
long_sprite.width = 36; long_sprite.height = 10;
|
||||
long_sprite.y += 3; long_sprite.offset.y = 3;
|
||||
|
||||
if (facing & LEFT) { //LEFT
|
||||
|
||||
long_sprite.scale.x = -1;
|
||||
long_sprite.x = x - 48; //so sorry
|
||||
|
||||
long_sprite.offset.x = 12;
|
||||
long_sprite.x += 12;
|
||||
} else {
|
||||
long_sprite.x = x + SPRITE_WIDTH; //RIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update_wide_pos():void {
|
||||
wide_sprite.visible = true;
|
||||
wide_sprite.angle = 0;
|
||||
wide_sprite.scale.x = wide_sprite.scale.y = 1;
|
||||
if (facing & (UP | DOWN)) {
|
||||
wide_sprite.loadGraphic(wide_atk_sprite, true, false, 48, 16);
|
||||
wide_sprite.x = x + SPRITE_WIDTH / 2 - wide_sprite.width / 2;
|
||||
wide_sprite.play("wide");
|
||||
|
||||
wide_sprite.height = 10;
|
||||
wide_sprite.width = 36;
|
||||
wide_sprite.offset.x = 6;
|
||||
wide_sprite.x += 6;
|
||||
//36x10
|
||||
if (facing & UP) { // up
|
||||
wide_sprite.angle = 180;
|
||||
wide_sprite.y = y - 10;
|
||||
|
||||
wide_sprite.offset.y = 6;
|
||||
wide_sprite.y += 6;
|
||||
|
||||
} else {//down
|
||||
|
||||
wide_sprite.y = y + 10;
|
||||
}
|
||||
} else {
|
||||
wide_sprite.loadGraphic(long_atk_sprite, true, false, 16, 48);
|
||||
wide_sprite.y = y + SPRITE_WIDTH / 2 - wide_sprite.height / 2;
|
||||
wide_sprite.play("tall");
|
||||
|
||||
wide_sprite.height = 36;
|
||||
wide_sprite.offset.y = 6;
|
||||
wide_sprite.y += 6;
|
||||
|
||||
wide_sprite.width = 10;
|
||||
if (facing & RIGHT) { //r right
|
||||
wide_sprite.x = x + SPRITE_WIDTH;
|
||||
} else { // left
|
||||
wide_sprite.scale.x = -1;
|
||||
wide_sprite.x = x - wide_sprite.width;
|
||||
|
||||
wide_sprite.offset.x = 6;
|
||||
wide_sprite.x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
//if (Math.sqrt(dx * dx + dy * dy) > WIDE_ATK_DISTANCE + 3) { //can get a good attack range here
|
||||
// state = S_MOVE;
|
||||
//wide_sprite.visible = false;
|
||||
//anim of enemy
|
||||
|
||||
|
||||
}
|
||||
private function collisions():void {
|
||||
|
||||
if (long_sprite.visible) {
|
||||
if (harmful_long_atk_frames.indexOf(long_sprite._curIndex) != -1) {
|
||||
if (long_sprite.overlaps(player)) player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
if (wide_sprite.visible) {
|
||||
if (harmful_wide_atk_frames.indexOf(wide_sprite._curIndex) != -1) {
|
||||
if (wide_sprite.overlaps(player) && player.state == player.S_GROUND) player.touchDamage(1);
|
||||
}
|
||||
}
|
||||
/*if (player.overlaps(this)) {
|
||||
player.touchDamage(1);
|
||||
}*/
|
||||
if (player.broom.visible) {
|
||||
if (player.broom.overlaps(this)) {
|
||||
if (!flickering) {
|
||||
flicker(1);
|
||||
health--;
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update timers - long transitions back to move, wide can continue
|
||||
* to transition to wide */
|
||||
public function attack():void {
|
||||
if (state == S_ATK_LONG) {
|
||||
LONG_ATK_TIMEOUT -= FlxG.elapsed;
|
||||
if (LONG_ATK_TIMEOUT < 0) {
|
||||
state = S_MOVE;
|
||||
started_attack_anim = false;
|
||||
LONG_ATK_TIMEOUT = LONG_ATK_TIMEOUT_MAX;
|
||||
long_sprite.visible = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/** This is a huge mess, the logic has been commented
|
||||
* to act like the long attack, so it piggy backs on the
|
||||
* code that does warning and attack */
|
||||
if (state == S_ATK_WIDE_DELAY) {
|
||||
WIDE_ATK_DELAY -= FlxG.elapsed;
|
||||
if (WIDE_ATK_DELAY < 0) {
|
||||
WIDE_ATK_DELAY = WIDE_ATK_DELAY_MAX;
|
||||
// state = S_ATK_WIDE;
|
||||
state = S_MOVE;
|
||||
started_attack_anim = false;
|
||||
wide_sprite.visible = false;
|
||||
move_timer = move_timer_max / 2;
|
||||
//wide_sprite.visible = true;
|
||||
//update_wide_pos();
|
||||
//sfx
|
||||
//anim
|
||||
}
|
||||
} else {
|
||||
|
||||
WIDE_ATK_TIMER -= FlxG.elapsed;
|
||||
if (WIDE_ATK_TIMER < 0) {
|
||||
WIDE_ATK_TIMER = WIDE_ATK_TIMER_MAX;
|
||||
state = S_ATK_WIDE_DELAY;
|
||||
wide_sprite.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package entity.enemy.suburb
|
||||
{
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
public class Suburb_Killer extends AnoSprite
|
||||
{
|
||||
|
||||
private const s_idle:int = 0;
|
||||
private const s_move:int = 1;
|
||||
|
||||
private var t_flip_vel:Number = 0;
|
||||
private const tm_flip_vel:Number = 0.5;
|
||||
|
||||
|
||||
[Embed(source = "../../../res/sprites/npcs/suburb_killers.png")] public static const embed_suburb_killer:Class;
|
||||
public function Suburb_Killer(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
loadGraphic(embed_suburb_killer, true, false, 16, 16);
|
||||
|
||||
var off:int = Math.random() * 6;
|
||||
off *= 9;
|
||||
addAnimation("idle_d", [off+0], 1);
|
||||
addAnimation("idle_r", [off+2], 1);
|
||||
addAnimation("idle_u", [off+4], 1);
|
||||
addAnimation("idle_l", [off+6], 1);
|
||||
|
||||
addAnimation("walk_d", [off,off+1], 4);
|
||||
addAnimation("walk_r", [off+2,off+3], 4);
|
||||
addAnimation("walk_u", [off+4, off+5], 4);
|
||||
addAnimation("walk_l", [off+6, off+7], 4);
|
||||
|
||||
play("idle_d");
|
||||
|
||||
width = height = 6;
|
||||
offset.x = offset.y = 5;
|
||||
x += 5;
|
||||
y += 5;
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
if (state == s_move) {
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
switch (state) {
|
||||
|
||||
case s_idle:
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (EventScripts.distance(player, this) < 36) {
|
||||
state = s_move;
|
||||
}
|
||||
break;
|
||||
case s_move:
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
|
||||
t_flip_vel += FlxG.elapsed;
|
||||
if (t_flip_vel > tm_flip_vel) {
|
||||
t_flip_vel = 0;
|
||||
EventScripts.scale_vector(this, player, velocity, 30);
|
||||
}
|
||||
|
||||
if (player.overlaps(this)) {
|
||||
player.touchDamage(6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package entity.enemy.suburb
|
||||
{
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
|
||||
public class Suburb_Walker extends AnoSprite
|
||||
{
|
||||
[Embed(source = "../../../res/sprites/enemies/suburb/suburb_walker.png")] public static var embed_suburb_walker:Class;
|
||||
[Embed(source = "../../../res/sprites/npcs/suburb_walkers.png")] public static var embed_suburb_folk:Class;
|
||||
[Embed(source = "../../../res/sprites/npcs/suburb_killers.png")] public static var embed_suburb_killer:Class;
|
||||
|
||||
|
||||
private var s_alive:int = 0;
|
||||
private var s_dead:int = 1;
|
||||
|
||||
private var t_walk:Number = 0;
|
||||
private var tm_walk:Number = 1.0;
|
||||
private var walk_vel:int = 20;
|
||||
|
||||
public var active_region:FlxObject;
|
||||
|
||||
private var dialogue_choices:int;
|
||||
private var blood:FlxSprite;
|
||||
private var dialogue_scene_name:String;
|
||||
private var ropes:FlxGroup;
|
||||
|
||||
private var is_talker:Boolean = false;
|
||||
private var talker_nr:int = 1;
|
||||
public function Suburb_Walker(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
// MARINA_ANIMS
|
||||
// will add gender sprite later
|
||||
loadGraphic(embed_suburb_folk, true, false, 16, 16);
|
||||
var off:int = parseInt(xml.@frame);
|
||||
var w:int = 9;
|
||||
off *= w;
|
||||
state = s_alive;
|
||||
immovable = true;
|
||||
tm_walk = 1.0 + Math.random();
|
||||
|
||||
active_region = new FlxObject(0, 0, 22, 22);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
play("dead");
|
||||
state = s_dead;
|
||||
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
blood = new FlxSprite;
|
||||
blood.loadGraphic(embed_suburb_folk, true, false, 16, 16);
|
||||
blood.addAnimation("a", [63,64,65,66], 3, false);
|
||||
blood.visible = false;
|
||||
|
||||
if (state == s_dead) {
|
||||
blood.x = x - 3 + 6 * Math.random();
|
||||
blood.y = y - 3 + 6 * Math.random();
|
||||
blood.play("a");
|
||||
blood.visible = true;
|
||||
}
|
||||
|
||||
parent.bg_sprites.add(blood);
|
||||
|
||||
gx = Registry.CURRENT_GRID_X;
|
||||
gy = Registry.CURRENT_GRID_Y;
|
||||
if (parseInt(xml.@frame) == 12) {
|
||||
Registry.subgroup_interactives.push(this);
|
||||
is_talker = true;
|
||||
talker_nr = 1;
|
||||
var first_anim:String = "walk_d";
|
||||
if (gx == 1 && gy == 5) { // Paranoid Guy (74)
|
||||
off = 0;
|
||||
} else if (gx == 3 && gy == 5) { // Younger kid in family house
|
||||
off = 4 * w;
|
||||
} else if (gx == 4 && gy == 5 ) { // Older kid in family house
|
||||
off = 2 * w;
|
||||
} else if (gx == 0 && gy == 7) { // dead mom
|
||||
off = w;
|
||||
first_anim = "dead";
|
||||
} else if (gx == 1 && gy == 7) { // dead dad
|
||||
off = 0;
|
||||
first_anim = "dead";
|
||||
} else if (gx == 1 && gy == 6) { // Hanged guy
|
||||
// Do weird stuff with the rope
|
||||
ropes = new FlxGroup(3);
|
||||
for (var r:int = 0; r < 3; r++) {
|
||||
var rope:FlxSprite = new FlxSprite(x, y - 16 * (r + 1));
|
||||
rope.loadGraphic(embed_suburb_folk, true, false, 16, 16);
|
||||
rope.frame = 55;
|
||||
ropes.add(rope);
|
||||
}
|
||||
parent.fg_sprites.add(ropes);
|
||||
addAnimation("hang", [54], 2);
|
||||
off = 0;
|
||||
first_anim = "hang";
|
||||
} else if (gx == 0 && gy == 6) { // festive person
|
||||
off = 0;
|
||||
frame = 4;
|
||||
}
|
||||
add_the_anims(off,false);
|
||||
play(first_anim);
|
||||
} else if (parseInt(xml.@frame) == 14) {
|
||||
Registry.subgroup_interactives.push(this);
|
||||
is_talker = true;
|
||||
talker_nr = 2;
|
||||
if (gx == 3 && gy == 5) { // prarent in family house
|
||||
frame = 4;
|
||||
off = w;
|
||||
add_the_anims(off,false);
|
||||
play("walk_d");
|
||||
}
|
||||
} else {
|
||||
add_the_anims(off);
|
||||
play("walk_d");
|
||||
}
|
||||
|
||||
if (state == s_dead) {
|
||||
play("dead");
|
||||
}
|
||||
|
||||
|
||||
if (off/w < 2) {
|
||||
dialogue_scene_name = DH.scene_suburb_walker_words_adult;
|
||||
} else if (off / w < 4) {
|
||||
dialogue_scene_name = DH.scene_suburb_walker_words_teen;
|
||||
} else {
|
||||
dialogue_scene_name = DH.scene_suburb_walker_words_kid;
|
||||
}
|
||||
dialogue_choices = DH.get_scene_length(DH.name_suburb_walker, dialogue_scene_name);
|
||||
|
||||
|
||||
}
|
||||
override public function preUpdate():void
|
||||
{
|
||||
if (state != s_dead) {
|
||||
FlxG.collide(player, this);
|
||||
immovable = false;
|
||||
FlxG.collide(parent.curMapBuf, this);
|
||||
immovable = true;
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
active_region.x = x - 3;
|
||||
active_region.y = y - 3;
|
||||
|
||||
if (is_talker) {
|
||||
update_talker();
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
if (state == s_alive) {
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
play("die");
|
||||
Registry.sound_data.broom_hit.play();
|
||||
Registry.Event_Nr_Suburb_Killed++;
|
||||
state = s_dead;
|
||||
Registry.sound_data.fall_in_hole.play();
|
||||
velocity.x = velocity.y = 0;
|
||||
xml.@alive = "false";
|
||||
Registry.subgroup_interactives.push(this);
|
||||
return;
|
||||
}
|
||||
|
||||
t_walk += FlxG.elapsed;
|
||||
|
||||
if (x + width > tl.x + 155 || x < tl.x + 5 || y + height > tl.y + 155 || y < tl.y + 5) {
|
||||
t_walk = tm_walk + 1;
|
||||
if (x + width > tl.x + 155) x = tl.x + 155 - width;
|
||||
if (x < tl.x + 5) x = tl.x + 6;
|
||||
if (y + height > tl.y + 155) y = tl.y + 155 - height;
|
||||
if (y < tl.y + 5) y = tl.y + 6;
|
||||
}
|
||||
if (t_walk > tm_walk) {
|
||||
t_walk = 0;
|
||||
if (facing & DOWN) {
|
||||
play("walk_r");
|
||||
} else if (facing & RIGHT) {
|
||||
play ("walk_u");
|
||||
} else if (facing & LEFT) {
|
||||
play("walk_d");
|
||||
} else {
|
||||
play("walk_l");
|
||||
}
|
||||
|
||||
}
|
||||
if (touching && player.touching == NONE) {
|
||||
t_walk = tm_walk + 1;
|
||||
}
|
||||
} else if (state == s_dead) {
|
||||
velocity.x = velocity.y = 0;
|
||||
if (blood.frame == 66 && player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
DH.start_dialogue(DH.name_suburb_walker, dialogue_scene_name, "", int(Math.random() * dialogue_choices));
|
||||
player.be_idle();
|
||||
|
||||
}
|
||||
if (finished) {
|
||||
if (_curAnim.name == "die" && _curAnim.frames.length - 1 == _curFrame) {
|
||||
Registry.sound_data.player_hit_1.play();
|
||||
play("dead");
|
||||
blood.x = x - 3 + 6 * Math.random();
|
||||
blood.y = y - 3 + 6 * Math.random();
|
||||
blood.play("a");
|
||||
blood.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private var talker_state:int = 0;
|
||||
private function update_talker():void {
|
||||
if (talker_state == 0) {
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
talker_state = 1;
|
||||
}
|
||||
} else if (talker_state == 1) {
|
||||
if (player.state == player.S_GROUND && player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
talker_state = 0;
|
||||
|
||||
if (talker_nr == 2) {
|
||||
if (gx == 3 && gy == 5) { // Mom in family
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_family, "", 0);
|
||||
}
|
||||
} else if (talker_nr == 1) {
|
||||
if (gx == 1 && gy == 5) { // Paranoid Guy (74)
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_paranoid);
|
||||
} else if (gx == 3 && gy == 5) { // Younger kid in family house 73
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_family, "", 1);
|
||||
} else if (gx == 4 && gy == 5 ) { // Older kid in family house 73
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_older_kid);
|
||||
} else if (gx == 0 && gy == 7) { // dead mom 76
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_dead, "", 0);
|
||||
} else if (gx == 1 && gy == 7) { // dead dad 76
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_dead, "", 1);
|
||||
} else if (gx == 1 && gy == 6) { // Hanged guy 78
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_hanged);
|
||||
} else if (gx == 0 && gy == 6) { // festive person 75
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
DH.start_dialogue(DH.name_suburb_walker, DH.scene_suburb_walker_festive);
|
||||
}
|
||||
}
|
||||
player.be_idle();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private function on_anim_change(name:String, frame:int, index:int):void {
|
||||
velocity.x = velocity.y = 0;
|
||||
if (name == "walk_d") {
|
||||
facing = DOWN;
|
||||
velocity.y = walk_vel;
|
||||
} else if (name == "walk_u") {
|
||||
facing = UP;
|
||||
velocity.y = -walk_vel;
|
||||
} else if (name == "walk_r") {
|
||||
facing = RIGHT;
|
||||
velocity.x = walk_vel;
|
||||
} else if (name == "walk_l") {
|
||||
facing = LEFT;
|
||||
velocity.x = -walk_vel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function add_the_anims(off:int,doeswalk:Boolean=true):void
|
||||
{
|
||||
addAnimation("walk_d", [0 + off, 1 + off], 4);
|
||||
addAnimation("walk_r", [2 + off, 3 + off], 4);
|
||||
addAnimation("walk_u", [4 + off, 5 + off], 4);
|
||||
addAnimation("walk_l", [6 + off, 7 + off], 4);
|
||||
addAnimation("die", [0+off,2+off,4+off,6+off,0+off,2+off,4+off,6+off,8+off], 8,false);
|
||||
addAnimation("dead", [8 + off]);
|
||||
if (true == doeswalk) {
|
||||
addAnimationCallback(on_anim_change);
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
active_region.destroy();
|
||||
active_region = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,299 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.FlxBitmapFont;
|
||||
|
||||
/**
|
||||
* a big door. either alive or not alive.
|
||||
* if alive, approaching this without enough growths has a bunch of outlines
|
||||
* of squares pop-up, with as many filled in as you have. The squares then fade out.
|
||||
* otherwise approaching with enough leads to the square sprites coming from
|
||||
* the character, circling around him, eventually leaving trails of blurred sprites, which
|
||||
* 'attack' the door, make it glow, then fizzle away. sets a global event.
|
||||
* if not alive, the doorway is 'open', so the actual Door entity will be alive
|
||||
* @author Seagaia
|
||||
*/
|
||||
|
||||
public class Big_Door extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.BIG_DOOR;
|
||||
[Embed (source = "../../res/sprites/gadgets/big_door.png")] public static var big_door_sprite:Class;
|
||||
public var active_region:FlxSprite;
|
||||
public var player:Player;
|
||||
public var state:int = 0;
|
||||
public var s_normal:int = 0;
|
||||
public var s_opening:int = 1;
|
||||
|
||||
public var s_locked_anim:int = 2;
|
||||
public var s_locked_fade:int = 3;
|
||||
public var s_wait_to_not_overlap:int = 4;
|
||||
|
||||
public var s_open_anim:int = 6;
|
||||
public var s_open_anim_ctr:int = 0;
|
||||
public var center_sprite:FlxSprite = new FlxSprite(80, 80);
|
||||
public var init_open_radius:Number = 45;
|
||||
|
||||
|
||||
public var s_open:int = 5;
|
||||
public var timer:Number = 0.06;
|
||||
public var timer_max:Number = 0.06;
|
||||
|
||||
public var s_locked_ctr:int = 0;
|
||||
public var locked_squares:FlxGroup = new FlxGroup(36);
|
||||
|
||||
public var score_text_1:FlxBitmapFont;
|
||||
public var score_text_2:FlxBitmapFont;
|
||||
public var white_flash:FlxSprite = new FlxSprite(0, 0);
|
||||
|
||||
/* Based on frame, which Big door */
|
||||
public static var bd_nexus1:int = 0;
|
||||
/*
|
||||
* dame params: frame is which door this corresponds to
|
||||
**/
|
||||
public function Big_Door(_xml:XML,_player:Player):void {
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
loadGraphic(big_door_sprite, true, false, 32, 32);
|
||||
active_region = new FlxSprite(x + width / 2 - 1, y + height + 2 + Registry.HEADER_HEIGHT);;
|
||||
active_region.makeGraphic(2, 2, 0xffff0000);
|
||||
player = _player;
|
||||
immovable = true;
|
||||
init_squares();
|
||||
center_sprite.makeGraphic(1, 1);
|
||||
center_sprite.scrollFactor = new FlxPoint(0, 0);
|
||||
|
||||
score_text_1 = EventScripts.init_bitmap_font();
|
||||
score_text_2 = EventScripts.init_bitmap_font();
|
||||
score_text_2.scrollFactor = score_text_1.scrollFactor = new FlxPoint(0, 0);
|
||||
score_text_1.y = 30;
|
||||
score_text_2.y = 50;
|
||||
white_flash.makeGraphic(160, 160, 0xffffffff); white_flash.alpha = 0;
|
||||
white_flash.y += Registry.HEADER_HEIGHT;
|
||||
white_flash.scrollFactor = new FlxPoint(0, 0);
|
||||
|
||||
if (Registry.Big_Door_State[parseInt(xml.@frame)]) exists = false;
|
||||
|
||||
}
|
||||
|
||||
private var hoooooops:Boolean = false;
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(player, this);
|
||||
|
||||
/* If the player overlaps the active region set off the event to open door. */
|
||||
if (state == s_normal) {
|
||||
if (player.overlaps(active_region)) {
|
||||
//if (false == hoooooops && Registry.nr_growths >= Registry.Big_Door_Reqs[parseInt(xml.@frame)]) {
|
||||
if (true == hoooooops) {
|
||||
state = s_open_anim;
|
||||
hoooooops = false;
|
||||
|
||||
} else {
|
||||
hoooooops = true;
|
||||
state = s_locked_anim;
|
||||
/* Set the "0.x" text".. */
|
||||
score_text_1.setText(Registry.nr_growths.toString()+"\n---", true, 0, 0, "center", true);
|
||||
score_text_2.setText(Registry.Big_Door_Reqs[parseInt(xml.@frame)].toString(), true, 0, 0, "center", true);
|
||||
score_text_1.x = -20;
|
||||
score_text_2.x = Registry.SCREEN_WIDTH_IN_PIXELS + 20;
|
||||
Registry.sound_data.big_door_locked.play();
|
||||
}
|
||||
}
|
||||
} else if (state == s_opening) {
|
||||
alpha -= 0.01;
|
||||
if (alpha < 0.01) {
|
||||
state = s_open;
|
||||
exists = false;
|
||||
Registry.Big_Door_State[parseInt(xml.@frame)] = true;
|
||||
}
|
||||
} else if (state == s_open) {
|
||||
|
||||
/* FADE IN FOR LOCKED DOOR */
|
||||
} else if (state == s_locked_anim) {
|
||||
timer -= FlxG.elapsed;
|
||||
if (timer < 0 && s_locked_ctr < locked_squares.maxSize) {
|
||||
timer = timer_max;
|
||||
s_locked_ctr ++;
|
||||
}
|
||||
for (var i:int = 0; i < s_locked_ctr; i++) {
|
||||
if (i < Registry.nr_growths) {
|
||||
locked_squares.members[i].makeGraphic(20, 20, 0xff000000);
|
||||
}
|
||||
locked_squares.members[i].alpha += 0.03;
|
||||
if (locked_squares.members[i].scale.x >= 1) {
|
||||
locked_squares.members[i].scale.x -= 0.04;
|
||||
locked_squares.members[i].scale.y -= 0.04;
|
||||
}
|
||||
}
|
||||
|
||||
var text_move_ctr:int = 0;
|
||||
if (EventScripts.send_property_to(score_text_1, "x", Registry.SCREEN_WIDTH_IN_PIXELS / 2 - 8, 4)) text_move_ctr++;
|
||||
if (EventScripts.send_property_to(score_text_2, "x", Registry.SCREEN_WIDTH_IN_PIXELS / 2, 4 )) text_move_ctr++;
|
||||
|
||||
if (text_move_ctr == 2 && locked_squares.members[locked_squares.maxSize - 1].alpha >= 1) {
|
||||
|
||||
white_flash.alpha += 0.05;
|
||||
if (white_flash.alpha == 1) text_move_ctr++;
|
||||
if (text_move_ctr == 3) {
|
||||
state = s_locked_fade;
|
||||
s_locked_ctr = 0;
|
||||
}
|
||||
}
|
||||
/* FADE OUT FOR LOCKED DOOR */
|
||||
} else if (state == s_locked_fade) {
|
||||
timer -= FlxG.elapsed;
|
||||
if (timer < 0 && s_locked_ctr < locked_squares.maxSize) {
|
||||
timer = timer_max;
|
||||
s_locked_ctr ++;
|
||||
}
|
||||
for (var j:int = 0; j < s_locked_ctr; j++) {
|
||||
locked_squares.members[j].angularVelocity += 5;
|
||||
if (locked_squares.members[j].scale.x > 0.02) {
|
||||
locked_squares.members[j].scale.x -= 0.01;
|
||||
locked_squares.members[j].scale.y -= 0.01;
|
||||
}
|
||||
locked_squares.members[j].alpha -= 0.03;
|
||||
|
||||
}
|
||||
|
||||
white_flash.alpha -= 0.05;
|
||||
EventScripts.send_property_to(score_text_1, "x", Registry.SCREEN_WIDTH_IN_PIXELS + 20, 3);
|
||||
EventScripts.send_property_to(score_text_2, "x", -20, 3 );
|
||||
score_text_1.alpha -= 0.02;
|
||||
score_text_2.alpha -= 0.02;
|
||||
|
||||
if ((score_text_1.alpha == 0 && score_text_2.alpha == 0) && locked_squares.members[locked_squares.maxSize - 1].alpha == 0) {
|
||||
locked_squares.setAll("angularVelocity", 0);
|
||||
locked_squares.setAll("angle", 0);
|
||||
locked_squares.setAll("alpha", 0);
|
||||
for (i = 0; i < locked_squares.maxSize; i++) {
|
||||
locked_squares.members[i].scale.x = 2;
|
||||
locked_squares.members[i].scale.y = 2;
|
||||
}
|
||||
state = s_wait_to_not_overlap;
|
||||
s_locked_ctr = 0;
|
||||
}
|
||||
/* WAIT NOT TO OVERLAP */
|
||||
} else if (state == s_wait_to_not_overlap) {
|
||||
if (!player.overlaps(active_region)) {
|
||||
state = s_normal;
|
||||
score_text_1.alpha = score_text_2.alpha = 1;
|
||||
score_text_2.x = Registry.SCREEN_WIDTH_IN_PIXELS + 20;
|
||||
score_text_1.x = -30;
|
||||
}
|
||||
} else if (state == s_open_anim) {
|
||||
// var nr_squares = Registry.Big_Door_Reqs[parseInt(xml.@frame)];
|
||||
var nr_squares:int = 20;
|
||||
var square:FlxSprite;
|
||||
if (s_open_anim_ctr == 0) {
|
||||
player.dontMove = true;
|
||||
|
||||
for (i = 0; i < nr_squares; i++) {
|
||||
square = locked_squares.members[i];
|
||||
square.rotate_angle = i * (360 / nr_squares);
|
||||
square.scale.x = square.scale.y = 1;
|
||||
square.color = 0xff000000;
|
||||
}
|
||||
s_open_anim_ctr ++;
|
||||
} else if (s_open_anim_ctr == 1) { //rotate, fade in squaers
|
||||
|
||||
for (i = 0; i < nr_squares; i++) {
|
||||
square = locked_squares.members[i];
|
||||
square.alpha += (((i + 1) / nr_squares) * 0.008);
|
||||
EventScripts.rotate_about_center_of_sprite(center_sprite, square, init_open_radius, 0.05, -8, -8);
|
||||
if (i == nr_squares - 1) {
|
||||
if (square.alpha > 0.8) s_open_anim_ctr++;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (s_open_anim_ctr == 2) { // move squares to center and outwars
|
||||
for (i = 0; i < nr_squares; i++) {
|
||||
square = locked_squares.members[i];
|
||||
EventScripts.rotate_about_center_of_sprite(center_sprite, square, init_open_radius, 0.1, -8, -8);
|
||||
}
|
||||
init_open_radius -= 1.4;
|
||||
if (init_open_radius < -100) s_open_anim_ctr++;
|
||||
} else if (s_open_anim_ctr == 3) { // move back to center
|
||||
for (i = 0; i < nr_squares; i++) {
|
||||
square = locked_squares.members[i];
|
||||
EventScripts.rotate_about_center_of_sprite(center_sprite, square, init_open_radius, 0.15, -8, -8);
|
||||
}
|
||||
init_open_radius += 1.4;
|
||||
if (init_open_radius > 0) s_open_anim_ctr++;
|
||||
} else if (s_open_anim_ctr == 4) { //flash in, rearrange squares
|
||||
white_flash.alpha += 0.04;
|
||||
if (white_flash.alpha > 0.99) {
|
||||
s_open_anim_ctr++;
|
||||
for each (square in locked_squares.members) {
|
||||
square.scale.y = square.scale.x = 0.5 + 2 * Math.random();
|
||||
square.x += ( -80 + 160 * Math.random());
|
||||
square.y += ( -80 + 160 * Math.random());
|
||||
square.angularVelocity = 400 - 800 * Math.random();
|
||||
}
|
||||
|
||||
}
|
||||
} else if (s_open_anim_ctr == 5) { // flash out
|
||||
white_flash.alpha -= 0.01;
|
||||
if (white_flash.alpha < 0.01) {
|
||||
s_open_anim_ctr++;
|
||||
}
|
||||
} else { // move squares inwards
|
||||
var ctr_ctr:int = 0;
|
||||
var nr_done:int = 0;
|
||||
white_flash.alpha -= 0.1;
|
||||
for each (square in locked_squares.members) {
|
||||
if (square.alpha == 0) {
|
||||
nr_done++;
|
||||
if (nr_done == locked_squares.maxSize) {
|
||||
s_open_anim_ctr++;
|
||||
state = s_opening;
|
||||
white_flash.alpha = 0;
|
||||
player.dontMove = false;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (EventScripts.send_property_to(square, "x", getScreenXY().x + width / 2, 1)) ctr_ctr++;
|
||||
if (EventScripts.send_property_to(square, "y", getScreenXY().y, 1)) ctr_ctr++;
|
||||
if (ctr_ctr == 2) {
|
||||
square.alpha = 0;
|
||||
}
|
||||
ctr_ctr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The event will freeze controls, and then show the squares in a grid if not enough,
|
||||
* or play the animation if there are enough. */
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function init_squares():void {
|
||||
for (var i:int = 0; i < locked_squares.maxSize; i++) {
|
||||
var s:FlxSprite = new FlxSprite(10 + 24 * (i % 6), 20 + 24 * int(i / 6));
|
||||
|
||||
if (i < Registry.nr_growths) {
|
||||
s.makeGraphic(20, 20, 0xff000000);
|
||||
} else {
|
||||
s.makeGraphic(20, 20, 0xffffff00);
|
||||
}
|
||||
s.scale.x = s.scale.y = 2;
|
||||
locked_squares.add(s);
|
||||
}
|
||||
locked_squares.setAll("scrollFactor", new FlxPoint(0, 0));
|
||||
locked_squares.setAll("alpha", 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxBasic;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxU;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Button extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var pressed:Boolean = false;
|
||||
public var type:int = 0;
|
||||
public var UP_FRAME:int = 0;
|
||||
public var DOWN_FRAME:int = 1;
|
||||
private var INCREMENTED_REGISTRY:Boolean = false;
|
||||
[Embed (source = "../../res/sprites/gadgets/buttons.png")] public static var S_BUTTON:Class;
|
||||
|
||||
private static var TYPE_PERMANENT:int = 0;
|
||||
private static var TYPE_TEMPORARY:int = 1;
|
||||
public var cid:int = CLASS_ID.BUTTON;
|
||||
private var parent:*;
|
||||
|
||||
private var overlappable_cids:Array = new Array(CLASS_ID.PLAYER, CLASS_ID.SINGLEPUSHBLOCK, CLASS_ID.SILVERFISH, CLASS_ID.SHIELDY, CLASS_ID.MOVER,CLASS_ID.RAT,CLASS_ID.MITRA);
|
||||
|
||||
public function Button(x:int,y:int,_xml:XML,_parent:*)
|
||||
{
|
||||
super(x, y);
|
||||
xml = _xml;
|
||||
immovable = true;
|
||||
solid = false;
|
||||
type = parseInt(_xml.@frame);
|
||||
loadGraphic(S_BUTTON, true, false, 16, 16);
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "STREET") {
|
||||
UP_FRAME = 6;
|
||||
DOWN_FRAME = 7;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BEDROOM") {
|
||||
UP_FRAME = 0;
|
||||
DOWN_FRAME = 1;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
UP_FRAME = 4;
|
||||
DOWN_FRAME = 5;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
UP_FRAME = 8;
|
||||
DOWN_FRAME = 9;
|
||||
}else {
|
||||
UP_FRAME = 2;
|
||||
DOWN_FRAME = 3;
|
||||
}
|
||||
parent = _parent;
|
||||
frame = UP_FRAME;
|
||||
}
|
||||
|
||||
|
||||
override public function update():void {
|
||||
|
||||
|
||||
if (overlaps(parent.player) && parent.player.state != parent.player.S_AIR) {
|
||||
overlap_callback(parent.player, this);
|
||||
}
|
||||
for each (var o:* in parent.sortables.members) {
|
||||
if (o != null && o is FlxSprite) {
|
||||
if (overlaps(o)) {
|
||||
overlap_callback(o, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type == TYPE_PERMANENT) return;
|
||||
|
||||
if (INCREMENTED_REGISTRY && !pressed) {
|
||||
Registry.sound_data.button_up.play();
|
||||
if (Registry.GRID_PUZZLES_DONE > 0)
|
||||
Registry.GRID_PUZZLES_DONE --;
|
||||
INCREMENTED_REGISTRY = false;
|
||||
frame = UP_FRAME;
|
||||
}
|
||||
pressed = false;
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
public function overlap_callback(s:*, x:*):void {
|
||||
if (s is FlxGroup) {
|
||||
s = s.draw_root;
|
||||
if (s == null) return;
|
||||
}
|
||||
if (s.exists && s.hasOwnProperty("cid") && overlappable_cids.indexOf(s.cid) != -1) {
|
||||
pressed = true;
|
||||
|
||||
if (!INCREMENTED_REGISTRY) {
|
||||
Registry.sound_data.button_down.play();
|
||||
frame = DOWN_FRAME;
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
INCREMENTED_REGISTRY = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Gate that only opens when you have enough energy
|
||||
* DAME PARAMS:
|
||||
* p : 2
|
||||
* alive: t/f, whether it should spawn
|
||||
*/
|
||||
public class Challenge_Gate extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/challenge_gate.png")] public static var sprite_challenge_gate:Class;
|
||||
|
||||
public var cid:int = CLASS_ID.CHALLENGE_GATE;
|
||||
public var xml:XML;
|
||||
public var active_region:FlxSprite;
|
||||
|
||||
public function Challenge_Gate(_xml:XML)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
|
||||
loadGraphic(sprite_challenge_gate, true, false, 16, 16);
|
||||
addAnimation('disappear', [0, 1, 2, 3,4], 4, false);
|
||||
immovable = true;
|
||||
frame = 0;
|
||||
active_region = new FlxSprite(x, y + height);
|
||||
active_region.makeGraphic(width, 4, 0xff00ffff);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (frame == 4) {
|
||||
xml.@alive = "false";
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function check_open(p:Player):void {
|
||||
|
||||
if (p.overlaps(active_region)) {
|
||||
if (xml.@alive == "false") return;
|
||||
if (p.health_bar.cur_health == p.health_bar.max_health && frame == 0) { //change for energy
|
||||
play('disappear');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import entity.player.Player;
|
||||
import global.Keys;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.FlxBitmapFont;
|
||||
import states.PauseState;
|
||||
|
||||
public class Checkpoint extends FlxSprite
|
||||
{
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
private var xml:XML;
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
private var state:int;
|
||||
private var s_inactive:int = 0;
|
||||
private var s_stepped_on:int = 1;
|
||||
private var s_active:int = 2;
|
||||
private var s_dialog:int = 3;
|
||||
private var did_save:Boolean = false;
|
||||
private var did_autosave:Boolean = false;
|
||||
private var t_save:Number = 0;
|
||||
private var tm_save:Number = 0.1;
|
||||
private var saved_coords:Boolean = false;
|
||||
|
||||
private var save_dialog_bg:FlxSprite;
|
||||
private var save_dialog_text:FlxBitmapFont;
|
||||
private var save_dialog_selector:FlxSprite;
|
||||
private var ctr:int = 0;
|
||||
|
||||
private var autosave_anim_ctr:int = 0;
|
||||
private var autosave_started:Boolean = false;
|
||||
private var autosave_loop:Boolean = true;
|
||||
|
||||
|
||||
private var player_hasnt_stepped_off:Boolean = false;
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/checkpoint.png")] public static var checkpoint_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/checkpoint_save_box.png")] public static var checkpoint_save_box_sprite:Class;
|
||||
public function Checkpoint(_player:Player,_parent:*,_xml:XML)
|
||||
{
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
loadGraphic(checkpoint_sprite, true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
addAnimation("inactive", [4]);
|
||||
addAnimation("stepped_on", [5,6],12);
|
||||
addAnimation("active", [5,6,7], 10, false);
|
||||
} else {
|
||||
addAnimation("inactive", [0]);
|
||||
addAnimation("stepped_on", [1, 2],12);
|
||||
addAnimation("active", [1, 2, 3], 10, false);
|
||||
}
|
||||
|
||||
width = height = 8;
|
||||
offset.x = offset.y = 4;
|
||||
x += 4;
|
||||
y += 4;
|
||||
|
||||
save_dialog_bg = new FlxSprite;
|
||||
save_dialog_bg.loadGraphic(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("Save game?\n Yes\n No", "left", save_dialog_bg.x + 5, save_dialog_bg.y + 2, null, "apple_white");
|
||||
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.color = 0xffffff;
|
||||
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;
|
||||
|
||||
parent.fg_sprites.add(save_dialog_bg);
|
||||
parent.fg_sprites.add(save_dialog_text);
|
||||
parent.fg_sprites.add(save_dialog_selector);
|
||||
save_dialog_bg.visible = save_dialog_text.visible = save_dialog_selector.visible = false;
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
oscillate_autosave();
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
|
||||
if (player.overlaps(this)) {
|
||||
player_hasnt_stepped_off = true;
|
||||
}
|
||||
|
||||
if (Registry.checkpoint.area == Registry.CURRENT_MAP_NAME && Registry.checkpoint.x == x && Registry.checkpoint.y == y) {
|
||||
play("active");
|
||||
state = s_active;
|
||||
} else {
|
||||
state = s_inactive;
|
||||
play("inactive");
|
||||
}
|
||||
}
|
||||
|
||||
if (player_hasnt_stepped_off) {
|
||||
super.update();
|
||||
if (!player.overlaps(this)) {
|
||||
player_hasnt_stepped_off = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Info popup
|
||||
if (!Registry.GE_States[Registry.GE_Did_A_Checkpoint]) {
|
||||
if (!Intra.is_test && EventScripts.distance(this,player) < 18) {
|
||||
Registry.GE_States[Registry.GE_Did_A_Checkpoint] = true;
|
||||
player.be_idle();
|
||||
|
||||
//DH.dialogue_popup("While standing on a checkpoint, press " + Registry.controls[Keys.IDX_ACTION_1] + " to save your progress and set it as your respawn point if you die.");
|
||||
DH.dialogue_popup(DH.lk("checkpoint",1)+" " + Registry.controls[Keys.IDX_ACTION_1] + " "+DH.lk("checkpoint",2));
|
||||
}
|
||||
}
|
||||
|
||||
// Do autosave if close or in same room
|
||||
//if (!did_autosave) {
|
||||
//if (Registry.autosave_on) {
|
||||
//if (Registry.is_playstate || (Math.abs(x - player.x) < 48 && Math.abs(y - player.y) < 48)) {
|
||||
//did_autosave = true;
|
||||
//autosave_started = true;
|
||||
// Make save icon appear
|
||||
//Save.save();
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
// Behavior the same otherwise
|
||||
switch (state) {
|
||||
case s_inactive:
|
||||
if (player.overlaps(this) && player.state == player.S_GROUND) {
|
||||
play("stepped_on");
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
state = s_stepped_on;
|
||||
}
|
||||
break;
|
||||
case s_stepped_on:
|
||||
// Require player input to set checkpint.
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
Registry.sound_data.button_down.play();
|
||||
// If this checkpoint is activated and it is not ou current one,
|
||||
// then refill the health of the palyer
|
||||
if (!(Registry.checkpoint.area == Registry.CURRENT_MAP_NAME && Registry.checkpoint.x == x && Registry.checkpoint.y == y)) {
|
||||
player.health_bar.modify_health(20);
|
||||
}
|
||||
update_global_checkpoint();
|
||||
|
||||
// Ask the player if they want to save if autosave is not on.
|
||||
if (!Registry.autosave_on) {
|
||||
state = s_dialog;
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle()
|
||||
save_dialog_bg.visible = save_dialog_selector.visible = save_dialog_text.visible = true;
|
||||
save_dialog_selector.x = save_dialog_text.x + 4;
|
||||
save_dialog_selector.y = save_dialog_text.y + 8;
|
||||
} else {
|
||||
|
||||
if (Registry.is_playstate || (Math.abs(x - player.x) < 48 && Math.abs(y - player.y) < 48)) {
|
||||
did_autosave = true;
|
||||
autosave_started = true;
|
||||
// Make save icon appear
|
||||
Save.save();
|
||||
}
|
||||
|
||||
did_save = true;
|
||||
state = s_active;
|
||||
play("active");
|
||||
}
|
||||
} else {
|
||||
if (!player.overlaps(this)) {
|
||||
state = s_inactive;
|
||||
play("inactive");
|
||||
|
||||
if (Registry.checkpoint.area == Registry.CURRENT_MAP_NAME && Registry.checkpoint.x == x && Registry.checkpoint.y == y) {
|
||||
play("active");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case s_active:
|
||||
if (!did_save) {
|
||||
if (player.overlaps(this)) {
|
||||
play("stepped_on");
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
state = s_stepped_on;
|
||||
}
|
||||
} else { // Timeout, lets you save again if you want to
|
||||
if (!player.overlaps(this)) {
|
||||
t_save += FlxG.elapsed;
|
||||
if (t_save > tm_save) {
|
||||
t_save = 0;
|
||||
did_save = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case s_dialog:
|
||||
player.invincible = true;
|
||||
player.invincible_timer = 0.1;
|
||||
|
||||
if (ctr == 0) {
|
||||
if (Registry.keywatch.JP_DOWN) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group);
|
||||
ctr++;
|
||||
save_dialog_selector.y += 8;
|
||||
}
|
||||
} else {
|
||||
if (Registry.keywatch.JP_UP) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group);
|
||||
ctr--;
|
||||
save_dialog_selector.y -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
if (ctr == 0) {
|
||||
Save.save();
|
||||
autosave_started = true;
|
||||
}
|
||||
|
||||
save_dialog_bg.visible = save_dialog_selector.visible = save_dialog_text.visible = false;
|
||||
ctr = 0;
|
||||
player.state = player.S_GROUND;
|
||||
state = s_active;
|
||||
did_save = true;
|
||||
play("active");
|
||||
}
|
||||
//something something dialog
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function update_global_checkpoint():void
|
||||
{
|
||||
if (saved_coords) return;
|
||||
saved_coords = true;
|
||||
Registry.checkpoint.area = Registry.CURRENT_MAP_NAME;
|
||||
Registry.checkpoint.x = x;
|
||||
Registry.checkpoint.y = y;
|
||||
trace("Check point updated: ",Registry.checkpoint.area, Registry.checkpoint.x, Registry.checkpoint.y);
|
||||
}
|
||||
|
||||
private function oscillate_autosave():void {
|
||||
|
||||
if (autosave_started) {
|
||||
switch (autosave_anim_ctr) {
|
||||
case 0:
|
||||
parent.autosave_icon.visible = true;
|
||||
parent.autosave_icon.alpha = 1;
|
||||
autosave_anim_ctr++;
|
||||
break;
|
||||
case 1:
|
||||
parent.autosave_icon.alpha -= (FlxG.elapsed / 3);
|
||||
if (parent.autosave_icon.alpha < 0.03) {
|
||||
parent.autosave_icon.visible = false;
|
||||
autosave_started = false;
|
||||
autosave_anim_ctr = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
|
||||
super.destroy();
|
||||
save_dialog_bg = save_dialog_selector = null;
|
||||
save_dialog_text = null;
|
||||
if (parent.autosave_icon != null) {
|
||||
parent.autosave_icon.visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import data.SoundData;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxU;
|
||||
import org.flixel.plugin.photonstorm.FlxBitmapFont;
|
||||
import states.PauseState;
|
||||
import states.PlayState;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Console extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.CONSOLE;
|
||||
public var active_region:FlxSprite;
|
||||
public var is_active:Boolean = true;
|
||||
public var INCREMENTED_REGISTRY:Boolean = false;
|
||||
public var did_init:Boolean = false;
|
||||
public var do_sound_test:Boolean = false;
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/console.png")] public var sprite_console:Class;
|
||||
[Embed(source = "../../res/sprites/gadgets/windmill_inside.png")] public static var embed_windmill_inside:Class;
|
||||
|
||||
private var p:Player;
|
||||
|
||||
|
||||
public function Console(x:int,y:int,_xml:XML,_p:Player)
|
||||
{
|
||||
super(x, y);
|
||||
xml = _xml;
|
||||
if (Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
loadGraphic(embed_windmill_inside, true, false, 48, 48);
|
||||
addAnimation("active", [0, 1], 5, true);
|
||||
addAnimation("green", [1], 3, true);
|
||||
active_region = new FlxSprite(x + 16, y + 16);
|
||||
active_region.makeGraphic(24, 20, 0x00ffffff);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK" && Registry.CURRENT_GRID_Y >= 7) {
|
||||
loadGraphic(sprite_console, true, false, 16, 16);
|
||||
addAnimation("spaz", [0, 1, 2], 20);
|
||||
play("spaz");
|
||||
active_region = new FlxSprite(x, y + 16);
|
||||
active_region.makeGraphic(16, 4, 0x00ffffff);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "DEBUG" && Registry.CURRENT_GRID_Y < 3) {
|
||||
loadGraphic(sprite_console, true, false, 16, 16);
|
||||
addAnimation("spaz", [0, 1, 2], 20);
|
||||
play("spaz");
|
||||
active_region = new FlxSprite(x, y + 16);
|
||||
active_region.makeGraphic(x, y + 16);
|
||||
do_sound_test = true;
|
||||
} else {
|
||||
loadGraphic(sprite_console, true, false, 16, 16);
|
||||
addAnimation("active", [0, 1], 5, true);
|
||||
addAnimation("green", [2], 3, true);
|
||||
active_region = new FlxSprite(x, y + 16);
|
||||
active_region.makeGraphic(16, 4, 0x00ffffff);
|
||||
}
|
||||
play("active");
|
||||
immovable = true;
|
||||
active_region.solid = false;
|
||||
|
||||
p = _p;
|
||||
xml.@p = "2";
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
play("green");
|
||||
is_active = false;
|
||||
}
|
||||
//visible = false;
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (state == S_SOUND) {
|
||||
sound_test();
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
if (!is_active && !INCREMENTED_REGISTRY) {
|
||||
INCREMENTED_REGISTRY = true;
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
play("green");
|
||||
|
||||
}
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "WINDMILL" && !did_init) {
|
||||
did_init = true;
|
||||
Registry.GAMESTATE.sortables.remove(this, true);
|
||||
Registry.GAMESTATE.bg_sprites.add(this);
|
||||
}
|
||||
if (Registry.CURRENT_MAP_NAME != "WINDMILL") {
|
||||
FlxG.collide(this, p);
|
||||
}
|
||||
if (p.overlaps(active_region) && p.facing == UP && (Registry.keywatch.JP_ACTION_1 || Registry.keywatch.JP_ACTION_2)) {
|
||||
if (!Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening] && Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
Registry.E_Load_Cutscene = true;
|
||||
Registry.CURRENT_CUTSCENE = Cutscene.Windmill_Opening;
|
||||
is_active = false;
|
||||
xml.@alive = "false";
|
||||
Registry.sound_data.get_small_health.play();
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK" && Registry.CURRENT_GRID_Y >= 7) {
|
||||
DH.start_dialogue(DH.name_rock, DH.scene_rock_five, "NEXUS");
|
||||
} else if (do_sound_test) {
|
||||
state = S_SOUND;
|
||||
Registry.GAMESTATE.player.be_idle();
|
||||
} else {
|
||||
is_active = false;
|
||||
xml.@alive = "false";
|
||||
Registry.sound_data.get_small_health.play();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
private var state:int = 0;
|
||||
private const S_SOUND:int = 1;
|
||||
private var soundtest_init:Boolean = false;
|
||||
private var sound_bg:FlxSprite;
|
||||
private var sound_text:FlxBitmapFont;
|
||||
private var sound_select_1:FlxSprite;
|
||||
private var sound_select_2:FlxSprite;
|
||||
private var snd_ctr:int = 0;
|
||||
private const snd_text:String = "Jukebox!\nMuzak\nSFX";
|
||||
private function sound_test():void {
|
||||
if (soundtest_init == false) {
|
||||
|
||||
sound_bg = new FlxSprite;
|
||||
sound_bg.loadGraphic(Checkpoint.checkpoint_save_box_sprite, true, false, 80, 29);
|
||||
sound_bg.scrollFactor.x = sound_bg.scrollFactor.y = 0;
|
||||
sound_bg.x = (160 - sound_bg.width) / 2;
|
||||
sound_bg.y = 20 + (160 - sound_bg.height) / 2;
|
||||
|
||||
sound_text= EventScripts.init_bitmap_font(snd_text, "center", sound_bg.x + 5, sound_bg.y + 3, null, "apple_black");
|
||||
sound_select_1 = new FlxSprite;
|
||||
sound_select_1.loadGraphic(PauseState.arrows_sprite, true, false, 7, 7);
|
||||
sound_select_1.scrollFactor = new FlxPoint(0, 0);
|
||||
sound_select_1.addAnimation("flash", [0, 1], 12);
|
||||
sound_select_1.play("flash");
|
||||
sound_select_1.scale.x = -1;
|
||||
|
||||
sound_select_1.x = sound_text.x + 4;
|
||||
sound_select_1.y = sound_text.y + 8;
|
||||
|
||||
var p:PlayState;
|
||||
p = Registry.GAMESTATE;
|
||||
p.fg_sprites.add(sound_bg);
|
||||
p.fg_sprites.add(sound_text);
|
||||
p.fg_sprites.add(sound_select_1);
|
||||
soundtest_init = true;
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_ACTION_2 && ((snd_ctr == 1) || (snd_ctr == 2))) {
|
||||
sound_bg.visible = sound_text.visible = sound_select_1.visible = false;
|
||||
Registry.GAMESTATE.player.state = Registry.GAMESTATE.player.S_GROUND;
|
||||
state = 0;
|
||||
snd_ctr = 0;
|
||||
return;
|
||||
}
|
||||
if (snd_ctr == 0) {
|
||||
sound_bg.visible = sound_text.visible = sound_select_1.visible = true;
|
||||
Registry.GAMESTATE.player.state = Registry.GAMESTATE.player.S_INTERACT;
|
||||
snd_ctr = 1;
|
||||
} else if (snd_ctr == 1) {
|
||||
if (Registry.keywatch.JP_DOWN) {
|
||||
sound_select_1.y += 8;
|
||||
snd_ctr = 2;
|
||||
}
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
snd_ctr = 3;
|
||||
sound_select_1.visible = false;
|
||||
sound_text.text = "MUSIC\n" + music_idx.toString();
|
||||
}
|
||||
} else if (snd_ctr == 2) {
|
||||
if (Registry.keywatch.JP_UP) {
|
||||
sound_select_1.y -= 8;
|
||||
snd_ctr = 1;
|
||||
}
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
sound_text.text = "SFX\n\n" + snd_idx.toString();
|
||||
snd_ctr = 4;
|
||||
sound_select_1.visible = false;
|
||||
}
|
||||
} else if (snd_ctr == 3) {
|
||||
do_music();
|
||||
} else if (snd_ctr == 4) {
|
||||
do_sfx();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static var sfxs:Array;
|
||||
private var snd_idx:int = 0;
|
||||
private function do_sfx():void {
|
||||
if (sfxs == null) {
|
||||
var s:SoundData = Registry.sound_data;
|
||||
sfxs = new Array(s.unlock, s.open, s.fall_in_hole, s.push_block, s.button_up, s.button_down, s.floor_crack, s.get_treasure, s.get_key, s.dash_pad_1, s.dash_pad_2, s.spring_bounce, s.puddle_up, s.puddle_down, s.puddle_step, s.ladder_step, s.sun_guy_death_l, s.sun_guy_death_s, s.sun_guy_scream, s.sun_guy_charge, s.player_jump_down, s.player_jump_up, s.enter_door, s.player_hit_1, s.broom_hit, s.teleport_up, s.teleport_down, s.shieldy_hit, s.shieldy_ineffective, s.red_cave_rise, s.redboss_moan, s.small_wave, s.big_wave, s.redboss_death, s.dog_dash, s.talk_group, s.wb_tap_ground, s.wb_hit_ground, s.wb_shoot, s.wb_moan, s.wb_moan_2, s.talk_death, s.teleguy_up, s.teleguy_down, s.gasguy_shoot, s.gasguy_move, s.rat_move, s.sb_split, s.sb_hurt, s.sb_dash, s.sb_ball_appear, s.sf_move, s.dustmaid_alert, s.elevator_open, s.elevator_close, s.flame_pillar_group, s.fireball_group, s.get_small_health, s.big_door_locked, s.hitground1, s.fall1, s.slasher_atk, s.on_off_laser_shoot, s.dialogue_bloop, s.cicada_chirp, s.briar_shine_group, s.stream_sound, s.dust_explode_group, s.mushroom_sound_group, s.slime_walk_group, s.slime_splash_group, s.slime_shoot_group, s.four_shooter_pop_group, s.four_shooter_shoot_group, s.mover_move_group, s.mover_die_group, s.bubble_group, s.bubble_triple_group, s.laser_pew_group, s.menu_move_group, s.menu_select_group, s.pause_sound_group, s.enemy_explode_1_group, s.swing_broom_group, s.water_step_group, s.dialogue_blip_group, s.sparkle_group, s.dog_bark_group, Dust.dust_sound);
|
||||
// Init array
|
||||
}
|
||||
if (Registry.keywatch.JP_ACTION_2) {
|
||||
snd_ctr = 2;
|
||||
sound_text.text = snd_text;
|
||||
sound_select_1.visible = true;
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_RIGHT && snd_idx < sfxs.length - 1) {
|
||||
snd_idx += 1;
|
||||
sound_text.text = "SFX\n\n" + snd_idx.toString();
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_LEFT && snd_idx > 0) {
|
||||
snd_idx -= 1;
|
||||
sound_text.text = "SFX\n\n" + snd_idx.toString();
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
if (sfxs[snd_idx]) {
|
||||
if ("FlxSound" == FlxU.getClassName(sfxs[snd_idx], true)) {
|
||||
sfxs[snd_idx].play();
|
||||
} else {
|
||||
Registry.sound_data.play_sound_group(sfxs[snd_idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static var musicks:Array;
|
||||
private var music_idx:int = 0;
|
||||
|
||||
private function do_music():void {
|
||||
if (musicks == null) {
|
||||
musicks = new Array("TITLE", "BLANK", "NEXUS", "STREET", "OVERWORLD", "BEDROOM", "BEDROOMBOSS", "MITRA", "FIELDS", "BEACH", "REDSEA", "FOREST", "CLIFF", "REDCAVE", "REDCAVEBOSS", "CROWD", "CROWDBOSS", "WINDMILL", "SUBURB", "SPACE", "APARTMENT", "APARTMENTBOSS", "ROOF", "HOTEL", "HOTELBOSS", "CELL", "CIRCUS", "CIRCUSBOSS", "PRETERMINAL", "SAGEFIGHT", "TERMINAL", "GO", "HAPPYINIT", "HAPPY", "BLUE", "BRIARFIGHT", "ENDING");
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_ACTION_2) {
|
||||
snd_ctr = 1;
|
||||
sound_select_1.visible = true;
|
||||
sound_text.text = snd_text;
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_RIGHT && music_idx < musicks.length - 1) {
|
||||
music_idx ++;
|
||||
sound_text.text = "MUSIC\n" + music_idx.toString();
|
||||
}
|
||||
|
||||
if (Registry.keywatch.JP_LEFT && music_idx > 0) {
|
||||
music_idx--;
|
||||
sound_text.text = "MUSIC\n" + music_idx.toString();
|
||||
}
|
||||
|
||||
|
||||
if (Registry.keywatch.JP_ACTION_1) {
|
||||
Registry.sound_data.start_song_from_title(musicks[music_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class CrackedTile extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/crackedtiles.png")] public var C_CRACKED_TILES:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var on:Boolean = false;
|
||||
public var broken:Boolean = false;
|
||||
public var TIMER_DEFAULT:Number = 1.0;
|
||||
public var timer:Number = TIMER_DEFAULT;
|
||||
public var hole:Hole;
|
||||
public var type:String = "CrackedTile";
|
||||
|
||||
private var player:Player;
|
||||
|
||||
public var cid:int = CLASS_ID.CRACKEDTILE;
|
||||
|
||||
public function CrackedTile(_x:int, _y:int, _xml:XML, _player:Player)
|
||||
{
|
||||
super(_x, _y);
|
||||
xml = _xml;
|
||||
immovable = true;
|
||||
solid = false;
|
||||
loadGraphic(C_CRACKED_TILES, false, false, 16, 16);
|
||||
frame = parseInt(xml.@frame);
|
||||
if (Registry.CURRENT_MAP_NAME == "BEDROOM") frame = 0;
|
||||
hole = new Hole(x, y, null, _player,frame);
|
||||
hole.visible = false;
|
||||
|
||||
player = _player;
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
|
||||
if (player.state != player.S_AIR && player.overlaps(this)) {
|
||||
on = true;
|
||||
}
|
||||
if (broken) {
|
||||
return;
|
||||
}
|
||||
if (on) {
|
||||
timer -= FlxG.elapsed;
|
||||
if (timer < 0) {
|
||||
Registry.sound_data.floor_crack.play();
|
||||
broken = true;
|
||||
visible = false;
|
||||
hole.visible = true;
|
||||
}
|
||||
}
|
||||
on = false;
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
|
||||
public class Dash_Pad extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/dash_pads.png")] public static var dash_pad_sprite:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var parent:*;
|
||||
public var player:Player;
|
||||
public var player_tracker:FlxSprite = new FlxSprite();
|
||||
|
||||
private var type:int;
|
||||
|
||||
|
||||
private var disabled:Boolean = false;
|
||||
private var t_disabled:Number = 0;
|
||||
private var tm_disabled:Number = 1.0;
|
||||
|
||||
|
||||
|
||||
public function Dash_Pad(_xml:XML, _player:Player, _parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
parent = _parent;
|
||||
player = _player;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
type = parseInt(xml.@frame);
|
||||
|
||||
loadGraphic(dash_pad_sprite, true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "DEBUG" || 1) {
|
||||
if (type == 0) {
|
||||
frame = 4;
|
||||
type = UP;
|
||||
} else if (type == 2) {//down
|
||||
frame = 6;
|
||||
type = DOWN;
|
||||
} else if (type == 1) {//right
|
||||
frame = 5;
|
||||
type = RIGHT;
|
||||
} else if (type == 3) {
|
||||
frame = 7;
|
||||
type = LEFT;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
player_tracker.makeGraphic(1, 1, 0x00123123);
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
player_tracker.x = player.midpoint.x;
|
||||
player_tracker.y = player.midpoint.y;
|
||||
|
||||
if (!disabled && (player.state == player.S_GROUND) && player_tracker.overlaps(this)) {
|
||||
player.SIG_DASH = true;
|
||||
player.SIG_DASH_TYPE = type;
|
||||
|
||||
alpha = 0.5;
|
||||
disabled = true;
|
||||
trace("Sending SIG DASH (DURL) ", type.toString(16));
|
||||
} else {
|
||||
t_disabled += FlxG.elapsed;
|
||||
if (t_disabled > tm_disabled) {
|
||||
t_disabled = 0;
|
||||
alpha = 1;
|
||||
disabled = false;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,738 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.interactive.Fisherman;
|
||||
import entity.player.HealthBar;
|
||||
import entity.player.Player;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import helper.Parabola_Thing;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
import states.PauseState;
|
||||
import states.PlayState;
|
||||
import global.Registry;
|
||||
// Door class - based on "type" input, load
|
||||
/* the right sprite, whether it's visible, etc,,,whatever the need arises */
|
||||
public class Door extends FlxSprite
|
||||
|
||||
|
||||
{
|
||||
|
||||
public static const INVISIBLE_TYPE:int = 1;
|
||||
public static const NORMAL_TYPE:int = 2;
|
||||
public static const THIN_INVISIBLE_TYPE:int = 3;
|
||||
public static const BLANK_PORTAL_UP_TYPE:int = 4;
|
||||
public static const INVISIBLE_TYPE_UP:int = 5;
|
||||
public static const NO_ENTRANCE_INVIS:int = 6;
|
||||
public static const WHIRLPOOL:int = 7;
|
||||
public static const FALL_DOOR:int = 8;
|
||||
public static const NO_MOVE_DOOR:int = 9;
|
||||
public static const RIGHT_DOOR:int = 11;
|
||||
public static const LEFT_DOOR:int = 10;
|
||||
public static const WIDE_5_DOOR_D:int = 12;
|
||||
public static const TALL_5_DOOR_L:int = 13;
|
||||
public static const WIDE_5_DOOR_U:int = 14;
|
||||
public static const TALL_5_DOOR_R:int = 15;
|
||||
public static const NEXUS_PAD:int = 16;
|
||||
|
||||
/* descriptive constants that essentially act like shitty keys
|
||||
* for the state of certain doors in the game. */
|
||||
private static const Door_Red_Cave_Left:int = 5;
|
||||
private static const Door_Red_Cave_Right:int = 7;
|
||||
private static const Door_Red_Cave_North:int = 8;
|
||||
|
||||
private static const Door_CrowdBossFilm:int = 14;
|
||||
|
||||
/* Nexus door constants */
|
||||
private static const Door_Nexus2Blank:int = 4;
|
||||
public static const Door_Nexus2Street:int = 13;
|
||||
|
||||
public static const Door_Nexus_Cell:int = 45;
|
||||
public static const Door_Nexus_Suburb:int = 46;
|
||||
public static const Door_Nexus_Space:int = 47;
|
||||
public static const Door_Nexus_Fields:int = 48;
|
||||
public static const Door_Nexus_Overworld:int = 49;
|
||||
public static const Door_Nexus_Forest:int = 50;
|
||||
public static const Door_Nexus_Terminal:int = 51;
|
||||
public static const Door_Nexus_Go:int = 52;
|
||||
public static const Door_Nexus_Redsea:int = 53;
|
||||
public static const Door_Nexus_Cliff:int = 54;
|
||||
public static const Door_Nexus_Beach:int = 55;
|
||||
public static const Door_Nexus_Blue:int = 56;
|
||||
public static const Door_Nexus_Happy:int = 57;
|
||||
public static const Door_Nexus_Circus:int = 58;
|
||||
public static const Door_Nexus_Hotel:int = 59;
|
||||
public static const Door_Nexus_Apartment:int = 60;
|
||||
public static const Door_Nexus_Crowd:int = 61;
|
||||
public static const Door_Nexus_Redcave:int = 62;
|
||||
public static const Door_Nexus_Bedroom:int = 63;
|
||||
public static const Door_Nexus_Windmill:int = 64;
|
||||
private static const Door_Go_Secret:int = 71;
|
||||
|
||||
|
||||
|
||||
private static var Nexus_Door_Keys:Array = new Array(4, 13, 45, 46, 47, 48, 49, 50, 51, 52, 53,54,55,56,57,58,59,60,61,62,63,64);
|
||||
// Maps door keys -> indices in the preview spritesheet
|
||||
// E,g, if you addded the graphic for REDSEA, then you'd look up the key (53), and then add "53: x" to the object below,
|
||||
// where x is the first frame of the 4-frame animation in the spritesheet
|
||||
private static var Nexus_Graphic_Hash:Object = { 13: 0, 49: 4 , 62:8, 61:12, 60: 16, 59: 20, 58: 24, 54: 28, 50: 32, 64: 36, 53: 40, 55:44
|
||||
, 63: 48, 48:52,52:56,51:60,57:64,47:68,45:72,46:76,56:80};
|
||||
private static var Nexus_Key_Hash:Object = { // For the states
|
||||
4: 0, 13: 1, 45: 2, 46: 3,
|
||||
47: 4, 48: 5, 49: 6, 50: 7,
|
||||
51: 8, 52: 9, 53: 10, 54: 11,
|
||||
55: 12, 56: 13, 57: 14, 58: 15,
|
||||
59: 16, 60: 17, 61: 18, 62: 19,
|
||||
63: 20, 64: 21 };
|
||||
private var nexus_jump_exit_d:Number = 0;
|
||||
|
||||
|
||||
//defaults to -1
|
||||
public static var Next_Door_Pair_ID:int = -1;
|
||||
|
||||
/**
|
||||
* Whether or not this door's sibling was used to enter the map.
|
||||
* Used in determining which door is the "entrance" door, allowing the
|
||||
* player to stand on it indefinitely until he moves off.
|
||||
*/
|
||||
private var is_entered_door:Boolean = false;
|
||||
|
||||
[Embed(source = "../../res/sprites/gadgets/doors.png")] public static var Door_Sprites:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/whiteportal.png")] public static var White_Portal_Sprite:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/whirlpool.png")] public static var Whirlpool_Door_Sprite:Class;
|
||||
[Embed(source = "../../res/sprites/gadgets/nexus_door.png")] public static var Sprite_nexus_door:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/nexus_door_preview_overlay.png")] public static var Nexus_door_previews_embed:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/nexus_door_preview_fade.png")] public static var Nexus_door_overlay_embed:Class;
|
||||
[Embed(source = "../../res/sprites/decoration/nexus_cardgem.png")] public static const embed_nexus_cardgem:Class;
|
||||
public var local_id:int;
|
||||
public var mapName:String;
|
||||
// Constants used to lookup values in the door lookup array
|
||||
public var XVAL:int = 0;
|
||||
public var YVAL:int = 1;
|
||||
public var MAPVAL:int = 2;
|
||||
public var xml:XML;
|
||||
public var index:int; // The key into the door lookup array
|
||||
public var inactive:Boolean = false; //whether or not this door 'works'
|
||||
public var type:int;
|
||||
public var parent:*; //playstate or roamstate
|
||||
|
||||
public var nexus_gem:FlxSprite;
|
||||
public var preview:FlxSprite = new FlxSprite;
|
||||
public var preview_fade:FlxSprite = new FlxSprite;
|
||||
public var undim_region:FlxObject = new FlxObject;
|
||||
public var is_dimmed:Boolean = false;
|
||||
|
||||
public var is_nexus_door:Boolean = false;
|
||||
private var start_nexus_door_outro:Boolean = false;
|
||||
private var nexus_ctr:int = 0;
|
||||
|
||||
public var cid:int = CLASS_ID.DOOR;
|
||||
public function Door(_x:int, _y:int, _xml:XML, _parent:*)
|
||||
{
|
||||
super(_x, _y);
|
||||
|
||||
parent = _parent;
|
||||
|
||||
mapName = Registry.CURRENT_MAP_NAME;
|
||||
loadGraphic(Door_Sprites, false, false, 16, 16);
|
||||
|
||||
immovable = true;
|
||||
type = parseInt(_xml.@type); // behavior
|
||||
|
||||
index = parseInt(_xml.@frame); // wher eit is
|
||||
|
||||
if (index == Next_Door_Pair_ID || Next_Door_Pair_ID == -1) {
|
||||
trace("is entered door! ", index);
|
||||
is_entered_door = true;
|
||||
}
|
||||
|
||||
if (Registry.CURRENT_GRID_X == 2 && Registry.CURRENT_GRID_Y == 2 && Registry.CURRENT_MAP_NAME == "GO") {
|
||||
if (false == Registry.GE_States[Registry.GE_QUEST_SPACE]) {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xml = _xml;
|
||||
|
||||
makeGraphic(16, 16, 0x00ffffff);
|
||||
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "NEXUS" && Nexus_Door_Keys.indexOf(index) != -1) {
|
||||
|
||||
|
||||
|
||||
|
||||
var doorPair:Array = Registry.DOOR_INFO[index];
|
||||
|
||||
loadGraphic(Sprite_nexus_door, true, false, 32, 32);
|
||||
visible = false;
|
||||
addAnimation("locked", [0, 1], 12);
|
||||
addAnimation("open", [2]);
|
||||
is_nexus_door = true;
|
||||
|
||||
inactive = !is_active(index);
|
||||
|
||||
if (inactive) {
|
||||
play("locked");
|
||||
} else {
|
||||
play("open");
|
||||
}
|
||||
|
||||
|
||||
// Load the door preview graphics. By default they are hiden, they will
|
||||
// pop iinto view if that nexus door is open
|
||||
load_nexus_preview_graphics(index);
|
||||
preview_fade.alpha = 0.5;
|
||||
if (inactive) {
|
||||
height = 32;
|
||||
preview.visible = preview_fade.visible = false;
|
||||
} else {
|
||||
|
||||
preview.visible = preview_fade.visible = true;
|
||||
}
|
||||
is_nexus_door = true;
|
||||
parent.bg_sprites.add(preview);
|
||||
parent.bg_sprites.add(preview_fade);
|
||||
|
||||
if (Registry.DOOR_INFO[index] == null || Registry.DOOR_INFO[index][0] == null || Registry.DOOR_INFO[index][1] == null) {
|
||||
exists = false;
|
||||
} else {
|
||||
var check_name:String = Registry.DOOR_INFO[index][0][MAPVAL] == "NEXUS" ? Registry.DOOR_INFO[index][1][MAPVAL] : Registry.DOOR_INFO[index][0][MAPVAL];
|
||||
}
|
||||
|
||||
if (true == have_all_cards(check_name)) {
|
||||
nexus_gem = new FlxSprite(x, y + 2, embed_nexus_cardgem);
|
||||
parent.bg_sprites.add(nexus_gem);
|
||||
//trace(check_name, " has all cards.");
|
||||
} else {
|
||||
|
||||
//trace(check_name, " not has all.");
|
||||
}
|
||||
|
||||
undim_region = new FlxObject(x, y + 32, 32, 25);
|
||||
|
||||
} else {
|
||||
if (!is_active(index)) {
|
||||
trace("Door ",index," inactive");
|
||||
inactive = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_nexus_door) {
|
||||
} else if (type == Door.THIN_INVISIBLE_TYPE) {
|
||||
makeGraphic(16, 4, 0x00ffffff);
|
||||
visible = false;
|
||||
height = 4;
|
||||
} else if (type == Door.BLANK_PORTAL_UP_TYPE) {
|
||||
loadGraphic(White_Portal_Sprite, true, false, 16, 16);
|
||||
width = height = 2;
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
|
||||
addAnimation("a", [4,5], 8, true);
|
||||
} else {
|
||||
|
||||
addAnimation("a", [0, 1, 2], 10, true);
|
||||
}
|
||||
play("a");
|
||||
centerOffsets(true);
|
||||
} else if (type == Door.INVISIBLE_TYPE_UP) {
|
||||
width = height = 8;
|
||||
centerOffsets(true);
|
||||
} else if (type == Door.NO_ENTRANCE_INVIS) {
|
||||
x = -65234; //lol
|
||||
y = -3422;
|
||||
} else if (type == Door.LEFT_DOOR) { // Generally these are on the left side of a map
|
||||
width = 16;
|
||||
if (Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
width = 20; // BAD HAX MAN
|
||||
}
|
||||
} else if (type == Door.WHIRLPOOL) {
|
||||
loadGraphic(Whirlpool_Door_Sprite, true, false, 16, 16);
|
||||
addAnimation("whirl", [0, 1], 6, true);
|
||||
addAnimation("transition", [3, 4,4], 6, false);
|
||||
addAnimation("whirl_red", [4, 5], 6, true);
|
||||
if (Fisherman.fisherman_dead) {
|
||||
play("whirl_red");
|
||||
} else {
|
||||
play("whirl");
|
||||
}
|
||||
} else if (type == Door.WIDE_5_DOOR_D || type == Door.WIDE_5_DOOR_U) {
|
||||
width = 80;
|
||||
x -= 32;
|
||||
offset.x = -32;
|
||||
} else if (type == Door.TALL_5_DOOR_L || type == Door.TALL_5_DOOR_R) {
|
||||
height = 80;
|
||||
y -= 32;
|
||||
offset.y = -32;
|
||||
} else if (type == Door.NEXUS_PAD) {
|
||||
x = -60000;
|
||||
y = -60000;
|
||||
} else {
|
||||
trace("Otherwise...", index);
|
||||
width = height = 14;
|
||||
centerOffsets(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
if (start_nexus_door_outro) {
|
||||
nexus_outro();
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == WHIRLPOOL) {
|
||||
if (Fisherman.fisherman_dead) {
|
||||
if (_curAnim.name == "whirl") {
|
||||
play("transition");
|
||||
}
|
||||
|
||||
if (_curAnim.name == "transition" && _curFrame == _curAnim.frames.length - 1) {
|
||||
play("whirl_red");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Bugginess in FlxG.collide? When x values are aligned,
|
||||
* collide returns true even though they're separated by 48 pixels */
|
||||
if (!is_nexus_door && parent.player.touches(this)) {
|
||||
if (!is_entered_door || (is_entered_door && !parent.player.hasnt_stepped_off_the_door_yet)) {
|
||||
if (doorCallback(this, parent.player)) {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
// jesus christ look at that conditional
|
||||
} else if (is_nexus_door && !inactive ) {
|
||||
y += 3;
|
||||
if (parent.player.touches(this)) {
|
||||
parent.player.actions_disabled = true;
|
||||
if (parent.player.facing == UP && Registry.keywatch.JP_ACTION_1 && !start_nexus_door_outro) {
|
||||
start_nexus_door_outro = true;
|
||||
}
|
||||
}
|
||||
y -= 3;
|
||||
} else {
|
||||
y += 2;
|
||||
if (is_entered_door && parent.player.hasnt_stepped_off_the_door_yet) {
|
||||
parent.player.hasnt_stepped_off_the_door_yet = false;
|
||||
} else if (is_nexus_door && parent.player.touches(this)) {
|
||||
parent.player.actions_disabled = true;
|
||||
if (parent.player.facing == UP && Registry.keywatch.JP_ACTION_1) {
|
||||
parent.player.be_idle();
|
||||
//DH.dialogue_popup("The portal does not appear to be active.");
|
||||
DH.dialogue_popup(DH.lk("door", 0));
|
||||
}
|
||||
}
|
||||
y -= 2;
|
||||
}
|
||||
|
||||
if (parent.SWITCH_MAPS) return;
|
||||
|
||||
if (is_nexus_door) {
|
||||
if (!inactive) {
|
||||
if (is_dimmed) {
|
||||
if (undim_region.overlaps(parent.player)) {
|
||||
is_dimmed = false;
|
||||
preview.play("a");
|
||||
}
|
||||
EventScripts.send_property_to(preview_fade, "alpha", 0.5, 0.01);
|
||||
} else {
|
||||
if (!undim_region.overlaps(parent.player)) {
|
||||
is_dimmed = true;
|
||||
preview.play("stop");
|
||||
}
|
||||
EventScripts.send_property_to(preview_fade, "alpha", 0, 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.abs(x - parent.player.x) < 48 && Math.abs(y - parent.player.y) < 48) {
|
||||
if (parent.state == parent.S_NORMAL) {
|
||||
FlxG.collide(parent.player, this);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (inactive && is_active(index)) {
|
||||
inactive = false;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
// There is nothing good about this entire class's code.
|
||||
// this function does nothing but reinforce that fact.
|
||||
private function nexus_outro():void {
|
||||
parent.player.actions_disabled = true;
|
||||
switch (nexus_ctr) {
|
||||
case 0:
|
||||
var p :Player = parent.player;
|
||||
p.solid = false;
|
||||
p.parabola_thing = new Parabola_Thing(parent.player, 16, 0.5, "offset", "y");
|
||||
p.my_shadow.visible = true;
|
||||
p.my_shadow.x = p.x + 2;
|
||||
p.my_shadow.y = p.y + 7;
|
||||
parent.bg_sprites.add(p.my_shadow);
|
||||
p.my_shadow.frame = 3;
|
||||
p.s_interact_shadow_visibility_override = true;
|
||||
p.state = p.S_INTERACT;
|
||||
Registry.sound_data.player_jump_up.play();
|
||||
nexus_ctr++;
|
||||
p.play("jump_u");
|
||||
break;
|
||||
case 1:
|
||||
parent.player.y -= 0.57;
|
||||
nexus_jump_exit_d += 0.57;
|
||||
if (nexus_jump_exit_d > 7) {
|
||||
parent.player.s_interact_shadow_visibility_override = false;
|
||||
}
|
||||
parent.player.my_shadow.x = parent.player.x + 2;
|
||||
parent.player.my_shadow.y = parent.player.y + 5;
|
||||
if (parent.player.parabola_thing.tick()) {
|
||||
parent.bg_sprites.remove(parent.player.my_shadow, true);
|
||||
parent.player.state = parent.player.S_GROUND;
|
||||
parent.player.velocity.y = 0;
|
||||
parent.player.my_shadow.visible = false;
|
||||
doorCallback(this, parent.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup corresponding door and switch states, also revive sprites with permanence <= 1 */
|
||||
public function doorCallback(door:Door, player:Player):Boolean {
|
||||
if (door.inactive) return false;
|
||||
if (player.state != player.S_GROUND && player.state != player.S_LADDER) return false;
|
||||
door.getNextParams();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* If there is a door (a,mid) and (mid,b) then calling this function when
|
||||
* you touch a or b will send you to respectively, b or a. Useful for skipping unfinished
|
||||
* areas without mucking around with the level editor.
|
||||
* @param a
|
||||
* @param mid
|
||||
* @param b
|
||||
* @param a_id
|
||||
* @param b_id
|
||||
*/
|
||||
private function warp(a:String, mid:String, b:String, a_id:int, b_id:int):void {
|
||||
if (mapName == a && index == a_id) {
|
||||
index = b_id;
|
||||
Registry.CURRENT_MAP_NAME = mapName = mid;
|
||||
yeah_no = true;
|
||||
} else if (mapName == b && index == b_id) {
|
||||
index = a_id;
|
||||
Registry.CURRENT_MAP_NAME = mapName = mid;
|
||||
yeah_no = true;
|
||||
}
|
||||
}
|
||||
|
||||
//used in conjunction with warp to do something god knows what
|
||||
private var yeah_no:Boolean = false;
|
||||
/* Sets the correct global values (map name, entrance x/y) based on the door. Then call switch state
|
||||
* whereever ye want */
|
||||
public function getNextParams():void {
|
||||
// Override door ehaviors for demo since DEEP areas arent finished
|
||||
// Door 3 (Fields-beach) and 34 (fields-windmill) are moved to forest for the time being.
|
||||
if (Intra.is_demo) {
|
||||
//warp("CLIFF", "SPACE", "HOTEL", 39, 25);
|
||||
//warp("REDCAVE", "TRAIN", "CIRCUS", 41, 31);
|
||||
//warp("OVERWORLD", "SUBURB", "APARTMENT", 37, 18);
|
||||
//warp("OVERWORLD", "FIELDS", "FOREST", 33, 35);
|
||||
|
||||
}
|
||||
var doorPair:Array = Registry.DOOR_INFO[index];
|
||||
|
||||
Next_Door_Pair_ID = index;
|
||||
var pairIndex:int;
|
||||
|
||||
|
||||
if (yeah_no) {
|
||||
if (doorPair[0][MAPVAL] == mapName) {
|
||||
pairIndex = 1;
|
||||
} else {
|
||||
pairIndex = 0;
|
||||
}
|
||||
} else {
|
||||
if (doorPair[0][XVAL] == (x - offset.x) && doorPair[0][YVAL] == (y - offset.y) && doorPair[0][MAPVAL] == mapName) {
|
||||
pairIndex = 1;
|
||||
} else {
|
||||
pairIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Intra.is_release) {
|
||||
if (Registry.CURRENT_MAP_NAME == "FIELDS" && (Registry.CURRENT_GRID_X < 5 || Registry.CURRENT_GRID_Y > 1)) {
|
||||
//if ((Registry.CURRENT_GRID_X != 1 || Registry.CURRENT_GRID_Y != 5) &&
|
||||
//(Registry.CURRENT_GRID_X != 10 || Registry.CURRENT_GRID_Y != 8)) {
|
||||
// 10 8 windmill
|
||||
parent.player.hasnt_stepped_off_the_door_yet = true;
|
||||
//DH.dialogue_popup("A voice: Sorry, but this area is as far as the demo goes! To proceed beyond, purchase the full version from www.anodynegame.com ! Thanks for playing!");
|
||||
DH.dialogue_popup("A voice: Sorry, but this area is blocked off in this demo! Buy the full version to explore more than these fields!");
|
||||
parent.player.be_idle();
|
||||
return;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Registry.NEXT_MAP_NAME = doorPair[pairIndex][MAPVAL];
|
||||
Registry.ENTRANCE_PLAYER_X = doorPair[pairIndex][XVAL];
|
||||
Registry.ENTRANCE_PLAYER_Y = doorPair[pairIndex][YVAL];
|
||||
|
||||
|
||||
//Special case things when transitioning
|
||||
|
||||
Registry.E_PLAY_ROOF = false;
|
||||
Registry.BOI = false;
|
||||
// If coming from SPACE -> Hotel, play the roof song
|
||||
if (Registry.NEXT_MAP_NAME == "HOTEL" && index == 25) {
|
||||
Registry.E_PLAY_ROOF = true;
|
||||
|
||||
} else if (index == 26) {
|
||||
// Always change songs going between roof and hotel
|
||||
Registry.E_OVERRIDE_SAME_MAP_SONG = true;
|
||||
// Coming from inside to outside, play roof
|
||||
if (Registry.CURRENT_GRID_Y != 0) {
|
||||
Registry.E_PLAY_ROOF = true;
|
||||
} else {
|
||||
}
|
||||
} else if (index == 14) {
|
||||
if (!Registry.Event_Biofilm_Broken) {
|
||||
return;
|
||||
}
|
||||
// Don't allow you to enter GO secret hut till quest is over
|
||||
} else if (index == Door_Go_Secret && false == Registry.GE_States[Registry.GE_QUEST_SPACE]) {
|
||||
return;
|
||||
} else if (index == 73 || index == 75) {
|
||||
// If we are entering a SUBURB house with no filter..
|
||||
Registry.E_OVERRIDE_SAME_MAP_SONG = true;
|
||||
if (Registry.CURRENT_GRID_Y < 4) {
|
||||
Registry.sound_data.trigger_soft = true;
|
||||
Registry.E_NEXT_MAP_NO_STATIC = true;
|
||||
}
|
||||
} else if (index == 74 || index == 76 || index == 78 || index == 77) {
|
||||
if (Registry.CURRENT_GRID_Y < 4) {
|
||||
Registry.E_NEXT_MAP_TURN_ON_LIGHT = true;
|
||||
Registry.E_NEXT_MAP_DARKNESS_8 = true;
|
||||
}
|
||||
} else if (index == 94 && Registry.CURRENT_MAP_NAME == "REDSEA") { // Entering BoI
|
||||
Registry.E_PLAY_ROOF = true;
|
||||
Registry.E_OVERRIDE_SAME_MAP_SONG = true;
|
||||
Registry.BOI = true;
|
||||
}
|
||||
|
||||
|
||||
trace("Getting next door...\ninput is (", x, ",", y, ",", Registry.CURRENT_MAP_NAME);
|
||||
trace("offsets; ", offset.x, offset.y);
|
||||
trace("New : ", Registry.ENTRANCE_PLAYER_X, Registry.ENTRANCE_PLAYER_Y, Registry.NEXT_MAP_NAME);
|
||||
//trace(Registry.ENTRANCE_PLAYER_Y % Registry.SCREEN_HEIGHT_IN_PIXELS);
|
||||
/* Use the just-stepped-on-door's type to determine where the player enters
|
||||
* the next map in reference to the next door. */
|
||||
var door_type:int = parseInt(xml.@type);
|
||||
var curmap:String = Registry.CURRENT_MAP_NAME;
|
||||
var next_y:int = Registry.ENTRANCE_PLAYER_Y;
|
||||
var next_x:int = Registry.ENTRANCE_PLAYER_X;
|
||||
|
||||
var going_to_nexus:Boolean = false;
|
||||
if (Registry.CURRENT_MAP_NAME != "NEXUS" && Registry.CURRENT_MAP_NAME != "BLANK" && Nexus_Door_Keys.indexOf(index) != -1) {
|
||||
going_to_nexus = true;
|
||||
Registry.sound_data.teleport_up.play();
|
||||
} else if (is_nexus_door) {
|
||||
Registry.sound_data.teleport_up.play();
|
||||
}
|
||||
|
||||
// Based on this input door, determine which way
|
||||
// hthe player should face in the next map
|
||||
// and where it should be positioned wrt next map's door.
|
||||
if (going_to_nexus) {
|
||||
next_y += 35;
|
||||
next_x += 10;
|
||||
Registry.sound_data.enter_door.play();
|
||||
} else if (door_type == INVISIBLE_TYPE_UP || door_type == WIDE_5_DOOR_U) {
|
||||
next_y = doorPair[pairIndex][YVAL] - 20;
|
||||
Registry.GAMESTATE.player.TRANSITION_IDLE = "idle_u";
|
||||
Registry.GAMESTATE.player.facing = UP;
|
||||
Registry.sound_data.enter_door.play();
|
||||
} else if (door_type == INVISIBLE_TYPE || door_type == WIDE_5_DOOR_D) {
|
||||
trace("Door type: Invisible Down");
|
||||
next_y += 16;
|
||||
Registry.GAMESTATE.player.TRANSITION_IDLE = "idle_d";
|
||||
Registry.GAMESTATE.player.facing = DOWN;
|
||||
Registry.sound_data.enter_door.play();
|
||||
} else if (door_type == BLANK_PORTAL_UP_TYPE) {
|
||||
Registry.sound_data.teleport_up.play();
|
||||
Registry.EVENT_TELEPORT_DOWN_SOUND = true;
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
next_y -= 12;
|
||||
}
|
||||
|
||||
} else if (door_type == WHIRLPOOL) {
|
||||
|
||||
Registry.E_Enter_Whirlpool_Down = true;
|
||||
if (curmap == "REDSEA") {
|
||||
next_y -= 36;
|
||||
}
|
||||
} else if (door_type == FALL_DOOR) {
|
||||
Registry.E_Enter_Fall_Down = true;
|
||||
} else if (door_type == NO_MOVE_DOOR) {
|
||||
if (is_nexus_door) {
|
||||
next_x += 10;
|
||||
next_y += 8;
|
||||
}
|
||||
Registry.sound_data.enter_door.play();
|
||||
} else if (door_type == RIGHT_DOOR || door_type == TALL_5_DOOR_R) {
|
||||
next_x += 17;
|
||||
Registry.sound_data.enter_door.play();
|
||||
Registry.GAMESTATE.player.TRANSITION_IDLE = "idle_r";
|
||||
Registry.GAMESTATE.player.facing = RIGHT;
|
||||
} else if (door_type == LEFT_DOOR || door_type == TALL_5_DOOR_L) {
|
||||
next_x -= 16;
|
||||
Registry.sound_data.enter_door.play();
|
||||
Registry.GAMESTATE.player.TRANSITION_IDLE = "idle_l";
|
||||
Registry.GAMESTATE.player.facing = LEFT;
|
||||
} else {
|
||||
Registry.sound_data.enter_door.play();
|
||||
next_y += 20;
|
||||
}
|
||||
Registry.ENTRANCE_PLAYER_Y = next_y;
|
||||
Registry.ENTRANCE_PLAYER_X = next_x;
|
||||
|
||||
parent.SWITCH_MAPS = true;
|
||||
}
|
||||
|
||||
private function change_stats(amount:int,give_jump:Boolean):void {
|
||||
amount = amount > 16 ? 16 : amount;
|
||||
if (Registry.MAX_HEALTH < amount) {
|
||||
parent.header_group.remove(parent.player.health_bar, true);
|
||||
parent.player.health_bar = new HealthBar(155, 2, amount);
|
||||
parent.header_group.add(parent.player.health_bar);
|
||||
}
|
||||
|
||||
if (give_jump) {
|
||||
Registry.bound_item_2 = "JUMP";
|
||||
Registry.inventory[Registry.IDX_JUMP] = true;
|
||||
} else {
|
||||
Registry.bound_item_2 = "";
|
||||
Registry.inventory[Registry.IDX_JUMP ] = false;
|
||||
}
|
||||
}
|
||||
/* Based on global game state,
|
||||
* check if this door is active based on its dame index*/
|
||||
public function is_active(_index:int):Boolean {
|
||||
switch (_index) {
|
||||
case Door_Red_Cave_Left:
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Left] == 0) return false;
|
||||
break;
|
||||
case Door_Red_Cave_Right:
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_Right] == 0) return false;
|
||||
break;
|
||||
case Door_Red_Cave_North:
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Red_Cave_North] == 0) return false;
|
||||
break;
|
||||
|
||||
/* For all of the NEXUS doors, if we're entering the pair from a non-nexus map,
|
||||
* then we flip the state to on. which makes the nexus door appear open (vs. closed) */
|
||||
case Door_Nexus2Blank:
|
||||
if (Registry.CURRENT_MAP_NAME == "NEXUS") {
|
||||
preview_fade.exists = preview.exists = false;
|
||||
exists = false;
|
||||
}
|
||||
case Door_CrowdBossFilm:
|
||||
//if...event film broken, active is true
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (Nexus_Door_Keys.indexOf(_index) != -1) {
|
||||
return is_nexus_door_open(Nexus_Key_Hash[_index]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function is_nexus_door_open(door_index:int):Boolean
|
||||
{
|
||||
// If the nexus door is not open
|
||||
if (!Registry.Nexus_Door_State[door_index]) {
|
||||
// And we're entering from the non-nexus side
|
||||
if (Registry.CURRENT_MAP_NAME != "NEXUS") {
|
||||
// Open the nexus side
|
||||
Registry.Nexus_Door_State[door_index] = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function igf_unlock():void {
|
||||
Registry.Nexus_Door_State[Nexus_Key_Hash[Door_Nexus_Apartment]] = true;
|
||||
Registry.Nexus_Door_State[Nexus_Key_Hash[Door_Nexus_Redcave]] = true;
|
||||
Registry.Nexus_Door_State[Nexus_Key_Hash[Door_Nexus_Crowd]] = true;
|
||||
Registry.Nexus_Door_State[Nexus_Key_Hash[Door_Nexus_Circus]] = true;
|
||||
Registry.Nexus_Door_State[Nexus_Key_Hash[Door_Nexus_Hotel]] = true;
|
||||
}
|
||||
|
||||
private function load_nexus_preview_graphics(key:int):void {
|
||||
preview_fade.loadGraphic(Nexus_door_overlay_embed, true, false, 32, 32);
|
||||
preview_fade.alpha = 0;
|
||||
|
||||
preview.loadGraphic(Nexus_door_previews_embed, true, false, 32, 32);
|
||||
if (Nexus_Graphic_Hash.hasOwnProperty(key)) {
|
||||
var i:int = Nexus_Graphic_Hash[key];
|
||||
preview.addAnimation("a", [i, i + 1, i + 2, i + 3], 10, true);
|
||||
preview.addAnimation("stop", [i], 1, true);
|
||||
preview.play("a");
|
||||
} else {
|
||||
preview.addAnimation("a", [0,1,2,3], 10, true);
|
||||
preview.addAnimation("stop", [0], 1, true);
|
||||
preview.play("a");
|
||||
}
|
||||
|
||||
preview_fade.x = preview.x = x;
|
||||
preview_fade.y = preview.y = y;
|
||||
}
|
||||
|
||||
private function have_all_cards(map:String):Boolean {
|
||||
|
||||
if (map == "BLANK") return false;
|
||||
if (PauseState.card_data.hasOwnProperty(map) == false) {
|
||||
if (Registry.Nexus_Door_State[Nexus_Key_Hash[index]] == false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
var id:int = 0;
|
||||
for each (var o:Object in PauseState.card_data[map]) {
|
||||
id = o.id;
|
||||
if (id < 36 || id == 43) {
|
||||
if (Registry.card_states[id] == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map == "STREET") return true;
|
||||
Registry.GE_States[Registry.GE_got_all_cards_inanarea] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
if (preview != null) preview.destroy();
|
||||
preview = null;
|
||||
nexus_gem = null;
|
||||
|
||||
if (preview_fade != null) preview_fade.destroy();
|
||||
preview_fade = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import flash.geom.Point;
|
||||
import helper.DH;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSound;
|
||||
import org.flixel.FlxSprite;
|
||||
import global.Registry;
|
||||
public class Dust extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
[Embed (source = "../../res/sprites/gadgets/dust.png")] public static var DUST_SPRITE:Class;
|
||||
[Embed (source = "../../../../sfx/dustpoof.mp3")] public static var S_DUST_POOF:Class;
|
||||
public static var dust_sound:FlxSound = new FlxSound();
|
||||
public static var EMPTY_FRAME:int = 4;
|
||||
public var cid:int = CLASS_ID.DUST;
|
||||
public var midpoint:Point = new Point();
|
||||
public var ON_CONVEYER:Boolean = false;
|
||||
public var fell_in_hole:Boolean = false;
|
||||
public var on_propelled:Boolean = false;
|
||||
public var poofed_by_player_landing:Boolean = false;
|
||||
|
||||
public var parent:*;
|
||||
|
||||
public var T_NORMAL:int = 0;
|
||||
public var T_PUZZLE:int = 1; //Only used in BEDROOM
|
||||
public var INCREMENTED_PUZCT:Boolean = false;
|
||||
public var dame_frame:int = 0;
|
||||
|
||||
//dust blocks lasers but can be walked over! AH can move it too
|
||||
public function Dust(_x:int, _y:int, _xml:XML,_parent:*)
|
||||
{
|
||||
super(_x, _y);
|
||||
xml = _xml;
|
||||
parent = _parent;
|
||||
if (xml == null) xml = <Dust></Dust>;
|
||||
loadGraphic(DUST_SPRITE, true, false, 16, 16);
|
||||
dust_sound.loadEmbedded(S_DUST_POOF);
|
||||
addAnimation("poof", [0, 1, 2, 3, 4], 13, false);
|
||||
addAnimation("unpoof", [3, 2, 1, 0], 13, false);
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
Registry.subgroup_dust.push(this);
|
||||
|
||||
if (parseInt(xml.@frame) == 1) {
|
||||
dame_frame = T_PUZZLE;
|
||||
}
|
||||
}
|
||||
|
||||
public function hit(hitter:String, player_dir:uint):int {
|
||||
if (hitter == "broom" && visible) {
|
||||
play("poof");
|
||||
if (!Registry.GE_States[Registry.GE_Swept_Dust]) {
|
||||
Registry.GE_States[Registry.GE_Swept_Dust] = true;
|
||||
if (!Intra.is_test) {
|
||||
//DH.dialogue_popup("Your broom is now full of dust! Attack again to place it.");
|
||||
DH.dialogue_popup(DH.lk("dust", 0));
|
||||
}
|
||||
}
|
||||
dust_sound.play();
|
||||
|
||||
}
|
||||
if (frame == 4) {
|
||||
visible = false;
|
||||
|
||||
}
|
||||
return Registry.HIT_NORMAL;
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (velocity == null) {
|
||||
exists = false;
|
||||
return;
|
||||
}
|
||||
/* Set midpoint for collision with conveyer-type tiles. */
|
||||
midpoint.x = x + 8;
|
||||
midpoint.y = y + 8;
|
||||
if (!ON_CONVEYER) {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Check for overlap with a Propelled and if so,
|
||||
* don't fall in a hole. If just poofed, then propel the Propelled. o_o*/
|
||||
for each (var propelled:Propelled in Registry.subgroup_propelled) {
|
||||
if (propelled != null) {
|
||||
if (propelled.overlaps(this)) {
|
||||
|
||||
// Instead, if the propelled is inactive, turn it on, and remove teh dust
|
||||
// If the propelled is active do nothing
|
||||
|
||||
propelled.turn_on();
|
||||
play("poof");
|
||||
if (frame == 4) {
|
||||
x = -5000;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
on_propelled = true;
|
||||
|
||||
/*if (poofed_by_player_landing) {
|
||||
propelled.propel_from_dust_poof();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!on_propelled && (this != parent.player.raft)) {
|
||||
if (fell_in_hole) {
|
||||
play("poof");
|
||||
if (frame == 4) x = -5000;
|
||||
}
|
||||
}
|
||||
on_propelled = false;
|
||||
|
||||
|
||||
if (parent.player.raft != this){
|
||||
FlxG.collide(this, parent.curMapBuf); // Can set ON_CONVEYER to true.
|
||||
}
|
||||
|
||||
/* If dust is on the conveyer and player touches it, then the
|
||||
* played should ride on top of it */
|
||||
if (ON_CONVEYER) {
|
||||
if (parent.player.ON_RAFT == false && parent.player.state != parent.player.S_AIR && parent.player.midpoint.x < x + width && parent.player.midpoint.x > x &&
|
||||
parent.player.midpoint.y > y && parent.player.midpoint.y < y + height) {
|
||||
parent.player.ON_RAFT = true;
|
||||
parent.player.raft = this;
|
||||
parent.bg_sprites.remove(this, true);
|
||||
parent.player_group.add(this);
|
||||
parent.player_group.move_to_front(this);
|
||||
var g:FlxGroup;
|
||||
}
|
||||
}
|
||||
|
||||
ON_CONVEYER = false;
|
||||
|
||||
/* Collision with broom */
|
||||
if (!parent.player.broom.has_dust && parent.player.broom.overlaps(this) && !parent.player.broom.just_released_dust && (parent.player.raft != this)) {
|
||||
if (parent.player.broom.visible) {
|
||||
hit("broom", parent.player.broom.root.facing);
|
||||
parent.player.broom.has_dust = true;
|
||||
parent.player.broom.dust = this;
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
// Weird edge case: You die, sortables "cleaned",
|
||||
// but then the dust that is a raft becomes not a raft,
|
||||
// but is destroyed? so need to set this to false so you go away later
|
||||
exists = false;
|
||||
super.destroy();
|
||||
}
|
||||
public function on_anim_change(name:String,a:int,b:int):void {
|
||||
if (name == "unpoof") {
|
||||
if (dame_frame == T_PUZZLE) {
|
||||
if (!INCREMENTED_PUZCT) {
|
||||
INCREMENTED_PUZCT = true;
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
import data.SoundData;
|
||||
|
||||
import global.Registry;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Gate extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var type:String = "Gate";
|
||||
|
||||
/* These stay open forever once opened */
|
||||
public static var ENEMY_1:int = 0;
|
||||
public static var ENEMY_2:int = 1;
|
||||
public static var ENEMY_3:int = 2;
|
||||
public static var ENEMY_4:int = 3;
|
||||
public static var PUZZLE_1:int = 5;
|
||||
public static var PUZZLE_2:int = 6;
|
||||
public static var PUZZLE_3:int = 7;
|
||||
/* These stay open ONLY WHEN THEIR CONDITIONS ARE MET. */
|
||||
public static var TEMP_ENEMY_1:int = 10;
|
||||
public static var TEMP_ENEMY_2:int = 11;
|
||||
public static var TEMP_ENEMY_3:int = 12;
|
||||
|
||||
public static var TEMP_PUZZLE_1:int = 15;
|
||||
public static var TEMP_PUZZLE_2:int = 16;
|
||||
public static var TEMP_PUZZLE_3:int = 17;
|
||||
|
||||
// Set to 10 as a theoretical limit
|
||||
public var REQUIRED_ENEMIES:int = 10;
|
||||
public var REQUIRED_PUZZLES:int = 10;
|
||||
public var is_temporary:Boolean = false; //DOes this close when its conditions arent met
|
||||
public var CLOSED_FRAME:int;
|
||||
public var behavior_type:int;
|
||||
public var player:Player;
|
||||
|
||||
public var cid:int = CLASS_ID.GATE;
|
||||
|
||||
public var grid_coords:Point = new Point;
|
||||
|
||||
private var player_hasnt_stepped_off:Boolean = false;
|
||||
/**
|
||||
* A gate - basically blocks a room except for some condition.
|
||||
* Conditions include: enemy deaths, or some puzzle events...
|
||||
* "ALIVE":
|
||||
* @param _x
|
||||
* @param _y
|
||||
*/
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/gates.png")] public var C_GATE_SPRITES:Class;
|
||||
|
||||
|
||||
public function Gate(_x:int, _y:int, _xml:XML,_player:Player) {
|
||||
xml = _xml;
|
||||
type = xml.name();
|
||||
super(_x, _y);
|
||||
player = _player;
|
||||
grid_coords.x = Registry.CURRENT_GRID_X;
|
||||
grid_coords.y = Registry.CURRENT_GRID_Y;
|
||||
immovable = true;
|
||||
loadGraphic(C_GATE_SPRITES, true, false, 16, 16);
|
||||
/* set anims */
|
||||
/*if (Registry.CURRENT_MAP_NAME == "BEDROOM") {
|
||||
CLOSED_FRAME = frame = 0;
|
||||
addAnimation("still", [0]);
|
||||
addAnimation("rise", [0, 1, 2, 3],10,false);
|
||||
addAnimation("close", [3,2,1,0],10,false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "STRE1ET") { //TODO change
|
||||
CLOSED_FRAME = frame = 4;
|
||||
addAnimation("still", [4]);
|
||||
addAnimation("rise", [4, 5, 6, 7], 4, false);
|
||||
addAnimation("close", [7,6,5,4], 4, false);*/
|
||||
if (Registry.CURRENT_MAP_NAME == "BLANK") {
|
||||
CLOSED_FRAME = frame = 8;
|
||||
addAnimation("still", [8]);
|
||||
addAnimation("rise", [8,9,10,11], 8, false);
|
||||
addAnimation("close", [11, 10, 9, 8], 4, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
CLOSED_FRAME = frame = 16;
|
||||
addAnimation("still", [16]);
|
||||
addAnimation("close", [19,18,17,16], 8, false);
|
||||
addAnimation("rise", [16,17,18,19], 4, false);
|
||||
} else {
|
||||
CLOSED_FRAME = frame = 0;
|
||||
addAnimation("still", [0]);
|
||||
addAnimation("rise", [0, 1, 2, 3],10,false);
|
||||
addAnimation("close", [3,2,1,0],10,false);
|
||||
}
|
||||
behavior_type = xml.@frame;
|
||||
/* if temporary we always revive this gate */
|
||||
|
||||
/* set conditions to open */
|
||||
switch (behavior_type) {
|
||||
case ENEMY_1:
|
||||
REQUIRED_ENEMIES = 1; break;
|
||||
case ENEMY_2:
|
||||
REQUIRED_ENEMIES = 2; break;
|
||||
case ENEMY_3:
|
||||
REQUIRED_ENEMIES = 3; break;
|
||||
case ENEMY_4:
|
||||
REQUIRED_ENEMIES = 4; break;
|
||||
case PUZZLE_1:
|
||||
REQUIRED_PUZZLES = 1; break;
|
||||
case PUZZLE_2:
|
||||
REQUIRED_PUZZLES = 2; break;
|
||||
case PUZZLE_3:
|
||||
REQUIRED_PUZZLES = 3; break;
|
||||
case TEMP_PUZZLE_1:
|
||||
REQUIRED_PUZZLES = 1;
|
||||
is_temporary = true; break;
|
||||
case TEMP_PUZZLE_2:
|
||||
REQUIRED_PUZZLES = 2;
|
||||
is_temporary = true; break;
|
||||
case TEMP_PUZZLE_3:
|
||||
REQUIRED_PUZZLES = 3;
|
||||
is_temporary = true; break;
|
||||
case TEMP_ENEMY_1:
|
||||
REQUIRED_ENEMIES = 1;
|
||||
is_temporary = true; break;
|
||||
case TEMP_ENEMY_2:
|
||||
REQUIRED_ENEMIES = 2;
|
||||
is_temporary = true; break;
|
||||
case TEMP_ENEMY_3:
|
||||
REQUIRED_ENEMIES = 3;
|
||||
is_temporary = true; break;
|
||||
}
|
||||
/* Temp gates are always closed until told otherwise. */
|
||||
if (is_temporary) {
|
||||
xml.@alive = "true";
|
||||
}
|
||||
|
||||
/* If already opened (permanently), open up when entering ar oom*/
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
//Registry.sound_data.open.play();
|
||||
} else {
|
||||
if (player.overlaps(this)) {
|
||||
player_hasnt_stepped_off = true;
|
||||
frame = CLOSED_FRAME + 3;
|
||||
}
|
||||
}
|
||||
/* set rotation */
|
||||
/* if (x % 160 < 10) {
|
||||
angle = -90;
|
||||
} else if (x % 160 > 140) {
|
||||
angle = 90;
|
||||
}*/
|
||||
|
||||
//HACKS
|
||||
if (Registry.CURRENT_MAP_NAME == "CROWD" && Registry.CURRENT_GRID_X == 0 && Registry.CURRENT_GRID_Y == 4 && REQUIRED_PUZZLES == 3) {
|
||||
REQUIRED_PUZZLES = 2;
|
||||
}
|
||||
Registry.subgroup_gates.push(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Enemies that are perma-dead, as well as perma-solved
|
||||
* puzzles should count in the GRID_..._... counter.
|
||||
*
|
||||
* possible source of bugs - dead enemies not auto-incrementing the counter.
|
||||
* I checked over this on 7/23, though., seems okay
|
||||
*/
|
||||
|
||||
override public function update():void {
|
||||
|
||||
if (player_hasnt_stepped_off) {
|
||||
if (!player.overlaps(this)) {
|
||||
play("close");
|
||||
Registry.sound_data.hitground1.play();
|
||||
player_hasnt_stepped_off = false;
|
||||
}
|
||||
}
|
||||
if (Registry.CURRENT_GRID_X != grid_coords.x || Registry.CURRENT_GRID_Y != grid_coords.y) {
|
||||
return;
|
||||
}
|
||||
|
||||
FlxG.collide(this, player);
|
||||
/* If ever alive and not closed, then close */
|
||||
if (frame != CLOSED_FRAME) {
|
||||
//close it if we're not touching
|
||||
if (xml.@alive == "true" && !player.overlaps(this)) {
|
||||
play("close");
|
||||
Registry.sound_data.hitground1.play();
|
||||
solid = true;
|
||||
}
|
||||
}
|
||||
if (Registry.GRID_ENEMIES_DEAD >= REQUIRED_ENEMIES) {
|
||||
xml.@alive = "false";
|
||||
} else if (Registry.GRID_PUZZLES_DONE >= REQUIRED_PUZZLES) {
|
||||
xml.@alive = "false";
|
||||
} else if (is_temporary) {
|
||||
xml.@alive = "true";
|
||||
}
|
||||
|
||||
if (frame == CLOSED_FRAME && xml.@alive == "false") {
|
||||
Registry.sound_data.open.play();
|
||||
play("rise");
|
||||
solid = false;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
|
||||
|
||||
|
||||
public class Go_Detector extends AnoSprite
|
||||
{
|
||||
|
||||
private var map:FlxTilemap;
|
||||
public var door:FlxSprite;
|
||||
|
||||
private const RED_ID:int = 60;
|
||||
private const GREEN_ID:int = 62;
|
||||
private const YELLOW_ID:int = 63;
|
||||
private const BLUE_ID:int = 61;
|
||||
|
||||
private var RED_PT:Point = new Point(0 + 2, 4 + 2);
|
||||
private var BLUE_PT:Point = new Point(5 + 2, 3 + 2);
|
||||
private var GREEN_PT:Point = new Point(4 + 2, 1 + 2);
|
||||
private var YELLOW_PT:Point = new Point(1 + 2, 1 + 2);
|
||||
|
||||
private const s_closed:int = 0;
|
||||
private const s_opening:int = 1;
|
||||
private const s_open:int = 2;
|
||||
|
||||
public function Go_Detector(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
makeGraphic(4, 4, 0xff151515);
|
||||
|
||||
door = new FlxSprite(0, 0);
|
||||
door.makeGraphic(16, 16, 0xffff0000);
|
||||
|
||||
xml.@p = "2";
|
||||
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
state = s_open;
|
||||
door.color = 0x00ff00;
|
||||
} else {
|
||||
state = s_closed;
|
||||
|
||||
}
|
||||
|
||||
if (Registry.CURRENT_GRID_X == 0 && Registry.CURRENT_GRID_Y == 4) {
|
||||
RED_PT.x = 2 + 1; RED_PT.y = 2 + 3;
|
||||
BLUE_PT.x = 2 + 4; BLUE_PT.y = 2 + 1;
|
||||
GREEN_PT.x = 2 + 4; GREEN_PT.y = 2 + 3;
|
||||
YELLOW_PT.x = 2 + 3; YELLOW_PT.y = 2 + 0;
|
||||
}
|
||||
visible = door.visible = false;
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (Registry.GE_States[Registry.GE_Briar_Blue_Done]) {
|
||||
Registry.GRID_PUZZLES_DONE = 1;
|
||||
}
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
map = parent.curMapBuf;
|
||||
parent.sortables.add(door);
|
||||
door.x = tl.x + 50;
|
||||
door.y = tl.y + 16;
|
||||
}
|
||||
|
||||
if (state == s_closed) {
|
||||
var r:int = map.getTile(RED_PT.x, RED_PT.y);
|
||||
var g:int = map.getTile(GREEN_PT.x, GREEN_PT.y);
|
||||
var b:int = map.getTile(BLUE_PT.x, BLUE_PT.y);
|
||||
var y:int = map.getTile(YELLOW_PT.x, YELLOW_PT.y);
|
||||
|
||||
|
||||
if (r == RED_ID && y == YELLOW_ID && g == GREEN_ID && b == BLUE_ID) {
|
||||
xml.@alive = "false";
|
||||
state = s_opening;
|
||||
Registry.sound_data.open.play();
|
||||
|
||||
}
|
||||
} else if (state == s_opening) {
|
||||
door.alpha -= 0.07;
|
||||
if (door.alpha == 0) {
|
||||
state = s_open;
|
||||
Registry.GRID_PUZZLES_DONE += 1;
|
||||
door.color = 0x00ff00;
|
||||
}
|
||||
} else if (state == s_open) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
RED_PT = BLUE_PT = GREEN_PT = YELLOW_PT = null;
|
||||
parent.sortables.remove(door, true);
|
||||
door.destroy();
|
||||
door = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Gate that only opens with the required number of growths
|
||||
* DAME PARAMS:
|
||||
* type : # of growths to open door
|
||||
* p: 2
|
||||
* alive: t/f, whether it should spawn
|
||||
*/
|
||||
public class Growth_Gate extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../res/sprites/gadgets/growth_gate.png")] public static var sprite_growth_gate:Class;
|
||||
|
||||
public var growth_requirement:int;
|
||||
public var xml:XML;
|
||||
public var active_region:FlxSprite;
|
||||
public var cid:int = CLASS_ID.GROWTH_GATE;
|
||||
public function Growth_Gate(_xml:XML)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
growth_requirement = parseInt(xml.@type);
|
||||
|
||||
loadGraphic(sprite_growth_gate, true, false, 16, 32);
|
||||
addAnimation('disappear', [0, 1, 2, 3,4], 4, false);
|
||||
immovable = true;
|
||||
frame = 0;
|
||||
active_region = new FlxSprite(x, y + height);
|
||||
active_region.makeGraphic(width, 4, 0xff00ffff);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (frame == 4) {
|
||||
xml.@alive = "false";
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
public function check_open(f:FlxSprite):void {
|
||||
|
||||
if (f.overlaps(active_region)) {
|
||||
if (xml.@alive == "false") return;
|
||||
if (Registry.nr_growths >= growth_requirement && frame == 0) {
|
||||
play('disappear');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import org.flixel.FlxSprite;
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Hole extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/hole.png")] public var C_HOLE_SPRITE:Class;
|
||||
public var type:String = "Hole";
|
||||
public var xml:XML;
|
||||
public var active_region:FlxSprite;
|
||||
public var cid:int = CLASS_ID.HOLE;
|
||||
|
||||
private var player:Player;
|
||||
public function Hole(_x:int, _y:int, _xml:XML, _player:Player, _frame:int = 0)
|
||||
{
|
||||
super(_x, _y);
|
||||
|
||||
immovable = true; solid = true;
|
||||
loadGraphic(C_HOLE_SPRITE, true, false, 16, 16);
|
||||
width = 4;
|
||||
height = 4;
|
||||
offset.x = 6;
|
||||
offset.y = 5;
|
||||
x += 6;
|
||||
y += 5;
|
||||
if (_xml != null) {
|
||||
xml = _xml;
|
||||
frame = parseInt(xml.@frame);
|
||||
} else {
|
||||
xml =<Hole />
|
||||
frame = _frame;
|
||||
}
|
||||
player = _player;
|
||||
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
if (player.state != player.S_AIR && player.overlaps(this)) {
|
||||
if (visible){
|
||||
player.isFalling = true;
|
||||
player.fall_pt.x = x;
|
||||
player.fall_pt.y = y;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/*
|
||||
* dame props:
|
||||
* frame - how many tiles this makes the player jump
|
||||
* past the next tile - 0 => 1, 1 => 2.
|
||||
* */
|
||||
public class Jump_Trigger extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/spring_pad.png")] public static var spring_pad_sprite:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
public var distance:int;
|
||||
public var time:Number;
|
||||
public var cid:int = CLASS_ID.JUMP_TRIGGER;
|
||||
private var active_region:FlxSprite = new FlxSprite(0, 0);
|
||||
|
||||
private var dame_type:int = 0;
|
||||
private var T_NORMAL:int = 0;
|
||||
private var T_SPRING:int = 1;
|
||||
private var frame_down:int = 1;
|
||||
private var frame_mid:int = 0;
|
||||
private var activated:Boolean = false;
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
public function Jump_Trigger(_xml:XML, _player:Player,_parent:*)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
dame_type = parseInt(xml.@type);
|
||||
|
||||
if (dame_type == T_SPRING) {
|
||||
loadGraphic(spring_pad_sprite, true, false, 16, 16);
|
||||
addAnimation("still", [0], 0, false);
|
||||
addAnimation("wobble", [0,2,0,1,0,2,0,1,0,0], 10, false);
|
||||
play("still");
|
||||
|
||||
active_region = this;
|
||||
} else {
|
||||
makeGraphic(16, 2, 0x00000000);
|
||||
immovable = true;
|
||||
solid = false;
|
||||
y += 12;
|
||||
active_region.makeGraphic(6, 4, 0x000000);
|
||||
}
|
||||
|
||||
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0:
|
||||
distance = 32;
|
||||
time = 0.3;
|
||||
break;
|
||||
case 1:
|
||||
distance = 48;
|
||||
time = 0.5;
|
||||
break;
|
||||
case 2:
|
||||
distance = 64;
|
||||
time = 0.7;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (!did_init) {
|
||||
did_init = true;
|
||||
parent.sortables.remove(this, true);
|
||||
parent.bg_sprites.add(this);
|
||||
}
|
||||
if (dame_type == T_NORMAL) {
|
||||
active_region.x = x + 5;
|
||||
active_region.y = y;
|
||||
|
||||
if (player.overlaps(active_region) && (player.state == player.S_LADDER || (player.state == player.S_GROUND && player.facing & DOWN))) {
|
||||
make_player_jump();
|
||||
}
|
||||
} else {
|
||||
active_region.x = x;
|
||||
active_region.y = y;
|
||||
if (player.overlaps(active_region)) {
|
||||
if (player.just_landed) {
|
||||
if (!activated) {
|
||||
activated = true;
|
||||
player.is_spring_jump = true;
|
||||
Registry.sound_data.spring_bounce.play();
|
||||
make_player_jump();
|
||||
play("wobble");
|
||||
}
|
||||
} else {
|
||||
if (!activated && player.state == player.S_GROUND) {
|
||||
frame = frame_down;
|
||||
} else if (player.state == player.S_AIR) {
|
||||
frame = frame_mid;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!activated) {
|
||||
frame = frame_mid;
|
||||
}
|
||||
if (_curAnim != null && _curAnim.name == "wobble" && _curAnim.frames.length - 1 == _curFrame) {
|
||||
frame = frame_mid;
|
||||
activated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function make_player_jump():void
|
||||
{
|
||||
player.auto_jump_period = time;
|
||||
player.auto_jump_distance = distance;
|
||||
player.auto_jump_base_y = player.y;
|
||||
player.state = player.S_AUTO_JUMP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxSprite;
|
||||
/**
|
||||
* OH COME ON WHAT DO YOU THINK THIS IS.
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Key extends FlxSprite
|
||||
{
|
||||
public var type:String = "Key";
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/key.png")] public static var C_KEY_SPRITE:Class;
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.KEY;
|
||||
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
public function Key(_x:int, _y:int, _player:Player, _parent:*,_xml:XML = null)
|
||||
{
|
||||
super(_x, _y);
|
||||
loadGraphic(C_KEY_SPRITE, false, false, 16, 16);
|
||||
if(_xml == null) {
|
||||
xml = <Key />;
|
||||
xml.@["x"] = _x.toString();
|
||||
xml.@["y"] = _y.toString();
|
||||
xml.@["p"] = "2"; //Keys only get collected once
|
||||
xml.@["alive"] = "true"; //Presumably, uh.
|
||||
} else {
|
||||
xml = _xml;
|
||||
if (xml.@alive == "false") {
|
||||
visible = false;
|
||||
}
|
||||
y -= 20;
|
||||
}
|
||||
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
|
||||
if (player.overlaps(this) && visible) {
|
||||
Registry.change_nr_keys(1);
|
||||
Registry.sound_data.get_key.play();
|
||||
xml.@alive = "false";
|
||||
visible = false;
|
||||
parent.bg_sprites.remove(this, true);
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,431 @@
|
|||
package entity.gadget
|
||||
{
|
||||
/**
|
||||
* A keyblock. These open up if you have a key.
|
||||
* Its sprite is set based on the frame in the level editor.
|
||||
* Alive refers to whether it has been opened. DUHH
|
||||
* @author Seagaia
|
||||
*/
|
||||
import data.CLASS_ID;
|
||||
import data.Common_Sprites;
|
||||
import entity.interactive.NPC;
|
||||
import entity.player.Player;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxSound;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
import data.SoundData;
|
||||
import global.Registry;
|
||||
|
||||
public class KeyBlock extends FlxSprite
|
||||
{
|
||||
|
||||
public var type:String = "KeyBlock";
|
||||
public var O:int = 16; //Offset for animation when unlocked
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.KEYBLOCK;
|
||||
public var sentinel:FlxSprite;
|
||||
public var active_region:FlxSprite;
|
||||
|
||||
private var is_big:Boolean = false;
|
||||
private var player:Player;
|
||||
private var start_unlock_anim:Boolean = false;
|
||||
private var ctr:int = 0;
|
||||
private var key_sprite:FlxSprite;
|
||||
private var t:Number = 0;
|
||||
private var tm:Number = 0.8;
|
||||
|
||||
public static var sig_change:Boolean = false;
|
||||
private var explosion:FlxSprite;
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/keyhole.png")] public var C_KEYBLOCK_SPRITE:Class;
|
||||
[Embed (source = "../../res/sprites/gadgets/gate_green.png")] public var green_gate_embed:Class;
|
||||
/**
|
||||
*
|
||||
* @param _x
|
||||
* @param _y
|
||||
* @param _frame frame type
|
||||
* @param _xml Reference to the sprites xml (if any)
|
||||
*/
|
||||
public function KeyBlock(_x:int, _y:int, _frame:int,_player:Player,_xml:XML = null)
|
||||
{
|
||||
super(_x , _y);
|
||||
sentinel = new FlxSprite(x -2, y - 2);
|
||||
sentinel.immovable = true;
|
||||
sentinel.makeGraphic(20, 20, 0x00ffffff);
|
||||
|
||||
loadGraphic(C_KEYBLOCK_SPRITE, true, false, 16, 16);
|
||||
|
||||
frame = _frame;
|
||||
immovable = true;
|
||||
if (_xml != null) {
|
||||
xml = _xml;
|
||||
}
|
||||
|
||||
if (frame == 2 && Registry.CURRENT_MAP_NAME == "OVERWORLD") {
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
addAnimation("open", [0, 1, 2, 3, 4, 5], 12, false);
|
||||
is_big = true;
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
switch (frame) {
|
||||
case 1:
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
addAnimation("open", [7, 1, 2, 3, 4, 5], 12, false);
|
||||
frame = 7;
|
||||
break;
|
||||
//blue
|
||||
case 2:
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
addAnimation("open", [0, 1, 2, 3, 4, 5], 12, false);
|
||||
break;
|
||||
//green
|
||||
case 3:
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
frame = 6;
|
||||
addAnimation("open", [6, 1, 2, 3, 4, 5], 12, false);
|
||||
break;
|
||||
//redcave
|
||||
}
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
is_big = true;
|
||||
} else if (frame == 4) { // card gate
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
is_big = true;
|
||||
if (Registry.CURRENT_MAP_NAME == "OVERWORLD") {
|
||||
frame = 8; // 5 card door
|
||||
addAnimation("open", [8, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TERMINAL") {
|
||||
frame = 14;
|
||||
addAnimation("open", [14, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BEACH") {
|
||||
frame = 9;
|
||||
addAnimation("open", [9, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SUBURB") {
|
||||
frame = 10;
|
||||
addAnimation("open", [10, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
frame = 13;
|
||||
addAnimation("open", [13, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK") {
|
||||
if (Registry.CURRENT_GRID_Y > 3 && Registry.CURRENT_GRID_Y < 7) { // 48
|
||||
//frame = 12;'
|
||||
frame = 11; //Changed so you cn get to the debug area with 47
|
||||
|
||||
addAnimation("open", [12, 1, 2, 3, 4, 5], 12, false);
|
||||
} else if(Registry.CURRENT_GRID_Y >= 7) {
|
||||
frame = 16;
|
||||
addAnimation("open", [16, 1, 2, 3, 4, 5], 12, false);
|
||||
} else { // 47
|
||||
frame = 11;
|
||||
addAnimation("open", [11, 1, 2, 3, 4, 5], 12, false);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "NEXUS") {
|
||||
frame = 15;
|
||||
addAnimation("open", [15, 1, 2, 3, 4, 5], 12, false);
|
||||
}
|
||||
active_region = sentinel;
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "FIELDS") {
|
||||
|
||||
loadGraphic(green_gate_embed, true, false, 32, 16);
|
||||
frame = 6;
|
||||
addAnimation("open", [6, 1, 2, 3, 4, 5], 12, false);
|
||||
is_big = true;
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
} else {
|
||||
addAnimation("open", [O, O + 1, O + 2, O + 3, O + 4], 10, false);
|
||||
tm = 0.2;
|
||||
}
|
||||
|
||||
player = _player;
|
||||
|
||||
}
|
||||
|
||||
public function unlock():void {
|
||||
Registry.sound_data.unlock.play();
|
||||
|
||||
play("open");
|
||||
xml.@alive = false;
|
||||
solid = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(this, player);
|
||||
|
||||
if (FlxG.keys.justPressed("G") && Intra.is_test) {
|
||||
Registry.nr_growths += 18;
|
||||
trace("New growhts: ", Registry.nr_growths);
|
||||
}
|
||||
|
||||
if (!is_big) {
|
||||
if (FlxG.overlap(player, sentinel)) {
|
||||
t -= FlxG.elapsed;
|
||||
|
||||
if (t < 0 && Registry.get_nr_keys() > 0 && xml.@alive == true) {
|
||||
unlock();
|
||||
xml.@alive = false;
|
||||
Registry.change_nr_keys( -1);
|
||||
Registry.GAMESTATE.number_of_keys_text.text = "x" + Registry.get_nr_keys().toString();
|
||||
} else if (t < 0 && xml.@alive == "true" && alive && player.state == player.S_GROUND) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblock",0));
|
||||
alive = false;
|
||||
}
|
||||
} else {
|
||||
t = tm;
|
||||
}
|
||||
}
|
||||
|
||||
if (sig_change) {
|
||||
explosion = new FlxSprite;
|
||||
explosion.loadGraphic(EventScripts.small_explosion_sprite, true, false, 24,24);
|
||||
explosion.x = x + 4;
|
||||
explosion.y = y - 4;
|
||||
Registry.GAMESTATE.fg_sprites.add(explosion);
|
||||
explosion.addAnimation("explode", [0, 1, 2, 3, 4], 12, false);
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.enemy_explode_1_group);
|
||||
explosion.play("explode");
|
||||
sig_change = false;
|
||||
frame = 17;
|
||||
}
|
||||
|
||||
if (is_big && xml.@alive == true) {
|
||||
sentinel.x = x + 6;
|
||||
sentinel.y = y - 3;
|
||||
sentinel.width = 10;
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "OVERWORLD" && active_region == null) {
|
||||
if (player.overlaps(sentinel) && player.state == player.S_GROUND && Registry.inventory[Registry.IDX_GREEN_KEY]) {
|
||||
start_unlock_anim = true;
|
||||
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
if (player.overlaps(sentinel) && player.state == player.S_GROUND) {
|
||||
switch (frame) {
|
||||
case 0:
|
||||
if (Registry.inventory[Registry.IDX_GREEN_KEY]) {
|
||||
start_unlock_anim = true;
|
||||
}
|
||||
break;
|
||||
case 6: // red
|
||||
if (Registry.inventory[Registry.IDX_RED_KEY]) {
|
||||
start_unlock_anim = true;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (Registry.inventory[Registry.IDX_BLUE_KEY]) {
|
||||
start_unlock_anim = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "FIELDS") {
|
||||
if (player.overlaps(sentinel) && player.state == player.S_GROUND) {
|
||||
if (Registry.inventory[Registry.IDX_RED_KEY]) {
|
||||
start_unlock_anim = true;
|
||||
}
|
||||
}
|
||||
} else { // It's a fuckin' card gate!
|
||||
var open_the_gate:Boolean = false;
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "OVERWORLD") { // 4 Cards
|
||||
if (Registry.nr_growths < 4 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 0));
|
||||
//DH.dialogue_popup("The gate stares, petrified. It won't open until it senses four cards...");
|
||||
} else if (Registry.nr_growths >= 4 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 1));
|
||||
//DH.dialogue_popup("Sensing four cards, the gate decides to open.");
|
||||
open_the_gate = true;
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TERMINAL") {
|
||||
if (Registry.nr_growths < 36 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
//DH.dialogue_popup("The gate stubbornly remains in place.");
|
||||
} else if (Registry.nr_growths >= 36 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 3));
|
||||
//DH.dialogue_popup("The gate senses all of the cards, and decides to open.");
|
||||
open_the_gate = true;
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BEACH") { // 8
|
||||
if (Registry.nr_growths < 8 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
} else if (Registry.nr_growths >= 8 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 4));
|
||||
open_the_gate = true;
|
||||
}
|
||||
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") { // 24
|
||||
if (Registry.nr_growths < 24 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
} else if (Registry.nr_growths >= 24 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 4));
|
||||
//DH.dialogue_popup("The gate senses enough cards, and decides to open.");
|
||||
open_the_gate = true;
|
||||
}
|
||||
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SUBURB") { // 16
|
||||
if (Registry.nr_growths < 16 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
} else if (Registry.nr_growths >= 16 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 4));
|
||||
//DH.dialogue_popup("The gate senses enough, and decides to open.");
|
||||
open_the_gate = true;
|
||||
}
|
||||
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK") {
|
||||
if (Registry.CURRENT_GRID_Y > 3 && Registry.CURRENT_GRID_Y < 7) {
|
||||
if ( Registry.nr_growths < 47 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
} else if (Registry.nr_growths >= 47 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 5));
|
||||
open_the_gate = true;
|
||||
}
|
||||
} else if (Registry.CURRENT_GRID_Y >= 7) {
|
||||
if (player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
//DH.dialogue_popup("It remains closed.");
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 6));
|
||||
player.be_idle();
|
||||
}
|
||||
} else {
|
||||
if ( Registry.nr_growths < 47 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1 ) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 2));
|
||||
} else if (Registry.nr_growths >= 47 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lk("keyblockgate", 5));
|
||||
open_the_gate = true;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "NEXUS") {
|
||||
if (Registry.nr_growths < 49 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup("....");
|
||||
} else if (Registry.nr_growths >= 49 && player.overlaps(sentinel) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup("!!!");
|
||||
open_the_gate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (xml.@alive == "true" && !start_unlock_anim && open_the_gate && player.overlaps(sentinel) && player.state == player.S_GROUND) {
|
||||
start_unlock_anim = true;
|
||||
ctr = 4; // Skip key shit
|
||||
}
|
||||
}
|
||||
|
||||
if (start_unlock_anim) {
|
||||
unlock_anim();
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
active_region = sentinel = null;
|
||||
super.destroy();
|
||||
}
|
||||
private function unlock_anim():void {
|
||||
var sub_ctr:int = 0;
|
||||
if (ctr == 0 ) {
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
key_sprite = new FlxSprite(player.x, player.y - 16);
|
||||
key_sprite.loadGraphic(NPC.key_green_embed, true, false, 16, 16);
|
||||
key_sprite.alpha = 0;
|
||||
Registry.GAMESTATE.fg_sprites.add(key_sprite);
|
||||
if (Registry.CURRENT_MAP_NAME == "WINDMILL") {
|
||||
switch (frame) {
|
||||
case 0:
|
||||
key_sprite.frame = 0; //WHO NEED SCOMMENTS ANYWAYS
|
||||
break;
|
||||
case 6: //blue
|
||||
key_sprite.frame = 2;
|
||||
break;
|
||||
case 7: // red
|
||||
key_sprite.frame = 4;
|
||||
break;
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "FIELDS") {
|
||||
key_sprite.frame = 2;
|
||||
} else {
|
||||
Registry.sound_data.stop_current_song();
|
||||
}
|
||||
ctr++;
|
||||
} else if (ctr == 1) {
|
||||
if (EventScripts.send_alpha_to(key_sprite, 1, 0.02)) ctr++;
|
||||
} else if (ctr == 2) {
|
||||
key_sprite.flicker(0.5);
|
||||
if (EventScripts.send_property_to(key_sprite, "y", y, 0.2)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(key_sprite, "x", x + 8, 0.2)) sub_ctr++;
|
||||
if (sub_ctr == 2) {
|
||||
ctr++;
|
||||
Registry.sound_data.player_jump_down.play();
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
if (EventScripts.send_alpha_to(key_sprite, 0, -0.025)) {
|
||||
ctr++;
|
||||
}
|
||||
|
||||
} else if (ctr > 3 && ctr < 9) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm) {
|
||||
trace(ctr);
|
||||
FlxG.shake(0.02, 0.3);
|
||||
t = 0;
|
||||
Registry.sound_data.hitground1.play();
|
||||
ctr++;
|
||||
if (frame == 0 || frame == 6 || frame == 7 || frame >= 8 ) {
|
||||
frame = 1;
|
||||
} else {
|
||||
frame++;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 9) {
|
||||
Registry.sound_data.open.play();
|
||||
if (Registry.CURRENT_GRID_Y == 6 && Registry.CURRENT_MAP_NAME == "WINDMILL" && Intra.is_release) {
|
||||
DH.dialogue_popup("A voice: Nice work! You've gotten as far as this demo goes. For the completionists, there are a total of 12 cards to find in this demo.");
|
||||
}
|
||||
player.state = player.S_GROUND;
|
||||
xml.@alive = "false";
|
||||
solid = false;
|
||||
start_unlock_anim = false;
|
||||
|
||||
x -= 160;
|
||||
sentinel.x -= 160;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Hitting this flips the global pillar_switch_state value.
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Pillar_Switch extends FlxSprite
|
||||
{
|
||||
[Embed(source = "../../res/sprites/gadgets/pillar_switch.png")] public var pillar_switch_sprite:Class;
|
||||
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var t_hit:Number = 1.0;
|
||||
public var tm_hit:Number = 1.0;
|
||||
|
||||
public var cid:int = CLASS_ID.PILLAR_SWITCH;
|
||||
|
||||
public function Pillar_Switch(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
|
||||
loadGraphic(pillar_switch_sprite, true, false, 16, 16);
|
||||
addAnimation("a", [0]);
|
||||
addAnimation("b", [1]);
|
||||
addAnimation("hit", [2, 3], 12);
|
||||
immovable = true;
|
||||
|
||||
if (Registry.pillar_switch_state) {
|
||||
play("a");
|
||||
} else {
|
||||
play("b");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(player, this);
|
||||
if (t_hit > tm_hit) {
|
||||
if (_curAnim.name == "hit") {
|
||||
if (Registry.pillar_switch_state) {
|
||||
play("b");
|
||||
} else {
|
||||
play("a");
|
||||
}
|
||||
}
|
||||
if (player.broom.visible && player.broom.overlaps(this)) {
|
||||
play("hit");
|
||||
Registry.pillar_switch_state = !Registry.pillar_switch_state;
|
||||
t_hit = 0;
|
||||
}
|
||||
} else {
|
||||
t_hit += FlxG.elapsed;
|
||||
}
|
||||
|
||||
if (_curAnim.name == "a" && !Registry.pillar_switch_state) {
|
||||
play("b");
|
||||
} else if (_curAnim.name == "b" && Registry.pillar_switch_state) {
|
||||
play("a");
|
||||
}
|
||||
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,308 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* A platform that faces a certain direction. When dust is placed on top
|
||||
* and it is jumped on, this will be propelled in that direction, taking
|
||||
* the player with it.
|
||||
*/
|
||||
public class Propelled extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/moving_platform.png")] public static var moving_platform_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/gadgets/moving_platform_poof.png")] public static var moving_platform_poof_sprite:Class;
|
||||
|
||||
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.PROPELLED;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
private var pushed_to_front:Boolean = false;
|
||||
private var Propel_Speed:int = 33;
|
||||
|
||||
public var active_region:FlxSprite = new FlxSprite();
|
||||
public var dame_frame:int;
|
||||
public var is_active:Boolean = false;
|
||||
private var init_pt:Point = new Point();
|
||||
|
||||
public var dust_poof:FlxSprite = new FlxSprite();
|
||||
private var showed_dust_poof:Boolean = false;
|
||||
|
||||
|
||||
public var is_propelling:Boolean = false;
|
||||
|
||||
private var H_UP_OFF:int = 0;
|
||||
private var H_UP_ON:int = 1;
|
||||
private var H_DOWN_ON:int = 2;
|
||||
private var H_DOWN_OFF:int = 3;
|
||||
private var V_UP_OFF:int = 4;
|
||||
private var V_UP_ON:int = 5;
|
||||
private var V_DOWN_ON:int = 6;
|
||||
private var V_DOWN_OFF:int = 7;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_normal:int = 0;
|
||||
private var s_done:int = 1;
|
||||
|
||||
private var is_first_movement:Boolean = true;
|
||||
|
||||
/*
|
||||
* dame params - frame: waht direction it faces, as well as the sprite itself.
|
||||
* should be added to FRONT of "flat gadgets" so that dust is drawn on tope*/
|
||||
public function Propelled(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
active_region.makeGraphic(10, 10, 0x00123456);
|
||||
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
|
||||
switch (dame_frame % 4) {
|
||||
case 0: facing = UP; break;
|
||||
case 1: facing = RIGHT; break;
|
||||
case 2: facing = DOWN; break;
|
||||
case 3: facing = LEFT; break;
|
||||
}
|
||||
|
||||
if (dame_frame > 3) {
|
||||
is_active = true;
|
||||
} else {
|
||||
is_active = false;
|
||||
}
|
||||
|
||||
dust_poof.makeGraphic(16, 16, 0xffff1233);
|
||||
dust_poof.loadGraphic(moving_platform_poof_sprite, true, false, 16, 16);
|
||||
dust_poof.addAnimation("poof", [0, 1, 2, 3, 4], 12, false);
|
||||
dust_poof.visible = false;
|
||||
|
||||
loadGraphic(moving_platform_sprite, true, false, 16, 16);
|
||||
|
||||
if (facing == RIGHT || facing == LEFT) {
|
||||
if (is_active) {
|
||||
frame = 1;
|
||||
} else {
|
||||
frame = 0;
|
||||
}
|
||||
} else {
|
||||
if (is_active) {
|
||||
frame = 5;
|
||||
} else {
|
||||
frame = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Registry.subgroup_propelled.push(this);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
/* Draw beneath dust */
|
||||
if (!pushed_to_front) {
|
||||
//noooo
|
||||
pushed_to_front = true;
|
||||
parent.bg_sprites.add(active_region);
|
||||
parent.bg_sprites.move_to_front(active_region);
|
||||
parent.bg_sprites.move_to_front(this);
|
||||
parent.bg_sprites.add(dust_poof);
|
||||
init_pt.x = x;
|
||||
init_pt.y = y;
|
||||
}
|
||||
|
||||
if (state == s_done) {
|
||||
if (active_region.overlaps(player) && !player.hasFallen && player.state != player.S_AIR) {
|
||||
player.falling_disabled = true;
|
||||
}
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pin active region to moving platform */
|
||||
active_region.x = x + 3;
|
||||
active_region.y = y + 3;
|
||||
if (active_region.overlaps(player) && !player.hasFallen && player.state != player.S_AIR) {
|
||||
player.falling_disabled = true;
|
||||
set_frame(true);
|
||||
if (is_propelling) {
|
||||
set_velocity();
|
||||
}
|
||||
|
||||
if (player.just_landed) {
|
||||
if (is_active) {
|
||||
is_propelling = true; //start moving
|
||||
if (!showed_dust_poof) {
|
||||
Dust.dust_sound.play();
|
||||
dust_poof.play("poof");
|
||||
showed_dust_poof = true;
|
||||
dust_poof.visible = true;
|
||||
switch (facing) {
|
||||
case LEFT:
|
||||
dust_poof.x = x + width;
|
||||
dust_poof.y = y;
|
||||
break;
|
||||
case RIGHT:
|
||||
dust_poof.x = x - dust_poof.width;
|
||||
dust_poof.y = y;
|
||||
break;
|
||||
case UP:
|
||||
dust_poof.x = x;
|
||||
dust_poof.y = y + height;
|
||||
break;
|
||||
case DOWN:
|
||||
dust_poof.x = x;
|
||||
dust_poof.y = y - dust_poof.height;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//HI
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set_frame(false);
|
||||
}
|
||||
|
||||
// On the return trip, if the platform is close,
|
||||
// then stop it and return it tot he initial state
|
||||
if (!is_first_movement) {
|
||||
if (EventScripts.distance(this, init_pt) < 3) {
|
||||
x = init_pt.x;
|
||||
y = init_pt.y;
|
||||
reset_moving_props();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function turn_on():void {
|
||||
if (!is_active) {
|
||||
// dont make a noise with the already-activated platforms
|
||||
// when entering map
|
||||
if (parent == null) {
|
||||
trace(Registry.GAMESTATE.sortables.members.indexOf(this));
|
||||
trace(Registry.GAMESTATE.members.indexOf(this));
|
||||
trace(Registry.GAMESTATE.bg_sprites.members.indexOf(this));
|
||||
exists = false;
|
||||
}
|
||||
if (parent.state != parent.S_TRANSITION) {
|
||||
Registry.sound_data.dash_pad_2.play();
|
||||
}
|
||||
if (frame == H_UP_OFF) {
|
||||
frame = H_UP_ON;
|
||||
} else if (frame == V_UP_OFF) {
|
||||
frame = V_UP_ON;
|
||||
} else if (frame == H_DOWN_OFF) {
|
||||
frame = H_DOWN_ON;
|
||||
|
||||
} else if (frame == V_DOWN_OFF) {
|
||||
frame = V_DOWN_ON;
|
||||
}
|
||||
is_active = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function set_frame(stepped_on:Boolean):void {
|
||||
if (stepped_on) {
|
||||
if (frame == H_UP_OFF) {
|
||||
Registry.sound_data.button_down.play();
|
||||
frame = H_DOWN_OFF;
|
||||
} else if (frame == H_UP_ON) {
|
||||
Registry.sound_data.button_down.play();
|
||||
frame = H_DOWN_ON;
|
||||
} else if (frame == V_UP_OFF) {
|
||||
Registry.sound_data.button_down.play();
|
||||
frame = V_DOWN_OFF;
|
||||
} else if (frame == V_UP_ON) {
|
||||
Registry.sound_data.button_down.play();
|
||||
frame = V_DOWN_ON;
|
||||
}
|
||||
} else {
|
||||
if (frame == H_DOWN_OFF) {
|
||||
Registry.sound_data.button_up.play();
|
||||
frame = H_UP_OFF;
|
||||
} else if (frame == H_DOWN_ON) {
|
||||
Registry.sound_data.button_up.play();
|
||||
frame = H_UP_ON;
|
||||
} else if (frame == V_DOWN_OFF) {
|
||||
Registry.sound_data.button_up.play();
|
||||
frame = V_UP_OFF;
|
||||
} else if (frame == V_DOWN_ON) {
|
||||
Registry.sound_data.button_up.play();
|
||||
frame = V_UP_ON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// changes facing (to tell platform where to move next), dust state,
|
||||
// etc
|
||||
private function reset_moving_props():void
|
||||
{
|
||||
is_propelling = false;
|
||||
is_active = false;
|
||||
if (facing == UP) {
|
||||
facing = DOWN;
|
||||
} else if (facing == DOWN) {
|
||||
facing = UP;
|
||||
} else if (facing == LEFT) {
|
||||
facing = RIGHT;
|
||||
} else {
|
||||
facing = LEFT;
|
||||
}
|
||||
if (frame == H_UP_ON || frame == H_DOWN_ON || frame == H_DOWN_OFF || frame == H_UP_OFF) {
|
||||
frame = H_UP_OFF;
|
||||
} else {
|
||||
frame = V_UP_OFF;
|
||||
}
|
||||
showed_dust_poof = false;
|
||||
dust_poof.visible = false;
|
||||
velocity.x = velocity.y = 0;
|
||||
is_first_movement = !is_first_movement;
|
||||
}
|
||||
|
||||
public function set_velocity():void {
|
||||
switch (facing) {
|
||||
case UP: player.additional_y_vel = velocity.y = -Propel_Speed; break;
|
||||
case DOWN: player.additional_y_vel = velocity.y = Propel_Speed; break;
|
||||
case RIGHT: player.additional_x_vel = velocity.x = Propel_Speed; break;
|
||||
case LEFT: player.additional_x_vel = velocity.x = -Propel_Speed; break;
|
||||
}
|
||||
}
|
||||
|
||||
public function propel_from_dust_poof():void {
|
||||
is_propelling = true;
|
||||
}
|
||||
|
||||
//Called by stop markers when they overlap this moving platform.
|
||||
public function stop_from_stop_marker(stop_marker:Stop_Marker):void {
|
||||
if (is_first_movement) {
|
||||
x = stop_marker.x;
|
||||
y = stop_marker.y;
|
||||
reset_moving_props();
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
dust_poof = null;
|
||||
init_pt = null;
|
||||
parent.bg_sprites.remove(this, true);
|
||||
parent.bg_sprites.remove(active_region, true);
|
||||
parent.bg_sprites.remove(dust_poof, true);
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxG;
|
||||
import global.Registry;
|
||||
/**
|
||||
* Single push blocks...push em from one direction, they move a tile. yeah WHAT
|
||||
* @author seagaia
|
||||
*/
|
||||
public class SinglePushBlock extends FlxSprite
|
||||
{
|
||||
private var dir:int;
|
||||
private var hasBeenPushed:Boolean = false;
|
||||
private var sound_played:Boolean = false;
|
||||
private var distanceToGo:int = Registry.TILE_HEIGHT;
|
||||
private var startedMoving:Boolean = false;
|
||||
public var type:String = "SinglePushBlock";
|
||||
public var xml:XML;
|
||||
public var sentinel:FlxSprite = new FlxSprite(0, 0);
|
||||
public var timeToPush:Number = 0.3;
|
||||
public var initial_coords:Point = new Point();
|
||||
public var MOVE_VEL:int = 24;
|
||||
public var INCREMENTED_REG:Boolean = false;
|
||||
public var BEDROOM_INDEX:int = 4;
|
||||
public var STREET_INDEX:int = 5;
|
||||
public var cid:int = CLASS_ID.SINGLEPUSHBLOCK;
|
||||
|
||||
private var is_non_puzzle:Boolean = false;
|
||||
[Embed (source = "../../res/sprites/gadgets/pushyblocks.png")] public var C_PUSH_BLOCKS:Class;
|
||||
|
||||
public var player:Player;
|
||||
//frame mod 4 determines direction
|
||||
|
||||
public function SinglePushBlock(_x:int, _y:int, _xml:XML, _p:Player)
|
||||
{
|
||||
super(_x, _y);
|
||||
initial_coords.x = x;
|
||||
initial_coords.y = y;
|
||||
xml = _xml;
|
||||
switch (parseInt(xml.@frame) % 4) {
|
||||
case 0: dir = FlxObject.UP; break;
|
||||
case 1: dir = FlxObject.DOWN; break;
|
||||
case 2: dir = FlxObject.LEFT; break;
|
||||
case 3: dir = FlxObject.RIGHT; break;
|
||||
}
|
||||
|
||||
loadGraphic(C_PUSH_BLOCKS,true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "BEDROOM") {
|
||||
trace("SET PUSH BLOCK FRAME: ", BEDROOM_INDEX);
|
||||
frame = BEDROOM_INDEX;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "STREET") {
|
||||
frame = STREET_INDEX;
|
||||
}
|
||||
|
||||
if (parseInt(xml.@type) == 1) {
|
||||
is_non_puzzle = true;
|
||||
}
|
||||
immovable = true;
|
||||
createSentinel();
|
||||
player = _p;
|
||||
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
|
||||
|
||||
if (FlxG.collide( player, this)) {
|
||||
if (player.overlaps(sentinel)) startMoving();
|
||||
}
|
||||
|
||||
if (timeToPush < 0) {
|
||||
if (!sound_played) {
|
||||
hasBeenPushed = true;
|
||||
Registry.sound_data.push_block.play();
|
||||
sound_played = true;
|
||||
}
|
||||
switch (dir) {
|
||||
case FlxObject.UP:
|
||||
velocity.y = -MOVE_VEL;
|
||||
break;
|
||||
case FlxObject.DOWN:
|
||||
velocity.y = MOVE_VEL;
|
||||
break;
|
||||
case FlxObject.RIGHT:
|
||||
velocity.x = MOVE_VEL;
|
||||
break;
|
||||
case FlxObject.LEFT:
|
||||
velocity.x = -MOVE_VEL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.abs(x - initial_coords.x) >= 16 || Math.abs(y - initial_coords.y) >= 16) {
|
||||
if (!INCREMENTED_REG) {
|
||||
if (!is_non_puzzle) {
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
}
|
||||
INCREMENTED_REG = true;
|
||||
}
|
||||
if ((x - initial_coords.x) > 16) {
|
||||
x = initial_coords.x + 16;
|
||||
} else if ((x - initial_coords.x) < -16) {
|
||||
x = initial_coords.x - 16;
|
||||
}
|
||||
|
||||
if ((y - initial_coords.y > 16)) {
|
||||
y = initial_coords.y + 16;
|
||||
} else if ((y - initial_coords.y) < -16) {
|
||||
y = initial_coords.y - 16;
|
||||
}
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
|
||||
if (!startedMoving) timeToPush = 0.3;
|
||||
startedMoving = false;
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function startMoving():void {
|
||||
if (hasBeenPushed) return;
|
||||
timeToPush -= FlxG.elapsed;
|
||||
startedMoving = true;
|
||||
}
|
||||
|
||||
public function createSentinel():void {
|
||||
sentinel.makeGraphic(4, 2, 0xFF022000);
|
||||
sentinel.visible = false;
|
||||
switch (dir) {
|
||||
case FlxObject.DOWN:
|
||||
sentinel.x = x + Registry.TILE_WIDTH / 2 - 2;
|
||||
sentinel.y = y - 2;
|
||||
break;
|
||||
case FlxObject.UP:
|
||||
sentinel.x = x + Registry.TILE_WIDTH / 2 - 2;
|
||||
sentinel.y = y + Registry.TILE_WIDTH + 2;
|
||||
break;
|
||||
case FlxObject.LEFT:
|
||||
sentinel.x = x + Registry.TILE_WIDTH + 2;
|
||||
sentinel.y = y + Registry.TILE_WIDTH / 2;
|
||||
break;
|
||||
case FlxObject.RIGHT:
|
||||
sentinel.x = x - 2;
|
||||
sentinel.y = y + Registry.TILE_WIDTH / 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Interacts with Propelled, stops them on a dime
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Stop_Marker extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
|
||||
public var cid:int = CLASS_ID.STOP_MARKER;
|
||||
|
||||
public var parent:*;
|
||||
|
||||
public function Stop_Marker(_xml:XML,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
makeGraphic(16, 16, 0x69386243);
|
||||
visible = false;
|
||||
parent = _parent;
|
||||
immovable = true;
|
||||
solid = false;
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
for each (var propelled:Propelled in Registry.subgroup_propelled) {
|
||||
if (propelled.is_propelling && Math.abs(x - propelled.x) <= 2 && Math.abs(y - propelled.y) <= 2) {
|
||||
propelled.stop_from_stop_marker(this);
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.media.Video;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Switch_Pillar extends FlxSprite
|
||||
{
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var up_frame:int;
|
||||
public var down_frame:int;
|
||||
|
||||
private var original_state:Boolean = false;
|
||||
|
||||
[Embed(source = "../../res/sprites/dame/dame-switch-pillar.png")] public var switch_pillar_sprite:Class;
|
||||
|
||||
public function Switch_Pillar(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
loadGraphic(switch_pillar_sprite, true, false, 16, 16);
|
||||
|
||||
var dame_frame:int = parseInt(xml.@frame);
|
||||
if (dame_frame < 2) {
|
||||
up_frame = 0;
|
||||
down_frame = 1;
|
||||
}
|
||||
|
||||
if (dame_frame % 2) {
|
||||
if (Registry.pillar_switch_state) {
|
||||
frame = down_frame;
|
||||
} else {
|
||||
frame = up_frame;
|
||||
}
|
||||
} else {
|
||||
if (!Registry.pillar_switch_state) {
|
||||
frame = down_frame;
|
||||
} else {
|
||||
frame = up_frame;
|
||||
}
|
||||
}
|
||||
addAnimation("dissolve", [0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1], 15,false);
|
||||
|
||||
addAnimation("solidify", [1,14,13,12,11,10,9,8,7,6,5,4,0], 15,false);
|
||||
original_state = Registry.pillar_switch_state;
|
||||
Registry.subgroup_switch_pillars.push(this);
|
||||
immovable = true;
|
||||
}
|
||||
|
||||
override public function update():void {
|
||||
if (frame == up_frame) {
|
||||
FlxG.collide(this, player);
|
||||
}
|
||||
|
||||
if (original_state != Registry.pillar_switch_state) {
|
||||
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
if (frame == up_frame) {
|
||||
Registry.sound_data.dash_pad_1.play();
|
||||
play("dissolve");
|
||||
} else {
|
||||
Registry.sound_data.dash_pad_2.play();
|
||||
play("solidify");
|
||||
}
|
||||
original_state = Registry.pillar_switch_state;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,398 @@
|
|||
package entity.gadget
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Broom;
|
||||
import entity.player.HealthBar;
|
||||
import entity.player.Player;
|
||||
import global.Keys;
|
||||
import helper.Achievements;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import global.Registry;
|
||||
import data.SoundData;
|
||||
import states.PauseState;
|
||||
/**
|
||||
* @author Seagaia
|
||||
*/
|
||||
|
||||
public class Treasure extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../res/sprites/gadgets/treasureboxes.png")] public static var S_TREASURE_SPRITE:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/item_jump_shoes.png")] public static var embed_jump_shoes:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/item_long_attack.png")] public static var embed_long_attack:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/item_wide_attack.png")] public static var embed_wide_attack:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/item_tranformer.png")] public static var embed_transformer:Class;
|
||||
[Embed(source = "../../res/sprites/menu/secret_trophies.png")] public static const embed_secret_trophies:Class;
|
||||
public var CLOSED_BEDROOM:int = 0;
|
||||
public var OPEN_BEDROOM:int = 1;
|
||||
public var CLOSED_STREET:int = 0;
|
||||
public var OPEN_STREET:int = 1;
|
||||
|
||||
|
||||
public var xml:XML;
|
||||
public var parent:*;
|
||||
public var CONTENT:int;
|
||||
public var item:FlxSprite;
|
||||
public var item_flicker_timer:Number = 1;
|
||||
public var item_flickered:Boolean = false;
|
||||
|
||||
public var cid:int = CLASS_ID.TREASURE;
|
||||
public var active_region:FlxSprite = new FlxSprite;
|
||||
/* These reference the frame of the DAME object, and let the PlayState know what item to grant
|
||||
* to the player. */
|
||||
public static const IDX_BROOM:int = 0;
|
||||
public static const IDX_KEY:int = 1;
|
||||
public static const IDX_GROWTH:int = 2;
|
||||
private var start_growth_anim:Boolean = false;
|
||||
private var ctr:int = 0;
|
||||
private var t:Number = 0;
|
||||
|
||||
|
||||
public static const IDX_JUMP:int = 3;
|
||||
public static const IDX_WIDE:int = 4;
|
||||
public static const IDX_LONG:int = 5;
|
||||
public static const IDX_SWAP:int = 6;
|
||||
|
||||
public static const IDX_goldenpoo:int = 7;
|
||||
public static const IDX_can_of_spam:int = 8;
|
||||
public static const IDX_missingno:int = 9;
|
||||
public static const IDX_aus_heart:int = 10;
|
||||
public static const IDX_electric:int = 11;
|
||||
public static const IDX_kittystatue:int = 12;
|
||||
public static const IDX_melos:int = 13;
|
||||
public static const IDX_marina:int = 14;
|
||||
public static const IDX_black:int = 15;
|
||||
public static const IDX_red:int = 16;
|
||||
public static const IDX_green:int = 17;
|
||||
public static const IDX_blue:int = 18;
|
||||
public static const IDX_white:int = 19;
|
||||
|
||||
public static const IDX_SECRETS_MAX:int = 40;
|
||||
|
||||
public static const IDX_NOTHING:int = 100;
|
||||
|
||||
public function Treasure(_x:int, _y:int, _xml:XML, _parent:* )
|
||||
{
|
||||
super(_x, _y);
|
||||
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
immovable = true;
|
||||
loadGraphic(S_TREASURE_SPRITE, true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "BEDROOM") {
|
||||
frame = CLOSED_BEDROOM;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "STREET") {
|
||||
frame = CLOSED_STREET;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
frame = 4;
|
||||
}
|
||||
CONTENT = xml.@frame;
|
||||
item = new FlxSprite(x, y);
|
||||
if (CONTENT >= IDX_goldenpoo && CONTENT <= IDX_SECRETS_MAX) {
|
||||
item.loadGraphic(embed_secret_trophies, true, false, 16, 16);
|
||||
}
|
||||
switch (CONTENT) {
|
||||
case IDX_BROOM:
|
||||
item.loadGraphic(Broom.Icon_Broom_Sprite, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_KEY:
|
||||
item.loadGraphic(Key.C_KEY_SPRITE, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_GROWTH:
|
||||
item.loadGraphic(PauseState.card_sheet_embed, false, false, 24, 24);
|
||||
item.frame = get_card_frame();
|
||||
item.scale.x = 0.5;
|
||||
item.scale.y = 0.5;
|
||||
item.x -= 4;
|
||||
if (xml != null && xml.@alive == "false") {
|
||||
Registry.card_states[item.frame] = 1;
|
||||
}
|
||||
// oops
|
||||
if (xml.@alive == "false" && item.frame != uint.MAX_VALUE) {
|
||||
if (Registry.card_states[item.frame] == 0) {
|
||||
Registry.nr_growths++;
|
||||
Registry.card_states[item.frame] = 1;
|
||||
}
|
||||
}
|
||||
if (item.frame == uint.MAX_VALUE) {
|
||||
item.makeGraphic(16, 16, 0xffff0000);
|
||||
}
|
||||
trace("Loading card with frame ", item.frame);
|
||||
|
||||
if (item.frame == Registry.CARD_GOLDMAN_IDX && Registry.GE_States[Registry.GE_tradequesthelpedshopkeeper] && Registry.card_states[Registry.CARD_GOLDMAN_IDX]) {
|
||||
CONTENT = IDX_NOTHING;
|
||||
}
|
||||
break;
|
||||
case IDX_LONG:
|
||||
item.loadGraphic(embed_long_attack, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_WIDE:
|
||||
item.loadGraphic(embed_wide_attack, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_JUMP:
|
||||
item.loadGraphic(embed_jump_shoes, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_SWAP:
|
||||
item.loadGraphic(embed_transformer, false, false, 16, 16);
|
||||
break;
|
||||
case IDX_goldenpoo:
|
||||
item.frame = 0; break;
|
||||
case IDX_can_of_spam:
|
||||
item.frame = 1; break;
|
||||
case IDX_missingno:
|
||||
item.frame = 2; break;
|
||||
case IDX_kittystatue:
|
||||
item.frame = 5; break;
|
||||
case IDX_aus_heart:
|
||||
item.frame = 3; break;
|
||||
case IDX_electric:
|
||||
item.frame = 4; break;
|
||||
case IDX_melos:
|
||||
item.frame = 6; break;
|
||||
case IDX_marina:
|
||||
item.frame = 7; break;
|
||||
case IDX_black:
|
||||
item.frame = 8; break;
|
||||
case IDX_red:
|
||||
item.frame = 9; break;
|
||||
case IDX_green:
|
||||
item.frame = 10; break;
|
||||
case IDX_blue:
|
||||
item.frame = 11; break;
|
||||
case IDX_white:
|
||||
item.frame = 12; break;
|
||||
default:
|
||||
item.makeGraphic(16, 16, 0xff00ff00);
|
||||
break;
|
||||
}
|
||||
item.visible = false;
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
frame++;
|
||||
}
|
||||
|
||||
active_region.makeGraphic(10, 3, 0x00000000);
|
||||
active_region.x = x + 3;
|
||||
active_region.y = y + 16;
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
private function get_card_frame():int {
|
||||
var _x:int;
|
||||
var _y:int;
|
||||
if (Registry.is_playstate) {
|
||||
_x = Registry.CURRENT_GRID_X;
|
||||
_y = Registry.CURRENT_GRID_Y;
|
||||
} else {
|
||||
_x = parseInt(xml.@x);
|
||||
_y = parseInt(xml.@y);
|
||||
}
|
||||
|
||||
var a:Array = PauseState.card_data[Registry.CURRENT_MAP_NAME];
|
||||
for each (var o:Object in a) {
|
||||
if (_x == o.x && _y == o.y) {
|
||||
return o.id;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private var dont_do_shit:Boolean = false;
|
||||
override public function update():void {
|
||||
if (item.visible) {
|
||||
if (CONTENT == IDX_GROWTH && !start_growth_anim) {
|
||||
if (item.frame != uint.MAX_VALUE) {
|
||||
if (Registry.CURRENT_MAP_NAME == "NEXUS") {
|
||||
Registry.card_states[48] = 1;
|
||||
Achievements.unlock(Achievements.A_GET_49TH_CARD);
|
||||
} else {
|
||||
Registry.card_states[item.frame] = 1;
|
||||
}
|
||||
parent.player.state = parent.player.S_GROUND;
|
||||
}
|
||||
|
||||
|
||||
start_growth_anim = true;
|
||||
|
||||
} else if (CONTENT == IDX_NOTHING) {
|
||||
item.visible = false;
|
||||
Registry.GAMESTATE.player.be_idle();
|
||||
//DH.dialogue_popup("Goldman: What? It's not there? That shopkeeper must have stolen it!");
|
||||
DH.dialogue_popup_misc_any("treasure", 10);
|
||||
|
||||
} else if (CONTENT != IDX_GROWTH) {
|
||||
EventScripts.send_property_to(item, "y", y - 16, 0.5)
|
||||
|
||||
if (!item_flickered) {
|
||||
parent.player.state = parent.player.S_GROUND;
|
||||
item_flickered = true;
|
||||
item.flicker(item_flicker_timer);
|
||||
}
|
||||
if (!item.flickering) item.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FlxG.collide(parent.player, this);
|
||||
if (frontTouches(parent.player) && Registry.keywatch.JP_ACTION_1 && xml.@alive == "true") {
|
||||
if (Registry.CURRENT_MAP_NAME == "WINDMILL" && Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening] == 0) {
|
||||
dont_do_shit = true;
|
||||
//DH.dialogue_popup("Some strange force stops this treasure box from being opened.");
|
||||
DH.dialogue_popup(DH.lk("treasure",0));
|
||||
}
|
||||
if (dont_do_shit) return;
|
||||
parent.player.update_player_inventory(this);
|
||||
item.visible = true;
|
||||
parent.player.state = parent.player.S_INTERACT;
|
||||
Registry.sound_data.get_treasure.play();
|
||||
Achievements.is_200_percent();
|
||||
if (CONTENT == IDX_BROOM) {
|
||||
Registry.bound_item_1 = "BROOM";
|
||||
//DH.dialogue_popup("An engraving on the broom handle reads: \"Press " + Registry.controls[Keys.IDX_ACTION_1] + " to sweep.\"");
|
||||
DH.dialogue_popup(DH.lk("treasure", 1) + " " + Registry.controls[Keys.IDX_ACTION_1] + " " + DH.lk("treasure", 2));
|
||||
|
||||
} else if (CONTENT == IDX_KEY && Registry.CURRENT_MAP_NAME == "STREET") {
|
||||
//DH.dialogue_popup("This key may be used a single time to open up a locked barrier.");
|
||||
DH.dialogue_popup_misc_any("treasure", 3);
|
||||
} else if (CONTENT == IDX_JUMP) {
|
||||
Registry.bound_item_2 = "JUMP";
|
||||
//DH.dialogue_popup("A mysterious pair of boots has nothing but the branding on it, which says \"Press " + Registry.controls[Keys.IDX_ACTION_2]+"\".");
|
||||
DH.dialogue_popup(DH.lk("treasure", 4) + " " + Registry.controls[Keys.IDX_ACTION_2] + " " + DH.lk("treasure", 5));
|
||||
} else if (CONTENT == IDX_WIDE) {
|
||||
//DH.dialogue_popup("A few words on the broom extension read \"Equip the WIDEN upgrade in the menu to have the broom release harmful dust to the left and right.\"");
|
||||
DH.dialogue_popup_misc_any("treasure", 6);
|
||||
} else if (CONTENT == IDX_LONG) {
|
||||
//DH.dialogue_popup("A few words on the broom extension read \"Equip the EXTEND upgrade in the menu for the broom to release harmful dust in front of the broom's normal reach.\"");
|
||||
DH.dialogue_popup_misc_any("treasure", 7);
|
||||
} else if (CONTENT == IDX_SWAP) {
|
||||
//DH.dialogue_popup("A note next to the broom extension: \"Hello, Young. Use this SWAP upgrade on two tiles to switch their places. It may be a while before you can use this everywhere, but it should serve you well for the time being.\"");
|
||||
DH.dialogue_popup_misc_any("treasure", 8);
|
||||
} else if (CONTENT == IDX_goldenpoo) {
|
||||
Registry.inventory[Registry.IDX_POO] = true;
|
||||
Achievements.unlock(Achievements.A_GET_GOLDEN_POO);
|
||||
} else if (CONTENT == IDX_can_of_spam) {
|
||||
Achievements.unlock(Achievements.Trophy_1);
|
||||
Registry.inventory[Registry.IDX_SPAM] = true;
|
||||
} else if (CONTENT == IDX_electric) {
|
||||
Achievements.unlock(Achievements.Trophy_1);
|
||||
Registry.inventory[Registry.IDX_ELECTRIC] = true;
|
||||
} else if (CONTENT == IDX_missingno) {
|
||||
Achievements.unlock(Achievements.Trophy_1);
|
||||
Registry.inventory[Registry.IDX_MISSINGNO] = true;
|
||||
} else if (CONTENT == IDX_aus_heart) {
|
||||
DH.dialogue_popup_misc_any("treasure", 9);
|
||||
//DH.dialogue_popup("YOU FOUND A HEART!!! Maximum Health increased by...zero.");
|
||||
Registry.inventory[Registry.IDX_AUS_HEART] = true;
|
||||
} else if (CONTENT == IDX_kittystatue) {
|
||||
Registry.inventory[Registry.IDX_KITTY] = true;
|
||||
} else if (CONTENT == IDX_marina) {
|
||||
Registry.inventory[Registry.IDX_MARINA] = true;
|
||||
} else if (CONTENT == IDX_melos) {
|
||||
Registry.inventory[Registry.IDX_MELOS] = true;
|
||||
}else if (CONTENT == IDX_black) {
|
||||
Registry.inventory[Registry.IDX_BLACK] = true;
|
||||
if (Registry.inventory[Registry.IDX_WHITE]) {
|
||||
Achievements.unlock(Achievements.A_GET_BW_CUBES);
|
||||
}
|
||||
}else if (CONTENT == IDX_red) {
|
||||
Registry.inventory[Registry.IDX_RED] = true;
|
||||
Achievements.unlock(Achievements.A_GET_RED_CUBE);
|
||||
}else if (CONTENT == IDX_green) {
|
||||
Registry.inventory[Registry.IDX_GREEN] = true;
|
||||
Achievements.unlock(Achievements.A_GET_GREEN_CUBE);
|
||||
}else if (CONTENT == IDX_blue) {
|
||||
Registry.inventory[Registry.IDX_BLUE] = true;
|
||||
Achievements.unlock(Achievements.A_GET_BLUE_CUBE);
|
||||
}else if (CONTENT == IDX_white) {
|
||||
Registry.inventory[Registry.IDX_WHITE] = true;
|
||||
if (Registry.inventory[Registry.IDX_BLACK]) {
|
||||
Achievements.unlock(Achievements.A_GET_BW_CUBES);
|
||||
}
|
||||
}
|
||||
|
||||
if (CONTENT >= IDX_goldenpoo && CONTENT < IDX_SECRETS_MAX) {
|
||||
Registry.GE_States[Registry.GE_HAVE_A_SECRET] = true;
|
||||
}
|
||||
xml.@alive = "false";
|
||||
frame++;
|
||||
}
|
||||
|
||||
if (start_growth_anim) {
|
||||
growth_anim();
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
private function growth_anim():void {
|
||||
switch (ctr) {
|
||||
case 0:
|
||||
|
||||
ctr++;
|
||||
break;
|
||||
case 1:
|
||||
item.scale.x += (0.5 * FlxG.elapsed);
|
||||
item.scale.y += (0.5 * FlxG.elapsed);
|
||||
if (item.y > Registry.CURRENT_GRID_Y * 160 + 20 + 80) {
|
||||
item.y -= (24 * FlxG.elapsed);
|
||||
} else {
|
||||
item.y += (24 * FlxG.elapsed);
|
||||
}
|
||||
if (item.scale.x >= 1) {
|
||||
item.scale.x = item.scale.y = 1;
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
t += FlxG.elapsed;
|
||||
if (t > 1) {
|
||||
t = 0;
|
||||
ctr++;
|
||||
if (item.y > Registry.CURRENT_GRID_Y * 160 + 20 + 80) {
|
||||
item.acceleration.y = -80;
|
||||
item.angularVelocity = 50;
|
||||
item.angularAcceleration = 200;
|
||||
} else {
|
||||
item.acceleration.y = 80;
|
||||
item.angularVelocity = -50;
|
||||
item.angularAcceleration = -200;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
item.scale.x += FlxG.elapsed*3;
|
||||
item.scale.y += FlxG.elapsed*3;
|
||||
item.alpha -= FlxG.elapsed / 2;
|
||||
if (item.alpha <= 0) {
|
||||
item.visible = false;
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function frontTouches(o:FlxSprite):Boolean {
|
||||
return (o.x >= (x - Registry.TILE_WIDTH / 2) && o.x <= (x + Registry.TILE_WIDTH / 2) &&
|
||||
o.y <= (y + Registry.TILE_WIDTH + 2) && o.y >= (y + Registry.TILE_WIDTH - 3));
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
super.destroy();
|
||||
if (active_region != null) active_region.destroy();
|
||||
active_region = null;
|
||||
item = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import entity.enemy.bedroom.Sun_Guy;
|
||||
import entity.interactive.npc.Forest_NPC;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxU;
|
||||
import org.flixel.plugin.photonstorm.FlxMath;
|
||||
|
||||
|
||||
/**
|
||||
* uses multiple draw calls to make a black square with other
|
||||
* black squares that do silly things via sin/linear interpolation
|
||||
*
|
||||
* FUN CLASS PROJECT make a class thing to hold timer/state/etc states and
|
||||
* do this all with wrapper functions
|
||||
*/
|
||||
|
||||
|
||||
public class Black_Thing extends AnoSprite
|
||||
{
|
||||
|
||||
private var is_green:Boolean = false;
|
||||
|
||||
public function Black_Thing(a:Array)
|
||||
{
|
||||
super(a);
|
||||
|
||||
make_sin_table_180();
|
||||
makeGraphic(32, 32, 0xff000000);
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "FOREST") {
|
||||
is_green = true;
|
||||
loadGraphic(Forest_NPC.embed_forest_npcs, true, false, 16, 16);
|
||||
addAnimation("walk", [32, 33], 4);
|
||||
play("walk");
|
||||
x = tl.x ;
|
||||
}
|
||||
}
|
||||
|
||||
private var dumct:int = 0;
|
||||
private var t_yell:Number = 0;
|
||||
private var t_lol:Number = 0;
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (is_green) {
|
||||
if (x > tl.x + 80 && x < tl.x + 160 ) {
|
||||
Registry.GRID_PUZZLES_DONE = 1;
|
||||
} else if (x > tl.x + 160) {
|
||||
Registry.GRID_PUZZLES_DONE = 2;
|
||||
}
|
||||
|
||||
t_yell += FlxG.elapsed;
|
||||
if (t_yell > 0.5) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.rat_move);
|
||||
t_yell = 0;
|
||||
}
|
||||
|
||||
t_lol += FlxG.elapsed;
|
||||
if (x < tl.x + 80) {
|
||||
if (t_lol > 1) {
|
||||
x += 1;
|
||||
t_lol = 0;
|
||||
}
|
||||
} else { // ~100 minutes
|
||||
if (t_lol > 80) {
|
||||
t_lol = 0;
|
||||
x += 1;
|
||||
}
|
||||
}
|
||||
//if (FlxG.keys.J) {
|
||||
//t_lol = 90;
|
||||
//}
|
||||
if (player.velocity.x != 0 || player.velocity.y != 0) {
|
||||
x -= 1;
|
||||
}
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.overlaps(this) && Registry.keywatch.JP_ACTION_2) {
|
||||
Registry.sound_data.fall_in_hole.play();
|
||||
dumct++;
|
||||
if (dumct > 50) {
|
||||
mm1.y = 10;
|
||||
mm2.y = 12;
|
||||
mm3.y = 9;
|
||||
Registry.GRID_PUZZLES_DONE++;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
||||
private var scale1:Number = 0.5;
|
||||
private var mm1:Point = new Point(0.5, 2);
|
||||
|
||||
private var scale2:Number = 2;
|
||||
private var mm2:Point = new Point(0.5, 2);
|
||||
|
||||
private var scale3:Number = 3;
|
||||
private var mm3:Point = new Point(0.75, 3);
|
||||
|
||||
|
||||
|
||||
private var state1:int = 0;
|
||||
private var state2:int = 0;
|
||||
private var state3:int = 0;
|
||||
|
||||
private var t3:Number = 0;
|
||||
private var t3_m:Number = 1;
|
||||
|
||||
// vals between 0 and 1
|
||||
private var sin_table_180:Array;
|
||||
|
||||
public function make_sin_table_180():void {
|
||||
sin_table_180 = new Array;
|
||||
for (var i:int = 0; i < 180; i++) {
|
||||
sin_table_180.push((1 + Math.sin( (i / 180.0) * 6.28))/2);
|
||||
}
|
||||
}
|
||||
|
||||
private var rate:Number = 0.03;
|
||||
override public function draw():void
|
||||
{
|
||||
if (is_green) {
|
||||
super.draw();
|
||||
return;
|
||||
}
|
||||
alpha = 0.25;
|
||||
color = 0xff0000;
|
||||
|
||||
scale.x = scale.y = scale1;
|
||||
|
||||
|
||||
|
||||
if (state1 == 0) {
|
||||
scale1 += rate;
|
||||
if (scale1 > mm1.y) {
|
||||
state1 = 1;
|
||||
}
|
||||
} else if (state1 == 1) {
|
||||
scale1 -= rate;
|
||||
if (scale1 < mm1.x) {
|
||||
state1 = 0;
|
||||
}
|
||||
}
|
||||
super.draw();
|
||||
|
||||
|
||||
|
||||
alpha = 0.5;
|
||||
color = 0x00ff00;
|
||||
scale.x = scale.y = scale2;
|
||||
|
||||
|
||||
if (state2 == 0) {
|
||||
scale2 += rate;
|
||||
if (scale2 > mm2.y) {
|
||||
state2 = 1;
|
||||
}
|
||||
} else if (state2 == 1) {
|
||||
scale2 -= rate;
|
||||
if (scale2 < mm2.x) {
|
||||
state2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.draw();
|
||||
|
||||
alpha = 0.7;
|
||||
color = 0x0000ff;
|
||||
scale.x = scale.y = scale3;
|
||||
t3 += FlxG.elapsed;
|
||||
if (t3 > t3_m) {
|
||||
t3 = 0;
|
||||
}
|
||||
|
||||
scale3 = sin_table_180[int(180 * (t3 / t3_m))] * (mm3.y - mm3.x) + mm3.x;
|
||||
|
||||
angle = get_sin_table_180(t3, t3_m, -90, 90);
|
||||
super.draw();
|
||||
|
||||
color = 0x000000;
|
||||
angle = 0;
|
||||
scale.x = scale.y = 1;
|
||||
alpha = 0.3;
|
||||
super.draw();
|
||||
}
|
||||
|
||||
public function get_sin_table_180(t:Number,tm:Number,min:Number,max:Number):Number {
|
||||
return sin_table_180[int(180 * (t3 / t3_m))] * (max - min) + min;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Statues that block the ways out of the first 3 dungeons.
|
||||
* If key not picked up, also spawns a key that does a little flashy nimation
|
||||
*/
|
||||
public class Dungeon_Statue extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed (source = "../../res/sprites/npcs/big_statue.png")] public static var statue_bedroom_embed:Class;
|
||||
|
||||
public var xml:XML;
|
||||
public var parent:*;
|
||||
public var player:Player;
|
||||
public var active_region:FlxObject;
|
||||
public function Dungeon_Statue(_p:Player,_pa:*,_xml:XML)
|
||||
{
|
||||
xml = _xml;
|
||||
parent = _pa;
|
||||
player = _p;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
immovable = true;
|
||||
active_region = new FlxObject(x, y, 34, 20);
|
||||
switch (Registry.CURRENT_MAP_NAME) {
|
||||
case "BEDROOM":
|
||||
loadGraphic(statue_bedroom_embed, false, false, 32, 48);
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]) {
|
||||
y -= 32;
|
||||
}
|
||||
break;
|
||||
case "REDCAVE":
|
||||
loadGraphic(statue_bedroom_embed, false, false, 32, 48);
|
||||
frame = 1;
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]) {
|
||||
x += 32;
|
||||
}
|
||||
break;
|
||||
|
||||
case "CROWD":
|
||||
loadGraphic(statue_bedroom_embed, false, false, 32, 48);
|
||||
frame = 2;
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]) {
|
||||
x += 32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
width = 30;
|
||||
height = 16;
|
||||
offset.x = 1;
|
||||
x += 1;
|
||||
offset.y = 32;
|
||||
y += 32;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
if (player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening] == 1) {
|
||||
DH.start_dialogue(DH.name_dungeon_statue, DH.scene_dungeon_statue_bedroom_two);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_dungeon_statue, DH.scene_dungeon_statue_bedroom_one);
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.plugin.photonstorm.FlxBitmapFont;
|
||||
import states.ControlsState;
|
||||
import states.PauseState;
|
||||
|
||||
/**
|
||||
* logic for the elevator in hotel.
|
||||
*/
|
||||
public class Elevator extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
private var locations:Array = new Array(new Point(1344, 1360), new Point(1344, 560), new Point(384, 1840), new Point(384, 880));
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_closed:int = 0;
|
||||
private var s_player_leaving:int = 1;
|
||||
private var s_open:int = 2;
|
||||
private var s_menu:int = 3;
|
||||
private var s_leaving:int = 4;
|
||||
|
||||
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
|
||||
private var open_sensor:FlxSprite;
|
||||
private var menu_sensor:FlxSprite;
|
||||
|
||||
private var OPEN_FRAME:int = 3;
|
||||
private var CLOSED_FRAME:int = 0;
|
||||
|
||||
public var text:FlxBitmapFont;
|
||||
public var menu:FlxSprite;
|
||||
public var selector:FlxSprite;
|
||||
public var selector_idx:int = 0;
|
||||
public var line_height:int = 8;
|
||||
public var min_selector_idx:int = 0;
|
||||
public var max_selector_idx:int = 4;
|
||||
public var choices:Array = new Array();
|
||||
|
||||
private var floor:int;
|
||||
|
||||
[Embed (source = "../../res/sprites/gadgets/elevator.png")] public static var Elevator_Sprite:Class;
|
||||
|
||||
|
||||
public function Elevator(_xml:XML,_player:Player,_parent:*)
|
||||
{
|
||||
xml = _xml;
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
/* Elevator anims */
|
||||
loadGraphic(Elevator_Sprite, true, false, 32, 32);
|
||||
addAnimation("open", [0, 1, 2, 3], 12, false);
|
||||
addAnimation("close", [3, 2, 1, 0], 12, false);
|
||||
|
||||
frame = CLOSED_FRAME;
|
||||
state = s_closed;
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (!did_init) { // o god
|
||||
did_init = true;
|
||||
|
||||
open_sensor = new FlxSprite(x, y + 32);
|
||||
open_sensor.makeGraphic(32, 32, 0xff992912);
|
||||
|
||||
menu_sensor = new FlxSprite(x, y);
|
||||
menu_sensor.makeGraphic(32, 20, 0xff991144);
|
||||
|
||||
menu_sensor.visible = open_sensor.visible = false;
|
||||
|
||||
menu = new FlxSprite(15, Registry.HEADER_HEIGHT + 20);
|
||||
menu.loadGraphic(ControlsState.S_CONTROLS, false, false, 135, 125);
|
||||
|
||||
//text = EventScripts.init_bitmap_font("Floor?\n", "center", menu.x + 12, menu.y + 4, null, "apple_white");
|
||||
text = EventScripts.init_bitmap_font(DH.lk("elevator",0)+"\n", "center", menu.x + 12, menu.y + 4, null, "apple_white");
|
||||
text.drop_shadow = true;
|
||||
text.x = menu.x + 46;
|
||||
text.y = menu.y + 34;
|
||||
|
||||
|
||||
|
||||
floor = 1;
|
||||
|
||||
for each (var point:Point in locations) {
|
||||
if (x == point.x && y == (point.y + Registry.HEADER_HEIGHT)) {
|
||||
break;
|
||||
}
|
||||
floor++;
|
||||
}
|
||||
|
||||
if (floor != 1) { text.text += DH.lk("elevator",1); choices.push(1); }
|
||||
if (floor != 2) { text.text += DH.lk("elevator",2); choices.push(2); }
|
||||
if (floor != 3) { text.text += DH.lk("elevator",3); choices.push(3); }
|
||||
if (floor != 4) { text.text += DH.lk("elevator",4); choices.push(4); }
|
||||
|
||||
|
||||
text.text += DH.lk("elevator",5);
|
||||
|
||||
selector = new FlxSprite(menu.x, menu.y);
|
||||
selector.loadGraphic(PauseState.arrows_sprite, true, false, 7, 7);
|
||||
selector.addAnimation("a", [2, 3], 6, true);
|
||||
selector.play("a");
|
||||
|
||||
text.scrollFactor = selector.scrollFactor = menu.scrollFactor = new FlxPoint();
|
||||
|
||||
parent.bg_sprites.add(open_sensor);
|
||||
parent.bg_sprites.add(menu_sensor);
|
||||
parent.fg_sprites.add(menu);
|
||||
parent.fg_sprites.add(text);
|
||||
parent.fg_sprites.add(selector);
|
||||
|
||||
menu.visible = text.visible = selector.visible = false;
|
||||
|
||||
}
|
||||
|
||||
if (state == s_closed) {
|
||||
if (player.overlaps(open_sensor)) {
|
||||
play("open");
|
||||
Registry.sound_data.elevator_open.play();
|
||||
state = s_open;
|
||||
} else if (player.overlaps(menu_sensor)) {
|
||||
state = s_menu;
|
||||
menu.visible = text.visible = selector.visible = true;
|
||||
selector_idx = 1;
|
||||
selector.y = text.y + line_height;
|
||||
selector.x = text.x - line_height;
|
||||
if (DH.isZH()) {
|
||||
selector.y += 8;
|
||||
selector.x += 22;
|
||||
}
|
||||
player.frame = player.offset.y = player.velocity.x = player.velocity.y = 0;
|
||||
|
||||
player.offset.y = player.DEFAULT_Y_OFFSET;
|
||||
player.invincible_timer = 400000;
|
||||
player.invincible = true;
|
||||
}
|
||||
} else if (state == s_open) {
|
||||
if (!player.overlaps(open_sensor)) {
|
||||
play("close");
|
||||
Registry.sound_data.elevator_close.play();
|
||||
state = s_closed;
|
||||
}
|
||||
} else if (state == s_menu) {
|
||||
player.state = player.S_INTERACT;
|
||||
if (Registry.keywatch.JP_DOWN && (selector_idx < max_selector_idx)) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group);
|
||||
selector.y += line_height;
|
||||
if (DH.isZH()) selector.y += 4;
|
||||
selector_idx++;
|
||||
} else if (Registry.keywatch.JP_UP && (selector_idx > min_selector_idx + 1)) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group);
|
||||
selector.y -= line_height;
|
||||
if (DH.isZH()) selector.y -= 4;
|
||||
selector_idx--;
|
||||
} else if (Registry.keywatch.JP_ACTION_1) {
|
||||
menu.visible = text.visible = selector.visible = false;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
if (selector_idx == max_selector_idx) { //cancel
|
||||
state = s_leaving;
|
||||
player.invincible_timer = 0;
|
||||
play("open");
|
||||
player.offset.y = player.DEFAULT_Y_OFFSET;
|
||||
Registry.sound_data.elevator_open.play();
|
||||
} else { // move
|
||||
Registry.ENTRANCE_PLAYER_X = locations[choices[selector_idx -1] - 1].x + 8;
|
||||
Registry.ENTRANCE_PLAYER_Y = locations[choices[selector_idx -1] - 1].y + Registry.HEADER_HEIGHT + 30;
|
||||
parent.SWITCH_MAPS = true;
|
||||
Registry.NEXT_MAP_NAME = "HOTEL";
|
||||
player.state = player.S_GROUND;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (state == s_leaving) {
|
||||
player.state = player.S_GROUND;
|
||||
if (!player.overlaps(menu_sensor)) {
|
||||
state = s_open;
|
||||
}
|
||||
}
|
||||
|
||||
//if elevator event triggered, go to "arrived closed" state, blocking event, open doors, move player out, go to open
|
||||
|
||||
//normal:
|
||||
// stay closed until player is close enough (cloed state)
|
||||
// do open animation, either go back to close or: (open state)
|
||||
// if player steps inside, freeze the controls, close the door (state)
|
||||
// --> pop up menu with the other 3 floors and CANCEL, if chosen, do the transition, if CNACEL:
|
||||
// --> open doors, move player out and give back control (return to closed). (blocking event)
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function move_player_out():Boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// -1: exit, 0: ongoing, 1, 2, 3, 4 - floor change
|
||||
private function menu_state():int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
|
||||
super.destroy();
|
||||
text = null;
|
||||
menu = menu_sensor = selector = open_sensor = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Fisherman extends FlxSprite
|
||||
{
|
||||
|
||||
public var player:Player;
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.FISHERMAN;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_normal:int = 0;
|
||||
private var s_dying:int = 1;
|
||||
private var s_dead:int = 2;
|
||||
|
||||
public static var fisherman_dead:Boolean = false;
|
||||
public function Fisherman(_xml:XML, _player:Player)
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
loadGraphic(NPC.embed_beach_npcs, true, false, 16, 16);
|
||||
immovable = true;
|
||||
health = 2;
|
||||
player = _player;
|
||||
addAnimation("idle", [10,11], 3, true);
|
||||
addAnimation("dead", [12], 3, true);
|
||||
play("idle");
|
||||
if (xml.@alive == "false") {
|
||||
fisherman_dead = true;
|
||||
x -= 5000; //fuck it
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
FlxG.collide(player, this);
|
||||
switch (state) {
|
||||
case s_normal:
|
||||
if (!flickering && player.broom.overlaps(this) && player.broom.visible) {
|
||||
flicker(0.5);
|
||||
health--;
|
||||
}
|
||||
if (health <= 0) {
|
||||
state = s_dying;
|
||||
play("dead");
|
||||
}
|
||||
break;
|
||||
case s_dying:
|
||||
player.state = player.S_INTERACT;
|
||||
if (EventScripts.send_property_to(this, "y", parseInt(xml.@y) + 44, 0.3)) {
|
||||
state = s_dead;
|
||||
fisherman_dead = true;
|
||||
player.state = player.S_GROUND;
|
||||
|
||||
}
|
||||
break;
|
||||
case s_dead:
|
||||
xml.@alive = "false";
|
||||
if (framePixels_y_push < 16) {
|
||||
framePixels_y_push ++;
|
||||
}
|
||||
if (scale.x > 0 && scale.y > 0) {
|
||||
scale.x -= 0.01;
|
||||
scale.y -= 0.01;
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import entity.gadget.Checkpoint;
|
||||
import entity.player.HealthBar;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.Achievements;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Health_Cicada extends FlxSprite
|
||||
{
|
||||
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
private var xml:XML;
|
||||
|
||||
private var state:int;
|
||||
private var s_invisible:int = 0;
|
||||
private var s_visible:int = 1;
|
||||
private var s_animating:int = 2;
|
||||
private var ctr:int = 0;
|
||||
|
||||
|
||||
private var logic:Function;
|
||||
|
||||
private var tl:Point;
|
||||
private var target:Point = new Point;
|
||||
private var t:Number = 0;
|
||||
private var tm:Number = 1.7 ;
|
||||
private var nr_gnaws:int = 0;
|
||||
|
||||
private var t_sound:Number = 0;
|
||||
|
||||
|
||||
public var boxes:FlxGroup = new FlxGroup(10);
|
||||
public var fly_away_distance:int = 80;
|
||||
|
||||
|
||||
[Embed (source = "../../res/sprites/inventory/life_cicada.png")] public static var health_cicada_embed:Class;
|
||||
public function Health_Cicada(_player:Player,_parent:*,_xml:XML)
|
||||
{
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
loadGraphic(health_cicada_embed, true, false, 16, 16);
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
addAnimation("idle", [6,7,6,7,6,6,6,6], 8);
|
||||
addAnimation("fly", [4,5], 14);
|
||||
addAnimation("gnaw", [6,7], 14);
|
||||
} else {
|
||||
addAnimation("idle", [2, 3, 2, 3, 2, 2, 2, 2], 8);
|
||||
addAnimation("fly", [0, 1], 14);
|
||||
addAnimation("gnaw", [2, 3], 14);
|
||||
}
|
||||
play("idle");
|
||||
width = height = 8;
|
||||
offset.x = offset.y = 4;
|
||||
x += 4;
|
||||
y += 4;
|
||||
|
||||
visible = false;
|
||||
|
||||
if (Registry.is_playstate) {
|
||||
tl = new Point;
|
||||
tl.x = Registry.CURRENT_GRID_X * 160;
|
||||
tl.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT;
|
||||
logic = dungeon_logic;
|
||||
} else {
|
||||
logic = roam_logic;
|
||||
}
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
for (var i:int = 0; i < boxes.maxSize; i++) {
|
||||
var box:FlxSprite = new FlxSprite;
|
||||
if (i % 2 == 0) {
|
||||
box.makeGraphic(4, 4, 0xff000000);
|
||||
} else {
|
||||
box.makeGraphic(3, 3, 0xff000000);
|
||||
}
|
||||
box.visible = false;
|
||||
boxes.add(box);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function dungeon_logic():void {
|
||||
if (state == s_visible || (state == s_animating && ctr < 1)) {
|
||||
Registry.sound_data.cicada_chirp.play();
|
||||
}
|
||||
switch (state) {
|
||||
case s_invisible:
|
||||
if (Registry.CURRENT_MAP_NAME == "BEDROOM") {
|
||||
if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) {
|
||||
start(tl.x + 72, tl.y + 60, tl.x - 16, tl.y + 30);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "REDCAVE") {
|
||||
if (Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx]) {
|
||||
start(tl.x + 90, tl.y + 75, tl.x - 16, tl.y + 30);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "CROWD") {
|
||||
if (Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) {
|
||||
start(tl.x + 70, tl.y + 60, tl.x - 16, tl.y + 30);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "APARTMENT") {
|
||||
if (Registry.GE_States[Registry.GE_Apartment_Boss_Dead_Idx]) {
|
||||
start(tl.x + 50, tl.y + 60, tl.x - 16, tl.y + 30);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "CIRCUS") {
|
||||
if (Registry.GE_States[Registry.GE_Circus_Boss_Dead_Idx]) {
|
||||
start(tl.x + 70, tl.y + 8 , tl.x - 16, tl.y + 30);
|
||||
fly_away_distance = 160;
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "HOTEL") {
|
||||
if (Registry.GE_States[Registry.GE_Hotel_Boss_Dead_Idx]) {
|
||||
start(tl.x + 60, tl.y + 70, tl.x -16, tl.y + 30);
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "OVERWORLD") {
|
||||
start(x, y, tl.x - 16, tl.y + 30);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SUBURB") {
|
||||
start(x, y, tl.x - 16, tl.y + 30);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN") {
|
||||
start(x, y, tl.x - 16, tl.y + 30);
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BEACH") {
|
||||
start(x, y, tl.x - 16, tl.y + 30);
|
||||
}
|
||||
|
||||
break;
|
||||
case s_visible: //Touch the player, freeze them.
|
||||
if (ctr == 0 && player.overlaps(this) && player.state == player.S_GROUND) {
|
||||
state = s_animating;
|
||||
ctr = 0;
|
||||
play("fly");
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
// Or fly away if plaer goes too far
|
||||
} else if (ctr == 1 || EventScripts.distance(player, this) > fly_away_distance) {
|
||||
play("fly");
|
||||
velocity.y = -100;
|
||||
ctr = 1;
|
||||
alpha -= 0.02;
|
||||
}
|
||||
break;
|
||||
case s_animating:
|
||||
switch (ctr) {
|
||||
case -1: //move to target point
|
||||
DH.disable_menu();
|
||||
var sub_ctr:int = 0;
|
||||
if (EventScripts.send_property_to(this, "x", target.x, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(this, "y", target.y, 0.5)) sub_ctr++;
|
||||
if (sub_ctr == 2) {
|
||||
ctr++;
|
||||
state = s_visible;
|
||||
play("idle");
|
||||
}
|
||||
break;
|
||||
case 0: //After touched, heal the player
|
||||
if (player.health_bar.max_health > player.health_bar.cur_health) {
|
||||
t += FlxG.elapsed;
|
||||
if (t > 0.5) {
|
||||
Registry.sound_data.get_small_health.play();
|
||||
t = 0;
|
||||
player.health_bar.modify_health(1);
|
||||
}
|
||||
} else { //eventually upgrade the health and set a target point in the spot of the new health thing
|
||||
ctr++;
|
||||
if (Registry.CURRENT_MAP_NAME == "OVERWORLD") {
|
||||
Achievements.unlock(Achievements.Extra_health_1);
|
||||
}
|
||||
HealthBar.upgrade_health(player);
|
||||
player.health_bar.members[player.health_bar.max_health - 1].visible = false;
|
||||
target.x = player.health_bar.members[player.health_bar.max_health - 1].x + tl.x;
|
||||
target.y = player.health_bar.members[player.health_bar.max_health - 1].y + tl.y - Registry.HEADER_HEIGHT;
|
||||
}
|
||||
break;
|
||||
case 1: //move there then nibble
|
||||
sub_ctr = 0;
|
||||
if (EventScripts.send_property_to(this, "x", target.x, 0.5)) sub_ctr++;
|
||||
if (EventScripts.send_property_to(this, "y", target.y, 0.5)) sub_ctr++;
|
||||
if (sub_ctr == 2) {
|
||||
ctr++;
|
||||
play("gnaw");
|
||||
boxes.setAll("visible", true);
|
||||
set_boxes();
|
||||
}
|
||||
break;
|
||||
case 2: // do the box animation a few more times
|
||||
for each (var b:FlxSprite in boxes.members) {
|
||||
if (b == null) continue;
|
||||
b.alpha -= 0.005;
|
||||
}
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm) {
|
||||
t = 0;
|
||||
set_boxes();
|
||||
}
|
||||
if (nr_gnaws == 3) {
|
||||
ctr++;
|
||||
player.health_bar.members[player.health_bar.max_health -1].visible = true;
|
||||
play("fly");
|
||||
velocity.y = -40;
|
||||
xml.@alive = "false";
|
||||
}
|
||||
break;
|
||||
case 3: //fade the last boxes out, then disappear after flying off
|
||||
for each (var b2:FlxSprite in boxes.members) {
|
||||
if (b2 == null) continue;
|
||||
b2.alpha -= 0.005;
|
||||
}
|
||||
alpha -= 0.01;
|
||||
if (alpha == 0) {
|
||||
DH.enable_menu();
|
||||
player.state = player.S_GROUND;
|
||||
exists = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function set_boxes():void {
|
||||
nr_gnaws++;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.four_shooter_pop_group);
|
||||
for each (var box:FlxSprite in boxes.members) {
|
||||
if (box == null) continue;
|
||||
box.alpha = 1;
|
||||
box.acceleration.y = 50 + 20 * Math.random();
|
||||
box.velocity.x = -40 + 80 * Math.random();
|
||||
box.velocity.y = 10 + 20 * Math.random();
|
||||
box.x = x + 6;
|
||||
box.y = y + 6;
|
||||
}
|
||||
}
|
||||
private function roam_logic():void {
|
||||
|
||||
}
|
||||
|
||||
private function start(target_x:int,target_y:int,start_x:int,start_y:int):void
|
||||
{
|
||||
state = s_animating;
|
||||
visible = true;
|
||||
target.x = target_x;
|
||||
target.y = target_y;
|
||||
x = start_x;
|
||||
y = start_y;
|
||||
ctr = -1;
|
||||
play("fly");
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
logic();
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
tl = null;
|
||||
logic = null;
|
||||
DH.enable_menu();
|
||||
Registry.sound_data.cicada_chirp.stop();
|
||||
parent.header_group.remove(this, true);
|
||||
parent.header_group.remove(boxes, true);
|
||||
boxes = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,147 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
public class Red_Pillar extends FlxSprite
|
||||
{
|
||||
/* dame props:
|
||||
* alive - whether this appears as broken or not etc
|
||||
* p = 2
|
||||
* frame: what event it triggers when destroyed
|
||||
* L R C1 C2 <-- the triggers (1 to 4) WHERE THEY ARE LOCATED */
|
||||
public var xml:XML;
|
||||
public var cid:int = CLASS_ID.RED_PILLAR;
|
||||
|
||||
public var state:int = 0;
|
||||
public var s_disappearing:int = 3;
|
||||
public var s_dead:int = 2;
|
||||
public var s_dying:int = 1;
|
||||
public var s_alive:int = 0;
|
||||
|
||||
public var player:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var active_region:FlxSprite;
|
||||
public var ripple:FlxSprite;
|
||||
public var pixel_push:Number = 0;
|
||||
public var retract_speed:Number = 0.4;
|
||||
|
||||
[Embed (source = "../../res/sprites/enemies/redcave/red_pillar.png")] public static var red_pillar_sprite:Class;
|
||||
[Embed (source = "../../res/sprites/enemies/redcave/red_pillar_ripple.png")] public static var red_pillar_ripple_sprite:Class;
|
||||
|
||||
public function Red_Pillar(_xml:XML, _p:Player, _parent:* )
|
||||
{
|
||||
super(parseInt(_xml.@x), parseInt(_xml.@y));
|
||||
xml = _xml;
|
||||
|
||||
/* AD DANIMS */
|
||||
loadGraphic(red_pillar_sprite, true, false, 16, 80);
|
||||
addAnimation("move", [1, 2], 8);
|
||||
addAnimation("stuck", [0]);
|
||||
retract_speed = 0.7;
|
||||
play("stuck");
|
||||
|
||||
// need to add
|
||||
ripple = new FlxSprite;
|
||||
ripple.loadGraphic(red_pillar_ripple_sprite, true, false, 16, 16);
|
||||
ripple.addAnimation("move", [0, 1], 8, true);
|
||||
ripple.play("move");
|
||||
ripple.visible = false;
|
||||
ripple.x = x;
|
||||
ripple.y = y + height + Registry.HEADER_HEIGHT - ripple.height + 1;
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
immovable = true;
|
||||
|
||||
player = _p;
|
||||
|
||||
active_region = new FlxSprite(x, y + Registry.HEADER_HEIGHT + 16);
|
||||
active_region.makeGraphic(16, 16, 0x000000);
|
||||
|
||||
parent = _parent;
|
||||
_parent.sortables.add(ripple);
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (state == s_dying) {
|
||||
if (!flickering) {
|
||||
Registry.Event_Nr_Red_Pillars_Broken++;
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 1:
|
||||
case 2:
|
||||
if (Registry.Event_Nr_Red_Pillars_Broken == 4) {
|
||||
Registry.E_Load_Cutscene = true;
|
||||
Registry.CURRENT_CUTSCENE = Cutscene.Red_Cave_North;
|
||||
|
||||
}
|
||||
xml.@alive = "false";
|
||||
break;
|
||||
case 3:
|
||||
Registry.E_Load_Cutscene = true;
|
||||
Registry.CURRENT_CUTSCENE = Cutscene.Red_Cave_Left;
|
||||
xml.@alive = "false";
|
||||
break;
|
||||
case 4:
|
||||
Registry.E_Load_Cutscene = true;
|
||||
Registry.CURRENT_CUTSCENE = Cutscene.Red_Cave_Right;
|
||||
xml.@alive = "false";
|
||||
break;
|
||||
}
|
||||
player.state = player.S_GROUND;
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == s_alive && player.broom.overlaps(active_region) && player.broom.visible) {
|
||||
hit();
|
||||
play_sfx(HURT_SOUND_NAME);
|
||||
play("hit");
|
||||
}
|
||||
|
||||
if (state == s_disappearing) {
|
||||
|
||||
player.invincible = true;
|
||||
if (player.broom.visible == false) {
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
}
|
||||
pixel_push += retract_speed;
|
||||
framePixels_y_push = pixel_push;
|
||||
if (framePixels_y_push == height) {
|
||||
state = s_dying;
|
||||
ripple.exists = false;
|
||||
}
|
||||
} else {
|
||||
FlxG.collide(this, player);
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
public function hit():void {
|
||||
flicker(1.5);
|
||||
play("move");
|
||||
state = s_disappearing;
|
||||
ripple.visible = true;
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(ripple, true);
|
||||
active_region = ripple = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package entity.interactive
|
||||
{
|
||||
import entity.player.Player;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* The gate in TERMINAL with three tiers. One is removed for each
|
||||
* of the first three bosses defeated.
|
||||
* A container class for the associated entities
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Terminal_Gate extends FlxSprite
|
||||
{
|
||||
|
||||
public var xml:XML;
|
||||
public var p:Player;
|
||||
public var parent:*;
|
||||
|
||||
public var gate_bedroom:FlxSprite;
|
||||
public var gate_redcave:FlxSprite;
|
||||
public var gate_crowd:FlxSprite;
|
||||
public var button:FlxSprite;
|
||||
|
||||
public function Terminal_Gate(_xml:XML, _p:Player, _parent:*,is_cutscene:Boolean=false)
|
||||
{
|
||||
xml = _xml;
|
||||
p = _p;
|
||||
parent = _parent;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
gate_bedroom = new FlxSprite(x, y + 16 + Registry.HEADER_HEIGHT);
|
||||
gate_redcave = new FlxSprite(x, y + 32 + Registry.HEADER_HEIGHT);
|
||||
gate_crowd = new FlxSprite(x, y + 48 + Registry.HEADER_HEIGHT);
|
||||
|
||||
gate_bedroom.makeGraphic(16, 16, 0xff00ee00);
|
||||
gate_redcave.makeGraphic(16, 16, 0xffee0000);
|
||||
gate_crowd.makeGraphic(16, 16, 0xff0000ee);
|
||||
|
||||
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Bedroom]) {
|
||||
gate_bedroom.exists = false;
|
||||
}
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Redcave]) {
|
||||
gate_redcave.exists = false;
|
||||
}
|
||||
if (Registry.CUTSCENES_PLAYED[Cutscene.Terminal_Gate_Crowd]) {
|
||||
gate_crowd.exists = false;
|
||||
}
|
||||
visible = false;
|
||||
button = new FlxSprite(x, y + Registry.HEADER_HEIGHT);
|
||||
button.makeGraphic(16, 16, 0xff000000);
|
||||
|
||||
if (!is_cutscene) {
|
||||
parent.sortables.add(button);
|
||||
parent.sortables.add(gate_bedroom);
|
||||
parent.sortables.add(gate_redcave);
|
||||
parent.sortables.add(gate_crowd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
super.update();
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void {
|
||||
parent.sortables.remove(gate_bedroom, true);
|
||||
parent.sortables.remove(gate_redcave, true);
|
||||
parent.sortables.remove(gate_crowd, true);
|
||||
parent.sortables.remove(button, true);
|
||||
gate_bedroom = gate_redcave = gate_crowd = button = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* Behaviors of forest sprites, minus mr. bear who is in NPC as a Quest_npc
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
|
||||
|
||||
public class Forest_NPC extends AnoSprite
|
||||
{
|
||||
|
||||
private var type:int;
|
||||
private var T_LORAX:int = 0;
|
||||
private var T_MUSHROOM:int = 1;
|
||||
private var T_BUNNY:int = 2;
|
||||
private var T_BUNNY_RUN:int = 3;
|
||||
public var active_region:FlxSprite;
|
||||
|
||||
[Embed(source = "../../../res/sprites/npcs/forest_npcs.png")] public static const embed_forest_npcs:Class;
|
||||
|
||||
public function Forest_NPC(a:Array)
|
||||
{
|
||||
super(a);
|
||||
|
||||
loadGraphic(embed_forest_npcs,true,false,16,16);
|
||||
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case 0: //Lorax
|
||||
type = T_LORAX;
|
||||
addAnimation("move", [0, 1], 4);
|
||||
addAnimation("stand", [1], 0);
|
||||
addAnimation("squat", [0], 0);
|
||||
play("move");
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case 20: // mushroom
|
||||
type = T_MUSHROOM;
|
||||
addAnimation("idle", [20], 4);
|
||||
addAnimation("move", [20, 21, 20,22,20,21,20,22,20], 8,false);
|
||||
play("idle");
|
||||
break;
|
||||
case 30: // rabbit
|
||||
type = T_BUNNY;
|
||||
add_bunny_anims(this);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case 34: // Random bunny swap
|
||||
type = T_BUNNY_RUN;
|
||||
add_bunny_anims(this);
|
||||
if (Math.random() < 0.25) {
|
||||
var r:Number = Math.random();
|
||||
if (r < 0.25) {
|
||||
play("walk_d");
|
||||
} else if (r < 0.5) {
|
||||
play("walk_r");
|
||||
} else if (r < 0.75) {
|
||||
play("walk_u");
|
||||
} else {
|
||||
play("walk_l");
|
||||
}
|
||||
} else {
|
||||
exists = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
active_region = new FlxSprite(x - 2, y - 2);
|
||||
active_region.makeGraphic(20, 20, 0x00ffffff);
|
||||
}
|
||||
override public function destroy():void
|
||||
{
|
||||
active_region.destroy();
|
||||
active_region = null;
|
||||
super.destroy();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
if (type == T_LORAX) {
|
||||
immovable = true;
|
||||
FlxG.collide(this, player);
|
||||
wait_to_talk(DH.name_forest_npc, DH.scene_forest_npc_thorax);
|
||||
} else if (type == T_BUNNY) {
|
||||
immovable = true;
|
||||
FlxG.collide(this, player);
|
||||
wait_to_talk(DH.name_forest_npc, DH.scene_forest_npc_bunny, "walk");
|
||||
} else if (type == T_MUSHROOM) {
|
||||
immovable = true;
|
||||
FlxG.collide(this, player);
|
||||
if (player.broom.visible && player.broom.overlaps(this) && _curAnim.name != "move") {
|
||||
play("move");
|
||||
Registry.sound_data.play_sound_group_randomly(Registry.sound_data.mushroom_sound_group);
|
||||
} else if (_curAnim.name == "move") {
|
||||
if (finished) {
|
||||
play("idle");
|
||||
}
|
||||
}
|
||||
} else if (type == T_BUNNY_RUN) {
|
||||
if (state == 0) {
|
||||
if (EventScripts.distance(this, player) < 48) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.rat_move);
|
||||
state = 1;
|
||||
var run_spd:int = 100;
|
||||
_curAnim.delay = 1.0 / 14.0;
|
||||
if (_curAnim.name == "walk_d") {
|
||||
velocity.y = run_spd;
|
||||
} else if (_curAnim.name == "walk_r") {
|
||||
velocity.x = run_spd;
|
||||
} else if (_curAnim.name == "walk_u") {
|
||||
velocity.y = -run_spd;
|
||||
} else if (_curAnim.name == "walk_l") {
|
||||
velocity.x = -run_spd;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (x < tl.x - 16 || x > tl.x + 160 || y > tl.y + 160 || y < tl.y - 16) {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function wait_to_talk(name:String, scene:String,anim_stem:String="",area:String="",pos:int=-1):void {
|
||||
if (DH.a_chunk_is_playing() == false && player.overlaps(active_region) && player.state == player.S_GROUND && Registry.keywatch.JP_ACTION_1) {
|
||||
DH.start_dialogue(name, scene, area, pos);
|
||||
player.be_idle();
|
||||
if (anim_stem != "") {
|
||||
EventScripts.face_and_play(this, player, anim_stem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function add_bunny_anims(s:FlxSprite):void
|
||||
{
|
||||
s.addAnimation("walk_d", [30,31], 4, true);
|
||||
s.addAnimation("walk_r", [32,33], 4, true);
|
||||
s.addAnimation("walk_u", [34,35], 4, true);
|
||||
s.addAnimation("walk_l", [36, 37], 4, true);
|
||||
s.play("walk_d");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import entity.decoration.Water_Anim;
|
||||
import entity.interactive.NPC;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
public class Happy_NPC extends AnoSprite
|
||||
{
|
||||
[Embed(source = "../../../res/sprites/npcs/happy_npcs.png")] public static const embed_happy_npcs:Class;
|
||||
private var type:int;
|
||||
public var active_region:FlxObject;
|
||||
|
||||
private static const T_HOT:int = 0;
|
||||
private static const T_DUMP:int = 1;
|
||||
private static const T_GOLD:int = 2;
|
||||
private static const T_DRINK:int = 3;
|
||||
private static const T_BEAUTIFUL:int = 4;
|
||||
|
||||
public function Happy_NPC(a:Array)
|
||||
{
|
||||
super(a);
|
||||
loadGraphic(embed_happy_npcs, true, false, 16, 16);
|
||||
type = parseInt(xml.@frame);
|
||||
|
||||
if (type == 2 || type == 4) { //woman
|
||||
addAnimation("walk_d", [0, 1], 4);
|
||||
addAnimation("walk_r", [2,3], 4);
|
||||
addAnimation("walk_u", [4,5], 4);
|
||||
addAnimation("walk_l", [6,7], 4);
|
||||
addAnimation("idle_d", [0], 4);
|
||||
addAnimation("idle_r", [2], 4);
|
||||
addAnimation("idle_u", [4], 4);
|
||||
addAnimation("idle_l", [6], 4);
|
||||
} else if (type == 18) { // dam like hoover dam DAMN
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
if (Registry.CURRENT_MAP_NAME == "BLUE") {
|
||||
loadGraphic(NPC.embed_blue_npcs, true, false, 16, 16);
|
||||
addAnimation("fall", [10, 11, 12, 13, 14], 7, false);
|
||||
frame = 10;
|
||||
} else {
|
||||
addAnimation("fall", [18, 19, 20, 21, 22], 7,false);
|
||||
frame = 18;
|
||||
}
|
||||
} else {
|
||||
addAnimation("walk_d", [9,10], 4);
|
||||
addAnimation("walk_r", [11,12], 4);
|
||||
addAnimation("walk_u", [13,14], 4);
|
||||
addAnimation("walk_l", [15,16], 4);
|
||||
addAnimation("idle_d", [9], 4);
|
||||
addAnimation("idle_r", [11], 4);
|
||||
addAnimation("idle_u", [13], 4);
|
||||
addAnimation("idle_l", [15], 4);
|
||||
}
|
||||
if (type != 18) {
|
||||
play("idle_d");
|
||||
}
|
||||
active_region = new FlxObject(0, 0, 20, 20);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (type == 18) {
|
||||
if (alive == false) {
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
if (Registry.CURRENT_MAP_NAME == "HAPPY") {
|
||||
if (Registry.GRID_PUZZLES_DONE >= 1) {
|
||||
play("fall");
|
||||
alive = false;
|
||||
xml.@alive = "false";
|
||||
xml.@p = "2";
|
||||
}
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLUE") {
|
||||
if (Registry.GRID_PUZZLES_DONE >= 3) {
|
||||
play("fall");
|
||||
alive = false;
|
||||
xml.@p = "2";
|
||||
xml.@alive = "false";
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
return;
|
||||
}
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
|
||||
immovable = true;
|
||||
player.solid = true;
|
||||
FlxG.collide(parent.curMapBuf,this);
|
||||
FlxG.collide(this, player);
|
||||
if (DH.nc(player, active_region)) {
|
||||
velocity.x = velocity.y = 0;
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (type == T_HOT) DH.start_dialogue(DH.name_happy_npc, DH.scene_happy_npc_hot);
|
||||
if (type == T_DUMP) DH.start_dialogue(DH.name_happy_npc, DH.scene_happy_npc_dump);
|
||||
if (type == T_GOLD) DH.start_dialogue(DH.name_happy_npc, DH.scene_happy_npc_gold);
|
||||
if (type == T_DRINK) DH.start_dialogue(DH.name_happy_npc, DH.scene_happy_npc_drink);
|
||||
if (type == T_BEAUTIFUL) DH.start_dialogue(DH.name_happy_npc, DH.scene_happy_npc_beautiful);
|
||||
}
|
||||
|
||||
// Behaviors
|
||||
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
if (type == T_HOT) {
|
||||
pace();
|
||||
} else if (type == T_DUMP) {
|
||||
run();
|
||||
} else if (type == T_GOLD) {
|
||||
run();
|
||||
} else if (type == T_DRINK) {
|
||||
run();
|
||||
} else if (type == T_BEAUTIFUL) {
|
||||
pace();
|
||||
}
|
||||
} else {
|
||||
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private var t:Number = 0;
|
||||
private var tm:Number = 1.0;
|
||||
private var ctr:int = 0;
|
||||
private function pace():void {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm) {
|
||||
t = 0;
|
||||
if (ctr == 0) {
|
||||
if (Math.random() < 0.5) {
|
||||
ctr = 1;
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
} else {
|
||||
velocity.x = 0;
|
||||
random_idle();
|
||||
}
|
||||
|
||||
} else if (ctr == 1) {
|
||||
velocity.x = 0;
|
||||
if (Math.random() < 0.5) {
|
||||
ctr = 0;
|
||||
play("walk_l");
|
||||
velocity.x = -20;
|
||||
} else {
|
||||
random_idle();
|
||||
velocity.x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function run():void {
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm) {
|
||||
t = 0;
|
||||
if (ctr == 0) {
|
||||
play("walk_r");
|
||||
velocity.x = 40;
|
||||
ctr = 1;
|
||||
} else {
|
||||
play("walk_l");
|
||||
velocity.x = -40;
|
||||
ctr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function random_idle():void {
|
||||
var r:Number = Math.random();
|
||||
|
||||
if (r < 0.25) {
|
||||
play("idle_d");
|
||||
} else if (r < 0.5) {
|
||||
play("idle_r");
|
||||
} else if (r < 0.75) {
|
||||
play("idle_u");
|
||||
} else {
|
||||
play("idle_l");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
public class Huge_Fucking_Stag extends AnoSprite
|
||||
{
|
||||
[Embed(source = "../../../res/sprites/npcs/forest_stag.png")] public static const embed_stag:Class;
|
||||
public function Huge_Fucking_Stag(a:Array)
|
||||
{
|
||||
super(a);
|
||||
|
||||
loadGraphic(embed_stag, true, false, 64, 80);
|
||||
addAnimation("a", [0, 1, 2], 4);
|
||||
play("a");
|
||||
if (Math.random() < 0.01 || (FlxG.keys.Q && FlxG.keys.W && FlxG.keys.E)) {
|
||||
|
||||
} else {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,912 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.enemy.etc.Sage_Boss;
|
||||
import entity.player.Player;
|
||||
import flash.geom.Point;
|
||||
import global.Keys;
|
||||
import global.Registry;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
|
||||
|
||||
public class Mitra extends FlxSprite
|
||||
{
|
||||
|
||||
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
private var xml:XML;
|
||||
private var dame_frame:int;
|
||||
public var active_region:FlxObject;
|
||||
public var sage_active_region:FlxObject;
|
||||
|
||||
public var bike:FlxSprite;
|
||||
public var cid:int = CLASS_ID.MITRA;
|
||||
public var sage:FlxSprite;
|
||||
|
||||
|
||||
private var logic:Function;
|
||||
private var fields_state:int = 0;
|
||||
private const FS_cards:int = 1;
|
||||
private const FS_init:int = 2;
|
||||
// whehter an in
|
||||
private var gave_initial_hint:Boolean = false;
|
||||
private var state_counter:int = 0;
|
||||
// Generic flags
|
||||
private var b1:Boolean = false;
|
||||
private var b2:Boolean = false;
|
||||
private var tl:Point = new Point();
|
||||
private var ctr:int = 0;
|
||||
private var bullet:FlxSprite;
|
||||
|
||||
[Embed (source = "../../../res/sprites/npcs/bike.png")] public static var bike_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/npcs/mitra.png")] public static var mitra_sprite:Class;
|
||||
[Embed (source = "../../../res/sprites/npcs/mitra_bike.png")] public static var mitra_on_bike_sprite:Class;
|
||||
public function Mitra(_player:Player,_parent:*,_xml:XML)
|
||||
{
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
|
||||
tl.x = Registry.CURRENT_GRID_X * 160;
|
||||
tl.y = 20 + Registry.CURRENT_GRID_Y * 160;
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
addAnimation("bike_d", [0,1], 8);
|
||||
addAnimation("bike_u", [4,5], 8);
|
||||
addAnimation("bike_idle_u", [4], 8);
|
||||
addAnimation("bike_r", [2,3], 8);
|
||||
addAnimation("bike_l", [2,3], 8);
|
||||
|
||||
addAnimation("walk_d", [0,1], 8);
|
||||
addAnimation("walk_u", [4,5], 8);
|
||||
addAnimation("walk_r", [2,3], 8);
|
||||
addAnimation("walk_l", [2,3], 8);
|
||||
|
||||
addAnimation("idle_d", [6], 8);
|
||||
addAnimation("idle_u", [8], 8);
|
||||
addAnimation("idle_r", [7], 8);
|
||||
addAnimation("idle_l", [7], 8);
|
||||
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
play("idle_d");
|
||||
|
||||
bike = new FlxSprite;
|
||||
bike.loadGraphic(bike_sprite, true, false, 20, 20)
|
||||
bike.addAnimation("r", [1], 2);
|
||||
bike.addAnimation("d", [0], 2);
|
||||
bike.addAnimation("u", [2], 2);
|
||||
bike.visible = false;
|
||||
bike.play("r");
|
||||
bike.width = 16;
|
||||
bike.height = 10;
|
||||
bike.offset.x = 2;
|
||||
bike.offset.y = 11;
|
||||
parent.sortables.add(bike);
|
||||
|
||||
active_region = new FlxObject(x, y, 20, 20);
|
||||
sage_active_region = new FlxObject(x, y, 20, 20);
|
||||
|
||||
Registry.subgroup_interactives.push(this);
|
||||
|
||||
switch (Registry.CURRENT_MAP_NAME) {
|
||||
case "OVERWORLD":
|
||||
to_bike();
|
||||
|
||||
if (dame_frame == 0) {
|
||||
Registry.EVENT_CHANGE_VOLUME_SCALE = true;
|
||||
Registry.EVENT_CHANGE_VOLUME_SCALE_TARGET = 0.3;
|
||||
logic = overworld_logic;
|
||||
visible = false;
|
||||
if (DH.scene_is_dirty(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld)) {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "FIELDS":
|
||||
|
||||
bike.visible = true;
|
||||
bike.x = x - 20;
|
||||
bike.y = y + 20;
|
||||
if (Registry.all_bosses_dead() && Registry.nr_growths < 36) {
|
||||
trace("Mitra.as : All bosses dead!");
|
||||
fields_state = FS_cards;
|
||||
}
|
||||
|
||||
if (DH.scene_is_dirty(DH.name_mitra, DH.scene_mitra_fields_init, "FIELDS") == false) {
|
||||
fields_state = FS_init;
|
||||
}
|
||||
logic = fields_logic;
|
||||
|
||||
loadGraphic(mitra_sprite, true, false, 16, 16);
|
||||
break;
|
||||
case "CLIFF":
|
||||
logic = cliff_logic;
|
||||
x = tl.x - 20;
|
||||
y = tl.y + 70;
|
||||
to_bike();
|
||||
if (Registry.inventory[Registry.IDX_JUMP]) exists = false;
|
||||
break;
|
||||
case "GO":
|
||||
// Make a sage sprite
|
||||
if (Registry.GE_States[Registry.GE_Briar_Blue_Done] == false) {
|
||||
exists = false;
|
||||
break;
|
||||
}
|
||||
loadGraphic(mitra_on_bike_sprite, true, false, 20,20);
|
||||
visible = false;
|
||||
sage = new FlxSprite(0, 0);
|
||||
|
||||
sage.loadGraphic(Sage.sage_sprite, true, false, 16, 16);
|
||||
|
||||
sage.addAnimation("walk_d", [0, 1], 6, true);
|
||||
sage.addAnimation("walk_r", [2,3], 6, true);
|
||||
sage.addAnimation("walk_l", [2,3],6, true);
|
||||
sage.addAnimation("walk_u", [4,5], 6, true);
|
||||
sage.addAnimation("idle_d",[6]);
|
||||
sage.addAnimation("idle_r", [7]);
|
||||
sage.addAnimation("idle_l", [7]);
|
||||
sage.addAnimation("idle_u", [8]);
|
||||
sage.visible = false;
|
||||
parent.sortables.add(sage);
|
||||
|
||||
bullet = new FlxSprite(0, 0);
|
||||
bullet.loadGraphic(Sage_Boss.embed_sage_attacks, true, false, 16, 16);
|
||||
bullet.addAnimation("a", [0, 1], 8);
|
||||
bullet.play("a");
|
||||
parent.sortables.add(bullet);
|
||||
|
||||
logic = go_logic;
|
||||
|
||||
if (Registry.GE_States[Registry.GE_go_mitra] == true) {
|
||||
GO_STATE = GO_STATE_AFTER;
|
||||
loadGraphic(mitra_sprite, true, false, 16, 16);
|
||||
sage.x = tl.x + 32 + 8;
|
||||
sage.y = tl.y + 7 * 16 + 2;
|
||||
sage.visible = true;
|
||||
bike.visible = true;
|
||||
visible = true;
|
||||
bike.x = tl.x + 6 * 16 + 2;
|
||||
bike.y = tl.y + 7 * 16;
|
||||
x = tl.x + 6 * 16 + 2;
|
||||
y = tl.y + 8 * 16 - 20;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override public function preUpdate():void
|
||||
{
|
||||
if (solid) {
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
if (parent.state == parent.S_NORMAL) {
|
||||
logic();
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private const GO_STATE_AFTER:int = 2;
|
||||
private const GO_STATE_DURING:int = 1;
|
||||
private const GO_STATE_BEFORE:int = 0;
|
||||
private var GO_STATE:int = 0;
|
||||
private function go_logic():void {
|
||||
if (GO_STATE == GO_STATE_BEFORE) {
|
||||
if (ctr == 0 && player.x < tl.x + 7 * 16 && player.y < tl.y + 7 * 16) {
|
||||
// Move into place.
|
||||
ctr = 1;
|
||||
}
|
||||
|
||||
if (ctr == 1) {
|
||||
player.state = player.S_INTERACT;
|
||||
player.x += 1;
|
||||
player.play("walk_r");
|
||||
if (player.x > tl.x + 7 * 16) {
|
||||
player.x = tl.x + 7 * 16;
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
if (player.y > tl.y + 7 * 16) {
|
||||
player.y -= 1;
|
||||
player.play("walk_u");
|
||||
} else if (player.y < tl.y + 7 * 16 - 3) {
|
||||
player.y += 1;
|
||||
player.play("walk_d");
|
||||
} else {
|
||||
player.play("idle_r");
|
||||
player.y = tl.y + 7 * 16;
|
||||
|
||||
visible = true;
|
||||
play("bike_l");
|
||||
velocity.x = -45;
|
||||
x = tl.x + 160;
|
||||
y = tl.y + 5 * 16;
|
||||
ctr ++;
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
if (x < player.x - 24) {
|
||||
velocity.y = 45;
|
||||
velocity.x = 0;
|
||||
play("bike_d");
|
||||
if (y > player.y - 4) {
|
||||
loadGraphic(mitra_sprite, true, false, 16, 16);
|
||||
velocity.y = 20;
|
||||
play("walk_d");
|
||||
|
||||
bike.visible = true;
|
||||
bike.x = player.x - 18;
|
||||
bike.y = player.y + 10;
|
||||
|
||||
ctr++;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 4) {
|
||||
if (y > player.y + player.height) {
|
||||
velocity.y = 0;
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
if (x > player.x) {
|
||||
player.play("idle_d");
|
||||
play("idle_u");
|
||||
velocity.x = 0;
|
||||
|
||||
sage.x = tl.x + 4 * 16;
|
||||
sage.y = tl.y + 160;
|
||||
sage.velocity.y = -20;
|
||||
sage.visible = true;
|
||||
sage.play("walk_u");
|
||||
|
||||
ctr++;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 5) {
|
||||
if (sage.y < tl.y + 8 * 16 - 8) {
|
||||
sage.velocity.y = 0;
|
||||
sage.velocity.x = -20;
|
||||
sage.scale.x = -1;
|
||||
sage.play("walk_l");
|
||||
if (sage.x < tl.x + 2 * 16 + 8) {
|
||||
sage.velocity.x = 0;
|
||||
sage.scale.x = 1;
|
||||
sage.play("idle_r");
|
||||
GO_STATE = GO_STATE_DURING;
|
||||
ctr = 0;
|
||||
DH.set_scene_to_pos(DH.name_sage, "one", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (GO_STATE == GO_STATE_DURING) {
|
||||
if (player.x > tl.x + 9 * 16) {
|
||||
player.x = tl.x + 9 * 16;
|
||||
}
|
||||
|
||||
if (player.x < tl.x + 16) {
|
||||
player.x = tl.x + 16;
|
||||
}
|
||||
if (player.y > tl.y + 9 * 16) {
|
||||
player.y = tl.y + 9 * 16;
|
||||
}
|
||||
if (player.y < tl.y +16) {
|
||||
player.y = tl.y + 16;
|
||||
}
|
||||
if (ctr == 0) {
|
||||
DH.start_dialogue(DH.name_sage, "one");
|
||||
ctr++;
|
||||
player.play("idle_l");
|
||||
play("idle_l");
|
||||
scale.x = -1;
|
||||
} else if (ctr == 1) {
|
||||
player.play("idle_l");
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
parent.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_sage, "one");
|
||||
repeats++;
|
||||
if (repeats == 6) {
|
||||
ctr++;
|
||||
Registry.sound_data.sun_guy_charge.play();
|
||||
}
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
bullet.x = sage.x + sage.width;
|
||||
bullet.y = sage.y;
|
||||
bullet.flicker(0.1);
|
||||
t += FlxG.elapsed;
|
||||
if (t > tm) {
|
||||
t = 0;
|
||||
bullet.velocity.x = 10;
|
||||
ctr++;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.laser_pew_group);
|
||||
}
|
||||
|
||||
// Fire bullet
|
||||
} else if (ctr == 3) {
|
||||
if (bullet.x > bike.x - 3) {
|
||||
bullet.visible = false;
|
||||
FlxG.flash(0xffff0000, 1);
|
||||
EventScripts.make_explosion_and_sound(bullet);
|
||||
ctr = 6;
|
||||
}
|
||||
if (bullet.overlaps(player)) {
|
||||
FlxG.flash(0xffff0000, 1);
|
||||
EventScripts.make_explosion_and_sound(bullet);
|
||||
player.state = player.S_INTERACT;
|
||||
bullet.visible = false;
|
||||
player.play("slumped");
|
||||
ctr = 4;
|
||||
}
|
||||
if (player.broom.visible && player.broom.overlaps(bullet)) {
|
||||
FlxG.flash(0xffffffff, 1);
|
||||
EventScripts.make_explosion_and_sound(bullet);
|
||||
ctr = 4;
|
||||
bullet.visible = false;
|
||||
}
|
||||
} else if (ctr == 4) {
|
||||
// Wares doesnt gets hit
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 0);
|
||||
ctr = 5;
|
||||
} else if (ctr == 5) {
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
ctr = 9;
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 1);
|
||||
}
|
||||
} else if (ctr == 6) {
|
||||
//wares gets hit
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 2);
|
||||
ctr ++;
|
||||
} else if (ctr == 7) {
|
||||
velocity.x = -20;
|
||||
scale.x = -1;
|
||||
play("walk_l");
|
||||
if (x < bike.x) {
|
||||
play("idle_u");
|
||||
velocity.x = 0;
|
||||
scale.x = 1;
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 3);
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 8) {
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
play("idle_l");
|
||||
scale.x = -1;
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 4);
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 9) {
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 5);
|
||||
ctr = 10;
|
||||
GO_STATE = GO_STATE_AFTER;
|
||||
Registry.GE_States[Registry.GE_go_mitra] = true;
|
||||
}
|
||||
}
|
||||
} else if (GO_STATE == GO_STATE_AFTER) {
|
||||
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
sage_active_region.x = sage.x - 2;
|
||||
sage_active_region.y = sage.y - 2;
|
||||
EventScripts.face_and_play(sage, player, "idle");
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
|
||||
immovable = true;
|
||||
sage.immovable = bike.immovable = true;
|
||||
FlxG.collide(sage, player);
|
||||
FlxG.collide(this, player);
|
||||
FlxG.collide(bike, player);
|
||||
if (DH.nc(player, active_region)) {
|
||||
//mitra
|
||||
if (Registry.GE_States[Registry.GE_Briar_Happy_Done]) {
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_happy_posthappy_mitra);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 7);
|
||||
}
|
||||
}
|
||||
if (player.overlaps(sage_active_region)) {
|
||||
player.actions_disabled = true;
|
||||
}
|
||||
if (DH.nc(player, sage_active_region)) {
|
||||
if (Registry.GE_States[Registry.GE_Briar_Happy_Done]) {
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_happy_posthappy_sage);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_sage, "hit", "", 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private var t:Number = 0;
|
||||
private var tm:Number = 2.5;
|
||||
private var repeats:int = 0;
|
||||
|
||||
private function cliff_logic():void {
|
||||
if (state_counter == 0) {
|
||||
if (player.y > tl.y + 50 && player.state != player.S_LADDER) {
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.sound_data.start_song_from_title("MITRA");
|
||||
player.be_idle();
|
||||
player.state = player.S_INTERACT;
|
||||
DH.disable_menu();
|
||||
//DH.dialogue_popup("Hey, Young!");
|
||||
DH.dialogue_popup(DH.lk("mitra",0));
|
||||
state_counter = 1;
|
||||
x = tl.x + 160 + 20;
|
||||
y = tl.y + 80;
|
||||
}
|
||||
} else if (state_counter == 1) {
|
||||
player.be_idle();
|
||||
player.state = player.S_INTERACT;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
play("bike_l");
|
||||
velocity.x = -37;
|
||||
state_counter = 2;
|
||||
}
|
||||
} else if (state_counter == 2) {
|
||||
if (x <= player.x) {
|
||||
velocity.x = 0;
|
||||
bike.x = x - 1;
|
||||
bike.y = y - 1;
|
||||
bike.visible = true;
|
||||
if (Registry.inventory[Registry.IDX_BIKE_SHOES]) {
|
||||
//DH.dialogue_popup("Are those bike shoes for me? Wow! Thanks, Young! I’ve been thinking about getting these, since Wares has those pedals where you can clip in bike shoes. Here, Young, take my boots in exchange! They have these cool springs that let you jump really high! You press " + Registry.controls[Keys.IDX_ACTION_2] + " to jump with them on!");
|
||||
DH.dialogue_popup(DH.lk("mitra",1) + " "+Registry.controls[Keys.IDX_ACTION_2] + " "+DH.lk("mitra",2));
|
||||
|
||||
} else {
|
||||
//DH.dialogue_popup("Hi Young! Notice anything new? ^... ^... Oh, well, I got new biking shoes, see! They clip into Wares' pedals. Since I’ll no longer be needing my old boots, I want you to have them, Young! They have these cool springs that let you jump really high! You press " + Registry.controls[Keys.IDX_ACTION_2] + " to jump with them on!");
|
||||
DH.dialogue_popup(DH.lk("mitra",3) + " "+Registry.controls[Keys.IDX_ACTION_2] + " "+DH.lk("mitra",4));
|
||||
}
|
||||
|
||||
Registry.inventory[Registry.IDX_JUMP] = true;
|
||||
Registry.bound_item_2 = "JUMP";
|
||||
Registry.inventory[Registry.IDX_BIKE_SHOES] = false;
|
||||
state_counter = 6;
|
||||
loadGraphic(mitra_sprite, true, false, 16, 16);
|
||||
play("idle_u");
|
||||
offset.x = offset.y = 0;
|
||||
|
||||
}
|
||||
} else if (state_counter == 3) {
|
||||
if (!DH.a_chunk_is_playing()) {
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
//DH.dialogue_popup("Alright, take care!");
|
||||
DH.dialogue_popup(DH.lk("mitra",5));
|
||||
state_counter = 4;
|
||||
}
|
||||
} else if (state_counter == 4) {
|
||||
|
||||
if (!DH.a_chunk_is_playing()) {
|
||||
velocity.x = 37;
|
||||
bike.visible = false;
|
||||
to_bike();
|
||||
play("bike_r");
|
||||
player.state = player.S_INTERACT;
|
||||
state_counter = 5;
|
||||
}
|
||||
} else if (state_counter == 5) {
|
||||
|
||||
if (x > tl.x + 160) {
|
||||
exists = false;
|
||||
player.state = player.S_GROUND;
|
||||
Registry.E_FADE_AND_SWITCH = true;
|
||||
Registry.E_FADE_AND_SWITCH_SONG = "CLIFF";
|
||||
DH.enable_menu();
|
||||
}
|
||||
} else if (state_counter == 6) {
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
|
||||
|
||||
FlxG.collide(this, player);
|
||||
if (player.state == player.S_AIR) {
|
||||
jumpedonce = true;
|
||||
}
|
||||
if (player.overlaps(active_region) && DH.a_chunk_is_playing() == false && player.state == player.S_GROUND && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
if (DH.get_int_property(DH.name_mitra, "smells") == -1) {
|
||||
DH.increment_property(DH.name_mitra, "smells");
|
||||
//DH.dialogue_popup("Go on, try them out! ^...They’re not THAT smelly.");
|
||||
DH.dialogue_popup(DH.lk("mitra",6));
|
||||
} else {
|
||||
if (jumpedonce) {
|
||||
//DH.dialogue_popup("Cool, huh?");
|
||||
DH.dialogue_popup(DH.lk("mitra",7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.y < tl.y + 49) {
|
||||
state_counter = 3;
|
||||
}
|
||||
|
||||
if (player.x > tl.x + 135) {
|
||||
if (player.state == player.S_GROUND) {
|
||||
state_counter = 3;
|
||||
}
|
||||
player.x = tl.x + 135;
|
||||
}
|
||||
}
|
||||
}
|
||||
private var jumpedonce:Boolean = false;
|
||||
//hints and shit
|
||||
private function fields_logic():void {
|
||||
bike.immovable = true;
|
||||
FlxG.collide(bike, player);
|
||||
if (fields_state == FS_cards) {
|
||||
// Find next card thing to help with
|
||||
idle_card();
|
||||
} else if (fields_state == FS_init) {
|
||||
idle_fields_init();
|
||||
} else {
|
||||
idle_fields();
|
||||
// Give hints about game, maybe
|
||||
// Orj ust talk in general
|
||||
}
|
||||
}
|
||||
|
||||
private function idle_fields_init():void {
|
||||
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
if (DH.nc(player,active_region)) {
|
||||
if (DH.get_scene_position(DH.name_mitra, DH.scene_mitra_fields_init) < 2) {
|
||||
if (DH.get_int_property(DH.name_mitra, "wares") != -1) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_init, "", 0);
|
||||
DH.set_scene_to_pos(DH.name_mitra, DH.scene_mitra_fields_init, 2);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_init, "", 1);
|
||||
DH.set_scene_to_pos(DH.name_mitra, DH.scene_mitra_fields_init, 2);
|
||||
}
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_init);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function overworld_logic():void {
|
||||
switch(state_counter) {
|
||||
case 0:
|
||||
DH.disable_menu();
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
state_counter++;
|
||||
EventScripts.scale_vector(this, player, velocity, 80);
|
||||
visible = true;
|
||||
|
||||
} else {
|
||||
if (Math.abs(player.y -y) < 48) {
|
||||
if (!Registry.EVENT_CHANGE_VOLUME_SCALE && !DH.a_chunk_is_playing()) {
|
||||
Registry.sound_data.start_song_from_title("MITRA");
|
||||
Registry.volume_scale = 1;
|
||||
x -= 20; // Keep mitra off screen
|
||||
player.state = player.S_INTERACT;
|
||||
player.play("idle_l");
|
||||
play("bike_r");
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // Move down
|
||||
player.state = player.S_INTERACT;
|
||||
if (player.x - x < 24 && (x > Registry.CURRENT_GRID_X * 160 + 40)) {
|
||||
state_counter++;
|
||||
velocity.x = 0;
|
||||
velocity.y = 80;
|
||||
play("bike_d");
|
||||
}
|
||||
break;
|
||||
case 2 : // move right
|
||||
if (y - player.y > 24) {
|
||||
state_counter++;
|
||||
velocity.y = 0;
|
||||
velocity.x = 80;
|
||||
player.play("idle_d");
|
||||
play("bike_r");
|
||||
}
|
||||
break;
|
||||
case 3: //Hit the wall, flash, shake, cahnge graphic
|
||||
if (touching != NONE) {
|
||||
FlxG.shake(0.02, 0.3);
|
||||
Registry.sound_data.sun_guy_death_s.play();
|
||||
loadGraphic(mitra_sprite, true, false, 16, 16);
|
||||
width = height = 10;
|
||||
offset.x = 3;
|
||||
offset.y = 3;
|
||||
velocity.x = velocity.y = 0;
|
||||
play("idle_r");
|
||||
|
||||
//Bike stuff
|
||||
bike.visible = true;
|
||||
bike.x = x - 4; bike.y = y;
|
||||
|
||||
// After flash, move left
|
||||
FlxG.flash(0xffffffff, 1.0, function():void {
|
||||
state_counter++;
|
||||
velocity.x = -20;
|
||||
velocity.y = 0;
|
||||
play("walk_l");
|
||||
player.play("idle_r");
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// walk up to player
|
||||
if (x < player.x + 3) {
|
||||
x = player.x;
|
||||
velocity.x = 0;
|
||||
velocity.y = -20;
|
||||
player.play("idle_d");
|
||||
play("walk_u");
|
||||
state_counter++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// Face player, talk
|
||||
if (y < player.y + 26) {
|
||||
velocity.y = 0;
|
||||
play("idle_u");
|
||||
state_counter++;
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// wait to be done
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
state_counter++;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
||||
// If player is below mitra, have mitra walk left/rght first before biking
|
||||
//nvm dont need it anymore
|
||||
if (DH.scene_is_finished(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld)) {
|
||||
var dx:int = x - player.x;
|
||||
if (velocity.x != 20 && Math.abs(dx) < 20 && y < player.y) {
|
||||
if (dx < 20 && dx > -4) {
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
} else if (dx > -20 && dx < -4) {
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
}
|
||||
} else {
|
||||
player.be_idle();
|
||||
// Touch the bike first
|
||||
play("walk_r");
|
||||
touching = NONE;
|
||||
velocity.x = 20;
|
||||
player.state = player.S_INTERACT;
|
||||
|
||||
if (EventScripts.distance(this,bike) < 8) {
|
||||
state_counter++;
|
||||
to_bike();
|
||||
bike.visible = false;
|
||||
play("bike_d");
|
||||
velocity.y = 50;
|
||||
velocity.x = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (false == DH.a_chunk_is_playing() && EventScripts.distance(this, player) > 48) {
|
||||
player.be_idle();
|
||||
DH.set_scene_to_end(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld);
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_overworld_initial_overworld);
|
||||
// otherwise wait for interaction
|
||||
} else {
|
||||
idle(DH.scene_mitra_overworld_initial_overworld);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
// When off map, change song back
|
||||
if (y > 160 * (Registry.CURRENT_GRID_Y + 1) + 30) {
|
||||
Registry.volume_scale -= 0.02;
|
||||
if (Registry.volume_scale < 0.2) {
|
||||
DH.enable_menu();
|
||||
DH.dont_need_recently_finished();
|
||||
player.state = player.S_GROUND;
|
||||
player.ANIM_STATE = 7;
|
||||
Registry.sound_data.start_song_from_title("OVERWORLD");
|
||||
Registry.volume_scale = 1;
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function idle(scene:String):void
|
||||
{
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (Registry.keywatch.JP_ACTION_1 && player.overlaps(active_region) && EventScripts.are_facing_opposite(this, player)) {
|
||||
EventScripts.face_and_play(player, this, "idle");
|
||||
DH.start_dialogue(DH.name_mitra, scene);
|
||||
|
||||
if (scene == DH.scene_mitra_overworld_initial_overworld) {
|
||||
// If we heard the "wares" line then set a flag which
|
||||
// affects the init FIELDS scene for mitra
|
||||
DH.increment_property(DH.name_mitra, "wares");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function idle_card():void {
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (Registry.keywatch.JP_ACTION_1 && player.overlaps(active_region) && EventScripts.are_facing_opposite(this, player)) {
|
||||
|
||||
EventScripts.face_and_play(player, this, "idle");
|
||||
|
||||
// Give quest hint first till they go to cliff?
|
||||
if (!gave_quest_hint) {
|
||||
gave_quest_hint = true;
|
||||
if (Registry.GE_States[Registry.GE_QUEST_CLIFF] == false) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_quest_event);
|
||||
Registry.GE_States[Registry.GE_QUEST_MITRA] = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var i:int = int(36 * Math.random());
|
||||
|
||||
for (var j:int = 0; j < 36; j++) {
|
||||
if (!Registry.card_states[(i + j) % 36]) {
|
||||
DH.set_scene_to_pos(DH.name_mitra, DH.scene_mitra_fields_card_hints, (i + j ) % 36);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Registry.nr_growths == 0) {
|
||||
DH.set_scene_to_pos(DH.name_mitra, DH.scene_mitra_fields_card_hints, 36);
|
||||
}
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_card_hints);
|
||||
}
|
||||
}
|
||||
|
||||
private var gave_quest_hint:Boolean = false;
|
||||
private function idle_fields():void {
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (Registry.keywatch.JP_ACTION_1 && player.overlaps(active_region) && EventScripts.are_facing_opposite(this, player)) {
|
||||
EventScripts.face_and_play(player, this, "idle");
|
||||
|
||||
if (Registry.inventory[Registry.IDX_BIKE_SHOES]) {
|
||||
Registry.inventory[Registry.IDX_BIKE_SHOES] = false;
|
||||
Registry.inventory[Registry.IDX_JUMP] = true;
|
||||
Registry.bound_item_2 = "JUMP";
|
||||
|
||||
//DH.dialogue_popup("Wow, are those the biking shoes from Finty's shop? You're giving them to me? Thanks, Young, I really appreciate it! Here, try out my old shoes in return--I think you'll find them really useful! There's an engraving on the shoes that says \"Press " + Registry.controls[Keys.IDX_ACTION_2] + " to jump\". I've never understood that, though, because there's no \"" + Registry.controls[Keys.IDX_ACTION_2] + "\" anywhere on the shoes...");
|
||||
DH.dialogue_popup(DH.lk("mitra", 8) + " " + Registry.controls[Keys.IDX_ACTION_2] + " " + DH.lk("mitra", 9) + Registry.controls[Keys.IDX_ACTION_2] + DH.lk("mitra", 10));
|
||||
|
||||
} else if (!gave_initial_hint) {
|
||||
|
||||
gave_initial_hint = true;
|
||||
// Before widmill event.
|
||||
if (0 == Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]) {
|
||||
// hint to go to beach (or forest)
|
||||
if (!Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] && !Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) {
|
||||
if (Math.random() < 0.5) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 1);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 2);
|
||||
}
|
||||
} else if (Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] && !Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 8);
|
||||
|
||||
} else if (!Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] && Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 7);
|
||||
// hint to go to windmill
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 3);
|
||||
}
|
||||
} else {
|
||||
// If the bosses aren't all dead, hint to go past dungeon statues
|
||||
if (!Registry.all_bosses_dead()) {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 4);
|
||||
// If don't have the transformer, hint to go to terminal
|
||||
} else if (!Registry.inventory[Registry.IDX_TRANSFORMER]) { // No GO yet
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 5);
|
||||
// Otheriwse a hint for hte puzzle?
|
||||
} else { // got swap
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_game_hints, "FIELDS", 6);
|
||||
}
|
||||
}
|
||||
} else if (!gave_quest_hint) {
|
||||
// Give quest hint first till they go to cliff?
|
||||
if (Registry.GE_States[Registry.GE_QUEST_CLIFF] == false) {
|
||||
if (true == DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_quest_event)) {
|
||||
gave_quest_hint = true;
|
||||
Registry.GE_States[Registry.GE_QUEST_MITRA] = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_fields_general_banter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function to_bike():void
|
||||
{
|
||||
loadGraphic(mitra_on_bike_sprite, true, false, 20, 20);
|
||||
width = height = 10;
|
||||
centerOffsets(true);
|
||||
}
|
||||
|
||||
public function on_anim_change(name:String, frame:int, index:int):void {
|
||||
if (name == "walk_l" || name == "bike_l" || name == "idle_l") {
|
||||
scale.x = -1;
|
||||
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(bike, true);
|
||||
bike.destroy();
|
||||
bike = null;
|
||||
|
||||
if (sage != null ) {
|
||||
parent.sortables.remove(sage, true);
|
||||
sage.destroy();
|
||||
sage = null;
|
||||
}
|
||||
|
||||
if (bullet != null) {
|
||||
parent.sortables.remove(bullet, true);
|
||||
bullet.destroy();
|
||||
bullet = null;
|
||||
}
|
||||
|
||||
active_region.destroy();
|
||||
active_region = null;
|
||||
|
||||
sage_active_region.destroy();
|
||||
sage_active_region = null;
|
||||
|
||||
DH.a_chunk_just_finished();
|
||||
DH.enable_menu();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import helper.S_NPC;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
public class Redsea_NPC extends AnoSprite
|
||||
{
|
||||
|
||||
private var type:int;
|
||||
|
||||
private static const T_HAIR:int = 0;
|
||||
private static const T_BOMB:int = 1;
|
||||
|
||||
public var active_region:FlxObject;
|
||||
|
||||
[Embed(source = "../../../res/sprites/npcs/redsea_npcs.png")] public static const embed_redsea_npcs:Class;
|
||||
|
||||
public function Redsea_NPC(a:Array)
|
||||
{
|
||||
super(a);
|
||||
|
||||
loadGraphic(embed_redsea_npcs, true, false, 16, 16);
|
||||
switch (parseInt(xml.@frame)) {
|
||||
// ...
|
||||
case 0: //hair
|
||||
type = T_HAIR;
|
||||
addAnimation("walk_d", [0, 1], 4);
|
||||
addAnimation("walk_r", [2,3], 4);
|
||||
addAnimation("walk_u", [4,5], 4);
|
||||
addAnimation("walk_l", [6, 7], 4);
|
||||
play("walk_d");
|
||||
break;
|
||||
case 10: // bomb
|
||||
xml.@p = "2";
|
||||
if (xml.@alive == "false" ) {
|
||||
exists = false;
|
||||
}
|
||||
type = T_BOMB;
|
||||
addAnimation("walk", [10, 11], 4);
|
||||
play("walk");
|
||||
DH.set_scene_to_pos(DH.name_generic_npc, "bomb", 0);
|
||||
break;
|
||||
}
|
||||
active_region = new FlxObject(0, 0, 20, 20);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
|
||||
private var S_exploding:int = 1;
|
||||
private var s_exploded:int = 2;
|
||||
private var t:Number = 0;
|
||||
private var tm:Number = 1;
|
||||
override public function update():void
|
||||
{
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
immovable = true;
|
||||
FlxG.collide(this, player);
|
||||
if (type == T_HAIR) {
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
if (DH.nc(player, active_region)) {
|
||||
if (S_NPC.check_to_play_second(DH.name_generic_npc, DH.scene_generic_npc_any_first, "REDSEA")) {
|
||||
DH.start_dialogue(DH.name_generic_npc, DH.scene_generic_npc_any_second, "REDSEA");
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_generic_npc, DH.scene_generic_npc_any_first, "REDSEA");
|
||||
}
|
||||
}
|
||||
} else if (type == T_BOMB) {
|
||||
|
||||
if (state == s_exploded) {
|
||||
visible = false;
|
||||
x -= 160;
|
||||
y -= 160;
|
||||
} else if (state == S_exploding) {
|
||||
if (DH.nc(player, active_region)) {
|
||||
|
||||
EventScripts.make_explosion_and_sound(this);
|
||||
if (player.overlaps(active_region)) {
|
||||
player.touchDamage(1);
|
||||
}
|
||||
state = s_exploded;
|
||||
DH.set_scene_to_pos(DH.name_generic_npc, "bomb", 0);
|
||||
}
|
||||
} else {
|
||||
if (DH.scene_is_finished(DH.name_generic_npc, "bomb") ){
|
||||
state = S_exploding;
|
||||
xml.@alive = "false";
|
||||
}
|
||||
if (DH.nc(player, active_region)) {
|
||||
if (DH.scene_is_finished(DH.name_generic_npc, "bomb")) {
|
||||
// Explode
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_generic_npc, "bomb");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,772 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import data.Common_Sprites;
|
||||
import entity.gadget.KeyBlock;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Endian;
|
||||
import global.Keys;
|
||||
import global.Registry;
|
||||
import helper.Achievements;
|
||||
import helper.Cutscene;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxRect;
|
||||
import org.flixel.FlxSprite;
|
||||
import entity.player.Player;
|
||||
import states.EndingState;
|
||||
import states.PlayState;
|
||||
public class Sage extends FlxSprite
|
||||
{
|
||||
|
||||
private var player:Player;
|
||||
private var parent:*;
|
||||
private var xml:XML;
|
||||
|
||||
// The logic function specific to a map/area.
|
||||
private var logic:Function;
|
||||
|
||||
private var dame_frame:int;
|
||||
|
||||
private var state_counter:int = 0;
|
||||
|
||||
private var briar_ref:FlxSprite;
|
||||
private var whitelayer:FlxSprite;
|
||||
// Generic flags
|
||||
private var b1:Boolean = false;
|
||||
private var b2:Boolean = false;
|
||||
public var active_region:FlxObject;
|
||||
|
||||
private var tl:Point = new Point();
|
||||
|
||||
|
||||
[Embed (source = "../../../res/sprites/npcs/sage.png")] public static var sage_sprite:Class;
|
||||
public function Sage(_player:Player,_parent:*,_xml:XML)
|
||||
{
|
||||
|
||||
player = _player;
|
||||
parent = _parent;
|
||||
xml = _xml;
|
||||
dame_frame = parseInt(xml.@frame);
|
||||
super(parseInt(xml.@x), parseInt(xml.@y));
|
||||
|
||||
loadGraphic(sage_sprite, true, false, 16, 16);
|
||||
addAnimation("walk_d", [0, 1], 6, true);
|
||||
addAnimation("walk_r", [2,3], 6, true);
|
||||
addAnimation("walk_l", [2,3],6, true);
|
||||
addAnimation("walk_u", [4,5], 6, true);
|
||||
addAnimation("idle_d",[6]);
|
||||
addAnimation("idle_r", [7]);
|
||||
addAnimation("idle_l", [7]);
|
||||
addAnimation("idle_u", [8]);
|
||||
addAnimationCallback(on_anim_change);
|
||||
|
||||
width = height = 10;
|
||||
offset.x = 3;
|
||||
offset.y = 3;
|
||||
x += 3;
|
||||
y += 3;
|
||||
|
||||
tl.x = Registry.CURRENT_GRID_X * 160;
|
||||
tl.y = Registry.CURRENT_GRID_Y * 160 + 20;
|
||||
|
||||
play("idle_d");
|
||||
|
||||
|
||||
// Pick the function that will be called (for map-specific events, etc)
|
||||
switch (Registry.CURRENT_MAP_NAME) {
|
||||
case "BLANK":
|
||||
visible = false;
|
||||
logic = blank_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case "BEDROOM":
|
||||
// Do not show up after being talked to once and having left bedroom
|
||||
if (Registry.GE_States[Registry.GE_Left_BDR_After_Boss_Dead]) {
|
||||
exists = false;
|
||||
}
|
||||
logic = bedroom_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case "REDCAVE":
|
||||
if (Registry.GE_States[Registry.GE_Left_RDC_After_Boss_Dead] && Registry.inventory[Registry.IDX_RED_KEY]) {
|
||||
exists = false;
|
||||
}
|
||||
play("idle_u");
|
||||
logic = redcave_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case "OVERWORLD":
|
||||
// Do not show up after sunboss dead
|
||||
if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) {
|
||||
exists = false;
|
||||
}
|
||||
logic = overworld_logic;
|
||||
break;
|
||||
case "NEXUS":
|
||||
if ( Registry.GE_States[Registry.GE_Sage_Dead_Idx]) {
|
||||
exists = false;
|
||||
}
|
||||
logic = nexus_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case "TERMINAL":
|
||||
// If all cards, sage should appear on the bridge for the fight, otherwise at terminal etrance.
|
||||
xml.@p = "2";
|
||||
if (xml.@alive == "false" || Registry.GE_States[Registry.GE_Sage_Dead_Idx] == true) {
|
||||
exists = false;
|
||||
} else {
|
||||
logic = terminal_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
break;
|
||||
case "CROWD":
|
||||
if (Registry.GE_States[Registry.GE_Left_CRD_After_Boss_Dead]) {
|
||||
exists = false;
|
||||
}
|
||||
logic = crowd_logic;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
break;
|
||||
case "GO":
|
||||
|
||||
if (Registry.playtime < 15 * 60) {
|
||||
Achievements.unlock(Achievements.A_ENDING_SUB_15_M);
|
||||
}
|
||||
player.grid_entrance_x = tl.x + 75;
|
||||
player.grid_entrance_y = tl.y + 140;
|
||||
briar_ref = new FlxSprite;
|
||||
briar_ref.loadGraphic(Shadow_Briar.embed_briar, true, false, 16, 16);
|
||||
briar_ref.addAnimation("walk_d", [0, 1], 4);
|
||||
briar_ref.addAnimation("walk_r", [2, 3], 4);
|
||||
briar_ref.addAnimation("walk_u", [4, 5], 4);
|
||||
briar_ref.addAnimation("walk_l", [6, 7], 4);
|
||||
briar_ref.play("walk_d");
|
||||
briar_ref.x = tl.x + 16 * 4;
|
||||
briar_ref.y = tl.y + 60;
|
||||
briar_ref.framePixels_y_push = 8;
|
||||
|
||||
whitelayer = new FlxSprite(tl.x, tl.y);
|
||||
whitelayer.makeGraphic(160, 160, 0xffffffff);
|
||||
whitelayer.alpha = 0;
|
||||
whitelayer.height = 2;
|
||||
parent.sortables.add(whitelayer);
|
||||
|
||||
parent.sortables.add(briar_ref);
|
||||
|
||||
visible = false;
|
||||
exists = true;
|
||||
logic = gof_logic;
|
||||
|
||||
parent.darkness.loadGraphic(Common_Sprites.ending_blend, true, false, 160, 160);
|
||||
Registry.EVENT_CHANGE_DARKNESS_ALPHA_TARGET = 1;
|
||||
Registry.EVENT_CHANGE_DARKNESS_ALPHA = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
immovable = true;
|
||||
// Where the player can talk to sage
|
||||
active_region = new FlxObject(x, y, 20, 20);
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
if (parent.state == parent.S_NORMAL) {
|
||||
logic();
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//The player controls Young again. Jumps into water and swims up to the next screen. Sees Briar swimming up off the top of the screen. Young struggles up through the water, sinking, the sides of the canal are steep, so Young sinks all the way into the water>
|
||||
//<Briar, from offscreen>
|
||||
//Dude, Young.
|
||||
//<briar swims over to where young sank, goes underwater and comes back up, with Young>
|
||||
//Kick your feet. Move your arms. Jeez, you wouldn’t last a minute without me!
|
||||
private function gof_logic():void {
|
||||
if (player.y > tl.y + 144) {
|
||||
player.y = tl.y + 144;
|
||||
}
|
||||
DH.disable_menu();
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
if (player.y < tl.y + 16 * 6) {
|
||||
player.y = tl.y + 16 * 6;
|
||||
}
|
||||
if (player.x < tl.x + 64) {
|
||||
player.x = tl.x + 64;
|
||||
}
|
||||
if (player.x > tl.x + 88) {
|
||||
player.x = tl.x + 88;
|
||||
}
|
||||
briar_ref.framePixels_y_push = 8;
|
||||
briar_ref.velocity.y = -20;
|
||||
briar_ref.play("walk_u");
|
||||
if (player.y < tl.y + 140 && player.framePixels_y_push > 14) {
|
||||
player.state = player.S_INTERACT;
|
||||
state_counter = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
DH.start_dialogue(DH.name_briar, "final");
|
||||
player.framePixels_y_push = 14;
|
||||
state_counter = 2;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
player.framePixels_y_push = 14;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
player.state = player.S_INTERACT;
|
||||
briar_ref.y = tl.y - 16;
|
||||
briar_ref.play("walk_d");
|
||||
player.play("idle_u");
|
||||
briar_ref.framePixels_y_push = 14;
|
||||
briar_ref.velocity.y = 25;
|
||||
state_counter = 3;
|
||||
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
player.framePixels_y_push = 14;
|
||||
EventScripts.move_to_x_and_stop(briar_ref, 10, player.x);
|
||||
t_pushdown += FlxG.elapsed;
|
||||
if (t_pushdown > 0.4 && briar_ref.framePixels_y_push < 14) {
|
||||
briar_ref.framePixels_y_push++;
|
||||
t_pushdown = 0;
|
||||
}
|
||||
if (EventScripts.distance(briar_ref, player) < 7) {
|
||||
briar_ref.play("idle_d");
|
||||
briar_ref.velocity.y = briar_ref.velocity.x = 0;
|
||||
state_counter = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
t_pushdown += FlxG.elapsed;
|
||||
|
||||
player.framePixels_y_push = briar_ref.framePixels_y_push;
|
||||
if (t_pushdown > 0.3 && briar_ref.framePixels_y_push > 0) {
|
||||
t_pushdown = 0;
|
||||
briar_ref.framePixels_y_push--;
|
||||
player.framePixels_y_push = briar_ref.framePixels_y_push;
|
||||
}
|
||||
// after rising from water play dialogue
|
||||
if (briar_ref.framePixels_y_push == 6) {
|
||||
state_counter = 5;
|
||||
DH.start_dialogue(DH.name_briar, "final");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
//<Young starts treading water>
|
||||
//Well, come on, let’s go get a sandwich or something.
|
||||
//<briar swims up>
|
||||
//SAGE: <walks up from the right side after briar leaves>
|
||||
//You... you did adequately. Until we meet again.
|
||||
//<you regain control of young and can swim upwards off the screen (I think we shld just make it so that you can’t go down without really explaining it).
|
||||
//Once you do that, Sage stands there for a second.
|
||||
//All the tiles waver (like gas guy effect) and fade to white, with sage just standing in a white screen.
|
||||
//Sage then walks back off to the right.
|
||||
//Fade to credits.
|
||||
case 5:
|
||||
player.state = player.S_INTERACT;
|
||||
player.framePixels_y_push = 6;
|
||||
if (false == DH.a_chunk_is_playing()) {
|
||||
state_counter = 6;
|
||||
player.play("walk_r");
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
player.state = player.S_INTERACT;
|
||||
player.framePixels_y_push = 6;
|
||||
if (EventScripts.send_property_to(player, "x", tl.x + 85, 0.25)) {
|
||||
state_counter = 7;
|
||||
player.play("walk_l");
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
player.state = player.S_INTERACT;
|
||||
player.framePixels_y_push = 6;
|
||||
if (EventScripts.send_property_to(player, "x", tl.x + 65, 0.25)) {
|
||||
state_counter = 8;
|
||||
DH.start_dialogue(DH.name_briar, "final");
|
||||
player.play("idle_u");
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
player.state = player.S_INTERACT;
|
||||
player.framePixels_y_push = 6;
|
||||
if (false == DH.a_chunk_is_playing()) {
|
||||
briar_ref.play("walk_u");
|
||||
briar_ref.velocity.y = -25;
|
||||
state_counter = 9;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (briar_ref.y < tl.y - 16) {
|
||||
x = tl.x + 160;
|
||||
y = player.y;
|
||||
play("walk_l");
|
||||
visible = true;
|
||||
velocity.x = -24;
|
||||
state_counter = 10;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (x < tl.x + 128) {
|
||||
player.play("idle_r");
|
||||
play("idle_l");
|
||||
velocity.x = 0;
|
||||
DH.start_dialogue(DH.name_briar, "final");
|
||||
state_counter = 11;
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
player.framePixels_y_push = 6;
|
||||
if (player.y > tl.y + 150) {
|
||||
player.y = tl.y + 150;
|
||||
}
|
||||
if (player.x > tl.x + 92) {
|
||||
player.x = tl.x + 92;
|
||||
}
|
||||
if (player.x < tl.x + 68) {
|
||||
player.x = tl.x + 68;
|
||||
}
|
||||
if (player.y < tl.y + 80) {
|
||||
player.alpha -= 0.005;
|
||||
}
|
||||
if (player.y < tl.y + 8) {
|
||||
state_counter = 12;
|
||||
play("idle_u");
|
||||
t_pushdown = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
if (player.y < tl.y + 8) {
|
||||
player.y = tl.y + 8;
|
||||
}
|
||||
player.state = player.S_INTERACT;
|
||||
player.alpha -= 0.005;
|
||||
if (player.alpha < 0.005) {
|
||||
state_counter = 13;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
t_pushdown += FlxG.elapsed;
|
||||
if (t_pushdown > 1) {
|
||||
state_counter = 14;
|
||||
t_pushdown = 0;
|
||||
Registry.GFX_WAVE_EFFECT_ON = true;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
whitelayer.alpha += 0.002;
|
||||
if (whitelayer.alpha >= 1) {
|
||||
play("walk_r");
|
||||
velocity.x = 10;
|
||||
var p:PlayState;
|
||||
parent.black_overlay.alpha += 0.005;
|
||||
if (parent.black_overlay.alpha >= 1) {
|
||||
t_pushdown += FlxG.elapsed;
|
||||
|
||||
Registry.volume_scale -= 0.0015;
|
||||
if (t_pushdown > 3 && Registry.volume_scale < 0.002) {
|
||||
DH.enable_menu();
|
||||
Registry.GE_States[Registry.GE_Finished_Game] = true;
|
||||
FlxG.switchState(new EndingState);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
if (FlxG.volume < 0.002) {
|
||||
//Registry.volume_scale = 1;
|
||||
Registry.sound_data.stop_current_song();
|
||||
FlxG.switchState(new EndingState);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private var t_pushdown:Number = 0;
|
||||
private var tm_pushdown:Number = 1;
|
||||
private var pushdown_val:int = 0;
|
||||
|
||||
private function go_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
if (player.y < tl.y + 16 * 5) {
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
state_counter += 1;
|
||||
DH.dialogue_popup("biar: so gald u cud make it lol!");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (DH.a_chunk_is_playing() == true) return;
|
||||
|
||||
x = tl.x + 86;
|
||||
y = tl.y + 160;
|
||||
visible = true;
|
||||
play("walk_u");
|
||||
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.dialogue_popup("sag: heeeey dun forget me, lolz!");
|
||||
player.state = player.S_INTERACT;
|
||||
state_counter += 1;
|
||||
break;
|
||||
case 2:
|
||||
player.state = player.S_INTERACT;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
velocity.y = -20;
|
||||
}
|
||||
if (y < tl.y + 16 * 6) {
|
||||
velocity.y = 0;
|
||||
play("idle_u");
|
||||
DH.dialogue_popup("sage: Good work, now get out of here!");
|
||||
player.state = player.S_INTERACT;
|
||||
state_counter += 1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (DH.a_chunk_is_playing() == true) return;
|
||||
player.state = player.S_INTERACT;
|
||||
player.play("walk_u");
|
||||
briar_ref.play("walk_u");
|
||||
briar_ref.velocity.y = -20;
|
||||
briar_ref.alpha -= 0.005;
|
||||
player.alpha -= 0.005;
|
||||
velocity.y = 0;
|
||||
|
||||
t_pushdown += FlxG.elapsed;
|
||||
if (t_pushdown > tm_pushdown) {
|
||||
t_pushdown = 0;
|
||||
if (pushdown_val < 16) pushdown_val += 1;
|
||||
}
|
||||
briar_ref.framePixels_y_push = pushdown_val;
|
||||
player.framePixels_y_push = pushdown_val;
|
||||
|
||||
if (Registry.volume_scale > 0) Registry.volume_scale -= 0.01;
|
||||
if (player.y <= tl.y + 2) {
|
||||
player.velocity.y = 0;
|
||||
alpha -= 0.005;
|
||||
if (alpha <= 0 && Registry.volume_scale <= 0) {
|
||||
|
||||
Registry.E_DESTROY_PLAYSTATE = true;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.reset_events();
|
||||
Registry.reset_subgroups();
|
||||
state_counter += 1;
|
||||
}
|
||||
} else {
|
||||
player.y -= 0.4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
Registry.sound_data.big_door_locked.play();
|
||||
FlxG.flash(0xffffffff, 3, function ():void { FlxG.switchState(new EndingState); } );
|
||||
// Load some image of the area.
|
||||
parent.header_group.setAll("exists", false);
|
||||
state_counter += 1;
|
||||
break;
|
||||
case 5:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private var blank:Object = {
|
||||
played: false
|
||||
};
|
||||
|
||||
private function blank_logic():void {
|
||||
if (!blank.played) {
|
||||
blank.played = true;
|
||||
if (dame_frame == 0 && DH.get_scene_position(DH.name_sage,DH.scene_sage_blank_intro) == 1) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lookup_string("sage", "BLANK","intro", 1) + Registry.controls[Keys.IDX_ACTION_1] + DH.lookup_string("sage", "BLANK", "intro",2));
|
||||
DH.set_scene_to_pos(DH.name_sage, DH.scene_sage_blank_intro, 2);
|
||||
} else if (dame_frame == 1 && DH.get_scene_position(DH.name_sage, DH.scene_sage_blank_intro) == 2) {
|
||||
player.be_idle();
|
||||
DH.dialogue_popup(DH.lookup_string("sage", "BLANK", "intro",3) + Registry.controls[Keys.IDX_PAUSE] + DH.lookup_string("sage", "BLANK","intro", 4));
|
||||
DH.set_scene_to_pos(DH.name_sage, DH.scene_sage_blank_intro, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function crowd_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
DH.disable_menu();
|
||||
wait_then_approach_player(46, 24, "walk_d", "idle_d", "idle_u", 20, 2, DH.scene_sage_crowd_one, DH.name_sage, this);
|
||||
break;
|
||||
case 1:
|
||||
play_chunk_then_proceed(DH.scene_sage_crowd_one);
|
||||
break;
|
||||
case 2:
|
||||
DH.enable_menu();
|
||||
idle(DH.scene_sage_crowd_one);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function redcave_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
DH.disable_menu();
|
||||
wait_then_approach_player(28, 16, "walk_u", "idle_u", "idle_d", 20, 2, DH.scene_sage_crowd_one, DH.name_sage, this);
|
||||
break;
|
||||
case 1:
|
||||
play_chunk_then_proceed(DH.scene_sage_redcave_one);
|
||||
break;
|
||||
case 2:
|
||||
DH.enable_menu();
|
||||
idle(DH.scene_sage_redcave_one);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function bedroom_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
DH.disable_menu();
|
||||
wait_then_approach_player(48, 24, "walk_l", "idle_l", "idle_r", 20, 2, DH.scene_sage_bedroom_after_boss, DH.name_sage, this);
|
||||
break;
|
||||
case 1:
|
||||
play_chunk_then_proceed(DH.scene_sage_bedroom_after_boss);
|
||||
break;
|
||||
case 2:
|
||||
DH.enable_menu();
|
||||
idle(DH.scene_sage_bedroom_after_boss);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private function nexus_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0: // Initial cutscene when entering from bLANK
|
||||
wait_then_approach_player(64, 32, "walk_d", "idle_d", "idle_u", 20, 2, DH.scene_sage_nexus_enter_nexus, DH.name_sage, this);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
DH.disable_menu();
|
||||
play_chunk_then_proceed(DH.scene_sage_nexus_enter_nexus);
|
||||
|
||||
break;
|
||||
case 2: // Idle logic, messages change based on game state
|
||||
DH.enable_menu();
|
||||
|
||||
|
||||
if (Registry.GE_States[Registry.GE_got_all_cards_inanarea] && DH.scene_is_dirty(DH.name_sage,DH.scene_sage_nexus_all_card_first) == false) {
|
||||
idle(DH.scene_sage_nexus_all_card_first);
|
||||
} else if (1 == Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]) {
|
||||
idle(DH.scene_sage_nexus_after_windmill);
|
||||
} else if (0 == Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening] && Registry.GE_States[Registry.GE_Redcave_Boss_Dead_Idx] && Registry.GE_States[Registry.GE_Crowd_Boss_Dead_Idx]) {
|
||||
idle(DH.scene_sage_nexus_before_windmill);
|
||||
} else if (Registry.GE_States[Registry.GE_Bedroom_Boss_Dead_Idx]) {
|
||||
idle(DH.scene_sage_nexus_after_bed);
|
||||
} else if (Registry.GE_States[Registry.GE_ent_str]) {
|
||||
idle(DH.scene_sage_nexus_after_ent_str);
|
||||
} else {
|
||||
idle(DH.scene_sage_nexus_enter_nexus);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function overworld_logic():void {
|
||||
switch (state_counter) {
|
||||
case 0:
|
||||
DH.disable_menu();
|
||||
wait_then_approach_player(56, 28, "walk_d", "idle_d", "idle_u", 20, 5, DH.scene_sage_overworld_bedroom_entrance, DH.name_sage, this);
|
||||
break;
|
||||
case 1:
|
||||
player.invincible_timer = 0.3;
|
||||
player.invincible = true;
|
||||
play_chunk_then_proceed(DH.scene_sage_overworld_bedroom_entrance);
|
||||
break;
|
||||
case 2:
|
||||
player.dontMove = true;
|
||||
player.state = player.S_GROUND;
|
||||
if (!b1 && player.broom.is_active()) {
|
||||
b1 = true;
|
||||
} else if (b1 && !player.broom.is_active()) {
|
||||
b1 = false;
|
||||
player.dontMove = false;
|
||||
player.state = player.S_INTERACT;
|
||||
state_counter++;
|
||||
Registry.subgroup_interactives.push(this);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 3:
|
||||
play_chunk_then_proceed(DH.scene_sage_overworld_bedroom_entrance);
|
||||
if (state_counter != 3) {
|
||||
player.state = player.S_GROUND;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
DH.enable_menu();
|
||||
idle(DH.scene_sage_overworld_bedroom_entrance);
|
||||
break;
|
||||
case 5:
|
||||
Registry.subgroup_interactives.push(this);
|
||||
state_counter = 4;
|
||||
|
||||
}
|
||||
}
|
||||
public var ctr:int = 0;
|
||||
private function terminal_logic():void {
|
||||
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
immovable = true;
|
||||
FlxG.collide(this, player);
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (ctr == 0) {
|
||||
if (EventScripts.distance(player, this) < 46) {
|
||||
// play intro text at least once
|
||||
if (DH.scene_is_dirty(DH.name_sage, DH.scene_sage_terminal_entrance) == false) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
player.be_idle();
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_entrance);
|
||||
}
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
// autoplay if you have 36 or more
|
||||
if (DH.nc(player, active_region) || (EventScripts.distance(player, this) < 46 && Registry.nr_growths >= 36)) {
|
||||
player.be_idle();
|
||||
if (Registry.nr_growths < 18) {
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_entrance, "", 1);
|
||||
} else if (Registry.nr_growths < 36) {
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_entrance, "", 2);
|
||||
} else {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_etc,"",0);
|
||||
ctr++;
|
||||
}
|
||||
}
|
||||
} else if (ctr == 2) {
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
KeyBlock.sig_change = true;
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 3) {
|
||||
if (player.y < tl.y + 55) {
|
||||
xml.@alive = "false";
|
||||
DH.start_dialogue(DH.name_sage, DH.scene_sage_terminal_etc, "", 1);
|
||||
ctr++;
|
||||
player.be_idle();
|
||||
} else if (DH.nc(player, active_region)) {
|
||||
DH.dialogue_popup("...");
|
||||
}
|
||||
} else if (ctr == 4) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Wait, face the player, and talk if the player talks to them while standing on the ground
|
||||
* @param scene
|
||||
*/
|
||||
private function idle(scene:String):void
|
||||
{
|
||||
FlxG.collide(this, player);
|
||||
EventScripts.face_and_play(this, player, "idle");
|
||||
if (Registry.keywatch.JP_ACTION_1 && player.state == player.S_GROUND && player.overlaps(active_region) && EventScripts.are_facing_opposite(this, player)) {
|
||||
EventScripts.face_and_play(player, this, "idle");
|
||||
DH.start_dialogue(DH.name_sage, scene);
|
||||
player.be_idle();
|
||||
}
|
||||
}
|
||||
|
||||
private function play_chunk_then_proceed(scene:String):void
|
||||
{
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
state_counter++;
|
||||
DH.dont_need_recently_finished();
|
||||
} else if (!DH.a_chunk_is_playing()) {
|
||||
DH.start_dialogue(DH.name_sage, scene);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for sage waiting then appraoching the player, dealing with dirty scene if needed
|
||||
* @param init_distance Distance at which NPC should approach player
|
||||
* @param stop_distance Distance at which NPC stops moving and plays final_anim
|
||||
* @param init_anim Anim played by NPC when moving to player
|
||||
* @param final_anim Anim played by NPC when stops moving
|
||||
* @param init_player_anim Anim played by player when NPC moves to player
|
||||
* @param speed Speed atwhich NPC moves to player
|
||||
* @param skip_to If scene is dirty, what to set state_coutner to
|
||||
* @param scene The name of the scene
|
||||
* @param npc_name Name of the NPC
|
||||
* @param npc_ref The reference of the npc that will be moving
|
||||
*/
|
||||
private function wait_then_approach_player(init_distance:int, stop_distance:int, init_anim:String,final_anim:String,init_player_anim:String,speed:int,skip_to:int,scene:String,npc_name:String,npc_ref:*):void
|
||||
{
|
||||
if (player.state != player.S_AIR && EventScripts.distance(player, npc_ref) < init_distance) {
|
||||
player.state = player.S_INTERACT; // Freeze the player.
|
||||
npc_ref.play(init_anim);
|
||||
EventScripts.scale_vector(npc_ref, player, velocity, speed);
|
||||
|
||||
if (EventScripts.distance(player, npc_ref) < stop_distance) {
|
||||
DH.dont_need_recently_finished();
|
||||
npc_ref.play(final_anim);
|
||||
velocity.y = velocity.x = 0;
|
||||
state_counter++;
|
||||
}
|
||||
|
||||
|
||||
if (DH.scene_is_dirty(npc_name, scene)) {
|
||||
DH.dont_need_recently_finished();
|
||||
state_counter = skip_to;
|
||||
velocity.y = velocity.x = 0;
|
||||
player.state = player.S_GROUND;
|
||||
return;
|
||||
}
|
||||
player.play(init_player_anim);
|
||||
}
|
||||
}
|
||||
|
||||
public function on_anim_change(name:String, frame:int, index:int):void {
|
||||
if (name == "walk_l" || name == "idle_l") {
|
||||
scale.x = -1;
|
||||
} else {
|
||||
scale.x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
|
||||
if (briar_ref != null) {
|
||||
parent.sortables.remove(briar_ref, true);
|
||||
briar_ref.destroy();
|
||||
briar_ref = null;
|
||||
}
|
||||
|
||||
if (whitelayer != null) {
|
||||
parent.sortables.remove(whitelayer, true);
|
||||
whitelayer.destroy();
|
||||
whitelayer = null;
|
||||
}
|
||||
|
||||
DH.a_chunk_just_finished();
|
||||
DH.enable_menu();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,474 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.decoration.Water_Anim;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import states.EndingState;
|
||||
|
||||
|
||||
public class Shadow_Briar extends AnoSprite
|
||||
{
|
||||
|
||||
private const IDX_BEACH:int = 0;
|
||||
private const IDX_FOREST:int = 1;
|
||||
private const IDX_HAPPY:int = 2;
|
||||
private const IDX_BLUE:int = 3;
|
||||
private const IDX_GO:int = 4;
|
||||
|
||||
private var idx:int;
|
||||
private var ctr:int;
|
||||
|
||||
// Flipped when cutscene finished or xml.alive is false
|
||||
// notifies the other events to start (gate raising, mitra appearing)
|
||||
|
||||
private static var is_finished_blue:Boolean = false;
|
||||
private static var is_finished_happy:Boolean = false;
|
||||
|
||||
private var mitra:FlxSprite;
|
||||
private var t:Number = 0;
|
||||
private var wheel:FlxSprite;
|
||||
public var cid:int = 0;
|
||||
|
||||
[Embed(source = "../../../res/sprites/npcs/shadow_briar.png")] public static var embed_shadow_briar:Class;
|
||||
[Embed(source = "../../../res/sprites/npcs/briar.png")] public static var embed_briar:Class;
|
||||
[Embed(source = "../../../res/sprites/npcs/hamster_wheel.png")] public static var embed_wheel:Class;
|
||||
public function Shadow_Briar(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
|
||||
// MARINA_ANIMS
|
||||
loadGraphic(embed_briar, true, false, 16, 16);
|
||||
addAnimation("idle_d", [20], 12);
|
||||
addAnimation("idle_l", [26], 12);
|
||||
addAnimation("idle_r", [22], 12);
|
||||
addAnimation("idle_u", [24], 12);
|
||||
addAnimation("walk_d", [20, 21], 4);
|
||||
addAnimation("walk_l", [26,27], 4);
|
||||
addAnimation("walk_r", [22,23], 4);
|
||||
addAnimation("walk_u", [24,25], 4);
|
||||
play("idle_d");
|
||||
|
||||
alpha = 0;
|
||||
ctr = 0;
|
||||
|
||||
idx = parseInt(xml.@frame);
|
||||
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
if (Registry.CURRENT_MAP_NAME == "BLUE") {
|
||||
|
||||
if (exists) {
|
||||
mitra = new FlxSprite(tl.x + 160, tl.y + 76 );
|
||||
mitra.loadGraphic(Mitra.mitra_on_bike_sprite, true, false, 20, 20);
|
||||
|
||||
mitra.addAnimation("bike_r", [2,3], 8);
|
||||
mitra.addAnimation("bike_l", [2, 3], 8);
|
||||
mitra.addAnimation("idle", [2], 8);
|
||||
mitra.play("bike_l");
|
||||
mitra.scale.x = -1;
|
||||
mitra.visible = false;
|
||||
parent.sortables.add(mitra);
|
||||
|
||||
}
|
||||
|
||||
// MARINA_ANIMS_HAMSTER_WHEEL
|
||||
//wheel = new FlxSprite(tl.x + 48, tl.y + 4 * 16);
|
||||
//wheel.loadGraphic(embed_wheel, true, false, 32, 32);
|
||||
//wheel.addAnimation("idle", [0], 10);
|
||||
//wheel.addAnimation("spin1", [0, 1], 5);
|
||||
//wheel.addAnimation("spin2", [0, 1], 10);
|
||||
//wheel.addAnimation("spin3", [0, 1], 15);
|
||||
//wheel.addAnimation("backspin", [1, 0], 20);
|
||||
//if (Registry.GE_States[Registry.GE_Briar_Blue_Done]) {
|
||||
//wheel.play("spin3");
|
||||
//} else {
|
||||
//wheel.play("idle");
|
||||
//}
|
||||
//parent.fg_sprites.add(wheel);
|
||||
ctr = -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(mitra, true);
|
||||
mitra = null;
|
||||
DH.dont_need_recently_finished();
|
||||
wheel = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
switch (idx) {
|
||||
case IDX_BEACH:
|
||||
update_beach();
|
||||
break;
|
||||
case IDX_HAPPY:
|
||||
update_happy();
|
||||
break;
|
||||
case IDX_BLUE:
|
||||
update_blue();
|
||||
break;
|
||||
case IDX_FOREST:
|
||||
update_forest();
|
||||
break;
|
||||
case IDX_GO:
|
||||
update_go();
|
||||
break;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function update_go():void {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//private var wheel_start_pt:Point = new Point(0, 0);
|
||||
//private var t_wheel_snd:Number = 0;
|
||||
//private var tm_wheel_snd:Number = 0.2;
|
||||
private var total_ticks:int = 100;
|
||||
private function update_blue():void {
|
||||
switch (ctr) {
|
||||
// 1. Hamster wheel waits. If close enough..
|
||||
// 2. Fadeout song.
|
||||
// 3. Fade in MITRA.
|
||||
case -1:
|
||||
/// something about presing buttons
|
||||
if (player.x < tl.x + 76 && player.y < tl.y + 47 && player.state == player.S_GROUND) {
|
||||
player.be_idle();
|
||||
DH.disable_menu();
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
//case -2:
|
||||
//player.x = wheel_start_pt.x;
|
||||
//player.y = wheel_start_pt.y;
|
||||
//if (Registry.keywatch.LEFT) {
|
||||
//t_wheel_snd += FlxG.elapsed;
|
||||
//
|
||||
//if (t_wheel_snd > tm_wheel_snd) {
|
||||
//t_wheel_snd = 0;
|
||||
//total_ticks --;
|
||||
//Registry.sound_data.play_sound_group(Registry.sound_data.dialogue_blip_group);
|
||||
//if (total_ticks < 45) {
|
||||
//tm_wheel_snd = 0.05;
|
||||
//wheel.play("spin3");
|
||||
//} else if (total_ticks < 84) {
|
||||
//tm_wheel_snd = 0.09;
|
||||
//wheel.play("spin2");
|
||||
//} else {
|
||||
//wheel.play("spin1");
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//if (total_ticks < 0) {
|
||||
//ctr--;
|
||||
//FlxG.shake(0.01, 0.5);
|
||||
//Registry.sound_data.hitground1.play();
|
||||
//wheel.play("idle");
|
||||
//player.state = player.S_INTERACT;
|
||||
//}
|
||||
//break;
|
||||
//case -3:
|
||||
//player.x = wheel_start_pt.x;
|
||||
//player.y = wheel_start_pt.y;
|
||||
//t_wheel_snd += FlxG.elapsed;
|
||||
//if (t_wheel_snd > 1) {
|
||||
//player.play("walk_r");
|
||||
//wheel.play("backspin");
|
||||
//FlxG.shake(0.01, 0.5);
|
||||
//Registry.sound_data.hitground1.play();
|
||||
//ctr--;
|
||||
//t_wheel_snd = 0;
|
||||
//total_ticks = 50;
|
||||
//}
|
||||
//break;
|
||||
//case -4:
|
||||
//player.x = wheel_start_pt.x;
|
||||
//player.y = wheel_start_pt.y;
|
||||
//t_wheel_snd += FlxG.elapsed;
|
||||
//if (t_wheel_snd > tm_wheel_snd) {
|
||||
//t_wheel_snd = 0;
|
||||
//Registry.sound_data.play_sound_group(Registry.sound_data.dialogue_blip_group);
|
||||
//total_ticks--;
|
||||
//if (total_ticks < 0) {
|
||||
//wheel.play("idle");
|
||||
//Registry.sound_data.player_hit_1.play();
|
||||
//ctr--;
|
||||
//}
|
||||
//}
|
||||
//break;
|
||||
//case -5:
|
||||
//player.play("slumped");
|
||||
//if (EventScripts.send_property_to(player, "x", tl.x + 140,2) ){
|
||||
//FlxG.shake(0.02, 0.76);
|
||||
//Registry.sound_data.hitground1.play();
|
||||
//ctr = 0;
|
||||
//}
|
||||
//break;
|
||||
case 0:
|
||||
ctr++;
|
||||
DH.disable_menu();
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
mitra.y = tl.y + 33;
|
||||
mitra.visible = true;
|
||||
break;
|
||||
case 1:
|
||||
Registry.volume_scale -= 0.04;
|
||||
if (Registry.volume_scale <= 0) {
|
||||
Registry.sound_data.stop_current_song();
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Registry.volume_scale += 0.01;
|
||||
if (Registry.volume_scale > 0.5) {
|
||||
Registry.sound_data.start_song_from_title("MITRA");
|
||||
ctr++;
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_blue_one);
|
||||
}
|
||||
break;
|
||||
// 4. Mitra Bikes in.
|
||||
// 5. Mitra sas hi
|
||||
case 3:
|
||||
if (DH.a_chunk_is_playing() == true) break;
|
||||
if (Registry.volume_scale < 1) Registry.volume_scale += 0.01;
|
||||
mitra.play("bike_l");
|
||||
mitra.velocity.x = -70;
|
||||
player.be_idle();
|
||||
player.state = player.S_INTERACT;
|
||||
x = mitra.x;
|
||||
y = mitra.y;
|
||||
cid = CLASS_ID.MITRA;
|
||||
if (mitra.x < tl.x + 75) { // ?
|
||||
Registry.GRID_PUZZLES_DONE += 3;
|
||||
mitra.velocity.x = 0;
|
||||
mitra.play("idle");
|
||||
ctr++;
|
||||
// says something else?
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_blue_one);
|
||||
}
|
||||
break;
|
||||
// Mitra goes across buttons and they presumably open
|
||||
case 4:
|
||||
if (DH.a_chunk_just_finished()) {
|
||||
ctr++;
|
||||
player.state = player.S_INTERACT;
|
||||
}
|
||||
break;
|
||||
// 8. Gate opens.
|
||||
// 9. Mitra says BYE!
|
||||
case 5:
|
||||
ctr++;
|
||||
parent.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_mitra, DH.scene_mitra_blue_one);
|
||||
break;
|
||||
// 10. Mitra bikes to right.
|
||||
case 6:
|
||||
if (DH.a_chunk_just_finished() || false == DH.a_chunk_is_playing()) {
|
||||
ctr++;
|
||||
player.state = player.S_INTERACT;
|
||||
|
||||
mitra.velocity.x = 40;
|
||||
mitra.play("bike_r");
|
||||
mitra.scale.x = 1;
|
||||
}
|
||||
// 11. Song fades out.
|
||||
case 7:
|
||||
if (mitra.x > tl.x + 160) {
|
||||
mitra.exists = false;
|
||||
Registry.volume_scale -= 0.03;
|
||||
if (Registry.volume_scale < 0) {
|
||||
Registry.volume_scale = 0;
|
||||
Registry.sound_data.stop_current_song();
|
||||
ctr = 69;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 69:
|
||||
t += FlxG.elapsed;
|
||||
if (t > 1.5) {
|
||||
t = 0;
|
||||
ctr = 8;
|
||||
y = tl.y;
|
||||
x = tl.x + 48;
|
||||
}
|
||||
break;
|
||||
// 12. Briar fades in
|
||||
case 8:
|
||||
alpha += 0.02;
|
||||
if (alpha > 0.5) {
|
||||
ctr++;
|
||||
play("walk_d");
|
||||
}
|
||||
break;
|
||||
// 13. Briar walks down, while GO fades in
|
||||
case 9:
|
||||
alpha += 0.02;
|
||||
Registry.volume_scale += 0.02;
|
||||
if (Registry.volume_scale > 0.5) {
|
||||
velocity.y = 20;
|
||||
Registry.sound_data.start_song_from_title("GO");
|
||||
Water_Anim.START_WATER_ANIMF();
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
alpha += 0.02;
|
||||
if (Registry.volume_scale < 1) {
|
||||
Registry.volume_scale += 0.02;
|
||||
} else {
|
||||
Registry.volume_scale = 1;
|
||||
}
|
||||
|
||||
if (y > tl.y + 43) {
|
||||
velocity.y = 0;
|
||||
velocity.x = -20;
|
||||
Registry.GE_States[Registry.GE_Briar_Blue_Done] = true;
|
||||
play("walk_l");
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (x < tl.x - 16) {
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
is_finished_blue = true;
|
||||
xml.@alive = "false";
|
||||
exists = false;
|
||||
player.state = player.S_GROUND;
|
||||
DH.enable_menu();
|
||||
break;
|
||||
|
||||
// 15. Briar walks left and elaves.
|
||||
}
|
||||
}
|
||||
|
||||
private function update_happy():void {
|
||||
|
||||
switch (ctr) {
|
||||
case 0: // Wait until switch is pressed
|
||||
if (Registry.GRID_PUZZLES_DONE > 0) {
|
||||
ctr++;
|
||||
player.be_idle();
|
||||
player.state = player.S_INTERACT;
|
||||
DH.disable_menu();
|
||||
play("walk_d");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
Registry.volume_scale -= 0.01;
|
||||
if (Registry.volume_scale <= 0) {
|
||||
ctr++;
|
||||
Registry.sound_data.stop_current_song();
|
||||
Registry.GE_States[Registry.GE_Briar_Happy_Done] = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// walk downwards a bit, fading in. remove palyer control
|
||||
alpha += 0.004;
|
||||
Registry.volume_scale += 0.004;
|
||||
if (alpha > 0.4) {
|
||||
velocity.y = 20;
|
||||
if (Registry.sound_data.current_song != null && !Registry.sound_data.current_song.playing ) {
|
||||
Water_Anim.START_WATER_ANIMF();
|
||||
Registry.sound_data.start_song_from_title("GO");
|
||||
}
|
||||
}
|
||||
if (y >= tl.y + 44) {
|
||||
velocity.y = 0;
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
alpha = 1;
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// walk to the right, out of the screen
|
||||
if (x > tl.x + 16 * 10) {
|
||||
visible = false;
|
||||
velocity.x = 0;
|
||||
ctr++;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
player.state = player.S_GROUND;
|
||||
DH.enable_menu();
|
||||
is_finished_happy = true;
|
||||
Registry.GE_States[Registry.GE_Briar_Happy_Done] = true;
|
||||
xml.@alive = "false";
|
||||
exists = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function update_beach():void {
|
||||
|
||||
switch (ctr) {
|
||||
case 0:
|
||||
play("walk_d");
|
||||
velocity.y = 20;
|
||||
alpha += 0.007;
|
||||
if (alpha >= 1) {
|
||||
ctr++;
|
||||
play("idle_d");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
velocity.y = 0;
|
||||
|
||||
if (player.overlaps(this)) {
|
||||
ctr++;
|
||||
velocity.y = 15;
|
||||
play("walk_d");
|
||||
xml.@alive = "false";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
alpha -= 0.01;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function update_forest():void {
|
||||
switch (ctr) {
|
||||
case 0:
|
||||
play("walk_u");
|
||||
velocity.y = -20;
|
||||
alpha += 0.005;
|
||||
if (y < tl.y - 16) {
|
||||
xml.@alive = "false";
|
||||
exists = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
|
||||
public class Space_NPC extends AnoSprite
|
||||
{
|
||||
[Embed(source = "../../../res/sprites/npcs/space_npcs.png")] public static var embed_space_npc:Class;
|
||||
private var type:int;
|
||||
public var active_region:FlxObject;
|
||||
private const T_COLOR_DEAD:int = 0;
|
||||
private const T_GREY_DEAD:int = 1;
|
||||
private const T_GREY_SPIN:int = 2;
|
||||
private const T_COLOR1:int = 3;
|
||||
private const T_COLOR2:int = 4;
|
||||
private const T_COLOR3:int = 5;
|
||||
private const T_GRAY1:int = 6;
|
||||
private const T_GRAY2:int = 7;
|
||||
private const T_GRAY3:int = 8;
|
||||
|
||||
|
||||
public function Space_NPC(a:Array)
|
||||
{
|
||||
super(a);
|
||||
|
||||
active_region = new FlxObject(0, 0, 20, 20);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
loadGraphic(embed_space_npc, true, false, 16, 16);
|
||||
var f:int = parseInt(xml.@frame);
|
||||
switch (f) {
|
||||
case 0: //gray geom
|
||||
case 1:
|
||||
case 3:
|
||||
if (f == 0) {
|
||||
type = T_GRAY1;
|
||||
} else if (f == 3) {
|
||||
type = T_GRAY3;
|
||||
} else {
|
||||
type = T_GRAY2;
|
||||
}
|
||||
addAnimation("walk_d", [0, 1], 4);
|
||||
addAnimation("walk_r", [2,3], 4);
|
||||
addAnimation("walk_u", [4,5], 4);
|
||||
addAnimation("walk_l", [6, 7], 4);
|
||||
play("walk_d");
|
||||
break;
|
||||
case 2:
|
||||
addAnimation("spin", [0, 2, 4, 6], 10);
|
||||
play("spin");
|
||||
type = T_GREY_SPIN;
|
||||
break;
|
||||
|
||||
case 8: // sleeping/dead geom
|
||||
alive = false;
|
||||
type = T_COLOR_DEAD;
|
||||
|
||||
addAnimation("dead", [8], 4);
|
||||
play("dead");
|
||||
|
||||
break;
|
||||
case 10: //color geom
|
||||
case 11:
|
||||
case 12:
|
||||
if (f == 10) {
|
||||
type = T_COLOR1;
|
||||
} else if (f == 11) {
|
||||
type = T_COLOR2;
|
||||
} else if (f == 12) {
|
||||
type = T_COLOR3;
|
||||
}
|
||||
addAnimation("walk_d", [10,11], 4);
|
||||
addAnimation("walk_r", [12,13], 4);
|
||||
addAnimation("walk_u", [14,15], 4);
|
||||
addAnimation("walk_l", [16,17], 4);
|
||||
play("walk_d");
|
||||
break;
|
||||
case 18: // sleep color geom
|
||||
alive = false;
|
||||
type = T_GREY_DEAD;
|
||||
addAnimation("dead", [18], 4);
|
||||
play("dead");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
immovable = true;
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
|
||||
if (alive) {
|
||||
if (type == T_GREY_SPIN) {
|
||||
if (DH.nc(player, active_region)) {
|
||||
DH.start_dialogue(DH.name_geoms, "grayspin");
|
||||
}
|
||||
} else if (type == T_GRAY1) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"gray1");
|
||||
} else if (type == T_GRAY2) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"gray2");
|
||||
} else if (type == T_GRAY3) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"gray3");
|
||||
} else if (type == T_COLOR1) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"color1");
|
||||
} else if (type == T_COLOR2) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"color2");
|
||||
} else if (type == T_COLOR3) {
|
||||
if (DH.nc(player, active_region)) DH.start_dialogue(DH.name_geoms,"color3");
|
||||
}
|
||||
|
||||
if (type != T_GREY_SPIN) {
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
}
|
||||
} else {
|
||||
if (DH.nc(player, active_region)) {
|
||||
if (type == T_GREY_DEAD) {
|
||||
DH.start_dialogue(DH.name_geoms, "graydead");
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_geoms, "colordead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,811 @@
|
|||
package entity.interactive.npc
|
||||
{
|
||||
import data.CLASS_ID;
|
||||
import entity.gadget.Dust;
|
||||
import entity.gadget.Treasure;
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import helper.EventScripts;
|
||||
import org.flixel.AnoSprite;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxGroup;
|
||||
import org.flixel.FlxSprite;
|
||||
import states.PauseState;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @author Melos Han-Tani
|
||||
*/
|
||||
public class Trade_NPC extends AnoSprite
|
||||
{
|
||||
|
||||
public static const cid:int = CLASS_ID.TRADE_NPC;
|
||||
private static const T_CAT:int = 0;
|
||||
private static const T_MONSTER_OUT:int = 2;
|
||||
private static const T_MONSTER_IN:int = 1;
|
||||
private static const T_SHOP:int = 3;
|
||||
private static const T_ICKY:int = 4;
|
||||
|
||||
public var active_region:FlxSprite;
|
||||
private var do_update:Function;
|
||||
|
||||
public static var cat_ref:FlxSprite;
|
||||
public static var cat_dust_ref:FlxSprite;
|
||||
private static const s_cat_wait:int = 0;
|
||||
private static const s_cat_follow:int = 1;
|
||||
private static const s_cat_water:int = 2;
|
||||
private static const s_cat_init_scene:int = 3;
|
||||
|
||||
private var monster_box:FlxSprite;
|
||||
private var monster_box_ar:FlxSprite;
|
||||
private var other_cat:FlxSprite;
|
||||
private const s_monst_out_present:int = 0;
|
||||
private const s_monst_out_gone:int = 1;
|
||||
private const s_monst_out_spooked:int = 2;
|
||||
|
||||
|
||||
private const s_monst_in_unhelped:int = 0;
|
||||
private const s_monst_in_helped:int = 1;
|
||||
private const s_monst_in_giving:int = 2;
|
||||
private var dusts:FlxGroup;
|
||||
|
||||
private var items:FlxGroup;
|
||||
private var card:FlxSprite;
|
||||
private const s_shop_helped:int = 0;
|
||||
private const s_shop_unhelped:int = 1;
|
||||
|
||||
private var ctr:int = 0;
|
||||
|
||||
[Embed(source = "../../../res/sprites/npcs/fields_npcs.png")] public static const embed_dame_trade_npc:Class;
|
||||
|
||||
|
||||
public function Trade_NPC(args:Array)
|
||||
{
|
||||
super(args);
|
||||
|
||||
immovable = true;
|
||||
active_region = new FlxSprite(0, 0);
|
||||
active_region.makeGraphic(20, 20, 0x00000000);
|
||||
Registry.subgroup_interactives.push(this);
|
||||
|
||||
// Registry.cleanup_on_map_change dealsw ith removnig the cat from memory.
|
||||
switch (parseInt(xml.@frame)) {
|
||||
case T_CAT:
|
||||
if (cat_ref == null) {
|
||||
loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
addAnimation("walk_d", [0,1], 4);
|
||||
addAnimation("walk_r", [2,3], 4);
|
||||
addAnimation("walk_u", [4,5], 4);
|
||||
addAnimation("walk_l", [6, 7], 4);
|
||||
width = height = 12;
|
||||
offset.x = offset.y = 2;
|
||||
play("walk_d");
|
||||
parent.bg_sprites.add(this);
|
||||
state = s_cat_wait;
|
||||
do_update = u_cat;
|
||||
|
||||
cat_dust_ref = new FlxSprite;
|
||||
cat_dust_ref.loadGraphic(Dust.DUST_SPRITE, true, false, 16, 16);
|
||||
cat_dust_ref.addAnimation("poof", [0, 1, 2, 3, 4], 13, false);
|
||||
cat_dust_ref.addAnimation("unpoof", [3, 2, 1, 0], 13, false);
|
||||
cat_dust_ref.visible = false;
|
||||
parent.sortables.add(cat_dust_ref);
|
||||
cat_dust_ref.frame = Dust.EMPTY_FRAME;
|
||||
|
||||
} else {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case T_MONSTER_OUT:
|
||||
|
||||
|
||||
|
||||
if (false == Registry.inventory[Registry.IDX_BOX] && false == Registry.GE_States[Registry.GE_tradequesthelpedshopkeeper]) { // Box is not taken, and not given to shop guy yet.
|
||||
|
||||
monster_box = new FlxSprite(x, y - 20);
|
||||
monster_box.loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
monster_box.addAnimation("closed", [31], 1);
|
||||
monster_box.addAnimation("open", [32], 1);
|
||||
monster_box.play("closed");
|
||||
monster_box.immovable = true;
|
||||
monster_box_ar = new FlxSprite(x, y);
|
||||
|
||||
other_cat = new FlxSprite(x, y - 30);
|
||||
other_cat.loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
other_cat.addAnimation("walk_d", [10,11], 4);
|
||||
other_cat.addAnimation("walk_r", [12,13], 4);
|
||||
other_cat.addAnimation("walk_u", [14,15], 4);
|
||||
other_cat.addAnimation("walk_l", [16,17], 4);
|
||||
other_cat.play("walk_d");
|
||||
other_cat.visible = false;
|
||||
|
||||
parent.sortables.add(monster_box);
|
||||
parent.sortables.add(other_cat);
|
||||
}
|
||||
|
||||
// already spooked
|
||||
if (Registry.GE_States[Registry.GE_tradequestspookedmonster]) {
|
||||
visible = false;
|
||||
// If we have the box or have given it to the shopkeeper
|
||||
// then do not make anything appear.
|
||||
if (Registry.inventory[Registry.IDX_BOX] || Registry.GE_States[Registry.GE_tradequesthelpedshopkeeper]) {
|
||||
exists = false;
|
||||
}
|
||||
state = s_monst_out_gone;
|
||||
} else { // not spooked
|
||||
loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
addAnimation("walk_d", [20,21], 4);
|
||||
addAnimation("walk_r", [22,23], 4);
|
||||
addAnimation("walk_u", [24,25], 4);
|
||||
addAnimation("walk_l", [26,27], 4);
|
||||
play("walk_d");
|
||||
state = s_monst_out_present;
|
||||
}
|
||||
|
||||
do_update = u_monster_out;
|
||||
break;
|
||||
case T_MONSTER_IN:
|
||||
|
||||
if (Registry.GE_States[Registry.GE_tradequestspookedmonster]) {
|
||||
|
||||
loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
addAnimation("walk_d", [20,21], 4);
|
||||
addAnimation("walk_r", [22,23], 4);
|
||||
addAnimation("walk_u", [24,25], 4);
|
||||
addAnimation("walk_l", [26,27], 4);
|
||||
play("walk_d");
|
||||
if (Registry.GE_States[Registry.GE_tradequesthelpedmonster]) {
|
||||
state = s_monst_in_helped;
|
||||
|
||||
} else {
|
||||
state = s_monst_in_unhelped;
|
||||
|
||||
dusts = new FlxGroup(3);
|
||||
for (var i:int = 0; i < dusts.maxSize; i++) {
|
||||
var dust:Dust = new Dust(0, 0, null, parent);
|
||||
dust.x = tl.x + 16;
|
||||
dust.y = tl.y + 16 + 32 * i;
|
||||
dusts.add(dust);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
parent.bg_sprites.add(dusts);
|
||||
|
||||
do_update = u_monster_in;
|
||||
break;
|
||||
case T_SHOP:
|
||||
loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
addAnimation("a", [50,51], 4);
|
||||
play("a");
|
||||
if (Registry.GE_States[Registry.GE_tradequesthelpedshopkeeper]) {
|
||||
state = s_shop_helped;
|
||||
} else {
|
||||
state = s_shop_unhelped;
|
||||
}
|
||||
|
||||
items = new FlxGroup(3);
|
||||
for (i = 0; i < 3; i++) {
|
||||
var item:FlxSprite = new FlxSprite;
|
||||
item.loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
if (i == 2) {
|
||||
if (state == s_shop_helped || Registry.inventory[Registry.IDX_JUMP]) {
|
||||
item.frame = 57;
|
||||
} else {
|
||||
item.frame = 56;
|
||||
}
|
||||
} else {
|
||||
item.frame = 54 + i;
|
||||
}
|
||||
|
||||
item.x = x - 30 + 34 * i;
|
||||
item.y = y + 32;
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
parent.bg_sprites.add(items);
|
||||
card = new FlxSprite;
|
||||
card.loadGraphic(PauseState.card_sheet_embed, true, false, 24, 24);
|
||||
card.frame = Registry.CARD_GOLDMAN_IDX;
|
||||
card.visible = false;
|
||||
parent.fg_sprites.add(card);
|
||||
do_update = u_shop;
|
||||
break;
|
||||
case T_ICKY:
|
||||
if (Registry.GE_States[Registry.GE_tradequestspookedmonster] == false) {
|
||||
exists = false;
|
||||
}
|
||||
loadGraphic(embed_dame_trade_npc, true, false, 16, 16);
|
||||
addAnimation("walk_d", [10,11], 4);
|
||||
addAnimation("walk_r", [12,13], 4);
|
||||
addAnimation("walk_u", [14,15], 4);
|
||||
addAnimation("walk_l", [16, 17], 4);
|
||||
play("walk_d");
|
||||
do_update = u_icky;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy():void
|
||||
{
|
||||
parent.sortables.remove(monster_box,true);
|
||||
if (monster_box != null) {
|
||||
monster_box.destroy();
|
||||
monster_box = null;
|
||||
}
|
||||
|
||||
parent.sortables.remove(other_cat,true);
|
||||
if (other_cat != null) {
|
||||
other_cat.destroy();
|
||||
other_cat = null;
|
||||
}
|
||||
|
||||
|
||||
parent.intra_bg_bg2_sprites.remove(dusts, true);
|
||||
if (dusts != null) {
|
||||
dusts.destroy();
|
||||
dusts = null;
|
||||
}
|
||||
|
||||
card = null;
|
||||
items = null;
|
||||
|
||||
|
||||
active_region.destroy();
|
||||
active_region = null;
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
do_update();
|
||||
super.update();
|
||||
}
|
||||
|
||||
public var midpoint:Point = new Point();
|
||||
public var ON_CONVEYER:Boolean = false;
|
||||
override public function preUpdate():void
|
||||
{
|
||||
|
||||
|
||||
if (parseInt(xml.@frame) == T_CAT) {
|
||||
FlxG.collide(this, parent.curMapBuf);
|
||||
}
|
||||
super.preUpdate();
|
||||
|
||||
}
|
||||
|
||||
private function u_icky():void {
|
||||
EventScripts.face_and_play(this, player, "walk");
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
immovable = true;
|
||||
FlxG.collide(player, this);
|
||||
if (DH.nc(player, active_region)) {
|
||||
DH.start_dialogue(DH.name_miao, "icky");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var t_talk:Number = 0;
|
||||
private var tm_talk:Number = 2.5;
|
||||
private static const cat_idx_shop:int = 0;
|
||||
private static const cat_idx_mitra:int = 1;
|
||||
private static const cat_idx_nexus:int = 2;
|
||||
private static const cat_idx_icky_worry:int = 3;
|
||||
private static const cat_idx_leave_map:int = 4;
|
||||
private var hasnt_left:Boolean = true; // said the leave map dialogue?
|
||||
|
||||
private function u_cat():void {
|
||||
|
||||
midpoint.x = x + (width / 2);
|
||||
midpoint.y = y + (height / 2);
|
||||
switch (state) {
|
||||
case s_cat_wait:
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
FlxG.collide(this, player);
|
||||
if (player.overlaps(active_region) && false == DH.a_chunk_is_playing() && Registry.keywatch.JP_ACTION_1) {
|
||||
if (true == Registry.GE_States[Registry.GE_tradequestspookedmonster] && false == DH.scene_is_finished(DH.name_miao, DH.scene_miao_philosophy)) {
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_philosophy);
|
||||
player.be_idle();
|
||||
return;
|
||||
}
|
||||
if (DH.scene_is_dirty(DH.name_miao, DH.scene_miao_init)) {
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_init, "", 2);
|
||||
state = s_cat_follow;
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_init);
|
||||
state = s_cat_init_scene;
|
||||
ctr = 0;
|
||||
}
|
||||
player.be_idle();
|
||||
cat_ref = this;
|
||||
parent.bg_sprites.remove(cat_ref, true);
|
||||
parent.sortables.add(cat_ref);
|
||||
}
|
||||
break;
|
||||
case s_cat_init_scene:
|
||||
if (ctr == 0) {
|
||||
if (false == DH.a_chunk_is_playing()) {
|
||||
ctr = 1;
|
||||
//Attack
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
// When attack over
|
||||
ctr = 2;
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_init);
|
||||
player.be_idle();
|
||||
state = s_cat_follow;
|
||||
}
|
||||
break;
|
||||
case s_cat_follow:
|
||||
immovable = false;
|
||||
// jank
|
||||
if (EventScripts.get_tile_nr(midpoint.x, midpoint.y, parent.curMapBuf) == 250) {
|
||||
ON_CONVEYER = true;
|
||||
}
|
||||
|
||||
if (EventScripts.distance(player.midpoint, midpoint) > 16) {
|
||||
EventScripts.scale_vector(midpoint, player.midpoint, velocity, 70);
|
||||
} else {
|
||||
velocity.x = velocity.y = 0;
|
||||
}
|
||||
|
||||
if (touching & (UP | DOWN)) {
|
||||
velocity.y = 0;
|
||||
}
|
||||
|
||||
if (touching & (LEFT | RIGHT)) {
|
||||
velocity.x = 0;
|
||||
}
|
||||
|
||||
if (velocity.x == 0 && velocity.y == 0) {
|
||||
// Do nothing
|
||||
} else if (Math.abs(velocity.x) > Math.abs(velocity.y)) {
|
||||
if (velocity.x > 0) {
|
||||
play("walk_r");
|
||||
} else {
|
||||
play("walk_l");
|
||||
}
|
||||
} else {
|
||||
if (velocity.y > 0) {
|
||||
play("walk_d");
|
||||
} else {
|
||||
play("walk_u");
|
||||
}
|
||||
}
|
||||
|
||||
// Determine events
|
||||
gx = Registry.CURRENT_GRID_X;
|
||||
gy = Registry.CURRENT_GRID_Y;
|
||||
|
||||
if (gx == 7 && gy == 4) { // shop
|
||||
if (DH.get_int_property(DH.name_shopkeeper,"talkedto") != -1) {
|
||||
if (t_talk > tm_talk) t_talk = 0; // Want the timer to be local to this room
|
||||
t_talk += FlxG.elapsed;
|
||||
if (false == DH.a_chunk_is_playing() && t_talk > tm_talk && DH.get_int_property(DH.name_miao, "shop") == -1) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", cat_idx_shop);
|
||||
player.be_idle();
|
||||
DH.increment_property(DH.name_miao, "shop");
|
||||
}
|
||||
}
|
||||
} else if (gx == 5 && gy == 4) { // Mitra
|
||||
if (false == DH.a_chunk_is_playing() && DH.scene_is_dirty(DH.name_mitra, DH.scene_mitra_fields_init) == true) {
|
||||
if (t_talk > tm_talk) t_talk = 0;
|
||||
t_talk += FlxG.elapsed;
|
||||
if (t_talk > tm_talk && DH.get_int_property(DH.name_miao, "mitra") == -1) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
player.be_idle();
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", cat_idx_mitra);
|
||||
player.be_idle();
|
||||
DH.increment_property(DH.name_miao, "mitra");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (gx == 6 && gy == 3) { // Nexus pad
|
||||
if (t_talk > tm_talk) t_talk = 0;
|
||||
t_talk += FlxG.elapsed;
|
||||
if (t_talk > tm_talk && DH.get_int_property(DH.name_miao, "nexus") == -1) {
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", cat_idx_nexus);
|
||||
player.be_idle();
|
||||
DH.increment_property(DH.name_miao, "nexus");
|
||||
}
|
||||
|
||||
} else {
|
||||
t_talk += FlxG.elapsed;
|
||||
if (t_talk > 70 && DH.a_chunk_is_playing() == false) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
t_talk = 0;
|
||||
if (Registry.GE_States[Registry.GE_tradequestspookedmonster] == false) {
|
||||
player.be_idle();
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", cat_idx_icky_worry);
|
||||
} else if (DH.get_int_property(DH.name_miao,"nexus") != -1 && DH.get_int_property(DH.name_miao,"mitra") != -1 && DH.get_int_property(DH.name_miao,"shop") != -1) {
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", 5 + int(3 * Math.random()));
|
||||
trace("Saying random");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Say something if you leave the map
|
||||
if ( // 3,3 7,5
|
||||
(Registry.CURRENT_GRID_Y < 2 || Registry.CURRENT_GRID_Y > 5 || Registry.CURRENT_GRID_X < 3 || Registry.CURRENT_GRID_X > 7)
|
||||
|| (Registry.GAMESTATE.SWITCH_MAPS == true && hasnt_left == true) ) {
|
||||
hasnt_left = false;
|
||||
player.be_idle();
|
||||
leavingleaving = true;
|
||||
DH.start_dialogue(DH.name_miao, DH.scene_miao_randoms, "", cat_idx_leave_map);
|
||||
}
|
||||
|
||||
if (leavingleaving && Registry.GAMESTATE.state != Registry.GAMESTATE.S_TRANSITION) {
|
||||
Registry.GAMESTATE.sortables.remove(Trade_NPC.cat_ref, true);
|
||||
Registry.GAMESTATE.sortables.remove(Trade_NPC.cat_dust_ref, true);
|
||||
state = s_cat_water;
|
||||
cat_ref = null;
|
||||
cat_dust_ref = null;
|
||||
}
|
||||
// go to water
|
||||
//if distance > 16 from center, move towardsplayer
|
||||
|
||||
if (cat_dust_ref != null) {
|
||||
cat_dust_ref.x = x - 2;
|
||||
cat_dust_ref.y = y;
|
||||
cat_dust_ref.height = 3;
|
||||
|
||||
if (player.ON_CONVEYER) ON_CONVEYER = true;
|
||||
if (ON_CONVEYER && cat_dust_ref.frame == Dust.EMPTY_FRAME) {
|
||||
cat_dust_ref.play("unpoof");
|
||||
cat_dust_ref.visible = true;
|
||||
} else if (!ON_CONVEYER && cat_dust_ref.frame == 0) {
|
||||
cat_dust_ref.play("poof");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case s_cat_water:
|
||||
break;
|
||||
}
|
||||
|
||||
ON_CONVEYER = false;
|
||||
}
|
||||
private var leavingleaving:Boolean = false;
|
||||
|
||||
private static const goldman_idx_run_away:int = 0;
|
||||
private static const goldman_idx_give_card:int = 1;
|
||||
private static const goldman_idx_box_open:int = 2;
|
||||
private static const goldman_idx_icky_thx:int = 3;
|
||||
private function u_monster_out():void {
|
||||
if (state == s_monst_out_present) {
|
||||
if (visible) {
|
||||
FlxG.collide(this, player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (monster_box.visible) {
|
||||
FlxG.collide(player, monster_box);
|
||||
}
|
||||
|
||||
// Monster present, run away if you have the cat
|
||||
if (state == s_monst_out_present) {
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
|
||||
if (DH.a_chunk_is_playing() == false && player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
if (cat_ref == null) {
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_outside);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc,"",goldman_idx_run_away);
|
||||
Registry.GE_States[Registry.GE_tradequestspookedmonster] = true;
|
||||
state = s_monst_out_spooked;
|
||||
}
|
||||
}
|
||||
// Mosnster, animate it running into cave
|
||||
} else if (state == s_monst_out_spooked) {
|
||||
if (ctr == 0) {
|
||||
player.state = player.S_INTERACT;
|
||||
if (false == DH.a_chunk_is_playing()) {
|
||||
velocity.y = -40;
|
||||
play("walk_u");
|
||||
ctr = 1;
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
if (y < tl.y + 6 * 16) {
|
||||
play("walk_r");
|
||||
velocity.y = 0;
|
||||
velocity.x = 40;
|
||||
if (x > tl.x + 160) {
|
||||
visible = false;
|
||||
player.state = player.S_GROUND;
|
||||
ctr = 0;
|
||||
state = s_monst_out_gone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Monster gone. If we're here wait till we interact with box
|
||||
// then make it dispappear, small cat pops out, state, etc.
|
||||
} else if (state == s_monst_out_gone) {
|
||||
monster_box_ar.x = monster_box.x - 2;
|
||||
monster_box_ar.y = monster_box.y + 2;
|
||||
|
||||
if (ctr == 0) {
|
||||
if (DH.a_chunk_is_playing() == false && player.overlaps(monster_box_ar) && Registry.keywatch.JP_ACTION_1) {
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
Registry.sound_data.broom_hit.play();
|
||||
player.actions_disabled = true;
|
||||
player.be_idle();
|
||||
DH.disable_menu();
|
||||
ctr = 1;
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc, "", goldman_idx_box_open);
|
||||
monster_box.frame += 1;
|
||||
Registry.inventory[Registry.IDX_BOX] = true;
|
||||
}
|
||||
} else if (ctr == 1) {
|
||||
player.actions_disabled = true;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
other_cat.visible = true;
|
||||
monster_box.visible = false; // make box disappear
|
||||
monster_box_ar.x -= 1000;
|
||||
player.state = player.S_INTERACT;
|
||||
player.be_idle();
|
||||
other_cat.velocity.x = 20;
|
||||
other_cat.play("walk_r");
|
||||
ctr = 2;
|
||||
}
|
||||
|
||||
} else if (ctr == 2) {
|
||||
if (other_cat.x > tl.x + 85) {
|
||||
other_cat.velocity.x = 0;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
ctr = 3;
|
||||
Registry.GAMESTATE.dialogue_latency = -1;
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc,"", goldman_idx_icky_thx);
|
||||
other_cat.play("walk_d");
|
||||
}
|
||||
}
|
||||
} else if ( ctr == 3) {
|
||||
player.actions_disabled = true;
|
||||
player.state = player.S_INTERACT;
|
||||
if (DH.a_chunk_is_playing() == false) {
|
||||
player.state = player.S_GROUND;
|
||||
DH.enable_menu();
|
||||
other_cat.play("walk_r");
|
||||
other_cat.velocity.x = 40;
|
||||
ctr = 4;
|
||||
}
|
||||
} else if (ctr == 4) {
|
||||
if (other_cat.x > tl.x + 6 * 16) {
|
||||
other_cat.velocity.x = 0;
|
||||
other_cat.play("walk_d");
|
||||
ctr++;
|
||||
}
|
||||
} else if (ctr == 5) {
|
||||
monster_box_ar.x = other_cat.x - 2;
|
||||
monster_box_ar.y = other_cat.y - 2;
|
||||
monster_box_ar.width = 20;
|
||||
monster_box_ar.height = 20;
|
||||
|
||||
other_cat.immovable = true;
|
||||
FlxG.collide(player, other_cat);
|
||||
if (player.overlaps(monster_box_ar)) {
|
||||
player.actions_disabled = true;
|
||||
}
|
||||
if (DH.nc(player, monster_box_ar)) {
|
||||
player.actions_disabled = true;
|
||||
player.be_idle();
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc,"",goldman_idx_icky_thx+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function u_monster_in():void {
|
||||
FlxG.collide(this, player);
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
if (DH.a_chunk_is_playing() == false && player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
if (Registry.GE_States[Registry.GE_tradequesthelpedmonster]) {
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc, "", goldman_idx_give_card);
|
||||
} else {
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_inside);
|
||||
}
|
||||
}
|
||||
|
||||
if (state == s_monst_in_unhelped) {
|
||||
var exists_ct:int = 0;
|
||||
for each (var dust:Dust in dusts.members) {
|
||||
|
||||
if (!dust.fell_in_hole) {
|
||||
exists_ct ++;
|
||||
}
|
||||
}
|
||||
|
||||
for each (dust in Registry.subgroup_dust) {
|
||||
if (dust != null && !dust.fell_in_hole) {
|
||||
exists_ct += 1;
|
||||
}
|
||||
}
|
||||
if (exists_ct == 0) {
|
||||
state = s_monst_in_giving;
|
||||
}
|
||||
} else if (state == s_monst_in_helped) {
|
||||
x = tl.x + 16 * 7;
|
||||
} else if (state == s_monst_in_giving) {
|
||||
if (ctr == 0) {
|
||||
DH.start_dialogue(DH.name_goldman, DH.scene_goldman_etc, "", goldman_idx_give_card);
|
||||
ctr = 1;
|
||||
} else if (ctr == 1) {
|
||||
// give gift
|
||||
Registry.GE_States[Registry.GE_tradequesthelpedmonster] = true;
|
||||
ctr = 2;
|
||||
} else if (ctr == 2) {
|
||||
velocity.x = 20;
|
||||
play("walk_r");
|
||||
if (x > tl.x + 16 * 7) {
|
||||
velocity.x = 0;
|
||||
play("walk_d");
|
||||
state = s_monst_in_helped;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var shop_start_anim:Boolean = false;
|
||||
private var shop_array:Array = new Array(false, false, false, false);
|
||||
private var shop_card_start:Boolean = false;
|
||||
private var shop_ctr:int = 0;
|
||||
|
||||
private function u_shop():void {
|
||||
FlxG.collide(this, player);
|
||||
active_region.x = x - 2;
|
||||
active_region.y = y - 2;
|
||||
|
||||
//if (FlxG.keys.justPressed("B")) {
|
||||
//Registry.inventory[Registry.IDX_BOX] = true;
|
||||
//} else if (FlxG.keys.justPressed("W")) {
|
||||
//Registry.inventory[Registry.IDX_JUMP] = true;
|
||||
//Registry.card_states[Registry.CARD_GOLDMAN_IDX] = 1;
|
||||
//} else if (FlxG.keys.justPressed("Q")) {
|
||||
//Registry.inventory[Registry.IDX_JUMP] = true;
|
||||
//Registry.card_states[Registry.CARD_GOLDMAN_IDX] = 0;
|
||||
//} else if (FlxG.keys.justPressed("R")) {
|
||||
//state = s_shop_unhelped;
|
||||
//}
|
||||
|
||||
if (shop_card_start) {
|
||||
if (shop_ctr == 0) {
|
||||
if (parent.state != parent.S_DIALOGUE) {
|
||||
card.visible = true;
|
||||
card.x = player.x - 8;
|
||||
card.y = player.y - 8;
|
||||
Registry.sound_data.get_treasure.play();
|
||||
shop_ctr ++;
|
||||
}
|
||||
} else if (shop_ctr == 1) {
|
||||
card.flicker(2);
|
||||
shop_ctr++;
|
||||
} else if (shop_ctr == 2) {
|
||||
if (card.flickering == false) {
|
||||
card.exists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Registry.PLAYSTATE.state != Registry.PLAYSTATE.S_DIALOGUE && player.overlaps(active_region) && Registry.keywatch.JP_ACTION_1) {
|
||||
player.be_idle();
|
||||
if (DH.get_int_property(DH.name_shopkeeper, "talkedto") == -1) {
|
||||
DH.increment_property(DH.name_shopkeeper, "talkedto");
|
||||
//DH.dialogue_popup("Finty: Welcome, welcome, my friend Young! The name’s Prasandhoff--Finty Prasandhoff! Take a look around at my shop and see if anything catches your eye!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 0));
|
||||
}else if (state == s_shop_helped) {
|
||||
//DH.dialogue_popup("Finty: I still appreciate that box!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 1));
|
||||
} else {
|
||||
if (Registry.inventory[Registry.IDX_BOX]) {
|
||||
Registry.inventory[Registry.IDX_BOX] = false;
|
||||
state = s_shop_helped;
|
||||
Registry.GE_States[Registry.GE_tradequesthelpedshopkeeper] = true;
|
||||
if (Registry.inventory[Registry.IDX_JUMP] && Registry.card_states[Registry.CARD_GOLDMAN_IDX]) {
|
||||
//DH.dialogue_popup("Finty: Ah, a box! Thank you so much! Now I can carry all my inventory home at night and back in the morning! As a token of my gratitude, take this ugly--I mean beautiful, collector's edition card!^ Wait a minute...it's not here! What happened to it? Well, here, let me ease your wounds instead!");//Goldman card
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 2)+" "+DH.lk("tradenpc",11)+" "+DH.lk("tradenpc",3));
|
||||
player.health_bar.modify_health(20);
|
||||
} else if (Registry.inventory[Registry.IDX_JUMP] && Registry.card_states[Registry.CARD_GOLDMAN_IDX] == 0) {
|
||||
//DH.dialogue_popup("Finty: Ah, a box! Thank you so much! Now I can carry all my inventory home at night and back in the morning! As a token of my gratitude, take this ugly--I mean beautiful, collector's edition card!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 2)+" "+DH.lk("tradenpc", 11));
|
||||
Registry.card_states[Registry.CARD_GOLDMAN_IDX] = 1;
|
||||
Registry.nr_growths++;
|
||||
shop_card_start = true;
|
||||
} else {
|
||||
//DH.dialogue_popup("Finty: Ah, a box! Thank you so much! Now I can carry all my inventory home at night and back in the morning! As a token of my gratitude, take these stylish biking shoes!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 2)+" "+DH.lk("tradenpc",4));
|
||||
Registry.inventory[Registry.IDX_BIKE_SHOES] = true;
|
||||
shop_start_anim = true;
|
||||
}
|
||||
// Give the player the BIKE SHOEZ or a NICE GIFT
|
||||
} else {
|
||||
//DH.dialogue_popup("Fine morning out, isn't it, my friend? A fine morning for shopping! I just wish I had a box to carry my inventory around.");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (shop_start_anim) {
|
||||
|
||||
if (items.members[2].frame != 57) {
|
||||
items.members[2].acceleration.y = -10;
|
||||
|
||||
if (items.members[2].velocity.y < -10 && items.members[2].velocity.y > -15) {
|
||||
items.members[2].flicker(1);
|
||||
}
|
||||
|
||||
if (items.members[2].velocity.y < -25) {
|
||||
if (items.members[2].flickering == false) {
|
||||
items.members[2].alpha = 0;
|
||||
items.members[2].velocity.y = items.members[2].acceleration.y = 0;
|
||||
items.members[2].y = items.members[1].y;
|
||||
items.members[2].frame = 57;
|
||||
}
|
||||
}
|
||||
} else if (items.members[2].frame == 57) {
|
||||
items.members[2].alpha += 0.01;
|
||||
if (items.members[2].alpha >= 1) {
|
||||
shop_start_anim = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for each (var item:FlxSprite in items.members) {
|
||||
item.immovable = true;
|
||||
FlxG.collide(player, item);
|
||||
if (player.x < item.x + item.width + 2 && player.x + player.width > item.x - 2&& player.y < item.y + item.height + 2 && player.y +player.height > item.y - 2) {
|
||||
if (DH.a_chunk_is_playing() == false && Registry.keywatch.JP_ACTION_1) {
|
||||
player.actions_disabled = true;
|
||||
player.be_idle();
|
||||
if (shop_array[item.frame - 54]) {
|
||||
DH.dialogue_popup("Too bad, looks like you can't afford this item! Come back later, when you have the cash!");
|
||||
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 6));
|
||||
break;
|
||||
}
|
||||
switch (item.frame) {
|
||||
case 54:
|
||||
//DH.dialogue_popup("Finty: Ah, you have a fine eye! You need a better weapon, don't you? Blow your enemies to pieces for only $499.99!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 7));
|
||||
shop_array[0] = true;
|
||||
break;
|
||||
case 55:
|
||||
//DH.dialogue_popup("Finty: That money sack will allow you to accumulate money that you find in The Land! It's yours for a mere $869.99!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 8));
|
||||
shop_array[1] = true;
|
||||
break;
|
||||
case 56:
|
||||
//DH.dialogue_popup("Finty: Oh ho ho, here's a specialty item indeed: clip-in bike shoes so you can be speedy AND stylish! On sale now for just $299.99!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 9));
|
||||
shop_array[2] = true;
|
||||
break;
|
||||
case 57:
|
||||
//DH.dialogue_popup("Finty: Tired of shoving dust around with your piddling little broom? Eradicate harmful dust particles with this state-of-The-Art vacuum cleaner! Just $749.99, or four easy, monthly payments of $199.99!");
|
||||
DH.dialogue_popup(DH.lk("tradenpc", 10));
|
||||
shop_array[3] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
package entity.player
|
||||
{
|
||||
import entity.gadget.Dust;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxG;
|
||||
import global.Registry;
|
||||
public class Broom extends FlxSprite
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* @param root: Who this broom is attached to.
|
||||
**/
|
||||
|
||||
public var root:Player;
|
||||
|
||||
public var horizontal_broom:FlxSprite;
|
||||
public var vertical_broom:FlxSprite;
|
||||
public var has_dust:Boolean = false;
|
||||
public var dust:Dust;
|
||||
public var just_released_dust:Boolean = false;
|
||||
|
||||
public var is_wide:Boolean = false;
|
||||
public var is_long:Boolean = false;
|
||||
|
||||
public var long_attack_v:FlxSprite = new FlxSprite();
|
||||
public var wide_attack_v:FlxSprite = new FlxSprite();
|
||||
public var long_attack_h:FlxSprite = new FlxSprite();
|
||||
public var wide_attack_h:FlxSprite = new FlxSprite();
|
||||
|
||||
private var WATK_W:int = 24;
|
||||
private var WATK_H:int = 12;
|
||||
private var LATK_W:int = 12;
|
||||
private var LATK_H:int = 22;
|
||||
|
||||
public var visible_timer:Number = 0;
|
||||
|
||||
private var is_behind_player:Boolean = false;
|
||||
|
||||
private var just_played_extra_anim:Boolean = false;
|
||||
|
||||
|
||||
public var locked:Boolean; //When the player is holding attack, broom should not switch directions.
|
||||
[Embed(source = "../../res/sprites/inventory/broom.png")] public static var Broom_Sprite:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/knife.png")] public static var Knife_Sprite:Class;
|
||||
[Embed(source = "../../res/sprites/broom_cell.png")] public static var Cell_Sprite:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/broom-icon.png")] public static var Icon_Broom_Sprite:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/wide_attack_h.png")] public static var Wide_Attack_h:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/long_attack_h.png")] public static var Long_Attack_h:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/wide_attack_v.png")] public static var Wide_Attack_v:Class;
|
||||
[Embed (source = "../../res/sprites/inventory/long_attack_v.png")] public static var Long_Attack_v:Class;
|
||||
public function Broom(_root:Player, _x:int, _y:int) {
|
||||
root = _root;
|
||||
x = root.x- 10;
|
||||
y = root.y;
|
||||
loadGraphic(Broom_Sprite, true, true, 16, 16);
|
||||
|
||||
addAnimation("stab", [1, 2,2,1,0,0], 20, false);
|
||||
addAnimation("stab2", [4, 5,5,4,3,9], 20, false);
|
||||
addAnimation("stab3", [7 , 8, 8, 7, 6, 9], 20, false);
|
||||
|
||||
wide_attack_h.loadGraphic(Wide_Attack_h, true, false, WATK_W,WATK_H);
|
||||
wide_attack_v.loadGraphic(Wide_Attack_v, true, false, WATK_H,WATK_W);
|
||||
long_attack_h.loadGraphic(Long_Attack_h, true, false, LATK_H,LATK_W);
|
||||
long_attack_v.loadGraphic(Long_Attack_v, true, false, LATK_W, LATK_H);
|
||||
|
||||
// Add lots of blank frames to the end of the animation. It is a hack to
|
||||
// avoid complexity in the code.
|
||||
|
||||
//ASSUMES THAT LONG ATTACK FACES LEFT/UP BY DEFAULT
|
||||
//ASSUMES THAT WIDE ATTACK FACES LEFT/UP BY DEFAULT
|
||||
wide_attack_h.addAnimation("a", [0,1,2,3,4], 14, false);
|
||||
wide_attack_v.addAnimation("a", [0,1,2,3,4], 14, false);
|
||||
long_attack_h.addAnimation("a", [0,1,2,3,4], 14, false);
|
||||
long_attack_v.addAnimation("a", [0,1,2,3,4], 14, false);
|
||||
}
|
||||
|
||||
public function is_active():Boolean {
|
||||
if (frame == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function draw():void
|
||||
{
|
||||
super.draw();
|
||||
}
|
||||
override public function update():void {
|
||||
|
||||
if (!has_dust && dust != null) {
|
||||
dust = null;
|
||||
}
|
||||
if (finished) {
|
||||
visible = false;
|
||||
}
|
||||
/* Hack to get around bug where broom gets "stuck" visible,
|
||||
* I can't reprodue.... */
|
||||
if (visible) {
|
||||
visible_timer += FlxG.elapsed;
|
||||
// needs to be long enough to ensure the broom makes a full anim
|
||||
if (visible_timer > 0.4) {
|
||||
long_attack_h.visible = long_attack_v.visible = visible = false;
|
||||
wide_attack_h.visible = wide_attack_v.visible = false;
|
||||
}
|
||||
} else {
|
||||
visible_timer = 0;
|
||||
}
|
||||
|
||||
|
||||
if (Registry.bound_effect == Registry.item_names[Registry.IDX_WIDEN]) {
|
||||
is_wide = true;
|
||||
is_long = false;
|
||||
} else if (Registry.bound_effect == Registry.item_names[Registry.IDX_LENGTHEN]) {
|
||||
is_wide = false;
|
||||
is_long = true;
|
||||
} else {
|
||||
is_wide = is_long = false;
|
||||
}
|
||||
if (Registry.CURRENT_MAP_NAME == "TRAIN" || Registry.CURRENT_MAP_NAME == "SUBURB") {
|
||||
is_wide = is_long = false;
|
||||
}
|
||||
|
||||
wide_attack_h.visible = false;
|
||||
long_attack_h.visible = false;
|
||||
wide_attack_v.visible = false;
|
||||
long_attack_v.visible = false;
|
||||
offset.y = offset.x = 0;
|
||||
offset.y = -root.framePixels_y_push;
|
||||
width = height = 16;
|
||||
|
||||
|
||||
if (!finished) {
|
||||
wide_attack_v.scale.x = 1;
|
||||
wide_attack_h.scale.y = 1;
|
||||
long_attack_h.scale.x = 1;
|
||||
long_attack_v.scale.y = 1;
|
||||
|
||||
|
||||
|
||||
if (root.facing == LEFT) {
|
||||
angle = 0;
|
||||
x = root.x - 14; y = root.y ;
|
||||
|
||||
if (is_wide && visible) {
|
||||
y -= 6;
|
||||
offset.y = -6;
|
||||
if (!just_played_extra_anim) {
|
||||
wide_attack_v.play("a", true);
|
||||
}
|
||||
wide_attack_v.visible = true;
|
||||
wide_attack_v.x = x;
|
||||
wide_attack_v.y = y;
|
||||
this.width = WATK_H;
|
||||
this.height = WATK_W;
|
||||
|
||||
|
||||
} else if (is_long && visible) {
|
||||
x -= 11;
|
||||
offset.x = -11;
|
||||
if (!just_played_extra_anim) long_attack_h.play("a",true);
|
||||
long_attack_h.visible = true;
|
||||
long_attack_h.x = x;
|
||||
long_attack_h.y = y;
|
||||
this.width = LATK_H;
|
||||
this.height = LATK_W;
|
||||
}
|
||||
|
||||
switch (frame) {
|
||||
case 0: x += 10; break;
|
||||
case 1: x += 6; break;
|
||||
case 2: x -= 1; break;
|
||||
}
|
||||
} else if (root.facing == RIGHT) {
|
||||
angle = 180;
|
||||
x = root.x + root.width; y = root.y - 2;
|
||||
if (is_wide && visible) {
|
||||
x += 4;
|
||||
y -= 6;
|
||||
offset.x = 4;
|
||||
offset.y = -6;
|
||||
wide_attack_v.scale.x = -1;
|
||||
if (!just_played_extra_anim) wide_attack_v.play("a",true);
|
||||
wide_attack_v.x = x;
|
||||
wide_attack_v.y = y + 2;
|
||||
wide_attack_v.visible = true;
|
||||
this.width = WATK_H;
|
||||
this.height = WATK_W;
|
||||
} else if (is_long && visible) {
|
||||
x += 6;
|
||||
offset.x = 6;
|
||||
long_attack_h.scale.x = -1;
|
||||
if (!just_played_extra_anim) long_attack_h.play("a",true);
|
||||
long_attack_h.visible = true;
|
||||
long_attack_h.x = x;
|
||||
long_attack_h.y = y + 2;
|
||||
this.width = LATK_H;
|
||||
this.height = LATK_W;
|
||||
|
||||
}
|
||||
|
||||
switch (frame) {
|
||||
case 0: x -= 12; break;
|
||||
case 1: x -= 8; break;
|
||||
case 2: x -= 1; break;
|
||||
}
|
||||
} else if (root.facing == UP) {
|
||||
angle = 90;
|
||||
x = root.x - 2; y = root.y - 16;
|
||||
x = int(x);
|
||||
y = int(y);
|
||||
if (is_wide && visible) {
|
||||
x -= 2;
|
||||
offset.x = -2;
|
||||
if (!just_played_extra_anim) wide_attack_h.play("a",true);
|
||||
wide_attack_h.x = x - 1;
|
||||
wide_attack_h.y = y;
|
||||
wide_attack_h.visible = true;
|
||||
this.width = WATK_W;
|
||||
this.height = WATK_H;
|
||||
|
||||
} else if (is_long && visible) {
|
||||
y -= 9;
|
||||
offset.y = -9;
|
||||
x += 3;
|
||||
offset.x = 3;
|
||||
if (!just_played_extra_anim) long_attack_v.play("a",true);
|
||||
long_attack_v.x = x;
|
||||
long_attack_v.y = y;
|
||||
long_attack_v.visible = true;
|
||||
width = LATK_W;
|
||||
height = LATK_H;
|
||||
}
|
||||
switch (frame) {
|
||||
case 0: y += 12; break;
|
||||
case 1: y += 6; break;
|
||||
case 2: y += 2; break;
|
||||
}
|
||||
} else if (root.facing == DOWN) {
|
||||
angle = 270;
|
||||
x = root.x - 6; y = root.y + root.height;
|
||||
if (is_wide && visible) {
|
||||
x -= 2;
|
||||
y += 4;
|
||||
offset.y = 4;
|
||||
offset.x = -2;
|
||||
wide_attack_h.scale.y = -1;
|
||||
if (!just_played_extra_anim) wide_attack_h.play("a",true);
|
||||
wide_attack_h.x = x -2;
|
||||
wide_attack_h.y = y;
|
||||
wide_attack_h.visible = true;
|
||||
this.width = WATK_W;
|
||||
this.height = WATK_H;
|
||||
} else if (is_long && visible) {
|
||||
long_attack_v.scale.y = -1;
|
||||
if (!just_played_extra_anim) long_attack_v.play("a",true);
|
||||
long_attack_v.x = x;
|
||||
long_attack_v.y = y;
|
||||
long_attack_v.visible = true;
|
||||
width = LATK_W;
|
||||
height = LATK_H;
|
||||
}
|
||||
switch (frame) {
|
||||
case 0: y -= 8; break;
|
||||
case 1: y -= 5; break;
|
||||
case 2: y -= 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!just_played_extra_anim && visible && (is_long || is_wide)) {
|
||||
just_played_extra_anim = true;
|
||||
}
|
||||
} else {
|
||||
just_played_extra_anim = false;
|
||||
}
|
||||
|
||||
switch (root.facing) {
|
||||
case LEFT: case UP:
|
||||
if (! is_behind_player) {
|
||||
flip_player_broom_draw_order(ANY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (is_behind_player) {
|
||||
flip_player_broom_draw_order(NONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the broom upgrades to right above the broom ased on bidx
|
||||
* @param bidx
|
||||
*/
|
||||
private function move_upgrades():void {
|
||||
var pgm:Array = Registry.GAMESTATE.player_group.members;
|
||||
var idx:int = pgm.indexOf(wide_attack_h);
|
||||
pgm.splice(idx, 4); // Delete thingy
|
||||
var bidx:int = pgm.indexOf(this);
|
||||
pgm.splice(bidx + 1, 0, wide_attack_h, wide_attack_v, long_attack_h, long_attack_v);
|
||||
}
|
||||
private function flip_player_broom_draw_order(dir:uint):void {
|
||||
// player Broom
|
||||
// foot <-> player
|
||||
// Broom foot
|
||||
is_behind_player = !is_behind_player;
|
||||
var player_group_members:Array = Registry.GAMESTATE.player_group.members;
|
||||
var player_idx:int = player_group_members.indexOf(root);
|
||||
var broom_idx:int = player_group_members.indexOf(this);
|
||||
var foot_overlay_idx:int = player_group_members.indexOf(root.foot_overlay);
|
||||
if (dir == ANY) { // left, up
|
||||
player_group_members[player_idx] = this;
|
||||
player_group_members[broom_idx] = root.foot_overlay;
|
||||
player_group_members[foot_overlay_idx] = root;
|
||||
move_upgrades();
|
||||
} else { // right, down
|
||||
player_group_members[broom_idx] = root;
|
||||
player_group_members[player_idx] = root.foot_overlay;
|
||||
player_group_members[foot_overlay_idx] = this;
|
||||
move_upgrades();
|
||||
}
|
||||
|
||||
// flip reflections too!
|
||||
if (root.reflection.exists) {
|
||||
var reflect_broom_idx:int = Registry.GAMESTATE.members.indexOf(root.reflection_broom);
|
||||
var reflect_idx:int = Registry.GAMESTATE.members.indexOf(root.reflection);
|
||||
|
||||
Registry.GAMESTATE.members[reflect_broom_idx] = root.reflection;
|
||||
Registry.GAMESTATE.members[reflect_idx] = root.reflection_broom;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
package entity.player
|
||||
{
|
||||
import global.Registry;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
import states.PlayState;
|
||||
|
||||
/**
|
||||
* sanity class for the foot overlay
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Foot_Overlay extends FlxSprite
|
||||
{
|
||||
[Embed (source = "../../res/sprites/decoration/player_overlay_foot_test.png")] public static var foot_test:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_APARTMENT_water.png")] public static var APARTMENT_water:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_REDCAVE_water.png")] public static var REDCAVE_water:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_REDSEA.png")] public static var REDSEA_water:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_WINDMILL_water.png")] public static var WINDMILL_water:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_FIELDS_grass.png")] public static var FIELDS_grass:Class;
|
||||
[Embed (source = "../../res/sprites/decoration/overlay_water.png")] public static var general_water:Class;
|
||||
|
||||
private var debug_tiles:Array = new Array(2, -1);
|
||||
private var fields_tiles:Array = new Array(200,201,250,270,271,272,273, -1);
|
||||
private var apartment_tiles:Array = new Array(206, 231, -1);
|
||||
private var redcave_tiles:Array = new Array(16, 17, 18, 19, 28, -1);
|
||||
private var redsea_tiles:Array = new Array(61, 71, -1);
|
||||
private var circus_tiles:Array = new Array(110, 111, 112, 113, 114, -1);
|
||||
private var windmill_tiles:Array = new Array(130, -1);
|
||||
private var working_maps:Array = new Array("DEBUG", "FOREST", "TERMINAL", "GO", "FIELDS", "APARTMENT", "REDCAVE", "CIRCUS", "HOTEL", "WINDMILL","BEACH", "REDSEA");
|
||||
|
||||
|
||||
private var player:Player
|
||||
private var cur_player_state:int;
|
||||
private var cur_player_anim_state:int;
|
||||
private var cur_tile:int = -1;
|
||||
|
||||
public var map:FlxTilemap;
|
||||
private var map_name:String;
|
||||
|
||||
|
||||
private var X_OFF:int = -4;
|
||||
private var Y_OFF:int = 0;
|
||||
private var W:int = 24;
|
||||
private var H:int = 24;
|
||||
private var player_midpoint:FlxPoint = new FlxPoint();
|
||||
|
||||
|
||||
public function Foot_Overlay(_player:Player)
|
||||
{
|
||||
super();
|
||||
|
||||
player = _player;
|
||||
player_midpoint = player.getMidpoint(player_midpoint);
|
||||
|
||||
if (working_maps.indexOf(Registry.CURRENT_MAP_NAME) == -1) {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
loadGraphic(foot_test, true, false, W, H);
|
||||
addAnimation("foot_test", [0, 1], 12);
|
||||
|
||||
//200 - yello, 201 - green
|
||||
addAnimation("FIELDS_yellow_stop", [3],20);
|
||||
addAnimation("FIELDS_yellow_go", [2, 3], 8);
|
||||
addAnimation("FIELDS_green_stop", [5],20);
|
||||
addAnimation("FIELDS_green_go", [4, 5], 8);
|
||||
|
||||
addAnimation("REDCAVE_water", [0],1);
|
||||
|
||||
addAnimation("APARTMENT_water", [0], 5);
|
||||
|
||||
addAnimation("WINDMILL_water", [0, 1], 5);
|
||||
|
||||
addAnimation("general_water", [0], 5);
|
||||
|
||||
visible = false;
|
||||
map_name = Registry.CURRENT_MAP_NAME;
|
||||
}
|
||||
|
||||
// When we change a map we need to reset some data
|
||||
// so that things don't break.
|
||||
public function reset_anodyne():void {
|
||||
map_name = Registry.CURRENT_MAP_NAME;
|
||||
if (working_maps.indexOf(Registry.CURRENT_MAP_NAME) == -1) {
|
||||
exists = false;
|
||||
} else {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
player_midpoint = player.getMidpoint(player_midpoint);
|
||||
|
||||
var tile_type:int = map.getTile(player_midpoint.x/16, (player_midpoint.y - Registry.HEADER_HEIGHT)/16);
|
||||
if (tile_type != cur_tile) {
|
||||
cur_tile = tile_type;
|
||||
change_anim();
|
||||
}
|
||||
|
||||
// Player state takes precedence over tile type
|
||||
if (player.state != cur_player_state) {
|
||||
cur_player_state = player.state;
|
||||
change_anim();
|
||||
}
|
||||
|
||||
if (player.ANIM_STATE != cur_player_anim_state) {
|
||||
cur_player_anim_state = player.ANIM_STATE;
|
||||
change_anim();
|
||||
}
|
||||
|
||||
if (player.facing == LEFT) {
|
||||
x = player.x - player.offset.x + X_OFF + 1;
|
||||
} else if (player.facing == RIGHT) {
|
||||
x = player.x - player.offset.x + X_OFF - 1;
|
||||
|
||||
} else {
|
||||
x = player.x - player.offset.x + X_OFF; //SUBTrACTION DOESNTO COMMUTe
|
||||
y = player.y - player.offset.y + Y_OFF ;
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
private function change_anim():void {
|
||||
flicker(0); // Stop infinite flickering
|
||||
visible = false;
|
||||
|
||||
Y_OFF = 0;
|
||||
|
||||
if (map_name == "DEBUG") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (debug_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 2) {
|
||||
visible = true;
|
||||
loadGraphic(foot_test, true, false, W, H);
|
||||
play("foot_test");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "FIELDS") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (fields_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 201) {
|
||||
Y_OFF = -1;
|
||||
loadGraphic(FIELDS_grass, true, false, W, H);
|
||||
if (player.velocity.x == 0 && player.velocity.y == 0) {
|
||||
visible = true;
|
||||
play("FIELDS_green_stop");
|
||||
} else {
|
||||
visible = true;
|
||||
play("FIELDS_green_go");
|
||||
}
|
||||
} else if (cur_tile == 200) {
|
||||
loadGraphic(FIELDS_grass, true, false, W, H);
|
||||
if (player.velocity.x == 0 && player.velocity.y == 0) {
|
||||
//visible = true;
|
||||
play("FIELDS_yellow_stop");
|
||||
} else {
|
||||
//visible = true;
|
||||
play("FIELDS_yellow_go");
|
||||
}
|
||||
} else { // It's a water tile
|
||||
visible = true;
|
||||
loadGraphic(WINDMILL_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
flicker( -1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "APARTMENT") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (apartment_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 231 || cur_tile == 206) {
|
||||
visible = true;
|
||||
loadGraphic(APARTMENT_water, true, false, W, H);
|
||||
play("APARTMENT_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "REDCAVE") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (redcave_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 16 || cur_tile == 17 || cur_tile == 18 || cur_tile == 19 || cur_tile == 28) {
|
||||
visible = true;
|
||||
loadGraphic(REDCAVE_water, true, false, W, H);
|
||||
play("REDCAVE_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "REDSEA") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (redsea_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 61 || cur_tile == 71) {
|
||||
visible = true;
|
||||
loadGraphic(REDSEA_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "WINDMILL") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (windmill_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 130) {
|
||||
visible = true;
|
||||
loadGraphic(WINDMILL_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
//flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "CIRCUS") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (circus_tiles.indexOf(cur_tile) != -1) {
|
||||
if (cur_tile == 110 || cur_tile == 111 || cur_tile == 112 || cur_tile == 113 || cur_tile == 114) {
|
||||
visible = true;
|
||||
loadGraphic(general_water, true, false, W, H);
|
||||
play("general_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_name == "BEACH") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if ((cur_tile >= 140 && cur_tile <= 146) || cur_tile >= 250) {
|
||||
visible = true;
|
||||
loadGraphic(WINDMILL_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
} else if (map_name == "FOREST") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (cur_tile == 110 || (cur_tile >= 134 && cur_tile <= 137)) {
|
||||
visible = true;
|
||||
loadGraphic(general_water, true, false, W, H);
|
||||
play("general_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
} else if (map_name == "TERMINAL") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (cur_tile == 150 || cur_tile == 151) {
|
||||
visible = true;
|
||||
loadGraphic(WINDMILL_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
} else if (map_name == "GO") {
|
||||
if (cur_player_state == player.S_GROUND) {
|
||||
if (cur_tile >= 50 && cur_tile <= 53) {
|
||||
visible = true;
|
||||
loadGraphic(WINDMILL_water, true, false, W, H);
|
||||
play("WINDMILL_water");
|
||||
flicker( -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package entity.player
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxPoint;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxGroup;
|
||||
public class HealthBar extends FlxGroup
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param _x x coordinate of the top-right health box.
|
||||
* @param _y y coordinate of the top-right health box.
|
||||
* @param health Max number of health boxes to show.
|
||||
*/
|
||||
|
||||
public var cur_health:int;
|
||||
public var max_health:int;
|
||||
public var health_boxes:Array;
|
||||
|
||||
public var BOX_WIDTH:int = 11;
|
||||
public var BOX_HEIGHT:int = 6;
|
||||
public var BOX_SPACING:int = -3;
|
||||
|
||||
public var COLOR_FULL:uint = 0x7d1818;
|
||||
public var COLOR_EMPTY:uint = 0x494949;
|
||||
|
||||
public var FULL_FRAME:int = 0;
|
||||
public var EMPTY_FRAME:int = 1;
|
||||
|
||||
public var NO_SCROLL:FlxPoint = new FlxPoint(0, 0);
|
||||
public var x:int;
|
||||
[Embed (source = "../../res/sprites/inventory/health_piece.png")] public static var health_piece_sprite:Class;
|
||||
|
||||
public function HealthBar(_x:int,_y:int,_max_health:int)
|
||||
{
|
||||
super(16);
|
||||
x = _x;
|
||||
y = _y;
|
||||
for (var i:int = 0; i < _max_health; i++) {
|
||||
make_box(i+1);
|
||||
|
||||
}
|
||||
max_health = _max_health;
|
||||
cur_health = max_health;
|
||||
// Thse values are deserialized when continuing a save
|
||||
Registry.MAX_HEALTH = max_health; // Want to do this because in the testing mode
|
||||
Registry.CUR_HEALTH = cur_health; // Sometimes we do construct a health bar more than once.
|
||||
}
|
||||
|
||||
public function make_box(i:int):void {
|
||||
i--;
|
||||
var health_box:FlxSprite = new FlxSprite;
|
||||
|
||||
health_box.x = (x - BOX_WIDTH - 8 * (7 - i % 8)) - 7 * int(i / 8);
|
||||
health_box.y = y + int(i / 8) * (BOX_HEIGHT + 1);
|
||||
|
||||
health_box.loadGraphic(health_piece_sprite, true, false, BOX_WIDTH, BOX_HEIGHT);
|
||||
health_box.alpha = 1;
|
||||
health_box.scrollFactor = NO_SCROLL;
|
||||
health_box.addAnimation("flash", [0, 2], 7, true);
|
||||
health_box.addAnimation("full", [0], 0,false);
|
||||
|
||||
add(health_box);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param change_amount How much the health changes
|
||||
* @return -1 if the change resulted in 0 health, 1 if full, 0 otherwise
|
||||
*/
|
||||
public function modify_health(change_amount:int):int {
|
||||
var nrChanges:int = 0;
|
||||
var health_box:FlxSprite;
|
||||
if (change_amount < 0) {
|
||||
if ( -change_amount > cur_health) change_amount = -cur_health;
|
||||
cur_health = Math.max(0, cur_health + change_amount);
|
||||
while (nrChanges < -change_amount) {
|
||||
health_box = getLastAlive() as FlxSprite;
|
||||
|
||||
if (health_box == null) return -1;
|
||||
health_box.alive = false;
|
||||
health_box.frame = EMPTY_FRAME;
|
||||
nrChanges++;
|
||||
}
|
||||
} else if (change_amount > 0) {
|
||||
cur_health = Math.min(max_health, cur_health + change_amount);
|
||||
while (nrChanges < change_amount) {
|
||||
// Iterate backwards to find the most recent emptied health box, then make it visible
|
||||
for (var i:int = 0; i < members.length; i++) {
|
||||
if (members[i] != null && members[i].alive == false) {
|
||||
members[i].alive = true;
|
||||
members[i].frame = FULL_FRAME;
|
||||
break;
|
||||
} else if (i == max_health - 1) {
|
||||
members[0].play("full");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
nrChanges++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_health == 1) {
|
||||
members[0].play("flash");
|
||||
} else if (cur_health > 1) {
|
||||
members[0].play("full");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function upgrade_health(player:Player):void {
|
||||
player.health_bar.make_box(player.health_bar.max_health + 1); // Extend bar
|
||||
player.health_bar.max_health ++; // Reflect changes in health bar state
|
||||
player.health_bar.modify_health(player.health_bar.max_health); // Heal player
|
||||
Registry.MAX_HEALTH++; // Reflect changes in global state
|
||||
}
|
||||
override public function update():void {
|
||||
super.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package entity.player
|
||||
{
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import states.PlayState;
|
||||
|
||||
/**
|
||||
* +1, +3 health things, and the extenderzzz
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class HealthPickup extends FlxSprite
|
||||
{
|
||||
|
||||
public static var HP_1:int = 1;
|
||||
public static var HP_3:int = 3;
|
||||
public static var HP_EXTEND:int = 0;
|
||||
public var pickup_type:int;
|
||||
public var xml:XML;
|
||||
public var parent:*;
|
||||
public var LATENCY:Number = 0.5; // Timeout for broom touching
|
||||
[Embed (source = "../../res/sprites/inventory/small_health_pickup.png")] public static const S_SMALL_HEALTH:Class;
|
||||
[Embed(source = "../../res/sprites/inventory/big_health_pickup.png")] public static const embed_Big_health:Class;
|
||||
|
||||
public function HealthPickup(x:int,y:int,_pickup_type:int,_parent:*,_xml:XML = null):void
|
||||
{
|
||||
super(x, y);
|
||||
solid = false;
|
||||
pickup_type = _pickup_type;
|
||||
has_tile_callbacks = false;
|
||||
parent = _parent;
|
||||
switch(pickup_type) {
|
||||
case HP_1:
|
||||
loadGraphic(S_SMALL_HEALTH, true, false, 10, 16);
|
||||
addAnimation("float", [0, 1, 2, 3], 5, true);
|
||||
play("float");
|
||||
break;
|
||||
case HP_3:
|
||||
loadGraphic(embed_Big_health, true, false, 16, 16);
|
||||
addAnimation("float", [0, 1, 2, 3], 5, true);
|
||||
play("float");
|
||||
break;
|
||||
//makeGraphic(12, 12, 0xffff0000); break;
|
||||
case HP_EXTEND:
|
||||
makeGraphic(16, 16, 0xffff2200); break;
|
||||
}
|
||||
|
||||
xml = _xml;
|
||||
if (xml == null) { // Usually when a health-pickup is dropped by an enemy
|
||||
xml = <HealthPickup/>;
|
||||
} else {
|
||||
if (xml.@alive == "false") {
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
if (LATENCY > 0) {
|
||||
LATENCY -= FlxG.elapsed;
|
||||
} else {
|
||||
if (parent.player.overlaps(this) ||
|
||||
(parent.player.broom.visible && parent.player.broom.overlaps(this))) {
|
||||
picked_up(parent.player);
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
/**
|
||||
* Given a reference to the player, heal it or trigger the events
|
||||
* to increase health bar
|
||||
* @param player
|
||||
*/
|
||||
public function picked_up(player:Player):void {
|
||||
switch (pickup_type) {
|
||||
case HP_1:
|
||||
Registry.sound_data.get_small_health.play();
|
||||
player.health_bar.modify_health(1); break;
|
||||
case HP_3:
|
||||
Registry.sound_data.get_small_health.play();
|
||||
player.health_bar.modify_health(3); break;
|
||||
case HP_EXTEND:
|
||||
xml.@alive = "false";
|
||||
Registry.EVENT_EXTEND_HEALTH = true;
|
||||
break;
|
||||
}
|
||||
visible = solid = false;
|
||||
exists = false;
|
||||
}
|
||||
|
||||
override public function destroy():void {
|
||||
//shouldget cleaned up in delete_otherobjecs
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package entity.player
|
||||
{
|
||||
import data.CSV_Data;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import global.Registry;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
import org.flixel.FlxU;
|
||||
import states.MinimapState;
|
||||
|
||||
public class Miniminimap extends FlxSprite
|
||||
{
|
||||
|
||||
[Embed(source = "../../res/tilemaps/mini_minimap_tiles.png")] public static const embed_miniminimap_tiles:Class;
|
||||
|
||||
// Used for calculating room bounds
|
||||
private var width_in_rooms:int;
|
||||
private var height_in_rooms:int;
|
||||
private var buffer:FlxSprite;
|
||||
private var minimap:FlxTilemap;
|
||||
|
||||
private const RED_IDX:int = 9;
|
||||
private var bm:FlxSprite;
|
||||
private var t:FlxTilemap;
|
||||
|
||||
public function Miniminimap()
|
||||
{
|
||||
makeGraphic(25, 20, 0x00000000);
|
||||
//visible = false;
|
||||
scrollFactor.x = scrollFactor.y = 0;
|
||||
x = 55;
|
||||
y = 0;
|
||||
bm = new FlxSprite(0, 0, embed_miniminimap_tiles);
|
||||
t = new FlxTilemap();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x_next
|
||||
* @param y_next
|
||||
*/
|
||||
public function switch_rooms(x_next:int, y_next:int):void {
|
||||
if (visible == false) return;
|
||||
// Find next room, get type, update map buffer
|
||||
dirty = true;
|
||||
|
||||
// Max coords of minimap
|
||||
var mx:int = minimap.widthInTiles - 1;
|
||||
var my:int = minimap.heightInTiles - 1;
|
||||
|
||||
// Try to find a 5x4 rectangle of things to show with the marker at (2,1). If not then offset it.
|
||||
|
||||
//We're good
|
||||
if (y_next >= 1 && (my - y_next >= 2) && x_next >= 2 && (mx - x_next) >= 2) {
|
||||
update_graphics_routine(x_next - 2, y_next - 1, 7);
|
||||
// Otherwise change the rectangle a bit
|
||||
} else {
|
||||
var cx:int;
|
||||
var cy:int;
|
||||
if (x_next < 2) {
|
||||
cx = 2 - x_next;
|
||||
} else if ((mx - x_next) < 2) {
|
||||
cx = -2 + (mx - x_next);
|
||||
}
|
||||
|
||||
if (y_next < 1) {
|
||||
cy = 1;
|
||||
} else if ((my - y_next) < 2) {
|
||||
cy = -2 + (my - y_next);
|
||||
}
|
||||
update_graphics_routine(x_next - 2 + cx, y_next - 1 + cy,7 + (-cy * 5) - cx );
|
||||
// Edge cases fuuuuuuuuck
|
||||
}
|
||||
}
|
||||
|
||||
private function update_graphics_routine(_x:int, _y:int, red_idx: int):void {
|
||||
var w:int = minimap.widthInTiles;
|
||||
var h:int = minimap.heightInTiles;
|
||||
var source_rect:Rectangle = new Rectangle(0, 0, 5, 5);
|
||||
var dest_point:Point = new Point(0, 0);
|
||||
|
||||
var visited:Array = MinimapState.visited[Registry.CURRENT_MAP_NAME];
|
||||
visited[w * Registry.CURRENT_GRID_Y + Registry.CURRENT_GRID_X] = 1;
|
||||
var data:Array = t.getData();
|
||||
|
||||
var t_idx:int; // tile idex
|
||||
var tt:int; //tile type
|
||||
for (var i:int = 0; i < 20; i++) {
|
||||
|
||||
t_idx = w * (_y + int (i / 5)) + (_x + (i % 5));
|
||||
tt = data[t_idx];
|
||||
if (visited[t_idx] == 0) {
|
||||
tt = 0; // Make it blank
|
||||
}
|
||||
|
||||
dest_point.x = 5 * (i % 5);
|
||||
dest_point.y = 5 * int (i / 5);
|
||||
// Miniminimap tileset is 20x25 pixels. Indexed by same values as the other minimap
|
||||
source_rect.x = (tt % 4) * 5;
|
||||
source_rect.y = int(tt / 4) * 5;
|
||||
pixels.copyPixels(bm.pixels, source_rect, dest_point);
|
||||
}
|
||||
|
||||
source_rect.x = 5 + 1;
|
||||
source_rect.y = 10 + 1
|
||||
source_rect.width = 3;
|
||||
source_rect.height = 3;
|
||||
dest_point.x = (red_idx % 5) * 5 + 1;
|
||||
dest_point.y = int(red_idx / 5) * 5 + 1;
|
||||
pixels.copyPixels(bm.pixels, source_rect, dest_point);
|
||||
draw();
|
||||
}
|
||||
/**
|
||||
* Switch to the next map, either make visible or not. Call AFTER updatin' minimap
|
||||
* Set bounds of map.
|
||||
* @param next_map
|
||||
*/
|
||||
public function switch_map():void {
|
||||
|
||||
|
||||
var mms:MinimapState = Registry.GAMESTATE.pause_state.minimap;
|
||||
var _minimap:FlxTilemap = mms.get_minimap();
|
||||
|
||||
if (_minimap == null) {
|
||||
visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
visible = true;
|
||||
var s:String = new CSV_Data.minimap_csv[Registry.CURRENT_MAP_NAME];
|
||||
t = new FlxTilemap();
|
||||
t.loadMap(s, embed_miniminimap_tiles, 5, 5);
|
||||
minimap = _minimap;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,247 @@
|
|||
package entity.player
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import global.Registry;
|
||||
import helper.DH;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxObject;
|
||||
import org.flixel.FlxSprite;
|
||||
import org.flixel.FlxTilemap;
|
||||
/**
|
||||
* Item that switches two arbitrary tiles on the map.
|
||||
* Obviously breaks things to hell so we only give it
|
||||
* to the player at the end.
|
||||
* @author Seagaia
|
||||
*/
|
||||
public class Transformer extends FlxSprite
|
||||
{
|
||||
|
||||
public var selector:FlxSprite = new FlxSprite;
|
||||
public var selected:FlxSprite = new FlxSprite;
|
||||
|
||||
private var state:int = 0;
|
||||
private var s_idle:int = 0;
|
||||
private var s_ready:int = -1;
|
||||
private var s_has_one:int = 1;
|
||||
private var s_transforming:int = 2;
|
||||
|
||||
private var map:FlxTilemap = new FlxTilemap;
|
||||
private var g_off:Point = new Point();
|
||||
private var is_playstate:Boolean = false;
|
||||
|
||||
private var p:Player;
|
||||
private var parent:*;
|
||||
|
||||
private var did_init:Boolean = false;
|
||||
private var dontfuckgindoanything:Boolean = true;
|
||||
|
||||
private var okay_places:Array;
|
||||
private var okay_rooms:Array;
|
||||
|
||||
|
||||
[Embed(source = "../../res/sprites/inventory/selector.png")] public static const embed_selector:Class;
|
||||
public function Transformer(_p:Player,_parent:*)
|
||||
{
|
||||
p = _p;
|
||||
parent = _parent;
|
||||
reset_next();
|
||||
|
||||
selector.loadGraphic(embed_selector, true, false, 16, 16);
|
||||
selected.loadGraphic(embed_selector, true, false, 16, 16);
|
||||
selected.addAnimation("a", [1]);
|
||||
selector.addAnimation("a", [0, 1], 4);
|
||||
selector.play("a");
|
||||
selected.play("a");
|
||||
|
||||
visible = false;
|
||||
selector.visible = false;
|
||||
selected.visible = false;
|
||||
|
||||
|
||||
okay_places = new Array("GO", "CIRCUS", "HOTEL", "APARTMENT");
|
||||
okay_rooms = new Array(new Point(2,3), new Point(7, 0), new Point(8, 11), new Point(8, 7));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
override public function update():void
|
||||
{
|
||||
|
||||
if (Registry.FUCK_IT_MODE_ON && FlxG.keys.justPressed("T")) {
|
||||
trace("Transformer.as: GE_EVENTS: BEAT GAME IS NOW TRUE");
|
||||
Registry.GE_States[Registry.GE_Finished_Game] = true;
|
||||
}
|
||||
|
||||
// Extra nexus and drawer hardcoded check...
|
||||
|
||||
if (!did_init) {
|
||||
reset_next();
|
||||
did_init = true;
|
||||
|
||||
}
|
||||
// hack
|
||||
map = parent.curMapBuf;
|
||||
g_off.x = Registry.CURRENT_GRID_X * 160;
|
||||
g_off.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT;
|
||||
switch (state) {
|
||||
case s_idle:
|
||||
break;
|
||||
case s_ready:
|
||||
case s_transforming:
|
||||
facing = p.facing;
|
||||
var hh:int = Registry.HEADER_HEIGHT;
|
||||
|
||||
if (facing == UP) {x = p.x; y = p.y - 16; }
|
||||
else if (facing == LEFT) { x = p.x - 16; y = p.y; }
|
||||
else if (facing == RIGHT) { x = p.x + 16; y = p.y; }
|
||||
else { x = p.x; y = p.y + 16; }
|
||||
|
||||
if ( x % 16 <= 10) { x -= x % 16; }
|
||||
else { x += (16 - x % 16); }
|
||||
if ((y - hh) % 16 <= 7) { y -= ((y - hh) % 16); }
|
||||
else { y += (16 - (y - hh) % 16); }
|
||||
|
||||
selector.x = x;
|
||||
selector.y = y;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Registry.E_Transformer_On) {
|
||||
Registry.E_Transformer_On = false;
|
||||
|
||||
}
|
||||
if (Registry.E_Transformer_Off) {
|
||||
Registry.E_Transformer_Off = false;
|
||||
selector.visible = selected.visible = false;
|
||||
state = s_idle;
|
||||
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
//called by player
|
||||
public function use_item():void {
|
||||
if (Registry.sound_data.current_song_name == "BRIARFIGHT") {
|
||||
return;
|
||||
}
|
||||
// If we finished the game, use swap everywhere
|
||||
if (Registry.GE_States[Registry.GE_Finished_Game]) {
|
||||
dontfuckgindoanything = false;
|
||||
|
||||
if (Registry.CURRENT_MAP_NAME == "DRAWER" && Registry.CURRENT_GRID_Y >= 9) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "NEXUS" && Registry.CURRENT_GRID_Y <= 3) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK" && Registry.CURRENT_GRID_Y >= 7) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SPACE" && Registry.CURRENT_GRID_Y >= 5) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN" && Registry.CURRENT_GRID_Y >= 8) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SUBURB" && Registry.CURRENT_GRID_Y >= 5 && Registry.CURRENT_GRID_X == 2) {
|
||||
dontfuckgindoanything = true;
|
||||
} else if (Registry.CURRENT_MAP_NAME == "DEBUG") {
|
||||
dontfuckgindoanything = true;
|
||||
}
|
||||
// Otherwise, only activate swap in certain rooms.
|
||||
} else {
|
||||
for (var i:int = 0; i < 4; i++) {
|
||||
if (Registry.CURRENT_MAP_NAME == okay_places[i] && Registry.CURRENT_GRID_X == okay_rooms[i].x && Registry.CURRENT_GRID_Y == okay_rooms[i].y) {
|
||||
if (Registry.CURRENT_MAP_NAME == "GO") {
|
||||
if (Registry.GAMESTATE.player.facing == FlxObject.UP && Registry.GAMESTATE.player.y < Registry.CURRENT_GRID_Y * 160 +20 + 32) {
|
||||
dontfuckgindoanything = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dontfuckgindoanything = false;
|
||||
break;
|
||||
} else {
|
||||
dontfuckgindoanything = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here and have the swap non-activated, show messsage.
|
||||
if (dontfuckgindoanything) {
|
||||
if (Registry.CURRENT_MAP_NAME == "DRAWER") { // Weird old overworld area
|
||||
//DH.dialogue_popup("The swap won't work here.");
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "NEXUS" && Registry.CURRENT_GRID_Y <= 3) { // postgame..
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "BLANK" && Registry.CURRENT_GRID_Y >= 7) {
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SPACE" && Registry.CURRENT_GRID_Y >= 5) {
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "TRAIN" && Registry.CURRENT_GRID_Y >= 7) {
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "SUBURB" && Registry.CURRENT_GRID_Y >= 5 && Registry.CURRENT_GRID_X == 2) {
|
||||
DH.dialogue_popup(DH.lk("swap", 1));
|
||||
} else if (Registry.CURRENT_MAP_NAME == "DEBUG") {
|
||||
//DH.dialogue_popup("Sorry!");
|
||||
DH.dialogue_popup(DH.lk("swap", 0));
|
||||
} else {
|
||||
//DH.dialogue_popup("Young could not muster the strength to use the swap here.");
|
||||
DH.dialogue_popup(DH.lk("swap", 2));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == s_idle) {
|
||||
state = s_ready;
|
||||
selector.visible = true;
|
||||
} else if (state == s_ready) {
|
||||
selected.visible = true;
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_move_group);
|
||||
selected.x = selector.x;
|
||||
selected.y = selector.y;
|
||||
state = s_transforming;
|
||||
} else if (state == s_transforming) {
|
||||
Registry.sound_data.play_sound_group(Registry.sound_data.menu_select_group);
|
||||
|
||||
var _x:int = (selected.x - g_off.x) / 16;
|
||||
var _y:int = (selected.y - g_off.y) / 16;
|
||||
|
||||
var tt1:int = map.getTile(_x, _y);
|
||||
|
||||
var _x2:int = (selector.x - g_off.x) / 16;
|
||||
var _y2:int = (selector.y - g_off.y) / 16;
|
||||
|
||||
var tt2:int = map.getTile(_x2, _y2);
|
||||
|
||||
//Switch tiles
|
||||
|
||||
//trace("tt1: ", tt1, _x, _y);
|
||||
//trace("tt2: ", tt2, _x2, _y2);
|
||||
|
||||
map.setTile(_x, _y, tt2);
|
||||
map.setTile(_x2, _y2, tt1);
|
||||
|
||||
state = s_ready;
|
||||
selected.visible = false;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Updates grid coords if needed, also the current map buffer
|
||||
*/
|
||||
public function reset_next():void {
|
||||
state = s_idle;
|
||||
selected.visible = selector.visible = false;
|
||||
if (Registry.is_playstate) {
|
||||
is_playstate = true;
|
||||
g_off.x = Registry.CURRENT_GRID_X * 160;
|
||||
g_off.y = Registry.CURRENT_GRID_Y * 160 + Registry.HEADER_HEIGHT;
|
||||
} else {
|
||||
g_off.x = 0;
|
||||
g_off.y = Registry.HEADER_HEIGHT;
|
||||
}
|
||||
map = parent.curMapBuf;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue