home *** CD-ROM | disk | FTP | other *** search
- package
- {
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.geom.ColorTransform;
-
- public class Tile extends Sprite
- {
-
- private static var TunnelGfx1:Class = Tile_TunnelGfx1;
-
- private static var TunnelGfx2:Class = Tile_TunnelGfx2;
-
- private static var RimGfx:Class = Tile_RimGfx;
-
- private static var TunnelGfx3:Class = Tile_TunnelGfx3;
-
- private static var TunnelGfx4:Class = Tile_TunnelGfx4;
-
- private static var TileGfx:Class = Tile_TileGfx;
-
- public static const COLORS:Array = [null,new ColorTransform(1,0,0),new ColorTransform(0.3,0.3,1),new ColorTransform(0.2,0.9,0.2),new ColorTransform(1,1,0)];
-
- private static var TunnelGfx:Class = Tile_TunnelGfx;
-
- private static var CenterGfx:Class = Tile_CenterGfx;
-
-
- public var startSlot:Slot;
-
- private var nTunnel:Sprite;
-
- public var locked:Boolean;
-
- public var slot:Slot;
-
- private var nwTunnel:Sprite;
-
- private var rim:MovieClip;
-
- public var swLight:MovieClip;
-
- public var neLight:MovieClip;
-
- private var background:Sprite;
-
- public var ne:int;
-
- private var sTunnel:Sprite;
-
- public var nw:int;
-
- public var nwLight:MovieClip;
-
- public var nLight:MovieClip;
-
- public var se:int;
-
- private var center:Sprite;
-
- private var seTunnel:Sprite;
-
- public var confirmed:Boolean;
-
- public var seLight:MovieClip;
-
- public var sLight:MovieClip;
-
- public var sw:int;
-
- private var swTunnel:Sprite;
-
- public var n:int;
-
- public var s:int;
-
- public var homeSlot:Slot;
-
- private var neTunnel:Sprite;
-
- public function Tile(param1:Slot)
- {
- super();
- mouseChildren = false;
- this.slot = param1;
- homeSlot = param1;
- startSlot = param1;
- if(param1)
- {
- param1.tile = this;
- snapToSlot();
- }
- background = new TileGfx() as Sprite;
- addChild(background);
- locked = false;
- confirmed = false;
- rim = new RimGfx() as MovieClip;
- addChild(rim);
- rim.stop();
- rim.addFrameScript(0,stopRim);
- }
-
- public static function getTileGhost() : Sprite
- {
- var _loc1_:Sprite = new Sprite();
- var _loc2_:Sprite = new RimGfx() as Sprite;
- while(_loc2_.numChildren)
- {
- _loc1_.addChild(_loc2_.getChildAt(0));
- }
- _loc1_.transform.colorTransform = new ColorTransform(0,0,0,0.7,255,255,255);
- return _loc1_;
- }
-
- public static function getTunnelGhost() : Sprite
- {
- var _loc1_:MovieClip = null;
- var _loc2_:Sprite = new Sprite();
- var _loc3_:Sprite = new TunnelGfx() as Sprite;
- _loc1_ = _loc3_.getChildByName("light") as MovieClip;
- _loc1_.stop();
- _loc2_.addChild(_loc3_);
- var _loc4_:Sprite;
- _loc1_ = (_loc4_ = new TunnelGfx() as Sprite).getChildByName("light") as MovieClip;
- _loc1_.stop();
- _loc4_.rotation = 180;
- _loc4_.y = 86;
- _loc2_.addChild(_loc4_);
- _loc2_.alpha = 0.2;
- _loc2_.mouseEnabled = false;
- _loc2_.mouseChildren = false;
- return _loc2_;
- }
-
- public static function colorRGB(param1:int, param2:Number = 1) : uint
- {
- var _loc3_:ColorTransform = COLORS[param1];
- var _loc4_:uint = uint(_loc3_.redMultiplier * param2 * 255 << 16);
- var _loc5_:uint = uint(_loc3_.greenMultiplier * param2 * 255 << 8);
- var _loc6_:uint = _loc3_.blueMultiplier * param2 * 255;
- return _loc4_ + _loc5_ + _loc6_;
- }
-
- private function addSETunnel(param1:int) : void
- {
- if(seTunnel)
- {
- return;
- }
- seTunnel = addTunnel(param1,-60);
- seLight = seTunnel.getChildByName("light") as MovieClip;
- seLight.stop();
- seLight.addFrameScript(seLight.totalFrames - 1,seLightLoop);
- }
-
- private function removeNETunnel() : void
- {
- if(!neTunnel)
- {
- return;
- }
- neLight.stop();
- removeChild(neTunnel);
- neTunnel = null;
- neLight = null;
- ne = 0;
- checkRemoveCenter();
- }
-
- private function nLightLoop() : void
- {
- nLight.gotoAndPlay(2);
- }
-
- public function unconfirm() : void
- {
- confirmed = false;
- rim.alpha = 1;
- background.alpha = 1;
- }
-
- private function addNTunnel(param1:int) : void
- {
- if(nTunnel)
- {
- return;
- }
- nTunnel = addTunnel(param1,180);
- nLight = nTunnel.getChildByName("light") as MovieClip;
- nLight.stop();
- nLight.addFrameScript(nLight.totalFrames - 1,nLightLoop);
- }
-
- private function removeSTunnel() : void
- {
- if(!sTunnel)
- {
- return;
- }
- sLight.stop();
- removeChild(sTunnel);
- sTunnel = null;
- sLight = null;
- s = 0;
- checkRemoveCenter();
- }
-
- private function nwLightLoop() : void
- {
- nwLight.gotoAndPlay(2);
- }
-
- public function snapToSlot() : void
- {
- x = slot.x;
- y = slot.y;
- }
-
- private function addSWTunnel(param1:int) : void
- {
- if(swTunnel)
- {
- return;
- }
- swTunnel = addTunnel(param1,60);
- swLight = swTunnel.getChildByName("light") as MovieClip;
- swLight.stop();
- swLight.addFrameScript(swLight.totalFrames - 1,swLightLoop);
- }
-
- public function checkNeighbours() : void
- {
- var _loc1_:Tile = null;
- if(slot.n)
- {
- _loc1_ = slot.n.tile;
- if(n)
- {
- if(n == _loc1_.s)
- {
- nLight.gotoAndPlay(2);
- _loc1_.sLight.gotoAndPlay(2);
- }
- else
- {
- nLight.gotoAndStop(1);
- if(_loc1_.s)
- {
- _loc1_.sLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.s)
- {
- _loc1_.sLight.gotoAndStop(1);
- }
- }
- else if(n)
- {
- nLight.gotoAndStop(1);
- }
- if(slot.ne)
- {
- _loc1_ = slot.ne.tile;
- if(ne)
- {
- if(ne == _loc1_.sw)
- {
- neLight.gotoAndPlay(2);
- _loc1_.swLight.gotoAndPlay(2);
- }
- else
- {
- neLight.gotoAndStop(1);
- if(_loc1_.sw)
- {
- _loc1_.swLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.sw)
- {
- _loc1_.swLight.gotoAndStop(1);
- }
- }
- else if(ne)
- {
- neLight.gotoAndStop(1);
- }
- if(slot.se)
- {
- _loc1_ = slot.se.tile;
- if(se)
- {
- if(se == _loc1_.nw)
- {
- seLight.gotoAndPlay(2);
- _loc1_.nwLight.gotoAndPlay(2);
- }
- else
- {
- seLight.gotoAndStop(1);
- if(_loc1_.nw)
- {
- _loc1_.nwLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.nw)
- {
- _loc1_.nwLight.gotoAndStop(1);
- }
- }
- else if(se)
- {
- seLight.gotoAndStop(1);
- }
- if(slot.s)
- {
- _loc1_ = slot.s.tile;
- if(s)
- {
- if(s == _loc1_.n)
- {
- sLight.gotoAndPlay(2);
- _loc1_.nLight.gotoAndPlay(2);
- }
- else
- {
- sLight.gotoAndStop(1);
- if(_loc1_.n)
- {
- _loc1_.nLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.n)
- {
- _loc1_.nLight.gotoAndStop(1);
- }
- }
- else if(s)
- {
- sLight.gotoAndStop(1);
- }
- if(slot.sw)
- {
- _loc1_ = slot.sw.tile;
- if(sw)
- {
- if(sw == _loc1_.ne)
- {
- swLight.gotoAndPlay(2);
- _loc1_.neLight.gotoAndPlay(2);
- }
- else
- {
- swLight.gotoAndStop(1);
- if(_loc1_.ne)
- {
- _loc1_.neLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.ne)
- {
- _loc1_.neLight.gotoAndStop(1);
- }
- }
- else if(sw)
- {
- swLight.gotoAndStop(1);
- }
- if(slot.nw)
- {
- _loc1_ = slot.nw.tile;
- if(nw)
- {
- if(nw == _loc1_.se)
- {
- nwLight.gotoAndPlay(2);
- _loc1_.seLight.gotoAndPlay(2);
- }
- else
- {
- nwLight.gotoAndStop(1);
- if(_loc1_.se)
- {
- _loc1_.seLight.gotoAndStop(1);
- }
- }
- }
- else if(_loc1_.se)
- {
- _loc1_.seLight.gotoAndStop(1);
- }
- }
- else if(nw)
- {
- nwLight.gotoAndStop(1);
- }
- }
-
- private function addNETunnel(param1:int) : void
- {
- if(neTunnel)
- {
- return;
- }
- neTunnel = addTunnel(param1,-120);
- neLight = neTunnel.getChildByName("light") as MovieClip;
- neLight.stop();
- neLight.addFrameScript(neLight.totalFrames - 1,neLightLoop);
- }
-
- private function checkRemoveCenter() : void
- {
- if(!n && !ne && !se && !s && !sw && !nw)
- {
- removeCenter();
- }
- }
-
- private function sLightLoop() : void
- {
- sLight.gotoAndPlay(2);
- }
-
- private function seLightLoop() : void
- {
- seLight.gotoAndPlay(2);
- }
-
- private function removeNWTunnel() : void
- {
- if(!nwTunnel)
- {
- return;
- }
- nwLight.stop();
- removeChild(nwTunnel);
- nwTunnel = null;
- nwLight = null;
- nw = 0;
- checkRemoveCenter();
- }
-
- public function setNE(param1:int) : void
- {
- ne = param1;
- if(!param1)
- {
- removeNETunnel();
- }
- else
- {
- addNETunnel(param1);
- neLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- public function lock() : void
- {
- locked = true;
- rim.visible = false;
- background.visible = false;
- buttonMode = false;
- }
-
- public function setS(param1:int) : void
- {
- s = param1;
- if(!param1)
- {
- removeSTunnel();
- }
- else
- {
- addSTunnel(param1);
- sLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- private function addNWTunnel(param1:int) : void
- {
- if(nwTunnel)
- {
- return;
- }
- nwTunnel = addTunnel(param1,120);
- nwLight = nwTunnel.getChildByName("light") as MovieClip;
- nwLight.stop();
- nwLight.addFrameScript(nwLight.totalFrames - 1,nwLightLoop);
- }
-
- public function setNW(param1:int) : void
- {
- nw = param1;
- if(!param1)
- {
- removeNWTunnel();
- }
- else
- {
- addNWTunnel(param1);
- nwLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- public function confirm() : void
- {
- confirmed = true;
- rim.alpha = 0.35;
- background.alpha = 0;
- }
-
- public function setSE(param1:int) : void
- {
- se = param1;
- if(!param1)
- {
- removeSETunnel();
- }
- else
- {
- addSETunnel(param1);
- seLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- public function unlock() : void
- {
- locked = false;
- rim.visible = true;
- background.visible = true;
- buttonMode = true;
- }
-
- private function stopRim() : void
- {
- rim.stop();
- }
-
- public function setN(param1:int) : void
- {
- n = param1;
- if(!param1)
- {
- removeNTunnel();
- }
- else
- {
- addNTunnel(param1);
- nLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- private function addCenter() : void
- {
- if(center)
- {
- return;
- }
- center = new CenterGfx();
- addChild(center);
- }
-
- private function removeNTunnel() : void
- {
- if(!nTunnel)
- {
- return;
- }
- nLight.stop();
- removeChild(nTunnel);
- nTunnel = null;
- nLight = null;
- n = 0;
- checkRemoveCenter();
- }
-
- private function swLightLoop() : void
- {
- swLight.gotoAndPlay(2);
- }
-
- private function removeSETunnel() : void
- {
- if(!seTunnel)
- {
- return;
- }
- seLight.stop();
- removeChild(seTunnel);
- seTunnel = null;
- seLight = null;
- se = 0;
- checkRemoveCenter();
- }
-
- private function addSTunnel(param1:int) : void
- {
- if(sTunnel)
- {
- return;
- }
- sTunnel = addTunnel(param1,0);
- sLight = sTunnel.getChildByName("light") as MovieClip;
- sLight.stop();
- sLight.addFrameScript(sLight.totalFrames - 1,sLightLoop);
- }
-
- public function setSW(param1:int) : void
- {
- sw = param1;
- if(!param1)
- {
- removeSWTunnel();
- }
- else
- {
- addSWTunnel(param1);
- swLight.transform.colorTransform = COLORS[param1];
- }
- checkNeighbours();
- }
-
- private function addTunnel(param1:int, param2:Number) : Sprite
- {
- var _loc3_:Sprite = null;
- addCenter();
- if(!Game.colorBlind)
- {
- _loc3_ = new TunnelGfx();
- }
- else if(param1 == 1)
- {
- _loc3_ = new TunnelGfx1();
- }
- else if(param1 == 2)
- {
- _loc3_ = new TunnelGfx2();
- }
- else if(param1 == 3)
- {
- _loc3_ = new TunnelGfx3();
- }
- else if(param1 == 4)
- {
- _loc3_ = new TunnelGfx4();
- }
- _loc3_.rotation = param2;
- addChildAt(_loc3_,getChildIndex(center));
- return _loc3_;
- }
-
- private function removeSWTunnel() : void
- {
- if(!swTunnel)
- {
- return;
- }
- swLight.stop();
- removeChild(swTunnel);
- swTunnel = null;
- swLight = null;
- sw = 0;
- checkRemoveCenter();
- }
-
- private function neLightLoop() : void
- {
- neLight.gotoAndPlay(2);
- }
-
- public function flash() : void
- {
- rim.gotoAndPlay(2);
- }
-
- private function removeCenter() : void
- {
- if(!center)
- {
- return;
- }
- removeChild(center);
- center = null;
- }
- }
- }
-