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

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