home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / Easter_Eggs.swf / scripts / __Packages / com / novelgames / flashgames / eggsAS2 / Game.as < prev    next >
Text File  |  2008-09-04  |  21KB  |  641 lines

  1. class com.novelgames.flashgames.eggsAS2.Game extends com.novelgames.flashgames.commonAS2.CommonGame
  2. {
  3.    static var DOWN = 1;
  4.    static var LEFTDOWN = 2;
  5.    static var RIGHTDOWN = 3;
  6.    function Game()
  7.    {
  8.       super();
  9.       this.gameOverDialog.__proto__ = com.novelgames.flashgames.eggsAS2.GameOverDialog.prototype;
  10.       this.lifePie.__proto__ = com.novelgames.flashgames.eggsAS2.LifePie.prototype;
  11.       this.scoreText.__proto__ = com.novelgames.flashgames.commonAS2.NewTextField.prototype;
  12.       this.levelText.__proto__ = com.novelgames.flashgames.commonAS2.NewTextField.prototype;
  13.       this.eggsHolder.__proto__ = com.novelgames.flashgames.commonAS2.NewMovieClip.prototype;
  14.       var _loc4_ = undefined;
  15.       var _loc3_ = undefined;
  16.       var _loc5_ = undefined;
  17.       this.eggs = new Array();
  18.       this.depth = 0;
  19.       this.occupiers = new Array();
  20.       this.chosenEgg = null;
  21.       this.isSwapping = false;
  22.       this.swappingEgg1 = null;
  23.       this.swappingEgg2 = null;
  24.       this.isUnswapping = false;
  25.       this.unswappingEgg1 = null;
  26.       this.unswappingEgg2 = null;
  27.       this.isDestroying = false;
  28.       this.destroyingEggs = new Array();
  29.       this.isDropping = false;
  30.       this.droppingEggs = new Array();
  31.       this.__set__level(1);
  32.       this.life = com.novelgames.flashgames.eggsAS2.Config.LIFE_INITIAL;
  33.       this.__set__score(0);
  34.       this.combo = 0;
  35.       this.decreaseRate = com.novelgames.flashgames.eggsAS2.Config.LEVEL_DECREASERATES[0];
  36.       this.decreaseCount = 0;
  37.       this.gameStarted = true;
  38.       _loc4_ = 0;
  39.       while(_loc4_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  40.       {
  41.          this.occupiers[_loc4_] = new Array(com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y);
  42.          _loc3_ = 0;
  43.          while(_loc3_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y)
  44.          {
  45.             this.occupiers[_loc4_][_loc3_] = null;
  46.             _loc3_ = _loc3_ + 1;
  47.          }
  48.          _loc4_ = _loc4_ + 1;
  49.       }
  50.       _loc4_ = 0;
  51.       while(_loc4_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y)
  52.       {
  53.          _loc3_ = 0;
  54.          while(_loc3_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  55.          {
  56.             _loc5_ = this.eggsHolder.createMovie("Egg");
  57.             this.eggs[this.depth] = _loc5_;
  58.             this.eggs[this.depth].initialize(this.getRealX(_loc3_,_loc4_),this.getRealY(_loc3_,_loc4_),Math.floor(Math.random() * com.novelgames.flashgames.eggsAS2.Config.EGG_TYPES));
  59.             this.eggsHolder.addChild(this.eggs[this.depth]);
  60.             this.setEggXY(this.eggs[this.depth],_loc3_,_loc4_);
  61.             this.depth = this.depth + 1;
  62.             _loc3_ = _loc3_ + 1;
  63.          }
  64.          _loc4_ = _loc4_ + 1;
  65.       }
  66.       this.soundChoose = this.createSound("SoundChoose");
  67.       this.soundSwap = this.createSound("SoundSwap");
  68.       this.soundGroup = this.createSound("SoundGroup");
  69.       this.soundGameOver = this.createSound("SoundGameOver");
  70.       this.lastDecreaseTime = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
  71.       this.timer = new com.novelgames.flashgames.commonAS2.NewTimer(1,0);
  72.       this.timer.addEventListener(com.novelgames.flashgames.commonAS2.TimerEvent.TIMER,this,"onTime");
  73.       this.timer.start();
  74.    }
  75.    function set score(score)
  76.    {
  77.       this.__score = score;
  78.       this.scoreText.text = score.toString();
  79.    }
  80.    function get score()
  81.    {
  82.       return this.__score;
  83.    }
  84.    function set level(level)
  85.    {
  86.       this.__level = level;
  87.       this.levelText.text = level.toString();
  88.    }
  89.    function get level()
  90.    {
  91.       return this.__level;
  92.    }
  93.    function getRealX(x, y)
  94.    {
  95.       return x * com.novelgames.flashgames.eggsAS2.Config.EGG_WIDTH;
  96.    }
  97.    function getRealY(x, y)
  98.    {
  99.       if(x % 2 == 0)
  100.       {
  101.          return y * com.novelgames.flashgames.eggsAS2.Config.EGG_HEIGHT;
  102.       }
  103.       return y * com.novelgames.flashgames.eggsAS2.Config.EGG_HEIGHT + com.novelgames.flashgames.eggsAS2.Config.EGG_HEIGHT / 2;
  104.    }
  105.    function chooseEgg(egg)
  106.    {
  107.       if(!this.gameStarted)
  108.       {
  109.          return undefined;
  110.       }
  111.       if(this.isSwapping || this.isUnswapping || this.isDestroying || this.isDropping)
  112.       {
  113.          return undefined;
  114.       }
  115.       if(!this.chosenEgg)
  116.       {
  117.          this.chosenEgg = egg;
  118.          egg.showChosen();
  119.          this.soundChoose.play();
  120.       }
  121.       else if(this.eggsAreAdjacent(egg,this.chosenEgg))
  122.       {
  123.          this.swapEggs(egg,this.chosenEgg);
  124.          this.chosenEgg.showNormal();
  125.          this.chosenEgg = null;
  126.          this.soundSwap.play();
  127.       }
  128.       else
  129.       {
  130.          this.chosenEgg.showNormal();
  131.          this.chosenEgg = null;
  132.          this.soundChoose.play();
  133.       }
  134.    }
  135.    function finishSwapping()
  136.    {
  137.       var _loc2_ = undefined;
  138.       if(this.swappingEgg1.isSwapping || this.swappingEgg2.isSwapping)
  139.       {
  140.          return undefined;
  141.       }
  142.       this.isSwapping = false;
  143.       this.setEggXY(this.swappingEgg1,this.swappingEgg1.targetX,this.swappingEgg1.targetY);
  144.       this.setEggXY(this.swappingEgg2,this.swappingEgg2.targetX,this.swappingEgg2.targetY);
  145.       _loc2_ = this.getGroups();
  146.       if(_loc2_.length == 0)
  147.       {
  148.          this.combo = 0;
  149.          this.unswapEggs(this.swappingEgg1,this.swappingEgg2);
  150.          this.soundSwap.play();
  151.       }
  152.       else
  153.       {
  154.          this.combo = this.combo + 1;
  155.          this.addScore(this.getScore(_loc2_));
  156.          this.addLife(_loc2_.length);
  157.          this.destroyEggs(_loc2_);
  158.          this.soundGroup.play();
  159.       }
  160.    }
  161.    function finishUnswapping()
  162.    {
  163.       if(this.unswappingEgg1.isUnswapping || this.unswappingEgg2.isUnswapping)
  164.       {
  165.          return undefined;
  166.       }
  167.       this.isUnswapping = false;
  168.       this.setEggXY(this.unswappingEgg1,this.unswappingEgg1.targetX,this.unswappingEgg1.targetY);
  169.       this.setEggXY(this.unswappingEgg2,this.unswappingEgg2.targetX,this.unswappingEgg2.targetY);
  170.    }
  171.    function finishDestroying()
  172.    {
  173.       var _loc2_ = undefined;
  174.       _loc2_ = 0;
  175.       while(_loc2_ < this.destroyingEggs.length)
  176.       {
  177.          if(this.destroyingEggs[_loc2_].visible)
  178.          {
  179.             return undefined;
  180.          }
  181.          _loc2_ = _loc2_ + 1;
  182.       }
  183.       _loc2_ = 0;
  184.       while(_loc2_ < this.destroyingEggs.length)
  185.       {
  186.          this.destroyEgg(this.destroyingEggs[_loc2_]);
  187.          _loc2_ = _loc2_ + 1;
  188.       }
  189.       this.isDestroying = false;
  190.       this.dropEggs();
  191.    }
  192.    function finishDropping()
  193.    {
  194.       var _loc2_ = undefined;
  195.       var _loc3_ = undefined;
  196.       _loc2_ = 0;
  197.       while(_loc2_ < this.droppingEggs.length)
  198.       {
  199.          if(this.droppingEggs[_loc2_].isDropping)
  200.          {
  201.             return undefined;
  202.          }
  203.          _loc2_ = _loc2_ + 1;
  204.       }
  205.       _loc2_ = 0;
  206.       while(_loc2_ < this.droppingEggs.length)
  207.       {
  208.          this.setEggXY(this.droppingEggs[_loc2_],this.droppingEggs[_loc2_].targetX,this.droppingEggs[_loc2_].targetY);
  209.          _loc2_ = _loc2_ + 1;
  210.       }
  211.       this.isDropping = false;
  212.       _loc3_ = this.getGroups();
  213.       if(_loc3_.length == 0)
  214.       {
  215.          this.combo = 0;
  216.       }
  217.       else
  218.       {
  219.          this.combo = this.combo + 1;
  220.          this.addScore(this.getScore(_loc3_));
  221.          this.addLife(_loc3_.length);
  222.          this.destroyEggs(_loc3_);
  223.          this.soundGroup.play();
  224.       }
  225.    }
  226.    function onTime(timerEvent)
  227.    {
  228.       var _loc2_ = undefined;
  229.       timerEvent.updateAfterEvent();
  230.       _loc2_ = 0;
  231.       while(_loc2_ < this.eggs.length)
  232.       {
  233.          if(this.eggs[_loc2_])
  234.          {
  235.             if(this.eggs[_loc2_].parent)
  236.             {
  237.                this.eggs[_loc2_].onTime();
  238.             }
  239.          }
  240.          _loc2_ = _loc2_ + 1;
  241.       }
  242.       this.updateLife();
  243.    }
  244.    function setEggXY(egg, x, y)
  245.    {
  246.       egg.indexX = x;
  247.       egg.indexY = y;
  248.       this.occupiers[x][y] = egg;
  249.    }
  250.    function eggsAreAdjacent(egg1, egg2)
  251.    {
  252.       if(egg1.indexX == egg2.indexX)
  253.       {
  254.          return egg1.indexY == egg2.indexY + 1 || egg1.indexY == egg2.indexY - 1;
  255.       }
  256.       if(egg1.indexX == egg2.indexX - 1)
  257.       {
  258.          if(egg1.indexX % 2 == 0)
  259.          {
  260.             return egg1.indexY == egg2.indexY || egg1.indexY == egg2.indexY + 1;
  261.          }
  262.          return egg1.indexY == egg2.indexY || egg1.indexY == egg2.indexY - 1;
  263.       }
  264.       if(egg1.indexX == egg2.indexX + 1)
  265.       {
  266.          if(egg2.indexX % 2 == 0)
  267.          {
  268.             return egg1.indexY == egg2.indexY || egg1.indexY == egg2.indexY - 1;
  269.          }
  270.          return egg1.indexY == egg2.indexY || egg1.indexY == egg2.indexY + 1;
  271.       }
  272.       return false;
  273.    }
  274.    function swapEggs(egg1, egg2)
  275.    {
  276.       this.isSwapping = true;
  277.       this.swappingEgg1 = egg1;
  278.       this.swappingEgg2 = egg2;
  279.       egg1.swapTo(egg2.indexX,egg2.indexY);
  280.       egg2.swapTo(egg1.indexX,egg1.indexY);
  281.    }
  282.    function unswapEggs(egg1, egg2)
  283.    {
  284.       this.isUnswapping = true;
  285.       this.unswappingEgg1 = egg1;
  286.       this.unswappingEgg2 = egg2;
  287.       egg1.unswapTo(egg2.indexX,egg2.indexY);
  288.       egg2.unswapTo(egg1.indexX,egg1.indexY);
  289.    }
  290.    function destroyEggs(groups)
  291.    {
  292.       var _loc3_ = undefined;
  293.       var _loc2_ = undefined;
  294.       this.isDestroying = true;
  295.       this.destroyingEggs = new Array();
  296.       _loc3_ = 0;
  297.       while(_loc3_ < groups.length)
  298.       {
  299.          _loc2_ = 0;
  300.          while(_loc2_ < groups[_loc3_].length)
  301.          {
  302.             this.destroyingEggs.push(groups[_loc3_][_loc2_]);
  303.             groups[_loc3_][_loc2_].destroy();
  304.             _loc2_ = _loc2_ + 1;
  305.          }
  306.          _loc3_ = _loc3_ + 1;
  307.       }
  308.    }
  309.    function destroyEgg(egg)
  310.    {
  311.       this.occupiers[egg.indexX][egg.indexY] = null;
  312.       if(egg.__get__parent())
  313.       {
  314.          this.eggsHolder.removeChild(egg);
  315.       }
  316.    }
  317.    function dropEggs()
  318.    {
  319.       var _loc4_ = undefined;
  320.       var _loc2_ = undefined;
  321.       var _loc3_ = undefined;
  322.       var _loc5_ = undefined;
  323.       var _loc6_ = undefined;
  324.       this.isDropping = true;
  325.       this.droppingEggs = new Array();
  326.       _loc4_ = 0;
  327.       while(_loc4_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  328.       {
  329.          _loc3_ = 0;
  330.          _loc2_ = com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y - 1;
  331.          while(_loc2_ >= 0)
  332.          {
  333.             _loc5_ = this.occupiers[_loc4_][_loc2_];
  334.             if(!_loc5_)
  335.             {
  336.                _loc3_ = _loc3_ + 1;
  337.             }
  338.             else if(_loc3_ > 0)
  339.             {
  340.                _loc5_.drop(_loc5_.indexY + _loc3_);
  341.                this.droppingEggs.push(_loc5_);
  342.             }
  343.             _loc2_ = _loc2_ - 1;
  344.          }
  345.          _loc2_ = 0;
  346.          while(_loc2_ < _loc3_)
  347.          {
  348.             _loc6_ = this.eggsHolder.createMovie("Egg");
  349.             this.eggs[this.depth] = _loc6_;
  350.             this.eggs[this.depth].indexX = _loc4_;
  351.             this.eggs[this.depth].indexY = - _loc2_ - 1;
  352.             this.eggs[this.depth].initialize(this.getRealX(_loc4_,- _loc2_ - 1),this.getRealY(_loc4_,- _loc2_ - 1),Math.floor(Math.random() * com.novelgames.flashgames.eggsAS2.Config.EGG_TYPES));
  353.             this.eggsHolder.addChild(this.eggs[this.depth]);
  354.             this.eggs[this.depth].drop(_loc3_ - 1 - _loc2_);
  355.             this.droppingEggs.push(this.eggs[this.depth]);
  356.             this.depth = this.depth + 1;
  357.             _loc2_ = _loc2_ + 1;
  358.          }
  359.          _loc4_ = _loc4_ + 1;
  360.       }
  361.    }
  362.    function getGroups()
  363.    {
  364.       var _loc6_ = new Array();
  365.       var _loc4_ = undefined;
  366.       var _loc3_ = undefined;
  367.       var _loc2_ = undefined;
  368.       var _loc5_ = undefined;
  369.       _loc5_ = 0;
  370.       while(_loc5_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  371.       {
  372.          _loc4_ = this.occupiers[_loc5_][0];
  373.          _loc3_ = _loc4_;
  374.          _loc2_ = new Array();
  375.          _loc2_.push(_loc3_);
  376.          while(_loc3_ = this.getNextEgg(_loc3_,com.novelgames.flashgames.eggsAS2.Game.DOWN))
  377.          {
  378.             if(_loc3_.type == _loc4_.type)
  379.             {
  380.                _loc2_.push(_loc3_);
  381.             }
  382.             else
  383.             {
  384.                if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  385.                {
  386.                   _loc6_.push(_loc2_);
  387.                }
  388.                _loc4_ = _loc3_;
  389.                _loc2_ = new Array();
  390.                _loc2_.push(_loc4_);
  391.             }
  392.          }
  393.          if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  394.          {
  395.             _loc6_.push(_loc2_);
  396.          }
  397.          _loc5_ = _loc5_ + 1;
  398.       }
  399.       _loc5_ = 0;
  400.       while(_loc5_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  401.       {
  402.          _loc4_ = this.occupiers[_loc5_][0];
  403.          _loc3_ = _loc4_;
  404.          _loc2_ = new Array();
  405.          _loc2_.push(_loc3_);
  406.          while(_loc3_ = this.getNextEgg(_loc3_,com.novelgames.flashgames.eggsAS2.Game.RIGHTDOWN))
  407.          {
  408.             if(_loc3_.type == _loc4_.type)
  409.             {
  410.                _loc2_.push(_loc3_);
  411.             }
  412.             else
  413.             {
  414.                if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  415.                {
  416.                   _loc6_.push(_loc2_);
  417.                }
  418.                _loc4_ = _loc3_;
  419.                _loc2_ = new Array();
  420.                _loc2_.push(_loc4_);
  421.             }
  422.          }
  423.          if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  424.          {
  425.             _loc6_.push(_loc2_);
  426.          }
  427.          _loc5_ += 2;
  428.       }
  429.       _loc5_ = 0;
  430.       while(_loc5_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y)
  431.       {
  432.          _loc4_ = this.occupiers[0][_loc5_];
  433.          _loc3_ = _loc4_;
  434.          _loc2_ = new Array();
  435.          _loc2_.push(_loc3_);
  436.          while(_loc3_ = this.getNextEgg(_loc3_,com.novelgames.flashgames.eggsAS2.Game.RIGHTDOWN))
  437.          {
  438.             if(_loc3_.type == _loc4_.type)
  439.             {
  440.                _loc2_.push(_loc3_);
  441.             }
  442.             else
  443.             {
  444.                if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  445.                {
  446.                   _loc6_.push(_loc2_);
  447.                }
  448.                _loc4_ = _loc3_;
  449.                _loc2_ = new Array();
  450.                _loc2_.push(_loc4_);
  451.             }
  452.          }
  453.          if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  454.          {
  455.             _loc6_.push(_loc2_);
  456.          }
  457.          _loc5_ = _loc5_ + 1;
  458.       }
  459.       _loc5_ = 0;
  460.       while(_loc5_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X)
  461.       {
  462.          _loc4_ = this.occupiers[_loc5_][0];
  463.          _loc3_ = _loc4_;
  464.          _loc2_ = new Array();
  465.          _loc2_.push(_loc3_);
  466.          while(_loc3_ = this.getNextEgg(_loc3_,com.novelgames.flashgames.eggsAS2.Game.LEFTDOWN))
  467.          {
  468.             if(_loc3_.type == _loc4_.type)
  469.             {
  470.                _loc2_.push(_loc3_);
  471.             }
  472.             else
  473.             {
  474.                if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  475.                {
  476.                   _loc6_.push(_loc2_);
  477.                }
  478.                _loc4_ = _loc3_;
  479.                _loc2_ = new Array();
  480.                _loc2_.push(_loc4_);
  481.             }
  482.          }
  483.          if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  484.          {
  485.             _loc6_.push(_loc2_);
  486.          }
  487.          _loc5_ += 2;
  488.       }
  489.       _loc5_ = 0;
  490.       while(_loc5_ < com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y)
  491.       {
  492.          _loc4_ = this.occupiers[com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X - 1][_loc5_];
  493.          _loc3_ = _loc4_;
  494.          _loc2_ = new Array();
  495.          _loc2_.push(_loc3_);
  496.          while(_loc3_ = this.getNextEgg(_loc3_,com.novelgames.flashgames.eggsAS2.Game.LEFTDOWN))
  497.          {
  498.             if(_loc3_.type == _loc4_.type)
  499.             {
  500.                _loc2_.push(_loc3_);
  501.             }
  502.             else
  503.             {
  504.                if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  505.                {
  506.                   _loc6_.push(_loc2_);
  507.                }
  508.                _loc4_ = _loc3_;
  509.                _loc2_ = new Array();
  510.                _loc2_.push(_loc4_);
  511.             }
  512.          }
  513.          if(_loc2_.length >= com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE)
  514.          {
  515.             _loc6_.push(_loc2_);
  516.          }
  517.          _loc5_ = _loc5_ + 1;
  518.       }
  519.       return _loc6_;
  520.    }
  521.    function getNextEgg(egg, direction)
  522.    {
  523.       if(direction == com.novelgames.flashgames.eggsAS2.Game.DOWN)
  524.       {
  525.          if(egg.indexY == com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y - 1)
  526.          {
  527.             return null;
  528.          }
  529.          return this.occupiers[egg.indexX][egg.indexY + 1];
  530.       }
  531.       if(direction == com.novelgames.flashgames.eggsAS2.Game.LEFTDOWN)
  532.       {
  533.          if(egg.indexX == 0)
  534.          {
  535.             return null;
  536.          }
  537.          if(egg.indexX % 2 == 0)
  538.          {
  539.             return this.occupiers[egg.indexX - 1][egg.indexY];
  540.          }
  541.          if(egg.indexY == com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y - 1)
  542.          {
  543.             return null;
  544.          }
  545.          return this.occupiers[egg.indexX - 1][egg.indexY + 1];
  546.       }
  547.       if(egg.indexX == com.novelgames.flashgames.eggsAS2.Config.DIMENSION_X - 1)
  548.       {
  549.          return null;
  550.       }
  551.       if(egg.indexX % 2 == 0)
  552.       {
  553.          return this.occupiers[egg.indexX + 1][egg.indexY];
  554.       }
  555.       if(egg.indexY == com.novelgames.flashgames.eggsAS2.Config.DIMENSION_Y - 1)
  556.       {
  557.          return null;
  558.       }
  559.       return this.occupiers[egg.indexX + 1][egg.indexY + 1];
  560.    }
  561.    function getScore(groups)
  562.    {
  563.       var _loc2_ = undefined;
  564.       var _loc4_ = 0;
  565.       _loc2_ = 0;
  566.       while(_loc2_ < groups.length)
  567.       {
  568.          _loc4_ += this.combo * ((groups[_loc2_].length - com.novelgames.flashgames.eggsAS2.Config.GROUPSIZE) * com.novelgames.flashgames.eggsAS2.Config.SCORE_EXTRAEGG + com.novelgames.flashgames.eggsAS2.Config.SCORE_GROUP);
  569.          _loc2_ = _loc2_ + 1;
  570.       }
  571.       return _loc4_;
  572.    }
  573.    function addScore(amount)
  574.    {
  575.       this.score += amount;
  576.       this.updateLevel();
  577.    }
  578.    function updateLevel()
  579.    {
  580.       var _loc2_ = undefined;
  581.       _loc2_ = this.__get__level() - 1;
  582.       while(_loc2_ < com.novelgames.flashgames.eggsAS2.Config.LEVEL_SCORES.length)
  583.       {
  584.          if(this.__get__score() < com.novelgames.flashgames.eggsAS2.Config.LEVEL_SCORES[_loc2_])
  585.          {
  586.             break;
  587.          }
  588.          _loc2_ = _loc2_ + 1;
  589.       }
  590.       if(this.__get__level() != _loc2_ + 1)
  591.       {
  592.          this.__set__level(_loc2_ + 1);
  593.          this.decreaseRate = com.novelgames.flashgames.eggsAS2.Config.LEVEL_DECREASERATES[_loc2_];
  594.       }
  595.    }
  596.    function updateLife()
  597.    {
  598.       if(!this.gameStarted)
  599.       {
  600.          return undefined;
  601.       }
  602.       if(this.lastDecreaseTime + this.decreaseRate <= com.novelgames.flashgames.commonAS2.NewTimer.getTimer())
  603.       {
  604.          this.lastDecreaseTime += this.decreaseRate;
  605.          this.addLife(-1);
  606.       }
  607.    }
  608.    function addLife(amount)
  609.    {
  610.       this.life += amount;
  611.       if(this.life < 0)
  612.       {
  613.          this.life = 0;
  614.       }
  615.       else if(this.life > com.novelgames.flashgames.eggsAS2.Config.LIFE_FULL)
  616.       {
  617.          this.life = com.novelgames.flashgames.eggsAS2.Config.LIFE_FULL;
  618.       }
  619.       this.lifePie.setLife(this.life);
  620.       if(this.life <= 0)
  621.       {
  622.          this.gameOver();
  623.          this.soundGameOver.play();
  624.       }
  625.    }
  626.    function gameOver()
  627.    {
  628.       var _loc2_ = undefined;
  629.       this.gameStarted = false;
  630.       this.gameOverDialog.show();
  631.       _loc2_ = new com.novelgames.flashgames.commonAS2.NewTimer(com.novelgames.flashgames.eggsAS2.Config.MESSAGE_GAMEOVERTIME,1);
  632.       _loc2_.addEventListener(com.novelgames.flashgames.commonAS2.TimerEvent.TIMER,this,"showPlayAgain");
  633.       _loc2_.start();
  634.    }
  635.    function showPlayAgain(timerEvent)
  636.    {
  637.       Object(this.__get__parent()).showEnterHighScore(this.__get__score());
  638.       this.gameOverDialog.showPlayAgain();
  639.    }
  640. }
  641.