WIP: convert to haxeflixel

This commit is contained in:
lif 2020-04-04 22:49:48 -07:00
parent 639466f2e8
commit ed193c2d18
1637 changed files with 223288 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
installation files
intra/air
intra/dist
intra/export
intra/Anodyne_standalone
intra/bin/Anodyne.swf
intra/mobile_PAX_Intra.dam
@ -17,4 +18,4 @@ intra/Anodyne_Only_Joy_1_506.exe
intra/commits.txt
intra/_weirdbinthings
intra/Anodyne_store_new.ipa
intra/Anodyne_Windows_1_511.zip
intra/Anodyne_Windows_1_511.zip

View File

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,115 @@
package;
import com.amanitadesign.steam.FRESteamWorks;
import com.amanitadesign.steam.SteamConstants;
import com.amanitadesign.steam.SteamEvent;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.utils.ByteArray<Dynamic>;
class FRESteamWorksTest extends Sprite
{
public var Steamworks:FRESteamWorks=new FRESteamWorks();
public var tf:TextField;
public function new()
{
tf=new TextField();
tf.width=stage.stageWidth;
tf.height=stage.stageHeight;
addChild(tf);
tf.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
Steamworks.addEventListener(SteamEvent.STEAM_RESPONSE, onSteamResponse);
if(Steamworks.init()){
log("STEAMWORKS API is available\n");
//comment.. current stats and achievement ids are from steam example app which is provided with their SDK
log("isAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.isAchievement("ACH_WIN_ONE_GAME"));
log("isAchievement('ACH_TRAVEL_FAR_SINGLE')=="+Steamworks.isAchievement("ACH_TRAVEL_FAR_SINGLE"));
log("setStatFloat('FeetTraveled')=="+Steamworks.setStatFloat('FeetTraveled', 21.3));
log("setStatInt('NumGames', 2)=="+Steamworks.setStatInt('NumGames', 2));
Steamworks.storeStats();
log("getStatInt('NumGames')=="+Steamworks.getStatInt('NumGames'));
log("getStatFloat('FeetTraveled')=="+Steamworks.getStatFloat('FeetTraveled'));
log("setCloudEnabledForApp(false)=="+Steamworks.setCloudEnabledForApp(false));
log("setCloudEnabledForApp(true)=="+Steamworks.setCloudEnabledForApp(true));
log("isCloudEnabledForApp()=="+Steamworks.isCloudEnabledForApp());
log("getFileCount()=="+Steamworks.getFileCount());
log("fileExists('test.txt')=="+Steamworks.fileExists('test.txt'));
//comment.. writing to app with id 480 is somehow not working, but works with our real appId
log("writeFileToCloud('test.txt','hello steam')=="+writeFileToCloud('test.txt','hello steam'));
log("readFileFromCloud('test.txt')=="+readFileFromCloud('test.txt'));
//-----------
//Steamworks.requestStats();
Steamworks.resetAllStats(true);
}else {
tf.appendText("STEAMWORKS API is NOT available\n");
}
}
private function log(value:String):Void{
tf.appendText(value+"\n");
tf.scrollV=tf.maxScrollV;
}
public function writeFileToCloud(fileName:String, data:String):Bool {
var dataOut:ByteArray<Dynamic>=new ByteArray();
dataOut.writeUTFBytes(data);
return Steamworks.fileWrite(fileName, dataOut);
}
public function readFileFromCloud(fileName:String):String {
var dataIn:ByteArray<Dynamic>=new ByteArray();
var result:String;
dataIn.position=0;
dataIn.length=Steamworks.getFileSize(fileName);
if(dataIn.length>0 && Steamworks.fileRead(fileName,dataIn)){
result=dataIn.readUTFBytes(dataIn.length);
}
return result;
}
public function onClick(e:MouseEvent):Void{
log("--click--");
if(Steamworks.isReady){
if(!Steamworks.isAchievement("ACH_WIN_ONE_GAME")){
log("setAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.setAchievement("ACH_WIN_ONE_GAME"));
} else {
log("clearAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.clearAchievement("ACH_WIN_ONE_GAME"));
}
if(Steamworks.fileExists('test.txt')){
log("readFileFromCloud('test.txt')=="+readFileFromCloud('test.txt'));
log("Steamworks.fileDelete('test.txt')=="+Steamworks.fileDelete('test.txt'));
} else {
log("writeFileToCloud('test.txt','click')=="+writeFileToCloud('test.txt','click'));
}
//Steamworks.storeStats();
} else {
log("not able to set achievement\n");
}
}
public function onSteamResponse(e:SteamEvent):Void{
switch(e.req_type){
case SteamConstants.RESPONSE_OnUserStatsStored:
log("RESPONSE_OnUserStatsStored:"+e.response);
break;
case SteamConstants.RESPONSE_OnUserStatsReceived:
log("RESPONSE_OnUserStatsReceived:"+e.response);
break;
case SteamConstants.RESPONSE_OnAchievementStored:
log("RESPONSE_OnAchievementStored:"+e.response);
break;
default:
log("STEAMresponse type:"+e.req_type+" response:"+e.response);
}
}
}

View File

@ -0,0 +1,170 @@
/*
* FRESteamWorks.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
import flash.utils.ByteArray<Dynamic>;
import flash.utils.clearInterval;
import flash.utils.setInterval;
class FRESteamWorks extends EventDispatcher
{
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
private var _ExtensionContext:ExtensionContext;
private var _tm:Int;
public var isReady:Bool=false;
public function new(target:IEventDispatcher=null)
{
_ExtensionContext=ExtensionContext.createExtensionContext("com.amanitadesign.steam.FRESteamWorks", null);
_ExtensionContext.addEventListener(StatusEvent.STATUS, handleStatusEvent);
super(target);
}
private function handleStatusEvent(event:StatusEvent):Void{
//_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
var req_type:Int=new Std.int(event.code);
var response:Int=new Std.int(event.level);
var sEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
trace("handleStatusEvent:"+req_type+" "+response);
dispatchEvent(sEvent);
}
public function dispose():Void
{
clearInterval(_tm);
_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
_ExtensionContext.dispose();
}
public function init():Bool
{
isReady=_ExtensionContext.call("AIRSteam_Init")as Bool;
if(isReady) _tm=setInterval(runCallbacks, 100);
return isReady;
}
public function requestStats():Bool
{
return _ExtensionContext.call("AIRSteam_RequestStats")as Bool;
}
public function runCallbacks():Bool
{
return _ExtensionContext.call("AIRSteam_RunCallbacks")as Bool;
}
public function getUserID():String
{
return _ExtensionContext.call("AIRSteam_GetUserID")as String;
}
public function getPersonaName():String
{
return _ExtensionContext.call("AIRSteam_GetPersonaName")as String;
}
public function useCrashHandler(appID:Int, version:String, date:String, time:String):Bool
{
return _ExtensionContext.call("AIRSteam_UseCrashHandler", appID, version, date, time)as Bool;
}
public function setAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_SetAchievement", id)as Bool;
}
public function clearAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_ClearAchievement", id)as Bool;
}
public function isAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_IsAchievement", id)as Bool;
}
public function getStatInt(id:String):Int
{
return _ExtensionContext.call("AIRSteam_GetStatInt", id)as Int;
}
public function getStatFloat(id:String):Float
{
return _ExtensionContext.call("AIRSteam_GetStatFloat", id)as Float;
}
public function setStatInt(id:String, value:Int):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatInt", id, value)as Bool;
}
public function setStatFloat(id:String, value:Float):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatFloat", id, value)as Bool;
}
public function storeStats():Bool
{
return _ExtensionContext.call("AIRSteam_StoreStats")as Bool;
}
public function resetAllStats(bAchievementsToo:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_ResetAllStats", bAchievementsToo)as Bool;
}
public function getFileCount():Int
{
return _ExtensionContext.call("AIRSteam_GetFileCount")as Int;
}
public function getFileSize(fileName:String):Int
{
return _ExtensionContext.call("AIRSteam_GetFileSize", fileName)as Int;
}
public function fileExists(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileExists", fileName)as Bool;
}
public function fileWrite(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileWrite", fileName, data)as Bool;
}
public function fileRead(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileRead", fileName, data)as Bool;
}
public function fileDelete(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileDelete", fileName)as Bool;
}
public function isCloudEnabledForApp():Bool
{
return _ExtensionContext.call("AIRSteam_IsCloudEnabledForApp")as Bool;
}
public function setCloudEnabledForApp(enabled:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_SetCloudEnabledForApp", enabled)as Bool;
}
}

View File

@ -0,0 +1,333 @@
/*
* FRESteamWorks.as
* This file is part of FRESteamWorks.
*
* Created by Ventero<http://github.com/Ventero>
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam {
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.StatusEvent;
import flash.filesystem.File;
import flash.utils.ByteArray<Dynamic>;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.clearInterval;
import flash.utils.setInterval;
import helper.Achievements;
class FRESteamWorks extends EventDispatcher {
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
private static inline var PATH:String=".local/share/Steam/SteamApps/common/Anodyne/share/APIWrapper";
private var _file:File;
private var _process:NativeProcess;
private var _tm:Int;
private var _error:Bool=false;
public var isReady:Bool=false;
private static inline var AIRSteam_Init:Int=0;
private static inline var AIRSteam_RunCallbacks:Int=1;
private static inline var AIRSteam_RequestStats:Int=2;
private static inline var AIRSteam_SetAchievement:Int=3;
private static inline var AIRSteam_ClearAchievement:Int=4;
private static inline var AIRSteam_IsAchievement:Int=5;
private static inline var AIRSteam_GetStatInt:Int=6;
private static inline var AIRSteam_GetStatFloat:Int=7;
private static inline var AIRSteam_SetStatInt:Int=8;
private static inline var AIRSteam_SetStatFloat:Int=9;
private static inline var AIRSteam_StoreStats:Int=10;
private static inline var AIRSteam_ResetAllStats:Int=11;
private static inline var AIRSteam_GetFileCount:Int=12;
private static inline var AIRSteam_GetFileSize:Int=13;
private static inline var AIRSteam_FileExists:Int=14;
private static inline var AIRSteam_FileWrite:Int=15;
private static inline var AIRSteam_FileRead:Int=16;
private static inline var AIRSteam_FileDelete:Int=17;
private static inline var AIRSteam_IsCloudEnabledForApp:Int=18;
private static inline var AIRSteam_SetCloudEnabledForApp:Int=19;
private static inline var AIRSteam_GetUserID:Int=20;
private static inline var AIRSteam_GetPersonaName:Int=21;
private static inline var AIRSteam_UseCrashHandler:Int=22;
public function new(target:IEventDispatcher=null){
Achievements.DEBUG_TEXT +="making FRESteamworks\n";
try {
_file=File.userDirectory.resolvePath(PATH);
Achievements.DEBUG_TEXT +="Found file at\n" + _file.nativePath +"\n";
Achievements.DEBUG_TEXT +=_file.size.toString()+ " bytes\n";
} catch(e:Dynamic){
Achievements.DEBUG_TEXT +="COULDN'T FIND FILE";
}
_process=new NativeProcess();
_process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, eventDispatched);
_process.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, errorCallback);
super(target);
}
public function dispose():Void {
if(_process.running){
_process.closeInput();
_process.exit();
}
clearInterval(_tm);
isReady=false;
}
private function startProcess():Void {
var startupInfo:NativeProcessStartupInfo=new NativeProcessStartupInfo();
startupInfo.executable=_file;
_process.start(startupInfo);
}
public function init():Bool {
Achievements.DEBUG_TEXT +="Sanity check...\n";
if(_file==null || !_file.exists)return false;
Achievements.DEBUG_TEXT +="got file\n";
startProcess();
if(!_process.running){
Achievements.DEBUG_TEXT +="Process not running\n";
return false;
}
if(!callWrapper(AIRSteam_Init))return false;
isReady=readBoolResponse();
if(isReady)_tm=setInterval(runCallbacks, 100);
Achievements.DEBUG_TEXT +="ready? " + isReady.toString()+ "\n";
return isReady;
}
private function errorCallback(e:IOErrorEvent):Void {
_error=true;
// the process doesn't accept our input anymore, so just stop it
clearInterval(_tm);
if(_process.running){
try {
_process.closeInput();
} catch(e:Dynamic){
// no-op
}
_process.exit();
}
}
private function callWrapper(funcName:Int, params:Array<Dynamic>=null):Bool {
_error=false;
if(!_process.running){
Achievements.DEBUG_TEXT +="wrapper call fail\n";
return false;
}
var stdin:IDataOutput=_process.standardInput;
stdin.writeUTFBytes(funcName + "\n");
if(params){
for(i in 0...params.lengthi){
if(params[i] is ByteArray){
var length:Int=params[i].length;
// length + 1 for the added newline
stdin.writeUTFBytes(String(length + 1)+ "\n");
stdin.writeBytes(params[i]);
stdin.writeUTFBytes("\n");
} else {
stdin.writeUTFBytes(String(params[i])+ "\n");
}
}
}
return !_error;
}
private function waitForData(output:IDataInput):Int {
while(!output.bytesAvailable){
// wait
if(!_process.running)return 0;
}
return output.bytesAvailable;
}
private function readBoolResponse():Bool {
if(!_process.running)return false;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(1);
Achievements.DEBUG_TEXT +="bool resp:" + response.toString()+ "\n";
return(response=="t");
}
private function readIntResponse():Int {
if(!_process.running)return 0;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail);
return parseInt(response, 10);
}
private function readFloatResponse():Float {
if(!_process.running)return 0.0;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail)
return parseFloat(response);
}
private function readStringResponse():String {
if(!_process.running)return "";
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail)
return response;
}
private function eventDispatched(e:ProgressEvent):Void {
var stderr:IDataInput=_process.standardError;
var avail:Int=stderr.bytesAvailable;
var data:String=stderr.readUTFBytes(avail);
var pattern:RegExp=/__event__<(\d+),(\d+)>/g;
var result:Dynamic;
while((result=pattern.exec(data))){
var req_type:Int=new Std.int(result[1]);
var response:Int=new Std.int(result[2]);
var steamEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
dispatchEvent(steamEvent);
}
}
public function requestStats():Bool {
if(!callWrapper(AIRSteam_RequestStats))return false;
return readBoolResponse();
}
public function runCallbacks():Bool {
if(!callWrapper(AIRSteam_RunCallbacks))return false;
return true;
}
public function getUserID():String {
if(!callWrapper(AIRSteam_GetUserID))return "";
return readStringResponse();
}
public function getPersonaName():String {
if(!callWrapper(AIRSteam_GetPersonaName))return "";
return readStringResponse();
}
public function useCrashHandler(appID:Int, version:String, date:String, time:String):Bool {
if(!callWrapper(AIRSteam_UseCrashHandler, [appID, version, date, time]))return false;
return readBoolResponse();
}
public function setAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_SetAchievement, [id]))return false;
return readBoolResponse();
}
public function clearAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_ClearAchievement, [id]))return false;
return readBoolResponse();
}
public function isAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_IsAchievement, [id]))return false;
return readBoolResponse();
}
public function getStatInt(id:String):Int {
if(!callWrapper(AIRSteam_GetStatInt, [id]))return 0;
return readIntResponse();
}
public function getStatFloat(id:String):Float {
if(!callWrapper(AIRSteam_GetStatFloat, [id]))return 0.0;
return readFloatResponse();
}
public function setStatInt(id:String, value:Int):Bool {
if(!callWrapper(AIRSteam_SetStatInt, [id, value]))return false;
return readBoolResponse();
}
public function setStatFloat(id:String, value:Float):Bool {
if(!callWrapper(AIRSteam_SetStatFloat, [id, value]))return false;
return readBoolResponse();
}
public function storeStats():Bool {
if(!callWrapper(AIRSteam_StoreStats))return false;
return readBoolResponse();
}
public function resetAllStats(bAchievementsToo:Bool):Bool {
if(!callWrapper(AIRSteam_ResetAllStats, [bAchievementsToo]))return false;
return readBoolResponse();
}
public function getFileCount():Int {
if(!callWrapper(AIRSteam_GetFileCount))return 0;
return readIntResponse();
}
public function getFileSize(fileName:String):Int {
if(!callWrapper(AIRSteam_GetFileSize, [fileName]))return 0;
return readIntResponse();
}
public function fileExists(fileName:String):Bool {
if(!callWrapper(AIRSteam_FileExists, [fileName]))return false;
return readBoolResponse();
}
public function fileWrite(fileName:String, data:ByteArray):Bool {
if(!callWrapper(AIRSteam_FileWrite, [fileName, data]))return false;
return readBoolResponse();
}
public function fileRead(fileName:String, data:ByteArray):Bool {
if(!callWrapper(AIRSteam_FileRead, [fileName]))return false;
var success:Bool=readBoolResponse();
if(success){
var content:String=readStringResponse();
data.writeUTFBytes(content);
data.position=0;
}
return success;
}
public function fileDelete(fileName:String):Bool {
if(!callWrapper(AIRSteam_FileDelete, [fileName]))return false;
return readBoolResponse();
}
public function isCloudEnabledForApp():Bool {
if(!callWrapper(AIRSteam_IsCloudEnabledForApp))return false;
return readBoolResponse();
}
public function setCloudEnabledForApp(enabled:Bool):Bool {
if(!callWrapper(AIRSteam_SetCloudEnabledForApp, [enabled]))return false;
return readBoolResponse();
}
}

View File

@ -0,0 +1,21 @@
/*
* SteamConstants.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
class SteamConstants
{
public static inline var RESPONSE_OK:Int=0;
public static inline var RESPONSE_FAILED:Int=1;
public static inline var RESPONSE_OnUserStatsReceived:Int=0;
public static inline var RESPONSE_OnUserStatsStored:Int=1;
public static inline var RESPONSE_OnAchievementStored:Int=2;
public static inline var RESPONSE_OnGameOverlayActivated:Int=3;
}

View File

@ -0,0 +1,55 @@
/*
* SteamEvent.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
import flash.events.Event;
class SteamEvent extends Event
{
public static var STEAM_RESPONSE:String="steamResponse";
private var _req_type:Int=-1;
private var _response:Int=-1;
private var _data:Dynamic=null;
public function new(type:String, req_type:Int, response:Int, bubbles:Bool=false, cancelable:Bool=false)
{
super(type, bubbles, cancelable);
_response=response;
_req_type=req_type;
}
public var response(get_response, set_response):Int;
private function get_response():Int
{
return _response;
}
public var data(get_data, set_data):Dynamic;
private function get_data():Dynamic
{
return _data;
}
private function set_data(value:Dynamic):Void
{
_data=value;
}
public var req_type(get_req_type, null):Int;
private function get_req_type():Int
{
return _req_type;
}
override public function clone():Event
{
var event:SteamEvent=new SteamEvent(type, req_type, response, bubbles, cancelable);
event.data=data;
return event;
}
}

View File

@ -0,0 +1,42 @@
package ca.wegetsignal.nativeextensions;
class MacJoystick
{
public var id:Int=-1;
public var axes:Array<Float>;
public var buttons:Array<Bool>;
public function new(id:Int,numAxes:Int,numButtons:Int)
{
this.id=id;
this.axes=new Array<Float>(numAxes);
this.buttons=new Array<Bool>(numButtons);
}
/** Returns the value for axis at index between -1 and 1
* Returns 0 for invalid axis index queries */
public function getAxis(index:Int=0):Float {
if(index<0 || index>=axes.length)
return 0;
return axes[index];
}
/** Returns true if the button is on, false if released.
* Returns false if button index is out of valid range */
public function getButton(index:Int=0):Bool {
if(index<0 || index>=buttons.length)
return false;
return buttons[index];
}
private function updateAxes(params:Array):Void {
// first param is this joystick id.. or should be..
if(params[0] !=id)
throw new Dynamic("Invalid joystick ID for Axes update");
for(i in 1...params.lengthi){
axes[i-1]=Std.parseFloat(params[i]);
}
}
}

View File

@ -0,0 +1,26 @@
package ca.wegetsignal.nativeextensions;
import flash.events.Event;
/** joystick property is the affected MacJoystick object
* elementIndex means the button index that was updated
* axes updates include all axes as a limitation of the IOKit HID Manager */
class MacJoystickEvent extends Event
{
public static const JOYSTICK_ADDED:String="JOYSTICK_ADDED",
JOYSTICK_REMOVED:String="JOYSTICK_REMOVED",
JOYSTICK_BUTTON_PUSHED:String="JOYSTICK_BUTTON_PUSHED",
JOYSTICK_BUTTON_RELEASED:String="JOYSTICK_BUTTON_RELEASED",
JOYSTICK_AXES_UPDATED:String="JOYSTICK_AXES_UPDATED";
public var joystick:MacJoystick;
public var elementIndex:Int;
public function new(type:String,joystick:MacJoystick,elementIndex:Int=-1)
{
super(type);
this.joystick=joystick;
this.elementIndex=elementIndex;
}
}

View File

@ -0,0 +1,76 @@
package ca.wegetsignal.nativeextensions;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
import global.Keys;
class MacJoystickManager extends EventDispatcher
{
private static inline var EXTENSION_ID:String="ca.wegetsignal.nativeextensions.MacJoyANE";
private var context:ExtensionContext;
private var numJoysticks:Int=0;
public var joysticks:Array<Dynamic>=[];
private static const JOYSTICK_ADDED:String="JOYSTICK_ADDED",
JOYSTICK_REMOVED:String="JOYSTICK_REMOVED",
JOYSTICK_BUTTON_PUSHED:String="JOYSTICK_BUTTON_PUSHED",
JOYSTICK_BUTTON_RELEASED:String="JOYSTICK_BUTTON_RELEASED",
JOYSTICK_AXES_UPDATED:String="JOYSTICK_AXES_UPDATED";
public function new()
{
super();
context=ExtensionContext.createExtensionContext(EXTENSION_ID,null);
context.addEventListener(StatusEvent.STATUS,onStatus);
context.call("initializeGamepads",null);
}
public function numberOfJoysticks():Int {
return numJoysticks;
}
private function onStatus(event:StatusEvent):Void
{
var params:Array<Dynamic>=event.level.split(',');
var affectedJoystick:MacJoystick;
var elementIndex:Int=-1;
switch(event.code){
case JOYSTICK_ADDED:
// level is joystickID,numAxes,numButtons
affectedJoystick=new MacJoystick(int(params[0]),int(params[1]),int(params[2]));
joysticks[int(params[0])]=affectedJoystick;
numJoysticks++;
break;
case JOYSTICK_REMOVED:
affectedJoystick=joysticks[int(params[0])];
joysticks[int(params[0])]=null;
numJoysticks--;
break;
case JOYSTICK_BUTTON_PUSHED:
// level is joystickID,buttonIndex
affectedJoystick=joysticks[int(params[0])]
affectedJoystick.buttons[int(params[1])]=true;
elementIndex=Std.int(params[1]);
break;
case JOYSTICK_BUTTON_RELEASED:
// level is joystickID,buttonIndex
affectedJoystick=joysticks[int(params[0])]
affectedJoystick.buttons[int(params[1])]=false;
elementIndex=Std.int(params[1]);
break;
case JOYSTICK_AXES_UPDATED:
// level is joystickID,[axes]
affectedJoystick=joysticks[int(params[0])]
affectedJoystick.updateAxes(params);
break;
}
dispatchEvent(new MacJoystickEvent(event.code,affectedJoystick,elementIndex));
}
}

View File

@ -0,0 +1,115 @@
package;
import com.amanitadesign.steam.FRESteamWorks;
import com.amanitadesign.steam.SteamConstants;
import com.amanitadesign.steam.SteamEvent;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.utils.ByteArray<Dynamic>;
class FRESteamWorksTest extends Sprite
{
public var Steamworks:FRESteamWorks=new FRESteamWorks();
public var tf:TextField;
public function new()
{
tf=new TextField();
tf.width=stage.stageWidth;
tf.height=stage.stageHeight;
addChild(tf);
tf.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
Steamworks.addEventListener(SteamEvent.STEAM_RESPONSE, onSteamResponse);
if(Steamworks.init()){
log("STEAMWORKS API is available\n");
//comment.. current stats and achievement ids are from steam example app which is provided with their SDK
log("isAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.isAchievement("ACH_WIN_ONE_GAME"));
log("isAchievement('ACH_TRAVEL_FAR_SINGLE')=="+Steamworks.isAchievement("ACH_TRAVEL_FAR_SINGLE"));
log("setStatFloat('FeetTraveled')=="+Steamworks.setStatFloat('FeetTraveled', 21.3));
log("setStatInt('NumGames', 2)=="+Steamworks.setStatInt('NumGames', 2));
Steamworks.storeStats();
log("getStatInt('NumGames')=="+Steamworks.getStatInt('NumGames'));
log("getStatFloat('FeetTraveled')=="+Steamworks.getStatFloat('FeetTraveled'));
log("setCloudEnabledForApp(false)=="+Steamworks.setCloudEnabledForApp(false));
log("setCloudEnabledForApp(true)=="+Steamworks.setCloudEnabledForApp(true));
log("isCloudEnabledForApp()=="+Steamworks.isCloudEnabledForApp());
log("getFileCount()=="+Steamworks.getFileCount());
log("fileExists('test.txt')=="+Steamworks.fileExists('test.txt'));
//comment.. writing to app with id 480 is somehow not working, but works with our real appId
log("writeFileToCloud('test.txt','hello steam')=="+writeFileToCloud('test.txt','hello steam'));
log("readFileFromCloud('test.txt')=="+readFileFromCloud('test.txt'));
//-----------
//Steamworks.requestStats();
Steamworks.resetAllStats(true);
}else {
tf.appendText("STEAMWORKS API is NOT available\n");
}
}
private function log(value:String):Void{
tf.appendText(value+"\n");
tf.scrollV=tf.maxScrollV;
}
public function writeFileToCloud(fileName:String, data:String):Bool {
var dataOut:ByteArray<Dynamic>=new ByteArray();
dataOut.writeUTFBytes(data);
return Steamworks.fileWrite(fileName, dataOut);
}
public function readFileFromCloud(fileName:String):String {
var dataIn:ByteArray<Dynamic>=new ByteArray();
var result:String;
dataIn.position=0;
dataIn.length=Steamworks.getFileSize(fileName);
if(dataIn.length>0 && Steamworks.fileRead(fileName,dataIn)){
result=dataIn.readUTFBytes(dataIn.length);
}
return result;
}
public function onClick(e:MouseEvent):Void{
log("--click--");
if(Steamworks.isReady){
if(!Steamworks.isAchievement("ACH_WIN_ONE_GAME")){
log("setAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.setAchievement("ACH_WIN_ONE_GAME"));
} else {
log("clearAchievement('ACH_WIN_ONE_GAME')=="+Steamworks.clearAchievement("ACH_WIN_ONE_GAME"));
}
if(Steamworks.fileExists('test.txt')){
log("readFileFromCloud('test.txt')=="+readFileFromCloud('test.txt'));
log("Steamworks.fileDelete('test.txt')=="+Steamworks.fileDelete('test.txt'));
} else {
log("writeFileToCloud('test.txt','click')=="+writeFileToCloud('test.txt','click'));
}
//Steamworks.storeStats();
} else {
log("not able to set achievement\n");
}
}
public function onSteamResponse(e:SteamEvent):Void{
switch(e.req_type){
case SteamConstants.RESPONSE_OnUserStatsStored:
log("RESPONSE_OnUserStatsStored:"+e.response);
break;
case SteamConstants.RESPONSE_OnUserStatsReceived:
log("RESPONSE_OnUserStatsReceived:"+e.response);
break;
case SteamConstants.RESPONSE_OnAchievementStored:
log("RESPONSE_OnAchievementStored:"+e.response);
break;
default:
log("STEAMresponse type:"+e.req_type+" response:"+e.response);
}
}
}

View File

@ -0,0 +1,170 @@
/*
* FRESteamWorks.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
import flash.utils.ByteArray<Dynamic>;
import flash.utils.clearInterval;
import flash.utils.setInterval;
class FRESteamWorks extends EventDispatcher
{
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
private var _ExtensionContext:ExtensionContext;
private var _tm:Int;
public var isReady:Bool=false;
public function new(target:IEventDispatcher=null)
{
_ExtensionContext=ExtensionContext.createExtensionContext("com.amanitadesign.steam.FRESteamWorks", null);
_ExtensionContext.addEventListener(StatusEvent.STATUS, handleStatusEvent);
super(target);
}
private function handleStatusEvent(event:StatusEvent):Void{
//_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
var req_type:Int=new Std.int(event.code);
var response:Int=new Std.int(event.level);
var sEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
trace("handleStatusEvent:"+req_type+" "+response);
dispatchEvent(sEvent);
}
public function dispose():Void
{
clearInterval(_tm);
_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
_ExtensionContext.dispose();
}
public function init():Bool
{
isReady=_ExtensionContext.call("AIRSteam_Init")as Bool;
if(isReady) _tm=setInterval(runCallbacks, 100);
return isReady;
}
public function requestStats():Bool
{
return _ExtensionContext.call("AIRSteam_RequestStats")as Bool;
}
public function runCallbacks():Bool
{
return _ExtensionContext.call("AIRSteam_RunCallbacks")as Bool;
}
public function getUserID():String
{
return _ExtensionContext.call("AIRSteam_GetUserID")as String;
}
public function getPersonaName():String
{
return _ExtensionContext.call("AIRSteam_GetPersonaName")as String;
}
public function useCrashHandler(appID:Int, version:String, date:String, time:String):Bool
{
return _ExtensionContext.call("AIRSteam_UseCrashHandler", appID, version, date, time)as Bool;
}
public function setAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_SetAchievement", id)as Bool;
}
public function clearAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_ClearAchievement", id)as Bool;
}
public function isAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_IsAchievement", id)as Bool;
}
public function getStatInt(id:String):Int
{
return _ExtensionContext.call("AIRSteam_GetStatInt", id)as Int;
}
public function getStatFloat(id:String):Float
{
return _ExtensionContext.call("AIRSteam_GetStatFloat", id)as Float;
}
public function setStatInt(id:String, value:Int):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatInt", id, value)as Bool;
}
public function setStatFloat(id:String, value:Float):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatFloat", id, value)as Bool;
}
public function storeStats():Bool
{
return _ExtensionContext.call("AIRSteam_StoreStats")as Bool;
}
public function resetAllStats(bAchievementsToo:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_ResetAllStats", bAchievementsToo)as Bool;
}
public function getFileCount():Int
{
return _ExtensionContext.call("AIRSteam_GetFileCount")as Int;
}
public function getFileSize(fileName:String):Int
{
return _ExtensionContext.call("AIRSteam_GetFileSize", fileName)as Int;
}
public function fileExists(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileExists", fileName)as Bool;
}
public function fileWrite(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileWrite", fileName, data)as Bool;
}
public function fileRead(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileRead", fileName, data)as Bool;
}
public function fileDelete(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileDelete", fileName)as Bool;
}
public function isCloudEnabledForApp():Bool
{
return _ExtensionContext.call("AIRSteam_IsCloudEnabledForApp")as Bool;
}
public function setCloudEnabledForApp(enabled:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_SetCloudEnabledForApp", enabled)as Bool;
}
}

View File

@ -0,0 +1,335 @@
/*
* FRESteamWorks.as
* This file is part of FRESteamWorks.
*
* Created by Ventero<http://github.com/Ventero>
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam {
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.StatusEvent;
import flash.filesystem.File;
import flash.utils.ByteArray<Dynamic>;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.clearInterval;
import flash.utils.setInterval;
import helper.Achievements;
class FRESteamWorks extends EventDispatcher {
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
private static inline var PATH:String=".local/share/Steam/SteamApps/common/Anodyne/share/APIWrapper";
private var _file:File;
private var _process:NativeProcess;
private var _tm:Int;
private var _error:Bool=false;
public var isReady:Bool=false;
private static inline var AIRSteam_Init:Int=0;
private static inline var AIRSteam_RunCallbacks:Int=1;
private static inline var AIRSteam_RequestStats:Int=2;
private static inline var AIRSteam_SetAchievement:Int=3;
private static inline var AIRSteam_ClearAchievement:Int=4;
private static inline var AIRSteam_IsAchievement:Int=5;
private static inline var AIRSteam_GetStatInt:Int=6;
private static inline var AIRSteam_GetStatFloat:Int=7;
private static inline var AIRSteam_SetStatInt:Int=8;
private static inline var AIRSteam_SetStatFloat:Int=9;
private static inline var AIRSteam_StoreStats:Int=10;
private static inline var AIRSteam_ResetAllStats:Int=11;
private static inline var AIRSteam_GetFileCount:Int=12;
private static inline var AIRSteam_GetFileSize:Int=13;
private static inline var AIRSteam_FileExists:Int=14;
private static inline var AIRSteam_FileWrite:Int=15;
private static inline var AIRSteam_FileRead:Int=16;
private static inline var AIRSteam_FileDelete:Int=17;
private static inline var AIRSteam_IsCloudEnabledForApp:Int=18;
private static inline var AIRSteam_SetCloudEnabledForApp:Int=19;
private static inline var AIRSteam_GetUserID:Int=20;
private static inline var AIRSteam_GetPersonaName:Int=21;
private static inline var AIRSteam_UseCrashHandler:Int=22;
public function new(target:IEventDispatcher=null){
try {
_file=File.userDirectory.resolvePath(PATH);
Achievements.DEBUG_TEXT +="Found file at\n" + _file.nativePath +"\n";
Achievements.DEBUG_TEXT +=_file.size.toString()+ " bytes\n";
} catch(e:Dynamic){
Achievements.DEBUG_TEXT +="COULDN'T FIND FILE";
}
_process=new NativeProcess();
_process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, eventDispatched);
_process.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, errorCallback);
super(target);
}
public function dispose():Void {
if(_process.running){
_process.closeInput();
_process.exit();
}
clearInterval(_tm);
isReady=false;
}
private function startProcess():Void {
var startupInfo:NativeProcessStartupInfo=new NativeProcessStartupInfo();
startupInfo.executable=_file;
_process.start(startupInfo);
}
public function init():Bool {
trace("hi")
trace(Achievements.DEBUG_TEXT);
Achievements.DEBUG_TEXT +="Sanity check...";
trace(Achievements.DEBUG_TEXT);
if(_file==null || !_file.exists)return false;
Achievements.DEBUG_TEXT +="got file\n";
startProcess();
if(!_process.running){
Achievements.DEBUG_TEXT +="Process not running\n";
return false;
}
if(!callWrapper(AIRSteam_Init))return false;
isReady=readBoolResponse();
if(isReady)_tm=setInterval(runCallbacks, 100);
Achievements.DEBUG_TEXT +="ready? " + isReady.toString()+ "\n";
return isReady;
}
private function errorCallback(e:IOErrorEvent):Void {
_error=true;
// the process doesn't accept our input anymore, so just stop it
clearInterval(_tm);
if(_process.running){
try {
_process.closeInput();
} catch(e:Dynamic){
// no-op
}
_process.exit();
}
}
private function callWrapper(funcName:Int, params:Array<Dynamic>=null):Bool {
_error=false;
if(!_process.running){
Achievements.DEBUG_TEXT +="wrapper call fail\n";
return false;
}
var stdin:IDataOutput=_process.standardInput;
stdin.writeUTFBytes(funcName + "\n");
if(params){
for(i in 0...params.lengthi){
if(params[i] is ByteArray){
var length:Int=params[i].length;
// length + 1 for the added newline
stdin.writeUTFBytes(String(length + 1)+ "\n");
stdin.writeBytes(params[i]);
stdin.writeUTFBytes("\n");
} else {
stdin.writeUTFBytes(String(params[i])+ "\n");
}
}
}
return !_error;
}
private function waitForData(output:IDataInput):Int {
while(!output.bytesAvailable){
// wait
if(!_process.running)return 0;
}
return output.bytesAvailable;
}
private function readBoolResponse():Bool {
if(!_process.running)return false;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(1);
Achievements.DEBUG_TEXT +="bool resp:" + response.toString()+ "\n";
return(response=="t");
}
private function readIntResponse():Int {
if(!_process.running)return 0;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail);
return parseInt(response, 10);
}
private function readFloatResponse():Float {
if(!_process.running)return 0.0;
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail)
return parseFloat(response);
}
private function readStringResponse():String {
if(!_process.running)return "";
var stdout:IDataInput=_process.standardOutput;
var avail:Int=waitForData(stdout);
var response:String=stdout.readUTFBytes(avail)
return response;
}
private function eventDispatched(e:ProgressEvent):Void {
var stderr:IDataInput=_process.standardError;
var avail:Int=stderr.bytesAvailable;
var data:String=stderr.readUTFBytes(avail);
var pattern:RegExp=/__event__<(\d+),(\d+)>/g;
var result:Dynamic;
while((result=pattern.exec(data))){
var req_type:Int=new Std.int(result[1]);
var response:Int=new Std.int(result[2]);
var steamEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
dispatchEvent(steamEvent);
}
}
public function requestStats():Bool {
if(!callWrapper(AIRSteam_RequestStats))return false;
return readBoolResponse();
}
public function runCallbacks():Bool {
if(!callWrapper(AIRSteam_RunCallbacks))return false;
return true;
}
public function getUserID():String {
if(!callWrapper(AIRSteam_GetUserID))return "";
return readStringResponse();
}
public function getPersonaName():String {
if(!callWrapper(AIRSteam_GetPersonaName))return "";
return readStringResponse();
}
public function useCrashHandler(appID:Int, version:String, date:String, time:String):Bool {
if(!callWrapper(AIRSteam_UseCrashHandler, [appID, version, date, time]))return false;
return readBoolResponse();
}
public function setAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_SetAchievement, [id]))return false;
return readBoolResponse();
}
public function clearAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_ClearAchievement, [id]))return false;
return readBoolResponse();
}
public function isAchievement(id:String):Bool {
if(!callWrapper(AIRSteam_IsAchievement, [id]))return false;
return readBoolResponse();
}
public function getStatInt(id:String):Int {
if(!callWrapper(AIRSteam_GetStatInt, [id]))return 0;
return readIntResponse();
}
public function getStatFloat(id:String):Float {
if(!callWrapper(AIRSteam_GetStatFloat, [id]))return 0.0;
return readFloatResponse();
}
public function setStatInt(id:String, value:Int):Bool {
if(!callWrapper(AIRSteam_SetStatInt, [id, value]))return false;
return readBoolResponse();
}
public function setStatFloat(id:String, value:Float):Bool {
if(!callWrapper(AIRSteam_SetStatFloat, [id, value]))return false;
return readBoolResponse();
}
public function storeStats():Bool {
if(!callWrapper(AIRSteam_StoreStats))return false;
return readBoolResponse();
}
public function resetAllStats(bAchievementsToo:Bool):Bool {
if(!callWrapper(AIRSteam_ResetAllStats, [bAchievementsToo]))return false;
return readBoolResponse();
}
public function getFileCount():Int {
if(!callWrapper(AIRSteam_GetFileCount))return 0;
return readIntResponse();
}
public function getFileSize(fileName:String):Int {
if(!callWrapper(AIRSteam_GetFileSize, [fileName]))return 0;
return readIntResponse();
}
public function fileExists(fileName:String):Bool {
if(!callWrapper(AIRSteam_FileExists, [fileName]))return false;
return readBoolResponse();
}
public function fileWrite(fileName:String, data:ByteArray):Bool {
if(!callWrapper(AIRSteam_FileWrite, [fileName, data]))return false;
return readBoolResponse();
}
public function fileRead(fileName:String, data:ByteArray):Bool {
if(!callWrapper(AIRSteam_FileRead, [fileName]))return false;
var success:Bool=readBoolResponse();
if(success){
var content:String=readStringResponse();
data.writeUTFBytes(content);
data.position=0;
}
return success;
}
public function fileDelete(fileName:String):Bool {
if(!callWrapper(AIRSteam_FileDelete, [fileName]))return false;
return readBoolResponse();
}
public function isCloudEnabledForApp():Bool {
if(!callWrapper(AIRSteam_IsCloudEnabledForApp))return false;
return readBoolResponse();
}
public function setCloudEnabledForApp(enabled:Bool):Bool {
if(!callWrapper(AIRSteam_SetCloudEnabledForApp, [enabled]))return false;
return readBoolResponse();
}
}

View File

@ -0,0 +1,21 @@
/*
* SteamConstants.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
class SteamConstants
{
public static inline var RESPONSE_OK:Int=0;
public static inline var RESPONSE_FAILED:Int=1;
public static inline var RESPONSE_OnUserStatsReceived:Int=0;
public static inline var RESPONSE_OnUserStatsStored:Int=1;
public static inline var RESPONSE_OnAchievementStored:Int=2;
public static inline var RESPONSE_OnGameOverlayActivated:Int=3;
}

View File

@ -0,0 +1,55 @@
/*
* SteamEvent.as
* This file is part of FRESteamWorks.
*
* Created by David ´Oldes´ Oliva on 3/29/12.
* Contributors:Ventero<http://github.com/Ventero>
* Copyright(c)2012 Amanita Design. All rights reserved.
* Copyright(c)2012-2013 Level Up Labs, LLC. All rights reserved.
*/
package com.amanitadesign.steam;
import flash.events.Event;
class SteamEvent extends Event
{
public static var STEAM_RESPONSE:String="steamResponse";
private var _req_type:Int=-1;
private var _response:Int=-1;
private var _data:Dynamic=null;
public function new(type:String, req_type:Int, response:Int, bubbles:Bool=false, cancelable:Bool=false)
{
super(type, bubbles, cancelable);
_response=response;
_req_type=req_type;
}
public var response(get_response, set_response):Int;
private function get_response():Int
{
return _response;
}
public var data(get_data, set_data):Dynamic;
private function get_data():Dynamic
{
return _data;
}
private function set_data(value:Dynamic):Void
{
_data=value;
}
public var req_type(get_req_type, null):Int;
private function get_req_type():Int
{
return _req_type;
}
override public function clone():Event
{
var event:SteamEvent=new SteamEvent(type, req_type, response, bubbles, cancelable);
event.data=data;
return event;
}
}

View File

@ -0,0 +1,154 @@
package com.amanitadesign.steam;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
import flash.utils.ByteArray<Dynamic>;
import flash.utils.clearInterval;
import flash.utils.setInterval;
class FRESteamWorks extends EventDispatcher
{
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
private var _ExtensionContext:ExtensionContext;
private var _tm:Int;
public var isReady:Bool=false;
public function new(target:IEventDispatcher=null)
{
_ExtensionContext=ExtensionContext.createExtensionContext("com.amanitadesign.steam.FRESteamWorks", null);
_ExtensionContext.addEventListener(StatusEvent.STATUS, handleStatusEvent);
super(target);
}
private function handleStatusEvent(event:StatusEvent):Void{
//_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
var req_type:Int=new Std.int(event.code);
var response:Int=new Std.int(event.level);
var sEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
trace("handleStatusEvent:"+req_type+" "+response);
switch(req_type)
{
case SteamConstants.RESPONSE_OnUserStatsReceived:
trace("RESPONSE_OnUserStatsReceived");
break;
case SteamConstants.RESPONSE_OnAchievementStored:
trace("RESPONSE_OnAchievementStored");
break;
}
dispatchEvent(sEvent);
}
public function dispose():Void
{
clearInterval(_tm);
_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
_ExtensionContext.dispose();
}
public function init():Bool
{
isReady=_ExtensionContext.call("AIRSteam_Init")as Bool;
if(isReady) _tm=setInterval(runCallbacks, 100);
return isReady;
}
public function requestStats():Bool
{
return _ExtensionContext.call("AIRSteam_RequestStats")as Bool;
}
public function runCallbacks():Bool
{
return _ExtensionContext.call("AIRSteam_RunCallbacks")as Bool;
}
public function setAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_SetAchievement", id)as Bool;
}
public function clearAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_ClearAchievement", id)as Bool;
}
public function isAchievement(id:String):Bool
{
return _ExtensionContext.call("AIRSteam_IsAchievement", id)as Bool;
}
public function getStatInt(id:String):Int
{
return _ExtensionContext.call("AIRSteam_GetStatInt", id)as Int;
}
public function getStatFloat(id:String):Float
{
return _ExtensionContext.call("AIRSteam_GetStatFloat", id)as Float;
}
public function setStatInt(id:String, value:Int):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatInt", id, value)as Bool;
}
public function setStatFloat(id:String, value:Float):Bool
{
return _ExtensionContext.call("AIRSteam_SetStatFloat", id, value)as Bool;
}
public function storeStats():Bool
{
return _ExtensionContext.call("AIRSteam_StoreStats")as Bool;
}
public function resetAllStats(bAchievementsToo:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_ResetAllStats", bAchievementsToo)as Bool;
}
public function getFileCount():Int
{
return _ExtensionContext.call("AIRSteam_GetFileCount")as Int;
}
public function getFileSize(fileName:String):Int
{
return _ExtensionContext.call("AIRSteam_GetFileSize", fileName)as Int;
}
public function fileExists(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileExists", fileName)as Bool;
}
public function fileWrite(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileWrite", fileName, data)as Bool;
}
public function fileRead(fileName:String, data:ByteArray):Bool
{
return _ExtensionContext.call("AIRSteam_FileRead", fileName, data)as Bool;
}
public function fileDelete(fileName:String):Bool
{
return _ExtensionContext.call("AIRSteam_FileDelete", fileName)as Bool;
}
public function isCloudEnabledForApp():Bool
{
return _ExtensionContext.call("AIRSteam_IsCloudEnabledForApp")as Bool;
}
public function setCloudEnabledForApp(enabled:Bool):Bool
{
return _ExtensionContext.call("AIRSteam_SetCloudEnabledForApp", enabled)as Bool;
}
}

View File

@ -0,0 +1,10 @@
package com.amanitadesign.steam;
class SteamConstants
{
public static inline var RESPONSE_OK:Int=1;
public static inline var RESPONSE_FAILED:Int=2;
public static inline var RESPONSE_OnUserStatsReceived:Int=0;
public static inline var RESPONSE_OnUserStatsStored:Int=1;
public static inline var RESPONSE_OnAchievementStored:Int=2;
}

View File

@ -0,0 +1,45 @@
package com.amanitadesign.steam;
import flash.events.Event;
class SteamEvent extends Event
{
public static var STEAM_RESPONSE:String="steamResponse";
private var _req_type:Int=-1;
private var _response:Int=-1;
private var _data:Dynamic=null;
public function new(type:String, req_type:Int, response:Int, bubbles:Bool=false, cancelable:Bool=false)
{
super(type, bubbles, cancelable);
_response=response;
_req_type=req_type;
}
public var response(get_response, set_response):Int;
private function get_response():Int
{
return _response;
}
public var data(get_data, set_data):Dynamic;
private function get_data():Dynamic
{
return _data;
}
private function set_data(value:Dynamic):Void
{
_data=value;
}
public var req_type(get_req_type, null):Int;
private function get_req_type():Int
{
return _req_type;
}
override public function clone():Event
{
var event:SteamEvent=new SteamEvent(type, req_type, response, bubbles, cancelable);
event.data=data;
return event;
}
}

View File

@ -0,0 +1,81 @@
package data
{
/**
* BECAUSE STRING COMPARISONS ARE SLOW AS FUCK
* IN THE COLLISION LOGIC
*
*(I still do comparisons on names in SpriteFactory, though - not
* really an issue there)
*
*(IDs for any object that is compared with its xml name...)
* @author Seagaia
*/
class CLASS_ID
{
/* ENEMIES */
public static var SLIME:Int=0;
public static var MOVER:Int=1;
public static var PEW_LASER:Int=2;
public static var SHIELDY:Int=3;
public static var SUN_GUY:Int=4;
public static var WALL_LASER:Int=5;
public static var ANNOYER:Int=6;
public static var RED_WALKER:Int=7;
public static var FOUR_SHOOTER:Int=8;
public static var SLASHER:Int=9;
public static var ON_OFF_LASER:Int=10;
public static var RED_BOSS:Int=11;
public static var ROTATOR:Int=12;
public static var PERSON:Int=13;
public static var FROG:Int=14;
public static var DOG:Int=15;
public static var SPIKE_ROLLER:Int=16;
public static var WALLBOSS:Int=17;
public static var RAT:Int=18;
public static var SILVERFISH:Int=19;
public static var GASGUY:Int=20;
public static var TELEGUY:Int=21;
public static var DASHTRAP:Int=22;
public static var DUSTMAID:Int=23;
public static var BURSTPLANT:Int=24;
/* DECORATIONS */
public static var EYE_LIGHT:Int=100;
public static var SOLID_SPRITE:Int=101;
/* GADGETS */
public static var BUTTON:Int=200;
public static var CRACKEDTILE:Int=201;
public static var DOOR:Int=202;
public static var DUST:Int=203;
public static var GATE:Int=204;
public static var HOLE:Int=205;
public static var KEY:Int=206;
public static var KEYBLOCK:Int=207;
public static var SINGLEPUSHBLOCK:Int=208;
public static var TREASURE:Int=209;
public static var CONSOLE:Int=210;
public static var GROWTH_GATE:Int=211;
public static var CHALLENGE_GATE:Int=212;
public static var BIG_DOOR:Int=213;
public static var JUMP_TRIGGER:Int=214;
public static var PROPELLED:Int=215;
public static var STOP_MARKER:Int=216;
public static var PILLAR_SWITCH:Int=217;
/* OTHER */
public static var PLAYER:Int=300;
public static var HEALTHPICKUP:Int=301;
public static var BROOM:Int=302;
public static var EVENT_SCRIPT:Int=303;
public static var CONTROLSDEITY:Int=304;
public static var FOLLOWER_BRO:Int=305;
public static var RED_PILLAR:Int=306;
public static var FISHERMAN:Int=307;
public static var NPC_:Int=308;
public static var TRADE_NPC:Int=309;
public static var MITRA:Int=310;
}

View File

@ -0,0 +1,319 @@
package data
{
import org.flixel.plugin.photonstorm.FlxGridOverlay;
class CSV_Data
{
//[Embed(source="../csv/DEBUG_BG.csv", mimeType="application/octet-stream")] public static var DEBUG_BG:Class;
//[Embed(source="../csv/DEBUG_BG2.csv", mimeType="application/octet-stream")] public static var DEBUG_BG2:Class;
//[Embed(source="../csv/DEBUG_FG.csv", mimeType="application/octet-stream")] public static var DEBUG_FG:Class;
//[Embed(source="../csv/Bedroom_BG.csv", mimeType="application/octet-stream")] public static var BEDROOM_BG:Class;
////[Embed(source="../csv/Bedroom_BG2.csv", mimeType="application/octet-stream")] public static var BEDROOM_BG2:Class;
////[Embed(source="../csv/Bedroom_FG.csv", mimeType="application/octet-stream")] public static var BEDROOM_FG:Class;
//[Embed(source="../csv/FOREST_BG.csv", mimeType="application/octet-stream")] public static var FOREST_BG:Class;
//[Embed(source="../csv/FOREST_BG2.csv", mimeType="application/octet-stream")] public static var FOREST_BG2:Class;
//[Embed(source="../csv/FOREST_FG.csv", mimeType="application/octet-stream")] public static var FOREST_FG:Class;
//[Embed(source="../csv/FIELDS_BG.csv", mimeType="application/octet-stream")] public static var FIELDS_BG:Class;
////[Embed(source="../csv/FIELDS_BG2.csv", mimeType="application/octet-stream")] public static var FIELDS_BG2:Class;
//[Embed(source="../csv/FIELDS_FG.csv", mimeType="application/octet-stream")] public static var FIELDS_FG:Class;
//[Embed(source="../csv/STREET_BG.csv", mimeType="application/octet-stream")] public static var STREET_BG:Class;
//[Embed(source="../csv/STREET_BG2.csv", mimeType="application/octet-stream")] public static var STREET_BG2:Class;
//[Embed(source="../csv/STREET_FG.csv", mimeType="application/octet-stream")] public static var STREET_FG:Class;
//[Embed(source="../csv/OVERWORLD_BG.csv", mimeType="application/octet-stream")] public static var OVERWORLD_BG:Class;
//[Embed(source="../csv/OVERWORLD_BG2.csv", mimeType="application/octet-stream")] public static var OVERWORLD_BG2:Class;
////[Embed(source="../csv/OVERWORLD_FG.csv", mimeType="application/octet-stream")] public static var OVERWORLD_FG:Class;
//[Embed(source="../csv/BEACH_BG.csv", mimeType="application/octet-stream")] public static var BEACH_BG:Class;
////[Embed(source="../csv/BEACH_BG2.csv", mimeType="application/octet-stream")] public static var BEACH_BG2:Class;
////[Embed(source="../csv/BEACH_FG.csv", mimeType="application/octet-stream")] public static var BEACH_FG:Class;
//[Embed(source="../csv/BLANK_BG.csv", mimeType="application/octet-stream")] public static var BLANK_BG:Class;
////[Embed(source="../csv/BLANK_BG2.csv", mimeType="application/octet-stream")] public static var BLANK_BG2:Class;
////[Embed(source="../csv/BLANK_FG.csv", mimeType="application/octet-stream")] public static var BLANK_FG:Class;
//[Embed(source="../csv/REDSEA_BG.csv", mimeType="application/octet-stream")] public static var REDSEA_BG:Class;
////[Embed(source="../csv/REDSEA_BG2.csv", mimeType="application/octet-stream")] public static var REDSEA_BG2:Class;
//[Embed(source="../csv/REDSEA_FG.csv", mimeType="application/octet-stream")] public static var REDSEA_FG:Class;
//[Embed(source="../csv/REDCAVE_BG.csv", mimeType="application/octet-stream")] public static var REDCAVE_BG:Class;
//[Embed(source="../csv/REDCAVE_BG2.csv", mimeType="application/octet-stream")] public static var REDCAVE_BG2:Class;
////[Embed(source="../csv/REDCAVE_FG.csv", mimeType="application/octet-stream")] public static var REDCAVE_FG:Class;
//[Embed(source="../csv/NEXUS_BG.csv", mimeType="application/octet-stream")] public static var NEXUS_BG:Class;
////[Embed(source="../csv/NEXUS_BG2.csv", mimeType="application/octet-stream")] public static var NEXUS_BG2:Class;
//[Embed(source="../csv/NEXUS_FG.csv", mimeType="application/octet-stream")] public static var NEXUS_FG:Class;
//[Embed(source="../csv/CROWD_BG.csv", mimeType="application/octet-stream")] public static var CROWD_BG:Class;
//[Embed(source="../csv/CROWD_BG2.csv", mimeType="application/octet-stream")] public static var CROWD_BG2:Class;
////[Embed(source="../csv/CROWD_FG.csv", mimeType="application/octet-stream")] public static var CROWD_FG:Class;
//[Embed(source="../csv/APARTMENT_BG.csv", mimeType="application/octet-stream")] public static var APARTMENT_BG:Class;
//[Embed(source="../csv/APARTMENT_BG2.csv", mimeType="application/octet-stream")] public static var APARTMENT_BG2:Class;
//[Embed(source="../csv/APARTMENT_FG.csv", mimeType="application/octet-stream")] public static var APARTMENT_FG:Class;
//[Embed(source="../csv/TERMINAL_BG.csv", mimeType="application/octet-stream")] public static var TERMINAL_BG:Class;
//[Embed(source="../csv/TERMINAL_BG2.csv", mimeType="application/octet-stream")] public static var TERMINAL_BG2:Class;
////[Embed(source="../csv/TERMINAL_FG.csv", mimeType="application/octet-stream")] public static var TERMINAL_FG:Class;
//[Embed(source="../csv/HOTEL_BG.csv", mimeType="application/octet-stream")] public static var HOTEL_BG:Class;
//[Embed(source="../csv/HOTEL_BG2.csv", mimeType="application/octet-stream")] public static var HOTEL_BG2:Class;
//[Embed(source="../csv/HOTEL_FG.csv", mimeType="application/octet-stream")] public static var HOTEL_FG:Class;
/* NOTE!!!! CELL is called TRAIN in DAME because I'm an idiot. That's why. */
//[Embed(source="../csv/TRAIN_BG.csv", mimeType="application/octet-stream")] public static var CELL_BG:Class;
// //[Embed(source="../csv/TRAIN_BG2.csv", mimeType="application/octet-stream")] public static var CELL_BG2:Class;
////[Embed(source="../csv/TRAIN_FG.csv", mimeType="application/octet-stream")] public static var CELL_FG:Class;
//[Embed(source="../csv/CIRCUS_BG.csv", mimeType="application/octet-stream")] public static var CIRCUS_BG:Class;
////[Embed(source="../csv/CIRCUS_BG2.csv", mimeType="application/octet-stream")] public static var CIRCUS_BG2:Class;
//[Embed(source="../csv/CIRCUS_FG.csv", mimeType="application/octet-stream")] public static var CIRCUS_FG:Class;
//[Embed(source="../csv/WINDMILL_BG.csv", mimeType="application/octet-stream")] public static var WINDMILL_BG:Class;
//[Embed(source="../csv/WINDMILL_BG2.csv", mimeType="application/octet-stream")] public static var WINDMILL_BG2:Class;
////[Embed(source="../csv/WINDMILL_FG.csv", mimeType="application/octet-stream")] public static var WINDMILL_FG:Class;
//[Embed(source="../csv/GO_BG.csv", mimeType="application/octet-stream")] public static var GO_BG:Class;
//[Embed(source="../csv/GO_BG2.csv", mimeType="application/octet-stream")] public static var GO_BG2:Class;
////[Embed(source="../csv/GO_FG.csv", mimeType="application/octet-stream")] public static var GO_FG:Class;
//[Embed(source="../csv/HAPPY_BG.csv", mimeType="application/octet-stream")] public static var HAPPY_BG:Class;
//[Embed(source="../csv/HAPPY_BG2.csv", mimeType="application/octet-stream")] public static var HAPPY_BG2:Class;
////[Embed(source="../csv/HAPPY_FG.csv", mimeType="application/octet-stream")] public static var HAPPY_FG:Class;
//[Embed(source="../csv/BLUE_BG.csv", mimeType="application/octet-stream")] public static var BLUE_BG:Class;
//[Embed(source="../csv/BLUE_BG2.csv", mimeType="application/octet-stream")] public static var BLUE_BG2:Class;
////[Embed(source="../csv/BLUE_FG.csv", mimeType="application/octet-stream")] public static var BLUE_FG:Class;
//[Embed(source="../csv/SUBURB_BG.csv", mimeType="application/octet-stream")] public static var SUBURB_BG:Class;
////[Embed(source="../csv/SUBURB_BG2.csv", mimeType="application/octet-stream")] public static var SUBURB_BG2:Class;
////[Embed(source="../csv/SUBURB_FG.csv", mimeType="application/octet-stream")] public static var SUBURB_FG:Class;
//[Embed(source="../csv/SPACE_BG.csv", mimeType="application/octet-stream")] public static var SPACE_BG:Class;
//[Embed(source="../csv/SPACE_BG2.csv", mimeType="application/octet-stream")] public static var SPACE_BG2:Class;
//[Embed(source="../csv/SPACE_FG.csv", mimeType="application/octet-stream")] public static var SPACE_FG:Class;
//[Embed(source="../csv/CLIFF_BG.csv", mimeType="application/octet-stream")] public static var CLIFF_BG:Class;
//[Embed(source="../csv/CLIFF_BG2.csv", mimeType="application/octet-stream")] public static var CLIFF_BG2:Class;
////[Embed(source="../csv/CLIFF_FG.csv", mimeType="application/octet-stream")] public static var CLIFF_FG:Class;
//[Embed(source="../csv/DRAWER_BG.csv", mimeType="application/octet-stream")] public static var DRAWER_BG:Class;
/* Minimaps */
//[Embed(source="../csv/Minimap_Street.csv", mimeType="application/octet-stream")] public static var MM_Street:Class;
//[Embed(source="../csv/Minimap_Bedroom.csv", mimeType="application/octet-stream")] public static var MM_Bedroom:Class;
//[Embed(source="../csv/Minimap_Redcave.csv", mimeType="application/octet-stream")] public static var MM_Redcave:Class;
//[Embed(source="../csv/Minimap_Crowd.csv", mimeType="application/octet-stream")] public static var MM_Crowd:Class;
//[Embed(source="../csv/Minimap_Apartment.csv", mimeType="application/octet-stream")] public static var MM_Apartment:Class;
//[Embed(source="../csv/Minimap_Hotel.csv", mimeType="application/octet-stream")] public static var MM_Hotel:Class;
//[Embed(source="../csv/Minimap_Circus.csv", mimeType="application/octet-stream")] public static var MM_Circus:Class;
//[Embed(source="../csv/Minimap_Fields.csv", mimeType="application/octet-stream")] public static var MM_Fields:Class;
//[Embed(source="../csv/Minimap_Beach.csv", mimeType="application/octet-stream")] public static var MM_Beach:Class;
//[Embed(source="../csv/Minimap_Cliff.csv", mimeType="application/octet-stream")] public static var MM_Cliff:Class;
//[Embed(source="../csv/Minimap_Forest.csv", mimeType="application/octet-stream")] public static var MM_Forest:Class;
//[Embed(source="../csv/Minimap_Overworld.csv", mimeType="application/octet-stream")] public static var MM_Overworld:Class;
//[Embed(source="../csv/Minimap_Redsea.csv", mimeType="application/octet-stream")] public static var MM_Redsea:Class;
//[Embed(source="../csv/Minimap_Suburb.csv", mimeType="application/octet-stream")] public static var MM_Suburb:Class;
//[Embed(source="../csv/Minimap_Space.csv", mimeType="application/octet-stream")] public static var MM_Space:Class;
//[Embed(source="../csv/Minimap_Cell.csv", mimeType="application/octet-stream")] public static var MM_Train:Class;
//[Embed(source="../csv/Minimap_Terminal.csv", mimeType="application/octet-stream")] public static var MM_Terminal:Class;
public static var minimap_csv:Dynamic={ STREET:MM_Street, BEDROOM:MM_Bedroom , REDCAVE:MM_Redcave, APARTMENT:MM_Apartment, HOTEL:MM_Hotel, CIRCUS:MM_Circus , CROWD:MM_Crowd, FIELDS:MM_Fields, BEACH:MM_Beach, CLIFF:MM_Cliff, FOREST:MM_Forest, OVERWORLD:MM_Overworld, REDSEA:MM_Redsea, SUBURB:MM_Suburb, SPACE:MM_Space, TRAIN:MM_Train, TERMINAL:MM_Terminal};
public static var maps_with_fg:Array<Dynamic>=new Array("DEBUG", "SPACE","STREET", "APARTMENT", "HOTEL", "NEXUS","CIRCUS","FOREST", "REDSEA", "FIELDS");
public static var maps_with_bg2:Array<Dynamic>=new Array("TERMINAL", "SPACE","DEBUG", "OVERWORLD","HAPPY", "BLUE", "REDCAVE","STREET", "APARTMENT", "HOTEL", "CROWD", "WINDMILL","CLIFF","FOREST","GO");
// it looks like you're adding a new CSV.
// did you make sure to add in the new tiles in TileData?
// How to add in a layer once it's been exported from DAME:
// 1.Make sure the file is included above("Embed ...")- just follow the pattern
// 2. Depending on what you're adding, add that map's name to the arrays maps_with_fg or maps_with_bg2.
// 3. In the big if-statement head, find and insert the necessary code(use the "DEBUG" block as an example)
// 4. you should then be good to go.
/* Layers:0,1,2:BG. 1 is collidable, others are decoration. 3:FG */
/**
*
* @param mapName
* @param layer 0,1,2 Bg layers, 3 fg
* @return "0", otherwise the CSV as a string.
*/
public static function getMap(mapName:String,layer:Int=1):String {
var CSV:String="0,0";
if(layer==3){
if(maps_with_fg.indexOf(mapName)==-1){
return CSV;
}
//else go down there and define the behavior
}
if(layer==2){
if(maps_with_bg2.indexOf(mapName)==-1){
return CSV;
}
}
if(mapName=="DEBUG"){
if(layer==2){
CSV=new DEBUG_BG2();
} else if(layer==3){
CSV=new DEBUG_FG();
} else {
CSV=new DEBUG_BG();
}
} else if(mapName=="BEDROOM"){
CSV=new BEDROOM_BG();
} else if(mapName=="STREET"){
if(layer==2){
return new STREET_BG2();
} else if(layer==3){
CSV=new STREET_FG();
} else {
CSV=new STREET_BG();
}
} else if(mapName=="FIELDS"){
if(layer==3){
CSV=new FIELDS_FG();
} else {
CSV=new FIELDS_BG();
}
} else if(mapName=="OVERWORLD"){
if(layer==2){
CSV=new OVERWORLD_BG2();
} else {
CSV=new OVERWORLD_BG();
}
} else if(mapName=="BEACH"){
CSV=new BEACH_BG();
} else if(mapName=="BLANK"){
CSV=new BLANK_BG();
} else if(mapName=="REDSEA"){
if(layer==3){
CSV=new REDSEA_FG();
} else {
CSV=new REDSEA_BG();
}
} else if(mapName=="REDCAVE"){
if(layer==2){
CSV=new REDCAVE_BG2();
} else if(layer==3){
//CSV=new REDCAVE_FG();
} else {
CSV=new REDCAVE_BG();
}
} else if(mapName=="NEXUS"){
if(layer==2){
//CSV=new NEXUS_BG2();
} else if(layer==3){
CSV=new NEXUS_FG();
} else {
CSV=new NEXUS_BG();
}
} else if(mapName=="CROWD"){
if(layer==2){
CSV=new CROWD_BG2();
} else {
CSV=new CROWD_BG();
}
} else if(mapName=="APARTMENT"){
if(layer==2){
CSV=new APARTMENT_BG2();
} else if(layer==3){
CSV=new APARTMENT_FG();
} else {
CSV=new APARTMENT_BG();
}
} else if(mapName=="HOTEL"){
if(layer==2){
CSV=new HOTEL_BG2();
} else if(layer==3){
CSV=new HOTEL_FG();
} else {
CSV=new HOTEL_BG();
}
} else if(mapName=="CIRCUS"){
if(layer==3){
CSV=new CIRCUS_FG();
} else {
CSV=new CIRCUS_BG();
}
} else if(mapName=="WINDMILL"){
if(layer==2){
CSV=new WINDMILL_BG2();
} else {
CSV=new WINDMILL_BG();
}
} else if(mapName=="TRAIN"){ //CELL!!
CSV=new CELL_BG();
} else if(mapName=="FOREST"){
if(layer==3){
CSV=new FOREST_FG();
} else if(layer==2){
CSV=new FOREST_BG2();
} else {
CSV=new FOREST_BG();
}
} else if(mapName=="BLUE"){
if(layer==2){
CSV=new BLUE_BG2();
} else {
CSV=new BLUE_BG();
}
} else if(mapName=="HAPPY"){
if(layer==2){
CSV=new HAPPY_BG2();
} else {
CSV=new HAPPY_BG();
}
} else if(mapName=="TERMINAL"){
if(layer==2){
CSV=new TERMINAL_BG2();
} else {
CSV=new TERMINAL_BG();
}
} else if(mapName=="GO"){
if(layer==2){
CSV=new GO_BG2();
} else {
CSV=new GO_BG();
}
} else if(mapName=="SUBURB"){
CSV=new SUBURB_BG();
} else if(mapName=="CLIFF"){
if(layer==2){
CSV=new CLIFF_BG2();
} else {
CSV=new CLIFF_BG();
}
} else if(mapName=="DRAWER"){
CSV=new DRAWER_BG();
} else if(mapName=="SPACE"){
if(layer==2){
CSV=new SPACE_BG2();
} else if(layer==3){
CSV=new SPACE_FG();
} else {
CSV=new SPACE_BG();
}
}
return CSV;
}
}

View File

@ -0,0 +1,66 @@
package data
{
import flash.display.Bitmap;
import flash.display.BitmapData;
/* Embedded sprites common to multiple entities, e.g., shadows */
public class Common_Sprites
{
/* Normal shadow that is used by bullets and has two animations */
//[Embed(source="../res/sprites/decoration/shadows/8x8_shadow.png")] public static var shadow_sprite_8_8:Class;
//[Embed(source="../res/sprites/decoration/SPACE_BG.png")] public static var space_bg:Class;
//[Embed(source="../res/sprites/decoration/briar_BG.png")] public static var briar_Bg:Class;
//[Embed(source="../res/sprites/decoration/nexus_bg.png")] public static var nexus_bg:Class;
/* This shadow has 5 frames, and its frame is determined by the fist's y-offset
*(or height)used by Wallboss fists, and Eyeboss Land form */
//[Embed(source="../res/sprites/decoration/shadows/28x10_shadow.png")] public static var shadow_sprite_28_10:Class;
//[Embed(source="../helper/static.pbj", mimeType="application/octet-stream")] public static inline var static_shader:Class;
// OVERLAYS
// 160x160 image, tiled 2x2. No anims.
//[Embed(source="../res/sprites/decoration/overlays/debug_overlay.png")] public static var debug_overlay:Class;
//[Embed(source="../res/sprites/decoration/overlays/windmill_overlay.png")] public static var windmill_overlay:Class;
//[Embed(source="../res/sprites/decoration/overlays/happy_overlay.png")] public static inline var happy_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/redsea_overlay.png")] public static inline var redsea_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/ending_overlay.png")] public static inline var ending_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/forest_overlay.png")] public static inline var forest_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/cliff_overlay.png")] public static inline var cliff_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/apartment_overlay.png")] public static inline var apartment_Blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/beach_overlay.png")] public static inline var beach_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/space_overlay.png")] public static inline var space_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/hotel_overlay.png")] public static inline var hotel_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/hotel_roof_overlay.png")] public static inline var roof_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/suburbs_overlay.png")] public static inline var suburbs_Blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/bedroom_overlay.png")] public static inline var bedroom_Blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/blue_overlay.png")] public static inline var blue_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/circus_overlay.png")] public static inline var circus_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/windmill_overlay2.png")] public static inline var windmill2_Blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/terminal_overlay.png")] public static inline var terminal_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/street_overlay.png")] public static inline var street_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/nexus_overlay.png")] public static inline var nexus_Blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/crowd_overlay.png")] public static inline var crowd_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/go_overlay.png")] public static inline var go_blend:Class;
//[Embed(source="../res/sprites/decoration/overlays/redcave_overlay .png")] public static inline var redcave_blend:Class;
public static var static_map:Bitmap;
public static function init():Void {
static_map=new Bitmap(new BitmapData(320, 320,true,0x00000000));
var alpha:Int;
var gray:Int;
var maxalpha:Int=80;
var maxgray:Int=80;
for(i in 0...320){
for(j in 0...320){
alpha=maxalpha * Math.random();
gray=maxgray * Math.random();
static_map.bitmapData.setPixel32(j, i,(alpha<<24)|(gray)|(gray<<8)|(gray<<16));
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,849 @@
package data
{
import helper.Cutscene;
import org.flixel.FlxG;
import org.flixel.FlxGroup;
import org.flixel.FlxSave;
import org.flixel.FlxSprite;
import org.flixel.FlxBasic;
import global.Registry;
import org.flixel.FlxSound;
class SoundData
{
//[Embed(source="../../../mp3/title.mp3")] public static var Title_Song:Class;
public var TITLE:FlxSound=new FlxSound();
private var Title_Samples:Int=2491776;//checked 9-15-12
//[Embed(source="../../../mp3/gameover.mp3")] public static var GameOver_Song:Class;
public var GameOver:FlxSound=new FlxSound();
private var GameOver_Samples:Int=1397376;//checked 9-15-12
//[Embed(source="../../../mp3/blank.mp3")] public static var Blank_Song:Class;
public var BLANK:FlxSound=new FlxSound();
private var Blank_Samples:Int=1568576;//checked 9-15-12
//[Embed(source="../../../mp3/nexus.mp3")] public static var Nexus_Song:Class;
public var NEXUS:FlxSound=new FlxSound();
private var NEXUSSAMPLES:Int=2983680;//checked 9-15-12
//[Embed(source="../../../mp3/street.mp3")] public static var Street_Song:Class;//street
public var STREET:FlxSound=new FlxSound();
private var Street_Samples:Int=2118528;//checked 9-15-12
//[Embed(source="../../../mp3/overworld.mp3")] public static var Overworld_Song:Class;//OVERWORLD
public var OVERWORLD:FlxSound=new FlxSound();
private var Overworld_Samples:Int=3646080;//checked 9-15-12
//[Embed(source="../../../mp3/mitra.mp3")] public static var Mitra_Song:Class;
public var MITRA:FlxSound=new FlxSound();
private var MITRASAMPLES:Int=2290176;//checked 9-15-12
//[Embed(source="../../../mp3/bedroom.mp3")] public static var Bedroom_Song:Class;//Bedroom
public var BEDROOM:FlxSound=new FlxSound();
private var Bedroom_Samples:Int=5293440;//checked 9-15-12
public var BOSS:FlxSound=new FlxSound();
//[Embed(source="../../../mp3/bedroom-boss.mp3")] public static var BedroomBoss_Song:Class;
public var BEDROOMBOSS:FlxSound=new FlxSound();
private var BEDROOMBOSSSAMPLES:Int=1580491;
//[Embed(source="../../../mp3/fields.mp3")] public static var Fields_Song:Class;
public var FIELDS:FlxSound=new FlxSound();
private var FIELDSSAMPLES:Int=6298125;//checked 9-15-12
///*
//[Embed(source="../../../mp3/beach.mp3")] public static var Beach_Song:Class;
public var BEACH:FlxSound=new FlxSound();
private var Beach_Samples:Int=3479040;
//[Embed(source="../../../mp3/red_cave.mp3")] public static var Red_Cave_Song:Class;
public var REDCAVE:FlxSound=new FlxSound();//checked 10-7-12
private var Red_Cave_Samples:Int=4021920;
//[Embed(source="../../../mp3/red_sea.mp3")] public static var Red_Sea_Song:Class;
public var REDSEA:FlxSound=new FlxSound();
private var Red_Sea_Samples:Int=2723328;
//[Embed(source="../../../mp3/redcave-boss.mp3")] public static var RedcaveBoss_Song:Class;
public var REDCAVEBOSS:FlxSound=new FlxSound();
private var REDCAVEBOSSSAMPLES:Int=1881600;
//[Embed(source="../../../mp3/windmill.mp3")] public static var Windmill_Song:Class;
public var WINDMILL:FlxSound=new FlxSound();
private var WINDMILLSAMPLES:Int=5019267;// checked 10-20-12
// END EXTENDED DEMO
//[Embed(source="../../../mp3/apartment.mp3")] public static var Apartment_Song:Class;
public var APARTMENT:FlxSound=new FlxSound();
private var APARTMENTSAMPLES:Int=8192009;
//[Embed(source="../../../mp3/forest.mp3")] public static var Forest_Song:Class;
public var FOREST:FlxSound=new FlxSound();
private var FORESTSAMPLES:Int=6542962;// 10-26
//[Embed(source="../../../mp3/cliff.mp3")] public static var Cliff_Song:Class;
public var CLIFF:FlxSound=new FlxSound();
private var CLIFFSAMPLES:Int=5840402;// 10-26
//[Embed(source="../../../mp3/crowd.mp3")] public static var Crowd_Song:Class;
public var CROWD:FlxSound=new FlxSound();//checked 10-7-12
private var CROWDSAMPLES:Int=6919426;
//[Embed(source="../../../mp3/space.mp3")] public static var Space_Song:Class;
public var SPACE:FlxSound=new FlxSound();//1-8-12
private var SPACESAMPLES:Int=4907395;
//[Embed(source="../../../mp3/terminal.mp3")] public static var Terminal_Song:Class;
public var TERMINAL:FlxSound=new FlxSound();
private var TERMINALSAMPLES:Int=7560503;// 1-8-12
//[Embed(source="../../../mp3/cell.mp3")] public static var Cell_Song:Class;
public var CELL:FlxSound=new FlxSound();
private var CELLSAMPLES:Int=5409600;//11-3-12
//[Embed(source="../../../mp3/suburb.mp3")] public static var Suburb_Song:Class;
public var SUBURB:FlxSound=new FlxSound();
private var SUBURBSAMPLES:Int=3182553;
//[Embed(source="../../../mp3/roof.mp3")] public static var Roof_Song:Class;
public var ROOF:FlxSound=new FlxSound();
private var ROOFSAMPLES:Int=7112084;
//[Embed(source="../../../mp3/circus.mp3")] public static var Circus_Song:Class;
public var CIRCUS:FlxSound=new FlxSound();
private var CIRCUSSAMPLES:Int=7566553;
//[Embed(source="../../../mp3/hotel.mp3")] public static var Hotel_Song:Class;
public var HOTEL:FlxSound=new FlxSound();// 12-2-12
private var HOTELSAMPLES:Int=9328688;
//[Embed(source="../../../mp3/happy.mp3")] public static var Happy_Song:Class;
public var HAPPY:FlxSound=new FlxSound();
private var HAPPYSAMPLES:Int=4456421;//checked 11-3-12
//[Embed(source="../../../mp3/blue.mp3")] public static var Blue_Song:Class;
public var BLUE:FlxSound=new FlxSound();
private var BLUESAMPLES:Int=6755745;//12-8-12
//[Embed(source="../../../mp3/go.mp3")] public static var Go_Song:Class;
public var GO:FlxSound=new FlxSound();
private var GOSAMPLES:Int=8090854;
//[Embed(source="../../../mp3/sagefight.mp3")] public static var Sagefight_Song:Class;
public var SAGEFIGHT:FlxSound=new FlxSound();// checked 10-20-12
private var SAGEFIGHTSAMPLES:Int=7467224;
private var SAGEFIGHTLOOP:Int=2061770;
//[Embed(source="../../../mp3/happy-init.mp3")] public static var Happyinit_song:Class;
public var HAPPYINIT:FlxSound=new FlxSound();
private var HAPPYINITSAMPLES:Int=1128960;
//[Embed(source="../../../mp3/ending.mp3")] public static var Ending_Song:Class;
public var ENDING:FlxSound=new FlxSound();
private var ENDINGSAMPLES:Int=15323054;
//[Embed(source="../../../mp3/briar-fight.mp3")] public static var BriarFight_Song:Class;
public var BRIARFIGHT:FlxSound=new FlxSound();
private var BRIARFIGHTSAMPLES:Int=5171605;// 11-25-12
//[Embed(source="../../../mp3/pre_terminal.mp3")] public static var PreTerminal_Song:Class;
public var PRETERMINAL:FlxSound=new FlxSound();
private var PRETERMSAMPLES:Int=1226195;
//[Embed(source="../../../mp3/soft.mp3")] public static var Soft_Song:Class;
public var SOFT:FlxSound=new FlxSound();
private var SOFTSAMPLES:Int=5007429;
//[Embed(source="../../../mp3/crowd_boss.mp3")] public static var CrowdBoss_Song:Class;
public var CROWDBOSS:FlxSound=new FlxSound();
private var CROWDBOSSSAMPLES:Int=1128960;
//[Embed(source="../../../mp3/apartment-boss.mp3")] public static var ApartmentBoss_Song:Class;
public var APARTMENTBOSS:FlxSound=new FlxSound();
private var APARTMENTBOSSSAMPLES:Int=1411199;
//[Embed(source="../../../mp3/hotel-boss.mp3")] public static var HotelBoss_Song:Class;
public var HOTELBOSS:FlxSound=new FlxSound();
private var HOTELBOSSSAMPLES:Int=1394129;
//[Embed(source="../../../mp3/circus-boss.mp3")] public static var CircusBoss_Song:Class;
public var CIRCUSBOSS:FlxSound=new FlxSound();
private var CIRCUSBOSSSAMPLES:Int=1299789;
//*/
/* Gadgets */
//[Embed(source="../../../sfx/unlock.mp3")] private var S_UNLOCK:Class;// Open locked door
//[Embed(source="../../../sfx/open.mp3")] private var S_OPEN:Class;// Gate open jingle
//[Embed(source="../../../sfx/pushblock.mp3")] private var S_PUSH_BLOCK:Class;
//[Embed(source="../../../sfx/gettreasure.mp3")] private var S_GET_TREASURE:Class;
//[Embed(source="../../../sfx/keyget.mp3")] private var S_GET_KEY:Class;//
//[Embed(source="../../../sfx/button_up.mp3")] public static var S_BUTTON_UP:Class;
//[Embed(source="../../../sfx/button_down.mp3")] public static var S_BUTTON_DOWN:Class;
//[Embed(source="../../../sfx/floor_crack.mp3")] public static var S_FLOOR_CRACK:Class;
//[Embed(source="../../../sfx/big_door_locked.mp3")] public static var S_Big_Door_Locked:Class;
//[Embed(source="../../../sfx/fall_1.mp3")] public static var sfall1:Class;//Falling - spike roller
//[Embed(source="../../../sfx/hit_ground_1.mp3")] public static var shitground1:Class;//Spike roller hits walls
//[Embed(source="../../../sfx/sparkle_1.mp3")] public static var sparkle_1_c:Class;
//[Embed(source="../../../sfx/sparkle_2.mp3")] public static var sparkle_2_c:Class;
//[Embed(source="../../../sfx/sparkle_3.mp3")] public static var sparkle_3_c:Class;
//[Embed(source="../../../sfx/dash_pad_1.mp3")] public static var embed_dash_pad_1:Class;//
//[Embed(source="../../../sfx/dash_pad_2.mp3")] public static var embed_dash_pad_2:Class;
//[Embed(source="../../../sfx/spring_bounce.mp3")] public static var embed_spring_bounce:Class;
/* Other things */
//[Embed(source="../../../sfx/cicada_chirp.mp3")] public static var cicada_chirp_c:Class;
//[Embed(source="../../../sfx/cross2.mp3")] public static var embed_cross2:Class;
//[Embed(source="../../../sfx/cross3.mp3")] public static var embed_cross3:Class;
//[Embed(source="../../../sfx/cross4.mp3")] public static var embed_cross4:Class;
/* Bedroom */
//[Embed(source="../../../sfx/laser-pew.mp3")] public static var S_LASER_PEW:Class;
//[Embed(source="../../../sfx/shieldy-hit.mp3")] public static var S_SHIELDY_HIT:Class;
//[Embed(source="../../../sfx/shieldy_ineffective.mp3")] public static var shieldy_ineffective_embed:Class;
//[Embed(source="../../../sfx/slime_walk.mp3")] public static var slime_walk_embed:Class;
//[Embed(source="../../../sfx/slime_splash.mp3")] public static var slime_splash_embed:Class;
//[Embed(source="../../../sfx/slime_shoot.mp3")] public static var slime_shoot_embed:Class;
/* Sun boss */
//[Embed(source="../../../sfx/sun_guy_scream2.mp3")] public static var S_SUN_GUY_SCREAM:Class;//softer
//[Embed(source="../../../sfx/sun_guy_charge.mp3")] public static var S_SUN_GUY_CHARGE:Class;//
/* Redcave */
//[Embed(source="../../../sfx/slasher_atk.mp3")] public static var slasher_atk_embed:Class;//
//[Embed(source="../../../sfx/on_off_laser_shoot.mp3")] public static var on_off_laser_shoot_embed:Class;
//[Embed(source="../../../sfx/4sht_shoot.mp3")] public static var four_shooter_shoot:Class;
//[Embed(source="../../../sfx/4sht_pop.mp3")] public static var four_shooter_pop:Class;
//[Embed(source="../../../sfx/mover_die.mp3")] public static var mover_die:Class;
//[Embed(source="../../../sfx/mover_move.mp3")] public static var mover_move:Class;
//[Embed(source="../../../sfx/red_cave_rise.mp3")] public static var embed_red_cave_rise:Class;
/* Red boss */
//[Embed(source="../../../sfx/bubble_loop.mp3")] public static var embed_bubble_loop:Class;
//[Embed(source="../../../sfx/bubble_1.mp3")] public static var embed_bubble_1:Class;
//[Embed(source="../../../sfx/bubble_2.mp3")] public static var embed_bubble_2:Class;
//[Embed(source="../../../sfx/bubble_3.mp3")] public static var embed_bubble_3:Class;
//[Embed(source="../../../sfx/bubble_triple.mp3")] public static var embed_bubble_triple:Class;
//[Embed(source="../../../sfx/redboss_moan.mp3")] public static var embed_redboss_moan:Class;
//[Embed(source="../../../sfx/small_wave.mp3")] public static var embed_small_wave:Class;
//[Embed(source="../../../sfx/big_wave.mp3")] public static var embed_big_wave:Class;
//[Embed(source="../../../sfx/redboss_death.mp3")] public static var embed_redboss_death:Class;
/* Crowd */
//[Embed(source="../../../sfx/dog_bark.mp3")] public static var embed_dog_bark:Class;//
//[Embed(source="../../../sfx/dog_dash.mp3")] public static var embed_dog_dash:Class;
//[Embed(source="../../../sfx/talk_1.mp3")] public static var embed_talk_1:Class;
//[Embed(source="../../../sfx/talk_2.mp3")] public static var embed_talk_2:Class;
//[Embed(source="../../../sfx/talk_3.mp3")] public static var embed_talk_3:Class;
//wallboss
//[Embed(source="../../../sfx/wb_hit_ground.mp3")] public static var embed_wb_hit_ground:Class;
//[Embed(source="../../../sfx/wb_tap_ground.mp3")] public static var embed_wb_tap_ground:Class;
//[Embed(source="../../../sfx/wb_shoot.mp3")] public static var embed_wb_shoot:Class;
//[Embed(source="../../../sfx/wb_moan.mp3")] public static var embed_wb_moan:Class;
//[Embed(source="../../../sfx/wb_moan_2.mp3")] public static var embed_wb_moan_2:Class;
//[Embed(source="../../../sfx/talk_death.mp3")] public static var embed_talk_death:Class;
//apt
//[Embed(source="../../../sfx/teleguy_up.mp3")] public static var embed_teleguy_up:Class;
//[Embed(source="../../../sfx/teleguy_down.mp3")] public static var embed_teleguy_down:Class;
//[Embed(source="../../../sfx/gasguy_shoot.mp3")] public static var embed_gasguy_shoot:Class;
//[Embed(source="../../../sfx/gasguy_move.mp3")] public static var embed_gasguy_move:Class;
//[Embed(source="../../../sfx/sf_move.mp3")] public static var embed_sf_move:Class;
//[Embed(source="../../../sfx/rat_move.mp3")] public static var embed_rat_move:Class;
//splitboss
//[Embed(source="../../../sfx/sb_split.mp3")] public static var embed_sb_split:Class;
//[Embed(source="../../../sfx/sb_ball_appear.mp3")] public static var embed_sb_ball_appear:Class;
//[Embed(source="../../../sfx/sb_hurt.mp3")] public static var embed_sb_hurt:Class;
//[Embed(source="../../../sfx/sb_dash.mp3")] public static var embed_sb_dash:Class;
/* hotel */
//[Embed(source="../../../sfx/dustmaid_alert.mp3")] public static var embed_dustmaid_alert:Class;
//[Embed(source="../../../sfx/elevator_open.mp3")] public static var embed_elevator_open:Class;
//[Embed(source="../../../sfx/elevator_close.mp3")] public static var embed_elevator_close:Class;
/* Circus */
//[Embed(source="../../../sfx/flame_pillar.mp3")] public static var embed_flame_pillar:Class;
//[Embed(source="../../../sfx/fireball.mp3")] public static var embed_fireball:Class;
/* etc */
//[Embed(source="../../../sfx/briar_shine.mp3")] public static var embed_briar_shine:Class;//
//[Embed(source="../../../sfx/stream.mp3")] public static var embed_stream:Class;
//[Embed(source="../../../sfx/dust_explode.mp3")] public static var embed_dust_explode:Class;
/* Explosions/rumbles */
//[Embed(source="../../../sfx/hit_wall.mp3")] public static var S_HIT_WALL:Class;//Bat die, sun guy hit wall
//[Embed(source="../../../sfx/sun_guy_death_long.mp3")] public static var S_SUN_GUY_DEATH_L:Class;
//[Embed(source="../../../sfx/sun_guy_death_short.mp3")] public static var S_SUN_GUY_DEATH_S:Class;
//[Embed(source="../../../sfx/broom_hit.mp3")] public static var embed_broom_hit:Class;
/* Player */
//[Embed(source="../../../sfx/player_hit_1.mp3")] public static var S_PLAYER_HIT_1:Class;//Hitting an enemy
//[Embed(source="../../../sfx/noise_step_1.mp3")] public static var S_NOISE_STEP_1:Class;
//[Embed(source="../../../sfx/water_step.mp3")] public static var water_step:Class;
//[Embed(source="../../../sfx/enter_door.mp3")] public static var embed_enter_door:Class;
//[Embed(source="../../../sfx/fall_in_hole.mp3")] private var S_FALL_IN_HOLE:Class;//
//[Embed(source="../../../sfx/get_small_health.mp3")] public static var S_GET_SMALL_HEALTH:Class;
//[Embed(source="../../../sfx/swing_broom_1.mp3")] public static var swing_broom_1:Class;
//[Embed(source="../../../sfx/swing_broom_2.mp3")] public static var swing_broom_2:Class;
//[Embed(source="../../../sfx/swing_broom_3.mp3")] public static var swing_broom_3:Class;
//[Embed(source="../../../sfx/player_jump_up.mp3")] private static var player_jump_up_sound:Class;
//[Embed(source="../../../sfx/player_jump_down.mp3")] private static var player_jump_down_sound:Class;
//[Embed(source="../../../sfx/puddle_up.mp3")] private static var embed_puddle_up:Class;
//[Embed(source="../../../sfx/puddle_down.mp3")] private static var embed_puddle_down:Class;
//[Embed(source="../../../sfx/puddle_step.mp3")] private static var embed_puddle_step:Class;
//[Embed(source="../../../sfx/ladder_step_2.mp3")] private static var embed_ladder_step_2:Class;
//[Embed(source="../../../sfx/ladder_step_1.mp3")] private static var embed_ladder_step_1:Class;
//[Embed(source="../../../sfx/teleport_up.mp3")] public static var S_TELEPORT_UP:Class;//
//[Embed(source="../../../sfx/teleport_down.mp3")] public static var S_TELEPORT_DOWN:Class;
/* Ambient */
//[Embed(source="../../../sfx/wavesandwind.mp3")] private var S_BEACH_WAVES:Class;
//[Embed(source="../../../sfx/rain.mp3")] private var embed_rain:Class;
/* Menu */
//[Embed(source="../../../sfx/menu_move.mp3")] public static var S_MENU_MOVE:Class;
//[Embed(source="../../../sfx/menu_select.mp3")] public static var S_MENU_SELECT:Class;
//[Embed(source="../../../sfx/pause_sound.mp3")] public static var S_PAUSE_SOUND:Class;
//[Embed(source="../../../sfx/dialogue_bloop.mp3")] public static var dialogue_bloop_embed:Class;
//[Embed(source="../../../sfx/dialogue_blip.mp3")] public static var dialogue_blip_embed:Class;
public var unlock:FlxSound=new FlxSound();
public var open:FlxSound=new FlxSound();
public var fall_in_hole:FlxSound=new FlxSound();
public var push_block:FlxSound=new FlxSound();
public var button_up:FlxSound=new FlxSound();
public var button_down:FlxSound=new FlxSound();
public var floor_crack:FlxSound=new FlxSound();
public var get_treasure:FlxSound=new FlxSound();
public var get_key:FlxSound=new FlxSound();
public var dash_pad_1:FlxSound=new FlxSound();
public var dash_pad_2:FlxSound=new FlxSound();
public var spring_bounce:FlxSound=new FlxSound();
public var waves:FlxSound=new FlxSound();
public var waves_samples:Int=1322496;//why is this here
public var rain:FlxSound=new FlxSound();
public var puddle_up:FlxSound=new FlxSound();
public var puddle_down:FlxSound=new FlxSound();
public var puddle_step:FlxGroup=new FlxGroup(2);
public var rain_samples:Int=236955;
public var ladder_step:FlxGroup=new FlxGroup(2);
public var sun_guy_death_l:FlxSound=new FlxSound();
public var sun_guy_death_s:FlxSound=new FlxSound();
public var sun_guy_scream:FlxSound=new FlxSound();
public var sun_guy_charge:FlxSound=new FlxSound();
public var player_jump_down:FlxSound=new FlxSound();
public var player_jump_up:FlxSound=new FlxSound();
public var enter_door:FlxSound=new FlxSound();
public var player_hit_1:FlxSound=new FlxSound();
public var broom_hit:FlxSound=new FlxSound();
public var teleport_up:FlxSound=new FlxSound();
public var teleport_down:FlxSound=new FlxSound();
public var shieldy_hit:FlxSound=new FlxSound();
public var shieldy_ineffective:FlxGroup=new FlxGroup(4);
//redcave
public var red_cave_rise:FlxSound=new FlxSound();
public var bubble_loop:FlxSound=new FlxSound();
public var redboss_moan:FlxSound=new FlxSound();
public var small_wave:FlxSound=new FlxSound();
public var big_wave:FlxSound=new FlxSound();
public var redboss_death:FlxSound=new FlxSound();
//crod
public var dog_dash:FlxGroup=new FlxGroup(3);
public var talk_group:FlxGroup=new FlxGroup(5);
public var wb_tap_ground:FlxSound=new FlxSound();
public var wb_hit_ground:FlxSound=new FlxSound();
public var wb_shoot:FlxSound=new FlxSound();
public var wb_moan:FlxSound=new FlxSound();
public var wb_moan_2:FlxSound=new FlxSound();
public var talk_death:FlxSound=new FlxSound();
//apt
public var teleguy_up:FlxSound=new FlxSound();
public var teleguy_down:FlxSound=new FlxSound();
public var gasguy_shoot:FlxSound=new FlxSound();
public var gasguy_move:FlxGroup=new FlxGroup(2);
public var rat_move:FlxGroup=new FlxGroup(2);
public var sb_split:FlxSound=new FlxSound();
public var sb_hurt:FlxSound=new FlxSound();
public var sb_dash:FlxSound=new FlxSound();
public var sb_ball_appear:FlxGroup=new FlxGroup(5);
public var sf_move:FlxGroup=new FlxGroup(3);
//hotel
public var dustmaid_alert:FlxSound=new FlxSound();
public var elevator_open:FlxSound=new FlxSound();
public var elevator_close:FlxSound=new FlxSound();
//circus
public var flame_pillar_group:FlxGroup=new FlxGroup(2);
public var fireball_group:FlxGroup=new FlxGroup(4);
public var get_small_health:FlxSound=new FlxSound();
public var big_door_locked:FlxSound=new FlxSound();
public var hitground1:FlxSound=new FlxSound();
public var fall1:FlxSound=new FlxSound();
public var slasher_atk:FlxSound=new FlxSound();
public var on_off_laser_shoot:FlxSound=new FlxSound();
public var dialogue_bloop:FlxSound=new FlxSound();
public var cicada_chirp:FlxSound=new FlxSound();
// Etc
public var briar_shine_group:FlxGroup=new FlxGroup(8);
public var stream_sound:FlxSound=new FlxSound();
public var dust_explode_group:FlxGroup=new FlxGroup(3);
public var mushroom_sound_group:FlxGroup=new FlxGroup(3);
/* Groups of sounds! */
public var slime_walk_group:FlxGroup=new FlxGroup(5);
public var slime_splash_group:FlxGroup=new FlxGroup(8);
public var slime_shoot_group:FlxGroup=new FlxGroup(2);
public var four_shooter_shoot_group:FlxGroup=new FlxGroup(2);
public var four_shooter_pop_group:FlxGroup=new FlxGroup(3);
public var mover_move_group:FlxGroup=new FlxGroup(2);
public var mover_die_group:FlxGroup=new FlxGroup(2);
public var bubble_group:FlxGroup=new FlxGroup(4);
public var bubble_triple_group:FlxGroup=new FlxGroup(4);
public var laser_pew_group:FlxGroup=new FlxGroup(2);
public var menu_move_group:FlxGroup=new FlxGroup(3);
public var menu_select_group:FlxGroup=new FlxGroup(2);
public var pause_sound_group:FlxGroup=new FlxGroup(2);
public var enemy_explode_1_group:FlxGroup=new FlxGroup(5);
public var swing_broom_group:FlxGroup=new FlxGroup(3);
public var water_step_group:FlxGroup=new FlxGroup(3);
public var dialogue_blip_group:FlxGroup=new FlxGroup(5);
public var sparkle_group:FlxGroup=new FlxGroup(5);
public var dog_bark_group:FlxGroup=new FlxGroup(2);
public var current_song_name:String="BEDROOM";
public var current_song:FlxSound=new FlxSound();
public function new(){
/* Init usually-one-off-noises. */
unlock.loadEmbedded(S_UNLOCK, false);
open.loadEmbedded(S_OPEN, false);
push_block.loadEmbedded(S_PUSH_BLOCK, false);
get_treasure.loadEmbedded(S_GET_TREASURE, false);
get_key.loadEmbedded(S_GET_KEY, false);
waves.loadEmbedded(S_BEACH_WAVES, true, waves_samples);
rain.loadEmbedded(embed_rain, true, rain_samples);
fall_in_hole.loadEmbedded(S_FALL_IN_HOLE, false);
button_down.loadEmbedded(S_BUTTON_DOWN);
button_up.loadEmbedded(S_BUTTON_UP);
floor_crack.loadEmbedded(S_FLOOR_CRACK);
big_door_locked.loadEmbedded(S_Big_Door_Locked);
hitground1.loadEmbedded(shitground1);
fall1.loadEmbedded(sfall1);
dash_pad_1.loadEmbedded(embed_dash_pad_1);
dash_pad_2.loadEmbedded(embed_dash_pad_2);
spring_bounce.loadEmbedded(embed_spring_bounce);
puddle_up.loadEmbedded(embed_puddle_up, false);
puddle_down.loadEmbedded(embed_puddle_down, false);
init_sound_group(puddle_step, embed_puddle_step);
init_multi_sound_group(ladder_step, new Array(embed_ladder_step_1, embed_ladder_step_2), false);
slasher_atk.loadEmbedded(slasher_atk_embed, false);
on_off_laser_shoot.loadEmbedded(on_off_laser_shoot_embed, false);
sun_guy_death_l.loadEmbedded(S_SUN_GUY_DEATH_L);
sun_guy_death_s.loadEmbedded(S_SUN_GUY_DEATH_S);
sun_guy_scream.loadEmbedded(S_SUN_GUY_SCREAM);
sun_guy_charge.loadEmbedded(S_SUN_GUY_CHARGE);
//redcave
red_cave_rise.loadEmbedded(embed_red_cave_rise);
bubble_loop.loadEmbedded(embed_bubble_loop, true, 89508);
redboss_moan.loadEmbedded(embed_redboss_moan);
big_wave.loadEmbedded(embed_big_wave, false);
small_wave.loadEmbedded(embed_small_wave, false);
redboss_death.loadEmbedded(embed_redboss_death);
//crowd
init_sound_group(dog_dash, embed_dog_dash);
init_multi_sound_group(talk_group, new Array(embed_talk_1, embed_talk_1, embed_talk_2, embed_talk_3, embed_talk_3));
wb_hit_ground.loadEmbedded(embed_wb_hit_ground);
wb_tap_ground.loadEmbedded(embed_wb_tap_ground);
wb_shoot.loadEmbedded(embed_wb_shoot);
wb_moan.loadEmbedded(embed_wb_moan);
wb_moan_2.loadEmbedded(embed_wb_moan_2);
talk_death.loadEmbedded(embed_talk_death);
//apt
teleguy_down.loadEmbedded(embed_teleguy_down);
teleguy_up.loadEmbedded(embed_teleguy_up);
gasguy_shoot.loadEmbedded(embed_gasguy_shoot);
init_sound_group(gasguy_move, embed_gasguy_move)
init_sound_group(rat_move, embed_rat_move);
sb_split.loadEmbedded(embed_sb_split);
init_sound_group(sb_ball_appear, embed_sb_ball_appear);
sb_dash.loadEmbedded(embed_sb_dash);
sb_hurt.loadEmbedded(embed_sb_hurt);
init_sound_group(sf_move, embed_sf_move);
//hotel
dustmaid_alert.loadEmbedded(embed_dustmaid_alert);
elevator_close.loadEmbedded(embed_elevator_close);
elevator_open.loadEmbedded(embed_elevator_open);
//circus
init_sound_group(flame_pillar_group, embed_flame_pillar);
init_sound_group(fireball_group, embed_fireball);
player_hit_1.loadEmbedded(S_PLAYER_HIT_1);
enter_door.loadEmbedded(embed_enter_door);
player_jump_down.loadEmbedded(player_jump_down_sound);
player_jump_up.loadEmbedded(player_jump_up_sound);
broom_hit.loadEmbedded(embed_broom_hit);
teleport_down.loadEmbedded(S_TELEPORT_DOWN);
teleport_up.loadEmbedded(S_TELEPORT_UP);
shieldy_hit.loadEmbedded(S_SHIELDY_HIT, false);
init_sound_group(shieldy_ineffective, shieldy_ineffective_embed);
get_small_health.loadEmbedded(S_GET_SMALL_HEALTH, false);
dialogue_bloop.loadEmbedded(dialogue_bloop_embed);
cicada_chirp.loadEmbedded(cicada_chirp_c);
GameOver.loadEmbedded(GameOver_Song);
stream_sound.loadEmbedded(embed_stream);
init_sound_group(dust_explode_group, embed_dust_explode);
/* Init repeated noises */
init_sound_group(laser_pew_group, S_LASER_PEW,false,0.1);
init_sound_group(slime_walk_group, slime_walk_embed);
init_sound_group(slime_shoot_group, slime_shoot_embed);
init_sound_group(slime_splash_group, slime_splash_embed);
init_sound_group(briar_shine_group, embed_briar_shine);
init_sound_group(four_shooter_pop_group, four_shooter_pop);
init_sound_group(four_shooter_shoot_group, four_shooter_shoot);
init_sound_group(mover_move_group, mover_move);
init_sound_group(mover_die_group, mover_die);
init_multi_sound_group(bubble_group, new Array(embed_bubble_1, embed_bubble_1, embed_bubble_2, embed_bubble_3));
init_sound_group(bubble_triple_group, embed_bubble_triple);
init_sound_group(dog_bark_group, embed_dog_bark);
init_multi_sound_group(mushroom_sound_group, new Array(embed_cross2, embed_cross3, embed_cross4), false, 1);
init_sound_group(menu_move_group, S_MENU_MOVE);
init_sound_group(menu_select_group, S_MENU_SELECT);
init_sound_group(dialogue_blip_group, dialogue_blip_embed);
init_sound_group(pause_sound_group, S_PAUSE_SOUND);
init_sound_group(enemy_explode_1_group, S_HIT_WALL, false, 0.3);
init_sound_group(water_step_group, water_step, false, 1);
init_multi_sound_group(swing_broom_group, new Array(swing_broom_1, swing_broom_2, swing_broom_3), false, 1);
init_multi_sound_group(sparkle_group, new Array(sparkle_1_c, sparkle_1_c, sparkle_2_c, sparkle_2_c,sparkle_3_c), false, 1);
}
public function init_sound_group(g:FlxGroup, embed_sound:Class, looped:Bool=false,volume:Float=1):Void {
for(i in 0...g.maxSize){
var s:FlxSound=new FlxSound();
s.loadEmbedded(embed_sound, looped);
s.volume=volume;
g.add(s);
}
}
public function init_multi_sound_group(g:FlxGroup, sounds:Array, looped:Bool=false, volume:Float=1):Void {
for(var sound:Class in sounds){
var s:FlxSound=new FlxSound;
s.loadEmbedded(sound, looped, volume);
g.add(s);
}
}
/**
* Given a sound object to reference what to play and
* the title of the song, play it.
*
* @param song
* @param title
*/
public var trigger_soft:Bool=false;
public function start_song_from_title(title:String):Void {
if(current_song==null)current_song=new FlxSound();
if(current_song.playing)current_song.stop();
if(!Registry.sound_data.hasOwnProperty(title)){
if(title=="TRAIN"){
title="CELL";//<_<
} else if(title=="DRAWER"){
// No music in post-death area
if(true==Registry.GAMESTATE.in_death_room){
return;
}
title="SUBURB";
} else {
title="BEDROOM";
}
}
if(Registry.E_PLAY_ROOF){
if(Registry.CURRENT_MAP_NAME=="REDCAVE" || Registry.CURRENT_MAP_NAME=="REDSEA"){
title="REDCAVE";
} else {
title="ROOF";
}
Registry.E_PLAY_ROOF=false;
}
if(title=="HAPPY"){
if(!Registry.GE_States[Registry.GE_Happy_Started]){
title="HAPPYINIT";
}
}
if(title=="TERMINAL"){
if(false==Registry.GE_States[Registry.GE_Sage_Dead_Idx]){
title="PRETERMINAL";
}
}
if(title=="SUBURB"){
if(trigger_soft){
trigger_soft=false;
title="SOFT";
}
}
if(title=="BOSS"){
switch(Registry.CURRENT_MAP_NAME){
case "BEDROOM":
title="BEDROOMBOSS";
break;
case "REDCAVE":
title="REDCAVEBOSS";
break;
case "CROWD":
title="CROWDBOSS";
break;
case "APARTMENT":
title="APARTMENTBOSS";
break;
case "HOTEL":
title="HOTELBOSS";
break;
case "CIRCUS":
title="CIRCUSBOSS";
break;
default:
title="BEDROOMBOSS";
break;
}
}
//title="TITLE";// remove
Registry.sound_data[title]=null;
Registry.sound_data[title]=new FlxSound();
//Registry.sound_data[title].loadEmbedded(Title_Song, true, Title_Samples);// remove
///*
if(title=="BEDROOM"){
Registry.sound_data.BEDROOM.loadEmbedded(Bedroom_Song, true, Bedroom_Samples);
} else if(title=="OVERWORLD"){
Registry.sound_data.OVERWORLD.loadEmbedded(Overworld_Song, true, Overworld_Samples);
} else if(title=="STREET"){
Registry.sound_data.STREET.loadEmbedded(Street_Song, true, Street_Samples);
} else if(title=="BLANK"){
Registry.sound_data.BLANK.loadEmbedded(Blank_Song, true, Blank_Samples);
} else if(title=="TITLE"){
Registry.sound_data.TITLE.loadEmbedded(Title_Song, true, Title_Samples);
}else if(title=="MITRA"){
Registry.sound_data.MITRA.loadEmbedded(Mitra_Song, true, MITRASAMPLES);
} else if(title=="FIELDS"){
Registry.sound_data.FIELDS.loadEmbedded(Fields_Song, true, FIELDSSAMPLES);
}else if(title=="NEXUS"){
Registry.sound_data.NEXUS.loadEmbedded(Nexus_Song, true, NEXUSSAMPLES);
} else if(title=="BEDROOMBOSS"){
Registry.sound_data.BEDROOMBOSS.loadEmbedded(BedroomBoss_Song, true, BEDROOMBOSSSAMPLES);
}
///*
else if(title==="BEACH"){
Registry.sound_data.BEACH.loadEmbedded(Beach_Song, true, Beach_Samples);
} else if(title=="REDSEA"){
Registry.sound_data.REDSEA.loadEmbedded(Red_Sea_Song, true, Red_Sea_Samples);
} else if(title=="REDCAVE"){
Registry.sound_data.REDCAVE.loadEmbedded(Red_Cave_Song, true, Red_Cave_Samples);
} else if(title=="REDCAVEBOSS"){
Registry.sound_data.REDCAVEBOSS.loadEmbedded(RedcaveBoss_Song, true, REDCAVEBOSSSAMPLES);
} else if(title=="WINDMILL"){
Registry.sound_data.WINDMILL.loadEmbedded(Windmill_Song, true, WINDMILLSAMPLES);
}else if(title=="APARTMENT"){
Registry.sound_data.APARTMENT.loadEmbedded(Apartment_Song, true, APARTMENTSAMPLES);
}else if(title=="FOREST"){
Registry.sound_data.FOREST.loadEmbedded(Forest_Song, true, FORESTSAMPLES);
} else if(title=="SPACE"){
Registry.sound_data.SPACE.loadEmbedded(Space_Song, true, SPACESAMPLES);
} else if(title=="CLIFF"){
Registry.sound_data.CLIFF.loadEmbedded(Cliff_Song, true, CLIFFSAMPLES);
} else if(title=="TERMINAL"){
Registry.sound_data.TERMINAL.loadEmbedded(Terminal_Song, true, TERMINALSAMPLES);
} else if(title=="CROWD"){
Registry.sound_data.CROWD.loadEmbedded(Crowd_Song, true, CROWDSAMPLES);
} else if(title=="CELL"){
Registry.sound_data.CELL.loadEmbedded(Cell_Song, true, CELLSAMPLES);
} else if(title=="SUBURB"){
Registry.sound_data.SUBURB.loadEmbedded(Suburb_Song, true, SUBURBSAMPLES);
} else if(title=="ROOF"){
Registry.sound_data.ROOF.loadEmbedded(Roof_Song, true, ROOFSAMPLES);
} else if(title=="CIRCUS"){
Registry.sound_data.CIRCUS.loadEmbedded(Circus_Song, true, CIRCUSSAMPLES,2009500);
} else if(title=="HOTEL"){
Registry.sound_data.HOTEL.loadEmbedded(Hotel_Song, true, HOTELSAMPLES);
} else if(title=="GO"){
Registry.sound_data.GO.loadEmbedded(Go_Song, true, GOSAMPLES);
} else if(title=="HAPPY"){
Registry.sound_data.HAPPY.loadEmbedded(Happy_Song, true, HAPPYSAMPLES);
} else if(title=="BLUE"){
Registry.sound_data.BLUE.loadEmbedded(Blue_Song, true, BLUESAMPLES);
} else if(title=="SAGEFIGHT"){
Registry.sound_data.SAGEFIGHT.loadEmbedded(Sagefight_Song, true, SAGEFIGHTSAMPLES,SAGEFIGHTLOOP);
} else if(title=="HAPPYINIT"){
Registry.sound_data.HAPPYINIT.loadEmbedded(Happyinit_song, true, HAPPYINITSAMPLES);
} else if(title=="ENDING"){
Registry.sound_data.ENDING.loadEmbedded(Ending_Song,false, ENDINGSAMPLES);
} else if(title=="BRIARFIGHT"){
Registry.sound_data.BRIARFIGHT.loadEmbedded(BriarFight_Song, true, BRIARFIGHTSAMPLES);
} else if(title=="PRETERMINAL"){
Registry.sound_data.PRETERMINAL.loadEmbedded(PreTerminal_Song, true, PRETERMSAMPLES);
} else if(title=="DRAWER"){
Registry.sound_data.SUBURB.loadEmbedded(Suburb_Song, true, SUBURBSAMPLES);
} else if(title=="SOFT"){
Registry.sound_data.SOFT.loadEmbedded(Soft_Song, true, SOFTSAMPLES);
} else if(title=="CIRCUSBOSS"){
Registry.sound_data.CIRCUSBOSS.loadEmbedded(CircusBoss_Song, true, CIRCUSBOSSSAMPLES);
} else if(title=="HOTELBOSS"){
Registry.sound_data.HOTELBOSS.loadEmbedded(HotelBoss_Song, true, HOTELBOSSSAMPLES);
} else if(title=="APARTMENTBOSS"){
Registry.sound_data.APARTMENTBOSS.loadEmbedded(ApartmentBoss_Song, true, APARTMENTBOSSSAMPLES);
} else if(title=="CROWDBOSS"){
Registry.sound_data.CROWDBOSS.loadEmbedded(CrowdBoss_Song, true, CROWDBOSSSAMPLES);
}
//*/
current_song=Registry.sound_data[title];
current_song_name=title;
if(Registry.GAMESTATE !=null){
Registry.GAMESTATE.last_song_time=0;// avoid issues with changing song midmap
}
//current_song.volume=FlxG.volume;
current_song.play();
if(title=="WINDMILL" && Registry.CUTSCENES_PLAYED[Cutscene.Windmill_Opening]==0){
current_song.stop();
}
}
/**
*
* @param g Group of the(loaded)flxsoudns ya wanna play
* @return 1 if a sound was played, 0 otherwise(too many playing);
*/
public function play_sound_group(g:FlxGroup,vol:Float=1):Int {
for(var s:FlxSound in g.members){
if(!s.playing){
s.volume=vol;
s.play();
return 1;
}
}
return 0;
}
public function play_sound_group_randomly(g:FlxGroup):Int {
var a:Array<Dynamic>=new Array<Dynamic>;
for(i in 0...g.length){
a.push(i);
}
for(i=0;i<g.length;i++){
var r:Int=(g.length - i)* Math.random();// Get a random index Into the the array of sound gruop indices to check
var v:Int=a[r];// Store the sound group index to check
a.splice(r, 1);// Remove the sound group index so we dont check again
if(!g.members[v].playing){
g.members[v].play();
return 1;
break;
}
}
return 0;
}
/*
* Stops the input song and resets it.
* */
public function stop_current_song():Void {
if(current_song !=null && current_song.playing){
current_song.stop();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
package entity.decoration
{
import data.CLASS_ID;
import org.flixel.FlxSprite;
/**
* ...
* @author seaga
*/
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 new(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");
}
}

View File

@ -0,0 +1,201 @@
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
*/
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:Bool=false;
private var lock_latency:Float=2.0;
private var lock_latency_max:Float=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:Float=3.0;
public var base_y_scale:Float=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 new(_x:Int, _y:Int, _darkness:FlxSprite, type:Int, follows:Bool=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=Std.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);
}
}
}

View File

@ -0,0 +1,39 @@
package entity.decoration
{
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.geom.Point;
import org.flixel.FlxSprite;
/**
* test
* @author Seagaia
*/
class Map_Preview extends FlxSprite
{
var erase_mask:FlxSprite=new FlxSprite();
public function new()
{
makeGraphic(16, 16, 0xffff0000);
erase_mask.makeGraphic(16, 16, 0x00000000);
for(i in 0...256){
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();
}
}

View File

@ -0,0 +1,48 @@
package entity.decoration
{
import org.flixel.FlxSprite;
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 new(_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;
}
}
}

View File

@ -0,0 +1,130 @@
/**
* 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
*/
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:Float=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 new(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:Float, max:Float):Float {
var randomNum:Float=(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:Float, min:Float, max:Float, periodo:Float):Float {
var escursione:Float=max - min;
var coefficiente:Float=Math.PI * 2 / periodo;
return escursione / 2 *(1 + Math.sin(x * coefficiente))+ min;
}
}

View File

@ -0,0 +1,179 @@
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
*/
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 new(_xml:XML,is_cutscene:Bool=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();
}
}

View File

@ -0,0 +1,199 @@
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
*/
class Water_Anim extends AnoSprite
{
private var started:Bool=false;
private var target_tiles:Array<Dynamic>;// List of tiles [0,99] that will be transformed in order
private var target_tile_types:Array<Dynamic>;// What each tile will change to.
private var latency:Float=0.3;//Time between tile transforms
private var t:Float=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:Bool=false;
public function new(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(i in 0...target_tiles.length){
TileData.make_anim_tile(anim_tiles, map_name, target_tile_types[i], tl.x + 16 *(target_tiles[i] % 10), tl.y + 16 * Std.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():Bool {
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:Bool=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;
}
}

View File

@ -0,0 +1,286 @@
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
*/
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:Dynamic;
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:Bool=false;
public function new(_x:XML, _p:Player, _pa:Dynamic)
{
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(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(var dust:Dust in Registry.subgroup_dust){
if(dust==null)continue;
if(dust.overlaps(this)){
play_sfx("hit");
state=s_retracting;
}
}
for(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():Bool
{
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;
}
}

View File

@ -0,0 +1,202 @@
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;
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:Dynamic;
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:Float=4;
private var tm:Float=5.0;
private var initial_latency:Float=1.5;
private var tm_shoot_latency:Float=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:Float;
private var t_move_sound:Float=0;
private var just_hit:Bool=false;
public var cid:Int=CLASS_ID.GASGUY;
public function new(_x:XML, _p:Player, _pa:Dynamic)
{
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(i in 0...gas_group.maxSize){
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(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(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();
}
}

View File

@ -0,0 +1,213 @@
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
*/
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:Dynamic;
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:Bool=false;
private var hurt_box:FlxSprite=new FlxSprite;
public function new(_xml:XML,_player:Player,_parent:Dynamic)
{
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:Dynamic):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(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(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(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();
}
}

View File

@ -0,0 +1,282 @@
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
*/
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:Dynamic;
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:Float=0;
private var tm_turn:Float=0.8;
private var vel:Int=50;
private var death_timer:Float=0.7;
private var seen_distance:Float=30;//
private var init_latency:Float=1.0;
public var cid:Int=CLASS_ID.SILVERFISH;
public function new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(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(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(var sp:Switch_Pillar in Registry.subgroup_switch_pillars){
if(sp==null)continue;
if(sp.frame==sp.up_frame && sp.overlaps(this)){
var yes:Bool=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):Bool {
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;
}
}

View File

@ -0,0 +1,653 @@
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;
class Splitboss extends FlxSprite
{
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
private var added_to_parent:Bool=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:Bool=false;
private var t_damaged:Float=0;
private var tm_damaged:Float=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<Dynamic>=new Array(2, 1, 4);
private var h_dethballz_shots:Array<Dynamic>=new Array(4, 10, 7);
private var h_dethballz_timeouts:Array<Dynamic>=new Array(0.7, 0.2, 0.8);
private var t_dethballz:Float=0;
private var dethball_queue:Array<Dynamic>=new Array();
private var s_h_dash:Int=2;
private var Y_OFF_R_DASH:Int=6;
private var h_dash_vel:Array<Dynamic>=new Array(80, 100, 120);
private var h_dash_ball_vel:Array<Dynamic>=new Array(80, 100, 120);
private var h_dashes_done:Int=0;
private var nr_dashes:Array<Dynamic>=new Array(2, 3, 4);
private var h_dash_ball_pos:Array<Dynamic>=new Array(1, 4);
private var t_h_dash:Float=0;
private var tm_h_dash:Float=0.5;
private var nr_dropped:Int=0;
private var nr_to_drop:Array<Dynamic>=new Array(2, 3, 4);
private var next_drop:Float=0;
private var s_split:Int=3;
private var t_split:Float=0;
private var split_vels:Array<Dynamic>=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(i in 0...DETHBALLZ.maxSize){
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:Float=5;
t_split -=FlxG.elapsed;
x=tl.x + 40;
y=tl.y + 40;
var r:Float=-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(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(DETHBALL in DETHBALLZ.members){
if(DETHBALL.exists){
DETHBALL.play("shoot");
}
}
} else {
ctr=0;
}
}
}
for(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(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(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(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:Float=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=Std.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:Float=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(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:Float=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();
}
}

View File

@ -0,0 +1,211 @@
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
*/
class Teleguy extends FlxSprite
{
public var xml:XML;
private var player:Player;
private var parent:Dynamic;
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:Float=0;
private var s_attacking:Int=2;
private var atk_pt:Point=new Point;
private var attack_speed:Float=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 new(_x:XML, _p:Player, _pa:Dynamic)
{
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;
}
}
}

View File

@ -0,0 +1,324 @@
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
*/
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:Float=0.25;
private var WAIT_TIMER_MAX:Float=0.25;
private var APPROACH_DISTANCE:Int=64;
private var CIRCLE_DISTANCE:Int=24;
private var wait_timer:Float=0.25;
private var CIRCLE_TIMER_MAX:Float=3.00;
private var circle_timer:Float=3.00;
private var swoop_to_point:Point=new Point(0, 0);
private var rotate_radius:Float=20;
private var rotate_velocity:Float=0.14;
private var just_hit_timer:Float=0.4;
private var just_hit:Bool=false;
public var cid:Int=CLASS_ID.ANNOYER;
public var INCREMENTED_REG:Bool=false;
public var parent:Dynamic;
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:Float=0;
private var tm_fireball:Float=2.3;
private var vel_fireball:Int=30;
public function new(x:Int,y:Int,_xml:XML,_player:Player,_parent:Dynamic)
{
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(i in 0...fireballs.maxSize){
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:Float;
var dy:Float;
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(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:Bool=EventScripts.send_property_to(this, "x", swoop_to_point.x, 2.5);
var res2:Bool=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:Dynamic,radius:Float,velocity:Float):Void {
var pivot_x:Float=pivot.x + pivot.width / 2;
var pivot_y:Float=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:Int):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;
}
}

View File

@ -0,0 +1,188 @@
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
*/
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:Float=0.5;
public var cur_velocity:Float=0;
public static var BULLET_VELOCITY:Float=40;
public static var BULLET_FAST_VELOCITY:Float=70;
public var bullet_timer:Float=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:Bool=false;
private var latency_ticks:Int=3;
public var cid:Int=CLASS_ID.PEW_LASER;
public function new(X:Float, Y:Float, _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(i in 0...5){
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(j in 0...bullets.members.length){
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(i in 0...bullets.length){
// 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(k in 0...Registry.subgroup_dust.length){
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(ka in 0...parent.statefuls.length){
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();
}
}

View File

@ -0,0 +1,216 @@
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 */
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:Bool=false;
public var hit_timer_max:Float=0.4;
public var hit_timer:Float=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:Bool=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 new(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():Bool {
for(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:Int):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=Std.int(x);
var old_y:Int=Std.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), Std.int((int(y)- 20)/ 16));
if(parent.curMapBuf._tileObjects[tile_type].allowCollisions==FlxObject.ANY){
x=old_x;
y=old_y;
}
}
return -1;
}
}

View File

@ -0,0 +1,355 @@
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;
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 inline var 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:Bool=false;
public var hitTimer:Float=0;
public var deathTimer:Float=0;
public var HIT_TIMEOUT:Float=0.3;
public var xml:XML;
private var state:Int=0;
private var s_dead:Int=1;
private var dropped_health:Bool=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:Bool=false;
public var has_key:Bool=false;
public var cid:Int=CLASS_ID.SLIME;
public var INCREMENTED_REGISTRY:Bool=false;
public var change_vel_timer:Float=0.5;
public var change_vel_timer_max:Float=0.5;
private var VEL:Int=20;
private var BULLET_VEL:Int=40;
public var t_shoot:Float=0;
public var tm_shoot:Float=1.8;
public var goo_collide_ticks:Int=4;
public var player:Player;
public var parent:Dynamic;
public var goo_group:FlxGroup=new FlxGroup(7);
public var goo_bullets:FlxGroup=new FlxGroup(4);
public var move_frame_sound_sync:Bool=false;
public function new(x:Int, y:Int, _local_id:Int, frame_type:Int, _xml:XML, _p:Player,_parent:Dynamic){
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(i in 0...goo_group.maxSize){
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 + Std.int(5 * Math.random()));
} else {
goo.addAnimation("move", [0,1,2,3,1,3,1,2,1,0],5 + Std.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 + Std.int(5 * Math.random()));
} else {
goo.loadGraphic(embed_slime_bullet, true, false, 8,8);
goo.addAnimation("move", [0, 1], 5 + Std.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(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(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(i in 0...2){
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;
}
}

View File

@ -0,0 +1,635 @@
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;
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 */
private var times_hurt_player:Int=0;
private var S_INTRO_1:Int=0;
private var S_INTRO_2:Int=6;
private var S_INTRO_0:Int=7;
private var S_HORIZONTAL_FLOAT:Int=1;
private var HF_1:Bool=false;
private var VF_1:Bool=false;
private var S_CHARGE:Int=2;
private var S_CHARGE_CTR:Int=0;
private var S_FIRE_LASER:Int=3;
private var S_DYING:Int=4;
private var S_DYING_CTR:Int=0;
private var S_DEAD:Int=5;
private var S_VERTIFLOAT:Int=8;
private var S_VERTIFLOAT_CTR:Int=0;
private var STATE:Int;
private var INCREMENTED_REGISTRY:Bool=false;
public var just_got_hurt:Bool=false;
public var hit_timer:Float=1;
public var HIT_TIMER_MAX:Float=1.5;
/* other stuff */
public var dusts:FlxGroup=new FlxGroup(3);
private var dusts_poofed:Bool=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:Bool=false;
/* Radii of circulation, rotation velocity(degrees/tick), angle about boss */
public var lr_1:Float=16;
public var lr_2:Float=32;
public var rv_1:Float=0.05;
public var rv_2:Float=0.04;
private var a_1:Float=0;
private var a_2:Float=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:Float=0;//For y-oscillations
private var stopped_song:Bool=false;
private var started_song:Bool=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 new(_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(i in 0...3){
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(i in 0...3){
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:Bool;
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:Bool;
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

View File

@ -0,0 +1,295 @@
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
*/
class Contort extends FlxSprite
{
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
//[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:Float=0;
private var tm_big_hit:Float=1.5;
private var just_hurt:Bool=false;
private var big_death_timeout:Float=1.0;
private var t_small_roll:Float=0;
private var tm_small_roll:Float=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:Bool=false;
private var big_is_v_flipped:Bool=false;
private var VEL:Int=35;
public var small_sprites:FlxGroup=new FlxGroup(3);
private var added_to_parent:Bool=false;
private var collide_ctr:Int=0;
private var tl:Point=new Point(0, 0);
private var did_normal:Bool=false;
public function new(_xml:XML, _player:Player, _parent:Dynamic)
{
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(i in 0...small_sprites.maxSize){
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(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(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();
}
}

View File

@ -0,0 +1,125 @@
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;
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:Dynamic;
private var added_to_parent:Bool=false;
public var hitbox:FlxSprite=new FlxSprite;
public var base:FlxSprite=new FlxSprite;
private var t:Float=0;
private var tm_idle:Float=0.74;
private var tm_emerge:Float=0.3;
private var tm_flame:Float=1.0;
private var tm_recede:Float=0.3;
private var ctr:Int=0;
public function new(_xml:XML, _player:Player, _parent:Dynamic){
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(var dust:Dust in Registry.subgroup_dust){
if(dust==null)continue;
if(dust.visible && dust.overlaps(hitbox)){
ctr=0;
play("idle");
}
}
for(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();
}
}

View File

@ -0,0 +1,541 @@
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;
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:Dynamic;
private var max_health:Int=4;
private var is_hurt:Bool=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:Float=0;
private var tm_pace:Float=0.8;
private var vel_pace:Float=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:Float=0;
private var tm_shoot:Float=0.165;
private var tm_shoot_warning:Float=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:Float=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:Bool=false;
public function new(_xml:XML, _player:Player, _parent:Dynamic)
{
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(i in 0...fireballs.maxSize){
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:Int, frame_index:Int):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=Std.int(6 * Math.random());
var r:Float=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(fireball in fireballs.members){
if(fireball._curAnim !=null && fireball._curAnim.name !="poof"){
for(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:Float=midpoint.y - player.midpoint.y;
var dx:Float=midpoint.x - player.midpoint.x;
var eps:Float=0.0001;
(Math.abs(dx)<eps)?(dx<0 ? dx=-0.1:dx=0.1):1;
var m:Float=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();
}
}

View File

@ -0,0 +1,275 @@
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;
class Dog extends FlxSprite
{
public var xml:XML;
public var cid:Int=CLASS_ID.DOG;
public var player:Player;
public var parent:Dynamic;
//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:Float=0;
private var state:Int=0;
private var s_pace:Int=0;
private var pace_vel:Int=20;
private var pace_timer_max:Float=1.0;
private var s_alert:Int=1;
private var alert_timer_max:Float=1.0;
private var s_attack:Int=2;
private var attack_pts:Array<Dynamic>=new Array(new Point(), new Point(), new Point(), new Point(), new Point());
private var vel_base_attack:Float=60;
private var attack_speeds:Array<Dynamic>=new Array(1.1, 1.4, 1.4, 1.6, 1.7);
private var attack_timer_max:Float=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:Float=1.5;
private var hit_timer:Float=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(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(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:Int,frame_idx:Int):Void {
if(name=="walk_l" || name=="stop_l"){
scale.x=-1;
} else if(name=="attack_l"){
scale.x=-1;
} else {
scale.x=1;
}
}
}

View File

@ -0,0 +1,309 @@
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;
class Frog extends FlxSprite
{
public var xml:XML;
public var cid:Int=CLASS_ID.FROG;
public var player:Player;
public var parent:Dynamic;
//[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:Bool=false
private var did_shoot_anim:Bool=false
private var added_to_parent:Bool=false;
public var y_bullets:FlxGroup=new FlxGroup();
public var BULLET_EMPTY_FRAME:Int=3;
private var dame_frame:Int;
private var hit_timer:Float=0;
private var hit_timer_max:Float=1.0;
private var init_latency:Float=0.8;
//dame - p(1), alive , frame(attk type)
public function new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(i in 0...3){
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(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(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(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(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(var b:FlxSprite in y_bullets.members){
parent.fg_sprites.remove(b, true);
}
super.destroy();
}
}

View File

@ -0,0 +1,173 @@
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;
class Person extends FlxSprite
{
public var xml:XML;
public var cid:Int=CLASS_ID.PERSON;
public var player:Player;
public var parent:Dynamic;
public var switch_dir_timer_max:Float=1.3;
public var switch_dir_timer:Float=0.6;
public var initial_vel_timeout:Float=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:Float;
//[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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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;
}
}
}

View File

@ -0,0 +1,79 @@
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
*/
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:Float=0.02;
public var r:Float=0;
private var t_timeout:Float=1.4;
/**
* dame props:
* frame:both the sprite to use as well as the rotational radius/speed... see types
*
*/
public function new(_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();
}
}

View File

@ -0,0 +1,284 @@
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
*/
class Spike_Roller extends FlxSprite
{
public var xml:XML;
public var cid:Int=CLASS_ID.SPIKE_ROLLER;
public var player:Player;
public var parent:Dynamic;
public var added_extras:Bool=false;
private var transitioned_in:Bool=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:Float=1.0;
private var init_pt:Point=new Point();
private var is_bounce:Bool=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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:Bool=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();
}
}

View File

@ -0,0 +1,896 @@
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
*/
class WallBoss extends FlxSprite
{
/* Generic properties */
public var tl:Point=new Point();
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
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:Float=0.04;
private var fade_out_alpha_rate:Float=0.003;
private var broke_ground:Bool=false;
private var talk_timer:Float=0;
/* wall properties */
public var wall:FlxSprite;
private var death_explosions:FlxGroup=new FlxGroup(4);
private var death_explosion_timer:Float=0.25;
private var tm_de:Float=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:Float=0;
public var hurt_tm:Float=1.0;
public var charge_t:Float=0;
public var charge_tm:Float=3.0;
public var finish_charge_tm:Float=1.0;
public var face_bullets:FlxGroup=new FlxGroup(8);
public var nr_bullets:Array<Dynamic>=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:Float=0;
private var tm_float:Float=2.0;
private var s_hand_push:Int=2;
private var max_nr_pushes:Array<Dynamic>=new Array(2,3, 3);
private var nr_pushes:Int=0;
private var push_y_vel:Array<Dynamic>=new Array(60, 90, 120);
private var p_double_push:Array<Dynamic>=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<Dynamic>=new Array(2, 3, 4);
private var nr_falls:Int=0;//counter
private var period_lhand_stomp:Float=2.0;
private var ctr_hand_stomp:Int=0;//sub-state ctr
private var rhand_stomp_vel:Float=30;
private var t_lhand_stomp:Float=0;
private var tm_lhand_stomp:Float=0.7
private var played_sound:Bool=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:Float=0;
private var tm_dying:Float=3;
private var s_hand_dead:Int=6;
private var do_intro:Bool=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 new(_x:XML,_p:Player,_s:Dynamic)
{
/* 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(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 + Std.int(8 * Math.random()), 1 + 0.5 * Math.random(), "offset", "y");
s.parabola_thing.set_shadow_fall_animation("get_big");
s.velocity.x=-30 + Std.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(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(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:Float=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<Dynamic>=new Array(62, 63, 64, 65, 66, 67);
var cracked_index:Int=71;
var is_broken:Bool=false;
for(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

View File

@ -0,0 +1,193 @@
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;
class Chaser extends FlxSprite
{
private var xml:XML;
private var player:Player;
private var parent:Dynamic;
private var state:Int;
private static inline var s_idle:Int=0;
private static inline var 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 new(_xml:XML, _player:Player, _parent:Dynamic)
{
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();
}
}

View File

@ -0,0 +1,211 @@
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
*/
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 new(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(i in 0...index){
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();
}
}

View File

@ -0,0 +1,84 @@
package entity.enemy.etc
{
import data.CLASS_ID;
import entity.player.Player;
import org.flixel.FlxG;
import org.flixel.FlxSprite;
/**
* ...
* @author Seagaia
*/
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 new(_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();
}
}

View File

@ -0,0 +1,63 @@
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
*/
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 new(_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=Std.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();
}
}

View File

@ -0,0 +1,74 @@
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
*/
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 new(_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();
}
}

View File

@ -0,0 +1,879 @@
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;
class Sage_Boss extends AnoSprite
{
private static inline var S_RESET:Int=-1;// going betwen substates of ACTIVE state
private static inline var S_WAITING:Int=0;// Intro
private static inline var S_ACTIVE:Int=1;// fighting
private static inline var S_DYING:Int=2;
private static inline var S_DEAD:Int=3;
private var active_substate:Int=0;
private var substate_ctr:Int=0;
private var gt:Float=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:Bool=false;
private var do_s2_debug:Bool=false;
private var do_s3_debug:Bool=false;
private var do_s4_debug:Bool=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 new(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(i in 0...s_bullets.maxSize){
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 static inline var s1_vel:Int=50;
private var t_s1:Float=0;
private var tm_s1:Array<Dynamic>=new Array(1.6, 1.4, 1.2);
private static inline var 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(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(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 static inline var s2_max_health:Int=3;
private var s2_health:Int=3;
private var s2_dash_vel:Array<Dynamic>=new Array(50, 70, 90);
private var s2_d1:FlxSprite;
private var s2_d2:FlxSprite;
private var s2_set_vel:Bool=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(i in 0...2){
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:Float=0;
private var s3_dust_osc_t:Float=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:Bool=false;
private var s3_max_health:Int=4;
private var s3_dash_vel:Array<Dynamic>=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:Float;
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=Std.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:Float=0;
private var s4_tm:Float=0.55;
private var s4_health:Int=3;
private var s4_health_max:Int=3;
private var s4_vel:Array<Dynamic>=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(d in s_bullets.members){
var undo:Bool=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:Float=0;
private function dust_routine(latency:Float):Void {
/* t_dust +=FlxG.elapsed;
if(t_dust>latency){
t_dust=0;
var d:Dust;
for(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(s in s_bullets.members){
if(s !=null && s.exists && s.visible){
if(s.overlaps(player)){
player.touchDamage(1);
}
}
}
for(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(d in s_bullets.members){
if(d !=null){
d.play("poof");
d.alive=false;
}
}
}
private function poof_big():Void
{
var d:FlxSprite;
for(d in l_bullets.members){
if(d !=null){
d.play("poof");
d.alive=false;
}
}
}
}

View File

@ -0,0 +1,66 @@
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;
class Space_Face extends AnoSprite
{
public var t_dash:Float=0;
public var tm_dash:Float;
public var t_calc_angle:Float=0;
public var tm_calc_angle:Float=0.2;
public function new(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();
}
}

View File

@ -0,0 +1,87 @@
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;
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:Bool=false;
public var charge_timer:Float=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 new(_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;
}
}
}
}

View File

@ -0,0 +1,212 @@
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;
class Burst_Plant extends FlxSprite
{
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
public var bullets:FlxGroup=new FlxGroup(8);
private var added_to_parent:Bool=false;
private var t_timeout:Float=0;
private var tm_timeout:Float=1;
private var t_hurt:Float=0;
private var tm_hurt:Float=1.0;
private var state:Int=0;
private var s_idle:Int=0;
private var s_charge:Int=1;
private var t_charge:Float=0;
private var tm_charge:Float=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:Float=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(i in 0...bullets.maxSize){
/* 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 + Std.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(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(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(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(bullet in bullets.members){
bullet.my_shadow.exists=false;
}
exists=false;
}
super.update();
}
}

View File

@ -0,0 +1,161 @@
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
*/
class Dustmaid extends FlxSprite
{
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
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:Float=0;
private var tm_hit:Float=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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();
}
}

View File

@ -0,0 +1,751 @@
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;
class Eye_Boss extends FlxSprite
{
public var xml:XML;
private var parent:Dynamic;
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:Bool=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:Float=0;
private var tm_pace:Float=1;
private var t_shoot:Float=0;
private var tm_shoot:Array<Dynamic>=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:Float=0;
private var tm_blink:Array<Dynamic>=new Array(1.1, 0.95, 0.9, 0.8, 0.7, 0.65);
private var move_vel:Float=100;
private var t_move:Float=0;
private var tm_move:Float=0.8;
public function new(_xml:XML, _player:Player, _parent:Dynamic)
{
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(i in 0...grp_water_bullets.maxSize){
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:Bool=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(var b:FlxSprite in grp_water_bullets.members){
parent.bg_sprites.add(b.my_shadow);
}
parent.fg_sprites.add(grp_land_splashes);
for(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:Float=Math.random();
if(r<0.7){
rel_coords.x=Std.int(3 * Math.random());
rel_coords.y=Std.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(j in 0...3){
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(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(i in 0...4 ++){
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(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(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(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();
}
}

View File

@ -0,0 +1,207 @@
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;
class Steam_Pipe extends FlxSprite
{
public var xml:XML;
public var player:Player;
public var parent:Dynamic;
private var dame_frame:Int;
private var added_to_parent:Bool=false;
private var eject_pt:Point;
private var eject_vel:Int=50;
public var steam_clouds:FlxGroup=new FlxGroup(6);
public var timers:Array<Dynamic>;
private var PUSH_VEL:Int=50;
private var active_region:FlxSprite=new FlxSprite();
private var disabled:Bool=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 new(_xml:XML,_player:Player,_parent:Dynamic)
{
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(i in 0...steam_clouds.maxSize){
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 + Std.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(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(var gas:FlxSprite in Registry.subgroup_gas){
if(gas !=null){
for(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(var steam:FlxSprite in steam_clouds.members){
timers[ctr]--;
if(timers[ctr]==0){
if(!disabled){
timers[ctr]=30 + Std.int(20 * Math.random());
} else {
timers[ctr]=3 + Std.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;
}
}
}

Some files were not shown because too many files have changed in this diff Show More