mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 17:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,994 @@
|
||||
package game.distanceChallenge
|
||||
{
|
||||
import achievement.AchievementManager;
|
||||
import achievement.AchievementXtCommManager;
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class DistanceChallenge extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const BACKGROUND_TYPES_TOTAL:int = 6;
|
||||
|
||||
public static const BACKGROUND_TYPES_SANDTRAP:int = 1;
|
||||
|
||||
public static const BACKGROUND_TYPES_HARDICE:int = 2;
|
||||
|
||||
public static const BACKGROUND_TYPES_SNOWDRIFT:int = 3;
|
||||
|
||||
public static const BACKGROUND_TYPES_GEYSER:int = 4;
|
||||
|
||||
public static const BACKGROUND_TYPES_ASH:int = 5;
|
||||
|
||||
public static const BACKGROUND_TYPES_VOLCANO:int = 6;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _facts:Array = [{
|
||||
"image":"9b1",
|
||||
"text":LocalizationManager.translateIdOnly(11394)
|
||||
},{
|
||||
"image":"9b3",
|
||||
"text":LocalizationManager.translateIdOnly(11395)
|
||||
},{
|
||||
"image":"7b1",
|
||||
"text":LocalizationManager.translateIdOnly(11396)
|
||||
},{
|
||||
"image":"6b1",
|
||||
"text":LocalizationManager.translateIdOnly(11397)
|
||||
},{
|
||||
"image":"9b6",
|
||||
"text":LocalizationManager.translateIdOnly(11398)
|
||||
},{
|
||||
"image":"9b3_2",
|
||||
"text":LocalizationManager.translateIdOnly(11399)
|
||||
},{
|
||||
"image":"3b1",
|
||||
"text":LocalizationManager.translateIdOnly(11400)
|
||||
},{
|
||||
"image":"3b1_2",
|
||||
"text":LocalizationManager.translateIdOnly(11401)
|
||||
},{
|
||||
"image":"9b1_2",
|
||||
"text":LocalizationManager.translateIdOnly(11402)
|
||||
},{
|
||||
"image":"9b4",
|
||||
"text":LocalizationManager.translateIdOnly(11403)
|
||||
},{
|
||||
"image":"9b4_2",
|
||||
"text":LocalizationManager.translateIdOnly(11404)
|
||||
},{
|
||||
"image":"9b5",
|
||||
"text":LocalizationManager.translateIdOnly(11405)
|
||||
},{
|
||||
"image":"9b3_3",
|
||||
"text":LocalizationManager.translateIdOnly(11406)
|
||||
}];
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerBackgroundSky:Sprite;
|
||||
|
||||
public var _layerBackgroundMiddle:Sprite;
|
||||
|
||||
public var _layerBackgroundGround:Sprite;
|
||||
|
||||
public var _layerBackgroundObstacle:Sprite;
|
||||
|
||||
public var _layerBackgroundLauncher:Sprite;
|
||||
|
||||
public var _layerPlayer:Sprite;
|
||||
|
||||
public var _layerSkyMove:Number;
|
||||
|
||||
public var _layerGroundMove:Number;
|
||||
|
||||
public var _particles:Array;
|
||||
|
||||
public var _sky:Array;
|
||||
|
||||
public var _backgroundElements:Array;
|
||||
|
||||
public var _activeBackgroundType:int;
|
||||
|
||||
public var _addBackgroundGroundX:int;
|
||||
|
||||
public var _lastChangeBackgroundGroundX:int;
|
||||
|
||||
public var _addMiddleX:int;
|
||||
|
||||
public var _lastChangeMiddleX:int;
|
||||
|
||||
public var _obstacleOffset:int;
|
||||
|
||||
public var _windSound:SoundChannel;
|
||||
|
||||
public var _gearsSound:SoundChannel;
|
||||
|
||||
public var _nextBackgroundSwitch:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _displayAchievementTimer:Number;
|
||||
|
||||
public var _score:Object;
|
||||
|
||||
public var _launcher:Object;
|
||||
|
||||
public var _transition:Object;
|
||||
|
||||
public var _gameOverTimer:Number;
|
||||
|
||||
public var _recordDistance:Number;
|
||||
|
||||
public var _gemsEarned:int;
|
||||
|
||||
public var _lastRot:Number;
|
||||
|
||||
public var _player:DistanceChallengePlayer;
|
||||
|
||||
public var SFX_ARM_GEARS:Class;
|
||||
|
||||
public var SFX_ARM_WIND:Class;
|
||||
|
||||
private const _sounds:Array = ["armadillo_bounce.mp3","armadillo_spray.mp3","armadillo_launch.mp3","armadillo_prairie_dog.mp3","aj_armadillo_outro.mp3","armdadillo_collision1.mp3","armdadillo_collision2.mp3","armdadillo_collision3.mp3","armadillo_intro.mp3","armadillo_stinger_success.mp3","armadillo_passby1.mp3","armadillo_passby2.mp3","armadillo_superman_close.mp3","armadillo_superman_open.mp3","armadillo_wonder_woman.mp3","armadillo_cactus_collision.mp3","armadillo_steam.mp3","armadillo_collision_snowman.mp3","armadillo_swing.mp3","aj_ls_steam.mp3","aj_ls_stump_imp.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3","armadillo_bounce.mp3"];
|
||||
|
||||
internal var _soundNameArmBounce:String = _sounds[0];
|
||||
|
||||
internal var _soundNameArmGeyser:String = _sounds[1];
|
||||
|
||||
internal var _soundNameArmLaunch:String = _sounds[2];
|
||||
|
||||
internal var _soundNameArmMole:String = _sounds[3];
|
||||
|
||||
internal var _soundNameArmOutro:String = _sounds[4];
|
||||
|
||||
internal var _soundNameArmCollision1:String = _sounds[5];
|
||||
|
||||
internal var _soundNameArmCollision2:String = _sounds[6];
|
||||
|
||||
internal var _soundNameArmCollision3:String = _sounds[7];
|
||||
|
||||
internal var _soundNameArmIntro:String = _sounds[8];
|
||||
|
||||
internal var _soundNameArmSuccess:String = _sounds[9];
|
||||
|
||||
internal var _soundNameArmPassBy1:String = _sounds[10];
|
||||
|
||||
internal var _soundNameArmPassBy2:String = _sounds[11];
|
||||
|
||||
internal var _soundNameArmSpmnClose:String = _sounds[12];
|
||||
|
||||
internal var _soundNameArmSpmnOpen:String = _sounds[13];
|
||||
|
||||
internal var _soundNameArmWonderwmn:String = _sounds[14];
|
||||
|
||||
internal var _soundNameArmCactusClsn:String = _sounds[15];
|
||||
|
||||
internal var _soundNameArmSteam:String = _sounds[16];
|
||||
|
||||
internal var _soundNameArmSnwmnClsn:String = _sounds[17];
|
||||
|
||||
internal var _soundNameArmSwing:String = _sounds[18];
|
||||
|
||||
internal var _soundNameArmLsSteam:String = _sounds[19];
|
||||
|
||||
internal var _soundNameArmStump:String = _sounds[20];
|
||||
|
||||
public var _SFX_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
public function DistanceChallenge()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmBounce],_soundNameArmBounce,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmGeyser],_soundNameArmGeyser,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmLaunch],_soundNameArmLaunch,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmMole],_soundNameArmMole,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmOutro],_soundNameArmOutro,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmCollision1],_soundNameArmCollision1,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmCollision2],_soundNameArmCollision2,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmCollision3],_soundNameArmCollision3,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmIntro],_soundNameArmIntro,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSuccess],_soundNameArmSuccess,0.62);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmPassBy1],_soundNameArmPassBy1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmPassBy2],_soundNameArmPassBy2,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSpmnClose],_soundNameArmSpmnClose,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSpmnOpen],_soundNameArmSpmnOpen,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmWonderwmn],_soundNameArmWonderwmn,1.24);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmCactusClsn],_soundNameArmCactusClsn,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSteam],_soundNameArmSteam,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSnwmnClsn],_soundNameArmSnwmnClsn,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmSwing],_soundNameArmSwing,0.58);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmLsSteam],_soundNameArmLsSteam,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameArmStump],_soundNameArmStump,1);
|
||||
_soundMan.addSound(SFX_ARM_WIND,0.2,"SFX_ARM_WIND");
|
||||
_soundMan.addSound(SFX_ARM_GEARS,0.2,"SFX_ARM_GEARS");
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_gameTime > 15 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
stage.removeEventListener("keyDown",greatJobKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",fireKeyDown);
|
||||
stage.removeEventListener("mouseDown",mouseClickHandler);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerBackgroundSky);
|
||||
removeLayer(_layerBackgroundMiddle);
|
||||
removeLayer(_layerBackgroundGround);
|
||||
removeLayer(_layerBackgroundObstacle);
|
||||
removeLayer(_layerBackgroundLauncher);
|
||||
removeLayer(_layerPlayer);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBackgroundSky = null;
|
||||
_layerBackgroundMiddle = null;
|
||||
_layerBackgroundGround = null;
|
||||
_layerBackgroundObstacle = null;
|
||||
_layerBackgroundLauncher = null;
|
||||
_layerPlayer = null;
|
||||
_guiLayer = null;
|
||||
MinigameManager.leave();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_displayAchievementTimer = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_particles = [];
|
||||
_layerBackgroundSky = new Sprite();
|
||||
_layerBackgroundMiddle = new Sprite();
|
||||
_layerBackgroundGround = new Sprite();
|
||||
_layerBackgroundObstacle = new Sprite();
|
||||
_layerBackgroundLauncher = new Sprite();
|
||||
_layerPlayer = new Sprite();
|
||||
_layerBackgroundSky.mouseEnabled = false;
|
||||
_layerBackgroundMiddle.mouseEnabled = false;
|
||||
_layerBackgroundGround.mouseEnabled = false;
|
||||
_layerBackgroundObstacle.mouseEnabled = false;
|
||||
_layerBackgroundLauncher.mouseEnabled = false;
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBackgroundSky);
|
||||
addChild(_layerBackgroundMiddle);
|
||||
addChild(_layerBackgroundGround);
|
||||
addChild(_layerBackgroundLauncher);
|
||||
addChild(_layerBackgroundObstacle);
|
||||
addChild(_layerPlayer);
|
||||
addChild(_guiLayer);
|
||||
loadScene("DistanceChallenge/room_main.xroom",_sounds);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc3_:* = null;
|
||||
SFX_ARM_GEARS = getDefinitionByName("gears") as Class;
|
||||
if(SFX_ARM_GEARS == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:gears");
|
||||
}
|
||||
SFX_ARM_WIND = getDefinitionByName("wind") as Class;
|
||||
if(SFX_ARM_WIND == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:wind");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
var _loc2_:int = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc2_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
}
|
||||
if(_loc2_ != 0)
|
||||
{
|
||||
_recordDistance = Math.max(gMainFrame.userInfo.userVarCache.getUserVarValueById(_loc2_),0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_recordDistance = 0;
|
||||
}
|
||||
_score = _scene.getLayer("score");
|
||||
_guiLayer.addChild(_score.loader);
|
||||
_score.loader.content.record.text = _recordDistance;
|
||||
_loc5_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",_loc5_.x,_loc5_.y,onCloseButton);
|
||||
_launcher = _scene.getLayer("launcher");
|
||||
_layerBackgroundLauncher.addChild(_launcher.loader);
|
||||
_lastRot = _launcher.loader.content.stringAngle;
|
||||
_backgroundElements = new Array(6);
|
||||
_sky = [];
|
||||
_sky.push(_scene.getLayer("sky"));
|
||||
_sky.push(_scene.getLayer("sky_2"));
|
||||
_sky[0].loader.y = 0;
|
||||
_sky[1].loader.y = 0;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 6)
|
||||
{
|
||||
_backgroundElements[_loc4_] = {};
|
||||
_backgroundElements[_loc4_].ground = [];
|
||||
_backgroundElements[_loc4_].ground.push(_scene.getLayer("ground" + (_loc4_ + 1)));
|
||||
_backgroundElements[_loc4_].ground.push(_scene.getLayer("ground" + (_loc4_ + 1) + "_2"));
|
||||
_backgroundElements[_loc4_].ground[0].loader.y = _sky[0].height;
|
||||
_backgroundElements[_loc4_].ground[1].loader.y = _sky[0].height;
|
||||
_backgroundElements[_loc4_].obstacle = [];
|
||||
_backgroundElements[_loc4_].obstacle.push(_scene.getLayer("obstacle" + (_loc4_ + 1)));
|
||||
_backgroundElements[_loc4_].obstacle.push(_scene.getLayer("obstacle" + (_loc4_ + 1) + "_2"));
|
||||
_backgroundElements[_loc4_].obstacle[0].loader.y = _sky[0].height;
|
||||
_backgroundElements[_loc4_].obstacle[1].loader.y = _sky[0].height;
|
||||
_backgroundElements[_loc4_].middle = [];
|
||||
_backgroundElements[_loc4_].middle.push(_scene.getLayer("middle" + (_loc4_ + 1)));
|
||||
_backgroundElements[_loc4_].middle.push(_scene.getLayer("middle" + (_loc4_ + 1) + "_2"));
|
||||
_backgroundElements[_loc4_].middle[0].loader.y = _sky[0].height - _backgroundElements[_loc4_].middle[0].height;
|
||||
_backgroundElements[_loc4_].middle[1].loader.y = _sky[0].height - _backgroundElements[_loc4_].middle[0].height;
|
||||
_loc4_++;
|
||||
}
|
||||
_transition = _scene.getLayer("transition");
|
||||
_transition.loader.y = _sky[0].height;
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("mouseDown",mouseClickHandler);
|
||||
stage.addEventListener("keyDown",fireKeyDown);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function fireKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
if(activeDlgMC == null)
|
||||
{
|
||||
mouseClickHandler(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function replayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onGreatJob_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onGreatJob_No();
|
||||
}
|
||||
}
|
||||
|
||||
private function greatJobKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
showGreatJobDlg();
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc12_:Object = null;
|
||||
var _loc6_:MovieClip = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc3_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc2_:int = 0;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc7_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_displayAchievementTimer > 0)
|
||||
{
|
||||
_displayAchievementTimer -= _frameTime;
|
||||
if(_displayAchievementTimer <= 0)
|
||||
{
|
||||
_displayAchievementTimer = 0;
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
}
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_player && _player._started == false && _launcher.loader.parent != null && _launcher.loader.content && _launcher.loader.content.launcherOn)
|
||||
{
|
||||
if(_gearsSound == null)
|
||||
{
|
||||
_gearsSound = _soundMan.play(SFX_ARM_GEARS,0,99999);
|
||||
}
|
||||
if(Math.abs(_launcher.loader.content.stringAngle - _lastRot) > 200)
|
||||
{
|
||||
_soundMan.playByName(_soundNameArmSwing);
|
||||
}
|
||||
_lastRot = _launcher.loader.content.stringAngle;
|
||||
}
|
||||
if(!_pauseGame)
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
if(_gameOverTimer > 0)
|
||||
{
|
||||
_gameOverTimer -= _frameTime;
|
||||
if(_gameOverTimer <= 0)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
stage.addEventListener("keyDown",greatJobKeyDown);
|
||||
_loc6_ = showDlg("longshot_result",[{
|
||||
"name":"continue_btn",
|
||||
"f":showGreatJobDlg
|
||||
}]);
|
||||
_pauseGame = false;
|
||||
_loc6_.x = 450;
|
||||
_loc6_.y = 275;
|
||||
_loc6_.result_score.text = valueTrackerCurrent();
|
||||
_loc8_ = Math.random() * _facts.length;
|
||||
_scene.getLayer(_facts[_loc8_].image).loader.x = 0;
|
||||
_scene.getLayer(_facts[_loc8_].image).loader.y = 0;
|
||||
_loc6_.result_pic.addChild(_scene.getLayer(_facts[_loc8_].image).loader);
|
||||
LocalizationManager.updateToFit(_loc6_.result_fact,_facts[_loc8_].text);
|
||||
_soundMan.playByName(_soundNameArmSuccess);
|
||||
if(valueTrackerCurrent() > _recordDistance)
|
||||
{
|
||||
_recordDistance = valueTrackerCurrent();
|
||||
_score.loader.content.record.text = _recordDistance;
|
||||
valueTrackerCommit();
|
||||
_displayAchievementTimer = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc4_ = Math.max(_player._clone.loader.x,_loc9_);
|
||||
_player.heartbeat(_frameTime);
|
||||
updateWindVolume();
|
||||
if(_player._started)
|
||||
{
|
||||
_loc3_ = 700;
|
||||
_loc9_ = 50;
|
||||
_loc11_ = (Math.min(_player._clone.loader.x,_loc3_) - _loc9_) / (_loc3_ - _loc9_);
|
||||
_loc4_ = _player._clone.loader.x - _loc4_;
|
||||
if(_loc4_ > 0)
|
||||
{
|
||||
_layerGroundMove += _loc4_ * _loc11_;
|
||||
_loc2_ = _layerGroundMove;
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_layerGroundMove -= _loc2_;
|
||||
_layerPlayer.x -= _loc2_;
|
||||
_layerBackgroundGround.x -= _loc2_;
|
||||
_layerBackgroundObstacle.x -= _loc2_;
|
||||
_layerBackgroundLauncher.x -= _loc2_;
|
||||
}
|
||||
if(_launcher.loader.parent && _launcher.loader.x + _launcher.width + _layerBackgroundLauncher.x < 0)
|
||||
{
|
||||
_launcher.loader.parent.removeChild(_launcher.loader);
|
||||
}
|
||||
_layerSkyMove += _loc4_ * _loc11_ * 0.125;
|
||||
_loc2_ = _layerSkyMove;
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_layerBackgroundSky.x -= _loc2_;
|
||||
if(_layerBackgroundSky.x < -_sky[0].width)
|
||||
{
|
||||
_layerBackgroundSky.x += _sky[0].width;
|
||||
}
|
||||
_layerSkyMove -= _loc2_;
|
||||
}
|
||||
_loc8_ = _layerBackgroundGround.numChildren - 1;
|
||||
while(_loc8_ >= 0)
|
||||
{
|
||||
_loc12_ = _layerBackgroundGround.getChildAt(_loc8_);
|
||||
if(_loc12_.x + _loc12_.width + _layerBackgroundGround.x < 0)
|
||||
{
|
||||
if(_loc12_.x < _lastChangeBackgroundGroundX)
|
||||
{
|
||||
_loc12_.parent.removeChild(_loc12_);
|
||||
_loc12_ = _layerBackgroundObstacle.getChildAt(_loc8_);
|
||||
_loc12_.parent.removeChild(_loc12_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _addBackgroundGroundX;
|
||||
_loc12_.x = _addBackgroundGroundX;
|
||||
_addBackgroundGroundX += _loc12_.width;
|
||||
_loc12_ = _layerBackgroundObstacle.getChildAt(_loc8_);
|
||||
_loc12_.content.gotoAndPlay("off");
|
||||
_loc12_.content.armadilloSpeedX = 0;
|
||||
_loc12_.x = _loc5_ + _obstacleOffset;
|
||||
}
|
||||
}
|
||||
_loc8_--;
|
||||
}
|
||||
if(_addBackgroundGroundX >= _nextBackgroundSwitch)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
_loc10_ = 1;
|
||||
if(_nextBackgroundSwitch < 100800)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
_loc10_ = 1;
|
||||
}
|
||||
else if(_nextBackgroundSwitch <= 208800)
|
||||
{
|
||||
_loc7_ = 2;
|
||||
_loc10_ = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = 4;
|
||||
_loc10_ = 5;
|
||||
}
|
||||
_loc8_ = _activeBackgroundType + 1;
|
||||
if(_loc8_ > _loc10_ || _loc8_ < _loc7_)
|
||||
{
|
||||
_loc8_ = _loc7_;
|
||||
}
|
||||
setBackgroundActive(_loc8_);
|
||||
}
|
||||
_layerBackgroundMiddle.x = _layerBackgroundLauncher.x / 4;
|
||||
_loc8_ = _layerBackgroundMiddle.numChildren - 1;
|
||||
while(_loc8_ >= 0)
|
||||
{
|
||||
_loc12_ = _layerBackgroundMiddle.getChildAt(_loc8_);
|
||||
if(_loc12_.x + _backgroundElements[0].ground[0].width * 2 + _layerBackgroundMiddle.x < 0)
|
||||
{
|
||||
if(_loc12_.x < _lastChangeMiddleX)
|
||||
{
|
||||
_loc12_.parent.removeChild(_loc12_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.x = _addMiddleX;
|
||||
_loc12_.visible = false;
|
||||
}
|
||||
}
|
||||
else if(_loc12_.visible == false)
|
||||
{
|
||||
if(_loc12_.x <= _lastChangeMiddleX)
|
||||
{
|
||||
_loc12_.parent.removeChild(_loc12_);
|
||||
}
|
||||
else if(_loc12_.x + _backgroundElements[0].ground[0].width * 2 + _layerBackgroundMiddle.x < _backgroundElements[0].ground[0].width * 2)
|
||||
{
|
||||
_addMiddleX += _backgroundElements[0].ground[0].width * 2;
|
||||
_loc12_.visible = true;
|
||||
}
|
||||
}
|
||||
_loc8_--;
|
||||
}
|
||||
}
|
||||
if(_player._started)
|
||||
{
|
||||
_score.loader.content.distance.text = valueTrackerCurrent();
|
||||
}
|
||||
else
|
||||
{
|
||||
_score.loader.content.distance.text = 0;
|
||||
}
|
||||
}
|
||||
if(_particles)
|
||||
{
|
||||
_loc8_ = _particles.length - 1;
|
||||
while(_loc8_ >= 0)
|
||||
{
|
||||
_particles[_loc8_].timeRemaining -= _frameTime;
|
||||
if(_particles[_loc8_].timeRemaining <= 0)
|
||||
{
|
||||
_particles[_loc8_].clone.loader.parent.removeChild(_particles[_loc8_].clone.loader);
|
||||
_scene.releaseCloneAsset(_particles[_loc8_].clone.loader);
|
||||
_particles.splice(_loc8_,1);
|
||||
}
|
||||
_loc8_--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateWindVolume() : void
|
||||
{
|
||||
var _loc1_:SoundTransform = null;
|
||||
if(_windSound && !SBAudio.isMusicMuted)
|
||||
{
|
||||
_loc1_ = _windSound.soundTransform;
|
||||
_loc1_.volume = Math.min(_player._velocity.x / 15000,0.2);
|
||||
_windSound.soundTransform = _loc1_;
|
||||
}
|
||||
}
|
||||
|
||||
public function showGreatJobDlg() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",greatJobKeyDown);
|
||||
stage.addEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
var _loc1_:MovieClip = showDlg("card_longshot_greatjob",[{
|
||||
"name":"button_yes",
|
||||
"f":onGreatJob_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onGreatJob_No
|
||||
}]);
|
||||
_pauseGame = false;
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.text_score,_gemsEarned == 1 ? 11433 : 11432,_gemsEarned);
|
||||
_loc1_.text_score.text.toLowerCase();
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_score.loader.content.distance.text = 0;
|
||||
_gameOverTimer = 0;
|
||||
resetGame();
|
||||
_player = new DistanceChallengePlayer(this);
|
||||
_obstacleOffset = 700;
|
||||
_activeBackgroundType = -1;
|
||||
_addBackgroundGroundX = 0;
|
||||
_addMiddleX = 0;
|
||||
_nextBackgroundSwitch = 0;
|
||||
setBackgroundActive(0);
|
||||
if(_launcher.loader.parent == null)
|
||||
{
|
||||
_layerBackgroundLauncher.addChild(_launcher.loader);
|
||||
}
|
||||
_launcher.loader.content.reset();
|
||||
_soundMan.playByName(_soundNameArmIntro);
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_layerBackgroundSky.x = 0;
|
||||
_layerBackgroundGround.x = 0;
|
||||
_layerBackgroundObstacle.x = 0;
|
||||
_layerBackgroundLauncher.x = 0;
|
||||
_layerBackgroundMiddle.x = 0;
|
||||
_layerPlayer.x = 0;
|
||||
_layerSkyMove = 0;
|
||||
_layerGroundMove = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_windSound != null)
|
||||
{
|
||||
_windSound.stop();
|
||||
_windSound = null;
|
||||
}
|
||||
if(_gearsSound != null)
|
||||
{
|
||||
_gearsSound.stop();
|
||||
_gearsSound = null;
|
||||
}
|
||||
if(_particles)
|
||||
{
|
||||
while(_particles.length > 0)
|
||||
{
|
||||
_particles[0].clone.loader.parent.removeChild(_particles[0].clone.loader);
|
||||
_scene.releaseCloneAsset(_particles[0].clone.loader);
|
||||
_particles.splice(0,1);
|
||||
}
|
||||
}
|
||||
if(_transition.loader.parent != null)
|
||||
{
|
||||
_transition.loader.parent.removeChild(_transition.loader);
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 6)
|
||||
{
|
||||
if(_sky[0].loader.parent)
|
||||
{
|
||||
_sky[0].loader.parent.removeChild(_sky[0].loader);
|
||||
}
|
||||
if(_sky[1].loader.parent)
|
||||
{
|
||||
_sky[1].loader.parent.removeChild(_sky[1].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].ground[0].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].ground[0].loader.parent.removeChild(_backgroundElements[_loc1_].ground[0].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].ground[1].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].ground[1].loader.parent.removeChild(_backgroundElements[_loc1_].ground[1].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].obstacle[0].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].obstacle[0].loader.parent.removeChild(_backgroundElements[_loc1_].obstacle[0].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].obstacle[1].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].obstacle[1].loader.parent.removeChild(_backgroundElements[_loc1_].obstacle[1].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].middle[0].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].middle[0].loader.parent.removeChild(_backgroundElements[_loc1_].middle[0].loader);
|
||||
}
|
||||
if(_backgroundElements[_loc1_].middle[1].loader.parent)
|
||||
{
|
||||
_backgroundElements[_loc1_].middle[1].loader.parent.removeChild(_backgroundElements[_loc1_].middle[1].loader);
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
if(_player)
|
||||
{
|
||||
_player.remove();
|
||||
_player = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setBackgroundActive(param1:int) : void
|
||||
{
|
||||
if(_activeBackgroundType != param1)
|
||||
{
|
||||
if(_addBackgroundGroundX > 0)
|
||||
{
|
||||
_transition.loader.x = _addBackgroundGroundX - _transition.width / 2;
|
||||
if(_transition.loader.parent == null)
|
||||
{
|
||||
_layerBackgroundLauncher.addChild(_transition.loader);
|
||||
}
|
||||
}
|
||||
_addMiddleX = _addBackgroundGroundX / 4 + 1;
|
||||
if(_addMiddleX > 1 && _addMiddleX + _layerBackgroundMiddle.x < 900)
|
||||
{
|
||||
_addMiddleX = 900 - _layerBackgroundMiddle.x;
|
||||
}
|
||||
_lastChangeBackgroundGroundX = _addBackgroundGroundX;
|
||||
_lastChangeMiddleX = _addMiddleX;
|
||||
if(_sky[0].loader.parent == null)
|
||||
{
|
||||
_layerBackgroundSky.addChild(_sky[0].loader);
|
||||
_sky[0].loader.x = 0;
|
||||
_layerBackgroundSky.addChild(_sky[1].loader);
|
||||
_sky[1].loader.x = _sky[0].width;
|
||||
}
|
||||
_layerBackgroundGround.addChild(_backgroundElements[param1].ground[0].loader);
|
||||
_layerBackgroundObstacle.addChild(_backgroundElements[param1].obstacle[0].loader);
|
||||
_layerBackgroundMiddle.addChild(_backgroundElements[param1].middle[0].loader);
|
||||
_layerBackgroundGround.addChild(_backgroundElements[param1].ground[1].loader);
|
||||
_layerBackgroundObstacle.addChild(_backgroundElements[param1].obstacle[1].loader);
|
||||
_backgroundElements[param1].obstacle[0].loader.content.gotoAndPlay("off");
|
||||
_backgroundElements[param1].obstacle[1].loader.content.gotoAndPlay("off");
|
||||
_backgroundElements[param1].obstacle[0].loader.content.armadilloSpeedX = 0;
|
||||
_backgroundElements[param1].middle[0].loader.visible = true;
|
||||
_backgroundElements[param1].ground[0].loader.x = _addBackgroundGroundX;
|
||||
_backgroundElements[param1].obstacle[0].loader.x = _addBackgroundGroundX + _obstacleOffset;
|
||||
_backgroundElements[param1].middle[0].loader.x = _addMiddleX;
|
||||
_addBackgroundGroundX += _backgroundElements[param1].ground[0].width;
|
||||
_addMiddleX += _backgroundElements[param1].ground[0].width * 2;
|
||||
_backgroundElements[param1].obstacle[1].loader.content.armadilloSpeedX = 0;
|
||||
_backgroundElements[param1].ground[1].loader.x = _addBackgroundGroundX;
|
||||
_backgroundElements[param1].obstacle[1].loader.x = _addBackgroundGroundX + _obstacleOffset;
|
||||
_addBackgroundGroundX += _backgroundElements[param1].ground[0].width;
|
||||
_addMiddleX += _backgroundElements[param1].ground[0].width * 2;
|
||||
_activeBackgroundType = param1;
|
||||
_nextBackgroundSwitch += 7200;
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameOver() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Array = new Array(1000,2000,3000,4000,5000,8000,10000,15000,20000,25000,30000,40000,50000,60000,75000,100000,150000);
|
||||
var _loc1_:Array = new Array(1,2,4,6,8,10,15,20,25,35,50,75,100,125,150,200,250);
|
||||
_gemsEarned = 300;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc3_.length)
|
||||
{
|
||||
if(valueTrackerCurrent() < _loc3_[_loc2_])
|
||||
{
|
||||
_gemsEarned = _loc1_[_loc2_];
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
addGemsToBalance(_gemsEarned);
|
||||
_gameOverTimer = 2;
|
||||
}
|
||||
|
||||
public function addSnowmanHead(param1:Number, param2:Number) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(_particles)
|
||||
{
|
||||
_loc3_ = {};
|
||||
_loc3_.clone = _scene.cloneAsset("snowmanHead");
|
||||
_loc3_.clone.loader.x = _layerBackgroundGround.x + param1;
|
||||
_loc3_.clone.loader.y = param2;
|
||||
_loc3_.clone.loader.contentLoaderInfo.addEventListener("complete",onSnowmanLoad);
|
||||
_loc3_.timeRemaining = 5;
|
||||
addChild(_loc3_.clone.loader);
|
||||
_particles.push(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
public function onSnowmanLoad(param1:Event) : void
|
||||
{
|
||||
param1.target.content.hit(_player._velocity.x,_player._velocity.y);
|
||||
param1.target.removeEventListener("complete",onSnowmanLoad);
|
||||
}
|
||||
|
||||
private function mouseClickHandler(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_player)
|
||||
{
|
||||
if(!_player._started)
|
||||
{
|
||||
if(_launcher.loader.content.launcherOn)
|
||||
{
|
||||
_launcher.loader.content.launch();
|
||||
_player.start();
|
||||
if(_windSound == null)
|
||||
{
|
||||
_windSound = _soundMan.play(SFX_ARM_WIND,0,99999);
|
||||
if(_gearsSound != null)
|
||||
{
|
||||
_gearsSound.stop();
|
||||
_gearsSound = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onGemMultiplierDone() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onGreatJob_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
_displayAchievementTimer = 1;
|
||||
}
|
||||
_closeBtn.visible = true;
|
||||
hideDlg();
|
||||
startGame();
|
||||
}
|
||||
|
||||
private function onGreatJob_No() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
package game.distanceChallenge
|
||||
{
|
||||
import flash.geom.Point;
|
||||
|
||||
public class DistanceChallengePlayer
|
||||
{
|
||||
|
||||
private static const GRAVITY:Number = 4500;
|
||||
|
||||
private static const WIND_RESISTANCE_UP:Number = 10000;
|
||||
|
||||
private static const WIND_RESISTANCE_RIGHT:Number = -120;
|
||||
|
||||
private static const GROUND_RESISTANCE_RIGHT:Number = -2750;
|
||||
|
||||
private static const MAX_DRAG_RIGHT:Number = -500;
|
||||
|
||||
private static const MAX_VELOCITY_UP:Number = 2000;
|
||||
|
||||
private static const MAX_VELOCITY_DOWN:Number = 1000;
|
||||
|
||||
private static const MAX_VELOCITY_RIGHT:Number = 3600;
|
||||
|
||||
public var _theGame:DistanceChallenge;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _velocity:Point;
|
||||
|
||||
public var _acceleration:Point;
|
||||
|
||||
public var _started:Boolean;
|
||||
|
||||
public var _currentObstacleType:int;
|
||||
|
||||
public var _currentObstacleX:Number;
|
||||
|
||||
public var _gameOver:Boolean;
|
||||
|
||||
public var _currentSoundX:Number;
|
||||
|
||||
public var _collisionTimer:Number;
|
||||
|
||||
public function DistanceChallengePlayer(param1:DistanceChallenge)
|
||||
{
|
||||
super();
|
||||
_gameOver = false;
|
||||
_theGame = param1;
|
||||
_started = false;
|
||||
_clone = {};
|
||||
_clone = _theGame.getScene().cloneAsset("player");
|
||||
_clone.loader.visible = false;
|
||||
_theGame._layerPlayer.addChild(_clone.loader);
|
||||
_velocity = new Point(0,0);
|
||||
_acceleration = new Point(0,0);
|
||||
_currentObstacleType = -1;
|
||||
_currentSoundX = -1;
|
||||
_collisionTimer = 0;
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
if(_clone && _clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
if(_clone.loader.content)
|
||||
{
|
||||
_clone.loader.content.reset();
|
||||
_theGame.getScene().releaseCloneAsset(_clone.loader);
|
||||
}
|
||||
_clone = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(_clone.loader.content && param1 > 0)
|
||||
{
|
||||
_loc3_ = Math.round(param1 / 0.0416666666666667);
|
||||
param1 /= _loc3_;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc3_)
|
||||
{
|
||||
updatePlayer(param1);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePlayer(param1:Number) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:* = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
if(_started == false)
|
||||
{
|
||||
_clone.loader.x = _theGame._launcher.loader.content.ArmadilloX;
|
||||
_clone.loader.y = _theGame._launcher.loader.content.ArmadilloY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_clone.loader.content.armadilloAudio == 1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSpmnOpen);
|
||||
_clone.loader.content.armadilloAudio = 0;
|
||||
}
|
||||
else if(_clone.loader.content.armadilloAudio == 2)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSpmnClose);
|
||||
_clone.loader.content.armadilloAudio = 0;
|
||||
}
|
||||
_collisionTimer -= param1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 6)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 2)
|
||||
{
|
||||
if(_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.parent)
|
||||
{
|
||||
if((_loc3_ + 1 == 1 || _loc3_ + 1 == 3) && _clone.loader.x > _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x && _clone.loader.x < _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x + _theGame._backgroundElements[_loc3_].obstacle[_loc5_].width && _velocity.x > 300)
|
||||
{
|
||||
if(_currentSoundX != _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x)
|
||||
{
|
||||
if(Math.random() > 0.5)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmPassBy1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmPassBy2);
|
||||
}
|
||||
_currentSoundX = _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x;
|
||||
}
|
||||
}
|
||||
_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.content.armadilloSpeedX = _velocity.x;
|
||||
if(_clone.loader.y > _clone.y - _clone.height / 3)
|
||||
{
|
||||
if(_currentObstacleType != _loc3_ || _currentObstacleX != _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x)
|
||||
{
|
||||
if(_clone.loader.x > _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x && _clone.loader.x < _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x + _theGame._backgroundElements[_loc3_].obstacle[_loc5_].width)
|
||||
{
|
||||
_currentObstacleType = _loc3_;
|
||||
_currentObstacleX = _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x;
|
||||
_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.content.gotoAndPlay("on");
|
||||
switch(_loc3_ + 1)
|
||||
{
|
||||
case 1:
|
||||
_acceleration.x -= 800;
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_clone.loader.content.cactus();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCactusClsn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
_acceleration.x = Math.max(650,_acceleration.x + 650);
|
||||
_acceleration.y = -2500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-110);
|
||||
_clone.loader.content.geyser();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmGeyser);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_acceleration.x -= 800;
|
||||
_theGame.addSnowmanHead(_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x,_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.y);
|
||||
_clone.loader.content.snowman();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSnwmnClsn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_acceleration.x = Math.max(1000,_acceleration.x + 1000);
|
||||
_acceleration.y = -3500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-150);
|
||||
_clone.loader.content.mole();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmMole);
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmWonderwmn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_acceleration.x -= 800;
|
||||
_clone.loader.content.other1();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmStump);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
_acceleration.x = Math.max(1000,_acceleration.x + 1000);
|
||||
_acceleration.y = -3500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-150);
|
||||
_clone.loader.content.other2();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmLsSteam);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_clone.loader.y >= _clone.y + _clone.height / 2)
|
||||
{
|
||||
_acceleration.x += -2750 * param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_acceleration.x += -120 * param1;
|
||||
}
|
||||
if(_acceleration.x < -500)
|
||||
{
|
||||
_acceleration.x = -500;
|
||||
}
|
||||
if(_acceleration.y < 0)
|
||||
{
|
||||
_acceleration.y += 10000 * param1;
|
||||
}
|
||||
else if(_velocity.y != 0 || _clone.loader.y < _clone.y + _clone.height / 2)
|
||||
{
|
||||
_acceleration.y += 4500 * param1;
|
||||
}
|
||||
_loc2_ = _velocity.x;
|
||||
_loc4_ = _velocity.y;
|
||||
_velocity.x += _acceleration.x * param1;
|
||||
_velocity.x = Math.min(_velocity.x,3600);
|
||||
_velocity.x = Math.max(_velocity.x,0);
|
||||
if(_velocity.y < 0)
|
||||
{
|
||||
_velocity.y += _acceleration.y * param1;
|
||||
if(_velocity.y > 0)
|
||||
{
|
||||
_velocity.y = 50;
|
||||
_acceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y += _acceleration.y * param1;
|
||||
}
|
||||
_velocity.y = Math.min(_velocity.y,2000);
|
||||
_velocity.y = Math.max(_velocity.y,-1000);
|
||||
if(_loc2_ != 0 && _velocity.x < 2)
|
||||
{
|
||||
_velocity.x = 0;
|
||||
_acceleration.x = 0;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmOutro);
|
||||
if(_theGame._windSound != null)
|
||||
{
|
||||
_theGame._windSound.stop();
|
||||
_theGame._windSound = null;
|
||||
}
|
||||
}
|
||||
_clone.loader.x += _velocity.x * param1;
|
||||
_clone.loader.y += _velocity.y * param1;
|
||||
_clone.loader.content.armadillo.armadillo.rotation += 2500 * (_velocity.x / 3600 * param1);
|
||||
_theGame.valueTracker(Math.round((_clone.loader.x - _clone.x) / 10));
|
||||
if(_clone.loader.y > _clone.y + _clone.height / 2 && _velocity.y > 0)
|
||||
{
|
||||
_clone.loader.y = _clone.y + _clone.height / 2;
|
||||
if(_velocity.y < 75)
|
||||
{
|
||||
_velocity.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y = -0.47 * _velocity.y;
|
||||
}
|
||||
_acceleration.y = 0;
|
||||
if(_velocity.y != 0)
|
||||
{
|
||||
_clone.loader.content.bounce();
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmBounce);
|
||||
_loc3_ = Math.random() * 3;
|
||||
switch(_loc3_)
|
||||
{
|
||||
case 0:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision1);
|
||||
break;
|
||||
case 1:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision2);
|
||||
break;
|
||||
default:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision3);
|
||||
}
|
||||
}
|
||||
}
|
||||
_clone.loader.content.armadilloSpeedX = _velocity.x;
|
||||
_clone.loader.content.armadilloSpeedY = _velocity.y;
|
||||
_clone.loader.content.armadilloX = _clone.loader.x;
|
||||
_clone.loader.content.armadilloY = _clone.loader.y;
|
||||
if(!_gameOver && _velocity.x == 0)
|
||||
{
|
||||
_theGame.setGameOver();
|
||||
_gameOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function start() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(!_started)
|
||||
{
|
||||
_clone.loader.visible = true;
|
||||
_loc1_ = 600 * _theGame._launcher.loader.content.firePower;
|
||||
if(_theGame._launcher.loader.content.adjustedStringAngle == 0)
|
||||
{
|
||||
_velocity.y = _loc1_;
|
||||
}
|
||||
else if(_theGame._launcher.loader.content.adjustedStringAngle == 180)
|
||||
{
|
||||
_velocity.y = -_loc1_ * 0.5;
|
||||
}
|
||||
else if(_theGame._launcher.loader.content.adjustedStringAngle > 90)
|
||||
{
|
||||
_velocity.y = Math.cos(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
_velocity.x = Math.sin(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y = Math.cos(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
_velocity.x = Math.sin(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
}
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmLaunch);
|
||||
_started = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user