Section 1
//bar_root_55 (battalion_asset_library_fla.bar_root_55)
package battalion_asset_library_fla {
import flash.display.*;
public dynamic class bar_root_55 extends MovieClip {
public var barmask:MovieClip;
}
}//package battalion_asset_library_fla
Section 2
//BG_39 (battalion_asset_library_fla.BG_39)
package battalion_asset_library_fla {
import flash.display.*;
public dynamic class BG_39 extends MovieClip {
public function BG_39(){
addFrameScript(10, frame11);
}
function frame11(){
MovieClip(parent).gotoAndStop(2);
}
}
}//package battalion_asset_library_fla
Section 3
//LOGOEND_80 (battalion_asset_library_fla.LOGOEND_80)
package battalion_asset_library_fla {
import flash.display.*;
public dynamic class LOGOEND_80 extends MovieClip {
public function LOGOEND_80(){
addFrameScript(132, frame133);
}
function frame133(){
stop();
}
}
}//package battalion_asset_library_fla
Section 4
//LOGOPRELOAD_0_60 (battalion_asset_library_fla.LOGOPRELOAD_0_60)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_0_60 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_0_60(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 5
//LOGOPRELOAD_1_64 (battalion_asset_library_fla.LOGOPRELOAD_1_64)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_1_64 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_1_64(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 6
//LOGOPRELOAD_2_67 (battalion_asset_library_fla.LOGOPRELOAD_2_67)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_2_67 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_2_67(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 7
//LOGOPRELOAD_3_69 (battalion_asset_library_fla.LOGOPRELOAD_3_69)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_3_69 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_3_69(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 8
//LOGOPRELOAD_4_71 (battalion_asset_library_fla.LOGOPRELOAD_4_71)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_4_71 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_4_71(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 9
//LOGOPRELOAD_5_73 (battalion_asset_library_fla.LOGOPRELOAD_5_73)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_5_73 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_5_73(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 10
//LOGOPRELOAD_6_75 (battalion_asset_library_fla.LOGOPRELOAD_6_75)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_6_75 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_6_75(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 11
//LOGOPRELOAD_7_77 (battalion_asset_library_fla.LOGOPRELOAD_7_77)
package battalion_asset_library_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class LOGOPRELOAD_7_77 extends MovieClip {
public var thenextframe;
public function LOGOPRELOAD_7_77(){
addFrameScript(0, frame1, 89, frame90);
}
function frame90(){
if (MovieClip(parent).isloaded){
MovieClip(parent).gotoAndStop(10);
} else {
thenextframe = (Math.ceil((Math.random() * 8)) + 1);
if (thenextframe == MovieClip(parent).currentFrame){
MovieClip(parent).nextFrame();
} else {
MovieClip(parent).gotoAndStop(thenextframe);
};
};
}
function frame1(){
if (Math.random() > 0.5){
scaleX = -(scaleX);
x = (x - MovieClip(parent).shiftamt);
};
}
}
}//package battalion_asset_library_fla
Section 12
//AssetLibrary (com.gamedozer.battalion.assets.AssetLibrary)
package com.gamedozer.battalion.assets {
import flash.display.*;
import flash.media.*;
import flash.utils.*;
public class AssetLibrary {
public function AssetLibrary(){
super();
}
public static function createSound(a_name:String):Sound{
var SoundClass:Object = getDefinitionByName(a_name);
var sound:Sound = (new (SoundClass) as Sound);
return (sound);
}
public static function createBitmapData(a_name:String):BitmapData{
var BitmapDataClass:Object = getDefinitionByName(a_name);
var bitmapData:BitmapData = (new BitmapDataClass(0, 0) as BitmapData);
return (bitmapData);
}
}
}//package com.gamedozer.battalion.assets
Section 13
//AudioProfile (com.gamedozer.battalion.audio.AudioProfile)
package com.gamedozer.battalion.audio {
import flash.media.*;
import flash.utils.*;
public class AudioProfile {
private var m_profile:Dictionary;
public static const k_attackType:String = "attack";
public static const k_moveType:String = "move";
static var s_multiton:Dictionary = null;
public function AudioProfile(){
super();
m_profile = new Dictionary();
}
function registerSound(a_soundType:String, a_linkage:String):void{
if (m_profile[a_soundType] == null){
m_profile[a_soundType] = new Array();
};
m_profile[a_soundType].push(a_linkage);
}
public function playSound(a_soundType:String):void{
var volume:Number;
var soundOptions:Array = m_profile[a_soundType];
var soundLinkage:String = soundOptions[Math.floor((Math.random() * soundOptions.length))];
if (soundLinkage != ""){
volume = 1;
SoundSystem.instance.playSound(SoundSystem.instance.createSound(soundLinkage), volume);
};
}
private static function initialize():void{
if (s_multiton != null){
return;
};
s_multiton = new Dictionary(true);
registerProfiles();
}
private static function createProfile(a_name:String):AudioProfile{
var profile:AudioProfile = new (AudioProfile);
s_multiton[a_name] = profile;
return (profile);
}
private static function registerProfiles():void{
var profile:AudioProfile = createProfile("Heavy Commando");
profile.registerSound(k_moveType, "CommandoMove1");
profile.registerSound(k_moveType, "CommandoMove2");
profile.registerSound(k_moveType, "CommandoMove3");
profile.registerSound(k_attackType, "FireHeavyCommando");
profile = createProfile("Strike Commando");
profile.registerSound(k_moveType, "CommandoMove1");
profile.registerSound(k_moveType, "CommandoMove2");
profile.registerSound(k_moveType, "CommandoMove3");
profile.registerSound(k_attackType, "FireStrikeCommando");
profile = createProfile("Flak Tank");
profile.registerSound(k_moveType, "TankMove1");
profile.registerSound(k_moveType, "TankMove2");
profile.registerSound(k_moveType, "TankMove3");
profile.registerSound(k_attackType, "FireFlakTank");
profile = createProfile("Scorpion Tank");
profile.registerSound(k_moveType, "TankMove1");
profile.registerSound(k_moveType, "TankMove2");
profile.registerSound(k_moveType, "TankMove3");
profile.registerSound(k_attackType, "FireScorpionTank");
profile = createProfile("Annihilator Tank");
profile.registerSound(k_moveType, "TankMove1");
profile.registerSound(k_moveType, "TankMove2");
profile.registerSound(k_moveType, "TankMove3");
profile.registerSound(k_attackType, "FireAnnihilatorTank");
profile = createProfile("Stealth Tank");
profile.registerSound(k_moveType, "TankMove1");
profile.registerSound(k_moveType, "TankMove2");
profile.registerSound(k_moveType, "TankMove3");
profile.registerSound(k_attackType, "FireStealthTank");
profile = createProfile("Mortar Truck");
profile.registerSound(k_moveType, "VehicleMove");
profile.registerSound(k_attackType, "FireMortarTruck");
profile = createProfile("Rocket Truck");
profile.registerSound(k_moveType, "VehicleMove");
profile.registerSound(k_attackType, "FireRocketTruck");
profile = createProfile("Turret");
profile.registerSound(k_moveType, "VehicleMove");
profile.registerSound(k_attackType, "FireTurret");
profile = createProfile("Raptor Fighter");
profile.registerSound(k_moveType, "AircraftMove");
profile.registerSound(k_attackType, "FireRaptorFighter");
profile = createProfile("Albatross Transport");
profile.registerSound(k_moveType, "BlimpMove");
profile.registerSound(k_attackType, "FireAlbatrossTransport");
profile = createProfile("Condor Bomber");
profile.registerSound(k_moveType, "BlimpMove");
profile.registerSound(k_attackType, "FireCondorBomber");
profile = createProfile("Leviathan Barge");
profile.registerSound(k_moveType, "ShipMove");
profile.registerSound(k_attackType, "FireLeviathanBarge");
profile = createProfile("Hunter Support");
profile.registerSound(k_moveType, "ShipMove");
profile.registerSound(k_attackType, "FireHunterSupport");
profile = createProfile("Corvette Fighter");
profile.registerSound(k_moveType, "ShipMove");
profile.registerSound(k_attackType, "FireCorvetteFighter");
profile = createProfile("Battlecruiser");
profile.registerSound(k_moveType, "ShipMove");
profile.registerSound(k_attackType, "FireBattlecruiser");
profile = createProfile("Intrepid");
profile.registerSound(k_moveType, "BoatMove");
profile.registerSound(k_attackType, "FireIntrepid");
profile = createProfile("U-Boat");
profile.registerSound(k_moveType, "SubmarineMove");
profile.registerSound(k_attackType, "FireUboat");
}
public static function getProfile(a_name:String):AudioProfile{
initialize();
return (s_multiton[a_name]);
}
}
}//package com.gamedozer.battalion.audio
Section 14
//SoundSystem (com.gamedozer.battalion.audio.SoundSystem)
package com.gamedozer.battalion.audio {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class SoundSystem {
private var m_loopMap:Dictionary;
private var m_isMuted:Boolean;
private var m_effectMasterVolumeModifier:Number;// = 0.75
private var m_loopMasterVolumeModifier:Number;// = 0.75
private var m_volume:Number;
private static var s_singleton:SoundSystem = null;
public function SoundSystem(){
super();
m_loopMap = new Dictionary();
m_isMuted = false;
m_volume = 1;
}
public function createLoop(a_id:String, a_sound:Sound, a_volume:Number=1, a_startImmediately:Boolean=true):Boolean{
if (m_loopMap[a_id] != null){
return (false);
};
var loop:BackgroundLoop = new BackgroundLoop();
loop.id = a_id;
loop.customVolume = a_volume;
var soundTransform:SoundTransform = new SoundTransform();
soundTransform.volume = (a_volume * m_loopMasterVolumeModifier);
loop.sound = a_sound;
m_loopMap[a_id] = loop;
if (a_startImmediately){
loop.loopChannel = a_sound.play(0, 999999999, soundTransform);
};
return (true);
}
private function updateMute():void{
if (m_isMuted){
changeVolume(0);
} else {
changeVolume(m_volume);
};
}
public function getMasterEffectVolume():Number{
return (m_effectMasterVolumeModifier);
}
public function playSound(a_sound:Sound, a_volume:Number=1, a_onCompleteCallback:Function=null):void{
var soundTransform:SoundTransform = new SoundTransform();
soundTransform.volume = (a_volume * m_effectMasterVolumeModifier);
var channel:SoundChannel = a_sound.play(0, 1, soundTransform);
if (a_onCompleteCallback != null){
channel.addEventListener(Event.SOUND_COMPLETE, a_onCompleteCallback);
};
}
public function toggleMute():void{
m_isMuted = !(m_isMuted);
updateMute();
}
public function stopLoop(a_id:String):Boolean{
var loop:BackgroundLoop = m_loopMap[a_id];
if (loop != null){
if (loop.loopChannel != null){
loop.loopChannel.stop();
loop.loopChannel = null;
};
return (true);
};
return (false);
}
public function getMasterLoopVolume():Number{
return (m_loopMasterVolumeModifier);
}
public function mute():void{
m_isMuted = true;
updateMute();
}
public function setMaxVolume(a_volume:Number):void{
m_volume = a_volume;
}
public function isMuted():Boolean{
return (m_isMuted);
}
public function setMasterLoopVolume(a_volume:Number):void{
var bgLoop:BackgroundLoop;
var channel:SoundChannel;
var newVolume:Number;
a_volume = (Math.floor((a_volume * 100)) / 100);
for each (bgLoop in m_loopMap) {
channel = bgLoop.loopChannel;
newVolume = (bgLoop.customVolume * a_volume);
if (newVolume > 1){
newVolume = 1;
};
if (newVolume < 0){
newVolume = 0;
};
if (channel != null){
channel.soundTransform = new SoundTransform(newVolume);
};
};
m_loopMasterVolumeModifier = a_volume;
}
public function isPlaying(a_id:String):Boolean{
var loop:BackgroundLoop = m_loopMap[a_id];
if (loop != null){
if (loop.loopChannel != null){
if (loop.loopChannel.position > 0){
return (true);
};
};
};
return (false);
}
public function startLoop(a_id:String, a_volume:Number=1):Boolean{
var soundTransform:SoundTransform;
var loop:BackgroundLoop = m_loopMap[a_id];
if (loop != null){
if (isPlaying(a_id)){
return (false);
};
soundTransform = new SoundTransform();
soundTransform.volume = (a_volume * m_loopMasterVolumeModifier);
loop.loopChannel = loop.sound.play(0, 999999999, soundTransform);
return (true);
};
return (false);
}
public function setMasterEffectVolume(a_volume:Number):void{
a_volume = (Math.floor((a_volume * 100)) / 100);
if (a_volume > 1){
a_volume = 1;
};
if (a_volume < 0){
a_volume = 0;
};
m_effectMasterVolumeModifier = a_volume;
}
public function changeVolume(a_volume:Number):void{
var soundTransform:SoundTransform = new SoundTransform();
soundTransform.volume = a_volume;
SoundMixer.soundTransform = soundTransform;
}
public function changeLoopVolume(a_id:String, a_volume:Number):Boolean{
var soundTransform:SoundTransform;
var loop:BackgroundLoop = m_loopMap[a_id];
if (loop == null){
return (false);
};
loop.customVolume = a_volume;
if (loop.loopChannel != null){
soundTransform = new SoundTransform((a_volume * m_loopMasterVolumeModifier));
loop.loopChannel.soundTransform = soundTransform;
};
return (true);
}
public function unmute():void{
m_isMuted = false;
updateMute();
}
public function createSound(a_className:String):Sound{
var SoundClass:Class = (getDefinitionByName(a_className) as Class);
return (new (SoundClass));
}
public function destroyLoop(a_id:String):Boolean{
var loop:BackgroundLoop = m_loopMap[a_id];
if (loop != null){
if (loop.loopChannel != null){
loop.loopChannel.stop();
loop.loopChannel = null;
};
loop.sound = null;
loop = null;
delete m_loopMap[a_id];
return (true);
};
return (false);
}
public static function get instance():SoundSystem{
if (s_singleton == null){
s_singleton = new (SoundSystem);
};
return (s_singleton);
}
}
}//package com.gamedozer.battalion.audio
import flash.media.*;
class BackgroundLoop {
public var customVolume:Number;
public var sound:Sound;
public var id:String;
public var loopChannel:SoundChannel;
private function BackgroundLoop(){
super();
}
}
Section 15
//Astar (com.gamedozer.battalion.data.Astar)
package com.gamedozer.battalion.data {
import flash.utils.*;
public class Astar {
protected static var open:Array;
protected static var iteration:int = -1;
public function Astar(){
super();
}
static function remove(a_node:Node):void{
var i:int = (open.length - 1);
while (i >= 0) {
if (open[i] == a_node){
open.splice(i, 1);
};
i--;
};
}
public static function path(a_start:Node, a_end:Node, a_unit:Unit=null, searchDepth:Number=0, a_flags:int=0):Array{
var path:Array;
var temp:Node;
if (a_start == a_end){
return ([a_start]);
};
if (search(a_start, a_end, a_unit, searchDepth, false, a_flags) == null){
return (null);
};
if (a_end.iteration == iteration){
path = new Array();
temp = a_end;
while (temp != a_start) {
path.unshift(temp);
temp = temp.previous;
};
path.unshift(temp);
return (path);
};
return (null);
}
public static function pathTrim(a_start:Node, a_end:Node, a_unit:Unit, a_flags:int=0):Array{
var nodes:Array = path(a_start, a_end, a_unit, Number.POSITIVE_INFINITY, a_flags);
if (nodes == null){
return (null);
};
var i:int = (nodes.length - 1);
while (i >= 0) {
if (nodes[i].g > a_unit.getRange()){
nodes.splice(i, 1);
};
i--;
};
return (nodes);
}
public static function search(a_start:Node, a_end:Node=null, a_unit:Unit=null, searchDepth:Number=0, a_additional:Boolean=false, a_flags:int=0):Array{
var current:Node;
var connections:Array;
var i:int;
var check:Node;
var h:Number;
var cost:Number;
var g:Number;
var startTime:int = getTimer();
iteration++;
if (a_unit != null){
if (a_end != null){
if (a_end.getCost(a_unit, a_flags, true) == Number.POSITIVE_INFINITY){
return (null);
};
};
if (a_start.getCost(a_unit, a_flags, false) == Number.POSITIVE_INFINITY){
return (null);
};
};
if (a_start == a_end){
return (null);
};
var nodes:Array = new Array();
open = new Array();
a_start.reset();
a_start.iteration = iteration;
addSorted(a_start);
nodes.push(a_start);
var range:Number = 0;
if (a_unit != null){
range = a_unit.getRange();
};
var found:Boolean;
while ((((open.length > 0)) && (!(found)))) {
current = open.shift();
current.state = Node.CLOSED;
connections = current.getConnections();
i = 0;
for (;i < connections.length;i++) {
check = connections[i];
if ((((check.iteration == iteration)) && ((check.state == Node.CLOSED)))){
} else {
h = check.getHeuristic(a_end);
cost = 1;
if (a_unit != null){
cost = check.getCost(a_unit, a_flags, false);
};
if ((((((cost == Number.POSITIVE_INFINITY)) && ((a_additional == false)))) && ((a_flags == 0)))){
} else {
if ((((check.iteration == iteration)) && ((check.state == Node.OPEN)))){
if (check.g > (current.g + cost)){
remove(check);
check.g = (current.g + cost);
check.f = (check.g + check.h);
check.previous = current;
addSorted(check);
};
} else {
g = (current.g + cost);
if ((((g > range)) && ((g > searchDepth)))){
if (a_additional){
if (current.g == Number.POSITIVE_INFINITY){
continue;
};
if (((((current.g + 1) > (range + 1))) && (((current.g + 1) > (searchDepth + 1))))){
continue;
};
//unresolved jump
};
if (a_flags != 0){
};
if ((((a_flags & Tile.k_astarFlagIgnoreLastNode)) && ((check == a_end)))){
cost = check.getCost(a_unit, a_flags, true);
g = (current.g + cost);
if ((((g > range)) && ((g > searchDepth)))){
continue;
};
//unresolved jump
};
} else {
check.reset(current, g, h, (g + h));
check.iteration = iteration;
addSorted(check);
nodes.push(check);
if (check == a_end){
found = true;
break;
};
};
};
};
};
};
};
return (nodes);
}
public static function range(a_start:Node, minRange:Number, maxRange:Number):Array{
var nodes:Array = search(a_start, null, null, maxRange);
var i:int = (nodes.length - 1);
while (i >= 0) {
if (nodes[i].g < minRange){
nodes.splice(i, 1);
};
i--;
};
return (nodes);
}
public static function calculatePositionsToTargetEndNode(a_start:Node, a_end:Node, a_unit:Unit, a_ignoreUnits:Boolean):Array{
var node:Node;
var flags:int;
var turns:int;
var nodesInRange:Array = range(a_end, a_unit.getWeaponRangeMin(), a_unit.getWeaponRangeMax());
var bestDestinationNode:Node;
var bestTurnCount:int = int.MAX_VALUE;
var n:int = (nodesInRange.length - 1);
while (n >= 0) {
node = nodesInRange[n];
flags = 0;
if (a_ignoreUnits){
flags = Tile.k_astarFlagIgnoreUnits;
};
turns = calculateTurnsToPath(a_start, node, a_unit, flags);
if (turns > 0){
if (turns < bestTurnCount){
bestDestinationNode = node;
bestTurnCount = turns;
};
} else {
nodesInRange.splice(n, 1);
};
n--;
};
return (nodesInRange);
}
public static function calculateTurnsToPath(a_start:Node, a_end:Node, a_unit:Unit, a_flags:int=0):int{
if (a_unit.getRange() == 0){
return (-1);
};
var nodes:Array = path(a_start, a_end, a_unit, Number.POSITIVE_INFINITY, a_flags);
if (nodes == null){
return (-1);
};
if ((a_flags & Tile.k_astarFlagIgnoreLastNode)){
if (nodes[(nodes.length - 1)].g == Number.POSITIVE_INFINITY){
nodes.splice((nodes.length - 1), 1);
if (nodes.length == 0){
return (1);
};
};
};
if (nodes[(nodes.length - 1)].g == Number.POSITIVE_INFINITY){
return (-1);
};
return (Math.ceil((nodes[(nodes.length - 1)].g / a_unit.getRange())));
}
static function addSorted(a_node:Node):void{
var i:int;
while (i < open.length) {
if (a_node.compare(open[i]) == 1){
open.splice(i, 0, a_node);
return;
};
i++;
};
open.push(a_node);
}
}
}//package com.gamedozer.battalion.data
Section 16
//BattalionSettings (com.gamedozer.battalion.data.BattalionSettings)
package com.gamedozer.battalion.data {
import com.gamedozer.utils.*;
public class BattalionSettings {
private static var m_singleton:Settings = null;
public function BattalionSettings(){
super();
}
public static function getSingleton():Settings{
return (m_singleton);
}
public static function createSingleton(a_xml:XML):void{
m_singleton = Settings.createSettingsFromXML(a_xml);
}
}
}//package com.gamedozer.battalion.data
Section 17
//CampaignManager (com.gamedozer.battalion.data.CampaignManager)
package com.gamedozer.battalion.data {
import flash.utils.*;
public class CampaignManager {
protected var completeName:String;
protected var levels:Array;
protected var victoryImage:String;
protected var levelName:String;
protected static var campaigns:Dictionary;
public function CampaignManager(a_campaign:String, a_xml:XML){
var level:Level;
super();
levels = new Array(a_xml.@levels);
victoryImage = a_xml.@victoryImage;
var levelList:XMLList = a_xml..level;
var i:int;
while (i < levelList.length()) {
level = new Level();
level.name = levelList[i].@name;
level.mapURL = levelList[i].map.@url;
level.mapName = levelList[i].map.@name;
level.teamName = levelList[i].team.@name;
level.teamIcon = levelList[i].team.@icon;
level.bg = levelList[i].team.@bg;
level.brief = levelList[i].brief.@value;
level.objective = levelList[i].objective.@value;
level.mapSettings = levelList[i]..mapsettings[0];
levels[parseInt(levelList[i].@number)] = level;
i++;
};
levelName = a_xml.@levelname;
completeName = a_xml.@completename;
if (campaigns == null){
campaigns = new Dictionary();
};
campaigns[a_campaign] = this;
}
public function getCompleteName():String{
return (completeName);
}
public function getMapSettings(a_level:int):XML{
return (levels[a_level].mapSettings);
}
public function getName(a_level:int):String{
return (levels[a_level].name);
}
public function getFinalVictoryImage():String{
return (victoryImage);
}
public function getObjective(a_level:int):String{
return (levels[a_level].objective);
}
public function getBrief(a_level:int):String{
return (levels[a_level].brief);
}
public function getTeamIcon(a_level:int):String{
return (levels[a_level].teamIcon);
}
public function getTeamName(a_level:int):String{
return (levels[a_level].teamName);
}
public function getMapName(a_level:int):String{
return (levels[a_level].mapName);
}
public function numLevels():int{
return (levels.length);
}
public function getMapURL(a_level:int):String{
return (levels[a_level].mapURL);
}
public function getLevelName():String{
return (levelName);
}
public function getBG(a_level:int):String{
return (levels[a_level].bg);
}
public static function getInstance(a_campaign:String):CampaignManager{
if (campaigns[a_campaign] == null){
trace("CampaignManager::No campaign exists");
};
return (campaigns[a_campaign]);
}
}
}//package com.gamedozer.battalion.data
class Level {
public var bg:String;
public var mapName:String;
public var teamName:String;
public var name:String;
public var mapURL:String;
public var teamIcon:String;
public var objective:String;
public var brief:String;
public var mapSettings:XML;
private function Level(){
super();
}
}
Section 18
//Map (com.gamedozer.battalion.data.Map)
package com.gamedozer.battalion.data {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import flash.geom.*;
import com.gamedozer.battalion.game.*;
public class Map {
protected var _hasGroundControl:Boolean;// = false
protected var width:int;
protected var mapName:String;// = "mapname"
protected var _hasSeaControl:Boolean;// = false
protected var author:String;// = "author"
protected var name:String;
protected var script:XML;
protected var structures:Array;
protected var height:int;
protected var data:Array;
protected var _hasAirControl:Boolean;// = false
protected var units:Array;
protected var mapURL:String;
protected var palette:Array;
protected var description:String;// = "description"
public function Map(a_xml:XML, a_mapURL:String, a_mapName:String){
var index:int;
var y:int;
var x:int;
var layerEntries:XMLList;
var j:int;
var reference:int;
var a_xml = a_xml;
var a_mapURL = a_mapURL;
var a_mapName = a_mapName;
super();
mapURL = a_mapURL;
mapName = a_mapName;
if (a_xml.name.length() > 0){
name = a_xml.name;
};
//unresolved jump
var _slot1 = e;
trace("Map constructor. You are loading a map that doesn't exist.");
if (a_xml.description != null){
description = a_xml.description;
};
author = a_xml.author;
palette = new Array();
var paletteEntries:XMLList = a_xml.palette..entry;
var i:int;
while (i < paletteEntries.length()) {
index = parseInt(paletteEntries[i].@reference);
palette[index] = new TileSwatch(stripPlayers(paletteEntries[i].name), paletteEntries[i].imageCode);
i = (i + 1);
};
height = parseInt(a_xml.rows);
width = parseInt(a_xml.cols);
data = new Array();
units = new Array();
structures = new Array();
i = 0;
while (i < height) {
data[i] = new Array();
j = 0;
while (j < width) {
data[i][j] = new Array();
j = (j + 1);
};
i = (i + 1);
};
var tileEntries:XMLList = a_xml..tile;
i = 0;
while (i < tileEntries.length()) {
y = tileEntries[i].@r;
x = tileEntries[i].@c;
layerEntries = tileEntries[i]..layer;
j = 0;
while (j < layerEntries.length()) {
index = parseInt(layerEntries[j].@depth);
reference = layerEntries[j].@reference;
if (index == 0){
data[y][x] = reference;
} else {
if (index == 1){
structures.push(new UnitHelper(reference, x, y));
} else {
if (index == 2){
units.push(new UnitHelper(reference, x, y));
};
};
};
j = (j + 1);
};
i = (i + 1);
};
script = a_xml..script[0];
}
public function getScript():XML{
return (script);
}
public function getName():String{
return (name);
}
public function getDescription():String{
return (description);
}
public function get hasSeaControl():Boolean{
return (_hasSeaControl);
}
public function generateMiniMap():BitmapData{
var x:int;
var te:Terrain;
var miniMapImage:BitmapData;
var miniMap:BitmapData = new BitmapData((width * 6), (height * 6));
var y:int;
while (y < height) {
x = 0;
while (x < width) {
te = TileManager.getInstance().get(palette[data[y][x]].getName());
if (te == null){
te = new Terrain(palette[data[y][x]].getName(), 1, "", "minimap_sea");
};
miniMapImage = BitmapLibrary.loadBitmap(te.getMiniMapImage());
miniMap.copyPixels(miniMapImage, miniMapImage.rect, new Point((x * TileManager.getInstance().getMiniMapWidth()), (y * TileManager.getInstance().getMiniMapHeight())));
x++;
};
y++;
};
return (miniMap);
}
public function getMapName():String{
return (mapName);
}
public function getWidth():int{
return (width);
}
public function ownedBy(a_x:int, a_y:int):int{
return (palette[data[a_y][a_x]].getTeam());
}
public function getAuthor():String{
return (author);
}
public function generateTileMap():Array{
var x:int;
var gt:GameTile;
var te:Terrain;
var t:Tile;
var tiles:Array = new Array();
var y:int;
while (y < height) {
tiles[y] = new Array();
x = 0;
while (x < width) {
gt = new GameTile(palette[data[y][x]].getSprite());
if (y == 0){
gt.addChild(new Bitmap(BitmapLibrary.loadBitmap("border_top")));
} else {
if (y == (height - 1)){
gt.addChild(new Bitmap(BitmapLibrary.loadBitmap("border_bottom")));
};
};
if (x == 0){
gt.addChild(new Bitmap(BitmapLibrary.loadBitmap("border_left")));
} else {
if (x == (width - 1)){
gt.addChild(new Bitmap(BitmapLibrary.loadBitmap("border_right")));
};
};
te = TileManager.getInstance().get(palette[data[y][x]].getName());
if (te == null){
te = new Terrain(palette[data[y][x]].getName(), 1, "", "minimap_sea", "undefined");
};
t = new Tile(gt, x, y, te);
tiles[y][x] = t;
x++;
};
y++;
};
y = 0;
while (y < height) {
x = 0;
while (x < width) {
if (x > 0){
tiles[y][x].addConnection(tiles[y][(x - 1)]);
};
if (x < (width - 1)){
tiles[y][x].addConnection(tiles[y][(x + 1)]);
};
if (y > 0){
tiles[y][x].addConnection(tiles[(y - 1)][x]);
};
if (y < (height - 1)){
tiles[y][x].addConnection(tiles[(y + 1)][x]);
};
x++;
};
y++;
};
return (tiles);
}
public function getMapURL():String{
return (mapURL);
}
public function get hasGroundControl():Boolean{
return (_hasGroundControl);
}
public function stripPlayers(a_name:String):String{
var ret:String = a_name.replace("P1 ", "");
ret = ret.replace("P2 ", "");
ret = ret.replace("P3 ", "");
ret = ret.replace("P4 ", "");
ret = ret.replace("Neutral ", "");
return (ret);
}
public function getNums():Object{
var p:TileSwatch;
var name:String;
var ud:UnitData;
var nums:Object = {air:0, ground:0, sea:0};
var i:int;
while (i < units.length) {
p = palette[units[i].swatch];
if (p.getTeam() == 1){
name = p.getName();
ud = UnitManager.getInstance().get(name);
if (ud.isAir()){
nums.air++;
} else {
if (ud.isGround()){
nums.ground++;
} else {
if (ud.isSea()){
nums.sea++;
};
};
};
};
i++;
};
return (nums);
}
public function get hasAirControl():Boolean{
return (_hasAirControl);
}
public function generateStructures(a_tileMap:Array, a_controllers:Array):Array{
var tile:Tile;
var p:TileSwatch;
var controller:Controller;
var argb:uint;
var name:String;
var upgrade:Terrain;
var sprite:GameSprite;
var structure:Array = new Array();
var i:int;
while (i < structures.length) {
tile = a_tileMap[structures[i].y][structures[i].x];
p = palette[structures[i].swatch];
controller = null;
argb = 4294967295;
if (p.getTeam() > 0){
controller = a_controllers[(p.getTeam() - 1)];
argb = controller.getTeam().getColor();
};
name = p.getName();
if (name == "Air Control"){
_hasAirControl = true;
};
if (name == "Ground Control"){
_hasGroundControl = true;
};
if (name == "Sea Control"){
_hasSeaControl = true;
};
upgrade = TileManager.getInstance().get(name);
if (upgrade != null){
if ((((((upgrade.getSprite() == "oilrig")) || ((upgrade.getSprite() == "oilrefinery")))) || ((upgrade.getSprite() == "oiladvanced")))){
sprite = TileSheetManager.getInstance().getColorised(name, argb);
(sprite as TileSheet).playAnimation("default");
} else {
sprite = new ColoredSprite(BitmapLibrary.loadBitmap(upgrade.getSprite()), BitmapLibrary.loadBitmap((upgrade.getSprite() + "_mask")), argb, "overlay");
};
tile.upgrade(sprite, upgrade, controller);
structure.push(tile);
};
i++;
};
return (structure);
}
public function generateUnits(a_controllers:Array):Array{
var p:TileSwatch;
var name:String;
var ud:UnitData;
var gu:GameUnit;
var u:Unit;
var ts:TileSheet;
var unit:Array = new Array();
var i:int;
while (i < units.length) {
p = palette[units[i].swatch];
if (p.getTeam() > 0){
name = p.getName();
ud = UnitManager.getInstance().get(name);
if (ud != null){
gu = new GameUnit(TileSheetManager.getInstance().getColorised(ud.getSprite(), a_controllers[(p.getTeam() - 1)].getTeam().getColor()));
u = new Unit(gu, ud, units[i].x, units[i].y, a_controllers[(p.getTeam() - 1)]);
ts = (u.getGameUnit().getSprite() as TileSheet);
if (u.getX() > (width / 2)){
ts.playAnimation("left_idle");
} else {
ts.playAnimation("right_idle");
};
unit.push(u);
};
};
i++;
};
return (unit);
}
public function getHeight():int{
return (height);
}
}
}//package com.gamedozer.battalion.data
class UnitHelper {
public var y:int;
public var swatch:int;
public var x:int;
private function UnitHelper(a_swatch:int, a_x:int, a_y:int){
super();
swatch = a_swatch;
x = a_x;
y = a_y;
}
}
Section 19
//MapSettings (com.gamedozer.battalion.data.MapSettings)
package com.gamedozer.battalion.data {
import com.gamedozer.battalion.ui.*;
public class MapSettings {
protected var campaignName:String;
protected var campaign:int;
protected var map:Map;
protected var resources:int;
protected var rounds:int;
protected var difficulty:int;
protected var teams:Array;
public function MapSettings(a_rounds:int, a_resources:int, a_difficulty:int, a_campaignName:String="", a_campaign:int=-1){
super();
rounds = a_rounds;
difficulty = a_difficulty;
resources = a_resources;
difficulty = a_difficulty;
campaign = a_campaign;
campaignName = a_campaignName;
teams = new Array();
}
public function getTeams():Array{
return (teams);
}
public function setCampaignName(a_campaignName:String):void{
campaignName = a_campaignName;
}
public function getCampaign():int{
return (campaign);
}
public function setCampaign(a_campaign:int):void{
campaign = a_campaign;
}
public function getTeam(i:int):Team{
return (teams[i]);
}
public function setMap(a_map:Map):void{
map = a_map;
}
public function getRounds():int{
return (rounds);
}
public function toXML():XML{
var ret = ((((((((" <mapsettings rounds=\"" + rounds) + "\" resources=\"0\" campaignname= \"") + campaignName) + "\" campaign=\"") + campaign) + "\" difficulty=\"") + difficulty) + "\"> <teams> ");
var i:int;
while (i < teams.length) {
ret = (ret + teams[i].toXML());
i++;
};
ret = (ret + "</teams> </mapsettings>");
return (new XML(ret));
}
public function addTeam(a_team:Team):void{
teams.push(a_team);
}
public function getMap():Map{
return (map);
}
public function setRounds(a_rounds:int):void{
rounds = a_rounds;
}
public function setResources(a_resources:int):void{
resources = a_resources;
}
public function getResources():int{
return (resources);
}
public function getCampaignName():String{
return (campaignName);
}
public static function getFromXML(a_xml:XML):MapSettings{
var team:Team;
var ms:MapSettings = new MapSettings(parseInt(a_xml.@rounds), parseInt(a_xml.@resources), parseInt(a_xml.@difficulty), a_xml.@campaignname, parseInt(a_xml.@campaign));
var teams:XMLList = a_xml.teams..team;
var i:int;
while (i < teams.length()) {
if (teams[i].controllertype.@value == "AI"){
teams[i].difficulty.@value = ms.difficulty;
} else {
teams[i].difficulty.@value = 1;
};
team = Team.getFromXML(teams[i]);
ms.addTeam(team);
i++;
};
var mapString:String = a_xml.@map;
return (ms);
}
}
}//package com.gamedozer.battalion.data
Section 20
//Modifier (com.gamedozer.battalion.data.Modifier)
package com.gamedozer.battalion.data {
import flash.display.*;
public class Modifier {
protected var effects:Array;
protected var name:String;
protected var visible:Boolean;
protected var type:String;
protected var image:String;
protected var description:String;
public function Modifier(a_name:String, a_description:String="", a_image:String=null, a_visible:Boolean=false, a_type:String=""){
super();
name = a_name;
description = a_description;
image = a_image;
visible = a_visible;
type = a_type;
effects = new Array();
}
public function getName():String{
return (name);
}
public function getVisible():Boolean{
return (visible);
}
public function getImage():String{
return (image);
}
public function getDescription():String{
return (description);
}
public function toString():String{
var ret = (name + " ");
var i:int;
while (i < effects.length) {
ret = (ret + (effects[i] + " "));
i++;
};
return (ret);
}
public function removeEffect(a_effect:ModifierEffect):void{
var i:int = (effects.length - 1);
while (i >= 0) {
if (effects[i] == a_effect){
effects.splice(i, 1);
return;
};
i--;
};
}
public function apply(a_type:String, a_unit:Unit, a_value:Number):Number{
var i:int;
if (a_type.toLowerCase() == type.toLowerCase()){
i = 0;
while (i < effects.length) {
a_value = effects[i].apply(a_unit, a_value);
i++;
};
};
return (a_value);
}
public function setVisible(a_visible:Boolean):void{
visible = a_visible;
}
public function addEffect(a_effect:ModifierEffect):void{
effects.push(a_effect);
}
}
}//package com.gamedozer.battalion.data
Section 21
//ModifierEffect (com.gamedozer.battalion.data.ModifierEffect)
package com.gamedozer.battalion.data {
public class ModifierEffect {
protected var value:String;
protected var effects:Array;
public function ModifierEffect(a_value:String){
super();
value = a_value.toLowerCase();
effects = new Array();
}
public function removeEffect(a_effect:ModifierEffect):void{
var i:int = (effects.length - 1);
while (i >= 0) {
if (effects[i] == a_effect){
effects.splice(i, 1);
return;
};
i--;
};
}
public function toString():String{
var ret = (value + " ");
var i:int;
while (i < effects.length) {
ret = (ret + (effects[i] + " "));
i++;
};
return (ret);
}
public function apply(a_unit:Unit, a_value:Number):Number{
var val:String;
var addPerc:Number;
var addVal:Number;
var minusPerc:Number;
var minusVal:Number;
var multVal:Number;
var setVal:Number;
if (value == "0"){
return (0);
};
if (value == "infinity"){
return (Number.POSITIVE_INFINITY);
};
if (value.charAt(0) == "+"){
val = value.substring(1);
if (val.charAt((val.length - 1)) == "%"){
addPerc = Number(val.substring(0, (val.length - 1)));
if (!isNaN(addPerc)){
addPerc = (addPerc / 100);
return ((a_value + (addPerc * a_value)));
};
} else {
addVal = Number(val);
if (!isNaN(addVal)){
return ((a_value + addVal));
};
};
} else {
if (value.charAt(0) == "-"){
val = value.substring(1);
if (val.charAt((val.length - 1)) == "%"){
minusPerc = Number(val.substring(0, (val.length - 1)));
if (!isNaN(minusPerc)){
minusPerc = (minusPerc / 100);
return ((a_value - (minusPerc * a_value)));
};
} else {
minusVal = Number(val);
if (!isNaN(minusVal)){
return ((a_value + minusVal));
};
};
} else {
if (value.charAt(0) == "*"){
val = value.substring(1);
multVal = Number(val);
if (!isNaN(multVal)){
return ((a_value * multVal));
};
} else {
setVal = Number(value);
if (!isNaN(setVal)){
return (setVal);
};
};
};
};
throw (new Error("ModifierEffect::Modify returned without affecting anything!"));
}
public function addEffect(a_effect:ModifierEffect):void{
effects.push(a_effect);
}
}
}//package com.gamedozer.battalion.data
Section 22
//ModifierEffectMatch (com.gamedozer.battalion.data.ModifierEffectMatch)
package com.gamedozer.battalion.data {
public class ModifierEffectMatch extends ModifierEffect {
protected var type:String;
public function ModifierEffectMatch(a_type:String, a_value:String){
super(a_value);
type = a_type.toLowerCase();
}
override public function apply(a_unit:Unit, a_value:Number):Number{
if (a_unit == null){
return (a_value);
};
if (type == "unittype"){
if (UnitData.unitTypes[a_unit.getUnitData().getUnitType()].toLowerCase() != value){
return (a_value);
};
} else {
if (type.toLowerCase() == "movementtype"){
if (UnitData.movementTypes[a_unit.getUnitData().getMovementType()].toLowerCase() != value){
return (a_value);
};
} else {
if (type.toLowerCase() == "weapontype"){
if (UnitData.weaponTypes[a_unit.getUnitData().getWeaponType()].toLowerCase() != value){
return (a_value);
};
} else {
if (type.toLowerCase() == "armortype"){
if (UnitData.armorTypes[a_unit.getUnitData().getArmorType()].toLowerCase() != value){
return (a_value);
};
} else {
if (type.toLowerCase() == "modifier"){
if (!a_unit.getUnitData().hasModifier(value)){
return (a_value);
};
} else {
throw (new Error("ModifierEffect::Nothing matched, invalid modifier match!"));
};
};
};
};
};
var i:int;
while (i < effects.length) {
a_value = effects[i].apply(a_unit, a_value);
i++;
};
return (a_value);
}
override public function toString():String{
return (type);
}
}
}//package com.gamedozer.battalion.data
Section 23
//ModifierManager (com.gamedozer.battalion.data.ModifierManager)
package com.gamedozer.battalion.data {
import flash.display.*;
import flash.utils.*;
public class ModifierManager {
protected var modifiers:Dictionary;
private static var singleton:ModifierManager;
public function ModifierManager(){
super();
singleton = this;
modifiers = new Dictionary();
}
public function add(a_modifier:Modifier):void{
modifiers[a_modifier.getName()] = a_modifier;
}
public function importXML(a_xml:XML):void{
var visible:Boolean;
var modifier:Modifier;
var effects:XMLList;
var j:int;
var current:XML;
var ln:String;
var match:ModifierEffect;
if (a_xml == null){
return;
};
var modifierList:XMLList = a_xml..modifier;
var i:int;
while (i < modifierList.length()) {
visible = false;
if (modifierList[i].visible.@value.toLowerCase() == "true"){
visible = true;
};
modifier = new Modifier(modifierList[i].@name, modifierList[i].description.@value, modifierList[i].image.@value, visible, modifierList[i].modify.@type);
effects = modifierList[i].modify.children();
j = 0;
while (j < effects.length()) {
current = effects[j];
ln = current.localName().toLowerCase();
if (ln == "effect"){
modifier.addEffect(new ModifierEffect(current.@value));
} else {
if (ln == "match"){
match = new ModifierEffectMatch(current.@type, current.@value);
modifier.addEffect(match);
handleEffect(current, match);
};
};
j++;
};
modifiers[modifier.getName()] = modifier;
i++;
};
}
public function remove(a_modifier:Modifier):void{
delete modifiers[a_modifier.getName()];
}
public function get(a_name:String):Modifier{
if (modifiers[a_name] == null){
trace(("ModifierManager::Could not get modifier: " + a_name));
};
return (modifiers[a_name]);
}
public function handleEffect(a_xml:XML, a_effect:ModifierEffect=null):void{
var current:XML;
var ln:String;
var match:ModifierEffect;
var effects:XMLList = a_xml.children();
var i:int;
while (i < effects.length()) {
current = effects[i];
ln = current.localName().toLowerCase();
if (ln == "effect"){
a_effect.addEffect(new ModifierEffect(current.@value));
} else {
if (ln == "match"){
match = new ModifierEffectMatch(current.@type, current.@value);
a_effect.addEffect(match);
handleEffect(current, match);
};
};
i++;
};
}
public function clear():void{
modifiers = new Dictionary();
}
public static function getInstance():ModifierManager{
if (singleton == null){
trace("ModifierManager::No instance exists");
};
return (singleton);
}
}
}//package com.gamedozer.battalion.data
Section 24
//Node (com.gamedozer.battalion.data.Node)
package com.gamedozer.battalion.data {
public class Node {
public var f:Number;
public var g:Number;
public var h:Number;
public var state:int;
public var previous:Node;
protected var connections:Array;
public var iteration:int;
static const OPEN:int = 0;
static const CLOSED:int = 1;
public function Node(a_previous:Node=null, a_g:Number=0, a_h:Number=0, a_f:Number=0){
super();
previous = a_previous;
g = a_g;
h = a_h;
f = a_f;
state = Node.OPEN;
iteration = -1;
connections = new Array();
}
public function addConnection(a_node:Node):void{
if (!isConnected(a_node)){
connections.push(a_node);
};
}
public function getCost(... _args):Number{
return (1);
}
public function compare(a_node:Node):int{
if (a_node.f > f){
return (1);
};
if (a_node.f < f){
return (-1);
};
return (0);
}
public function removeConnection(a_node:Node):void{
var i:int = (connections.length - 1);
while (i >= 0) {
if (connections[i] == a_node){
connections.splice(i, 1);
};
i--;
};
}
function reset(a_previous:Node=null, a_g:Number=0, a_h:Number=0, a_f:Number=0):void{
previous = a_previous;
g = a_g;
h = a_h;
f = a_f;
state = Node.OPEN;
iteration = -1;
}
public function getHeuristic(a_node:Node):Number{
return (0);
}
public function getConnections():Array{
return (connections);
}
public function isConnected(a_node:Node):Boolean{
var i:int;
while (i < connections.length) {
if (connections[i] == a_node){
return (true);
};
i++;
};
return (false);
}
}
}//package com.gamedozer.battalion.data
Section 25
//Team (com.gamedozer.battalion.data.Team)
package com.gamedozer.battalion.data {
import com.kongregate.as3.client.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.*;
public class Team {
protected var difficulty:int;
protected var rank:int;
protected var teamName:String;
protected var name:String;
protected var active:Boolean;
protected var allies:Array;
protected var avatar:String;
protected var stats:Array;
protected var color:uint;
protected var controllerType:String;
public static const STRUCTURES_LOST:int = 4;
public static const FINAL_SCORE:int = 6;
public static const UNITS_KILLED:int = 1;
public static const UNITS_BUILT:int = 0;
public static const RESOURCES_COLLECTED:int = 5;
public static const UNITS_LOST:int = 2;
public static const TIME_TAKEN:int = 7;
public static const STATISTICS:int = 8;
public static const STRUCTURES_CAPTURED:int = 3;
public function Team(a_name:String, a_teamName:String, a_avatar:String, a_rank:int, a_color:uint, a_controllerType:String, a_difficulty:int, a_active:Boolean=true){
super();
name = a_name;
teamName = a_teamName;
color = a_color;
avatar = a_avatar;
rank = a_rank;
controllerType = a_controllerType;
difficulty = a_difficulty;
active = a_active;
stats = new Array();
var i:int;
while (i < STATISTICS) {
stats[i] = 0;
i++;
};
allies = new Array();
}
public function getName():String{
return (name);
}
public function getTeamName():String{
return (teamName);
}
public function calculateFinalScore():void{
var score:int;
score = (score + (stats[UNITS_BUILT] * 500));
score = (score + (stats[UNITS_KILLED] * 1000));
score = (score - (stats[UNITS_LOST] * 100));
score = (score + (stats[STRUCTURES_CAPTURED] * 2500));
score = (score - (stats[STRUCTURES_LOST] * 1000));
score = (score + stats[RESOURCES_COLLECTED]);
score = Math.max(0, score);
stats[FINAL_SCORE] = score;
}
public function getControllerType():String{
return (controllerType);
}
public function getAvatar():String{
return (avatar);
}
public function isAllied(a_player:int):Boolean{
return (!((allies.indexOf(a_player) == -1)));
}
public function setActive(a_active:Boolean):void{
active = a_active;
}
public function getStatistic(a_statistic:int):int{
return (stats[a_statistic]);
}
public function toXML():XML{
var ret = ((((((((((((((((" <team active=\"" + ((active == true)) ? "true" : "false") + "\"> <name value=\"") + name) + "\"/> <teamname value=\"") + teamName) + "\"/> <color value=\"") + color.toString(16)) + "\"/> <avatar value=\"") + avatar) + "\"/> <rank value=\"") + rank) + "\"/> <controllertype value=\"") + controllerType) + "\"/> <difficulty value=\"") + difficulty) + "\"/>");
ret = (ret + (("<stats value=\"" + stats.join(",")) + "\"/>"));
if (allies.length > 0){
ret = (ret + (("<allies value=\"" + allies.join(",")) + "\"/>"));
};
ret = (ret + "</team>");
return (new XML(ret));
}
public function getRank():int{
return (rank);
}
public function getColor():uint{
return (color);
}
public function addStatistic(a_statistic:int, a_add:int):void{
var statName:String;
stats[a_statistic] = (stats[a_statistic] + a_add);
if (a_add != 0){
if (controllerType != "AI"){
statName = "";
switch (a_statistic){
case UNITS_KILLED:
statName = "Enemy Units Destroyed";
break;
case UNITS_LOST:
statName = "Allied Units Lost";
break;
case UNITS_BUILT:
statName = "Allied Units Built";
break;
case STRUCTURES_CAPTURED:
statName = "Enemy Structures Captured";
break;
case STRUCTURES_LOST:
statName = "Allied Structures Lost";
break;
case RESOURCES_COLLECTED:
statName = "Resources Collected";
break;
case TIME_TAKEN:
statName = "Time Taken";
break;
};
if (statName != ""){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit(statName, a_add);
};
};
};
};
}
public function getDifficulty():int{
return (difficulty);
}
public function createController():Controller{
var c:Controller;
if (controllerType == "Human"){
c = new HumanController(this);
} else {
if (controllerType == "AI"){
c = new AIController(this);
} else {
c = new Controller(this);
};
};
return (c);
}
public function addAlly(a_player:int):void{
allies.push(a_player);
}
public function getActive():Boolean{
return (active);
}
public static function getFromXML(a_xml:XML):Team{
var allies:String;
var statsarray:Array;
var i:int;
var alliesarray:Array;
var active:Boolean;
var activeString:String = a_xml.@active;
if (activeString.toLowerCase().charAt(0) == "t"){
active = true;
};
var d:Number = parseFloat(a_xml.difficulty.@value);
var controllerType:String = a_xml.controllertype.@value;
if (((isNaN(d)) || ((controllerType == "Human")))){
d = 1;
};
var t:Team = new Team(a_xml.name.@value, a_xml.teamname.@value, a_xml.avatar.@value, parseInt(a_xml.rank.@value), parseInt(a_xml.color.@value, 16), controllerType, d, active);
var statsstring:String = a_xml.stats.@value;
if (statsstring != ""){
statsarray = statsstring.split(",");
i = 0;
while (i < statsarray.length) {
t.addStatistic(i, parseInt(statsarray[i]));
i++;
};
};
var alliesstring:String = a_xml.allies.@value;
if (alliesstring != ""){
alliesarray = alliesstring.split(",");
i = 0;
while (i < alliesarray.length) {
t.addAlly(parseInt(alliesarray[i]));
i++;
};
};
return (t);
}
}
}//package com.gamedozer.battalion.data
Section 26
//Terrain (com.gamedozer.battalion.data.Terrain)
package com.gamedozer.battalion.data {
import flash.display.*;
public class Terrain {
protected var sprite:String;
protected var name:String;
protected var cost:Number;
protected var description:String;
protected var miniMapImage:String;
protected var resources:int;// = 0
protected var modifiers:Array;
public function Terrain(a_name:String, a_cost:Number, a_description:String, a_miniMapImage:String, a_sprite:String=""){
super();
name = a_name;
cost = a_cost;
description = a_description;
miniMapImage = a_miniMapImage;
sprite = a_sprite;
resources = 0;
modifiers = new Array();
}
public function getName():String{
return (name);
}
public function removeModifier(a_modifier:Modifier):void{
var i:int = (modifiers.length - 1);
while (i >= 0) {
if (modifiers[i] == a_modifier){
modifiers.splice(i, 1);
return;
};
i--;
};
}
public function getCost():Number{
return (cost);
}
public function getDescription():String{
return (description);
}
public function getMiniMapImage():String{
return (miniMapImage);
}
public function getModifiers():Array{
return (modifiers);
}
public function addModifier(a_modifier:Modifier):void{
modifiers.push(a_modifier);
}
public function hasModifier(a_name:String):Boolean{
var i:int;
while (i < modifiers.length) {
if (modifiers[i].getName().toLowerCase() == a_name.toLowerCase()){
return (true);
};
i++;
};
return (false);
}
public function clone():Terrain{
var terra:Terrain = new Terrain(name, cost, description, miniMapImage, sprite);
var i:int;
while (i < modifiers.length) {
terra.addModifier(modifiers[i]);
i++;
};
return (terra);
}
public function applyModifiers(a_type:String, a_unit:Unit, a_value:Number):Number{
var i:int;
while (i < modifiers.length) {
a_value = modifiers[i].apply(a_type, a_unit, a_value);
i++;
};
return (a_value);
}
public function getSprite():String{
return (sprite);
}
}
}//package com.gamedozer.battalion.data
Section 27
//Tile (com.gamedozer.battalion.data.Tile)
package com.gamedozer.battalion.data {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import flash.filters.*;
public class Tile extends Node {
protected var structure:GameSprite;
protected var unit:Unit;
protected var controller:Controller;
protected var baseTerrain:Terrain;
protected var resources:int;
protected var chunks:int;
protected var miniMapSprite:TileSheet;
protected var terrain:Terrain;
protected var gameTile:GameTile;
protected var resourcesField:TextField;
protected var captureBar:TileSheet;
protected var capturer:Unit;
protected var x:int;
protected var y:int;
protected var m_textField:TextField;
public static const k_astarFlagForceCost1:int = 2;
protected static const flagX:Number = 43;
protected static const flagY:Number = -5;
public static const k_allowDebugTextfield:Boolean = false;
public static const k_astarFlagUnused3:int = 8;
public static const k_astarFlagIgnoreLastNode:int = 1;
public static const k_astarFlagIgnoreUnits:int = 4;
protected static const flagH:Number = 20;
public function Tile(a_gameTile:GameTile, a_x:int, a_y:int, a_terrain:Terrain, a_unit:Unit=null){
super();
terrain = (baseTerrain = a_terrain);
x = a_x;
y = a_y;
gameTile = a_gameTile;
gameTile.x = (x * TileManager.getInstance().getWidth());
gameTile.y = (y * TileManager.getInstance().getHeight());
unit = a_unit;
controller = null;
structure = null;
capturer = null;
chunks = GameManager.TILE_CHUNKS;
resources = 0;
if (k_allowDebugTextfield){
m_textField = new DefaultTextField();
m_textField.filters = [new GlowFilter(0)];
gameTile.addChild(m_textField);
} else {
m_textField = null;
};
resourcesField = new DefaultTextField(0xFFFFFF, TextFormatAlign.CENTER);
resourcesField.text = "0";
resourcesField.y = ((TileManager.getInstance().getHeight() - resourcesField.textHeight) - 5);
resourcesField.width = TileManager.getInstance().getWidth();
}
public function canBeMovedOnBy(a_unit:Unit):Boolean{
return (!((getMovementCost(a_unit) == Number.POSITIVE_INFINITY)));
}
public function setUnit(a_unit:Unit):void{
if (((((!((unit == null))) && (!((a_unit == null))))) && (!((unit == a_unit))))){
throw (new Error("Tile::Unit trying to be placed on a Tile, while a unit already exists on it"));
};
unit = a_unit;
}
public function getController():Controller{
return (controller);
}
protected function updateCaptureBar():void{
var newY:Number = (flagY + (flagH * (1 - (chunks / GameManager.TILE_CHUNKS))));
captureBar.x = (flagX - 1);
TweenManager.getInstance().removeTweens(captureBar);
if ((((((this.getUnit() == null)) || ((this.getUnit().getController() == this.getController())))) || (!(this.getUnit().getUnitData().hasModifier("Capture"))))){
captureBar.filters = [];
captureBar.y = newY;
return;
};
var color:uint = this.getUnit().getController().getTeam().getColor();
captureBar.filters = [new GlowFilter(color)];
TweenManager.getInstance().add(new Tween(captureBar, Quad.easeIn, ["y"], [captureBar.y], [newY], 1000), TweenManager.SEQUENTIAL);
}
public function getMovementCost(a_unit:Unit):Number{
return (terrain.applyModifiers("movementCost", a_unit, terrain.getCost()));
}
public function setController(a_controller:Controller):void{
var neutralColor:uint = 4286414205;
controller = a_controller;
if (controller == null){
if ((structure is ColoredSprite)){
(structure as ColoredSprite).setColor(neutralColor);
} else {
(structure as TileSheet).setTileSheet(TileSheetManager.getInstance().getColorised(terrain.getName(), neutralColor).getTileSheet());
};
captureBar = TileSheetManager.getInstance().getColorised("flag", neutralColor);
} else {
if ((structure is ColoredSprite)){
(structure as ColoredSprite).setColor(controller.getTeam().getColor());
} else {
(structure as TileSheet).setTileSheet(TileSheetManager.getInstance().getColorised(terrain.getName(), controller.getTeam().getColor()).getTileSheet());
};
captureBar = TileSheetManager.getInstance().getColorised("flag", controller.getTeam().getColor());
};
gameTile.setFlag(captureBar);
captureBar.playAnimation("default");
updateCaptureBar();
updateMiniMap();
}
public function upgrade(a_structure:GameSprite, a_terrain:Terrain, a_controller:Controller=null):void{
if (structure != null){
throw (new Error("Tile::Trying to upgrade a tile which already has a structure on it"));
};
structure = a_structure;
var color:uint = 4294967295;
if (a_controller != null){
color = a_controller.getTeam().getColor();
};
captureBar = TileSheetManager.getInstance().getColorised("flag", color);
captureBar.playAnimation("default");
updateCaptureBar();
gameTile.setStructure(structure);
gameTile.setFlag(captureBar);
terrain = a_terrain;
controller = a_controller;
updateMiniMap();
}
public function isAdjacentTo(a_tile:Tile):Boolean{
if (a_tile == this){
trace("Tile: Can't be adjacent to ourself.");
return (false);
};
if (a_tile.getX() == getX()){
if ((((a_tile.getY() == (getY() + 1))) || ((a_tile.getY() == (getY() - 1))))){
return (true);
};
};
if (a_tile.getY() == getY()){
if ((((a_tile.getX() == (getX() + 1))) || ((a_tile.getX() == (getX() - 1))))){
return (true);
};
};
return (false);
}
public function setChunks(a_chunks:int):void{
chunks = a_chunks;
updateCaptureBar();
}
public function getChunks():int{
return (chunks);
}
public function getGameTile():GameTile{
return (gameTile);
}
public function getStructure():GameSprite{
return (structure);
}
public function seaBordered():Boolean{
var tiles:Array = getConnections();
var i:int;
while (i < tiles.length) {
if (tiles[i].getTerrain().hasModifier("Water")){
return (true);
};
i++;
};
return (false);
}
public function getX():int{
return (x);
}
public function getY():int{
return (y);
}
public function showText(a_string:String, a_color:uint=0xFFFFFF):void{
if (!k_allowDebugTextfield){
return;
};
m_textField.textColor = a_color;
m_textField.text = a_string;
m_textField.parent.setChildIndex(m_textField, (m_textField.parent.numChildren - 1));
}
override public function getCost(... _args):Number{
var ignoreUnitsOnLastNodeFlag:Boolean;
var movingUnit:Unit = _args[0];
var flags:int = _args[1];
var isLastNode:Boolean = _args[2];
if ((flags & Tile.k_astarFlagForceCost1)){
return (1);
};
if (((!((unit == null))) && (!((flags & k_astarFlagIgnoreUnits))))){
if (!unit.getController().isAllied(_args[0].getController())){
if (!unit.isCloaked()){
ignoreUnitsOnLastNodeFlag = !(((flags & Tile.k_astarFlagIgnoreLastNode) == 0));
if (!((isLastNode) && (ignoreUnitsOnLastNodeFlag))){
return (Number.POSITIVE_INFINITY);
};
};
};
};
var cost:Number = terrain.applyModifiers("movementCost", movingUnit, terrain.getCost());
return (cost);
}
override public function getHeuristic(a_node:Node):Number{
var a_tile:Tile;
var a_node = a_node;
a_tile = (a_node as Tile);
return ((Math.abs((x - a_tile.getX())) + Math.abs((y - a_tile.getY()))));
//unresolved jump
var _slot1 = e;
return (0);
}
protected function updateResources():void{
if (resources > 0){
if (resourcesField.parent == null){
gameTile.addChild(resourcesField);
};
resourcesField.text = ("" + resources);
} else {
if (resourcesField.parent != null){
gameTile.removeChild(resourcesField);
};
};
}
public function takeResources(perc:Number=1):Number{
var res:int = (getTerrain().applyModifiers("resources", null, 0) * perc);
var resMod:Number = getTerrain().applyModifiers("reducedResources", null, res);
if (res > resources){
resources = 0;
updateResources();
return (resMod);
};
resources = (resources - res);
updateResources();
return (res);
}
public function getFlag():GameSprite{
return (captureBar);
}
public function setResources(a_resources:int):void{
resources = a_resources;
updateResources();
}
public function isStructure():Boolean{
return (!((structure == null)));
}
public function toString():String{
return ((((("[Tile: " + x) + ",") + y) + " ]"));
}
public function setCapturer(a_unit:Unit):void{
capturer = a_unit;
if (capturer == null){
chunks = GameManager.TILE_CHUNKS;
};
}
public function getResources():int{
return (resources);
}
public function getCapturer():Unit{
return (capturer);
}
public function downgrade():void{
if (structure == null){
throw (new Error("Tile::Trying to downgrade a tile which does not have a structure on it"));
};
gameTile.setStructure(null);
gameTile.setFlag(null);
structure = null;
controller = null;
capturer = null;
captureBar = null;
terrain = baseTerrain;
chunks = GameManager.TILE_CHUNKS;
updateMiniMap();
}
public function getUnit():Unit{
return (unit);
}
public function updateMiniMap():void{
if (miniMapSprite != null){
GameManager.getInstance().getMiniMap().getMap().removeChild(miniMapSprite);
};
if (isStructure()){
if (controller == null){
miniMapSprite = TileSheetManager.getInstance().get("minimap_overlay");
} else {
miniMapSprite = TileSheetManager.getInstance().getColorised("minimap_overlay", controller.getTeam().getColor());
};
miniMapSprite.playAnimation(getTerrain().getMiniMapImage());
miniMapSprite.x = (x * TileManager.getInstance().getMiniMapWidth());
miniMapSprite.y = (y * TileManager.getInstance().getMiniMapHeight());
GameManager.getInstance().getMiniMap().getMap().addChild(miniMapSprite);
};
}
public function isSeaBased():Boolean{
return (getTerrain().hasModifier("Water"));
}
public function getTerrain():Terrain{
return (terrain);
}
}
}//package com.gamedozer.battalion.data
Section 28
//TileManager (com.gamedozer.battalion.data.TileManager)
package com.gamedozer.battalion.data {
import flash.display.*;
import flash.utils.*;
public class TileManager {
protected var miniMapWidth:int;
protected var width:int;
protected var height:int;
protected var miniMapHeight:int;
protected var terrain:Dictionary;
private static var singleton:TileManager;
public function TileManager(a_width:int, a_height:int, a_mWidth:int, a_mHeight:int){
super();
singleton = this;
width = a_width;
height = a_height;
miniMapWidth = a_mWidth;
miniMapHeight = a_mHeight;
terrain = new Dictionary();
}
public function remove(a_terrain:Terrain):void{
delete terrain[a_terrain.getName()];
}
public function get(a_name:String):Terrain{
if (terrain[a_name] == null){
trace(("TileManager::Could not get terrain: " + a_name));
return (null);
};
return (terrain[a_name].clone());
}
public function add(a_terrain:Terrain):void{
terrain[a_terrain.getName()] = a_terrain;
}
public function clear():void{
terrain = new Dictionary();
}
public function getWidth():int{
return (width);
}
public function importXML(a_xml:XML):void{
var terra:Terrain;
var modifiers:XMLList;
var j:int;
if (a_xml == null){
return;
};
var terrainList:XMLList = a_xml..terrain;
var i:int;
while (i < terrainList.length()) {
terra = new Terrain(terrainList[i].@name, Number(terrainList[i].cost.@value), terrainList[i].description.@value, terrainList[i].minimapimage.@value, terrainList[i].sprite.@value);
modifiers = terrainList[i]..modifier;
j = 0;
while (j < modifiers.length()) {
if (modifiers[j].@type != ""){
terra.addModifier(ModifierManager.getInstance().get(modifiers[j].@type));
};
j++;
};
terrain[terra.getName()] = terra;
i++;
};
}
public function getMiniMapHeight():int{
return (miniMapHeight);
}
public function getMiniMapWidth():int{
return (miniMapWidth);
}
public function getHeight():int{
return (height);
}
public static function getInstance():TileManager{
if (singleton == null){
trace("TileManager::No instance exists");
};
return (singleton);
}
}
}//package com.gamedozer.battalion.data
Section 29
//Unit (com.gamedozer.battalion.data.Unit)
package com.gamedozer.battalion.data {
import flash.display.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import flash.geom.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import flash.filters.*;
public class Unit {
protected var gameUnit:GameUnit;
protected var controller:Controller;
protected var miniMapSprite:TileSheet;
protected var moved:Boolean;
protected var vehicle:GameSprite;
protected var repairing:Boolean;
protected var deployed:Boolean;
protected var unitData:UnitData;
protected var baseUnitData:UnitData;
protected var health:Number;
protected var fired:Boolean;
protected var cloaked:Boolean;
protected var x:int;
protected var y:int;
protected var m_textField:TextField;
protected var disabled:Boolean;
public function Unit(a_gameUnit:GameUnit, a_unitData:UnitData, a_x:int=0, a_y:int=0, a_controller:Controller=null){
super();
unitData = (baseUnitData = a_unitData);
x = a_x;
y = a_y;
gameUnit = a_gameUnit;
gameUnit.x = (x * TileManager.getInstance().getWidth());
gameUnit.y = (y * TileManager.getInstance().getHeight());
controller = a_controller;
disabled = false;
if (controller == null){
miniMapSprite = TileSheetManager.getInstance().get("minimap_overlay");
} else {
miniMapSprite = TileSheetManager.getInstance().getColorised("minimap_overlay", controller.getTeam().getColor());
};
miniMapSprite.playAnimation("minimap_unit");
miniMapSprite.x = (x * TileManager.getInstance().getMiniMapWidth());
miniMapSprite.y = (y * TileManager.getInstance().getMiniMapHeight());
health = unitData.getHealth();
moved = false;
fired = false;
deployed = false;
repairing = false;
gameUnit.setHealth(1);
if (Tile.k_allowDebugTextfield){
m_textField = new DefaultTextField();
m_textField.autoSize = "center";
m_textField.width = 50;
m_textField.multiline = true;
m_textField.y = (m_textField.y + 10);
m_textField.filters = [new DropShadowFilter()];
gameUnit.addChild(m_textField);
} else {
m_textField = null;
};
}
public function disable():void{
disabled = true;
}
public function getName():String{
return (unitData.getName());
}
public function hasFired():Boolean{
return (fired);
}
public function getArmorType():int{
return (unitData.getArmorType());
}
public function getRange():Number{
return (unitData.getRange());
}
public function enable():void{
disabled = false;
}
public function getWeaponRangeMin():Number{
return (unitData.getWeaponRangeMin());
}
public function isDeployed():Boolean{
return (deployed);
}
public function isRanged():Boolean{
if ((((unitData.getWeaponRangeMin() > 1)) || ((unitData.getWeaponRangeMax() > 1)))){
return (true);
};
return (false);
}
public function getController():Controller{
return (controller);
}
public function getGameUnit():GameUnit{
return (gameUnit);
}
public function getWeaponRangeMax():Number{
return (unitData.getWeaponRangeMax());
}
public function isInActionQueue():Boolean{
var am:ActionManager = ActionManager.getInstance();
if (am.hasActionWithUnit(this)){
return (true);
};
return (false);
}
public function setController(a_controller:Controller):void{
if (((((!((controller == null))) && (!((a_controller == null))))) && (!((controller == a_controller))))){
throw (new Error("Unit::Setting controller to controlled unit"));
};
controller = a_controller;
}
public function darken():void{
if (isCloaked()){
if (getController() != null){
getGameUnit().transform.colorTransform = new ColorTransform(0.6, 0.6, 0.6, getController().getCloakVisibility());
} else {
getGameUnit().transform.colorTransform = new ColorTransform(0.6, 0.6, 0.6, 0);
};
} else {
getGameUnit().transform.colorTransform = new ColorTransform(0.6, 0.6, 0.6);
};
getGameUnit().setIdle(true);
}
public function isUpgraded():Boolean{
return (!((vehicle == null)));
}
public function getHealthPercentage():Number{
return ((health / unitData.getHealth()));
}
public function isRepairing():Boolean{
return (repairing);
}
public function setCloaked(a_cloaked:Boolean, a_alphaOnly:Boolean=false, a_animate:Boolean=true):void{
if (a_alphaOnly){
if (cloaked){
gameUnit.alpha = controller.getCloakVisibility();
miniMapSprite.alpha = controller.getCloakVisibility();
} else {
gameUnit.alpha = 1;
miniMapSprite.alpha = 1;
};
return;
};
var oldCloak:Boolean = cloaked;
cloaked = a_cloaked;
if (!cloaked){
if (oldCloak != cloaked){
if (a_animate){
TweenManager.getInstance().add(new Tween(gameUnit, Quad.easeIn, ["alpha"], [controller.getCloakVisibility()], [1], 500), TweenManager.SEQUENTIAL);
SoundSystem.instance.playSound(SoundSystem.instance.createSound("Cloak"));
} else {
gameUnit.alpha = controller.getCloakVisibility();
};
miniMapSprite.alpha = 1;
};
} else {
if (controller != null){
if (((!((oldCloak == cloaked))) || (!((gameUnit.alpha == controller.getCloakVisibility()))))){
if (a_animate){
TweenManager.getInstance().add(new Tween(gameUnit, Quad.easeIn, ["alpha"], [1], [controller.getCloakVisibility()], 500), TweenManager.SEQUENTIAL);
SoundSystem.instance.playSound(SoundSystem.instance.createSound("Decloak"));
} else {
gameUnit.alpha = controller.getCloakVisibility();
};
miniMapSprite.alpha = controller.getCloakVisibility();
};
};
};
}
public function getChunks(a_maxChunks:int=4):int{
if (health < 1){
return (0);
};
var chunk:int = Math.ceil(((health / unitData.getHealth()) * a_maxChunks));
return (chunk);
}
public function getBaseUnitData():UnitData{
return (baseUnitData);
}
public function setX(a_x:int):void{
x = a_x;
gameUnit.x = (x * TileManager.getInstance().getWidth());
miniMapSprite.x = (x * TileManager.getInstance().getMiniMapWidth());
}
public function setY(a_y:int):void{
y = a_y;
gameUnit.y = (y * TileManager.getInstance().getHeight());
miniMapSprite.y = (y * TileManager.getInstance().getMiniMapHeight());
}
public function hasMoved():Boolean{
return (moved);
}
public function upgrade(a_vehicle:GameSprite, a_unitData:UnitData):void{
if (vehicle != null){
throw (new Error("Unit::Trying to upgrade a unit which is already upgraded"));
};
var thumbnail:GameSprite = this.getGameUnit().getSprite().clone();
vehicle = a_vehicle;
gameUnit.upgrade(vehicle);
var healthPercentage:Number = (health / unitData.getHealth());
unitData = a_unitData;
health = (unitData.getHealth() * healthPercentage);
thumbnail.scaleX = 0.4;
thumbnail.scaleY = 0.4;
thumbnail.x = 0;
thumbnail.y = ((1 - thumbnail.scaleX) * BattalionMain.TILE_HEIGHT);
var thumbnailBG:Sprite = new Sprite();
thumbnailBG.name = "thumbnail";
thumbnailBG.graphics.lineStyle(1, 0, 0.85);
thumbnailBG.graphics.beginFill(0xF5F5F5, 0.85);
thumbnailBG.graphics.drawRect(thumbnail.x, thumbnail.y, thumbnail.width, thumbnail.height);
thumbnailBG.addChild(thumbnail);
thumbnailBG.filters = [new DropShadowFilter()];
gameUnit.addChild(thumbnailBG);
}
public function canMove():Boolean{
return ((getRange() > 0));
}
public function getX():int{
return (x);
}
public function getY():int{
return (y);
}
public function getUnitData():UnitData{
return (unitData);
}
public function setDeployed(a_deployed:Boolean):void{
deployed = a_deployed;
}
public function showText(a_string:String, a_color:uint=0xFFFFFF):void{
if (!Tile.k_allowDebugTextfield){
return;
};
m_textField.textColor = a_color;
m_textField.text = a_string;
m_textField.parent.setChildIndex(m_textField, (m_textField.parent.numChildren - 1));
}
public function getAttackDamage(a_defenderArmorType:int):Number{
var damage:Number = getUnitData().applyModifiers("damage", this, getUnitData().getDamage());
var scale:Number = (getChunks(GameManager.UNIT_CHUNKS) / GameManager.UNIT_CHUNKS);
var damageScale:Number = GameManager.getInstance().getBallisticsModifier(getUnitData().getWeaponType(), a_defenderArmorType);
return (((damage * damageScale) * scale));
}
public function reset():void{
if (!disabled){
moved = false;
fired = false;
getGameUnit().setIdle(false);
} else {
moved = true;
fired = true;
getGameUnit().setIdle(true);
};
}
public function getHealth():Number{
return (health);
}
public function takeDamage(a_damage:Number):void{
health = (health - a_damage);
gameUnit.setHealth((health / unitData.getHealth()));
}
public function setFired(a_fired:Boolean):void{
fired = a_fired;
}
public function isAlive():Boolean{
if (Math.floor(health) > 0){
return (true);
};
return (false);
}
public function clone():Unit{
return (new Unit((gameUnit.clone() as GameUnit), unitData.clone(), x, y, controller));
}
public function isAvailable():Boolean{
return (((((((!(hasMoved())) && (!(hasFired())))) && (!(disabled)))) && (!(isInActionQueue()))));
}
public function isCloaked():Boolean{
return (cloaked);
}
public function setMiniMapSprite(a_sprite:TileSheet):void{
miniMapSprite = a_sprite;
miniMapSprite.x = (x * TileManager.getInstance().getMiniMapWidth());
miniMapSprite.y = (y * TileManager.getInstance().getMiniMapHeight());
}
public function toString():String{
var r:String = ((((("[" + baseUnitData.toString()) + ": ") + x) + ",") + y);
if (isUpgraded()){
r = (r + " (transported)");
};
r = (r + " ]");
return (r);
}
public function setHealth(a_health:Number):void{
health = a_health;
gameUnit.setHealth((health / unitData.getHealth()));
}
public function setMoved(a_moved:Boolean):void{
moved = a_moved;
}
public function setRepairing(a_repairing:Boolean):void{
repairing = a_repairing;
gameUnit.setRepair(a_repairing);
}
public function getMiniMapSprite():TileSheet{
return (miniMapSprite);
}
public function downgrade():void{
if (vehicle == null){
throw (new Error("Unit::Trying to downgrade a unit which is not upgraded"));
};
var thumbnail:DisplayObject = gameUnit.getChildByName("thumbnail");
gameUnit.removeChild(thumbnail);
gameUnit.downgrade();
vehicle = null;
var healthPercentage:Number = (health / unitData.getHealth());
unitData = baseUnitData;
health = (unitData.getHealth() * healthPercentage);
}
public function healDamage(a_health:Number):void{
health = (health + a_health);
if (health > unitData.getHealth()){
health = unitData.getHealth();
};
gameUnit.setHealth((health / unitData.getHealth()));
}
}
}//package com.gamedozer.battalion.data
Section 30
//UnitData (com.gamedozer.battalion.data.UnitData)
package com.gamedozer.battalion.data {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.gamedozer.battalion.game.*;
public class UnitData {
protected var description:String;
protected var movementType:int;
protected var name:String;
protected var weaponRangeMin:int;
protected var armorType:int;
protected var weaponRangeMax:int;
protected var temporaryModifiers:Array;
protected var range:Number;
protected var sprite:String;
protected var cost:int;
protected var health:Number;
protected var unitType:int;
protected var damage:Number;
protected var weaponType:int;
protected var audioProfile:String;
protected var modifiers:Array;
public static const titleWeaponTypes:Array = ["None", "Light", "Medium", "Heavy"];
public static const descriptionWeaponTypes:Array = ["This unit cannot fire.", "This unit's attack is effective against lightly armored targets, but is ineffective against heavily armored targets.", "This unit's attack is equally as effective against all types of armor.", "This unit's attack is effective against heavily armored targets, but is very ineffective against lightly armored targets."];
public static const movementTypes:Array = ["none", "feet", "wheeled", "tracked", "rudder", "wings"];
public static const descriptionMovementTypes:Array = ["This unit cannot move.", "Even though Foot based units can climb Mountains, they generally suffer from reduced mobility.", "Wheeled units do fine on Roads and Bridges, but tend to suffer from reduced mobility on other terrain types.", "Tracked units are the most versatile ground units. They can cross most types of terrain quickly.", "Rudder based units are generally restricted to Sea and Shore tiles.", "There are few terrain tiles that can inhibit the movement of aircraft."];
public static const titleMovementTypes:Array = ["None", "Feet", "Wheeled", "Tracked", "Rudder", "Wings"];
public static const unitTypes:Array = ["none", "ground", "sea", "air"];
public static const descriptionArmorTypes:Array = ["This unit has no armor.", "Light armor is effective at deflecting Heavy attacks, but is susceptible to Light attacks.", "Medium armor is equally effective at deflecting Light, Medium and Heavy weapons.", "Heavy armor is susceptible to Heavy attacks, but is effective at absorbing damage from Light attacks."];
public static const titleArmorTypes:Array = ["None", "Light", "Medium", "Heavy"];
public static const armorTypes:Array = ["none", "light", "medium", "heavy"];
public static const weaponTypes:Array = ["none", "light", "medium", "heavy"];
public function UnitData(a_name:String, a_sprite:String, a_cost:int, a_range:Number, a_health:Number, a_damage:Number, a_weaponRangeMin:int, a_weaponRangeMax:int, a_unitType:int, a_movementType:int, a_weaponType:int, a_armorType:int, a_audioProfile:String, a_description:String){
super();
sprite = a_sprite;
name = a_name;
cost = a_cost;
range = a_range;
health = a_health;
damage = a_damage;
description = a_description;
weaponRangeMin = a_weaponRangeMin;
weaponRangeMax = a_weaponRangeMax;
unitType = a_unitType;
movementType = a_movementType;
weaponType = a_weaponType;
armorType = a_armorType;
audioProfile = a_audioProfile;
modifiers = new Array();
temporaryModifiers = new Array();
}
public function getName():String{
return (name);
}
public function removeModifier(a_modifier:Modifier):void{
var i:int = (modifiers.length - 1);
while (i >= 0) {
if (modifiers[i] == a_modifier){
modifiers.splice(i, 1);
return;
};
i--;
};
}
public function getRange():Number{
return (range);
}
public function getWeaponRangeMin():int{
return (weaponRangeMin);
}
public function addModifier(a_modifier:Modifier):void{
modifiers.push(a_modifier);
}
public function getWeaponRangeMax():int{
return (weaponRangeMax);
}
public function getTemporaryModifiers():Array{
return (temporaryModifiers);
}
public function removeTemporaryModifier(a_modifier:Modifier):void{
var i:int = (temporaryModifiers.length - 1);
while (i >= 0) {
if (temporaryModifiers[i] == a_modifier){
temporaryModifiers.splice(i, 1);
return;
};
i--;
};
}
public function addTemporaryModifier(a_modifier:Modifier):void{
temporaryModifiers.push(a_modifier);
}
public function hasModifier(a_name:String):Boolean{
var i:int;
while (i < modifiers.length) {
if (modifiers[i].getName().toLowerCase() == a_name.toLowerCase()){
return (true);
};
i++;
};
i = 0;
while (i < temporaryModifiers.length) {
if (temporaryModifiers[i].getName().toLowerCase() == a_name.toLowerCase()){
return (true);
};
i++;
};
return (false);
}
public function applyModifiers(a_type:String, a_unit:Unit, a_value:Number):Number{
var i:int;
while (i < modifiers.length) {
a_value = modifiers[i].apply(a_type, a_unit, a_value);
i++;
};
i = 0;
while (i < temporaryModifiers.length) {
a_value = temporaryModifiers[i].apply(a_type, a_unit, a_value);
i++;
};
return (a_value);
}
public function getSprite():String{
return (sprite);
}
public function isAir():Boolean{
if (unitType == 3){
return (true);
};
return (false);
}
public function playSound(a_type:String):void{
var audioProfile:AudioProfile = AudioProfile.getProfile(audioProfile);
if (audioProfile != null){
audioProfile.playSound(a_type);
};
}
public function getCost(a_controller:Controller=null):int{
var rcost:Number = cost;
if (a_controller == null){
return (rcost);
};
if (isGround()){
rcost = (rcost * a_controller.getGroundCost());
} else {
if (isAir()){
rcost = (rcost * a_controller.getAirCost());
} else {
if (isSea()){
rcost = (rcost * a_controller.getSeaCost());
};
};
};
return (Math.round(rcost));
}
public function isSea():Boolean{
if (unitType == 2){
return (true);
};
return (false);
}
public function isGround():Boolean{
if (unitType == 1){
return (true);
};
return (false);
}
public function getHealth():Number{
return (health);
}
public function getUnitType():int{
return (unitType);
}
public function getDescription():String{
return (description);
}
public function clearTemporaryModifiers():void{
temporaryModifiers = new Array();
}
public function clone():UnitData{
var stats:UnitData = new UnitData(name, sprite, cost, range, health, damage, weaponRangeMin, weaponRangeMax, unitType, movementType, weaponType, armorType, audioProfile, description);
var i:int;
while (i < modifiers.length) {
stats.addModifier(modifiers[i]);
i++;
};
return (stats);
}
public function getAllModifiers():Array{
return (modifiers.concat(temporaryModifiers));
}
public function getArmorType():int{
return (armorType);
}
public function getModifiers():Array{
return (modifiers);
}
public function getWeaponType():int{
return (weaponType);
}
public function getDamage():Number{
return (damage);
}
public function toString():String{
return ((("<" + name) + ">"));
}
public function getMovementType():int{
return (movementType);
}
public static function unitTypeFromString(a_type:String):int{
var i:int;
while (i < unitTypes.length) {
if (a_type.toLowerCase() == unitTypes[i].toLowerCase()){
return (i);
};
i++;
};
throw (new Error(("UnitData::Invalid unit type." + a_type)));
}
public static function armorTypeFromString(a_type:String):int{
var i:int;
while (i < armorTypes.length) {
if (a_type.toLowerCase() == armorTypes[i].toLowerCase()){
return (i);
};
i++;
};
throw (new Error(("UnitData::Invalid armor type." + a_type)));
}
public static function movementTypeFromString(a_type:String):int{
var i:int;
while (i < movementTypes.length) {
if (a_type.toLowerCase() == movementTypes[i].toLowerCase()){
return (i);
};
i++;
};
throw (new Error(("UnitData::Invalid movement type." + a_type)));
}
public static function weaponTypeFromString(a_type:String):int{
var i:int;
while (i < weaponTypes.length) {
if (a_type.toLowerCase() == weaponTypes[i].toLowerCase()){
return (i);
};
i++;
};
throw (new Error(("UnitData::Invalid weapon type. " + a_type)));
}
}
}//package com.gamedozer.battalion.data
Section 31
//UnitManager (com.gamedozer.battalion.data.UnitManager)
package com.gamedozer.battalion.data {
import flash.display.*;
import flash.utils.*;
public class UnitManager {
protected var units:Dictionary;
private static var singleton:UnitManager;
public function UnitManager(){
super();
singleton = this;
units = new Dictionary();
}
public function add(a_units:UnitData):void{
units[a_units.getName()] = a_units;
}
public function importXML(a_xml:XML):void{
var unit:UnitData;
var modifiers:XMLList;
var j:int;
if (a_xml == null){
return;
};
var unitsList:XMLList = a_xml..unit;
var i:int;
while (i < unitsList.length()) {
unit = new UnitData(unitsList[i].@name, unitsList[i].sprite.@value, int(unitsList[i].cost.@value), Number(unitsList[i].range.@value), Number(unitsList[i].health.@value), Number(unitsList[i].damage.@value), int(unitsList[i].weaponRangeMin.@value), int(unitsList[i].weaponRangeMax.@value), UnitData.unitTypeFromString(unitsList[i].unitType.@value), UnitData.movementTypeFromString(unitsList[i].movementType.@value), UnitData.weaponTypeFromString(unitsList[i].weaponType.@value), UnitData.armorTypeFromString(unitsList[i].armorType.@value), unitsList[i].audio.@value, unitsList[i].description.@value);
modifiers = unitsList[i]..modifier;
j = 0;
while (j < modifiers.length()) {
if (modifiers[j].@type != ""){
unit.addModifier(ModifierManager.getInstance().get(modifiers[j].@type));
};
j++;
};
units[unit.getName()] = unit;
i++;
};
}
public function remove(a_units:UnitData):void{
delete units[a_units.getName()];
}
public function get(a_name:String):UnitData{
if (units[a_name] == null){
trace(("UnitManager::Could not get unit: " + a_name));
return (null);
};
return (units[a_name].clone());
}
public function getAll():Array{
var unit:UnitData;
var allUnits:Array = new Array();
for each (unit in units) {
allUnits.push(unit);
};
return (allUnits);
}
public function clear():void{
units = new Dictionary();
}
public static function getInstance():UnitManager{
if (singleton == null){
trace("UnitManager::No instance exists");
};
return (singleton);
}
}
}//package com.gamedozer.battalion.data
Section 32
//Tween (com.gamedozer.battalion.display.tween.Tween)
package com.gamedozer.battalion.display.tween {
import com.gamedozer.battalion.display.*;
public class Tween implements TweenInterface {
private var start:Array;
private var timer:uint;
private var decoyObject:Object;
private var tweenMethod:Function;
private var time:uint;
private var change:Array;
private var variable:Array;
private var object;
public function Tween(a_object, a_tweenMethod:Function, a_variable:Array, a_start:Array, a_end:Array, a_time:uint, a_decoyObject:Object=null){
super();
object = a_object;
tweenMethod = a_tweenMethod;
variable = a_variable;
start = a_start;
change = new Array();
var i:int;
while (i < variable.length) {
change[i] = (a_end[i] - start[i]);
i++;
};
time = a_time;
timer = 0;
decoyObject = a_decoyObject;
}
public function isCompleted():Boolean{
return ((timer >= time));
}
public function update(a_ms:uint=0):void{
timer = (timer + a_ms);
if (timer > time){
timer = time;
};
var i:int;
while (i < variable.length) {
object[variable[i]] = tweenMethod(timer, start[i], change[i], time);
i++;
};
}
public function getObject():Object{
if (decoyObject != null){
return (decoyObject);
};
return (object);
}
}
}//package com.gamedozer.battalion.display.tween
Section 33
//TweenAnimation (com.gamedozer.battalion.display.tween.TweenAnimation)
package com.gamedozer.battalion.display.tween {
import com.gamedozer.battalion.display.*;
public class TweenAnimation implements TweenInterface {
var animation:String;
var animatedSprite:AnimatedSprite;
var completed:Boolean;
var decoyObject:Object;
var wait:Boolean;
var triggered:Boolean;
public function TweenAnimation(a_animatedSprite:AnimatedSprite, a_animation:String, a_wait:Boolean=false, a_decoyObject:Object=null){
super();
animatedSprite = a_animatedSprite;
animation = a_animation;
decoyObject = a_decoyObject;
completed = false;
wait = a_wait;
triggered = false;
}
public function isCompleted():Boolean{
return (completed);
}
public function update(a_ms:uint=0):void{
if (!triggered){
animatedSprite.playAnimation(animation);
triggered = true;
};
if (wait){
completed = animatedSprite.getCurrentAnimation().isCompleted();
} else {
completed = true;
};
}
public function getObject():Object{
if (decoyObject != null){
return (decoyObject);
};
return (animatedSprite);
}
}
}//package com.gamedozer.battalion.display.tween
Section 34
//TweenDisplay (com.gamedozer.battalion.display.tween.TweenDisplay)
package com.gamedozer.battalion.display.tween {
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
public class TweenDisplay implements TweenInterface {
protected var add:Boolean;
protected var depth:int;
protected var completed:Boolean;
protected var decoyObject:Object;
protected var gameSprite:GameSprite;
public function TweenDisplay(a_gameSprite:GameSprite, a_add:Boolean, a_depth:int=0, a_decoyObject:Object=null){
super();
gameSprite = a_gameSprite;
depth = a_depth;
add = a_add;
decoyObject = a_decoyObject;
completed = false;
}
public function isCompleted():Boolean{
return (completed);
}
public function update(a_ms:uint=0):void{
if (add){
GameManager.getInstance().getGameSpriteScroller().add(gameSprite, depth);
} else {
GameManager.getInstance().getGameSpriteScroller().remove(gameSprite);
};
completed = true;
}
public function getObject():Object{
if (decoyObject != null){
return (decoyObject);
};
return (gameSprite);
}
}
}//package com.gamedozer.battalion.display.tween
Section 35
//TweenFunction (com.gamedozer.battalion.display.tween.TweenFunction)
package com.gamedozer.battalion.display.tween {
import com.gamedozer.battalion.display.*;
public class TweenFunction implements TweenInterface {
private var func:Function;
private var decoyObject:Object;
private var completed:Boolean;
public function TweenFunction(a_function:Function, a_decoyObject:Object=null){
super();
func = a_function;
decoyObject = a_decoyObject;
completed = false;
}
public function isCompleted():Boolean{
return (completed);
}
public function update(a_ms:uint=0):void{
func();
completed = true;
}
public function getObject():Object{
if (decoyObject != null){
return (decoyObject);
};
return ((func as Object));
}
}
}//package com.gamedozer.battalion.display.tween
Section 36
//AnimatedSprite (com.gamedozer.battalion.display.AnimatedSprite)
package com.gamedozer.battalion.display {
public interface AnimatedSprite {
function playAnimation(:String):void;
function getCurrentAnimation():Animation;
function addAnimation(:Animation):void;
function setFrame(:int):void;
function getAnimation(a_frame:String):Animation;
}
}//package com.gamedozer.battalion.display
Section 37
//Animation (com.gamedozer.battalion.display.Animation)
package com.gamedozer.battalion.display {
public class Animation {
protected var timer:int;
protected var maxLoops:int;
protected var loops:int;
protected var name:String;
protected var frames:Array;
protected var playing:Boolean;
protected var currentFrame:int;
public static const LOOP_ONCE:int = 0;
public static const LOOP_FOREVER:int = -1;
public function Animation(a_name:String="", a_loops:int=-1){
super();
name = a_name;
frames = new Array();
loops = 0;
maxLoops = a_loops;
playing = true;
currentFrame = 0;
timer = 0;
}
public function getName():String{
return (name);
}
public function stop():void{
playing = false;
}
public function isCompleted():Boolean{
if (maxLoops == LOOP_FOREVER){
return (true);
};
if ((((loops == maxLoops)) && ((currentFrame == (frames.length - 1))))){
return (true);
};
return (false);
}
public function update(a_ms:int):Boolean{
if (!playing){
return (false);
};
timer = (timer + a_ms);
if (timer >= frames[currentFrame].wait){
timer = (timer - frames[currentFrame].wait);
return (nextFrame());
};
return (false);
}
public function addFrame(a_frame:int, a_wait:int=2147483647):void{
frames.push(new Frame(a_frame, a_wait));
}
public function gotoAndPlay(a_frame:int):void{
if ((((a_frame >= 0)) && ((a_frame < frames.length)))){
currentFrame = a_frame;
play();
};
}
public function clone():Animation{
var a:Animation = new Animation(name, maxLoops);
var i:int;
while (i < frames.length) {
a.addFrame(frames[i].frame, frames[i].wait);
i++;
};
return (a);
}
public function gotoAndStop(a_frame:int):void{
gotoAndPlay(a_frame);
stop();
}
public function reset():void{
loops = 0;
currentFrame = 0;
timer = 0;
playing = true;
}
public function getCurrentFrame():int{
return (currentFrame);
}
public function isPlaying():Boolean{
return (playing);
}
public function play():void{
playing = true;
}
public function previousFrame():void{
currentFrame--;
if (currentFrame < 0){
currentFrame = (frames.length - 1);
};
}
public function getFrame():int{
if ((((((frames == null)) || ((frames.length == 0)))) || ((frames[currentFrame] == null)))){
trace("Animation.getFrame. Corrupt animation.");
return (0);
};
return (frames[currentFrame].frame);
}
public function nextFrame():Boolean{
currentFrame++;
if (currentFrame > (frames.length - 1)){
if (playing){
if ((((loops < maxLoops)) || ((maxLoops == LOOP_FOREVER)))){
if (!(maxLoops) == LOOP_FOREVER){
loops++;
};
currentFrame = 0;
return (true);
};
playing = false;
return (false);
} else {
currentFrame = 0;
};
};
return (true);
}
}
}//package com.gamedozer.battalion.display
class Frame {
public var wait:int;
public var frame:int;
private function Frame(a_frame:int, a_wait:int){
super();
frame = a_frame;
wait = a_wait;
}
}
Section 38
//BitmapSprite (com.gamedozer.battalion.display.BitmapSprite)
package com.gamedozer.battalion.display {
import flash.display.*;
public class BitmapSprite extends GameSprite {
protected var image:Bitmap;
public function BitmapSprite(a_base:BitmapData){
super();
image = new Bitmap(a_base);
addChild(image);
}
public function getImage():BitmapData{
return (image.bitmapData);
}
public function setImage(a_base:BitmapData):void{
removeChild(image);
image = new Bitmap(a_base);
addChild(image);
}
override public function clone():GameSprite{
var b:BitmapSprite = new BitmapSprite(image.bitmapData);
return (b);
}
}
}//package com.gamedozer.battalion.display
Section 39
//ColoredSprite (com.gamedozer.battalion.display.ColoredSprite)
package com.gamedozer.battalion.display {
import flash.display.*;
import flash.geom.*;
public class ColoredSprite extends GameSprite {
protected var imageData:BitmapData;
protected var imageMask:BitmapData;
protected var imageBase:BitmapData;
protected var imageBlendMode:String;
protected var image:Bitmap;
protected var imageArgb:uint;
public function ColoredSprite(a_base:BitmapData, a_mask:BitmapData=null, a_argb:uint=4294967295, a_blendMode:String="overlay"){
super();
image = new Bitmap();
setImage(a_base, a_mask, a_argb, a_blendMode);
addChild(image);
}
public function setImage(a_base:BitmapData, a_mask:BitmapData=null, a_argb:uint=4294967295, a_blendMode:String="overlay"):void{
imageBase = a_base;
imageMask = a_mask;
imageArgb = a_argb;
imageBlendMode = a_blendMode;
imageData = colorise(imageBase, imageMask, imageArgb, imageBlendMode);
image.bitmapData = imageData;
}
public function setColor(a_argb:uint=4294967295):void{
imageArgb = a_argb;
imageData = colorise(imageBase, imageMask, imageArgb, imageBlendMode);
image.bitmapData = imageData;
}
public function getImage():BitmapData{
return (image.bitmapData);
}
override public function clone():GameSprite{
var c:ColoredSprite = new ColoredSprite(imageBase, imageMask, imageArgb, imageBlendMode);
return (c);
}
public static function colorise(a_imageBase:BitmapData, a_imageMask:BitmapData=null, a_imageArgb:uint=4294967295, a_imageBlendMode:String="overlay"):BitmapData{
var newImage:BitmapData = new BitmapData(a_imageBase.width, a_imageBase.height, a_imageBase.transparent);
newImage.copyPixels(a_imageBase, a_imageBase.rect, new Point(0, 0));
if (a_imageMask == null){
a_imageMask = new BitmapData(a_imageBase.width, a_imageBase.height, false, 4294967295);
};
var a:Number = (((a_imageArgb & 4278190080) >>> 24) / 0xFF);
var r:Number = (((a_imageArgb & 0xFF0000) >> 16) / 0xFF);
var g:Number = (((a_imageArgb & 0xFF00) >> 8) / 0xFF);
var b:Number = ((a_imageArgb & 0xFF) / 0xFF);
newImage.draw(a_imageMask, null, new ColorTransform(r, g, b, a, 0, 0, 0, 0), a_imageBlendMode);
return (newImage);
}
}
}//package com.gamedozer.battalion.display
Section 40
//GameButton (com.gamedozer.battalion.display.GameButton)
package com.gamedozer.battalion.display {
import flash.events.*;
import com.gamedozer.battalion.*;
import flash.filters.*;
public class GameButton extends GameSprite {
public var release:Function;
protected var m_glowOnRollover:Boolean;
public var value;
protected var cursor:String;
public var mouseOver:Function;
public function GameButton(a_sprite:GameSprite, a_cursor:String="default", a_glowOnRollover:Boolean=false){
super();
cursor = a_cursor;
m_glowOnRollover = a_glowOnRollover;
addChild(a_sprite);
addEventListener(MouseEvent.CLICK, clickHandler);
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
}
override public function clone():GameSprite{
var b:GameButton = new GameButton((getChildAt(0) as GameSprite));
b.value = value;
b.release = release;
b.mouseOver = mouseOver;
return (b);
}
function unglow():void{
this.filters = [];
}
function clickHandler(a_event:Event):void{
if (release != null){
release();
};
}
function glow():void{
this.filters = [new GlowFilter(0)];
}
public function setCursor(a_cursor:String):void{
cursor = a_cursor;
}
function outHandler(a_event:Event):void{
BattalionMain.getMouseCursor().setCursor("default");
if (m_glowOnRollover){
unglow();
};
}
function overHandler(a_event:Event):void{
if (cursor != null){
BattalionMain.getMouseCursor().setCursor(cursor);
};
if (mouseOver != null){
mouseOver();
};
if (m_glowOnRollover){
glow();
};
}
public function turnOffGlow():void{
unglow();
m_glowOnRollover = false;
}
}
}//package com.gamedozer.battalion.display
Section 41
//GameSprite (com.gamedozer.battalion.display.GameSprite)
package com.gamedozer.battalion.display {
import flash.display.*;
public class GameSprite extends Sprite {
public function GameSprite(){
super();
}
public function update(a_ms:int=0):void{
}
public function clone():GameSprite{
var g:GameSprite = new GameSprite();
return (g);
}
}
}//package com.gamedozer.battalion.display
Section 42
//GameSpriteScroller (com.gamedozer.battalion.display.GameSpriteScroller)
package com.gamedozer.battalion.display {
import flash.display.*;
import com.gamedozer.battalion.data.*;
import flash.geom.*;
import flash.utils.*;
public class GameSpriteScroller extends Sprite {
protected var layers:Array;
protected var oldX:Number;
protected var oldY:Number;
protected var screenHeight:int;
protected var screenWidth:int;
protected var gameSprites:Array;
public static const BELOW_UNITS:int = 2;
public static const TILES:int = 0;
public static const BUTTONS:int = 6;
public static const BOTTOM:int = 1;
public static const ABOVE_UNITS:int = 4;
public static const UNITS:int = 3;
public static const TOP:int = 5;
public static const LAYERS:int = 8;
public static const ABOVE_ALL:int = 7;
public function GameSpriteScroller(a_screenWidth:Number, a_screenHeight:Number){
super();
screenWidth = a_screenWidth;
screenHeight = a_screenHeight;
oldX = Number.POSITIVE_INFINITY;
oldY = Number.POSITIVE_INFINITY;
gameSprites = new Array();
layers = new Array();
var i:int;
while (i < LAYERS) {
gameSprites[i] = new Array();
layers[i] = new Sprite();
addChild(layers[i]);
i++;
};
layers[(LAYERS - 1)].mouseEnabled = false;
}
public function add(a_gameSprite:GameSprite, a_depth:int):void{
gameSprites[a_depth].push(a_gameSprite);
layers[a_depth].addChild(a_gameSprite);
oldX = Number.POSITIVE_INFINITY;
oldY = Number.POSITIVE_INFINITY;
}
public function lock(a_width:Number, a_height:Number):void{
if (x < (-(a_width) + screenWidth)){
x = (-(a_width) + screenWidth);
};
if (y < (-(a_height) + screenHeight)){
y = (-(a_height) + screenHeight);
};
if (x > 0){
x = 0;
};
if (y > 0){
y = 0;
};
}
public function scroll(forceScroll:Boolean=false):void{
var gameSpriteLayer:Array;
var gameSprite:GameSprite;
var gameSpriteXMax:Number;
var gameSpriteYMax:Number;
if ((((((x == oldX)) && ((y == oldY)))) && (!(forceScroll)))){
return;
};
oldX = x;
oldY = y;
var xMin:Number = -(x);
var yMin:Number = -(y);
var xMax:Number = (xMin + screenWidth);
var yMax:Number = ((yMin + screenHeight) + TileManager.getInstance().getHeight());
var depth:int;
for each (gameSpriteLayer in gameSprites) {
for each (gameSprite in gameSpriteLayer) {
gameSpriteXMax = (gameSprite.x + gameSprite.width);
gameSpriteYMax = (gameSprite.y + gameSprite.height);
if ((((((((gameSpriteXMax > xMin)) && ((gameSprite.x < xMax)))) && ((gameSpriteYMax > yMin)))) && ((gameSprite.y < yMax)))){
gameSprite.visible = true;
} else {
gameSprite.visible = false;
};
};
};
}
public function swapDepth(a_gameSprite:GameSprite, a_depth:int):void{
remove(a_gameSprite);
add(a_gameSprite, a_depth);
}
public function update(a_ms:uint):void{
var gameSpriteLayer:Array;
var gameSprite:GameSprite;
for each (gameSpriteLayer in gameSprites) {
for each (gameSprite in gameSpriteLayer) {
gameSprite.update(a_ms);
};
};
}
public function remove(a_gameSprite:GameSprite):void{
var gameSpriteLayer:Array;
var j:int;
var i:int;
while (i < LAYERS) {
gameSpriteLayer = gameSprites[i];
j = (gameSpriteLayer.length - 1);
while (j >= 0) {
if (gameSpriteLayer[j] == a_gameSprite){
layers[i].removeChild(a_gameSprite);
gameSpriteLayer.splice(j, 1);
return;
};
j--;
};
i++;
};
trace(("ERROR. GameSpriteScroller: Sprite not found: " + a_gameSprite));
}
}
}//package com.gamedozer.battalion.display
Section 43
//GameTile (com.gamedozer.battalion.display.GameTile)
package com.gamedozer.battalion.display {
import com.gamedozer.battalion.data.*;
public class GameTile extends GameSprite {
protected var sprite:GameSprite;
protected var flag:GameSprite;
protected var structure:GameSprite;
public function GameTile(a_sprite:GameSprite){
super();
sprite = a_sprite;
if (sprite.height > TileManager.getInstance().getHeight()){
sprite.y = -((sprite.height - TileManager.getInstance().getHeight()));
};
addChild(sprite);
}
override public function update(a_ms:int=0):void{
sprite.update(a_ms);
if (structure != null){
structure.update(a_ms);
};
if (flag != null){
flag.update(a_ms);
};
}
public function setFlag(a_flag:GameSprite):void{
if (flag != null){
removeChild(flag);
};
if (a_flag != null){
flag = a_flag;
addChild(flag);
};
}
public function setStructure(a_structure:GameSprite):void{
if (structure != null){
removeChild(structure);
};
if (a_structure != null){
structure = a_structure;
addChild(structure);
if (structure.height > TileManager.getInstance().getHeight()){
structure.y = (structure.y - (structure.height - TileManager.getInstance().getHeight()));
};
};
}
public function getSprite():GameSprite{
return (sprite);
}
override public function clone():GameSprite{
var t:GameTile = new GameTile(sprite.clone());
return (t);
}
}
}//package com.gamedozer.battalion.display
Section 44
//GameUnit (com.gamedozer.battalion.display.GameUnit)
package com.gamedozer.battalion.display {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
public class GameUnit extends GameSprite {
protected var bar:HealthBar;
protected var sprite:GameSprite;
protected var upgraded:GameSprite;
protected var repair:GameSprite;
protected var idle:Boolean;
public function GameUnit(a_sprite:GameSprite){
super();
sprite = a_sprite;
if (sprite.height > TileManager.getInstance().getHeight()){
sprite.y = -((sprite.height - TileManager.getInstance().getHeight()));
};
addChild(sprite);
repair = new BitmapSprite(BitmapLibrary.loadBitmap("repairIcon"));
repair.y = (TileManager.getInstance().getHeight() - repair.height);
repair.visible = false;
addChild(repair);
var padWidth:int;
var barWidth = 4;
var barHeight = 8;
bar = new HealthBar(barWidth, barHeight, padWidth);
bar.x = 48;
bar.y = 50;
addChild(bar);
idle = false;
}
public function setRepair(a_visible:Boolean):void{
repair.visible = a_visible;
}
override public function update(a_ms:int=0):void{
if (!idle){
if (upgraded != null){
upgraded.update(a_ms);
} else {
sprite.update(a_ms);
};
};
}
public function downgrade():void{
if (upgraded != null){
removeChild(upgraded);
upgraded = null;
};
}
public function setIdle(a_idle:Boolean):void{
idle = a_idle;
}
public function getSprite():GameSprite{
if (upgraded != null){
return (upgraded);
};
return (sprite);
}
public function upgrade(a_sprite:GameSprite):void{
if (upgraded == null){
a_sprite.x = 0;
a_sprite.y = 0;
if (a_sprite.height > TileManager.getInstance().getHeight()){
a_sprite.y = -((a_sprite.height - TileManager.getInstance().getHeight()));
};
upgraded = a_sprite;
addChildAt(upgraded, 1);
};
}
override public function clone():GameSprite{
var u:GameUnit = new GameUnit(sprite.clone());
return (u);
}
public function setHealth(a_health:Number):void{
bar.setHealth(a_health);
}
}
}//package com.gamedozer.battalion.display
Section 45
//HealthBar (com.gamedozer.battalion.display.HealthBar)
package com.gamedozer.battalion.display {
import flash.display.*;
public class HealthBar extends Sprite {
var m_chunkHeight:int;
var m_drawTarget:Sprite;
var m_chunkWidth:int;
var m_health:Number;
var m_chunkCount:int;
var m_padding:int;
public function HealthBar(a_chunkWidth:int, a_chunkHeight:int, a_padding:int, a_chunkCount:int=4){
super();
m_chunkCount = a_chunkCount;
m_chunkWidth = a_chunkWidth;
m_chunkHeight = a_chunkHeight;
m_padding = a_padding;
m_health = 1;
m_drawTarget = new Sprite();
m_drawTarget.cacheAsBitmap = true;
addChild(m_drawTarget);
m_drawTarget.scaleX = -1;
m_drawTarget.y = (m_drawTarget.y - m_chunkHeight);
setHealth(m_health);
}
public function setHealth(a_percentage:Number):void{
if (a_percentage > 1){
a_percentage = 1;
};
if (a_percentage < 0){
a_percentage = 0;
};
m_health = a_percentage;
redraw();
}
public function dispose():void{
}
function draw():void{
var x:int;
var chunkSize:Number;
var percentageOfThisBlock:Number;
var blockHeight:Number;
if (m_health >= 1){
return;
};
var color:uint;
if (m_health > 0.75){
color = 0xCE00;
} else {
if (m_health > 0.5){
color = 0xF9F900;
} else {
if (m_health > 0.25){
color = 16744964;
} else {
color = 0xF20000;
};
};
};
var visibleChunks:int = Math.ceil((m_health * m_chunkCount));
m_drawTarget.graphics.lineStyle(1);
m_drawTarget.graphics.beginFill(0);
var i:int;
while (i < m_chunkCount) {
x = ((m_chunkWidth + m_padding) * i);
m_drawTarget.graphics.drawRect(x, 0, m_chunkWidth, m_chunkHeight);
i++;
};
m_drawTarget.graphics.endFill();
m_drawTarget.graphics.lineStyle(0);
m_drawTarget.graphics.beginFill(color);
i = 0;
while (i < visibleChunks) {
x = ((m_chunkWidth + m_padding) * i);
if (i == (visibleChunks - 1)){
chunkSize = (1 / m_chunkCount);
percentageOfThisBlock = ((m_health % chunkSize) / chunkSize);
if (percentageOfThisBlock == 0){
percentageOfThisBlock = 1;
};
blockHeight = (m_chunkHeight * percentageOfThisBlock);
m_drawTarget.graphics.drawRect(x, (m_chunkHeight * (1 - percentageOfThisBlock)), m_chunkWidth, blockHeight);
} else {
m_drawTarget.graphics.drawRect(x, 0, m_chunkWidth, m_chunkHeight);
};
i++;
};
m_drawTarget.graphics.endFill();
}
function redraw():void{
m_drawTarget.graphics.clear();
draw();
}
}
}//package com.gamedozer.battalion.display
Section 46
//TileSheet (com.gamedozer.battalion.display.TileSheet)
package com.gamedozer.battalion.display {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class TileSheet extends GameSprite implements AnimatedSprite {
protected var display:Bitmap;
protected var currentAnimation:Animation;
protected var tileSheet:BitmapData;
protected var _noAnimation:Boolean;
protected var tileSheetMask:BitmapData;
protected var rectangles:Array;
protected var animations:Dictionary;
protected var currentFrame:int;// = -1
protected var tileHeight:int;
protected var tileWidth:int;
public function TileSheet(a_tileSheet:BitmapData, a_width:int, a_height:int, a_tileSheetMask:BitmapData=null){
var x:int;
var a_tileSheet = a_tileSheet;
var a_width = a_width;
var a_height = a_height;
var a_tileSheetMask = a_tileSheetMask;
super();
tileSheet = a_tileSheet;
tileWidth = a_width;
tileHeight = a_height;
tileSheetMask = a_tileSheetMask;
rectangles = new Array();
display = new Bitmap(tileSheet);
addChild(display);
var hit:Sprite = new Sprite();
var _local6 = hit.graphics;
with (_local6) {
beginFill(0, 0);
drawRect(0, 0, a_width, a_height);
endFill();
};
hit.mouseChildren = false;
hit.mouseEnabled = false;
addChild(hit);
hitArea = hit;
var y:int;
while (y < tileSheet.height) {
x = 0;
while (x < tileSheet.width) {
rectangles.push(new Rectangle(x, y, a_width, a_height));
x = (x + a_width);
};
y = (y + a_height);
};
if (rectangles.length < 1){
throw (new Error("TileSheet::Could not create tilesheet, image is too small"));
};
animations = new Dictionary();
var a:Animation = new Animation("default", Animation.LOOP_ONCE);
a.addFrame(0);
addAnimation(a);
currentAnimation = a;
setFrame(0);
}
public function getTileWidth():int{
return (tileWidth);
}
public function get noAnimation():Boolean{
return (_noAnimation);
}
override public function get width():Number{
return ((tileWidth * scaleX));
}
override public function clone():GameSprite{
var a:Animation;
var t:TileSheet = new TileSheet(tileSheet, tileWidth, tileHeight, tileSheetMask);
for each (a in animations) {
t.addAnimation(a.clone());
};
return (t);
}
public function set noAnimation(value:Boolean):void{
_noAnimation = value;
}
public function getAnimation(a_name:String):Animation{
return (animations[a_name]);
}
public function getCurrentAnimation():Animation{
return (currentAnimation);
}
public function getTileSheet():BitmapData{
return (tileSheet);
}
public function getFrames():int{
return (rectangles.length);
}
override public function update(a_ms:int=0):void{
if (noAnimation){
return;
};
currentAnimation.update(a_ms);
if (currentFrame != currentAnimation.getFrame()){
setFrame(currentAnimation.getFrame());
};
}
public function addAnimation(a_animation:Animation):void{
animations[a_animation.getName()] = a_animation;
}
override public function get height():Number{
return ((tileHeight * scaleY));
}
public function getTileHeight():int{
return (tileHeight);
}
override public function toString():String{
return (((((("TileSheet:: " + rectangles.length) + ":") + currentAnimation.getName()) + " >currentFrame ") + currentFrame));
}
public function getTileSheetMask():BitmapData{
return (tileSheetMask);
}
public function setTileSheet(a_tileSheet:BitmapData):void{
if ((((tileSheet.width == a_tileSheet.width)) && ((tileSheet.height == a_tileSheet.height)))){
tileSheet = a_tileSheet;
display.bitmapData = tileSheet;
};
}
public function setFrame(a_frame:int):void{
if ((((a_frame >= 0)) && ((a_frame < rectangles.length)))){
display.scrollRect = rectangles[a_frame];
currentFrame = a_frame;
};
}
public function playAnimation(a_name:String):void{
currentAnimation = getAnimation(a_name);
if (currentAnimation == null){
trace(("TileSheet::Could not play Animation:" + a_name));
currentAnimation = getAnimation("default");
};
currentAnimation.reset();
setFrame(currentAnimation.getFrame());
}
public function setTileSheetMask(a_tileSheetMask:BitmapData):void{
if (a_tileSheetMask == null){
tileSheetMask = null;
return;
};
if ((((tileSheetMask.width == a_tileSheetMask.width)) && ((tileSheetMask.height == a_tileSheetMask.height)))){
tileSheetMask = a_tileSheetMask;
};
}
}
}//package com.gamedozer.battalion.display
Section 47
//TileSheetManager (com.gamedozer.battalion.display.TileSheetManager)
package com.gamedozer.battalion.display {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import flash.utils.*;
public class TileSheetManager {
protected var tileSheets:Dictionary;
protected var stockAnimations:Dictionary;
protected var stockTileSheets:Dictionary;
private static var singleton:TileSheetManager;
public function TileSheetManager(){
super();
singleton = this;
tileSheets = new Dictionary();
stockAnimations = new Dictionary();
stockTileSheets = new Dictionary();
}
public function add(a_name:String, a_sprite:TileSheet):void{
if (tileSheets[a_name] == null){
tileSheets[a_name] = a_sprite;
};
}
public function remove(a_name:String):void{
delete tileSheets[a_name];
}
public function clear():void{
tileSheets = new Dictionary();
stockAnimations = new Dictionary();
stockTileSheets = new Dictionary();
}
public function importXML(a_xml:XML):void{
var a:Animation;
var frames:XMLList;
var defWait:int;
var j:int;
var name:String;
var wait:String;
var stockTileSheet:StockTileSheet;
var animations:XMLList;
var k:int;
var mask:BitmapData;
var maskName:String;
var newName:String;
var tileSheet:TileSheet;
if (a_xml == null){
return;
};
var stockAnimationsList:XMLList = a_xml.stockanimations..animation;
var i:int;
while (i < stockAnimationsList.length()) {
a = new Animation(stockAnimationsList[i].@name, int(stockAnimationsList[i].@loops));
frames = stockAnimationsList[i]..frame;
defWait = int(stockAnimationsList[i].@wait);
j = 0;
while (j < frames.length()) {
wait = frames[k].@wait;
if (wait != ""){
a.addFrame(int(frames[j].@frame), int(wait));
} else {
a.addFrame(int(frames[j].@frame), int(defWait));
};
j++;
};
name = stockAnimationsList[i].@name;
stockAnimations[name] = a;
i++;
};
var stockTileSheetsList:XMLList = a_xml.stocktilesheets..tilesheet;
i = 0;
while (i < stockTileSheetsList.length()) {
stockTileSheet = new StockTileSheet(stockTileSheetsList[i].@name, int(stockTileSheetsList[i].@width), int(stockTileSheetsList[i].@height));
stockAnimationsList = stockTileSheetsList[i]..stockanimation;
j = 0;
while (j < stockAnimationsList.length()) {
name = stockAnimationsList[j].@name;
stockTileSheet.addAnimation(stockAnimations[name].clone());
j++;
};
animations = stockTileSheetsList[i]..animation;
j = 0;
while (j < animations.length()) {
a = new Animation(animations[j].@name, parseInt(animations[j].@loops));
frames = animations[j]..frame;
defWait = parseInt(animations[j].@wait);
k = 0;
while (k < frames.length()) {
wait = frames[k].@wait;
if (wait != ""){
a.addFrame(int(frames[k].@frame), int(wait));
} else {
a.addFrame(int(frames[k].@frame), int(defWait));
};
k++;
};
stockTileSheet.addAnimation(a);
j++;
};
stockTileSheets[stockTileSheet.getName()] = stockTileSheet;
i++;
};
var stockTileSheetList:XMLList = a_xml.tilesheets..stocktilesheet;
i = 0;
while (i < stockTileSheetList.length()) {
name = stockTileSheetList[i].@stockname;
stockTileSheet = stockTileSheets[name];
mask = null;
maskName = stockTileSheetList[i].mask.@value;
if (maskName != ""){
mask = BitmapLibrary.loadBitmap(maskName);
};
newName = stockTileSheetList[i].@name;
tileSheets[newName] = stockTileSheet.getTileSheet(BitmapLibrary.loadBitmap(stockTileSheetList[i].image.@value), mask);
i++;
};
var tileSheetsList:XMLList = a_xml.tilesheets..tilesheet;
i = 0;
while (i < tileSheetsList.length()) {
mask = null;
maskName = tileSheetsList[i].mask.@value;
if (maskName != ""){
mask = BitmapLibrary.loadBitmap(maskName);
};
tileSheet = new TileSheet(BitmapLibrary.loadBitmap(tileSheetsList[i].image.@value), int(tileSheetsList[i].@width), int(tileSheetsList[i].@height), mask);
stockAnimationsList = tileSheetsList[i]..stockanimation;
j = 0;
while (j < stockAnimationsList.length()) {
name = stockAnimationsList[j].@name;
tileSheet.addAnimation(stockAnimations[name].clone());
j++;
};
animations = tileSheetsList[i]..animation;
j = 0;
while (j < animations.length()) {
a = new Animation(animations[j].@name, int(animations[j].@loops));
frames = animations[j]..frame;
defWait = int(animations[j].@wait);
k = 0;
while (k < frames.length()) {
wait = frames[k].@wait;
if (wait != ""){
a.addFrame(int(frames[k].@frame), int(wait));
} else {
a.addFrame(int(frames[k].@frame), int(defWait));
};
k++;
};
tileSheet.addAnimation(a);
j++;
};
name = tileSheetsList[i].@name;
tileSheets[name] = tileSheet;
i++;
};
}
public function get(a_name:String):TileSheet{
if (tileSheets[a_name] == null){
trace(("TileSheetManager::Could not get sprite: " + a_name));
if (tileSheets["error"] != null){
return ((tileSheets["error"].clone() as TileSheet));
};
throw (new Error("TileSheetManager::Could not get sprite, or default sprite"));
};
return ((tileSheets[a_name].clone() as TileSheet));
}
public function getColorised(a_name:String, a_argb:uint=4294967295):TileSheet{
var ts:TileSheet;
var b:BitmapData;
var bm:BitmapData;
var old:TileSheet = get(a_name);
if (old == null){
trace(("TileSheetManager::Could not get sprite: " + a_name));
return (null);
};
var fullname:String = (a_name + a_argb);
if ((((tileSheets[fullname] == null)) && (!((old.getTileSheetMask() == null))))){
ts = (old.clone() as TileSheet);
b = ts.getTileSheet();
bm = ts.getTileSheetMask();
ts.setTileSheet(ColoredSprite.colorise(b, bm, a_argb));
ts.setTileSheetMask(null);
tileSheets[fullname] = ts;
};
return (tileSheets[fullname].clone());
}
public static function getInstance():TileSheetManager{
if (singleton == null){
trace("TileSheetManager::No instance exists");
};
return (singleton);
}
}
}//package com.gamedozer.battalion.display
import flash.display.*;
class StockTileSheet {
private var width:int;
private var height:int;
private var name:String;
private var animations:Array;
private function StockTileSheet(a_name:String, a_width:int, a_height:int){
super();
name = a_name;
width = a_width;
height = a_height;
animations = new Array();
}
private function getName():String{
return (name);
}
private function addAnimation(a:Animation):void{
animations.push(a);
}
private function getTileSheet(a_bitmapData:BitmapData, a_mask:BitmapData):TileSheet{
var tileSheet:TileSheet = new TileSheet(a_bitmapData, width, height, a_mask);
var i:int;
while (i < animations.length) {
tileSheet.addAnimation(animations[i].clone());
i++;
};
return (tileSheet);
}
}
Section 48
//TileSwatch (com.gamedozer.battalion.display.TileSwatch)
package com.gamedozer.battalion.display {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import flash.geom.*;
import com.gamedozer.battalion.game.*;
public class TileSwatch {
protected var bitmaps:Array;
protected var imageCode:String;
protected var name:String;
public function TileSwatch(a_name:String, a_imageCode:String){
super();
if (a_name == "Hunter"){
a_name = "Hunter Support";
};
if (a_name == "Corvette"){
a_name = "Corvette Fighter";
};
name = a_name;
imageCode = a_imageCode;
generateTiles();
}
protected function generateMultipleTiles(a_filenames:String):void{
var filenames:Array = a_filenames.substring(2, (a_filenames.length - 1)).split(";");
var i:int;
while (i < filenames.length) {
generateTile(filenames[i]);
i++;
};
}
public function getName():String{
return (name);
}
public function getTeam():int{
if ((((imageCode.charAt(0) == "@")) || ((imageCode.charAt(0) == "%")))){
return (int(imageCode.charAt(2)));
};
return (0);
}
protected function generateTile(a_filename:String):void{
var className:String = a_filename.substring(0, a_filename.indexOf("."));
bitmaps.push(BitmapLibrary.loadBitmap(className));
}
protected function generateJoinedTile(a_filenames:String):void{
var filenames:Array = a_filenames.substring(2, (a_filenames.length - 1)).split(";");
if (filenames.length != 4){
return;
};
var i:int;
while (i < filenames.length) {
filenames[i] = filenames[i].substring(0, filenames[i].indexOf("."));
i++;
};
var instance:BitmapData = BitmapLibrary.loadBitmap(filenames[0]);
var image:BitmapData = new BitmapData((instance.width * 2), (instance.height * 2), instance.transparent);
var height:int = instance.height;
i = 0;
while (i < instance.width) {
image.copyPixels(instance, new Rectangle(i, 0, height, height), new Point((i * 2), 0));
i = (i + height);
};
instance = BitmapLibrary.loadBitmap(filenames[1]);
i = 0;
while (i < instance.width) {
image.copyPixels(instance, new Rectangle(i, 0, height, height), new Point(((i * 2) + height), 0));
i = (i + height);
};
instance = BitmapLibrary.loadBitmap(filenames[2]);
i = 0;
while (i < instance.width) {
image.copyPixels(instance, new Rectangle(i, 0, height, height), new Point((i * 2), height));
i = (i + height);
};
instance = BitmapLibrary.loadBitmap(filenames[3]);
i = 0;
while (i < instance.width) {
image.copyPixels(instance, new Rectangle(i, 0, height, height), new Point(((i * 2) + height), height));
i = (i + height);
};
bitmaps.push(image);
}
public function getImageCode():String{
return (imageCode);
}
protected function generateTiles():void{
var type:String;
bitmaps = new Array();
type = imageCode.charAt(0);
switch (type){
case "+":
generateJoinedTile(imageCode);
break;
case "?":
generateMultipleTiles(imageCode);
break;
case "@":
break;
case "%":
break;
default:
generateTile(imageCode);
break;
};
}
public function getSprite():GameSprite{
var ts:TileSheet;
var a:Animation;
var i:int;
var k_timeBetweenAnimations:int;
var bitmap:BitmapData = bitmaps[Math.floor((Math.random() * bitmaps.length))];
if (bitmap){
if (bitmap.width > 56){
ts = new TileSheet(bitmap, 56, bitmap.height);
a = new Animation("default", Animation.LOOP_FOREVER);
i = 0;
while (i < ts.getFrames()) {
k_timeBetweenAnimations = 500;
a.addFrame(i, k_timeBetweenAnimations);
i++;
};
ts.addAnimation(a);
ts.playAnimation("default");
return (ts);
} else {
return (new BitmapSprite(bitmap));
};
//unresolved jump
};
return (new GameSprite());
}
}
}//package com.gamedozer.battalion.display
Section 49
//TweenInterface (com.gamedozer.battalion.display.TweenInterface)
package com.gamedozer.battalion.display {
public interface TweenInterface {
function isCompleted():Boolean;
function update(C:\Documents and Settings\pany\My Documents\_unfuddle\_other\nemesis\flash;com\gamedozer\battalion\display;TweenInterface.as:uint=0):void;
function getObject():Object;
}
}//package com.gamedozer.battalion.display
Section 50
//TweenManager (com.gamedozer.battalion.display.TweenManager)
package com.gamedozer.battalion.display {
import flash.events.*;
import flash.utils.*;
public class TweenManager {
protected var dispatcher:EventDispatcher;
protected var tweens:Array;
protected var lastTimer:uint;
public static const SEQUENTIAL_ALL:int = 2;
public static const PARALLEL:int = 0;
public static const SEQUENTIAL:int = 1;
private static var singleton:TweenManager;
public function TweenManager(a_dispatcher:EventDispatcher){
super();
singleton = this;
tweens = new Array();
setDispatcher(a_dispatcher);
}
public function isTweened(a_object):Boolean{
var i:int;
while (i < tweens.length) {
if (tweens[i].tween.getObject() == a_object){
return (true);
};
i++;
};
return (false);
}
public function add(a_tween:TweenInterface, a_waitType:int=0):void{
tweens.push(new TweenHolder(a_tween, a_waitType));
}
public function isEmpty():Boolean{
return ((tweens.length == 0));
}
public function setDispatcher(a_dispatcher:EventDispatcher):void{
if (dispatcher != null){
dispatcher.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
};
dispatcher = a_dispatcher;
dispatcher.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function removeTweens(a_object):void{
var i:int = (tweens.length - 1);
while (i >= 0) {
if (tweens[i].tween.getObject() == a_object){
tweens.splice(i, 1);
};
i--;
};
}
public function clear():void{
tweens = new Array();
}
private function enterFrameHandler(a_event:Event):void{
var timer:int = getTimer();
var time:int = (timer - lastTimer);
lastTimer = timer;
update(time);
}
public function update(a_ms:uint=0):void{
var tween:TweenInterface;
var wait:int;
var objects:Dictionary = new Dictionary();
var tweened:Boolean;
var i:int;
for (;i < tweens.length;i++) {
tween = tweens[i].tween;
wait = tweens[i].waitType;
if (!tween.isCompleted()){
if ((((wait == SEQUENTIAL_ALL)) && (tweened))){
continue;
} else {
if (wait == SEQUENTIAL){
if (objects[tween.getObject()] != null){
continue;
};
};
};
tweened = true;
objects[tween.getObject()] = true;
tween.update(a_ms);
};
};
i = (tweens.length - 1);
while (i >= 0) {
if (tweens[i].tween.isCompleted()){
tweens.splice(i, 1);
};
i--;
};
}
public static function getInstance():TweenManager{
if (singleton == null){
trace("TweenManager::No instance exists");
};
return (singleton);
}
}
}//package com.gamedozer.battalion.display
class TweenHolder {
public var tween:TweenInterface;
public var waitType:int;
private function TweenHolder(a_tween:TweenInterface, a_waitType:int){
super();
tween = a_tween;
waitType = a_waitType;
}
}
Section 51
//AttackUnitAction (com.gamedozer.battalion.game.actions.AttackUnitAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class AttackUnitAction extends Action {
protected var targetX:int;
protected var targetY:int;
protected var unitX:int;
protected var unitY:int;
protected var phase:int;
protected static const ATTACKER_FIRE:int = 0;
protected static const DEFENDER_FIRE:int = 1;
protected static const DEFENDER_DIE:int = 2;
protected static const ATTACKER_DIE:int = 3;
protected static const COMPLETED:int = 4;
public function AttackUnitAction(a_unitX:int, a_unitY:int, a_targetX:int, a_targetY:int){
super();
unitX = a_unitX;
unitY = a_unitY;
targetX = a_targetX;
targetY = a_targetY;
phase = ATTACKER_FIRE;
}
public function fireAttackerSound():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
unit.getUnitData().playSound(AudioProfile.k_attackType);
}
public function fireDefenderSound():void{
var gameManager:GameManager = GameManager.getInstance();
var target:Unit = gameManager.unitAt(targetX, targetY);
target.getUnitData().playSound(AudioProfile.k_attackType);
}
override public function update():void{
}
public function fireImplied():void{
var ax:int;
var ay:int;
var returnFire:Boolean;
var tileSheet:TileSheet;
var tu:GameUnit;
var uu:GameUnit;
var gameUnitSprite:TileSheet;
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
var target:Unit = gameManager.unitAt(targetX, targetY);
if (phase == ATTACKER_FIRE){
TriggerManager.getInstance().add(new AttackUnitTrigger(unitX, unitY, targetX, targetY, unit, target));
ax = (unitX - targetX);
ay = (unitX - targetX);
phase = COMPLETED;
target.takeDamage(gameManager.resolveAttack(unit, target));
if (target.isAlive()){
if (!target.isRepairing()){
if (gameManager.canAttack(target, unit, true)){
returnFire = true;
if (target.isRanged()){
if (!target.getUnitData().hasModifier("Counter Battery")){
returnFire = false;
};
};
if (returnFire){
phase = DEFENDER_FIRE;
tileSheet = TileSheetManager.getInstance().get("Small Explosion");
tu = unit.getGameUnit();
tileSheet.x = (tu.x + ((tu.width - tileSheet.width) / 2));
tileSheet.y = (tu.y + ((tu.height - tileSheet.height) / 2));
uu = target.getGameUnit();
gameUnitSprite = (uu.getSprite() as TileSheet);
gameUnitSprite.playAnimation(direction(targetX, targetY, unitX, unitY));
TweenManager.getInstance().add(new Tween(uu, Quad.easeOut, ["y"], [uu.y], [(uu.y - 15)], 100, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(uu, Quad.easeIn, ["y"], [(uu.y - 15)], [uu.y], 100, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireDefenderSound, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, true, GameSpriteScroller.TOP, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenAnimation(tileSheet, "default", true, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, false, GameSpriteScroller.TOP, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, this), TweenManager.SEQUENTIAL);
};
};
} else {
target.setRepairing(false);
};
} else {
phase = DEFENDER_DIE;
GameManager.getInstance().addExplosion("Explosion", target.getGameUnit());
SoundSystem.instance.playSound(SoundSystem.instance.createSound("ExplosionSound"));
TweenManager.getInstance().add(new Tween(target.getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, target.getGameUnit()), TweenManager.SEQUENTIAL);
};
} else {
if (phase == DEFENDER_FIRE){
phase = COMPLETED;
unit.takeDamage(gameManager.resolveAttack(target, unit, null, null, false));
if (!unit.isAlive()){
phase = ATTACKER_DIE;
GameManager.getInstance().addExplosion("Explosion", unit.getGameUnit());
SoundSystem.instance.playSound(SoundSystem.instance.createSound("ExplosionSound"));
TweenManager.getInstance().add(new Tween(unit.getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, unit.getGameUnit()), TweenManager.SEQUENTIAL);
} else {
unit.setCloaked(false);
};
} else {
if (phase == DEFENDER_DIE){
phase = COMPLETED;
TriggerManager.getInstance().add(new KillUnitTrigger(targetX, targetY, target));
target.getController().getTeam().addStatistic(Team.UNITS_LOST, 1);
unit.getController().getTeam().addStatistic(Team.UNITS_KILLED, 1);
gameManager.removeUnit(target);
} else {
if (phase == ATTACKER_DIE){
phase = COMPLETED;
TriggerManager.getInstance().add(new KillUnitTrigger(unitX, unitY, unit));
unit.getController().getTeam().addStatistic(Team.UNITS_LOST, 1);
target.getController().getTeam().addStatistic(Team.UNITS_KILLED, 1);
gameManager.removeUnit(unit);
};
};
};
};
if (phase == COMPLETED){
unit.setMoved(true);
unit.setFired(true);
unit.darken();
super.update();
};
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
return ((unit == a_unit));
}
override public function fire():void{
var gameManager:GameManager;
var tileSheet:TileSheet;
var tu:GameUnit;
var uu:GameUnit;
var gameUnitSprite:TileSheet;
super.fire();
gameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
var target:Unit = gameManager.unitAt(targetX, targetY);
if ((((unit == null)) || ((((target == null)) && (!((unit == target))))))){
super.update();
throw (new Error("AttackUnitAction::Corrupt attack action"));
};
if (unit.getController() != gameManager.getActiveController()){
super.update();
throw (new Error("AttackUnitAction::Only the units controller may attack with the unit"));
};
if (unit.hasFired()){
super.update();
throw (new Error(("AttackUnitAction::Unit cannot complete attack action. (Unit has fired)" + gameManager.getCurrentController())));
};
if (((unit.isRanged()) && (unit.hasMoved()))){
super.update();
throw (new Error(("AttackUnitAction::Unit cannot complete attack action. (Ranged unit has already moved)" + gameManager.getCurrentController())));
};
if (!unit.hasMoved()){
if (unit.getUnitData().hasModifier("Cloaking")){
if (unit.isCloaked()){
unit.setCloaked(false);
unit.setCloaked(true);
} else {
unit.setCloaked(true);
};
};
};
if (gameManager.canAttack(unit, target)){
phase = ATTACKER_FIRE;
tileSheet = TileSheetManager.getInstance().get("Small Explosion");
tu = target.getGameUnit();
tileSheet.x = (tu.x + ((tu.width - tileSheet.width) / 2));
tileSheet.y = (tu.y + ((tu.height - tileSheet.height) / 2));
uu = unit.getGameUnit();
gameUnitSprite = (uu.getSprite() as TileSheet);
gameUnitSprite.playAnimation(direction(unitX, unitY, targetX, targetY));
TweenManager.getInstance().add(new Tween(uu, Quad.easeOut, ["y"], [uu.y], [(uu.y - 15)], 100, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(uu, Quad.easeIn, ["y"], [(uu.y - 15)], [uu.y], 100, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireAttackerSound, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, true, GameSpriteScroller.TOP, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenAnimation(tileSheet, "default", true, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, false, GameSpriteScroller.TOP, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, this), TweenManager.SEQUENTIAL);
gameManager.getCamera().setTarget(uu, 500);
} else {
super.update();
throw (new Error(("AttackUnitAction::Unit cannot complete attack action. (Target not in range)" + gameManager.getCurrentController())));
};
}
protected function direction(x1:int, y1:int, x2:int, y2:int):String{
if (y1 == y2){
if (x1 < x2){
return ("right_idle");
};
return ("left_idle");
};
if (y1 < y2){
return ("down_idle");
};
return ("up_idle");
}
}
}//package com.gamedozer.battalion.game.actions
Section 52
//BuildUnitAction (com.gamedozer.battalion.game.actions.BuildUnitAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class BuildUnitAction extends Action {
protected var unit:String;
protected var tileX:int;
protected var tileY:int;
protected var gu:GameUnit;
public function BuildUnitAction(a_tileX:int, a_tileY:int, a_unit:String){
super();
tileX = a_tileX;
tileY = a_tileY;
unit = a_unit;
}
override public function update():void{
}
public function fireImplied():void{
super.update();
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(tileX, tileY);
var controller:Controller = tile.getController();
var unitData:UnitData = UnitManager.getInstance().get(unit);
var newUnit:Unit = new Unit(gu, unitData, tileX, tileY, tile.getController());
newUnit.setDeployed(true);
newUnit.setMoved(true);
newUnit.setFired(true);
var ts:TileSheet = (newUnit.getGameUnit().getSprite() as TileSheet);
if (newUnit.getX() > (gameManager.getMap().getWidth() / 2)){
ts.playAnimation("left_idle");
} else {
ts.playAnimation("right_idle");
};
gameManager.addUnit(newUnit.getController(), newUnit);
tile.setUnit(newUnit);
newUnit.darken();
trace(("Built " + newUnit));
controller.spendResources(unitData.getCost(controller));
controller.getTeam().addStatistic(Team.UNITS_BUILT, 1);
TriggerManager.getInstance().add(new BuildUnitTrigger(newUnit));
}
override public function fire():void{
var ts:TileSheet;
var gameUnitSprite:AnimatedSprite;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(tileX, tileY);
var unitData:UnitData = UnitManager.getInstance().get(unit);
if ((((tile == null)) || ((unitData == null)))){
super.update();
throw (new Error("BuildUnitAction::Corrupt build action"));
};
var controller:Controller = tile.getController();
if (controller != gameManager.getActiveController()){
super.update();
throw (new Error("BuildUnitAction::Only the active controller may build"));
};
if (controller.getResources() < unitData.getCost(controller)){
super.update();
throw (new Error("BuildUnitAction::Controller cannot afford unit"));
};
var ground:Boolean = controller.controlsGround();
var sea:Boolean = controller.controlsSea();
var air:Boolean = controller.controlsAir();
var noBuild:Boolean;
if (unitData.isAir()){
if (!air){
noBuild = true;
};
} else {
if (unitData.isGround()){
if (!ground){
noBuild = true;
};
} else {
if (unitData.isSea()){
if (((!(tile.seaBordered())) || (!(sea)))){
noBuild = true;
};
} else {
noBuild = true;
};
};
};
if (unitData.hasModifier("Unbuildable")){
noBuild = true;
};
if (noBuild){
super.update();
throw (new Error("BuildUnitAction::Cannot build unit, non supported type"));
};
if (tile.getUnit() != null){
super.update();
throw (new Error("BuildUnitAction::Build cannot complete (Unit is on structure)!"));
};
if (tile.getTerrain().hasModifier("Construction")){
ts = TileSheetManager.getInstance().getColorised(unitData.getSprite(), tile.getController().getTeam().getColor());
gu = new GameUnit(ts);
gameManager.getGameSpriteScroller().add(gu, GameSpriteScroller.UNITS);
gu.x = (tileX * TileManager.getInstance().getWidth());
gu.y = (tileY * TileManager.getInstance().getHeight());
gu.alpha = 0;
TweenManager.getInstance().add(new Tween(gu, Quad.easeOut, ["alpha"], [0], [1], 1000), TweenManager.SEQUENTIAL);
gameUnitSprite = (gu.getSprite() as TileSheet);
TweenManager.getInstance().add(new TweenAnimation(gameUnitSprite, "right_idle", false, gu), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, gu), TweenManager.SEQUENTIAL);
gameManager.getCamera().setTarget(gu, 500);
} else {
super.update();
throw (new Error("BuildUnitAction::Build cannot complete (Structure cannot build)!"));
};
}
}
}//package com.gamedozer.battalion.game.actions
Section 53
//CallbackAction (com.gamedozer.battalion.game.actions.CallbackAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.game.*;
public class CallbackAction extends Action {
var m_callback:Function;
var m_toStringData:String;
public function CallbackAction(a_callback:Function, a_toStringData:String=""){
super();
m_callback = a_callback;
m_toStringData = a_toStringData;
}
override public function fire():void{
super.fire();
m_callback.call();
}
public function toString():String{
return ((("[ CallbackAction <" + m_toStringData) + "> ]"));
}
}
}//package com.gamedozer.battalion.game.actions
Section 54
//CaptureTerrainAction (com.gamedozer.battalion.game.actions.CaptureTerrainAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class CaptureTerrainAction extends Action {
protected var unitX:int;
protected var unitY:int;
public function CaptureTerrainAction(a_unitX:int, a_unitY:int){
super();
unitX = a_unitX;
unitY = a_unitY;
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
return ((unit == a_unit));
}
public function fireImplied():void{
super.update();
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
var tile:Tile = gameManager.tileAt(unitX, unitY);
var oldPlayer:int = GameManager.getInstance().getPlayer(tile.getController());
tile.setCapturer(unit);
tile.setChunks((tile.getChunks() - unit.getChunks(GameManager.UNIT_CHUNKS)));
trace(("Firing implied capture. Chunks are " + tile.getChunks()));
if (tile.getChunks() <= 0){
if (tile.getController() != null){
tile.getController().getTeam().addStatistic(Team.STRUCTURES_LOST, 1);
};
unit.getController().getTeam().addStatistic(Team.STRUCTURES_CAPTURED, 1);
trace("Critical is about to go down");
if (!tile.getTerrain().hasModifier("Mission Critical")){
if (tile.getController() != null){
tile.getController().removeStructure(tile);
};
unit.getController().addStructure(tile);
};
tile.setChunks(GameManager.TILE_CHUNKS);
TriggerManager.getInstance().add(new CaptureTerrainTrigger(tile, oldPlayer, GameManager.getInstance().getPlayer(unit.getController()), true));
} else {
TriggerManager.getInstance().add(new CaptureTerrainTrigger(tile, oldPlayer, GameManager.getInstance().getPlayer(unit.getController()), false));
};
}
override public function fire():void{
var gameUnit:GameUnit;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
var tile:Tile = gameManager.tileAt(unitX, unitY);
if ((((unit == null)) || ((tile == null)))){
super.update();
throw (new Error("CaptureTerrainAction::Corrupt capture action"));
};
if (unit.getController() != gameManager.getActiveController()){
super.update();
throw (new Error("CaptureTerrainAction::Only the units controller may capture with the unit"));
};
trace("This far");
var oldPlayer:int = GameManager.getInstance().getPlayer(tile.getController());
if (tile.getCapturer() == null){
tile.setChunks(GameManager.TILE_CHUNKS);
} else {
if (unit.getController() != tile.getCapturer().getController()){
tile.setChunks(GameManager.TILE_CHUNKS);
};
};
trace("Does it think its ours already");
if (unit.getController() == tile.getController()){
tile.setCapturer(null);
super.update();
return;
};
trace("Got here for the terrain action");
if (((unit.getUnitData().hasModifier("Capture")) || (!(unit.isDeployed())))){
gameUnit = unit.getGameUnit();
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeOut, ["y"], [gameUnit.y], [(gameUnit.y - 32)], 150), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeIn, ["y"], [(gameUnit.y - 32)], [gameUnit.y], 150), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(playCaptureSound), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeOut, ["y"], [gameUnit.y], [(gameUnit.y - 16)], 100), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeIn, ["y"], [(gameUnit.y - 16)], [gameUnit.y], 100), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeOut, ["y"], [gameUnit.y], [(gameUnit.y - 8)], 50), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new Tween(gameUnit, Circ.easeIn, ["y"], [(gameUnit.y - 8)], [gameUnit.y], 50), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, gameUnit), TweenManager.SEQUENTIAL);
gameManager.getCamera().setTarget(gameUnit, 1500);
} else {
super.update();
throw (new Error("CaptureTerrainAction::Unit cannot complete action, can not capture!"));
};
}
override public function update():void{
}
private function playCaptureSound():void{
SoundSystem.instance.playSound(SoundSystem.instance.createSound("Capture"));
}
}
}//package com.gamedozer.battalion.game.actions
Section 55
//DelayedCallbackAction (com.gamedozer.battalion.game.actions.DelayedCallbackAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class DelayedCallbackAction extends Action {
var m_callback:Function;
var m_toStringData:String;
var m_timeOfFire:int;
public function DelayedCallbackAction(a_callback:Function, a_delay:int, a_toStringData:String=""){
super();
m_callback = a_callback;
m_toStringData = a_toStringData;
m_timeOfFire = (getTimer() + a_delay);
}
override public function update():void{
if (getTimer() >= m_timeOfFire){
m_callback.call();
completed = true;
};
}
public function toString():String{
return ((("[ DelayedCallbackAction <" + m_toStringData) + "> ]"));
}
}
}//package com.gamedozer.battalion.game.actions
Section 56
//EndGameAction (com.gamedozer.battalion.game.actions.EndGameAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class EndGameAction extends Action {
public function EndGameAction(){
super();
}
override public function update():void{
if (((((((TweenManager.getInstance().isEmpty()) && (TriggerManager.getInstance().isEmpty()))) && (GameEventManager.getInstance().isEmpty()))) && (ResponseManager.getInstance().isEmpty()))){
GameManager.getInstance().endGame();
super.update();
};
}
override public function fire():void{
super.fire();
var controllers:Array = GameManager.getInstance().getControllers();
var i:int;
while (i < controllers.length) {
if (controllers[i].getTeam().getActive()){
TriggerManager.getInstance().add(new PlayerTrigger(PlayerTrigger.END_GAME, GameManager.getInstance().getPlayer(controllers[i])));
};
i++;
};
}
}
}//package com.gamedozer.battalion.game.actions
Section 57
//EndTurnAction (com.gamedozer.battalion.game.actions.EndTurnAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import flash.geom.*;
import com.gamedozer.battalion.game.*;
public class EndTurnAction extends Action {
public function EndTurnAction(){
super();
}
override public function fire():void{
var unit:Unit;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var controller:Controller = GameManager.getInstance().getActiveController();
var units:Array = controller.getUnits();
var i:int;
while (i < units.length) {
unit = units[i];
unit.getUnitData().clearTemporaryModifiers();
unit.getGameUnit().transform.colorTransform = new ColorTransform();
if (unit.isCloaked()){
unit.getGameUnit().alpha = unit.getController().getCloakVisibility();
};
if (unit.isDeployed()){
if (((unit.getUnitData().hasModifier("Cloaking")) && (unit.isAvailable()))){
unit.setCloaked(true, false, false);
};
};
i++;
};
do {
gameManager.setTurn((gameManager.getTurn() + 1));
gameManager.setCurrentController((gameManager.getCurrentController() + 1));
if (gameManager.getCurrentController() > (gameManager.getControllers().length - 1)){
gameManager.setRound((gameManager.getRound() + 1));
gameManager.setCurrentController(0);
};
if (gameManager.getRound() > gameManager.getMapSettings().getRounds()){
ActionManager.getInstance().add(new EndGameAction());
};
} while (!(gameManager.getActiveController().getTeam().getActive()));
ActionManager.getInstance().add(new StartTurnAction());
}
}
}//package com.gamedozer.battalion.game.actions
Section 58
//MoveUnitAction (com.gamedozer.battalion.game.actions.MoveUnitAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class MoveUnitAction extends Action {
protected var path:Array;
protected var unitX:int;
protected var unitY:int;
protected var uncloak:Unit;
protected var destination:Tile;
public function MoveUnitAction(a_unitX:int, a_unitY:int, a_path:Array){
super();
unitX = a_unitX;
unitY = a_unitY;
path = a_path;
uncloak = null;
}
override public function update():void{
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
return ((unit == a_unit));
}
public function fireImplied():void{
var canCloakAtNewPosition:Boolean;
var neighborX:Array;
var neighborY:Array;
var xNeighbor:int;
var yNeighbor:int;
var neighbor:Unit;
super.update();
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(unitX, unitY);
var unit:Unit = gameManager.unitAt(unitX, unitY);
if (destination.getUnit() != unit){
tile.setUnit(null);
destination.setUnit(unit);
unit.setMoved(true);
unit.setX(destination.getX());
unit.setY(destination.getY());
};
if (unit.getUnitData().hasModifier("Cloaking")){
canCloakAtNewPosition = true;
neighborX = [-1, -1, 1, 1];
neighborY = [-1, 1, -1, 1];
xNeighbor = 0;
while (xNeighbor < neighborX.length) {
yNeighbor = 0;
while (yNeighbor < neighborY.length) {
neighbor = gameManager.unitAt(neighborX[xNeighbor], neighborY[yNeighbor]);
if (neighbor != null){
if (neighbor.getController().getTeam() != unit.getController().getTeam()){
canCloakAtNewPosition = false;
};
};
yNeighbor++;
};
xNeighbor++;
};
if (canCloakAtNewPosition){
unit.setCloaked(true);
} else {
unit.setCloaked(false);
};
};
TriggerManager.getInstance().add(new MoveUnitTrigger(unit, path));
if (uncloak != null){
uncloak.setCloaked(false);
if (unit.getUnitData().hasModifier("Tracking")){
ActionManager.getInstance().add(new AttackUnitAction(unit.getX(), unit.getY(), uncloak.getX(), uncloak.getY()));
};
unit.darken();
};
var radarRange:int = unit.getUnitData().applyModifiers("radar", unit, 1);
var area:Array = GameManager.getInstance().unitsInRange(unit, true, -1, -1, 1, radarRange);
var j:int;
while (j < area.length) {
if (area[j].getUnitData().hasModifier("Cloaking")){
area[j].setCloaked(false);
};
j++;
};
}
override public function fire():void{
var i:int;
var tileT:Tile;
var unitT:Unit;
var tx:int;
var ty:int;
var x:int;
var y:int;
var gameUnit:GameUnit;
var gameUnitSprite:TileSheet;
var oldDirection:String;
var lock:Boolean;
var newx:int;
var newy:int;
var newtx:int;
var newty:int;
var newDirection:String;
var message:String;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(unitX, unitY);
var unit:Unit = gameManager.unitAt(unitX, unitY);
var nodePath:Array = gameManager.nodePath(path);
if ((((((tile == null)) || ((unit == null)))) || ((nodePath == null)))){
super.update();
throw (new Error("MoveUnitAction::Corrupt movement action"));
};
if (unit.getController() != gameManager.getActiveController()){
super.update();
throw (new Error("MoveUnitAction::Only the units controller may move the unit"));
};
if (unit.hasMoved()){
super.update();
throw (new Error("MoveUnitAction::Unit cannot complete movement action. (Already moved | Invalid path)"));
};
if (gameManager.canMove(unit, nodePath)){
if (unit.getUnitData().hasModifier("Cloaking")){
if (unit.isCloaked()){
unit.setCloaked(false);
unit.setCloaked(true);
};
};
i = 1;
while (i < nodePath.length) {
tileT = nodePath[i];
unitT = tileT.getUnit();
if (unitT != null){
if ((((i == (nodePath.length - 1))) || (!(unitT.getController().isAllied(unit.getController()))))){
do {
nodePath.splice(i, (nodePath.length - i));
i--;
} while (((!((nodePath[(nodePath.length - 1)].getUnit() == null))) && (!((nodePath[(nodePath.length - 1)].getUnit() == unit)))));
if (!unitT.getController().isAllied(unit.getController())){
uncloak = unitT;
};
break;
};
};
i++;
};
destination = nodePath[(nodePath.length - 1)];
if (destination.getUnit() != unit){
unit.getUnitData().playSound(AudioProfile.k_moveType);
tx = unit.getX();
ty = unit.getY();
x = unit.getGameUnit().x;
y = unit.getGameUnit().y;
gameUnit = unit.getGameUnit();
gameUnitSprite = (unit.getGameUnit().getSprite() as TileSheet);
oldDirection = "";
if (nodePath.length > 1){
i = 1;
while (i < nodePath.length) {
newx = nodePath[i].getGameTile().x;
newy = nodePath[i].getGameTile().y;
newtx = nodePath[i].getX();
newty = nodePath[i].getY();
if (((!((newtx == tx))) || (!((newty == ty))))){
newDirection = direction(tx, ty, newtx, newty);
if (newDirection != oldDirection){
TweenManager.getInstance().add(new TweenAnimation(gameUnitSprite, newDirection, false, gameUnit), TweenManager.SEQUENTIAL);
oldDirection = newDirection;
};
tx = newtx;
ty = newty;
};
if ((((i == 1)) && ((i == (nodePath.length - 1))))){
TweenManager.getInstance().add(new Tween(gameUnit, Quad.easeInOut, ["x", "y"], [x, y], [newx, newy], 400), TweenManager.SEQUENTIAL);
} else {
if (i == 1){
TweenManager.getInstance().add(new Tween(gameUnit, Quad.easeIn, ["x", "y"], [x, y], [newx, newy], 400), TweenManager.SEQUENTIAL);
} else {
if (i == (nodePath.length - 1)){
TweenManager.getInstance().add(new Tween(gameUnit, Quad.easeOut, ["x", "y"], [x, y], [newx, newy], 400), TweenManager.SEQUENTIAL);
} else {
TweenManager.getInstance().add(new Tween(gameUnit, Linear.easeNone, ["x", "y"], [x, y], [newx, newy], 200), TweenManager.SEQUENTIAL);
};
};
};
x = newx;
y = newy;
i++;
};
TweenManager.getInstance().add(new TweenAnimation(gameUnitSprite, (oldDirection + "_idle"), false, gameUnit), TweenManager.SEQUENTIAL);
lock = false;
if (unit.getController().getTeam().getControllerType() != "Human"){
lock = true;
};
if (((unit.isCloaked()) && (!(unit.getController().showCloak())))){
gameManager.getCamera().setTarget(gameUnit, 500, lock);
} else {
gameManager.getCamera().setTarget(gameUnit, (nodePath.length * 400), lock);
};
gameManager.getGameSpriteScroller().swapDepth(gameUnit, GameSpriteScroller.UNITS);
};
};
TweenManager.getInstance().add(new TweenFunction(fireImplied, gameUnit), TweenManager.SEQUENTIAL);
} else {
super.update();
message = (((("MoveUnitAction::" + unit) + " cannot complete movement action to ") + destination) + ". (Invalid path)");
throw (new Error(message));
};
}
protected function direction(x1:int, y1:int, x2:int, y2:int):String{
if (y1 == y2){
if (x1 < x2){
return ("right");
};
return ("left");
};
if (y1 < y2){
return ("down");
};
return ("up");
}
}
}//package com.gamedozer.battalion.game.actions
Section 59
//NoAttackAction (com.gamedozer.battalion.game.actions.NoAttackAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class NoAttackAction extends Action {
protected var unitX:int;
protected var unitY:int;
public function NoAttackAction(a_unitX:int, a_unitY:int){
super();
unitX = a_unitX;
unitY = a_unitY;
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
if (unit == a_unit){
trace((("Unit " + unit) + " is being used and must not be stolen."));
};
return ((unit == a_unit));
}
override public function fire():void{
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
if (unit == null){
throw (new Error("NoAttackAction::Corrupt action"));
};
if (unit.getController() != gameManager.getActiveController()){
throw (new Error("NoAttackAction::Only the units controller may do this action"));
};
unit.darken();
unit.setMoved(true);
}
}
}//package com.gamedozer.battalion.game.actions
Section 60
//RepairUnitAction (com.gamedozer.battalion.game.actions.RepairUnitAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class RepairUnitAction extends Action {
protected var unitX:int;
protected var unitY:int;
public function RepairUnitAction(a_unitX:int, a_unitY:int){
super();
unitX = a_unitX;
unitY = a_unitY;
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
return ((unit == a_unit));
}
override public function fire():void{
var healPerc:Number;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
if (unit == null){
throw (new Error("RepairUnitAction::Corrupt repair action"));
};
if (unit.getController() != gameManager.getActiveController()){
throw (new Error("RepairUnitAction::Only the units controller may repair the unit"));
};
if (((((!(unit.hasMoved())) && (!(unit.hasFired())))) || (!(unit.isDeployed())))){
if (unit.getHealth() < unit.getUnitData().getHealth()){
healPerc = GameManager.getInstance().healPercentage(unit);
if (unit.getController().getResources() >= (unit.getUnitData().getCost(unit.getController()) * healPerc)){
unit.getController().spendResources(Math.round((unit.getUnitData().getCost(unit.getController()) * healPerc)));
unit.setRepairing(true);
unit.setMoved(true);
unit.setFired(true);
unit.darken();
} else {
throw (new Error("RepairUnitAction::Units controller cannot afford the repair."));
};
};
} else {
throw (new Error("RepairUnitAction::Unit cannot complete repair action. (Already moved)"));
};
TriggerManager.getInstance().add(new RepairUnitTrigger(unit));
}
}
}//package com.gamedozer.battalion.game.actions
Section 61
//SendTriggerAction (com.gamedozer.battalion.game.actions.SendTriggerAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.game.*;
public class SendTriggerAction extends Action {
protected var trigger:Trigger;
public function SendTriggerAction(a_trigger:Trigger){
super();
trigger = a_trigger;
}
override public function fire():void{
super.fire();
TriggerManager.getInstance().add(trigger);
}
}
}//package com.gamedozer.battalion.game.actions
Section 62
//StartGameAction (com.gamedozer.battalion.game.actions.StartGameAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.game.*;
public class StartGameAction extends Action {
public function StartGameAction(){
super();
}
override public function fire():void{
super.fire();
var gameManager:GameManager = GameManager.getInstance();
gameManager.setTurn(0);
gameManager.setRound(0);
gameManager.setCurrentController(0);
TriggerManager.getInstance().add(new Trigger(Trigger.START_GAME));
}
}
}//package com.gamedozer.battalion.game.actions
Section 63
//StartRoundAction (com.gamedozer.battalion.game.actions.StartRoundAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.game.*;
public class StartRoundAction extends Action {
public function StartRoundAction(){
super();
}
override public function fire():void{
super.fire();
TriggerManager.getInstance().add(new Trigger(Trigger.START_ROUND));
}
}
}//package com.gamedozer.battalion.game.actions
Section 64
//StartTurnAction (com.gamedozer.battalion.game.actions.StartTurnAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class StartTurnAction extends Action {
public function StartTurnAction(){
super();
}
override public function fire():void{
var unit:Unit;
var radarRange:int;
var area:Array;
var j:int;
var healPerc:Number;
var hp:Number;
var cStructures:Array;
var res:int;
var capture:Boolean;
super.fire();
var controller:Controller = GameManager.getInstance().getActiveController();
var units:Array = controller.getUnits();
var i:int;
while (i < units.length) {
unit = units[i];
if (((unit.isDeployed()) && (unit.isAlive()))){
unit.reset();
unit.takeDamage(GameManager.getInstance().tileAt(unit.getX(), unit.getY()).getTerrain().applyModifiers("damage", unit, 0));
if (!unit.isAlive()){
TriggerManager.getInstance().add(new KillUnitTrigger(unit.getX(), unit.getY(), unit));
GameManager.getInstance().removeUnit(unit);
};
if (unit.isRepairing()){
if (unit.getHealth() < unit.getUnitData().getHealth()){
healPerc = GameManager.getInstance().healPercentage(unit);
unit.healDamage((unit.getUnitData().getHealth() * healPerc));
unit.setRepairing(false);
};
};
GameManager.getInstance().getCamera().setTarget(unit.getGameUnit());
radarRange = unit.getUnitData().applyModifiers("radar", unit, 1);
area = GameManager.getInstance().unitsInRange(unit, true, -1, -1, 1, radarRange);
j = 0;
while (j < area.length) {
if (area[j].getUnitData().hasModifier("Cloaking")){
area[j].setCloaked(false);
};
j++;
};
if (unit.getUnitData().hasModifier("Cloaking")){
if (unit.isCloaked()){
unit.getUnitData().addTemporaryModifier(ModifierManager.getInstance().get("Cloak Damage"));
};
};
};
i++;
};
units = GameManager.getInstance().getUnits();
i = 0;
while (i < units.length) {
unit = units[i];
if (((unit.isDeployed()) && (unit.isAlive()))){
hp = unit.getUnitData().applyModifiers("heal", unit, 0);
if (hp > 0){
if (unit.getHealth() < unit.getUnitData().getHealth()){
unit.healDamage(hp);
};
};
};
i++;
};
var controllers:Array = GameManager.getInstance().getControllers();
i = 0;
while (i < controllers.length) {
if (controllers[i] != null){
cStructures = controllers[i].getStructures();
res = 0;
j = 0;
while (j < cStructures.length) {
res = (res + cStructures[j].takeResources((1 / controllers.length)));
j++;
};
if (controllers[i] == controller){
j = 0;
while (j < cStructures.length) {
if (cStructures[j].getTerrain().hasModifier("Mission Critical")){
GameManager.getInstance().getCamera().setTarget(cStructures[j].getGameTile());
};
j++;
};
};
res = Math.round((res * controllers[i].getDifficultyResourcesScale()));
controllers[i].addResources(res);
controllers[i].getTeam().addStatistic(Team.RESOURCES_COLLECTED, res);
TriggerManager.getInstance().add(new ResourcesAcquiredTrigger(GameManager.getInstance().getPlayer(controllers[i]), res));
};
i++;
};
var structures:Array = GameManager.getInstance().getStructures();
i = 0;
while (i < structures.length) {
unit = structures[i].getUnit();
capture = false;
if (unit != null){
if (((unit.isDeployed()) && (unit.isAlive()))){
trace(("Checking unit " + unit), ("; has capture? " + unit.getUnitData().hasModifier("Capture")));
if (unit.getUnitData().hasModifier("Capture")){
trace("Capture is true.");
capture = true;
if (controller.controlsUnit(unit)){
trace("Doing the capture");
ActionManager.getInstance().add(new CaptureTerrainAction(structures[i].getX(), structures[i].getY()));
};
};
};
};
if (!capture){
structures[i].setChunks(GameManager.TILE_CHUNKS);
structures[i].setCapturer(null);
};
i++;
};
controller.setCamera();
ActionManager.getInstance().add(new SendTriggerAction(new PlayerTrigger(PlayerTrigger.START_TURN, GameManager.getInstance().getCurrentController())));
}
}
}//package com.gamedozer.battalion.game.actions
Section 65
//SurrenderAction (com.gamedozer.battalion.game.actions.SurrenderAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class SurrenderAction extends Action {
protected var player:int;
public function SurrenderAction(a_player:int){
super();
player = a_player;
}
public function fireImplied():void{
super.update();
GameManager.getInstance().surrender(player);
var controller:Controller = GameManager.getInstance().getController(player);
var units:Array = controller.getUnits();
var i:int = (units.length - 1);
while (i >= 0) {
GameManager.getInstance().removeUnit(units[i]);
i--;
};
var structures:Array = controller.getStructures();
i = (structures.length - 1);
while (i >= 0) {
if (structures[i].getTerrain().hasModifier("Mission Critical")){
GameManager.getInstance().removeStructure(structures[i]);
} else {
structures[i].setController(null);
};
i--;
};
TriggerManager.getInstance().add(new PlayerTrigger(PlayerTrigger.SURRENDER, player));
}
override public function fire():void{
super.fire();
var controller:Controller = GameManager.getInstance().getController(player);
var units:Array = controller.getUnits();
var i:int = (units.length - 1);
while (i >= 0) {
GameManager.getInstance().addExplosion("Explosion", units[i].getGameUnit());
TweenManager.getInstance().add(new Tween(units[i].getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL);
i--;
};
var structures:Array = controller.getStructures();
i = (structures.length - 1);
while (i >= 0) {
GameManager.getInstance().addExplosion("Explosion", null, ((structures[i].getX() + 0.5) * TileManager.getInstance().getWidth()), ((structures[i].getY() + 1) * TileManager.getInstance().getHeight()));
i--;
};
fireImplied();
}
override public function update():void{
}
override public function toXML():XML{
return (new XML((("<action type=\"surrenderAction\"> <player value=\"" + (player + 1)) + "\"/> </action>")));
}
public static function getFromXML(a_xml:XML):Action{
var player:String = a_xml.player.@value;
return (new SurrenderAction((parseInt(player) - 1)));
}
}
}//package com.gamedozer.battalion.game.actions
Section 66
//UpgradeUnitAction (com.gamedozer.battalion.game.actions.UpgradeUnitAction)
package com.gamedozer.battalion.game.actions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class UpgradeUnitAction extends Action {
protected var upgrade:Boolean;
protected var tileSheet:TileSheet;
protected var unitX:int;
protected var unitY:int;
protected var unitType:String;
public function UpgradeUnitAction(a_unitX:int, a_unitY:int, a_upgrade:Boolean, a_unitType:String=""){
super();
unitX = a_unitX;
unitY = a_unitY;
upgrade = a_upgrade;
unitType = a_unitType;
}
override public function update():void{
}
override public function usesUnit(a_unit:Unit):Boolean{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
return ((unit == a_unit));
}
public function fireImplied():void{
super.update();
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(unitX, unitY);
if (upgrade){
unit.getController().spendResources(unit.getUnitData().getCost());
};
TriggerManager.getInstance().add(new UpgradeUnitTrigger(unit, upgrade));
unit.setCloaked(false);
}
override public function fire():void{
var unit:Unit;
var tile:Tile;
var bUD:UnitData;
var newUnit:UnitData;
super.fire();
var gameManager:GameManager = GameManager.getInstance();
unit = gameManager.unitAt(unitX, unitY);
if (unit == null){
super.update();
throw (new Error("UpgradeUnitAction::Corrupt upgrade action"));
};
if (unit.getController() != gameManager.getActiveController()){
super.update();
throw (new Error("UpgradeUnitAction::Only the units controller may upgrade the unit"));
};
if (((((!(unit.hasMoved())) && (!(unit.hasFired())))) || (!(unit.isDeployed())))){
unit.setCloaked(false);
if (!upgrade){
tile = gameManager.tileAt(unit.getX(), unit.getY());
bUD = unit.getBaseUnitData();
if (tile.getCost(new Unit(new GameUnit(new GameSprite()), bUD, 0, 0, unit.getController())) != Number.POSITIVE_INFINITY){
tileSheet = (unit.getGameUnit().getSprite() as TileSheet);
unit.downgrade();
tileSheet.x = (unit.getGameUnit().x + tileSheet.x);
tileSheet.y = (unit.getGameUnit().y + tileSheet.y);
gameManager.getGameSpriteScroller().add(tileSheet, GameSpriteScroller.ABOVE_UNITS);
TweenManager.getInstance().add(new Tween(unit.getGameUnit().getSprite(), Linear.easeOut, ["alpha"], [0], [1], 1000), TweenManager.SEQUENTIAL_ALL);
TweenManager.getInstance().add(new Tween(tileSheet, Linear.easeIn, ["alpha"], [1], [0], 1000, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, false, GameSpriteScroller.ABOVE_UNITS, this), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(fireImplied, this), TweenManager.SEQUENTIAL);
gameManager.getCamera().setTarget(unit.getGameUnit(), 500);
} else {
super.update();
};
} else {
newUnit = UnitManager.getInstance().get(unitType);
if (unit.getController().getResources() < newUnit.getCost()){
super.update();
throw (new Error("UpgradeUnitAction::Controller cannot afford unit"));
};
tileSheet = TileSheetManager.getInstance().getColorised(newUnit.getSprite(), unit.getController().getTeam().getColor());
tileSheet.alpha = 0;
TweenManager.getInstance().add(new Tween(unit.getGameUnit().getSprite(), Linear.easeIn, ["alpha"], [1], [0], 1000, this));
unit.upgrade(tileSheet, newUnit);
TweenManager.getInstance().add(new Tween(unit.getGameUnit().getSprite(), Linear.easeOut, ["alpha"], [0], [1], 1000, this));
TweenManager.getInstance().add(new TweenFunction(fireImplied, this), TweenManager.SEQUENTIAL);
gameManager.getCamera().setTarget(unit.getGameUnit(), 500);
};
} else {
super.update();
throw (new Error("MoveUnitAction::Unit cannot complete upgrade action. (Already moved | Fired)"));
};
}
}
}//package com.gamedozer.battalion.game.actions
Section 67
//AIEngine (com.gamedozer.battalion.game.ai.AIEngine)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class AIEngine {
private var m_game:GameManager;
private var m_localInfluence:ControllerInfluence;
private var m_taskManager:AITaskManager;
private var m_unitBuilder:UnitBuilder;
private var m_controllerInfluences:Array;
private var m_controller:AIController;
public function AIEngine(a_controller:AIController){
super();
m_controller = a_controller;
m_controllerInfluences = new Array();
m_taskManager = new AITaskManager(this);
m_unitBuilder = new UnitBuilder(this);
m_game = GameManager.getInstance();
}
public function startLoading():void{
var controllerInfluence:ControllerInfluence;
var z:int;
while (z < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[z];
controllerInfluence.initialize();
z++;
};
}
public function doNothing():void{
}
function getDangerToArmorType(a_tile:Tile, a_armorType:int):Number{
var controllerInfluence:ControllerInfluence;
var dangerToArmorInfluenceMap:InfluenceMapDangerToArmorType;
var weight:Number = 0;
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
dangerToArmorInfluenceMap = controllerInfluence.getDangerToArmorType(a_armorType);
if (isLocalInfluence(controllerInfluence)){
weight = (weight + dangerToArmorInfluenceMap.getWeight(a_tile));
} else {
weight = (weight - dangerToArmorInfluenceMap.getWeight(a_tile));
};
i++;
};
return (weight);
}
public function isStillInitializing():Boolean{
var controllerInfluence:ControllerInfluence;
if (m_controllerInfluences.length == 0){
return (true);
};
var z:int;
while (z < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[z];
if (controllerInfluence.isStillInitializing()){
return (true);
};
z++;
};
return (false);
}
public function getDangerForUnit(a_unit:Unit, a_tile:Tile):Number{
return (m_localInfluence.getDangerForUnit(a_unit, a_tile));
}
public function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
var controllerInfluence:ControllerInfluence;
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.captureTerrain(a_tile, a_oldPlayer, a_player, a_complete);
i++;
};
}
public function initialize():void{
var controllerInfluence:ControllerInfluence;
var controllers:Array = GameManager.getInstance().getControllers();
var i:int;
while (i < controllers.length) {
if (m_controller == m_controller){
controllerInfluence = new ControllerInfluence(controllers[i]);
m_localInfluence = controllerInfluence;
m_controllerInfluences.push(controllerInfluence);
};
i++;
};
}
public function getController():AIController{
return (m_controller);
}
public function getCapturePriority(a_tile:Tile):Number{
return (m_localInfluence.getCapturePriority(a_tile));
}
public function parseUnitList():void{
var unit:Unit;
var killUnit:AITaskKillUnit;
var i:int;
var repairUnit:AITaskRepairUnit;
var controllerInfluence:ControllerInfluence;
var unitList:Array = m_game.getUnits();
for each (unit in unitList) {
if (m_controller.controlsUnit(unit)){
repairUnit = new AITaskRepairUnit(m_taskManager, unit);
} else {
killUnit = new AITaskKillUnit(m_taskManager, unit);
i = 0;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.addUnit(unit);
i++;
};
};
};
}
public function handleMovedUnit(a_unit:Unit, a_path:Array):void{
var controllerInfluence:ControllerInfluence;
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.moveUnit(a_unit, a_path);
i++;
};
}
public function handleBuiltUnit(a_unit:Unit):void{
var killUnit:AITaskKillUnit;
var repairUnit:AITaskRepairUnit;
var controllerInfluence:ControllerInfluence;
if (!m_controller.controlsUnit(a_unit)){
killUnit = new AITaskKillUnit(m_taskManager, a_unit);
} else {
repairUnit = new AITaskRepairUnit(m_taskManager, a_unit);
};
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.addUnit(a_unit);
i++;
};
}
public function parseTileMap():void{
var y:int;
var tile:Tile;
var captureTile:AITaskCapture;
var tileMap:Array = m_game.getTileMap();
var x:int;
while (x < tileMap.length) {
y = 0;
while (y < tileMap[x].length) {
tile = tileMap[x][y];
if (tile.isStructure()){
captureTile = new AITaskCapture(m_taskManager, tile);
};
y++;
};
x++;
};
}
public function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
var controllerInfluence:ControllerInfluence;
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.changeUpgradeStatus(a_unit, a_name, a_upgraded);
i++;
};
}
public function getKillPriority(a_unit:Unit):Number{
return (m_localInfluence.getKillPriority(a_unit));
}
function buildUnits():void{
m_unitBuilder.build();
m_unitBuilder.flush();
}
function queueBuild(a_task:AITask):void{
m_unitBuilder.queueBuild(a_task);
}
public function isSafeToRepair(a_unit:Unit):Boolean{
return (m_localInfluence.isSafeToRepair(a_unit));
}
public function handleKilledUnit(a_unit:Unit, a_unitX:Number, a_unitY:Number):void{
var controllerInfluence:ControllerInfluence;
m_taskManager.handleKilledUnit(a_unit);
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
controllerInfluence.removeUnit(a_unit);
i++;
};
}
public function getArmyFocalPoint():Tile{
var controllerInfluence:ControllerInfluence;
var dangerToArmorInfluenceMap:InfluenceMapDangerToArmorType;
var tile:Tile;
var i:int;
while (i < m_controllerInfluences.length) {
controllerInfluence = m_controllerInfluences[i];
dangerToArmorInfluenceMap = controllerInfluence.getDangerToArmorType(1);
if (isLocalInfluence(controllerInfluence)){
tile = dangerToArmorInfluenceMap.getMinimumTile();
return (tile);
};
i++;
};
return (null);
}
public function finishTurn():void{
m_taskManager.cleanupThink();
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, buildUnits)));
ActionManager.getInstance().add(new EndTurnAction());
//unresolved jump
var _slot1 = e;
trace("AIEngine", _slot1, _slot1.getStackTrace());
}
public function think():void{
m_taskManager.think();
if (ActionManager.getInstance().isEmpty()){
ActionManager.getInstance().add(new CallbackAction(doNothing));
};
//unresolved jump
var _slot1 = e;
trace("AIEngine", _slot1, _slot1.getStackTrace());
}
public function getTacticalPriority(a_tile:Tile):Number{
return (m_localInfluence.getTacticalPriority(a_tile));
}
function isLocalInfluence(a_influence:ControllerInfluence):Boolean{
return ((m_localInfluence == a_influence));
}
public function attackUnit(a_unit:Unit, a_target:Unit, a_damage:Number):void{
}
public function startTurn():void{
trace("");
trace("");
trace(("START TURN " + this.getController().getTeam().getName()));
m_taskManager.prepareThink();
//unresolved jump
var _slot1 = e;
trace("AIEngine", _slot1, _slot1.getStackTrace());
}
}
}//package com.gamedozer.battalion.game.ai
Section 68
//AITask (com.gamedozer.battalion.game.ai.AITask)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
public class AITask {
var m_manager:AITaskManager;
var m_isCompleted:Boolean;
var m_priority:Number;// = 0
public function AITask(a_manager:AITaskManager){
super();
m_manager = a_manager;
m_isCompleted = false;
m_manager.addTask(this);
}
public function assignUnits(a_activeUnits:Array):void{
assignUnitsImpl(a_activeUnits);
}
public function isComplete():Boolean{
return (m_isCompleted);
}
protected function executeImpl():void{
}
protected function assignUnitsImpl(a_activeUnits:Array):void{
trace("AITask.assignUnitImpl: Implement this!!!!!!!!!!!!");
}
public function set priority(value:Number):void{
this.m_priority = value;
}
public function updatePriority():void{
updatePriorityImpl();
}
public function handleUnitDied(a_unit:Unit):void{
handleUnitDiedImpl(a_unit);
}
protected function updatePriorityImpl():void{
trace("AITask.updataePriority: Implement this!!!!!!!!!!!!");
}
protected function handleUnitDiedImpl(a_unit:Unit):void{
}
function dispose():void{
disposeImpl();
m_manager = null;
}
public function get priority():Number{
return (this.m_priority);
}
public function completeTask():void{
m_isCompleted = true;
}
function calculateMinimumResourcesRequiredToBuild():Number{
return (0);
}
public function marshallReinforcements(a_activeUnits:Array):void{
marshallReinforcementsImpl(a_activeUnits);
}
protected function buildImpl(a_possibleFactories:Array, a_resourcesAvailable:Number):Number{
trace("AITask.buildImpl: Implement this!!!!!!!!!!!!!");
return (0);
}
protected function marshallReinforcementsImpl(a_activeUnits:Array):void{
}
public function build(a_possibleFactories:Array, a_resourcesAvailable:Number):Number{
return (buildImpl(a_possibleFactories, a_resourcesAvailable));
}
protected function disposeImpl():void{
}
public function toString():String{
return ((("[AITask: " + priority) + " ]"));
}
public function execute():void{
executeImpl();
}
}
}//package com.gamedozer.battalion.game.ai
Section 69
//AITaskCapture (com.gamedozer.battalion.game.ai.AITaskCapture)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class AITaskCapture extends AITask {
private var m_captureTargetTile:Tile;
private var m_capturingUnit:Unit;
public function AITaskCapture(a_manager:AITaskManager, a_captureTargetTile:Tile){
super(a_manager);
m_captureTargetTile = a_captureTargetTile;
priority = 0.65;
}
override protected function assignUnitsImpl(a_activeUnits:Array):void{
var index:int;
var unit:Unit;
var startTile:Tile;
var turns:int;
var engine:AIEngine;
var bestUnit:Unit;
var bestInterimTile:Tile;
var bestUnitIndex:int;
var controller:Controller;
var unitData:UnitData;
var fakeUnit:Unit;
var movementCombiner:MovementCombiner;
var interimDestination:Tile;
var turnCount:int;
var game:GameManager = GameManager.getInstance();
var unitOnTile:Unit = m_captureTargetTile.getUnit();
if (((((!((unitOnTile == null))) && (unitOnTile.getUnitData().hasModifier("Capture")))) && ((unitOnTile.getController() == m_manager.getController())))){
index = a_activeUnits.indexOf(unitOnTile);
if (index >= 0){
a_activeUnits.splice(index, 1);
} else {
trace("ISSUE WITH CAPTURE. COULD NOT FIND BEST UNIT.");
};
m_capturingUnit = unitOnTile;
return;
};
m_capturingUnit = null;
var bestCapturingUnit:Unit;
var bestTurnCount = 1000000;
var bestCapturingUnitIndex = -1;
var haveCapturables:Boolean;
var i:int;
while (i < a_activeUnits.length) {
unit = a_activeUnits[i];
if ((((m_captureTargetTile.getTerrain().getName() == "Oil Rig")) && ((unit.getBaseUnitData().getName().indexOf("Commando") >= 0)))){
} else {
if (unit.getUnitData().hasModifier("Capture")){
haveCapturables = true;
startTile = game.tileAt(unit.getX(), unit.getY());
if (startTile == m_captureTargetTile){
bestCapturingUnit = unit;
bestTurnCount = turns;
bestCapturingUnitIndex = i;
break;
};
turns = Astar.calculateTurnsToPath(startTile, m_captureTargetTile, unit, Tile.k_astarFlagIgnoreLastNode);
if ((((turns >= 0)) && ((turns < bestTurnCount)))){
bestCapturingUnit = unit;
bestTurnCount = turns;
bestCapturingUnitIndex = i;
};
};
if (unit.getBaseUnitData().hasModifier("Capture")){
haveCapturables = true;
};
};
i++;
};
if (bestCapturingUnit != null){
a_activeUnits.splice(bestCapturingUnitIndex, 1);
m_capturingUnit = bestCapturingUnit;
return;
};
if (!haveCapturables){
engine = m_manager.getEngine();
engine.queueBuild(this);
return;
};
if (bestCapturingUnit == null){
bestTurnCount = 9999999999;
bestUnit = null;
bestInterimTile = null;
engine = m_manager.getEngine();
controller = engine.getController();
if (controller.controlsAir()){
i = 0;
while (i < a_activeUnits.length) {
unit = a_activeUnits[i];
if (!unit.getBaseUnitData().hasModifier("Capture")){
} else {
if ((((m_captureTargetTile.getTerrain().getName() == "Oil Rig")) && ((unit.getBaseUnitData().getName().indexOf("Commando") >= 0)))){
} else {
startTile = game.tileAt(unit.getX(), unit.getY());
unitData = UnitManager.getInstance().get("Albatross Transport");
fakeUnit = new Unit(new GameUnit(new GameSprite()), unitData);
turns = (Math.abs((startTile.getX() - m_captureTargetTile.getX())) + Math.abs((startTile.getY() - m_captureTargetTile.getY())));
if ((((turns >= 0)) && ((turns < bestTurnCount)))){
bestUnit = unit;
bestTurnCount = turns;
bestCapturingUnitIndex = i;
};
};
};
i++;
};
if (bestUnit != null){
startTile = game.tileAt(bestUnit.getX(), bestUnit.getY());
if (startTile == m_captureTargetTile){
if (bestUnit.isUpgraded()){
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), false));
};
} else {
if (!bestUnit.isUpgraded()){
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), true, "Albatross Transport"));
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, delayedMove, bestUnit)));
} else {
moveTo(bestUnit, m_captureTargetTile);
};
};
a_activeUnits.splice(bestUnitIndex, 1);
return;
};
} else {
i = 0;
while (i < a_activeUnits.length) {
unit = a_activeUnits[i];
if ((((m_captureTargetTile.getTerrain().getName() == "Oil Rig")) && ((unit.getBaseUnitData().getName().indexOf("Commando") >= 0)))){
} else {
startTile = game.tileAt(unit.getX(), unit.getY());
if (unit.getBaseUnitData().hasModifier("Capture")){
movementCombiner = game.getMovementCombiner();
interimDestination = movementCombiner.getInterimDestination(startTile, m_captureTargetTile, unit);
if (interimDestination != null){
turnCount = movementCombiner.getTurnCount();
if (turnCount < bestTurnCount){
bestTurnCount = turnCount;
bestUnit = unit;
bestInterimTile = interimDestination;
bestUnitIndex = i;
};
};
};
};
i++;
};
if (bestUnit != null){
startTile = game.tileAt(bestUnit.getX(), bestUnit.getY());
if (bestInterimTile == m_captureTargetTile){
if (((((((m_captureTargetTile.getTerrain().hasModifier("Construction")) && (bestUnit.isUpgraded()))) && (m_captureTargetTile.seaBordered()))) && (!((m_captureTargetTile == startTile))))){
moveTo(bestUnit, m_captureTargetTile);
} else {
if (bestUnit.isUpgraded()){
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), false));
};
};
} else {
if (bestInterimTile == startTile){
if (!bestUnit.isUpgraded()){
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), true, "Leviathan Barge"));
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, delayedMove, bestUnit)));
} else {
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), false));
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, delayedMove, bestUnit)));
};
} else {
moveTo(bestUnit, bestInterimTile);
};
};
a_activeUnits.splice(bestUnitIndex, 1);
return;
};
};
};
}
public function delayedMove(a_unit:Unit):void{
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var movementCombiner:MovementCombiner = game.getMovementCombiner();
var interimDestination:Tile = movementCombiner.getInterimDestination(tile, m_captureTargetTile, a_unit);
moveTo(a_unit, interimDestination, true);
}
private function showMessage(a_message:String):void{
m_captureTargetTile.showText(a_message);
}
override public function toString():String{
return ((((("[CAP " + priority) + ": ") + m_captureTargetTile) + " ]"));
}
override protected function updatePriorityImpl():void{
var occupyingUnit:Unit;
var aiEngine:AIEngine;
var armyFocalPoint:Tile;
var fakeUnitType:String;
var fakeUnitData:UnitData;
var fakeUnit:Unit;
var turns:int;
var MAX_TURNS:int;
showMessage("");
if (m_captureTargetTile.getController() == m_manager.getController()){
priority = 0;
return;
};
occupyingUnit = m_captureTargetTile.getUnit();
if (((!((occupyingUnit == null))) && (!((occupyingUnit.getController() == m_manager.getController()))))){
priority = 0;
return;
};
aiEngine = m_manager.getEngine();
priority = aiEngine.getTacticalPriority(m_captureTargetTile);
var dangerToLightArmorModifier:Number = (aiEngine.getDangerToArmorType(m_captureTargetTile, 1) / 25);
if (dangerToLightArmorModifier > 0){
priority = (priority - dangerToLightArmorModifier);
};
if (((((!((occupyingUnit == null))) && ((occupyingUnit.getController() == m_manager.getController())))) && (occupyingUnit.getUnitData().hasModifier("Capture")))){
priority = (priority * 5);
return;
};
armyFocalPoint = aiEngine.getArmyFocalPoint();
if (armyFocalPoint != null){
fakeUnitType = "Strike Commando";
if (m_captureTargetTile.isSeaBased()){
fakeUnitType = "Leviathan Barge";
};
fakeUnitData = UnitManager.getInstance().get(fakeUnitType);
fakeUnit = new Unit(new GameUnit(new GameSprite()), fakeUnitData);
turns = Astar.calculateTurnsToPath(m_captureTargetTile, armyFocalPoint, fakeUnit, Tile.k_astarFlagIgnoreLastNode);
MAX_TURNS = 10;
if ((((turns > MAX_TURNS)) || ((turns < 0)))){
turns = MAX_TURNS;
};
if (turns > 0){
priority = (priority * (1 / (1.5 * turns)));
};
};
if (priority > 0){
showMessage(("CP: " + Math.round((priority * 1000))));
};
}
override protected function buildImpl(a_possibleFactories:Array, a_resourcesAvailable:Number):Number{
var commandoType:String;
var unitType:String;
var unitData:UnitData;
var fakeUnit:Unit;
var bestFactory:Tile;
var bestTurnCount:int;
var bestFactoryIndex:int;
var f:int;
var factory:Tile;
var turns:int;
if (m_capturingUnit != null){
return (0);
};
var options:Array = new Array();
var engine:AIEngine = m_manager.getEngine();
var controller:Controller = engine.getController();
if (m_captureTargetTile.isSeaBased()){
options.push("Intrepid");
};
if (m_captureTargetTile.getTerrain().getName() != "Oil Rig"){
commandoType = "Heavy Commando";
if (Math.random() > 0.35){
options.push("Heavy Commando");
};
options.push("Strike Commando");
};
var o:int;
while (o < options.length) {
unitType = options[o];
unitData = UnitManager.getInstance().get(unitType);
if (unitData.getCost(controller) > a_resourcesAvailable){
} else {
if (((!(controller.controlsSea())) && (unitData.isSea()))){
} else {
fakeUnit = new Unit(new GameUnit(new GameSprite()), unitData);
bestFactory = null;
bestTurnCount = 9999999999999;
bestFactoryIndex = -1;
f = 0;
while (f < a_possibleFactories.length) {
factory = a_possibleFactories[f];
turns = Astar.calculateTurnsToPath(factory, m_captureTargetTile, fakeUnit, Tile.k_astarFlagIgnoreLastNode);
if ((((turns >= 0)) && ((turns < bestTurnCount)))){
bestTurnCount = turns;
bestFactoryIndex = f;
bestFactory = factory;
};
f++;
};
if (bestFactory != null){
a_possibleFactories.splice(bestFactoryIndex, 1);
ActionManager.getInstance().add(new BuildUnitAction(bestFactory.getX(), bestFactory.getY(), unitType), true);
return (unitData.getCost(controller));
};
};
};
o++;
};
return (0);
}
override protected function handleUnitDiedImpl(a_unit:Unit):void{
if (m_capturingUnit == a_unit){
m_capturingUnit = null;
};
}
override function calculateMinimumResourcesRequiredToBuild():Number{
var unitData:UnitData;
if (m_capturingUnit != null){
return (0);
};
if (m_captureTargetTile.getTerrain().getName() == "Oil Rig"){
unitData = UnitManager.getInstance().get("Intrepid");
} else {
unitData = UnitManager.getInstance().get("Strike Commando");
};
return (unitData.getCost(m_manager.getEngine().getController()));
}
public function willAttackTargetOfOpportunity(a_attackingUnit:Unit):Boolean{
var x:int;
var y:int;
var tile:Tile;
var oppurtunityTarget:Unit;
var costDamage:Number;
var game:GameManager = GameManager.getInstance();
var positionX:int = a_attackingUnit.getX();
var positionY:int = a_attackingUnit.getY();
var bestTarget:Unit;
var bestCostDamage:Number = 0;
var i:int;
while (i < 4) {
x = 0;
y = 0;
if (i == 0){
x = -1;
y = 0;
} else {
if (i == 1){
x = 1;
y = 0;
} else {
if (i == 2){
x = 0;
y = -1;
} else {
x = 0;
y = 1;
};
};
};
tile = game.tileAt((positionX + x), (positionY + y));
if (tile == null){
} else {
oppurtunityTarget = tile.getUnit();
if (oppurtunityTarget == null){
} else {
if (oppurtunityTarget.getController() == a_attackingUnit.getController()){
} else {
costDamage = game.resolveAttackCycleInResources(a_attackingUnit, oppurtunityTarget);
if ((((bestTarget == null)) || ((((costDamage > 0)) && ((costDamage > bestCostDamage)))))){
bestTarget = oppurtunityTarget;
bestCostDamage = costDamage;
};
};
};
};
i++;
};
if (bestTarget != null){
ActionManager.getInstance().add(new AttackUnitAction(positionX, positionY, bestTarget.getX(), bestTarget.getY()), true);
return (true);
};
return (false);
}
protected function moveTo(a_unit:Unit, a_destination:Tile, a_forceNow:Boolean=false):void{
var pointPath:Array;
var game:GameManager = GameManager.getInstance();
var startTile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var flags:int;
flags = Tile.k_astarFlagIgnoreLastNode;
var path:Array = Astar.pathTrim(startTile, a_destination, a_unit, flags);
if (path == null){
trace("AITaskCapture.moveTo: We can't reach our target. This should not have happened because we should never let a unit be assigned to us that was useless.");
} else {
if (path.length == 0){
trace("AITaskCapture. moveTo Why is our path 0?");
};
if ((((path.length > 0)) && (!((path[(path.length - 1)].getUnit() == null))))){
if (!path[(path.length - 1)].getUnit().isCloaked()){
path.pop();
};
};
pointPath = game.pointPath(path);
ActionManager.getInstance().add(new MoveUnitAction(a_unit.getX(), a_unit.getY(), pointPath), a_forceNow);
};
}
override protected function executeImpl():void{
var goingToOpportunityAttack:Boolean;
if ((((m_capturingUnit == null)) || ((m_captureTargetTile == null)))){
return;
};
var aiEngine:AIEngine = m_manager.getEngine();
var potentialDamage:Number = aiEngine.getDangerToArmorType(m_captureTargetTile, 1);
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(m_capturingUnit.getX(), m_capturingUnit.getY());
var endTile:Tile = m_captureTargetTile;
if (tile == endTile){
goingToOpportunityAttack = willAttackTargetOfOpportunity(m_capturingUnit);
if (goingToOpportunityAttack){
} else {
if (m_capturingUnit.getHealthPercentage() < 1){
aiEngine = m_manager.getEngine();
if (aiEngine.isSafeToRepair(m_capturingUnit)){
ActionManager.getInstance().add(new RepairUnitAction(m_capturingUnit.getX(), m_capturingUnit.getY()));
};
} else {
ActionManager.getInstance().add(new NoAttackAction(m_capturingUnit.getX(), m_capturingUnit.getY()));
};
};
return;
};
moveTo(m_capturingUnit, endTile);
}
override protected function disposeImpl():void{
m_capturingUnit = null;
m_captureTargetTile = null;
}
}
}//package com.gamedozer.battalion.game.ai
Section 70
//AITaskKillUnit (com.gamedozer.battalion.game.ai.AITaskKillUnit)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class AITaskKillUnit extends AITask {
private var m_targetUnit:Unit;
private var m_attackingUnits:Array;
public function AITaskKillUnit(a_manager:AITaskManager, a_targetUnit:Unit){
super(a_manager);
m_targetUnit = a_targetUnit;
m_attackingUnits = new Array();
priority = 0.5;
}
override protected function assignUnitsImpl(a_activeUnits:Array):void{
var anAttacker:Unit;
var unit:Unit;
var costDamage:Number;
var engine:AIEngine;
if (m_targetUnit == null){
completeTask();
return;
};
m_attackingUnits.splice(0);
var game:GameManager = GameManager.getInstance();
var potentialHealthRemaining:Number = m_targetUnit.getHealth();
var potentialAttackers:Array = a_activeUnits.slice();
var z:int = (potentialAttackers.length - 1);
while (z >= 0) {
anAttacker = potentialAttackers[z];
if (anAttacker.isUpgraded()){
potentialAttackers.splice(z, 1);
};
z--;
};
var bestAttacker:Unit;
var bestCostDamage:Number = -999999999999;
var bestIndex = -1;
var i:int;
while (i < potentialAttackers.length) {
unit = potentialAttackers[i];
if (((!(unit.isUpgraded())) && (game.canAttack(unit, m_targetUnit, false, -1, -1, true)))){
costDamage = game.resolveAttackCycleInResources(unit, m_targetUnit);
if (costDamage > bestCostDamage){
bestAttacker = unit;
bestCostDamage = costDamage;
bestIndex = i;
};
};
i++;
};
if (bestAttacker == null){
} else {
potentialAttackers.splice(bestIndex, 1);
potentialHealthRemaining = (potentialHealthRemaining - game.resolveAttack(bestAttacker, m_targetUnit));
m_attackingUnits.push(bestAttacker);
a_activeUnits.splice(bestIndex, 1);
};
if (potentialHealthRemaining > 0){
engine = m_manager.getEngine();
engine.queueBuild(this);
return;
};
}
public function processRangedUnit(a_unit:Unit):void{
var bestDefense:Number;
var attackTile:Tile;
var path:Array;
var defensiveCover:Number;
var attackingUnit:Unit = a_unit;
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(attackingUnit.getX(), attackingUnit.getY());
var endTile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
if (game.canAttack(attackingUnit, m_targetUnit, false)){
ActionManager.getInstance().add(new AttackUnitAction(attackingUnit.getX(), attackingUnit.getY(), m_targetUnit.getX(), m_targetUnit.getY()), true);
return;
};
var neighbors:Array = getTilesThatThisUnitCanAttackFrom(attackingUnit);
var bestPath:Array;
while (neighbors.length > 0) {
attackTile = neighbors[0];
neighbors.splice(0, 1);
if (attackTile.getUnit() != null){
} else {
path = Astar.pathTrim(tile, attackTile, attackingUnit);
if (path == null){
} else {
defensiveCover = tile.getTerrain().applyModifiers("defense", attackingUnit, 1);
if ((((bestPath == null)) || ((defensiveCover < bestDefense)))){
bestPath = path;
bestDefense = defensiveCover;
};
};
};
};
if (bestPath == null){
trace("No suitable path to attack our target. Should this even be able to happen? Possibly. If so, TODO: Use this unit for something else.");
return;
};
var pointPath:Array = game.pointPath(bestPath);
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, attemptAttack, attackingUnit, pointPath[(pointPath.length - 2)], pointPath[(pointPath.length - 1)])), true);
if (attackingUnit.canMove()){
ActionManager.getInstance().add(new MoveUnitAction(attackingUnit.getX(), attackingUnit.getY(), pointPath), true);
};
}
function moveUnitCloserToTarget(a_unit:Unit, a_endTile:Tile):void{
var pointPath:Array;
if (!a_unit.canMove()){
return;
};
var game:GameManager = GameManager.getInstance();
var startTile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var path:Array = Astar.pathTrim(startTile, a_endTile, a_unit, Tile.k_astarFlagIgnoreLastNode);
if (path == null){
trace(((((("AITaskKillUnit. moveUnitCloserToTarget: Can't find path from " + startTile) + " to ") + a_endTile) + " using ") + a_unit));
} else {
if (path[(path.length - 1)].getUnit() != null){
if (!path[(path.length - 1)].getUnit().isCloaked()){
path.pop();
};
};
while (path[(path.length - 1)].getUnit() != null) {
path.pop();
};
if (path.length == 0){
return;
};
pointPath = game.pointPath(path);
if (!a_unit.isRanged()){
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, attemptAttack, a_unit, pointPath[(pointPath.length - 2)], pointPath[(pointPath.length - 1)])), true);
};
if (a_unit.canMove()){
ActionManager.getInstance().add(new MoveUnitAction(a_unit.getX(), a_unit.getY(), pointPath), true);
};
};
}
override protected function executeImpl():void{
var unit:Unit;
if (m_attackingUnits.length == 0){
return;
};
var game:GameManager = GameManager.getInstance();
var i:int = (m_attackingUnits.length - 1);
while (i >= 0) {
unit = m_attackingUnits[i];
if (unit.isRanged()){
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, processRangedUnit, unit)), true);
};
i--;
};
i = (m_attackingUnits.length - 1);
while (i >= 0) {
unit = m_attackingUnits[i];
if (!unit.isRanged()){
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, processUnrangedUnit, unit)), true);
};
i--;
};
}
override protected function disposeImpl():void{
m_attackingUnits.splice(0);
m_targetUnit = null;
}
function getPriorityBumpForPropertyType(a_tile:Tile):Number{
var name:String = a_tile.getTerrain().getName();
if (name == "Command Center"){
return (0.2);
};
if (name == "Sea Control"){
return (0.05);
};
if (name == "Air Control"){
return (0.05);
};
if (name == "Ground Control"){
return (0.05);
};
if (name == "Factory"){
return (0.1);
};
if (name == "Oil Rig"){
return (0.05);
};
if (name == "Oil Refinery"){
return (0.025);
};
if (name == "Advanced Oil Refinery"){
return (0.05);
};
trace(("AITaskKillUnit. Unknown structure : " + name));
return (0.1);
}
function createBestKillersQueue():Array{
var engine:AIEngine = m_manager.getEngine();
var controller:Controller = engine.getController();
var options:Array = new Array();
switch (m_targetUnit.getName()){
case "Heavy Commando":
options.push("Battlecruiser");
options.push("Raptor Fighter");
options.push("Flak Tank");
options.push("Strike Commando");
break;
case "Strike Commando":
options.push("Battlecruiser");
options.push("Raptor Fighter");
options.push("Flak Tank");
options.push("Strike Commando");
break;
case "Flak Tank":
options.push("Battlecruiser");
options.push("Scorpion Tank");
options.push("Condor Bomber");
options.push("Raptor Fighter");
break;
case "Scorpion Tank":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Battlecruiser");
options.push("Annihilator Tank");
options.push("Scorpion Tank");
options.push("Heavy Commando");
break;
case "Mortar Truck":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Battlecruiser");
options.push("Flak Tank");
options.push("Mortar Truck");
options.push("Strike Commando");
break;
case "Rocket Truck":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Battlecruiser");
options.push("Flak Tank");
options.push("Strike Commando");
break;
case "Annihilator Tank":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Battlecruiser");
options.push("Annihilator Tank");
options.push("Heavy Commando");
break;
case "Turret":
options.push("Battlecruiser");
options.push("Raptor Fighter");
options.push("Annihilator Tank");
options.push("Scorpion Tank");
options.push("Heavy Commando");
break;
case "Stealth Tank":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Battlecruiser");
options.push("Scorpion Tank");
options.push("Heavy Commando");
break;
case "Albatross Transport":
options.push("Raptor Fighter");
options.push("Flak Tank");
options.push("Hunter Support");
break;
case "Raptor Fighter":
options.push("Raptor Fighter");
options.push("Flak Tank");
options.push("Hunter Support");
break;
case "Condor Bomber":
options.push("Raptor Fighter");
options.push("Flak Tank");
options.push("Hunter Support");
break;
case "Leviathan Barge":
options.push("Condor Bomber");
options.push("Corvette Fighter");
options.push("Raptor Fighter");
break;
case "Hunter Support":
options.push("Condor Bomber");
options.push("Battlecruiser");
options.push("Corvette Fighter");
break;
case "Corvette Fighter":
options.push("Condor Bomber");
options.push("U-Boat");
options.push("Corvette Fighter");
options.push("Battlecruiser");
break;
case "U-Boat":
options.push("Condor Bomber");
options.push("Hunter Support");
break;
case "Battlecruiser":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Corvette Fighter");
options.push("Battlecruiser");
break;
case "Intrepid":
options.push("Condor Bomber");
options.push("Raptor Fighter");
options.push("Hunter Support");
options.push("Battlecruiser");
break;
default:
trace(("AIEngine: buildUnitToKill, unknown unit type: " + m_targetUnit.getName()));
break;
};
return (options);
}
private function getTilesThatThisUnitCanAttackFrom(a_unit:Unit, a_ignoreUnits:Boolean=false):Array{
var startTile:Tile = GameManager.getInstance().tileAt(a_unit.getX(), a_unit.getY());
var endTile:Tile = GameManager.getInstance().tileAt(m_targetUnit.getX(), m_targetUnit.getY());
return (Astar.calculatePositionsToTargetEndNode(startTile, endTile, a_unit, a_ignoreUnits));
}
public function processUnrangedUnit(a_unit:Unit):void{
var bestDefense:Number;
var attackTile:Tile;
var path:Array;
var defensiveCover:Number;
var attackingUnit:Unit = a_unit;
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(attackingUnit.getX(), attackingUnit.getY());
var endTile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
if (game.canAttack(attackingUnit, m_targetUnit, false)){
ActionManager.getInstance().add(new AttackUnitAction(attackingUnit.getX(), attackingUnit.getY(), m_targetUnit.getX(), m_targetUnit.getY()), true);
return;
};
var neighbors:Array = new Array();
var neighbor:Tile = game.tileAt(endTile.getX(), (endTile.getY() - 1));
if (neighbor != null){
neighbors.push(neighbor);
};
neighbor = game.tileAt(endTile.getX(), (endTile.getY() + 1));
if (neighbor != null){
neighbors.push(neighbor);
};
neighbor = game.tileAt((endTile.getX() + 1), endTile.getY());
if (neighbor != null){
neighbors.push(neighbor);
};
neighbor = game.tileAt((endTile.getX() - 1), endTile.getY());
if (neighbor != null){
neighbors.push(neighbor);
};
var bestPath:Array;
while (neighbors.length > 0) {
attackTile = neighbors[0];
neighbors.splice(0, 1);
if (attackTile.getUnit() != null){
} else {
path = Astar.pathTrim(tile, attackTile, attackingUnit);
if (path == null){
} else {
defensiveCover = tile.getTerrain().applyModifiers("defense", attackingUnit, 1);
if ((((bestPath == null)) || ((defensiveCover < bestDefense)))){
bestPath = path;
bestDefense = defensiveCover;
};
};
};
};
if (bestPath == null){
trace("No suitable path to attack our target. Should this even be able to happen? Possibly. If so, TODO: Use this unit for something else.");
return;
};
var pointPath:Array = game.pointPath(bestPath);
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, attemptAttack, attackingUnit, pointPath[(pointPath.length - 2)], pointPath[(pointPath.length - 1)])), true);
if (attackingUnit.canMove()){
ActionManager.getInstance().add(new MoveUnitAction(attackingUnit.getX(), attackingUnit.getY(), pointPath), true);
};
}
override public function toString():String{
return ((((("[KLL " + m_priority) + ": ") + m_targetUnit) + " ]"));
}
override protected function updatePriorityImpl():void{
var priorityBump:Number;
if (m_targetUnit == null){
completeTask();
priority = 0;
return;
};
if (m_targetUnit.isCloaked()){
priority = 0;
return;
};
priority = ((m_targetUnit.getHealth() / m_targetUnit.getUnitData().getHealth()) * (m_targetUnit.getUnitData().getCost(m_targetUnit.getController()) / 30000));
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
if (m_targetUnit.getUnitData().hasModifier("Capture")){
if (tile.isStructure()){
priorityBump = getPriorityBumpForPropertyType(tile);
if (tile.getController() == null){
priority = (priority + (priorityBump / 5));
} else {
if (tile.getController() == m_manager.getController()){
priority = (priority + ((3 * ((1 + GameManager.TILE_CHUNKS) - tile.getChunks())) * priorityBump));
};
};
};
};
var aiEngine:AIEngine = m_manager.getEngine();
priority = (priority + aiEngine.getKillPriority(m_targetUnit));
if (m_targetUnit.isRepairing()){
priority = (priority * 1.3);
};
var killPriorityModifier:Number = 2.4;
priority = (priority * killPriorityModifier);
if (priority <= 0){
priority = 0.0001;
};
m_targetUnit.showText(("KP: " + Math.round((priority * 1000))));
}
override protected function marshallReinforcementsImpl(a_activeUnits:Array):void{
var anAttacker:Unit;
var possibleAttackLocations:Array;
var bestAttackerToMove:Unit;
var bestCostDamage:Number;
var bestIndex:int;
var bestTurns:int;
var bestTargetTile:Tile;
var i:int;
var unit:Unit;
var startTile:Tile;
var path:Array;
var a:int;
var costDamage:Number;
var turns:int;
var movementCombiner:MovementCombiner;
var tilesInRange:Array;
var bestAttackerIndex:int;
var bestDamage:Number;
var bestTurnCount:int;
var bestInterimTile:Tile;
var c:int;
var bestUnit:Unit;
var unitTile:Tile;
var interimDestination:Tile;
var turnCount:int;
var engine:AIEngine;
var a_activeUnits = a_activeUnits;
if (m_targetUnit == null){
completeTask();
return;
};
var game:GameManager = GameManager.getInstance();
var potentialHealthRemaining:Number = m_targetUnit.getHealth();
var potentialAttackers:Array = a_activeUnits.slice();
var endTile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
var z:int = (potentialAttackers.length - 1);
for (;z >= 0;(z = (z - 1))) {
anAttacker = potentialAttackers[z];
if (!game.canWeaponsFireAtTarget(anAttacker, m_targetUnit)){
potentialAttackers.splice(z, 1);
} else {
if (endTile.isSeaBased()){
if (anAttacker.getBaseUnitData().isGround()){
possibleAttackLocations = getTilesThatThisUnitCanAttackFrom(anAttacker);
if ((((possibleAttackLocations == null)) || ((possibleAttackLocations.length == 0)))){
potentialAttackers.splice(z, 1);
continue;
};
};
};
};
};
var bestAttackerDestination:Tile;
while ((((potentialHealthRemaining > 0)) && ((potentialAttackers.length > 0)))) {
bestAttackerToMove = null;
bestCostDamage = -999999999999;
bestIndex = -1;
bestTurns = 0;
bestTargetTile = null;
i = (potentialAttackers.length - 1);
while (i >= 0) {
unit = potentialAttackers[i];
startTile = game.tileAt(unit.getX(), unit.getY());
path = getTilesThatThisUnitCanAttackFrom(unit, true);
if (path == null){
} else {
if (path.length == 0){
} else {
bestTurns = 0;
bestTargetTile = null;
a = (path.length - 1);
while (a >= 0) {
turns = Astar.calculateTurnsToPath(startTile, path[a], unit, Tile.k_astarFlagIgnoreUnits);
if (turns < -1){
} else {
if ((((bestTargetTile == null)) || ((turns < bestTurns)))){
bestTurns = turns;
bestTargetTile = path[a];
};
};
a = (a - 1);
};
if (bestTargetTile == null){
} else {
costDamage = game.resolveAttackCycleInResources(unit, m_targetUnit);
if (costDamage > bestCostDamage){
bestAttackerToMove = unit;
bestCostDamage = costDamage;
bestIndex = i;
bestAttackerDestination = bestTargetTile;
};
};
};
};
i = (i - 1);
};
if (bestAttackerToMove != null){
potentialHealthRemaining = (potentialHealthRemaining - game.resolveAttack(bestAttackerToMove, m_targetUnit));
potentialAttackers.splice(bestIndex, 1);
m_manager.useActiveUnit(bestAttackerToMove);
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, moveUnitCloserToTarget, bestAttackerToMove, bestAttackerDestination)));
} else {
break;
};
};
if (potentialHealthRemaining > 0){
potentialAttackers = new Array();
i = (a_activeUnits.length - 1);
for (;i >= 0;(i = (i - 1))) {
unit = a_activeUnits[i];
if (!unit.isAvailable()){
continue;
};
if (unit.isUpgraded()){
unit = new Unit(new GameUnit(new GameSprite()), unit.getBaseUnitData());
};
//unresolved if
costDamage = game.resolveAttackCycleInResources(unit, m_targetUnit);
//unresolved jump
var _slot1 = e;
trace((((("Got a crash in AITaskKill unit off of " + unit) + " aiming at ") + m_targetUnit) + _slot1));
costDamage = -1000000;
};
movementCombiner = game.getMovementCombiner();
while ((((potentialHealthRemaining > 0)) && ((potentialAttackers.length > 0)))) {
bestAttackerIndex = -1;
bestDamage = -1;
bestTurnCount = -1;
bestInterimTile = null;
c = (potentialAttackers.length - 1);
while (c >= 0) {
unit = potentialAttackers[c];
startTile = game.tileAt(unit.getX(), unit.getY());
interimDestination = movementCombiner.getInterimDestination(startTile, endTile, unit);
if (interimDestination != null){
turnCount = movementCombiner.getTurnCount();
if ((((bestAttackerIndex == -1)) || ((turnCount < bestTurnCount)))){
bestTurnCount = turnCount;
bestInterimTile = interimDestination;
bestAttackerIndex = c;
};
};
c = (c - 1);
};
if (bestAttackerIndex == -1){
break;
};
bestUnit = potentialAttackers[bestAttackerIndex];
m_manager.useActiveUnit(bestUnit);
potentialAttackers.splice(bestAttackerIndex, 1);
potentialHealthRemaining = (potentialHealthRemaining - game.resolveAttack(bestUnit, m_targetUnit));
unitTile = game.tileAt(bestUnit.getX(), bestUnit.getY());
movementCombiner = game.getMovementCombiner();
interimDestination = movementCombiner.getInterimDestination(unitTile, endTile, bestUnit);
if (interimDestination == unitTile){
if (bestUnit.isUpgraded()){
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), false));
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, delayedAttack, bestUnit)));
} else {
ActionManager.getInstance().add(new UpgradeUnitAction(bestUnit.getX(), bestUnit.getY(), true, "Leviathan Barge"));
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, delayedAttack, bestUnit)));
};
return;
};
ActionManager.getInstance().add(new CallbackAction(Delegate.create(this, moveUnitCloserToTarget, bestUnit, interimDestination)));
};
};
if (potentialHealthRemaining > 0){
engine = m_manager.getEngine();
engine.queueBuild(this);
return;
};
}
public function delayedAttack(a_unit:Unit):void{
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var targetTile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
var movementCombiner:MovementCombiner = game.getMovementCombiner();
var interimDestination:Tile = movementCombiner.getInterimDestination(tile, targetTile, a_unit);
if (interimDestination == targetTile){
if (a_unit.isRanged()){
processRangedUnit(a_unit);
} else {
processUnrangedUnit(a_unit);
};
} else {
moveTo(a_unit, interimDestination, true);
};
}
override function calculateMinimumResourcesRequiredToBuild():Number{
var killingUnitOptions:Array = createCheapestKillersQueue();
if (killingUnitOptions.length == 0){
throw (new Error(("KillUnit. Can't find a cheap unit to kill " + m_targetUnit.getName())));
};
var unitData:UnitData = UnitManager.getInstance().get(killingUnitOptions[0]);
return (unitData.getCost(m_manager.getEngine().getController()));
}
public function attemptAttack(a_attackingUnit:Unit, a_positionX:int, a_positionY:int):void{
var x:int;
var y:int;
var tile:Tile;
var oppurtunityTarget:Unit;
var costDamage:Number;
var game:GameManager = GameManager.getInstance();
if (game.canAttack(a_attackingUnit, m_targetUnit, false, a_positionX, a_positionY)){
ActionManager.getInstance().add(new AttackUnitAction(a_positionX, a_positionY, m_targetUnit.getX(), m_targetUnit.getY()), true);
return;
};
var bestTarget:Unit;
var bestCostDamage:Number = 0;
var i:int;
while (i < 4) {
x = 0;
y = 0;
if (i == 0){
x = -1;
y = 0;
} else {
if (i == 1){
x = 1;
y = 0;
} else {
if (i == 2){
x = 0;
y = -1;
} else {
x = 0;
y = 1;
};
};
};
tile = game.tileAt((a_positionX + x), (a_positionY + y));
if (tile == null){
} else {
oppurtunityTarget = tile.getUnit();
if (oppurtunityTarget == null){
} else {
if (oppurtunityTarget.getController() == a_attackingUnit.getController()){
} else {
costDamage = game.resolveAttackCycleInResources(a_attackingUnit, oppurtunityTarget);
if ((((bestTarget == null)) || ((((costDamage > 0)) && ((costDamage > bestCostDamage)))))){
bestTarget = oppurtunityTarget;
bestCostDamage = costDamage;
};
};
};
};
i++;
};
if (bestTarget != null){
ActionManager.getInstance().add(new AttackUnitAction(a_positionX, a_positionY, bestTarget.getX(), bestTarget.getY()), true);
};
}
protected function moveTo(a_unit:Unit, a_destination:Tile, a_forceNow:Boolean=false):void{
var pointPath:Array;
if (!a_unit.canMove()){
return;
};
var game:GameManager = GameManager.getInstance();
var startTile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var flags:int;
flags = Tile.k_astarFlagIgnoreLastNode;
var path:Array = Astar.pathTrim(startTile, a_destination, a_unit, flags);
if (path == null){
trace("AITaskKill.moveTo: We can't reach our target. This should not have happened because we should never let a unit be assigned to us that was useless.");
} else {
if (path.length == 0){
trace("AITaskKill. moveTo Why is our path 0?");
};
if ((((path.length > 0)) && (!((path[(path.length - 1)].getUnit() == null))))){
if (!path[(path.length - 1)].getUnit().isCloaked()){
path.pop();
};
};
pointPath = game.pointPath(path);
if (a_unit.canMove()){
ActionManager.getInstance().add(new MoveUnitAction(a_unit.getX(), a_unit.getY(), pointPath), a_forceNow);
};
};
}
function createCheapestKillersQueue():Array{
var engine:AIEngine = m_manager.getEngine();
var controller:Controller = engine.getController();
var options:Array = new Array();
var tile:Tile = GameManager.getInstance().tileAt(m_targetUnit.getX(), m_targetUnit.getY());
switch (m_targetUnit.getName()){
case "Heavy Commando":
options.push("Strike Commando");
break;
case "Strike Commando":
options.push("Strike Commando");
break;
case "Flak Tank":
options.push("Scorpion Tank");
break;
case "Scorpion Tank":
options.push("Heavy Commando");
break;
case "Mortar Truck":
options.push("Strike Commando");
break;
case "Rocket Truck":
options.push("Strike Commando");
break;
case "Annihilator Tank":
options.push("Heavy Commando");
break;
case "Turret":
options.push("Heavy Commando");
break;
case "Stealth Tank":
options.push("Heavy Commando");
break;
case "Albatross Transport":
case "Raptor Fighter":
case "Condor Bomber":
if (((tile.isSeaBased()) || (!(controller.controlsGround())))){
if (controller.controlsAir()){
options.push("Raptor Fighter");
} else {
if (controller.controlsSea()){
options.push("Hunter Support");
} else {
options.push("Flak Tank");
};
};
} else {
options.push("Flak Tank");
};
break;
case "Leviathan Barge":
if (controller.controlsAir()){
options.push("Raptor Fighter");
} else {
if (controller.controlsSea()){
options.push("Corvette Fighter");
} else {
options.push("Rocket Truck");
};
};
break;
case "Hunter Support":
if (controller.controlsSea()){
options.push("Corvette Fighter");
} else {
if (controller.controlsGround()){
options.push("Rocket Truck");
} else {
options.push("Condor Bomber");
};
};
break;
case "Corvette Fighter":
if (controller.controlsSea()){
options.push("U-Boat");
} else {
if (controller.controlsGround()){
options.push("Rocket Truck");
} else {
options.push("Raptor Fighter");
};
};
break;
case "U-Boat":
if (controller.controlsSea()){
options.push("Hunter Support");
} else {
if (controller.controlsAir()){
options.push("Condor Bomber");
} else {
options.push("Rocket Truck");
};
};
break;
case "Battlecruiser":
if (controller.controlsSea()){
options.push("U-Boat");
} else {
if (controller.controlsAir()){
options.push("Raptor Fighter");
} else {
options.push("Rocket Truck");
};
};
break;
case "Intrepid":
if (controller.controlsAir()){
options.push("Raptor Fighter");
} else {
if (controller.controlsSea()){
options.push("Intrepid");
} else {
options.push("Rocket Truck");
};
};
break;
default:
trace(("AIEngine: cheapestKillersQueue, unknown unit type: " + m_targetUnit.getName()));
break;
};
return (options);
}
override protected function buildImpl(a_possibleFactories:Array, a_resourcesAvailable:Number):Number{
var unitType:String;
var unitData:UnitData;
var fakeUnit:Unit;
var bestFactory:Tile;
var bestTurnCount:int;
var bestFactoryIndex:int;
var f:int;
var factory:Tile;
var turns:int;
var game:GameManager = GameManager.getInstance();
var targetTile:Tile = game.tileAt(m_targetUnit.getX(), m_targetUnit.getY());
var engine:AIEngine = m_manager.getEngine();
var controller:Controller = engine.getController();
var killingUnitOptions:Array = createBestKillersQueue();
var u:int;
while (u < killingUnitOptions.length) {
unitType = killingUnitOptions[u];
unitData = UnitManager.getInstance().get(unitType);
if (unitData.getCost(controller) > a_resourcesAvailable){
} else {
if (((!(controller.controlsGround())) && (unitData.isGround()))){
} else {
if (((!(controller.controlsAir())) && (unitData.isAir()))){
} else {
if (((!(controller.controlsSea())) && (unitData.isSea()))){
} else {
fakeUnit = new Unit(new GameUnit(new GameSprite()), unitData);
bestFactory = null;
bestTurnCount = 9999999999999;
bestFactoryIndex = -1;
f = 0;
while (f < a_possibleFactories.length) {
factory = a_possibleFactories[f];
turns = Astar.calculateTurnsToPath(factory, targetTile, fakeUnit, Tile.k_astarFlagIgnoreUnits);
if ((((turns >= 0)) && ((turns < bestTurnCount)))){
bestTurnCount = turns;
bestFactoryIndex = f;
bestFactory = factory;
};
f++;
};
if (bestFactory != null){
trace(((("Budget " + a_resourcesAvailable) + " using ") + unitData.getCost(controller)));
trace((((((((((("KILL Building " + unitType) + " at ") + bestFactory.getX()) + ", ") + bestFactory.getY()) + " to kill ") + m_targetUnit) + " in ") + bestTurnCount) + " turns."));
a_possibleFactories.splice(bestFactoryIndex, 1);
ActionManager.getInstance().add(new BuildUnitAction(bestFactory.getX(), bestFactory.getY(), unitType), true);
return (unitData.getCost(controller));
};
};
};
};
};
u++;
};
return (0);
}
override protected function handleUnitDiedImpl(a_unit:Unit):void{
var unit:Unit;
if (m_targetUnit == a_unit){
m_targetUnit = null;
completeTask();
return;
};
var i:int;
while (i < m_attackingUnits.length) {
unit = m_attackingUnits[i];
if (unit == a_unit){
m_attackingUnits.splice(i, 1);
return;
};
i++;
};
}
}
}//package com.gamedozer.battalion.game.ai
Section 71
//AITaskManager (com.gamedozer.battalion.game.ai.AITaskManager)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class AITaskManager {
private var m_reinforcementAttemptCount:int;
private var m_activeTasks:Array;
private var m_aiEngine:AIEngine;
private var m_ignoredTasks:Array;
private var m_activeUnits:Array;
private var m_tasks:Array;
private static const MAXIMUM_REINFORCEMENT_ATTEMPTS:int = 5;
public function AITaskManager(a_aiEngine:AIEngine){
super();
m_aiEngine = a_aiEngine;
m_tasks = new Array();
m_activeTasks = new Array();
m_activeUnits = new Array();
m_ignoredTasks = new Array();
m_reinforcementAttemptCount = MAXIMUM_REINFORCEMENT_ATTEMPTS;
}
private function assignUnits():void{
var bestTask:AITask = popBestTask();
if (bestTask == null){
return;
};
var availableUnitLength:int = m_activeUnits.length;
bestTask.assignUnits(m_activeUnits);
if (availableUnitLength == m_activeUnits.length){
ActionManager.getInstance().add(new DelayedCallbackAction(assignUnits, 200, "assignUnits"));
} else {
trace(("EXECUTING: " + bestTask));
bestTask.execute();
};
}
public function addTask(a_task:AITask):void{
m_tasks.push(a_task);
}
public function compareTwoUnits(a_unitA:Unit, a_unitB:Unit):Number{
var aTacticalValue:Number = (a_unitA.getUnitData().getHealth() * a_unitA.getUnitData().getCost());
var bTacticalValue:Number = (a_unitB.getUnitData().getHealth() * a_unitB.getUnitData().getCost());
if (aTacticalValue > bTacticalValue){
return (1);
};
if (aTacticalValue < bTacticalValue){
return (-1);
};
return (0);
}
function nestThink():void{
regenerateNonIgnoredTasks();
think();
}
function cleanupTasks():void{
var task:AITask;
var i:int = (m_tasks.length - 1);
while (i >= 0) {
task = m_tasks[i];
if (task.isComplete()){
task.dispose();
m_tasks.splice(i, 1);
};
i--;
};
}
public function sortActiveUnits():void{
m_activeUnits.sort(compareTwoUnits);
}
public function regenerateNonIgnoredTasks():void{
cleanupTasks();
m_activeTasks.splice(0);
prepareThink();
}
function useActiveUnit(a_unit:Unit):void{
var unit:Unit;
var i:int;
while (i < m_activeUnits.length) {
unit = m_activeUnits[i];
if (unit == a_unit){
m_activeUnits.splice(i, 1);
return;
};
i++;
};
}
function getController():AIController{
return (m_aiEngine.getController());
}
function popBestTask():AITask{
if (m_activeTasks.length == 0){
return (null);
};
var bestTask:AITask = m_activeTasks[0];
m_activeTasks.splice(0, 1);
return (bestTask);
}
public function handleKilledUnit(a_unit:Unit):void{
var task:AITask;
for each (task in m_tasks) {
task.handleUnitDied(a_unit);
};
}
function sortActiveTasks():void{
m_activeTasks.sortOn(["priority"], Array.DESCENDING);
}
public function prepareThink():void{
var task:AITask;
var i:int;
while (i < m_tasks.length) {
task = m_tasks[i];
task.updatePriority();
if (task.priority > 0){
m_activeTasks.push(task);
};
i++;
};
sortActiveTasks();
m_activeUnits = getAvailableUnits();
sortActiveUnits();
trace(("TASK LIST: " + m_activeTasks));
}
private function assignReinforcements():void{
var bestTask:AITask = popBestTask();
if (bestTask == null){
return;
};
m_activeUnits = getAvailableUnits(false);
var availableUnitLength:int = m_activeUnits.length;
bestTask.marshallReinforcements(m_activeUnits);
if (availableUnitLength == m_activeUnits.length){
m_ignoredTasks.push(bestTask);
ActionManager.getInstance().add(new DelayedCallbackAction(assignReinforcements, 250, "assignReinforcements"));
};
}
public function think():void{
if (m_reinforcementAttemptCount != MAXIMUM_REINFORCEMENT_ATTEMPTS){
assignReinforcements();
} else {
assignUnits();
};
if ((((((m_reinforcementAttemptCount >= 0)) && (!((m_activeUnits.length == 0))))) && ((m_activeTasks.length == 0)))){
m_reinforcementAttemptCount--;
ActionManager.getInstance().add(new DelayedCallbackAction(nestThink, 100, "nestThink"));
return;
};
if (m_activeTasks.length == 0){
if (m_activeUnits.length != 0){
trace(("AITaskManager. We didn't use all our units this turn. Left overs: " + m_activeUnits));
};
m_reinforcementAttemptCount = MAXIMUM_REINFORCEMENT_ATTEMPTS;
m_aiEngine.finishTurn();
};
}
function getAvailableUnits(a_allowUnmoveables:Boolean=true):Array{
var unit:Unit;
var availableUnits:Array = new Array();
var units:Array = getController().getUnits();
var i:int;
while (i < units.length) {
unit = units[i];
if (unit.isAvailable()){
if (((a_allowUnmoveables) || (unit.canMove()))){
availableUnits.push(unit);
};
};
i++;
};
return (availableUnits);
}
function getEngine():AIEngine{
return (m_aiEngine);
}
public function cleanupThink():void{
cleanupTasks();
m_activeTasks.splice(0);
m_ignoredTasks.splice(0);
}
public function ignoreTask(a_task:AITask):void{
m_ignoredTasks.push(a_task);
}
}
}//package com.gamedozer.battalion.game.ai
Section 72
//AITaskRepairUnit (com.gamedozer.battalion.game.ai.AITaskRepairUnit)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class AITaskRepairUnit extends AITask {
private var m_repairUnit:Unit;
private var m_canExecute:Boolean;// = false
public function AITaskRepairUnit(a_manager:AITaskManager, a_repairUnit:Unit){
super(a_manager);
m_repairUnit = a_repairUnit;
priority = 0.5;
}
override protected function assignUnitsImpl(a_activeUnits:Array):void{
var unit:Unit;
m_canExecute = false;
if (m_repairUnit.getHealthPercentage() == 1){
return;
};
var i:int = (a_activeUnits.length - 1);
while (i >= 0) {
unit = a_activeUnits[i];
if (unit == m_repairUnit){
m_canExecute = true;
a_activeUnits.splice(i, 1);
return;
};
i--;
};
}
override public function toString():String{
return ((((("[REP " + m_priority) + ": ") + m_repairUnit) + " ]"));
}
override protected function updatePriorityImpl():void{
if (m_repairUnit.getHealthPercentage() >= 1){
priority = 0;
return;
};
if (m_repairUnit.isUpgraded()){
priority = 0;
return;
};
var repairCost:Number = Math.round((m_repairUnit.getUnitData().getCost(m_repairUnit.getController()) * GameManager.getInstance().healPercentage(m_repairUnit)));
var availableResources:Number = m_repairUnit.getController().getResources();
if (availableResources < repairCost){
priority = 0;
return;
};
priority = 0.1;
}
override protected function buildImpl(a_possibleFactories:Array, a_resourcesAvailable:Number):Number{
return (0);
}
override protected function handleUnitDiedImpl(a_unit:Unit):void{
if (m_repairUnit == a_unit){
completeTask();
return;
};
}
function moveUnitCloserToTarget(a_unit:Unit, a_endTile:Tile):void{
var pointPath:Array;
if (!a_unit.canMove()){
return;
};
var game:GameManager = GameManager.getInstance();
var startTile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var path:Array = Astar.pathTrim(startTile, a_endTile, a_unit, Tile.k_astarFlagIgnoreLastNode);
if (path == null){
} else {
if (path[(path.length - 1)].getUnit() != null){
if (!path[(path.length - 1)].getUnit().isCloaked()){
path.pop();
};
};
pointPath = game.pointPath(path);
ActionManager.getInstance().add(new MoveUnitAction(a_unit.getX(), a_unit.getY(), pointPath), true);
};
}
override protected function executeImpl():void{
var nodes:Array;
var safestTile:Tile;
var leastDamage:Number;
var i:int;
var tile:Tile;
var damage:Number;
if (!m_canExecute){
return;
};
var game:GameManager = GameManager.getInstance();
var aiEngine:AIEngine = m_manager.getEngine();
var start:Tile = game.tileAt(m_repairUnit.getX(), m_repairUnit.getY());
var currentTileDamage:Number = aiEngine.getDangerForUnit(m_repairUnit, start);
if (aiEngine.isSafeToRepair(m_repairUnit)){
ActionManager.getInstance().add(new RepairUnitAction(m_repairUnit.getX(), m_repairUnit.getY()));
} else {
nodes = Astar.search(start, null, m_repairUnit);
safestTile = null;
leastDamage = currentTileDamage;
i = 0;
while (i < nodes.length) {
tile = nodes[i];
damage = aiEngine.getDangerForUnit(m_repairUnit, tile);
if ((((safestTile == null)) || ((damage < leastDamage)))){
safestTile = tile;
leastDamage = damage;
};
i++;
};
trace(("Safest tile : " + safestTile));
if (((!((safestTile == null))) && (!((safestTile == start))))){
moveUnitCloserToTarget(m_repairUnit, safestTile);
};
};
}
override protected function disposeImpl():void{
m_repairUnit = null;
}
}
}//package com.gamedozer.battalion.game.ai
Section 73
//ControllerInfluence (com.gamedozer.battalion.game.ai.ControllerInfluence)
package com.gamedozer.battalion.game.ai {
import flash.events.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class ControllerInfluence {
private var m_influenceMaps:Array;
private var m_dangerToMediumArmor:InfluenceMapDangerToArmorType;
private var m_dangerToHeavyArmor:InfluenceMapDangerToArmorType;
private var m_mapToLoad:int;// = -1
private var m_controller:Controller;
private var m_dangerToLightArmor:InfluenceMapDangerToArmorType;
private var m_mapControl:InfluenceMapControl;
private var m_tacticalValue:InfluenceMapTacticalValue;
public function ControllerInfluence(a_controller:Controller){
super();
m_controller = a_controller;
m_influenceMaps = new Array();
m_dangerToLightArmor = new InfluenceMapDangerToArmorType(m_controller, 1);
addInfluenceMap(m_dangerToLightArmor);
m_dangerToMediumArmor = new InfluenceMapDangerToArmorType(m_controller, 2);
addInfluenceMap(m_dangerToMediumArmor);
m_dangerToHeavyArmor = new InfluenceMapDangerToArmorType(m_controller, 3);
addInfluenceMap(m_dangerToHeavyArmor);
m_tacticalValue = new InfluenceMapTacticalValue();
addInfluenceMap(m_tacticalValue);
m_mapControl = new InfluenceMapControl(m_controller, m_tacticalValue);
addInfluenceMap(m_mapControl);
}
public function addUnit(a_unit:Unit):void{
var map:InfluenceMap;
var i:int;
while (i < m_influenceMaps.length) {
map = m_influenceMaps[i];
map.addUnit(a_unit);
i++;
};
}
function doCapture(a_map:InfluenceMap, a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
a_map.captureTerrain(a_tile, a_oldPlayer, a_player, a_complete);
}
public function isStillInitializing():Boolean{
return ((m_mapToLoad < m_influenceMaps.length));
}
public function getDangerToArmorType(a_armorType:int):InfluenceMapDangerToArmorType{
if (a_armorType == 1){
return (m_dangerToLightArmor);
};
if (a_armorType == 2){
return (m_dangerToMediumArmor);
};
if (a_armorType == 3){
return (m_dangerToHeavyArmor);
};
trace("Bad controller.");
return (null);
}
function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
var map:InfluenceMap;
var i:int;
while (i < m_influenceMaps.length) {
map = m_influenceMaps[i];
doCapture(map, a_tile, a_oldPlayer, a_player, a_complete);
i++;
};
}
function getController():Controller{
return (m_controller);
}
public function getDangerForUnit(a_unit:Unit, a_tile:Tile):Number{
var map:InfluenceMapDangerToArmorType = getDangerToArmorType(a_unit.getArmorType());
return (map.getWeight(a_tile));
}
public function initialize():void{
var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, loadMap);
timer.start();
m_mapToLoad = 0;
}
public function getKillPriority(a_unit:Unit):Number{
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
var weight:Number = m_mapControl.getNormalizedWeight(tile);
weight = (weight * getTacticalPriority(tile));
return (weight);
}
function getCapturePriority(a_tile:Tile):Number{
return ((1 - m_mapControl.getNormalizedWeight(a_tile)));
}
private function loadMap(a_event:Event):void{
var timer:Timer;
if (m_mapToLoad >= m_influenceMaps.length){
timer = (a_event.target as Timer);
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, loadMap);
timer = null;
return;
};
var map:InfluenceMap = m_influenceMaps[m_mapToLoad];
map.initialize();
m_mapToLoad++;
}
public function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
var map:InfluenceMap;
var i:int;
while (i < m_influenceMaps.length) {
map = m_influenceMaps[i];
map.changeUpgradeStatus(a_unit, a_name, a_upgraded);
i++;
};
}
public function isSafeToRepair(a_unit:Unit):Boolean{
var map:InfluenceMapDangerToArmorType = getDangerToArmorType(a_unit.getArmorType());
var game:GameManager = GameManager.getInstance();
var tile:Tile = game.tileAt(a_unit.getX(), a_unit.getY());
if (map.getWeight(tile) < 0){
return (true);
};
return (false);
}
function getTacticalPriority(a_tile:Tile):Number{
return (m_tacticalValue.getNormalizedWeight(a_tile));
}
public function attackUnit(a_unit:Unit, a_target:Unit):void{
}
public function addInfluenceMap(a_map:InfluenceMap):void{
m_influenceMaps.push(a_map);
}
public function moveUnit(a_unit:Unit, a_path:Array):void{
var map:InfluenceMap;
var i:int;
while (i < m_influenceMaps.length) {
map = m_influenceMaps[i];
map.moveUnit(a_unit, a_path);
i++;
};
}
public function removeUnit(a_unit:Unit):void{
var map:InfluenceMap;
var i:int;
while (i < m_influenceMaps.length) {
map = m_influenceMaps[i];
map.removeUnit(a_unit);
i++;
};
}
}
}//package com.gamedozer.battalion.game.ai
Section 74
//InfluenceMap (com.gamedozer.battalion.game.ai.InfluenceMap)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class InfluenceMap {
private var m_maximumWeightNode:InfluenceNode;
private var m_minimumWeightNode:InfluenceNode;
private var m_influenceMap:Dictionary;
public function InfluenceMap(){
super();
m_influenceMap = new Dictionary(false);
m_minimumWeightNode = null;
m_maximumWeightNode = null;
}
function getMaximumWeight():Number{
if (m_maximumWeightNode == null){
return (0);
};
return (m_maximumWeightNode.weight);
}
function draw():void{
var node:InfluenceNode;
var tile:Tile;
var color:uint;
var weight:Number;
for each (node in m_influenceMap) {
tile = node.tile;
color = 0xFFFFFF;
weight = node.weight;
if (Math.abs(weight) < 0.0001){
tile.showText("");
} else {
if (weight < 0){
color = 0xFF0000;
};
tile.showText(((Math.round((weight * 1000)) / 1000) + ""), color);
};
};
}
function getNormalizedWeight(a_tile:Tile):Number{
var maximumWeight:Number = getMaximumWeight();
var minimumWeight:Number = getMinimumWeight();
var normalizedMax:Number = (maximumWeight - minimumWeight);
var weight:Number = getWeight(a_tile);
var normalizedWeight:Number = (weight - minimumWeight);
if (normalizedMax == 0){
return (0);
};
var scaledWeight:Number = (normalizedWeight / normalizedMax);
return (scaledWeight);
}
public function addUnit(a_unit:Unit):void{
}
function reset():void{
var node:InfluenceNode;
for each (node in m_influenceMap) {
node.weight = 0;
};
m_minimumWeightNode = null;
m_maximumWeightNode = null;
}
function recalculate():void{
reset();
initialize();
}
public function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
}
function initialize():void{
initializeImpl();
}
function drawNormalized():void{
var node:InfluenceNode;
var tile:Tile;
var color:uint;
var weight:Number;
for each (node in m_influenceMap) {
tile = node.tile;
color = 0xFFFFFF;
weight = getNormalizedWeight(tile);
if (weight < 0.5){
color = 0;
};
tile.showText(((Math.round((weight * 1000)) / 1000) + ""), color);
};
}
public function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
}
function initializeImpl():void{
}
function updateWeight(a_node:InfluenceNode):void{
if (a_node.weight < m_minimumWeightNode.weight){
m_minimumWeightNode = a_node;
return;
};
if (a_node.weight > m_maximumWeightNode.weight){
m_maximumWeightNode = a_node;
return;
};
}
function getMinimumTile():Tile{
if (m_minimumWeightNode == null){
return (null);
};
return (m_minimumWeightNode.tile);
}
public function removeUnit(a_unit:Unit):void{
}
function propagate(a_x:int, a_y:int, amount:Number, dieOff:Number, a_maximumRange:int, a_allowWaterTiles:Boolean):void{
var currentTile:Tile;
var influenceNode:InfluenceNode;
var distanceX:int;
var distanceY:int;
var distance:int;
var changeAmount:Number;
var range:int = a_maximumRange;
var tile:Tile = GameManager.getInstance().tileAt(a_x, a_y);
var nodes:Array = Astar.search(tile, null, null, range, false);
var n:int;
while (n < nodes.length) {
currentTile = nodes[n];
if (!a_allowWaterTiles){
//unresolved if
} else {
influenceNode = getNode(currentTile);
distanceX = Math.abs((currentTile.getX() - tile.getX()));
distanceY = Math.abs((currentTile.getY() - tile.getY()));
distance = (distanceX + distanceY);
changeAmount = (amount * Math.pow(dieOff, distance));
influenceNode.weight = (influenceNode.weight + changeAmount);
};
n++;
};
}
function getWeight(a_tile:Tile):Number{
var node:InfluenceNode = getNode(a_tile);
return (node.weight);
}
function getMinimumWeight():Number{
if (m_minimumWeightNode == null){
return (0);
};
return (m_minimumWeightNode.weight);
}
public function moveUnit(a_unit:Unit, a_path:Array):void{
}
function getNode(a_tile:Tile):InfluenceNode{
if (m_influenceMap[a_tile] == null){
m_influenceMap[a_tile] = new InfluenceNode(a_tile, this);
};
var node:InfluenceNode = m_influenceMap[a_tile];
if (m_minimumWeightNode == null){
m_minimumWeightNode = node;
m_maximumWeightNode = node;
};
return (node);
}
public function attackUnit(a_unit:Unit, a_target:Unit):void{
}
function getMaximumTile():Tile{
if (m_maximumWeightNode == null){
return (null);
};
return (m_maximumWeightNode.tile);
}
}
}//package com.gamedozer.battalion.game.ai
Section 75
//InfluenceMapControl (com.gamedozer.battalion.game.ai.InfluenceMapControl)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.actions.*;
public class InfluenceMapControl extends InfluenceMap {
private var m_tacticalValueMap:InfluenceMapTacticalValue;
private var m_controller:Controller;
public function InfluenceMapControl(a_controller:Controller, a_tacticalValue:InfluenceMapTacticalValue){
super();
m_controller = a_controller;
m_tacticalValueMap = a_tacticalValue;
}
function calculateTileInfluence(a_tile:Tile):void{
var weight:Number;
var dieOff:Number;
var maximumRange:int;
var x:int = a_tile.getX();
var y:int = a_tile.getY();
if (a_tile.isStructure()){
weight = m_tacticalValueMap.getWeight(a_tile);
dieOff = 0.5;
maximumRange = 6;
if (a_tile.getController() == m_controller){
weight = (weight * 2);
} else {
if (a_tile.getController() == null){
weight = (weight * 1);
} else {
if (a_tile.getController() != m_controller){
weight = (weight * -1);
};
};
};
propagate(x, y, weight, dieOff, maximumRange, false);
};
}
override public function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
m_tacticalValueMap.recalculate();
ActionManager.getInstance().add(new CallbackAction(recalculate));
}
override function initializeImpl():void{
var x:int;
var tile:Tile;
var tileMap:Array = GameManager.getInstance().getTileMap();
var y:int;
while (y < tileMap.length) {
x = 0;
while (x < tileMap[y].length) {
tile = tileMap[y][x];
calculateTileInfluence(tile);
x++;
};
y++;
};
if (m_controller.getTeam().getName() == "Blue Team"){
};
}
}
}//package com.gamedozer.battalion.game.ai
Section 76
//InfluenceMapDangerToArmorType (com.gamedozer.battalion.game.ai.InfluenceMapDangerToArmorType)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.controllers.*;
public class InfluenceMapDangerToArmorType extends InfluenceMap {
private var m_influence:Dictionary;
private var m_againstArmorType:int;
private var m_controller:Controller;
public function InfluenceMapDangerToArmorType(a_controller:Controller, a_againstArmorType:int){
m_influence = new Dictionary(false);
super();
m_controller = a_controller;
m_againstArmorType = a_againstArmorType;
}
function calculateTileInfluence(a_tile:Tile):void{
var unit:Unit = a_tile.getUnit();
if (unit == null){
return;
};
addUnit(unit);
}
function display():void{
if (m_controller.getTeam().getName() == "Blue Team"){
if (m_againstArmorType == 1){
};
};
}
override public function addUnit(a_unit:Unit):void{
doInfluence(a_unit.getX(), a_unit.getY(), a_unit);
display();
}
function changeWeight(a_amount:Number, a_nodes:Array):void{
var currentTile:Tile;
var influenceNode:InfluenceNode;
var i:int;
while (i < a_nodes.length) {
currentTile = a_nodes[i];
influenceNode = getNode(currentTile);
influenceNode.weight = (influenceNode.weight + a_amount);
i++;
};
}
override public function attackUnit(a_unit:Unit, a_target:Unit):void{
}
override public function removeUnit(a_unit:Unit):void{
undoInfluence(a_unit.getX(), a_unit.getY(), a_unit);
if (m_influence[a_unit] != null){
if (m_influence[a_unit].nodes != null){
m_influence[a_unit].nodes.splice(0);
};
delete m_influence[a_unit];
};
display();
}
override function initializeImpl():void{
var x:int;
var tile:Tile;
var tileMap:Array = GameManager.getInstance().getTileMap();
var y:int;
while (y < tileMap.length) {
x = 0;
while (x < tileMap[y].length) {
tile = tileMap[y][x];
calculateTileInfluence(tile);
x++;
};
y++;
};
display();
}
function doInfluence(a_x:int, a_y:int, a_unit:Unit):void{
var game:GameManager = GameManager.getInstance();
var damage:Number = a_unit.getAttackDamage(m_againstArmorType);
if (m_controller.controlsUnit(a_unit)){
damage = (damage * -1);
};
if (m_influence[a_unit] == null){
m_influence[a_unit] = new Influences();
};
m_influence[a_unit].amount = damage;
var attackableNodes:Array = game.getNodesInAttackRange(a_x, a_y, a_unit);
m_influence[a_unit].nodes = attackableNodes;
if (attackableNodes == null){
trace((("InfluenceMapDamageToArmorType: " + a_unit) + " cannot attack. It has no attackable nodes."));
return;
};
changeWeight(damage, attackableNodes);
}
override public function moveUnit(a_unit:Unit, a_path:Array):void{
undoInfluence(a_path[0], a_path[1], a_unit);
doInfluence(a_path[(a_path.length - 2)], a_path[(a_path.length - 1)], a_unit);
display();
}
function undoInfluence(a_x:int, a_y:int, a_unit:Unit):void{
if (m_influence[a_unit] == null){
return;
};
if ((((m_influence[a_unit].nodes == null)) || ((m_influence[a_unit].nodes.length == 0)))){
return;
};
var game:GameManager = GameManager.getInstance();
var influenceAmount:Number = m_influence[a_unit].amount;
var nodes:Array = m_influence[a_unit].nodes;
changeWeight(-(influenceAmount), nodes);
m_influence[a_unit].nodes.splice(0);
}
override public function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
if (a_upgraded){
undoInfluence(a_unit.getX(), a_unit.getY(), a_unit);
} else {
doInfluence(a_unit.getX(), a_unit.getY(), a_unit);
};
display();
}
}
}//package com.gamedozer.battalion.game.ai
class Influences {
public var amount:Number;
public var nodes:Array;// = null
private function Influences(){
super();
}
}
Section 77
//InfluenceMapTacticalValue (com.gamedozer.battalion.game.ai.InfluenceMapTacticalValue)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.controllers.*;
public class InfluenceMapTacticalValue extends InfluenceMap {
private var m_commandCenterInfluence:Number;
private var m_oilRigControlInfluence:Number;
private var m_hasFactory:Boolean;// = false
private var m_oilRefineryControlInfluence:Number;
private var m_airControlInfluence:Number;
private var m_groundControlInfluence:Number;
private var m_seaControlInfluence:Number;
private var m_advancedOilRefineryControlInfluence:Number;
private var m_factoryControlInfluence:Number;
public function InfluenceMapTacticalValue(){
super();
m_commandCenterInfluence = BattalionSettings.getSingleton().getNumber("ai_commandCenterInfluence", 9);
m_seaControlInfluence = BattalionSettings.getSingleton().getNumber("ai_seaControlInfluence", 6);
m_airControlInfluence = BattalionSettings.getSingleton().getNumber("ai_airControlInfluence", 6);
m_groundControlInfluence = BattalionSettings.getSingleton().getNumber("ai_groundControlInfluence", 6);
m_factoryControlInfluence = BattalionSettings.getSingleton().getNumber("ai_factoryControlInfluence", 7);
m_oilRigControlInfluence = BattalionSettings.getSingleton().getNumber("ai_oilRigControlInfluence", 6);
m_oilRefineryControlInfluence = BattalionSettings.getSingleton().getNumber("ai_oilRefineryControlInfluence", 8);
m_advancedOilRefineryControlInfluence = BattalionSettings.getSingleton().getNumber("ai_advancedOilRefineryControlInfluence", 7);
}
function isMissionCritical(a_tile:Tile):Boolean{
return ((a_tile.getTerrain().getName() == "Command Center"));
}
function calculateTileInfluence(a_tile:Tile):void{
var amount:Number;
var allowWaterTiles:Boolean;
var dieOff:Number;
var maximumRange:int;
var x:int = a_tile.getX();
var y:int = a_tile.getY();
if (a_tile.isStructure()){
amount = 0;
allowWaterTiles = false;
if (a_tile.getTerrain().getName() == "Command Center"){
amount = m_commandCenterInfluence;
} else {
if (a_tile.getTerrain().getName() == "Sea Control"){
amount = m_seaControlInfluence;
} else {
if (a_tile.getTerrain().getName() == "Air Control"){
amount = m_airControlInfluence;
} else {
if (a_tile.getTerrain().getName() == "Ground Control"){
amount = m_groundControlInfluence;
} else {
if (a_tile.getTerrain().getName() == "Factory"){
amount = m_factoryControlInfluence;
} else {
if (a_tile.getTerrain().getName() == "Oil Rig"){
amount = m_oilRigControlInfluence;
allowWaterTiles = true;
} else {
if (a_tile.getTerrain().getName() == "Oil Refinery"){
amount = m_oilRefineryControlInfluence;
} else {
if (a_tile.getTerrain().getName() == "Advanced Oil Refinery"){
amount = m_advancedOilRefineryControlInfluence;
};
};
};
};
};
};
};
};
if (((!(m_hasFactory)) && (!(isMissionCritical(a_tile))))){
if (a_tile.getTerrain().getName().indexOf("Control") > 0){
return;
};
if (a_tile.getTerrain().getName().indexOf("Oil") > 0){
amount = (amount / 4);
};
};
dieOff = 0.5;
maximumRange = 3;
propagate(x, y, amount, dieOff, maximumRange, allowWaterTiles);
return;
};
var defenseScale:Number = 1;
var fakeUnitData:UnitData = new UnitData("fake", "", 0, 10, 100, 100, 1, 1, UnitData.unitTypeFromString("ground"), UnitData.movementTypeFromString("tracked"), 0, UnitData.armorTypeFromString("light"), "", "");
var fakeUnit:Unit = new Unit(new GameUnit(new GameSprite()), fakeUnitData);
defenseScale = a_tile.getTerrain().applyModifiers("defense", fakeUnit, defenseScale);
if (defenseScale < 1){
amount = (1 - defenseScale);
amount = (amount * 10);
dieOff = 0.3;
maximumRange = 3;
propagate(x, y, amount, dieOff, maximumRange, false);
return;
};
}
function isFactory(a_tile:Tile):Boolean{
return ((a_tile.getTerrain().getName() == "Factory"));
}
override function initializeImpl():void{
var x:int;
var tile:Tile;
var tileMap:Array = GameManager.getInstance().getTileMap();
var y:int;
while (y < tileMap.length) {
x = 0;
while (x < tileMap[y].length) {
tile = tileMap[y][x];
if (isFactory(tile)){
m_hasFactory = true;
};
x++;
};
y++;
};
y = 0;
while (y < tileMap.length) {
x = 0;
while (x < tileMap[y].length) {
tile = tileMap[y][x];
calculateTileInfluence(tile);
x++;
};
y++;
};
}
}
}//package com.gamedozer.battalion.game.ai
Section 78
//InfluenceNode (com.gamedozer.battalion.game.ai.InfluenceNode)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
public class InfluenceNode {
private var m_tile:Tile;
private var m_weight:Number;
private var m_map:InfluenceMap;
public function InfluenceNode(a_tile:Tile, a_map:InfluenceMap){
super();
m_map = a_map;
m_tile = a_tile;
m_weight = 0;
}
public function set weight(value:Number):void{
m_weight = value;
m_map.updateWeight(this);
}
public function get weight():Number{
return (m_weight);
}
public function get tile():Tile{
return (m_tile);
}
public function dispose():void{
m_tile = null;
}
}
}//package com.gamedozer.battalion.game.ai
Section 79
//UnitBuilder (com.gamedozer.battalion.game.ai.UnitBuilder)
package com.gamedozer.battalion.game.ai {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.controllers.*;
public class UnitBuilder {
private var m_engine:AIEngine;
private var m_queue:Array;
public function UnitBuilder(a_engine:AIEngine){
super();
m_engine = a_engine;
m_queue = new Array();
}
function processHighestPriorityBuildRequest(a_possibleFactories:Array, a_overageAvailable:Number):Number{
var owner:AIController = m_engine.getController();
var request:BuildRequest = m_queue[0];
m_queue.splice(0, 1);
var task:AITask = request.task;
var minRequired:Number = task.calculateMinimumResourcesRequiredToBuild();
trace(((((("Giving " + (minRequired + a_overageAvailable)) + " to ") + task) + ". Res left: ") + owner.getResources()));
var resourcesUsed:Number = task.build(a_possibleFactories, (minRequired + a_overageAvailable));
if (resourcesUsed > (minRequired + a_overageAvailable)){
throw (new Error((task + " tried to use more resources than it was allocated.")));
};
var overageUsed:Number = (a_overageAvailable - (resourcesUsed - minRequired));
return (overageUsed);
}
function build():void{
var factory:Tile;
var request:BuildRequest;
var task:AITask;
var minimumRequired:Number;
var overageUsed:Number;
var owner:AIController = m_engine.getController();
var structures:Array = owner.getStructures();
var possibleFactories:Array = new Array();
var f:int;
while (f < structures.length) {
factory = structures[f];
if (!factory.getTerrain().hasModifier("Construction")){
} else {
if (factory.getUnit() != null){
} else {
if (factory.getController() != owner){
} else {
possibleFactories.push(factory);
};
};
};
f++;
};
if (possibleFactories.length == 0){
trace("No possible build locations.");
return;
};
trace((((("Process building. [" + m_queue.length) + "] requests. Possible construction sites: [") + possibleFactories.length) + "]"));
if (m_queue.length > possibleFactories.length){
m_queue.splice(possibleFactories.length);
};
var resourcesAvailable:Number = m_engine.getController().getResources();
var minimumTotalAllocationRequired:Number = 0;
var indexOfFirstTaskWeCantSatisfy = -1;
var q:int;
while (q < m_queue.length) {
request = m_queue[q];
task = request.task;
minimumRequired = task.calculateMinimumResourcesRequiredToBuild();
if ((minimumRequired + minimumTotalAllocationRequired) > resourcesAvailable){
indexOfFirstTaskWeCantSatisfy = q;
break;
};
minimumTotalAllocationRequired = (minimumTotalAllocationRequired + minimumRequired);
q++;
};
if (minimumTotalAllocationRequired == 0){
trace("Not enough for highest priority task, quitting");
return;
};
if (indexOfFirstTaskWeCantSatisfy > 0){
m_queue.splice(indexOfFirstTaskWeCantSatisfy);
};
var overageAvailable:Number = (resourcesAvailable - minimumTotalAllocationRequired);
trace(((((("Overage available " + overageAvailable) + ". MinTot: ") + minimumTotalAllocationRequired) + " , Pruned building tasks: ") + m_queue));
while ((((m_queue.length > 0)) && ((possibleFactories.length > 0)))) {
overageUsed = processHighestPriorityBuildRequest(possibleFactories, overageAvailable);
overageAvailable = (overageAvailable - overageUsed);
trace(((("Overage left: " + overageAvailable) + " after subtracting overageUsed ") + overageUsed));
};
}
function flush():void{
m_queue.splice(0);
}
function queueBuild(a_task:AITask):void{
var buildRequest:BuildRequest = new BuildRequest();
buildRequest.task = a_task;
m_queue.push(buildRequest);
}
}
}//package com.gamedozer.battalion.game.ai
class BuildRequest {
public var task:AITask;
private function BuildRequest(){
super();
}
public function toString():String{
return ((("<Build Request: " + task) + " >"));
}
}
Section 80
//BooleanVariableCondition (com.gamedozer.battalion.game.conditions.BooleanVariableCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class BooleanVariableCondition implements Condition {
protected var boolean:String;
protected var value:Boolean;
public var satisfied:Boolean;
protected static var booleans:Dictionary;
public function BooleanVariableCondition(a_boolean:String, a_value:Boolean, a_satisfied:Boolean=false){
super();
if (booleans == null){
booleans = new Dictionary();
};
satisfied = a_satisfied;
boolean = a_boolean;
value = a_value;
if (booleans[boolean] == null){
booleans[boolean] = !(value);
};
}
public function toXML():XML{
return (new XML((((((("<condition type=\"booleanVariable\"><boolean value=\"" + boolean) + "\"/><value value=\"") + ((booleans[boolean] == true)) ? "true" : "false") + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function update():void{
if (booleans[boolean] == value){
satisfied = true;
};
}
public function reset():void{
satisfied = false;
booleans[boolean] = !(value);
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function dispose():void{
}
public static function getBoolean(a_boolean:String, a_defaultValue:Boolean=false):Boolean{
if (booleans == null){
booleans = new Dictionary();
};
if (booleans[a_boolean] == null){
booleans[a_boolean] = a_defaultValue;
};
return (booleans[a_boolean]);
}
public static function setBoolean(a_boolean:String, a_value:Boolean):void{
if (booleans == null){
booleans = new Dictionary();
};
booleans[a_boolean] = a_value;
}
public static function getFromXML(a_xml:XML):Condition{
var boolean:String = a_xml.boolean.@value;
var value:Boolean;
var booleanString:String = a_xml.value.@value;
if (booleanString.toLowerCase().charAt(0) == "t"){
value = true;
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new BooleanVariableCondition(boolean, value, satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 81
//BuildUnitCondition (com.gamedozer.battalion.game.conditions.BuildUnitCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class BuildUnitCondition implements Condition {
protected var y:int;
protected var player:int;
protected var name:String;
protected var x:int;
public var satisfied:Boolean;
public function BuildUnitCondition(a_name:String="", a_player:int=-1, a_x:int=-1, a_y:int=-1, a_satisfied:Boolean=false){
super();
name = a_name;
x = a_x;
y = a_y;
player = a_player;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(BuildUnitTrigger.TRIGGER, buildUnitListener);
}
private function buildUnitListener(a_trigger:BuildUnitTrigger):void{
var unit:Unit = a_trigger.getUnit();
if ((((name == "")) || ((unit.getUnitData().getName().toLowerCase() == name.toLowerCase())))){
if ((((x == -1)) || ((x == unit.getX())))){
if ((((y == -1)) || ((y == unit.getY())))){
if ((((player == -1)) || ((GameManager.getInstance().getPlayer(unit.getController()) == player)))){
satisfied = true;
};
};
};
};
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
public function toXML():XML{
return (new XML((((((((((("<condition type=\"buildUnit\"> <unitName value=\"" + name) + "\"/> <player value=\"") + (player + 1)) + "\"/> <x value=\"") + x) + "\"/> <y value=\"") + y) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(BuildUnitTrigger.TRIGGER, buildUnitListener);
}
public static function getFromXML(a_xml:XML):Condition{
var name:String = a_xml.unitName.@value;
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var x:String = a_xml.x.@value;
if (x == ""){
x = "-1";
};
var y:String = a_xml.y.@value;
if (y == ""){
y = "-1";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new BuildUnitCondition(name, (int(player) - 1), int(x), int(y), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 82
//CaptureTerrainCondition (com.gamedozer.battalion.game.conditions.CaptureTerrainCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class CaptureTerrainCondition implements Condition {
protected var player:int;
protected var oldPlayer:int;
protected var name:String;
public var satisfied:Boolean;
public function CaptureTerrainCondition(a_name:String="", a_oldPlayer:int=-1, a_player:int=-1, a_satisfied:Boolean=false){
super();
name = a_name;
oldPlayer = a_oldPlayer;
player = a_player;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(CaptureTerrainTrigger.TRIGGER, captureTerrainListener);
}
public function update():void{
}
private function captureTerrainListener(a_trigger:CaptureTerrainTrigger):void{
if (a_trigger.getComplete()){
trace("Capture Trigger is complete!");
if ((((name == "")) || ((a_trigger.getTile().getTerrain().getName().toLowerCase() == name.toLowerCase())))){
if (oldPlayer != -1){
if (oldPlayer == a_trigger.getOldPlayer()){
if (player != -1){
if (player == a_trigger.getPlayer()){
satisfied = true;
};
} else {
satisfied = true;
};
};
} else {
satisfied = true;
};
};
};
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function toXML():XML{
var xml:XML = new XML((((((((("<condition type=\"captureTerrain\"> <terrainName value=\"" + name) + "\"/> <oldPlayer value=\"") + (oldPlayer + 1)) + "\"/> <player value=\"") + (player + 1)) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>"));
return (xml);
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(CaptureTerrainTrigger.TRIGGER, captureTerrainListener);
}
public static function getFromXML(a_xml:XML):Condition{
var name:String = a_xml.terrainName.@value;
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var oldPlayer:String = a_xml.oldPlayer.@value;
if (oldPlayer == ""){
oldPlayer = "0";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
trace(("From XML, satisfied = " + satisfied));
return (new CaptureTerrainCondition(name, (int(oldPlayer) - 1), (int(player) - 1), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 83
//CounterVariableCondition (com.gamedozer.battalion.game.conditions.CounterVariableCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class CounterVariableCondition implements Condition {
protected var counter:String;
protected var defaultValue:int;
protected var value:int;
public var satisfied:Boolean;
protected static var counters:Dictionary;
public function CounterVariableCondition(a_counter:String, a_value:int, a_defaultValue:int=0, a_satisfied:Boolean=false){
super();
if (counters == null){
counters = new Dictionary();
};
satisfied = a_satisfied;
counter = a_counter;
value = a_value;
defaultValue = a_defaultValue;
if (counters[counter] == null){
counters[counter] = defaultValue;
};
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
if (counters[counter] == value){
satisfied = true;
};
}
public function reset():void{
satisfied = false;
counters[counter] = defaultValue;
}
public function toXML():XML{
return (new XML((((((((("<condition type=\"counterVariable\"><counter value=\"" + counter) + "\"/> <value value=\"") + counters[counter]) + "\"/> <defaultValue value=\"") + defaultValue) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function dispose():void{
}
public static function getFromXML(a_xml:XML):Condition{
var counter:String = a_xml.name.@value;
var value:String = a_xml.value.@value;
var defaultValue:String = a_xml.defaulValue.@value;
if (defaultValue == ""){
defaultValue = "0";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new CounterVariableCondition(counter, int(value), int(defaultValue), satisfied));
}
public static function setCounter(a_counter:String, a_value:int):void{
if (counters == null){
counters = new Dictionary();
};
counters[a_counter] = a_value;
}
public static function getCounter(a_counter:String, a_defaultValue:int=0):int{
if (counters == null){
counters = new Dictionary();
};
if (counters[a_counter] == null){
counters[a_counter] = a_defaultValue;
};
return (counters[a_counter]);
}
}
}//package com.gamedozer.battalion.game.conditions
Section 84
//EndGameCondition (com.gamedozer.battalion.game.conditions.EndGameCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class EndGameCondition implements Condition {
protected var player:int;
public var satisfied:Boolean;
protected var victory:Boolean;
public function EndGameCondition(a_player:int=-1, a_victory:Boolean=true, a_satisfied:Boolean=false){
super();
player = a_player;
victory = a_victory;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(PlayerTrigger.END_GAME, endGameListener);
TriggerManager.getInstance().addListener(PlayerTrigger.SURRENDER, surrenderListener);
}
private function endGameListener(a_trigger:PlayerTrigger):void{
if (victory == true){
if ((((player == -1)) || ((player == a_trigger.getPlayer())))){
satisfied = true;
};
};
}
private function surrenderListener(a_trigger:PlayerTrigger):void{
if (victory == false){
if ((((player == -1)) || ((player == a_trigger.getPlayer())))){
satisfied = true;
};
};
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
public function reset():void{
satisfied = false;
}
public function toXML():XML{
return (new XML((((((("<condition type=\"endGame\"><player value=\"" + (player + 1)) + "\"/> <victory value=\"") + ((victory == true)) ? "true" : "false") + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function dispose():void{
TriggerManager.getInstance().removeListener(PlayerTrigger.END_GAME, endGameListener);
TriggerManager.getInstance().removeListener(PlayerTrigger.SURRENDER, surrenderListener);
}
public static function getFromXML(a_xml:XML):Condition{
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var victory:Boolean;
var booleanString:String = a_xml.victory.@value;
if (booleanString.toLowerCase().charAt(0) == "f"){
victory = false;
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new EndGameCondition((int(player) - 1), victory, satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 85
//KillUnitCondition (com.gamedozer.battalion.game.conditions.KillUnitCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.game.responses.*;
public class KillUnitCondition implements Condition {
protected var y:int;
protected var player:int;
protected var name:String;
protected var x:int;
public var satisfied:Boolean;
public function KillUnitCondition(a_name:String="", a_player:int=-1, a_x:int=-1, a_y:int=-1, a_satisfied:Boolean=false){
super();
name = a_name;
x = a_x;
y = a_y;
player = a_player;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(KillUnitTrigger.TRIGGER, killUnitListener);
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
public function toXML():XML{
return (new XML((((((((((("<condition type=\"killUnit\"> <unitName value=\"" + name) + "\"/> <player value=\"") + (player + 1)) + "\"/> <x value=\"") + x) + "\"/> <y value=\"") + y) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
private function killUnitListener(a_trigger:KillUnitTrigger):void{
var unit:Unit = a_trigger.getUnit();
var unitData:UnitData = unit.getUnitData();
var named:Boolean;
if (unitData != null){
if (unitData.getName().toLowerCase() == name.toLowerCase()){
named = true;
};
} else {
if (unit == NameUnitResponse.getNamedUnit(name)){
named = true;
};
};
if ((((name == "")) || (named))){
if ((((x == -1)) || ((x == a_trigger.getUnitX())))){
if ((((y == -1)) || ((y == a_trigger.getUnitY())))){
if ((((player == -1)) || ((GameManager.getInstance().getPlayer(unit.getController()) == player)))){
satisfied = true;
};
};
};
};
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(KillUnitTrigger.TRIGGER, killUnitListener);
}
public static function getFromXML(a_xml:XML):Condition{
var name:String = a_xml.unitName.@value;
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var x:String = a_xml.x.@value;
if (x == ""){
x = "-1";
};
var y:String = a_xml.y.@value;
if (y == ""){
y = "-1";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new KillUnitCondition(name, (int(player) - 1), int(x), int(y), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 86
//MoveUnitCondition (com.gamedozer.battalion.game.conditions.MoveUnitCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.game.responses.*;
public class MoveUnitCondition implements Condition {
protected var y:int;
protected var player:int;
protected var name:String;
protected var x:int;
public var satisfied:Boolean;
public function MoveUnitCondition(a_x:int=-1, a_y:int=-1, a_name:String="", a_player:int=-1, a_satisfied:Boolean=false){
super();
name = a_name;
x = a_x;
y = a_y;
player = a_player;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(MoveUnitTrigger.TRIGGER, moveUnitListener);
}
public function isSatisfied():Boolean{
return (satisfied);
}
private function moveUnitListener(a_trigger:MoveUnitTrigger):void{
var unit:Unit = a_trigger.getUnit();
var unitData:UnitData = unit.getUnitData();
var named:Boolean;
if (unitData != null){
if (unitData.getName().toLowerCase() == name.toLowerCase()){
named = true;
};
} else {
if (unit == NameUnitResponse.getNamedUnit(name)){
named = true;
};
};
if ((((name == "")) || (named))){
if ((((x == -1)) || ((x == unit.getX())))){
if ((((y == -1)) || ((y == unit.getY())))){
if ((((player == -1)) || ((GameManager.getInstance().getPlayer(unit.getController()) == player)))){
satisfied = true;
};
};
};
};
}
public function toXML():XML{
return (new XML((((((((((("<condition type=\"moveUnit\"> <x value=\"" + x) + "\"/> <y value=\"") + y) + "\"/> <unitName value=\"") + name) + "\"/> <player value=\"") + (player + 1)) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function update():void{
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(MoveUnitTrigger.TRIGGER, moveUnitListener);
}
public static function getFromXML(a_xml:XML):Condition{
var name:String = a_xml.unitName.@value;
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var x:String = a_xml.x.@value;
if (x == ""){
x = "-1";
};
var y:String = a_xml.y.@value;
if (y == ""){
y = "-1";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new MoveUnitCondition(int(x), int(y), name, (int(player) - 1), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 87
//NoUnitsCondition (com.gamedozer.battalion.game.conditions.NoUnitsCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class NoUnitsCondition implements Condition {
protected var player:int;
protected var satisfied:Boolean;
public function NoUnitsCondition(a_player:int, a_satisfied:Boolean=false){
super();
player = a_player;
TriggerManager.getInstance().addListener(PlayerTrigger.NO_UNITS, noUnitsListener);
}
public function toXML():XML{
return (new XML((((("<condition type=\"noUnits\"> <satisfied value=\"" + ((satisfied == true)) ? "true" : "false") + "\"/> <player value=\"") + (player + 1)) + "\"/> </condition>")));
}
public function update():void{
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function noUnitsListener(a_trigger:PlayerTrigger):void{
if (a_trigger.getPlayer() == player){
satisfied = true;
};
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(PlayerTrigger.NO_UNITS, noUnitsListener);
}
public static function getFromXML(a_xml:XML):Condition{
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
return (new NoUnitsCondition((parseInt(player) - 1), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 88
//ResourcesAcquiredCondition (com.gamedozer.battalion.game.conditions.ResourcesAcquiredCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class ResourcesAcquiredCondition implements Condition {
protected var player:int;
protected var resources:int;
protected var count:int;
public var satisfied:Boolean;
public function ResourcesAcquiredCondition(a_resources:int=-1, a_player:int=-1, a_count:int=0, a_satisfied:Boolean=false){
super();
player = a_player;
resources = a_resources;
count = a_count;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(ResourcesAcquiredTrigger.TRIGGER, resourcesAcquiredListener);
}
public function toXML():XML{
return (new XML((((((((("<condition type=\"resourcesAcquired\"> <resources value=\"" + resources) + "\"/> <player value=\"") + (player + 1)) + "\"/> <count value=\"") + count) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
private function resourcesAcquiredListener(a_trigger:ResourcesAcquiredTrigger):void{
if ((((player == -1)) || ((player == a_trigger.getPlayer())))){
count = (count + a_trigger.getResources());
if (count >= resources){
satisfied = true;
};
};
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
public function reset():void{
satisfied = false;
count = 0;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(ResourcesAcquiredTrigger.TRIGGER, resourcesAcquiredListener);
}
public static function getFromXML(a_xml:XML):Condition{
var resources:String = a_xml.resources.@value;
if (resources == ""){
resources = "-1";
};
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var count:String = a_xml.count.@value;
if (count == ""){
count = "0";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new ResourcesAcquiredCondition(int(resources), (int(player) - 1), int(count), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 89
//StartGameCondition (com.gamedozer.battalion.game.conditions.StartGameCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class StartGameCondition implements Condition {
public var satisfied:Boolean;
public function StartGameCondition(a_satisfied:Boolean=false){
super();
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(Trigger.START_GAME, startGameListener);
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function reset():void{
satisfied = false;
}
public function update():void{
}
public function startGameListener(a_trigger:Trigger):void{
satisfied = true;
}
public function toXML():XML{
return (new XML((("<condition type=\"startGame\"> <satisfied value=\"" + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function dispose():void{
TriggerManager.getInstance().removeListener(Trigger.START_GAME, startGameListener);
}
public static function getFromXML(a_xml:XML):Condition{
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new StartGameCondition(satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 90
//StartTurnCondition (com.gamedozer.battalion.game.conditions.StartTurnCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class StartTurnCondition implements Condition {
protected var player:int;
protected var round:int;
public var satisfied:Boolean;
public function StartTurnCondition(a_player:int=-1, a_round:int=-1, a_satisfied:Boolean=false){
super();
player = a_player;
round = a_round;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(PlayerTrigger.START_TURN, startTurnListener);
}
public function toXML():XML{
return (new XML((((((("<condition type=\"startTurn\"> <player value=\"" + (player + 1)) + "\"/> <round value=\"") + round) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
private function startTurnListener(a_trigger:PlayerTrigger):void{
if ((((player == -1)) || ((player == a_trigger.getPlayer())))){
if ((((round == -1)) || ((round == GameManager.getInstance().getRound())))){
satisfied = true;
};
};
}
public function reset():void{
satisfied = false;
}
public function dispose():void{
TriggerManager.getInstance().removeListener(PlayerTrigger.START_TURN, startTurnListener);
}
public static function getFromXML(a_xml:XML):Condition{
var player:String = a_xml.player.@value;
if (player == ""){
player = "0";
};
var round:String = a_xml.round.@value;
if (round == ""){
round = "-1";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new StartTurnCondition((int(player) - 1), int(round), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 91
//TimePassedCondition (com.gamedozer.battalion.game.conditions.TimePassedCondition)
package com.gamedozer.battalion.game.conditions {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.triggers.*;
public class TimePassedCondition implements Condition {
protected var timer:uint;
protected var time:uint;
public var satisfied:Boolean;
public function TimePassedCondition(a_time:uint=0, a_timer:uint=0, a_satisfied:Boolean=false){
super();
time = a_time;
timer = a_timer;
satisfied = a_satisfied;
TriggerManager.getInstance().addListener(TimePassedTrigger.TRIGGER, timePassedListener);
}
public function isSatisfied():Boolean{
return (satisfied);
}
public function update():void{
}
private function timePassedListener(a_trigger:TimePassedTrigger):void{
timer = (timer + a_trigger.getTime());
if (timer >= time){
satisfied = true;
};
}
public function reset():void{
satisfied = false;
timer = 0;
}
public function toXML():XML{
return (new XML((((((("<condition type=\"timePassed\"> <time value=\"" + time) + "\"/> <timer value=\"") + timer) + "\"/> <satisfied value=\"") + ((satisfied == true)) ? "true" : "false") + "\"/> </condition>")));
}
public function dispose():void{
TriggerManager.getInstance().removeListener(TimePassedTrigger.TRIGGER, timePassedListener);
}
public static function getFromXML(a_xml:XML):Condition{
var time:String = a_xml.time.@value;
if (time == ""){
time = "0";
};
var timer:String = a_xml.timer.@value;
if (timer == ""){
timer = "0";
};
var satisfied:Boolean;
var satistfiedString:String = a_xml.satistfied.@value;
if (satistfiedString.toLowerCase().charAt(0) == "t"){
satisfied = true;
};
return (new TimePassedCondition(int(time), int(timer), satisfied));
}
}
}//package com.gamedozer.battalion.game.conditions
Section 92
//AIController (com.gamedozer.battalion.game.controllers.AIController)
package com.gamedozer.battalion.game.controllers {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.ai.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class AIController extends Controller {
private var m_engine:AIEngine;
private var control:Boolean;// = false
private var m_aiThinkingIndicator:Bitmap;// = null
private var m_sponsorLogoButton:GameSprite;
public function AIController(a_team:Team){
super(a_team);
control = false;
m_engine = new AIEngine(this);
TriggerManager.getInstance().addListener(Trigger.CONTROL, controlListener);
}
override protected function killUnit(a_unitX:int, a_unitY:int, a_unit:Unit):void{
m_engine.handleKilledUnit(a_unit, a_unitX, a_unitY);
}
private function rolloverSponsor(a_event:MouseEvent):void{
var logo:DisplayObject = (a_event.target as DisplayObject);
logo.alpha = 1;
}
override public function isStillInitializing():Boolean{
return (m_engine.isStillInitializing());
}
override protected function startRound():void{
}
override protected function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
m_engine.captureTerrain(a_tile, a_oldPlayer, a_player, a_complete);
}
override public function initialize():void{
m_engine.parseTileMap();
m_engine.parseUnitList();
m_engine.initialize();
m_engine.startLoading();
}
override protected function buildUnit(a_unit:Unit):void{
m_engine.handleBuiltUnit(a_unit);
}
override protected function startCurrentTurn():void{
var sponsorLogo:GameSprite;
control = true;
m_aiThinkingIndicator = new Bitmap(BitmapLibrary.loadBitmap("ai_thinking"));
m_aiThinkingIndicator.x = 15;
m_aiThinkingIndicator.y = 15;
GameManager.getInstance().getParent().addChild(m_aiThinkingIndicator);
m_aiThinkingIndicator.alpha = 0;
tweenDown();
if (((Sponsor.getInstance().isKongregate()) && (!(Sponsor.getInstance().isPlayingOnSponsorSite())))){
sponsorLogo = new GameSprite();
sponsorLogo.addChild(new Bitmap(BitmapLibrary.loadBitmap("ingame_kong_logo")));
m_sponsorLogoButton = new GameButton(sponsorLogo, "select");
m_sponsorLogoButton.x = 430;
m_sponsorLogoButton.y = 380;
m_sponsorLogoButton.addEventListener(MouseEvent.CLICK, BattalionMain.visitSponsor);
m_sponsorLogoButton.addEventListener(MouseEvent.ROLL_OVER, rolloverSponsor);
m_sponsorLogoButton.addEventListener(MouseEvent.ROLL_OUT, rolloutSponsor);
m_sponsorLogoButton.alpha = 0.5;
GameManager.getInstance().getParent().addChild(m_sponsorLogoButton);
};
m_engine.startTurn();
SoundSystem.instance.destroyLoop("background");
SoundSystem.instance.createLoop("background", SoundSystem.instance.createSound("AILoopWAV"));
}
function receiveControl():void{
if (isStillInitializing()){
return;
};
m_engine.think();
}
override protected function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
m_engine.changeUpgradeStatus(a_unit, a_name, a_upgraded);
}
override public function dispose():void{
super.dispose();
m_engine = null;
}
private function tweenUp():void{
if (m_aiThinkingIndicator == null){
return;
};
TweenManager.getInstance().add(new Tween(m_aiThinkingIndicator, Linear.easeIn, ["alpha"], [1], [0.2], 750), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(tweenDown, m_aiThinkingIndicator), TweenManager.SEQUENTIAL);
}
private function rolloutSponsor(a_event:MouseEvent):void{
var logo:DisplayObject = (a_event.target as DisplayObject);
logo.alpha = 0.5;
}
override protected function endGame():void{
removeGraphics();
}
private function removeGraphics():void{
if (m_aiThinkingIndicator == null){
return;
};
TweenManager.getInstance().removeTweens(m_aiThinkingIndicator);
m_aiThinkingIndicator.parent.removeChild(m_aiThinkingIndicator);
m_aiThinkingIndicator = null;
if (m_sponsorLogoButton != null){
m_sponsorLogoButton.parent.removeChild(m_sponsorLogoButton);
m_sponsorLogoButton = null;
};
}
protected function controlListener(a_trigger:Trigger):void{
if (((control) && (enabled))){
receiveControl();
};
}
override protected function startGame():void{
}
override protected function moveUnit(a_unit:Unit, a_path:Array):void{
m_engine.handleMovedUnit(a_unit, a_path);
}
private function tweenDown():void{
if (m_aiThinkingIndicator == null){
return;
};
TweenManager.getInstance().add(new Tween(m_aiThinkingIndicator, Linear.easeIn, ["alpha"], [0.2], [1], 750), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(tweenUp, m_aiThinkingIndicator), TweenManager.SEQUENTIAL);
}
override protected function startTurn(a_player:int):void{
control = false;
if (m_aiThinkingIndicator != null){
removeGraphics();
};
}
}
}//package com.gamedozer.battalion.game.controllers
Section 93
//HumanController (com.gamedozer.battalion.game.controllers.HumanController)
package com.gamedozer.battalion.game.controllers {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.assets.*;
import com.gamedozer.battalion.game.actions.*;
import flash.ui.*;
public class HumanController extends Controller {
var buttons:Array;
var currentPathSprites:Array;
var currentPath:Array;
var uiButtons:Array;
var lastSelected:Unit;
var control:Boolean;
var camerax:int;
var cameray:int;
var buildMenu:BuildMenu;
public function HumanController(a_team:Team){
super(a_team);
buttons = new Array();
control = false;
uiButtons = new Array();
currentPath = new Array();
currentPathSprites = new Array();
TriggerManager.getInstance().addListener(Trigger.CONTROL, controlListener);
control = false;
camerax = (cameray = -1);
}
protected function clearButtons():void{
var scroller:GameSpriteScroller = GameManager.getInstance().getGameSpriteScroller();
var i:int;
while (i < buttons.length) {
scroller.remove(buttons[i]);
i++;
};
buttons = new Array();
}
protected function direction(x1:int, y1:int, x2:int, y2:int):int{
if (y1 == y2){
if (x1 < x2){
return (0);
};
return (180);
};
if (y1 < y2){
return (90);
};
return (270);
}
protected function chooseMove(a_position:MovePosition):void{
var currentEndTile:Tile;
var unito:Boolean;
var nodes:Array;
var i:int;
var path:Array;
var unit:Unit = a_position.unit;
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(unit.getX(), unit.getY());
var endTile:Tile = gameManager.tileAt(a_position.x, a_position.y);
if (a_position.attack){
if (unit.isRanged()){
chooseMove(new MovePosition(unit.getX(), unit.getY(), unit));
return;
};
currentEndTile = gameManager.tileAt(currentPath[(currentPath.length - 2)], currentPath[(currentPath.length - 1)]);
unito = false;
if (currentEndTile.getUnit() != null){
if (!currentEndTile.getUnit().isCloaked()){
unito = true;
};
};
if (((!(currentEndTile.isConnected(endTile))) || (unito))){
nodes = Astar.search(tile, null, unit);
i = 0;
while (i < nodes.length) {
if (((nodes[i].isConnected(endTile)) && ((((nodes[i].getUnit() == null)) || ((nodes[i].getUnit() == unit)))))){
chooseMove(new MovePosition(nodes[i].getX(), nodes[i].getY(), unit));
return;
};
i++;
};
};
return;
};
var newPath:Boolean;
if (currentPath.length == 0){
newPath = true;
} else {
currentEndTile = gameManager.tileAt(currentPath[(currentPath.length - 2)], currentPath[(currentPath.length - 1)]);
if (currentEndTile == endTile){
return;
};
if (!currentEndTile.isConnected(endTile)){
newPath = true;
};
i = 0;
while (i < currentPath.length) {
if ((((currentPath[i] == a_position.x)) && ((currentPath[(i + 1)] == a_position.y)))){
currentPath.splice(i, (currentPath.length - i));
break;
};
i = (i + 2);
};
currentPath.push(a_position.x);
currentPath.push(a_position.y);
if (gameManager.moveCost(unit, gameManager.nodePath(currentPath)) > unit.getRange()){
newPath = true;
};
};
if (newPath){
clearPath();
path = Astar.pathTrim(tile, endTile, unit);
currentPath = gameManager.pointPath(path);
} else {
clearPath(true);
};
drawPath(unit);
}
protected function drawPath(a_unit:Unit):void{
var x:int;
var y:int;
var name:String;
var angle:int;
var vehicle:Boolean;
var b:BitmapSprite;
var d:GameSprite;
var node:Tile;
var unit:Boolean;
var cloaked:Boolean;
var t:TileSheet;
var dir:int;
var i:int;
while (i < currentPath.length) {
x = currentPath[i];
y = currentPath[(i + 1)];
name = "";
angle = 0;
vehicle = false;
if (i == 0){
if (currentPath.length < 3){
name = "nomove";
} else {
name = "start";
angle = direction(x, y, currentPath[(i + 2)], currentPath[(i + 3)]);
dir = angle;
};
} else {
if (i == (currentPath.length - 2)){
node = GameManager.getInstance().tileAt(currentPath[i], currentPath[(i + 1)]);
unit = false;
cloaked = false;
if (node.getUnit() != null){
unit = true;
if (node.getUnit().isCloaked()){
unit = false;
cloaked = true;
if (node.getUnit().getController() != a_unit.getController()){
cloaked = false;
};
};
};
if (((unit) || (cloaked))){
name = "unmoveable";
} else {
name = "end";
vehicle = true;
};
angle = dir;
} else {
if (dir == direction(x, y, currentPath[(i + 2)], currentPath[(i + 3)])){
name = "straight";
angle = dir;
} else {
name = "turn";
angle = dir;
dir = direction(x, y, currentPath[(i + 2)], currentPath[(i + 3)]);
if (dir != ((angle + 90) % 360)){
angle = (angle + 90);
};
};
};
};
b = new BitmapSprite(BitmapLibrary.loadBitmap(("movement_" + name)));
b.x = (-(TileManager.getInstance().getWidth()) / 2);
b.y = (-(TileManager.getInstance().getHeight()) / 2);
d = new GameSprite();
d.addChild(b);
d.x = ((x * TileManager.getInstance().getWidth()) + (TileManager.getInstance().getWidth() / 2));
d.y = ((y * TileManager.getInstance().getHeight()) + (TileManager.getInstance().getHeight() / 2));
d.rotation = angle;
GameManager.getInstance().getGameSpriteScroller().add(d, GameSpriteScroller.ABOVE_UNITS);
if (vehicle){
t = TileSheetManager.getInstance().getColorised(a_unit.getUnitData().getSprite(), a_unit.getController().getTeam().getColor());
t.alpha = 0.5;
if (angle == 0){
t.playAnimation("right_idle");
} else {
if (angle == 90){
t.playAnimation("down_idle");
} else {
if (angle == 180){
t.playAnimation("left_idle");
} else {
t.playAnimation("up_idle");
};
};
};
t.x = (x * TileManager.getInstance().getWidth());
t.y = (y * TileManager.getInstance().getHeight());
if (t.height > TileManager.getInstance().getHeight()){
t.y = (t.y - (t.height - TileManager.getInstance().getHeight()));
};
GameManager.getInstance().getGameSpriteScroller().add(t, GameSpriteScroller.ABOVE_UNITS);
currentPathSprites.push(t);
};
currentPathSprites.push(d);
i = (i + 2);
};
}
function unitMenu(a_unit:Unit):void{
var tile:Tile;
var leviathanCost:int;
var sea:TileSheet;
var albatrossCost:int;
var air:TileSheet;
var bUD:UnitData;
var drop:TileSheet;
var repairCost:int;
var repair:TileSheet;
var toolTipMessage:String;
var cancel:TileSheet;
var width:int;
var a_unit = a_unit;
var cancelOnly:Boolean;
createClearButton(a_unit);
selectUnits(new Array(a_unit));
var b:GameButton = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("marker")));
b.release = function ():void{
receiveControl();
};
b.x = a_unit.getGameUnit().x;
b.y = a_unit.getGameUnit().y;
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
var unitMenu:GameSprite = new GameSprite();
GameManager.getInstance().getGameSpriteScroller().add(unitMenu, GameSpriteScroller.BUTTONS);
buttons.push(unitMenu);
var startX:int;
var startY:int;
var flip:Boolean;
var map:Map = GameManager.getInstance().getMap();
if (!a_unit.isUpgraded()){
if (a_unit.getUnitData().isGround()){
if (a_unit.getUnitData().getMovementType() == UnitData.movementTypeFromString("feet")){
albatrossCost = UnitManager.getInstance().get("Albatross Transport").getCost(this);
air = TileSheetManager.getInstance().get("unitMenu");
air.playAnimation("air");
b = new GameButton(air, "option", true);
unitMenu.addChild(b);
if (((controlsAir()) && ((getResources() >= albatrossCost)))){
ToolTip.createToolTip(b, "Order Albatross", ("Order Albatross pickup for $" + albatrossCost));
b.value = a_unit;
b.release = function ():void{
upgradeUnits(this.value, true, "Albatross Transport");
};
} else {
if (((controlsAir()) && ((getResources() < albatrossCost)))){
ToolTip.createToolTip(b, "Albatross Unavailable", (("You need $" + albatrossCost) + " to order an Albatross pickup."));
b.value = a_unit;
b.turnOffGlow();
b.alpha = 0.7;
b.release = function ():void{
clear();
};
} else {
if (map.hasAirControl){
ToolTip.createToolTip(b, "Albatross Unavailable", "Capture an Air Control to enable Albatross pick up.");
b.value = a_unit;
b.turnOffGlow();
b.alpha = 0.7;
b.release = function ():void{
clear();
};
} else {
ToolTip.createToolTip(b, "Albatross Unavailable", "This map does not allow for an Albatross pickup.");
b.value = a_unit;
b.turnOffGlow();
b.alpha = 0.7;
b.release = function ():void{
clear();
};
};
};
};
b.x = startX;
b.y = startY;
startX = (startX + 54);
cancelOnly = false;
flip = false;
};
tile = GameManager.getInstance().tileAt(a_unit.getX(), a_unit.getY());
leviathanCost = UnitManager.getInstance().get("Leviathan Barge").getCost(this);
sea = TileSheetManager.getInstance().get("unitMenu");
sea.playAnimation("sea");
b = new GameButton(sea, "option", true);
unitMenu.addChild(b);
b.value = a_unit;
if (!map.hasSeaControl){
ToolTip.createToolTip(b, "Leviathan Unavailable", "This map does not allow for a Leviathan pickup.");
b.alpha = 0.7;
b.turnOffGlow();
b.release = function ():void{
clear();
};
} else {
if (((((controlsSea()) && (tile.seaBordered()))) && (tile.getTerrain().hasModifier("Shore")))){
if (getResources() >= leviathanCost){
ToolTip.createToolTip(b, "Order Leviathan", ("Order Leviathan pickup for $" + leviathanCost));
b.release = function ():void{
upgradeUnits(this.value, true, "Leviathan Barge");
};
} else {
ToolTip.createToolTip(b, "Leviathan Unavailable", (("You need $" + leviathanCost) + " to order a Leviathan pickup."));
b.alpha = 0.7;
b.turnOffGlow();
b.release = function ():void{
clear();
};
};
} else {
if (((!(controlsSea())) && (map.hasSeaControl))){
ToolTip.createToolTip(b, "Leviathan Unavailable", "Capture a Sea Control to enable Leviathan pick up.");
b.alpha = 0.7;
b.turnOffGlow();
b.release = function ():void{
clear();
};
} else {
if (!tile.getTerrain().hasModifier("Shore")){
ToolTip.createToolTip(b, "Leviathan Unavailable", "You must be standing on a Shore square to call a Leviathan pickup.");
b.alpha = 0.7;
b.turnOffGlow();
b.release = function ():void{
clear();
};
} else {
if (!tile.seaBordered()){
ToolTip.createToolTip(b, "Leviathan Unavailable", "You must be standing next to a Sea square to call a Leviathan pickup.");
b.alpha = 0.7;
b.turnOffGlow();
b.release = function ():void{
clear();
};
};
};
};
};
};
b.x = startX;
b.y = startY;
startX = (startX + 54);
cancelOnly = false;
flip = false;
};
} else {
tile = GameManager.getInstance().tileAt(a_unit.getX(), a_unit.getY());
bUD = a_unit.getBaseUnitData();
drop = TileSheetManager.getInstance().get("unitMenu");
drop.playAnimation("drop");
b = new GameButton(drop, "option", true);
unitMenu.addChild(b);
b.value = a_unit;
if (tile.getCost(new Unit(new GameUnit(new GameSprite()), bUD, 0, 0, a_unit.getController())) != Number.POSITIVE_INFINITY){
ToolTip.createToolTip(b, ("Unpack " + bUD.getName()), (("Unpack and deploy the " + bUD.getName()) + "."));
b.release = function ():void{
upgradeUnits(this.value, false);
};
} else {
ToolTip.createToolTip(b, "Unpack Unavailable", (("The " + bUD.getName()) + " cannot be unpacked on this square."));
b.turnOffGlow();
b.alpha = 0.7;
b.release = function ():void{
clear();
};
};
b.x = startX;
b.y = startY;
startX = (startX + 54);
cancelOnly = false;
flip = false;
};
if (!a_unit.isUpgraded()){
repairCost = Math.round((a_unit.getUnitData().getCost(this) * GameManager.getInstance().healPercentage(a_unit)));
repair = TileSheetManager.getInstance().get("unitMenu");
if (flip){
repair.playAnimation("repairFlip");
} else {
repair.playAnimation("repair");
};
b = new GameButton(repair, "option", true);
unitMenu.addChild(b);
if ((((getResources() >= repairCost)) && ((a_unit.getHealth() < a_unit.getUnitData().getHealth())))){
ToolTip.createToolTip(b, "Repair", ("Start repair for $" + repairCost));
b.value = a_unit;
b.release = function ():void{
repairUnits(this.value);
};
} else {
toolTipMessage = (("You need $" + repairCost) + " to repair this unit.");
if (a_unit.getHealth() >= a_unit.getUnitData().getHealth()){
toolTipMessage = "Unit is at full health.";
};
ToolTip.createToolTip(b, "Repair Unavailable", toolTipMessage);
b.turnOffGlow();
b.alpha = 0.7;
b.release = function ():void{
clear();
};
};
b.x = startX;
b.y = startY;
startX = (startX + 54);
cancelOnly = false;
};
if (cancelOnly){
receiveControl();
} else {
cancel = TileSheetManager.getInstance().get("unitMenu");
cancel.playAnimation("cancel");
b = new GameButton(cancel, "option", true);
unitMenu.addChild(b);
ToolTip.createToolTip(b, "Cancel", "Cancel unit selection");
b.release = function ():void{
receiveControl();
};
b.x = startX;
b.y = startY;
startX = (startX + 54);
unitMenu.y = ((a_unit.getY() * TileManager.getInstance().getHeight()) - 30);
if (unitMenu.y < 0){
unitMenu.y = 0;
};
unitMenu.x = (((a_unit.getX() + 0.5) * TileManager.getInstance().getWidth()) - (startX / 2));
if (unitMenu.x < 0){
unitMenu.x = 0;
};
width = (GameManager.getInstance().getMap().getWidth() * TileManager.getInstance().getWidth());
if ((unitMenu.x + startX) > width){
unitMenu.x = (width - startX);
};
};
}
override public function setEnabled(a_enabled:Boolean):void{
super.setEnabled(a_enabled);
if (enabled){
GameManager.getInstance().getCamera().setEnabled(true);
} else {
GameManager.getInstance().getCamera().setEnabled(false);
clearUIButtons();
clearButtons();
clearPath();
};
}
protected function selectEnemyUnit(a_unit:Unit):void{
var nodes:Array;
var b:GameButton;
var ranges:Array;
var i:int;
var index:int;
var r:Number;
var a_unit = a_unit;
clearButtons();
clearUIButtons();
clearPath();
var gameManager:GameManager = GameManager.getInstance();
gameManager.getCamera().setTarget(a_unit.getGameUnit(), 500);
var tile:Tile = gameManager.tileAt(a_unit.getX(), a_unit.getY());
if (a_unit.isRanged()){
nodes = Astar.search(tile, null, a_unit);
if (nodes == null){
nodes = new Array(tile);
};
ranges = Astar.range(tile, a_unit.getUnitData().getWeaponRangeMin(), tile.getTerrain().applyModifiers("attackRange", a_unit, a_unit.getUnitData().getWeaponRangeMax()));
i = (nodes.length - 1);
while (i >= 0) {
index = ranges.indexOf(nodes[i]);
if (index != -1){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectMixed")));
ranges.splice(index, 1);
} else {
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("select")));
};
b.x = nodes[i].getGameTile().x;
b.y = nodes[i].getGameTile().y;
if (nodes[i].getUnit() == a_unit){
b.release = function ():void{
receiveControl();
};
};
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
i = (i - 1);
};
i = (ranges.length - 1);
while (i >= 0) {
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectOrange")));
b.x = ranges[i].getGameTile().x;
b.y = ranges[i].getGameTile().y;
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
i = (i - 1);
};
} else {
nodes = Astar.search(tile, null, a_unit, 0, true);
if (nodes == null){
nodes = new Array(tile);
};
r = a_unit.getRange();
i = (nodes.length - 1);
while (i >= 0) {
if (nodes[i].g > r){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectOrange")));
} else {
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("select")));
};
b.x = nodes[i].getGameTile().x;
b.y = nodes[i].getGameTile().y;
if (nodes[i].getUnit() == a_unit){
b.release = function ():void{
receiveControl();
};
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
} else {
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.TOP);
};
buttons.push(b);
i = (i - 1);
};
};
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("marker2")));
b.x = a_unit.getGameUnit().x;
b.y = a_unit.getGameUnit().y;
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
createClearButton();
var ignoreMe:Array = new Array();
ignoreMe.push(a_unit);
selectUnits(null, ignoreMe);
selectBuildings();
}
protected function clearPath(a_spritesOnly:Boolean=false):void{
var scroller:GameSpriteScroller = GameManager.getInstance().getGameSpriteScroller();
var i:int;
while (i < currentPathSprites.length) {
scroller.remove(currentPathSprites[i]);
i++;
};
currentPathSprites = new Array();
if (!a_spritesOnly){
currentPath = new Array();
};
}
override public function dispose():void{
super.dispose();
clearPath();
clearButtons();
clearUIButtons();
uiButtons = null;
buttons = null;
currentPath = null;
currentPathSprites = null;
}
protected function selectUnit(a_unit:Unit):void{
var nodes:Array;
var i:int;
var node:Tile;
var j:int;
var cNode:Tile;
var unit:Unit;
var r:Number;
var nodey:Tile;
var connections:Array;
var linked:Boolean;
var target:Unit;
var resources:Number;
var wrapper:NodeWrapper;
var b:GameButton;
var t:TileSheet;
var targetGraphic:TileSheet;
var at:Boolean;
var a_unit = a_unit;
clearButtons();
clearUIButtons();
clearPath();
lastSelected = a_unit;
var gameManager:GameManager = GameManager.getInstance();
gameManager.getGameSpriteScroller().swapDepth(a_unit.getGameUnit(), GameSpriteScroller.TOP);
var tile:Tile = gameManager.tileAt(a_unit.getX(), a_unit.getY());
var ranges:Array = new Array();
var rangeNodes:Array = new Array();
var attacks:Array = new Array();
var allNodes:Array = new Array();
var ignoreUnits:Array = new Array(a_unit);
var ignoreBuildings:Array = new Array();
if (a_unit.isRanged()){
nodes = Astar.search(tile, null, a_unit);
if (nodes == null){
nodes = new Array(tile);
};
ranges = Astar.range(tile, a_unit.getUnitData().getWeaponRangeMin(), tile.getTerrain().applyModifiers("attackRange", a_unit, a_unit.getUnitData().getWeaponRangeMax()));
i = (ranges.length - 1);
while (i >= 0) {
j = nodes.indexOf(ranges[i]);
if (j != -1){
nodes.splice(j, 1);
cNode = ranges.splice(i, 1)[0];
unit = cNode.getUnit();
rangeNodes.push(cNode);
if (unit != null){
if (((!(unit.getController().isAllied(a_unit.getController()))) && (!(unit.isCloaked())))){
attacks.push(rangeNodes.pop());
};
};
} else {
unit = ranges[i].getUnit();
if (unit != null){
if (((((!(unit.getController().isAllied(a_unit.getController()))) && (!(unit.isCloaked())))) && (gameManager.canWeaponsFireAtTarget(a_unit, unit, true)))){
attacks.push(ranges.splice(i, 1)[0]);
};
};
};
i = (i - 1);
};
} else {
nodes = Astar.search(tile, null, a_unit, 0, true);
if (nodes == null){
nodes = new Array(tile);
};
r = a_unit.getRange();
i = (nodes.length - 1);
while (i >= 0) {
if (nodes[i].g > r){
unit = nodes[i].getUnit();
ranges.push(nodes.splice(i, 1)[0]);
if (unit != null){
if (((((!(unit.getController().isAllied(a_unit.getController()))) && (!(unit.isCloaked())))) && (gameManager.canWeaponsFireAtTarget(a_unit, unit, true)))){
attacks.push(ranges.pop());
};
};
};
i = (i - 1);
};
};
var touched:Dictionary = new Dictionary();
var choices:Boolean;
i = 0;
while (i < nodes.length) {
nodey = nodes[i];
allNodes.push(new NodeWrapper(nodey, NodeWrapper.MOVE));
if ((((((nodey.getUnit() == null)) || (nodey.getUnit().isCloaked()))) || ((nodey.getUnit() == a_unit)))){
touched[((nodey.getX() + "_") + nodey.getY())] = true;
choices = true;
};
i = (i + 1);
};
if (a_unit.getUnitData().getWeaponType() != UnitData.weaponTypeFromString("none")){
i = 0;
while (i < rangeNodes.length) {
nodey = rangeNodes[i];
allNodes.push(new NodeWrapper(nodey, NodeWrapper.RANGE_MOVE));
if ((((((nodey.getUnit() == null)) || (nodey.getUnit().isCloaked()))) || ((nodey.getUnit() == a_unit)))){
touched[((nodey.getX() + "_") + nodey.getY())] = true;
choices = true;
};
i = (i + 1);
};
i = 0;
while (i < ranges.length) {
allNodes.push(new NodeWrapper(ranges[i], NodeWrapper.RANGE));
i = (i + 1);
};
i = 0;
while (i < attacks.length) {
connections = attacks[i].getConnections();
linked = false;
if (a_unit.isRanged()){
linked = true;
} else {
j = 0;
while (j < connections.length) {
nodey = connections[j];
if (touched[((nodey.getX() + "_") + nodey.getY())] == true){
linked = true;
break;
};
j = (j + 1);
};
};
if (linked){
target = attacks[i].getUnit();
resources = gameManager.resolveAttackCycleInResources(a_unit, target);
wrapper = new NodeWrapper(attacks[i], NodeWrapper.ATTACK, 2);
wrapper.resourceDamage = resources;
allNodes.push(wrapper);
} else {
wrapper = new NodeWrapper(attacks[i], NodeWrapper.RANGE);
allNodes.push(wrapper);
};
i = (i + 1);
};
} else {
i = 0;
while (i < rangeNodes.length) {
allNodes.push(new NodeWrapper(rangeNodes[i], NodeWrapper.MOVE));
if (rangeNodes[i].getUnit() == null){
choices = true;
};
i = (i + 1);
};
};
var attackTargets:Array = [];
i = 0;
while (i < allNodes.length) {
wrapper = allNodes[i];
if (wrapper.type == NodeWrapper.ATTACK){
attackTargets.push(wrapper);
};
i = (i + 1);
};
attackTargets.sortOn("resourceDamage");
var markerThreshold:int = Math.floor((attackTargets.length / 3));
var secondMarkerThreshold:int = Math.floor(((2 * attackTargets.length) / 3));
i = 0;
while (i < attackTargets.length) {
wrapper = attackTargets[i];
if (wrapper.resourceDamage < 17){
wrapper.sort = 2;
} else {
if (wrapper.resourceDamage < 42){
wrapper.sort = 1;
} else {
wrapper.sort = 0;
};
};
i = (i + 1);
};
createClearButton(a_unit);
var resortedNodes:Array = [];
i = 0;
while (i < allNodes.length) {
wrapper = allNodes[i];
node = allNodes[i].node;
unit = node.getUnit();
if ((((wrapper.type == NodeWrapper.ATTACK)) || ((wrapper.type == NodeWrapper.MOVE)))){
ignoreBuildings.push(node);
};
if ((((((((wrapper.type == NodeWrapper.ATTACK)) || ((wrapper.type == NodeWrapper.RANGE)))) || (choices))) || ((nodes[i] == tile)))){
if (wrapper.type == NodeWrapper.MOVE){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("select")), "move");
b.value = new MovePosition(node.getX(), node.getY(), a_unit);
} else {
if (wrapper.type == NodeWrapper.ATTACK){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectRed")), "attack");
targetGraphic = TileSheetManager.getInstance().get("attackTargets");
targetGraphic.noAnimation = true;
targetGraphic.setFrame(int(wrapper.sort));
targetGraphic.mouseEnabled = false;
targetGraphic.mouseChildren = false;
targetGraphic.x = (node.getGameTile().x - 40);
targetGraphic.y = (node.getGameTile().y - 40);
if (targetGraphic.x < 0){
targetGraphic.x = (targetGraphic.width + 40);
targetGraphic.scaleX = -1;
};
if (targetGraphic.y < 0){
targetGraphic.y = 0;
};
gameManager.getGameSpriteScroller().add(targetGraphic, GameSpriteScroller.ABOVE_ALL);
buttons.push(targetGraphic);
b.value = new MovePosition(node.getX(), node.getY(), a_unit, true);
} else {
if (wrapper.type == NodeWrapper.RANGE){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectOrange")));
} else {
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("selectMixed")), "move");
b.value = new MovePosition(node.getX(), node.getY(), a_unit);
};
};
};
if (wrapper.type != NodeWrapper.RANGE){
b.mouseOver = function ():void{
chooseMove(this.value);
};
at = false;
if (node.getUnit() != null){
at = ((node.getUnit().isCloaked()) && (!((node.getUnit().getController() == a_unit.getController()))));
if (node.getUnit() == a_unit){
b.setCursor("option");
};
};
if ((((((((wrapper.type == NodeWrapper.ATTACK)) || ((node.getUnit() == null)))) || ((node == tile)))) || (at))){
b.release = function ():void{
GameManager.getInstance().getGameSpriteScroller().swapDepth(a_unit.getGameUnit(), GameSpriteScroller.UNITS);
selectMove(this.value);
};
if (node == tile){
b.addChild(new BitmapSprite(AssetLibrary.createBitmapData("marker")));
};
} else {
if (unit != null){
if ((((((((unit.getController() == a_unit.getController())) && (unit.isAlive()))) && (unit.isDeployed()))) && (unit.isAvailable()))){
b.value = new MovePositionClick(b.value.x, b.value.y, b.value.unit, unit);
b.release = function ():void{
GameManager.getInstance().getGameSpriteScroller().swapDepth(a_unit.getGameUnit(), GameSpriteScroller.UNITS);
selectUnit(this.value.other);
};
b.addChild(new BitmapSprite(AssetLibrary.createBitmapData("marker")));
ignoreUnits.push(unit);
b.setCursor("select");
};
};
};
} else {
if (unit != null){
if ((((((((unit.getController() == a_unit.getController())) && (unit.isAlive()))) && (unit.isDeployed()))) && (unit.isAvailable()))){
b.value = unit;
b.release = function ():void{
GameManager.getInstance().getGameSpriteScroller().swapDepth(a_unit.getGameUnit(), GameSpriteScroller.UNITS);
selectUnit(this.value);
};
b.addChild(new BitmapSprite(AssetLibrary.createBitmapData("marker")));
b.setCursor("select");
ignoreUnits.push(unit);
};
};
};
b.x = node.getGameTile().x;
b.y = node.getGameTile().y;
if ((((wrapper.type == NodeWrapper.RANGE)) && ((b.value == null)))){
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.TOP);
} else {
gameManager.getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
};
buttons.push(b);
};
i = (i + 1);
};
chooseMove(new MovePosition(a_unit.getX(), a_unit.getY(), a_unit));
selectUnits(ignoreUnits);
selectBuildings(ignoreBuildings);
}
public function buildUnits(a_unit:UnitData, a_tile:Tile):void{
ActionManager.getInstance().add(new BuildUnitAction(a_tile.getX(), a_tile.getY(), a_unit.getName()));
clearUIButtons();
}
protected function selectBuildings(a_ignore:Array=null):void{
var b:GameButton;
var a_ignore = a_ignore;
if (a_ignore == null){
a_ignore = new Array();
};
var i:int;
while (i < structures.length) {
if (a_ignore.indexOf(structures[i]) == -1){
if (structures[i].getUnit() == null){
if (structures[i].getTerrain().hasModifier("Construction")){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("marker")), "select");
b.value = structures[i];
b.release = function ():void{
selectBuilding(this.value);
};
b.x = structures[i].getGameTile().x;
b.y = structures[i].getGameTile().y;
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
};
};
};
i = (i + 1);
};
}
override public function setCamera():void{
if (camerax != -1){
GameManager.getInstance().getCamera().setLocation(camerax, cameray);
};
}
function clearUI():void{
clearUIButtons();
clearButtons();
clearPath();
}
protected function clearUIButtons():void{
if (buildMenu != null){
GameManager.getInstance().getParent().removeChild(buildMenu);
buildMenu = null;
};
}
protected function controlListener(a_trigger:Trigger):void{
if (((control) && (enabled))){
receiveControl();
};
}
protected function endTurnHandler(a_event:Event):void{
endTurn();
}
protected function nextUnitHandler(a_event:Event):void{
selectNextUnit();
}
function labelledGameButton(a_sprite:GameSprite, a_label:String):GameButton{
var b:GameButton = new GameButton(a_sprite, "select");
var tf:TextField = new DefaultTextField();
tf.width = (tf.height = 500);
tf.text = a_label;
tf.width = (tf.textWidth + 5);
tf.height = (tf.textHeight + 5);
tf.x = a_sprite.width;
b.addChild(tf);
return (b);
}
protected function createClearButton(a_unit:Unit=null):void{
var a_unit = a_unit;
var gs:GameSprite = new GameSprite();
gs.graphics.beginFill(0xFFFFFF, 0);
gs.graphics.drawRect(0, 0, (GameManager.getInstance().getMap().getWidth() * TileManager.getInstance().getWidth()), (GameManager.getInstance().getMap().getHeight() * TileManager.getInstance().getHeight()));
gs.graphics.endFill();
var b:GameButton = new GameButton(gs);
if (a_unit){
b.release = function ():void{
GameManager.getInstance().getGameSpriteScroller().swapDepth(a_unit.getGameUnit(), GameSpriteScroller.UNITS);
receiveControl();
};
} else {
b.release = function ():void{
receiveControl();
};
};
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
}
override public function update(a_ms:uint=0):void{
if (buildMenu != null){
buildMenu.update(a_ms);
};
}
protected function selectNextUnit():void{
var startIndex:int;
var i:int;
while (i < units.length) {
if (units[i] == lastSelected){
startIndex = i;
break;
};
i++;
};
i = (startIndex + 1);
while (i < units.length) {
if (units[i].isAvailable()){
selectUnit(units[i]);
GameManager.getInstance().getCamera().setTarget(units[i].getGameUnit(), 500);
return;
};
i++;
};
i = 0;
while (i < startIndex) {
if (units[i].isAvailable()){
selectUnit(units[i]);
GameManager.getInstance().getCamera().setTarget(units[i].getGameUnit(), 500);
return;
};
i++;
};
}
protected function selectBuilding(a_tile:Tile):void{
clearButtons();
createClearButton();
GameManager.getInstance().getCamera().setTarget(a_tile.getGameTile(), 500);
buildMenu = new BuildMenu(this, a_tile);
buildMenu.x = (GameManager.getInstance().getSprite().x + ((GameManager.GAME_WIDTH - BuildMenu.WIDTH) / 2));
buildMenu.y = (GameManager.getInstance().getSprite().y + ((GameManager.GAME_HEIGHT - BuildMenu.HEIGHT) / 2));
GameManager.getInstance().getCamera().setEnabled(false);
GameManager.getInstance().getParent().addChild(buildMenu);
}
override public function showCloak():Boolean{
return (true);
}
override protected function startCurrentTurn():void{
control = true;
cloakVisibility = 0.5;
var i:int;
while (i < units.length) {
if (units[i].isCloaked()){
units[i].setCloaked(false, true);
};
i++;
};
SoundSystem.instance.destroyLoop("background");
SoundSystem.instance.createLoop("background", SoundSystem.instance.createSound("PlayerLoopWAV"));
}
function upgradeUnits(a_unit:Unit, a_upgrade:Boolean, a_type:String=""):void{
ActionManager.getInstance().add(new UpgradeUnitAction(a_unit.getX(), a_unit.getY(), a_upgrade, a_type));
clearUI();
}
public function clear():void{
clearUIButtons();
receiveControl();
}
protected function selectUnits(a_ignoreUnits:Array=null, a_ignoreEnemies:Array=null):void{
var b:GameButton;
var allUnits:Array;
var a_ignoreUnits = a_ignoreUnits;
var a_ignoreEnemies = a_ignoreEnemies;
if (a_ignoreUnits == null){
a_ignoreUnits = new Array();
};
if (a_ignoreEnemies == null){
a_ignoreEnemies = new Array();
};
var done:int;
var i:int;
while (i < units.length) {
if (a_ignoreUnits.indexOf(units[i]) == -1){
if (((((units[i].isAlive()) && (units[i].isDeployed()))) && (units[i].isAvailable()))){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("marker")), "select");
b.value = units[i];
b.release = function ():void{
selectUnit(this.value);
};
b.x = units[i].getGameUnit().x;
b.y = units[i].getGameUnit().y;
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
done = (done + 1);
};
};
i = (i + 1);
};
if (a_ignoreUnits.length == 0){
allUnits = GameManager.getInstance().getUnits();
i = 0;
while (i < allUnits.length) {
if (a_ignoreEnemies.indexOf(allUnits[i]) == -1){
if (allUnits[i].getController() != this){
if (((((allUnits[i].isAlive()) && (allUnits[i].isDeployed()))) && (!(allUnits[i].isCloaked())))){
b = new GameButton(new BitmapSprite(AssetLibrary.createBitmapData("marker2")), "select");
b.value = allUnits[i];
b.release = function ():void{
selectEnemyUnit(this.value);
};
b.x = allUnits[i].getGameUnit().x;
b.y = allUnits[i].getGameUnit().y;
GameManager.getInstance().getGameSpriteScroller().add(b, GameSpriteScroller.BUTTONS);
buttons.push(b);
};
};
};
i = (i + 1);
};
};
if (done == 0){
};
}
protected function keyDownHandler(a_event:KeyboardEvent):void{
if (a_event.keyCode == Keyboard.CONTROL){
if (GameManager.getInstance().getCamera().isEnabled()){
selectNextUnit();
};
};
}
override protected function endGame():void{
var b:TileSheetButton;
var n:TileSheetButton;
clearPath();
clearButtons();
clearUIButtons();
if (control){
b = GameManager.getInstance().getEndTurnButton();
b.removeEventListener(MouseEvent.CLICK, endTurnHandler);
b.disable();
n = GameManager.getInstance().getNextUnitButton();
n.removeEventListener(MouseEvent.CLICK, nextUnitHandler);
BattalionMain.getStage().removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
n.disable();
GameManager.getInstance().getParent().mainMenuButton.disable();
control = false;
camerax = GameManager.getInstance().getCamera().getX();
cameray = GameManager.getInstance().getCamera().getY();
GameManager.getInstance().getCamera().setEnabled(false);
};
}
function repairUnits(a_unit:Unit):void{
ActionManager.getInstance().add(new RepairUnitAction(a_unit.getX(), a_unit.getY()));
clearUI();
}
protected function selectMove(a_position:MovePosition):void{
GameManager.getInstance().getCamera().setEnabled(false);
chooseMove(a_position);
clearButtons();
if (((((!(a_position.attack)) && ((currentPath[(currentPath.length - 2)] == a_position.unit.getX())))) && ((currentPath[(currentPath.length - 1)] == a_position.unit.getY())))){
unitMenu(a_position.unit);
} else {
ActionManager.getInstance().add(new MoveUnitAction(a_position.unit.getX(), a_position.unit.getY(), currentPath));
if (a_position.attack){
ActionManager.getInstance().add(new AttackUnitAction(currentPath[(currentPath.length - 2)], currentPath[(currentPath.length - 1)], a_position.x, a_position.y));
};
ActionManager.getInstance().add(new NoAttackAction(currentPath[(currentPath.length - 2)], currentPath[(currentPath.length - 1)]));
clearUIButtons();
};
clearPath();
}
protected function endTurn():void{
clearPath();
clearButtons();
clearUIButtons();
var b:TileSheetButton = GameManager.getInstance().getEndTurnButton();
b.removeEventListener(MouseEvent.CLICK, endTurnHandler);
b.disable();
var n:TileSheetButton = GameManager.getInstance().getNextUnitButton();
n.removeEventListener(MouseEvent.CLICK, nextUnitHandler);
BattalionMain.getStage().removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
n.disable();
GameManager.getInstance().getParent().mainMenuButton.disable();
control = false;
camerax = GameManager.getInstance().getCamera().getX();
cameray = GameManager.getInstance().getCamera().getY();
GameManager.getInstance().getCamera().setEnabled(false);
ActionManager.getInstance().add(new EndTurnAction());
}
protected function receiveControl():void{
clearPath();
clearButtons();
clearUIButtons();
GameManager.getInstance().getCamera().setEnabled(true);
var b:TileSheetButton = GameManager.getInstance().getEndTurnButton();
b.addEventListener(MouseEvent.CLICK, endTurnHandler);
b.enable();
var n:TileSheetButton = GameManager.getInstance().getNextUnitButton();
n.addEventListener(MouseEvent.CLICK, nextUnitHandler);
BattalionMain.getStage().addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
n.enable();
GameManager.getInstance().getParent().mainMenuButton.enable();
selectUnits();
selectBuildings();
}
override protected function startTurn(a_player:int):void{
control = false;
cloakVisibility = 0;
var i:int;
while (i < units.length) {
if (units[i].isCloaked()){
units[i].setCloaked(false, true);
};
i++;
};
}
}
}//package com.gamedozer.battalion.game.controllers
import com.gamedozer.battalion.data.*;
class NodeWrapper {
public var node:Node;
public var type:int;
public var resourceDamage:Number;// = 0
public var sort:Number;
public static const MOVE:int = 0;
public static const RANGE_MOVE:int = 2;
public static const ATTACK:int = 3;
public static const RANGE:int = 1;
private function NodeWrapper(a_node:Node, a_type:int, a_sort:Number=0){
super();
node = a_node;
type = a_type;
sort = a_sort;
}
}
class MovePosition {
public var unit:Unit;
public var attack:Boolean;
public var x:int;
public var y:int;
private function MovePosition(a_x:int=-1, a_y:int=-1, a_unit:Unit=null, a_attack:Boolean=false){
super();
x = a_x;
y = a_y;
unit = a_unit;
attack = a_attack;
}
}
class MovePositionClick extends MovePosition {
public var other:Unit;
private function MovePositionClick(a_x:int=-1, a_y:int=-1, a_unit:Unit=null, a_other:Unit=null){
super(a_x, a_y, a_unit, false);
other = a_other;
}
}
class BuildPosition {
public var unit:UnitData;
public var x:int;
public var y:int;
private function BuildPosition(a_x:int=-1, a_y:int=-1, a_unit:UnitData=null){
super();
x = a_x;
y = a_y;
unit = a_unit;
}
}
Section 94
//ChatResponse (com.gamedozer.battalion.game.responses.ChatResponse)
package com.gamedozer.battalion.game.responses {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class ChatResponse extends Response {
protected var color:String;
protected var message:String;
protected var chatWindow:ChatWindow;
protected var sender:String;
protected var avatar:String;
protected static var lastWindow:ChatWindow;
public function ChatResponse(a_sender:String, a_message:String, a_avatar:String, a_color:String){
super();
sender = a_sender;
message = a_message;
avatar = a_avatar;
color = a_color;
}
public function clickHandler(a_event:Event):void{
if (chatWindow.isDisplayed()){
remove();
} else {
chatWindow.display();
};
}
public function remove():void{
chatWindow.removeEventListener(MouseEvent.CLICK, clickHandler);
if ((((ResponseManager.getInstance().peek(this) is ChatResponse)) || ((ResponseManager.getInstance().peek(this) is HighlightResponse)))){
lastWindow = chatWindow;
chatWindow = null;
super.update();
} else {
TweenManager.getInstance().add(new Tween(chatWindow, Sine.easeIn, ["y"], [chatWindow.y], [(chatWindow.y + ChatWindow.PANEL_HEIGHT)], 500));
TweenManager.getInstance().add(new TweenFunction(finish, chatWindow), TweenManager.SEQUENTIAL);
};
}
override public function update():void{
}
public function finish():void{
GameManager.getInstance().getSprite().removeChild(chatWindow);
chatWindow = null;
super.update();
}
public function buttonClickHandler(a_event:Event):void{
remove();
}
override public function fire():void{
super.fire();
var dialog:Boolean = BattalionMain.getStorage().getBoolean("dialog", true);
if (!dialog){
chatWindow = null;
super.update();
return;
};
if (lastWindow != null){
chatWindow = lastWindow;
lastWindow = null;
chatWindow.setDisplay(BBCode.parseBBCode(sender), BBCode.parseBBCode(message), BBCode.parseAvatarCode(avatar), parseInt(BBCode.parseColorCode(color), 16));
(chatWindow.y - ChatWindow.PANEL_HEIGHT);
} else {
chatWindow = new ChatWindow(BBCode.parseBBCode(sender), BBCode.parseBBCode(message), BBCode.parseAvatarCode(avatar), parseInt(BBCode.parseColorCode(color), 16));
chatWindow.y = GameManager.GAME_HEIGHT;
TweenManager.getInstance().add(new Tween(chatWindow, Sine.easeOut, ["y"], [chatWindow.y], [(chatWindow.y - ChatWindow.PANEL_HEIGHT)], 500));
};
GameManager.getInstance().getSprite().addChild(chatWindow);
chatWindow.addEventListener(MouseEvent.CLICK, clickHandler);
}
override public function toXML():XML{
return (new XML((((((((("<response type=\"chat\"><sender value=\"" + sender) + "\"/><message value=\"") + message) + "\"/><avatar value=\"") + avatar) + "\"/><color value=\"") + color) + "\"/></response>")));
}
override public function globalQueue():Boolean{
return (true);
}
public static function getFromXML(a_xml:XML):Response{
return (new ChatResponse(a_xml.sender.@value, a_xml.message.@value, a_xml.avatar.@value, a_xml.color.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 95
//CreateTransportedUnitResponse (com.gamedozer.battalion.game.responses.CreateTransportedUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class CreateTransportedUnitResponse extends Response {
protected var player:int;
protected var transportType:String;
protected var transporterType:String;
protected var x:int;
protected var y:int;
public function CreateTransportedUnitResponse(a_x:int, a_y:int, a_transportType:String, a_transporterType:String, a_player:int){
super();
x = a_x;
y = a_y;
transportType = a_transportType;
transporterType = a_transporterType;
player = a_player;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var transportData:UnitData = UnitManager.getInstance().get(transportType);
var transporterData:UnitData = UnitManager.getInstance().get(transporterType);
if ((((transportData == null)) || ((transporterData == null)))){
trace("CreateTransportedUnitResponse::Invalid transportee or transporter name");
super.fire();
return;
};
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
trace(((((("CreateTransportedUnitResponse::Can't create a transport there because a unit [" + unit) + "] at ") + x) + ",") + y));
super.fire();
return;
};
var controller:Controller = gameManager.getController((player - 1));
var tile:Tile = gameManager.tileAt(x, y);
var gu:GameUnit = new GameUnit(TileSheetManager.getInstance().getColorised(transportData.getSprite(), controller.getTeam().getColor()));
var newUnit:Unit = new Unit(gu, transportData, x, y, controller);
newUnit.setDeployed(true);
gameManager.getGameSpriteScroller().add(gu, GameSpriteScroller.UNITS);
gameManager.addUnit(controller, newUnit);
tile.setUnit(newUnit);
newUnit.getGameUnit().getSprite().alpha = 0;
var transporterTileSheet:TileSheet = TileSheetManager.getInstance().getColorised(transporterData.getSprite(), controller.getTeam().getColor());
newUnit.upgrade(transporterTileSheet, transporterData);
var ts:TileSheet = (newUnit.getGameUnit().getSprite() as TileSheet);
if (newUnit.getX() > (gameManager.getMap().getWidth() / 2)){
ts.playAnimation("left_idle");
} else {
ts.playAnimation("right_idle");
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((((((("<response type=\"createTransportedUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><transportType value=\"") + transportType) + "\"/><transporterType value=\"") + transporterType) + "\"/><player value=\"") + player) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new CreateTransportedUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value), a_xml.transportType.@value, a_xml.transporterType.@value, a_xml.player.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 96
//CreateUnitResponse (com.gamedozer.battalion.game.responses.CreateUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class CreateUnitResponse extends Response {
protected var player:int;
protected var parallel:Boolean;
protected var fadeIn:Boolean;
protected var x:int;
protected var y:int;
protected var type:String;
public function CreateUnitResponse(a_x:int, a_y:int, a_type:String, a_player:int, a_fadeIn:Boolean, a_parallel:Boolean){
super();
x = a_x;
y = a_y;
type = a_type;
player = a_player;
fadeIn = a_fadeIn;
parallel = a_parallel;
}
override public function update():void{
}
private function execute():void{
super.update();
}
override public function fire():void{
var type:int;
var gameManager:GameManager = GameManager.getInstance();
var unitData:UnitData = UnitManager.getInstance().get(type);
super.fire();
if (unitData == null){
trace("CreateUnitResponse::Invalid unit type");
execute();
return;
};
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
trace("CreateUnitResponse::Can't create a transport there because a unit is in that location");
execute();
return;
};
var controller:Controller = gameManager.getController((player - 1));
var tile:Tile = gameManager.tileAt(x, y);
var gu:GameUnit = new GameUnit(TileSheetManager.getInstance().getColorised(unitData.getSprite(), controller.getTeam().getColor()));
var newUnit:Unit = new Unit(gu, unitData, x, y, controller);
newUnit.setDeployed(true);
gameManager.addUnit(controller, newUnit);
tile.setUnit(newUnit);
gameManager.getGameSpriteScroller().add(gu, GameSpriteScroller.UNITS);
var ts:TileSheet = (newUnit.getGameUnit().getSprite() as TileSheet);
if (newUnit.getX() > (gameManager.getMap().getWidth() / 2)){
ts.playAnimation("left_idle");
} else {
ts.playAnimation("right_idle");
};
if (fadeIn){
newUnit.getGameUnit().alpha = 0;
type = TweenManager.SEQUENTIAL_ALL;
if (parallel){
type = TweenManager.PARALLEL;
} else {
type = TweenManager.SEQUENTIAL_ALL;
};
TweenManager.getInstance().add(new Tween(newUnit.getGameUnit(), Quad.easeIn, ["alpha"], [0], [1], 1000), type);
TweenManager.getInstance().add(new TweenFunction(execute), type);
} else {
execute();
};
}
override public function toXML():XML{
return (new XML((((((((((((("<response type=\"createUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><type value=\"") + type) + "\"/><player value=\"") + player) + "\"/><fadeIn value=\"") + fadeIn) + "\"/><parallel value=\"") + parallel) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
var doFadeIn = (String(a_xml.fadeIn.@value).toLowerCase() == "true");
var doParallel = (String(a_xml.parallel.@value).toLowerCase() == "true");
return (new CreateUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value), a_xml.type.@value, a_xml.player.@value, doFadeIn, doParallel));
}
}
}//package com.gamedozer.battalion.game.responses
Section 97
//DamageUnitResponse (com.gamedozer.battalion.game.responses.DamageUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class DamageUnitResponse extends Response {
protected var x:int;
protected var y:int;
protected var amount:Number;
public function DamageUnitResponse(a_x:int, a_y:int, a_amount:Number){
super();
x = a_x;
y = a_y;
amount = a_amount;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
if (unit.getHealth() <= amount){
TweenManager.getInstance().add(new Tween(unit.getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL);
TriggerManager.getInstance().add(new KillUnitTrigger(x, y, unit));
unit.getController().getTeam().addStatistic(Team.UNITS_LOST, 1);
gameManager.removeUnit(unit);
} else {
unit.takeDamage(amount);
};
} else {
trace("DamageUnitResponse::No unit to destroy");
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((("<response type=\"damageUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><amount value=\"") + amount) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new DamageUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value), Number(a_xml.amount.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 98
//DecrementCounterVariableResponse (com.gamedozer.battalion.game.responses.DecrementCounterVariableResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.conditions.*;
public class DecrementCounterVariableResponse extends Response {
var counter:String;
public function DecrementCounterVariableResponse(a_counter:String){
super();
counter = a_counter;
}
override public function fire():void{
CounterVariableCondition.setCounter(counter, (CounterVariableCondition.getCounter(counter) - 1));
super.fire();
}
override public function toXML():XML{
return (new XML((("<response type=\"decrementCounterVariable\"><counter value=\"" + counter) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new DecrementCounterVariableResponse(a_xml.counter.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 99
//DestroyUnitResponse (com.gamedozer.battalion.game.responses.DestroyUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class DestroyUnitResponse extends Response {
protected var x:int;
protected var y:int;
public function DestroyUnitResponse(a_x:int, a_y:int){
super();
x = a_x;
y = a_y;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
GameManager.getInstance().addExplosion("Explosion", unit.getGameUnit());
TweenManager.getInstance().add(new Tween(unit.getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL);
TriggerManager.getInstance().add(new KillUnitTrigger(x, y, unit));
unit.getController().getTeam().addStatistic(Team.UNITS_LOST, 1);
gameManager.removeUnit(unit);
} else {
trace("DestroyUnitResponse::No unit to destroy");
};
super.fire();
}
override public function toXML():XML{
return (new XML((((("<response type=\"destroyUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new DestroyUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 100
//DisableControllersResponse (com.gamedozer.battalion.game.responses.DisableControllersResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
public class DisableControllersResponse extends Response {
protected var disable:Boolean;
public function DisableControllersResponse(a_disable:Boolean=true){
super();
disable = a_disable;
}
override public function toXML():XML{
return (new XML((("<response type=\"disableControllers\"><disable value=\"" + ((disable == true)) ? "true" : "false") + "\"/></response>")));
}
override public function fire():void{
var controllers:Array = GameManager.getInstance().getControllers();
var i:int;
while (i < controllers.length) {
if (controllers[i] != null){
controllers[i].setEnabled(!(disable));
};
i++;
};
GameManager.getInstance().getCamera().setEnabled(!(disable));
TriggerManager.getInstance().add(new Trigger(Trigger.CONTROL));
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
var disable:Boolean;
var booleanString:String = a_xml.disable.@value;
if (booleanString.toLowerCase().charAt(0) == "f"){
disable = false;
};
return (new DisableControllersResponse(disable));
}
}
}//package com.gamedozer.battalion.game.responses
Section 101
//DisableUnitResponse (com.gamedozer.battalion.game.responses.DisableUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class DisableUnitResponse extends Response {
protected var player:int;
protected var unit:String;
protected var disable:Boolean;
public function DisableUnitResponse(a_disable:Boolean, a_player:int, a_unit:String){
super();
disable = a_disable;
player = a_player;
unit = a_unit;
}
override public function fire():void{
var controllers:Array;
var i:int;
var controller:Controller;
if (player == 0){
controllers = GameManager.getInstance().getControllers();
i = 0;
while (i < controllers.length) {
if (controllers[i] != null){
if (!disable){
controllers[i].enableUnit(unit);
} else {
controllers[i].disableUnit(unit);
};
};
i++;
};
} else {
if (player > 0){
player--;
controller = GameManager.getInstance().getController(player);
if (controller != null){
if (!disable){
controller.enableUnit(unit);
} else {
controller.disableUnit(unit);
};
};
};
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((("<response type=\"disableUnit\"><disable value=\"" + disable) + "\"/><player value=\"") + player) + "\"/><unit value=\"") + unit) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new DisableUnitResponse((a_xml.disable.@value.toLowerCase().charAt(0) == "t"), parseInt(a_xml.player.@value), a_xml.unit.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 102
//HighlightResponse (com.gamedozer.battalion.game.responses.HighlightResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
public class HighlightResponse extends Response {
protected var x:int;
protected var y:int;
protected var show:Boolean;
protected static var highlights:Dictionary;
public function HighlightResponse(a_x:int, a_y:int, a_show:Boolean){
super();
x = a_x;
y = a_y;
show = a_show;
highlights = new Dictionary();
}
private function tweenUp():void{
var gs:GameSprite = highlights[((x + "_") + y)];
if (gs == null){
return;
};
TweenManager.getInstance().add(new Tween(gs, Linear.easeIn, ["alpha"], [1], [0.2], 750), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(tweenDown, gs), TweenManager.SEQUENTIAL);
}
private function tweenDown():void{
var gs:GameSprite = highlights[((x + "_") + y)];
if (gs == null){
return;
};
TweenManager.getInstance().add(new Tween(gs, Linear.easeIn, ["alpha"], [0.2], [1], 750), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenFunction(tweenUp, gs), TweenManager.SEQUENTIAL);
}
public function get willShow():Boolean{
return (show);
}
public function get willHide():Boolean{
return (!(show));
}
override public function fire():void{
var gs:GameSprite;
gs = highlights[((x + "_") + y)];
if (show){
if (gs == null){
gs = new BitmapSprite(BitmapLibrary.loadBitmap("highlight"));
gs.x = (((x + 0.5) * TileManager.getInstance().getWidth()) - (gs.width / 2));
gs.y = (((y + 0.5) * TileManager.getInstance().getHeight()) - (gs.height / 2));
GameManager.getInstance().getGameSpriteScroller().add(gs, GameSpriteScroller.TOP);
GameManager.getInstance().getCamera().setTarget(gs, 100);
highlights[((x + "_") + y)] = gs;
gs.alpha = 0.2;
tweenDown();
};
} else {
if (gs != null){
TweenManager.getInstance().removeTweens(gs);
GameManager.getInstance().getGameSpriteScroller().remove(gs);
};
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((("<response type=\"highlight\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><show value=\"") + ((show == true)) ? "true" : "false") + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
var show:Boolean;
var booleanString:String = a_xml.show.@value;
if (booleanString.toLowerCase().charAt(0) == "t"){
show = true;
};
return (new HighlightResponse(int(a_xml.x.@value), int(a_xml.y.@value), show));
}
}
}//package com.gamedozer.battalion.game.responses
Section 103
//IncrementCounterVariableResponse (com.gamedozer.battalion.game.responses.IncrementCounterVariableResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.conditions.*;
public class IncrementCounterVariableResponse extends Response {
var counter:String;
public function IncrementCounterVariableResponse(a_counter:String){
super();
counter = a_counter;
}
override public function fire():void{
CounterVariableCondition.setCounter(counter, (CounterVariableCondition.getCounter(counter) + 1));
super.fire();
}
override public function toXML():XML{
return (new XML((("<response type=\"incrementCounterVariable\"><counter value=\"" + counter) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new IncrementCounterVariableResponse(a_xml.counter.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 104
//NameUnitResponse (com.gamedozer.battalion.game.responses.NameUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class NameUnitResponse extends Response {
protected var x:int;
protected var y:int;
protected var name:String;
protected static var units:Dictionary;
public function NameUnitResponse(a_x:int, a_y:int, a_name:String){
super();
x = a_x;
y = a_y;
name = a_name;
units = new Dictionary(true);
}
override public function toXML():XML{
return (new XML((((((("<response type=\"nameUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><name value=\"") + name) + "\"/></response>")));
}
override public function fire():void{
var unit:Unit;
var gameManager:GameManager = GameManager.getInstance();
if (UnitManager.getInstance().get(name) == null){
unit = gameManager.unitAt(x, y);
if (unit != null){
units[name] = unit;
};
} else {
trace("NamedUnitResponse::Cannot name a unit to a stock unit name");
};
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
return (new NameUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value), a_xml.name));
}
public static function getNamedUnit(a_name:String):Unit{
return (units[a_name]);
}
}
}//package com.gamedozer.battalion.game.responses
Section 105
//RemoveUnitResponse (com.gamedozer.battalion.game.responses.RemoveUnitResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class RemoveUnitResponse extends Response {
protected var fadeOut:Boolean;
protected var x:int;
protected var y:int;
public function RemoveUnitResponse(a_x:int, a_y:int, a_fadeOut:Boolean){
super();
x = a_x;
y = a_y;
fadeOut = a_fadeOut;
}
private function execute():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(x, y);
gameManager.removeUnit(unit);
super.update();
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
if (fadeOut){
TweenManager.getInstance().add(new Tween(unit.getGameUnit(), Quad.easeIn, ["alpha"], [1], [0], 1000), TweenManager.SEQUENTIAL_ALL);
TweenManager.getInstance().add(new TweenFunction(execute, this), TweenManager.SEQUENTIAL_ALL);
} else {
execute();
};
} else {
trace("RemoveUnitResponse::No unit to remove");
};
super.fire();
}
override public function update():void{
}
override public function toXML():XML{
return (new XML((((((("<response type=\"removeUnit\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><fadeOut value=\"") + fadeOut) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
var doFadeOut:Boolean = Boolean(a_xml.fadeOut.@value);
return (new RemoveUnitResponse(int(a_xml.x.@value), int(a_xml.y.@value), doFadeOut));
}
}
}//package com.gamedozer.battalion.game.responses
Section 106
//ResourcesResponse (com.gamedozer.battalion.game.responses.ResourcesResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class ResourcesResponse extends Response {
protected var player:int;
protected var amount:int;
public function ResourcesResponse(a_player:int, a_amount:int){
super();
player = a_player;
amount = a_amount;
}
override public function fire():void{
var controllers:Array;
var i:int;
var controller:Controller;
if (player == 0){
controllers = GameManager.getInstance().getControllers();
i = 0;
while (i < controllers.length) {
if (controllers[i] != null){
controllers[i].addResources(amount);
};
i++;
};
} else {
if (player > 0){
player--;
controller = GameManager.getInstance().getController(player);
if (controller != null){
controller.addResources(amount);
};
};
};
super.fire();
}
override public function toXML():XML{
return (new XML((((("<response type=\"resources\"><player value=\"" + player) + "\"/><amount value=\"") + amount) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new ResourcesResponse(int(a_xml.player.@value), parseInt(a_xml.amount.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 107
//ScrollResponse (com.gamedozer.battalion.game.responses.ScrollResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class ScrollResponse extends Response {
protected var x:int;
protected var y:int;
public function ScrollResponse(a_x:int, a_y:int){
super();
x = a_x;
y = a_y;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
TweenManager.getInstance().add(new TweenFunction(doScroll, this), TweenManager.SEQUENTIAL);
}
override public function toXML():XML{
return (new XML((((("<response type=\"scroll\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/></response>")));
}
private function doScroll():void{
GameManager.getInstance().getCamera().setLocation(((-1 * (x - 6)) * BattalionMain.TILE_WIDTH), ((-1 * (y - 5)) * BattalionMain.TILE_HEIGHT));
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
return (new ScrollResponse(int(a_xml.x.@value), int(a_xml.y.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 108
//SendActionResponse (com.gamedozer.battalion.game.responses.SendActionResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
public class SendActionResponse extends Response {
var action:Action;
public function SendActionResponse(a_action:Action){
super();
action = a_action;
}
override public function toXML():XML{
return (new XML((("<response type=\"sendAction\">" + action.toXML()) + "</response>")));
}
override public function fire():void{
ActionManager.getInstance().add(action);
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
return (new SendActionResponse(ActionFactory.get(a_xml..action[0])));
}
}
}//package com.gamedozer.battalion.game.responses
Section 109
//SendTriggerResponse (com.gamedozer.battalion.game.responses.SendTriggerResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
public class SendTriggerResponse extends Response {
var trigger:Trigger;
public function SendTriggerResponse(a_trigger:Trigger){
super();
trigger = a_trigger;
}
override public function toXML():XML{
return (new XML((("<response type=\"sendTrigger\">" + trigger.toXML()) + "</response>")));
}
override public function fire():void{
TriggerManager.getInstance().add(trigger);
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
return (new SendTriggerResponse(TriggerFactory.get(a_xml.trigger)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 110
//SetBooleanVariableResponse (com.gamedozer.battalion.game.responses.SetBooleanVariableResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.conditions.*;
public class SetBooleanVariableResponse extends Response {
var value:Boolean;
var boolean:String;
public function SetBooleanVariableResponse(a_boolean:String, a_value:Boolean){
super();
boolean = a_boolean;
value = a_value;
}
override public function fire():void{
BooleanVariableCondition.setBoolean(boolean, value);
super.fire();
}
override public function toXML():XML{
return (new XML((((("<response type=\"setBooleanVariable\"><boolean value=\"" + boolean) + "\"/><value value=\"") + ((value == true)) ? "true" : "false") + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
var value:Boolean;
var booleanString:String = a_xml.value.@value;
if (booleanString.toLowerCase().charAt(0) == "t"){
value = true;
};
return (new SetBooleanVariableResponse(a_xml.boolean.@value, value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 111
//StructureResourcesResponse (com.gamedozer.battalion.game.responses.StructureResourcesResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class StructureResourcesResponse extends Response {
protected var x:int;
protected var y:int;
protected var amount:int;
public function StructureResourcesResponse(a_x:int, a_y:int, a_amount:int){
super();
x = a_x;
y = a_y;
amount = a_amount;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var tile:Tile = gameManager.tileAt(x, y);
if (tile != null){
tile.setResources((tile.getResources() + amount));
} else {
trace("StructureResourcesResponse::No tile to add resources");
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((("<response type=\"structureResources\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><amount value=\"") + amount) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new StructureResourcesResponse(int(a_xml.x.@value), int(a_xml.y.@value), parseInt(a_xml.amount.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 112
//TraceResponse (com.gamedozer.battalion.game.responses.TraceResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.game.*;
public class TraceResponse extends Response {
var message:String;
public function TraceResponse(a_message:String){
super();
message = a_message;
}
override public function toXML():XML{
return (new XML((("<response type=\"trace\"><message value=\"" + message) + "\"/></response>")));
}
override public function fire():void{
trace(message);
super.fire();
}
public static function getFromXML(a_xml:XML):Response{
return (new TraceResponse(a_xml.message.@value));
}
}
}//package com.gamedozer.battalion.game.responses
Section 113
//UnitDisableResponse (com.gamedozer.battalion.game.responses.UnitDisableResponse)
package com.gamedozer.battalion.game.responses {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.actions.*;
public class UnitDisableResponse extends Response {
protected var x:int;
protected var y:int;
protected var disable:Boolean;
public function UnitDisableResponse(a_x:int, a_y:int, a_disable:Boolean){
super();
x = a_x;
y = a_y;
disable = a_disable;
}
override public function fire():void{
var gameManager:GameManager = GameManager.getInstance();
var unit:Unit = gameManager.unitAt(x, y);
if (unit != null){
if (disable){
unit.disable();
} else {
unit.enable();
};
} else {
trace("UnitDisableResponse::No unit to destroy");
};
super.fire();
}
override public function toXML():XML{
return (new XML((((((("<response type=\"unitDisable\"><x value=\"" + x) + "\"/><y value=\"") + y) + "\"/><disable value=\"") + disable) + "\"/></response>")));
}
public static function getFromXML(a_xml:XML):Response{
return (new UnitDisableResponse(int(a_xml.x.@value), int(a_xml.y.@value), Boolean(a_xml.disable.@value)));
}
}
}//package com.gamedozer.battalion.game.responses
Section 114
//AttackUnitTrigger (com.gamedozer.battalion.game.triggers.AttackUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class AttackUnitTrigger extends Trigger {
protected var unit:Unit;
protected var targetX:int;
protected var targetY:int;
protected var target:Unit;
protected var unitX:int;
protected var unitY:int;
public static const TRIGGER:String = "attackUnit";
public function AttackUnitTrigger(a_unitX:int, a_unitY:int, a_targetX:int, a_targetY:int, a_unit:Unit, a_target:Unit){
super(TRIGGER);
unit = a_unit;
targetX = a_targetX;
targetY = a_targetY;
target = a_target;
}
public function getUnit():Unit{
return (unit);
}
public function getTargetY():int{
return (targetY);
}
public function getTarget():Unit{
return (target);
}
public function getTargetX():int{
return (targetX);
}
public function getUnitX():int{
return (unitX);
}
public function getUnitY():int{
return (unitY);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 115
//BuildUnitTrigger (com.gamedozer.battalion.game.triggers.BuildUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class BuildUnitTrigger extends Trigger {
protected var unit:Unit;
public static const TRIGGER:String = "buildUnit";
public function BuildUnitTrigger(a_unit:Unit){
super(TRIGGER);
unit = a_unit;
}
public function getUnit():Unit{
return (unit);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 116
//CaptureTerrainTrigger (com.gamedozer.battalion.game.triggers.CaptureTerrainTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class CaptureTerrainTrigger extends Trigger {
protected var player:int;
protected var oldPlayer:int;
protected var tile:Tile;
protected var complete:Boolean;
public static const TRIGGER:String = "captureTerrain";
public function CaptureTerrainTrigger(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean){
super(TRIGGER);
tile = a_tile;
player = a_player;
oldPlayer = a_oldPlayer;
complete = a_complete;
}
public function getTile():Tile{
return (tile);
}
public function getOldPlayer():int{
return (oldPlayer);
}
public function getComplete():Boolean{
return (complete);
}
public function getPlayer():int{
return (player);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 117
//KillUnitTrigger (com.gamedozer.battalion.game.triggers.KillUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class KillUnitTrigger extends Trigger {
protected var unit:Unit;
protected var unitY:int;
protected var unitX:int;
public static const TRIGGER:String = "killUnit";
public function KillUnitTrigger(a_unitX:int, a_unitY:int, a_unit:Unit){
super(TRIGGER);
unitX = a_unitX;
unitY = a_unitY;
unit = a_unit;
}
public function getUnit():Unit{
return (unit);
}
public function getUnitY():int{
return (unitY);
}
public function getUnitX():int{
return (unitX);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 118
//MoveUnitTrigger (com.gamedozer.battalion.game.triggers.MoveUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class MoveUnitTrigger extends Trigger {
protected var unit:Unit;
protected var path:Array;
public static const TRIGGER:String = "moveUnit";
public function MoveUnitTrigger(a_unit:Unit, a_path:Array){
super(TRIGGER);
unit = a_unit;
path = a_path;
}
public function getUnit():Unit{
return (unit);
}
public function getPath():Array{
return (path);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 119
//PlayerTrigger (com.gamedozer.battalion.game.triggers.PlayerTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.game.*;
public class PlayerTrigger extends Trigger {
protected var player:int;
public static const NO_UNITS:String = "noUnits";
public static const END_GAME:String = "endGame";
public static const START_TURN:String = "startTurn";
public static const SURRENDER:String = "surrender";
public function PlayerTrigger(a_name:String, a_player:int){
super(a_name);
player = a_player;
}
public function setPlayer(a_player:int):void{
player = a_player;
}
public function getPlayer():int{
return (player);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 120
//RepairUnitTrigger (com.gamedozer.battalion.game.triggers.RepairUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class RepairUnitTrigger extends Trigger {
protected var unit:Unit;
public static const TRIGGER:String = "repairUnit";
public function RepairUnitTrigger(a_unit:Unit){
super(TRIGGER);
unit = a_unit;
}
public function getUnit():Unit{
return (unit);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 121
//ResourcesAcquiredTrigger (com.gamedozer.battalion.game.triggers.ResourcesAcquiredTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.game.*;
public class ResourcesAcquiredTrigger extends Trigger {
protected var player:int;
protected var resources:int;
public static const TRIGGER:String = "resourcesAcquired";
public function ResourcesAcquiredTrigger(a_player:int, a_resources:int){
super(TRIGGER);
resources = a_resources;
player = a_player;
}
public function getPlayer():int{
return (player);
}
public function getResources():int{
return (resources);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 122
//TimePassedTrigger (com.gamedozer.battalion.game.triggers.TimePassedTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.game.*;
public class TimePassedTrigger extends Trigger {
protected var time:uint;
public static const TRIGGER:String = "timePassed";
public function TimePassedTrigger(a_time:uint){
super(TRIGGER);
time = a_time;
}
public function getTime():uint{
return (time);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 123
//UpgradeUnitTrigger (com.gamedozer.battalion.game.triggers.UpgradeUnitTrigger)
package com.gamedozer.battalion.game.triggers {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.game.*;
public class UpgradeUnitTrigger extends Trigger {
protected var unit:Unit;
protected var upgrade:Boolean;
public static const TRIGGER:String = "upgradeUnit";
public function UpgradeUnitTrigger(a_unit:Unit, a_upgrade:Boolean){
super(TRIGGER);
unit = a_unit;
upgrade = a_upgrade;
}
public function getUnit():Unit{
return (unit);
}
public function getUpgrade():Boolean{
return (upgrade);
}
}
}//package com.gamedozer.battalion.game.triggers
Section 124
//Action (com.gamedozer.battalion.game.Action)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.data.*;
public class Action {
protected var completed:Boolean;
protected var fired:Boolean;
public function Action(){
super();
fired = false;
completed = false;
}
public function isCompleted():Boolean{
return (completed);
}
public function isFired():Boolean{
return (fired);
}
public function update():void{
completed = true;
}
public function usesUnit(a_unit:Unit):Boolean{
return (false);
}
public function toXML():XML{
return (new XML());
}
public function fire():void{
fired = true;
}
public function dispose():void{
}
}
}//package com.gamedozer.battalion.game
Section 125
//ActionFactory (com.gamedozer.battalion.game.ActionFactory)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.game.actions.*;
public class ActionFactory {
public function ActionFactory(){
super();
}
public static function get(a_xml:XML):Action{
var type:String = a_xml.@type;
switch (type){
case "surrenderAction":
return (SurrenderAction.getFromXML(a_xml));
};
return (new Action());
}
}
}//package com.gamedozer.battalion.game
Section 126
//ActionManager (com.gamedozer.battalion.game.ActionManager)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.data.*;
public class ActionManager {
protected var actions:Array;
private static var singleton:ActionManager;
public function ActionManager(){
super();
singleton = this;
actions = new Array();
}
public function add(a_action:Action, a_next:Boolean=false):void{
if (a_next){
actions.splice(1, 0, a_action);
} else {
actions.push(a_action);
};
}
public function update():void{
var action:Action;
if (actions.length > 0){
action = actions[0];
if (!action.isFired()){
action.fire();
} else {
action.update();
};
//unresolved jump
var _slot1 = e;
trace("ActionManager::", _slot1);
TriggerManager.getInstance().add(new Trigger(Trigger.ERROR));
if (action.isCompleted()){
action.dispose();
actions.shift();
if (actions.length == 0){
TriggerManager.getInstance().add(new Trigger(Trigger.CONTROL));
};
};
};
}
public function hasActionWithUnit(a_unit:Unit):Boolean{
var action:Action;
var i:int;
while (i < actions.length) {
action = actions[i];
if (action.usesUnit(a_unit)){
return (true);
};
i++;
};
return (false);
}
public function isEmpty():Boolean{
return ((actions.length == 0));
}
public static function getInstance():ActionManager{
if (singleton == null){
throw (new Error("ActionManager::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.game
Section 127
//Condition (com.gamedozer.battalion.game.Condition)
package com.gamedozer.battalion.game {
public interface Condition {
function reset():void;
function isSatisfied():Boolean;
function update():void;
function toXML():XML;
function dispose():void;
}
}//package com.gamedozer.battalion.game
Section 128
//ConditionFactory (com.gamedozer.battalion.game.ConditionFactory)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.game.conditions.*;
public class ConditionFactory {
public function ConditionFactory(){
super();
}
public static function get(a_xml:XML):Condition{
var type:String = a_xml.@type;
trace(("Type " + type));
switch (type){
case "not":
return (NotCondition.getFromXML(a_xml));
case "and":
return (LogicalAndCondition.getFromXML(a_xml));
case "or":
trace("OR!");
return (LogicalOrCondition.getFromXML(a_xml));
case "xor":
return (LogicalXorCondition.getFromXML(a_xml));
case "startGame":
return (StartGameCondition.getFromXML(a_xml));
case "startTurn":
return (StartTurnCondition.getFromXML(a_xml));
case "counterVariable":
return (CounterVariableCondition.getFromXML(a_xml));
case "booleanVariable":
return (BooleanVariableCondition.getFromXML(a_xml));
case "timePassed":
return (TimePassedCondition.getFromXML(a_xml));
case "endGame":
return (EndGameCondition.getFromXML(a_xml));
case "moveUnit":
return (MoveUnitCondition.getFromXML(a_xml));
case "killUnit":
return (KillUnitCondition.getFromXML(a_xml));
case "resourcesAcquired":
return (ResourcesAcquiredCondition.getFromXML(a_xml));
case "buildUnit":
return (BuildUnitCondition.getFromXML(a_xml));
case "captureTerrain":
return (CaptureTerrainCondition.getFromXML(a_xml));
case "noUnits":
return (NoUnitsCondition.getFromXML(a_xml));
};
return (new LogicalAndCondition());
}
}
}//package com.gamedozer.battalion.game
Section 129
//Controller (com.gamedozer.battalion.game.Controller)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.data.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.game.actions.*;
public class Controller {
protected var cloakVisibility:Number;
protected var resources:int;
protected var difficulty:int;
protected var enabled:Boolean;
protected var disabledUnits:Dictionary;
protected var team:Team;
protected var structures:Array;
protected var units:Array;
public static const EASY:int = 2;
public static const MEDIUM:int = 1;
public static const HARD:int = 0;
public function Controller(a_team:Team){
super();
team = a_team;
units = new Array();
structures = new Array();
TriggerManager.getInstance().addListener(Trigger.ERROR, errorListener);
TriggerManager.getInstance().addListener(Trigger.START_GAME, startGameListener);
TriggerManager.getInstance().addListener(Trigger.START_ROUND, startRoundListener);
TriggerManager.getInstance().addListener(PlayerTrigger.START_TURN, startTurnListener);
TriggerManager.getInstance().addListener(PlayerTrigger.END_GAME, endGameListener);
TriggerManager.getInstance().addListener(MoveUnitTrigger.TRIGGER, moveUnitListener);
TriggerManager.getInstance().addListener(AttackUnitTrigger.TRIGGER, attackUnitListener);
TriggerManager.getInstance().addListener(KillUnitTrigger.TRIGGER, killUnitListener);
TriggerManager.getInstance().addListener(BuildUnitTrigger.TRIGGER, buildUnitListener);
TriggerManager.getInstance().addListener(CaptureTerrainTrigger.TRIGGER, captureTerrainListener);
TriggerManager.getInstance().addListener(UpgradeUnitTrigger.TRIGGER, upgradeUnitListener);
resources = 0;
cloakVisibility = 0;
enabled = true;
difficulty = a_team.getDifficulty();
disabledUnits = new Dictionary();
}
public function getAirCost():Number{
var newValue:Number;
var airCost:Number = 1;
var hasAtLeastOne:Boolean;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("airCost", null, airCost);
if ((((newValue < airCost)) && (!(hasAtLeastOne)))){
hasAtLeastOne = true;
} else {
airCost = newValue;
};
i++;
};
return (airCost);
}
private function repairUnitListener(a_trigger:RepairUnitTrigger):void{
repairUnit(a_trigger.getUnit());
}
public function getSeaCost():Number{
var newValue:Number;
var seaCost:Number = 1;
var hasAtLeastOne:Boolean;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("seaCost", null, seaCost);
if ((((newValue < seaCost)) && (!(hasAtLeastOne)))){
hasAtLeastOne = true;
} else {
seaCost = newValue;
};
i++;
};
return (seaCost);
}
protected function error():void{
}
public function isStillInitializing():Boolean{
return (false);
}
public function disableUnit(a_unit:String):void{
disabledUnits[a_unit] = true;
}
protected function startTurn(a_player:int):void{
}
protected function captureTerrain(a_tile:Tile, a_oldPlayer:int, a_player:int, a_complete:Boolean):void{
if (a_complete){
};
}
public function initialize():void{
}
protected function killUnit(a_unitX:int, a_unitY:int, a_unit:Unit):void{
}
protected function buildUnit(a_unit:Unit):void{
}
public function addResources(a_resources:int):void{
resources = (resources + a_resources);
}
private function upgradeUnitListener(a_trigger:UpgradeUnitTrigger):void{
changeUpgradeStatus(a_trigger.getUnit(), a_trigger.getName(), a_trigger.getUpgrade());
}
public function isUnitEnabled(a_unit:String):Boolean{
return (!((disabledUnits[a_unit] == true)));
}
public function dispose():void{
team = null;
units = null;
structures = null;
TriggerManager.getInstance().removeListener(Trigger.ERROR, errorListener);
TriggerManager.getInstance().removeListener(Trigger.START_GAME, startGameListener);
TriggerManager.getInstance().removeListener(Trigger.START_ROUND, startRoundListener);
TriggerManager.getInstance().removeListener(PlayerTrigger.START_TURN, startTurnListener);
TriggerManager.getInstance().removeListener(MoveUnitTrigger.TRIGGER, moveUnitListener);
TriggerManager.getInstance().removeListener(AttackUnitTrigger.TRIGGER, attackUnitListener);
TriggerManager.getInstance().removeListener(KillUnitTrigger.TRIGGER, killUnitListener);
TriggerManager.getInstance().removeListener(CaptureTerrainTrigger.TRIGGER, captureTerrainListener);
}
private function startRoundListener(a_trigger:Trigger):void{
startRound();
}
public function enableUnit(a_unit:String):void{
delete disabledUnits[a_unit];
}
public function removeUnit(a_unit:Unit):void{
var i:int = (units.length - 1);
while (i >= 0) {
if (a_unit == units[i]){
units.splice(i, 1);
};
i--;
};
}
public function setCamera():void{
}
public function getDifficulty():int{
return (difficulty);
}
public function controlsAir():Boolean{
var newValue:Number;
var airCost:Number = 1;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("airCost", null, airCost);
if (newValue < airCost){
return (true);
};
i++;
};
return (false);
}
public function getDifficultyResourcesScale():Number{
if (difficulty == EASY){
return (1.25);
};
if (difficulty == HARD){
return (0.75);
};
return (1);
}
public function isEnabled():Boolean{
return (enabled);
}
protected function repairUnit(a_unit:Unit):void{
}
public function controlsSea():Boolean{
var newValue:Number;
var seaCost:Number = 1;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("seaCost", null, seaCost);
if (newValue < seaCost){
return (true);
};
i++;
};
return (false);
}
public function setDifficulty(a_difficulty:int):void{
difficulty = a_difficulty;
}
public function addUnit(a_unit:Unit):void{
a_unit.setController(this);
units.push(a_unit);
}
private function attackUnitListener(a_trigger:AttackUnitTrigger):void{
attackUnit(a_trigger.getUnitX(), a_trigger.getUnitY(), a_trigger.getTargetX(), a_trigger.getTargetY(), a_trigger.getUnit(), a_trigger.getTarget());
}
public function getUnits():Array{
return (units);
}
public function update(a_ms:uint=0):void{
}
public function getCloakVisibility():Number{
return (cloakVisibility);
}
public function removeStructure(a_tile:Tile):void{
var i:int = (structures.length - 1);
while (i >= 0) {
if (a_tile == structures[i]){
structures.splice(i, 1);
};
i--;
};
}
public function canAfford(a_unitType:String):Boolean{
var cost:int = UnitManager.getInstance().get(a_unitType).getCost(this);
if (cost <= resources){
return (true);
};
return (false);
}
public function isAllied(a_controller:Controller):Boolean{
if (a_controller == this){
return (true);
};
if (a_controller == null){
return (false);
};
return (team.isAllied(GameManager.getInstance().getPlayer(a_controller)));
}
public function addStructure(a_tile:Tile):void{
a_tile.setController(this);
structures.push(a_tile);
}
protected function startCurrentTurn():void{
ActionManager.getInstance().add(new EndTurnAction());
}
public function getStructures():Array{
return (structures);
}
private function startGameListener(a_trigger:Trigger):void{
startGame();
}
private function moveUnitListener(a_trigger:MoveUnitTrigger):void{
moveUnit(a_trigger.getUnit(), a_trigger.getPath());
}
private function endGameListener(a_trigger:PlayerTrigger):void{
endGame();
}
public function getTeam():Team{
return (team);
}
protected function startRound():void{
}
private function errorListener(a_trigger:Trigger):void{
error();
}
public function controlsUnit(a_unit:Unit):Boolean{
if (a_unit.getController() == this){
return (true);
};
return (false);
}
public function showCloak():Boolean{
return (false);
}
private function captureTerrainListener(a_trigger:CaptureTerrainTrigger):void{
captureTerrain(a_trigger.getTile(), a_trigger.getOldPlayer(), a_trigger.getPlayer(), a_trigger.getComplete());
}
public function controlsGround():Boolean{
var newValue:Number;
var groundCost:Number = 1;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("groundCost", null, groundCost);
if (newValue < groundCost){
return (true);
};
i++;
};
return (false);
}
private function killUnitListener(a_trigger:KillUnitTrigger):void{
killUnit(a_trigger.getUnitX(), a_trigger.getUnitY(), a_trigger.getUnit());
}
private function buildUnitListener(a_trigger:BuildUnitTrigger):void{
buildUnit(a_trigger.getUnit());
}
public function spendResources(a_resources:int):void{
resources = (resources - a_resources);
}
public function getGroundCost():Number{
var newValue:Number;
var groundCost:Number = 1;
var hasAtLeastOne:Boolean;
var i:int;
while (i < structures.length) {
newValue = structures[i].getTerrain().applyModifiers("groundCost", null, groundCost);
if ((((newValue < groundCost)) && (!(hasAtLeastOne)))){
hasAtLeastOne = true;
} else {
groundCost = newValue;
};
i++;
};
return (groundCost);
}
private function startTurnListener(a_trigger:PlayerTrigger):void{
startTurn(a_trigger.getPlayer());
if (GameManager.getInstance().getController(a_trigger.getPlayer()) == this){
startCurrentTurn();
};
}
public function controlsStructure(a_tile:Tile):Boolean{
if (a_tile.getController() == this){
return (true);
};
return (false);
}
protected function changeUpgradeStatus(a_unit:Unit, a_name:String, a_upgraded:Boolean):void{
}
public function getDifficultyAttackScale():Number{
if (difficulty == EASY){
return (1.25);
};
if (difficulty == HARD){
return (0.75);
};
return (1);
}
public function getDisabled():Dictionary{
return (disabledUnits);
}
protected function attackUnit(a_unitX:int, a_unitY:int, a_targetX:int, a_targetY:int, a_unit:Unit, a_target:Unit):void{
}
protected function startGame():void{
}
protected function moveUnit(a_unit:Unit, a_path:Array):void{
}
public function getResources():int{
return (resources);
}
protected function endGame():void{
}
public function setEnabled(a_enabled:Boolean):void{
enabled = a_enabled;
}
}
}//package com.gamedozer.battalion.game
Section 130
//GameCamera (com.gamedozer.battalion.game.GameCamera)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.*;
import flash.ui.*;
public class GameCamera {
protected var enabled:Boolean;
protected var tx:int;
protected var ty:int;
protected var time:uint;
protected var target:GameSprite;
protected var targetWaitTime:uint;
protected var force:Boolean;
protected var cx:int;
protected var cy:int;
protected var x:int;
protected var y:int;
protected var defCursor:Boolean;
protected var targetTime:uint;
protected static const SCROLL_SPEED:int = 25;
protected static const SCROLL_DISTANCE:int = 84;
protected static const WAIT_TIME:uint = 2000;
protected static const TARGET_WAIT_TIME:uint = 1500;
protected static const BUFFER_TIME:uint = 200;
public function GameCamera(){
super();
x = (y = (cx = (cy = (tx = (ty = 0)))));
time = 0;
enabled = false;
defCursor = false;
force = false;
}
public function setTarget(a_gameSprite:GameSprite=null, a_timer:uint=1500, a_force:Boolean=false):void{
target = a_gameSprite;
force = a_force;
if (target != null){
tx = (-(target.x) + (GameManager.GAME_WIDTH / 2));
ty = (-(target.y) + (GameManager.GAME_HEIGHT / 2));
time = WAIT_TIME;
};
targetTime = 0;
targetWaitTime = a_timer;
}
public function getY():int{
return (y);
}
public function setLocation(a_x:int, a_y:int):void{
cx = a_x;
cy = a_y;
time = 0;
target = null;
}
public function update(a_ms:uint=0):void{
var dx:int;
var dy:int;
var mx:int;
var my:int;
var button:TileSheetButton;
var avail:Boolean;
var miniMap:MiniMap;
var speed:Number;
var c:String;
var gameManager:GameManager = GameManager.getInstance();
var gss:GameSpriteScroller = gameManager.getGameSpriteScroller();
var width:int = (gameManager.getMap().getWidth() * TileManager.getInstance().getWidth());
var height:int = (gameManager.getMap().getHeight() * TileManager.getInstance().getHeight());
time = (time + a_ms);
targetTime = (targetTime + a_ms);
if (targetTime < targetWaitTime){
if (target != null){
tx = (-(target.x) + (GameManager.GAME_WIDTH / 2));
ty = (-(target.y) + (GameManager.GAME_HEIGHT / 2));
};
} else {
target = null;
};
if (((enabled) && (!(force)))){
if (KeyboardHandler.getInstance().isDown(Keyboard.UP)){
cy = (cy + SCROLL_SPEED);
time = 0;
};
if (KeyboardHandler.getInstance().isDown(Keyboard.DOWN)){
cy = (cy - SCROLL_SPEED);
time = 0;
};
if (KeyboardHandler.getInstance().isDown(Keyboard.LEFT)){
cx = (cx + SCROLL_SPEED);
time = 0;
};
if (KeyboardHandler.getInstance().isDown(Keyboard.RIGHT)){
cx = (cx - SCROLL_SPEED);
time = 0;
};
if (MouseHandler.getInstance().isEnabled()){
mx = MouseHandler.getInstance().getX();
my = MouseHandler.getInstance().getY();
button = GameManager.getInstance().getEndTurnButton();
avail = true;
if (mx > button.x){
if (mx < (button.x + button.width)){
if (my > button.y){
if (my < (button.y + button.height)){
avail = false;
};
};
};
};
button = GameManager.getInstance().getNextUnitButton();
if (mx > button.x){
if (mx < (button.x + button.width)){
if (my > button.y){
if (my < (button.y + button.height)){
avail = false;
};
};
};
};
miniMap = GameManager.getInstance().getMiniMap();
if (mx > miniMap.x){
if (mx < (miniMap.x + miniMap.width)){
if (my > miniMap.y){
if (my < ((miniMap.y + miniMap.height) - 100)){
avail = false;
};
};
};
};
if (GameManager.getInstance().isMousingOverInfo()){
return;
};
if (avail){
if ((((mx >= 0)) && ((mx < SCROLL_DISTANCE)))){
if ((((my >= 0)) && ((my < BattalionMain.HEIGHT)))){
speed = ((1 - (mx / SCROLL_DISTANCE)) * SCROLL_SPEED);
cx = (cx + speed);
time = 0;
};
};
if ((((mx > (BattalionMain.WIDTH - SCROLL_DISTANCE))) && ((mx < BattalionMain.WIDTH)))){
if ((((my >= 0)) && ((my < BattalionMain.HEIGHT)))){
speed = ((((mx - BattalionMain.WIDTH) + SCROLL_DISTANCE) / SCROLL_DISTANCE) * SCROLL_SPEED);
cx = (cx - speed);
time = 0;
};
};
if ((((my >= 0)) && ((my < SCROLL_DISTANCE)))){
if ((((mx >= 0)) && ((mx < BattalionMain.WIDTH)))){
speed = ((1 - (my / SCROLL_DISTANCE)) * SCROLL_SPEED);
cy = (cy + speed);
time = 0;
};
};
if ((((my > (BattalionMain.HEIGHT - SCROLL_DISTANCE))) && ((my < BattalionMain.HEIGHT)))){
if ((((mx >= 0)) && ((mx < BattalionMain.WIDTH)))){
speed = ((((my - BattalionMain.HEIGHT) + SCROLL_DISTANCE) / SCROLL_DISTANCE) * SCROLL_SPEED);
cy = (cy - speed);
time = 0;
};
};
};
};
} else {
time = (WAIT_TIME + 1);
};
lock(width, height);
var scrolled:Boolean;
if ((((time > WAIT_TIME)) && (!((target == null))))){
dx = (cx = tx);
dy = (cy = ty);
} else {
dx = cx;
dy = cy;
scrolled = true;
force = false;
};
var ax:Number = x;
var ay:Number = y;
x = (x + ((dx - x) / 2));
y = (y + ((dy - y) / 2));
GameManager.getInstance().getMiniMap().setDrag(-(x), -(y));
gss.x = x;
gss.y = y;
gss.lock(width, height);
gss.scroll();
ax = (x - ax);
ay = (y - ay);
if (scrolled){
c = "";
if (ax < 0){
c = (c + "right");
};
if (ax > 0){
c = (c + "left");
};
if (ay < 0){
c = (c + "down");
};
if (ay > 0){
c = (c + "up");
};
if (c != ""){
BattalionMain.getMouseCursor().setCursor(c);
defCursor = true;
} else {
if (defCursor){
BattalionMain.getMouseCursor().setCursor("default");
defCursor = false;
};
};
};
}
public function move(a_x:int=0, a_y:int=0):void{
cx = (cx + a_x);
cy = (cy + a_y);
time = 0;
}
public function getX():int{
return (x);
}
public function isEnabled():Boolean{
return (enabled);
}
public function lock(width:int, height:int):void{
if (tx < (-(width) + GameManager.GAME_WIDTH)){
tx = (-(width) + GameManager.GAME_WIDTH);
};
if (ty < (-(height) + GameManager.GAME_HEIGHT)){
ty = (-(height) + GameManager.GAME_HEIGHT);
};
if (tx > 0){
tx = 0;
};
if (ty > 0){
ty = 0;
};
if (cx < (-(width) + GameManager.GAME_WIDTH)){
cx = (-(width) + GameManager.GAME_WIDTH);
};
if (cy < (-(height) + GameManager.GAME_HEIGHT)){
cy = (-(height) + GameManager.GAME_HEIGHT);
};
if (cx > 0){
cx = 0;
};
if (cy > 0){
cy = 0;
};
}
public function setEnabled(a_enabled:Boolean):void{
enabled = a_enabled;
}
}
}//package com.gamedozer.battalion.game
Section 131
//GameEvent (com.gamedozer.battalion.game.GameEvent)
package com.gamedozer.battalion.game {
public class GameEvent {
protected var fired:Boolean;
protected var responses:Array;
protected var conditions:LogicalAndCondition;
protected var repeats:int;
public static const REPEAT_FOREVER:int = -1;
public static const REPEAT_ONCE:int = 1;
public function GameEvent(a_repeats:int=1){
super();
repeats = a_repeats;
conditions = new LogicalAndCondition();
responses = new Array();
fired = false;
}
public function isCompleted():Boolean{
return ((repeats == 0));
}
public function toXML():XML{
var ret = (("<event repeats=\"" + ((repeats == GameEvent.REPEAT_FOREVER)) ? "infinity" : repeats) + "\">");
var conditions:Array = conditions.getConditions();
var i:int;
while (i < conditions.length) {
ret = (ret + conditions[i].toXML());
i++;
};
i = 0;
while (i < responses.length) {
ret = (ret + responses[i].toXML());
i++;
};
ret = (ret + "</event>");
return (new XML(ret));
}
public function dispose():void{
conditions.dispose();
var i:int;
while (i < responses.length) {
responses[i].dispose();
i++;
};
}
public function isSatisfied():Boolean{
return (conditions.isSatisfied());
}
public function addResponse(a_response:Response):void{
responses.push(a_response);
}
public function isFired():Boolean{
return (fired);
}
public function toString():String{
var message:String = "";
var conditions:Array = conditions.getConditions();
var i:int;
while (i < conditions.length) {
message = (message + ("c: " + conditions[i].toXML()));
i++;
};
i = 0;
while (i < responses.length) {
message = (message + ("r: " + responses[i].toXML()));
i++;
};
return (message);
}
public function update():void{
var i:int;
var response:Boolean;
if (!isFired()){
conditions.update();
if (isSatisfied()){
fired = true;
i = 0;
while (i < responses.length) {
ResponseManager.getInstance().add(responses[i], this);
i++;
};
};
} else {
response = true;
i = 0;
while (i < responses.length) {
if (!responses[i].isCompleted()){
response = false;
break;
};
i++;
};
if (response){
reset();
};
};
}
public function setRepeats(a_repeats:int):void{
repeats = a_repeats;
}
public function addCondition(a_condition:Condition):void{
conditions.add(a_condition);
}
public function reset():void{
fired = false;
repeats--;
if (repeats == 0){
return;
};
conditions.reset();
var i:int;
while (i < responses.length) {
responses[i].reset();
i++;
};
}
public static function getFromXML(a_xml:XML):GameEvent{
var repeats:String = a_xml.@repeats;
if (repeats == ""){
repeats = ("" + GameEvent.REPEAT_ONCE);
};
if (repeats.toLowerCase().charAt(0) == "i"){
repeats = ("" + GameEvent.REPEAT_FOREVER);
};
var e:GameEvent = new GameEvent(int(repeats));
var conditions:XMLList = a_xml.child("condition");
var j:int;
while (j < conditions.length()) {
e.addCondition(ConditionFactory.get(conditions[j]));
j++;
};
var responses:XMLList = a_xml.child("response");
j = 0;
while (j < responses.length()) {
e.addResponse(ResponseFactory.get(responses[j]));
j++;
};
return (e);
}
}
}//package com.gamedozer.battalion.game
Section 132
//GameEventManager (com.gamedozer.battalion.game.GameEventManager)
package com.gamedozer.battalion.game {
public class GameEventManager {
protected var gameEvents:Array;
private static var singleton:GameEventManager;
public function GameEventManager(){
super();
singleton = this;
gameEvents = new Array();
}
public function add(a_gameEvent:GameEvent):void{
gameEvents.push(a_gameEvent);
}
public function isEmpty():Boolean{
var i:int = (gameEvents.length - 1);
while (i >= 0) {
if (gameEvents[i].isFired()){
return (false);
};
i--;
};
return (true);
}
public function update():void{
var i:int = (gameEvents.length - 1);
while (i >= 0) {
gameEvents[i].update();
if (gameEvents[i].isCompleted()){
gameEvents[i].dispose();
gameEvents.splice(i, 1);
};
i--;
};
}
public function toXML():String{
var ret:String = new String();
var i:int;
while (i < gameEvents.length) {
ret = (ret + gameEvents[i].toXML());
i++;
};
return (ret);
}
public static function getInstance():GameEventManager{
if (singleton == null){
throw (new Error("GameEventManager::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.game
Section 133
//GameManager (com.gamedozer.battalion.game.GameManager)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import flash.text.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.display.tween.*;
import com.robertpenner.easing.*;
import com.gamedozer.battalion.game.responses.*;
import com.gamedozer.battalion.game.actions.*;
import com.gamedozer.battalion.game.conditions.*;
import flash.ui.*;
public class GameManager {
protected var camera:GameCamera;
protected var nextUnitButton:TileSheetButton;
protected var infoMenu:InfoMenu;
protected var endTurnButton:TileSheetButton;
protected var controllers:Array;
protected var structures:Array;
protected var units:Array;
protected var turn:int;
protected var miniMap:MiniMap;
protected var round:int;
protected var mapSettings:MapSettings;
protected var playerPanel:AllPlayerPanel;
protected var parent:GameMenu;
protected var mDown:Boolean;
protected var gameSpriteScroller:GameSpriteScroller;
protected var m_loadingPanel:LoadingPanel;
protected var sprite:Sprite;
protected var tileMap:Array;
protected var ballisticsTable:Array;
protected var movementCombiner:MovementCombiner;
protected var currentController:int;
protected var m_wasLoadedFromSavedGame:Boolean;// = false
public static const GAME_WIDTH:int = 560;
public static const UNIT_CHUNKS:int = 4;
public static const GAME_HEIGHT:int = 560;
public static const TILE_CHUNKS:int = 8;
private static var singleton:GameManager;
public function GameManager(a_parent:GameMenu, a_mapSettings:MapSettings, a_script:XML=null){
var x:int;
var c:Controller;
var structuresAdd:Array;
var unitsAdd:Array;
var tile:Tile;
var unit:Unit;
var e:GameEvent;
var co:LogicalOrCondition;
super();
singleton = this;
parent = a_parent;
sprite = new Sprite();
new TriggerManager();
new ActionManager();
new GameEventManager();
new ResponseManager();
mapSettings = a_mapSettings;
var map:Map = mapSettings.getMap();
tileMap = map.generateTileMap();
gameSpriteScroller = new GameSpriteScroller(GAME_WIDTH, GAME_HEIGHT);
sprite.addChild(gameSpriteScroller);
var y:int;
while (y < map.getHeight()) {
x = 0;
while (x < map.getWidth()) {
gameSpriteScroller.add(tileMap[y][x].getGameTile(), GameSpriteScroller.TILES);
x++;
};
y++;
};
gameSpriteScroller.scroll();
miniMap = new MiniMap(map.generateMiniMap());
controllers = new Array();
units = new Array();
structures = new Array();
var teams:Array = mapSettings.getTeams();
var i:int;
while (i < teams.length) {
c = teams[i].createController();
c.addResources(mapSettings.getResources());
controllers.push(c);
i++;
};
playerPanel = new AllPlayerPanel(teams);
infoMenu = new InfoMenu();
infoMenu.x = (BattalionMain.WIDTH - InfoMenu.WIDTH);
infoMenu.y = ((playerPanel.y + AllPlayerPanel.HEIGHT) + 4);
endTurnButton = new TileSheetButton("endTurnButton");
endTurnButton.x = ((BattalionMain.WIDTH - endTurnButton.width) + 3);
endTurnButton.y = ((BattalionMain.HEIGHT - endTurnButton.height) + 3);
nextUnitButton = new TileSheetButton("nextUnitButton");
nextUnitButton.x = ((GAME_WIDTH - nextUnitButton.width) - 3);
nextUnitButton.y = (BattalionMain.HEIGHT - nextUnitButton.height);
if (a_script == null){
structuresAdd = map.generateStructures(tileMap, controllers);
i = 0;
while (i < structuresAdd.length) {
tile = structuresAdd[i];
addStructure(tile.getController(), tile);
i++;
};
unitsAdd = map.generateUnits(controllers);
i = 0;
while (i < unitsAdd.length) {
unit = unitsAdd[i];
unit.setDeployed(true);
if (unit.getUnitData().hasModifier("Cloaking")){
unit.setCloaked(true, false, false);
};
addUnit(unit.getController(), unit);
tileMap[unit.getY()][unit.getX()].setUnit(unit);
gameSpriteScroller.add(unit.getGameUnit(), GameSpriteScroller.UNITS);
i++;
};
ScriptManager.parseScript(map.getScript());
i = 0;
while (i < controllers.length) {
e = new GameEvent(GameEvent.REPEAT_FOREVER);
co = new LogicalOrCondition();
co.add(new CaptureTerrainCondition("Command Center", i));
co.add(new NoUnitsCondition(i));
e.addCondition(co);
e.addResponse(new SendActionResponse(new SurrenderAction(i)));
GameEventManager.getInstance().add(e);
i++;
};
} else {
trace("");
trace("");
trace("");
trace("");
trace(getTimer());
trace(a_script);
ScriptManager.parseScript(a_script);
m_wasLoadedFromSavedGame = true;
};
resetBallisticsTable();
camera = new GameCamera();
movementCombiner = new MovementCombiner();
m_loadingPanel = new LoadingPanel();
parent.stage.addChild(m_loadingPanel);
i = 0;
while (i < controllers.length) {
if (controllers[i] != null){
controllers[i].initialize();
};
i++;
};
}
public function isStillInitializing():Boolean{
var controller:Controller;
var c:int;
while (c < controllers.length) {
controller = controllers[c];
if (controller.isStillInitializing()){
return (true);
};
c++;
};
return (false);
}
public function getCamera():GameCamera{
return (camera);
}
public function updateUI(a_ms:uint):void{
var tile:Tile;
playerPanel.setResources(controllers);
playerPanel.setActive(currentController);
miniMap.setString(("Round " + (round + 1)));
infoMenu.update();
var mmx:int = MouseHandler.getInstance().getX();
var mmy:int = MouseHandler.getInstance().getY();
var mx:int = ((mmx - GameManager.getInstance().getSprite().x) - GameManager.getInstance().getGameSpriteScroller().x);
var my:int = ((mmy - GameManager.getInstance().getSprite().y) - GameManager.getInstance().getGameSpriteScroller().y);
var mtx:int = Math.floor((mx / TileManager.getInstance().getWidth()));
var mty:int = Math.floor((my / TileManager.getInstance().getHeight()));
if ((((((((mmx > 0)) && ((mmy > 0)))) && ((mmx < GAME_WIDTH)))) && ((mmy < GAME_HEIGHT)))){
if (MouseHandler.getInstance().isDown()){
if ((ResponseManager.getInstance().peek() is ChatResponse)){
if (mmy > 405){
mDown = false;
return;
};
};
if (!mDown){
tile = tileAt(mtx, mty);
if (tile != null){
if (tile.getUnit() != null){
if (infoMenu.getActive() == tile.getUnit()){
infoMenu.setTile(tile, false, true);
} else {
infoMenu.setTile(tile);
};
} else {
infoMenu.setTile(tile);
};
};
};
mDown = true;
} else {
mDown = false;
};
};
}
public function getNextUnitButton():TileSheetButton{
return (nextUnitButton);
}
public function getControllers():Array{
return (controllers);
}
public function getMap():Map{
return (mapSettings.getMap());
}
public function removeUnit(a_unit:Unit):void{
a_unit.getController().removeUnit(a_unit);
if (a_unit.isDeployed()){
tileMap[a_unit.getY()][a_unit.getX()].setUnit(null);
};
a_unit.setDeployed(false);
gameSpriteScroller.remove(a_unit.getGameUnit());
miniMap.getMap().removeChild(a_unit.getMiniMapSprite());
var i:int = (units.length - 1);
while (i >= 0) {
if (a_unit == units[i]){
units.splice(i, 1);
};
i--;
};
if (((a_unit.getController().getTeam().getActive()) && ((a_unit.getController().getUnits().length < 1)))){
TriggerManager.getInstance().add(new PlayerTrigger(PlayerTrigger.NO_UNITS, getPlayer(a_unit.getController())));
};
}
public function dispose():void{
SoundSystem.instance.destroyLoop("background");
var i:int;
while (i < controllers.length) {
if (controllers[i] != null){
controllers[i].dispose();
};
i++;
};
controllers = null;
miniMap = null;
playerPanel = null;
mapSettings = null;
tileMap = null;
units = null;
structures = null;
gameSpriteScroller = null;
ballisticsTable = null;
parent.removeChild(sprite);
TweenManager.getInstance().clear();
singleton = null;
BattalionMain.getMouseCursor().setCursor("default");
camera = null;
}
public function getNodesInAttackRange(a_x:int, a_y:int, a_unit:Unit):Array{
var minRange:int;
var maxRange:int;
var x:int = a_x;
var y:int = a_y;
var tile:Tile = tileAt(x, y);
if (a_unit.isRanged()){
minRange = a_unit.getBaseUnitData().getWeaponRangeMin();
maxRange = a_unit.getBaseUnitData().getWeaponRangeMax();
maxRange = tile.getTerrain().applyModifiers("attackRange", a_unit, maxRange);
return (Astar.range(tileMap[y][x], minRange, maxRange));
};
return (Astar.search(tile, null, a_unit, 0, true));
}
public function canAttack(a_unit:Unit, a_targetUnit:Unit, a_ignoreChecks:Boolean=false, a_x:int=-1, a_y:int=-1, a_unitCanMove:Boolean=false):Boolean{
var units:Array;
if (!canWeaponsFireAtTarget(a_unit, a_targetUnit, true)){
return (false);
};
if (!a_unit.isAlive()){
return (false);
};
if (!a_unit.isDeployed()){
return (false);
};
if (!a_ignoreChecks){
if (a_unit.hasFired()){
return (false);
};
if (((a_unit.isRanged()) && (a_unit.hasMoved()))){
return (false);
};
};
if (a_unit.getController() == a_targetUnit.getController()){
return (false);
};
if (a_unitCanMove){
units = unitsInMoveRange(a_unit, true, a_x, a_y);
} else {
units = unitsInRange(a_unit, true, a_x, a_y);
};
var i:int;
while (i < units.length) {
if (units[i] == a_targetUnit){
return (true);
};
i++;
};
return (false);
}
public function resolveAttackCycleInResources(a_unit:Unit, a_targetUnit:Unit):Number{
var damage:Number;
var returnUnit:Unit;
var returnFire:Boolean;
var resources:Number = 0;
if (canWeaponsFireAtTarget(a_unit, a_targetUnit)){
damage = resolveAttack(a_unit, a_targetUnit, null, null, true, false);
resources = (resources + ((damage / a_targetUnit.getUnitData().getHealth()) * a_targetUnit.getUnitData().getCost()));
if ((a_targetUnit.getHealth() - damage) > 0){
returnUnit = a_targetUnit.clone();
returnUnit.takeDamage(damage);
returnFire = true;
if (returnUnit.isRanged()){
if (!returnUnit.getUnitData().hasModifier("Counter-Battery")){
returnFire = false;
};
} else {
if (a_unit.isRanged()){
returnFire = false;
};
};
if (returnFire){
resources = (resources - resolveAttackInResources(returnUnit, a_unit, false));
};
};
};
return (resources);
}
public function getCurrentController():int{
return (currentController);
}
public function moveCost(a_unit:Unit, a_path:Array):Number{
var check:Tile;
if (!canMove(a_unit, a_path, true)){
return (Number.POSITIVE_INFINITY);
};
var current:Tile = a_path[0];
var cost:Number = 0;
var i = 1;
while (i < a_path.length) {
check = a_path[i];
cost = (cost + check.getCost(a_unit));
current = check;
i++;
};
return (cost);
}
public function nodePath(a_path:Array):Array{
var retPath:Array = new Array();
var i:int;
while (i < a_path.length) {
retPath.push(tileAt(a_path[i], a_path[(i + 1)]));
i = (i + 2);
};
return (retPath);
}
public function setRound(a_round:int):void{
round = a_round;
}
public function getMiniMap():MiniMap{
return (miniMap);
}
public function removeStructure(a_tile:Tile):void{
if (a_tile.getController() != null){
a_tile.getController().removeStructure(a_tile);
};
a_tile.downgrade();
var i:int = (structures.length - 1);
while (i >= 0) {
if (a_tile == structures[i]){
structures.splice(i, 1);
};
i--;
};
}
public function getMovementCombiner():MovementCombiner{
return (movementCombiner);
}
public function resolveAttack(a_unit:Unit, a_targetUnit:Unit, a_tile:Tile=null, a_attackTile:Tile=null, a_attack:Boolean=true, a_tiles:Boolean=true):Number{
if (a_tiles){
if (a_tile == null){
a_tile = tileAt(a_targetUnit.getX(), a_targetUnit.getY());
};
if (a_attackTile == null){
a_attackTile = tileAt(a_unit.getX(), a_unit.getY());
};
};
var damage:Number = a_unit.getUnitData().applyModifiers("damage", a_targetUnit, a_unit.getUnitData().getDamage());
if (a_tiles){
if (a_attackTile.isStructure()){
damage = a_unit.getUnitData().applyModifiers("structureBonus", a_targetUnit, damage);
};
};
if (a_attack){
damage = a_unit.getUnitData().applyModifiers("attackBonus", a_targetUnit, damage);
} else {
damage = a_unit.getUnitData().applyModifiers("returnAttackBonus", a_targetUnit, damage);
};
var scale:Number = (a_unit.getChunks(UNIT_CHUNKS) / UNIT_CHUNKS);
var damageScale:Number = ballisticsTable[a_unit.getUnitData().getWeaponType()][a_targetUnit.getUnitData().getArmorType()];
var defenseScale:Number = 1;
if (a_tiles){
defenseScale = a_tile.getTerrain().applyModifiers("defense", a_targetUnit, defenseScale);
if (a_unit.isRanged()){
defenseScale = a_tile.getTerrain().applyModifiers("rangedDefense", a_targetUnit, defenseScale);
};
};
return (((((damage * damageScale) * scale) * defenseScale) * a_unit.getController().getDifficultyAttackScale()));
}
public function controlsStructure(a_controller:Controller, a_tile:Tile):Boolean{
if (a_tile.getController() == a_controller){
return (true);
};
return (false);
}
public function unitsInMoveRange(a_unit:Unit, a_trimSameTeam:Boolean=false, a_x:int=-1, a_y:int=-1):Array{
var linked:Boolean;
var connections:Array;
var j:int;
if (a_x == -1){
a_x = a_unit.getX();
};
if (a_y == -1){
a_y = a_unit.getY();
};
if (a_unit.isRanged()){
return (unitsInRange(a_unit, a_trimSameTeam, a_x, a_y));
};
var tile:Tile = tileAt(a_x, a_y);
var nodes:Array = Astar.search(tile, null, a_unit, 0, true);
var units:Array = new Array();
var i:int;
while (i < nodes.length) {
linked = false;
if (nodes[i].getUnit() != null){
connections = nodes[i].getConnections();
j = 0;
while (j < connections.length) {
if (nodes.indexOf(connections[j]) != -1){
if ((((connections[j].getUnit() == null)) || ((connections[j].getUnit() == a_unit)))){
linked = true;
break;
};
};
j++;
};
if (linked){
if (a_trimSameTeam){
if (nodes[i].getUnit().getController() != a_unit.getController()){
units.push(nodes[i].getUnit());
};
} else {
units.push(nodes[i].getUnit());
};
};
};
i++;
};
return (units);
}
public function isMousingOverInfo():Boolean{
return (infoMenu.isMousingOverInfo());
}
public function getStructures():Array{
return (structures);
}
public function getMapSettings():MapSettings{
return (mapSettings);
}
public function getPlayerPanel():AllPlayerPanel{
return (playerPanel);
}
public function controlsUnit(a_controller:Controller, a_unit:Unit):Boolean{
if (a_unit.getController() == a_controller){
return (true);
};
return (false);
}
public function startGame():void{
ActionManager.getInstance().add(new StartGameAction());
ActionManager.getInstance().add(new StartRoundAction());
ActionManager.getInstance().add(new StartTurnAction());
}
public function importBallisticsTable(a_xml:XML):void{
var weaponIndex:int;
var defenseList:XMLList;
var j:int;
var armorIndex:int;
resetBallisticsTable();
if (a_xml == null){
return;
};
var attackList:XMLList = a_xml..attack;
var i:int;
while (i < attackList.length()) {
weaponIndex = UnitData.weaponTypeFromString(attackList[i].@type);
defenseList = attackList[i]..defense;
j = 0;
while (j < defenseList.length()) {
armorIndex = UnitData.armorTypeFromString(defenseList[j].@type);
ballisticsTable[weaponIndex][armorIndex] = Number(defenseList[j].@value);
j++;
};
i++;
};
}
public function endGame():void{
parent.endGame(true);
}
public function isOneActiveTeam():Boolean{
var k:int;
var actives:Array = new Array();
var i:int;
while (i < controllers.length) {
if (controllers[i].getTeam().getActive()){
actives.push(controllers[i].getTeam());
};
i++;
};
if (actives.length < 2){
return (true);
};
var j:int;
while (j < actives.length) {
k = j;
while (k < actives.length) {
if (!actives[j].isAllied(actives[k])){
return (false);
};
j++;
};
j++;
};
return (true);
}
public function tileAt(a_x:int, a_y:int):Tile{
if ((((((((a_x < 0)) || ((a_y < 0)))) || ((a_x > (mapSettings.getMap().getWidth() - 1))))) || ((a_y > (mapSettings.getMap().getHeight() - 1))))){
return (null);
};
return (tileMap[a_y][a_x]);
}
public function getBallisticsModifier(weaponType:int, armorType:int):Number{
return (ballisticsTable[weaponType][weaponType]);
}
public function canWeaponsFireAtTarget(a_unit:Unit, a_targetUnit:Unit, a_strict:Boolean=false):Boolean{
var tile:Tile;
if (a_strict){
if (a_unit.isRanged()){
tile = tileAt(a_unit.getX(), a_unit.getY());
if (tile.getTerrain().hasModifier("Canopy")){
return (false);
};
tile = tileAt(a_targetUnit.getX(), a_targetUnit.getY());
if (tile.getTerrain().hasModifier("Shielded")){
return (false);
};
};
};
if (a_targetUnit.isCloaked()){
return (false);
};
if (a_targetUnit.getUnitData().isAir()){
if (a_unit.getUnitData().hasModifier("Skysweeper")){
return (true);
};
return (false);
} else {
if (a_unit.getUnitData().hasModifier("Air Bound")){
return (false);
};
};
if (((!(a_targetUnit.getUnitData().isGround())) && (a_unit.getUnitData().hasModifier("Ground Bound")))){
return (false);
};
if (((!(a_targetUnit.getUnitData().isSea())) && (a_unit.getUnitData().hasModifier("Sea Bound")))){
return (false);
};
if (((a_targetUnit.getUnitData().hasModifier("Submerged")) && (!(a_unit.getUnitData().hasModifier("Anti-Sub"))))){
return (false);
};
return (true);
}
public function resolveAttackInResources(a_unit:Unit, a_targetUnit:Unit, a_attack:Boolean=true):Number{
var damage:Number;
var resources:Number = 0;
if (canWeaponsFireAtTarget(a_unit, a_targetUnit)){
damage = resolveAttack(a_unit, a_targetUnit, null, null, a_attack, false);
resources = ((damage / a_targetUnit.getUnitData().getHealth()) * a_targetUnit.getUnitData().getCost());
};
return (resources);
}
public function resetBallisticsTable():void{
var j:int;
ballisticsTable = new Array();
var i:int;
while (i < UnitData.weaponTypes.length) {
ballisticsTable[i] = new Array();
j = 0;
while (j < UnitData.armorTypes.length) {
ballisticsTable[i][j] = 0;
j++;
};
i++;
};
}
public function getController(a_controller:int):Controller{
return (controllers[a_controller]);
}
public function addExplosion(a_type:String, a_gameSprite:GameSprite=null, x:int=0, y:int=0):void{
var tileSheet:TileSheet = TileSheetManager.getInstance().get("Explosion");
if (a_gameSprite != null){
tileSheet.x = (a_gameSprite.x + ((a_gameSprite.width - tileSheet.width) / 2));
tileSheet.y = ((a_gameSprite.y - tileSheet.height) + a_gameSprite.height);
} else {
tileSheet.x = (x - (tileSheet.width / 2));
tileSheet.y = (y - tileSheet.height);
};
TweenManager.getInstance().add(new TweenDisplay(tileSheet, true, GameSpriteScroller.TOP, tileSheet), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenAnimation(tileSheet, "default", true, tileSheet), TweenManager.SEQUENTIAL);
TweenManager.getInstance().add(new TweenDisplay(tileSheet, false, GameSpriteScroller.TOP, tileSheet), TweenManager.SEQUENTIAL);
}
public function getTileMap():Array{
return (tileMap);
}
public function getEndTurnButton():TileSheetButton{
return (endTurnButton);
}
public function toXML():XML{
var dis:Dictionary;
var unitName:String;
var unit:Unit;
var tm:Array;
var j:int;
var tile:Tile;
var capturerx:int;
var capturery:int;
var gameState = (((((("<gamestate turn=\"" + turn) + "\" round=\"") + round) + "\" controller=\"") + currentController) + "\"/>");
var i:int;
while (i < controllers.length) {
if (controllers[i] != null){
gameState = (gameState + (((("<resources controller=\"" + i) + "\" value=\"") + controllers[i].getResources()) + "\"/>"));
dis = controllers[i].getDisabled();
for (unitName in dis) {
gameState = (gameState + (((("<disableUnit controller=\"" + i) + "\" unit=\"") + unitName) + "\"/>"));
};
};
i++;
};
i = 0;
while (i < units.length) {
unit = units[i];
gameState = (gameState + (((((((("<unit name=\"" + unit.getBaseUnitData().getName()) + "\" x=\"") + unit.getX()) + "\" y=\"") + unit.getY()) + "\" controller=\"") + getPlayer(unit.getController())) + "\">"));
gameState = (gameState + (((((((((("<status deployed=\"" + unit.isDeployed()) + "\" moved=\"") + unit.hasMoved()) + "\" fired=\"") + unit.hasFired()) + "\" cloaked=\"") + unit.isCloaked()) + "\" repairing=\"") + unit.isRepairing()) + "\" />"));
if (unit.isUpgraded()){
gameState = (gameState + (("<upgrade name=\"" + unit.getUnitData().getName()) + "\"/>"));
};
if (unit.getHealth() != unit.getUnitData().getHealth()){
gameState = (gameState + (("<health value=\"" + unit.getHealth()) + "\"/>"));
};
tm = unit.getUnitData().getTemporaryModifiers();
j = 0;
while (j < tm.length) {
gameState = (gameState + (("<modifier value=\"" + tm[j].getName()) + "\"/>"));
j++;
};
gameState = (gameState + "</unit>");
i++;
};
i = 0;
while (i < structures.length) {
tile = structures[i];
capturerx = -1;
capturery = -1;
if (tile.getCapturer() != null){
capturerx = tile.getCapturer().getX();
capturery = tile.getCapturer().getY();
};
gameState = (gameState + (((((((((((((("<structure name=\"" + tile.getTerrain().getName()) + "\" x=\"") + tile.getX()) + "\" y=\"") + tile.getY()) + "\" controller=\"") + getPlayer(tile.getController())) + "\" chunks=\"") + tile.getChunks()) + "\" capturerx=\"") + capturerx) + "\" capturery=\"") + capturery) + "\"/>"));
if (tile.getResources() > 0){
gameState = (gameState + (((((("<structureresources x=\"" + tile.getX()) + "\" y=\"") + tile.getY()) + "\" value=\"") + tile.getResources()) + "\"/>"));
};
i++;
};
return (new XML(((((((((("<game mapurl=\"" + mapSettings.getMap().getMapURL()) + "\" mapname=\"") + mapSettings.getMap().getMapName()) + "\">") + mapSettings.toXML()) + "<script>") + GameEventManager.getInstance().toXML()) + gameState) + "</script> </game>")));
}
public function getParent():GameMenu{
return (parent);
}
public function healPercentage(a_unit:Unit):Number{
var healPerc:Number = ((a_unit.getUnitData().getHealth() - a_unit.getHealth()) / a_unit.getUnitData().getHealth());
if (healPerc > 0.25){
healPerc = 0.25;
};
return (healPerc);
}
public function getGameSpriteScroller():GameSpriteScroller{
return (gameSpriteScroller);
}
public function unitsInRange(a_unit:Unit, a_trimSameTeam:Boolean=false, a_x:int=-1, a_y:int=-1, a_forceMinRange:int=-1, a_forceMaxRange:int=-1):Array{
var minRange:int;
var maxRange:int;
var tile:Tile;
if (a_x == -1){
a_x = a_unit.getX();
};
if (a_y == -1){
a_y = a_unit.getY();
};
var units:Array = new Array();
if (((!((a_forceMinRange == -1))) && (!((a_forceMaxRange == -1))))){
minRange = a_forceMinRange;
maxRange = a_forceMaxRange;
} else {
minRange = a_unit.getUnitData().getWeaponRangeMin();
maxRange = a_unit.getUnitData().getWeaponRangeMax();
if (a_unit.isRanged()){
tile = tileAt(a_unit.getX(), a_unit.getY());
maxRange = tile.getTerrain().applyModifiers("attackRange", a_unit, maxRange);
};
};
var nodes:Array = Astar.range(tileMap[a_y][a_x], minRange, maxRange);
var i:int;
while (i < nodes.length) {
if (nodes[i].getUnit() != null){
if (a_trimSameTeam){
if (nodes[i].getUnit().getController() != a_unit.getController()){
units.push(nodes[i].getUnit());
};
} else {
units.push(nodes[i].getUnit());
};
};
i++;
};
return (units);
}
public function getInfoMenu():InfoMenu{
return (infoMenu);
}
public function setCurrentController(a_currentController:int):void{
currentController = a_currentController;
}
public function getActiveController():Controller{
return (controllers[currentController]);
}
public function getUnits():Array{
return (units);
}
public function getSprite():Sprite{
return (sprite);
}
public function canMove(a_unit:Unit, a_path:Array, ignoreEnd:Boolean=false):Boolean{
var current:Tile;
var cost:Number;
var check:Tile;
var i:int;
if (!a_unit.isAlive()){
return (false);
};
if (!a_unit.isDeployed()){
return (false);
};
if (a_unit.hasMoved()){
return (false);
};
if (a_path.length < 1){
return (false);
};
if (a_path[0] == null){
return (false);
};
if (!ignoreEnd){
if (a_path[(a_path.length - 1)].getUnit() != null){
if (((!((a_path[(a_path.length - 1)].getUnit() == a_unit))) && (!(a_path[(a_path.length - 1)].getUnit().isCloaked())))){
return (false);
};
};
};
if (a_path[0].getUnit() == a_unit){
current = a_path[0];
cost = 0;
i = 1;
while (i < a_path.length) {
check = a_path[i];
if (check == null){
return (false);
};
if (!current.isConnected(check)){
return (false);
};
cost = (cost + check.getCost(a_unit));
current = check;
i++;
};
if (cost > a_unit.getRange()){
return (false);
};
} else {
return (false);
};
return (true);
}
public function update(a_ms:uint=0):void{
if (m_loadingPanel != null){
if (!isStillInitializing()){
m_loadingPanel.stop();
m_loadingPanel = null;
if (!m_wasLoadedFromSavedGame){
startGame();
} else {
ActionManager.getInstance().add(new SendTriggerAction(new PlayerTrigger(PlayerTrigger.START_TURN, GameManager.getInstance().getCurrentController())));
};
};
return;
};
TriggerManager.getInstance().add(new TimePassedTrigger(a_ms));
TriggerManager.getInstance().update();
GameEventManager.getInstance().update();
ResponseManager.getInstance().update();
ActionManager.getInstance().update();
camera.update(a_ms);
var i:int;
while (i < controllers.length) {
if (controllers[i].getTeam().getActive()){
controllers[i].update(a_ms);
controllers[i].getTeam().addStatistic(Team.TIME_TAKEN, null);
};
i++;
};
if (!TweenManager.getInstance().isEmpty()){
gameSpriteScroller.scroll(true);
};
gameSpriteScroller.update(a_ms);
updateUI(a_ms);
if (BattalionMain.ALLOW_DEBUG){
if (KeyboardHandler.getInstance().isDown(Keyboard.HOME)){
i = 0;
while (i < controllers.length) {
if (controllers[i].getTeam().getControllerType() != "Human"){
ActionManager.getInstance().add(new SurrenderAction(i));
};
i++;
};
};
if (KeyboardHandler.getInstance().isDown(Keyboard.END)){
i = 0;
while (i < controllers.length) {
if (controllers[i].getTeam().getControllerType() == "Human"){
ActionManager.getInstance().add(new SurrenderAction(i));
};
i++;
};
};
};
}
public function activePlayers():int{
var active:int;
var i:int;
while (i < controllers.length) {
if (controllers[i].getTeam().getActive()){
active++;
};
i++;
};
return (active);
}
public function addStructure(a_controller:Controller, a_tile:Tile):void{
if (a_controller != null){
a_controller.addStructure(a_tile);
};
structures.push(a_tile);
}
public function addUnit(a_controller:Controller, a_unit:Unit):void{
a_controller.addUnit(a_unit);
units.push(a_unit);
miniMap.getMap().addChild(a_unit.getMiniMapSprite());
}
public function pointPath(a_path:Array):Array{
var retPath:Array = new Array();
var i:int;
while (i < a_path.length) {
retPath.push(a_path[i].getX());
retPath.push(a_path[i].getY());
i++;
};
return (retPath);
}
public function unitAt(a_x:int, a_y:int):Unit{
var t:Tile = tileAt(a_x, a_y);
if (t == null){
return (null);
};
return (t.getUnit());
}
public function getRound():int{
return (round);
}
public function surrender(a_player:int):void{
controllers[a_player].getTeam().setActive(false);
if (isOneActiveTeam()){
ActionManager.getInstance().add(new EndGameAction());
};
}
public function getPlayer(a_controller:Controller):int{
var i:int;
while (i < controllers.length) {
if (controllers[i] == a_controller){
return (i);
};
i++;
};
return (-1);
}
public function getTurn():int{
return (turn);
}
public function setTurn(a_turn:int):void{
turn = a_turn;
}
public static function getInstance():GameManager{
if (singleton == null){
return (null);
};
return (singleton);
}
}
}//package com.gamedozer.battalion.game
Section 134
//GameManagerHelper (com.gamedozer.battalion.game.GameManagerHelper)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.*;
public class GameManagerHelper {
private static var initialised:Boolean = false;
public function GameManagerHelper(){
super();
if (initialised){
return;
};
initialised = true;
new ModifierManager();
new TileManager(BattalionMain.TILE_WIDTH, BattalionMain.TILE_HEIGHT, 6, 6);
new UnitManager();
new TileSheetManager();
new TweenManager(BattalionMain.getStage());
}
public static function isInitialised():Boolean{
return (initialised);
}
}
}//package com.gamedozer.battalion.game
Section 135
//LogicalAndCondition (com.gamedozer.battalion.game.LogicalAndCondition)
package com.gamedozer.battalion.game {
public class LogicalAndCondition extends LogicalCondition {
public function LogicalAndCondition(){
super();
}
override public function isSatisfied():Boolean{
var i:int;
while (i < conditions.length) {
if (!conditions[i].isSatisfied()){
return (false);
};
i++;
};
return (true);
}
override public function toXML():XML{
var ret:String = "<condition type=\"and\"> ";
var i:int;
while (i < conditions.length) {
ret = (ret + conditions[i].toXML());
i++;
};
ret = (ret + "</condition>");
return (new XML(ret));
}
public static function getFromXML(a_xml:XML):Condition{
var conditions:XMLList = a_xml.child("condition");
var condition:LogicalAndCondition = new (LogicalAndCondition);
var i:int;
while (i < conditions.length()) {
condition.add(ConditionFactory.get(conditions[i]));
i++;
};
return (condition);
}
}
}//package com.gamedozer.battalion.game
Section 136
//LogicalCondition (com.gamedozer.battalion.game.LogicalCondition)
package com.gamedozer.battalion.game {
public class LogicalCondition implements Condition {
protected var conditions:Array;
public function LogicalCondition(){
super();
conditions = new Array();
}
public function add(a_condition:Condition):void{
conditions.push(a_condition);
}
public function update():void{
var i:int;
while (i < conditions.length) {
conditions[i].update();
i++;
};
}
public function getConditions():Array{
return (conditions);
}
public function reset():void{
var i:int;
while (i < conditions.length) {
conditions[i].reset();
i++;
};
}
public function isSatisfied():Boolean{
if (conditions.length > 0){
return (conditions[0].isSatistfied());
};
return (false);
}
public function toXML():XML{
var ret:String = "<condition type=\"logical\"> ";
var i:int;
while (i < conditions.length) {
ret = (ret + conditions[i].toXML());
i++;
};
ret = (ret + "</condition>");
return (new XML(ret));
}
public function dispose():void{
var i:int;
while (i < conditions.length) {
conditions[i].dispose();
i++;
};
}
}
}//package com.gamedozer.battalion.game
Section 137
//LogicalOrCondition (com.gamedozer.battalion.game.LogicalOrCondition)
package com.gamedozer.battalion.game {
public class LogicalOrCondition extends LogicalCondition {
public function LogicalOrCondition(){
super();
}
override public function isSatisfied():Boolean{
var i:int;
while (i < conditions.length) {
if (conditions[i].isSatisfied()){
return (true);
};
i++;
};
return (false);
}
override public function toXML():XML{
var ret:String = "<condition type=\"or\"> ";
var i:int;
while (i < conditions.length) {
ret = (ret + conditions[i].toXML());
i++;
};
ret = (ret + "</condition>");
return (new XML(ret));
}
public static function getFromXML(a_xml:XML):Condition{
var condition:LogicalOrCondition = new (LogicalOrCondition);
var conditions:XMLList = a_xml.child("condition");
trace(("LOC #" + conditions.length()));
var i:int;
while (i < conditions.length()) {
condition.add(ConditionFactory.get(conditions[i]));
i++;
};
return (condition);
}
}
}//package com.gamedozer.battalion.game
Section 138
//LogicalXorCondition (com.gamedozer.battalion.game.LogicalXorCondition)
package com.gamedozer.battalion.game {
public class LogicalXorCondition extends LogicalCondition {
public function LogicalXorCondition(){
super();
}
override public function isSatisfied():Boolean{
var ret:Boolean;
var one:Boolean;
var i:int;
while (i < conditions.length) {
if (conditions[i].isSatisfied()){
if (one == false){
ret = true;
} else {
return (false);
};
};
i++;
};
return (ret);
}
override public function toXML():XML{
var ret:String = "<condition type=\"xor\"> ";
var i:int;
while (i < conditions.length) {
ret = (ret + conditions[i].toXML());
i++;
};
ret = (ret + "</condition>");
return (new XML(ret));
}
public static function getFromXML(a_xml:XML):Condition{
var conditions:XMLList = a_xml.child("condition");
var condition:LogicalXorCondition = new (LogicalXorCondition);
var i:int;
while (i < conditions.length()) {
condition.add(ConditionFactory.get(conditions[i]));
i++;
};
return (condition);
}
}
}//package com.gamedozer.battalion.game
Section 139
//MovementCombiner (com.gamedozer.battalion.game.MovementCombiner)
package com.gamedozer.battalion.game {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.ai.*;
import com.gamedozer.battalion.game.actions.*;
public class MovementCombiner {
var m_turnCount:int;
var m_tankIslands:MovementIslands;
var m_commandoIslands:MovementIslands;
var m_leviathanIslands:MovementIslands;
public function MovementCombiner(){
super();
initialize();
}
public function getInterimDestination(a_startingTile:Tile, a_endingTile:Tile, a_unit:Unit):Tile{
var initialIsland:Set;
var intersectionSet:Set;
var visitedSet:Set;
var results:Array;
var bestTurnCount:int;
var bestIndex:int;
var i:int;
var result:InterimResult;
m_turnCount = 0;
var unitData:UnitData = a_unit.getUnitData();
if (unitData.isAir()){
return (a_endingTile);
};
var baseUnitMovementIslands:MovementIslands = lookupMovementIslands(a_unit);
if (((unitData.isGround()) && (a_unit.getController().controlsSea()))){
if (baseUnitMovementIslands.areSharingAnIsland(a_startingTile, a_endingTile)){
return (a_endingTile);
};
initialIsland = baseUnitMovementIslands.getIsland(a_startingTile);
intersectionSet = m_leviathanIslands.intersect(initialIsland);
visitedSet = new Set();
visitedSet = visitedSet.union(initialIsland);
results = drillIntersectionSet(a_unit, a_endingTile, visitedSet, intersectionSet, baseUnitMovementIslands, m_leviathanIslands);
if (results == null){
return (null);
};
if (results.length == 0){
return (null);
};
if (results.length == 1){
if (results[0].intersection.getTerrain().getName() == "High Bridge"){
return (null);
};
return (results[0].intersection);
};
bestTurnCount = 100000000000;
bestIndex = -1;
i = 0;
while (i < results.length) {
result = results[i];
if (result.intersection.getTerrain().getName() == "High Bridge"){
} else {
if (result.turns < bestTurnCount){
bestIndex = i;
};
};
i++;
};
if (bestIndex == -1){
return (null);
};
if (results[bestIndex].intersection.getTerrain().getName() == "High Bridge"){
throw (new Error("Cant have a high bridge intersection"));
};
return (results[bestIndex].intersection);
} else {
//unresolved if
if (m_leviathanIslands.areSharingAnIsland(a_startingTile, a_endingTile)){
return (a_endingTile);
};
initialIsland = m_leviathanIslands.getIsland(a_startingTile);
intersectionSet = baseUnitMovementIslands.intersect(initialIsland);
visitedSet = new Set();
visitedSet = visitedSet.union(initialIsland);
results = drillIntersectionSet(a_unit, a_endingTile, visitedSet, intersectionSet, m_leviathanIslands, baseUnitMovementIslands);
if (results == null){
return (null);
};
if (results.length == 0){
return (null);
};
if (results.length == 1){
return (results[0].intersection);
};
bestTurnCount = 100000000000;
bestIndex = -1;
i = 0;
while (i < results.length) {
result = results[i];
if (result.turns < bestTurnCount){
bestIndex = i;
};
i++;
};
if (bestIndex == -1){
return (null);
};
return (results[bestIndex].intersection);
};
//unresolved jump
return (null);
}
public function getAppropriateFakeUnit(a_actualUnit:Unit, a_activeMovementIsland:MovementIslands):Unit{
var unitManager:UnitManager = UnitManager.getInstance();
if (a_activeMovementIsland == m_leviathanIslands){
return (new Unit(new GameUnit(new GameSprite()), unitManager.get("Leviathan Barge")));
};
if (a_actualUnit.getName().indexOf("Commando") == -1){
return (new Unit(new GameUnit(new GameSprite()), unitManager.get("Scorpion Tank")));
};
return (new Unit(new GameUnit(new GameSprite()), unitManager.get("Strike Commando")));
}
private function lookupMovementIslands(a_unit:Unit):MovementIslands{
var unitData:UnitData = a_unit.getBaseUnitData();
if (unitData.isGround()){
if (unitData.getMovementType() == 1){
return (m_commandoIslands);
};
return (m_tankIslands);
};
return (null);
}
private function initialize():void{
m_leviathanIslands = new MovementIslands("Leviathan Barge");
m_commandoIslands = new MovementIslands("Strike Commando");
m_tankIslands = new MovementIslands("Scorpion Tank");
}
public function getTurnCount():int{
return (m_turnCount);
}
private function drillIntersectionSet(a_unit:Unit, a_endingTile:Tile, a_visitedSet:Set, a_intersections:Set, a_fromIslands:MovementIslands, a_toIslands:MovementIslands):Array{
var intersection:Tile;
var island:Set;
var turns:int;
var result:InterimResult;
var intersectionSet:Set;
var returnValue:Array;
var bestTurnCount:int;
var bestIndex:int;
var bestIntersectionResult:InterimResult;
var returnValues:Array;
var intersectionArray:Array = a_intersections.getArrayCopy();
var i:int;
while (i < intersectionArray.length) {
intersection = intersectionArray[i];
if (((!((intersection.getUnit() == null))) && (!((intersection.getUnit() == a_unit))))){
} else {
island = a_toIslands.getIsland(intersection);
if (a_visitedSet.containsSet(island)){
} else {
a_visitedSet = a_visitedSet.union(island);
if (island.containsObject(a_endingTile)){
if (returnValues == null){
returnValues = new Array();
};
turns = Astar.calculateTurnsToPath(intersection, a_endingTile, getAppropriateFakeUnit(a_unit, a_toIslands), Tile.k_astarFlagIgnoreLastNode);
result = new InterimResult();
result.turns = (turns + 1);
result.intersection = intersection;
returnValues.push(result);
};
if (returnValues == null){
intersectionSet = a_fromIslands.intersect(island);
returnValue = drillIntersectionSet(a_unit, a_endingTile, a_visitedSet, intersectionSet, a_toIslands, a_fromIslands);
if (returnValue != null){
if (returnValues == null){
returnValues = new Array();
};
bestTurnCount = 100000000000;
bestIndex = -1;
i = 0;
while (i < returnValue.length) {
result = returnValue[i];
if (result.turns < bestTurnCount){
bestIndex = i;
};
i++;
};
bestIntersectionResult = returnValue[bestIndex];
turns = Astar.calculateTurnsToPath(intersection, bestIntersectionResult.intersection, getAppropriateFakeUnit(a_unit, a_toIslands), Tile.k_astarFlagIgnoreLastNode);
result = new InterimResult();
result.turns = (bestIntersectionResult.turns + turns);
result.intersection = intersection;
returnValues.push(result);
};
};
};
};
i++;
};
return (returnValues);
}
}
}//package com.gamedozer.battalion.game
import com.gamedozer.battalion.data.*;
class InterimResult {
public var intersection:Tile;// = null
public var turns:int;// = 0
private function InterimResult(){
super();
}
}
Section 140
//MovementIslands (com.gamedozer.battalion.game.MovementIslands)
package com.gamedozer.battalion.game {
import com.gamedozer.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.game.controllers.*;
import com.gamedozer.battalion.game.ai.*;
import com.gamedozer.battalion.game.actions.*;
public class MovementIslands {
private var m_unitData:UnitData;
private var m_islands:Array;
public function MovementIslands(a_unitName:String){
super();
m_unitData = UnitManager.getInstance().get(a_unitName);
m_islands = new Array();
initialize();
}
private function initialize():void{
var y:int;
var tile:Tile;
var newSet:Array;
var i:int;
var island:Set;
var potentialNeighbor:Tile;
var c:int;
var setMember:Tile;
var fakeUnit:Unit = new Unit(new GameUnit(new GameSprite()), m_unitData);
var game:GameManager = GameManager.getInstance();
var tileMap:Array = game.getTileMap();
var reachableTiles:Array = new Array();
var x:int;
while (x < tileMap.length) {
y = 0;
while (y < tileMap[x].length) {
tile = tileMap[x][y];
if (tile.canBeMovedOnBy(fakeUnit)){
reachableTiles.push(tile);
};
y++;
};
x++;
};
while (reachableTiles.length > 0) {
tile = reachableTiles[0];
reachableTiles.splice(0, 1);
newSet = new Array();
newSet.push(tile);
i = 0;
while (i < reachableTiles.length) {
potentialNeighbor = reachableTiles[i];
c = 0;
while (c < newSet.length) {
setMember = newSet[c];
if (setMember.isAdjacentTo(potentialNeighbor)){
newSet.push(potentialNeighbor);
reachableTiles.splice(i, 1);
i = -1;
break;
};
c++;
};
i++;
};
island = new Set();
island.addArray(newSet);
m_islands.push(island);
};
}
private function getIslandFromTile(a_tile:Tile):Set{
var island:Set;
var islandsCount:int = m_islands.length;
var i:int;
while (i < islandsCount) {
island = m_islands[i];
if (island.containsObject(a_tile)){
return (island);
};
i++;
};
return (null);
}
public function accumulate(a_islands:MovementIslands):void{
}
public function areSharingAnIsland(a_tileA:Tile, a_tileB:Tile):Boolean{
var islandA:Set = getIslandFromTile(a_tileA);
var islandB:Set = getIslandFromTile(a_tileB);
if ((((islandA == null)) || ((islandB == null)))){
return (false);
};
if (islandA == islandB){
return (true);
};
return (false);
}
public function getIsland(a_tile:Tile):Set{
var island:Set;
var i:int;
while (i < m_islands.length) {
island = m_islands[i];
if (island.containsObject(a_tile)){
return (island);
};
i++;
};
return (null);
}
public function intersect(a_set:Set):Set{
var island:Set;
var result:Set = new Set();
var i:int;
while (i < m_islands.length) {
island = m_islands[i];
result = result.union(a_set.intersect(island));
i++;
};
return (result);
}
}
}//package com.gamedozer.battalion.game
Section 141
//NotCondition (com.gamedozer.battalion.game.NotCondition)
package com.gamedozer.battalion.game {
public class NotCondition implements Condition {
protected var condition:Condition;
public function NotCondition(a_condition:Condition){
super();
condition = a_condition;
}
public function isSatisfied():Boolean{
return (!(condition.isSatisfied()));
}
public function update():void{
condition.update();
}
public function toXML():XML{
return (new XML((("<condition type=\"not\"> " + condition.toXML()) + "</condition>")));
}
public function reset():void{
condition.reset();
}
public function dispose():void{
condition.dispose();
}
public static function getFromXML(a_xml:XML):Condition{
return (new NotCondition(ConditionFactory.get(a_xml..condition[0])));
}
}
}//package com.gamedozer.battalion.game
Section 142
//Response (com.gamedozer.battalion.game.Response)
package com.gamedozer.battalion.game {
public class Response {
protected var completed:Boolean;
protected var fired:Boolean;
public function Response(){
super();
fired = false;
completed = false;
}
public function isCompleted():Boolean{
return (completed);
}
public function toXML():XML{
return (new XML());
}
public function isFired():Boolean{
return (fired);
}
public function update():void{
completed = true;
}
public function reset():void{
fired = false;
completed = false;
}
public function globalQueue():Boolean{
return (false);
}
public function fire():void{
fired = true;
}
public function dispose():void{
}
}
}//package com.gamedozer.battalion.game
Section 143
//ResponseFactory (com.gamedozer.battalion.game.ResponseFactory)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.game.responses.*;
public class ResponseFactory {
public function ResponseFactory(){
super();
}
public static function get(a_xml:XML):Response{
var type:String = a_xml.@type;
switch (type){
case "incrementCounterVariable":
return (IncrementCounterVariableResponse.getFromXML(a_xml));
case "decrementCounterVariable":
return (DecrementCounterVariableResponse.getFromXML(a_xml));
case "setBooleanVariable":
return (SetBooleanVariableResponse.getFromXML(a_xml));
case "chat":
return (ChatResponse.getFromXML(a_xml));
case "highlight":
return (HighlightResponse.getFromXML(a_xml));
case "disableControllers":
return (DisableControllersResponse.getFromXML(a_xml));
case "trace":
return (TraceResponse.getFromXML(a_xml));
case "sendAction":
return (SendActionResponse.getFromXML(a_xml));
case "sendTrigger":
return (SendTriggerResponse.getFromXML(a_xml));
case "nameUnit":
return (NameUnitResponse.getFromXML(a_xml));
case "createTransportedUnit":
return (CreateTransportedUnitResponse.getFromXML(a_xml));
case "createUnit":
return (CreateUnitResponse.getFromXML(a_xml));
case "destroyUnit":
return (DestroyUnitResponse.getFromXML(a_xml));
case "removeUnit":
return (RemoveUnitResponse.getFromXML(a_xml));
case "scroll":
return (ScrollResponse.getFromXML(a_xml));
case "damageUnit":
return (DamageUnitResponse.getFromXML(a_xml));
case "unitDisable":
return (UnitDisableResponse.getFromXML(a_xml));
case "structureResources":
return (StructureResourcesResponse.getFromXML(a_xml));
case "resources":
return (ResourcesResponse.getFromXML(a_xml));
case "disableUnit":
return (DisableUnitResponse.getFromXML(a_xml));
};
return (new Response());
}
}
}//package com.gamedozer.battalion.game
Section 144
//ResponseManager (com.gamedozer.battalion.game.ResponseManager)
package com.gamedozer.battalion.game {
import flash.utils.*;
public class ResponseManager {
protected var responses:Array;
protected var objects:Array;
private static var singleton:ResponseManager;
public function ResponseManager(){
super();
singleton = this;
responses = new Array();
objects = new Array();
}
public function add(a_response:Response, a_object:Object):void{
responses.push(a_response);
objects.push(a_object);
}
public function isEmpty():Boolean{
return ((responses.length == 0));
}
public function update():void{
var response:Response;
var object:Dictionary = new Dictionary();
var i:int;
for (;i < responses.length;(i = (i + 1))) {
response = responses[i];
if (response.globalQueue()){
if (object[this] != null){
continue;
};
object[this] = true;
};
if (object[objects[i]] != null){
} else {
object[objects[i]] = true;
if (!response.isFired()){
response.fire();
} else {
response.update();
};
continue;
var _slot1 = e;
trace("ResponseManager::", _slot1.getStackTrace());
};
};
i = (responses.length - 1);
while (i >= 0) {
if (responses[i].isCompleted()){
responses.splice(i, 1);
objects.splice(i, 1);
};
i = (i - 1);
};
}
public function peek(startResponse:Response=null):Response{
var startIndex:int;
if (startResponse != null){
startIndex = responses.indexOf(startResponse);
if (startIndex == -1){
return (null);
};
};
var i:int = (startIndex + 1);
while (i < responses.length) {
if (!responses[i].isCompleted()){
return (responses[i]);
};
i++;
};
return (null);
}
public static function getInstance():ResponseManager{
if (singleton == null){
throw (new Error("ResponseManager::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.game
Section 145
//ScriptManager (com.gamedozer.battalion.game.ScriptManager)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.utils.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
public class ScriptManager {
public function ScriptManager(){
super();
}
public static function parseScript(a_xml:XML):void{
var i:int;
var controller:Controller;
var ud:UnitData;
var gu:GameUnit;
var u:Unit;
var ts:TileSheet;
var modifiers:XMLList;
var upgradeString:String;
var j:int;
var healthString:String;
var newUnit:UnitData;
var tileSheet:TileSheet;
var tile:Tile;
var argb:uint;
var upgrade:*;
var sprite:GameSprite;
var e:GameEvent;
var gameManager:GameManager = GameManager.getInstance();
var gamestate:XMLList = a_xml..gamestate;
i = 0;
while (i < gamestate.length()) {
gameManager.setTurn(gamestate[i].@turn);
gameManager.setRound(gamestate[i].@round);
gameManager.setCurrentController(gamestate[i].@controller);
i++;
};
var resources:XMLList = a_xml..resources;
i = 0;
while (i < resources.length()) {
gameManager.getController(resources[i].@controller).addResources(resources[i].@value);
i++;
};
var units:XMLList = a_xml..unit;
i = 0;
while (i < units.length()) {
controller = gameManager.getController(units[i].@controller);
if (controller == null){
} else {
ud = UnitManager.getInstance().get(units[i].@name);
if (ud != null){
gu = new GameUnit(TileSheetManager.getInstance().getColorised(ud.getSprite(), controller.getTeam().getColor()));
u = new Unit(gu, ud, parseInt(units[i].@x), parseInt(units[i].@y), controller);
ts = (u.getGameUnit().getSprite() as TileSheet);
ts.playAnimation("right_idle");
u.setDeployed((units[i].status.@deployed.charAt(0) == "t"));
u.setMoved((units[i].status.@moved.charAt(0) == "t"));
u.setFired((units[i].status.@fired.charAt(0) == "t"));
if ((((units[i].status.@moved.charAt(0) == "t")) || ((units[i].status.@fired.charAt(0) == "t")))){
u.darken();
};
u.setCloaked((units[i].status.@cloaked.charAt(0) == "t"), false, false);
u.setRepairing((units[i].status.@repairing.charAt(0) == "t"));
modifiers = units[i]..modifier;
upgradeString = units[i].upgrade.@name;
if (upgradeString != ""){
trace("Upgrade stuffs");
newUnit = UnitManager.getInstance().get(units[i].upgrade.@name);
tileSheet = TileSheetManager.getInstance().getColorised(newUnit.getSprite(), controller.getTeam().getColor());
u.getGameUnit().getSprite().alpha = 0;
u.upgrade(tileSheet, newUnit);
};
j = 0;
while (j < modifiers.length()) {
ud.addTemporaryModifier(ModifierManager.getInstance().get(modifiers[j].@value));
j++;
};
healthString = units[i].health.@value;
if (healthString != ""){
u.setHealth(parseFloat(units[i].health.@value));
};
gameManager.addUnit(controller, u);
gameManager.getTileMap()[u.getY()][u.getX()].setUnit(u);
gameManager.getGameSpriteScroller().add(u.getGameUnit(), GameSpriteScroller.UNITS);
};
};
i++;
};
var structures:XMLList = a_xml..structure;
i = 0;
while (i < structures.length()) {
controller = gameManager.getController(parseInt(structures[i].@controller));
tile = gameManager.tileAt(parseInt(structures[i].@x), parseInt(structures[i].@y));
argb = 4294967295;
if (controller != null){
argb = controller.getTeam().getColor();
};
upgrade = TileManager.getInstance().get(structures[i].@name);
if (upgrade != null){
if (upgrade.getSprite() == "oilrig"){
sprite = TileSheetManager.getInstance().getColorised("oilrig", argb);
(sprite as TileSheet).playAnimation("default");
} else {
sprite = new ColoredSprite(BitmapLibrary.loadBitmap(upgrade.getSprite()), BitmapLibrary.loadBitmap((upgrade.getSprite() + "_mask")), argb, "overlay");
};
tile.upgrade(sprite, upgrade, controller);
tile.setChunks(parseInt(structures[i].@chunks));
if (parseInt(structures[i].@capturerx) != -1){
tile.setCapturer(gameManager.unitAt(parseInt(structures[i].@capturerx), parseInt(structures[i].@capturery)));
};
gameManager.addStructure(controller, tile);
};
i++;
};
var sResources:XMLList = a_xml..structureresources;
i = 0;
while (i < sResources.length()) {
tile = gameManager.tileAt(parseInt(sResources[i].@x), parseInt(sResources[i].@y));
if (tile != null){
tile.setResources(parseInt(sResources[i].@value));
};
i++;
};
var cameras:XMLList = a_xml..camera;
i = 0;
while (i < cameras.length()) {
gameManager.getCamera().setLocation(parseInt(cameras[i].@x), parseInt(cameras[i].@y));
i++;
};
var disables:XMLList = a_xml.disableUnit;
i = 0;
while (i < disables.length()) {
gameManager.getController(parseInt(disables[i].@controller)).disableUnit(disables[i].@unit);
i++;
};
var events:XMLList = a_xml..event;
i = 0;
while (i < events.length()) {
e = GameEvent.getFromXML(events[i]);
GameEventManager.getInstance().add(e);
i++;
};
}
}
}//package com.gamedozer.battalion.game
Section 146
//Trigger (com.gamedozer.battalion.game.Trigger)
package com.gamedozer.battalion.game {
public class Trigger {
protected var name:String;
public static const START_ROUND:String = "startRound";
public static const END_GAME:String = "endGame";
public static const ERROR:String = "error";
public static const CONTROL:String = "control";
public static const START_GAME:String = "startGame";
public function Trigger(a_name:String=""){
super();
name = a_name;
}
public function getName():String{
return (name);
}
public function toXML():XML{
return (new XML());
}
public function setName(a_name:String):void{
name = a_name;
}
}
}//package com.gamedozer.battalion.game
Section 147
//TriggerFactory (com.gamedozer.battalion.game.TriggerFactory)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.game.triggers.*;
public class TriggerFactory {
public function TriggerFactory(){
super();
}
public static function get(a_xml:XML):Trigger{
var type:String = a_xml.@type;
switch (type){
case "":
break;
};
return (new Trigger());
}
}
}//package com.gamedozer.battalion.game
Section 148
//TriggerManager (com.gamedozer.battalion.game.TriggerManager)
package com.gamedozer.battalion.game {
import com.gamedozer.battalion.game.triggers.*;
public class TriggerManager {
protected var triggers:Array;
protected var listeners:Array;
private static var singleton:TriggerManager;
public function TriggerManager(){
super();
singleton = this;
triggers = new Array();
listeners = new Array();
}
public function add(a_trigger:Trigger):void{
triggers.push(a_trigger);
}
public function isEmpty():Boolean{
return ((triggers.length == 0));
}
public function addListener(a_name:String, a_function:Function):void{
var helper:TriggerHelper = new TriggerHelper();
helper.name = a_name;
helper.func = a_function;
listeners.push(helper);
}
public function removeListener(a_name:String, a_function:Function):void{
var i:int = (listeners.length - 1);
while (i >= 0) {
if ((((listeners[i].name == a_name)) && ((listeners[i].func == a_function)))){
listeners.splice(i, 1);
};
i--;
};
}
public function update():void{
var trigger:*;
var i:*;
do {
trigger = triggers.shift();
i = 0;
while (i < listeners.length) {
if (listeners[i].name == trigger.getName()){
listeners[i].func.call(null, trigger);
};
i++;
};
} while (triggers.length > 0);
}
public static function getInstance():TriggerManager{
if (singleton == null){
throw (new Error("TriggerManager::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.game
class TriggerHelper {
public var name:String;
public var func:Function;
private function TriggerHelper(){
super();
}
}
Section 149
//AllPlayerPanel (com.gamedozer.battalion.ui.AllPlayerPanel)
package com.gamedozer.battalion.ui {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
public class AllPlayerPanel extends Sprite {
var arrow:Sprite;
var panels:Array;
public static var WIDTH:int = 130;
public static var HEIGHT:int = 148;
public function AllPlayerPanel(a_teams:Array){
var panel:PlayerPanel;
super();
addChild(new Bitmap(BitmapLibrary.loadBitmap("playerboxbehind")));
panels = new Array();
var i:int;
while (i < 4) {
if (i < a_teams.length){
panel = new PlayerPanel(a_teams[i]);
panel.y = (i * PlayerPanel.HEIGHT);
addChild(panel);
panels.push(panel);
};
i++;
};
var frame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame2"), (WIDTH + 30), (HEIGHT + 30), 39, 39));
frame.x = -15;
frame.y = -15;
addChild(frame);
arrow = new Sprite();
arrow.addChild(new Bitmap(BitmapLibrary.loadBitmap("playerpointer")));
arrow.x = (-(arrow.width) + 16);
addChild(arrow);
setActive(0);
x = (BattalionMain.WIDTH - WIDTH);
y = (MiniMap.HEIGHT + 15);
}
public function setActive(a_active:int):void{
arrow.y = (((a_active * PlayerPanel.HEIGHT) + (PlayerPanel.HEIGHT / 2)) - (arrow.height / 2));
}
public function setResources(a_controllers:Array):void{
var i:int;
while (i < a_controllers.length) {
if (a_controllers[i] != null){
panels[i].setResources(a_controllers[i].getResources());
} else {
panels[i].setResources(0);
};
i++;
};
}
}
}//package com.gamedozer.battalion.ui
Section 150
//BattalionButton (com.gamedozer.battalion.ui.BattalionButton)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import flash.text.*;
import com.gamedozer.battalion.*;
public class BattalionButton extends SimpleButton {
protected static const OVER_BITMAP:String = "buttonUp";
protected static const DOWN_BITMAP:String = "buttonDown";
protected static const UP_BITMAP:String = "button";
protected static var downBitmapData:BitmapData;
protected static var overBitmapData:BitmapData;
protected static var upBitmapData:BitmapData;
public function BattalionButton(a_width:int=-1, a_height:int=-1, a_buttonLabel:String=""){
super();
if (upBitmapData == null){
upBitmapData = BitmapLibrary.loadBitmap(UP_BITMAP);
overBitmapData = BitmapLibrary.loadBitmap(OVER_BITMAP);
downBitmapData = BitmapLibrary.loadBitmap(DOWN_BITMAP);
};
upState = new Sprite();
(upState as Sprite).addChild(new Bitmap(FrameMaker.createFrame(upBitmapData, a_width, a_height, 8, 8)));
overState = new Sprite();
(overState as Sprite).addChild(new Bitmap(FrameMaker.createFrame(overBitmapData, a_width, a_height, 8, 8)));
downState = new Sprite();
(downState as Sprite).addChild(new Bitmap(FrameMaker.createFrame(downBitmapData, a_width, a_height, 8, 8)));
hitTestState = upState;
if (a_buttonLabel != ""){
labelButton((upState as DisplayObjectContainer), a_buttonLabel);
labelButton((downState as DisplayObjectContainer), a_buttonLabel);
labelButton((overState as DisplayObjectContainer), a_buttonLabel);
};
tabEnabled = false;
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
}
function outHandler(a_event:Event):void{
BattalionMain.getMouseCursor().setCursor("default");
}
function overHandler(a_event:Event):void{
if (enabled){
BattalionMain.getMouseCursor().setCursor("select");
};
}
private function labelButton(state:DisplayObjectContainer, a_buttonLabel:String):void{
var buttonLabel:TextField;
buttonLabel = new DefaultTextField();
buttonLabel.x = 0;
buttonLabel.y = 0;
var tf:TextFormat = new DefaultTextFormat();
tf.align = TextFormatAlign.CENTER;
buttonLabel.defaultTextFormat = tf;
buttonLabel.htmlText = BBCode.parseBBCode(a_buttonLabel);
buttonLabel.width = state.width;
buttonLabel.height = (buttonLabel.textHeight + 5);
buttonLabel.y = ((state.height - buttonLabel.height) / 2);
state.addChild(buttonLabel);
}
}
}//package com.gamedozer.battalion.ui
Section 151
//BattalionPanel (com.gamedozer.battalion.ui.BattalionPanel)
package com.gamedozer.battalion.ui {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import flash.text.*;
public class BattalionPanel extends MovieClip {
public var rHeight:int;
public var rWidth:int;
public static const SPOTTED:String = "spotted_texture";
public static const FRAME1:String = "frame1";
public static const FRAME2:String = "frame2";
public static const WOOD:String = "wood_texture";
protected static var bitmapData:BitmapData;
public function BattalionPanel(a_width:int=-1, a_height:int=-1, a_bitmap:String="wood_texture", a_frame:String="frame1", a_title:String=""){
var child0:DisplayObject;
var header:TextField;
var bgBorder:Sprite;
var frame1:Bitmap;
var frame2:Bitmap;
super();
if (bitmapData == null){
bitmapData = BitmapLibrary.loadBitmap(a_bitmap);
};
if (a_width == -1){
rWidth = Math.ceil(width);
rHeight = Math.ceil(height);
child0 = getChildAt(0);
child0.visible = false;
child0.scaleX = 0;
child0.scaleY = 0;
child0.width = 1;
child0.height = 1;
scaleX = 1;
scaleY = 1;
} else {
rWidth = a_width;
rHeight = a_height;
};
var child:Sprite = FrameMaker.createBlock(BitmapLibrary.loadBitmap(a_bitmap), rWidth, rHeight);
addChild(child);
if (a_title != ""){
header = new DefaultTextField(0xFFFFFF, TextFormatAlign.CENTER);
header.text = a_title;
header.width = rWidth;
header.height = (header.textHeight + 5);
bgBorder = new Sprite();
bgBorder.graphics.lineStyle(1, 0, 0);
bgBorder.graphics.beginFill(0, 0.5);
bgBorder.graphics.drawRect(0, 0, rWidth, header.height);
addChild(bgBorder);
addChild(header);
};
if (a_frame == FRAME1){
frame1 = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap(FRAME1), (rWidth + 16), (rHeight + 16), 43, 43));
frame1.x = (frame1.y = -8);
addChild(frame1);
} else {
if (a_frame == FRAME2){
frame2 = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap(FRAME2), (rWidth + 30), (rHeight + 30), 39, 39));
frame2.x = (frame2.y = -15);
addChild(frame2);
};
};
}
}
}//package com.gamedozer.battalion.ui
Section 152
//BuildMenu (com.gamedozer.battalion.ui.BuildMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import flash.geom.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
public class BuildMenu extends Sprite {
protected var tileSheets:Array;
protected var groundText:Bitmap;
protected var airText:Bitmap;
protected var groundIcon:Bitmap;
protected var airIcon:Bitmap;
protected var controller:HumanController;
protected var infoMenu:InfoMenu;
protected var seaText:Bitmap;
protected var seaIcon:Bitmap;
public var backButton:TileSheetButton;
protected var groundHeader:Bitmap;
protected var seaHeader:Bitmap;
protected var tile:Tile;
protected var airHeader:Bitmap;
public static const WIDTH:int = 560;
public static const HEIGHT:int = 565;
public function BuildMenu(a_controller:HumanController, a_tile:Tile){
var unit:UnitData;
var active:Boolean;
var unitBox:BuildMenuUnit;
var groundBlocker:Sprite;
var groundBlockerText:TextField;
var airBlocker:Sprite;
var airBlockerText:TextField;
var seaBlocker:Sprite;
var seaBlockerText:TextField;
super();
controller = a_controller;
tile = a_tile;
var bg:Sprite = FrameMaker.createBlock(BitmapLibrary.loadBitmap("wood_texture"), WIDTH, HEIGHT);
var frame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame1"), (WIDTH + 16), (HEIGHT + 16), 43, 43));
frame.x = -8;
frame.y = -8;
bg.addChild(frame);
addChild(bg);
var groundUnits:Array = new Array();
var airUnits:Array = new Array();
var seaUnits:Array = new Array();
var allUnits:Array = UnitManager.getInstance().getAll();
var i:int;
while (i < allUnits.length) {
unit = allUnits[i];
if (unit.hasModifier("Unbuildable")){
} else {
if (!a_controller.isUnitEnabled(unit.getName())){
} else {
if (unit.isGround()){
groundUnits.push(unit);
} else {
if (unit.isAir()){
airUnits.push(unit);
} else {
if (unit.isSea()){
seaUnits.push(unit);
};
};
};
};
};
i++;
};
groundUnits.sort(sortOnCost);
airUnits.sort(sortOnCost);
seaUnits.sort(sortOnCost);
tileSheets = new Array();
var originalX = 14;
var originalY = 204;
var rowHeight = 125;
var startX:int = originalX;
var startY:int = originalY;
i = 0;
while (i < groundUnits.length) {
unit = groundUnits[i];
active = (a_controller.getResources() >= unit.getCost(a_controller));
unitBox = new BuildMenuUnit(this, a_controller, unit, active, groundHeaderShow);
tileSheets.push(unitBox.getTileSheet());
unitBox.x = startX;
unitBox.y = startY;
startX = (startX + 68);
if (startX > WIDTH){
startX = 14;
startY = (startY + rowHeight);
unitBox.x = startX;
unitBox.y = startY;
};
addChild(unitBox);
i++;
};
var blockerHeight = 95;
var blockerWidth = 530;
var map:Map = GameManager.getInstance().getMap();
if (!a_controller.controlsGround()){
groundBlocker = createBlockingImage(blockerWidth, blockerHeight);
groundBlocker.x = originalX;
groundBlocker.y = (startY + 5);
addChild(groundBlocker);
groundBlockerText = new DefaultTextField(0, TextFormatAlign.LEFT, true);
groundBlocker.addChild(groundBlockerText);
groundBlockerText.width = 500;
if (map.hasGroundControl){
groundBlockerText.text = "You cannot build ground units unless you control at least one Ground Control.";
} else {
groundBlockerText.text = "You cannot build ground units on this map.";
};
groundBlockerText.x = 10;
groundBlockerText.y = 10;
groundBlocker.addEventListener(MouseEvent.CLICK, clickHandler);
};
startX = originalX;
startY = (originalY + rowHeight);
i = 0;
while (i < airUnits.length) {
unit = airUnits[i];
active = (a_controller.getResources() >= unit.getCost(a_controller));
unitBox = new BuildMenuUnit(this, a_controller, unit, active, airHeaderShow);
tileSheets.push(unitBox.getTileSheet());
unitBox.x = startX;
unitBox.y = startY;
startX = (startX + 68);
addChild(unitBox);
i++;
};
if (!a_controller.controlsAir()){
airBlocker = createBlockingImage(blockerWidth, blockerHeight);
airBlocker.x = originalX;
airBlocker.y = (startY + 5);
addChild(airBlocker);
airBlockerText = new DefaultTextField(0, TextFormatAlign.LEFT, true);
airBlocker.addChild(airBlockerText);
airBlockerText.width = 500;
if (map.hasAirControl){
airBlockerText.text = "You cannot build air units unless you control at least one Air Control.";
} else {
airBlockerText.text = "You cannot build air units on this map.";
};
airBlockerText.x = 10;
airBlockerText.y = 10;
airBlocker.addEventListener(MouseEvent.CLICK, clickHandler);
};
startX = originalX;
startY = (originalY + (rowHeight * 2));
i = 0;
while (i < seaUnits.length) {
unit = seaUnits[i];
active = (a_controller.getResources() >= unit.getCost(a_controller));
unitBox = new BuildMenuUnit(this, a_controller, unit, active, seaHeaderShow);
tileSheets.push(unitBox.getTileSheet());
unitBox.x = startX;
unitBox.y = startY;
startX = (startX + 68);
addChild(unitBox);
i++;
};
if (((!(a_controller.controlsSea())) || (!(a_tile.seaBordered())))){
seaBlocker = createBlockingImage((blockerWidth - 100), blockerHeight);
seaBlocker.x = originalX;
seaBlocker.y = (startY + 5);
addChild(seaBlocker);
seaBlockerText = new DefaultTextField(0, TextFormatAlign.LEFT, true);
seaBlocker.addChild(seaBlockerText);
seaBlockerText.width = 500;
if (((map.hasSeaControl) && (!(a_tile.seaBordered())))){
seaBlockerText.text = "You can only build sea units from Factories that border the sea.";
} else {
if (map.hasSeaControl){
seaBlockerText.text = "You cannot build sea units unless you control at least one Sea Control.";
} else {
seaBlockerText.text = "You cannot build sea units on this map.";
};
};
seaBlockerText.x = 10;
seaBlockerText.y = 10;
seaBlocker.addEventListener(MouseEvent.CLICK, clickHandler);
};
groundText = new Bitmap(BitmapLibrary.loadBitmap("build_text_ground"));
airText = new Bitmap(BitmapLibrary.loadBitmap("build_text_air"));
seaText = new Bitmap(BitmapLibrary.loadBitmap("build_text_sea"));
groundText.x = 48;
groundText.y = 186;
airText.x = groundText.x;
airText.y = (186 + rowHeight);
seaText.x = groundText.x;
seaText.y = (186 + (rowHeight * 2));
addChild(groundText);
addChild(airText);
addChild(seaText);
groundIcon = new Bitmap(BitmapLibrary.loadBitmap("build_icon_ground"));
airIcon = new Bitmap(BitmapLibrary.loadBitmap("build_icon_air"));
seaIcon = new Bitmap(BitmapLibrary.loadBitmap("build_icon_sea"));
groundIcon.y = 170;
airIcon.y = (airText.y - 7);
seaIcon.y = (seaText.y - 7);
seaIcon.x = 5;
addChild(groundIcon);
addChild(airIcon);
addChild(seaIcon);
groundHeader = new Bitmap(BitmapLibrary.loadBitmap("build_header_ground"));
airHeader = new Bitmap(BitmapLibrary.loadBitmap("build_header_air"));
seaHeader = new Bitmap(BitmapLibrary.loadBitmap("build_header_sea"));
groundHeader.x = (airHeader.x = (seaHeader.x = 47));
groundHeader.y = (airHeader.y = (seaHeader.y = 22));
addChild(groundHeader);
addChild(airHeader);
addChild(seaHeader);
var headerFrame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame2"), (groundHeader.width + 30), (InfoMenu.HEIGHT + 30), 39, 39));
headerFrame.x = (groundHeader.x - 15);
headerFrame.y = (groundHeader.y - 15);
addChild(headerFrame);
infoMenu = new InfoMenu();
infoMenu.x = seaHeader.x;
infoMenu.y = seaHeader.y;
addChild(infoMenu);
infoMenu.visible = (seaHeader.visible = (airHeader.visible = false));
groundHeader.visible = true;
bg.addEventListener(MouseEvent.CLICK, clickHandler);
backButton = new TileSheetButton("closeButton");
backButton.enable();
backButton.x = ((WIDTH - backButton.width) - 8);
backButton.y = ((HEIGHT - backButton.height) - 10);
backButton.addEventListener(MouseEvent.CLICK, clickHandler);
addChild(backButton);
}
public function complete(a_unit:UnitData):void{
controller.buildUnits(a_unit, tile);
}
public function update(a_ms:uint=0):void{
var i:int;
while (i < tileSheets.length) {
tileSheets[i].update(a_ms);
i++;
};
}
public function createBlockingImage(a_width:Number, a_height:Number):Sprite{
var bg:Sprite = new Sprite();
bg.graphics.beginBitmapFill(BitmapLibrary.loadBitmap("spotted_texture"));
bg.graphics.drawRect(0, 0, a_width, a_height);
var frame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame1"), (a_width + 16), (a_height + 16), 43, 43));
frame.x = -8;
frame.y = -8;
bg.addChild(frame);
addChild(bg);
return (bg);
}
public function sortOnCost(a:UnitData, b:UnitData):Number{
var aPrice:Number = a.getCost();
var bPrice:Number = b.getCost();
if (aPrice > bPrice){
return (1);
};
if (aPrice < bPrice){
return (-1);
};
return (0);
}
protected function groundHeaderShow(a_event:Event, a_unitData:UnitData=null):void{
groundHeader.visible = true;
airHeader.visible = false;
seaHeader.visible = false;
if (a_unitData != null){
infoMenu.setUnitData(a_unitData, controller);
infoMenu.visible = true;
} else {
infoMenu.visible = false;
};
}
protected function seaHeaderShow(a_event:Event, a_unitData:UnitData=null):void{
groundHeader.visible = false;
airHeader.visible = false;
seaHeader.visible = true;
if (a_unitData != null){
infoMenu.setUnitData(a_unitData, controller);
infoMenu.visible = true;
} else {
infoMenu.visible = false;
};
}
protected function airHeaderShow(a_event:Event, a_unitData:UnitData=null):void{
groundHeader.visible = false;
airHeader.visible = true;
seaHeader.visible = false;
if (a_unitData != null){
infoMenu.setUnitData(a_unitData, controller);
infoMenu.visible = true;
} else {
infoMenu.visible = false;
};
}
function clickHandler(a_event:Event):void{
controller.clear();
}
}
}//package com.gamedozer.battalion.ui
Section 153
//BuildMenuUnit (com.gamedozer.battalion.ui.BuildMenuUnit)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import flash.geom.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
public class BuildMenuUnit extends Sprite {
protected var unit:UnitData;
protected var sprite:TileSheet;
protected var func:Function;
protected var canAfford:Boolean;
protected var isOver:Boolean;
protected var menu:BuildMenu;
public function BuildMenuUnit(a_menu:BuildMenu, a_controller:Controller, a_unit:UnitData, a_canAfford:Boolean, a_func:Function){
super();
menu = a_menu;
func = a_func;
unit = a_unit;
canAfford = a_canAfford;
var bg:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("build_unit_box_bg"));
bg.x = 10;
bg.y = 11;
addChild(bg);
sprite = TileSheetManager.getInstance().getColorised(a_unit.getName(), a_controller.getTeam().getColor());
sprite.x = (sprite.y = 10);
sprite.mouseEnabled = false;
sprite.mouseChildren = false;
var mask:Sprite = new Sprite();
mask.graphics.beginFill(0);
var radius:int = (TileManager.getInstance().getWidth() / 2);
mask.graphics.drawCircle(radius, radius, radius);
sprite.addChild(mask);
sprite.mask = mask;
if (!a_canAfford){
sprite.transform.colorTransform = new ColorTransform(0.25, 0.25, 0.25);
};
addChild(sprite);
var fg:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("build_unit_box"));
addChild(fg);
var text:TextField = new DefaultTextField();
text.x = 14;
text.y = 69;
text.width = 49;
text.height = 19;
text.mouseEnabled = false;
var format:TextFormat = new DefaultTextFormat();
format.align = TextFormatAlign.CENTER;
if (!canAfford){
format.color = 4294901760;
};
text.defaultTextFormat = format;
var cost:Number = a_unit.getCost(a_controller);
text.text = Math.round(cost).toString();
addChild(text);
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
if (a_canAfford){
addEventListener(MouseEvent.CLICK, clickHandler);
};
}
protected function clickHandler(a_event:Event):void{
menu.complete(unit);
}
protected function outHandler(a_event:Event):void{
if (isOver){
if (canAfford){
BattalionMain.getMouseCursor().setCursor("default");
sprite.playAnimation("default");
};
};
isOver = false;
}
protected function overHandler(a_event:Event):void{
if (!isOver){
if (canAfford){
BattalionMain.getMouseCursor().setCursor("select");
sprite.playAnimation("spin");
sprite.getCurrentAnimation().nextFrame();
};
func(null, unit);
};
isOver = true;
}
public function getTileSheet():TileSheet{
return (sprite);
}
}
}//package com.gamedozer.battalion.ui
Section 154
//CampaignMenu (com.gamedozer.battalion.ui.CampaignMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.audio.*;
import flash.text.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.assets.*;
import flash.filters.*;
public class CampaignMenu extends Sprite implements ModeInterface {
protected const WIDTH:int = 184;
protected const HEIGHT:int = 184;
protected var mainMenuButton:TileSheetButton;
protected var header:Bitmap;
protected var xmlLoader:XMLLoader;
protected var resources:TextField;
protected var groundUnits:TextField;
protected var minimapBitmap:Bitmap;
protected var difficulty:int;// = 1
protected var minimap:BitmapData;
protected var airUnits:TextField;
protected var chapter:TextField;
protected var levelButton:TileSheetButton;
protected var missionText:TextField;
protected var seaUnits:TextField;
protected var startButton:TileSheetButton;
protected var campaignMenuData:CampaignMenuData;
protected var icon:Bitmap;
public function CampaignMenu(){
var mission:BattalionPanel;
super();
xmlLoader = BattalionMain.getXMLLoader();
header = new Bitmap(BitmapLibrary.loadBitmap("campaign_header_jungle"));
addChild(header);
var top:BattalionPanel = new BattalionPanel(350, 100, BattalionPanel.SPOTTED, BattalionPanel.FRAME1);
top.x = 20;
top.y = -60;
addChild(top);
chapter = new DefaultTextField();
chapter.embedFonts = true;
chapter.filters = [new DropShadowFilter(2)];
var tf:TextFormat = new ChatTextFormat();
tf.size = 16;
tf.color = 0xFFFFFF;
tf.bold = true;
tf.align = TextFormatAlign.CENTER;
chapter.defaultTextFormat = tf;
chapter.x = top.x;
chapter.width = top.rWidth;
chapter.height = 40;
chapter.text = "";
addChild(chapter);
icon = new Bitmap(BitmapLibrary.loadBitmap("campaign_shield_NF"));
icon.x = 540;
icon.y = 25;
addChild(icon);
var headerHeight = 140;
var bg:MovieClip = new BattalionPanel(BattalionMain.WIDTH, (BattalionMain.HEIGHT - headerHeight));
bg.y = headerHeight;
addChild(bg);
var iconBg:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("campaign_bg_icons"));
iconBg.height = 250;
iconBg.width = (iconBg.width + 25);
iconBg.x = 15;
iconBg.y = (bg.y + 15);
addChild(iconBg);
var offsetX = 30;
groundUnits = drawIcon("build_icon_ground", (iconBg.x + offsetX), (iconBg.y + 30));
airUnits = drawIcon("build_icon_air", (iconBg.x + offsetX), (iconBg.y + 90));
seaUnits = drawIcon("build_icon_sea", (iconBg.x + offsetX), (iconBg.y + 150));
resources = drawIcon("campaign_icon_money", (iconBg.x + offsetX), (iconBg.y + 200));
mission = new BattalionPanel(330, 360, BattalionPanel.SPOTTED, BattalionPanel.FRAME2, "Mission Brief");
mission.x = ((iconBg.x + iconBg.width) + 25);
mission.y = (iconBg.y + 8);
addChild(mission);
missionText = new DefaultTextField(0);
var missionTextTF:TextFormat = new ChatTextFormat();
missionTextTF.size = 16;
missionText.defaultTextFormat = missionTextTF;
missionText.width = 320;
missionText.height = 350;
missionText.x = (mission.x + 5);
missionText.y = (mission.y + 20);
missionText.embedFonts = true;
missionText.filters = [new DropShadowFilter(2)];
addChild(missionText);
missionText.text = "";
var difficultyPanel:DifficultyPanel = new DifficultyPanel(difficultyChangedCallback);
addChild(difficultyPanel);
difficultyPanel.x = 28;
difficultyPanel.y = 440;
mainMenuButton = new TileSheetButton("menuButton");
mainMenuButton.x = 30;
mainMenuButton.y = (BattalionMain.HEIGHT - mainMenuButton.height);
addChild(mainMenuButton);
levelButton = new TileSheetButton("button_levelselect");
levelButton.x = ((mainMenuButton.x + mainMenuButton.width) + 10);
levelButton.y = (BattalionMain.HEIGHT - levelButton.height);
addChild(levelButton);
startButton = new TileSheetButton("button_startgame");
startButton.x = ((BattalionMain.WIDTH - startButton.width) + 3);
startButton.y = ((BattalionMain.HEIGHT - startButton.height) + 3);
addChild(startButton);
createMinimap(bg.y);
}
private function mainMenuHandler(a_event:Event):void{
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
}
private function startHandler(a_event:Event):void{
var campaign:CampaignManager = CampaignManager.getInstance(campaignMenuData.getCampaign());
var currentLevel:int = BattalionMain.getStorage().getInt(campaign.getLevelName(), 0);
var mapSettingsXML:XML = campaign.getMapSettings(currentLevel);
mapSettingsXML.@difficulty = difficulty;
var mapSettings:MapSettings = MapSettings.getFromXML(mapSettingsXML);
mapSettings.setCampaignName(campaignMenuData.getCampaign());
mapSettings.setCampaign(currentLevel);
var gameMenuData:GameMenuData = new GameMenuData(campaign.getMapURL(currentLevel), campaign.getMapName(currentLevel), mapSettings);
MenuManager.getInstance().createSwitchMode(new GameMenu(), gameMenuData);
}
private function createMinimap(a_y:int):void{
var mmFrame:BattalionPanel = new BattalionPanel((WIDTH - 16), 50, BattalionPanel.SPOTTED, BattalionPanel.FRAME2, "Mission Preview");
mmFrame.x = 504;
mmFrame.y = (a_y + 22);
addChild(mmFrame);
var mm:Sprite = new Sprite();
mm.graphics.beginFill(0);
mm.graphics.drawRect(0, 0, WIDTH, HEIGHT);
minimapBitmap = new Bitmap();
mm.addChild(minimapBitmap);
var frame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame1"), (WIDTH + 16), (HEIGHT + 16), 43, 43));
frame.x = -8;
frame.y = -8;
mm.addChild(frame);
mm.x = (mmFrame.x - 9);
mm.y = (mmFrame.y + 18);
addChild(mm);
}
public function gainFocus():void{
mainMenuButton.enable();
startButton.enable();
levelButton.enable();
update();
}
public function popped():void{
if (campaignMenuData.restart){
return;
};
mainMenuButton.removeEventListener(MouseEvent.CLICK, mainMenuHandler);
mainMenuButton.disable();
startButton.removeEventListener(MouseEvent.CLICK, startHandler);
startButton.disable();
levelButton.removeEventListener(MouseEvent.CLICK, levelHandler);
levelButton.disable();
parent.removeChild(this);
}
private function xmlHandler(e:Event):void{
var map:Map;
var nums:Object;
xmlLoader.removeEventListener(Event.COMPLETE, xmlHandler);
var campaign:CampaignManager = CampaignManager.getInstance(campaignMenuData.getCampaign());
var currentLevel:int = BattalionMain.getStorage().getInt(campaign.getLevelName(), 0);
var level:XML = xmlLoader.get(campaign.getMapName(currentLevel));
if (level != null){
map = new Map(level, campaign.getMapURL(currentLevel), campaign.getMapName(currentLevel));
minimap = map.generateMiniMap();
minimapBitmap.bitmapData = minimap;
minimapBitmap.x = ((WIDTH - minimapBitmap.width) / 2);
minimapBitmap.y = ((HEIGHT - minimapBitmap.height) / 2);
nums = map.getNums();
groundUnits.text = nums.ground.toString();
airUnits.text = nums.air.toString();
seaUnits.text = nums.sea.toString();
resources.text = parseInt(campaign.getMapSettings(currentLevel).@resources).toString();
};
}
private function levelHandler(a_event:Event):void{
MenuManager.getInstance().pushMode(MenuManager.campaignSelectMenu, campaignMenuData);
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
campaignMenuData = (a_data as CampaignMenuData);
if (!SoundSystem.instance.isPlaying("background")){
SoundSystem.instance.createLoop("background", AssetLibrary.createSound("UIWAV"));
};
if (campaignMenuData.restart){
startHandler(null);
} else {
update();
mainMenuButton.addEventListener(MouseEvent.CLICK, mainMenuHandler);
mainMenuButton.enable();
startButton.addEventListener(MouseEvent.CLICK, startHandler);
startButton.enable();
levelButton.addEventListener(MouseEvent.CLICK, levelHandler);
levelButton.enable();
a_container.addChild(this);
};
}
public function loseFocus():void{
mainMenuButton.disable();
startButton.disable();
levelButton.disable();
}
public function update():void{
var campaign:CampaignManager = CampaignManager.getInstance(campaignMenuData.getCampaign());
var currentLevel:int = BattalionMain.getStorage().getInt(campaign.getLevelName(), 0);
var bitmapName:String = campaign.getBG(currentLevel);
header.bitmapData = BitmapLibrary.loadBitmap(campaign.getBG(currentLevel));
icon.bitmapData = BitmapLibrary.loadBitmap(("campaign_shield_" + campaign.getTeamIcon(currentLevel)));
chapter.text = campaign.getName(currentLevel);
missionText.text = campaign.getBrief(currentLevel);
minimapBitmap.bitmapData = null;
if (minimap != null){
minimap.dispose();
};
minimap = null;
groundUnits.text = "..";
airUnits.text = "..";
seaUnits.text = "..";
resources.text = "..";
xmlLoader.addEventListener(Event.COMPLETE, xmlHandler);
xmlLoader.add(campaign.getMapURL(currentLevel), campaign.getMapName(currentLevel));
xmlLoader.load();
}
protected function drawIcon(a_bitmap:String, a_x:int, a_y:int):TextField{
var bitmap:Bitmap = new Bitmap(BitmapLibrary.loadBitmap(a_bitmap));
bitmap.x = (a_x - (bitmap.width / 2));
bitmap.y = (a_y - (bitmap.width / 2));
var tf:TextField = new DefaultTextField();
var ttf:TextFormat = new ChatTextFormat();
ttf.size = 16;
tf.defaultTextFormat = ttf;
tf.embedFonts = true;
tf.filters = [new DropShadowFilter(2)];
tf.x = (a_x + 25);
tf.y = a_y;
addChild(bitmap);
addChild(tf);
return (tf);
}
private function difficultyChangedCallback(a_newValue:int):void{
difficulty = a_newValue;
}
}
}//package com.gamedozer.battalion.ui
Section 155
//CampaignMenuData (com.gamedozer.battalion.ui.CampaignMenuData)
package com.gamedozer.battalion.ui {
import com.gamedozer.ui.modes.*;
public class CampaignMenuData extends ModeData {
protected var campaign:String;
public var restart:Boolean;
public function CampaignMenuData(a_campaign:String, restart:Boolean=false){
super();
this.restart = restart;
campaign = a_campaign;
}
public function getCampaign():String{
return (campaign);
}
}
}//package com.gamedozer.battalion.ui
Section 156
//CampaignSelectMenu (com.gamedozer.battalion.ui.CampaignSelectMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import flash.text.*;
import com.gamedozer.battalion.*;
public class CampaignSelectMenu extends Sprite implements ModeInterface {
public var buttons:Array;
public var frame:BattalionPanel;
public var backButton:TileSheetButton;
protected var campaignMenuData:CampaignMenuData;
public static const WIDTH:int = 230;
public static const HEIGHT:int = 375;
public function CampaignSelectMenu(){
super();
graphics.beginFill(0, 0.5);
graphics.drawRect(0, 0, BattalionMain.WIDTH, BattalionMain.HEIGHT);
}
public function loseFocus():void{
}
public function gainFocus():void{
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
var button:BattalionButton;
campaignMenuData = (a_data as CampaignMenuData);
a_container.addChild(this);
var campaign:CampaignManager = CampaignManager.getInstance(campaignMenuData.getCampaign());
var currentLevel:int = BattalionMain.getStorage().getInt(campaign.getCompleteName(), 0);
buttons = new Array();
var height:int = (80 + ((Math.min(currentLevel, (campaign.numLevels() - 1)) + 1) * 35));
if (frame != null){
removeChild(frame);
};
frame = new BattalionPanel(WIDTH, height);
frame.x = ((BattalionMain.WIDTH / 2) - (WIDTH / 2));
frame.y = ((BattalionMain.HEIGHT / 2) - (height / 2));
addChild(frame);
backButton = new TileSheetButton("closeButton");
backButton.x = ((WIDTH - backButton.width) - 5);
backButton.y = ((-(backButton.height) / 2) + 10);
backButton.enable();
frame.addChild(backButton);
backButton.addEventListener(MouseEvent.CLICK, backHandler);
var i:int;
while ((((i <= currentLevel)) && ((i < campaign.numLevels())))) {
button = new BattalionButton((WIDTH - 30), 25, campaign.getName(i));
button.addEventListener(MouseEvent.CLICK, buttonPressHandler);
button.x = 15;
button.y = (65 + (i * 35));
frame.addChild(button);
buttons.push(button);
i++;
};
}
public function backHandler(a_event:Event):void{
MenuManager.getInstance().popMode();
}
public function buttonPressHandler(a_event:Event):void{
var button:BattalionButton = (a_event.target as BattalionButton);
var campaign:CampaignManager = CampaignManager.getInstance(campaignMenuData.getCampaign());
var i:int;
while (i < buttons.length) {
if (buttons[i] == button){
BattalionMain.getStorage().setInt(campaign.getLevelName(), i);
break;
};
i++;
};
MenuManager.getInstance().popMode();
}
public function popped():void{
backButton.removeEventListener(MouseEvent.CLICK, backHandler);
parent.removeChild(this);
var i:int;
while (i < buttons.length) {
buttons[i].removeEventListener(MouseEvent.CLICK, buttonPressHandler);
frame.removeChild(buttons[i]);
i++;
};
buttons = null;
}
}
}//package com.gamedozer.battalion.ui
Section 157
//ChatTextFormat (com.gamedozer.battalion.ui.ChatTextFormat)
package com.gamedozer.battalion.ui {
import flash.text.*;
public class ChatTextFormat extends TextFormat {
public function ChatTextFormat(){
super("TahomaEmbedded", 15, 0xFFFFFF);
}
}
}//package com.gamedozer.battalion.ui
Section 158
//ChatWindow (com.gamedozer.battalion.ui.ChatWindow)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import flash.filters.*;
public class ChatWindow extends Sprite {
protected var message:TextField;
protected var messageIndex:int;
protected var closed:Boolean;// = false
protected var colorBar:Bitmap;
protected var continueButton:TileSheetButton;
protected var messageText:String;
protected var format:TextFormat;
protected var avatar:TileSheet;
public static var PANEL_HEIGHT:int = 154;
public function ChatWindow(a_sender:String, a_message:String, a_avatar:String, a_color:uint){
super();
var panel:BattalionPanel = new BattalionPanel(GameManager.GAME_WIDTH, PANEL_HEIGHT);
panel.alpha = 0.65;
addChild(panel);
avatar = TileSheetManager.getInstance().get("avatars");
avatar.playAnimation(a_avatar);
avatar.x = 2;
avatar.y = 2;
addChild(avatar);
colorBar = new Bitmap(ColoredSprite.colorise(BitmapLibrary.loadBitmap("colorBarLong"), null, a_color));
colorBar.x = ((avatar.x + avatar.width) + 2);
colorBar.y = avatar.y;
addChild(colorBar);
message = new DefaultTextField();
message.embedFonts = true;
message.x = ((colorBar.x + colorBar.width) + 2);
message.y = 2;
message.width = ((GameManager.GAME_WIDTH - message.x) - 5);
message.height = (PANEL_HEIGHT - 4);
format = new ChatTextFormat();
message.defaultTextFormat = format;
messageText = ((a_sender + ":\n") + insertNewLines(a_message));
message.htmlText = "";
message.defaultTextFormat = format;
messageIndex = 0;
message.filters = [new DropShadowFilter(2)];
addChild(message);
continueButton = new TileSheetButton("continueButton");
continueButton.x = (GameManager.GAME_WIDTH - 160);
continueButton.y = (PANEL_HEIGHT - 45);
continueButton.enable();
addChild(continueButton);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function display():void{
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
messageIndex = (messageText.length + 1);
message.htmlText = messageText;
message.defaultTextFormat = format;
}
public function setDisplay(a_sender:String, a_message:String, a_avatar:String, a_color:uint):void{
avatar.playAnimation(a_avatar);
removeChild(colorBar);
colorBar = new Bitmap(ColoredSprite.colorise(BitmapLibrary.loadBitmap("colorBarLong"), null, a_color));
colorBar.x = ((avatar.x + avatar.width) + 2);
colorBar.y = avatar.y;
addChild(colorBar);
if (messageIndex > messageText.length){
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
};
messageText = ((a_sender + ":\n") + insertNewLines(a_message));
message.htmlText = "";
message.defaultTextFormat = format;
messageIndex = 0;
}
public function enterFrameHandler(a_event:Event):void{
messageIndex++;
if (messageIndex > messageText.length){
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
} else {
message.htmlText = messageText.substring(0, messageIndex);
message.defaultTextFormat = format;
};
}
public function isDisplayed():Boolean{
return ((messageIndex > messageText.length));
}
private function insertNewLines(a_message:String):String{
var word:String;
var previousLineCount:Number;
var processedMessage:String = "";
a_message = a_message.split("\r").join("");
a_message = a_message.split("\\n").join("\n");
var sentences:Array = a_message.split("\n");
var strippedMessage:String = sentences.join(" <br>");
var words:Array = strippedMessage.split(" ");
processedMessage = (processedMessage + words[0]);
message.htmlText = processedMessage;
message.defaultTextFormat = format;
var w = 1;
while (w < words.length) {
word = words[w];
previousLineCount = message.numLines;
message.appendText((" " + word));
message.defaultTextFormat = format;
if (message.numLines > previousLineCount){
word = ("<br>" + word);
} else {
word = (" " + word);
};
processedMessage = (processedMessage + word);
message.htmlText = processedMessage;
message.defaultTextFormat = format;
w++;
};
message.htmlText = "";
message.defaultTextFormat = format;
return (processedMessage);
}
}
}//package com.gamedozer.battalion.ui
Section 159
//ConfirmMenu (com.gamedozer.battalion.ui.ConfirmMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import flash.display.*;
import com.gamedozer.ui.modes.*;
import flash.text.*;
import com.gamedozer.battalion.*;
public class ConfirmMenu extends Sprite implements ModeInterface {
public var backButton:TileSheetButton;
private var functionData:ConfirmMenuData;
public var text:TextField;
public var frame:BattalionPanel;
public var yesButton:TileSheetButton;
public static const WIDTH:int = 250;
public static const HEIGHT:int = 200;
public function ConfirmMenu(){
var textBox:BattalionPanel;
super();
graphics.beginFill(0, 0.5);
graphics.drawRect(0, 0, BattalionMain.WIDTH, BattalionMain.HEIGHT);
frame = new BattalionPanel(WIDTH, HEIGHT);
frame.x = ((BattalionMain.WIDTH / 2) - (WIDTH / 2));
frame.y = ((BattalionMain.HEIGHT / 2) - (HEIGHT / 2));
addChild(frame);
backButton = new TileSheetButton("noButton");
backButton.x = (((frame.x + WIDTH) - backButton.width) - 5);
backButton.y = ((frame.y - (backButton.height / 2)) + 10);
addChild(backButton);
yesButton = new TileSheetButton("yesButton");
yesButton.x = (frame.x + 5);
yesButton.y = ((frame.y - (yesButton.height / 2)) + 10);
addChild(yesButton);
textBox = new BattalionPanel(200, 75, BattalionPanel.SPOTTED, BattalionPanel.FRAME2);
textBox.x = (frame.x + 25);
textBox.y = (frame.y + 100);
addChild(textBox);
text = new DefaultTextField(0);
text.width = 190;
text.x = (textBox.x + 5);
text.y = (textBox.y + 5);
addChild(text);
}
private function yesHandler(e:MouseEvent):void{
MenuManager.getInstance().popMode();
if (functionData.yes != null){
functionData.yes();
};
}
public function gainFocus():void{
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
functionData = (a_data as ConfirmMenuData);
a_container.addChild(this);
backButton.addEventListener(MouseEvent.CLICK, backHandler);
backButton.enable();
yesButton.addEventListener(MouseEvent.CLICK, yesHandler);
yesButton.enable();
text.text = functionData.text;
}
public function loseFocus():void{
}
public function backHandler(a_event:Event):void{
MenuManager.getInstance().popMode();
if (functionData.no != null){
functionData.no();
};
}
public function popped():void{
backButton.removeEventListener(MouseEvent.CLICK, backHandler);
backButton.disable();
yesButton.removeEventListener(MouseEvent.CLICK, yesHandler);
yesButton.disable();
parent.removeChild(this);
}
}
}//package com.gamedozer.battalion.ui
Section 160
//ConfirmMenuData (com.gamedozer.battalion.ui.ConfirmMenuData)
package com.gamedozer.battalion.ui {
import com.gamedozer.ui.modes.*;
public class ConfirmMenuData extends ModeData {
public var no:Function;
public var yes:Function;
public var text:String;
public function ConfirmMenuData(text:String, yes:Function=null, no:Function=null){
super();
this.text = text;
this.yes = yes;
this.no = no;
}
}
}//package com.gamedozer.battalion.ui
Section 161
//CreditsMenu (com.gamedozer.battalion.ui.CreditsMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.ui.modes.*;
import flash.text.*;
public class CreditsMenu extends Sprite implements ModeInterface {
public var message:TextField;
public var backButton:TileSheetButton;
public var frame:BattalionPanel;
private var textBox:BattalionPanel;
public function CreditsMenu(){
super();
var bg:BitmapData = BitmapLibrary.loadBitmap("title");
addChild(new Bitmap(bg));
frame = new BattalionPanel(400, 300);
frame.x = 200;
frame.y = 150;
addChild(frame);
var creditsLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("creditsLabel"));
creditsLabel.x = (frame.x + 15);
creditsLabel.y = (frame.y + 15);
addChild(creditsLabel);
textBox = new BattalionPanel(350, 200, BattalionPanel.SPOTTED, BattalionPanel.FRAME2);
textBox.x = (frame.x + 25);
textBox.y = (frame.y + 75);
addChild(textBox);
backButton = new TileSheetButton("closeButton");
backButton.x = (((frame.x + 400) - backButton.width) - 5);
backButton.y = ((frame.y - (backButton.height / 2)) + 10);
addChild(backButton);
message = new DefaultTextField(0, TextFormatAlign.CENTER);
message.x = (textBox.x + 5);
message.y = (textBox.y + 5);
message.width = 340;
var creditsText:Array = [];
creditsText.push("Battalion Nemesis");
creditsText.push("");
creditsText.push("");
creditsText.push("An Urbansquall production");
creditsText.push("");
creditsText.push("");
creditsText.push("");
creditsText.push("");
creditsText.push("Programming:");
creditsText.push("");
creditsText.push("");
creditsText.push("Christopher Rhodes");
creditsText.push("Panayoti Haritatos");
creditsText.push("");
creditsText.push("");
creditsText.push("Art:");
creditsText.push("Christian Hildenbrand");
creditsText.push("Tim Wendorf");
creditsText.push("Anthony Blinco");
creditsText.push("Christopher Rhodes");
creditsText.push("");
creditsText.push("");
creditsText.push("Game Design:");
creditsText.push("Panayoti Haritatos");
creditsText.push("Andrew Pellerano");
creditsText.push("");
creditsText.push("");
creditsText.push("Writing:");
creditsText.push("Michael Scarpelli");
creditsText.push("");
creditsText.push("");
creditsText.push("Level Design:");
creditsText.push("Forest Go");
creditsText.push("Panayoti Haritatos");
creditsText.push("");
creditsText.push("");
creditsText.push("Sound & Music:");
creditsText.push("Matt Sayre");
creditsText.push("Zack Parrish");
creditsText.push("");
creditsText.push("");
creditsText.push("Additional Programming:");
creditsText.push("Andrew Pellerano");
creditsText.push("");
creditsText.push("");
creditsText.push("Special Thanks:");
creditsText.push("Hans Lemurson");
creditsText.push("firehawk");
creditsText.push("squarecircleco.");
creditsText.push("Sprite Attack");
message.text = creditsText.join("\n");
message.height = (message.textHeight + 5);
addChild(message);
var mask:Shape = new Shape();
mask.graphics.beginFill(0, 1);
mask.graphics.drawRect((textBox.x + 5), (textBox.y + 5), 340, 190);
mask.graphics.endFill();
addChild(mask);
message.mask = mask;
}
public function loseFocus():void{
}
public function popped():void{
backButton.removeEventListener(MouseEvent.CLICK, backHandler);
backButton.disable();
parent.removeChild(this);
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function backHandler(a_event:Event):void{
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
}
public function gainFocus():void{
}
private function enterFrameHandler(e:Event):void{
message.y = (message.y - 0.2);
if ((message.y + message.height) < (textBox.y + 5)){
message.y = ((textBox.y + 5) + 200);
};
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
a_container.addChild(this);
backButton.addEventListener(MouseEvent.CLICK, backHandler);
backButton.enable();
message.y = ((textBox.y + 5) + 200);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
}
}//package com.gamedozer.battalion.ui
Section 162
//DefaultTextField (com.gamedozer.battalion.ui.DefaultTextField)
package com.gamedozer.battalion.ui {
import flash.text.*;
public class DefaultTextField extends TextField {
public function DefaultTextField(a_color:uint=4294967295, a_align:String="left", a_bold:Boolean=false){
super();
var textFormat:TextFormat = new DefaultTextFormat();
textFormat.color = a_color;
textFormat.align = a_align;
textFormat.bold = a_bold;
defaultTextFormat = textFormat;
selectable = false;
multiline = true;
wordWrap = true;
antiAliasType = AntiAliasType.ADVANCED;
}
}
}//package com.gamedozer.battalion.ui
Section 163
//DefaultTextFormat (com.gamedozer.battalion.ui.DefaultTextFormat)
package com.gamedozer.battalion.ui {
import flash.text.*;
public class DefaultTextFormat extends TextFormat {
public function DefaultTextFormat(){
super("Tahoma", 10, 4278190080);
}
}
}//package com.gamedozer.battalion.ui
Section 164
//DifficultyOption (com.gamedozer.battalion.ui.DifficultyOption)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
import com.gamedozer.battalion.*;
public class DifficultyOption extends Sprite {
var avatar:TileSheet;
var playerName:TextField;
var colorBar:Bitmap;
public var index:int;
var rankBadge:TileSheet;
public static var WIDTH:int = 80;
public static var HEIGHT:int = 37;
public function DifficultyOption(a_index:int, a_color:uint, a_name:String, a_avatar:String){
super();
index = a_index;
var bg:Sprite = new Sprite();
bg.graphics.beginBitmapFill(BitmapLibrary.loadBitmap("spotted_texture"));
bg.graphics.drawRect(0, 0, WIDTH, HEIGHT);
addChild(bg);
colorBar = new Bitmap(ColoredSprite.colorise(BitmapLibrary.loadBitmap("colorBar"), null, a_color));
colorBar.x = 0;
colorBar.y = 2;
addChild(colorBar);
rankBadge = TileSheetManager.getInstance().get("rankBadges");
var rank = 1;
if (index == 1){
rank = 2;
};
if (index == 2){
rank = 6;
};
rankBadge.setFrame(rank);
rankBadge.x = 15;
rankBadge.y = 9;
addChild(rankBadge);
playerName = new DefaultTextField();
playerName.x = 38;
playerName.y = 9;
playerName.width = 106;
var tf:TextFormat = new DefaultTextFormat();
tf.color = 0;
playerName.defaultTextFormat = tf;
playerName.text = a_name;
addChild(playerName);
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
}
protected function overHandler(a_event:Event):void{
BattalionMain.getMouseCursor().setCursor("select");
}
protected function outHandler(a_event:Event):void{
BattalionMain.getMouseCursor().setCursor("default");
}
}
}//package com.gamedozer.battalion.ui
Section 165
//DifficultyPanel (com.gamedozer.battalion.ui.DifficultyPanel)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.*;
public class DifficultyPanel extends Sprite {
var callback:Function;
var arrow:Sprite;
var panels:Array;
public static var WIDTH:int = DifficultyOption.WIDTH;
public static var HEIGHT:int = 111;
public function DifficultyPanel(a_callback:Function){
var panel:DifficultyOption;
super();
callback = a_callback;
var mmFrame:BattalionPanel = new BattalionPanel((WIDTH - 8), 50, BattalionPanel.SPOTTED, BattalionPanel.FRAME2, "AI Difficulty");
mmFrame.x = 5;
mmFrame.y = -25;
addChild(mmFrame);
var names:Array = ["Easy", "Normal", "Hard"];
var colors:Array = [4278255360, 3435973632, 4294901760];
var avatars:Array = ["tucker", "mullen", "evil_durand_dark"];
panels = new Array();
var i:int;
while (i < 3) {
panel = new DifficultyOption(i, colors[i], names[i], avatars[i]);
panel.y = (i * PlayerPanel.HEIGHT);
addChild(panel);
panels.push(panel);
panel.addEventListener(MouseEvent.CLICK, clickPanel);
i++;
};
var frame:Bitmap = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame1"), (WIDTH + 30), (HEIGHT + 30), 39, 39));
frame.x = -15;
frame.y = -15;
addChild(frame);
arrow = new Sprite();
arrow.addChild(new Bitmap(BitmapLibrary.loadBitmap("playerpointer")));
arrow.x = (-(arrow.width) + 16);
addChild(arrow);
var difficulty:int = BattalionMain.getStorage().getInt("aidifficulty", 1);
changeSelection(difficulty);
}
public function changeSelection(index:int):void{
arrow.y = (((index * DifficultyOption.HEIGHT) + (DifficultyOption.HEIGHT / 2)) - (arrow.height / 2));
callback(index);
BattalionMain.getStorage().setInt("aidifficulty", index);
}
public function clickPanel(a_event:Event):void{
var index:int = (a_event.currentTarget as DifficultyOption).index;
changeSelection(index);
}
}
}//package com.gamedozer.battalion.ui
Section 166
//FrameMaker (com.gamedozer.battalion.ui.FrameMaker)
package com.gamedozer.battalion.ui {
import flash.display.*;
import flash.geom.*;
public class FrameMaker {
public function FrameMaker(){
super();
}
public static function fillArea(a_destination:BitmapData, a_source:BitmapData, a_destinationRectangle:Rectangle, a_sourceRectangle:Rectangle):void{
var x:int;
var destX:int = (a_destinationRectangle.x + a_destinationRectangle.width);
var destY:int = (a_destinationRectangle.y + a_destinationRectangle.height);
var y:int = a_destinationRectangle.y;
while (y < destY) {
x = a_destinationRectangle.x;
while (x < destX) {
a_destination.copyPixels(a_source, a_sourceRectangle, new Point(x, y));
x = (x + a_sourceRectangle.width);
};
y = (y + a_sourceRectangle.width);
};
}
public static function createBlock(a_bitmapData:BitmapData, a_width:int, a_height:int):Sprite{
var bitmap:Bitmap;
var mask:Sprite;
var sprite:Sprite = new Sprite();
bitmap = new Bitmap(a_bitmapData);
mask = new Sprite();
mask.graphics.beginFill(0);
mask.graphics.drawRect(0, 0, a_width, a_height);
bitmap.mask = mask;
bitmap.x = (-(Math.random()) * (bitmap.width - a_width));
bitmap.y = (-(Math.random()) * (bitmap.height - a_height));
sprite.addChild(mask);
sprite.addChild(bitmap);
return (sprite);
}
public static function createFrame(a_bitmapData:BitmapData, a_width:int, a_height:int, a_cornerWidth:int, a_cornerHeight:int, a_tileEdges:Boolean=true):BitmapData{
if (((a_cornerWidth * 2) + 1) > a_bitmapData.width){
return (null);
};
if (((a_cornerHeight * 2) + 1) > a_bitmapData.height){
return (null);
};
if ((a_cornerWidth * 2) > a_width){
return (null);
};
if ((a_cornerHeight * 2) > a_height){
return (null);
};
var frame:BitmapData = new BitmapData(a_width, a_height, a_bitmapData.transparent, a_bitmapData.getPixel32(0, 0));
fillArea(frame, a_bitmapData, new Rectangle(a_cornerWidth, 0, (a_width - a_cornerWidth), a_cornerHeight), new Rectangle(a_cornerWidth, 0, (a_bitmapData.width - (a_cornerWidth * 2)), a_cornerHeight));
fillArea(frame, a_bitmapData, new Rectangle(0, a_cornerHeight, a_cornerWidth, (a_height - a_cornerHeight)), new Rectangle(0, a_cornerWidth, a_cornerWidth, (a_bitmapData.height - (a_cornerHeight * 2))));
fillArea(frame, a_bitmapData, new Rectangle(a_cornerWidth, a_cornerHeight, (a_width - a_cornerWidth), (a_height - a_cornerHeight)), new Rectangle(a_cornerWidth, a_cornerHeight, (a_bitmapData.width - (a_cornerWidth * 2)), (a_bitmapData.height - (a_cornerHeight * 2))));
fillArea(frame, a_bitmapData, new Rectangle((a_width - a_cornerWidth), a_cornerHeight, a_cornerWidth, (a_height - a_cornerHeight)), new Rectangle((a_bitmapData.width - a_cornerWidth), a_cornerWidth, a_cornerWidth, (a_bitmapData.height - (a_cornerHeight * 2))));
fillArea(frame, a_bitmapData, new Rectangle(a_cornerWidth, (a_height - a_cornerHeight), (a_width - a_cornerWidth), a_cornerHeight), new Rectangle(a_cornerWidth, (a_bitmapData.height - a_cornerHeight), (a_bitmapData.width - (a_cornerWidth * 2)), a_cornerHeight));
frame.copyPixels(a_bitmapData, new Rectangle(0, 0, a_cornerWidth, a_cornerHeight), new Point(0, 0));
frame.copyPixels(a_bitmapData, new Rectangle((a_bitmapData.width - a_cornerWidth), 0, a_cornerWidth, a_cornerHeight), new Point((a_width - a_cornerWidth), 0));
frame.copyPixels(a_bitmapData, new Rectangle(0, (a_bitmapData.height - a_cornerHeight), a_cornerWidth, a_cornerHeight), new Point(0, (a_height - a_cornerHeight)));
frame.copyPixels(a_bitmapData, new Rectangle((a_bitmapData.width - a_cornerWidth), (a_bitmapData.height - a_cornerHeight), a_cornerWidth, a_cornerHeight), new Point((a_width - a_cornerWidth), (a_height - a_cornerHeight)));
return (frame);
}
}
}//package com.gamedozer.battalion.ui
Section 167
//GameMenu (com.gamedozer.battalion.ui.GameMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
import com.gamedozer.battalion.game.triggers.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.game.actions.*;
import flash.ui.*;
public class GameMenu extends Sprite implements ModeInterface {
protected var active:Boolean;
public var mainMenuButton:TileSheetButton;
protected var restart:Boolean;// = false
protected var lastTimer:int;// = 0
protected var cleanUpGame:Boolean;// = false
protected var earlyQuit:Boolean;// = false
public var gameMenuData:GameMenuData;
public function GameMenu(){
super();
active = false;
TweenManager.getInstance().clear();
mainMenuButton = new TileSheetButton("optionsButton");
mainMenuButton.x = 30;
mainMenuButton.y = (BattalionMain.HEIGHT - mainMenuButton.height);
mainMenuButton.disable();
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
active = false;
gameMenuData = (a_data as GameMenuData);
a_container.addChild(this);
var xmlLoader:XMLLoader = BattalionMain.getXMLLoader();
var loadData:XML = gameMenuData.getLoadData();
xmlLoader.addEventListener(Event.COMPLETE, startGame);
if (loadData == null){
xmlLoader.add(gameMenuData.getURL(), gameMenuData.getName());
} else {
xmlLoader.add(loadData.@mapurl, loadData.@mapname);
};
xmlLoader.load();
}
public function loseFocus():void{
}
public function cleanUp():void{
active = false;
var game:GameManager = GameManager.getInstance();
if (game != null){
game.dispose();
};
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
gameMenuData.setComplete(!(earlyQuit));
if (!earlyQuit){
BattalionMain.getStorage().setXML("saveGame", null);
MenuManager.getInstance().switchMode(MenuManager.gameOverMenu, gameMenuData);
} else {
if (restart){
MenuManager.getInstance().switchMode(MenuManager.campaignMenu, new CampaignMenuData(gameMenuData.getMapSettings().getCampaignName(), restart));
} else {
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
};
};
}
private function enterFrameHandler(a_event:Event):void{
var game:GameManager;
var e:String;
var a_event = a_event;
if (!active){
return;
};
var timer:int = getTimer();
var time:int = (timer - lastTimer);
lastTimer = timer;
game = GameManager.getInstance();
if (game != null){
game.update(time);
};
if (cleanUpGame){
cleanUp();
};
//unresolved jump
var _slot1 = a_error;
e = _slot1.getStackTrace();
endGame(false);
throw (new Error(e));
}
public function gainFocus():void{
}
public function popped():void{
parent.removeChild(this);
}
private function mainMenuHandler(a_event:Event):void{
if (mainMenuButton.enabled){
MenuManager.getInstance().pushMode(MenuManager.ingameOptionsMenu, null);
};
}
private function startGame(a_event:Event):void{
var map:Map;
var lmapName:String;
var lmapURL:String;
var lmap:Map;
var lmapSettings:MapSettings;
active = true;
cleanUpGame = false;
var xmlLoader:XMLLoader = BattalionMain.getXMLLoader();
xmlLoader.removeEventListener(Event.COMPLETE, startGame);
var battalion:XML = xmlLoader.get(BattalionMain.XML_NAME);
var loadData:XML = gameMenuData.getLoadData();
if (loadData == null){
map = new Map(xmlLoader.get(gameMenuData.getName()), gameMenuData.getURL(), gameMenuData.getName());
gameMenuData.getMapSettings().setMap(map);
new GameManager(this, gameMenuData.getMapSettings());
GameManager.getInstance().importBallisticsTable(xmlLoader.get(battalion..ballisticstable.@name));
} else {
lmapName = loadData.@mapname;
lmapURL = loadData.@mapurl;
lmap = new Map(xmlLoader.get(lmapName), lmapURL, lmapName);
lmapSettings = MapSettings.getFromXML(loadData..mapsettings[0]);
gameMenuData.setMapSettings(lmapSettings);
lmapSettings.setMap(lmap);
new GameManager(this, lmapSettings, loadData..script[0]);
GameManager.getInstance().importBallisticsTable(xmlLoader.get(battalion..ballisticstable.@name));
};
var gameSprite:Sprite = GameManager.getInstance().getSprite();
gameSprite.y = 9;
addChild(GameManager.getInstance().getSprite());
var frame:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("mainframe"));
addChild(frame);
addChild(GameManager.getInstance().getPlayerPanel());
addChild(GameManager.getInstance().getMiniMap());
addChild(GameManager.getInstance().getInfoMenu());
addChild(GameManager.getInstance().getEndTurnButton());
addChild(GameManager.getInstance().getNextUnitButton());
addChild(mainMenuButton);
mainMenuButton.addEventListener(MouseEvent.CLICK, mainMenuHandler);
mainMenuButton.disable();
lastTimer = getTimer();
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function endGame(a_complete:Boolean, restart:Boolean=false):void{
if (!active){
return;
};
this.restart = restart;
cleanUpGame = true;
earlyQuit = !(a_complete);
}
}
}//package com.gamedozer.battalion.ui
Section 168
//GameMenuData (com.gamedozer.battalion.ui.GameMenuData)
package com.gamedozer.battalion.ui {
import com.gamedozer.battalion.data.*;
import com.gamedozer.ui.modes.*;
public class GameMenuData extends ModeData {
protected var name:String;
protected var url:String;
protected var loadData:XML;
protected var complete:Boolean;
protected var mapSettings:MapSettings;
public function GameMenuData(a_url:String, a_name:String, a_mapSettings:MapSettings=null, a_loadData:XML=null){
super();
name = a_name;
url = a_url;
mapSettings = a_mapSettings;
loadData = a_loadData;
complete = false;
}
public function getName():String{
return (name);
}
public function getLoadData():XML{
return (loadData);
}
public function reset():void{
complete = false;
}
public function getURL():String{
return (url);
}
public function getMapSettings():MapSettings{
return (mapSettings);
}
public function toString():String{
return (((name + " ") + url));
}
public function getComplete():Boolean{
return (complete);
}
public function setComplete(a_complete:Boolean):void{
complete = a_complete;
}
public function setMapSettings(a_mapSettings:MapSettings):void{
mapSettings = a_mapSettings;
}
}
}//package com.gamedozer.battalion.ui
Section 169
//GameOverMenu (com.gamedozer.battalion.ui.GameOverMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.audio.*;
import com.kongregate.as3.client.*;
import flash.text.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.assets.*;
import flash.filters.*;
public class GameOverMenu extends Sprite implements ModeInterface {
protected var sprite:Sprite;
protected var mainMenuButton:TileSheetButton;
protected var header:Bitmap;
protected var top:BattalionPanel;
protected var icon:Bitmap;
protected var chapter:TextField;
protected var result:TextField;
protected var finalVictoryDisplay:Sprite;
protected var gameMenuData:GameMenuData;
public function GameOverMenu(){
super();
header = new Bitmap(BitmapLibrary.loadBitmap("campaign_header_jungle"));
addChild(header);
top = new BattalionPanel(350, 100, BattalionPanel.SPOTTED, BattalionPanel.FRAME1);
top.x = 20;
top.y = -60;
addChild(top);
chapter = new DefaultTextField();
chapter.embedFonts = true;
var chapTF:TextFormat = new ChatTextFormat();
chapTF.align = "center";
chapter.defaultTextFormat = chapTF;
var tf:TextFormat = new DefaultTextFormat();
tf.size = 16;
tf.color = 0xFFFFFF;
tf.bold = true;
tf.align = TextFormatAlign.CENTER;
chapter.x = top.x;
chapter.width = top.rWidth;
chapter.height = 40;
chapter.text = "";
chapter.filters = [new DropShadowFilter(2)];
addChild(chapter);
var bg:MovieClip = new BattalionPanel(BattalionMain.WIDTH, (BattalionMain.HEIGHT - header.height));
bg.y = header.height;
addChild(bg);
icon = new Bitmap(BitmapLibrary.loadBitmap("campaign_shield_NF"));
icon.x = 540;
icon.y = 25;
addChild(icon);
result = new DefaultTextField();
tf = new ChatTextFormat();
tf.size = 70;
result.width = 600;
result.autoSize = TextFieldAutoSize.LEFT;
result.x = ((BattalionMain.WIDTH / 2) - (result.width / 2));
result.y = 60;
result.defaultTextFormat = tf;
result.embedFonts = true;
result.filters = [new DropShadowFilter(2)];
addChild(result);
mainMenuButton = new TileSheetButton("button_finish");
mainMenuButton.x = ((BattalionMain.WIDTH - mainMenuButton.width) + 3);
mainMenuButton.y = ((BattalionMain.HEIGHT - mainMenuButton.height) - 3);
addChild(mainMenuButton);
}
public function loseFocus():void{
}
private function hideFinalVictoryDisplay(a_event:Event):void{
removeChild(finalVictoryDisplay);
finalVictoryDisplay = null;
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
}
private function playUI():void{
if (!SoundSystem.instance.isPlaying("background")){
SoundSystem.instance.createLoop("background", AssetLibrary.createSound("UIWAV"));
};
}
public function gainFocus():void{
}
private function mainMenuHandler(a_event:Event):void{
var campaignName:String = gameMenuData.getMapSettings().getCampaignName();
var cm:CampaignManager = CampaignManager.getInstance(campaignName);
var campaign:int = gameMenuData.getMapSettings().getCampaign();
if (((((!((campaign == -1))) && (((campaign + 1) >= cm.numLevels())))) && (!((cm.getFinalVictoryImage() == ""))))){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Completed Campaign", 1);
};
} else {
if (((((!((campaign == -1))) && (((campaign + 1) >= cm.numLevels())))) && ((campaignName == "Bootcamp")))){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Completed Bootcamp", 1);
};
};
};
if (((!((campaign == -1))) && ((campaign < (cm.numLevels() - 1))))){
MenuManager.getInstance().switchMode(MenuManager.campaignMenu, new CampaignMenuData(gameMenuData.getMapSettings().getCampaignName()));
} else {
if (((((!((campaign == -1))) && (((campaign + 1) >= cm.numLevels())))) && (!((cm.getFinalVictoryImage() == ""))))){
finalVictoryDisplay = new Sprite();
finalVictoryDisplay.addChild(new Bitmap(BitmapLibrary.loadBitmap(cm.getFinalVictoryImage())));
addChild(finalVictoryDisplay);
finalVictoryDisplay.addEventListener(MouseEvent.CLICK, hideFinalVictoryDisplay);
} else {
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
};
};
}
public function popped():void{
mainMenuButton.removeEventListener(MouseEvent.CLICK, mainMenuHandler);
mainMenuButton.disable();
removeChild(sprite);
parent.removeChild(this);
}
protected function drawBox(a_color:uint, a_alpha:Number, a_text:String, a_x:int, a_y:int, a_width:int):Sprite{
var s:Sprite = new Sprite();
var t:TextField = new DefaultTextField();
var tf:TextFormat = t.defaultTextFormat;
tf.size = 14;
t.defaultTextFormat = tf;
t.text = a_text;
t.width = a_width;
t.height = (t.textHeight + 5);
s.graphics.beginFill(a_color, a_alpha);
s.graphics.drawRect(0, 0, t.width, t.height);
s.addChild(t);
s.x = a_x;
s.y = a_y;
return (s);
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
var p:BattalionPanel;
var complete:int;
var progress:int;
var j:int;
sprite = new Sprite();
gameMenuData = (a_data as GameMenuData);
if (!gameMenuData.getComplete()){
MenuManager.getInstance().switchMode(MenuManager.mainMenu, null);
return;
};
p = new BattalionPanel(480, 0xFF, BattalionPanel.SPOTTED, BattalionPanel.FRAME2);
p.x = 135;
p.y = 200;
addChild(p);
mainMenuButton.addEventListener(MouseEvent.CLICK, mainMenuHandler);
mainMenuButton.enable();
var player:Boolean;
var playerTeam:int;
var teams:Array = gameMenuData.getMapSettings().getTeams();
var i:int;
while (i < teams.length) {
if (teams[i].getActive()){
if (teams[i].getControllerType() == "Human"){
player = true;
playerTeam = i;
};
};
i++;
};
if (player){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Games Won", 1);
};
SoundSystem.instance.playSound(SoundSystem.instance.createSound("VictoryWAV"), 1);
result.text = "You Win!";
} else {
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Games Lost", 1);
};
SoundSystem.instance.playSound(SoundSystem.instance.createSound("DefeatWAV"), 1);
result.text = "You Lose!";
};
chapter.text = "";
top.visible = false;
var campaignName:String = gameMenuData.getMapSettings().getCampaignName();
var cm:CampaignManager = CampaignManager.getInstance(campaignName);
var campaign:int = gameMenuData.getMapSettings().getCampaign();
if (campaign != -1){
if (player){
complete = BattalionMain.getStorage().getInt(cm.getCompleteName(), -1);
progress = campaign;
if ((campaign + 1) > complete){
BattalionMain.getStorage().setInt(cm.getCompleteName(), (campaign + 1));
progress = complete;
};
if ((campaign + 1) < cm.numLevels()){
BattalionMain.getStorage().setInt(cm.getLevelName(), (campaign + 1));
progress = (campaign + 1);
};
if (campaignName == "Bootcamp"){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Bootcamp Progress", (progress + 1));
};
} else {
if (campaignName == "Campaign"){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Campaign Progress", (progress + 1));
};
};
};
};
header.bitmapData = BitmapLibrary.loadBitmap(cm.getBG(campaign));
icon.bitmapData = BitmapLibrary.loadBitmap(("campaign_shield_" + cm.getTeamIcon(campaign)));
chapter.text = cm.getName(campaign);
top.visible = true;
} else {
if (player){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Completed Bonus Map", 1);
};
};
};
var titles:Array = ["Team", "Units Built", "Units Killed", "Units Lost", "Structures Captured", "Structures Lost", "Resources Collected", "Final Score"];
var s:Sprite = drawBox(0, 0, "HEIGHT TESTy", 0, 0, 100);
var wi = 150;
var he:int = s.height;
i = 0;
while (i < titles.length) {
s = drawBox(0, (((i % 2))==0) ? 0.4 : 0.5, titles[i], 50, ((header.height + 50) + (i * he)), wi);
sprite.addChild(s);
i++;
};
var bestScore:int = BattalionMain.getStorage().getInt((gameMenuData.getURL() + "_bestScore"), 0);
i = 0;
while (i < teams.length) {
teams[i].calculateFinalScore();
s = drawBox(0, (((i % 2))==0) ? 0.3 : 0.4, teams[i].getName(), (50 + ((i + 1) * wi)), (header.height + 50), wi);
sprite.addChild(s);
j = 0;
while (j < (Team.STATISTICS - 1)) {
s = drawBox(0, ((((i + j) % 2))==0) ? 0.1 : 0.2, teams[i].getStatistic(j), (50 + ((i + 1) * wi)), ((header.height + 50) + ((j + 1) * he)), wi);
sprite.addChild(s);
j++;
};
if (teams[i].getStatistic(Team.FINAL_SCORE) > bestScore){
bestScore = teams[i].getStatistic(Team.FINAL_SCORE);
};
i++;
};
BattalionMain.getStorage().setInt((gameMenuData.getURL() + "_bestScore"), bestScore);
s = drawBox(0, 0.6, ("Best Score: " + bestScore.toString()), 50, ((header.height + 50) + ((Team.STATISTICS + 1) * he)), ((teams.length + 1) * wi));
sprite.addChild(s);
sprite.x = (sprite.x + 100);
addChild(sprite);
a_container.addChild(this);
}
}
}//package com.gamedozer.battalion.ui
Section 170
//InfoIcon (com.gamedozer.battalion.ui.InfoIcon)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import flash.geom.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
public class InfoIcon extends Sprite {
protected var description:String;
protected var info:Sprite;
protected var icon:TileSheet;
protected var image:String;
public function InfoIcon(a_image:String, a_name:String, a_description:String){
super();
image = a_image;
name = a_name;
description = a_description;
icon = TileSheetManager.getInstance().get("info_icons");
icon.playAnimation(image);
addChild(icon);
icon.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
icon.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
}
override public function get width():Number{
return (icon.width);
}
override public function get height():Number{
return (icon.height);
}
function outHandler(a_event:Event):void{
if (info != null){
info.visible = false;
};
}
function overHandler(a_event:Event):void{
var infoHolder:Sprite;
var header:TextField;
var text:TextField;
var bg:Sprite;
var bgBorder:Sprite;
var p:Point;
if (info == null){
info = new Sprite();
infoHolder = new Sprite();
header = new DefaultTextField(0xFFFFFF, TextFormatAlign.CENTER);
header.text = name;
header.width = 150;
header.height = (header.textHeight + 5);
text = new DefaultTextField(0);
text.text = description;
text.width = 150;
text.width = Math.min(150, (text.textWidth + 5));
text.height = (text.textHeight + 5);
text.y = header.height;
infoHolder.addChild(header);
infoHolder.addChild(text);
bg = FrameMaker.createBlock(BitmapLibrary.loadBitmap("spotted_texture"), infoHolder.width, infoHolder.height);
bgBorder = new Sprite();
bgBorder.graphics.lineStyle(1, 0, 0.75);
bgBorder.graphics.drawRect(0, 0, infoHolder.width, infoHolder.height);
bgBorder.graphics.lineStyle(1, 0, 0);
bgBorder.graphics.beginFill(0, 0.5);
bgBorder.graphics.drawRect(0, 0, header.width, header.height);
bg.addChild(bgBorder);
info.addChild(bg);
info.addChild(infoHolder);
addChild(info);
info.y = (-(infoHolder.height) - 5);
info.x = (-(infoHolder.width) + icon.width);
p = info.localToGlobal(new Point(0, 0));
if (p.y < GameManager.getInstance().getSprite().y){
info.y = (icon.height + 5);
};
if (p.x < GameManager.getInstance().getSprite().x){
info.x = 0;
};
} else {
info.visible = true;
};
var pa:DisplayObjectContainer = parent;
parent.removeChild(this);
pa.addChild(this);
}
}
}//package com.gamedozer.battalion.ui
Section 171
//InfoMenu (com.gamedozer.battalion.ui.InfoMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import flash.geom.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.game.controllers.*;
public class InfoMenu extends Sprite {
var bg:Sprite;
var active;
var rangeText:TextField;
var sprite:GameSprite;
var title:TextField;
var controller:Controller;// = null
var weaponText:TextField;
var lock:Boolean;
var info:Sprite;
var healthText:TextField;
var icons:Array;
public static const ICONY:int = 16;
public static const ICONW:int = 56;
public static const WIDTH:int = 130;
public static const HEIGHT:int = 153;
public function InfoMenu(a_frame:Boolean=true){
var frame:Bitmap;
icons = new Array();
super();
bg = new Sprite();
var bgBitmap:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("playerboxbehind"));
bgBitmap.height = HEIGHT;
bgBitmap.width = WIDTH;
bg.addChild(bgBitmap);
if (a_frame){
frame = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame2"), (WIDTH + 30), (HEIGHT + 30), 39, 39));
frame.x = -15;
frame.y = -15;
bg.addChild(frame);
};
addChild(bg);
title = new DefaultTextField();
title.width = WIDTH;
title.height = ICONY;
var format:TextFormat = new DefaultTextFormat();
format.align = TextFormatAlign.CENTER;
format.bold = true;
title.defaultTextFormat = format;
addChild(title);
lock = false;
active = null;
}
public function update():void{
var a_unit:Unit;
var health:String;
var fireRange:String;
var weapon:String;
var range:String;
var a_tile:Tile;
if ((active is Unit)){
if (active.isAlive()){
a_unit = (active as Unit);
health = ((Math.floor(a_unit.getHealth()) + "/") + a_unit.getUnitData().getHealth());
fireRange = (((("[" + a_unit.getUnitData().getWeaponRangeMin()) + "-") + a_unit.getUnitData().getWeaponRangeMax()) + "]");
if ((((a_unit.getUnitData().getWeaponRangeMin() == 1)) && ((a_unit.getUnitData().getWeaponRangeMax() == 1)))){
fireRange = "";
};
weapon = ((a_unit.getUnitData().getDamage() + " ") + fireRange);
if (a_unit.getUnitData().getDamage() <= 0){
weapon = "N/A";
};
range = a_unit.getUnitData().getRange().toString();
healthText.text = health;
weaponText.text = weapon;
rangeText.text = range;
} else {
if (info != null){
if (info.parent != null){
removeChild(info);
};
info = null;
};
if (sprite != null){
if (sprite.parent != null){
bg.removeChild(sprite);
};
sprite = null;
};
title.text = "";
};
} else {
if ((active is Tile)){
a_tile = (active as Tile);
if (controller != a_tile.getController()){
active = null;
setTile(a_tile, false, true);
};
};
};
}
public function clear():void{
active = null;
}
public function setUnitData(a_unitData:UnitData, a_controller:Controller, a_lock:Boolean=false):void{
var gu:GameUnit = new GameUnit(TileSheetManager.getInstance().getColorised(a_unitData.getSprite(), a_controller.getTeam().getColor()));
var unit:Unit = new Unit(gu, a_unitData);
setUnit(unit, a_lock);
}
public function setUnit(a_unit:Unit, a_lock:Boolean=false):void{
if (lock){
return;
};
lock = a_lock;
if (a_unit == null){
return;
};
if (a_unit == active){
return;
};
active = a_unit;
icons.splice(0);
if (sprite != null){
bg.removeChild(sprite);
sprite = null;
};
if (info != null){
removeChild(info);
info = null;
};
sprite = a_unit.getGameUnit().getSprite().clone();
sprite.y = (ICONY + ((ICONW - sprite.height) / 2));
sprite.x = (((ICONW - sprite.width) / 2) + 1);
bg.addChildAt(sprite, 1);
title.text = a_unit.getUnitData().getName();
info = new Sprite();
addChild(info);
var padding = 2;
var armorTitle:String = ("Armor: " + UnitData.titleArmorTypes[a_unit.getUnitData().getArmorType()]);
var armorDescription:String = UnitData.descriptionArmorTypes[a_unit.getUnitData().getArmorType()];
var health:String = ((Math.floor(a_unit.getHealth()) + "/") + a_unit.getUnitData().getHealth());
healthText = drawIcon((ICONW + padding), (ICONY + 1), ("armor_" + UnitData.armorTypes[a_unit.getUnitData().getArmorType()]), "Health:", health, armorTitle, armorDescription);
var weaponTitle:String = ("Weapon: " + UnitData.titleWeaponTypes[a_unit.getUnitData().getWeaponType()]);
var weaponDescription:String = "This unit cannot fire.";
if (a_unit.getUnitData().getDamage() > 0){
weaponDescription = (((("This unit does " + a_unit.getUnitData().getDamage()) + " damage against normal armor. ") + UnitData.descriptionWeaponTypes[a_unit.getUnitData().getWeaponType()]) + "\n\n");
if (a_unit.getUnitData().getWeaponRangeMax() > 1){
weaponDescription = (weaponDescription + (((("This unit can fire on enemy units that are " + a_unit.getUnitData().getWeaponRangeMin()) + " to ") + a_unit.getUnitData().getWeaponRangeMax()) + " squares away."));
} else {
weaponDescription = (weaponDescription + "This unit can only fire on neighboring enemy units.");
};
};
var weapon = (((((a_unit.getUnitData().getDamage() + " (") + a_unit.getUnitData().getWeaponRangeMin()) + "-") + a_unit.getUnitData().getWeaponRangeMax()) + ")");
weaponText = drawIcon((ICONW + padding), (ICONY + 22), ("weapon_" + UnitData.weaponTypes[a_unit.getUnitData().getWeaponType()]), "Damage:", weapon, weaponTitle, weaponDescription);
var range:String = a_unit.getUnitData().getRange().toString();
var rangeTitle:String = ("Movement: " + UnitData.titleMovementTypes[a_unit.getUnitData().getMovementType()]);
var rangeDescription:String = UnitData.descriptionMovementTypes[a_unit.getUnitData().getMovementType()];
rangeText = drawIcon((ICONW + padding), (ICONY + 43), UnitData.movementTypes[a_unit.getUnitData().getMovementType()], "Move:", range, rangeTitle, rangeDescription);
var description:TextField = createDescription();
description.text = a_unit.getUnitData().getDescription();
description.y = ((54 + 16) + 5);
info.addChild(description);
drawModifiers(a_unit.getUnitData().getAllModifiers());
}
public function isMousingOverInfo():Boolean{
var icon:DisplayObject;
if (info == null){
return (false);
};
if (icons == null){
return (false);
};
var mx:int = info.mouseX;
var my:int = info.mouseY;
var i:int;
while (i < icons.length) {
icon = icons[i];
if (mx > icon.x){
if (mx < (icon.x + icon.width)){
if (my > icon.y){
if (my < (icon.y + icon.height)){
return (true);
};
};
};
};
i++;
};
return (false);
}
protected function drawIcon(a_x:int, a_y:int, a_image:String, a_textHeader:String, a_text:String, a_name:String, a_description:String):TextField{
var icon:InfoIcon = new InfoIcon(a_image, a_name, a_description);
icon.x = a_x;
icon.y = a_y;
var textHeader:TextField = new DefaultTextField(0, TextFormatAlign.LEFT, true);
textHeader.x = ((a_x + icon.width) + 2);
textHeader.y = (a_y - 4);
textHeader.text = a_textHeader;
var text:TextField = new DefaultTextField(0);
text.x = ((a_x + icon.width) + 2);
text.y = (a_y + 6);
text.text = a_text;
info.addChild(textHeader);
info.addChild(text);
info.addChild(icon);
icons.push(icon);
return (text);
}
protected function drawModifiers(a_modifiers:Array):void{
var mod:Modifier;
var icon:InfoIcon;
var drawn = 1;
var offsetX = -5;
var offsetY = -5;
var i:int;
while (i < a_modifiers.length) {
mod = a_modifiers[i];
if (mod.getVisible()){
icon = new InfoIcon(mod.getImage(), mod.getName(), mod.getDescription());
icon.y = ((HEIGHT - icon.height) + offsetX);
icon.x = ((WIDTH - (drawn * (1 + icon.width))) + offsetY);
info.addChild(icon);
icons.push(icon);
drawn++;
};
i++;
};
}
private function createDescription():TextField{
var descriptionPadding = 2;
var description:TextField = new DefaultTextField(4278190080);
description.x = descriptionPadding;
description.y = 16;
description.width = (WIDTH - (descriptionPadding * 2));
description.height = 75;
return (description);
}
public function setLock(a_lock:Boolean):void{
lock = a_lock;
}
public function getActive(){
return (active);
}
public function setTile(a_tile:Tile, a_lock:Boolean=false, a_ignoreUnit:Boolean=false):void{
if (lock){
return;
};
lock = a_lock;
if (a_tile == null){
return;
};
if (((!((a_tile.getUnit() == null))) && (!(a_ignoreUnit)))){
if (((!(a_tile.getUnit().isCloaked())) || ((a_tile.getUnit().getController() == GameManager.getInstance().getActiveController())))){
setUnit(a_tile.getUnit());
return;
};
};
if (a_tile == active){
return;
};
icons.splice(0);
active = a_tile;
if (sprite != null){
bg.removeChild(sprite);
sprite = null;
};
if (info != null){
removeChild(info);
info = null;
};
if (a_tile.isStructure()){
sprite = a_tile.getStructure().clone();
} else {
sprite = a_tile.getGameTile().getSprite().clone();
};
sprite.y = (HEIGHT - TileManager.getInstance().getHeight());
if (sprite.height > TileManager.getInstance().getHeight()){
sprite.y = (sprite.y - (sprite.height - TileManager.getInstance().getHeight()));
};
sprite.y = (sprite.y - 5);
sprite.x = (((ICONW - TileManager.getInstance().getWidth()) / 2) + 3);
bg.addChildAt(sprite, 1);
var terrainName:String = a_tile.getTerrain().getName();
if (terrainName == "Factory"){
terrainName = "Warfactory";
};
title.text = terrainName;
info = new Sprite();
addChild(info);
var description:TextField = createDescription();
description.text = a_tile.getTerrain().getDescription();
info.addChild(description);
drawModifiers(a_tile.getTerrain().getModifiers());
controller = a_tile.getController();
}
}
}//package com.gamedozer.battalion.ui
Section 172
//IngameOptionsMenu (com.gamedozer.battalion.ui.IngameOptionsMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.audio.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
public class IngameOptionsMenu extends Sprite implements ModeInterface {
public var backButton:TileSheetButton;
public var saveButton:TileSheetButton;
public var quitAndNoSaveButton:TileSheetButton;
public var restartButton:TileSheetButton;
public var soundButton:ToggleableTileSheetButton;
public var dialogButton:ToggleableTileSheetButton;
public var frame:BattalionPanel;
public var musicButton:ToggleableTileSheetButton;
public static const WIDTH:int = 560;
public static const HEIGHT:int = 230;
public function IngameOptionsMenu(){
var topPadding:int;
super();
graphics.beginFill(0, 0.5);
graphics.drawRect(0, 0, BattalionMain.WIDTH, BattalionMain.HEIGHT);
frame = new BattalionPanel(WIDTH, HEIGHT);
frame.x = ((BattalionMain.WIDTH / 2) - (WIDTH / 2));
frame.y = ((BattalionMain.HEIGHT / 2) - (HEIGHT / 2));
addChild(frame);
backButton = new TileSheetButton("closeButton");
backButton.x = (((frame.x + WIDTH) - backButton.width) - 5);
backButton.y = (((frame.y + HEIGHT) - backButton.height) - 5);
addChild(backButton);
topPadding = 110;
restartButton = new TileSheetButton("restartButton");
restartButton.x = (frame.x + 5);
restartButton.y = ((frame.y - restartButton.height) + topPadding);
addChild(restartButton);
saveButton = new TileSheetButton("saveButton");
saveButton.x = ((restartButton.x + restartButton.width) + 5);
saveButton.y = ((frame.y - saveButton.height) + topPadding);
addChild(saveButton);
quitAndNoSaveButton = new TileSheetButton("quitAndNoSaveButton");
quitAndNoSaveButton.x = (saveButton.x + saveButton.width);
quitAndNoSaveButton.y = ((frame.y - quitAndNoSaveButton.height) + topPadding);
addChild(quitAndNoSaveButton);
var soundLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("SoundLabel"));
soundLabel.x = (frame.x + 20);
soundLabel.y = ((restartButton.y + restartButton.height) + 15);
addChild(soundLabel);
soundButton = new ToggleableTileSheetButton("soundButton");
soundButton.x = soundLabel.x;
soundButton.y = (soundLabel.y + 25);
addChild(soundButton);
var musicLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("MusicLabel"));
musicLabel.x = ((soundButton.x + soundButton.width) + 25);
musicLabel.y = soundLabel.y;
addChild(musicLabel);
musicButton = new ToggleableTileSheetButton("musicButton");
musicButton.x = musicLabel.x;
musicButton.y = (musicLabel.y + 25);
addChild(musicButton);
var dialogLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("dialogLabel"));
dialogLabel.x = ((musicButton.x + musicButton.width) + 25);
dialogLabel.y = musicLabel.y;
addChild(dialogLabel);
dialogButton = new ToggleableTileSheetButton("dialogButton");
dialogButton.x = dialogLabel.x;
dialogButton.y = (dialogLabel.y + 25);
addChild(dialogButton);
update();
}
public function loseFocus():void{
}
private function scheduleStorageIncrease():void{
this.addEventListener(Event.ENTER_FRAME, tickIncreaseStorage);
}
private function quitAndNoSaveConfirm():void{
GameManager.getInstance().getParent().endGame(false);
}
private function saveHandler(e:MouseEvent):void{
var increasedStorage:int = BattalionMain.getStorage().getInt("increasedStorage", 0);
if (increasedStorage == 0){
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, new ConfirmMenuData("In order to save your game, we need more game storage. Please click \"Yes\" to open the storage increase popup or \"No\" to cancel and return to the options menu.", scheduleStorageIncrease));
return;
};
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, new ConfirmMenuData("Are you sure you want to save and quit? You can continue from this point in the main menu when you return.", saveConfirm));
}
private function update():void{
soundButton.toggled = BattalionMain.getStorage().getBoolean("sound", true);
musicButton.toggled = BattalionMain.getStorage().getBoolean("music", true);
dialogButton.toggled = BattalionMain.getStorage().getBoolean("dialog", true);
}
private function saveConfirm():void{
BattalionMain.getStorage().setXML("saveGame", GameManager.getInstance().toXML());
GameManager.getInstance().getParent().endGame(false);
}
private function restartHandler(e:MouseEvent):void{
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, new ConfirmMenuData("Are you sure you want to restart?", restartConfirm));
}
public function gainFocus():void{
}
public function popped():void{
BattalionMain.setMusicButtonVisibility(true);
backButton.removeEventListener(MouseEvent.CLICK, backHandler);
backButton.disable();
restartButton.removeEventListener(MouseEvent.CLICK, restartHandler);
restartButton.disable();
quitAndNoSaveButton.removeEventListener(MouseEvent.CLICK, quitAndNoSaveHandler);
quitAndNoSaveButton.disable();
saveButton.removeEventListener(MouseEvent.CLICK, saveHandler);
saveButton.disable();
soundButton.removeEventListener(Event.CHANGE, soundHandler);
musicButton.removeEventListener(Event.CHANGE, musicHandler);
dialogButton.removeEventListener(Event.CHANGE, dialogHandler);
parent.removeChild(this);
}
private function dialogHandler(e:Event):void{
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("dialog", e.target.toggled);
}
public function backHandler(a_event:Event):void{
MenuManager.getInstance().popMode();
}
private function quitAndNoSaveHandler(e:MouseEvent):void{
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, new ConfirmMenuData("Are you sure you want to quit without saving? You will have to restart this mission when you return.", quitAndNoSaveConfirm));
}
private function musicHandler(e:Event):void{
var musicValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("music", musicValue);
BattalionMain.updateSoundSystem();
}
private function restartConfirm():void{
GameManager.getInstance().getParent().endGame(false, true);
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
BattalionMain.setMusicButtonVisibility(false);
a_container.addChild(this);
backButton.addEventListener(MouseEvent.CLICK, backHandler);
backButton.enable();
restartButton.addEventListener(MouseEvent.CLICK, restartHandler);
restartButton.enable();
quitAndNoSaveButton.addEventListener(MouseEvent.CLICK, quitAndNoSaveHandler);
quitAndNoSaveButton.enable();
saveButton.addEventListener(MouseEvent.CLICK, saveHandler);
saveButton.enable();
soundButton.addEventListener(Event.CHANGE, soundHandler);
soundButton.enable();
musicButton.addEventListener(Event.CHANGE, musicHandler);
musicButton.enable();
dialogButton.addEventListener(Event.CHANGE, dialogHandler);
dialogButton.enable();
update();
}
private function soundHandler(e:Event):void{
var soundValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("sound", soundValue);
BattalionMain.updateSoundSystem();
}
private function tickIncreaseStorage(a_event:Event):void{
if (!BattalionMain.getStorage().hasAllocatedSpace(500000)){
return;
};
BattalionMain.getStorage().setInt("increasedStorage", 1);
this.removeEventListener(Event.ENTER_FRAME, tickIncreaseStorage);
saveConfirm();
}
}
}//package com.gamedozer.battalion.ui
Section 173
//LoadingPanel (com.gamedozer.battalion.ui.LoadingPanel)
package com.gamedozer.battalion.ui {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.assets.*;
public class LoadingPanel extends Sprite {
var m_ticksBeforeHighlightChange:int;// = 0
var m_yHighlight:int;// = 0
var m_xHighlight:int;// = 0
var m_timer:Timer;
var m_yDirection:int;// = 1
var m_loadingPanels:Array;
private static const MAX_DISTANCE:int = 5;
private static const TILE_SIZE:Number = 56;
private static const PANEL_X_COUNT:int = Math.ceil((BattalionMain.WIDTH / TILE_SIZE));
private static const PANEL_Y_COUNT:int = Math.ceil((600 / TILE_SIZE));
public function LoadingPanel(){
var indexX:int;
var indexY:int;
var red:Bitmap;
super();
this.graphics.beginFill(0);
this.graphics.drawRect(0, 0, BattalionMain.WIDTH, 600);
m_timer = new Timer(60);
m_timer.addEventListener(TimerEvent.TIMER, tick);
m_timer.start();
var bitmapData:BitmapData = AssetLibrary.createBitmapData("selectRed");
m_loadingPanels = new Array();
indexX = 0;
while (indexX < PANEL_X_COUNT) {
m_loadingPanels.push(new Array());
indexY = 0;
while (indexY < PANEL_Y_COUNT) {
red = new Bitmap(bitmapData);
red.x = (TILE_SIZE * indexX);
red.y = (TILE_SIZE * indexY);
red.alpha = 0;
addChild(red);
m_loadingPanels[indexX].push(red);
indexY++;
};
indexX++;
};
var tf:TextField = new DefaultTextField(0xFFFFFF);
var df:TextFormat = new ChatTextFormat();
tf.embedFonts = true;
df.size = 26;
tf.defaultTextFormat = df;
tf.text = "Loading";
tf.autoSize = TextFieldAutoSize.LEFT;
tf.x = (BattalionMain.WIDTH - tf.width);
tf.y = (600 - tf.height);
this.addChild(tf);
}
private function updateHighlight():void{
var indexY:int;
var distance:int;
var alpha:Number;
var red:Bitmap;
if (m_xHighlight >= PANEL_X_COUNT){
m_xHighlight = 0;
};
if ((((m_yHighlight >= PANEL_X_COUNT)) || ((m_yHighlight < 0)))){
m_yDirection = (m_yDirection * -1);
};
var indexX:int;
while (indexX < PANEL_X_COUNT) {
indexY = 0;
while (indexY < PANEL_Y_COUNT) {
distance = (Math.abs((m_xHighlight - indexX)) + Math.abs((m_yHighlight - indexY)));
alpha = (distance / MAX_DISTANCE);
red = m_loadingPanels[indexX][indexY];
red.alpha = (1 - alpha);
indexY++;
};
indexX++;
};
m_xHighlight++;
m_yHighlight = (m_yHighlight + m_yDirection);
}
public function stop():void{
m_timer.removeEventListener(TimerEvent.TIMER, tick);
m_timer.stop();
m_timer = null;
this.removeEventListener(Event.ENTER_FRAME, tick, false);
this.addEventListener(Event.ENTER_FRAME, fadeOut);
}
public function fadeOut(a_event:Event):void{
this.alpha = (this.alpha - 0.07);
if (this.alpha <= 0.1){
this.removeEventListener(Event.ENTER_FRAME, fadeOut);
this.parent.removeChild(this);
};
}
private function tick(a_event:TimerEvent):void{
if (this.parent.getChildIndex(this) < (this.parent.numChildren - 1)){
this.parent.setChildIndex(this, (this.parent.numChildren - 1));
};
updateHighlight();
}
}
}//package com.gamedozer.battalion.ui
Section 174
//MainMenu (com.gamedozer.battalion.ui.MainMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.audio.*;
import com.kongregate.as3.client.*;
import flash.text.*;
import com.gamedozer.battalion.*;
import com.gamedozer.battalion.assets.*;
import flash.filters.*;
public class MainMenu extends Sprite implements ModeInterface {
public var bonusMapButton:TileSheetButton;
var menu:MainMenu;
public var restoreButton:TileSheetButton;
public var campaignButton:TileSheetButton;
public var bootCampButton:TileSheetButton;
public var frame:BattalionPanel;
public var optionsButton:TileSheetButton;
public function MainMenu(){
var sponsorLogo:GameSprite;
var sponsorLogoButton:GameButton;
super();
updateStats();
var bg:BitmapData = BitmapLibrary.loadBitmap("title");
addChild(new Bitmap(bg));
var buttonWidth:Number = 172;
var buttonHeight:Number = 140;
var padding:Number = 10;
var panelWidth:Number = ((4 * buttonWidth) + (2 * padding));
var panelHeight:Number = (buttonHeight + (2 * padding));
frame = new BattalionPanel(panelWidth, panelHeight);
frame.x = ((BattalionMain.WIDTH - panelWidth) / 2);
frame.y = 380;
addChild(frame);
restoreButton = new TileSheetButton("restoreButton");
restoreButton.x = ((392 - (restoreButton.width / 2)) + 12);
restoreButton.y = (600 - restoreButton.height);
addChild(restoreButton);
bootCampButton = new TileSheetButton("bootCampButton");
bootCampButton.x = (padding + 14);
bootCampButton.y = (padding + 15);
frame.addChild(bootCampButton);
campaignButton = new TileSheetButton("campaignButton");
campaignButton.x = ((bootCampButton.x + bootCampButton.width) + padding);
campaignButton.y = padding;
frame.addChild(campaignButton);
optionsButton = new TileSheetButton("optionsMainButton");
optionsButton.x = ((campaignButton.x + campaignButton.width) + padding);
optionsButton.y = (((padding + campaignButton.height) - optionsButton.height) + 2);
frame.addChild(optionsButton);
bonusMapButton = new TileSheetButton("bonusMapButton");
bonusMapButton.x = ((optionsButton.x + optionsButton.width) + padding);
bonusMapButton.y = ((padding + bonusMapButton.height) - bonusMapButton.height);
frame.addChild(bonusMapButton);
if (Sponsor.getInstance().hasTitleLogo()){
sponsorLogo = new GameSprite();
sponsorLogo.addChild(new Bitmap(BitmapLibrary.loadBitmap(Sponsor.getInstance().getTitleLogo())));
sponsorLogoButton = new GameButton(sponsorLogo, "select");
sponsorLogoButton.x = ((BattalionMain.WIDTH / 2) - (sponsorLogo.width / 2));
sponsorLogoButton.y = Sponsor.getInstance().getTitleLogoYPosition();
sponsorLogoButton.addEventListener(MouseEvent.CLICK, BattalionMain.visitSponsor);
sponsorLogoButton.addEventListener(MouseEvent.ROLL_OVER, rolloverSponsor);
sponsorLogoButton.addEventListener(MouseEvent.ROLL_OUT, rolloutSponsor);
addChild(sponsorLogoButton);
};
menu = this;
}
public function loseFocus():void{
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
if (!SoundSystem.instance.isPlaying("background")){
SoundSystem.instance.createLoop("background", AssetLibrary.createSound("UIWAV"));
};
var save:XML = BattalionMain.getStorage().getXML("saveGame", null);
if (save != null){
restoreButton.addEventListener(MouseEvent.CLICK, continueHandler);
restoreButton.enabled = true;
restoreButton.alpha = 1;
restoreButton.enable();
restoreButton.visible = true;
} else {
restoreButton.visible = false;
restoreButton.enabled = false;
restoreButton.disable();
};
campaignButton.enable();
bootCampButton.enable();
optionsButton.enable();
bonusMapButton.enable();
campaignButton.addEventListener(MouseEvent.CLICK, campaignButtonHandler);
bonusMapButton.addEventListener(MouseEvent.CLICK, bonusMapButtonHandler);
bootCampButton.addEventListener(MouseEvent.CLICK, bootCampHandler);
optionsButton.addEventListener(MouseEvent.CLICK, optionsHandler);
a_container.addChild(menu);
}
private function rolloverSponsor(a_event:MouseEvent):void{
var logo:DisplayObject = (a_event.target as DisplayObject);
logo.filters = [new GlowFilter(0xBF0000, 1, 10, 10)];
}
private function optionsHandler(e:MouseEvent):void{
MenuManager.getInstance().pushMode(MenuManager.optionsMenu, null);
}
private function updateStats():void{
var campaignName:String;
var cm:CampaignManager;
var currentLevel:int;
var complete:int;
var campaignNames:Array = ["Bootcamp", "Campaign"];
var i:int;
while (i < campaignNames.length) {
campaignName = campaignNames[i];
cm = CampaignManager.getInstance(campaignName);
if (cm != null){
currentLevel = BattalionMain.getStorage().getInt(cm.getLevelName(), 0);
complete = BattalionMain.getStorage().getInt(cm.getCompleteName(), -1);
trace(("Complete " + complete));
trace(("Num levels " + cm.numLevels()));
if (complete >= cm.numLevels()){
if (campaignName == "Bootcamp"){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Completed Bootcamp", 1);
};
} else {
if (campaignName == "Campaign"){
if (Sponsor.getInstance().isKongregate()){
KongregateAPI.getInstance().stats.submit("Completed Campaign", 1);
};
};
};
};
};
i++;
};
}
function campaignButtonHandler(a_event:MouseEvent):void{
var data:ConfirmMenuData;
var storage:Storage = BattalionMain.getStorage();
if (!storage.getBoolean("attemptedBootcamp", false)){
data = new ConfirmMenuData("Boot Camp has a lot of tactical information that will make it easier to tackle the Campaign. Are you sure you want to do the Campaign without doing Boot Camp first? ", startCampaign);
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, data);
return;
};
startCampaign();
}
public function gainFocus():void{
}
function startCampaign():void{
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("attemptedBootcamp", true);
var xmlLoader:XMLLoader = BattalionMain.getXMLLoader();
var battalion:XML = xmlLoader.get(BattalionMain.XML_NAME);
MenuManager.getInstance().switchMode(MenuManager.campaignMenu, new CampaignMenuData("Campaign"));
}
private function continueHandler(e:MouseEvent):void{
MenuManager.getInstance().createSwitchMode(new GameMenu(), new GameMenuData("", "", null, BattalionMain.getStorage().getXML("saveGame", null)));
BattalionMain.getStorage().setXML("saveGame", null);
}
private function rolloutSponsor(a_event:MouseEvent):void{
var logo:DisplayObject = (a_event.target as DisplayObject);
logo.filters = [];
}
public function popped():void{
campaignButton.removeEventListener(MouseEvent.CLICK, campaignButtonHandler);
bonusMapButton.removeEventListener(MouseEvent.CLICK, bonusMapButtonHandler);
bootCampButton.removeEventListener(MouseEvent.CLICK, bootCampHandler);
optionsButton.removeEventListener(MouseEvent.CLICK, optionsHandler);
restoreButton.removeEventListener(MouseEvent.CLICK, continueHandler);
menu.parent.removeChild(menu);
campaignButton.disable();
restoreButton.disable();
bootCampButton.disable();
optionsButton.disable();
}
function bootCampHandler(a_event:MouseEvent):void{
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("attemptedBootcamp", true);
var xmlLoader:XMLLoader = BattalionMain.getXMLLoader();
var battalion:XML = xmlLoader.get(BattalionMain.XML_NAME);
MenuManager.getInstance().switchMode(MenuManager.campaignMenu, new CampaignMenuData("Bootcamp"));
}
function bonusMapButtonHandler(a_event:MouseEvent):void{
var data:ConfirmMenuData;
if (!BattalionMain.ALLOW_DEBUG){
if (!Sponsor.getInstance().isPlayingOnSponsorSite()){
data = new ConfirmMenuData("The bonus level is available only on Kongregate. Click \"Yes\" to open Battalion on Kongregate in a new window, or click \"No\" to return to the main menu.", BattalionMain.visitKongregatesBattalionPage);
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, data);
return;
};
};
var xmlLoader:XMLLoader = BattalionMain.getXMLLoader();
var battalion:XML = xmlLoader.get(BattalionMain.XML_NAME);
var mapSettings:MapSettings = new MapSettings(int.MAX_VALUE, 500, 1);
mapSettings.addTeam(new Team("Red Team", "Red Federation", "tucker", 6, 4294901760, battalion.player1.@type, 0));
mapSettings.addTeam(new Team("Blue Team", "Blue Constitution", "durand", 1, 4278190335, battalion.player2.@type, 0));
var gameMenuData:GameMenuData = new GameMenuData(battalion.loadmap.@url, battalion.loadmap.@name, mapSettings);
MenuManager.getInstance().createSwitchMode(new GameMenu(), gameMenuData);
}
}
}//package com.gamedozer.battalion.ui
Section 175
//MenuManager (com.gamedozer.battalion.ui.MenuManager)
package com.gamedozer.battalion.ui {
import flash.display.*;
import com.gamedozer.ui.modes.*;
public class MenuManager extends ModeManager {
public static const gameOverMenu:String = "gameOverMenu";
public static const ingameOptionsMenu:String = "ingameOptionsMenu";
public static const campaignSelectMenu:String = "campaignSelectMenu";
public static const campaignMenu:String = "campaignMenu";
public static const mainMenu:String = "mainMenu";
public static const creditsMenu:String = "creditsMenu";
public static const optionsMenu:String = "optionsMenu";
public static const confirmMenu:String = "confirmMenu";
static var singleton:MenuManager;
public function MenuManager(a_container:DisplayObjectContainer){
super(a_container);
singleton = this;
createModes();
}
public function createModes():void{
registerMode(mainMenu, new MainMenu());
registerMode(campaignMenu, new CampaignMenu());
registerMode(gameOverMenu, new GameOverMenu());
registerMode(campaignSelectMenu, new CampaignSelectMenu());
registerMode(optionsMenu, new OptionsMenu());
registerMode(ingameOptionsMenu, new IngameOptionsMenu());
registerMode(confirmMenu, new ConfirmMenu());
registerMode(creditsMenu, new CreditsMenu());
}
public static function getInstance():MenuManager{
if (singleton == null){
throw (new Error("MenuManager::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.ui
Section 176
//MiniMap (com.gamedozer.battalion.ui.MiniMap)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
import com.gamedozer.battalion.*;
public class MiniMap extends Sprite {
protected var ratio:Number;
protected var dragging:Boolean;
var string:TextField;
protected var drag:Sprite;
protected var invRatio:Number;
var map:Sprite;
public static const HEIGHT:int = 184;
public static const MIN_WIDTH_FOOTPRINT:int = 132;
private static var WIDTH:int = 184;
public function MiniMap(a_map:BitmapData){
var frame:Bitmap;
super();
WIDTH = a_map.width;
WIDTH = Math.max(MIN_WIDTH_FOOTPRINT, WIDTH);
graphics.beginFill(0);
graphics.drawRect(0, 0, WIDTH, HEIGHT);
map = new Sprite();
map.addChild(new Bitmap(a_map));
map.x = ((WIDTH - map.width) / 2);
map.y = (((HEIGHT - map.height) / 2) - 4);
frame = new Bitmap(FrameMaker.createFrame(BitmapLibrary.loadBitmap("frame1"), (WIDTH + 16), (HEIGHT + 16), 43, 43));
frame.x = -8;
frame.y = -8;
addChild(map);
string = new DefaultTextField(4294967295, TextFormatAlign.CENTER);
string.width = WIDTH;
string.text = "WWW";
string.y = ((HEIGHT - string.textHeight) - 8);
graphics.beginFill(0xFF0000, 0.25);
graphics.drawRect(0, ((HEIGHT - string.textHeight) - 8), WIDTH, (string.textHeight + 8));
string.text = "";
addChild(string);
addChildAt(frame, 0);
var embelish:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("minimapembelishment"));
embelish.y = (HEIGHT - 6);
embelish.x = (WIDTH - 55);
addChild(embelish);
x = (BattalionMain.WIDTH - WIDTH);
ratio = (6 / BattalionMain.TILE_WIDTH);
invRatio = (BattalionMain.TILE_WIDTH / 6);
drag = new Sprite();
drag.graphics.lineStyle(1, 0xFFFF00, 1);
drag.graphics.beginFill(0, 0);
drag.graphics.drawRect(0, 0, Math.min(map.width, (GameManager.GAME_WIDTH * ratio)), Math.min(map.height, (GameManager.GAME_HEIGHT * ratio)));
drag.graphics.endFill();
drag.x = map.x;
drag.y = map.y;
addChild(drag);
drag.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
map.addEventListener(MouseEvent.CLICK, clickHandler);
MouseHandler.getInstance().getStage().addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
dragging = false;
}
public function setString(a_string:String):void{
string.text = a_string;
}
private function mouseMoveHandler(e:MouseEvent):void{
if (dragging){
if (MouseHandler.getInstance().isDown()){
doScroll(true);
} else {
dragging = false;
};
};
}
public function getMap():Sprite{
return (map);
}
private function clickHandler(e:MouseEvent):void{
if (GameManager.getInstance().getCamera().isEnabled()){
doScroll(false);
};
}
private function mouseDownHandler(e:MouseEvent):void{
if (GameManager.getInstance().getCamera().isEnabled()){
dragging = true;
};
}
public function setDrag(x:int, y:int):void{
if (!dragging){
drag.x = (map.x + (x * ratio));
drag.y = (map.y + (y * ratio));
};
}
private function doScroll(forceDrag:Boolean):void{
var ox:Number = drag.x;
var oy:Number = drag.y;
drag.x = ((MouseHandler.getInstance().getX() - x) - (drag.width / 2));
drag.y = ((MouseHandler.getInstance().getY() - y) - (drag.height / 2));
if (drag.x < map.x){
drag.x = map.x;
};
if (drag.y < map.y){
drag.y = map.y;
};
if ((drag.x + drag.width) > ((map.x + map.width) + 2)){
drag.x = (((map.x + map.width) - drag.width) + 2);
};
if ((drag.y + drag.height) > ((map.y + map.height) + 2)){
drag.y = (((map.y + map.height) - drag.height) + 2);
};
var mx:int = ((map.x - drag.x) * invRatio);
var my:int = ((map.y - drag.y) * invRatio);
GameManager.getInstance().getCamera().setLocation(mx, my);
if (!forceDrag){
drag.x = ox;
drag.y = oy;
};
}
}
}//package com.gamedozer.battalion.ui
Section 177
//MouseCursor (com.gamedozer.battalion.ui.MouseCursor)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.*;
import flash.ui.*;
public class MouseCursor extends Sprite {
protected var cursor:TileSheet;
public function MouseCursor(a_cursor:TileSheet){
super();
cursor = a_cursor;
addChild(cursor);
cursor.x = -24;
cursor.y = -24;
BattalionMain.getStage().addEventListener(Event.MOUSE_LEAVE, cursorHide);
BattalionMain.getStage().addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
Mouse.hide();
mouseEnabled = false;
mouseChildren = false;
}
public function cursorFollow(a_event:MouseEvent):void{
if (!visible){
visible = true;
};
x = MouseHandler.getInstance().getX();
y = MouseHandler.getInstance().getY();
a_event.updateAfterEvent();
}
public function setCursor(a_frame:String):void{
cursor.playAnimation(a_frame);
}
public function cursorHide(a_event:Event):void{
visible = false;
}
}
}//package com.gamedozer.battalion.ui
Section 178
//OptionsMenu (com.gamedozer.battalion.ui.OptionsMenu)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.ui.modes.*;
import com.gamedozer.battalion.audio.*;
import flash.text.*;
import com.gamedozer.battalion.*;
public class OptionsMenu extends Sprite implements ModeInterface {
public var backButton:TileSheetButton;
public var soundButton:ToggleableTileSheetButton;
public var clearDataButton:TileSheetButton;
public var creditsButton:TileSheetButton;
public var frame:BattalionPanel;
public var musicButton:ToggleableTileSheetButton;
public var dialogButton:ToggleableTileSheetButton;
public static const WIDTH:int = 590;
public static const HEIGHT:int = 125;
public function OptionsMenu(){
var soundLabel:Bitmap;
super();
graphics.beginFill(0, 0.5);
graphics.drawRect(0, 0, BattalionMain.WIDTH, BattalionMain.HEIGHT);
frame = new BattalionPanel(WIDTH, HEIGHT);
frame.x = ((BattalionMain.WIDTH / 2) - (WIDTH / 2));
frame.y = ((BattalionMain.HEIGHT / 2) - (HEIGHT / 2));
addChild(frame);
backButton = new TileSheetButton("closeButton");
backButton.x = (((frame.x + WIDTH) - backButton.width) - 5);
backButton.y = ((frame.y - (backButton.height / 2)) + 10);
addChild(backButton);
soundLabel = new Bitmap(BitmapLibrary.loadBitmap("SoundLabel"));
soundLabel.x = (frame.x + 20);
soundLabel.y = (frame.y + 20);
addChild(soundLabel);
soundButton = new ToggleableTileSheetButton("soundButton");
soundButton.x = soundLabel.x;
soundButton.y = (soundLabel.y + 25);
addChild(soundButton);
var musicLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("MusicLabel"));
musicLabel.x = ((soundButton.x + soundButton.width) + 25);
musicLabel.y = soundLabel.y;
addChild(musicLabel);
musicButton = new ToggleableTileSheetButton("musicButton");
musicButton.x = musicLabel.x;
musicButton.y = (musicLabel.y + 25);
addChild(musicButton);
var dialogLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("dialogLabel"));
dialogLabel.x = ((musicButton.x + musicButton.width) + 25);
dialogLabel.y = musicLabel.y;
addChild(dialogLabel);
dialogButton = new ToggleableTileSheetButton("dialogButton");
dialogButton.x = dialogLabel.x;
dialogButton.y = (dialogLabel.y + 25);
addChild(dialogButton);
var clearDataLabel:Bitmap = new Bitmap(BitmapLibrary.loadBitmap("clearDataLabel"));
clearDataLabel.x = ((dialogLabel.x + dialogLabel.width) + 25);
clearDataLabel.y = dialogLabel.y;
addChild(clearDataLabel);
clearDataButton = new TileSheetButton("clearDataButton");
clearDataButton.x = clearDataLabel.x;
clearDataButton.y = (clearDataLabel.y + 25);
addChild(clearDataButton);
creditsButton = new TileSheetButton("creditsButton");
creditsButton.x = ((frame.x + WIDTH) - creditsButton.width);
creditsButton.y = ((frame.y + HEIGHT) - creditsButton.height);
addChild(creditsButton);
update();
}
public function loseFocus():void{
}
private function update():void{
soundButton.toggled = BattalionMain.getStorage().getBoolean("sound", true);
musicButton.toggled = BattalionMain.getStorage().getBoolean("music", true);
dialogButton.toggled = BattalionMain.getStorage().getBoolean("dialog", true);
}
private function clearConfirm():void{
BattalionMain.getStorage().clear();
update();
}
private function unlockAllLevels():void{
BattalionMain.getStorage().setInt("campaign_level", 9);
BattalionMain.getStorage().setInt("campaign_complete", 9);
BattalionMain.getStorage().setInt("bootcamp_level", 5);
BattalionMain.getStorage().setInt("bootcamp_complete", 5);
}
private function creditsHandler(e:MouseEvent):void{
MenuManager.getInstance().switchMode(MenuManager.creditsMenu, null);
}
public function gainFocus():void{
}
public function popped():void{
BattalionMain.setMusicButtonVisibility(true);
backButton.removeEventListener(MouseEvent.CLICK, backHandler);
backButton.disable();
clearDataButton.removeEventListener(MouseEvent.CLICK, clearHandler);
clearDataButton.disable();
soundButton.removeEventListener(Event.CHANGE, soundHandler);
musicButton.removeEventListener(Event.CHANGE, musicHandler);
dialogButton.removeEventListener(Event.CHANGE, dialogHandler);
creditsButton.disable();
creditsButton.removeEventListener(MouseEvent.CLICK, creditsHandler);
parent.removeChild(this);
}
private function dialogHandler(e:Event):void{
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("dialog", e.target.toggled);
}
public function backHandler(a_event:Event):void{
MenuManager.getInstance().popMode();
}
private function musicHandler(e:Event):void{
var musicValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("music", musicValue);
BattalionMain.updateSoundSystem();
}
public function pushed(a_container:DisplayObjectContainer, a_data:ModeData):void{
BattalionMain.setMusicButtonVisibility(false);
a_container.addChild(this);
backButton.addEventListener(MouseEvent.CLICK, backHandler);
backButton.enable();
clearDataButton.addEventListener(MouseEvent.CLICK, clearHandler);
clearDataButton.enable();
soundButton.addEventListener(Event.CHANGE, soundHandler);
soundButton.enable();
musicButton.addEventListener(Event.CHANGE, musicHandler);
musicButton.enable();
dialogButton.addEventListener(Event.CHANGE, dialogHandler);
dialogButton.enable();
creditsButton.addEventListener(MouseEvent.CLICK, creditsHandler);
creditsButton.enable();
update();
}
private function soundHandler(e:Event):void{
var soundValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("sound", soundValue);
BattalionMain.updateSoundSystem();
}
private function clearHandler(e:MouseEvent):void{
if (((BattalionMain.ALLOW_DEBUG) && (e.altKey))){
unlockAllLevels();
return;
};
MenuManager.getInstance().pushMode(MenuManager.confirmMenu, new ConfirmMenuData("Are you sure you want to clear your saved game data?", clearConfirm));
}
}
}//package com.gamedozer.battalion.ui
Section 179
//PlayerPanel (com.gamedozer.battalion.ui.PlayerPanel)
package com.gamedozer.battalion.ui {
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
public class PlayerPanel extends Sprite {
var resources:TextField;
var playerName:TextField;
var selectedArrow:Bitmap;
var colorBar:Bitmap;
var resourcesBar:Bitmap;
var avatar:TileSheet;
var team:Team;
public static var WIDTH:int = 143;
public static var HEIGHT:int = 37;
public function PlayerPanel(a_team:Team){
super();
addChild(new Bitmap(BitmapLibrary.loadBitmap("playerbox")));
team = a_team;
colorBar = new Bitmap(ColoredSprite.colorise(BitmapLibrary.loadBitmap("colorBar"), null, team.getColor()));
colorBar.x = 0;
colorBar.y = 2;
addChild(colorBar);
avatar = TileSheetManager.getInstance().get("avatarsSmall");
avatar.playAnimation(team.getAvatar());
avatar.y = 2;
avatar.x = 11;
addChild(avatar);
playerName = new DefaultTextField();
playerName.x = 41;
playerName.y = 2;
playerName.width = 106;
playerName.height = 14;
var tf:TextFormat = new DefaultTextFormat();
tf.color = 0;
playerName.defaultTextFormat = tf;
playerName.text = team.getName();
addChild(playerName);
resources = new DefaultTextField();
resources.x = 57;
resources.y = 18;
resources.width = 70;
resources.height = 14;
tf = new DefaultTextFormat();
tf.align = TextFormatAlign.RIGHT;
tf.color = 0;
resources.defaultTextFormat = tf;
resources.text = "$0";
addChild(resources);
}
public function setResources(a_resources:int):void{
resources.text = ("$" + a_resources);
}
}
}//package com.gamedozer.battalion.ui
Section 180
//TileSheetButton (com.gamedozer.battalion.ui.TileSheetButton)
package com.gamedozer.battalion.ui {
import flash.events.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.*;
public class TileSheetButton extends SimpleButton {
var disabledFrame:TileSheet;
var upFrame:TileSheet;
public function TileSheetButton(a_tileSheet:String){
super();
disabledFrame = TileSheetManager.getInstance().get(a_tileSheet);
disabledFrame.setFrame(0);
upFrame = TileSheetManager.getInstance().get(a_tileSheet);
upFrame.setFrame(1);
var over:TileSheet = TileSheetManager.getInstance().get(a_tileSheet);
over.setFrame(2);
var down:TileSheet = TileSheetManager.getInstance().get(a_tileSheet);
down.setFrame(3);
var s:Sprite = new Sprite();
s.graphics.beginFill(0);
s.graphics.drawRect(0, 0, upFrame.width, upFrame.height);
upState = disabledFrame;
overState = over;
downState = down;
hitTestState = s;
enabled = false;
tabEnabled = false;
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
}
override public function get width():Number{
return (upState.width);
}
public function disable():void{
enabled = false;
upState = disabledFrame;
}
public function enable():void{
enabled = true;
upState = upFrame;
}
protected function outHandler(a_event:Event):void{
BattalionMain.getMouseCursor().setCursor("default");
}
protected function overHandler(a_event:Event):void{
if (enabled){
BattalionMain.getMouseCursor().setCursor("select");
};
}
}
}//package com.gamedozer.battalion.ui
Section 181
//ToggleableTileSheetButton (com.gamedozer.battalion.ui.ToggleableTileSheetButton)
package com.gamedozer.battalion.ui {
import flash.events.*;
import flash.display.*;
public class ToggleableTileSheetButton extends Sprite {
private var active:Boolean;// = true
private var activeButton:TileSheetButton;
private var inactiveButton:TileSheetButton;
public function ToggleableTileSheetButton(a_tileSheet:String){
super();
activeButton = new TileSheetButton(a_tileSheet);
addChild(activeButton);
inactiveButton = new TileSheetButton((a_tileSheet + "Toggled"));
addChild(inactiveButton);
inactiveButton.visible = false;
this.addEventListener(MouseEvent.CLICK, clicked);
}
public function set toggled(a_value:Boolean):void{
if (a_value){
showActive();
} else {
showInactive();
};
}
public function showActive():void{
active = true;
activeButton.visible = true;
inactiveButton.visible = false;
}
private function clicked(a_event:Event):void{
toggled = !(toggled);
dispatchEvent(new Event(Event.CHANGE));
}
public function showInactive():void{
active = false;
activeButton.visible = false;
inactiveButton.visible = true;
}
public function enable():void{
activeButton.enable();
inactiveButton.enable();
}
override public function get width():Number{
return (activeButton.width);
}
public function disable():void{
activeButton.disable();
inactiveButton.disable();
}
public function get toggled():Boolean{
return (active);
}
}
}//package com.gamedozer.battalion.ui
Section 182
//ToolTip (com.gamedozer.battalion.ui.ToolTip)
package com.gamedozer.battalion.ui {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import flash.display.*;
import com.gamedozer.battalion.display.*;
import flash.text.*;
import com.gamedozer.battalion.game.*;
public class ToolTip extends GameSprite {
private var m_target:DisplayObject;
private static var s_activeToolTip:ToolTip = null;
public function ToolTip(){
super();
this.visible = false;
this.mouseChildren = false;
this.mouseEnabled = false;
}
private function hide():void{
removeEventListener(Event.ENTER_FRAME, tick);
removeEventListener(Event.ENTER_FRAME, fadeOut);
this.visible = false;
}
private function tick(a_event:Event):void{
if (((!(this.hitTestPoint(this.stage.mouseX, this.stage.mouseY, true))) && (!(m_target.hitTestPoint(this.stage.mouseX, this.stage.mouseY, true))))){
addEventListener(Event.ENTER_FRAME, fadeOut);
removeEventListener(Event.ENTER_FRAME, tick);
};
}
private function showToolTip(a_event:MouseEvent):void{
if (this.stage == null){
return;
};
if (s_activeToolTip != null){
s_activeToolTip.hide();
};
removeEventListener(Event.ENTER_FRAME, fadeOut);
this.visible = true;
this.alpha = 1;
this.x = this.stage.mouseX;
this.y = this.stage.mouseY;
addEventListener(Event.ENTER_FRAME, tick);
s_activeToolTip = this;
}
private function fadeOut(a_event:Event):void{
this.alpha = (this.alpha - 0.03);
if (this.alpha < 0.1){
removeEventListener(Event.ENTER_FRAME, fadeOut);
this.visible = false;
s_activeToolTip = null;
};
}
public function listenForMouseEvents(a_target:DisplayObject):void{
if (a_target.stage == null){
throw (new Error("ToolTip. You cannot attach a tool tip to an object that has not yet been attached to the stage."));
};
m_target = a_target;
m_target.addEventListener(MouseEvent.MOUSE_OVER, showToolTip);
GameManager.getInstance().getSprite().parent.addChild(this);
}
public static function createToolTip(a_target:DisplayObject, a_title:String, a_message:String):void{
var text:TextField;
var toolTip:ToolTip = new (ToolTip);
var info:Sprite = new Sprite();
var infoHolder:Sprite = new Sprite();
var header:TextField = new DefaultTextField(0xFFFFFF, TextFormatAlign.CENTER);
header.text = a_title;
header.width = 150;
header.height = (header.textHeight + 5);
text = new DefaultTextField(0);
text.text = a_message;
text.width = 150;
text.width = Math.min(150, (text.textWidth + 5));
text.height = (text.textHeight + 5);
text.y = header.height;
infoHolder.addChild(header);
infoHolder.addChild(text);
var bg:Sprite = FrameMaker.createBlock(BitmapLibrary.loadBitmap("spotted_texture"), infoHolder.width, infoHolder.height);
var bgBorder:Sprite = new Sprite();
bgBorder.graphics.lineStyle(1, 0, 0.75);
bgBorder.graphics.drawRect(0, 0, infoHolder.width, infoHolder.height);
bgBorder.graphics.lineStyle(1, 0, 0);
bgBorder.graphics.beginFill(11296285, 1);
bgBorder.graphics.drawRect(1, 1, (header.width - 1), (header.height - 1));
bg.addChild(bgBorder);
info.addChild(bg);
info.addChild(infoHolder);
toolTip.addChild(info);
toolTip.listenForMouseEvents(a_target);
}
}
}//package com.gamedozer.battalion.ui
Section 183
//BBCode (com.gamedozer.battalion.utils.BBCode)
package com.gamedozer.battalion.utils {
import com.gamedozer.battalion.game.*;
public class BBCode {
public function BBCode(){
super();
}
public static function parseBBCode(a_message:String):String{
var teams:Array;
a_message = a_message.replace(/\[b\](.*?)\[\/b\]/gi, "<b>$1</b>");
a_message = a_message.replace(/\[i\](.*?)\[\/i\]/gi, "<i>$1</i>");
a_message = a_message.replace(/\[u\](.*?)\[\/u\]/gi, "<u>$1</u>");
a_message = a_message.replace(/\[color=(.*?)\](.*?)\[\/color\]/gi, "<font color=\"$1\">$2</font>");
if (GameManager.getInstance() != null){
teams = GameManager.getInstance().getMapSettings().getTeams();
if (teams[0] != null){
a_message = a_message.replace("^1", teams[0].getName());
a_message = a_message.replace("$1", teams[0].getTeamName());
};
if (teams[1] != null){
a_message = a_message.replace("^2", teams[1].getName());
a_message = a_message.replace("$2", teams[1].getTeamName());
};
if (teams[2] != null){
a_message = a_message.replace("^3", teams[2].getName());
a_message = a_message.replace("$3", teams[2].getTeamName());
};
if (teams[3] != null){
a_message = a_message.replace("^4", teams[3].getName());
a_message = a_message.replace("$4", teams[3].getTeamName());
};
};
return (a_message);
}
public static function parseAvatarCode(a_message:String):String{
var teams:Array;
if (GameManager.getInstance() != null){
teams = GameManager.getInstance().getMapSettings().getTeams();
if (teams[0] != null){
a_message = a_message.replace("@1", teams[0].getAvatar());
} else {
a_message = a_message.replace("@1", "default");
};
if (teams[1] != null){
a_message = a_message.replace("@2", teams[1].getAvatar());
} else {
a_message = a_message.replace("@2", "default");
};
if (teams[2] != null){
a_message = a_message.replace("@3", teams[2].getAvatar());
} else {
a_message = a_message.replace("@3", "default");
};
if (teams[3] != null){
a_message = a_message.replace("@4", teams[3].getAvatar());
} else {
a_message = a_message.replace("@4", "default");
};
} else {
a_message = a_message.replace("@1", "default");
a_message = a_message.replace("@2", "default");
a_message = a_message.replace("@3", "default");
a_message = a_message.replace("@4", "default");
};
return (a_message);
}
public static function parseColorCode(a_message:String):String{
var teams:Array;
if (GameManager.getInstance() != null){
teams = GameManager.getInstance().getMapSettings().getTeams();
if (teams[0] != null){
a_message = a_message.replace("%1", teams[0].getColor().toString(16));
} else {
a_message = a_message.replace("%1", "FF000000");
};
if (teams[1] != null){
a_message = a_message.replace("%2", teams[1].getColor().toString(16));
} else {
a_message = a_message.replace("%2", "FF000000");
};
if (teams[2] != null){
a_message = a_message.replace("%3", teams[2].getColor().toString(16));
} else {
a_message = a_message.replace("%3", "FF000000");
};
if (teams[3] != null){
a_message = a_message.replace("%4", teams[3].getColor().toString(16));
} else {
a_message = a_message.replace("%4", "FF000000");
};
} else {
a_message = a_message.replace("%1", "FF000000");
a_message = a_message.replace("%2", "FF000000");
a_message = a_message.replace("%3", "FF000000");
a_message = a_message.replace("%4", "FF000000");
};
return (a_message);
}
}
}//package com.gamedozer.battalion.utils
Section 184
//BitmapLibrary (com.gamedozer.battalion.utils.BitmapLibrary)
package com.gamedozer.battalion.utils {
import flash.display.*;
import flash.utils.*;
public class BitmapLibrary {
private static var bitmaps:Dictionary;
public function BitmapLibrary(){
super();
if (bitmaps == null){
bitmaps = new Dictionary();
};
}
public static function loadBitmap(className:String):BitmapData{
var ClassReference:Class;
var bitmap:BitmapData;
var className = className;
if (bitmaps == null){
bitmaps = new Dictionary();
};
if (bitmaps[className] != null){
return (bitmaps[className]);
};
ClassReference = (getDefinitionByName(className) as Class);
bitmap = new ClassReference(0, 0);
bitmaps[className] = bitmap;
return (bitmap);
//unresolved jump
var _slot1 = e;
trace("BitmapLibrary::Could not load", className, "as bitmapData");
return (null);
return (null);
}
}
}//package com.gamedozer.battalion.utils
Section 185
//EmbeddedURLLoader (com.gamedozer.battalion.utils.EmbeddedURLLoader)
package com.gamedozer.battalion.utils {
import flash.events.*;
import flash.net.*;
import flash.utils.*;
public class EmbeddedURLLoader extends URLLoader {
private var m_forceEmbedded:Boolean;
private var m_request:URLRequest;
private static var s_embeddedContent:Dictionary = new Dictionary();
public function EmbeddedURLLoader(a_forceEmbedded:Boolean=true){
super();
m_forceEmbedded = a_forceEmbedded;
this.addEventListener(IOErrorEvent.IO_ERROR, handleError);
this.addEventListener(Event.COMPLETE, handleCompleteLoad);
}
private function handleError(a_event:Event):void{
var errorMessage:String;
var url:String = m_request.url;
if (doesContentExist(url)){
a_event.stopImmediatePropagation();
loadEmbedded(url);
} else {
errorMessage = ("EmbeddedURLLoader. Could not find embedded or external asset with URL " + url);
trace(errorMessage);
throw (new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, errorMessage));
};
}
override public function load(a_request:URLRequest):void{
m_request = a_request;
var url:String = m_request.url;
if (!m_forceEmbedded){
super.load(m_request);
} else {
if (doesContentExist(url)){
loadEmbedded(url);
} else {
throw (new Error((("EmbeddedURLLoader. No content defined for " + m_request.url) + " and it required embedding.")));
};
};
}
private function handleCompleteLoad(a_event:Event):void{
var url:String = m_request.url;
if (!m_forceEmbedded){
trace(("EmbeddedURLLoader loaded an external asset for " + url));
};
}
override public function toString():String{
if (m_request != null){
return ((("[EmbeddedURLLoader " + m_request.url) + " ]"));
};
return (super.toString());
}
private function loadEmbedded(a_url:String):void{
this.data = getContent(a_url);
var loadCompleteEvent:Event = new Event(Event.COMPLETE);
dispatchEvent(loadCompleteEvent);
}
private static function getContent(a_url:String):Object{
return (s_embeddedContent[a_url]);
}
public static function registerContent(a_url:String, a_content:Object):void{
s_embeddedContent[a_url] = a_content;
}
private static function doesContentExist(a_url:String):Boolean{
return (!((s_embeddedContent[a_url] == null)));
}
}
}//package com.gamedozer.battalion.utils
Section 186
//KeyboardHandler (com.gamedozer.battalion.utils.KeyboardHandler)
package com.gamedozer.battalion.utils {
import flash.events.*;
public class KeyboardHandler {
protected var keys:Array;
protected var dispatcher:EventDispatcher;
private static var singleton:KeyboardHandler;
public function KeyboardHandler(a_dispatcher:EventDispatcher){
super();
singleton = this;
setDispatcher(a_dispatcher);
}
private function keyDownHandler(a_event:KeyboardEvent):void{
keys[a_event.keyCode] = true;
}
private function deactivateHandler(a_event:Event):void{
keys = new Array();
}
public function setDispatcher(a_dispatcher:EventDispatcher):void{
if (dispatcher == null){
keys = new Array();
} else {
dispatcher.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
dispatcher.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
dispatcher.removeEventListener(Event.DEACTIVATE, deactivateHandler);
dispatcher.removeEventListener(FocusEvent.FOCUS_OUT, deactivateHandler);
};
dispatcher = a_dispatcher;
dispatcher.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
dispatcher.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
dispatcher.addEventListener(Event.DEACTIVATE, deactivateHandler);
dispatcher.addEventListener(FocusEvent.FOCUS_OUT, deactivateHandler);
}
public function isDown(a_key:uint):Boolean{
return ((keys[a_key] == true));
}
private function keyUpHandler(a_event:KeyboardEvent):void{
keys[a_event.keyCode] = false;
}
public static function getInstance():KeyboardHandler{
if (singleton == null){
throw (new Error("KeyboardHandler::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.utils
Section 187
//MouseHandler (com.gamedozer.battalion.utils.MouseHandler)
package com.gamedozer.battalion.utils {
import flash.events.*;
import flash.display.*;
public class MouseHandler {
protected var enabled:Boolean;// = false
protected var dispatcher:EventDispatcher;
protected var buttonDown:Boolean;
protected var x:int;
protected var y:int;
protected var stage:Stage;
private static var singleton:MouseHandler;
public function MouseHandler(stage:Stage){
super();
this.stage = stage;
singleton = this;
setDispatcher(stage);
}
public function getY():int{
return (y);
}
public function setDispatcher(a_dispatcher:EventDispatcher):void{
if (dispatcher == null){
buttonDown = false;
x = 0;
y = 0;
} else {
dispatcher.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
dispatcher.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
dispatcher.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
dispatcher.removeEventListener(Event.DEACTIVATE, deactivateHandler);
dispatcher.removeEventListener(FocusEvent.FOCUS_OUT, deactivateHandler);
dispatcher.removeEventListener(Event.MOUSE_LEAVE, deactivateHandler);
};
dispatcher = a_dispatcher;
dispatcher.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
dispatcher.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
dispatcher.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
dispatcher.addEventListener(Event.DEACTIVATE, deactivateHandler);
dispatcher.addEventListener(FocusEvent.FOCUS_OUT, deactivateHandler);
dispatcher.addEventListener(Event.MOUSE_LEAVE, deactivateHandler);
}
private function mouseDownHandler(a_event:MouseEvent):void{
enabled = true;
buttonDown = true;
}
public function isDown():Boolean{
return (buttonDown);
}
private function mouseUpHandler(a_event:MouseEvent):void{
enabled = true;
buttonDown = false;
}
public function getStage():Stage{
return (stage);
}
public function getX():int{
return (x);
}
private function deactivateHandler(a_event:Event):void{
enabled = false;
buttonDown = false;
}
public function isEnabled():Boolean{
return (enabled);
}
private function mouseMoveHandler(a_event:MouseEvent):void{
enabled = true;
x = stage.mouseX;
y = stage.mouseY;
}
public static function getInstance():MouseHandler{
if (singleton == null){
throw (new Error("MouseHandler::No instance exists"));
};
return (singleton);
}
}
}//package com.gamedozer.battalion.utils
Section 188
//XMLLoader (com.gamedozer.battalion.utils.XMLLoader)
package com.gamedozer.battalion.utils {
import flash.events.*;
import flash.net.*;
public class XMLLoader extends EventDispatcher {
protected var xml:Array;
public function XMLLoader(a_target:IEventDispatcher=null){
super(a_target);
xml = new Array();
}
protected function completeHandler(a_event:Event):void{
var urlLoader:EmbeddedURLLoader = (a_event.target as EmbeddedURLLoader);
var i:int;
while (i < xml.length) {
if (xml[i].urlLoader == urlLoader){
xml[i].xml = new XML(urlLoader.data);
delete xml[i].urlLoader;
delete xml[i].urlRequest;
break;
};
i++;
};
checkComplete();
}
public function add(a_url:String, a_name:String, overwrite:Boolean=false):void{
if (exists(a_name)){
if (overwrite){
remove(a_name);
} else {
checkComplete();
return;
};
};
var xmlHelper:XMLLoaderHelper = new XMLLoaderHelper();
xmlHelper.name = a_name;
xmlHelper.url = a_url;
xmlHelper.urlRequest = new URLRequest(a_url);
xmlHelper.urlLoader = new EmbeddedURLLoader();
xmlHelper.urlLoader.addEventListener(Event.COMPLETE, completeHandler);
xmlHelper.urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
xml.push(xmlHelper);
}
protected function remove(a_name:String):void{
var i:int;
i = (xml.length - i);
while (i >= 0) {
if (xml[i].name == a_name){
xml.splice(i, 1);
};
i--;
};
}
public function get(a_name:String):XML{
var i:int;
while (i < xml.length) {
if (xml[i].name == a_name){
return (xml[i].xml);
};
i++;
};
return (null);
}
protected function checkComplete():void{
var i:int;
while (i < xml.length) {
if (xml[i].xml == null){
return;
};
i++;
};
dispatchEvent(new Event(Event.COMPLETE));
}
public function exists(a_name:String):Boolean{
var i:int;
while (i < xml.length) {
if (xml[i].name == a_name){
return (true);
};
i++;
};
return (false);
}
public function load():void{
var i:int;
while (i < xml.length) {
if (xml[i].xml == null){
xml[i].urlLoader.load(xml[i].urlRequest);
};
i++;
};
checkComplete();
}
protected function ioErrorHandler(a_event:Event):void{
var urlLoader:URLLoader = (a_event.target as URLLoader);
var i:int;
while (i < xml.length) {
if (xml[i].urlLoader == urlLoader){
trace("XMLLoader::Error loading", xml[i].url);
xml.splice(i, 1);
break;
};
i++;
};
dispatchEvent(new Event(IOErrorEvent.IO_ERROR));
checkComplete();
}
}
}//package com.gamedozer.battalion.utils
import flash.net.*;
class XMLLoaderHelper {
public var urlRequest:URLRequest;
public var urlLoader:EmbeddedURLLoader;
public var url:String;
public var xml:XML;
public var name:String;
private function XMLLoaderHelper(){
super();
}
}
Section 189
//BattalionMain (com.gamedozer.battalion.BattalionMain)
package com.gamedozer.battalion {
import flash.events.*;
import com.gamedozer.battalion.utils.*;
import com.gamedozer.utils.*;
import flash.display.*;
import com.gamedozer.battalion.ui.*;
import com.gamedozer.battalion.data.*;
import com.gamedozer.battalion.display.*;
import com.gamedozer.battalion.audio.*;
import com.kongregate.as3.client.*;
import flash.net.*;
import com.gamedozer.battalion.game.*;
import flash.utils.*;
public class BattalionMain extends Sprite {
public static const XML_URL:String = "xml/battalion.xml";
public static const XML_NAME:String = "Battalion1.0";
public static const TILE_WIDTH:int = 56;
public static const TILE_HEIGHT:int = 56;
public static const ALLOW_DEBUG:Boolean = false;
public static const WIDTH:int = 700;
public static const HEIGHT:int = 600;
protected static var currentStage:Stage;
protected static var xmlLoader:XMLLoader;
protected static var mouseCursor:MouseCursor;
protected static var soundButton:ToggleableTileSheetButton;
private static var Tahoma:Class = BattalionMain_Tahoma;
protected static var screen:Sprite;
protected static var musicButton:ToggleableTileSheetButton;
protected static var storage:Storage;
public function BattalionMain(){
super();
addEventListener(Event.ADDED, addedToStage);
}
private function createMasterMuteButtons():void{
var scale:Number = 0.3;
soundButton = new ToggleableTileSheetButton("soundButton");
soundButton.scaleX = scale;
soundButton.scaleY = scale;
soundButton.x = 0;
soundButton.y = 0;
soundButton.enable();
soundButton.addEventListener(Event.CHANGE, soundHandler);
addChild(soundButton);
musicButton = new ToggleableTileSheetButton("musicButton");
musicButton.scaleX = scale;
musicButton.scaleY = scale;
musicButton.x = (WIDTH - (musicButton.width * scale));
musicButton.y = 0;
musicButton.enable();
musicButton.addEventListener(Event.CHANGE, musicHandler);
addChild(musicButton);
}
private function musicHandler(e:Event):void{
var musicValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("music", musicValue);
BattalionMain.updateSoundSystem();
}
public function addedToStage(a_event:Event):void{
var kongregate:KongregateAPI;
removeEventListener(Event.ADDED, addedToStage);
currentStage = stage;
stage.scaleMode = StageScaleMode.NO_SCALE;
if (Sponsor.getInstance().isKongregate()){
kongregate = new KongregateAPI();
this.addChild(kongregate);
};
new KeyboardHandler(stage);
new MouseHandler(stage);
BattalionXMLs.registerEmbeddedXMLs();
xmlLoader = new XMLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initHandler);
xmlLoader.add(XML_URL, XML_NAME);
xmlLoader.load();
}
private function completeHandler(a_event:Event):void{
xmlLoader.removeEventListener(Event.COMPLETE, completeHandler);
var battalion:XML = xmlLoader.get(BattalionMain.XML_NAME);
BattalionSettings.createSingleton(xmlLoader.get(battalion.settings.@name));
storage = new Storage(battalion.storage.@storagename);
storage.loadFromXML(xmlLoader.get(battalion.storage.@name));
var modifiers:XMLList = battalion.modifierlist;
var i:int;
while (i < modifiers.length()) {
ModifierManager.getInstance().importXML(xmlLoader.get(modifiers[i].@name));
i++;
};
var terrain:XMLList = battalion..terrainlist;
var j:int;
while (j < terrain.length()) {
TileManager.getInstance().importXML(xmlLoader.get(terrain[j].@name));
j++;
};
var units:XMLList = battalion..unitlist;
var k:int;
while (k < units.length()) {
UnitManager.getInstance().importXML(xmlLoader.get(units[k].@name));
k++;
};
var tileSheets:XMLList = battalion..tilesheetlist;
var l:int;
while (l < tileSheets.length()) {
TileSheetManager.getInstance().importXML(xmlLoader.get(tileSheets[l].@name));
l++;
};
var campaigns:XMLList = battalion..campaign;
var m:int;
while (m < campaigns.length()) {
new CampaignManager(campaigns[m].@name, xmlLoader.get(campaigns[m].@name));
m++;
};
screen = new Sprite();
addChild(screen);
new MenuManager(screen);
MenuManager.getInstance().pushMode(MenuManager.mainMenu, null);
createMasterMuteButtons();
updateSoundSystem();
mouseCursor = new MouseCursor(TileSheetManager.getInstance().get("cursor"));
this.stage.addChild(mouseCursor);
}
private function initHandler(a_event:Event):void{
xmlLoader.removeEventListener(Event.COMPLETE, initHandler);
new GameManagerHelper();
preloadResources(xmlLoader.get(BattalionMain.XML_NAME));
}
private function soundHandler(e:Event):void{
var soundValue:Boolean = e.target.toggled;
var storage:Storage = BattalionMain.getStorage();
storage.setBoolean("sound", soundValue);
BattalionMain.updateSoundSystem();
}
private function preloadResources(a_XML:XML):void{
var xmls:XMLList = a_XML.resources..xml;
xmlLoader.addEventListener(Event.COMPLETE, completeHandler);
var i:int;
while (i < xmls.length()) {
xmlLoader.add(xmls[i].@url, xmls[i].@name);
i++;
};
xmlLoader.load();
}
public static function getStage():Stage{
return (currentStage);
}
public static function visitSponsor(a_event:Event=null):void{
navigateToURL(new URLRequest(Sponsor.getInstance().getClickURL()), "_blank");
}
public static function updateSoundSystem():void{
var soundValue:Boolean = storage.getBoolean("sound", true);
if (soundValue){
soundButton.toggled = true;
SoundSystem.instance.setMasterEffectVolume(1);
} else {
soundButton.toggled = false;
SoundSystem.instance.setMasterEffectVolume(0);
};
var musicValue:Boolean = storage.getBoolean("music", true);
if (musicValue){
musicButton.toggled = true;
SoundSystem.instance.setMasterLoopVolume(1);
} else {
musicButton.toggled = false;
SoundSystem.instance.setMasterLoopVolume(0);
};
}
public static function visitKongregatesBattalionPage():void{
navigateToURL(new URLRequest("http://www.kongregate.com/games/urbansquall/battalion-nemesis/?gamereferral=battalion-nemesis"), "_blank");
}
public static function getXMLLoader():XMLLoader{
return (xmlLoader);
}
public static function getMouseCursor():MouseCursor{
return (mouseCursor);
}
public static function getScreen():Sprite{
return (screen);
}
public static function getStorage():Storage{
return (storage);
}
public static function setMusicButtonVisibility(a_visible:Boolean):void{
soundButton.visible = a_visible;
musicButton.visible = a_visible;
}
}
}//package com.gamedozer.battalion
Section 190
//BattalionMain_Tahoma (com.gamedozer.battalion.BattalionMain_Tahoma)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionMain_Tahoma extends FontAsset {
}
}//package com.gamedozer.battalion
Section 191
//BattalionPreloader (com.gamedozer.battalion.BattalionPreloader)
package com.gamedozer.battalion {
import flash.events.*;
import flash.display.*;
import com.gamedozer.utils.*;
import flash.text.*;
import flash.net.*;
import flash.ui.*;
public class BattalionPreloader extends AbstractPreloader {
private var m_textfield:TextField;
private var m_logo:MovieClip;
public function BattalionPreloader(){
super();
var contextMenu:ContextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
this.contextMenu = contextMenu;
Sponsor.createInstance(Sponsor.FUNNY_GAMES, this.stage);
if (!Sponsor.getInstance().isKongregate()){
if (!Sponsor.getInstance().isPlayingOnSponsorSite()){
this.visible = false;
throw (new Error("Invalid URL"));
};
};
}
override protected function endLoading():void{
this.stage.frameRate = 120;
removeChild(m_textfield);
m_textfield = null;
m_logo.stop();
removeChild(m_logo);
m_logo = null;
}
override protected function beginLoading():void{
this.stage.frameRate = 30;
m_textfield = new TextField();
m_textfield.textColor = 0xFFFFFF;
addChild(m_textfield);
m_textfield.text = "0%";
m_logo = Sponsor.getInstance().createPreloaderClip();
if (Sponsor.getInstance().stretchSplash()){
m_logo.width = 700;
m_logo.height = 600;
};
m_logo.x = (700 / 2);
m_logo.y = (600 / 2);
m_logo.buttonMode = true;
addChild(m_logo);
m_logo.addEventListener(MouseEvent.CLICK, visitSponsor);
m_logo.addFrameScript(128, stopLogoAnimation);
}
override protected function updateLoading(a_percent:Number):void{
m_textfield.text = (Math.round((a_percent * 100)) + "%");
}
private function stopLogoAnimation():void{
if (m_logo != null){
m_logo.stop();
};
}
override protected function get mainClassName():String{
return ("com.gamedozer.battalion.BattalionMain");
}
public static function visitSponsor(a_event:Event=null):void{
navigateToURL(new URLRequest(Sponsor.getInstance().getClickURL()), "_blank");
}
}
}//package com.gamedozer.battalion
Section 192
//BattalionXMLs (com.gamedozer.battalion.BattalionXMLs)
package com.gamedozer.battalion {
import com.gamedozer.battalion.utils.*;
import flash.utils.*;
public class BattalionXMLs {
private static const Mission_8_yimf:Class = BattalionXMLs_Mission_8_yimf;
private static const Mission_4_yimf:Class = BattalionXMLs_Mission_4_yimf;
private static const terrain_xml:Class = BattalionXMLs_terrain_xml;
private static const battalionStorage_xml:Class = BattalionXMLs_battalionStorage_xml;
private static const batut_5_yimf:Class = BattalionXMLs_batut_5_yimf;
private static const terrainModifiers_xml:Class = BattalionXMLs_terrainModifiers_xml;
private static const tileSheets_xml:Class = BattalionXMLs_tileSheets_xml;
private static const batut_1_yimf:Class = BattalionXMLs_batut_1_yimf;
private static const Mission_5_yimf:Class = BattalionXMLs_Mission_5_yimf;
private static const Mission_1_yimf:Class = BattalionXMLs_Mission_1_yimf;
private static const unitModifiers_xml:Class = BattalionXMLs_unitModifiers_xml;
private static const Mission_9_yimf:Class = BattalionXMLs_Mission_9_yimf;
private static const battalion_xml:Class = BattalionXMLs_battalion_xml;
private static const ballisticsTable_xml:Class = BattalionXMLs_ballisticsTable_xml;
private static const batut_6_yimf:Class = BattalionXMLs_batut_6_yimf;
private static const batut_2_yimf:Class = BattalionXMLs_batut_2_yimf;
private static const Mission_6_yimf:Class = BattalionXMLs_Mission_6_yimf;
private static const units_xml:Class = BattalionXMLs_units_xml;
private static const Mission_2_yimf:Class = BattalionXMLs_Mission_2_yimf;
private static const Kongregate_Bonus_Map_yimf:Class = BattalionXMLs_Kongregate_Bonus_Map_yimf;
private static const bootcamp_xml:Class = BattalionXMLs_bootcamp_xml;
private static const BattalionSettings_xml:Class = BattalionXMLs_BattalionSettings_xml;
private static const batut_3_yimf:Class = BattalionXMLs_batut_3_yimf;
private static const Mission_7_yimf:Class = BattalionXMLs_Mission_7_yimf;
private static const Mission_3_yimf:Class = BattalionXMLs_Mission_3_yimf;
private static const campaign_xml:Class = BattalionXMLs_campaign_xml;
private static const Mission_10_yimf:Class = BattalionXMLs_Mission_10_yimf;
private static const batut_4_yimf:Class = BattalionXMLs_batut_4_yimf;
public function BattalionXMLs(){
super();
}
public static function registerEmbeddedXMLs():void{
EmbeddedURLLoader.registerContent("maps/Kongregate_Bonus_Map.yimf", parseXML(Kongregate_Bonus_Map_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_1.yimf", parseXML(batut_1_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_2.yimf", parseXML(batut_2_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_3.yimf", parseXML(batut_3_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_4.yimf", parseXML(batut_4_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_5.yimf", parseXML(batut_5_yimf));
EmbeddedURLLoader.registerContent("maps/bootcamp/batut_6.yimf", parseXML(batut_6_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_1.yimf", parseXML(Mission_1_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_2.yimf", parseXML(Mission_2_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_3.yimf", parseXML(Mission_3_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_4.yimf", parseXML(Mission_4_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_5.yimf", parseXML(Mission_5_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_6.yimf", parseXML(Mission_6_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_7.yimf", parseXML(Mission_7_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_8.yimf", parseXML(Mission_8_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_9.yimf", parseXML(Mission_9_yimf));
EmbeddedURLLoader.registerContent("maps/Mission_10.yimf", parseXML(Mission_10_yimf));
EmbeddedURLLoader.registerContent("xml/ballisticsTable.xml", parseXML(ballisticsTable_xml));
EmbeddedURLLoader.registerContent("xml/battalion.xml", parseXML(battalion_xml));
EmbeddedURLLoader.registerContent("xml/BattalionSettings.xml", parseXML(BattalionSettings_xml));
EmbeddedURLLoader.registerContent("xml/battalionStorage.xml", parseXML(battalionStorage_xml));
EmbeddedURLLoader.registerContent("xml/bootcamp.xml", parseXML(bootcamp_xml));
EmbeddedURLLoader.registerContent("xml/campaign.xml", parseXML(campaign_xml));
EmbeddedURLLoader.registerContent("xml/terrain.xml", parseXML(terrain_xml));
EmbeddedURLLoader.registerContent("xml/terrainModifiers.xml", parseXML(terrainModifiers_xml));
EmbeddedURLLoader.registerContent("xml/tileSheets.xml", parseXML(tileSheets_xml));
EmbeddedURLLoader.registerContent("xml/unitModifiers.xml", parseXML(unitModifiers_xml));
EmbeddedURLLoader.registerContent("xml/units.xml", parseXML(units_xml));
}
private static function parseXML(a_contentClass:Class):String{
var ba:ByteArray = (new (a_contentClass) as ByteArray);
var s:String = ba.readUTFBytes(ba.length);
return (s);
}
}
}//package com.gamedozer.battalion
Section 193
//BattalionXMLs_ballisticsTable_xml (com.gamedozer.battalion.BattalionXMLs_ballisticsTable_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_ballisticsTable_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 194
//BattalionXMLs_battalion_xml (com.gamedozer.battalion.BattalionXMLs_battalion_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_battalion_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 195
//BattalionXMLs_BattalionSettings_xml (com.gamedozer.battalion.BattalionXMLs_BattalionSettings_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_BattalionSettings_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 196
//BattalionXMLs_battalionStorage_xml (com.gamedozer.battalion.BattalionXMLs_battalionStorage_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_battalionStorage_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 197
//BattalionXMLs_batut_1_yimf (com.gamedozer.battalion.BattalionXMLs_batut_1_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_1_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 198
//BattalionXMLs_batut_2_yimf (com.gamedozer.battalion.BattalionXMLs_batut_2_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_2_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 199
//BattalionXMLs_batut_3_yimf (com.gamedozer.battalion.BattalionXMLs_batut_3_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_3_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 200
//BattalionXMLs_batut_4_yimf (com.gamedozer.battalion.BattalionXMLs_batut_4_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_4_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 201
//BattalionXMLs_batut_5_yimf (com.gamedozer.battalion.BattalionXMLs_batut_5_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_5_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 202
//BattalionXMLs_batut_6_yimf (com.gamedozer.battalion.BattalionXMLs_batut_6_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_batut_6_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 203
//BattalionXMLs_bootcamp_xml (com.gamedozer.battalion.BattalionXMLs_bootcamp_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_bootcamp_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 204
//BattalionXMLs_campaign_xml (com.gamedozer.battalion.BattalionXMLs_campaign_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_campaign_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 205
//BattalionXMLs_Kongregate_Bonus_Map_yimf (com.gamedozer.battalion.BattalionXMLs_Kongregate_Bonus_Map_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Kongregate_Bonus_Map_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 206
//BattalionXMLs_Mission_1_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_1_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_1_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 207
//BattalionXMLs_Mission_10_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_10_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_10_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 208
//BattalionXMLs_Mission_2_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_2_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_2_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 209
//BattalionXMLs_Mission_3_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_3_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_3_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 210
//BattalionXMLs_Mission_4_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_4_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_4_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 211
//BattalionXMLs_Mission_5_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_5_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_5_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 212
//BattalionXMLs_Mission_6_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_6_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_6_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 213
//BattalionXMLs_Mission_7_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_7_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_7_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 214
//BattalionXMLs_Mission_8_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_8_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_8_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 215
//BattalionXMLs_Mission_9_yimf (com.gamedozer.battalion.BattalionXMLs_Mission_9_yimf)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_Mission_9_yimf extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 216
//BattalionXMLs_terrain_xml (com.gamedozer.battalion.BattalionXMLs_terrain_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_terrain_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 217
//BattalionXMLs_terrainModifiers_xml (com.gamedozer.battalion.BattalionXMLs_terrainModifiers_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_terrainModifiers_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 218
//BattalionXMLs_tileSheets_xml (com.gamedozer.battalion.BattalionXMLs_tileSheets_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_tileSheets_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 219
//BattalionXMLs_unitModifiers_xml (com.gamedozer.battalion.BattalionXMLs_unitModifiers_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_unitModifiers_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 220
//BattalionXMLs_units_xml (com.gamedozer.battalion.BattalionXMLs_units_xml)
package com.gamedozer.battalion {
import mx.core.*;
public class BattalionXMLs_units_xml extends ByteArrayAsset {
}
}//package com.gamedozer.battalion
Section 221
//Sponsor (com.gamedozer.battalion.Sponsor)
package com.gamedozer.battalion {
import flash.display.*;
public class Sponsor {
private var m_preloaderClipClass:Class;
private var m_titleLogo:String;// = ""
private var m_isDisabledOnOtherSites:Boolean;// = true
private var m_clickURL:String;
private var m_name:String;
private var m_stage:Stage;
private var m_titleLogoYPosition:int;// = 300
private var m_stretchSplash:Boolean;// = false
private var m_homeURL:String;
public static const ARMOR_GAMES:String = "ArmorGames";
public static const MO_FUN_GAMES:String = "MoFunGames";
public static const FUNNY_GAMES:String = "funny_games";
public static const TWO_GAMES:String = "2games.com";
public static const ANDKON:String = "andkon.com";
public static const BUBBLE_BOX:String = "bubblebox.com";
public static const KONGREGATE:String = "Kongregate";
private static var s_instance:Sponsor;
public function Sponsor(a_name:String, a_stage:Stage){
super();
s_instance = this;
m_name = a_name;
m_stage = a_stage;
switch (m_name){
case FUNNY_GAMES:
m_homeURL = "funny-base.com";
m_clickURL = "http://www.funny-games.biz/main.html";
m_preloaderClipClass = funny_games_intro;
m_titleLogo = "funny_games_logo";
m_titleLogoYPosition = 250;
break;
case BUBBLE_BOX:
m_homeURL = "bubblebox.com";
m_clickURL = "http://www.bubblebox.com/";
m_preloaderClipClass = andkon_intro;
m_titleLogo = "andkon_small";
m_titleLogoYPosition = 250;
break;
case TWO_GAMES:
m_homeURL = "2games.com";
m_clickURL = "http://www.2games.com/";
m_preloaderClipClass = andkon_intro;
m_titleLogo = "andkon_small";
m_titleLogoYPosition = 250;
break;
case ANDKON:
m_homeURL = "andkon.com";
m_clickURL = "http://www.andkon.com/arcade/";
m_preloaderClipClass = andkon_intro;
m_titleLogo = "andkon_small";
m_titleLogoYPosition = 250;
break;
case ARMOR_GAMES:
m_homeURL = "armorgames.com";
m_preloaderClipClass = ag_intro_mc;
m_clickURL = "http://www.armorgames.com";
m_titleLogo = "armor_logo";
m_titleLogoYPosition = 250;
break;
case MO_FUN_GAMES:
m_homeURL = "mofunzone.com";
m_preloaderClipClass = mofungames_preloader;
m_clickURL = "http://www.MoFunZone.com";
m_titleLogo = "mofunzone_logo";
m_titleLogoYPosition = 300;
m_stretchSplash = false;
break;
case KONGREGATE:
default:
m_name = KONGREGATE;
m_titleLogoYPosition = 300;
m_isDisabledOnOtherSites = false;
m_homeURL = "kongregate.com";
m_preloaderClipClass = splash_kong;
m_clickURL = "http://www.kongregate.com/?gamereferral=battalion-nemesis";
m_titleLogo = "mainmenu_kong_logo";
break;
};
}
public function isDisabledOnOtherSites():Boolean{
return (m_isDisabledOnOtherSites);
}
public function createPreloaderClip():MovieClip{
if (m_preloaderClipClass == null){
return (null);
};
return (new m_preloaderClipClass());
}
public function stretchSplash():Boolean{
return (m_stretchSplash);
}
public function getTitleLogoYPosition():int{
return (m_titleLogoYPosition);
}
public function isPlayingOnSponsorSite():Boolean{
var url:String = m_stage.root.loaderInfo.url;
var urlStart:int = (url.indexOf("://") + 3);
var urlEnd:int = url.indexOf("/", urlStart);
var domain:String = url.substring(urlStart, urlEnd);
var LastDot:int = (domain.lastIndexOf(".") - 1);
var pfixEnd:int = (domain.lastIndexOf(".", LastDot) + 1);
domain = domain.substring(pfixEnd, domain.length);
return ((domain == m_homeURL));
}
public function isKongregate():Boolean{
return ((m_name == KONGREGATE));
}
public function getTitleLogo():String{
return (m_titleLogo);
}
public function hasTitleLogo():Boolean{
return (!((m_titleLogo == "")));
}
public function getClickURL():String{
return (m_clickURL);
}
public static function createInstance(a_sponsorName:String, a_stage:Stage):void{
if (s_instance != null){
return;
};
s_instance = new Sponsor(a_sponsorName, a_stage);
}
public static function getInstance():Sponsor{
return (s_instance);
}
}
}//package com.gamedozer.battalion
Section 222
//ModeData (com.gamedozer.ui.modes.ModeData)
package com.gamedozer.ui.modes {
public class ModeData {
public function ModeData(){
super();
}
}
}//package com.gamedozer.ui.modes
Section 223
//ModeInterface (com.gamedozer.ui.modes.ModeInterface)
package com.gamedozer.ui.modes {
import flash.display.*;
public interface ModeInterface {
function pushed(_arg1:DisplayObjectContainer, _arg2:ModeData):void;
function gainFocus():void;
function loseFocus():void;
function popped():void;
}
}//package com.gamedozer.ui.modes
Section 224
//ModeManager (com.gamedozer.ui.modes.ModeManager)
package com.gamedozer.ui.modes {
import flash.display.*;
import flash.utils.*;
public class ModeManager {
private var m_modeLookup:Dictionary;
private var m_modeStack:Array;
private var m_container:DisplayObjectContainer;
public function ModeManager(a_container:DisplayObjectContainer){
m_modeLookup = new Dictionary(false);
m_modeStack = new Array();
super();
m_container = a_container;
}
public function createMode(a_mode:ModeInterface, a_data:ModeData):void{
var top:ModeInterface = getTop();
if (top != null){
top.loseFocus();
};
m_modeStack.push(a_mode);
a_mode.pushed(m_container, a_data);
var newTop:ModeInterface = getTop();
newTop.gainFocus();
}
public function createSwitchMode(a_mode:ModeInterface, a_data:ModeData):void{
popMode();
createMode(a_mode, a_data);
}
public function registerMode(a_modeKey:String, a_mode:ModeInterface):void{
if (m_modeLookup[a_modeKey] != null){
trace(("ModeManager.registerMode: There already is a mode with " + a_modeKey));
return;
};
m_modeLookup[a_modeKey] = a_mode;
}
public function getTop():ModeInterface{
if (m_modeStack.length == 0){
return (null);
};
return (m_modeStack[(m_modeStack.length - 1)]);
}
public function popMode():void{
var currentTop:ModeInterface = getTop();
if (currentTop == null){
trace("NO CURRENT TOP");
return;
};
m_modeStack.splice((m_modeStack.length - 1), 1);
currentTop.popped();
var newTop:ModeInterface = getTop();
if (newTop != null){
newTop.gainFocus();
};
}
public function switchMode(a_modeKey:String, a_modeData:ModeData):void{
popMode();
pushMode(a_modeKey, a_modeData);
}
public function pushMode(a_modeKey:String, a_modeData:ModeData):void{
var mode:ModeInterface = m_modeLookup[a_modeKey];
if (mode == null){
trace(("ModeManager.pushMode: There is no mode with the key " + a_modeKey));
return;
};
var top:ModeInterface = getTop();
if (top != null){
top.loseFocus();
};
m_modeStack.push(mode);
mode.pushed(m_container, a_modeData);
var newTop:ModeInterface = getTop();
newTop.gainFocus();
}
public function dispose():void{
trace("ModeManager.dispose:: TODO, implement.");
}
}
}//package com.gamedozer.ui.modes
Section 225
//AbstractPreloader (com.gamedozer.utils.AbstractPreloader)
package com.gamedozer.utils {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class AbstractPreloader extends MovieClip {
private var m_firstEnterFrame:Boolean;
public function AbstractPreloader(){
super();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stop();
m_firstEnterFrame = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function initialize():void{
var MainClass:Class = (getDefinitionByName(mainClassName) as Class);
if (MainClass == null){
throw (new Error("AbstractPreloader:initialize. There was no class matching that name. Did you remember to override mainClassName?"));
};
var main:DisplayObject = (new (MainClass) as DisplayObject);
if (main == null){
throw (new Error("AbstractPreloader:initialize. Main class needs to inherit from Sprite or MovieClip."));
};
addChildAt(main, 0);
}
protected function endLoading():void{
}
protected function beginLoading():void{
}
private function onEnterFrame(event:Event):void{
var percent:Number;
if (m_firstEnterFrame){
m_firstEnterFrame = false;
if (root.loaderInfo.bytesLoaded >= root.loaderInfo.bytesTotal){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
nextFrame();
initialize();
} else {
beginLoading();
};
return;
};
if (root.loaderInfo.bytesLoaded >= root.loaderInfo.bytesTotal){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
nextFrame();
initialize();
endLoading();
} else {
percent = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
updateLoading(percent);
};
}
protected function get mainClassName():String{
return ("Main");
}
protected function updateLoading(a_percent:Number):void{
}
}
}//package com.gamedozer.utils
Section 226
//Delegate (com.gamedozer.utils.Delegate)
package com.gamedozer.utils {
public class Delegate {
public function Delegate(){
super();
}
public static function create(target, handler:Function, ... _args):Function{
var target = target;
var handler = handler;
var rest = _args;
var delegate:Function = function (... _args){
var fullArgs:Array = _args.concat(rest);
return (handler.apply(target, fullArgs));
};
return (delegate);
}
}
}//package com.gamedozer.utils
Section 227
//Set (com.gamedozer.utils.Set)
package com.gamedozer.utils {
import flash.utils.*;
public class Set {
var m_membersArray:Array;
var m_membersMap:Dictionary;
public function Set(){
super();
m_membersMap = new Dictionary(true);
m_membersArray = new Array();
}
public function addObject(a_object:Object):void{
if (containsObject(a_object)){
return;
};
m_membersArray.push(a_object);
m_membersMap[a_object] = a_object;
}
public function size():int{
return (m_membersArray.length);
}
public function isEmpty():Boolean{
return ((m_membersArray.length == 0));
}
public function removeObject(a_object:Object):void{
if (!containsObject(a_object)){
return;
};
m_membersMap[a_object] = null;
var arrayCount:int = m_membersArray.length;
var i:int;
while (i < arrayCount) {
if (m_membersArray[i] == a_object){
m_membersArray.splice(i, 1);
break;
};
i++;
};
}
public function equals(a_set:Set):Boolean{
if (size() != a_set.size()){
return (false);
};
if (containsSet(a_set)){
return (true);
};
return (false);
}
public function getArrayCopy():Array{
return (m_membersArray.slice());
}
public function toString():String{
return ((((("<Set[" + size()) + "],") + m_membersArray) + ">"));
}
public function clear():void{
var arrayCount:int = m_membersArray.length;
var i:int;
while (i < arrayCount) {
m_membersMap[m_membersArray[i]] = null;
i++;
};
m_membersArray.splice(0);
}
public function union(a_set:Set):Set{
var combinedArray:Array = m_membersArray.concat(a_set.m_membersArray);
var returnSet:Set = new Set();
returnSet.addArray(combinedArray);
return (returnSet);
}
public function minus(a_set:Set):Set{
var object:Object;
var newSetArray:Array = new Array();
var arrayCount:int = m_membersArray.length;
var i:int;
while (i < arrayCount) {
object = m_membersArray[i];
if (!a_set.containsObject(object)){
newSetArray.push(object);
};
i++;
};
var returnSet:Set = new Set();
returnSet.addArray(newSetArray);
return (returnSet);
}
public function addArray(a_array:Array):void{
var arrayCount:int = a_array.length;
var i:int;
while (i < arrayCount) {
addObject(a_array[i]);
i++;
};
}
public function containsSet(a_set:Set):Boolean{
var otherObject:Object;
var otherSetInternalArray:Array = a_set.m_membersArray;
var otherSetSize:int = otherSetInternalArray.length;
var o:int;
while (o < otherSetSize) {
otherObject = otherSetInternalArray[o];
if (!containsObject(otherObject)){
return (false);
};
o++;
};
return (true);
}
public function clone():Set{
var returnSet:Set = new Set();
returnSet.addArray(m_membersArray);
return (returnSet);
}
public function containsObject(a_object:Object):Boolean{
return (!((m_membersMap[a_object] == null)));
}
public function intersect(a_set:Set):Set{
var otherObject:Object;
var intersectingArray:Array = new Array();
var otherSetInternalArray:Array = a_set.m_membersArray;
var otherSetSize:int = otherSetInternalArray.length;
var o:int;
while (o < otherSetSize) {
otherObject = otherSetInternalArray[o];
if (containsObject(otherObject)){
intersectingArray.push(otherObject);
};
o++;
};
var returnSet:Set = new Set();
returnSet.addArray(intersectingArray);
return (returnSet);
}
}
}//package com.gamedozer.utils
Section 228
//Settings (com.gamedozer.utils.Settings)
package com.gamedozer.utils {
import flash.events.*;
import flash.net.*;
import flash.utils.*;
public class Settings {
private var m_keyValueMap:Dictionary;
public function Settings(){
super();
m_keyValueMap = new Dictionary(true);
}
function dispose():void{
m_keyValueMap = null;
}
public function getString(a_key:String, a_defaultValue:String):String{
if (!exists(a_key)){
return (a_defaultValue);
};
return (String(m_keyValueMap[a_key]));
}
function error(a_message:String):void{
trace(a_message);
}
function handleFileLoad(a_event:Event):void{
loadFromXML(new XML(a_event.target.data));
}
function loadFromXML(a_xml:XML):void{
var setting:XML;
var key:String;
var value:String;
var settingsList:XMLList = a_xml.descendants("setting");
for each (setting in settingsList) {
key = setting.attribute("key");
value = setting.attribute("value");
if (key == ""){
} else {
m_keyValueMap[key] = value;
};
};
}
public function getBoolean(a_key:String, a_defaultValue:Boolean):Boolean{
if (!exists(a_key)){
return (a_defaultValue);
};
return (Boolean(m_keyValueMap[a_key]));
}
public function getInt(a_key:String, a_defaultValue:int):int{
if (!exists(a_key)){
return (a_defaultValue);
};
return (int(m_keyValueMap[a_key]));
}
public function exists(a_key:String):Boolean{
if (m_keyValueMap[a_key] == null){
error((("Settings:exists. Key not found " + a_key) + "."));
return (false);
};
return (true);
}
public function getNumber(a_key:String, a_defaultValue:Number):Number{
if (!exists(a_key)){
return (a_defaultValue);
};
var number:Number = Number(m_keyValueMap[a_key]);
if (isNaN(number)){
error((("Settings:getNumber. Key " + a_key) + " is not a number."));
return (0);
};
return (number);
}
public static function createSettingsFromURL(a_url:String):Settings{
var settings:Settings = new (Settings);
var loader:URLLoader = new URLLoader();
var urlRequest:URLRequest = new URLRequest(a_url);
loader.load(urlRequest);
loader.addEventListener(Event.COMPLETE, settings.handleFileLoad);
return (settings);
}
public static function createSettingsFromXML(a_xml:XML):Settings{
var settings:Settings = new (Settings);
settings.loadFromXML(a_xml);
return (settings);
}
}
}//package com.gamedozer.utils
Section 229
//Storage (com.gamedozer.utils.Storage)
package com.gamedozer.utils {
import flash.net.*;
public class Storage {
var m_sharedObject:SharedObject;
var xml:Array;
public function Storage(a_name:String){
super();
m_sharedObject = SharedObject.getLocal(a_name);
}
public function getInt(a_key:String, a_defaultValue:int):int{
if (m_sharedObject.data[a_key] == null){
m_sharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
var number:Number = Number(m_sharedObject.data[a_key]);
if (isNaN(number)){
trace((("Storage:getInt. Key " + a_key) + " is not an integer."));
return (0);
};
return (number);
}
public function getXML(a_key:String, a_defaultValue:XML):XML{
if (m_sharedObject.data[a_key] == null){
m_sharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (m_sharedObject.data[a_key]);
}
public function setBoolean(a_key:String, a_value:Boolean):void{
m_sharedObject.data[a_key] = a_value;
}
public function getString(a_key:String, a_defaultValue:String):String{
if (m_sharedObject.data[a_key] == null){
m_sharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (String(m_sharedObject.data[a_key]));
}
public function loadFromXML(a_xml:XML, addToArray:Boolean=true):void{
var storage:XML;
var key:String;
var value:String;
if (addToArray){
if (xml == null){
xml = new Array();
};
xml.push(a_xml);
};
var storageList:XMLList = a_xml.descendants("storage");
for each (storage in storageList) {
key = storage.attribute("key");
value = storage.attribute("value");
if (key == ""){
} else {
if (m_sharedObject.data[key] == null){
m_sharedObject.data[key] = value;
};
};
};
}
public function setNumber(a_key:String, a_value:Number):void{
m_sharedObject.data[a_key] = a_value;
}
public function clear():void{
var i:int;
m_sharedObject.clear();
if (xml != null){
i = 0;
while (i < xml.length) {
loadFromXML(xml[i], false);
i++;
};
};
}
public function getBoolean(a_key:String, a_defaultValue:Boolean):Boolean{
if (m_sharedObject.data[a_key] == null){
m_sharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
return (Boolean(m_sharedObject.data[a_key]));
}
public function setInt(a_key:String, a_value:int):void{
m_sharedObject.data[a_key] = a_value;
}
public function setXML(a_key:String, a_value:XML):void{
m_sharedObject.data[a_key] = a_value;
}
public function hasAllocatedSpace(a_minimumBytes:int):Boolean{
return ((m_sharedObject.flush(a_minimumBytes) == SharedObjectFlushStatus.FLUSHED));
}
public function setString(a_key:String, a_value:String):void{
m_sharedObject.data[a_key] = a_value;
}
public function getNumber(a_key:String, a_defaultValue:Number):Number{
if (m_sharedObject.data[a_key] == null){
m_sharedObject.data[a_key] = a_defaultValue;
return (a_defaultValue);
};
var number:Number = Number(m_sharedObject.data[a_key]);
if (isNaN(number)){
trace((("Storage:getNumber. Key " + a_key) + " is not a number."));
return (0);
};
return (number);
}
}
}//package com.gamedozer.utils
Section 230
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 231
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 232
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 233
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 234
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 235
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 236
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 237
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 238
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 239
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 240
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 241
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.events.*;
import flash.display.*;
import com.kongregate.as3.client.services.*;
import flash.system.*;
import flash.net.*;
import flash.utils.*;
import com.kongregate.as3.client.events.*;
import flash.errors.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 242
//Circ (com.robertpenner.easing.Circ)
package com.robertpenner.easing {
public class Circ {
public function Circ(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = ((t / d) - 1);
return (((c * Math.sqrt((1 - (t * t)))) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
return (((-(c) * (Math.sqrt((1 - (t * t))) - 1)) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / (d / 2));
if (t < 1){
return ((((-(c) / 2) * (Math.sqrt((1 - (t * t))) - 1)) + b));
};
t = (t - 2);
return ((((c / 2) * (Math.sqrt((1 - (t * t))) + 1)) + b));
}
}
}//package com.robertpenner.easing
Section 243
//Linear (com.robertpenner.easing.Linear)
package com.robertpenner.easing {
public class Linear {
public function Linear(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeNone(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
}
}//package com.robertpenner.easing
Section 244
//Quad (com.robertpenner.easing.Quad)
package com.robertpenner.easing {
public class Quad {
public function Quad(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
return ((((-(c) * t) * (t - 2)) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
return ((((c * t) * t) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / (d / 2));
if (t < 1){
return (((((c / 2) * t) * t) + b));
};
--t;
return ((((-(c) / 2) * ((t * (t - 2)) - 1)) + b));
}
}
}//package com.robertpenner.easing
Section 245
//Sine (com.robertpenner.easing.Sine)
package com.robertpenner.easing {
public class Sine {
public function Sine(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
return (((c * Math.sin(((t / d) * (Math.PI / 2)))) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return ((((-(c) * Math.cos(((t / d) * (Math.PI / 2)))) + c) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
return ((((-(c) / 2) * (Math.cos(((Math.PI * t) / d)) - 1)) + b));
}
}
}//package com.robertpenner.easing
Section 246
//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";
public function ByteArrayAsset(){
super();
}
}
}//package mx.core
Section 247
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(left:Number=0, top:Number=0, right:Number=0, bottom:Number=0){
super();
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 248
//FlexLoader (mx.core.FlexLoader)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexLoader extends Loader {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexLoader(){
super();
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 249
//FlexShape (mx.core.FlexShape)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexShape extends Shape {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexShape(){
super();
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 250
//FlexVersion (mx.core.FlexVersion)
package mx.core {
import mx.resources.*;
public class FlexVersion {
public static const VERSION_2_0_1:uint = 33554433;
public static const CURRENT_VERSION:uint = 50331648;
public static const VERSION_3_0:uint = 50331648;
public static const VERSION_2_0:uint = 33554432;
public static const VERSION_ALREADY_READ:String = "versionAlreadyRead";
public static const VERSION_ALREADY_SET:String = "versionAlreadySet";
mx_internal static const VERSION:String = "3.0.0.0";
private static var compatibilityVersionChanged:Boolean = false;
private static var _compatibilityErrorFunction:Function;
private static var _compatibilityVersion:uint = 50331648;
private static var compatibilityVersionRead:Boolean = false;
public function FlexVersion(){
super();
}
mx_internal static function changeCompatibilityVersionString(value:String):void{
var pieces:Array = value.split(".");
var major:uint = parseInt(pieces[0]);
var minor:uint = parseInt(pieces[1]);
var update:uint = parseInt(pieces[2]);
_compatibilityVersion = (((major << 24) + (minor << 16)) + update);
}
public static function set compatibilityVersion(value:uint):void{
var s:String;
if (value == _compatibilityVersion){
return;
};
if (compatibilityVersionChanged){
if (compatibilityErrorFunction == null){
s = ResourceManager.getInstance().getString("core", VERSION_ALREADY_SET);
throw (new Error(s));
};
compatibilityErrorFunction(value, VERSION_ALREADY_SET);
};
if (compatibilityVersionRead){
if (compatibilityErrorFunction == null){
s = ResourceManager.getInstance().getString("core", VERSION_ALREADY_READ);
throw (new Error(s));
};
compatibilityErrorFunction(value, VERSION_ALREADY_READ);
};
_compatibilityVersion = value;
compatibilityVersionChanged = true;
}
public static function get compatibilityVersion():uint{
compatibilityVersionRead = true;
return (_compatibilityVersion);
}
public static function set compatibilityErrorFunction(value:Function):void{
_compatibilityErrorFunction = value;
}
public static function set compatibilityVersionString(value:String):void{
var pieces:Array = value.split(".");
var major:uint = parseInt(pieces[0]);
var minor:uint = parseInt(pieces[1]);
var update:uint = parseInt(pieces[2]);
compatibilityVersion = (((major << 24) + (minor << 16)) + update);
}
public static function get compatibilityErrorFunction():Function{
return (_compatibilityErrorFunction);
}
public static function get compatibilityVersionString():String{
var major:uint = ((compatibilityVersion >> 24) & 0xFF);
var minor:uint = ((compatibilityVersion >> 16) & 0xFF);
var update:uint = (compatibilityVersion & 0xFFFF);
return (((((major.toString() + ".") + minor.toString()) + ".") + update.toString()));
}
}
}//package mx.core
Section 251
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 252
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 253
//IButton (mx.core.IButton)
package mx.core {
public interface IButton extends IUIComponent {
function get emphasized():Boolean;
function set emphasized(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IButton.as:Boolean):void;
function callLater(_arg1:Function, _arg2:Array=null):void;
}
}//package mx.core
Section 254
//IChildList (mx.core.IChildList)
package mx.core {
import flash.display.*;
import flash.geom.*;
public interface IChildList {
function get numChildren():int;
function removeChild(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject;
function getChildByName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:String):DisplayObject;
function removeChildAt(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject;
function getChildIndex(:DisplayObject):int;
function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject;
function getObjectsUnderPoint(child:Point):Array;
function setChildIndex(_arg1:DisplayObject, _arg2:int):void;
function getChildAt(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject;
function addChild(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject;
function contains(flash.display:DisplayObject):Boolean;
}
}//package mx.core
Section 255
//IContainer (mx.core.IContainer)
package mx.core {
import flash.display.*;
import flash.media.*;
import flash.geom.*;
import flash.text.*;
import mx.managers.*;
public interface IContainer extends IUIComponent {
function set hitArea(mx.core:IContainer/mx.core:IContainer:graphics/get:Sprite):void;
function swapChildrenAt(_arg1:int, _arg2:int):void;
function getChildByName(Graphics:String):DisplayObject;
function get doubleClickEnabled():Boolean;
function get graphics():Graphics;
function get useHandCursor():Boolean;
function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject;
function set mouseChildren(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function set creatingContentPane(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function get textSnapshot():TextSnapshot;
function getChildIndex(value:DisplayObject):int;
function set doubleClickEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function getObjectsUnderPoint(lockCenter:Point):Array;
function get creatingContentPane():Boolean;
function setChildIndex(_arg1:DisplayObject, _arg2:int):void;
function get soundTransform():SoundTransform;
function set useHandCursor(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function get numChildren():int;
function contains(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ISpriteInterface.as:DisplayObject):Boolean;
function get verticalScrollPosition():Number;
function set defaultButton(mx.core:IContainer/mx.core:IContainer:graphics/get:IFlexDisplayObject):void;
function swapChildren(_arg1:DisplayObject, _arg2:DisplayObject):void;
function set horizontalScrollPosition(mx.core:IContainer/mx.core:IContainer:graphics/get:Number):void;
function get focusManager():IFocusManager;
function startDrag(_arg1:Boolean=false, _arg2:Rectangle=null):void;
function set mouseEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function getChildAt(Graphics:int):DisplayObject;
function set soundTransform(mx.core:IContainer/mx.core:IContainer:graphics/get:SoundTransform):void;
function get tabChildren():Boolean;
function get tabIndex():int;
function set focusRect(mx.core:IContainer/mx.core:IContainer:graphics/get:Object):void;
function get hitArea():Sprite;
function get mouseChildren():Boolean;
function removeChildAt(Graphics:int):DisplayObject;
function get defaultButton():IFlexDisplayObject;
function stopDrag():void;
function set tabEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function get horizontalScrollPosition():Number;
function get focusRect():Object;
function get viewMetrics():EdgeMetrics;
function set verticalScrollPosition(mx.core:IContainer/mx.core:IContainer:graphics/get:Number):void;
function get dropTarget():DisplayObject;
function get mouseEnabled():Boolean;
function set tabChildren(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function set buttonMode(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void;
function get tabEnabled():Boolean;
function get buttonMode():Boolean;
function removeChild(Graphics:DisplayObject):DisplayObject;
function set tabIndex(mx.core:IContainer/mx.core:IContainer:graphics/get:int):void;
function addChild(Graphics:DisplayObject):DisplayObject;
function areInaccessibleObjectsUnderPoint(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ISpriteInterface.as:Point):Boolean;
}
}//package mx.core
Section 256
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 257
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(void:Point):Point;
function get name():String;
function set width(flash.display:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(flash.display:String):void;
function set scaleX(flash.display:Number):void;
function set scaleY(flash.display:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(flash.display:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(void:Point):Point;
function get height():Number;
function set blendMode(flash.display:String):void;
function get parent():DisplayObjectContainer;
function getBounds(String:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(flash.display:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(flash.display:Number):void;
function set accessibilityProperties(flash.display:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(flash.display:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(flash.display:Number):void;
function set mask(flash.display:DisplayObject):void;
function getRect(String:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(flash.display:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean;
function set opaqueBackground(flash.display:Object):void;
function set visible(flash.display:Boolean):void;
function get mask():DisplayObject;
function set x(flash.display:Number):void;
function set y(flash.display:Number):void;
function get transform():Transform;
function set filters(flash.display:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(flash.display:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 258
//IFlexModuleFactory (mx.core.IFlexModuleFactory)
package mx.core {
public interface IFlexModuleFactory {
function create(... _args):Object;
function info():Object;
}
}//package mx.core
Section 259
//IInvalidating (mx.core.IInvalidating)
package mx.core {
public interface IInvalidating {
function validateNow():void;
function invalidateSize():void;
function invalidateDisplayList():void;
function invalidateProperties():void;
}
}//package mx.core
Section 260
//IProgrammaticSkin (mx.core.IProgrammaticSkin)
package mx.core {
public interface IProgrammaticSkin {
function validateNow():void;
function validateDisplayList():void;
}
}//package mx.core
Section 261
//IRawChildrenContainer (mx.core.IRawChildrenContainer)
package mx.core {
public interface IRawChildrenContainer {
function get rawChildren():IChildList;
}
}//package mx.core
Section 262
//IRectangularBorder (mx.core.IRectangularBorder)
package mx.core {
import flash.geom.*;
public interface IRectangularBorder extends IBorder {
function get backgroundImageBounds():Rectangle;
function get hasBackgroundImage():Boolean;
function set backgroundImageBounds(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRectangularBorder.as:Rectangle):void;
function layoutBackgroundImage():void;
}
}//package mx.core
Section 263
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 264
//IUIComponent (mx.core.IUIComponent)
package mx.core {
import flash.display.*;
import mx.managers.*;
public interface IUIComponent extends IFlexDisplayObject {
function set focusPane(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Sprite):void;
function get enabled():Boolean;
function set enabled(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function set isPopUp(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function get explicitMinHeight():Number;
function get percentWidth():Number;
function get isPopUp():Boolean;
function get owner():DisplayObjectContainer;
function get percentHeight():Number;
function get baselinePosition():Number;
function owns(Number:DisplayObject):Boolean;
function initialize():void;
function get maxWidth():Number;
function get minWidth():Number;
function getExplicitOrMeasuredWidth():Number;
function get explicitMaxWidth():Number;
function get explicitMaxHeight():Number;
function set percentHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get minHeight():Number;
function set percentWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get document():Object;
function get focusPane():Sprite;
function getExplicitOrMeasuredHeight():Number;
function set tweeningProperties(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Array):void;
function set explicitWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function set measuredMinHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get explicitMinWidth():Number;
function get tweeningProperties():Array;
function get maxHeight():Number;
function set owner(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void;
function set includeInLayout(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function setVisible(_arg1:Boolean, _arg2:Boolean=false):void;
function parentChanged(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void;
function get explicitWidth():Number;
function get measuredMinHeight():Number;
function set measuredMinWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function set explicitHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get includeInLayout():Boolean;
function get measuredMinWidth():Number;
function get explicitHeight():Number;
function set systemManager(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:ISystemManager):void;
function set document(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Object):void;
function get systemManager():ISystemManager;
}
}//package mx.core
Section 265
//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 266
//Singleton (mx.core.Singleton)
package mx.core {
public class Singleton {
mx_internal static const VERSION:String = "3.0.0.0";
private static var classMap:Object = {};
public function Singleton(){
super();
}
public static function registerClass(interfaceName:String, clazz:Class):void{
var c:Class = classMap[interfaceName];
if (!c){
classMap[interfaceName] = clazz;
};
}
public static function getClass(interfaceName:String):Class{
return (classMap[interfaceName]);
}
public static function getInstance(interfaceName:String):Object{
var c:Class = classMap[interfaceName];
if (!c){
throw (new Error((("No class registered for interface '" + interfaceName) + "'.")));
};
return (c["getInstance"]());
}
}
}//package mx.core
Section 267
//UIComponentGlobals (mx.core.UIComponentGlobals)
package mx.core {
import flash.display.*;
import flash.geom.*;
import mx.managers.*;
public class UIComponentGlobals {
mx_internal static var callLaterSuspendCount:int = 0;
mx_internal static var layoutManager:ILayoutManager;
mx_internal static var nextFocusObject:InteractiveObject;
mx_internal static var designTime:Boolean = false;
mx_internal static var tempMatrix:Matrix = new Matrix();
mx_internal static var callLaterDispatcherCount:int = 0;
private static var _catchCallLaterExceptions:Boolean = false;
public function UIComponentGlobals(){
super();
}
public static function set catchCallLaterExceptions(value:Boolean):void{
_catchCallLaterExceptions = value;
}
public static function get designMode():Boolean{
return (designTime);
}
public static function set designMode(value:Boolean):void{
designTime = value;
}
public static function get catchCallLaterExceptions():Boolean{
return (_catchCallLaterExceptions);
}
}
}//package mx.core
Section 268
//ModuleEvent (mx.events.ModuleEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
import mx.modules.*;
public class ModuleEvent extends ProgressEvent {
public var errorText:String;
private var _module:IModuleInfo;
public static const READY:String = "ready";
public static const ERROR:String = "error";
public static const PROGRESS:String = "progress";
mx_internal static const VERSION:String = "3.0.0.0";
public static const SETUP:String = "setup";
public static const UNLOAD:String = "unload";
public function ModuleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null, module:IModuleInfo=null){
super(type, bubbles, cancelable, bytesLoaded, bytesTotal);
this.errorText = errorText;
this._module = module;
}
public function get module():IModuleInfo{
if (_module){
return (_module);
};
return ((target as IModuleInfo));
}
override public function clone():Event{
return (new ModuleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText, module));
}
}
}//package mx.events
Section 269
//ResourceEvent (mx.events.ResourceEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class ResourceEvent extends ProgressEvent {
public var errorText:String;
mx_internal static const VERSION:String = "3.0.0.0";
public static const COMPLETE:String = "complete";
public static const PROGRESS:String = "progress";
public static const ERROR:String = "error";
public function ResourceEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null){
super(type, bubbles, cancelable, bytesLoaded, bytesTotal);
this.errorText = errorText;
}
override public function clone():Event{
return (new ResourceEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText));
}
}
}//package mx.events
Section 270
//StyleEvent (mx.events.StyleEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class StyleEvent extends ProgressEvent {
public var errorText:String;
mx_internal static const VERSION:String = "3.0.0.0";
public static const COMPLETE:String = "complete";
public static const PROGRESS:String = "progress";
public static const ERROR:String = "error";
public function StyleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null){
super(type, bubbles, cancelable, bytesLoaded, bytesTotal);
this.errorText = errorText;
}
override public function clone():Event{
return (new StyleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText));
}
}
}//package mx.events
Section 271
//RectangularDropShadow (mx.graphics.RectangularDropShadow)
package mx.graphics {
import flash.display.*;
import mx.core.*;
import flash.geom.*;
import mx.utils.*;
import flash.filters.*;
public class RectangularDropShadow {
private var leftShadow:BitmapData;
private var _tlRadius:Number;// = 0
private var _trRadius:Number;// = 0
private var _angle:Number;// = 45
private var topShadow:BitmapData;
private var _distance:Number;// = 4
private var rightShadow:BitmapData;
private var _alpha:Number;// = 0.4
private var shadow:BitmapData;
private var _brRadius:Number;// = 0
private var _blRadius:Number;// = 0
private var _color:int;// = 0
private var bottomShadow:BitmapData;
private var changed:Boolean;// = true
mx_internal static const VERSION:String = "3.0.0.0";
public function RectangularDropShadow(){
super();
}
public function get blRadius():Number{
return (_blRadius);
}
public function set brRadius(value:Number):void{
if (_brRadius != value){
_brRadius = value;
changed = true;
};
}
public function set color(value:int):void{
if (_color != value){
_color = value;
changed = true;
};
}
public function drawShadow(g:Graphics, x:Number, y:Number, width:Number, height:Number):void{
var tlWidth:Number;
var tlHeight:Number;
var trWidth:Number;
var trHeight:Number;
var blWidth:Number;
var blHeight:Number;
var brWidth:Number;
var brHeight:Number;
if (changed){
createShadowBitmaps();
changed = false;
};
width = Math.ceil(width);
height = Math.ceil(height);
var leftThickness:int = (leftShadow) ? leftShadow.width : 0;
var rightThickness:int = (rightShadow) ? rightShadow.width : 0;
var topThickness:int = (topShadow) ? topShadow.height : 0;
var bottomThickness:int = (bottomShadow) ? bottomShadow.height : 0;
var widthThickness:int = (leftThickness + rightThickness);
var heightThickness:int = (topThickness + bottomThickness);
var maxCornerHeight:Number = ((height + heightThickness) / 2);
var maxCornerWidth:Number = ((width + widthThickness) / 2);
var matrix:Matrix = new Matrix();
if (((leftShadow) || (topShadow))){
tlWidth = Math.min((tlRadius + widthThickness), maxCornerWidth);
tlHeight = Math.min((tlRadius + heightThickness), maxCornerHeight);
matrix.tx = (x - leftThickness);
matrix.ty = (y - topThickness);
g.beginBitmapFill(shadow, matrix);
g.drawRect((x - leftThickness), (y - topThickness), tlWidth, tlHeight);
g.endFill();
};
if (((rightShadow) || (topShadow))){
trWidth = Math.min((trRadius + widthThickness), maxCornerWidth);
trHeight = Math.min((trRadius + heightThickness), maxCornerHeight);
matrix.tx = (((x + width) + rightThickness) - shadow.width);
matrix.ty = (y - topThickness);
g.beginBitmapFill(shadow, matrix);
g.drawRect((((x + width) + rightThickness) - trWidth), (y - topThickness), trWidth, trHeight);
g.endFill();
};
if (((leftShadow) || (bottomShadow))){
blWidth = Math.min((blRadius + widthThickness), maxCornerWidth);
blHeight = Math.min((blRadius + heightThickness), maxCornerHeight);
matrix.tx = (x - leftThickness);
matrix.ty = (((y + height) + bottomThickness) - shadow.height);
g.beginBitmapFill(shadow, matrix);
g.drawRect((x - leftThickness), (((y + height) + bottomThickness) - blHeight), blWidth, blHeight);
g.endFill();
};
if (((rightShadow) || (bottomShadow))){
brWidth = Math.min((brRadius + widthThickness), maxCornerWidth);
brHeight = Math.min((brRadius + heightThickness), maxCornerHeight);
matrix.tx = (((x + width) + rightThickness) - shadow.width);
matrix.ty = (((y + height) + bottomThickness) - shadow.height);
g.beginBitmapFill(shadow, matrix);
g.drawRect((((x + width) + rightThickness) - brWidth), (((y + height) + bottomThickness) - brHeight), brWidth, brHeight);
g.endFill();
};
if (leftShadow){
matrix.tx = (x - leftThickness);
matrix.ty = 0;
g.beginBitmapFill(leftShadow, matrix);
g.drawRect((x - leftThickness), ((y - topThickness) + tlHeight), leftThickness, ((((height + topThickness) + bottomThickness) - tlHeight) - blHeight));
g.endFill();
};
if (rightShadow){
matrix.tx = (x + width);
matrix.ty = 0;
g.beginBitmapFill(rightShadow, matrix);
g.drawRect((x + width), ((y - topThickness) + trHeight), rightThickness, ((((height + topThickness) + bottomThickness) - trHeight) - brHeight));
g.endFill();
};
if (topShadow){
matrix.tx = 0;
matrix.ty = (y - topThickness);
g.beginBitmapFill(topShadow, matrix);
g.drawRect(((x - leftThickness) + tlWidth), (y - topThickness), ((((width + leftThickness) + rightThickness) - tlWidth) - trWidth), topThickness);
g.endFill();
};
if (bottomShadow){
matrix.tx = 0;
matrix.ty = (y + height);
g.beginBitmapFill(bottomShadow, matrix);
g.drawRect(((x - leftThickness) + blWidth), (y + height), ((((width + leftThickness) + rightThickness) - blWidth) - brWidth), bottomThickness);
g.endFill();
};
}
public function get brRadius():Number{
return (_brRadius);
}
public function get angle():Number{
return (_angle);
}
private function createShadowBitmaps():void{
var roundRectWidth:Number = ((Math.max(tlRadius, blRadius) + (2 * distance)) + Math.max(trRadius, brRadius));
var roundRectHeight:Number = ((Math.max(tlRadius, trRadius) + (2 * distance)) + Math.max(blRadius, brRadius));
if ((((roundRectWidth < 0)) || ((roundRectHeight < 0)))){
return;
};
var roundRect:Shape = new FlexShape();
var g:Graphics = roundRect.graphics;
g.beginFill(0xFFFFFF);
GraphicsUtil.drawRoundRectComplex(g, 0, 0, roundRectWidth, roundRectHeight, tlRadius, trRadius, blRadius, brRadius);
g.endFill();
var roundRectBitmap:BitmapData = new BitmapData(roundRectWidth, roundRectHeight, true, 0);
roundRectBitmap.draw(roundRect, new Matrix());
var filter:DropShadowFilter = new DropShadowFilter(distance, angle, color, alpha);
filter.knockout = true;
var inputRect:Rectangle = new Rectangle(0, 0, roundRectWidth, roundRectHeight);
var outputRect:Rectangle = roundRectBitmap.generateFilterRect(inputRect, filter);
var leftThickness:Number = (inputRect.left - outputRect.left);
var rightThickness:Number = (outputRect.right - inputRect.right);
var topThickness:Number = (inputRect.top - outputRect.top);
var bottomThickness:Number = (outputRect.bottom - inputRect.bottom);
shadow = new BitmapData(outputRect.width, outputRect.height);
shadow.applyFilter(roundRectBitmap, inputRect, new Point(leftThickness, topThickness), filter);
var origin:Point = new Point(0, 0);
var rect:Rectangle = new Rectangle();
if (leftThickness > 0){
rect.x = 0;
rect.y = ((tlRadius + topThickness) + bottomThickness);
rect.width = leftThickness;
rect.height = 1;
leftShadow = new BitmapData(leftThickness, 1);
leftShadow.copyPixels(shadow, rect, origin);
} else {
leftShadow = null;
};
if (rightThickness > 0){
rect.x = (shadow.width - rightThickness);
rect.y = ((trRadius + topThickness) + bottomThickness);
rect.width = rightThickness;
rect.height = 1;
rightShadow = new BitmapData(rightThickness, 1);
rightShadow.copyPixels(shadow, rect, origin);
} else {
rightShadow = null;
};
if (topThickness > 0){
rect.x = ((tlRadius + leftThickness) + rightThickness);
rect.y = 0;
rect.width = 1;
rect.height = topThickness;
topShadow = new BitmapData(1, topThickness);
topShadow.copyPixels(shadow, rect, origin);
} else {
topShadow = null;
};
if (bottomThickness > 0){
rect.x = ((blRadius + leftThickness) + rightThickness);
rect.y = (shadow.height - bottomThickness);
rect.width = 1;
rect.height = bottomThickness;
bottomShadow = new BitmapData(1, bottomThickness);
bottomShadow.copyPixels(shadow, rect, origin);
} else {
bottomShadow = null;
};
}
public function get alpha():Number{
return (_alpha);
}
public function get color():int{
return (_color);
}
public function set angle(value:Number):void{
if (_angle != value){
_angle = value;
changed = true;
};
}
public function set trRadius(value:Number):void{
if (_trRadius != value){
_trRadius = value;
changed = true;
};
}
public function set tlRadius(value:Number):void{
if (_tlRadius != value){
_tlRadius = value;
changed = true;
};
}
public function get trRadius():Number{
return (_trRadius);
}
public function set distance(value:Number):void{
if (_distance != value){
_distance = value;
changed = true;
};
}
public function get distance():Number{
return (_distance);
}
public function get tlRadius():Number{
return (_tlRadius);
}
public function set alpha(value:Number):void{
if (_alpha != value){
_alpha = value;
changed = true;
};
}
public function set blRadius(value:Number):void{
if (_blRadius != value){
_blRadius = value;
changed = true;
};
}
}
}//package mx.graphics
Section 272
//IFocusManager (mx.managers.IFocusManager)
package mx.managers {
import flash.display.*;
import mx.core.*;
public interface IFocusManager {
function get focusPane():Sprite;
function getFocus():IFocusManagerComponent;
function deactivate():void;
function set defaultButton(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IButton):void;
function set focusPane(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Sprite):void;
function set showFocusIndicator(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void;
function get defaultButtonEnabled():Boolean;
function findFocusManagerComponent(value:InteractiveObject):IFocusManagerComponent;
function get nextTabIndex():int;
function get defaultButton():IButton;
function get showFocusIndicator():Boolean;
function setFocus(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IFocusManagerComponent):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void;
function hideFocus():void;
function getNextFocusManagerComponent(value:Boolean=false):IFocusManagerComponent;
}
}//package mx.managers
Section 273
//IFocusManagerComponent (mx.managers.IFocusManagerComponent)
package mx.managers {
public interface IFocusManagerComponent {
function set focusEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void;
function drawFocus(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package mx.managers
Section 274
//IFocusManagerContainer (mx.managers.IFocusManagerContainer)
package mx.managers {
import flash.events.*;
import flash.display.*;
public interface IFocusManagerContainer extends IEventDispatcher {
function set focusManager(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerContainer.as:IFocusManager):void;
function get focusManager():IFocusManager;
function get systemManager():ISystemManager;
function contains(mx.managers:DisplayObject):Boolean;
}
}//package mx.managers
Section 275
//ILayoutManager (mx.managers.ILayoutManager)
package mx.managers {
import flash.events.*;
public interface ILayoutManager extends IEventDispatcher {
function validateNow():void;
function validateClient(_arg1:ILayoutManagerClient, _arg2:Boolean=false):void;
function isInvalid():Boolean;
function invalidateDisplayList(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void;
function set usePhasedInstantiation(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:Boolean):void;
function invalidateSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void;
function get usePhasedInstantiation():Boolean;
function invalidateProperties(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void;
}
}//package mx.managers
Section 276
//ILayoutManagerClient (mx.managers.ILayoutManagerClient)
package mx.managers {
import flash.events.*;
public interface ILayoutManagerClient extends IEventDispatcher {
function get updateCompletePendingFlag():Boolean;
function set updateCompletePendingFlag(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void;
function set initialized(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void;
function validateProperties():void;
function validateDisplayList():void;
function get nestLevel():int;
function get initialized():Boolean;
function get processedDescriptors():Boolean;
function validateSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean=false):void;
function set nestLevel(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:int):void;
function set processedDescriptors(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void;
}
}//package mx.managers
Section 277
//ISystemManager (mx.managers.ISystemManager)
package mx.managers {
import flash.events.*;
import flash.display.*;
import mx.core.*;
import flash.geom.*;
import flash.text.*;
public interface ISystemManager extends IEventDispatcher, IChildList, IFlexModuleFactory {
function get focusPane():Sprite;
function get loaderInfo():LoaderInfo;
function get toolTipChildren():IChildList;
function set focusPane(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Sprite):void;
function isTopLevel():Boolean;
function get popUpChildren():IChildList;
function get screen():Rectangle;
function isFontFaceEmbedded(mx.managers:ISystemManager/mx.managers:ISystemManager:focusPane/get:TextFormat):Boolean;
function get rawChildren():IChildList;
function get topLevelSystemManager():ISystemManager;
function getDefinitionByName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ISystemManager.as:String):Object;
function activate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function deactivate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get cursorChildren():IChildList;
function set document(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Object):void;
function get embeddedFontList():Object;
function set numModalWindows(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:int):void;
function removeFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get document():Object;
function get numModalWindows():int;
function addFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get stage():Stage;
}
}//package mx.managers
Section 278
//SystemManagerGlobals (mx.managers.SystemManagerGlobals)
package mx.managers {
public class SystemManagerGlobals {
public static var topLevelSystemManagers:Array = [];
public static var bootstrapLoaderInfoURL:String;
public function SystemManagerGlobals(){
super();
}
}
}//package mx.managers
Section 279
//IModuleInfo (mx.modules.IModuleInfo)
package mx.modules {
import flash.events.*;
import mx.core.*;
import flash.system.*;
public interface IModuleInfo extends IEventDispatcher {
function get ready():Boolean;
function get loaded():Boolean;
function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null):void;
function release():void;
function get error():Boolean;
function get data():Object;
function publish(E:\dev\3.0.x\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:IFlexModuleFactory):void;
function get factory():IFlexModuleFactory;
function set data(E:\dev\3.0.x\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:Object):void;
function get url():String;
function get setup():Boolean;
function unload():void;
}
}//package mx.modules
Section 280
//ModuleManager (mx.modules.ModuleManager)
package mx.modules {
import mx.core.*;
public class ModuleManager {
mx_internal static const VERSION:String = "3.0.0.0";
public function ModuleManager(){
super();
}
public static function getModule(url:String):IModuleInfo{
return (getSingleton().getModule(url));
}
private static function getSingleton():Object{
if (!ModuleManagerGlobals.managerSingleton){
ModuleManagerGlobals.managerSingleton = new ModuleManagerImpl();
};
return (ModuleManagerGlobals.managerSingleton);
}
public static function getAssociatedFactory(object:Object):IFlexModuleFactory{
return (getSingleton().getAssociatedFactory(object));
}
}
}//package mx.modules
import flash.events.*;
import flash.display.*;
import mx.core.*;
import flash.system.*;
import flash.net.*;
import mx.events.*;
import flash.utils.*;
class ModuleInfoProxy extends EventDispatcher implements IModuleInfo {
private var _data:Object;
private var info:ModuleInfo;
private var referenced:Boolean;// = false
private function ModuleInfoProxy(info:ModuleInfo){
super();
this.info = info;
info.addEventListener(ModuleEvent.SETUP, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.PROGRESS, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.READY, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.ERROR, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.UNLOAD, moduleEventHandler, false, 0, true);
}
public function get loaded():Boolean{
return (info.loaded);
}
public function release():void{
if (referenced){
info.removeReference();
referenced = false;
};
}
public function get error():Boolean{
return (info.error);
}
public function get factory():IFlexModuleFactory{
return (info.factory);
}
public function publish(factory:IFlexModuleFactory):void{
info.publish(factory);
}
public function set data(value:Object):void{
_data = value;
}
public function get ready():Boolean{
return (info.ready);
}
public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{
var moduleEvent:ModuleEvent;
info.resurrect();
if (!referenced){
info.addReference();
referenced = true;
};
if (info.error){
dispatchEvent(new ModuleEvent(ModuleEvent.ERROR));
} else {
if (info.loaded){
if (info.setup){
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
if (info.ready){
moduleEvent = new ModuleEvent(ModuleEvent.PROGRESS);
moduleEvent.bytesLoaded = info.size;
moduleEvent.bytesTotal = info.size;
dispatchEvent(moduleEvent);
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
};
};
} else {
info.load(applicationDomain, securityDomain);
};
};
}
private function moduleEventHandler(event:ModuleEvent):void{
dispatchEvent(event);
}
public function get url():String{
return (info.url);
}
public function get data():Object{
return (_data);
}
public function get setup():Boolean{
return (info.setup);
}
public function unload():void{
info.unload();
info.removeEventListener(ModuleEvent.SETUP, moduleEventHandler);
info.removeEventListener(ModuleEvent.PROGRESS, moduleEventHandler);
info.removeEventListener(ModuleEvent.READY, moduleEventHandler);
info.removeEventListener(ModuleEvent.ERROR, moduleEventHandler);
info.removeEventListener(ModuleEvent.UNLOAD, moduleEventHandler);
}
}
class ModuleManagerImpl extends EventDispatcher {
private var moduleList:Object;
private function ModuleManagerImpl(){
moduleList = {};
super();
}
public function getModule(url:String):IModuleInfo{
var info:ModuleInfo = (moduleList[url] as ModuleInfo);
if (!info){
info = new ModuleInfo(url);
moduleList[url] = info;
};
return (new ModuleInfoProxy(info));
}
public function getAssociatedFactory(object:Object):IFlexModuleFactory{
var m:Object;
var info:ModuleInfo;
var domain:ApplicationDomain;
var cls:Class;
var object = object;
var className:String = getQualifiedClassName(object);
for each (m in moduleList) {
info = (m as ModuleInfo);
if (!info.ready){
} else {
domain = info.applicationDomain;
cls = Class(domain.getDefinition(className));
if ((object is cls)){
return (info.factory);
};
//unresolved jump
var _slot1 = error;
};
};
return (null);
}
}
class ModuleInfo extends EventDispatcher {
private var _error:Boolean;// = false
private var loader:Loader;
private var factoryInfo:FactoryInfo;
private var limbo:Dictionary;
private var _loaded:Boolean;// = false
private var _ready:Boolean;// = false
private var numReferences:int;// = 0
private var _url:String;
private var _setup:Boolean;// = false
private function ModuleInfo(url:String){
super();
_url = url;
}
private function clearLoader():void{
if (loader){
if (loader.contentLoaderInfo){
loader.contentLoaderInfo.removeEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
};
if (loader.content){
loader.content.removeEventListener("ready", readyHandler);
};
//unresolved jump
var _slot1 = error;
if (_loaded){
loader.close();
//unresolved jump
var _slot1 = error;
};
loader.unload();
//unresolved jump
var _slot1 = error;
loader = null;
};
}
public function get size():int{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.bytesTotal : 0);
}
public function get loaded():Boolean{
return ((limbo) ? false : _loaded);
}
public function release():void{
if (((_ready) && (!(limbo)))){
limbo = new Dictionary(true);
limbo[factoryInfo] = 1;
factoryInfo = null;
} else {
unload();
};
}
public function get error():Boolean{
return ((limbo) ? false : _error);
}
public function get factory():IFlexModuleFactory{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.factory : null);
}
public function completeHandler(event:Event):void{
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = loader.contentLoaderInfo.bytesLoaded;
moduleEvent.bytesTotal = loader.contentLoaderInfo.bytesTotal;
dispatchEvent(moduleEvent);
}
public function publish(factory:IFlexModuleFactory):void{
if (factoryInfo){
return;
};
if (_url.indexOf("published://") != 0){
return;
};
factoryInfo = new FactoryInfo();
factoryInfo.factory = factory;
_loaded = true;
_setup = true;
_ready = true;
_error = false;
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
dispatchEvent(new ModuleEvent(ModuleEvent.PROGRESS));
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
}
public function initHandler(event:Event):void{
var moduleEvent:ModuleEvent;
var event = event;
factoryInfo = new FactoryInfo();
factoryInfo.factory = (loader.content as IFlexModuleFactory);
//unresolved jump
var _slot1 = error;
if (!factoryInfo.factory){
moduleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = 0;
moduleEvent.bytesTotal = 0;
moduleEvent.errorText = "SWF is not a loadable module";
dispatchEvent(moduleEvent);
return;
};
loader.content.addEventListener("ready", readyHandler);
factoryInfo.applicationDomain = loader.contentLoaderInfo.applicationDomain;
//unresolved jump
var _slot1 = error;
_setup = true;
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
}
public function resurrect():void{
var f:Object;
if (((!(factoryInfo)) && (limbo))){
for (f in limbo) {
factoryInfo = (f as FactoryInfo);
break;
};
limbo = null;
};
if (!factoryInfo){
if (_loaded){
dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD));
};
loader = null;
_loaded = false;
_setup = false;
_ready = false;
_error = false;
};
}
public function errorHandler(event:ErrorEvent):void{
_error = true;
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = 0;
moduleEvent.bytesTotal = 0;
moduleEvent.errorText = event.text;
dispatchEvent(moduleEvent);
}
public function get ready():Boolean{
return ((limbo) ? false : _ready);
}
public function removeReference():void{
numReferences--;
if (numReferences == 0){
release();
};
}
public function addReference():void{
numReferences++;
}
public function progressHandler(event:ProgressEvent):void{
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = event.bytesLoaded;
moduleEvent.bytesTotal = event.bytesTotal;
dispatchEvent(moduleEvent);
}
public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{
if (_loaded){
return;
};
_loaded = true;
limbo = null;
if (_url.indexOf("published://") == 0){
return;
};
var r:URLRequest = new URLRequest(_url);
var c:LoaderContext = new LoaderContext();
c.applicationDomain = (applicationDomain) ? applicationDomain : new ApplicationDomain(ApplicationDomain.currentDomain);
c.securityDomain = securityDomain;
if ((((securityDomain == null)) && ((Security.sandboxType == Security.REMOTE)))){
c.securityDomain = SecurityDomain.currentDomain;
};
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
loader.load(r, c);
}
public function get url():String{
return (_url);
}
public function get applicationDomain():ApplicationDomain{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.applicationDomain : null);
}
public function readyHandler(event:Event):void{
_ready = true;
factoryInfo.bytesTotal = loader.contentLoaderInfo.bytesTotal;
clearLoader();
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
}
public function get setup():Boolean{
return ((limbo) ? false : _setup);
}
public function unload():void{
clearLoader();
if (_loaded){
dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD));
};
limbo = null;
factoryInfo = null;
_loaded = false;
_setup = false;
_ready = false;
_error = false;
}
}
class FactoryInfo {
public var bytesTotal:int;// = 0
public var factory:IFlexModuleFactory;
public var applicationDomain:ApplicationDomain;
private function FactoryInfo(){
super();
}
}
Section 281
//ModuleManagerGlobals (mx.modules.ModuleManagerGlobals)
package mx.modules {
public class ModuleManagerGlobals {
public static var managerSingleton:Object = null;
public function ModuleManagerGlobals(){
super();
}
}
}//package mx.modules
Section 282
//IResourceBundle (mx.resources.IResourceBundle)
package mx.resources {
public interface IResourceBundle {
function get content():Object;
function get locale():String;
function get bundleName():String;
}
}//package mx.resources
Section 283
//IResourceManager (mx.resources.IResourceManager)
package mx.resources {
import flash.events.*;
import flash.system.*;
public interface IResourceManager extends IEventDispatcher {
function loadResourceModule(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher;
function getBoolean(_arg1:String, _arg2:String, _arg3:String=null):Boolean;
function getClass(_arg1:String, _arg2:String, _arg3:String=null):Class;
function getLocales():Array;
function removeResourceBundlesForLocale(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:String):void;
function getResourceBundle(_arg1:String, _arg2:String):IResourceBundle;
function get localeChain():Array;
function getInt(_arg1:String, _arg2:String, _arg3:String=null):int;
function update():void;
function set localeChain(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:Array):void;
function getUint(_arg1:String, _arg2:String, _arg3:String=null):uint;
function addResourceBundle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:IResourceBundle):void;
function getStringArray(_arg1:String, _arg2:String, _arg3:String=null):Array;
function getBundleNamesForLocale(:String):Array;
function removeResourceBundle(_arg1:String, _arg2:String):void;
function getObject(_arg1:String, _arg2:String, _arg3:String=null);
function getString(_arg1:String, _arg2:String, _arg3:Array=null, _arg4:String=null):String;
function installCompiledResourceBundles(_arg1:ApplicationDomain, _arg2:Array, _arg3:Array):void;
function unloadResourceModule(_arg1:String, _arg2:Boolean=true):void;
function findResourceBundleWithResource(_arg1:String, _arg2:String):IResourceBundle;
function getNumber(_arg1:String, _arg2:String, _arg3:String=null):Number;
}
}//package mx.resources
Section 284
//IResourceModule (mx.resources.IResourceModule)
package mx.resources {
public interface IResourceModule {
function get resourceBundles():Array;
}
}//package mx.resources
Section 285
//ResourceBundle (mx.resources.ResourceBundle)
package mx.resources {
import mx.core.*;
import flash.system.*;
import mx.utils.*;
public class ResourceBundle implements IResourceBundle {
mx_internal var _locale:String;
private var _content:Object;
mx_internal var _bundleName:String;
mx_internal static const VERSION:String = "3.0.0.0";
mx_internal static var backupApplicationDomain:ApplicationDomain;
mx_internal static var locale:String;
public function ResourceBundle(locale:String=null, bundleName:String=null){
_content = {};
super();
mx_internal::_locale = locale;
mx_internal::_bundleName = bundleName;
_content = getContent();
}
protected function getContent():Object{
return ({});
}
public function getString(key:String):String{
return (String(_getObject(key)));
}
public function get content():Object{
return (_content);
}
public function getBoolean(key:String, defaultValue:Boolean=true):Boolean{
var temp:String = _getObject(key).toLowerCase();
if (temp == "false"){
return (false);
};
if (temp == "true"){
return (true);
};
return (defaultValue);
}
public function getStringArray(key:String):Array{
var array:Array = _getObject(key).split(",");
var n:int = array.length;
var i:int;
while (i < n) {
array[i] = StringUtil.trim(array[i]);
i++;
};
return (array);
}
public function getObject(key:String):Object{
return (_getObject(key));
}
private function _getObject(key:String):Object{
var value:Object = content[key];
if (!value){
throw (new Error(((("Key " + key) + " was not found in resource bundle ") + bundleName)));
};
return (value);
}
public function get locale():String{
return (mx_internal::_locale);
}
public function get bundleName():String{
return (mx_internal::_bundleName);
}
public function getNumber(key:String):Number{
return (Number(_getObject(key)));
}
private static function getClassByName(name:String, domain:ApplicationDomain):Class{
var c:Class;
if (domain.hasDefinition(name)){
c = (domain.getDefinition(name) as Class);
};
return (c);
}
public static function getResourceBundle(baseName:String, currentDomain:ApplicationDomain=null):ResourceBundle{
var className:String;
var bundleClass:Class;
var bundleObj:Object;
var bundle:ResourceBundle;
if (!currentDomain){
currentDomain = ApplicationDomain.currentDomain;
};
className = (((mx_internal::locale + "$") + baseName) + "_properties");
bundleClass = getClassByName(className, currentDomain);
if (!bundleClass){
className = (baseName + "_properties");
bundleClass = getClassByName(className, currentDomain);
};
if (!bundleClass){
className = baseName;
bundleClass = getClassByName(className, currentDomain);
};
if (((!(bundleClass)) && (mx_internal::backupApplicationDomain))){
className = (baseName + "_properties");
bundleClass = getClassByName(className, mx_internal::backupApplicationDomain);
if (!bundleClass){
className = baseName;
bundleClass = getClassByName(className, mx_internal::backupApplicationDomain);
};
};
if (bundleClass){
bundleObj = new (bundleClass);
if ((bundleObj is ResourceBundle)){
bundle = ResourceBundle(bundleObj);
return (bundle);
};
};
throw (new Error(("Could not find resource bundle " + baseName)));
}
}
}//package mx.resources
Section 286
//ResourceManager (mx.resources.ResourceManager)
package mx.resources {
import mx.core.*;
public class ResourceManager {
mx_internal static const VERSION:String = "3.0.0.0";
private static var implClassDependency:ResourceManagerImpl;
private static var instance:IResourceManager;
public function ResourceManager(){
super();
}
public static function getInstance():IResourceManager{
if (!instance){
instance = IResourceManager(Singleton.getInstance("mx.resources::IResourceManager"));
};
return (instance);
}
}
}//package mx.resources
Section 287
//ResourceManagerImpl (mx.resources.ResourceManagerImpl)
package mx.resources {
import flash.events.*;
import mx.core.*;
import flash.system.*;
import mx.modules.*;
import mx.events.*;
import flash.utils.*;
import mx.utils.*;
public class ResourceManagerImpl extends EventDispatcher implements IResourceManager {
private var resourceModules:Object;
private var initializedForNonFrameworkApp:Boolean;// = false
private var localeMap:Object;
private var _localeChain:Array;
mx_internal static const VERSION:String = "3.0.0.0";
private static var instance:IResourceManager;
public function ResourceManagerImpl(){
localeMap = {};
resourceModules = {};
super();
}
public function get localeChain():Array{
return (_localeChain);
}
public function set localeChain(value:Array):void{
_localeChain = value;
update();
}
public function getStringArray(bundleName:String, resourceName:String, locale:String=null):Array{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:* = resourceBundle.content[resourceName];
var array:Array = String(value).split(",");
var n:int = array.length;
var i:int;
while (i < n) {
array[i] = StringUtil.trim(array[i]);
i++;
};
return (array);
}
mx_internal function installCompiledResourceBundle(applicationDomain:ApplicationDomain, locale:String, bundleName:String):void{
var packageName:String;
var localName:String = bundleName;
var colonIndex:int = bundleName.indexOf(":");
if (colonIndex != -1){
packageName = bundleName.substring(0, colonIndex);
localName = bundleName.substring((colonIndex + 1));
};
if (getResourceBundle(locale, bundleName)){
return;
};
var resourceBundleClassName = (((locale + "$") + localName) + "_properties");
if (packageName != null){
resourceBundleClassName = ((packageName + ".") + resourceBundleClassName);
};
var bundleClass:Class;
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
if (!bundleClass){
resourceBundleClassName = bundleName;
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
};
if (!bundleClass){
resourceBundleClassName = (bundleName + "_properties");
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
};
if (!bundleClass){
throw (new Error((((("Could not find compiled resource bundle '" + bundleName) + "' for locale '") + locale) + "'.")));
};
var resourceBundle:ResourceBundle = ResourceBundle(new (bundleClass));
resourceBundle.mx_internal::_locale = locale;
resourceBundle.mx_internal::_bundleName = bundleName;
addResourceBundle(resourceBundle);
}
public function getString(bundleName:String, resourceName:String, parameters:Array=null, locale:String=null):String{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:String = String(resourceBundle.content[resourceName]);
if (parameters){
value = StringUtil.substitute(value, parameters);
};
return (value);
}
public function loadResourceModule(url:String, updateFlag:Boolean=true, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{
var moduleInfo:IModuleInfo;
var resourceEventDispatcher:ResourceEventDispatcher;
var timer:Timer;
var timerHandler:Function;
var url = url;
var updateFlag = updateFlag;
var applicationDomain = applicationDomain;
var securityDomain = securityDomain;
moduleInfo = ModuleManager.getModule(url);
resourceEventDispatcher = new ResourceEventDispatcher(moduleInfo);
var readyHandler:Function = function (event:ModuleEvent):void{
var resourceModule:* = event.module.factory.create();
resourceModules[event.module.url].resourceModule = resourceModule;
if (updateFlag){
update();
};
};
moduleInfo.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true);
var errorHandler:Function = function (event:ModuleEvent):void{
var resourceEvent:ResourceEvent;
var message:String = ("Unable to load resource module from " + url);
if (resourceEventDispatcher.willTrigger(ResourceEvent.ERROR)){
resourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = 0;
resourceEvent.bytesTotal = 0;
resourceEvent.errorText = message;
resourceEventDispatcher.dispatchEvent(resourceEvent);
} else {
throw (new Error(message));
};
};
moduleInfo.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true);
resourceModules[url] = new ResourceModuleInfo(moduleInfo, readyHandler, errorHandler);
timer = new Timer(0);
timerHandler = function (event:TimerEvent):void{
timer.removeEventListener(TimerEvent.TIMER, timerHandler);
timer.stop();
moduleInfo.load(applicationDomain, securityDomain);
};
timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true);
timer.start();
return (resourceEventDispatcher);
}
public function getLocales():Array{
var p:String;
var locales:Array = [];
for (p in localeMap) {
locales.push(p);
};
return (locales);
}
public function removeResourceBundlesForLocale(locale:String):void{
delete localeMap[locale];
}
public function getResourceBundle(locale:String, bundleName:String):IResourceBundle{
var bundleMap:Object = localeMap[locale];
if (!bundleMap){
return (null);
};
return (bundleMap[bundleName]);
}
private function dumpResourceModule(resourceModule):void{
var bundle:ResourceBundle;
var p:String;
for each (bundle in resourceModule.resourceBundles) {
trace(bundle.locale, bundle.bundleName);
for (p in bundle.content) {
};
};
}
public function getObject(bundleName:String, resourceName:String, locale:String=null){
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (undefined);
};
return (resourceBundle.content[resourceName]);
}
public function addResourceBundle(resourceBundle:IResourceBundle):void{
var locale:String = resourceBundle.locale;
var bundleName:String = resourceBundle.bundleName;
if (!localeMap[locale]){
localeMap[locale] = {};
};
localeMap[locale][bundleName] = resourceBundle;
}
private function findBundle(bundleName:String, resourceName:String, locale:String):IResourceBundle{
supportNonFrameworkApps();
return (((locale)!=null) ? getResourceBundle(locale, bundleName) : findResourceBundleWithResource(bundleName, resourceName));
}
public function getInt(bundleName:String, resourceName:String, locale:String=null):int{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (0);
};
var value:* = resourceBundle.content[resourceName];
return (int(value));
}
private function supportNonFrameworkApps():void{
if (initializedForNonFrameworkApp){
return;
};
initializedForNonFrameworkApp = true;
if (getLocales().length > 0){
return;
};
var applicationDomain:ApplicationDomain = ApplicationDomain.currentDomain;
if (!applicationDomain.hasDefinition("_CompiledResourceBundleInfo")){
return;
};
var c:Class = Class(applicationDomain.getDefinition("_CompiledResourceBundleInfo"));
var locales:Array = c.compiledLocales;
var bundleNames:Array = c.compiledResourceBundleNames;
installCompiledResourceBundles(applicationDomain, locales, bundleNames);
localeChain = locales;
}
public function getClass(bundleName:String, resourceName:String, locale:String=null):Class{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:* = resourceBundle.content[resourceName];
return ((value as Class));
}
public function getNumber(bundleName:String, resourceName:String, locale:String=null):Number{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (NaN);
};
var value:* = resourceBundle.content[resourceName];
return (Number(value));
}
public function update():void{
dispatchEvent(new Event(Event.CHANGE));
}
public function getBundleNamesForLocale(locale:String):Array{
var p:String;
var bundleNames:Array = [];
for (p in localeMap[locale]) {
bundleNames.push(p);
};
return (bundleNames);
}
public function removeResourceBundle(locale:String, bundleName:String):void{
delete localeMap[locale][bundleName];
if (getBundleNamesForLocale(locale).length == 0){
delete localeMap[locale];
};
}
public function installCompiledResourceBundles(applicationDomain:ApplicationDomain, locales:Array, bundleNames:Array):void{
var locale:String;
var j:int;
var bundleName:String;
var n:int = (locales) ? locales.length : 0;
var m:int = (bundleNames) ? bundleNames.length : 0;
var i:int;
while (i < n) {
locale = locales[i];
j = 0;
while (j < m) {
bundleName = bundleNames[j];
mx_internal::installCompiledResourceBundle(applicationDomain, locale, bundleName);
j++;
};
i++;
};
}
public function findResourceBundleWithResource(bundleName:String, resourceName:String):IResourceBundle{
var locale:String;
var bundleMap:Object;
var bundle:ResourceBundle;
if (!_localeChain){
return (null);
};
var n:int = _localeChain.length;
var i:int;
while (i < n) {
locale = localeChain[i];
bundleMap = localeMap[locale];
if (!bundleMap){
} else {
bundle = bundleMap[bundleName];
if (!bundle){
} else {
if ((resourceName in bundle.content)){
return (bundle);
};
};
};
i++;
};
return (null);
}
public function getUint(bundleName:String, resourceName:String, locale:String=null):uint{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (0);
};
var value:* = resourceBundle.content[resourceName];
return (uint(value));
}
public function getBoolean(bundleName:String, resourceName:String, locale:String=null):Boolean{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (false);
};
var value:* = resourceBundle.content[resourceName];
return ((String(value).toLowerCase() == "true"));
}
public function unloadResourceModule(url:String, update:Boolean=true):void{
throw (new Error("unloadResourceModule() is not yet implemented."));
}
public static function getInstance():IResourceManager{
if (!instance){
instance = new (ResourceManagerImpl);
};
return (instance);
}
}
}//package mx.resources
import flash.events.*;
import mx.modules.*;
import mx.events.*;
class ResourceModuleInfo {
public var resourceModule:IResourceModule;
public var errorHandler:Function;
public var readyHandler:Function;
public var moduleInfo:IModuleInfo;
private function ResourceModuleInfo(moduleInfo:IModuleInfo, readyHandler:Function, errorHandler:Function){
super();
this.moduleInfo = moduleInfo;
this.readyHandler = readyHandler;
this.errorHandler = errorHandler;
}
}
class ResourceEventDispatcher extends EventDispatcher {
private function ResourceEventDispatcher(moduleInfo:IModuleInfo){
super();
moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true);
}
private function moduleInfo_progressHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.PROGRESS, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = event.bytesLoaded;
resourceEvent.bytesTotal = event.bytesTotal;
dispatchEvent(resourceEvent);
}
private function moduleInfo_readyHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.COMPLETE);
dispatchEvent(resourceEvent);
}
private function moduleInfo_errorHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = event.bytesLoaded;
resourceEvent.bytesTotal = event.bytesTotal;
resourceEvent.errorText = event.errorText;
dispatchEvent(resourceEvent);
}
}
Section 288
//HaloBorder (mx.skins.halo.HaloBorder)
package mx.skins.halo {
import flash.display.*;
import mx.core.*;
import mx.styles.*;
import mx.skins.*;
import mx.graphics.*;
import mx.utils.*;
public class HaloBorder extends RectangularBorder {
mx_internal var radiusObj:Object;
mx_internal var backgroundHole:Object;
mx_internal var radius:Number;
mx_internal var bRoundedCorners:Boolean;
mx_internal var backgroundColor:Object;
private var dropShadow:RectangularDropShadow;
protected var _borderMetrics:EdgeMetrics;
mx_internal var backgroundAlphaName:String;
mx_internal static const VERSION:String = "3.0.0.0";
private static var BORDER_WIDTHS:Object = {none:0, solid:1, inset:2, outset:2, alert:3, dropdown:2, menuBorder:1, comboNonEdit:2};
public function HaloBorder(){
super();
BORDER_WIDTHS["default"] = 3;
}
override public function styleChanged(styleProp:String):void{
if ((((((((((styleProp == null)) || ((styleProp == "styleName")))) || ((styleProp == "borderStyle")))) || ((styleProp == "borderThickness")))) || ((styleProp == "borderSides")))){
_borderMetrics = null;
};
invalidateDisplayList();
}
override protected function updateDisplayList(w:Number, h:Number):void{
if (((isNaN(w)) || (isNaN(h)))){
return;
};
super.updateDisplayList(w, h);
backgroundColor = getBackgroundColor();
bRoundedCorners = false;
backgroundAlphaName = "backgroundAlpha";
backgroundHole = null;
radius = 0;
radiusObj = null;
drawBorder(w, h);
drawBackground(w, h);
}
mx_internal function drawBorder(w:Number, h:Number):void{
var backgroundAlpha:Number;
var borderCapColor:uint;
var borderColor:uint;
var borderSides:String;
var borderThickness:Number;
var buttonColor:uint;
var docked:Boolean;
var dropdownBorderColor:uint;
var fillColors:Array;
var footerColors:Array;
var highlightColor:uint;
var shadowCapColor:uint;
var shadowColor:uint;
var themeColor:uint;
var translucent:Boolean;
var hole:Object;
var borderColorDrk1:Number;
var borderColorDrk2:Number;
var borderColorLt1:Number;
var borderInnerColor:Object;
var contentAlpha:Number;
var br:Number;
var parentContainer:IContainer;
var vm:EdgeMetrics;
var showChrome:Boolean;
var borderAlpha:Number;
var fillAlphas:Array;
var backgroundColorNum:uint;
var bHasAllSides:Boolean;
var holeRadius:Number;
var borderStyle:String = getStyle("borderStyle");
var highlightAlphas:Array = getStyle("highlightAlphas");
var drawTopHighlight:Boolean;
var g:Graphics = graphics;
g.clear();
if (borderStyle){
switch (borderStyle){
case "none":
break;
case "inset":
borderColor = getStyle("borderColor");
borderColorDrk1 = ColorUtil.adjustBrightness2(borderColor, -40);
borderColorDrk2 = ColorUtil.adjustBrightness2(borderColor, 25);
borderColorLt1 = ColorUtil.adjustBrightness2(borderColor, 40);
borderInnerColor = backgroundColor;
if ((((borderInnerColor === null)) || ((borderInnerColor === "")))){
borderInnerColor = borderColor;
};
draw3dBorder(borderColorDrk2, borderColorDrk1, borderColorLt1, Number(borderInnerColor), Number(borderInnerColor), Number(borderInnerColor));
break;
case "outset":
borderColor = getStyle("borderColor");
borderColorDrk1 = ColorUtil.adjustBrightness2(borderColor, -40);
borderColorDrk2 = ColorUtil.adjustBrightness2(borderColor, -25);
borderColorLt1 = ColorUtil.adjustBrightness2(borderColor, 40);
borderInnerColor = backgroundColor;
if ((((borderInnerColor === null)) || ((borderInnerColor === "")))){
borderInnerColor = borderColor;
};
draw3dBorder(borderColorDrk2, borderColorLt1, borderColorDrk1, Number(borderInnerColor), Number(borderInnerColor), Number(borderInnerColor));
break;
case "alert":
case "default":
if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){
contentAlpha = getStyle("backgroundAlpha");
backgroundAlpha = getStyle("borderAlpha");
backgroundAlphaName = "borderAlpha";
radius = getStyle("cornerRadius");
bRoundedCorners = (getStyle("roundedBottomCorners").toString().toLowerCase() == "true");
br = (bRoundedCorners) ? radius : 0;
drawDropShadow(0, 0, w, h, radius, radius, br, br);
if (!bRoundedCorners){
radiusObj = {};
};
parentContainer = (parent as IContainer);
if (parentContainer){
vm = parentContainer.viewMetrics;
backgroundHole = {x:vm.left, y:vm.top, w:Math.max(0, ((w - vm.left) - vm.right)), h:Math.max(0, ((h - vm.top) - vm.bottom)), r:0};
if ((((backgroundHole.w > 0)) && ((backgroundHole.h > 0)))){
if (contentAlpha != backgroundAlpha){
drawDropShadow(backgroundHole.x, backgroundHole.y, backgroundHole.w, backgroundHole.h, 0, 0, 0, 0);
};
g.beginFill(Number(backgroundColor), contentAlpha);
g.drawRect(backgroundHole.x, backgroundHole.y, backgroundHole.w, backgroundHole.h);
g.endFill();
};
};
backgroundColor = getStyle("borderColor");
};
break;
case "dropdown":
dropdownBorderColor = getStyle("dropdownBorderColor");
drawDropShadow(0, 0, w, h, 4, 0, 0, 4);
drawRoundRect(0, 0, w, h, {tl:4, tr:0, br:0, bl:4}, 5068126, 1);
drawRoundRect(0, 0, w, h, {tl:4, tr:0, br:0, bl:4}, [0xFFFFFF, 0xFFFFFF], [0.7, 0], verticalGradientMatrix(0, 0, w, h));
drawRoundRect(1, 1, (w - 1), (h - 2), {tl:3, tr:0, br:0, bl:3}, 0xFFFFFF, 1);
drawRoundRect(1, 2, (w - 1), (h - 3), {tl:3, tr:0, br:0, bl:3}, [0xEEEEEE, 0xFFFFFF], 1, verticalGradientMatrix(0, 0, (w - 1), (h - 3)));
if (!isNaN(dropdownBorderColor)){
drawRoundRect(0, 0, (w + 1), h, {tl:4, tr:0, br:0, bl:4}, dropdownBorderColor, 0.5);
drawRoundRect(1, 1, (w - 1), (h - 2), {tl:3, tr:0, br:0, bl:3}, 0xFFFFFF, 1);
drawRoundRect(1, 2, (w - 1), (h - 3), {tl:3, tr:0, br:0, bl:3}, [0xEEEEEE, 0xFFFFFF], 1, verticalGradientMatrix(0, 0, (w - 1), (h - 3)));
};
backgroundColor = null;
break;
case "menuBorder":
borderColor = getStyle("borderColor");
drawRoundRect(0, 0, w, h, 0, borderColor, 1);
drawDropShadow(1, 1, (w - 2), (h - 2), 0, 0, 0, 0);
break;
case "comboNonEdit":
break;
case "controlBar":
if ((((w == 0)) || ((h == 0)))){
backgroundColor = null;
break;
};
footerColors = getStyle("footerColors");
showChrome = !((footerColors == null));
borderAlpha = getStyle("borderAlpha");
if (showChrome){
g.lineStyle(0, ((footerColors.length > 0)) ? footerColors[1] : footerColors[0], borderAlpha);
g.moveTo(0, 0);
g.lineTo(w, 0);
g.lineStyle(0, 0, 0);
if (((((parent) && (parent.parent))) && ((parent.parent is IStyleClient)))){
radius = IStyleClient(parent.parent).getStyle("cornerRadius");
borderAlpha = IStyleClient(parent.parent).getStyle("borderAlpha");
};
if (isNaN(radius)){
radius = 0;
};
if (IStyleClient(parent.parent).getStyle("roundedBottomCorners").toString().toLowerCase() != "true"){
radius = 0;
};
drawRoundRect(0, 1, w, (h - 1), {tl:0, tr:0, bl:radius, br:radius}, footerColors, borderAlpha, verticalGradientMatrix(0, 0, w, h));
if ((((footerColors.length > 1)) && (!((footerColors[0] == footerColors[1]))))){
drawRoundRect(0, 1, w, (h - 1), {tl:0, tr:0, bl:radius, br:radius}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(0, 0, w, h));
drawRoundRect(1, 2, (w - 2), (h - 3), {tl:0, tr:0, bl:(radius - 1), br:(radius - 1)}, footerColors, borderAlpha, verticalGradientMatrix(0, 0, w, h));
};
};
backgroundColor = null;
break;
case "applicationControlBar":
fillColors = getStyle("fillColors");
backgroundAlpha = getStyle("backgroundAlpha");
highlightAlphas = getStyle("highlightAlphas");
fillAlphas = getStyle("fillAlphas");
docked = getStyle("docked");
backgroundColorNum = uint(backgroundColor);
radius = getStyle("cornerRadius");
if (!radius){
radius = 0;
};
drawDropShadow(0, 1, w, (h - 1), radius, radius, radius, radius);
if (((!((backgroundColor === null))) && (StyleManager.isValidStyleValue(backgroundColor)))){
drawRoundRect(0, 1, w, (h - 1), radius, backgroundColorNum, backgroundAlpha, verticalGradientMatrix(0, 0, w, h));
};
drawRoundRect(0, 1, w, (h - 1), radius, fillColors, fillAlphas, verticalGradientMatrix(0, 0, w, h));
drawRoundRect(0, 1, w, ((h / 2) - 1), {tl:radius, tr:radius, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(0, 0, w, ((h / 2) - 1)));
drawRoundRect(0, 1, w, (h - 1), {tl:radius, tr:radius, bl:0, br:0}, 0xFFFFFF, 0.3, null, GradientType.LINEAR, null, {x:0, y:2, w:w, h:(h - 2), r:{tl:radius, tr:radius, bl:0, br:0}});
backgroundColor = null;
break;
default:
borderColor = getStyle("borderColor");
borderThickness = getStyle("borderThickness");
borderSides = getStyle("borderSides");
bHasAllSides = true;
radius = getStyle("cornerRadius");
bRoundedCorners = (getStyle("roundedBottomCorners").toString().toLowerCase() == "true");
holeRadius = Math.max((radius - borderThickness), 0);
hole = {x:borderThickness, y:borderThickness, w:(w - (borderThickness * 2)), h:(h - (borderThickness * 2)), r:holeRadius};
if (!bRoundedCorners){
radiusObj = {tl:radius, tr:radius, bl:0, br:0};
hole.r = {tl:holeRadius, tr:holeRadius, bl:0, br:0};
};
if (borderSides != "left top right bottom"){
hole.r = {tl:holeRadius, tr:holeRadius, bl:(bRoundedCorners) ? holeRadius : 0, br:(bRoundedCorners) ? holeRadius : 0};
radiusObj = {tl:radius, tr:radius, bl:(bRoundedCorners) ? radius : 0, br:(bRoundedCorners) ? radius : 0};
borderSides = borderSides.toLowerCase();
if (borderSides.indexOf("left") == -1){
hole.x = 0;
hole.w = (hole.w + borderThickness);
hole.r.tl = 0;
hole.r.bl = 0;
radiusObj.tl = 0;
radiusObj.bl = 0;
bHasAllSides = false;
};
if (borderSides.indexOf("top") == -1){
hole.y = 0;
hole.h = (hole.h + borderThickness);
hole.r.tl = 0;
hole.r.tr = 0;
radiusObj.tl = 0;
radiusObj.tr = 0;
bHasAllSides = false;
};
if (borderSides.indexOf("right") == -1){
hole.w = (hole.w + borderThickness);
hole.r.tr = 0;
hole.r.br = 0;
radiusObj.tr = 0;
radiusObj.br = 0;
bHasAllSides = false;
};
if (borderSides.indexOf("bottom") == -1){
hole.h = (hole.h + borderThickness);
hole.r.bl = 0;
hole.r.br = 0;
radiusObj.bl = 0;
radiusObj.br = 0;
bHasAllSides = false;
};
};
if ((((radius == 0)) && (bHasAllSides))){
drawDropShadow(0, 0, w, h, 0, 0, 0, 0);
g.beginFill(borderColor);
g.drawRect(0, 0, w, h);
g.drawRect(borderThickness, borderThickness, (w - (2 * borderThickness)), (h - (2 * borderThickness)));
g.endFill();
} else {
if (radiusObj){
drawDropShadow(0, 0, w, h, radiusObj.tl, radiusObj.tr, radiusObj.br, radiusObj.bl);
drawRoundRect(0, 0, w, h, radiusObj, borderColor, 1, null, null, null, hole);
radiusObj.tl = Math.max((radius - borderThickness), 0);
radiusObj.tr = Math.max((radius - borderThickness), 0);
radiusObj.bl = (bRoundedCorners) ? Math.max((radius - borderThickness), 0) : 0;
radiusObj.br = (bRoundedCorners) ? Math.max((radius - borderThickness), 0) : 0;
} else {
drawDropShadow(0, 0, w, h, radius, radius, radius, radius);
drawRoundRect(0, 0, w, h, radius, borderColor, 1, null, null, null, hole);
radius = Math.max((getStyle("cornerRadius") - borderThickness), 0);
};
};
};
};
}
mx_internal function drawBackground(w:Number, h:Number):void{
var nd:Number;
var alpha:Number;
var bm:EdgeMetrics;
var g:Graphics;
var bottom:Number;
var bottomRadius:Number;
var highlightAlphas:Array;
var highlightAlpha:Number;
if (((((((!((backgroundColor === null))) && (!((backgroundColor === ""))))) || (getStyle("mouseShield")))) || (getStyle("mouseShieldChildren")))){
nd = Number(backgroundColor);
alpha = 1;
bm = getBackgroundColorMetrics();
g = graphics;
if (((((isNaN(nd)) || ((backgroundColor === "")))) || ((backgroundColor === null)))){
alpha = 0;
nd = 0xFFFFFF;
} else {
alpha = getStyle(backgroundAlphaName);
};
if (((!((radius == 0))) || (backgroundHole))){
bottom = bm.bottom;
if (radiusObj){
bottomRadius = (bRoundedCorners) ? radius : 0;
radiusObj = {tl:radius, tr:radius, bl:bottomRadius, br:bottomRadius};
drawRoundRect(bm.left, bm.top, (width - (bm.left + bm.right)), (height - (bm.top + bottom)), radiusObj, nd, alpha, null, GradientType.LINEAR, null, backgroundHole);
} else {
drawRoundRect(bm.left, bm.top, (width - (bm.left + bm.right)), (height - (bm.top + bottom)), radius, nd, alpha, null, GradientType.LINEAR, null, backgroundHole);
};
} else {
g.beginFill(nd, alpha);
g.drawRect(bm.left, bm.top, ((w - bm.right) - bm.left), ((h - bm.bottom) - bm.top));
g.endFill();
};
};
var borderStyle:String = getStyle("borderStyle");
if ((((((FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)) && ((((borderStyle == "alert")) || ((borderStyle == "default")))))) && ((getStyle("headerColors") == null)))){
highlightAlphas = getStyle("highlightAlphas");
highlightAlpha = (highlightAlphas) ? highlightAlphas[0] : 0.3;
drawRoundRect(0, 0, w, h, {tl:radius, tr:radius, bl:0, br:0}, 0xFFFFFF, highlightAlpha, null, GradientType.LINEAR, null, {x:0, y:1, w:w, h:(h - 1), r:{tl:radius, tr:radius, bl:0, br:0}});
};
}
mx_internal function drawDropShadow(x:Number, y:Number, width:Number, height:Number, tlRadius:Number, trRadius:Number, brRadius:Number, blRadius:Number):void{
var angle:Number;
var docked:Boolean;
if ((((((((getStyle("dropShadowEnabled") == false)) || ((getStyle("dropShadowEnabled") == "false")))) || ((width == 0)))) || ((height == 0)))){
return;
};
var distance:Number = getStyle("shadowDistance");
var direction:String = getStyle("shadowDirection");
if (getStyle("borderStyle") == "applicationControlBar"){
docked = getStyle("docked");
angle = (docked) ? 90 : getDropShadowAngle(distance, direction);
distance = Math.abs(distance);
} else {
angle = getDropShadowAngle(distance, direction);
distance = (Math.abs(distance) + 2);
};
if (!dropShadow){
dropShadow = new RectangularDropShadow();
};
dropShadow.distance = distance;
dropShadow.angle = angle;
dropShadow.color = getStyle("dropShadowColor");
dropShadow.alpha = 0.4;
dropShadow.tlRadius = tlRadius;
dropShadow.trRadius = trRadius;
dropShadow.blRadius = blRadius;
dropShadow.brRadius = brRadius;
dropShadow.drawShadow(graphics, x, y, width, height);
}
mx_internal function getBackgroundColor():Object{
var color:Object;
var p:IUIComponent = (parent as IUIComponent);
if (((p) && (!(p.enabled)))){
color = getStyle("backgroundDisabledColor");
if (((!((color === null))) && (StyleManager.isValidStyleValue(color)))){
return (color);
};
};
return (getStyle("backgroundColor"));
}
mx_internal function draw3dBorder(c1:Number, c2:Number, c3:Number, c4:Number, c5:Number, c6:Number):void{
var w:Number = width;
var h:Number = height;
drawDropShadow(0, 0, width, height, 0, 0, 0, 0);
var g:Graphics = graphics;
g.beginFill(c1);
g.drawRect(0, 0, w, h);
g.drawRect(1, 0, (w - 2), h);
g.endFill();
g.beginFill(c2);
g.drawRect(1, 0, (w - 2), 1);
g.endFill();
g.beginFill(c3);
g.drawRect(1, (h - 1), (w - 2), 1);
g.endFill();
g.beginFill(c4);
g.drawRect(1, 1, (w - 2), 1);
g.endFill();
g.beginFill(c5);
g.drawRect(1, (h - 2), (w - 2), 1);
g.endFill();
g.beginFill(c6);
g.drawRect(1, 2, (w - 2), (h - 4));
g.drawRect(2, 2, (w - 4), (h - 4));
g.endFill();
}
mx_internal function getBackgroundColorMetrics():EdgeMetrics{
return (borderMetrics);
}
mx_internal function getDropShadowAngle(distance:Number, direction:String):Number{
if (direction == "left"){
return (((distance >= 0)) ? 135 : 225);
} else {
if (direction == "right"){
return (((distance >= 0)) ? 45 : 315);
//unresolved jump
};
};
return (!NULL!);
}
override public function get borderMetrics():EdgeMetrics{
var borderThickness:Number;
var borderSides:String;
if (_borderMetrics){
return (_borderMetrics);
};
var borderStyle:String = getStyle("borderStyle");
if ((((borderStyle == "default")) || ((borderStyle == "alert")))){
if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){
_borderMetrics = new EdgeMetrics(0, 0, 0, 0);
} else {
return (EdgeMetrics.EMPTY);
};
} else {
if ((((borderStyle == "controlBar")) || ((borderStyle == "applicationControlBar")))){
_borderMetrics = new EdgeMetrics(1, 1, 1, 1);
} else {
if (borderStyle == "solid"){
borderThickness = getStyle("borderThickness");
if (isNaN(borderThickness)){
borderThickness = 0;
};
_borderMetrics = new EdgeMetrics(borderThickness, borderThickness, borderThickness, borderThickness);
borderSides = getStyle("borderSides");
if (borderSides != "left top right bottom"){
if (borderSides.indexOf("left") == -1){
_borderMetrics.left = 0;
};
if (borderSides.indexOf("top") == -1){
_borderMetrics.top = 0;
};
if (borderSides.indexOf("right") == -1){
_borderMetrics.right = 0;
};
if (borderSides.indexOf("bottom") == -1){
_borderMetrics.bottom = 0;
};
};
} else {
borderThickness = BORDER_WIDTHS[borderStyle];
if (isNaN(borderThickness)){
borderThickness = 0;
};
_borderMetrics = new EdgeMetrics(borderThickness, borderThickness, borderThickness, borderThickness);
};
};
};
return (_borderMetrics);
}
}
}//package mx.skins.halo
Section 289
//HaloFocusRect (mx.skins.halo.HaloFocusRect)
package mx.skins.halo {
import flash.display.*;
import mx.core.*;
import mx.styles.*;
import mx.skins.*;
import mx.utils.*;
public class HaloFocusRect extends ProgrammaticSkin implements IStyleClient {
private var _focusColor:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function HaloFocusRect(){
super();
}
public function get inheritingStyles():Object{
return (styleName.inheritingStyles);
}
public function set inheritingStyles(value:Object):void{
}
public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void{
}
public function registerEffects(effects:Array):void{
}
public function regenerateStyleCache(recursive:Boolean):void{
}
public function get styleDeclaration():CSSStyleDeclaration{
return (CSSStyleDeclaration(styleName));
}
public function getClassStyleDeclarations():Array{
return ([]);
}
public function get className():String{
return ("HaloFocusRect");
}
public function clearStyle(styleProp:String):void{
if (styleProp == "focusColor"){
_focusColor = NaN;
};
}
public function setStyle(styleProp:String, newValue):void{
if (styleProp == "focusColor"){
_focusColor = newValue;
};
}
public function set nonInheritingStyles(value:Object):void{
}
public function get nonInheritingStyles():Object{
return (styleName.nonInheritingStyles);
}
override protected function updateDisplayList(w:Number, h:Number):void{
var tl:Number;
var bl:Number;
var tr:Number;
var br:Number;
var nr:Number;
var ellipseSize:Number;
super.updateDisplayList(w, h);
var focusBlendMode:String = getStyle("focusBlendMode");
var focusAlpha:Number = getStyle("focusAlpha");
var focusColor:Number = getStyle("focusColor");
var cornerRadius:Number = getStyle("cornerRadius");
var focusThickness:Number = getStyle("focusThickness");
var focusRoundedCorners:String = getStyle("focusRoundedCorners");
var themeColor:Number = getStyle("themeColor");
var rectColor:Number = focusColor;
if (isNaN(rectColor)){
rectColor = themeColor;
};
var g:Graphics = graphics;
g.clear();
blendMode = focusBlendMode;
if (((!((focusRoundedCorners == "tl tr bl br"))) && ((cornerRadius > 0)))){
tl = 0;
bl = 0;
tr = 0;
br = 0;
nr = (cornerRadius + focusThickness);
if (focusRoundedCorners.indexOf("tl") >= 0){
tl = nr;
};
if (focusRoundedCorners.indexOf("tr") >= 0){
tr = nr;
};
if (focusRoundedCorners.indexOf("bl") >= 0){
bl = nr;
};
if (focusRoundedCorners.indexOf("br") >= 0){
br = nr;
};
g.beginFill(rectColor, focusAlpha);
GraphicsUtil.drawRoundRectComplex(g, 0, 0, w, h, tl, tr, bl, br);
tl = (tl) ? cornerRadius : 0;
tr = (tr) ? cornerRadius : 0;
bl = (bl) ? cornerRadius : 0;
br = (br) ? cornerRadius : 0;
GraphicsUtil.drawRoundRectComplex(g, focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), tl, tr, bl, br);
g.endFill();
nr = (cornerRadius + (focusThickness / 2));
tl = (tl) ? nr : 0;
tr = (tr) ? nr : 0;
bl = (bl) ? nr : 0;
br = (br) ? nr : 0;
g.beginFill(rectColor, focusAlpha);
GraphicsUtil.drawRoundRectComplex(g, (focusThickness / 2), (focusThickness / 2), (w - focusThickness), (h - focusThickness), tl, tr, bl, br);
tl = (tl) ? cornerRadius : 0;
tr = (tr) ? cornerRadius : 0;
bl = (bl) ? cornerRadius : 0;
br = (br) ? cornerRadius : 0;
GraphicsUtil.drawRoundRectComplex(g, focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), tl, tr, bl, br);
g.endFill();
} else {
g.beginFill(rectColor, focusAlpha);
ellipseSize = (((cornerRadius > 0)) ? (cornerRadius + focusThickness) : 0 * 2);
g.drawRoundRect(0, 0, w, h, ellipseSize, ellipseSize);
ellipseSize = (cornerRadius * 2);
g.drawRoundRect(focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), ellipseSize, ellipseSize);
g.endFill();
g.beginFill(rectColor, focusAlpha);
ellipseSize = (((cornerRadius > 0)) ? (cornerRadius + (focusThickness / 2)) : 0 * 2);
g.drawRoundRect((focusThickness / 2), (focusThickness / 2), (w - focusThickness), (h - focusThickness), ellipseSize, ellipseSize);
ellipseSize = (cornerRadius * 2);
g.drawRoundRect(focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), ellipseSize, ellipseSize);
g.endFill();
};
}
override public function getStyle(styleProp:String){
return (((styleProp == "focusColor")) ? _focusColor : super.getStyle(styleProp));
}
public function set styleDeclaration(value:CSSStyleDeclaration):void{
}
}
}//package mx.skins.halo
Section 290
//ToolTipBorder (mx.skins.halo.ToolTipBorder)
package mx.skins.halo {
import flash.display.*;
import mx.core.*;
import mx.skins.*;
import mx.graphics.*;
import flash.filters.*;
public class ToolTipBorder extends RectangularBorder {
private var _borderMetrics:EdgeMetrics;
private var dropShadow:RectangularDropShadow;
mx_internal static const VERSION:String = "3.0.0.0";
public function ToolTipBorder(){
super();
}
override public function get borderMetrics():EdgeMetrics{
if (_borderMetrics){
return (_borderMetrics);
};
var borderStyle:String = getStyle("borderStyle");
switch (borderStyle){
case "errorTipRight":
_borderMetrics = new EdgeMetrics(15, 1, 3, 3);
break;
case "errorTipAbove":
_borderMetrics = new EdgeMetrics(3, 1, 3, 15);
break;
case "errorTipBelow":
_borderMetrics = new EdgeMetrics(3, 13, 3, 3);
break;
default:
_borderMetrics = new EdgeMetrics(3, 1, 3, 3);
break;
};
return (_borderMetrics);
}
override protected function updateDisplayList(w:Number, h:Number):void{
super.updateDisplayList(w, h);
var borderStyle:String = getStyle("borderStyle");
var backgroundColor:uint = getStyle("backgroundColor");
var backgroundAlpha:Number = getStyle("backgroundAlpha");
var borderColor:uint = getStyle("borderColor");
var cornerRadius:Number = getStyle("cornerRadius");
var shadowColor:uint = getStyle("shadowColor");
var shadowAlpha:Number = 0.1;
var g:Graphics = graphics;
g.clear();
filters = [];
switch (borderStyle){
case "toolTip":
drawRoundRect(3, 1, (w - 6), (h - 4), cornerRadius, backgroundColor, backgroundAlpha);
if (!dropShadow){
dropShadow = new RectangularDropShadow();
};
dropShadow.distance = 3;
dropShadow.angle = 90;
dropShadow.color = 0;
dropShadow.alpha = 0.4;
dropShadow.tlRadius = (cornerRadius + 2);
dropShadow.trRadius = (cornerRadius + 2);
dropShadow.blRadius = (cornerRadius + 2);
dropShadow.brRadius = (cornerRadius + 2);
dropShadow.drawShadow(graphics, 3, 0, (w - 6), (h - 4));
break;
case "errorTipRight":
drawRoundRect(11, 0, (w - 11), (h - 2), 3, borderColor, backgroundAlpha);
g.beginFill(borderColor, backgroundAlpha);
g.moveTo(11, 7);
g.lineTo(0, 13);
g.lineTo(11, 19);
g.moveTo(11, 7);
g.endFill();
filters = [new DropShadowFilter(2, 90, 0, 0.4)];
break;
case "errorTipAbove":
drawRoundRect(0, 0, w, (h - 13), 3, borderColor, backgroundAlpha);
g.beginFill(borderColor, backgroundAlpha);
g.moveTo(9, (h - 13));
g.lineTo(15, (h - 2));
g.lineTo(21, (h - 13));
g.moveTo(9, (h - 13));
g.endFill();
filters = [new DropShadowFilter(2, 90, 0, 0.4)];
break;
case "errorTipBelow":
drawRoundRect(0, 11, w, (h - 13), 3, borderColor, backgroundAlpha);
g.beginFill(borderColor, backgroundAlpha);
g.moveTo(9, 11);
g.lineTo(15, 0);
g.lineTo(21, 11);
g.moveTo(10, 11);
g.endFill();
filters = [new DropShadowFilter(2, 90, 0, 0.4)];
break;
};
}
override public function styleChanged(styleProp:String):void{
if ((((((styleProp == "borderStyle")) || ((styleProp == "styleName")))) || ((styleProp == null)))){
_borderMetrics = null;
};
invalidateDisplayList();
}
}
}//package mx.skins.halo
Section 291
//Border (mx.skins.Border)
package mx.skins {
import mx.core.*;
public class Border extends ProgrammaticSkin implements IBorder {
mx_internal static const VERSION:String = "3.0.0.0";
public function Border(){
super();
}
public function get borderMetrics():EdgeMetrics{
return (EdgeMetrics.EMPTY);
}
}
}//package mx.skins
Section 292
//ProgrammaticSkin (mx.skins.ProgrammaticSkin)
package mx.skins {
import flash.display.*;
import mx.core.*;
import mx.styles.*;
import flash.geom.*;
import mx.managers.*;
import mx.utils.*;
public class ProgrammaticSkin extends FlexShape implements IFlexDisplayObject, IInvalidating, ILayoutManagerClient, ISimpleStyleClient, IProgrammaticSkin {
private var _initialized:Boolean;// = false
private var _height:Number;
private var invalidateDisplayListFlag:Boolean;// = false
private var _styleName:IStyleClient;
private var _nestLevel:int;// = 0
private var _processedDescriptors:Boolean;// = false
private var _updateCompletePendingFlag:Boolean;// = true
private var _width:Number;
mx_internal static const VERSION:String = "3.0.0.0";
private static var tempMatrix:Matrix = new Matrix();
public function ProgrammaticSkin(){
super();
_width = measuredWidth;
_height = measuredHeight;
}
public function getStyle(styleProp:String){
return (_styleName.getStyle(styleProp));
}
protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
}
public function get nestLevel():int{
return (_nestLevel);
}
public function set nestLevel(value:int):void{
_nestLevel = value;
invalidateDisplayList();
}
override public function get height():Number{
return (_height);
}
public function get updateCompletePendingFlag():Boolean{
return (_updateCompletePendingFlag);
}
protected function verticalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{
return (rotatedGradientMatrix(x, y, width, height, 90));
}
public function validateSize(recursive:Boolean=false):void{
}
public function invalidateDisplayList():void{
if (((!(invalidateDisplayListFlag)) && ((nestLevel > 0)))){
invalidateDisplayListFlag = true;
UIComponentGlobals.layoutManager.invalidateDisplayList(this);
};
}
public function set updateCompletePendingFlag(value:Boolean):void{
_updateCompletePendingFlag = value;
}
protected function horizontalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{
return (rotatedGradientMatrix(x, y, width, height, 0));
}
override public function set height(value:Number):void{
_height = value;
invalidateDisplayList();
}
public function set processedDescriptors(value:Boolean):void{
_processedDescriptors = value;
}
public function validateDisplayList():void{
invalidateDisplayListFlag = false;
updateDisplayList(width, height);
}
public function get measuredWidth():Number{
return (0);
}
override public function set width(value:Number):void{
_width = value;
invalidateDisplayList();
}
public function get measuredHeight():Number{
return (0);
}
public function set initialized(value:Boolean):void{
_initialized = value;
}
protected function drawRoundRect(x:Number, y:Number, width:Number, height:Number, cornerRadius:Object=null, color:Object=null, alpha:Object=null, gradientMatrix:Matrix=null, gradientType:String="linear", gradientRatios:Array=null, hole:Object=null):void{
var ellipseSize:Number;
var alphas:Array;
var holeR:Object;
var g:Graphics = graphics;
if ((((width == 0)) || ((height == 0)))){
return;
};
if (color !== null){
if ((color is uint)){
g.beginFill(uint(color), Number(alpha));
} else {
if ((color is Array)){
alphas = ((alpha is Array)) ? (alpha as Array) : [alpha, alpha];
if (!gradientRatios){
gradientRatios = [0, 0xFF];
};
g.beginGradientFill(gradientType, (color as Array), alphas, gradientRatios, gradientMatrix);
};
};
};
if (!cornerRadius){
g.drawRect(x, y, width, height);
} else {
if ((cornerRadius is Number)){
ellipseSize = (Number(cornerRadius) * 2);
g.drawRoundRect(x, y, width, height, ellipseSize, ellipseSize);
} else {
GraphicsUtil.drawRoundRectComplex(g, x, y, width, height, cornerRadius.tl, cornerRadius.tr, cornerRadius.bl, cornerRadius.br);
};
};
if (hole){
holeR = hole.r;
if ((holeR is Number)){
ellipseSize = (Number(holeR) * 2);
g.drawRoundRect(hole.x, hole.y, hole.w, hole.h, ellipseSize, ellipseSize);
} else {
GraphicsUtil.drawRoundRectComplex(g, hole.x, hole.y, hole.w, hole.h, holeR.tl, holeR.tr, holeR.bl, holeR.br);
};
};
if (color !== null){
g.endFill();
};
}
public function get processedDescriptors():Boolean{
return (_processedDescriptors);
}
public function set styleName(value:Object):void{
if (_styleName != value){
_styleName = (value as IStyleClient);
invalidateDisplayList();
};
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
var changed:Boolean;
if (_width != newWidth){
_width = newWidth;
changed = true;
};
if (_height != newHeight){
_height = newHeight;
changed = true;
};
if (changed){
invalidateDisplayList();
};
}
public function styleChanged(styleProp:String):void{
invalidateDisplayList();
}
override public function get width():Number{
return (_width);
}
public function invalidateProperties():void{
}
public function get initialized():Boolean{
return (_initialized);
}
protected function rotatedGradientMatrix(x:Number, y:Number, width:Number, height:Number, rotation:Number):Matrix{
tempMatrix.createGradientBox(width, height, ((rotation * Math.PI) / 180), x, y);
return (tempMatrix);
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
public function get styleName():Object{
return (_styleName);
}
public function validateNow():void{
if (invalidateDisplayListFlag){
validateDisplayList();
};
}
public function invalidateSize():void{
}
public function validateProperties():void{
}
}
}//package mx.skins
Section 293
//RectangularBorder (mx.skins.RectangularBorder)
package mx.skins {
import flash.events.*;
import flash.display.*;
import mx.core.*;
import mx.styles.*;
import flash.system.*;
import flash.geom.*;
import flash.net.*;
import mx.resources.*;
import flash.utils.*;
public class RectangularBorder extends Border implements IRectangularBorder {
private var backgroundImage:DisplayObject;
private var backgroundImageHeight:Number;
private var _backgroundImageBounds:Rectangle;
private var backgroundImageStyle:Object;
private var backgroundImageWidth:Number;
private var resourceManager:IResourceManager;
mx_internal static const VERSION:String = "3.0.0.0";
public function RectangularBorder(){
resourceManager = ResourceManager.getInstance();
super();
addEventListener(Event.REMOVED, removedHandler);
}
public function layoutBackgroundImage():void{
var sW:Number;
var sH:Number;
var sX:Number;
var sY:Number;
var scale:Number;
var g:Graphics;
var p:DisplayObject = parent;
var bm:EdgeMetrics = ((p is IContainer)) ? IContainer(p).viewMetrics : borderMetrics;
var scrollableBk = !((getStyle("backgroundAttachment") == "fixed"));
if (_backgroundImageBounds){
sW = _backgroundImageBounds.width;
sH = _backgroundImageBounds.height;
} else {
sW = ((width - bm.left) - bm.right);
sH = ((height - bm.top) - bm.bottom);
};
var percentage:Number = getBackgroundSize();
if (isNaN(percentage)){
sX = 1;
sY = 1;
} else {
scale = (percentage * 0.01);
sX = ((scale * sW) / backgroundImageWidth);
sY = ((scale * sH) / backgroundImageHeight);
};
backgroundImage.scaleX = sX;
backgroundImage.scaleY = sY;
var offsetX:Number = Math.round((0.5 * (sW - (backgroundImageWidth * sX))));
var offsetY:Number = Math.round((0.5 * (sH - (backgroundImageHeight * sY))));
backgroundImage.x = bm.left;
backgroundImage.y = bm.top;
var backgroundMask:Shape = Shape(backgroundImage.mask);
backgroundMask.x = bm.left;
backgroundMask.y = bm.top;
if (((scrollableBk) && ((p is IContainer)))){
offsetX = (offsetX - IContainer(p).horizontalScrollPosition);
offsetY = (offsetY - IContainer(p).verticalScrollPosition);
};
backgroundImage.alpha = getStyle("backgroundAlpha");
backgroundImage.x = (backgroundImage.x + offsetX);
backgroundImage.y = (backgroundImage.y + offsetY);
var maskWidth:Number = ((width - bm.left) - bm.right);
var maskHeight:Number = ((height - bm.top) - bm.bottom);
if (((!((backgroundMask.width == maskWidth))) || (!((backgroundMask.height == maskHeight))))){
g = backgroundMask.graphics;
g.clear();
g.beginFill(0xFFFFFF);
g.drawRect(0, 0, maskWidth, maskHeight);
g.endFill();
};
}
public function set backgroundImageBounds(value:Rectangle):void{
_backgroundImageBounds = value;
invalidateDisplayList();
}
private function getBackgroundSize():Number{
var index:int;
var percentage:Number = NaN;
var backgroundSize:Object = getStyle("backgroundSize");
if (((backgroundSize) && ((backgroundSize is String)))){
index = backgroundSize.indexOf("%");
if (index != -1){
percentage = Number(backgroundSize.substr(0, index));
};
};
return (percentage);
}
private function removedHandler(event:Event):void{
var childrenList:IChildList;
if (backgroundImage){
childrenList = ((parent is IRawChildrenContainer)) ? IRawChildrenContainer(parent).rawChildren : IChildList(parent);
childrenList.removeChild(backgroundImage.mask);
childrenList.removeChild(backgroundImage);
backgroundImage = null;
};
}
private function initBackgroundImage(image:DisplayObject):void{
backgroundImage = image;
if ((image is Loader)){
backgroundImageWidth = Loader(image).contentLoaderInfo.width;
backgroundImageHeight = Loader(image).contentLoaderInfo.height;
} else {
backgroundImageWidth = backgroundImage.width;
backgroundImageHeight = backgroundImage.height;
if ((image is ISimpleStyleClient)){
ISimpleStyleClient(image).styleName = styleName;
};
};
var childrenList:IChildList = ((parent is IRawChildrenContainer)) ? IRawChildrenContainer(parent).rawChildren : IChildList(parent);
var backgroundMask:Shape = new FlexShape();
backgroundMask.name = "backgroundMask";
backgroundMask.x = 0;
backgroundMask.y = 0;
childrenList.addChild(backgroundMask);
var myIndex:int = childrenList.getChildIndex(this);
childrenList.addChildAt(backgroundImage, (myIndex + 1));
backgroundImage.mask = backgroundMask;
}
public function get backgroundImageBounds():Rectangle{
return (_backgroundImageBounds);
}
public function get hasBackgroundImage():Boolean{
return (!((backgroundImage == null)));
}
private function completeEventHandler(event:Event):void{
if (!parent){
return;
};
var target:DisplayObject = DisplayObject(LoaderInfo(event.target).loader);
initBackgroundImage(target);
layoutBackgroundImage();
dispatchEvent(event.clone());
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
var cls:Class;
var newStyleObj:DisplayObject;
var loader:Loader;
var loaderContext:LoaderContext;
var message:String;
var unscaledWidth = unscaledWidth;
var unscaledHeight = unscaledHeight;
if (!parent){
return;
};
var newStyle:Object = getStyle("backgroundImage");
if (newStyle != backgroundImageStyle){
removedHandler(null);
backgroundImageStyle = newStyle;
if (((newStyle) && ((newStyle as Class)))){
cls = Class(newStyle);
initBackgroundImage(new (cls));
} else {
if (((newStyle) && ((newStyle is String)))){
cls = Class(getDefinitionByName(String(newStyle)));
//unresolved jump
var _slot1 = e;
if (cls){
newStyleObj = new (cls);
initBackgroundImage(newStyleObj);
} else {
loader = new FlexLoader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeEventHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorEventHandler);
loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, errorEventHandler);
loaderContext = new LoaderContext();
loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.load(new URLRequest(String(newStyle)), loaderContext);
};
} else {
if (newStyle){
message = resourceManager.getString("skins", "notLoaded", [newStyle]);
throw (new Error(message));
};
};
};
};
if (backgroundImage){
layoutBackgroundImage();
};
}
private function errorEventHandler(event:Event):void{
}
}
}//package mx.skins
Section 294
//CSSStyleDeclaration (mx.styles.CSSStyleDeclaration)
package mx.styles {
import flash.events.*;
import flash.display.*;
import mx.core.*;
import mx.managers.*;
import flash.utils.*;
public class CSSStyleDeclaration extends EventDispatcher {
mx_internal var effects:Array;
protected var overrides:Object;
public var defaultFactory:Function;
public var factory:Function;
mx_internal var selectorRefCount:int;// = 0
private var styleManager:IStyleManager2;
private var clones:Dictionary;
mx_internal static const VERSION:String = "3.0.0.0";
private static const NOT_A_COLOR:uint = 4294967295;
private static const FILTERMAP_PROP:String = "__reserved__filterMap";
public function CSSStyleDeclaration(selector:String=null){
clones = new Dictionary(true);
super();
if (selector){
styleManager = (Singleton.getInstance("mx.styles::IStyleManager2") as IStyleManager2);
styleManager.setStyleDeclaration(selector, this, false);
};
}
mx_internal function addStyleToProtoChain(chain:Object, target:DisplayObject, filterMap:Object=null):Object{
var p:String;
var emptyObjectFactory:Function;
var filteredChain:Object;
var filterObjectFactory:Function;
var i:String;
var chain = chain;
var target = target;
var filterMap = filterMap;
var nodeAddedToChain:Boolean;
var originalChain:Object = chain;
if (filterMap){
chain = {};
};
if (defaultFactory != null){
defaultFactory.prototype = chain;
chain = new defaultFactory();
nodeAddedToChain = true;
};
if (factory != null){
factory.prototype = chain;
chain = new factory();
nodeAddedToChain = true;
};
if (overrides){
if ((((defaultFactory == null)) && ((factory == null)))){
emptyObjectFactory = function ():void{
};
emptyObjectFactory.prototype = chain;
chain = new (emptyObjectFactory);
nodeAddedToChain = true;
};
for (p in overrides) {
if (overrides[p] === undefined){
delete chain[p];
} else {
chain[p] = overrides[p];
};
};
};
if (filterMap){
if (nodeAddedToChain){
filteredChain = {};
filterObjectFactory = function ():void{
};
filterObjectFactory.prototype = originalChain;
filteredChain = new (filterObjectFactory);
for (i in chain) {
if (filterMap[i] != null){
filteredChain[filterMap[i]] = chain[i];
};
};
chain = filteredChain;
chain[FILTERMAP_PROP] = filterMap;
} else {
chain = originalChain;
};
};
if (nodeAddedToChain){
clones[chain] = 1;
};
return (chain);
}
public function getStyle(styleProp:String){
var o:*;
var v:*;
if (overrides){
if ((((styleProp in overrides)) && ((overrides[styleProp] === undefined)))){
return (undefined);
};
v = overrides[styleProp];
if (v !== undefined){
return (v);
};
};
if (factory != null){
factory.prototype = {};
o = new factory();
v = o[styleProp];
if (v !== undefined){
return (v);
};
};
if (defaultFactory != null){
defaultFactory.prototype = {};
o = new defaultFactory();
v = o[styleProp];
if (v !== undefined){
return (v);
};
};
return (undefined);
}
public function clearStyle(styleProp:String):void{
setStyle(styleProp, undefined);
}
public function setStyle(styleProp:String, newValue):void{
var i:int;
var sm:Object;
var oldValue:Object = getStyle(styleProp);
var regenerate:Boolean;
if ((((((((((selectorRefCount > 0)) && ((factory == null)))) && ((defaultFactory == null)))) && (!(overrides)))) && (!((oldValue === newValue))))){
regenerate = true;
};
if (newValue !== undefined){
setStyle(styleProp, newValue);
} else {
if (newValue == oldValue){
return;
};
setStyle(styleProp, newValue);
};
var sms:Array = SystemManagerGlobals.topLevelSystemManagers;
var n:int = sms.length;
if (regenerate){
i = 0;
while (i < n) {
sm = sms[i];
sm.regenerateStyleCache(true);
i++;
};
};
i = 0;
while (i < n) {
sm = sms[i];
sm.notifyStyleChangeInChildren(styleProp, true);
i++;
};
}
private function clearStyleAttr(styleProp:String):void{
var clone:*;
if (!overrides){
overrides = {};
};
overrides[styleProp] = undefined;
for (clone in clones) {
delete clone[styleProp];
};
}
mx_internal function createProtoChainRoot():Object{
var root:Object = {};
if (defaultFactory != null){
defaultFactory.prototype = root;
root = new defaultFactory();
};
if (factory != null){
factory.prototype = root;
root = new factory();
};
clones[root] = 1;
return (root);
}
mx_internal function clearOverride(styleProp:String):void{
if (((overrides) && (overrides[styleProp]))){
delete overrides[styleProp];
};
}
mx_internal function setStyle(styleProp:String, value):void{
var o:Object;
var clone:*;
var colorNumber:Number;
var cloneFilter:Object;
if (value === undefined){
clearStyleAttr(styleProp);
return;
};
if ((value is String)){
if (!styleManager){
styleManager = (Singleton.getInstance("mx.styles::IStyleManager2") as IStyleManager2);
};
colorNumber = styleManager.getColorName(value);
if (colorNumber != NOT_A_COLOR){
value = colorNumber;
};
};
if (defaultFactory != null){
o = new defaultFactory();
if (o[styleProp] !== value){
if (!overrides){
overrides = {};
};
overrides[styleProp] = value;
} else {
if (overrides){
delete overrides[styleProp];
};
};
};
if (factory != null){
o = new factory();
if (o[styleProp] !== value){
if (!overrides){
overrides = {};
};
overrides[styleProp] = value;
} else {
if (overrides){
delete overrides[styleProp];
};
};
};
if ((((defaultFactory == null)) && ((factory == null)))){
if (!overrides){
overrides = {};
};
overrides[styleProp] = value;
};
for (clone in clones) {
cloneFilter = clone[FILTERMAP_PROP];
if (cloneFilter){
if (cloneFilter[styleProp] != null){
clone[cloneFilter[styleProp]] = value;
};
} else {
clone[styleProp] = value;
};
};
}
}
}//package mx.styles
Section 295
//ISimpleStyleClient (mx.styles.ISimpleStyleClient)
package mx.styles {
public interface ISimpleStyleClient {
function set styleName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;ISimpleStyleClient.as:Object):void;
function styleChanged(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;ISimpleStyleClient.as:String):void;
function get styleName():Object;
}
}//package mx.styles
Section 296
//IStyleClient (mx.styles.IStyleClient)
package mx.styles {
public interface IStyleClient extends ISimpleStyleClient {
function regenerateStyleCache(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Boolean):void;
function get className():String;
function clearStyle(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:String):void;
function getClassStyleDeclarations():Array;
function get inheritingStyles():Object;
function set nonInheritingStyles(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Object):void;
function setStyle(_arg1:String, _arg2):void;
function get styleDeclaration():CSSStyleDeclaration;
function set styleDeclaration(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:CSSStyleDeclaration):void;
function get nonInheritingStyles():Object;
function set inheritingStyles(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Object):void;
function getStyle(*:String);
function notifyStyleChangeInChildren(_arg1:String, _arg2:Boolean):void;
function registerEffects(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Array):void;
}
}//package mx.styles
Section 297
//IStyleManager (mx.styles.IStyleManager)
package mx.styles {
import flash.events.*;
public interface IStyleManager {
function isColorName(value:String):Boolean;
function registerParentDisplayListInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void;
function registerInheritingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void;
function set stylesRoot(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void;
function get typeSelectorCache():Object;
function styleDeclarationsChanged():void;
function setStyleDeclaration(_arg1:String, _arg2:CSSStyleDeclaration, _arg3:Boolean):void;
function isParentDisplayListInvalidatingStyle(value:String):Boolean;
function isSizeInvalidatingStyle(value:String):Boolean;
function get inheritingStyles():Object;
function isValidStyleValue(value):Boolean;
function isParentSizeInvalidatingStyle(value:String):Boolean;
function getColorName(mx.styles:IStyleManager/mx.styles:IStyleManager:inheritingStyles/set:Object):uint;
function set typeSelectorCache(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void;
function unloadStyleDeclarations(_arg1:String, _arg2:Boolean=true):void;
function getColorNames(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Array):void;
function loadStyleDeclarations(_arg1:String, _arg2:Boolean=true, _arg3:Boolean=false):IEventDispatcher;
function isInheritingStyle(value:String):Boolean;
function set inheritingStyles(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void;
function get stylesRoot():Object;
function initProtoChainRoots():void;
function registerColorName(_arg1:String, _arg2:uint):void;
function registerParentSizeInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void;
function registerSizeInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void;
function clearStyleDeclaration(_arg1:String, _arg2:Boolean):void;
function isInheritingTextFormatStyle(value:String):Boolean;
function getStyleDeclaration(mx.styles:IStyleManager/mx.styles:IStyleManager:inheritingStyles/get:String):CSSStyleDeclaration;
}
}//package mx.styles
Section 298
//IStyleManager2 (mx.styles.IStyleManager2)
package mx.styles {
import flash.events.*;
import flash.system.*;
public interface IStyleManager2 extends IStyleManager {
function get selectors():Array;
function loadStyleDeclarations2(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher;
}
}//package mx.styles
Section 299
//IStyleModule (mx.styles.IStyleModule)
package mx.styles {
public interface IStyleModule {
function unload():void;
}
}//package mx.styles
Section 300
//StyleManager (mx.styles.StyleManager)
package mx.styles {
import flash.events.*;
import mx.core.*;
import flash.system.*;
public class StyleManager {
mx_internal static const VERSION:String = "3.0.0.0";
public static const NOT_A_COLOR:uint = 4294967295;
private static var _impl:IStyleManager2;
private static var implClassDependency:StyleManagerImpl;
public function StyleManager(){
super();
}
public static function isParentSizeInvalidatingStyle(styleName:String):Boolean{
return (impl.isParentSizeInvalidatingStyle(styleName));
}
public static function registerInheritingStyle(styleName:String):void{
impl.registerInheritingStyle(styleName);
}
mx_internal static function set stylesRoot(value:Object):void{
impl.stylesRoot = value;
}
mx_internal static function get inheritingStyles():Object{
return (impl.inheritingStyles);
}
mx_internal static function styleDeclarationsChanged():void{
impl.styleDeclarationsChanged();
}
public static function setStyleDeclaration(selector:String, styleDeclaration:CSSStyleDeclaration, update:Boolean):void{
impl.setStyleDeclaration(selector, styleDeclaration, update);
}
public static function registerParentDisplayListInvalidatingStyle(styleName:String):void{
impl.registerParentDisplayListInvalidatingStyle(styleName);
}
mx_internal static function get typeSelectorCache():Object{
return (impl.typeSelectorCache);
}
mx_internal static function set inheritingStyles(value:Object):void{
impl.inheritingStyles = value;
}
public static function isColorName(colorName:String):Boolean{
return (impl.isColorName(colorName));
}
public static function isParentDisplayListInvalidatingStyle(styleName:String):Boolean{
return (impl.isParentDisplayListInvalidatingStyle(styleName));
}
public static function isSizeInvalidatingStyle(styleName:String):Boolean{
return (impl.isSizeInvalidatingStyle(styleName));
}
public static function getColorName(colorName:Object):uint{
return (impl.getColorName(colorName));
}
mx_internal static function set typeSelectorCache(value:Object):void{
impl.typeSelectorCache = value;
}
public static function unloadStyleDeclarations(url:String, update:Boolean=true):void{
impl.unloadStyleDeclarations(url, update);
}
public static function getColorNames(colors:Array):void{
impl.getColorNames(colors);
}
public static function loadStyleDeclarations(url:String, update:Boolean=true, trustContent:Boolean=false, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{
return (impl.loadStyleDeclarations2(url, update, applicationDomain, securityDomain));
}
private static function get impl():IStyleManager2{
if (!_impl){
_impl = IStyleManager2(Singleton.getInstance("mx.styles::IStyleManager2"));
};
return (_impl);
}
public static function isValidStyleValue(value):Boolean{
return (impl.isValidStyleValue(value));
}
mx_internal static function get stylesRoot():Object{
return (impl.stylesRoot);
}
public static function isInheritingStyle(styleName:String):Boolean{
return (impl.isInheritingStyle(styleName));
}
mx_internal static function initProtoChainRoots():void{
impl.initProtoChainRoots();
}
public static function registerParentSizeInvalidatingStyle(styleName:String):void{
impl.registerParentSizeInvalidatingStyle(styleName);
}
public static function get selectors():Array{
return (impl.selectors);
}
public static function registerSizeInvalidatingStyle(styleName:String):void{
impl.registerSizeInvalidatingStyle(styleName);
}
public static function clearStyleDeclaration(selector:String, update:Boolean):void{
impl.clearStyleDeclaration(selector, update);
}
public static function registerColorName(colorName:String, colorValue:uint):void{
impl.registerColorName(colorName, colorValue);
}
public static function isInheritingTextFormatStyle(styleName:String):Boolean{
return (impl.isInheritingTextFormatStyle(styleName));
}
public static function getStyleDeclaration(selector:String):CSSStyleDeclaration{
return (impl.getStyleDeclaration(selector));
}
}
}//package mx.styles
Section 301
//StyleManagerImpl (mx.styles.StyleManagerImpl)
package mx.styles {
import flash.events.*;
import mx.core.*;
import flash.system.*;
import mx.modules.*;
import mx.events.*;
import mx.resources.*;
import mx.managers.*;
import flash.utils.*;
public class StyleManagerImpl implements IStyleManager2 {
private var _stylesRoot:Object;
private var _selectors:Object;
private var styleModules:Object;
private var _inheritingStyles:Object;
private var resourceManager:IResourceManager;
private var _typeSelectorCache:Object;
mx_internal static const VERSION:String = "3.0.0.0";
private static var parentSizeInvalidatingStyles:Object = {bottom:true, horizontalCenter:true, left:true, right:true, top:true, verticalCenter:true, baseline:true};
private static var colorNames:Object = {transparent:"transparent", black:0, blue:0xFF, green:0x8000, gray:0x808080, silver:0xC0C0C0, lime:0xFF00, olive:0x808000, white:0xFFFFFF, yellow:0xFFFF00, maroon:0x800000, navy:128, red:0xFF0000, purple:0x800080, teal:0x8080, fuchsia:0xFF00FF, aqua:0xFFFF, magenta:0xFF00FF, cyan:0xFFFF, halogreen:8453965, haloblue:40447, haloorange:0xFFB600, halosilver:11455193};
private static var inheritingTextFormatStyles:Object = {align:true, bold:true, color:true, font:true, indent:true, italic:true, size:true};
private static var instance:IStyleManager2;
private static var parentDisplayListInvalidatingStyles:Object = {bottom:true, horizontalCenter:true, left:true, right:true, top:true, verticalCenter:true, baseline:true};
private static var sizeInvalidatingStyles:Object = {borderStyle:true, borderThickness:true, fontAntiAliasType:true, fontFamily:true, fontGridFitType:true, fontSharpness:true, fontSize:true, fontStyle:true, fontThickness:true, fontWeight:true, headerHeight:true, horizontalAlign:true, horizontalGap:true, kerning:true, leading:true, letterSpacing:true, paddingBottom:true, paddingLeft:true, paddingRight:true, paddingTop:true, strokeWidth:true, tabHeight:true, tabWidth:true, verticalAlign:true, verticalGap:true};
public function StyleManagerImpl(){
_selectors = {};
styleModules = {};
resourceManager = ResourceManager.getInstance();
_inheritingStyles = {};
_typeSelectorCache = {};
super();
}
public function setStyleDeclaration(selector:String, styleDeclaration:CSSStyleDeclaration, update:Boolean):void{
styleDeclaration.selectorRefCount++;
_selectors[selector] = styleDeclaration;
typeSelectorCache = {};
if (update){
styleDeclarationsChanged();
};
}
public function registerParentDisplayListInvalidatingStyle(styleName:String):void{
parentDisplayListInvalidatingStyles[styleName] = true;
}
public function getStyleDeclaration(selector:String):CSSStyleDeclaration{
var index:int;
if (selector.charAt(0) != "."){
index = selector.lastIndexOf(".");
if (index != -1){
selector = selector.substr((index + 1));
};
};
return (_selectors[selector]);
}
public function set typeSelectorCache(value:Object):void{
_typeSelectorCache = value;
}
public function isColorName(colorName:String):Boolean{
return (!((colorNames[colorName.toLowerCase()] === undefined)));
}
public function set inheritingStyles(value:Object):void{
_inheritingStyles = value;
}
public function getColorNames(colors:Array):void{
var colorNumber:uint;
if (!colors){
return;
};
var n:int = colors.length;
var i:int;
while (i < n) {
if (((!((colors[i] == null))) && (isNaN(colors[i])))){
colorNumber = getColorName(colors[i]);
if (colorNumber != StyleManager.NOT_A_COLOR){
colors[i] = colorNumber;
};
};
i++;
};
}
public function isInheritingTextFormatStyle(styleName:String):Boolean{
return ((inheritingTextFormatStyles[styleName] == true));
}
public function registerParentSizeInvalidatingStyle(styleName:String):void{
parentSizeInvalidatingStyles[styleName] = true;
}
public function registerColorName(colorName:String, colorValue:uint):void{
colorNames[colorName.toLowerCase()] = colorValue;
}
public function isParentSizeInvalidatingStyle(styleName:String):Boolean{
return ((parentSizeInvalidatingStyles[styleName] == true));
}
public function registerInheritingStyle(styleName:String):void{
inheritingStyles[styleName] = true;
}
public function set stylesRoot(value:Object):void{
_stylesRoot = value;
}
public function get typeSelectorCache():Object{
return (_typeSelectorCache);
}
public function isParentDisplayListInvalidatingStyle(styleName:String):Boolean{
return ((parentDisplayListInvalidatingStyles[styleName] == true));
}
public function isSizeInvalidatingStyle(styleName:String):Boolean{
return ((sizeInvalidatingStyles[styleName] == true));
}
public function styleDeclarationsChanged():void{
var sm:Object;
var sms:Array = SystemManagerGlobals.topLevelSystemManagers;
var n:int = sms.length;
var i:int;
while (i < n) {
sm = sms[i];
sm.regenerateStyleCache(true);
sm.notifyStyleChangeInChildren(null, true);
i++;
};
}
public function isValidStyleValue(value):Boolean{
return (!((value === undefined)));
}
public function loadStyleDeclarations(url:String, update:Boolean=true, trustContent:Boolean=false):IEventDispatcher{
return (loadStyleDeclarations2(url, update));
}
public function get inheritingStyles():Object{
return (_inheritingStyles);
}
public function unloadStyleDeclarations(url:String, update:Boolean=true):void{
var module:IModuleInfo;
var styleModuleInfo:StyleModuleInfo = styleModules[url];
if (styleModuleInfo){
styleModuleInfo.styleModule.unload();
module = styleModuleInfo.module;
module.unload();
module.removeEventListener(ModuleEvent.READY, styleModuleInfo.readyHandler);
module.removeEventListener(ModuleEvent.ERROR, styleModuleInfo.errorHandler);
styleModules[url] = null;
};
if (update){
styleDeclarationsChanged();
};
}
public function getColorName(colorName:Object):uint{
var n:Number;
var c:*;
if ((colorName is String)){
if (colorName.charAt(0) == "#"){
n = Number(("0x" + colorName.slice(1)));
return ((isNaN(n)) ? StyleManager.NOT_A_COLOR : uint(n));
};
if ((((colorName.charAt(1) == "x")) && ((colorName.charAt(0) == "0")))){
n = Number(colorName);
return ((isNaN(n)) ? StyleManager.NOT_A_COLOR : uint(n));
};
c = colorNames[colorName.toLowerCase()];
if (c === undefined){
return (StyleManager.NOT_A_COLOR);
};
return (uint(c));
};
return (uint(colorName));
}
public function isInheritingStyle(styleName:String):Boolean{
return ((inheritingStyles[styleName] == true));
}
public function get stylesRoot():Object{
return (_stylesRoot);
}
public function initProtoChainRoots():void{
if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){
delete _inheritingStyles["textDecoration"];
delete _inheritingStyles["leading"];
};
if (!stylesRoot){
stylesRoot = _selectors["global"].addStyleToProtoChain({}, null);
};
}
public function loadStyleDeclarations2(url:String, update:Boolean=true, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{
var module:IModuleInfo;
var styleEventDispatcher:StyleEventDispatcher;
var timer:Timer;
var timerHandler:Function;
var url = url;
var update = update;
var applicationDomain = applicationDomain;
var securityDomain = securityDomain;
module = ModuleManager.getModule(url);
var readyHandler:Function = function (moduleEvent:ModuleEvent):void{
var styleModule:IStyleModule = IStyleModule(moduleEvent.module.factory.create());
styleModules[moduleEvent.module.url].styleModule = styleModule;
if (update){
styleDeclarationsChanged();
};
};
module.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true);
styleEventDispatcher = new StyleEventDispatcher(module);
var errorHandler:Function = function (moduleEvent:ModuleEvent):void{
var styleEvent:StyleEvent;
var errorText:String = resourceManager.getString("styles", "unableToLoad", [moduleEvent.errorText, url]);
if (styleEventDispatcher.willTrigger(StyleEvent.ERROR)){
styleEvent = new StyleEvent(StyleEvent.ERROR, moduleEvent.bubbles, moduleEvent.cancelable);
styleEvent.bytesLoaded = 0;
styleEvent.bytesTotal = 0;
styleEvent.errorText = errorText;
styleEventDispatcher.dispatchEvent(styleEvent);
} else {
throw (new Error(errorText));
};
};
module.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true);
styleModules[url] = new StyleModuleInfo(module, readyHandler, errorHandler);
timer = new Timer(0);
timerHandler = function (event:TimerEvent):void{
timer.removeEventListener(TimerEvent.TIMER, timerHandler);
timer.stop();
module.load(applicationDomain, securityDomain);
};
timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true);
timer.start();
return (styleEventDispatcher);
}
public function registerSizeInvalidatingStyle(styleName:String):void{
sizeInvalidatingStyles[styleName] = true;
}
public function clearStyleDeclaration(selector:String, update:Boolean):void{
var styleDeclaration:CSSStyleDeclaration = getStyleDeclaration(selector);
if (((styleDeclaration) && ((styleDeclaration.selectorRefCount > 0)))){
styleDeclaration.selectorRefCount--;
};
delete _selectors[selector];
if (update){
styleDeclarationsChanged();
};
}
public function get selectors():Array{
var i:String;
var theSelectors:Array = [];
for (i in _selectors) {
theSelectors.push(i);
};
return (theSelectors);
}
public static function getInstance():IStyleManager2{
if (!instance){
instance = new (StyleManagerImpl);
};
return (instance);
}
}
}//package mx.styles
import flash.events.*;
import mx.modules.*;
import mx.events.*;
class StyleEventDispatcher extends EventDispatcher {
private function StyleEventDispatcher(moduleInfo:IModuleInfo){
super();
moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true);
}
private function moduleInfo_progressHandler(event:ModuleEvent):void{
var styleEvent:StyleEvent = new StyleEvent(StyleEvent.PROGRESS, event.bubbles, event.cancelable);
styleEvent.bytesLoaded = event.bytesLoaded;
styleEvent.bytesTotal = event.bytesTotal;
dispatchEvent(styleEvent);
}
private function moduleInfo_readyHandler(event:ModuleEvent):void{
var styleEvent:StyleEvent = new StyleEvent(StyleEvent.COMPLETE);
dispatchEvent(styleEvent);
}
private function moduleInfo_errorHandler(event:ModuleEvent):void{
var styleEvent:StyleEvent = new StyleEvent(StyleEvent.ERROR, event.bubbles, event.cancelable);
styleEvent.bytesLoaded = event.bytesLoaded;
styleEvent.bytesTotal = event.bytesTotal;
styleEvent.errorText = event.errorText;
dispatchEvent(styleEvent);
}
}
class StyleModuleInfo {
public var errorHandler:Function;
public var readyHandler:Function;
public var module:IModuleInfo;
public var styleModule:IStyleModule;
private function StyleModuleInfo(module:IModuleInfo, readyHandler:Function, errorHandler:Function){
super();
this.module = module;
this.readyHandler = readyHandler;
this.errorHandler = errorHandler;
}
}
Section 302
//ColorUtil (mx.utils.ColorUtil)
package mx.utils {
import mx.core.*;
public class ColorUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function ColorUtil(){
super();
}
public static function adjustBrightness2(rgb:uint, brite:Number):uint{
var r:Number;
var g:Number;
var b:Number;
if (brite == 0){
return (rgb);
};
if (brite < 0){
brite = ((100 + brite) / 100);
r = (((rgb >> 16) & 0xFF) * brite);
g = (((rgb >> 8) & 0xFF) * brite);
b = ((rgb & 0xFF) * brite);
} else {
brite = (brite / 100);
r = ((rgb >> 16) & 0xFF);
g = ((rgb >> 8) & 0xFF);
b = (rgb & 0xFF);
r = (r + ((0xFF - r) * brite));
g = (g + ((0xFF - g) * brite));
b = (b + ((0xFF - b) * brite));
r = Math.min(r, 0xFF);
g = Math.min(g, 0xFF);
b = Math.min(b, 0xFF);
};
return ((((r << 16) | (g << 8)) | b));
}
public static function rgbMultiply(rgb1:uint, rgb2:uint):uint{
var r1:Number = ((rgb1 >> 16) & 0xFF);
var g1:Number = ((rgb1 >> 8) & 0xFF);
var b1:Number = (rgb1 & 0xFF);
var r2:Number = ((rgb2 >> 16) & 0xFF);
var g2:Number = ((rgb2 >> 8) & 0xFF);
var b2:Number = (rgb2 & 0xFF);
return ((((((r1 * r2) / 0xFF) << 16) | (((g1 * g2) / 0xFF) << 8)) | ((b1 * b2) / 0xFF)));
}
public static function adjustBrightness(rgb:uint, brite:Number):uint{
var r:Number = Math.max(Math.min((((rgb >> 16) & 0xFF) + brite), 0xFF), 0);
var g:Number = Math.max(Math.min((((rgb >> 8) & 0xFF) + brite), 0xFF), 0);
var b:Number = Math.max(Math.min(((rgb & 0xFF) + brite), 0xFF), 0);
return ((((r << 16) | (g << 8)) | b));
}
}
}//package mx.utils
Section 303
//GraphicsUtil (mx.utils.GraphicsUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
public class GraphicsUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function GraphicsUtil(){
super();
}
public static function drawRoundRectComplex(graphics:Graphics, x:Number, y:Number, width:Number, height:Number, topLeftRadius:Number, topRightRadius:Number, bottomLeftRadius:Number, bottomRightRadius:Number):void{
var xw:Number = (x + width);
var yh:Number = (y + height);
var minSize:Number = ((width < height)) ? (width * 2) : (height * 2);
topLeftRadius = ((topLeftRadius < minSize)) ? topLeftRadius : minSize;
topRightRadius = ((topRightRadius < minSize)) ? topRightRadius : minSize;
bottomLeftRadius = ((bottomLeftRadius < minSize)) ? bottomLeftRadius : minSize;
bottomRightRadius = ((bottomRightRadius < minSize)) ? bottomRightRadius : minSize;
var a:Number = (bottomRightRadius * 0.292893218813453);
var s:Number = (bottomRightRadius * 0.585786437626905);
graphics.moveTo(xw, (yh - bottomRightRadius));
graphics.curveTo(xw, (yh - s), (xw - a), (yh - a));
graphics.curveTo((xw - s), yh, (xw - bottomRightRadius), yh);
a = (bottomLeftRadius * 0.292893218813453);
s = (bottomLeftRadius * 0.585786437626905);
graphics.lineTo((x + bottomLeftRadius), yh);
graphics.curveTo((x + s), yh, (x + a), (yh - a));
graphics.curveTo(x, (yh - s), x, (yh - bottomLeftRadius));
a = (topLeftRadius * 0.292893218813453);
s = (topLeftRadius * 0.585786437626905);
graphics.lineTo(x, (y + topLeftRadius));
graphics.curveTo(x, (y + s), (x + a), (y + a));
graphics.curveTo((x + s), y, (x + topLeftRadius), y);
a = (topRightRadius * 0.292893218813453);
s = (topRightRadius * 0.585786437626905);
graphics.lineTo((xw - topRightRadius), y);
graphics.curveTo((xw - s), y, (xw - a), (y + a));
graphics.curveTo(xw, (y + s), xw, (y + topRightRadius));
graphics.lineTo(xw, (yh - bottomRightRadius));
}
}
}//package mx.utils
Section 304
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public function NameUtil(){
super();
}
public static function displayObjectToString(displayObject:DisplayObject):String{
var result:String;
var s:String;
var indices:Array;
var o:DisplayObject = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
return (result);
}
public static function createUniqueName(object:Object):String{
if (!object){
return (null);
};
var name:String = getQualifiedClassName(object);
var index:int = name.indexOf("::");
if (index != -1){
name = name.substr((index + 2));
};
var charCode:int = name.charCodeAt((name.length - 1));
if ((((charCode >= 48)) && ((charCode <= 57)))){
name = (name + "_");
};
return ((name + counter++));
}
}
}//package mx.utils
Section 305
//StringUtil (mx.utils.StringUtil)
package mx.utils {
import mx.core.*;
public class StringUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function StringUtil(){
super();
}
public static function trim(str:String):String{
if (str == null){
return ("");
};
var startIndex:int;
while (isWhitespace(str.charAt(startIndex))) {
startIndex++;
};
var endIndex:int = (str.length - 1);
while (isWhitespace(str.charAt(endIndex))) {
endIndex--;
};
if (endIndex >= startIndex){
return (str.slice(startIndex, (endIndex + 1)));
};
return ("");
}
public static function isWhitespace(character:String):Boolean{
switch (character){
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return (true);
default:
return (false);
};
}
public static function substitute(str:String, ... _args):String{
var args:Array;
if (str == null){
return ("");
};
var len:uint = _args.length;
if ((((len == 1)) && ((_args[0] is Array)))){
args = (_args[0] as Array);
len = args.length;
} else {
args = _args;
};
var i:int;
while (i < len) {
str = str.replace(new RegExp((("\\{" + i) + "\\}"), "g"), args[i]);
i++;
};
return (str);
}
public static function trimArrayElements(value:String, delimiter:String):String{
var items:Array;
var len:int;
var i:int;
if (((!((value == ""))) && (!((value == null))))){
items = value.split(delimiter);
len = items.length;
i = 0;
while (i < len) {
items[i] = StringUtil.trim(items[i]);
i++;
};
if (len > 0){
value = items.join(delimiter);
};
};
return (value);
}
}
}//package mx.utils
Section 306
//_activeButtonStyleStyle (_activeButtonStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _activeButtonStyleStyle {
public static function init(_activeButtonStyleStyle:IFlexModuleFactory):void{
var fbs = _activeButtonStyleStyle;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".activeButtonStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".activeButtonStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
};
};
}
}
}//package
Section 307
//_activeTabStyleStyle (_activeTabStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _activeTabStyleStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".activeTabStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".activeTabStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
};
};
}
}
}//package
Section 308
//_alertButtonStyleStyle (_alertButtonStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _alertButtonStyleStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".alertButtonStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".alertButtonStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.color = 734012;
};
};
}
}
}//package
Section 309
//_comboDropdownStyle (_comboDropdownStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _comboDropdownStyle {
public static function init(leading:IFlexModuleFactory):void{
var fbs = leading;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".comboDropdown");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".comboDropdown", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.shadowDirection = "center";
this.fontWeight = "normal";
this.dropShadowEnabled = true;
this.leading = 0;
this.backgroundColor = 0xFFFFFF;
this.shadowDistance = 1;
this.cornerRadius = 0;
this.borderThickness = 0;
this.paddingLeft = 5;
this.paddingRight = 5;
};
};
}
}
}//package
Section 310
//_dataGridStylesStyle (_dataGridStylesStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _dataGridStylesStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".dataGridStyles");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".dataGridStyles", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
};
};
}
}
}//package
Section 311
//_dateFieldPopupStyle (_dateFieldPopupStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _dateFieldPopupStyle {
public static function init(_dateFieldPopupStyle.as$3:IFlexModuleFactory):void{
var fbs = _dateFieldPopupStyle.as$3;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".dateFieldPopup");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".dateFieldPopup", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.dropShadowEnabled = true;
this.backgroundColor = 0xFFFFFF;
this.borderThickness = 0;
};
};
}
}
}//package
Section 312
//_errorTipStyle (_errorTipStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _errorTipStyle {
public static function init(borderColor:IFlexModuleFactory):void{
var fbs = borderColor;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".errorTip");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".errorTip", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
this.borderStyle = "errorTipRight";
this.paddingTop = 4;
this.borderColor = 13510953;
this.color = 0xFFFFFF;
this.fontSize = 9;
this.shadowColor = 0;
this.paddingLeft = 4;
this.paddingBottom = 4;
this.paddingRight = 4;
};
};
}
}
}//package
Section 313
//_globalStyle (_globalStyle)
package {
import mx.core.*;
import mx.styles.*;
import mx.skins.halo.*;
public class _globalStyle {
public static function init(horizontalGridLines:IFlexModuleFactory):void{
var fbs = horizontalGridLines;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("global");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration("global", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fillColor = 0xFFFFFF;
this.kerning = false;
this.iconColor = 0x111111;
this.textRollOverColor = 2831164;
this.horizontalAlign = "left";
this.shadowCapColor = 14015965;
this.backgroundAlpha = 1;
this.filled = true;
this.textDecoration = "none";
this.roundedBottomCorners = true;
this.fontThickness = 0;
this.focusBlendMode = "normal";
this.fillColors = [0xFFFFFF, 0xCCCCCC, 0xFFFFFF, 0xEEEEEE];
this.horizontalGap = 8;
this.borderCapColor = 9542041;
this.buttonColor = 7305079;
this.indentation = 17;
this.selectionDisabledColor = 0xDDDDDD;
this.closeDuration = 250;
this.embedFonts = false;
this.paddingTop = 0;
this.letterSpacing = 0;
this.focusAlpha = 0.4;
this.bevel = true;
this.fontSize = 10;
this.shadowColor = 0xEEEEEE;
this.borderAlpha = 1;
this.paddingLeft = 0;
this.fontWeight = "normal";
this.indicatorGap = 14;
this.focusSkin = HaloFocusRect;
this.dropShadowEnabled = false;
this.leading = 2;
this.borderSkin = HaloBorder;
this.fontSharpness = 0;
this.modalTransparencyDuration = 100;
this.borderThickness = 1;
this.backgroundSize = "auto";
this.borderStyle = "inset";
this.borderColor = 12040892;
this.fontAntiAliasType = "advanced";
this.errorColor = 0xFF0000;
this.shadowDistance = 2;
this.horizontalGridLineColor = 0xF7F7F7;
this.stroked = false;
this.modalTransparencyColor = 0xDDDDDD;
this.cornerRadius = 0;
this.verticalAlign = "top";
this.textIndent = 0;
this.fillAlphas = [0.6, 0.4, 0.75, 0.65];
this.verticalGridLineColor = 14015965;
this.themeColor = 40447;
this.version = "3.0.0";
this.shadowDirection = "center";
this.modalTransparency = 0.5;
this.repeatInterval = 35;
this.openDuration = 250;
this.textAlign = "left";
this.fontFamily = "Verdana";
this.textSelectedColor = 2831164;
this.paddingBottom = 0;
this.strokeWidth = 1;
this.fontGridFitType = "pixel";
this.horizontalGridLines = false;
this.useRollOver = true;
this.verticalGridLines = true;
this.repeatDelay = 500;
this.fontStyle = "normal";
this.dropShadowColor = 0;
this.focusThickness = 2;
this.verticalGap = 6;
this.disabledColor = 11187123;
this.paddingRight = 0;
this.focusRoundedCorners = "tl tr bl br";
this.borderSides = "left top right bottom";
this.disabledIconColor = 0x999999;
this.modalTransparencyBlur = 3;
this.color = 734012;
this.selectionDuration = 250;
this.highlightAlphas = [0.3, 0];
};
};
}
}
}//package
Section 314
//_headerDateTextStyle (_headerDateTextStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _headerDateTextStyle {
public static function init(bold:IFlexModuleFactory):void{
var fbs = bold;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".headerDateText");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".headerDateText", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
this.textAlign = "center";
};
};
}
}
}//package
Section 315
//_headerDragProxyStyleStyle (_headerDragProxyStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _headerDragProxyStyleStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".headerDragProxyStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".headerDragProxyStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
};
};
}
}
}//package
Section 316
//_linkButtonStyleStyle (_linkButtonStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _linkButtonStyleStyle {
public static function init(http://adobe.com/AS3/2006/builtin:IFlexModuleFactory):void{
var fbs = http://adobe.com/AS3/2006/builtin;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".linkButtonStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".linkButtonStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.paddingTop = 2;
this.paddingLeft = 2;
this.paddingBottom = 2;
this.paddingRight = 2;
};
};
}
}
}//package
Section 317
//_opaquePanelStyle (_opaquePanelStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _opaquePanelStyle {
public static function init(Object:IFlexModuleFactory):void{
var fbs = Object;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".opaquePanel");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".opaquePanel", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.borderColor = 0xFFFFFF;
this.backgroundColor = 0xFFFFFF;
this.headerColors = [0xE7E7E7, 0xD9D9D9];
this.footerColors = [0xE7E7E7, 0xC7C7C7];
this.borderAlpha = 1;
};
};
}
}
}//package
Section 318
//_plainStyle (_plainStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _plainStyle {
public static function init(backgroundImage:IFlexModuleFactory):void{
var fbs = backgroundImage;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".plain");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".plain", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.paddingTop = 0;
this.backgroundColor = 0xFFFFFF;
this.backgroundImage = "";
this.horizontalAlign = "left";
this.paddingLeft = 0;
this.paddingBottom = 0;
this.paddingRight = 0;
};
};
}
}
}//package
Section 319
//_popUpMenuStyle (_popUpMenuStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _popUpMenuStyle {
public static function init(normal:IFlexModuleFactory):void{
var fbs = normal;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".popUpMenu");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".popUpMenu", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "normal";
this.textAlign = "left";
};
};
}
}
}//package
Section 320
//_richTextEditorTextAreaStyleStyle (_richTextEditorTextAreaStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _richTextEditorTextAreaStyleStyle {
public static function init(_richTextEditorTextAreaStyleStyle:IFlexModuleFactory):void{
var fbs = _richTextEditorTextAreaStyleStyle;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".richTextEditorTextAreaStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".richTextEditorTextAreaStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
};
};
}
}
}//package
Section 321
//_swatchPanelTextFieldStyle (_swatchPanelTextFieldStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _swatchPanelTextFieldStyle {
public static function init(shadowCapColor:IFlexModuleFactory):void{
var fbs = shadowCapColor;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".swatchPanelTextField");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".swatchPanelTextField", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.borderStyle = "inset";
this.borderColor = 14015965;
this.highlightColor = 12897484;
this.backgroundColor = 0xFFFFFF;
this.shadowCapColor = 14015965;
this.shadowColor = 14015965;
this.paddingLeft = 5;
this.buttonColor = 7305079;
this.borderCapColor = 9542041;
this.paddingRight = 5;
};
};
}
}
}//package
Section 322
//_textAreaHScrollBarStyleStyle (_textAreaHScrollBarStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _textAreaHScrollBarStyleStyle {
public static function init(_textAreaHScrollBarStyleStyle:IFlexModuleFactory):void{
var fbs = _textAreaHScrollBarStyleStyle;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".textAreaHScrollBarStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".textAreaHScrollBarStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
};
};
}
}
}//package
Section 323
//_textAreaVScrollBarStyleStyle (_textAreaVScrollBarStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _textAreaVScrollBarStyleStyle {
public static function init(_textAreaVScrollBarStyleStyle:IFlexModuleFactory):void{
var fbs = _textAreaVScrollBarStyleStyle;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".textAreaVScrollBarStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".textAreaVScrollBarStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
};
};
}
}
}//package
Section 324
//_todayStyleStyle (_todayStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _todayStyleStyle {
public static function init(color:IFlexModuleFactory):void{
var fbs = color;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".todayStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".todayStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.color = 0xFFFFFF;
this.textAlign = "center";
};
};
}
}
}//package
Section 325
//_ToolTipStyle (_ToolTipStyle)
package {
import mx.core.*;
import mx.styles.*;
import mx.skins.halo.*;
public class _ToolTipStyle {
public static function init(cornerRadius:IFlexModuleFactory):void{
var fbs = cornerRadius;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("ToolTip");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration("ToolTip", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.borderStyle = "toolTip";
this.paddingTop = 2;
this.borderColor = 9542041;
this.backgroundColor = 16777164;
this.borderSkin = ToolTipBorder;
this.cornerRadius = 2;
this.fontSize = 9;
this.shadowColor = 0;
this.paddingLeft = 4;
this.paddingBottom = 2;
this.backgroundAlpha = 0.95;
this.paddingRight = 4;
};
};
}
}
}//package
Section 326
//_weekDayStyleStyle (_weekDayStyleStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _weekDayStyleStyle {
public static function init(bold:IFlexModuleFactory):void{
var fbs = bold;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".weekDayStyle");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".weekDayStyle", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
this.textAlign = "center";
};
};
}
}
}//package
Section 327
//_windowStatusStyle (_windowStatusStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _windowStatusStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".windowStatus");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".windowStatus", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.color = 0x666666;
};
};
}
}
}//package
Section 328
//_windowStylesStyle (_windowStylesStyle)
package {
import mx.core.*;
import mx.styles.*;
public class _windowStylesStyle {
public static function init(:IFlexModuleFactory):void{
var fbs = ;
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".windowStyles");
if (!style){
style = new CSSStyleDeclaration();
StyleManager.setStyleDeclaration(".windowStyles", style, false);
};
if (style.defaultFactory == null){
style.defaultFactory = function ():void{
this.fontWeight = "bold";
};
};
}
}
}//package
Section 329
//ag_intro_mc (ag_intro_mc)
package {
import flash.display.*;
public dynamic class ag_intro_mc extends MovieClip {
public function ag_intro_mc(){
addFrameScript(0, frame1);
}
function frame1(){
gotoAndPlay(2);
}
}
}//package
Section 330
//ai_thinking (ai_thinking)
package {
import flash.display.*;
public dynamic class ai_thinking extends BitmapData {
public function ai_thinking(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 331
//AILoopWAV (AILoopWAV)
package {
import flash.media.*;
public dynamic class AILoopWAV extends Sound {
}
}//package
Section 332
//aircontrol (aircontrol)
package {
import flash.display.*;
public dynamic class aircontrol extends BitmapData {
public function aircontrol(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 333
//aircontrol_mask (aircontrol_mask)
package {
import flash.display.*;
public dynamic class aircontrol_mask extends BitmapData {
public function aircontrol_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 334
//AircraftMove (AircraftMove)
package {
import flash.media.*;
public dynamic class AircraftMove extends Sound {
}
}//package
Section 335
//albatross (albatross)
package {
import flash.display.*;
public dynamic class albatross extends BitmapData {
public function albatross(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 336
//albatross_mask (albatross_mask)
package {
import flash.display.*;
public dynamic class albatross_mask extends BitmapData {
public function albatross_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 337
//andkon_intro (andkon_intro)
package {
import flash.display.*;
public dynamic class andkon_intro extends MovieClip {
}
}//package
Section 338
//andkon_small (andkon_small)
package {
import flash.display.*;
public dynamic class andkon_small extends BitmapData {
public function andkon_small(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 339
//annihilator (annihilator)
package {
import flash.display.*;
public dynamic class annihilator extends BitmapData {
public function annihilator(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 340
//annihilator_mask (annihilator_mask)
package {
import flash.display.*;
public dynamic class annihilator_mask extends BitmapData {
public function annihilator_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 341
//archipelago_v1 (archipelago_v1)
package {
import flash.display.*;
public dynamic class archipelago_v1 extends BitmapData {
public function archipelago_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 342
//archipelago_v2 (archipelago_v2)
package {
import flash.display.*;
public dynamic class archipelago_v2 extends BitmapData {
public function archipelago_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 343
//archipelago_v3 (archipelago_v3)
package {
import flash.display.*;
public dynamic class archipelago_v3 extends BitmapData {
public function archipelago_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 344
//archipelago_v4 (archipelago_v4)
package {
import flash.display.*;
public dynamic class archipelago_v4 extends BitmapData {
public function archipelago_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 345
//armor_logo (armor_logo)
package {
import flash.display.*;
public dynamic class armor_logo extends BitmapData {
public function armor_logo(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 346
//attackTargets (attackTargets)
package {
import flash.display.*;
public dynamic class attackTargets extends BitmapData {
public function attackTargets(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 347
//avatars (avatars)
package {
import flash.display.*;
public dynamic class avatars extends BitmapData {
public function avatars(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 348
//avatarsSmall (avatarsSmall)
package {
import flash.display.*;
public dynamic class avatarsSmall extends BitmapData {
public function avatarsSmall(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 349
//battlecruiser (battlecruiser)
package {
import flash.display.*;
public dynamic class battlecruiser extends BitmapData {
public function battlecruiser(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 350
//battlecruiser_mask (battlecruiser_mask)
package {
import flash.display.*;
public dynamic class battlecruiser_mask extends BitmapData {
public function battlecruiser_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 351
//BlimpMove (BlimpMove)
package {
import flash.media.*;
public dynamic class BlimpMove extends Sound {
}
}//package
Section 352
//BoatMove (BoatMove)
package {
import flash.media.*;
public dynamic class BoatMove extends Sound {
}
}//package
Section 353
//bonusMapButton (bonusMapButton)
package {
import flash.display.*;
public dynamic class bonusMapButton extends BitmapData {
public function bonusMapButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 354
//bootCampButton (bootCampButton)
package {
import flash.display.*;
public dynamic class bootCampButton extends BitmapData {
public function bootCampButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 355
//border_bottom (border_bottom)
package {
import flash.display.*;
public dynamic class border_bottom extends BitmapData {
public function border_bottom(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 356
//border_left (border_left)
package {
import flash.display.*;
public dynamic class border_left extends BitmapData {
public function border_left(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 357
//border_right (border_right)
package {
import flash.display.*;
public dynamic class border_right extends BitmapData {
public function border_right(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 358
//border_top (border_top)
package {
import flash.display.*;
public dynamic class border_top extends BitmapData {
public function border_top(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 359
//bridge_1_v1 (bridge_1_v1)
package {
import flash.display.*;
public dynamic class bridge_1_v1 extends BitmapData {
public function bridge_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 360
//bridge_2_v1 (bridge_2_v1)
package {
import flash.display.*;
public dynamic class bridge_2_v1 extends BitmapData {
public function bridge_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 361
//bridge_3_v1 (bridge_3_v1)
package {
import flash.display.*;
public dynamic class bridge_3_v1 extends BitmapData {
public function bridge_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 362
//bridge_4_v1 (bridge_4_v1)
package {
import flash.display.*;
public dynamic class bridge_4_v1 extends BitmapData {
public function bridge_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 363
//bridge_5_v1 (bridge_5_v1)
package {
import flash.display.*;
public dynamic class bridge_5_v1 extends BitmapData {
public function bridge_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 364
//bridge_6_v1 (bridge_6_v1)
package {
import flash.display.*;
public dynamic class bridge_6_v1 extends BitmapData {
public function bridge_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 365
//bridge_7_v1 (bridge_7_v1)
package {
import flash.display.*;
public dynamic class bridge_7_v1 extends BitmapData {
public function bridge_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 366
//bridge_8_v1 (bridge_8_v1)
package {
import flash.display.*;
public dynamic class bridge_8_v1 extends BitmapData {
public function bridge_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 367
//bridge_canyon3_v1 (bridge_canyon3_v1)
package {
import flash.display.*;
public dynamic class bridge_canyon3_v1 extends BitmapData {
public function bridge_canyon3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 368
//bridge_canyon7_v1 (bridge_canyon7_v1)
package {
import flash.display.*;
public dynamic class bridge_canyon7_v1 extends BitmapData {
public function bridge_canyon7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 369
//build_header_air (build_header_air)
package {
import flash.display.*;
public dynamic class build_header_air extends BitmapData {
public function build_header_air(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 370
//build_header_ground (build_header_ground)
package {
import flash.display.*;
public dynamic class build_header_ground extends BitmapData {
public function build_header_ground(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 371
//build_header_sea (build_header_sea)
package {
import flash.display.*;
public dynamic class build_header_sea extends BitmapData {
public function build_header_sea(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 372
//build_icon_air (build_icon_air)
package {
import flash.display.*;
public dynamic class build_icon_air extends BitmapData {
public function build_icon_air(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 373
//build_icon_ground (build_icon_ground)
package {
import flash.display.*;
public dynamic class build_icon_ground extends BitmapData {
public function build_icon_ground(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 374
//build_icon_sea (build_icon_sea)
package {
import flash.display.*;
public dynamic class build_icon_sea extends BitmapData {
public function build_icon_sea(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 375
//build_text_air (build_text_air)
package {
import flash.display.*;
public dynamic class build_text_air extends BitmapData {
public function build_text_air(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 376
//build_text_ground (build_text_ground)
package {
import flash.display.*;
public dynamic class build_text_ground extends BitmapData {
public function build_text_ground(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 377
//build_text_sea (build_text_sea)
package {
import flash.display.*;
public dynamic class build_text_sea extends BitmapData {
public function build_text_sea(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 378
//build_unit_box (build_unit_box)
package {
import flash.display.*;
public dynamic class build_unit_box extends BitmapData {
public function build_unit_box(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 379
//build_unit_box_bg (build_unit_box_bg)
package {
import flash.display.*;
public dynamic class build_unit_box_bg extends BitmapData {
public function build_unit_box_bg(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 380
//button (button)
package {
import flash.display.*;
public dynamic class button extends BitmapData {
public function button(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 381
//button_finish (button_finish)
package {
import flash.display.*;
public dynamic class button_finish extends BitmapData {
public function button_finish(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 382
//button_levelselect (button_levelselect)
package {
import flash.display.*;
public dynamic class button_levelselect extends BitmapData {
public function button_levelselect(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 383
//button_startgame (button_startgame)
package {
import flash.display.*;
public dynamic class button_startgame extends BitmapData {
public function button_startgame(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 384
//buttonDown (buttonDown)
package {
import flash.display.*;
public dynamic class buttonDown extends BitmapData {
public function buttonDown(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 385
//buttonUp (buttonUp)
package {
import flash.display.*;
public dynamic class buttonUp extends BitmapData {
public function buttonUp(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 386
//campaign_bg_icons (campaign_bg_icons)
package {
import flash.display.*;
public dynamic class campaign_bg_icons extends BitmapData {
public function campaign_bg_icons(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 387
//campaign_header_jungle (campaign_header_jungle)
package {
import flash.display.*;
public dynamic class campaign_header_jungle extends BitmapData {
public function campaign_header_jungle(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 388
//campaign_icon_money (campaign_icon_money)
package {
import flash.display.*;
public dynamic class campaign_icon_money extends BitmapData {
public function campaign_icon_money(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 389
//campaign_shield_AE (campaign_shield_AE)
package {
import flash.display.*;
public dynamic class campaign_shield_AE extends BitmapData {
public function campaign_shield_AE(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 390
//campaign_shield_Dragoons (campaign_shield_Dragoons)
package {
import flash.display.*;
public dynamic class campaign_shield_Dragoons extends BitmapData {
public function campaign_shield_Dragoons(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 391
//campaign_shield_NF (campaign_shield_NF)
package {
import flash.display.*;
public dynamic class campaign_shield_NF extends BitmapData {
public function campaign_shield_NF(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 392
//campaign_tokens_holder (campaign_tokens_holder)
package {
import flash.display.*;
public dynamic class campaign_tokens_holder extends BitmapData {
public function campaign_tokens_holder(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 393
//campaign_victory (campaign_victory)
package {
import flash.display.*;
public dynamic class campaign_victory extends BitmapData {
public function campaign_victory(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 394
//campaignButton (campaignButton)
package {
import flash.display.*;
public dynamic class campaignButton extends BitmapData {
public function campaignButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 395
//canyon_0_v1 (canyon_0_v1)
package {
import flash.display.*;
public dynamic class canyon_0_v1 extends BitmapData {
public function canyon_0_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 396
//canyon_1_v1 (canyon_1_v1)
package {
import flash.display.*;
public dynamic class canyon_1_v1 extends BitmapData {
public function canyon_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 397
//canyon_10_v1 (canyon_10_v1)
package {
import flash.display.*;
public dynamic class canyon_10_v1 extends BitmapData {
public function canyon_10_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 398
//canyon_11_v1 (canyon_11_v1)
package {
import flash.display.*;
public dynamic class canyon_11_v1 extends BitmapData {
public function canyon_11_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 399
//canyon_12_v1 (canyon_12_v1)
package {
import flash.display.*;
public dynamic class canyon_12_v1 extends BitmapData {
public function canyon_12_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 400
//canyon_13_v1 (canyon_13_v1)
package {
import flash.display.*;
public dynamic class canyon_13_v1 extends BitmapData {
public function canyon_13_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 401
//canyon_14_v1 (canyon_14_v1)
package {
import flash.display.*;
public dynamic class canyon_14_v1 extends BitmapData {
public function canyon_14_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 402
//canyon_15_v1 (canyon_15_v1)
package {
import flash.display.*;
public dynamic class canyon_15_v1 extends BitmapData {
public function canyon_15_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 403
//canyon_16_v1 (canyon_16_v1)
package {
import flash.display.*;
public dynamic class canyon_16_v1 extends BitmapData {
public function canyon_16_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 404
//canyon_17_v1 (canyon_17_v1)
package {
import flash.display.*;
public dynamic class canyon_17_v1 extends BitmapData {
public function canyon_17_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 405
//canyon_18_v1 (canyon_18_v1)
package {
import flash.display.*;
public dynamic class canyon_18_v1 extends BitmapData {
public function canyon_18_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 406
//canyon_19_v1 (canyon_19_v1)
package {
import flash.display.*;
public dynamic class canyon_19_v1 extends BitmapData {
public function canyon_19_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 407
//canyon_2_v1 (canyon_2_v1)
package {
import flash.display.*;
public dynamic class canyon_2_v1 extends BitmapData {
public function canyon_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 408
//canyon_20_v1 (canyon_20_v1)
package {
import flash.display.*;
public dynamic class canyon_20_v1 extends BitmapData {
public function canyon_20_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 409
//canyon_21_v1 (canyon_21_v1)
package {
import flash.display.*;
public dynamic class canyon_21_v1 extends BitmapData {
public function canyon_21_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 410
//canyon_22_v1 (canyon_22_v1)
package {
import flash.display.*;
public dynamic class canyon_22_v1 extends BitmapData {
public function canyon_22_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 411
//canyon_23_v1 (canyon_23_v1)
package {
import flash.display.*;
public dynamic class canyon_23_v1 extends BitmapData {
public function canyon_23_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 412
//canyon_24_v1 (canyon_24_v1)
package {
import flash.display.*;
public dynamic class canyon_24_v1 extends BitmapData {
public function canyon_24_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 413
//canyon_25_v1 (canyon_25_v1)
package {
import flash.display.*;
public dynamic class canyon_25_v1 extends BitmapData {
public function canyon_25_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 414
//canyon_26_v1 (canyon_26_v1)
package {
import flash.display.*;
public dynamic class canyon_26_v1 extends BitmapData {
public function canyon_26_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 415
//canyon_27_v1 (canyon_27_v1)
package {
import flash.display.*;
public dynamic class canyon_27_v1 extends BitmapData {
public function canyon_27_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 416
//canyon_28_v1 (canyon_28_v1)
package {
import flash.display.*;
public dynamic class canyon_28_v1 extends BitmapData {
public function canyon_28_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 417
//canyon_29_v1 (canyon_29_v1)
package {
import flash.display.*;
public dynamic class canyon_29_v1 extends BitmapData {
public function canyon_29_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 418
//canyon_3_v1 (canyon_3_v1)
package {
import flash.display.*;
public dynamic class canyon_3_v1 extends BitmapData {
public function canyon_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 419
//canyon_30_v1 (canyon_30_v1)
package {
import flash.display.*;
public dynamic class canyon_30_v1 extends BitmapData {
public function canyon_30_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 420
//canyon_31_v1 (canyon_31_v1)
package {
import flash.display.*;
public dynamic class canyon_31_v1 extends BitmapData {
public function canyon_31_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 421
//canyon_32_v1 (canyon_32_v1)
package {
import flash.display.*;
public dynamic class canyon_32_v1 extends BitmapData {
public function canyon_32_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 422
//canyon_4_v1 (canyon_4_v1)
package {
import flash.display.*;
public dynamic class canyon_4_v1 extends BitmapData {
public function canyon_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 423
//canyon_5_v1 (canyon_5_v1)
package {
import flash.display.*;
public dynamic class canyon_5_v1 extends BitmapData {
public function canyon_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 424
//canyon_6_v1 (canyon_6_v1)
package {
import flash.display.*;
public dynamic class canyon_6_v1 extends BitmapData {
public function canyon_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 425
//canyon_7_v1 (canyon_7_v1)
package {
import flash.display.*;
public dynamic class canyon_7_v1 extends BitmapData {
public function canyon_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 426
//canyon_8_v1 (canyon_8_v1)
package {
import flash.display.*;
public dynamic class canyon_8_v1 extends BitmapData {
public function canyon_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 427
//canyon_9_v1 (canyon_9_v1)
package {
import flash.display.*;
public dynamic class canyon_9_v1 extends BitmapData {
public function canyon_9_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 428
//canyon_v1 (canyon_v1)
package {
import flash.display.*;
public dynamic class canyon_v1 extends BitmapData {
public function canyon_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 429
//capital (capital)
package {
import flash.display.*;
public dynamic class capital extends BitmapData {
public function capital(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 430
//capital_mask (capital_mask)
package {
import flash.display.*;
public dynamic class capital_mask extends BitmapData {
public function capital_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 431
//Capture (Capture)
package {
import flash.media.*;
public dynamic class Capture extends Sound {
}
}//package
Section 432
//chunks (chunks)
package {
import flash.display.*;
public dynamic class chunks extends BitmapData {
public function chunks(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 433
//clearDataButton (clearDataButton)
package {
import flash.display.*;
public dynamic class clearDataButton extends BitmapData {
public function clearDataButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 434
//clearDataLabel (clearDataLabel)
package {
import flash.display.*;
public dynamic class clearDataLabel extends BitmapData {
public function clearDataLabel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 435
//Cloak (Cloak)
package {
import flash.media.*;
public dynamic class Cloak extends Sound {
}
}//package
Section 436
//closeButton (closeButton)
package {
import flash.display.*;
public dynamic class closeButton extends BitmapData {
public function closeButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 437
//colorBar (colorBar)
package {
import flash.display.*;
public dynamic class colorBar extends BitmapData {
public function colorBar(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 438
//colorBarLong (colorBarLong)
package {
import flash.display.*;
public dynamic class colorBarLong extends BitmapData {
public function colorBarLong(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 439
//commando (commando)
package {
import flash.display.*;
public dynamic class commando extends BitmapData {
public function commando(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 440
//commando_mask (commando_mask)
package {
import flash.display.*;
public dynamic class commando_mask extends BitmapData {
public function commando_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 441
//CommandoMove1 (CommandoMove1)
package {
import flash.media.*;
public dynamic class CommandoMove1 extends Sound {
}
}//package
Section 442
//CommandoMove2 (CommandoMove2)
package {
import flash.media.*;
public dynamic class CommandoMove2 extends Sound {
}
}//package
Section 443
//CommandoMove3 (CommandoMove3)
package {
import flash.media.*;
public dynamic class CommandoMove3 extends Sound {
}
}//package
Section 444
//condor (condor)
package {
import flash.display.*;
public dynamic class condor extends BitmapData {
public function condor(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 445
//condor_mask (condor_mask)
package {
import flash.display.*;
public dynamic class condor_mask extends BitmapData {
public function condor_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 446
//continueButton (continueButton)
package {
import flash.display.*;
public dynamic class continueButton extends BitmapData {
public function continueButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 447
//corvette (corvette)
package {
import flash.display.*;
public dynamic class corvette extends BitmapData {
public function corvette(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 448
//corvette_mask (corvette_mask)
package {
import flash.display.*;
public dynamic class corvette_mask extends BitmapData {
public function corvette_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 449
//creditsButton (creditsButton)
package {
import flash.display.*;
public dynamic class creditsButton extends BitmapData {
public function creditsButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 450
//creditsLabel (creditsLabel)
package {
import flash.display.*;
public dynamic class creditsLabel extends BitmapData {
public function creditsLabel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 451
//cursor (cursor)
package {
import flash.display.*;
public dynamic class cursor extends BitmapData {
public function cursor(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 452
//Decloak (Decloak)
package {
import flash.media.*;
public dynamic class Decloak extends Sound {
}
}//package
Section 453
//DefeatWAV (DefeatWAV)
package {
import flash.media.*;
public dynamic class DefeatWAV extends Sound {
}
}//package
Section 454
//desert_v1 (desert_v1)
package {
import flash.display.*;
public dynamic class desert_v1 extends BitmapData {
public function desert_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 455
//desert_v2 (desert_v2)
package {
import flash.display.*;
public dynamic class desert_v2 extends BitmapData {
public function desert_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 456
//desert_v3 (desert_v3)
package {
import flash.display.*;
public dynamic class desert_v3 extends BitmapData {
public function desert_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 457
//dialogButton (dialogButton)
package {
import flash.display.*;
public dynamic class dialogButton extends BitmapData {
public function dialogButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 458
//dialogButtonToggled (dialogButtonToggled)
package {
import flash.display.*;
public dynamic class dialogButtonToggled extends BitmapData {
public function dialogButtonToggled(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 459
//dialogLabel (dialogLabel)
package {
import flash.display.*;
public dynamic class dialogLabel extends BitmapData {
public function dialogLabel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 460
//en_US$core_properties (en_US$core_properties)
package {
import mx.resources.*;
public class en_US$core_properties extends ResourceBundle {
public function en_US$core_properties(){
super("en_US", "core");
}
override protected function getContent():Object{
var _local1:Object = {multipleChildSets_ClassAndInstance:"Multiple sets of visual children have been specified for this component (component definition and component instance).", truncationIndicator:"...", notExecuting:"Repeater is not executing.", versionAlreadyRead:"Compatibility version has already been read.", multipleChildSets_ClassAndSubclass:"Multiple sets of visual children have been specified for this component (base component definition and derived component definition).", viewSource:"View Source", badFile:"File does not exist.", stateUndefined:"Undefined state '{0}'.", versionAlreadySet:"Compatibility version has already been set."};
return (_local1);
}
}
}//package
Section 461
//en_US$skins_properties (en_US$skins_properties)
package {
import mx.resources.*;
public class en_US$skins_properties extends ResourceBundle {
public function en_US$skins_properties(){
super("en_US", "skins");
}
override protected function getContent():Object{
var _local1:Object = {notLoaded:"Unable to load '{0}'."};
return (_local1);
}
}
}//package
Section 462
//en_US$styles_properties (en_US$styles_properties)
package {
import mx.resources.*;
public class en_US$styles_properties extends ResourceBundle {
public function en_US$styles_properties(){
super("en_US", "styles");
}
override protected function getContent():Object{
var _local1:Object = {unableToLoad:"Unable to load style({0}): {1}."};
return (_local1);
}
}
}//package
Section 463
//endturnbutton (endturnbutton)
package {
import flash.display.*;
public dynamic class endturnbutton extends BitmapData {
public function endturnbutton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 464
//error (error)
package {
import flash.display.*;
public dynamic class error extends BitmapData {
public function error(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 465
//error_mask (error_mask)
package {
import flash.display.*;
public dynamic class error_mask extends BitmapData {
public function error_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 466
//explosion (explosion)
package {
import flash.display.*;
public dynamic class explosion extends BitmapData {
public function explosion(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 467
//ExplosionSound (ExplosionSound)
package {
import flash.media.*;
public dynamic class ExplosionSound extends Sound {
}
}//package
Section 468
//factory (factory)
package {
import flash.display.*;
public dynamic class factory extends BitmapData {
public function factory(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 469
//factory_mask (factory_mask)
package {
import flash.display.*;
public dynamic class factory_mask extends BitmapData {
public function factory_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 470
//FireAnnihilatorTank (FireAnnihilatorTank)
package {
import flash.media.*;
public dynamic class FireAnnihilatorTank extends Sound {
}
}//package
Section 471
//FireBattlecruiser (FireBattlecruiser)
package {
import flash.media.*;
public dynamic class FireBattlecruiser extends Sound {
}
}//package
Section 472
//FireCondorBomber (FireCondorBomber)
package {
import flash.media.*;
public dynamic class FireCondorBomber extends Sound {
}
}//package
Section 473
//FireCorvetteFighter (FireCorvetteFighter)
package {
import flash.media.*;
public dynamic class FireCorvetteFighter extends Sound {
}
}//package
Section 474
//FireFlakTank (FireFlakTank)
package {
import flash.media.*;
public dynamic class FireFlakTank extends Sound {
}
}//package
Section 475
//FireHeavyCommando (FireHeavyCommando)
package {
import flash.media.*;
public dynamic class FireHeavyCommando extends Sound {
}
}//package
Section 476
//FireHunterSupport (FireHunterSupport)
package {
import flash.media.*;
public dynamic class FireHunterSupport extends Sound {
}
}//package
Section 477
//FireIntrepid (FireIntrepid)
package {
import flash.media.*;
public dynamic class FireIntrepid extends Sound {
}
}//package
Section 478
//FireMortarTruck (FireMortarTruck)
package {
import flash.media.*;
public dynamic class FireMortarTruck extends Sound {
}
}//package
Section 479
//FireRaptorFighter (FireRaptorFighter)
package {
import flash.media.*;
public dynamic class FireRaptorFighter extends Sound {
}
}//package
Section 480
//FireRocketTruck (FireRocketTruck)
package {
import flash.media.*;
public dynamic class FireRocketTruck extends Sound {
}
}//package
Section 481
//FireScorpionTank (FireScorpionTank)
package {
import flash.media.*;
public dynamic class FireScorpionTank extends Sound {
}
}//package
Section 482
//FireStealthTank (FireStealthTank)
package {
import flash.media.*;
public dynamic class FireStealthTank extends Sound {
}
}//package
Section 483
//FireStrikeCommando (FireStrikeCommando)
package {
import flash.media.*;
public dynamic class FireStrikeCommando extends Sound {
}
}//package
Section 484
//FireTurret (FireTurret)
package {
import flash.media.*;
public dynamic class FireTurret extends Sound {
}
}//package
Section 485
//FireUboat (FireUboat)
package {
import flash.media.*;
public dynamic class FireUboat extends Sound {
}
}//package
Section 486
//flag (flag)
package {
import flash.display.*;
public dynamic class flag extends BitmapData {
public function flag(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 487
//flag_mask (flag_mask)
package {
import flash.display.*;
public dynamic class flag_mask extends BitmapData {
public function flag_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 488
//flak (flak)
package {
import flash.display.*;
public dynamic class flak extends BitmapData {
public function flak(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 489
//flak_mask (flak_mask)
package {
import flash.display.*;
public dynamic class flak_mask extends BitmapData {
public function flak_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 490
//forest_v1 (forest_v1)
package {
import flash.display.*;
public dynamic class forest_v1 extends BitmapData {
public function forest_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 491
//forest_v2 (forest_v2)
package {
import flash.display.*;
public dynamic class forest_v2 extends BitmapData {
public function forest_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 492
//frame1 (frame1)
package {
import flash.display.*;
public dynamic class frame1 extends BitmapData {
public function frame1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 493
//frame2 (frame2)
package {
import flash.display.*;
public dynamic class frame2 extends BitmapData {
public function frame2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 494
//funny_games_intro (funny_games_intro)
package {
import flash.display.*;
public dynamic class funny_games_intro extends MovieClip {
public var more_btn:SimpleButton;
}
}//package
Section 495
//funny_games_logo (funny_games_logo)
package {
import flash.display.*;
public dynamic class funny_games_logo extends BitmapData {
public function funny_games_logo(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 496
//groundcontrol (groundcontrol)
package {
import flash.display.*;
public dynamic class groundcontrol extends BitmapData {
public function groundcontrol(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 497
//groundcontrol_mask (groundcontrol_mask)
package {
import flash.display.*;
public dynamic class groundcontrol_mask extends BitmapData {
public function groundcontrol_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 498
//hcommando (hcommando)
package {
import flash.display.*;
public dynamic class hcommando extends BitmapData {
public function hcommando(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 499
//hcommando_mask (hcommando_mask)
package {
import flash.display.*;
public dynamic class hcommando_mask extends BitmapData {
public function hcommando_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 500
//header_bootcamp (header_bootcamp)
package {
import flash.display.*;
public dynamic class header_bootcamp extends BitmapData {
public function header_bootcamp(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 501
//header_campaign_1 (header_campaign_1)
package {
import flash.display.*;
public dynamic class header_campaign_1 extends BitmapData {
public function header_campaign_1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 502
//header_campaign_10 (header_campaign_10)
package {
import flash.display.*;
public dynamic class header_campaign_10 extends BitmapData {
public function header_campaign_10(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 503
//header_campaign_2 (header_campaign_2)
package {
import flash.display.*;
public dynamic class header_campaign_2 extends BitmapData {
public function header_campaign_2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 504
//header_campaign_3 (header_campaign_3)
package {
import flash.display.*;
public dynamic class header_campaign_3 extends BitmapData {
public function header_campaign_3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 505
//header_campaign_4 (header_campaign_4)
package {
import flash.display.*;
public dynamic class header_campaign_4 extends BitmapData {
public function header_campaign_4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 506
//header_campaign_5 (header_campaign_5)
package {
import flash.display.*;
public dynamic class header_campaign_5 extends BitmapData {
public function header_campaign_5(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 507
//header_campaign_6 (header_campaign_6)
package {
import flash.display.*;
public dynamic class header_campaign_6 extends BitmapData {
public function header_campaign_6(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 508
//header_campaign_7 (header_campaign_7)
package {
import flash.display.*;
public dynamic class header_campaign_7 extends BitmapData {
public function header_campaign_7(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 509
//header_campaign_8 (header_campaign_8)
package {
import flash.display.*;
public dynamic class header_campaign_8 extends BitmapData {
public function header_campaign_8(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 510
//header_campaign_9 (header_campaign_9)
package {
import flash.display.*;
public dynamic class header_campaign_9 extends BitmapData {
public function header_campaign_9(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 511
//high_bridge_1_v1 (high_bridge_1_v1)
package {
import flash.display.*;
public dynamic class high_bridge_1_v1 extends BitmapData {
public function high_bridge_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 512
//high_bridge_2_v1 (high_bridge_2_v1)
package {
import flash.display.*;
public dynamic class high_bridge_2_v1 extends BitmapData {
public function high_bridge_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 513
//high_bridge_3_v1 (high_bridge_3_v1)
package {
import flash.display.*;
public dynamic class high_bridge_3_v1 extends BitmapData {
public function high_bridge_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 514
//high_bridge_4_v1 (high_bridge_4_v1)
package {
import flash.display.*;
public dynamic class high_bridge_4_v1 extends BitmapData {
public function high_bridge_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 515
//high_bridge_5_v1 (high_bridge_5_v1)
package {
import flash.display.*;
public dynamic class high_bridge_5_v1 extends BitmapData {
public function high_bridge_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 516
//high_bridge_6_v1 (high_bridge_6_v1)
package {
import flash.display.*;
public dynamic class high_bridge_6_v1 extends BitmapData {
public function high_bridge_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 517
//high_bridge_7_v1 (high_bridge_7_v1)
package {
import flash.display.*;
public dynamic class high_bridge_7_v1 extends BitmapData {
public function high_bridge_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 518
//high_bridge_8_v1 (high_bridge_8_v1)
package {
import flash.display.*;
public dynamic class high_bridge_8_v1 extends BitmapData {
public function high_bridge_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 519
//highlight (highlight)
package {
import flash.display.*;
public dynamic class highlight extends BitmapData {
public function highlight(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 520
//hills_v1 (hills_v1)
package {
import flash.display.*;
public dynamic class hills_v1 extends BitmapData {
public function hills_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 521
//hills_v2 (hills_v2)
package {
import flash.display.*;
public dynamic class hills_v2 extends BitmapData {
public function hills_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 522
//hills_v3 (hills_v3)
package {
import flash.display.*;
public dynamic class hills_v3 extends BitmapData {
public function hills_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 523
//hills_v4 (hills_v4)
package {
import flash.display.*;
public dynamic class hills_v4 extends BitmapData {
public function hills_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 524
//hunter (hunter)
package {
import flash.display.*;
public dynamic class hunter extends BitmapData {
public function hunter(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 525
//hunter_mask (hunter_mask)
package {
import flash.display.*;
public dynamic class hunter_mask extends BitmapData {
public function hunter_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 526
//info_icons (info_icons)
package {
import flash.display.*;
public dynamic class info_icons extends BitmapData {
public function info_icons(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 527
//info_panel (info_panel)
package {
import flash.display.*;
public dynamic class info_panel extends BitmapData {
public function info_panel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 528
//ingame_kong_logo (ingame_kong_logo)
package {
import flash.display.*;
public dynamic class ingame_kong_logo extends BitmapData {
public function ingame_kong_logo(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 529
//intrepid (intrepid)
package {
import flash.display.*;
public dynamic class intrepid extends BitmapData {
public function intrepid(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 530
//intrepid_mask (intrepid_mask)
package {
import flash.display.*;
public dynamic class intrepid_mask extends BitmapData {
public function intrepid_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 531
//leviathan (leviathan)
package {
import flash.display.*;
public dynamic class leviathan extends BitmapData {
public function leviathan(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 532
//leviathan_mask (leviathan_mask)
package {
import flash.display.*;
public dynamic class leviathan_mask extends BitmapData {
public function leviathan_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 533
//mainframe (mainframe)
package {
import flash.display.*;
public dynamic class mainframe extends BitmapData {
public function mainframe(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 534
//mainmenu_kong_logo (mainmenu_kong_logo)
package {
import flash.display.*;
public dynamic class mainmenu_kong_logo extends BitmapData {
public function mainmenu_kong_logo(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 535
//marker (marker)
package {
import flash.display.*;
public dynamic class marker extends BitmapData {
public function marker(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 536
//marker2 (marker2)
package {
import flash.display.*;
public dynamic class marker2 extends BitmapData {
public function marker2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 537
//menubutton (menubutton)
package {
import flash.display.*;
public dynamic class menubutton extends BitmapData {
public function menubutton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 538
//minimap_bridge (minimap_bridge)
package {
import flash.display.*;
public dynamic class minimap_bridge extends BitmapData {
public function minimap_bridge(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 539
//minimap_desert (minimap_desert)
package {
import flash.display.*;
public dynamic class minimap_desert extends BitmapData {
public function minimap_desert(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 540
//minimap_forest (minimap_forest)
package {
import flash.display.*;
public dynamic class minimap_forest extends BitmapData {
public function minimap_forest(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 541
//minimap_mountain (minimap_mountain)
package {
import flash.display.*;
public dynamic class minimap_mountain extends BitmapData {
public function minimap_mountain(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 542
//minimap_overlay (minimap_overlay)
package {
import flash.display.*;
public dynamic class minimap_overlay extends BitmapData {
public function minimap_overlay(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 543
//minimap_overlay_mask (minimap_overlay_mask)
package {
import flash.display.*;
public dynamic class minimap_overlay_mask extends BitmapData {
public function minimap_overlay_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 544
//minimap_plains (minimap_plains)
package {
import flash.display.*;
public dynamic class minimap_plains extends BitmapData {
public function minimap_plains(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 545
//minimap_reef (minimap_reef)
package {
import flash.display.*;
public dynamic class minimap_reef extends BitmapData {
public function minimap_reef(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 546
//minimap_road (minimap_road)
package {
import flash.display.*;
public dynamic class minimap_road extends BitmapData {
public function minimap_road(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 547
//minimap_sea (minimap_sea)
package {
import flash.display.*;
public dynamic class minimap_sea extends BitmapData {
public function minimap_sea(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 548
//minimap_shore (minimap_shore)
package {
import flash.display.*;
public dynamic class minimap_shore extends BitmapData {
public function minimap_shore(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 549
//minimapembelishment (minimapembelishment)
package {
import flash.display.*;
public dynamic class minimapembelishment extends BitmapData {
public function minimapembelishment(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 550
//mofungames_preloader (mofungames_preloader)
package {
import flash.display.*;
public dynamic class mofungames_preloader extends MovieClip {
public var bar:MovieClip;
public function mofungames_preloader(){
addFrameScript(0, frame1);
}
function frame1(){
gotoAndStop(10);
}
}
}//package
Section 551
//mofunzone_logo (mofunzone_logo)
package {
import flash.display.*;
public dynamic class mofunzone_logo extends BitmapData {
public function mofunzone_logo(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 552
//moneyBar (moneyBar)
package {
import flash.display.*;
public dynamic class moneyBar extends BitmapData {
public function moneyBar(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 553
//mortar (mortar)
package {
import flash.display.*;
public dynamic class mortar extends BitmapData {
public function mortar(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 554
//mortar_mask (mortar_mask)
package {
import flash.display.*;
public dynamic class mortar_mask extends BitmapData {
public function mortar_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 555
//mountains_v1 (mountains_v1)
package {
import flash.display.*;
public dynamic class mountains_v1 extends BitmapData {
public function mountains_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 556
//mountains_v2 (mountains_v2)
package {
import flash.display.*;
public dynamic class mountains_v2 extends BitmapData {
public function mountains_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 557
//mountains_v3 (mountains_v3)
package {
import flash.display.*;
public dynamic class mountains_v3 extends BitmapData {
public function mountains_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 558
//mountains_v4 (mountains_v4)
package {
import flash.display.*;
public dynamic class mountains_v4 extends BitmapData {
public function mountains_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 559
//movement_end (movement_end)
package {
import flash.display.*;
public dynamic class movement_end extends BitmapData {
public function movement_end(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 560
//movement_nomove (movement_nomove)
package {
import flash.display.*;
public dynamic class movement_nomove extends BitmapData {
public function movement_nomove(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 561
//movement_start (movement_start)
package {
import flash.display.*;
public dynamic class movement_start extends BitmapData {
public function movement_start(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 562
//movement_straight (movement_straight)
package {
import flash.display.*;
public dynamic class movement_straight extends BitmapData {
public function movement_straight(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 563
//movement_turn (movement_turn)
package {
import flash.display.*;
public dynamic class movement_turn extends BitmapData {
public function movement_turn(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 564
//movement_unmoveable (movement_unmoveable)
package {
import flash.display.*;
public dynamic class movement_unmoveable extends BitmapData {
public function movement_unmoveable(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 565
//musicButton (musicButton)
package {
import flash.display.*;
public dynamic class musicButton extends BitmapData {
public function musicButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 566
//musicButtonToggled (musicButtonToggled)
package {
import flash.display.*;
public dynamic class musicButtonToggled extends BitmapData {
public function musicButtonToggled(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 567
//MusicLabel (MusicLabel)
package {
import flash.display.*;
public dynamic class MusicLabel extends BitmapData {
public function MusicLabel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 568
//nextUnitButton (nextUnitButton)
package {
import flash.display.*;
public dynamic class nextUnitButton extends BitmapData {
public function nextUnitButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 569
//noButton (noButton)
package {
import flash.display.*;
public dynamic class noButton extends BitmapData {
public function noButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 570
//oiladvanced (oiladvanced)
package {
import flash.display.*;
public dynamic class oiladvanced extends BitmapData {
public function oiladvanced(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 571
//oiladvanced_mask (oiladvanced_mask)
package {
import flash.display.*;
public dynamic class oiladvanced_mask extends BitmapData {
public function oiladvanced_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 572
//oilrefinery (oilrefinery)
package {
import flash.display.*;
public dynamic class oilrefinery extends BitmapData {
public function oilrefinery(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 573
//oilrefinery_mask (oilrefinery_mask)
package {
import flash.display.*;
public dynamic class oilrefinery_mask extends BitmapData {
public function oilrefinery_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 574
//oilrig (oilrig)
package {
import flash.display.*;
public dynamic class oilrig extends BitmapData {
public function oilrig(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 575
//oilrig_mask (oilrig_mask)
package {
import flash.display.*;
public dynamic class oilrig_mask extends BitmapData {
public function oilrig_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 576
//optionsButton (optionsButton)
package {
import flash.display.*;
public dynamic class optionsButton extends BitmapData {
public function optionsButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 577
//optionsMainButton (optionsMainButton)
package {
import flash.display.*;
public dynamic class optionsMainButton extends BitmapData {
public function optionsMainButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 578
//panel (panel)
package {
import flash.display.*;
public dynamic class panel extends BitmapData {
public function panel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 579
//plains_v1 (plains_v1)
package {
import flash.display.*;
public dynamic class plains_v1 extends BitmapData {
public function plains_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 580
//plains_v2 (plains_v2)
package {
import flash.display.*;
public dynamic class plains_v2 extends BitmapData {
public function plains_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 581
//plains_v3 (plains_v3)
package {
import flash.display.*;
public dynamic class plains_v3 extends BitmapData {
public function plains_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 582
//plains_v4 (plains_v4)
package {
import flash.display.*;
public dynamic class plains_v4 extends BitmapData {
public function plains_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 583
//plains_v5 (plains_v5)
package {
import flash.display.*;
public dynamic class plains_v5 extends BitmapData {
public function plains_v5(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 584
//plains_v6 (plains_v6)
package {
import flash.display.*;
public dynamic class plains_v6 extends BitmapData {
public function plains_v6(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 585
//plains_v7 (plains_v7)
package {
import flash.display.*;
public dynamic class plains_v7 extends BitmapData {
public function plains_v7(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 586
//playerbox (playerbox)
package {
import flash.display.*;
public dynamic class playerbox extends BitmapData {
public function playerbox(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 587
//playerboxbehind (playerboxbehind)
package {
import flash.display.*;
public dynamic class playerboxbehind extends BitmapData {
public function playerboxbehind(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 588
//PlayerLoopWAV (PlayerLoopWAV)
package {
import flash.media.*;
public dynamic class PlayerLoopWAV extends Sound {
}
}//package
Section 589
//playerpointer (playerpointer)
package {
import flash.display.*;
public dynamic class playerpointer extends BitmapData {
public function playerpointer(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 590
//quitAndNoSaveButton (quitAndNoSaveButton)
package {
import flash.display.*;
public dynamic class quitAndNoSaveButton extends BitmapData {
public function quitAndNoSaveButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 591
//quitButton (quitButton)
package {
import flash.display.*;
public dynamic class quitButton extends BitmapData {
public function quitButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 592
//rankBadges (rankBadges)
package {
import flash.display.*;
public dynamic class rankBadges extends BitmapData {
public function rankBadges(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 593
//raptor (raptor)
package {
import flash.display.*;
public dynamic class raptor extends BitmapData {
public function raptor(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 594
//raptor_mask (raptor_mask)
package {
import flash.display.*;
public dynamic class raptor_mask extends BitmapData {
public function raptor_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 595
//reef_v1 (reef_v1)
package {
import flash.display.*;
public dynamic class reef_v1 extends BitmapData {
public function reef_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 596
//reef_v2 (reef_v2)
package {
import flash.display.*;
public dynamic class reef_v2 extends BitmapData {
public function reef_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 597
//reef_v3 (reef_v3)
package {
import flash.display.*;
public dynamic class reef_v3 extends BitmapData {
public function reef_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 598
//reef_v4 (reef_v4)
package {
import flash.display.*;
public dynamic class reef_v4 extends BitmapData {
public function reef_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 599
//repairIcon (repairIcon)
package {
import flash.display.*;
public dynamic class repairIcon extends BitmapData {
public function repairIcon(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 600
//restartButton (restartButton)
package {
import flash.display.*;
public dynamic class restartButton extends BitmapData {
public function restartButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 601
//restoreButton (restoreButton)
package {
import flash.display.*;
public dynamic class restoreButton extends BitmapData {
public function restoreButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 602
//road_1_v1 (road_1_v1)
package {
import flash.display.*;
public dynamic class road_1_v1 extends BitmapData {
public function road_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 603
//road_10_v1 (road_10_v1)
package {
import flash.display.*;
public dynamic class road_10_v1 extends BitmapData {
public function road_10_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 604
//road_11_v1 (road_11_v1)
package {
import flash.display.*;
public dynamic class road_11_v1 extends BitmapData {
public function road_11_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 605
//road_12_v1 (road_12_v1)
package {
import flash.display.*;
public dynamic class road_12_v1 extends BitmapData {
public function road_12_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 606
//road_13_v1 (road_13_v1)
package {
import flash.display.*;
public dynamic class road_13_v1 extends BitmapData {
public function road_13_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 607
//road_14_v1 (road_14_v1)
package {
import flash.display.*;
public dynamic class road_14_v1 extends BitmapData {
public function road_14_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 608
//road_15_v1 (road_15_v1)
package {
import flash.display.*;
public dynamic class road_15_v1 extends BitmapData {
public function road_15_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 609
//road_2_v1 (road_2_v1)
package {
import flash.display.*;
public dynamic class road_2_v1 extends BitmapData {
public function road_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 610
//road_3_v1 (road_3_v1)
package {
import flash.display.*;
public dynamic class road_3_v1 extends BitmapData {
public function road_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 611
//road_4_v1 (road_4_v1)
package {
import flash.display.*;
public dynamic class road_4_v1 extends BitmapData {
public function road_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 612
//road_5_v1 (road_5_v1)
package {
import flash.display.*;
public dynamic class road_5_v1 extends BitmapData {
public function road_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 613
//road_6_v1 (road_6_v1)
package {
import flash.display.*;
public dynamic class road_6_v1 extends BitmapData {
public function road_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 614
//road_7_v1 (road_7_v1)
package {
import flash.display.*;
public dynamic class road_7_v1 extends BitmapData {
public function road_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 615
//road_8_v1 (road_8_v1)
package {
import flash.display.*;
public dynamic class road_8_v1 extends BitmapData {
public function road_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 616
//road_9_v1 (road_9_v1)
package {
import flash.display.*;
public dynamic class road_9_v1 extends BitmapData {
public function road_9_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 617
//rock_formation_v1 (rock_formation_v1)
package {
import flash.display.*;
public dynamic class rock_formation_v1 extends BitmapData {
public function rock_formation_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 618
//rock_formation_v2 (rock_formation_v2)
package {
import flash.display.*;
public dynamic class rock_formation_v2 extends BitmapData {
public function rock_formation_v2(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 619
//rock_formation_v3 (rock_formation_v3)
package {
import flash.display.*;
public dynamic class rock_formation_v3 extends BitmapData {
public function rock_formation_v3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 620
//rock_formation_v4 (rock_formation_v4)
package {
import flash.display.*;
public dynamic class rock_formation_v4 extends BitmapData {
public function rock_formation_v4(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 621
//rocket (rocket)
package {
import flash.display.*;
public dynamic class rocket extends BitmapData {
public function rocket(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 622
//rocket_mask (rocket_mask)
package {
import flash.display.*;
public dynamic class rocket_mask extends BitmapData {
public function rocket_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 623
//saveButton (saveButton)
package {
import flash.display.*;
public dynamic class saveButton extends BitmapData {
public function saveButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 624
//scorpion (scorpion)
package {
import flash.display.*;
public dynamic class scorpion extends BitmapData {
public function scorpion(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 625
//scorpion_mask (scorpion_mask)
package {
import flash.display.*;
public dynamic class scorpion_mask extends BitmapData {
public function scorpion_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 626
//sea_0_v1 (sea_0_v1)
package {
import flash.display.*;
public dynamic class sea_0_v1 extends BitmapData {
public function sea_0_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 627
//sea_1_v1 (sea_1_v1)
package {
import flash.display.*;
public dynamic class sea_1_v1 extends BitmapData {
public function sea_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 628
//sea_10_v1 (sea_10_v1)
package {
import flash.display.*;
public dynamic class sea_10_v1 extends BitmapData {
public function sea_10_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 629
//sea_11_v1 (sea_11_v1)
package {
import flash.display.*;
public dynamic class sea_11_v1 extends BitmapData {
public function sea_11_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 630
//sea_12_v1 (sea_12_v1)
package {
import flash.display.*;
public dynamic class sea_12_v1 extends BitmapData {
public function sea_12_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 631
//sea_13_v1 (sea_13_v1)
package {
import flash.display.*;
public dynamic class sea_13_v1 extends BitmapData {
public function sea_13_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 632
//sea_14_v1 (sea_14_v1)
package {
import flash.display.*;
public dynamic class sea_14_v1 extends BitmapData {
public function sea_14_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 633
//sea_15_v1 (sea_15_v1)
package {
import flash.display.*;
public dynamic class sea_15_v1 extends BitmapData {
public function sea_15_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 634
//sea_16_v1 (sea_16_v1)
package {
import flash.display.*;
public dynamic class sea_16_v1 extends BitmapData {
public function sea_16_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 635
//sea_2_v1 (sea_2_v1)
package {
import flash.display.*;
public dynamic class sea_2_v1 extends BitmapData {
public function sea_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 636
//sea_3_v1 (sea_3_v1)
package {
import flash.display.*;
public dynamic class sea_3_v1 extends BitmapData {
public function sea_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 637
//sea_4_v1 (sea_4_v1)
package {
import flash.display.*;
public dynamic class sea_4_v1 extends BitmapData {
public function sea_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 638
//sea_5_v1 (sea_5_v1)
package {
import flash.display.*;
public dynamic class sea_5_v1 extends BitmapData {
public function sea_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 639
//sea_6_v1 (sea_6_v1)
package {
import flash.display.*;
public dynamic class sea_6_v1 extends BitmapData {
public function sea_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 640
//sea_7_v1 (sea_7_v1)
package {
import flash.display.*;
public dynamic class sea_7_v1 extends BitmapData {
public function sea_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 641
//sea_8_v1 (sea_8_v1)
package {
import flash.display.*;
public dynamic class sea_8_v1 extends BitmapData {
public function sea_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 642
//sea_9_v1 (sea_9_v1)
package {
import flash.display.*;
public dynamic class sea_9_v1 extends BitmapData {
public function sea_9_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 643
//sea_v1 (sea_v1)
package {
import flash.display.*;
public dynamic class sea_v1 extends BitmapData {
public function sea_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 644
//seacontrol (seacontrol)
package {
import flash.display.*;
public dynamic class seacontrol extends BitmapData {
public function seacontrol(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 645
//seacontrol_mask (seacontrol_mask)
package {
import flash.display.*;
public dynamic class seacontrol_mask extends BitmapData {
public function seacontrol_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 646
//select (select)
package {
import flash.display.*;
public dynamic class select extends BitmapData {
public function select(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 647
//selectedArrow (selectedArrow)
package {
import flash.display.*;
public dynamic class selectedArrow extends BitmapData {
public function selectedArrow(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 648
//selectMixed (selectMixed)
package {
import flash.display.*;
public dynamic class selectMixed extends BitmapData {
public function selectMixed(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 649
//selectOrange (selectOrange)
package {
import flash.display.*;
public dynamic class selectOrange extends BitmapData {
public function selectOrange(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 650
//selectRed (selectRed)
package {
import flash.display.*;
public dynamic class selectRed extends BitmapData {
public function selectRed(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 651
//ShipMove (ShipMove)
package {
import flash.media.*;
public dynamic class ShipMove extends Sound {
}
}//package
Section 652
//shore_1_v1 (shore_1_v1)
package {
import flash.display.*;
public dynamic class shore_1_v1 extends BitmapData {
public function shore_1_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 653
//shore_10_v1 (shore_10_v1)
package {
import flash.display.*;
public dynamic class shore_10_v1 extends BitmapData {
public function shore_10_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 654
//shore_11_v1 (shore_11_v1)
package {
import flash.display.*;
public dynamic class shore_11_v1 extends BitmapData {
public function shore_11_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 655
//shore_12_v1 (shore_12_v1)
package {
import flash.display.*;
public dynamic class shore_12_v1 extends BitmapData {
public function shore_12_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 656
//shore_2_v1 (shore_2_v1)
package {
import flash.display.*;
public dynamic class shore_2_v1 extends BitmapData {
public function shore_2_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 657
//shore_3_v1 (shore_3_v1)
package {
import flash.display.*;
public dynamic class shore_3_v1 extends BitmapData {
public function shore_3_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 658
//shore_4_v1 (shore_4_v1)
package {
import flash.display.*;
public dynamic class shore_4_v1 extends BitmapData {
public function shore_4_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 659
//shore_5_v1 (shore_5_v1)
package {
import flash.display.*;
public dynamic class shore_5_v1 extends BitmapData {
public function shore_5_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 660
//shore_6_v1 (shore_6_v1)
package {
import flash.display.*;
public dynamic class shore_6_v1 extends BitmapData {
public function shore_6_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 661
//shore_7_v1 (shore_7_v1)
package {
import flash.display.*;
public dynamic class shore_7_v1 extends BitmapData {
public function shore_7_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 662
//shore_8_v1 (shore_8_v1)
package {
import flash.display.*;
public dynamic class shore_8_v1 extends BitmapData {
public function shore_8_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 663
//shore_9_v1 (shore_9_v1)
package {
import flash.display.*;
public dynamic class shore_9_v1 extends BitmapData {
public function shore_9_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 664
//shore_v1 (shore_v1)
package {
import flash.display.*;
public dynamic class shore_v1 extends BitmapData {
public function shore_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 665
//small_explosion (small_explosion)
package {
import flash.display.*;
public dynamic class small_explosion extends BitmapData {
public function small_explosion(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 666
//smallIcon (smallIcon)
package {
import flash.display.*;
public dynamic class smallIcon extends BitmapData {
public function smallIcon(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 667
//soundButton (soundButton)
package {
import flash.display.*;
public dynamic class soundButton extends BitmapData {
public function soundButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 668
//soundButtonToggled (soundButtonToggled)
package {
import flash.display.*;
public dynamic class soundButtonToggled extends BitmapData {
public function soundButtonToggled(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 669
//SoundLabel (SoundLabel)
package {
import flash.display.*;
public dynamic class SoundLabel extends BitmapData {
public function SoundLabel(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 670
//splash_kong (splash_kong)
package {
import flash.display.*;
public dynamic class splash_kong extends MovieClip {
}
}//package
Section 671
//spotted_texture (spotted_texture)
package {
import flash.display.*;
public dynamic class spotted_texture extends BitmapData {
public function spotted_texture(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 672
//stealth (stealth)
package {
import flash.display.*;
public dynamic class stealth extends BitmapData {
public function stealth(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 673
//stealth_mask (stealth_mask)
package {
import flash.display.*;
public dynamic class stealth_mask extends BitmapData {
public function stealth_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 674
//SubmarineMove (SubmarineMove)
package {
import flash.media.*;
public dynamic class SubmarineMove extends Sound {
}
}//package
Section 675
//TankMove1 (TankMove1)
package {
import flash.media.*;
public dynamic class TankMove1 extends Sound {
}
}//package
Section 676
//TankMove2 (TankMove2)
package {
import flash.media.*;
public dynamic class TankMove2 extends Sound {
}
}//package
Section 677
//TankMove3 (TankMove3)
package {
import flash.media.*;
public dynamic class TankMove3 extends Sound {
}
}//package
Section 678
//title (title)
package {
import flash.display.*;
public dynamic class title extends BitmapData {
public function title(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 679
//turret (turret)
package {
import flash.display.*;
public dynamic class turret extends BitmapData {
public function turret(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 680
//turret_mask (turret_mask)
package {
import flash.display.*;
public dynamic class turret_mask extends BitmapData {
public function turret_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 681
//uboat (uboat)
package {
import flash.display.*;
public dynamic class uboat extends BitmapData {
public function uboat(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 682
//uboat_mask (uboat_mask)
package {
import flash.display.*;
public dynamic class uboat_mask extends BitmapData {
public function uboat_mask(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 683
//UIWAV (UIWAV)
package {
import flash.media.*;
public dynamic class UIWAV extends Sound {
}
}//package
Section 684
//unitMenu (unitMenu)
package {
import flash.display.*;
public dynamic class unitMenu extends BitmapData {
public function unitMenu(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 685
//wasteland_v1 (wasteland_v1)
package {
import flash.display.*;
public dynamic class wasteland_v1 extends BitmapData {
public function wasteland_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 686
//VehicleMove (VehicleMove)
package {
import flash.media.*;
public dynamic class VehicleMove extends Sound {
}
}//package
Section 687
//VictoryWAV (VictoryWAV)
package {
import flash.media.*;
public dynamic class VictoryWAV extends Sound {
}
}//package
Section 688
//volcano_v1 (volcano_v1)
package {
import flash.display.*;
public dynamic class volcano_v1 extends BitmapData {
public function volcano_v1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 689
//wood_texture (wood_texture)
package {
import flash.display.*;
public dynamic class wood_texture extends BitmapData {
public function wood_texture(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 690
//yesButton (yesButton)
package {
import flash.display.*;
public dynamic class yesButton extends BitmapData {
public function yesButton(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package