home *** CD-ROM | disk | FTP | other *** search
- class com.Polygon
- {
- var nodes;
- var polySound;
- var clickStatus;
- var complite;
- var stopPolygon;
- var polyType;
- var clip;
- var obj;
- var pass;
- var poitsFound;
- var i;
- function Polygon(_clip, _typePolygon)
- {
- var _loc3_ = parseInt(_typePolygon,10);
- this.nodes = new Array();
- this.polySound = new com.Sounds(_clip);
- this.clickStatus = false;
- this.complite = false;
- if(_typePolygon == undefined || _loc3_ < 1)
- {
- this.stopPolygon = false;
- if(_loc3_ < 0)
- {
- this.polyType = new com.Types(_loc3_);
- }
- else
- {
- this.polyType = new com.Types(0);
- }
- }
- else
- {
- _global.startPoint.push({poly:this,i:_global.polygons.length});
- this.stopPolygon = true;
- this.polyType = new com.Types(_loc3_);
- }
- this.clip = _clip;
- this.clip.obj = this;
- this.clip.useHandCursor = false;
- this.clip.onPress = this.clickToPolygon;
- this.clip.onRelease = this.clip.onReleaseOutside = this.deleteAutoSelect;
- }
- function addNode(a, b)
- {
- this.nodes.push({node:a,control:b});
- }
- function clickToPolygon()
- {
- _global.undoArray = new Array();
- if(this.obj.stopPolygon)
- {
- this.obj.polySound.playSound("clickToEndPoint");
- _global.selectType = this.obj.polyType.type;
- this.obj.selectFace();
- }
- else if(_global.selectType > 0 && this.obj.polyType.type >= 0 && this.obj.polyType.type != _global.selectType)
- {
- _global.undoArray.push({poly:this.obj,type:this.obj.polyType.type});
- this.obj.polySound.playSound("clickToFace");
- this.obj.polyType.type = _global.selectType;
- }
- this.obj.draw();
- this.obj.clip.onMouseMove = this.obj.autoSelect;
- }
- function autoSelect()
- {
- var _loc3_ = 3;
- var _loc5_ = _global.polygons.length;
- while(_loc3_ < _loc5_)
- {
- var _loc2_ = _global.polygons[_loc3_];
- if(_loc2_.clip.hitTest(_xmouse,_ymouse,true))
- {
- if(_loc2_.polyType.type != _global.selectType)
- {
- if(!_loc2_.stopPolygon && _loc2_.polyType.type >= 0)
- {
- _global.undoArray.push({poly:_loc2_,type:_loc2_.polyType.type});
- _loc2_.polyType.type = _global.selectType;
- _loc2_.polySound.playSound("clickToFace");
- _loc2_.draw();
- break;
- }
- }
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function deleteAutoSelect()
- {
- delete this.obj.clip.onMouseMove;
- if(_global.selectType > 0)
- {
- this.obj.checkStatusLines();
- }
- }
- function selectFace()
- {
- this.polyType.oStatus = 1;
- var _loc4_ = 0;
- var _loc5_ = _global.startPoint.length;
- while(_loc4_ < _loc5_)
- {
- var _loc3_ = _global.startPoint[_loc4_].poly;
- if(_loc3_.polyType.type == this.polyType.type)
- {
- _loc3_.polyType.oStatus = 1;
- }
- else if(_loc3_.polyType.complite)
- {
- _loc3_.polyType.oStatus = 2;
- }
- else
- {
- _loc3_.polyType.oStatus = 0;
- }
- _loc3_.draw();
- _loc4_ = _loc4_ + 1;
- }
- }
- function changeStatusComlite(poly)
- {
- var _loc4_ = false;
- if(!poly.polyType.complite)
- {
- var _loc3_ = 0;
- var _loc5_ = _global.startPoint.length;
- while(_loc3_ < _loc5_)
- {
- var _loc2_ = _global.startPoint[_loc3_].poly;
- if(_loc2_.polyType.type == poly.polyType.type)
- {
- _loc2_.polyType.complite = true;
- _loc2_.polyType.oStatus = 2;
- _loc4_ = true;
- }
- _loc2_.draw();
- _loc3_ = _loc3_ + 1;
- }
- }
- return _loc4_;
- }
- function changeStatusNoComlite(poly)
- {
- var _loc4_ = false;
- if(poly.polyType.complite)
- {
- var _loc3_ = 0;
- var _loc5_ = _global.startPoint.length;
- while(_loc3_ < _loc5_)
- {
- var _loc2_ = _global.startPoint[_loc3_].poly;
- if(_loc2_.polyType.type == poly.polyType.type)
- {
- _loc2_.polyType.complite = false;
- _loc2_.polyType.oStatus = 0;
- _loc4_ = true;
- }
- _loc2_.draw();
- _loc3_ = _loc3_ + 1;
- }
- }
- return _loc4_;
- }
- function checkStatusLines()
- {
- var _loc9_ = false;
- var _loc11_ = false;
- var _loc10_ = 0;
- var _loc12_ = _global.startPoint.length;
- var _loc8_ = 1;
- while(_loc8_ <= _loc12_ / 2)
- {
- var _loc4_ = 0;
- this.pass = new Array();
- this.poitsFound = new Array();
- while(_loc4_ < _loc12_)
- {
- var _loc3_ = _global.startPoint[_loc4_].poly;
- var _loc5_ = _loc8_.toString();
- if(_loc3_.polyType.type == _loc5_)
- {
- this.poitsFound.push(_global.startPoint[_loc4_].i);
- while(true)
- {
- var _loc6_ = this.poitsFound.length;
- if(_loc6_ == 0)
- {
- if(this.changeStatusNoComlite(_loc3_))
- {
- _loc11_ = true;
- }
- break;
- }
- var _loc7_ = this.foundNextFace(this.poitsFound[0],_loc5_);
- if(_loc7_)
- {
- _loc10_ = _loc10_ + 1;
- if(this.changeStatusComlite(_loc3_))
- {
- _loc9_ = true;
- }
- break;
- }
- }
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc8_ = _loc8_ + 1;
- }
- if(_loc11_)
- {
- this.polySound.playSound("lineNoComplite");
- }
- else if(_loc9_)
- {
- if(_loc10_ == _loc12_ / 2)
- {
- this.polySound.playSound("winLevel");
- this.clip._parent._parent.endLevel();
- }
- else
- {
- this.polySound.playSound("lineComplite");
- }
- }
- }
- function foundNextFace(i, type)
- {
- var _loc10_ = false;
- var _loc3_ = _global.amountFace;
- var _loc7_ = _loc3_ * _loc3_;
- var _loc14_ = i - 3;
- var _loc5_ = int(_loc14_ / _loc7_);
- var _loc9_ = Math.floor((_loc14_ - _loc5_ * _loc7_) / _loc3_);
- var _loc8_ = _loc14_ % _loc3_;
- var _loc15_ = _loc9_ - 1;
- var _loc11_ = _loc8_;
- if(_loc15_ < 0)
- {
- if(_loc5_ == 1)
- {
- _loc15_ = _loc3_ - _loc8_ - 1;
- _loc11_ = _loc3_ - 1;
- }
- else
- {
- _loc15_ = _loc3_ - 1;
- }
- var _loc17_ = 0;
- _loc17_ = _loc5_ == 0 ? 10 : _loc17_;
- }
- else
- {
- _loc17_ = _loc5_;
- }
- var _loc13_ = 3 + (_loc15_ * _loc3_ + _loc11_) + _loc17_ * _loc7_;
- if(_global.polygons[_loc13_].polyType.type == type && !this.pass[_loc13_])
- {
- if(_global.polygons[_loc13_].stopPolygon)
- {
- _loc10_ = true;
- }
- else
- {
- this.pass[i] = true;
- this.poitsFound.push(_loc13_);
- }
- }
- _loc15_ = _loc9_ + 1;
- _loc11_ = _loc8_;
- if(_loc15_ >= _loc3_)
- {
- _loc15_ = 0;
- _loc17_ = _loc5_ + 2;
- }
- else
- {
- _loc17_ = _loc5_;
- }
- _loc13_ = 3 + (_loc15_ * _loc3_ + _loc11_) + _loc17_ * _loc7_;
- if(_global.polygons[_loc13_].polyType.type == type && !this.pass[_loc13_])
- {
- if(_global.polygons[_loc13_].stopPolygon)
- {
- _loc10_ = true;
- }
- else
- {
- this.pass[i] = true;
- this.poitsFound.push(_loc13_);
- }
- }
- _loc15_ = _loc9_;
- _loc11_ = _loc8_ + 1;
- if(_loc11_ >= _loc3_)
- {
- if(_loc5_ == 0)
- {
- _loc15_ = 0;
- _loc11_ = _loc3_ - _loc9_ - 1;
- }
- else
- {
- _loc11_ = 0;
- }
- _loc17_ = 1;
- _loc17_ = _loc5_ == 1 ? 10 : _loc17_;
- }
- else
- {
- _loc17_ = _loc5_;
- }
- _loc13_ = 3 + (_loc15_ * _loc3_ + _loc11_) + _loc17_ * _loc7_;
- if(_global.polygons[_loc13_].polyType.type == type && !this.pass[_loc13_])
- {
- if(_global.polygons[_loc13_].stopPolygon)
- {
- _loc10_ = true;
- }
- else
- {
- this.pass[i] = true;
- this.poitsFound.push(_loc13_);
- }
- }
- _loc15_ = _loc9_;
- _loc11_ = _loc8_ - 1;
- if(_loc11_ < 0)
- {
- if(_loc5_ == 0)
- {
- _loc15_ = _loc3_ - 1;
- _loc11_ = _loc3_ - _loc8_ - 1;
- }
- else
- {
- _loc11_ = _loc3_ - 1;
- }
- _loc17_ = 2;
- _loc17_ = _loc5_ != 1 ? 10 : _loc17_;
- }
- else
- {
- _loc17_ = _loc5_;
- }
- _loc13_ = 3 + (_loc15_ * _loc3_ + _loc11_) + _loc17_ * _loc7_;
- if(_global.polygons[_loc13_].polyType.type == type && !this.pass[_loc13_])
- {
- if(_global.polygons[_loc13_].stopPolygon)
- {
- _loc10_ = true;
- }
- else
- {
- this.pass[i] = true;
- this.poitsFound.push(_loc13_);
- }
- }
- for(var _loc12_ in this.poitsFound)
- {
- if(this.poitsFound[_loc12_] == i)
- {
- var _loc4_ = _loc12_;
- this.poitsFound.splice(_loc4_,1);
- }
- }
- return _loc10_;
- }
- function draw()
- {
- this.i = 1;
- this.clip.clear();
- var _loc5_ = (this.nodes[1].node.x - this.nodes[0].node.x) * (this.nodes[2].node.y - this.nodes[0].node.y) - (this.nodes[1].node.y - this.nodes[0].node.y) * (this.nodes[2].node.x - this.nodes[0].node.x);
- if(_loc5_ < 0)
- {
- var _loc3_ = this.polyType.simpleStyle;
- this.clip.moveTo(this.nodes[0].node.x,this.nodes[0].node.y);
- if(_loc3_.linealpha != 0)
- {
- this.clip.lineStyle(_loc3_.lineweight,_loc3_.linecolor,_loc3_.linealpha);
- }
- this.clip.beginFill(_loc3_.fillcolor,_loc3_.fillalpha);
- var _loc4_ = this.nodes.length;
- while(this.i < _loc4_)
- {
- if(this.nodes[this.i].control)
- {
- var _loc2_ = this.polyType.advanceStyle;
- this.clip.moveTo(this.nodes[this.i].node.x,this.nodes[this.i].node.y);
- if(_loc2_.linealpha != 0)
- {
- this.clip.lineStyle(_loc2_.lineweight,_loc2_.linecolor,_loc2_.linealpha);
- }
- this.clip.beginFill(_loc2_.fillcolor,_loc2_.fillalpha);
- this.i = this.i + 1;
- }
- else
- {
- this.clip.lineTo(this.nodes[this.i].node.x,this.nodes[this.i].node.y);
- this.i = this.i + 1;
- }
- }
- this.clip.endFill();
- }
- }
- function set type(a)
- {
- this.polyType = a;
- }
- function get type()
- {
- return this.polyType;
- }
- }
-