Section 1
//AbstractMain (com.kerb.game.AbstractMain)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
public class AbstractMain extends Sprite {
protected var PreviousSectionClass:Class;
protected var currentSection:AbstractSection;
protected var overlaySprite:Sprite;
protected var contentSprite:Sprite;
public function AbstractMain(){
contentSprite = new Sprite();
addChild(contentSprite);
overlaySprite = new Sprite();
addChild(overlaySprite);
}
protected function gotoSection(_arg1:Class):void{
disposeCurrentSection();
currentSection = new (_arg1);
currentSection.setPreviousSection(PreviousSectionClass);
currentSection.addEventListener(Event.COMPLETE, onSectionComplete);
contentSprite.addChild(currentSection);
PreviousSectionClass = _arg1;
}
protected function disposeCurrentSection():void{
if (currentSection != null){
currentSection.removeEventListener(Event.COMPLETE, onSectionComplete);
currentSection.dispose();
contentSprite.removeChild(currentSection);
};
}
protected function onIdentClick(_arg1:MouseEvent):void{
}
protected function onIdentComplete(_arg1:Event):void{
currentSection.removeEventListener(MouseEvent.CLICK, onIdentClick);
onSectionComplete(_arg1);
}
protected function showIdent(_arg1:MovieClip, _arg2:Class):void{
disposeCurrentSection();
currentSection = new Ident(_arg1, _arg2);
currentSection.addEventListener(Event.COMPLETE, onIdentComplete);
currentSection.addEventListener(MouseEvent.CLICK, onIdentClick);
currentSection.buttonMode = true;
contentSprite.addChild(currentSection);
}
protected function onSectionComplete(_arg1:Event):void{
gotoSection(currentSection.getNextSection());
}
}
}//package com.kerb.game
Section 2
//AbstractPreload (com.kerb.game.AbstractPreload)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
public class AbstractPreload extends MovieClip {
protected var lowQualityItem:ContextMenuItem;
protected var url:String;
protected var highQualityItem:ContextMenuItem;
protected var mediumQualityItem:ContextMenuItem;
public static const KERB_SITE_URL:String = "http://www.kerb.co.uk";
public static const DOWNLOAD_THIS_GAME_URL:String = "http://blog.kerb.co.uk/download.php?url=";
public static const KERB_GAMES_URL:String = "http://www.kerbgames.com";
public function AbstractPreload(){
initStage();
initContextMenu();
}
protected function initContextMenu():void{
var _local1:ContextMenuItem;
contextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
url = loaderInfo.url;
_local1 = new ContextMenuItem("Built by Kerb!", false);
_local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect);
contextMenu.customItems.push(_local1);
_local1 = new ContextMenuItem("Download This Game", true);
_local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onDownloadMenuItemSelect);
contextMenu.customItems.push(_local1);
}
protected function onKerbMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest(KERB_SITE_URL), "_blank");
}
protected function initStage():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.stageFocusRect = false;
}
protected function onDownloadMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest((DOWNLOAD_THIS_GAME_URL + url)), "_blank");
}
protected function initMainContent(_arg1:String):void{
var _local2:Class = Class(getDefinitionByName(_arg1));
if (_local2){
addChild((new (_local2) as DisplayObject));
};
}
protected function onQualityMenuItemSelect(_arg1:Event):void{
lowQualityItem.caption = "Low Quality (fast)";
mediumQualityItem.caption = "Medium Quality";
highQualityItem.caption = "High Quality (slow)";
switch (_arg1.currentTarget){
case lowQualityItem:
lowQualityItem.caption = ("• " + lowQualityItem.caption);
stage.quality = StageQuality.LOW;
break;
case mediumQualityItem:
mediumQualityItem.caption = ("• " + mediumQualityItem.caption);
stage.quality = StageQuality.MEDIUM;
break;
case highQualityItem:
highQualityItem.caption = ("• " + highQualityItem.caption);
stage.quality = StageQuality.HIGH;
break;
};
}
}
}//package com.kerb.game
Section 3
//AbstractSection (com.kerb.game.AbstractSection)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
public class AbstractSection extends MovieClip implements IDisposable {
protected var NextSectionClass:Class;
protected var PreviousSectionClass:Class;
protected var keyboardNavigator:KeyboardNavigator;
public function AbstractSection(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
keyboardNavigator = new KeyboardNavigator(stage);
init();
}
public function setPreviousSection(_arg1:Class):void{
this.PreviousSectionClass = _arg1;
}
public function dispose():void{
keyboardNavigator.dispose();
}
protected function gotoNextSection():void{
dispatchEvent(new Event(Event.COMPLETE));
}
protected function init():void{
}
public function getNextSection():Class{
return (NextSectionClass);
}
}
}//package com.kerb.game
Section 4
//GameTimer (com.kerb.game.GameTimer)
package com.kerb.game {
import flash.events.*;
import com.kerb.utils.*;
import flash.utils.*;
public class GameTimer extends EventDispatcher implements IDisposable {
protected var _countdownTimer:Timer;
protected var _paused:Boolean;
protected var _stopTime:int;
protected var _startTime:int;
protected var _pauseStartTime:int;
protected var _countdownTime:int;
protected var _pauseTotalTime:int;
public function GameTimer(){
reset();
}
public function stop():void{
if (_startTime != -1){
if (_paused){
unpause();
};
if (_countdownTimer){
_countdownTimer.stop();
};
_stopTime = getTimer();
};
}
public function getTimeAsString(_arg1:String=":", _arg2:Boolean=true, _arg3:Boolean=true):String{
var _local4:int = (totalTime / 1000);
var _local5:int = (_local4 / 60);
var _local6:int = (_local4 % 60);
var _local7 = "";
var _local8:int = Math.abs(_local5);
var _local9:int = Math.abs(_local6);
if (_local4 < 0){
_local7 = (_local7 + "-");
};
if (((_arg2) && ((_local8 < 10)))){
_local7 = (_local7 + "0");
};
_local7 = (_local7 + _local8.toString());
_local7 = (_local7 + _arg1);
if (((_arg3) && ((_local9 < 10)))){
_local7 = (_local7 + "0");
};
_local7 = (_local7 + _local9.toString());
return (_local7);
}
public function get startTime():int{
return (_startTime);
}
public function addTime(_arg1:int):void{
var _local2:Boolean;
if (_countdownTimer){
if (_countdownTime == -1){
_startTime = (_startTime + _arg1);
} else {
_local2 = paused;
start((totalTime + _arg1));
if (_local2){
pause();
};
};
};
}
public function reset():void{
_startTime = -1;
_stopTime = -1;
_countdownTime = -1;
_pauseStartTime = 0;
_pauseTotalTime = 0;
_paused = false;
dispose();
}
public function get countdownTime():int{
return (_countdownTime);
}
public function start(_arg1:int=-1):void{
reset();
if (_arg1 != -1){
_countdownTime = _arg1;
_countdownTimer = new Timer(_arg1, 1);
_countdownTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
_countdownTimer.start();
};
_startTime = getTimer();
}
public function get paused():Boolean{
return (_paused);
}
public function get stopTime():int{
return (_stopTime);
}
public function get totalTime():int{
var _local2:int;
var _local1:int = _pauseTotalTime;
if (_paused){
_local1 = (_local1 + (getTimer() - _pauseStartTime));
};
if (_startTime == -1){
_local2 = 0;
} else {
if (_stopTime == -1){
_local2 = ((getTimer() - _startTime) - _local1);
} else {
_local2 = ((_stopTime - _startTime) - _local1);
};
};
if (_countdownTime != -1){
_local2 = (_countdownTime - _local2);
if (_local2 < 0){
_local2 = 0;
};
};
return (_local2);
}
public function pause():void{
if (((((!(_paused)) && ((_stopTime == -1)))) && (!((_startTime == -1))))){
_paused = true;
_pauseStartTime = getTimer();
if (_countdownTimer){
_countdownTimer.stop();
};
};
}
public function dispose():void{
if (_countdownTimer){
_countdownTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
};
_countdownTimer = null;
}
public function unpause():void{
if (((((_paused) && ((_stopTime == -1)))) && (!((_startTime == -1))))){
_paused = false;
_pauseTotalTime = (_pauseTotalTime + (getTimer() - _pauseStartTime));
if (_countdownTimer){
_countdownTimer.delay = totalTime;
_countdownTimer.start();
};
};
}
protected function onTimerComplete(_arg1:TimerEvent):void{
stop();
_countdownTimer.stop();
_countdownTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
_countdownTimer = null;
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package com.kerb.game
Section 5
//Ident (com.kerb.game.Ident)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
public class Ident extends AbstractSection {
protected var mc:MovieClip;
public function Ident(_arg1:MovieClip, _arg2:Class){
this.mc = _arg1;
this.NextSectionClass = _arg2;
}
override protected function init():void{
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onEnterFrame(_arg1:Event):void{
if (mc.currentFrame == mc.totalFrames){
mc.stop();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
dispatchEvent(new Event(Event.COMPLETE));
};
}
override public function dispose():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package com.kerb.game
Section 6
//KeyboardNavigator (com.kerb.game.KeyboardNavigator)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.ui.*;
public class KeyboardNavigator {
private var stage:Stage;
private var tabIndexes:Array;
private var keyListenerSet:Boolean;
private var controllableItems:Dictionary;
private var defaultAction:Function;
public function KeyboardNavigator(_arg1:Stage){
this.stage = _arg1;
init();
}
public function addInteractiveObject(_arg1:InteractiveObject, _arg2:Function, _arg3:int=-1):void{
controllableItems[_arg1] = _arg2;
if (_arg3 > -1){
tabIndexes[_arg3] = _arg1;
_arg1.tabEnabled = true;
};
_arg1.tabIndex = _arg3;
active = true;
}
protected function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:Function;
var _local3:int;
var _local4:InteractiveObject;
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
_local2 = controllableItems[stage.focus];
if (_local2 == null){
defaultAction();
} else {
_local2();
};
} else {
_local3 = -1;
_local4 = null;
if ((((stage.focus is InteractiveObject)) && (!((stage.focus == stage))))){
_local3 = (stage.focus as InteractiveObject).tabIndex;
};
if (_local3 == -1){
_local4 = getLowestTabIndex();
} else {
if (_arg1.keyCode == Keyboard.LEFT){
_local4 = getNextLowestTabIndex(_local3);
if (_local4 == null){
_local4 = getHighestTabIndex();
};
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
_local4 = getNextHighestTabIndex(_local3);
if (_local4 == null){
_local4 = getLowestTabIndex();
};
};
};
};
if (_local4){
stage.focus = _local4;
};
};
}
public function setDefaultAction(_arg1:Function):void{
this.defaultAction = _arg1;
active = true;
}
public function get active():Boolean{
return (keyListenerSet);
}
protected function getNextLowestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 - 1);
while (_local4 >= 0) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4--;
};
return (_local2);
}
public function set active(_arg1:Boolean):void{
if (((keyListenerSet) && (!(_arg1)))){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
keyListenerSet = false;
} else {
if (((!(keyListenerSet)) && (_arg1))){
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
keyListenerSet = true;
};
};
}
protected function init():void{
controllableItems = new Dictionary();
tabIndexes = new Array();
defaultAction = new Function();
stage.focus = stage;
keyListenerSet = false;
}
protected function getHighestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = (tabIndexes.length - 1);
while (_local2 >= 0) {
if (tabIndexes[_local2] != undefined){
_local1 = tabIndexes[_local2];
break;
};
_local2--;
};
return (_local1);
}
protected function getLowestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = tabIndexes.length;
var _local3:int;
while (_local3 < _local2) {
if (tabIndexes[_local3] != undefined){
_local1 = tabIndexes[_local3];
break;
};
_local3++;
};
return (_local1);
}
protected function getNextHighestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 + 1);
while (_local4 < _local3) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4++;
};
return (_local2);
}
public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
controllableItems = null;
tabIndexes = null;
defaultAction = null;
}
}
}//package com.kerb.game
Section 7
//AbstractCharacter (com.kerb.patapon.game.characters.AbstractCharacter)
package com.kerb.patapon.game.characters {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.game.projectiles.*;
import com.kerb.patapon.game.*;
import flash.utils.*;
public class AbstractCharacter extends EventDispatcher {
protected var nextAction:Function;
protected var offsetFrequency:Number;
protected var state:int;
protected var offset:Number;
public var mc:MovieClip;
protected var attacking:Boolean;
protected var thownShown:Boolean;
protected var sfxTimeOffset:int;
protected var deferCounter:int;
protected var offsetAmplitude:Number;
public var speaking:Boolean;
protected var velocity:Number;
protected var offsetDeferCounter:int;
private var hitCounter:int;
protected var deferFunction:Function;
private var damage:int;
public var projectile:Projectile;
private var jumping:Boolean;
public var x:Number;
protected static const ACCELERATION:Number = 1.1;
protected static const STATE_FINISHING:int = 2;
public static const SPACING:Number = 22;
protected static const VELOCITY_DAMPING:Number = 0.9;
protected static const MAX_DAMAGE:int = 50;
protected static const MIN_DAMAGE_PAUSE_FRAMES:int = 30;
protected static const STATE_NULL:int = -1;
public static const EVENT_DIE:String = "onDie";
protected static const STATE_MOVING:int = 1;
protected static const VELOCITY:Number = 1;
protected static const STATE_NOTHING:int = 0;
public function AbstractCharacter(_arg1:Number, _arg2:int){
init();
if (_arg2 == 0){
offset = 0;
offsetFrequency = 0;
offsetAmplitude = 0;
} else {
offset = (_arg2 * SPACING);
offsetFrequency = (((2 * Math.PI) * Math.random()) * 0.0005);
offsetAmplitude = (20 * Math.random());
if (Math.random() < 0.5){
offsetAmplitude = -(offsetAmplitude);
};
};
offsetDeferCounter = 0;
x = _arg1;
mc.x = x;
mc.y = (Renderer.groundLevel + 1);
setAnimation("idle");
state = STATE_NOTHING;
velocity = 0;
attacking = false;
thownShown = false;
jumping = false;
speaking = false;
damage = 0;
hitCounter = 0;
deferCounter = 0;
sfxTimeOffset = -1;
}
protected function die():void{
setAnimation("die");
dispatchEvent(new Event(EVENT_DIE));
}
protected function init():void{
}
protected function updateMovement(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
if (state == STATE_MOVING){
velocity = VELOCITY;
} else {
if (state == STATE_FINISHING){
velocity = (3 * VELOCITY);
} else {
velocity = (velocity * VELOCITY_DAMPING);
};
};
if (offsetDeferCounter == 0){
if (offset != 0){
_local4 = ((Math.random() * 3) - 1.5);
_local5 = (((_arg1 + offset) - x) + _local4);
_local5 = (_local5 + (offsetAmplitude * Math.sin((offsetFrequency * getTimer()))));
_local6 = ((Math.random() * 10) + 5);
if (_local5 > _local6){
_local5 = _local6;
} else {
if (_local5 < -(_local6)){
_local5 = -(_local6);
};
};
x = (x + (0.2 * _local5));
if (Math.random() < 0.005){
offsetDeferCounter = ((Math.random() * 100) + 30);
};
};
} else {
offsetDeferCounter--;
};
if ((this is Hatapon)){
if (x > _arg2){
x = (x - VELOCITY);
} else {
if ((x + velocity) < _arg2){
x = (x + velocity);
};
};
} else {
if (x > _arg3){
x = (x - VELOCITY);
} else {
if ((x + velocity) < _arg3){
x = (x + velocity);
};
};
};
hitCounter++;
mc.x = x;
}
public function getThrowForce(_arg1:Boolean):Point{
return (new Point());
}
public function pata():void{
if (Math.random() < 0.1){
deferCounter = (Math.random() + 1);
deferFunction = pata;
return;
};
setAnimation("pata");
if (state == STATE_NOTHING){
nextAction = idle;
} else {
nextAction = march;
};
}
protected function initWeaponSound():void{
sfxTimeOffset = (getTimer() + (500 * Math.random()));
}
public function finish():void{
state = STATE_FINISHING;
nextAction = march;
}
private function jump():void{
setAnimation("glee");
nextAction = march;
}
public function stationary():void{
setAnimation("stationary");
}
public function hit(_arg1:int):Boolean{
if (hitCounter > MIN_DAMAGE_PAUSE_FRAMES){
damage = (damage + _arg1);
hitCounter = 0;
if (damage > MAX_DAMAGE){
die();
return (false);
};
return (true);
};
return (false);
}
protected function setAnimation(_arg1:String):void{
mc.gotoAndStop(_arg1);
}
public function march():void{
if (Math.random() < 0.1){
deferCounter = ((Math.random() * 2) + 1);
deferFunction = march;
return;
};
if (((!(thownShown)) && ((Math.random() < 0.2)))){
setAnimation("throw");
nextAction = march;
thownShown = true;
} else {
setAnimation("forwards");
nextAction = null;
thownShown = false;
};
if (state != STATE_FINISHING){
state = STATE_MOVING;
};
}
public function glee():void{
if (!jumping){
nextAction = jump;
jumping = true;
};
}
public function attack(_arg1:Boolean=false):void{
if (Math.random() < 0.1){
deferCounter = (Math.random() + 3);
deferFunction = attack;
return;
};
setAnimation("attack");
initWeaponSound();
nextAction = idle;
state = STATE_NULL;
attacking = true;
}
public function update(_arg1:Array, _arg2:Boolean, _arg3:Number, _arg4:Number):Boolean{
if (deferCounter > 0){
if (--deferCounter == 0){
deferFunction();
};
};
if (nextAction != null){
if (mc.animation){
if (mc.animation.currentFrame == mc.animation.totalFrames){
if (state != STATE_FINISHING){
state = STATE_NULL;
};
nextAction();
if (state != STATE_FINISHING){
nextAction = null;
};
attacking = false;
jumping = false;
};
};
};
updateMovement(_arg1[0].x, _arg3, _arg4);
if (sfxTimeOffset != -1){
if (getTimer() > sfxTimeOffset){
playWeaponSound();
sfxTimeOffset = -1;
};
};
return (false);
}
public function pon():void{
if (Math.random() < 0.1){
deferCounter = (Math.random() + 1);
deferFunction = pon;
return;
};
setAnimation("pon");
if (state == STATE_NOTHING){
nextAction = idle;
} else {
nextAction = march;
};
}
public function getGlobalPosition(_arg1:Boolean):Point{
return (new Point());
}
public function idle():void{
if (state != STATE_NOTHING){
state = STATE_NOTHING;
setAnimation("idle");
};
}
public function mistake():void{
if (Math.random() < 0.1){
deferCounter = ((Math.random() * 2) + 1);
deferFunction = mistake;
return;
};
if (state != STATE_NOTHING){
if ((((Math.random() < 0.3)) && ((state == STATE_MOVING)))){
setAnimation("fallOver");
} else {
setAnimation("mistake");
};
state = STATE_NOTHING;
nextAction = idle;
};
}
protected function playWeaponSound():void{
}
}
}//package com.kerb.patapon.game.characters
Section 8
//Hatapon (com.kerb.patapon.game.characters.Hatapon)
package com.kerb.patapon.game.characters {
import flash.display.*;
import com.kerb.patapon.*;
public class Hatapon extends AbstractCharacter {
public function Hatapon(_arg1:Number, _arg2:int){
super(_arg1, _arg2);
}
override protected function init():void{
mc = (Main.assetFactory.createDisplayObject("HataponAsset") as MovieClip);
}
override public function march():void{
setAnimation("forwards");
nextAction = null;
if (state != STATE_FINISHING){
state = STATE_MOVING;
};
}
override public function idle():void{
if (state != STATE_NOTHING){
state = STATE_NOTHING;
setAnimation("forwards");
};
}
override public function glee():void{
}
override public function mistake():void{
if (Math.random() < 0.1){
deferCounter = ((Math.random() * 2) + 1);
deferFunction = mistake;
return;
};
if (state != STATE_NOTHING){
state = STATE_NOTHING;
setAnimation("mistake");
nextAction = mistake;
};
}
}
}//package com.kerb.patapon.game.characters
Section 9
//Hero (com.kerb.patapon.game.characters.Hero)
package com.kerb.patapon.game.characters {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.projectiles.*;
public class Hero extends Yuripon {
private var dead:Boolean;
private var heroEffect:Boolean;
private var heroEffectChanging:Boolean;
public function Hero(_arg1:Number, _arg2:int){
super(_arg1, _arg2);
projectile = new HeroSpear();
heroEffect = false;
dead = false;
}
private function powerUp():void{
mc.gotoAndStop("powerUp");
nextAction = march;
state = STATE_NULL;
heroEffectChanging = true;
}
override protected function setAnimation(_arg1:String):void{
super.setAnimation(_arg1);
if (((mc.animation) && (mc.animation.spear))){
if (mc.animation.spear.spear){
mc.animation.spear.spear.gotoAndStop((heroEffect) ? 2 : 1);
} else {
mc.animation.spear.gotoAndStop((heroEffect) ? 2 : 1);
};
};
}
override public function march():void{
if (heroEffectChanging){
nextAction = march;
} else {
super.march();
};
}
override public function mistake():void{
if (!heroEffectChanging){
super.mistake();
};
}
private function powerDown():void{
mc.gotoAndStop("powerDown");
nextAction = idle;
state = STATE_NULL;
heroEffectChanging = true;
}
override public function update(_arg1:Array, _arg2:Boolean, _arg3:Number, _arg4:Number):Boolean{
var _local6:int;
var _local5:Boolean;
if (attacking){
if (mc.animation){
_local6 = (_arg2) ? 12 : 3;
if (mc.animation.currentFrame == _local6){
_local5 = true;
};
};
};
if (deferCounter > 0){
if (--deferCounter == 0){
deferFunction();
};
};
if (nextAction != null){
if (mc.animation){
if (mc.animation.currentFrame == mc.animation.totalFrames){
if (heroEffectChanging){
if (heroEffect){
mc.scaleX = 1.118;
mc.scaleY = 1.118;
} else {
mc.scaleX = 1;
mc.scaleY = 1;
};
heroEffectChanging = false;
};
if (state != STATE_FINISHING){
state = STATE_NULL;
};
nextAction();
if (state != STATE_FINISHING){
nextAction = null;
};
attacking = false;
};
};
};
updateMovement(_arg1[0].x, _arg3, _arg4);
if (((mc.animation) && (mc.animation.spear))){
if (mc.animation.spear.spear){
mc.animation.spear.spear.gotoAndStop((heroEffect) ? 2 : 1);
} else {
mc.animation.spear.gotoAndStop((heroEffect) ? 2 : 1);
};
};
return (_local5);
}
override public function attack(_arg1:Boolean=false):void{
if (!heroEffectChanging){
super.attack();
};
}
override public function glee():void{
if (heroEffectChanging){
nextAction = glee;
} else {
super.glee();
};
}
public function setHeroEffect(_arg1:Boolean):void{
if (dead){
return;
};
if (((!(heroEffect)) && (_arg1))){
powerUp();
} else {
if (((heroEffect) && (!(_arg1)))){
powerDown();
};
};
heroEffect = _arg1;
(projectile as HeroSpear).setDamage(heroEffect);
projectile.mc.spear.gotoAndStop((heroEffect) ? 2 : 1);
}
override protected function die():void{
super.die();
dead = true;
}
override public function pon():void{
if (!heroEffectChanging){
super.pon();
};
}
override public function idle():void{
if (heroEffectChanging){
nextAction = idle;
} else {
super.idle();
};
}
override protected function init():void{
mc = (Main.assetFactory.createDisplayObject("HeroAsset") as MovieClip);
}
override public function stationary():void{
if (heroEffectChanging){
nextAction = stationary;
} else {
super.stationary();
};
}
override public function getThrowForce(_arg1:Boolean):Point{
var _local2:Number;
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local3:Number = (4 + _local2);
if (_arg1){
_local3 = (_local3 + 3);
};
if (heroEffect){
_local3 = (_local3 + 3);
};
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local4:Number = (-7 + _local2);
return (new Point(_local3, _local4));
}
override public function pata():void{
if (!heroEffectChanging){
super.pata();
};
}
}
}//package com.kerb.patapon.game.characters
Section 10
//Tatepon (com.kerb.patapon.game.characters.Tatepon)
package com.kerb.patapon.game.characters {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import flash.media.*;
public class Tatepon extends AbstractCharacter {
public static const AXE_DAMAGE:Number = 3;
private static var axe4Sound:Sound;
private static var axe3Sound:Sound;
private static var axe2Sound:Sound;
private static var axe1Sound:Sound;
public function Tatepon(_arg1:Number, _arg2:int){
super(_arg1, _arg2);
if (!axe1Sound){
axe1Sound = Main.assetFactory.createSound("Axe1Sound");
};
if (!axe2Sound){
axe2Sound = Main.assetFactory.createSound("Axe2Sound");
};
if (!axe3Sound){
axe3Sound = Main.assetFactory.createSound("Axe3Sound");
};
if (!axe4Sound){
axe4Sound = Main.assetFactory.createSound("Axe4Sound");
};
}
override protected function init():void{
mc = (Main.assetFactory.createDisplayObject("TateponAsset") as MovieClip);
}
override public function update(_arg1:Array, _arg2:Boolean, _arg3:Number, _arg4:Number):Boolean{
var _local6:int;
var _local5:Boolean;
super.update(_arg1, _arg2, _arg3, _arg4);
if (attacking){
if (mc.animation){
_local6 = 11;
if (mc.animation.currentFrame == _local6){
_local5 = true;
};
};
if (x < _arg4){
x = (x + 5);
};
};
return (_local5);
}
override public function getGlobalPosition(_arg1:Boolean):Point{
var _local2:Number;
var _local3:Number;
_local2 = 24;
_local3 = -17;
var _local4:Point = new Point(_local2, _local3);
_local4 = mc.localToGlobal(_local4);
return (_local4);
}
public function getLocalPosition(_arg1:Point):Point{
var _local2:Point = _arg1.clone();
return (mc.parent.globalToLocal(_local2));
}
override protected function playWeaponSound():void{
var _local1:Number = Math.random();
if (_local1 < 0.25){
axe1Sound.play();
} else {
if (_local1 < 0.5){
axe2Sound.play();
} else {
if (_local1 < 0.75){
axe3Sound.play();
} else {
axe4Sound.play();
};
};
};
}
}
}//package com.kerb.patapon.game.characters
Section 11
//Yumipon (com.kerb.patapon.game.characters.Yumipon)
package com.kerb.patapon.game.characters {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import flash.media.*;
import com.kerb.patapon.game.projectiles.*;
public class Yumipon extends AbstractCharacter {
private static const THROW_FORCE_VARIANCE:Number = 1;
private static var arrow3Sound:Sound;
private static var arrow2Sound:Sound;
private static var arrow1Sound:Sound;
private static var arrow4Sound:Sound;
public function Yumipon(_arg1:Number, _arg2:int){
super(_arg1, _arg2);
projectile = new Arrow();
if (!arrow1Sound){
arrow1Sound = Main.assetFactory.createSound("Arrow1Sound");
};
if (!arrow2Sound){
arrow2Sound = Main.assetFactory.createSound("Arrow2Sound");
};
if (!arrow3Sound){
arrow3Sound = Main.assetFactory.createSound("Arrow3Sound");
};
if (!arrow4Sound){
arrow4Sound = Main.assetFactory.createSound("Arrow4Sound");
};
}
override protected function init():void{
mc = (Main.assetFactory.createDisplayObject("YumiponAsset") as MovieClip);
}
override public function getGlobalPosition(_arg1:Boolean):Point{
var _local2:Number;
var _local3:Number;
if (_arg1){
_local2 = (mc.x + 5);
_local3 = (mc.y - 110);
} else {
_local2 = (mc.x + 19.6);
_local3 = (mc.y - 36);
};
return (new Point(_local2, _local3));
}
override public function attack(_arg1:Boolean=false):void{
if (Math.random() < 0.1){
deferCounter = ((Math.random() * 2) + 1);
deferFunction = attack;
return;
};
if (_arg1){
setAnimation("feverAttack");
} else {
setAnimation("attack");
};
initWeaponSound();
nextAction = idle;
state = STATE_NULL;
attacking = true;
}
override public function update(_arg1:Array, _arg2:Boolean, _arg3:Number, _arg4:Number):Boolean{
var _local6:int;
var _local5:Boolean;
if (attacking){
if (mc.animation){
_local6 = (_arg2) ? 11 : 2;
if (mc.animation.currentFrame == _local6){
_local5 = true;
};
};
};
super.update(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
override public function getThrowForce(_arg1:Boolean):Point{
var _local2:Number;
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local3:Number = (5 + _local2);
if (_arg1){
_local3 = (_local3 + 3);
};
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local4:Number = (-7 + _local2);
return (new Point(_local3, _local4));
}
override protected function playWeaponSound():void{
var _local1:Number = Math.random();
if (_local1 < 0.25){
arrow1Sound.play();
} else {
if (_local1 < 0.5){
arrow2Sound.play();
} else {
if (_local1 < 0.75){
arrow3Sound.play();
} else {
arrow4Sound.play();
};
};
};
}
}
}//package com.kerb.patapon.game.characters
Section 12
//Yuripon (com.kerb.patapon.game.characters.Yuripon)
package com.kerb.patapon.game.characters {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import flash.media.*;
import com.kerb.patapon.game.projectiles.*;
public class Yuripon extends AbstractCharacter {
protected static const THROW_FORCE_VARIANCE:Number = 1;
private static var spear3Sound:Sound;
private static var spear2Sound:Sound;
private static var spear1Sound:Sound;
private static var spear4Sound:Sound;
public function Yuripon(_arg1:Number, _arg2:int){
super(_arg1, _arg2);
projectile = new Spear();
if (!spear1Sound){
spear1Sound = Main.assetFactory.createSound("Spear1Sound");
};
if (!spear2Sound){
spear2Sound = Main.assetFactory.createSound("Spear2Sound");
};
if (!spear3Sound){
spear3Sound = Main.assetFactory.createSound("Spear3Sound");
};
if (!spear4Sound){
spear4Sound = Main.assetFactory.createSound("Spear4Sound");
};
}
override protected function init():void{
mc = (Main.assetFactory.createDisplayObject("YuriponAsset") as MovieClip);
}
override public function getGlobalPosition(_arg1:Boolean):Point{
var _local2:Number;
var _local3:Number;
if (_arg1){
_local2 = (mc.x + 18);
_local3 = (mc.y - 123);
} else {
_local2 = (mc.x + 16.3);
_local3 = (mc.y - 41.7);
};
return (new Point(_local2, _local3));
}
override public function attack(_arg1:Boolean=false):void{
if (Math.random() < 0.1){
deferCounter = ((Math.random() * 2) + 1);
deferFunction = attack;
return;
};
if (_arg1){
setAnimation("feverAttack");
} else {
setAnimation("attack");
};
initWeaponSound();
nextAction = idle;
state = STATE_NULL;
attacking = true;
}
override public function update(_arg1:Array, _arg2:Boolean, _arg3:Number, _arg4:Number):Boolean{
var _local6:int;
var _local5:Boolean;
if (attacking){
if (mc.animation){
_local6 = (_arg2) ? 12 : 3;
if (mc.animation.currentFrame == _local6){
_local5 = true;
};
};
};
super.update(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
override public function getThrowForce(_arg1:Boolean):Point{
var _local2:Number;
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local3:Number = (4 + _local2);
if (_arg1){
_local3 = (_local3 + 3);
};
_local2 = (Math.random() * THROW_FORCE_VARIANCE);
if (Math.random() < 0.5){
_local2 = -(_local2);
};
var _local4:Number = (-7 + _local2);
return (new Point(_local3, _local4));
}
override protected function playWeaponSound():void{
var _local1:Number = Math.random();
if (_local1 < 0.25){
spear1Sound.play();
} else {
if (_local1 < 0.5){
spear2Sound.play();
} else {
if (_local1 < 0.75){
spear3Sound.play();
} else {
spear4Sound.play();
};
};
};
}
}
}//package com.kerb.patapon.game.characters
Section 13
//Fireworks (com.kerb.patapon.game.fireworks.Fireworks)
package com.kerb.patapon.game.fireworks {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import flash.media.*;
import flash.filters.*;
public class Fireworks extends Sprite {
private var inactiveParticles:Array;
private var sfx:Sound;
private var activeParticles:Array;
private var intervalsIndex:int;
private var sfxTransform:SoundTransform;
private var canvas:BitmapData;
private var counter:int;
private static const MATRIX:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, FADE_RATE, 0];
private static const FADE_RATE:Number = 0.8;
private static const DEFAULT_PARTICLE_LIFESPAN:int = 30;
private static const RESTITUTION:Number = 0.8;
private static const PARTICLE_DIAMETER:Number = 8;
private static const GRAVITY:Number = 1;
private static const BLUR_FILTER:BlurFilter = new BlurFilter(2, 2, 1);
private static const DEFAULT_PARTICLE_SPEED:Number = 20;
private static const ZERO_POINT:Point = new Point();
private static const CMF:ColorMatrixFilter = new ColorMatrixFilter(MATRIX);
private static const EMITTER_INTERVALS:Array = [1, 15, 37, 45, 52, 65, 69, 80, 95, 113];
public function Fireworks(_arg1:Number, _arg2:Number){
inactiveParticles = new Array();
activeParticles = new Array();
var _local3:Number = 1;
canvas = new BitmapData((_arg1 / _local3), (_arg2 / _local3), true, 0);
var _local4:Bitmap = new Bitmap(canvas);
_local4.scaleX = _local3;
_local4.scaleY = _local3;
addChild(_local4);
counter = 0;
intervalsIndex = 0;
var _local5:int;
while (_local5 < 65) {
inactiveParticles.push(new Particle(PARTICLE_DIAMETER, PARTICLE_DIAMETER));
_local5++;
};
sfx = Main.assetFactory.createSound("FireworkSound");
sfxTransform = new SoundTransform();
}
public function dispose():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function start():void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
if (++counter == EMITTER_INTERVALS[intervalsIndex]){
if (++intervalsIndex == EMITTER_INTERVALS.length){
intervalsIndex = 0;
counter = 0;
};
launchFirework();
};
canvas.applyFilter(canvas, canvas.rect, ZERO_POINT, BLUR_FILTER);
canvas.applyFilter(canvas, canvas.rect, ZERO_POINT, CMF);
var _local2:int = activeParticles.length;
while (--_local2 > -1) {
if (!activeParticles[_local2].update(GRAVITY, RESTITUTION, canvas)){
inactiveParticles.push(activeParticles.splice(_local2, 1)[0]);
};
};
}
private function launchFirework():void{
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Particle;
var _local1 = 13;
var _local10:Number = (((0.7 * Math.random()) * canvas.width) + (0.15 * canvas.width));
var _local11:Number = (((0.2 * Math.random()) * canvas.height) + (0.1 * canvas.width));
_local2 = 0;
while (_local2 < _local1) {
if (inactiveParticles.length == 0){
_local9 = new Particle(PARTICLE_DIAMETER, PARTICLE_DIAMETER);
} else {
_local9 = inactiveParticles.splice(0, 1)[0];
};
_local4 = (_local2 / _local1);
_local3 = ((2 * Math.PI) * _local4);
_local3 = (_local3 + (((0.6 * Math.random()) * _local4) - (0.3 * _local4)));
_local5 = (DEFAULT_PARTICLE_SPEED + int((((0.2 * Math.random()) * DEFAULT_PARTICLE_SPEED) - (0.1 * DEFAULT_PARTICLE_SPEED))));
_local8 = (DEFAULT_PARTICLE_LIFESPAN + int((((0.2 * Math.random()) * DEFAULT_PARTICLE_LIFESPAN) - (0.1 * DEFAULT_PARTICLE_LIFESPAN))));
_local6 = (_local5 * Math.cos(_local3));
_local7 = (_local5 * Math.sin(_local3));
_local9.init(_local8, _local10, _local11, _local6, _local7);
activeParticles.push(_local9);
_local2++;
};
var _local12:int = (Math.random() * 100);
if (sfxTransform.volume > 0){
sfxTransform.volume = (sfxTransform.volume - 0.1);
} else {
if (sfxTransform.volume < 0){
sfxTransform.volume = 0;
};
};
sfx.play(_local12, 0, sfxTransform);
}
}
}//package com.kerb.patapon.game.fireworks
Section 14
//Particle (com.kerb.patapon.game.fireworks.Particle)
package com.kerb.patapon.game.fireworks {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class Particle {
private var pos:Point;
private var bmp:BitmapData;
private var lifeSpan:int;
private var vel:Point;
private static const ZERO_POINT:Point = new Point();
private static const MATRIX:Array = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, FADE_RATE, 0];
private static const FADE_RATE:Number = 0.9;
private static const CMF:ColorMatrixFilter = new ColorMatrixFilter(MATRIX);
public function Particle(_arg1:int, _arg2:int){
bmp = new BitmapData(_arg1, _arg2, true, 0);
pos = new Point(0, 0);
vel = new Point(0, 0);
}
public function init(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
this.lifeSpan = _arg1;
pos.x = _arg2;
pos.y = _arg3;
vel.x = _arg4;
vel.y = _arg5;
var _local6:Shape = new Shape();
_local6.graphics.beginFill(0xFFFFFF);
_local6.graphics.drawEllipse(0, 0, bmp.width, bmp.height);
bmp.draw(_local6);
}
public function update(_arg1:Number, _arg2:Number, _arg3:BitmapData):Boolean{
var _local4:Number;
var _local5:Number;
vel.x = (vel.x * _arg2);
vel.y = (vel.y * _arg2);
vel.y = (vel.y + _arg1);
var _local6:int;
var _local7:Number = Math.abs(vel.x);
var _local8:Number = Math.abs(vel.y);
if (_local7 > _local8){
_local4 = ((vel.x < 0)) ? -1 : 1;
_local5 = (vel.y / _local7);
_local6 = _local7;
} else {
_local4 = (vel.x / _local8);
_local5 = ((vel.y < 0)) ? -1 : 1;
_local6 = _local8;
};
while (--_local6 > 0) {
pos.x = (pos.x + _local4);
pos.y = (pos.y + _local5);
_arg3.copyPixels(bmp, bmp.rect, pos, bmp, ZERO_POINT, true);
};
bmp.applyFilter(bmp, bmp.rect, ZERO_POINT, CMF);
return ((--lifeSpan > 0));
}
}
}//package com.kerb.patapon.game.fireworks
Section 15
//Arrow (com.kerb.patapon.game.projectiles.Arrow)
package com.kerb.patapon.game.projectiles {
import flash.display.*;
import com.kerb.patapon.*;
public class Arrow extends Projectile {
public function Arrow(){
mc = (Main.assetFactory.createDisplayObject("ArrowAsset") as MovieClip);
mc.visible = false;
damageNormal = 2;
damageFever = 4;
}
}
}//package com.kerb.patapon.game.projectiles
Section 16
//HeroSpear (com.kerb.patapon.game.projectiles.HeroSpear)
package com.kerb.patapon.game.projectiles {
import flash.display.*;
import com.kerb.patapon.*;
public class HeroSpear extends Projectile {
public var heroEffect:Boolean;
public function HeroSpear(){
mc = (Main.assetFactory.createDisplayObject("HeroSpearAsset") as MovieClip);
mc.visible = false;
setDamage(false);
}
public function setDamage(_arg1:Boolean):void{
this.heroEffect = _arg1;
if (_arg1){
damageNormal = 5;
damageFever = 6;
} else {
damageNormal = 4;
damageFever = 5;
};
}
}
}//package com.kerb.patapon.game.projectiles
Section 17
//Projectile (com.kerb.patapon.game.projectiles.Projectile)
package com.kerb.patapon.game.projectiles {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.game.*;
public class Projectile {
public var activated:Boolean;
private var vx:Number;
private var vy:Number;
private var fadeOutCounter:int;
protected var damageFever:Number;
public var mc:MovieClip;
private var x:Number;
private var y:Number;
protected var damageNormal:Number;
private static const FADE_OUT_TIME:int = 10;
private static const RESTITUTION:Number = 0.99;
private static const GRAVITY:Number = 0.3;
private static const RAD_2_DEG:Number = 57.2957795130823;
public function Projectile(){
damageNormal = 0;
damageFever = 0;
activated = false;
}
public function update():Boolean{
var _local2:Number;
var _local1:Boolean;
if (fadeOutCounter == 0){
vx = (vx * RESTITUTION);
vy = (vy * RESTITUTION);
vy = (vy + GRAVITY);
x = (x + vx);
y = (y + vy);
mc.x = x;
mc.y = y;
_local2 = Math.atan2(vy, vx);
mc.rotation = (RAD_2_DEG * _local2);
if (y > Renderer.groundLevel){
fadeOutCounter = FADE_OUT_TIME;
};
} else {
if (--fadeOutCounter == 0){
_local1 = true;
};
mc.alpha = (fadeOutCounter / FADE_OUT_TIME);
};
return (_local1);
}
public function activate(_arg1:Point, _arg2:Point):void{
x = _arg1.x;
y = _arg1.y;
vx = _arg2.x;
vy = _arg2.y;
fadeOutCounter = 0;
mc.x = x;
mc.y = y;
mc.alpha = 1;
mc.visible = true;
activated = true;
}
public function targetHit(_arg1:Boolean):Number{
var _local2:Number = 0;
if (fadeOutCounter == 0){
fadeOutCounter = FADE_OUT_TIME;
_local2 = (_arg1) ? damageFever : damageNormal;
};
return (_local2);
}
public function deactivate():void{
mc.visible = false;
activated = false;
}
}
}//package com.kerb.patapon.game.projectiles
Section 18
//Spear (com.kerb.patapon.game.projectiles.Spear)
package com.kerb.patapon.game.projectiles {
import flash.display.*;
import com.kerb.patapon.*;
public class Spear extends Projectile {
public function Spear(){
mc = (Main.assetFactory.createDisplayObject("SpearAsset") as MovieClip);
mc.visible = false;
damageNormal = 3;
damageFever = 5;
}
}
}//package com.kerb.patapon.game.projectiles
Section 19
//AbstractLevel (com.kerb.patapon.game.AbstractLevel)
package com.kerb.patapon.game {
import flash.events.*;
import flash.display.*;
import com.kerb.game.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import flash.media.*;
import com.kerb.patapon.game.projectiles.*;
import flash.utils.*;
import flash.ui.*;
public class AbstractLevel extends AbstractSection {
protected var combo:int;
protected var numCharacters:int;
protected var frontLimit:Number;
protected var backLimit:Number;
protected var attacking:Boolean;
protected var vocals:Vocals;
protected var comboScore:int;
protected var beatPlayed:Boolean;
protected var projectiles:Array;
private var voxChannel:SoundChannel;
protected var coolThreshold:int;
protected var goodThreshold:int;
protected var levelDuration:int;
protected var damageSoundPlaying:Boolean;
protected var marching:Boolean;
protected var hit1Sound:Sound;
protected var numSilentBeats:int;
protected var renderer:Renderer;
protected var numProjectiles:int;
protected var timeScore:int;
protected var currentPatternStep:int;
protected var beatDistance:int;
protected var numCoolBeats:int;
protected var hit2Sound:Sound;
protected var heroEffectCounter:int;
protected var missionEndTimer:Timer;
protected var currentPattern:Array;
private var vox:Sound;
protected var characters:Array;
protected var musicState:int;
protected var hit3Sound:Sound;
protected var allowAttack:Boolean;
protected var gameTimer:GameTimer;
protected var hud:HUD;
protected var hero:Hero;
public static const RESPONSE:int = 1;
private static const NO_SOUND_COOL_DEVIATION_THRESHOLD:int = 4;
private static const SOUND_COOL_DEVIATION_THRESHOLD:int = 3;
private static const ATTACK:Array = [PON, PON, PATA, PON];
public static const COOL:int = 2;
private static const MISSION_WIN_PAUSE:int = 1200;
private static const TIME_POINTS:int = 10;
private static const BEAT_START:int = -7;
public static const PATA:int = 0;
private static const BEAT_END:int = 7;
private static const COOL_BEAT_FEVER:int = 8;
private static const MARCH:Array = [PATA, PATA, PATA, PON];
public static const BAD:int = 0;
private static const COMBO_POINTS:Array = [10, 20, 40, 80];
public static const CALL:int = 0;
private static const MISSION_LOSE_PAUSE:int = 700;
public static const PON:int = 1;
public static const MAX_COMBO:int = 4;
private static const NO_SOUND_GOOD_DEVIATION_THRESHOLD:int = 6;
private static const SOUND_GOOD_DEVIATION_THRESHOLD:int = 5;
public static const GOOD:int = 1;
protected function onMissionLoseTimer(_arg1:TimerEvent):void{
renderer.showMissionLose();
var _local2:MovieClip = renderer.getRetryMissionButton();
_local2.addEventListener(MouseEvent.CLICK, lose, false, 0, true);
_local2.buttonMode = true;
_local2.mouseChildren = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onLoseKeyDown);
}
protected function onLoseKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ENTER)))){
lose();
};
}
protected function win():void{
SoundMixer.stopAll();
removeChild(renderer);
renderer = null;
var _local1:Main = (main as Main);
_local1.setCurrLevelScore(getScore());
NextSectionClass = LevelWin;
gotoNextSection();
}
protected function playDamageSound():void{
var _local1:Number;
var _local2:int;
if (!damageSoundPlaying){
_local1 = Math.random();
_local2 = (Math.random() * 250);
if (_local1 < 0.33){
hit1Sound.play(_local2);
} else {
if (_local1 < 0.67){
hit2Sound.play(_local2);
} else {
hit3Sound.play(_local2);
};
};
damageSoundPlaying = true;
};
}
protected function start():void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
gameTimer.start(levelDuration);
stage.focus = stage;
}
protected function onLevelWinEnterFrame(_arg1:Event):void{
var _local2:int;
while (_local2 < numCharacters) {
if (Math.random() < 0.01){
characters[_local2].glee();
};
characters[_local2].update(characters, (combo >= 10), backLimit, frontLimit);
_local2++;
};
renderer.draw(characters, hero);
renderer.monochrome();
if (renderer.missionEndFinished(getScore())){
win();
};
}
protected function lose(_arg1:Event=null):void{
SoundMixer.stopAll();
removeChild(renderer);
renderer = null;
Main.buttonSound.play();
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onLoseKeyDown);
NextSectionClass = (getDefinitionByName(getQualifiedClassName(this)) as Class);
gotoNextSection();
}
override protected function init():void{
var _local1:int;
hud = new HUD((main as Main).currLevelNum);
currentPattern = new Array();
currentPatternStep = 0;
combo = 0;
beatDistance = 0;
numSilentBeats = 0;
musicState = CALL;
allowAttack = true;
vocals = new Vocals();
timeScore = 0;
comboScore = 0;
projectiles = new Array();
numProjectiles = 0;
numCoolBeats = 0;
backLimit = Number.MAX_VALUE;
frontLimit = Number.MAX_VALUE;
heroEffectCounter = 0;
attacking = false;
marching = false;
if ((main as Main).gameWithAudio){
coolThreshold = SOUND_COOL_DEVIATION_THRESHOLD;
goodThreshold = SOUND_GOOD_DEVIATION_THRESHOLD;
} else {
coolThreshold = NO_SOUND_COOL_DEVIATION_THRESHOLD;
goodThreshold = NO_SOUND_GOOD_DEVIATION_THRESHOLD;
};
renderer.setCamera(0);
renderer.addCharacters(characters);
addChild(renderer);
addChild(hud);
gameTimer = new GameTimer();
gameTimer.addEventListener(Event.COMPLETE, onGameTimerComplete);
_local1 = 0;
while (_local1 < numCharacters) {
characters[_local1].addEventListener(AbstractCharacter.EVENT_DIE, onCharacterDie);
_local1++;
};
_local1 = 0;
while (_local1 < 10) {
vocals.addPataVocal(("PataSound" + _local1));
vocals.addPonVocal(("PonSound" + _local1));
_local1++;
};
hit1Sound = Main.assetFactory.createSound("Hit1Sound");
hit2Sound = Main.assetFactory.createSound("Hit2Sound");
hit3Sound = Main.assetFactory.createSound("Hit3Sound");
damageSoundPlaying = false;
start();
}
protected function onCharacterDie(_arg1:Event):void{
var _local2:int = characters.indexOf(_arg1.target);
if (_local2 > -1){
characters[_local2].removeEventListener(AbstractCharacter.EVENT_DIE, onCharacterDie);
renderer.addSpeechBubble("game.bubbles.argh", characters[_local2], SpeechBubble.DEFAULT_DISPLAY_TIME, true);
characters.splice(_local2, 1);
numCharacters--;
};
if (_local2 == 0){
levelComplete(false);
};
}
override public function dispose():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
removeEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
removeEventListener(Event.ENTER_FRAME, onLevelLoseEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onLoseKeyDown);
if (missionEndTimer){
missionEndTimer.removeEventListener(TimerEvent.TIMER, onMissionWinTimer);
missionEndTimer.removeEventListener(TimerEvent.TIMER, onMissionLoseTimer);
};
if (gameTimer){
gameTimer.removeEventListener(Event.COMPLETE, onGameTimerComplete);
};
var _local1:int;
while (_local1 < characters.length) {
characters[_local1].removeEventListener(AbstractCharacter.EVENT_DIE, onCharacterDie);
_local1++;
};
if (renderer){
renderer.dispose();
};
}
protected function pata(_arg1:int):void{
renderer.showPata(_arg1);
var _local2:int;
while (_local2 < numCharacters) {
characters[_local2].pata();
_local2++;
};
}
protected function onGameTimerComplete(_arg1:Event):void{
levelComplete(false);
}
protected function onLevelLoseEnterFrame(_arg1:Event):void{
if (renderer.missionEndFinished()){
hud.deactivateTimer();
} else {
renderer.monochrome();
};
}
protected function onEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:Projectile;
var _local4:AbstractCharacter;
var _local6:Point;
var _local7:Point;
damageSoundPlaying = false;
beatDistance = hud.update(gameTimer);
if (beatDistance == BEAT_START){
beatStart();
} else {
if (beatDistance == BEAT_END){
beatEnd();
} else {
if (((vox) && ((beatDistance == -2)))){
voxChannel = vox.play(0, 1);
vox = null;
};
};
};
var _local5 = (combo >= 10);
_local2 = 0;
while (_local2 < numCharacters) {
_local4 = characters[_local2];
if (_local4.update(characters, _local5, backLimit, frontLimit)){
if ((_local4 is Tatepon)){
_local6 = _local4.getGlobalPosition(_local5);
_local7 = (_local4 as Tatepon).getLocalPosition(_local6);
checkAxeHit(_local6, _local7);
} else {
_local3 = _local4.projectile;
_local3.activate(_local4.getGlobalPosition(_local5), _local4.getThrowForce(_local5));
if (projectiles.indexOf(_local3) == -1){
projectiles.push(_local3);
numProjectiles++;
};
};
};
_local2++;
};
_local2 = numProjectiles;
while (--_local2 > -1) {
_local3 = projectiles[_local2];
if (_local3.update()){
_local3.deactivate();
projectiles.splice(_local2, 1);
numProjectiles--;
};
};
renderer.draw(characters, hero);
if (renderer.characterPastFinishingPost(characters)){
levelComplete(true);
} else {
if (marching){
if ((((Math.random() < 0.001)) && ((combo > 1)))){
renderer.addRandomSpeechBubble("game.bubbles.gogogo", characters);
};
};
if (combo > 0){
if (Math.random() < 0.005){
if (Math.random() < 0.5){
renderer.addRandomSpeechBubble("game.bubbles.super", characters);
} else {
renderer.addRandomSpeechBubble("game.bubbles.thatsit", characters);
};
};
};
};
}
protected function resetPattern():void{
currentPattern = new Array();
currentPatternStep = 0;
}
private function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:int = Math.abs(beatDistance);
if (_arg1.keyCode == Keyboard.LEFT){
hud.setMetronomeHilite(true);
if (beatPlayed){
pata(BAD);
mistake();
} else {
if (musicState == RESPONSE){
if (Math.random() < 0.6){
renderer.addRandomSpeechBubble("game.bubbles.response", characters, SpeechBubble.DEFAULT_DISPLAY_TIME, true);
} else {
renderer.addRandomSpeechBubble("game.bubbles.dontrush", characters, SpeechBubble.DEFAULT_DISPLAY_TIME, true);
};
pata(BAD);
mistake();
} else {
if (_local2 < coolThreshold){
numCoolBeats++;
addToPattern(PATA);
pata(COOL);
} else {
if (_local2 < goodThreshold){
numCoolBeats = 0;
addToPattern(PATA);
pata(GOOD);
} else {
pata(BAD);
mistake();
};
};
};
};
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
hud.setMetronomeHilite(true);
if (beatPlayed){
pon(BAD);
mistake();
} else {
if (musicState == RESPONSE){
renderer.addRandomSpeechBubble("game.bubbles.response", characters, SpeechBubble.DEFAULT_DISPLAY_TIME, true);
pon(BAD);
mistake();
} else {
if (_local2 < coolThreshold){
numCoolBeats++;
addToPattern(PON);
pon(COOL);
} else {
if (_local2 < goodThreshold){
numCoolBeats = 0;
addToPattern(PON);
pon(GOOD);
} else {
pon(BAD);
mistake();
};
};
};
};
};
};
if (numCoolBeats >= 4){
if (characters.indexOf(hero) != -1){
hero.setHeroEffect(true);
renderer.setAuraVisibility(true);
heroEffectCounter = 12;
};
};
}
protected function somethingToAttack():Boolean{
return (false);
}
protected function checkAxeHit(_arg1:Point, _arg2:Point):void{
}
protected function beatEnd():void{
var _local1:Boolean;
if (beatPlayed){
if (currentPatternStep == 4){
if (combo < MAX_COMBO){
comboScore = (comboScore + COMBO_POINTS[combo]);
if (numCoolBeats >= COOL_BEAT_FEVER){
numCoolBeats = 0;
combo = MAX_COMBO;
} else {
combo++;
};
hud.setCombo(combo);
} else {
comboScore = (comboScore + COMBO_POINTS[(COMBO_POINTS.length - 1)]);
};
if (currentPattern[0] == PATA){
march();
if (combo == 1){
renderer.addRandomSpeechBubble("game.bubbles.forward", characters, 3000);
} else {
if (combo > 1){
if (Math.random() < 0.2){
renderer.addRandomSpeechBubble("game.bubbles.pata", characters, 3000);
};
};
};
vox = ((combo)==1) ? vocals.getFirstPataVocal() : vocals.getPataVocal();
attacking = false;
marching = true;
} else {
if (currentPattern[0] == PON){
if (somethingToAttack()){
attack();
if (((!(attacking)) && ((Math.random() > 0.5)))){
renderer.addRandomSpeechBubble("game.bubbles.pon.together", characters, 3000);
} else {
if (Math.random() < 0.2){
renderer.addRandomSpeechBubble("game.bubbles.pon", characters, 3000);
};
};
vox = ((combo)==1) ? vocals.getFirstPonVocal() : vocals.getPonVocal();
attacking = true;
marching = false;
} else {
_local1 = true;
attacking = false;
marching = false;
renderer.addRandomSpeechBubble("game.bubbles.noattack", characters, SpeechBubble.DEFAULT_DISPLAY_TIME, true);
};
};
};
if (Math.random() < 0.5){
if (((!(attacking)) && (somethingToAttack()))){
renderer.addRandomSpeechBubble("game.bubbles.attack", characters, 10000, true);
};
};
musicState = (_local1) ? CALL : RESPONSE;
numSilentBeats = 0;
resetPattern();
};
} else {
if (musicState == CALL){
mistake();
} else {
if (++numSilentBeats == 4){
musicState = CALL;
};
};
};
if (--heroEffectCounter == 0){
hero.setHeroEffect(false);
renderer.setAuraVisibility(false);
};
}
protected function attack():void{
var _local1 = (combo >= 10);
var _local2:int;
while (_local2 < numCharacters) {
characters[_local2].attack(_local1);
_local2++;
};
}
protected function beatStart():void{
beatPlayed = false;
}
protected function march():void{
var _local1:int;
while (_local1 < numCharacters) {
characters[_local1].march();
_local1++;
};
}
protected function pon(_arg1:int):void{
renderer.showPon(_arg1);
var _local2:int;
while (_local2 < numCharacters) {
characters[_local2].pon();
_local2++;
};
}
public function getScore():int{
return ((comboScore + timeScore));
}
protected function mistake():void{
if (combo > 0){
if (voxChannel){
voxChannel.stop();
};
vocals.huh();
if (Math.random() < 0.5){
showMistakeSpeechBubble();
};
} else {
if (Math.random() < 0.05){
showMistakeSpeechBubble();
} else {
if (Math.random() < 0.08){
if (somethingToAttack()){
renderer.addRandomSpeechBubble("game.bubbles.attack", characters, 6000, true);
} else {
renderer.addRandomSpeechBubble("game.bubbles.march", characters, 6000, true);
};
};
};
};
combo = 0;
numCoolBeats = 0;
hud.setCombo(combo);
resetPattern();
var _local1:int;
while (_local1 < numCharacters) {
characters[_local1].mistake();
_local1++;
};
attacking = false;
musicState = CALL;
}
protected function levelComplete(_arg1:Boolean):void{
var _local2:int;
renderer.hideSymbols();
renderer.setAuraVisibility(false);
hud.deactivateMetronome();
hud.setCombo(0);
if (voxChannel){
voxChannel.stop();
};
gameTimer.stop();
timeScore = int(((TIME_POINTS * gameTimer.totalTime) / 1000));
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
if (_arg1){
_local2 = 0;
while (_local2 < numCharacters) {
characters[_local2].finish();
_local2++;
};
addEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
missionEndTimer = new Timer(MISSION_WIN_PAUSE, 1);
missionEndTimer.addEventListener(TimerEvent.TIMER, onMissionWinTimer);
renderer.showFireworks();
} else {
_local2 = 0;
while (_local2 < numCharacters) {
characters[_local2].stationary();
_local2++;
};
addEventListener(Event.ENTER_FRAME, onLevelLoseEnterFrame);
missionEndTimer = new Timer(MISSION_LOSE_PAUSE, 1);
missionEndTimer.addEventListener(TimerEvent.TIMER, onMissionLoseTimer);
};
missionEndTimer.start();
}
protected function onMissionWinTimer(_arg1:TimerEvent):void{
renderer.showMissionWin(getScore());
}
protected function addToPattern(_arg1:int):void{
var _local2:int;
var _local3:Array;
currentPattern[currentPatternStep] = _arg1;
currentPatternStep++;
if (currentPattern[0] == PATA){
_local3 = MARCH;
} else {
if (((allowAttack) && ((currentPattern[0] == PON)))){
_local3 = ATTACK;
};
};
if (_local3){
_local2 = 0;
while (_local2 < currentPatternStep) {
if (currentPattern[_local2] != _local3[_local2]){
mistake();
};
_local2++;
};
} else {
mistake();
};
beatPlayed = true;
}
private function showMistakeSpeechBubble():void{
var _local1:Number = Math.random();
if (_local1 < 0.33){
renderer.addRandomSpeechBubble("game.bubbles.match", characters, 3000, true);
} else {
if (_local1 < 0.66){
renderer.addRandomSpeechBubble("game.bubbles.thebeat", characters, 3000, true);
} else {
if ((main as Main).gameWithAudio){
renderer.addRandomSpeechBubble("game.bubbles.listen", characters, 3000, true);
} else {
renderer.addRandomSpeechBubble("game.bubbles.look", characters, 3000, true);
};
};
};
}
}
}//package com.kerb.patapon.game
Section 20
//HitSymbol (com.kerb.patapon.game.HitSymbol)
package com.kerb.patapon.game {
import flash.display.*;
import flash.utils.*;
public class HitSymbol {
private var stateDuration:int;
private var initRotation:Number;
private var baseRotation:Number;
private var state:int;
private var mc:MovieClip;
private var initScale:Number;
private var timeStamp:int;
private static const APPEARING_DURATION:int = 100;
private static const STATE_HIDDEN:int = 0;
private static const APPEARING_ROTATION:Number = 20;
private static const DISAPPEARING_SCALE:Number = 2.5;
private static const APPEARING_SCALE_PROBABILITY:Number = 0.2;
private static const STATE_SHOWING:int = 2;
private static const DISAPPEARING_ROTATION:Number = 20;
private static const DISAPPEARING_SCALE_PROBABILITY:Number = 0.2;
private static const STATE_DISAPPEARING:int = 3;
private static const DISAPPEARING_DURATION:int = 200;
private static const SHOWING_DURATION:int = 500;
private static const APPEARING_SCALE:Number = 1.4;
private static const STATE_APPEARING:int = 1;
public function HitSymbol(_arg1:MovieClip){
this.mc = _arg1;
_arg1.alpha = 0;
baseRotation = _arg1.rotation;
state = STATE_HIDDEN;
}
public function show(_arg1:int):void{
if (Math.random() < APPEARING_SCALE_PROBABILITY){
initScale = ((Math.random() * (APPEARING_SCALE - 1)) + 1);
initRotation = (Math.random() * APPEARING_ROTATION);
if (Math.random() < 0.5){
initRotation = -(initRotation);
};
initRotation = (initRotation + baseRotation);
} else {
initScale = 1;
initRotation = baseRotation;
};
mc.gotoAndStop((_arg1 + 1));
mc.scaleX = initScale;
mc.scaleY = initScale;
mc.rotation = initRotation;
mc.alpha = 0;
state = STATE_APPEARING;
stateDuration = APPEARING_DURATION;
timeStamp = getTimer();
}
public function hide():void{
if ((((state == STATE_DISAPPEARING)) || ((state == STATE_HIDDEN)))){
return;
};
if (Math.random() < DISAPPEARING_SCALE_PROBABILITY){
initScale = ((Math.random() * (DISAPPEARING_SCALE - 1)) + 1);
initRotation = (Math.random() * DISAPPEARING_ROTATION);
if (Math.random() < 0.5){
initRotation = -(initRotation);
};
initRotation = (initRotation + baseRotation);
} else {
initScale = 1;
initRotation = baseRotation;
};
mc.scaleX = 1;
mc.scaleY = 1;
mc.rotation = baseRotation;
mc.alpha = 1;
state = STATE_DISAPPEARING;
stateDuration = DISAPPEARING_DURATION;
timeStamp = getTimer();
}
public function getAge():int{
var _local1:int = (getTimer() - timeStamp);
switch (state){
case STATE_HIDDEN:
_local1 = (_local1 + DISAPPEARING_DURATION);
case STATE_DISAPPEARING:
_local1 = (_local1 + SHOWING_DURATION);
case STATE_SHOWING:
_local1 = (_local1 + APPEARING_DURATION);
};
return (_local1);
}
public function update():void{
var _local1:Number;
if (state != STATE_HIDDEN){
_local1 = ((getTimer() - timeStamp) / stateDuration);
if (_local1 > 1){
_local1 = 1;
};
if (state == STATE_APPEARING){
mc.alpha = _local1;
mc.scaleX = (mc.scaleY = (initScale + (_local1 * (1 - initScale))));
mc.rotation = (initRotation + (_local1 * (baseRotation - initRotation)));
if (_local1 == 1){
state = STATE_SHOWING;
stateDuration = SHOWING_DURATION;
timeStamp = getTimer();
};
} else {
if (state == STATE_SHOWING){
if (_local1 == 1){
hide();
};
} else {
if (state == STATE_DISAPPEARING){
mc.alpha = (1 - _local1);
mc.scaleX = (mc.scaleY = ((_local1 * (initScale - 1)) + 1));
mc.rotation = (baseRotation + (_local1 * (initRotation - baseRotation)));
if (_local1 == 1){
mc.gotoAndStop(4);
state = STATE_HIDDEN;
};
};
};
};
};
}
public function isHidden():Boolean{
return ((state == STATE_HIDDEN));
}
public function makeInvisible():void{
mc.visible = false;
}
}
}//package com.kerb.patapon.game
Section 21
//HUD (com.kerb.patapon.game.HUD)
package com.kerb.patapon.game {
import flash.events.*;
import flash.display.*;
import com.kerb.game.*;
import com.kerb.patapon.*;
import flash.media.*;
public class HUD extends Sprite {
private var levelNum:int;
private var timerCritical:Boolean;
private var hiliteCounter:int;
private var combo:int;
private var beatVolume:Number;
private var beatDistance:int;
private var heavySoundTransform:SoundTransform;
private var mc:MovieClip;
private static const METRONOME_HILITE:int = 20;
private static const TIMER_CRITICAL_THRESHOLD:int = 30000;
public function HUD(_arg1:int){
this.levelNum = _arg1;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
timerCritical = false;
hiliteCounter = 0;
heavySoundTransform = new SoundTransform();
heavySoundTransform.volume = 0;
beatVolume = 1;
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc = (Main.assetFactory.createDisplayObject("HUDAsset") as MovieClip);
mc.progress.gotoAndStop(("Level" + (levelNum + 1)));
mc.heavy.soundTransform = heavySoundTransform;
setCombo(0);
addChild(mc);
}
public function update(_arg1:GameTimer):int{
beatDistance = ((mc.metronome.currentFrame - 1) % 15);
if (beatDistance > 7){
beatDistance = (beatDistance - 15);
};
if (beatDistance == 0){
if ((((combo > 2)) && ((combo < AbstractLevel.MAX_COMBO)))){
mc.combo.numberAnimation.gotoAndPlay("beat");
};
};
mc.timer.time.time_txt.text = _arg1.getTimeAsString();
if (((!(timerCritical)) && ((_arg1.totalTime < TIMER_CRITICAL_THRESHOLD)))){
mc.timer.gotoAndPlay("flashing");
timerCritical = true;
};
if (hiliteCounter > 0){
if (--hiliteCounter == 0){
setMetronomeHilite(false);
};
};
return (beatDistance);
}
public function setMetronomeVolume(_arg1:Number):void{
beatVolume = _arg1;
mc.metronome.soundTransform = new SoundTransform(_arg1);
}
public function deactivateTimer():void{
mc.timer.gotoAndPlay("normal");
}
public function setCombo(_arg1:int):void{
if (_arg1 == 0){
mc.combo.numberAnimation.gotoAndStop("hidden");
mc.combo.animation.gotoAndStop("hidden");
} else {
if (_arg1 == 1){
} else {
if (_arg1 == 2){
mc.combo.numberAnimation.gotoAndPlay("appear");
mc.combo.numberAnimation.num.gotoAndStop(_arg1);
mc.combo.animation.gotoAndPlay("appear");
} else {
if (_arg1 < AbstractLevel.MAX_COMBO){
mc.combo.numberAnimation.num.gotoAndStop(_arg1);
mc.combo.animation.gotoAndPlay("increment");
} else {
if (_arg1 != combo){
mc.combo.numberAnimation.gotoAndStop("hidden");
mc.combo.animation.gotoAndPlay("fever");
};
};
};
};
};
if ((((combo == 0)) && ((_arg1 > 0)))){
heavySoundTransform.volume = beatVolume;
mc.heavy.soundTransform = heavySoundTransform;
} else {
if (_arg1 == 0){
heavySoundTransform.volume = 0;
mc.heavy.soundTransform = heavySoundTransform;
};
};
combo = _arg1;
}
public function deactivateMetronome():void{
mc.metronome.stop();
mc.metronome.visible = false;
mc.removeChild(mc.metronome);
mc.heavy.stop();
mc.removeChild(mc.heavy);
}
public function setMetronomeHilite(_arg1:Boolean):void{
if (_arg1){
mc.metronome.blendMode = BlendMode.NORMAL;
hiliteCounter = METRONOME_HILITE;
} else {
mc.metronome.blendMode = BlendMode.INVERT;
};
}
}
}//package com.kerb.patapon.game
Section 22
//Level1 (com.kerb.patapon.game.Level1)
package com.kerb.patapon.game {
import flash.events.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import flash.media.*;
import com.kerb.tracking.*;
public class Level1 extends AbstractLevel {
private var extraCharacters:Array;
private var windSoundChannel:SoundChannel;
override protected function init():void{
var _local1:AbstractCharacter;
renderer = new Renderer(0, 100, 550, 300, 1500, 260);
renderer.setParallaxLayers("Level1BackgroundAsset", "Level1ParallaxBackAsset", "Level1ParallaxMidAsset", "Level1ParallaxFrontAsset");
renderer.setFinishingPost(1400);
renderer.addToWeather("Level1WindAsset");
characters = new Array();
_local1 = new Hatapon(50, 0);
characters.push(_local1);
extraCharacters = new Array();
hero = new Hero(475, 1);
extraCharacters.push(hero);
_local1 = new Yuripon(725, 2);
extraCharacters.push(_local1);
_local1 = new Tatepon(1000, 3);
extraCharacters.push(_local1);
numCharacters = characters.length;
levelDuration = 180000;
super.init();
allowAttack = false;
renderer.addCharacters(extraCharacters);
renderer.addSpeechBubble("game.bubbles.march", characters[0], 10000, true);
hud.setMetronomeVolume(0.7);
var _local2:Sound = Main.assetFactory.createSound("WindSound");
var _local3:SoundTransform = new SoundTransform(0.2);
windSoundChannel = _local2.play(0, 999999, _local3);
if (Main.VIRAL){
DoubleQuick.event(293);
} else {
DoubleQuick.event(312);
Main.webtrends("level1loaded");
};
}
override protected function onMissionLoseTimer(_arg1:TimerEvent):void{
windSoundChannel.stop();
super.onMissionLoseTimer(_arg1);
}
override protected function onMissionWinTimer(_arg1:TimerEvent):void{
windSoundChannel.stop();
super.onMissionWinTimer(_arg1);
}
override protected function onEnterFrame(_arg1:Event):void{
var _local2:AbstractCharacter;
var _local4:Number;
var _local3:int = extraCharacters.length;
while (--_local3 > -1) {
_local2 = extraCharacters[_local3];
_local4 = (_local2.x - characters[0].x);
if (_local4 < 30){
characters.push(extraCharacters.splice(_local3, 1)[0]);
numCharacters++;
renderer.addSpeechBubble("game.bubbles.joinyou", _local2, SpeechBubble.DEFAULT_DISPLAY_TIME, true);
};
};
super.onEnterFrame(_arg1);
}
}
}//package com.kerb.patapon.game
Section 23
//Level2 (com.kerb.patapon.game.Level2)
package com.kerb.patapon.game {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import flash.media.*;
import com.kerb.patapon.game.projectiles.*;
import flash.utils.*;
import com.kerb.tracking.*;
public class Level2 extends AbstractLevel {
private var castleDestroyed:Boolean;
private var castleDamage:Number;
private var smokeCounter:int;
private var hintTime:int;
private var rainSoundChannel:SoundChannel;
private var rain:MovieClip;
private static const CASTLE_POSITION:Number = 500;
private static const CASTLE_MAX_DAMAGE:Number = 30;
private static const LIMIT_WIDTH:Number = 170;
private static const MIN_ATTACK_DISTANCE:Number = 160;
override protected function onEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:int;
var _local4:Projectile;
super.onEnterFrame(_arg1);
if (!castleDestroyed){
_local2 = numProjectiles;
while (--_local2 > -1) {
_local4 = projectiles[_local2];
if (renderer.projectileHittingCastle(_local4)){
_local3 = _local4.targetHit((combo >= AbstractLevel.MAX_COMBO));
castleDamage = (castleDamage + _local3);
playDamageSound();
renderer.showDamagePoints(_local4.mc.x, _local4.mc.y, _local3, true);
if ((((((--smokeCounter < 0)) && ((_local4 is HeroSpear)))) && ((_local4 as HeroSpear).heroEffect))){
renderer.addHeroSpearSmoke(_local4.mc.x, _local4.mc.y);
smokeCounter = 20;
};
if (castleDamage >= CASTLE_MAX_DAMAGE){
castleDamage = 0;
renderer.showCastleDamage();
};
};
};
if (renderer.castleDestroyed()){
castleDestroyed = true;
backLimit = Number.MAX_VALUE;
frontLimit = Number.MAX_VALUE;
};
if (((((!(marching)) && (!(attacking)))) && (!(somethingToAttack())))){
if ((getTimer() - hintTime) > 5000){
renderer.addRandomSpeechBubble("game.bubbles.noattack.forward", characters, 3000, true);
hintTime = getTimer();
};
};
};
}
override protected function onMissionLoseTimer(_arg1:TimerEvent):void{
rain.lightning.gotoAndStop(1);
rainSoundChannel.stop();
super.onMissionLoseTimer(_arg1);
}
override protected function onMissionWinTimer(_arg1:TimerEvent):void{
rain.lightning.gotoAndStop(1);
rainSoundChannel.stop();
super.onMissionWinTimer(_arg1);
}
override protected function checkAxeHit(_arg1:Point, _arg2:Point):void{
if (!castleDestroyed){
if (renderer.axeHittingCastle(_arg1)){
castleDamage = (castleDamage + Tatepon.AXE_DAMAGE);
playDamageSound();
renderer.showDamagePoints(_arg2.x, _arg2.y, Tatepon.AXE_DAMAGE, true);
if (castleDamage >= CASTLE_MAX_DAMAGE){
castleDamage = 0;
renderer.showCastleDamage();
};
};
};
}
override protected function somethingToAttack():Boolean{
var _local3:Number;
var _local4:int;
var _local1:Boolean;
var _local2:Number = Number.MAX_VALUE;
if (!castleDestroyed){
_local4 = 0;
while (_local4 < numCharacters) {
_local3 = (CASTLE_POSITION - characters[_local4].x);
if (_local3 < _local2){
_local2 = _local3;
};
_local4++;
};
if (_local2 < MIN_ATTACK_DISTANCE){
_local1 = true;
};
};
return (_local1);
}
override protected function init():void{
var _local2:AbstractCharacter;
renderer = new Renderer(0, 100, 550, 300, 1200, 260);
renderer.setParallaxLayers("Level2BackgroundAsset", "Level2ParallaxBackAsset", "Level2ParallaxMidAsset", "Level2ParallaxFrontAsset");
renderer.addCastle(CASTLE_POSITION);
renderer.setFinishingPost(950);
rain = renderer.addToWeather("Level2RainAsset");
var _local1:MovieClip = renderer.addToForeground("Level2BushesAssets");
_local1.y = Renderer.groundLevel;
characters = new Array();
_local2 = new Hatapon(70, 0);
characters.push(_local2);
_local2 = new Yumipon(50, 1);
characters.push(_local2);
_local2 = new Yuripon(90, 2);
characters.push(_local2);
_local2 = new Yuripon(110, 3);
characters.push(_local2);
_local2 = new Yumipon(130, 4);
characters.push(_local2);
hero = new Hero(150, 5);
characters.push(hero);
_local2 = new Tatepon(170, 6);
characters.push(_local2);
numCharacters = characters.length;
levelDuration = 180000;
super.init();
castleDamage = 0;
castleDestroyed = false;
smokeCounter = 0;
backLimit = (CASTLE_POSITION - LIMIT_WIDTH);
frontLimit = CASTLE_POSITION;
hintTime = 0;
renderer.addSpeechBubble("game.bubbles.march", characters[0], 10000, true);
var _local3:Sound = Main.assetFactory.createSound("RainSound");
var _local4:SoundTransform = new SoundTransform(0.3);
rainSoundChannel = _local3.play(0, 999999, _local4);
if (Main.VIRAL){
DoubleQuick.event(294);
} else {
DoubleQuick.event(313);
Main.webtrends("level2loaded");
};
}
}
}//package com.kerb.patapon.game
Section 24
//Level3 (com.kerb.patapon.game.Level3)
package com.kerb.patapon.game {
import flash.events.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import flash.media.*;
import com.kerb.patapon.game.projectiles.*;
import com.kerb.tracking.*;
public class Level3 extends AbstractLevel {
private var dragonDamage:Number;
private var dragonDestroyed:Boolean;
private var damage1Sound:Sound;
private var dragonAwake:Boolean;
private var damage2Sound:Sound;
private var smokeCounter:int;
private var windSoundChannel:SoundChannel;
private static const DRAGON_FIRE_DAMAGE:int = 5;
private static const DRAGON_POSITION:Number = 500;
private static const DRAGON_MAX_DAMAGE:Number = 120;
private static const LIMIT_WIDTH:Number = 200;
private static const MIN_ATTACK_DISTANCE:Number = 160;
override protected function onMissionLoseTimer(_arg1:TimerEvent):void{
windSoundChannel.stop();
super.onMissionLoseTimer(_arg1);
}
override protected function checkAxeHit(_arg1:Point, _arg2:Point):void{
if (!dragonDestroyed){
if (renderer.axeHittingDragon(_arg1)){
dragonDamage = (dragonDamage + Tatepon.AXE_DAMAGE);
playDamageSound();
renderer.showDamagePoints(_arg2.x, _arg2.y, Tatepon.AXE_DAMAGE, true);
if (dragonDamage >= DRAGON_MAX_DAMAGE){
dragonDestroyed = true;
renderer.dragonDestroyed();
frontLimit = Number.MAX_VALUE;
backLimit = Number.MAX_VALUE;
};
};
};
}
override protected function init():void{
var _local1:AbstractCharacter;
renderer = new Renderer(0, 100, 550, 300, 1200, 260);
renderer.setParallaxLayers("Level3BackgroundAsset", "Level3ParallaxBackAsset", "Level3ParallaxMidAsset", "Level3ParallaxFrontAsset");
renderer.addDragon(DRAGON_POSITION);
renderer.setFinishingPost(3000);
renderer.addToWeather("Level3WindAsset");
characters = new Array();
_local1 = new Hatapon(90, 0);
characters.push(_local1);
_local1 = new Yuripon(50, 1);
characters.push(_local1);
_local1 = new Yumipon(70, 2);
characters.push(_local1);
_local1 = new Yuripon(110, 3);
characters.push(_local1);
_local1 = new Yumipon(130, 4);
characters.push(_local1);
_local1 = new Yuripon(150, 5);
characters.push(_local1);
hero = new Hero(170, 6);
characters.push(hero);
_local1 = new Tatepon(190, 7);
characters.push(_local1);
_local1 = new Tatepon(210, 8);
characters.push(_local1);
numCharacters = characters.length;
levelDuration = 180000;
super.init();
dragonDamage = 0;
dragonDestroyed = false;
dragonAwake = false;
smokeCounter = 0;
backLimit = (DRAGON_POSITION - LIMIT_WIDTH);
frontLimit = DRAGON_POSITION;
damage1Sound = Main.assetFactory.createSound("Damage1Sound");
damage2Sound = Main.assetFactory.createSound("Damage2Sound");
var _local2:Sound = Main.assetFactory.createSound("WindSound");
var _local3:SoundTransform = new SoundTransform(0.4);
windSoundChannel = _local2.play(0, 999999, _local3);
if (Main.VIRAL){
DoubleQuick.event(295);
} else {
DoubleQuick.event(314);
Main.webtrends("level3loaded");
};
}
override protected function onMissionWinTimer(_arg1:TimerEvent):void{
windSoundChannel.stop();
super.onMissionWinTimer(_arg1);
}
override protected function onEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Projectile;
var _local6:Number;
var _local7:Number;
var _local8:Boolean;
var _local9:Sound;
super.onEnterFrame(_arg1);
renderer.updateDragon();
if (!dragonAwake){
frontLimit = renderer.getDragonLimit();
backLimit = (frontLimit - LIMIT_WIDTH);
_local6 = Number.MAX_VALUE;
_local2 = 0;
while (_local2 < numCharacters) {
_local7 = (frontLimit - characters[_local2].x);
if (_local7 < _local6){
_local6 = _local7;
};
_local2++;
};
if (_local6 < MIN_ATTACK_DISTANCE){
renderer.wakeDragon();
dragonAwake = true;
};
};
if (!dragonDestroyed){
frontLimit = renderer.getDragonLimit();
backLimit = (frontLimit - LIMIT_WIDTH);
_local3 = renderer.getDragonFrame();
switch (_local3){
case 406:
case 423:
case 442:
case 462:
renderer.initShake(0.75);
break;
case 713:
case 752:
case 791:
renderer.initShake(1);
break;
};
_local8 = false;
if ((((_local3 > 605)) && ((_local3 < 669)))){
_local2 = numCharacters;
while (--_local2 > -1) {
if (renderer.checkDragonFire(characters[_local2])){
if (characters[_local2].hit(DRAGON_FIRE_DAMAGE)){
renderer.showDamagePoints(characters[_local2].mc.x, (characters[_local2].mc.y - 24), DRAGON_FIRE_DAMAGE, false);
if (!_local8){
if (Math.random() < 0.5){
damage1Sound.play();
} else {
damage2Sound.play();
};
_local8 = true;
};
};
};
};
};
switch (true){
case (((_local3 > 686)) && ((_local3 < 714))):
case (((_local3 > 726)) && ((_local3 < 752))):
case (((_local3 > 765)) && ((_local3 < 792))):
renderer.moveDragonBack();
};
_local2 = numProjectiles;
while (--_local2 > -1) {
_local5 = projectiles[_local2];
if (renderer.projectileHittingDragon(_local5)){
_local4 = _local5.targetHit((combo >= AbstractLevel.MAX_COMBO));
dragonDamage = (dragonDamage + _local4);
playDamageSound();
renderer.showDamagePoints(_local5.mc.x, _local5.mc.y, _local4, true);
if ((((((--smokeCounter < 0)) && ((_local5 is HeroSpear)))) && ((_local5 as HeroSpear).heroEffect))){
renderer.addHeroSpearSmoke(_local5.mc.x, _local5.mc.y);
smokeCounter = 20;
};
if (dragonDamage >= DRAGON_MAX_DAMAGE){
dragonDestroyed = true;
renderer.dragonDestroyed();
backLimit = Number.MAX_VALUE;
frontLimit = Number.MAX_VALUE;
};
};
};
} else {
_local3 = renderer.getDragonFrame();
if (_local3 == 860){
renderer.setDragonFocus(true);
} else {
if (_local3 == 985){
renderer.setDragonFocus(false);
_local9 = Main.assetFactory.createSound("FinishSound");
_local9.play();
levelComplete(true);
} else {
if (_local3 == 926){
renderer.initShake(1.7);
};
};
};
_local2 = numProjectiles;
while (--_local2 > -1) {
_local5 = projectiles[_local2];
if (renderer.projectileHittingDragon(_local5)){
_local4 = _local5.targetHit((combo >= AbstractLevel.MAX_COMBO));
if ((((((--smokeCounter < 0)) && ((_local5 is HeroSpear)))) && ((_local5 as HeroSpear).heroEffect))){
renderer.addHeroSpearSmoke(_local5.mc.x, _local5.mc.y);
smokeCounter = 20;
};
renderer.showDamagePoints(_local5.mc.x, _local5.mc.y, _local4, true);
};
};
};
}
override protected function somethingToAttack():Boolean{
var _local3:Number;
var _local5:int;
var _local1:Boolean;
var _local2:Number = Number.MAX_VALUE;
var _local4:int = renderer.getDragonFrame();
if (!dragonDestroyed){
_local5 = 0;
while (_local5 < numCharacters) {
_local3 = (frontLimit - characters[_local5].x);
if (_local3 < _local2){
_local2 = _local3;
};
_local5++;
};
if (_local2 < MIN_ATTACK_DISTANCE){
_local1 = true;
};
} else {
if (_local4 < 985){
_local1 = true;
};
};
return (_local1);
}
}
}//package com.kerb.patapon.game
Section 25
//ParallaxLayer (com.kerb.patapon.game.ParallaxLayer)
package com.kerb.patapon.game {
import flash.display.*;
import com.kerb.patapon.*;
public class ParallaxLayer {
private var xMin:Number;// = 0
private var xRange:Number;// = 0
public var mc:MovieClip;
private var xMax:Number;// = 0
public function ParallaxLayer(_arg1:String){
mc = (Main.assetFactory.createDisplayObject(_arg1) as MovieClip);
}
public function set x(_arg1:Number):void{
mc.x = ((_arg1 * xRange) + xMin);
}
public function setLimits(_arg1:Number):void{
xMin = (_arg1 - mc.width);
xMax = 0;
xRange = (xMax - xMin);
}
}
}//package com.kerb.patapon.game
Section 26
//Renderer (com.kerb.patapon.game.Renderer)
package com.kerb.patapon.game {
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import com.kerb.patapon.game.projectiles.*;
import com.kerb.patapon.game.fireworks.*;
public class Renderer extends Sprite {
private var fireworks:Fireworks;
private var midParallax:ParallaxLayer;
private var dragon:MovieClip;
private var shakeCounter:int;
private var cameraOnDragon:Boolean;
private var viewportCentre:Number;
private var speechBubbles:Array;
private var pataAndPonSymbols:Array;
private var worldWidth:Number;
private var worldHeight:Number;
private var aura:MovieClip;
private var viewportHeight:Number;
private var ponSymbols:Array;
private var backgroundSprite:Sprite;
private var backParallax:ParallaxLayer;
private var shakePower:Number;
private var contentSprite:Sprite;
private var missionEnd:MovieClip;
private var finishingPost:MovieClip;
private var viewportWidth:Number;
private var cameraX:Number;
private var weatherSprite:Sprite;
private var frontParallax:ParallaxLayer;
private var pataSymbols:Array;
private var foregroundSprite:Sprite;
private var auraState:int;
private var damageIcons:Array;
private var renderSprite:Sprite;
private var castle:MovieClip;
private static const AURA_HIDDEN:int = 3;
private static const CAMERA_DAMPING:Number = 0.1;
private static const AURA_SHOWING:int = 0;
private static const SHAKE_DURATION:int = 15;
private static const AURA_VISIBLE:int = 2;
private static const MAX_SHAKE_DISTANCE:Number = 0;
private static const FLOOR_HEIGHT:Number = 20;
private static const AURA_HIDING:int = 1;
public static var groundLevel:Number;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.x = _arg1;
this.y = _arg2;
this.viewportWidth = _arg3;
this.viewportHeight = _arg4;
this.worldWidth = _arg5;
this.worldHeight = _arg6;
init();
}
public function addCastle(_arg1:Number):void{
castle = (Main.assetFactory.createDisplayObject("CastleAsset") as MovieClip);
castle.x = _arg1;
castle.y = (groundLevel - 266);
contentSprite.addChild(castle);
}
public function castleDestroyed():Boolean{
return ((castle.currentFrame == castle.totalFrames));
}
public function axeHittingDragon(_arg1:Point):Boolean{
return (dragon.animation.hitTestPoint(_arg1.x, _arg1.y, true));
}
public function projectileHittingDragon(_arg1:Projectile):Boolean{
var _local2:Point = new Point(0, 0);
_local2 = _arg1.mc.localToGlobal(_local2);
return (dragon.animation.hitTestPoint(_local2.x, _local2.y, true));
}
private function shake():void{
shakeCounter--;
var _local1:Number = ((shakeCounter * shakePower) * MAX_SHAKE_DISTANCE);
if ((shakeCounter % 2) == 1){
_local1 = -(_local1);
};
renderSprite.y = _local1;
}
private function init():void{
viewportCentre = (0.3 * viewportWidth);
groundLevel = (viewportHeight - FLOOR_HEIGHT);
cameraX = 0;
shakeCounter = 0;
cameraOnDragon = false;
damageIcons = new Array();
speechBubbles = new Array();
renderSprite = new Sprite();
addChild(renderSprite);
backgroundSprite = new Sprite();
renderSprite.addChild(backgroundSprite);
weatherSprite = new Sprite();
renderSprite.addChild(weatherSprite);
contentSprite = new Sprite();
renderSprite.addChild(contentSprite);
foregroundSprite = new Sprite();
foregroundSprite.graphics.beginFill(0);
foregroundSprite.graphics.drawRect(0, groundLevel, worldWidth, (2 * FLOOR_HEIGHT));
foregroundSprite.graphics.endFill();
renderSprite.addChild(foregroundSprite);
graphics.beginFill(0);
graphics.drawRect(0, 0, viewportWidth, viewportHeight);
graphics.endFill();
var _local1:Shape = new Shape();
_local1.graphics.beginFill(0);
_local1.graphics.drawRect(0, 0, viewportWidth, viewportHeight);
addChild(_local1);
renderSprite.mask = _local1;
initHitSymbols();
initAura();
}
public function checkDragonFire(_arg1:AbstractCharacter):Boolean{
if (dragon.hitRects.fire){
return (dragon.hitRects.fire.hitTestObject(_arg1.mc));
};
return (false);
}
public function showPon(_arg1:int):void{
showSymbol(ponSymbols, _arg1);
}
public function addDragon(_arg1:Number):void{
dragon = (Main.assetFactory.createDisplayObject("DragonAsset") as MovieClip);
dragon.x = _arg1;
dragon.y = groundLevel;
dragon.animation.sleeping = true;
dragon.animation.dead = false;
contentSprite.addChild(dragon);
}
public function getRetryMissionButton():MovieClip{
return (missionEnd.retry_btn);
}
public function monochrome():void{
var _local1:ColorTransform;
var _local2:int;
var _local3:Number;
var _local4:Sprite;
if (((missionEnd) && ((missionEnd.currentFrame > 150)))){
weatherSprite.alpha = (weatherSprite.alpha - 0.1);
_local4 = (backgroundSprite.getChildByName("whiteout") as Sprite);
if (_local4){
_local4.alpha = (_local4.alpha + 0.1);
} else {
_local4 = new Sprite();
_local4.graphics.beginFill(0xFFFFFF);
_local4.graphics.drawRect(0, 0, viewportWidth, viewportHeight);
_local4.alpha = 0;
_local4.name = "whiteout";
backgroundSprite.addChild(_local4);
};
_local1 = contentSprite.transform.colorTransform;
_local3 = (_local1.redMultiplier - 0.1);
if (_local3 < 0){
_local3 = 0;
};
_local1 = new ColorTransform(_local3, _local3, _local3);
contentSprite.transform.colorTransform = _local1;
};
}
public function showCastleDamage():void{
castle.nextFrame();
}
public function setCamera(_arg1:Number):void{
cameraX = (cameraX + (CAMERA_DAMPING * (_arg1 - cameraX)));
contentSprite.x = (viewportCentre - cameraX);
var _local2:Number = (1 - (cameraX / worldWidth));
backParallax.x = _local2;
midParallax.x = _local2;
frontParallax.x = _local2;
}
public function getDragonLimit():Number{
var _local1:Number = dragon.hitRects.limit.x;
_local1 = (_local1 + dragon.animation.x);
_local1 = (_local1 + dragon.x);
return (_local1);
}
public function dispose():void{
if (fireworks){
fireworks.dispose();
};
}
public function hideSymbols():void{
var _local1:int;
_local1 = 0;
while (_local1 < pataSymbols.length) {
pataSymbols[_local1].makeInvisible();
_local1++;
};
_local1 = 0;
while (_local1 < ponSymbols.length) {
ponSymbols[_local1].makeInvisible();
_local1++;
};
}
public function missionEndFinished(_arg1:int=0):Boolean{
var _local2:TextManager = TextManager.getInstance();
if (missionEnd){
if (missionEnd.logo){
missionEnd.logo.strapline.label_txt.text = "";
};
if (((missionEnd.failTitle) && (missionEnd.failTitle.label_txt))){
missionEnd.failTitle.label_txt.htmlText = (("<b>" + _local2.getTextById("game.title.missionfailed")) + "</b>");
};
if (((missionEnd.winTitle) && (missionEnd.winTitle.label_txt))){
missionEnd.winTitle.label_txt.htmlText = (("<b>" + _local2.getTextById("game.title.missioncomplete")) + "</b>");
};
if (((missionEnd.retry_btn) && (missionEnd.retry_btn.label_txt))){
missionEnd.retry_btn.label_txt.htmlText = (("<b>" + _local2.getTextById("game.title.tryagain")) + "</b>");
};
if (((missionEnd.score) && (missionEnd.score.label_txt))){
missionEnd.score.label_txt.htmlText = ((("<b>" + _local2.getTextById("game.title.score")) + ":") + "</b>");
};
if (((missionEnd.score) && (missionEnd.score.score_txt))){
missionEnd.score.score_txt.htmlText = (("<b>" + _arg1.toString()) + "</b>");
};
};
if (missionEnd){
return ((missionEnd.currentFrame == missionEnd.totalFrames));
};
return (false);
}
public function draw(_arg1:Array, _arg2:Hero):void{
var _local3:int;
var _local4:MovieClip;
var _local5:SpeechBubble;
if (cameraOnDragon){
setCamera((dragon.x + 100));
} else {
setCamera(_arg1[0].x);
};
_local3 = 0;
while (_local3 < 4) {
pataSymbols[_local3].update();
_local3++;
};
_local3 = 0;
while (_local3 < 4) {
ponSymbols[_local3].update();
_local3++;
};
_local3 = damageIcons.length;
while (--_local3 > -1) {
_local4 = damageIcons[_local3];
if (_local4.currentFrame == _local4.totalFrames){
foregroundSprite.removeChild(_local4);
damageIcons.splice(_local3, 1);
};
};
if (speechBubbles.length > 0){
_local5 = speechBubbles[0];
if (_local5.update()){
contentSprite.removeChild(_local5.mc);
speechBubbles.splice(0, 1);
if (speechBubbles.length > 0){
speechBubbles[0].activate();
};
};
};
if (auraState == AURA_SHOWING){
aura.alpha = (aura.alpha + 0.04);
aura.scaleX = (aura.scaleX + 0.04);
if (aura.scaleX >= 1){
aura.scaleX = 1;
aura.alpha = 1;
auraState = AURA_VISIBLE;
};
aura.scaleY = aura.scaleX;
} else {
if (auraState == AURA_HIDING){
aura.alpha = (aura.alpha - 0.04);
aura.scaleX = (aura.scaleX - 0.04);
if (aura.scaleX <= 0.1){
aura.alpha = 0;
aura.scaleX = 0.1;
auraState = AURA_HIDDEN;
aura.visible = false;
};
aura.scaleY = aura.scaleX;
};
};
aura.x = (aura.x + (0.05 * (_arg2.mc.x - aura.x)));
aura.y = (_arg2.mc.y - 80);
if (shakeCounter > 0){
shake();
};
}
public function dragonDestroyed():void{
dragon.animation.dead = true;
}
public function updateDragon():void{
dragon.hitRects.gotoAndStop(dragon.animation.currentFrame);
}
public function addSpeechBubble(_arg1:String, _arg2:AbstractCharacter, _arg3:int=0, _arg4:Boolean=false):void{
var _local8:SpeechBubble;
var _local5:SpeechBubble = new SpeechBubble();
var _local6:String = TextManager.getInstance().getTextById(_arg1);
var _local7 = !((((_arg1 == "game.bubbles.march")) || ((_arg1 == "game.bubbles.attack"))));
if (_arg3 == 0){
_arg3 = SpeechBubble.DEFAULT_DISPLAY_TIME;
};
if (speechBubbles.length == 0){
_arg4 = true;
speechBubbles.push(_local5);
} else {
if (_arg4){
if (speechBubbles[0].overridable){
_local8 = speechBubbles[0];
_local8.deactivate();
contentSprite.removeChild(_local8.mc);
speechBubbles.splice(0, 1, _local5);
} else {
return;
};
} else {
speechBubbles.push(_local5);
};
};
_local5.setText(_local6, _arg2, _local7, _arg3, _arg4);
contentSprite.addChild(_local5.mc);
}
public function moveDragonBack():void{
dragon.x = (dragon.x + 2.5);
}
public function addToWeather(_arg1:String):MovieClip{
var _local2:MovieClip = (Main.assetFactory.createDisplayObject(_arg1) as MovieClip);
weatherSprite.addChild(_local2);
return (_local2);
}
public function addToForeground(_arg1:String):MovieClip{
var _local2:MovieClip = (Main.assetFactory.createDisplayObject(_arg1) as MovieClip);
contentSprite.addChild(_local2);
return (_local2);
}
public function setFinishingPost(_arg1:Number):void{
finishingPost = (Main.assetFactory.createDisplayObject("FinishingPostAsset") as MovieClip);
finishingPost.x = _arg1;
finishingPost.y = ((groundLevel - finishingPost.height) + 16);
contentSprite.addChild(finishingPost);
}
public function showMissionLose():void{
missionEnd = (Main.assetFactory.createDisplayObject("MissionFailAsset") as MovieClip);
missionEnd.x = 275;
missionEnd.y = 145;
renderSprite.addChild(missionEnd);
renderSprite.removeChild(weatherSprite);
}
public function showMissionWin(_arg1:int):void{
missionEnd = (Main.assetFactory.createDisplayObject("MissionCompleteAsset") as MovieClip);
missionEnd.x = 275;
missionEnd.y = 145;
renderSprite.addChild(missionEnd);
renderSprite.removeChild(weatherSprite);
}
public function showFireworks():void{
fireworks = new Fireworks(viewportWidth, viewportHeight);
foregroundSprite.addChild(fireworks);
fireworks.start();
}
public function characterPastFinishingPost(_arg1:Array):Boolean{
var _local2:int = _arg1.length;
while (--_local2 > -1) {
if (_arg1[_local2].x > finishingPost.x){
finishingPost.gotoAndPlay("activate");
return (true);
};
};
return (false);
}
private function initAura():void{
aura = (Main.assetFactory.createDisplayObject("HeroAuraAsset") as MovieClip);
aura.alpha = 0;
aura.scaleX = (aura.scaleY = 0.1);
aura.visible = false;
contentSprite.addChild(aura);
auraState = AURA_HIDDEN;
}
public function addHeroSpearSmoke(_arg1:Number, _arg2:Number):void{
var _local3:MovieClip = (Main.assetFactory.createDisplayObject("HeroSpearSmokeAsset") as MovieClip);
_local3.x = (_arg1 + contentSprite.x);
_local3.y = _arg2;
foregroundSprite.addChild(_local3);
}
public function showPata(_arg1:int):void{
showSymbol(pataSymbols, _arg1);
}
public function setParallaxLayers(_arg1:String, _arg2:String, _arg3:String, _arg4:String):void{
backgroundSprite.addChild((Main.assetFactory.createDisplayObject(_arg1) as MovieClip));
backParallax = new ParallaxLayer(_arg2);
backParallax.setLimits(viewportWidth);
backgroundSprite.addChild(backParallax.mc);
midParallax = new ParallaxLayer(_arg3);
midParallax.setLimits(viewportWidth);
backgroundSprite.addChild(midParallax.mc);
frontParallax = new ParallaxLayer(_arg4);
frontParallax.setLimits(viewportWidth);
backgroundSprite.addChild(frontParallax.mc);
}
public function setDragonFocus(_arg1:Boolean):void{
cameraOnDragon = _arg1;
}
public function showDamagePoints(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Boolean):void{
var _local5:String;
var _local6:MovieClip;
if (_arg3 > 0){
_local5 = (_arg4) ? "DamageAsset" : "PataponDamageAsset";
_local6 = (Main.assetFactory.createDisplayObject(_local5) as MovieClip);
_local6.x = (_arg1 + contentSprite.x);
_local6.y = _arg2;
_local6.num.gotoAndStop(_arg3);
foregroundSprite.addChild(_local6);
damageIcons.push(_local6);
};
}
public function initShake(_arg1:Number):void{
this.shakePower = _arg1;
shakeCounter = (_arg1 * SHAKE_DURATION);
}
public function setAuraVisibility(_arg1:Boolean):void{
if (_arg1){
if ((((auraState == AURA_HIDING)) || ((auraState == AURA_HIDDEN)))){
auraState = AURA_SHOWING;
aura.visible = true;
};
} else {
if ((((auraState == AURA_SHOWING)) || ((auraState == AURA_VISIBLE)))){
auraState = AURA_HIDING;
};
};
}
public function wakeDragon():void{
dragon.animation.sleeping = false;
}
public function axeHittingCastle(_arg1:Point):Boolean{
return (castle.hitTestPoint(_arg1.x, _arg1.y, true));
}
public function getDragonFrame():int{
return (dragon.animation.currentFrame);
}
private function showSymbol(_arg1:Array, _arg2:int):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Array = new Array();
_local3 = 0;
while (_local3 < 4) {
if (_arg1[_local3].isHidden()){
_local7.push(_arg1[_local3]);
};
_local3++;
};
if (_local7.length > 0){
_local3 = (Math.random() * _local7.length);
_local7[_local3].show(_arg2);
} else {
_local5 = 0;
_local3 = 0;
while (_local3 < 4) {
_local4 = _arg1[_local3].getAge();
if (_local4 > _local5){
_local5 = _local4;
_local6 = _local3;
};
_local3++;
};
_arg1[_local6].show(_arg2);
};
}
public function projectileHittingCastle(_arg1:Projectile):Boolean{
var _local2:Point = new Point(0, 0);
_local2 = _arg1.mc.localToGlobal(_local2);
return (castle.hitTestPoint(_local2.x, _local2.y, true));
}
private function initHitSymbols():void{
var _local1:MovieClip;
var _local3:HitSymbol;
_local1 = (Main.assetFactory.createDisplayObject("HitSymbolsAsset") as MovieClip);
var _local2:MovieClip = _local1;
foregroundSprite.addChild(_local2);
pataSymbols = new Array();
ponSymbols = new Array();
var _local4:int;
while (_local4 < 4) {
_local1 = _local2.patas.getChildByName(("pata" + _local4));
_local3 = new HitSymbol(_local1);
pataSymbols[_local4] = _local3;
_local1 = _local2.pons.getChildByName(("pon" + _local4));
_local3 = new HitSymbol(_local1);
ponSymbols[_local4] = _local3;
_local4++;
};
}
public function addRandomSpeechBubble(_arg1:String, _arg2:Array, _arg3:int=0, _arg4:Boolean=false):void{
var _local5:int = int((Math.random() * _arg2.length));
addSpeechBubble(_arg1, _arg2[_local5], _arg3, _arg4);
}
public function addCharacters(_arg1:Array):void{
var _local3:AbstractCharacter;
var _local2:int;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
contentSprite.addChild(_local3.mc);
if (_local3.projectile){
contentSprite.addChild(_local3.projectile.mc);
};
_local2++;
};
}
}
}//package com.kerb.patapon.game
Section 27
//SpeechBubble (com.kerb.patapon.game.SpeechBubble)
package com.kerb.patapon.game {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.kerb.patapon.*;
import com.kerb.patapon.game.characters.*;
import flash.text.*;
import flash.utils.*;
public class SpeechBubble {
private var dimensions:Array;
public var overridable:Boolean;
public var mc:MovieClip;
private var displayTimer:Timer;
private var tweenStartTime:int;
private var character:AbstractCharacter;
public var verticalDeviation:Number;
private var numVisibleChars:int;
private var speechText:String;
private static const DEFAULT_VERTICAL_OFFSET_DEVIATION:Number = 35;
private static const MIN_TEXT_WIDTH:Number = 30;
private static const REVEAL_TIME:int = 1000;
private static const POINTER_HEIGHT:Number = 15;
private static const PATA_COLOUR:String = "#C31230";
private static const HORIZONTAL_PADDING:Number = 24;
private static const VERTICAL_TEXT_OFFSET:Number = 5;
private static const PON_COLOUR:String = "#0080C5";
public static const DEFAULT_DISPLAY_TIME:int = 2000;
private static const MAX_TEXT_WIDTH:Number = 100;
private static const REG_EXP:RegExp = new RegExp("[ \\-\n\t\r]");
private static const POINTER_HORIZONTAL_OFFSET:Number = 9;
private static const VERTICAL_PADDING:Number = 10;
private static const VERTICAL_OFFSET:Number = 70;
private static const GOAL_RATIO:Number = 1.414;
public function SpeechBubble(){
mc = (Main.assetFactory.createDisplayObject("SpeechBubbleAsset") as MovieClip);
mc.visible = false;
mc.speech_txt.wordWrap = true;
mc.speech_txt.autoSize = TextFieldAutoSize.CENTER;
dimensions = new Array();
var _local1:int;
while (_local1 < 10) {
dimensions.push(new Point());
_local1++;
};
verticalDeviation = DEFAULT_VERTICAL_OFFSET_DEVIATION;
displayTimer = new Timer(DEFAULT_DISPLAY_TIME, 1);
displayTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete, false, 0, true);
}
private function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
var _local5:Number = (0.45 * _arg4);
var _local6:Number = (0.35 * _local5);
return (((((_arg3 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local6) * (2 * Math.PI)) / _local5))) + _arg3) + _arg2));
}
private function formatText(_arg1:String):String{
_arg1 = _arg1.split("PATA").join((("<font color='" + PATA_COLOUR) + "'><b>PATA</b></font>"));
_arg1 = _arg1.split("PON").join((("<font color='" + PON_COLOUR) + "'><b>PON</b></font>"));
return (_arg1);
}
public function update():Boolean{
mc.x = character.mc.x;
if (mc.visible){
return (false);
};
character.speaking = false;
return (true);
}
private function formatWhiteText(_arg1:String):String{
_arg1 = _arg1.split("PATA").join("<b>PATA</b>");
_arg1 = _arg1.split("PON").join("<b>PON</b>");
_arg1 = (("<font color='#FFFFFF'>" + _arg1) + "</font>");
return (_arg1);
}
public function setText(_arg1:String, _arg2:AbstractCharacter, _arg3:Boolean, _arg4:int=2000, _arg5:Boolean=true):void{
var _local6:RegExp;
var _local9:int;
var _local13:Number;
_local6 = /pata /gi;
_arg1 = _arg1.replace(_local6, "PATA ");
_local6 = /pon /gi;
_arg1 = _arg1.replace(_local6, "PON ");
this.speechText = _arg1;
this.character = _arg2;
this.overridable = _arg3;
_arg2.speaking = true;
var _local7:Number = MIN_TEXT_WIDTH;
var _local8:Array = _arg1.split(REG_EXP);
_local9 = 0;
while (_local9 < _local8.length) {
if (_local8[_local9] == "PATA"){
_local8[_local9] = "<b>PATA</b>";
} else {
if (_local8[_local9] == "PON"){
_local8[_local9] = "<b>PON</b>";
};
};
_local9++;
};
_local9 = _local8.length;
while (_local9-- > 0) {
mc.speech_txt.htmlText = _local8[_local9];
if (mc.speech_txt.textWidth > _local7){
_local7 = mc.speech_txt.textWidth;
};
};
_local7 = (_local7 + 5);
mc.speech_txt.width = _local7;
mc.speech_txt.htmlText = formatText(_arg1);
var _local10:int = (mc.speech_txt.numLines + 1);
_local9 = 0;
while (_local10 > 1) {
mc.speech_txt.width++;
if (mc.speech_txt.numLines != _local10){
_local10 = mc.speech_txt.numLines;
var _temp1 = _local9;
_local9 = (_local9 + 1);
addToDimensions(mc.speech_txt, _temp1);
};
if (mc.speech_txt.width > MAX_TEXT_WIDTH){
break;
};
};
if (_local10 == 1){
var _temp2 = _local9;
_local9 = (_local9 + 1);
addToDimensions(mc.speech_txt, _temp2);
};
var _local11:Number = 9999;
var _local12:int;
while (_local9-- > 0) {
_local13 = (dimensions[_local9].x / dimensions[_local9].y);
_local13 = Math.abs((GOAL_RATIO - _local13));
if (_local13 < _local11){
_local11 = _local13;
_local12 = _local9;
};
};
mc.speech_txt.width = dimensions[_local12].x;
mc.speech_txt.height = dimensions[_local12].y;
mc.speech_txt.x = (-0.5 * mc.speech_txt.width);
mc.speech_txt.y = ((-(mc.speech_txt.height) - POINTER_HEIGHT) - VERTICAL_TEXT_OFFSET);
mc.bg.width = (HORIZONTAL_PADDING + mc.speech_txt.width);
mc.bg.height = (VERTICAL_PADDING + mc.speech_txt.height);
mc.bg.y = ((-0.5 * mc.bg.height) - POINTER_HEIGHT);
if (Math.random() < 0.5){
mc.pointer.scaleX = -1;
mc.bg.x = -(POINTER_HORIZONTAL_OFFSET);
mc.speech_txt.x = (mc.speech_txt.x - POINTER_HORIZONTAL_OFFSET);
} else {
mc.pointer.scaleX = 1;
mc.bg.x = -(POINTER_HORIZONTAL_OFFSET);
mc.speech_txt.x = (mc.speech_txt.x - POINTER_HORIZONTAL_OFFSET);
};
mc.pointer.scaleY = 1;
if (mc.pointer.height > -(mc.bg.y)){
mc.pointer.height = -(mc.bg.y);
};
displayTimer.reset();
displayTimer.delay = _arg4;
mc.speech_txt.htmlText = "";
mc.scaleX = 0;
mc.scaleY = 0;
var _local14:Number = (((2 * Math.random()) * verticalDeviation) - verticalDeviation);
mc.y = ((_arg2.mc.y - VERTICAL_OFFSET) + _local14);
if (_arg5){
activate();
};
}
private function addToDimensions(_arg1:TextField, _arg2:int):void{
while (dimensions.length < (_arg2 + 1)) {
dimensions.push(new Point());
};
dimensions[_arg2].x = _arg1.width;
dimensions[_arg2].y = _arg1.height;
}
public function deactivate():void{
displayTimer.reset();
if (mc){
mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
public function activate():void{
numVisibleChars = 0;
mc.visible = true;
displayTimer.reset();
displayTimer.start();
tweenStartTime = getTimer();
mc.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local5:String;
var _local6:String;
var _local7:String;
var _local2:int = numVisibleChars;
var _local3:int = (getTimer() - tweenStartTime);
var _local4:Number = easeOut(_local3, 0, 1, REVEAL_TIME);
mc.scaleX = _local4;
mc.scaleY = _local4;
if (numVisibleChars < speechText.length){
_local5 = speechText.charAt(_local2);
_local6 = speechText.substr(0, _local2);
_local6 = formatText(_local6);
_local7 = speechText.substr((_local2 + 1));
_local7 = formatWhiteText(_local7);
mc.speech_txt.htmlText = ((_local6 + _local5) + _local7);
numVisibleChars++;
} else {
if (_local3 >= REVEAL_TIME){
mc.scaleX = 1;
mc.scaleY = 1;
mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
};
}
private function onTimerComplete(_arg1:TimerEvent):void{
mc.visible = false;
}
}
}//package com.kerb.patapon.game
Section 28
//Vocals (com.kerb.patapon.game.Vocals)
package com.kerb.patapon.game {
import com.kerb.patapon.*;
import flash.media.*;
public class Vocals {
private var pataVox:Array;
private var numPonVox:int;
private var ponVox:Array;
private var huhSound:Sound;
private var numPataVox:int;
private static const STFU:Boolean = true;
public function Vocals(){
pataVox = new Array();
ponVox = new Array();
numPataVox = 0;
numPonVox = 0;
huhSound = Main.assetFactory.createSound("HuhSound");
}
public function getFirstPonVocal():Sound{
return (ponVox[0]);
}
public function huh():void{
huhSound.play();
}
public function addPataVocal(_arg1:String):void{
var _local2:Sound = Main.assetFactory.createSound(_arg1);
pataVox.push(_local2);
numPataVox++;
}
public function getPataVocal():Sound{
var _local1:int = (Math.random() * numPataVox);
return (pataVox[_local1]);
}
public function getPonVocal():Sound{
var _local1:int = (Math.random() * numPonVox);
return (ponVox[_local1]);
}
public function getFirstPataVocal():Sound{
return (pataVox[0]);
}
public function addPonVocal(_arg1:String):void{
var _local2:Sound = Main.assetFactory.createSound(_arg1);
ponVox.push(_local2);
numPonVox++;
}
}
}//package com.kerb.patapon.game
Section 29
//AbstractSection (com.kerb.patapon.AbstractSection)
package com.kerb.patapon {
import com.kerb.game.*;
public class AbstractSection extends AbstractSection {
protected var main:AbstractMain;
public function setMain(_arg1:AbstractMain):void{
this.main = _arg1;
}
}
}//package com.kerb.patapon
Section 30
//AssetBrowser (com.kerb.patapon.AssetBrowser)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.media.*;
public class AssetBrowser {
private var sfx:Sound;
private var autoUnlock:Boolean;
private var mc:MovieClip;
public var inTransition:Boolean;
private var buttonsActive:Boolean;
private var numAssets:int;
private var maxScreenNum:int;
private var linkagePrefix:String;
private var screenNum:int;
private var numUnlockedAssets:int;
public static const NUM_ICONS:int = 8;
public static const LEFT:int = -1;
private static const ASSET_PREFIX:Array = ["bg_", "char_", "enemy_"];
public static const RIGHT:int = 1;
public function AssetBrowser(_arg1:MovieClip, _arg2:int, _arg3:int, _arg4:int){
this.mc = _arg1;
this.numAssets = _arg2;
this.numUnlockedAssets = _arg3;
linkagePrefix = ASSET_PREFIX[_arg4];
init();
}
private function onRightClick(_arg1:MouseEvent):void{
if (!inTransition){
scroll(RIGHT);
};
}
public function scroll(_arg1:int):Boolean{
var _local2:int = (screenNum + _arg1);
if ((((_local2 >= 0)) && ((_local2 <= maxScreenNum)))){
screenNum = _local2;
inTransition = true;
if (screenNum == 0){
mc.left_btn.visible = false;
} else {
if (screenNum == maxScreenNum){
mc.right_btn.visible = false;
};
};
if (_arg1 == LEFT){
mc.gotoAndPlay("transitionLeft");
} else {
if (_arg1 == RIGHT){
mc.gotoAndPlay("transitionRight");
};
};
return (true);
//unresolved jump
};
return (false);
}
public function activateButtons():void{
buttonsActive = true;
mc.left_btn.visible = (screenNum > 0);
mc.right_btn.visible = (screenNum < maxScreenNum);
}
private function init():void{
mc.gotoAndStop("in");
mc.left_btn.addEventListener(MouseEvent.CLICK, onLeftClick);
mc.right_btn.addEventListener(MouseEvent.CLICK, onRightClick);
mc.addEventListener("ASSET_STORE_MIDTRANSITION", onMidTransition);
mc.addEventListener("ASSET_STORE_TRANSITION_FINISHED", onTransitionComplete);
mc.left_btn.visible = false;
mc.right_btn.visible = false;
inTransition = false;
autoUnlock = false;
buttonsActive = false;
screenNum = 0;
maxScreenNum = (Math.ceil((numAssets / NUM_ICONS)) - 1);
sfx = Main.assetFactory.createSound("LockSound");
populateIcons();
}
private function populateIcons():void{
var _local1:int;
var _local2:MovieClip;
var _local3:MovieClip;
var _local4:int;
_local1 = 1;
while (_local1 <= NUM_ICONS) {
_local4 = (_local1 + (screenNum * NUM_ICONS));
_local3 = (Main.assetFactory.createDisplayObject(((linkagePrefix + _local4) + "_btn")) as MovieClip);
_local2 = (mc.getChildByName((("icon" + _local1) + "_btn")) as MovieClip);
while (_local2.item_mc.numChildren > 0) {
_local2.item_mc.removeChildAt(0);
};
_local2.item_mc.addChild(_local3);
if (autoUnlock){
_local2.locked_mc.visible = (_local4 > numUnlockedAssets);
} else {
_local2.locked_mc.gotoAndStop("locked");
_local2.locked_mc.visible = true;
};
_local1++;
};
}
public function unlockIcon(_arg1:int):void{
var _local2:MovieClip;
_arg1 = (_arg1 - (screenNum * NUM_ICONS));
if (_arg1 < NUM_ICONS){
_arg1++;
_local2 = (mc.getChildByName((("icon" + _arg1) + "_btn")) as MovieClip);
_local2.locked_mc.gotoAndPlay("unlock");
sfx.play();
};
}
private function onMidTransition(_arg1:Event):void{
populateIcons();
}
public function dispose():void{
mc.left_btn.removeEventListener(MouseEvent.CLICK, onLeftClick);
mc.right_btn.removeEventListener(MouseEvent.CLICK, onRightClick);
mc.removeEventListener("ASSET_STORE_MIDTRANSITION", onMidTransition);
mc.removeEventListener("ASSET_STORE_TRANSITION_FINISHED", onTransitionComplete);
}
private function onLeftClick(_arg1:MouseEvent):void{
if (!inTransition){
scroll(LEFT);
};
}
public function activateAutoUnlock():void{
autoUnlock = true;
}
private function onTransitionComplete(_arg1:Event):void{
if (buttonsActive){
activateButtons();
};
inTransition = false;
}
}
}//package com.kerb.patapon
Section 31
//AssetFactory (com.kerb.patapon.AssetFactory)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.media.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):Sound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as Sound));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package com.kerb.patapon
Section 32
//Crypto (com.kerb.patapon.Crypto)
package com.kerb.patapon {
public class Crypto {
private static var KEYS:Array = new Array("98sdfa23Ql", "ADF8b3w2fq", "ER2b79hwfO", "clkenf0FSj", "4R7d6ASYU3", "ASDQsjhW02", "kCQ6YH9asc", "ADIx7g19SP", "Nd98fhiOAF", "a09hADNFkf");
private static var SALT:String = "8008135";
public static function encrypt(_arg1:String):String{
var _local2:String = ((_arg1 + "") + SALT);
var _local3 = "";
var _local4:int = Math.floor((Math.random() * KEYS.length));
var _local5:int = _local4;
var _local6:int;
while (_local6 < _local2.length) {
_local3 = (_local3 + KEYS[_local5].charAt(parseInt(_local2.charAt(_local6))));
_local5 = ((_local5 + 1) % KEYS.length);
_local6++;
};
_local3 = (_local3 + ("" + _local4));
return (_local3);
}
public static function decrypt(_arg1:String):String{
var _local6:int;
var _local2:int = parseInt(_arg1.substr(-1));
var _local3:String = _arg1.substr(0, (_arg1.length - 1));
var _local4 = "";
var _local5:int;
while (_local5 < _local3.length) {
_local6 = KEYS[_local2].indexOf(_local3.charAt(_local5));
if (_local6 > -1){
_local4 = (_local4 + ("" + _local6));
} else {
return ("");
};
_local2 = ((_local2 + 1) % KEYS.length);
_local5++;
};
if (_local4.substr(-(SALT.length)) != SALT){
return ("");
};
return (_local4.substr(0, (_local4.length - SALT.length)));
}
}
}//package com.kerb.patapon
Section 33
//GameComplete (com.kerb.patapon.GameComplete)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import com.kerb.tracking.*;
import flash.ui.*;
public class GameComplete extends AbstractSection {
private var submitScoreButton:SuperButton;
private var wallpaperString:String;
private var mc:MovieClip;
private var playAgainButton:SuperButton;
public function GameComplete(){
mc = (Main.assetFactory.createDisplayObject("GameCompleteSectionAsset") as MovieClip);
addChild(mc);
}
private function onPlayAgainClick(_arg1:MouseEvent=null):void{
Main.scoreSubmitted = false;
Main.buttonSound.play();
NextSectionClass = Title;
gotoNextSection();
if (Main.VIRAL){
DoubleQuick.event(300);
} else {
DoubleQuick.event(317);
Main.webtrends("tryagain");
};
}
private function onWallpaperClick(_arg1:MouseEvent=null):void{
Main.scoreSubmitted = true;
Main.buttonSound.play();
var _local2:String = (Main.basePath + Main.WALLPAPER_CREATOR_URL);
var _local3:URLVariables = new URLVariables();
_local3.score = wallpaperString;
var _local4:URLRequest = new URLRequest(_local2);
_local4.method = URLRequestMethod.POST;
_local4.data = _local3;
navigateToURL(_local4, (Main.VIRAL) ? "_blank" : "_self");
if (Main.VIRAL){
DoubleQuick.event(298);
} else {
DoubleQuick.event(315);
Main.webtrends("wallpaper");
};
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (stage.focus == mc.playAgain_btn){
onPlayAgainClick();
} else {
if (stage.focus == mc.submitScore_btn){
onSubmitScoreClick();
} else {
onWallpaperClick();
};
};
};
}
private function onSubmitScoreClick(_arg1:MouseEvent=null):void{
Main.buttonSound.play();
NextSectionClass = SubmitHighScore;
gotoNextSection();
if (Main.VIRAL){
DoubleQuick.event(299);
} else {
DoubleQuick.event(316);
Main.webtrends("highscore");
};
}
override public function dispose():void{
mc.wallpaper_btn.removeEventListener(MouseEvent.CLICK, onWallpaperClick);
playAgainButton.removeEventListener(MouseEvent.CLICK, onPlayAgainClick);
submitScoreButton.removeEventListener(MouseEvent.CLICK, onSubmitScoreClick);
}
override protected function init():void{
if (PreviousSectionClass == SubmitHighScore){
mc.gotoAndStop(mc.totalFrames);
};
mc.progress.gotoAndStop("Complete");
mc.title_txt.text = TextManager.getInstance().getTextById("game.endscreen.unlocked.final.1");
mc.logo.strapline.label_txt.text = "";
var _local1:String = TextManager.getInstance().getTextById("game.endscreen.unlocked.final.2");
var _local2:Main = (main as Main);
var _local3:int;
var _local4:int;
var _local5:int;
wallpaperString = "";
var _local6:int;
while (_local6 < _local2.levels.length) {
_local3 = (_local3 + _local2.levelScores[_local6]);
_local4 = (_local4 + _local2.numUnlockedItems[_local6]);
_local5 = (_local5 + _local2.numLevelItems[_local6]);
if (_local2.numUnlockedItems[_local6] < 10){
wallpaperString = (wallpaperString + "0");
};
wallpaperString = (wallpaperString + _local2.numUnlockedItems[_local6]);
_local6++;
};
_local1 = _local1.split("@@SCORE@@").join(_local3);
_local1 = _local1.split("@@UNLOCKED@@").join(_local4);
_local1 = _local1.split("@@TOTAL@@").join(_local5);
mc.subHead_txt.text = _local1;
wallpaperString = (wallpaperString + _local3);
wallpaperString = Crypto.encrypt(wallpaperString);
var _local7:String = TextManager.getInstance().getTextById("game.endscreen.unlocked.final.3");
var _local8:int = (0.5 * _local7.length);
_local8 = _local7.lastIndexOf(" ", _local8);
_local7 = ((_local7.substring(0, _local8) + "\n") + _local7.substring((_local8 + 1)));
mc.wallpaper_btn.addEventListener(MouseEvent.CLICK, onWallpaperClick);
mc.wallpaper_btn.tabIndex = 1;
mc.wallpaper_btn.txt.label_txt.htmlText = (("<b>" + _local7) + "</b>");
mc.wallpaper_btn.mouseChildren = false;
mc.wallpaper_btn.buttonMode = true;
playAgainButton = new SuperButton(mc.playAgain_btn, "game.title.tryagain");
playAgainButton.addEventListener(MouseEvent.CLICK, onPlayAgainClick);
mc.playAgain_btn.tabIndex = 3;
submitScoreButton = new SuperButton(mc.submitScore_btn, "game.button.submitscore");
submitScoreButton.addEventListener(MouseEvent.CLICK, onSubmitScoreClick);
mc.submitScore_btn.x = ((550 - mc.playAgain_btn.x) - mc.submitScore_btn.width);
mc.submitScore_btn.tabIndex = 2;
if (((Main.scoreSubmitted) && (Main.VIRAL))){
mc.wallpaper_btn.mouseEnabled = false;
submitScoreButton.enabled = false;
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
}
}
}//package com.kerb.patapon
Section 34
//Instructions (com.kerb.patapon.Instructions)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import com.kerb.patapon.game.*;
import com.kerb.tracking.*;
import flash.ui.*;
public class Instructions extends AbstractSection {
private var step:int;
private var soundOn:Boolean;
private var keyHitOK:Boolean;
private var skipButton:SuperButton;
private var mc:MovieClip;
private var panel_mc:MovieClip;
private var tm:TextManager;
public function Instructions(){
mc = (Main.assetFactory.createDisplayObject("InstructionsSectionAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
addChild(mc);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (step == 0){
showPanel1();
} else {
if (step == 1){
soundOn = true;
showPanel2();
} else {
mc.metronome.stop();
mc.metronome.visible = false;
gotoNextSection();
};
};
} else {
if ((((((step == 2)) && ((_arg1.keyCode == Keyboard.LEFT)))) && ((panel_mc.currentLabel == "userInput")))){
panel_mc.pata.gotoAndPlay("on");
if (panel_mc.left){
panel_mc.left.gotoAndStop("onRed");
};
if (!keyHitOK){
keyHitOK = timingOK();
};
if (!keyHitOK){
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.tryagain")) + "\n\n") + tm.getTextById("game.instructions.commands")) + "</b>");
};
} else {
if ((((((step == 3)) && ((_arg1.keyCode == Keyboard.RIGHT)))) && ((panel_mc.currentLabel == "userInput")))){
panel_mc.pon.gotoAndPlay("on");
if (panel_mc.right){
panel_mc.right.gotoAndStop("onBlue");
};
if (!keyHitOK){
keyHitOK = timingOK();
};
if (!keyHitOK){
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.tryagain")) + "\n\n") + tm.getTextById("game.instructions.commands")) + "</b>");
};
};
};
};
}
private function updateDynamicText(_arg1:Event=null):void{
if (((panel_mc.yes_btn) && (panel_mc.yes_btn.label_txt))){
panel_mc.yes_btn.label_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.loud")) + "</b>");
};
if (((panel_mc.no_btn) && (panel_mc.no_btn.label_txt))){
panel_mc.no_btn.label_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.nodrums")) + "</b>");
};
if (((panel_mc.battle_btn) && (panel_mc.battle_btn.label_txt))){
panel_mc.battle_btn.label_txt.htmlText = (("<b>" + tm.getTextById("game.intro.button.take")) + "</b>");
};
if (((panel_mc.next_btn) && (panel_mc.next_btn.label_txt))){
panel_mc.next_btn.label_txt.htmlText = (("<b>" + tm.getTextById("game.intro.button.take")) + "</b>");
};
}
private function showPanel0():void{
mc.metronome.stop();
mc.metronome.visible = false;
panel_mc = (Main.assetFactory.createDisplayObject("InstructionsPanel0Asset") as MovieClip);
panel_mc.title_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.title")) + "</b>");
panel_mc.strapline_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.art")) + "</b>");
panel_mc.subHead_txt.htmlText = (("<b>" + tm.getTextById("game.intro.become")) + "</b>");
panel_mc.copy1_txt.text = tm.getTextById("game.intro.immortalise1");
panel_mc.copy2_txt.text = tm.getTextById("game.intro.immortalise2");
panel_mc.next_btn.addEventListener(MouseEvent.ROLL_OVER, updateDynamicText, false, 0, true);
panel_mc.next_btn.addEventListener(MouseEvent.ROLL_OUT, updateDynamicText, false, 0, true);
panel_mc.next_btn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true);
panel_mc.next_btn.buttonMode = true;
panel_mc.next_btn.mouseChildren = false;
step = 0;
mc.addChild(panel_mc);
}
private function showPanel1():void{
SoundMixer.stopAll();
var _local1:Sound = Main.assetFactory.createSound("Africa2Sound");
_local1.play(0, 1);
mc.removeChild(panel_mc);
panel_mc = (Main.assetFactory.createDisplayObject("InstructionsPanel1Asset") as MovieClip);
panel_mc.copy_txt.text = tm.getTextById("game.instructions.hear");
panel_mc.yes_btn.label_txt.text = tm.getTextById("game.instructions.loud");
panel_mc.yes_btn.addEventListener(MouseEvent.ROLL_OVER, updateDynamicText, false, 0, true);
panel_mc.yes_btn.addEventListener(MouseEvent.ROLL_OUT, updateDynamicText, false, 0, true);
panel_mc.yes_btn.addEventListener(MouseEvent.CLICK, onYesClick, false, 0, true);
panel_mc.yes_btn.buttonMode = true;
panel_mc.yes_btn.mouseChildren = false;
panel_mc.no_btn.label_txt.text = tm.getTextById("game.instructions.nodrums");
panel_mc.no_btn.addEventListener(MouseEvent.ROLL_OVER, updateDynamicText, false, 0, true);
panel_mc.no_btn.addEventListener(MouseEvent.ROLL_OUT, updateDynamicText, false, 0, true);
panel_mc.no_btn.addEventListener(MouseEvent.CLICK, onNoClick, false, 0, true);
panel_mc.no_btn.buttonMode = true;
panel_mc.no_btn.mouseChildren = false;
step = 1;
mc.addChild(panel_mc);
mc.setChildIndex(mc.metronome, (mc.numChildren - 1));
}
private function showPanel2():void{
mc.removeChild(panel_mc);
panel_mc = (Main.assetFactory.createDisplayObject("InstructionsPanel2Asset") as MovieClip);
panel_mc.pata.gotoAndStop("off");
panel_mc.pon.gotoAndStop("off");
if (soundOn){
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.thisisthesound")) + "\n\n") + tm.getTextById("game.instructions.march.fight")) + "</b>");
} else {
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.noaudio.watch")) + "\n\n") + tm.getTextById("game.instructions.march.fight")) + "</b>");
};
panel_mc.bottom_txt.text = "";
skipButton = new SuperButton(panel_mc.skip_btn, "game.button.skip");
skipButton.addEventListener(MouseEvent.CLICK, onSkipClick);
step = 2;
keyHitOK = false;
mc.addChild(panel_mc);
mc.setChildIndex(mc.metronome, (mc.numChildren - 1));
stage.focus = stage;
}
private function showPanel4():void{
mc.metronome.stop();
mc.metronome.visible = false;
if (panel_mc.right){
panel_mc.right.gotoAndStop("disabled");
};
skipButton.removeEventListener(MouseEvent.CLICK, onSkipClick);
panel_mc.skip_btn.visible = false;
panel_mc.top_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.leader")) + "</b>");
panel_mc.bottom_txt.text = "";
panel_mc.battle_btn.label_txt.text = tm.getTextById("game.intro.button.take");
panel_mc.battle_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true);
panel_mc.battle_btn.buttonMode = true;
panel_mc.battle_btn.mouseChildren = false;
panel_mc.battle_btn.visible = true;
step = 4;
}
private function showPanel3():void{
mc.removeChild(panel_mc);
panel_mc = (Main.assetFactory.createDisplayObject("InstructionsPanel3Asset") as MovieClip);
panel_mc.pata.gotoAndStop("off");
panel_mc.pon.gotoAndStop("off");
panel_mc.battle_btn.visible = false;
if (soundOn){
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.thisisthesound")) + "\n\n") + tm.getTextById("game.instructions.march.fight")) + "</b>");
} else {
panel_mc.top_txt.htmlText = (((("<b>" + tm.getTextById("game.instructions.noaudio.watch")) + "\n\n") + tm.getTextById("game.instructions.march.fight")) + "</b>");
};
panel_mc.bottom_txt.text = "";
skipButton.removeEventListener(MouseEvent.CLICK, onSkipClick);
skipButton = new SuperButton(panel_mc.skip_btn, "game.button.skip");
skipButton.addEventListener(MouseEvent.CLICK, onSkipClick);
step = 3;
keyHitOK = false;
mc.addChild(panel_mc);
mc.setChildIndex(mc.metronome, (mc.numChildren - 1));
stage.focus = stage;
}
private function onPlayClick(_arg1:MouseEvent):void{
Main.buttonSound.play();
gotoNextSection();
}
override protected function init():void{
tm = TextManager.getInstance();
showPanel0();
NextSectionClass = Level1;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.focus = stage;
}
override public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function timingOK():Boolean{
var _local2:int;
var _local1:Boolean;
if (mc.metronome){
_local2 = (mc.metronome.currentFrame % 15);
if (_local2 > 7){
_local2 = (_local2 - 15);
};
if (Math.abs(_local2) < 4){
_local1 = true;
};
};
return (_local1);
}
private function onYesClick(_arg1:MouseEvent):void{
Main.buttonSound.play();
soundOn = true;
(main as Main).gameWithAudio = true;
showPanel2();
if (Main.VIRAL){
DoubleQuick.event(322);
} else {
DoubleQuick.event(310);
Main.webtrends("soundon");
};
}
private function onNoClick(_arg1:MouseEvent):void{
Main.buttonSound.play();
soundOn = false;
(main as Main).gameWithAudio = false;
showPanel2();
if (Main.VIRAL){
DoubleQuick.event(323);
} else {
DoubleQuick.event(321);
Main.webtrends("soundoff");
};
}
private function onSkipClick(_arg1:MouseEvent):void{
mc.metronome.stop();
mc.metronome.visible = false;
Main.buttonSound.play();
gotoNextSection();
}
private function onEnterFrame(_arg1:Event):void{
updateDynamicText();
if (step == 1){
if (((panel_mc) && ((panel_mc.currentFrame == (panel_mc.totalFrames - 3))))){
mc.metronome.play();
mc.metronome.visible = true;
};
} else {
if (step == 2){
if (panel_mc){
if (panel_mc.currentFrame == panel_mc.totalFrames){
showPanel3();
};
if (panel_mc.currentLabel == "userInstructions"){
panel_mc.bottom_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.pata.shout")) + "</b>");
} else {
if ((((panel_mc.currentLabel == "userSetup")) && (panel_mc.left))){
panel_mc.left.gotoAndStop("off");
};
};
};
} else {
if (step == 3){
if (panel_mc){
if (panel_mc.currentFrame == panel_mc.totalFrames){
panel_mc.stop();
showPanel4();
};
if (panel_mc.currentLabel == "userInstructions"){
panel_mc.bottom_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.pon.shout")) + "</b>");
} else {
if ((((panel_mc.currentLabel == "userSetup")) && (panel_mc.right))){
panel_mc.right.gotoAndStop("off");
};
};
};
};
};
};
}
private function onNextClick(_arg1:MouseEvent):void{
Main.buttonSound.play();
showPanel1();
}
private function onKeyUp(_arg1:KeyboardEvent):void{
if ((((step == 2)) && ((_arg1.keyCode == Keyboard.LEFT)))){
if (panel_mc.left){
panel_mc.left.gotoAndStop("off");
};
if (keyHitOK){
panel_mc.top_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.excellent")) + "</b>");
panel_mc.bottom_txt.text = "";
panel_mc.play();
};
} else {
if ((((step == 3)) && ((_arg1.keyCode == Keyboard.RIGHT)))){
if (panel_mc.right){
panel_mc.right.gotoAndStop("off");
};
if (keyHitOK){
panel_mc.top_txt.htmlText = (("<b>" + tm.getTextById("game.instructions.excellent")) + "</b>");
panel_mc.bottom_txt.text = "";
panel_mc.play();
};
};
};
}
}
}//package com.kerb.patapon
Section 35
//LevelWin (com.kerb.patapon.LevelWin)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.media.*;
import com.kerb.patapon.game.*;
import flash.utils.*;
import flash.ui.*;
public class LevelWin extends AbstractSection {
private var nextButton:SuperButton;
private var numUnlocks:int;
private var sc:SoundChannel;
private var mc:MovieClip;
private var assetBrowser:AssetBrowser;
private var pointsPerUnlock:Number;
private var lockedAssetsTimer:Timer;
private var bgMusic:Sound;
private var levelNum:int;
private var totalScore:int;
private var nextLevelNum:int;
private var retryButton:SuperButton;
private var levelScore:int;
private static const LOCKED_ASSETS_NORMAL_TIMER_INTERVAL:int = 2000;
private static const LOCKED_ASSETS_INIT_TIMER_INTERVAL:int = 20;
private static const POINTS_STEP:int = 10;
public function LevelWin(){
mc = (Main.assetFactory.createDisplayObject("LevelWinSectionAsset") as MovieClip);
addChild(mc);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (stage.focus == mc.retry_btn){
onRetryClick();
} else {
onNextClick();
};
};
}
private function updatePoints():void{
var _local3:int;
var _local1:int = Math.round((levelScore / pointsPerUnlock));
if (levelScore > POINTS_STEP){
levelScore = (levelScore - POINTS_STEP);
totalScore = (totalScore + POINTS_STEP);
} else {
totalScore = (totalScore + levelScore);
levelScore = 0;
};
var _local2:int = Math.round((levelScore / pointsPerUnlock));
if (_local2 != _local1){
_local3 = (numUnlocks - _local1);
assetBrowser.unlockIcon(_local3);
if (((_local3 + 1) % AssetBrowser.NUM_ICONS) == 0){
assetBrowser.scroll(AssetBrowser.RIGHT);
};
if (_local3 == (numUnlocks - 1)){
lockedAssetsTimer.start();
};
};
mc.levelScore_txt.text = ("00000" + levelScore.toString()).substr(-5);
mc.totalScore_txt.text = ("00000" + totalScore.toString()).substr(-5);
}
override protected function init():void{
var _local5:Number;
var _local6:Number;
var _local7:int;
var _local1:Main = (main as Main);
var _local2:Array = _local1.levelScores;
_local7 = _local1.currLevelNum;
levelScore = _local2[_local7];
numUnlocks = _local1.numUnlockedItems[_local7];
pointsPerUnlock = (levelScore / numUnlocks);
totalScore = -(levelScore);
var _local3:int;
while (_local3 < _local2.length) {
totalScore = (totalScore + _local2[_local3]);
_local3++;
};
mc.progress.gotoAndStop(("Level" + ((main as Main).currLevelNum + 1)));
mc.levelScore_txt.text = ("00000" + levelScore.toString()).substr(-5);
mc.totalScore_txt.text = ("00000" + totalScore.toString()).substr(-5);
var _local4:TextManager = TextManager.getInstance();
mc.levelScoreLabel_txt.text = (_local4.getTextById("game.title.levelscore") + ":");
mc.totalScoreLabel_txt.text = (_local4.getTextById("game.title.totalscore") + ":");
mc.levelScore_txt.autoSize = TextFieldAutoSize.LEFT;
mc.totalScore_txt.autoSize = TextFieldAutoSize.LEFT;
mc.levelScoreLabel_txt.autoSize = TextFieldAutoSize.RIGHT;
mc.totalScoreLabel_txt.autoSize = TextFieldAutoSize.RIGHT;
_local5 = ((mc.totalScore_txt.x + mc.totalScore_txt.width) - mc.totalScoreLabel_txt.x);
_local6 = (mc.totalScore_txt.x - mc.totalScoreLabel_txt.x);
mc.totalScoreLabel_txt.x = (0.5 * (550 - _local5));
mc.totalScore_txt.x = (mc.totalScoreLabel_txt.x + _local6);
_local6 = (mc.levelScore_txt.x - mc.levelScoreLabel_txt.x);
mc.levelScore_txt.x = mc.totalScore_txt.x;
mc.levelScoreLabel_txt.x = (mc.levelScore_txt.x - _local6);
mc.section1Label_txt.text = _local4.getTextById("game.title.backgrounds");
mc.section2Label_txt.text = _local4.getTextById("game.title.characters");
mc.section3Label_txt.text = _local4.getTextById("game.title.enemies");
mc.section1Label_txt.alpha = ((_local7)==0) ? 1 : 0.5;
mc.section2Label_txt.alpha = ((_local7)==1) ? 1 : 0.5;
mc.section3Label_txt.alpha = ((_local7)==2) ? 1 : 0.5;
mc.copy_txt.text = _local4.getTextById("game.levelend.unlock");
retryButton = new SuperButton(mc.retry_btn, "game.title.tryagain");
retryButton.addEventListener(MouseEvent.CLICK, onRetryClick);
mc.retry_btn.tabIndex = 2;
nextButton = new SuperButton(mc.next_btn, "game.button.continue");
nextButton.addEventListener(MouseEvent.CLICK, onNextClick);
mc.next_btn.x = ((550 - mc.retry_btn.x) - mc.next_btn.width);
mc.next_btn.tabIndex = 1;
_local7 = _local1.currLevelNum;
var _local8:int = _local1.numLevelItems[_local7];
var _local9:int = _local1.numUnlockedItems[_local7];
assetBrowser = new AssetBrowser(mc.assets, _local8, _local9, _local7);
lockedAssetsTimer = new Timer(LOCKED_ASSETS_INIT_TIMER_INTERVAL);
lockedAssetsTimer.addEventListener(TimerEvent.TIMER, onLockedAssetsTimer);
mc.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
}
override public function dispose():void{
mc.next_btn.removeEventListener(MouseEvent.CLICK, onNextClick);
mc.retry_btn.removeEventListener(MouseEvent.CLICK, onRetryClick);
mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
lockedAssetsTimer.removeEventListener(TimerEvent.TIMER, onLockedAssetsTimer);
assetBrowser.dispose();
}
public function getNextLevelNum():int{
return (nextLevelNum);
}
private function onNextClick(_arg1:MouseEvent=null):void{
Main.buttonSound.play();
var _local2:Main = (main as Main);
_local2.currLevelNum++;
if (_local2.currLevelNum < _local2.levels.length){
NextSectionClass = _local2.levels[_local2.currLevelNum];
} else {
NextSectionClass = GameComplete;
};
if (sc){
sc.stop();
};
gotoNextSection();
}
private function onLockedAssetsTimer(_arg1:TimerEvent):void{
if (lockedAssetsTimer.delay == LOCKED_ASSETS_INIT_TIMER_INTERVAL){
lockedAssetsTimer.delay = LOCKED_ASSETS_NORMAL_TIMER_INTERVAL;
};
if (!assetBrowser.scroll(AssetBrowser.RIGHT)){
lockedAssetsTimer.stop();
assetBrowser.activateButtons();
assetBrowser.activateAutoUnlock();
};
}
private function onEnterFrame(_arg1:Event):void{
if (levelScore > 0){
if (!assetBrowser.inTransition){
updatePoints();
};
} else {
mc.levelScoreLabel_txt.text = "";
mc.levelScore_txt.text = "";
if (!bgMusic){
bgMusic = Main.assetFactory.createSound("ResultSound");
sc = bgMusic.play(0, 9999999);
};
mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
private function onRetryClick(_arg1:MouseEvent=null):void{
Main.buttonSound.play();
NextSectionClass = PreviousSectionClass;
if (sc){
sc.stop();
};
gotoNextSection();
}
}
}//package com.kerb.patapon
Section 36
//Main (com.kerb.patapon.Main)
package com.kerb.patapon {
import flash.events.*;
import com.kerb.game.*;
import com.kerb.sound.*;
import flash.media.*;
import com.kerb.ui.*;
import mx.core.*;
import com.kerb.patapon.game.*;
import com.kerb.tracking.*;
import flash.external.*;
public class Main extends AbstractMain {
public var text_fr_BE:Class;
public var text_fr_FR:Class;
public var text_en_NZ:Class;
public var text_sv_SE:Class;
public var text_de_AT:Class;
public var levelsCompleted:Array;
public var text_pt_PT:Class;
public var text_en_GB:Class;
public var maxScores:Array;
public var text_fr_CH:Class;
private var SWFBytes:Class;
public var text_fi_FI:Class;
public var numUnlockedItems:Array;
private var levelScoreScalars:Array;
public var text_it_IT:Class;
public var numLevelItems:Array;
public var currLevelNum:int;
public var levelScores:Array;
public var text_fr_LU:Class;
public var text_es_ES:Class;
public var text_de_CH:Class;
public var text_nl_BE:Class;
public var text_nl_NL:Class;
private var soundControl:Toggle;
public var sm:SoundManager;
public var text_en_IE:Class;
public var gameWithAudio:Boolean;
public var text_it_CH:Class;
public var text_no_NO:Class;
public var levels:Array;
public var text_de_DE:Class;
public var text_de_LU:Class;
public var text_en_AU:Class;
public var text_da_DK:Class;
public var text_longest:Class;
public static const HIGH_SCORE_URL:String = "savewallpaper.php";
public static const VIRAL:Boolean = true;
public static const WALLPAPER_CREATOR_URL:String = "wallpaper.php";
public static var assetFactory:AssetFactory;
public static var scoreSubmitted:Boolean = false;
public static var basePath:String = "http://patapon-game.com/";
public static var locale:String = "en_GB";
public static var buttonSound:Sound;
public function Main(_arg1:Class){
text_da_DK = Main_text_da_DK;
text_de_AT = Main_text_de_AT;
text_de_CH = Main_text_de_CH;
text_de_DE = Main_text_de_DE;
text_de_LU = Main_text_de_LU;
text_en_AU = Main_text_en_AU;
text_en_GB = Main_text_en_GB;
text_en_IE = Main_text_en_IE;
text_en_NZ = Main_text_en_NZ;
text_es_ES = Main_text_es_ES;
text_fi_FI = Main_text_fi_FI;
text_fr_BE = Main_text_fr_BE;
text_fr_CH = Main_text_fr_CH;
text_fr_FR = Main_text_fr_FR;
text_fr_LU = Main_text_fr_LU;
text_it_CH = Main_text_it_CH;
text_it_IT = Main_text_it_IT;
text_longest = Main_text_longest;
text_nl_BE = Main_text_nl_BE;
text_nl_NL = Main_text_nl_NL;
text_no_NO = Main_text_no_NO;
text_pt_PT = Main_text_pt_PT;
text_sv_SE = Main_text_sv_SE;
super();
this.SWFBytes = _arg1;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
override protected function gotoSection(_arg1:Class):void{
disposeCurrentSection();
currentSection = new (_arg1);
currentSection.setPreviousSection(PreviousSectionClass);
(currentSection as AbstractSection).setMain(this);
currentSection.addEventListener(Event.COMPLETE, onSectionComplete);
contentSprite.addChild(currentSection);
PreviousSectionClass = _arg1;
}
private function init():void{
levels = [Level1, Level2, Level3];
numLevelItems = [32, 40, 32];
maxScores = [2030, 2200, 2200];
levelScoreScalars = [0.14, 0.09, 0.11];
if (Preload.basePath != ""){
basePath = Preload.basePath;
};
if (Preload.locale != ""){
locale = Preload.locale;
};
reset();
initText();
initSounds();
}
protected function onAssetFactoryReady(_arg1:Event):void{
assetFactory.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
init();
start();
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
if (VIRAL){
DoubleQuick.init(root, 51);
DoubleQuick.event(250);
} else {
DoubleQuick.init(root, 46);
DoubleQuick.event(311);
webtrends("gameloaded");
};
assetFactory = new AssetFactory();
assetFactory.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
assetFactory.initialize(SWFBytes);
}
public function setCurrLevelScore(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:int;
if (_arg1 > levelScores[currLevelNum]){
levelScores[currLevelNum] = _arg1;
_local2 = 0;
_local3 = levelScoreScalars[currLevelNum];
_local4 = 2;
while (_local2 <= _arg1) {
_local2 = (_local2 + (_local3 * (maxScores[currLevelNum] - _local2)));
_local4++;
if (_local4 == numLevelItems[currLevelNum]){
break;
};
};
numUnlockedItems[currLevelNum] = _local4;
};
levelsCompleted[currLevelNum] = true;
}
public function reset():void{
levelScores = new Array();
levelsCompleted = new Array();
numUnlockedItems = new Array();
currLevelNum = 0;
var _local1:int;
while (_local1 < levels.length) {
levelScores[_local1] = 0;
numUnlockedItems[_local1] = 1;
levelsCompleted[_local1] = false;
_local1++;
};
}
public function get allLevelsComplete():Boolean{
var _local1:int;
while (_local1 < levelsCompleted.length) {
if (!levelsCompleted[_local1]){
return (false);
};
_local1++;
};
return (true);
}
override protected function onIdentComplete(_arg1:Event):void{
soundControl.visible = true;
super.onIdentComplete(_arg1);
}
private function initText():void{
var _local4:XML;
var _local1:String = locale;
var _local2:Class = this[("text_" + _local1)];
var _local3:ByteArrayAsset = ByteArrayAsset(new (_local2));
var _local5:String = _local3.readUTFBytes(3);
if (_local5.length == 1){
_local4 = new XML(_local3.readUTFBytes((_local3.length - 3)));
} else {
_local4 = new XML((_local5 + _local3.readUTFBytes((_local3.length - 3))));
};
TextManager.getInstance().init(_local4);
}
private function start():void{
gotoSection(Title);
}
private function onSoundToggle(_arg1:Event):void{
var _local2:SoundTransform = new SoundTransform();
_local2.volume = (soundControl.isOn) ? 1 : 0;
SoundMixer.soundTransform = _local2;
}
private function initSounds():void{
sm = new SoundManager();
soundControl = (assetFactory.createDisplayObject("SoundToggleAsset") as Toggle);
soundControl.addEventListener(Event.CHANGE, onSoundToggle);
soundControl.isOn = true;
soundControl.x = 30;
soundControl.y = 35;
overlaySprite.addChild(soundControl);
buttonSound = assetFactory.createSound("ButtonSound");
}
public static function webtrends(_arg1:String):void{
if (!VIRAL){
if (ExternalInterface.available){
trace(("Webtrends tracking event " + _arg1));
ExternalInterface.call("dcsMultiTrack", "DCS.dcsuri", ("/flashtrack/patapongame/" + _arg1), "DCSext.locale", locale, "WT.ti", _arg1);
};
};
}
}
}//package com.kerb.patapon
Section 37
//Main_text_da_DK (com.kerb.patapon.Main_text_da_DK)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_da_DK extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 38
//Main_text_de_AT (com.kerb.patapon.Main_text_de_AT)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_de_AT extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 39
//Main_text_de_CH (com.kerb.patapon.Main_text_de_CH)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_de_CH extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 40
//Main_text_de_DE (com.kerb.patapon.Main_text_de_DE)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_de_DE extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 41
//Main_text_de_LU (com.kerb.patapon.Main_text_de_LU)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_de_LU extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 42
//Main_text_en_AU (com.kerb.patapon.Main_text_en_AU)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_en_AU extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 43
//Main_text_en_GB (com.kerb.patapon.Main_text_en_GB)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_en_GB extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 44
//Main_text_en_IE (com.kerb.patapon.Main_text_en_IE)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_en_IE extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 45
//Main_text_en_NZ (com.kerb.patapon.Main_text_en_NZ)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_en_NZ extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 46
//Main_text_es_ES (com.kerb.patapon.Main_text_es_ES)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_es_ES extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 47
//Main_text_fi_FI (com.kerb.patapon.Main_text_fi_FI)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_fi_FI extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 48
//Main_text_fr_BE (com.kerb.patapon.Main_text_fr_BE)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_fr_BE extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 49
//Main_text_fr_CH (com.kerb.patapon.Main_text_fr_CH)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_fr_CH extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 50
//Main_text_fr_FR (com.kerb.patapon.Main_text_fr_FR)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_fr_FR extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 51
//Main_text_fr_LU (com.kerb.patapon.Main_text_fr_LU)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_fr_LU extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 52
//Main_text_it_CH (com.kerb.patapon.Main_text_it_CH)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_it_CH extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 53
//Main_text_it_IT (com.kerb.patapon.Main_text_it_IT)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_it_IT extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 54
//Main_text_longest (com.kerb.patapon.Main_text_longest)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_longest extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 55
//Main_text_nl_BE (com.kerb.patapon.Main_text_nl_BE)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_nl_BE extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 56
//Main_text_nl_NL (com.kerb.patapon.Main_text_nl_NL)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_nl_NL extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 57
//Main_text_no_NO (com.kerb.patapon.Main_text_no_NO)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_no_NO extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 58
//Main_text_pt_PT (com.kerb.patapon.Main_text_pt_PT)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_pt_PT extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 59
//Main_text_sv_SE (com.kerb.patapon.Main_text_sv_SE)
package com.kerb.patapon {
import mx.core.*;
public class Main_text_sv_SE extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 60
//Preload (com.kerb.patapon.Preload)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import com.kerb.game.*;
import flash.utils.*;
public class Preload extends AbstractPreload {
private var af:AssetFactory;
private var mc:MovieClip;
private var SWFBytes:Class;
public static var locale:String = "";
public static var basePath:String = "";
public function Preload(){
SWFBytes = Preload_SWFBytes;
super();
stop();
var _local1 = 550;
var _local2 = 400;
var _local3:Sprite = new Sprite();
var _local4:Graphics = _local3.graphics;
_local4.beginFill(0);
_local4.drawRect(-1000, -1000, (2000 + _local1), 1000);
_local4.drawRect(-1000, _local2, (2000 + _local1), 1000);
_local4.drawRect(-1000, -1000, 1000, (1000 + _local2));
_local4.drawRect(_local1, -1000, 1000, (1000 + _local2));
_local4.endFill();
addChild(_local3);
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
private function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
mc = (af.createDisplayObject("PreloadAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
addChildAt(mc, 0);
af = null;
if (root.loaderInfo.parameters.locale){
locale = root.loaderInfo.parameters.locale;
};
if (root.loaderInfo.parameters.basePath){
basePath = root.loaderInfo.parameters.basePath;
};
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:int = root.loaderInfo.bytesLoaded;
var _local3:int = root.loaderInfo.bytesTotal;
var _local4:int = Math.ceil(((100 * _local2) / _local3));
if (mc.currentFrame != _local4){
mc.gotoAndStop(_local4);
};
if (_local4 == 100){
preloadComplete();
};
}
private function preloadComplete():void{
var _local1:Class;
if (currentFrame == 1){
nextFrame();
} else {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
_local1 = Class(getDefinitionByName("Patapon"));
addChild((new (_local1) as DisplayObject));
removeChild(mc);
mc = null;
};
}
}
}//package com.kerb.patapon
Section 61
//Preload_SWFBytes (com.kerb.patapon.Preload_SWFBytes)
package com.kerb.patapon {
import mx.core.*;
public class Preload_SWFBytes extends ByteArrayAsset {
}
}//package com.kerb.patapon
Section 62
//SubmitHighScore (com.kerb.patapon.SubmitHighScore)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.ui.*;
public class SubmitHighScore extends AbstractSection {
private var submitButton:SuperButton;
private var mc:MovieClip;
private var saveWallpaperLoader:URLLoader;
private var backButton:SuperButton;
public function SubmitHighScore(){
mc = (Main.assetFactory.createDisplayObject("SubmitScoreSectionAsset") as MovieClip);
addChild(mc);
}
private function onBackClick(_arg1:MouseEvent=null):void{
Main.buttonSound.play();
NextSectionClass = PreviousSectionClass;
gotoNextSection();
}
private function wallpaperSaved(_arg1:Event):void{
var _local2:String;
saveWallpaperLoader.removeEventListener(Event.COMPLETE, wallpaperSaved);
saveWallpaperLoader.removeEventListener(IOErrorEvent.IO_ERROR, wallpaperError);
if (saveWallpaperLoader.data.id){
_local2 = (Main.VIRAL) ? "_blank" : "_self";
navigateToURL(new URLRequest(((Main.basePath + "highscore.php?code=") + saveWallpaperLoader.data.id)), _local2);
} else {
if (saveWallpaperLoader.data.error){
if (saveWallpaperLoader.data.error == "name"){
mc.response_txt.text = TextManager.getInstance().getTextById("game.dataentry.empty");
} else {
if (saveWallpaperLoader.data.error == "profanity"){
mc.response_txt.text = TextManager.getInstance().getTextById("game.dataentry.swear");
} else {
mc.response_txt.text = "";
};
};
} else {
mc.response_txt.text = "";
};
submitButton.enabled = true;
};
}
override public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
if (submitButton){
submitButton.removeEventListener(MouseEvent.CLICK, onSubmitClick);
};
if (backButton){
backButton.removeEventListener(MouseEvent.CLICK, onBackClick);
};
}
private function submit(_arg1:String):void{
submitButton.enabled = false;
Main.scoreSubmitted = true;
var _local2:Main = (main as Main);
var _local3:int;
var _local4:int;
while (_local4 < _local2.levelScores.length) {
_local3 = (_local3 + _local2.levelScores[_local4]);
_local4++;
};
var _local5:URLVariables = new URLVariables();
_local5.score = _local3;
_local5.data = "";
_local5.name = _arg1;
var _local6:URLRequest = new URLRequest((Main.basePath + Main.HIGH_SCORE_URL));
_local6.method = URLRequestMethod.POST;
_local6.data = _local5;
saveWallpaperLoader = new URLLoader();
saveWallpaperLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
saveWallpaperLoader.addEventListener(Event.COMPLETE, wallpaperSaved);
saveWallpaperLoader.addEventListener(IOErrorEvent.IO_ERROR, wallpaperError);
saveWallpaperLoader.load(_local6);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
if (stage.focus == mc.back_btn){
onBackClick();
} else {
onSubmitClick();
};
};
}
private function wallpaperError(_arg1:IOErrorEvent=null):void{
saveWallpaperLoader.removeEventListener(Event.COMPLETE, wallpaperSaved);
saveWallpaperLoader.removeEventListener(IOErrorEvent.IO_ERROR, wallpaperError);
submitButton.enabled = true;
mc.response_txt.text = "";
}
private function onSubmitClick(_arg1:MouseEvent=null):void{
Main.buttonSound.play();
checkUserInput();
}
override protected function init():void{
mc.progress.gotoAndStop("Complete");
backButton = new SuperButton(mc.back_btn, "game.button.back");
backButton.addEventListener(MouseEvent.CLICK, onBackClick);
mc.back_btn.tabIndex = 2;
submitButton = new SuperButton(mc.submit_btn, "game.button.submit");
submitButton.addEventListener(MouseEvent.CLICK, onSubmitClick);
mc.submit_btn.x = ((550 - mc.back_btn.x) - mc.submit_btn.width);
mc.submit_btn.tabIndex = 1;
if (((Main.scoreSubmitted) && (Main.VIRAL))){
mc.submit_btn.mouseEnabled = false;
};
mc.subHead_txt.text = TextManager.getInstance().getTextById("game.submitscore.copy");
mc.logo.strapline.label_txt.text = "";
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = mc.userInput_txt;
}
private function checkUserInput():void{
var _local1:String = mc.userInput_txt.text;
if (_local1 == ""){
mc.response_txt.text = TextManager.getInstance().getTextById("game.dataentry.empty");
} else {
mc.response_txt.text = "";
mc.submit_btn.enabled = false;
submit(_local1);
};
}
}
}//package com.kerb.patapon
Section 63
//SuperButton (com.kerb.patapon.SuperButton)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class SuperButton extends EventDispatcher {
private var mc:MovieClip;
private static const STATE_DOWN:int = 2;
private static const PADDING:Number = 5;
private static const MIN_WIDTH:Number = 110;
private static const STATE_UP:int = 0;
private static const STATE_OVER:int = 1;
public function SuperButton(_arg1:MovieClip, _arg2:String){
this.mc = _arg1;
init(_arg2);
}
private function init(_arg1:String):void{
var _local2:String = TextManager.getInstance().getTextById(_arg1);
mc.upLabel_txt.autoSize = TextFieldAutoSize.LEFT;
mc.overLabel_txt.autoSize = TextFieldAutoSize.LEFT;
mc.downLabel_txt.autoSize = TextFieldAutoSize.LEFT;
mc.upLabel_txt.text = _local2;
mc.overLabel_txt.text = _local2;
mc.downLabel_txt.text = _local2;
var _local3:Number = ((2 * PADDING) + mc.upLabel_txt.width);
if (_local3 < MIN_WIDTH){
_local3 = MIN_WIDTH;
};
var _local4:Number = (0.5 * (_local3 - mc.upLabel_txt.width));
mc.upLabel_txt.x = _local4;
mc.overLabel_txt.x = _local4;
mc.downLabel_txt.x = _local4;
mc.upBG.width = _local3;
mc.overBG.width = _local3;
mc.downBG.width = _local3;
mc.upBG.x = 0;
mc.overBG.x = 0;
mc.downBG.x = 0;
mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, true);
mc.addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, true);
mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
mc.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
mc.mouseChildren = false;
mc.buttonMode = true;
update(STATE_UP);
}
public function get enabled():Boolean{
return (mc.enabled);
}
public function set enabled(_arg1:Boolean):void{
mc.enabled = _arg1;
mc.mouseEnabled = _arg1;
}
private function onRollOver(_arg1:MouseEvent):void{
update(STATE_OVER);
dispatchEvent(_arg1);
}
private function onMouseDown(_arg1:MouseEvent):void{
update(STATE_DOWN);
dispatchEvent(_arg1);
}
private function onRollOut(_arg1:MouseEvent):void{
update(STATE_UP);
dispatchEvent(_arg1);
}
private function onClick(_arg1:MouseEvent):void{
update(STATE_OVER);
dispatchEvent(_arg1);
}
private function update(_arg1:int):void{
mc.upLabel_txt.visible = (_arg1 == STATE_UP);
mc.overLabel_txt.visible = (_arg1 == STATE_OVER);
mc.downLabel_txt.visible = (_arg1 == STATE_DOWN);
mc.upBG.visible = (_arg1 == STATE_UP);
mc.overBG.visible = (_arg1 == STATE_OVER);
mc.downBG.visible = (_arg1 == STATE_DOWN);
if (_arg1 == STATE_OVER){
mc.overBG.gotoAndPlay(1);
};
}
}
}//package com.kerb.patapon
Section 64
//TextManager (com.kerb.patapon.TextManager)
package com.kerb.patapon {
public class TextManager {
private var _xmlData:XML;
private static var instance:TextManager;
public function init(_arg1:XML):void{
this._xmlData = _arg1;
}
public function getTextById(_arg1:String):String{
var result:String;
var id = _arg1;
if (_xmlData){
result = _xmlData.text.(@id == id);
if (result){
return (result);
};
return ((("[text key missing : " + id) + "]"));
//unresolved jump
};
return (id);
}
public static function getInstance():TextManager{
if (instance == null){
instance = new (TextManager);
};
return (instance);
}
}
}//package com.kerb.patapon
Section 65
//Title (com.kerb.patapon.Title)
package com.kerb.patapon {
import flash.events.*;
import flash.display.*;
import com.kerb.patapon.game.characters.*;
import flash.media.*;
import com.kerb.patapon.game.*;
import flash.utils.*;
import com.kerb.tracking.*;
import flash.ui.*;
public class Title extends AbstractSection {
private var speechBubbles:Array;
private var mc:MovieClip;
private var speechBubbleTimer:Timer;
private var speechBubbleTimerCount:int;
private var speechBubbleCharacter:AbstractCharacter;
private var speechBubblePositions:Array;
private static const SPEECH_BUBBLE_DISPLAY_TIME:int = 2600;
private static const NUM_SPEECH_BUBBLES:int = 8;
private static const SPEECH_BUBBLE_TIMER_INTERVAL:int = 2600;
public function Title(){
if (Main.VIRAL){
mc = (Main.assetFactory.createDisplayObject("TitleSectionLegalAsset") as MovieClip);
} else {
mc = (Main.assetFactory.createDisplayObject("TitleSectionAsset") as MovieClip);
};
mc.x = 275;
mc.y = 200;
addChild(mc);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
gotoNextSection();
};
}
private function updateDynamicText(_arg1:Event=null):void{
if (Main.VIRAL){
if (mc.animation_mc.logo){
if (!mc.animation_mc.logo.throb.hasEventListener(MouseEvent.CLICK)){
mc.animation_mc.logo.throb.addEventListener(MouseEvent.CLICK, onClickPlaystationLink);
mc.animation_mc.logo.throb.buttonMode = true;
mc.animation_mc.logo.throb.mouseChildren = false;
};
};
if (mc.outNow_btn){
if (!mc.outNow_btn.hasEventListener(MouseEvent.CLICK)){
mc.outNow_btn.addEventListener(MouseEvent.CLICK, onClickPlaystationLink);
};
};
if (mc.animation_mc.legal){
if (!mc.animation_mc.legal.eu_btn.hasEventListener(MouseEvent.CLICK)){
mc.animation_mc.legal.eu_btn.addEventListener(MouseEvent.CLICK, onClickEUPlaystationLink);
};
};
};
if (mc.animation_mc.start_btn.label_txt){
mc.animation_mc.start_btn.label_txt.htmlText = (("<b>" + TextManager.getInstance().getTextById("game.title.start")) + "</b>");
};
if (mc.animation_mc.logo){
if (mc.animation_mc.logo.title.label_txt){
mc.animation_mc.logo.title.label_txt.htmlText = (("<b>" + TextManager.getInstance().getTextById("game.strap.art")) + "</b>");
};
if (mc.animation_mc.logo.strapline.label_txt){
mc.animation_mc.logo.strapline.label_txt.htmlText = (("<b>" + TextManager.getInstance().getTextById("game.header.official")) + "</b>");
};
};
}
override public function dispose():void{
mc.animation_mc.start_btn.removeEventListener(MouseEvent.CLICK, onStartClick);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
mc.removeEventListener(Event.ENTER_FRAME, updateDynamicText);
mc.animation_mc.start_btn.removeEventListener(MouseEvent.ROLL_OVER, updateDynamicText);
mc.animation_mc.start_btn.removeEventListener(MouseEvent.ROLL_OUT, updateDynamicText);
speechBubbleTimer.removeEventListener(TimerEvent.TIMER, onSpeechBubbleTimer);
}
private function onSpeechBubbleTimer(_arg1:TimerEvent):void{
var _local4:int;
var _local5:int;
var _local6:int;
speechBubbleTimerCount = (speechBubbleTimerCount % NUM_SPEECH_BUBBLES);
if (speechBubbleTimerCount == 0){
_local4 = 0;
while (_local4 < speechBubblePositions.length) {
_local5 = (Math.random() * speechBubblePositions.length);
_local6 = speechBubblePositions[_local4];
speechBubblePositions[_local4] = speechBubblePositions[_local5];
speechBubblePositions[_local5] = _local6;
_local4++;
};
};
var _local2:SpeechBubble = speechBubbles[speechBubbleTimerCount];
_local2.mc.x = speechBubblePositions[speechBubbleTimerCount];
speechBubbleTimerCount++;
var _local3:String = TextManager.getInstance().getTextById(("game.home.bubble" + speechBubbleTimerCount));
_local2.setText(_local3, speechBubbleCharacter, false, SPEECH_BUBBLE_DISPLAY_TIME);
}
override protected function init():void{
var _local2:SpeechBubble;
NextSectionClass = Instructions;
mc.animation_mc.start_btn.addEventListener(MouseEvent.CLICK, onStartClick);
mc.animation_mc.start_btn.addEventListener(MouseEvent.ROLL_OVER, updateDynamicText);
mc.animation_mc.start_btn.addEventListener(MouseEvent.ROLL_OUT, updateDynamicText);
mc.addEventListener(Event.ENTER_FRAME, updateDynamicText);
mc.animation_mc.start_btn.buttonMode = true;
mc.animation_mc.start_btn.mouseChildren = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
var _local1:Sound = Main.assetFactory.createSound("TitleMusicSound");
_local1.play(0, 99999);
(main as Main).reset();
speechBubbles = new Array();
var _local3:int;
while (_local3 < NUM_SPEECH_BUBBLES) {
_local2 = new SpeechBubble();
_local2.verticalDeviation = 10;
mc.animation_mc.addChild(_local2.mc);
speechBubbles.push(_local2);
_local3++;
};
speechBubblePositions = [-215, -207, -161, -105, 89, 131, 185, 226];
speechBubbleCharacter = new Hatapon(0, 0);
speechBubbleCharacter.mc.y = (Main.VIRAL) ? 0xFF : 300;
speechBubbleTimer = new Timer(SPEECH_BUBBLE_TIMER_INTERVAL);
speechBubbleTimer.addEventListener(TimerEvent.TIMER, onSpeechBubbleTimer);
speechBubbleTimerCount = 0;
speechBubbleTimer.start();
if (!Main.VIRAL){
mc.sticker.gotoAndStop(Main.locale);
};
}
private function onClickPlaystationLink(_arg1:MouseEvent):void{
DoubleQuick.click(326);
}
private function onStartClick(_arg1:MouseEvent):void{
Main.buttonSound.play();
updateDynamicText();
gotoNextSection();
}
private function onClickEUPlaystationLink(_arg1:MouseEvent):void{
DoubleQuick.click(325);
}
}
}//package com.kerb.patapon
Section 66
//ExtendedSound (com.kerb.sound.ExtendedSound)
package com.kerb.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var fadeEndVolume:Number;
protected var panStartPosition:Number;
protected var panDuration:Number;
protected var panEndPosition:Number;
protected var masterVolume:Number;// = 1
protected var fadeTimer:Timer;
protected var panTimer:Timer;
protected var fadeDuration:Number;
protected var panStartTime:Number;
protected var fadeStartTime:Number;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
soundChannel = super.play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
};
}
public function fadeOut(_arg1:Number=0):void{
if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function fadeTo(_arg1:Number, _arg2:Number):void{
if (((soundChannel) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg2;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = _arg1;
startFade();
};
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local2, _arg1);
stopPan();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
stopFade();
};
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local4, _local2);
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
_arg3.volume = (_arg3.volume * masterVolume);
} else {
_arg3 = new SoundTransform(masterVolume);
};
soundChannel = super.play(_arg1, _arg2, _arg3);
return (soundChannel);
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_local2 * masterVolume), _local4);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
}
}//package com.kerb.sound
Section 67
//SoundManager (com.kerb.sound.SoundManager)
package com.kerb.sound {
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var masterVolume:Number;// = 1
public function SoundManager(){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound):void{
var _local2:String = _arg1.toString();
if (sounds[_local2] != null){
throw (new Error((("Class name conflict: A sound with the class name [" + _local2) + "] already exists in SoundManager.")));
};
sounds[_local2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function unmute():void{
if (muteState){
muteState = false;
setMasterVolume(prevMasterVolume);
};
}
public function mute():void{
if (!muteState){
muteState = true;
setMasterVolume(0);
};
}
public function getSoundByClassName(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + "SoundManager\n");
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
}
}//package com.kerb.sound
Section 68
//DoubleQuick (com.kerb.tracking.DoubleQuick)
package com.kerb.tracking {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_NAME:String = "doublequick";
private static const TICKER_PERIOD:Number = 30000;
private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm";
private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm";
private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static var tickerURL:URLRequest = null;
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
private static var dq:DoubleQuick;
public function startTimer():void{
var _local1:Timer = new Timer(TICKER_PERIOD, 0);
_local1.start();
_local1.addEventListener(TimerEvent.TIMER, pingProxy);
}
public function pingProxy(_arg1:TimerEvent):void{
DoubleQuick.ping();
}
private static function dummyListener(_arg1:Event):void{
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
trace(("Queueing event " + watchId));
queue.push(watchId);
} else {
trace(("Tracking event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
public static function click(_arg1:Number):void{
trace(("Tracking clickThrough " + _arg1));
navigateToURL(generateURL(_arg1));
}
private static function onInit(_arg1:Event):void{
var _local4:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
trace(("acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4);
};
DoubleQuick.initialisationFinished();
}
public static function init(_arg1:DisplayObject, _arg2:Number):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
projectId = _projectId;
baseurl = root.loaderInfo.url;
trace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
trace("requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit);
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
} else {
DoubleQuick.initialisationFinished();
};
}
public static function initialisationFinished():void{
trace("Tracking initialised");
initialised = true;
var _local1:int;
while (_local1 < queue.length) {
event(queue[_local1]);
_local1++;
};
queue = new Array();
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]));
tickerURL.method = URLRequestMethod.GET;
dq = new (DoubleQuick);
dq.startTimer();
}
public static function ping():void{
var loader:URLLoader;
if (tickerURL != null){
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
trace("Tracking ticker");
try {
loader.load(tickerURL);
} catch(error:Error) {
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
}
}//package com.kerb.tracking
Section 69
//Toggle (com.kerb.ui.Toggle)
package com.kerb.ui {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.kerb.utils.*;
public class Toggle extends MovieClip implements IDisposable {
protected var _isOn:Boolean;
protected var _state:int;
protected var _label:String;
public static const STATE_DOWN:int = 2;
public static const STATE_UP:int = 0;
public static const STATE_OVER:int = 1;
protected static var stateLabels:Array = ["upOff", "overOff", "downOff", "upOn", "overOn", "downOn"];
public function Toggle(){
_state = STATE_UP;
_label = "";
isOn = false;
buttonMode = true;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onMouseDown(_arg1:MouseEvent):void{
_state = STATE_DOWN;
update();
}
protected function onMouseUp(_arg1:MouseEvent):void{
_state = STATE_OVER;
isOn = !(_isOn);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
public function get isOn():Boolean{
return (_isOn);
}
protected function onRollOut(_arg1:MouseEvent):void{
_state = STATE_UP;
update();
}
public function set label(_arg1:String):void{
this._label = _arg1;
updateLabel();
}
public function get state():int{
return (_state);
}
public function get label():String{
return (_label);
}
protected function init():void{
var _local2:int;
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
_local2 = 0;
while (_local2 < totalFrames) {
addFrameScript(_local2, updateLabel);
_local2++;
};
break;
};
_local1++;
};
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
protected function update():void{
gotoAndStop(stateLabels[((_isOn) ? 3 : 0 + state)]);
}
public function set isOn(_arg1:Boolean):void{
this._isOn = _arg1;
update();
dispatchEvent(new Event(Event.CHANGE));
}
protected function updateLabel():void{
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
(getChildAt(_local1) as TextField).text = _label;
break;
};
_local1++;
};
}
protected function onRollOver(_arg1:MouseEvent):void{
_state = STATE_OVER;
update();
}
public function dispose():void{
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
}
}//package com.kerb.ui
Section 70
//IDisposable (com.kerb.utils.IDisposable)
package com.kerb.utils {
public interface IDisposable {
function dispose():void;
}
}//package com.kerb.utils
Section 71
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 72
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 73
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 74
//Patapon (Patapon)
package {
import flash.display.*;
import com.kerb.patapon.*;
public class Patapon extends Sprite {
private var SWFBytes:Class;
public function Patapon(){
SWFBytes = Patapon_SWFBytes;
super();
var _local1 = 550;
var _local2 = 400;
var _local3:Sprite = new Sprite();
var _local4:Graphics = _local3.graphics;
_local4.beginFill(0);
_local4.drawRect(-1000, -1000, (2000 + _local1), 1000);
_local4.drawRect(-1000, _local2, (2000 + _local1), 1000);
_local4.drawRect(-1000, -1000, 1000, (1000 + _local2));
_local4.drawRect(_local1, -1000, 1000, (1000 + _local2));
_local4.endFill();
addChild(_local3);
addChildAt(new Main(SWFBytes), 0);
}
}
}//package
Section 75
//Patapon_SWFBytes (Patapon_SWFBytes)
package {
import mx.core.*;
public class Patapon_SWFBytes extends ByteArrayAsset {
}
}//package