home *** CD-ROM | disk | FTP | other *** search
- package asCode
- {
- import flash.display.*;
- import flash.geom.*;
-
- internal class itemManager
- {
- private static var MEDAL_PERFECT_RUN:int = 0;
-
- private static var MEDAL_LOW_HEALTH:int = 1;
-
- private static var MEDAL_WINNING_STREAK:int = 2;
-
- private static var MEDAL_10_IN_A_ROW:int = 3;
-
- private static var MEDAL_25_IN_A_ROW:int = 4;
-
- private static var MEDAL_ALL_ACORNS:int = 5;
-
- private static var MEDAL_25_PLAYS:int = 6;
-
- private static var MEDAL_GAME_COMPLETED:int = 7;
-
- private static var PARTICLE_EFFECT_ENEMY_DEATH:int = 0;
-
- private static var PARTICLE_HIT_OBJECT:int = 1;
-
- private static var PARTICLE_COLLECT_ITEM:int = 2;
-
- private static var PARTICLE_EFFECT_CHIP_PLACED:int = 3;
-
- private static var PARTICLE_EFFECT_ELECTRICAL_CHARGE:int = 4;
-
- private static var PARTICLE_EFFECT_METEOR:int = 5;
-
- private static var PARTICLE_EFFECT_FLICKER:int = 6;
-
- private static var BUBBLE_TYPE_PLAYER:int = 0;
-
- private static var BUBBLE_TYPE_ACORN:int = 5;
-
- private static var BUBBLE_TYPE_HEALTH_POWERUP:int = 10;
-
- private static var BUBBLE_TYPE_INVINCIBLE:int = 15;
-
- private static var BUBBLE_TYPE_SHRINK:int = 20;
-
- private static var BUBBLE_TYPE_REVERSE:int = 25;
-
- private var scrollYDist:Number;
-
- private var acornsCollected:int;
-
- public var playerScreenLoc:Point;
-
- private var HIT_ENEMY:int = 10;
-
- private var HIT_WALL:int = 20;
-
- private var HIT_ACORN:int = 30;
-
- private var hitInARow:int = 0;
-
- private var lastThingHit:int = 0;
-
- private var specialEffectsActive:Boolean = true;
-
- public var _trigClassRef:trigClass;
-
- private var itemBubbleGenCount:int = 0;
-
- private var activeBubbles:int = 0;
-
- private var screenHeight:Number;
-
- private var dist:Number;
-
- private var removeBubble:Boolean;
-
- private var i:int;
-
- private var _itemBubbleRef:itemBubbleCodeClass;
-
- private var MAXActiveBubbles:int = 1;
-
- private var _clip:MovieClip;
-
- private var bubblesArray:Array;
-
- private var _tempPoint:Point;
-
- private var playerBubbleRadius:Number;
-
- private var _gameClipClassRef:gameClipClass;
-
- public function itemManager(param1:gameClipClass)
- {
- playerScreenLoc = new Point();
- _trigClassRef = new trigClass();
- super();
- _gameClipClassRef = param1;
- }
-
- public function reset() : void
- {
- if(bubblesArray != null)
- {
- activeBubbles = bubblesArray.length;
- i = activeBubbles;
- while(i--)
- {
- _itemBubbleRef = bubblesArray[i];
- bubblesArray.splice(i,1);
- }
- }
- bubblesArray = new Array();
- _gameClipClassRef.bubblesArray = bubblesArray;
- }
-
- public function manageItems() : void
- {
- var _loc1_:Number = NaN;
- var _loc2_:int = 0;
- playerScreenLoc = _gameClipClassRef.playerScreenLoc;
- acornsCollected = _gameClipClassRef.acornsCollected;
- scrollYDist = _gameClipClassRef.scrollYDist;
- playerBubbleRadius = _gameClipClassRef.playerBubbleRadius;
- bubblesArray = _gameClipClassRef.bubblesArray;
- screenHeight = _gameClipClassRef.screenHeight;
- lastThingHit = _gameClipClassRef.lastThingHit;
- if(bubblesArray != null)
- {
- activeBubbles = bubblesArray.length;
- i = activeBubbles;
- while(i--)
- {
- _itemBubbleRef = bubblesArray[i];
- removeBubble = false;
- if(!_itemBubbleRef.getCollected())
- {
- _tempPoint = _itemBubbleRef.getLoc();
- _tempPoint.y += scrollYDist;
- dist = _trigClassRef.findDistance(playerScreenLoc,_tempPoint);
- _loc1_ = (_itemBubbleRef.getBubbleRadius() + playerBubbleRadius) * 0.65;
- if(dist <= _loc1_)
- {
- removeBubble = true;
- if(lastThingHit == HIT_ACORN)
- {
- ++hitInARow;
- if(hitInARow == 2)
- {
- _gameClipClassRef.tellInARow(3);
- }
- if(hitInARow == 4)
- {
- _gameClipClassRef.tellInARow(5);
- }
- if(hitInARow == 9)
- {
- _gameClipClassRef.tellInARow(10);
- }
- if(hitInARow == 24)
- {
- _gameClipClassRef.tellInARow(25);
- }
- }
- else
- {
- hitInARow = 0;
- }
- lastThingHit = HIT_ACORN;
- switch(_itemBubbleRef.getBubbleType)
- {
- case BUBBLE_TYPE_ACORN:
- _loc2_ = Math.random() * 3 + 1;
- _gameClipClassRef.playSound("acornCollected_" + _loc2_ + ".wav");
- ++acornsCollected;
- _gameClipClassRef.acornsCollected = acornsCollected;
- _gameClipClassRef.addPoints(50);
- _gameClipClassRef.particleEffect(PARTICLE_EFFECT_CHIP_PLACED,_tempPoint.x,_tempPoint.y);
- break;
- case BUBBLE_TYPE_HEALTH_POWERUP:
- _gameClipClassRef.playSound("powerUp_health.wav");
- ++acornsCollected;
- _gameClipClassRef.acornsCollected = acornsCollected;
- _gameClipClassRef.addPoints(250);
- _gameClipClassRef.addHealth(25);
- _gameClipClassRef.particleEffect(PARTICLE_EFFECT_FLICKER,_tempPoint.x,_tempPoint.y);
- break;
- case BUBBLE_TYPE_REVERSE:
- _gameClipClassRef.playSound("powerUp_reverseControls.wav");
- ++acornsCollected;
- _gameClipClassRef.acornsCollected = acornsCollected;
- _gameClipClassRef.addPoints(250);
- _gameClipClassRef.reverseControls();
- _gameClipClassRef.particleEffect(PARTICLE_EFFECT_FLICKER,_tempPoint.x,_tempPoint.y);
- break;
- case BUBBLE_TYPE_SHRINK:
- _gameClipClassRef.playSound("powerUp_shrink.wav");
- ++acornsCollected;
- _gameClipClassRef.acornsCollected = acornsCollected;
- _gameClipClassRef.addPoints(250);
- _gameClipClassRef.shrinkPlayer();
- _gameClipClassRef.particleEffect(PARTICLE_EFFECT_FLICKER,_tempPoint.x,_tempPoint.y);
- break;
- case BUBBLE_TYPE_INVINCIBLE:
- _gameClipClassRef.playSound("powerUp_invincible.wav");
- ++acornsCollected;
- _gameClipClassRef.acornsCollected = acornsCollected;
- _gameClipClassRef.addPoints(250);
- _gameClipClassRef.makeInvincible();
- _gameClipClassRef.particleEffect(PARTICLE_EFFECT_FLICKER,_tempPoint.x,_tempPoint.y);
- }
- }
- if(removeBubble)
- {
- _itemBubbleRef.setCollected();
- _clip = _itemBubbleRef.getClip();
- _clip = null;
- bubblesArray.splice(i,1);
- }
- else
- {
- _itemBubbleRef.drawBubble(_tempPoint);
- }
- }
- }
- _gameClipClassRef.lastThingHit = lastThingHit;
- _gameClipClassRef.bubblesArray = bubblesArray;
- }
- }
- }
- }
-
-