Section 1
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var contentspotid:String;
private var cpmstarLoader:Loader;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function addedHandler(_arg1:Event):void{
var _local2:String;
var _local3:DisplayObjectContainer;
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
_local2 = "http://server.cpmstar.com/adviewas3.swf";
_local3 = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((_local2 + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
}
}//package CPMStar
Section 2
//None (fl.transitions.easing.None)
package fl.transitions.easing {
public class None {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
}
}//package fl.transitions.easing
Section 3
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
public var begin:Number;// = NAN
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var change:Number;// = NAN
private var _finish:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(_arg1:Object, _arg2:String, _arg3:Function, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false){
isPlaying = false;
obj = null;
prop = "";
func = function (_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
};
begin = NaN;
change = NaN;
useSeconds = false;
prevTime = NaN;
prevPos = NaN;
looping = false;
_duration = NaN;
_time = NaN;
_fps = NaN;
_position = NaN;
_startTime = NaN;
_intervalID = 0;
_finish = NaN;
_timer = null;
super();
if (!arguments.length){
return;
};
this.obj = _arg1;
this.prop = _arg2;
this.begin = _arg4;
this.position = _arg4;
this.duration = _arg6;
this.useSeconds = _arg7;
if ((_arg3 is Function)){
this.func = _arg3;
};
this.finish = _arg5;
this._timer = new Timer(100);
this.start();
}
public function continueTo(_arg1:Number, _arg2:Number):void{
this.begin = this.position;
this.finish = _arg1;
if (!isNaN(_arg2)){
this.duration = _arg2;
};
this.start();
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(_arg1:Number):void{
var _local2:Boolean;
_local2 = this.isPlaying;
this.stopEnterFrame();
this._fps = _arg1;
if (_local2){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function startEnterFrame():void{
var _local1:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
_local1 = (1000 / this._fps);
this._timer.delay = _local1;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function set time(_arg1:Number):void{
this.prevTime = this._time;
if (_arg1 > this.duration){
if (this.looping){
this.rewind((_arg1 - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (_arg1 < 0){
this.rewind();
this.update();
} else {
this._time = _arg1;
this.update();
};
};
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function getPosition(_arg1:Number=NaN):Number{
if (isNaN(_arg1)){
_arg1 = this._time;
};
return (this.func(_arg1, this.begin, this.change, this._duration));
}
public function set finish(_arg1:Number):void{
this.change = (_arg1 - this.begin);
}
public function set duration(_arg1:Number):void{
this._duration = ((_arg1)<=0) ? Infinity : _arg1;
}
public function setPosition(_arg1:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = _arg1);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(_arg1:Event):void{
this.nextFrame();
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(_arg1:TimerEvent):void{
this.nextFrame();
_arg1.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(_arg1:Number=0):void{
this._time = _arg1;
this.fixTime();
this.update();
}
public function set position(_arg1:Number):void{
this.setPosition(_arg1);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 4
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var time:Number;// = NAN
public var position:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false){
time = NaN;
position = NaN;
super(_arg1, _arg4, _arg5);
this.time = _arg2;
this.position = _arg3;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 5
//gamewin_mc_150 (game_fla.gamewin_mc_150)
package game_fla {
import flash.display.*;
import flash.text.*;
public dynamic class gamewin_mc_150 extends MovieClip {
public var txtScore:TextField;
public var playagain:SimpleButton;
}
}//package game_fla
Section 6
//infotxt_mc_136 (game_fla.infotxt_mc_136)
package game_fla {
import flash.display.*;
import flash.text.*;
public dynamic class infotxt_mc_136 extends MovieClip {
public var txtDesc:TextField;
public var txtCost:TextField;
public var txtUnitname:TextField;
}
}//package game_fla
Section 7
//init_mc_11 (game_fla.init_mc_11)
package game_fla {
import flash.display.*;
public dynamic class init_mc_11 extends MovieClip {
public function init_mc_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 8
//Nexus_Preloader_2 (game_fla.Nexus_Preloader_2)
package game_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class Nexus_Preloader_2 extends MovieClip {
public const FRAME_RATE_ADJUST:Boolean = true;
public const LOADER_FRAME_RATE:Number = 30;
public const AUTO_PLAY:Boolean = false;
public var bar:MovieClip;
public var MOVIE_LOADED:Boolean;
public var Nexusbtn:SimpleButton;
public var loadingComplete:Boolean;
public var movieFrameRate:Number;
public var initialized:Boolean;
public function Nexus_Preloader_2(){
addFrameScript(0, frame1, 49, frame50);
}
public function init():void{
if (initialized){
return;
};
gotoAndStop(1);
movieFrameRate = 0;
if (((FRAME_RATE_ADJUST) && (stage))){
movieFrameRate = stage.frameRate;
stage.frameRate = LOADER_FRAME_RATE;
};
initialized = true;
stop();
if (((root) && ((root is MovieClip)))){
MovieClip(root).stop();
};
loadingComplete = false;
addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 0, true);
if (meetsVersion([9, 0, 28, 0])){
addEventListener(Event.REMOVED_FROM_STAGE, cleanup, false, 0, true);
};
enterFrameHandler();
}
public function enterFrameHandler(_arg1:Event=null):void{
var _local2:Number;
if (((((!(movieFrameRate)) && (FRAME_RATE_ADJUST))) && (stage))){
movieFrameRate = stage.frameRate;
stage.frameRate = LOADER_FRAME_RATE;
};
if (!loadingComplete){
_local2 = 0;
if (loaderInfo){
_local2 = (loaderInfo.bytesLoaded / loaderInfo.bytesTotal);
};
if (bar){
bar.scaleX = (_local2 * 2);
};
if (_local2 == 1){
loadingComplete = true;
if (AUTO_PLAY){
startMovie();
} else {
gotoAndPlay("loaded");
};
};
};
}
public function meetsVersion(_arg1:Array):Boolean{
var _local2:Array;
var _local3:uint;
_local2 = String(Capabilities.version.split(" ")[1]).split(",");
_local3 = 0;
while (_local3 < _arg1.length) {
if (uint(_local2[_local3]) > _arg1[_local3]){
return (true);
};
if (uint(_local2[_local3]) < _arg1[_local3]){
return (false);
};
_local3++;
};
return (true);
}
function frame1(){
initialized = false;
MOVIE_LOADED = false;
Nexusbtn.addEventListener(MouseEvent.CLICK, callLink);
init();
}
public function callLink(_arg1:MouseEvent):void{
var url:String;
var request:URLRequest;
var e = _arg1;
url = "http://www.flashgamesnexus.com/";
request = new URLRequest(url);
try {
navigateToURL(request, "_blank");
} catch(e:Error) {
};
}
public function ngButtonClickHandler(_arg1:Event):void{
navigateToURL(new URLRequest("http://www.newgrounds.com"), "_blank");
}
public function cleanup(_arg1:Event=null){
if (initialized){
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
if (meetsVersion([9, 0, 28, 0])){
removeEventListener(Event.REMOVED_FROM_STAGE, cleanup);
};
if (movieFrameRate){
stage.frameRate = movieFrameRate;
movieFrameRate = 0;
};
};
initialized = false;
}
function frame50(){
startMovie();
stop();
}
public function startMovie():void{
cleanup();
if (((root) && ((root is MovieClip)))){
MOVIE_LOADED = true;
};
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package game_fla
Section 9
//sounds_mc_106 (game_fla.sounds_mc_106)
package game_fla {
import flash.display.*;
public dynamic class sounds_mc_106 extends MovieClip {
public var soundsButton:SimpleButton;
}
}//package game_fla
Section 10
//soundsinit_mc_102 (game_fla.soundsinit_mc_102)
package game_fla {
import flash.display.*;
public dynamic class soundsinit_mc_102 extends MovieClip {
public function soundsinit_mc_102(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 11
//unit_body_1_die_153 (game_fla.unit_body_1_die_153)
package game_fla {
import flash.display.*;
public dynamic class unit_body_1_die_153 extends MovieClip {
public function unit_body_1_die_153(){
addFrameScript(14, frame15);
}
function frame15(){
stop();
}
}
}//package game_fla
Section 12
//unit_body_10_die_158 (game_fla.unit_body_10_die_158)
package game_fla {
import flash.display.*;
public dynamic class unit_body_10_die_158 extends MovieClip {
public function unit_body_10_die_158(){
addFrameScript(12, frame13);
}
function frame13(){
stop();
}
}
}//package game_fla
Section 13
//unit_body_11_die_159 (game_fla.unit_body_11_die_159)
package game_fla {
import flash.display.*;
public dynamic class unit_body_11_die_159 extends MovieClip {
public function unit_body_11_die_159(){
addFrameScript(13, frame14);
}
function frame14(){
stop();
}
}
}//package game_fla
Section 14
//unit_body_12_die_160 (game_fla.unit_body_12_die_160)
package game_fla {
import flash.display.*;
public dynamic class unit_body_12_die_160 extends MovieClip {
public function unit_body_12_die_160(){
addFrameScript(8, frame9);
}
function frame9(){
stop();
}
}
}//package game_fla
Section 15
//unit_body_13_die_161 (game_fla.unit_body_13_die_161)
package game_fla {
import flash.display.*;
public dynamic class unit_body_13_die_161 extends MovieClip {
public function unit_body_13_die_161(){
addFrameScript(7, frame8);
}
function frame8(){
stop();
}
}
}//package game_fla
Section 16
//unit_body_14_die_162 (game_fla.unit_body_14_die_162)
package game_fla {
import flash.display.*;
public dynamic class unit_body_14_die_162 extends MovieClip {
public function unit_body_14_die_162(){
addFrameScript(6, frame7);
}
function frame7(){
stop();
}
}
}//package game_fla
Section 17
//unit_body_15_die_163 (game_fla.unit_body_15_die_163)
package game_fla {
import flash.display.*;
public dynamic class unit_body_15_die_163 extends MovieClip {
public function unit_body_15_die_163(){
addFrameScript(7, frame8);
}
function frame8(){
stop();
}
}
}//package game_fla
Section 18
//unit_body_6_die_154 (game_fla.unit_body_6_die_154)
package game_fla {
import flash.display.*;
public dynamic class unit_body_6_die_154 extends MovieClip {
public function unit_body_6_die_154(){
addFrameScript(7, frame8);
}
function frame8(){
stop();
}
}
}//package game_fla
Section 19
//unit_body_7_die_155 (game_fla.unit_body_7_die_155)
package game_fla {
import flash.display.*;
public dynamic class unit_body_7_die_155 extends MovieClip {
public function unit_body_7_die_155(){
addFrameScript(9, frame10);
}
function frame10(){
stop();
}
}
}//package game_fla
Section 20
//unit_body_8_die_156 (game_fla.unit_body_8_die_156)
package game_fla {
import flash.display.*;
public dynamic class unit_body_8_die_156 extends MovieClip {
public function unit_body_8_die_156(){
addFrameScript(9, frame10);
}
function frame10(){
stop();
}
}
}//package game_fla
Section 21
//unit_body_9_die_157 (game_fla.unit_body_9_die_157)
package game_fla {
import flash.display.*;
public dynamic class unit_body_9_die_157 extends MovieClip {
public function unit_body_9_die_157(){
addFrameScript(8, frame9);
}
function frame9(){
stop();
}
}
}//package game_fla
Section 22
//unit_gun_1_95 (game_fla.unit_gun_1_95)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_1_95 extends MovieClip {
public function unit_gun_1_95(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 23
//unit_gun_16_90 (game_fla.unit_gun_16_90)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_16_90 extends MovieClip {
public function unit_gun_16_90(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 24
//unit_gun_17_91 (game_fla.unit_gun_17_91)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_17_91 extends MovieClip {
public function unit_gun_17_91(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 25
//unit_gun_18_100 (game_fla.unit_gun_18_100)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_18_100 extends MovieClip {
public function unit_gun_18_100(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 26
//unit_gun_18e_92 (game_fla.unit_gun_18e_92)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_18e_92 extends MovieClip {
public function unit_gun_18e_92(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 27
//unit_gun_1e_85 (game_fla.unit_gun_1e_85)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_1e_85 extends MovieClip {
public function unit_gun_1e_85(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 28
//unit_gun_2_96 (game_fla.unit_gun_2_96)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_2_96 extends MovieClip {
public function unit_gun_2_96(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 29
//unit_gun_2e_86 (game_fla.unit_gun_2e_86)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_2e_86 extends MovieClip {
public function unit_gun_2e_86(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 30
//unit_gun_3_97 (game_fla.unit_gun_3_97)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_3_97 extends MovieClip {
public function unit_gun_3_97(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 31
//unit_gun_3e_87 (game_fla.unit_gun_3e_87)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_3e_87 extends MovieClip {
public function unit_gun_3e_87(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 32
//unit_gun_4_98 (game_fla.unit_gun_4_98)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_4_98 extends MovieClip {
public function unit_gun_4_98(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 33
//unit_gun_4e_88 (game_fla.unit_gun_4e_88)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_4e_88 extends MovieClip {
public function unit_gun_4e_88(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 34
//unit_gun_5_99 (game_fla.unit_gun_5_99)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_5_99 extends MovieClip {
public function unit_gun_5_99(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 35
//unit_gun_5e_89 (game_fla.unit_gun_5e_89)
package game_fla {
import flash.display.*;
public dynamic class unit_gun_5e_89 extends MovieClip {
public function unit_gun_5e_89(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package game_fla
Section 36
//youlose_mc_149 (game_fla.youlose_mc_149)
package game_fla {
import flash.display.*;
public dynamic class youlose_mc_149 extends MovieClip {
public var nextLevelButton:SimpleButton;
}
}//package game_fla
Section 37
//CBase (src.CBase)
package src {
import flash.display.*;
public class CBase extends MovieClip {
var Game:CGame;
var Life:int;
var LifeBar:MovieClip;
var maxLife:int;// = 1000
var Target2:MovieClip;
var Target1:MovieClip;
var isPlayer:Boolean;
public function CBase(){
maxLife = 1000;
Life = maxLife;
super();
LifeBar = new baselifebar_mc();
LifeBar.gotoAndStop(100);
LifeBar.alpha = 0;
LifeBar.scaleX = 1.8;
addChild(LifeBar);
}
public function createTargets():void{
Target1 = new MovieClip();
Target1.x = (x - 160);
Target1.y = y;
Target2 = new MovieClip();
Target2.x = (x + 160);
Target2.y = y;
addChild(Target1);
addChild(Target2);
}
public function repair(_arg1:int):void{
Life = Math.min((Life + _arg1), 1000);
LifeBar.alpha = 1;
}
public function getDamage(_arg1:int):void{
Life = Math.max(0, (Life - _arg1));
LifeBar.gotoAndStop(Math.round(((Life * 100) / maxLife)));
LifeBar.alpha = 1;
if (Life < 1){
if (!isPlayer){
Game.levelWin();
} else {
Game.levelFailed();
};
};
}
public function update():void{
LifeBar.alpha = Math.max(0, (LifeBar.alpha - 0.05));
}
}
}//package src
Section 38
//CBattleField (src.CBattleField)
package src {
import flash.geom.*;
import flash.display.*;
public class CBattleField extends MovieClip {
var Enemies:CLayer;
var Game:CGame;
var SpawnPoints:MovieClip;
var ChosedIcon:CUnitIcon;
var TurretPlace2:CTurretPlace;
var BG:MovieClip;
var MinePlace1:CMinePlace;
var MinePlace3:CMinePlace;
var TurretType:int;// = 16
var MinePlace2:CMinePlace;
var Units:CLayer;
var EnemyBase:CBase;
var TurretPlaces:MovieClip;
var PlaceInd:int;// = 1
var SFX:CLayer;
var TurretPlace1:CTurretPlace;
var PlayerBase:CBase;
var Tracks:Array;
var Bases:CLayer;
var TrackChoiser:CTrackChoiser;
var DieLayer:CLayer;
var BasesUp:MovieClip;
public function CBattleField(_arg1:CGame){
TurretType = 16;
PlaceInd = 1;
Tracks = new Array();
ChosedIcon = undefined;
super();
Game = _arg1;
BG = new background_mc();
addChild(BG);
createBases();
createTurretPlaces();
createMinePlaces();
createDieLayer();
createTrackChoiser();
Units = new CLayer();
Units.Game = Game;
Units.Type = 1;
addChild(Units);
Enemies = new CLayer();
Enemies.Game = Game;
Enemies.Type = 2;
addChild(Enemies);
createBasesUp();
SFX = new CLayer();
addChild(SFX);
SpawnPoints = new spawnpoints_mc();
initTracksArray();
}
public function createDieAnim(_arg1:int, _arg2:Point, _arg3:Boolean):void{
var _local4:CDieAnim;
if (_arg1 > 15){
return;
};
_local4 = new CDieAnim();
if (!_arg3){
_local4.rotation = 180;
};
_local4.gotoAndStop(_arg1);
_local4.x = _arg2.x;
_local4.y = _arg2.y;
DieLayer.addChild(_local4);
DieLayer.aChildren.push(_local4);
}
public function createBases():void{
Bases = new CLayer();
addChild(Bases);
PlayerBase = new playerBase_mc();
PlayerBase.isPlayer = true;
PlayerBase.Game = Game;
PlayerBase.LifeBar.x = 90;
PlayerBase.LifeBar.y = 55;
PlayerBase.x = 320;
PlayerBase.y = (480 - 120);
PlayerBase.createTargets();
Bases.addChild(PlayerBase);
EnemyBase = new enemyBase_mc();
EnemyBase.isPlayer = false;
EnemyBase.Game = Game;
EnemyBase.LifeBar.x = -310;
EnemyBase.LifeBar.y = -45;
EnemyBase.x = 320;
EnemyBase.y = (-480 + 60);
EnemyBase.createTargets();
addChild(EnemyBase);
}
public function showMinePlaces():void{
if (!MinePlace1.active){
MinePlace1.visible = true;
};
if (!MinePlace2.active){
MinePlace2.visible = true;
};
if (!MinePlace3.active){
MinePlace3.visible = true;
};
}
public function hideMinePlaces():void{
MinePlace1.visible = false;
MinePlace2.visible = false;
MinePlace3.visible = false;
}
public function createTurretPlaces():void{
TurretPlaces = new MovieClip();
addChild(TurretPlaces);
TurretPlace1 = new CTurretPlace();
TurretPlace1.x = 30;
TurretPlace1.y = 299;
TurretPlace1.rotation = 45;
TurretPlaces.addChild(TurretPlace1);
TurretPlace2 = new CTurretPlace();
TurretPlace2.x = (640 - 30);
TurretPlace2.y = 299;
TurretPlace2.rotation = -45;
TurretPlaces.addChild(TurretPlace2);
}
public function createTrackChoiser():void{
TrackChoiser = new CTrackChoiser(Game);
TrackChoiser.visible = false;
addChild(TrackChoiser);
}
public function initTracksArray():void{
var _local1:int;
var _local2:int;
var _local3:Array;
var _local4:int;
var _local5:Point;
_local1 = 25;
_local2 = 0;
while (_local2 < 16) {
_local3 = new Array();
_local1 = (_local1 + 35);
_local4 = 0;
while (_local4 < 61) {
_local5 = new Point(_local1, ((_local4 * 16) - 480));
_local3.push(_local5);
_local4++;
};
Tracks.push(_local3);
_local2++;
};
}
public function createBasesUp():void{
var _local1:MovieClip;
}
public function hideTrackChoiser():void{
TrackChoiser.visible = false;
}
public function createMinePlaces():void{
MinePlace1 = new CMinePlace();
MinePlace1.x = 320;
MinePlace1.y = (130 - 50);
MinePlace1.ind = 1;
TurretPlaces.addChild(MinePlace1);
MinePlace2 = new CMinePlace();
MinePlace2.x = 320;
MinePlace2.y = (190 - 50);
MinePlace2.ind = 2;
TurretPlaces.addChild(MinePlace2);
MinePlace3 = new CMinePlace();
MinePlace3.x = 320;
MinePlace3.y = (250 - 50);
MinePlace3.ind = 3;
TurretPlaces.addChild(MinePlace3);
}
public function createDieLayer():void{
DieLayer = new CLayer();
addChild(DieLayer);
}
public function clearMap():void{
Units.removeAllChildren();
Enemies.removeAllChildren();
PlayerBase.Life = 1000;
EnemyBase.Life = 1000;
}
public function update():void{
if (Units){
Units.update();
};
if (Enemies){
Enemies.update();
};
if (Bases){
EnemyBase.update();
PlayerBase.update();
};
if (SFX){
SFX.update();
};
if (TurretPlaces){
TurretPlace1.update();
TurretPlace2.update();
};
if (DieLayer){
DieLayer.update();
};
}
public function unitBuyed(_arg1:int):void{
Game.Money = (Game.Money - _arg1);
Game.Gui.writeMoney();
}
}
}//package src
Section 39
//CBattleMap (src.CBattleMap)
package src {
import flash.events.*;
import flash.display.*;
public class CBattleMap extends MovieClip {
var Game:CGame;
public var buyButton:SimpleButton;
public var menuButton:SimpleButton;
public var maps:MovieClip;
public var launchButton:SimpleButton;
public function CBattleMap(){
launchButton.addEventListener(MouseEvent.MOUSE_DOWN, launchButtonDownHandler);
buyButton.addEventListener(MouseEvent.MOUSE_DOWN, buyButtonDownHandler);
menuButton.addEventListener(MouseEvent.MOUSE_DOWN, menuButtonDownHandler);
launchButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
buyButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
menuButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
}
public function menuButtonDownHandler(_arg1:MouseEvent):void{
Game.goToMainMenu();
}
public function launchButtonDownHandler(_arg1:MouseEvent):void{
Game.hideBattleMap();
}
public function showMap(_arg1:int):void{
maps.gotoAndStop(_arg1);
visible = true;
}
public function playSnd(_arg1:MouseEvent):void{
Game.SoundManager.Play2DSnd("menu_snd");
}
public function buyButtonDownHandler(_arg1:MouseEvent):void{
Game.showShop();
}
}
}//package src
Section 40
//CBullet (src.CBullet)
package src {
public class CBullet extends CUpdatable {
}
}//package src
Section 41
//CDieAnim (src.CDieAnim)
package src {
import flash.display.*;
public class CDieAnim extends CUpdatable {
var tmp:int;// = 0
public var body:MovieClip;
public function CDieAnim(){
tmp = 0;
super();
}
override public function update():void{
tmp++;
if ((tmp / 5) == int((tmp / 5))){
alpha = (alpha - 0.02);
};
if (alpha < 0.05){
removeMe = true;
};
}
}
}//package src
Section 42
//CEnemyAI (src.CEnemyAI)
package src {
public class CEnemyAI {
var Money:int;
var UnitType:int;// = 1
var Enemies:Array;
var Units:CLayer;
var UnitsCreated:int;
var Game:CGame;
var t:int;// = 0
var LastEnemy:int;// = 0
public function CEnemyAI(_arg1:CGame){
t = 0;
LastEnemy = 0;
UnitType = 1;
super();
Game = _arg1;
Units = Game.BF.Units;
Enemies = new Array();
initAr();
}
public function createUnit(_arg1:int):void{
if (Game.BF.Enemies.aChildren.length > (Units.aChildren.length + 3)){
return;
};
selectCreateUnitType();
Game.createUnit(false, _arg1);
UnitsCreated++;
}
public function update():void{
t++;
if (t == 100){
t = 0;
createUnit(UnitType);
};
}
public function initAr():void{
Enemies = [];
if (Game.currentLevel == 1){
Enemies.push(1);
Enemies.push(2);
Enemies.push(1);
Enemies.push(2);
Enemies.push(1);
Enemies.push(2);
Enemies.push(6);
};
if (Game.currentLevel == 2){
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
Enemies.push(1);
Enemies.push(2);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
Enemies.push(6);
};
if (Game.currentLevel == 3){
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
Enemies.push(1);
Enemies.push(2);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(6);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(6);
};
if (Game.currentLevel == 4){
Enemies.push(6);
Enemies.push(2);
Enemies.push(3);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(9);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(6);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(6);
};
if (Game.currentLevel == 5){
Enemies.push(1);
Enemies.push(2);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(5);
Enemies.push(5);
Enemies.push(2);
Enemies.push(9);
Enemies.push(4);
Enemies.push(6);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(5);
};
if (Game.currentLevel == 6){
Enemies.push(5);
Enemies.push(4);
Enemies.push(4);
Enemies.push(5);
Enemies.push(2);
Enemies.push(5);
Enemies.push(3);
Enemies.push(2);
Enemies.push(7);
Enemies.push(3);
Enemies.push(1);
Enemies.push(7);
Enemies.push(3);
Enemies.push(4);
Enemies.push(5);
};
if (Game.currentLevel == 7){
Enemies.push(10);
Enemies.push(9);
Enemies.push(1);
Enemies.push(5);
Enemies.push(2);
Enemies.push(5);
Enemies.push(3);
Enemies.push(10);
Enemies.push(2);
Enemies.push(3);
Enemies.push(1);
Enemies.push(9);
Enemies.push(3);
Enemies.push(4);
Enemies.push(5);
Enemies.push(1);
Enemies.push(4);
Enemies.push(1);
Enemies.push(3);
Enemies.push(4);
Enemies.push(2);
};
if (Game.currentLevel == 8){
Enemies.push(1);
Enemies.push(5);
Enemies.push(4);
Enemies.push(8);
Enemies.push(3);
Enemies.push(5);
Enemies.push(3);
Enemies.push(10);
Enemies.push(9);
Enemies.push(3);
Enemies.push(1);
Enemies.push(9);
Enemies.push(3);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(1);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(2);
};
if (Game.currentLevel == 9){
Enemies.push(11);
Enemies.push(1);
Enemies.push(1);
Enemies.push(1);
Enemies.push(3);
Enemies.push(5);
Enemies.push(1);
Enemies.push(10);
Enemies.push(9);
Enemies.push(2);
Enemies.push(1);
Enemies.push(9);
Enemies.push(3);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(1);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(10);
};
if (Game.currentLevel == 10){
Enemies.push(11);
Enemies.push(12);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(5);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
};
if (Game.currentLevel == 11){
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(5);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
};
if (Game.currentLevel == 12){
Enemies.push(1);
Enemies.push(5);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(13);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(13);
Enemies.push(9);
Enemies.push(2);
Enemies.push(3);
Enemies.push(8);
Enemies.push(1);
};
if (Game.currentLevel == 13){
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(5);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
};
if (Game.currentLevel == 14){
Enemies.push(4);
Enemies.push(5);
Enemies.push(14);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(11);
Enemies.push(2);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(14);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(3);
};
if (Game.currentLevel == 15){
Enemies.push(4);
Enemies.push(5);
Enemies.push(14);
Enemies.push(15);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(3);
Enemies.push(2);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(13);
Enemies.push(2);
Enemies.push(1);
Enemies.push(15);
Enemies.push(3);
Enemies.push(1);
Enemies.push(3);
};
if (Game.currentLevel == 16){
Enemies.push(4);
Enemies.push(5);
Enemies.push(11);
Enemies.push(15);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(3);
Enemies.push(12);
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(13);
Enemies.push(2);
Enemies.push(1);
Enemies.push(15);
Enemies.push(3);
Enemies.push(1);
Enemies.push(3);
};
if (Game.currentLevel == 17){
Enemies.push(9);
Enemies.push(9);
Enemies.push(15);
Enemies.push(9);
Enemies.push(9);
Enemies.push(15);
Enemies.push(5);
Enemies.push(5);
Enemies.push(5);
};
if (Game.currentLevel == 18){
Enemies.push(10);
Enemies.push(14);
Enemies.push(10);
Enemies.push(13);
Enemies.push(10);
Enemies.push(11);
Enemies.push(12);
};
if (Game.currentLevel == 19){
Enemies.push(1);
Enemies.push(8);
Enemies.push(12);
Enemies.push(5);
Enemies.push(2);
Enemies.push(3);
Enemies.push(15);
Enemies.push(1);
Enemies.push(3);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(11);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(7);
Enemies.push(2);
Enemies.push(3);
};
if (Game.currentLevel == 20){
Enemies.push(15);
Enemies.push(14);
Enemies.push(15);
Enemies.push(14);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
};
if (Game.currentLevel == 21){
Enemies.push(4);
Enemies.push(8);
Enemies.push(1);
Enemies.push(5);
Enemies.push(1);
Enemies.push(3);
Enemies.push(2);
Enemies.push(1);
Enemies.push(11);
Enemies.push(4);
Enemies.push(5);
Enemies.push(5);
Enemies.push(12);
Enemies.push(5);
Enemies.push(1);
Enemies.push(2);
Enemies.push(9);
Enemies.push(8);
Enemies.push(1);
Enemies.push(2);
Enemies.push(3);
};
}
public function checkBuyUnits():void{
}
public function selectCreateUnitType():void{
UnitType = Enemies[LastEnemy];
LastEnemy++;
if (LastEnemy == Enemies.length){
LastEnemy = 0;
};
}
}
}//package src
Section 43
//CExplosion (src.CExplosion)
package src {
public class CExplosion extends CUpdatable {
public function CExplosion(){
addFrameScript(15, frame16);
}
function frame16(){
stop();
}
}
}//package src
Section 44
//CGame (src.CGame)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
import flash.utils.*;
public dynamic class CGame extends MovieClip {
var MainMenu:CMainMenu;
var Gui:CGui;
var unitDrag:Boolean;// = false
var Shop:CShop;
var Statistic:CGameStatistic;
var BF:CBattleField;
var timer:Timer;
var BM:CBattleMap;
var mouseOn:int;// = 0
var MoneyOld:int;
var intro:CIntroSponsor;
var AvailableUnits:Array;
var EnemyAI:CEnemyAI;
var currentLevel:int;// = 1
var Save:CGameSaves;
var Money:int;
var MiniUnitIcon:MovieClip;
var SoundManager:CSoundManager;
var PAUSE:Boolean;// = true
var XMLLoader:CXMLLoader;
public function CGame(){
PAUSE = true;
currentLevel = 1;
mouseOn = 0;
unitDrag = false;
super();
XMLLoader = new CXMLLoader(this);
createAvailableUnits();
Statistic = new CGameStatistic();
Save = new CGameSaves(this);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
addEventListener(MouseEvent.MOUSE_WHEEL, func01);
}
public function createExplosionBig(_arg1:Point):void{
var _local2:CExplosion;
SoundManager.Play2DSnd("explosion_snd");
_local2 = new CExplosion();
_local2.rotation = (Math.random() * 180);
_local2.x = 160;
_local2.y = _arg1.y;
BF.SFX.addChild(_local2);
BF.SFX.aChildren.push(_local2);
_local2 = new CExplosion();
_local2.rotation = (Math.random() * 180);
_local2.x = 320;
_local2.y = _arg1.y;
BF.SFX.addChild(_local2);
BF.SFX.aChildren.push(_local2);
_local2 = new CExplosion();
_local2.rotation = (Math.random() * 180);
_local2.x = 480;
_local2.y = _arg1.y;
BF.SFX.addChild(_local2);
BF.SFX.aChildren.push(_local2);
SoundManager.Play2DSnd("explosion_snd");
}
public function setLoaded():void{
Money = Save.SaveXML.money.@player;
EnemyAI.Money = Save.SaveXML.money.@enemy;
}
public function createShop():void{
Shop = new CShop(this);
Shop.visible = false;
addChild(Shop);
}
public function hideMainMenu():void{
MainMenu.visible = false;
BM.showMap(currentLevel);
createBF();
createEnemyAI();
setLoaded();
createGui();
createMiniIcon();
addTimer();
}
public function mouseUpHandler(_arg1:MouseEvent):void{
}
public function createEnemyAI():void{
EnemyAI = new CEnemyAI(this);
}
public function addTimer():void{
if (timer){
return;
};
timer = new Timer(30);
timer.addEventListener(TimerEvent.TIMER, Update);
timer.start();
}
public function saveGame():void{
Save.SaveXML.currentlevel.@value = currentLevel;
Save.SaveXML.money.@player = Money;
Save.save();
}
public function onSponsorIntroEnded():void{
removeChild(intro);
createMainMenu();
}
public function goToMainMenu():void{
setChildIndex(MainMenu, (numChildren - 1));
MainMenu.visible = true;
}
public function hideBattleMap():void{
startBattle();
}
public function mouseDownHandler(_arg1:MouseEvent):void{
if (BF){
if (mouseOn == 0){
BF.TurretPlace1.stopmigat();
BF.TurretPlace2.stopmigat();
if (BF.MinePlace1.visible){
BF.hideMinePlaces();
};
};
if (!Gui.TabSheet.hitTestPoint(mouseX, mouseY)){
unitDrag = false;
if (MiniUnitIcon){
MiniUnitIcon.visible = false;
};
BF.hideTrackChoiser();
};
};
}
public function updateMiniIcon():void{
if (!MiniUnitIcon){
return;
};
MiniUnitIcon.x = (mouseX + 24);
MiniUnitIcon.y = (mouseY + 24);
}
public function checkMapPosition():void{
if (Gui.sliderDir == 1){
BF.y = Math.min(480, (BF.y + 5));
};
if (Gui.sliderDir == 2){
BF.y = Math.max(0, (BF.y - 5));
};
}
public function gameWin():void{
}
public function positionMap(_arg1, _arg2:Number):void{
if (_arg2 > 0){
BF.y = Math.min(0, ((_arg2 * -8) + 480));
} else {
BF.y = Math.max(0, (_arg2 * -8));
};
}
public function createGui():void{
Gui = new CGui(this);
Gui.visible = false;
addChild(Gui);
}
public function createExplosion(_arg1:Point, _arg2:Number=1):void{
var _local3:CExplosion;
SoundManager.Play2DSnd("explosion_snd");
_local3 = new CExplosion();
_local3.scaleX = (_local3.scaleY = _arg2);
_local3.rotation = (Math.random() * 180);
_local3.x = _arg1.x;
_local3.y = _arg1.y;
BF.SFX.addChild(_local3);
BF.SFX.aChildren.push(_local3);
}
public function createUnit(_arg1:Boolean, _arg2:int, _arg3:Point=null):void{
var _local4:CUnit;
var _local5:int;
if (_arg2 == 20){
_local5 = 1;
while (_local5 < 7) {
_local4 = new CUnit(_arg1, _arg2, this);
_local4.x = BF.SpawnPoints[("sp" + _local5)].x;
_local4.currentTrack = _local5;
BF.Units.addChild(_local4);
BF.Units.aChildren.push(_local4);
_local5++;
};
return;
};
_local4 = new CUnit(_arg1, _arg2, this);
if (_arg1){
if (_arg3){
_local4.x = _arg3.x;
_local4.y = _arg3.y;
if (_arg2 != 19){
if (_arg3.x > 200){
_local4.BodyClip.rotation = -45;
} else {
_local4.BodyClip.rotation = 45;
};
} else {
_local4.x = (_arg3.x + 15);
_local4.y = (_arg3.y + 5);
};
};
BF.Units.addChild(_local4);
BF.Units.aChildren.push(_local4);
} else {
BF.Enemies.addChild(_local4);
BF.Enemies.aChildren.push(_local4);
};
if (_arg2 == 19){
if (BF.PlaceInd == 1){
_local4.MinePlace = BF.MinePlace1;
};
if (BF.PlaceInd == 2){
_local4.MinePlace = BF.MinePlace2;
};
if (BF.PlaceInd == 3){
_local4.MinePlace = BF.MinePlace3;
};
};
}
public function createBF():void{
BF = new CBattleField(this);
BF.visible = false;
addChild(BF);
}
public function createAvailableUnits():void{
var _local1:Boolean;
var _local2:int;
AvailableUnits = new Array();
_local1 = false;
_local2 = 0;
while (_local2 < 20) {
AvailableUnits.push(_local1);
_local2++;
};
}
public function startBattle():void{
BF.BG.gotoAndStop(currentLevel);
BF.DieLayer.removeAllChildren();
if (Money < 1000){
Money = 1000;
};
MoneyOld = Money;
Gui.writeMoney();
BF.EnemyBase.Life = 1000;
BF.PlayerBase.Life = 1000;
BM.visible = false;
BF.clearMap();
BF.y = 0;
BF.visible = true;
Gui.writeMoney();
Gui.writeLevelNumber();
Gui.visible = true;
PAUSE = false;
SoundManager.Play2DSnd("music");
}
public function func01(_arg1:MouseEvent):void{
}
public function showShop():void{
Shop.txtMoney.text = ("$ " + Money.toString());
setChildIndex(Shop, (numChildren - 1));
Shop.visible = true;
}
public function createIntro():void{
gotoAndStop(2);
intro = new CIntroSponsor(this);
intro.x = 320;
intro.y = 350;
addChild(intro);
}
public function createMiniIcon():void{
MiniUnitIcon = new miniuniticon_mc();
MiniUnitIcon.scaleX = (MiniUnitIcon.scaleY = 0.6);
MiniUnitIcon.visible = false;
addChild(MiniUnitIcon);
}
public function showMainMenu():void{
SoundManager.Play2DSnd("intro");
addChild(MainMenu);
}
public function goToMap():void{
Gui.LevelWin.visible = false;
BM.showMap(currentLevel);
setChildIndex(BM, (numChildren - 1));
SoundManager.stopMusic();
SoundManager.Play2DSnd("intro");
}
public function levelWin():void{
SoundManager.Play2DSnd("levelwin_snd");
if (currentLevel < 21){
currentLevel++;
};
saveGame();
PAUSE = true;
Gui.showLewelWin(1);
Shop.checkZamok();
Gui.TabSheet.stopSpawnProgress();
}
public function createMainMenu():void{
SoundManager = new CSoundManager();
SoundManager.musicPlaying = Save.musicPlaying;
SoundManager.soundsPlaying = Save.soundsPlaying;
MainMenu = new CMainMenu(this);
showMainMenu();
createBattleMap();
createShop();
}
public function replayLevel():void{
}
public function levelFailed():void{
PAUSE = true;
Money = MoneyOld;
Gui.showLewelWin(0);
Gui.TabSheet.stopSpawnProgress();
}
public function createBattleMap():void{
BM = new CBattleMap();
BM.maps.gotoAndStop(1);
BM.Game = this;
BM.visible = false;
addChild(BM);
}
public function Update(_arg1:TimerEvent):void{
if (PAUSE){
return;
};
if (BF){
BF.update();
checkMapPosition();
};
if (EnemyAI){
EnemyAI.update();
};
if (Gui){
Gui.TabSheet.update();
Gui.countInfoTime();
Gui.MiniMap.drawUnits();
};
updateMiniIcon();
}
}
}//package src
Section 45
//CGameSaves (src.CGameSaves)
package src {
import flash.net.*;
public class CGameSaves {
const SaveFile:String = "ants_bf";
var musicPlaying:Boolean;// = true
var soundsPlaying:Boolean;// = true
var Game:CGame;
var SaveXML:XML;
var SO:SharedObject;
public function CGameSaves(_arg1:CGame){
musicPlaying = true;
soundsPlaying = true;
super();
Game = _arg1;
load();
}
public function firstInit():void{
var _local1:int;
SaveXML = new XML(<save>
<currentlevel value="1"/>
<money player="1500" enemy="2000"/>
<units>
<unit type="1" desc="unit 1 description" cost="8" shootspeed="0.5" shootradius="200"/>
</units>
<options>
<music value="true"/>
<sounds value="true"/>
</options>
</save>
);
Game.AvailableUnits[0] = true;
Game.AvailableUnits[1] = true;
_local1 = 2;
while (_local1 < 20) {
Game.AvailableUnits[_local1] = false;
_local1++;
};
musicPlaying = true;
soundsPlaying = true;
save();
gameLoaded();
}
public function load():void{
SO = SharedObject.getLocal(SaveFile);
if (SO.data.saveXML){
SaveXML = new XML();
SaveXML = SO.data.saveXML;
gameLoaded();
} else {
firstInit();
};
}
public function gameLoaded():void{
var _local1:Array;
var _local2:int;
Game.Money = SaveXML.money.@player;
Game.currentLevel = SaveXML.currentlevel.@value;
_local1 = SO.data.AvailableUnits;
_local2 = 0;
while (_local2 < 20) {
Game.AvailableUnits[_local2] = _local1[_local2];
_local2++;
};
if (SO.data.Music){
musicPlaying = SO.data.Music;
soundsPlaying = SO.data.Sounds;
} else {
musicPlaying = true;
soundsPlaying = true;
};
}
public function save():void{
SO = SharedObject.getLocal(SaveFile);
SO.data.saveXML = SaveXML;
SO.data.AvailableUnits = Game.AvailableUnits;
if (Game.SoundManager){
SO.data.Music = Game.SoundManager.musicPlaying;
SO.data.Sounds = Game.SoundManager.soundsPlaying;
} else {
SO.data.Music = musicPlaying;
SO.data.Sounds = soundsPlaying;
};
SO.flush();
}
}
}//package src
Section 46
//CGameStatistic (src.CGameStatistic)
package src {
public class CGameStatistic {
public var EnemyKilled:int;
public var UnitsCreated_:int;
public var UnitsLost:int;
public var UnitsCreated:int;
public var EnemyKilled_:int;
public var UnitsLost_:int;
public function CGameStatistic(){
clear();
}
public function clear():void{
UnitsCreated = 0;
EnemyKilled = 0;
UnitsLost = 0;
UnitsCreated_ = 0;
EnemyKilled_ = 0;
UnitsLost_ = 0;
}
}
}//package src
Section 47
//CGrenade (src.CGrenade)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
public class CGrenade extends CUpdatable {
var TP:Point;
var Damage:int;
var Target:MovieClip;
public function CGrenade(_arg1:CGame, _arg2:MovieClip, _arg3:int){
addFrameScript(35, frame36);
scaleX = (scaleY = 0.6);
if (_arg2){
Game = _arg1;
Target = _arg2;
Damage = _arg3;
TP = new Point(_arg2.x, _arg2.y);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
} else {
removeMe = true;
};
}
public function enterFrameHandler(_arg1:Event):void{
var _local2:CVector;
var _local3:CVector;
var _local4:Number;
if (!Game.PAUSE){
move();
if (currentFrame == totalFrames){
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
Game.createExplosion(new Point(x, y), 0.65);
Target.getDamage(Damage);
removeMe = true;
};
_local2 = new CVector(Target.x, Target.y);
_local3 = new CVector(x, y);
_local2.Sub(_local3);
_local4 = Math.abs(_local2.Len());
if (_local4 < 5){
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
Game.createExplosion(new Point(x, y), 0.65);
Target.getDamage(Damage);
removeMe = true;
};
};
}
function frame36(){
stop();
}
public function move():void{
var _local1:Number;
var _local2:CVector;
var _local3:CVector;
_local1 = 5;
_local2 = new CVector(TP.x, TP.y);
_local3 = new CVector(x, y);
_local2.Sub(_local3);
_local2.Normalize();
_local2.Mul(_local1);
_local3.Add(_local2);
x = _local3.X;
y = _local3.Y;
}
}
}//package src
Section 48
//CGui (src.CGui)
package src {
import flash.events.*;
import flash.display.*;
import CPMStar.*;
import flash.text.*;
public class CGui extends MovieClip {
var LevelWin:MovieClip;
public var txtScore:TextField;
var sliderDir:int;// = 0
var Game:CGame;
public var sliderDown:MovieClip;
public var txtInfo:TextField;
public var sliderUp:MovieClip;
public var menuButton:SimpleButton;
var infoTimeLeft:int;// = 0
var MiniMap:CMiniMap;
var infoTime:Boolean;// = false
var totalScore:int;// = 0
var Options:COptions;
var tmpScore:int;// = 0
var Info:CunitInfo;
var CPMStarContentSpotID:String;// = "1374Q10A4FF88"
var TabSheet:CTabSheet;
public function CGui(_arg1:CGame){
totalScore = 0;
tmpScore = 0;
sliderDir = 0;
infoTime = false;
infoTimeLeft = 0;
CPMStarContentSpotID = "1374Q10A4FF88";
super();
Game = _arg1;
txtScore.selectable = false;
writeScore();
txtInfo.visible = false;
txtInfo.mouseEnabled = false;
menuButton.addEventListener(MouseEvent.CLICK, toMenu);
createMiniMap();
createTabSheet();
createInfo();
createLevelWin();
createOptions();
slider();
}
public function createMiniMap():void{
MiniMap = new CMiniMap(Game);
MiniMap.x = 5;
MiniMap.y = 100;
addChild(MiniMap);
}
public function createInfo():void{
Info = new CunitInfo(Game.XMLLoader.unitsXML);
Info.x = 403;
Info.y = 430;
writeMoney();
addChild(Info);
}
public function createOptions():void{
Options = new COptions();
Options.x = 320;
Options.y = 240;
Options.visible = false;
Options.returnBtn.addEventListener(MouseEvent.MOUSE_DOWN, continueGame);
Options.completeButton.addEventListener(MouseEvent.MOUSE_DOWN, completeGame);
Options.musicButton.addEventListener(MouseEvent.MOUSE_DOWN, checkMusic);
Options.soundsButton.addEventListener(MouseEvent.MOUSE_DOWN, checkSounds);
Options.musicButton.gotoAndStop(1);
Options.soundsButton.gotoAndStop(1);
addChild(Options);
if (Game.SoundManager.musicPlaying){
Options.musicButton.gotoAndStop(1);
} else {
Options.musicButton.gotoAndStop(2);
};
if (Game.SoundManager.soundsPlaying){
Options.soundsButton.gotoAndStop(1);
} else {
Options.soundsButton.gotoAndStop(2);
};
}
public function sliderUpMouseOver(_arg1:MouseEvent):void{
sliderDir = 1;
}
public function writeMoney():void{
Info.txtMoney.text = Game.Money.toString();
}
public function sliderDownMouseOver(_arg1:MouseEvent):void{
sliderDir = 2;
}
public function continueGame(_arg1:MouseEvent):void{
Game.PAUSE = false;
Options.visible = false;
}
public function writeScore():void{
txtScore.text = ("score " + tmpScore.toString());
}
public function showInfo(_arg1:String):void{
txtInfo.text = _arg1;
txtInfo.visible = true;
infoTime = true;
}
public function showLewelWin(_arg1:int):void{
var _local2:DisplayObject;
Game.SoundManager.stopMusic();
_local2 = new AdLoader(CPMStarContentSpotID);
LevelWin.adBox.addChild(_local2);
if (_arg1 == 0){
LevelWin.txtCaption.text = "YOU LOSE !";
} else {
LevelWin.txtCaption.text = "VICTORY !";
};
LevelWin.txtCreatedP.text = Game.Statistic.UnitsCreated;
LevelWin.txtCreatedE.text = Game.Statistic.UnitsCreated_;
LevelWin.txtKilledP.text = Game.Statistic.EnemyKilled;
LevelWin.txtKilledE.text = Game.Statistic.EnemyKilled_;
LevelWin.txtLostP.text = Game.Statistic.UnitsLost;
LevelWin.txtLostE.text = Game.Statistic.UnitsLost_;
Game.Statistic.clear();
LevelWin.visible = true;
}
public function writeLevelNumber():void{
Info.txtLevel.text = Game.currentLevel.toString();
}
public function checkSounds(_arg1:MouseEvent):void{
Game.SoundManager.soundsPlaying = !(Game.SoundManager.soundsPlaying);
if (Game.SoundManager.soundsPlaying){
Options.soundsButton.gotoAndStop(1);
} else {
Options.soundsButton.gotoAndStop(2);
};
Game.saveGame();
}
public function toMenu(_arg1:MouseEvent):void{
Game.PAUSE = true;
Options.visible = true;
}
public function sliderOut(_arg1:MouseEvent):void{
sliderDir = 0;
}
public function completeGame(_arg1:MouseEvent):void{
Options.visible = false;
Game.levelFailed();
}
public function countInfoTime():void{
if (infoTime){
infoTimeLeft++;
if (infoTimeLeft == 90){
infoTimeLeft = 0;
infoTime = false;
txtInfo.visible = false;
};
};
}
public function howHandler(_arg1:MouseEvent):void{
}
public function createLevelWin():void{
LevelWin = new levelwin_mc();
LevelWin.x = 320;
LevelWin.y = 240;
LevelWin.visible = false;
addChild(LevelWin);
LevelWin.nextLevelButton.addEventListener(MouseEvent.MOUSE_DOWN, goToMap);
}
public function countLevelScore():int{
return (tmpScore);
}
public function goToMap(_arg1:MouseEvent):void{
while (LevelWin.adBox.numChildren > 1) {
LevelWin.adBox.removeChildAt(0);
};
Game.goToMap();
}
public function slider():void{
sliderUp.addEventListener(MouseEvent.MOUSE_OVER, sliderUpMouseOver);
sliderDown.addEventListener(MouseEvent.MOUSE_OVER, sliderDownMouseOver);
sliderUp.addEventListener(MouseEvent.MOUSE_OUT, sliderOut);
sliderDown.addEventListener(MouseEvent.MOUSE_OUT, sliderOut);
}
public function createTabSheet():void{
TabSheet = new CTabSheet(Game);
TabSheet.x = 0;
TabSheet.y = 430;
addChild(TabSheet);
}
public function checkMusic(_arg1:MouseEvent):void{
Game.SoundManager.musicPlaying = !(Game.SoundManager.musicPlaying);
if (Game.SoundManager.musicPlaying){
Options.musicButton.gotoAndStop(1);
Game.SoundManager.Play2DSnd("music");
} else {
Options.musicButton.gotoAndStop(2);
Game.SoundManager.stopMusic();
};
Game.saveGame();
}
}
}//package src
Section 49
//CIconDescription (src.CIconDescription)
package src {
import flash.display.*;
public class CIconDescription extends MovieClip {
}
}//package src
Section 50
//CIntroSponsor (src.CIntroSponsor)
package src {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class CIntroSponsor extends MovieClip {
var Game:CGame;
public var Nexusbtn2:MovieClip;
public function CIntroSponsor(_arg1:CGame){
addFrameScript(0, frame1, 108, frame109);
Game = _arg1;
buttonMode = true;
addEventListener(Event.ENTER_FRAME, update);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
public function mouseDownHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashgamesnexus.com"), "_blank");
}
function frame1(){
Nexusbtn2.addEventListener(MouseEvent.CLICK, callLink);
}
function frame109(){
stop();
}
public function callLink(_arg1:MouseEvent):void{
var url:String;
var request:URLRequest;
var e = _arg1;
url = "http://www.flashgamesnexus.com/";
request = new URLRequest(url);
try {
navigateToURL(request, "_blank");
} catch(e:Error) {
};
}
public function update(_arg1:Event):void{
if (currentFrame == totalFrames){
removeEventListener(Event.ENTER_FRAME, update);
Game.onSponsorIntroEnded();
};
}
}
}//package src
Section 51
//CLayer (src.CLayer)
package src {
import flash.geom.*;
import flash.display.*;
public class CLayer extends MovieClip {
var Game:CGame;
var Type:int;
var aChildren:Array;
public function CLayer(){
aChildren = new Array();
}
public function removeDeathChildren():void{
var _local1:int;
var _local2:CUpdatable;
_local1 = aChildren.length;
while (_local1 > 0) {
_local2 = aChildren[(_local1 - 1)];
if (_local2.removeMe){
if ((_local2 is CUnit)){
Game.BF.createDieAnim((_local2 as CUnit).Type, new Point(_local2.x, _local2.y), (_local2 as CUnit).IsPlayerUnit);
};
removeDeathChild(_local2);
aChildren.splice((_local1 - 1), 1);
if (aChildren.length < 1){
allChildrenDeath();
};
};
_local1--;
};
}
public function removeDeathChild(_arg1:CUpdatable):void{
removeChild(_arg1);
if (!(_arg1 is CUnit)){
return;
};
if (Type == 1){
Game.Statistic.UnitsLost++;
Game.Statistic.EnemyKilled_++;
} else {
Game.Statistic.UnitsLost_++;
Game.Statistic.EnemyKilled++;
};
}
public function removeAllChildren():void{
var _local1:int;
var _local2:CUpdatable;
while (numChildren > 0) {
removeChildAt(0);
};
aChildren = [];
}
public function allChildrenDeath():void{
}
public function update():void{
updateChildren();
removeDeathChildren();
}
public function updateChildren():void{
var _local1:int;
var _local2:CUpdatable;
_local1 = 1;
while (_local1 <= aChildren.length) {
_local2 = aChildren[(_local1 - 1)];
_local2.update();
_local1++;
};
}
}
}//package src
Section 52
//CMainMenu (src.CMainMenu)
package src {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class CMainMenu extends MovieClip {
public var contButton:MovieClip;
var Game:CGame;
public var howtoplayButton:MovieClip;
public var playButton:MovieClip;
public var freeButton:MovieClip;
var confirmWindow:MovieClip;
public var moreButton:MovieClip;
public function CMainMenu(_arg1:CGame){
Game = _arg1;
confirmWindow = new confirmwindow_mc();
confirmWindow.visible = false;
confirmWindow.x = 412;
confirmWindow.y = 277;
addChild(confirmWindow);
confirmWindow.yesB.addEventListener(MouseEvent.MOUSE_DOWN, confirm);
confirmWindow.noB.addEventListener(MouseEvent.MOUSE_DOWN, cancel);
playButton.addEventListener(MouseEvent.MOUSE_UP, playButtonClick);
contButton.addEventListener(MouseEvent.MOUSE_UP, contButtonButtonClick);
moreButton.addEventListener(MouseEvent.MOUSE_DOWN, moreButtonButtonClick);
freeButton.addEventListener(MouseEvent.MOUSE_DOWN, freeButtonButtonClick);
playButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
contButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
moreButton.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
confirmWindow.yesB.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
confirmWindow.noB.addEventListener(MouseEvent.MOUSE_OVER, playSnd);
if (isUrl(["flashgamelicense.com", "ucoz.com"])){
};
}
public function freeButtonButtonClick(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashninjaclan.com/"), "_blank");
}
public function moreButtonButtonClick(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashgamesnexus.com"), "_blank");
}
private function playButtonClick(_arg1:MouseEvent):void{
if (Game.currentLevel > 1){
confirmWindow.visible = true;
return;
};
Game.Save.firstInit();
Game.Shop.firstInit();
Game.hideMainMenu();
}
public function playSnd(_arg1:MouseEvent):void{
Game.SoundManager.Play2DSnd("menu_snd");
}
public function cancel(_arg1:MouseEvent):void{
confirmWindow.visible = false;
}
public function confirm(_arg1:MouseEvent):void{
confirmWindow.visible = false;
Game.Save.firstInit();
Game.hideMainMenu();
}
private function contButtonButtonClick(_arg1:MouseEvent):void{
Game.hideMainMenu();
}
public function isUrl(_arg1:Array):Boolean{
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:String;
var _local6:Number;
var _local7:Number;
var _local8:int;
_local2 = Game.stage.loaderInfo.url;
_local3 = (_local2.indexOf("://") + 3);
_local4 = _local2.indexOf("/", _local3);
_local5 = _local2.substring(_local3, _local4);
_local6 = (_local5.lastIndexOf(".") - 1);
_local7 = (_local5.lastIndexOf(".", _local6) + 1);
_local5 = _local5.substring(_local7, _local5.length);
_local8 = 0;
while (_local8 < _arg1.length) {
if (_local5 == _arg1[_local8]){
return (true);
};
_local8++;
};
return (false);
}
}
}//package src
Section 53
//CMinePlace (src.CMinePlace)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
public class CMinePlace extends MovieClip {
var active:Boolean;// = false
public var mpa:MovieClip;
var ind:int;
public function CMinePlace(){
active = false;
super();
visible = false;
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
public function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:CUnitIcon;
_local2 = ((parent.parent as CBattleField).Game.Gui.TabSheet.sheet4.getChildByName("icon4") as CUnitIcon);
_local2.startSpawnProgress();
active = true;
(parent.parent as CBattleField).PlaceInd = ind;
(parent.parent as CBattleField).Game.createUnit(true, 19, new Point(x, y));
(parent.parent as CBattleField).hideMinePlaces();
}
}
}//package src
Section 54
//CMiniMap (src.CMiniMap)
package src {
import flash.events.*;
import flash.display.*;
public class CMiniMap extends MovieClip {
var Game:CGame;
var tmp:int;// = 1
var mapObjects:MovieClip;
public function CMiniMap(_arg1:CGame){
tmp = 1;
super();
Game = _arg1;
mapObjects = new MovieClip();
addChild(mapObjects);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
alpha = 0.5;
}
public function mouseDownHandler(_arg1:MouseEvent):void{
if (mouseY < 0){
Game.positionMap(mouseX, Math.max((mouseY - 2), -60));
} else {
Game.positionMap(mouseX, Math.min((mouseY + 2), 60));
};
}
public function drawUnits():void{
var _local1:Sprite;
var _local2:Sprite;
var _local3:int;
var _local4:Number;
if (tmp == 2){
tmp = 1;
return;
};
clearMap();
_local3 = 0;
while (_local3 < Game.BF.Enemies.aChildren.length) {
_local1 = new Sprite();
_local1.graphics.beginFill(0xFF0000);
_local4 = 3;
if (Game.BF.Enemies.aChildren[_local3].Type > 5){
_local4 = 4;
};
_local1.graphics.drawCircle(0, 0, _local4);
_local1.x = (Game.BF.Enemies.aChildren[_local3].x / 8);
_local1.y = Math.max((Game.BF.Enemies.aChildren[_local3].y / 8), -56);
mapObjects.addChild(_local1);
_local3++;
};
_local3 = 0;
while (_local3 < Game.BF.Units.aChildren.length) {
_local2 = new Sprite();
_local2.graphics.beginFill(0x6600);
_local4 = 3;
if (Game.BF.Units.aChildren[_local3].Type > 5){
_local4 = 4;
};
_local2.graphics.drawCircle(0, 0, _local4);
_local2.x = (Game.BF.Units.aChildren[_local3].x / 8);
_local2.y = Math.min((Game.BF.Units.aChildren[_local3].y / 8), 56);
mapObjects.addChild(_local2);
_local3++;
};
tmp = 2;
}
public function clearMap():void{
while (mapObjects.numChildren > 0) {
mapObjects.removeChildAt(0);
};
}
}
}//package src
Section 55
//COptions (src.COptions)
package src {
import flash.display.*;
public class COptions extends MovieClip {
public var returnBtn:SimpleButton;
public var musicButton:MovieClip;
public var soundsButton:MovieClip;
public var completeButton:SimpleButton;
}
}//package src
Section 56
//CPreloader (src.CPreloader)
package src {
import flash.events.*;
import flash.display.*;
import CPMStar.*;
import flash.text.*;
public dynamic class CPreloader extends MovieClip {
var Game:CGame;
public var ad:DisplayObject;
public var txt:TextField;
public var adBox:MovieClip;
public var CPMStarContentSpotID:String;
public var progressbar:MovieClip;
public function CPreloader(){
addFrameScript(0, frame1);
stage.showDefaultContextMenu = false;
Game = (parent as CGame);
Game.stop();
progressbar.gotoAndStop(1);
txt.selectable = false;
addEventListener(Event.ENTER_FRAME, Update);
}
function frame1(){
CPMStarContentSpotID = "1373Q1B087F0D";
ad = new AdLoader(CPMStarContentSpotID);
adBox.addChild(ad);
}
public function isUrl(_arg1:Array):Boolean{
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:String;
var _local6:Number;
var _local7:Number;
var _local8:int;
_local2 = parent.stage.loaderInfo.url;
_local3 = (_local2.indexOf("://") + 3);
_local4 = _local2.indexOf("/", _local3);
_local5 = _local2.substring(_local3, _local4);
_local6 = (_local5.lastIndexOf(".") - 1);
_local7 = (_local5.lastIndexOf(".", _local6) + 1);
_local5 = _local5.substring(_local7, _local5.length);
this.txt.text = _local5;
_local8 = 0;
while (_local8 < _arg1.length) {
if (_local5 == _arg1[_local8]){
return (true);
};
_local8++;
};
return (false);
}
public function Update(_arg1:Event):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = stage.loaderInfo.bytesLoaded;
_local3 = stage.loaderInfo.bytesTotal;
_local4 = 0;
if (_local3 > 0){
_local4 = Math.floor(((_local2 / _local3) * 100));
};
this.progressbar.gotoAndStop((_local4 + 1));
txt.text = _local4.toString();
if ((((_local2 == _local3)) || ((_local3 == 0)))){
removeEventListener(Event.ENTER_FRAME, Update);
removeChild(adBox);
stage.frameRate = 30;
Game.createMainMenu();
};
}
}
}//package src
Section 57
//CPreloader2 (src.CPreloader2)
package src {
import flash.events.*;
import flash.display.*;
import CPMStar.*;
public class CPreloader2 extends MovieClip {
var Game:CGame;
public var ad:DisplayObject;
public var nexuspreloader:MovieClip;
public var adBox:MovieClip;
public var playbtn:SimpleButton;
public var CPMStarContentSpotID:String;
public function CPreloader2(){
addFrameScript(0, frame1);
stage.showDefaultContextMenu = false;
Game = (parent as CGame);
gotoAndStop(1);
playbtn.visible = false;
nexuspreloader.addEventListener(Event.ENTER_FRAME, preloaderEnterFrame);
}
function frame1(){
stop();
CPMStarContentSpotID = "1373Q1B087F0D";
ad = new AdLoader(CPMStarContentSpotID);
adBox.addChild(ad);
}
public function preloaderEnterFrame(_arg1:Event):void{
if (nexuspreloader.currentFrame == 43){
nexuspreloader.gotoAndStop(44);
playbtn.addEventListener(MouseEvent.MOUSE_DOWN, playGame);
playbtn.visible = true;
};
if (nexuspreloader.MOVIE_LOADED == true){
nexuspreloader.removeEventListener(Event.ENTER_FRAME, preloaderEnterFrame);
};
}
public function playGame(_arg1:MouseEvent):void{
playbtn.removeEventListener(MouseEvent.DOUBLE_CLICK, playGame);
if (adBox){
removeChild(adBox);
};
stage.frameRate = 30;
Game.createIntro();
}
}
}//package src
Section 58
//CRocket (src.CRocket)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
public class CRocket extends CUpdatable {
var TP:Point;
var Owner:CUnit;
var Damage:int;
var Target:MovieClip;
public function CRocket(_arg1:CGame, _arg2:MovieClip, _arg3:int, _arg4:CUnit){
addFrameScript(59, frame60);
if (_arg2){
Game = _arg1;
Target = _arg2;
Damage = _arg3;
Owner = _arg4;
TP = new Point(_arg2.x, _arg2.y);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
scaleX = (scaleY = 0.3);
move();
} else {
removeMe = true;
};
}
public function enterFrameHandler(_arg1:Event):void{
if (!Game.PAUSE){
move();
if (currentFrame == totalFrames){
bum();
};
};
}
public function bum():void{
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
Game.createExplosion(new Point(x, y));
Target.getDamage(Damage);
if (Target.Life < 1){
Owner.Target = undefined;
Owner.state = 1;
};
removeMe = true;
}
public function move():void{
var _local1:Number;
var _local2:CVector;
var _local3:CVector;
_local1 = 10;
_local2 = new CVector((TP.x - (Math.random() * 2)), (TP.y + (Math.random() * 2)));
_local3 = new CVector(x, y);
_local2.Sub(_local3);
if (Math.abs(_local2.Len()) < _local1){
bum();
};
_local2.Normalize();
_local2.Mul(_local1);
_local3.Add(_local2);
x = _local3.X;
y = _local3.Y;
rotation = _local2.getDirection();
}
function frame60(){
stop();
}
}
}//package src
Section 59
//CSheet (src.CSheet)
package src {
import flash.events.*;
import flash.display.*;
public class CSheet extends MovieClip {
public function CSheet(){
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
buttonMode = true;
}
public function mouseDownHandler(_arg1:MouseEvent):void{
(parent as CTabSheet).bringToFront(this);
}
}
}//package src
Section 60
//CShop (src.CShop)
package src {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class CShop extends MovieClip {
var Icons:MovieClip;
public var txtDelay:TextField;
var Game:CGame;
public var shoptext:MovieClip;
public var txtMoney:TextField;
public var txtDist:TextField;
public var txtCost:TextField;
public var txtDescription:TextField;
public var txtRap:TextField;
public var txtSpeed:TextField;
public var txtLife:TextField;
public var backButton:SimpleButton;
public var txtDamage:TextField;
public function CShop(_arg1:CGame){
Game = _arg1;
txtDescription.visible = false;
txtCost.visible = false;
backButton.addEventListener(MouseEvent.MOUSE_DOWN, backButtonDownHandler);
createIcons();
shoptext.visible = false;
txtLife.visible = false;
txtDamage.visible = false;
txtSpeed.visible = false;
txtRap.visible = false;
txtDist.visible = false;
txtDelay.visible = false;
}
public function hideDesc():void{
txtDescription.visible = false;
txtCost.visible = false;
shoptext.visible = false;
txtLife.visible = false;
txtDamage.visible = false;
txtSpeed.visible = false;
txtRap.visible = false;
txtDist.visible = false;
txtDelay.visible = false;
}
public function showDesc(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8:String):void{
txtDescription.text = _arg1;
txtDescription.visible = true;
txtCost.text = _arg2;
txtCost.visible = true;
txtLife.text = _arg3;
txtDamage.text = _arg4;
txtSpeed.text = _arg5;
txtRap.text = _arg6;
txtDist.text = _arg7;
txtDelay.text = _arg8;
shoptext.visible = true;
txtLife.visible = true;
txtDamage.visible = true;
txtSpeed.visible = true;
txtRap.visible = true;
txtDist.visible = true;
txtDelay.visible = true;
}
public function buyUnit(_arg1:int):void{
var _local2:int;
_local2 = Game.XMLLoader.unitsXML.unit[_arg1].@cost;
if ((_local2 * 2) > Game.Money){
return;
};
Game.Money = (Game.Money - (_local2 * 2));
txtMoney.text = ("$ " + Game.Money.toString());
Game.AvailableUnits[(_arg1 - 1)] = true;
Game.Gui.TabSheet.checkIcons();
Game.saveGame();
}
public function checkZamok():void{
var _local1:int;
var _local2:int;
var _local3:int;
_local2 = 0;
_local3 = 0;
while (_local3 < numChildren) {
if ((getChildAt(_local3) is CShopIcon)){
_local2++;
_local1 = Game.XMLLoader.unitsXML.unit[_local2].@available;
if (_local1 <= Game.currentLevel){
(getChildAt(_local3) as CShopIcon).zamok.visible = false;
};
};
_local3++;
};
}
public function backButtonDownHandler(_arg1:MouseEvent):void{
visible = false;
}
public function createIcons():void{
var _local1:CShopIcon;
var _local2:int;
var _local3:int;
var _local4:int;
_local3 = 0;
_local2 = 0;
while (_local2 < 5) {
_local1 = new CShopIcon();
_local1.x = ((_local2 * 80) + 120);
_local1.y = 90;
_local3++;
_local1.gotoAndStop(_local3);
_local4 = Game.XMLLoader.unitsXML.unit[_local3].@available;
if (_local4 <= Game.currentLevel){
_local1.zamok.visible = false;
};
if (Game.AvailableUnits[(_local3 - 1)] == true){
_local1.showGalka();
};
addChild(_local1);
_local2++;
};
_local2 = 0;
while (_local2 < 5) {
_local1 = new CShopIcon();
_local1.x = ((_local2 * 80) + 120);
_local1.y = 160;
_local3++;
_local1.gotoAndStop(_local3);
_local4 = Game.XMLLoader.unitsXML.unit[_local3].@available;
if (_local4 <= Game.currentLevel){
_local1.zamok.visible = false;
};
if (Game.AvailableUnits[(_local3 - 1)] == true){
_local1.showGalka();
_local1.zamok.visible = false;
};
addChild(_local1);
_local2++;
};
_local2 = 0;
while (_local2 < 5) {
_local1 = new CShopIcon();
_local1.x = ((_local2 * 80) + 120);
_local1.y = 230;
_local3++;
_local1.gotoAndStop(_local3);
_local4 = Game.XMLLoader.unitsXML.unit[_local3].@available;
if (_local4 <= Game.currentLevel){
_local1.zamok.visible = false;
};
if (Game.AvailableUnits[(_local3 - 1)] == true){
_local1.showGalka();
_local1.zamok.visible = false;
};
addChild(_local1);
_local2++;
};
_local2 = 0;
while (_local2 < 5) {
_local1 = new CShopIcon();
_local1.x = ((_local2 * 80) + 120);
_local1.y = 300;
_local3++;
_local1.gotoAndStop(_local3);
_local4 = Game.XMLLoader.unitsXML.unit[_local3].@available;
if (_local4 <= Game.currentLevel){
_local1.zamok.visible = false;
};
if (Game.AvailableUnits[(_local3 - 1)] == true){
_local1.showGalka();
_local1.zamok.visible = false;
};
addChild(_local1);
_local2++;
};
}
public function firstInit():void{
var _local1:CShopIcon;
var _local2:int;
_local2 = 0;
while (_local2 < (numChildren - 1)) {
if ((getChildAt(_local2) is CShopIcon)){
removeChildAt(_local2);
};
_local2++;
};
createIcons();
}
}
}//package src
Section 61
//CShopIcon (src.CShopIcon)
package src {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
public class CShopIcon extends MovieClip {
var zamok:MovieClip;
var galka:MovieClip;
public function CShopIcon(){
var _local1:DropShadowFilter;
var _local2:BevelFilter;
super();
scaleX = (scaleY = 1.1);
buttonMode = true;
galka = new galka_mc();
galka.x = 12;
galka.y = 25;
zamok = new zamok_mc();
zamok.scaleX = (zamok.scaleY = 0.6);
zamok.x = 12;
zamok.y = 25;
addChild(zamok);
galka.visible = false;
addChild(galka);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
_local1 = new DropShadowFilter(0, 0, 0, 1, 2, 2, 3, BitmapFilterQuality.HIGH, false, false, false);
_local2 = new BevelFilter(3, 15, 12683010, 1, 8871681, 1, 2, 2, 1, 1, "inner", false);
filters = [_local2, _local1];
_local1 = new DropShadowFilter(0, 0, 0, 1, 2, 2, 2, BitmapFilterQuality.HIGH, false, false, false);
galka.filters = [_local1];
}
public function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:String;
_local2 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@available;
if (zamok.visible){
(parent as CShop).Game.SoundManager.Play2DSnd("blocking_snd");
return;
};
if (!galka.visible){
showGalka();
(parent as CShop).buyUnit(currentFrame);
};
}
public function mouseOutHandler(_arg1:MouseEvent):void{
(parent as CShop).hideDesc();
}
public function showGalka():void{
galka.visible = true;
}
public function mouseOverHandler(_arg1:MouseEvent):void{
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:String;
_local2 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@desc;
_local3 = (("Cost " + ((parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@cost * 2)) + " $");
_local4 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@life;
_local5 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@damage;
_local6 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@speed;
_local7 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@shootspeed;
_local8 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@shootradius;
_local9 = (parent as CShop).Game.XMLLoader.unitsXML.unit[currentFrame].@spawntime;
(parent as CShop).showDesc(_local2, _local3, _local4, _local5, _local6, _local7, _local8, _local9);
}
}
}//package src
Section 62
//CSoundManager (src.CSoundManager)
package src {
import flash.events.*;
import flash.media.*;
public dynamic class CSoundManager {
var chnl:SoundChannel;
var sounds:Object;
var musicPlaying:Boolean;// = true
var chnlM:SoundChannel;
var st:SoundTransform;
var soundsPlaying:Boolean;// = true
var introPlaying:Boolean;// = true
public function CSoundManager(){
musicPlaying = true;
soundsPlaying = true;
introPlaying = true;
super();
sounds = new Object();
sounds["intro"] = new intro();
sounds["music"] = new battle_snd();
sounds["menu_snd"] = new menu_snd();
sounds["levelwin_snd"] = new levelwin_snd();
sounds["explosion_snd"] = new explosion_snd();
sounds["blocking_snd"] = new blocking_snd();
sounds["gun16"] = new machine_gun();
sounds["gun17"] = new rocket_gun();
sounds["gun1"] = new pistol_snd();
sounds["gun3"] = new avtomat_snd();
st = new SoundTransform();
}
public function Play2DSnd(_arg1:String):void{
if (_arg1 == "music"){
if (!musicPlaying){
return;
};
st.volume = 0.8;
stopMusic();
chnlM = sounds[_arg1].play();
chnlM.soundTransform = st;
chnlM.addEventListener(Event.SOUND_COMPLETE, replayMusic);
return;
};
if (_arg1 == "intro"){
if (!musicPlaying){
return;
};
st.volume = 0.8;
stopMusic();
chnlM = sounds[_arg1].play();
chnlM.soundTransform = st;
chnlM.addEventListener(Event.SOUND_COMPLETE, replayIntro);
return;
} else {
if (soundsPlaying){
chnl = sounds[_arg1].play();
};
};
}
public function replayIntro(_arg1:Event):void{
chnlM.removeEventListener(Event.SOUND_COMPLETE, replayIntro);
if (musicPlaying){
Play2DSnd("intro");
};
}
public function playMusic():void{
}
public function stopMusic():void{
if (chnlM){
chnlM.stop();
};
}
public function replayMusic(_arg1:Event):void{
chnlM.removeEventListener(Event.SOUND_COMPLETE, replayMusic);
if (musicPlaying){
Play2DSnd("music");
};
}
}
}//package src
Section 63
//CSpawnProgress (src.CSpawnProgress)
package src {
import flash.display.*;
public class CSpawnProgress extends MovieClip {
}
}//package src
Section 64
//CSponsorLogo (src.CSponsorLogo)
package src {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.filters.*;
public class CSponsorLogo extends MovieClip {
public function CSponsorLogo(){
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
addEventListener(MouseEvent.MOUSE_OVER, addFilter);
addEventListener(MouseEvent.MOUSE_OUT, removeFilter);
}
public function removeFilter(_arg1:MouseEvent):void{
filters = [];
}
public function mouseDownHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashgamesnexus.com"), "_blank");
}
public function addFilter(_arg1:MouseEvent):void{
var _local2:DropShadowFilter;
_local2 = new DropShadowFilter(0, 0, 0xFF0000, 1, 2, 2, 2, BitmapFilterQuality.HIGH, false, false, false);
filters = [_local2];
}
}
}//package src
Section 65
//CSponsorLogo2 (src.CSponsorLogo2)
package src {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.filters.*;
public class CSponsorLogo2 extends MovieClip {
public function CSponsorLogo2(){
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
addEventListener(MouseEvent.MOUSE_OVER, addFilter);
addEventListener(MouseEvent.MOUSE_OUT, removeFilter);
}
public function removeFilter(_arg1:MouseEvent):void{
filters = [];
}
public function mouseDownHandler(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.flashninjaclan.com/"), "_blank");
}
public function addFilter(_arg1:MouseEvent):void{
var _local2:DropShadowFilter;
_local2 = new DropShadowFilter(0, 0, 0xFF0000, 1, 2, 2, 2, BitmapFilterQuality.HIGH, false, false, false);
filters = [_local2];
}
}
}//package src
Section 66
//CTabSheet (src.CTabSheet)
package src {
import flash.events.*;
import flash.display.*;
import fl.transitions.easing.*;
import fl.transitions.*;
public class CTabSheet extends MovieClip {
var Game:CGame;
var sheet2:CSheet;
var sheet4:CSheet;
var sheet1:CSheet;
var sheet3:CSheet;
public function CTabSheet(_arg1:CGame){
Game = _arg1;
createSheets();
}
public function createSheets():void{
var _local1:int;
var _local2:CUnitIcon;
var _local3:int;
_local1 = 0;
_local3 = 0;
sheet1 = new CSheet();
sheet1.gotoAndStop(1);
_local1 = 0;
while (_local1 < 5) {
_local3++;
_local2 = new CUnitIcon();
_local2.Game = Game;
_local2.x = ((_local1 * 50) + 40);
_local2.y = 24;
_local2.type = _local3;
_local2.gotoAndStop(_local3);
if (Game.AvailableUnits[(_local3 - 1)] == false){
_local2.gotoAndStop(21);
};
sheet1.addChild(_local2);
_local1++;
};
addChild(sheet1);
sheet2 = new CSheet();
sheet2.gotoAndStop(2);
_local1 = 0;
while (_local1 < 5) {
_local3++;
_local2 = new CUnitIcon();
_local2.Game = Game;
_local2.x = ((_local1 * 50) + 40);
_local2.y = 24;
_local2.type = _local3;
_local2.gotoAndStop(_local3);
if (Game.AvailableUnits[(_local3 - 1)] == false){
_local2.gotoAndStop(21);
};
sheet2.addChild(_local2);
_local1++;
};
addChild(sheet2);
sheet3 = new CSheet();
sheet3.gotoAndStop(3);
_local1 = 0;
while (_local1 < 5) {
_local3++;
_local2 = new CUnitIcon();
_local2.Game = Game;
_local2.x = ((_local1 * 50) + 40);
_local2.y = 24;
_local2.type = _local3;
_local2.gotoAndStop(_local3);
if (Game.AvailableUnits[(_local3 - 1)] == false){
_local2.gotoAndStop(21);
};
sheet3.addChild(_local2);
_local1++;
};
addChild(sheet3);
sheet4 = new CSheet();
sheet4.gotoAndStop(4);
_local1 = 0;
while (_local1 < 5) {
_local2.name = ("icon" + _local1);
_local3++;
_local2 = new CUnitIcon();
_local2.Game = Game;
_local2.x = ((_local1 * 50) + 40);
_local2.y = 24;
_local2.type = _local3;
_local2.gotoAndStop(_local3);
if (Game.AvailableUnits[(_local3 - 1)] == false){
_local2.gotoAndStop(21);
};
sheet4.addChild(_local2);
_local1++;
};
addChild(sheet4);
bringToFront(sheet1);
}
public function bringToFront(_arg1:MovieClip):void{
sheet1.buttonMode = true;
sheet2.buttonMode = true;
sheet3.buttonMode = true;
sheet4.buttonMode = true;
setChildIndex(_arg1, (numChildren - 1));
_arg1.buttonMode = false;
}
public function mouseOutHandler(_arg1:MouseEvent):void{
var _local2:Tween;
_local2 = new Tween(this, "alpha", None.easeNone, 1, 0.5, 5, false);
}
public function update():void{
var _local1:int;
_local1 = 0;
while (_local1 < sheet1.numChildren) {
if ((sheet1.getChildAt(_local1) is CUnitIcon)){
(sheet1.getChildAt(_local1) as CUnitIcon).update();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet2.numChildren) {
if ((sheet2.getChildAt(_local1) is CUnitIcon)){
(sheet2.getChildAt(_local1) as CUnitIcon).update();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet3.numChildren) {
if ((sheet3.getChildAt(_local1) is CUnitIcon)){
(sheet3.getChildAt(_local1) as CUnitIcon).update();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet4.numChildren) {
if ((sheet4.getChildAt(_local1) is CUnitIcon)){
(sheet4.getChildAt(_local1) as CUnitIcon).update();
};
_local1++;
};
}
public function stopSpawnProgress():void{
var _local1:int;
_local1 = 0;
while (_local1 < sheet1.numChildren) {
if ((sheet1.getChildAt(_local1) is CUnitIcon)){
(sheet1.getChildAt(_local1) as CUnitIcon).stopSpawnProgress();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet2.numChildren) {
if ((sheet2.getChildAt(_local1) is CUnitIcon)){
(sheet2.getChildAt(_local1) as CUnitIcon).stopSpawnProgress();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet3.numChildren) {
if ((sheet3.getChildAt(_local1) is CUnitIcon)){
(sheet3.getChildAt(_local1) as CUnitIcon).stopSpawnProgress();
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet4.numChildren) {
if ((sheet4.getChildAt(_local1) is CUnitIcon)){
(sheet4.getChildAt(_local1) as CUnitIcon).stopSpawnProgress();
};
_local1++;
};
}
public function mouseOverHandler(_arg1:MouseEvent):void{
var _local2:Tween;
_local2 = new Tween(this, "alpha", None.easeNone, 0.5, 1, 5, false);
}
public function checkIcons():void{
var _local1:int;
var _local2:int;
_local2 = 0;
_local1 = 0;
while (_local1 < sheet1.numChildren) {
if ((sheet1.getChildAt(_local1) is CUnitIcon)){
if ((sheet1.getChildAt(_local1) as CUnitIcon).currentFrame == 21){
if (Game.AvailableUnits[((sheet1.getChildAt(_local1) as CUnitIcon).type - 1)] == true){
(sheet1.getChildAt(_local1) as CUnitIcon).gotoAndStop((sheet1.getChildAt(_local1) as CUnitIcon).type);
};
};
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet2.numChildren) {
if ((sheet2.getChildAt(_local1) is CUnitIcon)){
if ((sheet2.getChildAt(_local1) as CUnitIcon).currentFrame == 21){
if (Game.AvailableUnits[((sheet2.getChildAt(_local1) as CUnitIcon).type - 1)] == true){
(sheet2.getChildAt(_local1) as CUnitIcon).gotoAndStop((sheet2.getChildAt(_local1) as CUnitIcon).type);
};
};
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet3.numChildren) {
if ((sheet3.getChildAt(_local1) is CUnitIcon)){
if ((sheet3.getChildAt(_local1) as CUnitIcon).currentFrame == 21){
if (Game.AvailableUnits[((sheet3.getChildAt(_local1) as CUnitIcon).type - 1)] == true){
(sheet3.getChildAt(_local1) as CUnitIcon).gotoAndStop((sheet3.getChildAt(_local1) as CUnitIcon).type);
};
};
};
_local1++;
};
_local1 = 0;
while (_local1 < sheet4.numChildren) {
if ((sheet4.getChildAt(_local1) is CUnitIcon)){
if ((sheet4.getChildAt(_local1) as CUnitIcon).currentFrame == 21){
if (Game.AvailableUnits[((sheet4.getChildAt(_local1) as CUnitIcon).type - 1)] == true){
(sheet4.getChildAt(_local1) as CUnitIcon).gotoAndStop((sheet4.getChildAt(_local1) as CUnitIcon).type);
};
};
};
_local1++;
};
}
}
}//package src
Section 67
//CTimer (src.CTimer)
package src {
import flash.display.*;
import flash.text.*;
public dynamic class CTimer extends MovieClip {
public var txtTime:TextField;
}
}//package src
Section 68
//CTrackChoiser (src.CTrackChoiser)
package src {
import flash.display.*;
public class CTrackChoiser extends MovieClip {
var Game:CGame;
var chosedUnitType:int;// = -1
var chosedUnitTrack:int;// = -1
public function CTrackChoiser(_arg1:CGame){
var _local2:CTrackPoint;
var _local3:int;
chosedUnitType = -1;
chosedUnitTrack = -1;
super();
Game = _arg1;
_local3 = 0;
while (_local3 < 8) {
_local2 = new CTrackPoint((_local3 + 1));
_local2.x = ((_local3 * 70) + 77.5);
_local2.y = 350;
addChild(_local2);
_local3++;
};
}
}
}//package src
Section 69
//CTrackPoint (src.CTrackPoint)
package src {
import flash.events.*;
import flash.display.*;
public class CTrackPoint extends MovieClip {
var ind:int;
public function CTrackPoint(_arg1:int){
ind = _arg1;
buttonMode = true;
alpha = 0.6;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
public function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:Number;
var _local3:int;
(parent as CTrackChoiser).Game.BF.hideTrackChoiser();
(parent as CTrackChoiser).Game.unitDrag = false;
(parent as CTrackChoiser).chosedUnitTrack = (ind - 1);
(parent as CTrackChoiser).Game.BF.ChosedIcon.startSpawnProgress();
(parent as CTrackChoiser).Game.createUnit(true, (parent as CTrackChoiser).chosedUnitType);
_local3 = (parent as CTrackChoiser).Game.XMLLoader.unitsXML.unit[(parent as CTrackChoiser).chosedUnitType].@cost;
(parent as CTrackChoiser).Game.BF.unitBuyed(_local3);
}
}
}//package src
Section 70
//CTurretPlace (src.CTurretPlace)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
public class CTurretPlace extends MovieClip {
var active:Boolean;// = false
var dir:int;// = 0
var migat:Boolean;// = true
public function CTurretPlace(){
active = false;
migat = true;
dir = 0;
super();
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
public function stopmigat():void{
migat = false;
alpha = 1;
buttonMode = false;
}
public function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:CUnitIcon;
if (!migat){
return;
};
(parent.parent as CBattleField).TurretPlace1.stopmigat();
(parent.parent as CBattleField).TurretPlace2.stopmigat();
(parent.parent as CBattleField).Game.createUnit(true, (parent.parent as CBattleField).TurretType, new Point(x, y));
if ((parent.parent as CBattleField).Game.BF.TurretType == 16){
_local2 = ((parent.parent as CBattleField).Game.Gui.TabSheet.sheet4.getChildByName("icon1") as CUnitIcon);
_local2.startSpawnProgress();
};
if ((parent.parent as CBattleField).Game.BF.TurretType == 17){
_local2 = ((parent.parent as CBattleField).Game.Gui.TabSheet.sheet4.getChildByName("icon2") as CUnitIcon);
_local2.startSpawnProgress();
};
}
public function update():void{
if (!migat){
return;
};
if (dir == 1){
alpha = (alpha - 0.025);
if (alpha < 0.25){
dir = 2;
};
};
if (dir == 2){
alpha = (alpha + 0.025);
if (alpha > 0.95){
dir = 1;
};
};
}
public function startmigat():void{
dir = 1;
migat = true;
buttonMode = true;
}
}
}//package src
Section 71
//CUnit (src.CUnit)
package src {
import flash.geom.*;
import flash.display.*;
import flash.filters.*;
public class CUnit extends CUpdatable {
const STATE_SPAWN:int = 0;
const STATE_SHOOTING:int = 2;
const STATE_MOVING:int = 1;
var isTlyaTarget:Boolean;// = false
var Speed:Number;
var BodyClip:MovieClip;
var MinePlace:CMinePlace;
var t:CVector;
var GunClip:MovieClip;
var desc:String;
var state:int;// = 0
var willBeKilled:Boolean;// = false
var SpawnTime:int;
var timeLeftMine:int;// = 0
var way:int;// = 0
var IsPlayerUnit:Boolean;
var Life:int;// = 100
var shadow:DropShadowFilter;
var Type:int;
var currentTrackPoint:int;
var currentTrack:int;
var Damage:int;
var shootRadius:Number;// = 200
var shootTime:Number;// = 0.5
var killAward:int;
var Target:MovieClip;
var shootTimeLeft:int;// = 0
var Cost:int;
public function CUnit(_arg1:Boolean, _arg2:int, _arg3:CGame){
var _local4:int;
Life = 100;
shootRadius = 200;
shootTime = 0.5;
shootTimeLeft = 0;
state = STATE_SPAWN;
willBeKilled = false;
isTlyaTarget = false;
way = 0;
timeLeftMine = 0;
MinePlace = undefined;
super();
IsPlayerUnit = _arg1;
Game = _arg3;
Type = _arg2;
desc = Game.XMLLoader.unitsXML.unit[_arg2].@desc;
Cost = Game.XMLLoader.unitsXML.unit[_arg2].@cost;
Life = Game.XMLLoader.unitsXML.unit[_arg2].@life;
Damage = Game.XMLLoader.unitsXML.unit[_arg2].@damage;
shootTime = Game.XMLLoader.unitsXML.unit[_arg2].@shootspeed;
shootTimeLeft = (((60 * 30) / shootTime) - 1);
Speed = Game.XMLLoader.unitsXML.unit[_arg2].@speed;
shootRadius = Game.XMLLoader.unitsXML.unit[_arg2].@shootradius;
SpawnTime = Game.XMLLoader.unitsXML.unit[_arg2].@spawntime;
killAward = Game.XMLLoader.unitsXML.unit[_arg2].@killaward;
BodyClip = new unit_body_mc();
BodyClip.gotoAndStop(Type);
addChild(BodyClip);
if (_arg1){
GunClip = new unit_gun_mc();
} else {
GunClip = new unit_gun_enemy_mc();
};
GunClip.gotoAndStop(Type);
addChild(GunClip);
if (Type < 6){
shadow = new DropShadowFilter(3, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
};
if ((((Type > 5)) && ((Type < 11)))){
shadow = new DropShadowFilter(3, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
};
if ((((Type > 10)) && ((Type < 16)))){
BodyClip.scaleX = (BodyClip.scaleY = 0.6);
shadow = new DropShadowFilter(20, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
};
if (Type == 20){
shadow = new DropShadowFilter(20, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
};
if ((((Type > 15)) && ((Type < 18)))){
shadow = new DropShadowFilter(3, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
};
if (Type == 18){
GunClip.rotation = -45;
shadow = new DropShadowFilter(5, 45, 0x333333, 1, 5, 5, 1, BitmapFilterQuality.HIGH, false, false, false);
filters = [shadow];
state = STATE_SHOOTING;
};
if ((((Type == CUnitTypes.TURRELAUTO_GUARDUNIT)) || ((Type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))){
BodyClip.scaleX = (BodyClip.scaleY = (GunClip.scaleX = (GunClip.scaleY = (32 / 19.8))));
};
if (IsPlayerUnit){
y = 490;
} else {
BodyClip.rotation = 180;
y = -490;
};
_local4 = (Math.round((Math.random() * 14)) + 1);
if (Type != 20){
currentTrack = _local4;
if (IsPlayerUnit){
currentTrack = (Game.BF.TrackChoiser.chosedUnitTrack * 2);
if (Math.random() > 0.5){
currentTrack++;
};
};
x = Game.BF.Tracks[currentTrack][0].x;
way = _local4;
};
currentTrackPoint = 59;
if (!IsPlayerUnit){
currentTrackPoint = 0;
};
t = new CVector();
if (IsPlayerUnit){
Game.Statistic.UnitsCreated++;
} else {
Game.Statistic.UnitsCreated_++;
};
}
public function shoot():void{
var _local1:int;
var _local2:int;
if (((((!(Target)) || (Target.willBeKilled))) || ((Target.Life < 1)))){
state = STATE_MOVING;
Target = undefined;
BodyClip.body.play();
GunClip.rotation = 0;
return;
};
if (Type == CUnitTypes.GUN_UNIT){
Game.SoundManager.Play2DSnd("gun1");
};
if (Type == CUnitTypes.AVTOMAT_UNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.GRANATOMET_UNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.SNIPER_UNIT){
Game.SoundManager.Play2DSnd("gun1");
};
if (Type == CUnitTypes.GUSENICA_HEAVYUNIT){
Game.SoundManager.Play2DSnd("gun1");
};
if (Type == CUnitTypes.KOROVKA_HEAVYUNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.TARAKAN_HEAVYUNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.ZHUKOLEN_HEAVYUNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.PAUK_HEAVYUNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.STREKOZA_FLYUNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.ZHUK_FLYUNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.BABOCHKA_FLYUNIT){
Game.SoundManager.Play2DSnd("gun3");
};
if (Type == CUnitTypes.ZHUK_FLYUNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.MUCHA_FLYUNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.TURRELAUTO_GUARDUNIT){
Game.SoundManager.Play2DSnd("gun16");
};
if (Type == CUnitTypes.TURRELRAKETA_GUARDUNIT){
Game.SoundManager.Play2DSnd("gun17");
};
if (Type == CUnitTypes.MINA_GUARDUNIT){
return;
};
if (Target.Life < 1){
return;
};
if (!Target){
return;
};
GunClip.gun.gotoAndPlay(2);
if ((((((((((((((((((((Type == CUnitTypes.GUN_UNIT)) || ((Type == CUnitTypes.SNIPER_UNIT)))) || ((Type == CUnitTypes.TURRELAUTO_GUARDUNIT)))) || ((Type == CUnitTypes.GUSENICA_HEAVYUNIT)))) || ((Type == CUnitTypes.KOROVKA_HEAVYUNIT)))) || ((Type == CUnitTypes.TARAKAN_HEAVYUNIT)))) || ((Type == CUnitTypes.STREKOZA_FLYUNIT)))) || ((Type == CUnitTypes.ZHUK_FLYUNIT)))) || ((Type == CUnitTypes.BABOCHKA_FLYUNIT)))) || ((Type == CUnitTypes.AVTOMAT_UNIT)))){
_local1 = Game.XMLLoader.unitsXML.unit[Type].@damage;
Target.getDamage(_local1);
};
if (Type == CUnitTypes.GRANADER_UNIT){
createGrenade();
};
if ((((((((((((Type == CUnitTypes.GRANATOMET_UNIT)) || ((Type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))) || ((Type == CUnitTypes.ZHUKOLEN_HEAVYUNIT)))) || ((Type == CUnitTypes.PAUK_HEAVYUNIT)))) || ((Type == CUnitTypes.SHMEL_FLYUNIT)))) || ((Type == CUnitTypes.MUCHA_FLYUNIT)))){
createRocket();
_local2 = Math.max(0, (Target.Life - Damage));
if (_local2 < 1){
if ((Target is CUnit)){
(Target as CUnit).willBeKilled = true;
};
Target = undefined;
state = STATE_MOVING;
BodyClip.body.play();
if (IsPlayerUnit){
if (Type == CUnitTypes.GRANATOMET_UNIT){
GunClip.rotation = 0;
};
} else {
if (Type == CUnitTypes.GRANATOMET_UNIT){
GunClip.rotation = 0;
};
};
};
};
f0();
}
public function getDamage(_arg1:int):void{
if (Type != 20){
Life = Math.max(0, (Life - _arg1));
};
}
public function die():void{
if (!IsPlayerUnit){
Game.Money = (Game.Money + killAward);
Game.Gui.writeMoney();
};
removeMe = true;
if ((((Type == CUnitTypes.TURRELAUTO_GUARDUNIT)) || ((Type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))){
Game.createExplosion(new Point(x, y), 1.2);
};
}
public function f0():void{
var _local1:int;
shootTimeLeft = 0;
if (!Target){
return;
};
if (Target.Life < 1){
state = STATE_MOVING;
if (IsPlayerUnit){
if (!(((Type == CUnitTypes.TURRELAUTO_GUARDUNIT)) || ((Type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))){
GunClip.rotation = 0;
};
} else {
GunClip.rotation = 0;
};
BodyClip.body.play();
if (((IsPlayerUnit) && ((Target is CUnit)))){
_local1 = Game.XMLLoader.unitsXML.unit[(Target as CUnit).Type].@killaward;
Game.Money = (Game.Money + _local1);
};
Target = undefined;
};
}
public function mineFieldBum():void{
var _local1:CLayer;
var _local2:CUnit;
var _local3:int;
var _local4:Number;
if (IsPlayerUnit){
_local1 = Game.BF.Enemies;
} else {
_local1 = Game.BF.Units;
};
_local3 = 0;
while (_local3 < _local1.numChildren) {
_local2 = _local1.aChildren[_local3];
if (_local2.Type < 11){
_local4 = Math.abs((y - _local2.y));
if (_local4 < shootRadius){
_local2.getDamage(Damage);
};
};
_local3++;
};
Game.createExplosionBig(new Point(x, y));
MinePlace.active = false;
removeMe = true;
}
public function followTarget():void{
var _local1:CVector;
var _local2:CVector;
_local1 = new CVector(Target.x, Target.y);
_local2 = new CVector(x, y);
_local1.Sub(_local2);
_local1.Normalize();
if (IsPlayerUnit){
GunClip.rotation = (_local1.getDirection() + 90);
};
}
public function findTarget():void{
var _local1:Number;
var _local2:Array;
var _local3:CVector;
var _local4:CVector;
var _local5:Object;
var _local6:CLayer;
var _local7:Boolean;
_local7 = true;
if (IsPlayerUnit){
_local6 = Game.BF.Enemies;
} else {
_local6 = Game.BF.Units;
};
if (_local6.aChildren.length < 1){
return;
};
_local2 = new Array();
_local3 = new CVector(x, y);
_local4 = new CVector();
_local1 = 1;
while (_local1 <= _local6.aChildren.length) {
_local5 = new Object();
_local5.enemy = _local6.aChildren[(_local1 - 1)];
_local4.InitXY(_local5.enemy.x, _local5.enemy.y);
t.InitVec(_local4);
t.Sub(_local3);
_local5.len = Math.abs(t.Len());
if (Type == 17){
};
if (_local5.len <= shootRadius){
if (_local5.enemy.Type == 19){
_local7 = false;
};
if ((_local5.enemy is CUnit)){
if (_local5.enemy.willBeKilled){
_local7 = false;
};
if (Type == 20){
if (_local5.enemy.isTlyaTarget){
_local7 = false;
};
};
};
if (Type == 17){
};
if (_local7){
_local2.push(_local5);
};
};
_local1++;
};
if (!_local2.length){
return;
};
_local2.sortOn("len", Array.NUMERIC);
Target = _local2[0].enemy;
if (Type == 20){
Target.isTlyaTarget = true;
};
_local4.Normalize();
if (IsPlayerUnit){
GunClip.rotation = _local4.getDirection();
} else {
t.InitXY(x, y);
_local4.InitXY(Target.x, Target.y);
t.Sub(_local4);
t.Normalize();
GunClip.rotation = (t.getDirection() + 90);
};
state = STATE_SHOOTING;
if (Type != 20){
BodyClip.body.stop();
};
}
public function createGrenade():void{
var _local1:CGrenade;
if (!Target){
return;
};
_local1 = new CGrenade(Game, Target, Damage);
_local1.x = (x + 3);
_local1.y = (y - 3);
Game.BF.SFX.addChild(_local1);
Game.BF.SFX.aChildren.push(_local1);
}
public function findEnemyBase():void{
var _local1:CVector;
var _local2:CVector;
var _local3:CBase;
var _local4:Number;
if (IsPlayerUnit){
_local3 = Game.BF.EnemyBase;
} else {
_local3 = Game.BF.PlayerBase;
};
if (_local3.Life < 1){
return;
};
_local1 = new CVector(x, y);
_local2 = new CVector(_local3.x, _local3.y);
_local2.Sub(_local1);
_local4 = Math.abs(_local2.Len());
_local2.Normalize();
if (_local4 <= shootRadius){
BodyClip.body.stop();
state = STATE_SHOOTING;
Target = _local3;
if (IsPlayerUnit){
GunClip.rotation = _local2.getDirection();
} else {
GunClip.rotation = (_local2.getDirection() - 90);
};
};
_local1 = new CVector(x, y);
_local2 = new CVector(_local3.Target1.x, _local3.Target1.y);
_local2.Sub(_local1);
_local4 = Math.abs(_local2.Len());
_local2.Normalize();
if (_local4 <= shootRadius){
BodyClip.body.stop();
state = STATE_SHOOTING;
Target = _local3;
_local1 = new CVector(x, y);
_local2 = new CVector(_local3.x, _local3.y);
_local2.Sub(_local1);
_local2.Normalize();
if (IsPlayerUnit){
GunClip.rotation = _local2.getDirection();
} else {
GunClip.rotation = (_local2.getDirection() - 90);
};
};
_local1 = new CVector(x, y);
_local2 = new CVector(_local3.Target2.x, _local3.Target2.y);
_local2.Sub(_local1);
_local4 = Math.abs(_local2.Len());
_local2.Normalize();
if (_local4 <= shootRadius){
BodyClip.body.stop();
state = STATE_SHOOTING;
Target = _local3;
_local1 = new CVector(x, y);
_local2 = new CVector(_local3.x, _local3.y);
_local2.Sub(_local1);
_local2.Normalize();
if (IsPlayerUnit){
GunClip.rotation = _local2.getDirection();
} else {
GunClip.rotation = (_local2.getDirection() - 90);
};
};
}
override public function update():void{
if (Type == CUnitTypes.TLYA_GUARDUNIT){
updateAsTlya();
return;
};
if (Type == CUnitTypes.MINA_GUARDUNIT){
updateAsMina();
return;
};
if (Type == 18){
shootTimeLeft++;
if (shootTimeLeft > ((60 * 30) / shootTime)){
Game.BF.PlayerBase.repair(Damage);
GunClip.gun.gotoAndPlay(2);
shootTimeLeft = 0;
};
return;
};
if (state == STATE_SPAWN){
move();
if (IsPlayerUnit){
if (y < 300){
state = STATE_MOVING;
};
} else {
if (y > -300){
state = STATE_MOVING;
};
};
};
if (state == STATE_MOVING){
move();
if (!Target){
findTarget();
};
if (!Target){
findEnemyBase();
};
};
if (state == STATE_SHOOTING){
shootTimeLeft++;
if (Target){
followTarget();
};
if (shootTimeLeft > ((60 * 30) / shootTime)){
shoot();
};
};
if (Life < 1){
die();
};
}
public function createRocket():void{
var _local1:CRocket;
if (Type == CUnitTypes.TURRELRAKETA_GUARDUNIT){
_local1 = new CRocket(Game, Target, Math.round((Damage / 2)), this);
_local1.x = (x + 6);
_local1.y = (y - 3);
Game.BF.SFX.addChild(_local1);
Game.BF.SFX.aChildren.push(_local1);
_local1 = new CRocket(Game, Target, Math.round((Damage / 2)), this);
_local1.x = (x - 6);
_local1.y = (y - 3);
Game.BF.SFX.addChild(_local1);
Game.BF.SFX.aChildren.push(_local1);
} else {
_local1 = new CRocket(Game, Target, Damage, this);
if (IsPlayerUnit){
_local1.x = (x + 5);
_local1.y = (y - 5);
} else {
_local1.x = (x - 5);
_local1.y = (y + 5);
};
Game.BF.SFX.addChild(_local1);
Game.BF.SFX.aChildren.push(_local1);
};
}
public function traceXY():void{
}
public function updateAsTlya():void{
var _local1:Boolean;
var _local2:*;
var _local3:CVector;
_local1 = true;
if (!Target){
findTarget();
y = (y - Speed);
BodyClip.rotation = 0;
} else {
_local3 = new CVector(Target.x, Target.y);
_local2 = new CVector(x, y);
_local3.Sub(_local2);
_local3.Normalize();
_local3.Mul((Speed * 4));
BodyClip.rotation = (_local3.getDirection() + 90);
x = (x + _local3.X);
y = (y + _local3.Y);
if (hitTestObject(Target)){
bansay(_local1);
};
};
if ((((y < 50)) && (!(Target)))){
_local1 = false;
bansay(_local1);
};
if (((Target) && ((Target.Life < 1)))){
_local1 = false;
bansay(_local1);
};
}
public function createBullet():void{
var _local1:MovieClip;
_local1 = new bullet_mc();
_local1.gotoAndStop(1);
_local1.x = x;
_local1.y = y;
_local1.width = 50;
_local1.rotation = t.getDirection();
Game.BF.SFX.addChild(_local1);
Game.BF.SFX.aChildren.push(_local1);
_local1.play();
}
override public function showInfo():void{
}
public function bansay(_arg1:Boolean):void{
die();
if (_arg1){
(Target as CUnit).isTlyaTarget = false;
(Target as CUnit).getDamage(Damage);
};
Game.createExplosion(new Point(x, y), 0.8);
}
public function updateAsMina():void{
var _local1:CLayer;
var _local2:CUnit;
var _local3:int;
timeLeftMine++;
if (timeLeftMine < 3){
return;
};
timeLeftMine = 0;
if (IsPlayerUnit){
_local1 = Game.BF.Enemies;
} else {
_local1 = Game.BF.Units;
};
_local3 = 0;
while (_local3 < _local1.numChildren) {
_local2 = _local1.aChildren[_local3];
if (_local2.Type < 11){
if (GunClip.hitTestObject(_local2)){
mineFieldBum();
};
};
_local3++;
};
}
public function move():void{
var _local1:CLayer;
var _local2:CUnit;
var _local3:CVector;
var _local4:CVector;
var _local5:int;
if (Life < 1){
return;
};
if ((((((((Type == CUnitTypes.TURRELAUTO_GUARDUNIT)) || ((Type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))) || ((Type == CUnitTypes.MINA_GUARDUNIT)))) || ((Type == CUnitTypes.REMONT_GUARDUNIT)))){
return;
};
_local3 = new CVector(x, y);
if (IsPlayerUnit){
_local4 = new CVector(Game.BF.Tracks[currentTrack][Math.max((currentTrackPoint - 1), 0)].x, Game.BF.Tracks[currentTrack][Math.max((currentTrackPoint - 1), 0)].y);
} else {
_local4 = new CVector(Game.BF.Tracks[currentTrack][Math.min((currentTrackPoint + 1), 59)].x, Game.BF.Tracks[currentTrack][Math.min((currentTrackPoint + 1), 59)].y);
};
_local4.Sub(_local3);
if (_local4.Len() < Speed){
if (IsPlayerUnit){
currentTrackPoint--;
} else {
currentTrackPoint++;
};
};
_local4.Normalize();
_local4.Mul(Speed);
x = (x + _local4.X);
y = (y + _local4.Y);
if (IsPlayerUnit){
_local1 = Game.BF.Units;
} else {
_local1 = Game.BF.Enemies;
};
_local5 = 0;
while (_local5 < _local1.aChildren.length) {
if (_local1.aChildren[_local5]){
_local2 = _local1.aChildren[_local5];
} else {
_local2 = undefined;
};
if (_local2){
if ((((currentTrack == _local2.currentTrack)) && (!((this == _local2))))){
if (IsPlayerUnit){
if (((((currentTrackPoint - _local2.currentTrackPoint) < 4)) && (((y - _local2.y) > 0)))){
if (currentTrack != 0){
currentTrack--;
} else {
currentTrack++;
};
currentTrackPoint--;
currentTrackPoint--;
if (currentTrackPoint < 0){
currentTrackPoint = 0;
};
};
} else {
if (((((_local2.currentTrackPoint - currentTrackPoint) < 4)) && (((_local2.y - y) > 0)))){
if (currentTrack != 15){
currentTrack++;
} else {
currentTrack--;
};
currentTrackPoint++;
currentTrackPoint++;
if (currentTrackPoint > 59){
currentTrackPoint = 59;
};
};
};
};
};
_local5++;
};
}
}
}//package src
Section 72
//CUnitIcon (src.CUnitIcon)
package src {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
public class CUnitIcon extends MovieClip {
var Game:CGame;
var timeleft:int;
var type:int;
var spawnprogress:CSpawnProgress;
var IconDescription:CIconDescription;
public function CUnitIcon(){
buttonMode = true;
spawnprogress = new CSpawnProgress();
spawnprogress.gotoAndStop(1);
spawnprogress.visible = false;
addChild(spawnprogress);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
}
public function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:int;
if (currentFrame == 21){
Game.SoundManager.Play2DSnd("blocking_snd");
return;
};
if (spawnprogress.visible){
Game.SoundManager.Play2DSnd("blocking_snd");
return;
};
_local2 = Game.XMLLoader.unitsXML.unit[type].@cost;
if ((Game.Money - _local2) < 0){
Game.Gui.showInfo("Can't create unit. Need more money.");
Game.SoundManager.Play2DSnd("blocking_snd");
return;
};
if (type == CUnitTypes.MINA_GUARDUNIT){
Game.BF.showMinePlaces();
return;
};
if ((((type == CUnitTypes.TURRELAUTO_GUARDUNIT)) || ((type == CUnitTypes.TURRELRAKETA_GUARDUNIT)))){
Game.BF.TurretPlace1.startmigat();
Game.BF.TurretPlace2.startmigat();
Game.BF.TurretType = type;
return;
};
if (type < 16){
Game.BF.TrackChoiser.visible = true;
Game.BF.TrackChoiser.chosedUnitType = type;
Game.MiniUnitIcon.gotoAndStop(type);
Game.MiniUnitIcon.visible = true;
Game.BF.ChosedIcon = this;
return;
};
if (type == 20){
Game.createUnit(true, type);
};
if (type == 18){
Game.createUnit(true, type, new Point(620, 410));
};
startSpawnProgress();
Game.Money = (Game.Money - _local2);
Game.Gui.writeMoney();
}
public function startSpawnProgress():void{
timeleft = 0;
spawnprogress.visible = true;
}
public function mouseOutHandler(_arg1:MouseEvent):void{
Game.Gui.Info.hideInfo();
if ((((((type == 16)) || ((type == 17)))) || ((type == 19)))){
Game.mouseOn = 0;
};
}
public function update():void{
var _local1:int;
var _local2:int;
if (spawnprogress.visible){
_local1 = Game.XMLLoader.unitsXML.unit[type].@spawntime;
timeleft++;
_local2 = Math.round(((timeleft * 50) / (30 * _local1)));
spawnprogress.gotoAndStop(_local2);
if (timeleft == (30 * _local1)){
spawnprogress.visible = false;
};
};
}
public function createIconDesc():void{
IconDescription = new CIconDescription();
IconDescription.visible = false;
IconDescription.y = -25;
addChild(IconDescription);
}
public function stopSpawnProgress():void{
spawnprogress.visible = false;
}
public function mouseOverHandler(_arg1:MouseEvent):void{
Game.Gui.Info.showDesc(type);
if ((((((type == 16)) || ((type == 17)))) || ((type == 19)))){
Game.mouseOn = type;
};
}
}
}//package src
Section 73
//CunitInfo (src.CunitInfo)
package src {
import flash.display.*;
import flash.text.*;
public class CunitInfo extends MovieClip {
public var txtLevel:TextField;
public var txtMoney:TextField;
public var txtInfo:MovieClip;
var InfoXML:XML;
public function CunitInfo(_arg1:XML){
InfoXML = _arg1;
txtInfo.visible = false;
txtInfo.txtDesc.wordWrap = true;
}
public function hideInfo():void{
txtInfo.visible = false;
}
public function showDesc(_arg1:int):void{
txtInfo.txtUnitname.text = InfoXML.unit[_arg1].@name;
txtInfo.txtCost.text = InfoXML.unit[_arg1].@cost;
txtInfo.txtDesc.text = InfoXML.unit[_arg1].@desc;
txtInfo.visible = true;
}
}
}//package src
Section 74
//CUnitTypes (src.CUnitTypes)
package src {
public class CUnitTypes {
public const MAXUNITCOUNT:int = 20;
public static const GUN_UNIT:int = 1;
public static const MUCHA_FLYUNIT:int = 15;
public static const GUSENICA_HEAVYUNIT:int = 6;
public static const TARAKAN_HEAVYUNIT:int = 8;
public static const GRANATOMET_UNIT:int = 4;
public static const TLYA_GUARDUNIT:int = 20;
public static const AVTOMAT_UNIT:int = 3;
public static const SNIPER_UNIT:int = 5;
public static const KOROVKA_HEAVYUNIT:int = 7;
public static const MINA_GUARDUNIT:int = 19;
public static const ZHUK_FLYUNIT:int = 12;
public static const SHMEL_FLYUNIT:int = 14;
public static const BABOCHKA_FLYUNIT:int = 13;
public static const TURRELAUTO_GUARDUNIT:int = 16;
public static const REMONT_GUARDUNIT:int = 18;
public static const TURRELRAKETA_GUARDUNIT:int = 17;
public static const PAUK_HEAVYUNIT:int = 10;
public static const STREKOZA_FLYUNIT:int = 11;
public static const GRANADER_UNIT:int = 2;
public static const ZHUKOLEN_HEAVYUNIT:int = 9;
}
}//package src
Section 75
//CUpdatable (src.CUpdatable)
package src {
import flash.display.*;
public class CUpdatable extends MovieClip {
var active:Boolean;// = true
var Game:CGame;
var Anim:MovieClip;
public var removeMe:Boolean;// = false
var posX:int;// = 0
var posY:int;// = 0
public function CUpdatable(){
removeMe = false;
posX = 0;
posY = 0;
active = true;
super();
}
public function hideInfo():void{
}
public function showInfo():void{
}
public function update():void{
}
}
}//package src
Section 76
//CVector (src.CVector)
package src {
public class CVector {
public var X:Number;
public var Y:Number;
public function CVector(_arg1:Number=0, _arg2:Number=0){
X = _arg1;
Y = _arg2;
}
public function Sub(_arg1:CVector):void{
X = (X - _arg1.X);
Y = (Y - _arg1.Y);
}
public function InitVec(_arg1:CVector):void{
X = _arg1.X;
Y = _arg1.Y;
}
public function Add(_arg1:CVector):void{
X = (X + _arg1.X);
Y = (Y + _arg1.Y);
}
public function getDirection():Number{
return (((Math.atan2(Y, X) / Math.PI) * 180));
}
public function Mul(_arg1:Number):void{
X = (X * _arg1);
Y = (Y * _arg1);
}
public function toString():String{
return ((((("[" + X.toString()) + ", ") + Y.toString()) + "]"));
}
public function Normalize():void{
var _local1:Number;
_local1 = ((X * X) + (Y * Y));
if (_local1 > 0){
_local1 = (1 / Math.sqrt(_local1));
X = (X * _local1);
Y = (Y * _local1);
};
}
public function Rot90():void{
var _local1:Number;
_local1 = X;
X = -(Y);
Y = _local1;
}
public function InitXY(_arg1:Number, _arg2:Number):void{
X = _arg1;
Y = _arg2;
}
public function Equal(_arg1:CVector, _arg2:Number):Boolean{
if ((((Math.abs((_arg1.X - X)) <= _arg2)) && ((Math.abs((_arg1.Y - Y)) <= _arg2)))){
return (true);
};
return (false);
}
public function Len():Number{
return (Math.sqrt(((X * X) + (Y * Y))));
}
public function Len2():Number{
return (((X * X) + (Y * Y)));
}
public static function Sub(_arg1:CVector, _arg2:CVector, _arg3:CVector):void{
_arg1.X = (_arg2.X - _arg3.X);
_arg1.Y = (_arg2.Y - _arg3.Y);
}
public static function Add(_arg1:CVector, _arg2:CVector, _arg3:CVector):void{
_arg1.X = (_arg2.X + _arg3.X);
_arg1.Y = (_arg2.Y + _arg3.Y);
}
public static function GetK(_arg1:CVector, _arg2:CVector):Number{
if (_arg2.X != 0){
return ((_arg1.X / _arg2.X));
};
if (_arg2.Y != 0){
return ((_arg1.Y / _arg2.Y));
};
return (0);
}
public static function Lerp(_arg1:CVector, _arg2:CVector, _arg3:CVector, _arg4:Number):void{
_arg1.X = (((_arg3.X - _arg2.X) * _arg4) + _arg2.X);
_arg1.Y = (((_arg3.Y - _arg2.Y) * _arg4) + _arg2.Y);
}
public static function Dot(_arg1:CVector, _arg2:CVector):Number{
return (((_arg1.X * _arg2.X) + (_arg1.Y * _arg2.Y)));
}
public static function CrossProduct(_arg1:CVector, _arg2:CVector):Number{
return (((_arg1.X * _arg2.Y) - (_arg1.Y * _arg2.X)));
}
}
}//package src
Section 77
//CWinInfo (src.CWinInfo)
package src {
import flash.display.*;
public dynamic class CWinInfo extends MovieClip {
public var levelwin:levelwin_mc;
public var gamewin:MovieClip;
public var youlose:MovieClip;
}
}//package src
Section 78
//CXMLLoader (src.CXMLLoader)
package src {
import flash.events.*;
import flash.net.*;
public class CXMLLoader {
const levelsFile:String = "xml/levels.xml";
const unitsFile:String = "xml/units.xml";
const testMode:Boolean = false;
var levelsLoader:URLLoader;
var levelsXML:XML;
var unitsLoader:URLLoader;
var unitsXML:XML;
var Game:CGame;
public function CXMLLoader(_arg1:CGame=null){
Game = _arg1;
unitsXML = new XML();
unitsXML.ignoreWhitespace = true;
if (testMode){
loadXMLs();
} else {
setXMLs();
};
}
public function setXMLs():void{
unitsXML = XML(<units>
<unit type="0"/>
<unit type="1" available="1" name="Recruit" desc="Recruit. The main cannon fodder." cost="100" life="100" damage="40" shootspeed="30" speed="0.6" shootradius="200" spawntime="2" killaward="120"/>
<unit type="2" available="1" name="Grenader" desc="Grenader. Effective against infantry." cost="150" life="100" damage="120" shootspeed="20" speed="0.6" shootradius="200" spawntime="2" killaward="150"/>
<unit type="3" available="2" name="Officer" desc="Officer. Great rate and armor." cost="200" life="150" damage="40" shootspeed="35" speed="0.8" shootradius="220" spawntime="4" killaward="240"/>
<unit type="4" available="3" name="Bazooka" desc="Bazooka. Effective against heavy artillery and aircraft." cost="400" life="150" damage="200" shootspeed="20" speed="0.5" shootradius="260" spawntime="6" killaward="480"/>
<unit type="5" available="5" name="Sniper" desc="Sniper. High range, is only effective against infantry." cost="300" life="150" damage="60" shootspeed="40" speed="0.6" shootradius="260" spawntime="4" killaward="300"/>
<unit type="6" available="1" name="Caterpillar" desc="Caterpillar. Medium damage, medium armor." cost="500" life="250" damage="40" shootspeed="30" speed="0.5" shootradius="220" spawntime="2" killaward="600"/>
<unit type="7" available="6" name="Ladybug" desc="Ladybug. Medium damage, high armor." cost="550" life="300" damage="50" shootspeed="30" speed="0.7" shootradius="220" spawntime="4" killaward="660"/>
<unit type="8" available="8" name="Roach" desc="Roach. Fast, rapid-firing unit. Little damage." cost="500" life="250" damage="20" shootspeed="40" speed="1" shootradius="220" spawntime="5" killaward="600"/>
<unit type="9" available="4" name="Beetle" desc="Beetle. Heavy armor, low speed and a lot of damage." cost="700" life="450" damage="200" shootspeed="20" speed="0.8" shootradius="200" spawntime="6" killaward="840"/>
<unit type="10" available="7" name="Spider" desc="Spider. Easy, but a heavily armed unit" cost="700" life="450" damage="200" shootspeed="20" speed="1" shootradius="220" spawntime="6" killaward="840"/>
<unit type="11" available="9" name="Dragonfly" desc="Dragonfly. Light aircraft, light armor" cost="500" life="200" damage="40" shootspeed="30" speed="1.6" shootradius="250" spawntime="5" killaward="600"/>
<unit type="12" available="10" name="Flying beetle" desc="Flying beetle. Light aircraft, light armor" cost="550" life="250" damage="40" shootspeed="30" speed="1.6" shootradius="250" spawntime="5" killaward="660"/>
<unit type="13" available="12" name="Butterfly" desc="Butterfly. Easy, fast unit with medium damage." cost="600" life="250" damage="50" shootspeed="35" speed="2" shootradius="250" spawntime="5" killaward="720"/>
<unit type="14" available="14" name="Bumblebee" desc="Bumblebee. Heavy aircraft, heavy damage." cost="700" life="400" damage="200" shootspeed="20" speed="2" shootradius="250" spawntime="6" killaward="840"/>
<unit type="15" available="15" name="Fly" desc="Fly. Heavy aircraft, heavy damage." cost="700" life="400" damage="200" shootspeed="20" speed="2" shootradius="250" spawntime="6" killaward="840"/>
<unit type="16" available="13" name="Turret" desc="Automatic turret. Excellent protective unit." cost="1000" life="400" damage="80" shootspeed="30" speed="0" shootradius="300" spawntime="10" killaward="1200"/>
<unit type="17" available="16" name="Turret" desc="Aircraft guns. Effective against heavy units and aviation." cost="1200" life="400" damage="200" shootspeed="15" speed="0" shootradius="300" spawntime="10" killaward="1400"/>
<unit type="18" available="11" name="Repair" desc="Repair. Repairs your base." cost="500" life="100" damage="200" shootspeed="30" speed="0" shootradius="100" spawntime="5" killaward="600"/>
<unit type="19" available="16" name="Minefield" desc="Minefield. Neither unit will not pass through this protection." cost="1000" life="1" damage="3000" shootspeed="1" speed="0" shootradius="100" spawntime="15" killaward="1200"/>
<unit type="20" available="16" name="Kamikaze" desc="Crowds bugs bombers, destroying everything in its path." cost="1000" life="1000" damage="200" shootspeed="1" speed="1" shootradius="250" spawntime="30" killaward="14"/>
</units>
);
}
public function loadXMLs():void{
unitsLoader = new URLLoader(new URLRequest(unitsFile));
unitsLoader.addEventListener(Event.COMPLETE, unitsLoaded);
}
public function unitsLoaded(_arg1:Event):void{
if (unitsLoader.data){
unitsXML = XML(unitsLoader.data);
};
}
}
}//package src
Section 79
//avtomat_snd (avtomat_snd)
package {
import flash.media.*;
public dynamic class avtomat_snd extends Sound {
}
}//package
Section 80
//background_mc (background_mc)
package {
import flash.display.*;
public dynamic class background_mc extends MovieClip {
public function background_mc(){
addFrameScript(0, frame1, 19, frame20);
}
function frame1(){
stop();
}
function frame20(){
stop();
}
}
}//package
Section 81
//baselifebar_mc (baselifebar_mc)
package {
import flash.display.*;
public dynamic class baselifebar_mc extends MovieClip {
}
}//package
Section 82
//baseup_mc (baseup_mc)
package {
import flash.display.*;
public dynamic class baseup_mc extends MovieClip {
}
}//package
Section 83
//battle_snd (battle_snd)
package {
import flash.media.*;
public dynamic class battle_snd extends Sound {
}
}//package
Section 84
//blocking_snd (blocking_snd)
package {
import flash.media.*;
public dynamic class blocking_snd extends Sound {
}
}//package
Section 85
//bullet_mc (bullet_mc)
package {
import src.*;
public dynamic class bullet_mc extends CBullet {
public function bullet_mc(){
addFrameScript(1, frame2);
}
function frame2(){
stop();
removeMe = true;
}
}
}//package
Section 86
//confirmwindow_mc (confirmwindow_mc)
package {
import flash.display.*;
public dynamic class confirmwindow_mc extends MovieClip {
public var yesB:SimpleButton;
public var noB:SimpleButton;
}
}//package
Section 87
//enemyBase_mc (enemyBase_mc)
package {
import src.*;
public dynamic class enemyBase_mc extends CBase {
}
}//package
Section 88
//explosion_snd (explosion_snd)
package {
import flash.media.*;
public dynamic class explosion_snd extends Sound {
}
}//package
Section 89
//galka_mc (galka_mc)
package {
import flash.display.*;
public dynamic class galka_mc extends MovieClip {
}
}//package
Section 90
//intro (intro)
package {
import flash.media.*;
public dynamic class intro extends Sound {
}
}//package
Section 91
//levelwin_mc (levelwin_mc)
package {
import flash.display.*;
import flash.text.*;
public dynamic class levelwin_mc extends MovieClip {
public var txtKilledP:TextField;
public var nextLevelButton:SimpleButton;
public var txtLostP:TextField;
public var txtKilledE:TextField;
public var txtLostE:TextField;
public var txtCaption:TextField;
public var adBox:MovieClip;
public var txtCreatedE:TextField;
public var txtCreatedP:TextField;
}
}//package
Section 92
//levelwin_snd (levelwin_snd)
package {
import flash.media.*;
public dynamic class levelwin_snd extends Sound {
}
}//package
Section 93
//machine_gun (machine_gun)
package {
import flash.media.*;
public dynamic class machine_gun extends Sound {
}
}//package
Section 94
//menu_snd (menu_snd)
package {
import flash.media.*;
public dynamic class menu_snd extends Sound {
}
}//package
Section 95
//miniuniticon_mc (miniuniticon_mc)
package {
import flash.display.*;
public dynamic class miniuniticon_mc extends MovieClip {
}
}//package
Section 96
//pistol_snd (pistol_snd)
package {
import flash.media.*;
public dynamic class pistol_snd extends Sound {
}
}//package
Section 97
//playerBase_mc (playerBase_mc)
package {
import src.*;
public dynamic class playerBase_mc extends CBase {
}
}//package
Section 98
//restart_mc (restart_mc)
package {
import flash.display.*;
public dynamic class restart_mc extends MovieClip {
}
}//package
Section 99
//rocket_gun (rocket_gun)
package {
import flash.media.*;
public dynamic class rocket_gun extends Sound {
}
}//package
Section 100
//spawnpoints_mc (spawnpoints_mc)
package {
import flash.display.*;
public dynamic class spawnpoints_mc extends MovieClip {
public var sp2:MovieClip;
public var sp3:MovieClip;
public var sp4:MovieClip;
public var sp1:MovieClip;
public var sp5:MovieClip;
public var sp6:MovieClip;
}
}//package
Section 101
//unit_body_mc (unit_body_mc)
package {
import flash.display.*;
public dynamic class unit_body_mc extends MovieClip {
public var body:MovieClip;
}
}//package
Section 102
//unit_gun_enemy_mc (unit_gun_enemy_mc)
package {
import flash.display.*;
public dynamic class unit_gun_enemy_mc extends MovieClip {
public var gun:MovieClip;
}
}//package
Section 103
//unit_gun_mc (unit_gun_mc)
package {
import flash.display.*;
public dynamic class unit_gun_mc extends MovieClip {
public var gun:MovieClip;
}
}//package
Section 104
//urlLock_mc (urlLock_mc)
package {
import flash.display.*;
public dynamic class urlLock_mc extends MovieClip {
}
}//package
Section 105
//zamok_mc (zamok_mc)
package {
import flash.display.*;
public dynamic class zamok_mc extends MovieClip {
}
}//package