Section 1
//GuiCutScene (com.bamtang.game.gui.GuiCutScene)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiCutScene extends Screen {
private var mCutSceneNumber:int;
private var mPlaying:Boolean;
private var mEnableButton:Boolean;
private var mInterval:Interval;
public function GuiCutScene(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null, cutSceneNum:int=1){
super(nameClip, x, y, appInstance);
mCutSceneNumber = cutSceneNum;
mClip.setData = setData;
mPlaying = false;
mEnableButton = false;
Application.instance.layer.clip.stage.focus = null;
Global.stage.quality = "high";
Global.app.stopAllSound();
if (mCutSceneNumber != 4){
Global.app.playSound("mus_AT_titlecard");
} else {
Global.app.playSound("mus_AT_ending");
};
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnNext"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
public function setData():void{
mClip["btnNext"].addEventListener(MouseEvent.CLICK, onClick);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + ((DemoGame.level == 0)) ? 1 : DemoGame.level)].popUpWaitingTime);
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnNext":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnNext"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
mClip.stop();
Global.app.stopSound("mus_AT_titlecard");
if (mCutSceneNumber == 1){
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:1});
} else {
if (mCutSceneNumber == 2){
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:2});
} else {
if (mCutSceneNumber == 3){
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:3});
};
};
};
if (mCutSceneNumber == 4){
Global.app.stopSound("mus_AT_ending");
DemoGame.gameScore = 0;
Global.guiManager.gotoScreen(GuiManager.SC_MAIN_MENU);
};
};
};
}
}
}//package com.bamtang.game.gui
Section 2
//GuiGame (com.bamtang.game.gui.GuiGame)
package com.bamtang.game.gui {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
public class GuiGame extends Screen {
private var mClipEffects:MovieClip;
private var mClipGame:MovieClip;
private var mEffectManager:EffectManager;
private var mActiveShift:Boolean;
private var mClipHud:MovieClip;
private var mGame:Game;
public static var instance:GuiGame;
public function GuiGame(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null, params:Object=null){
super(nameClip, x, y, appInstance);
mActiveShift = false;
mClipGame = mLayer.addEmptyChild();
mClipEffects = mLayer.addEmptyChild();
mClipHud = mLayer.addEmptyChild();
params.worldXML = ("GAT_world_0" + params.level);
params.guiGame = this;
mGame = new DemoGame(mClipGame, mClipHud, params);
Global.game = mGame;
mEffectManager = new EffectManager(mClipEffects);
instance = this;
}
override public function onActivate(activate:Boolean):void{
if (mGame){
mGame.onActivate(activate);
};
}
public function get clipGame():MovieClip{
return (mClipGame);
}
private function createPopupCheat():void{
if (!DemoPlayer(DemoPlayer.instance.world.player).disable){
addPopup(GuiPopupCheat, "mcPopupCheat");
};
}
override public function update(dt:int):void{
super.update(dt);
if (mGame){
mGame.update(dt);
};
}
override public function free():void{
Global.game = null;
instance = null;
if (mGame){
mGame.free();
};
if (mEffectManager){
mEffectManager.free();
};
mGame = null;
mEffectManager = null;
super.free();
}
public function get clipHud():MovieClip{
return (mClipHud);
}
override public function onKeyDown(keyCode:int):void{
super.onKeyDown(keyCode);
if (mGame){
mGame.onKeyDown(keyCode);
};
if (keyCode == Global.KEY_SHIFT){
mActiveShift = true;
};
if (((mActiveShift) && ((keyCode == Global.KEY_D)))){
if (Global.settings[("GAT_Config0" + DemoGame.level)].cheatPanelActivated){
createPopupCheat();
};
};
}
public function get clipEffects():MovieClip{
return (mClipEffects);
}
public function get game():Game{
return (mGame);
}
override public function onKeyUp(keyCode:int):void{
super.onKeyUp(keyCode);
if (mGame){
mGame.onKeyUp(keyCode);
};
if (keyCode == Global.KEY_SHIFT){
mActiveShift = false;
};
}
public function get effectManager():EffectManager{
return (mEffectManager);
}
public function removeGame(levelEnd:int, win:Boolean=true):void{
if (mGame){
mGame.free();
};
mGame = null;
if (win){
switch (levelEnd){
case 1:
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_2);
break;
case 2:
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_3);
break;
case 3:
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:4});
break;
case 4:
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_4);
break;
};
} else {
DemoGame.lifes = 3;
switch (levelEnd){
case 1:
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:1});
break;
case 2:
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:2});
break;
case 3:
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:3});
break;
case 4:
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:4});
break;
};
};
}
}
}//package com.bamtang.game.gui
Section 3
//GuiHud (com.bamtang.game.gui.GuiHud)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
public class GuiHud extends Screen {
public var isMute:Boolean;
private var mPlayEffect:Boolean;
public static var instance:GuiHud;
public function GuiHud(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
instance = this;
isMute = false;
mClip["btnSound"].gotoAndStop("on");
mClip["btnSound"].addEventListener(MouseEvent.CLICK, onMouseHandler, false, 0, true);
mClip["btnHelp"].addEventListener(MouseEvent.CLICK, onMouseHandler, false, 0, true);
setItemCollectible(0);
mClip["mcKey01"].visible = false;
mClip["mcKey02"].visible = false;
mClip["mcBossBar"].visible = false;
mClip["mcFxItem"].gotoAndStop(10);
mPlayEffect = false;
}
public function setHeadIconPosition(worldWidth:int, xIn:int):void{
mClip["mcHeadIcon"].x = scalePosition(worldWidth, xIn);
}
public function setBlueKeyIconPosition(worldWidth:int, xIn:int):void{
mClip["mcBlueKeyIcon"].x = scalePosition(worldWidth, xIn);
if (xIn == 0){
offBlueKey();
};
}
public function setHPBar(percent:int):void{
mClip["mcHp"].gotoAndStop((100 - percent));
}
override public function update(dt:int):void{
super.update(dt);
if (mPlayEffect){
mClip["mcFxItem"].nextFrame();
if (mClip["mcFxItem"].totalFrames == mClip["mcFxItem"].currentFrame){
mClip["mcFxItem"].gotoAndStop(10);
mPlayEffect = false;
};
};
}
public function scalePosition(worldWidth:int, xIn:int):int{
var widthScreen = 500;
var widthWorld:int = worldWidth;
var xOut:int = (((xIn * widthScreen) / widthWorld) + 25);
return (xOut);
}
public function setScore(score:int):void{
mClip["txtScore"].text = score;
}
public function keyVisible(type:int, _visible:Boolean):void{
mClip[("mcKey0" + (type + 1))].visible = _visible;
mClip[("mcKey0" + (type + 1))].gotoAndStop(((type == 0)) ? "blue" : "red");
}
public function offRedKey():void{
mClip["mcRedKeyIcon"].visible = false;
}
public function offFinish():void{
mClip["mcFinish"].visible = false;
}
public function playEffect():void{
mPlayEffect = true;
mClip["mcFxItem"].gotoAndStop(1);
}
public function setItemCollectible(val:int=0):void{
mClip["mcCard01"].gotoAndStop("off");
mClip["mcCard02"].gotoAndStop("off");
mClip["mcCard03"].gotoAndStop("off");
mClip["mcCard04"].gotoAndStop("off");
mClip["mcCard05"].gotoAndStop("off");
if (val > 0){
mClip["mcCard01"].gotoAndStop("on");
};
if (val > 1){
mClip["mcCard02"].gotoAndStop("on");
};
if (val > 2){
mClip["mcCard03"].gotoAndStop("on");
};
if (val > 3){
mClip["mcCard04"].gotoAndStop("on");
};
if (val > 4){
mClip["mcCard05"].gotoAndStop("on");
};
}
public function healthBoss(damage:int):void{
mClip["mcBossBar"].mcHp.gotoAndStop(damage);
}
public function hudBossActive(damage:int):void{
mClip["mcBossBar"].visible = true;
mClip["mcBossBar"].mcHp.gotoAndStop(damage);
mClip["mcCard01"].visible = false;
mClip["mcCard02"].visible = false;
mClip["mcCard03"].visible = false;
mClip["mcCard04"].visible = false;
mClip["mcCard05"].visible = false;
}
private function onMouseHandler(e:MouseEvent):void{
switch (e.type){
case MouseEvent.CLICK:
switch (e.currentTarget.name){
case "btnSound":
muteSound();
break;
case "btnHelp":
Global.game.isPause = true;
addPopup(GuiInstructions, "mcGuiInstructions");
break;
};
break;
};
}
public function setEnergyBar(val:int):void{
mClip["mcSpecial01"].gotoAndStop("off");
mClip["mcSpecial02"].gotoAndStop("off");
mClip["mcSpecial03"].gotoAndStop("off");
if (val > 0){
mClip["mcSpecial01"].gotoAndStop("on");
};
if (val > 1){
mClip["mcSpecial02"].gotoAndStop("on");
};
if (val > 2){
mClip["mcSpecial03"].gotoAndStop("on");
};
}
public function setLifes(lifes:int):void{
mClip["txtLifes"].text = lifes;
}
public function muteSound():void{
isMute = !(isMute);
Global.app.muteBg = (Global.app.muteFx = isMute);
mClip["btnSound"].gotoAndStop((isMute) ? "off" : "on");
if (!isMute){
if (DemoGame.level <= 3){
Global.app.playSound("mus_AT_gameplay");
} else {
Global.app.playSound("mus_AT_bossfight");
};
};
}
public function setFinishIconPosition(worldWidth:int, xIn:int, level:int):void{
mClip["mcFinish"].gotoAndStop(level);
mClip["mcFinish"].x = scalePosition(worldWidth, xIn);
}
public function setAction(type:String):void{
mClip["mcIcons"].gotoAndStop(type);
}
public function setRedKeyIconPosition(worldWidth:int, xIn:int):void{
mClip["mcRedKeyIcon"].x = scalePosition(worldWidth, xIn);
if (xIn == 0){
offRedKey();
};
}
public function offBlueKey():void{
mClip["mcBlueKeyIcon"].visible = false;
}
}
}//package com.bamtang.game.gui
Section 4
//GuiInstructions (com.bamtang.game.gui.GuiInstructions)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
public class GuiInstructions extends Screen {
public function GuiInstructions(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
mClip["btnToNext"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
Application.instance.layer.clip.stage.focus = null;
Global.app.muteFx = true;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
public function onClick(e:MouseEvent):void{
switch (e.target.name){
case "btnToNext":
if ((screenParent is GuiHud)){
screenParent.addPopup(GuiInstructions2, "mcGuiInstructions_02");
} else {
Global.guiManager.gotoScreen(GuiManager.SC_INSTRUCTIONS_2);
};
if (Global.stage.hasEventListener(KeyboardEvent.KEY_DOWN)){
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if ((screenParent is GuiHud)){
screenParent.addPopup(GuiInstructions2, "mcGuiInstructions_02");
} else {
Global.guiManager.gotoScreen(GuiManager.SC_INSTRUCTIONS_2);
};
if (Global.stage.hasEventListener(KeyboardEvent.KEY_DOWN)){
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function free():void{
super.free();
}
}
}//package com.bamtang.game.gui
Section 5
//GuiInstructions2 (com.bamtang.game.gui.GuiInstructions2)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
public class GuiInstructions2 extends Screen {
public function GuiInstructions2(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
mClip["btnToPlay"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
Global.stage.quality = "high";
}
public function onClick(e:MouseEvent):void{
switch (e.target.name){
case "btnToPlay":
if ((screenParent is GuiHud)){
Global.game.isPause = false;
Global.game.returnFocusToGame();
screenParent.dropPopup();
} else {
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_1);
};
if (Global.stage.hasEventListener(KeyboardEvent.KEY_DOWN)){
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
Global.app.muteFx = false;
break;
};
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if ((screenParent is GuiHud)){
Global.game.isPause = false;
Global.game.returnFocusToGame();
screenParent.dropPopup();
} else {
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:1});
};
if (Global.stage.hasEventListener(KeyboardEvent.KEY_DOWN)){
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
Global.app.muteFx = false;
};
}
override public function free():void{
super.free();
}
}
}//package com.bamtang.game.gui
Section 6
//GuiIntroLevel (com.bamtang.game.gui.GuiIntroLevel)
package com.bamtang.game.gui {
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
public class GuiIntroLevel extends Screen {
private var mIntroLevelNumber:int;
public function GuiIntroLevel(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null, introLevelNumber:int=1){
super(nameClip, x, y, appInstance);
mIntroLevelNumber = introLevelNumber;
Global.stage.quality = "high";
}
override public function update(dt:int):void{
super.update(dt);
if (mClip.currentFrame == mClip.totalFrames){
mClip.stop();
screenParent.dropPopup();
DemoPlayer(DemoGame(Global.game).world.player).disable = false;
Global.game.returnFocusToGame();
if (DemoGame.level == 3){
DemoGame(Global.game).showPopupIceKingdowm();
};
} else {
if (mClip.currentFrame == 135){
Global.app.playSound("snd_AT_finn_jake_adventuretime");
} else {
if (mClip.currentFrame == 165){
Global.app.playSound("snd_AT_adventuretimel");
};
};
};
}
}
}//package com.bamtang.game.gui
Section 7
//GuiKillTransition (com.bamtang.game.gui.GuiKillTransition)
package com.bamtang.game.gui {
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
public class GuiKillTransition extends Screen {
private var mFinish:Boolean;// = false
public function GuiKillTransition(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.stage.quality = "high";
}
override public function update(dt:int):void{
super.update(dt);
if (!mFinish){
if (mClip.currentFrame == (mClip.totalFrames - 15)){
DemoGame(Global.game).reset();
};
if (mClip.currentFrame == mClip.totalFrames){
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
mFinish = true;
};
};
}
}
}//package com.bamtang.game.gui
Section 8
//GuiMainMenu (com.bamtang.game.gui.GuiMainMenu)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.swit.controls.*;
import com.bamtang.game.*;
public class GuiMainMenu extends Screen {
public function GuiMainMenu(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.app.playSound("mus_AT_titlecard");
mClip["btnToPlayGame"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
if (Global.settings.GAT_Config01.debugCheats){
mClip["mcGame1"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip["mcGame2"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip["mcGame3"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip["mcGame4"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
} else {
mClip["mcGame1"].visible = false;
mClip["mcGame2"].visible = false;
mClip["mcGame3"].visible = false;
mClip["mcGame4"].visible = false;
};
mClip["btnToInstructions"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.quality = "high";
}
public function onClick(e:MouseEvent):void{
switch (e.target.name){
case "btnToPlayGame":
case "mcGame1":
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_1);
break;
case "mcGame2":
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_2);
break;
case "mcGame3":
Global.guiManager.gotoScreen(GuiManager.SC_CUTSCENE_3);
break;
case "mcGame4":
Global.guiManager.gotoScreen(GuiManager.SC_GAME, {level:4});
break;
case "btnToInstructions":
Global.guiManager.gotoScreen(GuiManager.SC_INSTRUCTIONS);
break;
};
}
override public function free():void{
super.free();
}
private function onClickButton1(b:Button):void{
Application.echo("Open Help");
Global.guiManager.gotoScreen(GuiManager.SC_INSTRUCTIONS);
}
}
}//package com.bamtang.game.gui
Section 9
//GuiManager (com.bamtang.game.gui.GuiManager)
package com.bamtang.game.gui {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
public class GuiManager extends ScreenManager {
public static const SC_GAME:String = "GuiGame";
public static const SC_INTRO_LEVEL_2:String = "GuiIntroLevel02";
public static const SC_INTRO_LEVEL_3:String = "GuiIntroLevel03";
public static const SC_INSTRUCTIONS_2:String = "GuiInstructions2";
public static const SC_CUTSCENE_1:String = "GuiCutScene01";
public static const SC_CUTSCENE_2:String = "GuiCutScene02";
public static const SC_CUTSCENE_3:String = "GuiCutScene03";
public static const SC_INSTRUCTIONS:String = "GuiInstructions";
public static const SC_CUTSCENE_4:String = "GuiCutScene04";
public static const SC_MAIN_MENU:String = "GuiMainMenu";
public static const SC_INTRO_LEVEL_1:String = "GuiIntroLevel01";
public function GuiManager(canvas:MovieClip){
super(canvas);
Global.settings = new Settings();
}
override public function onActivate(activate:Boolean):void{
if (mCurrentScreen){
mCurrentScreen.onActivate(activate);
};
}
override public function gotoScreen(idScreen:String, params:Object=null):void{
super.gotoScreen(idScreen);
switch (idScreen){
case SC_MAIN_MENU:
mCurrentScreen = new GuiMainMenu("mcGuiMainMenu");
break;
case SC_INSTRUCTIONS:
mCurrentScreen = new GuiInstructions("mcGuiInstructions");
break;
case SC_INSTRUCTIONS_2:
mCurrentScreen = new GuiInstructions2("mcGuiInstructions_02");
break;
case SC_GAME:
mCurrentScreen = new GuiGame("mcGuiGame", 0, 0, null, params);
break;
case SC_CUTSCENE_1:
mCurrentScreen = new GuiCutScene("mcGuiCutScene01", 0, 0, null, 1);
break;
case SC_CUTSCENE_2:
mCurrentScreen = new GuiCutScene("mcGuiCutScene02", 0, 0, null, 2);
break;
case SC_CUTSCENE_3:
mCurrentScreen = new GuiCutScene("mcGuiCutScene03", 0, 0, null, 3);
break;
case SC_CUTSCENE_4:
mCurrentScreen = new GuiCutScene("mcGuiEnding", 0, 0, null, 4);
break;
case SC_INTRO_LEVEL_1:
mCurrentScreen = new GuiIntroLevel("mcGuiIntroLevel01", 0, 0, null, 1);
break;
case SC_INTRO_LEVEL_2:
mCurrentScreen = new GuiIntroLevel("mcGuiIntroLevel02", 0, 0, null, 2);
break;
case SC_INTRO_LEVEL_3:
mCurrentScreen = new GuiIntroLevel("mcGuiIntroLevel03", 0, 0, null, 3);
break;
};
mCanvas.addChild(mCurrentScreen.clip);
}
}
}//package com.bamtang.game.gui
Section 10
//GuiPopupCheat (com.bamtang.game.gui.GuiPopupCheat)
package com.bamtang.game.gui {
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupCheat extends Screen {
private var mPlaying:Boolean;
private var mLock:Boolean;
public function GuiPopupCheat(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
mLock = true;
mPlaying = false;
Global.game.isPause = true;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
public function setFocus():void{
Global.stage.focus = mClip.txtInput;
}
override public function onKeyDown(keyCode:int):void{
super.onKeyDown(keyCode);
}
override public function onKeyUp(keyCode:int):void{
var cheat:String;
super.onKeyUp(keyCode);
if (mLock){
return;
};
if (keyCode == Global.KEY_ENTER){
cheat = mClip.txtInput.text.toUpperCase();
mLock = true;
switch (cheat){
case String(Global.settings[("GAT_Config0" + DemoGame.level)].cheat01):
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_UNLEASHJAKE);
DemoPlayer.instance.setEnergy(3);
mClip.mcJakeAnimation.gotoAndStop("positive");
break;
default:
mClip.mcJakeAnimation.gotoAndStop("negative");
break;
};
Common.execCommand(this, "continueAnimation", 1000);
};
}
public function setData():void{
mClip.mcJakeAnimation.gotoAndStop("default");
mLock = false;
setFocus();
}
public function continueAnimation():void{
mPlaying = true;
mClip.play();
}
override public function update(dt:int):void{
super.update(dt);
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
Global.game.returnFocusToGame();
mClip.stop();
screenParent.dropPopup();
};
};
}
}
}//package com.bamtang.game.gui
Section 11
//GuiPopupDoor (com.bamtang.game.gui.GuiPopupDoor)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupDoor extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupDoor(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 12
//GuiPopupFiveCards (com.bamtang.game.gui.GuiPopupFiveCards)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupFiveCards extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupFiveCards(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
Global.game.returnFocusToGame();
mClip.stop();
screenParent.dropPopup();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 13
//GuiPopupFly (com.bamtang.game.gui.GuiPopupFly)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupFly extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupFly(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 14
//GuiPopupIceKingskingdom (com.bamtang.game.gui.GuiPopupIceKingskingdom)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupIceKingskingdom extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupIceKingskingdom(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
Global.game.returnFocusToGame();
mClip.stop();
screenParent.dropPopup();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 15
//GuiPopupShoes (com.bamtang.game.gui.GuiPopupShoes)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupShoes extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupShoes(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
Global.game.returnFocusToGame();
mClip.stop();
screenParent.dropPopup();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 16
//GuiPopupStrech (com.bamtang.game.gui.GuiPopupStrech)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupStrech extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupStrech(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 17
//GuiPopupUnleashJakes (com.bamtang.game.gui.GuiPopupUnleashJakes)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupUnleashJakes extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupUnleashJakes(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 18
//GuiPopupUsesprings (com.bamtang.game.gui.GuiPopupUsesprings)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiPopupUsesprings extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiPopupUsesprings(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
Global.game.returnFocusToGame();
mClip.stop();
screenParent.dropPopup();
};
};
}
public function setData():void{
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
}
}
}//package com.bamtang.game.gui
Section 19
//GuiScorecard (com.bamtang.game.gui.GuiScorecard)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.objects.*;
public class GuiScorecard extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiScorecard(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopAllSound();
Global.app.playSound("mus_AT_scorecard");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
DemoGame(Global.game).onGameEnd(true);
};
};
}
public function setData():void{
var i:int;
if (Items.CARD_GRABBED == 5){
mClip["mcAllSwords"].visible = true;
} else {
mClip["mcAllSwords"].visible = false;
};
mClip["txtTitleClear"].text = (("Level " + DemoGame.level) + " Clear");
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
mClip["txtScore1"].text = ((DemoGame.DIAMONDS_MEDIUM_COLLECTED + "/") + DemoGame.DIAMONDS_MEDIUM_IN_LEVEL);
mClip["txtScore2"].text = ((DemoGame.DIAMONDS_COLLECTED + "/") + DemoGame.DIAMONDS_IN_LEVEL);
mClip["txtLocalScore"].text = (DemoGame.gameScore - DemoGame.oldScore);
i = 1;
while (i < 6) {
mClip[("mcCard0" + i)].gotoAndStop("off");
i++;
};
i = 1;
while (i < (Items.CARD_GRABBED + 1)) {
mClip[("mcCard0" + i)].gotoAndStop("on");
i++;
};
}
}
}//package com.bamtang.game.gui
Section 20
//GuiScorecardLose (com.bamtang.game.gui.GuiScorecardLose)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.objects.*;
public class GuiScorecardLose extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiScorecardLose(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopAllSound();
Global.app.playSound("mus_AT_lose");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
mClip.stop();
screenParent.dropPopup();
Global.app.stopAllSound();
GuiGame.instance.removeGame(DemoGame.level, false);
};
};
}
public function setData():void{
var i:int;
if (Items.CARD_GRABBED == 5){
mClip["mcAllSwords"].visible = true;
} else {
mClip["mcAllSwords"].visible = false;
};
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
mClip["txtScore1"].text = ((DemoGame.DIAMONDS_MEDIUM_COLLECTED + "/") + DemoGame.DIAMONDS_MEDIUM_IN_LEVEL);
mClip["txtScore2"].text = ((DemoGame.DIAMONDS_COLLECTED + "/") + DemoGame.DIAMONDS_IN_LEVEL);
i = 1;
while (i < 6) {
mClip[("mcCard0" + i)].gotoAndStop("off");
i++;
};
i = 1;
while (i < (Items.CARD_GRABBED + 1)) {
mClip[("mcCard0" + i)].gotoAndStop("on");
i++;
};
}
}
}//package com.bamtang.game.gui
Section 21
//GuiScorecardWinGame (com.bamtang.game.gui.GuiScorecardWinGame)
package com.bamtang.game.gui {
import flash.events.*;
import com.bamtang.swit.core.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.utils.*;
public class GuiScorecardWinGame extends Screen {
private var mPlaying:Boolean;
private var mInterval:Interval;
private var mEnableButton:Boolean;
public function GuiScorecardWinGame(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super(nameClip, x, y, appInstance);
Global.game.isPause = true;
mPlaying = false;
mEnableButton = false;
mClip.setData = setData;
Global.app.stopAllSound();
Global.app.playSound("mus_AT_scorecard");
Global.stage.quality = "high";
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "btnBack":
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
break;
};
}
private function onEnableButton():void{
mEnableButton = true;
mInterval.free();
mInterval = null;
}
private function onKeyHandler(e:KeyboardEvent):void{
if (e.keyCode == Global.KEY_SPACE){
if (mEnableButton){
mPlaying = true;
mClip.play();
mClip["btnBack"].removeEventListener(MouseEvent.CLICK, onClick);
Global.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
};
};
}
override public function update(dt:int):void{
super.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mPlaying){
if (mClip.currentFrame == mClip.totalFrames){
Global.game.isPause = false;
mClip.stop();
screenParent.dropPopup();
Global.game.returnFocusToGame();
DemoGame(Global.game).onGameEnd(true);
};
};
}
public function setData():void{
mClip["txtTitleClear"].text = (("Level " + DemoGame.level) + " Clear");
mClip["btnBack"].addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
Global.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler, false, 0, true);
mInterval = new Interval(onEnableButton, Global.settings[("GAT_Config0" + DemoGame.level)].popUpWaitingTime);
mClip["txtGameScore"].text = DemoGame.gameScore;
mClip["txtBonusScore"].text = Global.settings.GAT_Config04.bonusScoreKillBoss;
DemoGame.gameScore = (DemoGame.gameScore + Global.settings.GAT_Config04.bonusScoreKillBoss);
mClip["txtTotalScore"].text = DemoGame.gameScore;
}
}
}//package com.bamtang.game.gui
Section 22
//Boss (com.bamtang.game.platformGame.boss.Boss)
package com.bamtang.game.platformGame.boss {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
import com.bamtang.game.gui.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.objects.*;
public class Boss extends PlatformActor {
private var mBullets:List;
private var mPlayerBombDamage:int;
private var mActualBulletSpeed:Number;
private var mBeardState:int;
private var mIntervalStandTime:Interval;
private var mIntervalHitted:Interval;
private var mActualLoop:int;
private var mHealth:int;
private var mActualDamage:int;
private var mInitBoundsWidth:int;
private var mMovement:Movement;
private var mMaxDistanceBeard:int;
private var mLaughtLoops:int;
private var mLegsDisable:Array;
private var mPlayerBulletDamage:int;
private var mDx:int;
private var mInitBoundsX:int;
private var mTintMagnitude:Number;
private var mHittedByPunch:Boolean;
private var mBeardRectangle:Rectangle;
private var mAngle:Number;
private var mTouchDamage:int;
public var mHasDied:Boolean;// = false
private var mHasDiedInAir:Boolean;// = false
private var mStatesEngine:StatesEngine;
private var mDy:int;
public var isEnemy:Boolean;// = true
private static const ST_GOTO:String = "goto";
private static const ST_DIE:String = "die";
private static const FR_BEARD_STRETCH:int = 20;
private static const ST_CHAR_ANGRY:int = 13;
private static const ST_ANIMATION:String = "animation";
private static const ST_CHAR_FLY:int = 6;
private static const FR_DIED_IN_AIR_STOP:int = 7;
private static const ST_CUSTOM:String = "custom";
private static const ST_CHAR_DASH:int = 11;
private static const ST_CHAR_DEFEAT_STAND:int = 14;
private static const ST_CHAR_HIT:int = 1;
private static const ST_CHAR_FLOATHIT:int = 9;
private static const FR_BEARD_SHRINK:int = 26;
private static const ST_CHAR_FLOATHAPPY:int = 10;
private static const ST_CHAR_STAND:int = 3;
private static const ST_CHAR_HAPPY:int = 12;
private static const ST_CHAR_ZAPSTAND:int = 7;
private static const ST_CHAR_BEARD_HIT:int = 4;
private static const ST_CHAR_MOVE:int = 0;
private static const ST_CHAR_ZAPFLOAT:int = 8;
private static const FR_BEARD_DISSAPEAR:int = 32;
private static const ST_TELEPORT:String = "teleport";
public static const HIT_BULLET:int = 0;
private static const ST_STAND:String = "stand";
private static const ST_FLOAT:String = "float";
private static const FR_ZAPSTAND:int = 21;
private static const ST_ATTACK:String = "attack";
private static const FR_ZAPFLOAT:int = 24;
public static const HIT_BOMB:int = 1;
private static const ST_MOVE:String = "move";
private static const ST_CHAR_DEFEAT:int = 2;
private static const ST_CHAR_FLOAT_FRONT:int = 5;
public function Boss(canvas:MovieClip, world:World, x:int, y:int){
y = (world.getFloorCollision(x, y).y - (60 * world.sizeFactor));
super(canvas, world, "", x, y);
mHealth = Global.settings[("GAT_Config0" + DemoGame.level)].bossHP;
mTouchDamage = Global.settings[("GAT_Config0" + DemoGame.level)].bossTouchDamage;
mPlayerBulletDamage = Global.settings[("GAT_Config0" + DemoGame.level)].playerBulletHit;
mPlayerBombDamage = Global.settings[("GAT_Config0" + DemoGame.level)].playerBombHit;
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_CHAR_MOVE), "mcIceKingWalk");
mCharacter.addState(String(ST_CHAR_HIT), "mcIceKingHit");
mCharacter.addState(String(ST_CHAR_DEFEAT), "mcIceKingDefeat");
mCharacter.addState(String(ST_CHAR_DEFEAT_STAND), "mcIceKingDefeatStand");
mCharacter.addState(String(ST_CHAR_STAND), "mcIceKingStand");
mCharacter.addState(String(ST_CHAR_BEARD_HIT), "mcIceKingBeardHit");
mCharacter.addState(String(ST_CHAR_FLOAT_FRONT), "mcIceKingFloatFront");
mCharacter.addState(String(ST_CHAR_ZAPSTAND), "mcIcekingZapStand");
mCharacter.addState(String(ST_CHAR_FLY), "mcIceKingFly");
mCharacter.addState(String(ST_CHAR_ZAPFLOAT), "mcIceKingFloatAttack");
mCharacter.addState(String(ST_CHAR_FLOATHIT), "mcIceKingFloatHit");
mCharacter.addState(String(ST_CHAR_FLOATHAPPY), "mcIceKingFloatHappy");
mCharacter.addState(String(ST_CHAR_DASH), "mcIceKingDash");
mCharacter.addState(String(ST_CHAR_HAPPY), "mcIceKingHappy");
mCharacter.addState(String(ST_CHAR_ANGRY), "mcIceKingAngry");
mCharacter.onEndAnimation = onEndAnimation;
mStatesEngine = new StatesEngine(Global.settings.GAT_SE.statesCharacter[0].states, Global.settings.GAT_SE.statesCharacter[0].interruptedStates, Global.settings.GAT_SE.statesCharacter[0].customInterruptionStates);
mStatesEngine.addEventListener(StatesEngineEvents.SE_START_STATE, onEngineEvent);
mStatesEngine.addEventListener(StatesEngineEvents.SE_STATE_FORCED, onEngineEvent);
mStatesEngine.addEventListener(StatesEngineEvents.SE_STATE_INTERRUPTED, onEngineEvent);
mStatesEngine.addEventListener(StatesEngineEvents.SE_CUSTOM_STATE_INTERRUPTED, onEngineEvent);
mStatesEngine.addEventListener(StatesEngineEvents.SE_ENGINE_STOP, onEngineEvent);
mStatesEngine.addEventListener(StatesEngineEvents.SE_ENGINE_START, onEngineEvent);
mStatesEngine.startEngine();
mHittedByPunch = false;
mTintMagnitude = 1;
mBeardState = -1;
mInitBoundsX = mBounds.x;
mInitBoundsWidth = mBounds.width;
mBullets = new List();
mIsRangeControlled = false;
var legsDisableInit = 3;
var legsAlreadyDisable:int;
mLegsDisable = new Array();
var i:int;
while (i < DemoWorld(mWorld).objectManager.actors.length) {
if ((DemoWorld(mWorld).objectManager.actors[i] is Items)){
if (DemoWorld(mWorld).objectManager.actors[i].type == Items.FR_FLAG_LEGS){
if (legsDisableInit > legsAlreadyDisable){
DemoWorld(mWorld).objectManager.actors[i].enableItem(false);
mLegsDisable.push(DemoWorld(mWorld).objectManager.actors[i]);
legsAlreadyDisable++;
};
};
};
i++;
};
GuiHud.instance.hudBossActive((100 - int(((100 * mHealth) / Global.settings[("GAT_Config0" + DemoGame.level)].bossHP))));
mScale = 1;
gotoState(ST_CHAR_STAND);
}
public function onEndAnimation(state:String):void{
switch (int(state)){
case ST_CHAR_ANGRY:
case ST_CHAR_HAPPY:
case ST_CHAR_FLOATHAPPY:
mActualLoop++;
if (mActualLoop == mLaughtLoops){
mStatesEngine.nextState();
};
break;
case ST_CHAR_STAND:
break;
case ST_CHAR_DEFEAT:
DemoPlayer.instance.disable = true;
DemoPlayer(mWorld.player).playerWin();
gotoState(ST_CHAR_DEFEAT_STAND);
GuiHud.instance.offFinish();
break;
case ST_CHAR_HIT:
case ST_CHAR_FLOATHIT:
mStatesEngine.interrupted();
mHittedByPunch = false;
break;
case ST_CHAR_MOVE:
break;
case ST_CHAR_ZAPSTAND:
gotoState(ST_CHAR_STAND);
mStatesEngine.nextState();
break;
case ST_CHAR_ZAPFLOAT:
mStatesEngine.nextState();
break;
case ST_CHAR_BEARD_HIT:
gotoState(ST_CHAR_STAND);
mStatesEngine.nextState();
break;
};
}
private function onAttackBeard(distance:int):void{
gotoState(ST_CHAR_BEARD_HIT);
mMaxDistanceBeard = distance;
}
private function checkBulletCollisionWithPlayer(bullet:Bullet, index:int):void{
if (!mWorld.player.isInvulnerable){
if (mWorld.player.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mWorld.player.onEnemyCollision(bullet, bullet.damage);
};
};
}
public function onEngineEvent(e:StatesEngineEvents):void{
var e = e;
switch (e.type){
case StatesEngineEvents.SE_START_STATE:
mHittedByPunch = false;
switch (e.stateName){
case ST_STAND:
if (e.params.facing == "right"){
flipX = true;
} else {
if (e.params.facing == "left"){
flipX = false;
};
};
standTime(e.params.time);
break;
case ST_MOVE:
case ST_FLOAT:
moveTo(e.params.speed, (e.params.x * mWorld.sizeFactor), (e.params.y * mWorld.sizeFactor), e.params.type);
break;
case ST_GOTO:
moveTo(e.params.speed, (int((e.params.x * mWorld.sizeFactor)) - this.x), ((int((e.params.y * mWorld.sizeFactor)))==0) ? 0 : (int((e.params.y * mWorld.sizeFactor)) - this.y), e.params.type);
break;
case ST_DIE:
break;
case ST_ATTACK:
mActualDamage = int(e.params.damage);
switch (e.params.type){
case "melee":
onAttackBeard((e.params.distance * mWorld.sizeFactor));
break;
case "zapStand":
mActualBulletSpeed = Number(e.params.speed);
gotoState(ST_CHAR_ZAPSTAND);
break;
case "zapFloat":
mActualBulletSpeed = Number(e.params.speed);
gotoState(ST_CHAR_ZAPFLOAT);
break;
case "dash":
moveTo(e.params.speed, (e.params.x * mWorld.sizeFactor), (e.params.y * mWorld.sizeFactor), e.params.type);
break;
};
break;
case ST_TELEPORT:
if (e.params.type == "local"){
if (int((e.params.x * mWorld.sizeFactor)) < 0){
flipX = false;
} else {
flipX = true;
};
this.x = (this.x + int((e.params.x * mWorld.sizeFactor)));
this.y = (this.y + int((e.params.y * mWorld.sizeFactor)));
} else {
if (e.params.type == "global"){
if (int((e.params.x * mWorld.sizeFactor)) < x){
flipX = false;
} else {
flipX = true;
};
this.x = int((e.params.x * mWorld.sizeFactor));
this.y = int((e.params.y * mWorld.sizeFactor));
};
};
mStatesEngine.nextState();
break;
case ST_ANIMATION:
mActualLoop = 0;
mLaughtLoops = int(e.params.loop);
gotoState(Boss[e.params.ani]);
break;
case ST_CUSTOM:
switch (e.params.method){
case "echo":
Application.echo(e.params.msg);
break;
};
//unresolved jump
var _slot1 = error;
Application.error((("This method: '" + e.params.method) + "' doesnt exists."));
mStatesEngine.nextState();
break;
};
break;
case StatesEngineEvents.SE_STATE_INTERRUPTED:
trace("INTERRUPTED STATE", e.stateName);
break;
case StatesEngineEvents.SE_ENGINE_STOP:
trace("STOP ENGINE");
break;
case StatesEngineEvents.SE_ENGINE_START:
trace("START ENGINE");
break;
case StatesEngineEvents.SE_STATE_FORCED:
trace("FORCED STATE", e.stateName);
switch (e.stateName){
case "goto":
case "float":
DemoPlayer.instance.disable = true;
Common.execCommand(this, "localizedBozzFreeCam", 4800);
break;
};
break;
case StatesEngineEvents.SE_CUSTOM_STATE_INTERRUPTED:
switch (e.stateName){
case "health":
if (e.params.checkSign == "less"){
if (mHealth < int(e.params.value)){
DemoPlayer(mWorld.player).isInvulnerable = true;
mStatesEngine.gotoForcedState(e.params.gotoStateID);
mStatesEngine.eraseOldCustomInterruption();
};
};
break;
};
break;
};
}
private function onEndMove():void{
x = mMovement.x;
y = mMovement.y;
if (mMovement.params){
if (mMovement.params.type == "normal"){
gotoState(ST_CHAR_STAND);
} else {
if (mMovement.params.type == "landing"){
gotoState(ST_CHAR_STAND);
} else {
if (mMovement.params.type == "floating"){
gotoState(ST_CHAR_FLOAT_FRONT);
} else {
if (mMovement.params.type == "flying"){
gotoState(ST_CHAR_FLOAT_FRONT);
} else {
if (mMovement.params.type == "dash"){
mClip.rotation = 0;
gotoState(ST_CHAR_FLOAT_FRONT);
};
};
};
};
};
} else {
gotoState(ST_CHAR_STAND);
};
mMovement = null;
mStatesEngine.nextState();
}
private function findCollisionWithPlayer():void{
if (mWorld.player.state == DemoPlayer.ST_PLAYER_BOMB){
return;
};
switch (mState){
case ST_CHAR_STAND:
case ST_CHAR_MOVE:
case ST_CHAR_ZAPSTAND:
case ST_CHAR_FLOAT_FRONT:
case ST_CHAR_FLY:
case ST_CHAR_HAPPY:
case ST_CHAR_FLOATHAPPY:
case ST_CHAR_ANGRY:
DemoPlayer(mWorld.player).onBulletCollision(this);
break;
};
}
private function onFinishIntervalHitted():void{
Common.tint(mClip);
mIntervalHitted.free();
mIntervalHitted = null;
mHittedByPunch = false;
}
public function set health(perc:int):void{
var damageBoss:int;
if (!mHasDied){
mHealth = (mHealth + perc);
mStatesEngine.customInterruption("health");
damageBoss = (100 - int(((100 * mHealth) / Global.settings[("GAT_Config0" + DemoGame.level)].bossHP)));
GuiHud.instance.healthBoss(damageBoss);
if (mHealth <= 0){
if (mIntervalStandTime){
mIntervalStandTime.free();
mIntervalStandTime = null;
};
gotoState(ST_CHAR_DEFEAT);
mHasDied = (mHasDiedInAir = true);
};
};
}
public function localizedBozzFreeCam():void{
DemoPlayer.instance.disable = false;
DemoGame.instance.world.sensor.goto(Global.settings.GAT_Config04.freeCameraSpeed, (this.x - (Application.APP_WIDTH / 2)), (this.y - (Application.APP_HEIGHT / 2)), Global.settings.GAT_Config04.freeCameraStandTime);
DemoPlayer(mWorld.player).isInvulnerable = false;
}
private function standTime(time:int):void{
if ((((((mState == ST_CHAR_FLOAT_FRONT)) || ((mState == ST_CHAR_FLY)))) || ((mState == ST_CHAR_FLOATHAPPY)))){
gotoState(ST_CHAR_FLOAT_FRONT);
} else {
gotoState(ST_CHAR_STAND);
};
mIntervalStandTime = new Interval(null, time, 1);
mIntervalStandTime.onFinish = onFinishIntervalStand;
}
private function moveTo(speed:Number, x:int, y:int, _type:String=""):void{
if (x < 0){
flipX = false;
} else {
flipX = true;
};
mMovement = new Movement(speed, this.x, this.y, {type:_type});
mMovement.gotoPosition((this.x + x), (this.y + y));
mMovement.onEndMove = onEndMove;
if (_type == "flying"){
Global.app.playSound("snd_AT_mcIceKingFly");
gotoState(ST_CHAR_FLY);
} else {
if (_type == "normal"){
Global.app.playSound("snd_AT_mcIceKingWalk");
gotoState(ST_CHAR_MOVE);
} else {
if (_type == "floating"){
gotoState(ST_CHAR_FLOAT_FRONT);
} else {
if (_type == "landing"){
gotoState(ST_CHAR_FLOAT_FRONT);
} else {
if (_type == "dash"){
gotoState(ST_CHAR_DASH);
mClip.rotation = ((mMovement.angle * (180 / Math.PI)) - 180);
if (int(mClip.rotation) < 0){
mClip.scaleX = 1;
mClip.scaleY = -1;
};
};
};
};
};
};
}
public function onBossHitted(hitType:int):void{
if (!mHittedByPunch){
switch (hitType){
case HIT_BULLET:
health = -(mPlayerBulletDamage);
break;
case HIT_BOMB:
health = -(mPlayerBombDamage);
break;
};
if (mStatesEngine.isAllowedInterruption){
if (mIntervalStandTime){
mIntervalStandTime.free();
mIntervalStandTime = null;
};
if ((((((((((mState == ST_CHAR_STAND)) || ((mState == ST_CHAR_MOVE)))) || ((mState == ST_CHAR_ZAPSTAND)))) || ((mState == ST_CHAR_HAPPY)))) || ((mState == ST_CHAR_ANGRY)))){
Global.app.playSound("snd_AT_hit1");
gotoState(ST_CHAR_HIT);
} else {
if ((((((mState == ST_CHAR_FLOAT_FRONT)) || ((mState == ST_CHAR_FLY)))) || ((mState == ST_CHAR_FLOATHAPPY)))){
gotoState(ST_CHAR_FLOATHIT);
};
};
} else {
if (mIntervalHitted == null){
mIntervalHitted = new Interval(onRedTintCharacter, 100, 10);
mIntervalHitted.onFinish = onFinishIntervalHitted;
};
};
mHittedByPunch = true;
};
}
private function onRedTintCharacter():void{
if (mTintMagnitude == 1){
Common.tint(mClip, mTintMagnitude, 0, 0);
} else {
if (mTintMagnitude == 0){
Common.tint(mClip);
};
};
mTintMagnitude = ((mTintMagnitude)==1) ? 0 : 1;
}
public function hitTest(actor:PlatformActor):Boolean{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersects(rb));
};
return (false);
}
override public function update(dt:int):void{
var _damage:int;
mCharacter.update(dt);
mBullets.update(dt);
mBullets.iterate(checkBulletCollisionWithPlayer);
GuiHud.instance.setFinishIconPosition(mWorld.width, x, 4);
var i:int;
while (i < mLegsDisable.length) {
if (x > mLegsDisable[i].x){
mLegsDisable[i].enableItem(true);
mLegsDisable[i] = null;
mLegsDisable.splice(i, 1);
i--;
};
i++;
};
if (DemoPlayer(mWorld.player).hitTest(this)){
if (!mWorld.player.isInvulnerable){
if (mState == ST_CHAR_DASH){
_damage = mActualDamage;
} else {
_damage = mTouchDamage;
};
DemoPlayer(mWorld.player).onEnemyCollision(this, _damage);
};
};
if (mIntervalHitted){
mIntervalHitted.update(dt);
};
if (mIntervalStandTime){
mIntervalStandTime.update(dt);
};
switch (mState){
case ST_CHAR_ZAPFLOAT:
if (mClip.currentFrame == FR_ZAPFLOAT){
mDx = (mWorld.player.x - x);
mDy = ((mWorld.player.y - (mWorld.player.clip.height / 2)) - y);
mAngle = 90;
mBullets.add(new Bullet("mcIceKingIceray", mWorld, x, y, mActualBulletSpeed, Global.settings[("GAT_Config0" + DemoGame.level)].enemyScoopeBullet, mAngle, mActualDamage));
findCollisionWithPlayer();
Global.app.playSound("snd_AT_mcIcekingZap");
};
break;
case ST_CHAR_ZAPSTAND:
if (mClip.currentFrame == FR_ZAPSTAND){
if (mWorld.player.x < x){
flipX = false;
} else {
flipX = true;
};
mDx = (mWorld.player.x - x);
mDy = ((mWorld.player.y - (mWorld.player.clip.height / 2)) - y);
mAngle = (Math.atan2(mDy, mDx) * (180 / Math.PI));
mBullets.add(new Bullet("mcIcekingZap", mWorld, x, y, mActualBulletSpeed, Global.settings[("GAT_Config0" + DemoGame.level)].enemyScoopeBullet, mAngle, mActualDamage));
findCollisionWithPlayer();
Global.app.playSound("snd_AT_mcIcekingZap");
};
break;
case ST_CHAR_STAND:
findCollisionWithPlayer();
break;
case ST_CHAR_DEFEAT:
if (mHasDiedInAir){
y = (y + (0.5 * dt));
if (mClip.currentFrame == FR_DIED_IN_AIR_STOP){
mClip.gotoAndStop(FR_DIED_IN_AIR_STOP);
};
if (y >= (1050 * mWorld.sizeFactor)){
y = (1050 * mWorld.sizeFactor);
mClip.play();
mHasDiedInAir = false;
};
};
break;
case ST_CHAR_BEARD_HIT:
switch (mClip.currentFrame){
case FR_BEARD_STRETCH:
mBeardState = 1;
mClip["mcBeard"].alpha = 1;
mClip["mcBeard"].width = 10;
mBeardRectangle = new Rectangle(0, 0, 90, 50);
Global.app.playSound("snd_AT_mcIceKingBeard");
break;
case FR_BEARD_SHRINK:
mBeardState = 2;
break;
case FR_BEARD_DISSAPEAR:
mBeardState = -1;
mClip["mcBeard"].alpha = 0;
mBounds.x = mInitBoundsX;
mBounds.width = mInitBoundsWidth;
break;
};
if (mBeardState == 1){
mClip["mcBeard"].width = (mMaxDistanceBeard / (FR_BEARD_SHRINK - mClip.currentFrame));
} else {
if (mBeardState == 2){
mClip["mcBeard"].width = (mMaxDistanceBeard / ((mClip.currentFrame + 1) - FR_BEARD_SHRINK));
};
};
if ((((mBeardState == 1)) || ((mBeardState == 2)))){
if (mFlipX){
mBounds.width = mClip["mcBeard"].width;
mBounds.x = (mClip["mcBeard"].width / 4);
} else {
mBounds.width = mClip["mcBeard"].width;
mBounds.x = -(mClip["mcBeard"].width);
};
if (!mWorld.player.isInvulnerable){
if (DemoPlayer(mWorld.player).hitTest(this)){
mWorld.player.onEnemyCollision(this, mActualDamage);
};
};
};
break;
case ST_CHAR_HIT:
break;
case ST_CHAR_FLOAT_FRONT:
case ST_CHAR_FLY:
case ST_CHAR_MOVE:
case ST_CHAR_ANGRY:
case ST_CHAR_HAPPY:
case ST_CHAR_FLOATHAPPY:
if (mMovement){
x = mMovement.x;
y = mMovement.y;
mMovement.update(dt);
};
findCollisionWithPlayer();
break;
case ST_CHAR_DASH:
if (mMovement){
x = mMovement.x;
y = mMovement.y;
mMovement.update(dt);
};
break;
};
super.update(dt);
}
private function onFinishIntervalStand():void{
mIntervalStandTime.free();
mIntervalStandTime = null;
mStatesEngine.nextState();
}
override public function free():void{
super.free();
mBullets.free();
mBullets = null;
mMovement = null;
mStatesEngine.free();
mStatesEngine = null;
if (mIntervalHitted){
mIntervalHitted.free();
mIntervalHitted = null;
};
if (mIntervalStandTime){
mIntervalStandTime.free();
mIntervalStandTime = null;
};
mBeardRectangle = null;
}
override public function gotoState(state:int):void{
super.gotoState(state);
if (mState != ST_CHAR_MOVE){
Global.app.stopSound("snd_AT_mcIceKingWalk");
};
if (mState != ST_CHAR_FLOAT_FRONT){
Global.app.stopSound("snd_AT_mcIceKingFloatFront");
};
switch (state){
case ST_CHAR_FLOAT_FRONT:
Global.app.playSound("snd_AT_mcIceKingFloatFront");
break;
case ST_CHAR_DASH:
Global.app.playSound("snd_AT_dash");
break;
case ST_CHAR_DEFEAT:
Global.app.playSound("snd_AT_mcIceKingDefeat");
break;
};
}
}
}//package com.bamtang.game.platformGame.boss
Section 23
//StatesEngine (com.bamtang.game.platformGame.boss.StatesEngine)
package com.bamtang.game.platformGame.boss {
import flash.events.*;
import com.bamtang.game.platformGame.data.*;
import com.bamtang.swit.utils.*;
public class StatesEngine extends EventDispatcher {
private var mRunEngine:Boolean;
public var isAllowedInterruption:Boolean;
private var mES_States:Array;
private var mES_IStates:Array;
private var mStatesLength:int;
private var mOldCustomInterruption:int;
private var mActualState:int;
private var mStateCounter:int;
private var mES_CIStates:Array;
private var mTotalStatesLength:int;
public function StatesEngine(states:Array, iStates:Array, icStates:Array, doFromState:int=0){
super();
mES_States = states;
mES_IStates = iStates;
mES_CIStates = cloneCustomStates(icStates);
mActualState = doFromState;
mRunEngine = false;
mStateCounter = -1;
mTotalStatesLength = states.length;
mStatesLength = states[mActualState].states.length;
isAllowedInterruption = mES_States[mActualState].allowInterruption;
}
private function onCustomStateInterrupted(stateName:String, params:Object, gotoStateID:int):void{
params.gotoStateID = gotoStateID;
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_CUSTOM_STATE_INTERRUPTED, stateName, params));
}
public function interrupted():void{
var i:int;
if (((mRunEngine) && (mES_States[mActualState].allowInterruption))){
i = 0;
while (i < mES_IStates.length) {
if (mES_IStates[i].iStatesID == mActualState){
onStateInterrupted(mES_States[mActualState].states[mStateCounter][0]);
mActualState = mES_IStates[i].doStatesID;
mStatesLength = mES_States[mActualState].states.length;
isAllowedInterruption = mES_States[mActualState].allowInterruption;
mStateCounter = -1;
nextState();
break;
};
i++;
};
};
}
public function startEngine():void{
mRunEngine = true;
onStartEngine();
nextState();
}
private function onStateInterrupted(stateName:String):void{
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_STATE_INTERRUPTED, stateName));
}
private function cloneCustomStates(_icStates:Array):Array{
var newArray:Array = new Array();
var i:int;
while (i < _icStates.length) {
newArray.push(new dtOnCustomInterruption(_icStates[i].type, cloneParamsObject(_icStates[i].params), _icStates[i].doStatesID));
i++;
};
return (newArray);
}
public function customInterruption(type:String):void{
var i:int;
while (i < mES_CIStates.length) {
if (type == mES_CIStates[i].type){
onCustomStateInterrupted(mES_CIStates[i].type, mES_CIStates[i].params, mES_CIStates[i].doStatesID);
mOldCustomInterruption = i;
break;
};
i++;
};
}
public function eraseOldCustomInterruption():void{
mES_CIStates[mOldCustomInterruption] = null;
mES_CIStates.splice(mOldCustomInterruption, 1);
}
private function onForcedState(stateName:String):void{
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_STATE_FORCED, stateName));
}
public function gotoForcedState(state:int):void{
mActualState = state;
mStatesLength = mES_States[mActualState].states.length;
isAllowedInterruption = mES_States[mActualState].allowInterruption;
mStateCounter = -1;
onForcedState(mES_States[mActualState].states[(mStateCounter + 1)][0]);
}
private function onStartState(stateName:String, params:Object):void{
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_START_STATE, stateName, params));
}
public function nextState():void{
if (mRunEngine){
mStateCounter++;
if (mStateCounter == mStatesLength){
mActualState = mES_States[mActualState].onFinishDoState;
mStatesLength = mES_States[mActualState].states.length;
isAllowedInterruption = mES_States[mActualState].allowInterruption;
mStateCounter = 0;
};
onStartState(mES_States[mActualState].states[mStateCounter][0], Common.getParams(mES_States[mActualState].states[mStateCounter][1]));
};
}
private function cloneParamsObject(_params:Object):String{
var _id:String;
var newParams:String = "";
for (_id in _params) {
newParams = (newParams + (((_id + ":") + _params[_id]) + ";"));
};
return (newParams.substring(0, (newParams.length - 1)));
}
private function onStopEngine():void{
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_ENGINE_STOP));
}
public function stopEngine():void{
mRunEngine = false;
onStopEngine();
}
private function onStartEngine():void{
dispatchEvent(new StatesEngineEvents(StatesEngineEvents.SE_ENGINE_START));
}
public function free():void{
mES_States = null;
mES_IStates = null;
}
}
}//package com.bamtang.game.platformGame.boss
Section 24
//StatesEngineEvents (com.bamtang.game.platformGame.boss.StatesEngineEvents)
package com.bamtang.game.platformGame.boss {
import flash.events.*;
public class StatesEngineEvents extends Event {
public var stateName:String;
public var params:Object;
public static const SE_STATE_INTERRUPTED:String = "stateInterrupted";
public static const SE_ENGINE_START:String = "engineStart";
public static const SE_CUSTOM_STATE_INTERRUPTED:String = "customStateInterrupted";
public static const SE_STATE_FORCED:String = "stateForced";
public static const SE_START_STATE:String = "startState";
public static const SE_ENGINE_STOP:String = "engineStop";
public function StatesEngineEvents(type:String, stateName:String="", params:Object=null){
super(type);
this.stateName = stateName;
this.params = params;
}
override public function toString():String{
return (formatToString("StatesEngineEvents", "type", "stateName", "params"));
}
}
}//package com.bamtang.game.platformGame.boss
Section 25
//dtOnCustomInterruption (com.bamtang.game.platformGame.data.dtOnCustomInterruption)
package com.bamtang.game.platformGame.data {
import com.bamtang.swit.utils.*;
public class dtOnCustomInterruption {
public var params:Object;
public var doStatesID:int;
public var type:String;
public function dtOnCustomInterruption(type:String, params:String, doStatesID:int){
super();
this.type = type;
this.params = Common.getParams(params);
this.doStatesID = int(doStatesID);
}
}
}//package com.bamtang.game.platformGame.data
Section 26
//dtOnInterruptedStates (com.bamtang.game.platformGame.data.dtOnInterruptedStates)
package com.bamtang.game.platformGame.data {
public class dtOnInterruptedStates {
public var doStatesID:int;
public var iStatesID:int;
public function dtOnInterruptedStates(interruptedStatesID:int, doStatesID:int){
super();
iStatesID = interruptedStatesID;
this.doStatesID = doStatesID;
}
}
}//package com.bamtang.game.platformGame.data
Section 27
//dtStates (com.bamtang.game.platformGame.data.dtStates)
package com.bamtang.game.platformGame.data {
public class dtStates {
public var states:Array;
public var onFinishDoState:int;
public var id:int;
public var allowInterruption:Boolean;
public function dtStates(id:int, onFinishDoState:int, allowInterruption:Boolean, states:Array){
super();
this.id = id;
this.onFinishDoState = onFinishDoState;
this.allowInterruption = allowInterruption;
this.states = states;
}
}
}//package com.bamtang.game.platformGame.data
Section 28
//dtStatesCharacter (com.bamtang.game.platformGame.data.dtStatesCharacter)
package com.bamtang.game.platformGame.data {
public class dtStatesCharacter {
public var states:Array;
public var interruptedStates:Array;
public var customInterruptionStates:Array;
public function dtStatesCharacter(data:XML){
var i:int;
var e:int;
super();
var _temp:Array = new Array();
states = new Array();
interruptedStates = new Array();
customInterruptionStates = new Array();
i = 0;
while (i < data.states.length()) {
_temp = new Array();
e = 0;
while (e < data.states[i].state.length()) {
_temp.push([data.states[i].state[e].@type, data.states[i].state[e].@params]);
e++;
};
states.push(new dtStates(data.states[i].@id, data.states[i].@onFinishDoState, Boolean(int(data.states[i].@allowInterruption)), _temp));
i++;
};
i = 0;
while (i < data.onInterruptedState.length()) {
interruptedStates.push(new dtOnInterruptedStates(data.onInterruptedState[i].@statesID, data.onInterruptedState[i].@doStatesID));
i++;
};
i = 0;
while (i < data.onCustomInterruption.length()) {
customInterruptionStates.push(new dtOnCustomInterruption(data.onCustomInterruption[i].@type, data.onCustomInterruption[i].@params, data.onCustomInterruption[i].@doStatesID));
i++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 29
//GAT_Configuration01 (com.bamtang.game.platformGame.data.GAT_Configuration01)
package com.bamtang.game.platformGame.data {
import com.bamtang.game.*;
public class GAT_Configuration01 {
public var mostersDistanceWalk:int;
public var ninjaOutTimeStand:Number;
public var playerScoopeBullet:Number;
public var enemySpineDamage:int;
public var ninjaDistanceWalk:int;
public var playerHitImpulseX:int;
public var enemySquashFactor:Number;
public var enemyDamage:int;
public var enemyHitTimer:int;
public var cheat01:String;
public var cheat02:String;
public var playerHitImpulseY:int;
public var enemyScoopeBullet:int;
public var playerRespawnX:int;
public var playerRespawnY:int;
public var debugCheats:Boolean;
public var gnomeBulletDamage:int;
public var mostersDistanceAttack_2:int;
public var springJumpSpeed:Number;
public var mostersDistanceAttack_1:int;
public var smallDiamondScore:int;
public var enemyGnomeStandTime:int;
public var enemyWalkRange:int;
public var popUpWaitingTime:int;
public var mostersDamage:int;
public var playerTimeFly:Number;
public var enemyDistanceToAttack:int;
public var popUpTutorials:Array;
public var monsterHP:int;
public var playerFlySpeedY:Number;
public var enemySpeedBullet:Number;
public var distanceToOpenDoor:int;
public var enemyGnomeHorizontalMove:int;
public var playerSpeedBullet:Number;
public var ninjaDamage:int;
public var enemySpeed:Number;
public var heightCriteria:int;
public var mediumDiamondScore:int;
public var itemEnergyValue:Number;
public var enemyBulletDamage:int;
public var ninjaDistanceAttack_2:int;
public var ninjaDistanceShoot:Number;
public var playerFlyMaxSpeedX:Number;
public var bigDiamondScore:int;
public var itemExtraEnergyValue:Number;
public var ninjaDistanceAttack_1:int;
public var itemHPValue:int;
public var enemySpineImpulseX:int;
public var cheatPanelActivated:Boolean;
public var checkPointPositions:Array;
public var enemySpineImpulseY:int;
public var gnomeTouchPlayer:int;
public var enemyTimeRest:int;
public var itemExtraHPValue:int;
public var enemyGnomeVerticalMove:int;
public var mostersDamageBullet:int;
public var playerFlyImpulseX:Number;
public var ninjaDamageBullet:int;
public var mostersOutTimeStand:Number;
public var mostersDistanceShoot:Number;
public function GAT_Configuration01(){
super();
var xml:XML = Global.app.getXMLData("GTP_general");
debugCheats = Boolean(int(xml.general.@debugCheats));
cheatPanelActivated = Boolean(int(xml.general.@cheatPanelActivated));
enemySpineDamage = int(xml.general.@enemySpineDamage);
enemySpineImpulseX = int(xml.general.@enemySpineImpulseX);
enemySpineImpulseY = int(xml.general.@enemySpineImpulseY);
popUpWaitingTime = int(xml.general.@popUpWaitingTime);
distanceToOpenDoor = int(xml.general.@distanceToOpenDoor);
enemyGnomeHorizontalMove = int(xml.general.@enemyGnomeHorizontalMove);
enemyGnomeVerticalMove = int(xml.general.@enemyGnomeVerticalMove);
enemyGnomeStandTime = int(xml.general.@enemyGnomeStandTime);
gnomeTouchPlayer = int(xml.general.@gnomeTouchPlayer);
gnomeBulletDamage = int(xml.general.@gnomeBulletDamage);
playerHitImpulseX = int(xml.general.@playerHitImpulseX);
playerHitImpulseY = int(xml.general.@playerHitImpulseY);
enemyBulletDamage = int(xml.general.@enemyBulletDamage);
enemyScoopeBullet = int(xml.general.@enemyScoopeBullet);
enemyDistanceToAttack = int(xml.general.@enemyDistanceToAttack);
enemySpeedBullet = Number(xml.general.@enemySpeedBullet);
heightCriteria = int(xml.general.@heightCriteria);
itemHPValue = int(xml.general.@itemHPValue);
itemExtraHPValue = int(xml.general.@itemExtraHPValue);
smallDiamondScore = int(xml.general.@smallDiamondScore);
mediumDiamondScore = int(xml.general.@mediumDiamondScore);
bigDiamondScore = int(xml.general.@bigDiamondScore);
mostersDistanceWalk = int(xml.general.@mostersDistanceWalk);
mostersDistanceAttack_1 = int(xml.general.@mostersDistanceAttack_1);
mostersDistanceAttack_2 = int(xml.general.@mostersDistanceAttack_2);
mostersDamageBullet = int(xml.general.@mostersDamageBullet);
mostersDamage = int(xml.general.@mostersDamage);
mostersDistanceShoot = Number(xml.general.@mostersDistanceShoot);
mostersOutTimeStand = Number(xml.general.@mostersOutTimeStand);
monsterHP = int(xml.general.@monsterHP);
ninjaDistanceAttack_1 = int(xml.general.@ninjaDistanceAttack_1);
ninjaDistanceAttack_2 = int(xml.general.@ninjaDistanceAttack_2);
ninjaDamageBullet = int(xml.general.@ninjaDamageBullet);
ninjaDamage = int(xml.general.@ninjaDamage);
ninjaDistanceShoot = Number(xml.general.@ninjaDistanceShoot);
ninjaDistanceWalk = int(xml.general.@ninjaDistanceWalk);
ninjaOutTimeStand = Number(xml.general.@ninjaOutTimeStand);
springJumpSpeed = -(Number(xml.general.@springJumpSpeed));
enemySpeed = Number(xml.general.@enemySpeed);
enemyTimeRest = int(xml.general.@enemyTimeRest);
enemyDamage = int(xml.general.@enemyDamage);
enemyWalkRange = int(xml.general.@enemyWalkRange);
enemyHitTimer = int(xml.general.@enemyHitTimer);
enemySquashFactor = Number(xml.general.@enemySquashFactor);
playerRespawnX = int(xml.general.@playerRespawnX);
playerRespawnY = int(xml.general.@playerRespawnY);
playerScoopeBullet = Number(xml.general.@playerScoopeBullet);
playerSpeedBullet = Number(xml.general.@playerSpeedBullet);
playerFlyImpulseX = Number(xml.general.@playerFlyImpulseX);
playerFlyMaxSpeedX = Number(xml.general.@playerFlyMaxSpeedX);
playerFlySpeedY = Number(xml.general.@playerFlySpeedY);
itemEnergyValue = Number(xml.general.@itemEnergyValue);
playerTimeFly = Number(xml.general.@playerTimeFly);
cheat01 = String(xml.cheatGame.@cheat01);
cheat02 = String(xml.cheatGame.@cheat02);
var k:int;
checkPointPositions = new Array();
k = 0;
while (k < xml.checkPoints.pos.length()) {
checkPointPositions.push([int(xml.checkPoints.pos[k].@x), int(xml.checkPoints.pos[k].@y)]);
k++;
};
popUpTutorials = new Array();
k = 0;
while (k < xml.popUpTutorials.popUp.length()) {
popUpTutorials.push([xml.popUpTutorials.popUp[k].@id, int(xml.popUpTutorials.popUp[k].@appearX1), int(xml.popUpTutorials.popUp[k].@appearX2), int(xml.popUpTutorials.popUp[k].@appearY1), int(xml.popUpTutorials.popUp[k].@appearY2)]);
k++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 30
//GAT_Configuration02 (com.bamtang.game.platformGame.data.GAT_Configuration02)
package com.bamtang.game.platformGame.data {
import com.bamtang.game.*;
public class GAT_Configuration02 {
public var mostersDistanceWalk:int;
public var ninjaOutTimeStand:Number;
public var playerEnergySpentBySnow:Number;
public var ninjaDistanceWalk:int;
public var playerScoopeBullet:Number;
public var enemySpineDamage:int;
public var playerHitImpulseX:int;
public var enemySquashFactor:Number;
public var enemyDamage:int;
public var playerMinPowerLegs:int;
public var enemyHitTimer:int;
public var cheat01:String;
public var cheat02:String;
public var playerHitImpulseY:int;
public var energyAutoRecharge:Number;
public var playerEnergySpentByBomb:Number;
public var enemyScoopeBullet:int;
public var playerRespawnX:int;
public var debugCheats:Boolean;
public var gnomeBulletDamage:int;
public var playerRespawnY:int;
public var mostersDistanceAttack_2:int;
public var mostersDistanceAttack_1:int;
public var smallDiamondScore:int;
public var enemyGnomeStandTime:int;
public var enemyWalkRange:int;
public var popUpWaitingTime:int;
public var mostersDamage:int;
public var playerTimeFly:Number;
public var playerFlyDischarge:Number;
public var enemyDistanceToAttack:int;
public var monsterHP:int;
public var popUpTutorials:Array;
public var playerFlySpeedY:Number;
public var playerMinPowerSnow:int;
public var enemySpeedBullet:Number;
public var springJumpSpeedLow:Number;
public var enemyGnomeHorizontalMove:int;
public var playerSpeedBullet:Number;
public var playerMinPowerFlight:int;
public var distanceToOpenDoor:int;
public var ninjaDamage:int;
public var playerMinPowerBomb:int;
public var enemySpeed:Number;
public var playerEnergySpentByLegs:Number;
public var heightCriteria:int;
public var mediumDiamondScore:int;
public var itemEnergyValue:Number;
public var ninjaDistanceAttack_1:int;
public var ninjaDistanceAttack_2:int;
public var playerFlyMaxSpeedX:Number;
public var bigDiamondScore:int;
public var enemyBulletDamage:int;
public var itemExtraEnergyValue:Number;
public var itemHPValue:int;
public var ninjaDistanceShoot:Number;
public var enemySpineImpulseX:int;
public var enemyGnomeVerticalMove:int;
public var cheatPanelActivated:Boolean;
public var checkPointPositions:Array;
public var enemySpineImpulseY:int;
public var enemyTimeRest:int;
public var itemExtraHPValue:int;
public var springJumpSpeedHigh:Number;
public var gnomeTouchPlayer:int;
public var playerEnergySpentByFlight:Number;
public var mostersDamageBullet:int;
public var playerFlyImpulseX:Number;
public var ninjaDamageBullet:int;
public var mostersOutTimeStand:Number;
public var mostersDistanceShoot:Number;
public function GAT_Configuration02(){
super();
var xml:XML = Global.app.getXMLData("GAT_general02");
debugCheats = Boolean(int(xml.general.@debugCheats));
cheatPanelActivated = Boolean(int(xml.general.@cheatPanelActivated));
enemySpineDamage = int(xml.general.@enemySpineDamage);
enemySpineImpulseX = int(xml.general.@enemySpineImpulseX);
enemySpineImpulseY = int(xml.general.@enemySpineImpulseY);
popUpWaitingTime = int(xml.general.@popUpWaitingTime);
distanceToOpenDoor = int(xml.general.@distanceToOpenDoor);
enemyGnomeHorizontalMove = int(xml.general.@enemyGnomeHorizontalMove);
enemyGnomeVerticalMove = int(xml.general.@enemyGnomeVerticalMove);
enemyGnomeStandTime = int(xml.general.@enemyGnomeStandTime);
gnomeTouchPlayer = int(xml.general.@gnomeTouchPlayer);
gnomeBulletDamage = int(xml.general.@gnomeBulletDamage);
playerHitImpulseX = int(xml.general.@playerHitImpulseX);
playerHitImpulseY = int(xml.general.@playerHitImpulseY);
enemyBulletDamage = int(xml.general.@enemyBulletDamage);
enemyScoopeBullet = int(xml.general.@enemyScoopeBullet);
enemyDistanceToAttack = int(xml.general.@enemyDistanceToAttack);
enemySpeedBullet = Number(xml.general.@enemySpeedBullet);
heightCriteria = int(xml.general.@heightCriteria);
itemHPValue = int(xml.general.@itemHPValue);
itemExtraHPValue = int(xml.general.@itemExtraHPValue);
smallDiamondScore = int(xml.general.@smallDiamondScore);
mediumDiamondScore = int(xml.general.@mediumDiamondScore);
bigDiamondScore = int(xml.general.@bigDiamondScore);
springJumpSpeedLow = -(Number(xml.general.@springJumpSpeedLow));
springJumpSpeedHigh = -(Number(xml.general.@springJumpSpeedHigh));
ninjaDistanceAttack_1 = int(xml.general.@ninjaDistanceAttack_1);
ninjaDistanceAttack_2 = int(xml.general.@ninjaDistanceAttack_2);
ninjaDamageBullet = int(xml.general.@ninjaDamageBullet);
ninjaDamage = int(xml.general.@ninjaDamage);
ninjaDistanceShoot = Number(xml.general.@ninjaDistanceShoot);
ninjaDistanceWalk = int(xml.general.@ninjaDistanceWalk);
ninjaOutTimeStand = Number(xml.general.@ninjaOutTimeStand);
mostersDistanceWalk = int(xml.general.@mostersDistanceWalk);
mostersDistanceAttack_1 = int(xml.general.@mostersDistanceAttack_1);
mostersDistanceAttack_2 = int(xml.general.@mostersDistanceAttack_2);
mostersDamageBullet = int(xml.general.@mostersDamageBullet);
mostersDamage = int(xml.general.@mostersDamage);
mostersDistanceShoot = Number(xml.general.@mostersDistanceShoot);
mostersOutTimeStand = Number(xml.general.@mostersOutTimeStand);
monsterHP = int(xml.general.@monsterHP);
enemySpeed = Number(xml.general.@enemySpeed);
enemyTimeRest = int(xml.general.@enemyTimeRest);
enemyDamage = int(xml.general.@enemyDamage);
enemyWalkRange = int(xml.general.@enemyWalkRange);
enemyHitTimer = int(xml.general.@enemyHitTimer);
enemySquashFactor = Number(xml.general.@enemySquashFactor);
playerRespawnX = int(xml.general.@playerRespawnX);
playerRespawnY = int(xml.general.@playerRespawnY);
playerScoopeBullet = Number(xml.general.@playerScoopeBullet);
playerSpeedBullet = Number(xml.general.@playerSpeedBullet);
playerFlyImpulseX = Number(xml.general.@playerFlyImpulseX);
playerFlyMaxSpeedX = Number(xml.general.@playerFlyMaxSpeedX);
playerFlySpeedY = Number(xml.general.@playerFlySpeedY);
playerMinPowerSnow = int(xml.general.@playerMinPowerSnow);
playerMinPowerLegs = int(xml.general.@playerMinPowerLegs);
playerMinPowerFlight = int(xml.general.@playerMinPowerFlight);
playerMinPowerBomb = int(xml.general.@playerMinPowerBomb);
energyAutoRecharge = Number(xml.general.@energyAutoRecharge);
playerEnergySpentBySnow = Number(xml.general.@playerEnergySpentBySnow);
playerEnergySpentByLegs = Number(xml.general.@playerEnergySpentByLegs);
playerEnergySpentByFlight = Number(xml.general.@playerEnergySpentByFlight);
playerEnergySpentByBomb = Number(xml.general.@playerEnergySpentByBomb);
playerFlyDischarge = Number(xml.general.@playerFlyDischarge);
playerTimeFly = Number(xml.general.@playerTimeFly);
itemEnergyValue = Number(xml.general.@itemEnergyValue);
itemExtraEnergyValue = Number(xml.general.@itemExtraEnergyValue);
cheat01 = String(xml.cheatGame.@cheat01);
cheat02 = String(xml.cheatGame.@cheat02);
var k:int;
checkPointPositions = new Array();
k = 0;
while (k < xml.checkPoints.pos.length()) {
checkPointPositions.push([int(xml.checkPoints.pos[k].@x), int(xml.checkPoints.pos[k].@y)]);
k++;
};
popUpTutorials = new Array();
k = 0;
while (k < xml.popUpTutorials.popUp.length()) {
popUpTutorials.push([xml.popUpTutorials.popUp[k].@id, int(xml.popUpTutorials.popUp[k].@appearX1), int(xml.popUpTutorials.popUp[k].@appearX2), int(xml.popUpTutorials.popUp[k].@appearY1), int(xml.popUpTutorials.popUp[k].@appearY2)]);
k++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 31
//GAT_Configuration03 (com.bamtang.game.platformGame.data.GAT_Configuration03)
package com.bamtang.game.platformGame.data {
import com.bamtang.game.*;
public class GAT_Configuration03 {
public var mostersDistanceWalk:int;
public var ninjaOutTimeStand:Number;
public var playerEnergySpentBySnow:Number;
public var ninjaDistanceWalk:int;
public var playerScoopeBullet:Number;
public var enemySpineDamage:int;
public var playerHitImpulseX:int;
public var enemySquashFactor:Number;
public var enemyDamage:int;
public var playerMinPowerLegs:int;
public var enemyHitTimer:int;
public var cheat01:String;
public var cheat02:String;
public var playerHitImpulseY:int;
public var energyAutoRecharge:Number;
public var playerEnergySpentByBomb:Number;
public var enemyScoopeBullet:int;
public var playerRespawnX:int;
public var debugCheats:Boolean;
public var gnomeBulletDamage:int;
public var playerRespawnY:int;
public var mostersDistanceAttack_2:int;
public var mostersDistanceAttack_1:int;
public var smallDiamondScore:int;
public var enemyGnomeStandTime:int;
public var enemyWalkRange:int;
public var popUpWaitingTime:int;
public var mostersDamage:int;
public var playerTimeFly:Number;
public var playerFlyDischarge:Number;
public var enemyDistanceToAttack:int;
public var monsterHP:int;
public var popUpTutorials:Array;
public var playerFlySpeedY:Number;
public var playerMinPowerSnow:int;
public var enemySpeedBullet:Number;
public var springJumpSpeedLow:Number;
public var enemyGnomeHorizontalMove:int;
public var playerSpeedBullet:Number;
public var playerMinPowerFlight:int;
public var distanceToOpenDoor:int;
public var ninjaDamage:int;
public var playerMinPowerBomb:int;
public var enemySpeed:Number;
public var playerEnergySpentByLegs:Number;
public var heightCriteria:int;
public var mediumDiamondScore:int;
public var itemEnergyValue:Number;
public var ninjaDistanceAttack_1:int;
public var ninjaDistanceAttack_2:int;
public var playerFlyMaxSpeedX:Number;
public var bigDiamondScore:int;
public var enemyBulletDamage:int;
public var itemExtraEnergyValue:Number;
public var itemHPValue:int;
public var ninjaDistanceShoot:Number;
public var enemySpineImpulseX:int;
public var enemyGnomeVerticalMove:int;
public var cheatPanelActivated:Boolean;
public var checkPointPositions:Array;
public var enemySpineImpulseY:int;
public var enemyTimeRest:int;
public var itemExtraHPValue:int;
public var springJumpSpeedHigh:Number;
public var gnomeTouchPlayer:int;
public var playerEnergySpentByFlight:Number;
public var mostersDamageBullet:int;
public var playerFlyImpulseX:Number;
public var ninjaDamageBullet:int;
public var mostersOutTimeStand:Number;
public var mostersDistanceShoot:Number;
public function GAT_Configuration03(){
super();
var xml:XML = Global.app.getXMLData("GAT_general03");
debugCheats = Boolean(int(xml.general.@debugCheats));
cheatPanelActivated = Boolean(int(xml.general.@cheatPanelActivated));
enemySpineDamage = int(xml.general.@enemySpineDamage);
enemySpineImpulseX = int(xml.general.@enemySpineImpulseX);
enemySpineImpulseY = int(xml.general.@enemySpineImpulseY);
popUpWaitingTime = int(xml.general.@popUpWaitingTime);
distanceToOpenDoor = int(xml.general.@distanceToOpenDoor);
enemyGnomeHorizontalMove = int(xml.general.@enemyGnomeHorizontalMove);
enemyGnomeVerticalMove = int(xml.general.@enemyGnomeVerticalMove);
enemyGnomeStandTime = int(xml.general.@enemyGnomeStandTime);
gnomeTouchPlayer = int(xml.general.@gnomeTouchPlayer);
gnomeBulletDamage = int(xml.general.@gnomeBulletDamage);
playerHitImpulseX = int(xml.general.@playerHitImpulseX);
playerHitImpulseY = int(xml.general.@playerHitImpulseY);
enemyBulletDamage = int(xml.general.@enemyBulletDamage);
enemyScoopeBullet = int(xml.general.@enemyScoopeBullet);
enemyDistanceToAttack = int(xml.general.@enemyDistanceToAttack);
enemySpeedBullet = Number(xml.general.@enemySpeedBullet);
heightCriteria = int(xml.general.@heightCriteria);
itemHPValue = int(xml.general.@itemHPValue);
itemExtraHPValue = int(xml.general.@itemExtraHPValue);
smallDiamondScore = int(xml.general.@smallDiamondScore);
mediumDiamondScore = int(xml.general.@mediumDiamondScore);
bigDiamondScore = int(xml.general.@bigDiamondScore);
springJumpSpeedLow = -(Number(xml.general.@springJumpSpeedLow));
springJumpSpeedHigh = -(Number(xml.general.@springJumpSpeedHigh));
ninjaDistanceAttack_1 = int(xml.general.@ninjaDistanceAttack_1);
ninjaDistanceAttack_2 = int(xml.general.@ninjaDistanceAttack_2);
ninjaDamageBullet = int(xml.general.@ninjaDamageBullet);
ninjaDamage = int(xml.general.@ninjaDamage);
ninjaDistanceShoot = Number(xml.general.@ninjaDistanceShoot);
ninjaDistanceWalk = int(xml.general.@ninjaDistanceWalk);
ninjaOutTimeStand = Number(xml.general.@ninjaOutTimeStand);
mostersDistanceWalk = int(xml.general.@mostersDistanceWalk);
mostersDistanceAttack_1 = int(xml.general.@mostersDistanceAttack_1);
mostersDistanceAttack_2 = int(xml.general.@mostersDistanceAttack_2);
mostersDamageBullet = int(xml.general.@mostersDamageBullet);
mostersDamage = int(xml.general.@mostersDamage);
mostersDistanceShoot = Number(xml.general.@mostersDistanceShoot);
mostersOutTimeStand = Number(xml.general.@mostersOutTimeStand);
monsterHP = int(xml.general.@monsterHP);
enemySpeed = Number(xml.general.@enemySpeed);
enemyTimeRest = int(xml.general.@enemyTimeRest);
enemyDamage = int(xml.general.@enemyDamage);
enemyWalkRange = int(xml.general.@enemyWalkRange);
enemyHitTimer = int(xml.general.@enemyHitTimer);
enemySquashFactor = Number(xml.general.@enemySquashFactor);
playerRespawnX = int(xml.general.@playerRespawnX);
playerRespawnY = int(xml.general.@playerRespawnY);
playerScoopeBullet = Number(xml.general.@playerScoopeBullet);
playerSpeedBullet = Number(xml.general.@playerSpeedBullet);
playerFlyImpulseX = Number(xml.general.@playerFlyImpulseX);
playerFlyMaxSpeedX = Number(xml.general.@playerFlyMaxSpeedX);
playerFlySpeedY = Number(xml.general.@playerFlySpeedY);
playerMinPowerSnow = int(xml.general.@playerMinPowerSnow);
playerMinPowerLegs = int(xml.general.@playerMinPowerLegs);
playerMinPowerFlight = int(xml.general.@playerMinPowerFlight);
playerMinPowerBomb = int(xml.general.@playerMinPowerBomb);
energyAutoRecharge = Number(xml.general.@energyAutoRecharge);
playerEnergySpentBySnow = Number(xml.general.@playerEnergySpentBySnow);
playerEnergySpentByLegs = Number(xml.general.@playerEnergySpentByLegs);
playerEnergySpentByFlight = Number(xml.general.@playerEnergySpentByFlight);
playerEnergySpentByBomb = Number(xml.general.@playerEnergySpentByBomb);
playerFlyDischarge = Number(xml.general.@playerFlyDischarge);
playerTimeFly = Number(xml.general.@playerTimeFly);
itemEnergyValue = Number(xml.general.@itemEnergyValue);
itemExtraEnergyValue = Number(xml.general.@itemExtraEnergyValue);
cheat01 = String(xml.cheatGame.@cheat01);
cheat02 = String(xml.cheatGame.@cheat02);
var k:int;
checkPointPositions = new Array();
k = 0;
while (k < xml.checkPoints.pos.length()) {
checkPointPositions.push([int(xml.checkPoints.pos[k].@x), int(xml.checkPoints.pos[k].@y)]);
k++;
};
popUpTutorials = new Array();
k = 0;
while (k < xml.popUpTutorials.popUp.length()) {
popUpTutorials.push([xml.popUpTutorials.popUp[k].@id, int(xml.popUpTutorials.popUp[k].@appearX1), int(xml.popUpTutorials.popUp[k].@appearX2), int(xml.popUpTutorials.popUp[k].@appearY1), int(xml.popUpTutorials.popUp[k].@appearY2)]);
k++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 32
//GAT_Configuration04 (com.bamtang.game.platformGame.data.GAT_Configuration04)
package com.bamtang.game.platformGame.data {
import com.bamtang.game.*;
public class GAT_Configuration04 {
public var mostersDistanceWalk:int;
public var ninjaOutTimeStand:Number;
public var playerEnergySpentBySnow:Number;
public var ninjaDistanceWalk:int;
public var playerScoopeBullet:Number;
public var enemySpineDamage:int;
public var freeCameraStandTime:int;
public var playerHitImpulseX:int;
public var enemySquashFactor:Number;
public var enemyDamage:int;
public var playerMinPowerLegs:int;
public var enemyHitTimer:int;
public var cheat01:String;
public var cheat02:String;
public var playerHitImpulseY:int;
public var energyAutoRecharge:Number;
public var playerEnergySpentByBomb:Number;
public var enemyScoopeBullet:int;
public var playerRespawnX:int;
public var debugCheats:Boolean;
public var bossHP:int;
public var gnomeBulletDamage:int;
public var playerRespawnY:int;
public var mostersDistanceAttack_2:int;
public var mostersDistanceAttack_1:int;
public var smallDiamondScore:int;
public var enemyGnomeStandTime:int;
public var enemyWalkRange:int;
public var popUpWaitingTime:int;
public var freeCameraSpeed:Number;
public var playerBulletHit:int;
public var mostersDamage:int;
public var playerTimeFly:Number;
public var playerFlyDischarge:Number;
public var enemyDistanceToAttack:int;
public var monsterHP:int;
public var popUpTutorials:Array;
public var playerFlySpeedY:Number;
public var playerMinPowerSnow:int;
public var playerBombHit:int;
public var enemySpeedBullet:Number;
public var springJumpSpeedLow:Number;
public var enemyGnomeHorizontalMove:int;
public var playerSpeedBullet:Number;
public var playerMinPowerFlight:int;
public var distanceToOpenDoor:int;
public var ninjaDamage:int;
public var playerMinPowerBomb:int;
public var enemySpeed:Number;
public var playerEnergySpentByLegs:Number;
public var heightCriteria:int;
public var mediumDiamondScore:int;
public var itemEnergyValue:Number;
public var ninjaDistanceAttack_1:int;
public var ninjaDistanceAttack_2:int;
public var playerFlyMaxSpeedX:Number;
public var bigDiamondScore:int;
public var enemyBulletDamage:int;
public var itemExtraEnergyValue:Number;
public var itemHPValue:int;
public var ninjaDistanceShoot:Number;
public var enemySpineImpulseX:int;
public var enemyGnomeVerticalMove:int;
public var cheatPanelActivated:Boolean;
public var bossTouchDamage:int;
public var checkPointPositions:Array;
public var enemySpineImpulseY:int;
public var enemyTimeRest:int;
public var bonusScoreKillBoss:int;
public var itemExtraHPValue:int;
public var springJumpSpeedHigh:Number;
public var gnomeTouchPlayer:int;
public var playerEnergySpentByFlight:Number;
public var mostersDamageBullet:int;
public var playerFlyImpulseX:Number;
public var ninjaDamageBullet:int;
public var mostersOutTimeStand:Number;
public var mostersDistanceShoot:Number;
public function GAT_Configuration04(){
super();
var xml:XML = Global.app.getXMLData("GAT_general04");
debugCheats = Boolean(int(xml.general.@debugCheats));
cheatPanelActivated = Boolean(int(xml.general.@cheatPanelActivated));
playerBulletHit = int(xml.general.@playerBulletHit);
playerBombHit = int(xml.general.@playerBombHit);
bossHP = int(xml.general.@bossHP);
bossTouchDamage = int(xml.general.@bossTouchDamage);
bonusScoreKillBoss = int(xml.general.@bonusScoreKillBoss);
freeCameraSpeed = int(xml.general.@freeCameraSpeed);
freeCameraStandTime = Number(xml.general.@freeCameraStandTime);
enemySpineDamage = int(xml.general.@enemySpineDamage);
enemySpineImpulseX = int(xml.general.@enemySpineImpulseX);
enemySpineImpulseY = int(xml.general.@enemySpineImpulseY);
popUpWaitingTime = int(xml.general.@popUpWaitingTime);
distanceToOpenDoor = int(xml.general.@distanceToOpenDoor);
enemyGnomeHorizontalMove = int(xml.general.@enemyGnomeHorizontalMove);
enemyGnomeVerticalMove = int(xml.general.@enemyGnomeVerticalMove);
enemyGnomeStandTime = int(xml.general.@enemyGnomeStandTime);
gnomeTouchPlayer = int(xml.general.@gnomeTouchPlayer);
gnomeBulletDamage = int(xml.general.@gnomeBulletDamage);
playerHitImpulseX = int(xml.general.@playerHitImpulseX);
playerHitImpulseY = int(xml.general.@playerHitImpulseY);
enemyBulletDamage = int(xml.general.@enemyBulletDamage);
enemyScoopeBullet = int(xml.general.@enemyScoopeBullet);
enemyDistanceToAttack = int(xml.general.@enemyDistanceToAttack);
enemySpeedBullet = Number(xml.general.@enemySpeedBullet);
heightCriteria = int(xml.general.@heightCriteria);
itemHPValue = int(xml.general.@itemHPValue);
itemExtraHPValue = int(xml.general.@itemExtraHPValue);
smallDiamondScore = int(xml.general.@smallDiamondScore);
mediumDiamondScore = int(xml.general.@mediumDiamondScore);
bigDiamondScore = int(xml.general.@bigDiamondScore);
springJumpSpeedLow = -(Number(xml.general.@springJumpSpeedLow));
springJumpSpeedHigh = -(Number(xml.general.@springJumpSpeedHigh));
ninjaDistanceAttack_1 = int(xml.general.@ninjaDistanceAttack_1);
ninjaDistanceAttack_2 = int(xml.general.@ninjaDistanceAttack_2);
ninjaDamageBullet = int(xml.general.@ninjaDamageBullet);
ninjaDamage = int(xml.general.@ninjaDamage);
ninjaDistanceShoot = Number(xml.general.@ninjaDistanceShoot);
ninjaDistanceWalk = int(xml.general.@ninjaDistanceWalk);
ninjaOutTimeStand = Number(xml.general.@ninjaOutTimeStand);
mostersDistanceWalk = int(xml.general.@mostersDistanceWalk);
mostersDistanceAttack_1 = int(xml.general.@mostersDistanceAttack_1);
mostersDistanceAttack_2 = int(xml.general.@mostersDistanceAttack_2);
mostersDamageBullet = int(xml.general.@mostersDamageBullet);
mostersDamage = int(xml.general.@mostersDamage);
mostersDistanceShoot = Number(xml.general.@mostersDistanceShoot);
mostersOutTimeStand = Number(xml.general.@mostersOutTimeStand);
monsterHP = int(xml.general.@monsterHP);
enemySpeed = Number(xml.general.@enemySpeed);
enemyTimeRest = int(xml.general.@enemyTimeRest);
enemyDamage = int(xml.general.@enemyDamage);
enemyWalkRange = int(xml.general.@enemyWalkRange);
enemyHitTimer = int(xml.general.@enemyHitTimer);
enemySquashFactor = Number(xml.general.@enemySquashFactor);
playerRespawnX = int(xml.general.@playerRespawnX);
playerRespawnY = int(xml.general.@playerRespawnY);
playerScoopeBullet = Number(xml.general.@playerScoopeBullet);
playerSpeedBullet = Number(xml.general.@playerSpeedBullet);
playerFlyImpulseX = Number(xml.general.@playerFlyImpulseX);
playerFlyMaxSpeedX = Number(xml.general.@playerFlyMaxSpeedX);
playerFlySpeedY = Number(xml.general.@playerFlySpeedY);
playerMinPowerSnow = int(xml.general.@playerMinPowerSnow);
playerMinPowerLegs = int(xml.general.@playerMinPowerLegs);
playerMinPowerFlight = int(xml.general.@playerMinPowerFlight);
playerMinPowerBomb = int(xml.general.@playerMinPowerBomb);
energyAutoRecharge = Number(xml.general.@energyAutoRecharge);
playerEnergySpentBySnow = Number(xml.general.@playerEnergySpentBySnow);
playerEnergySpentByLegs = Number(xml.general.@playerEnergySpentByLegs);
playerEnergySpentByFlight = Number(xml.general.@playerEnergySpentByFlight);
playerEnergySpentByBomb = Number(xml.general.@playerEnergySpentByBomb);
playerFlyDischarge = Number(xml.general.@playerFlyDischarge);
playerTimeFly = Number(xml.general.@playerTimeFly);
itemEnergyValue = Number(xml.general.@itemEnergyValue);
itemExtraEnergyValue = Number(xml.general.@itemExtraEnergyValue);
cheat01 = String(xml.cheatGame.@cheat01);
cheat02 = String(xml.cheatGame.@cheat02);
var k:int;
checkPointPositions = new Array();
k = 0;
while (k < xml.checkPoints.pos.length()) {
checkPointPositions.push([int(xml.checkPoints.pos[k].@x), int(xml.checkPoints.pos[k].@y)]);
k++;
};
popUpTutorials = new Array();
k = 0;
while (k < xml.popUpTutorials.popUp.length()) {
popUpTutorials.push([xml.popUpTutorials.popUp[k].@id, int(xml.popUpTutorials.popUp[k].@appearX)]);
k++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 33
//GAT_StatesEngine (com.bamtang.game.platformGame.data.GAT_StatesEngine)
package com.bamtang.game.platformGame.data {
import com.bamtang.game.*;
public class GAT_StatesEngine {
public var statesCharacter:Array;
public function GAT_StatesEngine(){
super();
statesCharacter = new Array();
var xmlGame:XML = Global.app.getXMLData("GTP_bossStates");
var i:int;
while (i < xmlGame.character.length()) {
statesCharacter.push(new dtStatesCharacter(xmlGame.character[i]));
i++;
};
}
}
}//package com.bamtang.game.platformGame.data
Section 34
//Door (com.bamtang.game.platformGame.door.Door)
package com.bamtang.game.platformGame.door {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
import com.bamtang.game.gui.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.objects.*;
public class Door {
public var betweenYs:Array;
private var mAllowedToOpen:Boolean;
public var layerDepthPartRear:int;
private var mAlwaysOpen:Boolean;
private var mDynamicCollisionSet:Boolean;
private var mRealRearDoorPositionY:int;
private var mDistanceToOpenDoor:int;
private var mInterval:Interval;
private var mRearLayer:PlatformLayer;
private var mRearDoorDetected:Boolean;// = false
public var betweenXs:Array;
public var layerDepthPartFront:int;
private var mWorld:World;
private var mFrontDoorDetected:Boolean;// = false
private var mDoorPlayed:Boolean;
private var mRepositionInY:int;
private var mDoorFinded:Boolean;
private var mFrontLayer:PlatformLayer;
public var type:int;
private var mRealFrontDoorPositionY:int;
public static const DR_RED:int = 1;
public static const DOOR_RED_BW:uint = 1;
public static const DOOR_BLUE_BW:uint = 2;
public static const DR_BLUE:int = 0;
public static var DOOR_OPEN:uint = 0;
public function Door(world:World, type:int, layerDepthPartFront:int, layerDepthPartRear:int, betweenXs:Array, repositionInY:int, betweenYs:Array=null){
super();
this.type = type;
this.layerDepthPartRear = layerDepthPartRear;
this.layerDepthPartFront = layerDepthPartFront;
this.betweenXs = betweenXs;
this.betweenYs = betweenYs;
mWorld = world;
mRepositionInY = repositionInY;
mDoorFinded = (mDoorPlayed = (mAllowedToOpen = (mAlwaysOpen = (mDynamicCollisionSet = false))));
mFrontLayer = mWorld.layers[layerDepthPartFront];
mRearLayer = mWorld.layers[layerDepthPartRear];
mDistanceToOpenDoor = Global.settings[("GAT_Config0" + DemoGame.level)].distanceToOpenDoor;
}
public function allowedToOpen():void{
mAllowedToOpen = true;
}
public function getClips():Array{
return ([mFrontLayer.canvas.getChildAt(0)["mcFrontDoor"], mRearLayer.canvas.getChildAt(0)["mcRearDoor"]]);
}
public function update(dt:int):void{
if (((mDoorPlayed) && (mAlwaysOpen))){
if (mFrontLayer.canvas.numChildren >= 1){
MovieClip(mFrontLayer.canvas.getChildAt(0))["mcFrontDoor"].gotoAndStop(11);
mFrontLayer.canvas.getChildAt(0).y = mRealFrontDoorPositionY;
};
if (mRearLayer.canvas.numChildren >= 1){
MovieClip(mRearLayer.canvas.getChildAt(0))["mcRearDoor"].gotoAndStop(11);
mRearLayer.canvas.getChildAt(0).y = mRealRearDoorPositionY;
};
} else {
if (checkPositionDoor()){
if (!mDynamicCollisionSet){
enableDynamicCollision(true);
mDynamicCollisionSet = true;
};
mDoorFinded = true;
} else {
mDoorFinded = false;
};
if (mDoorFinded){
if (mAllowedToOpen){
if (!mDoorPlayed){
if (SMath.abs((mWorld.player.x - (mRearLayer.canvas.getChildAt(0).x + mRearLayer.canvas.getChildAt(0).width))) < mDistanceToOpenDoor){
openDoors();
enableDynamicCollision(false);
mInterval = new Interval(doorsAlwaysOpen, 700);
mDoorPlayed = true;
};
};
};
};
};
if (mInterval){
mInterval.update(dt);
};
}
public function openDoors():void{
switch (type){
case DR_RED:
DOOR_OPEN = (DOOR_OPEN | DOOR_RED_BW);
GuiHud.instance.keyVisible(Key.KEY_RED, false);
break;
case DR_BLUE:
DOOR_OPEN = (DOOR_OPEN | DOOR_BLUE_BW);
GuiHud.instance.keyVisible(Key.KEY_BLUE, false);
break;
};
Global.app.playSound("snd_AT_door_open");
MovieClip(mRearLayer.canvas.getChildAt(0))["mcRearDoor"].gotoAndPlay(2);
MovieClip(mFrontLayer.canvas.getChildAt(0))["mcFrontDoor"].gotoAndPlay(2);
}
public function checkDoor():void{
if (type == DR_RED){
if (((DOOR_OPEN & DOOR_RED_BW) == DOOR_RED_BW)){
mAlwaysOpen = (mDoorPlayed = true);
} else {
allowedToOpen();
};
} else {
if (type == DR_BLUE){
if ((DOOR_OPEN & DOOR_BLUE_BW) == DOOR_BLUE_BW){
mAlwaysOpen = (mDoorPlayed = true);
} else {
allowedToOpen();
};
};
};
}
private function doorsAlwaysOpen():void{
mAlwaysOpen = true;
mInterval.free();
mInterval = null;
}
private function checkPositionDoor():Boolean{
var doorCount:int;
if (mFrontLayer.canvas.numChildren >= 1){
doorCount++;
if (!mFrontDoorDetected){
mRealFrontDoorPositionY = (mFrontLayer.canvas.getChildAt(0).y - mRepositionInY);
mFrontDoorDetected = true;
};
mFrontLayer.canvas.getChildAt(0).y = mRealFrontDoorPositionY;
};
if (mRearLayer.canvas.numChildren >= 1){
doorCount++;
if (!mRearDoorDetected){
mRealRearDoorPositionY = (mRearLayer.canvas.getChildAt(0).y - mRepositionInY);
mRearDoorDetected = true;
};
mRearLayer.canvas.getChildAt(0).y = mRealRearDoorPositionY;
};
if (doorCount == 2){
return (true);
};
return (false);
}
private function enableDynamicCollision(state:Boolean):void{
var _y:int;
var limits:Rectangle = mWorld.getMaxFloorRange(mRearLayer.canvas.getChildAt(0).x, (mRearLayer.canvas.getChildAt(0).y + (mRearLayer.canvas.getChildAt(0).height / 2)), 300);
var initX:int = ((mRearLayer.canvas.getChildAt(0).x + (mRearLayer.canvas.getChildAt(0).width / 2)) / mWorld.tileWidth);
var initY:int = (mRearLayer.canvas.getChildAt(0).y / mWorld.tileHeight);
var finalY:int = (limits.y / mWorld.tileHeight);
var _x:int = (initX + 1);
while (_x < (initX + 3)) {
_y = initY;
while (_y < finalY) {
mWorld.setCollisionCell(_x, _y, (state) ? CollisionLayer.CELL_FULL : CollisionLayer.CELL_EMPTY);
_y++;
};
_x++;
};
mWorld.refreshCollision();
}
public function free():void{
mWorld = null;
betweenXs = null;
betweenYs = null;
mFrontLayer = null;
mRearLayer = null;
if (mInterval){
mInterval.free();
mInterval = null;
};
}
}
}//package com.bamtang.game.platformGame.door
Section 35
//DoorManager (com.bamtang.game.platformGame.door.DoorManager)
package com.bamtang.game.platformGame.door {
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.gui.*;
public class DoorManager {
public var doors:Array;
private var mWorld:World;
private var mDoorPlayed:Boolean;// = false
private var mDoorFinded:Boolean;// = false
public function DoorManager(world:World){
super();
mWorld = world;
doors = new Array();
if (DemoGame.level == 2){
addDoor(Door.DR_BLUE, (mWorld.layers.length - 1), (mWorld.layers.length - 2), [(world.sizeFactor * 22000), (world.sizeFactor * 22850)], (world.sizeFactor * 45));
addDoor(Door.DR_RED, (mWorld.layers.length - 1), (mWorld.layers.length - 2), [(world.sizeFactor * 23000), (world.sizeFactor * 24000)], (world.sizeFactor * 45));
} else {
if (DemoGame.level == 3){
addDoor(Door.DR_BLUE, (mWorld.layers.length - 1), (mWorld.layers.length - 2), [(world.sizeFactor * 10050), (world.sizeFactor * 11050)], (world.sizeFactor * -40), [(world.sizeFactor * 1600), (world.sizeFactor * 2200)]);
addDoor(Door.DR_RED, (mWorld.layers.length - 1), (mWorld.layers.length - 2), [(world.sizeFactor * 14600), (world.sizeFactor * 15600)], (world.sizeFactor * 110));
};
};
}
public function activateDoor(type:int):void{
var i:int;
while (i < doors.length) {
if (doors[i].type == type){
doors[i].allowedToOpen();
GuiHud.instance.keyVisible(type, true);
break;
};
i++;
};
}
public function getDoor(type:int):Array{
var i:int;
while (i < doors.length) {
if (doors[i].type == type){
return (doors[i].getClips());
};
i++;
};
return (new Array());
}
public function update(dt:int):void{
var i:int;
while (i < doors.length) {
if ((((mWorld.player.x > doors[i].betweenXs[0])) && ((mWorld.player.x < doors[i].betweenXs[1])))){
if (doors[i].betweenYs == null){
doors[i].update(dt);
} else {
if ((((mWorld.player.y > doors[i].betweenYs[0])) && ((mWorld.player.y < doors[i].betweenYs[1])))){
doors[i].update(dt);
};
};
};
i++;
};
}
public function addDoor(type:int, layerDepthFront:int, layerDepthRear:int, betweenXs:Array, repositionInY:int=0, betweenYs:Array=null):void{
doors.push(new Door(mWorld, type, layerDepthFront, layerDepthRear, betweenXs, repositionInY, betweenYs));
}
public function doorOpen(type:int):void{
var i:int;
while (i < doors.length) {
if (doors[i].type == type){
doors[i].checkDoor();
break;
};
i++;
};
}
public function free():void{
var i:int;
while (i < doors.length) {
doors[i].free();
doors[i] = null;
i++;
};
doors = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.door
Section 36
//Gnome (com.bamtang.game.platformGame.enemys.Gnome)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
public class Gnome extends PlatformActor {
protected var mDistance:int;
private var mHitImpulseX:int;
private var mHitImpulseY:int;
protected var mBullets:List;
protected var mStandTime:int;
protected var mDestinationX:int;
protected var mTimer:int;
protected var mAltitude:int;
public var mHasDied:Boolean;
protected var mHeightCriteria:int;
public var isEnemy:Boolean;// = true
public static const ST_DIE:int = 110;
public function Gnome(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mTimer = 0;
mFlipX = true;
mHasDied = false;
mHitImpulseX = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseX;
mHitImpulseY = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseY;
mHeightCriteria = (Global.settings[("GAT_Config0" + DemoGame.level)].heightCriteria * mWorld.sizeFactor);
}
public function hitTest(actor:PlatformActor):Boolean{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersects(rb));
};
return (false);
}
override public function update(dt:int):void{
mCharacter.update(dt);
DemoPlayer(mWorld.player).onBulletCollision(this);
if (!mHasDied){
if (mWorld.player.hitTest(this)){
if (!mWorld.player.isInvulnerable){
mWorld.player.onEnemyCollision(this, Global.settings[("GAT_Config0" + DemoGame.level)].gnomeTouchPlayer);
mWorld.player.applyImpulse(((mWorld.player.x)<mX) ? -(mHitImpulseX) : mHitImpulseX, -(mHitImpulseY));
};
};
};
super.update(dt);
}
public function makeEffect():void{
DemoWorld(mWorld).effectManager.addEffect("fx_hit", mWorld, x, y);
}
public function clearBullets():void{
if (mBullets){
mBullets.clear();
};
}
public function kill():void{
if (mState != ST_DIE){
gotoState(ST_DIE);
mHasDied = true;
};
}
public function onEndAnimation(state:String):void{
switch (int(state)){
case ST_DIE:
mIsAwaitingDelete = true;
break;
};
}
override public function gotoState(state:int):void{
super.gotoState(state);
switch (state){
case ST_DIE:
Global.app.playSound("snd_AT_mc_gnome_die");
break;
};
}
override public function free():void{
clearBullets();
Global.app.stopSound("snd_AT_mc_gnome_fly");
super.free();
}
}
}//package com.bamtang.game.platformGame.enemys
Section 37
//GnomeEasy (com.bamtang.game.platformGame.enemys.GnomeEasy)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
import com.bamtang.swit.math.*;
import com.bamtang.swit.utils.*;
public class GnomeEasy extends Gnome {
private var mBezierSpeed:Number;
private var mDistanceToAttack:int;
private var mOldXMove:int;
private var mCountingDashes:int;// = 0
private var mTimesToDash:int;// = 3
private var mBezier:Bezier;
private var mSpeedGnomeEasy:Number;// = 0.2
private var mOldState:int;
private var mOldDash:int;
private var mStartingDash:int;
public static const ST_SHOOT:int = 104;
public static const ST_MOVE_RIGHT:int = 106;
public static const ST_DASH_RIGHT:int = 102;
public static const ST_DASH_LEFT:int = 101;
public static const ST_MOVE_LEFT:int = 107;
public static const ST_STAND:int = 103;
public static const ST_RETUN_POSITION:int = 108;
public function GnomeEasy(canvas:MovieClip, world:World, x:int, y:int){
var color:String;
super(canvas, world, x, y);
color = "_red";
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_MOVE_RIGHT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_MOVE_LEFT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DASH_LEFT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DASH_RIGHT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DIE), (("mc_gnome" + color) + "_die"));
mCharacter.addState(String(ST_SHOOT), (("mc_gnome" + color) + "_shoot"));
mCharacter.addState(String(ST_STAND), (("mc_gnome" + color) + "_stand"));
mCharacter.addState(String(ST_RETUN_POSITION), (("mc_gnome" + color) + "_fly"));
mCharacter.onEndAnimation = onEndAnimation;
gotoState(ST_STAND);
mOldState = ST_MOVE_RIGHT;
mBezierSpeed = Global.settings[("GAT_Config0" + DemoGame.level)].enemySpeed;
mDistanceToAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyDistanceToAttack * mWorld.sizeFactor);
mAltitude = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeVerticalMove * mWorld.sizeFactor);
mDistance = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeHorizontalMove * mWorld.sizeFactor);
mStandTime = Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeStandTime;
}
override public function free():void{
mBezier = null;
super.free();
}
override public function update(dt:int):void{
mCharacter.update(dt);
if (mBezier){
mBezier.update(dt);
};
switch (mState){
case ST_RETUN_POSITION:
if (mStartingDash != mOldDash){
gotoState(ST_STAND);
} else {
if (mStartingDash == ST_DASH_LEFT){
flipX = true;
x = (x + (mSpeedGnomeEasy * dt));
if (x >= (mOldXMove + mDistance)){
gotoState(ST_STAND);
};
} else {
if (mStartingDash == ST_DASH_RIGHT){
flipX = false;
x = (x - (mSpeedGnomeEasy * dt));
if (x <= (mOldXMove - mDistance)){
gotoState(ST_STAND);
};
};
};
};
break;
case ST_DASH_LEFT:
mOldDash = ST_DASH_LEFT;
if (mBezier.position){
mX = mBezier.position.x;
mY = mBezier.position.y;
};
if (mX <= mDestinationX){
mCountingDashes++;
if (mCountingDashes >= mTimesToDash){
gotoState(ST_RETUN_POSITION);
} else {
gotoState(ST_DASH_RIGHT);
};
};
break;
case ST_DASH_RIGHT:
mOldDash = ST_DASH_RIGHT;
if (mBezier.position){
mX = mBezier.position.x;
mY = mBezier.position.y;
};
if (mX >= mDestinationX){
mCountingDashes++;
if (mCountingDashes >= mTimesToDash){
gotoState(ST_RETUN_POSITION);
} else {
gotoState(ST_DASH_LEFT);
};
};
break;
case ST_STAND:
if (isNearEnemyThenAttack()){
break;
};
mTimer = (mTimer + dt);
if (mTimer >= mStandTime){
mTimer = 0;
if (mOldState == ST_MOVE_LEFT){
mDestinationX = (x + mDistance);
gotoState(ST_MOVE_RIGHT);
flipX = true;
} else {
if (mOldState == ST_MOVE_RIGHT){
mDestinationX = (x - mDistance);
gotoState(ST_MOVE_LEFT);
flipX = false;
};
};
};
break;
case ST_MOVE_LEFT:
x = (x - (mSpeedGnomeEasy * dt));
if (x <= mDestinationX){
gotoState(ST_STAND);
};
break;
case ST_MOVE_RIGHT:
x = (x + (mSpeedGnomeEasy * dt));
if (x >= mDestinationX){
gotoState(ST_STAND);
};
break;
};
super.update(dt);
}
private function isNearEnemyThenAttack(inState:int=-1):Boolean{
var dx:int = (mWorld.player.x - x);
var dy:int = (mWorld.player.y - y);
var distance:Number = Math.sqrt(((dx * dx) + (dy * dy)));
if (distance <= mDistanceToAttack){
if ((((((mWorld.camera.x < x)) && (((mWorld.camera.x + mWorld.camera.width) > x)))) && ((((mWorld.camera.y < y)) && (((mWorld.camera.y + mWorld.camera.height) > y)))))){
if (SMath.abs((mWorld.player.y - y)) <= mHeightCriteria){
if (inState == -1){
if (x > mWorld.player.x){
gotoState(ST_DASH_LEFT);
mStartingDash = ST_DASH_LEFT;
} else {
if (x < mWorld.player.x){
gotoState(ST_DASH_RIGHT);
mStartingDash = ST_DASH_RIGHT;
};
};
} else {
if (inState == ST_DASH_LEFT){
gotoState(ST_DASH_RIGHT);
} else {
if (inState == ST_DASH_RIGHT){
gotoState(ST_DASH_LEFT);
};
};
};
return (true);
};
};
};
return (false);
}
override public function onEndAnimation(state:String):void{
super.onEndAnimation(state);
}
override public function gotoState(state:int):void{
super.gotoState(state);
if (((!((state == ST_DASH_RIGHT))) && (!((state == ST_DASH_LEFT))))){
Global.app.stopSound("snd_AT_mc_gnome_fly");
};
switch (state){
case ST_MOVE_RIGHT:
mOldState = state;
break;
case ST_MOVE_LEFT:
mOldState = state;
break;
case ST_RETUN_POSITION:
mTimer = 0;
mOldXMove = x;
mCountingDashes = 0;
break;
case ST_DASH_LEFT:
flipX = false;
mDestinationX = (x - mDistance);
mBezier = new Bezier([new Point(x, y), new Point((x + (mDistance / 4)), (y + mAltitude)), new Point((x + (mDistance / 2)), (y + mAltitude)), new Point(mDestinationX, y)], mBezierSpeed);
Global.app.playSound("snd_AT_mc_gnome_fly");
break;
case ST_DASH_RIGHT:
flipX = true;
mDestinationX = (x + mDistance);
mBezier = new Bezier([new Point(x, y), new Point((x + (mDistance / 4)), (y + mAltitude)), new Point((x + (mDistance / 2)), (y + mAltitude)), new Point(mDestinationX, y)], mBezierSpeed);
Global.app.playSound("snd_AT_mc_gnome_fly");
break;
};
}
}
}//package com.bamtang.game.platformGame.enemys
Section 38
//GnomeMedium (com.bamtang.game.platformGame.enemys.GnomeMedium)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.swit.utils.*;
public class GnomeMedium extends Gnome {
private var mOldDirection:String;
private var mSpeedGnomeEasy:Number;// = 0.1
private var mDistanceToAttack:int;
private var mIntervalShoot:Interval;
private var mDirection:String;
private var mSpeedGnomeMedium:Number;// = 0.2
private var mCanShoot:Boolean;
private var mActualX:int;
public static const ST_SHOOT:int = 103;
public static const DIR_RIGHT:String = "RIGHT";
public static const ST_DASH_RIGHT:int = 106;
public static const ST_FLY:int = 101;
public static const ST_DASH_LEFT:int = 105;
public static const ST_STAND:int = 104;
public static const DIR_LEFT:String = "LEFT";
public function GnomeMedium(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, x, y);
var color:String = "_yellow";
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_FLY), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DASH_LEFT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DASH_RIGHT), (("mc_gnome" + color) + "_fly"));
mCharacter.addState(String(ST_DIE), (("mc_gnome" + color) + "_die"));
mCharacter.addState(String(ST_SHOOT), (("mc_gnome" + color) + "_shoot"));
mCharacter.addState(String(ST_STAND), (("mc_gnome" + color) + "_stand"));
mCharacter.onEndAnimation = onEndAnimation;
mBullets = new List();
mDirection = DIR_RIGHT;
gotoState(ST_STAND);
mCanShoot = true;
mDistanceToAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyDistanceToAttack * mWorld.sizeFactor);
mAltitude = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeVerticalMove * mWorld.sizeFactor);
mDistance = (Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeHorizontalMove * mWorld.sizeFactor);
mStandTime = Global.settings[("GAT_Config0" + DemoGame.level)].enemyGnomeStandTime;
}
override public function free():void{
super.free();
if (mIntervalShoot){
mIntervalShoot.free();
mIntervalShoot = null;
};
if (mBullets){
mBullets.free();
mBullets = null;
};
}
override public function update(dt:int):void{
var dx:int;
var dy:int;
var angle:Number;
mBullets.update(dt);
mBullets.iterate(checkBulletCollisionWithPlayer);
if (mIntervalShoot){
mIntervalShoot.update(dt);
};
switch (mState){
case ST_SHOOT:
if (mClip.currentFrame == 29){
dx = (mWorld.player.x - x);
dy = ((mWorld.player.y - (mWorld.player.clip.height / 2)) - y);
angle = (Math.atan2(dy, dx) * (180 / Math.PI));
mBullets.add(new Bullet("mc_gnome_bullet", mWorld, mX, (mY - ((mClip.height / 2) - 12)), Global.settings[("GAT_Config0" + DemoGame.level)].enemySpeedBullet, Global.settings[("GAT_Config0" + DemoGame.level)].enemyScoopeBullet, angle));
Global.app.playSound("snd_AT_mc_gnome_shoot");
};
break;
case ST_STAND:
if ((((((mWorld.camera.x < x)) && (((mWorld.camera.x + mWorld.camera.width) > x)))) && ((((mWorld.camera.y < y)) && (((mWorld.camera.y + mWorld.camera.height) > y)))))){
if (SMath.abs((mWorld.player.y - y)) <= mHeightCriteria){
attackPlayerByDistance();
};
};
mTimer = (mTimer + dt);
if (mTimer >= mStandTime){
mTimer = 0;
if (mDirection == DIR_RIGHT){
mFlipX = true;
} else {
mFlipX = false;
};
gotoState(ST_FLY);
};
break;
case ST_FLY:
if (mDirection == DIR_RIGHT){
mX = (mX + (mSpeedGnomeMedium * dt));
if (mX >= mDestinationX){
gotoState(ST_STAND);
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
} else {
if (mDirection == DIR_LEFT){
mX = (mX - (mSpeedGnomeMedium * dt));
if (mX <= mDestinationX){
gotoState(ST_STAND);
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
};
};
Global.app.playSound("snd_AT_mc_gnome_fly");
break;
};
super.update(dt);
}
override public function gotoState(state:int):void{
super.gotoState(state);
if (state != ST_FLY){
Global.app.stopSound("snd_AT_mc_gnome_fly");
};
switch (state){
case ST_FLY:
mActualX = mX;
mDestinationX = ((mDirection)==DIR_RIGHT) ? (mActualX + mDistance) : (mActualX - mDistance);
break;
};
}
override public function onEndAnimation(state:String):void{
super.onEndAnimation(state);
switch (int(state)){
case ST_DIE:
mIsAwaitingDelete = true;
break;
case ST_SHOOT:
gotoState(ST_STAND);
break;
};
}
private function attackPlayerByDistance():void{
var dx:int;
var dy:int;
var distance:int;
if (mCanShoot){
dx = (mWorld.player.x - x);
dy = (mWorld.player.y - y);
distance = Math.sqrt(((dx * dx) - (dy * dy)));
if (distance <= mDistanceToAttack){
if (mWorld.player.x < mX){
flipX = false;
} else {
flipX = true;
};
gotoState(ST_SHOOT);
mCanShoot = false;
mIntervalShoot = new Interval(enableToShoot, 2000);
};
};
}
public function enableToShoot():void{
mCanShoot = true;
}
private function checkBulletCollisionWithPlayer(bullet:Bullet, index:int):void{
if (!mWorld.player.isInvulnerable){
if (mWorld.player.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mWorld.player.onEnemyCollision(bullet, Global.settings[("GAT_Config0" + DemoGame.level)].gnomeBulletDamage);
};
};
}
}
}//package com.bamtang.game.platformGame.enemys
Section 39
//Ninja (com.bamtang.game.platformGame.enemys.Ninja)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
import com.bamtang.swit.utils.*;
public class Ninja extends PlatformActor {
private var mDistance:int;
private var mBullets:List;// = null
private var mCurrentX:int;
private var mOutTime:int;
private var mDifficulty:int;
private var mImpulseX:int;
private var mImpulseY:int;
private var mDirection:String;
private var mInterval:Interval;// = null
private var mMoveEndX:int;
private var mTimer:int;
private var mSpeedDF:Number;
private var mDistanceAttack:int;
public var mHasDied:Boolean;
private var mHeightCriteria:int;
private var mCanShoot:Boolean;
public var isEnemy:Boolean;// = true
public static const ST_SHOOT_2:int = 17;
public static const ST_DIE:int = 18;
public static const ST_STAND_1:int = 10;
public static const ST_STAND_2:int = 14;
public static const DIR_RIGHT:String = "RIGHT";
public static const ST_ALERT_1:int = 12;
public static const ST_ALERT_2:int = 16;
public static const ST_SHOOT_1:int = 13;
public static const ST_WALK_1:int = 11;
public static const ST_WALK_2:int = 15;
public static const DIR_LEFT:String = "LEFT";
public function Ninja(canvas:MovieClip, world:World, x:int, y:int, difficulty:int=0){
var rect:Rectangle;
rect = world.getMaxFloorRange(x, y, int((Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDistanceWalk * world.sizeFactor)));
super(canvas, world, null, rect.x, y);
mTimer = 0;
mFlipX = true;
mSpeedDF = 0.2;
mOutTime = Global.settings[("GAT_Config0" + DemoGame.level)].ninjaOutTimeStand;
mDistance = rect.width;
mHasDied = false;
mCanShoot = true;
mDifficulty = difficulty;
mCharacter = new Character(rect.x, rect.y, canvas);
mCharacter.addState(String(ST_STAND_1), "mc_ninja01_stand");
mCharacter.addState(String(ST_WALK_1), "mc_ninja01_walk");
mCharacter.addState(String(ST_ALERT_1), "mc_ninja01_alert");
mCharacter.addState(String(ST_SHOOT_1), "mc_ninja01_attack");
mCharacter.addState(String(ST_STAND_2), "mc_ninja02_stand");
mCharacter.addState(String(ST_WALK_2), "mc_ninja02_walk");
mCharacter.addState(String(ST_ALERT_2), "mc_ninja02_alert");
mCharacter.addState(String(ST_SHOOT_2), "mc_ninja02_attack");
mCharacter.addState(String(ST_DIE), "mc_ninja_die");
mCharacter.onEndAnimation = onEndAnimation;
mDirection = DIR_RIGHT;
if (mDifficulty != 0){
gotoState(ST_STAND_2);
mDistanceAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDistanceAttack_2 * mWorld.sizeFactor);
} else {
gotoState(ST_STAND_1);
mDistanceAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDistanceAttack_1 * mWorld.sizeFactor);
};
mBullets = new List();
mImpulseX = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseX;
mImpulseY = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseY;
mHeightCriteria = (Global.settings[("GAT_Config0" + DemoGame.level)].heightCriteria * mWorld.sizeFactor);
}
public function hitTest(actor:PlatformActor):Boolean{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersects(rb));
};
return (false);
}
public function clearBullets():void{
if (mBullets){
mBullets.clear();
};
}
override public function update(dt:int):void{
var shoot:ShootNinja;
if (mCharacter){
mCharacter.update(dt);
};
if (mInterval){
mInterval.update(dt);
};
switch (mState){
case ST_STAND_1:
case ST_STAND_2:
if ((((((mWorld.camera.x < x)) && (((mWorld.camera.x + mWorld.camera.width) > x)))) && ((((mWorld.camera.y < y)) && (((mWorld.camera.y + mWorld.camera.height) > y)))))){
if (SMath.abs((mWorld.player.y - y)) <= mHeightCriteria){
attackEnable();
};
};
mTimer = (mTimer + dt);
if (mTimer >= mOutTime){
mTimer = 0;
if (mDirection == DIR_RIGHT){
mFlipX = true;
} else {
mFlipX = false;
};
if (mDifficulty != 0){
gotoState(ST_WALK_2);
} else {
gotoState(ST_WALK_1);
};
};
break;
case ST_WALK_1:
case ST_WALK_2:
if (mDirection == DIR_RIGHT){
mX = (mX + (mSpeedDF * dt));
if (mX >= mMoveEndX){
if (mDifficulty != 0){
gotoState(ST_STAND_2);
} else {
gotoState(ST_STAND_1);
};
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
} else {
if (mDirection == DIR_LEFT){
mX = (mX - (mSpeedDF * dt));
if (mX <= mMoveEndX){
if (mDifficulty != 0){
gotoState(ST_STAND_2);
} else {
gotoState(ST_STAND_1);
};
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
};
};
break;
case ST_SHOOT_1:
createCorners();
if (mClip.currentFrame == 3){
Global.app.playSound("snd_AT_mc_ninja01_attack");
};
break;
case ST_SHOOT_2:
if (mClip.currentFrame == 13){
shoot = new ShootNinja("mc_ninja_star", mWorld, mX, (mY - 20), 0.4, (Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDistanceShoot * mWorld.sizeFactor), mFlipX);
mBullets.add(shoot);
Global.app.playSound("snd_AT_mc_ninja02_attack");
};
break;
};
DemoPlayer(world.player).onBulletCollision(this);
if (!mHasDied){
if (mWorld.player.hitTest(this)){
if (!mWorld.player.isInvulnerable){
mWorld.player.onEnemyCollision(this, Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDamage);
mWorld.player.applyImpulse(((mWorld.player.x)<mX) ? -(mImpulseX) : mImpulseX, -(mImpulseY));
};
};
if ((((mWorld.player.state == DemoPlayer.ST_PLAYER_PUNCH)) || ((mWorld.player.state == DemoPlayer.ST_PLAYER_PUNCH_JUMP)))){
if (DemoPlayer(mWorld.player).hitTestPunch(this)){
kill();
};
};
};
super.update(dt);
mBullets.update(dt);
mBullets.iterate(checkBulletCollisionWithPlayer);
}
private function checkBulletCollisionWithPlayer(bullet:ShootNinja, index:int):void{
if (!mWorld.player.isInvulnerable){
if (mWorld.player.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mWorld.player.onEnemyCollision(bullet, Global.settings[("GAT_Config0" + DemoGame.level)].ninjaDamageBullet);
};
};
}
public function kill():void{
if (mState != ST_DIE){
gotoState(ST_DIE);
mHasDied = true;
};
}
public function onEndAnimation(state:String):void{
switch (int(state)){
case ST_ALERT_1:
gotoState(ST_SHOOT_1);
break;
case ST_ALERT_2:
gotoState(ST_SHOOT_2);
break;
case ST_SHOOT_1:
gotoState(ST_STAND_1);
break;
case ST_SHOOT_2:
gotoState(ST_STAND_2);
break;
case ST_DIE:
mIsAwaitingDelete = true;
break;
};
}
override public function free():void{
super.free();
if (mInterval){
mInterval.free();
};
mInterval = null;
if (mBullets){
mBullets.free();
};
mBullets = null;
}
override public function gotoState(state:int):void{
super.gotoState(state);
switch (state){
case ST_WALK_1:
case ST_WALK_2:
mCurrentX = mX;
mMoveEndX = ((mDirection)==DIR_RIGHT) ? (mCurrentX + mDistance) : (mCurrentX - mDistance);
break;
case ST_DIE:
Global.app.playSound("snd_AT_mc_gnome_die");
break;
};
}
private function attackEnable():void{
var dx:int = (mWorld.player.x - x);
var dy:int = (mWorld.player.y - y);
var distance:int = Math.sqrt(((dx * dx) - (dy * dy)));
if ((((distance <= mDistanceAttack)) && (mCanShoot))){
if (mWorld.player.x < mX){
mFlipX = false;
} else {
mFlipX = true;
};
if (mDifficulty != 0){
gotoState(ST_ALERT_2);
} else {
gotoState(ST_ALERT_1);
};
mCanShoot = false;
mInterval = new Interval(activeShoot, 2000);
};
}
public function makeEffect():void{
DemoWorld(mWorld).effectManager.addEffect("fx_hit", mWorld, x, y, 1, null, mWorld.sizeFactor);
}
public function activeShoot():void{
mCanShoot = true;
}
}
}//package com.bamtang.game.platformGame.enemys
Section 40
//ShootNinja (com.bamtang.game.platformGame.enemys.ShootNinja)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.platform.*;
import com.bamtang.swit.utils.*;
public class ShootNinja extends PlatformActor {
private var mMove:Movement;// = null
public function ShootNinja(clipName:String, world:World, x:int, y:int, speed:Number, distance:Number, flip:Boolean){
super(world.objectsCanvas, world, clipName, x, y);
mMove = new Movement(speed, x, y);
if (flip){
mMove.gotoPosition((x + distance), y);
} else {
mMove.gotoPosition((x - distance), y);
};
mMove.onEndMove = onEndMove;
mClip.play();
mClip.scaleX = (mClip.scaleY = mWorld.sizeFactor);
}
override public function update(dt:int):void{
mMove.update(dt);
mX = mMove.x;
mY = mMove.y;
super.update(dt);
}
override public function free():void{
super.free();
mMove = null;
}
private function onEndMove():void{
mIsAwaitingDelete = true;
}
}
}//package com.bamtang.game.platformGame.enemys
Section 41
//SnowMonster (com.bamtang.game.platformGame.enemys.SnowMonster)
package com.bamtang.game.platformGame.enemys {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
import com.bamtang.swit.utils.*;
public class SnowMonster extends PlatformActor {
private var mDistance:int;
private var mDifficulty:int;
private var mBullets:List;// = null
private var mCurrentX:int;
private var mOutTime:int;
private var mImpulseY:int;
private var mDirection:String;
private var mHitActive:Boolean;
private var mImpulseX:int;
private var mCountRotate:int;
private var mSoundRollActive:Boolean;
private var mHP:int;
private var mCanShoot:Boolean;
private var mInterval:Interval;// = null
private var mSpeedRotate:Number;
private var mTimer:int;
private var mMoveEndX:int;
private var mSpeedDF:Number;
private var mEffect:EffectPlatform;
private var mTintMagnitude:Number;
private var mDistanceAttack:int;
private var mHeightCriteria:int;
public var mHasDied:Boolean;
public var isEnemy:Boolean;// = true
public static const ST_ROTATE:int = 20;
public static const DIR_LEFT:String = "LEFT";
public static const ST_HIT_1:int = 22;
public static const ST_HIT_2:int = 23;
public static const ST_STAND_1:int = 10;
public static const ST_STAND_2:int = 15;
public static const ST_DETRANSFORM:int = 19;
public static const ST_ALERT_1:int = 12;
public static const ST_ALERT_2:int = 17;
public static const ST_SHOOT_1:int = 13;
public static const ST_WALK_1:int = 11;
public static const ST_WALK_2:int = 16;
public static const ST_TRANSFORM:int = 21;
public static const DIR_RIGHT:String = "RIGHT";
public static const ST_DIE_2:int = 18;
public static const ST_DIE_1:int = 14;
public function SnowMonster(canvas:MovieClip, world:World, x:int, y:int, difficulty:int=0){
var rect:Rectangle = world.getMaxFloorRange(x, y, (Global.settings[("GAT_Config0" + DemoGame.level)].mostersDistanceWalk * world.sizeFactor));
super(canvas, world, null, rect.x, y);
mTimer = 0;
mFlipX = true;
mSpeedDF = 0.1;
mSpeedRotate = 0.4;
mOutTime = Global.settings[("GAT_Config0" + DemoGame.level)].mostersOutTimeStand;
mDistance = rect.width;
mHasDied = false;
mHitActive = false;
mSoundRollActive = false;
mCanShoot = true;
mCountRotate = 0;
mTintMagnitude = 1;
mCurrentX = mX;
mDifficulty = difficulty;
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_STAND_1), "mc_snowmonster02_stand");
mCharacter.addState(String(ST_WALK_1), "mc_snowmonster02_walk");
mCharacter.addState(String(ST_ALERT_1), "mc_snowmonster02_alert");
mCharacter.addState(String(ST_SHOOT_1), "mc_snowmonster02_shoot");
mCharacter.addState(String(ST_DIE_1), "mc_snowmonster02_die");
mCharacter.addState(String(ST_STAND_2), "mc_snowmonster01_stand");
mCharacter.addState(String(ST_WALK_2), "mc_snowmonster01_walk");
mCharacter.addState(String(ST_ALERT_2), "mc_snowmonster01_alert");
mCharacter.addState(String(ST_DIE_2), "mc_snowmonster01_die");
mCharacter.addState(String(ST_DETRANSFORM), "mc_snowmonster01_detransform");
mCharacter.addState(String(ST_ROTATE), "mc_snowmonster01_roll");
mCharacter.addState(String(ST_TRANSFORM), "mc_snowmonster01_transform");
mCharacter.onEndAnimation = onEndAnimation;
mDirection = DIR_RIGHT;
if (mDifficulty != 0){
gotoState(ST_STAND_2);
mDistanceAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].mostersDistanceAttack_2 * mWorld.sizeFactor);
} else {
gotoState(ST_STAND_1);
mDistanceAttack = (Global.settings[("GAT_Config0" + DemoGame.level)].mostersDistanceAttack_1 * mWorld.sizeFactor);
};
mBullets = new List();
mImpulseX = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseX;
mImpulseY = Global.settings[("GAT_Config0" + DemoGame.level)].playerHitImpulseY;
mHeightCriteria = (Global.settings[("GAT_Config0" + DemoGame.level)].heightCriteria * mWorld.sizeFactor);
mHP = Global.settings[("GAT_Config0" + DemoGame.level)].monsterHP;
}
private function checkBulletCollisionWithPlayer(bullet:ShootNinja, index:int):void{
if (!mWorld.player.isInvulnerable){
if (mWorld.player.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mWorld.player.onEnemyCollision(bullet, Global.settings[("GAT_Config0" + DemoGame.level)].mostersDamageBullet);
};
};
}
private function onRedCharacter():void{
if (mTintMagnitude == 1){
Common.tint(mClip, mTintMagnitude, 0, 0, 0.5);
} else {
if (mTintMagnitude == 0){
Common.tint(mClip);
};
};
mTintMagnitude = ((mTintMagnitude)==1) ? 0 : 1;
}
public function makeEffect():void{
DemoWorld(mWorld).effectManager.addEffect("fx_hit", mWorld, x, y, 1, null, mWorld.sizeFactor);
}
public function stopSound():void{
Global.app.stopSound("snd_AT_mc_snowmonster_roll");
}
private function finishAnimation():void{
mClip.visible = true;
mEffect = null;
}
public function activeShoot():void{
mCanShoot = true;
}
public function hitTest(actor:PlatformActor):Boolean{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersects(rb));
};
return (false);
}
public function clearBullets():void{
if (mBullets){
mBullets.clear();
};
}
override public function update(dt:int):void{
var adjust:Number;
var shoot:ShootNinja;
if (mCharacter){
mCharacter.update(dt);
};
if (mInterval){
mInterval.update(dt);
};
if (mBullets){
mBullets.update(dt);
mBullets.iterate(checkBulletCollisionWithPlayer);
};
if (mEffect){
return;
};
switch (mState){
case ST_STAND_1:
case ST_STAND_2:
if ((((((mWorld.camera.x < x)) && (((mWorld.camera.x + mWorld.camera.width) > x)))) && ((((mWorld.camera.y < y)) && (((mWorld.camera.y + mWorld.camera.height) > y)))))){
if (SMath.abs((mWorld.player.y - y)) <= mHeightCriteria){
attackEnable();
};
};
mTimer = (mTimer + dt);
if (mTimer >= mOutTime){
mTimer = 0;
if (mDirection == DIR_RIGHT){
mFlipX = true;
} else {
mFlipX = false;
};
if (mDifficulty != 0){
gotoState(ST_WALK_2);
} else {
gotoState(ST_WALK_1);
};
};
break;
case ST_WALK_1:
case ST_WALK_2:
if (mDirection == DIR_RIGHT){
mX = (mX + (mSpeedDF * dt));
if (mX >= mMoveEndX){
if (mDifficulty != 0){
gotoState(ST_STAND_2);
} else {
gotoState(ST_STAND_1);
};
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
} else {
if (mDirection == DIR_LEFT){
mX = (mX - (mSpeedDF * dt));
if (mX <= mMoveEndX){
if (mDifficulty != 0){
gotoState(ST_STAND_2);
} else {
gotoState(ST_STAND_1);
};
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
};
};
break;
case ST_SHOOT_1:
if (mClip.currentFrame == 20){
adjust = (mX - 50);
if (mFlipX){
adjust = (mX + 50);
};
shoot = new ShootNinja("mc_snowmonster_snowball", mWorld, adjust, (mY - 20), 0.4, (Global.settings[("GAT_Config0" + DemoGame.level)].mostersDistanceShoot * mWorld.sizeFactor), mFlipX);
mBullets.add(shoot);
Global.app.playSound("snd_AT_mc_gnome_shoot");
};
break;
case ST_ROTATE:
activeAttackRotate(dt);
break;
};
if (mState != ST_ROTATE){
DemoPlayer(world.player).onBulletCollision(this);
};
if (!mHasDied){
if (mWorld.player.hitTest(this)){
if (!mWorld.player.isInvulnerable){
mWorld.player.onEnemyCollision(this, Global.settings[("GAT_Config0" + DemoGame.level)].mostersDamage);
mWorld.player.applyImpulse(((mWorld.player.x)<mX) ? -(mImpulseX) : mImpulseX, -(mImpulseY));
};
};
if ((((mWorld.player.state == DemoPlayer.ST_PLAYER_PUNCH)) || ((mWorld.player.state == DemoPlayer.ST_PLAYER_PUNCH_JUMP)))){
if (mState != ST_ROTATE){
if (DemoPlayer(mWorld.player).hitTestPunch(this)){
kill();
};
};
};
};
super.update(dt);
}
private function onHitted():void{
var hitState:String = "";
mHP--;
if (mHP <= 0){
if (mDifficulty != 0){
if (mState != ST_DIE_2){
gotoState(ST_DIE_2);
mHasDied = true;
};
} else {
if (mState != ST_DIE_1){
gotoState(ST_DIE_1);
mHasDied = true;
};
};
} else {
if (mDifficulty != 0){
hitState = "mc_snowmonster01_hit";
} else {
hitState = "mc_snowmonster02_hit";
};
mClip.visible = false;
mEffect = DemoWorld(world).effectManager.addEffect(hitState, world, mX, mY);
mEffect.onEndAnimation = finishAnimation;
mEffect.clip.scaleX = mClip.scaleX;
mEffect.clip.scaleY = mClip.scaleY;
mHitActive = true;
};
}
public function kill():void{
if (DemoPlayer.instance.state == DemoPlayer.ST_PLAYER_BOMB){
mHP = 0;
};
onHitted();
}
private function activeAttackRotate(dt:int):void{
if (mDirection == DIR_RIGHT){
mX = (mX + (mSpeedRotate * dt));
if (mX >= mMoveEndX){
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
if (mDirection == DIR_RIGHT){
mFlipX = true;
} else {
mFlipX = false;
};
if (mCountRotate == 1){
mCountRotate = 0;
Global.app.stopSound("snd_AT_mc_snowmonster_roll");
gotoState(ST_DETRANSFORM);
} else {
Global.app.stopSound("snd_AT_mc_snowmonster_roll");
Global.app.playSound("snd_AT_mc_snowmonster_roll");
gotoState(ST_ROTATE);
mCountRotate++;
};
};
} else {
if (mDirection == DIR_LEFT){
mX = (mX - (mSpeedRotate * dt));
if (mX <= mMoveEndX){
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
if (mDirection == DIR_RIGHT){
mFlipX = true;
} else {
mFlipX = false;
};
Global.app.stopSound("snd_AT_mc_snowmonster_roll");
Global.app.playSound("snd_AT_mc_snowmonster_roll");
gotoState(ST_ROTATE);
};
};
};
}
private function attackEnable():void{
var dx:int = (mWorld.player.x - x);
var dy:int = (mWorld.player.y - y);
var distance:int = Math.sqrt(((dx * dx) - (dy * dy)));
if ((((distance <= mDistanceAttack)) && (mCanShoot))){
if (mWorld.player.x < mX){
mFlipX = false;
} else {
mFlipX = true;
};
if (mDifficulty != 0){
gotoState(ST_ALERT_2);
} else {
gotoState(ST_ALERT_1);
};
mCanShoot = false;
mInterval = new Interval(activeShoot, 2000);
};
}
override public function free():void{
super.free();
stopSound();
if (mInterval){
mInterval.free();
};
mInterval = null;
clearBullets();
mBullets = null;
}
override public function gotoState(state:int):void{
super.gotoState(state);
switch (state){
case ST_STAND_1:
case ST_STAND_2:
mHitActive = false;
break;
case ST_TRANSFORM:
Global.app.playSound("snd_AT_mc_snowmonster_transform");
break;
case ST_DETRANSFORM:
Global.app.playSound("snd_AT_mc_snowmonster_detransform");
break;
case ST_WALK_1:
case ST_WALK_2:
if (!mHitActive){
mCurrentX = mX;
mMoveEndX = ((mDirection)==DIR_RIGHT) ? (mCurrentX + mDistance) : (mCurrentX - mDistance);
} else {
mDirection = ((mDirection)==DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
};
break;
case ST_ROTATE:
mCurrentX = mX;
mMoveEndX = ((mDirection)==DIR_RIGHT) ? (mCurrentX + mDistance) : (mCurrentX - mDistance);
break;
case ST_DIE_1:
case ST_DIE_2:
Global.app.playSound("snd_AT_mc_snowmonster_die");
break;
};
}
public function onEndAnimation(state:String):void{
switch (int(state)){
case ST_ALERT_1:
gotoState(ST_SHOOT_1);
break;
case ST_ALERT_2:
gotoState(ST_TRANSFORM);
break;
case ST_TRANSFORM:
Global.app.stopSound("snd_AT_mc_snowmonster_roll");
Global.app.playSound("snd_AT_mc_snowmonster_roll");
gotoState(ST_ROTATE);
break;
case ST_DETRANSFORM:
gotoState(ST_STAND_2);
break;
case ST_HIT_1:
gotoState(ST_WALK_1);
break;
case ST_HIT_2:
gotoState(ST_WALK_2);
break;
case ST_DIE_1:
case ST_DIE_2:
mIsAwaitingDelete = true;
break;
case ST_SHOOT_1:
gotoState(ST_STAND_1);
break;
};
}
}
}//package com.bamtang.game.platformGame.enemys
Section 42
//Spine (com.bamtang.game.platformGame.enemys.Spine)
package com.bamtang.game.platformGame.enemys {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
public class Spine extends PlatformActor {
private var mFromUp:Boolean;
private var mImpX:int;
private var mImpY:int;
public function Spine(canvas:MovieClip, world:World, x:int, y:int, width:int, fromUp:Boolean=true){
super(canvas, world, "mcSpien2", x, y);
mClip.width = (mClip["mcCollision"].width = (width * world.sizeFactor));
createCorners();
mClip["mcCollision"].alpha = 0;
mFromUp = fromUp;
mImpX = Global.settings[("GAT_Config0" + DemoGame.level)].enemySpineImpulseX;
mImpY = Global.settings[("GAT_Config0" + DemoGame.level)].enemySpineImpulseY;
}
override public function update(dt:int):void{
var fx:int;
if (!mWorld.player.isInvulnerable){
if (((mWorld.player.hitTest(this)) && (!((DemoPlayer(mWorld.player).state == Player.ST_PLAYER_LOSE))))){
fx = ((mWorld.player.x > x)) ? mImpX : -(mImpX);
if (mFromUp){
mWorld.player.applyImpulse(mImpX, -(mImpY));
} else {
mWorld.player.applyImpulse(mImpX, mImpY);
};
mWorld.player.onEnemyCollision(this, Global.settings[("GAT_Config0" + DemoGame.level)].enemySpineDamage);
};
};
super.update(dt);
}
}
}//package com.bamtang.game.platformGame.enemys
Section 43
//Bat (com.bamtang.game.platformGame.objects.Bat)
package com.bamtang.game.platformGame.objects {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.swit.platform.*;
import com.bamtang.swit.utils.*;
public class Bat extends PlatformActor {
private var mSineWaveValue:Number;
private var mBatSpeed:Number;
private var mSineWaveIncremention:Number;
private var mAcceleration:Number;
private var mDistanceToActivate:int;
private var mDirection:int;
private var mSineWaveDirection:int;
private var mBatSpeedInY:Number;
private var mDisable:Boolean;
private var mTopSpeed:Number;
private static const ST_FLY:int = 3;
private static const ST_STAND:int = 1;
private static const ST_ALERTED:int = 2;
public function Bat(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_STAND), "AT_bat_stand");
mCharacter.addState(String(ST_ALERTED), "AT_bat_alerted");
mCharacter.addState(String(ST_FLY), "AT_bat_fly");
mCharacter.onEndAnimation = onEndAnimation;
if ((mDirection = Math.round(SMath.random(1, 2))) == 1){
flipX = true;
} else {
flipX = false;
};
gotoState(ST_STAND);
mScale = 1;
mDisable = true;
mBatSpeed = randomDecimals(0.065, 0.12);
mTopSpeed = randomDecimals(0.35, 0.65);
mBatSpeedInY = randomDecimals(0.1, 0.3);
mAcceleration = randomDecimals(0.006, 0.014);
mSineWaveValue = 0;
mDistanceToActivate = 250;
mSineWaveIncremention = randomDecimals(0.3, 0.6);
mSineWaveDirection = Math.round(SMath.random(1, 2));
}
public function onEndAnimation(state:String):void{
if (state == String(ST_ALERTED)){
gotoState(ST_FLY);
};
}
override public function update(dt:int):void{
mCharacter.update(dt);
if (!mDisable){
switch (mState){
case ST_FLY:
if (mBatSpeed < mTopSpeed){
mBatSpeed = (mBatSpeed + mAcceleration);
};
if (mDirection == 1){
x = (x + (mBatSpeed * dt));
} else {
x = (x - (mBatSpeed * dt));
};
y = (y + Math.sin(mSineWaveValue));
if (mSineWaveDirection == 1){
mSineWaveValue = (mSineWaveValue + mSineWaveIncremention);
} else {
mSineWaveValue = (mSineWaveValue - mSineWaveIncremention);
};
if (SMath.abs((mWorld.player.x - x)) > (Application.APP_WIDTH * mWorld.sizeFactor)){
mIsAwaitingDelete = true;
};
break;
case ST_ALERTED:
if (mClip.currentFrame > 9){
y = (y + (mBatSpeedInY * dt));
};
break;
};
} else {
if ((((((mWorld.camera.x < x)) && (((mWorld.camera.x + mWorld.camera.width) > x)))) && ((((mWorld.camera.y < y)) && (((mWorld.camera.y + mWorld.camera.height) > y)))))){
if (SMath.abs((mWorld.player.x - x)) < mDistanceToActivate){
mDisable = false;
gotoState(ST_ALERTED);
};
};
};
super.update(dt);
}
private function randomDecimals(min:Number, max:Number):Number{
var rnd:Number = (Math.random() * max);
return (((rnd)<min) ? min : rnd);
}
}
}//package com.bamtang.game.platformGame.objects
Section 44
//BookFinish (com.bamtang.game.platformGame.objects.BookFinish)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
public class BookFinish extends PlatformActor {
public const ST_ITEM_STAND:int = 101;
public function BookFinish(canvas:MovieClip, world:World, x:int, y:int, id:int){
var name:String;
super(canvas, world, null, x, y);
switch (DemoGame.level){
case 1:
name = "mcBook";
break;
case 2:
name = "mcHousekeys";
break;
case 3:
name = "mcIceKingHead";
break;
};
mClip = Global.app.getClip(name);
canvas.addChild(mClip);
mClip.x = x;
mClip.y = y;
mClip.scaleX = (mClip.scaleY = world.sizeFactor);
createCorners();
}
override public function update(dt:int):void{
super.update(dt);
if (DemoGame.level == 3){
mClip.visible = false;
};
if (mWorld.player.hitTest(this)){
mWorld.player.resetControl();
mWorld.player.gotoState(Player.ST_PLAYER_WIN);
};
}
override public function free():void{
super.free();
mCanvas = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.objects
Section 45
//Flag (com.bamtang.game.platformGame.objects.Flag)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
public class Flag extends PlatformActor {
private var mCheckPointReached:Boolean;
public static var FLAGS_GRABBED:Array;
public function Flag(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mClip = Global.app.getClip("mc_flag");
canvas.addChild(mClip);
mClip.x = x;
mClip.y = y;
mClip.gotoAndStop("off");
mClip.scaleX = (mClip.scaleY = world.sizeFactor);
createCorners();
mCheckPointReached = false;
if (FLAGS_GRABBED == null){
FLAGS_GRABBED = new Array();
};
if (FLAGS_GRABBED[String(x)] == null){
FLAGS_GRABBED[String(x)] = false;
} else {
if (FLAGS_GRABBED[String(x)] == true){
mClip.gotoAndStop("on");
mCheckPointReached = true;
};
};
}
override public function update(dt:int):void{
if (!mCheckPointReached){
if (mWorld.player.hitTest(this)){
FLAGS_GRABBED[String(x)] = true;
mClip.gotoAndStop("transition");
Global.app.playSound("snd_AT_checkpoint");
mCheckPointReached = true;
DemoWorld(mWorld).positionToRevive.x = mWorld.player.x;
DemoWorld(mWorld).positionToRevive.y = mWorld.player.y;
};
};
super.update(dt);
}
}
}//package com.bamtang.game.platformGame.objects
Section 46
//Gummys (com.bamtang.game.platformGame.objects.Gummys)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.swit.platform.*;
public class Gummys extends PlatformActor {
public function Gummys(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mClip = Global.app.getClip("AT_GummyGroup");
canvas.addChild(mClip);
mScale = world.sizeFactor;
}
}
}//package com.bamtang.game.platformGame.objects
Section 47
//Items (com.bamtang.game.platformGame.objects.Items)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.gui.*;
public class Items extends PlatformActor {
private var mFrame:int;
private var mEnable:Boolean;
public static const ST_ITEM_FADING:int = 101;
public static const FR_EXTRA_HP:int = 5;
public static const FR_FLAG_FLY:int = 55;
public static const FR_1UP:int = 20;
public static const FR_HP:int = 1;
public static const FR_EXTRA_POWER:int = 15;
public static const FR_FLAG_LEGS:int = 50;
public static const ST_ITEM_STAND:int = 100;
public static const FR_DIAMOND_SMALL:int = 40;
public static const FR_CARD:int = 25;
public static const FR_DIAMOND_BIG:int = 45;
public static const FR_DIAMOND_MEDIUM:int = 35;
public static const FR_SHOES_SNOW:int = 60;
public static const FR_POWER:int = 10;
public static var FLAG_FLY_GRABBED:Boolean = false;
public static var CARD_GRABBED:int = 0;
public static var FLAG_LEGS_GRABBED:Boolean = false;
public function Items(canvas:MovieClip, world:World, x:int, y:int, id:int){
super(canvas, world, null, x, y);
mClip = Global.app.getClip("mc_items");
canvas.addChild(mClip);
mClip.x = x;
mClip.y = y;
mState = ST_ITEM_STAND;
switch (id){
case ActorManager.ITEM_HP:
mFrame = FR_HP;
break;
case ActorManager.ITEM_EXTRA_HP:
mFrame = FR_EXTRA_HP;
break;
case ActorManager.ITEM_POWER:
mFrame = FR_POWER;
break;
case ActorManager.ITEM_EXTRA_POWER:
mFrame = FR_EXTRA_POWER;
break;
case ActorManager.ITEM_1UP:
mFrame = FR_1UP;
break;
case ActorManager.ITEM_CARD:
mFrame = FR_CARD;
break;
case ActorManager.ITEM_DIAMOND_SMALL:
mFrame = FR_DIAMOND_SMALL;
break;
case ActorManager.ITEM_DIAMOND_MEDIUM:
mFrame = FR_DIAMOND_MEDIUM;
break;
case ActorManager.ITEM_DIAMOND_BIG:
mFrame = FR_DIAMOND_BIG;
break;
case ActorManager.ITEM_FLAG_FLY:
mFrame = FR_FLAG_FLY;
break;
case ActorManager.ITEM_FLAG_LEGS:
mFrame = FR_FLAG_LEGS;
break;
case ActorManager.ITEM_SNOW_SHOES:
mFrame = FR_SHOES_SNOW;
break;
};
mClip.gotoAndStop(mFrame);
mClip.scaleX = (mClip.scaleY = mWorld.sizeFactor);
createCorners();
mEnable = true;
}
public function enableItem(state:Boolean):void{
mClip.visible = (mEnable = state);
}
override public function update(dt:int):void{
var i:int;
if (mEnable){
super.update(dt);
switch (mState){
case ST_ITEM_STAND:
if (mWorld.player.hitTest(this)){
switch (mFrame){
case FR_FLAG_LEGS:
if (!FLAG_LEGS_GRABBED){
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_STRETCH) != DemoGame.GPP_STRETCH){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupStrech, "mcGuiPopupStrech");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_STRETCH);
};
FLAG_LEGS_GRABBED = true;
};
DemoPlayer(world.player).setAction(DemoPlayer.ACT_LEGS);
break;
case FR_FLAG_FLY:
if (!FLAG_FLY_GRABBED){
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_FLY) != DemoGame.GPP_FLY){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupFly, "mcGuiPopupFly");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_FLY);
};
FLAG_FLY_GRABBED = true;
};
DemoPlayer(world.player).setAction(DemoPlayer.ACT_FLIGHT);
break;
case FR_POWER:
DemoPlayer(mWorld.player).setEnergy(1);
Global.app.playSound("snd_AT_mc_iconpower");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_EXTRA_POWER:
DemoPlayer(mWorld.player).setEnergy(3);
Global.app.playSound("snd_AT_mc_iconextrapower");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_CARD:
CARD_GRABBED++;
if (CARD_GRABBED == 1){
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_FIVECARDS) != DemoGame.GPP_FIVECARDS){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupFiveCards, "mcGuiPopupfivecards");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_FIVECARDS);
};
} else {
if (CARD_GRABBED == 5){
Global.app.playSound("snd_Jake_WayToGoBuddy");
i = 0;
while (i < DemoWorld(mWorld).objectManager.actors.length) {
if ((DemoWorld(mWorld).objectManager.actors[i] is SwordInStone)){
DemoWorld(mWorld).objectManager.actors[i].activateStone();
break;
};
i++;
};
};
};
mWorld.game.score = (mWorld.game.score + Global.settings[("GAT_Config0" + DemoGame.level)].smallDiamondScore);
DemoPlayer(mWorld.player).setItemCollectible(1);
Global.app.playSound("snd_AT_mc_iconcard");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_SHOES_SNOW:
Global.app.playSound("snd_AT_mc_diamond01");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_SHOES) != DemoGame.GPP_SHOES){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupShoes, "mcGuiPopupShoes");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_SHOES);
};
break;
case FR_DIAMOND_SMALL:
DemoGame.DIAMONDS_COLLECTED++;
mWorld.game.score = (mWorld.game.score + Global.settings[("GAT_Config0" + DemoGame.level)].smallDiamondScore);
Global.app.playSound("snd_AT_mc_diamond02");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_DIAMOND_MEDIUM:
DemoGame.DIAMONDS_MEDIUM_COLLECTED++;
mWorld.game.score = (mWorld.game.score + Global.settings[("GAT_Config0" + DemoGame.level)].mediumDiamondScore);
Global.app.playSound("snd_AT_mc_diamond03");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_DIAMOND_BIG:
mWorld.game.score = (mWorld.game.score + Global.settings[("GAT_Config0" + DemoGame.level)].bigDiamondScore);
Global.app.playSound("snd_AT_mc_diamond01");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_HP:
DemoPlayer(mWorld.player).setHealth(Global.settings[("GAT_Config0" + DemoGame.level)].itemHPValue);
Global.app.playSound("snd_AT_mc_iconhp");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y);
mWorld.sizeFactor;
break;
case FR_EXTRA_HP:
DemoPlayer(mWorld.player).setHealth(Global.settings[("GAT_Config0" + DemoGame.level)].itemExtraHPValue);
Global.app.playSound("snd_AT_mc_iconextrahp");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
case FR_1UP:
DemoGame(Global.game).addLife(1);
Global.app.playSound("snd_Finn_Yeah");
Global.app.playSound("snd_AT_mc_icon1up");
mState = ST_ITEM_FADING;
DemoWorld(mWorld).effectManager.addEffect("fx_item", mWorld, x, y, 1, null, mWorld.sizeFactor);
break;
};
};
break;
case ST_ITEM_FADING:
mClip.alpha = (mClip.alpha - (0.0015 * dt));
mY = (mY - (0.25 * dt));
if (mClip.alpha < 0.05){
mIsAwaitingDelete = true;
};
break;
};
};
}
public function get type():int{
return (mFrame);
}
override public function free():void{
super.free();
mCanvas = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.objects
Section 48
//Key (com.bamtang.game.platformGame.objects.Key)
package com.bamtang.game.platformGame.objects {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.gui.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.door.*;
public class Key extends PlatformActor {
private var mInterval:Interval;
private var mType:int;
private static const KEY_BLUE_BW:uint = 2;
private static const KEY_RED_BW:uint = 1;
public static const ST_DISAPPEAR:int = 102;
public static const KEY_RED:int = 1;
public static const ST_STAND:int = 101;
public static const KEY_BLUE:int = 0;
public function Key(canvas:MovieClip, world:World, x:int, y:int, type:int){
super(canvas, world, null, x, y);
mType = type;
mCharacter = new Character(x, y, canvas);
switch (type){
case KEY_RED:
mCharacter.addState(String(ST_STAND), "mc_AT_keypersonB_stand");
mCharacter.addState(String(ST_DISAPPEAR), "mc_AT_keypersonB_key");
break;
case KEY_BLUE:
mCharacter.addState(String(ST_STAND), "mc_AT_keypersonA_stand");
mCharacter.addState(String(ST_DISAPPEAR), "mc_AT_keypersonA_key");
break;
};
mCharacter.onEndAnimation = onEndAnimation;
gotoState(ST_STAND);
}
private function checkDoor():void{
mInterval.free();
mInterval = null;
mIsAwaitingDelete = true;
if (mType == KEY_RED){
DemoGame(Global.game).doorManager.doorOpen(Door.DR_RED);
} else {
if (mType == KEY_BLUE){
DemoGame(Global.game).doorManager.doorOpen(Door.DR_BLUE);
};
};
}
private function onEndAnimation(state:String):void{
switch (int(state)){
case ST_DISAPPEAR:
mIsAwaitingDelete = true;
Global.app.playSound("snd_AT_magic_key");
break;
};
}
override public function update(dt:int):void{
mCharacter.update(dt);
if (mInterval){
mInterval.update(dt);
};
if (mState == ST_STAND){
if (mWorld.player.hitTest(this)){
gotoState(ST_DISAPPEAR);
if (mType == KEY_RED){
DemoGame(Global.game).doorManager.activateDoor(Door.DR_RED);
GuiHud.instance.offRedKey();
} else {
if (mType == KEY_BLUE){
DemoGame(Global.game).doorManager.activateDoor(Door.DR_BLUE);
GuiHud.instance.offBlueKey();
};
};
};
};
super.update(dt);
}
override public function free():void{
super.free();
}
}
}//package com.bamtang.game.platformGame.objects
Section 49
//Penguin (com.bamtang.game.platformGame.objects.Penguin)
package com.bamtang.game.platformGame.objects {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.swit.platform.*;
public class Penguin extends PlatformActor {
private static const ST_GOTO_LEFT:int = 3;
private static const ST_STAND_RIGHT:int = 2;
private static const ST_GOTO_RIGHT:int = 4;
private static const ST_STAND_LEFT:int = 1;
public function Penguin(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_STAND_LEFT), "AT_penguin_turnL_stand");
mCharacter.addState(String(ST_STAND_RIGHT), "AT_penguin_turnR_stand");
mCharacter.addState(String(ST_GOTO_LEFT), "AT_penguins_turnL");
mCharacter.addState(String(ST_GOTO_RIGHT), "AT_penguins_turnR");
mCharacter.onEndAnimation = onEndAnimation;
mScale = 1;
gotoState(ST_STAND_LEFT);
}
public function onEndAnimation(state:String):void{
if (state == String(ST_GOTO_LEFT)){
gotoState(ST_STAND_LEFT);
} else {
if (state == String(ST_GOTO_RIGHT)){
gotoState(ST_STAND_RIGHT);
};
};
}
override public function update(dt:int):void{
mCharacter.update(dt);
switch (mState){
case ST_STAND_LEFT:
if (mWorld.player.x > x){
gotoState(ST_GOTO_RIGHT);
};
break;
case ST_STAND_RIGHT:
if (mWorld.player.x < x){
gotoState(ST_GOTO_LEFT);
};
break;
};
super.update(dt);
}
}
}//package com.bamtang.game.platformGame.objects
Section 50
//SecretDoor (com.bamtang.game.platformGame.objects.SecretDoor)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
public class SecretDoor extends PlatformActor {
private var mHitted:Boolean;
public function SecretDoor(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, "mcSecretDoor", x, y);
mHitted = false;
}
override public function update(dt:int):void{
if (!mHitted){
if (mWorld.player.hitTest(this)){
if (DemoGame.level == 1){
mWorld.player.setPosition(12000, 1000);
};
mHitted = true;
};
};
super.update(dt);
}
}
}//package com.bamtang.game.platformGame.objects
Section 51
//SpringHigh (com.bamtang.game.platformGame.objects.SpringHigh)
package com.bamtang.game.platformGame.objects {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.gui.*;
public class SpringHigh extends PlatformActor {
public static const ST_SPRING_STAND:int = 100;
public static const ST_SPRING_RELEASE:int = 101;
public function SpringHigh(canvas:MovieClip, world:World, x:int, y:int){
y = (world.getFloorCollision(x, y).y - 30);
super(canvas, world, null, x, y);
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_SPRING_STAND), (("AT_gum_lvl0" + DemoGame.level) + "_stand"));
mCharacter.addState(String(ST_SPRING_RELEASE), (("AT_gum_lvl0" + DemoGame.level) + "_jump"));
mCharacter.onEndAnimation = onEndAnimation;
gotoState(ST_SPRING_STAND);
}
public function onEndAnimation(state:String):void{
if (String(ST_SPRING_RELEASE) == state){
gotoState(ST_SPRING_STAND);
};
}
override public function update(dt:int):void{
switch (mState){
case ST_SPRING_STAND:
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_USESPRINGS) != DemoGame.GPP_USESPRINGS){
if (mWorld.player.hitTest(this)){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupUsesprings, "mcGuiPopupUsesprings");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_USESPRINGS);
};
};
if (((((!((mState == ST_SPRING_RELEASE))) && (mWorld.player.hitTest(this)))) && (DemoPlayer(mWorld.player).isJumpingDown))){
Global.app.playSound("snd_AT_spring");
mWorld.player.onSpringCollision((Global.settings[("GAT_Config0" + DemoGame.level)].springJumpSpeedHigh * (mWorld.sizeFactor + 0.1)));
gotoState(ST_SPRING_RELEASE);
};
break;
case ST_SPRING_RELEASE:
mCharacter.update(dt);
break;
};
super.update(dt);
}
override public function free():void{
mCharacter.actor.free();
mCharacter.free();
mCharacter = null;
mCanvas = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.objects
Section 52
//SpringLow (com.bamtang.game.platformGame.objects.SpringLow)
package com.bamtang.game.platformGame.objects {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.gui.*;
public class SpringLow extends PlatformActor {
public static const ST_SPRING_STAND:int = 100;
public static const ST_SPRING_RELEASE:int = 101;
public function SpringLow(canvas:MovieClip, world:World, x:int, y:int){
y = (world.getFloorCollision(x, y).y - 30);
super(canvas, world, null, x, y);
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_SPRING_STAND), (("AT_gum_lvl0" + DemoGame.level) + "_stand"));
mCharacter.addState(String(ST_SPRING_RELEASE), (("AT_gum_lvl0" + DemoGame.level) + "_jump"));
mCharacter.onEndAnimation = onEndAnimation;
gotoState(ST_SPRING_STAND);
}
public function onEndAnimation(state:String):void{
if (String(ST_SPRING_RELEASE) == state){
gotoState(ST_SPRING_STAND);
};
}
override public function update(dt:int):void{
switch (mState){
case ST_SPRING_STAND:
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_USESPRINGS) != DemoGame.GPP_USESPRINGS){
if (mWorld.player.hitTest(this)){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupUsesprings, "mcGuiPopupUsesprings");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_USESPRINGS);
};
};
if (((((!((mState == ST_SPRING_RELEASE))) && (mWorld.player.hitTest(this)))) && (DemoPlayer(mWorld.player).isJumpingDown))){
Global.app.playSound("snd_AT_spring");
mWorld.player.onSpringCollision((Global.settings[("GAT_Config0" + DemoGame.level)].springJumpSpeedLow * (mWorld.sizeFactor + 0.1)));
gotoState(ST_SPRING_RELEASE);
};
break;
case ST_SPRING_RELEASE:
mCharacter.update(dt);
break;
};
super.update(dt);
}
override public function free():void{
mCharacter.actor.free();
mCharacter.free();
mCharacter = null;
mCanvas = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.objects
Section 53
//SwordInStone (com.bamtang.game.platformGame.objects.SwordInStone)
package com.bamtang.game.platformGame.objects {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import com.bamtang.swit.platform.*;
public class SwordInStone extends PlatformActor {
public const ST_ITEM_STAND:int = 101;
private var mStoneActivated:Boolean;
private var mAlreadyUsed:Boolean;
public function SwordInStone(canvas:MovieClip, world:World, x:int, y:int){
super(canvas, world, null, x, y);
mClip = Global.app.getClip("mcSwordInStone");
canvas.addChild(mClip);
mClip.x = x;
mClip.y = y;
mClip.gotoAndStop(DemoGame.level);
mClip.scaleX = (mClip.scaleY = world.sizeFactor);
createCorners();
mAlreadyUsed = false;
mClip.alpha = 0.5;
mStoneActivated = false;
}
public function activateStone():void{
mClip.alpha = 1;
mStoneActivated = true;
}
override public function update(dt:int):void{
super.update(dt);
if (!mAlreadyUsed){
if (((mStoneActivated) && ((Items.CARD_GRABBED == 5)))){
if (((mWorld.player.hitTest(this)) && ((mClip.alpha == 1)))){
mAlreadyUsed = true;
mWorld.player.gotoState(DemoPlayer.ST_PLAYER_BONUS);
};
};
};
}
override public function free():void{
super.free();
mCanvas = null;
mWorld = null;
}
}
}//package com.bamtang.game.platformGame.objects
Section 54
//ActorManager (com.bamtang.game.platformGame.ActorManager)
package com.bamtang.game.platformGame {
import com.bamtang.swit.platform.*;
import com.bamtang.game.platformGame.boss.*;
import com.bamtang.game.platformGame.enemys.*;
import com.bamtang.game.platformGame.objects.*;
public class ActorManager extends NpcManager {
public var blueKeyX:int;// = 0
public var redKeyX:int;// = 0
public static const ITEM_SPRING_HIGH:int = 3001;
public static const ITEM_KEY_BLUE:int = 21;
public static const ITEM_DIAMOND_MEDIUM:int = 8;
public static const ITEM_GNOME_MEDIUM:int = 42;
public static const ITEM_MONSTER:int = 16;
public static const ITEM_THREE_SPINE:int = 102;
public static const ITEM_FLAG:int = 3;
public static const ITEM_BOSS:int = 4000;
public static const ITEM_FOUR_SPINE:int = 103;
public static const ITEM_DIAMOND_BIG:int = 12;
public static const ITEM_SPIEN_BIG:int = 33;
public static const ITEM_FLAG_FLY:int = 14;
public static const ITEM_GNOME_EASY:int = 41;
public static const ITEM_SPRING_LOW:int = 3000;
public static const ITEM_SPIEN_SMALL:int = 31;
public static const ITEM_HP:int = 4;
public static const ITEM_SECRET_DOOR:int = 69;
public static const ITEM_FIVE_SPINE:int = 104;
public static const ITEM_CARD:int = 6;
public static const ITEM_NINJA:int = 15;
public static const ITEM_SNOW_SHOES:int = 99;
public static const ITEM_MONSTER_2:int = 17;
public static const ITEM_EXTRA_POWER:int = 9;
public static const ITEM_TWO_SPINE:int = 101;
public static const ITEM_KEY_RED:int = 22;
public static const ITEM_POWER:int = 5;
public static const ITEM_BAT:int = 36;
public static const ITEM_ONE_SPINE:int = 100;
public static const ITEM_SIX_SPINE:int = 105;
public static const ITEM_EXTRA_HP:int = 10;
public static const ITEM_1UP:int = 7;
public static const ITEM_EIGHT_SPIKE:int = 208;
public static const ITEM_SPIEN_MEDIUM:int = 32;
public static const ITEM_FLAG_LEGS:int = 13;
public static const ITEM_PENGUIN:int = 34;
public static const ITEM_DIAMOND_SMALL:int = 2;
public static const ITEM_NINJA_2:int = 18;
public static const ITEM_GUMMYS:int = 35;
public static const ITEM_SWORD_IN_STONE:int = 98;
public static var instance:ActorManager;
public function ActorManager(world:World){
super(world);
instance = this;
}
public function drawDiamond(_x:int, _y:int):void{
mActors.push(new Items(mWorld.objectsCanvas, mWorld, _x, _y, ITEM_DIAMOND_BIG));
}
public function drawActor(_x:int, _y:int):void{
mActors.push(new Flag(mWorld.objectsCanvas, mWorld, _x, _y));
}
override public function init(player:Player):void{
mPlayer = player;
var k:int;
while (k < mBuffer.length) {
switch (mBuffer[k].id){
case ITEM_SECRET_DOOR:
mActors.push(new SecretDoor(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_KEY_BLUE:
blueKeyX = mBuffer[k].x;
mActors.push(new Key(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, Key.KEY_BLUE));
break;
case ITEM_KEY_RED:
redKeyX = mBuffer[k].x;
mActors.push(new Key(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, Key.KEY_RED));
break;
case ITEM_SPIEN_SMALL:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 100));
break;
case ITEM_SPIEN_MEDIUM:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 320));
break;
case ITEM_SPIEN_BIG:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 470));
break;
case ITEM_ONE_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 65));
break;
case ITEM_TWO_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 125));
break;
case ITEM_THREE_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 250));
break;
case ITEM_FOUR_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 420));
break;
case ITEM_FIVE_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 550));
break;
case ITEM_SIX_SPINE:
mActors.push(new Spine(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 750));
break;
case ITEM_BOSS:
mActors.push(new Boss(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_GNOME_EASY:
mActors.push(new GnomeEasy(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_GNOME_MEDIUM:
mActors.push(new GnomeMedium(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_NINJA:
mActors.push(new Ninja(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_NINJA_2:
mActors.push(new Ninja(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 1));
break;
case ITEM_MONSTER:
mActors.push(new SnowMonster(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_SWORD_IN_STONE:
mActors.push(new SwordInStone(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_MONSTER_2:
mActors.push(new SnowMonster(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, 1));
break;
case ITEM_PENGUIN:
mActors.push(new Penguin(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_GUMMYS:
mActors.push(new Gummys(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_BAT:
mActors.push(new Bat(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_POWER:
case ITEM_EXTRA_POWER:
case ITEM_HP:
case ITEM_CARD:
case ITEM_EXTRA_HP:
case ITEM_1UP:
case ITEM_DIAMOND_SMALL:
case ITEM_DIAMOND_MEDIUM:
case ITEM_DIAMOND_BIG:
case ITEM_FLAG_LEGS:
case ITEM_FLAG_FLY:
case ITEM_SNOW_SHOES:
if (mBuffer[k].id == ITEM_DIAMOND_SMALL){
DemoGame.DIAMONDS_IN_LEVEL++;
};
if (mBuffer[k].id == ITEM_DIAMOND_MEDIUM){
DemoGame.DIAMONDS_MEDIUM_IN_LEVEL++;
};
mActors.push(new Items(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, mBuffer[k].id));
break;
case ITEM_FLAG:
mActors.push(new BookFinish(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y, mBuffer[k].id));
break;
case ITEM_SPRING_HIGH:
mActors.push(new SpringHigh(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
case ITEM_SPRING_LOW:
mActors.push(new SpringLow(mWorld.objectsCanvas, mWorld, mBuffer[k].x, mBuffer[k].y));
break;
};
k++;
};
}
override public function update(dt:int):void{
var dx:Number;
var k:int;
while (k < mActors.length) {
if (mActors[k].isAwaitingDelete){
mActors[k].free();
mActors[k] = null;
var _temp1 = k;
k = (k - 1);
mActors.splice(_temp1, 1);
} else {
dx = (DemoWorld(mWorld).sensor.x - mActors[k].x);
if (((mActors[k].isRangeControlled) && ((((dx < -(visibleWidth))) || ((dx > visibleWidthOffset)))))){
if (!mActors[k].isIdle){
mActors[k].onIdle(true);
if ((((mActors[k] is Gnome)) || ((mActors[k] is Ninja)))){
mActors[k].clearBullets();
};
if ((mActors[k] is SnowMonster)){
mActors[k].clearBullets();
mActors[k].stopSound();
};
};
} else {
if (mActors[k].isIdle){
mActors[k].onIdle(false);
};
mActors[k].update(dt);
};
};
k++;
};
}
public function clearBullets():void{
var i:int;
while (i < mActors.length) {
if ((mActors[i] is Gnome)){
mActors[i].clearBullets();
} else {
if ((mActors[i] is Ninja)){
mActors[i].clearBullets();
} else {
if ((mActors[i] is SnowMonster)){
mActors[i].clearBullets();
};
};
};
i++;
};
}
override public function free():void{
instance = null;
super.free();
}
public function get actors():Array{
return (mActors);
}
}
}//package com.bamtang.game.platformGame
Section 55
//Bullet (com.bamtang.game.platformGame.Bullet)
package com.bamtang.game.platformGame {
import com.bamtang.swit.platform.*;
import com.bamtang.swit.utils.*;
public class Bullet extends PlatformActor {
private var mFrame:int;// = 0
private var mMove:Movement;
public var damage:int;
public function Bullet(clipName:String, world:World, x:int, y:int, speed:Number, distance:Number, angle:Number=0, damage:int=0){
super(world.objectsCanvas, world, clipName, x, y);
mClip.rotation = angle;
this.damage = damage;
angle = (angle * (Math.PI / 180));
var targetX:Number = (x + (distance * Math.cos(angle)));
var targetY:Number = (y + (distance * Math.sin(angle)));
mMove = new Movement(speed, x, y);
mMove.gotoPosition(targetX, targetY);
mMove.onEndMove = onEndMove;
mClip.play();
mClip.scaleX = (mClip.scaleY = mWorld.sizeFactor);
}
override public function update(dt:int):void{
mMove.update(dt);
mX = mMove.x;
mY = mMove.y;
super.update(dt);
}
override public function free():void{
super.free();
mMove = null;
}
private function onEndMove():void{
mIsAwaitingDelete = true;
}
}
}//package com.bamtang.game.platformGame
Section 56
//DemoCamera (com.bamtang.game.platformGame.DemoCamera)
package com.bamtang.game.platformGame {
import com.bamtang.swit.platform.*;
public class DemoCamera extends Camera {
private var mState:int;
public static const ST_FREE_CAMERA:int = 1;
public static const ST_CAMERA_IN_PLAYER:int = 0;
public function DemoCamera(world:World, width:int, height:int, positionScreenX:int=0, positionScreenY:int=0){
super(world, width, height, positionScreenX, positionScreenY);
mState = ST_CAMERA_IN_PLAYER;
}
override public function update(dt:int):void{
if (mState == ST_CAMERA_IN_PLAYER){
if (mFixedX){
mX = (mWorld.player.x - mLefLimit);
} else {
if ((mX + mLefLimit) > mWorld.player.x){
mX = (mWorld.player.x - mLefLimit);
};
if ((mX + mRightLimit) < mWorld.player.x){
mX = (mWorld.player.x - mRightLimit);
};
};
if (mFixedY){
mY = (mWorld.player.x - mUpLimit);
} else {
if ((mY + mUpLimit) > mWorld.player.y){
mY = (mWorld.player.y - mUpLimit);
};
if ((mY + mDownLimit) < mWorld.player.y){
mY = (mWorld.player.y - mDownLimit);
};
};
} else {
if (mState == ST_FREE_CAMERA){
x = DemoWorld(mWorld).sensor.x;
y = DemoWorld(mWorld).sensor.y;
};
};
if (mX < 0){
mX = 0;
} else {
if (mX > (mWorld.width - mWidth)){
mX = (mWorld.width - mWidth);
};
};
if (mY < 0){
mY = 0;
} else {
if (mY > (mWorld.height - mHeight)){
mY = (mWorld.height - mHeight);
};
};
}
public function gotoState(state:int):void{
mState = state;
}
}
}//package com.bamtang.game.platformGame
Section 57
//DemoGame (com.bamtang.game.platformGame.DemoGame)
package com.bamtang.game.platformGame {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.swit.math.*;
import com.bamtang.game.gui.*;
import com.bamtang.swit.utils.*;
import com.bamtang.game.platformGame.door.*;
import com.bamtang.game.platformGame.objects.*;
public class DemoGame extends Game {
private var mZoomFactor:int;// = 0
private var mLifes:int;
private var mCreateDoor:Boolean;// = false
public var doorManager:DoorManager;
private var mFinish:Boolean;// = false
private var mReset:Boolean;
private var mWorld:DemoWorld;
private var mYouLose:Boolean;// = false
private var popUpTutorials:Array;
private var mCollisionVisible:Boolean;// = false
private static const MAX_DELTA:int = 50;
public static var gameScore:int = 0;
public static var level:int;
public static var DIAMONDS_COLLECTED:int;
public static var GPP_SHOES:uint = 32;
private static var mParentCanvas:MovieClip;
public static var POPUPS_SHOWED:uint = (((((((0 | 0) | 0) | 0) | 0) | 0) | 0) | 0);
public static var instance:DemoGame;
public static var GPP_USESPRINGS:uint = 128;
public static var GPP_ICEKINGDOM:uint = 16;
public static var GPP_FIVECARDS:uint = 4;
public static var GPP_FLY:uint = 8;
public static var GPP_UNLEASHJAKE:uint = 1;
private static var mCanvas:MovieClip;
public static var GPP_DOOR:uint = 2;
public static var DIAMONDS_IN_LEVEL:int;
public static var oldScore:int = 0;
public static var GPP_STRETCH:uint = 64;
public static var DIAMONDS_MEDIUM_IN_LEVEL:int;
public static var lifes:int = 3;
public static var DIAMONDS_MEDIUM_COLLECTED:int;
public function DemoGame(canvas:MovieClip, canvasHud:MovieClip, params:Object){
super(canvas, canvasHud);
mLifes = DemoGame.lifes;
instance = this;
Global.stage.quality = Application.QUALITY;
switch (params.level){
case 1:
params.guiGame.addPopup(GuiIntroLevel, "mcGuiIntroLevel01");
break;
case 2:
params.guiGame.addPopup(GuiIntroLevel, "mcGuiIntroLevel02");
break;
case 3:
params.guiGame.addPopup(GuiIntroLevel, "mcGuiIntroLevel03");
break;
};
startGame(params);
oldScore = gameScore;
GuiHud.instance.setScore(gameScore);
if (params.level != 4){
DemoPlayer(mWorld.player).disable = true;
};
}
override public function onKeyDown(keyCode:int):void{
super.onKeyDown(keyCode);
mWorld.player.onKeyDown(keyCode);
if (Global.settings[("GAT_Config0" + DemoGame.level)].debugCheats){
if (keyCode == Global.KEY_3){
mZoomFactor = -1;
};
if (keyCode == Global.KEY_4){
mZoomFactor = 1;
};
};
}
override public function update(dt:int):void{
var i:int;
var j:int;
if (mZoomFactor != 0){
mWorld.camera.setScale((mWorld.camera.scale + (mZoomFactor * 0.01)));
Application.log(("scale: :" + mWorld.camera.scale));
};
if (!isPause){
i = 0;
while (i < popUpTutorials.length) {
if (!popUpTutorials[i][5]){
if ((((((((mWorld.player.x >= (mWorld.sizeFactor * popUpTutorials[i][1]))) && ((mWorld.player.x <= (mWorld.sizeFactor * popUpTutorials[i][2]))))) && ((mWorld.player.y >= (mWorld.sizeFactor * popUpTutorials[i][3]))))) && ((mWorld.player.y <= (mWorld.sizeFactor * popUpTutorials[i][4]))))){
if (!isPause){
j = 0;
while (j < popUpTutorials.length) {
if (popUpTutorials[i][0] == popUpTutorials[j][0]){
popUpTutorials[j][5] = true;
};
j++;
};
switch (String(popUpTutorials[i][0])){
case "door":
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_DOOR) != DemoGame.GPP_DOOR){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupDoor, "mcGuiPopupDoor");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_DOOR);
};
break;
};
};
};
};
i++;
};
if (mReset){
mReset = false;
} else {
if (mFinish){
if (mYouLose){
GuiGame.instance.addPopup(GuiScorecardLose, "mcGuiScorecardLose");
} else {
if (GuiGame.instance){
GuiGame.instance.removeGame(level);
};
};
} else {
if (dt > MAX_DELTA){
dt = MAX_DELTA;
};
super.update(dt);
mWorld.update(dt);
doorManager.update(dt);
GuiHud.instance.setHeadIconPosition(mWorld.width, mWorld.player.x);
};
};
};
}
public function toCheckPointPosition():void{
var v2d:Vector2D;
if (mWorld.positionToRevive != null){
v2d = mWorld.getFloorCollision(mWorld.positionToRevive.x, mWorld.positionToRevive.y);
mWorld.player.setPosition(v2d.x, v2d.y);
};
}
public function get score():int{
return (gameScore);
}
override public function onKeyUp(keyCode:int):void{
var tx:Number;
var ty:Number;
var v2d:Vector2D;
var i:int;
super.onKeyUp(keyCode);
if (Global.settings[("GAT_Config0" + DemoGame.level)].debugCheats){
if (keyCode == Global.KEY_1){
mCollisionVisible = !(mCollisionVisible);
mWorld.showCollision(mCollisionVisible);
Application.echo(("Collision visible: " + mCollisionVisible));
};
if ((((keyCode == Global.KEY_3)) || ((keyCode == Global.KEY_4)))){
mZoomFactor = 0;
};
if (keyCode == Global.KEY_5){
if (level == 1){
mWorld.player.setPosition((12000 * mWorld.sizeFactor), (1400 * mWorld.sizeFactor));
} else {
if (level == 2){
mWorld.player.setPosition(22993, 760);
} else {
if (level == 3){
mWorld.player.setPosition(25000, 760);
};
};
};
};
if (keyCode == Global.KEY_6){
mWorld.sensor.goto(1.2, 0, 180);
};
if (keyCode == Global.KEY_7){
tx = (mWorld.width * Math.random());
ty = ((mWorld.height * 0.8) * Math.random());
v2d = mWorld.getRayCollision(tx, ty, null);
if (v2d){
trace(("tx = " + tx));
trace(("ty = " + ty));
mWorld.player.setPosition(v2d.x, v2d.y);
};
};
if (keyCode == Global.KEY_8){
Application.echo(((("worldX: " + mWorld.player.x) + " - worldY: ") + mWorld.player.y));
};
if (keyCode == Global.KEY_P){
Items.CARD_GRABBED = 5;
i = 0;
while (i < DemoWorld(mWorld).objectManager.actors.length) {
if ((DemoWorld(mWorld).objectManager.actors[i] is SwordInStone)){
DemoWorld(mWorld).objectManager.actors[i].activateStone();
};
i++;
};
};
};
mWorld.player.onKeyUp(keyCode);
}
public function reset():void{
GuiHud.instance.setLifes(mLifes);
mWorld.objectManager.clearBullets();
DemoPlayer(mWorld.player).resetPlayer();
toCheckPointPosition();
}
public function get world():DemoWorld{
return (mWorld);
}
public function set score(value:int):void{
gameScore = value;
GuiHud.instance.setScore(gameScore);
}
public function onGameEnd(win:Boolean):void{
mYouLose = !(win);
mFinish = true;
}
override public function free():void{
if (level == 4){
if (!mYouLose){
DemoGame.lifes = 3;
};
};
DIAMONDS_COLLECTED = (DIAMONDS_MEDIUM_COLLECTED = (DIAMONDS_MEDIUM_IN_LEVEL = (DIAMONDS_IN_LEVEL = (Door.DOOR_OPEN = (Items.CARD_GRABBED = 0)))));
Flag.FLAGS_GRABBED = null;
popUpTutorials = null;
mWorld.free();
mWorld = null;
doorManager.free();
doorManager = null;
super.free();
instance = null;
Global.app.stopSoundsBgs();
}
override public function onInit():void{
mHud = new GuiHud("mcGuiHud");
mCanvasHud.addChild(mHud.clip);
}
override public function onActivate(activate:Boolean):void{
if (!activate){
mWorld.player.resetControl();
};
}
public function showPopupIceKingdowm():void{
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_ICEKINGDOM) != DemoGame.GPP_ICEKINGDOM){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupIceKingskingdom, "mcGuiPopupIceKingskingdom");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_ICEKINGDOM);
};
}
public function get lifes():int{
return (mLifes);
}
private function initPopupTutorials(tutorials:Array):void{
popUpTutorials = Common.cloneBiArray(tutorials);
var i:int;
while (i < popUpTutorials.length) {
popUpTutorials[i].push(false);
i++;
};
}
public function transitionReset():void{
GuiGame.instance.addPopup(GuiKillTransition, "mcGuiTransition");
}
public function startGame(params:Object):void{
level = params.level;
if (mWorld){
mWorld.free();
doorManager.free();
};
var configuration:* = Global.settings[("GAT_Config0" + DemoGame.level)];
mWorld = new DemoWorld(mLayer.addEmptyChild(), this, params.worldXML);
doorManager = new DoorManager(mWorld);
GuiHud.instance.setLifes(mLifes);
GuiHud.instance.setHPBar(100);
GuiHud.instance.setEnergyBar(0);
GuiHud.instance.setBlueKeyIconPosition(mWorld.width, mWorld.objectManager.blueKeyX);
GuiHud.instance.setRedKeyIconPosition(mWorld.width, mWorld.objectManager.redKeyX);
GuiHud.instance.setFinishIconPosition(mWorld.width, mWorld.width, level);
initPopupTutorials(configuration.popUpTutorials);
Global.app.stopSound("mus_AT_gameplay");
Global.app.stopSound("mus_AT_titlecard");
if (DemoGame.level != 4){
Global.app.playSound("mus_AT_gameplay");
} else {
Global.app.playSound("mus_AT_bossfight");
};
}
public function addLife(inc:int):void{
mLifes = (mLifes + inc);
DemoGame.lifes = (DemoGame.lifes + inc);
if (inc < 0){
if (mLifes < 0){
onGameEnd(false);
} else {
mReset = true;
};
} else {
GuiHud.instance.setLifes(mLifes);
};
}
}
}//package com.bamtang.game.platformGame
Section 58
//DemoPlayer (com.bamtang.game.platformGame.DemoPlayer)
package com.bamtang.game.platformGame {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.swit.platform.*;
import com.bamtang.game.platformGame.boss.*;
import com.bamtang.game.gui.*;
import com.bamtang.swit.utils.*;
public class DemoPlayer extends Player {
private var mBullets:List;
private var mLockKey:Boolean;
private var mTimerDie:int;
private var mCountSound:int;
private var mObjectToCheckCollision;
private var mCurrentAction:String;
private var mHealth:int;
private var mInvulnerableTime:Interval;
private var mTimeFly:Interval;
private var mDisable:Boolean;// = false
private var mItemCollectible:int;
private var mActionLegs:PlayerActionLegs;
private var mEnergy:Number;// = 0
public var disableForBonus:Boolean;// = false
private var mPositionCounter:int;// = 5
private var mHasDied:Boolean;
private var mActiveHitTest:Boolean;
public var disableAnimation:Boolean;// = false
public static const ST_PLAYER_BONUS:int = 207;
public static const ST_PLAYER_FLY_UP:int = 205;
private static const DIE_TIME:int = 500;
public static const ST_PLAYER_PUNCH:int = 200;
public static const ACT_LEGS:String = "legs";
public static const ST_PLAYER_FLY:int = 204;
public static const ST_PLAYER_SHOOT:int = 202;
public static const ACT_POWER:String = "power";
public static const ACT_FLIGHT:String = "flight";
private static const POSITION_COUNTER:int = 5;
public static const ST_PLAYER_BOMB:int = 206;
public static const ST_PLAYER_SHOOT_JUMP:int = 203;
public static const ACT_SNOW:String = "snow";
public static const ST_PLAYER_PUNCH_JUMP:int = 201;
private static var ViewPopupBomb:Boolean = false;
public static var instance:DemoPlayer;
public static var passedCheckPoint:Boolean = false;
public static var playerWin:Boolean = false;
public function DemoPlayer(canvas:MovieClip, world:DemoWorld, x:int, y:int){
super(canvas, world, x, y);
mScale = mWorld.sizeFactor;
mCountSound = 0;
mControl = new PlayerControl(this);
mCharacter = new Character(x, y, canvas);
mCharacter.addState(String(ST_PLAYER_STAND), "mc_player_stand_1");
mCharacter.addState(String(ST_PLAYER_STAND_2), "mc_player_stand_2", [allowedStand, 50]);
mCharacter.addState(String(ST_PLAYER_STAND_3), "mc_player_stand_3");
mCharacter.addState(String(ST_PLAYER_WALK), "mc_player_walk");
mCharacter.addState(String(ST_PLAYER_RUN), "mc_player_walk");
mCharacter.addState(String(ST_PLAYER_JUMP_UP), "mc_player_jump_up");
mCharacter.addState(String(ST_PLAYER_JUMP_DOWN), "mc_player_jump_fall");
mCharacter.addState(String(ST_PLAYER_HIT), "mc_player_hit");
mCharacter.addState(String(ST_PLAYER_LOSE), "mc_player_defeat", [DemoGame.instance.transitionReset, 65]);
mCharacter.addState(String(ST_PLAYER_WIN), "mc_player_win");
mCharacter.addState(String(ST_PLAYER_LAND), "mc_player_jump_land");
mCharacter.addState(String(ST_PLAYER_PUNCH), "mc_player_punch");
mCharacter.addState(String(ST_PLAYER_SHOOT), "mc_player_shoot");
mCharacter.addState(String(ST_PLAYER_PUNCH_JUMP), "mc_player_punch_jump");
mCharacter.addState(String(ST_PLAYER_SHOOT_JUMP), "mc_player_shoot_jump");
mCharacter.addState(String(ST_PLAYER_FLY), "mc_player_fly");
mCharacter.addState(String(ST_PLAYER_FLY_UP), "mc_player_fly_up");
mCharacter.addState(String(ST_PLAYER_BOMB), "mc_player_grow_up", [applyBomb, 29], [callBombSoundFX, 12]);
mCharacter.addState(String(ST_PLAYER_BONUS), "mc_player_bonus", [createDynamicDiamonds, 50], [callBonusSoundFX, 45]);
mCharacter.onEndAnimation = onEndAnimation;
gotoState(ST_PLAYER_STAND);
createCorners();
mLimitUp = true;
mLimitLeft = true;
mLimitRight = true;
mTimerDie = -1;
mHasDied = false;
mBullets = new List();
setHealth(100);
setEnergy(0);
instance = this;
mActionLegs = new PlayerActionLegs(mWorld, mScale);
mItemCollectible = 0;
setAction(ACT_SNOW);
}
private function onShoot():void{
if (mFreeMovement){
return;
};
if (mControl.isAction){
return;
};
if (mControl.isJumping){
gotoState(ST_PLAYER_SHOOT_JUMP);
} else {
gotoState(ST_PLAYER_SHOOT);
};
var angle:int = ((mClip.scaleX)>0) ? 0 : 180;
mBullets.add(new Bullet("mcBulletPlayer", mWorld, mX, (mY - 70), Global.settings[("GAT_Config0" + DemoGame.level)].playerSpeedBullet, Global.settings[("GAT_Config0" + DemoGame.level)].playerScoopeBullet, angle));
mControl.onAction(true);
}
public function onBulletCollision(object):void{
mObjectToCheckCollision = object;
mBullets.iterate(checkBulletCollision);
}
public function setEnergy(val:Number):void{
mEnergy = (mEnergy + val);
if (mEnergy < 0){
mEnergy = 0;
};
if (mEnergy > 3){
mEnergy = 3;
};
if (!ViewPopupBomb){
if (mEnergy > 0){
ViewPopupBomb = true;
if ((DemoGame.POPUPS_SHOWED & DemoGame.GPP_UNLEASHJAKE) != DemoGame.GPP_UNLEASHJAKE){
Global.app.playSound("snd_Finn_What");
GuiGame.instance.addPopup(GuiPopupUnleashJakes, "mcGuiPopupUnleashJakes");
DemoGame.POPUPS_SHOWED = (DemoGame.POPUPS_SHOWED | DemoGame.GPP_UNLEASHJAKE);
};
};
};
GuiHud.instance.setEnergyBar(mEnergy);
}
public function unLockKeysForActionLegs():void{
mLockKey = false;
}
private function onFly(active:Boolean=false):void{
if (((mFlyMovement) && (active))){
return;
};
mFlyMovement = active;
mSpeedFlyX = 0;
if (mFlyMovement){
gotoState(ST_PLAYER_FLY_UP);
mY = (mY - 10);
mControl.onFly(mFlyMovement);
mTimeFly = new Interval(onFly, Global.settings[("GAT_Config0" + DemoGame.level)].playerTimeFly);
} else {
gotoState(ST_PLAYER_JUMP_DOWN);
setAction(ACT_SNOW);
mTimeFly = null;
};
}
private function allowedStand():void{
mCountSound++;
Global.app.playSound(("snd_Finn_timestand_" + mCountSound));
if (mCountSound >= 3){
mCountSound = 0;
};
}
private function callBonusSoundFX():void{
Global.app.playSound("snd_AT_5sword");
}
private function onMoveLeg():void{
if (((((((!((mState == ST_PLAYER_STAND))) && (!((mState == ST_PLAYER_STAND_2))))) && (!((mState == ST_PLAYER_STAND_3))))) && (!((mState == ST_PLAYER_WALK))))){
return;
};
if (mControl.isJumping){
return;
};
mIsMoveLeg = true;
mActionLegs.reset(mX, mY, mDir);
mActionLegs.onEndMove = onEndMoveLeg;
mCanvas.visible = false;
mLockKey = true;
Global.app.stopSound("snd_AT_mc_player_walk");
Global.app.playSound("snd_AT_stretch");
}
public function resetPlayer():void{
mHasDied = false;
mIsDead = false;
if (mInvulnerableTime){
mInvulnerableTime.free();
mInvulnerableTime = null;
};
invulnerable({state:true});
mDir = 1;
super.gotoState(Player.ST_PLAYER_STAND_3);
setHealth(100);
setEnergy(0);
resetControl();
setAction(ACT_SNOW);
disableAnimation = false;
}
public function onBomb():void{
if (((((((!((mState == ST_PLAYER_STAND))) && (!((mState == ST_PLAYER_STAND_2))))) && (!((mState == ST_PLAYER_STAND_3))))) && (!((mState == ST_PLAYER_WALK))))){
return;
};
if (mControl.isJumping){
return;
};
if (mEnergy > 0){
mCanvas.alpha = 1;
if (mInvulnerableTime){
mInvulnerableTime.free();
mInvulnerableTime = null;
};
mIsInvulnerable = true;
mLockKey = true;
gotoState(ST_PLAYER_BOMB);
GuiHud.instance.setAction(ACT_POWER);
setEnergy(-1);
};
}
public function setItemCollectible(val:int=0):void{
mItemCollectible = (mItemCollectible + val);
GuiHud.instance.setItemCollectible(mItemCollectible);
}
private function checkBulletCollision(bullet:Bullet, index:int):void{
if (!(mObjectToCheckCollision is Boss)){
if (((mObjectToCheckCollision.isEnemy) && (!(mObjectToCheckCollision.mHasDied)))){
if (mObjectToCheckCollision.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mObjectToCheckCollision.makeEffect();
mObjectToCheckCollision.kill();
};
};
} else {
if (mObjectToCheckCollision.hitTest(bullet)){
bullet.setAwaitingDelete(true);
mObjectToCheckCollision.onBossHitted(Boss.HIT_BULLET);
};
};
}
public function get isJumpingDown():Boolean{
return (((mControl.isJumping) && (!(mControl.isJumpingUp))));
}
public function invulnerable(param:Object, moreTime:int=0):void{
mIsInvulnerable = param.state;
if (mInvulnerableTime == null){
mCanvas.alpha = 0.5;
mInvulnerableTime = new Interval(invulnerable, (2000 + moreTime), 1, {state:false});
} else {
mCanvas.alpha = 1;
mInvulnerableTime.free();
mInvulnerableTime = null;
};
}
public function undisable():void{
disable = false;
disableForBonus = false;
}
public function applyBomb():void{
Common.shake(Global.scene.clip, 10, 15);
}
public function setAction(type:String):void{
if (mCurrentAction != type){
GuiHud.instance.playEffect();
};
mCurrentAction = type;
GuiHud.instance.setAction(type);
}
public function playerWin():void{
DemoPlayer.playerWin = true;
onWinPlayer();
}
public function onWinPlayer():void{
super.gotoState(Player.ST_PLAYER_WIN);
}
public function fixedMoveForActionLegs():void{
mControl.onRight(false);
mControl.onLeft(false);
}
public function onEndBomb():void{
mLockKey = false;
mIsInvulnerable = false;
gotoState(ST_PLAYER_STAND);
createCorners();
}
override public function onEnemyCollision(enemy:PlatformActor, damage:int):void{
if (DemoGame.level == 4){
if ((enemy is Boss)){
if (Boss(enemy).mHasDied){
return;
};
};
};
setHealth(-(damage));
if (mState == ST_PLAYER_BOMB){
return;
};
if (mHealth > 0){
if (!mFlyMovement){
gotoState(ST_PLAYER_HIT);
};
if (mActionLegs){
mActionLegs.onHit();
};
if (!mIsInvulnerable){
invulnerable({state:true});
};
} else {
gotoState(ST_PLAYER_LOSE);
mControl.reset();
};
}
override public function onKeyUp(keyCode:int):void{
super.onKeyUp(keyCode);
if ((((((keyCode == Global.KEY_SPACE)) && (mFlyMovement))) && (!(GuiGame.instance.popup)))){
onFly(false);
};
}
public function set disable(state:Boolean):void{
mDisable = state;
if (mDisable){
mControl.reset();
};
}
override public function onKeyDown(keyCode:int):void{
if (!mDisable){
if (mState == ST_PLAYER_LOSE){
return;
};
if (Global.game.isPause){
return;
};
if (mLockKey){
return;
};
super.onKeyDown(keyCode);
if ((((((mState == ST_PLAYER_LOSE)) || ((mState == ST_PLAYER_HIT)))) || ((mState == ST_PLAYER_WIN)))){
return;
};
if (keyCode == Global.KEY_Z){
onBomb();
};
if (keyCode == Global.KEY_SPACE){
switch (mCurrentAction){
case ACT_SNOW:
onShoot();
break;
case ACT_LEGS:
onMoveLeg();
break;
case ACT_FLIGHT:
onFly(true);
break;
};
};
};
}
override public function hitTest(actor:PlatformActor):Boolean{
var object:Object;
var actor = actor;
if (mState == ST_PLAYER_LOSE){
return (false);
};
if (mState == ST_PLAYER_BOMB){
object = (actor as Object);
if (((object.isEnemy) && (!(object.mHasDied)))){
createCorners();
mBounds.x = (((mFlipX) ? -1 : 1 * mClip.mcCollision.x) - (0.5 * mClip.mcCollision.width));
if (super.hitTest(actor)){
if ((object is Boss)){
object.onBossHitted(Boss.HIT_BOMB);
} else {
if (object.clearBullets){
object.clearBullets();
};
object.kill();
};
};
};
//unresolved jump
var _slot1 = e;
return (false);
};
var isHit:Boolean = super.hitTest(actor);
if (isHit){
mActiveHitTest = true;
};
return (isHit);
}
override public function update(dt:int):void{
var px:int;
var py:int;
var tx:int;
var ty:int;
mBullets.update(dt);
if (mTimerDie > 0){
mTimerDie = (mTimerDie - dt);
if (mTimerDie <= 0){
gotoState(ST_PLAYER_STAND);
mWorld.game.addLife(-1);
if (DemoGame(mWorld.game).lifes > -1){
DemoGame(mWorld.game).transitionReset();
};
};
};
if (mTimeFly){
mTimeFly.update(dt);
};
if (mIsMoveLeg){
mActionLegs.update(dt);
} else {
if (mState == ST_PLAYER_BOMB){
mCharacter.update(dt);
if (mClip.currentFrame == 10){
Global.app.playSound("snd_Jake_special_voice");
};
} else {
super.update(dt);
};
};
if (mState == ST_PLAYER_FLY){
if (mTimeFly.timeElapse > (mTimeFly.time * 0.7)){
Common.tint(mClip, (((mTimeFly.timeElapse % 100) / 100) + 0.8), (((mTimeFly.timeElapse % 100) / 100) + 0.8), 1.2);
};
};
if (mInvulnerableTime != null){
mInvulnerableTime.update(dt);
};
if (--mPositionCounter < 0){
mPositionCounter = POSITION_COUNTER;
px = int(mX);
py = int(mY);
tx = int((mX / mWorld.tileWidth));
ty = int((mY / mWorld.tileHeight));
Application.logPlayer((((((((("x:" + int(((mX / mWorld.tileWidth) * 25))) + " y:") + int(((mY / mWorld.tileHeight) * 25))) + " (") + tx) + " , ") + ty) + ")"));
};
if (((((!(mActiveHitTest)) && (!(mFlyMovement)))) && (!(mIsMoveLeg)))){
if (mState != ST_PLAYER_BOMB){
setAction(ACT_SNOW);
};
};
mActiveHitTest = false;
}
private function callBombSoundFX():void{
Global.app.playSound("snd_AT_player_special");
}
public function setHealth(perc:int):void{
mHealth = (mHealth + perc);
if (mHealth < 0){
mHealth = 0;
};
if (mHealth > 100){
mHealth = 100;
};
GuiHud.instance.setHPBar(mHealth);
}
public function get disable():Boolean{
return (mDisable);
}
public function hitTestPunch(actor:PlatformActor):Boolean{
return (false);
}
override public function onPlayerFellOutOfWorld():void{
if (!mHasDied){
mTimerDie = DIE_TIME;
mHasDied = true;
};
}
override public function gotoState(state:int):void{
if (((!(mDisable)) || ((DemoGame.level == 4)))){
if (state == ST_PLAYER_BONUS){
disable = true;
super.gotoState(state);
disableForBonus = true;
Common.execCommand(this, "undisable", 3500);
};
if (state != ST_PLAYER_WALK){
Global.app.stopSound("snd_AT_mc_player_walk");
};
if (mState == ST_PLAYER_LOSE){
return;
};
};
if (!disableForBonus){
super.gotoState(state);
};
}
override public function onEndAnimation(state:String):void{
super.onEndAnimation(state);
switch (state){
case String(ST_PLAYER_BOMB):
Global.app.playSound("snd_Finn_GoodOneJake");
break;
};
if (state == String(ST_PLAYER_WIN)){
if (DemoGame.level != 4){
GuiGame.instance.addPopup(GuiScorecard, "mcGuiScorecardWin");
} else {
GuiGame.instance.addPopup(GuiScorecardWinGame, "mcGuiScorecardWinGame");
};
} else {
if (state == String(ST_PLAYER_BONUS)){
disable = false;
disableForBonus = false;
Global.app.playSound("snd_Jake_HolyMoly");
gotoState(ST_PLAYER_STAND);
} else {
if (state == String(ST_PLAYER_LOSE)){
if (!disableAnimation){
if (mInvulnerableTime){
mInvulnerableTime.free();
mInvulnerableTime = null;
};
invulnerable({state:true}, 5000);
mWorld.game.addLife(-1);
disableAnimation = true;
};
} else {
if ((((((((state == String(ST_PLAYER_SHOOT))) || ((state == String(ST_PLAYER_PUNCH))))) || ((state == String(ST_PLAYER_SHOOT_JUMP))))) || ((state == String(ST_PLAYER_PUNCH_JUMP))))){
mControl.onAction(false);
gotoState(ST_PLAYER_STAND);
} else {
if (state == String(ST_PLAYER_HIT)){
gotoState(ST_PLAYER_STAND);
} else {
if (state == String(ST_PLAYER_FLY_UP)){
gotoState(ST_PLAYER_FLY);
} else {
if (state == String(ST_PLAYER_BOMB)){
onEndBomb();
};
};
};
};
};
};
};
}
private function onEndMoveLeg():void{
mIsMoveLeg = false;
if (mActionLegs.dir == 1){
mControl.onRight(true);
} else {
mControl.onLeft(true);
};
mCanvas.visible = true;
Common.execCommand(this, "unLockKeysForActionLegs", 350);
Common.execCommand(this, "fixedMoveForActionLegs", 50);
setAction(ACT_SNOW);
}
override public function free():void{
mActionLegs.free();
mTimeFly = null;
mActionLegs = null;
instance = null;
mBullets.free();
mBullets = null;
mCharacter.free();
mCharacter = null;
mControl.free();
mControl = null;
mCanvas = null;
mWorld = null;
}
private function createDynamicDiamonds():void{
var _i:int;
var _j:int;
var _initX:int = x;
var _initY:int = y;
_i = -4;
while (_i < 4) {
_j = -4;
while (_j < 0) {
DemoWorld(world).objectManager.drawDiamond((_initX + (_i * (70 * mWorld.sizeFactor))), (_initY + (_j * (48 * mWorld.sizeFactor))));
_j++;
};
_i++;
};
}
}
}//package com.bamtang.game.platformGame
Section 59
//DemoWorld (com.bamtang.game.platformGame.DemoWorld)
package com.bamtang.game.platformGame {
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.swit.platform.*;
import flash.geom.*;
public class DemoWorld extends World {
private var mCheckPointsLength:int;
private var mUseCheckPoints:Boolean;
public var positionToRevive:Point;
public var sensor:Sensor;
public var effectManager:EffectPlatformManager;
private var mCheckPoints:Array;
public function DemoWorld(canvas:MovieClip, game:DemoGame, worldXML:String){
super(canvas, game, worldXML);
mObjectManager = new ActorManager(this);
createLayers();
mPlayer = new DemoPlayer(mPlayerCanvas, this, mWorldConfig.playerInitX, mWorldConfig.playerInitY);
mObjectManager.init(mPlayer);
mCamera.update(0);
init();
createCheckPoints(Global.settings[("GAT_Config0" + DemoGame.level)].checkPointPositions);
sensor = new Sensor(mPlayerCanvas, this, "mcSensor", mWorldConfig.playerInitX, mWorldConfig.playerInitY);
effectManager = new EffectPlatformManager(this);
}
override protected function createCamera(worlXml:XML):void{
mCamera = new DemoCamera(this, mWorldConfig.cameraWidth, mWorldConfig.cameraHeight, mWorldConfig.cameraScreenX, mWorldConfig.cameraScreenY);
mCamera.setScale(mWorldConfig.cameraScale);
}
private function drawCheckPoints(checkPoints:Array):void{
var i:int;
i = 0;
while (i < checkPoints.length) {
ActorManager(mObjectManager).drawActor((sizeFactor * checkPoints[i][0]), (sizeFactor * checkPoints[i][1]));
i++;
};
}
override public function update(dt:int):void{
effectManager.update(dt);
super.update(dt);
sensor.update(dt);
}
public function resetNpc():void{
mObjectManager.reset();
mObjectManager.init(mPlayer);
drawCheckPoints(Global.settings[("GAT_Config0" + DemoGame.level)].checkPointPositions);
}
override public function free():void{
sensor.free();
sensor = null;
mCheckPoints = null;
positionToRevive = null;
effectManager.free();
effectManager = null;
super.free();
}
public function get objectManager():ActorManager{
return ((mObjectManager as ActorManager));
}
private function createCheckPoints(checkPoints:Array):void{
if (checkPoints != null){
mUseCheckPoints = ((checkPoints.length)>0) ? true : false;
if (mUseCheckPoints){
positionToRevive = new Point();
drawCheckPoints(checkPoints);
};
};
}
}
}//package com.bamtang.game.platformGame
Section 60
//PlayerActionLegs (com.bamtang.game.platformGame.PlayerActionLegs)
package com.bamtang.game.platformGame {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.swit.platform.*;
public class PlayerActionLegs {
private var mDir:int;
private var mCanvas:MovieClip;
private var mX:Number;
private var mY:Number;
public var onEndMove:Function;
private var mWorld:World;
private var mCharacter:Character;
private var mScale:Number;
private static const ST_UP:String = "ST_UP";
private static const ST_MOVE:String = "ST_MOVE";
public function PlayerActionLegs(world:World, scale:Number){
super();
mWorld = world;
mCanvas = new MovieClip();
mWorld.objectsCanvas.addChild(mCanvas);
mX = 0;
mY = 0;
mCharacter = new Character(0, 0, mCanvas);
mCharacter.addState(ST_UP, "mc_player_legs_up");
mCharacter.addState(ST_MOVE, "mc_player_legs_move");
mCharacter.onEndAnimation = onEndAnimation;
mCanvas.visible = false;
mScale = scale;
}
public function stop():void{
mCanvas.visible = false;
}
public function free():void{
mCharacter = null;
mCanvas = null;
mWorld = null;
}
public function onEndAnimation(idState:String):void{
switch (idState){
case ST_UP:
mCharacter.gotoState(ST_MOVE);
break;
case ST_MOVE:
stop();
mCharacter.gotoState(ST_UP);
onEndMove();
break;
};
}
public function update(dt:int):void{
mCanvas.x = (mX - mWorld.camera.x);
mCanvas.y = (mY - mWorld.camera.y);
mCharacter.update(dt);
if (mCharacter.state == ST_MOVE){
DemoPlayer.instance.setPosition(mX, (mY - (mCharacter.actor.clip["mcHelper"].height * mScale)));
};
}
public function get dir():int{
return (mDir);
}
public function onHit():void{
mCanvas.alpha = 0.5;
}
public function reset(x:int, y:int, dir:int):void{
mDir = dir;
mX = x;
mY = y;
mCanvas.scaleX = (mDir * mScale);
mCanvas.scaleY = mScale;
mCanvas.visible = true;
mCanvas.alpha = 1;
mCharacter.gotoState(ST_UP);
mWorld.objectsCanvas.swapChildrenAt((mWorld.objectsCanvas.numChildren - 1), mWorld.objectsCanvas.getChildIndex(mCanvas));
}
}
}//package com.bamtang.game.platformGame
Section 61
//Sensor (com.bamtang.game.platformGame.Sensor)
package com.bamtang.game.platformGame {
import flash.display.*;
import com.bamtang.swit.platform.*;
import com.bamtang.swit.utils.*;
public class Sensor extends PlatformActor {
private var mDestinationPauseTime:int;
private var mOldSensorY:int;
private var mSensorState:int;
private var mOldSensorX:int;
private var mOldSpeed:Number;
private var mMovement:Movement;
private static const ST_GOTO:int = 0;
private static const ST_STAND:int = 2;
private static const ST_GOBACK:int = 1;
public function Sensor(canvas:MovieClip, world:World, name:String, x:int, y:int){
super(canvas, world, name, x, y);
mSensorState = ST_STAND;
}
public function freeCamera(state:Boolean):void{
if (state){
DemoPlayer(mWorld.player).disable = true;
DemoCamera(mWorld.camera).gotoState(DemoCamera.ST_FREE_CAMERA);
} else {
DemoPlayer(mWorld.player).disable = false;
DemoCamera(mWorld.camera).gotoState(DemoCamera.ST_CAMERA_IN_PLAYER);
};
}
public function goto(_speed:Number, _x:int, _y:int, destinationPauseTime:int=0):void{
if (mSensorState == ST_STAND){
mOldSensorX = mWorld.camera.x;
mOldSensorY = mWorld.camera.y;
mOldSpeed = _speed;
mDestinationPauseTime = destinationPauseTime;
mMovement = new Movement(_speed, mOldSensorX, mOldSensorY, {state:ST_GOTO});
mMovement.gotoPosition(_x, _y);
mMovement.onEndMove = onEndMove;
mSensorState = ST_GOTO;
freeCamera(true);
};
}
override public function update(dt:int):void{
switch (mSensorState){
case ST_GOTO:
if (mMovement){
x = mMovement.x;
y = mMovement.y;
mMovement.update(dt);
};
break;
case ST_GOBACK:
if (mDestinationPauseTime <= 0){
if (mMovement){
x = mMovement.x;
y = mMovement.y;
mMovement.update(dt);
};
} else {
mDestinationPauseTime = (mDestinationPauseTime - dt);
};
break;
case ST_STAND:
x = mWorld.camera.x;
y = mWorld.camera.y;
break;
};
super.update(dt);
}
override public function free():void{
super.free();
mMovement = null;
}
private function onEndMove():void{
switch (mMovement.params.state){
case ST_GOTO:
mMovement = null;
mMovement = new Movement(mOldSpeed, x, y, {state:ST_GOBACK});
mMovement.gotoPosition(mOldSensorX, mOldSensorY);
mMovement.onEndMove = onEndMove;
mSensorState = ST_GOBACK;
break;
case ST_GOBACK:
mMovement = null;
freeCamera(false);
mSensorState = ST_STAND;
break;
};
}
}
}//package com.bamtang.game.platformGame
Section 62
//Game (com.bamtang.game.Game)
package com.bamtang.game {
import com.bamtang.swit.core.*;
import flash.display.*;
public class Game {
protected var mLayer:Layer;
protected var mHud;
public var isPause:Boolean;
protected var mEffectManager:EffectManager;
protected var mCanvasHud:MovieClip;
public function Game(canvas:MovieClip, canvasHud:MovieClip){
super();
mLayer = new Layer(canvas);
mEffectManager = new EffectManager(mLayer.addEmptyChildAt(1000));
mCanvasHud = canvasHud;
onInit();
returnFocusToGame();
}
public function onKeyDown(keyCode:int):void{
if (mHud){
mHud.onKeyDown(keyCode);
};
}
public function update(dt:int):void{
if (mHud){
mHud.update(dt);
};
if (mEffectManager){
mEffectManager.update(dt);
};
}
public function free():void{
mEffectManager.free();
mEffectManager = null;
mLayer.free();
mLayer = null;
mCanvasHud = null;
if (mHud){
mHud.free();
};
mHud = null;
}
public function get layer():Layer{
return (mLayer);
}
public function returnFocusToGame():void{
Application.instance.layer.clip.stage.focus = null;
Global.stage.quality = Application.QUALITY;
}
public function onInit():void{
}
public function onActivate(activate:Boolean):void{
if (mHud){
mHud.onActivate(activate);
};
}
public function onKeyUp(keyCode:int):void{
if (mHud){
mHud.onKeyUp(keyCode);
};
}
}
}//package com.bamtang.game
Section 63
//Global (com.bamtang.game.Global)
package com.bamtang.game {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.gui.*;
public class Global {
public static const KEY_LEFT:int = 37;
public static const KEY_UP:int = 38;
public static const KEY_DOWN:int = 40;
public static const KEY_0:int = 48;
public static const KEY_1:int = 49;
public static const KEY_2:int = 50;
public static const KEY_3:int = 51;
public static const KEY_4:int = 52;
public static const KEY_5:int = 53;
public static const KEY_7:int = 55;
public static const KEY_ENTER:int = 13;
public static const KEY_9:int = 57;
public static const KEY_6:int = 54;
public static const KEY_8:int = 56;
public static const KEY_A:int = 65;
public static const KEY_C:int = 67;
public static const KEY_P:int = 80;
public static const KEY_S:int = 83;
public static const KEY_W:int = 87;
public static const KEY_X:int = 88;
public static const KEY_Z:int = 90;
public static const KEY_D:int = 68;
public static const KEY_SHIFT:int = 16;
public static const KEY_SPACE:int = 32;
public static const PATH_APP:String = "config_app.xml";
public static const KEY_RIGTH:int = 39;
public static var game:Game;
public static var scene:Layer;
public static var app:Application;
public static var settings:Settings;
public static var guiManager:GuiManager;
public static var stage:Stage;
}
}//package com.bamtang.game
Section 64
//Settings (com.bamtang.game.Settings)
package com.bamtang.game {
import com.bamtang.game.platformGame.data.*;
public class Settings {
public var GAT_SE:GAT_StatesEngine;
public var GAT_Config01:GAT_Configuration01;
public var GAT_Config02:GAT_Configuration02;
public var GAT_Config03:GAT_Configuration03;
public var GAT_Config04:GAT_Configuration04;
public function Settings(){
super();
GAT_Config01 = new GAT_Configuration01();
GAT_Config02 = new GAT_Configuration02();
GAT_Config03 = new GAT_Configuration03();
GAT_Config04 = new GAT_Configuration04();
GAT_SE = new GAT_StatesEngine();
}
}
}//package com.bamtang.game
Section 65
//Box (com.bamtang.swit.controls.Box)
package com.bamtang.swit.controls {
import com.bamtang.swit.core.*;
import flash.display.*;
public class Box extends Control {
private var mFunctionClick:Function;
public function Box(color:Number, width:Number, height:Number, alpha:Number, useHand:Boolean=false){
var color = color;
var width = width;
var height = height;
var alpha = alpha;
var useHand = useHand;
super("", 0, 0);
var _local7 = mActor.clip.graphics;
with (_local7) {
beginFill(color, alpha);
lineStyle(1, color, alpha);
lineTo(width, 0);
lineTo(width, height);
lineTo(0, height);
lineTo(0, 0);
endFill();
};
mActor.useHandCursor = useHand;
mActor.onClick = _onClick;
mActor.clip.width = width;
mActor.clip.height = height;
}
public function get clip():MovieClip{
return (mActor.clip);
}
private function _onClick(a:Actor):void{
if (mFunctionClick != null){
mFunctionClick(this);
};
}
public function set onClick(f:Function):void{
mFunctionClick = f;
}
override public function free():void{
mFunctionClick = null;
super.free();
}
}
}//package com.bamtang.swit.controls
Section 66
//Button (com.bamtang.swit.controls.Button)
package com.bamtang.swit.controls {
import com.bamtang.swit.core.*;
import flash.display.*;
public class Button extends Control {
private var mIsEnabled:Boolean;// = true
private var mGroupSrpites:SpriteGroup;
private var mFunctionOver:Function;
private var mFunctionClick:Function;
private var mFunctionDown:Function;
private var mFunctionOut:Function;
private static const INDEX_DISABLED:int = 3;
private static const INDEX_OVER:int = 1;
private static const INDEX_OUT:int = 0;
private static const INDEX_RELEASE:int = 2;
public function Button(idOut:String, idOver:String, idRelease:String, idDisabled:String){
super("", 0, 0);
mGroupSrpites = new SpriteGroup(mActor.clip, [idOut, idOver, idRelease, idDisabled]);
mActor.onMouseOver = _onMouseOver;
mActor.onMouseOut = _onMouseOut;
mActor.onMouseUp = _onMouseUp;
mActor.onMouseDown = _onMouseDown;
mActor.onClick = _onClick;
mActor.useHandCursor = true;
mGroupSrpites.showClipIn(INDEX_OUT);
}
public function get enabled():Boolean{
return (mIsEnabled);
}
public function set enabled(value:Boolean):void{
mGroupSrpites.showClipIn((value) ? INDEX_OUT : INDEX_DISABLED);
mIsEnabled = value;
}
private function _onMouseOut(a:Actor):void{
if (mIsEnabled){
mGroupSrpites.showClipIn(INDEX_OUT);
if (mFunctionOut != null){
mFunctionOut(this);
};
};
}
private function _onMouseDown(a:Actor):void{
if (mIsEnabled){
mGroupSrpites.showClipIn(INDEX_RELEASE);
if (mFunctionDown != null){
mFunctionDown(this);
};
};
}
public function set onMouseDown(functionDown:Function):void{
mFunctionDown = mFunctionDown;
}
private function _onMouseUp(a:Actor):void{
if (mIsEnabled){
mGroupSrpites.showClipIn(INDEX_OVER);
};
}
public function get clip():MovieClip{
return (mActor.clip);
}
public function set onMouseOut(functionOut:Function):void{
mFunctionOut = functionOut;
}
public function set onClick(functionClick:Function):void{
mFunctionClick = functionClick;
}
private function _onClick(a:Actor):void{
if (mIsEnabled){
if (mFunctionClick != null){
mFunctionClick(this);
};
};
}
override public function free():void{
mGroupSrpites.free();
mGroupSrpites = null;
mFunctionClick = null;
mFunctionDown = null;
mFunctionOver = null;
mFunctionOut = null;
super.free();
}
public function set onMouseOver(functionOver:Function):void{
mFunctionOver = functionOver;
}
private function _onMouseOver(a:Actor):void{
if (mIsEnabled){
mGroupSrpites.showClipIn(INDEX_OVER);
if (mFunctionOver != null){
mFunctionOver(this);
};
};
}
}
}//package com.bamtang.swit.controls
Section 67
//Control (com.bamtang.swit.controls.Control)
package com.bamtang.swit.controls {
import com.bamtang.swit.core.*;
public class Control {
protected var mActor:Actor;
protected var mXBase:Number;
protected var mYBase:Number;
public static const BUTTON:String = "button";
public static const TEXTFONT:String = "text";
public function Control(nameClip:String="", x:Number=0, y:Number=0){
super();
mActor = new Actor(nameClip, x, y);
mXBase = x;
mYBase = y;
}
public function free():void{
mActor.free();
mActor = null;
}
public function setPosition(x:Number, y:Number):void{
mActor.x = (mXBase = x);
mActor.y = (mYBase = y);
}
}
}//package com.bamtang.swit.controls
Section 68
//TextFont (com.bamtang.swit.controls.TextFont)
package com.bamtang.swit.controls {
import flash.display.*;
import flash.text.*;
import flash.filters.*;
public class TextFont extends Control {
private var mTextFormat:TextFormat;
private var mGlow:GlowFilter;
private var mTextField:TextField;
private var mForceCenter:Boolean;
private var mShadow:DropShadowFilter;
public static var ALIGN_LEFT:String = "left";
public static var FONT_ARIAL:String = "mcFontArial";
public static var ALIGN_RIGHT:String = "right";
public static var ALIGN_CENTER:String = "center";
public function TextFont(typeFont:String, text:String, size:Number=0, color:Number=0, align:String="left", bold:Boolean=false, italic:Boolean=false, spacing:Number=1){
super(typeFont, 0, 0);
mTextField = (mActor.clip.txtInfo as TextField);
mTextField.autoSize = TextFieldAutoSize.LEFT;
mTextField.multiline = true;
mTextField.text = text;
mTextFormat = new TextFormat();
mTextFormat.size = size;
mTextFormat.color = color;
mTextFormat.align = align;
mTextFormat.letterSpacing = spacing;
mTextFormat.bold = bold;
mTextFormat.italic = italic;
mTextField.setTextFormat(mTextFormat);
}
public function set size(value:Number):void{
mTextFormat.size = value;
mTextField.setTextFormat(mTextFormat);
}
public function get text():String{
return (mTextField.text);
}
public function set color(value:Number):void{
mTextFormat.color = value;
mTextField.setTextFormat(mTextFormat);
}
public function set forceCenter(value:Boolean):void{
mForceCenter = value;
if (value){
mActor.clip.x = (mXBase - (mActor.clip.width / 2));
} else {
mActor.clip.x = mXBase;
};
}
public function set align(value:String):void{
mTextFormat.align = value;
mTextField.setTextFormat(mTextFormat);
}
public function set width(value:Number):void{
mActor.clip.width = value;
}
public function get textField():TextField{
return (mTextField);
}
public function set height(value:Number):void{
mActor.clip.height = value;
}
public function get clip():MovieClip{
return (mActor.clip);
}
public function set spacing(value:Number):void{
mTextFormat.letterSpacing = value;
mTextField.setTextFormat(mTextFormat);
}
public function set bold(value:Boolean):void{
mTextFormat.bold = value;
mTextField.setTextFormat(mTextFormat);
}
public function applyGlow(color:Number=0, strength:Number=15, alpha:Number=1, blurX:Number=2, blurY:Number=2):void{
if (color < 0){
return;
};
mGlow = new GlowFilter(0, alpha, blurX, blurY, strength, 8);
mGlow.color = color;
applyFilters();
}
public function set italic(value:Boolean):void{
mTextFormat.italic = value;
mTextField.setTextFormat(mTextFormat);
}
public function set text(text:String):void{
mTextField.text = text;
mTextField.setTextFormat(mTextFormat);
forceCenter = mForceCenter;
}
override public function free():void{
mActor.clip.filters = [];
mTextFormat = null;
mTextField = null;
mGlow = null;
mShadow = null;
super.free();
}
private function applyFilters():void{
var filters:Array = new Array(0);
if (mGlow){
filters.push(mGlow);
};
if (mShadow){
filters.push(mShadow);
};
mActor.clip.filters = filters;
}
public function applyShadow(color:Number=0, distance:Number=2, angle:Number=0, strength:Number=1):void{
if (color < 0){
return;
};
mShadow = new DropShadowFilter();
mShadow.color = color;
mShadow.distance = distance;
mShadow.angle = angle;
mShadow.strength = strength;
applyFilters();
}
public function get forceCenter():Boolean{
return (mForceCenter);
}
public function set htmlText(text:String):void{
mTextField.htmlText = text;
mTextField.setTextFormat(mTextFormat);
}
public function set mouseEnabled(value:Boolean):void{
clip.mouseEnabled = value;
mTextField.mouseEnabled = value;
}
}
}//package com.bamtang.swit.controls
Section 69
//Actor (com.bamtang.swit.core.Actor)
package com.bamtang.swit.core {
import flash.events.*;
import flash.display.*;
public class Actor {
private var mCurrentFrame:int;
protected var mApp:Application;
public var toDie:Boolean;
private var mRefOnMouseDown:Function;
protected var mX:Number;
protected var mY:Number;
private var mRefOnClick:Function;
public var loop:Boolean;
protected var mUseHandCursor:Boolean;
private var mRefOnMouseMove:Function;
private var mRefOnMouseOver:Function;
protected var mClip:MovieClip;
private var mTotalFrames:int;
private var mRefOnMouseOut:Function;
private var mRefOnMouseUp:Function;
public function Actor(nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null){
super();
if (appInstance == null){
appInstance = Application.instance;
};
mApp = appInstance;
if (nameClip == ""){
mClip = new MovieClip();
} else {
mClip = mApp.getClip(nameClip);
};
if (mClip == null){
mClip = new MovieClip();
Application.error((("Clip :: " + nameClip) + " :: no found or not exported."), this);
};
mClip.stop();
mX = (mClip.x = x);
mY = (mClip.y = y);
mCurrentFrame = 0;
mTotalFrames = mClip.totalFrames;
mUseHandCursor = true;
loop = true;
}
private function _onMouseOut(e:MouseEvent):void{
if (mRefOnMouseOut != null){
mRefOnMouseOut(this);
};
}
public function set onMouseDown(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnMouseDown = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
} else {
mClip.removeEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
};
}
public function set onMouseUp(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnMouseUp = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.MOUSE_UP, _onMouseUp);
} else {
mClip.removeEventListener(MouseEvent.MOUSE_UP, _onMouseUp);
};
}
public function get useHandCursor():Boolean{
return (mUseHandCursor);
}
public function set useHandCursor(value:Boolean):void{
mUseHandCursor = value;
mClip.buttonMode = value;
mClip.useHandCursor = value;
}
private function _onMouseDown(e:MouseEvent):void{
if (mRefOnMouseDown != null){
mRefOnMouseDown(this);
};
}
private function _onClick(e:MouseEvent):void{
if (mRefOnClick != null){
mRefOnClick(this);
};
}
private function _onMouseMove(e:MouseEvent):void{
if (mRefOnMouseMove != null){
mRefOnMouseMove(this);
};
}
private function _onMouseOver(e:MouseEvent):void{
if (mRefOnMouseOver != null){
mRefOnMouseOver(this);
};
}
public function onKeyDown(keyCode:int):void{
}
public function update(dt:int):void{
mClip.x = mX;
mClip.y = mY;
mCurrentFrame++;
if (mClip){
mClip.gotoAndStop(mCurrentFrame);
};
if ((((mCurrentFrame == mTotalFrames)) && (loop))){
mCurrentFrame = 0;
};
}
public function onKeyUp(keyCode:int):void{
}
public function get clip():MovieClip{
return (mClip);
}
private function _onMouseUp(e:MouseEvent):void{
if (mRefOnMouseUp != null){
mRefOnMouseUp(this);
};
}
public function set onClick(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnClick = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.CLICK, _onClick);
} else {
mClip.removeEventListener(MouseEvent.CLICK, _onClick);
};
}
public function set onMouseOut(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnMouseOut = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.MOUSE_OUT, _onMouseOut);
} else {
mClip.removeEventListener(MouseEvent.MOUSE_OUT, _onMouseOut);
};
}
public function free():void{
mApp = null;
onClick = null;
onMouseDown = null;
onMouseOut = null;
onMouseOver = null;
onMouseUp = null;
onMouseMove = null;
mClip.parent.removeChild(mClip);
//unresolved jump
var _slot1 = e;
mClip = null;
}
public function set x(value:Number):void{
mX = value;
if (clip){
clip.x = mX;
};
}
public function set y(value:Number):void{
mY = value;
if (clip){
clip.y = mY;
};
}
public function set onMouseOver(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnMouseOver = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.MOUSE_OVER, _onMouseOver);
} else {
mClip.removeEventListener(MouseEvent.MOUSE_OVER, _onMouseOver);
};
}
public function set onMouseMove(f_Ref:Function):void{
if (mClip == null){
return;
};
mRefOnMouseMove = f_Ref;
if (f_Ref != null){
mClip.addEventListener(MouseEvent.MOUSE_MOVE, _onMouseMove);
} else {
mClip.removeEventListener(MouseEvent.MOUSE_MOVE, _onMouseMove);
};
}
public function get x():Number{
return (mX);
}
public function get y():Number{
return (mY);
}
}
}//package com.bamtang.swit.core
Section 70
//ActorBitmap (com.bamtang.swit.core.ActorBitmap)
package com.bamtang.swit.core {
public class ActorBitmap extends Actor {
private var mChangeTime:Number;
public var fps:Number;
private var mChangeTimeCounter:Number;
private var mSprGroup:SpriteGroup;
public function ActorBitmap(idSprites:Array, x:Number=0, y:Number=0, forceCenter:Boolean=false, framerate:int=24, appInstance:Application=null){
super("", x, y, appInstance);
mSprGroup = new SpriteGroup(mClip, idSprites, forceCenter, appInstance);
fps = framerate;
mChangeTime = (1 / fps);
mChangeTime = (mChangeTime * 1000);
mChangeTimeCounter = 0;
}
override public function update(dt:int):void{
mClip.x = mX;
mClip.y = mY;
mChangeTimeCounter = (mChangeTimeCounter + dt);
if (mChangeTimeCounter >= mChangeTime){
mChangeTimeCounter = 0;
mSprGroup.showNextClip();
};
}
override public function free():void{
mSprGroup.free();
mSprGroup = null;
super.free();
}
public function get totalSprites():int{
return (mSprGroup.sprites.length);
}
public function get currentSprite():int{
return (mSprGroup.currentIndex);
}
}
}//package com.bamtang.swit.core
Section 71
//Application (com.bamtang.swit.core.Application)
package com.bamtang.swit.core {
import flash.events.*;
import flash.display.*;
import com.bamtang.swit.modules.*;
import flash.media.*;
import com.bamtang.swit.data.*;
import com.bamtang.swit.utils.*;
public class Application {
private const DEPTH_CONSOLE:int = 100;
private const DEPTH_LOADER:int = 99;
private var mLoaderSWF:AssetLoader;
private var mLocalCode:String;
private var mSize:Number;
private var mMuteBg:Boolean;
private var mMuteFx:Boolean;
private var mAppName:String;
private var mUseConsole:Boolean;
private var mSoundManager:SoundManager;
private var mClipConsole:MovieClip;
private var mLoaderConfig:FileLoader;
private var mPathConsole:String;// = "root/Console.swf"
public var onLoadProcess:Function;
private var mStorage:Storage;
public var mClipLoader:MovieClip;
private var mDataSounds:Object;
private var mConsoleLoader:AssetLoader;
private var mLoader:LoaderManager;
private var mLayer:Layer;
public var onLoadComplete:Function;
private var mTexts:Array;
public static var APP_HEIGHT:int;
public static var APP_WIDTH:int;
public static var PATH_BASE:String;
private static var mConsole:Console;
public static var FRAMERATE:int;
public static var instance:Application;
public static var xmlConfig:XML;
public static var useLog:Boolean;
public static var QUALITY:String;
public function Application(urlConfig:String, canvas:DisplayObject){
super();
mLayer = new Layer(DisplayObjectContainer(canvas));
trace((canvas is Sprite));
mLoaderConfig = new FileLoader(urlConfig);
mLoaderConfig.onComplete = this.configLoaded;
mLoaderConfig.load();
mTexts = new Array();
mSoundManager = new SoundManager();
mDataSounds = new Object();
instance = this;
}
public function stopSoundsBgs():void{
var snd:String;
for (snd in mDataSounds) {
if (mDataSounds[snd].bg == 1){
mSoundManager.stopSound(snd);
};
};
}
public function stopAllSound():void{
stopSoundsFxs();
stopSoundsBgs();
}
public function get name():String{
return (mAppName);
}
public function stopSoundsFxs():void{
var snd:String;
for (snd in mDataSounds) {
if (mDataSounds[snd].bg == 0){
mSoundManager.stopSound(snd);
};
};
}
public function set muteFx(value:Boolean):void{
if (value){
stopSoundsFxs();
};
mMuteFx = value;
}
public function getData(id:String):Object{
var id = id;
return (mLoader.getData(id));
//unresolved jump
var _slot1 = e;
error((("Data id ::>>" + id) + "<<:: no found"), this);
return (null);
}
private function loadProcess(e:Event):void{
if (mClipLoader["txtLoading"] != null){
mClipLoader["txtLoading"].text = percentLoaded;
};
if (mClipLoader["mcBarLoading"] != null){
mClipLoader["mcBarLoading"].gotoAndStop(percentLoaded);
};
if (onLoadProcess != null){
onLoadProcess(this);
};
}
public function get percentLoaded():int{
if ((mLoader.bytesLoaded / mSize) > 1){
return (100);
} else {
return (Math.floor(((mLoader.bytesLoaded / mSize) * 100)));
};
//unresolved jump
var _slot1 = e;
return (0);
return (0);
}
public function getBitmap(id:String):Bitmap{
return (mLoader.getBitmap(id));
}
public function stopSound(id:String):void{
mSoundManager.stopSound(id);
}
public function getXMLData(id:String):XML{
var id = id;
return (new XML(mLoader.getData(id)));
//unresolved jump
var _slot1 = e;
error((("XML id ::>>" + id) + "<<:: no found"), this);
return (null);
}
public function removeLoader():void{
mClipLoader.removeEventListener(Event.ENTER_FRAME, loadProcess);
mLayer.removeChild(mClipLoader);
}
public function getDataScreen(idScreen:String):DataScreen{
var idScreen = idScreen;
var xmlScreen:XML;
xmlScreen = new XML(mLoader.getData(idScreen));
//unresolved jump
var _slot1 = e;
warn((("XML id ::>>" + idScreen) + "<<:: no found"), this);
var dataScreen:DataScreen;
if (xmlScreen != null){
dataScreen = readXmlScreen(idScreen, xmlScreen);
};
return (dataScreen);
}
private function consoleLoaded(assetLoad:AssetLoader):void{
mClipConsole = assetLoad.data.getClass("mcConsole");
if (mLayer){
mLayer.addChildAt(mClipConsole, DEPTH_CONSOLE);
};
Console.SCENE_WIDTH = APP_WIDTH;
Console.SCENE_HEIGHT = APP_HEIGHT;
mConsole = new Console(mClipConsole);
mLoader = new LoaderManager((PATH_BASE + xmlConfig.urls), mLocalCode);
mLoader.onLoadComplete = this.loadComplete;
log("*** DETAILS CONFIG.XML ****************************");
log(("Config :: localized = " + xmlConfig.localized), this);
log(("Config :: size = " + xmlConfig.size), this);
log(("Config :: pathBase = " + xmlConfig.pathBase), this);
log(("Config :: urls = " + xmlConfig.urls), this);
log(("Config :: appHeight = " + xmlConfig.appHeight), this);
log(("Config :: appWidth = " + xmlConfig.appWidth), this);
log(("Config :: frameRate = " + xmlConfig.frameRate), this);
log(("Config :: quality = " + xmlConfig.quality), this);
log(("Config :: traceLog = " + xmlConfig.traceLog), this);
log(("Config :: useConsole = " + xmlConfig.useConsole), this);
log(("Config :: loaderURL = " + xmlConfig.loaderURL), this);
log(("Config :: appName = " + xmlConfig.appName), this);
}
private function loadComplete():void{
var txt:String;
var soundsXML:XML;
var snd:String;
echo((("Application is loaded :: " + bytesLoaded) + " bytesLoaded"), this);
mStorage = new Storage(Common.replaceIn(mAppName.concat(), " ", "_"));
var textsXML:XML = getXMLData("texts");
for (txt in textsXML.text) {
mTexts[textsXML.text[txt].@id] = String(Common.replaceIn(textsXML.text[txt], "\\n", "\n").concat());
};
soundsXML = getXMLData("soundsIds");
for (snd in soundsXML.sound) {
mDataSounds[soundsXML.sound[snd].@linked] = new Object();
mDataSounds[soundsXML.sound[snd].@linked].bg = soundsXML.sound[snd].@bg;
mDataSounds[soundsXML.sound[snd].@linked].vol = soundsXML.sound[snd].@vol;
mSoundManager.createSoundObject(soundsXML.sound[snd].@linked, (getClass(soundsXML.sound[snd].@linked) as Sound));
};
if (onLoadComplete != null){
onLoadComplete();
};
}
public function getClip(id:String):MovieClip{
return ((mLoader.getClass(id) as MovieClip));
}
public function get muteFx():Boolean{
return (mMuteFx);
}
public function get muteBg():Boolean{
return (mMuteBg);
}
public function get layer():Layer{
return (mLayer);
}
public function getSprite(id:String, forceCenter:Boolean=false):MovieClip{
var id = id;
var forceCenter = forceCenter;
return (mLoader.getSprite(id, forceCenter));
//unresolved jump
var _slot1 = e;
error((("Sprite id [" + id) + "]:: no found"), this);
return (new MovieClip());
}
private function initLoaderClip(assetLoad:AssetLoader):void{
if (assetLoad != null){
mClipLoader = assetLoad.data.getClass("mcLoader");
} else {
mClipLoader = new MovieClip();
};
if (mLayer){
mLayer.addChildAt(mClipLoader, DEPTH_LOADER);
};
mClipLoader.addEventListener(Event.ENTER_FRAME, loadProcess, false, 0, true);
}
public function get bytesLoaded():int{
return (mLoader.bytesLoaded);
//unresolved jump
var _slot1 = e;
return (0);
return (0);
}
public function getSound(id:String):Sound{
return ((mLoader.getClass(id) as Sound));
}
public function getClass(id:String):Object{
return (mLoader.getClass(id));
}
public function getText(id:String):String{
return (mTexts[id]);
}
private function configLoaded(fileLoad:FileLoader):void{
xmlConfig = new XML(fileLoad.data);
mSize = Number(xmlConfig.size);
PATH_BASE = String(xmlConfig.pathBase);
APP_HEIGHT = int(xmlConfig.appHeight);
APP_WIDTH = int(xmlConfig.appWidth);
FRAMERATE = int(xmlConfig.frameRate);
QUALITY = String(xmlConfig.quality);
useLog = Boolean(int(xmlConfig.traceLog));
mUseConsole = Boolean(int(xmlConfig.useConsole));
mAppName = xmlConfig.appName;
if (mAppName == ""){
mAppName = "Application";
};
mLocalCode = xmlConfig.localized;
if (mUseConsole){
mConsoleLoader = new AssetLoader((PATH_BASE + mPathConsole));
mConsoleLoader.onComplete = this.consoleLoaded;
mConsoleLoader.load();
} else {
mLoader = new LoaderManager((PATH_BASE + xmlConfig.urls));
mLoader.onLoadComplete = this.loadComplete;
};
if (Boolean(String(xmlConfig.loaderURL).length)){
mLoaderSWF = new AssetLoader((PATH_BASE + xmlConfig.loaderURL));
mLoaderSWF.onComplete = this.initLoaderClip;
mLoaderSWF.load();
} else {
initLoaderClip(null);
};
}
public function playSound(id:String, loops:int=1):void{
if (!mDataSounds[id]){
error((("Sound :: " + id) + " :: no registered"), this);
return;
};
if (mDataSounds[id].bg == 0){
if (mMuteFx){
return;
};
mSoundManager.playSound(id, Number(mDataSounds[id].vol), loops);
} else {
if (mMuteBg){
return;
};
mSoundManager.playLoop(id, Number(mDataSounds[id].vol));
};
}
public function free():void{
mStorage = null;
}
private function readXmlScreen(idScreen:String, xmlScreen:XML):DataScreen{
var objDataPage:DataScreen;
var dataItemSprite:DataCtrSprite;
var dataItemButton:DataCtrButton;
var dataItemBox:DataCtrBox;
var dataItemText:DataCtrTextFont;
var s:String;
var item:XMLList;
var type:String;
var listSprites:Array = new Array();
var listButtons:Array = new Array();
var listBoxes:Array = new Array();
var listTexts:Array = new Array();
var items:XML = new XML(xmlScreen);
for (s in items.children()) {
item = items.child(int(s));
if (((!((item == null))) && (!((item.@id == null))))){
type = item.@type;
switch (type){
case "button":
dataItemButton = new DataCtrButton(item.@id, item.@x, item.@y, item.@depth, item.@idOut, item.@idOver, item.@idRelease, item.@idDisabled);
listButtons.push(dataItemButton);
break;
case "sprite":
dataItemSprite = new DataCtrSprite(item.@id, item.@x, item.@y, item.@depth, item.@idSprite);
listSprites.push(dataItemSprite);
break;
case "box":
dataItemBox = new DataCtrBox(item.@id, item.@x, item.@y, item.@depth, item.@width, item.@height, item.@color, item.@alpha, (item.@useHand == "1"));
listBoxes.push(dataItemBox);
break;
case "text":
dataItemText = new DataCtrTextFont(item.@id, item.@x, item.@y, item.@depth, item.@text, item.@font, Number(item.@size), Number(item.@color), item.@align, (item.@bold == "1"), (item.@italic == "1"), item.@glow, item.@shadow, Boolean(int(item.@forceCenter)));
listTexts.push(dataItemText);
break;
};
};
};
objDataPage = new DataScreen(idScreen, listButtons, listTexts, listBoxes, listSprites);
return (objDataPage);
}
public function getBitmapData(id:String, _width:int, _height:int):BitmapData{
var _class:Class = (mLoader.getClass(id, false) as Class);
return ((new _class(_width, _height) as BitmapData));
}
public function get storage():Storage{
return (mStorage);
}
public function set muteBg(value:Boolean):void{
if (value){
stopSoundsBgs();
};
mMuteBg = value;
}
public static function log(message, caller=""):void{
if (useLog){
trace(((("LOG::" + caller) + ">> ") + message));
if (mConsole){
mConsole.out(((("LOG::" + caller) + ">> ") + message), Console.TYPE_LOG);
};
};
}
public static function warn(message, caller=""):void{
trace(((("WARN::" + caller) + ">> ") + message));
if (mConsole){
mConsole.out(((("WARN::" + caller) + ">> ") + message), Console.TYPE_WARN);
};
}
public static function echo(message, caller=""):void{
trace(((caller + " >> ") + message));
if (mConsole){
mConsole.out(((caller + " >> ") + message), Console.TYPE_ECHO);
};
}
public static function error(message, caller=""):void{
trace(((("ERROR::" + caller) + ">> ") + message));
if (mConsole){
mConsole.out(((("ERROR::" + caller) + ">> ") + message), Console.TYPE_ERROR);
};
}
public static function showFPS():void{
if (mConsole){
mConsole.showFPS();
};
}
public static function logPlayer(message:String):void{
if (mConsole){
mConsole.logPlayer(message);
};
}
}
}//package com.bamtang.swit.core
Section 72
//BitmapManager (com.bamtang.swit.core.BitmapManager)
package com.bamtang.swit.core {
import flash.display.*;
import com.bamtang.swit.modules.*;
import com.bamtang.swit.data.*;
import flash.geom.*;
public class BitmapManager {
private var mDataUrl:Array;
private var mImagesData:Object;
private var mDataSprites:Object;
private var mData:XML;
public var onComplete:Function;
private var mBytesLoaded:Number;// = 0
public var onProgress:Function;
private var mPathLoacalized:String;
private var mAssetsLoaded:int;
private var mTotalToLoad:int;
public static var instance:BitmapManager;
public function BitmapManager(data:Object, pathLocal:String){
super();
mData = XML(data);
mDataUrl = new Array();
mDataSprites = new Object();
mImagesData = new Object();
mAssetsLoaded = 0;
mBytesLoaded = 0;
mPathLoacalized = pathLocal;
}
public function free():void{
var s:String;
var d:String;
instance = null;
onComplete = null;
onProgress = null;
mData = null;
var k:int;
while (k < mDataUrl.length) {
mDataUrl[k] = null;
k++;
};
mDataUrl = null;
for (s in mImagesData) {
mImagesData[s].free();
mImagesData[s] = null;
delete mImagesData[s];
};
mImagesData = null;
for (d in mDataSprites) {
mDataSprites[d] = null;
delete mImagesData[d];
};
mDataSprites = null;
}
public function completeLoad():void{
if (onComplete != null){
onComplete();
};
}
public function get bytesLoaded():Number{
return (mBytesLoaded);
}
public function checkProgress(asset:AssetLoader):void{
mBytesLoaded = (mBytesLoaded + asset.bytesLoaded);
}
public function getBitmap(spriteID:String):Bitmap{
return (Bitmap(mImagesData[mDataSprites[spriteID].id].data));
}
public function load():void{
mTotalToLoad = mData.asset.length();
if (mTotalToLoad == 0){
completeLoad();
} else {
nextLoad();
};
}
public function checkLoaded(asset:AssetLoader):void{
mAssetsLoaded++;
Application.log(("Success file loaded :: " + asset.url));
if (mAssetsLoaded < mTotalToLoad){
nextLoad();
} else {
completeLoad();
};
}
private function nextLoad():void{
var asset:int;
var sprite:int;
var id:String;
var url:String;
var assetID:String;
var dimensions:String;
var dataSprite:DataSprite;
var dataUrl:DataUrl;
var imagesLength:int = mData.asset.length();
asset = 0;
while (asset < imagesLength) {
sprite = 0;
while (sprite < mData.asset[asset].sprite.length()) {
id = mData.asset[asset].@id;
assetID = mData.asset[asset].sprite[sprite].@id;
dimensions = mData.asset[asset].sprite[sprite].@dim;
dataSprite = new DataSprite(id, assetID, dimensions);
mDataSprites[dataSprite.idAsset] = dataSprite;
sprite++;
};
url = (Application.PATH_BASE + String(mData.asset[asset].@url).replace("%localCode", mPathLoacalized));
dataUrl = new DataUrl(id, "img", url);
mDataUrl.push(dataUrl);
asset++;
};
loadImages();
}
public function getSprite(spriteID:String, forceCenter:Boolean=false):MovieClip{
var bitmap:Bitmap;
var sourceBitmapData:BitmapData;
var newBitmapData:BitmapData;
var dataSprite:DataSprite;
var clip:MovieClip = new MovieClip();
dataSprite = mDataSprites[spriteID];
bitmap = Bitmap(mImagesData[dataSprite.id].data);
sourceBitmapData = bitmap.bitmapData;
newBitmapData = new BitmapData(dataSprite.drawWidth, dataSprite.drawHeight, true);
newBitmapData.copyPixels(sourceBitmapData, new Rectangle(dataSprite.drawX, dataSprite.drawY, dataSprite.drawWidth, dataSprite.drawHeight), new Point(0, 0));
bitmap = new Bitmap(newBitmapData);
if (forceCenter){
clip.x = (-(bitmap.width) / 2);
clip.y = (-(bitmap.height) / 2);
};
clip.addChild(bitmap);
return (clip);
}
private function loadImages():void{
var id:String;
var index:int;
var urlLength:int = mDataUrl.length;
id = String(mDataUrl[mAssetsLoaded].id);
mImagesData[id] = new AssetLoader(mDataUrl[mAssetsLoaded].path);
mImagesData[id].id = id;
mImagesData[id].onComplete = this.checkLoaded;
mImagesData[id].onProgress = this.checkProgress;
mImagesData[id].load();
}
}
}//package com.bamtang.swit.core
Section 73
//Character (com.bamtang.swit.core.Character)
package com.bamtang.swit.core {
import flash.display.*;
public class Character {
public var toDie:Boolean;
protected var mCurrentActor;
protected var mX:Number;
protected var mY:Number;
protected var mLastFrame:int;
protected var mOnMouseDown:Function;
protected var mUseHandCursor:Boolean;
protected var mCurrentState:String;
protected var mAppInstance:Application;
protected var mCanvas:MovieClip;
protected var mFunctions:Array;
protected var mOnMouseOut:Function;
protected var mOnClick:Function;
protected var mOnMouseOver:Function;
protected var mStates:Array;
protected var mOnMouseUp:Function;
protected var mOnMouseMove:Function;
public var onEndAnimation:Function;
public function Character(x:Number, y:Number, canvas:MovieClip, appInstance:Application=null){
super();
mAppInstance = appInstance;
mStates = new Array();
mFunctions = new Array();
mX = x;
mY = y;
mCanvas = canvas;
}
protected function endAnimation():void{
if (onEndAnimation != null){
onEndAnimation(mCurrentState);
};
}
public function set onMouseUp(value:Function):void{
if (mCurrentActor){
mCurrentActor.onMouseUp = value;
};
mOnMouseUp = value;
}
public function addState(idState:String, idSymbol:String, ... _args):void{
mStates[idState] = idSymbol;
if (_args.length > 0){
mFunctions[idState] = _args;
} else {
mFunctions[idState] = null;
};
}
public function set onMouseDown(value:Function):void{
if (mCurrentActor){
mCurrentActor.onMouseDown = value;
};
mOnMouseDown = value;
}
public function get state():String{
return (mCurrentState);
}
public function get useHandCursor():Boolean{
return (mUseHandCursor);
}
public function set useHandCursor(value:Boolean):void{
if (mCurrentActor){
mCurrentActor.useHandCursor = value;
};
mUseHandCursor = value;
}
public function onKeyUp(keyCode:int):void{
}
public function get onMouseUp():Function{
return (mOnMouseUp);
}
public function onKeyDown(keyCode:int):void{
}
public function set loop(value:Boolean):void{
if (mCurrentActor){
mCurrentActor.loop = value;
};
}
public function update(dt:int):void{
var k:int;
if (mCurrentActor != null){
mCurrentActor.x = mX;
mCurrentActor.y = mY;
mCurrentActor.update(dt);
if (mLastFrame == mCurrentActor.clip.currentFrame){
endAnimation();
};
};
if (mFunctions[mCurrentState] != null){
k = 0;
while (k < mFunctions[mCurrentState].length) {
if (((!((mFunctions[mCurrentState][k][0] == null))) && ((mFunctions[mCurrentState][k][1] == mCurrentActor.clip.currentFrame)))){
var _local3 = mFunctions[mCurrentState][k];
_local3[0]();
};
k++;
};
};
}
public function get onMouseDown():Function{
return (mOnMouseDown);
}
public function set onClick(value:Function):void{
if (mCurrentActor){
mCurrentActor.onClick = value;
};
mOnClick = value;
}
public function set onMouseOut(value:Function):void{
if (mCurrentActor){
mCurrentActor.onMouseOut = value;
};
mOnMouseOut = value;
}
public function get onClick():Function{
return (mOnClick);
}
public function free():void{
var s:String;
if (mCurrentActor){
mCurrentActor.free();
};
mOnClick = null;
mOnMouseDown = null;
mOnMouseUp = null;
mOnMouseOver = null;
mOnMouseOut = null;
mOnMouseMove = null;
mCurrentActor = null;
mCurrentState = null;
mCanvas = null;
mAppInstance = null;
for (s in mStates) {
mStates[s] = null;
delete mStates[s];
};
for (s in mFunctions) {
mFunctions[s] = null;
delete mFunctions[s];
};
mFunctions = null;
mStates = null;
}
public function set onMouseMove(value:Function):void{
if (mCurrentActor){
mCurrentActor.onMouseMove = value;
};
mOnMouseMove = value;
}
public function set x(value:Number):void{
mX = value;
if (mCurrentActor){
mCurrentActor.x = mX;
};
}
public function set y(value:Number):void{
mY = value;
if (mCurrentActor){
mCurrentActor.y = mY;
};
}
public function set onMouseOver(value:Function):void{
if (mCurrentActor){
mCurrentActor.onMouseOver = value;
};
mOnMouseOver = value;
}
public function get actor():Actor{
return (mCurrentActor);
}
public function get onMouseMove():Function{
return (mOnMouseMove);
}
public function get y():Number{
return (mY);
}
public function get onMouseOver():Function{
return (mOnMouseOver);
}
public function gotoState(idState:String):void{
if (mStates[idState] == null){
Application.error((("State ::" + idState) + ":: no registered"), this);
return;
};
mCurrentState = idState;
if (mCurrentActor){
mCurrentActor.free();
};
mCurrentActor = null;
mCurrentActor = new Actor(mStates[idState], mX, mY, mAppInstance);
mCanvas.addChild(mCurrentActor.clip);
mLastFrame = mCurrentActor.clip.totalFrames;
mCurrentActor.onClick = mOnClick;
mCurrentActor.onMouseDown = mOnMouseDown;
mCurrentActor.onMouseUp = mOnMouseUp;
mCurrentActor.onMouseOver = mOnMouseOver;
mCurrentActor.onMouseOut = mOnMouseOut;
mCurrentActor.onMouseMove = mOnMouseMove;
mCurrentActor.useHandCursor = mUseHandCursor;
}
public function get x():Number{
return (mX);
}
}
}//package com.bamtang.swit.core
Section 74
//DataManager (com.bamtang.swit.core.DataManager)
package com.bamtang.swit.core {
import com.bamtang.swit.modules.*;
import com.bamtang.swit.data.*;
public class DataManager {
private var mBytesLoaded:Number;// = 0
private var mXMLtoLoad:Array;
public var onProgress:Function;
private var mFilesLoaded:int;
private var mXMLsData:Object;
private var mTotalToLoad:int;
public var onComplete:Function;
public static var instance:DataManager;
public function DataManager(){
super();
mXMLsData = new Object();
mXMLtoLoad = new Array();
mFilesLoaded = 0;
mBytesLoaded = 0;
instance = this;
}
public function getData(id:String):Object{
return (mXMLsData[id].data);
}
public function completeLoad():void{
if (onComplete != null){
onComplete();
};
}
public function get bytesLoaded():Number{
return (mBytesLoaded);
}
public function addUrl(dataUrl:DataUrl):void{
mXMLtoLoad.push(dataUrl);
}
public function checkLoaded(file:FileLoader):void{
mFilesLoaded++;
Application.log(("Succes file loaded :: " + file.url));
if (mFilesLoaded < mTotalToLoad){
nextLoad();
} else {
completeLoad();
};
}
public function load():void{
mTotalToLoad = mXMLtoLoad.length;
if (mTotalToLoad == 0){
completeLoad();
} else {
nextLoad();
};
}
private function nextLoad():void{
var id:String = String(mXMLtoLoad[mFilesLoaded].id).concat();
mXMLsData[id] = new FileLoader(mXMLtoLoad[mFilesLoaded].path, mXMLtoLoad[mFilesLoaded].type);
mXMLsData[id].id = id;
mXMLsData[id].onComplete = this.checkLoaded;
mXMLsData[id].onProgress = this.checkProgress;
mXMLsData[id].load();
}
public function free():void{
var s:String;
instance = null;
onComplete = null;
onProgress = null;
var k:int;
while (k < mXMLtoLoad.length) {
mXMLtoLoad[k] = null;
k++;
};
mXMLtoLoad = null;
for (s in mXMLsData) {
mXMLsData[s].free();
mXMLsData[s] = null;
delete mXMLsData[s];
};
mXMLsData = null;
}
public function checkProgress(file:FileLoader):void{
mBytesLoaded = (mBytesLoaded + file.bytesLoaded);
}
}
}//package com.bamtang.swit.core
Section 75
//Effect (com.bamtang.swit.core.Effect)
package com.bamtang.swit.core {
import flash.display.*;
public class Effect {
private var mRepeat:int;
public var toDie:Boolean;
private var mActor:Actor;
public var onEndAnimation:Function;
private var mLoop:int;
public function Effect(nameClip:String, x:int, y:int, canvas:MovieClip, loop:int=1, appInstance:Application=null){
super();
mActor = new Actor(nameClip, x, y, appInstance);
canvas.addChild(mActor.clip);
mLoop = loop;
mRepeat = 0;
}
public function update(dt:int):void{
mActor.update(dt);
if (mActor.clip.currentFrame == mActor.clip.totalFrames){
mRepeat++;
if (mRepeat >= mLoop){
mActor.clip.stop();
toDie = true;
if (onEndAnimation != null){
onEndAnimation();
};
};
};
}
public function free():void{
onEndAnimation = null;
mActor.free();
mActor = null;
}
public function get actor():Actor{
return (mActor);
}
}
}//package com.bamtang.swit.core
Section 76
//EffectBitmap (com.bamtang.swit.core.EffectBitmap)
package com.bamtang.swit.core {
import flash.display.*;
public class EffectBitmap {
public var toDie:Boolean;
private var mRepeat:int;
public var onEndAnimation:Function;
private var mLoop:int;
private var mActorBitmap:ActorBitmap;
private var mLastFrame:int;
public function EffectBitmap(idSprites:Array, x:int, y:int, canvas:MovieClip, loop:int=1, forceCenter:Boolean=false, fps:int=24, appInstance:Application=null){
super();
mActorBitmap = new ActorBitmap(idSprites, x, y, forceCenter, fps, appInstance);
canvas.addChild(mActorBitmap.clip);
mLastFrame = (mActorBitmap.totalSprites - 1);
mLoop = loop;
mRepeat = 0;
}
public function update(dt:int):void{
mActorBitmap.update(dt);
if (mLastFrame == mActorBitmap.currentSprite){
mRepeat++;
if (mRepeat == mLoop){
toDie = true;
if (onEndAnimation != null){
onEndAnimation();
};
};
};
}
public function free():void{
onEndAnimation = null;
mActorBitmap.free();
mActorBitmap = null;
}
public function get actor():ActorBitmap{
return (mActorBitmap);
}
}
}//package com.bamtang.swit.core
Section 77
//EffectManager (com.bamtang.swit.core.EffectManager)
package com.bamtang.swit.core {
import flash.display.*;
public class EffectManager {
private var mCanvas:MovieClip;
private var mAppInstance:Application;
private var mEffects:List;
public function EffectManager(canvas:MovieClip, appInstance:Application=null){
super();
mEffects = new List();
mCanvas = canvas;
mAppInstance = appInstance;
}
public function update(dt:int):void{
mEffects.update(dt);
}
public function addFxBitmap(idSprites:Array, x:int, y:int, loop:int=1, canvas:MovieClip=null, forceCenter:Boolean=false, fps:int=24, onEndAnimation:Function=null):EffectBitmap{
if (canvas == null){
canvas = mCanvas;
};
var tempEffect:EffectBitmap = new EffectBitmap(idSprites, x, y, canvas, loop, forceCenter, fps, mAppInstance);
tempEffect.onEndAnimation = onEndAnimation;
mEffects.add(tempEffect);
return (tempEffect);
}
public function add(nameClip:String, x:int, y:int, canvas:MovieClip=null, loop:int=1, onEndAnimation:Function=null):Effect{
var tempEffect:Effect;
if (canvas == null){
canvas = mCanvas;
};
tempEffect = new Effect(nameClip, x, y, canvas, loop, mAppInstance);
tempEffect.onEndAnimation = onEndAnimation;
mEffects.add(tempEffect);
return (tempEffect);
}
public function free():void{
mAppInstance = null;
mEffects.free();
mEffects = null;
}
}
}//package com.bamtang.swit.core
Section 78
//Layer (com.bamtang.swit.core.Layer)
package com.bamtang.swit.core {
import flash.display.*;
import flash.utils.*;
public class Layer {
private const DEPTH_RESERVED:int = 1048575;
private const DEPTH_LOWEST:int = -16383;
private const DEPTH_HIGHEST:int = 2130690045;
private var _container:DisplayObjectContainer;
private var _dict:Dictionary;
private var mDepth:Number;
public function Layer(container:DisplayObjectContainer):void{
var child:DisplayObject;
super();
mDepth = 0;
_container = container;
_dict = new Dictionary(true);
var len:int = _container.numChildren;
var i:int;
while (i < len) {
child = _container.getChildAt(i);
_dict[i] = child;
_dict[child] = i;
i++;
};
}
public function setDepth(child:DisplayObject, depth:int):void{
var index:int;
var child = child;
var depth = depth;
if ((((depth < DEPTH_LOWEST)) || ((depth > DEPTH_HIGHEST)))){
trace(((":>ERROR: " + depth) + " is over limit of depth"));
};
if (_dict[child] == depth){
return;
};
var child0:DisplayObject = getInstanceAtDepth(depth);
if (child0 != null){
swapChildren(child, child0);
} else {
index = searchIndex(depth);
delete _dict[_dict[child]];
_dict[child] = depth;
_dict[depth] = child;
if (_container.getChildIndex(child) < index){
_container.setChildIndex(child, (index - 1));
} else {
_container.setChildIndex(child, index);
};
//unresolved jump
var _slot1 = e;
};
}
public function getInstanceAtDepth(depth:int){
return (_dict[depth]);
}
private function searchIndex(depth:int):int{
var left:int;
var right:int;
var index:int;
var child:DisplayObject;
if (_container.numChildren > 0){
left = 0;
right = (_container.numChildren - 1);
index = right;
child = _container.getChildAt(index);
if (depth <= _dict[_container.getChildAt(0)]){
return (0);
};
if (_dict[child] < depth){
return ((index + 1));
};
while (_dict[child] != depth) {
if (index == left){
index = (index + ((_dict[child])<depth) ? 1 : 0);
break;
} else {
if (depth < _dict[child]){
right = index;
index = ((left + right) >> 1);
} else {
if (_dict[child] < depth){
left = index;
index = ((left + right) >> 1);
} else {
break;
};
};
};
child = _container.getChildAt(index);
};
return (index);
//unresolved jump
};
return (0);
}
public function getDepth(child:DisplayObject):int{
return (_dict[child]);
}
public function removeChildAt(depth:int){
var child:DisplayObject = _dict[depth];
if (child == null){
trace(((":>ERROR: " + depth) + " is over limit of depth"));
};
delete _dict[child];
delete _dict[depth];
return (_container.removeChild(child));
}
public function clear():void{
var child:String;
for (child in _dict) {
if ((_dict[child] is DisplayObject)){
removeChild(_dict[child]);
};
};
}
public function get clip():MovieClip{
return ((_container as MovieClip));
}
public function free():void{
clear();
_container = null;
_dict = null;
}
public function addChildAt(child:DisplayObject, depth:int){
var child0:DisplayObject;
var index:int = searchIndex(depth);
if (index < _container.numChildren){
child0 = _container.getChildAt(index);
if (_dict[child0] == depth){
removeChild(child0);
};
};
_dict[depth] = child;
_dict[child] = depth;
return (_container.addChildAt(child, index));
}
public function addEmptyChild(){
return (addChild(new MovieClip()));
}
public function addEmptyChildAt(depth:int){
return (addChildAt(new MovieClip(), depth));
}
public function swapChildren(child1:DisplayObject, child2:DisplayObject):void{
var child1 = child1;
var child2 = child2;
if (child1 == child2){
return;
};
var depth:int = _dict[child1];
_dict[child1] = _dict[child2];
_dict[child2] = depth;
_dict[_dict[child1]] = child1;
_dict[_dict[child2]] = child2;
_container.swapChildren(child1, child2);
//unresolved jump
var _slot1 = e;
}
public function removeChild(child:DisplayObject):void{
delete _dict[_dict[child]];
delete _dict[child];
_container.removeChild(child);
}
public function addChild(child:DisplayObject){
mDepth++;
return (addChildAt(child, mDepth));
}
public function show(value:Boolean):void{
_container.visible = value;
}
}
}//package com.bamtang.swit.core
Section 79
//List (com.bamtang.swit.core.List)
package com.bamtang.swit.core {
public class List {
private var mErrorRemoveDie:Boolean;
private var mIsIterate:Boolean;
private var mErrorUpdate:Boolean;
protected var mItems:Array;
private var mIndexIterate:int;
private var mIndex:int;
private var mLen:int;
public var removeToDie:Boolean;
public function List(){
super();
mItems = new Array();
removeToDie = true;
}
public function get items():Array{
return (mItems);
}
public function get firtsItem(){
return (mItems[0]);
}
public function remove(item):Boolean{
var index:int = mItems.indexOf(item);
if (index == -1){
return (false);
};
removeAt(index);
return (true);
}
public function clear():void{
var k:int;
for (;k < mItems.length;(mItems[k] = null), mItems.splice(k, 1), (k = (k - 1)), (k = (k + 1))) {
mItems[k].free();
continue;
var _slot1 = e;
};
}
public function addUnique(item, last:Boolean=true):Boolean{
if (mItems.indexOf(item) == -1){
if (last){
mItems.push(item);
} else {
mItems.unshift(item);
};
return (true);
};
return (false);
}
public function removeAt(index:int):void{
var index = index;
try {
mItems[index].free();
} catch(e:Error) {
Application.warn(e.message, this);
};
try {
mItems[index] = null;
} catch(e:Error) {
Application.warn(e.message, this);
};
mItems.splice(index, 1);
if (mIsIterate){
mIndexIterate--;
};
}
public function get lastItem(){
return (mItems[(mItems.length - 1)]);
}
public function get size():int{
return (mItems.length);
}
public function add(item, last:Boolean=true):void{
if (last){
mItems.push(item);
} else {
mItems.unshift(item);
};
}
public function reverse():void{
mItems.reverse();
}
public function update(dt:int):void{
var dt = dt;
mLen = mItems.length;
mIndex = 0;
for (;mIndex < mLen;mIndex++) {
mItems[mIndex].update(dt);
//unresolved jump
var _slot1 = e;
if (!mErrorUpdate){
Application.warn(("ErrorUpdate : " + _slot1.message), this);
mErrorUpdate = true;
};
if (removeToDie){
if (mItems[mIndex].isAwaitingDelete){
mItems[mIndex].free();
mItems[mIndex] = null;
mItems.splice(mIndex, 1);
mIndex--;
mLen--;
};
continue;
var _slot1 = e;
if (!mErrorRemoveDie){
Application.warn(_slot1.message, this);
mErrorRemoveDie = true;
};
};
};
}
public function free():void{
clear();
mItems = null;
}
public function existItem(item):Boolean{
if (mItems.indexOf(item) == -1){
return (false);
};
return (true);
}
public function iterate(callback:Function):void{
mIsIterate = true;
mIndexIterate = 0;
while (mIndexIterate < mItems.length) {
callback(mItems[mIndexIterate], mIndexIterate);
mIndexIterate++;
};
callback = null;
mIsIterate = false;
}
}
}//package com.bamtang.swit.core
Section 80
//LoaderManager (com.bamtang.swit.core.LoaderManager)
package com.bamtang.swit.core {
import flash.display.*;
import com.bamtang.swit.modules.*;
import com.bamtang.swit.data.*;
public class LoaderManager {
private var mClipLoader:MovieClip;
private var mBitmapManager:BitmapManager;
private var mFileData:FileLoader;
private var mSwfManager:SwfManager;
private var mPathLoacalized:String;// = "en-US"
private var mDataManager:DataManager;
public var onLoadComplete:Function;
private static const TYPE_XML:String = "xml";
private static const TYPE_SWF:String = "swf";
private static const TYPE_IMG:String = "img";
private static const TYPE_BIN:String = "bin";
public static var instance:LoaderManager;
public function LoaderManager(urls:String="", localCode:String="en-US"){
super();
if (urls != ""){
mFileData = new FileLoader(urls);
mFileData.onComplete = this.fileDataLoaded;
mFileData.load();
mPathLoacalized = localCode;
instance = this;
};
}
public function getClass(id:String, instantiate:Boolean=true):Object{
return (mSwfManager.getClass(id, instantiate));
}
public function free():void{
instance = null;
mDataManager.free();
mDataManager = null;
mSwfManager.free();
mSwfManager = null;
}
private function loadComplete():void{
if (onLoadComplete != null){
onLoadComplete();
};
}
private function onLoadDataComplete():void{
mSwfManager.onComplete = this.onLoadAssetComplete;
mSwfManager.load();
}
public function get swfManager():SwfManager{
return (mSwfManager);
}
private function onLoadImagesComplete():void{
loadComplete();
}
public function get bytesLoaded():Number{
var bytesBitmap:int;
if (mBitmapManager){
bytesBitmap = mBitmapManager.bytesLoaded;
};
return (((mDataManager.bytesLoaded + mSwfManager.bytesLoaded) + bytesBitmap));
}
private function onLoadAssetComplete():void{
mBitmapManager = new BitmapManager(mDataManager.getData("mainImageAssets"), mPathLoacalized);
mBitmapManager.onComplete = this.onLoadImagesComplete;
mBitmapManager.load();
//unresolved jump
var _slot1 = e;
Application.warn("URL [mainImageAssets.xml] no loaded", this);
onLoadImagesComplete();
}
public function get dataManager():DataManager{
return (mDataManager);
}
public function getBitmap(id:String):Bitmap{
return (mBitmapManager.getBitmap(id));
}
public function getData(id:String):Object{
return (mDataManager.getData(id));
}
private function fileDataLoaded(file:FileLoader):void{
var tempData:DataUrl;
var s:String;
var child:XMLList;
mDataManager = new DataManager();
mSwfManager = new SwfManager();
var URLList:XML = new XML(file.data);
for (s in URLList.children()) {
child = URLList.child(int(s));
tempData = new DataUrl();
tempData.id = child.attribute("id");
tempData.type = child.attribute("type");
tempData.path = (Application.PATH_BASE + String(child.attribute("path")).replace("%localCode", mPathLoacalized));
switch (tempData.type){
case TYPE_XML:
tempData.type = FileLoader.FORMAT_TEXT;
mDataManager.addUrl(tempData);
break;
case TYPE_IMG:
tempData.type = FileLoader.FORMAT_TEXT;
mDataManager.addUrl(tempData);
break;
case TYPE_BIN:
tempData.type = FileLoader.FORMAT_BINARY;
mDataManager.addUrl(tempData);
break;
case TYPE_SWF:
mSwfManager.addUrl(tempData);
break;
default:
Application.error((((("Type no found '" + tempData.type) + "'") + " url : ") + tempData.path), "LoaderManager");
break;
};
};
Application.log("*** DETAILS EXTERNAL FILES **********************");
mDataManager.onComplete = this.onLoadDataComplete;
mDataManager.load();
}
public function getSprite(id:String, forceCenter:Boolean=false):MovieClip{
return (mBitmapManager.getSprite(id, forceCenter));
}
public function getContentSWF(id:String):MovieClip{
return (mSwfManager.getSWF(id));
}
}
}//package com.bamtang.swit.core
Section 81
//Screen (com.bamtang.swit.core.Screen)
package com.bamtang.swit.core {
import flash.display.*;
import com.bamtang.swit.data.*;
import com.bamtang.swit.controls.*;
import flash.utils.*;
public class Screen {
protected var mX:Number;
protected var mY:Number;
protected var mBoxes:Array;
protected var mButtons:Array;
protected var mClip:MovieClip;
protected var mSprites:Array;
protected var mLayer:Layer;
protected var mId:String;
protected var mTextFonts:Array;
public var screenParent:Screen;
protected var mPopup:Screen;
public function Screen(nameClip:String="", x:Number=0, y:Number=0, appInstance:Application=null){
super();
if (appInstance == null){
appInstance = Application.instance;
};
mClip = ((nameClip)=="") ? new MovieClip() : appInstance.getClip(nameClip);
if (mClip == null){
Application.error((("Clip " + nameClip) + " no found "));
mClip = new MovieClip();
};
mLayer = new Layer((mClip.addChild(new MovieClip()) as DisplayObjectContainer));
mX = (mClip.x = x);
mY = (mClip.y = y);
mBoxes = new Array();
mButtons = new Array();
mTextFonts = new Array();
mSprites = new Array();
loadControls(appInstance);
}
protected function removeTextFont(id:String):void{
if (mTextFonts[id]){
mTextFonts[id].free();
mTextFonts[id] = null;
delete mTextFonts[id];
};
}
public function onActivate(activate:Boolean):void{
if (mPopup){
mPopup.onActivate(activate);
};
}
public function free():void{
var id:String;
mLayer.free();
var size:Number = mSprites.length;
for (id in mSprites) {
removeSprite(id);
};
mSprites = null;
id = null;
for (id in mButtons) {
removeButton(id);
};
mButtons = null;
id = null;
for (id in mBoxes) {
removeBox(id);
};
id = null;
mBoxes = null;
for (id in mTextFonts) {
removeTextFont(id);
};
mTextFonts = null;
dropPopup();
screenParent = null;
mLayer = null;
mClip.parent.removeChild(mClip);
//unresolved jump
var _slot1 = e;
mClip = null;
}
protected function addSprite(id:String, idSprite:String, x1:Number, y1:Number, depth:Number, forceCenter:Boolean=false):void{
var obj:MovieClip = Application.instance.getSprite(idSprite);
obj.x = x1;
obj.y = y1;
mLayer.addChildAt(obj, depth);
mSprites[id] = obj;
}
public function update(dt:int):void{
if (mPopup){
mPopup.update(dt);
};
}
protected function getSprite(id:String):MovieClip{
return ((mSprites[id] as MovieClip));
}
public function get layer():Layer{
return (mLayer);
}
public function addPopup(classInstanceOf, nameClip:String, x:Number=0, y:Number=0, appInstance:Application=null):void{
dropPopup();
mPopup = new classInstanceOf(nameClip, x, y, appInstance);
mPopup.screenParent = this;
mClip.addChild(mPopup.clip);
}
public function get clip():MovieClip{
return (mClip);
}
protected function getTextFont(id:String):TextFont{
return ((mTextFonts[id] as TextFont));
}
public function onKeyDown(keyCode:int):void{
if (mPopup){
mPopup.onKeyDown(keyCode);
};
}
protected function getBox(id:String):Box{
return ((mBoxes[id] as Box));
}
protected function addButton(id:String, idOut:String, idOver:String, idRelease:String, idDisabled:String, x1:Number, y1:Number, depth:Number):void{
var obj:Button = new Button(idOut, idOver, idRelease, idDisabled);
obj.setPosition(x1, y1);
mLayer.addChildAt(obj.clip, depth);
mButtons[id] = obj;
}
protected function removeButton(id:String):void{
if (mButtons[id]){
mButtons[id].free();
mButtons[id] = null;
delete mButtons[id];
};
}
protected function removeBox(id:String):void{
if (mBoxes[id]){
mBoxes[id].free();
mBoxes[id] = null;
delete mBoxes[id];
};
}
protected function removeSprite(id:String):void{
if (mSprites[id]){
mSprites[id] = null;
delete mSprites[id];
};
}
public function set x(value:Number):void{
mX = value;
if (clip){
clip.x = mX;
};
}
protected function addBox(id:String, color:Number, width:Number, height:Number, alpha:Number, useHand:Boolean, x1:Number, y1:Number, depth:Number):void{
var obj:Box = new Box(color, width, height, alpha, useHand);
obj.setPosition(x1, y1);
mLayer.addChildAt(obj.clip, depth);
mBoxes[id] = obj;
}
public function set y(value:Number):void{
mY = value;
if (clip){
clip.y = mY;
};
}
public function get popup():Screen{
return (mPopup);
}
protected function addTextFont(id:String, idFont:String, text:String, size:Number=0, color:Number=0, align:String="left", bold:Boolean=false, italic:Boolean=false, paramGlow:String="0", paramShadow:String="0", spacing:Number=1, x1:Number=0, y1:Number=0, depth:Number=0, forceCenter:Boolean=false):void{
var pGlow:Array;
var pShadow:Array;
var obj:TextFont = new TextFont(idFont, text, size, color, align, bold, italic, spacing);
if (paramGlow != "0"){
pGlow = paramGlow.split(",");
if (pGlow.length > 1){
obj.applyGlow(Number(pGlow[0]), Number(pGlow[1]));
};
};
if (paramShadow != "0"){
pShadow = paramShadow.split(",");
if (pShadow.length > 1){
obj.applyShadow(Number(pShadow[0]), Number(pShadow[1]), Number(pShadow[2]), Number(pShadow[3]));
};
};
obj.setPosition(x1, y1);
obj.forceCenter = forceCenter;
obj.mouseEnabled = false;
mLayer.addChildAt(obj.clip, depth);
mTextFonts[id] = obj;
}
protected function getButton(id:String):Button{
return ((mButtons[id] as Button));
}
public function get x():Number{
return (mX);
}
public function get y():Number{
return (mY);
}
public function onKeyUp(keyCode:int):void{
if (mPopup){
mPopup.onKeyUp(keyCode);
};
}
private function loadControls(appInstance:Application):void{
var size:int;
var k:int;
var dtBox:DataCtrBox;
var dtButton:DataCtrButton;
var dtSprite:DataCtrSprite;
var dtText:DataCtrTextFont;
var nameCompleteClass:String = getQualifiedClassName(this);
var nameClass:String = nameCompleteClass.split("::")[1];
var dataScreen:DataScreen = appInstance.getDataScreen(nameClass);
if (dataScreen != null){
size = dataScreen.boxes.length;
k = 0;
while (k < size) {
dtBox = (dataScreen.boxes[k] as DataCtrBox);
addBox(dtBox.id, dtBox.color, dtBox.width, dtBox.height, dtBox.alpha, dtBox.useHand, dtBox.x, dtBox.y, dtBox.depth);
k++;
};
size = dataScreen.buttons.length;
k = 0;
while (k < size) {
dtButton = (dataScreen.buttons[k] as DataCtrButton);
addButton(dtButton.id, dtButton.idOut, dtButton.idOver, dtButton.idRelease, dtButton.idDisabled, dtButton.x, dtButton.y, dtButton.depth);
k++;
};
size = dataScreen.sprites.length;
k = 0;
while (k < size) {
dtSprite = (dataScreen.sprites[k] as DataCtrSprite);
addSprite(dtSprite.id, dtSprite.idSprite, dtSprite.x, dtSprite.y, dtSprite.depth);
k++;
};
size = dataScreen.textfonts.length;
k = 0;
while (k < size) {
dtText = (dataScreen.textfonts[k] as DataCtrTextFont);
addTextFont(dtText.id, dtText.font, dtText.text, dtText.size, dtText.color, dtText.align, dtText.bold, dtText.italic, dtText.glow, dtText.shadow, 1, dtText.x, dtText.y, dtText.depth, dtText.forceCenter);
k++;
};
};
}
public function dropPopup():void{
if (mPopup){
mPopup.free();
};
mPopup = null;
}
}
}//package com.bamtang.swit.core
Section 82
//ScreenManager (com.bamtang.swit.core.ScreenManager)
package com.bamtang.swit.core {
import flash.display.*;
public class ScreenManager {
protected var mCurrentScreenName:String;
protected var mCanvas:MovieClip;
protected var mCurrentScreen:Screen;
public function ScreenManager(canvas:MovieClip){
super();
mCanvas = canvas;
}
public function onKeyDown(keyCode:int):void{
if (mCurrentScreen){
mCurrentScreen.onKeyDown(keyCode);
};
}
public function free():void{
if (mCurrentScreen){
mCurrentScreen.free();
};
mCanvas = null;
mCurrentScreen = null;
mCurrentScreenName = null;
}
public function update(dt:int):void{
if (mCurrentScreen){
mCurrentScreen.update(dt);
};
}
public function get currentScreen():Screen{
return (mCurrentScreen);
}
public function gotoScreen(idScreen:String, params:Object=null):void{
if (mCurrentScreen){
mCurrentScreen.free();
};
mCurrentScreen = null;
mCurrentScreenName = idScreen;
Application.log(("GO TO SCREEN :: " + idScreen));
}
public function onActivate(activate:Boolean):void{
if (mCurrentScreen){
mCurrentScreen.onActivate(activate);
};
}
public function get currentScreenName():String{
return (mCurrentScreenName);
}
public function onKeyUp(keyCode:int):void{
if (mCurrentScreen){
mCurrentScreen.onKeyUp(keyCode);
};
}
}
}//package com.bamtang.swit.core
Section 83
//SpriteGroup (com.bamtang.swit.core.SpriteGroup)
package com.bamtang.swit.core {
import flash.display.*;
public class SpriteGroup {
public var mSpriteClips:Array;
public var mCurrentIndex:int;
public var layer:Layer;
public function SpriteGroup(canvas:MovieClip, spriteIds:Array, forcedCenter:Boolean=false, appInstance:Application=null){
var mc:MovieClip;
super();
if (appInstance == null){
appInstance = Application.instance;
};
layer = new Layer(canvas);
mSpriteClips = new Array();
var i:int;
while (i < spriteIds.length) {
mc = layer.addChild(appInstance.getSprite(spriteIds[i], forcedCenter));
mSpriteClips.push(mc);
mc.visible = false;
i++;
};
var tempW:int = canvas.width;
var tempH:int = canvas.height;
var tempX:int;
var tempY:int;
if (forcedCenter){
tempW = (canvas.width * 0.5);
tempH = (canvas.height * 0.5);
tempX = (-(canvas.width) * 0.5);
tempY = (-(canvas.height) * 0.5);
};
mc = layer.addEmptyChild();
mc.graphics.beginFill(0);
mc.graphics.drawRect(tempX, tempY, tempW, tempH);
mc.graphics.endFill();
mc.alpha = 0;
showClipIn(0);
mCurrentIndex = 0;
}
public function get currentIndex():int{
return (mCurrentIndex);
}
public function showNextClip():void{
if (mCurrentIndex >= (mSpriteClips.length - 1)){
showClipIn(0);
} else {
showClipIn((mCurrentIndex + 1));
};
}
public function showClipIn(index:Number):void{
if (index >= mSpriteClips.length){
return;
};
mSpriteClips[mCurrentIndex].visible = false;
mSpriteClips[index].visible = true;
mCurrentIndex = index;
}
public function free():void{
layer.free();
layer = null;
var i:int;
while (i < mSpriteClips.length) {
mSpriteClips[i] = null;
i++;
};
mSpriteClips = null;
}
public function get sprites():Array{
return (mSpriteClips);
}
}
}//package com.bamtang.swit.core
Section 84
//SwfManager (com.bamtang.swit.core.SwfManager)
package com.bamtang.swit.core {
import flash.display.*;
import com.bamtang.swit.modules.*;
import com.bamtang.swit.data.*;
public class SwfManager {
public var onComplete:Function;
private var mXMLsData:Object;
private var mBytesLoaded:Number;// = 0
private var mXMLtoLoad:Array;
public var onProgress:Function;
private var mFilesLoaded:int;
private var mTotalToLoad:int;
public static var instance:SwfManager;
public function SwfManager(){
super();
mXMLtoLoad = new Array();
mXMLsData = new Array();
mFilesLoaded = 0;
mBytesLoaded = 0;
instance = this;
}
public function getClass(nameClass:String, instantiate:Boolean=true):Object{
var s:String;
var tempClass:Object;
var nameClass = nameClass;
var instantiate = instantiate;
for (s in mXMLsData) {
tempClass = mXMLsData[s].data.getClass(nameClass, instantiate);
if (tempClass != null){
return (tempClass);
};
//unresolved jump
var _slot1 = e;
};
Application.error((("Definiton Class ::" + nameClass) + ":: no found"), this);
return (null);
}
public function getSWF(id:String):MovieClip{
return (mXMLsData[id].data);
}
public function addUrl(dataUrl:DataUrl):void{
mXMLtoLoad.push(dataUrl);
}
public function addAsset():void{
}
public function get bytesLoaded():Number{
return (mBytesLoaded);
}
public function checkProgress(file:AssetLoader):void{
mBytesLoaded = (mBytesLoaded + file.bytesLoaded);
}
public function checkLoaded(file:AssetLoader):void{
mFilesLoaded++;
Application.log(("Succes file loaded :: " + file.url));
if (mFilesLoaded < mTotalToLoad){
nextLoad();
} else {
completeLoad();
};
}
public function load():void{
mTotalToLoad = mXMLtoLoad.length;
nextLoad();
}
private function nextLoad():void{
var id:String = String(mXMLtoLoad[mFilesLoaded].id).concat();
mXMLsData[id] = new AssetLoader(mXMLtoLoad[mFilesLoaded].path);
mXMLsData[id].id = id;
mXMLsData[id].onComplete = this.checkLoaded;
mXMLsData[id].onProgress = this.checkProgress;
mXMLsData[id].load();
}
public function free():void{
var s:String;
instance = null;
onComplete = null;
onProgress = null;
var k:int;
while (k < mXMLtoLoad.length) {
mXMLtoLoad[k] = null;
k++;
};
mXMLtoLoad = null;
for (s in mXMLsData) {
mXMLsData[s].free();
mXMLsData[s] = null;
delete mXMLsData[s];
};
mXMLsData = null;
}
private function completeLoad():void{
if (onComplete != null){
onComplete();
};
}
}
}//package com.bamtang.swit.core
Section 85
//DataCtrBox (com.bamtang.swit.data.DataCtrBox)
package com.bamtang.swit.data {
public class DataCtrBox {
public var depth:Number;
public var width:Number;
public var height:Number;
public var color:Number;
public var x:Number;
public var y:Number;
public var id:String;
public var useHand:Boolean;
public var alpha:Number;
public function DataCtrBox(_id:String, x1:Number, y1:Number, depth:Number, width1:Number, height1:Number, color1:Number, alpha1:Number, useHand1:Boolean){
super();
id = _id;
x = x1;
y = y1;
this.depth = depth;
width = width1;
height = height1;
color = color1;
alpha = alpha1;
useHand = useHand1;
}
}
}//package com.bamtang.swit.data
Section 86
//DataCtrButton (com.bamtang.swit.data.DataCtrButton)
package com.bamtang.swit.data {
public class DataCtrButton {
public var depth:Number;
public var idRelease:String;
public var idOver:String;
public var idOut:String;
public var idDisabled:String;
public var x:Number;
public var y:Number;
public var id:String;
public function DataCtrButton(_id:String, _x1:Number, _y1:Number, depth:Number, _idOut:String, _idOver:String, _idRelease:String, _idDisabled:String){
super();
id = _id;
x = _x1;
y = _y1;
this.depth = depth;
idOut = _idOut;
idOver = _idOver;
idRelease = _idRelease;
idDisabled = _idDisabled;
}
}
}//package com.bamtang.swit.data
Section 87
//DataCtrSprite (com.bamtang.swit.data.DataCtrSprite)
package com.bamtang.swit.data {
public class DataCtrSprite {
public var depth:Number;
public var idSprite:String;
public var x:Number;
public var y:Number;
public var id:String;
public function DataCtrSprite(_id:String, _x1:Number, _y1:Number, depth:Number, _idSprite:String){
super();
id = _id;
x = _x1;
y = _y1;
this.depth = depth;
idSprite = _idSprite;
}
}
}//package com.bamtang.swit.data
Section 88
//DataCtrTextFont (com.bamtang.swit.data.DataCtrTextFont)
package com.bamtang.swit.data {
public class DataCtrTextFont {
public var size:Number;
public var depth:Number;
public var align:String;
public var bold:Boolean;
public var font:String;
public var glow:String;
public var id:String;
public var color:Number;
public var shadow:String;
public var text:String;
public var forceCenter:Boolean;
public var italic:Boolean;
public var x:Number;
public var y:Number;
public function DataCtrTextFont(_id:String, _x1:Number, _y1:Number, depth:Number, _text:String, _font:String, _size:Number, _color:Number, _align:String, _bold:Boolean, _italic:Boolean, _glow:String="", _shadow:String="", _forceCenter:Boolean=false){
super();
id = _id;
x = _x1;
y = _y1;
this.depth = depth;
text = _text;
font = _font;
size = _size;
color = _color;
align = _align;
bold = _bold;
italic = _italic;
shadow = _shadow;
glow = _glow;
forceCenter = _forceCenter;
}
}
}//package com.bamtang.swit.data
Section 89
//DataScreen (com.bamtang.swit.data.DataScreen)
package com.bamtang.swit.data {
public class DataScreen {
public var buttons:Array;
public var sprites:Array;
public var textfonts:Array;
public var boxes:Array;
public var id:String;
public function DataScreen(id:String, buttons:Array, textfonts:Array, boxes:Array, sprites:Array){
super();
this.id = id;
this.buttons = buttons;
this.textfonts = textfonts;
this.boxes = boxes;
this.sprites = sprites;
}
}
}//package com.bamtang.swit.data
Section 90
//DataSprite (com.bamtang.swit.data.DataSprite)
package com.bamtang.swit.data {
public class DataSprite {
public var drawWidth:Number;
public var drawHeight:Number;
public var drawX:Number;
public var idAsset:String;
public var id:String;
public var drawY:Number;
public function DataSprite(id:String, idAsset:String, dimension:String){
super();
this.id = id;
this.idAsset = idAsset;
var dim:Array = dimension.split(",");
drawX = dim[0];
drawY = dim[1];
drawWidth = (dim[2] - drawX);
drawHeight = (dim[3] - drawY);
}
}
}//package com.bamtang.swit.data
Section 91
//DataUrl (com.bamtang.swit.data.DataUrl)
package com.bamtang.swit.data {
public class DataUrl {
public var type:String;
public var path:String;
public var id:String;
public function DataUrl(id:String="", type:String="", path:String=""){
super();
this.id = id;
this.type = type;
this.path = path;
}
}
}//package com.bamtang.swit.data
Section 92
//Bezier (com.bamtang.swit.math.Bezier)
package com.bamtang.swit.math {
import flash.geom.*;
public class Bezier {
private var timeElapse:Number;
public var speed:Number;
public var position:Point;
private var mXPoints:Array;
public function Bezier(points:Array, speed:Number){
super();
mXPoints = points;
timeElapse = 0;
this.speed = speed;
}
public function update(dt:int):void{
timeElapse = (timeElapse + speed);
position = pointInBezier(mXPoints, timeElapse);
}
private function pointInBezier(points:Array, t:Number):Point{
var cx:Number = (3 * (points[1].x - points[0].x));
var bx:Number = ((3 * (points[2].x - points[1].x)) - cx);
var ax:Number = (((points[3].x - points[0].x) - cx) - bx);
var cy:Number = (3 * (points[1].y - points[0].y));
var by:Number = ((3 * (points[2].y - points[1].y)) - cy);
var ay:Number = (((points[3].y - points[0].y) - cy) - by);
var result:Point = new Point();
result.x = ((((((ax * t) * t) * t) + ((bx * t) * t)) + (cx * t)) + points[0].x);
result.y = ((((((ay * t) * t) * t) + ((by * t) * t)) + (cy * t)) + points[0].y);
return (result);
}
}
}//package com.bamtang.swit.math
Section 93
//Vector2D (com.bamtang.swit.math.Vector2D)
package com.bamtang.swit.math {
public class Vector2D {
public var y:Number;
public var x:Number;
public function Vector2D(xc:Number=0, yc:Number=0){
super();
x = xc;
y = yc;
}
public function add(b:Vector2D):void{
x = (x + b.x);
y = (y + b.y);
}
public function length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function dot(b:Vector2D):Number{
return (((x * b.x) + (y * b.y)));
}
public function scale(scale:Number):void{
x = (x * scale);
y = (y * scale);
}
public function toString():String{
return (((("V2D: x=" + x) + " y=") + y));
}
public function normalize():void{
var vectorLength:Number = length();
if (vectorLength > 0){
x = (x / vectorLength);
y = (y / vectorLength);
} else {
trace("[WARN]: Vector2D.normalize: called on a zero-length vector.");
};
}
public function projectionOn(b:Vector2D):Vector2D{
var squareLength:Number = b.dot(b);
if (squareLength == 0){
trace("[WARN] Vector2D.projectionOn: zero-length projection vector.");
return (this.clone());
};
var ret:Vector2D = b.clone();
ret.scale((this.dot(b) / squareLength));
return (ret);
}
public function subtract(b:Vector2D):void{
x = (x - b.x);
y = (y - b.y);
}
public function copy(b:Vector2D):void{
x = b.x;
y = b.y;
}
public function minus(b:Vector2D):Vector2D{
return (new Vector2D((x - b.x), (y - b.y)));
}
public function orthogonal():Vector2D{
return (new Vector2D(-(y), x));
}
public function plus(b:Vector2D):Vector2D{
return (new Vector2D((x + b.x), (y + b.y)));
}
public function componentOn(b:Vector2D):Number{
var val:Number = b.dot(b);
if (val == 0){
trace("[WARN] Vector2D.componentOn: zero-length projection vector.");
return (0);
};
val = (this.dot(b) / val);
return (((val)<0) ? -(val) : val);
}
public function clone():Vector2D{
return (new Vector2D(x, y));
}
public function udir():Vector2D{
var ret:Vector2D = clone();
ret.normalize();
return (ret);
}
}
}//package com.bamtang.swit.math
Section 94
//AssetLoader (com.bamtang.swit.modules.AssetLoader)
package com.bamtang.swit.modules {
import flash.events.*;
import com.bamtang.swit.core.*;
import flash.display.*;
import flash.net.*;
public class AssetLoader {
private var mRequest:URLRequest;
private var mUrl:String;
public var onProgress:Function;// = null
private var mLoader:Loader;
public var bytesLoaded:Number;// = 0
public var onComplete:Function;// = null
public var bytesTotal:Number;// = 0
public var id:String;
public function AssetLoader(url:String){
super();
mUrl = url;
}
private function completeEvent(e:Event):void{
if (onComplete != null){
onComplete(this);
};
mLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressEvent);
mLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeEvent);
mLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorEvent);
}
public function load(saveCache:Boolean=false):void{
var saveCache = saveCache;
mLoader = new Loader();
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressEvent);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeEvent);
mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorEvent);
mRequest = new URLRequest(url);
if (!saveCache){
mRequest.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
mRequest.method = URLRequestMethod.POST;
mRequest.data = new URLVariables(("time=" + Number(new Date().getTime())));
};
mLoader.load(mRequest);
//unresolved jump
var _slot1 = e;
Application.error(_slot1.message, this);
}
public function get data():Object{
return (mLoader.contentLoaderInfo.content);
}
private function progressEvent(e:ProgressEvent):void{
bytesLoaded = e.bytesLoaded;
bytesTotal = e.bytesTotal;
if (onProgress != null){
onProgress(this);
};
}
public function free():void{
onComplete = null;
onProgress = null;
mRequest = null;
mLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressEvent);
mLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeEvent);
mLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorEvent);
//unresolved jump
var _slot1 = e;
mLoader.unload();
mLoader = null;
}
private function errorEvent(e:IOErrorEvent):void{
Application.error(("Process Load :: " + e.text), "AssetLoader");
}
public function get url():String{
return (mUrl);
}
}
}//package com.bamtang.swit.modules
Section 95
//FileLoader (com.bamtang.swit.modules.FileLoader)
package com.bamtang.swit.modules {
import flash.events.*;
import com.bamtang.swit.core.*;
import flash.net.*;
public class FileLoader {
public var dataFormat:String;// = "text"
private var mUrl:String;
public var bytesLoaded:Number;// = 0
public var bytesTotal:Number;// = 0
public var id:String;// = ""
private var mRequest:URLRequest;
public var onProgress:Function;// = null
private var mURLLoader:URLLoader;
public var onComplete:Function;// = null
public static const FORMAT_VARS:String = "variables";
public static const FORMAT_TEXT:String = "text";
public static const FORMAT_BINARY:String = "binary";
public function FileLoader(url:String, dataFormat:String="text"){
super();
this.dataFormat = dataFormat;
mUrl = url;
}
private function completeEvent(e:Event):void{
if (onComplete != null){
onComplete(this);
};
mURLLoader.removeEventListener(Event.COMPLETE, completeEvent);
mURLLoader.removeEventListener(IOErrorEvent.IO_ERROR, errorEvent);
mURLLoader.removeEventListener(ProgressEvent.PROGRESS, progressEvent);
}
public function load(saveCache:Boolean=false):void{
mURLLoader = new URLLoader();
mURLLoader.dataFormat = this.dataFormat;
mURLLoader.addEventListener(ProgressEvent.PROGRESS, progressEvent);
mURLLoader.addEventListener(Event.COMPLETE, completeEvent);
mURLLoader.addEventListener(IOErrorEvent.IO_ERROR, errorEvent);
mRequest = new URLRequest(mUrl);
if (!saveCache){
mRequest.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
mRequest.method = URLRequestMethod.POST;
mRequest.data = new URLVariables(("time=" + Number(new Date().getTime())));
};
mURLLoader.load(mRequest);
}
public function get data():Object{
return (mURLLoader.data);
}
private function progressEvent(e:ProgressEvent):void{
bytesLoaded = e.bytesLoaded;
bytesTotal = e.bytesTotal;
if (onProgress != null){
onProgress(this);
};
}
public function get url():Object{
return (mUrl);
}
private function errorEvent(e:IOErrorEvent):void{
Application.error(e.text, "FileLoader");
}
public function free():void{
onComplete = null;
onProgress = null;
mRequest = null;
mURLLoader.removeEventListener(ProgressEvent.PROGRESS, progressEvent);
mURLLoader.removeEventListener(Event.COMPLETE, completeEvent);
mURLLoader.removeEventListener(IOErrorEvent.IO_ERROR, errorEvent);
//unresolved jump
var _slot1 = e;
mURLLoader = null;
}
}
}//package com.bamtang.swit.modules
Section 96
//SoundManager (com.bamtang.swit.modules.SoundManager)
package com.bamtang.swit.modules {
import com.bamtang.swit.core.*;
import flash.media.*;
import flash.utils.*;
public class SoundManager {
private var isPlaying:Array;
private var soundChannels:Array;
private var soundList:Array;
private var MAX_LOOP:Number;// = 99999999
public function SoundManager():void{
super();
soundList = new Array();
soundChannels = new Array();
isPlaying = new Array();
}
public function free():void{
var id:String;
stopAllSound();
for (id in soundChannels) {
soundChannels[id] = null;
delete soundChannels[id];
};
for (id in isPlaying) {
isPlaying[id] = null;
delete isPlaying[id];
};
soundChannels = null;
isPlaying = null;
}
public function stopAllSound():void{
var id:String;
for (id in soundChannels) {
stopSound(id);
};
}
public function createSoundObject(id:String, sound:Sound):void{
soundList[id] = sound;
isPlaying[id] = false;
}
private function createSound(id:String):Boolean{
var classDefinition:Class;
var id = id;
classDefinition = (getDefinitionByName(id) as Class);
soundList[id] = (new (classDefinition) as Sound);
isPlaying[id] = (false as Boolean);
return (true);
//unresolved jump
var _slot1 = e;
Application.error((("Sound class ::" + id) + ":: no found"), this);
return (false);
return (false);
}
public function stopSound(id:String):void{
if (soundChannels[id]){
soundChannels[id].stop();
isPlaying[id] = false;
};
}
public function playLoop(id:String, vol:Number=1):void{
if (((!((isPlaying[id] == null))) && ((isPlaying[id] == false)))){
playSound(id, vol, MAX_LOOP);
};
}
public function playSound(id:String, vol:Number=1, loops:int=1):void{
var transform:SoundTransform;
if (soundList[id] == undefined){
if (!createSound(id)){
return;
};
};
var soundChannel:SoundChannel = soundList[id].play(0, loops);
isPlaying[id] = true;
if (vol != 1){
transform = soundChannel.soundTransform;
transform.volume = vol;
soundChannel.soundTransform = transform;
};
soundChannels[id] = soundChannel;
}
}
}//package com.bamtang.swit.modules
Section 97
//Storage (com.bamtang.swit.modules.Storage)
package com.bamtang.swit.modules {
import flash.net.*;
public class Storage {
private var mSharedObject:SharedObject;
public function Storage(a_name:String):void{
super();
mSharedObject = SharedObject.getLocal(a_name);
}
public function saveObject(a_key:String, a_value:Object):void{
mSharedObject.data[a_key] = a_value;
flush();
}
public function flush():void{
mSharedObject.flush();
}
public function loadObject(a_key:String, a_defaultValue:Object):Object{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return ((mSharedObject.data[a_key] as Object));
}
public function saveNumber(a_key:String, a_value:Number):void{
mSharedObject.data[a_key] = a_value;
flush();
}
public function loadInt(a_key:String, a_defaultValue:int):int{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (int(mSharedObject.data[a_key]));
}
public function saveBoolean(a_key:String, a_value:Boolean):void{
mSharedObject.data[a_key] = a_value;
flush();
}
public function clear():void{
mSharedObject.clear();
}
public function saveString(a_key:String, a_value:String):void{
mSharedObject.data[a_key] = a_value;
flush();
}
public function loadNumber(a_key:String, a_defaultValue:Number):Number{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (Number(mSharedObject.data[a_key]));
}
public function saveInt(a_key:String, a_value:int):void{
mSharedObject.data[a_key] = a_value;
flush();
}
public function loadString(a_key:String, a_defaultValue:String):String{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (String(mSharedObject.data[a_key]));
}
public function loadArray(a_key:String, a_defaultValue:Array):Array{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return ((mSharedObject.data[a_key] as Array));
}
public function loadBoolean(a_key:String, a_defaultValue:Boolean):Boolean{
if (mSharedObject.data[a_key] == null){
mSharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (Boolean(mSharedObject.data[a_key]));
}
public function saveArray(a_key:String, a_value:Array):void{
mSharedObject.data[a_key] = a_value;
flush();
}
}
}//package com.bamtang.swit.modules
Section 98
//Camera (com.bamtang.swit.platform.Camera)
package com.bamtang.swit.platform {
import flash.display.*;
public class Camera {
protected var mX:Number;
protected var mY:Number;
protected var mWorld:World;
protected var mFixedX:Boolean;
protected var mFixedY:Boolean;
protected var mParallaxX:Boolean;
protected var mParallaxY:Boolean;
protected var mUpLimit:Number;
protected var mLefLimit:Number;
protected var mScreenX:int;
protected var mScreenY:int;
protected var mCollision:Sprite;// = null
protected var mDownLimit:Number;
protected var mRightLimit:Number;
protected var mWidth:int;
protected var mHeight:int;
public function Camera(world:World, width:int, height:int, positionScreenX:int=0, positionScreenY:int=0){
super();
mWorld = world;
mWidth = width;
mHeight = height;
mX = 0;
mY = 0;
mScreenX = positionScreenX;
mScreenY = positionScreenY;
mFixedX = (mWorld.config.cameraXMin == mWorld.config.cameraXMax);
mLefLimit = (mWorld.config.cameraXMin * mWidth);
mRightLimit = (mWorld.config.cameraXMax * mWidth);
mFixedY = (mWorld.config.cameraYMax == mWorld.config.cameraYMin);
mUpLimit = (mWorld.config.cameraYMin * mHeight);
mDownLimit = (mWorld.config.cameraYMax * mHeight);
mParallaxY = (mWorld.height > mHeight);
mParallaxX = (mWorld.width > mWidth);
}
public function setScale(val:Number):void{
mWorld.canvas.scaleX = val;
mWorld.canvas.scaleY = val;
}
public function get parallaxX():Boolean{
return (mParallaxX);
}
public function get parallaxY():Boolean{
return (mParallaxY);
}
public function get height():int{
return (mHeight);
}
public function get downLimit():Number{
return (mDownLimit);
}
public function showCollision(show:Boolean):void{
if (!mCollision){
mCollision = new Sprite();
mCollision.graphics.lineStyle(0.5, 0xFF0000);
mCollision.graphics.moveTo(0, 0);
mCollision.graphics.lineTo(0, mHeight);
mCollision.graphics.lineTo(mWidth, mHeight);
mCollision.graphics.lineTo(mWidth, 0);
mCollision.graphics.lineTo(0, 0);
mWorld.canvas.addChild(mCollision);
};
mCollision.visible = show;
}
public function get width():int{
return (mWidth);
}
public function update(dt:int):void{
if (mFixedX){
mX = (mWorld.player.x - mLefLimit);
} else {
if ((mX + mLefLimit) > mWorld.player.x){
mX = (mWorld.player.x - mLefLimit);
};
if ((mX + mRightLimit) < mWorld.player.x){
mX = (mWorld.player.x - mRightLimit);
};
};
if (mFixedY){
mY = (mWorld.player.x - mUpLimit);
} else {
if ((mY + mUpLimit) > mWorld.player.y){
mY = (mWorld.player.y - mUpLimit);
};
if ((mY + mDownLimit) < mWorld.player.y){
mY = (mWorld.player.y - mDownLimit);
};
};
if (mX < 0){
mX = 0;
} else {
if (mX > (mWorld.width - mWidth)){
mX = (mWorld.width - mWidth);
};
};
if (mY < 0){
mY = 0;
} else {
if (mY > (mWorld.height - mHeight)){
mY = (mWorld.height - mHeight);
};
};
}
public function get scale():Number{
return (mWorld.canvas.scaleX);
}
public function set screenX(val:int):void{
mScreenX = val;
}
public function set screenY(val:int):void{
mScreenY = val;
}
public function get upLimit():Number{
return (mUpLimit);
}
public function get screenX():int{
return (mScreenX);
}
public function get screenY():int{
return (mScreenY);
}
public function set x(val:Number):void{
mX = val;
}
public function set y(val:Number):void{
mY = val;
}
public function free():void{
if (mCollision){
mWorld.canvas.removeChild(mCollision);
mCollision = null;
};
mWorld = null;
}
public function get x():Number{
return (mX);
}
public function get y():Number{
return (mY);
}
}
}//package com.bamtang.swit.platform
Section 99
//CollisionLayer (com.bamtang.swit.platform.CollisionLayer)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import flash.geom.*;
import com.bamtang.swit.math.*;
public class CollisionLayer extends PlatformLayer {
private var mPlatforms:Array;
private var mFrames:Array;
private var mTileX:Number;
private var mTileY:Number;
public static const CELL_FULL:int = 1;
public static const CELL_DIAG_UP_RIGHT:int = 3;
public static const CELL_EMPTY:int = 0;
private static const MAX_VY_SPEED_PLATFORM:int = 2;
public static const CELL_DIAG_UP_LEFT:int = 2;
private static const COLLISION_SET:String = "mc_set_collision_";
public static const CELL_DIAG_DOWN_RIGHT:int = 4;
public static const CELL_UP_LEFT_0_90:int = 9;
public static const CELL_UP_LEFT_0_75:int = 8;
private static const MIN_VY_FRICTION:int = -2;
public static const CELL_DIAG_DOWN_LEFT:int = 5;
public static const CELL_UP_LEFT_75_90:int = 7;
public static const CELL_PLATFORM:int = 6;
public function CollisionLayer(world:World, layerData:PlatformLayerData){
super(world, layerData);
mCanvas.visible = false;
mFrames = new Array();
var k:int = CELL_EMPTY;
while (k <= CELL_UP_LEFT_0_90) {
mFrames.push((COLLISION_SET + k));
k++;
};
mPlatforms = new Array();
}
public function getFloorCollision(x:Number, y:Number):Vector2D{
var ty:int = (y / mDataLayer.tileHeight);
var tx:int = (x / mDataLayer.tileWidth);
while (ty < mDataLayer.height) {
if (getCell(tx, ty) != CELL_EMPTY){
return (new Vector2D(x, (ty * mDataLayer.tileHeight)));
};
ty++;
};
Application.warn("getFloorCollision: no floor found");
return (new Vector2D(x, y));
}
public function getRayCollision(x:Number, y:Number, dir:Vector2D):Vector2D{
var ty:int = (y / mDataLayer.tileHeight);
var tx:int = (x / mDataLayer.tileWidth);
while (ty < mDataLayer.height) {
if (getCell(tx, ty) != CELL_EMPTY){
return (new Vector2D(x, (ty * mDataLayer.tileHeight)));
};
ty++;
};
return (null);
}
override protected function get parallaxX():Number{
return (mWorld.camera.x);
}
override protected function get parallaxY():Number{
return (mWorld.camera.y);
}
public function checkCollision(px:Number, py:Number, normal:Vector2D, actor:PlatformActor):Vector2D{
var dx:Number;
var dy:Number;
mTileX = Math.floor((px / mDataLayer.tileWidth));
mTileY = Math.floor((py / mDataLayer.tileHeight));
switch (getCell(mTileX, mTileY)){
case CELL_PLATFORM:
if (normal.y > 0){
if ((((normal.x > 0)) && ((getCell(mTileX, (mTileY - 1)) == CELL_DIAG_UP_LEFT)))){
dy = (px - (mTileX * mDataLayer.tileWidth));
return (new Vector2D(0, (((mTileY * mDataLayer.tileHeight) - py) - dy)));
};
if ((((normal.x < 0)) && ((getCell(mTileX, (mTileY - 1)) == CELL_DIAG_UP_RIGHT)))){
dy = (((mTileX + 1) * mDataLayer.tileWidth) - px);
return (new Vector2D(0, (((mTileY * mDataLayer.tileHeight) - py) - dy)));
};
if ((((actor.speed.y > 0)) && ((getCell(mTileX, (mTileY - 1)) == CELL_EMPTY)))){
if ((((actor.speed.y < MAX_VY_SPEED_PLATFORM)) && (((py - (mTileY * mDataLayer.tileHeight)) > (0.5 * mDataLayer.tileHeight))))){
return (null);
};
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
};
break;
case CELL_DIAG_UP_RIGHT:
dx = (px - (mTileX * mDataLayer.tileWidth));
dy = (py - (mTileY * mDataLayer.tileWidth));
if (dx < dy){
dx = ((dy - dx) / 2);
return (new Vector2D(dx, -(dx)));
};
break;
case CELL_DIAG_UP_LEFT:
dx = (((mTileX + 1) * mDataLayer.tileWidth) - px);
dy = (py - (mTileY * mDataLayer.tileWidth));
if (dx < dy){
dx = ((dy - dx) / 2);
return (new Vector2D(-(dx), -(dx)));
};
break;
case CELL_FULL:
if (normal.x == 0){
if (normal.y > 0){
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
return (new Vector2D(0, (((mTileY + 1) * mDataLayer.tileHeight) - py)));
} else {
if (normal.y == 0){
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
if (normal.x > 0){
if (getCell((mTileX - 1), mTileY) == CELL_EMPTY){
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), 0));
};
} else {
if (getCell((mTileX + 1), mTileY) == CELL_EMPTY){
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), 0));
};
};
} else {
if (normal.y > 0){
if (normal.x > 0){
if (getCell(mTileX, (mTileY - 1)) == CELL_DIAG_UP_LEFT){
dy = (px - (mTileX * mDataLayer.tileWidth));
return (new Vector2D(0, (((mTileY * mDataLayer.tileHeight) - py) - dy)));
};
if (getCell(mTileX, (mTileY - 1)) == CELL_FULL){
if (getCell((mTileX - 1), mTileY) == CELL_FULL){
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), ((mTileY * mDataLayer.tileHeight) - py)));
};
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), 0));
} else {
if (getCell((mTileX - 1), mTileY) == CELL_FULL){
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
if ((py - (mTileY * mDataLayer.tileHeight)) > (px - (mTileX * mDataLayer.tileWidth))){
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), 0));
} else {
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
};
} else {
if (getCell(mTileX, (mTileY - 1)) == CELL_DIAG_UP_RIGHT){
dy = (((mTileX + 1) * mDataLayer.tileWidth) - px);
return (new Vector2D(0, (((mTileY * mDataLayer.tileHeight) - py) - dy)));
};
if (getCell(mTileX, (mTileY - 1)) == CELL_FULL){
if (getCell((mTileX + 1), mTileY) == CELL_FULL){
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), ((mTileY * mDataLayer.tileHeight) - py)));
};
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), 0));
} else {
if (getCell((mTileX + 1), mTileY) == CELL_FULL){
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
if ((py - (mTileY * mDataLayer.tileHeight)) > (((mTileX + 1) * mDataLayer.tileWidth) - px)){
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), 0));
} else {
return (new Vector2D(0, ((mTileY * mDataLayer.tileHeight) - py)));
};
};
};
} else {
if (normal.x > 0){
if (getCell(mTileX, (mTileY + 1)) == CELL_FULL){
if (getCell((mTileX - 1), mTileY) == CELL_FULL){
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), 0));
} else {
if (getCell((mTileX - 1), mTileY) == CELL_FULL){
return (new Vector2D(0, (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
if ((((mTileY + 1) * mDataLayer.tileHeight) - py) > (px - (mTileX * mDataLayer.tileWidth))){
actor.setFallingOverWall(true);
return (new Vector2D(((mTileX * mDataLayer.tileWidth) - px), 0));
};
return (new Vector2D(0, (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
} else {
if (getCell(mTileX, (mTileY + 1)) == CELL_FULL){
if (getCell((mTileX + 1), mTileY) == CELL_FULL){
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), 0));
} else {
if (getCell((mTileX + 1), mTileY) == CELL_FULL){
return (new Vector2D(0, (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
if ((((mTileY + 1) * mDataLayer.tileHeight) - py) > (((mTileX + 1) * mDataLayer.tileWidth) - px)){
if (actor.speed.y >= MIN_VY_FRICTION){
actor.setFallingOverWall(true);
};
return (new Vector2D((((mTileX + 1) * mDataLayer.tileWidth) - px), 0));
} else {
return (new Vector2D(0, (((mTileY + 1) * mDataLayer.tileHeight) - py)));
};
};
};
};
};
};
break;
};
return (null);
}
override protected function addTileCell(tileX:int, tileY:int, bufferX:int, bufferY:int):void{
var tile:MovieClip;
var cell:int = getCell(tileX, tileY);
if (cell > CELL_EMPTY){
tile = Global.app.getClip(mFrames[cell]);
tile.cacheAsBitmap = true;
tile.x = (tileX * mDataLayer.tileWidth);
tile.y = (tileY * mDataLayer.tileHeight);
setBufferCell(bufferX, bufferY, tile);
mCanvas.addChild(tile);
};
}
override protected function initCell(kx:int, ky:int):void{
var cell:int;
var tile:MovieClip;
if (mWorld.config.showCollisions){
cell = getCell((kx + mMinX), (ky + mMinY));
if (cell > CELL_EMPTY){
tile = Global.app.getClip(mFrames[cell]);
tile.cacheAsBitmap = true;
tile.x = ((kx + mMinX) * mDataLayer.tileWidth);
tile.y = ((ky + mMinY) * mDataLayer.tileHeight);
setBufferCell(kx, ky, tile);
mCanvas.addChild(tile);
};
};
}
public function addPlatform(platform:PlatformActor):void{
mPlatforms.push(platform);
}
override public function render():void{
if (mWorld.config.showCollisions){
super.render();
};
}
public function checkPlatforms(px:Number, py:Number, normal:Vector2D, actor:PlatformActor):Vector2D{
var k:int;
actor.setVehicle(null);
if ((((normal.y > 0)) && ((actor.speed.y > 0)))){
k = 0;
while (k < mPlatforms.length) {
if ((((((((px <= ((mPlatforms[k].x + mPlatforms[k].bounds.x) + mPlatforms[k].bounds.width))) && ((px >= (mPlatforms[k].x + mPlatforms[k].bounds.x))))) && ((py <= ((mPlatforms[k].y + mPlatforms[k].bounds.y) + mPlatforms[k].bounds.height))))) && ((py >= (mPlatforms[k].y + mPlatforms[k].bounds.y))))){
actor.setVehicle(mPlatforms[k]);
return (new Vector2D(0, ((mPlatforms[k].y + mPlatforms[k].bounds.y) - py)));
};
k++;
};
};
return (null);
}
override public function refresh():void{
if (mWorld.config.showCollisions){
super.refresh();
};
}
public function getMaxFloorRange(x:Number, y:Number, max:int):Rectangle{
var px:int;
var left:Number;
var ty:int = (y / mDataLayer.tileHeight);
var tx:int = (x / mDataLayer.tileWidth);
while (ty < mDataLayer.height) {
if (getCell(tx, ty) != CELL_EMPTY){
px = (tx - 1);
while (((!((getCell(px, ty) == CELL_EMPTY))) && ((getCell(px, (ty - 1)) == CELL_EMPTY)))) {
--px;
if ((x - (px * mDataLayer.tileWidth)) >= max){
break;
};
};
left = ((px + 1) * mDataLayer.tileWidth);
px = (tx + 1);
while (((!((getCell(px, ty) == CELL_EMPTY))) && ((getCell(px, (ty - 1)) == CELL_EMPTY)))) {
++px;
if (((px * mDataLayer.tileWidth) - x) >= max){
break;
};
};
return (new Rectangle(left, (ty * mDataLayer.tileHeight), ((px * mDataLayer.tileWidth) - left)));
};
ty++;
};
Application.warn(((("getMaxFloorRange: no floor found at x:" + x) + " y:") + y));
return (new Rectangle(x, y, 0));
}
}
}//package com.bamtang.swit.platform
Section 100
//CollisionPoint (com.bamtang.swit.platform.CollisionPoint)
package com.bamtang.swit.platform {
import com.bamtang.swit.math.*;
public class CollisionPoint {
public var position:Vector2D;
public var normal:Vector2D;
public function CollisionPoint(positionX:Number, positionY:Number, normalX:Number, normalY:Number){
super();
position = new Vector2D(positionX, positionY);
normal = new Vector2D(normalX, normalY);
}
public function toString():String{
return (((("\n[COLL] " + position) + " ") + normal));
}
}
}//package com.bamtang.swit.platform
Section 101
//EffectPlatform (com.bamtang.swit.platform.EffectPlatform)
package com.bamtang.swit.platform {
import flash.display.*;
import com.bamtang.game.*;
public class EffectPlatform extends PlatformActor {
private var mLoop:int;
public var toDie:Boolean;
public var onEndAnimation:Function;
private var mRepeat:int;
public function EffectPlatform(nameClip:String, canvas:MovieClip, world:World, x:int, y:int, loop:int=1){
super(canvas, world, null, x, y);
mClip = Global.app.getClip(nameClip);
mClip.gotoAndStop(1);
canvas.addChild(mClip);
mLoop = loop;
mRepeat = 0;
}
override public function update(dt:int):void{
if (mClip.currentFrame == mClip.totalFrames){
mRepeat++;
if (mRepeat >= mLoop){
mClip.stop();
mIsAwaitingDelete = true;
if (onEndAnimation != null){
onEndAnimation();
};
};
} else {
mClip.nextFrame();
};
super.update(dt);
}
override public function free():void{
onEndAnimation = null;
super.free();
}
}
}//package com.bamtang.swit.platform
Section 102
//EffectPlatformManager (com.bamtang.swit.platform.EffectPlatformManager)
package com.bamtang.swit.platform {
public class EffectPlatformManager extends NpcManager {
public function EffectPlatformManager(world:World){
super(world);
}
public function addEffect(nameClip:String, world:World, x:int, y:int, loop:int=1, onEndAnimation:Function=null, fxscale:Number=1):EffectPlatform{
var tempEffect:EffectPlatform = new EffectPlatform(nameClip, mWorld.objectsCanvas, mWorld, x, y, loop);
tempEffect.scale = fxscale;
tempEffect.onEndAnimation = onEndAnimation;
mActors.push(tempEffect);
return (tempEffect);
}
}
}//package com.bamtang.swit.platform
Section 103
//Npc (com.bamtang.swit.platform.Npc)
package com.bamtang.swit.platform {
public class Npc {
private var mId:int;
private var mX:Number;
private var mY:Number;
public function Npc(idObject:int, posX:Number, posY:Number){
super();
mId = idObject;
mX = posX;
mY = posY;
}
public function get id():int{
return (mId);
}
public function get x():Number{
return (mX);
}
public function get y():Number{
return (mY);
}
}
}//package com.bamtang.swit.platform
Section 104
//NpcManager (com.bamtang.swit.platform.NpcManager)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
public class NpcManager {
protected var mMaxX:Number;
protected var mBuffer:Array;
protected var mMinX:Number;
protected var mWidth:int;
protected var mMaxIndex:int;
protected var mWorld:World;
protected var mActors:Array;
protected var mMinIndex:int;
protected var mPlayer:Player;
protected var mHeight:int;
public static var visibleWidth:int = 850;
public static var visibleWidthOffset:int = (visibleWidth - Application.APP_WIDTH);
public static var visibleHeight:int = 400;
public function NpcManager(world:World){
mActors = new Array();
mBuffer = new Array();
super();
mWorld = world;
mWidth = 0;
mHeight = 0;
}
public function update(dt:int):void{
var dx:Number;
var k:int;
while (k < mActors.length) {
if (mActors[k].isAwaitingDelete){
mActors[k].free();
mActors[k] = null;
var _temp1 = k;
k = (k - 1);
mActors.splice(_temp1, 1);
} else {
dx = (mWorld.player.x - mActors[k].x);
if (((mActors[k].isRangeControlled) && ((((dx > visibleWidth)) || ((dx < -(visibleWidth))))))){
if (!mActors[k].isIdle){
mActors[k].onIdle(true);
};
} else {
if (mActors[k].isIdle){
mActors[k].onIdle(false);
};
mActors[k].update(dt);
};
};
k++;
};
}
public function reset():void{
var k:int;
while (k < mActors.length) {
mActors[k].free();
mActors[k] = null;
k++;
};
mActors = null;
mActors = new Array();
}
public function init(player:Player):void{
}
public function add(object:Npc):void{
if ((((mBuffer.length > 0)) && ((object.x < mBuffer[(mBuffer.length - 1)].x)))){
Application.error("add: objects are not sorted");
};
mBuffer.push(object);
}
public function free():void{
var k:int;
while (k < mActors.length) {
mActors[k].free();
mActors[k] = null;
k++;
};
mActors = null;
mWorld = null;
}
}
}//package com.bamtang.swit.platform
Section 105
//PlatformActor (com.bamtang.swit.platform.PlatformActor)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import flash.geom.*;
import com.bamtang.swit.math.*;
public class PlatformActor {
protected var mBounds:Rectangle;
protected var mIsAwaitingDelete:Boolean;
protected var mLimitUp:Boolean;
protected var mX:Number;
protected var mY:Number;
protected var mLimitBottom:Boolean;
protected var mOldX:Number;
protected var mOldY:Number;
protected var mState:int;
protected var mWorld:World;
protected var mCanvas:MovieClip;
protected var mFlipX:Boolean;
protected var mIsRangeControlled:Boolean;
protected var mCharacter:Character;
protected var mCornersArray:Array;
protected var mClip:MovieClip;
protected var mSpeed:Vector2D;
protected var mScale:Number;
protected var mCollisionVisible:Boolean;
protected var mIsFallingOverWall:Boolean;
protected var mIsIdle:Boolean;
protected var mLimitLeft:Boolean;
protected var mLimitRight:Boolean;
protected var mVehicle:PlatformActor;
public function PlatformActor(canvas:MovieClip, world:World, clip:String, x:int, y:int){
super();
mCanvas = canvas;
mWorld = world;
mIsIdle = false;
mClip = null;
mCharacter = null;
mCollisionVisible = false;
mLimitBottom = false;
mLimitUp = false;
mLimitLeft = false;
mLimitRight = false;
mFlipX = false;
mIsAwaitingDelete = false;
mIsRangeControlled = true;
mIsFallingOverWall = false;
mVehicle = null;
mScale = mWorld.sizeFactor;
if (clip){
mClip = Global.app.getClip(clip);
mClip.gotoAndStop(1);
mCanvas.addChild(mClip);
createCorners();
};
setPosition(x, y);
}
public function get y():Number{
return (mY);
}
public function get x():Number{
return (mX);
}
public function checkCollision():Vector2D{
return (mWorld.checkCollision(this));
}
public function set scale(val:Number):void{
if (mScale != val){
if (mClip){
mClip.scaleX = (mFlipX) ? -(val) : val;
mClip.scaleY = val;
};
mScale = val;
createCorners();
};
}
public function get flipX():Boolean{
return (mFlipX);
}
public function gotoState(state:int):void{
mCharacter.gotoState(String(state));
mClip = mCharacter.actor.clip;
mClip.scaleX = (mFlipX) ? -(mScale) : mScale;
mClip.scaleY = mScale;
createCorners();
mState = state;
if (mClip.mcCollision){
mClip.mcCollision.visible = mCollisionVisible;
};
}
public function set flipX(flip:Boolean):void{
var absScaleX:Number;
if (flip != mFlipX){
mFlipX = flip;
if (mClip){
absScaleX = ((mClip.scaleX)>0) ? mClip.scaleX : -(mClip.scaleX);
mClip.scaleX = (mFlipX) ? -(absScaleX) : absScaleX;
};
};
}
public function setAwaitingDelete(val:Boolean):void{
mIsAwaitingDelete = val;
}
public function get isRangeControlled():Boolean{
return (mIsRangeControlled);
}
protected function createCorners():void{
if (mClip.mcCollision){
mBounds = new Rectangle((mScale * (((mFlipX) ? -1 : 1 * mClip.mcCollision.x) - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.5 * mClip.mcCollision.height))), (mScale * mClip.mcCollision.width), (mScale * mClip.mcCollision.height));
} else {
mBounds = null;
};
}
public function setFallingOverWall(val:Boolean):void{
mIsFallingOverWall = val;
}
public function applyImpulse(fx:Number, fy:Number):void{
mOldX = (mX - fx);
mOldY = (mY - fy);
}
public function get limitRight():Boolean{
return (mLimitRight);
}
public function integrateVerlet(dt:Number):void{
var oldX:Number = mOldX;
var oldY:Number = mOldY;
mOldX = mX;
mOldY = mY;
var incX:Number = (mX - oldX);
if (incX < -(mWorld.config.maxVerletHorizontalDisplace)){
incX = -(mWorld.config.maxVerletHorizontalDisplace);
} else {
if (incX > mWorld.config.maxVerletHorizontalDisplace){
incX = mWorld.config.maxVerletHorizontalDisplace;
};
};
mX = (mX + incX);
var incY:Number = ((mY - oldY) + ((mWorld.config.gravity * dt) * dt));
if (incY < -(mWorld.config.maxVerletUpDisplace)){
incY = -(mWorld.config.maxVerletUpDisplace);
} else {
if (incY > mWorld.config.maxVerletDownDisplace){
incY = mWorld.config.maxVerletDownDisplace;
};
};
mY = (mY + incY);
}
public function get world():World{
return (mWorld);
}
public function setPosition(px:Number, py:Number):void{
mOldX = (mX = px);
mOldY = (mY = py);
}
public function get vehicle():PlatformActor{
return (mVehicle);
}
public function get bounds():Rectangle{
return (mBounds);
}
public function get limitUp():Boolean{
return (mLimitUp);
}
public function get isIdle():Boolean{
return (mIsIdle);
}
public function showCollision(show:Boolean):void{
mCollisionVisible = show;
if (mClip.mcCollision){
mClip.mcCollision.visible = mCollisionVisible;
};
}
public function get corners():Array{
var ret:Array;
if (mSpeed.y < 0){
if (mSpeed.x >= 0){
ret = mCornersArray[2];
} else {
ret = mCornersArray[3];
};
} else {
if (mSpeed.x < 0){
ret = mCornersArray[1];
} else {
ret = mCornersArray[0];
};
};
return (ret);
}
public function get limitBottom():Boolean{
return (mLimitBottom);
}
public function get speed():Vector2D{
return (mSpeed);
}
public function update(dt:int):void{
mClip.x = (mX - mWorld.camera.x);
mClip.y = (mY - mWorld.camera.y);
}
public function showInCamera(camera:Camera):void{
mClip.x = (mX - camera.x);
mClip.y = (mY - camera.y);
}
public function get clip():MovieClip{
return (mClip);
}
public function onIdle(idle:Boolean):void{
mIsIdle = idle;
mClip.visible = !(idle);
}
public function get scale():Number{
return (mScale);
}
public function get isFallingOverWall():Boolean{
return (mIsFallingOverWall);
}
public function get limitLeft():Boolean{
return (mLimitLeft);
}
public function setRangeControlled(val:Boolean):void{
mIsRangeControlled = val;
}
public function free():void{
if (mCharacter){
mCharacter.free();
mCharacter = null;
mClip = null;
};
if (mClip){
mCanvas.removeChild(mClip);
};
mCanvas = null;
mWorld = null;
}
public function get isAwaitingDelete():Boolean{
return (mIsAwaitingDelete);
}
public function setVehicle(val:PlatformActor):void{
mVehicle = val;
}
public function set x(px:Number):void{
mOldX = (mX = px);
}
public function set y(py:Number):void{
mOldY = (mY = py);
}
}
}//package com.bamtang.swit.platform
Section 106
//PlatformConfigData (com.bamtang.swit.platform.PlatformConfigData)
package com.bamtang.swit.platform {
public class PlatformConfigData {
private var mPlayerJumpRunInitSpeed:Number;
private var mDebugSpeed:Number;
private var mElasticity:Number;
private var mMaxVerletHorizontalDisplace:Number;
private var mCameraScreenX:int;
private var mCameraScreenY:int;
private var mPlayerImpulseSpeed:Number;
private var mGravity:Number;
private var mShowCollisions:Boolean;
private var mCameraYMin:Number;
private var mPlayerInitX:int;
private var mPlayerInitY:int;
private var mCameraYMax:Number;
private var mWidth:int;
private var mOldTileSize:int;
private var mCameraScale:Number;
private var mPlayerMaxSpeedAir:Number;
private var mPlayerJumpInitSpeed:Number;
private var mPlayerMaxSpeedFloor:Number;
private var mMaxVerletUpDisplace:Number;
private var mFriction:Number;
private var mPlayerRunFactor:Number;
private var mCameraHeight:int;
private var mScalePlayerSpeed:Boolean;
private var mMaxVerletDownDisplace:Number;
private var mCameraXMin:Number;
private var mPlayerImpulseTime:Number;
private var mNewTileSize:int;
private var mCameraXMax:Number;
private var mPlayerCanRun:Boolean;
private var mPlayerAirSpeed:Number;
private var mHeight:int;
private var mCameraWidth:int;
private var mPlayerWalkSpeed:Number;
private static const CAMERA_SCALE:Number = 1;
public function PlatformConfigData(configXml:XML){
super();
mWidth = int(configXml.@width);
mHeight = int(configXml.@height);
mShowCollisions = Boolean((configXml.@showCollisions == "1"));
mDebugSpeed = Number(configXml.@debugSpeed);
mGravity = Number(configXml.@gravity);
mElasticity = Number(configXml.@elasticity);
mFriction = Number(configXml.@friction);
mMaxVerletUpDisplace = Number(configXml.@maxVerletUpDisplace);
mMaxVerletDownDisplace = Number(configXml.@maxVerletDownDisplace);
mMaxVerletHorizontalDisplace = Number(configXml.@maxVerletHorizontalDisplace);
mPlayerInitX = int(configXml.@playerX);
mPlayerInitY = int(configXml.@playerY);
mPlayerWalkSpeed = Number(configXml.@playerWalkSpeed);
mPlayerAirSpeed = Number(configXml.@playerAirSpeed);
mPlayerRunFactor = Number(configXml.@playerRunFactor);
mPlayerMaxSpeedFloor = Number(configXml.@playerMaxSpeedFloor);
mPlayerMaxSpeedAir = Number(configXml.@playerMaxSpeedAir);
mPlayerJumpInitSpeed = -(Number(configXml.@playerJumpInitSpeed));
mPlayerJumpRunInitSpeed = -(Number(configXml.@playerJumpRunInitSpeed));
mPlayerImpulseTime = Number(configXml.@playerImpulseTime);
mPlayerImpulseSpeed = -(Number(configXml.@playerImpulseSpeed));
mPlayerCanRun = (int(configXml.@playerCanRun) == 1);
mScalePlayerSpeed = (int(configXml.@scalePlayerSpeed) == 1);
mCameraWidth = int(configXml.@cameraWidth);
mCameraHeight = int(configXml.@cameraHeight);
mCameraScreenX = int(configXml.@cameraScreenX);
mCameraScreenY = int(configXml.@cameraScreenY);
mCameraYMax = Number(configXml.@cameraYMax);
mCameraYMin = Number(configXml.@cameraYMin);
mCameraXMax = Number(configXml.@cameraXMax);
mCameraXMin = Number(configXml.@cameraXMin);
var scale:Number = Number(configXml.@cameraScale);
mCameraScale = ((scale)>0) ? scale : CAMERA_SCALE;
var fixOldSize:int = Number(configXml.@oldTileSize);
var fixNewSize:int = Number(configXml.@newTileSize);
if ((((((fixOldSize > 0)) && ((fixNewSize > 0)))) && (!((fixOldSize == fixNewSize))))){
mOldTileSize = fixOldSize;
mNewTileSize = fixNewSize;
mWidth = ((mWidth / fixOldSize) * fixNewSize);
mHeight = ((mHeight / fixOldSize) * fixNewSize);
} else {
mOldTileSize = 0;
mNewTileSize = 0;
};
}
public function get oldTileSize():int{
return (mOldTileSize);
}
public function get playerWalkSpeed():Number{
return (mPlayerWalkSpeed);
}
public function get playerAirSpeed():Number{
return (mPlayerAirSpeed);
}
public function get playerJumpRunInitSpeed():Number{
return (mPlayerJumpRunInitSpeed);
}
public function get cameraScale():Number{
return (mCameraScale);
}
public function get height():int{
return (mHeight);
}
public function get playerMaxSpeedFloor():Number{
return (mPlayerMaxSpeedFloor);
}
public function get playerJumpInitSpeed():Number{
return (mPlayerJumpInitSpeed);
}
public function get maxVerletUpDisplace():Number{
return (mMaxVerletUpDisplace);
}
public function get maxVerletDownDisplace():Number{
return (mMaxVerletDownDisplace);
}
public function get scalePlayerSpeed():Boolean{
return (mScalePlayerSpeed);
}
public function get gravity():Number{
return (mGravity);
}
public function get showCollisions():Boolean{
return (mShowCollisions);
}
public function get playerMaxSpeedAir():Number{
return (mPlayerMaxSpeedAir);
}
public function get cameraXMin():Number{
return (mCameraXMin);
}
public function get cameraScreenY():int{
return (mCameraScreenY);
}
public function get cameraScreenX():int{
return (mCameraScreenX);
}
public function get newTileSize():int{
return (mNewTileSize);
}
public function get cameraXMax():Number{
return (mCameraXMax);
}
public function get cameraWidth():int{
return (mCameraWidth);
}
public function get cameraHeight():int{
return (mCameraHeight);
}
public function get debugSpeed():Number{
return (mDebugSpeed);
}
public function get elasticity():Number{
return (mElasticity);
}
public function get playerImpulseTime():Number{
return (mPlayerImpulseTime);
}
public function get width():int{
return (mWidth);
}
public function get maxVerletHorizontalDisplace():Number{
return (mMaxVerletHorizontalDisplace);
}
public function get playerImpulseSpeed():Number{
return (mPlayerImpulseSpeed);
}
public function get playerCanRun():Boolean{
return (mPlayerCanRun);
}
public function get cameraYMin():Number{
return (mCameraYMin);
}
public function get playerInitX():int{
return (mPlayerInitX);
}
public function get playerInitY():int{
return (mPlayerInitY);
}
public function get cameraYMax():Number{
return (mCameraYMax);
}
public function get playerRunFactor():Number{
return (mPlayerRunFactor);
}
public function get friction():Number{
return (mFriction);
}
}
}//package com.bamtang.swit.platform
Section 107
//PlatformLayer (com.bamtang.swit.platform.PlatformLayer)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
public class PlatformLayer {
protected var mMaxX:int;
protected var mMaxY:int;
protected var mX:Number;
protected var mY:Number;
protected var mBuffer:Array;
protected var mBufferHeight:int;
protected var mParallaxXFactor:Number;
protected var mWorld:World;
protected var mCanvas:MovieClip;
protected var mBufferWidth:int;
protected var mBitmapData:BitmapData;
protected var mMinX:int;
protected var mMinY:int;
protected var mDataLayer:PlatformLayerData;
protected var mParallaxYFactor:Number;
protected var mBufferX:int;
protected var mBufferY:int;
public function PlatformLayer(world:World, dataLayer:PlatformLayerData){
super();
mWorld = world;
mDataLayer = dataLayer;
mBitmapData = Global.app.getBitmapData(mDataLayer.map, 0, 0);
if (mDataLayer.columns != mBitmapData.width){
Application.error(("clsLayer: width " + mDataLayer.map));
return;
};
if (mDataLayer.rows != mBitmapData.height){
Application.error(("clsLayer: height " + mDataLayer.map));
return;
};
mCanvas = new MovieClip();
mWorld.canvas.addChild(mCanvas);
}
public function init():void{
var ky:int;
if (mWorld.camera.parallaxX){
mParallaxXFactor = ((mDataLayer.width - mWorld.camera.width) / (mWorld.width - mWorld.camera.width));
};
if (mWorld.camera.parallaxY){
mParallaxYFactor = ((mDataLayer.height - mWorld.camera.height) / (mWorld.height - mWorld.camera.height));
};
mBufferWidth = Math.ceil(((mWorld.camera.width / mDataLayer.tileWidth) + 1));
mBufferHeight = Math.ceil(((mWorld.camera.height / mDataLayer.tileHeight) + 1));
mBufferX = 0;
mBufferY = 0;
mBuffer = new Array();
mBuffer.length = (mBufferWidth * mBufferHeight);
mMinX = Math.floor((mWorld.camera.x / mDataLayer.tileWidth));
if (mMinX < 0){
mMinX = 0;
};
mMaxX = (mMinX + mBufferWidth);
mMinY = Math.floor((mWorld.camera.y / mDataLayer.tileHeight));
if (mMinY < 0){
mMinY = 0;
};
mMaxY = (mMinY + mBufferHeight);
var kx:int;
while (kx < mBufferWidth) {
ky = 0;
while (ky < mBufferHeight) {
initCell(kx, ky);
ky++;
};
kx++;
};
}
protected function initCell(kx:int, ky:int):void{
var tile:MovieClip;
var tileIndex:int = getCell((kx + mMinX), (ky + mMinY));
if (tileIndex > 0){
tile = Global.app.getClip(mDataLayer.getTileName((tileIndex - 1)));
tile.x = ((kx + mMinX) * mDataLayer.tileWidth);
tile.y = ((ky + mMinY) * mDataLayer.tileHeight);
setBufferCell(kx, ky, tile);
mCanvas.addChild(tile);
};
}
public function render():void{
var minTile:int;
var inc:int;
var kx:int;
var ky:int;
var tile:MovieClip;
var redrawAll:Boolean;
if (mWorld.camera.parallaxX){
minTile = Math.floor((parallaxX / mDataLayer.tileWidth));
inc = (minTile - mMinX);
if ((((inc <= -(mBufferWidth))) || ((inc >= mBufferWidth)))){
redrawAll = true;
} else {
if (minTile > mMinX){
kx = 0;
while (kx < inc) {
ky = 0;
while (ky < mBufferHeight) {
tile = getBufferCell(kx, ky);
if (tile){
mCanvas.removeChild(tile);
setBufferCell(kx, ky, null);
};
addTileCell((kx + mMaxX), (ky + mMinY), kx, ky);
ky++;
};
kx++;
};
mBufferX = ((mBufferX + inc) % mBufferWidth);
} else {
if (minTile < mMinX){
kx = 1;
while (kx <= -(inc)) {
ky = 0;
while (ky < mBufferHeight) {
tile = getBufferCell((mBufferWidth - kx), ky);
if (tile){
mCanvas.removeChild(tile);
setBufferCell((mBufferWidth - kx), ky, null);
};
addTileCell((mMinX - kx), (ky + mMinY), (mBufferWidth - kx), ky);
ky++;
};
kx++;
};
mBufferX = (((mBufferWidth + mBufferX) + inc) % mBufferWidth);
};
};
};
if (inc != 0){
mMinX = minTile;
mMaxX = (mMinX + mBufferWidth);
};
mCanvas.x = -(parallaxX);
};
if (mWorld.camera.parallaxY){
minTile = Math.floor((parallaxY / mDataLayer.tileHeight));
inc = (minTile - mMinY);
if ((((inc <= -(mBufferHeight))) || ((inc >= mBufferHeight)))){
redrawAll = true;
} else {
if (minTile > mMinY){
ky = 0;
while (ky < inc) {
kx = 0;
while (kx < mBufferWidth) {
tile = getBufferCell(kx, ky);
if (tile){
mCanvas.removeChild(tile);
setBufferCell(kx, ky, null);
};
addTileCell((kx + mMinX), (ky + mMaxY), kx, ky);
kx++;
};
ky++;
};
mBufferY = ((mBufferY + inc) % mBufferHeight);
} else {
if (minTile < mMinY){
ky = 1;
while (ky <= -(inc)) {
kx = 0;
while (kx < mBufferWidth) {
tile = getBufferCell(kx, (mBufferHeight - ky));
if (tile){
mCanvas.removeChild(tile);
setBufferCell(kx, (mBufferHeight - ky), null);
};
addTileCell((kx + mMinX), (mMinY - ky), kx, (mBufferHeight - ky));
kx++;
};
ky++;
};
mBufferY = (((mBufferHeight + mBufferY) + inc) % mBufferHeight);
};
};
};
if (inc != 0){
mMinY = minTile;
mMaxY = (mMinY + mBufferHeight);
};
mCanvas.y = -(parallaxY);
};
if (redrawAll){
refresh();
};
}
public function set y(val:Number):void{
mY = val;
}
protected function get parallaxX():Number{
return ((mWorld.camera.x * mParallaxXFactor));
}
protected function get parallaxY():Number{
return ((mWorld.camera.y * mParallaxYFactor));
}
public function get height():int{
return (mDataLayer.height);
}
protected function getBufferCell(x:int, y:int):MovieClip{
return (mBuffer[(((x + mBufferX) % mBufferWidth) + (((y + mBufferY) % mBufferHeight) * mBufferWidth))]);
}
public function get tileWidth():int{
return (mDataLayer.tileWidth);
}
protected function setBufferCell(x:int, y:int, clip:MovieClip):void{
mBuffer[(((x + mBufferX) % mBufferWidth) + (((y + mBufferY) % mBufferHeight) * mBufferWidth))] = clip;
}
public function get width():int{
return (mDataLayer.width);
}
public function refresh():void{
var ky:int;
var clip:MovieClip;
mBufferX = 0;
mBufferY = 0;
var kx:int;
while (kx < mBufferWidth) {
ky = 0;
while (ky < mBufferHeight) {
clip = mBuffer[(kx + (ky * mBufferWidth))];
if (clip){
mCanvas.removeChild(clip);
mBuffer[(kx + (ky * mBufferWidth))] = null;
};
initCell(kx, ky);
ky++;
};
kx++;
};
}
public function get canvas():MovieClip{
return (mCanvas);
}
protected function getCell(col:int, row:int):int{
if ((((((((col >= 0)) && ((row >= 0)))) && ((col < mDataLayer.columns)))) && ((row < mDataLayer.rows)))){
return ((mBitmapData.getPixel(col, row) / mDataLayer.step));
};
return (0);
}
public function set x(val:Number):void{
mX = val;
}
protected function addTileCell(tileX:int, tileY:int, bufferX:int, bufferY:int):void{
var tile:MovieClip;
var tileIndex:int = getCell(tileX, tileY);
if (tileIndex > 0){
tile = Global.app.getClip(mDataLayer.getTileName((tileIndex - 1)));
tile.x = (tileX * mDataLayer.tileWidth);
tile.y = (tileY * mDataLayer.tileHeight);
setBufferCell(bufferX, bufferY, tile);
mCanvas.addChild(tile);
};
}
public function get visible():Boolean{
return (mCanvas.visible);
}
public function set visible(val:Boolean):void{
mCanvas.visible = val;
}
public function get tileHeight():int{
return (mDataLayer.tileHeight);
}
public function get x():Number{
return (mX);
}
public function get y():Number{
return (mY);
}
public function free():void{
var clip:MovieClip;
var ky:int;
var kx:int;
while (kx < mBufferWidth) {
ky = 0;
while (ky < mBufferHeight) {
clip = mBuffer[(kx + (ky * mBufferWidth))];
if (clip){
mCanvas.removeChild(clip);
};
ky++;
};
kx++;
};
mWorld.canvas.removeChild(mCanvas);
mCanvas = null;
mWorld = null;
}
public function setCell(col:int, row:int, val:uint):void{
if ((((((((col >= 0)) && ((row >= 0)))) && ((col < mDataLayer.columns)))) && ((row < mDataLayer.rows)))){
mBitmapData.setPixel32(col, row, (val * mDataLayer.step));
};
}
}
}//package com.bamtang.swit.platform
Section 108
//PlatformLayerData (com.bamtang.swit.platform.PlatformLayerData)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
public class PlatformLayerData {
private var mTileHeight:int;
private var mTileWidth:int;
private var mName:String;
private var mWidth:int;
private var mTiles:Array;
private var mPalettes:Array;
private var mRows:int;
private var mMap:String;
private var mColumns:int;
private var mStep:int;
private var mHeight:int;
public function PlatformLayerData(data:XML, oldTileSize:int=0, newTileSize:int=0){
var idPalette:int;
super();
mName = String(data.@name);
mColumns = int(data.@cols);
mRows = int(data.@rows);
mTileWidth = int(data.@tileW);
mTileHeight = int(data.@tileH);
mMap = String(data.@map);
mStep = int(data.@step);
mWidth = int(data.@width);
mHeight = int(data.@height);
if (oldTileSize != 0){
mTileWidth = ((mTileWidth / oldTileSize) * newTileSize);
mTileHeight = ((mTileHeight / oldTileSize) * newTileSize);
mWidth = ((mWidth / oldTileSize) * newTileSize);
mHeight = ((mHeight / oldTileSize) * newTileSize);
};
mPalettes = new Array();
var numSets:int = data.set.length();
var k:int;
while (k < numSets) {
mPalettes.push(data.set[k].@name);
k++;
};
mTiles = new Array();
var numTiles:int = data.tile.length();
k = 0;
while (k < numTiles) {
idPalette = int(data.tile[k].@set);
if ((((idPalette >= 0)) && ((idPalette < mPalettes.length)))){
mTiles.push(((mPalettes[idPalette] + "_") + data.tile[k].@frame));
} else {
Application.error(("PlatformLayerData: invalid set in: " + mName));
};
k++;
};
}
public function get width():int{
return (mWidth);
}
public function getTileName(index:int):String{
if ((((index >= 0)) && ((index < mTiles.length)))){
return (mTiles[index]);
};
return (null);
}
public function get name():String{
return (mName);
}
public function get step():int{
return (mStep);
}
public function get map():String{
return (mMap);
}
public function get columns():int{
return (mColumns);
}
public function get height():int{
return (mHeight);
}
public function get tileHeight():int{
return (mTileHeight);
}
public function get tileWidth():int{
return (mTileWidth);
}
public function get rows():int{
return (mRows);
}
}
}//package com.bamtang.swit.platform
Section 109
//Player (com.bamtang.swit.platform.Player)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import com.bamtang.game.platformGame.*;
import flash.geom.*;
import com.bamtang.swit.math.*;
import com.bamtang.swit.utils.*;
import flash.ui.*;
public class Player extends PlatformActor {
protected var mIsMoveLeg:Boolean;
protected var mKeyFlyLeft:Boolean;// = false
protected var mFlyMovement:Boolean;
protected var mKeyFlyRigth:Boolean;// = false
protected var mFactorSpeedX:Number;
protected var mFactorSpeedY:Number;
protected var mDebugAcceleratedMovement:Boolean;
protected var mControl:PlayerControl;
protected var mSpeedFlyX:Number;// = 0
protected var mIsInvulnerable:Boolean;
protected var mCollision:Vector2D;
protected var mFreeMovement:Boolean;
protected var mDebugVerticalMovement:int;
protected var mSkipRun:int;// = 0
protected var mDebugCollisionOn:Boolean;
protected var mDir:Number;// = 1
protected var mDebugHorizontalMovement:int;
protected var mIsDead:Boolean;
public static const ST_PLAYER_WIN:int = 109;
public static const ST_PLAYER_LAND:int = 110;
public static const ST_PLAYER_WALK:int = 103;
public static const ST_PLAYER_STAND_3:int = 102;
public static const ST_PLAYER_RUN:int = 104;
public static const ST_PLAYER_JUMP_UP:int = 105;
public static const ST_PLAYER_BRAKE:int = 111;
public static const ST_PLAYER_STAND_2:int = 101;
public static const ST_PLAYER_HIT:int = 107;
public static const ST_PLAYER_STAND:int = 100;
public static const ST_PLAYER_JUMP_DOWN:int = 106;
public static const ST_PLAYER_LOSE:int = 108;
public function Player(canvas:MovieClip, world:World, x:int, y:int){
y = world.getFloorCollision(x, y).y;
super(canvas, world, null, x, y);
mSpeed = new Vector2D(0, 0);
mIsInvulnerable = false;
mFactorSpeedX = 1;
mFactorSpeedY = 1;
mFreeMovement = false;
mDebugCollisionOn = false;
mDebugVerticalMovement = 0;
mDebugHorizontalMovement = 0;
mDebugAcceleratedMovement = false;
mIsInvulnerable = false;
mIsDead = false;
}
override public function free():void{
if (mControl){
mControl.free();
mControl = null;
};
super.free();
}
public function resetControl():void{
if (mControl){
mControl.reset();
};
}
public function get state():int{
return (mState);
}
public function get factorSpeedX():Number{
return (mFactorSpeedX);
}
public function get factorSpeedY():Number{
return (mFactorSpeedY);
}
public function setFactorSpeedX(val:Number):void{
mFactorSpeedX = val;
}
override protected function createCorners():void{
var corners:Array;
var indexesArray:Array;
var i:int;
var j:int;
if (mClip.mcCollision){
corners = new Array();
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.5 * mClip.mcCollision.height))), 1, 1));
if ((mScale * mClip.mcCollision.width) > mWorld.tileWidth){
corners.push(new CollisionPoint((mScale * mClip.mcCollision.x), (mScale * (mClip.mcCollision.y + (0.5 * mClip.mcCollision.height))), 0, 1));
} else {
corners.push(null);
};
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.5 * mClip.mcCollision.height))), -1, 1));
if ((mScale * mClip.mcCollision.height) > (3 * mWorld.tileHeight)){
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.25 * mClip.mcCollision.height))), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.25 * mClip.mcCollision.height))), -1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * mClip.mcCollision.y), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * mClip.mcCollision.y), -1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.25 * mClip.mcCollision.height))), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.25 * mClip.mcCollision.height))), -1, 0));
} else {
if ((mScale * mClip.mcCollision.height) > (2 * mWorld.tileHeight)){
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.17 * mClip.mcCollision.height))), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y + (0.17 * mClip.mcCollision.height))), -1, 0));
corners.push(null, null);
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.17 * mClip.mcCollision.height))), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.17 * mClip.mcCollision.height))), -1, 0));
} else {
if ((mScale * mClip.mcCollision.height) > mWorld.tileHeight){
corners.push(null, null);
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * mClip.mcCollision.y), 1, 0));
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * mClip.mcCollision.y), -1, 0));
corners.push(null, null);
} else {
corners.push(null, null, null, null, null, null);
};
};
};
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x + (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.5 * mClip.mcCollision.height))), 1, -1));
if ((mScale * mClip.mcCollision.width) > mWorld.tileWidth){
corners.push(new CollisionPoint((mScale * mClip.mcCollision.x), (mScale * (mClip.mcCollision.y - (0.5 * mClip.mcCollision.height))), 0, -1));
} else {
corners.push(null);
};
corners.push(new CollisionPoint((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.5 * mClip.mcCollision.height))), -1, -1));
mCornersArray = new Array(new Array(), new Array(), new Array(), new Array());
indexesArray = new Array(new Array(0, 1, 3, 2, 5, 7, 9), new Array(2, 1, 4, 0, 6, 8, 11), new Array(9, 10, 7, 11, 5, 3, 0), new Array(11, 10, 8, 9, 6, 4, 2));
i = 0;
while (i < mCornersArray.length) {
j = 0;
while (j < indexesArray[i].length) {
if (corners[indexesArray[i][j]]){
mCornersArray[i].push(corners[indexesArray[i][j]]);
};
j++;
};
i++;
};
mBounds = new Rectangle((mScale * (mClip.mcCollision.x - (0.5 * mClip.mcCollision.width))), (mScale * (mClip.mcCollision.y - (0.5 * mClip.mcCollision.height))), (mScale * mClip.mcCollision.width), (mScale * mClip.mcCollision.height));
} else {
mCornersArray = null;
mBounds = null;
};
}
public function setFactorSpeedY(val:Number):void{
mFactorSpeedY = val;
}
public function get collision():Vector2D{
return (mCollision);
}
public function get isDead():Boolean{
return (mIsDead);
}
override public function integrateVerlet(dt:Number):void{
var incY:Number;
var oldX:Number = mOldX;
var oldY:Number = mOldY;
mOldX = mX;
mOldY = mY;
var incX:Number = (mX - oldX);
if (incX < -(mWorld.config.maxVerletHorizontalDisplace)){
incX = -(mWorld.config.maxVerletHorizontalDisplace);
} else {
if (incX > mWorld.config.maxVerletHorizontalDisplace){
incX = mWorld.config.maxVerletHorizontalDisplace;
};
};
mX = (mX + incX);
if (!mControl.isJumpingUp){
incY = ((mY - oldY) + ((mWorld.config.gravity * dt) * dt));
if (incY < -(mWorld.config.maxVerletUpDisplace)){
incY = -(mWorld.config.maxVerletUpDisplace);
} else {
if (incY > mWorld.config.maxVerletDownDisplace){
incY = mWorld.config.maxVerletDownDisplace;
};
};
mY = (mY + incY);
};
}
public function onKeyUp(keyCode:int):void{
if ((((mState == ST_PLAYER_LOSE)) || ((mState == ST_PLAYER_WIN)))){
return;
};
switch (keyCode){
case Keyboard.LEFT:
case Global.KEY_A:
mControl.onLeft(false);
mKeyFlyLeft = false;
mDebugHorizontalMovement = 0;
break;
case Keyboard.RIGHT:
case Global.KEY_D:
mControl.onRight(false);
mKeyFlyRigth = false;
mDebugHorizontalMovement = 0;
break;
case Keyboard.UP:
case Global.KEY_W:
mControl.onJump(false);
case Keyboard.DOWN:
case Global.KEY_S:
mDebugVerticalMovement = 0;
break;
case Global.KEY_X:
mControl.onJump(false);
break;
case Global.KEY_Z:
mControl.onRun(false);
break;
};
}
public function hitIntersection(actor:PlatformActor):Rectangle{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersection(rb));
};
return (null);
}
public function onKeyDown(keyCode:int):void{
if ((((mState == ST_PLAYER_LOSE)) || ((mState == ST_PLAYER_WIN)))){
return;
};
switch (keyCode){
case Keyboard.LEFT:
mControl.onLeft(true);
mDebugHorizontalMovement = -1;
mKeyFlyLeft = true;
break;
case Keyboard.RIGHT:
mControl.onRight(true);
mDebugHorizontalMovement = 1;
mKeyFlyRigth = true;
break;
case Keyboard.UP:
mDebugVerticalMovement = -1;
if (mFreeMovement){
return;
};
if (mFlyMovement){
return;
};
if (mIsMoveLeg){
return;
};
mControl.onJump(true);
break;
case Keyboard.DOWN:
mDebugVerticalMovement = 1;
break;
case Global.KEY_0:
if (Global.settings[("GAT_Config0" + DemoGame.level)].debugCheats){
mFreeMovement = !(mFreeMovement);
Application.echo(("FreeMove: " + mFreeMovement));
};
break;
};
}
public function onEnemyCollision(enemy:PlatformActor, damage:int):void{
}
public function hitTest(actor:PlatformActor):Boolean{
var ra:Rectangle;
var rb:Rectangle;
if (((mBounds) && (actor.bounds))){
ra = new Rectangle(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
ra.x = (ra.x + mX);
ra.y = (ra.y + mY);
rb = new Rectangle(actor.bounds.x, actor.bounds.y, actor.bounds.width, actor.bounds.height);
rb.x = (rb.x + actor.x);
rb.y = (rb.y + actor.y);
return (ra.intersects(rb));
};
return (false);
}
public function onSpringCollision(initSpeed:Number):void{
mControl.onCustomJump(initSpeed);
}
override public function update(dt:int):void{
var limit:Number;
var incX:Number;
var d:Vector2D;
var normal:Vector2D;
var tangent:Vector2D;
var vy:Number;
mCharacter.update(dt);
if (mControl.dir != 0){
mDir = mControl.dir;
if (!mFlyMovement){
mClip.scaleX = (mDir * mScale);
};
};
if (mFreeMovement){
moveFree(dt);
return;
};
if (mFlyMovement){
moveFly(dt);
return;
};
mControl.update(dt);
var iniY:Number = mY;
integrateVerlet(dt);
if (vehicle){
if (vehicle.speed.y > 0){
mY = (mY + ((1.5 * dt) * vehicle.speed.y));
};
mX = (mX + (dt * vehicle.speed.x));
mOldX = mX;
};
if (mControl.fx != 0){
if (mControl.isJumping){
incX = (((mWorld.config.playerAirSpeed * mControl.fx) * dt) * dt);
} else {
if (((mControl.isAction) && (!(mControl.isJumping)))){
incX = 0;
} else {
incX = (((mWorld.config.playerWalkSpeed * mControl.fx) * dt) * dt);
};
};
mX = (mX + incX);
if (((((((!((mState == ST_PLAYER_WIN))) && (!((mState == ST_PLAYER_LOSE))))) && (!(mControl.isJumping)))) && (!(mControl.isAction)))){
if (mControl.isRunning){
if (mState != ST_PLAYER_RUN){
gotoState(ST_PLAYER_RUN);
};
} else {
if (mState != ST_PLAYER_WALK){
gotoState(ST_PLAYER_WALK);
trace("::: ST_PLAYER_WALK :::");
};
};
};
flipX = (mControl.fx < 0);
} else {
if ((((((((mSpeed.x > -0.5)) && ((mSpeed.x < 0.5)))) && ((((mState == ST_PLAYER_WALK)) || ((mState == ST_PLAYER_RUN)))))) && (!(mControl.isJumping)))){
gotoState(ST_PLAYER_STAND);
};
};
if (mControl.isJumpingUp){
mY = (mY + mControl.dh);
};
mSpeed.x = (mX - mOldX);
if (mControl.isJumping){
if (mWorld.config.scalePlayerSpeed){
limit = (mScale * mWorld.config.playerMaxSpeedAir);
} else {
limit = (mFactorSpeedX * mWorld.config.playerMaxSpeedAir);
};
if (mControl.isRunning){
limit = (limit * mWorld.config.playerRunFactor);
};
} else {
if (mWorld.config.scalePlayerSpeed){
limit = (mScale * mWorld.config.playerMaxSpeedFloor);
} else {
limit = (mFactorSpeedX * mWorld.config.playerMaxSpeedFloor);
};
if (mControl.isRunning){
limit = (limit * mWorld.config.playerRunFactor);
};
};
if (mSpeed.x < -(limit)){
mX = (mOldX - limit);
};
if (mSpeed.x > limit){
mX = (mOldX + limit);
};
mSpeed.y = (mY - mOldY);
mCollision = checkCollision();
mControl.onCollision(mCollision, dt);
if (mCollision){
d = new Vector2D((mX - mOldX), (mY - mOldY));
normal = d.projectionOn(mCollision);
tangent = d.minus(normal);
normal.scale((1 + mWorld.config.elasticity));
if (!isFallingOverWall){
tangent.scale(mWorld.config.friction);
normal.add(tangent);
} else {
mIsFallingOverWall = false;
};
mOldX = (mOldX + (normal.x + mCollision.x));
mOldY = (mOldY + (normal.y + mCollision.y));
mX = (mX + mCollision.x);
vy = ((mY + mCollision.y) - iniY);
if ((((vy > -1)) && ((vy < 1)))){
mY = iniY;
} else {
mY = (mY + mCollision.y);
};
};
mWorld.checkWorldBoundaries(this);
if (mY > (mWorld.height + 60)){
onPlayerFellOutOfWorld();
};
}
protected function moveFree(dt:int):void{
var coll:Vector2D;
var factor:int = (mControl.isRunning) ? 3 : 1;
if (mDebugHorizontalMovement != 0){
mX = (mX + (((factor * mWorld.config.debugSpeed) * mDebugHorizontalMovement) * dt));
};
if (mDebugVerticalMovement != 0){
mY = (mY + (((factor * mWorld.config.debugSpeed) * mDebugVerticalMovement) * dt));
};
mSpeed.x = mDebugHorizontalMovement;
mSpeed.y = mDebugVerticalMovement;
mOldX = mX;
mOldY = mY;
if (mDebugCollisionOn){
coll = checkCollision();
if (coll){
mX = (mX + coll.x);
mY = (mY + coll.y);
};
};
}
public function onTargetReached():void{
}
public function onEndAnimation(state:String):void{
var rand:Number;
if (state == String(ST_PLAYER_JUMP_UP)){
gotoState(ST_PLAYER_JUMP_DOWN);
} else {
if (state == String(ST_PLAYER_LAND)){
gotoState(ST_PLAYER_STAND);
} else {
if (state == String(ST_PLAYER_STAND)){
rand = Math.random();
if (rand < 0.3){
gotoState(ST_PLAYER_STAND_2);
};
if (rand > 0.8){
gotoState(ST_PLAYER_STAND_3);
};
} else {
if (state == String(ST_PLAYER_STAND_2)){
gotoState(ST_PLAYER_STAND);
} else {
if (state == String(ST_PLAYER_STAND_3)){
gotoState(ST_PLAYER_STAND);
};
};
};
};
};
}
protected function moveFly(dt:int):void{
var speedY:Number = Global.settings[("GAT_Config0" + DemoGame.level)].playerFlySpeedY;
mClip.scaleX = (mDir * mScale);
mSpeedFlyX = Global.settings[("GAT_Config0" + DemoGame.level)].playerFlyMaxSpeedX;
if (mState == DemoPlayer.ST_PLAYER_FLY_UP){
mSpeedFlyX = 0;
};
mX = (mX + ((mSpeedFlyX * mDir) * dt));
if (mDebugVerticalMovement != 0){
mY = (mY + ((speedY * mDebugVerticalMovement) * dt));
};
mOldX = mX;
mOldY = mY;
var coll:Vector2D = checkCollision();
if (coll){
mX = (mX + coll.x);
mY = (mY + coll.y);
};
}
public function onPlayerFellOutOfWorld():void{
}
override public function gotoState(state:int):void{
var voices:Number;
if (state == ST_PLAYER_LAND){
if ((((((DemoGame.level == 4)) && (DemoPlayer(DemoGame(Global.game).world.player).disable))) && (DemoPlayer.playerWin))){
return;
};
};
if (state != mState){
mCharacter.gotoState(String(state));
switch (state){
case ST_PLAYER_JUMP_DOWN:
mCharacter.loop = false;
break;
case ST_PLAYER_JUMP_UP:
mOldY = mY;
voices = Common.setRandom(1, 2);
Global.app.playSound(("snd_AT_finn_jump" + voices));
Global.app.playSound("snd_AT_mc_player_jump_up");
break;
case ST_PLAYER_WALK:
Global.app.playSound("snd_AT_mc_player_walk");
break;
case ST_PLAYER_HIT:
voices = Common.setRandom(1, 3);
Global.app.playSound(("snd_AT_finn_hit" + voices));
Global.app.playSound("snd_AT_mc_player_hit");
break;
case DemoPlayer.ST_PLAYER_FLY_UP:
case DemoPlayer.ST_PLAYER_FLY:
Global.app.playSound("snd_AT_mc_player_fly");
break;
case DemoPlayer.ST_PLAYER_PUNCH:
case DemoPlayer.ST_PLAYER_PUNCH_JUMP:
case DemoPlayer.ST_PLAYER_SHOOT_JUMP:
case DemoPlayer.ST_PLAYER_SHOOT:
voices = Common.setRandom(1, 3);
Global.app.playSound(("snd_AT_finn_punch" + voices));
Global.app.playSound("snd_AT_mc_player_shoot");
break;
case ST_PLAYER_LAND:
Global.app.playSound("snd_AT_mc_player_jump_land");
break;
case ST_PLAYER_LOSE:
Global.app.playSound("snd_AT_finn_die");
mCharacter.loop = false;
break;
case ST_PLAYER_WIN:
voices = Common.setRandom(1, 3);
Global.app.playSound(("snd_AT_winLevel_" + voices));
break;
};
if (mControl.isAction){
mControl.onAction(false);
};
mClip = mCharacter.actor.clip;
mClip.scaleX = (mDir * mScale);
mClip.scaleY = mScale;
mState = state;
if (mClip.mcCollision){
mClip.mcCollision.visible = mCollisionVisible;
};
};
}
public function toString():String{
return (((((("clsPlayer x:" + mX) + " y:") + mY) + " s:") + mState));
}
public function set isInvulnerable(bool:Boolean):void{
mIsInvulnerable = bool;
}
public function get isInvulnerable():Boolean{
return (mIsInvulnerable);
}
}
}//package com.bamtang.swit.platform
Section 110
//PlayerControl (com.bamtang.swit.platform.PlayerControl)
package com.bamtang.swit.platform {
import com.bamtang.swit.math.*;
public class PlayerControl {
protected var mIsRunning:Boolean;
private var mIsFly:Boolean;
protected var mIsAction:Boolean;
protected var mHorizontalBuffer:Array;
protected var mDeltaHeight:Number;
public var TIME_LAND:int;// = 400
protected var mJumpInitSpeed:Number;
protected var mTimeJumping:int;
protected var mForceX:Number;
protected var mImpulseTimer:int;
protected var mJumpAllowed:Boolean;
protected var mPlayer:Player;
protected var mFloatingTimer:int;
public var TIME_FALL:int;// = 75
protected var mIsJumpingUp:Boolean;
protected var mIsJumping:Boolean;
public function PlayerControl(player:Player){
super();
mPlayer = player;
mForceX = 0;
mIsJumping = false;
mImpulseTimer = -1;
mFloatingTimer = TIME_FALL;
mHorizontalBuffer = new Array(0, 0);
mIsRunning = false;
mJumpAllowed = true;
mDeltaHeight = 0;
mTimeJumping = 0;
}
public function get isAction():Boolean{
return (mIsAction);
}
public function get dh():Number{
return (mDeltaHeight);
}
public function onJump(pressed:Boolean):void{
if (pressed){
if (((!(mIsJumping)) && (mJumpAllowed))){
mPlayer.gotoState(Player.ST_PLAYER_JUMP_UP);
mImpulseTimer = mPlayer.world.config.playerImpulseTime;
mIsJumping = true;
mIsJumpingUp = true;
mJumpAllowed = false;
mTimeJumping = 0;
if (mIsRunning){
mJumpInitSpeed = (mPlayer.factorSpeedY * mPlayer.world.config.playerJumpRunInitSpeed);
} else {
mJumpInitSpeed = (mPlayer.factorSpeedY * mPlayer.world.config.playerJumpInitSpeed);
};
};
} else {
if (((mIsJumpingUp) && ((mImpulseTimer > 0)))){
mJumpInitSpeed = mPlayer.world.config.playerImpulseSpeed;
};
mJumpAllowed = true;
};
}
public function onLeft(pressed:Boolean):void{
if (pressed){
if (mHorizontalBuffer[0] == 1){
mHorizontalBuffer[1] = 1;
};
mHorizontalBuffer[0] = -1;
} else {
if (mHorizontalBuffer[0] == -1){
mHorizontalBuffer[0] = mHorizontalBuffer[1];
};
mHorizontalBuffer[1] = 0;
};
}
public function onRight(pressed:Boolean):void{
if (pressed){
if (mHorizontalBuffer[0] == -1){
mHorizontalBuffer[1] = -1;
};
mHorizontalBuffer[0] = 1;
} else {
if (mHorizontalBuffer[0] == 1){
mHorizontalBuffer[0] = mHorizontalBuffer[1];
};
mHorizontalBuffer[1] = 0;
};
}
public function onRun(pressed:Boolean):void{
if (mPlayer.world.config.playerCanRun){
mIsRunning = pressed;
};
}
public function reset():void{
mForceX = 0;
mHorizontalBuffer[0] = 0;
mHorizontalBuffer[1] = 0;
mIsRunning = false;
}
public function onCollision(coll:Vector2D, dt:int):void{
if (coll){
if ((((((coll.y < 0)) && (mIsJumping))) || ((((coll.y < 0)) && (mIsFly))))){
mIsJumping = false;
mIsAction = false;
mIsFly = false;
mPlayer.gotoState(Player.ST_PLAYER_LAND);
mFloatingTimer = TIME_LAND;
};
if (mFloatingTimer < TIME_FALL){
mFloatingTimer = TIME_FALL;
};
if (((mPlayer.vehicle) && ((mFloatingTimer < TIME_LAND)))){
mFloatingTimer = TIME_LAND;
};
if (coll.y != 0){
mIsJumpingUp = false;
};
} else {
if (mFloatingTimer > 0){
mFloatingTimer = (mFloatingTimer - dt);
if ((((mFloatingTimer <= 0)) && (!(mIsJumping)))){
mPlayer.gotoState(Player.ST_PLAYER_JUMP_DOWN);
mIsJumping = true;
};
};
};
}
public function get dir():Number{
return (mHorizontalBuffer[0]);
}
public function onAction(pressed:Boolean):void{
mIsAction = pressed;
}
public function update(dt:int):void{
if (isJumping){
mTimeJumping = (mTimeJumping + dt);
mDeltaHeight = ((mJumpInitSpeed * dt) + ((mPlayer.world.config.gravity * ((2 * mTimeJumping) + dt)) * dt));
if (mDeltaHeight > 0){
mIsJumpingUp = false;
};
if (mImpulseTimer > 0){
mImpulseTimer = (mImpulseTimer - dt);
};
};
if (mHorizontalBuffer[0] != 0){
mForceX = mHorizontalBuffer[0];
} else {
if (mHorizontalBuffer[1] != 0){
mForceX = mHorizontalBuffer[1];
} else {
mForceX = 0;
};
};
}
public function get fx():Number{
if (mIsRunning){
return ((mPlayer.world.config.playerRunFactor * mForceX));
};
return (mForceX);
}
public function onFly(pressed:Boolean):void{
mIsFly = pressed;
}
public function free():void{
mPlayer = null;
}
public function get isJumpingUp():Boolean{
return (mIsJumpingUp);
}
public function get isJumping():Boolean{
return (mIsJumping);
}
public function get isRunning():Boolean{
return (mIsRunning);
}
public function onCustomJump(iniSpeed:Number):void{
mPlayer.gotoState(Player.ST_PLAYER_JUMP_UP);
mIsJumping = true;
mIsJumpingUp = true;
mTimeJumping = 0;
mImpulseTimer = -1;
mJumpInitSpeed = iniSpeed;
}
}
}//package com.bamtang.swit.platform
Section 111
//World (com.bamtang.swit.platform.World)
package com.bamtang.swit.platform {
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import flash.geom.*;
import com.bamtang.swit.math.*;
public class World {
protected var mObjectManager:NpcManager;
protected var mLayers:Array;
protected var mPointX:int;
protected var mPointY:int;
protected var mObjectsCanvas:MovieClip;
protected var mCanvas:MovieClip;
protected var mPlayerCanvas:MovieClip;
protected var mPlayer:Player;
public var sizeFactor:Number;
protected var mWorldXml:XML;
protected var mWorldConfig:PlatformConfigData;
protected var mCollisions:CollisionLayer;
protected var mWidth:int;
protected var mCamera:Camera;
protected var mHeight:int;
protected var mGame:Object;
protected static const PLAYER_LAYER:String = "player";
protected static const COLLISION_LAYER:String = "collisions";
public static const MAX_SCAN_FLOOR:int = 750;
protected static const OBJECTS_LAYER:String = "items";
public static const MAX_DELTA_TIME:int = 50;
public function World(canvas:MovieClip, game:Object, worldFile:String){
super();
mCanvas = canvas;
mGame = game;
mLayers = new Array();
mWorldXml = Global.app.getXMLData(worldFile);
mWorldConfig = new PlatformConfigData(mWorldXml);
mWidth = mWorldConfig.width;
mHeight = mWorldConfig.height;
createCamera(mWorldXml);
}
public function setCollisionCell(x:int, y:int, cell:int):void{
mCollisions.setCell(x, y, cell);
}
public function get objectsCanvas():MovieClip{
return (mObjectsCanvas);
}
protected function init():void{
mCanvas.x = mCamera.screenX;
mCanvas.y = mCamera.screenY;
var k:int;
while (k < mLayers.length) {
mLayers[k].init();
k++;
};
}
public function checkCollision(actor:PlatformActor):Vector2D{
var overPlatform:Boolean;
var k:int;
var collisionPoint:CollisionPoint;
var coll:Vector2D;
var collision:Vector2D = new Vector2D(0, 0);
var corners:Array = actor.corners;
if (corners){
overPlatform = false;
k = 0;
while (k < corners.length) {
if (corners[k]){
collisionPoint = corners[k];
mPointX = (actor.x + collisionPoint.position.x);
mPointY = (actor.y + collisionPoint.position.y);
coll = mCollisions.checkCollision(mPointX, mPointY, collisionPoint.normal, actor);
if (coll){
if ((((collision.x == 0)) && (!((coll.x == 0))))){
collision.x = (collision.x + coll.x);
};
if ((((collision.y == 0)) && (!((coll.y == 0))))){
collision.y = (collision.y + coll.y);
};
};
if (!overPlatform){
coll = mCollisions.checkPlatforms(mPointX, mPointY, collisionPoint.normal, actor);
if (coll){
overPlatform = true;
if ((((collision.x == 0)) && (!((coll.x == 0))))){
collision.x = (collision.x + coll.x);
};
if ((((collision.y == 0)) && (!((coll.y == 0))))){
collision.y = (collision.y + coll.y);
};
};
};
if (((!((collision.x == 0))) && (!((collision.y == 0))))){
break;
};
};
k++;
};
return ((((!((collision.y == 0))) || (!((collision.x == 0))))) ? collision : null);
};
return (null);
}
public function refreshCollision():void{
mCollisions.refresh();
}
public function get height():int{
return (mHeight);
}
public function getRayCollision(x:Number, y:Number, dir:Vector2D):Vector2D{
if (mCollisions){
return (mCollisions.getRayCollision(x, y, dir));
};
return (null);
}
public function get camera():Camera{
return (mCamera);
}
public function showCollision(show:Boolean):void{
mPlayer.showCollision(show);
mCollisions.visible = show;
mCamera.showCollision(show);
}
public function get tileWidth():int{
return (mCollisions.tileWidth);
}
public function addPlatform(platform:PlatformActor):void{
mCollisions.addPlatform(platform);
}
protected function createCamera(xmlWorld:XML):void{
mCamera = new Camera(this, mWorldConfig.cameraWidth, mWorldConfig.cameraHeight, mWorldConfig.cameraScreenX, mWorldConfig.cameraScreenY);
mCamera.setScale(mWorldConfig.cameraScale);
}
public function get config():PlatformConfigData{
return (mWorldConfig);
}
public function get width():int{
return (mWidth);
}
public function get layers():Array{
return (mLayers);
}
public function update(dt:int):void{
mObjectManager.update(dt);
mPlayer.update(dt);
var k:int;
while (k < mLayers.length) {
if (mLayers[k].visible){
mLayers[k].render();
};
k++;
};
mCamera.update(dt);
mPlayer.showInCamera(mCamera);
}
public function checkWorldBoundaries(actor:PlatformActor):void{
if (actor.bounds){
if (((actor.limitLeft) && (((actor.x + actor.bounds.left) < mCollisions.tileWidth)))){
actor.x = (mCollisions.tileWidth - actor.bounds.left);
};
if (((actor.limitRight) && (((actor.x + actor.bounds.right) > (mWidth - mCollisions.tileWidth))))){
actor.x = ((mWidth - mCollisions.tileWidth) - actor.bounds.right);
};
if (((actor.limitUp) && (((actor.y + actor.bounds.top) <= 0)))){
actor.y = -(actor.bounds.top);
};
if (((actor.limitBottom) && (((actor.y + actor.bounds.bottom) >= mHeight)))){
actor.y = (mHeight - actor.bounds.bottom);
};
};
}
public function get canvas():MovieClip{
return (mCanvas);
}
protected function createLayers():void{
var numObjects:int;
var i:int;
var layer:PlatformLayerData;
var factor:Number = ((mWorldConfig.oldTileSize)<=0) ? 1 : (mWorldConfig.newTileSize / mWorldConfig.oldTileSize);
sizeFactor = factor;
var numLayers:int = mWorldXml.layer.length();
var k:int = (numLayers - 1);
while (k >= 0) {
if (String(mWorldXml.layer[k].@name) == OBJECTS_LAYER){
if (mWorldXml.layer[k].object){
numObjects = mWorldXml.layer[k].object.length();
if (numObjects > 0){
i = 0;
while (i < numObjects) {
mObjectManager.add(new Npc(int(mWorldXml.layer[k].object[i].@id), (factor * Number(mWorldXml.layer[k].object[i].@x)), (factor * Number(mWorldXml.layer[k].object[i].@y))));
i++;
};
};
};
mObjectsCanvas = new MovieClip();
mCanvas.addChild(mObjectsCanvas);
} else {
if (String(mWorldXml.layer[k].@name) == PLAYER_LAYER){
mPlayerCanvas = new MovieClip();
mCanvas.addChild(mPlayerCanvas);
} else {
layer = new PlatformLayerData(mWorldXml.layer[k], mWorldConfig.oldTileSize, mWorldConfig.newTileSize);
if (layer.name == COLLISION_LAYER){
mCollisions = new CollisionLayer(this, layer);
mLayers.push(mCollisions);
} else {
mLayers.push(new PlatformLayer(this, layer));
};
};
};
k--;
};
if (!mPlayerCanvas){
mPlayerCanvas = mObjectsCanvas;
};
mWorldXml = null;
}
public function getMaxFloorRange(x:Number, y:Number, max:int=750):Rectangle{
if (mCollisions){
return (mCollisions.getMaxFloorRange(x, y, max));
};
Application.error("getMaxFloorToLeft: no collisions");
return (new Rectangle(x, y));
}
public function get player():Player{
return (mPlayer);
}
public function free():void{
if (mPlayer){
mPlayer.free();
mPlayer = null;
};
if (mPlayerCanvas != mObjectsCanvas){
mCanvas.removeChild(mPlayerCanvas);
mPlayerCanvas = null;
};
if (mObjectsCanvas){
mCanvas.removeChild(mObjectsCanvas);
mObjectsCanvas = null;
};
mCollisions = null;
mWorldConfig = null;
mObjectManager.free();
mObjectManager = null;
if (mCamera){
mCamera.free();
mCamera = null;
};
var k:int;
while (k < mLayers.length) {
mLayers[k].free();
mLayers[k] = null;
k++;
};
mLayers = null;
}
public function get tileHeight():int{
return (mCollisions.tileHeight);
}
public function get game():Object{
return (mGame);
}
public function getFloorCollision(x:Number, y:Number):Vector2D{
if (mCollisions){
return (mCollisions.getFloorCollision(x, y));
};
Application.error("getFloorCollision: no collisions");
return (new Vector2D(x, y));
}
}
}//package com.bamtang.swit.platform
Section 112
//Common (com.bamtang.swit.utils.Common)
package com.bamtang.swit.utils {
import flash.display.*;
import flash.utils.*;
import flash.filters.*;
public class Common {
public static function mouseDisable(canvas):void{
var canvas = canvas;
canvas.mouseEnabled = false;
//unresolved jump
var _slot1 = e;
return;
if (canvas.numChildren == 0){
return;
};
var k:int;
while (k < canvas.numChildren) {
mouseDisable(canvas.getChildAt(k));
k = (k + 1);
};
}
public static function setRandom(min:Number, max:Number):Number{
return ((Math.floor((Math.random() * ((max - min) + 1))) + min));
}
public static function shake(clip:MovieClip, time:Number=10, strong:Number=2, caller=null, nameFunction:String=null):void{
var internalAction:Function;
var clip = clip;
var time = time;
var strong = strong;
var caller = caller;
var nameFunction = nameFunction;
internalAction = function ():void{
if (int(arguments[0].baseTime) == int(arguments[0].time)){
clearInterval(arguments[0].interval);
if (arguments[0].caller != null){
var _local2 = arguments[0].caller;
_local2[arguments[0].nameFunction]();
};
if (arguments[0].clip != null){
arguments[0].clip.x = arguments[0].x;
arguments[0].clip.y = arguments[0].y;
};
arguments[0] = null;
} else {
if (arguments[0].clip != null){
arguments[0].clip.x = (arguments[0].x + (SMath.random(0, arguments[0].strong) - (arguments[0].strong * 0.5)));
arguments[0].clip.y = (arguments[0].y + (SMath.random(0, arguments[0].strong) - (arguments[0].strong * 0.5)));
};
arguments[0].baseTime++;
};
};
var object:Object = new Object();
object.clip = (clip as MovieClip);
object.x = object.clip.x;
object.y = object.clip.y;
object.caller = caller;
object.nameFunction = (nameFunction as String);
object.time = time;
object.baseTime = 0;
object.strong = strong;
object.interval = setInterval(internalAction, 50, object);
}
public static function getClipByName(nameClip:String):MovieClip{
var ClassDefinition:Class;
if (nameClip != ""){
ClassDefinition = (getDefinitionByName(nameClip) as Class);
return (new (ClassDefinition));
};
return (null);
}
public static function mixer(ids:Array):Array{
var toMixer:Array = ids.concat();
var pos:int;
var i:int;
while (i < toMixer.length) {
pos = (Math.round((Math.random() * ((toMixer.length - 1) - i))) + i);
toMixer.splice(i, 0, toMixer[pos]);
toMixer.splice((pos + 1), 1);
i++;
};
return (toMixer);
}
public static function objectToString(o:Object):void{
var s:String;
for (s in o) {
trace(((s + " = ") + o[s]));
};
}
public static function cloneBiArray(biArray:Array):Array{
var _localArray:Array;
var j:int;
var _tempArray = new Array();
var i:int;
while (i < biArray.length) {
_localArray = new Array();
j = 0;
while (j < biArray[i].length) {
_localArray.push(biArray[i][j]);
j++;
};
_tempArray.push(_localArray);
i++;
};
return (_tempArray);
}
public static function getRandomList(list:Array){
var index:int = SMath.random(0, (list.length - 1));
return (list[index]);
}
public static function replaceIn(text:String, search:String, replaceWith:String, all:Boolean=true):String{
if (all){
while (text.indexOf(search) != -1) {
text = text.replace(search, replaceWith);
};
return (text);
};
return (text.replace(search, replaceWith));
}
public static function execCommand(caller, nameFunction:String, time:int=0, params:Object=null):void{
var internalAction:Function;
var caller = caller;
var nameFunction = nameFunction;
var time = time;
var params = params;
internalAction = function ():void{
var arguments = arguments;
clearInterval(arguments[0].interval);
arguments[0].interval = null;
if (arguments[0].caller[arguments[0].nameFunction] != null){
if (arguments[0].params != null){
var _local3 = arguments[0].caller;
_local3[arguments[0].nameFunction](arguments[0].params);
} else {
_local3 = arguments[0].caller;
_local3[arguments[0].nameFunction]();
};
};
//unresolved jump
var _slot1 = e;
trace(("Error = " + arguments));
arguments[0] = null;
arguments[0] = null;
};
var object:Object = new Object();
object.caller = caller;
object.nameFunction = (nameFunction as String);
object.interval = setInterval(internalAction, time, object);
object.params = params;
}
public static function tint(clip:MovieClip, r:Number=1, g:Number=1, b:Number=1, a:Number=1):void{
var elements:Array = [r, 0, 0, 0, 0, 0, g, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, a, 0];
var NewColorMatrixFilter:ColorMatrixFilter = new ColorMatrixFilter(elements);
clip.filters = [NewColorMatrixFilter];
}
public static function getParams(stringParams:String):Object{
var tempArray:Array;
var z:int;
var params:Object = new Object();
var array:Array = stringParams.split(";");
var i:int;
while (i < array.length) {
tempArray = array[i].split(":");
z = 0;
while (z < tempArray.length) {
params[String(tempArray[0]).concat()] = tempArray[1];
z++;
};
i++;
};
return (params);
}
public static function getDigitsByValue(value:int, num_digits:Number):Array{
var digits:Array;
var s:String = String(value);
var offset:int = (num_digits - s.length);
var i:int;
while (i < offset) {
s = ("0" + s);
i++;
};
digits = s.split("");
return (digits);
}
public static function equals(total:int, ids:Array):Array{
if (total <= ids.length){
return (ids.splice(0, total));
};
var temp:Array = new Array().concat(ids);
return (temp.concat(equals((total - ids.length), ids)));
}
}
}//package com.bamtang.swit.utils
Section 113
//Console (com.bamtang.swit.utils.Console)
package com.bamtang.swit.utils {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.system.*;
public class Console {
private var mTimedLast:int;
private var mFps:int;// = 0
private var mClip:MovieClip;
private var mCollapse:Boolean;
private var mPause:Boolean;
private var mTimedDelta:int;// = 0
private var mTimedCurrent:int;// = 0
private var mTicks:int;// = 0
private var mCountLines:Number;// = 0
public static var TYPE_ERROR:Number = 1;
private static var HEIGHT:Number = 100;
public static var TYPE_ECHO:Number = 0;
public static var TYPE_WARN:Number = 2;
public static var SCENE_WIDTH:Number;
public static var SCENE_HEIGHT:Number;
public static var TYPE_LOG:Number = 3;
public function Console(clipConsole:MovieClip){
mTimedLast = getTimer();
super();
mClip = clipConsole;
mClip.x = 0;
mClip.y = SCENE_HEIGHT;
mClip.mcBar.width = SCENE_WIDTH;
mClip.mcBg.width = SCENE_WIDTH;
mClip.mcBar.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip.btnCopy.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip.btnClear.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip.btnPause.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mClip.txtOut.width = (SCENE_WIDTH - 5);
mClip.txtOut.height = HEIGHT;
mClip.txtOut.text = " :: Init Console ::";
mClip.txtFps.text = "";
mClip.txtLogPlayer.mouseEnabled = false;
}
public function logPlayer(msn:String):void{
mClip.txtLogPlayer.text = msn;
}
private function onClick(e:MouseEvent):void{
switch (e.currentTarget.name){
case "mcBar":
mCollapse = !(mCollapse);
if (mCollapse){
mClip.y = (HEIGHT + SCENE_HEIGHT);
} else {
mClip.y = SCENE_HEIGHT;
};
break;
case "btnCopy":
System.setClipboard(mClip.txtOut.text);
break;
case "btnClear":
mClip.txtOut.htmlText = "";
break;
case "btnPause":
mPause = !(mPause);
if (mPause){
mClip.mcPause.gotoAndStop("PLAY");
out("... console stopped ...", TYPE_WARN);
} else {
mClip.mcPause.gotoAndStop("PAUSE");
out("... console continue ...", TYPE_WARN);
};
break;
};
}
public function showFPS():void{
mTicks++;
mTimedCurrent = getTimer();
mTimedDelta = (mTimedCurrent - mTimedLast);
if (mTimedDelta >= 1000){
mFps = ((mTicks / mTimedDelta) * 1000);
mClip.txtFps.text = ("FPS:" + Math.floor(mFps));
mTicks = 0;
mTimedLast = mTimedCurrent;
};
}
public function out(message, typeAlert:Number):void{
switch (typeAlert){
case TYPE_ECHO:
if (mPause){
return;
};
mCountLines++;
mClip.txtOut.htmlText = (mClip.txtOut.htmlText + (((("<font color='#FFFFFF'> " + mCountLines) + ". ") + message) + " </font><br/>"));
break;
case TYPE_WARN:
mCountLines++;
mClip.txtOut.htmlText = (mClip.txtOut.htmlText + (((("<font color='#FFFF00'> " + mCountLines) + ". ") + message) + " </font><br/>"));
break;
case TYPE_LOG:
mCountLines++;
mClip.txtOut.htmlText = (mClip.txtOut.htmlText + (((("<font color='#00FF00'> " + mCountLines) + ". ") + message) + " </font><br/>"));
break;
case TYPE_ERROR:
mCountLines++;
mClip.txtOut.htmlText = (mClip.txtOut.htmlText + (((("<font color='#FF0000'> <b>" + mCountLines) + ". ") + message) + "</b></font><br/>"));
break;
};
mClip.txtOut.scrollV = mCountLines;
}
}
}//package com.bamtang.swit.utils
Section 114
//Interval (com.bamtang.swit.utils.Interval)
package com.bamtang.swit.utils {
public class Interval {
public var onFinish:Function;
private var mParams:Object;
private var mStop:Boolean;
private var mCallback:Function;
private var mTime:Number;
private var mTimeElapse:int;
private var mIsOver:Boolean;
private var mLoop:int;
private var mIniLoop:int;
public function Interval(callback:Function, milliseconds:Number, loop:int=1, params:Object=null, stop:Boolean=false){
super();
mTime = milliseconds;
mCallback = callback;
mTimeElapse = 0;
mParams = params;
mLoop = loop;
if (mLoop < 1){
mLoop = 1;
};
mIniLoop = mLoop;
mStop = stop;
}
public function stop():void{
mStop = true;
}
public function update(dt:Number):void{
if (mStop){
return;
};
if (mIsOver == true){
return;
};
mTimeElapse = (mTimeElapse + dt);
if (mTimeElapse >= mTime){
mTimeElapse = 0;
mLoop--;
if (mCallback != null){
if (mParams){
mCallback(mParams);
} else {
mCallback();
};
};
if (mLoop == 0){
mIsOver = true;
if (onFinish != null){
onFinish();
};
};
};
}
public function get time():Number{
return (mTime);
}
public function reset(newTime:int=0, newLoop:int=1, callback:Function=null, params:Object=null):void{
if (newTime != 0){
mTime = newTime;
};
if (((!((newLoop == mLoop))) && ((newLoop > 0)))){
mLoop = newLoop;
};
if (callback != null){
mCallback = callback;
};
if (params != null){
mParams = params;
};
mTimeElapse = 0;
mLoop = mIniLoop;
mIsOver = false;
mStop = false;
}
public function get timeElapse():int{
return (mTimeElapse);
}
public function set timeElapse(value:int):void{
mTimeElapse = value;
}
public function free():void{
onFinish = null;
mCallback = null;
mParams = null;
}
public function resume():void{
mStop = false;
}
}
}//package com.bamtang.swit.utils
Section 115
//Movement (com.bamtang.swit.utils.Movement)
package com.bamtang.swit.utils {
public class Movement {
public var params:Object;
private var mDistance:int;
private var mVx:Number;
private var mVy:Number;
private var mX:Number;
private var mY:Number;
private var mOldX:int;
private var mOldY:int;
private var mDx:Number;
private var mDy:Number;
public var useDeltaTime:Boolean;
private var mAngle:Number;
private var mOffset:Number;
private var mIsMove:Boolean;
private var mSpeed:Number;
public var onEndMove:Function;
private var mXTarget:Number;
private var mYTarget:Number;
public function Movement(speed:Number, x:Number=0, y:Number=0, params:Object=null){
super();
setPosition(x, y);
mOffset = 2;
mSpeed = speed;
useDeltaTime = true;
this.params = params;
}
public function get speed():Number{
return (mSpeed);
}
public function update(dt:int):void{
if (mIsMove){
if (!useDeltaTime){
dt = 1;
};
mX = (mX + (mVx * dt));
mY = (mY + (mVy * dt));
mDx = (mOldX - mX);
mDy = (mOldY - mY);
if (Math.sqrt(((mDx * mDx) + (mDy * mDy))) >= mDistance){
setPosition(mXTarget, mYTarget);
if (onEndMove != null){
onEndMove();
};
};
};
}
public function get isMove():Boolean{
return (mIsMove);
}
public function get angle():Number{
return (mAngle);
}
public function gotoPosition(x:Number, y:Number, newSpeed:Number=0):void{
mXTarget = x;
mYTarget = y;
mOldX = mX;
mOldY = mY;
mDx = (mXTarget - mOldX);
mDy = (mYTarget - mOldY);
mAngle = Math.atan2(mDy, mDx);
mDistance = Math.sqrt(((mDx * mDx) + (mDy * mDy)));
if (mDistance == 0){
mVx = 0;
mVy = 0;
} else {
mVx = ((mDx / mDistance) * mSpeed);
mVy = ((mDy / mDistance) * mSpeed);
};
mIsMove = true;
if (newSpeed != 0){
mSpeed = newSpeed;
};
}
public function setPosition(x:Number, y:Number):void{
mX = x;
mY = y;
mIsMove = false;
}
public function set offSet(value:Number):void{
mOffset = value;
}
public function get y():Number{
return (mY);
}
public function get x():Number{
return (mX);
}
}
}//package com.bamtang.swit.utils
Section 116
//SMath (com.bamtang.swit.utils.SMath)
package com.bamtang.swit.utils {
public class SMath {
private function uintToARGB(color:uint):uint{
return (argbToUint(((color >> 24) & 0xFF), ((color >> 16) & 0xFF), ((color >> 8) & 0xFF), (color & 0xFF)));
}
public static function argbToUint(a:Number, r:Number, g:Number, b:Number):uint{
return (((((a << 24) | (r << 16)) | (g << 8)) | b));
}
public static function abs(num:Number):Number{
return (((num)<0) ? -(num) : num);
}
public static function random(min:Number, max:Number):Number{
return ((int((Math.random() * ((max - min) + 1))) + min));
}
public static function uintToHexadecimal(color:uint):String{
return (color.toString(16).toUpperCase());
}
public static function degrees(dx:Number, dy:Number):Number{
return (((Math.atan2(dy, dx) * 180) / Math.PI));
}
public static function flip(num:int):int{
return ((~(num) + 1));
}
public static function round(num:Number, decimals:int):Number{
var exp:int = Math.pow(10, decimals);
return ((Math.round((num * exp)) / exp));
}
}
}//package com.bamtang.swit.utils
Section 117
//Main (Main)
package {
import flash.events.*;
import com.bamtang.swit.core.*;
import flash.display.*;
import com.bamtang.game.*;
import flash.utils.*;
import com.bamtang.game.gui.*;
public class Main extends MovieClip {
private var mNewTime:Number;// = 0
private var mOldTime:Number;// = 0
private var mDeltaTime:Number;// = 0
public function Main():void{
super();
if (this.stage){
init(null);
} else {
this.addEventListener(Event.ADDED_TO_STAGE, init);
};
}
private function onMainKeyDown(e:KeyboardEvent):void{
if (Global.guiManager != null){
Global.guiManager.onKeyDown(e.keyCode);
};
}
private function onMainKeyUp(e:KeyboardEvent):void{
if (Global.guiManager != null){
Global.guiManager.onKeyUp(e.keyCode);
};
}
private function update(dt:int):void{
if (Global.guiManager != null){
Global.guiManager.update(dt);
};
}
private function onLoadProcess(appLoading:Application):void{
if (appLoading.mClipLoader["done_txt"] != null){
appLoading.mClipLoader["done_txt"].text = (appLoading.percentLoaded + "%");
};
}
private function init(e:Event):void{
var e = e;
Global.stage = this.stage;
Global.stage = this.parent.parent.stage;
//unresolved jump
var _slot1 = e;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
this.addEventListener(Event.ENTER_FRAME, onTick);
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, onMainKeyDown);
this.stage.addEventListener(KeyboardEvent.KEY_UP, onMainKeyUp);
this.stage.addEventListener(Event.DEACTIVATE, onDeactivate);
this.stage.addEventListener(Event.ACTIVATE, onActivate);
Global.scene = new Layer(this);
Global.app = new Application(Global.PATH_APP, this);
Global.app.onLoadComplete = this.onLoadComplete;
Global.app.onLoadProcess = this.onLoadProcess;
}
private function onActivate(e:Event):void{
if (Global.guiManager){
Global.guiManager.onActivate(true);
};
}
private function onGoGame():void{
Application.instance.removeLoader();
stage.frameRate = Application.FRAMERATE;
stage.quality = Application.QUALITY;
Global.guiManager = new GuiManager(Global.scene.addEmptyChild());
Global.guiManager.gotoScreen(GuiManager.SC_MAIN_MENU);
}
private function onDeactivate(e:Event):void{
if (Global.guiManager){
Global.guiManager.onActivate(false);
};
}
private function onTick(e:Event):void{
mNewTime = getTimer();
mDeltaTime = (mNewTime - mOldTime);
mOldTime = mNewTime;
update(mDeltaTime);
Application.showFPS();
}
private function onLoadComplete():void{
Application.instance.mClipLoader.gotoAndPlay("GOPLAY");
Application.instance.mClipLoader.finishAnimationLoader = onGoGame;
}
}
}//package