home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / david.swf / scripts / __Packages / Slange.as < prev    next >
Encoding:
Text File  |  2007-03-28  |  8.2 KB  |  307 lines

  1. class Slange extends Figur
  2. {
  3.    var mc;
  4.    var dybde;
  5.    var iLufta;
  6.    var skjerm_y;
  7.    var hogrevendt;
  8.    var nesteFrame;
  9.    var brett_x;
  10.    var bredde;
  11.    var brett_y;
  12.    var hogde;
  13.    var i;
  14.    var underlag;
  15.    var roligH = 1;
  16.    var roligV = 10;
  17.    var angripH = 20;
  18.    var angripV = 30;
  19.    var angriper = false;
  20.    var forsteKnockoutH = 120;
  21.    var sisteKnockoutH = 123;
  22.    var forsteFlatH = 140;
  23.    var sisteFlatH = 148;
  24.    var forsteKnockoutV = 130;
  25.    var sisteKnockoutV = 133;
  26.    var forsteFlatV = 150;
  27.    var sisteFlatV = 158;
  28.    var knock = false;
  29.    var flat = false;
  30.    var forsteSlaaH = 40;
  31.    var sisteSlaaH = 78;
  32.    var forsteSlaaV = 80;
  33.    var sisteSlaaV = 118;
  34.    var slaar = false;
  35.    function Slange(mc, brett_x, brett_y, bredde, hogde)
  36.    {
  37.       super(mc,brett_x,brett_y,bredde,hogde);
  38.       Figur.figurliste.push(this);
  39.       this.mc.swapDepths(4200 + Figur.figurliste.length);
  40.       this.dybde = this.mc.getDepth();
  41.       this.iLufta = true;
  42.       this.aks_y = 0.7;
  43.    }
  44.    function knockout()
  45.    {
  46.       if(!this.knock)
  47.       {
  48.          this.knock = true;
  49.          _root.hit.start();
  50.          if(Figur.helt.stokkeslaar || Figur.helt.kraftspark)
  51.          {
  52.             this.skjerm_y -= 15;
  53.             this.iLufta = true;
  54.          }
  55.          else
  56.          {
  57.             this.fart_y -= 10;
  58.          }
  59.          this.iLufta = true;
  60.          if(this.hogrevendt)
  61.          {
  62.             this.nesteFrame = this.posisjon = this.forsteKnockoutH;
  63.          }
  64.          else
  65.          {
  66.             this.nesteFrame = this.posisjon = this.forsteKnockoutV;
  67.          }
  68.       }
  69.    }
  70.    function flatUt()
  71.    {
  72.       this.flat = true;
  73.       _root.hit.start();
  74.       if(this.hogrevendt)
  75.       {
  76.          this.nesteFrame = this.posisjon = this.forsteFlatH;
  77.       }
  78.       else
  79.       {
  80.          this.nesteFrame = this.posisjon = this.forsteFlatV;
  81.       }
  82.    }
  83.    function vedTreff()
  84.    {
  85.       if(Figur.helt.sparkar || Figur.helt.slaar || Figur.helt.stokkeslaar || Figur.helt.feirer)
  86.       {
  87.          this.knockout();
  88.       }
  89.       else if(!Figur.helt.knock && !Figur.helt.flat)
  90.       {
  91.          Figur.helt.knockout();
  92.          this.slag();
  93.       }
  94.    }
  95.    function slag()
  96.    {
  97.       this.slaar = true;
  98.       _root.slyngelyd.start();
  99.       if(this.hogrevendt)
  100.       {
  101.          this.nesteFrame = this.posisjon = this.forsteSlaaH;
  102.       }
  103.       else
  104.       {
  105.          this.nesteFrame = this.posisjon = this.forsteSlaaV;
  106.       }
  107.    }
  108.    function visRiktigFrame()
  109.    {
  110.       if(!this.aktiv)
  111.       {
  112.          this.bliUsynlig();
  113.       }
  114.       else
  115.       {
  116.          if(Math.abs(this.brett_x + this.bredde / 2 - (Figur.helt.brett_x + Figur.helt.bredde / 2)) < 200)
  117.          {
  118.             if(Math.abs(this.brett_y + this.hogde - (Figur.helt.brett_y + Figur.helt.hogde)) < 100 && !Figur.helt.flat && !Figur.helt.knock)
  119.             {
  120.                this.angriper = true;
  121.             }
  122.             else
  123.             {
  124.                this.angriper = false;
  125.             }
  126.          }
  127.          else
  128.          {
  129.             this.angriper = false;
  130.          }
  131.          if(!this.knock)
  132.          {
  133.             if(!this.slaar)
  134.             {
  135.                if(!this.flat)
  136.                {
  137.                   if(!this.angriper)
  138.                   {
  139.                      if(this.brett_x + this.bredde / 2 > Figur.helt.brett_x + Figur.helt.bredde / 2)
  140.                      {
  141.                         this.hogrevendt = true;
  142.                         this.nesteFrame = this.roligH;
  143.                      }
  144.                      else
  145.                      {
  146.                         this.hogrevendt = false;
  147.                         this.nesteFrame = this.roligV;
  148.                      }
  149.                   }
  150.                   else if(this.hogrevendt)
  151.                   {
  152.                      this.nesteFrame = this.angripH;
  153.                      this.brett_x -= 5;
  154.                      this.i = 0;
  155.                      while(this.i < Figur.platformliste.length)
  156.                      {
  157.                         if(Figur.platformliste[this.i].treffVegg(this))
  158.                         {
  159.                            if(Figur.platformliste[this.i] != this.underlag)
  160.                            {
  161.                               this.brett_x += 5;
  162.                               break;
  163.                            }
  164.                         }
  165.                         this.i = this.i + 1;
  166.                      }
  167.                   }
  168.                   else
  169.                   {
  170.                      this.nesteFrame = this.angripV;
  171.                      this.brett_x += 5;
  172.                      this.i = 0;
  173.                      while(this.i < Figur.platformliste.length)
  174.                      {
  175.                         if(Figur.platformliste[this.i].treffVegg(this))
  176.                         {
  177.                            if(Figur.platformliste[this.i] != this.underlag)
  178.                            {
  179.                               this.brett_x -= 5;
  180.                               break;
  181.                            }
  182.                         }
  183.                         this.i = this.i + 1;
  184.                      }
  185.                   }
  186.                }
  187.             }
  188.          }
  189.       }
  190.       if(this.slaar)
  191.       {
  192.          if(this.hogrevendt)
  193.          {
  194.             if(this.mc._currentframe < this.sisteSlaaH)
  195.             {
  196.                this.posisjon += 1;
  197.                this.nesteFrame = this.posisjon;
  198.             }
  199.             else
  200.             {
  201.                this.slaar = false;
  202.             }
  203.          }
  204.          else if(this.mc._currentframe < this.sisteSlaaV)
  205.          {
  206.             this.posisjon += 1;
  207.             this.nesteFrame = this.posisjon;
  208.          }
  209.          else
  210.          {
  211.             this.slaar = false;
  212.          }
  213.       }
  214.       if(this.flat)
  215.       {
  216.          if(!this.hogrevendt)
  217.          {
  218.             if(this.mc._currentframe < this.sisteFlatV)
  219.             {
  220.                this.posisjon += 1;
  221.                this.nesteFrame = this.posisjon;
  222.             }
  223.             else
  224.             {
  225.                this.flat = false;
  226.             }
  227.          }
  228.          else if(this.mc._currentframe < this.sisteFlatH)
  229.          {
  230.             this.posisjon += 1;
  231.             this.nesteFrame = this.posisjon;
  232.          }
  233.          else
  234.          {
  235.             this.flat = false;
  236.          }
  237.       }
  238.       if(this.knock)
  239.       {
  240.          if(!this.hogrevendt)
  241.          {
  242.             if(this.mc._currentframe < this.sisteKnockoutV)
  243.             {
  244.                this.posisjon += 1;
  245.                this.nesteFrame = this.posisjon;
  246.                this.brett_x -= 8;
  247.             }
  248.             else if(!this.iLufta)
  249.             {
  250.                this.knock = false;
  251.                this.flatUt();
  252.             }
  253.             else
  254.             {
  255.                this.nesteFrame = this.sisteKnockoutV;
  256.                this.brett_x -= 8;
  257.             }
  258.             this.i = 0;
  259.             while(this.i < Figur.platformliste.length)
  260.             {
  261.                if(Figur.platformliste[this.i].treffVegg(this))
  262.                {
  263.                   if(Figur.platformliste[this.i] != this.underlag)
  264.                   {
  265.                      this.brett_x += 5;
  266.                      break;
  267.                   }
  268.                }
  269.                this.i = this.i + 1;
  270.             }
  271.          }
  272.          else
  273.          {
  274.             if(this.mc._currentframe < this.sisteKnockoutH)
  275.             {
  276.                this.posisjon += 1;
  277.                this.nesteFrame = this.posisjon;
  278.                this.brett_x += 5;
  279.             }
  280.             else if(!this.iLufta)
  281.             {
  282.                this.knock = false;
  283.                this.flatUt();
  284.             }
  285.             else
  286.             {
  287.                this.nesteFrame = this.sisteKnockoutH;
  288.                this.brett_x += 5;
  289.             }
  290.             this.i = 0;
  291.             while(this.i < Figur.platformliste.length)
  292.             {
  293.                if(Figur.platformliste[this.i].treffVegg(this))
  294.                {
  295.                   if(Figur.platformliste[this.i] != this.underlag)
  296.                   {
  297.                      this.brett_x -= 5;
  298.                      break;
  299.                   }
  300.                }
  301.                this.i = this.i + 1;
  302.             }
  303.          }
  304.       }
  305.    }
  306. }
  307.