mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01: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
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,610 @@
|
||||
package game.riverRace
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import game.MinigameManager;
|
||||
|
||||
public class RiverRacePlayer
|
||||
{
|
||||
|
||||
private static const MAX_THROTTLE:Number = 50;
|
||||
|
||||
private static const MAX_RAPIDS_THROTTLE:Number = 1000;
|
||||
|
||||
private static const MAX_ACCELERATION:int = 400;
|
||||
|
||||
private static const SIDE_ACCELERATION:int = 700;
|
||||
|
||||
private static const SIDE_DECELERATION:int = 300;
|
||||
|
||||
private static const MAX_SPEED:int = 300;
|
||||
|
||||
private static const MIN_SPEED:int = 200;
|
||||
|
||||
private static const ROCK_SPEED:int = 100;
|
||||
|
||||
private static const WHIRLPOOL_SPEED:int = 100;
|
||||
|
||||
private static const MAX_SIDE_SPEED:int = 200;
|
||||
|
||||
private static const UPDATE_POSITION_TIME:Number = 0.25;
|
||||
|
||||
private static const PROGRESSBAR_RANGE:int = 500;
|
||||
|
||||
private static const MAX_SPEED_TIME:Number = 2;
|
||||
|
||||
public var _theGame:RiverRace;
|
||||
|
||||
public var _localPlayer:Boolean;
|
||||
|
||||
public var _netID:int;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _updatePositionTimer:Number;
|
||||
|
||||
public var _lastFrameVelocity:Point;
|
||||
|
||||
public var _maxSpeed:int;
|
||||
|
||||
public var _currentVelocity:Point;
|
||||
|
||||
public var _currentAcceleration:Point;
|
||||
|
||||
public var _serverVelocity:Point;
|
||||
|
||||
public var _serverAcceleration:Point;
|
||||
|
||||
public var _serverPosition:Point;
|
||||
|
||||
public var _gemCount:int;
|
||||
|
||||
public var _waitingForAllLoaded:Boolean;
|
||||
|
||||
public var _debugCircle:Sprite;
|
||||
|
||||
public var _finished:Boolean;
|
||||
|
||||
public var _radius:Number;
|
||||
|
||||
public var _speedMultiplier:Number;
|
||||
|
||||
public var _color:String;
|
||||
|
||||
public var _finishedPlace:int;
|
||||
|
||||
public var _dbID:int;
|
||||
|
||||
public var _collisionSoundDelay:Number;
|
||||
|
||||
public var _playerIndex:int;
|
||||
|
||||
public var _maxSpeedTimer:Number;
|
||||
|
||||
public var _decelerateThrottle:Number;
|
||||
|
||||
public var _turboSoundTimer:Number;
|
||||
|
||||
public var _rockSoundTimer:Number;
|
||||
|
||||
public var _whirlpoolSoundTimer:Number;
|
||||
|
||||
public var _fastActive:Boolean;
|
||||
|
||||
public var _userName:String;
|
||||
|
||||
public function RiverRacePlayer(param1:RiverRace)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
}
|
||||
|
||||
public function init(param1:String, param2:int, param3:Array, param4:int, param5:String) : int
|
||||
{
|
||||
_netID = parseInt(param3[param4++]);
|
||||
_localPlayer = _theGame.myId == _netID;
|
||||
_finishedPlace = 0;
|
||||
_maxSpeed = 200;
|
||||
_maxSpeedTimer = 0;
|
||||
_decelerateThrottle = 50;
|
||||
_turboSoundTimer = 0;
|
||||
_rockSoundTimer = 0;
|
||||
_whirlpoolSoundTimer = 0;
|
||||
_fastActive = false;
|
||||
_playerIndex = _theGame.getPlayerIndex(_localPlayer);
|
||||
_dbID = param2;
|
||||
_userName = param1;
|
||||
_lastFrameVelocity = new Point();
|
||||
_currentVelocity = new Point();
|
||||
_currentAcceleration = new Point();
|
||||
_serverVelocity = new Point();
|
||||
_serverAcceleration = new Point();
|
||||
_serverPosition = new Point();
|
||||
_finished = false;
|
||||
_color = param5;
|
||||
_theGame._progressBar.clone.loader.content.sizeColor(_localPlayer ? "large" : "small",_color,_playerIndex);
|
||||
_theGame._progressBar.clone.loader.content.boatProgress[_playerIndex] = 0;
|
||||
_theGame._progressBar.clone.loader.content.boatRange[_playerIndex] = 500;
|
||||
_clone = _theGame.getScene().cloneAsset("player_raft");
|
||||
_clone.loader.contentLoaderInfo.addEventListener("complete",onRaftLoaderComplete);
|
||||
_clone.loader.x = parseInt(param3[param4++]);
|
||||
_clone.loader.y = parseInt(param3[param4++]);
|
||||
_clone.loader.y = _theGame._startingLine.loader.y + _theGame._startingLine.height;
|
||||
_serverPosition.x = _clone.loader.x;
|
||||
_serverPosition.y = _clone.loader.y;
|
||||
_gemCount = 0;
|
||||
_collisionSoundDelay = 0;
|
||||
_updatePositionTimer = 0;
|
||||
_waitingForAllLoaded = false;
|
||||
if(_localPlayer)
|
||||
{
|
||||
_theGame._layerLocalPlayer.addChild(_clone.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._layerPlayers.addChild(_clone.loader);
|
||||
}
|
||||
_radius = Math.min(_clone.width,_clone.height) / 2;
|
||||
_speedMultiplier = 1;
|
||||
return param4;
|
||||
}
|
||||
|
||||
public function onRaftLoaderComplete(param1:Event) : void
|
||||
{
|
||||
if(_localPlayer)
|
||||
{
|
||||
_clone.loader.content.gotoAndStop(_color + "_big");
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.loader.content.gotoAndStop(_color + "_small");
|
||||
}
|
||||
_clone.loader.content.wake.alpha = 0;
|
||||
_clone.loader.content.slow();
|
||||
param1.target.removeEventListener("complete",onRaftLoaderComplete);
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
_theGame._progressBar.clone.loader.content.sizeColor("small","none",_playerIndex);
|
||||
if(_clone && _clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
}
|
||||
if(_debugCircle && _debugCircle.parent)
|
||||
{
|
||||
_debugCircle.parent.removeChild(_debugCircle);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:Point = null;
|
||||
var _loc2_:* = null;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc9_:Point = null;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc3_:Array = null;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc6_:Point = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
if(!_waitingForAllLoaded)
|
||||
{
|
||||
if(_maxSpeedTimer > 0)
|
||||
{
|
||||
_maxSpeedTimer -= param1;
|
||||
if(_maxSpeedTimer <= 0)
|
||||
{
|
||||
_maxSpeed = 200;
|
||||
_decelerateThrottle = 50;
|
||||
updateRaftEffect(false);
|
||||
}
|
||||
}
|
||||
_loc7_ = new Point();
|
||||
_loc10_ = _maxSpeed;
|
||||
if(_collisionSoundDelay > 0)
|
||||
{
|
||||
_collisionSoundDelay -= param1;
|
||||
}
|
||||
if(_turboSoundTimer > 0)
|
||||
{
|
||||
_turboSoundTimer -= param1;
|
||||
}
|
||||
if(_rockSoundTimer > 0)
|
||||
{
|
||||
_rockSoundTimer -= param1;
|
||||
}
|
||||
if(_whirlpoolSoundTimer > 0)
|
||||
{
|
||||
_whirlpoolSoundTimer -= param1;
|
||||
}
|
||||
_loc7_.x = _serverPosition.x + _clone.width / 2;
|
||||
_loc7_.y = _serverPosition.y + _clone.height / 2;
|
||||
if(!_finished)
|
||||
{
|
||||
_loc10_ *= _speedMultiplier;
|
||||
}
|
||||
if(_serverAcceleration.x != 0)
|
||||
{
|
||||
_serverVelocity.x += param1 * _serverAcceleration.x;
|
||||
if(_serverVelocity.x > 200)
|
||||
{
|
||||
_serverVelocity.x = 200;
|
||||
}
|
||||
else if(_serverVelocity.x < -200)
|
||||
{
|
||||
_serverVelocity.x = -200;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x > 0)
|
||||
{
|
||||
_serverVelocity.x -= 300 * param1;
|
||||
if(_serverVelocity.x < 0)
|
||||
{
|
||||
_serverVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x < 0)
|
||||
{
|
||||
_serverVelocity.x += 300 * param1;
|
||||
if(_serverVelocity.x > 0)
|
||||
{
|
||||
_serverVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
if(!_finished)
|
||||
{
|
||||
if(_serverAcceleration.y > -400)
|
||||
{
|
||||
if(_speedMultiplier > 1)
|
||||
{
|
||||
_serverAcceleration.y -= 1000 * param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.y -= _decelerateThrottle * param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.y = 0;
|
||||
}
|
||||
if(_serverAcceleration.y > 0)
|
||||
{
|
||||
if(_serverVelocity.y < _loc10_)
|
||||
{
|
||||
_serverVelocity.y += param1 * _serverAcceleration.y;
|
||||
if(_serverVelocity.y > _loc10_)
|
||||
{
|
||||
_serverVelocity.y = _loc10_;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.y > _loc10_)
|
||||
{
|
||||
_serverVelocity.y -= _decelerateThrottle * param1;
|
||||
if(_serverVelocity.y < _loc10_)
|
||||
{
|
||||
_serverVelocity.y = _loc10_;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_serverAcceleration.y < 0)
|
||||
{
|
||||
if(_serverVelocity.y > -_loc10_)
|
||||
{
|
||||
_serverVelocity.y += param1 * _serverAcceleration.y;
|
||||
if(_serverVelocity.y < -_loc10_)
|
||||
{
|
||||
_serverVelocity.y = -_loc10_;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.y < -_loc10_)
|
||||
{
|
||||
_serverVelocity.y += _decelerateThrottle * param1;
|
||||
if(_serverVelocity.y > -_loc10_)
|
||||
{
|
||||
_serverVelocity.y = -_loc10_;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.y > 0)
|
||||
{
|
||||
_serverVelocity.y -= 2 * _decelerateThrottle * param1;
|
||||
if(_serverVelocity.y < 0)
|
||||
{
|
||||
_serverVelocity.y = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.y < 0)
|
||||
{
|
||||
if(_finished)
|
||||
{
|
||||
_serverVelocity.y += 6 * _decelerateThrottle * param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverVelocity.y += 2 * _decelerateThrottle * param1;
|
||||
}
|
||||
if(_serverVelocity.y > 0)
|
||||
{
|
||||
_serverVelocity.y = 0;
|
||||
}
|
||||
}
|
||||
_lastFrameVelocity.x = param1 * _serverVelocity.x;
|
||||
_lastFrameVelocity.y = param1 * _serverVelocity.y;
|
||||
_loc7_.x = _serverPosition.x + _clone.width / 2;
|
||||
_loc7_.y = _serverPosition.y + _clone.height / 2;
|
||||
if(_lastFrameVelocity.x != 0 || _lastFrameVelocity.y != 0)
|
||||
{
|
||||
_speedMultiplier = 1;
|
||||
_loc9_ = _theGame.TestShoreCollision(this,_loc7_,_lastFrameVelocity,_radius);
|
||||
if(_loc9_)
|
||||
{
|
||||
_loc11_ = _serverVelocity.length;
|
||||
_maxSpeed = 100;
|
||||
_maxSpeedTimer = 0.25;
|
||||
_decelerateThrottle = 10 * 50;
|
||||
if(_localPlayer && _collisionSoundDelay <= 0 && _loc11_ > _maxSpeed / 2)
|
||||
{
|
||||
_collisionSoundDelay = 0.25;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameCollision);
|
||||
}
|
||||
_serverVelocity.x = _loc9_.x;
|
||||
_serverVelocity.y = _loc9_.y;
|
||||
_serverVelocity.x *= _loc11_;
|
||||
_serverVelocity.y *= _loc11_;
|
||||
_lastFrameVelocity.x = param1 * _serverVelocity.x;
|
||||
_lastFrameVelocity.y = param1 * _serverVelocity.y;
|
||||
_loc11_ = _serverVelocity.length;
|
||||
}
|
||||
}
|
||||
_serverPosition.x += _lastFrameVelocity.x;
|
||||
if(_serverPosition.x + _clone.width > 900)
|
||||
{
|
||||
_serverPosition.x = 900 - _clone.width;
|
||||
}
|
||||
else if(_serverPosition.x < 0)
|
||||
{
|
||||
_serverPosition.x = 0;
|
||||
}
|
||||
_serverPosition.y += _lastFrameVelocity.y;
|
||||
if(_clone.loader.content)
|
||||
{
|
||||
if(_serverVelocity.y < -25)
|
||||
{
|
||||
if(_clone.loader.content.wake.alpha < 1)
|
||||
{
|
||||
_clone.loader.content.wake.alpha += 0.5 * param1;
|
||||
if(_clone.loader.content.wake.alpha > 1)
|
||||
{
|
||||
_clone.loader.content.wake.alpha = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_clone.loader.content.wake.alpha > 0)
|
||||
{
|
||||
_clone.loader.content.wake.alpha -= 3 * param1;
|
||||
if(_clone.loader.content.wake.alpha < 0)
|
||||
{
|
||||
_clone.loader.content.wake.alpha = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc15_ = 500 * -_serverPosition.y / _theGame._maxTotalY;
|
||||
if(_loc15_ > 500)
|
||||
{
|
||||
_loc15_ = 500;
|
||||
}
|
||||
_theGame._progressBar.clone.loader.content.boatProgress[_playerIndex] = _loc15_;
|
||||
if(_localPlayer)
|
||||
{
|
||||
_clone.loader.x = _serverPosition.x;
|
||||
_clone.loader.y = _serverPosition.y;
|
||||
if(!_finished)
|
||||
{
|
||||
if(_theGame._riverCurrentSegment > _theGame._levelProgression.length)
|
||||
{
|
||||
if(_clone.loader.y <= _theGame._finishLine.loader.y + _theGame._finishLine.height / 2)
|
||||
{
|
||||
_finished = true;
|
||||
_loc3_ = [];
|
||||
_loc3_[0] = "finished";
|
||||
MinigameManager.msg(_loc3_);
|
||||
}
|
||||
}
|
||||
if(!_finished)
|
||||
{
|
||||
if(_theGame._rightArrowDown)
|
||||
{
|
||||
_serverAcceleration.x = 700;
|
||||
}
|
||||
else if(_theGame._leftArrowDown)
|
||||
{
|
||||
_serverAcceleration.x = -700;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
_updatePositionTimer += param1;
|
||||
if(_updatePositionTimer > 0.25)
|
||||
{
|
||||
_loc3_ = [];
|
||||
_loc3_[0] = "pos";
|
||||
_loc3_[1] = String(int(_clone.loader.x));
|
||||
_loc3_[2] = String(int(_clone.loader.y));
|
||||
_loc3_[3] = String(int(_serverAcceleration.x));
|
||||
_loc3_[4] = String(int(_serverAcceleration.y));
|
||||
_loc3_[5] = String(int(_serverVelocity.x));
|
||||
_loc3_[6] = String(int(_serverVelocity.y));
|
||||
MinigameManager.msg(_loc3_);
|
||||
_updatePositionTimer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new Point();
|
||||
_loc6_.x = _clone.loader.x;
|
||||
_loc6_.y = _clone.loader.y;
|
||||
_currentVelocity.x = _serverPosition.x - _clone.loader.x;
|
||||
_currentVelocity.y = _serverPosition.y - _clone.loader.y;
|
||||
_loc4_ = Point.distance(_loc6_,_serverPosition);
|
||||
_loc5_ = 0.2;
|
||||
_clone.loader.x += _currentVelocity.x * _loc5_;
|
||||
_clone.loader.y += _currentVelocity.y * _loc5_;
|
||||
}
|
||||
if(_debugCircle)
|
||||
{
|
||||
_debugCircle.x = _clone.loader.x + _clone.width / 2;
|
||||
_debugCircle.y = _clone.loader.y + _clone.height / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function receivePositionData(param1:Array, param2:int) : int
|
||||
{
|
||||
_serverPosition.x = int(param1[param2++]);
|
||||
_serverPosition.y = int(param1[param2++]);
|
||||
_serverAcceleration.x = int(param1[param2++]);
|
||||
_serverAcceleration.y = int(param1[param2++]);
|
||||
_serverVelocity.x = int(param1[param2++]);
|
||||
_serverVelocity.y = int(param1[param2++]);
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function receiveGem(param1:int) : void
|
||||
{
|
||||
_gemCount += param1;
|
||||
}
|
||||
|
||||
public function insideBuoy() : void
|
||||
{
|
||||
updateRaftEffect(true);
|
||||
_maxSpeed = 300;
|
||||
_maxSpeedTimer = 2;
|
||||
_decelerateThrottle = 50;
|
||||
if(_turboSoundTimer <= 0)
|
||||
{
|
||||
_turboSoundTimer = 1;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameTurbo);
|
||||
}
|
||||
}
|
||||
|
||||
public function insideRock() : void
|
||||
{
|
||||
updateRaftEffect(false);
|
||||
_maxSpeed = 100;
|
||||
_maxSpeedTimer = 0.25;
|
||||
_decelerateThrottle = 10 * 50;
|
||||
if(_rockSoundTimer <= 0)
|
||||
{
|
||||
_rockSoundTimer = 3;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameRockCollision);
|
||||
}
|
||||
}
|
||||
|
||||
public function insideWhirlpool() : void
|
||||
{
|
||||
updateRaftEffect(false);
|
||||
_maxSpeed = 100;
|
||||
_maxSpeedTimer = 0.25;
|
||||
_decelerateThrottle = 10 * 50;
|
||||
if(_whirlpoolSoundTimer <= 0)
|
||||
{
|
||||
_whirlpoolSoundTimer = 3;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameWhirlpoolCollision);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateRaftEffect(param1:Boolean) : void
|
||||
{
|
||||
if(_clone.loader.content)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
if(_fastActive == false || _maxSpeedTimer < 1.5)
|
||||
{
|
||||
_clone.loader.content.fast();
|
||||
_fastActive = true;
|
||||
}
|
||||
}
|
||||
else if(_fastActive == true)
|
||||
{
|
||||
_fastActive = false;
|
||||
_clone.loader.content.slow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setFinishedPlace(param1:int, param2:int) : void
|
||||
{
|
||||
_finishedPlace = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
if(param2 == 4)
|
||||
{
|
||||
if(_localPlayer && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).custom1UserVarRef,1);
|
||||
}
|
||||
_gemCount += 30;
|
||||
}
|
||||
else if(param2 == 3)
|
||||
{
|
||||
_gemCount += 20;
|
||||
}
|
||||
else if(param2 == 2)
|
||||
{
|
||||
_gemCount += 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gemCount += 5;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(param2 == 4)
|
||||
{
|
||||
_gemCount += 20;
|
||||
}
|
||||
else if(param2 == 3)
|
||||
{
|
||||
_gemCount += 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gemCount += 5;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(param2 == 4)
|
||||
{
|
||||
_gemCount += 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gemCount += 5;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
_gemCount += 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,437 @@
|
||||
package game.riverRace
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
public class RiverSegment
|
||||
{
|
||||
|
||||
public static const SLOT_STARTX:int = 150;
|
||||
|
||||
public static const RIVER_WIDTH:int = 615;
|
||||
|
||||
public var _theGame:RiverRace;
|
||||
|
||||
public var _scene:Sprite;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _riverWater:Object;
|
||||
|
||||
public var _tileID:int;
|
||||
|
||||
public var _flipType:int;
|
||||
|
||||
public var _name:String;
|
||||
|
||||
public var _volumes:Array;
|
||||
|
||||
public var _startEnd:Boolean;
|
||||
|
||||
public var _added:Boolean;
|
||||
|
||||
public var _buoys:Array;
|
||||
|
||||
public var _rocks:Array;
|
||||
|
||||
public var _whirlpools:Array;
|
||||
|
||||
public function RiverSegment(param1:RiverRace)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
}
|
||||
|
||||
public function init(param1:Object, param2:String, param3:Boolean, param4:int = -1, param5:int = 1) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc11_:* = null;
|
||||
var _loc6_:* = null;
|
||||
_scene = new Sprite();
|
||||
_clone = param1;
|
||||
_startEnd = param3;
|
||||
_tileID = param4;
|
||||
_flipType = param5;
|
||||
_name = param2;
|
||||
_added = false;
|
||||
var _loc10_:int = int(param1.loader.x);
|
||||
var _loc13_:int = int(param1.loader.y);
|
||||
_clone.loader.x = 0;
|
||||
_clone.loader.y = 0;
|
||||
flipTile(_clone.loader);
|
||||
_scene.addChild(_clone.loader);
|
||||
var _loc7_:Array = _theGame.getScene().getActorList("ActorVolume");
|
||||
var _loc12_:Number = -1;
|
||||
var _loc9_:Number = -1;
|
||||
_volumes = [];
|
||||
for each(_loc11_ in _loc7_)
|
||||
{
|
||||
if(_loc11_.name.search(param2 + "_volume_") != -1)
|
||||
{
|
||||
_volumes.push(_loc11_.points);
|
||||
}
|
||||
}
|
||||
for each(_loc6_ in _volumes)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc6_.length - 1)
|
||||
{
|
||||
_loc6_[_loc8_].x -= _loc10_;
|
||||
_loc6_[_loc8_].y -= _loc13_;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = _loc6_.length - 1;
|
||||
while(_loc8_ >= 0)
|
||||
{
|
||||
if(_loc6_[_loc8_].x < 0 && _loc6_[_loc8_].y < 0 || _loc6_[_loc8_].x < 0 && _loc6_[_loc8_].y > _clone.loader.height || _loc6_[_loc8_].x > _clone.loader.width && _loc6_[_loc8_].y < 0 || _loc6_[_loc8_].x > _clone.loader.width && _loc6_[_loc8_].y > _clone.loader.height)
|
||||
{
|
||||
_loc6_.splice(_loc8_,1);
|
||||
}
|
||||
else if(_loc6_[_loc8_].y < 0 || _loc6_[_loc8_].y > _clone.loader.height)
|
||||
{
|
||||
if(_loc6_[_loc8_].y < 0)
|
||||
{
|
||||
_loc6_[_loc8_].y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_[_loc8_].y = _clone.loader.height;
|
||||
}
|
||||
if(_loc6_[_loc8_].x < _clone.loader.width - _loc6_[_loc8_].x)
|
||||
{
|
||||
if(_loc12_ == -1)
|
||||
{
|
||||
_loc12_ = Number(_loc6_[_loc8_].x);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_[_loc8_].x = _loc12_;
|
||||
}
|
||||
}
|
||||
else if(_loc9_ == -1)
|
||||
{
|
||||
_loc9_ = Number(_loc6_[_loc8_].x);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_[_loc8_].x = _loc9_;
|
||||
}
|
||||
}
|
||||
_loc8_--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function initRiverWater() : void
|
||||
{
|
||||
_riverWater.loader.content.gotoAndPlay("tile4_1");
|
||||
}
|
||||
|
||||
public function onRiverWaterLoaderComplete(param1:Event) : void
|
||||
{
|
||||
if(_added)
|
||||
{
|
||||
initRiverWater();
|
||||
}
|
||||
param1.target.removeEventListener("complete",onRiverWaterLoaderComplete);
|
||||
}
|
||||
|
||||
public function add(param1:int, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
_added = true;
|
||||
if(_riverWater && _riverWater.loader.content)
|
||||
{
|
||||
initRiverWater();
|
||||
}
|
||||
_scene.x = 0;
|
||||
_scene.y = param1;
|
||||
_theGame._layerBackground.addChild(_scene);
|
||||
if(_startEnd)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_theGame._startingLine.loader.x = 0;
|
||||
_theGame._startingLine.loader.y = param1 + _theGame._startingLine.y;
|
||||
_theGame._currentBuoyY = _theGame._startingLine.loader.y;
|
||||
_theGame._layerForeground.addChild(_theGame._startingLine.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._finishLine.loader.x = 0;
|
||||
_theGame._finishLine.loader.y = param1 + _theGame._finishLine.y;
|
||||
_theGame._layerBackground.addChild(_theGame._finishLine.loader);
|
||||
}
|
||||
}
|
||||
_buoys = [];
|
||||
_rocks = [];
|
||||
_whirlpools = [];
|
||||
while(_theGame._currentBuoyIndex < _theGame._levels[_theGame._levelIndex].length && -_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].offset + _theGame._currentBuoyY >= param1)
|
||||
{
|
||||
_loc3_ = null;
|
||||
_theGame._currentBuoyY += -_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].offset;
|
||||
if(_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].boost)
|
||||
{
|
||||
if(_theGame._inactiveBuoys.length > 0)
|
||||
{
|
||||
_loc3_ = _theGame._inactiveBuoys[0];
|
||||
_theGame._inactiveBuoys.splice(0,1);
|
||||
initBuoy(_loc3_.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _theGame.getScene().cloneAsset("arrows");
|
||||
_loc3_.loader.contentLoaderInfo.addEventListener("complete",onBuoyLoaderComplete);
|
||||
}
|
||||
_loc3_.loader.x = 150 + (615 - _loc3_.width) / 4 * (_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].boost - 1);
|
||||
_loc3_.loader.y = _theGame._currentBuoyY + _theGame._arrowOffsetY;
|
||||
_theGame._layerBuoys.addChild(_loc3_.loader);
|
||||
_buoys.push(_loc3_);
|
||||
}
|
||||
else if(_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].rocks)
|
||||
{
|
||||
if(_theGame._inactiveRocks.length > 0)
|
||||
{
|
||||
_loc3_ = _theGame._inactiveRocks[0];
|
||||
_theGame._inactiveRocks.splice(0,1);
|
||||
initRocks(_loc3_.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _theGame.getScene().cloneAsset("rocks");
|
||||
_loc3_.loader.contentLoaderInfo.addEventListener("complete",onRocksLoaderComplete);
|
||||
}
|
||||
_loc3_.loader.x = 150 + (615 - _loc3_.width) / 4 * (_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].rocks - 1);
|
||||
_theGame._layerBuoys.addChild(_loc3_.loader);
|
||||
_loc3_.loader.y = _theGame._currentBuoyY + _theGame._rocksOffsetY;
|
||||
_rocks.push(_loc3_);
|
||||
}
|
||||
else if(_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].whirlpool)
|
||||
{
|
||||
if(_theGame._inactiveWhirlpools.length > 0)
|
||||
{
|
||||
_loc3_ = _theGame._inactiveWhirlpools[0];
|
||||
_theGame._inactiveWhirlpools.splice(0,1);
|
||||
initWhirlpool(_loc3_.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _theGame.getScene().cloneAsset("whirlpool");
|
||||
_loc3_.loader.contentLoaderInfo.addEventListener("complete",onWhirlpoolLoaderComplete);
|
||||
}
|
||||
_loc3_.loader.x = 150 + (615 - _loc3_.width) / 4 * (_theGame._levels[_theGame._levelIndex][_theGame._currentBuoyIndex].whirlpool - 1);
|
||||
_theGame._layerBuoys.addChild(_loc3_.loader);
|
||||
_loc3_.loader.y = _theGame._currentBuoyY + _theGame._whirlpoolOffsetY;
|
||||
_whirlpools.push(_loc3_);
|
||||
}
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_._active = true;
|
||||
}
|
||||
_theGame._currentBuoyIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
var _loc1_:* = null;
|
||||
_added = false;
|
||||
while(_buoys && _buoys.length > 0)
|
||||
{
|
||||
if(_buoys[0].loader.parent)
|
||||
{
|
||||
_buoys[0].loader.parent.removeChild(_buoys[0].loader);
|
||||
}
|
||||
_theGame._inactiveBuoys.push(_buoys[0]);
|
||||
_buoys.splice(0,1);
|
||||
}
|
||||
_buoys = null;
|
||||
while(_rocks && _rocks.length > 0)
|
||||
{
|
||||
if(_rocks[0].loader.parent)
|
||||
{
|
||||
_rocks[0].loader.parent.removeChild(_rocks[0].loader);
|
||||
}
|
||||
_theGame._inactiveRocks.push(_rocks[0]);
|
||||
_rocks.splice(0,1);
|
||||
}
|
||||
_rocks = null;
|
||||
while(_whirlpools && _whirlpools.length > 0)
|
||||
{
|
||||
if(_whirlpools[0].loader.parent)
|
||||
{
|
||||
_whirlpools[0].loader.parent.removeChild(_whirlpools[0].loader);
|
||||
}
|
||||
_theGame._inactiveWhirlpools.push(_whirlpools[0]);
|
||||
_whirlpools.splice(0,1);
|
||||
}
|
||||
_whirlpools = null;
|
||||
if(_riverWater && _riverWater.loader.content)
|
||||
{
|
||||
_riverWater.loader.content.stop();
|
||||
}
|
||||
if(_startEnd)
|
||||
{
|
||||
if(_theGame._startingLine.loader.parent)
|
||||
{
|
||||
_theGame._startingLine.loader.parent.removeChild(_theGame._startingLine.loader);
|
||||
}
|
||||
if(_theGame._finishLine.loader.parent)
|
||||
{
|
||||
_theGame._finishLine.loader.parent.removeChild(_theGame._finishLine.loader);
|
||||
}
|
||||
}
|
||||
_scene.parent.removeChild(_scene);
|
||||
}
|
||||
|
||||
public function onBuoyLoaderComplete(param1:Event) : void
|
||||
{
|
||||
initBuoy(param1.target);
|
||||
param1.target.removeEventListener("complete",onBuoyLoaderComplete);
|
||||
}
|
||||
|
||||
public function onRocksLoaderComplete(param1:Event) : void
|
||||
{
|
||||
initRocks(param1.target);
|
||||
param1.target.removeEventListener("complete",onRocksLoaderComplete);
|
||||
}
|
||||
|
||||
public function onWhirlpoolLoaderComplete(param1:Event) : void
|
||||
{
|
||||
initWhirlpool(param1.target);
|
||||
param1.target.removeEventListener("complete",onWhirlpoolLoaderComplete);
|
||||
}
|
||||
|
||||
public function initBuoy(param1:Object) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function initRocks(param1:Object) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function initWhirlpool(param1:Object) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function flipTile(param1:Object) : void
|
||||
{
|
||||
var _loc6_:Matrix = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
if(_flipType > 1)
|
||||
{
|
||||
_loc6_ = param1.transform.matrix;
|
||||
_loc6_.identity();
|
||||
_loc3_ = 1;
|
||||
_loc5_ = 1;
|
||||
_loc2_ = Number(param1.x);
|
||||
_loc4_ = Number(param1.y);
|
||||
if(_flipType == 2 || _flipType == 4)
|
||||
{
|
||||
_loc3_ *= -1;
|
||||
_loc2_ += param1.content.width;
|
||||
}
|
||||
if(_flipType == 3 || _flipType == 4)
|
||||
{
|
||||
_loc5_ *= -1;
|
||||
_loc4_ += param1.content.height;
|
||||
}
|
||||
_loc6_.scale(_loc3_,_loc5_);
|
||||
_loc6_.translate(_loc2_,_loc4_);
|
||||
param1.transform.matrix = _loc6_;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHeight() : int
|
||||
{
|
||||
return _clone.loader.height;
|
||||
}
|
||||
|
||||
public function toggleRiverWater() : void
|
||||
{
|
||||
if(_riverWater && _riverWater.loader.content)
|
||||
{
|
||||
if(_riverWater.loader.parent)
|
||||
{
|
||||
_riverWater.loader.parent.removeChild(_riverWater.loader);
|
||||
_riverWater.loader.content.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_scene.addChild(_riverWater.loader);
|
||||
initRiverWater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testObstacleCollision(param1:RiverRacePlayer, param2:Point, param3:Point, param4:int) : void
|
||||
{
|
||||
var _loc8_:Rectangle = null;
|
||||
var _loc5_:Rectangle = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
if(param1._clone.loader.content)
|
||||
{
|
||||
_loc8_ = new Rectangle(param1._clone.loader.x + param1._clone.loader.content.collision.x,param1._clone.loader.y + param1._clone.loader.content.collision.y,param1._clone.loader.content.collision.width,param1._clone.loader.content.collision.height);
|
||||
_loc5_ = new Rectangle();
|
||||
if(_buoys)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _buoys.length)
|
||||
{
|
||||
_loc5_.x = _buoys[_loc6_].loader.content.collision.x + _buoys[_loc6_].loader.x;
|
||||
_loc5_.y = _buoys[_loc6_].loader.content.collision.y + _buoys[_loc6_].loader.y;
|
||||
_loc5_.width = _buoys[_loc6_].loader.content.collision.width;
|
||||
_loc5_.height = _buoys[_loc6_].loader.content.collision.height;
|
||||
if(_loc8_.intersects(_loc5_))
|
||||
{
|
||||
_buoys[_loc6_].loader.content.activateArrow();
|
||||
param1.insideBuoy();
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
if(_rocks)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _rocks.length)
|
||||
{
|
||||
_loc5_.x = _rocks[_loc9_].loader.content.collision.x + _rocks[_loc9_].loader.x;
|
||||
_loc5_.y = _rocks[_loc9_].loader.content.collision.y + _rocks[_loc9_].loader.y;
|
||||
_loc5_.width = _rocks[_loc9_].loader.content.collision.width;
|
||||
_loc5_.height = _rocks[_loc9_].loader.content.collision.height;
|
||||
if(_loc8_.intersects(_loc5_))
|
||||
{
|
||||
param1.insideRock();
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
if(_whirlpools)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _whirlpools.length)
|
||||
{
|
||||
_loc5_.x = _whirlpools[_loc7_].loader.content.collision.x + _whirlpools[_loc7_].loader.x;
|
||||
_loc5_.y = _whirlpools[_loc7_].loader.content.collision.y + _whirlpools[_loc7_].loader.y;
|
||||
_loc5_.width = _whirlpools[_loc7_].loader.content.collision.width;
|
||||
_loc5_.height = _whirlpools[_loc7_].loader.content.collision.height;
|
||||
if(_loc8_.intersects(_loc5_))
|
||||
{
|
||||
param1.insideWhirlpool();
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user