Section 1
//Exponential (fl.motion.easing.Exponential)
package fl.motion.easing {
public class Exponential {
public function Exponential(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
return (((t == d)) ? (b + c) : ((c * (-(Math.pow(2, ((-10 * t) / d))) + 1)) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return (((t == 0)) ? b : ((c * Math.pow(2, (10 * ((t / d) - 1)))) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
if (t == 0){
return (b);
};
if (t == d){
return ((b + c));
};
t = (t / (d / 2));
if (t < 1){
return ((((c / 2) * Math.pow(2, (10 * (t - 1)))) + b));
};
--t;
return ((((c / 2) * (-(Math.pow(2, (-10 * t))) + 2)) + b));
}
}
}//package fl.motion.easing
Section 2
//Bounce (fl.transitions.easing.Bounce)
package fl.transitions.easing {
public class Bounce {
public function Bounce(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
t = (t / d);
if (t < (1 / 2.75)){
return (((c * ((7.5625 * t) * t)) + b));
};
if (t < (2 / 2.75)){
t = (t - (1.5 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.75)) + b));
};
if (t < (2.5 / 2.75)){
t = (t - (2.25 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.9375)) + b));
};
t = (t - (2.625 / 2.75));
return (((c * (((7.5625 * t) * t) + 0.984375)) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return (((c - easeOut((d - t), 0, c, d)) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
if (t < (d / 2)){
return (((easeIn((t * 2), 0, c, d) * 0.5) + b));
};
return ((((easeOut(((t * 2) - d), 0, c, d) * 0.5) + (c * 0.5)) + b));
}
}
}//package fl.transitions.easing
Section 3
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
public var begin:Number;// = NAN
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var change:Number;// = NAN
private var _finish:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(obj:Object, prop:String, func:Function, begin:Number, finish:Number, duration:Number, useSeconds:Boolean=false){
isPlaying = false;
obj = null;
prop = "";
func = function (t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
};
begin = NaN;
change = NaN;
useSeconds = false;
prevTime = NaN;
prevPos = NaN;
looping = false;
_duration = NaN;
_time = NaN;
_fps = NaN;
_position = NaN;
_startTime = NaN;
_intervalID = 0;
_finish = NaN;
_timer = null;
super();
if (!arguments.length){
return;
};
this.obj = obj;
this.prop = prop;
this.begin = begin;
this.position = begin;
this.duration = duration;
this.useSeconds = useSeconds;
if ((func is Function)){
this.func = func;
};
this.finish = finish;
this._timer = new Timer(100);
this.start();
}
public function continueTo(finish:Number, duration:Number):void{
this.begin = this.position;
this.finish = finish;
if (!isNaN(duration)){
this.duration = duration;
};
this.start();
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(fps:Number):void{
var oldIsPlaying:Boolean;
oldIsPlaying = this.isPlaying;
this.stopEnterFrame();
this._fps = fps;
if (oldIsPlaying){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function startEnterFrame():void{
var milliseconds:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
milliseconds = (1000 / this._fps);
this._timer.delay = milliseconds;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function set time(t:Number):void{
this.prevTime = this._time;
if (t > this.duration){
if (this.looping){
this.rewind((t - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (t < 0){
this.rewind();
this.update();
} else {
this._time = t;
this.update();
};
};
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function getPosition(t:Number=NaN):Number{
if (isNaN(t)){
t = this._time;
};
return (this.func(t, this.begin, this.change, this._duration));
}
public function set finish(value:Number):void{
this.change = (value - this.begin);
}
public function set duration(d:Number):void{
this._duration = ((d)<=0) ? Infinity : d;
}
public function setPosition(p:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = p);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(event:Event):void{
this.nextFrame();
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(timerEvent:TimerEvent):void{
this.nextFrame();
timerEvent.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(t:Number=0):void{
this._time = t;
this.fixTime();
this.update();
}
public function set position(p:Number):void{
this.setPosition(p);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 4
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var time:Number;// = NAN
public var position:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(type:String, time:Number, position:Number, bubbles:Boolean=false, cancelable:Boolean=false){
time = NaN;
position = NaN;
super(type, bubbles, cancelable);
this.time = time;
this.position = position;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 5
//MainTimeline (ocean_traders_v12_fla.MainTimeline)
package ocean_traders_v12_fla {
import flash.display.*;
public dynamic class MainTimeline extends MovieClip {
public var oGame:Game;
public function MainTimeline(){
super();
addFrameScript(0, frame1);
}
function frame1(){
oGame = new Game(this);
}
}
}//package ocean_traders_v12_fla
Section 6
//_iconRouteCost_mc (_iconRouteCost_mc)
package {
import flash.display.*;
public dynamic class _iconRouteCost_mc extends MovieClip {
public function _iconRouteCost_mc(){
super();
}
}
}//package
Section 7
//admiral_btn (admiral_btn)
package {
import flash.display.*;
public dynamic class admiral_btn extends MovieClip {
public function admiral_btn(){
super();
}
}
}//package
Section 8
//Bulbous (Bulbous)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.media.*;
import flash.utils.*;
public class Bulbous {
private var _player:Player;
private var _sndTipRollover:Sound;
private var _popUp:MovieClip;
private var _adText:TextField;
private var _pm:PortManager;
private var _bulbous:MovieClip;
private var _tipText:TextField;
private var _sndTipSelect:Sound;
private var _bigFont:TextFormat;
private var _doneButton:Button;
private var _dispObj:MovieClip;
private var _advert:MovieClip;
public function Bulbous(disp:MovieClip, pm:PortManager, player:Player){
super();
_dispObj = disp;
_pm = pm;
_player = player;
_bulbous = new tipGuy_btn();
_bulbous.visible = false;
_bulbous.x = (55 - (_bulbous.width / 2));
_bulbous.y = (275 - (_bulbous.height / 2));
_dispObj.addChild(_bulbous);
_advert = new tipGuyAdvert_mc();
_advert.x = (350 - (_advert.width / 2));
_advert.y = (90 - (_advert.height / 2));
_bigFont = new TextFormat();
_bigFont.size = 32;
_adText = new TextField();
_adText.x = 200;
_adText.y = 40;
_adText.width = 300;
_adText.height = 300;
_adText.wordWrap = true;
_adText.text = "Gimme a silver and I'll give you a tip!";
_adText.setTextFormat(_bigFont);
_popUp = new popUp_mc();
_popUp.x = (320 - (_popUp.width / 2));
_popUp.y = (240 - (_popUp.height / 2));
_tipText = new TextField();
_tipText.x = 175;
_tipText.y = 100;
_tipText.width = 300;
_tipText.height = 300;
_tipText.wordWrap = true;
_tipText.setTextFormat(_bigFont);
_sndTipRollover = new tip_rollover2();
_sndTipSelect = new tip_select2();
}
public function giveTipEnd(id:String){
_bulbous.addEventListener(MouseEvent.CLICK, this.giveTip);
_bulbous.addEventListener(MouseEvent.ROLL_OVER, this.adOn);
_bulbous.addEventListener(MouseEvent.ROLL_OUT, this.adOff);
_doneButton.die();
_dispObj.removeChild(_popUp);
_dispObj.removeChild(_tipText);
}
public function adOff(e:MouseEvent){
_dispObj.removeChild(_advert);
_dispObj.removeChild(_adText);
}
public function giveTip(e:MouseEvent){
var ch:SoundChannel;
if (_player.getSilver() < 2){
return;
};
_bulbous.removeEventListener(MouseEvent.CLICK, this.giveTip);
_bulbous.removeEventListener(MouseEvent.ROLL_OVER, this.adOn);
_bulbous.removeEventListener(MouseEvent.ROLL_OUT, this.adOff);
_dispObj.removeChild(_advert);
_dispObj.removeChild(_adText);
ch = _sndTipSelect.play();
setTipText();
_player.addSilver(-1);
_pm.updateStatusText();
_dispObj.addChild(_popUp);
_dispObj.addChild(_tipText);
_doneButton = new Button(280, 300, 0, 0, "?", 0, new done_btn(), "done", false, _dispObj, this.giveTipEnd);
}
public function end(){
_bulbous.visible = false;
_bulbous.removeEventListener(MouseEvent.CLICK, this.giveTip);
_bulbous.removeEventListener(MouseEvent.ROLL_OVER, this.adOn);
_bulbous.removeEventListener(MouseEvent.ROLL_OUT, this.adOff);
}
public function start(){
_bulbous.visible = true;
_bulbous.addEventListener(MouseEvent.CLICK, this.giveTip);
_bulbous.addEventListener(MouseEvent.ROLL_OVER, this.adOn);
_bulbous.addEventListener(MouseEvent.ROLL_OUT, this.adOff);
}
public function adOn(e:MouseEvent){
var ch:SoundChannel;
ch = _sndTipRollover.play();
_dispObj.addChild(_advert);
_dispObj.addChild(_adText);
}
public function setTipText(){
var portNames:Array;
var port1:int;
var port2:int;
var item:*;
var p1:*;
var ex1:*;
var p2:*;
var ex2:*;
var v1:*;
var v2:*;
portNames = ["Havana", "San Domingo", "Puerto Cabezas", "Santa Marta", "Cape Coral", "San Juan", "Kingston", "Parlamar"];
do {
port1 = _pm.getCurrentPort();
do {
port2 = (Math.random() * 8);
} while (port1 == port2);
item = (Math.random() * 10);
p1 = _pm.getPort(port1);
ex1 = p1.getExchange();
p2 = _pm.getPort(port2);
ex2 = p2.getExchange();
v1 = ex1.getValueByIndex(item);
v2 = ex2.getValueByIndex(item);
if (v1 > v2){
_tipText.text = ((((("I hear " + ex1.getPrintedNameByIndex(item)) + " is ") + (v1 - v2)) + " less expensive in ") + portNames[port2]);
_tipText.setTextFormat(_bigFont);
} else {
if (v2 > v1){
_tipText.text = ((((("I hear " + ex1.getPrintedNameByIndex(item)) + " sells for ") + (v2 - v1)) + " more in ") + portNames[port2]);
_tipText.setTextFormat(_bigFont);
};
};
} while (v1 == v2);
}
}
}//package
Section 9
//Button (Button)
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
public class Button {
var _displayObj:Object;
var _x:int;
var _gfx:MovieClip;
var _id:String;
var _start:int;
var _bounce:Boolean;
var _func:Function;
var _playthis:Tween;
var _finish:int;
var _y:int;
public function Button(x:int, y:int, strt:int, finish:int, property:String, time:Number, graphic:MovieClip, id:String, bounce:Boolean, displayObj:Object, func:Function):void{
super();
_x = x;
_y = y;
_start = strt;
_finish = finish;
_gfx = graphic;
_id = id;
_bounce = bounce;
_func = func;
_displayObj = displayObj;
_gfx.addEventListener(MouseEvent.CLICK, this.Exit);
_displayObj.addChild(_gfx);
_gfx.x = _x;
_gfx.y = _y;
if (bounce == true){
_playthis = new Tween(_gfx, property, Bounce.easeOut, _start, _finish, time, true);
};
}
public function die():void{
_displayObj.removeChild(_gfx);
}
public function Exit(event:MouseEvent){
_func(_id);
}
}
}//package
Section 10
//captain_btn (captain_btn)
package {
import flash.display.*;
public dynamic class captain_btn extends MovieClip {
public function captain_btn(){
super();
}
}
}//package
Section 11
//credits_btn (credits_btn)
package {
import flash.display.*;
public dynamic class credits_btn extends MovieClip {
public function credits_btn(){
super();
}
}
}//package
Section 12
//done_btn (done_btn)
package {
import flash.display.*;
public dynamic class done_btn extends MovieClip {
public function done_btn(){
super();
}
}
}//package
Section 13
//endGame_btn (endGame_btn)
package {
import flash.display.*;
public dynamic class endGame_btn extends MovieClip {
public function endGame_btn(){
super();
}
}
}//package
Section 14
//Exchange (Exchange)
package {
class Exchange {
private const _itemCount = 10;
private var _items:Array;
private var words:Array;
private var list:Array;
function Exchange(difficulty:String):void{
var a:int;
var b:int;
var mult:Number;
var i:int;
var price:int;
var o:Object;
_items = new Array();
list = ["fur", "sugar", "wood", "copper", "fish", "fruit", "spices", "tools", "tobacco", "wool"];
words = ["Fur", "Sugar", "Wood", "Copper", "Fish", "Fruit", "Spices", "Tools", "Tobacco", "Wool"];
super();
a = 40;
b = 10;
switch (difficulty){
case "easy":
mult = 0.5;
case "normal":
mult = 1;
case "hard":
mult = 1.5;
};
i = 0;
while (i < _itemCount) {
price = ((Math.random() * a) + b);
o = {item:list[i], value:(price * mult)};
_items.push(o);
a = (a + 40);
b = (b + 10);
i++;
};
}
public function getValueByIndex(index:int):int{
return (_items[index].value);
}
public function getNameByIndex(index:int):String{
return (list[index]);
}
public function getPrintedNameByIndex(index:int):String{
return (words[index]);
}
public function shuffle():void{
_items.sort(((Math.random() * 3) - 1));
}
public function getValue(item:String):int{
var i:int;
i = 0;
while (i < _items.length) {
if (_items[i].item == item){
return (_items[i].value);
};
i++;
};
return (0);
}
}
}//package
Section 15
//exitGame_btn (exitGame_btn)
package {
import flash.display.*;
public dynamic class exitGame_btn extends MovieClip {
public function exitGame_btn(){
super();
}
}
}//package
Section 16
//fight_btn (fight_btn)
package {
import flash.display.*;
public dynamic class fight_btn extends MovieClip {
public function fight_btn(){
super();
}
}
}//package
Section 17
//Game (Game)
package {
import flash.display.*;
import flash.text.*;
import flash.media.*;
public class Game {
var _popUp:MovieClip;
var oHelpMenu:Menu;
var oDiffMenu:Menu;
var _uiClick:ui_click;
var _turns:int;
var oRoute:Route;
var _newgameButton:Button;
var _port:int;
var oCreditsMenu:Menu;
var oMap:Map;
var oMenu:Menu;
var oPlayer:Player;
var _displayObj:MovieClip;
var _bigFont:TextFormat;
var _endText:TextField;
var oPortManager:PortManager;
public function Game(displayObj:MovieClip):void{
var bigFont:TextFormat;
_uiClick = new ui_click();
super();
_displayObj = displayObj;
bigFont = new TextFormat();
bigFont.size = 32;
Start();
}
public function Start():void{
var channel:SoundChannel;
oMenu = new Menu(menuMain_mc, _displayObj);
oMenu.draw();
oMenu.addButton(0, 150, 1, 150, "x", 2, new play_btn(), "play", true, this.Difficulty);
oMenu.addButton(640, 200, 640, 150, "x", 2, new help_btn(), "help", true, this.Help);
oMenu.addButton(0, 250, 1, 150, "x", 2, new credits_btn(), "exit", true, this.Credits);
channel = _uiClick.play();
}
public function gameOver(){
var didPoor:String;
var didOK:String;
var didWell:String;
var didVeryWell:String;
var silver:int;
var summaryJudgement:*;
didPoor = "Better luck next time, matey, lets play again!";
didOK = "A good haul, but ye can do better!";
didWell = "Ye doubled your money! Can you do another trip for us Captain McMoneybags?";
didVeryWell = "Shiver me timbers, ye be the best trader these old eyes have ever seen!";
oPortManager.portRemoveMenuButton();
_popUp = new popUp_mc();
_popUp.x = (320 - (_popUp.width / 2));
_popUp.y = (240 - (_popUp.height / 2));
_displayObj.addChild(_popUp);
silver = oPlayer.getSilver();
summaryJudgement = didPoor;
if (silver > 2000){
summaryJudgement = didOK;
};
if (silver > 4000){
summaryJudgement = didWell;
};
if (silver > 20000){
summaryJudgement = didVeryWell;
};
_endText = new TextField();
_endText.x = 165;
_endText.y = 110;
_endText.width = 350;
_endText.height = 260;
_endText.wordWrap = true;
_bigFont = new TextFormat();
_bigFont.size = 32;
_endText.text = ((("Game Over!\n\nYour booty: " + silver) + "\n") + summaryJudgement);
_endText.setTextFormat(_bigFont);
_displayObj.addChild(_endText);
_newgameButton = new Button(250, 330, 640, 250, "x", 1, new newGame_btn(), "newgame", false, _displayObj, this.gameOverStartAgain);
}
public function Credits(which:String){
trace(("the button pressed was " + which));
oMenu.die();
oCreditsMenu = new Menu(menuCredits_mc, _displayObj);
oCreditsMenu.draw();
oCreditsMenu.addButton(500, 480, 480, 420, "y", 2, new done_btn(), "exitcredits", true, this.ExitCredits);
}
public function turnCost(amt:int){
_turns = (_turns - amt);
}
public function getTurns():int{
return (_turns);
}
public function Difficulty(which:String){
var channel:SoundChannel;
trace(("the button pressed was " + which));
oMenu.die();
oDiffMenu = new Menu(menuMain_mc, _displayObj);
oDiffMenu.draw();
oDiffMenu.addButton(150, 150, 1, 150, "y", 2, new sailor_btn(), "easy", true, this.SetDiffMode);
oDiffMenu.addButton(150, 200, 1, 200, "y", 2.1, new captain_btn(), "normal", true, this.SetDiffMode);
oDiffMenu.addButton(150, 250, 1, 250, "y", 2.2, new admiral_btn(), "hard", true, this.SetDiffMode);
channel = _uiClick.play();
}
public function ExitHelp(which:String){
oHelpMenu.die();
Start();
}
public function SetDiffMode(which:String){
trace(("game difficulty is " + which));
oDiffMenu.die();
_port = 0;
_turns = 50;
oMap = new Map(_displayObj);
oMap.draw();
oRoute = new Route(which, _displayObj);
oRoute.drawAllRoutes(_port, getTurns());
oPortManager = new PortManager(_displayObj, which, oRoute, oMap, this);
oPortManager.setPort(_port);
oPortManager.setConnectingPortsActive();
oPortManager.drawPorts();
oPortManager.bouncePorts();
oPortManager.drawConnectingGoods();
oPlayer = new Player(_displayObj);
oPlayer.setPort(_port);
oPlayer.draw();
oPortManager.setPlayerObj(oPlayer);
oPortManager.drawStatusText();
oPortManager.portMenuButtonStart();
}
public function gameOverStartAgain(id:String){
Start();
}
public function Help(which:String){
trace(("the button pressed was " + which));
oMenu.die();
oHelpMenu = new Menu(menuHelp_mc, _displayObj);
oHelpMenu.draw();
oHelpMenu.addButton(500, 480, 480, 420, "y", 2, new done_btn(), "exithelp", true, this.ExitHelp);
}
public function ExitCredits(which:String){
oCreditsMenu.die();
Start();
}
public function Exit(which:String){
oMenu.die();
}
}
}//package
Section 18
//game_over (game_over)
package {
import flash.media.*;
public dynamic class game_over extends Sound {
public function game_over(){
super();
}
}
}//package
Section 19
//help_btn (help_btn)
package {
import flash.display.*;
public dynamic class help_btn extends MovieClip {
public function help_btn(){
super();
}
}
}//package
Section 20
//iconCopper_mc (iconCopper_mc)
package {
import flash.display.*;
public dynamic class iconCopper_mc extends MovieClip {
public function iconCopper_mc(){
super();
}
}
}//package
Section 21
//iconFish_mc (iconFish_mc)
package {
import flash.display.*;
public dynamic class iconFish_mc extends MovieClip {
public function iconFish_mc(){
super();
}
}
}//package
Section 22
//iconFruit_mc (iconFruit_mc)
package {
import flash.display.*;
public dynamic class iconFruit_mc extends MovieClip {
public function iconFruit_mc(){
super();
}
}
}//package
Section 23
//iconFur_mc (iconFur_mc)
package {
import flash.display.*;
public dynamic class iconFur_mc extends MovieClip {
public function iconFur_mc(){
super();
}
}
}//package
Section 24
//iconPirateAttack_mc (iconPirateAttack_mc)
package {
import flash.display.*;
public dynamic class iconPirateAttack_mc extends MovieClip {
public function iconPirateAttack_mc(){
super();
}
}
}//package
Section 25
//iconPort_mc (iconPort_mc)
package {
import flash.display.*;
public dynamic class iconPort_mc extends MovieClip {
public function iconPort_mc(){
super();
}
}
}//package
Section 26
//iconShip_mc (iconShip_mc)
package {
import flash.display.*;
public dynamic class iconShip_mc extends MovieClip {
public function iconShip_mc(){
super();
addFrameScript(0, frame1, 23, frame24, 47, frame48);
}
function frame1(){
stop();
}
function frame24(){
stop();
}
function frame48(){
gotoAndStop(1);
}
}
}//package
Section 27
//iconShipAtPort_mc (iconShipAtPort_mc)
package {
import flash.display.*;
public dynamic class iconShipAtPort_mc extends MovieClip {
public function iconShipAtPort_mc(){
super();
}
}
}//package
Section 28
//iconSpices_mc (iconSpices_mc)
package {
import flash.display.*;
public dynamic class iconSpices_mc extends MovieClip {
public function iconSpices_mc(){
super();
}
}
}//package
Section 29
//iconSugar_mc (iconSugar_mc)
package {
import flash.display.*;
public dynamic class iconSugar_mc extends MovieClip {
public function iconSugar_mc(){
super();
}
}
}//package
Section 30
//iconTipGuy_mc (iconTipGuy_mc)
package {
import flash.display.*;
public dynamic class iconTipGuy_mc extends MovieClip {
public function iconTipGuy_mc(){
super();
}
}
}//package
Section 31
//iconTobacco_mc (iconTobacco_mc)
package {
import flash.display.*;
public dynamic class iconTobacco_mc extends MovieClip {
public function iconTobacco_mc(){
super();
}
}
}//package
Section 32
//iconTools_mc (iconTools_mc)
package {
import flash.display.*;
public dynamic class iconTools_mc extends MovieClip {
public function iconTools_mc(){
super();
}
}
}//package
Section 33
//iconToolsLARGE_mc (iconToolsLARGE_mc)
package {
import flash.display.*;
public dynamic class iconToolsLARGE_mc extends MovieClip {
public function iconToolsLARGE_mc(){
super();
}
}
}//package
Section 34
//iconWood_mc (iconWood_mc)
package {
import flash.display.*;
public dynamic class iconWood_mc extends MovieClip {
public function iconWood_mc(){
super();
}
}
}//package
Section 35
//iconWoodLARGE_mc (iconWoodLARGE_mc)
package {
import flash.display.*;
public dynamic class iconWoodLARGE_mc extends MovieClip {
public function iconWoodLARGE_mc(){
super();
}
}
}//package
Section 36
//iconWool_mc (iconWool_mc)
package {
import flash.display.*;
public dynamic class iconWool_mc extends MovieClip {
public function iconWool_mc(){
super();
}
}
}//package
Section 37
//Inventory (Inventory)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.media.*;
public class Inventory {
private const _iconSize = 47;
private var _invHeight:int;
private var _disp:MovieClip;
private var _pickup:Sound;
private var _dragItemIndex:int;
private var _screenX:int;
private var _screenY:int;
private var _inv:Array;
private var _invWidth:int;
private var _dragging:Boolean;
private var _dragItem:Object;
private var _next:Object;
private var _invItemGfx:Array;
public function Inventory(disp:MovieClip, invHeight:int, invWidth:int, x:int, y:int, next:Object){
var i:int;
var j:int;
var o:Object;
_invItemGfx = new Array();
super();
_pickup = new item_place();
_dragItem = new Object();
_dragItem.item = null;
_dragItem.value = 0;
_dragging = false;
_disp = disp;
_next = next;
_inv = new Array(invHeight);
i = 0;
while (i < invHeight) {
_inv[i] = new Array(invWidth);
j = 0;
while (j < invWidth) {
o = {item:String, value:int};
o.item = null;
o.value = 0;
_inv[i][j] = o;
j++;
};
i++;
};
_invHeight = invHeight;
_invWidth = invWidth;
_screenX = x;
_screenY = y;
}
public function fillValues(ex:Exchange):void{
var invItem:*;
var y:int;
var x:int;
invItem = null;
y = 0;
while (y < (_invHeight - 1)) {
x = 0;
while (x < (_invWidth - 1)) {
invItem = _inv[y][x];
invItem.value = ex.getValue(invItem.item);
x++;
};
y++;
};
y = 0;
while (y < _invItemGfx.length) {
invItem = _invItemGfx[y];
invItem.value = ex.getValue(invItem.istring);
y++;
};
}
public function clearInvSpace(row:int, col:int){
trace(((("clearing space at x" + col) + ", y") + row));
switch (_inv[row][col].item){
case "wood":
case "tools":
_inv[row][(col + 1)].item = null;
_inv[row][(col + 1)].value = 0;
_inv[(row + 1)][col].item = null;
_inv[(row + 1)][col].value = 0;
_inv[(row + 1)][(col + 1)].item = null;
_inv[(row + 1)][(col + 1)].value = 0;
break;
case "temp1":
_inv[row][(col - 1)].item = null;
_inv[row][(col - 1)].value = 0;
_inv[(row + 1)][(col - 1)].item = null;
_inv[(row + 1)][(col - 1)].value = 0;
_inv[(row + 1)][col].item = null;
_inv[(row + 1)][col].value = 0;
break;
case "temp2":
_inv[(row - 1)][(col + 1)].item = null;
_inv[(row - 1)][(col + 1)].value = 0;
_inv[(row - 1)][col].item = null;
_inv[(row - 1)][col].value = 0;
_inv[row][(col + 1)].item = null;
_inv[row][(col + 1)].value = 0;
break;
case "temp3":
_inv[(row - 1)][(col - 1)].item = null;
_inv[(row - 1)][(col - 1)].value = 0;
_inv[(row - 1)][col].item = null;
_inv[(row - 1)][col].value = 0;
_inv[row][(col - 1)].item = null;
_inv[row][(col - 1)].value = 0;
break;
};
_inv[row][col].item = null;
_inv[row][col].value = 0;
}
public function getInvLocation(rc:Object){
var x:int;
var y:int;
x = rc.x;
y = rc.y;
rc.row = int(((y - _screenY) / _iconSize));
rc.col = int(((x - _screenX) / _iconSize));
if ((((((((((((rc.row >= _invHeight)) || ((rc.col >= _invWidth)))) || ((rc.row < 0)))) || ((rc.col < 0)))) || ((y < _screenY)))) || ((x < _screenX)))){
rc.row = -1;
rc.col = -1;
};
}
public function find2x2(coord:Object){
var y:int;
var x:int;
y = 0;
while (y < (_invHeight - 1)) {
x = 0;
while (x < (_invWidth - 1)) {
if ((((((((_inv[y][x].item == null)) && ((_inv[y][(x + 1)].item == null)))) && ((_inv[(y + 1)][x].item == null)))) && ((_inv[(y + 1)][(x + 1)].item == null)))){
coord.x = x;
coord.y = y;
return;
};
x++;
};
y++;
};
coord.x = (coord.y = -1);
}
public function checkClickedInv(x:int, y:int, item:String):Boolean{
var xy:Object;
xy = {x:x, y:y};
getInvLocation(xy);
if ((((xy.row == -1)) || ((xy.col == -1)))){
return (false);
};
return (canFit(xy, item, true));
}
public function canFit(xy:Object, item:String, checkOnly:Boolean):Boolean{
var i:int;
var count:int;
var found:String;
var foundx:int;
var foundy:int;
var foundv:int;
var flist:Array;
var yy:int;
var xx:int;
var t:String;
var xd:int;
var yd:int;
var nx:int;
var ny:int;
var gotit:Boolean;
var b:int;
var o:Object;
var cc:Object;
trace(((("clicked at x" + xy.col) + ", y") + xy.row));
if ((((item == "wood")) || ((item == "tools")))){
if ((((xy.row == (_invHeight - 1))) || ((xy.col == (_invWidth - 1))))){
return (false);
};
count = 0;
found = null;
flist = new Array();
yy = xy.row;
while (yy < (xy.row + 2)) {
xx = xy.col;
while (xx < (xy.col + 2)) {
if (_inv[yy][xx].item != null){
t = _inv[yy][xx].item;
xd = 0;
yd = 0;
switch (t){
case "temp1":
xd = -1;
break;
case "temp2":
yd = -1;
break;
case "temp3":
yd = -1;
xd = -1;
break;
};
nx = (xx + xd);
ny = (yy + yd);
t = _inv[ny][nx].item;
gotit = false;
b = 0;
while (b < flist.length) {
if ((((((flist[b].item == t)) && ((flist[b].x == nx)))) && ((flist[b].y == ny)))){
gotit = true;
};
b++;
};
if (gotit == false){
o = {item:t, x:nx, y:ny};
flist.push(o);
count++;
found = _inv[ny][nx].item;
foundv = _inv[ny][nx].value;
foundx = nx;
foundy = ny;
};
};
xx++;
};
yy++;
};
trace((("found " + count) + " items here"));
trace((("flist is " + flist.length) + " items long"));
if (count > 1){
return (false);
};
xy.itemIndex = -1;
i = 0;
while (i < _invItemGfx.length) {
if ((((_invItemGfx[i].row == foundy)) && ((_invItemGfx[i].col == foundx)))){
trace(("found the item index " + i));
xy.itemIndex = i;
break;
};
i++;
};
xy.item = found;
xy.value = foundv;
if (checkOnly == true){
return (true);
};
if (count){
clearInvSpace(foundy, foundx);
};
return (true);
} else {
if (checkOnly == true){
return (true);
};
cc = {row:xy.row, col:xy.col};
findOrigin(cc);
found = _inv[cc.row][cc.col].item;
foundv = _inv[cc.row][cc.col].value;
clearInvSpace(cc.row, cc.col);
xy.itemIndex = -1;
i = 0;
while (i < _invItemGfx.length) {
if ((((_invItemGfx[i].row == cc.row)) && ((_invItemGfx[i].col == cc.col)))){
trace(("found the item index " + i));
xy.itemIndex = i;
break;
};
i++;
};
};
xy.item = found;
xy.value = foundv;
clearInvSpace(xy.row, xy.col);
return (true);
}
public function erase():void{
var i:int;
i = 0;
while (i < _invItemGfx.length) {
_disp.removeChild(_invItemGfx[i].graphics);
delete _invItemGfx[i].graphics;
_invItemGfx[i] = null;
i++;
};
_invItemGfx = null;
_invItemGfx = new Array();
}
public function showPrices(ex:Exchange):void{
var invItem:Object;
var gfx:MovieClip;
var portVal:int;
var y:int;
y = 0;
while (y < _invItemGfx.length) {
invItem = _invItemGfx[y];
gfx = invItem.graphics;
portVal = ex.getValue(invItem.istring);
if (invItem.value < portVal){
addPNLBorder(gfx, new profit_mc());
} else {
if (invItem.value > portVal){
addPNLBorder(gfx, new loss_mc());
};
};
addPriceTag(gfx);
updatePriceTag(gfx.priceTags, invItem.value);
y++;
};
}
public function removeDraggedItem(index:int){
var gfx:MovieClip;
gfx = _invItemGfx[index].graphics;
gfx.stopDrag();
gfx.visible = false;
gfx.removeEventListener(MouseEvent.CLICK, this.clickedInv);
_disp.removeChild(gfx);
_invItemGfx.splice(index, 1);
_dragging = false;
}
public function portFill(invtypes:Array, amount:int){
var intObjs:Object;
var x:int;
var y:int;
var i:int;
var which:int;
var item:String;
intObjs = {x:0, y:0};
i = 0;
while (i < amount) {
which = (Math.random() * invtypes.length);
item = invtypes[which];
if ((((item == "tools")) || ((item == "wood")))){
find2x2(intObjs);
x = intObjs.x;
y = intObjs.y;
if ((((x == -1)) || ((y == -1)))){
break;
};
_inv[y][(x + 1)].item = "temp1";
_inv[(y + 1)][x].item = "temp2";
_inv[(y + 1)][(x + 1)].item = "temp3";
} else {
find1x1(intObjs);
};
x = intObjs.x;
y = intObjs.y;
_inv[y][x].item = item;
i++;
};
}
public function showDraggedItemPrice():void{
this.addPriceTag(_dragItem.gfx);
this.updatePriceTag(_dragItem.gfx.priceTags, _dragItem.value);
}
public function getItemGfx(item:String, isPriceListIcon:Boolean):MovieClip{
var types:Array;
var icons:Array;
var i:int;
var gfx:MovieClip;
types = ["fur", "sugar", "wood", "copper", "fish", "fruit", "spices", "tools", "tobacco", "wool"];
icons = [iconFur_mc, iconSugar_mc, iconWoodLARGE_mc, iconCopper_mc, iconFish_mc, iconFruit_mc, iconSpices_mc, iconToolsLARGE_mc, iconTobacco_mc, iconWool_mc];
if (isPriceListIcon){
if (item == "wood"){
return (new iconWood_mc());
};
if (item == "tools"){
return (new iconTools_mc());
};
};
i = 0;
while (i < types.length) {
if (types[i] == item){
gfx = new (icons[i]);
return (gfx);
};
i++;
};
return (null);
}
public function loseStarboardInv(){
clearInvSpace(0, 2);
clearInvSpace(1, 2);
clearInvSpace(2, 2);
clearInvSpace(3, 2);
}
public function setInv(x:int, y:int, it:String, v:int){
_inv[y][x].item = it;
_inv[y][x].value = v;
if ((((it == "tools")) || ((it == "wood")))){
_inv[y][(x + 1)].item = "temp1";
_inv[y][(x + 1)].value = 0;
_inv[(y + 1)][x].item = "temp2";
_inv[(y + 1)][x].value = 0;
_inv[(y + 1)][(x + 1)].item = "temp3";
_inv[(y + 1)][(x + 1)].value = 0;
};
}
public function findOrigin(rc:Object){
var xd:int;
var yd:int;
xd = 0;
yd = 0;
if (_inv[rc.row][rc.col].item == "temp1"){
xd = -1;
} else {
if (_inv[rc.row][rc.col].item == "temp2"){
yd = -1;
} else {
if (_inv[rc.row][rc.col].item == "temp3"){
xd = -1;
yd = -1;
};
};
};
rc.row = (rc.row + yd);
rc.col = (rc.col + xd);
}
public function draw():void{
var x:int;
var y:int;
var tsize = ??pushnamespace
;
var i:int;
var j:int;
var invItem:Object;
var item:String;
var scale:Number;
var gfx:MovieClip;
var listitem:Object;
y = _screenY;
tsize = _iconSize;
i = 0;
while (i < _inv.length) {
x = _screenX;
j = 0;
while (j < _inv[i].length) {
invItem = _inv[i][j];
item = invItem.item;
if ((((((((item == "temp1")) || ((item == "temp2")))) || ((item == "temp3")))) || (!(item)))){
x = (x + tsize);
} else {
scale = 1;
if ((((item == "tools")) || ((item == "wood")))){
scale = 2.15;
};
gfx = getItemGfx(item, false);
gfx.x = x;
gfx.y = y;
gfx.scaleX = (gfx.scaleY = 1);
gfx.addEventListener(MouseEvent.CLICK, this.clickedInv);
listitem = {graphics:gfx, istring:item, x:x, y:y, size:(tsize * scale), row:i, col:j, dragging:false, value:invItem.value};
_invItemGfx.push(listitem);
_disp.addChild(gfx);
x = (x + tsize);
};
j++;
};
y = (y + tsize);
i++;
};
}
public function clickedInv(event:MouseEvent){
var e:Object;
var x:int;
var y:int;
var xy:Object;
var stuff:Object;
var d:int;
var which:int;
x = event.stageX;
y = event.stageY;
xy = {x:0, y:0, row:0, col:0};
xy.x = x;
xy.y = y;
getInvLocation(xy);
if ((((xy.row == -1)) || ((xy.col == -1)))){
stuff = {item:String, value:int, itemIndex:int, x:int, y:int, event:MouseEvent};
stuff.item = _dragItem.item;
stuff.value = _dragItem.value;
stuff.itemIndex = _dragItemIndex;
stuff.x = x;
stuff.y = y;
stuff.event = event;
if (_next != null){
_next(stuff);
};
return;
};
if (_dragging == true){
if (true == canFit(xy, _dragItem.item, false)){
trace(("it can fit. we picked up " + xy.item));
_inv[xy.row][xy.col].item = _dragItem.item;
_inv[xy.row][xy.col].value = _dragItem.value;
if ((((_dragItem.item == "tools")) || ((_dragItem.item == "wood")))){
_inv[xy.row][(xy.col + 1)].item = "temp1";
_inv[xy.row][(xy.col + 1)].value = 0;
_inv[(xy.row + 1)][xy.col].item = "temp2";
_inv[(xy.row + 1)][xy.col].value = 0;
_inv[(xy.row + 1)][(xy.col + 1)].item = "temp3";
_inv[(xy.row + 1)][(xy.col + 1)].value = 0;
};
d = _dragItemIndex;
e = _invItemGfx[d];
e.dragging = false;
e.graphics.stopDrag();
e.graphics.x = ((xy.col * _iconSize) + _screenX);
e.graphics.y = ((xy.row * _iconSize) + _screenY);
e.row = xy.row;
e.col = xy.col;
e.x = e.graphics.x;
e.y = e.graphics.y;
playPickup();
if (xy.item != null){
_dragItemIndex = xy.itemIndex;
_dragItem.item = xy.item;
_dragItem.value = xy.value;
d = xy.itemIndex;
e = _invItemGfx[d];
e.dragging = true;
e.graphics.startDrag();
e.graphics.x = (x - 23);
e.graphics.y = (y - 23);
e.x = (e.y = 0);
e.row = (e.col = -1);
_disp.removeChild(e.graphics);
_disp.addChild(e.graphics);
} else {
_dragging = false;
};
} else {
trace("error beep");
};
} else {
which = checkInvClick(x, y);
if (which != -1){
findOrigin(xy);
clearInvSpace(xy.row, xy.col);
e = _invItemGfx[which];
e.value = _invItemGfx[which].value;
e.dragging = true;
e.x = (e.y = 0);
e.row = (e.col = -1);
e.graphics.x = (x - 23);
e.graphics.y = (y - 23);
e.graphics.startDrag();
playPickup();
_disp.removeChild(e.graphics);
_disp.addChild(e.graphics);
_dragItem.item = e.istring;
_dragItem.value = e.value;
_dragItemIndex = which;
_dragging = true;
};
};
trace("---------------FINAL REPORT--------------------");
dump();
}
public function checkInvClick(x:int, y:int):int{
var i:int;
var tmp:Object;
i = 0;
while (i < _invItemGfx.length) {
tmp = _invItemGfx[i];
if ((((((((x >= tmp.x)) && ((y >= tmp.y)))) && ((x <= (tmp.x + tmp.size))))) && ((y <= (tmp.y + tmp.size))))){
return (i);
};
i++;
};
return (-1);
}
private function playPickup():void{
_pickup.play();
}
public function find1x1(coord:Object){
var y:int;
var x:int;
y = 0;
while (y < _invHeight) {
x = 0;
while (x < _invWidth) {
if (!_inv[y][x].item){
coord.x = x;
coord.y = y;
return;
};
x++;
};
y++;
};
coord.x = (coord.y = -1);
}
private function addPriceTag(gfx:MovieClip):void{
var ptWidth:Number;
var ptScale:Number;
var ptHeight:*;
var ptY:Number;
var ptX:Number;
var i:Number;
var priceTag:TextField;
if (gfx.priceTags != null){
return;
};
gfx.priceTags = new Array(5);
ptWidth = (gfx.width - 4);
ptScale = 1;
ptHeight = 22;
ptY = (gfx.height - ptHeight);
ptX = 2;
if (gfx.width > 50){
ptScale = 2;
ptY = (gfx.height - 36);
ptHeight = (ptHeight * 0.5);
ptWidth = (ptWidth * 0.5);
};
i = 0;
while (i < 5) {
priceTag = new TextField();
priceTag.text = " ";
priceTag.mouseEnabled = false;
priceTag.selectable = false;
priceTag.multiline = false;
priceTag.textColor = 0;
priceTag.x = ptX;
priceTag.y = ptY;
priceTag.width = ptWidth;
priceTag.height = 22;
priceTag.scaleX = (priceTag.scaleY = ptScale);
switch (i){
case 0:
priceTag.x = (ptX - 1);
break;
case 1:
priceTag.x = (ptX + 1);
break;
case 2:
priceTag.y = (ptY - 1);
break;
case 3:
priceTag.y = (ptY + 1);
break;
case 4:
priceTag.textColor = 0xFFFFFF;
};
gfx.addChild(priceTag);
gfx.priceTags[i] = priceTag;
i++;
};
}
public function losePortInv(){
clearInvSpace(0, 0);
clearInvSpace(1, 0);
clearInvSpace(2, 0);
clearInvSpace(3, 0);
}
private function addPNLBorder(gfx:MovieClip, b:MovieClip){
b.x = 0;
b.y = 0;
b.scaleX = 1;
b.scaleY = 1;
b.width = gfx.width;
b.height = gfx.height;
b.mouseEnabled = false;
gfx.addChild(b);
}
public function addDraggedItem(item:String, v:int, event:MouseEvent, showPrice:Boolean){
var scale:Number;
var gfx:MovieClip;
var tileSize:*;
var listitem:Object;
scale = 1;
if ((((item == "tools")) || ((item == "wood")))){
scale = 2.15;
};
gfx = getItemGfx(item, false);
gfx.x = (_disp.mouseX - 23);
gfx.y = (_disp.mouseY - 23);
gfx.scaleX = (gfx.scaleY = 1);
gfx.addEventListener(MouseEvent.CLICK, this.clickedInv);
tileSize = (_iconSize * scale);
listitem = {graphics:gfx, istring:item, x:0, y:0, size:tileSize, row:-1, col:-1, dragging:true, value:v};
_invItemGfx.push(listitem);
_disp.addChild(gfx);
gfx.startDrag();
_dragging = true;
_dragItemIndex = (_invItemGfx.length - 1);
_dragItem.item = item;
_dragItem.value = v;
_dragItem.gfx = gfx;
if (showPrice){
addPriceTag(gfx);
updatePriceTag(gfx.priceTags, _dragItem.value);
};
clickedInv(event);
}
private function dump(){
var yy:int;
var output:String;
var xx:int;
yy = 0;
while (yy < _invHeight) {
output = "";
xx = 0;
while (xx < _invWidth) {
output = output.concat(_inv[yy][xx].item);
output = output.concat("(");
output = output.concat(_inv[yy][xx].value);
output = output.concat(") ");
xx++;
};
trace(output);
yy++;
};
}
private function updatePriceTag(tags:Array, price:int){
var fmt:TextFormat;
var i:Number;
if (tags != null){
fmt = new TextFormat(null, 10.5);
i = 0;
while (i < 5) {
tags[i].text = (("" + price) + " Ag");
tags[i].setTextFormat(fmt);
i++;
};
};
}
}
}//package
Section 38
//item_buy (item_buy)
package {
import flash.media.*;
public dynamic class item_buy extends Sound {
public function item_buy(){
super();
}
}
}//package
Section 39
//item_buy_fail (item_buy_fail)
package {
import flash.media.*;
public dynamic class item_buy_fail extends Sound {
public function item_buy_fail(){
super();
}
}
}//package
Section 40
//item_place (item_place)
package {
import flash.media.*;
public dynamic class item_place extends Sound {
public function item_place(){
super();
}
}
}//package
Section 41
//loss_mc (loss_mc)
package {
import flash.display.*;
public dynamic class loss_mc extends MovieClip {
public function loss_mc(){
super();
}
}
}//package
Section 42
//lossLarge_mc (lossLarge_mc)
package {
import flash.display.*;
public dynamic class lossLarge_mc extends MovieClip {
public function lossLarge_mc(){
super();
}
}
}//package
Section 43
//Map (Map)
package {
import flash.text.*;
public class Map {
var _displayObj:Object;
var _theMap:Object;
public function Map(dispObj:Object):void{
super();
_displayObj = dispObj;
_theMap = new mapBackground_mc();
_displayObj.addChild(_theMap);
_theMap.visible = false;
makeRouteCostLabel(-1, -1, 0);
makeRouteCostLabel(1, -1, 0);
makeRouteCostLabel(1, 1, 0);
makeRouteCostLabel(-1, 1, 0);
makeRouteCostLabel(0, 0, 0xFFFFFF);
}
public function erase():void{
_theMap.visible = false;
}
private function makeRouteCostLabel(xOff:int, yOff:int, color:int):void{
var routeCost:TextField;
routeCost = new TextField();
routeCost.text = "3 Turns\n2 Turns\n1 Turn";
routeCost.mouseEnabled = false;
routeCost.selectable = false;
routeCost.multiline = true;
routeCost.height = 55;
routeCost.width = 80;
routeCost.x = (555 + xOff);
routeCost.y = (122 + yOff);
routeCost.textColor = color;
_theMap.addChild(routeCost);
}
public function draw():void{
_theMap.x = 0;
_theMap.y = 0;
_theMap.visible = true;
}
}
}//package
Section 44
//mapBackground_mc (mapBackground_mc)
package {
import flash.display.*;
public dynamic class mapBackground_mc extends MovieClip {
public function mapBackground_mc(){
super();
}
}
}//package
Section 45
//Menu (Menu)
package {
import flash.display.*;
import flash.media.*;
public class Menu {
private var _introSound:sail_very_long;
private var _buttons:Array;
private var _didDraw:Boolean;
private var _drawObj:Object;
private var _backgnd;
public function Menu(backgnd:Object, obj:Object):void{
var channel:SoundChannel;
_introSound = new sail_very_long();
super();
_backgnd = new (backgnd);
channel = _introSound.play();
_drawObj = obj;
_didDraw = false;
}
public function addButton(x:int, y:int, start:int, finish:int, property:String, time:Number, graphic:MovieClip, id:String, bounce:Boolean, func:Function){
var btn:*;
btn = new Button(x, y, start, finish, property, time, graphic, id, bounce, _drawObj, func);
if (!_buttons){
_buttons = new Array(btn);
} else {
_buttons.push(btn);
};
}
public function die():void{
var i:int;
if (_didDraw == true){
_drawObj.removeChild(_backgnd);
};
i = 0;
while (i < _buttons.length) {
_buttons[i].die();
i++;
};
}
public function draw():void{
_backgnd.x = 0;
_backgnd.y = 0;
_drawObj.addChild(_backgnd);
_didDraw = true;
}
}
}//package
Section 46
//menu_btn (menu_btn)
package {
import flash.display.*;
public dynamic class menu_btn extends MovieClip {
public function menu_btn(){
super();
}
}
}//package
Section 47
//menuCredits_mc (menuCredits_mc)
package {
import flash.display.*;
public dynamic class menuCredits_mc extends MovieClip {
public function menuCredits_mc(){
super();
}
}
}//package
Section 48
//menuHelp_mc (menuHelp_mc)
package {
import flash.display.*;
public dynamic class menuHelp_mc extends MovieClip {
public function menuHelp_mc(){
super();
}
}
}//package
Section 49
//menuMain_mc (menuMain_mc)
package {
import flash.display.*;
public dynamic class menuMain_mc extends MovieClip {
public function menuMain_mc(){
super();
}
}
}//package
Section 50
//menuPort_mc (menuPort_mc)
package {
import flash.display.*;
public dynamic class menuPort_mc extends MovieClip {
public function menuPort_mc(){
super();
}
}
}//package
Section 51
//newGame_btn (newGame_btn)
package {
import flash.display.*;
public dynamic class newGame_btn extends MovieClip {
public function newGame_btn(){
super();
}
}
}//package
Section 52
//pirate_flee2 (pirate_flee2)
package {
import flash.media.*;
public dynamic class pirate_flee2 extends Sound {
public function pirate_flee2(){
super();
}
}
}//package
Section 53
//pirate_start2 (pirate_start2)
package {
import flash.media.*;
public dynamic class pirate_start2 extends Sound {
public function pirate_start2(){
super();
}
}
}//package
Section 54
//pirate_win1 (pirate_win1)
package {
import flash.media.*;
public dynamic class pirate_win1 extends Sound {
public function pirate_win1(){
super();
}
}
}//package
Section 55
//Pirates (Pirates)
package {
import flash.display.*;
import flash.text.*;
import flash.media.*;
import flash.utils.*;
public class Pirates {
private var _player:Player;
private var _victorySound:Sound;
private var _pirateText:TextField;
private var _route:Route;
private var _fleeSound:Sound;
private var _piratePopup:MovieClip;
private var _pm:PortManager;
private var _defeatSound:Sound;
private var _runButton:Button;
private var _fightButton:Button;
private var _savedPort:int;
private var _bigFont:TextFormat;
private var _doneButton:Button;
private var _dispObj:MovieClip;
public function Pirates(display:MovieClip, route:Route, player:Player, pm:PortManager):void{
super();
_victorySound = new pirate_win1();
_defeatSound = new pirate_start2();
_fleeSound = new pirate_flee2();
_dispObj = display;
_route = route;
_player = player;
_pm = pm;
}
public function PirateFight(id:String){
var check:int;
var amount:int;
trace("we clicked to FIGHT");
_runButton.die();
_fightButton.die();
check = (Math.random() * 10);
amount = (Math.random() * 100);
if (check > 5){
amount = (amount + 50);
_pirateText.text = (("You whipped the scurvy dogs! You win " + amount) + " silver!");
_player.addSilver(amount);
_pm.updateStatusText();
_victorySound.play();
} else {
_pirateText.text = "You are filled with regret... Lose 50 silver.";
_player.addSilver(-50);
_pm.updateStatusText();
_defeatSound.play();
};
_pirateText.setTextFormat(_bigFont);
_doneButton = new Button(280, 300, 0, 0, "?", 0, new done_btn(), "done", false, _dispObj, this.PirateContinue);
}
public function PirateContinue(id:String){
trace("continuing on from pirate attack");
_doneButton.die();
_dispObj.removeChild(_pirateText);
_dispObj.removeChild(_piratePopup);
_pirateText = null;
_piratePopup = null;
_bigFont = null;
_pm.portReady(_savedPort);
}
public function PirateRun(id:String){
var lose:int;
trace("we clicked to RUN");
_runButton.die();
_fightButton.die();
lose = (Math.random() * 3);
switch (lose){
case 0:
_pirateText.text = "You lose all cargo from the port side of your ship!";
_player.losePortInv();
_defeatSound.play();
break;
case 1:
_pirateText.text = "Clever sailing allows you to escape!";
_fleeSound.play();
break;
case 2:
_pirateText.text = "You lose all cargo from the starboard side of your ship!";
_player.loseStarboardInv();
_defeatSound.play();
break;
};
_pirateText.setTextFormat(_bigFont);
_doneButton = new Button(280, 300, 0, 0, "?", 0, new done_btn(), "done", false, _dispObj, this.PirateContinue);
}
public function start(which:int){
var roll:int;
var chance:int;
roll = (Math.random() * 10);
switch (_pm.getTurnCost()){
case 3:
chance = 9;
break;
case 2:
chance = 7;
break;
case 1:
chance = 5;
break;
};
trace(((("checking for pirates. roll = " + roll) + ", chance = ") + chance));
if ((((roll > chance)) && ((_player.getSilver() > 100)))){
_route.endAnimate();
_savedPort = which;
_piratePopup = new popUp_mc();
_piratePopup.x = (320 - 240);
_piratePopup.y = (240 - 209);
_dispObj.addChild(_piratePopup);
_pirateText = new TextField();
_pirateText.x = 165;
_pirateText.y = 150;
_pirateText.width = 350;
_pirateText.height = 200;
_pirateText.wordWrap = true;
_bigFont = new TextFormat();
_bigFont.size = 32;
_pirateText.text = "You are attacked by PIRATES!";
_pirateText.setTextFormat(_bigFont);
_dispObj.addChild(_pirateText);
_runButton = new Button(280, 250, 0, 0, "?", 0, new run_btn(), "run", false, _dispObj, this.PirateRun);
_fightButton = new Button(280, 300, 0, 0, "?", 0, new fight_btn(), "fight", false, _dispObj, this.PirateFight);
} else {
setTimeout(_pm.portReady, 1000, which);
};
}
}
}//package
Section 56
//play_btn (play_btn)
package {
import flash.display.*;
public dynamic class play_btn extends MovieClip {
public function play_btn(){
super();
}
}
}//package
Section 57
//Player (Player)
package {
import flash.display.*;
import flash.events.*;
public class Player {
private const _invWidth:int = 3;
private const _invHeight:int = 4;
private var _x:int;
private var oInv:Inventory;
private var _buySell:item_buy;
private var oPort:Port;
private var _shipCoords:Array;
private var _ship:MovieClip;
private var _silver;
private var _dispObj:MovieClip;
private var _y:int;
private var _whichPort:int;
public function Player(dispObj:MovieClip){
super();
_dispObj = dispObj;
_ship = new iconShipAtPort_mc();
_dispObj.addChild(_ship);
_ship.visible = false;
_buySell = new item_buy();
_shipCoords = new Array(8);
_shipCoords[0] = new xy(210, 130);
_shipCoords[1] = new xy(322, 286);
_shipCoords[2] = new xy(55, 330);
_shipCoords[3] = new xy(220, 417);
_shipCoords[4] = new xy(35, 70);
_shipCoords[5] = new xy(510, 280);
_shipCoords[6] = new xy(105, 260);
_shipCoords[7] = new xy(495, 415);
oInv = new Inventory(_dispObj, _invHeight, _invWidth, 457, 277, this.clickedOut);
_silver = 2000;
}
public function getSilver():int{
return (_silver);
}
public function getInvLocation(rc:Object){
oInv.getInvLocation(rc);
}
public function addSilver(value:int){
_buySell.play();
_silver = (_silver + value);
trace((("PURCHASE/SALE: we have " + _silver) + " silver left"));
}
public function erasePlayerInv():void{
oInv.erase();
}
public function setPort(which:int){
_whichPort = which;
_x = _shipCoords[which].x;
_y = _shipCoords[which].y;
}
public function draw():void{
_ship.x = _x;
_ship.y = _y;
_ship.visible = true;
}
public function canAfford(stuff:Object){
if (stuff.value > _silver){
return (false);
};
return (true);
}
public function removeDraggedItem(index:int){
oInv.removeDraggedItem(index);
}
public function clickedInv(e:MouseEvent){
oInv.clickedInv(e);
}
public function addDraggedItem(item:String, value:int, event:MouseEvent){
oInv.addDraggedItem(item, value, event, true);
}
public function drawPlayerInv():void{
oInv.draw();
oInv.showPrices(this.oPort.getExchange());
}
public function erase():void{
_ship.visible = false;
}
public function setCurrentPort(port:Port){
oPort = port;
}
public function losePortInv(){
oInv.losePortInv();
}
public function checkClickedInv(x:int, y:int, item:String):Boolean{
return (oInv.checkClickedInv(x, y, item));
}
public function clickedOut(stuff:Object){
var ex:Exchange;
var value:*;
trace(((("clicked outside player inventory with a " + stuff.item) + " which cost us ") + stuff.value));
if (oPort.checkClickedInv(stuff.x, stuff.y, stuff.item) == true){
oInv.removeDraggedItem(stuff.itemIndex);
ex = oPort.getExchange();
value = ex.getValue(stuff.item);
oPort.addDraggedItem(stuff.item, value, stuff.event);
addSilver(value);
oPort.updateStatusText();
};
}
public function loseStarboardInv(){
oInv.loseStarboardInv();
}
}
}//package
class xy {
public var x:int;
public var y:int;
private function xy(xx:int, yy:int){
super();
x = xx;
y = yy;
}
}
Section 58
//popUp_mc (popUp_mc)
package {
import flash.display.*;
public dynamic class popUp_mc extends MovieClip {
public function popUp_mc(){
super();
}
}
}//package
Section 59
//Port (Port)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import fl.transitions.*;
import flash.media.*;
import fl.transitions.easing.*;
import fl.motion.easing.*;
class Port {
private const _amountInvTypes = 3;
private const _invWidth:int = 6;
private const _amountInitialInv = 7;
private const _invHeight:int = 5;
private var _player:Player;
private var oInv:Inventory;
private var _cantBuy:Sound;
private var _exchText:Array;
public var _invtypes:Array;
private var _portCoords:xy;
private var _productLabel:TextField;
private var _active:Boolean;
private var _bounce:Tween;
private var _portManager:PortManager;
private var _portWH:xy;
private var oExchange:Exchange;
private var _dispObj:MovieClip;
private var _gfx:MovieClip;
private var _id:int;
private var _exchIcon:Array;
private var _portGoods:Array;
function Port(pm:PortManager, display:MovieClip, type1:String, type2:String, type3:String, difficulty:String, x:int, y:int, id:int){
var i:int;
var xc:Array;
var yc:Array;
_invtypes = new Array(_amountInvTypes);
super();
_dispObj = display;
_portManager = pm;
_id = id;
_cantBuy = new item_buy_fail();
_gfx = new iconPort_mc();
_dispObj.addChild(_gfx);
_portWH = new xy(0, 0);
_portWH.x = (_gfx.width / 4);
_portWH.y = (_gfx.height / 4);
_gfx.addEventListener(MouseEvent.CLICK, gotoPort);
_gfx.addEventListener(MouseEvent.ROLL_OVER, overPort);
_gfx.addEventListener(MouseEvent.ROLL_OUT, outPort);
_portCoords = new xy(x, y);
_invtypes[0] = type1;
_invtypes[1] = type2;
_invtypes[2] = type3;
oInv = new Inventory(_dispObj, _invHeight, _invWidth, 128, 234, this.clickedOut);
oInv.portFill(_invtypes, _amountInitialInv);
oExchange = new Exchange(difficulty);
_portGoods = new Array(3);
_active = false;
_exchText = new Array(10);
_exchIcon = new Array(10);
i = 0;
while (i < 10) {
xc = [70, 165, 70, 165, 70, 165, 70, 165, 70, 165];
yc = [20, 20, 40, 40, 60, 60, 80, 80, 100, 100];
_exchIcon[i] = oInv.getItemGfx(oExchange.getNameByIndex(i), true);
_exchIcon[i].x = (xc[i] - 20);
_exchIcon[i].y = (yc[i] + 1);
_exchIcon[i].scaleX = 0.45;
_exchIcon[i].scaleY = 0.45;
_exchText[i] = new TextField();
_exchText[i].x = xc[i];
_exchText[i].y = yc[i];
_exchText[i].textColor = 0xFFFFFF;
_exchText[i].text = ((oExchange.getPrintedNameByIndex(i) + ": ") + oExchange.getValueByIndex(i));
i++;
};
}
public function drawGoods():void{
_portGoods[0].draw();
_portGoods[1].draw();
_portGoods[2].draw();
_productLabel.visible = true;
}
public function getInvLocation(rc:Object){
oInv.getInvLocation(rc);
}
public function gotoPort(event:MouseEvent):void{
trace(("trying to click on #" + _id));
if (_active == false){
return;
};
trace(((("clicked on port at " + _portCoords.x) + ", ") + _portCoords.y));
_portManager.portClicked(_id);
}
public function setGoods(x:int, y:int){
var gfx:MovieClip;
var goodsLabel:TextField;
gfx = null;
goodsLabel = new TextField();
goodsLabel.text = "This Port Produces";
goodsLabel.mouseEnabled = false;
goodsLabel.selectable = false;
goodsLabel.multiline = false;
goodsLabel.height = 22;
goodsLabel.width = 150;
goodsLabel.textColor = 4294967295;
goodsLabel.x = x;
goodsLabel.y = (y - 18);
goodsLabel.visible = false;
_dispObj.addChild(goodsLabel);
gfx = oInv.getItemGfx(_invtypes[0], true);
_portGoods[0] = new PortItem(gfx, x, y, _invtypes[0], _dispObj);
gfx = oInv.getItemGfx(_invtypes[1], true);
_portGoods[1] = new PortItem(gfx, (x + 41), y, _invtypes[1], _dispObj);
gfx = oInv.getItemGfx(_invtypes[2], true);
_portGoods[2] = new PortItem(gfx, (x + 82), y, _invtypes[2], _dispObj);
_productLabel = goodsLabel;
}
public function setActive(value:Boolean){
if (_active == true){
_gfx.scaleX = 1;
_gfx.scaleY = 1;
_gfx.x = _portCoords.x;
_gfx.y = _portCoords.y;
};
_active = value;
}
public function getExchange():Exchange{
return (oExchange);
}
public function removeDraggedItem(index:int){
oInv.removeDraggedItem(index);
}
public function erase():void{
_gfx.visible = false;
}
public function bounce():void{
_bounce = new Tween(_gfx, "y", Bounce.easeOut, 1, _portCoords.y, 1.3, true);
}
public function checkClickedInv(x:int, y:int, item:String):Boolean{
return (oInv.checkClickedInv(x, y, item));
}
public function clickedOut(stuff:Object){
trace(((("clicked outside port inventory with " + stuff.item) + " which cost ") + stuff.value));
if (_player.checkClickedInv(stuff.x, stuff.y, stuff.item) == true){
if (_player.canAfford(stuff) == true){
oInv.removeDraggedItem(stuff.itemIndex);
_player.addDraggedItem(stuff.item, stuff.value, stuff.event);
_player.addSilver(-(stuff.value));
_portManager.updateStatusText();
} else {
_cantBuy.play();
};
};
}
public function draw():void{
_gfx.x = _portCoords.x;
_gfx.y = _portCoords.y;
_gfx.visible = true;
}
public function drawPortInv():void{
var i:int;
i = 0;
while (i < _exchIcon.length) {
_dispObj.addChild(_exchIcon[i]);
_dispObj.addChild(_exchText[i]);
i++;
};
oInv.draw();
oInv.fillValues(oExchange);
}
public function eraseGoods():void{
_portGoods[0].erase();
_portGoods[1].erase();
_portGoods[2].erase();
_productLabel.visible = false;
}
public function setPlayer(player:Player){
_player = player;
}
public function clearInv():void{
var i:int;
i = 0;
while (i < _exchIcon.length) {
_dispObj.removeChild(_exchIcon[i]);
_dispObj.removeChild(_exchText[i]);
i++;
};
oInv.erase();
oInv = null;
oInv = new Inventory(_dispObj, _invHeight, _invWidth, 128, 234, this.clickedOut);
oInv.portFill(_invtypes, _amountInitialInv);
}
public function outPort(event:MouseEvent):void{
trace(("moved away from #" + _id));
if (_active == false){
return;
};
_gfx.scaleX = 1;
_gfx.scaleY = 1;
_gfx.x = (_gfx.x + _portWH.x);
_gfx.y = (_gfx.y + _portWH.y);
}
public function overPort(event:MouseEvent):void{
trace(("over me! #" + _id));
if (_active == false){
return;
};
_gfx.scaleX = 1.5;
_gfx.scaleY = 1.5;
_gfx.x = (_gfx.x - _portWH.x);
_gfx.y = (_gfx.y - _portWH.y);
}
public function updateStatusText(){
_portManager.updateStatusText();
}
public function addDraggedItem(item:String, value:int, event:MouseEvent){
oInv.addDraggedItem(item, value, event, false);
}
}
}//package
import flash.display.*;
class xy {
public var x:int;
public var y:int;
private function xy(xx:int, yy:int){
super();
x = xx;
y = yy;
}
}
class PortItem {
private var _display:Object;
private var _coord:xy;
private var _type:String;
private var _gfx:Object;
private function PortItem(gfx:MovieClip, x:int, y:int, itype:String, display:Object){
super();
_display = display;
_coord = new xy(x, y);
_type = itype;
_gfx = gfx;
_display.addChild(_gfx);
_gfx.visible = false;
}
public function draw():void{
_gfx.x = _coord.x;
_gfx.y = _coord.y;
_gfx.visible = true;
}
public function erase():void{
_gfx.visible = false;
}
public function drawAt(x:int, y:int):void{
_gfx.x = x;
_gfx.y = y;
_gfx.visible = true;
}
}
Section 60
//port_arrive_short (port_arrive_short)
package {
import flash.media.*;
public dynamic class port_arrive_short extends Sound {
public function port_arrive_short(){
super();
}
}
}//package
Section 61
//port_leave2 (port_leave2)
package {
import flash.media.*;
public dynamic class port_leave2 extends Sound {
public function port_leave2(){
super();
}
}
}//package
Section 62
//portBoat_mc (portBoat_mc)
package {
import flash.display.*;
public dynamic class portBoat_mc extends MovieClip {
public function portBoat_mc(){
super();
}
}
}//package
Section 63
//PortManager (PortManager)
package {
import flash.display.*;
import flash.text.*;
import fl.transitions.*;
import flash.media.*;
import fl.transitions.easing.*;
import fl.motion.easing.*;
import flash.utils.*;
public class PortManager {
private const _numPorts = 8;
private var _player:Player;
private var oPirateAttack:Pirates;
private var _ports:Array;
private var _menuButton:Button;
private var _map:Map;
private var _portCoords:Array;
private var _helpScreen:MovieClip;
private var _setSail:Button;
private var oBulbous:Bulbous;
private var _textSilver:TextField;
private var _dispObj:MovieClip;
private var _portBoat:MovieClip;
private var _turnCost:int;
private var _route:Route;
private var _popUp:MovieClip;
private var _game:Game;
private var _currentPort:int;
private var _portMap:MovieClip;
private var _diff:String;
private var _newgameButton:Button;
private var oRandomEnc:RndEnc;
private var _introPortBoat:Tween;
private var _textTurns:TextField;
private var _helpButton:Button;
private var _doneButton:Button;
public function PortManager(display:MovieClip, difficulty:String, route:Route, mapscreen:Map, game:Game):void{
var _portIcons:*;
var _portGoods:*;
var i:int;
super();
_dispObj = display;
_game = game;
_diff = difficulty;
trace(("game difficulty is " + _diff));
_portCoords = new Array(_numPorts);
_portCoords[0] = new xy(142, 114);
_portCoords[1] = new xy(341, 245);
_portCoords[2] = new xy(12, 312);
_portCoords[3] = new xy(264, 415);
_portCoords[4] = new xy(58, 22);
_portCoords[5] = new xy(539, 266);
_portCoords[6] = new xy(137, 232);
_portCoords[7] = new xy(522, 427);
_portIcons = new Array(_numPorts);
_portIcons[0] = new xy(77, 67);
_portIcons[1] = new xy(347, 183);
_portIcons[2] = new xy(7, 268);
_portIcons[3] = new xy(277, 368);
_portIcons[4] = new xy(110, 25);
_portIcons[5] = new xy(497, 212);
_portIcons[6] = new xy(77, 187);
_portIcons[7] = new xy(497, 375);
_portGoods = new Array(_numPorts);
_portGoods[0] = new Array("fur", "sugar", "wood");
_portGoods[1] = new Array("copper", "fish", "fruit");
_portGoods[2] = new Array("spices", "tools", "tobacco");
_portGoods[3] = new Array("wool", "fur", "sugar");
_portGoods[4] = new Array("wood", "copper", "fish");
_portGoods[5] = new Array("fruit", "spices", "tools");
_portGoods[6] = new Array("tobacco", "wool", "wood");
_portGoods[7] = new Array("tools", "fur", "sugar");
_ports = new Array(_numPorts);
i = 0;
while (i < _numPorts) {
_ports[i] = new Port(this, display, _portGoods[i][0], _portGoods[i][1], _portGoods[i][2], difficulty, _portCoords[i].x, _portCoords[i].y, i);
_ports[i].setGoods(_portIcons[i].x, _portIcons[i].y);
_ports[i].setActive(false);
i++;
};
_portMap = new menuPort_mc();
_portMap.x = 0;
_portMap.y = 0;
display.addChild(_portMap);
_portMap.visible = false;
_portBoat = new portBoat_mc();
_portBoat.x = 410;
_portBoat.y = 200;
display.addChild(_portBoat);
_portBoat.visible = false;
_textTurns = new TextField();
_textTurns.x = 380;
_textTurns.y = 60;
_textTurns.textColor = 0xFFFFFF;
_textSilver = new TextField();
_textSilver.x = 380;
_textSilver.y = 75;
_textSilver.textColor = 0xFFFFFF;
_currentPort = 0;
_route = route;
_map = mapscreen;
}
public function showEndGameButton():void{
_setSail = new Button(500, 50, 640, 500, "x", 1, new endGame_btn(), "endgame", true, _dispObj, this.EndGame);
}
public function portUp():void{
var gameEndMsg:String;
var gameEndingPopup:PopupDlg;
_player.drawPlayerInv();
if (_game.getTurns() < 1){
gameEndMsg = ("You have reached the end of your voyage. " + "Sell your cargo and click \"Set Sail\" to collect your booty.");
gameEndingPopup = new PopupDlg(this, _dispObj, gameEndMsg);
gameEndingPopup.start();
} else {
_setSail = new Button(500, 50, 640, 500, "x", 1, new setSail_btn(), "setsail", true, _dispObj, this.RandomEncounter);
};
}
public function eraseStatusText(){
_dispObj.removeChild(_textTurns);
_dispObj.removeChild(_textSilver);
}
public function updateStatusText(){
_textTurns.text = ("TURNS: " + _game.getTurns());
_textSilver.text = ("SILVER: " + _player.getSilver());
}
public function bouncePorts():void{
var i:int;
i = 0;
while (i < _numPorts) {
_ports[i].bounce();
i++;
};
}
public function portMenuNewGame(id:String){
_doneButton.die();
_newgameButton.die();
_helpButton.die();
_dispObj.removeChild(_popUp);
_map.erase();
_game.Start();
}
public function setPlayerObj(p:Player){
var i:int;
_player = p;
i = 0;
while (i < _ports.length) {
_ports[i].setPlayer(p);
i++;
};
oRandomEnc = new RndEnc(_dispObj, p, this);
oPirateAttack = new Pirates(_dispObj, _route, p, this);
oBulbous = new Bulbous(_dispObj, this, p);
}
public function RandomEncounter(id:String){
if (_player.getSilver() >= 40){
oRandomEnc.start();
} else {
SetSail("");
};
}
public function PirateAttack(which:int){
oPirateAttack.start(which);
}
public function drawStatusText(){
updateStatusText();
_dispObj.addChild(_textTurns);
_dispObj.addChild(_textSilver);
}
public function closePortMap():void{
oBulbous.end();
eraseStatusText();
_setSail.die();
_setSail = null;
_portMap.visible = false;
_portBoat.visible = false;
_introPortBoat = null;
_map.draw();
drawStatusText();
portMenuButtonStart();
}
public function drawAllGoods():void{
var i:int;
i = 0;
while (i < _numPorts) {
drawPortGoods(i);
i++;
};
}
public function portReady(which:int):void{
var minTurns:int;
minTurns = ((_diff == "easy")) ? 2 : 1;
if (_game.getTurns() < minTurns){
trace("not enough turns left to go anwhere.");
_game.turnCost(_game.getTurns());
};
trace("timed function portReady() called");
_route.endAnimate();
setPort(which);
_player.setPort(which);
_map.erase();
drawPortMap();
_ports[which].drawPortInv();
_player.setCurrentPort(_ports[which]);
setTimeout(portUp, 1500);
}
public function portMenu(id:String){
var stop:int;
_popUp = new popUp_mc();
_popUp.x = (320 - (_popUp.width / 2));
_popUp.y = (240 - (_popUp.height / 2));
_dispObj.addChild(_popUp);
stop = 250;
_newgameButton = new Button(stop, 125, 640, stop, "x", 1, new newGame_btn(), "newgame", false, _dispObj, this.portMenuNewGame);
_helpButton = new Button(stop, 175, 640, stop, "x", 1, new help_btn(), "help", false, _dispObj, this.portMenuHelp);
_doneButton = new Button(stop, 300, 640, stop, "x", 1, new done_btn(), "done", false, _dispObj, this.portMenuClose);
_menuButton.die();
}
public function drawPorts():void{
var i:int;
i = 0;
while (i < _numPorts) {
_ports[i].draw();
i++;
};
}
public function portMenuHelpClose(id:String){
var stop:int;
_doneButton.die();
_dispObj.removeChild(_helpScreen);
stop = 250;
_doneButton = new Button(stop, 300, 640, stop, "x", 1, new done_btn(), "done", false, _dispObj, this.portMenuClose);
}
public function portMenuButtonStart(){
_menuButton = new Button(475, 50, 640, 475, "x", 1, new menu_btn(), "menu", true, _dispObj, this.portMenu);
}
public function getDifficulty():String{
return (_diff);
}
public function drawConnectingGoods():void{
var portobj:Object;
portobj = {a:0, b:0, c:0};
_route.getRouteConnections(_currentPort, portobj, _game.getTurns());
if (portobj.a >= 0){
drawPortGoods(portobj.a);
};
if (portobj.b >= 0){
drawPortGoods(portobj.b);
};
if (portobj.c >= 0){
drawPortGoods(portobj.c);
};
}
public function drawPortMap():void{
var _portArrive:port_arrive_short;
var channel:SoundChannel;
_portMap.visible = true;
_portBoat.visible = true;
_portArrive = new port_arrive_short();
channel = _portArrive.play();
_introPortBoat = new Tween(_portBoat, "y", Exponential.easeOut, 300, 202, 2, true);
drawStatusText();
oBulbous.start();
}
public function portRemoveMenuButton(){
_menuButton.die();
}
public function setConnectingPortsActive():void{
var i:int;
var portobj:Object;
if (_route == null){
trace("setConnectingPortsActive() error: you must define _route first!");
return;
};
i = 0;
while (i < _numPorts) {
_ports[i].setActive(false);
i++;
};
portobj = {a:0, b:0, c:0};
_route.getRouteConnections(_currentPort, portobj, _game.getTurns());
if (portobj.a >= 0){
_ports[portobj.a].setActive(true);
};
if (portobj.b >= 0){
_ports[portobj.b].setActive(true);
};
if (portobj.c >= 0){
_ports[portobj.c].setActive(true);
};
trace(((((("activating ports " + portobj.a) + ", ") + portobj.b) + ", ") + portobj.c));
}
public function erasePortGoods(which:int):void{
_ports[which].eraseGoods();
}
public function SetSail(id:String){
_ports[_currentPort].clearInv();
_player.erasePlayerInv();
closePortMap();
if (_game.getTurns() < 1){
_game.gameOver();
} else {
_player.draw();
setConnectingPortsActive();
drawConnectingGoods();
_route.drawAllRoutes(_currentPort, _game.getTurns());
};
}
public function setConnectingPortsInactive():void{
var portobj:Object;
portobj = {a:0, b:0, c:0};
_route.getRouteConnections(_currentPort, portobj, 1000);
_ports[portobj.a].setActive(false);
_ports[portobj.b].setActive(false);
_ports[portobj.c].setActive(false);
trace(((((("deactivating ports " + portobj.a) + ", ") + portobj.b) + ", ") + portobj.c));
}
public function portMenuClose(id:String){
_newgameButton.die();
_helpButton.die();
_doneButton.die();
_dispObj.removeChild(_popUp);
portMenuButtonStart();
}
public function getTurnCost():int{
return (_turnCost);
}
public function portMenuHelp(id:String){
_doneButton.die();
_helpScreen = new menuHelp_mc();
_dispObj.addChild(_helpScreen);
_doneButton = new Button(520, 430, 640, 520, "x", 1, new done_btn(), "done", true, _dispObj, this.portMenuHelpClose);
}
public function portClicked(which:int){
_menuButton.die();
_player.erase();
_route.eraseAllRoutes();
_route.animate(_currentPort, which);
eraseConnectingGoods();
setConnectingPortsInactive();
_turnCost = _route.getRouteTurns(_currentPort, which);
_game.turnCost(_turnCost);
updateStatusText();
setTimeout(PirateAttack, 1000, which);
}
public function getPortCoords(which:int, obj:Object){
var coords:xy;
obj.x = _portCoords[which].x;
obj.y = _portCoords[which].y;
}
public function setPort(which:int){
_currentPort = which;
}
public function getPort(index:int):Port{
return (_ports[index]);
}
public function drawPortGoods(which:int):void{
_ports[which].drawGoods();
}
public function EndGame(id:String):void{
this.SetSail(id);
}
public function getCurrentPort():int{
return (_currentPort);
}
public function eraseConnectingGoods():void{
var portobj:Object;
portobj = {a:0, b:0, c:0};
_route.getRouteConnections(_currentPort, portobj, 1000);
erasePortGoods(portobj.a);
erasePortGoods(portobj.b);
erasePortGoods(portobj.c);
}
}
}//package
import flash.display.*;
import flash.text.*;
import flash.media.*;
class PopupDlg {
private var _msg:String;
private var _text:TextField;
private var _popup:MovieClip;
private var _sound:tip_select2;
private var _doneButton:Button;
private var _owner:PortManager;
private var _dispObj:MovieClip;
private var _bigFont:TextFormat;
private function PopupDlg(owner:PortManager, display:MovieClip, msg:String):void{
super();
_dispObj = display;
_msg = msg;
_owner = owner;
}
public function end(id:String){
_dispObj.removeChild(_text);
_dispObj.removeChild(_popup);
_doneButton.die();
_text = null;
_popup = null;
_bigFont = null;
_msg = null;
_owner.showEndGameButton();
}
public function start(){
var channel:SoundChannel;
_sound = new tip_select2();
channel = _sound.play();
_popup = new popUp_mc();
_popup.x = (320 - 240);
_popup.y = (240 - 209);
_dispObj.addChild(_popup);
_text = new TextField();
_text.x = 165;
_text.y = 150;
_text.width = 350;
_text.height = 200;
_text.wordWrap = true;
_bigFont = new TextFormat();
_bigFont.size = 32;
_doneButton = new Button(280, 350, 0, 0, "?", 0, new done_btn(), "done", false, _dispObj, this.end);
_text.text = _msg;
_text.setTextFormat(_bigFont);
_dispObj.addChild(_text);
}
}
class xy {
public var x:int;
public var y:int;
private function xy(xx:int, yy:int){
super();
x = xx;
y = yy;
}
}
Section 64
//profit_mc (profit_mc)
package {
import flash.display.*;
public dynamic class profit_mc extends MovieClip {
public function profit_mc(){
super();
}
}
}//package
Section 65
//profitLarge_mc (profitLarge_mc)
package {
import flash.display.*;
public dynamic class profitLarge_mc extends MovieClip {
public function profitLarge_mc(){
super();
}
}
}//package
Section 66
//r10DiffA (r10DiffA)
package {
import flash.display.*;
public dynamic class r10DiffA extends MovieClip {
public function r10DiffA(){
super();
}
}
}//package
Section 67
//r10DiffB (r10DiffB)
package {
import flash.display.*;
public dynamic class r10DiffB extends MovieClip {
public function r10DiffB(){
super();
}
}
}//package
Section 68
//r10DiffC (r10DiffC)
package {
import flash.display.*;
public dynamic class r10DiffC extends MovieClip {
public function r10DiffC(){
super();
}
}
}//package
Section 69
//r11DiffA (r11DiffA)
package {
import flash.display.*;
public dynamic class r11DiffA extends MovieClip {
public function r11DiffA(){
super();
}
}
}//package
Section 70
//r11DiffB (r11DiffB)
package {
import flash.display.*;
public dynamic class r11DiffB extends MovieClip {
public function r11DiffB(){
super();
}
}
}//package
Section 71
//r11DiffC (r11DiffC)
package {
import flash.display.*;
public dynamic class r11DiffC extends MovieClip {
public function r11DiffC(){
super();
}
}
}//package
Section 72
//r12DiffA (r12DiffA)
package {
import flash.display.*;
public dynamic class r12DiffA extends MovieClip {
public function r12DiffA(){
super();
}
}
}//package
Section 73
//r12DiffB (r12DiffB)
package {
import flash.display.*;
public dynamic class r12DiffB extends MovieClip {
public function r12DiffB(){
super();
}
}
}//package
Section 74
//r12DiffC (r12DiffC)
package {
import flash.display.*;
public dynamic class r12DiffC extends MovieClip {
public function r12DiffC(){
super();
}
}
}//package
Section 75
//r1DiffA (r1DiffA)
package {
import flash.display.*;
public dynamic class r1DiffA extends MovieClip {
public function r1DiffA(){
super();
}
}
}//package
Section 76
//r1DiffB (r1DiffB)
package {
import flash.display.*;
public dynamic class r1DiffB extends MovieClip {
public function r1DiffB(){
super();
}
}
}//package
Section 77
//r1DiffC (r1DiffC)
package {
import flash.display.*;
public dynamic class r1DiffC extends MovieClip {
public function r1DiffC(){
super();
}
}
}//package
Section 78
//r2DiffA (r2DiffA)
package {
import flash.display.*;
public dynamic class r2DiffA extends MovieClip {
public function r2DiffA(){
super();
}
}
}//package
Section 79
//r2DiffB (r2DiffB)
package {
import flash.display.*;
public dynamic class r2DiffB extends MovieClip {
public function r2DiffB(){
super();
}
}
}//package
Section 80
//r2DiffC (r2DiffC)
package {
import flash.display.*;
public dynamic class r2DiffC extends MovieClip {
public function r2DiffC(){
super();
}
}
}//package
Section 81
//r3DiffA (r3DiffA)
package {
import flash.display.*;
public dynamic class r3DiffA extends MovieClip {
public function r3DiffA(){
super();
}
}
}//package
Section 82
//r3DiffB (r3DiffB)
package {
import flash.display.*;
public dynamic class r3DiffB extends MovieClip {
public function r3DiffB(){
super();
}
}
}//package
Section 83
//r3DiffC (r3DiffC)
package {
import flash.display.*;
public dynamic class r3DiffC extends MovieClip {
public function r3DiffC(){
super();
}
}
}//package
Section 84
//r4DiffA (r4DiffA)
package {
import flash.display.*;
public dynamic class r4DiffA extends MovieClip {
public function r4DiffA(){
super();
}
}
}//package
Section 85
//r4DiffB (r4DiffB)
package {
import flash.display.*;
public dynamic class r4DiffB extends MovieClip {
public function r4DiffB(){
super();
}
}
}//package
Section 86
//r4DiffC (r4DiffC)
package {
import flash.display.*;
public dynamic class r4DiffC extends MovieClip {
public function r4DiffC(){
super();
}
}
}//package
Section 87
//r5DiffA (r5DiffA)
package {
import flash.display.*;
public dynamic class r5DiffA extends MovieClip {
public function r5DiffA(){
super();
}
}
}//package
Section 88
//r5DiffB (r5DiffB)
package {
import flash.display.*;
public dynamic class r5DiffB extends MovieClip {
public function r5DiffB(){
super();
}
}
}//package
Section 89
//r5DiffC (r5DiffC)
package {
import flash.display.*;
public dynamic class r5DiffC extends MovieClip {
public function r5DiffC(){
super();
}
}
}//package
Section 90
//r6DiffA (r6DiffA)
package {
import flash.display.*;
public dynamic class r6DiffA extends MovieClip {
public function r6DiffA(){
super();
}
}
}//package
Section 91
//r6DiffB (r6DiffB)
package {
import flash.display.*;
public dynamic class r6DiffB extends MovieClip {
public function r6DiffB(){
super();
}
}
}//package
Section 92
//r6DiffC (r6DiffC)
package {
import flash.display.*;
public dynamic class r6DiffC extends MovieClip {
public function r6DiffC(){
super();
}
}
}//package
Section 93
//r7DiffA (r7DiffA)
package {
import flash.display.*;
public dynamic class r7DiffA extends MovieClip {
public function r7DiffA(){
super();
}
}
}//package
Section 94
//r7DiffB (r7DiffB)
package {
import flash.display.*;
public dynamic class r7DiffB extends MovieClip {
public function r7DiffB(){
super();
}
}
}//package
Section 95
//r7DiffC (r7DiffC)
package {
import flash.display.*;
public dynamic class r7DiffC extends MovieClip {
public function r7DiffC(){
super();
}
}
}//package
Section 96
//r8DiffA (r8DiffA)
package {
import flash.display.*;
public dynamic class r8DiffA extends MovieClip {
public function r8DiffA(){
super();
}
}
}//package
Section 97
//r8DiffB (r8DiffB)
package {
import flash.display.*;
public dynamic class r8DiffB extends MovieClip {
public function r8DiffB(){
super();
}
}
}//package
Section 98
//r8DiffC (r8DiffC)
package {
import flash.display.*;
public dynamic class r8DiffC extends MovieClip {
public function r8DiffC(){
super();
}
}
}//package
Section 99
//r9DiffA (r9DiffA)
package {
import flash.display.*;
public dynamic class r9DiffA extends MovieClip {
public function r9DiffA(){
super();
}
}
}//package
Section 100
//r9DiffB (r9DiffB)
package {
import flash.display.*;
public dynamic class r9DiffB extends MovieClip {
public function r9DiffB(){
super();
}
}
}//package
Section 101
//r9DiffC (r9DiffC)
package {
import flash.display.*;
public dynamic class r9DiffC extends MovieClip {
public function r9DiffC(){
super();
}
}
}//package
Section 102
//RndEnc (RndEnc)
package {
import flash.display.*;
import flash.text.*;
import flash.media.*;
public class RndEnc {
private var _randomPopup:MovieClip;
private var _randomSound:tip_select2;
private var _bigFont:TextFormat;
private var _doneButton:Button;
private var _randomText:TextField;
private var _player:Player;
private var _pm:PortManager;
private var _dispObj:MovieClip;
public function RndEnc(display:MovieClip, player:Player, pm:PortManager):void{
super();
_dispObj = display;
_player = player;
_pm = pm;
}
public function start(){
var channel:SoundChannel;
var rtext:Array;
var rsilver:Array;
var rvalue:int;
trace("we have left the port screen - random encounter!");
_randomSound = new tip_select2();
channel = _randomSound.play();
_randomPopup = new popUp_mc();
_randomPopup.x = (320 - 240);
_randomPopup.y = (240 - 209);
_dispObj.addChild(_randomPopup);
_randomText = new TextField();
_randomText.x = 165;
_randomText.y = 150;
_randomText.width = 350;
_randomText.height = 200;
_randomText.wordWrap = true;
_bigFont = new TextFormat();
_bigFont.size = 32;
_doneButton = new Button(280, 350, 0, 0, "?", 0, new done_btn(), "done", false, _dispObj, this.end);
rtext = ["The harbormaster asks you to deliver a letter. Plus 20 silver!", "A desperate merchant begs you to transport a mysterious artifact. Plus 40 silver!", "A corrupt tax collector demands a bribe before you leave. Minus 20 silver!", "Last minute repairs cost more than expected. Minus 40 silver!"];
rsilver = [20, 40, -20, -40];
rvalue = (Math.random() * rsilver.length);
_randomText.text = rtext[rvalue];
_randomText.setTextFormat(_bigFont);
_dispObj.addChild(_randomText);
_player.addSilver(rsilver[rvalue]);
}
public function end(id:String){
_dispObj.removeChild(_randomText);
_dispObj.removeChild(_randomPopup);
_doneButton.die();
_randomText = null;
_randomPopup = null;
_bigFont = null;
_pm.SetSail(id);
}
}
}//package
Section 103
//Route (Route)
package {
public class Route {
private var _disp:Object;
private var _currentAnim:Object;
private var _easy_set:Array;
private var _route;
private var _routeGfxDelta:Array;
private var _routeGfxCoords:Array;
private var _portAnims:Array;
private var _norm_turns:Array;
private var _drawnRoutes:Array;
private var _routeAnims:Array;
private var _hard_turns:Array;
private var _portNameCoords:Array;
private var _hard_set:Array;
private var _easy_turns:Array;
private var _routeAnimCoords:Array;
private var _turnlist;
private var _norm_set:Array;
public function Route(difficulty:String, displayObj:Object):void{
var whichRoute:int;
var i:int;
_easy_set = new Array(3);
_norm_set = new Array(3);
_hard_set = new Array(3);
_easy_turns = new Array(3);
_norm_turns = new Array(3);
_hard_turns = new Array(3);
super();
_disp = displayObj;
_routeAnims = new Array(new route1AnimContainer(), new route2AnimContainer(), new route3AnimContainer(), new route4AnimContainer(), new route5AnimContainer(), new route6AnimContainer(), new route7AnimContainer(), new route8AnimContainer(), new route9AnimContainer(), new route10AnimContainer(), new route11AnimContainer(), new route12AnimContainer());
_easy_set[0] = new Array(new r1DiffA(), new r2DiffB(), new r3DiffA(), new r4DiffA(), new r5DiffB(), new r6DiffA(), new r7DiffA(), new r8DiffA(), new r9DiffA(), new r10DiffB(), new r11DiffB(), new r12DiffA());
_easy_set[1] = new Array(new r1DiffA(), new r2DiffB(), new r3DiffA(), new r4DiffA(), new r5DiffB(), new r6DiffA(), new r7DiffA(), new r8DiffA(), new r9DiffA(), new r10DiffB(), new r11DiffB(), new r12DiffA());
_easy_set[2] = new Array(new r1DiffA(), new r2DiffB(), new r3DiffA(), new r4DiffA(), new r5DiffB(), new r6DiffA(), new r7DiffA(), new r8DiffA(), new r9DiffA(), new r10DiffB(), new r11DiffB(), new r12DiffA());
_easy_turns[0] = new Array(3, 2, 3, 3, 2, 3, 3, 3, 3, 2, 2, 3);
_easy_turns[1] = new Array(3, 2, 3, 3, 2, 3, 3, 3, 3, 2, 2, 3);
_easy_turns[2] = new Array(3, 2, 3, 3, 2, 3, 3, 3, 3, 2, 2, 3);
_norm_set[0] = new Array(new r1DiffC(), new r2DiffA(), new r3DiffB(), new r4DiffB(), new r5DiffA(), new r6DiffB(), new r7DiffC(), new r8DiffB(), new r9DiffC(), new r10DiffA(), new r11DiffA(), new r12DiffC());
_norm_set[1] = new Array(new r1DiffB(), new r2DiffC(), new r3DiffA(), new r4DiffA(), new r5DiffC(), new r6DiffA(), new r7DiffB(), new r8DiffA(), new r9DiffB(), new r10DiffC(), new r11DiffC(), new r12DiffB());
_norm_set[2] = new Array(new r1DiffA(), new r2DiffB(), new r3DiffC(), new r4DiffC(), new r5DiffB(), new r6DiffC(), new r7DiffA(), new r8DiffC(), new r9DiffA(), new r10DiffB(), new r11DiffB(), new r12DiffA());
_norm_turns[0] = new Array(1, 3, 2, 2, 3, 2, 1, 2, 1, 3, 3, 1);
_norm_turns[1] = new Array(2, 1, 3, 3, 1, 3, 2, 3, 2, 1, 1, 2);
_norm_turns[2] = new Array(3, 2, 1, 1, 2, 1, 3, 1, 3, 2, 2, 3);
_hard_set[0] = new Array(new r1DiffC(), new r2DiffB(), new r3DiffC(), new r4DiffC(), new r5DiffB(), new r6DiffC(), new r7DiffC(), new r8DiffC(), new r9DiffC(), new r10DiffB(), new r11DiffB(), new r12DiffC());
_hard_set[1] = new Array(new r1DiffC(), new r2DiffB(), new r3DiffC(), new r4DiffC(), new r5DiffB(), new r6DiffC(), new r7DiffC(), new r8DiffC(), new r9DiffC(), new r10DiffB(), new r11DiffB(), new r12DiffC());
_hard_set[2] = new Array(new r1DiffC(), new r2DiffB(), new r3DiffC(), new r4DiffC(), new r5DiffB(), new r6DiffC(), new r7DiffC(), new r8DiffC(), new r9DiffC(), new r10DiffB(), new r11DiffB(), new r12DiffC());
_hard_turns[0] = new Array(1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1);
_hard_turns[1] = new Array(1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1);
_hard_turns[2] = new Array(1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1);
_portAnims = new Array(8);
_portAnims[0] = new Array(new Array(1, 0, 2), new Array(4, 2, 2), new Array(2, 1, 2));
_portAnims[1] = new Array(new Array(0, 0, 60), new Array(5, 3, 2), new Array(3, 4, 2));
_portAnims[2] = new Array(new Array(0, 1, 60), new Array(6, 5, 2), new Array(3, 6, 2));
_portAnims[3] = new Array(new Array(2, 6, 60), new Array(1, 4, 60), new Array(7, 7, 2));
_portAnims[4] = new Array(new Array(5, 8, 2), new Array(0, 2, 60), new Array(6, 9, 2));
_portAnims[5] = new Array(new Array(4, 8, 60), new Array(1, 3, 60), new Array(7, 10, 2));
_portAnims[6] = new Array(new Array(4, 9, 60), new Array(2, 5, 60), new Array(7, 11, 2));
_portAnims[7] = new Array(new Array(5, 10, 60), new Array(6, 11, 60), new Array(3, 7, 60));
_routeAnimCoords = new Array(12);
_routeAnimCoords[0] = new Array(200, 125);
_routeAnimCoords[1] = new Array(200, 125);
_routeAnimCoords[2] = new Array(200, 125);
_routeAnimCoords[3] = new Array(300, 300);
_routeAnimCoords[4] = new Array(275, 300);
_routeAnimCoords[5] = new Array(75, 350);
_routeAnimCoords[6] = new Array(75, 330);
_routeAnimCoords[7] = new Array(240, 400);
_routeAnimCoords[8] = new Array(75, 75);
_routeAnimCoords[9] = new Array(75, 75);
_routeAnimCoords[10] = new Array(510, 300);
_routeAnimCoords[11] = new Array(150, 300);
_routeGfxCoords = new Array(12);
_routeGfxCoords[0] = new Array(231, 136);
_routeGfxCoords[1] = new Array(85, 140);
_routeGfxCoords[2] = new Array(49, 64);
_routeGfxCoords[3] = new Array(328, 273);
_routeGfxCoords[4] = new Array(215, 298);
_routeGfxCoords[5] = new Array(69, 295);
_routeGfxCoords[6] = new Array(93, 335);
_routeGfxCoords[7] = new Array(211, 353);
_routeGfxCoords[8] = new Array(60, 64);
_routeGfxCoords[9] = new Array(80, 39);
_routeGfxCoords[10] = new Array(462, 297);
_routeGfxCoords[11] = new Array(138, 302);
_drawnRoutes = new Array(3);
whichRoute = (Math.random() * 3);
trace(("picked random route " + whichRoute));
switch (difficulty){
case "easy":
_route = _easy_set[whichRoute];
_turnlist = _easy_turns[whichRoute];
break;
case "normal":
_route = _norm_set[whichRoute];
_turnlist = _norm_turns[whichRoute];
break;
case "hard":
_route = _hard_set[whichRoute];
_turnlist = _hard_turns[whichRoute];
break;
};
i = 0;
while (i < 12) {
_disp.addChild(_route[i]);
_route[i].visible = false;
_disp.addChild(_routeAnims[i]);
_routeAnims[i].visible = false;
i++;
};
trace(((("selected " + difficulty) + " route: ") + _route));
}
public function eraseAllRoutes(){
var i:int;
i = 0;
while (i < 3) {
_route[_drawnRoutes[i]].visible = false;
trace(("erasing route " + _drawnRoutes[i]));
i++;
};
}
public function endAnimate():void{
_currentAnim.visible = false;
}
public function getRouteTurns(from:int, to:int):int{
var i:int;
i = 0;
while (i < 3) {
if (_portAnims[from][i][0] == to){
return (_turnlist[_portAnims[from][i][1]]);
};
i++;
};
return (0);
}
public function drawAllRoutes(port:int, turnsLeft:int){
var i:int;
var destPort:int;
var routeCost:int;
var whichAnim:int;
var x:int;
var y:int;
trace(("drawAllRoutes: turns left=" + turnsLeft));
i = 0;
while (i < 3) {
destPort = _portAnims[port][i][0];
routeCost = getRouteTurns(port, destPort);
trace((((((("route " + port) + "->") + destPort) + " costs ") + routeCost) + " turns."));
if (routeCost <= turnsLeft){
whichAnim = _portAnims[port][i][1];
x = _routeGfxCoords[whichAnim][0];
y = _routeGfxCoords[whichAnim][1];
_route[whichAnim].x = x;
_route[whichAnim].y = y;
_route[whichAnim].visible = true;
_drawnRoutes[i] = whichAnim;
trace(((((("drawing route " + whichAnim) + " at ") + x) + ", ") + y));
} else {
trace((((("skipping route " + port) + "->") + destPort) + " - too few turns left"));
};
i++;
};
}
public function animate(from:int, to:int):void{
var start:int;
var whichAnim:int;
var i:int;
start = 0;
i = 0;
while (i < 3) {
if (_portAnims[from][i][0] == to){
trace(("found a match for animating the path: " + _portAnims[from][i]));
whichAnim = _portAnims[from][i][1];
_currentAnim = _routeAnims[whichAnim];
start = _portAnims[from][i][2];
trace(((("using animation " + _currentAnim) + " and starting anim value ") + start));
break;
};
i++;
};
if (!start){
trace((((("error with data animating from port " + from) + " to port ") + to) + ". route does not exist!"));
return;
};
_currentAnim.x = _routeAnimCoords[whichAnim][0];
_currentAnim.y = _routeAnimCoords[whichAnim][1];
_currentAnim.visible = true;
_currentAnim.gotoAndPlay(start);
trace(((("drawing route animation at " + _currentAnim.x) + ", ") + _currentAnim.y));
}
public function getRouteConnections(from:int, portobj:Object, turnsLeft:int){
portobj.a = _portAnims[from][0][0];
if (getRouteTurns(from, portobj.a) > turnsLeft){
portobj.a = -1;
};
portobj.b = _portAnims[from][1][0];
if (getRouteTurns(from, portobj.b) > turnsLeft){
portobj.b = -1;
};
portobj.c = _portAnims[from][2][0];
if (getRouteTurns(from, portobj.c) > turnsLeft){
portobj.c = -1;
};
}
}
}//package
Section 104
//route10AnimContainer (route10AnimContainer)
package {
import flash.display.*;
public dynamic class route10AnimContainer extends MovieClip {
public function route10AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 105
//route11AnimContainer (route11AnimContainer)
package {
import flash.display.*;
public dynamic class route11AnimContainer extends MovieClip {
public function route11AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 106
//route12AnimContainer (route12AnimContainer)
package {
import flash.display.*;
public dynamic class route12AnimContainer extends MovieClip {
public function route12AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 107
//route1AnimContainer (route1AnimContainer)
package {
import flash.display.*;
public dynamic class route1AnimContainer extends MovieClip {
public function route1AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
gotoAndStop(1);
}
function frame59(){
stop();
}
}
}//package
Section 108
//route2AnimContainer (route2AnimContainer)
package {
import flash.display.*;
public dynamic class route2AnimContainer extends MovieClip {
public function route2AnimContainer(){
super();
addFrameScript(58, frame59, 119, frame120);
}
function frame120(){
gotoAndStop(1);
}
function frame59(){
stop();
}
}
}//package
Section 109
//route3AnimContainer (route3AnimContainer)
package {
import flash.display.*;
public dynamic class route3AnimContainer extends MovieClip {
public function route3AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 110
//route4AnimContainer (route4AnimContainer)
package {
import flash.display.*;
public dynamic class route4AnimContainer extends MovieClip {
public function route4AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 111
//route5AnimContainer (route5AnimContainer)
package {
import flash.display.*;
public dynamic class route5AnimContainer extends MovieClip {
public function route5AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 112
//route6AnimContainer (route6AnimContainer)
package {
import flash.display.*;
public dynamic class route6AnimContainer extends MovieClip {
public function route6AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 113
//route7AnimContainer (route7AnimContainer)
package {
import flash.display.*;
public dynamic class route7AnimContainer extends MovieClip {
public function route7AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 114
//route8AnimContainer (route8AnimContainer)
package {
import flash.display.*;
public dynamic class route8AnimContainer extends MovieClip {
public function route8AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
stop();
}
function frame59(){
stop();
}
}
}//package
Section 115
//route9AnimContainer (route9AnimContainer)
package {
import flash.display.*;
public dynamic class route9AnimContainer extends MovieClip {
public function route9AnimContainer(){
super();
addFrameScript(0, frame1, 58, frame59, 119, frame120);
}
function frame1(){
stop();
}
function frame120(){
gotoAndStop(1);
}
function frame59(){
stop();
}
}
}//package
Section 116
//run_btn (run_btn)
package {
import flash.display.*;
public dynamic class run_btn extends MovieClip {
public function run_btn(){
super();
}
}
}//package
Section 117
//sail_short (sail_short)
package {
import flash.media.*;
public dynamic class sail_short extends Sound {
public function sail_short(){
super();
}
}
}//package
Section 118
//sail_very_long (sail_very_long)
package {
import flash.media.*;
public dynamic class sail_very_long extends Sound {
public function sail_very_long(){
super();
}
}
}//package
Section 119
//sailor_btn (sailor_btn)
package {
import flash.display.*;
public dynamic class sailor_btn extends MovieClip {
public function sailor_btn(){
super();
}
}
}//package
Section 120
//setSail_btn (setSail_btn)
package {
import flash.display.*;
public dynamic class setSail_btn extends MovieClip {
public function setSail_btn(){
super();
}
}
}//package
Section 121
//tip_rollover2 (tip_rollover2)
package {
import flash.media.*;
public dynamic class tip_rollover2 extends Sound {
public function tip_rollover2(){
super();
}
}
}//package
Section 122
//tip_select2 (tip_select2)
package {
import flash.media.*;
public dynamic class tip_select2 extends Sound {
public function tip_select2(){
super();
}
}
}//package
Section 123
//tipGuy_btn (tipGuy_btn)
package {
import flash.display.*;
public dynamic class tipGuy_btn extends MovieClip {
public function tipGuy_btn(){
super();
}
}
}//package
Section 124
//tipGuyAdvert_mc (tipGuyAdvert_mc)
package {
import flash.display.*;
public dynamic class tipGuyAdvert_mc extends MovieClip {
public function tipGuyAdvert_mc(){
super();
}
}
}//package
Section 125
//ui_click (ui_click)
package {
import flash.media.*;
public dynamic class ui_click extends Sound {
public function ui_click(){
super();
}
}
}//package