home *** CD-ROM | disk | FTP | other *** search
- class JigPiece
- {
- var §set§;
- var id;
- var clip;
- var sec;
- var rot;
- var y;
- var x;
- var dot;
- function JigPiece()
- {
- }
- function Create(§set§, id, top, right, bottom, left)
- {
- this["set"] = §set§;
- this.id = id;
- this.clip = §set§.clip.attachMovie("Piece","piece" + id,id);
- this.sec = new Array(-1,-1,-1,-1);
- this.LoadSec(0,top);
- this.LoadSec(1,right);
- this.LoadSec(2,bottom);
- this.LoadSec(3,left);
- this.rot = 0;
- this.clip._alpha = 0;
- }
- function Destroy()
- {
- this.clip.removeMovieClip();
- this.sec = new Array();
- this["set"] = undefined;
- }
- function Toggle()
- {
- if(this.clip._alpha > 0)
- {
- this.clip._alpha = 0;
- }
- else
- {
- this.clip._alpha = 100;
- }
- }
- function Show()
- {
- this.clip._alpha = 100;
- }
- function ShowLabel()
- {
- this.clip.top.seclabel._alpha = 100;
- this.clip.right.seclabel._alpha = 100;
- this.clip.bottom.seclabel._alpha = 100;
- this.clip.left.seclabel._alpha = 100;
- }
- function Begin()
- {
- this.SetPosition(_root.randomindex(this["set"].freecols),-2);
- this.Show();
- }
- function NextPiece()
- {
- this.clip._x = 481;
- this.clip._y = 39.7;
- this.Show();
- }
- function GetLocalSec(orient)
- {
- var _loc2_ = orient - this.rot;
- if(_loc2_ < 0)
- {
- _loc2_ = 4 + _loc2_;
- }
- return _loc2_ % 4;
- }
- function GetLocalValue(orient)
- {
- return this.sec[this.GetLocalSec(orient)];
- }
- function GetNormal(orient)
- {
- switch(orient)
- {
- case 0:
- return new Array(0,-1);
- case 1:
- return new Array(1,0);
- case 2:
- return new Array(0,1);
- case 3:
- return new Array(-1,0);
- default:
- }
- }
- function GetAdjacent()
- {
- var _loc2_ = new Array();
- _loc2_[3] = this.GetAdjacentLeft();
- _loc2_[1] = this.GetAdjacentRight();
- if(this.y != this["set"].height - 1)
- {
- _loc2_[2] = this["set"].stack[this.x][this["set"].height - this.y - 2];
- }
- if(this["set"].stack[this.x].length >= this["set"].height - this.y)
- {
- _loc2_[0] = this["set"].stack[this.x][this["set"].height - this.y];
- }
- return _loc2_;
- }
- function GetAdjacentLeft()
- {
- if(this.x > 0)
- {
- return this["set"].stack[this.x - 1][this["set"].height - this.y - 1];
- }
- return undefined;
- }
- function GetAdjacentRight()
- {
- if(this.x < this["set"].width - 1)
- {
- return this["set"].stack[this.x + 1][this["set"].height - this.y - 1];
- }
- return undefined;
- }
- function OrientName(orient)
- {
- var _loc1_ = new Array("top","right","bottom","left");
- return _loc1_[orient];
- }
- function LoadSec(orient, val)
- {
- var _loc3_ = undefined;
- var _loc4_ = undefined;
- _loc4_ = this.OrientName(orient);
- _loc3_ = orient * 90;
- this.sec[orient] = val;
- var _loc6_ = new Array("flat","tri-out","tri-in");
- if(val < 0)
- {
- this.clip[_loc4_].removeMovieClip();
- return undefined;
- }
- var _loc2_ = this.clip.attachMovie("sec-" + _loc6_[val],_loc4_,_loc3_);
- _loc2_._rotation = _loc3_;
- _loc2_.seclabel.text.text = orient;
- }
- function Hide()
- {
- this.clip._alpha = 0;
- }
- function Window()
- {
- this.clip.top.gotoAndStop(2);
- this.clip.right.gotoAndStop(2);
- this.clip.bottom.gotoAndStop(2);
- this.clip.left.gotoAndStop(2);
- }
- function Flaw()
- {
- this.clip.top.gotoAndStop(3);
- this.clip.right.gotoAndStop(3);
- this.clip.bottom.gotoAndStop(3);
- this.clip.left.gotoAndStop(3);
- }
- function Dot(orient)
- {
- if(this.dot != undefined)
- {
- this.dot.removeMovieClip();
- }
- this.dot = this.clip[this.OrientName(orient)].attachMovie("Dot","dot",0);
- this.dot._y = -10;
- }
- function Mark()
- {
- this.clip.attachMovie("Dot","mark",100);
- }
- function Unmark()
- {
- if(this.clip.mark)
- {
- this.clip.mark.removeMovieClip();
- }
- }
- function GlobalY(y)
- {
- return this["set"].offy + this["set"].psizey * y;
- }
- function GlobalX(x)
- {
- return this["set"].offx + this["set"].psizex * x;
- }
- function SetY(y)
- {
- this.y = y;
- this.clip._y = this.GlobalY(y);
- }
- function SetX(x)
- {
- this.x = x;
- this.clip._x = this.GlobalX(x);
- }
- function SetPosition(x, y)
- {
- if(x != -1)
- {
- this.SetX(x);
- }
- if(y != -1)
- {
- this.SetY(y);
- }
- }
- function AddPosition(x, y)
- {
- if(x)
- {
- this.SetX(this.x + x);
- }
- if(y)
- {
- this.SetY(this.y + y);
- }
- }
- function SetRotation(r)
- {
- if(r < 0)
- {
- r = 4 + r;
- }
- this.rot = r % 4;
- this.clip._rotation = this.rot * 90;
- }
- function AddRotation(r)
- {
- if(r < 0)
- {
- r = 4 + r;
- }
- this.rot = (this.rot + r) % 4;
- this.clip._rotation = this.rot * 90;
- }
- }
-