STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
228088
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2561 · P5121

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/48630483?noj=FRM48630483-3DC" width="1" height="1"></div>

hexcelle.swf

This is the info page for
Flash #137608

(Click the ID number above for more basic data on this flash file.)


Text
loading hexcelle

<p align="center"><font face="Verdana" size="10" color="#000000" letterSpacing="0.000000" kerning="1"><b>000%</b></font></p>

passing sound content...

ActionScript [AS3]

Section 1
//ARGSprite (arg.utils.ARGSprite) package arg.utils { import flash.display.*; import flash.events.*; public class ARGSprite extends Sprite { public var appearing:Boolean;// = false public var disappearing:Boolean;// = false public var disappearSpeed:Number;// = 0.2 public var target:Object; public var appearSpeed:Number;// = 0.2 public static const DISAPPEARED:String = "argsprite_disappeared"; public static const APPEARED:String = "argsprite_appeared"; public function ARGSprite(){ appearSpeed = 0.2; disappearSpeed = 0.2; appearing = false; disappearing = false; super(); } private function appearItem(_arg1:Event):void{ _arg1.target.alpha = (_arg1.target.alpha + ((1 - _arg1.target.alpha) * appearSpeed)); if (_arg1.target.alpha > 0.95){ _arg1.target.alpha = 1; _arg1.target.removeEventListener(Event.ENTER_FRAME, appearItem); appearing = false; _arg1.target.dispatchEvent(new Event(APPEARED)); }; } private function disappearItem(_arg1:Event):void{ _arg1.target.alpha = (_arg1.target.alpha * (1 - disappearSpeed)); if (_arg1.target.alpha < 0.05){ _arg1.target.visible = false; _arg1.target.removeEventListener(Event.ENTER_FRAME, disappearItem); disappearing = false; _arg1.target.dispatchEvent(new Event(DISAPPEARED)); }; } public function kill(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; }; _arg1.addEventListener(DISAPPEARED, remove); _arg1.disappear(); } private function remove(_arg1:Event):void{ if (_arg1.target.parent){ _arg1.target.parent.removeChild(this); }; } public function appear(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; appearing = true; disappearing = false; }; _arg1.visible = true; _arg1.removeEventListener(Event.ENTER_FRAME, appearItem); _arg1.removeEventListener(Event.ENTER_FRAME, disappearItem); _arg1.removeEventListener(DISAPPEARED, remove); _arg1.addEventListener(Event.ENTER_FRAME, appearItem); } public function disappear(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; appearing = false; disappearing = true; }; _arg1.removeEventListener(Event.ENTER_FRAME, appearItem); _arg1.removeEventListener(Event.ENTER_FRAME, disappearItem); _arg1.addEventListener(Event.ENTER_FRAME, disappearItem); } } }//package arg.utils
Section 2
//Tools (arg.utils.Tools) package arg.utils { import flash.display.*; import flash.events.*; import flash.text.*; import flash.system.*; import flash.utils.*; import flash.filters.*; public class Tools { public static var TextFont:String = "MainFont"; public static function addShadow(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=60, _arg4:Number=0.8, _arg5:Number=12, _arg6:Number=12, _arg7:Number=8, _arg8:Number=0.7, _arg9:int=3):void{ _arg1.filters = [new DropShadowFilter(_arg7, _arg3, _arg2, _arg4, _arg5, _arg6, _arg8, _arg9)]; } public static function getBoxSprite():ARGSprite{ var container:ARGSprite; var box:Sprite; var fadeInBox:Function; var fadeOutBox:Function; var draw:Function; var over:Function; var out:Function; var added:Function; container = new ARGSprite(); box = new Sprite(); box.alpha = 0; container.addChild(box); fadeInBox = function (_arg1:Event):void{ if (box.alpha > 0.95){ box.alpha = 1; container.removeEventListener(Event.ENTER_FRAME, fadeInBox); } else { box.alpha = (box.alpha + ((1 - box.alpha) * 0.2)); }; }; fadeOutBox = function (_arg1:Event):void{ if (box.alpha < 0.05){ box.alpha = 0; container.removeEventListener(Event.ENTER_FRAME, fadeOutBox); } else { box.alpha = (box.alpha * 0.8); }; }; draw = function ():void{ container.removeChild(box); container.addChild(box); box.graphics.clear(); box.graphics.lineStyle(3, 0); box.graphics.beginFill(0, 0); box.graphics.drawRect(-5, -5, (container.width + 10), (container.height + 10)); }; over = function (_arg1:MouseEvent):void{ draw(); container.removeEventListener(Event.ENTER_FRAME, fadeOutBox); container.addEventListener(Event.ENTER_FRAME, fadeInBox); }; out = function (_arg1:MouseEvent):void{ container.removeEventListener(Event.ENTER_FRAME, fadeInBox); container.addEventListener(Event.ENTER_FRAME, fadeOutBox); }; added = function (_arg1:Event):void{ draw(); }; container.addEventListener(MouseEvent.MOUSE_OVER, over); container.addEventListener(MouseEvent.MOUSE_OUT, out); container.addEventListener(Event.ADDED_TO_STAGE, added); container.buttonMode = true; return (container); } public static function makeText(_arg1:DisplayObjectContainer, _arg2:String="", _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:uint=0x333333, _arg7:Number=NaN, _arg8:Number=NaN):TextField{ var _local9:*; var _local10:TextFormat; var _local11:Class; _local9 = new TextField(); _local9.name = "txt"; _local9.autoSize = TextFieldAutoSize.LEFT; _local9.selectable = false; _local10 = new TextFormat(); if (ApplicationDomain.currentDomain.hasDefinition(TextFont)){ _local11 = (getDefinitionByName(TextFont) as Class); _local10.font = new (_local11).fontName; _local9.embedFonts = true; } else { trace(("text font not found: " + TextFont)); _local10.font = "Arial"; }; _local10.color = _arg6; _local10.size = _arg5; _local9.defaultTextFormat = _local10; _local9.x = _arg3; _local9.y = _arg4; if (((_arg7) || (_arg8))){ _local9.wordWrap = true; if (_arg7){ _local9.width = _arg7; }; if (_arg8){ _local9.height = _arg8; }; }; _local9.text = _arg2; _arg1.addChild(_local9); return (_local9); } public static function makeInput(_arg1:DisplayObjectContainer, _arg2:String="", _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:Number=NaN, _arg7:Number=NaN, _arg8:Number=NaN):TextField{ var _local9:TextField; _local9 = makeText(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8); _local9.type = TextFieldType.INPUT; _local9.selectable = true; return (_local9); } public static function rotateVEquals(_arg1:Object, _arg2:Number):Object{ var _local3:Object; _local3 = {x:0, y:0}; _local3.x = ((Math.cos(_arg2) * _arg1.x) - (Math.sin(_arg2) * _arg1.y)); _local3.y = ((Math.sin(_arg2) * _arg1.x) + (Math.cos(_arg2) * _arg1.y)); _arg1.x = _local3.x; _arg1.y = _local3.y; return (_arg1); } public static function rotateV(_arg1:Object, _arg2:Number):Object{ var _local3:Object; _local3 = {x:0, y:0}; _local3.x = ((Math.cos(_arg2) * _arg1.x) - (Math.sin(_arg2) * _arg1.y)); _local3.y = ((Math.sin(_arg2) * _arg1.x) + (Math.cos(_arg2) * _arg1.y)); return (_local3); } public static function makeBoxButton(_arg1:DisplayObjectContainer, _arg2:String, _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:uint=0x888888):ARGSprite{ var button:ARGSprite; var tf:TextField; var box:Sprite; var fadeInBox:Function; var fadeOutBox:Function; var buttonOver:Function; var buttonOut:Function; var container = _arg1; var t = _arg2; var posX = _arg3; var posY = _arg4; var size = _arg5; var color = _arg6; button = new ARGSprite(); button.buttonMode = true; button.mouseChildren = false; container.addChild(button); button.x = posX; button.y = posY; tf = makeText(button, t, 0, 0, size, color); box = new Sprite(); button.addChild(box); box.graphics.lineStyle(3, color); box.graphics.beginFill(0, 0); box.graphics.drawRect(-5, -5, (tf.width + 10), (tf.height + 10)); box.alpha = 0; fadeInBox = function (_arg1:Event):void{ if (box.alpha > 0.95){ box.alpha = 1; button.removeEventListener(Event.ENTER_FRAME, fadeInBox); } else { box.alpha = (box.alpha + ((1 - box.alpha) * 0.2)); }; }; fadeOutBox = function (_arg1:Event):void{ if (box.alpha < 0.05){ box.alpha = 0; button.removeEventListener(Event.ENTER_FRAME, fadeOutBox); } else { box.alpha = (box.alpha * 0.8); }; }; buttonOver = function (_arg1:MouseEvent):void{ button.removeEventListener(Event.ENTER_FRAME, fadeOutBox); button.addEventListener(Event.ENTER_FRAME, fadeInBox); }; buttonOut = function (_arg1:MouseEvent):void{ button.removeEventListener(Event.ENTER_FRAME, fadeInBox); button.addEventListener(Event.ENTER_FRAME, fadeOutBox); }; button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); return (button); } } }//package arg.utils
Section 3
//ARGLogo (arg.ARGLogo) package arg { import flash.events.*; import arg.utils.*; public class ARGLogo extends ARGSprite { private var _spacing:Number;// = 15 private var _counter:int; private var _letters:Array; private var _init:Boolean;// = false private var _w:Number;// = 0 public function ARGLogo():void{ _init = false; _letters = ["A", "d", "a", "m", " ", "R", " ", "G", "i", "m", "p", "e", "r", "t"]; _spacing = 15; _w = 0; super(); appearSpeed = 0.05; alpha = 0; visible = false; } private function init():void{ var _local1:*; var _local2:ARGSprite; var _local3:ARGSprite; if (_init){ return; }; _init = true; Tools.makeText(this, "a game by", ((stage.stageWidth / 2) - 150), ((stage.stageHeight / 2) - 25), 12, 0x888888); for each (_local1 in _letters) { _local2 = new ARGSprite(); Tools.makeText(_local2, _local1, 0, 0, 14, 0x333333); addChildAt(_local2, 0); _local3 = new ARGSprite(); Tools.makeText(_local3, _local1, 0, 0, 14, 0xFF3300); addChild(_local3); _letters[_letters.indexOf(_local1)] = {letter:_local1, sprite:_local3, shadow:_local2}; _w = (_w + _spacing); }; graphics.lineStyle(0, 0, 0); graphics.beginFill(0, 1); graphics.drawRect(0, 0, 650, 500); graphics.lineStyle(1, 0x222222); graphics.moveTo(((stage.stageWidth / 2) - 200), ((stage.stageHeight / 2) + 16)); graphics.lineTo(((stage.stageWidth / 2) + 200), ((stage.stageHeight / 2) + 16)); x = (x - (stage.stageWidth * 0.1)); _counter = 0; } private function draw(_arg1:Number, _arg2:Number):void{ var _local3:Number; var _local4:int; var _local5:Number; _local3 = ((stage.stageWidth / 2) - (_w / 2)); _local4 = 0; while (_local4 < _letters.length) { _local5 = Math.sqrt((Math.pow((_arg1 - _letters[_local4].sprite.x), 2) + Math.pow((_arg2 - _letters[_local4].sprite.y), 2))); _local5 = (1 - Math.min(1, (_local5 / 120))); _letters[_local4].shadow.scaleY = (-(_letters[_local4].sprite.scaleX) - (_local5 * 2)); _letters[_local4].sprite.x = (_local3 - (_spacing / 2)); _letters[_local4].sprite.y = ((stage.stageHeight / 2) - (5 * _local5)); _letters[_local4].shadow.x = (_local3 - (_spacing / 2)); _letters[_local4].shadow.y = (((stage.stageHeight / 2) + (_local5 * 40)) + 34); _local3 = (_local3 + _letters[_local4].sprite.width); updateShadow(_letters[_local4].shadow, _local5); _local4++; }; } private function updateShadow(_arg1:ARGSprite, _arg2:Number):void{ Tools.addShadow(_arg1, 0x333333, 60, 1, (8 * _arg2), (8 * _arg2), 0, (1 + _arg2), 3); _arg1.alpha = (1 - (0.5 * _arg2)); } override public function appear(_arg1:Object=null):void{ super.appear(_arg1); init(); stage.addEventListener(Event.ENTER_FRAME, update); } override public function disappear(_arg1:Object=null):void{ super.disappear(_arg1); if (_init){ addEventListener(ARGSprite.DISAPPEARED, cleanUp); }; } private function update(_arg1:Event):void{ draw(((stage.stageWidth * 0.1) + ((Math.random() * stage.stageWidth) * 0.8)), ((stage.stageHeight * 0.1) + ((Math.random() * stage.stageHeight) * 0.8))); if (_counter == (stage.frameRate * 3)){ disappear(); } else { if (alpha > 0.9){ _counter++; }; }; } private function cleanUp(_arg1:Event):void{ stage.removeEventListener(Event.ENTER_FRAME, update); while (numChildren > 0) { removeChildAt(0); }; _init = false; removeEventListener(ARGSprite.DISAPPEARED, cleanUp); dispatchEvent(new Event(Event.COMPLETE)); } } }//package arg
Section 4
//Area (hexcelle.Area) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; public class Area { private var _player:Player; private var _container:Sprite; public var size:Number; public var maxSkill:Number; public var faunaCount:int; public var type:String; public var bgColor:uint; public var minSkill:Number; public var othersCount:int; public var x:Number; public var y:Number; private var _content:Sprite; public function Area(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Sprite, _arg5:Player){ this.x = _arg1; this.y = _arg2; this.size = _arg3; _container = _arg4; _content = new Sprite(); _content.name = "area sprite"; _content.visible = false; _player = _arg5; minSkill = (Math.pow(steps, 1.5) * 0.05); maxSkill = (((Math.pow(steps, 1.15) * 0.1) + 0.1) * 2); othersCount = Math.ceil((Math.random() * Math.min(((steps / 2) + 1), 4))); minSkill = (minSkill / othersCount); maxSkill = (maxSkill / othersCount); faunaCount = Math.max((30 - steps), 0); bgColor = 0x333333; type = "normal"; } public function fade():void{ _content.removeEventListener(Event.ENTER_FRAME, fadeIn); _content.removeEventListener(Event.ENTER_FRAME, fadeOut); _content.addEventListener(Event.ENTER_FRAME, fadeOut); } private function fadeOut(_arg1:Event):void{ _content.alpha = (_content.alpha * 0.9); if (_content.alpha < 0.25){ _content.alpha = 0.25; _content.removeEventListener(Event.ENTER_FRAME, fadeOut); }; } public function update(_arg1:Vector):void{ _content.x = ((x - _arg1.x) + _player.centerX); _content.y = ((y - _arg1.y) + _player.centerY); } public function remove():void{ if (_content.parent){ _container.removeChild(_content); }; } public function get visible():Boolean{ return (_content.visible); } private function fadeIn(_arg1:Event):void{ _content.alpha = (_content.alpha + ((1 - _content.alpha) * 0.2)); if (_content.alpha > 0.9){ _content.alpha = 1; _content.removeEventListener(Event.ENTER_FRAME, fadeIn); }; } public function unhide():void{ _content.removeEventListener(Event.ENTER_FRAME, fadeIn); _content.removeEventListener(Event.ENTER_FRAME, fadeOut); _content.visible = true; } private function draw():void{ _content.graphics.clear(); _content.graphics.lineStyle(2, 0x999999); _content.graphics.beginFill(bgColor); _content.graphics.drawCircle(0, 0, size); } public function reload():void{ _content.removeEventListener(Event.ENTER_FRAME, fadeIn); _content.removeEventListener(Event.ENTER_FRAME, fadeOut); draw(); _content.alpha = 0.25; _content.visible = true; if (!_content.parent){ _container.addChildAt(_content, 0); }; update(new Vector(0, 0)); } public function hide():void{ _content.removeEventListener(Event.ENTER_FRAME, fadeIn); _content.removeEventListener(Event.ENTER_FRAME, fadeOut); _content.visible = false; } public function get alpha():Number{ return (_content.alpha); } public function get steps():int{ return ((location.magnitude() / (size * 2))); } public function set visible(_arg1:Boolean):void{ _content.visible = _arg1; } public function get location():Vector{ return (new Vector(x, y)); } public function show():void{ _content.removeEventListener(Event.ENTER_FRAME, fadeIn); _content.removeEventListener(Event.ENTER_FRAME, fadeOut); if (_content.visible){ _content.addEventListener(Event.ENTER_FRAME, fadeOut); return; }; _content.alpha = 0; _content.visible = true; draw(); if (!_content.parent){ _container.addChildAt(_content, 0); }; _content.addEventListener(Event.ENTER_FRAME, fadeIn); } } }//package hexcelle
Section 5
//Areas (hexcelle.Areas) package hexcelle { import flash.display.*; import org.cove.ape.*; public class Areas extends Sprite { private var _player:Player; private var _lastNewArea:Area; private var _homeArea:Area; private var _areas:Array; private var _checkpointRadius:Sprite; private var _areaSize:Number; private var _background:BGs; private var _mapAreaSize:Number; private var _currentArea:Area; private var _p:Vector; public function Areas(_arg1:Player, _arg2:Number=650){ _areaSize = (_arg2 / 2); _areas = new Array([new Area(0, 0, _areaSize, this, _arg1)]); _p = new Vector(0, 0); _currentArea = _areas[_p.x][_p.y]; _lastNewArea = _currentArea; _homeArea = _currentArea; _currentArea.show(); _background = new BGs(_arg1, 40); addChild(_background); _player = _arg1; _mapAreaSize = 10; name = "areas sprite"; _checkpointRadius = new Sprite(); addChild(_checkpointRadius); drawCheckpoint(); } private function getAreaCoords(_arg1:Area):Vector{ var _local2:Vector; var _local3:*; var _local4:*; _local2 = new Vector(); for each (_local3 in _areas) { for each (_local4 in _local3) { if (_local4 == _arg1){ _local2.x = _areas.indexOf(_local3); _local2.y = _local3.indexOf(_local4); return (_local2); }; }; }; return (null); } public function drawCheckpoint():void{ var r:Number; r = (_player.checkDistance * (1 + _player.checkpoints)); var _local2 = _checkpointRadius.graphics; with (_local2) { clear(); lineStyle(1, 16750882, 0.5); endFill(); drawCircle(0, 0, r); lineStyle(1, 16750882, 0.35); drawCircle(0, 0, (r + 4)); lineStyle(1, 16750882, 0.2); drawCircle(0, 0, (r + 6)); }; } public function get count():int{ var _local1:int; var _local2:*; var _local3:*; _local1 = 0; for each (_local2 in _areas) { for each (_local3 in _local2) { if (_local3){ _local1++; }; }; }; return (_local1); } public function getSaveArray():Array{ var _local1:Array; var _local2:Vector; var _local3:Vector; var _local4:Array; var _local5:int; var _local6:Array; var _local7:Array; var _local8:int; var _local9:Array; var _local10:Area; _local1 = new Array(); _local2 = getAreaCoords(_homeArea); _local1.push([_local2.x, _local2.y]); _local3 = getAreaCoords(_lastNewArea); _local1.push([_local3.x, _local3.y]); _local4 = new Array(); _local5 = 0; while (_local5 < _areas.length) { _local6 = new Array(); _local7 = _areas[_local5]; _local8 = 0; while (_local8 < _local7.length) { _local9 = new Array(); _local10 = _local7[_local8]; if (_local10){ _local9.push(_local10.x, _local10.y, _local10.size, _local10.othersCount, _local10.minSkill, _local10.maxSkill, _local10.faunaCount, _local10.bgColor, _local10.type); }; _local6.push(_local9); _local8++; }; _local4.push(_local6); _local5++; }; _local1.push(_local4); return (_local1); } public function get minSkill():Number{ return (_currentArea.minSkill); } public function get steps():int{ return (_currentArea.steps); } public function traceAreas():void{ var _local1:int; var _local2:int; _local1 = 0; while (_local1 < _areas.length) { trace(("column " + _local1)); _local2 = 0; while (_local2 < _areas[_local1].length) { trace((((" row " + _local2) + ": ") + _areas[_local1][_local2])); _local2++; }; _local1++; }; } public function get bg():BGs{ return (_background); } public function translate(_arg1:Vector):void{ _background.translate(_arg1); } public function reset():void{ var _local1:int; var _local2:int; _local1 = 0; while (_local1 < _areas.length) { _local2 = 0; while (_local2 < _areas[_local1].length) { if (_areas[_local1][_local2]){ _areas[_local1][_local2].remove(); }; _local2++; }; _local1++; }; _areas = new Array([new Area(0, 0, _areaSize, this, _player)]); _p = new Vector(0, 0); _currentArea = _areas[_p.x][_p.y]; _lastNewArea = _currentArea; _homeArea = _currentArea; _currentArea.show(); } public function clear():void{ _lastNewArea.fade(); _player.onAreaClear(_lastNewArea); } public function get othersCount():int{ return (_currentArea.othersCount); } public function drawMap(_arg1:Sprite):void{ var i:*; var j:*; var map = _arg1; var _local3 = map.graphics; with (_local3) { clear(); i = 0; while (i < _areas.length) { j = 0; while (j < _areas[i].length) { if (_areas[i][j]){ if (_areas[i][j] == _currentArea){ lineStyle(1, 0x8800); beginFill(12320699, 0.8); } else { if (_areas[i][j] == _homeArea){ lineStyle(2, 136); beginFill(12303359, 0.8); } else { if (_areas[i][j].type == "boss"){ lineStyle(2, 0x880000); beginFill(6697779, 0.8); } else { if (_areas[i][j] == _lastNewArea){ lineStyle(2, 0x888800); beginFill(16777147, 0.8); } else { lineStyle(2, 0xFFFFFF); beginFill(0xBBBBBB, 0.5); }; }; }; }; drawCircle(((i * _mapAreaSize) * 2), ((j * _mapAreaSize) * 2), _mapAreaSize); }; j++; }; i++; }; }; } public function get maxSkill():Number{ return (_currentArea.maxSkill); } private function updateVisibilities(_arg1:Boolean=true):void{ var _local2:int; var _local3:int; _local2 = 0; while (_local2 < _areas.length) { _local3 = 0; while (_local3 < _areas[_local2].length) { if (_areas[_local2][_local3]){ if (!(((((((_local2 >= (_p.x - 1))) && ((_local2 <= (_p.x + 1))))) && ((_local3 >= (_p.y - 1))))) && ((_local3 <= (_p.y + 1))))){ _areas[_local2][_local3].hide(); } else { if (_currentArea != _areas[_local2][_local3]){ _areas[_local2][_local3].visible = true; } else { if (_arg1){ _currentArea.show(); }; }; }; }; _local3++; }; _local2++; }; } public function loadInfo(_arg1:Array):void{ var _local2:int; var _local3:int; var _local4:Array; var _local5:Array; var _local6:Area; _local2 = 0; while (_local2 < _areas.length) { _local3 = 0; while (_local3 < _areas[_local2].length) { if (_areas[_local2][_local3]){ _areas[_local2][_local3].remove(); }; _local3++; }; _local2++; }; _local4 = _arg1[2]; _areas = new Array(_local4.length); _local2 = 0; while (_local2 < _areas.length) { _areas[_local2] = new Array(_local4[0].length); _local2++; }; _local2 = 0; while (_local2 < _local4.length) { _local3 = 0; while (_local3 < _local4[_local2].length) { _local5 = _local4[_local2][_local3]; if (_local5.length == 0){ } else { _local6 = new Area(0, 0, _areaSize, this, _player); _local6.x = _local5[0]; _local6.y = _local5[1]; _local6.size = _local5[2]; _local6.othersCount = _local5[3]; _local6.minSkill = _local5[4]; _local6.maxSkill = _local5[5]; _local6.faunaCount = _local5[6]; _local6.bgColor = _local5[7]; _local6.type = _local5[8]; _local6.reload(); _areas[_local2][_local3] = _local6; }; _local3++; }; _local2++; }; _p = new Vector(_arg1[0][0], _arg1[0][1]); _currentArea = _areas[_p.x][_p.y]; _homeArea = _currentArea; _lastNewArea = _areas[_arg1[1][0]][_arg1[1][1]]; updateVisibilities(); } public function get faunaCount():int{ return (_currentArea.faunaCount); } public function update(_arg1:Vector):void{ var check:Function; var location = _arg1; _background.update(); _currentArea.update(location); check = function (_arg1:int, _arg2:int):void{ if ((((((((_arg1 < 0)) || ((_arg1 >= _areas.length)))) || ((_arg2 < 0)))) || ((_arg2 >= _areas[0].length)))){ return; }; if (_areas[_arg1][_arg2]){ _areas[_arg1][_arg2].update(location); }; }; check((_p.x - 1), (_p.y - 1)); check(_p.x, (_p.y - 1)); check((_p.x + 1), (_p.y - 1)); check((_p.x - 1), _p.y); check((_p.x + 1), _p.y); check((_p.x - 1), (_p.y + 1)); check(_p.x, (_p.y + 1)); check((_p.x + 1), (_p.y + 1)); checkLocation(location); _checkpointRadius.x = (-(location.x) + _player.centerX); _checkpointRadius.y = (-(location.y) + _player.centerY); } public function updateMap(_arg1:Sprite, _arg2:Vector):void{ var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; _local3 = (_arg2.x % (_areaSize * 2)); _local4 = Math.abs(_local3); if (_local4 > _areaSize){ _local4 = ((2 * _areaSize) - _local4); }; if ((((((_local3 > 0)) && ((_local3 < _areaSize)))) || ((_local3 < -(_areaSize))))){ _local4 = (_local4 * -1); }; _local4 = (_local4 * (_mapAreaSize / _areaSize)); _local5 = (_arg2.y % (_areaSize * 2)); _local6 = Math.abs(_local5); if (_local6 > _areaSize){ _local6 = ((2 * _areaSize) - _local6); }; if ((((((_local5 > 0)) && ((_local5 < _areaSize)))) || ((_local5 < -(_areaSize))))){ _local6 = (_local6 * -1); }; _local6 = (_local6 * (_mapAreaSize / _areaSize)); _arg1.x = ((_player.centerX - ((2 * _p.x) * _mapAreaSize)) + _local4); _arg1.y = ((_player.centerY - ((2 * _p.y) * _mapAreaSize)) + _local6); } public function checkLocation(_arg1:Vector):void{ var _local2:int; var _local3:int; var _local4:Area; var _local5:Area; var _local6:Array; _local2 = 0; _local3 = 0; if (_arg1.x > (_currentArea.x + _currentArea.size)){ _local2 = 1; } else { if (_arg1.x < (_currentArea.x - _currentArea.size)){ _local2 = -1; } else { if (_arg1.y > (_currentArea.y + _currentArea.size)){ _local3 = 1; } else { if (_arg1.y < (_currentArea.y - _currentArea.size)){ _local3 = -1; } else { return; }; }; }; }; if ((_p.x + _local2) == _areas.length){ _areas.push(new Array(_areas[0].length)); } else { if ((_p.x + _local2) == -1){ _areas.unshift(new Array(_areas[0].length)); _p.x++; } else { if ((_p.y + _local3) == _areas[0].length){ for each (_local6 in _areas) { _local6.push(null); }; } else { if ((_p.y + _local3) == -1){ for each (_local6 in _areas) { _local6.unshift(null); }; _p.y++; }; }; }; }; _local5 = _areas[(_p.x + _local2)][(_p.y + _local3)]; if (_local5){ _currentArea = _local5; } else { _local4 = new Area((_currentArea.x + ((_currentArea.size * 2) * _local2)), (_currentArea.y + ((_currentArea.size * 2) * _local3)), _currentArea.size, this, _player); }; if (_local4){ _areas[(_p.x + _local2)][(_p.y + _local3)] = _local4; _currentArea = _local4; _lastNewArea.fade(); _lastNewArea = _local4; _player.onNewArea(_currentArea); } else { _player.onArea(_currentArea); }; _p.x = (_p.x + _local2); _p.y = (_p.y + _local3); updateVisibilities(!((_local4 == null))); if (_player.fxNo > 1){ _background.BGCount = 40; } else { if (_player.fxNo > 0){ _background.BGCount = 30; } else { _background.BGCount = 20; }; }; } } }//package hexcelle
Section 6
//ARGSprite (hexcelle.ARGSprite) package hexcelle { import flash.display.*; import flash.events.*; public class ARGSprite extends Sprite { public var disappearSpeed:Number;// = 0.2 public var appearSpeed:Number;// = 0.2 public static const DISAPPEARED:String = "argsprite_disappeared"; public static const APPEARED:String = "argsprite_appeared"; public function ARGSprite(){ appearSpeed = 0.2; disappearSpeed = 0.2; super(); } private function appearItem(_arg1:Event):void{ _arg1.target.alpha = (_arg1.target.alpha + ((1 - _arg1.target.alpha) * appearSpeed)); if (_arg1.target.alpha > 0.95){ _arg1.target.alpha = 1; _arg1.target.removeEventListener(Event.ENTER_FRAME, appearItem); _arg1.target.dispatchEvent(new Event(APPEARED)); }; } private function disappearItem(_arg1:Event):void{ _arg1.target.alpha = (_arg1.target.alpha * (1 - disappearSpeed)); if (_arg1.target.alpha < 0.05){ _arg1.target.visible = false; _arg1.target.removeEventListener(Event.ENTER_FRAME, disappearItem); _arg1.target.dispatchEvent(new Event(DISAPPEARED)); }; } public function kill(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; }; _arg1.addEventListener(DISAPPEARED, remove); _arg1.disappear(); } private function remove(_arg1:Event):void{ if (_arg1.target.parent){ _arg1.target.parent.removeChild(this); }; } public function appear(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; }; _arg1.visible = true; _arg1.removeEventListener(Event.ENTER_FRAME, appearItem); _arg1.removeEventListener(Event.ENTER_FRAME, disappearItem); _arg1.removeEventListener(DISAPPEARED, remove); _arg1.addEventListener(Event.ENTER_FRAME, appearItem); } public function disappear(_arg1:Object=null):void{ if (!_arg1){ _arg1 = this; }; _arg1.removeEventListener(Event.ENTER_FRAME, appearItem); _arg1.removeEventListener(Event.ENTER_FRAME, disappearItem); _arg1.addEventListener(Event.ENTER_FRAME, disappearItem); } } }//package hexcelle
Section 7
//Batch (hexcelle.Batch) package hexcelle { import org.cove.ape.*; public class Batch { private var _bombRate:Number; private var _bombPower:Number; private var _bombProximity:Number; private var _bombSeekTime:Number; private var _bombCount:int; private var _missilePropel:Number; private var _lastFrameShot:uint; private var _missileBurnIn:Number; private var _bombGrowTime:int; private var _bombSize:Number; private var _missileSeekThrust:Number; public var type:String; private var _batch:Array; private var _missileFuel:Number; private var _bombArmor:Number; private var _bombShotPropel:int; private var _bombShotBurnIn:Number; private var _bombSeekThrust:Number; private var _skill:Number; private var _missilePower:Number; private var _bombInterval:int; private var _missileRate:Number; private var _regeneration:Number; private var _bombShotSeekThrust:Number; private var _missileSeekTime:Number; private var _missileSeekRadius:Number; private var _thrust:Number; private var _bombShotFuel:int; private var _regenerationRate:int; private var _missileGrowTime:int; private var _missileSize:Number; private var _bombSeekRadius:Number; private var _missileGrowth:Number; private var _bombShotRate:Number; private var _bombShotSeekTime:Number; private var _speedHexes:int; private var _bombShotSeekRadius:Number; private var _bombGrowth:Number; private var _lastFrameDropped:uint; private var _bombShotSize:Number; private var _hasMissile:Boolean; private var _minThrust:Number; private var _antithrust:Number; private var _pool:DNA; private var _noSpeedThrust:Number; public function Batch(){ _batch = new Array(); _lastFrameShot = 0; _lastFrameDropped = 0; } public function push(_arg1:Hex):void{ _batch.push(_arg1); } public function prep(_arg1:Celle, _arg2:Boolean=true, _arg3:Boolean=false):void{ var _local4:Hex; var _local5:Hex; var _local6:int; var _local7:String; var _local8:Number; if (_arg1.hexSize < 3){ trace("warning: very small hex size for batch prep"); }; _pool = new DNA(); for each (_local4 in _batch) { _pool.add(_local4.pool); }; if (_arg3){ _local7 = (type + ": "); for each (_local4 in _batch) { _local7 = (_local7 + (DNA.getIndexName(_local4.type) + ", ")); }; _local7 = _local7.substr(0, (_local7.length - 2)); _local7 = (_local7 + " _ "); _local6 = 0; while (_local6 < 6) { _local7 = (_local7 + (((DNA.getIndexName(_local6) + ": ") + _pool.getByIndex(_local6)) + ", ")); _local6++; }; _local7 = _local7.substr(0, (_local7.length - 2)); trace(_local7); }; if (_arg2){ _local6 = getTypeCount(DNA.ARMOR); if (_local6 > 0){ _arg1.toggleAll(false); for each (_local4 in _batch) { _local4.armor = Math.max(_pool.armor, (_local4.armor + 1)); if (type == "line"){ for each (_local5 in _local4.links) { if (((((_local5) && ((_batch.indexOf(_local5) < 0)))) && (!(_local5.toggle)))){ _local5.armor = (_local5.armor + _pool.armor); _local5.toggle = true; }; }; }; }; } else { for each (_local4 in _batch) { _local4.armor = (_local4.armor + _local4.pool.armor); }; }; }; _regenerationRate = 30; if ((((getTypeCount(DNA.ARMOR) > 0)) && ((_pool.tech > 0)))){ _regeneration = (_pool.tech / 30); _regenerationRate = (_regenerationRate - (_pool.speed * 2)); if (_regenerationRate < 1){ _regenerationRate = 1; }; } else { _regeneration = 0; }; _local6 = getTypeCount(DNA.BOMB); _bombCount = _local6; if ((((_bombCount > 0)) && ((type == "cluster")))){ _bombCount = 1; }; if (type == "cluster"){ _bombPower = (_local6 + 9); _bombSize = (_local6 + 3); } else { _bombPower = _local6; _bombSize = (_local6 - 1); }; _bombArmor = 0; if (getTypeCount(DNA.BOMB) > 0){ _bombArmor = (_bombArmor + _pool.armor); }; _bombGrowth = 0; if (getTypeCount(DNA.BOMB) > 0){ _bombGrowth = (_pool.grow / 60); _bombGrowTime = (Math.ceil((_pool.grow / 5)) * 30); }; if ((((_bombGrowth > 0)) && ((_pool.speed > 0)))){ _local8 = (_pool.speed / 60); _bombGrowth = (_bombGrowth + _local8); _bombGrowTime = (_bombGrowTime - ((_bombGrowTime * _local8) / _bombGrowth)); _bombGrowTime = (_bombGrowTime + (_pool.speed * 2)); }; _bombShotSize = 0; _bombShotRate = 90; _bombShotFuel = 0; _bombShotPropel = 0; if ((((((getTypeCount(DNA.BOMB) > 0)) && ((_pool.missile > 0)))) && ((type == "cluster")))){ _bombShotSize = _pool.missile; _bombShotFuel = (30 + _pool.missile); _bombShotPropel = (2.5 + _pool.missile); }; if (getTypeCount(DNA.BOMB) > 0){ _bombShotRate = (_bombShotRate - Math.floor((_pool.speed * 1.5))); if (_bombShotRate < 5){ _bombShotRate = 5; }; }; _bombShotSeekRadius = 0; _bombShotSeekTime = 0; _bombShotSeekThrust = 0; if ((((((getTypeCount(DNA.BOMB) > 0)) && ((_pool.missile > 0)))) && ((_pool.tech > 0)))){ _bombShotSeekRadius = (_bombSize + (_pool.tech * 2)); _bombShotSeekTime = (30 + (_pool.tech * 3)); _bombShotSeekThrust = _pool.tech; }; _bombShotBurnIn = 0; if (getTypeCount(DNA.BOMB) > 0){ if (_pool.speed > 0){ _bombShotBurnIn = (1 + (_pool.tech * 0.01)); }; }; _bombRate = 30; if ((((getTypeCount(DNA.BOMB) > 0)) && ((_pool.speed > 0)))){ _bombRate = ((30 - (_pool.speed * 5)) + (_bombSize * _bombSize)); if (_bombRate < 5){ _bombRate = 5; }; }; _bombProximity = 0; if ((((getTypeCount(DNA.BOMB) > 0)) && ((_pool.tech > 0)))){ _bombProximity = (((_pool.tech * _arg1.hexSize) / 2) + _bombSize); }; _bombSeekRadius = 0; _bombSeekTime = 0; _bombSeekThrust = 0; if ((((((((getTypeCount(DNA.BOMB) > 0)) && ((_pool.tech > 2)))) && ((type == "cluster")))) && ((_pool.speed > 0)))){ _bombSeekRadius = (_bombProximity * 1.5); _bombSeekTime = ((20 + (_pool.tech * 3)) + _pool.speed); _bombSeekThrust = ((_pool.tech + _pool.speed) / 2); }; if (_bombRate < _bombCount){ _bombRate = _bombCount; }; _bombInterval = 5; if ((_bombRate / _bombCount) < _bombInterval){ _bombInterval = Math.floor((_bombRate / _bombCount)); }; _local6 = getTypeCount(DNA.MISSILE); _hasMissile = (_local6 > 0); if (_hasMissile){ _missileSize = (_local6 + 1); _missilePropel = ((40 / _local6) + (_local6 / 2)); _missileFuel = (_local6 * 3); _missilePower = (5 + _local6); _missileBurnIn = 1; _missileRate = 30; } else { _missileSize = 0; _missilePropel = 0; _missileFuel = 0; _missileRate = 0; _missilePower = 0; _missileBurnIn = 0; }; _missileGrowth = 0; _missileGrowTime = 0; if (((_hasMissile) && ((_pool.grow > 1)))){ _missileGrowth = (_pool.grow / 120); _missileGrowTime = ((_pool.grow * 2) + 50); }; if (((((_hasMissile) && ((_missileGrowth > 0)))) && ((_pool.speed > 0)))){ _missileGrowth = (_missileGrowth + (_pool.speed / 100)); }; if (((_hasMissile) && ((_pool.speed > 0)))){ _missileRate = (((30 - (_pool.speed * 4)) + Math.round(Math.pow(_missileSize, 2.3))) + _pool.grow); if (_missileRate < 5){ _missileRate = 5; }; }; if (((((_hasMissile) && ((_pool.speed > 0)))) && ((_pool.tech > 0)))){ _missileBurnIn = (((_pool.speed + (_pool.tech * 3)) * 0.01) + 1); _missilePropel = (_missilePropel + ((_pool.speed + (_pool.tech * 2)) / 15)); }; _missileSeekRadius = 0; _missileSeekTime = 0; _missileSeekThrust = 0; if (((_hasMissile) && ((_pool.tech > 2)))){ _missileSeekRadius = (_missileSize + (_pool.tech * 2)); _missileSeekTime = (30 + (_pool.tech * 3)); _missileSeekThrust = _pool.tech; }; _noSpeedThrust = (0.5 * _batch.length); _local6 = getTypeCount(DNA.SPEED); _speedHexes = _local6; _minThrust = 2; _thrust = _minThrust; _thrust = (_thrust + ((_local6)<6) ? ((_local6 * _local6) * (6 - _local6)) : (_local6 * _local6)); if (type == "line"){ _thrust = (_thrust + _local6); } else { _thrust = (_thrust - _local6); }; _antithrust = ((getTypeCount(DNA.SPEED))>0) ? ((_pool.tech / 1.9) * _thrust) : 0; if (_arg1.hexCount > 2){ if (_arg1.core.type == DNA.ARMOR){ for each (_local4 in _batch) { _local4.armor = (_local4.armor + 0.5); _local4.mass = (_local4.mass + 0.1); }; } else { if (_arg1.core.type == DNA.BOMB){ _bombPower = (_bombPower + 3); _bombSize = (_bombSize + 2); } else { if (_arg1.core.type == DNA.GROW){ if (_bombGrowTime > 0){ _bombGrowTime = (_bombGrowTime + 10); }; if (_missileGrowTime > 0){ _missileGrowTime = (_missileGrowTime + 10); }; } else { if ((((_arg1.core.type == DNA.MISSILE)) && ((getTypeCount(DNA.MISSILE) > 0)))){ _missilePower = (_missilePower + 2); _missileBurnIn = (_missileBurnIn + 0.05); } else { if (_arg1.core.type == DNA.SPEED){ _thrust = (_thrust + (_speedHexes * 2)); } else { if (_arg1.core.type == DNA.TECH){ if (_regeneration > 0){ _regeneration = (_regeneration + 0.05); }; if (_bombProximity > 0){ _bombProximity = (_bombProximity + 2); }; if (_missileSeekRadius > 0){ _missileSeekRadius = (_missileSeekRadius + 2); }; }; }; }; }; }; }; }; calcSkill(_arg1); } public function getTypeCount(_arg1:int):int{ var _local2:int; var _local3:*; _local2 = 0; for each (_local3 in _batch) { if (_local3.type == _arg1){ _local2++; }; }; return (_local2); } public function get abilities():Array{ var _local1:Array; _local1 = new Array(); if (getTypeCount(DNA.ARMOR) > 0){ _local1.push("armor"); }; if (_regeneration > 0){ _local1.push("armor regeneration"); if ((((_regenerationRate < 30)) && ((_regenerationRate > 1)))){ _local1.push("faster armor regeneration"); } else { _local1.push("maximized armor regeneration"); }; }; if (_bombCount == 1){ _local1.push("bombs"); }; if (_bombCount > 1){ _local1.push("multi-bombs"); }; if (_bombArmor > 0){ _local1.push("shelled bombs"); }; if (_bombGrowth > 0){ _local1.push("growing bombs"); }; if ((((_bombGrowth > 0)) && ((_pool.speed > 0)))){ _local1.push("faster bomb growth"); }; if (_bombShotSize > 0){ _local1.push("bomb shots"); }; if ((((_bombShotSize > 0)) && ((_bombShotBurnIn > 0)))){ _local1.push("greater bomb shot acceleration"); }; if ((((_bombShotSize > 0)) && ((_bombShotSeekRadius > 0)))){ _local1.push("seeking bomb shots"); }; if (_bombProximity > 0){ _local1.push("proximity bombs"); }; if (_bombSeekRadius > 0){ _local1.push("seeking bombs"); }; if (_hasMissile){ _local1.push("missiles"); }; if (_missileBurnIn > 1){ _local1.push("greater missile acceleration"); }; if (_missileGrowth > 0){ _local1.push("growing missiles"); }; if (((((_hasMissile) && ((_missileGrowth > 0)))) && ((_pool.speed > 0)))){ _local1.push("faster missile growth"); }; if (_missileSeekRadius > 0){ _local1.push("seeking missiles"); }; if (((_hasMissile) && ((_pool.speed > 0)))){ _local1.push("increased missile firing rate"); }; if (_thrust > _minThrust){ _local1.push("thrusters"); }; if ((((_thrust > _minThrust)) && ((type == "line")))){ _local1.push("optimized thrusters"); }; if (_antithrust > 0){ _local1.push("anti-thrusters"); }; return (_local1); } public function fire(_arg1:Player, _arg2:Celle, _arg3:Vector):void{ var _local4:Number; var _local5:Missile; var _local6:int; var _local7:Celle; if (!_hasMissile){ return; }; if ((_arg1.frameCount - _lastFrameShot) < _missileRate){ return; }; _lastFrameShot = _arg1.frameCount; _local4 = (Math.atan2((_arg3.y - _arg2.y), (_arg3.x - _arg2.x)) + (Math.PI / 2)); _local5 = new Missile(_batch[0].x, _batch[0].y, _missileSize, _missileSeekRadius, _arg2.missiles, _arg1); _local5.velocity = _batch[0].velocity; _local5.power = _missilePower; _local5.fuel = _missileFuel; _local5.propel = new Vector((_missilePropel * Math.sin(_local4)), (-(_missilePropel) * Math.cos(_local4))); _local5.burnIn = _missileBurnIn; _local5.growth = _missileGrowth; _local5.growTime = _missileGrowTime; _local5.seekTime = _missileSeekTime; _local5.seekThrust = _missileSeekThrust; if (_arg1.celle == _arg2){ GameSound.play("missile"); if (_missileSeekRadius > 0){ _local6 = 0; while (_local6 < _arg1.others.count) { _local7 = _arg1.others.celles[_local6]; if (_local7.position.distance(_arg3) < (_local7.size + _missileSeekRadius)){ _local5.seekLock = _local7; _local5.draw(); _arg1.fx.ring(_local7.x, _local7.y, (_local7.size + _missileSeekRadius), 1.5, 0xFFFFFF, 0.8, false); _local6 = 4242; }; _local6++; }; }; }; } public function antiThrust(_arg1:Celle, _arg2:Array):void{ var _local3:Vector; var _local4:VectorForce; var _local5:*; if (_antithrust == 0){ return; }; _local3 = _batch[0].velocity; if (((!(_arg2[0])) && ((_local3.y < 0)))){ _local3.y = _antithrust; } else { if (((!(_arg2[2])) && ((_local3.y > 0)))){ _local3.y = -(_antithrust); }; }; if (((!(_arg2[1])) && ((_local3.x > 0)))){ _local3.x = -(_antithrust); } else { if (((!(_arg2[3])) && ((_local3.x < 0)))){ _local3.x = _antithrust; }; }; if (_speedHexes <= 1){ _local4 = new VectorForce(true, _local3.x, _local3.y); _batch[0].addForce(_local4); } else { _local3.divEquals(_speedHexes); _local4 = new VectorForce(true, _local3.x, _local3.y); for each (_local5 in _batch) { _local5.addForce(_local4); }; }; } public function thrust(_arg1:Celle, _arg2:Array, _arg3:Boolean=false):void{ var _local4:Number; var _local5:Vector; var _local6:VectorForce; var _local7:*; _local4 = _thrust; if (_arg3){ _local4 = _noSpeedThrust; }; if (_local4 > 0){ _local5 = new Vector(); if (_arg2[0]){ _local5.y = (_local5.y - _local4); }; if (_arg2[1]){ _local5.x = (_local5.x + _local4); }; if (_arg2[2]){ _local5.y = (_local5.y + _local4); }; if (_arg2[3]){ _local5.x = (_local5.x - _local4); }; if (_speedHexes <= 1){ _local6 = new VectorForce(true, _local5.x, _local5.y); _batch[0].addForce(_local6); } else { _local5.divEquals(_speedHexes); _local6 = new VectorForce(true, _local5.x, _local5.y); for each (_local7 in _batch) { _local7.addForce(_local6); }; }; antiThrust(_arg1, _arg2); }; } public function get skill():Number{ return (_skill); } public function indexOf(_arg1:Hex):int{ return (_batch.indexOf(_arg1)); } public function getAll():Array{ return (_batch); } public function remove(_arg1:Hex):void{ _batch.splice(_batch.indexOf(_arg1), 1); } public function update(_arg1:Player):void{ var _local2:Hex; var _local3:int; var _local4:*; if ((((_regeneration > 0)) && (((_arg1.frameCount % _regenerationRate) == 0)))){ for each (_local2 in _batch) { if (_local2.armor < _local2.maxArmor){ _local2.armor = (_local2.armor + _regeneration); if (_local2.armor > _local2.maxArmor){ _local2.armor = _local2.maxArmor; }; if (_arg1.fxNo > 0){ _arg1.fx.magnet(_local2, 2.5, 120, 3, 0x888888); }; }; for each (_local4 in _local2.links) { if (_local4){ if ((((_batch.indexOf(_local4) < 0)) && ((_local4.armor < _local4.maxArmor)))){ _local4.armor = (_local4.armor + _regeneration); if (_local4.armor > _local4.maxArmor){ _local4.armor = _local4.maxArmor; }; if (_arg1.fxNo > 1){ _arg1.fx.magnet(_local2, 2.5, 120, 3, 0x888888); }; }; }; }; }; }; _local3 = 0; while (_local3 < _batch.length) { if (_batch[_local3].armor < 0){ _batch[_local3].destroy(_arg1); _local3 = _batch.length; }; _local3++; }; } public function index(_arg1:int):Hex{ return (_batch[_arg1]); } public function get length():int{ return (_batch.length); } public function drop(_arg1:Player, _arg2:Celle):void{ var _local3:Boolean; var _local4:int; var _local5:Bomb; if (_bombCount == 0){ return; }; _local3 = false; _local4 = (_arg1.frameCount - _lastFrameDropped); if (_bombCount == 1){ if (_local4 >= _bombRate){ _lastFrameDropped = _arg1.frameCount; _local3 = true; }; } else { if (_local4 >= _bombRate){ _lastFrameDropped = _arg1.frameCount; _local4 = (_arg1.frameCount - _lastFrameDropped); }; if (_local4 < (_bombInterval * _bombCount)){ if ((_local4 % _bombInterval) == 0){ _local3 = true; }; }; }; if (!_local3){ return; }; _local5 = new Bomb(_batch[0].x, _batch[0].y, _bombSize, _bombArmor, _bombProximity, _arg2.bombs, _arg1, _bombSeekRadius); _local5.power = _bombPower; _local5.growth = _bombGrowth; _local5.growTime = _bombGrowTime; _local5.shotSize = _bombShotSize; _local5.shotFuel = _bombShotFuel; _local5.shotPropel = _bombShotPropel; _local5.shotRate = _bombShotRate; _local5.shotBurnIn = _bombShotBurnIn; _local5.shotGroup = _arg2.missiles; _local5.shotSeekRadius = _bombShotSeekRadius; _local5.shotSeekTime = _bombShotSeekTime; _local5.shotSeekThrust = _bombShotSeekThrust; _local5.seekTime = _bombSeekTime; _local5.seekThrust = _bombSeekThrust; _local5.lastShotFrame = 0; if (_arg1.celle == _arg2){ if (_bombSize < 4){ GameSound.play("bombsmall"); } else { if (_bombSize < 8){ GameSound.play("bombnormal"); } else { GameSound.play("bombbig"); }; }; }; } public function removeHex(_arg1:Hex):void{ var _local2:int; _local2 = _batch.indexOf(_arg1); if (_local2 >= 0){ _batch.splice(_local2, 1); }; } public function calcSkill(_arg1:Celle):void{ var _local2:Array; var _local3:Number; var _local4:*; _local2 = new Array(); _local2.push((_pool.armor / 5)); _local2.push((_regeneration * 15)); if (_regeneration > 0){ _local2.push((((30 - _regenerationRate) / 20) + 1)); }; if (_bombCount > 0){ _local2.push(((40 - _bombRate) / 10)); }; _local2.push((_bombSize / 10)); _local2.push((_bombArmor / 20)); _local2.push((_bombPower / 15)); _local2.push(((30 - _bombRate) / 20)); _local2.push((_bombShotSize / 15)); _local2.push((_bombShotFuel / 30)); _local2.push((_bombShotPropel / 10)); _local2.push(((90 - _bombShotRate) / 15)); _local2.push(((_bombProximity / (_arg1.hexSize / 2)) / 5)); _local2.push((_bombSeekRadius / 10)); _local2.push((_missileSize / 5)); _local2.push((_missilePower / 9)); _local2.push((_missileFuel / 10)); _local2.push(((30 - _missileRate) / 20)); if (_missileBurnIn > 1){ _local2.push((((_missileBurnIn - 1) * 100) / 10)); }; _local2.push(((_missileGrowTime * _missileGrowth) / 4)); _local2.push((_missileSeekRadius / 10)); _local2.push((_thrust / 10)); _local2.push((_antithrust / 20)); _local3 = 0; for each (_local4 in _local2) { _local3 = (_local3 + _local4); }; _skill = (_local3 / _local2.length); } } }//package hexcelle
Section 8
//Batches (hexcelle.Batches) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; public class Batches { private const MAX_BATCH_SIZE:int = 7; private var _celle:Celle; private var _noSpeed:Boolean; private var _noWeapons:Boolean; private var _player:Player; private var _batches:Array; public function Batches(_arg1:Celle){ _celle = _arg1; _batches = new Array(); } public function update():void{ var _local1:int; _local1 = 0; while (_local1 < _batches.length) { _batches[_local1].update(_player); _local1++; }; } public function draw(_arg1:Sprite):void{ var undraw:Function; var batch:*; var batchHexes:*; var hex:*; var otherHex:*; var sprite = _arg1; var _local3 = sprite.graphics; with (_local3) { beginFill(0xFFFFFF, 0.35); drawRect(0, 0, sprite.stage.stageWidth, sprite.stage.stageHeight); endFill(); for each (batch in _batches) { lineStyle(2, 0); batchHexes = batch.getAll(); for each (hex in batchHexes) { for each (otherHex in batchHexes) { if (hex != otherHex){ moveTo(hex.x, hex.y); lineTo(otherHex.x, otherHex.y); }; }; }; lineStyle(3, 0); drawCircle(batchHexes[0].x, batchHexes[0].y, 4); }; }; undraw = function (_arg1:MouseEvent):void{ sprite.graphics.clear(); }; sprite.removeEventListener(MouseEvent.CLICK, undraw); sprite.addEventListener(MouseEvent.CLICK, undraw); } public function get abilities():Array{ var _local1:Array; var _local2:*; var _local3:int; var _local4:*; var _local5:int; _local1 = new Array(); for each (_local2 in _batches) { for each (_local4 in _local2.abilities) { _local1.push(_local4); }; }; _local3 = 0; while (_local3 < _local1.length) { _local5 = (_local3 + 1); while (_local5 < _local1.length) { if ((((_local1[_local5] == _local1[_local3])) && (!((_local5 == _local3))))){ _local1.splice(_local5, 1); _local5--; }; _local5++; }; _local3++; }; return (_local1); } public function get skill():Number{ var _local1:Number; var _local2:*; if (_batches.length == 0){ trace("no batches exist"); return (NaN); }; _local1 = 0; for each (_local2 in _batches) { _local1 = (_local1 + _local2.skill); }; if (_local1 < 0.1){ _local1 = 0.1; } else { _local1 = (Math.round((_local1 * 100)) / 100); }; return (_local1); } public function getHexBatch(_arg1:Hex):Batch{ var _local2:*; for each (_local2 in _batches) { if (_local2.indexOf(_arg1) >= 0){ return (_local2); }; }; trace("hex not found in a batch"); return (null); } public function thrust(_arg1:Array):void{ var _local2:*; for each (_local2 in _batches) { _local2.thrust(_celle, _arg1, _noSpeed); }; } public function prepHexes():void{ var updater:Function; _celle.resetPools(); updater = function (_arg1:Hex):void{ var _local2:*; _arg1.pool.changeByIndex(_arg1.type, 1); for each (_local2 in _arg1.links) { if (_local2){ _local2.pool.changeByIndex(_arg1.type, 1); }; }; }; _celle.applyToHexes(updater); } public function get batches():Array{ return (_batches); } public function prep(_arg1:Player=null, _arg2:Boolean=true):void{ var batch:Batch; var partner:Hex; var link:Hex; var similars:Array; var i:int; var checkSize:int; var buildCluster:Function; var collect:Function; var buildLine:Function; var missCheck:Function; var max:Function; var armorer:Function; var player = _arg1; var resetArmors = _arg2; if (player){ _player = player; }; prepHexes(); _batches = new Array(); buildCluster = function (_arg1:Hex):void{ var _local2:Array; if (_arg1.toggle){ return; }; if (_arg1.linkCount < (checkSize - 1)){ return; }; _local2 = new Array(); if (_arg1.type != DNA.TECH){ for each (link in _arg1.links) { if (!link){ } else { if (link.toggle){ } else { if ((((link.type == DNA.TECH)) || ((link.type == _arg1.type)))){ _local2.push(link); }; }; }; }; } else { for each (link in _arg1.links) { if (!link){ } else { if (link.toggle){ } else { similars = new Array(); for each (partner in _arg1.links) { if (!partner){ } else { if (partner.toggle){ } else { if (partner.type == link.type){ similars.push(partner); }; }; }; }; if (similars.length == (checkSize - 1)){ _local2 = _local2.concat(similars); break; }; }; }; }; }; if (_local2.length == (checkSize - 1)){ batch = new Batch(); batch.type = "cluster"; batch.push(_arg1); _arg1.toggle = true; for each (partner in _local2) { batch.push(partner); partner.toggle = true; }; _batches.push(batch); }; }; collect = function (_arg1:Hex, _arg2:int):Array{ var _local3:Array; var _local4:Hex; _local3 = new Array(); _local4 = _arg1.links[_arg2]; while (_local4) { if (((_local4.toggle) || (((!((_local4.type == DNA.TECH))) && (!((_local4.type == _arg1.type))))))){ _local4 = null; } else { _local3.push(_local4); _local4 = _local4.links[_arg2]; }; }; return (_local3); }; buildLine = function (_arg1:Hex):void{ var _local2:int; var _local3:int; if (_arg1.toggle){ return; }; if (_arg1.type == DNA.TECH){ return; }; _local2 = 0; while (_local2 < 6) { similars = new Array(_arg1); similars = similars.concat(collect(_arg1, _local2)); if (similars.length < checkSize){ _local3 = ((_local2)<3) ? (_local2 + 3) : (_local2 - 3); similars = similars.concat(collect(_arg1, _local3)); }; if (similars.length < checkSize){ } else { while (similars.length > checkSize) { similars.pop(); }; batch = new Batch(); for each (partner in similars) { batch.push(partner); partner.toggle = true; }; batch.type = "line"; _batches.push(batch); }; _local2++; }; }; _celle.toggleAll(false); checkSize = Math.min(MAX_BATCH_SIZE, _celle.hexCount); while (checkSize > 0) { if (checkSize > 3){ _celle.applyToHexes(buildCluster); _celle.applyToHexes(buildLine); } else { if (checkSize == 3){ _celle.applyToHexes(buildLine); }; _celle.applyToHexes(buildCluster); }; checkSize = (checkSize - 1); }; i = 0; while (i < _batches.length) { if (_batches[i].length == 0){ trace("!!! empty batch !!!"); _batches.splice(i, 1); i = (i - 1); }; i = (i + 1); }; missCheck = function (_arg1:Hex):void{ if (!_arg1.toggle){ trace("hex not toggled"); }; getHexBatch(_arg1); }; _celle.applyToHexes(missCheck); _noSpeed = true; _noWeapons = true; if (resetArmors){ armorer = function (_arg1:Hex):void{ _arg1.armor = 2; _arg1.dead = false; }; _celle.applyToHexes(armorer); }; for each (batch in _batches) { batch.prep(_celle, resetArmors, false); if (batch.getTypeCount(DNA.SPEED) > 0){ _noSpeed = false; }; if ((((batch.getTypeCount(DNA.MISSILE) > 0)) || ((batch.getTypeCount(DNA.BOMB) > 0)))){ _noWeapons = false; }; }; max = function (_arg1:Hex):void{ _arg1.maxArmor = _arg1.armor; }; _celle.applyToHexes(max); } public function drop():void{ var _local1:*; if (_noWeapons){ return; }; for each (_local1 in _batches) { _local1.drop(_player, _celle); }; } public function fire(_arg1:Vector):void{ var checkRadius:Number; var damager:Function; var c:*; var batch:*; var target = _arg1; if (((_noWeapons) && (((_player.frameCount % 10) == 0)))){ checkRadius = ((_celle.size * 2) + 10); _player.fx.ring(_celle.x, _celle.y, checkRadius, 3, 0x994400); damager = function (_arg1:Hex):void{ var _local2:Vector; if (_celle.position.distance(_arg1.position) < checkRadius){ _arg1.armor = (_arg1.armor - 0.1); _local2 = _arg1.position.minus(_celle.position).normalize().mult(3); _arg1.addForce(new VectorForce(true, _local2.x, _local2.y)); _player.fx.ring(_arg1.x, _arg1.y, 50, 1, 10044450, 1, false); }; }; for each (c in _player.others.celles) { if (_player.testOnScreen(c)){ c.applyToHexes(damager); }; }; GameSound.play("pulse"); } else { for each (batch in _batches) { batch.fire(_player, _celle, target); }; }; } public function removeHex(_arg1:Hex):void{ var _local2:*; for each (_local2 in _batches) { _local2.removeHex(_arg1); }; prep(null, false); } } }//package hexcelle
Section 9
//BG (hexcelle.BG) package hexcelle { import flash.display.*; import org.cove.ape.*; import flash.filters.*; public class BG extends Sprite { private var levelScale:Number; private var level:uint; public function BG(_arg1:Number, _arg2:Number){ var size:Number; var gray:Number; var color:String; var blur:BlurFilter; var x = _arg1; var y = _arg2; super(); this.x = x; this.y = y; size = 200; level = Math.floor((Math.random() * 4)); levelScale = Math.pow(0.5, level); gray = Math.ceil((Math.random() * 99)); color = ((("0x" + gray) + gray) + gray); var _local4 = graphics; with (_local4) { beginFill(uint(color), ((0.25 + (0.05 * Math.random())) - (0.05 * level))); drawRect(0, 0, ((size + (Math.random() * size)) - ((level * size) / 3)), ((size + (Math.random() * size)) - ((level * size) / 3))); endFill(); }; blur = new BlurFilter(); blur.blurX = (5 / levelScale); blur.blurY = (5 / levelScale); blur.quality = BitmapFilterQuality.HIGH; filters = [blur]; cacheAsBitmap = true; name = "bg sprite"; } public function translate(_arg1:Vector){ x = (x + (_arg1.x * levelScale)); y = (y + (_arg1.y * levelScale)); } } }//package hexcelle
Section 10
//BGs (hexcelle.BGs) package hexcelle { import flash.display.*; import org.cove.ape.*; public class BGs extends Sprite { private var _player:Player; private var _backgrounds:Array; public var BGCount:uint; public function BGs(_arg1:Player, _arg2:uint=10){ var _local3:int; super(); _player = _arg1; BGCount = _arg2; _backgrounds = new Array(); _local3 = 0; while (_local3 < BGCount) { spawn(_player.randomBoundaryX(), _player.randomBoundaryY()); _local3++; }; } public function translate(_arg1:Vector){ var _local2:*; for each (_local2 in _backgrounds) { _local2.translate(_arg1); }; } public function spawn(_arg1:Number=0, _arg2:Number=0){ var _local3:BG; _local3 = new BG(_arg1, _arg2); addChild(_local3); _backgrounds.push(_local3); } public function update(){ var _local1:*; var _local2:int; var _local3:Vector; for each (_local1 in _backgrounds) { if (_player.testOutOfBounds(_local1)){ removeChild(_local1); _local2 = _backgrounds.indexOf(_local1); _backgrounds.splice(_local2, 1); }; }; if (_backgrounds.length < BGCount){ _local3 = _player.randomEdgeV(); spawn(_local3.x, _local3.y); }; } public function get bgs():Array{ return (_backgrounds); } } }//package hexcelle
Section 11
//Bomb (hexcelle.Bomb) package hexcelle { import flash.display.*; import org.cove.ape.*; public class Bomb extends UtilityCircleParticle { public var shotRate:Number; public var power:Number; public var shotSize:Number; private var _player:Player; public var seekRadius:Number; public var armor:Number; public var seekTime:Number; public var growTime:int; private var _group:Bombs; public var shotSeekTime:Number; public var lastShotFrame:uint; public var shotSeekThrust:Number; public var shotGroup:Group; public var proximity:Number; private var _proximityParticle:UtilityCircleParticle; public var seekLock:Celle; public var shotSeekRadius:Number; public var growth:Number; public var shotFuel:int; public var shotPropel:int; public var shotBurnIn:Number; public var seekThrust:Number; public function Bomb(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Bombs, _arg7:Player, _arg8:Number){ super(_arg1, _arg2, _arg3); armor = _arg4; proximity = _arg5; seekRadius = _arg8; _group = _arg6; _group.addParticle(this); addEventListener(CollisionEvent.COLLIDE, collide); if (proximity > 0){ _proximityParticle = new UtilityCircleParticle(_arg1, _arg2, proximity); _proximityParticle.solid = false; _proximityParticle.visible = false; _group.addParticle(_proximityParticle); _proximityParticle.addEventListener(CollisionEvent.COLLIDE, proximityCollide); }; _player = _arg7; draw(); } public function destroy(_arg1:Boolean=false):void{ var _local2:int; remove(); _local2 = Math.ceil((power / Math.max(1, (4 - _player.fxNo)))); if (_player.celle.bombs == _group){ _player.fx.clash(x, y, (proximity + (power * 3)), radius, _local2, 0xCCCC); } else { _player.fx.clash(x, y, (proximity + (power * 3)), radius, _local2, 0xFF3300); }; if (_arg1){ GameSound.play("bomb"); }; } public function get proximityParticle():UtilityCircleParticle{ return (_proximityParticle); } public function collide(_arg1:CollisionEvent):void{ var _local2:Bomb; var _local3:Faun; var _local4:Hex; var _local5:*; var _local6:Vector; var _local7:int; var _local8:Missile; _local2 = Bomb(_arg1.target); if ((_arg1.collidingItem is Faun)){ _local3 = Faun(_arg1.collidingItem); _local3.hit(_local2, _player); destroy(true); } else { if ((_arg1.collidingItem is Hex)){ _local4 = Hex(_arg1.collidingItem); Hex(_arg1.collidingItem).armor = (_local4.armor - (_local2.power / 5)); for each (_local5 in _local4.links) { if (_local5){ _local5.armor = (_local5.armor - (power / 8)); }; }; _local6 = _local4.position.minus(_local2.position).normalize().mult((power * 3)); _local4.addForce(new VectorForce(true, _local6.x, _local6.y)); destroy(true); _local7 = Math.ceil((power / Math.max(1, (3 - _player.fxNo)))); _player.fx.shardSpray(_local4.x, _local4.y, _local4.velocity, 0.3, 2.5, (power / 4), _local7, _local4.typeColor); } else { if ((_arg1.collidingItem is Missile)){ _local8 = Missile(_arg1.collidingItem); _local2.armor = (_local2.armor - (_local8.power / 6)); if (_local2.armor < 0){ _local2.destroy(true); }; _local8.destroy(); }; }; }; } public function draw():void{ var bSprite:Sprite; if (radius <= 0){ trace("bomb radius negative"); } else { mass = radius; }; bSprite = new Sprite(); var _local2 = bSprite.graphics; with (_local2) { if (_player.celle.bombs == _group){ if (proximity > 0){ lineStyle(1, 0xCCCC, 0.5); drawCircle(0, 0, proximity); }; lineStyle((radius / 4), 0xCCCC); } else { if (proximity > 0){ lineStyle(1, 0xFF3300, 0.5); drawCircle(0, 0, proximity); }; lineStyle((radius / 4), 0xFF3300); }; beginFill(0x777777, (0.1 + (armor / 25))); drawCircle(0, 0, (radius - 1)); endFill(); lineStyle(1, 0x1111, 0.6); drawCircle(0, 0, (radius + (radius / 8))); if ((((seekRadius > 0)) && (!(seekLock)))){ lineStyle(1, 16729156, 0.2); drawCircle(0, 0, seekRadius); }; }; setDisplay(bSprite); sprite.name = "bomb sprite"; } public function remove():void{ removeEventListener(CollisionEvent.COLLIDE, collide); _group.removeParticle(this); if (sprite.parent){ sprite.parent.removeChild(sprite); }; if (_proximityParticle){ _proximityParticle.removeEventListener(CollisionEvent.COLLIDE, proximityCollide); _group.removeParticle(_proximityParticle); if (_proximityParticle.sprite.parent){ _proximityParticle.sprite.parent.removeChild(_proximityParticle.sprite); }; }; } public function proximityCollide(_arg1:CollisionEvent):void{ var _local2:Bomb; var _local3:Hex; var _local4:uint; _local2 = this; if ((_arg1.collidingItem is Hex)){ _local3 = Hex(_arg1.collidingItem); _local3.armor = (_local3.armor - (_local2.power / 5)); destroy(true); _local4 = ((_player.celle.bombs == _group)) ? 0xCCCC : 0xFF3300; _player.fx.ring(x, y, (proximity * 2.5), (_local2.power / 3), _local4); if (_player.fxNo > 1){ _player.fx.ring(x, y, (proximity * 1.8), (_local2.power / 2), _local4); }; if (_player.fxNo > 0){ _player.fx.ring(x, y, proximity, (_local2.power / 5), _local4); }; }; } } }//package hexcelle
Section 12
//Bombs (hexcelle.Bombs) package hexcelle { import org.cove.ape.*; public class Bombs extends Group { private var _player:Player; private var _proximityCheck:int; private var _dropping:Boolean; public function Bombs(_arg1:Player){ _player = _arg1; _dropping = false; _proximityCheck = 0; APEngine.addGroup(this); collideInternal = false; } public function set dropping(_arg1:Boolean){ _dropping = _arg1; } public function update():void{ var _local1:*; var _local2:*; var _local3:Number; var _local4:Missile; var _local5:Number; var _local6:int; var _local7:int; var _local8:Celle; var _local9:int; var _local10:int; var _local11:Vector; var _local12:Number; for each (_local1 in particles) { if ((_local1 is Bomb)){ if (!_player.testOnScreen(_local1)){ _local1.remove(); }; }; }; for each (_local2 in particles) { if (!(_local2 is Bomb)){ } else { if ((((_local2.growth > 0)) && ((_local2.growTime > 0)))){ _local2.radius = (_local2.radius + _local2.growth); _local2.growTime--; if (((_local2.radius - (_local2.sprite.width / 2)) + 1) > 0.2){ _local2.draw(); }; }; if (_local2.proximityParticle){ _local2.proximityParticle.x = _local2.x; _local2.proximityParticle.y = _local2.y; }; if ((((_local2.shotSize > 0)) && (((_player.frameCount - _local2.lastShotFrame) > _local2.shotRate)))){ _local2.lastShotFrame = _player.frameCount; _local3 = ((Math.PI * 2) * (Math.random() - 0.5)); _local4 = new Missile(_local2.x, _local2.y, _local2.shotSize, _local2.shotSeekRadius, _local2.shotGroup, _player); _local4.power = (_local2.shotSize * 2); _local4.fuel = _local2.shotFuel; _local4.propel = new Vector((_local2.shotPropel * Math.sin(_local3)), (_local2.shotPropel * Math.cos(_local3))); _local4.burnIn = _local2.shotBurnIn; _local4.growth = 0; _local4.growTime = 0; _local4.seekTime = _local2.shotSeekTime; _local4.seekThrust = _local2.shotSeekThrust; }; if (_local2.seekRadius > 0){ if (!_local2.seekLock){ _local5 = _local2.seekRadius; if (_player.celle.bombs == this){ _local6 = _player.others.celles.length; if (_local6 > 0){ _local7 = Math.floor((Math.random() * _local6)); _local8 = _player.others.celles[_local7]; if (_local2.position.distance(_local8.position) < (_local5 * 2)){ _local9 = 0; while (_local9 < _local8.group.particles.length) { if (_local2.position.distance(_local8.group.particles[_local9].position) < _local5){ _local2.seekLock = _local8; _local2.draw(); _local9 = _local8.group.particles.length; }; _local9++; }; }; }; } else { if (_local2.position.distance(_player.celle.position) < (_local5 * 2)){ _local10 = 0; while (_local10 < _player.celle.group.particles.length) { if (_local2.position.distance(_player.celle.group.particles[_local10].position) < _local5){ _local2.seekLock = _player.celle; _local2.draw(); _local10 = _player.celle.group.particles.length; }; _local10++; }; }; }; } else { if (_local2.seekTime > 0){ _local11 = _local2.seekLock.position.minus(_local2.position).normalize(); _player.fx.line(_local2.x, _local2.y, _local2.seekLock.x, _local2.seekLock.y, 0x990000, 0.2); if (_player.fxNo > 1){ _local12 = ((_player.celle.bombs)==this) ? 0xCCCC : 0xFF3300; _player.fx.shardSpray(_local2.x, _local2.y, new Vector(-(_local11.x), -(_local11.y)), 0.2, 1.5, _local2.seekThrust, 1, _local12, 0.5); }; _local11.multEquals(_local2.seekThrust); _local2.addForce(new VectorForce(true, _local11.x, _local11.y)); _local2.seekTime--; }; }; }; }; }; } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in particles) { _local2.translate(_arg1); }; } public function destroyAll():void{ var _local1:int; _local1 = 0; while (_local1 < particles.length) { if ((particles[_local1] is Bomb)){ particles[_local1].destroy(); _local1 = -1; }; _local1++; }; } public function get dropping():Boolean{ return (_dropping); } public function set visible(_arg1:Boolean):void{ var _local2:*; for each (_local2 in particles) { if ((_local2 is Bomb)){ _local2.visible = _arg1; }; }; } } }//package hexcelle
Section 13
//Celle (hexcelle.Celle) package hexcelle { import flash.display.*; import org.cove.ape.*; public class Celle { private var _player:Player; private var _added:Boolean; private var _hexes:Hexes; private var _bombs:Bombs; private var _hexCount:int; private var _batches:Batches; private var _offset:Vector; private var _bounds:Vector; private var _size:Number; public var dropping:Boolean; private var _hexLinkStiffness:Number; private var _missiles:Missiles; public var firing:Boolean; private var _hexSize:Number; public function Celle(_arg1:Number=3):void{ _hexSize = _arg1; _hexLinkStiffness = 0.7; _hexes = new Hexes(this); _batches = new Batches(this); _offset = new Vector(); _bounds = new Vector(); APEngine.addGroup(_hexes); _added = true; } public function get missileHexes():int{ return (_hexes.composition.missile); } public function remove():void{ var cleaner:Function; APEngine.removeGroup(_hexes); _hexes.removeSprites(); _added = false; if (((_bombs) && (_missiles))){ APEngine.removeGroup(_bombs); APEngine.removeGroup(_missiles); _bombs.destroyAll(); _missiles.destroyAll(); }; cleaner = function (_arg1:Hex):void{ _arg1.removeEventListener(CollisionEvent.COLLIDE, collide); }; applyToHexes(cleaner); } public function get hexes():Hexes{ return (_hexes); } public function drawBatches(_arg1:Sprite):void{ _batches.draw(_arg1); } public function get missiles():Missiles{ return (_missiles); } public function get x():Number{ return (core.px); } public function get bombs():Bombs{ return (_bombs); } private function prepCollisions():void{ var collider:Function; collider = function (_arg1:Hex):void{ _arg1.removeEventListener(CollisionEvent.COLLIDE, collide); if (_arg1.linkCount < 6){ _arg1.addEventListener(CollisionEvent.COLLIDE, collide); }; }; applyToHexes(collider); } public function get bombHexes():int{ return (_hexes.composition.bomb); } public function applyToHexes(_arg1:Function):void{ _hexes.grid.applyToHexes(_arg1); } public function get hexLinkStiffness():Number{ return (_hexLinkStiffness); } public function get offset():Vector{ return (_offset); } public function set hexLinkStiffness(_arg1:Number){ _hexLinkStiffness = _arg1; } public function get core():Hex{ if (_hexes){ return (_hexes.core); }; return (null); } public function add():void{ var adder:Function; remove(); APEngine.addGroup(_hexes); adder = function (_arg1:Hex):void{ APEngine.container.addChild(_arg1.sprite); }; _hexes.applyToHexes(adder); _added = true; } public function get added():Boolean{ return (_added); } public function get size():Number{ return (_size); } public function get techHexes():int{ return (_hexes.composition.tech); } public function get armorHexes():int{ return (_hexes.composition.armor); } public function toggleAll(_arg1:Boolean):void{ _hexes.toggleAll(_arg1); } public function get speedHexes():int{ return (_hexes.composition.speed); } public function prepForPlay(_arg1:Player=null):void{ var _local2:Hex; _player = _arg1; if (_arg1){ if (!_missiles){ _missiles = new Missiles(_arg1); _missiles.addCollidable(_arg1.fauna); }; if (!_bombs){ _bombs = new Bombs(_arg1); _bombs.addCollidable(_arg1.fauna); }; }; _batches.prep(_arg1); firing = false; dropping = false; _offset = new Vector(); _bounds = new Vector(); for each (_local2 in _hexes.particles) { if ((_local2.x - _local2.radius) < (core.x + _offset.x)){ _offset.x = ((_local2.x - _local2.radius) - core.x); }; if ((_local2.y - _local2.radius) < (core.y + _offset.y)){ _offset.y = ((_local2.y - _local2.radius) - core.y); }; }; for each (_local2 in _hexes.particles) { if ((_local2.x + _local2.radius) > ((core.x + _offset.x) + _bounds.x)){ _bounds.x = (((_local2.x + _local2.radius) - core.x) - _offset.x); }; if ((_local2.y + _local2.radius) > ((core.y + _offset.y) + _bounds.y)){ _bounds.y = (((_local2.y + _local2.radius) - core.y) - _offset.y); }; }; _size = Math.sqrt((Math.pow((_bounds.x / 2), 2) + Math.pow((_bounds.y / 2), 2))); } public function positionHex(_arg1:Hex, _arg2:Hex, _arg3:int){ _hexes.positionHex(_arg1, _arg2, _arg3, _hexSize); } public function get hexCount():int{ return (_hexCount); } public function get bounds():Vector{ return (_bounds); } public function fire(_arg1:Vector=null):void{ if (_arg1){ _batches.fire(_arg1); } else { _batches.fire(new Vector(APEngine.container.mouseX, APEngine.container.mouseY)); }; } public function get position():Vector{ return (core.position); } public function addHex(_arg1:Hex, _arg2:int):Hex{ return (_hexes.addHex(_arg1, _arg2)); } public function set playItemsVisibility(_arg1:Boolean):void{ _missiles.visible = _arg1; _bombs.visible = _arg1; } public function get growHexes():int{ return (_hexes.composition.grow); } private function collide(_arg1:CollisionEvent):void{ var _local2:Hex; if ((_arg1.collidingItem is Hex)){ _local2 = Hex(_arg1.target); if (_hexes.particles.indexOf(_local2) < 0){ trace("hit another celle"); if (_local2.multisample == 0){ _local2.multisample = 4; _player.collision = true; trace("colliding!"); }; } else { trace(_hexes.particles.indexOf(_local2)); }; }; } public function get batchArray():Array{ return (_batches.batches); } public function destroyHex(_arg1:Hex, _arg2:Player):void{ var fxCount:int; var thisCelle:Celle; var lostHex:Hex; var allHexes:Array; var foodify:Function; var speed:Number; var count:int; var destroySets:Array; var done:Boolean; var linkDeaths:Array; var i:int; var set:*; var deadHex:*; var linkHex:*; var explodingHex:*; var delay:int; var e:Effect; var force:Vector; var link:*; var except:Function; var hexSprite:HexSprite; var h = _arg1; var player = _arg2; thisCelle = this; fxCount = (5 + (player.fxNo * 5)); player.fx.bolts(h.x, h.y, 40, fxCount); h.dead = true; allHexes = _hexes.grid.allHexes; removeHex(h); foodify = function (_arg1:Number, _arg2:Number):void{ var _local3:int; var _local4:int; var _local5:String; var _local6:Food; var _local7:Number; var _local8:Number; var _local9:VectorForce; _local3 = 0; while (_local3 < 3) { _local4 = ((thisCelle)==player.boss) ? 3 : 2; _local4 = (_local4 + Math.floor((player.areas.steps / 3))); _local5 = ((thisCelle)==player.boss) ? "boss" : "celle"; _local6 = player.foods.makeFood(_arg1, _arg2, _local5, _local4); _local7 = ((Math.random() * 12) - 6); _local8 = ((Math.random() * 12) - 6); _local9 = new VectorForce(true, _local7, _local8); _local6.addForce(_local9); _local3++; }; }; if ((((this == player.celle)) && (!((h == core))))){ player.fx.textFloat((DNA.getIndexName(h.type) + " hex lost!"), h.x, ((core.y - size) - 10), h.typeColor); GameSound.play("hexlost"); }; if (h == core){ count = hexCount; if (((!((this == player.celle))) && ((count > 1)))){ player.fx.textFloat((("core destroy " + count) + "!"), h.x, (h.y - 25), 11158596); player.coreDestroy(count); }; _hexes.toggleAll(false); destroySets = [[core]]; done = false; while (!(done)) { linkDeaths = new Array(); done = true; for each (set in destroySets) { for each (deadHex in set) { if (!deadHex.toggle){ deadHex.toggle = true; done = false; for each (linkHex in deadHex.links) { if (linkHex){ if (!linkHex.toggle){ linkDeaths.push(linkHex); }; }; }; }; }; }; destroySets.push(linkDeaths); }; i = 0; while (i < destroySets.length) { for each (explodingHex in destroySets[i]) { delay = ((i * 15) + Math.round((10 * Math.random()))); if (player.fxNo > 1){ e = player.fx.bolts(explodingHex.x, explodingHex.y, (_hexSize * 10), 5); e.delay = delay; e = player.fx.ring(explodingHex.x, explodingHex.y, (_hexSize * 23), 1, explodingHex.typeColor); e.delay = delay; }; fxCount = (30 + (player.fxNo * 10)); e = player.fx.shards(explodingHex.x, explodingHex.y, (_hexSize / 2), 15, fxCount, explodingHex.typeColor); e.delay = delay; e = player.fx.ring(explodingHex.x, explodingHex.y, (_hexSize * 20), 4, explodingHex.typeColor); e.delay = delay; }; i = (i + 1); }; for each (lostHex in allHexes) { if (lostHex != core){ _hexes.removeHex(lostHex); _batches.removeHex(lostHex); }; }; fxCount = (30 + (player.fxNo * 10)); player.fx.shards(core.x, core.y, (_hexSize / 2), 10, fxCount, h.typeColor); player.fx.ring(core.x, core.y, (_hexSize * 20), 4, h.typeColor); player.fx.ring(core.x, core.y, (_hexSize * 23), 1, h.typeColor); if (this == player.celle){ player.die(); } else { player.others.destroy(this); }; } else { player.fx.ring(h.x, h.y, (_hexSize * 10), 2, h.typeColor); for each (link in h.links) { if (link){ force = link.position.minus(h.position).normalize().mult((50 * h.mass)); link.addForce(new VectorForce(true, force.x, force.y)); }; }; except = function (_arg1:Hex):void{ var _local2:int; _local2 = allHexes.indexOf(_arg1); if (_local2 < 0){ trace("this should never happen, excpet fucked up"); }; allHexes.splice(_local2, 1); }; applyToHexes(except); }; if (this != player.celle){ for each (lostHex in allHexes) { foodify(lostHex.x, lostHex.y); }; }; speed = 10; for each (lostHex in allHexes) { hexSprite = new HexSprite(_hexSize, lostHex.type); hexSprite.x = lostHex.x; hexSprite.y = lostHex.y; if (lostHex != core){ force = core.position.minus(lostHex.position).normalize().mult((speed + (10 * Math.random()))); } else { force = new Vector((-(speed) + ((2 * speed) * Math.random())), (-(speed) + ((2 * speed) * Math.random()))); }; player.fx.shootingSprite(hexSprite, force, (8 + (4 * Math.random()))); }; } public function hasHex(_arg1:Hex):Boolean{ return (_hexes.grid.hasHex(_arg1)); } public function draw():void{ build(); prepForPlay(); _hexes.draw(); } public function set core(_arg1:Hex){ _hexes.core = _arg1; } public function get grid():Grid{ return (_hexes.grid); } public function addEventListenerToHexes(_arg1:String, _arg2:Function):void{ _hexes.addEventListenerToHexes(_arg1, _arg2); } public function update():void{ if (!core.sprite.parent){ trace("celle's core has no container"); return; }; _batches.update(); _missiles.update(); _bombs.update(); if (firing){ fire(); }; if (dropping){ drop(); }; } public function addForce(_arg1:Vector):void{ _arg1.divEquals(_hexes.particles.length); _hexes.addForce(_arg1); } public function get hexSize():Number{ return (_hexSize); } public function translate(_arg1:Vector):void{ _hexes.translate(_arg1); if (_missiles){ _missiles.translate(_arg1); }; if (_bombs){ _bombs.translate(_arg1); }; } public function get abilities():Array{ return (_batches.abilities); } public function getHexSpriteOwner(_arg1:Sprite):Hex{ return (_hexes.getHexSpriteOwner(_arg1)); } public function get skill():Number{ return (_batches.skill); } public function removeEventListenerFromHexes(_arg1:String, _arg2:Function):void{ _hexes.removeEventListenerFromHexes(_arg1, _arg2); } public function resetPools():void{ _hexes.grid.resetPools(); } public function get details():String{ var _local1:String; _local1 = ""; _local1 = (_local1 + (("size:\t" + hexSize) + "\n")); _local1 = (_local1 + (("hexCount:\t" + _hexes.particles.length) + "\n")); _local1 = (_local1 + (((("coreCoords:\t" + core.x) + ", ") + core.y) + "\n")); _local1 = (_local1 + (("coreType:\t" + DNA.getIndexName(core.type)) + "\n")); _local1 = (_local1 + (("groups:\t" + APEngine.groups) + "\n")); _local1 = (_local1 + (((("container:\t" + APEngine.container) + ": ") + APEngine.container.name) + "\n")); _local1 = (_local1 + _hexes.grid.details); return (_local1); } public function thrust(_arg1:Array):void{ _batches.thrust(_arg1); } public function removeHexes(_arg1:Array):void{ var _local2:Array; var _local3:int; var _local4:*; _local2 = _arg1; _local3 = 0; while (_local3 < _local2.length) { if (_hexes.grid.getHexCoords(_local2[_local3]) == null){ trace("hex removed from list before removal"); _local2.splice(_local3, 1); _local3--; }; _local2[_local3].removeEventListener(CollisionEvent.COLLIDE, collide); _local3++; }; _hexes.removeHexes(_local2); for each (_local4 in _local2) { if (_local4 != core){ _batches.removeHex(_local4); }; }; } public function set visible(_arg1:Boolean):void{ _hexes.visible = _arg1; playItemsVisibility = _arg1; } public function build(){ var updatePosition:Function; updatePosition = function (_arg1:Hex){ var _local2:int; _local2 = 0; while (_local2 < 6) { if (((_arg1.links[_local2]) && (!(_arg1.links[_local2].toggle)))){ _hexes.positionHex(_arg1.links[_local2], _arg1, _local2, _hexSize); _arg1.links[_local2].toggle = true; updatePosition(_arg1.links[_local2]); }; _local2++; }; }; _hexes.toggleAll(false); core.toggle = true; updatePosition(core); _hexes.initPhysics(); _hexCount = _hexes.grid.hexCount; } public function drop():void{ _batches.drop(); } public function set x(_arg1:Number):void{ core.px = _arg1; } public function set y(_arg1:Number):void{ core.py = _arg1; } public function copy():Celle{ var _local1:CelleFile; var _local2:String; var _local3:Celle; var _local4:*; _local1 = new CelleFile(); _local2 = _local1.getCelleSaveString(this); _local3 = _local1.loadFromString(_local2); _local3.x = this.x; _local3.y = this.y; _local3.hexSize = this.hexSize; for each (_local4 in this.group.collisionList) { _local3.group.addCollidable(_local4); }; if (!_added){ _local3.remove(); }; return (_local3); } public function removeHex(_arg1:Hex):void{ if (_arg1 == core){ return; }; _hexes.removeHex(_arg1); _batches.removeHex(_arg1); _arg1.removeEventListener(CollisionEvent.COLLIDE, collide); _hexCount = _hexes.grid.hexCount; } public function set hexSize(_arg1:Number){ _hexSize = _arg1; _hexes.hexSize = _arg1; draw(); } public function get y():Number{ return (core.py); } public function get group():Group{ return (_hexes); } } }//package hexcelle
Section 14
//CelleFile (hexcelle.CelleFile) package hexcelle { import org.cove.ape.*; import flash.system.*; import flash.net.*; public class CelleFile { public function loadLocal(_arg1:String):Celle{ var _local2:SharedObject; _local2 = SharedObject.getLocal(_arg1); if (_local2.size == 0){ return (null); }; System.setClipboard(_local2.data.hexcelle); return (buildCelleFromSaveString(_local2.data.hexcelle)); } public function loadFromString(_arg1:String):Celle{ return (buildCelleFromSaveString(_arg1)); } public function getCelleSaveString(_arg1:Celle):String{ var s:String; var a:Array; var getCelleData:Function; var celle = _arg1; s = (((celle.grid.width + ";") + celle.grid.height) + ";"); a = celle.grid.getHexCoords(celle.core); s = (s + (a[0] + ";")); s = (s + (a[1] + ";")); s = (s + (celle.grid.orientUp + ";")); s = (s + (celle.skill + ";")); getCelleData = function (_arg1:Hex){ a = celle.grid.getHexCoords(_arg1); s = (s + (a[0] + ";")); s = (s + (a[1] + ";")); s = (s + (_arg1.type + ";")); }; celle.applyToHexes(getCelleData); s = s.substr(0, (s.length - 1)); return (s); } private function buildCelleFromSaveString(_arg1:String):Celle{ var values:Array; var i:int; var newCelle:Celle; var grid:Array; var adder:Function; var h:Hex; var s = _arg1; values = s.split(";"); newCelle = new Celle(); grid = new Array(); i = 0; while (i < values[0]) { grid.push(new Array(int(values[1]))); i = (i + 1); }; i = 0; while (((i * 3) + 7) < values.length) { h = new Hex(0, 0, 10, newCelle); h.type = int(values[((i * 3) + 8)]); grid[int(values[((i * 3) + 6)])][int(values[((i * 3) + 7)])] = h; i = (i + 1); }; newCelle.remove(); values[4] = (values[4] == "true"); newCelle.core = grid[int(values[2])][int(values[3])]; newCelle.grid.grid = grid; newCelle.grid.orientUp = values[4]; newCelle.grid.updateAllHexLinks(); adder = function (_arg1:Hex):void{ if (_arg1 != newCelle.core){ newCelle.group.addParticle(_arg1); }; }; newCelle.applyToHexes(adder); newCelle.draw(); APEngine.addGroup(newCelle.group); return (newCelle); } public function saveLocal(_arg1:Celle, _arg2:String){ var _local3:SharedObject; _local3 = SharedObject.getLocal(_arg2); _local3.data.hexcelle = getCelleSaveString(_arg1); System.setClipboard(_local3.data.hexcelle); _local3.flush(); } } }//package hexcelle
Section 15
//DNA (hexcelle.DNA) package hexcelle { public class DNA { public var speed:int; public var grow:int; public var tech:int; public var bomb:int; public var missile:int; public var armor:int; public static const BOMB:int = 1; public static const SPEED:int = 4; public static const MISSILE:int = 3; public static const GROW:int = 2; public static const TECH:int = 5; public static const ARMOR:int = 0; public function DNA(_arg1:Array=null){ reset(); if (_arg1 != null){ addArray(_arg1); }; } public function getByIndex(_arg1:int):int{ switch (_arg1){ case 0: return (armor); case 1: return (bomb); case 2: return (grow); case 3: return (missile); case 4: return (speed); case 5: return (tech); default: return (NaN); }; } public function get total():int{ return ((((((armor + bomb) + grow) + missile) + speed) + tech)); } public function getAsArray():Array{ return (array); } public function reset(){ armor = 0; tech = 0; missile = 0; bomb = 0; grow = 0; speed = 0; } public function get array():Array{ return (new Array(armor, bomb, grow, missile, speed, tech)); } public function add(_arg1:DNA){ armor = (armor + _arg1.armor); tech = (tech + _arg1.tech); missile = (missile + _arg1.missile); bomb = (bomb + _arg1.bomb); grow = (grow + _arg1.grow); speed = (speed + _arg1.speed); } public function changeByIndex(_arg1:int, _arg2:int){ setByIndex(_arg1, (getByIndex(_arg1) + _arg2)); } public function getRandomGene():int{ var _local1:Number; var _local2:int; _local1 = (Math.random() * total); _local2 = -1; while (_local1 > 0) { _local2++; _local1 = (_local1 - getByIndex(_local2)); }; return (_local2); } public function addArray(_arg1:Array){ var _local2:int; if ((((_arg1 == null)) || (!((_arg1.length == 6))))){ trace(("incorrect array added to DNA: " + _arg1)); return; }; _local2 = 0; while (_local2 < 6) { changeByIndex(_local2, _arg1[_local2]); _local2++; }; } public function setByIndex(_arg1:int, _arg2:int){ switch (_arg1){ case 0: armor = _arg2; break; case 1: bomb = _arg2; break; case 2: grow = _arg2; break; case 3: missile = _arg2; break; case 4: speed = _arg2; break; case 5: tech = _arg2; break; }; } public static function getIndexName(_arg1:int):String{ if (_arg1 == 0){ return ("armor"); }; if (_arg1 == 1){ return ("bomb"); }; if (_arg1 == 2){ return ("grow"); }; if (_arg1 == 3){ return ("missile"); }; if (_arg1 == 4){ return ("speed"); }; if (_arg1 == 5){ return ("tech"); }; return (null); } } }//package hexcelle
Section 16
//DropdownMenu (hexcelle.DropdownMenu) package hexcelle { import flash.display.*; import flash.events.*; import flash.filters.*; public class DropdownMenu extends Sprite { private var _isDown:Boolean; protected var parentMenu:DropdownMenu; private var _title:MenuItem; public var upSpeed:Number; private var _items:Array; public var downSpeed:Number; private var _width:Number; private var _itemSpacing:Number; public function DropdownMenu(_arg1:String){ var dropShadow:DropShadowFilter; var title = _arg1; super(); _items = new Array(); _title = new MenuItem(title); _title.backgroundColor = 8952200; _title.hoverBackgroundColor = 0x888888; addChild(_title); _title.show(); dropShadow = new DropShadowFilter(); var _local3 = dropShadow; with (_local3) { distance = 6; angle = 40; blurX = 6; blurY = 6; alpha = 0.6; }; this.filters = [dropShadow]; visible = false; _isDown = false; _itemSpacing = 16; _width = _title.width; downSpeed = 0.25; upSpeed = 0.2; } private function showSubmenu(_arg1:MouseEvent):void{ var _local2:MenuItem; _local2 = _items[_items.indexOf(_arg1.currentTarget)]; if (!_local2.submenu){ trace("item has lost its submenu"); return; }; _local2.submenu.x = _title.x; _local2.submenu.y = (_title.y + _title.height); _local2.submenu.show(); } private function onItemClick(_arg1:MouseEvent):void{ var _local2:MenuItem; _local2 = _items[_items.indexOf(_arg1.currentTarget)]; if (_local2.submenu){ dropUp(); } else { collapse(); }; } public function dropDown():void{ var _local1:*; if (_isDown){ return; }; removeItemListeners(); for each (_local1 in _items) { _local1.show(); _local1.addEventListener(Event.ENTER_FRAME, moveItemDown); _local1.addEventListener(MouseEvent.CLICK, onItemClick); }; _isDown = true; } private function moveItemUp(_arg1:Event):void{ var _local2:int; _local2 = _items.indexOf(_arg1.target); _arg1.target.y = (_arg1.target.y * (1 - upSpeed)); if (_arg1.target.y < 1){ _arg1.target.y = 0; _arg1.target.removeEventListener(Event.ENTER_FRAME, moveItemUp); }; } private function removeItemListeners():void{ var _local1:*; for each (_local1 in _items) { _local1.removeEventListener(Event.ENTER_FRAME, moveItemDown); _local1.removeEventListener(Event.ENTER_FRAME, moveItemUp); _local1.removeEventListener(MouseEvent.CLICK, onItemClick); }; } public function hide():void{ var _local1:*; if (!visible){ return; }; dropUp(); for each (_local1 in _items) { _local1.hide(); }; _title.hide(); _title.removeEventListener(MouseEvent.CLICK, onTitleClick); removeEventListener(Event.ENTER_FRAME, hiding); if (_items.length > 0){ addEventListener(Event.ENTER_FRAME, hiding); }; } public function indexOf(_arg1:Object):int{ return (_items.indexOf(_arg1)); } public function addItem(_arg1:String):MenuItem{ var _local2:MenuItem; _local2 = new MenuItem(_arg1); _items.push(_local2); if (_local2.width > _width){ resizeAll(_local2.width); }; _local2.width = _width; _local2.height = _itemSpacing; addChildAt(_local2, 0); return (_local2); } private function onTitleClick(_arg1:MouseEvent):void{ if (_isDown){ dropUp(); if (parentMenu){ parentMenu.show(); parentMenu.dropDown(); hide(); }; } else { collapseSubmenus(); dropDown(); }; } private function resizeAll(_arg1:Number):void{ var _local2:*; _width = _arg1; _title.width = _width; for each (_local2 in _items) { _local2.width = _width; }; } private function hiding(_arg1:Event):void{ if (!_items[0].visible){ visible = false; removeEventListener(Event.ENTER_FRAME, hiding); }; } public function collapseSubmenus():void{ var _local1:*; for each (_local1 in _items) { if (_local1.submenu){ _local1.submenu.hide(); _local1.submenu.collapseSubmenus(); }; }; } private function moveItemDown(_arg1:Event):void{ var _local2:int; var _local3:Number; _local2 = _items.indexOf(_arg1.target); _local3 = ((_local2 + (_title) ? 1 : 0) * _itemSpacing); _arg1.target.y = (_arg1.target.y + ((_local3 - _arg1.target.y) * downSpeed)); if (_arg1.target.y > (_local3 - 1)){ _arg1.target.y = _local3; _arg1.target.removeEventListener(Event.ENTER_FRAME, moveItemDown); }; } public function addItems(... _args):Array{ var _local2:Array; var _local3:*; _local2 = new Array(); for each (_local3 in _args) { if ((!(_local3) is String)){ } else { _local2.push(addItem(_local3)); }; }; return (_local2); } private function appear(_arg1:Event):void{ alpha = (alpha + ((1 - alpha) * 0.2)); if (alpha > 0.95){ removeEventListener(Event.ENTER_FRAME, appear); alpha = 1; }; } public function collapse():void{ if (parentMenu){ hide(); parentMenu.collapse(); } else { dropUp(); }; } public function changeItemText(_arg1:int, _arg2:String):void{ var _local3:MenuItem; _local3 = _items[_arg1]; _local3.text = _arg2; if (_local3.width < _width){ _local3.width = _width; } else { resizeAll(_local3.width); }; } private function disappear(_arg1:Event):void{ alpha = (alpha * 0.8); if (alpha < 0.05){ alpha = 0; removeEventListener(Event.ENTER_FRAME, disappear); }; } public function addSubmenu(_arg1:DropdownMenu):void{ var _local2:MenuItem; _local2 = _items[(_items.length - 1)]; if (_arg1.parentMenu){ trace("submenu already has a parent menu"); return; }; if (_local2.submenu){ trace("item already has a submenu"); return; }; _local2.submenu = _arg1; _arg1.parentMenu = this; _arg1.filters = null; addChildAt(_arg1, 0); _local2.addEventListener(MouseEvent.CLICK, showSubmenu); } public function get itemCount():int{ return (_items.length); } public function dropUp():void{ var _local1:*; if (!_isDown){ return; }; removeItemListeners(); for each (_local1 in _items) { _local1.addEventListener(Event.ENTER_FRAME, moveItemUp); _local1.hide(); }; _isDown = false; } public function show():void{ var _local1:*; visible = true; for each (_local1 in _items) { _local1.show(); }; _title.show(); _title.addEventListener(MouseEvent.CLICK, onTitleClick); if (parentMenu){ dropDown(); }; } } }//package hexcelle import flash.display.*; import flash.events.*; import flash.text.*; class MenuItem extends Sprite { private var _hover:Boolean; private var _height:Number; private var tf:TextField; public var submenu:DropdownMenu; private var _width:Number; public var backgroundColor:uint; public var hoverBackgroundColor:uint; private function MenuItem(_arg1:String){ backgroundColor = 0xDDDDDD; hoverBackgroundColor = 0xAAAAAA; _hover = false; visible = false; makeText(_arg1); } public function get text():String{ return (tf.text); } private function makeText(_arg1:String):void{ var _local2:TextFormat; var _local3:HexcelleFont; if (tf){ removeChild(tf); }; _local2 = new TextFormat(); _local3 = new HexcelleFont(); _local2.font = _local3.fontName; _local2.font = "Verdana"; _local2.color = 0x333333; _local2.size = 10; tf = new TextField(); tf.embedFonts = true; tf.selectable = false; tf.autoSize = TextFieldAutoSize.LEFT; _local2.align = TextFormatAlign.LEFT; tf.defaultTextFormat = _local2; tf.text = _arg1; addChild(tf); _width = tf.width; _height = tf.height; draw(); } public function hide():void{ removeEventListener(Event.ENTER_FRAME, appear); removeEventListener(Event.ENTER_FRAME, disappear); removeEventListener(MouseEvent.MOUSE_OVER, onOver); removeEventListener(MouseEvent.MOUSE_OUT, onOut); addEventListener(Event.ENTER_FRAME, disappear); } override public function set height(_arg1:Number):void{ _height = _arg1; draw(); } private function onOver(_arg1:MouseEvent):void{ _hover = true; draw(); } private function draw():void{ if (tf.text == ""){ _hover = false; }; var _local2 = graphics; with (_local2) { clear(); if (_hover){ beginFill(hoverBackgroundColor); } else { beginFill(backgroundColor); }; drawRect(0, 0, _width, _height); }; } public function set text(_arg1:String):void{ makeText(_arg1); } override public function set width(_arg1:Number):void{ _width = _arg1; draw(); } private function appear(_arg1:Event):void{ alpha = (alpha + ((1 - alpha) * 0.2)); if (alpha > 0.95){ removeEventListener(Event.ENTER_FRAME, appear); alpha = 1; }; } private function disappear(_arg1:Event):void{ alpha = (alpha * 0.8); if (alpha < 0.05){ visible = false; alpha = 0; removeEventListener(Event.ENTER_FRAME, disappear); }; } private function onOut(_arg1:MouseEvent):void{ _hover = false; draw(); } public function show():void{ removeEventListener(Event.ENTER_FRAME, appear); removeEventListener(Event.ENTER_FRAME, disappear); alpha = 0; visible = true; addEventListener(Event.ENTER_FRAME, appear); addEventListener(MouseEvent.MOUSE_OVER, onOver); addEventListener(MouseEvent.MOUSE_OUT, onOut); _hover = false; draw(); } }
Section 17
//Editor (hexcelle.Editor) package hexcelle { import flash.display.*; import flash.events.*; import flash.text.*; public class Editor extends UtilitySprite { private var armorText:TextField; private var _initialized:Boolean; private var skillText:TextField; private var _ui:Sprite; private var _celle:Celle; private var batches:Sprite; private var selectionSprite:HexSprite; private var selection:Hex; private var adjacentHexes:Array; private var typeHexes:Array; public function Editor(_arg1:Main):void{ _ui = new Sprite(); _arg1.ui.addChild(_ui); _initialized = false; } private function select(_arg1:Hex):void{ selection = _arg1; update(); removeAdjacents(); drawSelectionSprite(); makeAdjacents(); } private function init():void{ var _local1:TextField; var _local2:int; if (!_celle){ _celle = new Celle(); }; typeHexes = new Array(); _local2 = 0; while (_local2 < 6) { typeHexes.push(new HexSprite((stage.stageHeight / 13), _local2)); addChild(typeHexes[_local2]); typeHexes[_local2].x = 0; typeHexes[_local2].y = ((typeHexes[_local2].radius * 2) * (_local2 + 0.6)); typeHexes[_local2].addEventListener(MouseEvent.MOUSE_UP, typeMouseUp); _local1 = makeText(DNA.getIndexName(_local2), (typeHexes[_local2].radius + 5), (typeHexes[_local2].y - 9), _ui); if (_local2 == DNA.ARMOR){ armorText = _local1; }; _local2++; }; _local1 = makeText("save", 50, (stage.stageHeight - 20), _ui); _local1.addEventListener(MouseEvent.MOUSE_UP, save); _local1 = makeText("load", 100, (stage.stageHeight - 20), _ui); _local1.addEventListener(MouseEvent.MOUSE_UP, load); _local1 = makeText("batches", 150, (stage.stageHeight - 20), _ui); _local1.addEventListener(MouseEvent.MOUSE_UP, drawBatches); skillText = makeText("skill: ", 250, (stage.stageHeight - 20), _ui); selectionSprite = new HexSprite(_celle.hexSize, 7); selectionSprite.visible = false; _ui.addChild(selectionSprite); batches = new Sprite(); _ui.addChild(batches); _initialized = true; } private function makeAdjacents():void{ var _local1:HexSprite; var _local2:int; if (selection == null){ return; }; adjacentHexes = new Array(); _local2 = 0; while (_local2 < 6) { if (selection.links[_local2] == null){ _local1 = new HexSprite(_celle.hexSize, 6); _local1.position(selection.x, selection.y, _local2, _celle.hexSize); adjacentHexes.push(new Array(_local1, _local2)); addChild(_local1); _local1.addEventListener(MouseEvent.MOUSE_UP, adjacentMouseUp); }; _local2++; }; } private function applyInput(_arg1:Function):void{ var editor:Sprite; var screen:Sprite; var input:TextField; var finishText:Function; var finishMouse:Function; var f = _arg1; editor = this; screen = new Sprite(); var _local3 = screen.graphics; with (_local3) { beginFill(0, 0.8); drawRect(0, 0, stage.stageWidth, stage.stageHeight); endFill(); }; addChild(screen); input = makeInput("input", (stage.stageWidth / 5), ((stage.stageHeight / 2) - 4)); input.multiline = true; finishText = function (_arg1:TextEvent){ if (_arg1.text == "\n"){ editor.removeChild(screen); editor.removeChild(input); f(input.text); }; }; finishMouse = function (_arg1:MouseEvent){ editor.removeChild(screen); editor.removeChild(input); f(input.text); }; input.addEventListener(TextEvent.TEXT_INPUT, finishText); screen.addEventListener(MouseEvent.CLICK, finishMouse); } private function removeCelle():void{ select(null); _celle.removeEventListenerFromHexes(MouseEvent.MOUSE_UP, hexMouseUp); _celle.remove(); _celle = null; } public function get celle():Celle{ return (_celle); } public function hide(){ visible = false; _ui.visible = false; _celle.removeEventListenerFromHexes(MouseEvent.MOUSE_UP, hexMouseUp); stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); } public function giveFocus():void{ if (!_initialized){ init(); }; _celle.prepForPlay(); _celle.x = ((stage.stageWidth * 2) / 3); _celle.y = (stage.stageHeight / 2); _celle.hexSize = 12; _celle.addEventListenerToHexes(MouseEvent.MOUSE_UP, hexMouseUp); visible = true; _ui.visible = true; stage.addEventListener(KeyboardEvent.KEY_UP, keyboardUp); update(); } private function drawBatches(_arg1:MouseEvent):void{ _celle.drawBatches(batches); } private function typeMouseUp(_arg1:MouseEvent):void{ if (!selection){ return; }; selection.type = HexSprite(_arg1.target).type; update(); } private function adjacentMouseUp(_arg1:MouseEvent){ var _local2:*; var _local3:Hex; for each (_local2 in adjacentHexes) { if (_local2[0] == _arg1.target){ _local3 = _celle.addHex(selection, _local2[1]); _local3.type = selection.type; select(null); _local3.addSpriteEventListener(MouseEvent.MOUSE_UP, hexMouseUp); select(_local3); }; }; } private function hexMouseUp(_arg1:MouseEvent):void{ var _local2:Hex; _local2 = _celle.getHexSpriteOwner(Sprite(_arg1.currentTarget)); if (selection == _local2){ select(null); } else { select(_local2); }; } private function save(_arg1:MouseEvent){ var go:Function; var e = _arg1; update(); go = function (_arg1:String){ var _local2:CelleFile; _local2 = new CelleFile(); _local2.saveLocal(celle, _arg1); }; applyInput(go); } private function removeAdjacents():void{ var _local1:*; for each (_local1 in adjacentHexes) { removeChild(_local1[0]); _local1[0].removeEventListener(MouseEvent.MOUSE_UP, adjacentMouseUp); }; adjacentHexes = null; } public function set celle(_arg1:Celle):void{ _celle = _arg1; } private function drawSelectionSprite():void{ if (selection == null){ selectionSprite.visible = false; return; }; selectionSprite.visible = true; selectionSprite.x = selection.x; selectionSprite.y = selection.y; } private function update():void{ celle.draw(); armorText.text = "armor"; if (selection){ armorText.appendText((": " + selection.armor)); }; skillText.text = ("skill: " + (Math.round((celle.skill * 100)) / 100)); } private function load(_arg1:MouseEvent){ var go:Function; var e = _arg1; go = function (_arg1:String){ var _local2:CelleFile; var _local3:Celle; _local2 = new CelleFile(); _local3 = _local2.loadFromString(_arg1); removeCelle(); _celle = _local3; giveFocus(); }; applyInput(go); } private function keyboardUp(_arg1:KeyboardEvent){ switch (_arg1.keyCode){ case 46: case 32: if (!selection){ return; }; celle.removeHex(selection); select(null); break; case 38: _celle.y = (_celle.y + 5); break; case 37: _celle.x = (_celle.x + 5); break; case 40: _celle.y = (_celle.y - 5); break; case 39: _celle.x = (_celle.x - 5); break; }; update(); } } }//package hexcelle
Section 18
//Effect (hexcelle.Effect) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; public class Effect extends Sprite { protected var fadeSpeed:Number; protected var fading:Boolean; public var delay:uint; public function Effect(){ fadeSpeed = 0.8; fading = false; delay = 0; } public function fadeOut():void{ if (fading){ return; }; removeEventListener(Event.ENTER_FRAME, appearGo); removeEventListener(Event.ENTER_FRAME, fadeOutGo); fading = true; addEventListener(Event.ENTER_FRAME, fadeOutGo); } public function rotateV(_arg1:Vector, _arg2:Number):Vector{ var _local3:Vector; _local3 = new Vector(); _local3.x = ((Math.cos(_arg2) * _arg1.x) - (Math.sin(_arg2) * _arg1.y)); _local3.y = ((Math.sin(_arg2) * _arg1.x) + (Math.cos(_arg2) * _arg1.y)); return (_local3); } public function translate(_arg1:Vector):void{ x = (x + _arg1.x); y = (y + _arg1.y); } private function appearGo(_arg1:Event):void{ alpha = (alpha + ((1 - alpha) * (1 - fadeSpeed))); if (alpha > 0.95){ alpha = 1; removeEventListener(Event.ENTER_FRAME, appearGo); }; } public function remove():void{ visible = false; } public function appear():void{ removeEventListener(Event.ENTER_FRAME, appearGo); removeEventListener(Event.ENTER_FRAME, fadeOutGo); fading = false; alpha = 0.01; visible = true; addEventListener(Event.ENTER_FRAME, appearGo); } private function fadeOutGo(_arg1:Event):void{ alpha = (alpha * 0.8); if (alpha < 0.05){ visible = false; removeEventListener(Event.ENTER_FRAME, fadeOutGo); }; } public function update():void{ } public function rgb(_arg1:Number, _arg2:Number, _arg3:Number):Number{ var _local4:Number; if (_arg1 > 0xFF){ _arg1 = 0xFF; }; if (_arg2 > 0xFF){ _arg2 = 0xFF; }; if (_arg3 > 0xFF){ _arg3 = 0xFF; }; if (_arg1 < 0){ _arg1 = 0; }; if (_arg2 < 0){ _arg2 = 0; }; if (_arg3 < 0){ _arg3 = 0; }; _local4 = (((_arg1 << 16) | (_arg2 << 8)) | _arg3); return (_local4); } public function rotateVEquals(_arg1:Vector, _arg2:Number):Vector{ var _local3:Vector; _local3 = new Vector(); _local3.x = ((Math.cos(_arg2) * _arg1.x) - (Math.sin(_arg2) * _arg1.y)); _local3.y = ((Math.sin(_arg2) * _arg1.x) + (Math.cos(_arg2) * _arg1.y)); _arg1.copy(_local3); return (_arg1); } } }//package hexcelle
Section 19
//Evolver (hexcelle.Evolver) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; import flash.text.*; import flash.net.*; import flash.filters.*; public class Evolver extends UtilitySprite { private var _cv:Vector; private var _initialized:Boolean; private var _status:TextField; private var _batches:Sprite; private var _selectionSprite:HexSprite; private var _ui:Sprite; private var _comment:String; private var _typeAlphaOff:Number; private var _typeHexes:Array; private var _fx:FX; private var _mutaters:Array; private var _noEvo:Boolean; private var _spawns:int; private var _mutations:int; private var _hexSize:Number; private var _main:Main; private var _popups:Object; private var _typeAlphaOn:Number; private var _mutationsUsed:int; private var _abilities:Sprite; private var _bounds:Sprite; private var _spawnsUsed:int; private var _adjacentHexes:Array; private var _rebuild:Boolean; private var MINHEXES:int; private static var _celle:Celle; public static var newHexes:Array; public static var selection:Hex; public function Evolver(_arg1:Main):void{ _main = _arg1; _ui = new Sprite(); _main.ui.addChild(_ui); _initialized = false; } private function adjacentMouseOver(_arg1:MouseEvent):void{ _arg1.target.alpha = 1; GameSound.play("ui"); } private function select(_arg1:Hex):void{ selection = _arg1; removeAdjacents(); if (selection){ _cv = new Vector(); makeAdjacents(); _fx.ring(selection.x, selection.y, (_hexSize * 3), 1.5, 0xCCCCCC); }; update(); } private function typeMouseOver(_arg1:MouseEvent):void{ if (((!(selection)) || ((_arg1.target.alpha < 0.5)))){ return; }; _arg1.target.alpha = 1; } private function init():void{ var t:TextField; var i:int; var saveMenu:DropdownMenu; var saveSlot:Function; var loadMenu:DropdownMenu; var loadSlot:Function; var menu:DropdownMenu; _hexSize = 12; _typeHexes = new Array(6); _typeAlphaOn = 0.7; _typeAlphaOff = 0.1; i = 0; while (i < 6) { _typeHexes[i] = new HexSprite((stage.stageHeight / 13), i); _typeHexes[i].x = stage.stageWidth; _typeHexes[i].y = ((_typeHexes[i].radius * 2) * (i + 0.6)); addChild(_typeHexes[i]); _typeHexes[i].addEventListener(MouseEvent.MOUSE_UP, typeMouseUp); _typeHexes[i].addEventListener(MouseEvent.MOUSE_OVER, typeMouseOver); _typeHexes[i].addEventListener(MouseEvent.MOUSE_OUT, typeMouseOut); t = makeText(DNA.getIndexName(i), (-(_typeHexes[i].radius) - 45), -9, _typeHexes[i]); i = (i + 1); }; saveMenu = new DropdownMenu("choose a slot to save"); saveSlot = function (_arg1:MouseEvent):void{ var _local2:int; var _local3:CelleFile; _local2 = (saveMenu.indexOf(_arg1.currentTarget) + 1); _local3 = new CelleFile(); _local3.saveLocal(_celle, ("hexcelle_" + _local2)); _comment = ("celle saved to slot " + _local2); GameSound.play("ui"); }; i = 1; while (i <= 6) { saveMenu.addItem(("slot " + i)).addEventListener(MouseEvent.CLICK, saveSlot); i = (i + 1); }; loadMenu = new DropdownMenu("choose a slot to load"); loadSlot = function (_arg1:MouseEvent):void{ var _local2:int; var _local3:CelleFile; var _local4:Celle; _local2 = (loadMenu.indexOf(_arg1.currentTarget) + 1); _local3 = new CelleFile(); _local4 = _local3.loadLocal(("hexcelle_" + _local2)); if (_local4){ hide(); removeCelle(); _celle = _local4; giveFocus(false); _comment = ("celle loaded from slot " + _local2); } else { _comment = ("no celle saved in slot " + _local2); }; GameSound.play("ui"); }; i = 1; while (i <= 6) { loadMenu.addItem(("slot " + i)).addEventListener(MouseEvent.CLICK, loadSlot); i = (i + 1); }; menu = new DropdownMenu("evolver menu"); menu.addItem(""); menu.addItem("play").addEventListener(MouseEvent.CLICK, play); menu.addItem(""); menu.addItem("show celle batches").addEventListener(MouseEvent.CLICK, drawBatches); menu.addItem("list celle abilities").addEventListener(MouseEvent.CLICK, showAbilities); menu.addItem(""); menu.addItem("reset celle").addEventListener(MouseEvent.CLICK, reset); menu.addItem(""); menu.addItem("show all hints").addEventListener(MouseEvent.CLICK, showAllHints); if (MINHEXES > 50){ menu.addItem(""); menu.addItem("remove unlocked mode").addEventListener(MouseEvent.CLICK, resetKing); }; menu.x = 5; menu.y = 5; _ui.addChild(menu); menu.show(); _status = makeText("", 150, 5, _ui); _status.multiline = true; _comment = ""; _selectionSprite = new HexSprite(_hexSize, 7); _selectionSprite.visible = false; _ui.addChild(_selectionSprite); _bounds = new Sprite(); addChild(_bounds); _batches = new Sprite(); _ui.addChild(_batches); _popups = new Object(); _fx = new FX(); _ui.addChild(_fx); _initialized = true; } private function drawBounds(_arg1:Event):void{ var bWidth:Number; var bHeight:Number; var e = _arg1; bWidth = (_bounds.width - 1); bHeight = (_bounds.height - 1); _bounds.x = (_bounds.x + (((celle.x + celle.offset.x) - _bounds.x) * 0.2)); _bounds.y = (_bounds.y + (((celle.y + celle.offset.y) - _bounds.y) * 0.2)); bWidth = (bWidth + ((celle.bounds.x - bWidth) * 0.2)); bHeight = (bHeight + ((celle.bounds.y - bHeight) * 0.2)); var _local3 = _bounds.graphics; with (_local3) { clear(); lineStyle(1, 0xBBBBBB, 0.8); endFill(); drawRect(0, 0, bWidth, bHeight); }; if ((((((((Math.abs((_bounds.x - (celle.x + celle.offset.x))) < 1)) && ((Math.abs((_bounds.y - (celle.y + celle.offset.y))) < 1)))) && ((Math.abs((bWidth - celle.bounds.x)) < 1)))) && ((Math.abs((bHeight - celle.bounds.y)) < 1)))){ _bounds.removeEventListener(Event.ENTER_FRAME, drawBounds); }; } private function checkCelle():void{ var hasWeapon:Boolean; var hasGrow:Boolean; var checkWeapons:Function; var checkGrows:Function; hasWeapon = false; hasGrow = false; checkWeapons = function (_arg1:Hex):void{ if ((((_arg1.type == DNA.MISSILE)) || ((_arg1.type == DNA.BOMB)))){ hasWeapon = true; }; }; checkGrows = function (_arg1:Hex):void{ if (_arg1.type == DNA.GROW){ hasGrow = true; }; }; _celle.applyToHexes(checkWeapons); _celle.applyToHexes(checkGrows); if (((!(hasWeapon)) || (!(hasGrow)))){ if (!hasWeapon){ _comment = (_comment + "\nYour celle is missing weapons.\nConsider missile or bomb hexes."); }; if (((!(hasWeapon)) && (!(hasGrow)))){ _comment = (_comment + "\n"); }; if (!hasGrow){ _comment = (_comment + "\nYour celle has no grow hexes for evolution.\nConsider grow hexes."); }; statusAttention(); }; } private function makeAdjacents():void{ var _local1:HexSprite; var _local2:int; if (((((((_rebuild) && ((_celle.hexCount == MINHEXES)))) || (((!(_rebuild)) && ((((_spawns == 0)) || ((_spawnsUsed >= _spawns)))))))) || ((selection.freeLinks == 0)))){ return; }; if (_adjacentHexes){ trace("adjacent hexes already exist"); }; _adjacentHexes = new Array(); _local2 = 0; while (_local2 < 6) { if (selection.links[_local2] == null){ _local1 = new HexSprite(_celle.hexSize, 6); _local1.alpha = 0.5; _local1.position(selection.x, selection.y, _local2, _celle.hexSize); _adjacentHexes.push(new Array(_local1, _local2)); addChild(_local1); _local1.addEventListener(MouseEvent.MOUSE_UP, adjacentMouseUp); _local1.addEventListener(MouseEvent.MOUSE_OVER, adjacentMouseOver); _local1.addEventListener(MouseEvent.MOUSE_OUT, adjacentMouseOut); _fx.magnet(_local1, 2.5, (_hexSize * 4), 10, 0x222222, _hexSize); }; _local2++; }; } private function changeType(_arg1:int):void{ var _local2:Boolean; var _local3:*; var _local4:HexSprite; if ((((_arg1 < 0)) || ((_arg1 > 5)))){ return; }; if ((((_typeHexes[_arg1].alpha < 0.5)) || (!(selection)))){ return; }; if (((!(_rebuild)) && ((newHexes.indexOf(selection) < 0)))){ _local2 = true; for each (_local3 in _mutaters) { if (_local3[0].hex == selection){ _local2 = false; }; }; if (_local2){ _mutationsUsed++; _local4 = new HexSprite(_celle.hexSize, 16, selection); _local4.x = selection.x; _local4.y = selection.y; _ui.addChild(_local4); _local4.addEventListener(MouseEvent.MOUSE_UP, mutate); _mutaters.push([_local4, selection.type]); }; }; selection.type = _arg1; _fx.ring(selection.x, selection.y, (_hexSize * 4), 4.5, HexSprite.typeColor(selection.type)); checkCelle(); update(); } private function removeCelle():void{ select(null); _celle.removeEventListenerFromHexes(MouseEvent.MOUSE_UP, hexMouseUp); _celle.remove(); _celle = null; } private function play(_arg1:MouseEvent):void{ GameSound.play("ui"); if (((((_rebuild) && ((_celle.hexCount < MINHEXES)))) && ((MINHEXES < 50)))){ GameSound.play("error"); _comment = (("Build your celle up to " + MINHEXES) + " hexes before playing."); statusAttention(); return; }; _main.switchScreen("player"); } public function hide(){ var _local1:*; var _local2:*; visible = false; _ui.visible = false; select(null); _celle.removeEventListenerFromHexes(MouseEvent.MOUSE_UP, hexMouseUp); stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); stage.removeEventListener(MouseEvent.CLICK, update); for each (_local1 in _mutaters) { _ui.removeChild(_local1[0]); _local1[0].removeEventListener(MouseEvent.MOUSE_UP, mutate); }; newHexes = null; for each (_local2 in _popups) { _local2.hide(); }; removeEventListener(Event.ENTER_FRAME, frameUpdate); } private function statusAttention():void{ var counter:int; var blinker:Function; counter = 0; blinker = function (_arg1:Event):void{ counter++; if ((counter % 2) == 0){ _status.background = !(_status.background); }; if (counter > 15){ _status.background = false; removeEventListener(Event.ENTER_FRAME, blinker); }; }; _status.background = true; _status.backgroundColor = 0xBBBBBB; addEventListener(Event.ENTER_FRAME, blinker); } public function giveFocus(_arg1:Boolean=true):void{ var factor:Number; var growHexes:int; var counter:Function; var evolve = _arg1; checkMinHexes(); if (!_initialized){ init(); }; if (!_celle){ _celle = new Celle(); }; _celle.prepForPlay(); _celle.x = (stage.stageWidth / 3); _celle.y = (stage.stageHeight / 2); _cv = new Vector(); _celle.hexSize = _hexSize; visible = true; _ui.visible = true; stage.addEventListener(KeyboardEvent.KEY_UP, keyboardUp); addEventListener(Event.ENTER_FRAME, frameUpdate); _rebuild = (((_celle.hexCount < MINHEXES)) || (((!(evolve)) && ((_celle.hexCount <= MINHEXES))))); _celle.addEventListenerToHexes(MouseEvent.MOUSE_UP, hexMouseUp); if ((((_celle.hexCount >= MINHEXES)) && (evolve))){ growHexes = 0; counter = function (_arg1:Hex):void{ if (_arg1.type == DNA.GROW){ growHexes++; }; }; _celle.applyToHexes(counter); factor = ((_celle.core.type)==DNA.GROW) ? 0.5 : 0.35; _mutations = Math.floor(Math.max(1, (growHexes * factor))); factor = ((_celle.core.type)==DNA.GROW) ? 0.6 : 0.35; _spawns = Math.ceil((growHexes * factor)); if (_spawns == 0){ _spawns = 1; }; }; _spawnsUsed = 0; newHexes = new Array(); _mutationsUsed = 0; _mutaters = new Array(); if (!_rebuild){ _comment = "spawns and mutations may only\nbe used during this evolution"; }; update(); statusAttention(); } private function reset(_arg1:MouseEvent):void{ var _local2:*; for each (_local2 in _mutaters) { _ui.removeChild(_local2[0]); _local2[0].removeEventListener(MouseEvent.MOUSE_UP, mutate); _local2[0].hex.type = _local2[1]; }; _mutaters = new Array(); _mutationsUsed = 0; if (newHexes.length == 0){ return; }; select(null); celle.removeHexes(newHexes); newHexes = new Array(); _spawnsUsed = 0; update(); GameSound.play("evolve"); } private function removeAdjacents():void{ var _local1:*; for each (_local1 in _adjacentHexes) { _fx.shards(_local1[0].x, _local1[0].y, 2.5, 9, 6, 0x222222); removeChild(_local1[0]); _local1[0].removeEventListener(MouseEvent.MOUSE_UP, adjacentMouseUp); _local1[0].removeEventListener(MouseEvent.MOUSE_OVER, adjacentMouseOver); _local1[0].removeEventListener(MouseEvent.MOUSE_OUT, adjacentMouseOut); }; _adjacentHexes = null; } private function updatePopups():void{ var _local1:Array; var _local2:*; var _local3:Boolean; for each (_local2 in _popups) { _local2.hide(); }; if (((((_rebuild) && ((celle.hexCount == 1)))) && (!(_adjacentHexes)))){ if (_popups.loneCore){ _popups.loneCore.show(); } else { _popups.loneCore = new Popup("Click your celle's core\nhex to begin building.\n(The core is the hex with a\ndark circle in the middle.)", celle.core.x, celle.core.y, _ui); _popups.loneCore.offset = 50; _popups.loneCore.angle = 1; }; _popups.loneCore.x = celle.core.x; _popups.loneCore.y = celle.core.y; if (_popups.hint){ _popups.hint.show(); } else { _popups.hint = new Popup("You can remove these hints\nby clicking them.", celle.core.x, celle.core.y, _ui); _popups.hint.offset = 50; _popups.hint.angle = -1; }; _popups.hint.x = celle.core.x; _popups.hint.y = celle.core.y; } else { if (((((((_rebuild) && ((celle.hexCount < MINHEXES)))) && (_adjacentHexes))) && (selection))){ if (_popups.adjacents){ _popups.adjacents.show(); } else { _popups.adjacents = new Popup("Click one of the adjacent hexes\nto spawn a new hex there.", selection.x, selection.y, _ui); _popups.adjacents.offset = 50; _popups.adjacents.angle = 1; }; _popups.adjacents.x = selection.x; _popups.adjacents.y = selection.y; if (_popups.types){ _popups.types.show(); } else { _popups.types = new Popup("Click one of these colored\ntypes to change the selected\nhex's type.", (stage.stageWidth - 10), 20, _ui); _popups.types.offset = 100; _popups.types.angle = 3; }; } else { if (((((_rebuild) && ((celle.hexCount == MINHEXES)))) && (selection))){ if (_popups.deleter){ _popups.deleter.show(); } else { _popups.deleter = new Popup("Press the delete key\nto remove a hex.\n(This CANNOT be undone.)", selection.x, selection.y, _ui); _popups.deleter.offset = 100; _popups.deleter.angle = -2; }; _popups.deleter.x = selection.x; _popups.deleter.y = selection.y; if (_popups.player){ _popups.player.show(); } else { _popups.player = new Popup("Click play from the\nmenu when you are ready!", 100, 20, _ui); _popups.player.offset = 25; _popups.player.angle = 1; }; if (_popups.core){ _popups.core.show(); } else { _popups.core = new Popup("Remember to protect your\ncelle's core. If this\nis destroyed, your\nentire celle will die.", celle.core.x, celle.core.y, _ui); _popups.core.offset = 75; _popups.core.angle = 1; }; _popups.core.x = celle.core.x; _popups.core.y = celle.core.y; } else { if (((!(_rebuild)) && (!(selection)))){ if (_mutaters.length > 0){ if (_popups.mutater){ _popups.mutater.show(); } else { _popups.mutater = new Popup("Click a hex\nhighlighted in white\nto mutate that hex.", _mutaters[0][0].x, _mutaters[0][0].y, _ui); _popups.mutater.offset = 75; _popups.mutater.angle = 1; }; _popups.mutater.x = _mutaters[0][0].x; _popups.mutater.y = _mutaters[0][0].y; } else { if (_mutationsUsed < _mutations){ if (_popups.mutateHint){ _popups.mutateHint.show(); } else { _popups.mutateHint = new Popup("You have mutations to mutate\nany hex in your celle.", celle.core.x, celle.core.y, _ui); _popups.mutateHint.offset = 75; _popups.mutateHint.angle = 1; }; _popups.mutateHint.x = celle.core.x; _popups.mutateHint.y = celle.core.y; }; }; if (_spawnsUsed < _spawns){ if (_popups.evos){ _popups.evos.show(); } else { _popups.evos = new Popup("Click a hex to begin\nspawning a new one.", celle.core.x, celle.core.y, _ui); _popups.evos.offset = 100; _popups.evos.angle = -1; }; _popups.evos.x = celle.core.x; _popups.evos.y = celle.core.y; }; } else { if (selection){ if (newHexes.length > 0){ if (_popups.resetter){ _popups.resetter.show(); } else { _popups.resetter = new Popup("Click reset from the menu\nto undo any evolutions or\nmutations made this turn.", 20, 20, _ui); _popups.resetter.offset = 75; _popups.resetter.angle = 1; }; }; _local3 = false; for each (_local1 in _mutaters) { if (selection == _local1[0].hex){ _local3 = true; }; }; if (_local3){ if (_popups.mutation){ _popups.mutation.show(); } else { _popups.mutation = new Popup("Change the type of this hex\nby clicking one of the types\non the right side (mutate).", selection.x, selection.y, _ui); _popups.mutation.offset = 75; _popups.mutation.angle = 2; }; _popups.mutation.x = selection.x; _popups.mutation.y = selection.y; } else { if (newHexes.indexOf(selection) >= 0){ if (_popups.newHex){ _popups.newHex.show(); } else { _popups.newHex = new Popup("Spawned hexes can take the\ntype of only adjacent hexes.", selection.x, selection.y, _ui); _popups.newHex.offset = 75; _popups.newHex.angle = -1; }; _popups.newHex.x = selection.x; _popups.newHex.y = selection.y; } else { if (_mutationsUsed < _mutations){ if (_popups.newMutate){ _popups.newMutate.show(); } else { _popups.newMutate = new Popup("This hex may mutate into any type.\nJust click one of the colored\ntypes on the right.", selection.x, selection.y, _ui); _popups.newMutate.offset = 75; _popups.newMutate.angle = 1; }; _popups.newMutate.x = selection.x; _popups.newMutate.y = selection.y; }; }; }; if (_adjacentHexes){ if (_popups.evo){ _popups.evo.show(); } else { _popups.evo = new Popup("Click one of the adjacent\nhexes to spawn\na new hex there.", selection.x, selection.y, _ui); _popups.evo.offset = 75; _popups.evo.angle = -1; }; _popups.evo.x = selection.x; _popups.evo.y = selection.y; }; }; }; }; }; }; } private function checkComposition():void{ var freeLinks:int; var countFreeLinks:Function; freeLinks = 0; countFreeLinks = function (_arg1:Hex):void{ freeLinks = (freeLinks + _arg1.freeLinks); }; celle.applyToHexes(countFreeLinks); if ((freeLinks / celle.hexCount) < 1.2){ _comment = (_comment + "\nDensely packed celles may implode. Consider growing appendages."); }; } private function resetKing(_arg1:MouseEvent):void{ var _local2:SharedObject; _local2 = SharedObject.getLocal("HexcelleGame"); _local2.data.win = false; _local2.flush(); _comment = "unlocked mode will be removed next\ntime you enter the evolver"; update(); statusAttention(); } private function frameUpdate(_arg1:Event):void{ var _local2:Array; _fx.update(); if (_cv){ _celle.x = (_celle.x + _cv.x); _celle.y = (_celle.y + _cv.y); _cv.multEquals(0.9); if (_cv.magnitude() < 1){ _cv = null; for each (_local2 in _mutaters) { _local2[0].x = _local2[0].hex.x; _local2[0].y = _local2[0].hex.y; }; for each (_local2 in _mutaters) { _local2[0].x = _local2[0].hex.x; _local2[0].y = _local2[0].hex.y; }; update(); } else { celle.build(); updatePopups(); if (!_bounds.hasEventListener(Event.ENTER_FRAME)){ drawBounds(null); }; for each (_local2 in _mutaters) { _local2[0].x = _local2[0].hex.x; _local2[0].y = _local2[0].hex.y; }; }; }; } private function mutate(_arg1:MouseEvent):void{ var _local2:Hex; _local2 = HexSprite(_arg1.target).hex; select(_local2); GameSound.play("ui"); } private function hexMouseUp(_arg1:MouseEvent):void{ var _local2:Hex; checkCelle(); _local2 = _celle.getHexSpriteOwner(Sprite(_arg1.currentTarget)); if (selection == _local2){ select(null); } else { select(_local2); }; GameSound.play("ui"); } private function selectionGo(_arg1:Event):void{ var _local2:Number; _local2 = 0.2; _selectionSprite.rotation = (_selectionSprite.rotation + 2); _selectionSprite.x = (_selectionSprite.x + ((selection.x - _selectionSprite.x) * _local2)); _selectionSprite.y = (_selectionSprite.y + ((selection.y - _selectionSprite.y) * _local2)); } private function drawBatches(_arg1:MouseEvent):void{ _celle.drawBatches(_batches); GameSound.play("ui"); } private function typeMouseUp(_arg1:MouseEvent):void{ if (!(_arg1.target is HexSprite)){ return; }; GameSound.play("ui"); changeType(HexSprite(_arg1.target).type); } private function adjacentMouseUp(_arg1:MouseEvent):void{ var _local2:*; var _local3:Hex; for each (_local2 in _adjacentHexes) { if (_local2[0] == _arg1.target){ _local3 = _celle.addHex(selection, _local2[1]); _local3.type = selection.type; select(null); _local3.addSpriteEventListener(MouseEvent.MOUSE_UP, hexMouseUp); _local3.sprite.scaleX = 3; _local3.sprite.scaleY = _local3.sprite.scaleX; _local3.sprite.addEventListener(Event.ENTER_FRAME, newHexGo); newHexes.push(_local3); if (!_rebuild){ _spawnsUsed++; }; checkCelle(); select(_local3); GameSound.play("addnewhex"); }; }; } public function drawSelectionSprite():void{ _selectionSprite.removeEventListener(Event.ENTER_FRAME, selectionGo); if (selection == null){ _selectionSprite.visible = false; _selectionSprite.x = 0; _selectionSprite.y = 0; return; }; _selectionSprite.visible = true; _selectionSprite.addEventListener(Event.ENTER_FRAME, selectionGo); } private function typeMouseOut(_arg1:MouseEvent):void{ if (((!(selection)) || ((_arg1.target.alpha < 0.5)))){ return; }; _arg1.target.alpha = _typeAlphaOn; } private function showAllHints(_arg1:MouseEvent):void{ var _local2:*; for each (_local2 in _popups) { _local2.unhide(); }; GameSound.play("ui"); update(); } private function adjacentMouseOut(_arg1:MouseEvent):void{ _arg1.target.alpha = 0.5; } private function showAbilities(_arg1:MouseEvent):void{ var t:TextField; var _abilitiesList:Array; var a:*; var blur:BlurFilter; var undraw:Function; var e = _arg1; _abilities = new Sprite(); _main.addChild(_abilities); var _local3 = _abilities.graphics; with (_local3) { beginFill(0xFFFFFF, 0.6); drawRect(0, 0, stage.stageWidth, stage.stageHeight); endFill(); }; t = makeText("Abilities:", 5, 20, _abilities); t = makeText("", 50, 40, _abilities); t.multiline = true; _abilitiesList = _celle.abilities; for each (a in _abilitiesList) { t.appendText((a + "\n")); }; if (_abilitiesList.length == 0){ t.appendText("Your celle has no _abilities. That's terribly unfortunate."); if (_celle.hexCount < MINHEXES){ t.appendText("\n\nYou can still add more hexes, which you better do before playing!"); } else { t.appendText("\n\n(The types of hexes and their arrangement relative to \neach other determine what _abilities the celle will have.)"); }; }; blur = new BlurFilter(); blur.blurX = 4; blur.blurY = 4; blur.quality = BitmapFilterQuality.HIGH; _main.gameSprite.filters = [blur]; _main.gameSprite.cacheAsBitmap = true; _main.ui.filters = [blur]; _main.ui.cacheAsBitmap = true; undraw = function (_arg1:MouseEvent):void{ _main.removeChild(_abilities); _main.gameSprite.filters = null; _main.gameSprite.cacheAsBitmap = false; _main.ui.filters = null; _main.ui.cacheAsBitmap = false; GameSound.play("ui"); }; _abilities.addEventListener(MouseEvent.CLICK, undraw); GameSound.play("ui"); } public function update(_arg1:MouseEvent=null):void{ var _local2:HexSprite; var _local3:Array; var _local4:int; var _local5:*; celle.draw(); checkComposition(); _local4 = 0; while (_local4 < 6) { _typeHexes[_local4].alpha = (((_rebuild) && (selection))) ? _typeAlphaOn : _typeAlphaOff; if (((!(_rebuild)) && (selection))){ if (newHexes.indexOf(selection) >= 0){ if (selection.pool.getByIndex(_local4) > 0){ _typeHexes[_local4].alpha = _typeAlphaOn; }; for each (_local5 in selection.links) { if (_local5){ for each (_local3 in _mutaters) { if (_local3[0].hex == _local5){ _typeHexes[_local4].alpha = _typeAlphaOn; }; }; }; }; } else { if (_mutationsUsed < _mutations){ _typeHexes[_local4].alpha = _typeAlphaOn; } else { for each (_local3 in _mutaters) { if (_local3[0].hex == selection){ _typeHexes[_local4].alpha = _typeAlphaOn; }; }; }; }; }; _local4++; }; drawSelectionSprite(); for each (_local3 in _mutaters) { _local3[0].visible = !((_local3[0].hex == selection)); }; if (!_bounds.hasEventListener(Event.ENTER_FRAME)){ _bounds.addEventListener(Event.ENTER_FRAME, drawBounds); }; updatePopups(); if (!_rebuild){ _status.text = ((((((("Spawns: " + _spawnsUsed) + "/") + _spawns) + "\nMutations: ") + _mutationsUsed) + "/") + _mutations); } else { if (_celle.hexCount < MINHEXES){ _status.text = (("Rebuild your celle up to " + MINHEXES) + " hexes."); } else { _status.text = "Click play from the menu!"; }; }; if (_comment != ""){ _status.appendText(("\n\n" + _comment)); _comment = ""; }; } private function keyboardUp(_arg1:KeyboardEvent){ var _local2:Number; var _local3:int; if (!_cv){ _cv = new Vector(); }; _local2 = 5; switch (_arg1.keyCode){ case 46: case 109: if (!selection){ return; }; celle.removeHex(selection); _fx.shards(selection.x, selection.y, 2.5, 9, 6, HexSprite.typeColor(selection.type)); _local3 = 0; while (_local3 < newHexes.length) { if (!celle.hasHex(newHexes[_local3])){ if (newHexes[_local3] != selection){ _fx.shards(newHexes[_local3].x, newHexes[_local3].y, 2.5, 9, 6, HexSprite.typeColor(newHexes[_local3].type)); }; newHexes.splice(_local3, 1); _spawnsUsed--; _local3--; }; _local3++; }; checkCelle(); select(null); GameSound.play("hexlost"); break; case 49: case 65: changeType(0); break; case 50: case 66: changeType(1); break; case 51: case 71: changeType(2); break; case 52: case 77: changeType(3); break; case 53: case 83: changeType(4); break; case 54: case 84: changeType(5); break; case 38: GameSound.play("ui"); select(null); _cv.y = (_cv.y + _local2); break; case 37: GameSound.play("ui"); select(null); _cv.x = (_cv.x + _local2); break; case 40: GameSound.play("ui"); select(null); _cv.y = (_cv.y - _local2); break; case 39: GameSound.play("ui"); select(null); _cv.x = (_cv.x - _local2); break; case 36: GameSound.play("ui"); select(null); _celle.x = (stage.stageWidth / 3); _celle.y = (stage.stageHeight / 2); update(); break; case 32: if ((((_batches.width == 0)) && ((_batches.height == 0)))){ GameSound.play("ui"); _celle.drawBatches(_batches); }; break; }; } private function checkMinHexes():void{ var _local1:SharedObject; _local1 = SharedObject.getLocal("HexcelleGame"); if (_local1.size == 0){ MINHEXES = 4; return; }; if (!_local1.data.win){ MINHEXES = 4; } else { MINHEXES = 1000; }; } public static function newHexGo(_arg1:Event):void{ _arg1.target.scaleX = (_arg1.target.scaleX - ((_arg1.target.scaleX - 1) * 0.2)); _arg1.target.scaleY = _arg1.target.scaleX; if (Math.abs((1 - _arg1.target.scaleX)) < 0.05){ _arg1.target.removeEventListener(Event.ENTER_FRAME, newHexGo); _arg1.target.scaleX = 1; _arg1.target.scaleY = 1; }; } public static function set celle(_arg1:Celle):void{ _celle = _arg1; } public static function get celle():Celle{ return (_celle); } } }//package hexcelle
Section 20
//Faun (hexcelle.Faun) package hexcelle { import org.cove.ape.*; public class Faun extends UtilityWheelParticle { public var breaks:uint; private var _group:Fauna; public function Faun(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Fauna){ super(_arg1, _arg2, _arg3); breaks = 0; _group = _arg4; draw(); } public function draw():void{ var _local1:HexSprite; _local1 = new HexSprite(radius, 8); setDisplay(_local1); sprite.name = "faun sprite"; } public function hit(_arg1:CircleParticle, _arg2:Player):void{ var _local3:Vector; var _local4:Vector; var _local5:Vector; var _local6:Vector; var _local7:VectorForce; var _local8:VectorForce; var _local9:VectorForce; var _local10:Number; var _local11:Number; var _local12:Faun; var _local13:Faun; var _local14:Faun; var _local15:Food; var _local16:Food; _local3 = _arg1.velocity; if ((((_local3.x == 0)) && ((_local3.y == 0)))){ _local3.x = ((Math.random() * 2) - 1); _local3.y = ((Math.random() * 2) - 1); }; _local3.normalizeEquals(); _local4 = new Vector(_local3.x, _local3.y); _local5 = new Vector(-(_local3.y), _local3.x); _local6 = new Vector(_local3.y, -(_local3.x)); if ((_arg1 is Missile)){ _local3.multEquals((Missile(_arg1).power * 5)); } else { if ((_arg1 is Bomb)){ _local3.multEquals((Bomb(_arg1).power * 5)); } else { _local3.multEquals(((Math.random() * 5) + 5)); }; }; _local7 = new VectorForce(true, _local3.x, _local3.y); _local8 = new VectorForce(true, -(_local3.y), _local3.x); _local9 = new VectorForce(true, _local3.y, -(_local3.x)); if (breaks == 0){ _local10 = (radius / 3); _local11 = (_local10 + 3); _local4.multEquals(_local11); _local12 = _group.spawn((x + _local4.x), (y + _local4.y), _local10); _local5.multEquals(_local11); _local13 = _group.spawn((x + _local5.x), (y + _local5.y), _local10); _local6.multEquals(_local11); _local14 = _group.spawn((x + _local6.x), (y + _local6.y), _local10); _local12.addForce(_local7); _local13.addForce(_local8); _local14.addForce(_local9); _local12.breaks = 1; _local13.breaks = 1; _local14.breaks = 1; } else { if (((_arg2.testOnScreen(this)) && (_arg2.celle.core.collidable))){ _local15 = _group.player.foods.makeFood(x, y, "faun"); _local16 = _group.player.foods.makeFood(x, y, "faun"); _local15.addForce(_local8); _local16.addForce(_local9); }; }; _group.removeParticle(this); if (sprite.parent){ sprite.parent.removeChild(sprite); }; if (_arg2.testOnScreen(this)){ if (_group.player.fxNo > 0){ _group.player.fx.shards(x, y, (radius / 4), 4, 10, 0x444444); }; GameSound.play("faun"); }; } } }//package hexcelle
Section 21
//Fauna (hexcelle.Fauna) package hexcelle { import org.cove.ape.*; public class Fauna extends Group { public var count:uint; private var _player:Player; public function Fauna(_arg1:Player, _arg2:uint=10){ var _local3:int; super(); _player = _arg1; this.count = _arg2; _local3 = 0; while (_local3 < _arg2) { spawn(((_player.randomBoundaryX() - 100) + (Math.random() * 200)), ((_player.randomBoundaryY() - 100) + (Math.random() * 200))); _local3++; }; APEngine.addGroup(this); collideInternal = true; } public function update():void{ var _local1:*; var _local2:Vector; for each (_local1 in particles) { if (_player.testOutOfBounds(_local1)){ removeParticle(_local1); if (APEngine.container.contains(_local1.sprite)){ APEngine.container.removeChild(_local1.sprite); }; }; }; if (particles.length < count){ _local2 = _player.randomEdgeV(); spawn(_local2.x, _local2.y); }; } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in particles) { _local2.translate(_arg1); }; } public function get player():Player{ return (_player); } public function spawn(_arg1:Number=0, _arg2:Number=0, _arg3:Number=15):Faun{ var _local4:Faun; _local4 = new Faun(_arg1, _arg2, ((Math.random() * 5) + _arg3), this); addParticle(_local4); return (_local4); } public function set visible(_arg1:Boolean):void{ var _local2:*; for each (_local2 in particles) { _local2.visible = _arg1; }; } } }//package hexcelle
Section 22
//Food (hexcelle.Food) package hexcelle { import flash.display.*; public class Food extends UtilityWheelParticle { public var calories:int; public var type:String; public function Food(_arg1:Number, _arg2:Number, _arg3:String="faun", _arg4:int=1){ super(_arg1, _arg2, 3); type = _arg3; this.calories = _arg4; draw(); } public function draw():void{ var fSprite:Sprite; fSprite = new Sprite(); var _local2 = fSprite.graphics; with (_local2) { if (type == "faun"){ beginFill(873458, 1); } else { if (type == "boss"){ beginFill(0xF00000, 1); } else { beginFill(15790335, 1); }; }; lineStyle(2, 12320529); drawCircle(0, 0, (radius - 1)); endFill(); }; setDisplay(fSprite); sprite.name = "food sprite"; } } }//package hexcelle
Section 23
//Foods (hexcelle.Foods) package hexcelle { import org.cove.ape.*; public class Foods extends Group { private var _player:Player; public function Foods(_arg1:Player){ _player = _arg1; APEngine.addGroup(this); collideInternal = false; } public function update():void{ var _local1:*; var _local2:Food; var _local3:Vector; var _local4:int; var _local5:int; var _local6:uint; for each (_local1 in particles) { if (_player.testOutOfBounds(_local1)){ destroy(_local1); } else { if (_player.others.count == 0){ _local2 = Food(_local1); if (((!((_local2.type == "faun"))) || (_player.testOnScreen(_local1)))){ _local3 = _player.celle.position.minus(_local1.position).normalize().multEquals(2); _local1.addForce(new VectorForce(true, _local3.x, _local3.y)); if (particles.length < 50){ if (_player.fxNo == 0){ _local4 = 10; } else { if (_player.fxNo == 1){ _local4 = 6; } else { _local4 = 3; }; }; if (((((_player.frameCount % _local4) == 0)) && (_player.testOnScreen(_local1)))){ _local5 = (10 - Math.floor((particles.length / 5))); if (_local2.type == "faun"){ _local6 = 4482628; } else { if (_local2.type == "celle"){ _local6 = 11035816; } else { _local6 = 15737378; }; }; _player.fx.ghost(_local1.sprite, _local5, 10079385, _local6); }; }; }; }; }; }; } public function removeAll():void{ while (particles.length > 0) { destroy(particles[0]); }; } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in particles) { _local2.translate(_arg1); }; } public function makeFood(_arg1:Number, _arg2:Number, _arg3:String, _arg4:int=1):Food{ var _local5:Food; _local5 = new Food(_arg1, _arg2, _arg3, _arg4); addParticle(_local5); _local5.addEventListener(CollisionEvent.COLLIDE, collide); return (_local5); } public function destroy(_arg1:Food):void{ _arg1.removeEventListener(CollisionEvent.COLLIDE, collide); removeParticle(_arg1); if (_arg1.sprite.parent){ _arg1.sprite.parent.removeChild(_arg1.sprite); }; } public function set visible(_arg1:Boolean):void{ var _local2:*; for each (_local2 in particles) { _local2.visible = _arg1; }; } public function collide(_arg1:CollisionEvent):void{ var _local2:Food; _local2 = Food(_arg1.target); destroy(_local2); _player.foodCount = (_player.foodCount + _local2.calories); if (_local2.type == "faun"){ GameSound.play("foodfaun"); } else { GameSound.play("foodhex"); }; if (_player.fxNo > 0){ _player.fx.ring(_local2.x, _local2.y, 25, 1, 12320529); }; if (_player.fxNo > 1){ _player.fx.movingDot(_local2.x, _local2.y, _player.stage.stageWidth, _player.stage.stageHeight, 10079249, 3, 0.1); }; } } }//package hexcelle
Section 24
//FX (hexcelle.FX) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; public class FX extends Sprite { private var effects:Array; public function FX(){ effects = new Array(); } public function shootingSprite(_arg1:Sprite, _arg2:Vector, _arg3:Number=10):Effect{ return (addEffect(new ShootingSprite(_arg1, _arg2, _arg3))); } public function implode(_arg1:Number, _arg2:Number, _arg3:Number):Effect{ return (addEffect(new Implode(_arg1, _arg2, _arg3))); } public function movingDot(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint=0x888888, _arg6:Number=2, _arg7:Number=0.2):Effect{ return (addEffect(new MovingDot(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7))); } public function line(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number=1):Effect{ return (addEffect(new Line(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function boundary(_arg1:Object, _arg2:Number, _arg3:Number=1, _arg4:uint=0x888888, _arg5:Number=1):Effect{ return (addEffect(new Boundary(_arg1, _arg2, _arg3, _arg4, _arg5))); } public function textFloat(_arg1:String, _arg2:Number, _arg3:Number, _arg4:uint):Effect{ return (addEffect(new MovingText(_arg1, _arg2, _arg3, _arg4, true))); } public function ring(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=1, _arg5:uint=0x888888, _arg6:Number=1, _arg7:Boolean=true):Effect{ return (addEffect(new Ring(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7))); } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in effects) { _local2.translate(_arg1); }; } public function magnet(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:int, _arg5:uint, _arg6:Number=0){ return (addEffect(new Magnet(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function shardSpray(_arg1:Number, _arg2:Number, _arg3:Vector, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:int, _arg8:uint, _arg9:Number=1):Effect{ return (addEffect(new ShardSpray(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9))); } public function clash(_arg1:Number, _arg2:Number, _arg3:Number=50, _arg4:Number=10, _arg5:int=4, _arg6:uint=0xBBBBBB){ return (addEffect(new Clash(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function shards(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:uint):Effect{ return (addEffect(new Shards(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function removeAll():void{ while (effects.length > 0) { removeChild(effects[0]); effects.shift(); }; } public function bolts(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int):Effect{ return (addEffect(new Bolts(_arg1, _arg2, _arg3, _arg4))); } public function confetti(_arg1:Number, _arg2:Number, _arg3:Vector, _arg4:Number, _arg5:Number, _arg6:int):Effect{ return (addEffect(new Confetti(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function addEffect(_arg1:Effect):Effect{ effects.push(_arg1); addChild(_arg1); return (_arg1); } public function ghost(_arg1:Object, _arg2:int, _arg3:uint=0x999999, _arg4:uint=0xAAAAAA):Effect{ return (addEffect(new Ghost(_arg1, _arg2, _arg3, _arg4))); } public function streak(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:uint):Effect{ return (addEffect(new Streak(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6))); } public function textDrop(_arg1:String, _arg2:Number, _arg3:Number, _arg4:uint):Effect{ return (addEffect(new MovingText(_arg1, _arg2, _arg3, _arg4, false))); } public function update():void{ var _local1:int; var _local2:Effect; _local1 = 0; while (_local1 < effects.length) { _local2 = effects[_local1]; if (_local2.delay > 0){ _local2.delay--; } else { _local2.update(); if (!_local2.visible){ if (_local2.hasEventListener(Event.ENTER_FRAME)){ trace("removed effect has ENTER_FRAME event"); }; removeChild(_local2); effects.splice(_local1, 1); _local1--; }; }; _local1++; }; } public function get fx():Array{ return (effects); } } }//package hexcelle import flash.display.*; import org.cove.ape.*; import flash.text.*; import flash.filters.*; class Line extends Effect { private var lifeFrame:Boolean; private function Line(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint, _arg6:Number=1){ var x = _arg1; var y = _arg2; var x2 = _arg3; var y2 = _arg4; var color = _arg5; var alpha = _arg6; super(); var _local8 = graphics; with (_local8) { lineStyle(1, color, alpha); moveTo(x, y); lineTo(x2, y2); }; lifeFrame = false; } override public function update():void{ if (lifeFrame){ remove(); } else { lifeFrame = true; }; } } class ShootingSprite extends Effect { private var spin:Number; private var force:Vector; private function ShootingSprite(_arg1:Sprite, _arg2:Vector, _arg3:Number=10){ x = _arg1.x; y = _arg1.y; addChild(_arg1); _arg1.x = 0; _arg1.y = 0; force = _arg2; this.spin = _arg3; } override public function update():void{ x = (x + force.x); y = (y + force.y); rotation = (rotation + spin); force.multEquals(0.9); if (fading){ return; }; if (force.magnitude() < 1){ fadeOut(); }; } } class Boundary extends Effect { private var target:Object; private function Boundary(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:uint, _arg5:Number){ var offset:Number; var o = _arg1; var radius = _arg2; var thickness = _arg3; var color = _arg4; var alpha = _arg5; super(); target = o; offset = (radius / 5); var _local7 = graphics; with (_local7) { lineStyle(thickness, color, alpha); moveTo(-(offset), radius); lineTo(offset, radius); moveTo(radius, offset); lineTo(radius, -(offset)); moveTo(-(offset), -(radius)); lineTo(offset, -(radius)); moveTo(-(radius), offset); lineTo(-(radius), -(offset)); }; alpha = 0; x = target.x; y = target.y; rotation = (Math.random() * 90); } override public function update():void{ x = target.x; y = target.y; if (alpha < 1){ alpha = (alpha + ((1 - alpha) * 0.1)); if (alpha > 0.9){ alpha = 1; }; }; rotation = (rotation + 2.5); if ((target is Sprite)){ if (!target.visible){ remove(); }; }; if (target.hasOwnProperty("sprite")){ if (target.sprite){ if (!target.sprite.visible){ remove(); }; }; }; } } class Ring extends Effect { private var grow:Boolean; private function Ring(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint, _arg6:Number, _arg7:Boolean){ var x = _arg1; var y = _arg2; var radius = _arg3; var thickness = _arg4; var color = _arg5; var alpha = _arg6; var grow = _arg7; super(); this.grow = grow; var _local9 = graphics; with (_local9) { lineStyle(thickness, color, alpha); drawCircle(0, 0, radius); }; if (grow){ scaleX = 0; scaleY = 0; }; this.x = x; this.y = y; } override public function update():void{ if (grow){ scaleX = (scaleX + ((1 - scaleX) * 0.2)); scaleY = scaleX; if ((((scaleX > 0.75)) && (!(fading)))){ fadeOut(); }; } else { scaleX = (scaleX * 0.8); scaleY = scaleX; if ((((scaleX < 0.15)) && (!(fading)))){ fadeOut(); }; }; } } class Bolts extends Effect { private var count:int; private var perFrame:int; private var radius:Number; private function Bolts(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int){ this.x = _arg1; this.y = _arg2; radius = _arg3; count = _arg4; perFrame = Math.ceil((count / 15)); } override public function update():void{ var _local1:int; if ((((count <= 0)) && (!(fading)))){ fadeOut(); } else { _local1 = 0; while (_local1 < perFrame) { drawBolt(); _local1++; }; count = (count - perFrame); }; } public function drawBolt():void{ var roll:*; var a:*; var a2:*; var steps:*; var vx:*; var vy:*; var r:*; var i:*; var _local2 = graphics; with (_local2) { roll = Math.random(); if (roll < 0.2){ lineStyle(2, 15663103, 0.5); } else { if (roll < 0.4){ lineStyle(1, 16759739, 0.7); } else { if (roll < 0.6){ lineStyle(2, 8952200, 0.8); } else { lineStyle(1, 15658751); }; }; }; a = (Math.PI - ((2 * Math.PI) * Math.random())); steps = 4; vx = 0; vy = 0; r = ((radius / 2) + (Math.random() * radius)); moveTo(vx, vy); i = 0; while (i < steps) { a2 = ((Math.random())<0.5) ? (a + ((Math.random() * Math.PI) / 25)) : (a - ((Math.random() * Math.PI) / 25)); vx = (vx + ((r * Math.cos(a2)) / steps)); vy = (vy + ((r * Math.sin(a2)) / steps)); lineTo(vx, vy); i++; }; }; } } class Ghost extends Effect { private var doOnce:Boolean; private var lifeFrames:int; private function Ghost(_arg1:Object, _arg2:int, _arg3:uint, _arg4:uint){ var size:Number; var o = _arg1; var frames = _arg2; var lineColor = _arg3; var fillColor = _arg4; super(); if (((((((!(o.hasOwnProperty("width"))) || (!(o.hasOwnProperty("height"))))) || (!(o.hasOwnProperty("x"))))) || (!(o.hasOwnProperty("y"))))){ trace("ghost object is missing needed properties - effect terminated"); remove(); return; }; size = Math.max(o.width, o.height); var _local6 = graphics; with (_local6) { lineStyle((size / 20), lineColor, 0.8); beginFill(fillColor, 0.6); drawCircle(o.x, o.y, (size / 2)); }; alpha = 0; doOnce = false; lifeFrames = frames; if (lifeFrames < 1){ lifeFrames = 1; }; } override public function update():void{ if (!doOnce){ appear(); doOnce = true; }; if (lifeFrames == 0){ fadeOut(); } else { lifeFrames--; }; } } class Shards extends Effect { private var shards:Array; private var forces:Array; private function Shards(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:uint){ var i:int; var shard:Sprite; var r:Number; var a:Number; var push:Number; var f:Vector; var x = _arg1; var y = _arg2; var size = _arg3; var force = _arg4; var count = _arg5; var color = _arg6; super(); shards = new Array(); forces = new Array(); i = 0; while (i < count) { shard = new Sprite(); r = ((size / 2) + (Math.random() * size)); var _local8 = shard.graphics; with (_local8) { lineStyle(2, 10044433); beginFill(color); moveTo(0, r); lineTo(r, -(r)); lineTo(-(r), -(r)); }; shards.push(shard); addChild(shard); a = (Math.PI - ((Math.random() * 2) * Math.PI)); push = (force * (0.75 + (Math.random() * 0.5))); f = new Vector((push * Math.cos(a)), (push * Math.sin(a))); forces.push(f); i = (i + 1); }; alpha = 0; this.x = x; this.y = y; } override public function update():void{ var _local1:int; var _local2:Number; alpha = 1; _local1 = 0; while (_local1 < shards.length) { if (shards[_local1].alpha < 0.05){ shards.splice(_local1, 1); forces.splice(_local1, 1); _local1--; } else { shards[_local1].x = (shards[_local1].x + forces[_local1].x); shards[_local1].y = (shards[_local1].y + forces[_local1].y); forces[_local1].multEquals(0.9); shards[_local1].alpha = (shards[_local1].alpha * 0.9); _local2 = ((Math.random() * 10) + 10); shards[_local1].rotation = (shards[_local1].rotation + _local2); }; _local1++; }; if (shards.length == 0){ remove(); }; } } class Confetti extends Effect { private var angles:Array; private var specks:Array; private var red:Number; private var frames:uint; private var force:Number; private function Confetti(_arg1:Number, _arg2:Number, _arg3:Vector, _arg4:Number, _arg5:Number, _arg6:int){ var i:int; var speck:Vector; var a:Number; var temp:Vector; var x = _arg1; var y = _arg2; var direction = _arg3; var force = _arg4; var spread = _arg5; var count = _arg6; super(); specks = new Array(); angles = new Array(); frames = 0; red = 0xFF; direction.normalizeEquals(); i = 0; while (i < count) { speck = direction.mult(force); a = ((Math.PI * spread) * (Math.random() - 0.5)); temp = new Vector(speck.x, speck.y); speck.x = ((Math.cos(a) * temp.x) - (Math.sin(a) * temp.y)); speck.y = ((Math.sin(a) * temp.x) + (Math.cos(a) * temp.y)); var _local8 = graphics; with (_local8) { lineStyle(1, rgb(red, (red / 4), 0)); moveTo(0, 0); lineTo(speck.x, speck.y); }; specks.push(speck); angles.push(a); i = (i + 1); }; this.x = x; this.y = y; this.force = force; } override public function update():void{ var i:int; var ahead:Vector; var temp:Vector; if (frames == 5){ fadeOut(); }; if (frames > 30){ return; }; frames++; i = 0; while (i < specks.length) { ahead = specks[i].normalize().mult(((force / frames) * 3)); angles[i] = (angles[i] * 1.02); temp = new Vector(ahead.x, ahead.y); ahead.x = ((Math.cos(angles[i]) * temp.x) - (Math.sin(angles[i]) * temp.y)); ahead.y = ((Math.sin(angles[i]) * temp.x) + (Math.cos(angles[i]) * temp.y)); ahead.plusEquals(specks[i]); var _local2 = graphics; with (_local2) { lineStyle(1, rgb(red, ((red / 4) + (frames * 5)), (frames * 10))); moveTo(specks[i].x, specks[i].y); lineTo(ahead.x, ahead.y); }; specks[i].copy(ahead); i = (i + 1); }; } } class MovingText extends Effect { private var appeared:Boolean; private var speed:Number; private var up:Boolean; private function MovingText(_arg1:String, _arg2:Number, _arg3:Number, _arg4:uint, _arg5:Boolean){ var format:TextFormat; var font:HexcelleFont; var tf:TextField; var dropShadow:DropShadowFilter; var t = _arg1; var x = _arg2; var y = _arg3; var color = _arg4; var up = _arg5; super(); format = new TextFormat(); format.color = color; format.size = 12; font = new HexcelleFont(); format.font = font.fontName; tf = new TextField(); tf.embedFonts = true; tf.selectable = false; tf.background = false; tf.autoSize = TextFieldAutoSize.CENTER; format.align = TextFormatAlign.CENTER; tf.defaultTextFormat = format; tf.x = x; tf.y = y; tf.text = t; dropShadow = new DropShadowFilter(); var _local7 = dropShadow; with (_local7) { distance = 2; angle = 40; blurX = 3; blurY = 3; alpha = 0.6; }; this.filters = [dropShadow]; speed = 0.05; appeared = false; addChild(tf); alpha = 0; this.up = up; } override public function translate(_arg1:Vector):void{ } override public function update():void{ if (!appeared){ appear(); appeared = true; }; if (up){ this.y = (this.y - speed); } else { this.y = (this.y + speed); }; speed = (speed * 1.06); if (fading){ return; }; if (speed > 3){ fadeOut(); }; } } class Implode extends Effect { private function Implode(_arg1:Number, _arg2:Number, _arg3:Number){ var x = _arg1; var y = _arg2; var size = _arg3; super(); var _local5 = graphics; with (_local5) { beginFill(0xFF8800); drawCircle(0, 0, size); beginFill(0x442200); drawCircle(0, 0, (size / 3)); this.x = x; this.y = y; }; alpha = 0; } override public function update():void{ alpha = 1; scaleY = (scaleY * 0.9); if (scaleY < 0.6){ scaleX = (scaleX * 0.85); }; if (scaleX < 0.1){ remove(); }; } } class Clash extends Effect { private function Clash(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:uint){ var a:Number; var i:int; var points:Array; var point:*; var x = _arg1; var y = _arg2; var radius = _arg3; var offset = _arg4; var count = _arg5; var color = _arg6; super(); a = 0; i = 0; while (i < count) { points = new Array(); points.push(new Vector(offset, 0)); points.push(new Vector((offset + (((radius - offset) / 4) * Math.random())), (-(radius) / 10))); points.push(new Vector(radius, 0)); points.push(new Vector((offset + (((radius - offset) / 4) * Math.random())), (radius / 10))); a = (a + (Math.PI * (0.05 + ((2 * Math.random()) / count)))); for each (point in points) { rotateVEquals(point, a); }; var _local8 = graphics; with (_local8) { beginFill(color, 0.9); lineStyle(2, 0xFFFFFF, 0.8); moveTo(points[3].x, points[3].y); lineTo(points[0].x, points[0].y); lineTo(points[1].x, points[1].y); lineStyle(1, 0xFFFFFF, 0.8); lineTo(points[2].x, points[2].y); lineTo(points[3].x, points[3].y); }; i = (i + 1); }; scaleX = 0; scaleY = 0; this.x = x; this.y = y; fadeSpeed = 0.7; } override public function update():void{ scaleX = (scaleX + ((1 - scaleX) * 0.2)); scaleY = scaleX; if ((((scaleX > 0.8)) && (!(fading)))){ fadeOut(); }; } } class Magnet extends Effect { private var positions:Array; private var shards:Array; private var _target:Object; private var _offset:Number; private function Magnet(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:int, _arg5:uint, _arg6:Number=0){ var i:int; var shard:Sprite; var r:Number; var a:Number; var p:Vector; var o = _arg1; var size = _arg2; var radius = _arg3; var count = _arg4; var color = _arg5; var offset = _arg6; super(); if (((!(o.hasOwnProperty("x"))) || (!(o.hasOwnProperty("y"))))){ trace("magnet object is missing x or y property"); remove(); return; }; shards = new Array(); i = 0; while (i < count) { shard = new Sprite(); r = ((size / 2) + (Math.random() * size)); var _local8 = shard.graphics; with (_local8) { beginFill(color); moveTo(0, r); lineTo(r, -(r)); lineTo(-(r), -(r)); }; shards.push(shard); addChild(shard); a = (Math.PI - ((Math.random() * 2) * Math.PI)); p = new Vector(Math.cos(a), Math.sin(a)); p.normalizeEquals().multEquals((radius * (0.5 + Math.random()))); shard.x = (p.x + o.x); shard.y = (p.y + o.y); i = (i + 1); }; alpha = 0; _target = o; _offset = offset; } override public function translate(_arg1:Vector):void{ } override public function update():void{ var _local1:Vector; var _local2:*; var _local3:Vector; var _local4:Vector; var _local5:Number; if ((((alpha == 0)) && (!(fading)))){ appear(); }; if (alpha == 1){ fadeOut(); }; _local1 = new Vector(_target.x, _target.y); for each (_local2 in shards) { _local3 = new Vector(_local2.x, _local2.y); if (_offset == 0){ _local3.minusEquals(_local1).multEquals(0.8).plusEquals(_local1); } else { _local4 = _local3.minus(_local1); _local5 = _local4.magnitude(); _local4.multEquals(((_local5 - _offset) / _local5)); _local3.minusEquals(_local4.mult(0.2)); }; _local2.x = _local3.x; _local2.y = _local3.y; }; } } class ShardSpray extends Effect { private var shards:Array; private var forces:Array; private function ShardSpray(_arg1:Number, _arg2:Number, _arg3:Vector, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:int, _arg8:uint, _arg9:Number){ var v:Vector; var i:int; var shard:Sprite; var r:Number; var push:Number; var forceV:Vector; var a:Number; var x = _arg1; var y = _arg2; var direction = _arg3; var spread = _arg4; var size = _arg5; var force = _arg6; var count = _arg7; var color = _arg8; var alpha = _arg9; super(); shards = new Array(); forces = new Array(); v = direction.normalize(); i = 0; while (i < count) { shard = new Sprite(); r = ((size / 2) + (Math.random() * size)); var _local11 = shard.graphics; with (_local11) { lineStyle(2, 10044433); beginFill(color, alpha); moveTo(0, r); lineTo(r, -(r)); lineTo(-(r), -(r)); }; shards.push(shard); addChild(shard); push = (force * (0.95 + (Math.random() * 0.1))); forceV = v.multEquals(push); a = ((Math.PI * spread) * (Math.random() - 0.5)); forceV = rotateV(forceV, a); forces.push(forceV); i = (i + 1); }; alpha = 0; this.x = x; this.y = y; } override public function update():void{ var _local1:int; var _local2:Number; alpha = 1; _local1 = 0; while (_local1 < shards.length) { if (shards[_local1].alpha < 0.05){ shards.splice(_local1, 1); forces.splice(_local1, 1); _local1--; } else { shards[_local1].x = (shards[_local1].x + forces[_local1].x); shards[_local1].y = (shards[_local1].y + forces[_local1].y); forces[_local1].multEquals(0.9); shards[_local1].alpha = (shards[_local1].alpha * 0.95); _local2 = ((Math.random() * 10) + 10); shards[_local1].rotation = (shards[_local1].rotation + _local2); }; _local1++; }; if (shards.length == 0){ remove(); }; } } class Streak extends Effect { private var lifeFrames:int; private function Streak(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:uint){ var x = _arg1; var y = _arg2; var x2 = _arg3; var y2 = _arg4; var size = _arg5; var color = _arg6; super(); var _local8 = graphics; with (_local8) { lineStyle(size, color, 0.4); moveTo(x, y); lineTo(x2, y2); lineStyle((size / 3), color, 0.7); moveTo(x, y); lineTo(x2, y2); }; lifeFrames = 5; } override public function update():void{ if (lifeFrames == 0){ remove(); } else { lifeFrames--; }; } } class MovingDot extends Effect { private var speed:Number; private var targetY:Number; private var targetX:Number; private function MovingDot(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint, _arg6:Number, _arg7:Number){ graphics.beginFill(_arg5); graphics.drawCircle(0, 0, _arg6); this.x = _arg1; this.y = _arg2; targetX = _arg3; targetY = _arg4; this.speed = _arg7; } override public function update():void{ if (fading){ return; }; x = (x + ((targetX - x) * speed)); y = (y + ((targetY - y) * speed)); if (Math.abs((targetX - x)) < 10){ if (Math.abs((targetY - y)) < 10){ fadeOut(); }; }; } }
Section 25
//GameSound (hexcelle.GameSound) package hexcelle { import flash.display.*; import flash.media.*; import flash.events.*; public class GameSound { private static var _targetMusicVolume:Number; private static var _targetMusic:String; private static var musicChannel:SoundChannel; private static var _musicVolume:Number; private static var _sounds:int; private static var _fxVolume:Number; private static var currentMusic:String; private static var _mute:Boolean; private static var _stage:Stage; public static function set musicVolume(_arg1:Number):void{ if (!musicChannel){ return; }; if (_arg1 < 0){ _arg1 = 0; }; if (_arg1 > 1){ _arg1 = 1; }; _musicVolume = _arg1; if (_mute){ return; }; _targetMusicVolume = _arg1; if (!_targetMusic){ _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); _stage.addEventListener(Event.ENTER_FRAME, changeMusicVolume); }; } public static function get fxVolume():Number{ return (_fxVolume); } public static function init(_arg1:Stage):void{ _musicVolume = 1; _fxVolume = 1; _stage = _arg1; _mute = false; _sounds = 0; } private static function changeMusicVolume(_arg1:Event):void{ var _local2:SoundTransform; _local2 = musicChannel.soundTransform; _local2.volume = (_local2.volume + ((_targetMusicVolume - _local2.volume) * 0.15)); if (Math.abs((_local2.volume - _targetMusicVolume)) < 0.05){ _local2.volume = _targetMusicVolume; _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); if (_targetMusic){ fadeInMusic(_targetMusic); _targetMusic = null; }; }; musicChannel.soundTransform = _local2; } public static function get mute():Boolean{ return (_mute); } private static function end(_arg1:Event):void{ _sounds--; } public static function get musicVolume():Number{ return (_musicVolume); } private static function fadeInMusic(_arg1:String):void{ var _local2:Boolean; var _local3:String; var _local4:IntroMusic; var _local5:MainMusic; var _local6:SoundTransform; if (musicChannel){ musicChannel.stop(); }; _local2 = false; _local3 = _arg1.toLowerCase(); if (_local3 == "intro"){ _local4 = new IntroMusic(); musicChannel = _local4.play(0, 10); _local2 = true; } else { if (_local3 == "main"){ _local5 = new MainMusic(); musicChannel = _local5.play(0, 200); _local2 = true; }; }; if (_local2){ _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); _local6 = musicChannel.soundTransform; _local6.volume = 0; musicChannel.soundTransform = _local6; _targetMusicVolume = (_mute) ? 0 : _musicVolume; currentMusic = _local3; _stage.addEventListener(Event.ENTER_FRAME, changeMusicVolume); }; } public static function set fxVolume(_arg1:Number):void{ if (_arg1 < 0){ _arg1 = 0; }; if (_arg1 > 1){ _arg1 = 1; }; _fxVolume = _arg1; } public static function startMusic(_arg1:String):void{ var _local2:String; _local2 = _arg1.toLowerCase(); if (_local2 == currentMusic){ return; }; if (musicChannel){ _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); _targetMusic = _local2; _targetMusicVolume = 0; _stage.addEventListener(Event.ENTER_FRAME, changeMusicVolume); } else { fadeInMusic(_local2); }; } public static function play(_arg1:String):void{ var _local2:String; _local2 = _arg1.toLowerCase(); if (_local2 == "foodhex"){ playSound(new SoundFoodHex(), 0.5); } else { if (_local2 == "foodfaun"){ playSound(new SoundFoodFaun(), 0.9); } else { if (_local2 == "evolve"){ playSound(new SoundEvolve()); } else { if (_local2 == "bombsmall"){ playSound(new SoundBombSmall()); } else { if (_local2 == "bombnormal"){ playSound(new SoundBombNormal()); } else { if (_local2 == "bombbig"){ playSound(new SoundBombBig()); } else { if (_local2 == "newarea"){ playSound(new SoundNewArea()); } else { if (_local2 == "kill"){ playSound(new SoundKill()); } else { if (_local2 == "hexlost"){ playSound(new SoundHexLost()); } else { if (_local2 == "missile"){ playSound(new SoundMissile(), 0.6); } else { if (_local2 == "addnewhex"){ playSound(new SoundAddNewHex()); } else { if (_local2 == "bomb"){ playSound(new SoundBomb()); } else { if (_local2 == "checkpoint"){ playSound(new SoundCheckpoint()); } else { if (_local2 == "coredestroy"){ playSound(new SoundCoreDestroy()); } else { if (_local2 == "death"){ playSound(new SoundDeath()); } else { if (_local2 == "faun"){ playSound(new SoundFaun()); } else { if (_local2 == "hit"){ playSound(new SoundHit()); } else { if (_local2 == "pulse"){ playSound(new SoundPulse(), 0.7); } else { if (_local2 == "ui"){ playSound(new SoundUI()); } else { if (_local2 == "error"){ playSound(new SoundError()); } else { trace(("sound not recognized: " + _arg1)); }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; }; } public static function set mute(_arg1:Boolean):void{ if (((!(_mute)) && (_arg1))){ _targetMusicVolume = 0; if (!_targetMusic){ _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); _stage.addEventListener(Event.ENTER_FRAME, changeMusicVolume); }; } else { if (((_mute) && (!(_arg1)))){ _targetMusicVolume = _musicVolume; if (!_targetMusic){ _stage.removeEventListener(Event.ENTER_FRAME, changeMusicVolume); _stage.addEventListener(Event.ENTER_FRAME, changeMusicVolume); }; }; }; _mute = _arg1; } private static function playSound(_arg1:Sound=null, _arg2:Number=1):void{ var _local3:SoundChannel; var _local4:SoundTransform; if (((((!(_arg1)) || (_mute))) || ((_sounds > 20)))){ return; }; _local3 = _arg1.play(); _local3.addEventListener(Event.SOUND_COMPLETE, end); _local4 = _local3.soundTransform; _local4.volume = (_fxVolume * _arg2); _local3.soundTransform = _local4; _sounds++; } } }//package hexcelle
Section 26
//Grid (hexcelle.Grid) package hexcelle { public class Grid { public var grid:Array; public var core:Hex; private var orientGridUp:Boolean; public function Grid(_arg1:Hex){ this.core = _arg1; grid = new Array(new Array(_arg1)); orientGridUp = true; } public function applyToHexes(_arg1:Function){ var _local2:*; var _local3:*; for each (_local2 in grid) { for each (_local3 in _local2) { if (_local3){ _arg1(_local3); }; }; }; } public function get details():String{ var _local1:String; var _local2:int; var _local3:int; var _local4:int; _local1 = ""; if (orientUp){ _local1 = (_local1 + "grid orientation: UP\n"); } else { _local1 = (_local1 + "grid orientation: DOWN\n"); }; _local1 = (_local1 + "------------\n"); _local2 = 0; while (_local2 < grid.length) { _local1 = (_local1 + (("column " + _local2) + ": \n")); _local3 = 0; while (_local3 < grid[_local2].length) { _local1 = (_local1 + (((" row " + _local3) + ": ") + grid[_local2][_local3])); _local1 = (_local1 + (": " + (grid[_local2][_local3]) ? DNA.getIndexName(grid[_local2][_local3].type) : "")); _local1 = (_local1 + ((grid[_local2][_local3]) ? ((grid[_local2][_local3] == core)) ? " (CORE)" : "" : "" + "\n")); if (grid[_local2][_local3]){ _local4 = 0; while (_local4 < 6) { if (grid[_local2][_local3].links[_local4]){ _local1 = (_local1 + ((((((" link " + _local4) + ": ") + grid[_local2][_local3].links[_local4]) + ": ") + DNA.getIndexName(grid[_local2][_local3].links[_local4].type)) + "\n")); }; _local4++; }; }; _local3++; }; _local2++; }; _local1 = (_local1 + "------------\n"); return (_local1); } public function getAdjacentHex(_arg1:Hex, _arg2:int):Hex{ var _local3:Array; var _local4:int; var _local5:int; _local3 = getHexCoords(_arg1); _local4 = _local3[0]; _local5 = _local3[1]; if (((((((_local4 % 2) == 0)) && (orientGridUp))) || (((!(((_local4 % 2) == 0))) && (!(orientGridUp)))))){ switch (_arg2){ case 0: if (_local4 == (grid.length - 1)){ return (null); }; return (grid[(_local4 + 1)][_local5]); case 1: if ((((_local4 == (grid.length - 1))) || ((_local5 == (grid[_local4].length - 1))))){ return (null); }; return (grid[(_local4 + 1)][(_local5 + 1)]); case 2: if (_local5 == (grid[_local4].length - 1)){ return (null); }; return (grid[_local4][(_local5 + 1)]); case 3: if ((((_local4 == 0)) || ((_local5 == (grid[_local4].length - 1))))){ return (null); }; return (grid[(_local4 - 1)][(_local5 + 1)]); case 4: if (_local4 == 0){ return (null); }; return (grid[(_local4 - 1)][_local5]); case 5: if (_local5 == 0){ return (null); }; return (grid[_local4][(_local5 - 1)]); }; } else { switch (_arg2){ case 0: if ((((_local4 == (grid.length - 1))) || ((_local5 == 0)))){ return (null); }; return (grid[(_local4 + 1)][(_local5 - 1)]); case 1: if (_local4 == (grid.length - 1)){ return (null); }; return (grid[(_local4 + 1)][_local5]); case 2: if (_local5 == (grid[_local4].length - 1)){ return (null); }; return (grid[_local4][(_local5 + 1)]); case 3: if (_local4 == 0){ return (null); }; return (grid[(_local4 - 1)][_local5]); case 4: if ((((_local4 == 0)) || ((_local5 == 0)))){ return (null); }; return (grid[(_local4 - 1)][(_local5 - 1)]); case 5: if (_local5 == 0){ return (null); }; return (grid[_local4][(_local5 - 1)]); }; }; return (null); } private function cleanUp():void{ var _local1:Array; var _local2:Hex; var _local3:Boolean; var _local4:int; _local4 = (grid[0].length - 1); while (_local4 >= 0) { _local3 = true; for each (_local1 in grid) { if (_local1[_local4]){ _local3 = false; }; }; if (_local3){ for each (_local1 in grid) { _local1.splice(_local4, 1); }; }; _local4--; }; _local4 = (grid.length - 1); while (_local4 >= 0) { _local3 = true; for each (_local2 in grid[_local4]) { if (_local2){ _local3 = false; }; }; if (_local3){ grid.pop(); } else { _local4 = -1; }; _local4--; }; _local4 = 0; while (_local4 < grid.length) { _local3 = true; for each (_local2 in grid[_local4]) { if (_local2){ _local3 = false; }; }; if (_local3){ grid.shift(); _local4--; orientGridUp = !(orientGridUp); } else { _local4 = grid.length; }; _local4++; }; } public function resetPools(){ var _local1:*; var _local2:*; for each (_local1 in grid) { for each (_local2 in _local1) { if (_local2){ _local2.pool.reset(); }; }; }; } private function removeStrayHexes(_arg1:Hexes):void{ var connector:Function; var theCleaner:Function; var hexes = _arg1; toggleAll(false); connector = function (_arg1:Hex):void{ var _local2:*; _arg1.toggle = true; for each (_local2 in _arg1.links) { if (_local2){ if (!_local2.toggle){ connector(_local2); }; }; }; }; connector(core); theCleaner = function (_arg1:Hex):void{ var _local2:Array; if (_arg1.toggle){ return; }; _local2 = getHexCoords(_arg1); grid[_local2[0]][_local2[1]] = null; hexes.clearHex(_arg1); }; applyToHexes(theCleaner); } public function get width():int{ return (grid.length); } public function updateHexLinks(_arg1:Hex){ var _local2:Array; var _local3:int; var _local4:int; _local2 = getHexCoords(_arg1); _local3 = _local2[0]; _local4 = _local2[1]; if (((((((_local3 % 2) == 0)) && (orientGridUp))) || (((!(((_local3 % 2) == 0))) && (!(orientGridUp)))))){ if ((((_local3 < (grid.length - 1))) && (!((grid[(_local3 + 1)][_local4] == null))))){ _arg1.links[0] = grid[(_local3 + 1)][_local4]; grid[(_local3 + 1)][_local4].links[3] = _arg1; }; if ((((((_local3 < (grid.length - 1))) && ((_local4 < (grid[_local3].length - 1))))) && (!((grid[(_local3 + 1)][(_local4 + 1)] == null))))){ _arg1.links[1] = grid[(_local3 + 1)][(_local4 + 1)]; grid[(_local3 + 1)][(_local4 + 1)].links[4] = _arg1; }; if ((((_local4 < (grid[_local3].length - 1))) && (!((grid[_local3][(_local4 + 1)] == null))))){ _arg1.links[2] = grid[_local3][(_local4 + 1)]; grid[_local3][(_local4 + 1)].links[5] = _arg1; }; if ((((((_local3 > 0)) && ((_local4 < (grid[_local3].length - 1))))) && (!((grid[(_local3 - 1)][(_local4 + 1)] == null))))){ _arg1.links[3] = grid[(_local3 - 1)][(_local4 + 1)]; grid[(_local3 - 1)][(_local4 + 1)].links[0] = _arg1; }; if ((((_local3 > 0)) && (!((grid[(_local3 - 1)][_local4] == null))))){ _arg1.links[4] = grid[(_local3 - 1)][_local4]; grid[(_local3 - 1)][_local4].links[1] = _arg1; }; if ((((_local4 > 0)) && (!((grid[_local3][(_local4 - 1)] == null))))){ _arg1.links[5] = grid[_local3][(_local4 - 1)]; grid[_local3][(_local4 - 1)].links[2] = _arg1; }; } else { if ((((((_local3 < (grid.length - 1))) && ((_local4 > 0)))) && (!((grid[(_local3 + 1)][(_local4 - 1)] == null))))){ _arg1.links[0] = grid[(_local3 + 1)][(_local4 - 1)]; grid[(_local3 + 1)][(_local4 - 1)].links[3] = _arg1; }; if ((((_local3 < (grid.length - 1))) && (!((grid[(_local3 + 1)][_local4] == null))))){ _arg1.links[1] = grid[(_local3 + 1)][_local4]; grid[(_local3 + 1)][_local4].links[4] = _arg1; }; if ((((_local4 < (grid[_local3].length - 1))) && (!((grid[_local3][(_local4 + 1)] == null))))){ _arg1.links[2] = grid[_local3][(_local4 + 1)]; grid[_local3][(_local4 + 1)].links[5] = _arg1; }; if ((((_local3 > 0)) && (!((grid[(_local3 - 1)][_local4] == null))))){ _arg1.links[3] = grid[(_local3 - 1)][_local4]; grid[(_local3 - 1)][_local4].links[0] = _arg1; }; if ((((((_local3 > 0)) && ((_local4 > 0)))) && (!((grid[(_local3 - 1)][(_local4 - 1)] == null))))){ _arg1.links[4] = grid[(_local3 - 1)][(_local4 - 1)]; grid[(_local3 - 1)][(_local4 - 1)].links[1] = _arg1; }; if ((((_local4 > 0)) && (!((grid[_local3][(_local4 - 1)] == null))))){ _arg1.links[5] = grid[_local3][(_local4 - 1)]; grid[_local3][(_local4 - 1)].links[2] = _arg1; }; }; } public function replaceHex(_arg1:Hex, _arg2:Hex):void{ var _local3:Array; _local3 = getHexCoords(_arg1); grid[_local3[0]][_local3[1]] = _arg2; updateHexLinks(_arg2); } public function get orientUp():Boolean{ return (orientGridUp); } public function updateAllHexLinks(){ var _local1:*; var _local2:*; for each (_local1 in grid) { for each (_local2 in _local1) { if (_local2){ updateHexLinks(_local2); }; }; }; } public function hasHex(_arg1:Hex):Boolean{ var _local2:Boolean; var _local3:*; var _local4:*; _local2 = false; for each (_local3 in grid) { for each (_local4 in _local3) { if (_local4 == _arg1){ _local2 = true; }; }; }; return (_local2); } public function set orientUp(_arg1:Boolean):void{ orientGridUp = _arg1; } public function getHexCoords(_arg1:Hex):Array{ var _local2:int; var _local3:int; _local2 = 0; while (_local2 < grid.length) { _local3 = 0; while (_local3 < grid[_local2].length) { if (grid[_local2][_local3] == _arg1){ return (new Array(_local2, _local3)); }; _local3++; }; _local2++; }; return (null); } public function removeHexes(_arg1:Array, _arg2:Hexes):void{ var _local3:*; for each (_local3 in _arg1) { if (_local3 != _arg2.core){ stripHex(_local3); }; }; removeStrayHexes(_arg2); cleanUp(); } public function get height():int{ return (grid[0].length); } public function get allHexes():Array{ var _local1:Array; var _local2:*; var _local3:*; _local1 = new Array(); for each (_local2 in grid) { for each (_local3 in _local2) { if (_local3){ _local1.push(_local3); }; }; }; return (_local1); } private function stripHex(_arg1:Hex):void{ var _local2:Array; var _local3:int; var _local4:int; _local2 = getHexCoords(_arg1); grid[_local2[0]][_local2[1]] = null; _local3 = 0; while (_local3 < 6) { if (_arg1.links[_local3]){ _local4 = ((_local3)<3) ? (_local3 + 3) : (_local3 - 3); _arg1.links[_local3].links[_local4] = null; }; _local3++; }; } public function toggleAll(_arg1:Boolean){ var _local2:*; var _local3:*; for each (_local2 in grid) { for each (_local3 in _local2) { if (_local3){ _local3.toggle = _arg1; }; }; }; } public function get hexCount():int{ var _local1:int; var _local2:*; var _local3:*; _local1 = 0; for each (_local2 in grid) { for each (_local3 in _local2) { if (_local3){ _local1++; }; }; }; return (_local1); } public function linkNewHex(_arg1:Hex, _arg2:Hex, _arg3:int){ var _local4:int; var _local5:int; var _local6:Array; var _local7:int; var _local8:int; var _local9:Array; _local6 = getHexCoords(_arg1); _local7 = _local6[0]; _local8 = _local6[1]; if (((((((_local7 % 2) == 0)) && (orientGridUp))) || (((!(((_local7 % 2) == 0))) && (!(orientGridUp)))))){ switch (_arg3){ case 0: if (_local7 == (grid.length - 1)){ grid.push(new Array(grid[_local7].length)); }; grid[(_local7 + 1)][_local8] = _arg2; break; case 1: if (_local7 == (grid.length - 1)){ grid.push(new Array(grid[_local7].length)); }; if (_local8 == (grid[_local7].length - 1)){ for each (_local9 in grid) { _local9.push(null); }; }; grid[(_local7 + 1)][(_local8 + 1)] = _arg2; break; case 2: if (_local8 == (grid[_local7].length - 1)){ for each (_local9 in grid) { _local9.push(null); }; }; grid[_local7][(_local8 + 1)] = _arg2; break; case 3: if (_local7 == 0){ grid.unshift(new Array(grid[0].length)); _local4 = 1; orientGridUp = !(orientGridUp); }; if (_local8 == (grid[_local7].length - 1)){ for each (_local9 in grid) { _local9.push(null); }; }; grid[((_local7 - 1) + _local4)][(_local8 + 1)] = _arg2; break; case 4: if (_local7 == 0){ grid.unshift(new Array(grid[0].length)); _local4 = 1; orientGridUp = !(orientGridUp); }; grid[((_local7 - 1) + _local4)][_local8] = _arg2; break; case 5: if (_local8 == 0){ for each (_local9 in grid) { _local9.unshift(null); }; _local5 = 1; }; grid[_local7][((_local8 - 1) + _local5)] = _arg2; break; }; } else { switch (_arg3){ case 0: if (_local7 == (grid.length - 1)){ grid.push(new Array(grid[_local7].length)); }; if (_local8 == 0){ for each (_local9 in grid) { _local9.unshift(null); }; _local5 = 1; }; grid[(_local7 + 1)][((_local8 - 1) + _local5)] = _arg2; break; case 1: if (_local7 == (grid.length - 1)){ grid.push(new Array(grid[_local7].length)); }; grid[(_local7 + 1)][_local8] = _arg2; break; case 2: if (_local8 == (grid[_local7].length - 1)){ for each (_local9 in grid) { _local9.push(null); }; }; grid[_local7][(_local8 + 1)] = _arg2; break; case 3: if (_local7 == 0){ grid.unshift(new Array(grid[0].length)); _local4 = 1; orientGridUp = !(orientGridUp); }; grid[((_local7 - 1) + _local4)][_local8] = _arg2; break; case 4: if (_local7 == 0){ grid.unshift(new Array(grid[0].length)); _local4 = 1; orientGridUp = !(orientGridUp); }; if (_local8 == 0){ for each (_local9 in grid) { _local9.unshift(null); }; _local5 = 1; }; grid[((_local7 - 1) + _local4)][((_local8 - 1) + _local5)] = _arg2; break; case 5: if (_local8 == 0){ for each (_local9 in grid) { _local9.unshift(null); }; _local5 = 1; }; grid[_local7][((_local8 - 1) + _local5)] = _arg2; break; }; }; updateHexLinks(_arg2); } public function removeHex(_arg1:Hex, _arg2:Hexes):void{ if (getHexCoords(_arg1) == null){ return; }; stripHex(_arg1); removeStrayHexes(_arg2); cleanUp(); } public function set hexSize(_arg1:int){ var _local2:*; var _local3:*; for each (_local2 in grid) { for each (_local3 in _local2) { if (_local3){ _local3.size = _arg1; }; }; }; } } }//package hexcelle
Section 27
//Guide (hexcelle.Guide) package hexcelle { import flash.events.*; public class Guide extends ARGSprite { private var _pages:Array; private var _guide:Object; public static const CLOSE:String = "Hexcelle_Guide_Close"; public function Guide(){ _guide = new Object(); _pages = new Array(); super(); _guide = {Adventuring...:{areas:["Your celle will travel from area to area, which are shown as large circles. As you enter an area, there is a chance that enemies will attack you, so beware.", "When entering a new area (one that you have not entered before), enemies will always be present. Areas that you have already visited may or may not contain enemies. Always be on the lookout. In general, it is unwise to rush into and/or through areas. If you do and your celle is moving too quickly, an area will \"brake\" the celle.", "It is best to remain within one area at a time, so as to avoid attracting more enemies than needed.", "If a new area turns red when entered, you have encountered a boss! Good luck!"], bosses:["Sometimes an area will contain a single boss celle. These enemy bosses will be able to pack a punch, so enter areas carefully.", "For a boss to spawn, your celle must travel at increasing distances (see \"Adventuring: distance\"). Your celle must also destroy a sufficient number of enemies for a boss to spawn.", "10 bosses exist. Destroying all 10 will win you the game!"], check points:["As your celle travels from its starting point, its distance increases. At regular intervals of distance (concentric circles from the starting point), your celle will meet checkpoints. These are shown as thin orange lines.", "Crossing a checkpoint will repair all existing hexes of the celle, so look for them, if your celle has been damaged!"], damage:["An undamaged hex will have a bright white outline. As it takes damage, this white will dim, eventually resulting in losing the hex. A regular hex can take about 3 hits from a small missile before being lost. If a hex's armor value drops below zero, it will be destroyed.", "If a celle's core hex is destroyed, the entire celle will explode.", "Armor hexes will increase the damage a hex can take. Armor hexes are crucial to surviving large missiles.", "When a missile or bomb hits a hex, adjacent hexes will also take damage, but at a lesser degree (splash damage). This means that even with a core completely surrounded by hexes, it is possible to destroy the core without destroying one of the surrounding hexes."], distance:["As your celle travels from its starting location, you will increase its \"distance.\" At further distances, enemies will be more difficult, and your celle will encounter more of them.", "Some players find that a spiral exploration is best to maximize evolutions and encounters."], enemies:["As you enter areas you may encounter enemy celles. These celles may or may not be able to damage you, though they usually will be outfitted with missiles and/or bombs, so be careful!", "There are 40 different types of enemies, ranging from small harmless specks, to large missile- and bomb-carrying beasts."], evolving:["After collecting enough food (see \"Adventuring: food\"), your celle will be able to evolve. To evolve, press \"E\".", "This will take you to the Evolver screen, where you will be granted a number of mutations and spawns. The number of mutations and spawns is directly related to the number of Grow hexes in your celle. It is not random.", "Each mutation allows you to change the type of one hex. Each spawn allows you to grow a new hex. When a new hex is spawned it may only take the type of an adjacent hex. If a mutated hex is adjacent, it can spawn as any type.", "Evolving and spawning hexes is the only way to add hexes to your celle. The arrangement of these hexes determines what abilities your celle has.", "After each evolve, all hexes in the celle will be repaired."], food:["Destroyed enemy hexes and celles will leave behind green bits of food. You can collect these by moving over them. If all enemies are destroyed, then your celle will attract nearby food.", "If your celle collects enough food, it will be able to evolve. This will be announced to you, and you can see available evolves as green dots in the lower right of the screen.", "The amount of food required to evolve is directly proportional to the number of hexes in the celle. This means that if a celle has enough food for 2 evolves, and after evolving the celle adds hexes, the celle may need to collect additional food before being able to evolve a second time."], map:["By holding the Shift key while adventuring, a map will show. The different colored areas of the map indicate the following:", "\twhite: normal area", "\tblue: starting area (center)", "\tgreen: current area", "\tyellow: last visited new area", "\tred: boss area"]}, Celles...:{hex types...:{armor:["Armor hexes are gray and have increased armor (can take more damage before being destroyed). Hexes of any type adjacent to an armor batch will have their armors increased, too.", "Armor hexes can provide the following abilities:", "\tarmor regeneration", "\tfaster armor regeneration", "\tmaximized armor regeneration"], bomb:["Bomb hexes are blue and allow your celle to drop bombs (by pressing spacebar or Ctrl).", "Bomb hexes can provide the following abilities:", "\tmulti-bombs", "\tshelled bombs", "\tgrowing bombs", "\tfaster bomb growth", "\tbomb shots", "\tgreater bomb shot acceleration", "\tseeking bomb shots", "\tproximity bombs", "\tseeking bombs"], grow:["Grow hexes are green and increase the number of mutations and spawns granted per evolution. They also make missiles and bombs grow in size.", "Grow hexes can provide the following abilities:", "\tgrowing bombs", "\tfaster bomb growth", "\tgrowing missiles", "\tfaster missile growth"], missile:["Missile hexes are red and allow your celle to fire missiles (by pressing the left mouse button).", "Missile hexes can provide the following abilities:", "\tbomb shots", "\tgreater bomb shot acceleration", "\tseeking bomb shots", "\tgreater missile acceleration", "\tgrowing missiles", "\tfaster missile growth", "\tseeking missiles", "\tincreased missile firing rate", "\tfaster missiles"], speed:["Speed hexes are yellow and allow your celle to move quicker (by pressing the arrow keys or WASD keys). For adjacent batches, they also increase the rate at which your celle can fire missiles, drop bombs, regenerate, and grow (for growing abilities).", "Speed hexes can provide the following abilities:", "\tthrusters abilities", "\tfaster armor regeneration", "\tmaximized armor regeneration", "\tfaster bomb growth", "\tgreater bomb shot acceleration", "\tseeking bombs", "\tgreater missile acclerations", "\tfaster missile growth", "\tincreased missile firing rate"], tech:["Tech hexes are pink and act as \"wildcards\" in batches. They grant special abilities to other hexes in their batch.", "Tech hexes can provide the following abilities:", "\tarmor regeneration abilities", "\tgreater bomb shot acceleration", "\tseeking bomb shots", "\tproximity bombs", "\tseeking bombs", "\tgreater missile acceleration", "\tseeking missiles", "\tfaster missiles"]}, batches:["Groups of adjacent similar-type hexes will be combined into a \"batch.\" A batch acts as one unit with specific abilities. When evolving, you can see batches by choosing so from the menu.", "The abilities of batches are also affected by hexes adjacent to the batch. For example, a batch of missiles hexes will fire a single missile. If a speed hex is adjacent to the missile batch, then the missile batch will fire its missile at an increased rate because of the adjacent speed hex.", "Hexes can be combined in thousands of ways to create batches with differing abilities. As you evolve, pay attention to batch creation, as sometimes the placement of a hex will alter the arrangement of batches.", "Batch composition is automatically generated. A celle will always assemble the largest (most skillful) batch possible of similar hexes (plus tech hexes) first. The maximimum size of a batch is seven hexes.", "Batches in a \"cluster\" may behave differently than batches in a \"line.\""], firing:["Your celle's first missiles will be slow and weak. Because of this, the trajectory of a missile will be strongly affected by your celle's velocity. This results in a few things:", "When your celle is moving quickly, the trajectory of slow missiles will be overtaken by the velocity of the celle. Put simply, move slower for better aim.", "Missile batches far from the center of your celle will likely be \"spinning\" due to collisions with objects. This gives them not only the velocity of the celle as a whole, but also an additional rotational velocity. Put simply, missiles fired from batches far from the center of your celle will be more difficult to aim when moving quickly.", "However, celle spinning can be a strategy to achieve drastically faster missiles by \"sling-shotting\" them.", "For easier aiming, try these strategies:", "\t1. do not rush, move slower", "\t2. evolve faster accelerating missiles", "\t3. evolve seeking missiles"], large celles:["When evolving your celle to large sizes (over 20 hexes), try to evolve arms of hexes. A large clustered mass of hexes may implode due to insane gravitational forces. This is somewhat like a black hole in outerspace, except this happens with your celle in this game.", "From Wikipedia (paraphrased with Hexcelle terminology): \"A black hole is a [boring fat celle's center] from which nothing, including light, can escape. It is the result of the defomation of spacetime caused by a very compact mass [of hexes].\"", "In other words, do not evolve simple, boring, large blocks of hexes."], enemy celles:["Enemy celles are composed exactly as your celles. They use the same system of batches and abilities. This allows you to study their composition to see how they behave."], hex masses:["Each hex has a mass determined by its type. More massive hexes are harder to move and act \"heavier.\"", "\tarmor: 1.3", "\tbomb: 1.2", "\tgrow: 0.8", "\tmissile: 1.3", "\tspeed: 1.0", "\ttech: 1.1"]}, Abilities...:{Armor...:{armor (A):["Each new or repaired hex has an armor value of 2. Hexes in an armor batch have armor values equal to the maximum of 3 or the batch's armor pool.", "If the batch is a line, then each hex adjacent to the batch will have its armor value increased by the batch's armor pool."], armor regeneration (A+T)(+S):["If an armor batch includes tech hexes, it will regenerate armor. Speed hexes adjacent to the batch also have an affect.", "More tech hexes will increase the degree of regeneration.", "More adjacent speed hexes will increase the rate of regeneration."], faster armor regeneration (A+T):["An armor batch with 2 or more tech hexes (see \"armor regeneration\")."], maximized armor regeneration (A+T+S):["An armor batch that regerates armor every frame (lots of adjacent speed hexes, see \"armor regeneration\")."]}, Bombs...:{bombs (B):["A batch with bomb hexes is able to drop bombs.", "A clustered bomb batch will drop 1 bomb at a time (see \"multi-bombs\" for line batches).", "The size and power of the bomb are determined by the number of bomb hexes in the batch.", "A default bomb has 0 armor, meaning one missile shot will destroy it."], multi-bombs (B):["A bomb batch in a line drops multiple bombs per \"drop\""], shelled bombs (B+A):["Bomb batches with adjacent armor hexes will drop bombs that are armored, and will resist damage from missiles and other bombs."], growing bombs (B+G):["Bomb batches with adjacent grow hexes drop bombs that grow in size.", "More adjacent grow hexes increase the degree and rate of growth."], faster bomb growth (B+G+S):["Bomb batches with adjacent grow and speed hexes drop bombs that grow in size faster."], bomb shots (B+M):["Cluster bomb batches with adjacent missile hexes drop bombs that shoot missiles.", "More adjacent missile hexes result in bigger and faster missiles."], greater bomb shot acceleration (B+M+S+T):["Bomb batches with adjacent missile, speed, and tech hexes drop bombs that shoot missiles with greater acceleration (laser-like missiles).", "More adjacent tech hexes result in greater acceleration."], seeking bomb shots (B+M+T):["Bomb batches with adjacent missile and tech hexes drop bombs that shoot seeking missiles.", "More tech hexes increase the seek radius.", "More tech hexes increase the seek time.", "More tech hexes increase the seek propulsion."], proximity bombs (B+T):["Bomb batches with tech hexes have a proximity radius that trigger the bomb to explode when enemies are near.", "More tech hexes increase the proximity radius."], seeking bombs (B+T+S):["Bomb batches with tech hexes and adjacent speed hexes will seek out nearby enemies.", "More tech hexes and adjacent speed hexes increase the seek time.", "More tech hexes and adjacent speed hexes increase the seeking propulsion."]}, Missiles...:{missiles (M):["Missile batches shoot missiles.", "The number of missile hexes determines the base missile size, propulsion, fuel, and power."], greater missile acceleration (M+S+T):["Missile batches with adjacent speed and tech hexes fire missiles with greater acceleration (laser-like missiles).", "More speed and tech hexes increase the missile's acceleration."], growing missiles (M+G):["Missile batches with adjacent grow hexes shoot missiles that grow in size (not power).", "More adjacent grow hexes increase the growth amount and growth time."], faster missile growth (M+G+S):["Missile batches with adjacent grow and speed hexes shoot missiles that grow faster.", "More adjacent speed hexes increase the growth amount."], seeking missiles (M+T):["Missile batches with tech hexes shoot missiles that seek out enemies. If an enemy comes within the seek radius, the missile will lock on and propel towards the enemy. If you click near an enemy (with the seek radius), the missile will lock on immediately.", "More tech hexes increase the missile's seek radius, seek time, and propulsion."], increased missile firing rate (M+S)(+G):["Missile batches with adjacent speed hexes fire missiles more frequently. (The firing rate is also affected by adjacent grow hexes.)", "More adjacent speed hexes increase the batch's firing rate.", "More adjacent grow hexes minimally increases the batch's firing rate."]}, Movement...:{thrusters (S):["Speed batches increase the thrust of a celle."], optimized thrusters (S):["Speed batches in a line thrust more efficiently."], anti-thrusters (S+T):["Speed batches with tech hexes will counter thrusting movement after thrusters are disengaged. This helps keep a celle from \"floating.\""]}, core bonuses:["The type of hex of a celle's core gives all its batches a bonus:", "\tarmor: increased armor to all hexes", "\tbomb: increased power and size of dropped bombs", "\tgrow: increased grow times", "\tmissile: increased power and acceleration of fired missiles", "\tspeed: increased thrust", "\ttech: increased regeneration, bomb proximities, and missile seek radii"]}}; addEventListener(Event.ADDED_TO_STAGE, prepareGuide); } private function detailGuide(_arg1:Object, _arg2:NewDropdownMenu, _arg3:MenuItem=null):void{ var _local4:ARGSprite; var _local5:int; var _local6:*; var _local7:MenuItem; var _local8:NewDropdownMenu; if ((_arg1 is Array)){ if (!_arg3){ trace("cannot detail a page without a linked menu item"); return; }; _local4 = new ARGSprite(); _local4.visible = false; _local4.alpha = 0; addChild(_local4); _pages.push({page:_local4, item:_arg3}); Tools.makeText(_local4, _arg3.text, 10, 80, 14); _local5 = 0; while (_local5 < _arg1.length) { Tools.makeText(_local4, _arg1[_local5], 10, ((_local5 == 0)) ? 100 : ((_local4.getChildAt(_local5).y + _local4.getChildAt(_local5).height) + 10), 10, 0x333333, (stage.stageWidth - 20)); _local5++; }; } else { for (_local6 in _arg1) { _local7 = _arg2.addItem(_local6); if (!(_arg1[_local6] is Array)){ _local8 = new NewDropdownMenu(_local6); _arg2.addSubmenu(_local8, (_arg2.itemCount - 1)); _local8.addEventListener(NewDropdownMenu.CHOICE, menuChoice); }; detailGuide(_arg1[_local6], _local8, _local7); }; _arg2.sort(); }; } private function prepareGuide(_arg1:Event):void{ var _local2:NewDropdownMenu; var _local3:ARGSprite; _local2 = new NewDropdownMenu("Guide"); detailGuide(_guide, _local2); addChild(_local2); _local2.show(); _local2.x = 10; _local2.y = 45; _local2.addEventListener(NewDropdownMenu.CHOICE, menuChoice); _local3 = Tools.makeBoxButton(this, "close", 0, 10, 10, 0x333333); _local3.x = ((stage.stageWidth - 10) - _local3.width); _local3.addEventListener(MouseEvent.CLICK, goClose); graphics.clear(); graphics.lineStyle(1, 0x999999); graphics.beginFill(0x999999, 1); graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); } private function showSection(_arg1:MenuItem):void{ var _local2:*; for each (_local2 in _pages) { if (_local2.item == _arg1){ _local2.page.appear(); } else { _local2.page.disappear(); }; }; } private function menuChoice(_arg1:Event):void{ showSection(_arg1.target.choiceItem); } private function goClose(_arg1:MouseEvent):void{ dispatchEvent(new Event(CLOSE)); } } }//package hexcelle
Section 28
//Hex (hexcelle.Hex) package hexcelle { public class Hex extends UtilityCircleParticle { private var _type:int; private var _dead:Boolean; private var _celle:Celle; private var _armor:Number; public var toggle:Boolean; private var _maxArmor:Number; private var _generation:int; private var _links:Array; private var _pool:DNA; public function Hex(_arg1:Number=0, _arg2:Number=0, _arg3:Number=10, _arg4:Celle=null){ super(_arg1, _arg2, (_arg3 - 1)); _links = new Array(6); _pool = new DNA(); type = 2; _celle = _arg4; elasticity = 0.1; _dead = false; draw(); } public function destroy(_arg1:Player):void{ if (!_celle){ trace("this hex has no idea what celle it belongs to!"); return; }; if (_dead){ trace("hex is already dead"); return; }; _dead = true; _celle.destroyHex(this, _arg1); } public function get generation():int{ return (_generation); } public function get pool():DNA{ return (_pool); } public function set generation(_arg1:int){ _generation = _arg1; } public function get linkCount():int{ var _local1:int; var _local2:*; _local1 = 0; for each (_local2 in links) { if (_local2){ _local1++; }; }; return (_local1); } public function set pool(_arg1:DNA){ _pool = _arg1; } public function get maxArmor():Number{ return (_maxArmor); } public function get type():int{ return (_type); } public function get typeColor():uint{ return (HexSprite.typeColor(_type)); } public function draw():void{ var _local1:Boolean; var _local2:HexSprite; var _local3:Number; var _local4:int; var _local5:Number; _local1 = false; if (_celle){ if (_celle.core){ _local1 = (this == _celle.core); }; }; _local2 = new HexSprite((radius + 1), _type, this, _local1); if (radius > 5){ _local2.graphics.lineStyle(1, 0xFFFFFF, 0.2); _local3 = (radius * 0.7); _local4 = 0; while (_local4 < _links.length) { if (_links[_local4]){ _local2.graphics.moveTo(0, 0); _local5 = (Math.PI * ((-1 / 6) + (_local4 / 3))); _local2.graphics.lineTo((_local3 * Math.cos(_local5)), (_local3 * Math.sin(_local5))); }; _local4++; }; }; setDisplay(_local2); sprite.name = "hex sprite"; } public function get armor():Number{ return (_armor); } public function get celle():Celle{ return (_celle); } public function get dead():Boolean{ return (_dead); } public function set type(_arg1:int):void{ _type = _arg1; switch (_type){ case 0: mass = 1.3; break; case 1: mass = 1.2; break; case 2: mass = 0.8; break; case 3: mass = 1.3; break; case 4: mass = 1; break; case 5: mass = 1.1; break; }; draw(); } public function set maxArmor(_arg1:Number){ _maxArmor = _arg1; draw(); } public function set links(_arg1:Array){ _links = _arg1; } public function get freeLinks():int{ return ((6 - linkCount)); } public function set celle(_arg1:Celle):void{ _celle = _arg1; draw(); } public function set armor(_arg1:Number){ _armor = _arg1; draw(); } public function set dead(_arg1:Boolean):void{ _dead = _arg1; } public function get links():Array{ return (_links); } } }//package hexcelle
Section 29
//Hexes (hexcelle.Hexes) package hexcelle { import flash.display.*; import org.cove.ape.*; public class Hexes extends Group { private var _grid:Grid; private var _celle:Celle; private var _composition:DNA; private var _core:Hex; public function Hexes(_arg1:Celle){ collideInternal = true; _celle = _arg1; _core = new Hex(0, 0, _celle.hexSize, _celle); _grid = new Grid(_core); addParticle(_core); _composition = new DNA(); } public function applyToHexes(_arg1:Function){ _grid.applyToHexes(_arg1); } public function clearHex(_arg1:Hex):void{ var _local2:int; if (_arg1 == _core){ return; }; if (_arg1.sprite.parent){ _arg1.sprite.parent.removeChild(_arg1.sprite); }; removeParticle(_arg1); _local2 = 0; while (_local2 < constraints.length) { if (constraints[_local2].isConnectedTo(_arg1)){ if (APEngine.container.contains(constraints[_local2].sprite)){ APEngine.container.removeChild(constraints[_local2].sprite); }; removeConstraint(constraints[_local2]); _local2--; }; _local2++; }; _arg1.armor = -1; } private function compose():void{ var composer:Function; _composition = new DNA(); composer = function (_arg1:Hex){ _composition.changeByIndex(_arg1.type, 1); }; _grid.applyToHexes(composer); } public function removeConstraints():void{ var _local1:Array; var _local2:*; var _local3:*; _local1 = getAll(); for each (_local2 in _local1) { if ((_local2 is AbstractConstraint)){ if (APEngine.container.contains(_local2.sprite)){ APEngine.container.removeChild(_local2.sprite); }; }; }; for each (_local3 in _local1) { if ((_local3 is AbstractConstraint)){ removeConstraint(_local3); }; }; } public function initPhysics(){ var initHexParticle:Function; removeConstraints(); initHexParticle = function (_arg1:Hex){ var _local2:*; var _local3:Boolean; var _local4:*; var _local5:SpringConstraint; for each (_local2 in _arg1.links) { if (_local2){ _local3 = false; for each (_local4 in constraints) { if (((_local4.isConnectedTo(_local2)) && (_local4.isConnectedTo(_arg1)))){ _local3 = true; }; }; if (!_local3){ _local5 = new SpringConstraint(_arg1, _local2, _celle.hexLinkStiffness); addConstraint(_local5); _local5.sprite.name = "constraint sprite"; if (_local5.sprite.parent){ _local5.sprite.parent.removeChild(_local5.sprite); }; }; }; }; }; applyToHexes(initHexParticle); } public function get core():Hex{ return (_core); } public function positionHex(_arg1:Hex, _arg2:Hex, _arg3:int, _arg4:Number){ var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; _local5 = (_arg4 + 1); _local6 = (Math.PI / 3); _local7 = Math.cos(_local6); _local8 = Math.sin(_local6); switch (_arg3){ case 1: _arg1.x = ((_arg2.x + (_local5 * _local7)) + _local5); _arg1.y = (_arg2.y + (_local5 * _local8)); break; case 2: _arg1.x = _arg2.x; _arg1.y = (_arg2.y + ((2 * _local5) * _local8)); break; case 3: _arg1.x = ((_arg2.x - (_local5 * _local7)) - _local5); _arg1.y = (_arg2.y + (_local5 * _local8)); break; case 4: _arg1.x = ((_arg2.x - (_local5 * _local7)) - _local5); _arg1.y = (_arg2.y - (_local5 * _local8)); break; case 5: _arg1.x = _arg2.x; _arg1.y = (_arg2.y - ((2 * _local5) * _local8)); break; case 0: _arg1.x = ((_arg2.x + (_local5 * _local7)) + _local5); _arg1.y = (_arg2.y - (_local5 * _local8)); break; }; } public function toggleAll(_arg1:Boolean){ _grid.toggleAll(_arg1); } public function removeSprites():void{ var p:*; var c:*; var remover:Function; for each (p in particles) { if (p.sprite.parent){ p.sprite.parent.removeChild(p.sprite); }; }; for each (c in constraints) { if (c.sprite.parent){ c.sprite.parent.removeChild(c.sprite); }; }; remover = function (_arg1:Hex){ if (_arg1.sprite.parent){ _arg1.sprite.parent.removeChild(_arg1.sprite); }; }; grid.applyToHexes(remover); } public function addHex(_arg1:Hex, _arg2:int):Hex{ var _local3:String; var _local4:Hex; _local3 = ((_arg1)==null) ? "parent hex for hex addition is null" : ""; _local3 = (((((isNaN(_arg2)) || ((_arg2 < 0)))) || ((_arg2 > 5)))) ? "invalid index for hex addition" : ""; _local3 = ((grid.getAdjacentHex(_arg1, _arg2))!=null) ? ("hex already exists at index " + _arg2) : ""; _local3 = ((grid.getHexCoords(_arg1))==null) ? "parent hex does not exist in the celle" : ""; if (_local3 != ""){ trace(_local3); return (null); }; _local4 = new Hex(0, 0, _celle.hexSize, _celle); addParticle(_local4); _local4.generation = (_arg1.generation + 1); _grid.linkNewHex(_arg1, _local4, _arg2); positionHex(_local4, _arg1, _arg2, _celle.hexSize); return (_local4); } public function set core(_arg1:Hex){ var _local2:Hex; _local2 = _core; _core = _arg1; _grid.replaceHex(_local2, _arg1); _grid.core = _core; addParticle(_core); clearHex(_local2); } public function addEventListenerToHexes(_arg1:String, _arg2:Function){ var adder:Function; var e = _arg1; var f = _arg2; adder = function (_arg1:Hex):void{ _arg1.addSpriteEventListener(e, f); }; applyToHexes(adder); } public function get composition():DNA{ return (_composition); } public function getHexSpriteOwner(_arg1:Sprite):Hex{ var _local2:*; var _local3:*; for each (_local2 in grid.grid) { for each (_local3 in _local2) { if (_local3){ if (_local3.sprite == _arg1){ return (_local3); }; }; }; }; return (null); } public function draw():void{ var painter:Function; painter = function (_arg1:Hex){ _arg1.draw(); }; _grid.applyToHexes(painter); compose(); } public function get grid():Grid{ return (_grid); } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in particles) { _local2.translate(_arg1); }; } public function addForce(_arg1:Vector):void{ var f:VectorForce; var forcer:Function; var v = _arg1; f = new VectorForce(true, v.x, v.y); forcer = function (_arg1:Hex){ _arg1.addForce(f); }; applyToHexes(forcer); } public function removeEventListenerFromHexes(_arg1:String, _arg2:Function){ var remover:Function; var e = _arg1; var f = _arg2; remover = function (_arg1:Hex):void{ _arg1.removeSpriteEventListener(e, f); }; applyToHexes(remover); } public function set visible(_arg1:Boolean):void{ var _local2:*; for each (_local2 in particles) { _local2.visible = _arg1; }; } public function removeHexes(_arg1:Array):void{ var _local2:*; for each (_local2 in _arg1) { if (_local2 != _core){ clearHex(_local2); }; }; grid.removeHexes(_arg1, this); draw(); } public function removeHex(_arg1:Hex):void{ if (_arg1 == _core){ return; }; clearHex(_arg1); grid.removeHex(_arg1, this); draw(); } public function set hexSize(_arg1:Number){ var sizer:Function; var value = _arg1; sizer = function (_arg1:Hex):void{ _arg1.radius = value; }; applyToHexes(sizer); } } }//package hexcelle
Section 30
//HexSprite (hexcelle.HexSprite) package hexcelle { import flash.display.*; import flash.filters.*; public class HexSprite extends Sprite { public var hex:Hex; public var type:int; public var radius:Number; public function HexSprite(_arg1:Number=10, _arg2:int=0, _arg3:Hex=null, _arg4:Boolean=false){ radius = _arg1; type = _arg2; hex = _arg3; draw(_arg4); } public function position(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number){ var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; _local5 = _arg4; _local6 = (Math.PI / 3); _local7 = Math.cos(_local6); _local8 = Math.sin(_local6); switch (_arg3){ case 1: x = ((_arg1 + (_local5 * _local7)) + _local5); y = (_arg2 + (_local5 * _local8)); break; case 2: x = _arg1; y = (_arg2 + ((2 * _local5) * _local8)); break; case 3: x = ((_arg1 - (_local5 * _local7)) - _local5); y = (_arg2 + (_local5 * _local8)); break; case 4: x = ((_arg1 - (_local5 * _local7)) - _local5); y = (_arg2 - (_local5 * _local8)); break; case 5: x = _arg1; y = (_arg2 - ((2 * _local5) * _local8)); break; case 0: x = ((_arg1 + (_local5 * _local7)) + _local5); y = (_arg2 - (_local5 * _local8)); break; }; } private function drawHex(_arg1:Number):void{ var a:Number; var c:Number; var s:Number; var r = _arg1; if (r < 1){ return; }; a = (Math.PI / 3); c = Math.cos(a); s = Math.sin(a); var _local3 = graphics; with (_local3) { moveTo((r * c), (r * s)); lineTo(r, 0); lineTo((r * c), (-(r) * s)); lineTo((-(r) * c), (-(r) * s)); lineTo(-(r), 0); lineTo((-(r) * c), (r * s)); lineTo((r * c), (r * s)); }; } public function draw(_arg1:Boolean=false){ var r:Number; var a:Number; var c:Number; var s:Number; var dropShadow:*; var isCore = _arg1; r = radius; a = (Math.PI / 3); c = Math.cos(a); s = Math.sin(a); var _local3 = graphics; with (_local3) { clear(); if (hex){ if (hex.armor > 4){ lineStyle(3, 0xFFFFFF, 1); } else { lineStyle(Math.max((hex.armor - 1), 1), 0xFFFFFF, ((hex.armor * 0.2) + 0.2)); }; } else { lineStyle(1, 0xFFFFFF); }; switch (type){ case 0: beginFill(typeColor(0)); break; case 1: beginFill(typeColor(1)); break; case 2: beginFill(typeColor(2)); break; case 3: beginFill(typeColor(3)); break; case 4: beginFill(typeColor(4)); break; case 5: beginFill(typeColor(5)); break; case 6: r = (r - 2); beginGradientFill(GradientType.RADIAL, new Array(0, 0xDDDDDD), new Array(0.9, 0.7), new Array(0, 50)); break; case 7: lineStyle(3, 0x111111); r = (r + 4); break; case 8: lineStyle((r / 2), 0x999999, 0.7); beginFill(0x333333, 0.9); r = (r - 4); break; case 9: lineStyle(1, 0xFFFFFF); drawHex((r + 3)); lineStyle(1, 0xFFFFFF); drawHex((r - 3)); lineStyle(4, 9127187); beginFill(0x777777, 0.05); break; case 10: lineStyle(2, 3398963); drawHex((r - 1)); lineStyle(1, 3398963); beginFill(0xAAAAAA, 1); r = (r - 4); break; case 11: lineStyle(2, 3398963); drawHex((r + 1)); lineStyle(1, 3398963); beginFill(0xCCCC, 1); r = (r - 2); break; case 12: lineStyle(2, 3398963); drawHex((r - 1)); lineStyle(1, 3398963); beginFill(3385907, 1); r = (r - 4); break; case 13: lineStyle(2, 3398963); drawHex((r + 1)); lineStyle(1, 3398963); beginFill(11154227, 1); r = (r - 2); break; case 14: lineStyle(2, 3398963); drawHex((r + 1)); lineStyle(1, 3398963); beginFill(11184691, 1); r = (r - 2); break; case 15: lineStyle(2, 3398963); drawHex((r + 1)); lineStyle(1, 3398963); beginFill(11154346, 1); r = (r - 2); break; case 16: lineStyle(1, 0); drawHex(r); lineStyle(4, 0xEEEEEE); beginFill(0x777777, 0.05); r = (r - 3); break; }; drawHex(r); endFill(); if (isCore){ lineStyle(1, 0); drawHex((r - 1)); beginFill(0x222222, 0.5); drawCircle(0, 0, (r * 0.5)); endFill(); }; if ((((type >= 10)) && ((type <= 15)))){ dropShadow = new DropShadowFilter(); var _local4 = dropShadow; with (_local4) { distance = 6; angle = 40; blurX = 6; blurY = 6; alpha = 0.6; }; this.filters = [dropShadow]; }; }; } public static function typeColor(_arg1:int):uint{ if (_arg1 == 0){ return (0xAAAAAA); }; if (_arg1 == 1){ return (0xCCCC); }; if (_arg1 == 2){ return (3385907); }; if (_arg1 == 3){ return (10035746); }; if (_arg1 == 4){ return (11184691); }; if (_arg1 == 5){ return (12272827); }; return (0); } } }//package hexcelle
Section 31
//Intro (hexcelle.Intro) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; import flash.text.*; import flash.net.*; public class Intro extends UtilitySprite { private var _hexCount:int; private var _hexes:Group; private var _initialized:Boolean; private var _loadData:Array; private var _cloth:Sprite; private var _box:Sprite; private var _celleCount:int; private var _ui:Sprite; private var _celle:Celle; private var _credits:Sprite; private var _hexSize:Number; private var CELLES:Array; private var _main:Main; private var _loadText:TextField; private var celleOption; private var _instructions:Sprite; private var _celleName:Sprite; private var _guide:Guide; public function Intro(_arg1:Main):void{ _guide = new Guide(); super(); _main = _arg1; _initialized = false; } private function live(_arg1:Event):void{ var _local2:Hex; var _local3:CelleFile; if (_hexes.particles.length < _hexCount){ _local2 = new Hex(0, 0, _hexSize); _local2.type = Math.floor((Math.random() * 6)); _local2.x = (Math.random() * stage.stageWidth); _local2.y = -(_hexSize); _local2.sprite.alpha = 0.5; _local2.elasticity = 1; _local2.mass = 0.4; _hexes.addParticle(_local2); }; if (!_celle){ _local3 = new CelleFile(); _celle = _local3.loadFromString(CELLES[_celleCount][1]); _celle.x = (-(stage.stageWidth) / 3); _celle.y = (stage.stageHeight * 0.5); _celle.hexSize = 10; _celle.prepForPlay(); _celle.group.addCollidable(_hexes); _celle.core.addForce(new VectorForce(true, 80, 0)); while (_celleName.numChildren) { _celleName.removeChildAt(0); }; makeText(CELLES[_celleCount][0], 5, (stage.stageHeight - 50), _celleName, 8921634); _celleCount = (_celleCount + ((_celleCount)>0) ? -1 : (CELLES.length - 1)); } else { _celle.thrust(new Array(false, true, false, false)); if ((((_celle.x > (1.3 * stage.stageWidth))) || ((_celle.y > (1.3 * stage.stageHeight))))){ _celle.remove(); _celle = null; }; }; for each (_local2 in _hexes.particles) { _local2.addForce(new VectorForce(true, 0, 0.5)); if (_local2.y > (stage.stageHeight + _hexSize)){ _local2.y = -(_hexSize); _local2.x = (Math.random() * stage.stageWidth); _local2.velocity = new Vector(); }; }; } private function closeGuide(_arg1:Event):void{ _guide.disappear(); } private function init():void{ var tf:TextField; CELLES = Others.CELLES; _ui = new Sprite(); _main.ui.addChild(_ui); _hexSize = 6; _hexCount = 125; _hexes = new Group(); APEngine.addGroup(_hexes); makeText("hexcelle", 75, 50, _ui); makeText("adventure", 64, 65, _ui, 4473988); tf = makeText("new game", 64, 100, _ui); tf.addEventListener(MouseEvent.CLICK, goStart); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); tf = makeText("instructions", 54, 126, _ui); tf.addEventListener(MouseEvent.CLICK, goInstructions); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); _loadText = makeText("load game", 62.5, 150, _ui); _loadText.addEventListener(MouseEvent.CLICK, loadGame); _loadText.addEventListener(MouseEvent.MOUSE_OVER, goOver); _loadText.addEventListener(MouseEvent.MOUSE_OUT, goOut); tf = makeText("credits", 83, 175, _ui); tf.addEventListener(MouseEvent.CLICK, goCredits); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); tf = makeText("guide", 88, 200, _ui); tf.addEventListener(MouseEvent.CLICK, goGuide); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); tf = makeText("mute", ((stage.stageWidth / 2) - 20), (stage.stageHeight - 20), _ui); tf.addEventListener(MouseEvent.CLICK, goMute); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); makeText("©2009 adam r gimpert", (stage.stageWidth - 142), (stage.stageHeight - 20), _ui, 0x666666); makeText(_main.version, 5, (stage.stageHeight - 20), _ui, 0x666666); var _local2 = graphics; with (_local2) { beginFill(0x999999); drawRect(0, 0, stage.stageWidth, stage.stageHeight); }; _cloth = new Sprite(); _local2 = _cloth.graphics; with (_local2) { beginFill(0x999999); drawRect(0, 0, stage.stageWidth, stage.stageHeight); }; _cloth.visible = false; _ui.addChild(_cloth); _box = new Sprite(); _ui.addChild(_box); _celleName = new Sprite(); _ui.addChild(_celleName); _celleName.addEventListener(MouseEvent.CLICK, nextCelle); _celleCount = (CELLES.length - 1); _main.guide.addChild(_guide); _guide.alpha = 0; _guide.visible = false; _guide.addEventListener(Guide.CLOSE, closeGuide); } private function nextCelle(_arg1:MouseEvent):void{ var push:Function; var e = _arg1; if (!_celle){ return; }; push = function (_arg1:Hex):void{ _arg1.addForce(new VectorForce(true, 0, 80)); if (_arg1.type == DNA.SPEED){ _arg1.addForce(new VectorForce(true, 0, 50)); }; }; _celle.applyToHexes(push); } private function fadeOutCloth(_arg1:Event):void{ _cloth.alpha = (_cloth.alpha * 0.95); if (_cloth.alpha < 0.5){ _cloth.alpha = 0; _cloth.visible = false; removeEventListener(Event.ENTER_FRAME, fadeOutCloth); }; } private function checkLoadGame():void{ var _local1:SharedObject; _local1 = SharedObject.getLocal("HexcelleGame"); _loadText.visible = !((_local1.size == 0)); } private function goMute(_arg1:MouseEvent):void{ GameSound.mute = !(GameSound.mute); } private function goGuide(_arg1:MouseEvent):void{ _guide.appear(); } public function hide():void{ visible = false; _ui.visible = false; removeLive(); _loadData = null; stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); } public function get celle():Celle{ return (celleOption); } public function giveFocus(_arg1:Boolean=true):void{ if (!_initialized){ init(); }; checkLoadGame(); _loadData = null; addEventListener(Event.ENTER_FRAME, live); visible = true; _ui.visible = true; celleOption = null; stage.addEventListener(KeyboardEvent.KEY_UP, keyboardUp); } private function goStart(_arg1:MouseEvent):void{ var fadeOut:Function; var e = _arg1; fadeOut = function (_arg1:Event):void{ _cloth.alpha = (_cloth.alpha + ((1 - _cloth.alpha) * 0.2)); if (_cloth.alpha > 0.95){ _cloth.alpha = 1; removeEventListener(Event.ENTER_FRAME, fadeOut); while (_ui.numChildren) { _ui.removeChildAt(0); }; removeLive(); showBaseBuilds(); _ui.addChild(_cloth); addEventListener(Event.ENTER_FRAME, fadeOutCloth); }; }; _cloth.alpha = 0; _cloth.visible = true; addEventListener(Event.ENTER_FRAME, fadeOut); } private function goOut(_arg1:MouseEvent):void{ _box.graphics.clear(); } public function set celle(_arg1:Celle):void{ celleOption = _arg1; } private function goCredits(_arg1:MouseEvent):void{ var _local2:String; if (!_credits){ _credits = new Sprite(); _ui.addChildAt(_credits, 0); } else { if (_credits.parent){ _credits.visible = !(_credits.visible); if (((_instructions) && (_credits.visible))){ _instructions.visible = false; }; return; } else { _ui.addChildAt(_credits, 0); _credits.visible = true; if (_instructions){ _instructions.visible = false; }; return; }; }; if (_instructions){ _instructions.visible = false; }; _credits.graphics.beginFill(0xFFFFFF, 0.8); _credits.graphics.drawRect(137, 0, stage.stageWidth, stage.stageHeight); _local2 = "Credits"; _local2 = (_local2 + "\n\n\tConcept, design, and programming:"); _local2 = (_local2 + "\n\t\tAdam Gimpert"); _local2 = (_local2 + "\n\n\tSound and music creation:"); _local2 = (_local2 + "\n\t\tAdam Gimpert"); _local2 = (_local2 + "\n\n\tGame testing:"); _local2 = (_local2 + "\n\t\tBenjamin Gimpert"); _local2 = (_local2 + "\n\t\tNick Michelin"); _local2 = (_local2 + "\n\t\tKurt Johansen"); _local2 = (_local2 + "\n\n\tThanks:"); _local2 = (_local2 + "\n\t\tAlec Cove (APE)"); makeText(_local2, 150, 125, _credits); } private function removeLive():void{ var _local1:int; var _local2:*; var _local3:*; _local1 = 0; APEngine.removeGroup(_hexes); for each (_local2 in _hexes.particles) { if (APEngine.container.contains(_local2.sprite)){ APEngine.container.removeChild(_local2.sprite); }; }; for each (_local3 in _hexes.particles) { _hexes.removeParticle(_local3); }; if (_celle){ _celle.remove(); _celle = null; }; removeEventListener(Event.ENTER_FRAME, live); } private function goInstructions(_arg1:MouseEvent):void{ var pages:Array; var t:String; var h:HexSprite; var i:int; var goNext:Function; var page:*; var tf:TextField; var h2:HexSprite; var line:HexSprite; var h3:HexSprite; var e = _arg1; if (!_instructions){ _instructions = new Sprite(); _ui.addChildAt(_instructions, 0); } else { if (_instructions.parent){ _instructions.visible = !(_instructions.visible); if (((_credits) && (_instructions.visible))){ _credits.visible = false; }; return; } else { _ui.addChildAt(_instructions, 0); _instructions.visible = true; if (_credits){ _credits.visible = false; }; return; }; }; if (_credits){ _credits.visible = false; }; var _local3 = _instructions.graphics; with (_local3) { beginFill(0xFFFFFF, 0.8); drawRect(137, 0, stage.stageWidth, stage.stageHeight); }; pages = new Array(); t = "In Hexcelle, you control a 'celle' made of hexagonal parts that can"; t = (t + "\nshoot, move, drop bombs, build armor, and develop special skills."); t = (t + "\n\nGrow your celle to enormous sizes, destroy all 10 bosses, and"); t = (t + "\nventure far from home, uncovering as many areas as possible."); pages[0] = new Sprite(); makeText(t, 150, 125, pages[0]); t = "You will meet other celles on your way, some hostile, some not. All"; t = (t + "\ncan be destroyed for food."); t = (t + "\n\nAs your celle travels, you will collect food, , which will allow your"); t = (t + "\ncelle to evolve, adding more hexes to its body."); t = (t + "\n\nCollecting food and evolving is the only way to grow your celle."); pages[1] = new Sprite(); makeText(t, 150, 125, pages[1]); _local3 = pages[1].graphics; with (_local3) { beginFill(873458, 1); lineStyle(2, 12320529); drawCircle(395, 168, 3); endFill(); }; t = "There are six types of hexes:"; t = (t + "\n\narmor \n\nbomb \n\ngrow \n\nmissile \n\nspeed \n\ntech"); pages[2] = new Sprite(); makeText(t, 150, 125, pages[2]); i = 0; while (i < 6) { h = new HexSprite(6, i); h.x = 212; h.y = (159 + (i * 23.8)); pages[2].addChild(h); i = (i + 1); }; t = "\n\nmakes hexes more difficult to destroy"; t = (t + "\n\n gives a celle the ability to drop bombs"); t = (t + "\n\n allows quicker celle evolution"); t = (t + "\n\n gives a celle the ability to fire missiles"); t = (t + "\n\n increases thrust for movement"); t = (t + "\n\n develops the abilities of batches"); makeText(t, 230, 125, pages[2]); t = "When evolving your celle, try to group similar hexes together."; t = (t + "\nThis can be done in close clusters or in lines."); t = (t + "\n\nThe type of hex and size of these 'batches' will affect"); t = (t + "\nthe behavior of the celle."); t = (t + "\n\nFor instance, larger batches of missile hexes will allow"); t = (t + "\nthe celle to fire larger missiles."); pages[3] = new Sprite(); makeText(t, 150, 125, pages[3]); h = new HexSprite(6, DNA.MISSILE); h.x = 225; h.y = 280; pages[3].addChild(h); i = 0; while (i < 6) { h2 = new HexSprite(6, DNA.MISSILE); h2.position(h.x, h.y, i, 6); pages[3].addChild(h2); i = (i + 1); }; h = new HexSprite(6, DNA.MISSILE); h.x = 300; h.y = 270; pages[3].addChild(h); i = 0; while (i < 3) { line = new HexSprite(6, DNA.MISSILE); line.position(h.x, h.y, 1, 6); pages[3].addChild(line); h = line; i = (i + 1); }; t = "Each batch (a group of hexes of similar type) is affected"; t = (t + "\nby adjacent hexes."); t = (t + "\n\nFor example, a batch of missile hexes with adjacent speed"); t = (t + "\nhexes will not only fire larger missiles because of the batch, but"); t = (t + "\nwill also fire at a faster rate because of the adjacent speed hexes."); pages[4] = new Sprite(); makeText(t, 150, 125, pages[4]); h = new HexSprite(6, DNA.MISSILE); h.x = 275; h.y = 260; pages[4].addChild(h); i = 0; while (i < 6) { if (i < 4){ h3 = new HexSprite(6, DNA.MISSILE); } else { h3 = new HexSprite(6, DNA.SPEED); }; h3.position(h.x, h.y, i, 6); pages[4].addChild(h3); i = (i + 1); }; t = "Lastly, each celle has a core hex, shown darker than others."; t = (t + "\n\nIf a celle's core is ever destroyed, the entire celle"); t = (t + "\nwill self-destruct. So protect your celle's core!"); t = (t + "\n\nMove your celle with the W,A,S,D or arrow keys."); t = (t + "\nFire missiles with the left mouse button."); t = (t + "\nDrop bombs with the space bar."); t = (t + "\nEvolve by pressing E (when you have collected enough food)."); t = (t + "\nShow the map by holding shift."); t = (t + "\nPress P to pause and unpause the game."); pages[5] = new Sprite(); makeText(t, 150, 125, pages[5]); t = "The following instruction pages contain even more game details."; t = (t + "\n\nSplash Damage"); t = (t + "\nMissiles and bombs deal splash damage, meaning hexes adjacent"); t = (t + "\nto the one hit will also suffer damage, but not as much. Thus,"); t = (t + "\nit is possible, but difficult, to destroy a core that is"); t = (t + "\ncompletely surrounded by hexes."); t = (t + "\n\nEvolves"); t = (t + "\nThe cost of evolving relates to the number of hexes in your celle."); t = (t + "\nSo after evolving, if you spawned new hexes, the cost of your"); t = (t + "\nnext evolution will be more than the previous one."); pages[6] = new Sprite(); makeText(t, 150, 125, pages[6]); t = "Evolution"; t = (t + "\nBe mindful of how you construct your celle. Missile hexes spawned"); t = (t + "\nfar from your core will be more difficult to aim. Clusters of"); t = (t + "\nhexes behave differently than lines. A celle's core type alters"); t = (t + "\nthe behavior of similar batches throughout the entire celle. Grow"); t = (t + "\nhexes are essential for adequate spawning and mutation. Tech hexes"); t = (t + "\nincrease the size of a batch, and add essential abilities. Large,"); t = (t + "\ndense celles may implode - arm-like growths help avoid this."); t = (t + "\n\nStudy the enemy's composition. Enemy celles are no different than"); t = (t + "\nyours."); pages[7] = new Sprite(); makeText(t, 150, 125, pages[7]); t = "Surviving"; t = (t + "\nAs you venture away from your home area, enemy celles will be"); t = (t + "\nlarger and more skilled."); t = (t + "\n\nPay attention to your play style. If you are having difficulty"); t = (t + "\ndodging enemy missiles, consider spawning more armor or speed for"); t = (t + "\nhelp. Consider defensive as well as offensive tactics."); t = (t + "\n\nDo not rush into new areas. Your celle will be slowed if moving"); t = (t + "\ntoo quickly into a new area. Bosses will not spawn when rushing."); pages[8] = new Sprite(); makeText(t, 150, 125, pages[8]); goNext = function (_arg1:MouseEvent):void{ i = 0; while (i < pages.length) { if (pages[i].visible){ if (i < (pages.length - 1)){ pages[i].visible = false; pages[(i + 1)].visible = true; i = pages.length; } else { pages[i].visible = false; _instructions.visible = false; pages[0].visible = true; }; }; i++; }; GameSound.play("ui"); }; for each (page in pages) { page.visible = false; _instructions.addChild(page); }; tf = makeText("NEXT >>>", 465, 300, _instructions); tf.addEventListener(MouseEvent.CLICK, goNext); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); pages[0].visible = true; } public function get loadData():Array{ return (_loadData); } private function showBaseBuilds():void{ var baseBuildStrings:Array; var descriptions:Array; var options:Array; var choice:int; var box:Sprite; var spacing:Number; var description:TextField; var tf:TextField; var loader:CelleFile; var i:int; var field:Sprite; var goPlay:Function; var goBack:Function; var moveBox:Function; var indexBox:Function; var checkMouse:Function; var mouseClick:Function; var center:Function; var celle:Celle; baseBuildStrings = ["2;2;0;0;true;0.45;0;0;3;0;1;4;1;0;5;1;1;2", "3;3;1;1;false;0.56;0;2;3;1;0;4;1;1;2;2;2;3", "3;2;1;1;false;0.67;0;1;3;1;0;2;1;1;1;2;1;4", "2;3;0;0;true;0.59;0;0;0;1;0;4;1;1;2;1;2;3"]; descriptions = ["missilus technicus \n\na solid base build providing an excellent path for evolution to \nstrong missiles with technical modifications \n\nbeware, however, that this celle's core is unprotected on one side", "growicus missilduplicae \n\nthis base build provides two starting \nmissile batches and a grow core for \nthe best growing abilities and fast evolution \n\nit's moving limbs make its core easy to protect", "bombus generium \n\na missile-firing celle ready to evolve strong bombing capabilities \n\nthe bomb core of this celle is highly exposed, \nso take great care to protect it", "armorus missilia \n\nwith an armored core, this celle is a safe choice for fast exploring", "< custom build > \n\nbuild a unique base celle\n\nfor advanced evolutionaries who want to test\nthe fringes of celle development"]; options = new Array(); description = makeText("", 50, (stage.stageHeight * 0.67), _ui); description.multiline = true; tf = makeText("select a starting celle then click PLAY in the lower right corner", 50, 25, _ui); if (_loadText.visible){ tf.appendText("\nWARNING: Clicking PLAY will replace your saved game!"); }; loader = new CelleFile(); spacing = (stage.stageWidth / (baseBuildStrings.length + 1)); i = 0; while (i < baseBuildStrings.length) { celle = loader.loadFromString(baseBuildStrings[i]); celle.x = ((i * spacing) + (spacing / 2)); celle.y = (stage.stageHeight * 0.33); celle.hexSize = 10; options.push(celle); i = (i + 1); }; field = new Sprite(); field.graphics.beginFill(0, 0); field.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); _ui.addChild(field); field.graphics.beginFill(0, 0.8); field.graphics.drawCircle((stage.stageWidth - (spacing / 2)), (stage.stageHeight * 0.33), 10); field.addChild(_box); goPlay = function (_arg1:MouseEvent):void{ var _local2:*; GameSound.play("ui"); _ui.removeChild(field); field.removeEventListener(MouseEvent.MOUSE_MOVE, checkMouse); field.removeEventListener(MouseEvent.CLICK, mouseClick); box.removeEventListener(Event.ENTER_FRAME, moveBox); removeEventListener(Event.ENTER_FRAME, center); if (choice < options.length){ celleOption = options[choice]; }; for each (_local2 in options) { if (_local2 != celleOption){ _local2.remove(); }; }; if (choice < options.length){ _main.switchScreen("player"); } else { _main.switchScreen("evolver"); }; }; tf = makeText("PLAY", (stage.stageWidth - 50), (stage.stageHeight - 20), _ui); tf.addEventListener(MouseEvent.CLICK, goPlay); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); goBack = function (_arg1:MouseEvent):void{ var fadeOut:Function; var e = _arg1; GameSound.play("ui"); fadeOut = function (_arg1:Event):void{ var _local2:*; _cloth.alpha = (_cloth.alpha + ((1 - _cloth.alpha) * 0.2)); if (_cloth.alpha > 0.95){ _cloth.alpha = 1; removeEventListener(Event.ENTER_FRAME, fadeOut); _ui.removeChild(field); field.removeEventListener(MouseEvent.MOUSE_MOVE, checkMouse); field.removeEventListener(MouseEvent.CLICK, mouseClick); box.removeEventListener(Event.ENTER_FRAME, moveBox); removeEventListener(Event.ENTER_FRAME, center); for each (_local2 in options) { _local2.remove(); }; hide(); giveFocus(); }; }; _cloth.alpha = 0; _cloth.visible = true; removeEventListener(Event.ENTER_FRAME, fadeOutCloth); removeEventListener(Event.ENTER_FRAME, fadeOut); addEventListener(Event.ENTER_FRAME, fadeOut); }; tf = makeText("BACK", 10, (stage.stageHeight - 20), _ui); tf.addEventListener(MouseEvent.CLICK, goBack); tf.addEventListener(MouseEvent.MOUSE_OVER, goOver); tf.addEventListener(MouseEvent.MOUSE_OUT, goOut); box = new Sprite(); var _local2 = box.graphics; with (_local2) { lineStyle(5, 0); drawRect((-(spacing) / 2), (-(spacing) / 2), spacing, spacing); }; box.x = stage.stageWidth; box.y = (stage.stageHeight * 0.33); _ui.addChild(box); moveBox = function (_arg1:Event):void{ var _local2:Number; _local2 = ((choice * spacing) + (spacing / 2)); if (Math.abs((box.x - _local2)) <= 1){ box.removeEventListener(Event.ENTER_FRAME, moveBox); } else { box.x = (box.x + ((_local2 - box.x) * 0.1)); }; }; indexBox = function (_arg1:int):void{ choice = _arg1; box.removeEventListener(Event.ENTER_FRAME, moveBox); box.addEventListener(Event.ENTER_FRAME, moveBox); }; checkMouse = function (_arg1:MouseEvent):void{ var _local2:int; _local2 = Math.floor((mouseX / spacing)); description.text = descriptions[_local2]; }; mouseClick = function (_arg1:MouseEvent):void{ var _local2:int; var _local3:Number; var _local4:Hex; _local2 = Math.floor((mouseX / spacing)); _local3 = 200; if (_local2 < options.length){ _local4 = options[_local2].group.particles[Math.floor((Math.random() * options[_local2].group.particles.length))]; _local4.addForce(new VectorForce(true, (-(_local3) + ((Math.random() * 2) * _local3)), (-(_local3) + ((Math.random() * 2) * _local3)))); }; indexBox(_local2); GameSound.play("ui"); }; center = function (_arg1:Event):void{ var _local2:int; var _local3:Celle; var _local4:Number; var _local5:Number; var _local6:Vector; _local2 = 0; while (_local2 < options.length) { _local3 = options[_local2]; _local4 = (((_local2 * spacing) + (spacing / 2)) - _local3.x); _local5 = ((stage.stageHeight * 0.33) - _local3.y); _local6 = new Vector(_local4, _local5); _local6.multEquals(0.2); _local3.translate(_local6); _local2++; }; }; addEventListener(Event.ENTER_FRAME, center); indexBox(0); field.addEventListener(MouseEvent.MOUSE_MOVE, checkMouse); field.addEventListener(MouseEvent.CLICK, mouseClick); } private function keyboardUp(_arg1:KeyboardEvent){ var _local2:Number; if (_celle){ _local2 = (20 * _celle.hexCount); switch (_arg1.keyCode){ case 38: _celle.core.addForce(new VectorForce(true, 0, -(_local2))); break; case 39: _celle.core.addForce(new VectorForce(true, _local2, 0)); break; case 40: _celle.core.addForce(new VectorForce(true, 0, _local2)); break; case 37: _celle.core.addForce(new VectorForce(true, -(_local2), 0)); break; }; }; } private function goOver(_arg1:MouseEvent):void{ var offset:Number; var x:Number; var y:Number; var w:Number; var h:Number; var e = _arg1; offset = 5; x = (e.target.x - offset); y = (e.target.y - offset); w = (e.target.width + (offset * 2)); h = (e.target.height + (offset * 2)); var _local3 = _box.graphics; with (_local3) { lineStyle(2, 0x666666); drawRect(x, y, w, h); }; GameSound.play("ui"); } private function loadGame(_arg1:MouseEvent):void{ var _local2:SharedObject; var _local3:CelleFile; _local2 = SharedObject.getLocal("HexcelleGame"); if (_local2.size == 0){ return; }; GameSound.play("ui"); _local3 = new CelleFile(); celleOption = _local3.loadFromString(_local2.data.celle); _loadData = new Array(); _loadData.push(_local2.data.areas); _loadData.push(_local2.data.player); _main.switchScreen("player"); } } }//package hexcelle
Section 32
//Kong (hexcelle.Kong) package hexcelle { import flash.display.*; import flash.events.*; import flash.system.*; import flash.net.*; public class Kong extends Sprite { public var kong; private var _ready:Boolean;// = false private var _stage:Stage; public function Kong(_arg1:Stage):void{ _ready = false; super(); _stage = _arg1; _arg1.addChild(this); init(); } private function init():void{ var _local1:Object; var _local2:String; var _local3:URLRequest; var _local4:Loader; _local1 = LoaderInfo(_stage.root.loaderInfo).parameters; _local2 = ((_local1.kongregate_api_path) || ("http://www.kongregate.com/flash/API_AS3_Local.swf")); Security.allowDomain(_local2); _local3 = new URLRequest(_local2); _local4 = new Loader(); _local4.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); _local4.contentLoaderInfo.addEventListener(Event.OPEN, loadOpen); _local4.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError); _local4.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress); _local4.load(_local3); this.addChild(_local4); } private function loadComplete(_arg1:Event):void{ kong = _arg1.target.content; kong.services.connect(); _ready = true; } private function loadOpen(_arg1:Event):void{ } public function submitStats(_arg1:Array):void{ var _local2:*; if (!_ready){ return; }; for each (_local2 in _arg1) { submitStat(_local2.name, _local2.value); }; } private function loadProgress(_arg1:ProgressEvent):void{ } public function submitStat(_arg1:String, _arg2:Number):void{ if (!_ready){ return; }; kong.stats.submit(_arg1, _arg2); } private function loadError(_arg1:IOErrorEvent):void{ Main.debug(("kong api load error: " + _arg1)); } } }//package hexcelle
Section 33
//Main (hexcelle.Main) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; import flash.text.*; import arg.*; public class Main extends UtilitySprite { private const START_SCREEN:String = "intro"; public var guide:Sprite; private var _cloth:Sprite; private var _kong:Kong; private var _ui:Sprite; private var editor:Editor; private var intro:Intro; private var screen:String; private var evolver:Evolver; private var _top:Sprite; private var _newScreen:String; private var _game:Sprite; private var player:Player; public var version:String;// = "v0.11" public static const DEBUG:Boolean = true; private static var _errorFade:int; private static var _argLogo:ARGLogo = new ARGLogo(); private static var _errorSprite:ARGSprite; private static var _argDone:Boolean = false; public function Main(){ guide = new Sprite(); version = "v0.11"; super(); _game = new Sprite(); _game.name = "game sprite"; APEngine.init(); APEngine.container = _game; APEngine.damping = 0.99; } private function uncoverAndGo(_arg1:Event):void{ _cloth.alpha = (_cloth.alpha * 0.8); if (_cloth.alpha < 0.05){ _cloth.visible = false; _cloth.alpha = 0.5; removeEventListener(Event.ENTER_FRAME, uncoverAndGo); }; } public function init():void{ if (!_argDone){ showARG(); return; }; _errorSprite = new ARGSprite(); addChild(_errorSprite); GameSound.init(stage); addChild(_game); _ui = new Sprite(); _ui.name = "main ui"; addChild(_ui); _top = new Sprite(); _top.name = "main top"; addChild(_top); _cloth = new Sprite(); _cloth.name = "main cloth"; var _local2 = _cloth.graphics; with (_local2) { beginFill(0xFFFFFF); drawRect(0, 0, stage.stageWidth, stage.stageHeight); }; _cloth.visible = false; addChild(_cloth); editor = new Editor(this); _game.addChildAt(editor, 0); evolver = new Evolver(this); _game.addChildAt(evolver, 0); player = new Player(this); _game.addChildAt(player, 0); intro = new Intro(this); _game.addChildAt(intro, 0); prepKong(); addChild(guide); switchScreen(START_SCREEN); addEventListener(Event.ENTER_FRAME, update); removeChild(_errorSprite); addChild(_errorSprite); } private function showARG():void{ addChild(_argLogo).addEventListener(Event.COMPLETE, logoDone); _argLogo.appear(); } public function get cloth():Sprite{ return (_cloth); } private function coverAndSwitch(_arg1:Event):void{ _cloth.alpha = (_cloth.alpha + ((1 - _cloth.alpha) * 0.15)); if (_cloth.alpha > 0.95){ _cloth.alpha = 1; removeEventListener(Event.ENTER_FRAME, coverAndSwitch); doSwitch(_newScreen); addEventListener(Event.ENTER_FRAME, uncoverAndGo); }; } public function get gameSprite():Sprite{ return (_game); } public function submitStats(_arg1:Array):void{ _kong.submitStats(_arg1); } public function get top():Sprite{ return (_top); } private function doSwitch(_arg1:String):void{ var _local2:Array; if (_arg1 == screen){ return; }; if (_arg1 == "player"){ if (screen == "editor"){ editor.hide(); player.celle = editor.celle; } else { if (screen == "evolver"){ evolver.hide(); player.celle = Evolver.celle; } else { if (screen == "intro"){ _local2 = intro.loadData; intro.hide(); player.celle = intro.celle; }; }; }; GameSound.startMusic("main"); player.giveFocus(_local2); } else { if (_arg1 == "editor"){ if (screen == "player"){ player.hide(); editor.celle = player.celle; } else { if (screen == "evolver"){ evolver.hide(); editor.celle = Evolver.celle; } else { if (screen == "intro"){ intro.hide(); }; }; }; GameSound.startMusic("main"); editor.giveFocus(); } else { if (_arg1 == "evolver"){ if (screen == "player"){ player.hide(); Evolver.celle = player.celle; } else { if (screen == "editor"){ editor.hide(); Evolver.celle = editor.celle; } else { if (screen == "intro"){ intro.hide(); Evolver.celle = null; }; }; }; GameSound.startMusic("intro"); evolver.giveFocus(); } else { if (_arg1 == "intro"){ if (screen == "player"){ player.hide(); } else { if (screen == "editor"){ editor.hide(); } else { if (screen == "evolver"){ evolver.hide(); }; }; }; intro.giveFocus(); GameSound.startMusic("intro"); }; }; }; }; screen = _arg1; } public function submitStat(_arg1:String, _arg2:Number):void{ _kong.submitStat(_arg1, _arg2); } public function get ui():Sprite{ return (_ui); } public function switchScreen(_arg1:String):void{ if (_arg1 == screen){ return; }; _newScreen = _arg1; removeEventListener(Event.ENTER_FRAME, uncoverAndGo); removeEventListener(Event.ENTER_FRAME, coverAndSwitch); if (!_cloth.visible){ _cloth.alpha = 0; _cloth.visible = true; }; addEventListener(Event.ENTER_FRAME, coverAndSwitch); } public function update(_arg1:Event):void{ if ((((((screen == "player")) && (!(player.paused)))) || ((screen == "intro")))){ APEngine.step(); }; APEngine.paint(); } private function logoDone(_arg1:Event):void{ _argDone = true; init(); } private function prepKong():void{ _kong = new Kong(stage); } private static function errorUpdate(_arg1:Event):void{ if (_errorFade > 0){ if (--_errorFade == 0){ _errorSprite.removeEventListener(Event.ENTER_FRAME, errorUpdate); _errorSprite.disappear(); }; }; } public static function reportError(_arg1:String):void{ var _local2:TextField; trace(_arg1); _arg1 = ((" " + _arg1) + " "); if (_errorSprite){ if (_errorSprite.numChildren > 0){ _local2 = TextField(_errorSprite.getChildByName("txt")); if (_local2.height > 500){ _local2.text = _arg1; } else { _local2.appendText(("\n" + _arg1)); }; } else { _local2 = Tools.makeText(_errorSprite, _arg1, 0, 0, 10, 0xAAAAAA); _local2.selectable = true; _errorSprite.addEventListener(Event.ENTER_FRAME, errorUpdate); }; _errorSprite.y = ((_errorSprite.stage.stageHeight - _local2.height) - 10); _errorSprite.graphics.clear(); _errorSprite.graphics.beginFill(0, 0.5); _errorSprite.graphics.drawRect(0, 0, _errorSprite.width, _errorSprite.height); _errorSprite.appear(); _errorFade = 900; }; } public static function debug(_arg1:String):void{ if (DEBUG){ reportError(_arg1); }; } } }//package hexcelle
Section 34
//MenuItem (hexcelle.MenuItem) package hexcelle { import flash.events.*; import flash.text.*; public class MenuItem extends ARGSprite { private var _enabled:Boolean;// = true private var _text:String; private var _tf:TextField; public var textColor:uint;// = 0x333333 private var _hover:Boolean; public var hoverTextColor:uint;// = 0x222222 public var target:Object; private var _height:Number; public var submenu:NewDropdownMenu; private var _previousText:String; private var _width:Number; private var _input:Boolean;// = false public var backgroundColor:uint;// = 0xDDDDDD public var hoverBackgroundColor:uint;// = 0xAAAAAA public static const CLICK:String = "MenuItem_Click"; public static const CHANGE:String = "MenuItem_Change"; public function MenuItem(_arg1:String){ textColor = 0x333333; backgroundColor = 0xDDDDDD; hoverTextColor = 0x222222; hoverBackgroundColor = 0xAAAAAA; _enabled = true; _input = false; super(); visible = false; _text = _arg1; draw(false); } public function get text():String{ return (_tf.text); } public function get enabled():Boolean{ return (_enabled); } public function hide():void{ disappear(this); removeEventListener(MouseEvent.MOUSE_OVER, onOver); removeEventListener(MouseEvent.MOUSE_OUT, onOut); removeEventListener(MouseEvent.CLICK, onClick); } override public function set height(_arg1:Number):void{ _height = _arg1; drawBackground(); } private function onOver(_arg1:MouseEvent):void{ if (((!(_input)) && (_enabled))){ draw(true); }; } private function draw(_arg1:Boolean):void{ var _local2:Number; var _local3:Number; var _local4:Number; _hover = _arg1; if ((((((_text == "")) || (_input))) || (!(_enabled)))){ _hover = false; }; if (_tf){ removeChild(_tf); }; _local2 = 0; _local3 = 0; _local4 = 10; if (_input){ _tf = Tools.makeInput(this, _text, _local2, _local3, _local4, textColor); _tf.addEventListener(Event.CHANGE, onInputChange); } else { _tf = Tools.makeText(this, _text, _local2, _local3, _local4, (_hover) ? hoverTextColor : textColor); }; _tf.background = false; addChild(_tf); if (!_width){ _width = _tf.width; }; if (!_height){ _height = _tf.height; }; drawBackground(); buttonMode = ((!(_input)) && (_enabled)); mouseChildren = _input; } override public function toString():String{ return (_text); } public function set enabled(_arg1:Boolean):void{ _enabled = _arg1; buttonMode = _enabled; } public function set text(_arg1:String):void{ _previousText = _text; _text = _arg1; if (_input){ _tf.text = _text; }; draw(_hover); dispatchEvent(new Event(CHANGE)); } override public function set width(_arg1:Number):void{ _width = _arg1; drawBackground(); } private function drawBackground():void{ graphics.clear(); graphics.beginFill((_hover) ? hoverBackgroundColor : backgroundColor); graphics.drawRect(0, 0, _width, _height); } public function get minWidth():Number{ return (_tf.width); } private function onInputChange(_arg1:Event):void{ _width = _tf.width; _previousText = _text; _text = _tf.text; drawBackground(); dispatchEvent(new Event(CHANGE)); } public function get input():Boolean{ return (_input); } public function set input(_arg1:Boolean):void{ if (_input == _arg1){ return; }; _input = _arg1; draw(!(_input)); } public function get previousText():String{ return (_previousText); } public function refresh():void{ draw(_hover); } private function onClick(_arg1:MouseEvent):void{ if (((enabled) && (!(_input)))){ dispatchEvent(new Event(CLICK)); }; } private function onOut(_arg1:MouseEvent):void{ if (((!(_input)) && (_enabled))){ draw(false); }; } public function show():void{ if (visible){ return; }; alpha = 0; visible = true; draw(false); appear(this); addEventListener(MouseEvent.MOUSE_OVER, onOver); addEventListener(MouseEvent.MOUSE_OUT, onOut); addEventListener(MouseEvent.CLICK, onClick); } } }//package hexcelle
Section 35
//Missile (hexcelle.Missile) package hexcelle { import flash.display.*; import org.cove.ape.*; public class Missile extends UtilityCircleParticle { public var power:Number; private var _player:Player; public var seekRadius:Number; public var propel:Vector; public var burnIn:Number; private var seekFX:Effect; public var seekTime:int; public var growTime:int; private var _group:Missiles; public var fuel:Number; public var seekLock:Celle; public var growth:Number; public var seekThrust:int; public function Missile(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Missiles, _arg6:Player){ super(_arg1, _arg2, _arg3); _group = _arg5; _group.addParticle(this); addEventListener(CollisionEvent.COLLIDE, collide); _player = _arg6; this.seekRadius = _arg4; mass = (radius / 2); draw(); } public function destroy():void{ var _local1:int; remove(); if (_player.fxNo > 0){ _player.fx.implode(x, y, (radius + 2)); }; if (radius > 3){ _local1 = Math.floor(radius); if (_player.fxNo == 1){ _local1 = Math.ceil((_local1 / 2)); } else { if (_player.fxNo == 0){ _local1 = Math.ceil((_local1 / 3)); }; }; _player.fx.clash(x, y, (radius * radius), radius, _local1); }; } public function collide(_arg1:CollisionEvent):void{ var _local2:int; var _local3:Faun; var _local4:Hex; var _local5:*; var _local6:Vector; var _local7:Missile; var _local8:Number; if ((_arg1.collidingItem is Faun)){ _local3 = Faun(_arg1.collidingItem); _local3.hit(this, _player); destroy(); if (_player.fxNo > 1){ _local2 = (radius * 2); } else { if (_player.fxNo > 0){ _local2 = radius; } else { _local2 = 0; }; }; if (_local2 > 0){ _player.fx.confetti(x, y, velocity.mult(-1), (power / 2), 0.4, _local2); }; _local2 = (6 + power); if (_player.fxNo == 1){ _local2 = Math.ceil((_local2 / 2)); } else { if (_player.fxNo == 0){ _local2 = Math.ceil((_local2 / 3)); }; }; _player.fx.shardSpray(x, y, velocity.mult(-1), 0.35, 2.5, (power / 6), _local2, 0x888888); } else { if ((_arg1.collidingItem is Hex)){ if (_player.celle.missiles != _group){ GameSound.play("hit"); }; _local4 = Hex(_arg1.collidingItem); Hex(_arg1.collidingItem).armor = (_local4.armor - (power / 6)); for each (_local5 in _local4.links) { if (_local5){ _local5.armor = (_local5.armor - (power / 10)); }; }; _local6 = velocity.normalize().mult(power); _local4.addForce(new VectorForce(true, _local6.x, _local6.y)); destroy(); _local2 = (6 + power); if (_player.fxNo == 1){ _local2 = Math.ceil((_local2 / 2)); } else { if (_player.fxNo == 0){ _local2 = Math.ceil((_local2 / 3)); }; }; _player.fx.shardSpray(x, y, velocity.mult(-1), 0.35, 3, (power / 6), _local2, _local4.typeColor); } else { if ((_arg1.collidingItem is Missile)){ _local7 = Missile(_arg1.collidingItem); _local8 = power; power = (power - _local7.power); if (power <= 0){ power = 0.01; }; radius = (radius * (power / _local8)); if (radius < 1.5){ destroy(); } else { mass = (radius / 2); draw(); }; }; }; }; } public function draw():void{ var mSprite:Sprite; var r:*; var s:*; mSprite = new Sprite(); var _local2 = mSprite.graphics; with (_local2) { r = ((radius)>2) ? (radius - 1) : 2; s = ((radius)>3) ? 2 : 1; if (_player.celle.missiles == _group){ lineStyle(s, 0x884400); beginFill(3346705); } else { lineStyle(s, 0xFF9900); beginFill(10031377); }; drawCircle(0, 0, r); endFill(); if (seekFX){ seekFX.remove(); }; if ((((seekRadius > 0)) && (!(seekLock)))){ lineStyle(1, 16729156, 0.2); drawCircle(0, 0, seekRadius); }; }; setDisplay(mSprite); sprite.name = "missile sprite"; } public function remove():void{ removeEventListener(CollisionEvent.COLLIDE, collide); _group.removeParticle(this); if (sprite.parent){ sprite.parent.removeChild(sprite); }; if (seekFX){ seekFX.remove(); }; } } }//package hexcelle
Section 36
//Missiles (hexcelle.Missiles) package hexcelle { import org.cove.ape.*; public class Missiles extends Group { private var _player:Player; private var _firing:Boolean; public function Missiles(_arg1:Player){ _player = _arg1; _firing = false; APEngine.addGroup(this); collideInternal = false; } public function get firing():Boolean{ return (_firing); } public function update():void{ var _local1:Vector; var _local2:*; var _local3:*; var _local4:*; var _local5:Number; var _local6:int; var _local7:int; var _local8:Celle; var _local9:int; var _local10:int; var _local11:Vector; var _local12:Vector; var _local13:Number; var _local14:Vector; for each (_local2 in particles) { if (_player.testOutOfBounds(_local2)){ _local2.remove(); }; }; if ((((((_player.fxNo == 1)) && (((_player.frameCount % 2) == 0)))) || ((_player.fxNo > 1)))){ for each (_local4 in particles) { if (_player.testOnScreen(_local4)){ _local1 = _local4.velocity; if (_player.celle.missiles == this){ _player.fx.streak(_local4.x, _local4.y, (_local4.x - _local1.x), (_local4.y - _local1.y), (_local4.radius * 2), 0xFFFFFF); } else { _player.fx.streak(_local4.x, _local4.y, (_local4.x - _local1.x), (_local4.y - _local1.y), (_local4.radius * 2), 16724787); }; }; }; }; for each (_local3 in particles) { _local1 = _local3.velocity; if (_local3.fuel > 0){ _local3.addForce(new VectorForce(true, _local3.propel.x, _local3.propel.y)); _local3.propel.multEquals(_local3.burnIn); _local3.fuel--; if (_local1.magnitude() > 10){ _local3.multisample = 10; } else { if (_local1.magnitude() > 50){ _local3.multisample = 50; }; }; } else { if ((((((((_local1.x < 1)) && ((_local1.x > -1)))) && ((_local1.y < 1)))) && ((_local1.y > -1)))){ _local3.destroy(); }; }; if ((((_local3.growth > 0)) && ((_local3.growTime > 0)))){ _local3.radius = (_local3.radius + _local3.growth); _local3.growTime--; if ((_local3.radius - (_local3.sprite.width / 2)) > 0.5){ _local3.draw(); }; }; if (_local3.seekRadius > 0){ if (!_local3.seekLock){ _local5 = (_local3.seekRadius + _player.celle.hexSize); if (_player.celle.missiles == this){ _local6 = _player.others.celles.length; if (_local6 > 0){ _local7 = Math.floor((Math.random() * _local6)); _local8 = _player.others.celles[_local7]; if (_local3.position.distance(_local8.position) < (_local5 * 2)){ _local9 = 0; while (_local9 < _local8.group.particles.length) { if (_local3.position.distance(_local8.group.particles[_local9].position) < _local5){ _local3.seekLock = _local8; _local3.draw(); _local9 = _local8.group.particles.length; }; _local9++; }; }; }; } else { if (_local3.position.distance(_player.celle.position) < (_local5 * 2)){ _local10 = 0; while (_local10 < _player.celle.group.particles.length) { if (_local3.position.distance(_player.celle.group.particles[_local10].position) < _local5){ _local3.seekLock = _player.celle; _local3.draw(); _local10 = _player.celle.group.particles.length; }; _local10++; }; }; }; } else { if (_local3.seekTime > 0){ _player.fx.line(_local3.x, _local3.y, _local3.seekLock.x, _local3.seekLock.y, 0x990000, 0.2); _local11 = _local3.seekLock.position.minus(_local3.position).normalize(); _local12 = new Vector(); _local12.copy(_local3.velocity.normalize()); _local13 = ((_local11.x * -(_local12.y)) - (-(_local11.y) * _local12.x)); _local14 = _local11; if (_local13 > 0){ _local14.x = -(_local11.y); _local14.y = -(_local11.x); } else { _local14.x = _local11.y; _local14.y = _local11.x; }; if (_player.fxNo > 1){ _player.fx.shardSpray(_local3.x, _local3.y, new Vector(-(_local14.x), -(_local14.y)), 0.2, 1.5, _local3.seekThrust, 1, 0x990000, 0.5); }; _local14.multEquals(_local3.seekThrust); _local3.addForce(new VectorForce(true, _local14.x, _local14.y)); _local3.seekTime--; }; }; }; }; } public function translate(_arg1:Vector):void{ var _local2:*; for each (_local2 in particles) { _local2.translate(_arg1); }; } public function destroyAll():void{ while (particles.length > 0) { particles[0].destroy(); }; } public function set visible(_arg1:Boolean):void{ var _local2:*; for each (_local2 in particles) { _local2.visible = _arg1; }; } public function set firing(_arg1:Boolean){ _firing = _arg1; } } }//package hexcelle
Section 37
//NewDropdownMenu (hexcelle.NewDropdownMenu) package hexcelle { import flash.events.*; import flash.filters.*; public class NewDropdownMenu extends ARGSprite { private var _isDown:Boolean; protected var parentMenu:NewDropdownMenu; public var textColor:uint;// = 0x333333 public var spacing:Number;// = 20 public var hoverTextColor:uint;// = 0x222222 private var _title:MenuItem; public var upSpeed:Number;// = 0.2 private var _combo:Boolean; public var downSpeed:Number;// = 0.3 private var _width:Number; private var _choice:int; private var _items:Array; public var backgroundColor:uint;// = 0xDDDDDD public var hoverBackgroundColor:uint;// = 0xAAAAAA public static const TITLE_CLICK:String = "NewDropdownMenu_Title_Click"; public static const COMBO_CHANGE:String = "NewDropdownMenu_Combo_Change"; public static const DROP_UP:String = "NewDropdownMenu_Drop_Up"; public static const CHOICE:String = "NewDropdownMenu_Choice"; public static const DROP_DOWN:String = "NewDropdownMenu_Drop_Down"; public function NewDropdownMenu(_arg1:String){ var dropShadow:DropShadowFilter; var title = _arg1; downSpeed = 0.3; upSpeed = 0.2; textColor = 0x333333; backgroundColor = 0xDDDDDD; hoverTextColor = 0x222222; hoverBackgroundColor = 0xAAAAAA; spacing = 20; super(); _items = new Array(); _title = new MenuItem(title); _title.textColor = 4465186; _title.backgroundColor = 0xEEEEEE; _title.hoverTextColor = 0x111111; _title.hoverBackgroundColor = 12307643; _title.addEventListener(MenuItem.CLICK, onTitleClick); addChild(_title); _title.show(); dropShadow = new DropShadowFilter(); var _local3 = dropShadow; with (_local3) { distance = 6; angle = 40; blurX = 6; blurY = 6; alpha = 0.6; }; this.filters = [dropShadow]; visible = false; _isDown = false; _width = _title.width; } public function set titleHoverBackgroundColor(_arg1:uint):void{ _title.hoverBackgroundColor = _arg1; _title.refresh(); } public function dropUp():void{ var _local1:*; if (!_isDown){ return; }; removeItemListeners(); for each (_local1 in _items) { _local1.addEventListener(Event.ENTER_FRAME, moveItemUp); _local1.hide(); }; _isDown = false; dispatchEvent(new Event(DROP_UP)); } public function set combo(_arg1:Boolean):void{ if (_combo == _arg1){ return; }; _combo = _arg1; _title.input = _combo; if (_combo){ _title.addEventListener(MenuItem.CHANGE, onComboChange); } else { _title.removeEventListener(MenuItem.CHANGE, onComboChange); }; } public function sort():void{ _items.sort(); } public function dropDown():void{ var _local1:*; if (_isDown){ return; }; removeItemListeners(); for each (_local1 in _items) { _local1.show(); _local1.addEventListener(Event.ENTER_FRAME, moveItemDown); }; _isDown = true; dispatchEvent(new Event(DROP_DOWN)); } private function onItemClick(_arg1:Event):void{ var _local2:MenuItem; _local2 = MenuItem(_arg1.target); if (_local2.submenu){ dropUp(); } else { collapse(); }; _choice = _items.indexOf(_local2); dispatchEvent(new Event(CHOICE)); } public function get choiceItem():MenuItem{ return (_items[_choice]); } private function moveItemUp(_arg1:Event):void{ var _local2:int; _local2 = _items.indexOf(_arg1.target); _arg1.target.y = (_arg1.target.y * (1 - upSpeed)); if (_arg1.target.y < 1){ _arg1.target.y = 0; _arg1.target.removeEventListener(Event.ENTER_FRAME, moveItemUp); }; } private function removeItemListeners():void{ var _local1:*; for each (_local1 in _items) { _local1.removeEventListener(Event.ENTER_FRAME, moveItemDown); _local1.removeEventListener(Event.ENTER_FRAME, moveItemUp); }; } public function hide():void{ var _local1:*; if (!visible){ return; }; dropUp(); for each (_local1 in _items) { _local1.hide(); }; _title.hide(); removeEventListener(Event.ENTER_FRAME, hiding); if (_items.length > 0){ addEventListener(Event.ENTER_FRAME, hiding); }; } public function indexOf(_arg1:Object):int{ return (_items.indexOf(_arg1)); } public function get choiceValue():String{ return (_items[_choice].text); } public function addItem(_arg1:String):MenuItem{ var _local2:MenuItem; _local2 = getNewItem(_arg1); _items.push(_local2); checkWidth(_local2); addChildAt(_local2, 0); return (_local2); } public function get title():String{ return (_title.text); } public function hasParentMenu():Boolean{ return (Boolean(parentMenu)); } private function onTitleClick(_arg1:Event):void{ if (_isDown){ dropUp(); if (parentMenu){ parentMenu.show(); parentMenu.dropDown(); hide(); }; } else { collapseSubmenus(); dropDown(); }; dispatchEvent(new Event(TITLE_CLICK)); } private function resizeAll(_arg1:Number):void{ var _local2:*; _width = _arg1; _title.width = _width; for each (_local2 in _items) { _local2.width = _width; }; } public function removeAllItems():void{ while (_items.length > 0) { removeItem(0); }; } private function hiding(_arg1:Event):void{ if (!_items[0].visible){ visible = false; removeEventListener(Event.ENTER_FRAME, hiding); }; } public function set titleTextColor(_arg1:uint):void{ _title.textColor = _arg1; _title.refresh(); } public function collapseSubmenus():void{ var _local1:*; for each (_local1 in _items) { if (_local1.submenu){ _local1.submenu.hide(); _local1.submenu.collapseSubmenus(); }; }; } private function onComboChange(_arg1:Event):void{ checkWidth(MenuItem(_arg1.target)); dispatchEvent(new Event(COMBO_CHANGE)); } public function getItem(_arg1:int):MenuItem{ return (_items[_arg1]); } public function insertItem(_arg1:String, _arg2:int):MenuItem{ var _local3:MenuItem; _local3 = getNewItem(_arg1); _items.splice(_arg2, 0, _local3); checkWidth(_local3); addChildAt(_local3, 0); return (_local3); } private function moveItemDown(_arg1:Event):void{ var _local2:int; var _local3:Number; _local2 = _items.indexOf(_arg1.target); _local3 = ((_local2 + (_title) ? 1 : 0) * spacing); _arg1.target.y = (_arg1.target.y + ((_local3 - _arg1.target.y) * downSpeed)); if (_arg1.target.y > (_local3 - 1)){ _arg1.target.y = _local3; _arg1.target.removeEventListener(Event.ENTER_FRAME, moveItemDown); }; } public function addItems(... _args):Array{ var _local2:Array; var _local3:*; _local2 = new Array(); for each (_local3 in _args) { if ((!(_local3) is String)){ } else { _local2.push(addItem(_local3)); }; }; return (_local2); } public function get choice():int{ return (_choice); } private function getNewItem(_arg1:String):MenuItem{ var _local2:MenuItem; _local2 = new MenuItem(_arg1); _local2.height = spacing; _local2.textColor = textColor; _local2.backgroundColor = backgroundColor; _local2.hoverTextColor = hoverTextColor; _local2.hoverBackgroundColor = hoverBackgroundColor; _local2.addEventListener(MenuItem.CLICK, onItemClick); _local2.addEventListener(MenuItem.CHANGE, onItemChange); return (_local2); } public function get combo():Boolean{ return (_combo); } public function get getParent():NewDropdownMenu{ return (parentMenu); } public function hasSubmenu(_arg1:int):Boolean{ return (Boolean(_items[_arg1].submenu)); } public function collapse():void{ if (parentMenu){ hide(); parentMenu.collapse(); } else { dropUp(); }; } public function changeItemText(_arg1:int, _arg2:String):void{ var _local3:MenuItem; _local3 = _items[_arg1]; _local3.text = _arg2; checkWidth(_local3); } public function set titleHoverTextColor(_arg1:uint):void{ _title.hoverTextColor = _arg1; _title.refresh(); } public function removeItem(_arg1:int):void{ var _local2:MenuItem; _local2 = _items[_arg1]; removeChild(_local2); if (_local2.submenu){ removeChild(_local2.submenu); }; _items.splice(_arg1, 1); checkWidth(); } public function set titleBackgroundColor(_arg1:uint):void{ _title.backgroundColor = _arg1; _title.refresh(); } public function addSubmenu(_arg1:NewDropdownMenu, _arg2:int):void{ var _local3:MenuItem; _local3 = _items[_arg2]; if (((_arg1.parentMenu) && (!((_arg1.parentMenu == this))))){ trace("submenu already has a parent menu"); return; }; if (_local3.submenu){ removeChild(_local3.submenu); }; _local3.submenu = _arg1; _arg1.parentMenu = this; _arg1.filters = null; addChildAt(_arg1, 0); _local3.addEventListener(MenuItem.CLICK, showSubmenu); } public function getValue(_arg1:int):String{ return (_items[_arg1].text); } public function get itemCount():int{ return (_items.length); } public function set title(_arg1:String):void{ _title.text = _arg1; checkWidth(); } private function checkWidth(_arg1:MenuItem=null):void{ var _local2:Number; var _local3:Number; _local2 = (_arg1) ? _arg1.width : 0; if (_local2 > _width){ resizeAll(_local2); } else { if (_local2 < _width){ _local3 = _title.minWidth; for each (_arg1 in _items) { if (_arg1.minWidth > _local3){ _local3 = _arg1.minWidth; }; }; resizeAll(_local3); }; }; if (_arg1){ _arg1.width = _width; }; } private function showSubmenu(_arg1:Event):void{ var _local2:MenuItem; _local2 = MenuItem(_arg1.target); if (!_local2.submenu){ trace("item has lost its submenu"); return; }; _local2.submenu.x = _title.x; _local2.submenu.y = (_title.y + _title.height); _local2.submenu.show(); } private function onItemChange(_arg1:Event):void{ checkWidth(MenuItem(_arg1.target)); } public function show():void{ visible = true; _title.show(); if (parentMenu){ dropDown(); }; } } }//package hexcelle
Section 38
//Others (hexcelle.Others) package hexcelle { import org.cove.ape.*; public class Others { private const BOSSES:Array; public const BOSS_NAMES:Array; private var _player:Player; private var _others:Array; private var _traits:Array; private var _boss:Celle; private var _kills:int; private var _skills:Array; private var _maxSkill:Number; private var _minSkill:Number; public static const CELLES:Array = [["uber bomber fighter", "13;11;6;6;true;5.43;0;7;3;0;8;4;0;9;4;1;7;5;1;8;1;1;9;1;1;10;4;2;6;2;2;7;5;2;8;1;2;9;1;2;10;3;3;6;2;3;8;0;3;9;5;3;10;5;4;1;3;4;2;5;4;3;2;4;4;2;4;5;2;4;7;0;4;9;2;5;1;4;5;2;1;5;3;5;5;6;2;5;7;0;5;9;2;6;0;4;6;1;1;6;2;1;6;3;0;6;4;0;6;5;0;6;6;1;6;7;2;6;8;2;7;1;4;7;2;1;7;3;5;7;6;2;7;7;0;7;9;2;8;1;3;8;2;5;8;3;2;8;4;2;8;5;2;8;7;0;8;9;2;9;6;2;9;8;0;9;9;5;9;10;5;10;6;2;10;7;5;10;8;1;10;9;1;10;10;3;11;7;5;11;8;1;11;9;1;11;10;4;12;7;3;12;8;4;12;9;4"], ["flower power", "13;13;6;6;true;5.06;0;3;3;0;4;3;0;8;3;0;9;3;1;3;3;1;4;3;1;5;3;1;8;3;1;9;3;1;10;3;2;3;3;2;4;3;2;8;3;2;9;3;3;5;0;3;8;0;4;5;0;4;6;4;4;7;0;5;1;3;5;2;3;5;5;4;5;6;0;5;7;0;5;8;4;5;11;3;5;12;3;6;0;3;6;1;3;6;2;3;6;3;0;6;4;0;6;5;0;6;6;2;6;7;0;6;8;0;6;9;0;6;10;3;6;11;3;6;12;3;7;1;3;7;2;3;7;5;4;7;6;0;7;7;0;7;8;4;7;11;3;7;12;3;8;5;0;8;6;4;8;7;0;9;5;0;9;8;0;10;8;3;10;9;3;10;3;3;10;4;3;11;8;3;11;9;3;11;10;3;11;3;3;11;4;3;11;5;3;12;8;3;12;9;3;12;3;3;12;4;3"], ["station", "11;9;5;4;false;4.58;0;3;5;1;1;5;1;2;3;1;3;0;2;2;0;2;3;4;2;4;4;2;5;0;2;7;0;2;8;5;3;2;4;3;3;4;3;5;1;3;6;1;3;7;3;3;8;5;4;2;0;4;4;3;4;5;5;4;6;1;4;7;1;4;8;0;5;2;1;5;3;5;5;4;3;5;5;5;5;6;1;6;1;0;6;2;1;6;3;1;6;4;5;6;5;3;6;7;0;7;0;5;7;1;3;7;2;1;7;3;1;7;5;4;7;6;4;8;1;5;8;2;0;8;4;0;8;5;4;8;6;4;8;7;0;9;5;0;9;6;3;9;7;5;10;6;5"], ["armor arms", "29;19;14;9;true;3.88;0;12;5;0;13;5;1;13;1;1;14;5;2;12;0;3;12;0;4;11;0;5;11;0;6;10;0;7;10;0;8;9;0;9;9;3;9;10;3;10;9;5;11;9;3;11;10;3;12;8;4;12;9;4;12;10;4;13;1;5;13;9;1;13;10;1;13;18;5;14;0;5;14;1;1;14;2;0;14;3;0;14;4;0;14;5;0;14;6;0;14;7;0;14;8;0;14;9;3;14;10;0;14;11;0;14;12;0;14;13;0;14;14;0;14;15;0;14;16;0;14;17;1;14;18;5;15;1;5;15;9;1;15;10;1;15;18;5;16;8;4;16;9;4;16;10;4;17;9;3;17;10;3;18;9;5;19;9;3;19;10;3;20;9;0;21;9;0;22;8;0;23;8;0;24;7;0;25;7;0;26;6;0;27;5;5;27;6;1;28;5;5;28;6;5"], ["missile back", "14;10;9;3;false;3.76;0;5;4;0;7;5;0;8;0;1;5;4;1;6;3;1;7;5;1;8;5;2;6;4;2;7;4;2;8;3;3;6;3;3;7;4;3;8;4;3;9;4;4;6;3;5;4;5;5;5;3;6;4;5;6;5;3;6;6;5;7;1;0;7;2;0;7;3;1;7;4;3;7;5;5;8;1;0;8;4;3;8;5;1;9;0;0;9;2;0;9;3;3;9;5;0;10;0;1;10;3;0;10;4;0;10;6;0;11;5;0;12;5;0;13;4;1"], ["sower", "3;9;1;4;false;3.14;0;1;4;0;2;0;0;3;4;0;4;0;0;5;0;0;6;4;0;7;0;0;8;4;1;0;4;1;1;1;1;2;1;1;3;1;1;4;1;1;5;1;1;6;1;1;7;1;1;8;4;2;1;4;2;2;0;2;3;4;2;4;0;2;5;0;2;6;4;2;7;0;2;8;4"], ["armor blaster", "11;8;5;3;false;3.09;0;1;4;0;3;4;1;1;5;1;2;5;2;0;4;2;1;5;2;2;3;2;3;5;3;1;5;3;2;5;4;3;0;4;4;0;5;2;0;5;3;0;5;4;0;6;3;0;6;4;0;7;4;5;7;5;5;8;4;5;8;5;3;8;6;5;8;7;4;9;4;5;9;5;5;10;4;4;10;6;4"], ["feone's gun", "5;5;2;2;true;3.02;0;1;4;0;2;0;0;3;4;1;1;4;1;2;5;1;3;5;1;4;4;2;0;4;2;1;5;2;2;3;2;3;5;2;4;4;3;1;0;3;2;5;3;3;5;3;4;0;4;1;4;4;2;4;4;3;4"], ["armorplasm", "7;7;3;3;false;2.71;0;3;0;0;4;0;0;5;0;1;1;0;1;2;0;1;5;0;2;1;0;2;3;4;2;4;5;2;5;2;2;6;0;3;0;0;3;2;5;3;3;3;3;4;5;3;6;0;4;1;0;4;2;2;4;3;5;4;4;4;4;6;0;5;1;0;5;4;0;5;5;0;6;2;0;6;3;0;6;4;0"], ["growplasm", "9;9;4;4;true;2.52;0;2;0;0;3;0;0;6;4;1;2;0;1;4;2;1;5;2;1;6;2;2;2;2;2;3;5;2;6;2;3;2;2;3;4;3;3;5;3;3;7;2;3;8;0;4;0;4;4;1;2;4;3;3;4;4;2;4;5;3;4;6;5;4;8;0;5;2;2;5;4;3;5;5;3;5;7;2;5;8;0;6;2;2;6;3;5;6;6;2;7;2;0;7;4;2;7;5;2;7;6;2;8;2;0;8;3;0;8;6;4"], ["growicus masseus", "7;5;3;2;false;2.35;0;2;2;0;3;2;1;1;2;1;2;3;1;3;2;2;1;4;2;2;3;2;3;3;2;4;4;3;0;1;3;1;4;3;2;2;3;3;4;3;4;1;4;1;4;4;2;3;4;3;3;4;4;4;5;1;2;5;2;3;5;3;2;6;2;2;6;3;2"], ["dual shot", "9;4;4;1;true;1.8;0;1;1;1;1;3;1;2;3;2;0;3;2;1;5;2;2;3;3;0;4;3;1;3;3;2;3;3;3;4;4;0;0;4;1;0;4;2;0;5;0;4;5;1;3;5;2;3;5;3;4;6;0;3;6;1;5;6;2;3;7;1;3;7;2;3;8;1;1"], ["bomber-shooter", "7;2;3;0;false;1.54;0;0;4;0;1;1;1;0;3;2;1;1;3;0;3;3;1;0;4;1;1;5;0;3;6;0;4;6;1;1"], ["multi-shooter", "3;4;1;1;false;1.39;0;0;3;0;1;0;0;2;0;0;3;3;1;0;5;1;1;4;1;2;5;2;0;3;2;1;0;2;2;0;2;3;3"], ["cannon", "5;4;2;1;true;1.26;0;1;4;1;0;0;1;1;3;1;2;3;1;3;0;2;0;3;2;1;5;2;2;3;3;0;0;3;1;3;3;2;3;3;3;0;4;1;4"], ["gunner", "7;3;3;1;false;1.1;0;2;0;1;1;3;1;2;3;2;1;5;2;2;3;3;0;0;3;1;2;4;1;5;4;2;3;5;1;3;5;2;3;6;2;0"], ["fire-starter", "5;3;2;1;true;0.93;0;0;5;0;1;3;1;1;3;1;2;3;2;0;0;2;1;4;2;2;0;3;1;3;3;2;3;4;0;5;4;1;3"], ["worm bomber", "3;4;1;0;false;0.89;0;1;0;1;0;1;1;1;4;1;2;1;1;3;4;2;1;0"], ["uberbomber", "9;6;2;3;true;0.78;0;3;4;0;4;4;1;3;0;1;4;1;1;5;4;2;2;0;2;3;1;2;4;0;3;3;1;3;4;0;4;2;5;5;2;5;6;0;1;6;1;5;7;0;1;7;1;1;7;2;1;8;0;1;8;1;1"], ["bomber", "3;4;1;1;false;0.74;0;1;0;0;2;1;0;3;0;1;0;4;1;1;1;1;2;1;2;1;4;2;2;0"], ["whackshot", "4;4;1;1;false;0.68;0;0;3;0;2;4;0;3;2;1;0;3;1;1;2;2;1;3;2;2;3;3;2;3"], ["cluster shot", "3;3;1;1;false;0.58;0;1;5;0;2;3;1;0;5;1;1;5;1;2;4;2;1;5;2;2;3"], ["trigger finger", "3;3;1;1;false;0.57;0;2;4;1;0;5;1;1;3;1;2;4;2;1;5;2;2;2"], ["shooter", "3;4;1;1;false;0.5;0;2;4;0;3;5;1;0;3;1;1;3;1;2;3;2;2;4;2;3;5"], ["firer", "3;2;1;1;false;0.5;0;1;4;1;0;3;1;1;3;2;1;4"], ["armorhead", "3;2;1;0;false;0.49;0;0;0;1;0;0;1;1;0;2;0;0"], ["defender", "3;3;1;0;false;0.49;0;0;4;0;1;4;0;2;3;1;0;2;1;1;3;2;1;3"], ["bomb grower", "3;2;1;0;false;0.46;0;0;2;1;0;1;1;1;2;2;0;2"], ["gnat", "3;2;1;0;false;0.45;0;1;0;1;0;3;2;1;0"], ["armored missilehead", "3;2;1;0;false;0.46;0;0;0;0;1;3;1;0;3;2;0;3;2;1;0"], ["missile grower", "3;2;1;0;false;0.43;0;0;2;0;1;2;1;0;3;2;0;2;2;1;2"], ["smart bomber", "3;2;1;0;false;0.41;0;0;5;0;1;0;1;0;1;1;1;1;2;0;5;2;1;5"], ["regenerator", "3;1;1;0;false;0.31;0;0;5;1;0;0;2;0;5"], ["pede", "1;4;0;0;true;0.26;0;0;3;0;1;3;0;2;3;0;3;1"], ["duobomber", "3;4;1;1;false;0.23;0;2;1;0;3;1;1;0;1;1;1;4;1;2;1;2;0;1;2;1;1"], ["targeter", "3;2;1;0;false;0.2;0;0;5;1;0;3;1;1;5;2;0;5"], ["speck firer", "1;1;0;0;true;0.14;0;0;3"], ["bread basket", "2;1;0;0;true;0.13;0;0;2;1;0;2"], ["speck bomber", "1;1;0;0;true;0.1;0;0;1"], ["tech speck", "1;1;0;0;true;0.1;0;0;5"]]; public function Others(_arg1:Player){ var _local2:*; var _local3:String; var _local4:Number; BOSSES = ["9;7;4;2;true;2.31;0;0;4;1;1;2;1;2;2;2;0;2;2;1;3;2;2;2;3;1;2;3;2;3;3;3;2;3;4;2;3;5;2;4;1;2;4;2;2;4;3;3;4;4;3;4;5;2;4;6;4;5;1;2;5;2;3;5;3;2;5;4;2;5;5;2;6;0;2;6;1;3;6;2;2;7;1;2;7;2;2;8;0;4", "11;11;5;5;false;2.18;0;8;4;0;3;5;1;7;3;1;3;3;2;4;3;2;7;3;3;4;3;3;6;3;4;5;0;4;6;5;5;0;2;5;1;3;5;2;3;5;3;3;5;4;0;5;5;2;5;6;0;5;7;3;5;8;3;5;9;3;5;10;2;6;5;5;6;6;0;7;4;3;7;6;3;8;4;3;8;7;3;9;7;3;9;3;3;10;8;5;10;3;4", "12;8;10;5;true;3.5;0;4;1;0;5;5;1;5;5;1;6;0;2;5;0;2;6;0;3;2;0;3;3;0;3;4;5;3;5;3;3;6;2;4;1;0;4;2;0;4;3;0;4;4;2;4;5;3;5;1;2;5;2;2;6;0;3;6;1;3;7;1;2;7;2;2;8;1;0;8;2;0;8;3;0;9;2;0;9;3;5;9;4;5;9;5;4;9;6;3;10;3;5;10;4;0;10;5;0;10;6;3;11;6;5;11;7;3", "19;11;9;5;false;3.58;0;1;5;1;1;1;2;2;1;3;2;1;4;3;0;4;4;5;4;8;3;5;2;5;5;3;1;5;4;4;5;7;2;6;3;4;6;4;3;6;7;2;7;4;3;7;5;5;7;6;5;8;4;5;8;5;1;8;6;1;9;0;3;9;1;2;9;2;2;9;3;5;9;4;1;9;5;5;9;6;1;9;7;5;9;8;2;9;9;2;9;10;3;10;5;1;10;6;1;10;7;5;11;4;5;11;5;5;11;6;3;12;4;2;12;7;3;12;8;4;13;3;2;13;6;4;13;7;1;13;8;5;14;3;3;14;7;5;14;8;0;15;8;1;16;9;1;17;9;1;18;10;5", "11;5;5;1;false;2.42;0;1;5;0;3;5;1;1;3;1;2;3;2;0;5;2;1;3;2;2;3;2;3;3;2;4;5;3;1;3;3;2;3;4;1;0;4;2;4;4;3;0;5;0;5;5;1;3;5;2;5;6;1;0;6;2;4;6;3;0;7;1;3;7;2;3;8;0;5;8;1;3;8;2;3;8;3;3;8;4;5;9;1;3;9;2;3;10;1;5;10;3;5", "11;8;5;4;false;5.74;0;6;3;1;6;4;1;7;3;2;3;5;2;4;0;2;6;4;3;2;0;3;3;3;3;4;4;3;5;3;4;0;3;4;3;4;4;4;3;4;5;0;4;6;4;4;7;0;5;0;4;5;1;4;5;2;3;5;3;0;5;4;4;5;5;3;5;6;3;5;7;5;6;0;3;6;3;4;6;4;3;6;5;0;6;6;4;6;7;0;7;2;0;7;3;3;7;4;4;7;5;3;8;3;5;8;4;0;8;6;4;9;6;4;9;7;3;10;6;3", "17;11;8;5;true;7.13;0;4;1;0;5;1;1;4;0;1;5;0;1;6;0;2;4;4;2;5;3;3;5;1;3;10;5;4;9;1;4;10;0;4;4;1;4;5;1;5;8;2;5;9;0;5;10;1;5;5;5;5;6;5;6;2;0;6;3;5;6;4;3;6;5;1;6;6;1;6;7;1;6;8;2;6;9;5;7;3;5;7;4;1;7;5;0;7;6;5;7;7;5;8;3;5;8;4;4;8;5;1;8;6;4;8;7;5;9;8;5;9;4;5;9;5;5;9;6;0;9;7;1;10;1;5;10;2;2;10;3;1;10;4;1;10;5;1;10;6;3;10;7;5;10;8;0;11;1;1;11;2;0;11;3;2;11;5;5;11;6;5;12;0;0;12;1;1;12;5;1;12;6;1;13;1;5;13;6;1;14;5;3;14;6;4;15;5;0;15;6;0;15;7;0;16;5;1;16;6;1", "16;14;7;6;false;9.03;0;7;4;1;8;0;1;2;0;1;5;0;1;6;0;1;7;0;2;2;5;2;3;5;2;13;0;2;7;3;3;0;0;3;1;3;3;2;3;3;3;5;3;8;0;3;11;4;3;12;3;3;5;0;3;6;0;3;7;0;4;2;4;4;3;3;4;4;0;4;7;3;4;10;0;4;11;3;4;12;3;4;13;5;5;3;0;5;4;0;5;5;0;5;6;4;5;7;4;5;8;0;5;9;0;5;10;0;5;11;5;5;12;5;5;13;0;6;8;5;6;9;0;6;5;0;6;6;5;6;7;3;7;8;4;7;10;0;7;3;0;7;5;4;7;6;3;7;7;3;8;2;0;8;4;0;8;5;3;8;6;4;8;7;5;8;8;4;8;9;3;8;10;0;8;12;0;9;2;0;9;3;3;9;4;0;9;6;0;9;7;0;9;9;0;9;10;3;9;11;0;10;2;4;10;3;0;10;5;0;10;7;0;10;9;0;10;11;0;10;12;4;11;10;0;11;3;0;11;6;0;11;7;0;12;6;5;12;7;3;13;5;5;13;6;3;13;7;4;14;5;0;14;6;5;14;7;3;15;7;0", "15;15;7;7;false;7.37;0;4;1;0;11;1;1;4;0;1;5;0;1;6;0;1;7;0;1;8;0;1;9;0;1;10;0;2;10;5;2;11;0;2;4;0;2;5;5;3;8;3;3;9;3;3;3;0;3;11;0;3;5;3;3;6;3;4;3;0;4;5;3;4;7;5;4;8;5;4;9;4;4;10;3;4;12;0;5;8;3;5;9;5;5;2;0;5;12;0;5;5;5;5;6;3;6;2;0;6;4;3;6;5;5;6;7;5;6;8;5;6;10;5;6;11;3;6;13;0;7;0;1;7;1;0;7;2;5;7;3;3;7;4;4;7;5;3;7;6;5;7;7;0;7;8;5;7;9;3;7;11;3;7;12;5;7;13;0;7;14;1;8;2;0;8;4;3;8;5;5;8;7;5;8;8;5;8;10;5;8;11;3;8;13;0;9;8;3;9;9;5;9;2;0;9;12;0;9;5;5;9;6;3;10;3;0;10;5;3;10;7;5;10;8;5;10;9;4;10;10;3;10;12;0;11;8;3;11;9;3;11;3;0;11;11;0;11;5;3;11;6;3;12;10;5;12;11;0;12;4;0;12;5;5;13;4;0;13;5;0;13;6;0;13;7;0;13;8;0;13;9;0;13;10;0;14;4;1;14;11;1", "23;18;11;7;false;13.65;0;4;0;0;5;0;1;4;3;1;3;3;2;1;0;2;2;3;2;3;2;2;4;4;3;0;0;3;1;3;3;2;4;3;3;3;3;4;3;4;4;3;4;5;5;4;3;3;5;4;0;5;3;5;6;8;0;6;5;0;6;6;5;6;7;0;7;8;0;7;4;5;7;5;0;7;6;5;8;17;0;8;4;0;8;5;5;8;6;0;8;7;1;8;9;0;8;10;0;8;11;0;9;16;3;9;17;0;9;3;0;9;5;1;9;6;0;9;7;5;9;8;0;9;11;0;10;16;4;10;17;3;10;4;0;10;6;5;10;7;4;10;8;3;10;9;5;10;10;1;10;11;5;10;12;5;10;14;5;10;15;3;11;4;0;11;5;0;11;6;3;11;7;4;11;8;4;11;9;0;11;10;0;11;11;0;11;12;0;11;13;0;11;14;3;11;15;3;11;16;2;12;16;4;12;17;3;12;4;0;12;6;5;12;7;4;12;8;3;12;9;5;12;10;1;12;11;5;12;12;5;12;14;5;12;15;3;13;16;3;13;17;0;13;3;0;13;5;1;13;6;0;13;7;5;13;8;0;13;11;0;14;17;0;14;4;0;14;5;5;14;6;0;14;7;1;14;9;0;14;10;0;14;11;0;15;8;0;15;4;5;15;5;0;15;6;5;16;8;0;16;5;0;16;6;5;16;7;0;17;4;0;17;3;5;18;4;3;18;5;5;18;3;3;19;0;0;19;1;3;19;2;4;19;3;3;19;4;3;20;1;0;20;2;3;20;3;2;20;4;4;21;4;3;21;3;3;22;4;0;22;5;0"]; BOSS_NAMES = ["GROWICUS MISSILEUM", "MISSILUS STARSWARMEOT", "MISSILUS SNAKEUM", "BOMBUS TECHNICEUM", "MISSILUS UBERCUS", "SPEEDUS MISSILEUM", "BOMBUS MULTIPLICAE", "MISSILUS ARMORUM HASTEUM", "ARMORUS MISSILUM CONSOLIDATA", "SPEEDUS TRIUSTAR AWESUM"]; super(); _player = _arg1; _others = new Array(); _traits = new Array(); _minSkill = 0.5; _maxSkill = 0.5; _skills = new Array(); for each (_local2 in CELLES) { _local3 = _local2[1]; _local4 = Number(_local3.split(";")[5]); if (_local4 < _minSkill){ _minSkill = _local4; }; if (_local4 > _maxSkill){ _maxSkill = _local4; }; _skills.push(_local4); }; _kills = 0; } public function spawn(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Boolean=false):Celle{ var _local5:CelleFile; var _local6:Celle; var _local7:Object; _local5 = new CelleFile(); if (_arg4){ _local6 = _local5.loadFromString(BOSSES[_arg3]); } else { _local6 = _local5.loadFromString(CELLES[_arg3][1]); }; _local6.group.addCollidable(_player.celle.group); _local6.group.addCollidable(_player.celle.missiles); _local6.group.addCollidable(_player.celle.bombs); _local6.group.addCollidable(_player.fauna); _local6.x = _arg1; _local6.y = _arg2; _local6.hexSize = _player.celle.hexSize; _local6.prepForPlay(_player); _local6.missiles.addCollidable(_player.celle.group); _local6.missiles.addCollidable(_player.celle.bombs); _local6.bombs.addCollidable(_player.celle.group); _local6.bombs.addCollidable(_player.celle.missiles); _others.push(_local6); _local7 = new Object(); _traits.push(_local7); _local7.celle = _local6; _local7.offense = (((_local6.bombHexes + _local6.missileHexes) + _local6.techHexes) / _local6.hexCount); _local7.defense = (((_local6.speedHexes + _local6.armorHexes) + _local6.techHexes) / _local6.hexCount); if ((_local6.bombHexes + _local6.missileHexes) == 0){ _local7.offense = 0; }; return (_local6); } public function destroyAll():void{ while (_others.length > 0) { destroy(_others[0]); }; } public function update():void{ var _local1:*; for each (_local1 in _others) { if (((_player.testOutOfBounds(_local1)) && (!((_local1 == _boss))))){ remove(_local1); } else { think(_local1); _local1.update(); }; }; } public function destroy(_arg1:Celle):void{ _kills++; _player.onCelleDestroy(_arg1); remove(_arg1); } public function remove(_arg1:Celle):void{ var _local2:int; var _local3:*; _arg1.remove(); _local2 = _others.indexOf(_arg1); _others.splice(_local2, 1); _traits.splice(_local2, 1); for each (_local3 in _traits) { if (_local3.friend){ if (_local3.friend.celle == _arg1){ _local3.friend = null; }; }; }; if (_others.length == 0){ _player.areas.clear(); }; if (_arg1 == _boss){ _boss = null; }; } public function get kills():int{ return (_kills); } public function spawnBoss(_arg1:Area, _arg2:int):Celle{ var _local3:Vector; if ((((_arg2 < 0)) || ((_arg2 >= BOSSES.length)))){ return (null); }; _local3 = _arg1.location.minus(_player.location).plus(_player.centerV); _boss = spawn(_local3.x, _local3.y, _arg2, true); return (_boss); } public function get celles():Array{ return (_others); } public function translate(_arg1:Vector):void{ var _local2:*; var _local3:*; for each (_local2 in _others) { _local2.translate(_arg1); }; for each (_local3 in _traits) { if (_local3.moveTo){ _local3.moveTo.plusEquals(_arg1); }; }; } public function get count():int{ return (_others.length); } public function spawnArea(_arg1:Area):void{ var _local2:Boolean; var _local3:int; var _local4:int; var _local5:*; var _local6:Vector; if ((((_minSkill > _arg1.maxSkill)) || ((_maxSkill < _arg1.minSkill)))){ trace("area skills are outside available skills"); return; }; _local2 = true; do { for each (_local5 in _skills) { if ((((_local5 > _arg1.minSkill)) && ((_local5 < _arg1.maxSkill)))){ _local2 = false; }; }; if (_local2){ _arg1.minSkill = (_arg1.minSkill * 0.9); _arg1.maxSkill = (_arg1.maxSkill * 1.1); trace("area skills expanded"); }; } while (_local2); _local4 = 0; while (_local4 < _arg1.othersCount) { _local6 = _arg1.location.minus(_player.location).plus(_player.centerV); _local6.plusEquals(_player.celle.core.velocity.normalize().mult(100)); _local6.x = (_local6.x + (100 - (Math.random() * 200))); _local6.y = (_local6.y + (100 - (Math.random() * 200))); do { _local3 = Math.floor((Math.random() * CELLES.length)); } while ((((_skills[_local3] < _arg1.minSkill)) || ((_skills[_local3] > _arg1.maxSkill)))); spawn(_local6.x, _local6.y, _local3); _local4++; }; } public function set kills(_arg1:int):void{ _kills = _arg1; } public function set visible(_arg1:Boolean){ var _local2:*; for each (_local2 in _others) { _local2.visible = _arg1; }; } public function think(_arg1:Celle):void{ var directions:Array; var trait:Object; var count:int; var pick:int; var moveCheckDistance:Number; var thrustTowards:Function; var moveNear:Function; var moveRandomly:Function; var fireOffScreen:Boolean; var m:*; var distanceCheck:Number; var bombCheckRange:Number; var missileCheckRange:Number; var distance:Number; var makeTarget:Boolean; var celle = _arg1; directions = new Array(4); trait = _traits[_others.indexOf(celle)]; moveCheckDistance = 60; thrustTowards = function (_arg1:Vector):void{ directions = [false, false, false, false]; if (celle.x < _arg1.x){ directions[1] = true; } else { directions[3] = true; }; if (celle.y < _arg1.y){ directions[2] = true; } else { directions[0] = true; }; }; moveNear = function (_arg1:Object):void{ trait.moveTo = new Vector(); trait.moveTo.x = ((_arg1.x + moveCheckDistance) - ((Math.random() * moveCheckDistance) * 2)); trait.moveTo.y = ((_arg1.y + moveCheckDistance) - ((Math.random() * moveCheckDistance) * 2)); thrustTowards(trait.moveTo); }; moveRandomly = function ():void{ moveNear(celle); }; if (trait.moveTo){ if (celle.position.distance(trait.moveTo) < moveCheckDistance){ trait.moveTo = null; } else { thrustTowards(trait.moveTo); }; } else { if (trait.friend){ if (trait.friend.offense > 0.5){ thrustTowards(_player.celle.position.minus(trait.friend.celle.position).mult(0.5).plus(trait.friend.celle.position)); } else { thrustTowards(_player.celle.position.minus(trait.friend.celle.position).plus(_player.celle.position)); }; }; }; if (!_player.testOnScreen(celle)){ if (!trait.moveTo){ if (Math.random() < 0.97){ thrustTowards(_player.celle.position); } else { moveRandomly(); }; } else { if (!_player.testOnScreen(trait.moveTo)){ trait.moveTo = null; }; }; if (celle.missileHexes > 0){ fireOffScreen = false; for each (m in _player.celle.missiles.particles) { if (!_player.testOnScreen(m)){ if (m.position.distance(celle.position) < 200){ fireOffScreen = true; break; }; }; }; if (fireOffScreen){ celle.fire(_player.celle.position); }; }; } else { distanceCheck = (100 + celle.size); bombCheckRange = (90 + (celle.size * 2)); missileCheckRange = (50 + celle.size); if ((((((trait.offense > 0)) && ((trait.offense < 0.4)))) && (trait.friend))){ bombCheckRange = (bombCheckRange * 2.5); missileCheckRange = (missileCheckRange * 1.5); }; count = _player.celle.bombs.particles.length; if (count > 0){ pick = Math.floor((Math.random() * count)); distance = celle.position.distance(_player.celle.bombs.particles[pick].position); if (distance < (bombCheckRange + 10)){ makeTarget = !(trait.targetBomb); if (trait.targetBomb){ if (distance < celle.position.distance(trait.targetBomb.position)){ makeTarget = true; }; }; if (makeTarget){ trait.targetBomb = _player.celle.bombs.particles[pick]; trait.moveTo = null; }; }; }; count = _player.celle.missiles.particles.length; if (count > 0){ pick = Math.floor((Math.random() * count)); distance = celle.position.distance(_player.celle.missiles.particles[pick].position); if (distance < missileCheckRange){ makeTarget = !(trait.targetMissile); if (trait.targetMissile){ if (distance < celle.position.distance(trait.targetMissile.position)){ makeTarget = true; }; }; if (makeTarget){ trait.targetMissile = _player.celle.missiles.particles[pick]; trait.moveTo = null; }; }; }; if (trait.targetMissile){ if (!trait.targetMissile.sprite.parent){ trait.targetMissile = null; } else { if (celle.position.distance(trait.targetMissile.position) < missileCheckRange){ thrustTowards(celle.position.minus(trait.targetMissile.position)); } else { trait.targetMissile = null; }; }; } else { if (trait.targetBomb){ if (!trait.targetBomb.sprite.parent){ trait.targetBomb = null; } else { if (celle.position.distance(trait.targetBomb.position) < bombCheckRange){ thrustTowards(celle.position.minus(trait.targetBomb.position)); } else { trait.targetBomb = null; }; }; } else { if (((!(trait.moveTo)) && (!(trait.friend)))){ trait.moveTo = new Vector(); if ((((((((trait.defense > 0.3)) && ((trait.offense < 0.3)))) && ((_others.length > 1)))) && (!(trait.friend)))){ while (((!(trait.friend)) || ((trait.friend.celle == celle)))) { trait.friend = _traits[Math.floor((Math.random() * _traits.length))]; }; trait.moveTo = null; } else { if (celle.position.distance(_player.celle.position) > distanceCheck){ moveNear(_player.celle.position); } else { if (trait.offense > 0.4){ moveNear(_player.celle.position); } else { if (trait.defense > 0.4){ if ((((celle.bombHexes > 0)) && ((celle.bombHexes > celle.missileHexes)))){ thrustTowards(_player.celle.position.plus(_player.celle.core.velocity.normalize().mult(50))); } else { moveRandomly(); }; } else { moveRandomly(); }; }; }; }; }; }; }; if (_player.celle.core.collidable){ if (celle.bombHexes > 0){ if (celle.position.distance(_player.celle.position) < bombCheckRange){ celle.drop(); }; }; }; if (celle.missileHexes > 0){ if (trait.targetBomb){ celle.fire(trait.targetBomb.position.minus(celle.core.velocity)); } else { celle.fire(_player.celle.position); }; }; }; celle.thrust(directions); } public function removeAll():void{ while (_others.length > 0) { remove(_others[0]); }; } } }//package hexcelle
Section 39
//Player (hexcelle.Player) package hexcelle { import flash.display.*; import flash.events.*; import org.cove.ape.*; import flash.text.*; import flash.net.*; import flash.ui.*; public class Player extends UtilitySprite { public const checkDistance:Number = 500; private var _settingsMenu:DropdownMenu; public var RIGHT_EDGE:Number; private var _checkpoints:int; public var boundary:Vector; private var _menu:DropdownMenu; private var _celle:Celle; private var _fxQuality:int; private var _paused:Boolean; private var _boss:Celle; private var _maxHexCount:int; private var _others:Others; private var _areas:Areas; private var _foodCollected:int; private var ui:Sprite; public var TOP_EDGE:Number; private var _map:Sprite; private var _main:Main; private var _distanceText:TextField; private var _foodHUD:Sprite; private var _evolve:Boolean; private var _tasks:Array; public var bounds:Vector; private var _mouseCursor:Sprite; private var _fxQualityMenu:DropdownMenu; public var fx:FX; private var _foods:Foods; public var LEFT_EDGE:Number; private var _fxNo:int; private var _box:Sprite; private var _initialized:Boolean; private var _pausedScreen:Sprite; private var _pausedScreenContent:Sprite; private var _autoSave:Boolean; private var _win:Boolean;// = false private var _evos:int; private var _foodQuota:int; private var _mainHUD:Sprite; private var _frameCount:uint; private var _bossesDestroyed:Array; private var _fauna:Fauna; private var _enemyText:TextField; public var BOTTOM_EDGE:Number; private var _centerX:Number; private var _centerY:Number; private var _thrust:Array; private var _distanceV:Vector; private var _fxNoMenu:DropdownMenu; private var _coreDestroy:int; private var _collision:Boolean; private var _musicMenu:DropdownMenu; private var _maxDistance:Number; private var _brakes:int; private var _foodCount:int; private var _shiftKey:Boolean; private var _bossKills:int; private var _fxVolumeMenu:DropdownMenu; private var _bosses:Array; public function Player(_arg1:Main):void{ _win = false; super(); _initialized = false; _paused = true; _shiftKey = false; _frameCount = 0; _thrust = new Array(4); _main = _arg1; } private function handleCollision():void{ var allDone:Boolean; var multisampleCheck:Function; allDone = true; multisampleCheck = function (_arg1:Hex):void{ if (_arg1.multisample > 0){ allDone = false; _arg1.multisample--; }; }; _celle.applyToHexes(multisampleCheck); _collision = !(allDone); if (allDone){ trace("collision over"); }; } public function getSaveArray():Array{ var _local1:Array; var _local2:Array; var _local3:int; _local1 = new Array(); _local2 = new Array(); if (_bossesDestroyed){ _local3 = 0; while (_local3 < _bossesDestroyed.length) { if (_bossesDestroyed[_local3]){ _local2.push(true); } else { _local2.push(false); }; _local3++; }; }; _local1.push(_foodCount, _foodCollected, _maxDistance, _checkpoints, _evos, _maxHexCount, _bossKills, _coreDestroy, _others.kills, _local2, _autoSave); return (_local1); } private function clickUp(_arg1:MouseEvent):void{ _celle.firing = false; } public function updateTasks():void{ var t:Object; var completeTask:Function; var stats:Array; completeTask = function (_arg1:String):void{ for each (t in _tasks) { if (t.name == _arg1){ t.completed = true; }; }; }; if (_bossKills >= 5){ completeTask("assassin"); }; if (_bossKills >= 10){ completeTask("terminator"); }; if (_maxDistance >= 5000){ completeTask("wanderer"); }; if (_maxDistance >= 10000){ completeTask("trailblazer"); }; if (_coreDestroy >= 25){ completeTask("sniper"); }; if (_areas.count >= 100){ completeTask("explorer"); }; if (_areas.count >= 200){ completeTask("voyager"); }; if (_others.kills >= 250){ completeTask("destroyer"); }; if (_others.kills >= 500){ completeTask("deathbringer"); }; if (_evos >= 50){ completeTask("evolver"); }; if (_maxHexCount >= 25){ completeTask("monster"); }; if (_maxHexCount >= 50){ completeTask("behemoth"); }; if (_foodCollected >= 5000){ completeTask("starved"); }; if (_foodCollected >= 10000){ completeTask("ravenous"); }; if ((((_bossKills >= 10)) && ((_evos <= 25)))){ completeTask("mastery"); }; if ((((_bossKills >= 10)) && ((_maxHexCount <= 20)))){ completeTask("efficiency"); }; stats = new Array(); for each (t in _tasks) { if (t.completed){ stats.push({name:t.name, value:1}); }; }; if (stats.length > 0){ _main.submitStats(stats); }; } private function clickDown(_arg1:MouseEvent):void{ if (_paused){ return; }; _celle.firing = true; } public function get fxNo():int{ return (_fxNo); } public function giveFocus(_arg1:Array=null):void{ if (!_initialized){ init(); }; if (!_celle){ return; }; if (_arg1){ loadGame(_arg1); }; prepCelle(); stage.addEventListener(MouseEvent.MOUSE_DOWN, clickDown); stage.addEventListener(MouseEvent.MOUSE_UP, clickUp); stage.addEventListener(MouseEvent.MOUSE_MOVE, updateCursor); stage.addEventListener(Event.DEACTIVATE, mouseLeave); stage.addEventListener(KeyboardEvent.KEY_DOWN, keyboardDown); stage.addEventListener(KeyboardEvent.KEY_UP, keyboardUp); stage.addEventListener(Event.ENTER_FRAME, update); visible = true; _paused = false; drawFoodHUD(); drawHUD(); _areas.drawCheckpoint(); submitStats(); if (_autoSave){ saveGameContent(); }; _win = false; if (_areas.count == 1){ fx.textDrop("You are now free to explore!", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); }; } private function alignAll():void{ var _local1:Number; var _local2:Number; var _local3:Vector; _local1 = (_centerX - _celle.x); _local2 = (_centerY - _celle.y); _local3 = new Vector(_local1, _local2); _celle.translate(_local3); _fauna.translate(_local3); _foods.translate(_local3); _areas.translate(_local3); _others.translate(_local3); fx.translate(_local3); _distanceV.minusEquals(_local3); } private function quit(_arg1:MouseEvent):void{ GameSound.play("ui"); _paused = false; _pausedScreen.visible = false; _celle.destroyHex(_celle.core, this); } private function saveGameContent():void{ var _local1:CelleFile; var _local2:SharedObject; _local1 = new CelleFile(); _local2 = SharedObject.getLocal("HexcelleGame"); _local2.data.celle = _local1.getCelleSaveString(_celle); _local2.data.areas = _areas.getSaveArray(); _local2.data.player = getSaveArray(); _local2.flush(); } public function set collision(_arg1:Boolean):void{ _collision = _arg1; } public function get fauna():Fauna{ return (_fauna); } public function set celle(_arg1:Celle):void{ var _local2:Celle; if (_celle == _arg1){ return; }; if (_celle){ for each (_local2 in _others.celles) { _local2.group.removeCollidable(_celle.group); _local2.group.removeCollidable(_celle.missiles); _local2.group.removeCollidable(_celle.bombs); _local2.missiles.removeCollidable(_celle.group); _local2.missiles.removeCollidable(_celle.bombs); _local2.bombs.removeCollidable(_celle.group); _local2.bombs.removeCollidable(_celle.missiles); }; _celle.group.removeCollidable(_fauna); _celle.group.removeCollidable(_foods); _celle.remove(); }; _celle = _arg1; if (((_celle) && (_initialized))){ _celle.group.addCollidable(_fauna); _celle.group.addCollidable(_foods); for each (_local2 in _others.celles) { _local2.group.addCollidable(_celle.group); _local2.group.addCollidable(_celle.missiles); _local2.group.addCollidable(_celle.bombs); _local2.missiles.addCollidable(_celle.group); _local2.missiles.addCollidable(_celle.bombs); _local2.bombs.addCollidable(_celle.group); _local2.bombs.addCollidable(_celle.missiles); }; }; } private function initTasks():void{ var addTask:Function; _tasks = new Array(); addTask = function (_arg1:String, _arg2:String):void{ var _local3:Object; _local3 = {name:_arg1, words:_arg2}; _tasks.push(_local3); }; addTask("assassin", "5 bosses destroyed"); addTask("terminator", "all 10 bosses destroyed"); addTask("wanderer", "5k traveled"); addTask("trailblazer", "10k traveled"); addTask("sniper", "25 hex core destroy"); addTask("explorer", "100 areas discovered"); addTask("voyager", "200 areas discovered"); addTask("destroyer", "250 celles destroyed"); addTask("deathbringer", "500 celles destroyed"); addTask("evolver", "50 evolutions"); addTask("monster", "25 hex celle"); addTask("behemoth", "50 hex celle"); addTask("starved", "5000 food"); addTask("ravenous", "10000 food"); addTask("mastery", "game complete, 25 max evolves"); addTask("efficiency", "game complete, 20 max hexes"); } public function get centerY():Number{ return (_centerY); } public function onAreaClear(_arg1:Area):void{ fx.textFloat("area cleared", _celle.x, ((_celle.y - _celle.size) - 10), 16777096); _boss = null; if (_areas.count == 2){ fx.textDrop("After defeating all enemies,\nyou will attract nearby food.", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); }; } public function die():void{ var t:TextField; var box:Sprite; var onOver:Function; var onOut:Function; var moveOn:Function; var fadeInCloth:Function; GameSound.play("death"); stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickDown); stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickUp); stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyboardDown); stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); _thrust = new Array(4); _celle.core.collidable = false; _foods.removeAll(); _main.cloth.alpha = 0; _main.cloth.visible = true; t = makeText("You Dead.", 50, 50, _main.cloth); t.multiline = true; t.appendText("\n\n\tMax distance:"); t.appendText("\n\n\tCheckpoints:"); t.appendText("\n\n\tBosses destroyed:"); t.appendText("\n\n\tAreas discovered:"); t.appendText("\n\n\tCelles destroyed:"); t.appendText("\n\n\tLargest core destroy:"); t.appendText("\n\n\tEvolutions:"); t.appendText("\n\n\tLargest celle:"); t.appendText("\n\n\tFood collected:"); t = makeText("", 200, 50, _main.cloth); t.appendText(("\n\n" + Math.round(_maxDistance))); t.appendText(("\n\n" + _checkpoints)); t.appendText(("\n\n" + _bossKills)); t.appendText(("\n\n" + _areas.count)); t.appendText(("\n\n" + _others.kills)); t.appendText((("\n\n" + _coreDestroy) + " hexes")); t.appendText(("\n\n" + _evos)); t.appendText((("\n\n" + _maxHexCount) + " hexes")); t.appendText(("\n\n" + _foodCollected)); t = makeText("CONTINUE >>>", (stage.stageWidth * 0.67), (stage.stageHeight * 0.67), _main.cloth); box = new Sprite(); var _local2 = box.graphics; with (_local2) { lineStyle(2, 0x999999); drawRect((t.x - 5), (t.y - 5), (t.width + 10), (t.height + 10)); }; box.visible = false; _main.cloth.addChild(box); onOver = function (_arg1:MouseEvent):void{ box.visible = true; GameSound.play("ui"); }; onOut = function (_arg1:MouseEvent):void{ box.visible = false; }; t.addEventListener(MouseEvent.MOUSE_OVER, onOver); t.addEventListener(MouseEvent.MOUSE_OUT, onOut); Mouse.show(); moveOn = function (_arg1:Event):void{ GameSound.play("ui"); t.removeEventListener(MouseEvent.CLICK, moveOn); while (_main.cloth.numChildren) { _main.cloth.removeChildAt(0); }; _main.switchScreen("intro"); clearGame(); }; fadeInCloth = function (_arg1:Event):void{ _main.cloth.alpha = (_main.cloth.alpha + ((1 - _main.cloth.alpha) * 0.1)); if (_main.cloth.alpha > 0.7){ _main.cloth.alpha = 0.7; _main.cloth.removeEventListener(Event.ENTER_FRAME, fadeInCloth); t.addEventListener(MouseEvent.CLICK, moveOn); }; }; _main.cloth.addEventListener(Event.ENTER_FRAME, fadeInCloth); submitStats(); } public function get centerV():Vector{ return (new Vector(_centerX, _centerY)); } public function set foodCount(_arg1:int):void{ var _local2:int; var _local3:int; _local2 = (_arg1 - _foodCount); _foodCollected = (_foodCollected + _local2); _local3 = (_foodCount % _foodQuota); _foodCount = _arg1; drawFoodHUD(); if ((_local3 + _local2) >= _foodQuota){ fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2), 3, 12320529); fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2.25), 3, 12320529); fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2.5), 3, 12320529); fx.textFloat("evolve", _celle.x, ((_celle.y - _celle.size) - 10), 4521796); if (_evos == 0){ fx.textDrop("You have collected enough food.\nPress E to evolve your celle.", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); }; GameSound.play("evolve"); }; } public function get centerX():Number{ return (_centerX); } public function onCelleDestroy(_arg1:Celle):void{ var _local2:Boolean; var _local3:int; var _local4:String; var _local5:uint; _local2 = false; if (_boss){ if (_boss == _arg1){ if (!_bossesDestroyed){ _bossesDestroyed = new Array(_bosses.length); }; _local3 = 0; while (_local3 < _bosses.length) { if (_bosses[_local3] == _boss){ _local4 = (("Boss" + _local3) + "Destroyed"); _main.submitStat(_local4, 1); _bossesDestroyed[_local3] = true; }; _local3++; }; _boss = null; _bossKills++; if (_bosses.length == _bossKills){ _local2 = true; }; fx.textFloat("boss destroyed", _arg1.x, (_arg1.y - 20), 11206655); }; }; if ((_others.kills % 10) == 0){ _local5 = 11158596; fx.ring(_arg1.x, _arg1.y, (Math.min(bounds.x, bounds.y) / 2), 3, _local5); fx.ring(_arg1.x, _arg1.y, (Math.min(bounds.x, bounds.y) / 2.25), 3, _local5); fx.ring(_arg1.x, _arg1.y, (Math.min(bounds.x, bounds.y) / 2.5), 3, _local5); fx.textFloat((_others.kills + " celles destroyed"), _arg1.x, (_arg1.y - 20), _local5); }; GameSound.play("kill"); if (_local2){ win(); }; } private function showAbilities(_arg1:MouseEvent):void{ var _local2:Boolean; var _local3:TextField; var _local4:Array; var _local5:*; _local2 = (_pausedScreenContent.numChildren > 1); while (_pausedScreenContent.numChildren) { _pausedScreenContent.removeChildAt(0); }; if (_local2){ _local3 = makeText("Current abilities:\n", 25, 60, _pausedScreenContent); _local3.multiline = true; _local4 = _celle.abilities; for each (_local5 in _local4) { _local3.appendText(("\n\t" + _local5)); }; _menu.changeItemText(3, "list stats"); } else { cleanPausedScreenContent(); _menu.changeItemText(3, "list abilities"); }; } private function update(_arg1:Event):void{ var brake:Function; var e = _arg1; if (_paused){ _thrust = new Array(4); return; }; _frameCount++; _fauna.update(); _foods.update(); _areas.update(_distanceV); if (_map){ if (_map.visible){ _areas.updateMap(_map, _distanceV); }; }; _others.update(); if (!_celle.core.dead){ if (_brakes > 0){ _brakes--; brake = function (_arg1:Hex){ _arg1.velocity = _arg1.velocity.mult(0.9); }; _celle.applyToHexes(brake); } else { _celle.thrust(_thrust); }; _celle.update(); }; fx.update(); alignAll(); drawHUD(); if (_collision){ handleCollision(); }; if (_evolve){ _paused = true; _foodCount = (_foodCount - _foodQuota); _evos++; _main.switchScreen("evolver"); _evolve = false; }; } private function fadeOutMap(_arg1:Event):void{ _map.alpha = (_map.alpha * 0.8); if (_map.alpha < 0.1){ _map.visible = false; _map.alpha = 0; _map.removeEventListener(Event.ENTER_FRAME, fadeOutMap); }; } private function fadeInMap(_arg1:Event):void{ _map.alpha = (_map.alpha + ((1 - _map.alpha) * 0.2)); if (_map.alpha > 0.9){ _map.alpha = 1; _map.removeEventListener(Event.ENTER_FRAME, fadeInMap); }; } private function cleanPausedScreenContent():void{ var _local1:int; var _local2:String; var _local3:TextField; var _local4:TextField; var _local5:HexSprite; while (_pausedScreenContent.numChildren) { if ((_pausedScreenContent.getChildAt(0) is DropdownMenu)){ DropdownMenu(_pausedScreenContent.getChildAt(0)).hide(); }; _pausedScreenContent.removeChildAt(0); }; _local3 = makeText("Current stats:", 25, 60, _pausedScreenContent); _local3.multiline = true; _local3.appendText("\n\n\tMax distance:"); _local3.appendText("\n\n\tCurrent distance:"); _local3.appendText("\n\n\tCheckpoints:"); _local3.appendText("\n\n\tBosses destroyed:"); _local3.appendText("\n\n\tAreas discovered:"); _local3.appendText("\n\n\tCelles destroyed:"); _local3.appendText("\n\n\tLargest core destroy:"); _local3.appendText("\n\n\tEvolutions:"); _local3.appendText("\n\n\tLargest celle:"); _local3.appendText("\n\n\tCurrent celle:"); _local3.appendText("\n\n\tFood collected:"); _local3.appendText("\n\n\tFood to next evolve:"); _local3 = makeText("", 175, 60, _pausedScreenContent); _local3.appendText(("\n\n" + Math.round(_maxDistance))); _local3.appendText(("\n\n" + Math.round(_distanceV.magnitude()))); _local3.appendText(("\n\n" + _checkpoints)); _local3.appendText(("\n\n" + _bossKills)); _local3.appendText(("\n\n" + _areas.count)); _local3.appendText(("\n\n" + _others.kills)); _local3.appendText((("\n\n" + _coreDestroy) + " hexes")); _local3.appendText(("\n\n" + _evos)); _local3.appendText((("\n\n" + _maxHexCount) + " hexes")); _local3.appendText((("\n\n" + _celle.hexCount) + " hexes")); _local3.appendText(("\n\n" + _foodCollected)); _local3.appendText(("\n\n" + Math.max((_foodQuota - _foodCount), 0))); _local3 = makeText("Achievements:\n", 250, 60, _pausedScreenContent); _local4 = makeText("\n", 365, 60, _pausedScreenContent, 0x666666); _local1 = 0; while (_local1 < _tasks.length) { if (_tasks[_local1].completed){ _local3.appendText((("\n\t" + _tasks[_local1].name) + ":")); _local5 = new HexSprite(6, 6); _local5.x = 260; _local5.y = (92 + (_local1 * 12.1)); _pausedScreenContent.addChild(_local5); } else { _local3.appendText("\n\t- - - - - -:"); }; _local4.appendText(("\n" + _tasks[_local1].words)); _local1++; }; _local1 = 0; while (_local1 < _fxNoMenu.itemCount) { if (_local1 == 0){ _local2 = "all"; } else { if (_local1 == 1){ _local2 = "many"; } else { _local2 = "few"; }; }; if (_fxNo == ((_fxNoMenu.itemCount - 1) - _local1)){ _local2 = ("-> " + _local2); } else { _local2 = (" " + _local2); }; _fxNoMenu.changeItemText(_local1, _local2); _local1++; }; _local1 = 0; while (_local1 < _fxQualityMenu.itemCount) { if (_local1 == 0){ _local2 = "best"; } else { if (_local1 == 1){ _local2 = "high"; } else { if (_local1 == 2){ _local2 = "medium"; } else { if (_local1 == 3){ _local2 = "low"; }; }; }; }; if (_fxQuality == _local1){ _local2 = ("-> " + _local2); } else { _local2 = (" " + _local2); }; _fxQualityMenu.changeItemText(_local1, _local2); _local1++; }; _local1 = 0; while (_local1 < _musicMenu.itemCount) { if (_local1 == 0){ _local2 = "100%"; } else { if (_local1 == 1){ _local2 = "80%"; } else { if (_local1 == 2){ _local2 = "60%"; } else { if (_local1 == 3){ _local2 = "40%"; } else { if (_local1 == 4){ _local2 = "20%"; } else { if (_local1 == 5){ _local2 = "mute"; }; }; }; }; }; }; if (((1 - GameSound.musicVolume) * (_musicMenu.itemCount - 1)) == _local1){ _local2 = ("-> " + _local2); } else { _local2 = (" " + _local2); }; _musicMenu.changeItemText(_local1, _local2); _local1++; }; _local1 = 0; while (_local1 < _fxVolumeMenu.itemCount) { if (_local1 == 0){ _local2 = "100%"; } else { if (_local1 == 1){ _local2 = "80%"; } else { if (_local1 == 2){ _local2 = "60%"; } else { if (_local1 == 3){ _local2 = "40%"; } else { if (_local1 == 4){ _local2 = "20%"; } else { if (_local1 == 5){ _local2 = "mute"; }; }; }; }; }; }; if (((1 - GameSound.fxVolume) * (_fxVolumeMenu.itemCount - 1)) == _local1){ _local2 = ("-> " + _local2); } else { _local2 = (" " + _local2); }; _fxVolumeMenu.changeItemText(_local1, _local2); _local1++; }; _local2 = (_autoSave) ? "autosave is on" : "autosave is off"; _menu.changeItemText(8, _local2); _local2 = (GameSound.mute) ? "sound is muted" : "sound is not muted"; _settingsMenu.changeItemText(2, _local2); } override public function set visible(_arg1:Boolean):void{ super.visible = _arg1; if (_celle){ _celle.playItemsVisibility = _arg1; }; if (_initialized){ _fauna.visible = _arg1; _foods.visible = _arg1; _others.visible = _arg1; _mouseCursor.visible = _arg1; if (_arg1){ Mouse.hide(); } else { Mouse.show(); }; }; if (((!(_arg1)) && (_map))){ _map.visible = false; }; } public function testOutOfBounds(_arg1:Object):Boolean{ return ((((((((_arg1.x < LEFT_EDGE)) || ((_arg1.x > RIGHT_EDGE)))) || ((_arg1.y < TOP_EDGE)))) || ((_arg1.y > BOTTOM_EDGE)))); } private function keyboardUp(_arg1:KeyboardEvent){ if (_paused){ if (_arg1.keyCode == 107){ dumpGameInfo(); }; return; }; if (_arg1.shiftKey != _shiftKey){ _shiftKey = _arg1.shiftKey; onShiftKey(_shiftKey); }; switch (_arg1.keyCode){ case 107: fx.textFloat(String(APEngine.container.numChildren), _celle.x, ((_celle.y - _celle.size) - 10), 8947899); if (_arg1.shiftKey){ dumpGameInfo(); }; break; case 87: case 38: _thrust[0] = false; break; case 65: case 37: _thrust[3] = false; break; case 83: case 40: _thrust[2] = false; break; case 68: case 39: _thrust[1] = false; break; case 32: case 17: if (!_arg1.ctrlKey){ _celle.dropping = false; }; break; }; } private function unPause(_arg1:MouseEvent):void{ GameSound.play("ui"); if (!_paused){ return; }; _paused = false; _pausedScreen.visible = false; } public function pauseGame():void{ _paused = true; _pausedScreen.visible = true; cleanPausedScreenContent(); submitStats(); } private function init():void{ var i:int; var tf:TextField; var saveMenu:DropdownMenu; var saveSlot:Function; var loadMenu:DropdownMenu; var loadSlot:Function; var options:Array; var o:Object; var changeMusicVolume:Function; var changeFXVolume:Function; var changeQuality:Function; var changeNumber:Function; var autoSave:Function; var changeMute:Function; var cursorSize:Number; var cursorOffset:Number; bounds = new Vector(stage.stageWidth, stage.stageHeight); boundary = new Vector((stage.stageWidth + (1.8 * bounds.x)), (stage.stageHeight + (2.2 * bounds.y))); RIGHT_EDGE = (boundary.x - bounds.x); LEFT_EDGE = -(bounds.x); TOP_EDGE = -(bounds.y); BOTTOM_EDGE = (boundary.y - bounds.y); _centerX = (stage.stageWidth / 2); _centerY = (stage.stageHeight / 2); _fauna = new Fauna(this, 10); _foods = new Foods(this); _others = new Others(this); _areas = new Areas(this); addChildAt(_areas, 0); fx = new FX(); addChild(fx); _celle.group.addCollidable(_fauna); _celle.group.addCollidable(_foods); ui = new Sprite(); addChild(ui); var _local2 = ui.graphics; with (_local2) { beginFill(0xEEEEEE, 0.5); drawRect(0, 0, stage.stageWidth, 30); drawRect(0, (stage.stageHeight - 30), stage.stageWidth, 30); }; _distanceV = new Vector(); _checkpoints = 0; _foodCount = 0; _evolve = false; _foodHUD = new Sprite(); ui.addChild(_foodHUD); drawFoodHUD(); _foodCollected = 0; _mainHUD = new Sprite(); ui.addChild(_mainHUD); _maxDistance = 0; drawHUD(); _map = new Sprite(); _main.ui.addChild(_map); _map.visible = false; tf = makeText("menu", 5, 5, _mainHUD); tf.addEventListener(MouseEvent.CLICK, menuClick); tf.addEventListener(MouseEvent.MOUSE_OVER, boxOver); tf.addEventListener(MouseEvent.MOUSE_OUT, boxOut); _box = new Sprite(); _mainHUD.addChild(_box); makeText(_main.version, ((stage.stageWidth / 2) - 20), (stage.stageHeight - 20), _mainHUD, 0x666666, 8); _pausedScreen = new Sprite(); _local2 = _pausedScreen.graphics; with (_local2) { beginFill(0xEEEEEE, 0.6); drawRect(0, 0, stage.stageWidth, stage.stageHeight); }; _pausedScreen.visible = false; _main.top.addChild(_pausedScreen); _pausedScreenContent = new Sprite(); _pausedScreen.addChild(_pausedScreenContent); saveMenu = new DropdownMenu("choose a slot to save"); saveSlot = function (_arg1:MouseEvent):void{ var _local2:int; var _local3:CelleFile; cleanPausedScreenContent(); _local2 = (saveMenu.indexOf(_arg1.currentTarget) + 1); _local3 = new CelleFile(); _local3.saveLocal(_celle, ("hexcelle_" + _local2)); makeText(("celle saved to slot " + _local2), (stage.stageWidth - 135), 40, _pausedScreenContent); GameSound.play("ui"); }; i = 1; while (i <= 6) { saveMenu.addItem(("slot " + i)).addEventListener(MouseEvent.CLICK, saveSlot); i = (i + 1); }; loadMenu = new DropdownMenu("choose a slot to load"); loadSlot = function (_arg1:MouseEvent):void{ var _local2:int; var _local3:CelleFile; var _local4:Celle; cleanPausedScreenContent(); _local2 = (loadMenu.indexOf(_arg1.currentTarget) + 1); _local3 = new CelleFile(); _local4 = _local3.loadLocal(("hexcelle_" + _local2)); if (_local4){ celle = _local4; prepCelle(); makeText(("celle loaded from slot " + _local2), ((stage.stageWidth / 2) - 65), 40, _pausedScreenContent); } else { makeText(("no celle found in slot " + _local2), ((stage.stageWidth / 2) - 65), 40, _pausedScreenContent); }; GameSound.play("ui"); }; i = 1; while (i <= 6) { loadMenu.addItem(("slot " + i)).addEventListener(MouseEvent.CLICK, loadSlot); i = (i + 1); }; _musicMenu = new DropdownMenu("choose a volume level"); options = _musicMenu.addItems("100%", "80%", "60%", "40%", "20%", "mute"); changeMusicVolume = function (_arg1:MouseEvent):void{ var _local2:int; _local2 = _musicMenu.indexOf(_arg1.currentTarget); GameSound.musicVolume = (1 - (_local2 / Math.max(1, (_musicMenu.itemCount - 1)))); cleanPausedScreenContent(); GameSound.play("ui"); }; for each (o in options) { o.addEventListener(MouseEvent.CLICK, changeMusicVolume); }; _fxVolumeMenu = new DropdownMenu("choose a volume level"); options = _fxVolumeMenu.addItems("100%", "80%", "60%", "40%", "20%", "mute"); changeFXVolume = function (_arg1:MouseEvent):void{ var _local2:int; _local2 = _fxVolumeMenu.indexOf(_arg1.currentTarget); GameSound.fxVolume = (1 - (_local2 / Math.max(1, (_fxVolumeMenu.itemCount - 1)))); cleanPausedScreenContent(); GameSound.play("ui"); }; for each (o in options) { o.addEventListener(MouseEvent.CLICK, changeFXVolume); }; _fxQualityMenu = new DropdownMenu("choose a quality level"); options = _fxQualityMenu.addItems("0", "1", "2", "3"); changeQuality = function (_arg1:MouseEvent):void{ var _local2:int; _local2 = _fxQualityMenu.indexOf(_arg1.currentTarget); if (_local2 == 0){ stage.quality = StageQuality.BEST; } else { if (_local2 == 1){ stage.quality = StageQuality.HIGH; } else { if (_local2 == 2){ stage.quality = StageQuality.MEDIUM; } else { if (_local2 == 3){ stage.quality = StageQuality.LOW; }; }; }; }; _fxQuality = _local2; cleanPausedScreenContent(); GameSound.play("ui"); }; for each (o in options) { o.addEventListener(MouseEvent.CLICK, changeQuality); }; _fxNoMenu = new DropdownMenu("how many effects?"); options = _fxNoMenu.addItems("2", "1", "0"); changeNumber = function (_arg1:MouseEvent):void{ var _local2:int; GameSound.play("ui"); _local2 = _fxNoMenu.indexOf(_arg1.currentTarget); _fxNo = ((_fxNoMenu.itemCount - _local2) - 1); cleanPausedScreenContent(); }; for each (o in options) { o.addEventListener(MouseEvent.CLICK, changeNumber); }; autoSave = function (_arg1:MouseEvent):void{ GameSound.play("ui"); _autoSave = !(_autoSave); cleanPausedScreenContent(); }; changeMute = function (_arg1:MouseEvent):void{ GameSound.play("ui"); GameSound.mute = !(GameSound.mute); cleanPausedScreenContent(); }; _settingsMenu = new DropdownMenu("change what setting?"); _settingsMenu.addItem("music volume"); _settingsMenu.addSubmenu(_musicMenu); _settingsMenu.addItem("effects volume"); _settingsMenu.addSubmenu(_fxVolumeMenu); _settingsMenu.addItem("mute").addEventListener(MouseEvent.CLICK, changeMute); _settingsMenu.addItem(""); _settingsMenu.addItem("visual quality"); _settingsMenu.addSubmenu(_fxQualityMenu); _settingsMenu.addItem("number of effects"); _settingsMenu.addSubmenu(_fxNoMenu); _menu = new DropdownMenu("game menu"); _pausedScreen.addChild(_menu); _menu.addItem(""); _menu.addItem("return to game").addEventListener(MouseEvent.CLICK, unPause); _menu.addItem("toggle map").addEventListener(MouseEvent.CLICK, toggleMap); _menu.addItem("list abilities").addEventListener(MouseEvent.CLICK, showAbilities); _menu.addItem(""); _menu.addItem("settings"); _menu.addSubmenu(_settingsMenu); _menu.addItem(""); _menu.addItem("save game").addEventListener(MouseEvent.CLICK, saveGame); _menu.addItem("autosave").addEventListener(MouseEvent.CLICK, autoSave); _menu.addItem(""); _menu.addItem("self-destruct").addEventListener(MouseEvent.CLICK, quit); _menu.x = 5; _menu.y = 5; _menu.show(); _mouseCursor = new Sprite(); cursorSize = 10; cursorOffset = 2; _local2 = _mouseCursor.graphics; with (_local2) { lineStyle(1, 0); moveTo(-(cursorSize), 0); lineTo(-(cursorOffset), 0); moveTo(cursorOffset, 0); lineTo(cursorSize, 0); moveTo(0, -(cursorSize)); lineTo(0, -(cursorOffset)); moveTo(0, cursorOffset); lineTo(0, cursorSize); lineStyle(1, 0xFFFFFF); drawCircle(0, 0, (cursorOffset + 2)); }; _main.top.addChild(_mouseCursor); _evos = 0; _maxHexCount = 0; _bossKills = 0; _coreDestroy = 0; initTasks(); _fxNo = 2; _fxQuality = 0; _autoSave = false; _initialized = true; } public function drawHUD():void{ var arrowOffset:Number; var currentDistance:Number; var v:*; var healer:Function; arrowOffset = 75; var _local2 = _mainHUD.graphics; with (_local2) { clear(); v = _distanceV.normalize(); v.multEquals(10); lineStyle(2, 16750882, 1); drawCircle((stage.stageWidth - arrowOffset), 14, 2); moveTo((stage.stageWidth - arrowOffset), 14); lineTo(((stage.stageWidth - arrowOffset) - v.x), (14 - v.y)); }; if (!_enemyText){ _enemyText = makeText("ENEMIES NEAR", 5, (stage.stageHeight - 25), _mainHUD, 10040115); }; if (_others.count > 0){ _enemyText.visible = true; _enemyText.alpha = (_enemyText.alpha - 0.03); if (_enemyText.alpha < 0){ _enemyText.alpha = 1; }; } else { _enemyText.visible = false; }; if (!_distanceText){ _distanceText = makeText("", ((stage.stageWidth - arrowOffset) + 20), 6, _mainHUD); _distanceText.autoSize = TextFieldAutoSize.LEFT; } else { if (_distanceText.text == ""){ _distanceText.text = String(Math.round(_maxDistance)); }; }; currentDistance = _distanceV.magnitude(); if (currentDistance > _maxDistance){ _distanceText.text = String(Math.round(currentDistance)); _maxDistance = currentDistance; if (currentDistance > ((_checkpoints + 1) * checkDistance)){ _checkpoints++; GameSound.play("checkpoint"); fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2), 3, 16750882); fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2.25), 3, 16746530); fx.ring(_celle.x, _celle.y, (Math.min(bounds.x, bounds.y) / 2.5), 3, 16750882); fx.textFloat(("checkpoint: " + (_checkpoints * checkDistance)), _celle.x, ((_celle.y - _celle.size) - 10), 16746530); _areas.drawCheckpoint(); healer = function (_arg1:Hex):void{ _arg1.armor = _arg1.maxArmor; }; _celle.applyToHexes(healer); if (_checkpoints == 1){ fx.textDrop("Your celle repairs at checkpoints.", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); }; }; }; } public function onArea(_arg1:Area):void{ _fauna.count = _areas.faunaCount; _areas.drawMap(_map); if ((((_others.count == 0)) && (!(_win)))){ if (Math.random() < (0.3 + (0.02 * _areas.steps))){ _others.spawnArea(_arg1); GameSound.play("newarea"); } else { if (_autoSave){ saveGameContent(); }; }; }; } private function keyboardDown(_arg1:KeyboardEvent){ if ((((((_arg1.keyCode == 80)) || ((_arg1.keyCode == 219)))) || ((_arg1.keyCode == 27)))){ _paused = !(_paused); _pausedScreen.visible = _paused; if (_paused){ cleanPausedScreenContent(); submitStats(); }; }; if (_paused){ return; }; if (_arg1.shiftKey != _shiftKey){ _shiftKey = _arg1.shiftKey; onShiftKey(_shiftKey); }; switch (_arg1.keyCode){ case 69: case 192: if (_foodCount >= _foodQuota){ _evolve = true; }; break; case 87: case 38: _thrust[0] = true; break; case 65: case 37: _thrust[3] = true; break; case 83: case 40: _thrust[2] = true; break; case 68: case 39: _thrust[1] = true; break; case 32: case 17: _celle.dropping = true; break; }; } private function mouseLeave(_arg1:Event):void{ if (_celle.core.dead){ return; }; pauseGame(); } private function prepCelle():void{ _celle.x = _centerX; _celle.y = _centerY; _celle.hexSize = 5; _celle.prepForPlay(this); if (_celle.hexCount > _maxHexCount){ _maxHexCount = _celle.hexCount; }; } private function saveGame(_arg1:MouseEvent):void{ GameSound.play("ui"); if (_others.count == 0){ saveGameContent(); makeText("game saved", 5, 35, _pausedScreenContent); } else { makeText("cannot save while enemies are near", 5, 35, _pausedScreenContent); GameSound.play("error"); }; } public function get collision():Boolean{ return (_collision); } public function get paused():Boolean{ return (_paused); } public function randomEdgeV():Vector{ var _local1:Vector; var _local2:Vector; var _local3:Number; _local1 = _celle.core.velocity; _local2 = new Vector(); _local3 = Math.random(); if (_local1.x > 0){ if (_local1.y > 0){ if (_local3 < 0.5){ _local2.x = RIGHT_EDGE; _local2.y = (BOTTOM_EDGE - ((Math.random() * boundary.y) / 2)); } else { _local2.y = BOTTOM_EDGE; _local2.x = (RIGHT_EDGE - ((Math.random() * boundary.x) / 2)); }; } else { if (_local1.y < 0){ if (_local3 < 0.5){ _local2.x = RIGHT_EDGE; _local2.y = (TOP_EDGE + ((Math.random() * boundary.y) / 2)); } else { _local2.y = TOP_EDGE; _local2.x = (RIGHT_EDGE - ((Math.random() * boundary.x) / 2)); }; } else { _local2.x = RIGHT_EDGE; _local2.y = randomBoundaryY(); }; }; } else { if (_local1.x < 0){ if (_local1.y > 0){ if (_local3 < 0.5){ _local2.x = LEFT_EDGE; _local2.y = (BOTTOM_EDGE - ((Math.random() * boundary.y) / 2)); } else { _local2.y = BOTTOM_EDGE; _local2.x = (LEFT_EDGE + ((Math.random() * boundary.x) / 2)); }; } else { if (_local1.y < 0){ if (_local3 < 0.5){ _local2.x = LEFT_EDGE; _local2.y = (TOP_EDGE + ((Math.random() * boundary.y) / 2)); } else { _local2.y = TOP_EDGE; _local2.x = (LEFT_EDGE + ((Math.random() * boundary.x) / 2)); }; } else { _local2.x = LEFT_EDGE; _local2.y = randomBoundaryY(); }; }; } else { if (_local1.y > 0){ _local2.y = BOTTOM_EDGE; _local2.x = randomBoundaryX(); } else { if (_local1.y < 0){ _local2.y = TOP_EDGE; _local2.x = randomBoundaryX(); } else { _local2.x = randomBoundaryX(); _local2.y = randomBoundaryY(); }; }; }; }; return (_local2); } public function get celle():Celle{ return (_celle); } public function hide():void{ if (_paused){ unPause(null); }; _paused = true; _thrust = new Array(4); visible = false; stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickDown); stage.removeEventListener(MouseEvent.MOUSE_UP, clickUp); stage.removeEventListener(MouseEvent.MOUSE_MOVE, updateCursor); stage.removeEventListener(Event.DEACTIVATE, mouseLeave); stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyboardDown); stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); stage.removeEventListener(Event.ENTER_FRAME, update); } private function boxOver(_arg1:MouseEvent):void{ var offset:Number; var x:Number; var y:Number; var w:Number; var h:Number; var e = _arg1; offset = 5; x = (e.target.x - offset); y = (e.target.y - offset); w = (e.target.width + (offset * 2)); h = (e.target.height + (offset * 2)); var _local3 = _box.graphics; with (_local3) { lineStyle(2, 0x666666); drawRect(x, y, w, h); }; GameSound.play("ui"); } public function coreDestroy(_arg1:int):void{ if (_arg1 > _coreDestroy){ _coreDestroy = _arg1; }; GameSound.play("coredestroy"); } public function get others():Others{ return (_others); } public function submitStats():void{ var _local1:Array; _local1 = new Array(); _local1.push({name:"MaxDistance", value:Math.round(_maxDistance)}); _local1.push({name:"Checkpoints", value:_checkpoints}); _local1.push({name:"BossKills", value:_bossKills}); _local1.push({name:"AreasFound", value:_areas.count}); _local1.push({name:"CelleKills", value:_others.kills}); _local1.push({name:"MaxCoreDestroy", value:_coreDestroy}); _local1.push({name:"Evolutions", value:_evos}); _local1.push({name:"MaxHexes", value:_maxHexCount}); _local1.push({name:"FoodCollected", value:_foodCollected}); _main.submitStats(_local1); updateTasks(); } private function menuClick(_arg1:MouseEvent):void{ pauseGame(); GameSound.play("ui"); } public function get boss():Celle{ return (_boss); } public function onNewArea(_arg1:Area):void{ var _local2:Boolean; var _local3:Array; var _local4:int; var _local5:int; _local2 = !(_boss); _local3 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; if (!_bosses){ _bosses = new Array(_local3.length); }; if (_local2){ _local4 = -1; _local5 = 0; while (_local5 < _local3.length) { if (_local3[_local5] < _areas.count){ _local4 = _local5; if (!_bosses[_local5]){ break; }; }; _local5++; }; if ((((_local4 > -1)) && ((_areas.steps > _local4)))){ if (_bosses[_local4] == null){ if (_others.kills >= (_local3[_local4] - 2)){ _boss = _others.spawnBoss(_arg1, _local4); _bosses[_local4] = _boss; _arg1.bgColor = 6697779; _arg1.type = "boss"; fx.textFloat(_others.BOSS_NAMES[_local4], _celle.x, ((_celle.y - _celle.size) - 10), 11184895); }; }; }; }; if (((((_local2) && (!(_boss)))) || (!(_local2)))){ _others.spawnArea(_arg1); fx.textFloat((((("new area\n" + _others.count) + " celle") + ((_others.count)>1) ? "s" : "") + " near"), _celle.x, ((_celle.y - _celle.size) - 25), 11184895); }; GameSound.play("newarea"); _areas.drawMap(_map); if (_celle.core.velocity.magnitude() > 9){ _brakes = 20; }; onArea(_arg1); if (_areas.count == 2){ fx.textDrop("You uncovered a new area.\nLook out for enemy celles.", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); } else { if (_areas.count == 3){ fx.textDrop("Distant areas will contain\nmore difficult enemies!", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); } else { if (_areas.count == 4){ fx.textDrop("Hold Shift to see a map.", _celle.x, (_celle.y + _celle.size), 0xBBBBBB); }; }; }; submitStats(); } private function toggleMap(_arg1:MouseEvent):void{ GameSound.play("ui"); if (!_map){ return; }; _map.visible = !(_map.visible); if (_map.visible){ _map.alpha = 1; _areas.updateMap(_map, _distanceV); }; } public function get foodCount():int{ return (_foodCount); } private function onShiftKey(_arg1:Boolean):void{ if (_map){ _map.removeEventListener(Event.ENTER_FRAME, fadeOutMap); _map.removeEventListener(Event.ENTER_FRAME, fadeInMap); if (_arg1){ _map.alpha = 0; _map.visible = true; _map.addEventListener(Event.ENTER_FRAME, fadeInMap); } else { _map.addEventListener(Event.ENTER_FRAME, fadeOutMap); }; }; } private function updateCursor(_arg1:MouseEvent):void{ _mouseCursor.x = mouseX; _mouseCursor.y = mouseY; } private function boxOut(_arg1:MouseEvent):void{ _box.graphics.clear(); } public function get areas():Areas{ return (_areas); } public function get frameCount():uint{ return (_frameCount); } public function get location():Vector{ return (_distanceV); } public function get main():Main{ return (_main); } public function drawFoodHUD():void{ var count:int; var t:TextField; var i:*; var progress:*; var lastX:*; var lastY:*; ui.removeChild(_foodHUD); _foodHUD = new Sprite(); ui.addChild(_foodHUD); if (_celle.hexCount < 10){ _foodQuota = (Math.pow((_celle.hexCount - 4), 3) + 20); } else { _foodQuota = ((_celle.hexCount - 6) * 50); }; count = Math.floor((_foodCount / _foodQuota)); var _local2 = _foodHUD.graphics; with (_local2) { beginFill(873458, 1); lineStyle(3, 12320529); i = 0; while (i < count) { drawCircle(((stage.stageWidth - (i * 20)) - 20), (stage.stageHeight - 15), 6); i++; }; progress = ((_foodCount % _foodQuota) / _foodQuota); lastX = ((stage.stageWidth - (count * 20)) - 20); lastY = (stage.stageHeight - 15); beginFill(873458, (progress / 1.5)); lineStyle(3, 12320529, (progress / 1.5)); drawCircle(lastX, lastY, 6); }; t = makeText("", (lastX - 2), lastY, _foodHUD); t.autoSize = TextFieldAutoSize.CENTER; t.text = ("0." + String(Math.floor((progress * 10)))); if (count > 0){ t = makeText("", (lastX - 20), lastY, _foodHUD); t.autoSize = TextFieldAutoSize.RIGHT; t.text = "press E"; }; } private function dumpGameInfo():void{ var indent:int; var dump:Function; var dumpListeners:Function; var dumpCelle:Function; var other:*; var types:Array; var names:Array; var j:int; var child:*; var name_:*; var g:*; var t:int; var n:int; var type:Object; var newName:Object; var c:*; indent = 0; dump = function (_arg1:String):void{ var _local2:String; var _local3:int; _local2 = ""; _local3 = 0; while (_local3 < indent) { _local2 = (_local2 + " "); _local3++; }; _local2 = (_local2 + _arg1); trace(_local2); }; dumpListeners = function (_arg1:Group):void{ var countListeners:Function; var group = _arg1; countListeners = function (_arg1:String):void{ var _local2:int; var _local3:int; var _local4:*; _local2 = 0; _local3 = 0; for each (_local4 in group.particles) { if (_local4.hasEventListener(_arg1)){ _local2++; }; if (_local4.sprite.hasEventListener(_arg1)){ _local3++; }; }; if (_local2 > 0){ dump((((("particles: " + _arg1) + "(") + _local2) + ")")); }; if (_local3 > 0){ dump((((("sprites: " + _arg1) + "(") + _local3) + ")")); }; }; indent = (indent + 3); countListeners(Event.ENTER_FRAME); countListeners(MouseEvent.CLICK); countListeners(MouseEvent.MOUSE_DOWN); countListeners(MouseEvent.MOUSE_UP); countListeners(MouseEvent.MOUSE_OVER); countListeners(CollisionEvent.COLLIDE); indent = (indent - 3); }; dumpCelle = function (_arg1:Celle):void{ trace("-"); dump(("hexes: " + _arg1.hexes.particles.length)); dumpListeners(_arg1.hexes); dump(("constraints: " + _arg1.hexes.constraints.length)); dump(((("missiles: " + _arg1.missiles) + ": ") + _arg1.missiles.particles.length)); dumpListeners(_arg1.missiles); dump(((("bombs: " + _arg1.bombs) + ": ") + _arg1.bombs.particles.length)); dumpListeners(_arg1.bombs); }; trace("\nPLAYER CELLE"); indent = 3; dumpCelle(_celle); trace((("\nOTHERS (" + _others.celles.length) + ")")); for each (other in _others.celles) { dumpCelle(other); }; trace((("\nFAUNA (" + _fauna.particles.length) + ")")); trace((("FOODS (" + _foods.particles.length) + ")")); trace((("BACKGROUNDS (" + _areas.bg.bgs.length) + ")")); trace((((("EFFECTS (" + fx.fx.length) + ")(") + fx.numChildren) + ")")); trace((("MAIN UI CHILDREN (" + _main.ui.numChildren) + ")")); trace((("MAIN CLOTH CHILDREN (" + _main.cloth.numChildren) + ")")); trace((("MAIN TOP CHILDREN (" + _main.top.numChildren) + ")")); trace((("MAIN GAME CHILDREN (" + _main.gameSprite.numChildren) + ")")); trace((("APENGINE CHILDREN (" + APEngine.container.numChildren) + ")")); types = new Array(); names = new Array(); j = 0; while (j < _main.gameSprite.numChildren) { t = 0; while (t < types.length) { if (types[t].label == String(_main.gameSprite.getChildAt(j))){ types[t].count++; t = (types.length + 1); }; t = (t + 1); }; if (t == types.length){ type = new Object(); type.label = String(_main.gameSprite.getChildAt(j)); type.count = 1; types.push(type); }; n = 0; while (n < names.length) { if (names[n].label == _main.gameSprite.getChildAt(j).name){ names[n].count++; n = (names.length + 1); }; n = (n + 1); }; if (n == names.length){ newName = new Object(); newName.label = _main.gameSprite.getChildAt(j).name; newName.count = 1; names.push(newName); }; j = (j + 1); }; for each (child in types) { dump((((child.label + "(") + child.count) + ")")); }; for each (name_ in names) { if (name_.count > 1){ dump((((name_.label + "(") + name_.count) + ")")); }; }; trace((("APENGINE GROUPS (" + APEngine.groups.length) + ")")); for each (g in APEngine.groups) { indent = 3; dump(("group " + APEngine.groups.indexOf(g))); indent = 6; dump((("particles (" + g.particles.length) + ")")); dump((("constraints (" + g.constraints.length) + ")")); dump("collision list:"); indent = 9; for each (c in g.collisionList) { dump(c); }; }; } public function testOnScreen(_arg1:Object):Boolean{ return ((((((((_arg1.x > 0)) && ((_arg1.x < bounds.x)))) && ((_arg1.y > 0)))) && ((_arg1.y < bounds.y)))); } public function win():void{ var t:TextField; var box:Sprite; var onOver:Function; var onOut:Function; var moveOn:Function; var fadeInCloth:Function; var o:SharedObject; stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickDown); stage.removeEventListener(MouseEvent.MOUSE_DOWN, clickUp); stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyboardDown); stage.removeEventListener(KeyboardEvent.KEY_UP, keyboardUp); _thrust = new Array(4); _foods.removeAll(); _others.destroyAll(); _main.cloth.alpha = 0; _main.cloth.visible = true; t = makeText("You Win.", 50, 50, _main.cloth); t = makeText("", 75, 75, _main.cloth); t.multiline = true; t.appendText("Survival of the fittest has proven you to be"); t.appendText("\nquite ... fit. Darwin may have been on to something,"); t.appendText("\nfor your celle's evolutionary choices have meant the"); t.appendText((((("\ndemise of " + String(_bossKills)) + " vile boss celles and ") + String((_others.kills - _bossKills))) + " lesser celles.")); t.appendText((("\nYour journey took you as far as " + String(Math.round(_maxDistance))) + " distant pixels,")); t.appendText("\nto areas where only the ugliest, meanest celles exist,"); t.appendText("\nand they stood no chance to your might, power, and"); t.appendText("\ngood looks. And speaking of areas, you managed to"); t.appendText((("\nuncover " + String(_areas.count)) + " of them - not bad by the sight of you now.")); t.appendText("\n"); t.appendText("\nFrom here on out, you are now entitled, 'King of the"); t.appendText("\nPetri Dish.' And it is not simply a fancy label. Next"); t.appendText("\ntime you customize a celle or drop into the evolver,"); t.appendText("\nyou will face no limit to the size of your celle. Go"); t.appendText("\nahead, build the biggest, baddest, most symmetrical"); t.appendText("\ncelle of your dreams. Just take it easy on the little"); t.appendText("\nguys, mmm-k?"); t.appendText("\n"); t.appendText("\nHope you enjoyed the game."); t = makeText("CONTINUE >>>", (stage.stageWidth * 0.67), (stage.stageHeight * 0.85), _main.cloth); box = new Sprite(); var _local2 = box.graphics; with (_local2) { lineStyle(2, 0x999999); drawRect((t.x - 5), (t.y - 5), (t.width + 10), (t.height + 10)); }; box.visible = false; _main.cloth.addChild(box); onOver = function (_arg1:MouseEvent):void{ box.visible = true; GameSound.play("ui"); }; onOut = function (_arg1:MouseEvent):void{ box.visible = false; }; t.addEventListener(MouseEvent.MOUSE_OVER, onOver); t.addEventListener(MouseEvent.MOUSE_OUT, onOut); Mouse.show(); moveOn = function (_arg1:Event):void{ GameSound.play("ui"); t.removeEventListener(MouseEvent.CLICK, moveOn); while (_main.cloth.numChildren) { _main.cloth.removeChildAt(0); }; _main.switchScreen("intro"); clearGame(); }; fadeInCloth = function (_arg1:Event):void{ _main.cloth.alpha = (_main.cloth.alpha + ((1 - _main.cloth.alpha) * 0.1)); if (_main.cloth.alpha > 0.7){ _main.cloth.alpha = 0.7; _main.cloth.removeEventListener(Event.ENTER_FRAME, fadeInCloth); t.addEventListener(MouseEvent.CLICK, moveOn); }; }; _main.cloth.addEventListener(Event.ENTER_FRAME, fadeInCloth); submitStats(); o = SharedObject.getLocal("HexcelleGame"); o.data.win = true; o.flush(); saveGameContent(); _win = true; } public function get foods():Foods{ return (_foods); } private function clearGame():void{ _foodCount = 0; _foodCollected = 0; _foods.removeAll(); _evos = 0; _maxHexCount = 0; _boss = null; _bosses = null; _bossKills = 0; _distanceV = new Vector(); _maxDistance = 0; _others.removeAll(); _others.kills = 0; _coreDestroy = 0; _areas.reset(); _areas.drawMap(_map); _celle.core.collidable = true; fx.removeAll(); _paused = true; celle = null; } public function randomBoundaryX():Number{ return (((Math.random() * boundary.x) - bounds.x)); } public function randomBoundaryV():Vector{ return (new Vector(randomBoundaryX(), randomBoundaryY())); } public function get checkpoints():int{ return (_checkpoints); } public function randomBoundaryY():Number{ return (((Math.random() * boundary.y) - bounds.y)); } private function loadGame(_arg1:Array):void{ var _local2:Array; var _local3:int; _areas.loadInfo(_arg1[0]); _areas.drawMap(_map); _local2 = _arg1[1]; _foodCount = _local2[0]; _foodCollected = _local2[1]; _maxDistance = _local2[2]; _checkpoints = _local2[3]; _evos = _local2[4]; _maxHexCount = _local2[5]; _bossKills = _local2[6]; _coreDestroy = _local2[7]; _others.kills = _local2[8]; _bosses = null; if (_local2[9]){ if (_local2[9].length > 0){ _bosses = new Array(); _bossesDestroyed = new Array(); _local3 = 0; while (_local3 < _local2[9].length) { if (_local2[9][_local3]){ _bosses.push(true); _bossesDestroyed.push(true); } else { _bosses.push(null); _bossesDestroyed.push(null); }; _local3++; }; } else { trace("boss array is zero length"); }; } else { trace("no boss array found"); }; _autoSave = _local2[10]; } } }//package hexcelle
Section 40
//Popup (hexcelle.Popup) package hexcelle { import flash.display.*; import flash.events.*; import flash.text.*; import flash.filters.*; public class Popup extends Sprite { private var _hide:Boolean; private var tf:TextField; private var _targetY:Number; private var _targetX:Number; private var _words:String; private var _offset:Number; private var _angle:Number; public function Popup(_arg1:String, _arg2:Number, _arg3:Number, _arg4:DisplayObjectContainer){ var dropShadow:DropShadowFilter; var words = _arg1; var targetX = _arg2; var targetY = _arg3; var container = _arg4; super(); container.addChild(this); _angle = 0; _offset = 0; _words = words; _targetX = targetX; _targetY = targetY; _hide = false; visible = false; alpha = 0; draw(); show(); dropShadow = new DropShadowFilter(); var _local6 = dropShadow; with (_local6) { distance = 6; angle = 40; blurX = 6; blurY = 6; alpha = 0.6; }; this.filters = [dropShadow]; } public function set offset(_arg1:Number):void{ _offset = _arg1; draw(); } private function makeText(_arg1:String="", _arg2:Number=0, _arg3:Number=0):TextField{ var _local4:TextFormat; if (tf){ tf.removeEventListener(MouseEvent.MOUSE_OVER, onOver); tf.removeEventListener(MouseEvent.MOUSE_OUT, onOut); tf.removeEventListener(MouseEvent.CLICK, onClick); removeChild(tf); }; _local4 = new TextFormat(); _local4.font = "Verdana"; _local4.color = 0x333333; _local4.size = 10; tf = new TextField(); tf.selectable = false; tf.background = true; tf.backgroundColor = 0xAAAAAA; if (Math.abs((_angle % Math.PI)) > (Math.PI / 2)){ tf.autoSize = TextFieldAutoSize.RIGHT; _local4.align = TextFormatAlign.RIGHT; } else { tf.autoSize = TextFieldAutoSize.LEFT; _local4.align = TextFormatAlign.LEFT; }; tf.defaultTextFormat = _local4; tf.x = _arg2; tf.y = _arg3; tf.text = _arg1; tf.addEventListener(MouseEvent.MOUSE_OVER, onOver); tf.addEventListener(MouseEvent.MOUSE_OUT, onOut); tf.addEventListener(MouseEvent.CLICK, onClick); addChild(tf); return (tf); } private function draw():void{ var _local2 = graphics; with (_local2) { clear(); beginFill(0xFFFFFF, 0.5); endFill(); lineStyle(1, 0x222222); moveTo(_targetX, _targetY); lineTo(((_offset * Math.cos(_angle)) + _targetX), ((_offset * Math.sin(_angle)) + _targetY)); }; makeText(_words, ((_offset * Math.cos(_angle)) + _targetX), ((_offset * Math.sin(_angle)) + _targetY)); } public function unhide():void{ _hide = false; } public function hide():void{ removeEventListener(Event.ENTER_FRAME, disappear); removeEventListener(Event.ENTER_FRAME, appear); addEventListener(Event.ENTER_FRAME, disappear); tf.removeEventListener(MouseEvent.CLICK, onClick); tf.removeEventListener(MouseEvent.CLICK, onOver); tf.removeEventListener(MouseEvent.CLICK, onOut); } private function onOver(_arg1:MouseEvent):void{ tf.backgroundColor = 0x888888; } public function remove():void{ if (!parent){ return; }; hide(); parent.removeChild(this); } private function appear(_arg1:Event):void{ alpha = (alpha + ((1 - alpha) * 0.2)); if (alpha > 0.95){ removeEventListener(Event.ENTER_FRAME, appear); alpha = 1; }; } public function set angle(_arg1:Number):void{ _angle = _arg1; draw(); } private function disappear(_arg1:Event):void{ alpha = (alpha * 0.8); if (alpha < 0.05){ visible = false; alpha = 0; removeEventListener(Event.ENTER_FRAME, disappear); }; } private function onClick(_arg1:MouseEvent):void{ _hide = true; hide(); } private function onOut(_arg1:MouseEvent):void{ tf.backgroundColor = 0xAAAAAA; } override public function set x(_arg1:Number):void{ _targetX = _arg1; draw(); } override public function set y(_arg1:Number):void{ _targetY = _arg1; draw(); } public function show():void{ if (_hide){ return; }; removeEventListener(Event.ENTER_FRAME, disappear); removeEventListener(Event.ENTER_FRAME, appear); visible = true; addEventListener(Event.ENTER_FRAME, appear); tf.addEventListener(MouseEvent.MOUSE_OVER, onOver); tf.addEventListener(MouseEvent.MOUSE_OUT, onOut); tf.addEventListener(MouseEvent.CLICK, onClick); } } }//package hexcelle
Section 41
//Tools (hexcelle.Tools) package hexcelle { import flash.display.*; import flash.events.*; import flash.text.*; import flash.system.*; import flash.utils.*; public class Tools { public static var TextFont:String = "HexcelleFont"; public static function makeInput(_arg1:DisplayObjectContainer, _arg2:String="", _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:Number=NaN, _arg7:Number=NaN, _arg8:Number=NaN):TextField{ var _local9:TextField; _local9 = makeText(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8); _local9.type = TextFieldType.INPUT; _local9.selectable = true; return (_local9); } public static function getBoxSprite():ARGSprite{ var container:ARGSprite; var box:Sprite; var fadeInBox:Function; var fadeOutBox:Function; var draw:Function; var over:Function; var out:Function; var added:Function; container = new ARGSprite(); box = new Sprite(); box.alpha = 0; container.addChild(box); fadeInBox = function (_arg1:Event):void{ if (box.alpha > 0.95){ box.alpha = 1; container.removeEventListener(Event.ENTER_FRAME, fadeInBox); } else { box.alpha = (box.alpha + ((1 - box.alpha) * 0.2)); }; }; fadeOutBox = function (_arg1:Event):void{ if (box.alpha < 0.05){ box.alpha = 0; container.removeEventListener(Event.ENTER_FRAME, fadeOutBox); } else { box.alpha = (box.alpha * 0.8); }; }; draw = function ():void{ container.removeChild(box); container.addChild(box); box.graphics.clear(); box.graphics.lineStyle(3, 0); box.graphics.beginFill(0, 0); box.graphics.drawRect(-5, -5, (container.width + 10), (container.height + 10)); }; over = function (_arg1:MouseEvent):void{ draw(); container.removeEventListener(Event.ENTER_FRAME, fadeOutBox); container.addEventListener(Event.ENTER_FRAME, fadeInBox); }; out = function (_arg1:MouseEvent):void{ container.removeEventListener(Event.ENTER_FRAME, fadeInBox); container.addEventListener(Event.ENTER_FRAME, fadeOutBox); }; added = function (_arg1:Event):void{ draw(); }; container.addEventListener(MouseEvent.MOUSE_OVER, over); container.addEventListener(MouseEvent.MOUSE_OUT, out); container.addEventListener(Event.ADDED_TO_STAGE, added); container.buttonMode = true; return (container); } public static function makeText(_arg1:DisplayObjectContainer, _arg2:String="", _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:uint=0x333333, _arg7:Number=NaN, _arg8:Number=NaN):TextField{ var _local9:*; var _local10:TextFormat; var _local11:Class; _local9 = new TextField(); _local9.name = "txt"; _local9.autoSize = TextFieldAutoSize.LEFT; _local9.selectable = false; _local10 = new TextFormat(); if (ApplicationDomain.currentDomain.hasDefinition(TextFont)){ _local11 = (getDefinitionByName(TextFont) as Class); _local10.font = new (_local11).fontName; _local9.embedFonts = true; } else { trace(("text font not found: " + TextFont)); _local10.font = "Arial"; }; _local10.color = _arg6; _local10.size = _arg5; _local9.defaultTextFormat = _local10; _local9.x = _arg3; _local9.y = _arg4; if (((_arg7) || (_arg8))){ _local9.wordWrap = true; if (_arg7){ _local9.width = _arg7; }; if (_arg8){ _local9.height = _arg8; }; }; _local9.text = _arg2; _arg1.addChild(_local9); return (_local9); } public static function makeBoxButton(_arg1:DisplayObjectContainer, _arg2:String, _arg3:Number=0, _arg4:Number=0, _arg5:Number=10, _arg6:uint=0x888888):ARGSprite{ var button:ARGSprite; var tf:TextField; var box:Sprite; var fadeInBox:Function; var fadeOutBox:Function; var buttonOver:Function; var buttonOut:Function; var container = _arg1; var t = _arg2; var posX = _arg3; var posY = _arg4; var size = _arg5; var color = _arg6; button = new ARGSprite(); button.buttonMode = true; button.mouseChildren = false; container.addChild(button); button.x = posX; button.y = posY; tf = makeText(button, t, 0, 0, size, color); box = new Sprite(); button.addChild(box); box.graphics.lineStyle(3, 0); box.graphics.beginFill(0, 0); box.graphics.drawRect(-5, -5, (tf.width + 10), (tf.height + 10)); box.alpha = 0; fadeInBox = function (_arg1:Event):void{ if (box.alpha > 0.95){ box.alpha = 1; button.removeEventListener(Event.ENTER_FRAME, fadeInBox); } else { box.alpha = (box.alpha + ((1 - box.alpha) * 0.2)); }; }; fadeOutBox = function (_arg1:Event):void{ if (box.alpha < 0.05){ box.alpha = 0; button.removeEventListener(Event.ENTER_FRAME, fadeOutBox); } else { box.alpha = (box.alpha * 0.8); }; }; buttonOver = function (_arg1:MouseEvent):void{ button.removeEventListener(Event.ENTER_FRAME, fadeOutBox); button.addEventListener(Event.ENTER_FRAME, fadeInBox); }; buttonOut = function (_arg1:MouseEvent):void{ button.removeEventListener(Event.ENTER_FRAME, fadeInBox); button.addEventListener(Event.ENTER_FRAME, fadeOutBox); }; button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); return (button); } } }//package hexcelle
Section 42
//UtilityCircleParticle (hexcelle.UtilityCircleParticle) package hexcelle { import org.cove.ape.*; public class UtilityCircleParticle extends CircleParticle { public function UtilityCircleParticle(_arg1:Number, _arg2:Number, _arg3:Number){ super(_arg1, _arg2, _arg3); } public function get x():Number{ return (px); } public function set y(_arg1:Number){ py = _arg1; } public function get y():Number{ return (py); } public function removeSpriteEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{ sprite.removeEventListener(_arg1, _arg2, _arg3); } public function hasSpriteEventListener(_arg1:String):Boolean{ return (sprite.hasEventListener(_arg1)); } public function translate(_arg1:Vector){ curr.plusEquals(_arg1); prev.plusEquals(_arg1); } public function addSpriteEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{ sprite.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5); } public function set x(_arg1:Number){ px = _arg1; } } }//package hexcelle
Section 43
//UtilitySprite (hexcelle.UtilitySprite) package hexcelle { import flash.display.*; import flash.text.*; public class UtilitySprite extends Sprite { public function makeText(_arg1:String="", _arg2:Number=0, _arg3:Number=0, _arg4:DisplayObjectContainer=null, _arg5:uint=0x333333, _arg6:Number=10):TextField{ var _local7:*; var _local8:TextFormat; var _local9:HexcelleFont; _local7 = new TextField(); _local7.autoSize = TextFieldAutoSize.LEFT; _local7.selectable = false; _local8 = new TextFormat(); _local9 = new HexcelleFont(); _local8.font = _local9.fontName; _local7.embedFonts = true; _local8.color = _arg5; _local8.size = _arg6; _local7.defaultTextFormat = _local8; _local7.text = _arg1; _local7.x = _arg2; _local7.y = _arg3; if (!_arg4){ _arg4 = this; }; _arg4.addChild(_local7); return (_local7); } public function makeInput(_arg1:String="", _arg2:Number=0, _arg3:Number=0, _arg4:DisplayObjectContainer=null):TextField{ var _local5:TextField; _local5 = makeText(_arg1, _arg2, _arg3, _arg4); _local5.type = TextFieldType.INPUT; _local5.selectable = true; _local5.background = true; _local5.backgroundColor = 0xBBBBBB; return (_local5); } public function CHSprite(){ } } }//package hexcelle
Section 44
//UtilityWheelParticle (hexcelle.UtilityWheelParticle) package hexcelle { import org.cove.ape.*; public class UtilityWheelParticle extends WheelParticle { public function UtilityWheelParticle(_arg1:Number, _arg2:Number, _arg3:Number){ super(_arg1, _arg2, _arg3); } override public function set radius(_arg1:Number):void{ super.radius = (_arg1 - 1); } public function addSpriteEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{ sprite.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5); } public function translate(_arg1:Vector){ curr.plusEquals(_arg1); prev.plusEquals(_arg1); } public function get x():Number{ return (px); } public function get y():Number{ return (py); } public function removeSpriteEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{ sprite.removeEventListener(_arg1, _arg2, _arg3); } override public function get radius():Number{ return ((super.radius + 1)); } public function hasSpriteEventListener(_arg1:String):Boolean{ return (sprite.hasEventListener(_arg1)); } public function set x(_arg1:Number){ px = _arg1; } public function set y(_arg1:Number){ py = _arg1; } } }//package hexcelle
Section 45
//MainTimeline (hexcelle_fla.MainTimeline) package hexcelle_fla { import flash.display.*; import flash.events.*; import flash.text.*; import hexcelle.*; public dynamic class MainTimeline extends MovieClip { public var output:TextField; public var m:Main; public var hexMask:MovieClip; public function MainTimeline(){ addFrameScript(0, frame1, 2, frame3); } public function preload(_arg1:Event):void{ var _local2:Number; var _local3:Number; var _local4:int; _local2 = stage.loaderInfo.bytesLoaded; _local3 = stage.loaderInfo.bytesTotal; _local4 = Math.floor(((_local2 / _local3) * 100)); output.text = (_local4 + "%"); hexMask.scaleY = (_local4 / 100); if (_local4 == 100){ removeEventListener(Event.ENTER_FRAME, preload); play(); }; } function frame3(){ stop(); m = new Main(); addChild(m); m.init(); } function frame1(){ stop(); hexMask.scaleY = 0.1; addEventListener(Event.ENTER_FRAME, preload); } } }//package hexcelle_fla
Section 46
//MusicContainer_2 (hexcelle_fla.MusicContainer_2) package hexcelle_fla { import flash.display.*; public dynamic class MusicContainer_2 extends MovieClip { public function MusicContainer_2(){ addFrameScript(0, frame1); } function frame1(){ stop(); } } }//package hexcelle_fla
Section 47
//SoundContainer_3 (hexcelle_fla.SoundContainer_3) package hexcelle_fla { import flash.display.*; public dynamic class SoundContainer_3 extends MovieClip { public function SoundContainer_3(){ addFrameScript(0, frame1); } function frame1(){ stop(); } } }//package hexcelle_fla
Section 48
//AbstractCollection (org.cove.ape.AbstractCollection) package org.cove.ape { import flash.display.*; import flash.utils.*; public class AbstractCollection { private var _sprite:Sprite; private var _isParented:Boolean; private var _particles:Array; private var _constraints:Array; public function AbstractCollection(){ if (getQualifiedClassName(this) == "org.cove.ape::AbstractCollection"){ throw (new ArgumentError("AbstractCollection can't be instantiated directly")); }; _isParented = false; _particles = new Array(); _constraints = new Array(); } public function getAll():Array{ return (particles.concat(constraints)); } function checkCollisionsVsCollection(_arg1:AbstractCollection):void{ var _local2:int; var _local3:int; var _local4:int; var _local5:AbstractParticle; var _local6:int; var _local7:int; var _local8:int; var _local9:AbstractParticle; var _local10:SpringConstraint; var _local11:SpringConstraint; var _local12:int; _local2 = _particles.length; _local3 = 0; while (_local3 < _local2) { _local5 = _particles[_local3]; if ((((_local5 == null)) || (!(_local5.collidable)))){ } else { _local6 = _arg1.particles.length; _local7 = 0; while (_local7 < _local6) { _local9 = _arg1.particles[_local7]; if (((!((_local9 == null))) && (_local9.collidable))){ CollisionDetector.test(_local5, _local9); }; _local7++; }; _local8 = _arg1.constraints.length; _local7 = 0; while (_local7 < _local8) { _local10 = _arg1.constraints[_local7]; if (((((!((_local10 == null))) && (_local10.collidable))) && (!(_local10.isConnectedTo(_local5))))){ _local10.scp.updatePosition(); CollisionDetector.test(_local5, _local10.scp); }; _local7++; }; }; _local3++; }; _local4 = _constraints.length; _local3 = 0; while (_local3 < _local4) { _local11 = _constraints[_local3]; if ((((_local11 == null)) || (!(_local11.collidable)))){ } else { _local6 = _arg1.particles.length; _local12 = 0; while (_local12 < _local6) { _local9 = _arg1.particles[_local12]; if (((((!((_local9 == null))) && (_local9.collidable))) && (!(_local11.isConnectedTo(_local9))))){ _local11.scp.updatePosition(); CollisionDetector.test(_local9, _local11.scp); }; _local12++; }; }; _local3++; }; } public function get sprite():Sprite{ if (_sprite != null){ return (_sprite); }; if (APEngine.container == null){ throw (new Error("The container property of the APEngine class has not been set")); }; _sprite = new Sprite(); APEngine.container.addChild(_sprite); return (_sprite); } function checkInternalCollisions():void{ var _local1:int; var _local2:int; var _local3:AbstractParticle; var _local4:int; var _local5:int; var _local6:int; var _local7:AbstractParticle; var _local8:SpringConstraint; _local1 = _particles.length; _local2 = 0; while (_local2 < _local1) { _local3 = _particles[_local2]; if ((((_local3 == null)) || (!(_local3.collidable)))){ } else { _local4 = (_local2 + 1); while (_local4 < _local1) { _local7 = _particles[_local4]; if (((!((_local7 == null))) && (_local7.collidable))){ CollisionDetector.test(_local3, _local7); }; _local4++; }; _local5 = _constraints.length; _local6 = 0; while (_local6 < _local5) { _local8 = _constraints[_local6]; if (((((!((_local8 == null))) && (_local8.collidable))) && (!(_local8.isConnectedTo(_local3))))){ _local8.scp.updatePosition(); CollisionDetector.test(_local3, _local8.scp); }; _local6++; }; }; _local2++; }; } public function addParticle(_arg1:AbstractParticle):void{ particles.push(_arg1); if (isParented){ _arg1.init(); }; } public function removeConstraint(_arg1:AbstractConstraint):void{ var _local2:int; _local2 = constraints.indexOf(_arg1); if (_local2 == -1){ return; }; constraints.splice(_local2, 1); _arg1.cleanup(); } function get isParented():Boolean{ return (_isParented); } public function init():void{ var _local1:int; _local1 = 0; while (_local1 < particles.length) { particles[_local1].init(); _local1++; }; _local1 = 0; while (_local1 < constraints.length) { constraints[_local1].init(); _local1++; }; } function satisfyConstraints():void{ var _local1:int; var _local2:int; var _local3:AbstractConstraint; _local1 = _constraints.length; _local2 = 0; while (_local2 < _local1) { _local3 = _constraints[_local2]; _local3.resolve(); _local2++; }; } public function paint():void{ var _local1:AbstractParticle; var _local2:int; var _local3:int; var _local4:SpringConstraint; _local2 = _particles.length; _local3 = 0; while (_local3 < _local2) { _local1 = _particles[_local3]; if (((!(_local1.fixed)) || (_local1.alwaysRepaint))){ _local1.paint(); }; _local3++; }; _local2 = _constraints.length; _local3 = 0; while (_local3 < _local2) { _local4 = _constraints[_local3]; if (((!(_local4.fixed)) || (_local4.alwaysRepaint))){ _local4.paint(); }; _local3++; }; } public function addConstraint(_arg1:AbstractConstraint):void{ constraints.push(_arg1); if (isParented){ _arg1.init(); }; } function set isParented(_arg1:Boolean):void{ _isParented = _arg1; } public function removeParticle(_arg1:AbstractParticle):void{ var _local2:int; _local2 = particles.indexOf(_arg1); if (_local2 == -1){ return; }; particles.splice(_local2, 1); _arg1.cleanup(); } public function cleanup():void{ var _local1:int; _local1 = 0; while (_local1 < particles.length) { particles[_local1].cleanup(); _local1++; }; _local1 = 0; while (_local1 < constraints.length) { constraints[_local1].cleanup(); _local1++; }; } public function get particles():Array{ return (_particles); } function integrate(_arg1:Number):void{ var _local2:int; var _local3:int; var _local4:AbstractParticle; _local2 = _particles.length; _local3 = 0; while (_local3 < _local2) { _local4 = _particles[_local3]; _local4.update(_arg1); _local3++; }; } public function get constraints():Array{ return (_constraints); } } }//package org.cove.ape
Section 49
//AbstractConstraint (org.cove.ape.AbstractConstraint) package org.cove.ape { import flash.utils.*; public class AbstractConstraint extends AbstractItem { private var _stiffness:Number; public function AbstractConstraint(_arg1:Number){ if (getQualifiedClassName(this) == "org.cove.ape::AbstractConstraint"){ throw (new ArgumentError("AbstractConstraint can't be instantiated directly")); }; this.stiffness = _arg1; setStyle(); } public function get stiffness():Number{ return (_stiffness); } public function resolve():void{ } public function set stiffness(_arg1:Number):void{ _stiffness = _arg1; } } }//package org.cove.ape
Section 50
//AbstractItem (org.cove.ape.AbstractItem) package org.cove.ape { import flash.display.*; import flash.events.*; public class AbstractItem extends EventDispatcher { var displayObjectOffset:Vector; var fillColor:uint; var displayObject:DisplayObject; var fillAlpha:Number; private var _solid:Boolean; private var _visible:Boolean; var displayObjectRotation:Number; var lineColor:uint; var lineAlpha:Number; var lineThickness:Number; private var _sprite:Sprite; private var _alwaysRepaint:Boolean; public function AbstractItem(){ _solid = true; _visible = true; _alwaysRepaint = false; } public function setFill(_arg1:uint=0xFFFFFF, _arg2:Number=1):void{ fillColor = _arg1; fillAlpha = _arg2; } public function init():void{ } public function cleanup():void{ var _local1:int; sprite.graphics.clear(); _local1 = 0; while (_local1 < sprite.numChildren) { sprite.removeChildAt(_local1); _local1++; }; } public function get solid():Boolean{ return (_solid); } public function get sprite():Sprite{ if (_sprite != null){ return (_sprite); }; if (APEngine.container == null){ throw (new Error("The container property of the APEngine class has not been set")); }; _sprite = new Sprite(); APEngine.container.addChild(_sprite); return (_sprite); } public function set solid(_arg1:Boolean):void{ _solid = _arg1; } public function paint():void{ } public function set visible(_arg1:Boolean):void{ _visible = _arg1; sprite.visible = _arg1; } public function setStyle(_arg1:Number=0, _arg2:uint=0, _arg3:Number=1, _arg4:uint=0xFFFFFF, _arg5:Number=1):void{ setLine(_arg1, _arg2, _arg3); setFill(_arg4, _arg5); } public function get visible():Boolean{ return (_visible); } public function setLine(_arg1:Number=0, _arg2:uint=0, _arg3:Number=1):void{ lineThickness = _arg1; lineColor = _arg2; lineAlpha = _arg3; } final public function set alwaysRepaint(_arg1:Boolean):void{ _alwaysRepaint = _arg1; } final public function get alwaysRepaint():Boolean{ return (_alwaysRepaint); } } }//package org.cove.ape
Section 51
//AbstractParticle (org.cove.ape.AbstractParticle) package org.cove.ape { import flash.display.*; import flash.utils.*; public class AbstractParticle extends AbstractItem { private var forceList:Array; public var curr:Vector; public var prev:Vector; private var collision:Collision; private var _invMass:Number; private var _friction:Number; private var firstCollision:Boolean; private var _multisample:int; var samp:Vector; private var _center:Vector; private var _fixed:Boolean; private var _collidable:Boolean; private var _kfr:Number; var interval:Interval; private var _mass:Number; private var temp:Vector; private var forces:Vector; public function AbstractParticle(_arg1:Number, _arg2:Number, _arg3:Boolean, _arg4:Number, _arg5:Number, _arg6:Number){ if (getQualifiedClassName(this) == "org.cove.ape::AbstractParticle"){ throw (new ArgumentError("AbstractParticle can't be instantiated directly")); }; interval = new Interval(0, 0); curr = new Vector(_arg1, _arg2); prev = new Vector(_arg1, _arg2); samp = new Vector(); temp = new Vector(); fixed = _arg3; forces = new Vector(); forceList = new Array(); collision = new Collision(new Vector(), new Vector()); collidable = true; firstCollision = false; this.mass = _arg4; this.elasticity = _arg5; this.friction = _arg6; setStyle(); _center = new Vector(); _multisample = 0; } public function get px():Number{ return (curr.x); } public function get py():Number{ return (curr.y); } public function set py(_arg1:Number):void{ curr.y = _arg1; prev.y = _arg1; } function getComponents(_arg1:Vector):Collision{ var _local2:Vector; var _local3:Number; _local2 = velocity; _local3 = _arg1.dot(_local2); collision.vn = _arg1.mult(_local3); collision.vt = _local2.minus(collision.vn); return (collision); } public function set px(_arg1:Number):void{ curr.x = _arg1; prev.x = _arg1; } public function setDisplay(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{ displayObject = _arg1; displayObjectRotation = _arg4; displayObjectOffset = new Vector(_arg2, _arg3); cleanup(); initDisplay(); } public function get multisample():int{ return (_multisample); } public function get position():Vector{ return (new Vector(curr.x, curr.y)); } public function set multisample(_arg1:int):void{ _multisample = _arg1; } public function get center():Vector{ _center.setTo(px, py); return (_center); } public function set position(_arg1:Vector):void{ curr.copy(_arg1); prev.copy(_arg1); } function testParticleEvents(_arg1:AbstractParticle):void{ if (hasEventListener(CollisionEvent.COLLIDE)){ dispatchEvent(new CollisionEvent(CollisionEvent.COLLIDE, false, false, _arg1)); }; if (((hasEventListener(CollisionEvent.FIRST_COLLIDE)) && (!(firstCollision)))){ firstCollision = true; dispatchEvent(new CollisionEvent(CollisionEvent.FIRST_COLLIDE, false, false, _arg1)); }; } public function set elasticity(_arg1:Number):void{ _kfr = _arg1; } public function get fixed():Boolean{ return (_fixed); } function get invMass():Number{ return ((fixed) ? 0 : _invMass); } public function resetFirstCollision():void{ firstCollision = false; } function initDisplay():void{ displayObject.x = displayObjectOffset.x; displayObject.y = displayObjectOffset.y; displayObject.rotation = displayObjectRotation; sprite.addChild(displayObject); } private function clearForces():void{ forceList.length = 0; forces.setTo(0, 0); } function resolveCollision(_arg1:Vector, _arg2:Vector, _arg3:Vector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{ testParticleEvents(_arg6); if (((((fixed) || (!(solid)))) || (!(_arg6.solid)))){ return; }; curr.copy(samp); curr.plusEquals(_arg1); velocity = _arg2; } public function get elasticity():Number{ return (_kfr); } public function set velocity(_arg1:Vector):void{ prev = curr.minus(_arg1); } public function set collidable(_arg1:Boolean):void{ _collidable = _arg1; } public function update(_arg1:Number):void{ var _local2:Vector; if (fixed){ return; }; accumulateForces(); temp.copy(curr); _local2 = velocity.plus(forces.multEquals(_arg1)); curr.plusEquals(_local2.multEquals(APEngine.damping)); prev.copy(temp); clearForces(); } public function addForce(_arg1:IForce):void{ forceList.push(_arg1); } public function get velocity():Vector{ return (curr.minus(prev)); } public function get collidable():Boolean{ return (_collidable); } public function set mass(_arg1:Number):void{ if (_arg1 <= 0){ throw (new ArgumentError("mass may not be set <= 0")); }; _mass = _arg1; _invMass = (1 / _mass); } public function set fixed(_arg1:Boolean):void{ _fixed = _arg1; } private function accumulateForces():void{ var _local1:IForce; var _local2:int; var _local3:int; var _local4:Array; _local2 = forceList.length; _local3 = 0; while (_local3 < _local2) { _local1 = forceList[_local3]; forces.plusEquals(_local1.getValue(_invMass)); _local3++; }; _local4 = APEngine.forces; _local2 = _local4.length; _local3 = 0; while (_local3 < _local2) { _local1 = _local4[_local3]; forces.plusEquals(_local1.getValue(_invMass)); _local3++; }; } public function get mass():Number{ return (_mass); } public function get friction():Number{ return (_friction); } public function set friction(_arg1:Number):void{ if ((((_arg1 < 0)) || ((_arg1 > 1)))){ throw (new ArgumentError("Legal friction must be >= 0 and <=1")); }; _friction = _arg1; } } }//package org.cove.ape
Section 52
//APEngine (org.cove.ape.APEngine) package org.cove.ape { import flash.display.*; public final class APEngine { private static var _damping:Number; private static var _container:DisplayObjectContainer; private static var _constraintCollisionCycles:int; public static var groups:Array; static var forces:Array; private static var _constraintCycles:int; private static var timeStep:Number; private static var numGroups:int; public static function get container():DisplayObjectContainer{ return (_container); } public static function get constraintCollisionCycles():int{ return (_constraintCollisionCycles); } public static function removeForce(_arg1:IForce):void{ var _local2:int; _local2 = forces.indexOf(_arg1); if (_local2 == -1){ return; }; forces.splice(_local2, 1); } public static function set damping(_arg1:Number):void{ _damping = _arg1; } public static function step():void{ var _local1:int; var _local2:int; integrate(); _local1 = 0; while (_local1 < _constraintCycles) { satisfyConstraints(); _local1++; }; _local2 = 0; while (_local2 < _constraintCollisionCycles) { satisfyConstraints(); checkCollisions(); _local2++; }; } public static function get constraintCycles():int{ return (_constraintCycles); } public static function set constraintCollisionCycles(_arg1:int):void{ _constraintCollisionCycles = _arg1; } public static function init(_arg1:Number=0.25):void{ timeStep = (_arg1 * _arg1); numGroups = 0; groups = new Array(); forces = new Array(); _damping = 1; _constraintCycles = 0; _constraintCollisionCycles = 1; } public static function addForce(_arg1:IForce):void{ forces.push(_arg1); } public static function get damping():Number{ return (_damping); } public static function set constraintCycles(_arg1:int):void{ _constraintCycles = _arg1; } public static function addGroup(_arg1:Group):void{ groups.push(_arg1); _arg1.isParented = true; numGroups++; _arg1.init(); } public static function set container(_arg1:DisplayObjectContainer):void{ _container = _arg1; } public static function paint():void{ var _local1:int; var _local2:Group; _local1 = 0; while (_local1 < numGroups) { _local2 = groups[_local1]; _local2.paint(); _local1++; }; } public static function removeGroup(_arg1:Group):void{ var _local2:int; _local2 = groups.indexOf(_arg1); if (_local2 == -1){ return; }; groups.splice(_local2, 1); _arg1.isParented = false; numGroups--; _arg1.cleanup(); } private static function satisfyConstraints():void{ var _local1:int; var _local2:Group; _local1 = 0; while (_local1 < numGroups) { _local2 = groups[_local1]; _local2.satisfyConstraints(); _local1++; }; } public static function removeAllForce():void{ forces = new Array(); } private static function checkCollisions():void{ var _local1:int; var _local2:Group; _local1 = 0; while (_local1 < numGroups) { _local2 = groups[_local1]; _local2.checkCollisions(); _local1++; }; } private static function integrate():void{ var _local1:int; var _local2:Group; _local1 = 0; while (_local1 < numGroups) { _local2 = groups[_local1]; _local2.integrate(timeStep); _local1++; }; } } }//package org.cove.ape
Section 53
//CircleParticle (org.cove.ape.CircleParticle) package org.cove.ape { public class CircleParticle extends AbstractParticle { private var _radius:Number; public function CircleParticle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=0.3, _arg7:Number=0){ super(_arg1, _arg2, _arg4, _arg5, _arg6, _arg7); _radius = _arg3; } function getProjection(_arg1:Vector):Interval{ var _local2:Number; _local2 = samp.dot(_arg1); interval.min = (_local2 - _radius); interval.max = (_local2 + _radius); return (interval); } override public function init():void{ cleanup(); if (displayObject != null){ initDisplay(); } else { sprite.graphics.clear(); sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha); sprite.graphics.beginFill(fillColor, fillAlpha); sprite.graphics.drawCircle(0, 0, radius); sprite.graphics.endFill(); }; paint(); } public function get radius():Number{ return (_radius); } function getIntervalY():Interval{ interval.min = (samp.y - _radius); interval.max = (samp.y + _radius); return (interval); } public function set radius(_arg1:Number):void{ _radius = _arg1; } override public function paint():void{ sprite.x = curr.x; sprite.y = curr.y; } function getIntervalX():Interval{ interval.min = (samp.x - _radius); interval.max = (samp.x + _radius); return (interval); } } }//package org.cove.ape
Section 54
//Collision (org.cove.ape.Collision) package org.cove.ape { import org.cove.ape.*; final class Collision { var vn:Vector; var vt:Vector; function Collision(_arg1:Vector, _arg2:Vector){ this.vn = _arg1; this.vt = _arg2; } } }//package org.cove.ape
Section 55
//CollisionDetector (org.cove.ape.CollisionDetector) package org.cove.ape { import org.cove.ape.*; final class CollisionDetector { private static var collNormal:Vector; private static var cpa:AbstractParticle; private static var cpb:AbstractParticle; private static var collDepth:Number; private static function testIntervals(_arg1:Interval, _arg2:Interval):Number{ var _local3:Number; var _local4:Number; if (_arg1.max < _arg2.min){ return (0); }; if (_arg2.max < _arg1.min){ return (0); }; _local3 = (_arg2.max - _arg1.min); _local4 = (_arg2.min - _arg1.max); return (((Math.abs(_local3))<Math.abs(_local4)) ? _local3 : _local4); } private static function testOBBvsOBB(_arg1:RectangleParticle, _arg2:RectangleParticle):Boolean{ var _local3:int; var _local4:Vector; var _local5:Number; var _local6:Vector; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Boolean; collDepth = Number.POSITIVE_INFINITY; _local3 = 0; while (_local3 < 2) { _local4 = _arg1.axes[_local3]; _local5 = testIntervals(_arg1.getProjection(_local4), _arg2.getProjection(_local4)); if (_local5 == 0){ return (false); }; _local6 = _arg2.axes[_local3]; _local7 = testIntervals(_arg1.getProjection(_local6), _arg2.getProjection(_local6)); if (_local7 == 0){ return (false); }; _local8 = Math.abs(_local5); _local9 = Math.abs(_local7); if ((((_local8 < Math.abs(collDepth))) || ((_local9 < Math.abs(collDepth))))){ _local10 = (_local8 < _local9); collNormal = (_local10) ? _local4 : _local6; collDepth = (_local10) ? _local5 : _local7; }; _local3++; }; cpa = _arg1; cpb = _arg2; return (true); } private static function testTypes(_arg1:AbstractParticle, _arg2:AbstractParticle):Boolean{ if ((((_arg1 is RectangleParticle)) && ((_arg2 is RectangleParticle)))){ return (testOBBvsOBB((_arg1 as RectangleParticle), (_arg2 as RectangleParticle))); }; if ((((_arg1 is CircleParticle)) && ((_arg2 is CircleParticle)))){ return (testCirclevsCircle((_arg1 as CircleParticle), (_arg2 as CircleParticle))); }; if ((((_arg1 is RectangleParticle)) && ((_arg2 is CircleParticle)))){ return (testOBBvsCircle((_arg1 as RectangleParticle), (_arg2 as CircleParticle))); }; if ((((_arg1 is CircleParticle)) && ((_arg2 is RectangleParticle)))){ return (testOBBvsCircle((_arg2 as RectangleParticle), (_arg1 as CircleParticle))); }; return (false); } private static function sampVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):void{ var _local3:Number; var _local4:Number; var _local5:int; if (normVsNorm(_arg1, _arg2)){ return; }; _local3 = (1 / (_arg1.multisample + 1)); _local4 = _local3; _local5 = 0; while (_local5 <= _arg1.multisample) { _arg1.samp.setTo((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y)))); if (testTypes(_arg1, _arg2)){ CollisionResolver.resolve(cpa, cpb, collNormal, collDepth); return; }; _local4 = (_local4 + _local3); _local5++; }; } private static function testCirclevsCircle(_arg1:CircleParticle, _arg2:CircleParticle):Boolean{ var _local3:Number; var _local4:Number; var _local5:Number; _local3 = testIntervals(_arg1.getIntervalX(), _arg2.getIntervalX()); if (_local3 == 0){ return (false); }; _local4 = testIntervals(_arg1.getIntervalY(), _arg2.getIntervalY()); if (_local4 == 0){ return (false); }; collNormal = _arg1.samp.minus(_arg2.samp); _local5 = collNormal.magnitude(); collDepth = ((_arg1.radius + _arg2.radius) - _local5); if (collDepth > 0){ collNormal.divEquals(_local5); cpa = _arg1; cpb = _arg2; return (true); }; return (false); } static function test(_arg1:AbstractParticle, _arg2:AbstractParticle):void{ if (((_arg1.fixed) && (_arg2.fixed))){ return; }; if ((((_arg1.multisample == 0)) && ((_arg2.multisample == 0)))){ normVsNorm(_arg1, _arg2); } else { if ((((_arg1.multisample > 0)) && ((_arg2.multisample == 0)))){ sampVsNorm(_arg1, _arg2); } else { if ((((_arg2.multisample > 0)) && ((_arg1.multisample == 0)))){ sampVsNorm(_arg2, _arg1); } else { if (_arg1.multisample == _arg2.multisample){ sampVsSamp(_arg1, _arg2); } else { normVsNorm(_arg1, _arg2); }; }; }; }; } private static function testOBBvsCircle(_arg1:RectangleParticle, _arg2:CircleParticle):Boolean{ var _local3:Array; var _local4:int; var _local5:Number; var _local6:Vector; var _local7:Number; var _local8:Vector; var _local9:Number; collDepth = Number.POSITIVE_INFINITY; _local3 = new Array(2); _local4 = 0; while (_local4 < 2) { _local6 = _arg1.axes[_local4]; _local7 = testIntervals(_arg1.getProjection(_local6), _arg2.getProjection(_local6)); if (_local7 == 0){ return (false); }; if (Math.abs(_local7) < Math.abs(collDepth)){ collNormal = _local6; collDepth = _local7; }; _local3[_local4] = _local7; _local4++; }; _local5 = _arg2.radius; if ((((Math.abs(_local3[0]) < _local5)) && ((Math.abs(_local3[1]) < _local5)))){ _local8 = closestVertexOnOBB(_arg2.samp, _arg1); collNormal = _local8.minus(_arg2.samp); _local9 = collNormal.magnitude(); collDepth = (_local5 - _local9); if (collDepth > 0){ collNormal.divEquals(_local9); } else { return (false); }; }; cpa = _arg1; cpb = _arg2; return (true); } private static function closestVertexOnOBB(_arg1:Vector, _arg2:RectangleParticle):Vector{ var _local3:Vector; var _local4:Vector; var _local5:int; var _local6:Number; _local3 = _arg1.minus(_arg2.samp); _local4 = new Vector(_arg2.samp.x, _arg2.samp.y); _local5 = 0; while (_local5 < 2) { _local6 = _local3.dot(_arg2.axes[_local5]); if (_local6 >= 0){ _local6 = _arg2.extents[_local5]; } else { if (_local6 < 0){ _local6 = -(_arg2.extents[_local5]); }; }; _local4.plusEquals(_arg2.axes[_local5].mult(_local6)); _local5++; }; return (_local4); } private static function normVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):Boolean{ _arg1.samp.copy(_arg1.curr); _arg2.samp.copy(_arg2.curr); if (testTypes(_arg1, _arg2)){ CollisionResolver.resolve(cpa, cpb, collNormal, collDepth); return (true); }; return (false); } private static function sampVsSamp(_arg1:AbstractParticle, _arg2:AbstractParticle):void{ var _local3:Number; var _local4:Number; var _local5:int; if (normVsNorm(_arg1, _arg2)){ return; }; _local3 = (1 / (_arg1.multisample + 1)); _local4 = _local3; _local5 = 0; while (_local5 <= _arg1.multisample) { _arg1.samp.setTo((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y)))); _arg2.samp.setTo((_arg2.prev.x + (_local4 * (_arg2.curr.x - _arg2.prev.x))), (_arg2.prev.y + (_local4 * (_arg2.curr.y - _arg2.prev.y)))); if (testTypes(_arg1, _arg2)){ CollisionResolver.resolve(cpa, cpb, collNormal, collDepth); return; }; _local4 = (_local4 + _local3); _local5++; }; } } }//package org.cove.ape
Section 56
//CollisionEvent (org.cove.ape.CollisionEvent) package org.cove.ape { import flash.events.*; public class CollisionEvent extends Event { private var _collidingItem:AbstractItem; public static const COLLIDE:String = "collide"; public static const FIRST_COLLIDE:String = "firstCollide"; public function CollisionEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:AbstractItem=null){ super(_arg1, _arg2, _arg3); _collidingItem = _arg4; } public function get collidingItem():AbstractItem{ var _local1:SpringConstraintParticle; if ((_collidingItem is SpringConstraintParticle)){ _local1 = (_collidingItem as SpringConstraintParticle); return (_local1.parent); }; return (_collidingItem); } } }//package org.cove.ape
Section 57
//CollisionResolver (org.cove.ape.CollisionResolver) package org.cove.ape { import org.cove.ape.*; final class CollisionResolver { static function resolve(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:Vector, _arg4:Number):void{ var _local5:Vector; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Collision; var _local10:Collision; var _local11:Vector; var _local12:Vector; var _local13:Vector; var _local14:Vector; _local5 = _arg3.mult(_arg4); _local6 = (_arg1.elasticity + _arg2.elasticity); _local7 = (_arg1.invMass + _arg2.invMass); _local8 = MathUtil.clamp((1 - (_arg1.friction + _arg2.friction)), 0, 1); _local9 = _arg1.getComponents(_arg3); _local10 = _arg2.getComponents(_arg3); _local11 = _local10.vn.mult(((_local6 + 1) * _arg1.invMass)).plus(_local9.vn.mult((_arg2.invMass - (_local6 * _arg1.invMass)))).divEquals(_local7); _local12 = _local9.vn.mult(((_local6 + 1) * _arg2.invMass)).plus(_local10.vn.mult((_arg1.invMass - (_local6 * _arg2.invMass)))).divEquals(_local7); _local9.vt.multEquals(_local8); _local10.vt.multEquals(_local8); _local13 = _local5.mult((_arg1.invMass / _local7)); _local14 = _local5.mult((-(_arg2.invMass) / _local7)); _local11.plusEquals(_local9.vt); _local12.plusEquals(_local10.vt); _arg1.resolveCollision(_local13, _local11, _arg3, _arg4, -1, _arg2); _arg2.resolveCollision(_local14, _local12, _arg3, _arg4, 1, _arg1); } } }//package org.cove.ape
Section 58
//Composite (org.cove.ape.Composite) package org.cove.ape { public class Composite extends AbstractCollection { private var delta:Vector; public function Composite(){ delta = new Vector(); } private function getRelativeAngle(_arg1:Vector, _arg2:Vector):Number{ delta.setTo((_arg2.x - _arg1.x), (_arg2.y - _arg1.y)); return (Math.atan2(delta.y, delta.x)); } public function rotateByRadian(_arg1:Number, _arg2:Vector):void{ var _local3:AbstractParticle; var _local4:Array; var _local5:int; var _local6:int; var _local7:Number; var _local8:Number; _local4 = particles; _local5 = _local4.length; _local6 = 0; while (_local6 < _local5) { _local3 = _local4[_local6]; _local7 = _local3.center.distance(_arg2); _local8 = (getRelativeAngle(_arg2, _local3.center) + _arg1); _local3.px = ((Math.cos(_local8) * _local7) + _arg2.x); _local3.py = ((Math.sin(_local8) * _local7) + _arg2.y); _local6++; }; } public function rotateByAngle(_arg1:Number, _arg2:Vector):void{ var _local3:Number; _local3 = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY); rotateByRadian(_local3, _arg2); } public function set fixed(_arg1:Boolean):void{ var _local2:int; _local2 = 0; while (_local2 < particles.length) { particles[_local2].fixed = _arg1; _local2++; }; } public function get fixed():Boolean{ var _local1:int; _local1 = 0; while (_local1 < particles.length) { if (!particles[_local1].fixed){ return (false); }; _local1++; }; return (true); } } }//package org.cove.ape
Section 59
//Group (org.cove.ape.Group) package org.cove.ape { public class Group extends AbstractCollection { private var _collideInternal:Boolean; private var _composites:Array; private var _collisionList:Array; public function Group(_arg1:Boolean=false){ _composites = new Array(); _collisionList = new Array(); this.collideInternal = _arg1; } function checkCollisions():void{ var _local1:int; var _local2:int; var _local3:Group; if (collideInternal){ checkCollisionGroupInternal(); }; _local1 = collisionList.length; _local2 = 0; while (_local2 < _local1) { _local3 = collisionList[_local2]; if (_local3 == null){ } else { checkCollisionVsGroup(_local3); }; _local2++; }; } public function get composites():Array{ return (_composites); } override public function init():void{ var _local1:int; super.init(); _local1 = 0; while (_local1 < composites.length) { composites[_local1].init(); _local1++; }; } public function removeCollidable(_arg1:Group):void{ var _local2:int; _local2 = collisionList.indexOf(_arg1); if (_local2 == -1){ return; }; collisionList.splice(_local2, 1); } private function checkCollisionVsGroup(_arg1:Group):void{ var _local2:Composite; var _local3:int; var _local4:int; var _local5:int; var _local6:Composite; var _local7:int; checkCollisionsVsCollection(_arg1); _local3 = _composites.length; _local4 = _arg1.composites.length; _local5 = 0; while (_local5 < _local3) { _local6 = _composites[_local5]; if (_local6 == null){ } else { _local6.checkCollisionsVsCollection(_arg1); _local7 = 0; while (_local7 < _local4) { _local2 = _arg1.composites[_local7]; if (_local2 == null){ } else { _local6.checkCollisionsVsCollection(_local2); }; _local7++; }; }; _local5++; }; _local7 = 0; while (_local7 < _local4) { _local2 = _arg1.composites[_local7]; if (_local2 == null){ } else { checkCollisionsVsCollection(_local2); }; _local7++; }; } override function satisfyConstraints():void{ var _local1:int; var _local2:int; var _local3:Composite; super.satisfyConstraints(); _local1 = _composites.length; _local2 = 0; while (_local2 < _local1) { _local3 = _composites[_local2]; _local3.satisfyConstraints(); _local2++; }; } public function get collideInternal():Boolean{ return (_collideInternal); } public function addCollidableList(_arg1:Array):void{ var _local2:int; var _local3:Group; _local2 = 0; while (_local2 < _arg1.length) { _local3 = _arg1[_local2]; collisionList.push(_local3); _local2++; }; } public function removeComposite(_arg1:Composite):void{ var _local2:int; _local2 = composites.indexOf(_arg1); if (_local2 == -1){ return; }; composites.splice(_local2, 1); _arg1.isParented = false; _arg1.cleanup(); } override public function cleanup():void{ var _local1:int; super.cleanup(); _local1 = 0; while (_local1 < composites.length) { composites[_local1].cleanup(); _local1++; }; } override public function paint():void{ var _local1:int; var _local2:int; var _local3:Composite; super.paint(); _local1 = _composites.length; _local2 = 0; while (_local2 < _local1) { _local3 = _composites[_local2]; _local3.paint(); _local2++; }; } public function addCollidable(_arg1:Group):void{ collisionList.push(_arg1); } override public function getAll():Array{ return (particles.concat(constraints).concat(composites)); } public function get collisionList():Array{ return (_collisionList); } override function integrate(_arg1:Number):void{ var _local2:int; var _local3:int; var _local4:Composite; super.integrate(_arg1); _local2 = _composites.length; _local3 = 0; while (_local3 < _local2) { _local4 = _composites[_local3]; _local4.integrate(_arg1); _local3++; }; } public function addComposite(_arg1:Composite):void{ composites.push(_arg1); _arg1.isParented = true; if (isParented){ _arg1.init(); }; } private function checkCollisionGroupInternal():void{ var _local1:int; var _local2:int; var _local3:Composite; var _local4:int; var _local5:Composite; checkInternalCollisions(); _local1 = _composites.length; _local2 = 0; while (_local2 < _local1) { _local3 = _composites[_local2]; if (_local3 == null){ } else { _local3.checkCollisionsVsCollection(this); _local4 = (_local2 + 1); while (_local4 < _local1) { _local5 = _composites[_local4]; if (_local5 != null){ _local3.checkCollisionsVsCollection(_local5); }; _local4++; }; }; _local2++; }; } public function set collideInternal(_arg1:Boolean):void{ _collideInternal = _arg1; } } }//package org.cove.ape
Section 60
//IForce (org.cove.ape.IForce) package org.cove.ape { public interface IForce { function getValue(_arg1:Number):Vector; } }//package org.cove.ape
Section 61
//Interval (org.cove.ape.Interval) package org.cove.ape { final class Interval { var min:Number; var max:Number; function Interval(_arg1:Number, _arg2:Number){ this.min = _arg1; this.max = _arg2; } function toString():String{ return (((min + " : ") + max)); } } }//package org.cove.ape
Section 62
//MathUtil (org.cove.ape.MathUtil) package org.cove.ape { final class MathUtil { static var ONE_EIGHTY_OVER_PI:Number = 57.2957795130823; static var PI_OVER_ONE_EIGHTY:Number = 0.0174532925199433; static function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{ if (_arg1 < _arg2){ return (_arg2); }; if (_arg1 > _arg3){ return (_arg3); }; return (_arg1); } static function sign(_arg1:Number):int{ if (_arg1 < 0){ return (-1); }; return (1); } } }//package org.cove.ape
Section 63
//RectangleParticle (org.cove.ape.RectangleParticle) package org.cove.ape { public class RectangleParticle extends AbstractParticle { private var _axes:Array; private var _extents:Array; private var _radian:Number; public function RectangleParticle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Boolean=false, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){ super(_arg1, _arg2, _arg6, _arg7, _arg8, _arg9); _extents = new Array((_arg3 / 2), (_arg4 / 2)); _axes = new Array(new Vector(0, 0), new Vector(0, 0)); radian = _arg5; } function getProjection(_arg1:Vector):Interval{ var _local2:Number; var _local3:Number; _local2 = ((extents[0] * Math.abs(_arg1.dot(axes[0]))) + (extents[1] * Math.abs(_arg1.dot(axes[1])))); _local3 = samp.dot(_arg1); interval.min = (_local3 - _local2); interval.max = (_local3 + _local2); return (interval); } override public function init():void{ var _local1:Number; var _local2:Number; cleanup(); if (displayObject != null){ initDisplay(); } else { _local1 = (extents[0] * 2); _local2 = (extents[1] * 2); sprite.graphics.clear(); sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha); sprite.graphics.beginFill(fillColor, fillAlpha); sprite.graphics.drawRect((-(_local1) / 2), (-(_local2) / 2), _local1, _local2); sprite.graphics.endFill(); }; paint(); } public function set width(_arg1:Number):void{ _extents[0] = (_arg1 / 2); } function get extents():Array{ return (_extents); } function get axes():Array{ return (_axes); } public function get height():Number{ return ((_extents[1] * 2)); } private function setAxes(_arg1:Number):void{ var _local2:Number; var _local3:Number; _local2 = Math.sin(_arg1); _local3 = Math.cos(_arg1); axes[0].x = _local3; axes[0].y = _local2; axes[1].x = -(_local2); axes[1].y = _local3; } public function get radian():Number{ return (_radian); } public function set angle(_arg1:Number):void{ radian = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY); } public function set height(_arg1:Number):void{ _extents[1] = (_arg1 / 2); } public function get angle():Number{ return ((radian * MathUtil.ONE_EIGHTY_OVER_PI)); } public function set radian(_arg1:Number):void{ _radian = _arg1; setAxes(_arg1); } override public function paint():void{ sprite.x = curr.x; sprite.y = curr.y; sprite.rotation = angle; } public function get width():Number{ return ((_extents[0] * 2)); } } }//package org.cove.ape
Section 64
//RimParticle (org.cove.ape.RimParticle) package org.cove.ape { import org.cove.ape.*; class RimParticle { private var maxTorque:Number; var curr:Vector; var prev:Vector; private var av:Number; private var wr:Number; private var sp:Number; function RimParticle(_arg1:Number, _arg2:Number){ curr = new Vector(_arg1, 0); prev = new Vector(0, 0); sp = 0; av = 0; maxTorque = _arg2; wr = _arg1; } function update(_arg1:Number):void{ var _local2:Number; var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; sp = Math.max(-(maxTorque), Math.min(maxTorque, (sp + av))); _local2 = -(curr.y); _local3 = curr.x; _local4 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3))); _local2 = (_local2 / _local4); _local3 = (_local3 / _local4); curr.x = (curr.x + (sp * _local2)); curr.y = (curr.y + (sp * _local3)); _local5 = prev.x; _local6 = prev.y; _local7 = (prev.x = curr.x); _local8 = (prev.y = curr.y); curr.x = (curr.x + (APEngine.damping * (_local7 - _local5))); curr.y = (curr.y + (APEngine.damping * (_local8 - _local6))); _local9 = Math.sqrt(((curr.x * curr.x) + (curr.y * curr.y))); _local10 = ((_local9 - wr) / _local9); curr.x = (curr.x - (curr.x * _local10)); curr.y = (curr.y - (curr.y * _local10)); } function set speed(_arg1:Number):void{ sp = _arg1; } function get angularVelocity():Number{ return (av); } function set angularVelocity(_arg1:Number):void{ av = _arg1; } function get speed():Number{ return (sp); } } }//package org.cove.ape
Section 65
//SpringConstraint (org.cove.ape.SpringConstraint) package org.cove.ape { import flash.display.*; public class SpringConstraint extends AbstractConstraint { private var _collidable:Boolean; private var p1:AbstractParticle; private var p2:AbstractParticle; private var _scp:SpringConstraintParticle; private var _restLength:Number; public function SpringConstraint(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:Number=0.5, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=1, _arg7:Boolean=false){ super(_arg3); this.p1 = _arg1; this.p2 = _arg2; checkParticlesLocation(); _restLength = currLength; setCollidable(_arg4, _arg5, _arg6, _arg7); } public function get fixed():Boolean{ return (((p1.fixed) && (p2.fixed))); } public function set rectScale(_arg1:Number):void{ if (scp == null){ return; }; scp.rectScale = _arg1; } override public function init():void{ cleanup(); if (collidable){ scp.init(); } else { if (displayObject != null){ initDisplay(); }; }; paint(); } function initDisplay():void{ if (collidable){ scp.initDisplay(); } else { displayObject.x = displayObjectOffset.x; displayObject.y = displayObjectOffset.y; displayObject.rotation = displayObjectRotation; sprite.addChild(displayObject); }; } public function isConnectedTo(_arg1:AbstractParticle):Boolean{ return ((((_arg1 == p1)) || ((_arg1 == p2)))); } public function setDisplay(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{ if (collidable){ scp.setDisplay(_arg1, _arg2, _arg3, _arg4); } else { displayObject = _arg1; displayObjectRotation = _arg4; displayObjectOffset = new Vector(_arg2, _arg3); }; } function get scp():SpringConstraintParticle{ return (_scp); } private function checkParticlesLocation():void{ if ((((p1.curr.x == p2.curr.x)) && ((p1.curr.y == p2.curr.y)))){ p2.curr.x = (p2.curr.x + 0.0001); }; } public function get radian():Number{ var _local1:Vector; _local1 = delta; return (Math.atan2(_local1.y, _local1.x)); } public function get rectHeight():Number{ return (scp.rectHeight); } public function set restLength(_arg1:Number):void{ if (_arg1 <= 0){ throw (new ArgumentError("restLength must be greater than 0")); }; _restLength = _arg1; } public function get currLength():Number{ return (p1.curr.distance(p2.curr)); } public function get fixedEndLimit():Number{ return (scp.fixedEndLimit); } function get delta():Vector{ return (p1.curr.minus(p2.curr)); } public function get angle():Number{ return ((radian * MathUtil.ONE_EIGHTY_OVER_PI)); } public function get center():Vector{ return (p1.curr.plus(p2.curr).divEquals(2)); } public function set rectHeight(_arg1:Number):void{ if (scp == null){ return; }; scp.rectHeight = _arg1; } public function setCollidable(_arg1:Boolean, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{ _collidable = _arg1; _scp = null; if (_collidable){ _scp = new SpringConstraintParticle(p1, p2, this, _arg2, _arg3, _arg4); }; } override public function paint():void{ var _local1:Vector; if (collidable){ scp.paint(); } else { if (displayObject != null){ _local1 = center; sprite.x = _local1.x; sprite.y = _local1.y; sprite.rotation = angle; } else { sprite.graphics.clear(); sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha); sprite.graphics.moveTo(p1.px, p1.py); sprite.graphics.lineTo(p2.px, p2.py); }; }; } public function get rectScale():Number{ return (scp.rectScale); } public function get restLength():Number{ return (_restLength); } override public function resolve():void{ var _local1:Number; var _local2:Number; var _local3:Vector; if (((p1.fixed) && (p2.fixed))){ return; }; _local1 = currLength; _local2 = ((_local1 - restLength) / (_local1 * (p1.invMass + p2.invMass))); _local3 = delta.mult((_local2 * stiffness)); p1.curr.minusEquals(_local3.mult(p1.invMass)); p2.curr.plusEquals(_local3.mult(p2.invMass)); } public function get collidable():Boolean{ return (_collidable); } public function set fixedEndLimit(_arg1:Number):void{ if (scp == null){ return; }; scp.fixedEndLimit = _arg1; } } }//package org.cove.ape
Section 66
//SpringConstraintParticle (org.cove.ape.SpringConstraintParticle) package org.cove.ape { import flash.display.*; import org.cove.ape.*; class SpringConstraintParticle extends RectangleParticle { private var _fixedEndLimit:Number; private var rca:Vector; private var rcb:Vector; private var _rectScale:Number; private var s:Number; var parent:SpringConstraint; private var scaleToLength:Boolean; private var p1:AbstractParticle; private var p2:AbstractParticle; private var lambda:Vector; private var avgVelocity:Vector; private var _rectHeight:Number; function SpringConstraintParticle(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:SpringConstraint, _arg4:Number, _arg5:Number, _arg6:Boolean){ super(0, 0, 0, 0, 0, false); this.p1 = _arg1; this.p2 = _arg2; lambda = new Vector(0, 0); avgVelocity = new Vector(0, 0); parent = _arg3; this.rectScale = _arg5; this.rectHeight = _arg4; this.scaleToLength = _arg6; fixedEndLimit = 0; rca = new Vector(); rcb = new Vector(); } private function setCorners(_arg1:RectangleParticle, _arg2:int):void{ var _local3:Number; var _local4:Number; var _local5:Array; var _local6:Array; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; _local3 = _arg1.curr.x; _local4 = _arg1.curr.y; _local5 = _arg1.axes; _local6 = _arg1.extents; _local7 = (_local5[0].x * _local6[0]); _local8 = (_local5[0].y * _local6[0]); _local9 = (_local5[1].x * _local6[1]); _local10 = (_local5[1].y * _local6[1]); _local11 = (_local7 - _local9); _local12 = (_local8 - _local10); _local13 = (_local7 + _local9); _local14 = (_local8 + _local10); if (_arg2 == 0){ rca.x = (_local3 - _local13); rca.y = (_local4 - _local14); rcb.x = (_local3 + _local11); rcb.y = (_local4 + _local12); } else { if (_arg2 == 1){ rca.x = (_local3 + _local11); rca.y = (_local4 + _local12); rcb.x = (_local3 + _local13); rcb.y = (_local4 + _local14); } else { if (_arg2 == 2){ rca.x = (_local3 + _local13); rca.y = (_local4 + _local14); rcb.x = (_local3 - _local11); rcb.y = (_local4 - _local12); } else { if (_arg2 == 3){ rca.x = (_local3 - _local11); rca.y = (_local4 - _local12); rcb.x = (_local3 - _local13); rcb.y = (_local4 - _local14); }; }; }; }; } override public function init():void{ var _local1:Sprite; var _local2:Number; var _local3:Number; if (displayObject != null){ initDisplay(); } else { _local1 = new Sprite(); parent.sprite.addChild(_local1); _local1.name = "inner"; _local2 = (parent.currLength * rectScale); _local3 = rectHeight; _local1.graphics.clear(); _local1.graphics.lineStyle(parent.lineThickness, parent.lineColor, parent.lineAlpha); _local1.graphics.beginFill(parent.fillColor, parent.fillAlpha); _local1.graphics.drawRect((-(_local2) / 2), (-(_local3) / 2), _local2, _local3); _local1.graphics.endFill(); }; paint(); } function updatePosition():void{ var _local1:Vector; _local1 = parent.center; curr.setTo(_local1.x, _local1.y); width = (scaleToLength) ? (parent.currLength * rectScale) : (parent.restLength * rectScale); height = rectHeight; radian = parent.radian; } private function closestPtSegmentSegment():Number{ var _local1:Vector; var _local2:Vector; var _local3:Vector; var _local4:Vector; var _local5:Vector; var _local6:Vector; var _local7:Vector; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Vector; var _local16:Vector; var _local17:Vector; _local1 = p1.curr; _local2 = p2.curr; _local3 = rca; _local4 = rcb; _local5 = _local2.minus(_local1); _local6 = _local4.minus(_local3); _local7 = _local1.minus(_local3); _local9 = _local5.dot(_local5); _local10 = _local6.dot(_local6); _local11 = _local6.dot(_local7); _local12 = _local5.dot(_local7); _local13 = _local5.dot(_local6); _local14 = ((_local9 * _local10) - (_local13 * _local13)); if (_local14 != 0){ s = MathUtil.clamp((((_local13 * _local11) - (_local12 * _local10)) / _local14), 0, 1); } else { s = 0.5; }; _local8 = (((_local13 * s) + _local11) / _local10); if (_local8 < 0){ _local8 = 0; s = MathUtil.clamp((-(_local12) / _local9), 0, 1); } else { if (_local8 > 0){ _local8 = 1; s = MathUtil.clamp(((_local13 - _local12) / _local9), 0, 1); }; }; _local15 = _local1.plus(_local5.mult(s)); _local16 = _local3.plus(_local6.mult(_local8)); _local17 = _local15.minus(_local16); return (_local15.minus(_local16).dot(_local17)); } function get rectHeight():Number{ return (_rectHeight); } function get fixedEndLimit():Number{ return (_fixedEndLimit); } private function closestParamPoint(_arg1:Vector):Number{ var _local2:Vector; var _local3:Number; _local2 = p2.curr.minus(p1.curr); _local3 = (_local2.dot(_arg1.minus(p1.curr)) / _local2.dot(_local2)); return (MathUtil.clamp(_local3, 0, 1)); } override public function paint():void{ var _local1:Vector; var _local2:Sprite; _local1 = parent.center; _local2 = parent.sprite; if (scaleToLength){ _local2.getChildByName("inner").width = (parent.currLength * rectScale); } else { if (displayObject != null){ _local2.getChildByName("inner").width = (parent.restLength * rectScale); }; }; _local2.x = _local1.x; _local2.y = _local1.y; _local2.rotation = parent.angle; } function set rectHeight(_arg1:Number):void{ _rectHeight = _arg1; } private function getContactPointParam(_arg1:AbstractParticle):Number{ var _local2:Number; var _local3:Number; var _local4:Array; var _local5:Number; var _local6:int; var _local7:Number; if ((_arg1 is CircleParticle)){ _local2 = closestParamPoint(_arg1.curr); } else { if ((_arg1 is RectangleParticle)){ _local4 = new Array(4); _local5 = Number.POSITIVE_INFINITY; _local6 = 0; while (_local6 < 4) { setCorners((_arg1 as RectangleParticle), _local6); _local7 = closestPtSegmentSegment(); if (_local7 < _local5){ _local5 = _local7; _local3 = _local6; _local4[_local6] = s; }; _local6++; }; _local2 = _local4[_local3]; }; }; return (_local2); } function set fixedEndLimit(_arg1:Number):void{ _fixedEndLimit = _arg1; } override public function get fixed():Boolean{ return (parent.fixed); } override function get invMass():Number{ if (((p1.fixed) && (p2.fixed))){ return (0); }; return ((1 / ((p1.mass + p2.mass) / 2))); } override function initDisplay():void{ var _local1:Sprite; displayObject.x = displayObjectOffset.x; displayObject.y = displayObjectOffset.y; displayObject.rotation = displayObjectRotation; _local1 = new Sprite(); _local1.name = "inner"; _local1.addChild(displayObject); parent.sprite.addChild(_local1); } function set rectScale(_arg1:Number):void{ _rectScale = _arg1; } override function resolveCollision(_arg1:Vector, _arg2:Vector, _arg3:Vector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{ var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:AbstractParticle; testParticleEvents(_arg6); if (((fixed) || (!(_arg6.solid)))){ return; }; _local7 = getContactPointParam(_arg6); _local8 = (1 - _local7); _local9 = _local7; if (p1.fixed){ if (_local9 <= fixedEndLimit){ return; }; lambda.setTo((_arg1.x / _local9), (_arg1.y / _local9)); p2.curr.plusEquals(lambda); p2.velocity = _arg2; } else { if (p2.fixed){ if (_local8 <= fixedEndLimit){ return; }; lambda.setTo((_arg1.x / _local8), (_arg1.y / _local8)); p1.curr.plusEquals(lambda); p1.velocity = _arg2; } else { _local10 = ((_local8 * _local8) + (_local9 * _local9)); if (_local10 == 0){ return; }; lambda.setTo((_arg1.x / _local10), (_arg1.y / _local10)); p1.curr.plusEquals(lambda.mult(_local8)); p2.curr.plusEquals(lambda.mult(_local9)); if (_local7 == 0.5){ p1.velocity = _arg2; p2.velocity = _arg2; } else { _local11 = ((_local7)<0.5) ? p1 : p2; _local11.velocity = _arg2; }; }; }; } override public function get elasticity():Number{ return (((p1.elasticity + p2.elasticity) / 2)); } function get rectScale():Number{ return (_rectScale); } override public function get velocity():Vector{ var _local1:Vector; var _local2:Vector; _local1 = p1.velocity; _local2 = p2.velocity; avgVelocity.setTo(((_local1.x + _local2.x) / 2), ((_local1.y + _local2.y) / 2)); return (avgVelocity); } override public function get mass():Number{ return (((p1.mass + p2.mass) / 2)); } override public function get friction():Number{ return (((p1.friction + p2.friction) / 2)); } } }//package org.cove.ape
Section 67
//Vector (org.cove.ape.Vector) package org.cove.ape { public class Vector { public var x:Number; public var y:Number; public function Vector(_arg1:Number=0, _arg2:Number=0){ x = _arg1; y = _arg2; } public function cross(_arg1:Vector):Number{ return (((x * _arg1.y) - (y * _arg1.x))); } public function magnitude():Number{ return (Math.sqrt(((x * x) + (y * y)))); } public function divEquals(_arg1:Number):Vector{ if (_arg1 == 0){ _arg1 = 0.0001; }; x = (x / _arg1); y = (y / _arg1); return (this); } public function times(_arg1:Vector):Vector{ return (new Vector((x * _arg1.x), (y * _arg1.y))); } public function plusEquals(_arg1:Vector):Vector{ x = (x + _arg1.x); y = (y + _arg1.y); return (this); } public function dot(_arg1:Vector):Number{ return (((x * _arg1.x) + (y * _arg1.y))); } public function normalizeEquals():Vector{ var _local1:Number; _local1 = magnitude(); if (_local1 == 0){ _local1 = 0.0001; }; return (multEquals((1 / _local1))); } public function normalize():Vector{ var _local1:Number; _local1 = magnitude(); if (_local1 == 0){ _local1 = 0.0001; }; return (mult((1 / _local1))); } public function copy(_arg1:Vector):void{ x = _arg1.x; y = _arg1.y; } public function minusEquals(_arg1:Vector):Vector{ x = (x - _arg1.x); y = (y - _arg1.y); return (this); } public function minus(_arg1:Vector):Vector{ return (new Vector((x - _arg1.x), (y - _arg1.y))); } public function plus(_arg1:Vector):Vector{ return (new Vector((x + _arg1.x), (y + _arg1.y))); } public function toString():String{ return (((x + " : ") + y)); } public function distance(_arg1:Vector):Number{ var _local2:Vector; _local2 = this.minus(_arg1); return (_local2.magnitude()); } public function setTo(_arg1:Number, _arg2:Number):void{ x = _arg1; y = _arg2; } public function multEquals(_arg1:Number):Vector{ x = (x * _arg1); y = (y * _arg1); return (this); } public function mult(_arg1:Number):Vector{ return (new Vector((x * _arg1), (y * _arg1))); } } }//package org.cove.ape
Section 68
//VectorForce (org.cove.ape.VectorForce) package org.cove.ape { public class VectorForce implements IForce { private var fvx:Number; private var fvy:Number; private var value:Vector; private var scaleMass:Boolean; public function VectorForce(_arg1:Boolean, _arg2:Number, _arg3:Number){ fvx = _arg2; fvy = _arg3; scaleMass = _arg1; value = new Vector(_arg2, _arg3); } public function set vx(_arg1:Number):void{ fvx = _arg1; value.x = _arg1; } public function set vy(_arg1:Number):void{ fvy = _arg1; value.y = _arg1; } public function set useMass(_arg1:Boolean):void{ scaleMass = _arg1; } public function getValue(_arg1:Number):Vector{ if (scaleMass){ value.setTo((fvx * _arg1), (fvy * _arg1)); }; return (value); } } }//package org.cove.ape
Section 69
//WheelParticle (org.cove.ape.WheelParticle) package org.cove.ape { public class WheelParticle extends CircleParticle { private var normSlip:Vector; private var rp:RimParticle; private var _traction:Number; private var tan:Vector; private var orientation:Vector; public function WheelParticle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=0.3, _arg7:Number=0, _arg8:Number=1){ super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7); tan = new Vector(0, 0); normSlip = new Vector(0, 0); rp = new RimParticle(_arg3, 2); this.traction = _arg8; orientation = new Vector(); } override public function init():void{ cleanup(); if (displayObject != null){ initDisplay(); } else { sprite.graphics.clear(); sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha); sprite.graphics.beginFill(fillColor, fillAlpha); sprite.graphics.drawCircle(0, 0, radius); sprite.graphics.endFill(); sprite.graphics.moveTo(-(radius), 0); sprite.graphics.lineTo(radius, 0); sprite.graphics.moveTo(0, -(radius)); sprite.graphics.lineTo(0, radius); }; paint(); } public function get radian():Number{ orientation.setTo(rp.curr.x, rp.curr.y); return ((Math.atan2(orientation.y, orientation.x) + Math.PI)); } public function get traction():Number{ return ((1 - _traction)); } public function get speed():Number{ return (rp.speed); } override public function paint():void{ sprite.x = curr.x; sprite.y = curr.y; sprite.rotation = angle; } public function set traction(_arg1:Number):void{ _traction = (1 - _arg1); } public function set speed(_arg1:Number):void{ rp.speed = _arg1; } override function resolveCollision(_arg1:Vector, _arg2:Vector, _arg3:Vector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{ super.resolveCollision(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); resolve(_arg3.mult(MathUtil.sign((_arg4 * _arg5)))); } public function set angularVelocity(_arg1:Number):void{ rp.angularVelocity = _arg1; } override public function update(_arg1:Number):void{ super.update(_arg1); rp.update(_arg1); } public function get angle():Number{ return ((radian * MathUtil.ONE_EIGHTY_OVER_PI)); } public function get angularVelocity():Number{ return (rp.angularVelocity); } private function resolve(_arg1:Vector):void{ var _local2:Vector; var _local3:Vector; var _local4:Number; var _local5:Number; tan.setTo(-(rp.curr.y), rp.curr.x); tan = tan.normalize(); _local2 = tan.mult(rp.speed); _local3 = velocity.plusEquals(_local2); _local4 = _local3.cross(_arg1); tan.multEquals(_local4); rp.prev.copy(rp.curr.minus(tan)); _local5 = ((1 - _traction) * rp.speed); normSlip.setTo((_local5 * _arg1.y), (_local5 * _arg1.x)); curr.plusEquals(normSlip); rp.speed = (rp.speed * _traction); } } }//package org.cove.ape
Section 70
//HexcelleFont (HexcelleFont) package { import flash.text.*; public dynamic class HexcelleFont extends Font { } }//package
Section 71
//IntroMusic (IntroMusic) package { import flash.media.*; public dynamic class IntroMusic extends Sound { } }//package
Section 72
//MainFont (MainFont) package { import flash.text.*; public dynamic class MainFont extends Font { } }//package
Section 73
//MainMusic (MainMusic) package { import flash.media.*; public dynamic class MainMusic extends Sound { } }//package
Section 74
//SoundAddNewHex (SoundAddNewHex) package { import flash.media.*; public dynamic class SoundAddNewHex extends Sound { } }//package
Section 75
//SoundBomb (SoundBomb) package { import flash.media.*; public dynamic class SoundBomb extends Sound { } }//package
Section 76
//SoundBombBig (SoundBombBig) package { import flash.media.*; public dynamic class SoundBombBig extends Sound { } }//package
Section 77
//SoundBombNormal (SoundBombNormal) package { import flash.media.*; public dynamic class SoundBombNormal extends Sound { } }//package
Section 78
//SoundBombSmall (SoundBombSmall) package { import flash.media.*; public dynamic class SoundBombSmall extends Sound { } }//package
Section 79
//SoundCheckpoint (SoundCheckpoint) package { import flash.media.*; public dynamic class SoundCheckpoint extends Sound { } }//package
Section 80
//SoundCoreDestroy (SoundCoreDestroy) package { import flash.media.*; public dynamic class SoundCoreDestroy extends Sound { } }//package
Section 81
//SoundDeath (SoundDeath) package { import flash.media.*; public dynamic class SoundDeath extends Sound { } }//package
Section 82
//SoundError (SoundError) package { import flash.media.*; public dynamic class SoundError extends Sound { } }//package
Section 83
//SoundEvolve (SoundEvolve) package { import flash.media.*; public dynamic class SoundEvolve extends Sound { } }//package
Section 84
//SoundFaun (SoundFaun) package { import flash.media.*; public dynamic class SoundFaun extends Sound { } }//package
Section 85
//SoundFoodFaun (SoundFoodFaun) package { import flash.media.*; public dynamic class SoundFoodFaun extends Sound { } }//package
Section 86
//SoundFoodHex (SoundFoodHex) package { import flash.media.*; public dynamic class SoundFoodHex extends Sound { } }//package
Section 87
//SoundHexLost (SoundHexLost) package { import flash.media.*; public dynamic class SoundHexLost extends Sound { } }//package
Section 88
//SoundHit (SoundHit) package { import flash.media.*; public dynamic class SoundHit extends Sound { } }//package
Section 89
//SoundKill (SoundKill) package { import flash.media.*; public dynamic class SoundKill extends Sound { } }//package
Section 90
//SoundMissile (SoundMissile) package { import flash.media.*; public dynamic class SoundMissile extends Sound { } }//package
Section 91
//SoundNewArea (SoundNewArea) package { import flash.media.*; public dynamic class SoundNewArea extends Sound { } }//package
Section 92
//SoundPulse (SoundPulse) package { import flash.media.*; public dynamic class SoundPulse extends Sound { } }//package
Section 93
//SoundUI (SoundUI) package { import flash.media.*; public dynamic class SoundUI extends Sound { } }//package

Library Items

Symbol 1 Font {MainFont}Used by:7
Symbol 2 Font {HexcelleFont}Used by:6 7 8
Symbol 3 GraphicUsed by:4
Symbol 4 MovieClipUses:3Used by:Timeline
Symbol 5 GraphicUsed by:Timeline
Symbol 6 TextUses:2Used by:Timeline
Symbol 7 EditableTextUses:1 2Used by:Timeline
Symbol 8 TextUses:2Used by:Timeline
Symbol 9 GraphicUsed by:12
Symbol 10 Sound {MainMusic}Used by:12
Symbol 11 Sound {IntroMusic}Used by:12
Symbol 12 MovieClip {hexcelle_fla.MusicContainer_2}Uses:9 10 11Used by:Timeline
Symbol 13 GraphicUsed by:34
Symbol 14 Sound {SoundUI}Used by:34
Symbol 15 Sound {SoundPulse}Used by:34
Symbol 16 Sound {SoundMissile}Used by:34
Symbol 17 Sound {SoundHit}Used by:34
Symbol 18 Sound {SoundFaun}Used by:34
Symbol 19 Sound {SoundCheckpoint}Used by:34
Symbol 20 Sound {SoundCoreDestroy}Used by:34
Symbol 21 Sound {SoundDeath}Used by:34
Symbol 22 Sound {SoundBomb}Used by:34
Symbol 23 Sound {SoundAddNewHex}Used by:34
Symbol 24 Sound {SoundNewArea}Used by:34
Symbol 25 Sound {SoundError}Used by:34
Symbol 26 Sound {SoundKill}Used by:34
Symbol 27 Sound {SoundHexLost}Used by:34
Symbol 28 Sound {SoundFoodHex}Used by:34
Symbol 29 Sound {SoundFoodFaun}Used by:34
Symbol 30 Sound {SoundEvolve}Used by:34
Symbol 31 Sound {SoundBombSmall}Used by:34
Symbol 32 Sound {SoundBombNormal}Used by:34
Symbol 33 Sound {SoundBombBig}Used by:34
Symbol 34 MovieClip {hexcelle_fla.SoundContainer_3}Uses:13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33Used by:Timeline

Instance Names

"hexMask"Frame 1Symbol 4 MovieClip
"output"Frame 1Symbol 7 EditableText

Special Tags

FileAttributes (69)Timeline Frame 1Access local files only, Metadata not present, AS3.




http://swfchan.com/28/137608/info.shtml
Created: 8/2 -2019 19:41:33 Last modified: 8/2 -2019 19:41:33 Server time: 03/05 -2024 10:51:05