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

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