home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / casual_gameplay_escape.swf / scripts / DefineSprite_540_shotcontrol / frame_31 / DoAction.as
Text File  |  2008-09-05  |  13KB  |  389 lines

  1. player = this._parent.player;
  2. curspot = this._parent.player.currentspot;
  3. object = this._parent.getInstanceAtDepth(curspot);
  4. if(object.tempcooloff)
  5. {
  6.    object.tempcooloff = false;
  7.    object = undefined;
  8. }
  9. level = this._parent.curlevel;
  10. divisor = 29;
  11. lasers = 0;
  12. sl = 1;
  13. while(sl <= 105)
  14. {
  15.    objectsl = this._parent.getInstanceAtDepth(sl);
  16.    if(objectsl == this._parent["shotswitch" + sl])
  17.    {
  18.       if(objectsl.switched == true)
  19.       {
  20.          objectsl.laser();
  21.          lasers++;
  22.       }
  23.    }
  24.    sl++;
  25. }
  26. if(lasers > 0)
  27. {
  28. }
  29. if(object.isswitch || this._parent.levels[this._parent.curlevel][curspot] == 2)
  30. {
  31.    object = undefined;
  32. }
  33. if(this._parent.thwomp.going)
  34. {
  35.    this._parent.thwomp._y = this._parent.pa[this._parent.thwomp.curposition][1];
  36.    if(this._parent.levels[lvl][this._parent.thwomp.curposition + 15] != 3 && this._parent.thwomp.curposition <= 105)
  37.    {
  38.       this._parent.thwomp.curposition += 15;
  39.    }
  40. }
  41. if(this._parent.thwomp.waitforcontrol)
  42. {
  43.    this._parent.thwomp.going = true;
  44. }
  45. if(level == 1)
  46. {
  47.    maxmod = 5;
  48. }
  49. if(level == 2)
  50. {
  51.    maxmod = 10;
  52. }
  53. if(level == 3)
  54. {
  55.    maxmod = 60;
  56. }
  57. if(player.dead != true)
  58. {
  59.    this.onEnterFrame = undefined;
  60.    player._x = this._parent.pa[curspot][0];
  61.    player._y = this._parent.pa[curspot][1];
  62. }
  63. else if(this._parent.shotfader1._currentframe == 1)
  64. {
  65.    this.started = false;
  66.    this.gotoAndStop(29);
  67.    if(player.fading)
  68.    {
  69.       if(level == 2)
  70.       {
  71.          this._parent._parent.trimask.play();
  72.          this._parent._parent._parent.slider2.play();
  73.          this._parent._parent._parent.al2.blinkmode = "flashgreen";
  74.          _root.slide2open = true;
  75.          _root.savedata();
  76.       }
  77.       if(level == 3)
  78.       {
  79.          this._parent._parent.trimask.play();
  80.          this._parent._parent._parent.slider3.play();
  81.          this._parent._parent._parent.al3.blinkmode = "flashgreen";
  82.          _root.slide3open = true;
  83.          _root.savedata();
  84.       }
  85.       if(level == 4)
  86.       {
  87.          this._parent._parent.trimask.play();
  88.          this._parent._parent._parent.slider1.play();
  89.          this._parent._parent._parent.slider2.play();
  90.          this._parent._parent._parent.slider3.play();
  91.          _root.slide1open = false;
  92.          _root.slide2open = false;
  93.          _root.slide3open = false;
  94.          this._parent._parent._parent.al1.blinkmode = "flashgreen";
  95.          this._parent._parent._parent.al2.blinkmode = "flashgreen";
  96.          this._parent._parent._parent.al3.blinkmode = "flashgreen";
  97.          _root.puzze8solved = true;
  98.          _root.savedata();
  99.       }
  100.    }
  101.    this._parent.shotfader1.play();
  102.    this._parent.shotfader2.play();
  103.    this._parent.shotfader3.play();
  104. }
  105. else if(this._parent.shotfader1._currentframe == 50)
  106. {
  107.    this._parent.playin = false;
  108.    this._parent.levelspawn(level);
  109.    this.onEnterFrame = undefined;
  110. }
  111. this.shoot = function()
  112. {
  113.    player.shoot();
  114.    object.tempcooloff = true;
  115. };
  116. this.goright = function()
  117. {
  118.    player.facing = "right";
  119.    player._xscale = 100;
  120.    if(player.getDepth() != 106)
  121.    {
  122.       player.swapDepths(106);
  123.       player.onRelease = undefined;
  124.    }
  125.    if((curspot + 1) % 15 <= maxmod && this._parent.levels[level][curspot + 1] != 3 && this._parent.thwomp.curposition != curspot + 1 && this._parent.thwomp.curposition != curspot + 16)
  126.    {
  127.       bc = 1;
  128.       while(bc <= 7)
  129.       {
  130.          if(bc == 0)
  131.          {
  132.          }
  133.          if(this._parent.levels[level][curspot + 1 + bc * 15] == 3 || this._parent.thwomp.curposition == curspot + 1 + (bc + 1) * 15 || curspot + 1 + bc * 15 > 105)
  134.          {
  135.             oldspot = curspot;
  136.             curspot = curspot + 1 + (bc - 1) * 15;
  137.             if(this._parent.getInstanceAtDepth(curspot) == this._parent["shotdoor" + curspot])
  138.             {
  139.                this._parent["shotdoor" + curspot].door();
  140.             }
  141.             this.diff = bc;
  142.             bc = 8;
  143.             player.currentspot = curspot;
  144.             this.divx = (this._parent.pa[curspot][0] - this._parent.pa[oldspot][0]) / divisor;
  145.             this.divy = (this._parent.pa[curspot][1] - this._parent.pa[oldspot][1]) / divisor;
  146.             if(curspot == oldspot + 1)
  147.             {
  148.                if(!player.shotguy.running)
  149.                {
  150.                   player.run();
  151.                }
  152.                this.onEnterFrame = function()
  153.                {
  154.                   player._x += this.divx;
  155.                   player._y += this.divy;
  156.                };
  157.             }
  158.             else
  159.             {
  160.                player.jump();
  161.                this.framecounter = 0;
  162.                this.onEnterFrame = function()
  163.                {
  164.                   this.framecounter = this.framecounter + 1;
  165.                   player._x += this.divx;
  166.                   player._y = this._parent.pa[oldspot][1] + this.divy * framecounter - (8 * Math.pow(this.diff - 1,1.3200000000000003) + 12) * Math.sin(3.141592653589793 / divisor * this.framecounter);
  167.                };
  168.             }
  169.          }
  170.          bc++;
  171.       }
  172.    }
  173.    else
  174.    {
  175.       player.stand();
  176.       this.standcount = this.standcount + 1;
  177.    }
  178. };
  179. this.goleft = function()
  180. {
  181.    player.facing = "left";
  182.    player._xscale = -100;
  183.    if((curspot - 1) % 15 != 0 && this._parent.levels[level][curspot - 1] != 3 && this._parent.thwomp.curposition != curspot - 1 && this._parent.thwomp.curposition != curspot + 14)
  184.    {
  185.       bc = 1;
  186.       while(bc <= 7)
  187.       {
  188.          if(bc == 0)
  189.          {
  190.          }
  191.          if(this._parent.levels[level][curspot - 1 + bc * 15] == 3 || this._parent.thwomp.curposition == curspot - 1 + (bc + 1) * 15 || curspot + 1 + bc * 15 > 105)
  192.          {
  193.             oldspot = curspot;
  194.             curspot = curspot - 1 + (bc - 1) * 15;
  195.             this.diff = bc;
  196.             bc = 8;
  197.             player.currentspot = curspot;
  198.             if(this._parent.getInstanceAtDepth(curspot) == this._parent["shotdoor" + curspot])
  199.             {
  200.                this._parent["shotdoor" + curspot].door();
  201.             }
  202.             this.divx = (this._parent.pa[curspot][0] - this._parent.pa[oldspot][0]) / divisor;
  203.             this.divy = (this._parent.pa[curspot][1] - this._parent.pa[oldspot][1]) / divisor;
  204.             if(curspot == oldspot - 1)
  205.             {
  206.                if(!player.shotguy.running)
  207.                {
  208.                   player.run();
  209.                }
  210.                this.onEnterFrame = function()
  211.                {
  212.                   player._x += this.divx;
  213.                   player._y += this.divy;
  214.                };
  215.             }
  216.             else
  217.             {
  218.                player.jump();
  219.                this.framecounter = 0;
  220.                this.onEnterFrame = function()
  221.                {
  222.                   this.framecounter = this.framecounter + 1;
  223.                   player._x += this.divx;
  224.                   player._y = this._parent.pa[oldspot][1] + this.divy * framecounter - (8 * Math.pow(this.diff - 1,1.3200000000000003) + 12) * Math.sin(3.141592653589793 / divisor * this.framecounter);
  225.                };
  226.             }
  227.          }
  228.          bc++;
  229.       }
  230.    }
  231.    else
  232.    {
  233.       player.stand();
  234.       this.standcount = this.standcount + 1;
  235.    }
  236. };
  237. this.jump = function()
  238. {
  239.    if(player.facing == "left")
  240.    {
  241.       offset = -1;
  242.    }
  243.    else
  244.    {
  245.       offset = 1;
  246.    }
  247.    jumptype = 0;
  248.    if((this._parent.levels[level][curspot + offset] == 3 || this._parent.thwomp.curposition == curspot + offset + 15) && this._parent.thwomp.curposition != curspot + offset && this._parent.levels[level][curspot + offset - 15] != 3)
  249.    {
  250.       if(player.facing == "right" && (curspot + 1) % 15 <= maxmod || player.facing == "left" && curspot - 1 != 0 && (curspot - 1) % 15 != 0)
  251.       {
  252.          this.jumptype = 1;
  253.       }
  254.       else
  255.       {
  256.          player.stand();
  257.          this.standcount = this.standcount + 1;
  258.       }
  259.    }
  260.    if(this._parent.levels[level][curspot + offset] != 3 && this._parent.thwomp.curposition != curspot + offset + 15 && this._parent.levels[level][curspot + offset * 2] != 3 && this._parent.thwomp.curposition != curspot + offset * 2 + 15)
  261.    {
  262.       if(player.facing == "right" && (curspot + 1) % 15 <= maxmod || player.facing == "left" && curspot - 1 != 0 && (curspot - 1) % 15 != 0)
  263.       {
  264.          if(player.facing == "right" && (curspot + 2) % 15 <= maxmod || player.facing == "left" && curspot - 2 != 0 && (curspot - 2) % 15 != 0)
  265.          {
  266.             this.jumptype = 2;
  267.          }
  268.          else
  269.          {
  270.             if(player.facing == "right")
  271.             {
  272.                this.goright();
  273.             }
  274.             if(player.facing == "left")
  275.             {
  276.                this.goleft();
  277.             }
  278.          }
  279.       }
  280.       else
  281.       {
  282.          player.stand();
  283.          this.standcount = this.standcount + 1;
  284.       }
  285.    }
  286.    if(jumptype == 0)
  287.    {
  288.       if(player.facing == "right")
  289.       {
  290.          this.goright();
  291.       }
  292.       if(player.facing == "left")
  293.       {
  294.          this.goleft();
  295.       }
  296.    }
  297.    if(jumptype == 1)
  298.    {
  299.       oldspot = curspot;
  300.       this.curspot = this.curspot + offset - 15;
  301.       if(this._parent.getInstanceAtDepth(curspot) == this._parent["shotdoor" + curspot])
  302.       {
  303.          this._parent["shotdoor" + curspot].door();
  304.       }
  305.       player.currentspot = curspot;
  306.       this.divx = (this._parent.pa[curspot][0] - this._parent.pa[oldspot][0]) / divisor;
  307.       this.divy = (this._parent.pa[curspot][1] - this._parent.pa[oldspot][1]) / divisor;
  308.       player.jump();
  309.       this.framecounter = 0;
  310.       this.onEnterFrame = function()
  311.       {
  312.          this.framecounter = this.framecounter + 1;
  313.          player._x += this.divx;
  314.          player._y = this._parent.pa[oldspot][1] + this.divy * framecounter - 40 * Math.sin(3.141592653589793 / divisor * this.framecounter);
  315.       };
  316.    }
  317.    if(jumptype == 2)
  318.    {
  319.       bc = 1;
  320.       while(bc <= 7)
  321.       {
  322.          if(this._parent.levels[level][curspot + offset * 2 + bc * 15] == 3 || this._parent.thwomp.curposition == curspot + offset * 2 + (bc + 1) * 15 || curspot + offset * 2 + bc * 15 > 105)
  323.          {
  324.             oldspot = curspot;
  325.             curspot = curspot + offset * 2 + (bc - 1) * 15;
  326.             this.diff = bc;
  327.             bc = 8;
  328.             player.currentspot = curspot;
  329.             if(this._parent.getInstanceAtDepth(curspot) == this._parent["shotdoor" + curspot])
  330.             {
  331.                this._parent["shotdoor" + curspot].door();
  332.             }
  333.             this.divx = (this._parent.pa[curspot][0] - this._parent.pa[oldspot][0]) / divisor;
  334.             this.divy = (this._parent.pa[curspot][1] - this._parent.pa[oldspot][1]) / divisor;
  335.             player.jump();
  336.             this.framecounter = 0;
  337.             this.onEnterFrame = function()
  338.             {
  339.                this.framecounter = this.framecounter + 1;
  340.                player._x += this.divx;
  341.                player._y = this._parent.pa[oldspot][1] + this.divy * framecounter - (8 * Math.pow(this.diff - 1,1.3200000000000003) + 12) * Math.sin(3.141592653589793 / divisor * this.framecounter);
  342.             };
  343.          }
  344.          bc++;
  345.       }
  346.    }
  347. };
  348. if(player.dead != true)
  349. {
  350.    if(this._parent.levels[level][curspot] == 1 || object == player && this.started != true || object == undefined || object == player && player.facing == "left")
  351.    {
  352.       if(object.arrowinner._currentframe == 1 || object == player && this.started != true || object == undefined && player.facing == "right")
  353.       {
  354.          this.started = true;
  355.          goright();
  356.       }
  357.       else if(object.arrowinner._currentframe == 2)
  358.       {
  359.          jump();
  360.       }
  361.       else if(object.arrowinner._currentframe == 3 || object == undefined && player.facing == "left" || object == player && player.facing == "left")
  362.       {
  363.          goleft();
  364.       }
  365.       else if(object.arrowinner._currentframe == 4)
  366.       {
  367.          shoot();
  368.       }
  369.    }
  370.    if(this._parent.levels[level][curspot] == 7 && object.isdoor && player.fading != true)
  371.    {
  372.       player.stand();
  373.       player.fadeout();
  374.       object.door();
  375.    }
  376.    else if(player.fading == true)
  377.    {
  378.       player.kill();
  379.       this._parent.curlevel += 1;
  380.       _root.curlevel = this._parent.curlevel;
  381.       _root.savedata();
  382.    }
  383.    if(this.standcount >= 3)
  384.    {
  385.       player.kill();
  386.    }
  387.    this.gotoAndPlay(2);
  388. }
  389.