mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 17:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,562 @@
|
||||
package game
|
||||
{
|
||||
import com.adobe.crypto.MD5;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.LoaderCache;
|
||||
import com.sbi.loader.LoaderCacheEntry_URL;
|
||||
import com.sbi.loader.LoaderEvent;
|
||||
import com.sbi.loader.SceneLoader;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.media.Sound;
|
||||
import flash.media.SoundLoaderContext;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.net.URLRequest;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.getTimer;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class GameBase extends Sprite
|
||||
{
|
||||
|
||||
private var _activeDlgMC:MovieClip;
|
||||
|
||||
private var _activeDlg:GuiDialog;
|
||||
|
||||
private var _guiButtons:Array;
|
||||
|
||||
private var _gemMultiplierMC:MovieClip;
|
||||
|
||||
private var _gemMultiplierMediaHelper:MediaHelper;
|
||||
|
||||
private var _gameLoader:LoaderCacheEntry_URL;
|
||||
|
||||
private var _sceneName:String;
|
||||
|
||||
private var _audioFiles:Array;
|
||||
|
||||
protected var _audioByName:Dictionary;
|
||||
|
||||
protected var _pauseGame:Boolean;
|
||||
|
||||
private var _trackerVal:Array;
|
||||
|
||||
protected var _scene:SceneLoader;
|
||||
|
||||
protected var _closeBtn:MovieClip;
|
||||
|
||||
protected var _guiLayer:Sprite;
|
||||
|
||||
private var _gameStartTime:int;
|
||||
|
||||
public var _totalGemsEarned:int;
|
||||
|
||||
protected var _gameIdleTimer:Number;
|
||||
|
||||
private var _trackerMain:Array;
|
||||
|
||||
private var _lastIdleTimer:Number;
|
||||
|
||||
private var _kickPopup:SBOkPopup;
|
||||
|
||||
protected var _miniGameDefID:int;
|
||||
|
||||
private var _inRoomGame:Boolean;
|
||||
|
||||
private var _trackerNum:Array;
|
||||
|
||||
private var _onCloseCallback:Function;
|
||||
|
||||
public function GameBase()
|
||||
{
|
||||
super();
|
||||
MinigameManager._pvpPromptReplay = false;
|
||||
_miniGameDefID = MinigameManager.minigameInfoCache.currMinigameId;
|
||||
_trackerVal = [];
|
||||
_trackerNum = [];
|
||||
_trackerMain = [];
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_inRoomGame = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).isInRoomGame;
|
||||
}
|
||||
else
|
||||
{
|
||||
_inRoomGame = false;
|
||||
}
|
||||
_gameIdleTimer = 0;
|
||||
_totalGemsEarned = 0;
|
||||
_guiButtons = [];
|
||||
_audioByName = new Dictionary();
|
||||
_gameStartTime = getTimer();
|
||||
}
|
||||
|
||||
public function get activeDlgMC() : MovieClip
|
||||
{
|
||||
return _activeDlgMC;
|
||||
}
|
||||
|
||||
protected function loadScene(param1:String, param2:Array = null) : void
|
||||
{
|
||||
_sceneName = param1;
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = [];
|
||||
}
|
||||
_audioFiles = param2;
|
||||
_gemMultiplierMediaHelper = new MediaHelper();
|
||||
_gemMultiplierMediaHelper.init(1067,gemMultiplierMediaHandler);
|
||||
}
|
||||
|
||||
private function gemMultiplierMediaHandler(param1:MovieClip) : void
|
||||
{
|
||||
var handleAudioFilePreloaded:Function;
|
||||
var i:int;
|
||||
var curAudioFilename:String;
|
||||
var audioCDNRequest:URLRequest;
|
||||
var s:Sound;
|
||||
var mc:MovieClip = param1;
|
||||
_gemMultiplierMC = mc;
|
||||
var audioFilesLeftToLoad:int = int(_audioFiles.length);
|
||||
if(audioFilesLeftToLoad == 0)
|
||||
{
|
||||
audioFilesPreloadComplete();
|
||||
}
|
||||
handleAudioFilePreloaded = function(param1:Event):void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc5_:Sound = param1.target as Sound;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc2_ = decodeURI(_loc5_.url);
|
||||
_loc4_ = _loc2_.slice(_loc2_.lastIndexOf("/") + 1,_loc2_.lastIndexOf("?"));
|
||||
if(_loc4_.substr(-4) != ".mp3")
|
||||
{
|
||||
for each(var _loc3_:String in _audioFiles)
|
||||
{
|
||||
if(MD5.hash(_loc3_) == _loc4_)
|
||||
{
|
||||
_loc4_ = _loc3_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_audioByName[_loc4_] = _loc5_;
|
||||
}
|
||||
if(--audioFilesLeftToLoad <= 0)
|
||||
{
|
||||
audioFilesPreloadComplete();
|
||||
}
|
||||
};
|
||||
i = 0;
|
||||
while(i < _audioFiles.length)
|
||||
{
|
||||
curAudioFilename = _audioFiles[i];
|
||||
DebugUtility.debugTrace("loading audio file:" + curAudioFilename);
|
||||
audioCDNRequest = LoaderCache.fetchCDNURLRequest("audio/" + curAudioFilename);
|
||||
s = new Sound();
|
||||
s.addEventListener("complete",handleAudioFilePreloaded);
|
||||
s.addEventListener("ioError",function(param1:Event):void
|
||||
{
|
||||
DebugUtility.debugTrace("IOError loading audio file! e:" + param1,16711680);
|
||||
});
|
||||
s.load(audioCDNRequest,new SoundLoaderContext(1,true));
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private function audioFilesPreloadComplete() : void
|
||||
{
|
||||
_gameLoader = new LoaderCacheEntry_URL("roomDefs/" + _sceneName.toLowerCase());
|
||||
_gameLoader.addEventListener("OnLoadComplete",loadComplete);
|
||||
_gameLoader.load();
|
||||
}
|
||||
|
||||
private function loadComplete(param1:LoaderEvent) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
_loc2_ = _gameLoader.data;
|
||||
_gameLoader.removeEventListener("OnLoadComplete",loadComplete);
|
||||
_scene = new SceneLoader();
|
||||
_scene.setScene(_loc2_,true);
|
||||
_scene.addEventListener("complete",sceneLoaded,false,0,true);
|
||||
}
|
||||
|
||||
protected function releaseBase() : void
|
||||
{
|
||||
var _loc1_:Number = (getTimer() - _gameStartTime) / 1000;
|
||||
if(_kickPopup != null)
|
||||
{
|
||||
_kickPopup.destroy();
|
||||
_kickPopup = null;
|
||||
}
|
||||
if(stage)
|
||||
{
|
||||
stage.removeEventListener("keyDown",gemMultiplierCloseKeyDown);
|
||||
stage.removeEventListener("keyDown",resetKeyIdleTimer,false);
|
||||
stage.removeEventListener("mouseDown",resetMouseDownIdleTimer,false);
|
||||
stage.removeEventListener("mouseMove",resetMouseMoveIdleTimer,false);
|
||||
stage.removeEventListener("enterFrame",gameBaseHeartbeat);
|
||||
}
|
||||
for each(var _loc2_:GuiButton in _guiButtons)
|
||||
{
|
||||
_loc2_.release();
|
||||
}
|
||||
_guiButtons = [];
|
||||
if(_scene)
|
||||
{
|
||||
_scene.release();
|
||||
}
|
||||
_gameLoader = null;
|
||||
}
|
||||
|
||||
protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
_scene.removeEventListener("complete",sceneLoaded);
|
||||
param1 = new Event("complete");
|
||||
dispatchEvent(param1);
|
||||
var _loc2_:Array = _scene.getActorList("ActorLayer");
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_.length)
|
||||
{
|
||||
_loc4_ = _loc2_[_loc3_];
|
||||
if(_loc4_.s.content is MovieClip)
|
||||
{
|
||||
LocalizationManager.findAllTextfields(_loc4_.s.content);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
_lastIdleTimer = getTimer();
|
||||
stage.addEventListener("keyDown",resetKeyIdleTimer,false);
|
||||
stage.addEventListener("mouseDown",resetMouseDownIdleTimer,false);
|
||||
stage.addEventListener("mouseMove",resetMouseMoveIdleTimer,false);
|
||||
stage.addEventListener("enterFrame",gameBaseHeartbeat);
|
||||
}
|
||||
|
||||
private function gameBaseHeartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Number = (getTimer() - _lastIdleTimer) / 1000;
|
||||
_lastIdleTimer = getTimer();
|
||||
if(_inRoomGame == false)
|
||||
{
|
||||
_gameIdleTimer += _loc2_;
|
||||
if(_gameIdleTimer > 180)
|
||||
{
|
||||
if(_gameIdleTimer > 240)
|
||||
{
|
||||
if(this.hasOwnProperty("end"))
|
||||
{
|
||||
this["end"](null);
|
||||
}
|
||||
}
|
||||
else if(_kickPopup == null)
|
||||
{
|
||||
_kickPopup = new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14681),false,onKickWarningPopup);
|
||||
AJAudio.playIdleWarningSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onKickWarningPopup(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
SBOkPopup.destroyInParentChain(param1.target.parent);
|
||||
_kickPopup = null;
|
||||
_gameIdleTimer = 0;
|
||||
}
|
||||
|
||||
private function resetKeyIdleTimer(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(_kickPopup != null)
|
||||
{
|
||||
_kickPopup.destroy();
|
||||
_kickPopup = null;
|
||||
}
|
||||
_gameIdleTimer = 0;
|
||||
}
|
||||
|
||||
private function resetMouseMoveIdleTimer(param1:MouseEvent) : void
|
||||
{
|
||||
if(_kickPopup == null)
|
||||
{
|
||||
_gameIdleTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function resetMouseDownIdleTimer(param1:Event) : void
|
||||
{
|
||||
if(_kickPopup != null)
|
||||
{
|
||||
_kickPopup.destroy();
|
||||
_kickPopup = null;
|
||||
}
|
||||
_gameIdleTimer = 0;
|
||||
}
|
||||
|
||||
private function gemMultiplierClose() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",gemMultiplierCloseKeyDown);
|
||||
if(_onCloseCallback != null)
|
||||
{
|
||||
_onCloseCallback();
|
||||
_onCloseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function gemMultiplierCloseKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
gemMultiplierClose();
|
||||
}
|
||||
}
|
||||
|
||||
protected function showGemMultiplierDlg(param1:Function) : MovieClip
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_totalGemsEarned > 0)
|
||||
{
|
||||
_loc3_ = 1;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc3_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).gemMultiplier;
|
||||
}
|
||||
if(_loc3_ > 1)
|
||||
{
|
||||
if(_activeDlg != null)
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
if(_activeDlg == null && _gemMultiplierMC)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
_pauseGame = true;
|
||||
_loc2_ = _gemMultiplierMC.getChildAt(0) as MovieClip;
|
||||
_guiLayer.addChild(_loc2_);
|
||||
_onCloseCallback = param1;
|
||||
_activeDlg = new GuiDialog(_loc2_,[{
|
||||
"name":"x_btn",
|
||||
"f":param1
|
||||
}]);
|
||||
stage.addEventListener("keyDown",gemMultiplierCloseKeyDown);
|
||||
_activeDlgMC = _loc2_;
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.Gems_Earned,10062,_totalGemsEarned / _loc3_);
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.Gem_Bonus,10063,_loc3_);
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.Gems_Total,10064,_totalGemsEarned);
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function showDlg(param1:String, param2:Array, param3:int = 0, param4:int = 0, param5:Boolean = true, param6:Boolean = false) : MovieClip
|
||||
{
|
||||
var _loc7_:MovieClip = null;
|
||||
if(!param5)
|
||||
{
|
||||
_loc7_ = GETDEFINITIONBYNAME(param1);
|
||||
_guiLayer.addChild(_loc7_);
|
||||
_loc7_.x = param3;
|
||||
_loc7_.y = param4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_activeDlg != null)
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
if(_activeDlg == null)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
_pauseGame = true;
|
||||
_loc7_ = GETDEFINITIONBYNAME(param1);
|
||||
_guiLayer.addChild(_loc7_);
|
||||
_activeDlg = new GuiDialog(_loc7_,param2);
|
||||
_activeDlgMC = _loc7_;
|
||||
_activeDlgMC.darkened = param6;
|
||||
_activeDlgMC.x = param3;
|
||||
_activeDlgMC.y = param4;
|
||||
if(param6)
|
||||
{
|
||||
DarkenManager.darken(_activeDlgMC);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
protected function hideDlg() : void
|
||||
{
|
||||
if(_activeDlg)
|
||||
{
|
||||
_activeDlg.release();
|
||||
if(_activeDlgMC.darkened)
|
||||
{
|
||||
DarkenManager.unDarken(_activeDlgMC);
|
||||
}
|
||||
_guiLayer.removeChild(_activeDlgMC);
|
||||
_activeDlg = null;
|
||||
_activeDlgMC = null;
|
||||
_pauseGame = false;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function addBtn(param1:String, param2:int, param3:int, param4:Function) : MovieClip
|
||||
{
|
||||
var _loc6_:MovieClip = GETDEFINITIONBYNAME(param1);
|
||||
_loc6_.x = param2;
|
||||
_loc6_.y = param3;
|
||||
_guiLayer.addChild(_loc6_);
|
||||
var _loc5_:GuiButton = new GuiButton(_loc6_,param4);
|
||||
_guiButtons.push(_loc5_);
|
||||
_loc6_.guiBtn = _loc5_;
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function mainTracker() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc1_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
}
|
||||
_trackerNum.push(_trackerMain[_trackerMain.length - 1] - _loc1_ * 7 - 78922);
|
||||
numTracker();
|
||||
}
|
||||
|
||||
protected function loadSound(param1:Class) : Sound
|
||||
{
|
||||
var _loc3_:Sound = new param1() as Sound;
|
||||
var _loc2_:SoundTransform = new SoundTransform(0,0);
|
||||
_loc3_.play(0,0,_loc2_);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function valueTrackerCommit() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc1_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
if(_loc1_ != 0)
|
||||
{
|
||||
MinigameManager.sendScore(_trackerMain[_trackerMain.length - 1],_trackerVal[_trackerVal.length - 1],_trackerNum[_trackerNum.length - 1],_loc1_,_miniGameDefID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeLayer(param1:Sprite) : void
|
||||
{
|
||||
while(param1.numChildren)
|
||||
{
|
||||
param1.removeChild(param1.getChildAt(0));
|
||||
}
|
||||
param1.parent.removeChild(param1);
|
||||
}
|
||||
|
||||
protected function addToPetMastery(param1:int) : void
|
||||
{
|
||||
MinigameManager.awardPetMasteryPoints(param1);
|
||||
}
|
||||
|
||||
private function numTracker() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc1_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
}
|
||||
_trackerVal.push(_trackerNum[_trackerNum.length - 1] - _loc1_ * 9 + 15645);
|
||||
}
|
||||
|
||||
protected function addGemsToBalance(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 1;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc2_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).gemMultiplier;
|
||||
}
|
||||
if(_loc2_ > 1)
|
||||
{
|
||||
param1 *= _loc2_;
|
||||
}
|
||||
_totalGemsEarned += param1;
|
||||
MinigameManager.awardGems(param1,_miniGameDefID);
|
||||
}
|
||||
|
||||
public function valueTrackerCurrent() : Number
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_trackerMain.length > 0)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc1_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
}
|
||||
return 9999999 - (_trackerMain[_trackerMain.length - 1] - _loc1_ * 5 + MinigameManager.getScoreSN());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getScene() : SceneLoader
|
||||
{
|
||||
return _scene;
|
||||
}
|
||||
|
||||
public function getPaused() : Boolean
|
||||
{
|
||||
return _pauseGame;
|
||||
}
|
||||
|
||||
public function getGuiLayer() : Sprite
|
||||
{
|
||||
return _guiLayer;
|
||||
}
|
||||
|
||||
public function valueTracker(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(_miniGameDefID != -1)
|
||||
{
|
||||
_loc2_ = MinigameManager.minigameInfoCache.getMinigameInfo(_miniGameDefID).lbUseVarRef;
|
||||
}
|
||||
_trackerMain.push(9999999 - (param1 - _loc2_ * 5 + MinigameManager.getScoreSN()));
|
||||
if(_trackerMain.length >= 3)
|
||||
{
|
||||
_trackerMain.shift();
|
||||
}
|
||||
mainTracker();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package game
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class GuiButton
|
||||
{
|
||||
|
||||
private var _mc:MovieClip;
|
||||
|
||||
private var _clickFunc:Function;
|
||||
|
||||
private var _grayBtn:MovieClip;
|
||||
|
||||
private var _isGray:Boolean;
|
||||
|
||||
private var _pressed:Boolean;
|
||||
|
||||
private var _usePressedState:Boolean;
|
||||
|
||||
public function GuiButton(param1:MovieClip, param2:Function)
|
||||
{
|
||||
super();
|
||||
_mc = param1;
|
||||
_grayBtn = param1.grayBtn;
|
||||
if(_grayBtn)
|
||||
{
|
||||
_grayBtn.visible = false;
|
||||
}
|
||||
_isGray = false;
|
||||
_clickFunc = param2;
|
||||
_mc.addEventListener("rollOver",mouseOver);
|
||||
_mc.addEventListener("rollOut",mouseOut);
|
||||
_mc.addEventListener("mouseDown",mouseClick);
|
||||
_mc.gotoAndStop("off");
|
||||
}
|
||||
|
||||
public function setGrayState(param1:Boolean) : void
|
||||
{
|
||||
if(_grayBtn)
|
||||
{
|
||||
_isGray = param1;
|
||||
_grayBtn.visible = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isGray = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function setUsePressedState() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _mc.currentLabels.length)
|
||||
{
|
||||
if(_mc.currentLabels[_loc1_].name == "pressed")
|
||||
{
|
||||
_usePressedState = true;
|
||||
break;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function setPressedState(param1:Boolean) : void
|
||||
{
|
||||
_pressed = param1;
|
||||
if(_usePressedState)
|
||||
{
|
||||
if(_pressed)
|
||||
{
|
||||
if(_mc.currentFrameLabel != "pressed")
|
||||
{
|
||||
_mc.gotoAndStop("pressed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_mc.gotoAndPlay("off");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
_mc.removeEventListener("rollOver",mouseOver);
|
||||
_mc.removeEventListener("rollOut",mouseOut);
|
||||
_mc.removeEventListener("mouseDown",mouseClick);
|
||||
_mc.parent.removeChild(_mc);
|
||||
_grayBtn = null;
|
||||
_isGray = false;
|
||||
_pressed = false;
|
||||
_usePressedState = false;
|
||||
_mc = null;
|
||||
}
|
||||
|
||||
private function mouseOver(param1:MouseEvent) : void
|
||||
{
|
||||
if(!_isGray && !_pressed)
|
||||
{
|
||||
if(_mc.currentFrameLabel != "on")
|
||||
{
|
||||
_mc.gotoAndPlay("on");
|
||||
}
|
||||
AJAudio.playHudBtnRollover();
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseOut(param1:MouseEvent) : void
|
||||
{
|
||||
if(!_isGray && !_pressed)
|
||||
{
|
||||
if(_mc.currentFrameLabel != "off")
|
||||
{
|
||||
_mc.gotoAndPlay("off");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseClick(param1:MouseEvent) : void
|
||||
{
|
||||
if(!_isGray && !_pressed)
|
||||
{
|
||||
_clickFunc();
|
||||
if(_usePressedState)
|
||||
{
|
||||
setPressedState(true);
|
||||
}
|
||||
AJAudio.playHudBtnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package game
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class GuiDialog
|
||||
{
|
||||
|
||||
private var _mc:MovieClip;
|
||||
|
||||
private var _buttons:Array;
|
||||
|
||||
public function GuiDialog(param1:MovieClip, param2:Array)
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:Object = null;
|
||||
var _loc5_:MovieClip = null;
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc8_:GuiButton = null;
|
||||
super();
|
||||
_mc = param1;
|
||||
_buttons = [];
|
||||
while(_loc6_ < param2.length)
|
||||
{
|
||||
_loc9_ = param2[_loc6_];
|
||||
_loc5_ = _mc[_loc9_.name];
|
||||
if(!_loc5_)
|
||||
{
|
||||
_loc3_ = _loc9_.name;
|
||||
_loc4_ = _mc;
|
||||
while(_loc3_.indexOf(".") != -1)
|
||||
{
|
||||
_loc7_ = _loc3_.substring(0,_loc3_.indexOf("."));
|
||||
_loc4_ = _loc4_[_loc7_];
|
||||
_loc3_ = _loc3_.substring(_loc3_.indexOf(".") + 1,_loc3_.length);
|
||||
}
|
||||
_loc5_ = _loc4_[_loc3_];
|
||||
if(!_loc5_)
|
||||
{
|
||||
throw new Error("ERROR: Button Not Found:\" " + _loc9_.name + "\" verify button names across SWF files.");
|
||||
}
|
||||
}
|
||||
_loc8_ = new GuiButton(_loc5_,_loc9_.f);
|
||||
if(_loc9_.hasOwnProperty("grayed") && _loc9_.grayed == "yes")
|
||||
{
|
||||
_loc8_.setGrayState(true);
|
||||
}
|
||||
_buttons.push(_loc8_);
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < _buttons.length)
|
||||
{
|
||||
_buttons[_loc1_].release();
|
||||
_loc1_++;
|
||||
}
|
||||
_buttons = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package game
|
||||
{
|
||||
public interface IMinigame
|
||||
{
|
||||
|
||||
function start(param1:uint, param2:Array, param3:Function, param4:Function) : void;
|
||||
|
||||
function message(param1:Array) : void;
|
||||
|
||||
function end(param1:Array) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
package game
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
import game.artPrintPlayPortrait.ArtPrintPlayPortrait;
|
||||
import game.artStudioPainting.ArtStudioPainting;
|
||||
import game.artStudioPottery.ArtStudioPottery;
|
||||
import game.artStudioPrint.ArtStudioPrint;
|
||||
import game.bradyChemistrySet.BradyChemistrySet;
|
||||
import game.bradyExpeditions.BradyExpeditions;
|
||||
import game.candyCatcher.CandyCatcher;
|
||||
import game.cottonCandy.CottonCandy;
|
||||
import game.distanceChallenge.DistanceChallenge;
|
||||
import game.dolphinRace.DolphinRace;
|
||||
import game.dunkAPhantom.DunkAPhantom;
|
||||
import game.eagleFlap.EagleFlap;
|
||||
import game.fallingPhantoms.FallingPhantoms;
|
||||
import game.fashionShow.FashionShow;
|
||||
import game.feedingFrenzy.FeedingFrenzy;
|
||||
import game.fortSmasher.FortSmasher;
|
||||
import game.gemBreaker.GemBreaker;
|
||||
import game.hedgeHog.HedgeHog;
|
||||
import game.horseRace.HorseRace;
|
||||
import game.microBambooHarvest.MicroBambooHarvest;
|
||||
import game.microCrane.MicroCrane;
|
||||
import game.microDucky.MicroDucky;
|
||||
import game.microGameInvasion.MicroGameInvasion;
|
||||
import game.microGoldPanning.MicroGoldPanning;
|
||||
import game.microHotCocoa.MicroHotCocoa;
|
||||
import game.microMiraSays.MicroMiraSays;
|
||||
import game.microOatHarvest.MicroOatHarvest;
|
||||
import game.microPetSalon.MicroPetSalon;
|
||||
import game.microPetWash.MicroPetWash;
|
||||
import game.microPhantom.MicroPhantom;
|
||||
import game.microPopcorn.MicroPopcorn;
|
||||
import game.microPuppy.MicroPuppy;
|
||||
import game.microSmoothie.MicroSmoothie;
|
||||
import game.microSnake.MicroSnake;
|
||||
import game.microStoneMining.MicroStoneMining;
|
||||
import game.microWoodGather.MicroWoodGather;
|
||||
import game.miniGame_Memory.MiniGame_Memory;
|
||||
import game.moatMadness.MoatMadness;
|
||||
import game.pVP_Bowling.PVP_Bowling;
|
||||
import game.pVP_ConnectFour.PVP_ConnectFour;
|
||||
import game.pVP_Marbles.PVP_Marbles;
|
||||
import game.pVP_Memory.PVP_Memory;
|
||||
import game.pVP_RockPaperScissor.PVP_RockPaperScissor;
|
||||
import game.pVP_Scooped.PVP_Scooped;
|
||||
import game.pVP_ShellGame.PVP_ShellGame;
|
||||
import game.pVP_TicTacToe.PVP_TicTacToe;
|
||||
import game.pachinko.Pachinko;
|
||||
import game.parachuteGlider.ParachuteGlider;
|
||||
import game.phantomFighter.PhantomFighter;
|
||||
import game.phantomsTreasure.PhantomsTreasure;
|
||||
import game.pillBugs.PillBugs;
|
||||
import game.questParachuteGlider.QuestParachuteGlider;
|
||||
import game.riverRace.RiverRace;
|
||||
import game.safetyQuiz.SafetyQuiz;
|
||||
import game.shootingGallery.ShootingGallery;
|
||||
import game.skeeball.Skeeball;
|
||||
import game.spiderShooter.SpiderShooter;
|
||||
import game.spotOn.SpotOn;
|
||||
import game.superSort.SuperSort;
|
||||
import game.touchPool.TouchPool;
|
||||
import game.towerDefense.TowerDefense;
|
||||
import game.trivia.Trivia;
|
||||
import game.trueFalse.TrueFalse;
|
||||
import game.twister.Twister;
|
||||
import game.whackPhantom.WhackPhantom;
|
||||
import game.windRider.WindRider;
|
||||
|
||||
public class IncludeMinigames
|
||||
{
|
||||
|
||||
public static const minigameFullyQualifiedNames:Dictionary = new Dictionary();
|
||||
|
||||
public function IncludeMinigames()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
ArtPrintPlayPortrait;
|
||||
minigameFullyQualifiedNames["ArtPrintPlayPortrait"] = "game.artPrintPlayPortrait.ArtPrintPlayPortrait";
|
||||
ArtStudioPainting;
|
||||
minigameFullyQualifiedNames["ArtStudioPainting"] = "game.artStudioPainting.ArtStudioPainting";
|
||||
ArtStudioPottery;
|
||||
minigameFullyQualifiedNames["ArtStudioPottery"] = "game.artStudioPottery.ArtStudioPottery";
|
||||
ArtStudioPrint;
|
||||
minigameFullyQualifiedNames["ArtStudioPrint"] = "game.artStudioPrint.ArtStudioPrint";
|
||||
BradyChemistrySet;
|
||||
minigameFullyQualifiedNames["BradyChemistrySet"] = "game.bradyChemistrySet.BradyChemistrySet";
|
||||
BradyExpeditions;
|
||||
minigameFullyQualifiedNames["BradyExpeditions"] = "game.bradyExpeditions.BradyExpeditions";
|
||||
CandyCatcher;
|
||||
minigameFullyQualifiedNames["CandyCatcher"] = "game.candyCatcher.CandyCatcher";
|
||||
CottonCandy;
|
||||
minigameFullyQualifiedNames["CottonCandy"] = "game.cottonCandy.CottonCandy";
|
||||
DistanceChallenge;
|
||||
minigameFullyQualifiedNames["DistanceChallenge"] = "game.distanceChallenge.DistanceChallenge";
|
||||
DolphinRace;
|
||||
minigameFullyQualifiedNames["DolphinRace"] = "game.dolphinRace.DolphinRace";
|
||||
DunkAPhantom;
|
||||
minigameFullyQualifiedNames["DunkAPhantom"] = "game.dunkAPhantom.DunkAPhantom";
|
||||
EagleFlap;
|
||||
minigameFullyQualifiedNames["EagleFlap"] = "game.eagleFlap.EagleFlap";
|
||||
FallingPhantoms;
|
||||
minigameFullyQualifiedNames["FallingPhantoms"] = "game.fallingPhantoms.FallingPhantoms";
|
||||
FashionShow;
|
||||
minigameFullyQualifiedNames["FashionShow"] = "game.fashionShow.FashionShow";
|
||||
FeedingFrenzy;
|
||||
minigameFullyQualifiedNames["FeedingFrenzy"] = "game.feedingFrenzy.FeedingFrenzy";
|
||||
FortSmasher;
|
||||
minigameFullyQualifiedNames["FortSmasher"] = "game.fortSmasher.FortSmasher";
|
||||
GemBreaker;
|
||||
minigameFullyQualifiedNames["GemBreaker"] = "game.gemBreaker.GemBreaker";
|
||||
HedgeHog;
|
||||
minigameFullyQualifiedNames["HedgeHog"] = "game.hedgeHog.HedgeHog";
|
||||
HorseRace;
|
||||
minigameFullyQualifiedNames["HorseRace"] = "game.horseRace.HorseRace";
|
||||
MicroBambooHarvest;
|
||||
minigameFullyQualifiedNames["MicroBambooHarvest"] = "game.microBambooHarvest.MicroBambooHarvest";
|
||||
MicroCrane;
|
||||
minigameFullyQualifiedNames["MicroCrane"] = "game.microCrane.MicroCrane";
|
||||
MicroDucky;
|
||||
minigameFullyQualifiedNames["MicroDucky"] = "game.microDucky.MicroDucky";
|
||||
MicroGameInvasion;
|
||||
minigameFullyQualifiedNames["MicroGameInvasion"] = "game.microGameInvasion.MicroGameInvasion";
|
||||
MicroGoldPanning;
|
||||
minigameFullyQualifiedNames["MicroGoldPanning"] = "game.microGoldPanning.MicroGoldPanning";
|
||||
MicroHotCocoa;
|
||||
minigameFullyQualifiedNames["MicroHotCocoa"] = "game.microHotCocoa.MicroHotCocoa";
|
||||
MicroMiraSays;
|
||||
minigameFullyQualifiedNames["MicroMiraSays"] = "game.microMiraSays.MicroMiraSays";
|
||||
MicroOatHarvest;
|
||||
minigameFullyQualifiedNames["MicroOatHarvest"] = "game.microOatHarvest.MicroOatHarvest";
|
||||
MicroPetSalon;
|
||||
minigameFullyQualifiedNames["MicroPetSalon"] = "game.microPetSalon.MicroPetSalon";
|
||||
MicroPetWash;
|
||||
minigameFullyQualifiedNames["MicroPetWash"] = "game.microPetWash.MicroPetWash";
|
||||
MicroPhantom;
|
||||
minigameFullyQualifiedNames["MicroPhantom"] = "game.microPhantom.MicroPhantom";
|
||||
MicroPopcorn;
|
||||
minigameFullyQualifiedNames["MicroPopcorn"] = "game.microPopcorn.MicroPopcorn";
|
||||
MicroPuppy;
|
||||
minigameFullyQualifiedNames["MicroPuppy"] = "game.microPuppy.MicroPuppy";
|
||||
MicroSmoothie;
|
||||
minigameFullyQualifiedNames["MicroSmoothie"] = "game.microSmoothie.MicroSmoothie";
|
||||
MicroSnake;
|
||||
minigameFullyQualifiedNames["MicroSnake"] = "game.microSnake.MicroSnake";
|
||||
MicroStoneMining;
|
||||
minigameFullyQualifiedNames["MicroStoneMining"] = "game.microStoneMining.MicroStoneMining";
|
||||
MicroWoodGather;
|
||||
minigameFullyQualifiedNames["MicroWoodGather"] = "game.microWoodGather.MicroWoodGather";
|
||||
MiniGame_Memory;
|
||||
minigameFullyQualifiedNames["MiniGame_Memory"] = "game.miniGame_Memory.MiniGame_Memory";
|
||||
MoatMadness;
|
||||
minigameFullyQualifiedNames["MoatMadness"] = "game.moatMadness.MoatMadness";
|
||||
PVP_Bowling;
|
||||
minigameFullyQualifiedNames["PVP_Bowling"] = "game.pVP_Bowling.PVP_Bowling";
|
||||
PVP_ConnectFour;
|
||||
minigameFullyQualifiedNames["PVP_ConnectFour"] = "game.pVP_ConnectFour.PVP_ConnectFour";
|
||||
PVP_Marbles;
|
||||
minigameFullyQualifiedNames["PVP_Marbles"] = "game.pVP_Marbles.PVP_Marbles";
|
||||
PVP_Memory;
|
||||
minigameFullyQualifiedNames["PVP_Memory"] = "game.pVP_Memory.PVP_Memory";
|
||||
PVP_RockPaperScissor;
|
||||
minigameFullyQualifiedNames["PVP_RockPaperScissor"] = "game.pVP_RockPaperScissor.PVP_RockPaperScissor";
|
||||
PVP_Scooped;
|
||||
minigameFullyQualifiedNames["PVP_Scooped"] = "game.pVP_Scooped.PVP_Scooped";
|
||||
PVP_ShellGame;
|
||||
minigameFullyQualifiedNames["PVP_ShellGame"] = "game.pVP_ShellGame.PVP_ShellGame";
|
||||
PVP_TicTacToe;
|
||||
minigameFullyQualifiedNames["PVP_TicTacToe"] = "game.pVP_TicTacToe.PVP_TicTacToe";
|
||||
Pachinko;
|
||||
minigameFullyQualifiedNames["Pachinko"] = "game.pachinko.Pachinko";
|
||||
ParachuteGlider;
|
||||
minigameFullyQualifiedNames["ParachuteGlider"] = "game.parachuteGlider.ParachuteGlider";
|
||||
PhantomFighter;
|
||||
minigameFullyQualifiedNames["PhantomFighter"] = "game.phantomFighter.PhantomFighter";
|
||||
PhantomsTreasure;
|
||||
minigameFullyQualifiedNames["PhantomsTreasure"] = "game.phantomsTreasure.PhantomsTreasure";
|
||||
PillBugs;
|
||||
minigameFullyQualifiedNames["PillBugs"] = "game.pillBugs.PillBugs";
|
||||
QuestParachuteGlider;
|
||||
minigameFullyQualifiedNames["QuestParachuteGlider"] = "game.questParachuteGlider.QuestParachuteGlider";
|
||||
RiverRace;
|
||||
minigameFullyQualifiedNames["RiverRace"] = "game.riverRace.RiverRace";
|
||||
SafetyQuiz;
|
||||
minigameFullyQualifiedNames["SafetyQuiz"] = "game.safetyQuiz.SafetyQuiz";
|
||||
ShootingGallery;
|
||||
minigameFullyQualifiedNames["ShootingGallery"] = "game.shootingGallery.ShootingGallery";
|
||||
Skeeball;
|
||||
minigameFullyQualifiedNames["Skeeball"] = "game.skeeball.Skeeball";
|
||||
SpiderShooter;
|
||||
minigameFullyQualifiedNames["SpiderShooter"] = "game.spiderShooter.SpiderShooter";
|
||||
SpotOn;
|
||||
minigameFullyQualifiedNames["SpotOn"] = "game.spotOn.SpotOn";
|
||||
SuperSort;
|
||||
minigameFullyQualifiedNames["SuperSort"] = "game.superSort.SuperSort";
|
||||
TouchPool;
|
||||
minigameFullyQualifiedNames["TouchPool"] = "game.touchPool.TouchPool";
|
||||
TowerDefense;
|
||||
minigameFullyQualifiedNames["TowerDefense"] = "game.towerDefense.TowerDefense";
|
||||
Trivia;
|
||||
minigameFullyQualifiedNames["Trivia"] = "game.trivia.Trivia";
|
||||
TrueFalse;
|
||||
minigameFullyQualifiedNames["TrueFalse"] = "game.trueFalse.TrueFalse";
|
||||
Twister;
|
||||
minigameFullyQualifiedNames["Twister"] = "game.twister.Twister";
|
||||
WhackPhantom;
|
||||
minigameFullyQualifiedNames["WhackPhantom"] = "game.whackPhantom.WhackPhantom";
|
||||
WindRider;
|
||||
minigameFullyQualifiedNames["WindRider"] = "game.windRider.WindRider";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package game
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class MinigameInfo
|
||||
{
|
||||
|
||||
public var gameDefId:uint;
|
||||
|
||||
public var titleStrId:uint;
|
||||
|
||||
public var extName:String;
|
||||
|
||||
public var swfName:String;
|
||||
|
||||
public var minPlayers:uint;
|
||||
|
||||
public var maxPlayers:uint;
|
||||
|
||||
public var maxSpectators:uint;
|
||||
|
||||
public var type:uint;
|
||||
|
||||
public var gameCardMediaId:uint;
|
||||
|
||||
public var gameCountUserVarRef:uint;
|
||||
|
||||
public var custom1UserVarRef:uint;
|
||||
|
||||
public var custom2UserVarRef:uint;
|
||||
|
||||
public var readyForPVP:Boolean;
|
||||
|
||||
public var gemMultiplier:Number;
|
||||
|
||||
public var petDefId:int;
|
||||
|
||||
public var proModeUserVarRefId:int;
|
||||
|
||||
public var lbUseVarRef:int;
|
||||
|
||||
public var gameLibraryIconMediaId:int;
|
||||
|
||||
public var requiredAvatarType:int;
|
||||
|
||||
private var _gameCardScreen:MovieClip;
|
||||
|
||||
private var _hasLoadedScreen:Boolean;
|
||||
|
||||
public function MinigameInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:uint, param2:uint, param3:String, param4:String, param5:uint, param6:uint, param7:uint, param8:uint, param9:uint, param10:uint, param11:uint, param12:uint, param13:uint, param14:Number, param15:MovieClip, param16:int, param17:int, param18:int, param19:int, param20:int) : void
|
||||
{
|
||||
gameDefId = param1;
|
||||
titleStrId = param2;
|
||||
extName = param3;
|
||||
swfName = param4;
|
||||
minPlayers = param5;
|
||||
maxPlayers = param6;
|
||||
maxSpectators = param7;
|
||||
type = param8;
|
||||
gameCardMediaId = param9;
|
||||
gameCountUserVarRef = param10;
|
||||
custom1UserVarRef = param11;
|
||||
custom2UserVarRef = param12;
|
||||
readyForPVP = param13 != 0;
|
||||
gemMultiplier = param14;
|
||||
gameCardScreen = param15;
|
||||
petDefId = param16;
|
||||
proModeUserVarRefId = param17;
|
||||
lbUseVarRef = param18;
|
||||
gameLibraryIconMediaId = param19;
|
||||
requiredAvatarType = param20;
|
||||
}
|
||||
|
||||
public function get isInRoomGame() : Boolean
|
||||
{
|
||||
return type == 0;
|
||||
}
|
||||
|
||||
public function get gameCardScreen() : MovieClip
|
||||
{
|
||||
var _loc1_:MediaHelper = null;
|
||||
if(_hasLoadedScreen)
|
||||
{
|
||||
return _gameCardScreen;
|
||||
}
|
||||
_gameCardScreen = new MovieClip();
|
||||
_loc1_ = new MediaHelper();
|
||||
_loc1_.init(gameCardMediaId,onScreenLoaded);
|
||||
return _gameCardScreen;
|
||||
}
|
||||
|
||||
public function set gameCardScreen(param1:MovieClip) : void
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
_hasLoadedScreen = true;
|
||||
}
|
||||
_gameCardScreen = param1;
|
||||
}
|
||||
|
||||
private function onScreenLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_gameCardScreen.addChild(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package game
|
||||
{
|
||||
public class MinigameInfoCache
|
||||
{
|
||||
|
||||
public var currMinigameId:int;
|
||||
|
||||
private var minigameInfo:Object;
|
||||
|
||||
public function MinigameInfoCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
minigameInfo = {};
|
||||
currMinigameId = -1;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
minigameInfo = null;
|
||||
}
|
||||
|
||||
public function get playerMinigameInfo() : MinigameInfo
|
||||
{
|
||||
return minigameInfo[currMinigameId];
|
||||
}
|
||||
|
||||
public function set playerMinigameInfo(param1:MinigameInfo) : void
|
||||
{
|
||||
currMinigameId = param1.gameDefId;
|
||||
minigameInfo[currMinigameId] = param1;
|
||||
}
|
||||
|
||||
public function getMinigameInfo(param1:int) : MinigameInfo
|
||||
{
|
||||
return minigameInfo[param1];
|
||||
}
|
||||
|
||||
public function getMinigameInfoByExtName(param1:String) : MinigameInfo
|
||||
{
|
||||
for each(var _loc2_:MinigameInfo in minigameInfo)
|
||||
{
|
||||
if(_loc2_.extName == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getMinigameInfoBySwfName(param1:String) : MinigameInfo
|
||||
{
|
||||
for each(var _loc2_:MinigameInfo in minigameInfo)
|
||||
{
|
||||
if(_loc2_.swfName == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAllReadyForPvpGameDefs() : Array
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
if(minigameInfo)
|
||||
{
|
||||
_loc1_ = [];
|
||||
for each(var _loc2_:MinigameInfo in minigameInfo)
|
||||
{
|
||||
if(_loc2_.readyForPVP)
|
||||
{
|
||||
_loc1_.push(_loc2_);
|
||||
}
|
||||
}
|
||||
_loc1_.sortOn(["gameDefId"],2 | 0x10);
|
||||
return _loc1_;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setMinigameInfo(param1:int, param2:MinigameInfo) : void
|
||||
{
|
||||
minigameInfo[param1] = param2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,143 @@
|
||||
package game
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
|
||||
public class MinigameXtCommManager
|
||||
{
|
||||
|
||||
public static const PVP_REQUEST_OR_ACCEPT:int = 0;
|
||||
|
||||
public static const PVP_DENY_DENIED_OR_CANCEL:int = 1;
|
||||
|
||||
private static var _miCallback:Function;
|
||||
|
||||
public function MinigameXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
XtReplyDemuxer.addModule(handleXtReply,"m");
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
XtReplyDemuxer.removeModule(handleXtReply);
|
||||
}
|
||||
|
||||
public static function sendMinigameInfoRequest(param1:Array, param2:Boolean = false, param3:Function = null) : void
|
||||
{
|
||||
_miCallback = param3;
|
||||
gMainFrame.server.setXtObject_Str("mi",param1,true,param2);
|
||||
}
|
||||
|
||||
public static function sendMinigameJoinRequest(param1:int, param2:Boolean = false, param3:Boolean = false, param4:int = 0) : void
|
||||
{
|
||||
var _loc5_:Array = [param1,param3 ? "1" : "0",param4];
|
||||
gMainFrame.server.setXtObject_Str("mj",_loc5_,true,param2);
|
||||
}
|
||||
|
||||
public static function sendMinigameStartRequest(param1:int, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc3_:Array = [param1];
|
||||
gMainFrame.server.setXtObject_Str("ms",_loc3_,true,param2);
|
||||
}
|
||||
|
||||
public static function sendMinigameLeaveRequest() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ml",null,true,true);
|
||||
}
|
||||
|
||||
public static function sendMinigameMessageRequest(param1:Array, param2:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("mm",param1,true,param2);
|
||||
}
|
||||
|
||||
public static function sendMinigamePvpMsg(param1:int, param2:int, param3:String = "") : void
|
||||
{
|
||||
if(param3 != "")
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("mp",[param1,param2,param3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("mp",[param1,param2]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendMinigameCustomPvpJoinMsg(param1:int, param2:int, param3:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("mcp",[param1,param2,param3]);
|
||||
}
|
||||
|
||||
public static function sendMinigameLeaderboardRequest(param1:int) : void
|
||||
{
|
||||
var _loc2_:Array = [param1];
|
||||
gMainFrame.server.setXtObject_Str("mlb",_loc2_);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:* = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "mi":
|
||||
handleMinigameInfo(_loc2_);
|
||||
break;
|
||||
case "ms":
|
||||
MinigameManager.startGame(_loc2_);
|
||||
break;
|
||||
case "mj":
|
||||
MinigameManager.joinGameResponse(_loc2_);
|
||||
break;
|
||||
case "ml":
|
||||
case "mm":
|
||||
MinigameManager.messageGame(_loc2_);
|
||||
break;
|
||||
case "me":
|
||||
MinigameManager.minigameEndResponse(_loc2_);
|
||||
break;
|
||||
case "mr":
|
||||
MinigameManager.minigameRoomRemovedResponse(_loc2_);
|
||||
break;
|
||||
case "mp":
|
||||
MinigameManager.pvpResponse(_loc2_);
|
||||
break;
|
||||
case "mg":
|
||||
MinigameManager.minigameGems(_loc2_);
|
||||
break;
|
||||
case "ma":
|
||||
MinigameManager.minigamePetMastery(_loc2_);
|
||||
break;
|
||||
case "mlb":
|
||||
MinigameManager.leaderBoardResponse(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("MinigameManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleMinigameInfo(param1:Object) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:MinigameInfo = null;
|
||||
var _loc2_:int = 2;
|
||||
var _loc4_:int = parseInt(param1[_loc2_++]);
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_)
|
||||
{
|
||||
_loc5_ = new MinigameInfo();
|
||||
_loc5_.init(parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),param1[_loc2_++],param1[_loc2_++],parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseFloat(param1[_loc2_++]),null,parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]),parseInt(param1[_loc2_++]));
|
||||
MinigameManager.minigameInfoCache.setMinigameInfo(_loc5_.gameDefId,_loc5_);
|
||||
_loc3_++;
|
||||
}
|
||||
if(_miCallback != null)
|
||||
{
|
||||
_miCallback();
|
||||
_miCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
package game
|
||||
{
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import com.sbi.loader.LoaderCache;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.media.Sound;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class SoundManager
|
||||
{
|
||||
|
||||
private static const BARWIDTH:int = 136;
|
||||
|
||||
public var _soundVolume:Dictionary;
|
||||
|
||||
public var _soundChannel:Dictionary;
|
||||
|
||||
public var _sound:Dictionary;
|
||||
|
||||
public var _soundByName:Dictionary;
|
||||
|
||||
private var _soundsPlaying:Dictionary;
|
||||
|
||||
private var _soundLimit:int;
|
||||
|
||||
public var _sounds:Array;
|
||||
|
||||
public var _soundToolInstace:MovieClip;
|
||||
|
||||
public var _barSound:Dictionary;
|
||||
|
||||
public var _minigame:GameBase;
|
||||
|
||||
private var _currentDragger:MovieClip;
|
||||
|
||||
private var _soundVolumeByName:Dictionary;
|
||||
|
||||
private var _lastTimeFadeIn:Number;
|
||||
|
||||
private var _lastTimeFadeOut:Number;
|
||||
|
||||
private var _fadeInStream:SBMusic;
|
||||
|
||||
private var _fadeOutStream:SBMusic;
|
||||
|
||||
public function SoundManager(param1:GameBase, param2:int = 0)
|
||||
{
|
||||
super();
|
||||
_soundVolume = new Dictionary(true);
|
||||
_barSound = new Dictionary(true);
|
||||
_soundChannel = new Dictionary(true);
|
||||
_sound = new Dictionary(true);
|
||||
_soundByName = new Dictionary(true);
|
||||
_soundsPlaying = new Dictionary(true);
|
||||
_soundVolumeByName = new Dictionary(true);
|
||||
_sounds = [];
|
||||
_minigame = param1;
|
||||
_soundLimit = param2;
|
||||
if(!MainFrame.isInitialized())
|
||||
{
|
||||
LoaderCache.contentURL = "../../";
|
||||
}
|
||||
}
|
||||
|
||||
public function setVolumes(param1:Dictionary) : void
|
||||
{
|
||||
for(var _loc2_:Object in param1)
|
||||
{
|
||||
_soundVolumeByName[_loc2_] = param1[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private function getSound(param1:String) : Object
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for each(_loc2_ in _sounds)
|
||||
{
|
||||
if(_loc2_.name == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addSound(param1:Class, param2:Number, param3:String = null) : void
|
||||
{
|
||||
var _loc6_:Object = getSound(param3);
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
_loc6_ = {};
|
||||
_loc6_.sound = new param1() as Sound;
|
||||
if(param3)
|
||||
{
|
||||
_loc6_.name = param3;
|
||||
}
|
||||
_sounds.push(_loc6_);
|
||||
_sound[param1] = _loc6_.sound;
|
||||
}
|
||||
if(param2 >= 0)
|
||||
{
|
||||
_soundVolume[_loc6_.sound] = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundVolume[_loc6_.sound] = _soundVolumeByName[param3];
|
||||
}
|
||||
_soundsPlaying[_loc6_.sound] = 0;
|
||||
var _loc5_:SoundTransform = new SoundTransform(0,0);
|
||||
var _loc4_:SoundChannel = _loc6_.sound.play(0,0,_loc5_);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public function addSoundByName(param1:Sound, param2:String, param3:Number) : void
|
||||
{
|
||||
var _loc6_:Object = getSound(param2);
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
_loc6_ = {};
|
||||
_loc6_.sound = param1;
|
||||
_loc6_.name = param2;
|
||||
_sounds.push(_loc6_);
|
||||
_soundByName[param2] = param1;
|
||||
}
|
||||
if(param3 >= 0)
|
||||
{
|
||||
_soundVolume[_loc6_.sound] = param3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundVolume[_loc6_.sound] = _soundVolumeByName[param2];
|
||||
}
|
||||
_soundsPlaying[_loc6_.sound] = 0;
|
||||
var _loc5_:SoundTransform = new SoundTransform(0,0);
|
||||
var _loc4_:SoundChannel = _loc6_.sound.play(0,0,_loc5_);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public function addStream(param1:String, param2:Number) : SBMusic
|
||||
{
|
||||
var _loc4_:Object = {};
|
||||
var _loc3_:SBMusic = new SBMusic(param1 + ".mp3",false,param2);
|
||||
_loc4_.sound = _loc3_;
|
||||
_loc4_.name = param1;
|
||||
_soundVolume[_loc4_.sound] = param2;
|
||||
_sounds.push(_loc4_);
|
||||
return _loc4_.sound;
|
||||
}
|
||||
|
||||
public function play(param1:Class, param2:Number = 0, param3:int = 0) : SoundChannel
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:SoundTransform = null;
|
||||
var _loc5_:SoundChannel = null;
|
||||
var _loc7_:Sound = _sound[param1];
|
||||
if(_loc7_)
|
||||
{
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Number(_soundVolume[_loc7_]);
|
||||
}
|
||||
_loc6_ = new SoundTransform(_loc4_,0);
|
||||
if(_soundLimit > 0)
|
||||
{
|
||||
if(_soundsPlaying[_loc7_] >= _soundLimit && param3 == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_loc5_ = _loc7_.play(param2,param3,_loc6_);
|
||||
if(_loc5_)
|
||||
{
|
||||
_soundsPlaying[_loc5_] = _loc7_;
|
||||
_soundsPlaying[_loc7_]++;
|
||||
if(param3 == 0)
|
||||
{
|
||||
_loc5_.addEventListener("soundComplete",soundComplete);
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
return _loc7_.play(param2,param3,_loc6_);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function playByName(param1:String, param2:Number = 0, param3:int = 0) : SoundChannel
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:SoundTransform = null;
|
||||
var _loc5_:SoundChannel = null;
|
||||
var _loc7_:Sound = _soundByName[param1];
|
||||
if(_loc7_)
|
||||
{
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Number(_soundVolume[_loc7_]);
|
||||
}
|
||||
_loc6_ = new SoundTransform(_loc4_,0);
|
||||
if(_soundLimit > 0)
|
||||
{
|
||||
if(_soundsPlaying[_loc7_] >= _soundLimit && param3 == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_loc5_ = _loc7_.play(param2,param3,_loc6_);
|
||||
if(_loc5_)
|
||||
{
|
||||
_soundsPlaying[_loc5_] = _loc7_;
|
||||
_soundsPlaying[_loc7_]++;
|
||||
if(param3 == 0)
|
||||
{
|
||||
_loc5_.addEventListener("soundComplete",soundComplete);
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
return _loc7_.play(param2,param3,_loc6_);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function soundComplete(param1:Event) : void
|
||||
{
|
||||
param1.target.removeEventListener("soundComplete",soundComplete);
|
||||
_soundsPlaying[_soundsPlaying[param1.target]]--;
|
||||
_soundsPlaying[param1.target] = null;
|
||||
}
|
||||
|
||||
private function doFadeIn(param1:Event) : void
|
||||
{
|
||||
var _loc4_:Number = (getTimer() - _lastTimeFadeIn) / 1000;
|
||||
if(_loc4_ >= 1)
|
||||
{
|
||||
_loc4_ = 1;
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeIn);
|
||||
}
|
||||
var _loc2_:Number = _soundVolume[_fadeInStream] * _loc4_;
|
||||
var _loc5_:SoundChannel = _fadeInStream.sc;
|
||||
var _loc3_:SoundTransform = new SoundTransform(_loc2_,0);
|
||||
_fadeInStream.sc.soundTransform = _loc3_;
|
||||
if(_loc4_ == 1)
|
||||
{
|
||||
_fadeInStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function doFadeOut(param1:Event) : void
|
||||
{
|
||||
var _loc4_:Number = (getTimer() - _lastTimeFadeOut) / 1000;
|
||||
if(_loc4_ >= 1)
|
||||
{
|
||||
_loc4_ = 1;
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeOut);
|
||||
}
|
||||
var _loc2_:Number = _soundVolume[_fadeOutStream] * (1 - _loc4_);
|
||||
var _loc3_:SoundTransform = new SoundTransform(_loc2_,0);
|
||||
_fadeOutStream.sc.soundTransform = _loc3_;
|
||||
if(_loc4_ == 1)
|
||||
{
|
||||
_fadeOutStream.sc.stop();
|
||||
_fadeOutStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(_fadeInStream)
|
||||
{
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeIn);
|
||||
_fadeInStream = null;
|
||||
}
|
||||
if(_fadeOutStream)
|
||||
{
|
||||
_fadeOutStream.sc.stop();
|
||||
_fadeOutStream = null;
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeOut);
|
||||
}
|
||||
}
|
||||
|
||||
public function fadeOut(param1:SBMusic) : void
|
||||
{
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
param1.stop();
|
||||
return;
|
||||
}
|
||||
_lastTimeFadeOut = getTimer();
|
||||
_fadeOutStream = param1;
|
||||
gMainFrame.stage.addEventListener("enterFrame",doFadeOut,false,0,true);
|
||||
}
|
||||
|
||||
public function playStream(param1:SBMusic, param2:Number = 0, param3:int = 0, param4:Boolean = false) : SoundChannel
|
||||
{
|
||||
var _loc6_:SoundTransform = null;
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
param4 = false;
|
||||
}
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc5_:Number = Number(_soundVolume[param1]);
|
||||
if(_fadeOutStream == param1)
|
||||
{
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeOut);
|
||||
_loc5_ = Number(_soundVolume[_fadeOutStream]);
|
||||
_loc6_ = new SoundTransform(_loc5_,0);
|
||||
_fadeOutStream.sc.soundTransform = _loc6_;
|
||||
return _fadeOutStream.sc;
|
||||
}
|
||||
if(param4)
|
||||
{
|
||||
_loc6_ = new SoundTransform(0,0);
|
||||
gMainFrame.stage.addEventListener("enterFrame",doFadeIn,false,0,true);
|
||||
_lastTimeFadeIn = getTimer();
|
||||
_fadeInStream = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new SoundTransform(_loc5_,0);
|
||||
}
|
||||
param1.stop();
|
||||
param1.play(param2,param3,_loc6_);
|
||||
if(param1.sc == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_soundChannel[param1] = param1.sc;
|
||||
param1.sc.soundTransform = _loc6_;
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
param1.mute();
|
||||
}
|
||||
return param1.sc;
|
||||
}
|
||||
|
||||
public function pauseStream(param1:SBMusic) : void
|
||||
{
|
||||
param1.pause();
|
||||
}
|
||||
|
||||
public function unpauseStream(param1:SBMusic) : void
|
||||
{
|
||||
param1.unpause();
|
||||
}
|
||||
|
||||
public function togglePauseStream(param1:SBMusic) : void
|
||||
{
|
||||
param1.togglePause();
|
||||
}
|
||||
|
||||
public function stop(param1:SoundChannel) : void
|
||||
{
|
||||
_soundsPlaying[_soundsPlaying[param1]]--;
|
||||
param1.stop();
|
||||
}
|
||||
|
||||
private function onPlay(param1:MouseEvent) : void
|
||||
{
|
||||
if(_barSound[param1.target.parent] is Sound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playStream(_barSound[param1.target.parent],0,9999);
|
||||
}
|
||||
|
||||
private function onStop(param1:MouseEvent) : void
|
||||
{
|
||||
if(_barSound[param1.target.parent] is Sound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_barSound[param1.target.parent].stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,478 @@
|
||||
package game.artPrintPlayPortrait
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.printing.PrintJob;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import gui.LoadingSpiral;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class ArtPrintPlayPortrait extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _printMediaHelper:MediaHelper;
|
||||
|
||||
private var _activeImageIndex:int;
|
||||
|
||||
private var _imageIDs:Array;
|
||||
|
||||
private var _loadedImages:Array;
|
||||
|
||||
private var _loadedPrintImages:Array;
|
||||
|
||||
private var _printOffsets:Array;
|
||||
|
||||
private var _theGame:MovieClip;
|
||||
|
||||
private var _activeImage1:MovieClip;
|
||||
|
||||
private var _activeImage2:MovieClip;
|
||||
|
||||
private var _activeImage3:MovieClip;
|
||||
|
||||
private var _loadingSpiral1:LoadingSpiral;
|
||||
|
||||
private var _loadingSpiral2:LoadingSpiral;
|
||||
|
||||
private var _loadingSpiral3:LoadingSpiral;
|
||||
|
||||
public var _layerBackground:Sprite;
|
||||
|
||||
public function ArtPrintPlayPortrait()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_loadingSpiral1)
|
||||
{
|
||||
_loadingSpiral1.destroy();
|
||||
}
|
||||
if(_loadingSpiral2)
|
||||
{
|
||||
_loadingSpiral2.destroy();
|
||||
}
|
||||
if(_loadingSpiral3)
|
||||
{
|
||||
_loadingSpiral3.destroy();
|
||||
}
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",keyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
_bInit = false;
|
||||
removeLayer(_layerBackground);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBackground = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBackground = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBackground);
|
||||
addChild(_guiLayer);
|
||||
loadScene("ArtPrintPlayPortrait/room_main.xroom");
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:* = null;
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("keyDown",keyDown);
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_theGame = showDlg("museumPrint_GUI",[{
|
||||
"name":"page0",
|
||||
"f":onPage0
|
||||
},{
|
||||
"name":"page1",
|
||||
"f":onPage1
|
||||
},{
|
||||
"name":"page2",
|
||||
"f":onPage2
|
||||
},{
|
||||
"name":"arrowL_btn",
|
||||
"f":onArrowLeft
|
||||
},{
|
||||
"name":"arrowR_btn",
|
||||
"f":onArrowRight
|
||||
},{
|
||||
"name":"x_btn",
|
||||
"f":onExit
|
||||
}]);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 122)
|
||||
{
|
||||
case 0:
|
||||
_theGame.arrowR_btn.visible = false;
|
||||
_theGame.arrowL_btn.visible = false;
|
||||
_theGame.Deleted_Symbol.visible = false;
|
||||
_theGame.Deleted_Symbol_1.visible = false;
|
||||
_theGame.covers.y = 157.05;
|
||||
}
|
||||
}
|
||||
_loadingSpiral1 = new LoadingSpiral(_theGame.page0,0,0);
|
||||
_loadingSpiral2 = new LoadingSpiral(_theGame.page1,0,0);
|
||||
_loadingSpiral3 = new LoadingSpiral(_theGame.page2,0,0);
|
||||
_activeImageIndex = 0;
|
||||
_imageIDs = new Array(2290,2289,2291);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId)
|
||||
{
|
||||
case 76:
|
||||
_imageIDs = new Array(1591,1592,1593);
|
||||
break;
|
||||
case 86:
|
||||
_imageIDs = new Array(1679,1680,1681);
|
||||
break;
|
||||
case 87:
|
||||
_imageIDs = new Array(1735,1736,1737);
|
||||
break;
|
||||
case 95:
|
||||
_imageIDs = new Array(2839,2840,2841,2842);
|
||||
break;
|
||||
case 122:
|
||||
_imageIDs = new Array(4504,4504,4504);
|
||||
break;
|
||||
case 124:
|
||||
_imageIDs = new Array(4594,4595,4596,4597);
|
||||
break;
|
||||
case 135:
|
||||
_imageIDs = new Array(4743,4744,4745,4746);
|
||||
break;
|
||||
case 136:
|
||||
_imageIDs = new Array(4885,4886,4887);
|
||||
}
|
||||
}
|
||||
_printOffsets = new Array(new Point(0,0),new Point(0,0),new Point(0,0),new Point(0,0));
|
||||
_loadedImages = [];
|
||||
_loadedPrintImages = [];
|
||||
loadImage(_imageIDs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadImage(param1:int) : void
|
||||
{
|
||||
_printMediaHelper = new MediaHelper();
|
||||
_printMediaHelper.init(param1,ImageLoadedHandler);
|
||||
}
|
||||
|
||||
private function updateButtonImages() : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
var _loc1_:MovieClip = null;
|
||||
var _loc4_:MovieClip = null;
|
||||
var _loc3_:int = _activeImageIndex;
|
||||
if(_loc3_ < _loadedPrintImages.length)
|
||||
{
|
||||
_loc2_ = _loadedImages[_loc3_];
|
||||
}
|
||||
if(++_loc3_ >= _imageIDs.length)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
if(_loc3_ < _loadedPrintImages.length)
|
||||
{
|
||||
_loc1_ = _loadedImages[_loc3_];
|
||||
}
|
||||
if(++_loc3_ >= _imageIDs.length)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
if(_loc3_ < _loadedPrintImages.length)
|
||||
{
|
||||
_loc4_ = _loadedImages[_loc3_];
|
||||
}
|
||||
if(_activeImage1 != null && (_activeImage1 != _loc2_ && _activeImage1 != _loc1_ && _activeImage1 != _loc4_))
|
||||
{
|
||||
if(_activeImage1.parent != null)
|
||||
{
|
||||
_activeImage1.parent.removeChild(_activeImage1);
|
||||
}
|
||||
_activeImage1 = null;
|
||||
}
|
||||
if(_activeImage2 != null && (_activeImage2 != _loc2_ && _activeImage2 != _loc1_ && _activeImage2 != _loc4_))
|
||||
{
|
||||
if(_activeImage2.parent != null)
|
||||
{
|
||||
_activeImage2.parent.removeChild(_activeImage2);
|
||||
}
|
||||
_activeImage2 = null;
|
||||
}
|
||||
if(_activeImage3 != null && (_activeImage3 != _loc2_ && _activeImage3 != _loc1_ && _activeImage3 != _loc4_))
|
||||
{
|
||||
if(_activeImage3.parent != null)
|
||||
{
|
||||
_activeImage3.parent.removeChild(_activeImage3);
|
||||
}
|
||||
_activeImage3 = null;
|
||||
}
|
||||
if(_loc2_)
|
||||
{
|
||||
_theGame.page0.imageContainer.addChild(_loc2_);
|
||||
_activeImage1 = _loc2_;
|
||||
_loadingSpiral1.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadingSpiral1.visible = true;
|
||||
}
|
||||
if(_loc1_)
|
||||
{
|
||||
_theGame.page1.imageContainer.addChild(_loc1_);
|
||||
_activeImage2 = _loc1_;
|
||||
_loadingSpiral2.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadingSpiral2.visible = true;
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
_theGame.page2.imageContainer.addChild(_loc4_);
|
||||
_activeImage3 = _loc4_;
|
||||
_loadingSpiral3.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadingSpiral3.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function ImageLoadedHandler(param1:MovieClip) : void
|
||||
{
|
||||
if(_loadedImages.length == _loadedPrintImages.length)
|
||||
{
|
||||
_loadedImages.push(param1);
|
||||
loadImage(_imageIDs[_loadedImages.length - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadedPrintImages.push(param1);
|
||||
if(_loadedPrintImages.length < _imageIDs.length)
|
||||
{
|
||||
loadImage(_imageIDs[_loadedPrintImages.length]);
|
||||
}
|
||||
updateButtonImages();
|
||||
}
|
||||
}
|
||||
|
||||
private function keyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onPage1();
|
||||
break;
|
||||
case 39:
|
||||
onArrowRight();
|
||||
break;
|
||||
case 37:
|
||||
onArrowLeft();
|
||||
}
|
||||
}
|
||||
|
||||
private function onPage0() : void
|
||||
{
|
||||
if(_activeImageIndex < _loadedPrintImages.length)
|
||||
{
|
||||
printOnePerPage(_activeImageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private function onPage1() : void
|
||||
{
|
||||
var _loc1_:int = _activeImageIndex + 1;
|
||||
if(_loc1_ >= _imageIDs.length)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
if(_loc1_ < _loadedPrintImages.length)
|
||||
{
|
||||
printOnePerPage(_loc1_);
|
||||
}
|
||||
}
|
||||
|
||||
private function onPage2() : void
|
||||
{
|
||||
var _loc1_:int = _activeImageIndex + 2;
|
||||
if(_loc1_ == _imageIDs.length)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
else if(_loc1_ >= _imageIDs.length)
|
||||
{
|
||||
_loc1_ = 1;
|
||||
}
|
||||
if(_loc1_ < _loadedPrintImages.length)
|
||||
{
|
||||
printOnePerPage(_loc1_);
|
||||
}
|
||||
}
|
||||
|
||||
private function onArrowLeft() : void
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex - 1;
|
||||
if(_activeImageIndex < 0)
|
||||
{
|
||||
_activeImageIndex = _imageIDs.length - 1;
|
||||
}
|
||||
updateButtonImages();
|
||||
}
|
||||
|
||||
private function onArrowRight() : void
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex + 1;
|
||||
if(_activeImageIndex >= _imageIDs.length)
|
||||
{
|
||||
_activeImageIndex = 0;
|
||||
}
|
||||
updateButtonImages();
|
||||
}
|
||||
|
||||
private function onExit() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function printOnePerPage(param1:int) : void
|
||||
{
|
||||
var _loc6_:PrintJob = null;
|
||||
var _loc3_:Sprite = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc8_:BitmapData = null;
|
||||
var _loc11_:Bitmap = null;
|
||||
var _loc9_:Sprite = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
if(param1 < _loadedPrintImages.length)
|
||||
{
|
||||
stage.removeEventListener("keyDown",keyDown);
|
||||
_loc6_ = new PrintJob();
|
||||
if(_loc6_.start())
|
||||
{
|
||||
_loc3_ = new Sprite();
|
||||
_loadedPrintImages[param1].scaleX = 4;
|
||||
_loadedPrintImages[param1].scaleY = 4;
|
||||
_loc3_.addChild(_loadedPrintImages[param1]);
|
||||
_loadedPrintImages[param1].x = 1;
|
||||
_loadedPrintImages[param1].y = 1;
|
||||
_loc7_ = _loc3_.width;
|
||||
_loc10_ = _loc3_.height;
|
||||
_loc2_ = 0;
|
||||
_loc8_ = new BitmapData(_loc3_.width,_loc3_.height,false,4294967295);
|
||||
_loc8_.draw(_loc3_);
|
||||
_loc11_ = new Bitmap(_loc8_);
|
||||
_loc9_ = new Sprite();
|
||||
_loc9_.addChild(_loc11_);
|
||||
_loc11_.x = 0;
|
||||
_loc11_.y = 0;
|
||||
_loc11_.scaleX = 0.999;
|
||||
_loc11_.scaleY = 0.999;
|
||||
_loc9_.x = 0;
|
||||
_loc9_.y = 0;
|
||||
if(_loc6_.orientation != "portrait")
|
||||
{
|
||||
_loc9_.rotation = 90;
|
||||
_loc9_.x = _loc9_.width;
|
||||
_loc5_ = _loc6_.pageWidth / _loc10_;
|
||||
_loc4_ = _loc6_.pageHeight / _loc7_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc6_.pageWidth / _loc7_;
|
||||
_loc4_ = _loc6_.pageHeight / _loc10_;
|
||||
}
|
||||
_loc9_.scaleX = _loc9_.scaleY = Math.min(_loc5_,_loc4_);
|
||||
_loc9_.visible = false;
|
||||
gMainFrame.stage.addChild(_loc9_);
|
||||
try
|
||||
{
|
||||
_loc6_.addPage(_loc9_,new Rectangle(0,0,_loc7_ + 2,_loc10_ + 2));
|
||||
_loc2_++;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
trace(e);
|
||||
}
|
||||
gMainFrame.stage.removeChild(_loc9_);
|
||||
_loc9_.visible = true;
|
||||
_loc9_.scaleX = _loc9_.scaleY = 1;
|
||||
_loc9_.rotation = 0;
|
||||
_loc3_.removeChild(_loadedPrintImages[param1]);
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_loc6_.send();
|
||||
}
|
||||
}
|
||||
stage.addEventListener("keyDown",keyDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,560 @@
|
||||
package game.artStudioPottery
|
||||
{
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.printing.PrintJob;
|
||||
import flash.ui.Mouse;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class ArtStudioPottery extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _activeImageMediaHelper:MediaHelper;
|
||||
|
||||
private var _exitConfirmationActive:Boolean;
|
||||
|
||||
private var _activeImageIndex:int;
|
||||
|
||||
private var _imageIDs:Array;
|
||||
|
||||
private var _previewIDs:Array;
|
||||
|
||||
private var _loadingImage:Boolean;
|
||||
|
||||
private var _interfaceObject:Object;
|
||||
|
||||
private var _brush:Object;
|
||||
|
||||
private var _activeImage:MovieClip;
|
||||
|
||||
public var _layerBackground:Sprite;
|
||||
|
||||
public var _layerForeground:Sprite;
|
||||
|
||||
public var _layerInterface:Sprite;
|
||||
|
||||
public var _layerMouse:Sprite;
|
||||
|
||||
public var _selectBackground:Object;
|
||||
|
||||
protected var _buttonLeft:MovieClip;
|
||||
|
||||
protected var _buttonRight:MovieClip;
|
||||
|
||||
protected var _buttonColor:MovieClip;
|
||||
|
||||
protected var _buttonPrint:MovieClip;
|
||||
|
||||
protected var _buttonClose:MovieClip;
|
||||
|
||||
private var _printBackground:Object;
|
||||
|
||||
public var _SFX_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
public function ArtStudioPottery()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
private function drawCanvasMouseOver(param1:MouseEvent) : void
|
||||
{
|
||||
Mouse.show();
|
||||
_layerMouse.visible = false;
|
||||
}
|
||||
|
||||
private function drawCanvasMouseOut(param1:MouseEvent) : void
|
||||
{
|
||||
Mouse.hide();
|
||||
_layerMouse.visible = true;
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
Mouse.show();
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",keyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("mouseMove",moveMouse);
|
||||
_buttonPrint.removeEventListener("mouseOver",drawCanvasMouseOver);
|
||||
_buttonPrint.removeEventListener("mouseOut",drawCanvasMouseOut);
|
||||
_buttonClose.removeEventListener("mouseOver",drawCanvasMouseOver);
|
||||
_buttonClose.removeEventListener("mouseOut",drawCanvasMouseOut);
|
||||
_bInit = false;
|
||||
removeLayer(_layerForeground);
|
||||
removeLayer(_layerBackground);
|
||||
removeLayer(_layerInterface);
|
||||
removeLayer(_layerMouse);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBackground = null;
|
||||
_layerInterface = null;
|
||||
_layerMouse = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBackground = new Sprite();
|
||||
_layerInterface = new Sprite();
|
||||
_layerMouse = new Sprite();
|
||||
_layerForeground = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerInterface);
|
||||
addChild(_layerBackground);
|
||||
addChild(_layerForeground);
|
||||
addChild(_guiLayer);
|
||||
addChild(_layerMouse);
|
||||
loadScene("ArtStudioPottery/room_main.xroom");
|
||||
_bInit = true;
|
||||
_exitConfirmationActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
private function moveMouse(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded && _brush)
|
||||
{
|
||||
_brush.loader.x = mouseX;
|
||||
_brush.loader.y = mouseY;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_buttonClose = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_printBackground = _scene.getLayer("template");
|
||||
_printBackground.loader.x = 10000;
|
||||
_printBackground.loader.y = 10000;
|
||||
_brush = _scene.getLayer("brush");
|
||||
_brush.loader.content.mouseEnabled = false;
|
||||
_brush.loader.content.mouseChildren = false;
|
||||
_brush.loader.content.brushTip.mouseEnabled = false;
|
||||
_brush.loader.content.brushTip.mouseChildren = false;
|
||||
_brush.loader.x = mouseX;
|
||||
_brush.loader.y = mouseY;
|
||||
_interfaceObject = _scene.getLayer("interface");
|
||||
_interfaceObject.loader.content.activeCursor = _brush.loader.content;
|
||||
_selectBackground = _scene.getLayer("selectBackground");
|
||||
_selectBackground.loader.x = 0;
|
||||
_selectBackground.loader.y = 0;
|
||||
_layerInterface.addChild(_selectBackground.loader);
|
||||
_loc4_ = _scene.getLayer("buttonLeft");
|
||||
_buttonLeft = addBtn("arrowL_button",_loc4_.x - _selectBackground.x,_loc4_.y - _selectBackground.y,onButtonLeft);
|
||||
_loc4_ = _scene.getLayer("buttonRight");
|
||||
_buttonRight = addBtn("arrowR_button",_loc4_.x - _selectBackground.x,_loc4_.y - _selectBackground.y,onButtonRight);
|
||||
_loc4_ = _scene.getLayer("buttonColor");
|
||||
_buttonColor = addBtn("color_button",_loc4_.x - _selectBackground.x,_loc4_.y - _selectBackground.y,onButtonColor);
|
||||
_loc4_ = _scene.getLayer("buttonPrint");
|
||||
_buttonPrint = addBtn("createPrint_button",_loc4_.x,_loc4_.y,onButtonPrint);
|
||||
_buttonPrint.visible = false;
|
||||
_exitConfirmationActive = false;
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("keyDown",keyDown);
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("mouseMove",moveMouse);
|
||||
startGame();
|
||||
_layerForeground.addChild(_scene.getLayer("insideframe").loader);
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_activeImageIndex = 0;
|
||||
_previewIDs = [77,105,106,107,108,109];
|
||||
_imageIDs = [76,98,99,100,101,102];
|
||||
loadImage(0,true);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadImage(param1:int, param2:Boolean) : void
|
||||
{
|
||||
if(!_loadingImage)
|
||||
{
|
||||
if(param1 > 0)
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex + 1;
|
||||
if(_activeImageIndex >= _imageIDs.length)
|
||||
{
|
||||
_activeImageIndex = 0;
|
||||
}
|
||||
}
|
||||
else if(param1 < 0)
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex - 1;
|
||||
if(_activeImageIndex < 0)
|
||||
{
|
||||
_activeImageIndex = _imageIDs.length - 1;
|
||||
}
|
||||
}
|
||||
_loadingImage = true;
|
||||
_activeImageMediaHelper = new MediaHelper();
|
||||
if(param2)
|
||||
{
|
||||
_activeImageMediaHelper.init(_previewIDs[_activeImageIndex],artStudioImageMediaHandler,param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_activeImageMediaHelper.init(_imageIDs[_activeImageIndex],artStudioImageMediaHandler,param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function artStudioImageMediaHandler(param1:MovieClip) : void
|
||||
{
|
||||
if(_activeImage != null && _activeImage.parent)
|
||||
{
|
||||
_activeImage.parent.removeChild(_activeImage);
|
||||
}
|
||||
_activeImage = param1;
|
||||
if(param1.passback)
|
||||
{
|
||||
param1.x = 115;
|
||||
param1.y = 102;
|
||||
}
|
||||
else
|
||||
{
|
||||
_interfaceObject.loader.content.activeImage = _activeImage;
|
||||
_interfaceObject.loader.content.newColor(10,_interfaceObject.loader.content._10.transform.colorTransform);
|
||||
param1.x = 138;
|
||||
param1.y = 84;
|
||||
}
|
||||
_layerBackground.addChild(_activeImage);
|
||||
_layerBackground.addChild(_printBackground.loader);
|
||||
_loadingImage = false;
|
||||
}
|
||||
|
||||
private function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
_exitConfirmationActive = true;
|
||||
_loc1_ = showDlg("ArtStudioPottery_ExitDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
|
||||
private function keyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(_buttonPrint.visible == false)
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
if(_buttonColor && _buttonColor.visible)
|
||||
{
|
||||
onButtonColor();
|
||||
}
|
||||
break;
|
||||
case 39:
|
||||
if(_buttonRight && _buttonRight.visible)
|
||||
{
|
||||
onButtonRight();
|
||||
}
|
||||
break;
|
||||
case 37:
|
||||
if(_buttonLeft && _buttonLeft.visible)
|
||||
{
|
||||
onButtonLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonLeft() : void
|
||||
{
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
loadImage(-1,true);
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonRight() : void
|
||||
{
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
loadImage(1,true);
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonColor() : void
|
||||
{
|
||||
if(!_exitConfirmationActive && !_loadingImage)
|
||||
{
|
||||
if(_activeImage != null && _activeImage.parent)
|
||||
{
|
||||
_activeImage.parent.removeChild(_activeImage);
|
||||
_activeImage = null;
|
||||
}
|
||||
loadImage(0,false);
|
||||
Mouse.hide();
|
||||
_buttonColor.visible = false;
|
||||
_buttonLeft.visible = false;
|
||||
_buttonRight.visible = false;
|
||||
_buttonPrint.visible = true;
|
||||
_buttonPrint.addEventListener("mouseOver",drawCanvasMouseOver);
|
||||
_buttonPrint.addEventListener("mouseOut",drawCanvasMouseOut);
|
||||
_buttonClose.addEventListener("mouseOver",drawCanvasMouseOver);
|
||||
_buttonClose.addEventListener("mouseOut",drawCanvasMouseOut);
|
||||
_selectBackground.loader.parent.removeChild(_selectBackground.loader);
|
||||
_layerInterface.addChild(_interfaceObject.loader);
|
||||
_layerMouse.addChild(_brush.loader);
|
||||
_layerForeground.removeChildAt(0);
|
||||
_layerForeground.addChild(_scene.getLayer("paintframe").loader);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
Mouse.show();
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
}
|
||||
|
||||
private function onButtonPrint() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(!_exitConfirmationActive && !_loadingImage)
|
||||
{
|
||||
_exitConfirmationActive = true;
|
||||
_loc1_ = showDlg("ArtStudioPottery_PrintDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onPrint_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onPrint_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
|
||||
private function onPrint_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
printOnePerPage();
|
||||
}
|
||||
|
||||
private function onPrint_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
}
|
||||
|
||||
private function printOnePerPage() : void
|
||||
{
|
||||
var _loc15_:PrintJob = null;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc1_:Object = null;
|
||||
var _loc11_:Sprite = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc6_:BitmapData = null;
|
||||
var _loc8_:Bitmap = null;
|
||||
var _loc7_:Sprite = null;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
if(_activeImage)
|
||||
{
|
||||
_loc15_ = new PrintJob();
|
||||
if(_loc15_.start())
|
||||
{
|
||||
_loc16_ = _activeImage.x;
|
||||
_loc14_ = _activeImage.y;
|
||||
_loc9_ = _activeImage.scaleX;
|
||||
_loc10_ = _activeImage.scaleY;
|
||||
_loc4_ = Number(_printBackground.loader.content.scaleX);
|
||||
_loc2_ = Number(_printBackground.loader.content.scaleY);
|
||||
_loc1_ = _activeImage.parent;
|
||||
_loc1_.removeChild(_activeImage);
|
||||
_loc11_ = new Sprite();
|
||||
_loc11_.graphics.beginFill(16777215);
|
||||
_activeImage.scaleX = 4;
|
||||
_activeImage.scaleY = 4;
|
||||
_loc11_.graphics.drawRect(0,0,_printBackground.loader.width,_printBackground.loader.height);
|
||||
_printBackground.loader.content.scaleX = 4;
|
||||
_printBackground.loader.content.scaleY = 4;
|
||||
_loc11_.addChild(_printBackground.loader.content);
|
||||
_loc11_.addChild(_activeImage);
|
||||
_activeImage.x = 170;
|
||||
_activeImage.y = 170;
|
||||
_loc5_ = _loc11_.width;
|
||||
_loc17_ = _loc11_.height;
|
||||
_loc3_ = 0;
|
||||
_loc6_ = new BitmapData(_loc11_.width + 2,_loc11_.height + 2);
|
||||
_loc6_.draw(_loc11_);
|
||||
_loc8_ = new Bitmap(_loc6_);
|
||||
_loc7_ = new Sprite();
|
||||
_loc7_.addChild(_loc8_);
|
||||
_loc8_.x = 0;
|
||||
_loc8_.y = 0;
|
||||
_loc8_.scaleX = 0.999;
|
||||
_loc8_.scaleY = 0.999;
|
||||
_loc7_.x = 0;
|
||||
_loc7_.y = 0;
|
||||
if(_loc15_.orientation != "landscape")
|
||||
{
|
||||
_loc7_.rotation = 90;
|
||||
_loc7_.x = _loc7_.width;
|
||||
_loc13_ = _loc15_.pageWidth / _loc17_;
|
||||
_loc12_ = _loc15_.pageHeight / _loc5_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = _loc15_.pageWidth / _loc5_;
|
||||
_loc12_ = _loc15_.pageHeight / _loc17_;
|
||||
}
|
||||
_loc7_.scaleX = _loc7_.scaleY = Math.min(_loc13_,_loc12_);
|
||||
_loc7_.visible = false;
|
||||
gMainFrame.stage.addChild(_loc7_);
|
||||
try
|
||||
{
|
||||
_loc15_.addPage(_loc7_,new Rectangle(0,0,_loc5_,_loc17_));
|
||||
_loc3_++;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
trace(e);
|
||||
}
|
||||
gMainFrame.stage.removeChild(_loc7_);
|
||||
_loc7_.visible = true;
|
||||
_loc7_.scaleX = _loc7_.scaleY = 1;
|
||||
_loc7_.rotation = 0;
|
||||
_loc11_.removeChild(_activeImage);
|
||||
_loc1_.addChild(_activeImage);
|
||||
_activeImage.x = _loc16_;
|
||||
_activeImage.y = _loc14_;
|
||||
_activeImage.scaleX = _loc9_;
|
||||
_activeImage.scaleY = _loc10_;
|
||||
_printBackground.loader.content.scaleX = _loc4_;
|
||||
_printBackground.loader.content.scaleY = _loc2_;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_loc15_.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
package game.artStudioPrint
|
||||
{
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.printing.PrintJob;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class ArtStudioPrint extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _printMediaHelper:MediaHelper;
|
||||
|
||||
private var _exitConfirmationActive:Boolean;
|
||||
|
||||
private var _printImage:MovieClip;
|
||||
|
||||
private var _imageToPrint:MovieClip;
|
||||
|
||||
private var _activeImageIndex:int;
|
||||
|
||||
private var _imageIDs:Array;
|
||||
|
||||
private var _printIDs:Array;
|
||||
|
||||
private var _printOffsets:Array;
|
||||
|
||||
private var _loadingImage:Boolean;
|
||||
|
||||
private var _printBackground:Object;
|
||||
|
||||
public var _layerBackground:Sprite;
|
||||
|
||||
public var _layerForeground:Sprite;
|
||||
|
||||
public var _SFX_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
public function ArtStudioPrint()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",keyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
_bInit = false;
|
||||
removeLayer(_layerForeground);
|
||||
removeLayer(_layerBackground);
|
||||
removeLayer(_guiLayer);
|
||||
_layerForeground = null;
|
||||
_layerBackground = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBackground = new Sprite();
|
||||
_layerForeground = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBackground);
|
||||
addChild(_layerForeground);
|
||||
addChild(_guiLayer);
|
||||
loadScene("ArtStudioPrint/room_main.xroom");
|
||||
_bInit = true;
|
||||
_exitConfirmationActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
var _loc4_:String = "template";
|
||||
var _loc5_:Boolean = true;
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 89)
|
||||
{
|
||||
case 0:
|
||||
_loc4_ = "notemplate";
|
||||
_loc5_ = false;
|
||||
}
|
||||
}
|
||||
_printBackground = _scene.getLayer(_loc4_);
|
||||
_printBackground.loader.x = 10000;
|
||||
_printBackground.loader.y = 10000;
|
||||
_loc6_ = _scene.getLayer("closeButton");
|
||||
addBtn("CloseButton",_loc6_.x,_loc6_.y,onCloseButton);
|
||||
_layerBackground.addChild(_scene.getLayer("background").loader);
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc6_ = _scene.getLayer("buttonLeft");
|
||||
addBtn("arrowPrintL_button",_loc6_.x,_loc6_.y,onButtonLeft);
|
||||
_loc6_ = _scene.getLayer("buttonRight");
|
||||
addBtn("arrowPrintR_button",_loc6_.x,_loc6_.y,onButtonRight);
|
||||
}
|
||||
_loc6_ = _scene.getLayer("buttonCreate");
|
||||
addBtn("createPrint_button",_loc6_.x,_loc6_.y,onButtonPrint);
|
||||
_loc6_ = _scene.getLayer("buttonPrint");
|
||||
_exitConfirmationActive = false;
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("keyDown",keyDown);
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
_layerForeground.addChild(_scene.getLayer("topLayer1").loader);
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_activeImageIndex = 0;
|
||||
_imageIDs = new Array(434,422,394,67,68,88,89,90,2379,2381);
|
||||
_printIDs = new Array(435,423,395,112,113,114,115,116,2380,2382);
|
||||
_printOffsets = new Array(new Point(20,20),new Point(20,20),new Point(20,20),new Point(20,-50),new Point(20,-50),new Point(20,20),new Point(20,20),new Point(20,-50),new Point(20,20),new Point(20,20));
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 89)
|
||||
{
|
||||
case 0:
|
||||
_imageIDs = new Array(1958,1958,1958);
|
||||
_printIDs = new Array(1957,1957,1957);
|
||||
_printOffsets = new Array(new Point(-67,-69));
|
||||
}
|
||||
}
|
||||
loadImage(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadPrintImage() : void
|
||||
{
|
||||
_loadingImage = true;
|
||||
_printMediaHelper = new MediaHelper();
|
||||
_printMediaHelper.init(_printIDs[_activeImageIndex],printImageMediaHandler);
|
||||
}
|
||||
|
||||
private function printImageMediaHandler(param1:MovieClip) : void
|
||||
{
|
||||
_imageToPrint = param1;
|
||||
_loadingImage = false;
|
||||
printOnePerPage();
|
||||
}
|
||||
|
||||
private function loadImage(param1:int) : void
|
||||
{
|
||||
if(!_loadingImage)
|
||||
{
|
||||
if(param1 > 0)
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex + 1;
|
||||
if(_activeImageIndex >= _imageIDs.length)
|
||||
{
|
||||
_activeImageIndex = 0;
|
||||
}
|
||||
}
|
||||
else if(param1 < 0)
|
||||
{
|
||||
_activeImageIndex = _activeImageIndex - 1;
|
||||
if(_activeImageIndex < 0)
|
||||
{
|
||||
_activeImageIndex = _imageIDs.length - 1;
|
||||
}
|
||||
}
|
||||
_loadingImage = true;
|
||||
_printMediaHelper = new MediaHelper();
|
||||
_printMediaHelper.init(_imageIDs[_activeImageIndex],printMediaHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private function printMediaHandler(param1:MovieClip) : void
|
||||
{
|
||||
if(_printImage != null)
|
||||
{
|
||||
_printImage.parent.removeChild(_printImage);
|
||||
}
|
||||
param1.x = 114;
|
||||
param1.y = 104;
|
||||
_printImage = param1;
|
||||
_layerBackground.addChild(_printImage);
|
||||
_layerBackground.addChild(_printBackground.loader);
|
||||
_loadingImage = false;
|
||||
}
|
||||
|
||||
private function keyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(!_loadingImage)
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onButtonPrint();
|
||||
break;
|
||||
case 39:
|
||||
onButtonRight();
|
||||
break;
|
||||
case 37:
|
||||
onButtonLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonLeft() : void
|
||||
{
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
loadImage(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonRight() : void
|
||||
{
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
loadImage(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onButtonPrint() : void
|
||||
{
|
||||
if(!_exitConfirmationActive && !_loadingImage)
|
||||
{
|
||||
loadPrintImage();
|
||||
}
|
||||
}
|
||||
|
||||
private function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(!_exitConfirmationActive)
|
||||
{
|
||||
_exitConfirmationActive = true;
|
||||
_loc1_ = showDlg("ArtStudioPrint_ExitDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitConfirmationActive = false;
|
||||
}
|
||||
|
||||
private function printOnePerPage() : void
|
||||
{
|
||||
var _loc7_:PrintJob = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc3_:Sprite = null;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc9_:BitmapData = null;
|
||||
var _loc12_:Bitmap = null;
|
||||
var _loc10_:Sprite = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
if(_imageToPrint)
|
||||
{
|
||||
stage.removeEventListener("keyDown",keyDown);
|
||||
_loc7_ = new PrintJob();
|
||||
if(_loc7_.start())
|
||||
{
|
||||
_loc5_ = Number(_printBackground.loader.content.scaleX);
|
||||
_loc1_ = Number(_printBackground.loader.content.scaleY);
|
||||
_loc3_ = new Sprite();
|
||||
_imageToPrint.scaleX = 4;
|
||||
_imageToPrint.scaleY = 4;
|
||||
_printBackground.loader.content.scaleX = 4;
|
||||
_printBackground.loader.content.scaleY = 4;
|
||||
_loc3_.addChild(_printBackground.loader.content);
|
||||
_loc3_.addChild(_imageToPrint);
|
||||
_imageToPrint.x = _printOffsets[_activeImageIndex].x;
|
||||
_imageToPrint.y = _printOffsets[_activeImageIndex].y;
|
||||
_loc8_ = _loc3_.width;
|
||||
_loc11_ = _loc3_.height;
|
||||
_loc2_ = 0;
|
||||
_loc9_ = new BitmapData(_loc3_.width + 20,_loc3_.height + 20);
|
||||
_loc9_.draw(_loc3_);
|
||||
_loc12_ = new Bitmap(_loc9_);
|
||||
_loc10_ = new Sprite();
|
||||
_loc10_.addChild(_loc12_);
|
||||
_loc12_.x = 0;
|
||||
_loc12_.y = 0;
|
||||
_loc12_.scaleX = 0.999;
|
||||
_loc12_.scaleY = 0.999;
|
||||
_loc10_.x = 0;
|
||||
_loc10_.y = 0;
|
||||
if(_loc7_.orientation != "landscape")
|
||||
{
|
||||
_loc10_.rotation = 90;
|
||||
_loc10_.x = _loc10_.width;
|
||||
_loc6_ = _loc7_.pageWidth / _loc11_;
|
||||
_loc4_ = _loc7_.pageHeight / _loc8_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = _loc7_.pageWidth / _loc8_;
|
||||
_loc4_ = _loc7_.pageHeight / _loc11_;
|
||||
}
|
||||
_loc10_.scaleX = _loc10_.scaleY = Math.min(_loc6_,_loc4_);
|
||||
_loc10_.visible = false;
|
||||
gMainFrame.stage.addChild(_loc10_);
|
||||
try
|
||||
{
|
||||
_loc7_.addPage(_loc10_,new Rectangle(0,0,_loc8_,_loc11_));
|
||||
_loc2_++;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
trace(e);
|
||||
}
|
||||
gMainFrame.stage.removeChild(_loc10_);
|
||||
_loc10_.visible = true;
|
||||
_loc10_.scaleX = _loc10_.scaleY = 1;
|
||||
_loc10_.rotation = 0;
|
||||
_loc3_.removeChild(_imageToPrint);
|
||||
_printBackground.loader.content.scaleX = _loc5_;
|
||||
_printBackground.loader.content.scaleY = _loc1_;
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_loc7_.send();
|
||||
}
|
||||
}
|
||||
stage.addEventListener("keyDown",keyDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
package game.bradyChemistrySet
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class BradyChemistrySet extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static var SFX_BCS_beaker_bubble_lp:Class;
|
||||
|
||||
public static var SFX_BCS_flame_lp:Class;
|
||||
|
||||
private const _sounds:Array = ["bb_beaker_found_stinger.mp3","bb_bubble_over.mp3","bb_flame_start.mp3","bb_lever_turn.mp3","bb_steam_poof.mp3","bb_steam_sssss.mp3","bb_beaker_rollover.mp3","bb_beaker_Select.mp3"];
|
||||
|
||||
private var _soundNameBeakerFound:String = _sounds[0];
|
||||
|
||||
private var _soundNameBubbleOver:String = _sounds[1];
|
||||
|
||||
private var _soundNameFlameStart:String = _sounds[2];
|
||||
|
||||
private var _soundNameLeverTurn:String = _sounds[3];
|
||||
|
||||
private var _soundNameSteamPoof:String = _sounds[4];
|
||||
|
||||
private var _soundNameSteamSSSSS:String = _sounds[5];
|
||||
|
||||
private var _soundNameBeakerRollover:String = _sounds[6];
|
||||
|
||||
private var _soundNameBeakerSelect:String = _sounds[7];
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _SFX_BCS_beaker_bubble_lp:SoundChannel;
|
||||
|
||||
private var _SFX_BCS_flame_lp:SoundChannel;
|
||||
|
||||
public function BradyChemistrySet()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBeakerFound],_soundNameBeakerFound,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBubbleOver],_soundNameBubbleOver,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlameStart],_soundNameFlameStart,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverTurn],_soundNameLeverTurn,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSteamPoof],_soundNameSteamPoof,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSteamSSSSS],_soundNameSteamSSSSS,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBeakerRollover],_soundNameBeakerRollover,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBeakerSelect],_soundNameBeakerSelect,0.2);
|
||||
_soundMan.addSound(SFX_BCS_beaker_bubble_lp,0.3,"SFX_BCS_beaker_bubble_lp");
|
||||
_soundMan.addSound(SFX_BCS_flame_lp,0.2,"SFX_BCS_flame_lp");
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_SFX_BCS_beaker_bubble_lp)
|
||||
{
|
||||
_SFX_BCS_beaker_bubble_lp.stop();
|
||||
_SFX_BCS_beaker_bubble_lp = null;
|
||||
}
|
||||
if(_SFX_BCS_flame_lp)
|
||||
{
|
||||
_SFX_BCS_flame_lp.stop();
|
||||
_SFX_BCS_flame_lp = null;
|
||||
}
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("BradyChemistrySet/room_main.xroom",_sounds);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
SFX_BCS_beaker_bubble_lp = getDefinitionByName("bb_beaker_bubble_lp") as Class;
|
||||
if(SFX_BCS_beaker_bubble_lp == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:bb_beaker_bubble_lp");
|
||||
}
|
||||
SFX_BCS_flame_lp = getDefinitionByName("bb_flame_lp") as Class;
|
||||
if(SFX_BCS_flame_lp == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:bb_flame_lp");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",761,77,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.beaker_bubble_lp)
|
||||
{
|
||||
if(!_SFX_BCS_beaker_bubble_lp)
|
||||
{
|
||||
_SFX_BCS_beaker_bubble_lp = _soundMan.play(SFX_BCS_beaker_bubble_lp,0,99999);
|
||||
}
|
||||
}
|
||||
else if(_SFX_BCS_beaker_bubble_lp)
|
||||
{
|
||||
_SFX_BCS_beaker_bubble_lp.stop();
|
||||
_SFX_BCS_beaker_bubble_lp = null;
|
||||
}
|
||||
if(_theGame.loader.content.beaker_found_stinger)
|
||||
{
|
||||
_theGame.loader.content.beaker_found_stinger = false;
|
||||
_soundMan.playByName(_soundNameBeakerFound);
|
||||
}
|
||||
if(_theGame.loader.content.bubble_over)
|
||||
{
|
||||
_theGame.loader.content.bubble_over = false;
|
||||
_soundMan.playByName(_soundNameBubbleOver);
|
||||
}
|
||||
if(_theGame.loader.content.flame_start)
|
||||
{
|
||||
_theGame.loader.content.flame_start = false;
|
||||
_soundMan.playByName(_soundNameFlameStart);
|
||||
}
|
||||
if(_theGame.loader.content.lever_turn)
|
||||
{
|
||||
_theGame.loader.content.lever_turn = false;
|
||||
_soundMan.playByName(_soundNameLeverTurn);
|
||||
}
|
||||
if(_theGame.loader.content.steam_poof)
|
||||
{
|
||||
_theGame.loader.content.steam_poof = false;
|
||||
_soundMan.playByName(_soundNameSteamPoof);
|
||||
}
|
||||
if(_theGame.loader.content.steam_sssss)
|
||||
{
|
||||
_theGame.loader.content.steam_sssss = false;
|
||||
_soundMan.playByName(_soundNameSteamSSSSS);
|
||||
}
|
||||
if(_theGame.loader.content.beaker_rollover)
|
||||
{
|
||||
_theGame.loader.content.beaker_rollover = false;
|
||||
_soundMan.playByName(_soundNameBeakerRollover);
|
||||
}
|
||||
if(_theGame.loader.content.beaker_Select)
|
||||
{
|
||||
_theGame.loader.content.beaker_Select = false;
|
||||
_soundMan.playByName(_soundNameBeakerSelect);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(_theGame.loader.content.secretActivated)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
}
|
||||
if(messageServer != null)
|
||||
{
|
||||
messageServer(["_a",6,_theGame.loader.content.emoticonInfo]);
|
||||
}
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,796 @@
|
||||
package game.bradyExpeditions
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import collection.IntItemCollection;
|
||||
import com.sbi.client.KeepAlive;
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import com.sbi.popup.SBLeaveCancelPopup;
|
||||
import com.sbi.popup.SBYesNoPopup;
|
||||
import den.DenItem;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import flash.utils.setTimeout;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GiftPopup;
|
||||
import gui.LoadingSpiral;
|
||||
import gui.WindowGenerator;
|
||||
import gui.itemWindows.ItemWindowChapterSelect;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
import movie.MovieNode;
|
||||
import movie.MovieXtCommManager;
|
||||
import movie.VideoPlayerOSMF;
|
||||
|
||||
public class BradyExpeditions extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
private static const NUM_X_WIN:int = 2;
|
||||
|
||||
private static const NUM_Y_WIN:int = 6;
|
||||
|
||||
private static const X_WIN_OFFSET:int = 0;
|
||||
|
||||
private static const Y_WIN_OFFSET:int = 0;
|
||||
|
||||
private static const X_WIN_START:int = 0;
|
||||
|
||||
public static var CHOICE_SOUND:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _popup:MovieClip;
|
||||
|
||||
private var _soundBtn:MovieClip;
|
||||
|
||||
private var _videoPlayer:VideoPlayerOSMF;
|
||||
|
||||
private var _currMovieNodeDef:MovieNode;
|
||||
|
||||
private var _prevMovieNodeDef:MovieNode;
|
||||
|
||||
private var _mediaHolder:Array;
|
||||
|
||||
private var _iconMediaHolder:Array;
|
||||
|
||||
private var _thumbMediaHolder:Array;
|
||||
|
||||
private var _prizePopup:GiftPopup;
|
||||
|
||||
private var _serialNumber:int;
|
||||
|
||||
private var _loadingSpirals:Object;
|
||||
|
||||
private var _selectionItemWindow:WindowGenerator;
|
||||
|
||||
private var _sceneEvent:Event;
|
||||
|
||||
private var _isSkipping:Boolean;
|
||||
|
||||
private var _baseNodeDefId:int;
|
||||
|
||||
private var _currChoiceHolder:Array;
|
||||
|
||||
private var _randomChoiceHolder:Array;
|
||||
|
||||
private var _prizeDenItem:DenItem;
|
||||
|
||||
private var _wereSoundsMuted:Boolean;
|
||||
|
||||
private var _soundMan:SoundManager;
|
||||
|
||||
private var _CHOICE_SOUND_INSTANCE:SoundChannel;
|
||||
|
||||
public function BradyExpeditions()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
messageServer(["hs"]);
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_wereSoundsMuted)
|
||||
{
|
||||
SBAudio.muteAll();
|
||||
}
|
||||
else if(SBAudio.isMusicMuted)
|
||||
{
|
||||
SBAudio.unmuteAll();
|
||||
}
|
||||
releaseBase();
|
||||
MovieXtCommManager.resetAllChosenChapters(_baseNodeDefId);
|
||||
_bInit = false;
|
||||
removeLayer(_guiLayer);
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
if(_CHOICE_SOUND_INSTANCE)
|
||||
{
|
||||
_soundMan.stop(_CHOICE_SOUND_INSTANCE);
|
||||
_CHOICE_SOUND_INSTANCE = null;
|
||||
_soundMan = null;
|
||||
}
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
_videoPlayer = null;
|
||||
}
|
||||
_loadingSpirals = null;
|
||||
for each(var _loc2_:MediaHelper in _mediaHolder)
|
||||
{
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.destroy();
|
||||
_loc2_ = null;
|
||||
}
|
||||
}
|
||||
removeEventListeners();
|
||||
if(_prizeDenItem)
|
||||
{
|
||||
_prizeDenItem.destroy();
|
||||
}
|
||||
_mediaHolder = null;
|
||||
_iconMediaHolder = null;
|
||||
_thumbMediaHolder = null;
|
||||
_currChoiceHolder = null;
|
||||
_randomChoiceHolder = null;
|
||||
_closeBtn = null;
|
||||
_soundBtn = null;
|
||||
_popup = null;
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "hs")
|
||||
{
|
||||
_serialNumber = parseInt(param1[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_loadingSpirals = {
|
||||
"spiral1":new LoadingSpiral(),
|
||||
"spiral2":new LoadingSpiral(),
|
||||
"spiral3":new LoadingSpiral()
|
||||
};
|
||||
if(!_bInit)
|
||||
{
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_guiLayer);
|
||||
loadScene("BradyExpeditionsAssets/room_main.xroom");
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
_sceneEvent = param1;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(2126,onMediaLoaded,param1);
|
||||
_baseNodeDefId = 1;
|
||||
CHOICE_SOUND = getDefinitionByName("choiceLoop") as Class;
|
||||
if(CHOICE_SOUND == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:choiceLoop");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
_soundMan.addSound(CHOICE_SOUND,0.5,"CHOICE_SOUND");
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_mediaHolder = [];
|
||||
_iconMediaHolder = [];
|
||||
_thumbMediaHolder = [];
|
||||
_currChoiceHolder = [];
|
||||
_randomChoiceHolder = [];
|
||||
_popup = MovieClip(param1.getChildAt(0));
|
||||
_closeBtn = new (param1.loaderInfo.applicationDomain.getDefinition("closeBtn") as Class)();
|
||||
_soundBtn = new (param1.loaderInfo.applicationDomain.getDefinition("soundBtn") as Class)();
|
||||
_wereSoundsMuted = SBAudio.isMusicMuted || SBAudio.areSoundsMuted;
|
||||
SBAudio.unmuteAll();
|
||||
_popup.banner.titleTxt.autoSize = "center";
|
||||
KeepAlive.inputReceivedHandler(null);
|
||||
setupAdventureSelection();
|
||||
_guiLayer.addChild(_popup);
|
||||
super.sceneLoaded(_sceneEvent);
|
||||
}
|
||||
|
||||
private function setupAdventureSelection() : void
|
||||
{
|
||||
if(_CHOICE_SOUND_INSTANCE == null)
|
||||
{
|
||||
_CHOICE_SOUND_INSTANCE = _soundMan.play(CHOICE_SOUND,0,99999);
|
||||
}
|
||||
_popup.bigCloseBtn.addEventListener("mouseDown",onCloseButton,false,0,true);
|
||||
_popup.pythonBtnCont.visible = true;
|
||||
_popup.videoFrame.visible = false;
|
||||
_popup.banner.visible = false;
|
||||
_popup.outsideFrame.visible = false;
|
||||
hideAllWindows();
|
||||
_popup.pythonBtnCont.addEventListener("mouseDown",onPythonDown,false,0,true);
|
||||
}
|
||||
|
||||
private function onPythonDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
param1.currentTarget.removeEventListener("mouseDown",onPythonDown);
|
||||
_popup.pythonBtnCont.visible = false;
|
||||
_popup.bigCloseBtn.removeEventListener("mouseDown",onCloseButton);
|
||||
_popup.bigCloseBtn.visible = false;
|
||||
setupSelectionScreen();
|
||||
}
|
||||
|
||||
private function setupSelectionScreen() : void
|
||||
{
|
||||
var nodes:Array;
|
||||
if(_CHOICE_SOUND_INSTANCE == null)
|
||||
{
|
||||
_CHOICE_SOUND_INSTANCE = _soundMan.play(CHOICE_SOUND,0,99999);
|
||||
}
|
||||
_prevMovieNodeDef = null;
|
||||
nodes = MovieXtCommManager.getAllChapters(_baseNodeDefId);
|
||||
_popup.outsideFrame.chapterTitle.visible = true;
|
||||
_popup.videoFrame.visible = false;
|
||||
_popup.banner.visible = false;
|
||||
_popup.outsideFrame.visible = true;
|
||||
with(_popup.outsideFrame)
|
||||
{
|
||||
while(xBtn2.numChildren > 0)
|
||||
{
|
||||
xBtn2.removeChildAt(0);
|
||||
}
|
||||
xBtn2.addChild(_closeBtn);
|
||||
while(volBtn2.numChildren > 0)
|
||||
{
|
||||
volBtn2.removeChildAt(0);
|
||||
}
|
||||
volBtn2.addChild(_soundBtn);
|
||||
}
|
||||
hideAllWindows();
|
||||
if(_selectionItemWindow)
|
||||
{
|
||||
_selectionItemWindow.destroy();
|
||||
_selectionItemWindow = null;
|
||||
}
|
||||
_selectionItemWindow = new WindowGenerator();
|
||||
_selectionItemWindow.init(2,6,nodes.length,0,0,0,ItemWindowChapterSelect,nodes,"icon",{
|
||||
"mouseDown":chapterSelectDown,
|
||||
"mouseOver":null,
|
||||
"mouseOut":null,
|
||||
"memberOnlyDown":null
|
||||
},{"baseDefId":_baseNodeDefId},onSelectionScreenLoaded,false,false);
|
||||
}
|
||||
|
||||
private function onSelectionScreenLoaded() : void
|
||||
{
|
||||
_popup.chapterWindow.visible = true;
|
||||
while(_popup.chapterWindow.numChildren > 0)
|
||||
{
|
||||
_popup.chapterWindow.removeChildAt(0);
|
||||
}
|
||||
_popup.chapterWindow.addChild(_selectionItemWindow);
|
||||
addEventListeners();
|
||||
}
|
||||
|
||||
private function addEventListeners() : void
|
||||
{
|
||||
_closeBtn.addEventListener("mouseDown",onCloseButton,false,0,true);
|
||||
_soundBtn.addEventListener("mouseDown",onSoundBtn,false,0,true);
|
||||
_popup.videoFrame.addEventListener("mouseDown",onVideoFrame,false,0,true);
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
{
|
||||
_closeBtn.removeEventListener("mouseDown",onCloseButton);
|
||||
_soundBtn.removeEventListener("mouseDown",onSoundBtn);
|
||||
_popup.videoFrame.removeEventListener("mouseDown",onVideoFrame);
|
||||
}
|
||||
|
||||
private function onExit() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function onRetry() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
}
|
||||
|
||||
private function hideAllWindows() : void
|
||||
{
|
||||
_popup.bigWindow1.visible = false;
|
||||
_popup.bigWindow2.visible = false;
|
||||
_popup.smWindow1.visible = false;
|
||||
_popup.smWindow2.visible = false;
|
||||
_popup.smWindow3.visible = false;
|
||||
_popup.chapterWindow.visible = false;
|
||||
}
|
||||
|
||||
private function onMovieFinish() : void
|
||||
{
|
||||
var _loc1_:MovieNode = null;
|
||||
KeepAlive.inputReceivedHandler(null);
|
||||
if(_isSkipping)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_currMovieNodeDef.denRewardId != 0)
|
||||
{
|
||||
_loc1_ = _currMovieNodeDef.isChapter ? _currMovieNodeDef : _prevMovieNodeDef;
|
||||
if(!gMainFrame.userInfo.userVarCache.isBitSet(_loc1_.userVarId,_loc1_.bitIndex))
|
||||
{
|
||||
_prizeDenItem = new DenItem();
|
||||
_prizeDenItem.initShopItem(_currMovieNodeDef.denRewardId,0,true);
|
||||
_prizePopup = new GiftPopup();
|
||||
_prizePopup.init(this.parent,_prizeDenItem.icon,_prizeDenItem.name,_prizeDenItem.defId,2,2,keptItem,rejectedItem,destroyPrizePopup);
|
||||
return;
|
||||
}
|
||||
}
|
||||
showChooseScreen();
|
||||
}
|
||||
|
||||
private function keptItem() : void
|
||||
{
|
||||
var _loc1_:Number = (gMainFrame.server.userId + 99) * 3 + (_serialNumber + 49) * 5 + (_currMovieNodeDef.defId + _serialNumber + 24);
|
||||
var _loc2_:Number = (_serialNumber + gMainFrame.server.userId) * 3;
|
||||
messageServer(["hp",_loc1_,_loc2_,_prizeDenItem.version]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function rejectedItem() : void
|
||||
{
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function destroyPrizePopup() : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
showChooseScreen();
|
||||
}
|
||||
|
||||
private function showChooseScreen() : void
|
||||
{
|
||||
var shuffle:Boolean;
|
||||
var i:int;
|
||||
if(_currMovieNodeDef && _currMovieNodeDef.numChoices > 0)
|
||||
{
|
||||
with(_popup.outsideFrame)
|
||||
{
|
||||
|
||||
while(xBtn2.numChildren > 0)
|
||||
{
|
||||
xBtn2.removeChildAt(0);
|
||||
}
|
||||
xBtn2.addChild(_closeBtn);
|
||||
while(volBtn2.numChildren > 0)
|
||||
{
|
||||
volBtn2.removeChildAt(0);
|
||||
}
|
||||
volBtn2.addChild(_soundBtn);
|
||||
}
|
||||
_popup.videoFrame.visible = false;
|
||||
_popup.outsideFrame.visible = true;
|
||||
hideAllWindows();
|
||||
if(_prevMovieNodeDef && (_currMovieNodeDef.choice1Id == _prevMovieNodeDef.defId || _currMovieNodeDef.choice2Id == _prevMovieNodeDef.defId || _currMovieNodeDef.choice3Id == _prevMovieNodeDef.defId))
|
||||
{
|
||||
_currMovieNodeDef.hasChosenThisChoice = true;
|
||||
_currMovieNodeDef = _prevMovieNodeDef;
|
||||
}
|
||||
else
|
||||
{
|
||||
_randomChoiceHolder = [];
|
||||
shuffle = true;
|
||||
}
|
||||
if(_currMovieNodeDef.numChoices == 1)
|
||||
{
|
||||
if(_currMovieNodeDef.isChapter)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(_currMovieNodeDef.userVarId,_currMovieNodeDef.bitIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(_prevMovieNodeDef.userVarId,_prevMovieNodeDef.bitIndex);
|
||||
}
|
||||
onChoiceDown(null);
|
||||
return;
|
||||
}
|
||||
if(_CHOICE_SOUND_INSTANCE == null)
|
||||
{
|
||||
_CHOICE_SOUND_INSTANCE = _soundMan.play(CHOICE_SOUND,0,99999);
|
||||
}
|
||||
setAndSizeTitleTxt(LocalizationManager.translateIdOnly(_currMovieNodeDef.titleId).split("|")[1]);
|
||||
i = 1;
|
||||
while(i <= _currMovieNodeDef.numChoices)
|
||||
{
|
||||
if(_currMovieNodeDef.numChoices > 2)
|
||||
{
|
||||
_loadingSpirals["spiral" + i].setNewParent(_popup["smWindow" + i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadingSpirals["spiral" + i].setNewParent(_popup["bigWindow" + i]);
|
||||
}
|
||||
_loadingSpirals["spiral" + i].visible = true;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHolder[i] = _mediaHelper;
|
||||
_mediaHelper.init(MovieXtCommManager.getMovieDef(_currMovieNodeDef.getChoiceById(i)).mediaId,onChoicesLoaded,{
|
||||
"index":i,
|
||||
"shuffle":shuffle
|
||||
});
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_currMovieNodeDef)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(_currMovieNodeDef.userVarId,_currMovieNodeDef.bitIndex);
|
||||
}
|
||||
_popup.parent.parent.x = 450;
|
||||
_popup.parent.parent.y = 275;
|
||||
new SBYesNoPopup(_guiLayer,LocalizationManager.translateIdOnly(11132),true,onReplayConfirm);
|
||||
_popup.parent.parent.x = 0;
|
||||
_popup.parent.parent.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function onChoicesLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:MovieClip = MovieClip(param1.getChildAt(0));
|
||||
_currChoiceHolder.push(_loc2_);
|
||||
if(MovieXtCommManager.getMovieNodeFromTree(_baseNodeDefId,_currMovieNodeDef.getChoiceById(param1.passback.index)).hasChosenThisChoice)
|
||||
{
|
||||
_loc2_.filters = [new ColorMatrixFilter([0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0,0,0,1,0])];
|
||||
}
|
||||
_loc2_.addEventListener("mouseDown",onChoiceDown,false,0,true);
|
||||
_loc2_.nextNodeId = _currMovieNodeDef.getChoiceById(param1.passback.index);
|
||||
_loc2_.windowIndex = param1.passback.index;
|
||||
_loc2_.txt.text = "";
|
||||
_mediaHelper = new MediaHelper();
|
||||
_iconMediaHolder[param1.passback.index] = _mediaHelper;
|
||||
_mediaHelper.init(MovieXtCommManager.getMovieDef(_loc2_.nextNodeId).iconMediaId,onIconsLoaded,_loc2_);
|
||||
_mediaHelper = new MediaHelper();
|
||||
_thumbMediaHolder[param1.passback.index] = _mediaHelper;
|
||||
_mediaHelper.init(MovieXtCommManager.getMovieDef(_loc2_.nextNodeId).thumbMediaId,onThumbsLoaded,_loc2_);
|
||||
onChoicesLocalization(LocalizationManager.translateIdOnly(MovieXtCommManager.getMovieDef(_loc2_.nextNodeId).titleId),{
|
||||
"currChoice":_loc2_,
|
||||
"shuffle":param1.passback.shuffle
|
||||
});
|
||||
if(_mediaHolder[param1.passback.index])
|
||||
{
|
||||
_mediaHolder[param1.passback.index].destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private function onIconsLoaded(param1:MovieClip) : void
|
||||
{
|
||||
param1.passback.iconWindow.addChild(MovieClip(param1.getChildAt(0)));
|
||||
_iconMediaHolder[param1.passback.windowIndex].destroy();
|
||||
}
|
||||
|
||||
private function onThumbsLoaded(param1:MovieClip) : void
|
||||
{
|
||||
param1.passback.thumbItemWindow.addChild(MovieClip(param1.getChildAt(0)));
|
||||
_thumbMediaHolder[param1.passback.windowIndex].destroy();
|
||||
}
|
||||
|
||||
private function onChoicesLocalization(param1:String, param2:Object) : void
|
||||
{
|
||||
var _loc4_:MovieClip = null;
|
||||
var _loc3_:int = 0;
|
||||
LocalizationManager.updateToFit(param2.currChoice.txt,param1.split("|")[0]);
|
||||
_loadingSpirals["spiral" + param2.currChoice.windowIndex].visible = false;
|
||||
var _loc5_:int = int(param2.shuffle ? Math.floor(Math.random() * (_currMovieNodeDef.numChoices - 1 + 1)) + 1 : _randomChoiceHolder[param2.currChoice.windowIndex]);
|
||||
if(param2.shuffle)
|
||||
{
|
||||
if(_randomChoiceHolder[param2.currChoice.windowIndex] == null)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _randomChoiceHolder.length)
|
||||
{
|
||||
if(_randomChoiceHolder[_loc3_] == _loc5_)
|
||||
{
|
||||
onChoicesLocalization(param1,param2);
|
||||
return;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
_randomChoiceHolder[param2.currChoice.windowIndex] = _loc5_;
|
||||
}
|
||||
if(_currMovieNodeDef.numChoices > 2)
|
||||
{
|
||||
_loc4_ = _popup["smWindow" + _loc5_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = _popup["bigWindow" + _loc5_];
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.visible = true;
|
||||
while(_loc4_.numChildren > 0)
|
||||
{
|
||||
_loc4_.removeChildAt(0);
|
||||
}
|
||||
_loc4_.addChild(MovieClip(param2.currChoice));
|
||||
}
|
||||
_mediaHolder[param2.currChoice.windowIndex] = null;
|
||||
}
|
||||
|
||||
private function setupStreamLocalization(param1:String, param2:Boolean) : void
|
||||
{
|
||||
var streamCollection:IntItemCollection;
|
||||
var subtitleCollection:IntItemCollection;
|
||||
var text:String = param1;
|
||||
var showTextOnly:Boolean = param2;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(showTextOnly)
|
||||
{
|
||||
setAndSizeTitleTxt(text);
|
||||
return;
|
||||
}
|
||||
if(_CHOICE_SOUND_INSTANCE)
|
||||
{
|
||||
_soundMan.stop(_CHOICE_SOUND_INSTANCE);
|
||||
_CHOICE_SOUND_INSTANCE = null;
|
||||
}
|
||||
streamCollection = new IntItemCollection();
|
||||
streamCollection.pushIntItem(_currMovieNodeDef.streamId);
|
||||
subtitleCollection = new IntItemCollection();
|
||||
subtitleCollection.pushIntItem(_currMovieNodeDef.subtitleId);
|
||||
_videoPlayer.init(streamCollection,subtitleCollection,["BradyExpeditions|" + text],-1,-1,false,768,432,onMovieFinish);
|
||||
setAndSizeTitleTxt(text);
|
||||
_popup.videoFrame.visible = true;
|
||||
_popup.outsideFrame.visible = false;
|
||||
with(_popup.videoFrame)
|
||||
{
|
||||
while(xBtn1.numChildren > 0)
|
||||
{
|
||||
xBtn1.removeChildAt(0);
|
||||
}
|
||||
xBtn1.addChild(_closeBtn);
|
||||
while(volBtn1.numChildren > 0)
|
||||
{
|
||||
volBtn1.removeChildAt(0);
|
||||
}
|
||||
volBtn1.addChild(_soundBtn);
|
||||
}
|
||||
}
|
||||
|
||||
private function onchoicesTitleLocalizationReceived(param1:int, param2:String) : void
|
||||
{
|
||||
param2 = param2.split("|")[1];
|
||||
setAndSizeTitleTxt(param2);
|
||||
}
|
||||
|
||||
private function setAndSizeTitleTxt(param1:String) : void
|
||||
{
|
||||
var text:String = param1;
|
||||
_popup.banner.visible = true;
|
||||
_popup.banner.titleTxt.text = text;
|
||||
with(_popup.banner)
|
||||
{
|
||||
m.width = Math.floor(titleTxt.width);
|
||||
l.x = titleTxt.x - (l.width - 5);
|
||||
m.x = Math.floor(l.x + l.width);
|
||||
r.x = m.x + m.width;
|
||||
}
|
||||
}
|
||||
|
||||
private function chapterSelectDown(param1:MouseEvent) : void
|
||||
{
|
||||
var evt:MouseEvent = param1;
|
||||
evt.stopPropagation();
|
||||
if(evt.currentTarget.isGray)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
}
|
||||
_popup.chapterWindow.visible = false;
|
||||
_videoPlayer = new VideoPlayerOSMF();
|
||||
_popup.outsideFrame.visible = false;
|
||||
_popup.outsideFrame.chapterTitle.visible = false;
|
||||
_popup.videoFrame.visible = true;
|
||||
_selectionItemWindow.destroy();
|
||||
with(_popup.videoFrame)
|
||||
{
|
||||
while(xBtn1.numChildren > 0)
|
||||
{
|
||||
xBtn1.removeChildAt(0);
|
||||
}
|
||||
xBtn1.addChild(_closeBtn);
|
||||
while(volBtn1.numChildren > 0)
|
||||
{
|
||||
volBtn1.removeChildAt(0);
|
||||
}
|
||||
volBtn1.addChild(_soundBtn);
|
||||
}
|
||||
_popup.videoFrame.addChild(_videoPlayer);
|
||||
_popup.videoFrame.addEventListener("mouseDown",onVideoFrame,false,0,true);
|
||||
_currMovieNodeDef = evt.currentTarget.getMovieNodeDef();
|
||||
setupStreamLocalization(LocalizationManager.translateIdOnly(_currMovieNodeDef.streamTitleId),false);
|
||||
}
|
||||
|
||||
private function onChoiceDown(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc3_:MovieClip = null;
|
||||
var _loc2_:int = 0;
|
||||
KeepAlive.inputReceivedHandler(null);
|
||||
if(param1)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_prevMovieNodeDef = _currMovieNodeDef;
|
||||
_currMovieNodeDef = MovieXtCommManager.getMovieNodeFromTree(_baseNodeDefId,param1 != null ? param1.currentTarget.nextNodeId : _currMovieNodeDef.choice1Id);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _currChoiceHolder.length)
|
||||
{
|
||||
_loc3_ = _currChoiceHolder[_loc2_];
|
||||
_loc3_.removeEventListener("mouseDown",onChoiceDown);
|
||||
_loc3_ = null;
|
||||
_currChoiceHolder.splice(_loc2_,1);
|
||||
_loc2_--;
|
||||
_loc2_++;
|
||||
}
|
||||
hideAllWindows();
|
||||
setTimeout(setupStreamLocalization,41.666666666666664,LocalizationManager.translateIdOnly(_currMovieNodeDef.streamTitleId),false);
|
||||
}
|
||||
|
||||
private function onSoundBtn(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = null;
|
||||
param1.stopPropagation();
|
||||
SBAudio.toggleMuteAll();
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.toggleSound();
|
||||
}
|
||||
if(_CHOICE_SOUND_INSTANCE)
|
||||
{
|
||||
_loc2_ = _CHOICE_SOUND_INSTANCE.soundTransform;
|
||||
_loc2_.volume = SBAudio.areSoundsMuted ? 0 : 0.5;
|
||||
_CHOICE_SOUND_INSTANCE.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
private function onVideoFrame(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
private function onCloseButton(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_popup.chapterWindow.visible || _popup.pythonBtnCont.visible)
|
||||
{
|
||||
_popup.parent.parent.x = 450;
|
||||
_popup.parent.parent.y = 275;
|
||||
new SBLeaveCancelPopup(_guiLayer,LocalizationManager.translateIdOnly(11133),true,onConfirmClose);
|
||||
_popup.parent.parent.x = 0;
|
||||
_popup.parent.parent.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
}
|
||||
setupSelectionScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private function onReplayConfirm(param1:Object) : void
|
||||
{
|
||||
if(param1.status)
|
||||
{
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
}
|
||||
setupAdventureSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onConfirmClose(param1:Object) : void
|
||||
{
|
||||
if(param1.status)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package game.candyCatcher
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class CandyCatchObject
|
||||
{
|
||||
|
||||
public static const CANDYTYPE_CANDY:int = 0;
|
||||
|
||||
public static const CANDYTYPE_TRASH:int = 1;
|
||||
|
||||
public static const CANDYTYPE_GOLD:int = 2;
|
||||
|
||||
private var MIN_FALL_SPEED:int = 50;
|
||||
|
||||
private var MAX_FALL_SPEED:int = 175;
|
||||
|
||||
public var _candy:MovieClip;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _fallSpeed:Number;
|
||||
|
||||
public function CandyCatchObject(param1:int, param2:int, param3:int, param4:Sprite)
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
super();
|
||||
_candy = GETDEFINITIONBYNAME("candyCatch_object");
|
||||
_type = param1;
|
||||
switch(_type - 1)
|
||||
{
|
||||
case 0:
|
||||
_loc5_ = Math.random() * 5 + 1;
|
||||
_candy.gotoAndStop("trash" + _loc5_);
|
||||
MIN_FALL_SPEED = 350;
|
||||
MAX_FALL_SPEED = 500;
|
||||
break;
|
||||
case 1:
|
||||
_candy.gotoAndStop("gold");
|
||||
MIN_FALL_SPEED = 300;
|
||||
MAX_FALL_SPEED = 500;
|
||||
break;
|
||||
default:
|
||||
_loc5_ = Math.random() * 5 + 1;
|
||||
_candy.gotoAndStop("candy" + _loc5_);
|
||||
MIN_FALL_SPEED = 200;
|
||||
MAX_FALL_SPEED = 500;
|
||||
}
|
||||
_candy.x = param2 + Math.random() * (param3 - param2);
|
||||
_candy.y = -_candy.height;
|
||||
_fallSpeed = MIN_FALL_SPEED + Math.random() * (MAX_FALL_SPEED - MIN_FALL_SPEED);
|
||||
param4.addChild(_candy);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(_candy != null)
|
||||
{
|
||||
if(_candy.parent != null)
|
||||
{
|
||||
_candy.parent.removeChild(_candy);
|
||||
}
|
||||
_candy = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : Boolean
|
||||
{
|
||||
_candy.rotation += 10 * _fallSpeed / MAX_FALL_SPEED;
|
||||
_candy.y += _fallSpeed * param1;
|
||||
if(_candy.y >= 550 + _candy.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,724 @@
|
||||
package game.candyCatcher
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
|
||||
public class CandyCatcher extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
private static const MAX_TIMER_FRAME:int = 275;
|
||||
|
||||
private static const MIN_TIMER_FRAME:int = 1;
|
||||
|
||||
private static const GAME_TIME:int = 45;
|
||||
|
||||
private static const SCORE_BASE:int = 10;
|
||||
|
||||
private static const SCORE_INCREMENT:int = 10;
|
||||
|
||||
private static const TRASH_APPEARS_MIN:int = 2;
|
||||
|
||||
private static const TRASH_APPEARS_MAX:int = 4;
|
||||
|
||||
private static const GOLD_APPEARS_MIN:int = 20;
|
||||
|
||||
private static const GOLD_APPEARS_MAX:int = 20;
|
||||
|
||||
private static const SPAWN_DELAY:Number = 0.3;
|
||||
|
||||
private static const SPAWN_DECREMENT:Number = 0.01;
|
||||
|
||||
private static const MIN_SPAWN_DELAY:Number = 0.15;
|
||||
|
||||
private static const EDGE_MIN_X:int = 173;
|
||||
|
||||
private static const EDGE_MAX_X:int = 723;
|
||||
|
||||
private static const CANDY_EDGE_MIN_X:int = 228;
|
||||
|
||||
private static const CANDY_EDGE_MAX_X:int = 668;
|
||||
|
||||
public static var SFX_cc_candyGoldLP:Class;
|
||||
|
||||
public static var SFX_aj_tickets:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _ticketsWon:int;
|
||||
|
||||
public var _serialNumber1:int;
|
||||
|
||||
public var _serialNumber2:int;
|
||||
|
||||
public var _candy:Array;
|
||||
|
||||
private var _scorePopups:Array;
|
||||
|
||||
private var _scorePopupIndex:int;
|
||||
|
||||
public var _gameTimer:Number;
|
||||
|
||||
public var _candySpawnTimer:Number;
|
||||
|
||||
public var _candySpawnDelay:Number;
|
||||
|
||||
public var _nextTrash:int;
|
||||
|
||||
public var _nextGold:int;
|
||||
|
||||
public var _gameOver:Boolean;
|
||||
|
||||
public var _missed:int;
|
||||
|
||||
public var _score:int;
|
||||
|
||||
public var _scoreCounter:int;
|
||||
|
||||
public var _scoreMultiplier:int;
|
||||
|
||||
public var _highScore:int;
|
||||
|
||||
public var _debugSliders:Array;
|
||||
|
||||
public var _DebugMinSpeeds:Array;
|
||||
|
||||
public var _DebugMaxSpeeds:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _enterSounds:Array;
|
||||
|
||||
public var _resultsDlg:MovieClip;
|
||||
|
||||
public var _instructionsPopup:MovieClip;
|
||||
|
||||
public var _showInstructions:Boolean;
|
||||
|
||||
private const _sounds:Array = ["cc_GameOver.mp3","cc_TrashCaught.mp3","cc_candyCaught.mp3","cc_candyCaughtGold.mp3","cc_candyEnter1.mp3","cc_candyEnter2.mp3","cc_redFlash.mp3"];
|
||||
|
||||
private var _soundNameGameOver:String = _sounds[0];
|
||||
|
||||
private var _soundNameTrashCaught:String = _sounds[1];
|
||||
|
||||
private var _soundNameCandyCaught:String = _sounds[2];
|
||||
|
||||
private var _soundNameCandyCaughtGold:String = _sounds[3];
|
||||
|
||||
private var _soundNameCandyEnter1:String = _sounds[4];
|
||||
|
||||
private var _soundNameCandyEnter2:String = _sounds[5];
|
||||
|
||||
private var _soundNameRedFlash:String = _sounds[6];
|
||||
|
||||
private var _SFX_cc_candyGoldLP_Instance:SoundChannel;
|
||||
|
||||
private var _SFX_aj_tickets_Instance:SoundChannel;
|
||||
|
||||
public function CandyCatcher()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_enterSounds = new Array(_soundNameCandyEnter1,_soundNameCandyEnter2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGameOver],_soundNameGameOver,0.59);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTrashCaught],_soundNameTrashCaught,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCandyCaught],_soundNameCandyCaught,0.44);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCandyCaughtGold],_soundNameCandyCaughtGold,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCandyEnter1],_soundNameCandyEnter1,0.12);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCandyEnter2],_soundNameCandyEnter2,0.13);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedFlash],_soundNameRedFlash,0.67);
|
||||
_soundMan.addSound(SFX_cc_candyGoldLP,0.55,"SFX_cc_candyGoldLP");
|
||||
_soundMan.addSound(SFX_aj_tickets,0.15,"SFX_aj_tickets");
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
if(_SFX_cc_candyGoldLP_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_cc_candyGoldLP_Instance);
|
||||
_SFX_cc_candyGoldLP_Instance = null;
|
||||
}
|
||||
resetGame();
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",onInstructionsKeyDown);
|
||||
stage.removeEventListener("keyDown",onCarnPlayKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
_gameOver = true;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
_candy = [];
|
||||
loadScene("CandyCatcher/room_main.xroom",_sounds);
|
||||
_bInit = true;
|
||||
}
|
||||
else if(_sceneLoaded)
|
||||
{
|
||||
_loc1_ = showDlg("carnival_play",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
}
|
||||
|
||||
private function onCarnPlayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onStart_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onStart_No();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
var _loc3_:MovieClip = null;
|
||||
SFX_cc_candyGoldLP = getDefinitionByName("cc_candyGoldLP") as Class;
|
||||
if(SFX_cc_candyGoldLP == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:cc_candyGoldLP");
|
||||
}
|
||||
SFX_aj_tickets = getDefinitionByName("aj_tickets") as Class;
|
||||
if(SFX_aj_tickets == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:aj_tickets");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc5_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc5_.x,_loc5_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
_scorePopups = [];
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 1)
|
||||
{
|
||||
_loc3_ = GETDEFINITIONBYNAME("candyCatch_scorePopup");
|
||||
_scorePopups.push(_loc3_);
|
||||
_loc3_.mouseEnabled = false;
|
||||
_loc3_.mouseChildren = false;
|
||||
_guiLayer.addChild(_loc3_);
|
||||
_loc4_++;
|
||||
}
|
||||
_scorePopupIndex = 0;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
_gameOver = true;
|
||||
_highScore = Math.max(gMainFrame.userInfo.userVarCache.getUserVarValueById(336),0);
|
||||
_theGame.loader.content.scoreText.text = "";
|
||||
_theGame.loader.content.highScoreText.text = _highScore.toString();
|
||||
_showInstructions = true;
|
||||
_loc3_ = showDlg("carnival_play",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:MovieClip = null;
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc3_ + 1];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "pz")
|
||||
{
|
||||
_serialNumber1 = (parseInt(param1[3]) + 7) / 3 - 5;
|
||||
}
|
||||
else if(param1[2] == "pg")
|
||||
{
|
||||
if(parseInt(param1[3]) == 1)
|
||||
{
|
||||
_serialNumber2 = (parseInt(param1[4]) + 7) / 3 - 5;
|
||||
if(_showInstructions)
|
||||
{
|
||||
_instructionsPopup = showDlg("carnival_candyInstructions",[{
|
||||
"name":"x_btn",
|
||||
"f":onInstructions
|
||||
}]);
|
||||
_instructionsPopup.x = 450;
|
||||
_instructionsPopup.y = 275;
|
||||
stage.addEventListener("keyDown",onInstructionsKeyDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = showDlg("carnival_lowGems",[{
|
||||
"name":"exitButton",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "gr")
|
||||
{
|
||||
_ticketsWon = parseInt(param1[3]);
|
||||
showResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onInstructionsKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onInstructions();
|
||||
}
|
||||
}
|
||||
|
||||
private function showResults() : void
|
||||
{
|
||||
_resultsDlg = showDlg("carnival_results",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_resultsDlg.ticketCounter.earnTickets(_ticketsWon);
|
||||
_resultsDlg.messageText.text = _ticketsWon;
|
||||
_resultsDlg.x = 450;
|
||||
_resultsDlg.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.timer.flashingOff();
|
||||
_gameOver = false;
|
||||
_missed = 0;
|
||||
_nextTrash = 4;
|
||||
_nextGold = 20 + Math.random() * (20 - 20);
|
||||
_candySpawnTimer = 0.3 / 2;
|
||||
_candySpawnDelay = 0.3;
|
||||
_gameTimer = 45;
|
||||
_scoreCounter = 10;
|
||||
_scoreMultiplier = 1;
|
||||
_score = 0;
|
||||
_theGame.loader.content.scoreText.text = _score;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
while(_candy.length > 0)
|
||||
{
|
||||
_candy[0].destroy();
|
||||
_candy.splice(0,1);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc10_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc12_:Boolean = false;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc11_:int = 0;
|
||||
var _loc14_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_resultsDlg != null)
|
||||
{
|
||||
if(_resultsDlg.ticketCounter.ticketState == 0)
|
||||
{
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
}
|
||||
else if(_SFX_aj_tickets_Instance == null)
|
||||
{
|
||||
_SFX_aj_tickets_Instance = _soundMan.play(SFX_aj_tickets,0,99999);
|
||||
}
|
||||
}
|
||||
if(_sceneLoaded && _pauseGame == false && _instructionsPopup == null)
|
||||
{
|
||||
if(_gameOver == false)
|
||||
{
|
||||
_loc3_ = _theGame.loader.content.bucket.x + _theGame.loader.content.bucket.bucketCollision.x;
|
||||
_loc4_ = _theGame.loader.content.bucket.y + _theGame.loader.content.bucket.bucketCollision.y;
|
||||
_loc7_ = _candy.length - 1;
|
||||
while(_loc7_ >= 0)
|
||||
{
|
||||
if(_candy[_loc7_].heartbeat(_frameTime))
|
||||
{
|
||||
if(_candy[_loc7_]._type == 2)
|
||||
{
|
||||
if(_SFX_cc_candyGoldLP_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_cc_candyGoldLP_Instance);
|
||||
_SFX_cc_candyGoldLP_Instance = null;
|
||||
}
|
||||
}
|
||||
_candy[_loc7_].destroy();
|
||||
_candy.splice(_loc7_,1);
|
||||
}
|
||||
else if(_candy[_loc7_]._candy.y >= _loc4_)
|
||||
{
|
||||
if(_candy[_loc7_]._candy.x > _loc3_ && _candy[_loc7_]._candy.x < _loc3_ + _theGame.loader.content.bucket.bucketCollision.width)
|
||||
{
|
||||
_theGame.loader.content.catchType(_candy[_loc7_]._type,_candy[_loc7_]._candy.whichColor);
|
||||
switch(_candy[_loc7_]._type)
|
||||
{
|
||||
case 0:
|
||||
_soundMan.playByName(_soundNameCandyCaught);
|
||||
doScorePopup(_theGame.loader.content.bucket.x,_loc4_,_scoreCounter);
|
||||
_score += _scoreCounter * _scoreMultiplier;
|
||||
_scoreCounter += 10;
|
||||
break;
|
||||
case 2:
|
||||
if(_SFX_cc_candyGoldLP_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_cc_candyGoldLP_Instance);
|
||||
_SFX_cc_candyGoldLP_Instance = null;
|
||||
}
|
||||
_soundMan.playByName(_soundNameCandyCaughtGold);
|
||||
_scoreMultiplier = _scoreMultiplier + 1;
|
||||
doScorePopup(_theGame.loader.content.bucket.x,_loc4_,_scoreCounter);
|
||||
_score += _scoreCounter * _scoreMultiplier;
|
||||
_scoreCounter += 10;
|
||||
break;
|
||||
case 1:
|
||||
_soundMan.playByName(_soundNameTrashCaught);
|
||||
_scoreMultiplier = 1;
|
||||
_scoreCounter = 10;
|
||||
_missed = _missed + 1;
|
||||
}
|
||||
_theGame.loader.content.scoreText.text = _score;
|
||||
_candy[_loc7_].destroy();
|
||||
_candy.splice(_loc7_,1);
|
||||
}
|
||||
}
|
||||
_loc7_--;
|
||||
}
|
||||
_loc12_ = stage.mouseX < _theGame.loader.content.bucket.x;
|
||||
_theGame.loader.content.bucket.x = stage.mouseX;
|
||||
if(_theGame.loader.content.bucket.x < 173)
|
||||
{
|
||||
_theGame.loader.content.bucket.x = 173;
|
||||
}
|
||||
else if(_theGame.loader.content.bucket.x > 723)
|
||||
{
|
||||
_theGame.loader.content.bucket.x = 723;
|
||||
}
|
||||
_loc3_ = _theGame.loader.content.bucket.x + _theGame.loader.content.bucket.bucketCollision.x;
|
||||
_loc4_ = _theGame.loader.content.bucket.y + _theGame.loader.content.bucket.bucketCollision.y;
|
||||
_loc7_ = _candy.length - 1;
|
||||
while(_loc7_ >= 0)
|
||||
{
|
||||
if(_candy[_loc7_]._candy.y >= _loc4_)
|
||||
{
|
||||
if(_candy[_loc7_]._candy.x > _loc3_ && _candy[_loc7_]._candy.x < _loc3_ + _theGame.loader.content.bucket.bucketCollision.width)
|
||||
{
|
||||
if(_loc12_)
|
||||
{
|
||||
_candy[_loc7_]._candy.x = _loc3_ - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_candy[_loc7_]._candy.x = _loc3_ + _theGame.loader.content.bucket.bucketCollision.width + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc7_--;
|
||||
}
|
||||
_loc5_ = _gameTimer;
|
||||
_gameTimer -= _frameTime;
|
||||
if(_gameTimer <= 10)
|
||||
{
|
||||
if(_loc5_ > 10)
|
||||
{
|
||||
_theGame.loader.content.timer.flashingOn();
|
||||
}
|
||||
if(_theGame.loader.content.timer.flashRed == true)
|
||||
{
|
||||
_theGame.loader.content.timer.flashRed = false;
|
||||
_soundMan.playByName(_soundNameRedFlash);
|
||||
}
|
||||
}
|
||||
if(_gameTimer <= 0)
|
||||
{
|
||||
if(_candy.length <= 0)
|
||||
{
|
||||
if(_SFX_cc_candyGoldLP_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_cc_candyGoldLP_Instance);
|
||||
_SFX_cc_candyGoldLP_Instance = null;
|
||||
}
|
||||
_theGame.loader.content.timer.flashingOff();
|
||||
_theGame.loader.content.timer.timerMask.gotoAndStop(1);
|
||||
_soundMan.playByName(_soundNameGameOver);
|
||||
_gameOver = true;
|
||||
if(_score > _highScore)
|
||||
{
|
||||
_highScore = _score;
|
||||
AchievementXtCommManager.requestSetUserVar(336,_highScore);
|
||||
_theGame.loader.content.highScoreText.text = _highScore.toString();
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc11_ = (_score + 29) * 7 + (_serialNumber1 + 49) * 5;
|
||||
_loc14_ = (_score + 49) * 3 + (_serialNumber2 + 83) * 5;
|
||||
_loc6_ = (_serialNumber1 + _score) * 3 + _score * 3;
|
||||
_loc2_[0] = "gr";
|
||||
_loc2_[1] = _loc11_;
|
||||
_loc2_[2] = _loc14_;
|
||||
_loc2_[3] = _loc6_;
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_ = (275 - 1) * ((45 - _gameTimer) / 45);
|
||||
_theGame.loader.content.timer.timerMask.gotoAndStop(_loc9_);
|
||||
_candySpawnTimer -= _frameTime;
|
||||
if(_candySpawnTimer <= 0)
|
||||
{
|
||||
_nextTrash = _nextTrash - 1;
|
||||
_nextGold = _nextGold - 1;
|
||||
if(_nextTrash <= 0 && _gameTimer <= 45 - 5)
|
||||
{
|
||||
_nextTrash = 2 + Math.random() * (4 - 2);
|
||||
_loc8_ = 1;
|
||||
}
|
||||
else if(_nextGold <= 0)
|
||||
{
|
||||
_nextGold = 20 + Math.random() * (20 - 20);
|
||||
_loc8_ = 2;
|
||||
if(_SFX_cc_candyGoldLP_Instance == null)
|
||||
{
|
||||
_SFX_cc_candyGoldLP_Instance = _soundMan.play(SFX_cc_candyGoldLP,0,99999);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = 0;
|
||||
}
|
||||
_loc13_ = Math.random() * _enterSounds.length;
|
||||
_soundMan.playByName(_enterSounds[_loc13_]);
|
||||
_candy.push(new CandyCatchObject(_loc8_,228,668,_theGame.loader.content.candyContainer));
|
||||
_candySpawnTimer = _candySpawnDelay;
|
||||
_candySpawnDelay -= 0.01;
|
||||
if(_candySpawnDelay < 0.15)
|
||||
{
|
||||
_candySpawnDelay = 0.15;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function doScorePopup(param1:Number, param2:Number, param3:int) : void
|
||||
{
|
||||
if(_scoreMultiplier > 1)
|
||||
{
|
||||
_scorePopups[_scorePopupIndex].combo.gotoAndStop("multi");
|
||||
_scorePopups[_scorePopupIndex].combo.comboMult.text = "x " + _scoreMultiplier.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_scorePopups[_scorePopupIndex].combo.gotoAndStop("single");
|
||||
}
|
||||
_scorePopups[_scorePopupIndex].combo.comboNum.text = param3.toString();
|
||||
_scorePopups[_scorePopupIndex].x = param1;
|
||||
_scorePopups[_scorePopupIndex].y = param2;
|
||||
_scorePopups[_scorePopupIndex].gotoAndPlay("on");
|
||||
_scorePopupIndex = _scorePopupIndex + 1;
|
||||
if(_scorePopupIndex >= _scorePopups.length)
|
||||
{
|
||||
_scorePopupIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("carnival_leaveGame",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function onStart_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onCarnPlayKeyDown);
|
||||
_resultsDlg = null;
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
hideDlg();
|
||||
var _loc1_:Array = [];
|
||||
_loc1_[0] = "pg";
|
||||
messageServer(_loc1_);
|
||||
}
|
||||
|
||||
private function onStart_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onInstructions() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onInstructionsKeyDown);
|
||||
hideDlg();
|
||||
_instructionsPopup = null;
|
||||
_showInstructions = false;
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
package game.cottonCandy
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
|
||||
public class CottonCandy extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private const _sounds:Array = ["cc_cottonGet1.mp3","cc_cottonGet2.mp3","cc_cottonGet3.mp3","cc_cottonGet4.mp3","cc_cottonSelect.mp3","cc_cotton_Rollover.mp3","cc_cottonSpun.mp3","cc_enjoy.mp3","cc_spinnerCottonEnter.mp3","cc_conesEnter.mp3"];
|
||||
|
||||
private var _soundNameCottonGet1:String = _sounds[0];
|
||||
|
||||
private var _soundNameCottonGet2:String = _sounds[1];
|
||||
|
||||
private var _soundNameCottonGet3:String = _sounds[2];
|
||||
|
||||
private var _soundNameCottonGet4:String = _sounds[3];
|
||||
|
||||
private var _soundNameCottonSelect:String = _sounds[4];
|
||||
|
||||
private var _soundNameCottonRollover:String = _sounds[5];
|
||||
|
||||
private var _soundNameCottonSpun:String = _sounds[6];
|
||||
|
||||
private var _soundNameEnjoy:String = _sounds[7];
|
||||
|
||||
private var _soundNameSpinnerCottonEnter:String = _sounds[8];
|
||||
|
||||
private var _soundNameConesEnter:String = _sounds[9];
|
||||
|
||||
public function CottonCandy()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonGet1],_soundNameCottonGet1,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonGet2],_soundNameCottonGet2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonGet3],_soundNameCottonGet3,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonGet4],_soundNameCottonGet4,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonSelect],_soundNameCottonSelect,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonRollover],_soundNameCottonRollover,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCottonSpun],_soundNameCottonSpun,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEnjoy],_soundNameEnjoy,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSpinnerCottonEnter],_soundNameSpinnerCottonEnter,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameConesEnter],_soundNameConesEnter,0.48);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("CottonCandy/room_main.xroom",_sounds);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.cottonGet1)
|
||||
{
|
||||
_theGame.loader.content.cottonGet1 = false;
|
||||
_soundMan.playByName(_soundNameCottonGet1);
|
||||
}
|
||||
if(_theGame.loader.content.cottonGet2)
|
||||
{
|
||||
_theGame.loader.content.cottonGet2 = false;
|
||||
_soundMan.playByName(_soundNameCottonGet2);
|
||||
}
|
||||
if(_theGame.loader.content.cottonGet3)
|
||||
{
|
||||
_theGame.loader.content.cottonGet3 = false;
|
||||
_soundMan.playByName(_soundNameCottonGet3);
|
||||
}
|
||||
if(_theGame.loader.content.cottonGet4)
|
||||
{
|
||||
_theGame.loader.content.cottonGet4 = false;
|
||||
_soundMan.playByName(_soundNameCottonGet4);
|
||||
}
|
||||
if(_theGame.loader.content.cottonSelect)
|
||||
{
|
||||
_theGame.loader.content.cottonSelect = false;
|
||||
_soundMan.playByName(_soundNameCottonSelect);
|
||||
}
|
||||
if(_theGame.loader.content.cotton_Rollover)
|
||||
{
|
||||
_theGame.loader.content.cotton_Rollover = false;
|
||||
_soundMan.playByName(_soundNameCottonRollover);
|
||||
}
|
||||
if(_theGame.loader.content.cottonSpun)
|
||||
{
|
||||
_theGame.loader.content.cottonSpun = false;
|
||||
_soundMan.playByName(_soundNameCottonSpun);
|
||||
}
|
||||
if(_theGame.loader.content.enjoy)
|
||||
{
|
||||
_theGame.loader.content.enjoy = false;
|
||||
_soundMan.playByName(_soundNameEnjoy);
|
||||
}
|
||||
if(_theGame.loader.content.spinnerCottonEnter)
|
||||
{
|
||||
_theGame.loader.content.spinnerCottonEnter = false;
|
||||
_soundMan.playByName(_soundNameSpinnerCottonEnter);
|
||||
}
|
||||
if(_theGame.loader.content.conesEnter)
|
||||
{
|
||||
_theGame.loader.content.conesEnter = false;
|
||||
_soundMan.playByName(_soundNameConesEnter);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(messageServer != null)
|
||||
{
|
||||
messageServer(["_a",30,_theGame.loader.content.emoticonInfo]);
|
||||
}
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,356 @@
|
||||
package game.distanceChallenge
|
||||
{
|
||||
import flash.geom.Point;
|
||||
|
||||
public class DistanceChallengePlayer
|
||||
{
|
||||
|
||||
private static const GRAVITY:Number = 4500;
|
||||
|
||||
private static const WIND_RESISTANCE_UP:Number = 10000;
|
||||
|
||||
private static const WIND_RESISTANCE_RIGHT:Number = -120;
|
||||
|
||||
private static const GROUND_RESISTANCE_RIGHT:Number = -2750;
|
||||
|
||||
private static const MAX_DRAG_RIGHT:Number = -500;
|
||||
|
||||
private static const MAX_VELOCITY_UP:Number = 2000;
|
||||
|
||||
private static const MAX_VELOCITY_DOWN:Number = 1000;
|
||||
|
||||
private static const MAX_VELOCITY_RIGHT:Number = 3600;
|
||||
|
||||
public var _theGame:DistanceChallenge;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _velocity:Point;
|
||||
|
||||
public var _acceleration:Point;
|
||||
|
||||
public var _started:Boolean;
|
||||
|
||||
public var _currentObstacleType:int;
|
||||
|
||||
public var _currentObstacleX:Number;
|
||||
|
||||
public var _gameOver:Boolean;
|
||||
|
||||
public var _currentSoundX:Number;
|
||||
|
||||
public var _collisionTimer:Number;
|
||||
|
||||
public function DistanceChallengePlayer(param1:DistanceChallenge)
|
||||
{
|
||||
super();
|
||||
_gameOver = false;
|
||||
_theGame = param1;
|
||||
_started = false;
|
||||
_clone = {};
|
||||
_clone = _theGame.getScene().cloneAsset("player");
|
||||
_clone.loader.visible = false;
|
||||
_theGame._layerPlayer.addChild(_clone.loader);
|
||||
_velocity = new Point(0,0);
|
||||
_acceleration = new Point(0,0);
|
||||
_currentObstacleType = -1;
|
||||
_currentSoundX = -1;
|
||||
_collisionTimer = 0;
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
if(_clone && _clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
if(_clone.loader.content)
|
||||
{
|
||||
_clone.loader.content.reset();
|
||||
_theGame.getScene().releaseCloneAsset(_clone.loader);
|
||||
}
|
||||
_clone = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(_clone.loader.content && param1 > 0)
|
||||
{
|
||||
_loc3_ = Math.round(param1 / 0.0416666666666667);
|
||||
param1 /= _loc3_;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc3_)
|
||||
{
|
||||
updatePlayer(param1);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePlayer(param1:Number) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:* = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
if(_started == false)
|
||||
{
|
||||
_clone.loader.x = _theGame._launcher.loader.content.ArmadilloX;
|
||||
_clone.loader.y = _theGame._launcher.loader.content.ArmadilloY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_clone.loader.content.armadilloAudio == 1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSpmnOpen);
|
||||
_clone.loader.content.armadilloAudio = 0;
|
||||
}
|
||||
else if(_clone.loader.content.armadilloAudio == 2)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSpmnClose);
|
||||
_clone.loader.content.armadilloAudio = 0;
|
||||
}
|
||||
_collisionTimer -= param1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 6)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 2)
|
||||
{
|
||||
if(_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.parent)
|
||||
{
|
||||
if((_loc3_ + 1 == 1 || _loc3_ + 1 == 3) && _clone.loader.x > _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x && _clone.loader.x < _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x + _theGame._backgroundElements[_loc3_].obstacle[_loc5_].width && _velocity.x > 300)
|
||||
{
|
||||
if(_currentSoundX != _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x)
|
||||
{
|
||||
if(Math.random() > 0.5)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmPassBy1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmPassBy2);
|
||||
}
|
||||
_currentSoundX = _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x;
|
||||
}
|
||||
}
|
||||
_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.content.armadilloSpeedX = _velocity.x;
|
||||
if(_clone.loader.y > _clone.y - _clone.height / 3)
|
||||
{
|
||||
if(_currentObstacleType != _loc3_ || _currentObstacleX != _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x)
|
||||
{
|
||||
if(_clone.loader.x > _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x && _clone.loader.x < _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x + _theGame._backgroundElements[_loc3_].obstacle[_loc5_].width)
|
||||
{
|
||||
_currentObstacleType = _loc3_;
|
||||
_currentObstacleX = _theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x;
|
||||
_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.content.gotoAndPlay("on");
|
||||
switch(_loc3_ + 1)
|
||||
{
|
||||
case 1:
|
||||
_acceleration.x -= 800;
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_clone.loader.content.cactus();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCactusClsn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
_acceleration.x = Math.max(650,_acceleration.x + 650);
|
||||
_acceleration.y = -2500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-110);
|
||||
_clone.loader.content.geyser();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmGeyser);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_acceleration.x -= 800;
|
||||
_theGame.addSnowmanHead(_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.x,_theGame._backgroundElements[_loc3_].obstacle[_loc5_].loader.y);
|
||||
_clone.loader.content.snowman();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmSnwmnClsn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_acceleration.x = Math.max(1000,_acceleration.x + 1000);
|
||||
_acceleration.y = -3500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-150);
|
||||
_clone.loader.content.mole();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmMole);
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmWonderwmn);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
_velocity.x = Math.max(0,_velocity.x - 400);
|
||||
_acceleration.x -= 800;
|
||||
_clone.loader.content.other1();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmStump);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
_acceleration.x = Math.max(1000,_acceleration.x + 1000);
|
||||
_acceleration.y = -3500;
|
||||
_velocity.x = Math.max(750,_velocity.x + 750);
|
||||
_velocity.y = Math.min(_velocity.y,-150);
|
||||
_clone.loader.content.other2();
|
||||
if(_collisionTimer <= 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmLsSteam);
|
||||
_collisionTimer = 0.2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_clone.loader.y >= _clone.y + _clone.height / 2)
|
||||
{
|
||||
_acceleration.x += -2750 * param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_acceleration.x += -120 * param1;
|
||||
}
|
||||
if(_acceleration.x < -500)
|
||||
{
|
||||
_acceleration.x = -500;
|
||||
}
|
||||
if(_acceleration.y < 0)
|
||||
{
|
||||
_acceleration.y += 10000 * param1;
|
||||
}
|
||||
else if(_velocity.y != 0 || _clone.loader.y < _clone.y + _clone.height / 2)
|
||||
{
|
||||
_acceleration.y += 4500 * param1;
|
||||
}
|
||||
_loc2_ = _velocity.x;
|
||||
_loc4_ = _velocity.y;
|
||||
_velocity.x += _acceleration.x * param1;
|
||||
_velocity.x = Math.min(_velocity.x,3600);
|
||||
_velocity.x = Math.max(_velocity.x,0);
|
||||
if(_velocity.y < 0)
|
||||
{
|
||||
_velocity.y += _acceleration.y * param1;
|
||||
if(_velocity.y > 0)
|
||||
{
|
||||
_velocity.y = 50;
|
||||
_acceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y += _acceleration.y * param1;
|
||||
}
|
||||
_velocity.y = Math.min(_velocity.y,2000);
|
||||
_velocity.y = Math.max(_velocity.y,-1000);
|
||||
if(_loc2_ != 0 && _velocity.x < 2)
|
||||
{
|
||||
_velocity.x = 0;
|
||||
_acceleration.x = 0;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmOutro);
|
||||
if(_theGame._windSound != null)
|
||||
{
|
||||
_theGame._windSound.stop();
|
||||
_theGame._windSound = null;
|
||||
}
|
||||
}
|
||||
_clone.loader.x += _velocity.x * param1;
|
||||
_clone.loader.y += _velocity.y * param1;
|
||||
_clone.loader.content.armadillo.armadillo.rotation += 2500 * (_velocity.x / 3600 * param1);
|
||||
_theGame.valueTracker(Math.round((_clone.loader.x - _clone.x) / 10));
|
||||
if(_clone.loader.y > _clone.y + _clone.height / 2 && _velocity.y > 0)
|
||||
{
|
||||
_clone.loader.y = _clone.y + _clone.height / 2;
|
||||
if(_velocity.y < 75)
|
||||
{
|
||||
_velocity.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y = -0.47 * _velocity.y;
|
||||
}
|
||||
_acceleration.y = 0;
|
||||
if(_velocity.y != 0)
|
||||
{
|
||||
_clone.loader.content.bounce();
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmBounce);
|
||||
_loc3_ = Math.random() * 3;
|
||||
switch(_loc3_)
|
||||
{
|
||||
case 0:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision1);
|
||||
break;
|
||||
case 1:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision2);
|
||||
break;
|
||||
default:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmCollision3);
|
||||
}
|
||||
}
|
||||
}
|
||||
_clone.loader.content.armadilloSpeedX = _velocity.x;
|
||||
_clone.loader.content.armadilloSpeedY = _velocity.y;
|
||||
_clone.loader.content.armadilloX = _clone.loader.x;
|
||||
_clone.loader.content.armadilloY = _clone.loader.y;
|
||||
if(!_gameOver && _velocity.x == 0)
|
||||
{
|
||||
_theGame.setGameOver();
|
||||
_gameOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function start() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(!_started)
|
||||
{
|
||||
_clone.loader.visible = true;
|
||||
_loc1_ = 600 * _theGame._launcher.loader.content.firePower;
|
||||
if(_theGame._launcher.loader.content.adjustedStringAngle == 0)
|
||||
{
|
||||
_velocity.y = _loc1_;
|
||||
}
|
||||
else if(_theGame._launcher.loader.content.adjustedStringAngle == 180)
|
||||
{
|
||||
_velocity.y = -_loc1_ * 0.5;
|
||||
}
|
||||
else if(_theGame._launcher.loader.content.adjustedStringAngle > 90)
|
||||
{
|
||||
_velocity.y = Math.cos(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
_velocity.x = Math.sin(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_velocity.y = Math.cos(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
_velocity.x = Math.sin(_theGame._launcher.loader.content.adjustedStringAngle * 3.141592653589793 / 180) * _loc1_;
|
||||
}
|
||||
_theGame._soundMan.playByName(_theGame._soundNameArmLaunch);
|
||||
_started = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,21 @@
|
||||
package game.dolphinRace
|
||||
{
|
||||
public class DolphinRaceAIProfile
|
||||
{
|
||||
|
||||
public var _jumpDetectionProbability:int;
|
||||
|
||||
public var _jumpDetectionDelay:Number;
|
||||
|
||||
public var _jumpDetectionDistance:Number;
|
||||
|
||||
public function DolphinRaceAIProfile(param1:int, param2:Number, param3:int)
|
||||
{
|
||||
super();
|
||||
_jumpDetectionProbability = param1;
|
||||
_jumpDetectionDelay = param2;
|
||||
_jumpDetectionDistance = param3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package game.dolphinRace
|
||||
{
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarViewExt_Splash;
|
||||
import com.sbi.graphics.LayerBitmap;
|
||||
import flash.filters.GlowFilter;
|
||||
|
||||
public class DolphinRaceAvatarView extends AvatarView
|
||||
{
|
||||
|
||||
private static const GLOW_LAND_DEFAULT_COLOR:int = 5586479;
|
||||
|
||||
private static const GLOW_OCEAN_DEFAULT_COLOR:int = 2775381;
|
||||
|
||||
private var _splash:AvatarViewExt_Splash;
|
||||
|
||||
private var _glow:GlowFilter;
|
||||
|
||||
public var _bInSplashVolume:Boolean;
|
||||
|
||||
private var _splashLiquid:String;
|
||||
|
||||
public function DolphinRaceAvatarView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function InitDolphinRaceAvatarView() : void
|
||||
{
|
||||
_layerAnim.avDefId = 19;
|
||||
var _loc1_:LayerBitmap = _layerAnim.bitmap;
|
||||
_loc1_.x = 0;
|
||||
_loc1_.y = 0;
|
||||
_glow = new GlowFilter(0,1,4,4,4);
|
||||
_layerAnim.bitmap.filters = [_glow];
|
||||
setBlendColor();
|
||||
_splash = new AvatarViewExt_Splash(this,_layerAnim.bitmap);
|
||||
_splash.showShadow(false);
|
||||
_bInSplashVolume = false;
|
||||
}
|
||||
|
||||
public function setBlendColor(param1:uint = 0, param2:uint = 4294967295) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
if(param2 == 4294967295)
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
param2 = 5586479;
|
||||
}
|
||||
else
|
||||
{
|
||||
param2 = uint(param1 & 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
if(_layerAnim.bitmap.filters != null && _layerAnim.bitmap.filters[0].color != param2)
|
||||
{
|
||||
_loc3_ = _layerAnim.bitmap.filters;
|
||||
_loc3_[0].color = param2;
|
||||
_layerAnim.bitmap.filters = _loc3_;
|
||||
}
|
||||
_layerAnim.bitmap.setBlendColor(param1);
|
||||
}
|
||||
|
||||
public function toggleSplash(param1:Boolean, param2:String = null) : void
|
||||
{
|
||||
_bInSplashVolume = param1;
|
||||
if(_bInSplashVolume)
|
||||
{
|
||||
_splashLiquid = param2;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat() : void
|
||||
{
|
||||
_splash.heartbeat(_bInSplashVolume,true,_splashLiquid,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
package game.dolphinRace
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.net.FileFilter;
|
||||
import flash.net.FileReference;
|
||||
import flash.net.URLLoader;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class DolphinRaceData
|
||||
{
|
||||
|
||||
public var _data:Object;
|
||||
|
||||
public var _facts:Array;
|
||||
|
||||
public var loadit:URLLoader;
|
||||
|
||||
public var MyFile:FileReference;
|
||||
|
||||
public function DolphinRaceData()
|
||||
{
|
||||
super();
|
||||
initLevelData();
|
||||
}
|
||||
|
||||
public function initLevelData() : void
|
||||
{
|
||||
_facts = [{
|
||||
"imageID":1738,
|
||||
"text":11408
|
||||
},{
|
||||
"imageID":1739,
|
||||
"text":11409
|
||||
},{
|
||||
"imageID":1740,
|
||||
"text":11410
|
||||
},{
|
||||
"imageID":1741,
|
||||
"text":11411
|
||||
},{
|
||||
"imageID":1742,
|
||||
"text":11412
|
||||
},{
|
||||
"imageID":1743,
|
||||
"text":11413
|
||||
},{
|
||||
"imageID":1744,
|
||||
"text":11414
|
||||
},{
|
||||
"imageID":1745,
|
||||
"text":11415
|
||||
},{
|
||||
"imageID":1746,
|
||||
"text":11416
|
||||
},{
|
||||
"imageID":1747,
|
||||
"text":11417
|
||||
},{
|
||||
"imageID":1748,
|
||||
"text":11418
|
||||
},{
|
||||
"imageID":1749,
|
||||
"text":11419
|
||||
},{
|
||||
"imageID":1750,
|
||||
"text":11420
|
||||
},{
|
||||
"imageID":1751,
|
||||
"text":11421
|
||||
},{
|
||||
"imageID":1752,
|
||||
"text":11422
|
||||
},{
|
||||
"imageID":1753,
|
||||
"text":11423
|
||||
},{
|
||||
"imageID":1754,
|
||||
"text":11424
|
||||
},{
|
||||
"imageID":1755,
|
||||
"text":11425
|
||||
},{
|
||||
"imageID":1756,
|
||||
"text":11426
|
||||
},{
|
||||
"imageID":1757,
|
||||
"text":11427
|
||||
},{
|
||||
"imageID":1758,
|
||||
"text":11428
|
||||
},{
|
||||
"imageID":1759,
|
||||
"text":11429
|
||||
},{
|
||||
"imageID":1760,
|
||||
"text":11430
|
||||
}];
|
||||
_data = {
|
||||
"hurdles":[[1,0,0],[1,1,0],[1,2,0],[1,3,0],[1,4,0],[2,0,0],[2,1,0],[2,2,0],[2,3,0],[2,4,0],[2,5,0],[2,7,0],[2,8,0],[2,9,0]],
|
||||
"tiles":[[600],[500,0,0,10],[500,1,0,13],[500,2],[500,3],[500,4],[500,5],[500,6],[500,7],[500,8],[500,9],[500,10],[500,11],[500,12],[500,13],[500,3,400,4,0,5,400,3,400,4,0,6,400,3,400,4,0,5],[500,0,50,0,0,10,50,0],[500,3,50,3,0,5,50,3],[500,4,50,4,0,6,50,4],[500,2,0,8,400,2,400,2,0,8],[300,3,300,3,0,10,0,9,300,3],[300,4,300,4,300,4],[1200],[200],[200,2,0,8,200,2,0,9,200,2,0,8,200,2,0,9],[300,3,300,4,300,3,300,4,300,3,300,4],[0,4,50,4,50,4],[300,3,300,4,300,3,250,4,50,4,50,4,250,3,300,4],[500,2,50,2,0,5,50,2],[500,8,100,4,100,4,100,4,100,8],[500,13,0,0],[500,12,0,4],[500,7,0,9,0,3],[500,13,0,1],[300,3,225,4,225,3,225,4,225,3,225,4],[300,2,0,8,300,3,0,7],[400,12,0,3,250,4,350,1,50,13,100,0,50,10,75,1],[0,4,50,4,50,4,200,2,200,0,0,9,0,10,250,13,150,2,300,4,50,4,50,4],[500,12,0,4]],
|
||||
"proTracks":[[0,19,23,20,21,1,29,1,29,20,33,31,32,31,30,23,34,1,34,1,0,26,23,26,23,26,23,1,0,26,16,0,24,24,25,1,34,16,18,1,23,38,23,37,0,36],[0,19,0,26,23,26,23,1,0,26,16,0,24,24,25,1,34,16,18,1,0,26,23,20,21,1,29,1,29,20,33,31,32,31,30,23,34,1,34,1,23,38,23,36,0,37],[0,35,35,19,0,26,23,26,23,1,0,26,16,0,35,24,35,25,1,34,16,18,1,0,26,23,20,21,1,29,1,28,23,38,23,36,0,37,29,20,33,31,32,31,30,23,34,1,34,1],[0,19,0,20,21,1,29,1,29,20,33,31,32,31,30,23,34,1,34,1,0,35,35,0,26,23,26,23,26,23,1,0,26,16,0,35,24,35,25,1,34,16,18,1,23,38,23,37,0,36],[0,19,0,35,24,35,25,1,34,16,18,1,20,21,1,23,29,1,0,35,35,0,26,23,26,23,26,23,1,0,26,16,29,20,33,31,32,31,30,23,34,1,34,1,23,38,23,36,0,37]],
|
||||
"beginnerTracks":[[0,19,15,2,15,1,15,16,0,24,24,23,20,21,20,14,0,18,1,15,18,1,23,13,23,1,23,38,23,36,0,37],[0,19,23,20,21,20,14,0,15,2,15,1,15,16,0,13,23,1,23,38,23,36,0,37,23,24,24,18,1,15,18,1,28],[0,24,3,4,5,6,25,23,24,20,27,23,1,28,13,23,24,18,16,25,19,15,2,15,1,13,23,1,23,38,23,37,0,36],[0,19,23,20,21,20,14,0,15,2,15,1,15,16,0,24,24,25,1,25,16,18,1,28,23,38,23,36,0,37,13,23,1],[0,19,23,0,24,24,25,1,25,16,18,12,0,21,20,14,0,25,2,25,1,27,16,28,13,23,1,23,38,23,36,0,37]]
|
||||
};
|
||||
}
|
||||
|
||||
public function getArrayStartIndex(param1:String, param2:int) : int
|
||||
{
|
||||
while(param1.charAt(param2) != "[" && param2 < param1.length)
|
||||
{
|
||||
param2++;
|
||||
}
|
||||
return param2 + 1;
|
||||
}
|
||||
|
||||
public function getArrayEndIndex(param1:String, param2:int) : int
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Boolean = false;
|
||||
while(!_loc4_)
|
||||
{
|
||||
if(param2 >= param1.length)
|
||||
{
|
||||
param2 = -1;
|
||||
_loc4_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = param1.charAt(param2);
|
||||
if(_loc5_ == "[")
|
||||
{
|
||||
_loc3_++;
|
||||
}
|
||||
else if(_loc5_ == "]")
|
||||
{
|
||||
if(_loc3_ == 0)
|
||||
{
|
||||
_loc4_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_--;
|
||||
}
|
||||
}
|
||||
if(!_loc4_)
|
||||
{
|
||||
param2++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function parseArray(param1:Array, param2:String, param3:String) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc13_:* = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc12_:String = null;
|
||||
var _loc9_:Array = null;
|
||||
var _loc5_:Array = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc11_:int = param2.indexOf(param3);
|
||||
_loc8_ = getArrayStartIndex(param2,_loc11_);
|
||||
if(_loc8_ < param2.length)
|
||||
{
|
||||
_loc10_ = getArrayEndIndex(param2,_loc8_);
|
||||
if(_loc10_ != -1)
|
||||
{
|
||||
while(_loc8_ < _loc10_)
|
||||
{
|
||||
_loc4_ = getArrayStartIndex(param2,_loc8_);
|
||||
if(_loc4_ < _loc10_ && _loc4_ < param2.length)
|
||||
{
|
||||
_loc7_ = getArrayEndIndex(param2,_loc4_);
|
||||
if(_loc7_ != -1)
|
||||
{
|
||||
_loc12_ = param2.substring(_loc4_,_loc7_);
|
||||
_loc9_ = _loc12_.split(",");
|
||||
_loc5_ = [];
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc9_.length)
|
||||
{
|
||||
_loc5_.push(int(_loc9_[_loc6_]));
|
||||
_loc6_++;
|
||||
}
|
||||
param1.push(_loc5_);
|
||||
}
|
||||
_loc8_ = _loc7_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadFromFile() : void
|
||||
{
|
||||
MyFile = new FileReference();
|
||||
MyFile.addEventListener("select",selectHandler);
|
||||
var _loc2_:Array = [];
|
||||
var _loc1_:FileFilter = new FileFilter("Text Files (*.txt)","*.txt");
|
||||
_loc2_.push(_loc1_);
|
||||
MyFile.browse(_loc2_);
|
||||
}
|
||||
|
||||
private function selectHandler(param1:Event) : void
|
||||
{
|
||||
MyFile.addEventListener("complete",onFileLoaded);
|
||||
MyFile.load();
|
||||
}
|
||||
|
||||
public function onFileLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:FileReference = param1.target as FileReference;
|
||||
var _loc2_:ByteArray = _loc3_["data"];
|
||||
var _loc4_:String = _loc2_.toString();
|
||||
_data = {};
|
||||
_data.hurdles = [];
|
||||
_data.tiles = [];
|
||||
_data.proTracks = [];
|
||||
_data.beginnerTracks = [];
|
||||
parseArray(_data.hurdles,_loc4_,"hurdles:");
|
||||
parseArray(_data.tiles,_loc4_,"tiles:");
|
||||
parseArray(_data.proTracks,_loc4_,"proTracks:");
|
||||
parseArray(_data.beginnerTracks,_loc4_,"beginnerTracks:");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
package game.dolphinRace
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class DolphinRaceHurdle
|
||||
{
|
||||
|
||||
private static const DOLPHINOBSTACLE_0:String = "o_0";
|
||||
|
||||
private static const DOLPHINOBSTACLE_1:String = "o_1";
|
||||
|
||||
private static const DOLPHINOBSTACLE_2:String = "o_2";
|
||||
|
||||
private static const DOLPHINOBSTACLE_3:String = "o_3";
|
||||
|
||||
private static const DOLPHINOBSTACLE_4:String = "o_4";
|
||||
|
||||
private static const DOLPHINOBSTACLE_1_2:String = "o_1_2";
|
||||
|
||||
private static const DOLPHINOBSTACLE_1_3:String = "o_1_3";
|
||||
|
||||
private static const DOLPHINOBSTACLE_2_3:String = "o_2_3";
|
||||
|
||||
private static const DOLPHINOBSTACLE_0_1_2:String = "o_0_1_2";
|
||||
|
||||
private static const DOLPHINOBSTACLE_2_3_4:String = "o_2_3_4";
|
||||
|
||||
private static const DOLPHINRING_1:String = "o1";
|
||||
|
||||
private static const DOLPHINRING_2:String = "o2";
|
||||
|
||||
public static const DR_HURDLE_TYPE_RING:int = 1;
|
||||
|
||||
public static const DR_HURDLE_TYPE_OBSTACLE:int = 2;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_DOUBLE_HIGH:int = 0;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_HIGH:int = 1;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_MIDDLE:int = 2;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_LOW:int = 3;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_DOUBLE_LOW:int = 4;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_HIGH_MIDDLE:int = 5;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_HIGH_LOW:int = 6;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_MIDDLE_LOW:int = 7;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_DOUBLEHIGH_HIGH_MIDDLE:int = 8;
|
||||
|
||||
public static const DR_OBSTACLE_CLASS_DOUBLELOW_LOW_MIDDLE:int = 9;
|
||||
|
||||
public static const DR_RING_MODIFIER_1:int = 0;
|
||||
|
||||
public static const DR_RING_MODIFIER_2:int = 1;
|
||||
|
||||
public static const DR_RING_CLASS_DOUBLEHIGH:int = 0;
|
||||
|
||||
public static const DR_RING_CLASS_HIGH:int = 1;
|
||||
|
||||
public static const DR_RING_CLASS_MIDDLE:int = 2;
|
||||
|
||||
public static const DR_RING_CLASS_LOW:int = 3;
|
||||
|
||||
public static const DR_RING_CLASS_DOUBLELOW:int = 4;
|
||||
|
||||
public var _spawnX:Number;
|
||||
|
||||
public var _x:Number;
|
||||
|
||||
public var _y:Number;
|
||||
|
||||
public var _y2:Number;
|
||||
|
||||
public var _width:Number;
|
||||
|
||||
public var _height:Number;
|
||||
|
||||
public var _height2:Number;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _class:int;
|
||||
|
||||
public var _modifier:int;
|
||||
|
||||
private var _lanesHit:Array;
|
||||
|
||||
public var _debugmc:MovieClip;
|
||||
|
||||
private var _theGame:DolphinRace;
|
||||
|
||||
public function DolphinRaceHurdle(param1:DolphinRace, param2:int, param3:int, param4:int, param5:int, param6:MovieClip, param7:MovieClip)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_lanesHit = [false,false,false,false];
|
||||
_type = param2;
|
||||
_class = param3;
|
||||
_modifier = param4;
|
||||
_spawnX = param5;
|
||||
if(_type == 1)
|
||||
{
|
||||
_width = 20;
|
||||
setHurdle(param7);
|
||||
_y = param7.y + param7.collision.y - param7.collision.height / 2;
|
||||
_height = param7.collision.height;
|
||||
switch(_class)
|
||||
{
|
||||
case 0:
|
||||
_y -= 144;
|
||||
break;
|
||||
case 1:
|
||||
_y -= 54;
|
||||
break;
|
||||
case 2:
|
||||
_y += 56;
|
||||
break;
|
||||
case 3:
|
||||
_y += 156;
|
||||
break;
|
||||
case 4:
|
||||
_y += 246;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setHurdle(param6);
|
||||
_width = param6.collision.width;
|
||||
_y = param6.y + param6.collision.y - param6.collision.height / 2;
|
||||
_height = param6.collision.height;
|
||||
_y2 = param6.y + param6.collision2.y - param6.collision2.height / 2;
|
||||
_height2 = param6.collision2.height;
|
||||
}
|
||||
_x = param5 - _width / 2;
|
||||
}
|
||||
|
||||
public function getLeftEdgeX() : Number
|
||||
{
|
||||
switch(_type - 1)
|
||||
{
|
||||
case 0:
|
||||
return _x - _width / 2;
|
||||
case 1:
|
||||
return _x - _width / 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getRightEdgeX() : Number
|
||||
{
|
||||
switch(_type - 1)
|
||||
{
|
||||
case 0:
|
||||
return _x - _width / 2 + _width;
|
||||
case 1:
|
||||
return _x - _width / 2 + _width;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function testCollision(param1:Number, param2:Number, param3:Number, param4:Number, param5:int, param6:Boolean) : int
|
||||
{
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
if(_lanesHit[param5] == false)
|
||||
{
|
||||
switch(_type - 1)
|
||||
{
|
||||
case 0:
|
||||
_loc8_ = _x - _width / 2;
|
||||
_loc7_ = _y - _height / 2;
|
||||
if(param1 > _loc8_ && param1 < _loc8_ + _width || param1 + param2 > _loc8_ && param1 + param2 < _loc8_ + _width || param1 < _loc8_ && param1 + param2 > _loc8_ + _width)
|
||||
{
|
||||
if(param3 > _loc7_ && param3 < _loc7_ + _height && (param3 + param4 > _loc7_ && param3 + param4 < _loc7_ + _height))
|
||||
{
|
||||
_lanesHit[param5] = true;
|
||||
if(param6)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRRingStinger);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_loc8_ = _x - _width / 2;
|
||||
_loc7_ = _y;
|
||||
if(param1 > _loc8_ && param1 < _loc8_ + _width || param1 + param2 > _loc8_ && param1 + param2 < _loc8_ + _width || param1 < _loc8_ && param1 + param2 > _loc8_ + _width)
|
||||
{
|
||||
if(param3 > _loc7_ && param3 < _loc7_ + _height || param3 + param4 > _loc7_ && param3 + param4 < _loc7_ + _height || param3 < _loc7_ && param3 + param4 > _loc7_ + _height)
|
||||
{
|
||||
_lanesHit[param5] = true;
|
||||
if(param6)
|
||||
{
|
||||
playHitSound(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
_loc7_ = _y2;
|
||||
if(param3 > _loc7_ && param3 < _loc7_ + _height2 || param3 + param4 > _loc7_ && param3 + param4 < _loc7_ + _height2 || param3 < _loc7_ && param3 + param4 > _loc7_ + _height2)
|
||||
{
|
||||
_lanesHit[param5] = true;
|
||||
if(param6)
|
||||
{
|
||||
playHitSound(2);
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function playHitSound(param1:int) : void
|
||||
{
|
||||
switch(_class)
|
||||
{
|
||||
case 0:
|
||||
_theGame._soundMan.playByName(_theGame["_soundNameAJDRImpSeagull" + (Math.floor(Math.random() * 3) + 1)]);
|
||||
break;
|
||||
case 1:
|
||||
_theGame._soundMan.playByName(_theGame["_soundNameAJDRImpSeagull" + (Math.floor(Math.random() * 3) + 1)]);
|
||||
break;
|
||||
case 2:
|
||||
_theGame._soundMan.playByName(_theGame["_soundNameAJDRImpBuoySmall" + (Math.floor(Math.random() * 2) + 1)]);
|
||||
break;
|
||||
case 3:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRBallChain);
|
||||
break;
|
||||
case 4:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRRockslide);
|
||||
break;
|
||||
case 5:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRImpBuoyMed);
|
||||
break;
|
||||
case 6:
|
||||
if(param1 == 1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame["_soundNameAJDRImpSeagull" + (Math.floor(Math.random() * 3) + 1)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRBallChain);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if(param1 == 1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRBallChain);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame["_soundNameAJDRImpBuoySmall" + (Math.floor(Math.random() * 2) + 1)]);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRImpBuoyLarge);
|
||||
break;
|
||||
case 9:
|
||||
_theGame._soundMan.playByName(_theGame._soundNameAJDRRockslide);
|
||||
}
|
||||
}
|
||||
|
||||
public function setHurdle(param1:MovieClip) : void
|
||||
{
|
||||
_debugmc = param1;
|
||||
switch(_type - 1)
|
||||
{
|
||||
case 0:
|
||||
switch(_modifier)
|
||||
{
|
||||
case 0:
|
||||
param1.gotoAndPlay("o1");
|
||||
break;
|
||||
case 1:
|
||||
param1.gotoAndPlay("o2");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch(_class)
|
||||
{
|
||||
case 0:
|
||||
param1.gotoAndPlay("o_0");
|
||||
break;
|
||||
case 1:
|
||||
param1.gotoAndPlay("o_1");
|
||||
break;
|
||||
case 2:
|
||||
param1.gotoAndPlay("o_2");
|
||||
break;
|
||||
case 3:
|
||||
param1.gotoAndPlay("o_3");
|
||||
break;
|
||||
case 4:
|
||||
param1.gotoAndPlay("o_4");
|
||||
break;
|
||||
case 5:
|
||||
param1.gotoAndPlay("o_1_2");
|
||||
break;
|
||||
case 6:
|
||||
param1.gotoAndPlay("o_1_3");
|
||||
break;
|
||||
case 7:
|
||||
param1.gotoAndPlay("o_2_3");
|
||||
break;
|
||||
case 8:
|
||||
param1.gotoAndPlay("o_0_1_2");
|
||||
break;
|
||||
case 9:
|
||||
param1.gotoAndPlay("o_2_3_4");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,572 @@
|
||||
package game.dunkAPhantom
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
|
||||
public class DunkAPhantom extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static var SFX_aj_tickets:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _ticketsWon:int;
|
||||
|
||||
public var _serialNumber1:int;
|
||||
|
||||
public var _serialNumber2:int;
|
||||
|
||||
private var _scorePopups:Array;
|
||||
|
||||
private var _scorePopupIndex:int;
|
||||
|
||||
public var _gameTimer:Number;
|
||||
|
||||
public var _gameOver:Boolean;
|
||||
|
||||
public var _score:int;
|
||||
|
||||
public var _scoreCounter:int;
|
||||
|
||||
public var _scoreMultiplier:int;
|
||||
|
||||
public var _highScore:int;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _resultsDlg:MovieClip;
|
||||
|
||||
public var _instructionsPopup:MovieClip;
|
||||
|
||||
public var _showInstructions:Boolean;
|
||||
|
||||
private var _audio:Array = ["aj_phntmDunk.mp3","aj_phntmFallPlatform.mp3","aj_phntmGrunt.mp3","aj_slingshotStretch.mp3","aj_slingshotLaunch.mp3","aj_targetBreak.mp3","aj_targetImpact.mp3","aj_targetSpawn.mp3","ajj_timerCountDown.mp3","aj_phntmGoldFall.mp3","aj_phntmGoldDunk.mp3","aj_phantomLaugh.mp3","aj_dunkTick.mp3","aj_dunkRedTick.mp3","aj_dunkPhantomHit.mp3"];
|
||||
|
||||
internal var _soundNamePhntmDunk:String = _audio[0];
|
||||
|
||||
internal var _soundNamePhntmFallPlatform:String = _audio[1];
|
||||
|
||||
internal var _soundNamePhntmGrunt:String = _audio[2];
|
||||
|
||||
internal var _soundNameSlingshotStretch:String = _audio[3];
|
||||
|
||||
internal var _soundNameSlingshotLaunch:String = _audio[4];
|
||||
|
||||
internal var _soundNameTargetBreak:String = _audio[5];
|
||||
|
||||
internal var _soundNameTargetImpact:String = _audio[6];
|
||||
|
||||
internal var _soundNameTargetSpawn:String = _audio[7];
|
||||
|
||||
internal var _soundNameTimerCountDown:String = _audio[8];
|
||||
|
||||
internal var _soundNamePhntmGoldFall:String = _audio[9];
|
||||
|
||||
internal var _soundNamePhntmGoldDunk:String = _audio[10];
|
||||
|
||||
internal var _soundNamePhantomLaugh:String = _audio[11];
|
||||
|
||||
internal var _soundNameDunkTick:String = _audio[12];
|
||||
|
||||
internal var _soundNameDunkRedTick:String = _audio[13];
|
||||
|
||||
internal var _soundNameDunkPhantomHit:String = _audio[14];
|
||||
|
||||
private var _SFX_aj_tickets_Instance:SoundChannel;
|
||||
|
||||
public function DunkAPhantom()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhntmDunk],_soundNamePhntmDunk,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhntmFallPlatform],_soundNamePhntmFallPlatform,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhntmGrunt],_soundNamePhntmGrunt,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSlingshotStretch],_soundNameSlingshotStretch,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSlingshotLaunch],_soundNameSlingshotLaunch,0.47);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTargetBreak],_soundNameTargetBreak,0.57);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTargetImpact],_soundNameTargetImpact,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTargetSpawn],_soundNameTargetSpawn,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCountDown],_soundNameTimerCountDown,0.3);
|
||||
_soundMan.addSound(SFX_aj_tickets,0.15);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhntmGoldFall],_soundNamePhntmGoldFall,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhntmGoldDunk],_soundNamePhntmGoldDunk,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePhantomLaugh],_soundNamePhantomLaugh,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDunkTick],_soundNameDunkTick,0.38);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDunkRedTick],_soundNameDunkRedTick,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDunkPhantomHit],_soundNameDunkPhantomHit,0.48);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
resetGame();
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
_gameOver = true;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("DunkAPhantom/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else if(_sceneLoaded)
|
||||
{
|
||||
_loc1_ = showDlg("carnival_play",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
}
|
||||
|
||||
private function onCarnPlayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onStart_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onStart_No();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
var _loc3_:MovieClip = null;
|
||||
SFX_aj_tickets = getDefinitionByName("aj_tickets") as Class;
|
||||
if(SFX_aj_tickets == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:aj_tickets");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc5_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc5_.x,_loc5_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
_gameOver = true;
|
||||
_highScore = Math.max(gMainFrame.userInfo.userVarCache.getUserVarValueById(380),0);
|
||||
_theGame.loader.content.highScoreText.text = _highScore.toString();
|
||||
_loc3_ = showDlg("carnival_play",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:MovieClip = null;
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc3_ + 1];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "pz")
|
||||
{
|
||||
_serialNumber1 = (parseInt(param1[3]) + 7) / 3 - 5;
|
||||
}
|
||||
else if(param1[2] == "pg")
|
||||
{
|
||||
if(parseInt(param1[3]) == 1)
|
||||
{
|
||||
_serialNumber2 = (parseInt(param1[4]) + 7) / 3 - 5;
|
||||
if(_showInstructions)
|
||||
{
|
||||
_instructionsPopup = showDlg("carnival_candyInstructions",[{
|
||||
"name":"x_btn",
|
||||
"f":onInstructions
|
||||
}]);
|
||||
_instructionsPopup.x = 450;
|
||||
_instructionsPopup.y = 275;
|
||||
stage.addEventListener("keyDown",onInstructionsKeyDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = showDlg("carnival_lowGems",[{
|
||||
"name":"exitButton",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "gr")
|
||||
{
|
||||
_ticketsWon = parseInt(param1[3]);
|
||||
showResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onInstructionsKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onInstructions();
|
||||
}
|
||||
}
|
||||
|
||||
private function showResults() : void
|
||||
{
|
||||
_resultsDlg = showDlg("carnival_results",[{
|
||||
"name":"button_yes",
|
||||
"f":onStart_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onStart_No
|
||||
}]);
|
||||
_resultsDlg.ticketCounter.earnTickets(_ticketsWon);
|
||||
_resultsDlg.messageText.text = _ticketsWon;
|
||||
_resultsDlg.x = 450;
|
||||
_resultsDlg.y = 275;
|
||||
stage.addEventListener("keyDown",onCarnPlayKeyDown);
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
hideDlg();
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_gameOver = false;
|
||||
_theGame.loader.content.playAgain();
|
||||
_scoreMultiplier = 1;
|
||||
_score = 0;
|
||||
_theGame.loader.content.scoreText.text = _score;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
_theGame.loader.content.gamePaused = false;
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_resultsDlg != null)
|
||||
{
|
||||
if(_resultsDlg.ticketCounter.ticketState == 0)
|
||||
{
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
}
|
||||
else if(_SFX_aj_tickets_Instance == null)
|
||||
{
|
||||
_SFX_aj_tickets_Instance = _soundMan.play(SFX_aj_tickets,0,99999);
|
||||
}
|
||||
}
|
||||
if(_sceneLoaded && _pauseGame == false && _instructionsPopup == null)
|
||||
{
|
||||
if(_gameOver == false)
|
||||
{
|
||||
if(_theGame.loader.content.timerCountDown)
|
||||
{
|
||||
_theGame.loader.content.timerCountDown = false;
|
||||
_soundMan.playByName(_soundNameTimerCountDown);
|
||||
}
|
||||
if(_theGame.loader.content.targetSpawn)
|
||||
{
|
||||
_theGame.loader.content.targetSpawn = false;
|
||||
_soundMan.playByName(_soundNameTargetSpawn);
|
||||
}
|
||||
if(_theGame.loader.content.phntmFallPlatform)
|
||||
{
|
||||
_theGame.loader.content.phntmFallPlatform = false;
|
||||
_soundMan.playByName(_soundNamePhntmFallPlatform);
|
||||
}
|
||||
if(_theGame.loader.content.phntmGrunt)
|
||||
{
|
||||
_theGame.loader.content.phntmGrunt = false;
|
||||
_soundMan.playByName(_soundNamePhntmGrunt);
|
||||
}
|
||||
if(_theGame.loader.content.phntmDunk)
|
||||
{
|
||||
_theGame.loader.content.phntmDunk = false;
|
||||
_soundMan.playByName(_soundNamePhntmDunk);
|
||||
}
|
||||
if(_theGame.loader.content.targetImpact)
|
||||
{
|
||||
_theGame.loader.content.targetImpact = false;
|
||||
_soundMan.playByName(_soundNameTargetImpact);
|
||||
}
|
||||
if(_theGame.loader.content.targetBreak)
|
||||
{
|
||||
_theGame.loader.content.targetBreak = false;
|
||||
_soundMan.playByName(_soundNameTargetBreak);
|
||||
}
|
||||
if(_theGame.loader.content.slingshotStretch)
|
||||
{
|
||||
_theGame.loader.content.slingshotStretch = false;
|
||||
_soundMan.playByName(_soundNameSlingshotStretch);
|
||||
}
|
||||
if(_theGame.loader.content.slingshotLaunch)
|
||||
{
|
||||
_theGame.loader.content.slingshotLaunch = false;
|
||||
_soundMan.playByName(_soundNameSlingshotLaunch);
|
||||
}
|
||||
if(_theGame.loader.content.phntmGoldFall)
|
||||
{
|
||||
_theGame.loader.content.phntmGoldFall = false;
|
||||
_soundMan.playByName(_soundNamePhntmGoldFall);
|
||||
}
|
||||
if(_theGame.loader.content.phntmGoldDunk)
|
||||
{
|
||||
_theGame.loader.content.phntmGoldDunk = false;
|
||||
_soundMan.playByName(_soundNamePhntmGoldDunk);
|
||||
}
|
||||
if(_theGame.loader.content.phantomLaugh)
|
||||
{
|
||||
_theGame.loader.content.phantomLaugh = false;
|
||||
_soundMan.playByName(_soundNamePhantomLaugh);
|
||||
}
|
||||
if(_theGame.loader.content.dunkTick)
|
||||
{
|
||||
_theGame.loader.content.dunkTick = false;
|
||||
_soundMan.playByName(_soundNameDunkTick);
|
||||
}
|
||||
if(_theGame.loader.content.dunkRedTick)
|
||||
{
|
||||
_theGame.loader.content.dunkRedTick = false;
|
||||
_soundMan.playByName(_soundNameDunkRedTick);
|
||||
}
|
||||
if(_theGame.loader.content.dunkPhantomHit)
|
||||
{
|
||||
_theGame.loader.content.dunkPhantomHit = false;
|
||||
_soundMan.playByName(_soundNameDunkPhantomHit);
|
||||
}
|
||||
if(_theGame.loader.content.roundOver)
|
||||
{
|
||||
_score = _theGame.loader.content.score;
|
||||
if(_score > _highScore)
|
||||
{
|
||||
_highScore = _score;
|
||||
AchievementXtCommManager.requestSetUserVar(380,_highScore);
|
||||
_theGame.loader.content.highScoreText.text = _highScore.toString();
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc6_ = (_score + 29) * 7 + (_serialNumber1 + 49) * 5;
|
||||
_loc7_ = (_score + 49) * 3 + (_serialNumber2 + 83) * 5;
|
||||
_loc3_ = (_serialNumber1 + _score) * 3 + _score * 3;
|
||||
_loc2_[0] = "gr";
|
||||
_loc2_[1] = _loc6_;
|
||||
_loc2_[2] = _loc7_;
|
||||
_loc2_[3] = _loc3_;
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function doScorePopup(param1:Number, param2:Number, param3:int) : void
|
||||
{
|
||||
if(_scoreMultiplier > 1)
|
||||
{
|
||||
_scorePopups[_scorePopupIndex].combo.gotoAndStop("multi");
|
||||
_scorePopups[_scorePopupIndex].combo.comboMult.text = "x " + _scoreMultiplier.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_scorePopups[_scorePopupIndex].combo.gotoAndStop("single");
|
||||
}
|
||||
_scorePopups[_scorePopupIndex].combo.comboNum.text = param3.toString();
|
||||
_scorePopups[_scorePopupIndex].x = param1;
|
||||
_scorePopups[_scorePopupIndex].y = param2;
|
||||
_scorePopups[_scorePopupIndex].gotoAndPlay("on");
|
||||
_scorePopupIndex = _scorePopupIndex + 1;
|
||||
if(_scorePopupIndex >= _scorePopups.length)
|
||||
{
|
||||
_scorePopupIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("carnival_leaveGame",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
_theGame.loader.content.gamePaused = true;
|
||||
}
|
||||
|
||||
private function onStart_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onCarnPlayKeyDown);
|
||||
_resultsDlg = null;
|
||||
if(_SFX_aj_tickets_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_aj_tickets_Instance);
|
||||
_SFX_aj_tickets_Instance = null;
|
||||
}
|
||||
var _loc1_:Array = [];
|
||||
_loc1_[0] = "pg";
|
||||
messageServer(_loc1_);
|
||||
}
|
||||
|
||||
private function onStart_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_theGame.loader.content.gamePaused = false;
|
||||
}
|
||||
|
||||
private function onInstructions() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onInstructionsKeyDown);
|
||||
hideDlg();
|
||||
_instructionsPopup = null;
|
||||
_showInstructions = false;
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
package game.eagleFlap
|
||||
{
|
||||
import achievement.AchievementManager;
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.AvatarInfo;
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class EagleFlap extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_WAITINGFORPOPUP:int = 1;
|
||||
|
||||
public static const GAMESTATE_STARTED:int = 4;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 6;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _layerPopups:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _timeOutTimer:Number;
|
||||
|
||||
private var _currentPopup:MovieClip;
|
||||
|
||||
private var _score:int;
|
||||
|
||||
private var _scoreThisLevel:int;
|
||||
|
||||
private var _scorePopup:MovieClip;
|
||||
|
||||
private var _scoreMultiplier:int = 1;
|
||||
|
||||
private var _gameOver:Boolean;
|
||||
|
||||
private var _highScore:int;
|
||||
|
||||
public var _player:Object = {};
|
||||
|
||||
public var _bgContent:Object;
|
||||
|
||||
private var _gemsEarned:int;
|
||||
|
||||
private var _gemsAwarded:int;
|
||||
|
||||
private var _displayAchievementTimer:Number = 0;
|
||||
|
||||
private var _gameOverPopup:MovieClip;
|
||||
|
||||
private var _popupDismissed:Boolean;
|
||||
|
||||
private var _exitDismissed:Boolean;
|
||||
|
||||
private var _audio:Array = ["aj_eagleFail.mp3","aj_eagleIntro.mp3","aj_eagleFlap.mp3","aj_eagleImp.mp3"];
|
||||
|
||||
internal var _soundNameEagleFail:String = _audio[0];
|
||||
|
||||
internal var _soundNameEagleIntro:String = _audio[1];
|
||||
|
||||
internal var _soundNameEagleFlap:String = _audio[2];
|
||||
|
||||
internal var _soundNameEagleImp:String = _audio[3];
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _SFX_Music:SBMusic;
|
||||
|
||||
private var _introSC:SoundChannel;
|
||||
|
||||
private var _failSC:SoundChannel;
|
||||
|
||||
private var _musicSC:SoundChannel;
|
||||
|
||||
public function EagleFlap()
|
||||
{
|
||||
super();
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_SFX_Music = _soundMan.addStream("aj_musEagleLP",0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEagleFail],_soundNameEagleFail,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEagleIntro],_soundNameEagleIntro,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEagleFlap],_soundNameEagleFlap,0.17);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEagleImp],_soundNameEagleImp,0.67);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function doGameOver() : void
|
||||
{
|
||||
setGameState(6);
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_gameTime > 15)
|
||||
{
|
||||
}
|
||||
if(_introSC)
|
||||
{
|
||||
_introSC.stop();
|
||||
_introSC = null;
|
||||
}
|
||||
if(_failSC)
|
||||
{
|
||||
_failSC.stop();
|
||||
_failSC = null;
|
||||
}
|
||||
if(_musicSC)
|
||||
{
|
||||
_musicSC.stop();
|
||||
_musicSC = null;
|
||||
}
|
||||
hideDlg();
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.removeEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_layerPopups);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_layerPopups = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_layerPopups = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_layerPopups);
|
||||
addChild(_guiLayer);
|
||||
loadScene("EagleFlapAssets/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:* = null;
|
||||
var _loc3_:* = null;
|
||||
var _loc2_:Array = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_closeBtn = addBtn("CloseButton",847,1,showExitConfirmationDlg);
|
||||
_bgContent = _scene.getLayer("bg").loader;
|
||||
_bgContent = _bgContent.content;
|
||||
_layerMain.addChild(_bgContent as DisplayObject);
|
||||
stage.addEventListener("enterFrame",heartbeat);
|
||||
stage.addEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.addEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
_highScore = Math.max(gMainFrame.userInfo.userVarCache.getUserVarValueById(376),0);
|
||||
_bgContent.hiScoreText.pointsText.text = _highScore;
|
||||
var _loc4_:AvatarInfo = gMainFrame.userInfo.playerAvatarInfo;
|
||||
if(_loc4_.type == 2)
|
||||
{
|
||||
_loc2_ = _loc4_.colors;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = [3228143359,0,16728063];
|
||||
}
|
||||
var _loc5_:Array = PaletteHelper.getRGBColors(_loc2_[0]);
|
||||
_bgContent.eagleColor1RGB(_loc5_[0].r,_loc5_[0].g,_loc5_[0].b);
|
||||
_bgContent.eagleColor2RGB(_loc5_[1].r,_loc5_[1].g,_loc5_[1].b);
|
||||
_bgContent.eagleColor3RGB(_loc5_[2].r,_loc5_[2].g,_loc5_[2].b);
|
||||
_popupDismissed = false;
|
||||
_sceneLoaded = true;
|
||||
super.sceneLoaded(param1);
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
}
|
||||
|
||||
private function replayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onRetry();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onExit_Yes();
|
||||
}
|
||||
}
|
||||
|
||||
private function showGameOver() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
stage.addEventListener("keyDown",replayKeyDown);
|
||||
if(_bgContent.points > 0)
|
||||
{
|
||||
_loc1_ = showDlg("EagleFlap_Great_Job",[{
|
||||
"name":"button_nextlevel",
|
||||
"f":onRetry
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_Yes
|
||||
}]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = showDlg("EagleFlap_Try_Again",[{
|
||||
"name":"button_yes",
|
||||
"f":onRetry
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_Yes
|
||||
}]);
|
||||
}
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.removeEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.removeEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
_loc1_.addEventListener("keyDown",spacePressed);
|
||||
stage.stageFocusRect = false;
|
||||
_gameOverPopup = _loc1_;
|
||||
stage.focus = _loc1_;
|
||||
if(_bgContent.points >= _highScore)
|
||||
{
|
||||
_highScore = _bgContent.points;
|
||||
_bgContent.hiScoreText.pointsText.text = _highScore;
|
||||
AchievementXtCommManager.requestSetUserVar(376,_highScore);
|
||||
}
|
||||
if(_bgContent.points > 0)
|
||||
{
|
||||
_gemsEarned = _bgContent.points * 5;
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.points,15787,_bgContent.points);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Gems_Earned,15788,_bgContent.points);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Gems_Total,15789,_gemsEarned);
|
||||
AchievementXtCommManager.requestSetUserVar(377,_bgContent.points);
|
||||
if(_gemsEarned > 0)
|
||||
{
|
||||
addGemsToBalance(_gemsEarned);
|
||||
}
|
||||
}
|
||||
AchievementXtCommManager.requestSetUserVar(378,1);
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
|
||||
private function spacePressed(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(param1.keyCode == 32)
|
||||
{
|
||||
onRetry();
|
||||
}
|
||||
}
|
||||
|
||||
private function showExitConfirmationDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
_bgContent.xPause = true;
|
||||
stage.removeEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.removeEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
}
|
||||
|
||||
private function showNextLevel() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function onRetry() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
_popupDismissed = true;
|
||||
if(_failSC)
|
||||
{
|
||||
_failSC.stop();
|
||||
_failSC = null;
|
||||
}
|
||||
_gameOverPopup.removeEventListener("keyDown",spacePressed);
|
||||
stage.addEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.addEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
stage.focus = _bgContent as MovieClip;
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onGemMultiplierDone() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_exitDismissed = true;
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc3_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_gameState != param1)
|
||||
{
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 3:
|
||||
hideDlg();
|
||||
_gameOver = false;
|
||||
break;
|
||||
case 5:
|
||||
showGameOver();
|
||||
_gameOver = true;
|
||||
}
|
||||
_gameState = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
var _loc3_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted && !_pauseGame)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_bgContent.highScore > _highScore)
|
||||
{
|
||||
_highScore = _bgContent.points;
|
||||
_bgContent.hiScoreText.pointsText.text = _highScore;
|
||||
}
|
||||
if(_bgContent.playFlap)
|
||||
{
|
||||
_soundMan.playByName(_soundNameEagleFlap);
|
||||
_bgContent.playFlap = false;
|
||||
}
|
||||
if(_bgContent.playImpact)
|
||||
{
|
||||
_soundMan.playByName(_soundNameEagleImp);
|
||||
_bgContent.playImpact = false;
|
||||
}
|
||||
if(_exitDismissed)
|
||||
{
|
||||
_bgContent.xPause = false;
|
||||
stage.addEventListener("keyDown",_bgContent.fl_KeyboardDownHandler);
|
||||
stage.addEventListener("mouseDown",_bgContent.fl_MouseClickHandler);
|
||||
}
|
||||
if(_popupDismissed)
|
||||
{
|
||||
_bgContent.reset();
|
||||
_popupDismissed = false;
|
||||
}
|
||||
if(_bgContent.clickToStart.visible)
|
||||
{
|
||||
if(_introSC == null)
|
||||
{
|
||||
if(_failSC)
|
||||
{
|
||||
_failSC.stop();
|
||||
_failSC = null;
|
||||
}
|
||||
_introSC = _soundMan.playByName(_soundNameEagleIntro);
|
||||
}
|
||||
}
|
||||
else if(!_bgContent.dead)
|
||||
{
|
||||
if(_introSC)
|
||||
{
|
||||
_introSC.stop();
|
||||
_introSC = null;
|
||||
}
|
||||
if(_musicSC == null)
|
||||
{
|
||||
_musicSC = _soundMan.playStream(_SFX_Music,0,999999);
|
||||
}
|
||||
}
|
||||
else if(_failSC == null)
|
||||
{
|
||||
if(_musicSC)
|
||||
{
|
||||
_musicSC.stop();
|
||||
_musicSC = null;
|
||||
}
|
||||
_failSC = _soundMan.playByName(_soundNameEagleFail);
|
||||
}
|
||||
if(_bgContent.eagleOut)
|
||||
{
|
||||
showGameOver();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,15 @@
|
||||
package game.fallingPhantoms
|
||||
{
|
||||
public class FallingPhantomsAIProfile
|
||||
{
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public function FallingPhantomsAIProfile(param1:int)
|
||||
{
|
||||
super();
|
||||
_type = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package game.fallingPhantoms
|
||||
{
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarViewExt_Splash;
|
||||
import flash.display.Shape;
|
||||
import flash.filters.GlowFilter;
|
||||
|
||||
public class FallingPhantomsAvatarView extends AvatarView
|
||||
{
|
||||
|
||||
private static const GLOW_LAND_DEFAULT_COLOR:int = 5586479;
|
||||
|
||||
private static const GLOW_OCEAN_DEFAULT_COLOR:int = 2775381;
|
||||
|
||||
private var _splash:AvatarViewExt_Splash;
|
||||
|
||||
private var _glow:GlowFilter;
|
||||
|
||||
public var _bInSplashVolume:Boolean;
|
||||
|
||||
private var _splashLiquid:String;
|
||||
|
||||
public var rectangle:Shape;
|
||||
|
||||
public function FallingPhantomsAvatarView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function InitFallingPhantomsAvatarView() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function setBlendColor(param1:uint = 0, param2:uint = 4294967295) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function toggleSplash(param1:Boolean, param2:String = null) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function heartbeat() : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,742 @@
|
||||
package game.fallingPhantoms
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import collection.AccItemCollection;
|
||||
import com.sbi.corelib.math.RandomSeed;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Sprite;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
|
||||
public class FallingPhantomsPlayer
|
||||
{
|
||||
|
||||
private static const AI_EMOTE_NONE:int = 0;
|
||||
|
||||
private static const AI_EMOTE_JUMP:int = 1;
|
||||
|
||||
private static const AI_EMOTE_FALL:int = 2;
|
||||
|
||||
public static const ANIM_JUMP_IN:int = 35;
|
||||
|
||||
public static const ANIM_IDLE_EAST:int = 37;
|
||||
|
||||
public var _theGame:FallingPhantoms;
|
||||
|
||||
public var _avatar:FallingPhantomsAvatarView;
|
||||
|
||||
public var _replacedAvatar:FallingPhantomsAvatarView;
|
||||
|
||||
public var _animsLoaded:Boolean;
|
||||
|
||||
public var _playerID:int;
|
||||
|
||||
public var _dbID:int;
|
||||
|
||||
public var _avID:int;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _colors:Array;
|
||||
|
||||
public var _localPlayer:Boolean;
|
||||
|
||||
public var _playerLeft:Boolean;
|
||||
|
||||
public var _debugCircle:Sprite;
|
||||
|
||||
public var _finishPlace:int;
|
||||
|
||||
public var _aiGameRandomizer:RandomSeed;
|
||||
|
||||
public var _isAI:Boolean;
|
||||
|
||||
public var _aiProfile:FallingPhantomsAIProfile;
|
||||
|
||||
public var _name:String;
|
||||
|
||||
public var _playerLayer:Sprite;
|
||||
|
||||
public var _aiRandomizer:RandomSeed;
|
||||
|
||||
public var _currentAnim:int;
|
||||
|
||||
public var _moveRight:Boolean;
|
||||
|
||||
public var _moveLeft:Boolean;
|
||||
|
||||
public var _gotoX:Number;
|
||||
|
||||
public var _gotoTimer:Number;
|
||||
|
||||
public var _receiveBonus:Boolean;
|
||||
|
||||
public var _dropped:Boolean;
|
||||
|
||||
public var _dead:Boolean;
|
||||
|
||||
public var _gemMultiplier:int;
|
||||
|
||||
public var _phantomThreshold:Number;
|
||||
|
||||
public var _userName:String;
|
||||
|
||||
public var _customAvId:int;
|
||||
|
||||
private var _avatarArray:Array = [1,4,5,6,7,8,13,15,16,17,18,23,24,26];
|
||||
|
||||
public function FallingPhantomsPlayer(param1:FallingPhantoms)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_currentAnim = -1;
|
||||
}
|
||||
|
||||
public function replacePlayer(param1:FallingPhantomsPlayer) : void
|
||||
{
|
||||
if(param1._avatar && param1._avatar.parent)
|
||||
{
|
||||
param1._avatar.parent.removeChild(param1._avatar);
|
||||
_avatar.parent.removeChild(_avatar);
|
||||
if(_replacedAvatar == null)
|
||||
{
|
||||
_replacedAvatar = _avatar;
|
||||
}
|
||||
else
|
||||
{
|
||||
_avatar.destroy();
|
||||
}
|
||||
_avatar = param1._avatar;
|
||||
_playerLayer.addChild(_avatar);
|
||||
}
|
||||
_finishPlace = param1._finishPlace;
|
||||
}
|
||||
|
||||
public function setupHumanPlayer(param1:int, param2:Boolean, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int, param9:int, param10:String, param11:String, param12:int) : void
|
||||
{
|
||||
_userName = param11;
|
||||
_name = param10;
|
||||
_isAI = false;
|
||||
_avatar = null;
|
||||
_localPlayer = param2;
|
||||
_playerID = param1;
|
||||
_dbID = param3;
|
||||
_avID = param4;
|
||||
_type = param5;
|
||||
_colors = new Array(param6,param7,param8);
|
||||
_gotoX = param9;
|
||||
_customAvId = param12;
|
||||
}
|
||||
|
||||
public function setupAIPlayer(param1:int, param2:int, param3:int, param4:String) : void
|
||||
{
|
||||
_name = param4;
|
||||
_isAI = true;
|
||||
_aiGameRandomizer = new RandomSeed(param1);
|
||||
_avatar = null;
|
||||
_localPlayer = true;
|
||||
_playerID = param2;
|
||||
_dbID = -1;
|
||||
_avID = -1;
|
||||
_customAvId = -1;
|
||||
}
|
||||
|
||||
public function prepareForStart(param1:int) : void
|
||||
{
|
||||
if(_replacedAvatar != null)
|
||||
{
|
||||
if(_avatar)
|
||||
{
|
||||
if(_avatar.parent)
|
||||
{
|
||||
_avatar.parent.removeChild(_avatar);
|
||||
}
|
||||
_avatar.destroy();
|
||||
_avatar = null;
|
||||
}
|
||||
_avatar = _replacedAvatar;
|
||||
_replacedAvatar = null;
|
||||
_playerLayer.addChild(_avatar);
|
||||
}
|
||||
if(_playerLayer)
|
||||
{
|
||||
_playerLayer.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function pickRandomColors() : void
|
||||
{
|
||||
var _loc1_:uint = uint(PaletteHelper.avatarPalette1[_aiGameRandomizer.integer(PaletteHelper.avatarPalette1.length)]);
|
||||
var _loc4_:uint = uint(PaletteHelper.avatarPalette2[_aiGameRandomizer.integer(PaletteHelper.avatarPalette2.length)]);
|
||||
var _loc5_:uint = uint(PaletteHelper.avatarPalette2[_aiGameRandomizer.integer(PaletteHelper.avatarPalette1.length)]);
|
||||
var _loc8_:uint = uint(PaletteHelper.avatarPalette2[_aiGameRandomizer.integer(PaletteHelper.avatarPalette1.length)]);
|
||||
var _loc2_:Array = _avatar.avatarData.colors;
|
||||
var _loc3_:uint = uint(_loc2_[0]);
|
||||
var _loc6_:uint = uint(_loc2_[1]);
|
||||
var _loc7_:uint = uint(_loc2_[2]);
|
||||
_loc3_ = uint(_loc1_ << 24 | _loc4_ << 16 | (_loc3_ >> 8 & 0xFF) << 8 | _loc3_ & 0xFF);
|
||||
_loc6_ = uint(_loc5_ << 24 | (_loc6_ >> 16 & 0xFF) << 16 | (_loc6_ >> 8 & 0xFF) << 8 | _loc6_ & 0xFF);
|
||||
_loc7_ = uint(_loc8_ << 24 | (_loc7_ >> 16 & 0xFF) << 16 | (_loc7_ >> 8 & 0xFF) << 8 | _loc7_ & 0xFF);
|
||||
_avatar.avatarData.colors = [_loc3_,_loc6_,_loc7_];
|
||||
}
|
||||
|
||||
private function pickEyeAndPattern() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Array = [];
|
||||
var _loc1_:Array = [];
|
||||
if(_avatar.avatarData.inventoryBodyMod != null)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _avatar.avatarData.inventoryBodyMod.numItems)
|
||||
{
|
||||
if(_avatar.avatarData.inventoryBodyMod.itemCollection.getAccItem(_loc2_).layerId == 2)
|
||||
{
|
||||
_loc1_.push(_avatar.avatarData.inventoryBodyMod.itemCollection.getAccItem(_loc2_));
|
||||
}
|
||||
else if(_avatar.avatarData.inventoryBodyMod.itemCollection.getAccItem(_loc2_).layerId == 3)
|
||||
{
|
||||
_loc4_.push(_avatar.avatarData.inventoryBodyMod.itemCollection.getAccItem(_loc2_));
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
if(_loc1_.length > 0)
|
||||
{
|
||||
_loc3_ = _aiGameRandomizer.integer(_loc1_.length);
|
||||
if(!_loc1_[_loc3_].getInUse(_avatar.perUserAvId))
|
||||
{
|
||||
_loc1_[_loc3_].inUseFlagLand = -1;
|
||||
_loc1_[_loc3_].inUseFlagOcean = -1;
|
||||
_avatar.avatarData.accStateShowAccessory(_loc1_[_loc3_]);
|
||||
}
|
||||
}
|
||||
if(_loc4_.length > 0)
|
||||
{
|
||||
_loc3_ = _aiGameRandomizer.integer(_loc4_.length);
|
||||
if(!_loc4_[_loc3_].getInUse(_avatar.perUserAvId))
|
||||
{
|
||||
_loc4_[_loc3_].inUseFlagLand = -1;
|
||||
_loc4_[_loc3_].inUseFlagOcean = -1;
|
||||
_avatar.avatarData.accStateShowAccessory(_loc4_[_loc3_]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function pickRandomClothingItemByLayer(param1:int) : Item
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:Item = null;
|
||||
var _loc4_:Item = null;
|
||||
var _loc5_:int = 0;
|
||||
_loc3_ = _aiGameRandomizer.integer(_theGame._availableItems.length);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _theGame._availableItems.length)
|
||||
{
|
||||
_loc4_ = _theGame._availableItems[_loc3_];
|
||||
_loc5_ = _aiGameRandomizer.integer(_theGame._availableItemColors[_loc4_.defId].length);
|
||||
_loc4_.color = _theGame._availableItemColors[_loc4_.defId][_loc5_];
|
||||
if(_loc4_.type == 1 && _loc4_.layerId == param1)
|
||||
{
|
||||
_loc6_ = new Item();
|
||||
_loc6_.init(_loc4_.defId,_loc4_.invIdx,_loc4_.color,-1,-1);
|
||||
return _loc6_;
|
||||
}
|
||||
if(++_loc3_ >= _theGame._availableItems.length)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function initAIAccessories() : void
|
||||
{
|
||||
var _loc3_:AccItemCollection = null;
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:Item = null;
|
||||
if(_isAI)
|
||||
{
|
||||
_loc3_ = new AccItemCollection();
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _avatar.avatarData.inventoryBodyMod.numItems)
|
||||
{
|
||||
_loc3_.pushAccItem(_avatar.avatarData.inventoryBodyMod.itemCollection.getAccItem(_loc1_));
|
||||
_loc1_++;
|
||||
}
|
||||
if(_aiGameRandomizer.integer(100) > 20)
|
||||
{
|
||||
_loc2_ = pickRandomClothingItemByLayer(5);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_.pushAccItem(_loc2_);
|
||||
}
|
||||
}
|
||||
if(_aiGameRandomizer.integer(100) > 20)
|
||||
{
|
||||
_loc2_ = pickRandomClothingItemByLayer(6);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_.pushAccItem(_loc2_);
|
||||
}
|
||||
}
|
||||
if(_aiGameRandomizer.integer(100) > 20)
|
||||
{
|
||||
_loc2_ = pickRandomClothingItemByLayer(8);
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
_loc2_ = pickRandomClothingItemByLayer(9);
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
_loc2_ = pickRandomClothingItemByLayer(10);
|
||||
}
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_.pushAccItem(_loc2_);
|
||||
}
|
||||
}
|
||||
if(_loc3_.length > _avatar.avatarData.inventoryBodyMod.numItems)
|
||||
{
|
||||
_avatar.avatarData.itemResponseIntegrate(_loc3_);
|
||||
}
|
||||
pickRandomColors();
|
||||
pickEyeAndPattern();
|
||||
}
|
||||
}
|
||||
|
||||
public function initFinalize(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_avatar != null)
|
||||
{
|
||||
_avatar.InitFallingPhantomsAvatarView();
|
||||
_playerLayer.addChild(_avatar);
|
||||
if(_localPlayer && !_isAI)
|
||||
{
|
||||
_playerLayer.parent.setChildIndex(_playerLayer,_playerLayer.parent.numChildren - 1);
|
||||
}
|
||||
if(_isAI)
|
||||
{
|
||||
initAIAccessories();
|
||||
}
|
||||
_loc2_ = new Array(2);
|
||||
_loc2_[0] = 14;
|
||||
_loc2_[1] = 9;
|
||||
_avatar.preloadAnims(_loc2_,redrawCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private function isSafe(param1:Number) : Boolean
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc2_:Object = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:Boolean = true;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _theGame._phantoms.length)
|
||||
{
|
||||
_loc2_ = _theGame._phantoms[_loc7_];
|
||||
if(_loc2_.y > _phantomThreshold)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
do
|
||||
{
|
||||
_loc4_ = _loc2_.rectangle.x - _loc2_.velX * _loc6_ * 0.04;
|
||||
_loc5_ = 520 - _loc2_.velY * _loc6_ * 0.04;
|
||||
if(520 - _loc5_ >= (_loc2_.rectangle.height + _avatar.rectangle.height) * 0.5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(Math.abs(_loc4_ - param1) < (_loc2_.rectangle.width + _avatar.rectangle.width + 40) * 0.5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while(++_loc6_ < 10);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function setGoto() : void
|
||||
{
|
||||
if(_aiProfile)
|
||||
{
|
||||
if(_aiProfile._type == 0)
|
||||
{
|
||||
_gotoX = _aiGameRandomizer.float(30,870);
|
||||
_gotoTimer = _aiGameRandomizer.float(1,5);
|
||||
}
|
||||
else if(_aiProfile._type == 1)
|
||||
{
|
||||
findSafeGoto();
|
||||
}
|
||||
else
|
||||
{
|
||||
findSafeGoto();
|
||||
}
|
||||
}
|
||||
if(_gotoX < _avatar.x)
|
||||
{
|
||||
_moveLeft = true;
|
||||
_moveRight = false;
|
||||
}
|
||||
else if(_gotoX > _avatar.x)
|
||||
{
|
||||
_moveRight = true;
|
||||
_moveLeft = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_moveRight = _moveLeft = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function findSafeGoto() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc4_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc8_:Array = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:* = 0;
|
||||
if(_aiProfile._type == 1)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
else if(_aiProfile._type == 2)
|
||||
{
|
||||
_loc1_ = 150;
|
||||
}
|
||||
if(!isSafe(_avatar.x))
|
||||
{
|
||||
_loc8_ = [];
|
||||
_loc3_ = _aiGameRandomizer.float(0,20);
|
||||
_loc4_ = 0;
|
||||
_loc5_ = 0;
|
||||
do
|
||||
{
|
||||
_loc7_ = _avatar.rectangle.width * _loc4_ * 0.5 + _loc3_ + 30;
|
||||
if(_loc7_ < 870)
|
||||
{
|
||||
_loc8_[_loc5_] = {};
|
||||
_loc8_[_loc5_].x = _loc7_;
|
||||
_loc8_[_loc5_].distance = Math.abs(_avatar.x - _loc8_[_loc5_].x);
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
while(_loc7_ < 870);
|
||||
if(_theGame._phantoms.length > 1)
|
||||
{
|
||||
_loc8_.sortOn("distance",[16]);
|
||||
}
|
||||
else
|
||||
{
|
||||
randomizeArray(_loc8_);
|
||||
}
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc8_.length)
|
||||
{
|
||||
_loc2_ = _loc4_;
|
||||
if(isSafe(_loc8_[_loc2_].x))
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_ = -1;
|
||||
_loc4_++;
|
||||
}
|
||||
if(_loc2_ >= 0)
|
||||
{
|
||||
_gotoX = Math.min(Math.max(_loc8_[_loc2_].x,30),870);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gotoX = _avatar.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_gotoX = _avatar.x;
|
||||
}
|
||||
}
|
||||
|
||||
public function randomizeArray(param1:Array) : Array
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:* = undefined;
|
||||
var _loc5_:Number = param1.length - 1;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc5_)
|
||||
{
|
||||
_loc2_ = Math.round(_aiGameRandomizer.random() * _loc5_);
|
||||
_loc3_ = param1[_loc4_];
|
||||
param1[_loc4_] = param1[_loc2_];
|
||||
param1[_loc2_] = _loc3_;
|
||||
_loc4_++;
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function init(param1:Sprite) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Avatar = new Avatar();
|
||||
_avatar = new FallingPhantomsAvatarView();
|
||||
_avatar.init(_loc3_);
|
||||
_playerLayer = param1;
|
||||
_playerLayer.visible = false;
|
||||
_playerLeft = false;
|
||||
if(_aiGameRandomizer)
|
||||
{
|
||||
_avatar.x = _aiGameRandomizer.float(30,870);
|
||||
_gotoTimer = _aiGameRandomizer.float(0.01,1);
|
||||
_gotoX = _avatar.x;
|
||||
_phantomThreshold = _aiGameRandomizer.float(150,250);
|
||||
}
|
||||
else
|
||||
{
|
||||
_avatar.x = _gotoX;
|
||||
}
|
||||
_avatar.y = 525;
|
||||
_avatar.rectangle = new Shape();
|
||||
_avatar.rectangle.graphics.beginFill(16711680);
|
||||
_avatar.rectangle.graphics.drawRect(-35,-50,70,100);
|
||||
_avatar.rectangle.graphics.endFill();
|
||||
_avatar.rectangle.alpha = 0.4;
|
||||
_playerLayer.addChild(_avatar.rectangle);
|
||||
_avatar.rectangle.visible = _theGame._showBBs;
|
||||
if(_isAI)
|
||||
{
|
||||
_loc2_ = int(_avatarArray[_aiGameRandomizer.integer(0,_avatarArray.length - 1)]);
|
||||
_loc3_.init(-1,"FallingPhantomsAI",_loc2_,[0,0,0]);
|
||||
_loc3_.itemResponseIntegrate(ItemXtCommManager.generateBodyModList(_loc2_,0,0,false));
|
||||
}
|
||||
else if(_avID != -1)
|
||||
{
|
||||
_loc3_.init(_avID,"FallingPhantoms",_type,_colors,_customAvId,null,_userName);
|
||||
AvatarXtCommManager.requestADForAvatar(_avID,true,initFinalize,_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
private function redrawCallback(param1:LayerAnim) : void
|
||||
{
|
||||
if(param1 && _avatar)
|
||||
{
|
||||
playAnimationState(14);
|
||||
_animsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function receivePositionData(param1:int, param2:int) : void
|
||||
{
|
||||
_avatar.x = param1;
|
||||
if(param2 == 0)
|
||||
{
|
||||
_moveLeft = true;
|
||||
_moveRight = false;
|
||||
}
|
||||
else if(param2 == 1)
|
||||
{
|
||||
_moveRight = true;
|
||||
_moveLeft = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_moveLeft = _moveRight = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove(param1:Boolean = false) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(_avatar && !_dead)
|
||||
{
|
||||
if(!param1)
|
||||
{
|
||||
_loc2_ = GETDEFINITIONBYNAME("fallingPhantoms_deathPath");
|
||||
_theGame._layerPlayer.addChild(_loc2_ as DisplayObject);
|
||||
_loc2_.x = _avatar.x;
|
||||
_loc2_.y = _avatar.y;
|
||||
_loc2_.deathAnimation.addChild(_avatar);
|
||||
_avatar.x = _avatar.y = 0;
|
||||
_loc2_.gotoAndPlay("die");
|
||||
_dead = true;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFPStingerDeath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_avatar.rectangle.parent.removeChild(_avatar.rectangle);
|
||||
if(_avatar.parent)
|
||||
{
|
||||
_avatar.parent.removeChild(_avatar);
|
||||
}
|
||||
_avatar.destroy();
|
||||
_avatar = null;
|
||||
}
|
||||
}
|
||||
if(_replacedAvatar)
|
||||
{
|
||||
if(_replacedAvatar.parent)
|
||||
{
|
||||
_replacedAvatar.parent.removeChild(_replacedAvatar);
|
||||
}
|
||||
_replacedAvatar.destroy();
|
||||
_replacedAvatar = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function cleanup() : void
|
||||
{
|
||||
if(_avatar)
|
||||
{
|
||||
if(_avatar.rectangle && _avatar.rectangle.parent)
|
||||
{
|
||||
_avatar.rectangle.parent.removeChild(_avatar.rectangle);
|
||||
}
|
||||
if(_avatar.parent)
|
||||
{
|
||||
_avatar.parent.removeChild(_avatar);
|
||||
}
|
||||
_avatar.destroy();
|
||||
_avatar = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeatIntro(param1:Number) : Boolean
|
||||
{
|
||||
if(_avatar != null)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCollisionOffsetX() : Number
|
||||
{
|
||||
switch(_currentAnim - 9)
|
||||
{
|
||||
case 0:
|
||||
return 10 * _avatar.scaleX;
|
||||
case 5:
|
||||
return 20 * _avatar.scaleX;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Number = NaN;
|
||||
if(_animsLoaded == true)
|
||||
{
|
||||
if(_localPlayer)
|
||||
{
|
||||
_avatar.rectangle.x = _avatar.x;
|
||||
_avatar.rectangle.y = _avatar.y;
|
||||
switch(_currentAnim - 9)
|
||||
{
|
||||
case 0:
|
||||
_avatar.rectangle.x -= getCollisionOffsetX();
|
||||
break;
|
||||
case 5:
|
||||
_avatar.rectangle.x -= getCollisionOffsetX();
|
||||
}
|
||||
if(_isAI)
|
||||
{
|
||||
if(_gotoTimer > 0)
|
||||
{
|
||||
_gotoTimer -= param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = Math.abs(_avatar.x - _gotoX);
|
||||
move(param1,_moveLeft,_moveRight);
|
||||
if(Math.abs(_avatar.x - _gotoX) >= _loc2_)
|
||||
{
|
||||
_avatar.x = _gotoX;
|
||||
setGoto();
|
||||
move(param1,false,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
move(param1,_theGame._leftArrow,_theGame._rightArrow);
|
||||
}
|
||||
if(_debugCircle)
|
||||
{
|
||||
_debugCircle.x = _avatar.x;
|
||||
_debugCircle.y = _avatar.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
move(param1,_moveLeft,_moveRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function move(param1:Number, param2:Boolean, param3:Boolean) : void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_avatar.x -= param1 * 250;
|
||||
_avatar.scaleX = -1;
|
||||
playAnimationState(9);
|
||||
if(_avatar.x < 30)
|
||||
{
|
||||
_avatar.x = 30;
|
||||
playAnimationState(14);
|
||||
}
|
||||
}
|
||||
else if(param3)
|
||||
{
|
||||
_avatar.x += param1 * 250;
|
||||
_avatar.scaleX = 1;
|
||||
playAnimationState(9);
|
||||
if(_avatar.x > 870)
|
||||
{
|
||||
_avatar.x = 870;
|
||||
playAnimationState(14);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
playAnimationState(14);
|
||||
}
|
||||
}
|
||||
|
||||
private function playAnimationState(param1:int) : void
|
||||
{
|
||||
var _loc2_:Function = null;
|
||||
var _loc3_:int = 0;
|
||||
if(_currentAnim != param1 && _avatar)
|
||||
{
|
||||
_avatar.playAnim(param1,false,_loc3_,_loc2_);
|
||||
_currentAnim = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAIRandomizer(param1:int) : void
|
||||
{
|
||||
_aiRandomizer = new RandomSeed(param1);
|
||||
_aiProfile = _theGame._aiProfiles[_aiRandomizer.integer(0,_theGame._aiProfiles.length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,68 @@
|
||||
package game.fashionShow
|
||||
{
|
||||
import avatar.AccessoryState;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import collection.AccItemCollection;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import item.Item;
|
||||
|
||||
public class FashionShowAvatarEditorView extends AvatarView
|
||||
{
|
||||
|
||||
public function FashionShowAvatarEditorView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function init(param1:Avatar, param2:Function = null, param3:Function = null) : void
|
||||
{
|
||||
_avatar = param1;
|
||||
_avatar.addEventListener("OnAvatarChanged",avatarChanged,false,0,true);
|
||||
_layerAnim = LayerAnim.getNew();
|
||||
_layerAnim.avDefId = _avatar.avTypeId;
|
||||
_layerAnim.layers = AvatarUtility.layerArrayForItemsAndColors(param1.inventoryClothing.itemCollection,param1.colors,param1.perUserAvId);
|
||||
this.addChild(_layerAnim.bitmap);
|
||||
}
|
||||
|
||||
override public function destroy(param1:Boolean = false) : void
|
||||
{
|
||||
this.removeChild(_layerAnim.bitmap);
|
||||
_avatar.removeEventListener("OnAvatarChanged",avatarChanged);
|
||||
LayerAnim.destroy(_layerAnim);
|
||||
_layerAnim = null;
|
||||
}
|
||||
|
||||
public function get colors() : Array
|
||||
{
|
||||
return _avatar.colors;
|
||||
}
|
||||
|
||||
public function set colors(param1:Array) : void
|
||||
{
|
||||
_avatar.colors = param1;
|
||||
}
|
||||
|
||||
public function get accState() : AccessoryState
|
||||
{
|
||||
return _avatar.accState;
|
||||
}
|
||||
|
||||
public function get clothingItemArray() : AccItemCollection
|
||||
{
|
||||
return _avatar.inventoryClothing.itemCollection;
|
||||
}
|
||||
|
||||
public function showAccessory(param1:Item, param2:Function = null) : void
|
||||
{
|
||||
_avatar.accStateShowAccessory(param1,param2);
|
||||
}
|
||||
|
||||
public function hideAccessory(param1:Item) : void
|
||||
{
|
||||
_avatar.accStateHideAccessory(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package game.fashionShow
|
||||
{
|
||||
import avatar.AvatarView;
|
||||
import collection.AccItemCollection;
|
||||
|
||||
public class FashionShowPlayer
|
||||
{
|
||||
|
||||
public var pId:int;
|
||||
|
||||
public var positionIndex:int;
|
||||
|
||||
public var sfsId:int;
|
||||
|
||||
public var dbId:int;
|
||||
|
||||
public var _active:Boolean;
|
||||
|
||||
public var customAvId:int;
|
||||
|
||||
public var avtView:AvatarView;
|
||||
|
||||
public var bCorrect:Boolean;
|
||||
|
||||
public var playerBodyModList:AccItemCollection;
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public function FashionShowPlayer()
|
||||
{
|
||||
super();
|
||||
playerBodyModList = null;
|
||||
positionIndex = -1;
|
||||
_active = false;
|
||||
customAvId = -1;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(playerBodyModList)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < playerBodyModList.length)
|
||||
{
|
||||
playerBodyModList.getAccItem(_loc1_).destroy();
|
||||
playerBodyModList.setAccItem(_loc1_,null);
|
||||
_loc1_++;
|
||||
}
|
||||
playerBodyModList = null;
|
||||
}
|
||||
if(avtView)
|
||||
{
|
||||
avtView.destroy();
|
||||
avtView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,433 @@
|
||||
package game.feedingFrenzy
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class FeedingFrenzyFish
|
||||
{
|
||||
|
||||
public static const FISH_NEUTRAL:int = 0;
|
||||
|
||||
public static const FISH_FLEE:int = 1;
|
||||
|
||||
public static const FISH_ATTACK:int = 2;
|
||||
|
||||
public static const GROUP_PATTERN_MULTIPLIER:int = 20;
|
||||
|
||||
public static const GROWTH_THRESHOLD:Array = [400,700,1000];
|
||||
|
||||
public static const GROUP_PATTERN:Array = [[0,-2],[-0.5,-1],[0.5,-1],[-1,0],[0,0],[1,0],[-0.5,1],[0.5,1],[0,2]];
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _theGame:FeedingFrenzy;
|
||||
|
||||
public var _groupParent:FeedingFrenzyFish;
|
||||
|
||||
public var _groupPatternIndex:int;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _gotoPoint:Point = new Point();
|
||||
|
||||
public var _speed:Number;
|
||||
|
||||
public var _defaultSpeed:Number;
|
||||
|
||||
public var _direction:Point = new Point();
|
||||
|
||||
public var _currentSize:int;
|
||||
|
||||
public var _currentGrowthPoints:Number;
|
||||
|
||||
public var _init:Boolean;
|
||||
|
||||
public var _queueDelete:Boolean;
|
||||
|
||||
public var _state:int;
|
||||
|
||||
public var _dist:Point = new Point();
|
||||
|
||||
public var _mouseX:int;
|
||||
|
||||
public var _mouseY:int;
|
||||
|
||||
public var _prevMouseX:int;
|
||||
|
||||
public var _prevMouseY:int;
|
||||
|
||||
public var _checkTimer:Number;
|
||||
|
||||
public function FeedingFrenzyFish(param1:FeedingFrenzy, param2:int = 0, param3:Boolean = true)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_type = param2;
|
||||
_checkTimer = 0;
|
||||
if(param3)
|
||||
{
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
public function setType(param1:int) : void
|
||||
{
|
||||
_type = param1;
|
||||
_clone.fishType(_type);
|
||||
_clone.visible = false;
|
||||
_checkTimer = 0;
|
||||
_theGame._layerPlayer.addChild(_clone as DisplayObject);
|
||||
if(_groupParent == null)
|
||||
{
|
||||
_clone.y = Math.random() * 550;
|
||||
_gotoPoint.y = Math.random() * 550;
|
||||
if(Math.random() < 0.5)
|
||||
{
|
||||
_clone.x = 1000;
|
||||
_gotoPoint.x = -100;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.x = -100;
|
||||
_gotoPoint.x = 1000;
|
||||
}
|
||||
_direction.x = _gotoPoint.x - _clone.x;
|
||||
_direction.y = _gotoPoint.y - _clone.y;
|
||||
_direction.normalize(1);
|
||||
_defaultSpeed = _theGame._fishSpeed[_type] + Math.random() * 10 - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.x = _groupParent._clone.x + GROUP_PATTERN[_groupPatternIndex][0] * 20;
|
||||
_clone.y = _groupParent._clone.y + GROUP_PATTERN[_groupPatternIndex][1] * 20;
|
||||
_defaultSpeed = _theGame._fishSpeed[_type];
|
||||
}
|
||||
_state = 0;
|
||||
_speed = _defaultSpeed;
|
||||
_queueDelete = false;
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
var _loc1_:FeedingFrenzyFish = null;
|
||||
var _loc2_:int = 0;
|
||||
_init = false;
|
||||
if(_type != 7)
|
||||
{
|
||||
_clone = GETDEFINITIONBYNAME("ff_fish");
|
||||
if(_type >= 0)
|
||||
{
|
||||
_clone.fishType(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentSize = _theGame._startingSize[Math.floor(_theGame._currentLevel / 10)][_theGame._currentLevel % 10] - 1;
|
||||
_clone.fishType(_currentSize,true);
|
||||
}
|
||||
_theGame._layerPlayer.addChild(_clone as DisplayObject);
|
||||
if(_type == -1)
|
||||
{
|
||||
_clone.x = 450;
|
||||
_clone.y = 225;
|
||||
_mouseX = _theGame._layerPlayer.mouseX;
|
||||
_mouseY = _theGame._layerPlayer.mouseY;
|
||||
}
|
||||
finishInit();
|
||||
if(_type != -1)
|
||||
{
|
||||
_clone.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone = {};
|
||||
finishInit();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < GROUP_PATTERN.length)
|
||||
{
|
||||
_loc1_ = _theGame.getFish(0,false);
|
||||
_loc1_._groupPatternIndex = _loc2_;
|
||||
_loc1_._groupParent = this;
|
||||
if(_loc1_._clone)
|
||||
{
|
||||
_loc1_.setType(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.init();
|
||||
}
|
||||
_loc1_._clone.visible = true;
|
||||
_theGame._fish.push(_loc1_);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function finishInit() : void
|
||||
{
|
||||
if(_type == -1)
|
||||
{
|
||||
_speed = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_groupParent)
|
||||
{
|
||||
_clone.x = _groupParent._clone.x + GROUP_PATTERN[_groupPatternIndex][0] * 20;
|
||||
_clone.y = _groupParent._clone.y + GROUP_PATTERN[_groupPatternIndex][1] * 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.y = Math.random() * 550;
|
||||
_gotoPoint.y = Math.random() * 550;
|
||||
if(Math.random() < 0.5)
|
||||
{
|
||||
_clone.x = 1000;
|
||||
_gotoPoint.x = -100;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.x = -100;
|
||||
_gotoPoint.x = 1000;
|
||||
}
|
||||
_direction.x = _gotoPoint.x - _clone.x;
|
||||
_direction.y = _gotoPoint.y - _clone.y;
|
||||
_direction.normalize(1);
|
||||
}
|
||||
if(_type != 7)
|
||||
{
|
||||
if(_groupParent)
|
||||
{
|
||||
_speed = _defaultSpeed = _theGame._fishSpeed[_type];
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultSpeed = _theGame._fishSpeed[_type] + Math.random() * 10 - 5;
|
||||
_speed = _defaultSpeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_speed = _theGame._fishSpeed[0] * 0.5;
|
||||
}
|
||||
}
|
||||
_currentGrowthPoints = 0;
|
||||
_queueDelete = false;
|
||||
_init = true;
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number, param2:int) : void
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc5_:FeedingFrenzyFish = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
if(_init)
|
||||
{
|
||||
_loc6_ = Number(_clone.x);
|
||||
_loc7_ = Number(_clone.y);
|
||||
if(_type == -1)
|
||||
{
|
||||
_loc4_ = _mouseX;
|
||||
_loc3_ = _mouseY;
|
||||
_clone.x = _loc6_ + (_loc4_ - _loc6_) * _speed * param1;
|
||||
_clone.y = _loc7_ + (_loc3_ - _loc7_) * _speed * param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_checkTimer -= param1;
|
||||
if(_type == 3)
|
||||
{
|
||||
if(_clone.blowfishSound)
|
||||
{
|
||||
_clone.blowfishSound = false;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameBlowfishPuff);
|
||||
}
|
||||
}
|
||||
if(_state == 0)
|
||||
{
|
||||
_loc4_ = _gotoPoint.x;
|
||||
_loc3_ = _gotoPoint.y;
|
||||
if(_groupParent)
|
||||
{
|
||||
_loc4_ = _gotoPoint.x = _groupParent._clone.x + GROUP_PATTERN[_groupPatternIndex][0] * 20;
|
||||
_loc3_ = _gotoPoint.y = _groupParent._clone.y + GROUP_PATTERN[_groupPatternIndex][1] * 20;
|
||||
_direction.x = _loc4_ - _clone.x;
|
||||
_direction.y = _loc3_ - _clone.y;
|
||||
_direction.normalize(1);
|
||||
_clone.x = _loc6_ + _direction.x * _speed * param1;
|
||||
_clone.y = _loc7_ + _direction.y * _speed * param1;
|
||||
if(Math.abs(_clone.x - _loc4_) > Math.abs(_loc6_ - _loc4_))
|
||||
{
|
||||
_clone.x = _loc4_;
|
||||
}
|
||||
if(Math.abs(_clone.y - _loc3_) > Math.abs(_loc7_ - _loc3_))
|
||||
{
|
||||
_clone.y = _loc3_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.x = _loc6_ + _direction.x * _speed * param1;
|
||||
_clone.y = _loc7_ + _direction.y * _speed * param1;
|
||||
if(Math.abs(_clone.x - _loc4_) > Math.abs(_loc6_ - _loc4_) || Math.abs(_clone.y - _loc3_) > Math.abs(_loc7_ - _loc3_))
|
||||
{
|
||||
if(_clone.x < 0 || _clone.x > 900)
|
||||
{
|
||||
if(_type != 7)
|
||||
{
|
||||
_theGame.removeFish(this);
|
||||
}
|
||||
_theGame._fish.splice(param2,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_state == 1 || _state == 2)
|
||||
{
|
||||
_loc4_ = _gotoPoint.x;
|
||||
_loc3_ = _gotoPoint.y;
|
||||
_clone.x = _loc6_ + _direction.x * _speed * param1;
|
||||
_clone.y = _loc7_ + _direction.y * _speed * param1;
|
||||
if(Math.abs(_clone.x - _loc4_) > Math.abs(_loc6_ - _loc4_) || Math.abs(_clone.y - _loc3_) > Math.abs(_loc7_ - _loc3_))
|
||||
{
|
||||
if(_groupParent)
|
||||
{
|
||||
_checkTimer = 0;
|
||||
}
|
||||
setState(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc4_ - _loc6_ > 0 && _clone.scaleX < 0 || _loc4_ - _loc6_ < 0 && _clone.scaleX > 0)
|
||||
{
|
||||
_clone.scaleX *= -1;
|
||||
_clone.turn();
|
||||
}
|
||||
if(_type == -1 && _clone.alpha == 1)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _theGame._fish.length)
|
||||
{
|
||||
_loc5_ = _theGame._fish[_loc8_];
|
||||
if(_loc5_ != this && _loc5_._type != 7)
|
||||
{
|
||||
_dist.x = _loc5_._clone.x - _clone.x;
|
||||
_dist.y = _loc5_._clone.y - _clone.y;
|
||||
_loc9_ = _loc5_._clone.width * 0.5 + _clone.width * 0.5;
|
||||
if(_currentSize < _loc5_._type && _theGame.boxCollisionTestLocal(_loc5_._clone.collisionMouth,_clone.collision))
|
||||
{
|
||||
_loc5_._clone.eat();
|
||||
_theGame._soundMan.playByName(_theGame._soundNameDeath);
|
||||
_queueDelete = true;
|
||||
}
|
||||
else if(_currentSize >= _loc5_._type && _theGame.boxCollisionTestLocal(_loc5_._clone.collision,_clone.collisionMouth))
|
||||
{
|
||||
_loc5_._queueDelete = true;
|
||||
_clone.eat();
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFishEats);
|
||||
_currentGrowthPoints += _theGame.getGrowthPoints(_loc5_._type);
|
||||
if(_currentGrowthPoints >= GROWTH_THRESHOLD[_theGame._difficulty])
|
||||
{
|
||||
_currentSize = _currentSize + 1;
|
||||
_currentGrowthPoints = 0;
|
||||
_theGame.checkGrowthTarget();
|
||||
}
|
||||
_theGame.updateGrowth();
|
||||
}
|
||||
else if(_dist.length < _loc9_ + 50)
|
||||
{
|
||||
if(_currentSize >= _loc5_._type)
|
||||
{
|
||||
if(_theGame._difficulty > 0)
|
||||
{
|
||||
_loc5_._dist = _dist;
|
||||
_loc5_.setState(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_._dist = _dist;
|
||||
_loc5_.setState(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setState(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = _state;
|
||||
if(_state != param1 && _type != 7)
|
||||
{
|
||||
_state = param1;
|
||||
if(_state == 1)
|
||||
{
|
||||
if(_checkTimer <= 0)
|
||||
{
|
||||
if(Math.random() < 0.5 || _groupParent)
|
||||
{
|
||||
_direction.x = _dist.x;
|
||||
_direction.y = _dist.y;
|
||||
_direction.normalize(1);
|
||||
_speed = _defaultSpeed * 1.5;
|
||||
_gotoPoint.x = _clone.x + _direction.x * 100;
|
||||
_gotoPoint.y = _clone.y + _direction.y * 100;
|
||||
if(_groupParent && _groupParent._checkTimer <= 0 && _groupPatternIndex == 4)
|
||||
{
|
||||
_groupParent._clone.x = _clone.x + _direction.x * 100;
|
||||
_groupParent._clone.y = _clone.y + _direction.y * 100;
|
||||
_groupParent._direction.x = _direction.x;
|
||||
_groupParent._direction.y = _direction.y;
|
||||
_groupParent._gotoPoint.x = _groupParent._clone.x + _direction.x * 1500;
|
||||
_groupParent._gotoPoint.y = _groupParent._clone.y + _direction.y * 1500;
|
||||
_groupParent._checkTimer = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = _loc2_;
|
||||
}
|
||||
_checkTimer = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = _loc2_;
|
||||
}
|
||||
}
|
||||
else if(_state == 2)
|
||||
{
|
||||
_direction.x = -_dist.x;
|
||||
_direction.y = -_dist.y;
|
||||
_direction.normalize(1);
|
||||
_speed = _defaultSpeed * 1.5;
|
||||
_gotoPoint.x = _theGame._player1._clone.x;
|
||||
_gotoPoint.y = _theGame._player1._clone.y;
|
||||
}
|
||||
else if(_state == 0)
|
||||
{
|
||||
_gotoPoint.y = Math.random() * 550;
|
||||
if(Math.random() < 0.5)
|
||||
{
|
||||
_gotoPoint.x = -100;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gotoPoint.x = 1000;
|
||||
}
|
||||
_direction.x = _gotoPoint.x - _clone.x;
|
||||
_direction.y = _gotoPoint.y - _clone.y;
|
||||
_direction.normalize(1);
|
||||
_speed = _defaultSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,65 @@
|
||||
package game.fortSmasher
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Collision.b2ContactPoint;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.Contacts.b2ContactResult;
|
||||
import Box2D.Dynamics.b2ContactListener;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class FortSmasherContactListener extends b2ContactListener
|
||||
{
|
||||
|
||||
public var contactStack:Array = [];
|
||||
|
||||
private var shapeLookup:Dictionary = new Dictionary();
|
||||
|
||||
public function FortSmasherContactListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function Add(param1:b2ContactPoint) : void
|
||||
{
|
||||
var _loc2_:b2Shape = param1.shape1;
|
||||
var _loc3_:b2Shape = param1.shape2;
|
||||
var _loc4_:b2Vec2 = param1.position;
|
||||
if((_loc2_.m_isSensor || _loc3_.m_isSensor) && (_loc2_.m_body.m_userData && _loc2_.m_body.m_userData.name == "ball" || _loc3_.m_body.m_userData && _loc3_.m_body.m_userData.name == "ball"))
|
||||
{
|
||||
contactStack.push(new FortSmasherCustomContactPoint(_loc2_,_loc3_,0,0,_loc4_));
|
||||
}
|
||||
else if(_loc2_.m_body.m_userData && _loc2_.m_body.m_userData.hasOwnProperty("type") && _loc2_.m_body.m_userData.type == 4)
|
||||
{
|
||||
_loc2_.m_body.m_userData.linVelX = _loc2_.m_body.m_linearVelocity.x;
|
||||
_loc2_.m_body.m_userData.linVelY = _loc2_.m_body.m_linearVelocity.y;
|
||||
_loc2_.m_body.m_userData.angVel = _loc2_.m_body.m_angularVelocity;
|
||||
}
|
||||
else if(_loc3_.m_body.m_userData && _loc3_.m_body.m_userData.hasOwnProperty("type") && _loc3_.m_body.m_userData.type == 4)
|
||||
{
|
||||
_loc3_.m_body.m_userData.linVelX = _loc3_.m_body.m_linearVelocity.x;
|
||||
_loc3_.m_body.m_userData.linVelY = _loc3_.m_body.m_linearVelocity.y;
|
||||
_loc3_.m_body.m_userData.angVel = _loc3_.m_body.m_angularVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
shapeLookup = new Dictionary();
|
||||
}
|
||||
|
||||
override public function Result(param1:b2ContactResult) : void
|
||||
{
|
||||
var _loc2_:b2Shape = param1.shape1;
|
||||
var _loc3_:b2Shape = param1.shape2;
|
||||
var _loc5_:Number = param1.normalImpulse;
|
||||
var _loc6_:Number = param1.tangentImpulse;
|
||||
var _loc4_:b2Vec2 = param1.position;
|
||||
if(_loc5_ > 2 && shapeLookup[_loc2_] == null)
|
||||
{
|
||||
shapeLookup[_loc2_] = _loc3_;
|
||||
contactStack.push(new FortSmasherCustomContactPoint(_loc2_,_loc3_,_loc5_,_loc6_,_loc4_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package game.fortSmasher
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class FortSmasherCustomContactPoint
|
||||
{
|
||||
|
||||
public var shape1:b2Shape;
|
||||
|
||||
public var shape2:b2Shape;
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var position:b2Vec2;
|
||||
|
||||
public var velocity:b2Vec2;
|
||||
|
||||
public var normal:b2Vec2;
|
||||
|
||||
public var force:Number;
|
||||
|
||||
public var normalImpulse:Number;
|
||||
|
||||
public var tangentImpulse:Number;
|
||||
|
||||
public function FortSmasherCustomContactPoint(param1:b2Shape, param2:b2Shape, param3:Number, param4:Number, param5:b2Vec2)
|
||||
{
|
||||
super();
|
||||
shape1 = param1;
|
||||
shape2 = param2;
|
||||
position = param5;
|
||||
normalImpulse = param3;
|
||||
tangentImpulse = param4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
package game.fortSmasher
|
||||
{
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class FortSmasherPlayer
|
||||
{
|
||||
|
||||
private static const UPDATE_POSITION_TIME:Number = 0.25;
|
||||
|
||||
public var _theGame:FortSmasher;
|
||||
|
||||
public var _localPlayer:Boolean;
|
||||
|
||||
public var _netID:int;
|
||||
|
||||
public var _playerID:int;
|
||||
|
||||
public var _slingshot:Object;
|
||||
|
||||
public var _fort:Object;
|
||||
|
||||
public var _updatePositionTimer:Number;
|
||||
|
||||
public var _serverPosition:Point;
|
||||
|
||||
public var _lastServerPosition:Point;
|
||||
|
||||
public var _gemCount:int;
|
||||
|
||||
public var _waitingForAllLoaded:Boolean;
|
||||
|
||||
public var _score:int;
|
||||
|
||||
public var _lost:Boolean;
|
||||
|
||||
public var _trailingPosX:Number;
|
||||
|
||||
public var _trailingPosY:Number;
|
||||
|
||||
public var _angleVector:Point;
|
||||
|
||||
public var _pullDistance:Number;
|
||||
|
||||
public var _angle:Number;
|
||||
|
||||
public var _doHeartbeat:Boolean;
|
||||
|
||||
public var _hasTurn:Boolean;
|
||||
|
||||
public var _bodies:Array;
|
||||
|
||||
public var _steps:int;
|
||||
|
||||
public var _projectileType:int;
|
||||
|
||||
public var _trail:Array;
|
||||
|
||||
public var _trailFrames:int;
|
||||
|
||||
public var _makeTrail:Boolean;
|
||||
|
||||
public var _firstShot:Boolean;
|
||||
|
||||
public var _launcherLoaded:Boolean;
|
||||
|
||||
public var _numPhantoms:int;
|
||||
|
||||
public var _anchor:Point;
|
||||
|
||||
public var _hadFirstTurn:Boolean;
|
||||
|
||||
public function FortSmasherPlayer(param1:FortSmasher)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:Array, param3:int, param4:uint) : int
|
||||
{
|
||||
var _loc5_:* = null;
|
||||
_serverPosition = new Point();
|
||||
_lastServerPosition = new Point();
|
||||
_playerID = param1;
|
||||
_netID = parseInt(param2[param3++]);
|
||||
_bodies = [];
|
||||
setProjectileType(0);
|
||||
_slingshot = _theGame.getScene().getLayer("slingshot" + (param1 + 1));
|
||||
_fort = _theGame.getScene().getLayer("forts" + (param1 + 1));
|
||||
_hasTurn = false;
|
||||
if(_playerID == 0)
|
||||
{
|
||||
_theGame._layerFort1.addChild(_fort.loader);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._layerFort2.addChild(_fort.loader);
|
||||
}
|
||||
_anchor = new Point();
|
||||
_anchor.x = _slingshot.loader.x;
|
||||
_anchor.y = _slingshot.loader.y - 60;
|
||||
param3++;
|
||||
param3++;
|
||||
_gemCount = 0;
|
||||
_score = 0;
|
||||
_updatePositionTimer = 0;
|
||||
_waitingForAllLoaded = false;
|
||||
_lost = false;
|
||||
_doHeartbeat = true;
|
||||
_theGame._layerPlayers.addChild(_slingshot.loader);
|
||||
_slingshot.loader.content.launcher.loadLauncher(0);
|
||||
_slingshot.loader.content.launcher.stretch(0,0);
|
||||
_trail = [];
|
||||
_trailFrames = 1;
|
||||
_firstShot = true;
|
||||
_launcherLoaded = false;
|
||||
_numPhantoms = 0;
|
||||
_pullDistance = -1;
|
||||
_hadFirstTurn = false;
|
||||
if(param1 == 1)
|
||||
{
|
||||
_slingshot.loader.scaleX = -1;
|
||||
}
|
||||
_angleVector = new Point();
|
||||
_localPlayer = _theGame.myId == _netID;
|
||||
if(_localPlayer)
|
||||
{
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.player(_playerID + 1);
|
||||
if(_theGame._totalPlayers == 2)
|
||||
{
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.addEventListener("exitFrame",UILoaded);
|
||||
}
|
||||
}
|
||||
_trailingPosX = 600;
|
||||
_trailingPosY = 0;
|
||||
return param3;
|
||||
}
|
||||
|
||||
public function createBody(param1:b2Body) : void
|
||||
{
|
||||
var _loc2_:Object = {};
|
||||
_loc2_.body = param1;
|
||||
_loc2_.deleteTimer = 0;
|
||||
_bodies.push(_loc2_);
|
||||
}
|
||||
|
||||
public function isCurrentBody(param1:b2Body) : Boolean
|
||||
{
|
||||
var _loc2_:int = int(_bodies.length);
|
||||
if(_bodies[_loc2_ - 1].body == param1 || param1.m_userData.type == 5 && _loc2_ >= 3 && (_bodies[_loc2_ - 2].body == param1 || _bodies[_loc2_ - 3].body == param1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function UILoaded(param1:Event) : void
|
||||
{
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.removeEventListener("exitFrame",UILoaded);
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.counter1Cont.counter1.visible = false;
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.counter2Cont.counter2.visible = false;
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.counter3Cont.counter3.visible = false;
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.counter4Cont.counter4.visible = false;
|
||||
_theGame.getScene().getLayer("fort_ui").loader.content.counter5Cont.counter5.visible = false;
|
||||
}
|
||||
|
||||
public function destroySleepingBodies() : void
|
||||
{
|
||||
var _loc1_:b2Body = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Boolean = false;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _bodies.length)
|
||||
{
|
||||
_loc1_ = _bodies[_loc3_].body;
|
||||
if(_bodies[_loc3_].deleteTimer == 0)
|
||||
{
|
||||
if(_loc1_.IsSleeping() || _loc1_.m_linearVelocity.LengthSquared() <= 1 && Math.abs(_loc1_.m_angularVelocity) <= 0.1)
|
||||
{
|
||||
_bodies[_loc3_].deleteTimer = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_bodies[_loc3_].deleteTimer -= _theGame._timeStep * 2;
|
||||
if(_bodies[_loc3_].deleteTimer <= 0)
|
||||
{
|
||||
if(_loc1_.IsSleeping() || _loc1_.m_linearVelocity.LengthSquared() <= 1 && Math.abs(_loc1_.m_angularVelocity) <= 0.1)
|
||||
{
|
||||
_theGame._world.DestroyBody(_loc1_);
|
||||
_loc1_.m_userData.loader.content.destroy();
|
||||
_theGame._projectilePool.push(_loc1_.m_userData);
|
||||
_bodies.splice(_loc3_,1);
|
||||
_loc3_--;
|
||||
_loc2_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bodies[_loc3_].deleteTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_loc2_)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFruitSplat);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroyBody(param1:b2Body = null) : void
|
||||
{
|
||||
var _loc2_:b2Body = null;
|
||||
var _loc3_:int = 0;
|
||||
if(!param1)
|
||||
{
|
||||
if(_bodies.length > 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFruitSplat);
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _bodies.length)
|
||||
{
|
||||
_loc2_ = _bodies[_loc3_].body;
|
||||
_theGame._world.DestroyBody(_loc2_);
|
||||
_loc2_.m_userData.loader.content.destroy();
|
||||
_theGame._projectilePool.push(_loc2_.m_userData);
|
||||
_loc3_++;
|
||||
}
|
||||
_bodies.splice(0,_bodies.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _bodies.length)
|
||||
{
|
||||
_loc2_ = _bodies[_loc3_].body;
|
||||
if(param1 == _loc2_)
|
||||
{
|
||||
_theGame._world.DestroyBody(_loc2_);
|
||||
_loc2_.m_userData.loader.content.destroy();
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFruitSplat);
|
||||
_bodies.splice(_loc3_,1);
|
||||
_theGame._projectilePool.push(_loc2_.m_userData);
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isPlayerBody(param1:b2Body) : Boolean
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _bodies.length)
|
||||
{
|
||||
if(param1 == _bodies[_loc2_].body)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setProjectileType(param1:int, param2:Boolean = false) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
if(_projectileType != param1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFruitReload);
|
||||
if(_localPlayer && _theGame._totalPlayers == 2)
|
||||
{
|
||||
_loc3_ = [];
|
||||
_loc3_[0] = "setType";
|
||||
_loc3_[1] = String(param1);
|
||||
_theGame.messageServer(_loc3_);
|
||||
}
|
||||
}
|
||||
else if(param2)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameFruitReload);
|
||||
}
|
||||
_projectileType = param1;
|
||||
if(_slingshot)
|
||||
{
|
||||
_slingshot.loader.content.launcher.loadLauncher(_projectileType + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc5_:Point = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
if(!_waitingForAllLoaded && _doHeartbeat)
|
||||
{
|
||||
if(_localPlayer)
|
||||
{
|
||||
if(_hasTurn && _launcherLoaded && _theGame._gameState == 4 && !_theGame.DESIGN_MODE)
|
||||
{
|
||||
_lastServerPosition.x = _serverPosition.x;
|
||||
_lastServerPosition.y = _serverPosition.y;
|
||||
_serverPosition.x = _trailingPosX = _theGame.stage.mouseX / _theGame._layerPlayers.scaleX - _theGame._layerPlayers.x;
|
||||
_serverPosition.y = _trailingPosY = (_theGame.stage.mouseY - _theGame._layerPlayers.y) / _theGame._layerPlayers.scaleY;
|
||||
if(_theGame._totalPlayers > 1)
|
||||
{
|
||||
_updatePositionTimer += param1;
|
||||
if(_updatePositionTimer > 0.25 && (_lastServerPosition.x != _serverPosition.x || _lastServerPosition.y != _serverPosition.y))
|
||||
{
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "pos";
|
||||
_loc2_[1] = String(int(_serverPosition.x));
|
||||
_loc2_[2] = String(int(_serverPosition.y));
|
||||
_theGame.messageServer(_loc2_);
|
||||
_updatePositionTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = new Point();
|
||||
_launcherLoaded = true;
|
||||
_loc5_.x = _trailingPosX;
|
||||
_loc5_.y = _trailingPosY;
|
||||
_loc3_ = Point.distance(_loc5_,_serverPosition);
|
||||
_loc4_ = 0.25;
|
||||
_trailingPosX += (_serverPosition.x - _trailingPosX) * _loc4_;
|
||||
_trailingPosY += (_serverPosition.y - _trailingPosY) * _loc4_;
|
||||
}
|
||||
if(_hasTurn && _launcherLoaded)
|
||||
{
|
||||
_anchor.x = _slingshot.loader.x;
|
||||
_anchor.y = _slingshot.loader.y - 60;
|
||||
_loc6_ = _angle;
|
||||
_angle = Math.atan2(_trailingPosY - _anchor.y,_trailingPosX - _anchor.x);
|
||||
_pullDistance = Math.min(Math.sqrt((_trailingPosY - _anchor.y) * (_trailingPosY - _anchor.y) + (_trailingPosX - _anchor.x) * (_trailingPosX - _anchor.x)),80);
|
||||
if(_pullDistance < 20)
|
||||
{
|
||||
_pullDistance = 20;
|
||||
_angle = _loc6_;
|
||||
}
|
||||
if(_playerID == 0)
|
||||
{
|
||||
if(_angle < 3.141592653589793 * 0.5 && _angle >= 0)
|
||||
{
|
||||
_angle -= 3.141592653589793;
|
||||
}
|
||||
else if(_angle > -1.5707963267948966 && _angle < 0)
|
||||
{
|
||||
_angle += 3.141592653589793;
|
||||
}
|
||||
if(_angle <= -1.5707963267948966 && _angle > -2.891592653589793)
|
||||
{
|
||||
_angle = Math.abs(-1.5707963267948966 - _angle) > Math.abs(-2.891592653589793 - _angle) ? -2.891592653589793 : 3.141592653589793 * 0.5;
|
||||
}
|
||||
_slingshot.loader.content.launcher.stretch(_angle * 180 / 3.141592653589793 + 180,_pullDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_angle >= 3.141592653589793 * 0.5)
|
||||
{
|
||||
_angle -= 3.141592653589793;
|
||||
}
|
||||
else if(_angle < -1.5707963267948966)
|
||||
{
|
||||
_angle += 3.141592653589793;
|
||||
}
|
||||
if(_angle >= -1.5707963267948966 && _angle < -0.25)
|
||||
{
|
||||
_angle = Math.abs(-1.5707963267948966 - _angle) > Math.abs(-0.25 - _angle) ? -0.25 : 3.141592653589793 * 0.5;
|
||||
}
|
||||
_slingshot.loader.content.launcher.stretch(-_angle * 180 / 3.141592653589793,_pullDistance);
|
||||
}
|
||||
_angleVector.x = Math.cos(_angle);
|
||||
_angleVector.y = Math.sin(_angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function receivePositionData(param1:Array, param2:int) : int
|
||||
{
|
||||
_serverPosition.x = int(param1[param2++]);
|
||||
_serverPosition.y = int(param1[param2++]);
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function receiveShootData(param1:Array, param2:int) : int
|
||||
{
|
||||
_pullDistance = param1[param2++];
|
||||
_angle = param1[param2++];
|
||||
_projectileType = param1[param2++];
|
||||
shoot(false);
|
||||
_theGame._clusterSteps = param1[param2++];
|
||||
if(_theGame._clusterSteps > 0)
|
||||
{
|
||||
_theGame._queueCluster = true;
|
||||
}
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function removeTrail() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _trail.length)
|
||||
{
|
||||
if(_trail[_loc1_].parent)
|
||||
{
|
||||
_trail[_loc1_].parent.removeChild(_trail[_loc1_]);
|
||||
}
|
||||
_theGame._trailDotPool.push(_trail[_loc1_]);
|
||||
_loc1_++;
|
||||
}
|
||||
_trail.splice(0,_trail.length);
|
||||
}
|
||||
|
||||
public function shoot(param1:Boolean) : void
|
||||
{
|
||||
if(!_theGame.DESIGN_MODE)
|
||||
{
|
||||
if(_localPlayer)
|
||||
{
|
||||
_makeTrail = true;
|
||||
removeTrail();
|
||||
_slingshot.loader.content.previewOff();
|
||||
}
|
||||
_steps = 0;
|
||||
_doHeartbeat = false;
|
||||
_theGame.createBall(this,_projectileType);
|
||||
_theGame.launchBall(this,_pullDistance,_angle,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,218 @@
|
||||
package game.gemBreaker
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class GemBreakerGem
|
||||
{
|
||||
|
||||
public static const GEMSTATE_READY:int = 0;
|
||||
|
||||
public static const GEMSTATE_CHECKED:int = 1;
|
||||
|
||||
public static const GEMSTATE_FALLING:int = 2;
|
||||
|
||||
private var _theGame:GemBreaker;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _moveDirection:Point;
|
||||
|
||||
public var _targetLocation:Point;
|
||||
|
||||
public var _targetRowColumn:Point;
|
||||
|
||||
private var _moving:Boolean;
|
||||
|
||||
private var _movingFinal:Boolean;
|
||||
|
||||
private var _velocity:Number;
|
||||
|
||||
public var _state:int;
|
||||
|
||||
public var _player:GemBreakerPlayer;
|
||||
|
||||
public var _distanceToTravel:Number;
|
||||
|
||||
public var _distanceTraveled:Number;
|
||||
|
||||
public var _distanceDropoff:Number;
|
||||
|
||||
public var _bRandom:Boolean;
|
||||
|
||||
public function GemBreakerGem(param1:GemBreaker, param2:int, param3:GemBreakerPlayer)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_type = param2;
|
||||
_moveDirection = new Point();
|
||||
_targetLocation = new Point();
|
||||
_targetRowColumn = new Point();
|
||||
_moving = false;
|
||||
_player = param3;
|
||||
init();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
_clone = _theGame.getScene().cloneAsset("gem");
|
||||
_clone.loader.contentLoaderInfo.addEventListener("complete",onGemLoaderComplete);
|
||||
_state = 0;
|
||||
_bRandom = false;
|
||||
}
|
||||
|
||||
public function reset(param1:int, param2:Boolean) : void
|
||||
{
|
||||
_type = param1;
|
||||
_moving = false;
|
||||
_state = 0;
|
||||
_bRandom = param2;
|
||||
_clone.loader.content.gemColor(_type);
|
||||
_clone.loader.content.gemBlur(0,0,0);
|
||||
if(_bRandom)
|
||||
{
|
||||
_clone.loader.content.appear();
|
||||
}
|
||||
}
|
||||
|
||||
public function onGemLoaderComplete(param1:Event) : void
|
||||
{
|
||||
_clone.loader.content.gemColor(_type);
|
||||
if(_bRandom)
|
||||
{
|
||||
_clone.loader.content.appear();
|
||||
}
|
||||
_clone.loader.contentLoaderInfo.removeEventListener("complete",onGemLoaderComplete);
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
if(_clone.loader && _clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMoving() : void
|
||||
{
|
||||
_moving = true;
|
||||
_movingFinal = false;
|
||||
_velocity = 1000;
|
||||
_distanceTraveled = 0;
|
||||
_state = 0;
|
||||
}
|
||||
|
||||
public function moveStep(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(_moving)
|
||||
{
|
||||
if(_distanceToTravel < 125)
|
||||
{
|
||||
_velocity -= 3000 * param1;
|
||||
if(_velocity < 300)
|
||||
{
|
||||
_velocity += 3000 * param1;
|
||||
}
|
||||
}
|
||||
_clone.loader.x += _moveDirection.x * param1 * _velocity;
|
||||
_clone.loader.y += _moveDirection.y * param1 * _velocity;
|
||||
_distanceToTravel -= param1 * _velocity;
|
||||
_distanceTraveled += param1 * _velocity;
|
||||
_loc2_ = Math.atan2(_moveDirection.y,_moveDirection.x) * 180 / 3.141592653589793 + 90;
|
||||
_clone.loader.content.gemBlur(0.75,0.5,_loc2_);
|
||||
if(_clone.loader.x < 55 + _player._xOffset && _moveDirection.x < 0 || _clone.loader.x > 360 + _player._xOffset && _moveDirection.x > 0)
|
||||
{
|
||||
_moveDirection.x *= -1;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameCollision1);
|
||||
}
|
||||
if(_clone.loader.y < 30 || _distanceToTravel <= 5)
|
||||
{
|
||||
_movingFinal = true;
|
||||
_moving = false;
|
||||
_moveDirection.x = _targetLocation.x - _clone.loader.x;
|
||||
_moveDirection.y = _targetLocation.y - _clone.loader.y;
|
||||
_moveDirection.normalize(1);
|
||||
_velocity = 0;
|
||||
_clone.loader.content.gemBlur(0,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setState(param1:int) : void
|
||||
{
|
||||
if(param1 == 2)
|
||||
{
|
||||
_velocity = 0;
|
||||
}
|
||||
_state = param1;
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:Point = null;
|
||||
var _loc3_:int = 0;
|
||||
if(_moving)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 4)
|
||||
{
|
||||
moveStep(param1 / 4);
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
if(_movingFinal)
|
||||
{
|
||||
_player._flyingGems.splice(_player._flyingGems.indexOf(this),1);
|
||||
_clone.loader.x = _targetLocation.x;
|
||||
_clone.loader.y = _targetLocation.y;
|
||||
_loc4_ = _player._gemGrid.getGridCoords(this,_theGame.getScene().getLayer("gem").loader.width);
|
||||
_loc3_ = _player.placeGem(_loc4_.x,_loc4_.y,this,true);
|
||||
_player.score(_loc3_);
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameGemBreak);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameCollision1);
|
||||
}
|
||||
_movingFinal = false;
|
||||
}
|
||||
if(_state == 2)
|
||||
{
|
||||
_velocity += 1000 * param1;
|
||||
_clone.loader.y += param1 * _velocity;
|
||||
if(_clone.loader.y > 650)
|
||||
{
|
||||
if(_clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
}
|
||||
_player.removeGem(this);
|
||||
}
|
||||
}
|
||||
else if(_state == 1)
|
||||
{
|
||||
if(_clone.loader.content.finished)
|
||||
{
|
||||
if(_clone.loader.parent)
|
||||
{
|
||||
_clone.loader.parent.removeChild(_clone.loader);
|
||||
}
|
||||
_player._gemPoolTemp.splice(_player._gemPoolTemp.indexOf(this),1);
|
||||
_player.safePush(_player._gemPool,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function canRecycle() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
package game.gemBreaker
|
||||
{
|
||||
import flash.geom.Point;
|
||||
|
||||
public class GemBreakerGrid
|
||||
{
|
||||
|
||||
public static const CIRCLE_YSHIFT:Number = 0.86602540378444;
|
||||
|
||||
private var _data:Array;
|
||||
|
||||
private var _counter:int;
|
||||
|
||||
private var _hasShifted:Boolean;
|
||||
|
||||
public function GemBreakerGrid()
|
||||
{
|
||||
super();
|
||||
_data = [];
|
||||
_hasShifted = false;
|
||||
}
|
||||
|
||||
public function length() : int
|
||||
{
|
||||
return _data.length;
|
||||
}
|
||||
|
||||
public function getRowLength(param1:int) : int
|
||||
{
|
||||
return _data[param1] ? _data[param1].length : 0;
|
||||
}
|
||||
|
||||
public function isRowEmpty(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(_data[param1] != null)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _data[param1].length)
|
||||
{
|
||||
if(_data[param1][_loc2_] != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function put(param1:int, param2:int, param3:GemBreakerGem) : Boolean
|
||||
{
|
||||
param3._state = 0;
|
||||
if(param1 >= 0 && _data[param1] == null)
|
||||
{
|
||||
_data[param1] = [];
|
||||
}
|
||||
if(_data[param1][param2] == null)
|
||||
{
|
||||
_data[param1][param2] = param3;
|
||||
return true;
|
||||
}
|
||||
return _data[param1][param2] == param3;
|
||||
}
|
||||
|
||||
public function dropDisconnectedElements() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _data[0].length)
|
||||
{
|
||||
if(_data[0][_loc1_] != null)
|
||||
{
|
||||
markHangingElements(0,_loc1_);
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _data.length)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_data[_loc1_] != null && _loc2_ < _data[_loc1_].length)
|
||||
{
|
||||
if(_data[_loc1_][_loc2_] != null)
|
||||
{
|
||||
if(_data[_loc1_][_loc2_]._state != 1)
|
||||
{
|
||||
_data[_loc1_][_loc2_].setState(2);
|
||||
_data[_loc1_][_loc2_] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data[_loc1_][_loc2_]._state = 0;
|
||||
}
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function markHangingElements(param1:int, param2:int) : void
|
||||
{
|
||||
if(param1 < 0 || param2 < 0 || _data[param1] == null || _data[param1][param2] == null || _data[param1][param2]._state != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_data[param1][param2]._state = 1;
|
||||
markHangingElements(param1,param2 - 1);
|
||||
markHangingElements(param1,param2 + 1);
|
||||
markHangingElements(param1 - 1,param2);
|
||||
markHangingElements(param1 + 1,param2);
|
||||
markHangingElements(param1 - 1,param2 + (param1 % 2 == hasShifted() ? -1 : 1));
|
||||
markHangingElements(param1 + 1,param2 + (param1 % 2 == hasShifted() ? -1 : 1));
|
||||
}
|
||||
|
||||
public function eliminateNeighbors(param1:int, param2:int, param3:int = -1) : int
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
if(param1 < 0 || param2 < 0 || _data[param1] == null || _data[param1][param2] == null || _data[param1][param2]._state != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc6_:Boolean = false;
|
||||
if(param3 == -1)
|
||||
{
|
||||
param3 = int(_data[param1][param2]._type);
|
||||
_counter = 0;
|
||||
_loc6_ = true;
|
||||
}
|
||||
if(_data[param1][param2]._type == param3)
|
||||
{
|
||||
_data[param1][param2]._state = 1;
|
||||
_counter = _counter + 1;
|
||||
eliminateNeighbors(param1,param2 - 1,param3);
|
||||
eliminateNeighbors(param1,param2 + 1,param3);
|
||||
eliminateNeighbors(param1 - 1,param2,param3);
|
||||
eliminateNeighbors(param1 + 1,param2,param3);
|
||||
eliminateNeighbors(param1 - 1,param2 + (param1 % 2 == hasShifted() ? -1 : 1),param3);
|
||||
eliminateNeighbors(param1 + 1,param2 + (param1 % 2 == hasShifted() ? -1 : 1),param3);
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _data.length)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_data[_loc4_] != null && _loc5_ < _data[_loc4_].length)
|
||||
{
|
||||
if(_data[_loc4_][_loc5_] != null && _data[_loc4_][_loc5_]._state != 0)
|
||||
{
|
||||
if(_counter >= 3)
|
||||
{
|
||||
_data[_loc4_][_loc5_]._player.removeGem(_data[_loc4_][_loc5_]);
|
||||
_data[_loc4_][_loc5_] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data[_loc4_][_loc5_]._state = 0;
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
dropDisconnectedElements();
|
||||
return _counter >= 3 ? _counter : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function checkCollision(param1:GemBreakerGem, param2:Number, param3:Number, param4:int) : Boolean
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
_loc8_ = _data.length - 1;
|
||||
loop0:
|
||||
while(_loc8_ >= 0)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(true)
|
||||
{
|
||||
if(!(_data[_loc8_] != null && _loc9_ < _data[_loc8_].length))
|
||||
{
|
||||
_loc8_--;
|
||||
continue loop0;
|
||||
}
|
||||
if(_data[_loc8_][_loc9_] != null)
|
||||
{
|
||||
_loc7_ = (_loc9_ + 1) * param2 + (_loc8_ % 2 == hasShifted() ? 0 : param2 / 2) + param3;
|
||||
_loc6_ = (_loc8_ + 1) * param2 * 0.86602540378444;
|
||||
_loc5_ = (_loc7_ - param1._clone.loader.x) * (_loc7_ - param1._clone.loader.x) + (_loc6_ - param1._clone.loader.y) * (_loc6_ - param1._clone.loader.y);
|
||||
if(_loc5_ <= (param2 - param4) * (param2 - param4))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getGridCoords(param1:GemBreakerGem, param2:Number) : Point
|
||||
{
|
||||
var _loc3_:Point = new Point();
|
||||
_loc3_.x = Math.max(Math.round(param1._clone.loader.y / (0.86602540378444 * param2)) - 1,0);
|
||||
_loc3_.y = Math.max(Math.round((param1._clone.loader.x - param1._player._xOffset - (_loc3_.x % 2 == hasShifted() ? 0 : param2 / 2)) / param2) - 1,0);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function getGridCoordsByPos(param1:Number, param2:Number, param3:Number, param4:Number) : Point
|
||||
{
|
||||
var _loc5_:Point = new Point();
|
||||
_loc5_.x = Math.max(Math.round(param2 / (0.86602540378444 * param4)) - 1,0);
|
||||
_loc5_.y = Math.max(Math.round((param1 - param3 - (_loc5_.x % 2 == hasShifted() ? 0 : param4 / 2)) / param4) - 1,0);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public function shiftDown(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
_hasShifted = !_hasShifted;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _data.length)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_data[_loc2_] != null && _loc3_ < _data[_loc2_].length)
|
||||
{
|
||||
if(_data[_loc2_][_loc3_] != null)
|
||||
{
|
||||
_data[_loc2_][_loc3_]._clone.loader.y += 0.86602540378444 * param1;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
_data.unshift([]);
|
||||
}
|
||||
|
||||
public function hasShifted() : int
|
||||
{
|
||||
return int(_hasShifted);
|
||||
}
|
||||
|
||||
public function isOccupied(param1:int, param2:int) : Boolean
|
||||
{
|
||||
return _data[param1] != null && _data[param1][param2] != null;
|
||||
}
|
||||
|
||||
public function clear() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
_hasShifted = false;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _data.length)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
while(_data[_loc1_] != null && _loc2_ < _data[_loc1_].length)
|
||||
{
|
||||
_data[_loc1_][_loc2_] = null;
|
||||
_loc2_++;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getElement(param1:int, param2:int) : Object
|
||||
{
|
||||
if(_data[param1] && _data[param1][param2])
|
||||
{
|
||||
return _data[param1][param2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function numRowElements(param1:int) : int
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(_data[param1])
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _data[param1].length)
|
||||
{
|
||||
if(_data[param1][_loc3_])
|
||||
{
|
||||
_loc2_++;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function rowContainsPropertyValue(param1:int, param2:String, param3:*) : Boolean
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
if(_data[param1])
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _data[param1].length)
|
||||
{
|
||||
if(_data[param1][_loc4_] && _data[param1][_loc4_].hasOwnProperty(param2) && _data[param1][_loc4_][param2] == param3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,457 @@
|
||||
package game.hedgeHog
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class HedgeHogEnemy
|
||||
{
|
||||
|
||||
public static const MODE_ROAM:int = 0;
|
||||
|
||||
public static const MODE_CHASE:int = 1;
|
||||
|
||||
public static const MODE_FEAR:int = 2;
|
||||
|
||||
public static const MODE_DIE:int = 3;
|
||||
|
||||
public static const MODE_WAITING:int = 4;
|
||||
|
||||
private static const RIGHT:int = 0;
|
||||
|
||||
private static const UP:int = 1;
|
||||
|
||||
private static const LEFT:int = 2;
|
||||
|
||||
private static const DOWN:int = 3;
|
||||
|
||||
public var MODE_SWITCH_TIME:int;
|
||||
|
||||
private var _theGame:HedgeHog;
|
||||
|
||||
public var i:int;
|
||||
|
||||
public var j:int;
|
||||
|
||||
public var turnX:Number;
|
||||
|
||||
public var turnY:Number;
|
||||
|
||||
public var turnDirection:int;
|
||||
|
||||
public var _mode:int;
|
||||
|
||||
public var _direction:int;
|
||||
|
||||
public var _clone:Object;
|
||||
|
||||
public var _speed:Number;
|
||||
|
||||
public var _directions:Array = [0,0,0,0];
|
||||
|
||||
public var _detectionRadius:Number;
|
||||
|
||||
public var _detectionObject:Object;
|
||||
|
||||
private var _tempObject:Object = {};
|
||||
|
||||
public var _respawnTime:int;
|
||||
|
||||
private var _respawnTimer:Number;
|
||||
|
||||
private var _forceCheck:Boolean;
|
||||
|
||||
private var _modeSwitchTimer:Number;
|
||||
|
||||
private var _warningPlaying:Boolean;
|
||||
|
||||
public function HedgeHogEnemy(param1:HedgeHog, param2:int, param3:int, param4:Number)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_clone = GETDEFINITIONBYNAME("hedgeHog_enemy");
|
||||
setStartingLocation(param2,param3);
|
||||
MODE_SWITCH_TIME = _theGame._phantomModeSwitchTime;
|
||||
_speed = _theGame._phantomBaseSpeed;
|
||||
_mode = 4;
|
||||
_detectionRadius = 200;
|
||||
_detectionObject = new Sprite();
|
||||
_detectionObject.graphics.beginFill(16711680);
|
||||
_detectionObject.graphics.drawCircle(0,0,_detectionRadius);
|
||||
_detectionObject.graphics.endFill();
|
||||
_detectionObject.alpha = 0.5;
|
||||
_clone.addChild(_detectionObject as DisplayObject);
|
||||
_respawnTime = _theGame._phantomRespawnTime;
|
||||
_respawnTimer = param4;
|
||||
_detectionObject.visible = false;
|
||||
_modeSwitchTimer = MODE_SWITCH_TIME;
|
||||
if(_respawnTimer > _theGame._powerUpWarningTime)
|
||||
{
|
||||
_mode = 4;
|
||||
_clone.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.spawnWarning();
|
||||
}
|
||||
}
|
||||
|
||||
private function setStartingLocation(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
i = param1;
|
||||
j = param2;
|
||||
_theGame.setTurnXY(i,j,this);
|
||||
_clone.x = turnX;
|
||||
_clone.y = turnY;
|
||||
turnX = turnY = -1;
|
||||
_direction = -1;
|
||||
getPossibleDirections();
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 4)
|
||||
{
|
||||
if(_directions[_loc3_] == 1)
|
||||
{
|
||||
_direction = _loc3_;
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
_directions[0] = _directions[1] = _directions[2] = _directions[3] = 0;
|
||||
}
|
||||
|
||||
public function isSeekingPlayer() : Boolean
|
||||
{
|
||||
return _mode == 1 || _mode == 0;
|
||||
}
|
||||
|
||||
public function changeMode(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
if((_mode != param1 || _mode == 2) && _respawnTimer <= 0)
|
||||
{
|
||||
_mode = param1;
|
||||
if(_mode == 2)
|
||||
{
|
||||
_warningPlaying = false;
|
||||
_clone.powerDown();
|
||||
_forceCheck = true;
|
||||
_speed = _theGame._phantomBaseSpeed * 0.5;
|
||||
}
|
||||
else if(_mode == 4)
|
||||
{
|
||||
_respawnTimer = _respawnTime;
|
||||
_loc2_ = _theGame.getPhantomSpawnIndex();
|
||||
_loc3_ = _theGame.getCurrentLevelArray();
|
||||
setStartingLocation(Math.floor(_theGame._phantomSpawnIndices[_loc2_] / _loc3_[0].length),_theGame._phantomSpawnIndices[_loc2_] % _loc3_[0].length);
|
||||
}
|
||||
else if(_mode == 3)
|
||||
{
|
||||
_clone.die();
|
||||
}
|
||||
else
|
||||
{
|
||||
_warningPlaying = false;
|
||||
_speed = _theGame._phantomBaseSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getDistSq(param1:Number, param2:Number) : Number
|
||||
{
|
||||
return (param1 - _theGame._player._clone.x) * (param1 - _theGame._player._clone.x) + (param2 - _theGame._player._clone.y) * (param2 - _theGame._player._clone.y);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc8_:* = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc7_:int = i;
|
||||
var _loc6_:int = j;
|
||||
_theGame.getGridIndices(_clone.x,_clone.y,this);
|
||||
if(_mode == 4)
|
||||
{
|
||||
_respawnTimer -= param1;
|
||||
if(_respawnTimer < _theGame._powerUpWarningTime && !_warningPlaying)
|
||||
{
|
||||
_clone.visible = true;
|
||||
_clone.spawnWarning();
|
||||
_warningPlaying = true;
|
||||
_theGame.playPortal();
|
||||
}
|
||||
if(_respawnTimer <= 0)
|
||||
{
|
||||
_theGame.playPhantomSpawn();
|
||||
_clone.visible = true;
|
||||
_warningPlaying = false;
|
||||
_clone.spawn();
|
||||
if(_theGame._energizerTimer > 2)
|
||||
{
|
||||
changeMode(2);
|
||||
}
|
||||
else if(_theGame._energizerTimer > 0)
|
||||
{
|
||||
changeMode(2);
|
||||
_clone.powerUpWarning();
|
||||
}
|
||||
else
|
||||
{
|
||||
changeMode(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_mode == 3)
|
||||
{
|
||||
if(_clone.busy == false)
|
||||
{
|
||||
_clone.visible = false;
|
||||
changeMode(4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_mode != 2)
|
||||
{
|
||||
_modeSwitchTimer -= param1;
|
||||
if(_modeSwitchTimer <= 0)
|
||||
{
|
||||
changeMode(_mode == 0 ? 1 : 0);
|
||||
_modeSwitchTimer = MODE_SWITCH_TIME;
|
||||
}
|
||||
}
|
||||
if(turnX < 0 && turnY < 0)
|
||||
{
|
||||
if(Math.abs(_loc7_ - i) > 1 && Math.abs(_loc7_ - i) < 5 || Math.abs(_loc6_ - j) > 1 && Math.abs(_loc6_ - j) < 5)
|
||||
{
|
||||
trace("skipped a square!");
|
||||
}
|
||||
if(_loc7_ != i || _loc6_ != j)
|
||||
{
|
||||
if(getPossibleDirections())
|
||||
{
|
||||
if(isSeekingPlayer())
|
||||
{
|
||||
if(_mode == 1 || getDistSq(_clone.x,_clone.y) < _detectionRadius * _detectionRadius)
|
||||
{
|
||||
_loc4_ = 1.7976931348623157e+308;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < 4)
|
||||
{
|
||||
if(_directions[_loc9_] == 1)
|
||||
{
|
||||
switch(_loc9_)
|
||||
{
|
||||
case 0:
|
||||
_loc5_ = i;
|
||||
_loc3_ = j + 1;
|
||||
break;
|
||||
case 1:
|
||||
_loc5_ = i - 1;
|
||||
_loc3_ = j;
|
||||
break;
|
||||
case 2:
|
||||
_loc5_ = i;
|
||||
_loc3_ = j - 1;
|
||||
break;
|
||||
case 3:
|
||||
_loc5_ = i + 1;
|
||||
_loc3_ = j;
|
||||
}
|
||||
_theGame.setTurnXY(_loc5_,_loc3_,_tempObject);
|
||||
_loc2_ = getDistSq(_tempObject.turnX,_tempObject.turnY);
|
||||
if(_loc2_ < _loc4_)
|
||||
{
|
||||
_loc4_ = _loc2_;
|
||||
_loc8_ = _loc9_;
|
||||
}
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = int(Math.floor(Math.random() * 4));
|
||||
while(_directions[_loc8_] == 0)
|
||||
{
|
||||
if(++_loc8_ == _directions.length)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_mode == 2)
|
||||
{
|
||||
_loc4_ = -1;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < 4)
|
||||
{
|
||||
if(_directions[_loc9_] == 1)
|
||||
{
|
||||
switch(_loc9_)
|
||||
{
|
||||
case 0:
|
||||
_loc5_ = i;
|
||||
_loc3_ = j + 1;
|
||||
break;
|
||||
case 1:
|
||||
_loc5_ = i - 1;
|
||||
_loc3_ = j;
|
||||
break;
|
||||
case 2:
|
||||
_loc5_ = i;
|
||||
_loc3_ = j - 1;
|
||||
break;
|
||||
case 3:
|
||||
_loc5_ = i + 1;
|
||||
_loc3_ = j;
|
||||
}
|
||||
_theGame.setTurnXY(_loc5_,_loc3_,_tempObject);
|
||||
_loc2_ = getDistSq(_tempObject.turnX,_tempObject.turnY);
|
||||
if(_loc2_ > _loc4_)
|
||||
{
|
||||
_loc4_ = _loc2_;
|
||||
_loc8_ = _loc9_;
|
||||
}
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
if(_loc8_ != _direction)
|
||||
{
|
||||
if(Math.abs(_loc8_ - _direction) == 2)
|
||||
{
|
||||
_direction = _loc8_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.setTurningPointXY(_loc8_,_direction,this);
|
||||
turnDirection = _loc8_;
|
||||
}
|
||||
}
|
||||
_directions[0] = _directions[1] = _directions[2] = _directions[3] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 4)
|
||||
{
|
||||
if(_directions[_loc8_] == 1)
|
||||
{
|
||||
if(_loc8_ != _direction)
|
||||
{
|
||||
_theGame.setTurningPointXY(_loc8_,_direction,this);
|
||||
turnDirection = _loc8_;
|
||||
}
|
||||
_directions[_loc8_] = 0;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_mode != 4)
|
||||
{
|
||||
if(_direction == 0)
|
||||
{
|
||||
_clone.x += _speed * param1;
|
||||
if(_clone.x > _theGame.getLevelExtent(0))
|
||||
{
|
||||
_clone.x = _theGame.getLevelExtent(2);
|
||||
}
|
||||
else if(turnX >= 0 && _clone.x >= turnX)
|
||||
{
|
||||
_clone.x = turnX;
|
||||
_theGame.resetTurnXY(this);
|
||||
_direction = turnDirection;
|
||||
}
|
||||
}
|
||||
else if(_direction == 2)
|
||||
{
|
||||
_clone.x -= _speed * param1;
|
||||
if(_clone.x < _theGame.getLevelExtent(2))
|
||||
{
|
||||
_clone.x = _theGame.getLevelExtent(0);
|
||||
}
|
||||
else if(turnX >= 0 && _clone.x <= turnX)
|
||||
{
|
||||
_clone.x = turnX;
|
||||
_theGame.resetTurnXY(this);
|
||||
_direction = turnDirection;
|
||||
}
|
||||
}
|
||||
else if(_direction == 3)
|
||||
{
|
||||
_clone.y += _speed * param1;
|
||||
if(_clone.y > _theGame.getLevelExtent(3))
|
||||
{
|
||||
_clone.y = _theGame.getLevelExtent(1);
|
||||
}
|
||||
else if(turnY >= 0 && _clone.y >= turnY)
|
||||
{
|
||||
_clone.y = turnY;
|
||||
_theGame.resetTurnXY(this);
|
||||
_direction = turnDirection;
|
||||
}
|
||||
}
|
||||
else if(_direction == 1)
|
||||
{
|
||||
_clone.y -= _speed * param1;
|
||||
if(_clone.y < _theGame.getLevelExtent(1))
|
||||
{
|
||||
_clone.y = _theGame.getLevelExtent(3);
|
||||
}
|
||||
else if(turnY >= 0 && _clone.y <= turnY)
|
||||
{
|
||||
_clone.y = turnY;
|
||||
_theGame.resetTurnXY(this);
|
||||
_direction = turnDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPossibleDirections() : Boolean
|
||||
{
|
||||
var _loc2_:Array = _theGame.getCurrentLevelArray();
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = i - 1 >= 0 ? i - 1 : _loc2_.length - 1;
|
||||
if((_direction != 3 || _forceCheck) && _loc2_[_loc4_][j] != 0)
|
||||
{
|
||||
_directions[1] = 1;
|
||||
_loc3_++;
|
||||
}
|
||||
_loc4_ = i + 1 < _loc2_.length ? i + 1 : 0;
|
||||
if((_direction != 1 || _forceCheck) && _loc2_[_loc4_][j] != 0)
|
||||
{
|
||||
_directions[3] = 1;
|
||||
_loc3_++;
|
||||
}
|
||||
var _loc1_:int = j - 1 >= 0 ? j - 1 : _loc2_[i].length - 1;
|
||||
if((_direction != 0 || _forceCheck) && _loc2_[i][_loc1_] != 0)
|
||||
{
|
||||
_directions[2] = 1;
|
||||
_loc3_++;
|
||||
}
|
||||
_loc1_ = j + 1 < _loc2_[i].length ? j + 1 : 0;
|
||||
if((_direction != 2 || _forceCheck) && _loc2_[i][_loc1_] != 0)
|
||||
{
|
||||
_directions[0] = 1;
|
||||
_loc3_++;
|
||||
}
|
||||
_forceCheck = false;
|
||||
if(_loc3_ == 0)
|
||||
{
|
||||
trace("uh oh");
|
||||
}
|
||||
return _loc3_ > 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,21 @@
|
||||
package game.horseRace
|
||||
{
|
||||
public class HorseRaceAIProfile
|
||||
{
|
||||
|
||||
public var _jumpDetectionProbability:int;
|
||||
|
||||
public var _jumpDetectionDelay:Number;
|
||||
|
||||
public var _jumpDetectionDistance:Number;
|
||||
|
||||
public function HorseRaceAIProfile(param1:int, param2:Number, param3:int)
|
||||
{
|
||||
super();
|
||||
_jumpDetectionProbability = param1;
|
||||
_jumpDetectionDelay = param2;
|
||||
_jumpDetectionDistance = param3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package game.horseRace
|
||||
{
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarViewExt_Splash;
|
||||
import com.sbi.graphics.LayerBitmap;
|
||||
import flash.filters.GlowFilter;
|
||||
|
||||
public class HorseRaceAvatarView extends AvatarView
|
||||
{
|
||||
|
||||
private static const GLOW_LAND_DEFAULT_COLOR:int = 5586479;
|
||||
|
||||
private static const GLOW_OCEAN_DEFAULT_COLOR:int = 2775381;
|
||||
|
||||
private var _splash:AvatarViewExt_Splash;
|
||||
|
||||
private var _glow:GlowFilter;
|
||||
|
||||
public var _bInSplashVolume:Boolean;
|
||||
|
||||
private var _splashLiquid:String;
|
||||
|
||||
public function HorseRaceAvatarView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function InitHorseRaceAvatarView() : void
|
||||
{
|
||||
_layerAnim.avDefId = 23;
|
||||
var _loc1_:LayerBitmap = _layerAnim.bitmap;
|
||||
_loc1_.x = 0;
|
||||
_loc1_.y = 0;
|
||||
_glow = new GlowFilter(0,1,4,4,4);
|
||||
_layerAnim.bitmap.filters = [_glow];
|
||||
setBlendColor();
|
||||
_splash = new AvatarViewExt_Splash(this,_layerAnim.bitmap);
|
||||
_bInSplashVolume = false;
|
||||
}
|
||||
|
||||
public function setBlendColor(param1:uint = 0, param2:uint = 4294967295) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
if(param2 == 4294967295)
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
param2 = 5586479;
|
||||
}
|
||||
else
|
||||
{
|
||||
param2 = uint(param1 & 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
if(_layerAnim.bitmap.filters != null && _layerAnim.bitmap.filters[0].color != param2)
|
||||
{
|
||||
_loc3_ = _layerAnim.bitmap.filters;
|
||||
_loc3_[0].color = param2;
|
||||
_layerAnim.bitmap.filters = _loc3_;
|
||||
}
|
||||
_layerAnim.bitmap.setBlendColor(param1);
|
||||
}
|
||||
|
||||
public function toggleSplash(param1:Boolean, param2:String = null) : void
|
||||
{
|
||||
_bInSplashVolume = param1;
|
||||
if(_bInSplashVolume)
|
||||
{
|
||||
_splashLiquid = param2;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat() : void
|
||||
{
|
||||
_splash.heartbeat(_bInSplashVolume,true,_splashLiquid,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package game.horseRace
|
||||
{
|
||||
public class HorseRaceData
|
||||
{
|
||||
|
||||
public var _data:Object;
|
||||
|
||||
public var _facts:Array;
|
||||
|
||||
public var _audio:Array;
|
||||
|
||||
public function HorseRaceData()
|
||||
{
|
||||
super();
|
||||
initLevelData();
|
||||
}
|
||||
|
||||
public function initLevelData() : void
|
||||
{
|
||||
_facts = [{
|
||||
"imageID":1484,
|
||||
"text":11602
|
||||
},{
|
||||
"imageID":1485,
|
||||
"text":11603
|
||||
},{
|
||||
"imageID":1486,
|
||||
"text":11604
|
||||
},{
|
||||
"imageID":1487,
|
||||
"text":11605
|
||||
},{
|
||||
"imageID":1488,
|
||||
"text":11606
|
||||
},{
|
||||
"imageID":1489,
|
||||
"text":11607
|
||||
},{
|
||||
"imageID":1490,
|
||||
"text":11608
|
||||
},{
|
||||
"imageID":1491,
|
||||
"text":11609
|
||||
},{
|
||||
"imageID":1492,
|
||||
"text":11610
|
||||
},{
|
||||
"imageID":1493,
|
||||
"text":11611
|
||||
},{
|
||||
"imageID":1494,
|
||||
"text":11612
|
||||
},{
|
||||
"imageID":1495,
|
||||
"text":11613
|
||||
},{
|
||||
"imageID":1496,
|
||||
"text":11614
|
||||
},{
|
||||
"imageID":1497,
|
||||
"text":11615
|
||||
},{
|
||||
"imageID":1498,
|
||||
"text":11616
|
||||
}];
|
||||
_data = {
|
||||
"tiles":[[600,0,400,0,100],[600,1,300,1,100],[600,0,300,1,100],[700,1,300,0,100],[500,0,300,0,100],[500,0,200,0,200],[200,1,200,1,500,2,100],[200,1,400,2,200,1,100],[300,1,300,0,50,0,100],[100,1,100,0,50],[100,0,100,1,50],[300,0,500,1,300],[200,0,25,0,200,0,200],[200,1,25,1,200,1,200],[200,2,200,2,100,2,200],[200,0,200,1,100,2,200],[200,0,200,1,100,2,200],[200,2,200,2,100,2,200],[700,0,500,0,300],[600,1,400,1,300],[700,0,500,1,300],[600,1,400,0,300],[600,0,400,0,200],[600,0,300,0,300],[300,1,400,2,200],[300,0,500,2,200],[400,1,400,1,150],[200,1,300,0,150],[200,0,300,1,150],[400,2,500,1,300],[300,0,225,0,300,0,300],[300,1,225,1,300,1,300],[300,2,300,2,200,2,300],[300,0,300,1,200,2,300],[350,2,300,1,200,0,300],[350,2,400,0,400,2,300]],
|
||||
"proTracks":[[0,2,4,6,8,10,12,14,16],[1,3,5,7,9,11,13,15,17],[0,3,4,7,8,11,12,15,16],[1,2,5,6,9,10,13,14,17],[0,1,4,5,8,9,12,13,16],[2,3,6,7,10,11,14,15,17]],
|
||||
"beginnerTracks":[[18,20,22,24,26,28,30,32,34],[19,21,23,25,27,29,31,33,35],[18,21,22,25,26,29,30,33,34],[19,20,23,24,27,28,31,32,35],[18,19,22,23,26,27,30,31,34],[20,21,24,25,28,29,32,33,35]]
|
||||
};
|
||||
_audio = ["aj_horsejump1.mp3","aj_horsejump2.mp3","aj_horseJump3.mp3","aj_horseTurbo.mp3","aj_horseWhine1.mp3","aj_horseWhine2.mp3","aj_horseWhine3.mp3","aj_horseWhine4.mp3","aj_popUp.mp3","aj_hoovesHay.mp3","aj_hoovesMud.mp3","aj_hoovesWater.mp3","aj_hoovesWeeds.mp3","aj_horse1.mp3","aj_horse2.mp3","aj_horse3.mp3","aj_PopUp_ReadySet.mp3","aj_PopUp_Go.mp3"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package game.horseRace
|
||||
{
|
||||
public class HorseRaceHurdle
|
||||
{
|
||||
|
||||
public var _type:int;
|
||||
|
||||
public var _class:int;
|
||||
|
||||
public var _width:int;
|
||||
|
||||
public var _x:int;
|
||||
|
||||
public function HorseRaceHurdle(param1:int, param2:int, param3:int, param4:int)
|
||||
{
|
||||
super();
|
||||
_type = param1;
|
||||
_class = param2;
|
||||
_width = param3;
|
||||
_x = param4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package game.horseRace
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class HorseRaceLaneTexture
|
||||
{
|
||||
|
||||
public var _active:Array = [];
|
||||
|
||||
public var _inactive:Array = [];
|
||||
|
||||
public var _minSpacing:int;
|
||||
|
||||
public var _varSpacing:int;
|
||||
|
||||
public var _currentX:int;
|
||||
|
||||
public var _fixedWidth:int;
|
||||
|
||||
public var _theGame:HorseRace;
|
||||
|
||||
public function HorseRaceLaneTexture(param1:HorseRace, param2:String, param3:int, param4:int, param5:int, param6:int, param7:int = 0)
|
||||
{
|
||||
var _loc9_:int = 0;
|
||||
var _loc8_:MovieClip = null;
|
||||
super();
|
||||
_theGame = param1;
|
||||
_minSpacing = param5;
|
||||
_varSpacing = param6;
|
||||
_fixedWidth = param7;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < param4)
|
||||
{
|
||||
_loc8_ = GETDEFINITIONBYNAME(param2);
|
||||
_loc8_.y = param3;
|
||||
_inactive.push(_loc8_);
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
_currentX = Math.random() * _varSpacing;
|
||||
while(_active.length > 0)
|
||||
{
|
||||
_loc1_ = _active[0];
|
||||
if(_loc1_.parent != null)
|
||||
{
|
||||
_loc1_.parent.removeChild(_loc1_);
|
||||
}
|
||||
_active.splice(0,1);
|
||||
_inactive.push(_loc1_);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number, param2:Sprite) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MovieClip = null;
|
||||
_loc4_ = _active.length - 1;
|
||||
while(_loc4_ >= 0)
|
||||
{
|
||||
_loc3_ = _active[_loc4_];
|
||||
if(_loc3_.x + param2.x < -_loc3_.width)
|
||||
{
|
||||
if(_loc3_.parent != null)
|
||||
{
|
||||
_loc3_.parent.removeChild(_loc3_);
|
||||
}
|
||||
_active.splice(0,1);
|
||||
_inactive.push(_loc3_);
|
||||
}
|
||||
_loc4_--;
|
||||
}
|
||||
while(_inactive.length > 0 && _currentX + param2.x < 1100)
|
||||
{
|
||||
_loc3_ = _inactive[0];
|
||||
_inactive.splice(0,1);
|
||||
_active.push(_loc3_);
|
||||
_loc3_.x = _currentX;
|
||||
if(_currentX == 0)
|
||||
{
|
||||
_loc3_.setStart();
|
||||
}
|
||||
else if(_theGame._trackLength != 0 && _currentX >= _theGame._trackLength - _fixedWidth / 2)
|
||||
{
|
||||
_loc3_.setEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.randomize();
|
||||
}
|
||||
param2.addChildAt(_loc3_,0);
|
||||
if(_fixedWidth > 0)
|
||||
{
|
||||
_currentX += _fixedWidth + _minSpacing + Math.random() * _varSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentX += _loc3_.width + _minSpacing + Math.random() * _varSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,326 @@
|
||||
package game.microBambooHarvest
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroBambooHarvest extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["ajq_bambooGrab1.mp3","ajq_bambooGrab2.mp3","ajq_bambooGrab3a.mp3","ajq_bambooGrab3b.mp3","ajq_bambooGrab3c.mp3","ajq_bambooGrab3d.mp3","ajq_miningStinger.mp3","ajq_textEnter.mp3","ajq_textExit.mp3","ajq_resourceMoving2Bag.mp3","ajq_resourceDrop.mp3","ajq_resourcePopupEnter.mp3","ajq_resourcePopUpExit.mp3","ajq_satchelClose.mp3","ajq_satchelOpen.mp3"];
|
||||
|
||||
private var _soundNameBambooGrab1:String = _audio[0];
|
||||
|
||||
private var _soundNameBambooGrab2:String = _audio[1];
|
||||
|
||||
private var _soundNameBambooGrab3:String = _audio[2];
|
||||
|
||||
private var _soundNameBambooGrab4:String = _audio[3];
|
||||
|
||||
private var _soundNameBambooGrab5:String = _audio[4];
|
||||
|
||||
private var _soundNameBambooGrab6:String = _audio[5];
|
||||
|
||||
private var _soundNameBambooStinger:String = _audio[6];
|
||||
|
||||
private var _soundNameBambooTextEnter:String = _audio[7];
|
||||
|
||||
private var _soundNameBambooTextExit:String = _audio[8];
|
||||
|
||||
private var _soundNameResourceMove:String = _audio[9];
|
||||
|
||||
private var _soundNameResourceDrop:String = _audio[10];
|
||||
|
||||
private var _soundNamePopupEnter:String = _audio[11];
|
||||
|
||||
private var _soundNamePopupExit:String = _audio[12];
|
||||
|
||||
private var _soundNameSatchelClose:String = _audio[13];
|
||||
|
||||
private var _soundNameSatchelOpen:String = _audio[14];
|
||||
|
||||
public function MicroBambooHarvest()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab1],_soundNameBambooGrab1,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab2],_soundNameBambooGrab2,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab3],_soundNameBambooGrab3,0.68);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab4],_soundNameBambooGrab4,0.58);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab5],_soundNameBambooGrab5,1.15);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooGrab6],_soundNameBambooGrab6,1.14);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooStinger],_soundNameBambooStinger,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooTextEnter],_soundNameBambooTextEnter,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBambooTextExit],_soundNameBambooTextExit,1.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceMove],_soundNameResourceMove,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceDrop],_soundNameResourceDrop,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupEnter],_soundNamePopupEnter,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupExit],_soundNamePopupExit,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelClose],_soundNameSatchelClose,0.73);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelOpen],_soundNameSatchelOpen,0.82);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroBambooHarvest/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.gameFinished)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_textEnter = false;
|
||||
_soundMan.playByName(_soundNameBambooTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_textExit = false;
|
||||
_soundMan.playByName(_soundNameBambooTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_miningStinger)
|
||||
{
|
||||
_theGame.loader.content.ajq_miningStinger = false;
|
||||
_soundMan.playByName(_soundNameBambooStinger);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab1)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab1 = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab2)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab2 = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab3a)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab3a = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab3);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab3b)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab3b = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab4);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab3c)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab3c = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab5);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_bambooGrab3d)
|
||||
{
|
||||
_theGame.loader.content.ajq_bambooGrab3d = false;
|
||||
_soundMan.playByName(_soundNameBambooGrab6);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopupEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopupEnter = false;
|
||||
_soundMan.playByName(_soundNamePopupEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopUpExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopUpExit = false;
|
||||
_soundMan.playByName(_soundNamePopupExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceMoveToBag)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceMoveToBag = false;
|
||||
_soundMan.playByName(_soundNameResourceMove);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceDrop)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceDrop = false;
|
||||
_soundMan.playByName(_soundNameResourceDrop);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelClose)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelClose = false;
|
||||
_soundMan.playByName(_soundNameSatchelClose);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelOpen)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelOpen = false;
|
||||
_soundMan.playByName(_soundNameSatchelOpen);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
MinigameManager.handleQuestMiniGameComplete(_theGame.loader.content.reward);
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package game.microCrane
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class CraneEvent extends Event
|
||||
{
|
||||
|
||||
public static const CRANE_DROP_COMPLETE:String = "craneDropComplete";
|
||||
|
||||
public static const CRANE_OPEN:String = "craneOpen";
|
||||
|
||||
public static const CRANE_CLOSE:String = "craneClose";
|
||||
|
||||
public static const CRANE_LOWER:String = "craneLower";
|
||||
|
||||
public static const CRANE_RETRACT:String = "craneRetract";
|
||||
|
||||
public function CraneEvent(param1:String)
|
||||
{
|
||||
super(param1,true,false);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new CraneEvent(type);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("CraneEvent",type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,946 @@
|
||||
package game.microCrane
|
||||
{
|
||||
import currency.UserCurrency;
|
||||
import den.DenItem;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import gui.GiftPopup;
|
||||
import item.Item;
|
||||
|
||||
public class MicroCrane extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const MAX_CRANE_POSITION:int = 200;
|
||||
|
||||
public static var SFX_CRANE_SERVO:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerBack:Sprite;
|
||||
|
||||
public var _layerCrane:Sprite;
|
||||
|
||||
public var _layerFront:Sprite;
|
||||
|
||||
public var _layerControls:Sprite;
|
||||
|
||||
public var _goCountdown:Number;
|
||||
|
||||
public var _goMC:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _crane:Object;
|
||||
|
||||
private var _drop:Object;
|
||||
|
||||
private var _left:Object;
|
||||
|
||||
private var _right:Object;
|
||||
|
||||
private var _success:Boolean;
|
||||
|
||||
private var _dropped:Boolean;
|
||||
|
||||
private var _moveDirection:int;
|
||||
|
||||
private var _cranePosition:Number;
|
||||
|
||||
private var _craneOriginalPosition:Number;
|
||||
|
||||
public var _leftArrowDown:Boolean;
|
||||
|
||||
public var _rightArrowDown:Boolean;
|
||||
|
||||
public var _downArrowDown:Boolean;
|
||||
|
||||
public var _upArrowDown:Boolean;
|
||||
|
||||
private var _velocity:Number;
|
||||
|
||||
private var _gameStarted:Boolean;
|
||||
|
||||
private var _endText:Object;
|
||||
|
||||
private var _tryAgainTimer:Number;
|
||||
|
||||
private var _needGemsTimer:Number;
|
||||
|
||||
private var _prizePopup:GiftPopup;
|
||||
|
||||
private var _cranePlaySuccess:Boolean;
|
||||
|
||||
private var _prizeDenItem:DenItem;
|
||||
|
||||
private var _prizeAccessory:Item;
|
||||
|
||||
private var _audio:Array = ["claw_drop_button.mp3","claw_arrow_buttons.mp3","claw_close.mp3","claw_item_pick_up.mp3","claw_lower.mp3","claw_open.mp3","claw_retract.mp3","claw_prize.mp3","claw_almost.mp3","MG_popup_youWon.mp3","claw_insert_coin.mp3"];
|
||||
|
||||
private var _soundNameCraneDrop:String = _audio[0];
|
||||
|
||||
private var _soundNameCraneArrow:String = _audio[1];
|
||||
|
||||
private var _soundNameCraneClose:String = _audio[2];
|
||||
|
||||
private var _soundNameCraneItemPickup:String = _audio[3];
|
||||
|
||||
private var _soundNameCraneLower:String = _audio[4];
|
||||
|
||||
private var _soundNameCraneOpen:String = _audio[5];
|
||||
|
||||
private var _soundNameCraneRetract:String = _audio[6];
|
||||
|
||||
private var _soundNameCranePrize:String = _audio[7];
|
||||
|
||||
private var _soundNameCraneAlmost:String = _audio[8];
|
||||
|
||||
private var _soundNameCraneSuccess:String = _audio[9];
|
||||
|
||||
private var _soundNameCraneInsertCoin:String = _audio[10];
|
||||
|
||||
private var _SFX_Crane_Servo_Instance:SoundChannel;
|
||||
|
||||
public function MicroCrane()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneDrop],_soundNameCraneDrop,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneArrow],_soundNameCraneArrow,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneClose],_soundNameCraneClose,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneItemPickup],_soundNameCraneItemPickup,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneLower],_soundNameCraneLower,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneOpen],_soundNameCraneOpen,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneRetract],_soundNameCraneRetract,0.5);
|
||||
_soundMan.addSound(SFX_CRANE_SERVO,0.15,"SFX_CRANE_SERVO");
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCranePrize],_soundNameCranePrize,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneAlmost],_soundNameCraneAlmost,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneSuccess],_soundNameCraneSuccess,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCraneInsertCoin],_soundNameCraneInsertCoin,0.6);
|
||||
}
|
||||
|
||||
private function keyHandleUp(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = false;
|
||||
releaseMoveButtons();
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = false;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = false;
|
||||
releaseMoveButtons();
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function keyHandleDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 32)
|
||||
{
|
||||
case 0:
|
||||
case 8:
|
||||
pressDropButton();
|
||||
_downArrowDown = true;
|
||||
break;
|
||||
case 5:
|
||||
_leftArrowDown = true;
|
||||
pressMoveButtons(-1);
|
||||
break;
|
||||
case 6:
|
||||
_upArrowDown = true;
|
||||
break;
|
||||
case 7:
|
||||
_rightArrowDown = true;
|
||||
pressMoveButtons(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
hideDlg();
|
||||
releaseBase();
|
||||
if(_SFX_Crane_Servo_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_Crane_Servo_Instance);
|
||||
_SFX_Crane_Servo_Instance = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",playKeyDown);
|
||||
stage.removeEventListener("keyUp",keyHandleUp);
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("mouseUp",mouseUpHandler);
|
||||
if(_drop)
|
||||
{
|
||||
_drop.loader.removeEventListener("click",mouseClickHandlerDrop);
|
||||
}
|
||||
if(_left)
|
||||
{
|
||||
_left.loader.removeEventListener("mouseDown",mouseDownHandlerLeft);
|
||||
}
|
||||
if(_right)
|
||||
{
|
||||
_right.loader.removeEventListener("mouseDown",mouseDownHandlerRight);
|
||||
}
|
||||
if(_crane)
|
||||
{
|
||||
_crane.loader.removeEventListener("craneDropComplete",craneDropCompleteHandler);
|
||||
}
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerBack);
|
||||
removeLayer(_layerCrane);
|
||||
removeLayer(_layerFront);
|
||||
removeLayer(_layerControls);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBack = null;
|
||||
_layerCrane = null;
|
||||
_layerFront = null;
|
||||
_layerControls = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBack = new Sprite();
|
||||
_layerCrane = new Sprite();
|
||||
_layerFront = new Sprite();
|
||||
_layerControls = new Sprite();
|
||||
_layerBack.mouseEnabled = false;
|
||||
_layerCrane.mouseEnabled = false;
|
||||
_layerFront.mouseEnabled = false;
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBack);
|
||||
addChild(_layerCrane);
|
||||
addChild(_layerFront);
|
||||
addChild(_layerControls);
|
||||
addChild(_guiLayer);
|
||||
loadScene("CraneAssets/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
SFX_CRANE_SERVO = getDefinitionByName("claw_servo") as Class;
|
||||
if(SFX_CRANE_SERVO == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:claw_servo");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_endText = null;
|
||||
_loc5_ = _scene.getLayer("closeButton");
|
||||
addBtn("CloseButton",_loc5_.x,_loc5_.y,onCloseButton);
|
||||
_crane = _scene.getLayer("crane_main");
|
||||
var _loc4_:String = MinigameManager.roomName;
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId)
|
||||
{
|
||||
case 16:
|
||||
_crane.loader.content.setType(1);
|
||||
break;
|
||||
case 57:
|
||||
_crane.loader.content.setType(2);
|
||||
break;
|
||||
case 58:
|
||||
_crane.loader.content.setType(3);
|
||||
break;
|
||||
case 61:
|
||||
_crane.loader.content.setType(4);
|
||||
break;
|
||||
case 67:
|
||||
_crane.loader.content.setType(6);
|
||||
break;
|
||||
case 71:
|
||||
_crane.loader.content.setType(7);
|
||||
break;
|
||||
case 75:
|
||||
_crane.loader.content.setType(5);
|
||||
break;
|
||||
case 85:
|
||||
_crane.loader.content.setType(12);
|
||||
break;
|
||||
case 99:
|
||||
_crane.loader.content.setType(10);
|
||||
break;
|
||||
case 100:
|
||||
_crane.loader.content.setType(8);
|
||||
break;
|
||||
case 103:
|
||||
_crane.loader.content.setType(11);
|
||||
break;
|
||||
case 104:
|
||||
_crane.loader.content.setType(15);
|
||||
break;
|
||||
case 105:
|
||||
_crane.loader.content.setType(14);
|
||||
break;
|
||||
case 106:
|
||||
_crane.loader.content.setType(13);
|
||||
break;
|
||||
case 107:
|
||||
_crane.loader.content.setType(16);
|
||||
break;
|
||||
case 109:
|
||||
_crane.loader.content.setType(18);
|
||||
break;
|
||||
case 110:
|
||||
_crane.loader.content.setType(19);
|
||||
break;
|
||||
case 116:
|
||||
_crane.loader.content.setType(9);
|
||||
break;
|
||||
case 117:
|
||||
_crane.loader.content.setType(20);
|
||||
break;
|
||||
case 118:
|
||||
_crane.loader.content.setType(17);
|
||||
break;
|
||||
case 119:
|
||||
_crane.loader.content.setType(23);
|
||||
break;
|
||||
case 120:
|
||||
_crane.loader.content.setType(3);
|
||||
break;
|
||||
case 121:
|
||||
_crane.loader.content.setType(24);
|
||||
break;
|
||||
case 123:
|
||||
_crane.loader.content.setType(22);
|
||||
break;
|
||||
case 125:
|
||||
_crane.loader.content.setType(26);
|
||||
break;
|
||||
case 126:
|
||||
_crane.loader.content.setType(25);
|
||||
break;
|
||||
case 127:
|
||||
_crane.loader.content.setType(31);
|
||||
break;
|
||||
case 128:
|
||||
_crane.loader.content.setType(27);
|
||||
break;
|
||||
case 129:
|
||||
_crane.loader.content.setType(28);
|
||||
break;
|
||||
case 130:
|
||||
_crane.loader.content.setType(29);
|
||||
break;
|
||||
case 131:
|
||||
_crane.loader.content.setType(30);
|
||||
break;
|
||||
case 132:
|
||||
_crane.loader.content.setType(33);
|
||||
break;
|
||||
case 133:
|
||||
_crane.loader.content.setType(34);
|
||||
break;
|
||||
case 134:
|
||||
_crane.loader.content.setType(35);
|
||||
break;
|
||||
default:
|
||||
_crane.loader.content.setType(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_crane.loader.content.setType(0);
|
||||
}
|
||||
_craneOriginalPosition = _crane.loader.content.CraneClaw.x;
|
||||
_drop = _scene.getLayer("crane_drop");
|
||||
_left = _scene.getLayer("crane_left");
|
||||
_right = _scene.getLayer("crane_right");
|
||||
_crane.loader.content.CraneStop();
|
||||
_layerCrane.addChild(_crane.loader);
|
||||
_layerControls.addChild(_drop.loader);
|
||||
_layerControls.addChild(_left.loader);
|
||||
_layerControls.addChild(_right.loader);
|
||||
_sceneLoaded = true;
|
||||
_leftArrowDown = false;
|
||||
_rightArrowDown = false;
|
||||
_downArrowDown = false;
|
||||
_upArrowDown = false;
|
||||
stage.addEventListener("keyUp",keyHandleUp);
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("mouseUp",mouseUpHandler);
|
||||
_drop.loader.addEventListener("click",mouseClickHandlerDrop);
|
||||
_left.loader.addEventListener("mouseDown",mouseDownHandlerLeft);
|
||||
_right.loader.addEventListener("mouseDown",mouseDownHandlerRight);
|
||||
_crane.loader.addEventListener("craneDropComplete",craneDropCompleteHandler);
|
||||
_crane.loader.addEventListener("craneOpen",craneOpenHandler);
|
||||
_crane.loader.addEventListener("craneClose",craneCloseHandler);
|
||||
_crane.loader.addEventListener("craneLower",craneLowerHandler);
|
||||
_crane.loader.addEventListener("craneRetract",craneRetractHandler);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:MovieClip = null;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc3_ + 1];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "cp")
|
||||
{
|
||||
if(param1[3] != "1" && param1[3] != "0")
|
||||
{
|
||||
_loc2_ = showDlg("popup_needgems",[]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
_needGemsTimer = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_success = false;
|
||||
_dropped = false;
|
||||
releaseMoveButtons();
|
||||
_drop.loader.content.gotoAndStop("off");
|
||||
_gameStarted = true;
|
||||
if(param1[3] == "1")
|
||||
{
|
||||
_cranePlaySuccess = true;
|
||||
if(param1[4] == "1")
|
||||
{
|
||||
_prizeAccessory = null;
|
||||
_prizeDenItem = new DenItem();
|
||||
_prizeDenItem.initShopItem(param1[5],param1[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_prizeDenItem = null;
|
||||
_prizeAccessory = new Item();
|
||||
_prizeAccessory.init(param1[5],0,param1[7],0,0,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_cranePlaySuccess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function keptItem() : void
|
||||
{
|
||||
messageServer(["cd","1"]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function rejectedItem() : void
|
||||
{
|
||||
messageServer(["cd","0"]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function destroyPrizePopup() : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
popupTryAgain();
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_gameStarted)
|
||||
{
|
||||
if(_goCountdown > 0)
|
||||
{
|
||||
_goCountdown -= _frameTime;
|
||||
if(_goCountdown <= 0)
|
||||
{
|
||||
if(_goMC && _goMC.loader.parent)
|
||||
{
|
||||
_goMC.loader.parent.removeChild(_goMC.loader);
|
||||
_scene.releaseCloneAsset(_goMC.loader);
|
||||
_goMC = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
if(_moveDirection != 0)
|
||||
{
|
||||
_velocity += 200 * _frameTime * _moveDirection;
|
||||
if(_velocity > 125)
|
||||
{
|
||||
_velocity = 125;
|
||||
}
|
||||
else if(_velocity < -125)
|
||||
{
|
||||
_velocity = -125;
|
||||
}
|
||||
}
|
||||
else if(_velocity > 0)
|
||||
{
|
||||
_velocity -= 200 * _frameTime;
|
||||
if(_velocity < 0)
|
||||
{
|
||||
_velocity = 0;
|
||||
}
|
||||
}
|
||||
else if(_velocity < 0)
|
||||
{
|
||||
_velocity += 200 * _frameTime;
|
||||
if(_velocity > 0)
|
||||
{
|
||||
_velocity = 0;
|
||||
}
|
||||
}
|
||||
if(_velocity != 0)
|
||||
{
|
||||
_cranePosition += _velocity * _frameTime;
|
||||
if(_cranePosition < 0)
|
||||
{
|
||||
_velocity = 0;
|
||||
_cranePosition = 0;
|
||||
releaseMoveButtons();
|
||||
}
|
||||
else if(_cranePosition > 200)
|
||||
{
|
||||
_velocity = 0;
|
||||
_cranePosition = 200;
|
||||
releaseMoveButtons();
|
||||
}
|
||||
_crane.loader.content.CraneClaw.x = _craneOriginalPosition + _cranePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_tryAgainTimer > 0)
|
||||
{
|
||||
_tryAgainTimer -= _frameTime;
|
||||
if(_tryAgainTimer <= 0)
|
||||
{
|
||||
if(_endText && _endText.loader.parent)
|
||||
{
|
||||
_endText.loader.parent.removeChild(_endText.loader);
|
||||
_scene.releaseCloneAsset(_endText.loader);
|
||||
_endText = null;
|
||||
}
|
||||
if(_success)
|
||||
{
|
||||
_prizePopup = new GiftPopup();
|
||||
if(_prizeDenItem != null)
|
||||
{
|
||||
_prizePopup.init(this.parent,_prizeDenItem.icon,_prizeDenItem.name,_prizeDenItem.defId,2,2,keptItem,rejectedItem,destroyPrizePopup);
|
||||
}
|
||||
else
|
||||
{
|
||||
_prizePopup.init(this.parent,_prizeAccessory.largeIcon,_prizeAccessory.name,_prizeAccessory.defId,2,1,keptItem,rejectedItem,destroyPrizePopup);
|
||||
}
|
||||
_soundMan.playByName(_soundNameCranePrize);
|
||||
}
|
||||
else
|
||||
{
|
||||
popupTryAgain();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_needGemsTimer > 0)
|
||||
{
|
||||
_needGemsTimer -= _frameTime;
|
||||
if(_needGemsTimer <= 0)
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function playKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onYes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onNo();
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc1_:String = null;
|
||||
var _loc2_:MovieClip = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_success = false;
|
||||
_dropped = false;
|
||||
_moveDirection = 0;
|
||||
_cranePosition = 0;
|
||||
_velocity = 0;
|
||||
_tryAgainTimer = 0;
|
||||
_gameStarted = false;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
stage.addEventListener("keyDown",playKeyDown);
|
||||
_loc1_ = "popup_play";
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 57)
|
||||
{
|
||||
case 0:
|
||||
_loc1_ = "popup_play_25";
|
||||
}
|
||||
}
|
||||
_loc2_ = showDlg(_loc1_,[{
|
||||
"name":"button_yes",
|
||||
"f":onYes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onNo
|
||||
}]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_goMC)
|
||||
{
|
||||
if(_goMC.loader.parent)
|
||||
{
|
||||
_goMC.loader.parent.removeChild(_goMC.loader);
|
||||
}
|
||||
_scene.releaseCloneAsset(_goMC.loader);
|
||||
_goMC = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseClickHandlerDrop(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
pressDropButton();
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseDownHandlerRight(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(!_dropped)
|
||||
{
|
||||
if(_moveDirection == 0)
|
||||
{
|
||||
pressMoveButtons(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseDownHandlerLeft(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(!_dropped)
|
||||
{
|
||||
if(_moveDirection == 0)
|
||||
{
|
||||
pressMoveButtons(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseUpHandler(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
releaseMoveButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private function craneOpenHandler(param1:CraneEvent) : void
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneOpen);
|
||||
}
|
||||
|
||||
private function craneLowerHandler(param1:CraneEvent) : void
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneLower);
|
||||
}
|
||||
|
||||
private function craneCloseHandler(param1:CraneEvent) : void
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneClose);
|
||||
if(_success)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneItemPickup);
|
||||
}
|
||||
}
|
||||
|
||||
private function craneRetractHandler(param1:CraneEvent) : void
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneRetract);
|
||||
}
|
||||
|
||||
private function craneDropCompleteHandler(param1:CraneEvent) : void
|
||||
{
|
||||
if(_gameStarted)
|
||||
{
|
||||
_gameStarted = false;
|
||||
if(_success)
|
||||
{
|
||||
_endText = _scene.cloneAsset("crane_success");
|
||||
_soundMan.playByName(_soundNameCraneSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
_endText = _scene.cloneAsset("crane_fail");
|
||||
_soundMan.playByName(_soundNameCraneAlmost);
|
||||
}
|
||||
_guiLayer.addChild(_endText.loader);
|
||||
_tryAgainTimer = 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
private function pressDropButton() : void
|
||||
{
|
||||
if(!_dropped && _goCountdown <= 0)
|
||||
{
|
||||
releaseMoveButtons();
|
||||
if(_gameStarted)
|
||||
{
|
||||
if(_cranePlaySuccess)
|
||||
{
|
||||
_crane.loader.content.CraneDropSuccess();
|
||||
_success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_crane.loader.content.CraneDropFail();
|
||||
}
|
||||
_dropped = true;
|
||||
_drop.loader.content.gotoAndStop("on");
|
||||
_soundMan.playByName(_soundNameCraneDrop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function pressMoveButtons(param1:int) : void
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
if(!_dropped && _gameStarted)
|
||||
{
|
||||
if(param1 < 0 && _cranePosition > 0 || param1 > 0 && _cranePosition < 200)
|
||||
{
|
||||
_loc2_ = _moveDirection != param1;
|
||||
_moveDirection = param1;
|
||||
_crane.loader.content.CraneMove();
|
||||
if(param1 < 0)
|
||||
{
|
||||
_right.loader.content.gotoAndStop("off");
|
||||
_left.loader.content.gotoAndStop("on");
|
||||
if(_loc2_)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneArrow);
|
||||
if(_SFX_Crane_Servo_Instance == null)
|
||||
{
|
||||
_SFX_Crane_Servo_Instance = _soundMan.play(SFX_CRANE_SERVO,0,99999);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 > 0)
|
||||
{
|
||||
_left.loader.content.gotoAndStop("off");
|
||||
_right.loader.content.gotoAndStop("on");
|
||||
if(_loc2_)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCraneArrow);
|
||||
if(_SFX_Crane_Servo_Instance == null)
|
||||
{
|
||||
_SFX_Crane_Servo_Instance = _soundMan.play(SFX_CRANE_SERVO,0,99999);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function releaseMoveButtons() : void
|
||||
{
|
||||
_moveDirection = 0;
|
||||
_crane.loader.content.CraneStop();
|
||||
_left.loader.content.gotoAndStop("off");
|
||||
_right.loader.content.gotoAndStop("off");
|
||||
if(_SFX_Crane_Servo_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_Crane_Servo_Instance);
|
||||
_SFX_Crane_Servo_Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function onYes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",playKeyDown);
|
||||
var _loc1_:int = UserCurrency.getCurrency(0);
|
||||
hideDlg();
|
||||
_crane.loader.content.CraneClearSuccess();
|
||||
_soundMan.playByName(_soundNameCraneInsertCoin);
|
||||
messageServer(["cp"]);
|
||||
if(_goMC)
|
||||
{
|
||||
if(_goMC.loader.parent)
|
||||
{
|
||||
_goMC.loader.parent.removeChild(_goMC.loader);
|
||||
}
|
||||
_scene.releaseCloneAsset(_goMC.loader);
|
||||
_goMC = null;
|
||||
}
|
||||
_goMC = _scene.cloneAsset("goPopup");
|
||||
if(_goMC)
|
||||
{
|
||||
_goMC.loader.x = 251;
|
||||
_goMC.loader.y = 76;
|
||||
_guiLayer.addChild(_goMC.loader);
|
||||
_goCountdown = 1.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_goCountdown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function onNo() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",playKeyDown);
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
public function popupTryAgain() : void
|
||||
{
|
||||
stage.addEventListener("keyDown",playKeyDown);
|
||||
var _loc1_:String = "popup_try";
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 57)
|
||||
{
|
||||
case 0:
|
||||
_loc1_ = "popup_try_25";
|
||||
}
|
||||
}
|
||||
var _loc2_:MovieClip = showDlg(_loc1_,[{
|
||||
"name":"button_yes",
|
||||
"f":onYes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onNo
|
||||
}]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,447 @@
|
||||
package game.microGameInvasion
|
||||
{
|
||||
import currency.UserCurrency;
|
||||
import den.DenItem;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import gui.GiftPopup;
|
||||
import item.Item;
|
||||
|
||||
public class MicroGameInvasion extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _bInit:Boolean;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _layerBack:Sprite;
|
||||
|
||||
public var _sceneLoaded:Boolean;
|
||||
|
||||
private var _prizePopup:GiftPopup;
|
||||
|
||||
private var _playSuccessNumber:int;
|
||||
|
||||
private var _prizeDenItem:DenItem;
|
||||
|
||||
private var _prizeAccessory:Item;
|
||||
|
||||
private var _prizePopupActive:Boolean;
|
||||
|
||||
private var _serialNumber:int;
|
||||
|
||||
private var _needGemsTimer:Number;
|
||||
|
||||
private var _audio:Array = ["pi_menuEnter.mp3","pi_menuExit.mp3","pi_popupFireColor.mp3","pi_ufoDamaged.mp3","pi_ufoDestroyed.mp3","pi_ufoEnter.mp3","pi_ufoExit.mp3","pi_ufoTractorBeam.mp3","pi_ufoWarp.mp3","pi_weaponCharge.mp3","pi_weaponFire.mp3"];
|
||||
|
||||
private var _soundNameMenuEnter:String = _audio[0];
|
||||
|
||||
private var _soundNameMenuExit:String = _audio[1];
|
||||
|
||||
private var _soundNamePopupFireColor:String = _audio[2];
|
||||
|
||||
private var _soundNameUfoDamaged:String = _audio[3];
|
||||
|
||||
private var _soundNameUfoDestroyed:String = _audio[4];
|
||||
|
||||
private var _soundNameUfoEnter:String = _audio[5];
|
||||
|
||||
private var _soundNameUfoExit:String = _audio[6];
|
||||
|
||||
private var _soundNameUfoTractorBeam:String = _audio[7];
|
||||
|
||||
private var _soundNameUfoWarp:String = _audio[8];
|
||||
|
||||
private var _soundNameWeaponCharge:String = _audio[9];
|
||||
|
||||
private var _soundNameWeaponFire:String = _audio[10];
|
||||
|
||||
public function MicroGameInvasion()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMenuEnter],_soundNameMenuEnter,1.12);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMenuExit],_soundNameMenuExit,1.15);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupFireColor],_soundNamePopupFireColor,1.18);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoDamaged],_soundNameUfoDamaged,1.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoDestroyed],_soundNameUfoDestroyed,1.31);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoEnter],_soundNameUfoEnter,1.08);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoExit],_soundNameUfoExit,1.21);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoTractorBeam],_soundNameUfoTractorBeam,1.27);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameUfoWarp],_soundNameUfoWarp,1.38);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWeaponCharge],_soundNameWeaponCharge,1.04);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWeaponFire],_soundNameWeaponFire,1.41);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
hideDlg();
|
||||
releaseBase();
|
||||
resetGame();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
_bInit = false;
|
||||
removeLayer(_layerBack);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBack = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_needGemsTimer = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBack = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBack);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroGameInvasion/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("xbutton");
|
||||
addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_theGame = _scene.getLayer("thegame");
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 55)
|
||||
{
|
||||
case 0:
|
||||
_theGame.loader.content.machine.setType(1);
|
||||
break;
|
||||
default:
|
||||
_theGame.loader.content.machine.setType(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.machine.setType(0);
|
||||
}
|
||||
_layerBack.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
private function keyHandleDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.machine.shoot();
|
||||
_theGame.loader.content.machine.respondYes();
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.machine.respondNo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "cp")
|
||||
{
|
||||
if(param1[3] != "1" && param1[3] != "0")
|
||||
{
|
||||
_theGame.loader.content.machine.noGems();
|
||||
_needGemsTimer = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_playSuccessNumber = Math.random() * 10000 + 1;
|
||||
_serialNumber = parseInt(param1[4]);
|
||||
if(param1[5] == "1")
|
||||
{
|
||||
_prizeAccessory = null;
|
||||
_prizeDenItem = new DenItem();
|
||||
_prizeDenItem.initShopItem(param1[6],param1[8]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_prizeDenItem = null;
|
||||
_prizeAccessory = new Item();
|
||||
_prizeAccessory.init(param1[6],0,param1[8],-1,-1);
|
||||
}
|
||||
_theGame.loader.content.machine.hasGems(_playSuccessNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function keptItem() : void
|
||||
{
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
var _loc1_:int = 11;
|
||||
var _loc2_:Number = _loc1_ * 5 + (gMainFrame.server.userId + 99) * 3 + (_serialNumber + 49) * 5;
|
||||
var _loc3_:Number = (_serialNumber + gMainFrame.server.userId + _loc1_) * 3 + _loc1_ * 3;
|
||||
messageServer(["cd",_loc2_,_loc3_]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function rejectedItem() : void
|
||||
{
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
messageServer(["cd","2","0"]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function destroyPrizePopup() : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
_theGame.loader.content.machine.newRound();
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc3_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.machine.menuEnter)
|
||||
{
|
||||
_theGame.loader.content.machine.menuEnter = false;
|
||||
_soundMan.playByName(_soundNameMenuEnter);
|
||||
}
|
||||
if(_theGame.loader.content.machine.menuExit)
|
||||
{
|
||||
_theGame.loader.content.machine.menuExit = false;
|
||||
_soundMan.playByName(_soundNameMenuExit);
|
||||
}
|
||||
if(_theGame.loader.content.machine.popupFireColor)
|
||||
{
|
||||
_theGame.loader.content.machine.popupFireColor = false;
|
||||
_soundMan.playByName(_soundNamePopupFireColor);
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoDamaged)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoDamaged = false;
|
||||
_soundMan.playByName(_soundNameUfoDamaged);
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoDestroyed)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoDestroyed = false;
|
||||
_soundMan.playByName(_soundNameUfoDestroyed);
|
||||
}
|
||||
if(_theGame.loader.content.machine.rolloverSound)
|
||||
{
|
||||
_theGame.loader.content.machine.rolloverSound = false;
|
||||
AJAudio.playHudBtnRollover();
|
||||
}
|
||||
if(_theGame.loader.content.machine.clickSound)
|
||||
{
|
||||
_theGame.loader.content.machine.clickSound = false;
|
||||
AJAudio.playHudBtnClick();
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoEnter)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoEnter = false;
|
||||
_soundMan.playByName(_soundNameUfoEnter);
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoExit)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoExit = false;
|
||||
_soundMan.playByName(_soundNameUfoExit);
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoTractorBeam)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoTractorBeam = false;
|
||||
_soundMan.playByName(_soundNameUfoTractorBeam);
|
||||
}
|
||||
if(_theGame.loader.content.machine.ufoWarp)
|
||||
{
|
||||
_theGame.loader.content.machine.ufoWarp = false;
|
||||
_soundMan.playByName(_soundNameUfoWarp);
|
||||
}
|
||||
if(_theGame.loader.content.machine.weaponCharge)
|
||||
{
|
||||
_theGame.loader.content.machine.weaponCharge = false;
|
||||
_soundMan.playByName(_soundNameWeaponCharge);
|
||||
}
|
||||
if(_theGame.loader.content.machine.weaponFire)
|
||||
{
|
||||
_theGame.loader.content.machine.weaponFire = false;
|
||||
_soundMan.playByName(_soundNameWeaponFire);
|
||||
}
|
||||
if(_needGemsTimer > 0)
|
||||
{
|
||||
_needGemsTimer -= _frameTime;
|
||||
if(_needGemsTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(_prizePopup == null)
|
||||
{
|
||||
if(_theGame.loader.content.machine.exit == true)
|
||||
{
|
||||
_theGame.loader.content.machine.exit = false;
|
||||
onCloseButton();
|
||||
}
|
||||
else if(_theGame.loader.content.machine.end == true && !_prizePopupActive)
|
||||
{
|
||||
_theGame.loader.content.machine.end = false;
|
||||
_loc3_ = int(_theGame.loader.content.machine.results);
|
||||
_loc3_ = _loc3_ / 5 - (_playSuccessNumber + 39) * 7;
|
||||
if(_loc3_ == 11)
|
||||
{
|
||||
_prizePopup = new GiftPopup();
|
||||
_prizePopupActive = true;
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
if(_prizeDenItem != null)
|
||||
{
|
||||
_prizePopup.init(this.parent,_prizeDenItem.icon,_prizeDenItem.name,_prizeDenItem.defId,2,2,keptItem,rejectedItem,destroyPrizePopup);
|
||||
}
|
||||
else
|
||||
{
|
||||
_prizePopup.init(this.parent,_prizeAccessory.largeIcon,_prizeAccessory.name,_prizeAccessory.defId,2,1,keptItem,rejectedItem,destroyPrizePopup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageServer(["cd","0","0"]);
|
||||
_theGame.loader.content.machine.newRound();
|
||||
}
|
||||
}
|
||||
else if(_theGame.loader.content.machine.clickedStart == true)
|
||||
{
|
||||
_theGame.loader.content.machine.clickedStart = false;
|
||||
clickedStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function clickedStart() : void
|
||||
{
|
||||
var _loc1_:int = UserCurrency.getCurrency(0);
|
||||
messageServer(["cp"]);
|
||||
_prizePopupActive = false;
|
||||
_theGame.loader.content.machine.end = false;
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
package game.microGoldPanning
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroGoldPanning extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["ajq_goldPan1.mp3","ajq_goldPan2.mp3","ajq_goldPan3.mp3","ajq_goldPan4.mp3","ajq_miningStinger.mp3","ajq_textEnter.mp3","ajq_textExit.mp3","ajq_resourceMoving2Bag.mp3","ajq_resourceDrop.mp3","ajq_resourcePopupEnter.mp3","ajq_resourcePopUpExit.mp3","ajq_satchelClose.mp3","ajq_satchelOpen.mp3","ajq_panWaterDip.mp3"];
|
||||
|
||||
private var _soundNameGoldPan1:String = _audio[0];
|
||||
|
||||
private var _soundNameGoldPan2:String = _audio[1];
|
||||
|
||||
private var _soundNameGoldPan3:String = _audio[2];
|
||||
|
||||
private var _soundNameGoldPan4:String = _audio[3];
|
||||
|
||||
private var _soundNameStinger:String = _audio[4];
|
||||
|
||||
private var _soundNameTextEnter:String = _audio[5];
|
||||
|
||||
private var _soundNameTextExit:String = _audio[6];
|
||||
|
||||
private var _soundNameResourceMove:String = _audio[7];
|
||||
|
||||
private var _soundNameResourceDrop:String = _audio[8];
|
||||
|
||||
private var _soundNamePopupEnter:String = _audio[9];
|
||||
|
||||
private var _soundNamePopupExit:String = _audio[10];
|
||||
|
||||
private var _soundNameSatchelClose:String = _audio[11];
|
||||
|
||||
private var _soundNameSatchelOpen:String = _audio[12];
|
||||
|
||||
private var _soundNameWaterDip:String = _audio[13];
|
||||
|
||||
public function MicroGoldPanning()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGoldPan1],_soundNameGoldPan1,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGoldPan2],_soundNameGoldPan2,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGoldPan3],_soundNameGoldPan3,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGoldPan4],_soundNameGoldPan4,0.7);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStinger],_soundNameStinger,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextEnter],_soundNameTextEnter,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextExit],_soundNameTextExit,1.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceMove],_soundNameResourceMove,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceDrop],_soundNameResourceDrop,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupEnter],_soundNamePopupEnter,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupExit],_soundNamePopupExit,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelClose],_soundNameSatchelClose,0.73);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelOpen],_soundNameSatchelOpen,0.82);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWaterDip],_soundNameWaterDip,0.5);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroGoldPanning/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.gameFinished)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_textEnter = false;
|
||||
_soundMan.playByName(_soundNameTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_textExit = false;
|
||||
_soundMan.playByName(_soundNameTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_miningStinger)
|
||||
{
|
||||
_theGame.loader.content.ajq_miningStinger = false;
|
||||
_soundMan.playByName(_soundNameStinger);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_goldPan1)
|
||||
{
|
||||
_theGame.loader.content.ajq_goldPan1 = false;
|
||||
_soundMan.playByName(_soundNameGoldPan1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_goldPan2)
|
||||
{
|
||||
_theGame.loader.content.ajq_goldPan2 = false;
|
||||
_soundMan.playByName(_soundNameGoldPan2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_goldPan3)
|
||||
{
|
||||
_theGame.loader.content.ajq_goldPan3 = false;
|
||||
_soundMan.playByName(_soundNameGoldPan3);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_goldPan4)
|
||||
{
|
||||
_theGame.loader.content.ajq_goldPan4 = false;
|
||||
_soundMan.playByName(_soundNameGoldPan4);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopupEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopupEnter = false;
|
||||
_soundMan.playByName(_soundNamePopupEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopUpExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopUpExit = false;
|
||||
_soundMan.playByName(_soundNamePopupExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceMoveToBag)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceMoveToBag = false;
|
||||
_soundMan.playByName(_soundNameResourceMove);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceDrop)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceDrop = false;
|
||||
_soundMan.playByName(_soundNameResourceDrop);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelClose)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelClose = false;
|
||||
_soundMan.playByName(_soundNameSatchelClose);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelOpen)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelOpen = false;
|
||||
_soundMan.playByName(_soundNameSatchelOpen);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_panWaterDip)
|
||||
{
|
||||
_theGame.loader.content.ajq_panWaterDip = false;
|
||||
_soundMan.playByName(_soundNameWaterDip);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
MinigameManager.handleQuestMiniGameComplete(_theGame.loader.content.reward);
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
package game.microHotCocoa
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroHotCocoa extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["aj_cocoa_button_select.mp3","aj_cocoa_condiment_enter.mp3","aj_cocoa_cup_option_enter.mp3","aj_cocoa_cup_option_exit.mp3","aj_cocoa_enjoy.mp3","aj_cocoa_lever_down.mp3","aj_cocoa_lever_enter.mp3","aj_cocoa_lever_stop.mp3","aj_cocoa_lever_up.mp3","aj_cocoa_pour_topping_enter.mp3","aj_cocoa_rollover.mp3","aj_cocoa_topping_select.mp3","aj_cocoa_vend_select_enter.mp3","aj_cocoa_marshmallow_splash.mp3","aj_cocoa_whipcream.mp3","aj_cocoa_lever_click.mp3"];
|
||||
|
||||
private var _soundNameButtonSelect:String = _audio[0];
|
||||
|
||||
private var _soundNameCondimentEnter:String = _audio[1];
|
||||
|
||||
private var _soundNameCupOptionEnter:String = _audio[2];
|
||||
|
||||
private var _soundNameCupOptionExit:String = _audio[3];
|
||||
|
||||
private var _soundNameEnjoy:String = _audio[4];
|
||||
|
||||
private var _soundNameLeverDown:String = _audio[5];
|
||||
|
||||
private var _soundNameLeverEnter:String = _audio[6];
|
||||
|
||||
private var _soundNameLeverStop:String = _audio[7];
|
||||
|
||||
private var _soundNameLeverUp:String = _audio[8];
|
||||
|
||||
private var _soundNamePourToppingEnter:String = _audio[9];
|
||||
|
||||
private var _soundNameRollover:String = _audio[10];
|
||||
|
||||
private var _soundNameToppingSelect:String = _audio[11];
|
||||
|
||||
private var _soundNameVendSelectEnter:String = _audio[12];
|
||||
|
||||
private var _soundNameMarshmallowSplash:String = _audio[13];
|
||||
|
||||
private var _soundNameWhipCream:String = _audio[14];
|
||||
|
||||
private var _soundNameLeverPull:String = _audio[15];
|
||||
|
||||
private var _leverPullSound:SoundChannel;
|
||||
|
||||
public function MicroHotCocoa()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameButtonSelect],_soundNameButtonSelect,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCondimentEnter],_soundNameCondimentEnter,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCupOptionEnter],_soundNameCupOptionEnter,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCupOptionExit],_soundNameCupOptionExit,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEnjoy],_soundNameEnjoy,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverDown],_soundNameLeverDown,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverEnter],_soundNameLeverEnter,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverStop],_soundNameLeverStop,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverUp],_soundNameLeverUp,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourToppingEnter],_soundNamePourToppingEnter,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameToppingSelect],_soundNameToppingSelect,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameVendSelectEnter],_soundNameVendSelectEnter,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMarshmallowSplash],_soundNameMarshmallowSplash,0.37);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWhipCream],_soundNameWhipCream,0.43);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLeverPull],_soundNameLeverPull,0.95);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_leverPullSound)
|
||||
{
|
||||
_leverPullSound.stop();
|
||||
_leverPullSound = null;
|
||||
}
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_leverPullSound = null;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroHotCocoa/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.button_select)
|
||||
{
|
||||
_theGame.loader.content.button_select = false;
|
||||
_soundMan.playByName(_soundNameButtonSelect);
|
||||
}
|
||||
if(_theGame.loader.content.condiment_enter)
|
||||
{
|
||||
_theGame.loader.content.condiment_enter = false;
|
||||
_soundMan.playByName(_soundNameCondimentEnter);
|
||||
}
|
||||
if(_theGame.loader.content.cup_option_enter)
|
||||
{
|
||||
_theGame.loader.content.cup_option_enter = false;
|
||||
_soundMan.playByName(_soundNameCupOptionEnter);
|
||||
}
|
||||
if(_theGame.loader.content.cup_option_exit)
|
||||
{
|
||||
_theGame.loader.content.cup_option_exit = false;
|
||||
_soundMan.playByName(_soundNameCupOptionExit);
|
||||
}
|
||||
if(_theGame.loader.content.enjoy)
|
||||
{
|
||||
_theGame.loader.content.enjoy = false;
|
||||
_soundMan.playByName(_soundNameEnjoy);
|
||||
}
|
||||
if(_theGame.loader.content.lever_down)
|
||||
{
|
||||
if(_leverPullSound)
|
||||
{
|
||||
_leverPullSound.stop();
|
||||
_leverPullSound = null;
|
||||
}
|
||||
_leverPullSound = _soundMan.playByName(_soundNameLeverPull,0,5);
|
||||
_theGame.loader.content.lever_down = false;
|
||||
}
|
||||
if(_theGame.loader.content.lever_up)
|
||||
{
|
||||
if(_leverPullSound)
|
||||
{
|
||||
_leverPullSound.stop();
|
||||
_leverPullSound = null;
|
||||
}
|
||||
_leverPullSound = _soundMan.playByName(_soundNameLeverPull,0,5);
|
||||
_theGame.loader.content.lever_up = false;
|
||||
}
|
||||
if(_theGame.loader.content.lever_stop)
|
||||
{
|
||||
if(_leverPullSound)
|
||||
{
|
||||
_leverPullSound.stop();
|
||||
_leverPullSound = null;
|
||||
}
|
||||
_theGame.loader.content.lever_stop = false;
|
||||
_soundMan.playByName(_soundNameLeverStop);
|
||||
}
|
||||
if(_theGame.loader.content.lever_enter)
|
||||
{
|
||||
_theGame.loader.content.lever_enter = false;
|
||||
_soundMan.playByName(_soundNameLeverEnter);
|
||||
}
|
||||
if(_theGame.loader.content.pour_topping_enter)
|
||||
{
|
||||
_theGame.loader.content.pour_topping_enter = false;
|
||||
_soundMan.playByName(_soundNamePourToppingEnter);
|
||||
}
|
||||
if(_theGame.loader.content.rollover)
|
||||
{
|
||||
_theGame.loader.content.rollover = false;
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
if(_theGame.loader.content.topping_select)
|
||||
{
|
||||
_theGame.loader.content.topping_select = false;
|
||||
_soundMan.playByName(_soundNameToppingSelect);
|
||||
}
|
||||
if(_theGame.loader.content.vend_select_enter)
|
||||
{
|
||||
_theGame.loader.content.vend_select_enter = false;
|
||||
_soundMan.playByName(_soundNameVendSelectEnter);
|
||||
}
|
||||
if(_theGame.loader.content.marshmallow_splash)
|
||||
{
|
||||
_theGame.loader.content.marshmallow_splash = false;
|
||||
_soundMan.playByName(_soundNameMarshmallowSplash);
|
||||
}
|
||||
if(_theGame.loader.content.whipcream)
|
||||
{
|
||||
_theGame.loader.content.whipcream = false;
|
||||
_soundMan.playByName(_soundNameWhipCream);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
if(messageServer != null)
|
||||
{
|
||||
messageServer(["_a",5,_theGame.loader.content.cocoaInfo]);
|
||||
}
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,566 @@
|
||||
package game.microMiraSays
|
||||
{
|
||||
import achievement.AchievementManager;
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class MicroMiraSays extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _displayAchievementTimer:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _failed:Boolean;
|
||||
|
||||
public var _score:int;
|
||||
|
||||
public var _gemsEarnedInRound:int;
|
||||
|
||||
public var _roundEnded:Boolean;
|
||||
|
||||
public var _awards:Array;
|
||||
|
||||
private var _audio:Array = ["mira_says_note1.mp3","mira_says_note2.mp3","mira_says_note3.mp3","mira_says_note4.mp3","mira_says_rollover.mp3","MG_pop_up.mp3","mira_says_flash_1_2.mp3","mira_says_flash_1_4.mp3","mira_says_flash_2_2.mp3","mira_says_flash_2_4.mp3","mira_says_flash_3_2.mp3","mira_says_flash_3_4.mp3","mira_says_flash_4_2.mp3","mira_says_flash_4_4.mp3","mira_says_Go_Whoosh.mp3","mira_says_star1.mp3","mira_says_star2.mp3","mira_says_star3.mp3","mira_says_star4.mp3","mira_says_wrong_button.mp3"];
|
||||
|
||||
private var _soundNameButton1:String = _audio[0];
|
||||
|
||||
private var _soundNameButton2:String = _audio[1];
|
||||
|
||||
private var _soundNameButton3:String = _audio[2];
|
||||
|
||||
private var _soundNameButton4:String = _audio[3];
|
||||
|
||||
private var _soundNameRollover:String = _audio[4];
|
||||
|
||||
private var _soundNamePopup:String = _audio[5];
|
||||
|
||||
private var _soundNameFlash_1_2:String = _audio[6];
|
||||
|
||||
private var _soundNameFlash_1_4:String = _audio[7];
|
||||
|
||||
private var _soundNameFlash_2_2:String = _audio[8];
|
||||
|
||||
private var _soundNameFlash_2_4:String = _audio[9];
|
||||
|
||||
private var _soundNameFlash_3_2:String = _audio[10];
|
||||
|
||||
private var _soundNameFlash_3_4:String = _audio[11];
|
||||
|
||||
private var _soundNameFlash_4_2:String = _audio[12];
|
||||
|
||||
private var _soundNameFlash_4_4:String = _audio[13];
|
||||
|
||||
private var _soundNameGoWhoosh:String = _audio[14];
|
||||
|
||||
private var _soundNameStar1:String = _audio[15];
|
||||
|
||||
private var _soundNameStar2:String = _audio[16];
|
||||
|
||||
private var _soundNameStar3:String = _audio[17];
|
||||
|
||||
private var _soundNameStar4:String = _audio[18];
|
||||
|
||||
private var _soundNameWrongButton:String = _audio[19];
|
||||
|
||||
public function MicroMiraSays()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameButton1],_soundNameButton1,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameButton2],_soundNameButton2,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameButton3],_soundNameButton3,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameButton4],_soundNameButton4,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopup],_soundNamePopup,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_1_2],_soundNameFlash_1_2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_1_4],_soundNameFlash_1_4,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_2_2],_soundNameFlash_2_2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_2_4],_soundNameFlash_2_4,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_3_2],_soundNameFlash_3_2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_3_4],_soundNameFlash_3_4,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_4_2],_soundNameFlash_4_2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFlash_4_4],_soundNameFlash_4_4,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGoWhoosh],_soundNameGoWhoosh,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStar1],_soundNameStar1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStar2],_soundNameStar2,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStar3],_soundNameStar3,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStar4],_soundNameStar4,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWrongButton],_soundNameWrongButton,0.15);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_gameTime > 15 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_displayAchievementTimer = 0;
|
||||
_score = 0;
|
||||
_gemsEarnedInRound = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroMiraSays/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_roundEnded = false;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_failed = false;
|
||||
_score = 0;
|
||||
_awards = [false,false,false,false,false];
|
||||
_gemsEarnedInRound = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.goSound = false;
|
||||
_theGame.loader.content.button1Sound = false;
|
||||
_theGame.loader.content.button2Sound = false;
|
||||
_theGame.loader.content.button3Sound = false;
|
||||
_theGame.loader.content.button4Sound = false;
|
||||
_theGame.loader.content.rollover1Sound = false;
|
||||
_theGame.loader.content.rollover2Sound = false;
|
||||
_theGame.loader.content.rollover3Sound = false;
|
||||
_theGame.loader.content.rollover4Sound = false;
|
||||
_theGame.loader.content.instructionSound = false;
|
||||
_theGame.loader.content.failSound = false;
|
||||
_loc1_ = 1;
|
||||
while(_loc1_ < 5)
|
||||
{
|
||||
_theGame.loader.content.starSound[_loc1_] = false;
|
||||
_theGame.loader.content.successSound[_loc1_] = false;
|
||||
_theGame.loader.content.prizeSound[_loc1_] = false;
|
||||
_loc1_++;
|
||||
}
|
||||
_theGame.loader.content.setGemsEarned(_gemsEarnedInRound);
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:* = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc7_:Array = null;
|
||||
var _loc5_:Array = null;
|
||||
var _loc8_:Array = null;
|
||||
var _loc4_:MovieClip = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
if(_displayAchievementTimer > 0)
|
||||
{
|
||||
_displayAchievementTimer -= _frameTime;
|
||||
if(_displayAchievementTimer <= 0)
|
||||
{
|
||||
_displayAchievementTimer = 0;
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.failSound)
|
||||
{
|
||||
_theGame.loader.content.failSound = false;
|
||||
_soundMan.playByName(_soundNameWrongButton);
|
||||
}
|
||||
if(_failed == false)
|
||||
{
|
||||
if(!_roundEnded)
|
||||
{
|
||||
if(_theGame.loader.content.gameState == "success")
|
||||
{
|
||||
_roundEnded = true;
|
||||
_loc3_ = 0;
|
||||
if(!_awards[0] && _theGame.loader.content.award1)
|
||||
{
|
||||
_awards[0] = true;
|
||||
switch(_theGame.loader.content.prize1)
|
||||
{
|
||||
case 1:
|
||||
_loc3_ += 5;
|
||||
break;
|
||||
case 2:
|
||||
_loc3_ += 10;
|
||||
}
|
||||
}
|
||||
if(!_awards[1] && _theGame.loader.content.award2)
|
||||
{
|
||||
_awards[1] = true;
|
||||
switch(_theGame.loader.content.prize2)
|
||||
{
|
||||
case 1:
|
||||
_loc3_ += 5;
|
||||
break;
|
||||
case 2:
|
||||
_loc3_ += 10;
|
||||
}
|
||||
}
|
||||
if(!_awards[2] && _theGame.loader.content.award3)
|
||||
{
|
||||
_awards[2] = true;
|
||||
switch(_theGame.loader.content.prize3)
|
||||
{
|
||||
case 1:
|
||||
_loc3_ += 5;
|
||||
break;
|
||||
case 2:
|
||||
_loc3_ += 10;
|
||||
}
|
||||
}
|
||||
if(!_awards[3] && _theGame.loader.content.award4)
|
||||
{
|
||||
_awards[3] = true;
|
||||
switch(_theGame.loader.content.prize4)
|
||||
{
|
||||
case 1:
|
||||
_loc3_ += 5;
|
||||
break;
|
||||
case 2:
|
||||
_loc3_ += 10;
|
||||
}
|
||||
}
|
||||
_score = (_theGame.loader.content.score - _score) / 2000;
|
||||
_loc3_ += _score;
|
||||
_score *= 2000;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
addGemsToBalance(_loc3_);
|
||||
_gemsEarnedInRound += _loc3_;
|
||||
_theGame.loader.content.setGemsEarned(_gemsEarnedInRound);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_theGame.loader.content.gameState != "success")
|
||||
{
|
||||
_roundEnded = false;
|
||||
}
|
||||
if(!_failed && _theGame.loader.content.gameState != "fail")
|
||||
{
|
||||
if(_theGame.loader.content.button1Sound)
|
||||
{
|
||||
_theGame.loader.content.button1Sound = false;
|
||||
_soundMan.playByName(_soundNameButton1);
|
||||
}
|
||||
if(_theGame.loader.content.button2Sound)
|
||||
{
|
||||
_theGame.loader.content.button2Sound = false;
|
||||
_soundMan.playByName(_soundNameButton2);
|
||||
}
|
||||
if(_theGame.loader.content.button3Sound)
|
||||
{
|
||||
_theGame.loader.content.button3Sound = false;
|
||||
_soundMan.playByName(_soundNameButton3);
|
||||
}
|
||||
if(_theGame.loader.content.button4Sound)
|
||||
{
|
||||
_theGame.loader.content.button4Sound = false;
|
||||
_soundMan.playByName(_soundNameButton4);
|
||||
}
|
||||
if(_theGame.loader.content.rollover1Sound || _theGame.loader.content.rollover2Sound || _theGame.loader.content.rollover3Sound || _theGame.loader.content.rollover4Sound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
_theGame.loader.content.rollover1Sound = false;
|
||||
_theGame.loader.content.rollover2Sound = false;
|
||||
_theGame.loader.content.rollover3Sound = false;
|
||||
_theGame.loader.content.rollover4Sound = false;
|
||||
}
|
||||
if(_theGame.loader.content.instructionSound)
|
||||
{
|
||||
_theGame.loader.content.instructionSound = false;
|
||||
_soundMan.playByName(_soundNamePopup);
|
||||
}
|
||||
if(_theGame.loader.content.goSound)
|
||||
{
|
||||
_theGame.loader.content.goSound = false;
|
||||
_soundMan.playByName(_soundNameGoWhoosh);
|
||||
}
|
||||
_loc7_ = [0,_soundNameFlash_1_2,_soundNameFlash_2_2,_soundNameFlash_3_2,_soundNameFlash_4_2];
|
||||
_loc5_ = [0,_soundNameFlash_1_4,_soundNameFlash_2_4,_soundNameFlash_3_4,_soundNameFlash_4_4];
|
||||
_loc8_ = [0,_soundNameStar1,_soundNameStar2,_soundNameStar3,_soundNameStar4];
|
||||
_loc6_ = 1;
|
||||
while(_loc6_ < 5)
|
||||
{
|
||||
if(_theGame.loader.content.successSound[_loc6_])
|
||||
{
|
||||
_theGame.loader.content.successSound[_loc6_] = false;
|
||||
_soundMan.playByName(_loc7_[_loc6_]);
|
||||
}
|
||||
if(_theGame.loader.content.prizeSound[_loc6_])
|
||||
{
|
||||
_theGame.loader.content.prizeSound[_loc6_] = false;
|
||||
_soundMan.playByName(_loc5_[_loc6_]);
|
||||
}
|
||||
if(_theGame.loader.content.starSound[_loc6_])
|
||||
{
|
||||
_theGame.loader.content.starSound[_loc6_] = false;
|
||||
_soundMan.playByName(_loc8_[_loc6_]);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
else if(!_pauseGame)
|
||||
{
|
||||
_score = (_theGame.loader.content.score - _score) / 2000;
|
||||
_loc3_ += _score;
|
||||
_score *= 2000;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
addGemsToBalance(_loc3_);
|
||||
_gemsEarnedInRound += _loc3_;
|
||||
_theGame.loader.content.setGemsEarned(_gemsEarnedInRound);
|
||||
}
|
||||
_closeBtn.visible = false;
|
||||
_failed = true;
|
||||
stage.addEventListener("keyDown",replayKeyDown);
|
||||
_loc4_ = showDlg("MS_Game_Over",[{
|
||||
"name":"button_yes",
|
||||
"f":onFail_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onFail_No
|
||||
}]);
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc4_.points,11550,_theGame.loader.content.score);
|
||||
LocalizationManager.translateIdAndInsert(_loc4_.Gems_Earned,11432,_gemsEarnedInRound);
|
||||
}
|
||||
if(!_pauseGame && !_awards[4] && _theGame.loader.content.award5)
|
||||
{
|
||||
_awards[4] = true;
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).custom1UserVarRef,1);
|
||||
_theGame._displayAchievementTimer = 1;
|
||||
}
|
||||
_closeBtn.visible = false;
|
||||
_failed = true;
|
||||
stage.addEventListener("keyDown",replayKeyDown);
|
||||
_loc4_ = showDlg("MS_Game_Over",[{
|
||||
"name":"button_yes",
|
||||
"f":onFail_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onFail_No
|
||||
}]);
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc4_.points,11550,_theGame.loader.content.score);
|
||||
LocalizationManager.translateIdAndInsert(_loc4_.Gems_Earned,11432,_gemsEarnedInRound);
|
||||
_roundEnded = false;
|
||||
}
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
}
|
||||
}
|
||||
|
||||
private function replayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onFail_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onFail_No();
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
_theGame.loader.content.unpauseGame();
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onFail_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
_displayAchievementTimer = 1;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.newRound();
|
||||
startGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onFail_No() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onGemMultiplierDone() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
package game.microOatHarvest
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroOatHarvest extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["ajq_miningStinger.mp3","ajq_strawImp1.mp3","ajq_strawImp2.mp3","ajq_strawSlice1.mp3","ajq_strawSlice2.mp3","ajq_textEnter.mp3","ajq_textExit.mp3","ajq_resourceMoving2Bag.mp3","ajq_resourceDrop.mp3","ajq_resourcePopupEnter.mp3","ajq_resourcePopUpExit.mp3","ajq_satchelClose.mp3","ajq_satchelOpen.mp3"];
|
||||
|
||||
private var _soundNameStinger:String = _audio[0];
|
||||
|
||||
private var _soundNameOatImp1:String = _audio[1];
|
||||
|
||||
private var _soundNameOatImp2:String = _audio[2];
|
||||
|
||||
private var _soundNameOatSlice1:String = _audio[3];
|
||||
|
||||
private var _soundNameOatSlice2:String = _audio[4];
|
||||
|
||||
private var _soundNameTextEnter:String = _audio[5];
|
||||
|
||||
private var _soundNameTextExit:String = _audio[6];
|
||||
|
||||
private var _soundNameResourceMove:String = _audio[7];
|
||||
|
||||
private var _soundNameResourceDrop:String = _audio[8];
|
||||
|
||||
private var _soundNamePopupEnter:String = _audio[9];
|
||||
|
||||
private var _soundNamePopupExit:String = _audio[10];
|
||||
|
||||
private var _soundNameSatchelClose:String = _audio[11];
|
||||
|
||||
private var _soundNameSatchelOpen:String = _audio[12];
|
||||
|
||||
public function MicroOatHarvest()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStinger],_soundNameStinger,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameOatImp1],_soundNameOatImp1,0.32);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameOatImp2],_soundNameOatImp2,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameOatSlice1],_soundNameOatSlice1,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameOatSlice2],_soundNameOatSlice2,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextEnter],_soundNameTextEnter,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextExit],_soundNameTextExit,1.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceMove],_soundNameResourceMove,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceDrop],_soundNameResourceDrop,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupEnter],_soundNamePopupEnter,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupExit],_soundNamePopupExit,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelClose],_soundNameSatchelClose,0.73);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelOpen],_soundNameSatchelOpen,0.82);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroOatHarvest/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.gameFinished)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_textEnter = false;
|
||||
_soundMan.playByName(_soundNameTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_textExit = false;
|
||||
_soundMan.playByName(_soundNameTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_miningStinger)
|
||||
{
|
||||
_theGame.loader.content.ajq_miningStinger = false;
|
||||
_soundMan.playByName(_soundNameStinger);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_strawImp1)
|
||||
{
|
||||
_theGame.loader.content.ajq_strawImp1 = false;
|
||||
_soundMan.playByName(_soundNameOatImp1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_strawImp2)
|
||||
{
|
||||
_theGame.loader.content.ajq_strawImp2 = false;
|
||||
_soundMan.playByName(_soundNameOatImp2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_strawSlice1)
|
||||
{
|
||||
_theGame.loader.content.ajq_strawSlice1 = false;
|
||||
_soundMan.playByName(_soundNameOatSlice1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_strawSlice2)
|
||||
{
|
||||
_theGame.loader.content.ajq_strawSlice2 = false;
|
||||
_soundMan.playByName(_soundNameOatSlice2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopupEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopupEnter = false;
|
||||
_soundMan.playByName(_soundNamePopupEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopUpExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopUpExit = false;
|
||||
_soundMan.playByName(_soundNamePopupExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceMoveToBag)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceMoveToBag = false;
|
||||
_soundMan.playByName(_soundNameResourceMove);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceDrop)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceDrop = false;
|
||||
_soundMan.playByName(_soundNameResourceDrop);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelClose)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelClose = false;
|
||||
_soundMan.playByName(_soundNameSatchelClose);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelOpen)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelOpen = false;
|
||||
_soundMan.playByName(_soundNameSatchelOpen);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
MinigameManager.handleQuestMiniGameComplete(_theGame.loader.content.reward);
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,500 @@
|
||||
package game.microPetSalon
|
||||
{
|
||||
import currency.UserCurrency;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import gui.DarkenManager;
|
||||
|
||||
public class MicroPetSalon extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
private static const COST_OF_PET:int = 200;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
protected var _doneButton:MovieClip;
|
||||
|
||||
protected var _resetButton:MovieClip;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _pet:Object;
|
||||
|
||||
public var _pet2:Object;
|
||||
|
||||
public var _updatingPet:Boolean;
|
||||
|
||||
public var _petLoadedCount:int;
|
||||
|
||||
private var _audio:Array = ["aj_PS_ChairSpin.mp3","aj_PS_ChairSpinReveal.mp3","aj_PS_cupboardClose.mp3","aj_PS_cupboardOpen.mp3","aj_PS_SalonDrawersClose.mp3","aj_PS_SalonDrawersOpen.mp3","aj_PS_trunkClose.mp3","aj_PS_trunkOpen.mp3","aj_PS_ItemSelect.mp3","aj_PS_petEnters.mp3","aj_PS_reset.mp3","aj_PS_RollOver.mp3"];
|
||||
|
||||
private var _soundNameChairSpin:String = _audio[0];
|
||||
|
||||
private var _soundNameChairSpinReveal:String = _audio[1];
|
||||
|
||||
private var _soundNameCupboardClose:String = _audio[2];
|
||||
|
||||
private var _soundNameCupboardOpen:String = _audio[3];
|
||||
|
||||
private var _soundNameSalonDrawersClose:String = _audio[4];
|
||||
|
||||
private var _soundNameSalonDrawersOpen:String = _audio[5];
|
||||
|
||||
private var _soundNameTrunkClose:String = _audio[6];
|
||||
|
||||
private var _soundNameTrunkOpen:String = _audio[7];
|
||||
|
||||
private var _soundNameItemSelect:String = _audio[8];
|
||||
|
||||
private var _soundNamePetEnters:String = _audio[9];
|
||||
|
||||
private var _soundNameReset:String = _audio[10];
|
||||
|
||||
private var _soundNameRollOver:String = _audio[11];
|
||||
|
||||
public function MicroPetSalon()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameChairSpin],_soundNameChairSpin,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameChairSpinReveal],_soundNameChairSpinReveal,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCupboardClose],_soundNameCupboardClose,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCupboardOpen],_soundNameCupboardOpen,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSalonDrawersClose],_soundNameSalonDrawersClose,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSalonDrawersOpen],_soundNameSalonDrawersOpen,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTrunkClose],_soundNameTrunkClose,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTrunkOpen],_soundNameTrunkOpen,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameItemSelect],_soundNameItemSelect,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePetEnters],_soundNamePetEnters,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameReset],_soundNameReset,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollOver],_soundNameRollOver,0.5);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_layerMain)
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",onCostCloseKeyDown);
|
||||
stage.removeEventListener("keyDown",onConfirmKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_updatingPet = false;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroPetSalon/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_resetButton = addBtn("PetSalon_reset",125,481,onResetDlg);
|
||||
_doneButton = addBtn("PetSalon_done",791,481,showDoneDlg);
|
||||
_closeBtn = addBtn("CloseButton",800,44,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_theGame.loader.content.showConfirm = false;
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 81)
|
||||
{
|
||||
case 0:
|
||||
_theGame.loader.content.specialItems();
|
||||
}
|
||||
}
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc7_:* = null;
|
||||
var _loc3_:* = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:MovieClip = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false && _updatingPet == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.ChairSpin)
|
||||
{
|
||||
_theGame.loader.content.ChairSpin = false;
|
||||
_soundMan.playByName(_soundNameChairSpin);
|
||||
}
|
||||
if(_theGame.loader.content.ChairSpinReveal)
|
||||
{
|
||||
_theGame.loader.content.ChairSpinReveal = false;
|
||||
_soundMan.playByName(_soundNameChairSpinReveal);
|
||||
}
|
||||
if(_theGame.loader.content.cupboardClose)
|
||||
{
|
||||
_theGame.loader.content.cupboardClose = false;
|
||||
_soundMan.playByName(_soundNameCupboardClose);
|
||||
}
|
||||
if(_theGame.loader.content.cupboardOpen)
|
||||
{
|
||||
_theGame.loader.content.cupboardOpen = false;
|
||||
_soundMan.playByName(_soundNameCupboardOpen);
|
||||
}
|
||||
if(_theGame.loader.content.SalonDrawersClose)
|
||||
{
|
||||
_theGame.loader.content.SalonDrawersClose = false;
|
||||
_soundMan.playByName(_soundNameSalonDrawersClose);
|
||||
}
|
||||
if(_theGame.loader.content.SalonDrawersOpen)
|
||||
{
|
||||
_theGame.loader.content.SalonDrawersOpen = false;
|
||||
_soundMan.playByName(_soundNameSalonDrawersOpen);
|
||||
}
|
||||
if(_theGame.loader.content.trunkOpen)
|
||||
{
|
||||
_theGame.loader.content.trunkOpen = false;
|
||||
_soundMan.playByName(_soundNameTrunkOpen);
|
||||
}
|
||||
if(_theGame.loader.content.trunkClose)
|
||||
{
|
||||
_theGame.loader.content.trunkClose = false;
|
||||
_soundMan.playByName(_soundNameTrunkClose);
|
||||
}
|
||||
if(_theGame.loader.content.itemClicked)
|
||||
{
|
||||
_theGame.loader.content.itemClicked = false;
|
||||
_soundMan.playByName(_soundNameItemSelect);
|
||||
}
|
||||
if(_theGame.loader.content.RollOver)
|
||||
{
|
||||
_theGame.loader.content.RollOver = false;
|
||||
_soundMan.playByName(_soundNameRollOver);
|
||||
}
|
||||
if(_theGame.loader.content.showConfirm)
|
||||
{
|
||||
_theGame.loader.content.showConfirm = false;
|
||||
_loc2_ = UserCurrency.getCurrency(0);
|
||||
if(_loc2_ >= 200)
|
||||
{
|
||||
_loc4_ = showDlg("PetSalon_confirm",[{
|
||||
"name":"yesBtn",
|
||||
"f":onDone_Yes
|
||||
},{
|
||||
"name":"noBtn",
|
||||
"f":onDone_No
|
||||
}]);
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275 - 100;
|
||||
stage.addEventListener("keyDown",onConfirmKeyDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = showDlg("PetSalon_costPopup",[{
|
||||
"name":"x_btn",
|
||||
"f":onCostClose
|
||||
}]);
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
_loc4_.gemsTxt.text = _loc2_;
|
||||
_loc4_.costTxt.text = 200;
|
||||
_loc4_.needTxt.text = 200 - _loc2_;
|
||||
stage.addEventListener("keyDown",onCostCloseKeyDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onConfirmKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onDone_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onDone_No();
|
||||
}
|
||||
}
|
||||
|
||||
private function onCostCloseKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onCostClose();
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_petLoadedCount = 0;
|
||||
_pet = MinigameManager.getActivePet(petLoaded);
|
||||
if(_pet == null)
|
||||
{
|
||||
_theGame.loader.content.setUpPet(null,0,0,0,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pet2 = MinigameManager.getActivePet(petLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function petLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_petLoadedCount = _petLoadedCount + 1;
|
||||
if(_petLoadedCount >= 2)
|
||||
{
|
||||
if(_pet.canGoInOcean() && MinigameManager.roomEnviroType == 1)
|
||||
{
|
||||
_theGame.loader.content.underWater();
|
||||
}
|
||||
_theGame.loader.content.setUpPet(_pet,_pet.getLBits(),_pet.getUBits(),_pet.getEBits(),_pet.getType(),MinigameManager.roomEnviroType,_pet2);
|
||||
_pet.getChildAt(0).pet.setAnim(1);
|
||||
_soundMan.playByName(_soundNamePetEnters);
|
||||
}
|
||||
}
|
||||
|
||||
public function petUpdated(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(!param1)
|
||||
{
|
||||
_loc2_ = showDlg("PetSalon_error",[{
|
||||
"name":"okBtn",
|
||||
"f":onError_OK
|
||||
}]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onError_OK() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
private function onResetDlg() : void
|
||||
{
|
||||
_soundMan.playByName(_soundNameReset);
|
||||
_theGame.loader.content.reset();
|
||||
}
|
||||
|
||||
private function showDoneDlg() : void
|
||||
{
|
||||
if(_theGame.loader.content.cat9 != _theGame.loader.content.cat9original || _theGame.loader.content.cat10 != _theGame.loader.content.cat10original || _theGame.loader.content.cat11 != _theGame.loader.content.cat11original)
|
||||
{
|
||||
_theGame.loader.content.showConfirm = false;
|
||||
_theGame.loader.content.faceFront();
|
||||
_closeBtn.visible = false;
|
||||
_doneButton.visible = false;
|
||||
_resetButton.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onCostClose() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onCostCloseKeyDown);
|
||||
_theGame.loader.content.faceBack();
|
||||
_closeBtn.visible = true;
|
||||
_doneButton.visible = true;
|
||||
_resetButton.visible = true;
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onDone_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onConfirmKeyDown);
|
||||
hideDlg();
|
||||
_closeBtn.visible = false;
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
MinigameManager.sendPetItemRequest(_theGame.loader.content.cat9,_theGame.loader.content.cat10,_theGame.loader.content.cat11,MinigameManager.roomEnviroType,petUpdated);
|
||||
_updatingPet = true;
|
||||
}
|
||||
|
||||
private function onDone_No() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onConfirmKeyDown);
|
||||
_theGame.loader.content.faceBack();
|
||||
hideDlg();
|
||||
_doneButton.visible = true;
|
||||
_resetButton.visible = true;
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
showExitConfirmationDlg();
|
||||
}
|
||||
|
||||
private function showExitConfirmationDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("PetSalon_areYouSure",[{
|
||||
"name":"yesBtn",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"noBtn",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
_doneButton.visible = false;
|
||||
_resetButton.visible = false;
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_doneButton.visible = true;
|
||||
_resetButton.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
package game.microPetWash
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroPetWash extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static var SFX_MICROPET_dispenser_lights_lp:Class;
|
||||
|
||||
public static var SFX_MICROPET_water_dripping:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _sentSparkle:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _pet:Object;
|
||||
|
||||
private var _audio:Array = ["aj_cart_rollout.mp3","aj_pw_brushes_fast.mp3","aj_pw_brushes_medium.mp3","aj_pw_brushes_slow.mp3","aj_pw_bubbleDispenser_lower.mp3","aj_pw_bubbles_released.mp3","aj_pw_chain_lower.mp3","aj_pw_petEnters.mp3","aj_pw_rinse.mp3","aj_pw_rinseAscend.mp3","aj_pw_spray.mp3","aj_pw_towelDry.mp3","aj_pw_wash_stinger.mp3","aj_pw_wash_select.mp3"];
|
||||
|
||||
private var _soundNameCartRollout:String = _audio[0];
|
||||
|
||||
private var _soundNameBrushesFast:String = _audio[1];
|
||||
|
||||
private var _soundNameBrushesMedium:String = _audio[2];
|
||||
|
||||
private var _soundNameBrushesSlow:String = _audio[3];
|
||||
|
||||
private var _soundNameBubbleDispenserLower:String = _audio[4];
|
||||
|
||||
private var _soundNameBubblesReleased:String = _audio[5];
|
||||
|
||||
private var _soundNameChainLower:String = _audio[6];
|
||||
|
||||
private var _soundNamePetEnters:String = _audio[7];
|
||||
|
||||
private var _soundNameRinse:String = _audio[8];
|
||||
|
||||
private var _soundNameRinseAscend:String = _audio[9];
|
||||
|
||||
private var _soundNameSpray:String = _audio[10];
|
||||
|
||||
private var _soundNameTowelDry:String = _audio[11];
|
||||
|
||||
private var _soundNameWashStinger:String = _audio[12];
|
||||
|
||||
private var _soundNameWashSelect:String = _audio[13];
|
||||
|
||||
private var _SFX_MICROPET_dispenser_lights_lp_Instance:SoundChannel;
|
||||
|
||||
private var _SFX_MICROPET_water_dripping_Instance:SoundChannel;
|
||||
|
||||
public function MicroPetWash()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCartRollout],_soundNameCartRollout,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBrushesFast],_soundNameBrushesFast,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBrushesMedium],_soundNameBrushesMedium,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBrushesSlow],_soundNameBrushesSlow,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBubbleDispenserLower],_soundNameBubbleDispenserLower,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBubblesReleased],_soundNameBubblesReleased,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameChainLower],_soundNameChainLower,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePetEnters],_soundNamePetEnters,0.9);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRinse],_soundNameRinse,0.7);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRinseAscend],_soundNameRinseAscend,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSpray],_soundNameSpray,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTowelDry],_soundNameTowelDry,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWashStinger],_soundNameWashStinger,0.7);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWashSelect],_soundNameWashSelect,0.45);
|
||||
_soundMan.addSound(SFX_MICROPET_dispenser_lights_lp,0.45,"SFX_MICROPET_dispenser_lights_lp");
|
||||
_soundMan.addSound(SFX_MICROPET_water_dripping,0.6,"SFX_MICROPET_water_dripping");
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_SFX_MICROPET_dispenser_lights_lp_Instance)
|
||||
{
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance.stop();
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance = null;
|
||||
}
|
||||
if(_SFX_MICROPET_water_dripping_Instance)
|
||||
{
|
||||
_SFX_MICROPET_water_dripping_Instance.stop();
|
||||
_SFX_MICROPET_water_dripping_Instance = null;
|
||||
}
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance = null;
|
||||
_SFX_MICROPET_water_dripping_Instance = null;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroPetWash/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
SFX_MICROPET_dispenser_lights_lp = getDefinitionByName("dispenser_lights_lp") as Class;
|
||||
if(SFX_MICROPET_dispenser_lights_lp == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:dispenser_lights_lp");
|
||||
}
|
||||
SFX_MICROPET_water_dripping = getDefinitionByName("water_Dripping") as Class;
|
||||
if(SFX_MICROPET_water_dripping == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:water_Dripping");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closebutton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("thegame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.wash_stinger)
|
||||
{
|
||||
_theGame.loader.content.wash_stinger = false;
|
||||
_soundMan.playByName(_soundNameWashStinger);
|
||||
}
|
||||
if(_theGame.loader.content.wash_select)
|
||||
{
|
||||
_theGame.loader.content.wash_select = false;
|
||||
_soundMan.playByName(_soundNameWashSelect);
|
||||
}
|
||||
if(_theGame.loader.content.spray)
|
||||
{
|
||||
_theGame.loader.content.spray = false;
|
||||
_soundMan.playByName(_soundNameSpray);
|
||||
}
|
||||
if(_theGame.loader.content.petEnters)
|
||||
{
|
||||
_theGame.loader.content.petEnters = false;
|
||||
_soundMan.playByName(_soundNamePetEnters);
|
||||
}
|
||||
if(_theGame.loader.content.rinse)
|
||||
{
|
||||
_theGame.loader.content.rinse = false;
|
||||
_soundMan.playByName(_soundNameRinse);
|
||||
}
|
||||
if(_theGame.loader.content.rinseAscend)
|
||||
{
|
||||
_theGame.loader.content.rinseAscend = false;
|
||||
_soundMan.playByName(_soundNameRinseAscend);
|
||||
}
|
||||
if(_theGame.loader.content.towelDry)
|
||||
{
|
||||
_theGame.loader.content.towelDry = false;
|
||||
_soundMan.playByName(_soundNameTowelDry);
|
||||
}
|
||||
if(_theGame.loader.content.cart_rollout)
|
||||
{
|
||||
_theGame.loader.content.cart_rollout = false;
|
||||
_soundMan.playByName(_soundNameCartRollout);
|
||||
}
|
||||
if(_theGame.loader.content.brushes_fast)
|
||||
{
|
||||
_theGame.loader.content.brushes_fast = false;
|
||||
_soundMan.playByName(_soundNameBrushesFast);
|
||||
}
|
||||
if(_theGame.loader.content.brushes_medium)
|
||||
{
|
||||
_theGame.loader.content.brushes_medium = false;
|
||||
_soundMan.playByName(_soundNameBrushesMedium);
|
||||
}
|
||||
if(_theGame.loader.content.brushes_slow)
|
||||
{
|
||||
_theGame.loader.content.brushes_slow = false;
|
||||
_soundMan.playByName(_soundNameBrushesSlow);
|
||||
}
|
||||
if(_theGame.loader.content.bubbleDispenser_lower)
|
||||
{
|
||||
_theGame.loader.content.bubbleDispenser_lower = false;
|
||||
_soundMan.playByName(_soundNameBubbleDispenserLower);
|
||||
}
|
||||
if(_theGame.loader.content.bubbles_released)
|
||||
{
|
||||
_theGame.loader.content.bubbles_released = false;
|
||||
_soundMan.playByName(_soundNameBubblesReleased);
|
||||
}
|
||||
if(_theGame.loader.content.chain_lower)
|
||||
{
|
||||
_theGame.loader.content.chain_lower = false;
|
||||
_soundMan.playByName(_soundNameChainLower);
|
||||
}
|
||||
if(_theGame.loader.content.dispenser_lights_lp)
|
||||
{
|
||||
if(_SFX_MICROPET_dispenser_lights_lp_Instance == null)
|
||||
{
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance = _soundMan.play(SFX_MICROPET_dispenser_lights_lp,0,99999);
|
||||
}
|
||||
}
|
||||
else if(_SFX_MICROPET_dispenser_lights_lp_Instance != null)
|
||||
{
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance.stop();
|
||||
_SFX_MICROPET_dispenser_lights_lp_Instance = null;
|
||||
}
|
||||
if(_theGame.loader.content.water_dripping)
|
||||
{
|
||||
if(_SFX_MICROPET_water_dripping_Instance == null)
|
||||
{
|
||||
_SFX_MICROPET_water_dripping_Instance = _soundMan.play(SFX_MICROPET_water_dripping,0,99999);
|
||||
}
|
||||
}
|
||||
else if(_SFX_MICROPET_water_dripping_Instance != null)
|
||||
{
|
||||
_SFX_MICROPET_water_dripping_Instance.stop();
|
||||
_SFX_MICROPET_water_dripping_Instance = null;
|
||||
}
|
||||
if(!_sentSparkle && _theGame.loader.content.sparkleReady)
|
||||
{
|
||||
MinigameManager.setPetSparkle(_theGame.loader.content.effectInfo);
|
||||
_sentSparkle = true;
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_pet = MinigameManager.getActivePet(petLoaded);
|
||||
if(_pet == null)
|
||||
{
|
||||
_theGame.loader.content.setUpPet(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function petLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_theGame.loader.content.setUpPet(_pet);
|
||||
_pet.getChildAt(0).pet.setAnim(1);
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,695 @@
|
||||
package game.microPhantom
|
||||
{
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import den.DenItem;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.utils.getDefinitionByName;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
import gui.GiftPopup;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class MicroPhantom extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const GEMS_PER_PHANTOM:int = 3;
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static var SFX_PHANTOM_TORCHACTIVE:Class;
|
||||
|
||||
public static var SFX_PHANTOM_TORCHFLAME:Class;
|
||||
|
||||
public static var SFX_PHANTOM_IDLE:Class;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _loseTimer:Number;
|
||||
|
||||
public var _winnerReset:Boolean;
|
||||
|
||||
public var _totalPhantomsKilled:int;
|
||||
|
||||
public var _torchCollisionTimer:Number;
|
||||
|
||||
public var _torchCollisionVolume:Number;
|
||||
|
||||
public var _torchRelativeVolume:Number;
|
||||
|
||||
public var _phantomIdleVolume:Number;
|
||||
|
||||
public var _phantomRelativeVolume:Number;
|
||||
|
||||
public var _torchFlameVolume:Number;
|
||||
|
||||
public var _torchFlameRelativeVolume:Number;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _hasItem:Boolean;
|
||||
|
||||
private var _prizePopup:GiftPopup;
|
||||
|
||||
private var _prize:DenItem;
|
||||
|
||||
private var _roundCounter:int;
|
||||
|
||||
private var _audio:Array = ["phantom_eats_candy1.mp3","phantom_eats_candy2.mp3","phantom_eats_candy3.mp3","phantom_eats_candy4.mp3","phantom_growl1.mp3","phantom_growl2.mp3","phantom_growl3.mp3","phantom_growl4.mp3","phantom_growl5.mp3","phantom_light_shaft_off.mp3","phantom_light_shaft_on.mp3","phantom_prize.mp3","phantom_stinger_fail.mp3","phantom_stinger_success.mp3","phantom_torch_collision.mp3","phantom_torch_collision2.mp3","phantom_torch_collision3.mp3","vo_phatom_death1.mp3","vo_phatom_death2.mp3","vo_phatom_death3.mp3","vo_phatom_death4.mp3","vo_phatom_death5.mp3","vo_phatom_death6.mp3","MG_pop_ups.mp3","phantom_candy_fall.mp3"];
|
||||
|
||||
private var _soundNameEatsCandy1:String = _audio[0];
|
||||
|
||||
private var _soundNameEatsCandy2:String = _audio[1];
|
||||
|
||||
private var _soundNameEatsCandy3:String = _audio[2];
|
||||
|
||||
private var _soundNameEatsCandy4:String = _audio[3];
|
||||
|
||||
private var _soundNameGrowl1:String = _audio[4];
|
||||
|
||||
private var _soundNameGrowl2:String = _audio[5];
|
||||
|
||||
private var _soundNameGrowl3:String = _audio[6];
|
||||
|
||||
private var _soundNameGrowl4:String = _audio[7];
|
||||
|
||||
private var _soundNameGrowl5:String = _audio[8];
|
||||
|
||||
private var _soundNameLightShaftOff:String = _audio[9];
|
||||
|
||||
private var _soundNameLightShaftOn:String = _audio[10];
|
||||
|
||||
private var _soundNamePrize:String = _audio[11];
|
||||
|
||||
private var _soundNameStingerFail:String = _audio[12];
|
||||
|
||||
private var _soundNameStingerSuccess:String = _audio[13];
|
||||
|
||||
private var _soundNameCollision1:String = _audio[14];
|
||||
|
||||
private var _soundNameCollision2:String = _audio[15];
|
||||
|
||||
private var _soundNameCollision3:String = _audio[16];
|
||||
|
||||
private var _soundNameDeath1:String = _audio[17];
|
||||
|
||||
private var _soundNameDeath2:String = _audio[18];
|
||||
|
||||
private var _soundNameDeath3:String = _audio[19];
|
||||
|
||||
private var _soundNameDeath4:String = _audio[20];
|
||||
|
||||
private var _soundNameDeath5:String = _audio[21];
|
||||
|
||||
private var _soundNameDeath6:String = _audio[22];
|
||||
|
||||
private var _soundNamePopUps:String = _audio[23];
|
||||
|
||||
private var _soundNameCandyFall:String = _audio[24];
|
||||
|
||||
private var _SFX_Phantom_TorchActive_Instance:SoundChannel;
|
||||
|
||||
private var _SFX_Phantom_TorchFlame_Instance:SoundChannel;
|
||||
|
||||
private var _SFX_Phantom_Idle_Instance:SoundChannel;
|
||||
|
||||
public function MicroPhantom()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEatsCandy1],_soundNameEatsCandy1,0.47);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEatsCandy2],_soundNameEatsCandy2,0.47);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEatsCandy3],_soundNameEatsCandy3,0.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEatsCandy4],_soundNameEatsCandy4,0.36);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowl1],_soundNameGrowl1,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowl2],_soundNameGrowl2,0.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowl3],_soundNameGrowl3,0.54);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowl4],_soundNameGrowl4,0.49);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowl5],_soundNameGrowl5,0.44);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLightShaftOff],_soundNameLightShaftOff,1.01);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLightShaftOn],_soundNameLightShaftOn,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePrize],_soundNamePrize,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerFail],_soundNameStingerFail,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerSuccess],_soundNameStingerSuccess,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCollision1],_soundNameCollision1,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCollision2],_soundNameCollision2,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCollision3],_soundNameCollision3,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath1],_soundNameDeath1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath2],_soundNameDeath2,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath3],_soundNameDeath3,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath4],_soundNameDeath4,0.52);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath5],_soundNameDeath5,0.48);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeath6],_soundNameDeath6,0.46);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopUps],_soundNamePopUps,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCandyFall],_soundNameCandyFall,1);
|
||||
_torchRelativeVolume = 0.15;
|
||||
_torchFlameRelativeVolume = 0.29;
|
||||
_phantomRelativeVolume = 0.24;
|
||||
_soundMan.addSound(SFX_PHANTOM_TORCHACTIVE,_torchRelativeVolume,"SFX_PHANTOM_TORCHACTIVE");
|
||||
_soundMan.addSound(SFX_PHANTOM_TORCHFLAME,_torchFlameRelativeVolume,"SFX_PHANTOM_TORCHFLAME");
|
||||
_soundMan.addSound(SFX_PHANTOM_IDLE,_phantomRelativeVolume,"SFX_PHANTOM_IDLE");
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
messageServer(["pi"]);
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
}
|
||||
hideDlg();
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",onLoseKeyDown);
|
||||
stage.removeEventListener("keyDown",onLoseKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_SFX_Phantom_TorchActive_Instance = null;
|
||||
_SFX_Phantom_Idle_Instance = null;
|
||||
_SFX_Phantom_TorchFlame_Instance = null;
|
||||
_hasItem = false;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroPhantom/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
SFX_PHANTOM_TORCHACTIVE = getDefinitionByName("phantom_torch_active") as Class;
|
||||
if(SFX_PHANTOM_TORCHACTIVE == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:phantom_torch_active");
|
||||
}
|
||||
SFX_PHANTOM_TORCHFLAME = getDefinitionByName("Phantom_torch_flame") as Class;
|
||||
if(SFX_PHANTOM_TORCHFLAME == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:Phantom_torch_flame");
|
||||
}
|
||||
SFX_PHANTOM_IDLE = getDefinitionByName("phantom_idle") as Class;
|
||||
if(SFX_PHANTOM_IDLE == null)
|
||||
{
|
||||
throw new Error("Sound not found! name:phantom_idle");
|
||||
}
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "cp")
|
||||
{
|
||||
if(param1[3] == "0")
|
||||
{
|
||||
_hasItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasItem = false;
|
||||
_prize = new DenItem();
|
||||
_prize.initShopItem(param1[4],param1[6]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc9_:* = null;
|
||||
var _loc3_:SoundTransform = null;
|
||||
var _loc4_:Array = null;
|
||||
var _loc6_:Array = null;
|
||||
var _loc7_:Array = null;
|
||||
var _loc2_:Array = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(!SBAudio.isMusicMuted)
|
||||
{
|
||||
if(_theGame.loader.content.sNumPhantoms > 0)
|
||||
{
|
||||
if(_torchFlameVolume < 1)
|
||||
{
|
||||
_torchFlameVolume += _frameTime;
|
||||
if(_torchFlameVolume > 1)
|
||||
{
|
||||
_torchFlameVolume = 1;
|
||||
}
|
||||
if(_SFX_Phantom_TorchFlame_Instance == null)
|
||||
{
|
||||
_SFX_Phantom_TorchFlame_Instance = _soundMan.play(SFX_PHANTOM_TORCHFLAME,0,99999);
|
||||
}
|
||||
_loc3_ = new SoundTransform(_torchFlameVolume * _torchFlameRelativeVolume,0);
|
||||
_SFX_Phantom_TorchFlame_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
if(_phantomIdleVolume < 1)
|
||||
{
|
||||
_phantomIdleVolume += _frameTime;
|
||||
if(_phantomIdleVolume > 1)
|
||||
{
|
||||
_phantomIdleVolume = 1;
|
||||
}
|
||||
if(_SFX_Phantom_Idle_Instance == null)
|
||||
{
|
||||
_SFX_Phantom_Idle_Instance = _soundMan.play(SFX_PHANTOM_IDLE,0,99999);
|
||||
}
|
||||
_loc3_ = new SoundTransform(_phantomIdleVolume * _phantomRelativeVolume,0);
|
||||
_SFX_Phantom_Idle_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_torchFlameVolume > 0)
|
||||
{
|
||||
_torchFlameVolume -= _frameTime / 0.35;
|
||||
if(_torchFlameVolume <= 0 || _SFX_Phantom_TorchFlame_Instance == null)
|
||||
{
|
||||
_torchFlameVolume = 0;
|
||||
if(_SFX_Phantom_TorchFlame_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_Phantom_TorchFlame_Instance);
|
||||
_SFX_Phantom_TorchFlame_Instance = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new SoundTransform(_torchFlameVolume * _torchFlameRelativeVolume,0);
|
||||
_SFX_Phantom_TorchFlame_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
if(_phantomIdleVolume > 0)
|
||||
{
|
||||
_phantomIdleVolume -= _frameTime / 0.35;
|
||||
if(_phantomIdleVolume <= 0 || _SFX_Phantom_Idle_Instance == null)
|
||||
{
|
||||
_phantomIdleVolume = 0;
|
||||
if(_SFX_Phantom_Idle_Instance)
|
||||
{
|
||||
_soundMan.stop(_SFX_Phantom_Idle_Instance);
|
||||
_SFX_Phantom_Idle_Instance = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new SoundTransform(_phantomIdleVolume * _phantomRelativeVolume,0);
|
||||
_SFX_Phantom_Idle_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_torchCollisionTimer > 0)
|
||||
{
|
||||
_torchCollisionTimer -= _frameTime;
|
||||
if(_torchCollisionTimer > 0)
|
||||
{
|
||||
if(_torchCollisionVolume < 1)
|
||||
{
|
||||
_torchCollisionVolume += _frameTime;
|
||||
if(_torchCollisionVolume > 1)
|
||||
{
|
||||
_torchCollisionVolume = 1;
|
||||
}
|
||||
_loc3_ = new SoundTransform(_torchCollisionVolume * _torchRelativeVolume,0);
|
||||
_SFX_Phantom_TorchActive_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_SFX_Phantom_TorchActive_Instance)
|
||||
{
|
||||
_torchCollisionVolume -= _frameTime / 0.15;
|
||||
if(_torchCollisionVolume <= 0)
|
||||
{
|
||||
_soundMan.stop(_SFX_Phantom_TorchActive_Instance);
|
||||
_SFX_Phantom_TorchActive_Instance = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new SoundTransform(_torchCollisionVolume * _torchRelativeVolume,0);
|
||||
_SFX_Phantom_TorchActive_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.sCandyDrop)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCandyFall);
|
||||
_theGame.loader.content.sCandyDrop = false;
|
||||
}
|
||||
if(_theGame.loader.content.sTorchCollision)
|
||||
{
|
||||
if(_torchCollisionTimer <= 0)
|
||||
{
|
||||
_loc4_ = new Array(_soundNameCollision1,_soundNameCollision2,_soundNameCollision3);
|
||||
_loc8_ = Math.random() * _loc4_.length;
|
||||
_soundMan.playByName(_loc4_[_loc8_]);
|
||||
if(_SFX_Phantom_TorchActive_Instance == null)
|
||||
{
|
||||
_torchCollisionVolume = 0;
|
||||
_SFX_Phantom_TorchActive_Instance = _soundMan.play(SFX_PHANTOM_TORCHACTIVE,0,99999);
|
||||
_loc3_ = new SoundTransform(0,0);
|
||||
_SFX_Phantom_TorchActive_Instance.soundTransform = _loc3_;
|
||||
}
|
||||
}
|
||||
_torchCollisionTimer = 0.25;
|
||||
}
|
||||
}
|
||||
_loc9_;
|
||||
if(_theGame.loader.content.sNewPhantom)
|
||||
{
|
||||
_loc6_ = new Array(_soundNameGrowl1,_soundNameGrowl2,_soundNameGrowl3,_soundNameGrowl4,_soundNameGrowl5);
|
||||
_loc8_ = Math.random() * (_loc6_.length * 1.5);
|
||||
if(_loc8_ < _loc6_.length)
|
||||
{
|
||||
_soundMan.playByName(_loc6_[_loc8_]);
|
||||
}
|
||||
_theGame.loader.content.sNewPhantom = false;
|
||||
}
|
||||
if(_theGame.loader.content.sPhantomDied)
|
||||
{
|
||||
_loc7_ = new Array(_soundNameDeath1,_soundNameDeath2,_soundNameDeath3,_soundNameDeath4,_soundNameDeath5,_soundNameDeath6);
|
||||
_soundMan.playByName(_soundNameLightShaftOff);
|
||||
_loc8_ = Math.random() * _loc7_.length;
|
||||
_soundMan.playByName(_loc7_[_loc8_]);
|
||||
_theGame.loader.content.sPhantomDied = false;
|
||||
}
|
||||
if(_theGame.loader.content.sLightShaftAppeared)
|
||||
{
|
||||
_soundMan.playByName(_soundNameLightShaftOn);
|
||||
_theGame.loader.content.sLightShaftAppeared = false;
|
||||
}
|
||||
if(_theGame.loader.content.sPopups)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePopUps);
|
||||
_theGame.loader.content.sPopups = false;
|
||||
}
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_winnerReset)
|
||||
{
|
||||
if(_theGame && _theGame.loader.content.winner)
|
||||
{
|
||||
_roundCounter = _roundCounter + 1;
|
||||
if(_roundCounter == 5 && _hasItem == false && _prize != null)
|
||||
{
|
||||
_prizePopup = new GiftPopup();
|
||||
_prizePopup.init(this.parent,_prize.icon,_prize.name,_prize.defId,2,2,keptItem,rejectedItem,destroyPrizePopup);
|
||||
_soundMan.playByName(_soundNamePrize);
|
||||
}
|
||||
else
|
||||
{
|
||||
onWin();
|
||||
}
|
||||
_winnerReset = false;
|
||||
}
|
||||
else if(_loseTimer == 0)
|
||||
{
|
||||
if(_theGame && _theGame.loader.content.lose)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
_loseTimer = 1.25;
|
||||
_soundMan.playByName(_soundNameStingerFail);
|
||||
_loc2_ = new Array(_soundNameEatsCandy1,_soundNameEatsCandy2,_soundNameEatsCandy3,_soundNameEatsCandy4);
|
||||
_loc8_ = Math.random() * _loc2_.length;
|
||||
_soundMan.playByName(_loc2_[_loc8_]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loseTimer -= _frameTime;
|
||||
if(_loseTimer <= 0)
|
||||
{
|
||||
onLose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_theGame && _theGame.loader.content.winner == false)
|
||||
{
|
||||
_winnerReset = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_roundCounter = 0;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_torchCollisionTimer = 0;
|
||||
_torchCollisionVolume = 0;
|
||||
_phantomIdleVolume = 0;
|
||||
_torchFlameVolume = 0;
|
||||
_torchFlameRelativeVolume = 0.6;
|
||||
_totalPhantomsKilled = 0;
|
||||
_loseTimer = 0;
|
||||
_winnerReset = true;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.sLightFrameOffset = 12;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_SFX_Phantom_TorchActive_Instance)
|
||||
{
|
||||
_torchCollisionVolume = 0;
|
||||
_soundMan.stop(_SFX_Phantom_TorchActive_Instance);
|
||||
_SFX_Phantom_TorchActive_Instance = null;
|
||||
}
|
||||
if(_SFX_Phantom_Idle_Instance)
|
||||
{
|
||||
_phantomIdleVolume = 0;
|
||||
_soundMan.stop(_SFX_Phantom_Idle_Instance);
|
||||
_SFX_Phantom_Idle_Instance = null;
|
||||
}
|
||||
if(_SFX_Phantom_TorchFlame_Instance)
|
||||
{
|
||||
_torchFlameVolume = 0;
|
||||
_soundMan.stop(_SFX_Phantom_TorchFlame_Instance);
|
||||
_SFX_Phantom_TorchFlame_Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onLoseKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onLose_Yes();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onLose_No();
|
||||
}
|
||||
}
|
||||
|
||||
public function onLose() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("PhMicro_Game_Over",[{
|
||||
"name":"button_yes",
|
||||
"f":onLose_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onLose_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",onLoseKeyDown);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.text_score,11432,_totalPhantomsKilled * 3);
|
||||
}
|
||||
|
||||
private function onLose_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onLose_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onLoseKeyDown);
|
||||
hideDlg();
|
||||
_theGame.loader.content.reset();
|
||||
startGame();
|
||||
}
|
||||
|
||||
private function onWinKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onWinnerNextLevel();
|
||||
}
|
||||
}
|
||||
|
||||
public function onWin() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("PhMicro_Great_Job",[{
|
||||
"name":"button_nextlevel",
|
||||
"f":onWinnerNextLevel
|
||||
}]);
|
||||
var _loc2_:int = (_theGame.loader.content.points - _totalPhantomsKilled) * 3;
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",onLoseKeyDown);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Text_hit,11624,_theGame.loader.content.points);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Gems_Earned,11554,_loc2_);
|
||||
addGemsToBalance(_loc2_);
|
||||
_totalPhantomsKilled = _theGame.loader.content.points;
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Total_Gems,11549,_totalPhantomsKilled * 3);
|
||||
_soundMan.playByName(_soundNameStingerSuccess);
|
||||
}
|
||||
|
||||
private function onWinnerNextLevel() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",onLoseKeyDown);
|
||||
_theGame.loader.content.gotoAndPlay("nextRound");
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function keptItem() : void
|
||||
{
|
||||
_hasItem = true;
|
||||
messageServer(["pd","1"]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function rejectedItem() : void
|
||||
{
|
||||
messageServer(["pd","0"]);
|
||||
_prizePopup.close();
|
||||
}
|
||||
|
||||
private function destroyPrizePopup() : void
|
||||
{
|
||||
if(_prizePopup)
|
||||
{
|
||||
_prizePopup.destroy();
|
||||
_prizePopup = null;
|
||||
onWin();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,534 @@
|
||||
package game.microPopcorn
|
||||
{
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.SoundManager;
|
||||
import gskinner.motion.GTween;
|
||||
|
||||
public class MicroPopcorn extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const MAX_VELOCITY_X:Number = 450;
|
||||
|
||||
private static const MAX_VELOCITY_Y:Number = 250;
|
||||
|
||||
private static const ACCELERATION_X:Number = 2500;
|
||||
|
||||
private static const ACCELERATION_Y:Number = 450;
|
||||
|
||||
private static const BRAKE_X:Number = 4000;
|
||||
|
||||
private static const BRAKE_Y:Number = 800;
|
||||
|
||||
private static const REQUIRED_KERNELS:int = 15;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerBack:Sprite;
|
||||
|
||||
public var _layerFront:Sprite;
|
||||
|
||||
public var _layerKernels:Sprite;
|
||||
|
||||
public var _layerCupFront:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _readySetGo:Number;
|
||||
|
||||
private var _cupFront:Object;
|
||||
|
||||
private var _cupBack:Object;
|
||||
|
||||
private var _cupFrontMax:Object;
|
||||
|
||||
private var _cupBackMax:Object;
|
||||
|
||||
private var _popper:Object;
|
||||
|
||||
private var _popcornMachine:Object;
|
||||
|
||||
private var _ready:Object;
|
||||
|
||||
private var _congrats:Object;
|
||||
|
||||
private var _popStart:Object;
|
||||
|
||||
public var _leftArrowDown:Boolean;
|
||||
|
||||
public var _rightArrowDown:Boolean;
|
||||
|
||||
public var _downArrowDown:Boolean;
|
||||
|
||||
public var _upArrowDown:Boolean;
|
||||
|
||||
public var _popKernelTimer:Number;
|
||||
|
||||
public var _congratsTimer:Number;
|
||||
|
||||
public var _velocityX:Number;
|
||||
|
||||
public var _popcornCaught:int;
|
||||
|
||||
public var _kernelPoppedSounds:Array;
|
||||
|
||||
private var _audio:Array = ["kernel_popped1.mp3","kernel_popped2.mp3","burnt_kernel.mp3","bad kernel.mp3","good kernel.mp3","MG_popup_youWon.mp3","GS_Ready_Blink.mp3"];
|
||||
|
||||
private var _soundNameKernelPopped1:String = _audio[0];
|
||||
|
||||
private var _soundNameKernelPopped2:String = _audio[1];
|
||||
|
||||
private var _soundNameKernelBurnt:String = _audio[2];
|
||||
|
||||
private var _soundNameKernelBad:String = _audio[3];
|
||||
|
||||
private var _soundNameKernelGood:String = _audio[4];
|
||||
|
||||
private var _soundNamePlayerWins:String = _audio[5];
|
||||
|
||||
private var _soundNameReady:String = _audio[6];
|
||||
|
||||
public var _SFX_POP_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
public function MicroPopcorn()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_SFX_POP_Music = _soundMan.addStream("popcorn_lp",1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameKernelPopped1],_soundNameKernelPopped1,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameKernelPopped2],_soundNameKernelPopped2,1);
|
||||
_kernelPoppedSounds = new Array(_soundNameKernelPopped1,_soundNameKernelPopped2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameKernelBurnt],_soundNameKernelBurnt,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameKernelBad],_soundNameKernelBad,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameKernelGood],_soundNameKernelGood,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerWins],_soundNamePlayerWins,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameReady],_soundNameReady,0.65);
|
||||
}
|
||||
|
||||
private function keyHandleUp(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = false;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = false;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = false;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function keyHandleDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = true;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = true;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = true;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",startKeyDown);
|
||||
stage.removeEventListener("keyUp",keyHandleUp);
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("click",mouseClickHandler);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerBack);
|
||||
removeLayer(_layerFront);
|
||||
removeLayer(_layerKernels);
|
||||
removeLayer(_layerCupFront);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBack = null;
|
||||
_layerFront = null;
|
||||
_layerKernels = null;
|
||||
_layerCupFront = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBack = new Sprite();
|
||||
_layerFront = new Sprite();
|
||||
_layerKernels = new Sprite();
|
||||
_layerCupFront = new Sprite();
|
||||
_layerBack.mouseEnabled = false;
|
||||
_layerFront.mouseEnabled = false;
|
||||
_layerKernels.mouseEnabled = false;
|
||||
_layerCupFront.mouseEnabled = false;
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBack);
|
||||
addChild(_layerKernels);
|
||||
addChild(_layerFront);
|
||||
addChild(_layerCupFront);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PopcornAssets/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_musicLoop = _soundMan.playStream(_SFX_POP_Music,0,999999);
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_cupFront = _scene.getLayer("pop_bucket_front");
|
||||
_cupBack = _scene.getLayer("pop_bucket_rear");
|
||||
_cupFrontMax = _scene.getLayer("pop_bucket_front_max");
|
||||
_cupBackMax = _scene.getLayer("pop_bucket_rear_max");
|
||||
_popper = _scene.getLayer("pop_popper");
|
||||
_popcornMachine = _scene.getLayer("popcornMachine");
|
||||
_layerBack.addChild(_scene.getLayer("pop_background").loader);
|
||||
_layerBack.addChild(_popper.loader);
|
||||
_layerBack.addChild(_cupBack.loader);
|
||||
_layerKernels.addChild(_popcornMachine.loader);
|
||||
_layerFront.addChild(_scene.getLayer("pop_foreground").loader);
|
||||
_layerFront.addChild(_scene.getLayer("pop_foreground_top").loader);
|
||||
_layerCupFront.addChild(_cupFront.loader);
|
||||
_congrats = _scene.getLayer("pop_congrats");
|
||||
_popStart = _scene.getLayer("pop_exit");
|
||||
_leftArrowDown = false;
|
||||
_rightArrowDown = false;
|
||||
_downArrowDown = false;
|
||||
_upArrowDown = false;
|
||||
stage.addEventListener("keyUp",keyHandleUp);
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("click",mouseClickHandler);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:* = null;
|
||||
var _loc5_:Point = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
if(_readySetGo > 0)
|
||||
{
|
||||
_readySetGo -= _frameTime;
|
||||
if(_readySetGo <= 0)
|
||||
{
|
||||
if(_ready && _ready.loader.parent)
|
||||
{
|
||||
_ready.loader.parent.removeChild(_ready.loader);
|
||||
_scene.releaseCloneAsset(_ready.loader);
|
||||
_ready = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_popcornCaught < 15)
|
||||
{
|
||||
if(_popKernelTimer >= 0)
|
||||
{
|
||||
_loc5_ = localToGlobal(new Point(_cupBack.loader.x,_cupBack.loader.y));
|
||||
switch(_popcornMachine.loader.content.detectCollision(_loc5_.x,_loc5_.y,_cupBack.width,_cupBack.height + 75))
|
||||
{
|
||||
case 0:
|
||||
_soundMan.playByName(_soundNameKernelBad);
|
||||
_popcornCaught -= 2;
|
||||
if(_popcornCaught < 0)
|
||||
{
|
||||
_popcornCaught = 0;
|
||||
}
|
||||
updatePopcornMeter();
|
||||
_cupFront.loader.content.losePopcorn();
|
||||
break;
|
||||
case 1:
|
||||
_soundMan.playByName(_soundNameKernelGood);
|
||||
_popcornCaught += 2;
|
||||
updatePopcornMeter();
|
||||
if(_popcornCaught >= 15)
|
||||
{
|
||||
new GTween(_popcornMachine.loader,0.5,{"alpha":0});
|
||||
_soundMan.playByName(_soundNamePlayerWins);
|
||||
_guiLayer.addChild(_congrats.loader);
|
||||
_congrats.loader.content.Ready_Text.gotoAndPlay("on");
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
if(messageServer != null)
|
||||
{
|
||||
messageServer(["_a",1]);
|
||||
}
|
||||
_congratsTimer = 2;
|
||||
}
|
||||
}
|
||||
_popKernelTimer -= _frameTime;
|
||||
if(_popKernelTimer <= 0)
|
||||
{
|
||||
_loc4_ = Math.min(2,Math.random() * 6);
|
||||
_popKernelTimer = 0.5 + Math.random() * 0.5;
|
||||
_popcornMachine.loader.content.popKernel(_loc4_);
|
||||
_loc2_ = Math.random() * _kernelPoppedSounds.length;
|
||||
_soundMan.playByName(_kernelPoppedSounds[_loc2_]);
|
||||
if(_loc4_ == 0)
|
||||
{
|
||||
_soundMan.playByName(_soundNameKernelBurnt);
|
||||
}
|
||||
}
|
||||
_cupBack.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
_cupFront.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
if(_cupFront.loader.x < _cupFront.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBack.x;
|
||||
_cupFront.loader.x = _cupFront.x;
|
||||
}
|
||||
else if(_cupFront.loader.x > _cupFrontMax.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBackMax.x;
|
||||
_cupFront.loader.x = _cupFrontMax.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_congratsTimer -= _frameTime;
|
||||
if(_congratsTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePopcornMeter() : void
|
||||
{
|
||||
var _loc1_:int = 2;
|
||||
if(_popcornCaught > 0)
|
||||
{
|
||||
_loc1_ = Math.max(3,_popcornCaught / 15 * 15 + 1);
|
||||
}
|
||||
_cupFront.loader.content.gotoAndStop(_loc1_);
|
||||
}
|
||||
|
||||
public function updateControls() : void
|
||||
{
|
||||
if(stage.mouseX < _cupFront.loader.x + _cupFront.width / 3)
|
||||
{
|
||||
_velocityX -= 2500 * _frameTime;
|
||||
if(_velocityX < -450)
|
||||
{
|
||||
_velocityX = -450;
|
||||
}
|
||||
}
|
||||
else if(stage.mouseX > _cupFront.loader.x + 2 * _cupFront.width / 3)
|
||||
{
|
||||
_velocityX += 2500 * _frameTime;
|
||||
if(_velocityX > 450)
|
||||
{
|
||||
_velocityX = 450;
|
||||
}
|
||||
}
|
||||
else if(_velocityX > 0)
|
||||
{
|
||||
_velocityX -= 4000 * _frameTime;
|
||||
if(_velocityX < 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
else if(_velocityX < 0)
|
||||
{
|
||||
_velocityX += 4000 * _frameTime;
|
||||
if(_velocityX > 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function startKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onStart();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onCloseButton();
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc1_:MovieClip = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_popKernelTimer = -1;
|
||||
_popcornCaught = 0;
|
||||
_velocityX = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_loc3_ = (_cupFrontMax.x - _cupFront.x) / 2;
|
||||
_cupFront.loader.x = _cupFront.x + _loc3_;
|
||||
_cupBack.loader.x = _cupBack.x + _loc3_;
|
||||
_cupFront.loader.content.gotoAndStop(2);
|
||||
_loc1_ = showDlg("popup_fill",[{
|
||||
"name":"button_play",
|
||||
"f":onStart
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",startKeyDown);
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
private function mouseClickHandler(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
|
||||
public function onStart() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",startKeyDown);
|
||||
hideDlg();
|
||||
if(_ready && _ready.loader.parent)
|
||||
{
|
||||
_ready.loader.parent.removeChild(_ready.loader);
|
||||
}
|
||||
_readySetGo = 3;
|
||||
_ready = _scene.cloneAsset("pop_ready");
|
||||
_guiLayer.addChild(_ready.loader);
|
||||
_soundMan.playByName(_soundNameReady);
|
||||
_popKernelTimer = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,445 @@
|
||||
package game.microPuppy
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class MicroPuppy extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _pet:Object;
|
||||
|
||||
public var _goldFrisbees:int;
|
||||
|
||||
public var _gemsAwarded:int;
|
||||
|
||||
private var _audio:Array = ["pup_frisbee1.mp3","pup_frisbee2.mp3","pup_frisbee3.mp3","pup_frisbeeCollision1.mp3","pup_frisbeeCollision2.mp3","pup_frisbeeCollision3.mp3","pup_growlJump.mp3","pup_growlMiss.mp3","pup_pointCounter.mp3","pup_stingerCatch.mp3","pup_stingerGold.mp3","pup_stingerMiss.mp3","pup_paw1.mp3","pup_paw2.mp3","pup_paw3.mp3","pup_paw4.mp3","popup_Go.mp3","popup_Ready.mp3"];
|
||||
|
||||
private var _soundNameFrisbee1:String = _audio[0];
|
||||
|
||||
private var _soundNameFrisbee2:String = _audio[1];
|
||||
|
||||
private var _soundNameFrisbee3:String = _audio[2];
|
||||
|
||||
private var _soundNameFrisbeeCollision1:String = _audio[3];
|
||||
|
||||
private var _soundNameFrisbeeCollision2:String = _audio[4];
|
||||
|
||||
private var _soundNameFrisbeeCollision3:String = _audio[5];
|
||||
|
||||
private var _soundNameGrowlJump:String = _audio[6];
|
||||
|
||||
private var _soundNameGrowlMiss:String = _audio[7];
|
||||
|
||||
private var _soundNamePointCounter:String = _audio[8];
|
||||
|
||||
private var _soundNameStingerCatch:String = _audio[9];
|
||||
|
||||
private var _soundNameStingerGold:String = _audio[10];
|
||||
|
||||
private var _soundNameStingerMiss:String = _audio[11];
|
||||
|
||||
private var _soundNamePaw1:String = _audio[12];
|
||||
|
||||
private var _soundNamePaw2:String = _audio[13];
|
||||
|
||||
private var _soundNamePaw3:String = _audio[14];
|
||||
|
||||
private var _soundNamePaw4:String = _audio[15];
|
||||
|
||||
private var _soundNamePopupGo:String = _audio[16];
|
||||
|
||||
private var _soundNamePopupReady:String = _audio[17];
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public function MicroPuppy()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbee1],_soundNameFrisbee1,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbee2],_soundNameFrisbee2,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbee3],_soundNameFrisbee3,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbeeCollision1],_soundNameFrisbeeCollision1,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbeeCollision2],_soundNameFrisbeeCollision2,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFrisbeeCollision3],_soundNameFrisbeeCollision3,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowlJump],_soundNameGrowlJump,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGrowlMiss],_soundNameGrowlMiss,0.38);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePointCounter],_soundNamePointCounter,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerCatch],_soundNameStingerCatch,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerGold],_soundNameStingerGold,0.72);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerMiss],_soundNameStingerMiss,0.72);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePaw1],_soundNamePaw1,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePaw2],_soundNamePaw2,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePaw3],_soundNamePaw3,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePaw4],_soundNamePaw4,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupGo],_soundNamePopupGo,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupReady],_soundNamePopupReady,0.2);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(313,_theGame.loader.content.catches);
|
||||
AchievementXtCommManager.requestSetUserVar(314,_theGame.loader.content.catches);
|
||||
var _loc2_:int = _pet.getUBits() >> 16 & 0x0F;
|
||||
if(_loc2_ == 2)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(315,1);
|
||||
}
|
||||
addGemsToBalance(_theGame.loader.content.gemsEarned - _gemsAwarded);
|
||||
stage.removeEventListener("keyDown",gameOverKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",_theGame.loader.content.fl_KeyboardDownHandler);
|
||||
stage.removeEventListener("keyUp",_theGame.loader.content.fl_KeyboardUpHandler);
|
||||
releaseBase();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroPuppy/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_closeBtn = addBtn("CloseButton",749,58,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_goldFrisbees = 0;
|
||||
_gemsAwarded = 0;
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("keyDown",_theGame.loader.content.fl_KeyboardDownHandler);
|
||||
stage.addEventListener("keyUp",_theGame.loader.content.fl_KeyboardUpHandler);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.frisbee1Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbee1Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbee1);
|
||||
}
|
||||
if(_theGame.loader.content.frisbee2Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbee2Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbee2);
|
||||
}
|
||||
if(_theGame.loader.content.frisbee3Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbee3Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbee3);
|
||||
}
|
||||
if(_theGame.loader.content.frisbeeCollision1Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbeeCollision1Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbeeCollision1);
|
||||
}
|
||||
if(_theGame.loader.content.frisbeeCollision2Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbeeCollision2Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbeeCollision2);
|
||||
}
|
||||
if(_theGame.loader.content.frisbeeCollision3Sound)
|
||||
{
|
||||
_theGame.loader.content.frisbeeCollision3Sound = false;
|
||||
_soundMan.playByName(_soundNameFrisbeeCollision3);
|
||||
}
|
||||
if(_theGame.loader.content.growlJumpSound)
|
||||
{
|
||||
_theGame.loader.content.growlJumpSound = false;
|
||||
_soundMan.playByName(_soundNameGrowlJump);
|
||||
}
|
||||
if(_theGame.loader.content.growlMissSound)
|
||||
{
|
||||
_theGame.loader.content.growlMissSound = false;
|
||||
_soundMan.playByName(_soundNameGrowlMiss);
|
||||
}
|
||||
if(_theGame.loader.content.pointCounterSound)
|
||||
{
|
||||
_theGame.loader.content.pointCounterSound = false;
|
||||
_soundMan.playByName(_soundNamePointCounter);
|
||||
}
|
||||
if(_theGame.loader.content.stingerCatchSound)
|
||||
{
|
||||
_theGame.loader.content.stingerCatchSound = false;
|
||||
_soundMan.playByName(_soundNameStingerCatch);
|
||||
if(_theGame.loader.content.gemsEarned - _gemsAwarded >= 300)
|
||||
{
|
||||
addGemsToBalance(300);
|
||||
_gemsAwarded += 300;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.stingerGoldSound)
|
||||
{
|
||||
_theGame.loader.content.stingerGoldSound = false;
|
||||
_soundMan.playByName(_soundNameStingerGold);
|
||||
_goldFrisbees = _goldFrisbees + 1;
|
||||
addToPetMastery(1);
|
||||
}
|
||||
if(_theGame.loader.content.stingerMissSound)
|
||||
{
|
||||
_theGame.loader.content.stingerMissSound = false;
|
||||
_soundMan.playByName(_soundNameStingerMiss);
|
||||
}
|
||||
if(_theGame.loader.content.paw1Sound)
|
||||
{
|
||||
_theGame.loader.content.paw1Sound = false;
|
||||
_soundMan.playByName(_soundNamePaw1);
|
||||
}
|
||||
if(_theGame.loader.content.paw2Sound)
|
||||
{
|
||||
_theGame.loader.content.paw2Sound = false;
|
||||
_soundMan.playByName(_soundNamePaw2);
|
||||
}
|
||||
if(_theGame.loader.content.paw3Sound)
|
||||
{
|
||||
_theGame.loader.content.paw3Sound = false;
|
||||
_soundMan.playByName(_soundNamePaw3);
|
||||
}
|
||||
if(_theGame.loader.content.paw4Sound)
|
||||
{
|
||||
_theGame.loader.content.paw4Sound = false;
|
||||
_soundMan.playByName(_soundNamePaw4);
|
||||
}
|
||||
if(_theGame.loader.content.goSound)
|
||||
{
|
||||
_theGame.loader.content.goSound = false;
|
||||
_soundMan.playByName(_soundNamePopupGo);
|
||||
}
|
||||
if(_theGame.loader.content.readySound)
|
||||
{
|
||||
_theGame.loader.content.readySound = false;
|
||||
_soundMan.playByName(_soundNamePopupReady);
|
||||
}
|
||||
if(_theGame.loader.content.endGame)
|
||||
{
|
||||
showGameOver();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function showExitConfirmationDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
_theGame.loader.content.gamePaused = true;
|
||||
}
|
||||
|
||||
private function gameOverKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onRetry();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
|
||||
public function showGameOver() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("puppyGame_gameOver",[{
|
||||
"name":"button_yes",
|
||||
"f":onRetry
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit
|
||||
}]);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Gems_Earned,_theGame.loader.content.gemsEarned == 1 ? 11619 : 11554,_theGame.loader.content.gemsEarned);
|
||||
if(_goldFrisbees > 0)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.goldenDiscs,_goldFrisbees == 1 ? 11623 : 11622,_goldFrisbees);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.goldenDiscs.text = "";
|
||||
}
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",gameOverKeyDown);
|
||||
}
|
||||
|
||||
private function onExit() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
_theGame.loader.content.gamePaused = false;
|
||||
}
|
||||
|
||||
private function onRetry() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",gameOverKeyDown);
|
||||
hideDlg();
|
||||
AchievementXtCommManager.requestSetUserVar(313,_theGame.loader.content.catches);
|
||||
AchievementXtCommManager.requestSetUserVar(314,_theGame.loader.content.catches);
|
||||
_goldFrisbees = 0;
|
||||
addGemsToBalance(_theGame.loader.content.gemsEarned - _gemsAwarded);
|
||||
_gemsAwarded = 0;
|
||||
_theGame.loader.content.newRound();
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_pet = MinigameManager.getActivePet(petLoaded);
|
||||
_theGame.loader.content.puppyName.text = MinigameManager.getActivePetName();
|
||||
}
|
||||
}
|
||||
|
||||
public function petLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_theGame.loader.content.setUpPet(_pet);
|
||||
_pet.getChildAt(0).pet.setAnim(0);
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
showExitConfirmationDlg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,562 @@
|
||||
package game.microSmoothie
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import gskinner.motion.GTween;
|
||||
|
||||
public class MicroSmoothie extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const MAX_VELOCITY_X:Number = 900;
|
||||
|
||||
private static const MAX_VELOCITY_Y:Number = 250;
|
||||
|
||||
private static const ACCELERATION_X:Number = 2500;
|
||||
|
||||
private static const ACCELERATION_Y:Number = 450;
|
||||
|
||||
private static const BRAKE_X:Number = 4000;
|
||||
|
||||
private static const BRAKE_Y:Number = 800;
|
||||
|
||||
private static const REQUIRED_FRUITS:int = 10;
|
||||
|
||||
public var _fruitTypesColor:Array;
|
||||
|
||||
public var _fruitTypes:Array;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerBack:Sprite;
|
||||
|
||||
public var _layerFront:Sprite;
|
||||
|
||||
public var _layerFruits:Sprite;
|
||||
|
||||
public var _layerCupFront:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _cupFront:Object;
|
||||
|
||||
private var _cupBack:Object;
|
||||
|
||||
private var _cupFrontMax:Object;
|
||||
|
||||
private var _cupBackMax:Object;
|
||||
|
||||
private var _fruitMachine:Object;
|
||||
|
||||
private var _ready:Object;
|
||||
|
||||
private var _congrats:Object;
|
||||
|
||||
private var _fruitStart:Object;
|
||||
|
||||
public var _leftArrowDown:Boolean;
|
||||
|
||||
public var _rightArrowDown:Boolean;
|
||||
|
||||
public var _downArrowDown:Boolean;
|
||||
|
||||
public var _upArrowDown:Boolean;
|
||||
|
||||
public var _nextFruitTimer:Number;
|
||||
|
||||
public var _congratsTimer:Number;
|
||||
|
||||
public var _velocityX:Number;
|
||||
|
||||
public var _fruitCaught:int;
|
||||
|
||||
public var _smoothieType:int;
|
||||
|
||||
private var _dismissDialogTimer:Number;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _fruitStartSounds:Array;
|
||||
|
||||
private var _audio:Array = ["slushy_fruit_passby.mp3","slushy_fruit_passby2.mp3","slushy_correct_fruit.mp3","slushy_wrong_fruit.mp3","MG_popup_youWon.mp3"];
|
||||
|
||||
private var _soundNameFruitStart1:String = _audio[0];
|
||||
|
||||
private var _soundNameFruitStart2:String = _audio[1];
|
||||
|
||||
private var _soundNameCorrect:String = _audio[2];
|
||||
|
||||
private var _soundNameWrong:String = _audio[3];
|
||||
|
||||
private var _soundNamePlayerWins:String = _audio[4];
|
||||
|
||||
public function MicroSmoothie()
|
||||
{
|
||||
super();
|
||||
_fruitTypesColor = new Array("purple","orange","red","yellow");
|
||||
_fruitTypes = new Array("grapes","orange","strawberry","banana");
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_fruitStartSounds = [];
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFruitStart1],_soundNameFruitStart1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFruitStart2],_soundNameFruitStart2,0.5);
|
||||
_fruitStartSounds = new Array(_soundNameFruitStart1,_soundNameFruitStart2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCorrect],_soundNameCorrect,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWrong],_soundNameWrong,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerWins],_soundNamePlayerWins,0.35);
|
||||
}
|
||||
|
||||
private function keyHandleUp(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = false;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = false;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = false;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function keyHandleDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = true;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = true;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = true;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyUp",keyHandleUp);
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("click",mouseClickHandler);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerBack);
|
||||
removeLayer(_layerFront);
|
||||
removeLayer(_layerFruits);
|
||||
removeLayer(_layerCupFront);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBack = null;
|
||||
_layerFront = null;
|
||||
_layerFruits = null;
|
||||
_layerCupFront = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBack = new Sprite();
|
||||
_layerFront = new Sprite();
|
||||
_layerFruits = new Sprite();
|
||||
_layerCupFront = new Sprite();
|
||||
_layerBack.mouseEnabled = false;
|
||||
_layerFront.mouseEnabled = false;
|
||||
_layerFruits.mouseEnabled = false;
|
||||
_layerCupFront.mouseEnabled = false;
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBack);
|
||||
addChild(_layerFruits);
|
||||
addChild(_layerFront);
|
||||
addChild(_layerCupFront);
|
||||
addChild(_guiLayer);
|
||||
loadScene("SmoothieAssets/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_cupFront = _scene.getLayer("cupFront");
|
||||
_cupBack = _scene.getLayer("cupBack");
|
||||
_cupFrontMax = _scene.getLayer("cupFrontMax");
|
||||
_cupBackMax = _scene.getLayer("cupBackMax");
|
||||
_fruitMachine = _scene.getLayer("smoothieGame");
|
||||
_layerBack.addChild(_scene.getLayer("smoothieBackground").loader);
|
||||
_layerBack.addChild(_cupBack.loader);
|
||||
_layerFruits.addChild(_fruitMachine.loader);
|
||||
_layerCupFront.addChild(_cupFront.loader);
|
||||
_congrats = _scene.getLayer("smoothieSuccess");
|
||||
_leftArrowDown = false;
|
||||
_rightArrowDown = false;
|
||||
_downArrowDown = false;
|
||||
_upArrowDown = false;
|
||||
stage.addEventListener("keyUp",keyHandleUp);
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("click",mouseClickHandler);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc7_:* = null;
|
||||
var _loc6_:Point = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
if(_fruitCaught < 10)
|
||||
{
|
||||
if(_dismissDialogTimer > 0)
|
||||
{
|
||||
_dismissDialogTimer -= _frameTime;
|
||||
if(_dismissDialogTimer <= 0)
|
||||
{
|
||||
hideDlg();
|
||||
_nextFruitTimer = 1.5;
|
||||
}
|
||||
}
|
||||
else if(_nextFruitTimer >= 0)
|
||||
{
|
||||
_loc6_ = localToGlobal(new Point(_cupBack.loader.x,_cupBack.loader.y));
|
||||
_loc5_ = int(_fruitMachine.loader.content.detectCollision(_loc6_.x,_loc6_.y,_cupBack.width,_cupBack.height + 75));
|
||||
if(_loc5_ >= 0)
|
||||
{
|
||||
if(_loc5_ == _smoothieType)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCorrect);
|
||||
_fruitCaught += 2;
|
||||
updateFruitMeter();
|
||||
if(_fruitCaught >= 10)
|
||||
{
|
||||
new GTween(_fruitMachine.loader,0.5,{"alpha":0});
|
||||
_guiLayer.addChild(_congrats.loader);
|
||||
_congrats.loader.content.Ready_Text.gotoAndPlay("on");
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
if(messageServer != null)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
switch(MinigameManager.minigameInfoCache.currMinigameId - 91)
|
||||
{
|
||||
case 0:
|
||||
MinigameManager.handleQuestMiniGameComplete(1);
|
||||
break;
|
||||
default:
|
||||
messageServer(["_a",2,_fruitTypesColor[_smoothieType]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
_congratsTimer = 3;
|
||||
_soundMan.playByName(_soundNamePlayerWins);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameWrong);
|
||||
_cupFront.loader.content.loseSlush();
|
||||
_fruitCaught -= 2;
|
||||
if(_fruitCaught < 0)
|
||||
{
|
||||
_fruitCaught = 0;
|
||||
}
|
||||
updateFruitMeter();
|
||||
}
|
||||
}
|
||||
_nextFruitTimer -= _frameTime;
|
||||
if(_nextFruitTimer <= 0)
|
||||
{
|
||||
_loc2_ = Math.random() * 6;
|
||||
if(_loc2_ >= 3)
|
||||
{
|
||||
_loc2_ = _smoothieType;
|
||||
}
|
||||
else if(_smoothieType == _loc2_)
|
||||
{
|
||||
_loc2_ = 3;
|
||||
}
|
||||
_nextFruitTimer = 0.5 + Math.random() * 0.5;
|
||||
_fruitMachine.loader.content.createFruit(_loc2_);
|
||||
_loc4_ = Math.random() * _fruitStartSounds.length;
|
||||
_soundMan.playByName(_fruitStartSounds[_loc4_]);
|
||||
}
|
||||
_cupBack.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
_cupFront.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
if(_cupFront.loader.x < _cupFront.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBack.x;
|
||||
_cupFront.loader.x = _cupFront.x;
|
||||
}
|
||||
else if(_cupFront.loader.x > _cupFrontMax.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBackMax.x;
|
||||
_cupFront.loader.x = _cupFrontMax.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_congratsTimer -= _frameTime;
|
||||
if(_congratsTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateFruitMeter() : void
|
||||
{
|
||||
var _loc1_:int = 2;
|
||||
if(_fruitCaught > 0)
|
||||
{
|
||||
_loc1_ = Math.max(3,_fruitCaught / 10 * 15 + 1);
|
||||
if(_loc1_ > 16)
|
||||
{
|
||||
_loc1_ = 16;
|
||||
}
|
||||
}
|
||||
_cupFront.loader.content.gotoAndStop(_loc1_);
|
||||
}
|
||||
|
||||
public function updateControls() : void
|
||||
{
|
||||
if(stage.mouseX < _cupFront.loader.x + _cupFront.width / 5)
|
||||
{
|
||||
_velocityX -= 2500 * _frameTime;
|
||||
if(_velocityX < -900)
|
||||
{
|
||||
_velocityX = -900;
|
||||
}
|
||||
}
|
||||
else if(stage.mouseX > _cupFront.loader.x + 4 * _cupFront.width / 5)
|
||||
{
|
||||
_velocityX += 2500 * _frameTime;
|
||||
if(_velocityX > 900)
|
||||
{
|
||||
_velocityX = 900;
|
||||
}
|
||||
}
|
||||
else if(_velocityX > 0)
|
||||
{
|
||||
_velocityX -= 4000 * _frameTime;
|
||||
if(_velocityX < 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
else if(_velocityX < 0)
|
||||
{
|
||||
_velocityX += 4000 * _frameTime;
|
||||
if(_velocityX > 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc1_:MovieClip = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_nextFruitTimer = -1;
|
||||
_dismissDialogTimer = 0;
|
||||
_fruitCaught = 0;
|
||||
_velocityX = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_loc3_ = (_cupFrontMax.x - _cupFront.x) / 2;
|
||||
_cupFront.loader.x = _cupFront.x + _loc3_;
|
||||
_cupBack.loader.x = _cupBack.x + _loc3_;
|
||||
_cupFront.loader.content.gotoAndStop(2);
|
||||
_loc1_ = showDlg("popup_flavor",[{
|
||||
"name":"button_strawberry",
|
||||
"f":onFlavorStrawberry
|
||||
},{
|
||||
"name":"button_orange",
|
||||
"f":onFlavorOrange
|
||||
},{
|
||||
"name":"button_banana",
|
||||
"f":onFlavorBanana
|
||||
},{
|
||||
"name":"button_grape",
|
||||
"f":onFlavorGrape
|
||||
}]);
|
||||
_loc1_.x = 455;
|
||||
_loc1_.y = 225;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
private function mouseClickHandler(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
|
||||
public function onStart() : void
|
||||
{
|
||||
hideDlg();
|
||||
if(_ready && _ready.loader.parent)
|
||||
{
|
||||
_ready.loader.parent.removeChild(_ready.loader);
|
||||
}
|
||||
_nextFruitTimer = 3;
|
||||
}
|
||||
|
||||
public function selectFlavor(param1:int) : void
|
||||
{
|
||||
_smoothieType = param1;
|
||||
_cupFront.loader.content.slush.gotoAndStop(_fruitTypesColor[_smoothieType]);
|
||||
hideDlg();
|
||||
var _loc2_:MovieClip = showDlg("popup_fillcup",[]);
|
||||
_loc2_.x = 455;
|
||||
_loc2_.y = 300;
|
||||
_loc2_.gotoAndStop(_fruitTypes[_smoothieType]);
|
||||
_dismissDialogTimer = 3;
|
||||
addChild(_scene.getLayer("pickedFruit").loader);
|
||||
}
|
||||
|
||||
public function onFlavorStrawberry() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_strawberry");
|
||||
selectFlavor(2);
|
||||
}
|
||||
|
||||
public function onFlavorBanana() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_banana");
|
||||
selectFlavor(3);
|
||||
}
|
||||
|
||||
public function onFlavorOrange() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_orange");
|
||||
selectFlavor(1);
|
||||
}
|
||||
|
||||
public function onFlavorGrape() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_grape");
|
||||
selectFlavor(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,790 @@
|
||||
package game.microSnake
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class MicroSnake extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _layerGame:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _pet:Object;
|
||||
|
||||
public var _petContainer:Object;
|
||||
|
||||
public var _gems:int;
|
||||
|
||||
public var _goldCollection:int;
|
||||
|
||||
public var _points:int;
|
||||
|
||||
public var _lives:int;
|
||||
|
||||
public var _difficultyRampFactor:Number = 150;
|
||||
|
||||
public var _readyGo:Boolean;
|
||||
|
||||
public var _snakeSpeed:int = 5;
|
||||
|
||||
public var _mice:Array;
|
||||
|
||||
public var _micePool:Array;
|
||||
|
||||
public var _useKeyboard:Boolean;
|
||||
|
||||
public var _rightArrow:Boolean;
|
||||
|
||||
public var _leftArrow:Boolean;
|
||||
|
||||
public var _upArrow:Boolean;
|
||||
|
||||
public var _downArrow:Boolean;
|
||||
|
||||
public var _currentVelX:Number;
|
||||
|
||||
public var _currentVelY:Number;
|
||||
|
||||
public var _constantMotion:Boolean;
|
||||
|
||||
public var _gameOverTimer:Number;
|
||||
|
||||
public var _snakeParts:Array;
|
||||
|
||||
public var _snakeBody:Sprite;
|
||||
|
||||
public var _numMiceCreated:int;
|
||||
|
||||
private var _audio:Array = ["popup_Go.mp3","popup_Ready.mp3","aj_snakeTel.mp3","aj_snakeTurn1.mp3","aj_snakeTurn2.mp3","aj_hamsterEat.mp3","aj_hamsterGoldEat.mp3","aj_snakeDeath.mp3"];
|
||||
|
||||
private var _soundNamePopupGo:String = _audio[0];
|
||||
|
||||
private var _soundNamePopupReady:String = _audio[1];
|
||||
|
||||
private var _soundNameSnakeTel:String = _audio[2];
|
||||
|
||||
private var _soundNameSnakeTurn1:String = _audio[3];
|
||||
|
||||
private var _soundNameSnakeTurn2:String = _audio[4];
|
||||
|
||||
private var _soundNameHamsterEat:String = _audio[5];
|
||||
|
||||
private var _soundNameHamsterGoldEat:String = _audio[6];
|
||||
|
||||
private var _soundNameSnakeDeath:String = _audio[7];
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public function MicroSnake()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupGo],_soundNamePopupGo,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupReady],_soundNamePopupReady,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSnakeTel],_soundNameSnakeTel,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSnakeTurn1],_soundNameSnakeTurn1,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSnakeTurn2],_soundNameSnakeTurn2,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameHamsterEat],_soundNameHamsterEat,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameHamsterGoldEat],_soundNameHamsterGoldEat,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSnakeDeath],_soundNameSnakeDeath,0.3);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function showExitConfirmationDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function gameOverKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
onRetry();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
|
||||
public function showGameOver() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("snakeGame_gameOver",[{
|
||||
"name":"button_yes",
|
||||
"f":onRetry
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit
|
||||
}]);
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.Gems_Earned,_gems == 1 ? 11619 : 11554,_gems);
|
||||
if(_goldCollection > 0)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.goldenDuckies,_goldCollection == 1 ? 11618 : 11617,_goldCollection);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.goldenDuckies.text = "";
|
||||
}
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
stage.addEventListener("keyDown",gameOverKeyDown);
|
||||
}
|
||||
|
||||
private function onExit() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onRetry() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",gameOverKeyDown);
|
||||
hideDlg();
|
||||
AchievementXtCommManager.requestSetUserVar(321,_points);
|
||||
AchievementXtCommManager.requestSetUserVar(322,_points);
|
||||
AchievementXtCommManager.requestSetUserVar(323,_goldCollection);
|
||||
_goldCollection = 0;
|
||||
addGemsToBalance(_gems);
|
||||
_gems = 0;
|
||||
_points = 0;
|
||||
_theGame.loader.content.gems.gemsText.text = "0";
|
||||
_theGame.loader.content.points.text = "0";
|
||||
_gameTime = 0;
|
||||
_readyGo = true;
|
||||
_theGame.loader.content.readyGo.gotoAndPlay("on");
|
||||
_theGame.loader.content.startMovement = false;
|
||||
_numMiceCreated = 0;
|
||||
_rightArrow = false;
|
||||
_leftArrow = false;
|
||||
_upArrow = false;
|
||||
_downArrow = false;
|
||||
_theGame.loader.content.controls.visible = true;
|
||||
_theGame.loader.content.readyGo.visible = true;
|
||||
while(_mice.length)
|
||||
{
|
||||
_mice[0].parent.removeChild(_mice[0]);
|
||||
_micePool.push(_mice[0]);
|
||||
_mice.splice(0,1);
|
||||
}
|
||||
addMouse();
|
||||
destroySnake();
|
||||
createSnake();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(321,_points);
|
||||
AchievementXtCommManager.requestSetUserVar(322,_points);
|
||||
AchievementXtCommManager.requestSetUserVar(323,_goldCollection);
|
||||
addGemsToBalance(_gems);
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyDown",gameOverKeyDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",keyboardHandler);
|
||||
stage.removeEventListener("keyUp",keyboardReleased);
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroSnake/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
private function addMouse() : void
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
if(_micePool.length > 1)
|
||||
{
|
||||
_loc1_ = _micePool[0];
|
||||
_micePool.splice(0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = GETDEFINITIONBYNAME("snakeGame_mouse");
|
||||
}
|
||||
_loc1_.scaleX = _loc1_.scaleY = 0.38;
|
||||
_layerGame.addChild(_loc1_ as DisplayObject);
|
||||
do
|
||||
{
|
||||
_loc1_.x = Math.random() * 640 + 30;
|
||||
_loc1_.y = Math.random() * 365 + 30;
|
||||
}
|
||||
while(_loc1_.hitTestObject(_layerGame["deadZone1"]) || _loc1_.hitTestObject(_layerGame["deadZone2"]) || _loc1_.hitTestObject(_layerGame["deadZone3"]) || _loc1_.hitTestObject(_layerGame["deadZone4"]));
|
||||
_mice.push(_loc1_);
|
||||
_numMiceCreated = _numMiceCreated + 1;
|
||||
_soundMan.playByName(_soundNameSnakeTel);
|
||||
if(_numMiceCreated % 20 == 1 && _numMiceCreated > 1)
|
||||
{
|
||||
_loc1_.gotoAndPlay("gold");
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.gotoAndPlay("white");
|
||||
}
|
||||
if(_numMiceCreated % 15 == 1 && _numMiceCreated / 15 < 5 && _numMiceCreated > 1)
|
||||
{
|
||||
addMouse();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_closeBtn = addBtn("CloseButton",749,58,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_layerGame = _theGame.loader.content.snakeGameAll;
|
||||
_theGame.loader.content.gems.gemsText.text = "0";
|
||||
_theGame.loader.content.points.text = "0";
|
||||
_lives = 3;
|
||||
_gameOverTimer = 0;
|
||||
_snakeParts = [];
|
||||
_snakeBody = new Sprite();
|
||||
_mice = [];
|
||||
_micePool = [];
|
||||
addMouse();
|
||||
_useKeyboard = true;
|
||||
_constantMotion = true;
|
||||
_layerGame.addChild(_snakeBody);
|
||||
_pet = MinigameManager.getActivePet(petLoaded);
|
||||
_theGame.loader.content.petName.text = MinigameManager.getActivePetName();
|
||||
createSnake();
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("keyDown",keyboardHandler);
|
||||
stage.addEventListener("keyUp",keyboardReleased);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
private function destroySnake() : void
|
||||
{
|
||||
while(_snakeParts.length)
|
||||
{
|
||||
_snakeParts[0].mc.parent.removeChild(_snakeParts[0].mc);
|
||||
_snakeParts.splice(0,1);
|
||||
}
|
||||
}
|
||||
|
||||
private function createSnake() : void
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
var _loc2_:int = 0;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 6)
|
||||
{
|
||||
if(_loc2_ == 0)
|
||||
{
|
||||
_loc1_ = GETDEFINITIONBYNAME("snake_head");
|
||||
_loc1_.init();
|
||||
_loc1_.setState(_pet.getLBits(),_pet.getUBits());
|
||||
_layerGame.addChild(_loc1_ as DisplayObject);
|
||||
}
|
||||
else if(_loc2_ < 5)
|
||||
{
|
||||
_loc1_ = GETDEFINITIONBYNAME("snake_part");
|
||||
_loc1_.init();
|
||||
_loc1_.setState(_pet.getLBits(),_pet.getUBits());
|
||||
_snakeBody.addChild(_loc1_ as DisplayObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = GETDEFINITIONBYNAME("snake_tail");
|
||||
_loc1_.init();
|
||||
_loc1_.setState(_pet.getLBits(),_pet.getUBits());
|
||||
_snakeBody.addChild(_loc1_ as DisplayObject);
|
||||
}
|
||||
_snakeParts.push({
|
||||
"x":-15 * _loc2_ + 250,
|
||||
"y":210,
|
||||
"mc":_loc1_
|
||||
});
|
||||
_loc2_++;
|
||||
}
|
||||
taperTail();
|
||||
updateSnakeBody(0);
|
||||
}
|
||||
|
||||
private function extend(param1:int) : void
|
||||
{
|
||||
var _loc2_:Object = _snakeParts[param1];
|
||||
var _loc4_:Object = _snakeParts[param1 + 1];
|
||||
var _loc7_:Object = GETDEFINITIONBYNAME("snake_part");
|
||||
_snakeBody.addChildAt(_loc7_ as DisplayObject,_snakeBody.getChildIndex(_loc4_.mc) + 1);
|
||||
_loc7_.init();
|
||||
_loc7_.setState(_pet.getLBits(),_pet.getUBits());
|
||||
var _loc6_:Object = {
|
||||
"x":_loc2_.x,
|
||||
"y":_loc2_.y,
|
||||
"mc":_loc7_
|
||||
};
|
||||
_snakeParts.splice(param1 + 1,0,_loc6_);
|
||||
var _loc3_:Number = (_loc2_.x - _loc4_.x) * 0.5;
|
||||
var _loc5_:Number = (_loc2_.y - _loc4_.y) * 0.5;
|
||||
_loc2_.x += _loc3_;
|
||||
_loc2_.y += _loc5_;
|
||||
updateSnakeBody(param1);
|
||||
_loc2_.x -= _loc3_;
|
||||
_loc2_.y -= _loc5_;
|
||||
updateSnakeBody(param1);
|
||||
}
|
||||
|
||||
private function taperTail() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _snakeParts.length - 4)
|
||||
{
|
||||
_snakeParts[_loc1_].mc.scaleY = 1;
|
||||
_loc1_++;
|
||||
}
|
||||
_snakeParts[_snakeParts.length - 4].mc.scaleY = 0.8;
|
||||
_snakeParts[_snakeParts.length - 3].mc.scaleY = 0.6;
|
||||
_snakeParts[_snakeParts.length - 2].mc.scaleY = 0.4;
|
||||
_snakeParts[_snakeParts.length - 1].mc.scaleY = 0.2;
|
||||
}
|
||||
|
||||
private function updateSnakeBody(param1:int) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
_loc8_ = param1;
|
||||
while(_loc8_ < _snakeParts.length - 1)
|
||||
{
|
||||
_loc2_ = _snakeParts[_loc8_];
|
||||
_loc3_ = _snakeParts[_loc8_ + 1];
|
||||
_loc5_ = _loc3_.x - _loc2_.x;
|
||||
_loc4_ = _loc3_.y - _loc2_.y;
|
||||
_loc7_ = Math.atan2(_loc4_,_loc5_) * 180 / 3.141592653589793;
|
||||
_loc6_ = Math.sqrt(_loc5_ * _loc5_ + _loc4_ * _loc4_);
|
||||
_loc3_.x += (15 - _loc6_) * _loc5_ / _loc6_;
|
||||
_loc3_.y += (15 - _loc6_) * _loc4_ / _loc6_;
|
||||
_loc2_.mc.x = _loc2_.x;
|
||||
_loc2_.mc.y = _loc2_.y;
|
||||
_loc2_.mc.rotation = _loc7_;
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseMove() : void
|
||||
{
|
||||
var _loc1_:Number = mouseX - 100 - _snakeParts[0].x;
|
||||
var _loc3_:Number = mouseY - 60 - _snakeParts[0].y;
|
||||
var _loc2_:Number = Math.sqrt(_loc1_ * _loc1_ + _loc3_ * _loc3_);
|
||||
if(_loc2_ > _snakeSpeed)
|
||||
{
|
||||
_loc2_ = _snakeSpeed / _loc2_;
|
||||
_snakeParts[0].x += (mouseX - 100 - _snakeParts[0].x) * _loc2_;
|
||||
_snakeParts[0].y += (mouseY - 60 - _snakeParts[0].y) * _loc2_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_snakeParts[0].x = mouseX - 100;
|
||||
_snakeParts[0].y = mouseY - 60;
|
||||
}
|
||||
updateSnakeBody(0);
|
||||
}
|
||||
|
||||
private function keyboardMove() : void
|
||||
{
|
||||
var _loc1_:Number = Math.min(_snakeSpeed + _gameTime / 36,20);
|
||||
var _loc2_:Number = _loc1_;
|
||||
if(_upArrow)
|
||||
{
|
||||
if(_leftArrow || _rightArrow)
|
||||
{
|
||||
_loc2_ = _snakeSpeed * 0.7071067811865476;
|
||||
}
|
||||
_snakeParts[0].y -= _loc2_;
|
||||
}
|
||||
else if(_downArrow)
|
||||
{
|
||||
if(_leftArrow || _rightArrow)
|
||||
{
|
||||
_loc2_ = _snakeSpeed * 0.7071067811865476;
|
||||
}
|
||||
_snakeParts[0].y += _loc2_;
|
||||
}
|
||||
_loc2_ = _loc1_;
|
||||
if(_leftArrow)
|
||||
{
|
||||
if(_upArrow || _downArrow)
|
||||
{
|
||||
_loc2_ = _snakeSpeed * 0.7071067811865476;
|
||||
}
|
||||
_snakeParts[0].x -= _loc2_;
|
||||
}
|
||||
else if(_rightArrow)
|
||||
{
|
||||
if(_upArrow || _downArrow)
|
||||
{
|
||||
_loc2_ = _snakeSpeed * 0.7071067811865476;
|
||||
}
|
||||
_snakeParts[0].x += _loc2_;
|
||||
}
|
||||
updateSnakeBody(0);
|
||||
}
|
||||
|
||||
private function keyboardHandler(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(_theGame.loader.content.startMovement)
|
||||
{
|
||||
if(_useKeyboard)
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
if(!_rightArrow && !_theGame.loader.content.controls.visible)
|
||||
{
|
||||
if(!_leftArrow)
|
||||
{
|
||||
_soundMan.playByName(Math.random() < 0.5 ? _soundNameSnakeTurn1 : _soundNameSnakeTurn2);
|
||||
}
|
||||
_leftArrow = true;
|
||||
if(_constantMotion)
|
||||
{
|
||||
_rightArrow = false;
|
||||
_upArrow = false;
|
||||
_downArrow = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(!_downArrow)
|
||||
{
|
||||
if(!_upArrow)
|
||||
{
|
||||
_soundMan.playByName(Math.random() < 0.5 ? _soundNameSnakeTurn1 : _soundNameSnakeTurn2);
|
||||
}
|
||||
_upArrow = true;
|
||||
if(_constantMotion)
|
||||
{
|
||||
_downArrow = false;
|
||||
_leftArrow = false;
|
||||
_rightArrow = false;
|
||||
}
|
||||
if(_theGame.loader.content.controls.visible)
|
||||
{
|
||||
_theGame.loader.content.controls.visible = false;
|
||||
_theGame.loader.content.readyGo.visible = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(!_leftArrow)
|
||||
{
|
||||
if(!_rightArrow)
|
||||
{
|
||||
_soundMan.playByName(Math.random() < 0.5 ? _soundNameSnakeTurn1 : _soundNameSnakeTurn2);
|
||||
}
|
||||
_rightArrow = true;
|
||||
if(_constantMotion)
|
||||
{
|
||||
_leftArrow = false;
|
||||
_upArrow = false;
|
||||
_downArrow = false;
|
||||
}
|
||||
if(_theGame.loader.content.controls.visible)
|
||||
{
|
||||
_theGame.loader.content.controls.visible = false;
|
||||
_theGame.loader.content.readyGo.visible = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(!_upArrow)
|
||||
{
|
||||
if(!_downArrow)
|
||||
{
|
||||
_soundMan.playByName(Math.random() < 0.5 ? _soundNameSnakeTurn1 : _soundNameSnakeTurn2);
|
||||
}
|
||||
_downArrow = true;
|
||||
if(_constantMotion)
|
||||
{
|
||||
_upArrow = false;
|
||||
_leftArrow = false;
|
||||
_rightArrow = false;
|
||||
}
|
||||
if(_theGame.loader.content.controls.visible)
|
||||
{
|
||||
_theGame.loader.content.controls.visible = false;
|
||||
_theGame.loader.content.readyGo.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function keyboardReleased(param1:KeyboardEvent) : void
|
||||
{
|
||||
var _loc2_:Array = [_rightArrow == true,_leftArrow == true,_upArrow == true,_downArrow == true];
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrow = false;
|
||||
break;
|
||||
case 1:
|
||||
_upArrow = false;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrow = false;
|
||||
break;
|
||||
case 3:
|
||||
_downArrow = false;
|
||||
}
|
||||
if(_constantMotion)
|
||||
{
|
||||
if(!_rightArrow && !_leftArrow && !_upArrow && !_downArrow)
|
||||
{
|
||||
_rightArrow = _loc2_[0];
|
||||
_leftArrow = _loc2_[1];
|
||||
_upArrow = _loc2_[2];
|
||||
_downArrow = _loc2_[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_theGame.loader.content.goSound)
|
||||
{
|
||||
_theGame.loader.content.goSound = false;
|
||||
_soundMan.playByName(_soundNamePopupGo);
|
||||
}
|
||||
if(_theGame.loader.content.readySound)
|
||||
{
|
||||
_theGame.loader.content.readySound = false;
|
||||
_soundMan.playByName(_soundNamePopupReady);
|
||||
}
|
||||
if(!(_readyGo && !_theGame.loader.content.startMovement))
|
||||
{
|
||||
if(_pauseGame == false && _gameOverTimer <= 0)
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
_readyGo = false;
|
||||
if(_useKeyboard == 0)
|
||||
{
|
||||
mouseMove();
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardMove();
|
||||
}
|
||||
if(_snakeParts[0].x < 0 || _snakeParts[0].x > 700 || _snakeParts[0].y < 0 || _snakeParts[0].y > 425)
|
||||
{
|
||||
_snakeParts[0].mc.top.miss.gotoAndPlay("onWall");
|
||||
_gameOverTimer = 1;
|
||||
_soundMan.playByName(_soundNameSnakeDeath);
|
||||
}
|
||||
else if(_snakeBody.hitTestPoint(_snakeParts[0].x + 100,_snakeParts[0].y + 60,true))
|
||||
{
|
||||
_snakeParts[0].mc.top.miss.gotoAndPlay("on");
|
||||
_gameOverTimer = 1;
|
||||
_soundMan.playByName(_soundNameSnakeDeath);
|
||||
}
|
||||
_loc2_ = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _mice.length)
|
||||
{
|
||||
if(_snakeParts[0].mc.hitTestObject(_mice[_loc3_]))
|
||||
{
|
||||
extend(_snakeParts.length - 2);
|
||||
taperTail();
|
||||
_mice[_loc3_].gotoAndPlay("off");
|
||||
if(_mice[_loc3_].golden)
|
||||
{
|
||||
_gems += 15;
|
||||
_goldCollection = _goldCollection + 1;
|
||||
addToPetMastery(1);
|
||||
_soundMan.playByName(_soundNameHamsterGoldEat);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gems = _gems + 1;
|
||||
_soundMan.playByName(_soundNameHamsterEat);
|
||||
}
|
||||
_micePool.push(_mice[_loc3_]);
|
||||
_mice.splice(_loc3_,1);
|
||||
_loc3_--;
|
||||
_loc2_++;
|
||||
_points = _points + 1;
|
||||
_theGame.loader.content.gems.gemsText.text = _gems.toString();
|
||||
_theGame.loader.content.points.text = _points.toString();
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
addMouse();
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_gameOverTimer > 0)
|
||||
{
|
||||
_gameOverTimer -= _frameTime;
|
||||
if(_gameOverTimer <= 0)
|
||||
{
|
||||
showGameOver();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(_theGame)
|
||||
{
|
||||
_readyGo = true;
|
||||
_theGame.loader.content.readyGo.gotoAndPlay("on");
|
||||
}
|
||||
}
|
||||
|
||||
public function petLoaded(param1:MovieClip) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
showExitConfirmationDlg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
package game.microStoneMining
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroStoneMining extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["ajq_miningStinger.mp3","ajq_rockImp1.mp3","ajq_rockImp2.mp3","ajq_rockImp3.mp3","ajq_rockImp4.mp3","ajq_rockImp5.mp3","ajq_rockImp6.mp3","ajq_rockImp7.mp3","ajq_textEnter.mp3","ajq_textExit.mp3","ajq_resourceMoving2Bag.mp3","ajq_resourceDrop.mp3","ajq_resourcePopupEnter.mp3","ajq_resourcePopUpExit.mp3","ajq_satchelClose.mp3","ajq_satchelOpen.mp3"];
|
||||
|
||||
private var _soundNameStinger:String = _audio[0];
|
||||
|
||||
private var _soundNameImp1:String = _audio[1];
|
||||
|
||||
private var _soundNameImp2:String = _audio[2];
|
||||
|
||||
private var _soundNameImp3:String = _audio[3];
|
||||
|
||||
private var _soundNameImp4:String = _audio[4];
|
||||
|
||||
private var _soundNameImp5:String = _audio[5];
|
||||
|
||||
private var _soundNameImp6:String = _audio[6];
|
||||
|
||||
private var _soundNameImp7:String = _audio[7];
|
||||
|
||||
private var _soundNameTextEnter:String = _audio[8];
|
||||
|
||||
private var _soundNameTextExit:String = _audio[9];
|
||||
|
||||
private var _soundNameResourceMove:String = _audio[10];
|
||||
|
||||
private var _soundNameResourceDrop:String = _audio[11];
|
||||
|
||||
private var _soundNamePopupEnter:String = _audio[12];
|
||||
|
||||
private var _soundNamePopupExit:String = _audio[13];
|
||||
|
||||
private var _soundNameSatchelClose:String = _audio[14];
|
||||
|
||||
private var _soundNameSatchelOpen:String = _audio[15];
|
||||
|
||||
public function MicroStoneMining()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStinger],_soundNameStinger,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp1],_soundNameImp1,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp2],_soundNameImp2,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp3],_soundNameImp3,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp4],_soundNameImp4,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp5],_soundNameImp5,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp6],_soundNameImp6,0.85);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameImp7],_soundNameImp7,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextEnter],_soundNameTextEnter,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextExit],_soundNameTextExit,1.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceMove],_soundNameResourceMove,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceDrop],_soundNameResourceDrop,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupEnter],_soundNamePopupEnter,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupExit],_soundNamePopupExit,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelClose],_soundNameSatchelClose,0.73);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelOpen],_soundNameSatchelOpen,0.82);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroStoneMining/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.gameFinished)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_textEnter = false;
|
||||
_soundMan.playByName(_soundNameTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_textExit = false;
|
||||
_soundMan.playByName(_soundNameTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_miningStinger)
|
||||
{
|
||||
_theGame.loader.content.ajq_miningStinger = false;
|
||||
_soundMan.playByName(_soundNameStinger);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp1)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp1 = false;
|
||||
_soundMan.playByName(_soundNameImp1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp2)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp2 = false;
|
||||
_soundMan.playByName(_soundNameImp2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp3)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp3 = false;
|
||||
_soundMan.playByName(_soundNameImp3);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp4)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp4 = false;
|
||||
_soundMan.playByName(_soundNameImp4);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp5)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp5 = false;
|
||||
_soundMan.playByName(_soundNameImp5);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp6)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp6 = false;
|
||||
_soundMan.playByName(_soundNameImp6);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_rockImp7)
|
||||
{
|
||||
_theGame.loader.content.ajq_rockImp7 = false;
|
||||
_soundMan.playByName(_soundNameImp7);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopupEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopupEnter = false;
|
||||
_soundMan.playByName(_soundNamePopupEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopUpExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopUpExit = false;
|
||||
_soundMan.playByName(_soundNamePopupExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceMoveToBag)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceMoveToBag = false;
|
||||
_soundMan.playByName(_soundNameResourceMove);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceDrop)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceDrop = false;
|
||||
_soundMan.playByName(_soundNameResourceDrop);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelClose)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelClose = false;
|
||||
_soundMan.playByName(_soundNameSatchelClose);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelOpen)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelOpen = false;
|
||||
_soundMan.playByName(_soundNameSatchelOpen);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
MinigameManager.handleQuestMiniGameComplete(_theGame.loader.content.reward);
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
package game.microWoodGather
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
|
||||
public class MicroWoodGather extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["ajq_miningStinger.mp3","ajq_textEnter.mp3","ajq_textExit.mp3","ajq_woodDrop1.mp3","ajq_woodDrop2.mp3","ajq_woodDrop3.mp3","ajq_woodDrop4.mp3","ajq_woodDrop5.mp3","ajq_woodGroundImp.mp3","ajq_woodReleased.mp3","ajq_resourceMoving2Bag.mp3","ajq_resourceDrop.mp3","ajq_resourcePopupEnter.mp3","ajq_resourcePopUpExit.mp3","ajq_satchelClose.mp3","ajq_satchelOpen.mp3"];
|
||||
|
||||
private var _soundNameStinger:String = _audio[0];
|
||||
|
||||
private var _soundNameTextEnter:String = _audio[1];
|
||||
|
||||
private var _soundNameTextExit:String = _audio[2];
|
||||
|
||||
private var _soundNameDrop1:String = _audio[3];
|
||||
|
||||
private var _soundNameDrop2:String = _audio[4];
|
||||
|
||||
private var _soundNameDrop3:String = _audio[5];
|
||||
|
||||
private var _soundNameDrop4:String = _audio[6];
|
||||
|
||||
private var _soundNameDrop5:String = _audio[7];
|
||||
|
||||
private var _soundNameWoodImp:String = _audio[8];
|
||||
|
||||
private var _soundNameWoodReleased:String = _audio[9];
|
||||
|
||||
private var _soundNameResourceMove:String = _audio[10];
|
||||
|
||||
private var _soundNameResourceDrop:String = _audio[11];
|
||||
|
||||
private var _soundNamePopupEnter:String = _audio[12];
|
||||
|
||||
private var _soundNamePopupExit:String = _audio[13];
|
||||
|
||||
private var _soundNameSatchelClose:String = _audio[14];
|
||||
|
||||
private var _soundNameSatchelOpen:String = _audio[15];
|
||||
|
||||
public function MicroWoodGather()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStinger],_soundNameStinger,0.55);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextEnter],_soundNameTextEnter,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextExit],_soundNameTextExit,1.42);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrop1],_soundNameDrop1,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrop2],_soundNameDrop2,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrop3],_soundNameDrop3,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrop4],_soundNameDrop4,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrop5],_soundNameDrop5,0.95);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWoodImp],_soundNameWoodImp,1.1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWoodReleased],_soundNameWoodReleased,2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceMove],_soundNameResourceMove,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameResourceDrop],_soundNameResourceDrop,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupEnter],_soundNamePopupEnter,0.78);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopupExit],_soundNamePopupExit,0.75);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelClose],_soundNameSatchelClose,0.73);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSatchelOpen],_soundNameSatchelOpen,0.82);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("MicroWoodGather/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",847,1,onCloseButton);
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_pauseGame == false)
|
||||
{
|
||||
if(_theGame && _theGame.loader && _theGame.loader.content)
|
||||
{
|
||||
if(_theGame.loader.content.gameFinished)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_textEnter = false;
|
||||
_soundMan.playByName(_soundNameTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_textExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_textExit = false;
|
||||
_soundMan.playByName(_soundNameTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_miningStinger)
|
||||
{
|
||||
_theGame.loader.content.ajq_miningStinger = false;
|
||||
_soundMan.playByName(_soundNameStinger);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodDrop1)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodDrop1 = false;
|
||||
_soundMan.playByName(_soundNameDrop1);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodDrop2)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodDrop2 = false;
|
||||
_soundMan.playByName(_soundNameDrop2);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodDrop3)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodDrop3 = false;
|
||||
_soundMan.playByName(_soundNameDrop3);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodDrop4)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodDrop4 = false;
|
||||
_soundMan.playByName(_soundNameDrop4);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodDrop5)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodDrop5 = false;
|
||||
_soundMan.playByName(_soundNameDrop5);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodGroundImp)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodGroundImp = false;
|
||||
_soundMan.playByName(_soundNameWoodImp);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_woodReleased)
|
||||
{
|
||||
_theGame.loader.content.ajq_woodReleased = false;
|
||||
_soundMan.playByName(_soundNameWoodReleased);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopupEnter)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopupEnter = false;
|
||||
_soundMan.playByName(_soundNamePopupEnter);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourcePopUpExit)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourcePopUpExit = false;
|
||||
_soundMan.playByName(_soundNamePopupExit);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceMoveToBag)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceMoveToBag = false;
|
||||
_soundMan.playByName(_soundNameResourceMove);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_resourceDrop)
|
||||
{
|
||||
_theGame.loader.content.ajq_resourceDrop = false;
|
||||
_soundMan.playByName(_soundNameResourceDrop);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelClose)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelClose = false;
|
||||
_soundMan.playByName(_soundNameSatchelClose);
|
||||
}
|
||||
if(_theGame.loader.content.ajq_satchelOpen)
|
||||
{
|
||||
_theGame.loader.content.ajq_satchelOpen = false;
|
||||
_soundMan.playByName(_soundNameSatchelOpen);
|
||||
}
|
||||
if(_theGame.loader.content.finished)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
MinigameManager.handleQuestMiniGameComplete(_theGame.loader.content.reward);
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = true;
|
||||
}
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
package game.miniGame_Memory
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import gskinner.motion.GTween;
|
||||
|
||||
public class MemoryCard
|
||||
{
|
||||
|
||||
public var _cardType:int;
|
||||
|
||||
public var _slot:int;
|
||||
|
||||
private var _theGame:MiniGame_Memory;
|
||||
|
||||
private var _selected:Boolean;
|
||||
|
||||
private var _card:Object;
|
||||
|
||||
private var _disabledImage:Sprite;
|
||||
|
||||
private var _imageMask:Sprite;
|
||||
|
||||
private var _matched:Boolean;
|
||||
|
||||
private var _state:int;
|
||||
|
||||
private var _cardPath:MovieClip;
|
||||
|
||||
public const STATE_IDLE:int = 1;
|
||||
|
||||
public const STATE_SELECTING:int = 2;
|
||||
|
||||
public const STATE_DISABLED:int = 3;
|
||||
|
||||
public function MemoryCard()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function getCardType() : int
|
||||
{
|
||||
return _cardType;
|
||||
}
|
||||
|
||||
public function initCard(param1:MiniGame_Memory, param2:Object, param3:int, param4:int) : void
|
||||
{
|
||||
_card = param2;
|
||||
_cardType = param4;
|
||||
_slot = param3;
|
||||
_theGame = param1;
|
||||
_matched = false;
|
||||
_selected = false;
|
||||
_state = 1;
|
||||
_cardPath = _theGame.getScene().getLayer("animalPaths").loader.content.createPath();
|
||||
_cardPath.addEventListener("MemoryPathInComplete",memoryPathInComplete);
|
||||
_cardPath.addEventListener("MemoryPathOutComplete",memoryPathOutComplete);
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
_cardPath.removeEventListener("MemoryPathInComplete",memoryPathInComplete);
|
||||
_cardPath.removeEventListener("MemoryPathOutComplete",memoryPathOutComplete);
|
||||
_card.loader.mask = null;
|
||||
if(_disabledImage && _disabledImage.parent)
|
||||
{
|
||||
_disabledImage.parent.removeChild(_disabledImage);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
if(!_imageMask)
|
||||
{
|
||||
_imageMask = new Sprite();
|
||||
_imageMask.mouseEnabled = false;
|
||||
_imageMask.graphics.beginFill(16711680);
|
||||
_imageMask.graphics.drawRect(0,0,125,125);
|
||||
_imageMask.x = _theGame._cardSelect.x + 125 * (_slot % 4);
|
||||
_imageMask.y = _theGame._cardSelect.y + 125 * Math.floor(_slot / 4);
|
||||
_card.loader.mask = _imageMask;
|
||||
_card.loader.alpha = 1;
|
||||
_cardPath.x = _imageMask.x;
|
||||
_cardPath.y = _imageMask.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
_card.loader.x = _cardPath.x + _cardPath.animal_null1.x;
|
||||
_card.loader.y = _cardPath.y + _cardPath.animal_null1.y;
|
||||
}
|
||||
}
|
||||
|
||||
public function isMouseOverHighlightable() : Boolean
|
||||
{
|
||||
return _state == 1 && !isMatched() && !isSelected();
|
||||
}
|
||||
|
||||
public function isSelected() : Boolean
|
||||
{
|
||||
return _state != 3 && !_matched && _selected;
|
||||
}
|
||||
|
||||
public function isSelectable() : Boolean
|
||||
{
|
||||
return _state != 3 && !_matched;
|
||||
}
|
||||
|
||||
public function getState() : int
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public function select(param1:Boolean = false) : void
|
||||
{
|
||||
if(_imageMask && _state != 3)
|
||||
{
|
||||
if(!_matched && !_selected)
|
||||
{
|
||||
_selected = true;
|
||||
_state = 2;
|
||||
if(!param1)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameEnter);
|
||||
}
|
||||
switch(_theGame.getSlotDirection(_cardType) - 1)
|
||||
{
|
||||
case 0:
|
||||
_cardPath.gotoAndPlay("top_in");
|
||||
break;
|
||||
case 1:
|
||||
_cardPath.gotoAndPlay("bottom_in");
|
||||
break;
|
||||
case 2:
|
||||
_cardPath.gotoAndPlay("left_in");
|
||||
break;
|
||||
case 3:
|
||||
_cardPath.gotoAndPlay("right_in");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function memoryPathInComplete(param1:MemoryEvent) : void
|
||||
{
|
||||
_state = 1;
|
||||
}
|
||||
|
||||
private function memoryPathOutComplete(param1:MemoryEvent) : void
|
||||
{
|
||||
_state = 1;
|
||||
}
|
||||
|
||||
public function unselect(param1:Boolean = false) : void
|
||||
{
|
||||
if(_state != 3)
|
||||
{
|
||||
if(!_matched && _selected)
|
||||
{
|
||||
_state = 1;
|
||||
_selected = false;
|
||||
switch(_theGame.getSlotDirection(_cardType) - 1)
|
||||
{
|
||||
case 0:
|
||||
_cardPath.gotoAndPlay("top_out");
|
||||
break;
|
||||
case 1:
|
||||
_cardPath.gotoAndPlay("bottom_out");
|
||||
break;
|
||||
case 2:
|
||||
_cardPath.gotoAndPlay("left_out");
|
||||
break;
|
||||
case 3:
|
||||
_cardPath.gotoAndPlay("right_out");
|
||||
}
|
||||
if(param1 == false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function matched() : void
|
||||
{
|
||||
if(_state != 3)
|
||||
{
|
||||
_matched = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function isMatched() : Boolean
|
||||
{
|
||||
return _matched;
|
||||
}
|
||||
|
||||
public function disable() : void
|
||||
{
|
||||
if(_state != 3)
|
||||
{
|
||||
_state = 3;
|
||||
_disabledImage = new Sprite();
|
||||
_disabledImage.graphics.beginFill(0);
|
||||
_disabledImage.graphics.drawRect(0,0,125,125);
|
||||
_disabledImage.x = _theGame._cardSelect.x + 125 * (_slot % 4);
|
||||
_disabledImage.y = _theGame._cardSelect.y + 125 * Math.floor(_slot / 4);
|
||||
_theGame._layerBackground.addChild(_disabledImage);
|
||||
_disabledImage.alpha = 0;
|
||||
new GTween(_disabledImage,1,{"alpha":0.35});
|
||||
}
|
||||
}
|
||||
|
||||
public function mouseOver(param1:Object) : void
|
||||
{
|
||||
if(_imageMask)
|
||||
{
|
||||
if(param1.layer.loader.x != _imageMask.x || param1.layer.loader.y != _imageMask.y || param1.layer.loader.alpha == 0)
|
||||
{
|
||||
param1.layer.loader.x = _imageMask.x;
|
||||
param1.layer.loader.y = _imageMask.y;
|
||||
param1.tween = new GTween(param1.layer.loader,0.5,{"alpha":0.6});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package game.miniGame_Memory
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MemoryEvent extends Event
|
||||
{
|
||||
|
||||
public static const MEMORY_PATH_IN_COMPLETE:String = "MemoryPathInComplete";
|
||||
|
||||
public static const MEMORY_PATH_OUT_COMPLETE:String = "MemoryPathOutComplete";
|
||||
|
||||
public function MemoryEvent(param1:String)
|
||||
{
|
||||
super(param1,true,false);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MemoryEvent(type);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("MemoryEvent",type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,119 @@
|
||||
package game.moatMadness
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.Sprite;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
public class FrameAnimation
|
||||
{
|
||||
|
||||
public var _container:Sprite;
|
||||
|
||||
private var _activeImage:Bitmap;
|
||||
|
||||
private var _totalFrames:int;
|
||||
|
||||
private var _frameWidth:int;
|
||||
|
||||
private var _frameHeight:int;
|
||||
|
||||
private var _frame:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _frameTimer:Number;
|
||||
|
||||
private var _imageFrames:Bitmap;
|
||||
|
||||
private var _loopFrame:int;
|
||||
|
||||
public function FrameAnimation(param1:Bitmap, param2:int, param3:int, param4:int, param5:int, param6:Number, param7:int = -1, param8:int = -1)
|
||||
{
|
||||
super();
|
||||
_container = new Sprite();
|
||||
_frameWidth = param4;
|
||||
_frameHeight = param5;
|
||||
_container.x = param2;
|
||||
_container.y = param3;
|
||||
_loopFrame = param8 - 1;
|
||||
_imageFrames = param1;
|
||||
var _loc9_:int = _imageFrames.width;
|
||||
var _loc10_:int = _imageFrames.height;
|
||||
_totalFrames = _loc9_ / _frameWidth * (_loc10_ / _frameHeight);
|
||||
if(param7 != -1 && param7 < _totalFrames)
|
||||
{
|
||||
_totalFrames = param7;
|
||||
}
|
||||
_frameTime = param6 / _totalFrames;
|
||||
_activeImage = new Bitmap();
|
||||
_activeImage.x = -_frameWidth / 2;
|
||||
_activeImage.y = -_frameHeight / 2;
|
||||
_container.addChild(_activeImage);
|
||||
setActiveFrame(0);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
if(!atFrameEnd())
|
||||
{
|
||||
_frameTimer -= param1;
|
||||
if(_frameTimer <= 0)
|
||||
{
|
||||
setActiveFrame(_frame + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function atFrameEnd() : Boolean
|
||||
{
|
||||
return _frame >= _totalFrames;
|
||||
}
|
||||
|
||||
public function atNextToLastFrame(param1:int) : Boolean
|
||||
{
|
||||
return _frame >= _totalFrames - param1;
|
||||
}
|
||||
|
||||
private function setActiveFrame(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:Rectangle = null;
|
||||
var _loc6_:Point = null;
|
||||
var _loc4_:BitmapData = null;
|
||||
if(param1 >= _totalFrames)
|
||||
{
|
||||
if(_loopFrame >= 0)
|
||||
{
|
||||
param1 = _loopFrame;
|
||||
}
|
||||
}
|
||||
if(param1 < _totalFrames)
|
||||
{
|
||||
_loc2_ = _imageFrames.width;
|
||||
_loc9_ = _imageFrames.height;
|
||||
_loc5_ = _loc2_ / _frameWidth;
|
||||
_loc8_ = param1 % _loc5_;
|
||||
_loc7_ = param1 / _loc5_;
|
||||
_loc3_ = new Rectangle(_loc8_ * _frameWidth,_loc7_ * _frameHeight,_frameWidth,_frameHeight);
|
||||
_loc6_ = new Point(0,0);
|
||||
_loc4_ = new BitmapData(_frameWidth,_frameHeight);
|
||||
_loc4_.copyPixels(_imageFrames.bitmapData,_loc3_,_loc6_);
|
||||
_activeImage.bitmapData = _loc4_;
|
||||
_frame = param1;
|
||||
_frameTimer = _frameTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
_frame = _totalFrames;
|
||||
_frameTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,107 @@
|
||||
package game.moatMadness
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class MoatPath
|
||||
{
|
||||
|
||||
public var _theGame:MoatMadness;
|
||||
|
||||
public var _container:Sprite;
|
||||
|
||||
public var _width:int;
|
||||
|
||||
public var _height:int;
|
||||
|
||||
public var _targetRotation:Number;
|
||||
|
||||
public var _currentRotation:Number;
|
||||
|
||||
public var _nextFillDirection:int;
|
||||
|
||||
protected var _filling:Boolean;
|
||||
|
||||
public function MoatPath()
|
||||
{
|
||||
super();
|
||||
_container = new Sprite();
|
||||
_targetRotation = 0;
|
||||
_currentRotation = 0;
|
||||
_filling = false;
|
||||
}
|
||||
|
||||
public function init(param1:MoatMadness, param2:int, param3:int, param4:int) : void
|
||||
{
|
||||
_theGame = param1;
|
||||
_container.x = param2 + _width / 2;
|
||||
_container.y = param3 + _height / 2;
|
||||
_theGame._layerBackground.addChild(_container);
|
||||
_container.addEventListener("click",handleClick,false,0,true);
|
||||
_targetRotation = param4;
|
||||
_currentRotation = _targetRotation;
|
||||
_container.rotation = _targetRotation;
|
||||
}
|
||||
|
||||
public function Remove() : void
|
||||
{
|
||||
_container.removeEventListener("click",handleClick);
|
||||
_container.parent.removeChild(_container);
|
||||
_container = null;
|
||||
}
|
||||
|
||||
public function handleClick(param1:MouseEvent) : void
|
||||
{
|
||||
if(!_theGame._waterFilling && !_theGame._gameOver && !_theGame.getPaused())
|
||||
{
|
||||
if(_currentRotation == _targetRotation)
|
||||
{
|
||||
_targetRotation += 90;
|
||||
_theGame._soundMan.playByName(_theGame._soundNameRotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(_currentRotation != _targetRotation)
|
||||
{
|
||||
_loc2_ = 360 * param1;
|
||||
_currentRotation += _loc2_;
|
||||
if(_currentRotation >= _targetRotation)
|
||||
{
|
||||
_loc2_ -= _currentRotation - _targetRotation;
|
||||
if(_targetRotation >= 360)
|
||||
{
|
||||
_targetRotation -= 360;
|
||||
}
|
||||
_currentRotation = _targetRotation;
|
||||
}
|
||||
_container.rotation += _loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
public function testForValidFill(param1:int, param2:int, param3:int) : Boolean
|
||||
{
|
||||
return param1 >= _container.x - _width / 2 && param1 <= _container.x + _width / 2 && param2 >= _container.y - _height / 2 && param2 <= _container.y + _height / 2;
|
||||
}
|
||||
|
||||
public function startFill(param1:int) : void
|
||||
{
|
||||
_filling = true;
|
||||
}
|
||||
|
||||
protected function setFull() : void
|
||||
{
|
||||
_filling = false;
|
||||
_theGame.pathFill(this,_nextFillDirection);
|
||||
}
|
||||
|
||||
public function getFillDirection(param1:int) : int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package game.moatMadness
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class MoatPathCross extends MoatPath
|
||||
{
|
||||
|
||||
private var _activeImage:Object;
|
||||
|
||||
private var _fillAnimationTop:FrameAnimation;
|
||||
|
||||
private var _fillAnimationBottom:FrameAnimation;
|
||||
|
||||
public function MoatPathCross(param1:MoatMadness)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
var _loc2_:Object = _theGame.getScene().getLayer("piece_cross");
|
||||
_activeImage = _theGame.getScene().cloneAsset("piece_cross");
|
||||
_width = _loc2_.loader.width;
|
||||
_height = _loc2_.loader.height;
|
||||
_activeImage.loader.x = -_width / 2;
|
||||
_activeImage.loader.y = -_height / 2;
|
||||
}
|
||||
|
||||
override public function init(param1:MoatMadness, param2:int, param3:int, param4:int) : void
|
||||
{
|
||||
_container.addChild(_activeImage.loader);
|
||||
super.init(param1,param2,param3,param4);
|
||||
}
|
||||
|
||||
override public function Remove() : void
|
||||
{
|
||||
_container.removeChild(_activeImage.loader);
|
||||
if(_fillAnimationTop)
|
||||
{
|
||||
_fillAnimationTop._container.parent.removeChild(_fillAnimationTop._container);
|
||||
_fillAnimationTop = null;
|
||||
}
|
||||
if(_fillAnimationBottom)
|
||||
{
|
||||
_fillAnimationBottom._container.parent.removeChild(_fillAnimationBottom._container);
|
||||
_fillAnimationBottom = null;
|
||||
}
|
||||
super.Remove();
|
||||
}
|
||||
|
||||
override public function handleClick(param1:MouseEvent) : void
|
||||
{
|
||||
super.handleClick(param1);
|
||||
}
|
||||
|
||||
override public function heartbeat(param1:Number) : void
|
||||
{
|
||||
if(_fillAnimationTop && !_fillAnimationTop.atFrameEnd())
|
||||
{
|
||||
_fillAnimationTop.heartbeat(param1);
|
||||
if(_filling && _fillAnimationTop.atNextToLastFrame(5))
|
||||
{
|
||||
setFull();
|
||||
}
|
||||
}
|
||||
if(_fillAnimationBottom && !_fillAnimationBottom.atFrameEnd())
|
||||
{
|
||||
_fillAnimationBottom.heartbeat(param1);
|
||||
if(_filling && _fillAnimationBottom.atNextToLastFrame(5))
|
||||
{
|
||||
setFull();
|
||||
}
|
||||
}
|
||||
super.heartbeat(param1);
|
||||
}
|
||||
|
||||
override public function testForValidFill(param1:int, param2:int, param3:int) : Boolean
|
||||
{
|
||||
return super.testForValidFill(param1,param2,param3);
|
||||
}
|
||||
|
||||
override public function getFillDirection(param1:int) : int
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
override public function startFill(param1:int) : void
|
||||
{
|
||||
super.startFill(param1);
|
||||
_nextFillDirection = getFillDirection(param1);
|
||||
var _loc3_:Bitmap = _theGame.getScene().getLayer("fill_cross_top").loader.content as Bitmap;
|
||||
var _loc2_:Bitmap = _theGame.getScene().getLayer("fill_cross_bottom").loader.content as Bitmap;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
if(_targetRotation == 0 || _targetRotation == 180)
|
||||
{
|
||||
_fillAnimationBottom = new FrameAnimation(_loc2_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationBottom._container.rotation = 180;
|
||||
_theGame._layerBackground.addChild(_fillAnimationBottom._container);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimationTop = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationTop._container.rotation = 90;
|
||||
_theGame._layerBackground.addChild(_fillAnimationTop._container);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_targetRotation == 90 || _targetRotation == 270)
|
||||
{
|
||||
_fillAnimationBottom = new FrameAnimation(_loc2_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationBottom._container.rotation = 270;
|
||||
_theGame._layerBackground.addChild(_fillAnimationBottom._container);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimationTop = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationTop._container.rotation = 180;
|
||||
_theGame._layerBackground.addChild(_fillAnimationTop._container);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(_targetRotation == 0 || _targetRotation == 180)
|
||||
{
|
||||
_fillAnimationBottom = new FrameAnimation(_loc2_,_container.x,_container.y,100,100,0.5);
|
||||
_theGame._layerBackground.addChild(_fillAnimationBottom._container);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimationTop = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationTop._container.rotation = 270;
|
||||
_theGame._layerBackground.addChild(_fillAnimationTop._container);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(_targetRotation == 90 || _targetRotation == 270)
|
||||
{
|
||||
_fillAnimationBottom = new FrameAnimation(_loc2_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationBottom._container.rotation = 90;
|
||||
_theGame._layerBackground.addChild(_fillAnimationBottom._container);
|
||||
break;
|
||||
}
|
||||
_fillAnimationTop = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
_fillAnimationTop._container.rotation = 0;
|
||||
_theGame._layerBackground.addChild(_fillAnimationTop._container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package game.moatMadness
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class MoatPathCurve extends MoatPath
|
||||
{
|
||||
|
||||
private var _activeImage:Object;
|
||||
|
||||
private var _fillAnimation:FrameAnimation;
|
||||
|
||||
public function MoatPathCurve(param1:MoatMadness)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
var _loc2_:Object = _theGame.getScene().getLayer("piece_curve");
|
||||
_activeImage = _theGame.getScene().cloneAsset("piece_curve");
|
||||
_width = _loc2_.loader.width;
|
||||
_height = _loc2_.loader.height;
|
||||
_activeImage.loader.x = -_width / 2;
|
||||
_activeImage.loader.y = -_height / 2;
|
||||
}
|
||||
|
||||
override public function init(param1:MoatMadness, param2:int, param3:int, param4:int) : void
|
||||
{
|
||||
_container.addChild(_activeImage.loader);
|
||||
super.init(param1,param2,param3,param4);
|
||||
}
|
||||
|
||||
override public function Remove() : void
|
||||
{
|
||||
_container.removeChild(_activeImage.loader);
|
||||
if(_fillAnimation)
|
||||
{
|
||||
_fillAnimation._container.parent.removeChild(_fillAnimation._container);
|
||||
_fillAnimation = null;
|
||||
}
|
||||
super.Remove();
|
||||
}
|
||||
|
||||
override public function handleClick(param1:MouseEvent) : void
|
||||
{
|
||||
super.handleClick(param1);
|
||||
}
|
||||
|
||||
override public function heartbeat(param1:Number) : void
|
||||
{
|
||||
if(_fillAnimation && !_fillAnimation.atFrameEnd())
|
||||
{
|
||||
_fillAnimation.heartbeat(param1);
|
||||
if(_filling && _fillAnimation.atNextToLastFrame(5))
|
||||
{
|
||||
setFull();
|
||||
}
|
||||
}
|
||||
super.heartbeat(param1);
|
||||
}
|
||||
|
||||
override public function testForValidFill(param1:int, param2:int, param3:int) : Boolean
|
||||
{
|
||||
if(super.testForValidFill(param1,param2,param3))
|
||||
{
|
||||
return param3 == 1 && (_targetRotation == 180 || _targetRotation == 270) || param3 == 3 && (_targetRotation == 0 || _targetRotation == 90) || param3 == 2 && (_targetRotation == 0 || _targetRotation == 270) || param3 == 4 && (_targetRotation == 90 || _targetRotation == 180);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function getFillDirection(param1:int) : int
|
||||
{
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
if(_targetRotation == 180)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 4;
|
||||
break;
|
||||
case 1:
|
||||
if(_targetRotation == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 3;
|
||||
break;
|
||||
case 2:
|
||||
if(_targetRotation == 0)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return 2;
|
||||
break;
|
||||
case 3:
|
||||
if(_targetRotation == 90)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 3;
|
||||
break;
|
||||
default:
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function startFill(param1:int) : void
|
||||
{
|
||||
super.startFill(param1);
|
||||
_nextFillDirection = getFillDirection(param1);
|
||||
var _loc2_:Object = _theGame.getScene().getLayer("fill_curve_1").loader;
|
||||
var _loc4_:Object = _theGame.getScene().getLayer("fill_curve_2").loader;
|
||||
var _loc3_:Bitmap = _loc2_.content as Bitmap;
|
||||
var _loc5_:Bitmap = _loc4_.content as Bitmap;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
if(_targetRotation == 180)
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc5_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_targetRotation == 0)
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc5_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(_targetRotation == 0)
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc5_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(_targetRotation == 90)
|
||||
{
|
||||
_fillAnimation = new FrameAnimation(_loc3_,_container.x,_container.y,100,100,0.5);
|
||||
break;
|
||||
}
|
||||
_fillAnimation = new FrameAnimation(_loc5_,_container.x,_container.y,100,100,0.5);
|
||||
}
|
||||
_fillAnimation._container.rotation = _targetRotation;
|
||||
_theGame._layerBackground.addChild(_fillAnimation._container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package game.moatMadness
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class MoatPathStraight extends MoatPath
|
||||
{
|
||||
|
||||
private var _activeImage:Object;
|
||||
|
||||
private var _fillAnimation:FrameAnimation;
|
||||
|
||||
public function MoatPathStraight(param1:MoatMadness)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
var _loc2_:Object = _theGame.getScene().getLayer("piece_straight");
|
||||
_activeImage = _theGame.getScene().cloneAsset("piece_straight");
|
||||
_width = _loc2_.loader.width;
|
||||
_height = _loc2_.loader.height;
|
||||
_activeImage.loader.x = -_width / 2;
|
||||
_activeImage.loader.y = -_height / 2;
|
||||
}
|
||||
|
||||
override public function init(param1:MoatMadness, param2:int, param3:int, param4:int) : void
|
||||
{
|
||||
_container.addChild(_activeImage.loader);
|
||||
super.init(param1,param2,param3,param4);
|
||||
}
|
||||
|
||||
override public function Remove() : void
|
||||
{
|
||||
_container.removeChild(_activeImage.loader);
|
||||
if(_fillAnimation)
|
||||
{
|
||||
_fillAnimation._container.parent.removeChild(_fillAnimation._container);
|
||||
_fillAnimation = null;
|
||||
}
|
||||
super.Remove();
|
||||
}
|
||||
|
||||
override public function handleClick(param1:MouseEvent) : void
|
||||
{
|
||||
super.handleClick(param1);
|
||||
}
|
||||
|
||||
override public function heartbeat(param1:Number) : void
|
||||
{
|
||||
if(_fillAnimation && !_fillAnimation.atFrameEnd())
|
||||
{
|
||||
_fillAnimation.heartbeat(param1);
|
||||
if(_filling && _fillAnimation.atNextToLastFrame(5))
|
||||
{
|
||||
setFull();
|
||||
}
|
||||
}
|
||||
super.heartbeat(param1);
|
||||
}
|
||||
|
||||
override public function testForValidFill(param1:int, param2:int, param3:int) : Boolean
|
||||
{
|
||||
if(super.testForValidFill(param1,param2,param3))
|
||||
{
|
||||
return param3 == 1 && (_targetRotation == 0 || _targetRotation == 180) || param3 == 3 && (_targetRotation == 0 || _targetRotation == 180) || param3 == 2 && (_targetRotation == 90 || _targetRotation == 270) || param3 == 4 && (_targetRotation == 90 || _targetRotation == 270);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function getFillDirection(param1:int) : int
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
override public function startFill(param1:int) : void
|
||||
{
|
||||
super.startFill(param1);
|
||||
_nextFillDirection = getFillDirection(param1);
|
||||
var _loc2_:Bitmap = _theGame.getScene().getLayer("fill_straight").loader.content as Bitmap;
|
||||
_fillAnimation = new FrameAnimation(_loc2_,_container.x,_container.y,100,100,0.5);
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_fillAnimation._container.rotation = 180;
|
||||
break;
|
||||
case 1:
|
||||
_fillAnimation._container.rotation = 270;
|
||||
break;
|
||||
case 2:
|
||||
_fillAnimation._container.rotation = 0;
|
||||
break;
|
||||
case 3:
|
||||
_fillAnimation._container.rotation = 90;
|
||||
}
|
||||
_theGame._layerBackground.addChild(_fillAnimation._container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,842 @@
|
||||
package game.pVP_Bowling
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_Bowling extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PHASE_WAIT_RESULTS:int = 5;
|
||||
|
||||
public static const GAMESTATE_PHASE_RESULTS_COMPLETE:int = 7;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 8;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER_RESULTS:int = 9;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 10;
|
||||
|
||||
public static const TURN_TIME:int = 15;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
public var _currentBowl:int;
|
||||
|
||||
public var _currentFrame:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _timeout:Boolean;
|
||||
|
||||
private var _timeoutTimer:Number;
|
||||
|
||||
private var _isFrameDone:Boolean;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _iGameResult:int;
|
||||
|
||||
public var _gameCompleteTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _emoteTimer:Number;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["aj_bowlBallRoll_2.mp3","aj_bowlGutterBall.mp3","aj_bowlPinDbleHit.mp3","aj_bowlPinMultiHit.mp3","aj_bowlPinSngleHit.mp3","aj_bowlPinSngleHitStars.mp3","aj_bowlPlayerFail.mp3","aj_bowlPlayerWin.mp3","aj_bowlSpare.mp3","aj_bowlStrike.mp3","aj_pinSingleHitWall.mp3","pvp_emojiRollover.mp3","pvp_emojiSelect.mp3","pvp_RedTexExit.mp3","pvp_RedTextEnter.mp3","pvp_timerRedCountdown.mp3","pvp_timeUpBuzzer.mp3","pvp_TurnEnter.mp3","pvp_TurnExit.mp3"];
|
||||
|
||||
private var _soundNameBallRoll2:String = _audio[0];
|
||||
|
||||
private var _soundNameGutterBall:String = _audio[1];
|
||||
|
||||
private var _soundNamePinDbleHit:String = _audio[2];
|
||||
|
||||
private var _soundNamePinMultiHit:String = _audio[3];
|
||||
|
||||
private var _soundNamePinSngleHit:String = _audio[4];
|
||||
|
||||
private var _soundNamePinSngleHitStars:String = _audio[5];
|
||||
|
||||
private var _soundNamePlayerFail:String = _audio[6];
|
||||
|
||||
private var _soundNamePlayerWin:String = _audio[7];
|
||||
|
||||
private var _soundNameSpare:String = _audio[8];
|
||||
|
||||
private var _soundNameStrike:String = _audio[9];
|
||||
|
||||
private var _soundNamePinSingleHitWall:String = _audio[10];
|
||||
|
||||
private var _soundNameEmojiRollover:String = _audio[11];
|
||||
|
||||
private var _soundNameEmojiSelect:String = _audio[12];
|
||||
|
||||
private var _soundNameRedTexExit:String = _audio[13];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[14];
|
||||
|
||||
private var _soundNameTimerRedCountdown:String = _audio[15];
|
||||
|
||||
private var _soundNameTimeUpBuzzer:String = _audio[16];
|
||||
|
||||
private var _soundNameTurnEnter:String = _audio[17];
|
||||
|
||||
private var _soundNameTurnExit:String = _audio[18];
|
||||
|
||||
public function PVP_Bowling()
|
||||
{
|
||||
super();
|
||||
_iGameResult = 0;
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameBallRoll2],_soundNameBallRoll2,0.69);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGutterBall],_soundNameGutterBall,0.88);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePinDbleHit],_soundNamePinDbleHit,1.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePinMultiHit],_soundNamePinMultiHit,0.96);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePinSngleHit],_soundNamePinSngleHit,1.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePinSngleHitStars],_soundNamePinSngleHitStars,1.15);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerFail],_soundNamePlayerFail,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerWin],_soundNamePlayerWin,0.9);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSpare],_soundNameSpare,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStrike],_soundNameStrike,0.63);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePinSingleHitWall],_soundNamePinSingleHitWall,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEmojiRollover],_soundNameEmojiRollover,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEmojiSelect],_soundNameEmojiSelect,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTexExit],_soundNameRedTexExit,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerRedCountdown],_soundNameTimerRedCountdown,0.38);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimeUpBuzzer],_soundNameTimeUpBuzzer,1.1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurnEnter],_soundNameTurnEnter,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurnExit],_soundNameTurnExit,0.25);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("keyDown",onKeyDown);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function onKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
if(_theGame.loader.content.localTurn)
|
||||
{
|
||||
_theGame.loader.content.playerInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_Bowling/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
_emoteTimer = 0;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("keyDown",onKeyDown,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
_iGameResult = 1;
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(9);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[3]);
|
||||
_players[1] = parseInt(param1[4]);
|
||||
_currentBowl = 1;
|
||||
_currentFrame = 0;
|
||||
if(_players[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.startTurn(true,_currentFrame + 1,_currentBowl);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.startTurn(false,_currentFrame + 1,_currentBowl);
|
||||
}
|
||||
setGameState(5);
|
||||
hideDlg();
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "ball")
|
||||
{
|
||||
_theGame.loader.content.bowlRemote(parseFloat(param1[3]),parseFloat(param1[4]),parseFloat(param1[5]));
|
||||
_turnTimer = 0;
|
||||
_theGame.loader.content.time(15,15);
|
||||
}
|
||||
else if(param1[2] == "time")
|
||||
{
|
||||
_theGame.loader.content.lane1Sim.simBall.moveActive = 3;
|
||||
_theGame.loader.content.bowlScore = 0;
|
||||
_timeout = true;
|
||||
if(!_theGame.loader.content.localTurn)
|
||||
{
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "nextround")
|
||||
{
|
||||
setGameState(5);
|
||||
_theGame.loader.content.startTurn(_theGame.loader.content.localTurn,_currentFrame / 2 + 1,_currentBowl);
|
||||
}
|
||||
else if(param1[2] == "emote")
|
||||
{
|
||||
if(_theGame != null && _theGame.loader != null && _theGame.loader.content != null)
|
||||
{
|
||||
_theGame.loader.content.opponentEmote(parseInt(param1[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 10)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc2_ = showDlg("PVPBowling_waiting",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
_turnTimer = 15;
|
||||
break;
|
||||
case 8:
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
switch(_iGameResult)
|
||||
{
|
||||
case 0:
|
||||
_theGame.loader.content.setLose();
|
||||
break;
|
||||
case 1:
|
||||
_theGame.loader.content.setWin();
|
||||
break;
|
||||
case 2:
|
||||
_theGame.loader.content.setTie();
|
||||
}
|
||||
_gameCompleteTimer = 3;
|
||||
break;
|
||||
case 9:
|
||||
switch(_iGameResult)
|
||||
{
|
||||
case 0:
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
addGemsToBalance(5);
|
||||
_loc2_ = showDlg("PVPBowling_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.gemsEarned,11577,5);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(20);
|
||||
_loc2_ = showDlg("PVPBowling_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(10);
|
||||
_loc2_ = showDlg("PVPBowling_tie",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
_gameCompleteTimer = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
|
||||
private function processResults() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
if(_isFrameDone)
|
||||
{
|
||||
if(_currentFrame >= 5)
|
||||
{
|
||||
handleEndGame();
|
||||
return;
|
||||
}
|
||||
_currentFrame = _currentFrame + 1;
|
||||
_currentBowl = 1;
|
||||
_theGame.loader.content.localTurn = !_theGame.loader.content.localTurn;
|
||||
}
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "rp";
|
||||
messageServer(_loc1_);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_emoteTimer > 0)
|
||||
{
|
||||
_emoteTimer -= _frameTime;
|
||||
}
|
||||
if(_emoteTimer <= 0 && _theGame.loader.content.emoteClicked > 0)
|
||||
{
|
||||
_emoteTimer = 1.5;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "emote";
|
||||
_loc2_[1] = _theGame.loader.content.emoteClicked;
|
||||
messageServer(_loc2_);
|
||||
_theGame.loader.content.emoteClicked = 0;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlBallRoll_2)
|
||||
{
|
||||
_soundMan.playByName(_soundNameBallRoll2);
|
||||
_theGame.loader.content.aj_bowlBallRoll_2 = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlGutterBall)
|
||||
{
|
||||
_soundMan.playByName(_soundNameGutterBall);
|
||||
_theGame.loader.content.aj_bowlGutterBall = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPinDbleHit)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePinDbleHit);
|
||||
_theGame.loader.content.aj_bowlPinDbleHit = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPinMultiHit)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePinMultiHit);
|
||||
_theGame.loader.content.aj_bowlPinMultiHit = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPinSngleHit)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePinSngleHit);
|
||||
_theGame.loader.content.aj_bowlPinSngleHit = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPinSngleHitStars)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePinSngleHitStars);
|
||||
_theGame.loader.content.aj_bowlPinSngleHitStars = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPlayerFail)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePlayerFail);
|
||||
_theGame.loader.content.aj_bowlPlayerFail = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlPlayerWin)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePlayerWin);
|
||||
_theGame.loader.content.aj_bowlPlayerWin = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlSpare)
|
||||
{
|
||||
_soundMan.playByName(_soundNameSpare);
|
||||
_theGame.loader.content.aj_bowlSpare = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_bowlStrike)
|
||||
{
|
||||
_soundMan.playByName(_soundNameStrike);
|
||||
_theGame.loader.content.aj_bowlStrike = false;
|
||||
}
|
||||
if(_theGame.loader.content.aj_pinSingleHitWall)
|
||||
{
|
||||
_soundMan.playByName(_soundNamePinSingleHitWall);
|
||||
_theGame.loader.content.aj_pinSingleHitWall = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_emojiRollover)
|
||||
{
|
||||
_soundMan.playByName(_soundNameEmojiRollover);
|
||||
_theGame.loader.content.pvp_emojiRollover = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_emojiSelect)
|
||||
{
|
||||
_soundMan.playByName(_soundNameEmojiSelect);
|
||||
_theGame.loader.content.pvp_emojiSelect = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_RedTexExit)
|
||||
{
|
||||
_soundMan.playByName(_soundNameRedTexExit);
|
||||
_theGame.loader.content.pvp_RedTexExit = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_RedTextEnter)
|
||||
{
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
_theGame.loader.content.pvp_RedTextEnter = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_timerRedCountdown)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimerRedCountdown);
|
||||
_theGame.loader.content.pvp_timerRedCountdown = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_timeUpBuzzer)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimeUpBuzzer);
|
||||
_theGame.loader.content.pvp_timeUpBuzzer = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_TurnEnter)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurnEnter);
|
||||
_theGame.loader.content.pvp_TurnEnter = false;
|
||||
}
|
||||
if(_theGame.loader.content.pvp_TurnExit)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurnExit);
|
||||
_theGame.loader.content.pvp_TurnExit = false;
|
||||
}
|
||||
switch(_gameState - 5)
|
||||
{
|
||||
case 0:
|
||||
_theGame.loader.content.stageHeartbeat();
|
||||
if(_timeoutTimer > 0)
|
||||
{
|
||||
_timeoutTimer -= _frameTime;
|
||||
if(_timeoutTimer <= 0)
|
||||
{
|
||||
processResults();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_theGame.loader.content.lane1Sim.simBall.moveActive == 3)
|
||||
{
|
||||
_isFrameDone = _theGame.loader.content.recordScore(_theGame.loader.content.localTurn,_currentFrame / 2 + 1,_currentBowl++);
|
||||
_theGame.loader.content.lane1Sim.simBall.moveActive = 4;
|
||||
if(_timeout)
|
||||
{
|
||||
_timeout = false;
|
||||
_timeoutTimer = 1.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
processResults();
|
||||
}
|
||||
}
|
||||
if(_theGame.loader.content.localTurn && _theGame.loader.content.ballThrown)
|
||||
{
|
||||
_theGame.loader.content.ballThrown = false;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "ball";
|
||||
_loc2_[1] = _theGame.loader.content.ballThrown_Angle;
|
||||
_loc2_[2] = _theGame.loader.content.ballThrown_x;
|
||||
_loc2_[3] = _theGame.loader.content.ballThrown_y;
|
||||
messageServer(_loc2_);
|
||||
_turnTimer = 0;
|
||||
_theGame.loader.content.time(15,15);
|
||||
}
|
||||
}
|
||||
if(_turnTimer > 0)
|
||||
{
|
||||
_turnTimer -= _frameTime;
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
if(_theGame.loader.content.myTurn)
|
||||
{
|
||||
_turnTimer = 0;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
messageServer(_loc2_);
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(_gameCompleteTimer > 0)
|
||||
{
|
||||
_gameCompleteTimer -= _frameTime;
|
||||
if(_gameCompleteTimer <= 0)
|
||||
{
|
||||
setGameState(10);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if(_gameCompleteTimer > 0)
|
||||
{
|
||||
_gameCompleteTimer -= _frameTime;
|
||||
if(_gameCompleteTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function handleEndGame() : void
|
||||
{
|
||||
if(_theGame.loader.content.totalScoreL > _theGame.loader.content.totalScoreR)
|
||||
{
|
||||
_iGameResult = 1;
|
||||
}
|
||||
else if(_theGame.loader.content.totalScoreL == _theGame.loader.content.totalScoreR)
|
||||
{
|
||||
_iGameResult = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_iGameResult = 0;
|
||||
}
|
||||
setGameState(9);
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 10)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,717 @@
|
||||
package game.pVP_ConnectFour
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_ConnectFour extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PLAYING:int = 5;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 6;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 7;
|
||||
|
||||
public static const TURN_TIME:int = 15;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _roundCompleteTimer:Number;
|
||||
|
||||
public var _gameOverTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _myTurn:Boolean;
|
||||
|
||||
public var _winState:int;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["pvp_stinger_draw.mp3","pvp_stinger_fail.mp3","pvp_stinger_win.mp3","pvp_stinger_turn.mp3","connect_four_slide.mp3","connect_four_square_rollover.mp3","connect_four_imp.mp3","popup_pvp_RedText_enter.mp3","popup_pvp_RedText_exit.mp3","popup_pvp_YourTurn_enter.mp3","popup_pvp_YourTurn_exit.mp3","pvp_c4_timer_count_down.mp3","pvp_timeUp_buzzer.mp3"];
|
||||
|
||||
private var _soundNameTie:String = _audio[0];
|
||||
|
||||
private var _soundNameLose:String = _audio[1];
|
||||
|
||||
private var _soundNameWin:String = _audio[2];
|
||||
|
||||
private var _soundNameTurn:String = _audio[3];
|
||||
|
||||
private var _soundNameSelect:String = _audio[4];
|
||||
|
||||
private var _soundNameRollover:String = _audio[5];
|
||||
|
||||
private var _soundNameSlideStop:String = _audio[6];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[7];
|
||||
|
||||
private var _soundNameRedTextExit:String = _audio[8];
|
||||
|
||||
private var _soundNameYourTurnEnter:String = _audio[9];
|
||||
|
||||
private var _soundNameYourTurnExit:String = _audio[10];
|
||||
|
||||
private var _soundNameTimerCount:String = _audio[11];
|
||||
|
||||
private var _soundNameTimerDone:String = _audio[12];
|
||||
|
||||
public function PVP_ConnectFour()
|
||||
{
|
||||
super();
|
||||
_winState = 0;
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTie],_soundNameTie,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLose],_soundNameLose,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWin],_soundNameWin,0.45);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurn],_soundNameTurn,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSelect],_soundNameSelect,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.29);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSlideStop],_soundNameSlideStop,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.14);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextExit],_soundNameRedTextExit,0.13);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYourTurnEnter],_soundNameYourTurnEnter,0.17);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYourTurnExit],_soundNameYourTurnExit,0.17);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCount],_soundNameTimerCount,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerDone],_soundNameTimerDone,1);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_gameOverTimer = 0;
|
||||
_winState = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_ConnectFour/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
if(_soundMan)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
}
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setPlayerInactive();
|
||||
}
|
||||
_winState = 1;
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(7);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[4]);
|
||||
_players[1] = parseInt(param1[5]);
|
||||
_myTurn = _players[parseInt(param1[3])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
setGameState(5);
|
||||
}
|
||||
else if(param1[2] == "mark")
|
||||
{
|
||||
_soundMan.playByName(_soundNameSelect);
|
||||
_theGame.loader.content.setMark(parseInt(param1[3]) == 0,parseInt(param1[4]));
|
||||
_boardSelectDelayTimer = 0.5;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_messageCache[_loc3_] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "invalid" || param1[2] == "wp")
|
||||
{
|
||||
_myTurn = _players[parseInt(param1[3])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 7 && _gameState != param1)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_loc2_ = showDlg("c4_waiting",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
hideDlg();
|
||||
break;
|
||||
case 5:
|
||||
_roundCompleteTimer = 3;
|
||||
break;
|
||||
case 6:
|
||||
if(_winState == 1)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(20);
|
||||
}
|
||||
else if(_winState == 2)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
addGemsToBalance(5);
|
||||
}
|
||||
_roundCompleteTimer = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_theGame.loader.content.newRound();
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
_theGame.loader.content.checkerSound = false;
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.playerX = true;
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.playerX = false;
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:MovieClip = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_theGame.loader.content.timer_count_down)
|
||||
{
|
||||
_theGame.loader.content.timer_count_down = false;
|
||||
_soundMan.playByName(_soundNameTimerCount);
|
||||
}
|
||||
if(_theGame.loader.content.timer_timeUp)
|
||||
{
|
||||
_theGame.loader.content.timer_timeUp = false;
|
||||
_soundMan.playByName(_soundNameTimerDone);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_enter)
|
||||
{
|
||||
_theGame.loader.content.RedText_enter = false;
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_exit)
|
||||
{
|
||||
_theGame.loader.content.RedText_exit = false;
|
||||
_soundMan.playByName(_soundNameRedTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_enter)
|
||||
{
|
||||
_theGame.loader.content.YourTurn_enter = false;
|
||||
_soundMan.playByName(_soundNameYourTurnEnter);
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_exit)
|
||||
{
|
||||
_theGame.loader.content.YourTurn_exit = false;
|
||||
_soundMan.playByName(_soundNameYourTurnExit);
|
||||
}
|
||||
if(_gameState == 5)
|
||||
{
|
||||
if(_theGame.loader.content.rolloverSound)
|
||||
{
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
if(_theGame.loader.content.checkerSound)
|
||||
{
|
||||
_theGame.loader.content.checkerSound = false;
|
||||
_soundMan.playByName(_soundNameSlideStop);
|
||||
}
|
||||
if(_theGame.loader.content.marked)
|
||||
{
|
||||
_myTurn = false;
|
||||
_turnTimer = 0;
|
||||
_theGame.loader.content.marked = false;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "mark";
|
||||
_loc2_[1] = String(int(_theGame.loader.content.markedX));
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
else if(_boardSelectDelayTimer > 0)
|
||||
{
|
||||
_boardSelectDelayTimer -= _frameTime;
|
||||
if(_boardSelectDelayTimer <= 0)
|
||||
{
|
||||
if(_messageCache[5] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[3])] == myId)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
_theGame.loader.content.setWin();
|
||||
_winState = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameLose);
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(7);
|
||||
}
|
||||
else if(_messageCache[6] == "1")
|
||||
{
|
||||
_winState = 2;
|
||||
_soundMan.playByName(_soundNameTie);
|
||||
_theGame.loader.content.setTie();
|
||||
setGameState(7);
|
||||
}
|
||||
else
|
||||
{
|
||||
_myTurn = _players[parseInt(_messageCache[7])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_turnTimer > 0)
|
||||
{
|
||||
_turnTimer -= _frameTime;
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_turnTimer = 0;
|
||||
if(_myTurn)
|
||||
{
|
||||
_myTurn = false;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
else if(_gameState == 6)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 7)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
if(_winState == 1)
|
||||
{
|
||||
_loc3_ = showDlg("c4_win",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
}
|
||||
}
|
||||
else if(_winState == 2)
|
||||
{
|
||||
_loc3_ = showDlg("c4_tie",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = showDlg("c4_win",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc3_.gemsEarned,11577,5);
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
}
|
||||
}
|
||||
_gameOverTimer = 3;
|
||||
}
|
||||
}
|
||||
else if(_gameOverTimer > 0)
|
||||
{
|
||||
_gameOverTimer -= _frameTime;
|
||||
if(_gameOverTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 7)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
package game.pVP_Marbles
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.Contacts.b2ContactResult;
|
||||
import Box2D.Dynamics.b2ContactListener;
|
||||
|
||||
public class PVP_Marbles_ContactListener extends b2ContactListener
|
||||
{
|
||||
|
||||
public var contactStack:Array = [];
|
||||
|
||||
public function PVP_Marbles_ContactListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function Result(param1:b2ContactResult) : void
|
||||
{
|
||||
var _loc2_:b2Shape = param1.shape1;
|
||||
var _loc3_:b2Shape = param1.shape2;
|
||||
var _loc4_:Number = param1.normalImpulse;
|
||||
var _loc5_:b2Vec2 = param1.position;
|
||||
if(_loc4_ > 1)
|
||||
{
|
||||
contactStack.push(new PVP_Marbles_CustomContactPoint(_loc2_,_loc3_,_loc4_,_loc5_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package game.pVP_Marbles
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class PVP_Marbles_CustomContactPoint
|
||||
{
|
||||
|
||||
public var shape1:b2Shape;
|
||||
|
||||
public var shape2:b2Shape;
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var position:b2Vec2;
|
||||
|
||||
public var velocity:b2Vec2;
|
||||
|
||||
public var normal:b2Vec2;
|
||||
|
||||
public var force:Number;
|
||||
|
||||
public var normalImpulse:Number;
|
||||
|
||||
public var tangentImpulse:Number;
|
||||
|
||||
public function PVP_Marbles_CustomContactPoint(param1:b2Shape, param2:b2Shape, param3:Number, param4:b2Vec2)
|
||||
{
|
||||
super();
|
||||
shape1 = param1;
|
||||
shape2 = param2;
|
||||
normalImpulse = param3;
|
||||
position = param4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package game.pVP_Marbles
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
|
||||
public class PVP_Marbles_Marble extends MovieClip
|
||||
{
|
||||
|
||||
private static const FADE_RATE:Number = 0.1;
|
||||
|
||||
public var _fadeIn:Boolean;
|
||||
|
||||
public var _fadedOut:Function;
|
||||
|
||||
public var _fadedIn:Function;
|
||||
|
||||
public var _delayTime:Number;
|
||||
|
||||
public function PVP_Marbles_Marble()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function fade(param1:Function) : void
|
||||
{
|
||||
alpha -= 0.1;
|
||||
_fadeIn = false;
|
||||
_fadedOut = param1;
|
||||
addEventListener("enterFrame",heartbeat);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
if(_fadeIn)
|
||||
{
|
||||
alpha += 0.1;
|
||||
if(alpha >= 1)
|
||||
{
|
||||
alpha = 1;
|
||||
removeEventListener("enterFrame",heartbeat);
|
||||
if(_fadedIn != null)
|
||||
{
|
||||
_fadedIn(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_delayTime > 0)
|
||||
{
|
||||
_delayTime -= 0.04;
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha -= 0.1;
|
||||
if(alpha <= 0)
|
||||
{
|
||||
alpha = 0;
|
||||
_fadedOut(this);
|
||||
_fadeIn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,820 @@
|
||||
package game.pVP_Memory
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_Memory extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PHASE_WAIT_RESULTS:int = 5;
|
||||
|
||||
public static const GAMESTATE_PHASE_PROCESS_RESULTS:int = 6;
|
||||
|
||||
public static const GAMESTATE_PHASE_RESULTS_COMPLETE:int = 7;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 8;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER_RESULTS:int = 9;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 10;
|
||||
|
||||
public static const TURN_TIME:int = 15;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _iGameResult:int;
|
||||
|
||||
public var _cardPickedStatus:int;
|
||||
|
||||
public var _gameCompleteTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _emoteTimer:Number;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["pvp_stinger_draw.mp3","pvp_matchFail.mp3","pvp_matchFlip.mp3","pvp_matchRollOver.mp3","pvp_matchSelect.mp3","pvp_matchSuccess.mp3","pvp_stingerFail.mp3","pvp_stingerWin.mp3","pvp_stingerYourTurn.mp3","pvp_timerCountdown.mp3","pvp_timeUpBuzzer.mp3","pvp_RedTextEnter.mp3","pvp_RedTextExit.mp3","pvp_emojiRollover.mp3","pvp_emojiSelect.mp3","pvp_TurnEnter.mp3","pvp_TurnExit.mp3","pvp_textAwesome.mp3","pvp_textFindMatch.mp3"];
|
||||
|
||||
private var _soundNameTie:String = _audio[0];
|
||||
|
||||
private var _soundNameMatchNo:String = _audio[1];
|
||||
|
||||
private var _soundNameMatchFlip:String = _audio[2];
|
||||
|
||||
private var _soundNameMatchRollOver:String = _audio[3];
|
||||
|
||||
private var _soundNameMatchSelect:String = _audio[4];
|
||||
|
||||
private var _soundNameMatchYes:String = _audio[5];
|
||||
|
||||
private var _soundNameLose:String = _audio[6];
|
||||
|
||||
private var _soundNameWin:String = _audio[7];
|
||||
|
||||
private var _soundNameYourTurn:String = _audio[8];
|
||||
|
||||
private var _soundNameTimerCountdown:String = _audio[9];
|
||||
|
||||
private var _soundNameTimerZero:String = _audio[10];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[11];
|
||||
|
||||
private var _soundNameRedTextExit:String = _audio[12];
|
||||
|
||||
private var _soundNameEmojiRollover:String = _audio[13];
|
||||
|
||||
private var _soundNameEmojiSelect:String = _audio[14];
|
||||
|
||||
private var _soundNameTurnEnter:String = _audio[15];
|
||||
|
||||
private var _soundNameTurnExit:String = _audio[16];
|
||||
|
||||
private var _soundNameTextAwesome:String = _audio[17];
|
||||
|
||||
private var _soundNameTextFindMatch:String = _audio[18];
|
||||
|
||||
public function PVP_Memory()
|
||||
{
|
||||
super();
|
||||
_iGameResult = 0;
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTie],_soundNameTie,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMatchNo],_soundNameMatchNo,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMatchFlip],_soundNameMatchFlip,0.9);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMatchRollOver],_soundNameMatchRollOver,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMatchSelect],_soundNameMatchSelect,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameMatchYes],_soundNameMatchYes,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLose],_soundNameLose,0.65);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWin],_soundNameWin,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYourTurn],_soundNameYourTurn,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCountdown],_soundNameTimerCountdown,0.25);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerZero],_soundNameTimerZero,1.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextExit],_soundNameRedTextExit,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEmojiRollover],_soundNameEmojiRollover,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameEmojiSelect],_soundNameEmojiSelect,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurnEnter],_soundNameTurnEnter,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurnExit],_soundNameTurnExit,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextAwesome],_soundNameTextAwesome,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTextFindMatch],_soundNameTextFindMatch,0.3);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_Memory/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
_emoteTimer = 0;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc11_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
var _loc12_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc8_:Boolean = false;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
_iGameResult = 1;
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(9);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc5_ = 1;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc9_] = param1[_loc5_++];
|
||||
_userNames[_loc9_] = param1[_loc5_++];
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[3]);
|
||||
_players[1] = parseInt(param1[4]);
|
||||
_loc2_ = parseInt(param1[5]);
|
||||
_loc3_ = new Array(_loc2_);
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < _loc2_)
|
||||
{
|
||||
_loc3_[_loc12_] = parseInt(param1[6 + _loc12_]);
|
||||
_loc12_++;
|
||||
}
|
||||
_theGame.loader.content.setCards(_loc3_);
|
||||
_theGame.loader.content.myTurn = _players[0] == myId ? 1 : 0;
|
||||
_theGame.loader.content.newPhase(1);
|
||||
_cardPickedStatus = 0;
|
||||
setGameState(5);
|
||||
hideDlg();
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "c1" || param1[2] == "c2")
|
||||
{
|
||||
_turnTimer = 15;
|
||||
_cardPickedStatus = _cardPickedStatus + 1;
|
||||
_loc4_ = parseInt(param1[3]);
|
||||
_loc7_ = _loc4_ / 4 + 1;
|
||||
_loc10_ = _loc4_ % 4 + 1;
|
||||
_theGame.loader.content.cardPicked(_loc10_,_loc7_);
|
||||
_soundMan.playByName(_soundNameMatchSelect);
|
||||
}
|
||||
else if(param1[2] == "time")
|
||||
{
|
||||
setGameState(6);
|
||||
_theGame.loader.content.setResult(false);
|
||||
}
|
||||
else if(param1[2] == "results")
|
||||
{
|
||||
setGameState(6);
|
||||
if(param1[3] == "1")
|
||||
{
|
||||
_theGame.loader.content.setResult(true);
|
||||
_loc6_ = parseInt(param1[4]);
|
||||
if(_loc6_ == myId)
|
||||
{
|
||||
_iGameResult = 1;
|
||||
}
|
||||
else if(_loc6_ == 0)
|
||||
{
|
||||
_iGameResult = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_iGameResult = 0;
|
||||
}
|
||||
setGameState(9);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = param1[4] == "1";
|
||||
_theGame.loader.content.setResult(_loc8_);
|
||||
if(!_loc8_)
|
||||
{
|
||||
_soundMan.playByName(_soundNameMatchNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameMatchYes);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "nextround")
|
||||
{
|
||||
_theGame.loader.content.newPhase(9);
|
||||
setGameState(5);
|
||||
if(_theGame.loader.content.myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameYourTurn);
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "emote")
|
||||
{
|
||||
if(_theGame != null && _theGame.loader != null && _theGame.loader.content != null)
|
||||
{
|
||||
_theGame.loader.content.opponentEmote(parseInt(param1[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 10 && _gameState != param1)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc2_ = showDlg("PVPMemory_waiting",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
_cardPickedStatus = 0;
|
||||
_theGame.loader.content.card1X = 0;
|
||||
_theGame.loader.content.card2X = 0;
|
||||
_theGame.loader.content.card1Y = 0;
|
||||
_theGame.loader.content.card2Y = 0;
|
||||
_turnTimer = 15;
|
||||
break;
|
||||
case 5:
|
||||
_cardPickedStatus = 3;
|
||||
break;
|
||||
case 8:
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
switch(_iGameResult)
|
||||
{
|
||||
case 0:
|
||||
_soundMan.playByName(_soundNameLose);
|
||||
_theGame.loader.content.setLose();
|
||||
break;
|
||||
case 1:
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
_theGame.loader.content.setWin();
|
||||
break;
|
||||
case 2:
|
||||
_soundMan.playByName(_soundNameTie);
|
||||
_theGame.loader.content.setTie();
|
||||
}
|
||||
_gameCompleteTimer = 3;
|
||||
break;
|
||||
case 9:
|
||||
switch(_iGameResult)
|
||||
{
|
||||
case 0:
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
addGemsToBalance(5);
|
||||
_loc2_ = showDlg("PVPMemory_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.gemsEarned,11577,5);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(20);
|
||||
_loc2_ = showDlg("PVPMemory_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(10);
|
||||
_loc2_ = showDlg("PVPMemory_tie",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
_gameCompleteTimer = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_emoteTimer > 0)
|
||||
{
|
||||
_emoteTimer -= _frameTime;
|
||||
}
|
||||
if(_emoteTimer <= 0 && _theGame.loader.content.emoteClicked > 0)
|
||||
{
|
||||
_emoteTimer = 1.5;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "emote";
|
||||
_loc2_[1] = _theGame.loader.content.emoteClicked;
|
||||
messageServer(_loc2_);
|
||||
_theGame.loader.content.emoteClicked = 0;
|
||||
_soundMan.playByName(_soundNameEmojiSelect);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_enter)
|
||||
{
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
_theGame.loader.content.RedText_enter = false;
|
||||
}
|
||||
if(_theGame.loader.content.RedText_exit)
|
||||
{
|
||||
_soundMan.playByName(_soundNameRedTextExit);
|
||||
_theGame.loader.content.RedText_exit = false;
|
||||
}
|
||||
if(_theGame.loader.content.rolloverSound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameMatchRollOver);
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
}
|
||||
if(_theGame.loader.content.emojiRolloverSound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameEmojiRollover);
|
||||
_theGame.loader.content.emojiRolloverSound = false;
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_enter)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurnEnter);
|
||||
_theGame.loader.content.YourTurn_enter = false;
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_exit)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurnExit);
|
||||
_theGame.loader.content.YourTurn_exit = false;
|
||||
}
|
||||
if(_theGame.loader.content.matchFlipSound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameMatchFlip);
|
||||
_theGame.loader.content.matchFlipSound = false;
|
||||
}
|
||||
if(_theGame.loader.content.textAwesomeSound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTextAwesome);
|
||||
_theGame.loader.content.textAwesomeSound = false;
|
||||
}
|
||||
if(_theGame.loader.content.textFindMatchSound)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTextFindMatch);
|
||||
_theGame.loader.content.textFindMatchSound = false;
|
||||
}
|
||||
switch(_gameState - 5)
|
||||
{
|
||||
case 0:
|
||||
switch(_cardPickedStatus)
|
||||
{
|
||||
case 0:
|
||||
if(_theGame.loader.content.card1X != 0 && _theGame.loader.content.card1Y != 0)
|
||||
{
|
||||
_turnTimer = 15;
|
||||
_cardPickedStatus = 1;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "c1";
|
||||
_loc2_[1] = (_theGame.loader.content.card1Y - 1) * 4 + (_theGame.loader.content.card1X - 1);
|
||||
messageServer(_loc2_);
|
||||
_soundMan.playByName(_soundNameMatchSelect);
|
||||
}
|
||||
else if(_turnTimer > 0)
|
||||
{
|
||||
_loc3_ = _turnTimer;
|
||||
_turnTimer -= _frameTime;
|
||||
if(_loc3_ >= 3 && _turnTimer < 3 || _loc3_ >= 2 && _turnTimer < 2 || _loc3_ >= 1 && _turnTimer < 1)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimerCountdown);
|
||||
}
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimerZero);
|
||||
if(_theGame.loader.content.myTurn)
|
||||
{
|
||||
_cardPickedStatus = 2;
|
||||
_turnTimer = 0;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_theGame.loader.content.card2X > 0 && _theGame.loader.content.card2Y > 0)
|
||||
{
|
||||
_cardPickedStatus = 2;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "c2";
|
||||
_loc2_[1] = (_theGame.loader.content.card2Y - 1) * 4 + (_theGame.loader.content.card2X - 1);
|
||||
messageServer(_loc2_);
|
||||
_soundMan.playByName(_soundNameMatchSelect);
|
||||
break;
|
||||
}
|
||||
if(_turnTimer > 0)
|
||||
{
|
||||
_loc3_ = _turnTimer;
|
||||
_turnTimer -= _frameTime;
|
||||
if(_loc3_ >= 3 && _turnTimer < 3 || _loc3_ >= 2 && _turnTimer < 2 || _loc3_ >= 1 && _turnTimer < 1)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimerCountdown);
|
||||
}
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTimerZero);
|
||||
if(_theGame.loader.content.myTurn)
|
||||
{
|
||||
_cardPickedStatus = 2;
|
||||
_turnTimer = 0;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_theGame.loader.content.phase == 8)
|
||||
{
|
||||
setGameState(7);
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "rp";
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(_gameCompleteTimer > 0)
|
||||
{
|
||||
_gameCompleteTimer -= _frameTime;
|
||||
if(_gameCompleteTimer <= 0)
|
||||
{
|
||||
setGameState(10);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if(_gameCompleteTimer > 0)
|
||||
{
|
||||
_gameCompleteTimer -= _frameTime;
|
||||
if(_gameCompleteTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 10)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,649 @@
|
||||
package game.pVP_RockPaperScissor
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_RockPaperScissor extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PLAYING:int = 5;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 6;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 7;
|
||||
|
||||
public static const TURN_TIME:int = 5;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _iWon:Boolean;
|
||||
|
||||
public var _roundCompleteTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["pvp_stinger_draw.mp3","pvp_stinger_fail.mp3","pvp_stinger_win.mp3","pvp_stinger_turn.mp3","rps_select.mp3","rps_drum_roll.mp3","rps_stinger_reveal.mp3","rps_rollover.mp3","rps_hand_thrust.mp3","popup_pvp_RedText_enter.mp3","popup_pvp_RedText_exit.mp3","pvp_rps_timer_count_down.mp3","pvp_rps_timer_throw.mp3"];
|
||||
|
||||
private var _soundNameTie:String = _audio[0];
|
||||
|
||||
private var _soundNameLose:String = _audio[1];
|
||||
|
||||
private var _soundNameWin:String = _audio[2];
|
||||
|
||||
private var _soundNameTurn:String = _audio[3];
|
||||
|
||||
private var _soundNameSelect:String = _audio[4];
|
||||
|
||||
private var _soundNameDrumRoll:String = _audio[5];
|
||||
|
||||
private var _soundNameReveal:String = _audio[6];
|
||||
|
||||
private var _soundNameRollover:String = _audio[6];
|
||||
|
||||
private var _soundNameHandThrust:String = _audio[6];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[9];
|
||||
|
||||
private var _soundNameRedTextExit:String = _audio[10];
|
||||
|
||||
private var _soundNameTimerCountdown:String = _audio[11];
|
||||
|
||||
private var _soundNameTimerThrow:String = _audio[12];
|
||||
|
||||
public function PVP_RockPaperScissor()
|
||||
{
|
||||
super();
|
||||
_iWon = false;
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTie],_soundNameTie,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLose],_soundNameLose,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWin],_soundNameWin,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurn],_soundNameTurn,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSelect],_soundNameSelect,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDrumRoll],_soundNameDrumRoll,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameReveal],_soundNameReveal,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameHandThrust],_soundNameHandThrust,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.14);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextExit],_soundNameRedTextExit,0.13);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCountdown],_soundNameTimerCountdown,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerThrow],_soundNameTimerThrow,0.2);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_RockPaperScissors/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
if(_soundMan)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
}
|
||||
_iWon = true;
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setPlayerInactive();
|
||||
}
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(7);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[3]);
|
||||
_players[1] = parseInt(param1[4]);
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_turnTimer = 5;
|
||||
setGameState(5);
|
||||
}
|
||||
else if(param1[2] == "mark")
|
||||
{
|
||||
_boardSelectDelayTimer = 1.75;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_messageCache[_loc3_] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 7 && _gameState != param1)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_loc2_ = showDlg("rps_waiting",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
hideDlg();
|
||||
break;
|
||||
case 5:
|
||||
_roundCompleteTimer = 3;
|
||||
break;
|
||||
case 6:
|
||||
if(_iWon)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(20);
|
||||
_loc2_ = showDlg("rps_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
addGemsToBalance(5);
|
||||
_loc2_ = showDlg("rps_win",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.gemsEarned,11577,5);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
}
|
||||
_roundCompleteTimer = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_theGame.loader.content.newRound();
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
_theGame.loader.content.thumpSound = false;
|
||||
_theGame.loader.content.clickSound = false;
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_theGame.loader.content.timer_throw)
|
||||
{
|
||||
_theGame.loader.content.timer_throw = false;
|
||||
_soundMan.playByName(_soundNameTimerThrow);
|
||||
}
|
||||
if(_theGame.loader.content.timer_count_down)
|
||||
{
|
||||
_theGame.loader.content.timer_count_down = false;
|
||||
_soundMan.playByName(_soundNameTimerCountdown);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_enter)
|
||||
{
|
||||
_theGame.loader.content.RedText_enter = false;
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_exit)
|
||||
{
|
||||
_theGame.loader.content.RedText_exit = false;
|
||||
_soundMan.playByName(_soundNameRedTextExit);
|
||||
}
|
||||
if(_gameState == 5)
|
||||
{
|
||||
if(_boardSelectDelayTimer > 0)
|
||||
{
|
||||
_loc3_ = _boardSelectDelayTimer;
|
||||
_boardSelectDelayTimer -= _frameTime;
|
||||
if(_loc3_ >= 1 && _boardSelectDelayTimer < 1)
|
||||
{
|
||||
_soundMan.playByName(_soundNameReveal);
|
||||
if(_players[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.setMark(_messageCache[3],_messageCache[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.setMark(_messageCache[4],_messageCache[3]);
|
||||
}
|
||||
}
|
||||
if(_boardSelectDelayTimer <= 0)
|
||||
{
|
||||
if(_messageCache[5] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[6])] == myId)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
_theGame.loader.content.setWin();
|
||||
_iWon = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameLose);
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(7);
|
||||
}
|
||||
else if(_messageCache[6] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[7])] == myId)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
_theGame.loader.content.setWin();
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameLose);
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameTie);
|
||||
_theGame.loader.content.setTie();
|
||||
setGameState(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_turnTimer > 0)
|
||||
{
|
||||
if(_theGame.loader.content.rolloverSound)
|
||||
{
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
if(_theGame.loader.content.thumpSound)
|
||||
{
|
||||
_theGame.loader.content.thumpSound = false;
|
||||
_soundMan.playByName(_soundNameHandThrust);
|
||||
}
|
||||
if(_theGame.loader.content.clickSound)
|
||||
{
|
||||
_theGame.loader.content.clickSound = false;
|
||||
_soundMan.playByName(_soundNameSelect);
|
||||
}
|
||||
_turnTimer -= _frameTime;
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_turnTimer = 0;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
_loc2_[1] = _theGame.loader.content.markedHand;
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,5);
|
||||
}
|
||||
}
|
||||
else if(_gameState == 6)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 7)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 7)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,948 @@
|
||||
package game.pVP_Scooped
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import com.sbi.corelib.math.RandomSeed;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_Scooped extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_STARTED:int = 4;
|
||||
|
||||
public static const GAMESTATE_PRE_GAME_OVER:int = 5;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 6;
|
||||
|
||||
public static const GAMESTATE_WAITINGFORPLAYER:int = 7;
|
||||
|
||||
public static const GAMESTATE_COINTOSS:int = 8;
|
||||
|
||||
public static const GAMESTATE_HOWTOPLAY:int = 9;
|
||||
|
||||
public static const GAMESTATE_PRESTARTED:int = 10;
|
||||
|
||||
private var TIMEOUT_TIME:Number = 15;
|
||||
|
||||
private var _background:Sprite;
|
||||
|
||||
private var _foreground:Sprite;
|
||||
|
||||
private var _layerPopups:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _totalGameTime:Number;
|
||||
|
||||
private var _ui:Object;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _currentDragger:Object;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _playerLeft:Boolean;
|
||||
|
||||
private var _gameState:int;
|
||||
|
||||
private var _serverStarted:Boolean;
|
||||
|
||||
public var _readyLevelDisplayTimer:Number;
|
||||
|
||||
public var _readyLevelDisplay:Object;
|
||||
|
||||
public var _timeOutTimer:Number;
|
||||
|
||||
private var _currentPopup:MovieClip;
|
||||
|
||||
private var _currentConeIndex:Array = [0,0];
|
||||
|
||||
private var _cones:Array = [];
|
||||
|
||||
private var _conesComplete:Array = [0,0];
|
||||
|
||||
private var _queueComplete:Array = [0,0];
|
||||
|
||||
private var _queueFail:Array = [0,0];
|
||||
|
||||
private var _queueNextScoopSound:Array = [0,0];
|
||||
|
||||
private var _queueNewConeSounds:int = 0;
|
||||
|
||||
private var _newConeSoundIndex:int = 0;
|
||||
|
||||
private var _newConeScoopSoundIndex:int = 0;
|
||||
|
||||
private var _currentConeScoopSoundIndex:Array = [0,0];
|
||||
|
||||
private var _iWon:Boolean;
|
||||
|
||||
private var _tie:Boolean;
|
||||
|
||||
private var _roundCompleteTimer:Number;
|
||||
|
||||
private var _theGame:MovieClip;
|
||||
|
||||
private var _iLost:Boolean;
|
||||
|
||||
public var _SFX_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
private var _audio:Array = ["aj_SC_fail.mp3","aj_SC_GetReadyEnter.mp3","aj_SC_GetReadyExit.mp3","aj_SC_IceCream1.mp3","aj_SC_IceCream2.mp3","aj_SC_IceCream3.mp3","aj_SC_IceCream4.mp3","aj_SC_IceCream5.mp3","aj_SC_IceCream6.mp3","aj_SC_popupDelciousExit.mp3","aj_SC_popupDeliciousEnter.mp3","aj_SC_popupYouEnter.mp3","aj_SC_popupYouExit.mp3","aj_SC_pourChipsL.mp3","aj_SC_pourChipsM.mp3","aj_SC_PourLiquidL.mp3","aj_SC_PourLiquidM.mp3","aj_SC_pourSprinklesL.mp3","aj_SC_pourSprinklesM.mp3","aj_SC_splatstinger1.mp3","aj_SC_splatstinger2.mp3","aj_SC_splatstinger3.mp3","aj_SC_splatstinger4.mp3","aj_SC_splatstinger5.mp3","aj_SC_splatstinger6.mp3","aj_SC_topping_select.mp3","micro_game_rollover.mp3","pvp_stinger_draw.mp3","pvp_stinger_fail.mp3","pvp_stinger_win.mp3"];
|
||||
|
||||
private var _soundNameFail:String = _audio[0];
|
||||
|
||||
private var _soundNameGetReadyEnter:String = _audio[1];
|
||||
|
||||
private var _soundNameGetReadyExit:String = _audio[2];
|
||||
|
||||
private var _soundNameIceCream1:String = _audio[3];
|
||||
|
||||
private var _soundNameIceCream2:String = _audio[4];
|
||||
|
||||
private var _soundNameIceCream3:String = _audio[5];
|
||||
|
||||
private var _soundNameIceCream4:String = _audio[6];
|
||||
|
||||
private var _soundNameIceCream5:String = _audio[7];
|
||||
|
||||
private var _soundNameIceCream6:String = _audio[8];
|
||||
|
||||
private var _soundNameDeliciousExit:String = _audio[9];
|
||||
|
||||
private var _soundNameDeliciousEnter:String = _audio[10];
|
||||
|
||||
private var _soundNameYouEnter:String = _audio[11];
|
||||
|
||||
private var _soundNameYouExit:String = _audio[12];
|
||||
|
||||
private var _soundNamePourChipsL:String = _audio[13];
|
||||
|
||||
private var _soundNamePourChipsM:String = _audio[14];
|
||||
|
||||
private var _soundNamePourLiquidL:String = _audio[15];
|
||||
|
||||
private var _soundNamePourLiquidM:String = _audio[16];
|
||||
|
||||
private var _soundNamePourSprinklesL:String = _audio[17];
|
||||
|
||||
private var _soundNamePourSprinklesM:String = _audio[18];
|
||||
|
||||
private var _soundNameSplatStinger1:String = _audio[19];
|
||||
|
||||
private var _soundNameSplatStinger2:String = _audio[20];
|
||||
|
||||
private var _soundNameSplatStinger3:String = _audio[21];
|
||||
|
||||
private var _soundNameSplatStinger4:String = _audio[22];
|
||||
|
||||
private var _soundNameSplatStinger5:String = _audio[23];
|
||||
|
||||
private var _soundNameSplatStinger6:String = _audio[24];
|
||||
|
||||
private var _soundNameToppingSelect:String = _audio[25];
|
||||
|
||||
private var _soundNameRollover:String = _audio[26];
|
||||
|
||||
private var _soundNameStingerDraw:String = _audio[27];
|
||||
|
||||
private var _soundNameStingerFail:String = _audio[28];
|
||||
|
||||
private var _soundNameStingerWin:String = _audio[29];
|
||||
|
||||
public function PVP_Scooped()
|
||||
{
|
||||
super();
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
trace("myID: " + myId);
|
||||
init();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_lastTime = getTimer();
|
||||
if(!_bInit)
|
||||
{
|
||||
_background = new Sprite();
|
||||
_foreground = new Sprite();
|
||||
_layerPopups = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_background);
|
||||
addChild(_foreground);
|
||||
addChild(_layerPopups);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_Scooped/main_room.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFail],_soundNameFail,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGetReadyEnter],_soundNameGetReadyEnter,1.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameGetReadyExit],_soundNameGetReadyExit,1.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream1],_soundNameIceCream1,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream2],_soundNameIceCream2,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream3],_soundNameIceCream3,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream4],_soundNameIceCream4,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream5],_soundNameIceCream5,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameIceCream6],_soundNameIceCream6,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeliciousExit],_soundNameDeliciousExit,0.66);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameDeliciousEnter],_soundNameDeliciousEnter,0.66);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYouEnter],_soundNameYouEnter,0.66);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYouExit],_soundNameYouExit,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourChipsL],_soundNamePourChipsL,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourChipsM],_soundNamePourChipsM,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourLiquidL],_soundNamePourLiquidL,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourLiquidM],_soundNamePourLiquidM,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourSprinklesL],_soundNamePourSprinklesL,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePourSprinklesM],_soundNamePourSprinklesM,0.33);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger1],_soundNameSplatStinger1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger2],_soundNameSplatStinger2,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger3],_soundNameSplatStinger3,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger4],_soundNameSplatStinger4,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger5],_soundNameSplatStinger5,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSplatStinger6],_soundNameSplatStinger6,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameToppingSelect],_soundNameToppingSelect,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerDraw],_soundNameStingerDraw,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerFail],_soundNameStingerFail,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerWin],_soundNameStingerWin,0.45);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
_playerLeft = true;
|
||||
if(_gameState <= 3)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else if(!_iLost)
|
||||
{
|
||||
setGameState(6);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_userNames = [];
|
||||
_dbIDs = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
generateRandomCones(parseInt(param1[_loc3_ + 1]));
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "start")
|
||||
{
|
||||
setGameState(10);
|
||||
}
|
||||
else if(param1[2] == "sc_click")
|
||||
{
|
||||
doNextScoopOrTopping(1,param1[3]);
|
||||
}
|
||||
else if(param1[2] == "sc_done")
|
||||
{
|
||||
_iLost = _pIDs[parseInt(param1[3])] != myId;
|
||||
setGameState(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function generateRandomCones(param1:int) : void
|
||||
{
|
||||
var _loc4_:RandomSeed = new RandomSeed(param1);
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Array = [1,2,3,4,5,6];
|
||||
_cones[_loc5_] = [];
|
||||
_cones[_loc5_][0] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_loc5_++;
|
||||
_cones[_loc5_] = [];
|
||||
_cones[_loc5_][0] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][1] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_loc5_++;
|
||||
_cones[_loc5_] = [];
|
||||
_cones[_loc5_][0] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][1] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][2] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][3] = Math.floor(_loc4_.random() * 3) + 7;
|
||||
_loc5_++;
|
||||
_cones[_loc5_] = [];
|
||||
_loc2_ = shuffle(_loc2_,_loc4_);
|
||||
_cones[_loc5_][0] = _loc2_[0];
|
||||
_cones[_loc5_][1] = _loc2_[1];
|
||||
_cones[_loc5_][2] = _loc2_[2];
|
||||
_cones[_loc5_][3] = _loc2_[3];
|
||||
_loc3_ = Math.floor(_loc4_.random() * 3);
|
||||
_cones[_loc5_][_loc3_] = _cones[_loc5_][_loc3_ + 1];
|
||||
_cones[_loc5_][4] = Math.floor(_loc4_.random() * 3) + 7;
|
||||
_loc5_++;
|
||||
_cones[_loc5_] = [];
|
||||
_cones[_loc5_][0] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][1] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][2] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][3] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_cones[_loc5_][4] = Math.floor(_loc4_.random() * 6) + 1;
|
||||
_loc3_ = Math.floor(_loc4_.random() * 4);
|
||||
_cones[_loc5_][_loc3_] = _cones[_loc5_][_loc3_ + 1];
|
||||
_cones[_loc5_].splice(Math.floor(_loc4_.random() * 4) + 1,0,Math.floor(_loc4_.random() * 3) + 7);
|
||||
_cones[_loc5_][6] = Math.floor(_loc4_.random() * 3) + 7;
|
||||
_loc5_++;
|
||||
}
|
||||
|
||||
private function shuffle(param1:Array, param2:RandomSeed) : Array
|
||||
{
|
||||
var _loc3_:Array = [];
|
||||
while(param1.length > 0)
|
||||
{
|
||||
_loc3_.push(param1.splice(Math.round(param2.random() * (param1.length - 1)),1)[0]);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.portrait1 != null)
|
||||
{
|
||||
_theGame.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
showHowToPlay();
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc3_:* = null;
|
||||
var _loc2_:Array = null;
|
||||
if(_gameState != 6 && _gameState != param1)
|
||||
{
|
||||
if(_readyLevelDisplay && _readyLevelDisplay.loader && _readyLevelDisplay.loader.parent)
|
||||
{
|
||||
_readyLevelDisplay.loader.parent.removeChild(_readyLevelDisplay.loader);
|
||||
_readyLevelDisplay = null;
|
||||
}
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
showWaitingForPlayer();
|
||||
break;
|
||||
case 3:
|
||||
newCone();
|
||||
break;
|
||||
case 4:
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "sc_done";
|
||||
messageServer(_loc2_);
|
||||
break;
|
||||
case 5:
|
||||
_iWon = (_conesComplete[0] >= _cones.length || _playerLeft) && !_iLost;
|
||||
_readyLevelDisplay = GETDEFINITIONBYNAME("Scooped_gameEnd");
|
||||
_layerPopups.addChild(_readyLevelDisplay as DisplayObject);
|
||||
_readyLevelDisplay.x = 450;
|
||||
_readyLevelDisplay.y = 275;
|
||||
if(_iWon)
|
||||
{
|
||||
_readyLevelDisplay.setWin();
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
_soundMan.playByName(_soundNameStingerWin);
|
||||
addGemsToBalance(20);
|
||||
_roundCompleteTimer = 5;
|
||||
}
|
||||
else if(_playerLeft || _iLost && _conesComplete[0] >= _cones.length)
|
||||
{
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
addGemsToBalance(5);
|
||||
_readyLevelDisplay.setLose();
|
||||
_soundMan.playByName(_soundNameStingerFail);
|
||||
_roundCompleteTimer = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_iLost = true;
|
||||
_gameState = 4;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
hideDlg();
|
||||
break;
|
||||
case 8:
|
||||
_timeOutTimer = 10;
|
||||
break;
|
||||
case 9:
|
||||
hideDlg();
|
||||
_soundMan.playByName(_soundNameYouEnter);
|
||||
_soundMan.playByName(_soundNameGetReadyEnter);
|
||||
_theGame.you();
|
||||
_theGame.getReady();
|
||||
_timeOutTimer = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
private function showWaitingForPlayer() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("Scooped_Waiting",[]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function exit() : void
|
||||
{
|
||||
if(_totalGameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",onHowToPlayKeyDown);
|
||||
removeEventListener("enterFrame",Heartbeat);
|
||||
removeLayer(_background);
|
||||
removeLayer(_foreground);
|
||||
removeLayer(_layerPopups);
|
||||
removeLayer(_guiLayer);
|
||||
_background = null;
|
||||
_foreground = null;
|
||||
_layerPopups = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
_bInit = false;
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
stage.quality = "medium";
|
||||
_theGame = _scene.getLayer("scooped").loader.content;
|
||||
_background.addChild(_scene.getLayer("scooped").loader);
|
||||
addEventListener("enterFrame",Heartbeat);
|
||||
_closeBtn = addBtn("CloseButton",847,5,showExitConfirmationDlg);
|
||||
var _loc2_:MovieClip = _theGame;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 6)
|
||||
{
|
||||
_loc2_["flav" + _loc3_].addEventListener("mouseOver",mouseOverHandler,false,0,true);
|
||||
_loc2_["flav" + _loc3_].addEventListener("mouseOut",mouseOutHandler,false,0,true);
|
||||
_loc2_["flav" + _loc3_].addEventListener("mouseUp",mouseClick,false,0,true);
|
||||
_loc3_++;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 3)
|
||||
{
|
||||
_loc2_["top" + _loc3_].addEventListener("mouseOver",mouseOverHandler,false,0,true);
|
||||
_loc2_["top" + _loc3_].addEventListener("mouseOut",mouseOutHandler,false,0,true);
|
||||
_loc2_["top" + _loc3_].addEventListener("mouseUp",mouseClick,false,0,true);
|
||||
_loc3_++;
|
||||
}
|
||||
_playerLeft = false;
|
||||
if(_dbIDs.length > 1)
|
||||
{
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
_totalGameTime = 0;
|
||||
super.sceneLoaded(param1);
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function newCone() : void
|
||||
{
|
||||
_theGame.modelCone(_cones[_conesComplete[0]]);
|
||||
_queueNewConeSounds = -4;
|
||||
_newConeSoundIndex = 0;
|
||||
_newConeScoopSoundIndex = 0;
|
||||
}
|
||||
|
||||
private function fail(param1:int) : void
|
||||
{
|
||||
_theGame.fail(param1 + 1);
|
||||
_currentConeIndex[param1] = 0;
|
||||
_soundMan.playByName(_soundNameFail);
|
||||
}
|
||||
|
||||
private function scoopComplete(param1:int) : void
|
||||
{
|
||||
_conesComplete[param1]++;
|
||||
_theGame["p" + (param1 + 1) + "_score"]["score" + _conesComplete[param1]].gotoAndStop(2);
|
||||
_currentConeIndex[param1] = 0;
|
||||
_theGame.coneComplete(param1 + 1);
|
||||
_soundMan.playByName(_soundNameDeliciousEnter);
|
||||
if(_conesComplete[param1] >= _cones.length)
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
if(_iLost)
|
||||
{
|
||||
setGameState(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 == 0)
|
||||
{
|
||||
newCone();
|
||||
}
|
||||
}
|
||||
|
||||
private function doNextScoopOrTopping(param1:int, param2:String, param3:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:MovieClip = _theGame;
|
||||
var _loc5_:int = int(param2.charAt(param2.length - 1)) + 1;
|
||||
param2.charAt(0) == "f" ? _loc4_.dropNext(param1 + 1,_loc5_) : _loc4_.topping(param1 + 1,_loc5_);
|
||||
if(param3)
|
||||
{
|
||||
playNextScoopSound(param1,param2);
|
||||
}
|
||||
if(_cones[_conesComplete[param1]][_currentConeIndex[param1]++] != _loc5_ + (param2.charAt(0) == "f" ? 0 : 6))
|
||||
{
|
||||
_queueFail[param1] = 0.4;
|
||||
_currentConeScoopSoundIndex[param1] = 0;
|
||||
}
|
||||
else if(_currentConeIndex[param1] == _cones[_conesComplete[param1]].length)
|
||||
{
|
||||
_queueComplete[param1] = 0.4;
|
||||
_currentConeScoopSoundIndex[param1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseClick(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
if(!_queueFail[0] && !_queueComplete[0] && _gameState == 4)
|
||||
{
|
||||
_loc2_ = int(_currentConeIndex[0]);
|
||||
doNextScoopOrTopping(0,param1.currentTarget.name,true);
|
||||
if(_loc2_ != 0 || _queueFail[0] == 0)
|
||||
{
|
||||
_loc3_ = [];
|
||||
_loc3_[0] = "sc_click";
|
||||
_loc3_[1] = param1.currentTarget.name;
|
||||
messageServer(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseOverHandler(param1:MouseEvent) : void
|
||||
{
|
||||
param1.currentTarget.gotoAndStop(2);
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
|
||||
private function mouseOutHandler(param1:MouseEvent) : void
|
||||
{
|
||||
param1.currentTarget.gotoAndStop(1);
|
||||
}
|
||||
|
||||
private function playNewConeSound() : void
|
||||
{
|
||||
switch(_cones[_conesComplete[0]][_newConeSoundIndex++])
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
_soundMan.playByName(this["_soundNameSplatStinger" + ++_newConeScoopSoundIndex]);
|
||||
break;
|
||||
case 7:
|
||||
_soundMan.playByName(_soundNamePourLiquidM);
|
||||
break;
|
||||
case 8:
|
||||
_soundMan.playByName(_soundNamePourChipsM);
|
||||
break;
|
||||
case 9:
|
||||
_soundMan.playByName(_soundNamePourSprinklesM);
|
||||
}
|
||||
trace("sound:play " + _newConeScoopSoundIndex);
|
||||
}
|
||||
|
||||
private function playNextScoopSound(param1:int, param2:String) : void
|
||||
{
|
||||
if(param2.charAt(0) == "f")
|
||||
{
|
||||
_soundMan.playByName(this["_soundNameIceCream" + ++_currentConeScoopSoundIndex[param1]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(param2.charAt(param2.length - 1))
|
||||
{
|
||||
case "0":
|
||||
_soundMan.playByName(_soundNamePourLiquidL);
|
||||
break;
|
||||
case "1":
|
||||
_soundMan.playByName(_soundNamePourChipsL);
|
||||
break;
|
||||
case "2":
|
||||
_soundMan.playByName(_soundNamePourSprinklesL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function Heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc2_:MovieClip = null;
|
||||
11;
|
||||
var _loc3_:Number = (getTimer() - _lastTime) / 1000;
|
||||
_lastTime = getTimer();
|
||||
if(!_serverStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_gameState == 8)
|
||||
{
|
||||
if(_readyLevelDisplay && _readyLevelDisplay.loader.content.finished)
|
||||
{
|
||||
setGameState(4);
|
||||
}
|
||||
}
|
||||
if(_gameState == 9)
|
||||
{
|
||||
_timeOutTimer -= _loc3_;
|
||||
_currentPopup.timer.text = Math.ceil(_timeOutTimer).toString();
|
||||
if(_timeOutTimer <= 0)
|
||||
{
|
||||
sendReady();
|
||||
}
|
||||
}
|
||||
if(_gameState == 10)
|
||||
{
|
||||
if(_timeOutTimer > 0)
|
||||
{
|
||||
_timeOutTimer -= _loc3_;
|
||||
if(_timeOutTimer <= 0)
|
||||
{
|
||||
_soundMan.playByName(_soundNameYouExit);
|
||||
_soundMan.playByName(_soundNameGetReadyExit);
|
||||
_theGame.readyOff();
|
||||
setGameState(4);
|
||||
}
|
||||
}
|
||||
if(_queueNewConeSounds < 0)
|
||||
{
|
||||
_queueNewConeSounds = _queueNewConeSounds + 1;
|
||||
if(_queueNewConeSounds == 0)
|
||||
{
|
||||
_queueNewConeSounds = 2 * _cones[_conesComplete[0]].length;
|
||||
}
|
||||
}
|
||||
if(_queueNewConeSounds > 0)
|
||||
{
|
||||
if(_queueNewConeSounds % 2 == 0)
|
||||
{
|
||||
playNewConeSound();
|
||||
}
|
||||
_queueNewConeSounds = _queueNewConeSounds - 1;
|
||||
}
|
||||
}
|
||||
if(_gameState == 4)
|
||||
{
|
||||
if(_theGame.coneCompleted1.turnOff)
|
||||
{
|
||||
_theGame.coneCompleted1.turnOff = false;
|
||||
_soundMan.playByName(_soundNameDeliciousExit);
|
||||
}
|
||||
if(_theGame.coneCompleted2.turnOff)
|
||||
{
|
||||
_theGame.coneCompleted2.turnOff = false;
|
||||
_soundMan.playByName(_soundNameDeliciousExit);
|
||||
}
|
||||
if(_queueFail[0] > 0)
|
||||
{
|
||||
var _loc6_:* = 0;
|
||||
var _loc7_:* = _queueFail[_loc6_] - _loc3_;
|
||||
_queueFail[_loc6_] = _loc7_;
|
||||
if(_queueFail[0] <= 0)
|
||||
{
|
||||
_queueFail[0] = 0;
|
||||
fail(0);
|
||||
}
|
||||
}
|
||||
if(_queueComplete[0] > 0)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
_loc6_ = _queueComplete[_loc7_] - _loc3_;
|
||||
_queueComplete[_loc7_] = _loc6_;
|
||||
if(_queueComplete[0] <= 0)
|
||||
{
|
||||
_queueComplete[0] = 0;
|
||||
scoopComplete(0);
|
||||
}
|
||||
}
|
||||
if(_queueFail[1] > 0)
|
||||
{
|
||||
_loc6_ = 1;
|
||||
_loc7_ = _queueFail[_loc6_] - _loc3_;
|
||||
_queueFail[_loc6_] = _loc7_;
|
||||
if(_queueFail[1] <= 0)
|
||||
{
|
||||
_queueFail[1] = 0;
|
||||
fail(1);
|
||||
}
|
||||
}
|
||||
if(_queueComplete[1] > 0)
|
||||
{
|
||||
_loc7_ = 1;
|
||||
_loc6_ = _queueComplete[_loc7_] - _loc3_;
|
||||
_queueComplete[_loc7_] = _loc6_;
|
||||
if(_queueComplete[1] <= 0)
|
||||
{
|
||||
_queueComplete[1] = 0;
|
||||
scoopComplete(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 6)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _loc3_;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
else if(_roundCompleteTimer <= 2 && _roundCompleteTimer + _loc3_ > 2)
|
||||
{
|
||||
if(_tie)
|
||||
{
|
||||
_loc2_ = showDlg("Scooped_tie",[]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
else if(_iWon)
|
||||
{
|
||||
_loc2_ = showDlg("Scooped_win",[]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = showDlg("Scooped_win",[]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc2_.gemsEarned,11577,5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_totalGameTime += _loc3_;
|
||||
}
|
||||
|
||||
public function sendReady() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
stage.removeEventListener("keyDown",onHowToPlayKeyDown);
|
||||
hideDlg();
|
||||
_timeOutTimer = 0;
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(3);
|
||||
}
|
||||
|
||||
private function onHowToPlayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
sendReady();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
sendReady();
|
||||
}
|
||||
}
|
||||
|
||||
private function showHowToPlay() : void
|
||||
{
|
||||
_currentPopup = showDlg("Scooped_HowToPlay",[{
|
||||
"name":"doneButton",
|
||||
"f":sendReady
|
||||
},{
|
||||
"name":"x_btn",
|
||||
"f":sendReady
|
||||
}]);
|
||||
_currentPopup.x = 450;
|
||||
_currentPopup.y = 275;
|
||||
stage.addEventListener("keyDown",onHowToPlayKeyDown);
|
||||
setGameState(9);
|
||||
}
|
||||
|
||||
private function showExitConfirmationDlg() : void
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
exit();
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,724 @@
|
||||
package game.pVP_ShellGame
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_ShellGame extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PLAYING:int = 5;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 6;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 7;
|
||||
|
||||
public static const TURN_TIME:int = 6;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _winningShell:int;
|
||||
|
||||
public var _iWon:Boolean;
|
||||
|
||||
public var _iTieCounter:int;
|
||||
|
||||
public var _gameOverTimer:Number;
|
||||
|
||||
public var _roundCompleteTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["pvp_stinger_draw.mp3","shells_timer_countdown.mp3","shells_popup.mp3","shells_player_wins_flash.mp3","shells_coconut_shuffle_short2.mp3","shells_coconut_shuffle_short1.mp3","shells_coconut_shuffle_long.mp3","shells_coconut_select.mp3","shells_coconut_rollover.mp3","shells_coconut_open.mp3","shells_coconut_close.mp3","pvp_stinger_win.mp3","pvp_stinger_fail.mp3","popup_pvp_RedText_exit.mp3","popup_pvp_RedText_enter.mp3"];
|
||||
|
||||
private var _soundNameStingerDraw:String = _audio[0];
|
||||
|
||||
private var _soundNameTimerCountdown:String = _audio[1];
|
||||
|
||||
private var _soundNamePopup:String = _audio[2];
|
||||
|
||||
private var _soundNamePlayerWinsFlash:String = _audio[3];
|
||||
|
||||
private var _soundNameCoconutShuffleShort2:String = _audio[4];
|
||||
|
||||
private var _soundNameCoconutShuffleShort1:String = _audio[5];
|
||||
|
||||
private var _soundNameCoconutShuffleLong:String = _audio[6];
|
||||
|
||||
private var _soundNameSelect:String = _audio[7];
|
||||
|
||||
private var _soundNameRollover:String = _audio[8];
|
||||
|
||||
private var _soundNameOpen:String = _audio[9];
|
||||
|
||||
private var _soundNameClose:String = _audio[10];
|
||||
|
||||
private var _soundNameStingerWin:String = _audio[11];
|
||||
|
||||
private var _soundNameStingerFail:String = _audio[12];
|
||||
|
||||
private var _soundNameRedTextExit:String = _audio[13];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[14];
|
||||
|
||||
public function PVP_ShellGame()
|
||||
{
|
||||
super();
|
||||
_iTieCounter = 0;
|
||||
_iWon = false;
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerDraw],_soundNameStingerDraw,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCountdown],_soundNameTimerCountdown,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePopup],_soundNamePopup,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerWinsFlash],_soundNamePlayerWinsFlash,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCoconutShuffleShort2],_soundNameCoconutShuffleShort2,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCoconutShuffleShort1],_soundNameCoconutShuffleShort1,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCoconutShuffleLong],_soundNameCoconutShuffleLong,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSelect],_soundNameSelect,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameOpen],_soundNameOpen,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameClose],_soundNameClose,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerWin],_soundNameStingerWin,0.3);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameStingerFail],_soundNameStingerFail,0.4);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextExit],_soundNameRedTextExit,0.15);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.15);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_ShellGame/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
if(_iTieCounter < 3)
|
||||
{
|
||||
_iWon = true;
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setPlayerInactive();
|
||||
}
|
||||
}
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(7);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[3]);
|
||||
_players[1] = parseInt(param1[4]);
|
||||
_winningShell = parseInt(param1[5]);
|
||||
_turnTimer = 6;
|
||||
setGameState(5);
|
||||
}
|
||||
else if(param1[2] == "mark")
|
||||
{
|
||||
_boardSelectDelayTimer = 1.75;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_messageCache[_loc3_] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 7 && _gameState != param1)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_loc2_ = showDlg("shells_waiting",[]);
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
break;
|
||||
case 4:
|
||||
hideDlg();
|
||||
_theGame.loader.content.startRound(_winningShell);
|
||||
break;
|
||||
case 5:
|
||||
_roundCompleteTimer = 3;
|
||||
break;
|
||||
case 6:
|
||||
if(_iTieCounter >= 3)
|
||||
{
|
||||
addGemsToBalance(10);
|
||||
}
|
||||
else if(_iWon)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
addGemsToBalance(20);
|
||||
}
|
||||
else
|
||||
{
|
||||
addGemsToBalance(5);
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
}
|
||||
_roundCompleteTimer = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_theGame.loader.content.newRound();
|
||||
_theGame.loader.content.timerReady = false;
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.names(gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName,gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.names(gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName,gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:MovieClip = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_theGame.loader.content.coconut_close)
|
||||
{
|
||||
_theGame.loader.content.coconut_close = false;
|
||||
_soundMan.playByName(_soundNameClose);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_open)
|
||||
{
|
||||
_theGame.loader.content.coconut_open = false;
|
||||
_soundMan.playByName(_soundNameOpen);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_rollover)
|
||||
{
|
||||
_theGame.loader.content.coconut_rollover = false;
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_select)
|
||||
{
|
||||
_theGame.loader.content.coconut_select = false;
|
||||
_soundMan.playByName(_soundNameSelect);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_shuffle_long)
|
||||
{
|
||||
_theGame.loader.content.coconut_shuffle_long = false;
|
||||
_soundMan.playByName(_soundNameCoconutShuffleLong);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_shuffle_short1)
|
||||
{
|
||||
_theGame.loader.content.coconut_shuffle_short1 = false;
|
||||
_soundMan.playByName(_soundNameCoconutShuffleShort1);
|
||||
}
|
||||
if(_theGame.loader.content.coconut_shuffle_short2)
|
||||
{
|
||||
_theGame.loader.content.coconut_shuffle_short2 = false;
|
||||
_soundMan.playByName(_soundNameCoconutShuffleShort2);
|
||||
}
|
||||
if(_theGame.loader.content.player_wins_flash)
|
||||
{
|
||||
_theGame.loader.content.player_wins_flash = false;
|
||||
_soundMan.playByName(_soundNamePlayerWinsFlash);
|
||||
}
|
||||
if(_theGame.loader.content.popup)
|
||||
{
|
||||
_theGame.loader.content.popup = false;
|
||||
_soundMan.playByName(_soundNamePopup);
|
||||
}
|
||||
if(_theGame.loader.content.timer_countdown)
|
||||
{
|
||||
_theGame.loader.content.timer_countdown = false;
|
||||
_soundMan.playByName(_soundNameTimerCountdown);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_enter)
|
||||
{
|
||||
_theGame.loader.content.RedText_enter = false;
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_exit)
|
||||
{
|
||||
_theGame.loader.content.RedText_exit = false;
|
||||
_soundMan.playByName(_soundNameRedTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.stinger_draw)
|
||||
{
|
||||
_theGame.loader.content.stinger_draw = false;
|
||||
_soundMan.playByName(_soundNameStingerDraw);
|
||||
}
|
||||
if(_theGame.loader.content.stinger_fail)
|
||||
{
|
||||
_theGame.loader.content.stinger_fail = false;
|
||||
_soundMan.playByName(_soundNameStingerFail);
|
||||
}
|
||||
if(_theGame.loader.content.stinger_win)
|
||||
{
|
||||
_theGame.loader.content.stinger_win = false;
|
||||
_soundMan.playByName(_soundNameStingerWin);
|
||||
}
|
||||
if(_gameState == 5)
|
||||
{
|
||||
if(_boardSelectDelayTimer > 0)
|
||||
{
|
||||
_loc3_ = _boardSelectDelayTimer;
|
||||
_boardSelectDelayTimer -= _frameTime;
|
||||
if(_loc3_ >= 1 && _boardSelectDelayTimer < 1)
|
||||
{
|
||||
if(_players[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.setMark(_messageCache[3],_messageCache[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.setMark(_messageCache[4],_messageCache[3]);
|
||||
}
|
||||
}
|
||||
if(_boardSelectDelayTimer <= 0)
|
||||
{
|
||||
if(_messageCache[5] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[6])] == myId)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
_iWon = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(7);
|
||||
}
|
||||
else if(_messageCache[6] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[7])] == myId)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
_iTieCounter = _iTieCounter + 1;
|
||||
if(_iTieCounter >= 3)
|
||||
{
|
||||
_theGame.loader.content.setTie();
|
||||
setGameState(7);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_turnTimer > 0)
|
||||
{
|
||||
if(_theGame.loader.content.timerReady)
|
||||
{
|
||||
_turnTimer -= _frameTime;
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_turnTimer = 0;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
_loc2_[1] = _theGame.loader.content.marked;
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,6);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 6)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 7)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
if(_iTieCounter >= 3)
|
||||
{
|
||||
_loc4_ = showDlg("shells_tie",[]);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
}
|
||||
}
|
||||
else if(_iWon)
|
||||
{
|
||||
_loc4_ = showDlg("shells_win",[]);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = showDlg("shells_win",[]);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.x = 450;
|
||||
_loc4_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc4_.gemsEarned,11577,5);
|
||||
}
|
||||
}
|
||||
_gameOverTimer = 3;
|
||||
}
|
||||
}
|
||||
else if(_gameOverTimer > 0)
|
||||
{
|
||||
_gameOverTimer -= _frameTime;
|
||||
if(_gameOverTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 7)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,707 @@
|
||||
package game.pVP_TicTacToe
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PVP_TicTacToe extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
public static const GAMESTATE_LOADING:int = 0;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR1:int = 1;
|
||||
|
||||
public static const GAMESTATE_LOADING_AVATAR2:int = 2;
|
||||
|
||||
public static const GAMESTATE_READY_TO_START:int = 3;
|
||||
|
||||
public static const GAMESTATE_WAITING_FOR_START:int = 4;
|
||||
|
||||
public static const GAMESTATE_PLAYING:int = 5;
|
||||
|
||||
public static const GAMESTATE_ROUND_COMPLETE:int = 6;
|
||||
|
||||
public static const GAMESTATE_GAME_OVER:int = 7;
|
||||
|
||||
public static const TURN_TIME:int = 15;
|
||||
|
||||
public var messageServer:Function;
|
||||
|
||||
public var leaveMinigame:Function;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
public var _userNames:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _playerAvatar1:Avatar;
|
||||
|
||||
private var _playerAvatar2:Avatar;
|
||||
|
||||
private var _playerAvatarView1:AvatarView;
|
||||
|
||||
private var _playerAvatarView2:AvatarView;
|
||||
|
||||
public var _layerMain:Sprite;
|
||||
|
||||
public var _serverStarted:Boolean;
|
||||
|
||||
public var _gameState:int;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
public var _theGame:Object;
|
||||
|
||||
public var _players:Array;
|
||||
|
||||
public var _winState:int;
|
||||
|
||||
public var _roundCompleteTimer:Number;
|
||||
|
||||
public var _gameOverTimer:Number;
|
||||
|
||||
public var _turnTimer:Number;
|
||||
|
||||
public var _myTurn:Boolean;
|
||||
|
||||
public var _boardSelectDelayTimer:Number;
|
||||
|
||||
public var _messageCache:Array;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _audio:Array = ["pvp_stinger_draw.mp3","pvp_stinger_fail.mp3","pvp_stinger_win.mp3","pvp_stinger_turn.mp3","ttt_select.mp3","ttt_rollover.mp3","popup_pvp_RedText_enter.mp3","popup_pvp_RedText_exit.mp3","popup_pvp_YourTurn_enter.mp3","popup_pvp_YourTurn_exit.mp3","pvp_ttt_timer_count_down.mp3","pvp_timeUp_buzzer.mp3"];
|
||||
|
||||
private var _soundNameTie:String = _audio[0];
|
||||
|
||||
private var _soundNameLose:String = _audio[1];
|
||||
|
||||
private var _soundNameWin:String = _audio[2];
|
||||
|
||||
private var _soundNameTurn:String = _audio[3];
|
||||
|
||||
private var _soundNameSelect:String = _audio[4];
|
||||
|
||||
private var _soundNameRollover:String = _audio[5];
|
||||
|
||||
private var _soundNameRedTextEnter:String = _audio[6];
|
||||
|
||||
private var _soundNameRedTextExit:String = _audio[7];
|
||||
|
||||
private var _soundNameYourTurnEnter:String = _audio[8];
|
||||
|
||||
private var _soundNameYourTurnExit:String = _audio[9];
|
||||
|
||||
private var _soundNameTimerCount:String = _audio[10];
|
||||
|
||||
private var _soundNameTimerDone:String = _audio[11];
|
||||
|
||||
public function PVP_TicTacToe()
|
||||
{
|
||||
super();
|
||||
_serverStarted = false;
|
||||
_gameState = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTie],_soundNameTie,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameLose],_soundNameLose,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWin],_soundNameWin,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTurn],_soundNameTurn,0.6);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameSelect],_soundNameSelect,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRollover],_soundNameRollover,0.35);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextEnter],_soundNameRedTextEnter,0.14);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameRedTextExit],_soundNameRedTextExit,0.13);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYourTurnEnter],_soundNameYourTurnEnter,0.17);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameYourTurnExit],_soundNameYourTurnExit,0.17);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerCount],_soundNameTimerCount,0.2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameTimerDone],_soundNameTimerDone,1);
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
messageServer = param3;
|
||||
leaveMinigame = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
if(_gameTime > 5 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(86,1);
|
||||
}
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "quit";
|
||||
messageServer(_loc2_);
|
||||
releaseBase();
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerMain);
|
||||
removeLayer(_guiLayer);
|
||||
_layerMain = null;
|
||||
_guiLayer = null;
|
||||
if(leaveMinigame != null)
|
||||
{
|
||||
leaveMinigame(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_winState = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerMain = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerMain);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PVP_TicTacToe/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
if(_sceneLoaded && MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
_theGame = _scene.getLayer("theGame");
|
||||
_closeBtn = addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_layerMain.addChild(_theGame.loader);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
super.sceneLoaded(param1);
|
||||
startGame();
|
||||
_theGame.loader.content.player1Name.text = "";
|
||||
_theGame.loader.content.player2Name.text = "";
|
||||
if(MainFrame.isInitialized())
|
||||
{
|
||||
setGameState(1);
|
||||
}
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "ml")
|
||||
{
|
||||
if(_soundMan)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
}
|
||||
_winState = 1;
|
||||
if(_theGame && _theGame.loader.content)
|
||||
{
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setWin();
|
||||
_theGame.loader.content.setPlayerInactive();
|
||||
}
|
||||
if(_gameState <= 4)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGameState(7);
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "ms")
|
||||
{
|
||||
_serverStarted = true;
|
||||
_dbIDs = [];
|
||||
_userNames = [];
|
||||
_loc2_ = 1;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc3_] = param1[_loc2_++];
|
||||
_userNames[_loc3_] = param1[_loc2_++];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
if(param1[2] == "round")
|
||||
{
|
||||
_players = new Array(2);
|
||||
_players[0] = parseInt(param1[4]);
|
||||
_players[1] = parseInt(param1[5]);
|
||||
_myTurn = _players[parseInt(param1[3])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
setGameState(5);
|
||||
}
|
||||
else if(param1[2] == "mark")
|
||||
{
|
||||
_soundMan.playByName(_soundNameSelect);
|
||||
_theGame.loader.content.setMark(parseInt(param1[3]) == 0,parseInt(param1[4]),parseInt(param1[5]));
|
||||
_boardSelectDelayTimer = 0.5;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_messageCache[_loc3_] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
else if(param1[2] == "invalid")
|
||||
{
|
||||
_myTurn = _players[parseInt(param1[3])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function avatarAdCallback(param1:String = null) : void
|
||||
{
|
||||
var _loc2_:Point = null;
|
||||
switch(_gameState - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatarView1.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView1.avTypeId);
|
||||
_playerAvatarView1.x = _loc2_.x;
|
||||
_playerAvatarView1.y = _loc2_.y;
|
||||
setGameState(2);
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatarView2.playAnim(15,false,1,null);
|
||||
_loc2_ = AvatarUtility.getAvatarHudPosition(_playerAvatarView2.avTypeId);
|
||||
_playerAvatarView2.x = _loc2_.x;
|
||||
_playerAvatarView2.y = _loc2_.y;
|
||||
if(_theGame.loader.content.portrait1 != null)
|
||||
{
|
||||
_theGame.loader.content.portrait1.portraitContainer.addChild(_playerAvatarView1);
|
||||
_theGame.loader.content.portrait2.portraitContainer.addChild(_playerAvatarView2);
|
||||
}
|
||||
setGameState(3);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGameState(param1:int) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
if(_gameState != 7 && _gameState != param1)
|
||||
{
|
||||
_gameState = param1;
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
_playerAvatar1 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar1.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView1 = new AvatarView();
|
||||
_playerAvatarView1.init(_playerAvatar1);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_playerAvatar2 = new Avatar();
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[1],"pvp" + _dbIDs[1],1,[0,0,0],-1,null,_userNames[1]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[1],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerAvatar2.init(_dbIDs[0],"pvp" + _dbIDs[0],1,[0,0,0],-1,null,_userNames[0]);
|
||||
_playerAvatarView2 = new AvatarView();
|
||||
_playerAvatarView2.init(_playerAvatar2);
|
||||
AvatarXtCommManager.requestADForAvatar(_dbIDs[0],true,avatarAdCallback,_playerAvatar2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
_loc2_ = showDlg("ttt_waiting",[]);
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.x = 450;
|
||||
_loc2_.y = 275;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
hideDlg();
|
||||
break;
|
||||
case 5:
|
||||
_roundCompleteTimer = 3;
|
||||
break;
|
||||
case 6:
|
||||
if(_winState == 1)
|
||||
{
|
||||
addGemsToBalance(20);
|
||||
}
|
||||
else if(_winState == 2)
|
||||
{
|
||||
addGemsToBalance(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
addGemsToBalance(5);
|
||||
MinigameManager._pvpPromptReplay = true;
|
||||
}
|
||||
_roundCompleteTimer = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:* = null;
|
||||
resetGame();
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
if(!_theGame)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function startRound() : void
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
_theGame.loader.content.newRound();
|
||||
_boardSelectDelayTimer = 0;
|
||||
_messageCache = [];
|
||||
_loc1_ = [];
|
||||
_loc1_[0] = "ready";
|
||||
messageServer(_loc1_);
|
||||
setGameState(4);
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
if(_pIDs[0] == myId)
|
||||
{
|
||||
_theGame.loader.content.playerX = true;
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.playerX = false;
|
||||
_theGame.loader.content.player1Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[1],_dbIDs[1]).avName;
|
||||
_theGame.loader.content.player2Name.text = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_userNames[0],_dbIDs[0]).avName;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:MovieClip = null;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
if(_serverStarted)
|
||||
{
|
||||
if(_gameState == 3)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
_gameTime += _frameTime;
|
||||
if(_theGame.loader.content.timer_count_down)
|
||||
{
|
||||
_theGame.loader.content.timer_count_down = false;
|
||||
_soundMan.playByName(_soundNameTimerCount);
|
||||
}
|
||||
if(_theGame.loader.content.timer_timeUp)
|
||||
{
|
||||
_theGame.loader.content.timer_timeUp = false;
|
||||
_soundMan.playByName(_soundNameTimerDone);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_enter)
|
||||
{
|
||||
_theGame.loader.content.RedText_enter = false;
|
||||
_soundMan.playByName(_soundNameRedTextEnter);
|
||||
}
|
||||
if(_theGame.loader.content.RedText_exit)
|
||||
{
|
||||
_theGame.loader.content.RedText_exit = false;
|
||||
_soundMan.playByName(_soundNameRedTextExit);
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_enter)
|
||||
{
|
||||
_theGame.loader.content.YourTurn_enter = false;
|
||||
_soundMan.playByName(_soundNameYourTurnEnter);
|
||||
}
|
||||
if(_theGame.loader.content.YourTurn_exit)
|
||||
{
|
||||
_theGame.loader.content.YourTurn_exit = false;
|
||||
_soundMan.playByName(_soundNameYourTurnExit);
|
||||
}
|
||||
if(_gameState == 5)
|
||||
{
|
||||
if(_theGame.loader.content.rolloverSound)
|
||||
{
|
||||
_theGame.loader.content.rolloverSound = false;
|
||||
_soundMan.playByName(_soundNameRollover);
|
||||
}
|
||||
if(_theGame.loader.content.marked)
|
||||
{
|
||||
_myTurn = false;
|
||||
_turnTimer = 0;
|
||||
_theGame.loader.content.marked = false;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "mark";
|
||||
_loc2_[1] = String(int(_theGame.loader.content.markedX));
|
||||
_loc2_[2] = String(int(_theGame.loader.content.markedY));
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
else if(_boardSelectDelayTimer > 0)
|
||||
{
|
||||
_boardSelectDelayTimer -= _frameTime;
|
||||
if(_boardSelectDelayTimer <= 0)
|
||||
{
|
||||
if(_messageCache[6] == "1")
|
||||
{
|
||||
if(_players[parseInt(_messageCache[3])] == myId)
|
||||
{
|
||||
_soundMan.playByName(_soundNameWin);
|
||||
_winState = 1;
|
||||
_theGame.loader.content.setWin();
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameLose);
|
||||
_theGame.loader.content.setLose();
|
||||
}
|
||||
setGameState(7);
|
||||
}
|
||||
else if(_messageCache[7] == "1")
|
||||
{
|
||||
_winState = 2;
|
||||
_theGame.loader.content.setTie();
|
||||
_soundMan.playByName(_soundNameTie);
|
||||
setGameState(7);
|
||||
}
|
||||
else
|
||||
{
|
||||
_myTurn = _players[parseInt(_messageCache[8])] == myId;
|
||||
if(_myTurn)
|
||||
{
|
||||
_soundMan.playByName(_soundNameTurn);
|
||||
_theGame.loader.content.setPlayerActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame.loader.content.opponentsTurn();
|
||||
}
|
||||
_turnTimer = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_turnTimer > 0)
|
||||
{
|
||||
_turnTimer -= _frameTime;
|
||||
if(_turnTimer <= 0)
|
||||
{
|
||||
_turnTimer = 0;
|
||||
if(_myTurn)
|
||||
{
|
||||
_myTurn = false;
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "time";
|
||||
messageServer(_loc2_);
|
||||
}
|
||||
}
|
||||
_theGame.loader.content.time(_turnTimer,15);
|
||||
}
|
||||
}
|
||||
else if(_gameState == 6)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameState == 7)
|
||||
{
|
||||
if(_roundCompleteTimer > 0)
|
||||
{
|
||||
_roundCompleteTimer -= _frameTime;
|
||||
if(_roundCompleteTimer <= 0)
|
||||
{
|
||||
_gameOverTimer = 3;
|
||||
if(_winState == 1)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
_loc3_ = showDlg("ttt_win",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
}
|
||||
}
|
||||
else if(_winState == 2)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(87,1);
|
||||
}
|
||||
_loc3_ = showDlg("ttt_tie",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = showDlg("ttt_win",[]);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = 450;
|
||||
_loc3_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc3_.gemsEarned,11577,5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_gameOverTimer > 0)
|
||||
{
|
||||
_gameOverTimer -= _frameTime;
|
||||
if(_gameOverTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(_gameState != 7)
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.pauseGame();
|
||||
}
|
||||
_loc1_ = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
else
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
if(_theGame)
|
||||
{
|
||||
_theGame.loader.content.unPauseGame();
|
||||
}
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function onExitButton() : void
|
||||
{
|
||||
hideDlg();
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package game.pachinko
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Collision.b2ContactPoint;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2ContactListener;
|
||||
|
||||
public class ContactListener extends b2ContactListener
|
||||
{
|
||||
|
||||
public var contactStack:Array = [];
|
||||
|
||||
public function ContactListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function Add(param1:b2ContactPoint) : void
|
||||
{
|
||||
var _loc2_:b2Shape = param1.shape1;
|
||||
var _loc3_:b2Shape = param1.shape2;
|
||||
var _loc4_:Number = param1.separation;
|
||||
var _loc5_:b2Vec2 = param1.position.Copy();
|
||||
contactStack.push(new CustomContactPoint(_loc2_,_loc3_,_loc4_,_loc5_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package game.pachinko
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class CustomContactPoint
|
||||
{
|
||||
|
||||
public var shape1:b2Shape;
|
||||
|
||||
public var shape2:b2Shape;
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var position:b2Vec2;
|
||||
|
||||
public function CustomContactPoint(param1:b2Shape, param2:b2Shape, param3:Number, param4:b2Vec2)
|
||||
{
|
||||
super();
|
||||
shape1 = param1;
|
||||
shape2 = param2;
|
||||
separation = param3;
|
||||
position = param4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,999 @@
|
||||
package game.pachinko
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2CircleDef;
|
||||
import Box2D.Collision.Shapes.b2MassData;
|
||||
import Box2D.Collision.Shapes.b2PolygonDef;
|
||||
import Box2D.Collision.b2AABB;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2BodyDef;
|
||||
import Box2D.Dynamics.b2DebugDraw;
|
||||
import Box2D.Dynamics.b2World;
|
||||
import achievement.AchievementManager;
|
||||
import achievement.AchievementXtCommManager;
|
||||
import com.sbi.corelib.audio.SBMusic;
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class Pachinko extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const MAX_BALLS:int = 10;
|
||||
|
||||
private static const MAX_JACKPOT_ICONS:int = 3;
|
||||
|
||||
private static const JACKPOT_GEM_AWARD:int = 75;
|
||||
|
||||
private static const JACKPOT_POPUP_TIMER:int = 36;
|
||||
|
||||
private static const SHOW_DEBUG:Boolean = false;
|
||||
|
||||
private static const SPRING_FORCE_BASE:int = 180;
|
||||
|
||||
private static const SPRING_FORCE_MULTIPLYER:Number = 3.7;
|
||||
|
||||
private static const SPRING_FORCE_RANDOM_VARIANCE:Number = 10;
|
||||
|
||||
private static const POPUP_X:int = 450;
|
||||
|
||||
private static const POPUP_Y:int = 275;
|
||||
|
||||
private var _world:b2World;
|
||||
|
||||
private var _iterations:int = 10;
|
||||
|
||||
private var _timeStep:Number = 0.041666666666666664;
|
||||
|
||||
private var _phyScale:Number = 0.03333333333333333;
|
||||
|
||||
private var _contactListener:ContactListener;
|
||||
|
||||
private var _phyWidth:int = 900;
|
||||
|
||||
private var _phyHeight:int = 700;
|
||||
|
||||
private var _background:Sprite;
|
||||
|
||||
private var _playfield:Sprite;
|
||||
|
||||
private var _foreground:Sprite;
|
||||
|
||||
private var _ballIcon:Array;
|
||||
|
||||
private var _jackpotIcons:Array;
|
||||
|
||||
private var _scoreCtrl:Object;
|
||||
|
||||
private var _jackpot:Array;
|
||||
|
||||
private var _gems:Array;
|
||||
|
||||
private var _springMode:int;
|
||||
|
||||
private var _spring:Object;
|
||||
|
||||
private var _springTop:Object;
|
||||
|
||||
private var _springOffset:Number;
|
||||
|
||||
private var _ballBody:b2Body;
|
||||
|
||||
private var _volumeBlockEntry:b2Body;
|
||||
|
||||
private var _ballPos:b2Vec2;
|
||||
|
||||
private var _offset:Point;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _totalGameTime:Number;
|
||||
|
||||
private var _displayAchievementTimer:Number;
|
||||
|
||||
private var _jackpotCount:int;
|
||||
|
||||
private var _inputEnabled:Boolean;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
private var _leaveCallback:Function;
|
||||
|
||||
private var _audio:Array = ["impact_peg.mp3","aj_gem_new.mp3","jackpot_1.mp3","jackpot_2.mp3","jackpot_3.mp3","pachinko_spring_pull.mp3"];
|
||||
|
||||
private var _soundNamePin:String = _audio[0];
|
||||
|
||||
private var _soundNamePoints:String = _audio[1];
|
||||
|
||||
private var _soundNameJackpot1:String = _audio[2];
|
||||
|
||||
private var _soundNameJackpot2:String = _audio[3];
|
||||
|
||||
private var _soundNameJackpot3:String = _audio[4];
|
||||
|
||||
private var _soundNamePullSpring:String = _audio[5];
|
||||
|
||||
private var _bBallInMotion:Boolean;
|
||||
|
||||
private var _score:int;
|
||||
|
||||
private var _balls:int;
|
||||
|
||||
private var _clearJackpot:Boolean;
|
||||
|
||||
private var _springStart:int;
|
||||
|
||||
private var _springForce:int;
|
||||
|
||||
private var _jackpotPopup:MovieClip;
|
||||
|
||||
private var _jackpotCountdown:int;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
private var _bLevelComplete:Boolean;
|
||||
|
||||
public var _SFX_Music:SBMusic;
|
||||
|
||||
public var _musicLoop:SoundChannel;
|
||||
|
||||
public function Pachinko()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array, param3:Function, param4:Function) : void
|
||||
{
|
||||
_leaveCallback = param4;
|
||||
init();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
_lastTime = getTimer();
|
||||
_displayAchievementTimer = 0;
|
||||
_jackpotCount = 0;
|
||||
if(!_bInit)
|
||||
{
|
||||
_background = new Sprite();
|
||||
_playfield = new Sprite();
|
||||
_foreground = new Sprite();
|
||||
_guiLayer = new Sprite();
|
||||
_jackpot = [];
|
||||
_gems = [];
|
||||
_ballIcon = [];
|
||||
_jackpotIcons = [];
|
||||
addChild(_background);
|
||||
addChild(_playfield);
|
||||
addChild(_foreground);
|
||||
addChild(_guiLayer);
|
||||
loadScene("PachinkoAssets/game_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_SFX_Music = _soundMan.addStream("AJ_mus_gem_ball",1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePin],_soundNamePin,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePoints],_soundNamePoints,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameJackpot1],_soundNameJackpot1,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameJackpot2],_soundNameJackpot2,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameJackpot3],_soundNameJackpot3,1);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePullSpring],_soundNamePullSpring,1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
private function exit() : void
|
||||
{
|
||||
if(_totalGameTime > 15 && MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
}
|
||||
releaseBase();
|
||||
if(_musicLoop)
|
||||
{
|
||||
_musicLoop.stop();
|
||||
_musicLoop = null;
|
||||
}
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
removeEventListener("enterFrame",Update);
|
||||
disableInput();
|
||||
_world = null;
|
||||
removeLayer(_background);
|
||||
removeLayer(_playfield);
|
||||
removeLayer(_foreground);
|
||||
removeLayer(_guiLayer);
|
||||
_background = null;
|
||||
_playfield = null;
|
||||
_foreground = null;
|
||||
_guiLayer = null;
|
||||
_gems = null;
|
||||
if(_leaveCallback != null)
|
||||
{
|
||||
_leaveCallback();
|
||||
}
|
||||
_bInit = false;
|
||||
}
|
||||
|
||||
override protected function showDlg(param1:String, param2:Array, param3:int = 0, param4:int = 0, param5:Boolean = true, param6:Boolean = false) : MovieClip
|
||||
{
|
||||
disableInput();
|
||||
return super.showDlg(param1,param2,0,0,param5);
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc11_:Object = null;
|
||||
var _loc22_:* = null;
|
||||
var _loc3_:b2Body = null;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc9_:b2Body = null;
|
||||
var _loc4_:b2BodyDef = null;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc23_:Array = _scene.getActorList("ActorCollisionPoint");
|
||||
var _loc15_:Array = _scene.getActorList("ActorSpawn");
|
||||
var _loc7_:Array = _scene.getActorList("ActorVolume");
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_musicLoop = _soundMan.playStream(_SFX_Music,0,999999);
|
||||
_offset = _scene.getOffset(stage);
|
||||
_offset.x = int(_offset.x);
|
||||
_offset.y = int(_offset.y);
|
||||
var _loc12_:b2AABB = new b2AABB();
|
||||
_loc12_.lowerBound.Set(-1000,-1000);
|
||||
_loc12_.upperBound.Set(1000,1000);
|
||||
var _loc16_:b2Vec2 = new b2Vec2(0,30);
|
||||
var _loc13_:Boolean = true;
|
||||
_world = new b2World(_loc12_,_loc16_,_loc13_);
|
||||
var _loc2_:b2PolygonDef = new b2PolygonDef();
|
||||
var _loc17_:b2BodyDef = new b2BodyDef();
|
||||
var _loc5_:b2Vec2 = new b2Vec2();
|
||||
var _loc6_:b2MassData = new b2MassData();
|
||||
for each(_loc11_ in _loc23_)
|
||||
{
|
||||
_loc10_ = Math.sqrt((_loc11_.x - _loc11_.x1) * (_loc11_.x - _loc11_.x1) + (_loc11_.y - _loc11_.y1) * (_loc11_.y - _loc11_.y1)) / 2;
|
||||
_loc5_.x = (_loc11_.x + _loc11_.x1) / 2 - _offset.x;
|
||||
_loc5_.y = (_loc11_.y + _loc11_.y1) / 2 - _offset.y;
|
||||
_loc20_ = Math.atan2(_loc11_.y - _loc11_.y1,_loc11_.x - _loc11_.x1);
|
||||
_loc17_.position.Set(_loc5_.x * _phyScale,_loc5_.y * _phyScale);
|
||||
_loc2_.SetAsOrientedBox(_loc10_ * _phyScale,1 * _phyScale,new b2Vec2(0,0),_loc20_);
|
||||
_loc3_ = _world.CreateBody(_loc17_);
|
||||
_loc3_.CreateShape(_loc2_);
|
||||
_loc3_.SetMassFromShapes();
|
||||
}
|
||||
for each(_loc11_ in _loc7_)
|
||||
{
|
||||
_loc17_.position.Set(0,0);
|
||||
_loc17_.userData = _loc11_;
|
||||
_loc2_.vertices = [];
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc11_.points.length - 1)
|
||||
{
|
||||
_loc18_ = (_loc11_.points[_loc8_].x - _offset.x) * _phyScale;
|
||||
_loc21_ = (_loc11_.points[_loc8_].y - _offset.y) * _phyScale;
|
||||
_loc2_.vertices.push(new b2Vec2(_loc18_,_loc21_));
|
||||
_loc8_++;
|
||||
}
|
||||
if(_loc11_.name == "score")
|
||||
{
|
||||
_loc2_.isSensor = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.isSensor = false;
|
||||
}
|
||||
_loc2_.vertexCount = _loc2_.vertices.length;
|
||||
_loc3_ = _world.CreateBody(_loc17_);
|
||||
_loc3_.CreateShape(_loc2_);
|
||||
_loc3_.SetMassFromShapes();
|
||||
if(_loc11_.name == "block_entry")
|
||||
{
|
||||
_volumeBlockEntry = _loc3_;
|
||||
}
|
||||
}
|
||||
var _loc24_:b2CircleDef = new b2CircleDef();
|
||||
var _loc19_:Array = _scene.getActorList("ActorLayer");
|
||||
for each(_loc11_ in _loc19_)
|
||||
{
|
||||
var _loc26_:* = _loc11_.name;
|
||||
if("col" === _loc26_)
|
||||
{
|
||||
_loc14_ = Math.sqrt(_loc11_.width * _loc11_.width + _loc11_.height * _loc11_.height) * 0.5;
|
||||
_loc14_ = _loc14_ * 0.7;
|
||||
_loc24_.radius = _loc14_ * _phyScale;
|
||||
_loc4_ = new b2BodyDef();
|
||||
_loc4_.position.x = (_loc11_.x - _offset.x + _loc11_.width * 0.5) * _phyScale;
|
||||
_loc4_.position.y = (_loc11_.y - _offset.y + _loc11_.height * 0.5) * _phyScale;
|
||||
_loc4_.userData = _loc11_;
|
||||
_loc24_.isSensor = false;
|
||||
_loc9_ = _world.CreateBody(_loc4_);
|
||||
_loc9_.CreateShape(_loc24_);
|
||||
_loc9_.SetMassFromShapes();
|
||||
}
|
||||
}
|
||||
for each(_loc11_ in _loc15_)
|
||||
{
|
||||
_loc24_.radius = _loc11_.r * _phyScale;
|
||||
_loc4_ = new b2BodyDef();
|
||||
_loc4_.position.x = (_loc11_.x - _offset.x) * _phyScale;
|
||||
_loc4_.position.y = (_loc11_.y - _offset.y) * _phyScale;
|
||||
_loc4_.userData = _loc11_;
|
||||
_loc24_.isSensor = true;
|
||||
_loc9_ = _world.CreateBody(_loc4_);
|
||||
_loc9_.CreateShape(_loc24_);
|
||||
_loc9_.SetMassFromShapes();
|
||||
}
|
||||
_contactListener = new ContactListener();
|
||||
_world.SetContactListener(_contactListener);
|
||||
addEventListener("enterFrame",Update);
|
||||
stage.addEventListener("keyDown",onKeyDown);
|
||||
stage.addEventListener("keyUp",onKeyUp);
|
||||
stage.addEventListener("mouseUp",onMouseUp);
|
||||
stage.addEventListener("mouseDown",onMouseDown);
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc19_.length)
|
||||
{
|
||||
_loc11_ = _loc19_[_loc8_];
|
||||
_loc11_.s.x = _loc11_.s.x - _offset.x;
|
||||
_loc11_.s.y -= _offset.y;
|
||||
if(_loc11_.name != "ball_default" && _loc11_.name != "score_gem")
|
||||
{
|
||||
var _loc25_:* = _loc11_.layer;
|
||||
if(2 !== _loc25_)
|
||||
{
|
||||
_background.addChild(_loc11_.s);
|
||||
}
|
||||
else
|
||||
{
|
||||
_foreground.addChild(_loc11_.s);
|
||||
}
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < 10)
|
||||
{
|
||||
_ballIcon[_loc8_] = _scene.getLayer("ball_" + (_loc8_ + 1));
|
||||
_loc8_++;
|
||||
}
|
||||
_jackpotIcons[0] = _scene.getLayer("butterfly_1x");
|
||||
_jackpotIcons[1] = _scene.getLayer("butterfly_2x");
|
||||
_jackpotIcons[2] = _scene.getLayer("butterfly_3x");
|
||||
_scoreCtrl = _scene.getLayer("scorectrl");
|
||||
_spring = _scene.getLayer("spring");
|
||||
_springTop = _scene.getLayer("spring_top");
|
||||
_loc11_ = _scene.getLayer("closeButton");
|
||||
_closeBtn = addBtn("CloseButton",_loc11_.x,_loc11_.y,showExitConfirmationDlg);
|
||||
_springOffset = 0;
|
||||
createBall();
|
||||
startLevel();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
private function createBall() : void
|
||||
{
|
||||
var _loc3_:b2Body = null;
|
||||
var _loc1_:b2BodyDef = null;
|
||||
var _loc5_:Object = _scene.cloneAsset("ball_default");
|
||||
_loc5_.name = "ball";
|
||||
var _loc2_:Loader = _loc5_.loader;
|
||||
var _loc4_:b2CircleDef = new b2CircleDef();
|
||||
_ballPos = new b2Vec2(_loc2_.x + _loc5_.width / 2,_loc2_.y + _loc5_.height / 2);
|
||||
_ballPos.x *= _phyScale;
|
||||
_ballPos.y *= _phyScale;
|
||||
_loc1_ = new b2BodyDef();
|
||||
_loc1_.position.x = _ballPos.x;
|
||||
_loc1_.position.y = _ballPos.y;
|
||||
_loc4_.radius = _loc5_.height * 0.5 * _phyScale;
|
||||
_loc4_.density = 1;
|
||||
_loc4_.friction = 0.01;
|
||||
_loc4_.restitution = 0.5;
|
||||
_loc1_.userData = _loc5_;
|
||||
_loc3_ = _world.CreateBody(_loc1_);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.CreateShape(_loc4_);
|
||||
_loc3_.SetMassFromShapes();
|
||||
_playfield.addChild(_loc1_.userData.loader);
|
||||
}
|
||||
_ballBody = _loc3_;
|
||||
}
|
||||
|
||||
private function Update(param1:Event) : void
|
||||
{
|
||||
var _loc13_:Object = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc2_:b2Body = null;
|
||||
var _loc10_:Loader = null;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc12_:Matrix = null;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc3_:CustomContactPoint = null;
|
||||
var _loc4_:* = undefined;
|
||||
var _loc5_:* = undefined;
|
||||
var _loc14_:Boolean = false;
|
||||
var _loc9_:int = 0;
|
||||
var _loc8_:Number = (getTimer() - _lastTime) / 1000;
|
||||
_totalGameTime += _loc8_;
|
||||
if(_displayAchievementTimer > 0)
|
||||
{
|
||||
_displayAchievementTimer -= _loc8_;
|
||||
if(_displayAchievementTimer <= 0)
|
||||
{
|
||||
_displayAchievementTimer = 0;
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
AchievementManager.displayNewAchievements();
|
||||
if(_pauseGame)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!_inputEnabled)
|
||||
{
|
||||
enableInput();
|
||||
}
|
||||
if(_springMode >= 0)
|
||||
{
|
||||
_loc6_ = _springOffset;
|
||||
if(_loc6_ < 0)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
}
|
||||
_spring.loader.y = _spring.y + _loc6_;
|
||||
_springTop.loader.y = _springTop.y + _loc6_;
|
||||
if(_springMode < 4)
|
||||
{
|
||||
_ballBody.SetXForm(new b2Vec2(_ballPos.x,_ballPos.y + _springOffset * _phyScale),0);
|
||||
_ballBody.SetLinearVelocity(new b2Vec2());
|
||||
}
|
||||
switch(_springMode - 1)
|
||||
{
|
||||
case 0:
|
||||
if(_springOffset < 100)
|
||||
{
|
||||
_springOffset += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_springOffset = 100;
|
||||
_springMode = 2;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
enableEntryBlock(false);
|
||||
_springForce = _springOffset;
|
||||
_springMode = 3;
|
||||
break;
|
||||
case 2:
|
||||
if(_springOffset > 0)
|
||||
{
|
||||
_springOffset -= 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
launchBall();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
_springMode = -1;
|
||||
_springStart = 0;
|
||||
}
|
||||
}
|
||||
_world.Step(_timeStep,_iterations);
|
||||
_loc2_ = _world.m_bodyList;
|
||||
while(_loc2_)
|
||||
{
|
||||
if(_loc2_.m_userData is Object)
|
||||
{
|
||||
_loc13_ = _loc2_.m_userData;
|
||||
if(_loc13_.hasOwnProperty("loader"))
|
||||
{
|
||||
_loc10_ = _loc13_.loader;
|
||||
_loc11_ = _loc2_.GetAngle();
|
||||
_loc12_ = _loc10_.transform.matrix;
|
||||
_loc15_ = _loc2_.GetPosition().x / _phyScale;
|
||||
_loc16_ = _loc2_.GetPosition().y / _phyScale;
|
||||
_loc10_.x = _loc15_ - _loc13_.width * 0.5;
|
||||
_loc10_.y = _loc16_ - _loc13_.height * 0.5;
|
||||
}
|
||||
}
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
var _loc7_:Boolean = _bBallInMotion;
|
||||
while(_contactListener.contactStack.length)
|
||||
{
|
||||
_loc3_ = _contactListener.contactStack.pop();
|
||||
_loc4_ = _loc3_.shape1.GetBody().GetUserData();
|
||||
_loc5_ = _loc3_.shape2.GetBody().GetUserData();
|
||||
if(_loc4_ != null && _loc4_.hasOwnProperty("name") && _loc4_.name == "ball")
|
||||
{
|
||||
processCollision(_loc5_);
|
||||
}
|
||||
else if(_loc5_ != null && _loc5_.hasOwnProperty("name") && _loc5_.name == "ball")
|
||||
{
|
||||
processCollision(_loc4_);
|
||||
}
|
||||
}
|
||||
if(_loc7_ != _bBallInMotion)
|
||||
{
|
||||
if(_balls == 0)
|
||||
{
|
||||
_ballBody.m_userData.loader.visible = false;
|
||||
_bLevelComplete = true;
|
||||
_springMode = 0;
|
||||
_balls = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_balls = _balls - 1;
|
||||
refreshBallIcons();
|
||||
_springMode = 0;
|
||||
}
|
||||
}
|
||||
if(_jackpotPopup)
|
||||
{
|
||||
JackpotDlg_Heartbeat();
|
||||
}
|
||||
for each(_loc13_ in _gems)
|
||||
{
|
||||
_loc14_ = false;
|
||||
if(_loc13_.loader.content)
|
||||
{
|
||||
if(!_loc13_.loader.visible)
|
||||
{
|
||||
_guiLayer.addChild(_loc13_.loader);
|
||||
_loc13_.loader.visible = true;
|
||||
}
|
||||
_loc13_.loader.x += _loc13_.ox;
|
||||
_loc13_.loader.y += _loc13_.oy;
|
||||
}
|
||||
if(_loc13_.ox > 0 && _loc13_.loader.x > _loc13_.tx || _loc13_.ox < 0 && _loc13_.loader.x < _loc13_.tx)
|
||||
{
|
||||
_loc14_ = true;
|
||||
}
|
||||
else if(_loc13_.oy > 0 && _loc13_.loader.y > _loc13_.ty || _loc13_.oy < 0 && _loc13_.loader.y < _loc13_.ty)
|
||||
{
|
||||
_loc14_ = true;
|
||||
}
|
||||
if(_loc14_)
|
||||
{
|
||||
_loc9_ = _gems.indexOf(_loc13_);
|
||||
_gems.splice(_loc9_,1);
|
||||
_loc13_.loader.parent.removeChild(_loc13_.loader);
|
||||
_scene.releaseCloneAsset(_loc13_.loader);
|
||||
_score += _loc13_.points;
|
||||
updateScore();
|
||||
}
|
||||
}
|
||||
if(!_gems.length && _bLevelComplete)
|
||||
{
|
||||
endLevel();
|
||||
}
|
||||
}
|
||||
|
||||
private function launchBall() : void
|
||||
{
|
||||
_bBallInMotion = true;
|
||||
_springOffset = 0;
|
||||
var _loc1_:Number = -(_springForce * 3.7 + 180 + Math.random() * 10);
|
||||
_ballBody.m_force = new b2Vec2(0,_loc1_);
|
||||
_springMode = 4;
|
||||
}
|
||||
|
||||
private function processCollision(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:String = null;
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc4_:int = 0;
|
||||
if(param1 == null || !param1.hasOwnProperty("name"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc7_:int = -1;
|
||||
var _loc3_:int = -1;
|
||||
switch(param1.name)
|
||||
{
|
||||
case "col":
|
||||
_loc2_ = _soundNamePin;
|
||||
break;
|
||||
case "score":
|
||||
_loc7_ = int(param1.message);
|
||||
break;
|
||||
case "jackpot_1":
|
||||
_loc3_ = 0;
|
||||
break;
|
||||
case "jackpot_2":
|
||||
_loc3_ = 1;
|
||||
break;
|
||||
case "jackpot_3":
|
||||
_loc3_ = 2;
|
||||
break;
|
||||
case "ball_catch":
|
||||
_bBallInMotion = false;
|
||||
break;
|
||||
case "ball_inplay":
|
||||
enableEntryBlock(true);
|
||||
}
|
||||
if(_loc3_ >= 0 && !_clearJackpot)
|
||||
{
|
||||
if(!_jackpot[_loc3_])
|
||||
{
|
||||
_jackpot[_loc3_] = true;
|
||||
_loc6_ = true;
|
||||
}
|
||||
refreshJackpotIcons();
|
||||
_loc4_ = 0;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 3)
|
||||
{
|
||||
if(_jackpot[_loc5_] == true)
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
switch(_loc4_ - 1)
|
||||
{
|
||||
case 0:
|
||||
_soundMan.playByName(_soundNameJackpot1);
|
||||
break;
|
||||
case 1:
|
||||
_soundMan.playByName(_soundNameJackpot2);
|
||||
break;
|
||||
case 2:
|
||||
_soundMan.playByName(_soundNameJackpot3);
|
||||
_clearJackpot = true;
|
||||
showJackpotDlg();
|
||||
_jackpotCount = _jackpotCount + 1;
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).custom1UserVarRef,_jackpotCount);
|
||||
_displayAchievementTimer = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc7_ >= 0)
|
||||
{
|
||||
if(_clearJackpot)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 3)
|
||||
{
|
||||
_jackpot[_loc5_] = false;
|
||||
_loc5_++;
|
||||
}
|
||||
refreshJackpotIcons();
|
||||
_clearJackpot = false;
|
||||
}
|
||||
_bBallInMotion = false;
|
||||
_loc2_ = _soundNamePoints;
|
||||
if(_loc7_ > 0)
|
||||
{
|
||||
AddScore(_loc7_);
|
||||
}
|
||||
}
|
||||
if(_loc2_)
|
||||
{
|
||||
_soundMan.playByName(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function enableEntryBlock(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:b2Shape = _volumeBlockEntry.m_shapeList;
|
||||
_loc2_.m_isSensor = !param1;
|
||||
}
|
||||
|
||||
private function onMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
startPullSpring();
|
||||
}
|
||||
|
||||
private function onMouseUp(param1:MouseEvent) : void
|
||||
{
|
||||
releaseSpring();
|
||||
}
|
||||
|
||||
private function onKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(param1.keyCode == 32)
|
||||
{
|
||||
startPullSpring();
|
||||
}
|
||||
}
|
||||
|
||||
private function onKeyUp(param1:KeyboardEvent) : void
|
||||
{
|
||||
if(param1.keyCode == 32)
|
||||
{
|
||||
releaseSpring();
|
||||
}
|
||||
else if(param1.keyCode == 81)
|
||||
{
|
||||
showExitConfirmationDlg();
|
||||
}
|
||||
}
|
||||
|
||||
private function startPullSpring() : void
|
||||
{
|
||||
if(!_bBallInMotion && _balls >= 0 && !_pauseGame && _springStart == 0)
|
||||
{
|
||||
_springStart = getTimer();
|
||||
_springMode = 1;
|
||||
_soundMan.playByName(_soundNamePullSpring);
|
||||
}
|
||||
}
|
||||
|
||||
private function releaseSpring() : void
|
||||
{
|
||||
if(_springStart && _springMode == 1)
|
||||
{
|
||||
_springMode = 2;
|
||||
}
|
||||
}
|
||||
|
||||
private function startLevel() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
_totalGameTime = 0;
|
||||
_jackpotCount = 0;
|
||||
_bLevelComplete = false;
|
||||
_springMode = 0;
|
||||
_score = 0;
|
||||
_balls = 10 - 1;
|
||||
_ballBody.m_userData.loader.visible = true;
|
||||
while(_loc1_ < 3)
|
||||
{
|
||||
_jackpot[_loc1_] = false;
|
||||
_loc1_++;
|
||||
}
|
||||
refreshBallIcons();
|
||||
refreshJackpotIcons();
|
||||
updateScore();
|
||||
}
|
||||
|
||||
private function endLevel() : void
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
var _loc1_:int = 0;
|
||||
showGameOverDlg();
|
||||
for each(_loc2_ in _gems)
|
||||
{
|
||||
_loc1_ = _gems.indexOf(_loc2_);
|
||||
_gems.splice(_loc1_,1);
|
||||
if(_loc2_.loader.parent)
|
||||
{
|
||||
_loc2_.loader.parent.removeChild(_loc2_.loader);
|
||||
}
|
||||
}
|
||||
addGemsToBalance(_score);
|
||||
}
|
||||
|
||||
private function refreshBallIcons() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < 10)
|
||||
{
|
||||
_ballIcon[_loc1_].loader.visible = _loc1_ < _balls;
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function refreshJackpotIcons() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < 3)
|
||||
{
|
||||
if(_jackpot[_loc1_])
|
||||
{
|
||||
_jackpotIcons[_loc1_].loader.content.gotoAndPlay("on");
|
||||
}
|
||||
else
|
||||
{
|
||||
_jackpotIcons[_loc1_].loader.content.gotoAndStop("off");
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function updateScore() : void
|
||||
{
|
||||
_scoreCtrl.loader.content.score.text = _score;
|
||||
}
|
||||
|
||||
public function onGemCloneComplete(param1:Event) : void
|
||||
{
|
||||
param1.target.content.gotoAndPlay("collect");
|
||||
param1.target.removeEventListener("complete",onGemCloneComplete);
|
||||
}
|
||||
|
||||
private function AddScore(param1:int) : void
|
||||
{
|
||||
var _loc8_:Object = _scene.cloneAsset("score_gem");
|
||||
var _loc7_:Loader = _loc8_.loader;
|
||||
_loc8_.loader.contentLoaderInfo.addEventListener("complete",onGemCloneComplete);
|
||||
_loc7_.x = _ballBody.m_userData.loader.x - 10;
|
||||
_loc7_.y = _ballBody.m_userData.loader.y - _loc8_.height / 2;
|
||||
_loc7_.scaleX = 1;
|
||||
_loc7_.scaleY = 1;
|
||||
_loc7_.visible = false;
|
||||
var _loc2_:int = _scoreCtrl.loader.x + _scoreCtrl.loader.width / 2;
|
||||
var _loc4_:int = _loc7_.y - 1;
|
||||
var _loc3_:int = 30;
|
||||
var _loc5_:Number = 0;
|
||||
var _loc6_:Number = (_loc4_ - _loc7_.y) / _loc3_;
|
||||
_loc8_ = {
|
||||
"loader":_loc7_,
|
||||
"ox":_loc5_,
|
||||
"oy":_loc6_,
|
||||
"tx":_loc2_,
|
||||
"ty":_loc4_,
|
||||
"points":param1
|
||||
};
|
||||
_gems.push(_loc8_);
|
||||
}
|
||||
|
||||
private function showExitConfirmationDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("ExitConfirmationDlg",[{
|
||||
"name":"button_yes",
|
||||
"f":onExit_Yes
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_No
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
}
|
||||
|
||||
private function onExit_Yes() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
hideDlg();
|
||||
if(showGemMultiplierDlg(onGemMultiplierDone) == null)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
private function onGemMultiplierDone() : void
|
||||
{
|
||||
hideDlg();
|
||||
exit();
|
||||
}
|
||||
|
||||
private function onExit_No() : void
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function showGameOverDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("pachinko_greatjob",[{
|
||||
"name":"button_yes",
|
||||
"f":GameOverDlg_close
|
||||
},{
|
||||
"name":"button_no",
|
||||
"f":onExit_Yes
|
||||
}]);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.text_score,11432,_score);
|
||||
if(_jackpotPopup)
|
||||
{
|
||||
_jackpotCountdown = 0;
|
||||
JackpotDlg_Heartbeat();
|
||||
}
|
||||
stage.addEventListener("keyDown",replayKeyDown);
|
||||
}
|
||||
|
||||
private function replayKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(param1.keyCode)
|
||||
{
|
||||
case 13:
|
||||
case 32:
|
||||
GameOverDlg_close();
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
case 27:
|
||||
onExit_Yes();
|
||||
}
|
||||
}
|
||||
|
||||
private function GameOverDlg_close() : void
|
||||
{
|
||||
stage.removeEventListener("keyDown",replayKeyDown);
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId != -1)
|
||||
{
|
||||
AchievementXtCommManager.requestSetUserVar(MinigameManager.minigameInfoCache.getMinigameInfo(MinigameManager.minigameInfoCache.currMinigameId).gameCountUserVarRef,1);
|
||||
_displayAchievementTimer = 1;
|
||||
}
|
||||
startLevel();
|
||||
hideDlg();
|
||||
}
|
||||
|
||||
private function showJackpotDlg() : void
|
||||
{
|
||||
var _loc1_:MovieClip = showDlg("pachinko_jackpot",null,0,0,false);
|
||||
_loc1_.x = 450;
|
||||
_loc1_.y = 275;
|
||||
LocalizationManager.translateIdAndInsert(_loc1_.text_score,11432,75);
|
||||
AddScore(75);
|
||||
_jackpotPopup = _loc1_;
|
||||
_jackpotCountdown = 36;
|
||||
}
|
||||
|
||||
private function JackpotDlg_Heartbeat() : void
|
||||
{
|
||||
if(_jackpotCountdown > 0)
|
||||
{
|
||||
_jackpotCountdown = _jackpotCountdown - 1;
|
||||
}
|
||||
if(_jackpotCountdown == 0)
|
||||
{
|
||||
_jackpotPopup.parent.removeChild(_jackpotPopup);
|
||||
_jackpotPopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function disableInput() : void
|
||||
{
|
||||
if(_inputEnabled)
|
||||
{
|
||||
stage.removeEventListener("keyDown",onKeyDown);
|
||||
stage.removeEventListener("keyUp",onKeyUp);
|
||||
stage.removeEventListener("mouseUp",onMouseUp);
|
||||
stage.removeEventListener("mouseDown",onMouseDown);
|
||||
_inputEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function enableInput() : void
|
||||
{
|
||||
if(!_inputEnabled)
|
||||
{
|
||||
stage.addEventListener("keyDown",onKeyDown);
|
||||
stage.addEventListener("keyUp",onKeyUp);
|
||||
stage.addEventListener("mouseUp",onMouseUp);
|
||||
stage.addEventListener("mouseDown",onMouseDown);
|
||||
_inputEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,909 @@
|
||||
package game.parachuteGlider
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarInfo;
|
||||
import avatar.AvatarView;
|
||||
import com.sbi.corelib.math.Collision;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import gskinner.motion.GTween;
|
||||
|
||||
public class ParachuteGliderPlayer
|
||||
{
|
||||
|
||||
private static const MAX_GRAVITY:Number = 300;
|
||||
|
||||
private static const MAX_ACCELERATION:int = 150;
|
||||
|
||||
private static const JUMP_ACCELERATION:int = 225;
|
||||
|
||||
private static const SIDE_ACCELERATION:int = 700;
|
||||
|
||||
private static const MAX_SPEED:int = 150;
|
||||
|
||||
private static const MAX_SIDE_SPEED:int = 200;
|
||||
|
||||
private static const MAX_SIDE_WIND_SPEED:int = 275;
|
||||
|
||||
private static const MAX_WIND_SPEED:int = 150;
|
||||
|
||||
private static const MAX_WIND_DRAG:Number = 5000;
|
||||
|
||||
private static const MAX_WIND_ACCELERATOR:Number = 2500;
|
||||
|
||||
private static const JUMP_HOLD_TIME:Number = 0.15;
|
||||
|
||||
private static const PHANTOM_HOLD_TIME:Number = 0.25;
|
||||
|
||||
private static const HITTYPE_NONE:int = 0;
|
||||
|
||||
private static const HITTYPE_BRANCH:int = 1;
|
||||
|
||||
private static const HITTYPE_PHANTOM:int = 2;
|
||||
|
||||
private static const HITTYPE_WIND:int = 3;
|
||||
|
||||
private static const HITTYPE_LAND:int = 4;
|
||||
|
||||
private static const POLLUTETIMER:Number = 3.5;
|
||||
|
||||
private static const POLLUTETIMER_RETURN_TO_IDLE:Number = 2.25;
|
||||
|
||||
private static const POSITION_UPDATE_TIME:Number = 0.25;
|
||||
|
||||
public var _theGame:ParachuteGlider;
|
||||
|
||||
public var _localPlayer:Boolean;
|
||||
|
||||
public var _netID:int;
|
||||
|
||||
public var _clone:AvatarView;
|
||||
|
||||
public var _updatePositionTimer:Number;
|
||||
|
||||
public var _lastFrameVelocity:Point;
|
||||
|
||||
public var _currentVelocity:Point;
|
||||
|
||||
public var _currentAcceleration:Point;
|
||||
|
||||
public var _serverWindTargetAcceleration:Point;
|
||||
|
||||
public var _serverWindAcceleration:Point;
|
||||
|
||||
public var _serverVelocity:Point;
|
||||
|
||||
public var _serverAcceleration:Point;
|
||||
|
||||
public var _serverPosition:Point;
|
||||
|
||||
public var _serverHitType:int;
|
||||
|
||||
public var _gemCount:int;
|
||||
|
||||
public var _radius:int;
|
||||
|
||||
public var _centerPointOffsetX:int;
|
||||
|
||||
public var _centerPointOffsetY:int;
|
||||
|
||||
public var _waitingForAllLoaded:Boolean;
|
||||
|
||||
private var _parachute:Object;
|
||||
|
||||
private var _parachuteFrame:Sprite;
|
||||
|
||||
private var _dropGems:Object;
|
||||
|
||||
private var _polluteTimer:Number;
|
||||
|
||||
private var _lastTreeBranchHit:Object;
|
||||
|
||||
public var _landed:Boolean;
|
||||
|
||||
private var _landedReceived:int;
|
||||
|
||||
private var _positionHoldTimer:Number;
|
||||
|
||||
public var _progressbar:Object;
|
||||
|
||||
public var _alpha:Number;
|
||||
|
||||
public var _phantomsHit:int;
|
||||
|
||||
public function ParachuteGliderPlayer(param1:ParachuteGlider)
|
||||
{
|
||||
super();
|
||||
_theGame = param1;
|
||||
_lastFrameVelocity = new Point();
|
||||
_currentVelocity = new Point();
|
||||
_currentAcceleration = new Point();
|
||||
_serverVelocity = new Point();
|
||||
_serverWindAcceleration = new Point();
|
||||
_serverWindTargetAcceleration = new Point();
|
||||
_serverAcceleration = new Point();
|
||||
_serverPosition = new Point();
|
||||
_polluteTimer = 0;
|
||||
_landed = false;
|
||||
_landedReceived = 0;
|
||||
_positionHoldTimer = 0;
|
||||
_alpha = 0;
|
||||
_phantomsHit = 0;
|
||||
_radius = 30;
|
||||
_centerPointOffsetX = -20;
|
||||
_centerPointOffsetY = -35;
|
||||
}
|
||||
|
||||
public function preloadAnims(param1:String, param2:int) : void
|
||||
{
|
||||
_waitingForAllLoaded = true;
|
||||
var _loc4_:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(param1,param2);
|
||||
var _loc5_:Avatar = new Avatar();
|
||||
_loc5_.init(_loc4_.perUserAvId,_loc4_.avName,_loc4_.type,_loc4_.colors,_loc4_.customAvId,null,param1);
|
||||
_clone = new AvatarView();
|
||||
_clone.init(_loc5_);
|
||||
var _loc3_:Array = new Array(4);
|
||||
_loc3_[0] = 19;
|
||||
_loc3_[1] = 24;
|
||||
_loc3_[2] = 20;
|
||||
_loc3_[3] = 21;
|
||||
_clone.preloadAnims(_loc3_,redrawCallback);
|
||||
}
|
||||
|
||||
public function init(param1:Array, param2:int, param3:Object, param4:Object) : int
|
||||
{
|
||||
_progressbar = param4;
|
||||
_netID = parseInt(param1[param2++]);
|
||||
_parachute = param3;
|
||||
_parachuteFrame = new Sprite();
|
||||
_parachute.loader.contentLoaderInfo.addEventListener("complete",onParachuteLoaderComplete);
|
||||
_dropGems = _theGame.getScene().cloneAsset("dropGems");
|
||||
_serverPosition.x = parseInt(param1[param2++]);
|
||||
_serverPosition.y = parseInt(param1[param2++]);
|
||||
_serverPosition.y = 300;
|
||||
_clone.x = _serverPosition.x;
|
||||
_clone.y = _serverPosition.y;
|
||||
_serverHitType = 0;
|
||||
_gemCount = 0;
|
||||
_updatePositionTimer = 0;
|
||||
_localPlayer = _theGame.myId == _netID;
|
||||
_alpha = 1;
|
||||
playAnimationState(19);
|
||||
_theGame._layerPlayers.addChild(_dropGems.loader);
|
||||
_parachuteFrame.addChild(_parachute.loader);
|
||||
_theGame._layerPlayers.addChild(_parachuteFrame);
|
||||
_theGame._layerPlayers.addChild(_clone);
|
||||
_updatePositionTimer = 0;
|
||||
return param2;
|
||||
}
|
||||
|
||||
private function redrawCallback(param1:LayerAnim) : void
|
||||
{
|
||||
if(param1 && _clone)
|
||||
{
|
||||
_waitingForAllLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove() : void
|
||||
{
|
||||
if(_dropGems)
|
||||
{
|
||||
if(_dropGems.loader.parent)
|
||||
{
|
||||
_dropGems.loader.parent.removeChild(_dropGems.loader);
|
||||
}
|
||||
_theGame.getScene().releaseCloneAsset(_dropGems.loader);
|
||||
_dropGems = null;
|
||||
}
|
||||
if(_clone && _clone.parent)
|
||||
{
|
||||
_clone.parent.removeChild(_clone);
|
||||
_clone.destroy();
|
||||
_clone = null;
|
||||
}
|
||||
if(_parachute)
|
||||
{
|
||||
if(_parachute.loader.parent)
|
||||
{
|
||||
_parachute.loader.parent.removeChild(_parachute.loader);
|
||||
}
|
||||
_theGame.getScene().releaseCloneAsset(_parachute.loader);
|
||||
_parachute = null;
|
||||
}
|
||||
if(_parachuteFrame && _parachuteFrame.parent)
|
||||
{
|
||||
_parachuteFrame.parent.removeChild(_parachuteFrame);
|
||||
_parachuteFrame = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Number) : void
|
||||
{
|
||||
var _loc9_:int = 0;
|
||||
var _loc20_:* = 0;
|
||||
var _loc21_:* = null;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc8_:Point = null;
|
||||
var _loc18_:Rectangle = null;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc12_:Object = null;
|
||||
var _loc2_:Array = null;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc22_:Boolean = false;
|
||||
var _loc16_:Boolean = false;
|
||||
var _loc11_:Array = null;
|
||||
var _loc3_:Point = null;
|
||||
var _loc4_:Point = null;
|
||||
var _loc7_:Point = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
if(!_waitingForAllLoaded)
|
||||
{
|
||||
_clone.alpha = _alpha;
|
||||
if(!_landed)
|
||||
{
|
||||
if(_landedReceived == 0)
|
||||
{
|
||||
_loc20_ = -1;
|
||||
_loc10_ = false;
|
||||
_loc8_ = new Point();
|
||||
if(_polluteTimer > 2.25)
|
||||
{
|
||||
_polluteTimer -= param1;
|
||||
if(_polluteTimer <= 2.25)
|
||||
{
|
||||
playAnimationState(19);
|
||||
}
|
||||
}
|
||||
else if(_polluteTimer > 0)
|
||||
{
|
||||
_polluteTimer -= param1;
|
||||
}
|
||||
if(_positionHoldTimer > 0)
|
||||
{
|
||||
_positionHoldTimer -= param1;
|
||||
_lastFrameVelocity.x = 0;
|
||||
_lastFrameVelocity.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(_loc21_ in _theGame._winds)
|
||||
{
|
||||
if(_loc21_.clone)
|
||||
{
|
||||
_loc18_ = _loc21_.clone.getBounds(_theGame._layerWinds);
|
||||
if(_serverPosition.x > _loc18_.x && _serverPosition.x < _loc18_.x + _loc18_.width && _serverPosition.y > _loc18_.y && _serverPosition.y < _loc18_.y + _loc18_.height)
|
||||
{
|
||||
if(_loc21_.ySpeed >= 0 || _serverWindAcceleration.y != 0 || _serverPosition.y > _loc18_.y + 50)
|
||||
{
|
||||
if(_serverWindAcceleration.x == 0 && _loc21_.xSpeed != 0 || _serverWindAcceleration.y == 0 && _loc21_.ySpeed != 0)
|
||||
{
|
||||
_loc10_ = true;
|
||||
if(_serverWindAcceleration.x == 0 && _loc21_.xSpeed != 0)
|
||||
{
|
||||
_serverWindTargetAcceleration.x = _loc21_.xSpeed;
|
||||
}
|
||||
if(_serverWindAcceleration.y == 0 && _loc21_.ySpeed != 0)
|
||||
{
|
||||
_serverWindTargetAcceleration.y = _loc21_.ySpeed;
|
||||
}
|
||||
_theGame._soundMan.playByName(_theGame._soundNameWindGust);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_serverWindTargetAcceleration.x > 0)
|
||||
{
|
||||
_serverWindAcceleration.x += 2500 * param1;
|
||||
if(_serverWindAcceleration.x > _serverWindTargetAcceleration.x)
|
||||
{
|
||||
_serverWindAcceleration.x = _serverWindTargetAcceleration.x;
|
||||
_serverWindTargetAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindTargetAcceleration.x < 0)
|
||||
{
|
||||
_serverWindAcceleration.x -= 2500 * param1;
|
||||
if(_serverWindAcceleration.x < _serverWindTargetAcceleration.x)
|
||||
{
|
||||
_serverWindAcceleration.x = _serverWindTargetAcceleration.x;
|
||||
_serverWindTargetAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindAcceleration.x < 0)
|
||||
{
|
||||
_serverWindAcceleration.x += 5000 * param1;
|
||||
if(_serverWindAcceleration.x > 0)
|
||||
{
|
||||
_serverWindAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindAcceleration.x > 0)
|
||||
{
|
||||
_serverWindAcceleration.x -= 5000 * param1;
|
||||
if(_serverWindAcceleration.x < 0)
|
||||
{
|
||||
_serverWindAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
if(_serverWindTargetAcceleration.y > 0)
|
||||
{
|
||||
_serverWindAcceleration.y += 2500 * param1;
|
||||
if(_serverWindAcceleration.y > _serverWindTargetAcceleration.y)
|
||||
{
|
||||
_serverWindAcceleration.y = _serverWindTargetAcceleration.y;
|
||||
_serverWindTargetAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindTargetAcceleration.y < 0)
|
||||
{
|
||||
_serverWindAcceleration.y -= 2500 * param1;
|
||||
if(_serverWindAcceleration.y < _serverWindTargetAcceleration.y)
|
||||
{
|
||||
_serverWindAcceleration.y = _serverWindTargetAcceleration.y;
|
||||
_serverWindTargetAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindAcceleration.y < 0)
|
||||
{
|
||||
_serverWindAcceleration.y += 5000 * param1;
|
||||
if(_serverWindAcceleration.y > 0)
|
||||
{
|
||||
_serverWindAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverWindAcceleration.y > 0)
|
||||
{
|
||||
_serverWindAcceleration.y -= 5000 * param1;
|
||||
if(_serverWindAcceleration.y < 0)
|
||||
{
|
||||
_serverWindAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
if(_serverWindTargetAcceleration.y == 0)
|
||||
{
|
||||
if(_serverAcceleration.y < 150)
|
||||
{
|
||||
_serverAcceleration.y += 300 * param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.y = 0;
|
||||
}
|
||||
_serverVelocity.y += param1 * (_serverAcceleration.y + _serverWindAcceleration.y);
|
||||
if(_serverWindAcceleration.y != 0)
|
||||
{
|
||||
if(_serverVelocity.y > 1.5 * 150)
|
||||
{
|
||||
_serverVelocity.y = 1.5 * 150;
|
||||
}
|
||||
if(_serverVelocity.y < -150)
|
||||
{
|
||||
_serverVelocity.y = -150;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.y > 150)
|
||||
{
|
||||
_serverVelocity.y -= 3 * 300 * param1;
|
||||
if(_serverVelocity.y < 150)
|
||||
{
|
||||
_serverVelocity.y = 150;
|
||||
}
|
||||
}
|
||||
if(_serverAcceleration.x != 0 || _serverWindAcceleration.x != 0)
|
||||
{
|
||||
_serverVelocity.x += param1 * (_serverAcceleration.x + _serverWindAcceleration.x);
|
||||
if(_serverWindAcceleration.x != 0)
|
||||
{
|
||||
if(_serverVelocity.x > 275)
|
||||
{
|
||||
_serverVelocity.x = 275;
|
||||
}
|
||||
else if(_serverVelocity.x < -275)
|
||||
{
|
||||
_serverVelocity.x = -275;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x > 200)
|
||||
{
|
||||
_serverVelocity.x -= 700 * param1;
|
||||
if(_serverVelocity.x < 200)
|
||||
{
|
||||
_serverVelocity.x = 200;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x < -200)
|
||||
{
|
||||
_serverVelocity.x += 700 * param1;
|
||||
if(_serverVelocity.x > -200)
|
||||
{
|
||||
_serverVelocity.x = -200;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x > 0)
|
||||
{
|
||||
_serverVelocity.x -= 700 * param1;
|
||||
if(_serverVelocity.x < 0)
|
||||
{
|
||||
_serverVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
else if(_serverVelocity.x < 0)
|
||||
{
|
||||
_serverVelocity.x += 700 * param1;
|
||||
if(_serverVelocity.x > 0)
|
||||
{
|
||||
_serverVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
_lastFrameVelocity.x = param1 * _serverVelocity.x;
|
||||
_lastFrameVelocity.y = param1 * _serverVelocity.y;
|
||||
}
|
||||
_loc8_.x = _serverPosition.x + _centerPointOffsetX;
|
||||
_loc8_.y = _serverPosition.y + _centerPointOffsetY;
|
||||
if(_lastFrameVelocity.y != 0)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _theGame._treeBranches.length)
|
||||
{
|
||||
if(_theGame._treeBranches[_loc9_].clone && _theGame._treeBranches[_loc9_].enabled && (_loc8_.y + _radius >= _theGame._treeBranches[_loc9_].clone.y && _loc8_.y <= _theGame._treeBranches[_loc9_].clone.y + _theGame._treeBranches[_loc9_].clone.height))
|
||||
{
|
||||
_loc19_ = _theGame.PlayerBranchCollision(_loc8_,_lastFrameVelocity,_radius,_theGame._treeBranches[_loc9_]);
|
||||
if(_loc19_ >= 0)
|
||||
{
|
||||
if(_lastTreeBranchHit != _theGame._treeBranches[_loc9_])
|
||||
{
|
||||
_lastTreeBranchHit = _theGame._treeBranches[_loc9_];
|
||||
if(_lastFrameVelocity.y > 0)
|
||||
{
|
||||
_serverAcceleration.y = -225;
|
||||
if(_serverVelocity.y > 0)
|
||||
{
|
||||
if(_localPlayer)
|
||||
{
|
||||
playAnimationState(24);
|
||||
_loc20_ = _loc9_;
|
||||
_theGame._treeBranches[_loc9_].clone.content.gotoAndPlay("on");
|
||||
if(_theGame._treeBranches[_loc9_].removeAfterHit)
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameCloudSwirl);
|
||||
_theGame._treeBranches[_loc9_].enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_theGame._soundMan.playByName(_theGame._soundNameTreeBranch);
|
||||
}
|
||||
}
|
||||
_serverVelocity.y = -50;
|
||||
_lastFrameVelocity.y *= _loc19_;
|
||||
_positionHoldTimer = 0.15;
|
||||
_serverWindAcceleration.x = 0;
|
||||
_serverWindTargetAcceleration.x = 0;
|
||||
_serverWindAcceleration.y = 0;
|
||||
_serverWindTargetAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.y = 0;
|
||||
_serverVelocity.y = 0;
|
||||
_lastFrameVelocity.y *= _loc19_;
|
||||
_serverWindAcceleration.y = 0;
|
||||
_serverWindTargetAcceleration.y = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(_lastTreeBranchHit == _theGame._treeBranches[_loc9_])
|
||||
{
|
||||
_lastTreeBranchHit = null;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
if(_lastFrameVelocity.x != 0)
|
||||
{
|
||||
_serverPosition.x += _lastFrameVelocity.x;
|
||||
if(_serverPosition.x > 850)
|
||||
{
|
||||
_serverPosition.x = 850;
|
||||
}
|
||||
else if(_serverPosition.x - _radius < 50)
|
||||
{
|
||||
_serverPosition.x = 50 + _radius;
|
||||
}
|
||||
}
|
||||
_serverPosition.y += _lastFrameVelocity.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
_landedReceived = _landedReceived - 1;
|
||||
if(_landedReceived == 0)
|
||||
{
|
||||
setLanded();
|
||||
}
|
||||
}
|
||||
_loc12_ = null;
|
||||
if(_serverVelocity.x != 0)
|
||||
{
|
||||
_parachuteFrame.rotation = 7 * _serverVelocity.x / 200;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.rotation = 0;
|
||||
_parachuteFrame.rotation = 0;
|
||||
}
|
||||
if(_localPlayer)
|
||||
{
|
||||
_loc22_ = false;
|
||||
_loc16_ = false;
|
||||
_clone.x = _serverPosition.x;
|
||||
_clone.y = _serverPosition.y;
|
||||
if(_theGame._ground.clone && _theGame._ground.clone.loader.parent)
|
||||
{
|
||||
_loc8_.x = _serverPosition.x + _centerPointOffsetX;
|
||||
_loc8_.y = _serverPosition.y + _centerPointOffsetY;
|
||||
if(_lastFrameVelocity.y != 0)
|
||||
{
|
||||
if(_loc8_.y + _radius >= _theGame._ground.clone.loader.y)
|
||||
{
|
||||
_loc11_ = _theGame._ground.volumePoints;
|
||||
_loc3_ = new Point();
|
||||
_loc4_ = new Point();
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc11_.length - 1)
|
||||
{
|
||||
_loc3_.x = _loc11_[_loc9_].x + _theGame._ground.clone.loader.x;
|
||||
_loc4_.x = _loc11_[_loc9_ + 1].x + _theGame._ground.clone.loader.x;
|
||||
_loc3_.y = _loc11_[_loc9_].y + _theGame._ground.clone.loader.y;
|
||||
_loc4_.y = _loc11_[_loc9_ + 1].y + _theGame._ground.clone.loader.y;
|
||||
if(Collision.movingCircleVsRay(_loc8_,_radius,_lastFrameVelocity,1,_loc3_,_loc4_) >= 0)
|
||||
{
|
||||
setLanded();
|
||||
_loc22_ = true;
|
||||
break;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var _loc14_:Object in _theGame._gems)
|
||||
{
|
||||
if(_theGame._gems[_loc14_] && _theGame._gems[_loc14_].enabled == true)
|
||||
{
|
||||
_loc15_ = _theGame._gems[_loc14_].centerPointX - (_clone.x + _centerPointOffsetX);
|
||||
_loc17_ = _theGame._gems[_loc14_].centerPointY - (_clone.y + _centerPointOffsetY);
|
||||
_loc13_ = _radius + _theGame._gems[_loc14_].radius;
|
||||
_loc15_ *= _loc15_;
|
||||
_loc17_ *= _loc17_;
|
||||
if(_loc15_ + _loc17_ < _loc13_ * _loc13_)
|
||||
{
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "gem";
|
||||
_loc2_[1] = String(_loc14_);
|
||||
_theGame.messageServer(_loc2_);
|
||||
_theGame.gemPickup(int(_loc14_));
|
||||
_theGame._soundMan.playByName(_theGame._soundNameGemAdded);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_polluteTimer <= 0)
|
||||
{
|
||||
for each(_loc12_ in _theGame._phantoms)
|
||||
{
|
||||
if(_loc12_.clone && _loc12_.clone.content && _loc12_.polluteTimer <= 0)
|
||||
{
|
||||
_loc15_ = _loc12_.clone.x + _loc12_.clone.content.collision.x + _loc12_.clone.content.collision.width / 2 - (_clone.x + _centerPointOffsetX);
|
||||
_loc17_ = _loc12_.clone.y + _loc12_.clone.content.collision.y + _loc12_.clone.content.collision.height / 2 - (_clone.y + _centerPointOffsetY);
|
||||
_loc13_ = _radius + _loc12_.clone.content.collision.width / 2;
|
||||
_loc15_ *= _loc15_;
|
||||
_loc17_ *= _loc17_;
|
||||
if(_loc15_ + _loc17_ < _loc13_ * _loc13_)
|
||||
{
|
||||
setPolluted(_loc12_,false);
|
||||
_loc16_ = true;
|
||||
_theGame._soundMan.playByName(_theGame._soundNamePhantomShock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_serverWindTargetAcceleration.x == 0)
|
||||
{
|
||||
if(_theGame._rightArrowDown)
|
||||
{
|
||||
_serverAcceleration.x = 700;
|
||||
}
|
||||
else if(_theGame._leftArrowDown)
|
||||
{
|
||||
_serverAcceleration.x = -700;
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.x = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverAcceleration.x = 0;
|
||||
}
|
||||
_updatePositionTimer += param1;
|
||||
if(_updatePositionTimer > 0.25 || _loc20_ != -1 || _loc22_ || _loc16_ || _loc10_)
|
||||
{
|
||||
_loc2_ = [];
|
||||
_loc2_[0] = "pos";
|
||||
_loc2_[1] = String(int(_clone.x));
|
||||
_loc2_[2] = String(int(_clone.y));
|
||||
_loc2_[3] = String(int(_serverAcceleration.x));
|
||||
_loc2_[4] = String(int(_serverAcceleration.y));
|
||||
_loc2_[5] = String(int(_serverVelocity.x));
|
||||
_loc2_[6] = String(int(_serverVelocity.y));
|
||||
if(_loc22_)
|
||||
{
|
||||
_loc2_[7] = "4";
|
||||
}
|
||||
else if(_loc10_)
|
||||
{
|
||||
_loc2_[7] = "3";
|
||||
_loc2_[8] = String(int(_serverWindTargetAcceleration.x));
|
||||
_loc2_[9] = String(int(_serverWindTargetAcceleration.y));
|
||||
}
|
||||
else if(_loc16_)
|
||||
{
|
||||
_loc2_[7] = "2";
|
||||
_loc2_[8] = String(_loc12_.phantomID);
|
||||
}
|
||||
else if(_loc20_ != -1)
|
||||
{
|
||||
_loc2_[7] = "1";
|
||||
_loc2_[8] = String(int(_theGame._treeBranches[_loc20_].branchID));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_[7] = "0";
|
||||
}
|
||||
_theGame.messageServer(_loc2_);
|
||||
_updatePositionTimer = 0;
|
||||
}
|
||||
}
|
||||
else if(_landed)
|
||||
{
|
||||
_clone.x = _serverPosition.x;
|
||||
_clone.y = _serverPosition.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = new Point();
|
||||
_loc7_.x = _clone.x;
|
||||
_loc7_.y = _clone.y;
|
||||
_loc5_ = Point.distance(_loc7_,_serverPosition);
|
||||
_currentVelocity.x = _serverPosition.x - _clone.x;
|
||||
_currentVelocity.y = _serverPosition.y - _clone.y;
|
||||
_serverHitType = 0;
|
||||
_loc6_ = 0.2;
|
||||
_clone.x += _currentVelocity.x * _loc6_;
|
||||
_clone.y += _currentVelocity.y * _loc6_;
|
||||
}
|
||||
updateParachute();
|
||||
}
|
||||
else
|
||||
{
|
||||
_clone.rotation = 0;
|
||||
_parachuteFrame.rotation = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function receivePositionData(param1:Array, param2:int) : int
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:* = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc4_:int = 0;
|
||||
_serverPosition.x = int(param1[param2++]);
|
||||
_serverPosition.y = int(param1[param2++]);
|
||||
_serverAcceleration.x = int(param1[param2++]);
|
||||
_serverAcceleration.y = int(param1[param2++]);
|
||||
_serverVelocity.x = int(param1[param2++]);
|
||||
_serverVelocity.y = int(param1[param2++]);
|
||||
_serverHitType = int(param1[param2++]);
|
||||
loop2:
|
||||
switch(_serverHitType - 1)
|
||||
{
|
||||
case 0:
|
||||
_loc4_ = int(param1[param2++]);
|
||||
_positionHoldTimer = 0.15 / 2;
|
||||
playAnimationState(24);
|
||||
_loc6_ = 0;
|
||||
while(true)
|
||||
{
|
||||
if(_loc6_ >= _theGame._treeBranches.length)
|
||||
{
|
||||
break loop2;
|
||||
}
|
||||
if(_loc4_ == _theGame._treeBranches[_loc6_].branchID)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
if(_theGame._treeBranches[_loc6_].clone)
|
||||
{
|
||||
_theGame._treeBranches[_loc6_].clone.content.gotoAndPlay("on");
|
||||
}
|
||||
if(_theGame._treeBranches[_loc6_].removeAfterHit)
|
||||
{
|
||||
_theGame._treeBranches[_loc6_].enabled = false;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_loc6_ = int(param1[param2++]);
|
||||
_loc7_ = false;
|
||||
for each(_loc3_ in _theGame._phantoms)
|
||||
{
|
||||
if(_loc3_.phantomID == _loc6_)
|
||||
{
|
||||
_loc7_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!_loc7_)
|
||||
{
|
||||
_loc3_ = null;
|
||||
}
|
||||
setPolluted(_loc3_,false);
|
||||
break;
|
||||
case 2:
|
||||
_serverWindTargetAcceleration.x = int(param1[param2++]);
|
||||
_serverWindTargetAcceleration.y = int(param1[param2++]);
|
||||
break;
|
||||
case 3:
|
||||
_landedReceived = 3;
|
||||
}
|
||||
return param2;
|
||||
}
|
||||
|
||||
private function updateParachute() : void
|
||||
{
|
||||
if(_parachuteFrame)
|
||||
{
|
||||
_parachuteFrame.x = _clone.x - 112 + _parachute.loader.width / 2;
|
||||
_parachuteFrame.y = _clone.y - 230 + _parachute.loader.height;
|
||||
_parachute.loader.x = -_parachute.loader.width / 2;
|
||||
_parachute.loader.y = -_parachute.loader.height;
|
||||
if(_dropGems)
|
||||
{
|
||||
_dropGems.loader.x = _clone.x - 50;
|
||||
_dropGems.loader.y = _clone.y - 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function playAnimationState(param1:int) : void
|
||||
{
|
||||
var _loc2_:Function = null;
|
||||
var _loc3_:int = 0;
|
||||
switch(param1 - 19)
|
||||
{
|
||||
case 0:
|
||||
if(_parachute.loader.content)
|
||||
{
|
||||
_parachute.loader.content.transition = "Float";
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_parachute.loader.content)
|
||||
{
|
||||
_parachute.loader.content.transition = "Struggle";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(_parachute.loader.content)
|
||||
{
|
||||
_parachute.loader.content.transition = "Land";
|
||||
}
|
||||
_loc2_ = animationAtEnd;
|
||||
break;
|
||||
case 5:
|
||||
_loc3_ = 0;
|
||||
if(_parachute.loader.content)
|
||||
{
|
||||
_parachute.loader.content.transition = "BounceUp";
|
||||
}
|
||||
_loc2_ = animationAtEnd;
|
||||
}
|
||||
_clone.playAnim(param1,false,_loc3_,_loc2_);
|
||||
if(_parachute)
|
||||
{
|
||||
updateParachute();
|
||||
}
|
||||
}
|
||||
|
||||
private function animationAtEnd(param1:LayerAnim, param2:int) : void
|
||||
{
|
||||
if(_clone && param1)
|
||||
{
|
||||
switch(param2 - 21)
|
||||
{
|
||||
case 3:
|
||||
playAnimationState(19);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function receiveGem(param1:int) : void
|
||||
{
|
||||
_gemCount = _gemCount + 1;
|
||||
}
|
||||
|
||||
public function setLanded() : void
|
||||
{
|
||||
_landed = true;
|
||||
new GTween(this,0.5,{"_alpha":0});
|
||||
playAnimationState(21);
|
||||
}
|
||||
|
||||
public function setPolluted(param1:Object, param2:Boolean) : void
|
||||
{
|
||||
_phantomsHit = _phantomsHit + 1;
|
||||
if(!_dropGems.loader.content.dropGems)
|
||||
{
|
||||
_dropGems.loader.content.dropGems = true;
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
_gemCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gemCount -= 3;
|
||||
if(_gemCount < 0)
|
||||
{
|
||||
_gemCount = 0;
|
||||
}
|
||||
}
|
||||
playAnimationState(20);
|
||||
_polluteTimer = 3.5;
|
||||
_positionHoldTimer = 0.25;
|
||||
_serverAcceleration.x = 0;
|
||||
_serverVelocity.x = 0;
|
||||
_serverWindAcceleration.x = 0;
|
||||
_serverWindTargetAcceleration.x = 0;
|
||||
_serverAcceleration.y = 0;
|
||||
_serverVelocity.y = 0;
|
||||
_serverWindAcceleration.y = 0;
|
||||
_serverWindTargetAcceleration.y = 0;
|
||||
if(!param2 && param1)
|
||||
{
|
||||
param1.polluteTimer = 1;
|
||||
if(param1.clone && param1.clone.content)
|
||||
{
|
||||
param1.clone.content.gotoAndPlay("Pollute");
|
||||
param1.clone.content.currentLoop = "Pollute";
|
||||
param1.clone.content.transition = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onParachuteLoaderComplete(param1:Event) : void
|
||||
{
|
||||
param1.target.content.transition = "Float";
|
||||
param1.target.removeEventListener("complete",onParachuteLoaderComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 7925 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user