home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / jig.swf / scripts / __Packages / JigSet.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  27.6 KB  |  1,039 lines

  1. class JigSet
  2. {
  3.    var clip;
  4.    var pointsclip;
  5.    var pieces;
  6.    var mark;
  7.    var order;
  8.    var pointsclist;
  9.    var compliments;
  10.    var opposites;
  11.    var callback;
  12.    var bgm;
  13.    var mainvol;
  14.    var sound;
  15.    var soundmode;
  16.    var soundfx;
  17.    var start;
  18.    var sitemode;
  19.    var scoresent;
  20.    var userid;
  21.    var usertype;
  22.    var ground;
  23.    var stack;
  24.    var freecols;
  25.    var timemode;
  26.    var clawdir;
  27.    var clawqueue;
  28.    var lastmod;
  29.    var pointsi;
  30.    var holdmeter;
  31.    var mutexpiece;
  32.    var turn;
  33.    var tickcount;
  34.    var tickbase;
  35.    var countleveler;
  36.    var countsculptor;
  37.    var countdrill;
  38.    var countflaws;
  39.    var score;
  40.    var combo;
  41.    var flawpiece;
  42.    var flawpieceinv;
  43.    var active;
  44.    var nextpiece;
  45.    var clawclip;
  46.    var holdclip;
  47.    var difficulty;
  48.    var speedbase;
  49.    var playmode;
  50.    var backclip;
  51.    var starttime;
  52.    var keylistener;
  53.    var ref;
  54.    var attachSound;
  55.    var onSoundComplete;
  56.    var bgmchannels = 2;
  57.    var height = 12;
  58.    var width = 8;
  59.    var psizex = 40;
  60.    var psizey = 40;
  61.    var offx = 120;
  62.    var offy = 120;
  63.    var clawspeed = 50;
  64.    var flawscore = -100;
  65.    var drillscore = -20;
  66.    var sculptorscore = -20;
  67.    var levelerscore = -20;
  68.    var landscore = 100;
  69.    var allowedflaws = 40;
  70.    var accel = 0;
  71.    var accelmax = 10;
  72.    var accelrate = 0.4;
  73.    var holdmax = 400;
  74.    var holdregen = 0.15;
  75.    var flawtimetick = 0;
  76.    var flawtime = 5;
  77.    var flawcount = 0;
  78.    var flawlimit = 6;
  79.    var timelimit = 360;
  80.    var tickdiv = 15;
  81.    var username = "";
  82.    function JigSet()
  83.    {
  84.       this.clip = _root.pieces;
  85.       this.pointsclip = _root.createEmptyMovieClip("points",1);
  86.       this.pieces = new Array();
  87.       this.mark = new Array();
  88.       this.order = new Array();
  89.       this.pointsclist = new Array();
  90.       this.compliments = new Array(0,2,1);
  91.       this.opposites = new Array(2,3,0,1);
  92.       this.callback = new Array();
  93.       this.bgm = new Array();
  94.       this.bgm[0] = new SoundChannel(true);
  95.       this.bgm[0].SetPlaylist(new Array(new SoundPhrase("BGM_Jig")));
  96.       this.mainvol = new Sound();
  97.       var _loc3_ = _root.createEmptyMovieClip("sidesound",4094);
  98.       this.sound = new Sound(_loc3_);
  99.       this.soundmode = 0;
  100.       var _loc4_ = _root.createEmptyMovieClip("sidesoundfx",4093);
  101.       this.soundfx = new Sound(_loc4_);
  102.       this.IntroSound();
  103.       _root.createEmptyMovieClip("timertick",5000);
  104.       _root.timertick.onEnterFrame = _root.tick;
  105.       _root.timertick.gotoAndPlay(1);
  106.    }
  107.    function IntroSound()
  108.    {
  109.       if(this.soundmode != 9999)
  110.       {
  111.          this.sound.attachSound("Intro");
  112.          this.sound.setVolume(100);
  113.          this.sound.start();
  114.          this.soundmode = 9999;
  115.          this.sound.onSoundComplete = function()
  116.          {
  117.             this.start();
  118.          };
  119.       }
  120.    }
  121.    function AddPiece()
  122.    {
  123.       var _loc4_ = new JigPiece();
  124.       this.pieces.push(_loc4_);
  125.       var _loc3_ = 3;
  126.       var _loc5_ = _root.randn(_loc3_);
  127.       var _loc6_ = _root.randn(_loc3_);
  128.       var _loc7_ = _root.randn(_loc3_);
  129.       var _loc8_ = _root.randn(_loc3_);
  130.       _loc4_.Create(this,this.pieces.length - 1,_loc5_,_loc7_,_loc6_,_loc8_);
  131.       return _loc4_;
  132.    }
  133.    function StatusReport()
  134.    {
  135.    }
  136.    function Init()
  137.    {
  138.       this.StatusReport();
  139.       this.SoundEffect("Menu");
  140.       if(_root._url.indexOf("endgameradio.com") != -1)
  141.       {
  142.          this.sitemode = 1;
  143.       }
  144.       else
  145.       {
  146.          this.sitemode = 0;
  147.       }
  148.       this.scoresent = 0;
  149.       if(_root.username)
  150.       {
  151.          this.username = _root.username;
  152.          this.userid = _root.userid;
  153.          this.usertype = 1;
  154.       }
  155.       this.ground = new Array(12,12,12,12,12,12,12,12);
  156.       this.stack = new Array();
  157.       this.freecols = new Array(0,1,2,3,4,5,6,7);
  158.       var _loc7_ = 0;
  159.       while(_loc7_ < 8)
  160.       {
  161.          this.stack[_loc7_] = new Array();
  162.          _loc7_ = _loc7_ + 1;
  163.       }
  164.       this.sound.stop();
  165.       this.soundmode = 0;
  166.       this.timemode = 0;
  167.       this.clawdir = 0;
  168.       this.clawqueue = 0;
  169.       this.lastmod = 0;
  170.       this.pointsi = 0;
  171.       this.usertype = 0;
  172.       this.holdmeter = this.holdmax;
  173.       this.mutexpiece = false;
  174.       this.turn = 0;
  175.       this.timemode = 0;
  176.       this.tickcount = 0;
  177.       this.tickbase = 0;
  178.       this.countleveler = 0;
  179.       this.countsculptor = 0;
  180.       this.countdrill = 0;
  181.       this.countflaws = 0;
  182.       this.score = 0;
  183.       this.combo = 0;
  184.       this.flawpiece = new JigPiece();
  185.       this.flawpiece.Create(this,9999,0,0,0,0);
  186.       this.flawpieceinv = new JigPiece();
  187.       this.flawpieceinv.Create(this,9998,0,0,0,0);
  188.       this.clip.loadVariables("http://endgameradio.com/smack.php");
  189.       var _loc8_ = this.AddPiece();
  190.       this.active = _loc8_;
  191.       this.nextpiece = this.AddPiece();
  192.       this.nextpiece.NextPiece();
  193.       _loc8_.Begin();
  194.       this.clawclip = _root.claw;
  195.       this.holdclip = _root.holdbar;
  196.       switch(this.difficulty)
  197.       {
  198.          case 1:
  199.             this.speedbase = Math.floor(this.tickdiv * 2);
  200.             this.allowedflaws = 40;
  201.             break;
  202.          case 2:
  203.             this.speedbase = this.tickdiv;
  204.             this.allowedflaws = 20;
  205.             break;
  206.          case 3:
  207.             this.speedbase = Math.floor(this.tickdiv * 0.66);
  208.             this.allowedflaws = 10;
  209.       }
  210.       switch(this.playmode)
  211.       {
  212.          case "basic":
  213.          case "sudden":
  214.             break;
  215.          case "speed":
  216.             this.timelimit = 120 * (4 - this.difficulty);
  217.             break;
  218.          case "leveler":
  219.          case "sculptor":
  220.          case "driller":
  221.             break;
  222.          case "bare":
  223.             this.clawclip._alpha = 0;
  224.             this.holdclip._alpha = 0;
  225.       }
  226.       _root.textflaws.text = this.allowedflaws;
  227.       var _loc5_ = undefined;
  228.       var _loc6_ = undefined;
  229.       this.backclip = _root.backblocks;
  230.       this.backclip._alpha = 100;
  231.       var _loc4_ = 0;
  232.       while(_loc4_ < this.height)
  233.       {
  234.          var _loc3_ = 0;
  235.          while(_loc3_ < this.width)
  236.          {
  237.             _loc5_ = _loc4_ * this.width + _loc3_;
  238.             _loc6_ = this.backclip.attachMovie("JigBlock","b" + _loc5_,_loc5_);
  239.             _loc6_._x = this.psizex * _loc3_ + this.offx - this.psizex * 0.5;
  240.             _loc6_._y = this.psizey * _loc4_ + this.offy - this.psizex * 0.5;
  241.             _loc3_ = _loc3_ + 1;
  242.          }
  243.          _loc4_ = _loc4_ + 1;
  244.       }
  245.       var _loc9_ = new Date();
  246.       this.starttime = Math.floor(_loc9_.getTime() / 1000);
  247.       this.keylistener = new Object();
  248.       this.keylistener.ref = this;
  249.       this.keylistener.onKeyDown = function()
  250.       {
  251.          switch(Key.getCode())
  252.          {
  253.             case 37:
  254.             case 65:
  255.                this.ref.KeyLeft();
  256.                break;
  257.             case 39:
  258.             case 68:
  259.                this.ref.KeyRight();
  260.                break;
  261.             case 38:
  262.             case 87:
  263.                this.ref.KeyUp();
  264.                break;
  265.             case 40:
  266.             case 83:
  267.                this.ref.KeyDown();
  268.                break;
  269.             case 32:
  270.                this.ref.KeyHold();
  271.                break;
  272.             case 70:
  273.                this.ref.KeyDrop();
  274.                break;
  275.             case 86:
  276.                this.ref.KeyAccel();
  277.                break;
  278.             case 90:
  279.                this.ref.KeySculptor();
  280.                break;
  281.             case 88:
  282.                this.ref.KeyLeveler();
  283.                break;
  284.             case 67:
  285.                this.ref.KeyDrill();
  286.          }
  287.       };
  288.       this.keylistener.onKeyUp = function()
  289.       {
  290.          switch(Key.getCode())
  291.          {
  292.             case 32:
  293.                this.ref.KeyUnHold();
  294.                break;
  295.             case 86:
  296.                this.ref.KeyUnAccel();
  297.          }
  298.       };
  299.       Key.addListener(this.keylistener);
  300.       _loc7_ = 0;
  301.       while(_loc7_ < this.bgm.length)
  302.       {
  303.          this.bgm[_loc7_].Play();
  304.          _loc7_ = _loc7_ + 1;
  305.       }
  306.       this.callback.timer = this.TickTimer;
  307.       this.callback.frame = this.TickFrame;
  308.       this.callback.fall = this.TickJumpFall;
  309.    }
  310.    function ViewScores()
  311.    {
  312.       var _loc2_ = undefined;
  313.       switch(this.difficulty)
  314.       {
  315.          case 1:
  316.             _loc2_ = "easy";
  317.             break;
  318.          case 2:
  319.             _loc2_ = "normal";
  320.             break;
  321.          case 3:
  322.             _loc2_ = "hard";
  323.       }
  324.       getURL("http://endgameradio.com/score.php?game=1&mode=" + this.playmode + "-" + _loc2_,"_blank");
  325.    }
  326.    function SubmitScore()
  327.    {
  328.       var _loc4_ = this.GetFinalScore();
  329.       var _loc2_ = undefined;
  330.       switch(this.difficulty)
  331.       {
  332.          case 1:
  333.             _loc2_ = "easy";
  334.             break;
  335.          case 2:
  336.             _loc2_ = "normal";
  337.             break;
  338.          case 3:
  339.             _loc2_ = "hard";
  340.       }
  341.       if(!this.username || this.scoresent == 1 || _loc4_ < 0)
  342.       {
  343.          return false;
  344.       }
  345.       var _loc3_ = "http://endgameradio.com/sendscore.php?username=" + this.username + "&game=1&mode=" + this.playmode + "-" + _loc2_ + "&score=" + _loc4_ + "&user=" + this.userid + "&scoretype=";
  346.       this.clip.loadVariables(_loc3_);
  347.       this.scoresent = 1;
  348.       return true;
  349.    }
  350.    function GetFinalScore()
  351.    {
  352.       var _loc2_ = undefined;
  353.       _loc2_ = this.score;
  354.       return _loc2_;
  355.    }
  356.    function End(result)
  357.    {
  358.       this.timemode = 3;
  359.       Key.removeListener(this.keylistener);
  360.       for(var _loc5_ in this.callback)
  361.       {
  362.          if(_loc5_ != "pointfade")
  363.          {
  364.             delete this.callback[_loc5_];
  365.          }
  366.       }
  367.       var _loc4_ = undefined;
  368.       switch(result)
  369.       {
  370.          case "win":
  371.             _loc4_ = "*Ding* Grats! ^_^\nYou get 150% of your\nscore for completing";
  372.             var _loc6_ = this.score;
  373.             this.score = Math.floor(this.score * 1.5);
  374.             this.Score(this.score - _loc6_);
  375.             break;
  376.          case "time":
  377.             _loc4_ = "OH NOES!\nYou ran out of time O.o";
  378.             break;
  379.          case "quit":
  380.             _loc4_ = ":(";
  381.             break;
  382.          case "fail":
  383.             _loc4_ = "OH NOES!\nInstant Death mode means you lose. T.T";
  384.             break;
  385.          case "flaw":
  386.             _loc4_ = "OH NOES!\nToo many flaws.\nThe Gods are not pleased...";
  387.       }
  388.       _root.backblocks._alpha = 0;
  389.       var _loc3_ = _root.attachMovie("Dialog","dialog",10000);
  390.       if(this.sitemode == 0)
  391.       {
  392.          _loc3_.submit._visible = false;
  393.          _loc3_.entry._visible = false;
  394.       }
  395.       else
  396.       {
  397.          _loc3_.msg.text = "";
  398.          _loc3_.msg._visible = false;
  399.       }
  400.       _loc3_._x = 270;
  401.       _loc3_._y = 300;
  402.       _loc3_.text.text = _loc4_;
  403.       _loc3_.score.text = this.GetFinalScore();
  404.       _loc3_.entry.name.text = this.username;
  405.    }
  406.    function Clean()
  407.    {
  408.       var _loc2_ = 0;
  409.       while(_loc2_ < this.pieces.length)
  410.       {
  411.          this.pieces[_loc2_].Destroy();
  412.          delete this.pieces[_loc2_];
  413.          _loc2_ = _loc2_ + 1;
  414.       }
  415.       this.flawpiece.Destroy();
  416.       this.flawpieceinv.Destroy();
  417.       _loc2_ = 0;
  418.       while(_loc2_ < this.bgm.length)
  419.       {
  420.          this.bgm[_loc2_].Stop();
  421.          _loc2_ = _loc2_ + 1;
  422.       }
  423.    }
  424.    function GetTimeLeft()
  425.    {
  426.       var _loc2_ = this.GetTimeUsed();
  427.       _loc2_ = this.timelimit - _loc2_;
  428.       return _loc2_;
  429.    }
  430.    function GetTimeUsed()
  431.    {
  432.       var _loc2_ = new Date();
  433.       var _loc4_ = Math.floor(_loc2_.getTime() / 1000);
  434.       var _loc3_ = _loc4_ - this.starttime;
  435.       return _loc3_;
  436.    }
  437.    function Tick()
  438.    {
  439.       var _loc2_ = "--tick:";
  440.       for(var _loc3_ in this.callback)
  441.       {
  442.          this.callback[_loc3_].call(this);
  443.          _loc2_ += _loc3_ + ",";
  444.       }
  445.    }
  446.    function Turn()
  447.    {
  448.       while(this.mutexpiece == true)
  449.       {
  450.       }
  451.       this.mutexpiece = true;
  452.       if(this.active.y + 1 == this.ground[this.active.x])
  453.       {
  454.          this.Land();
  455.       }
  456.       else
  457.       {
  458.          this.active.AddPosition(0,1);
  459.       }
  460.       this.mutexpiece = false;
  461.       _root.whiteout._alpha = 0;
  462.       this.turn = this.turn + 1;
  463.    }
  464.    function Land()
  465.    {
  466.       if(this.timemode >= 2)
  467.       {
  468.          return undefined;
  469.       }
  470.       this.active.SetPosition(-1,this.ground[this.active.x] - 1);
  471.       this.ground[this.active.x] = this.active.y;
  472.       var _loc4_ = 0;
  473.       if(this.active.y < 1)
  474.       {
  475.          var _loc6_ = _root.array_search(this.freecols,this.active.x);
  476.          this.freecols.splice(_loc6_,1);
  477.          if(this.freecols.length == 0)
  478.          {
  479.             _loc4_ = 1;
  480.          }
  481.       }
  482.       this.stack[this.active.x].push(this.active);
  483.       this.order.push(this.active);
  484.       var _loc3_ = this.landscore;
  485.       this.Score(_loc3_);
  486.       if(this.active.y < 4)
  487.       {
  488.          this.Score(_loc3_ * ((4 - this.active.y - 1) * 0.5 + 1) - _loc3_,"combo");
  489.       }
  490.       if(this.combo > 0)
  491.       {
  492.          this.Score(_loc3_ * ((this.combo - 1) * 0.5 + 1) - _loc3_,"combo");
  493.       }
  494.       this.combo = this.combo + 1;
  495.       _root.textcombo.text = this.combo;
  496.       var _loc5_ = this.Match();
  497.       if(!_loc5_.match)
  498.       {
  499.          this.Fix(_loc5_);
  500.          this.SoundEffect("PieceFlaw");
  501.       }
  502.       else
  503.       {
  504.          this.SoundEffect("PiecePlace");
  505.       }
  506.       if(_loc4_)
  507.       {
  508.          return this.End("win");
  509.       }
  510.       this.active = this.nextpiece;
  511.       this.nextpiece = this.AddPiece();
  512.       this.nextpiece.NextPiece();
  513.       this.active.Begin();
  514.    }
  515.    function Fix(con)
  516.    {
  517.       var _loc4_ = undefined;
  518.       var _loc5_ = undefined;
  519.       var _loc7_ = 0;
  520.       if(this.playmode == "sudden")
  521.       {
  522.          return this.End("fail");
  523.       }
  524.       var _loc8_ = this.active.GetLocalSec(0);
  525.       var _loc3_ = 0;
  526.       while(_loc3_ < 4)
  527.       {
  528.          _loc4_ = this.active.GetLocalSec(_loc3_);
  529.          if(con.res[_loc3_] == false)
  530.          {
  531.             if(con.adj[_loc3_] == 0)
  532.             {
  533.                _loc5_ = 0;
  534.             }
  535.             else
  536.             {
  537.                _loc5_ = this.compliments[con.adj[_loc3_].GetLocalValue(this.opposites[_loc3_])];
  538.             }
  539.             this.flawpiece.LoadSec(_loc4_,_loc5_);
  540.             this.flawpieceinv.LoadSec(_loc4_,this.active.GetLocalValue(_loc3_));
  541.             this.active.LoadSec(_loc4_,_loc5_);
  542.             this.countflaws = this.countflaws + 1;
  543.             _root.textflaws.text = this.allowedflaws - this.countflaws;
  544.             _loc7_ += this.flawscore;
  545.             if(this.allowedflaws == this.countflaws)
  546.             {
  547.                return this.End("flaw");
  548.             }
  549.          }
  550.          else
  551.          {
  552.             this.flawpiece.LoadSec(_loc4_,-1);
  553.             this.flawpieceinv.LoadSec(_loc4_,-1);
  554.          }
  555.          _loc3_ = _loc3_ + 1;
  556.       }
  557.       if(_loc7_)
  558.       {
  559.          this.flawpiece.SetPosition(this.active.x,this.active.y);
  560.          this.flawpiece.SetRotation(- _loc8_);
  561.          this.flawpiece.Flaw();
  562.          this.flawpiece.Show();
  563.          this.flawpieceinv.SetPosition(this.active.x,this.active.y);
  564.          this.flawpieceinv.SetRotation(- _loc8_);
  565.          this.flawpieceinv.Flaw();
  566.          this.flawpieceinv.Show();
  567.          this.callback.flawflash = this.TickFlawFlash;
  568.          this.Score(_loc7_,"flaw");
  569.          this.combo = 0;
  570.          _root.textcombo.text = this.combo;
  571.       }
  572.    }
  573.    function Match()
  574.    {
  575.       var _loc3_ = new JigConnection();
  576.       _loc3_.adj = this.active.GetAdjacent();
  577.       _loc3_.res = new Array();
  578.       _loc3_.match = true;
  579.       var _loc2_ = 0;
  580.       while(_loc2_ < 4)
  581.       {
  582.          var _loc5_ = "testing " + this.active.OrientName(_loc2_) + ": ";
  583.          var _loc6_ = this.active.GetLocalValue(_loc2_);
  584.          if(_loc3_.adj[_loc2_] == undefined)
  585.          {
  586.             var _loc4_ = undefined;
  587.             switch(_loc2_)
  588.             {
  589.                case 0:
  590.                   _loc4_ = this.active.y == 0;
  591.                   break;
  592.                case 1:
  593.                   _loc4_ = this.active.x == this.width - 1;
  594.                   break;
  595.                case 3:
  596.                   _loc4_ = this.active.x == 0;
  597.                   break;
  598.                case 2:
  599.                   _loc4_ = this.active.y == this.height - 1;
  600.             }
  601.             if(_loc4_)
  602.             {
  603.                _loc3_.res[_loc2_] = _loc6_ == 0;
  604.                _loc3_.adj[_loc2_] = 0;
  605.                _loc5_ += "wall (" + _loc6_ + "==0)";
  606.             }
  607.             else
  608.             {
  609.                _loc3_.res[_loc2_] = true;
  610.                _loc5_ += "nothing";
  611.             }
  612.          }
  613.          else
  614.          {
  615.             _loc3_.res[_loc2_] = this.compliments[_loc6_] == _loc3_.adj[_loc2_].GetLocalValue(this.opposites[_loc2_]);
  616.             _loc5_ += "piece (" + _loc6_ + "<=>" + _loc3_.adj[_loc2_].GetLocalValue(this.opposites[_loc2_]) + ")";
  617.          }
  618.          if(_loc3_.res[_loc2_] == false)
  619.          {
  620.             _loc3_.match = false;
  621.          }
  622.          _loc2_ = _loc2_ + 1;
  623.       }
  624.       return _loc3_;
  625.    }
  626.    function Mark(arr)
  627.    {
  628.       var _loc2_ = 0;
  629.       while(_loc2_ < this.mark.length)
  630.       {
  631.          this.pieces[this.mark[_loc2_]].Unmark();
  632.          _loc2_ = _loc2_ + 1;
  633.       }
  634.       this.mark = new Array();
  635.       _loc2_ = 0;
  636.       while(_loc2_ < arr.length)
  637.       {
  638.          this.pieces[arr[_loc2_]].Mark();
  639.          this.mark.push(arr[_loc2_]);
  640.          _loc2_ = _loc2_ + 1;
  641.       }
  642.    }
  643.    function Score(n, type)
  644.    {
  645.       n = Math.floor(n);
  646.       if(n == 0)
  647.       {
  648.          return undefined;
  649.       }
  650.       this.score += n;
  651.       _root.textscore.text = this.score;
  652.       var _loc3_ = this.pointsclip.attachMovie("points",this.pointsi,this.pointsi);
  653.       _loc3_._x = this.active.clip._x;
  654.       _loc3_._y = this.active.clip._y;
  655.       if(n > 0)
  656.       {
  657.          _loc3_.text.text = "+" + n;
  658.       }
  659.       else
  660.       {
  661.          _loc3_.text.text = n;
  662.       }
  663.       switch(type)
  664.       {
  665.          case "flaw":
  666.             _loc3_.text.textColor = 16751001;
  667.             _loc3_._y += 20;
  668.             break;
  669.          case "combo":
  670.             _loc3_.text.textColor = 10066431;
  671.             _loc3_._y -= 20;
  672.       }
  673.       this.pointsclist[this.pointsi] = _loc3_;
  674.       this.pointsi = this.pointsi + 1;
  675.       this.callback.pointfade = this.TickPointFade;
  676.    }
  677.    function SoundEffect(v)
  678.    {
  679.       this.soundfx.stop();
  680.       this.soundfx.attachSound(v);
  681.       this.soundfx.setVolume(100);
  682.       this.soundfx.start();
  683.    }
  684.    function UseClaw(v)
  685.    {
  686.       if(this.active.GetLocalValue(3) == v)
  687.       {
  688.          return undefined;
  689.       }
  690.       this.callback.claw = this.TickClawOut;
  691.       this.clawqueue = v;
  692.       switch(v)
  693.       {
  694.          case 0:
  695.             this.countleveler = this.countleveler + 1;
  696.             _root.textleveler.text = this.countleveler;
  697.             this.Score(this.levelerscore);
  698.             this.SoundEffect("ToolLeveler");
  699.             break;
  700.          case 1:
  701.             this.countsculptor = this.countsculptor + 1;
  702.             _root.textsculptor.text = this.countsculptor;
  703.             this.Score(this.sculptorscore);
  704.             this.SoundEffect("ToolSculptor");
  705.             break;
  706.          case 2:
  707.             this.countdrill = this.countdrill + 1;
  708.             _root.textdrill.text = this.countdrill;
  709.             this.Score(this.drillscore);
  710.             this.SoundEffect("ToolDrill");
  711.       }
  712.    }
  713.    function KeyRight()
  714.    {
  715.       while(this.mutexpiece == true)
  716.       {
  717.       }
  718.       this.mutexpiece = true;
  719.       if(this.active.x < 7)
  720.       {
  721.          var _loc2_ = this.active.GetAdjacentRight();
  722.          if(_loc2_ == undefined)
  723.          {
  724.             this.active.AddPosition(1,0);
  725.          }
  726.       }
  727.       this.mutexpiece = false;
  728.    }
  729.    function KeyLeft()
  730.    {
  731.       while(this.mutexpiece == true)
  732.       {
  733.       }
  734.       this.mutexpiece = true;
  735.       if(this.active.x > 0)
  736.       {
  737.          var _loc2_ = this.active.GetAdjacentLeft();
  738.          if(_loc2_ == undefined)
  739.          {
  740.             this.active.AddPosition(-1,0);
  741.          }
  742.       }
  743.       this.mutexpiece = false;
  744.    }
  745.    function KeyUp()
  746.    {
  747.       this.active.AddRotation(-1);
  748.    }
  749.    function KeyDown()
  750.    {
  751.       this.active.AddRotation(1);
  752.    }
  753.    function KeyDrop()
  754.    {
  755.       this.Land();
  756.    }
  757.    function KeyAccel()
  758.    {
  759.       if(this.timemode != 3)
  760.       {
  761.          this.timemode = 1;
  762.       }
  763.    }
  764.    function KeyUnAccel()
  765.    {
  766.       this.accel = 0;
  767.       if(this.timemode != 3)
  768.       {
  769.          this.timemode = 0;
  770.       }
  771.    }
  772.    function KeyHold()
  773.    {
  774.       if(this.timemode != 3)
  775.       {
  776.          this.timemode = 2;
  777.          if(this.soundmode == 0)
  778.          {
  779.             var _loc2_ = 0;
  780.             while(_loc2_ < this.bgm.length)
  781.             {
  782.                this.bgm[_loc2_].SetVolume(15);
  783.                _loc2_ = _loc2_ + 1;
  784.             }
  785.             this.soundmode = 1;
  786.             this.callback.whiteout = this.TickWhiteOut;
  787.             this.sound.attachSound("HoldStart");
  788.             this.sound.setVolume(100);
  789.             this.sound.start();
  790.             this.sound.onSoundComplete = function()
  791.             {
  792.                if(this.GetTimeLeft() < 60)
  793.                {
  794.                   this.attachSound("HoldLoopAlt");
  795.                }
  796.                else
  797.                {
  798.                   this.attachSound("HoldLoop");
  799.                }
  800.                this.start();
  801.                this.onSoundComplete = function()
  802.                {
  803.                   this.start();
  804.                };
  805.             };
  806.          }
  807.       }
  808.    }
  809.    function KeyUnHold()
  810.    {
  811.       if(this.timemode == 3)
  812.       {
  813.          return undefined;
  814.       }
  815.       this.timemode = 0;
  816.       _root.whiteout._alpha = 0;
  817.       if(this.soundmode == 1)
  818.       {
  819.          this.soundmode = 0;
  820.          this.callback.mixout = this.TickMixOut;
  821.       }
  822.    }
  823.    function KeyDrill()
  824.    {
  825.       if(this.playmode != "bare" && this.playmode != "sculptor" && this.playmode != "leveler")
  826.       {
  827.          this.UseClaw(2);
  828.       }
  829.    }
  830.    function KeySculptor()
  831.    {
  832.       if(this.playmode != "bare" && this.playmode != "driller" && this.playmode != "leveler")
  833.       {
  834.          this.UseClaw(1);
  835.       }
  836.    }
  837.    function KeyLeveler()
  838.    {
  839.       if(this.playmode != "bare" && this.playmode != "sculptor" && this.playmode != "driller")
  840.       {
  841.          this.UseClaw(0);
  842.       }
  843.    }
  844.    function TickClawOut()
  845.    {
  846.       var _loc2_ = undefined;
  847.       var _loc4_ = -20;
  848.       _loc2_ = this.clawclip._x + this.clawspeed * (this.active.x + 1) * 0.5;
  849.       var _loc3_ = this.active.GlobalX(this.active.x);
  850.       if(_loc2_ >= _loc3_ + _loc4_)
  851.       {
  852.          _loc2_ = _loc3_ + _loc4_;
  853.          this.callback.claw = this.TickClawIn;
  854.          this.active.LoadSec(this.active.GetLocalSec(3),this.clawqueue);
  855.       }
  856.       this.clawclip._x = _loc2_;
  857.    }
  858.    function TickClawIn()
  859.    {
  860.       var _loc2_ = undefined;
  861.       _loc2_ = this.clawclip._x - this.clawspeed * (this.active.x + 1) * 0.5;
  862.       if(_loc2_ <= 66)
  863.       {
  864.          _loc2_ = 66;
  865.          delete this.callback.claw;
  866.       }
  867.       this.clawclip._x = _loc2_;
  868.    }
  869.    function TickTimer()
  870.    {
  871.       var _loc3_ = undefined;
  872.       if(this.playmode == "speed")
  873.       {
  874.          _loc3_ = this.GetTimeLeft();
  875.          if(_loc3_ <= 0)
  876.          {
  877.             this.End("time");
  878.          }
  879.       }
  880.       else
  881.       {
  882.          _loc3_ = this.GetTimeUsed();
  883.       }
  884.       var _loc4_ = Math.floor(_loc3_ / 60) + ":" + _root.str_lpad(_loc3_ % 60);
  885.       _root.texttime.text = _loc4_;
  886.    }
  887.    function TickMixOut()
  888.    {
  889.       var _loc3_ = 3;
  890.       var _loc4_ = this.sound.getVolume() - _loc3_;
  891.       if(_loc4_ < 0)
  892.       {
  893.          _loc4_ = 0;
  894.       }
  895.       this.sound.setVolume(_loc4_);
  896.       var _loc5_ = "mixout: ";
  897.       var _loc2_ = 0;
  898.       while(_loc2_ <= 100)
  899.       {
  900.          if(_loc2_ <= _loc4_)
  901.          {
  902.             _loc5_ += "*";
  903.          }
  904.          _loc2_ += _loc3_;
  905.       }
  906.       if(_loc4_ == 0)
  907.       {
  908.          delete this.callback.mixout;
  909.          this.sound.stop();
  910.       }
  911.       _loc2_ = 0;
  912.       while(_loc2_ < this.bgm.length)
  913.       {
  914.          this.bgm[_loc2_].AddVolume(_loc3_);
  915.          _loc2_ = _loc2_ + 1;
  916.       }
  917.    }
  918.    function TickPointFade()
  919.    {
  920.       var _loc2_ = 0;
  921.       for(var _loc3_ in this.pointsclist)
  922.       {
  923.          this.pointsclist[_loc3_].text._y -= 5;
  924.          if(this.pointsclist[_loc3_].text._y < -20)
  925.          {
  926.             this.pointsclist[_loc3_].text._alpha -= 5;
  927.          }
  928.          if(this.pointsclist[_loc3_].text._y < -120)
  929.          {
  930.             this.pointsclist[_loc3_].removeMovieClip();
  931.             delete this.pointsclist[_loc3_];
  932.          }
  933.          _loc2_ = _loc2_ + 1;
  934.       }
  935.       if(_loc2_ == 0)
  936.       {
  937.          delete this.callback.pointfade;
  938.       }
  939.    }
  940.    function TickFrame()
  941.    {
  942.       switch(this.timemode)
  943.       {
  944.          case 0:
  945.             this.holdmeter += this.holdregen;
  946.             if(this.holdmeter > this.holdmax)
  947.             {
  948.                this.holdmeter = this.holdmax;
  949.             }
  950.             this.holdclip._width = this.holdmeter / this.holdmax * 171;
  951.             break;
  952.          case 1:
  953.             this.accel += this.accelrate;
  954.             if(this.accel > this.accelmax)
  955.             {
  956.                this.accel = this.accelmax;
  957.             }
  958.             break;
  959.          case 2:
  960.             this.holdmeter -= 1;
  961.             if(this.holdmeter <= 0)
  962.             {
  963.                this.holdmeter = 0;
  964.                this.KeyUnHold();
  965.             }
  966.             this.holdclip._width = this.holdmeter / this.holdmax * 171;
  967.       }
  968.    }
  969.    function TickSmoothFall()
  970.    {
  971.       if(this.timemode < 2)
  972.       {
  973.          this.tickcount += 1 + this.accel;
  974.          var _loc2_ = this.tickcount % this.speedbase;
  975.          if(_loc2_ < this.lastmod)
  976.          {
  977.             this.Turn();
  978.          }
  979.          else
  980.          {
  981.             var _loc3_ = this.active.GlobalY(this.active.y) + Math.floor(_loc2_ / this.speedbase * this.psizey);
  982.             this.active.clip._y = _loc3_;
  983.             this.clawclip._y = _loc3_;
  984.          }
  985.          this.lastmod = _loc2_;
  986.       }
  987.    }
  988.    function TickFlawFlash()
  989.    {
  990.       this.flawtimetick = this.flawtimetick + 1;
  991.       if(this.flawtimetick >= this.flawtime)
  992.       {
  993.          this.flawtimetick = 0;
  994.          this.flawcount = this.flawcount + 1;
  995.          this.flawpiece.Toggle();
  996.          this.flawpieceinv.Toggle();
  997.          if(this.flawcount >= this.flawlimit)
  998.          {
  999.             this.flawpiece.Hide();
  1000.             this.flawpieceinv.Hide();
  1001.             this.flawcount = 0;
  1002.             delete this.callback.flawflash;
  1003.          }
  1004.       }
  1005.    }
  1006.    function TickWhiteOut()
  1007.    {
  1008.       if(this.soundmode == 0)
  1009.       {
  1010.          _root.whiteout._alpha = 0;
  1011.          delete this.callback.whiteout;
  1012.       }
  1013.       var _loc3_ = _root.whiteout._alpha;
  1014.       _loc3_ += 9;
  1015.       if(_loc3_ > 100)
  1016.       {
  1017.          _loc3_ = 30;
  1018.          delete this.callback.whiteout;
  1019.       }
  1020.       _root.whiteout._alpha = _loc3_;
  1021.    }
  1022.    function TickJumpFall()
  1023.    {
  1024.       if(this.timemode < 2)
  1025.       {
  1026.          this.tickcount += 1;
  1027.          var _loc2_ = this.tickcount % this.speedbase;
  1028.          if(_loc2_ < this.lastmod)
  1029.          {
  1030.             this.Turn();
  1031.             var _loc3_ = this.active.GlobalY(this.active.y) + Math.floor(_loc2_ / this.speedbase * this.psizey);
  1032.             this.active.clip._y = _loc3_;
  1033.             this.clawclip._y = _loc3_;
  1034.          }
  1035.          this.lastmod = _loc2_;
  1036.       }
  1037.    }
  1038. }
  1039.