home *** CD-ROM | disk | FTP | other *** search
/ Ice Age Fan CD 1 / CD1_Scrat.iso / flash / data / game.swf / scripts / asCode / nextThingFinder.as < prev    next >
Encoding:
Text File  |  2012-07-04  |  8.2 KB  |  242 lines

  1. package asCode
  2. {
  3.    import com.terry.SeededRandomNumber;
  4.    import flash.display.MovieClip;
  5.    import flash.geom.*;
  6.    
  7.    public class nextThingFinder
  8.    {
  9.       private static var BUBBLE_TYPE_PLAYER:int = 0;
  10.       
  11.       private static var BUBBLE_TYPE_ACORN:int = 5;
  12.       
  13.       private static var BUBBLE_TYPE_HEALTH_POWERUP:int = 10;
  14.       
  15.       private static var BUBBLE_TYPE_INVINCIBLE:int = 15;
  16.       
  17.       private static var BUBBLE_TYPE_SHRINK:int = 20;
  18.       
  19.       private static var BUBBLE_TYPE_REVERSE:int = 25;
  20.       
  21.       private var _SeededRandomNumberRef:SeededRandomNumber;
  22.       
  23.       private var itemLocations:Array;
  24.       
  25.       private var level:int;
  26.       
  27.       private var rCell:int;
  28.       
  29.       private var powerUpChoice:int;
  30.       
  31.       private var r:int;
  32.       
  33.       private var _gameClipClassRef:gameClipClass;
  34.       
  35.       private var _findClearOfBitmapRef:findClearOfBitmap;
  36.       
  37.       private var levelStorageArray:Array;
  38.       
  39.       private var bubblesArray:Array;
  40.       
  41.       private var _tempArray:Array;
  42.       
  43.       private var _itemArray:Array;
  44.       
  45.       private var totalLevelCells:int;
  46.       
  47.       private var k:int;
  48.       
  49.       private var _clip:MovieClip;
  50.       
  51.       private var levelAcornAmount:int;
  52.       
  53.       private var itemBubbleSize:Number;
  54.       
  55.       private var _itemBubbleRef:itemBubbleCodeClass;
  56.       
  57.       private var _tempPoint:Point;
  58.       
  59.       public function nextThingFinder(param1:gameClipClass)
  60.       {
  61.          _SeededRandomNumberRef = new SeededRandomNumber();
  62.          itemLocations = new Array();
  63.          levelStorageArray = new Array();
  64.          bubblesArray = new Array();
  65.          _tempArray = new Array();
  66.          _itemArray = new Array();
  67.          _tempPoint = new Point();
  68.          super();
  69.          _gameClipClassRef = param1;
  70.          _findClearOfBitmapRef = _gameClipClassRef._findClearOfBitmapRef;
  71.       }
  72.       
  73.       public function resetForNextLevel() : void
  74.       {
  75.          level = _gameClipClassRef.level;
  76.          levelStorageArray = new Array();
  77.          bubblesArray = new Array();
  78.          _SeededRandomNumberRef.seed = level * _gameClipClassRef.characterChoice;
  79.       }
  80.       
  81.       public function findNextBackgroundType(param1:int = 0) : int
  82.       {
  83.          level = _gameClipClassRef.level;
  84.          if(level == 1 || level == 4 || level == 7)
  85.          {
  86.             r = _SeededRandomNumberRef.nextIntRange(0,4);
  87.          }
  88.          if(level == 2 || level == 5 || level == 8)
  89.          {
  90.             r = _SeededRandomNumberRef.nextIntRange(5,9);
  91.          }
  92.          if(level == 3 || level == 6 || level == 9 || level == 10)
  93.          {
  94.             r = _SeededRandomNumberRef.nextIntRange(10,14);
  95.          }
  96.          return r;
  97.       }
  98.       
  99.       public function findNextForegroundType(param1:String) : int
  100.       {
  101.          r = _SeededRandomNumberRef.nextIntRange(1,10);
  102.          if(level == 1 || level == 4 || level == 7)
  103.          {
  104.          }
  105.          if(level == 2 || level == 5 || level == 8)
  106.          {
  107.             r += 10;
  108.          }
  109.          if(level == 3 || level == 6 || level == 9 || level == 10)
  110.          {
  111.             r += 20;
  112.          }
  113.          if(param1 == "left")
  114.          {
  115.             return r;
  116.          }
  117.          return r + 99;
  118.       }
  119.       
  120.       public function findNextScreenCellType(param1:int, param2:Number) : int
  121.       {
  122.          var _loc3_:int = 0;
  123.          levelStorageArray = _gameClipClassRef.levelStorageArray;
  124.          bubblesArray = _gameClipClassRef.bubblesArray;
  125.          totalLevelCells = _gameClipClassRef.totalLevelCells;
  126.          itemBubbleSize = _gameClipClassRef.itemBubbleSize;
  127.          levelAcornAmount = _gameClipClassRef.levelAcornAmount;
  128.          level = _gameClipClassRef.level;
  129.          if(levelStorageArray[param1] == undefined || levelStorageArray[param1] == "")
  130.          {
  131.             if(level == 1)
  132.             {
  133.                rCell = _SeededRandomNumberRef.nextIntRange(2,8);
  134.             }
  135.             if(level == 2)
  136.             {
  137.                rCell = _SeededRandomNumberRef.nextIntRange(12,19);
  138.             }
  139.             if(level == 3)
  140.             {
  141.                rCell = _SeededRandomNumberRef.nextIntRange(24,31);
  142.             }
  143.             if(level == 4 || level == 7)
  144.             {
  145.                rCell = _SeededRandomNumberRef.nextIntRange(2,11);
  146.             }
  147.             if(level == 5 || level == 8)
  148.             {
  149.                rCell = _SeededRandomNumberRef.nextIntRange(12,23);
  150.             }
  151.             if(level == 6 || level == 9 || level == 10)
  152.             {
  153.                rCell = _SeededRandomNumberRef.nextIntRange(24,34);
  154.             }
  155.             if(param1 > totalLevelCells)
  156.             {
  157.                rCell = 35;
  158.             }
  159.             if(param1 == 0)
  160.             {
  161.                rCell = 0;
  162.             }
  163.             if(param1 == 1)
  164.             {
  165.                rCell = 36;
  166.             }
  167.             if(param1 == totalLevelCells)
  168.             {
  169.                rCell = 1;
  170.             }
  171.             _tempArray = [];
  172.             _tempArray[0] = rCell;
  173.             if(param1 > 1 && param1 < totalLevelCells)
  174.             {
  175.                _itemArray = [];
  176.                _loc3_ = _SeededRandomNumberRef.nextIntRange(0,6) + 1;
  177.                itemLocations = _findClearOfBitmapRef.getEmptySpaces(rCell,_loc3_);
  178.                k = 0;
  179.                while(k < _loc3_)
  180.                {
  181.                   _clip = new bubbleClip();
  182.                   ++levelAcornAmount;
  183.                   if(_SeededRandomNumberRef.nextDouble() < 0.15)
  184.                   {
  185.                      if(level < 5)
  186.                      {
  187.                         powerUpChoice = _SeededRandomNumberRef.nextIntRange(0,4);
  188.                      }
  189.                      else
  190.                      {
  191.                         powerUpChoice = _SeededRandomNumberRef.nextIntRange(0,3);
  192.                      }
  193.                      switch(powerUpChoice)
  194.                      {
  195.                         case 0:
  196.                            _clip.gotoAndStop(3);
  197.                            _itemBubbleRef = new itemBubbleCodeClass(_clip,itemBubbleSize,BUBBLE_TYPE_INVINCIBLE,false);
  198.                            break;
  199.                         case 1:
  200.                            _clip.gotoAndStop(4);
  201.                            _itemBubbleRef = new itemBubbleCodeClass(_clip,itemBubbleSize,BUBBLE_TYPE_HEALTH_POWERUP,false);
  202.                            break;
  203.                         case 2:
  204.                            _clip.gotoAndStop(5);
  205.                            _itemBubbleRef = new itemBubbleCodeClass(_clip,itemBubbleSize,BUBBLE_TYPE_SHRINK,false);
  206.                            break;
  207.                         case 3:
  208.                            _clip.gotoAndStop(6);
  209.                            _itemBubbleRef = new itemBubbleCodeClass(_clip,itemBubbleSize,BUBBLE_TYPE_REVERSE,false);
  210.                      }
  211.                      _tempPoint.x = itemLocations[k * 2];
  212.                      _tempPoint.y = itemLocations[k * 2 + 1] + param2;
  213.                      _itemBubbleRef.setLoc(_tempPoint);
  214.                      bubblesArray.push(_itemBubbleRef);
  215.                      _itemArray.push(_itemBubbleRef);
  216.                   }
  217.                   else
  218.                   {
  219.                      _clip.gotoAndStop(2);
  220.                      _itemBubbleRef = new itemBubbleCodeClass(_clip,itemBubbleSize,BUBBLE_TYPE_ACORN,false);
  221.                      _tempPoint.x = itemLocations[k * 2];
  222.                      _tempPoint.y = itemLocations[k * 2 + 1] + param2;
  223.                      _itemBubbleRef.setLoc(_tempPoint);
  224.                      bubblesArray.push(_itemBubbleRef);
  225.                      _itemArray.push(_itemBubbleRef);
  226.                   }
  227.                   ++k;
  228.                }
  229.                _tempArray[1] = _itemArray;
  230.             }
  231.             levelStorageArray[param1] = _tempArray;
  232.             _gameClipClassRef.levelStorageArray = levelStorageArray;
  233.             _gameClipClassRef.bubblesArray = bubblesArray;
  234.             _gameClipClassRef.levelAcornAmount = levelAcornAmount;
  235.             return rCell;
  236.          }
  237.          return levelStorageArray[param1][0];
  238.       }
  239.    }
  240. }
  241.  
  242.