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,474 @@
|
||||
package game
|
||||
{
|
||||
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.SoundTransform;
|
||||
import flash.utils.getTimer;
|
||||
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;
|
||||
|
||||
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 = [];
|
||||
_gameStartTime = getTimer();
|
||||
}
|
||||
|
||||
public function get activeDlgMC() : MovieClip
|
||||
{
|
||||
return _activeDlgMC;
|
||||
}
|
||||
|
||||
protected function loadScene(param1:String) : void
|
||||
{
|
||||
_sceneName = param1;
|
||||
_gemMultiplierMediaHelper = new MediaHelper();
|
||||
_gemMultiplierMediaHelper.init(1067,gemMultiplierMediaHandler);
|
||||
}
|
||||
|
||||
private function gemMultiplierMediaHandler(param1:MovieClip) : void
|
||||
{
|
||||
_gemMultiplierMC = param1;
|
||||
_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 _loc2_: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 _loc1_:GuiButton in _guiButtons)
|
||||
{
|
||||
_loc1_.release();
|
||||
}
|
||||
_guiButtons = [];
|
||||
if(_scene)
|
||||
{
|
||||
_scene.release();
|
||||
}
|
||||
_gameLoader = null;
|
||||
}
|
||||
|
||||
protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
_scene.removeEventListener("complete",sceneLoaded);
|
||||
param1 = new Event("complete");
|
||||
dispatchEvent(param1);
|
||||
var _loc2_:Array = _scene.getActorList("ActorLayer");
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc2_.length)
|
||||
{
|
||||
_loc3_ = _loc2_[_loc4_];
|
||||
if(_loc3_.s.content is MovieClip)
|
||||
{
|
||||
LocalizationManager.findAllTextfields(_loc3_.s.content);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
_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:Boolean = true) : MovieClip
|
||||
{
|
||||
var _loc4_:MovieClip = null;
|
||||
if(!param3)
|
||||
{
|
||||
_loc4_ = GETDEFINITIONBYNAME(param1);
|
||||
_guiLayer.addChild(_loc4_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_activeDlg != null)
|
||||
{
|
||||
hideDlg();
|
||||
}
|
||||
if(_activeDlg == null)
|
||||
{
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
_pauseGame = true;
|
||||
_loc4_ = GETDEFINITIONBYNAME(param1);
|
||||
_guiLayer.addChild(_loc4_);
|
||||
_activeDlg = new GuiDialog(_loc4_,param2);
|
||||
_activeDlgMC = _loc4_;
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
protected function hideDlg() : void
|
||||
{
|
||||
if(_activeDlg)
|
||||
{
|
||||
_activeDlg.release();
|
||||
_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 _loc5_:MovieClip = GETDEFINITIONBYNAME(param1);
|
||||
_loc5_.x = param2;
|
||||
_loc5_.y = param3;
|
||||
_guiLayer.addChild(_loc5_);
|
||||
var _loc6_:GuiButton = new GuiButton(_loc5_,param4);
|
||||
_guiButtons.push(_loc6_);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
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,57 @@
|
||||
package game
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class GuiButton
|
||||
{
|
||||
|
||||
private var _mc:MovieClip;
|
||||
|
||||
private var _clickFunc:Function;
|
||||
|
||||
public function GuiButton(param1:MovieClip, param2:Function)
|
||||
{
|
||||
super();
|
||||
_mc = param1;
|
||||
_clickFunc = param2;
|
||||
_mc.addEventListener("rollOver",mouseOver);
|
||||
_mc.addEventListener("rollOut",mouseOut);
|
||||
_mc.addEventListener("mouseDown",mouseClick);
|
||||
_mc.gotoAndStop("off");
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
_mc.removeEventListener("rollOver",mouseOver);
|
||||
_mc.removeEventListener("rollOut",mouseOut);
|
||||
_mc.removeEventListener("mouseDown",mouseClick);
|
||||
_mc.parent.removeChild(_mc);
|
||||
_mc = null;
|
||||
}
|
||||
|
||||
private function mouseOver(param1:MouseEvent) : void
|
||||
{
|
||||
if(_mc.currentFrameLabel != "on")
|
||||
{
|
||||
_mc.gotoAndPlay("on");
|
||||
}
|
||||
AJAudio.playHudBtnRollover();
|
||||
}
|
||||
|
||||
private function mouseOut(param1:MouseEvent) : void
|
||||
{
|
||||
if(_mc.currentFrameLabel != "off")
|
||||
{
|
||||
_mc.gotoAndPlay("off");
|
||||
}
|
||||
}
|
||||
|
||||
private function mouseClick(param1:MouseEvent) : void
|
||||
{
|
||||
_clickFunc();
|
||||
AJAudio.playHudBtnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
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 _loc9_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc8_:MovieClip = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc4_:Object = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc3_:GuiButton = null;
|
||||
super();
|
||||
_mc = param1;
|
||||
_buttons = [];
|
||||
while(_loc9_ < param2.length)
|
||||
{
|
||||
_loc5_ = param2[_loc9_];
|
||||
_loc8_ = _mc[_loc5_.name];
|
||||
if(!_loc8_)
|
||||
{
|
||||
_loc7_ = _loc5_.name;
|
||||
_loc4_ = _mc;
|
||||
while(_loc7_.indexOf(".") != -1)
|
||||
{
|
||||
_loc6_ = _loc7_.substring(0,_loc7_.indexOf("."));
|
||||
_loc4_ = _loc4_[_loc6_];
|
||||
_loc7_ = _loc7_.substring(_loc7_.indexOf(".") + 1,_loc7_.length);
|
||||
}
|
||||
_loc8_ = _loc4_[_loc7_];
|
||||
if(!_loc8_)
|
||||
{
|
||||
throw new Error("ERROR: Button Not Found:\" " + _loc5_.name + "\" verify button names across SWF files.");
|
||||
}
|
||||
}
|
||||
_loc3_ = new GuiButton(_loc8_,_loc5_.f);
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < _buttons.length)
|
||||
{
|
||||
_buttons.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,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 _loc2_:Array = null;
|
||||
if(minigameInfo)
|
||||
{
|
||||
_loc2_ = [];
|
||||
for each(var _loc1_:MinigameInfo in minigameInfo)
|
||||
{
|
||||
if(_loc1_.readyForPVP)
|
||||
{
|
||||
_loc2_.push(_loc1_);
|
||||
}
|
||||
}
|
||||
_loc2_.sortOn(["gameDefId"],2 | 0x10);
|
||||
return _loc2_;
|
||||
}
|
||||
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 _loc2_:int = 0;
|
||||
var _loc4_:MinigameInfo = null;
|
||||
var _loc3_:int = 2;
|
||||
var _loc5_:int = parseInt(param1[_loc3_++]);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc5_)
|
||||
{
|
||||
_loc4_ = new MinigameInfo();
|
||||
_loc4_.init(parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),param1[_loc3_++],param1[_loc3_++],parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseFloat(param1[_loc3_++]),null,parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]),parseInt(param1[_loc3_++]));
|
||||
MinigameManager.minigameInfoCache.setMinigameInfo(_loc4_.gameDefId,_loc4_);
|
||||
_loc2_++;
|
||||
}
|
||||
if(_miCallback != null)
|
||||
{
|
||||
_miCallback();
|
||||
_miCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
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;
|
||||
|
||||
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);
|
||||
_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 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 _loc5_:Number = NaN;
|
||||
var _loc7_:SoundTransform = null;
|
||||
var _loc6_:SoundChannel = null;
|
||||
var _loc4_:Sound = _sound[param1];
|
||||
if(_loc4_)
|
||||
{
|
||||
if(SBAudio.isMusicMuted)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = Number(_soundVolume[_loc4_]);
|
||||
}
|
||||
_loc7_ = new SoundTransform(_loc5_,0);
|
||||
if(_soundLimit > 0)
|
||||
{
|
||||
if(_soundsPlaying[_loc4_] >= _soundLimit && param3 == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_loc6_ = _loc4_.play(param2,param3,_loc7_);
|
||||
if(_loc6_)
|
||||
{
|
||||
_soundsPlaying[_loc6_] = _loc4_;
|
||||
_soundsPlaying[_loc4_]++;
|
||||
if(param3 == 0)
|
||||
{
|
||||
_loc6_.addEventListener("soundComplete",soundComplete);
|
||||
}
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
return _loc4_.play(param2,param3,_loc7_);
|
||||
}
|
||||
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 _loc5_:Number = (getTimer() - _lastTimeFadeIn) / 1000;
|
||||
if(_loc5_ >= 1)
|
||||
{
|
||||
_loc5_ = 1;
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeIn);
|
||||
}
|
||||
var _loc2_:Number = _soundVolume[_fadeInStream] * _loc5_;
|
||||
var _loc3_:SoundChannel = _fadeInStream.sc;
|
||||
var _loc4_:SoundTransform = new SoundTransform(_loc2_,0);
|
||||
_fadeInStream.sc.soundTransform = _loc4_;
|
||||
if(_loc5_ == 1)
|
||||
{
|
||||
_fadeInStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function doFadeOut(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Number = (getTimer() - _lastTimeFadeOut) / 1000;
|
||||
if(_loc2_ >= 1)
|
||||
{
|
||||
_loc2_ = 1;
|
||||
gMainFrame.stage.removeEventListener("enterFrame",doFadeOut);
|
||||
}
|
||||
var _loc3_:Number = _soundVolume[_fadeOutStream] * (1 - _loc2_);
|
||||
var _loc4_:SoundTransform = new SoundTransform(_loc3_,0);
|
||||
_fadeOutStream.sc.soundTransform = _loc4_;
|
||||
if(_loc2_ == 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user